UNPKG

@radial-color-picker/angular-color-picker

Version:
1,297 lines 58.9 kB
(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/coercion'), require('@angular/cdk/platform'), require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/animations'), require('@angular/forms'), require('@angular/platform-browser'), require('@angular/common'), require('@angular/platform-browser/animations')) :
    typeof define === 'function' && define.amd ? define('@radial-color-picker/angular-color-picker', ['exports', '@angular/cdk/coercion', '@angular/cdk/platform', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/animations', '@angular/forms', '@angular/platform-browser', '@angular/common', '@angular/platform-browser/animations'], factory) :
    (global = global || self, factory((global['radial-color-picker'] = global['radial-color-picker'] || {}, global['radial-color-picker']['angular-color-picker'] = {}), global.ng.cdk.coercion, global.ng.cdk.platform, global.ng.core, global.rxjs, global.rxjs.operators, global.ng.animations, global.ng.forms, global.ng.platformBrowser, global.ng.common, global.ng.platformBrowser.animations));
}(this, (function (exports, coercion, platform, core, rxjs, operators, animations, forms, platformBrowser, common, animations$1) { 'use strict';

    /*! *****************************************************************************
    Copyright (c) Microsoft Corporation. All rights reserved.
    Licensed under the Apache License, Version 2.0 (the "License"); you may not use
    this file except in compliance with the License. You may obtain a copy of the
    License at http://www.apache.org/licenses/LICENSE-2.0

    THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
    WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
    MERCHANTABLITY OR NON-INFRINGEMENT.

    See the Apache Version 2.0 License for specific language governing permissions
    and limitations under the License.
    ***************************************************************************** */
    /* global Reflect, Promise */

    var extendStatics = function(d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };

    function __extends(d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    }

    var __assign = function() {
        __assign = Object.assign || function __assign(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
            }
            return t;
        };
        return __assign.apply(this, arguments);
    };

    function __rest(s, e) {
        var t = {};
        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
            t[p] = s[p];
        if (s != null && typeof Object.getOwnPropertySymbols === "function")
            for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
                if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                    t[p[i]] = s[p[i]];
            }
        return t;
    }

    function __decorate(decorators, target, key, desc) {
        var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
        if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
        else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
        return c > 3 && r && Object.defineProperty(target, key, r), r;
    }

    function __param(paramIndex, decorator) {
        return function (target, key) { decorator(target, key, paramIndex); }
    }

    function __metadata(metadataKey, metadataValue) {
        if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
    }

    function __awaiter(thisArg, _arguments, P, generator) {
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    }

    function __generator(thisArg, body) {
        var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f) throw new TypeError("Generator is already executing.");
            while (_) try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0: case 1: t = op; break;
                    case 4: _.label++; return { value: op[1], done: false };
                    case 5: _.label++; y = op[1]; op = [0]; continue;
                    case 7: op = _.ops.pop(); _.trys.pop(); continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                        if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                        if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                        if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                        if (t[2]) _.ops.pop();
                        _.trys.pop(); continue;
                }
                op = body.call(thisArg, _);
            } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
            if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
        }
    }

    function __exportStar(m, exports) {
        for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
    }

    function __values(o) {
        var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
        if (m) return m.call(o);
        return {
            next: function () {
                if (o && i >= o.length) o = void 0;
                return { value: o && o[i++], done: !o };
            }
        };
    }

    function __read(o, n) {
        var m = typeof Symbol === "function" && o[Symbol.iterator];
        if (!m) return o;
        var i = m.call(o), r, ar = [], e;
        try {
            while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
        }
        catch (error) { e = { error: error }; }
        finally {
            try {
                if (r && !r.done && (m = i["return"])) m.call(i);
            }
            finally { if (e) throw e.error; }
        }
        return ar;
    }

    function __spread() {
        for (var ar = [], i = 0; i < arguments.length; i++)
            ar = ar.concat(__read(arguments[i]));
        return ar;
    }

    function __spreadArrays() {
        for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
        for (var r = Array(s), k = 0, i = 0; i < il; i++)
            for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
                r[k] = a[j];
        return r;
    };

    function __await(v) {
        return this instanceof __await ? (this.v = v, this) : new __await(v);
    }

    function __asyncGenerator(thisArg, _arguments, generator) {
        if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
        var g = generator.apply(thisArg, _arguments || []), i, q = [];
        return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
        function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
        function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
        function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
        function fulfill(value) { resume("next", value); }
        function reject(value) { resume("throw", value); }
        function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
    }

    function __asyncDelegator(o) {
        var i, p;
        return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
        function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
    }

    function __asyncValues(o) {
        if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
        var m = o[Symbol.asyncIterator], i;
        return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
        function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
        function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
    }

    function __makeTemplateObject(cooked, raw) {
        if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
        return cooked;
    };

    function __importStar(mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
        result.default = mod;
        return result;
    }

    function __importDefault(mod) {
        return (mod && mod.__esModule) ? mod : { default: mod };
    }

    var hexToRgb = function (hex) {
        var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
        var r = parseInt(result[1], 16);
        var g = parseInt(result[2], 16);
        var b = parseInt(result[3], 16);
        return { r: r, g: g, b: b };
    };
    var extractRGB = function (rgb) {
        var result = /^(?:rgb\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\))$/i.exec(rgb);
        var r = parseInt(result[1], 10);
        var g = parseInt(result[2], 10);
        var b = parseInt(result[3], 10);
        return { r: r, g: g, b: b };
    };
    var extractHSL = function (hsl) {
        var result = /^(?:hsl\((\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\))$/i.exec(hsl);
        var h = parseInt(result[1], 10);
        var s = parseInt(result[2], 10);
        var l = parseInt(result[3], 10);
        return { h: h, s: s, l: l };
    };
    /**
     * Converts RGB color model to hexadecimal string.
     *
     * @memberOf Utilities
     *
     * @param r Integer between 0 and 255
     * @param g Integer between 0 and 255
     * @param b Integer between 0 and 255
     *
     * @return 6 char long hex string
    */
    var rgbToHex = function (r, g, b) {
        // tslint:disable-next-line:no-bitwise
        return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
    };
    /**
     * Converts RGB color model to HSL model.
     *
     * @memberOf Utilities
     *
     * @param r Integer between 0 and 255
     * @param g Integer between 0 and 255
     * @param Integer between 0 and 255
     *
     * @return The HSL representation containing the hue (in degrees),
     *                     saturation (in percentage) and luminosity (in percentage) fields.
     */
    var rgbToHsl = function (r, g, b) {
        r = r / 255;
        g = g / 255;
        b = b / 255;
        var h, s;
        var max = Math.max(r, g, b);
        var min = Math.min(r, g, b);
        var l = (max + min) / 2;
        if (max === min) {
            h = s = 0; // achromatic
        }
        else {
            var d = max - min;
            s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
            if (max === r) {
                h = (g - b) / d + (g < b ? 6 : 0);
            }
            if (max === g) {
                h = (b - r) / d + 2;
            }
            if (max === b) {
                h = (r - g) / d + 4;
            }
        }
        return {
            hue: h * 60,
            saturation: s * 100,
            luminosity: l * 100
        };
    };
    /**
     * Converts HSL color model to hexademical string.
     *
     * @memberOf Utilities
     *
     * @param h Integer between 0 and 360
     * @param s Integer between 0 and 100
     * @param l Integer between 0 and 50
     *
     * @return 6 char long hex string
     */
    var hslToHex = function (h, s, l) {
        var colorModel = hslToRgb(h, s, l);
        return rgbToHex(colorModel.red, colorModel.green, colorModel.blue);
    };
    /**
     * Converts HSL color model to RGB model.
     * Shamelessly taken from http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c
     *
     * @memberOf Utilities
     *
     * @param h The hue. Number in the 0-360 range
     * @param s The saturation. Number in the 0-100 range
     * @param l The luminosity. Number in the 0-100 range
     *
     * @return The RGB representation containing the red, green and blue fields
     */
    var hslToRgb = function (h, s, l) {
        var r, g, b;
        h = h / 360;
        s = s / 100;
        l = l / 100;
        if (s === 0) {
            r = g = b = l; // achromatic
        }
        else {
            var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
            var p = 2 * l - q;
            r = _hue2rgb(p, q, h + 1 / 3);
            g = _hue2rgb(p, q, h);
            b = _hue2rgb(p, q, h - 1 / 3);
        }
        return {
            red: Math.round(r * 255),
            green: Math.round(g * 255),
            blue: Math.round(b * 255)
        };
    };
    var _hue2rgb = function (p, q, t) {
        if (t < 0) {
            t += 1;
        }
        if (t > 1) {
            t -= 1;
        }
        if (t < 1 / 6) {
            return p + (q - p) * 6 * t;
        }
        if (t < 1 / 2) {
            return q;
        }
        if (t < 2 / 3) {
            return p + (q - p) * (2 / 3 - t) * 6;
        }
        return p;
    };

    /**
     * Modified version of Lea Verou's
     * {@link https://github.com/leaverou/conic-gradient conic-gradient}.
     *
     * @example
     * paintColorWheelToCanvas(document.querySelector('#canvas'), 250);
     *
     * @param canvas Canvas to paint the color wheel
     * @param size   Color wheel diameter in pixels
     * @returns canvas The passed canvas for easier chaining
     */
    var paintColorWheelToCanvas = function (canvas, size) {
        var half = size / 2;
        var radius = Math.sqrt(2) * half;
        var deg = Math.PI / 180;
        var pi2 = Math.PI * 2;
        canvas.width = canvas.height = size;
        var ctx = canvas.getContext('2d');
        // .02: To prevent empty blank line and corresponding moire
        // only non-alpha colors are cared now
        var thetaOffset = 0.5 * deg + 0.02;
        // Transform coordinate system so that angles start from the top left, like in CSS
        ctx.translate(half, half);
        ctx.rotate(-Math.PI / 2);
        ctx.translate(-half, -half);
        for (var i = 0; i < 360; i += 0.5) {
            ctx.fillStyle = "hsl(" + i + ", 100%, 50%)";
            ctx.beginPath();
            ctx.moveTo(half, half);
            var beginArg = i * deg;
            var endArg = Math.min(pi2, beginArg + thetaOffset);
            ctx.arc(half, half, radius, beginArg, endArg);
            ctx.closePath();
            ctx.fill();
        }
        return canvas;
    };
    /**
     *
     * @param canvas Canvas to paint the color wheel
     * @param diameter Color wheel diameter in pixels
     * @param coefficient Relation between inner white circle outer border and color circle outer border, controls the width of the color gradient path
     * @returns canvas The passed canvas for easier chaining
     */
    var renderColorMap = function (canvas, diameter, coefficient) {
        if (coefficient === void 0) { coefficient = 0.77; }
        canvas.width = canvas.height = diameter;
        var radius = diameter / 2;
        var toRad = (2 * Math.PI) / 360;
        var step = 0.2;
        var aliasing = 1;
        var ctx = canvas.getContext('2d');
        ctx.clearRect(0, 0, diameter, diameter);
        for (var i = 0; i < 360; i += step) {
            var sRad = (i - aliasing) * toRad;
            var eRad = (i + step) * toRad;
            ctx.beginPath();
            ctx.arc(radius, radius, radius / 2, sRad, eRad, false);
            ctx.strokeStyle = 'hsl(' + i + ', 100%, 50%)';
            ctx.lineWidth = radius;
            ctx.closePath();
            ctx.stroke();
        }
        ctx.fillStyle = 'rgb(255, 255, 255)';
        ctx.beginPath();
        ctx.arc(radius, radius, radius * coefficient, 0, Math.PI * 2, true);
        ctx.closePath();
        ctx.fill();
        ctx.strokeStyle = 'rgb(255, 255, 255)';
        ctx.lineWidth = 2;
        ctx.beginPath();
        ctx.arc(radius, radius, radius, 0, 2 * Math.PI);
        ctx.stroke();
        return canvas;
    };

    var Cache = {
        sin90: Math.sin(270 * Math.PI / 180),
        sin180: Math.sin(180 * Math.PI / 180),
        sin270: Math.sin(90 * Math.PI / 180),
        cos90: Math.cos(270 * Math.PI / 180),
        cos180: Math.cos(180 * Math.PI / 180),
        cos270: Math.cos(90 * Math.PI / 180)
    };
    var Quadrant = {
        I: 'q1',
        II: 'q2',
        III: 'q3',
        IV: 'q4'
    };
    var bezierCurves = {
        // Standard easing puts subtle attention at the end of an animation,
        // by giving more time to deceleration than acceleration.It is the most common form of easing.
        standard: 'cubic-bezier(0.4, 0.0, 0.2, 1)',
        // Elements exiting a screen use acceleration easing, where they start at rest and end at peak velocity.
        acc: 'cubic-bezier(0.4, 0.0, 1, 1)',
        // Incoming elements are animated using deceleration easing,
        // which starts a transition at peak velocity(the fastest point of an element’s movement) and ends at rest.
        dec: 'cubic-bezier(0.0, 0.0, 0.2, 1)'
    };
    var timings = {
        simpleMicro: '100ms',
        simpleEnter: '150ms',
        simpleExit: '75ms',
        complexEnter: '250ms',
        complexExit: '200ms',
        largeEnter: '300ms',
        largeExit: '250ms'
    };

    /**
     * Calculates in which quadrant is the point, serves for calculating the right angle.
     *
     * @param point x,y coordinates of client's pointer position
     */
    var calculateQuadrant = function (point) {
        if (point.x > 0) {
            if (point.y > 0) {
                return Quadrant.I;
            }
            else {
                return Quadrant.IV;
            }
        }
        else {
            if (point.y > 0) {
                return Quadrant.II;
            }
            else {
                return Quadrant.III;
            }
        }
    };
    /**
        * Calculates the distance between two points.
        *
        * This variant expects separate x/y values for each point. If you already have
        * the points as array or object use the corresponding methods.
        *
        * @param x1 The X value of the first point.
        * @param y1 The Y value of the first point.
        * @param x2 The X value of the second point.
        * @param y2 The Y value of the second point.
        * @return The distance between the two points.
        */
    var distanceOfSegmentByXYValues = function (x1, y1, x2, y2) {
        return Math.sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
    };
    /**
     * Calculates the angle of rotation
     *
     * @param point x,y coordinates of client's pointer position
     * @param quadrant one of four quarters of the coordinate plane
     */
    var determineCSSRotationAngle = function (point, quadrant) {
        var cx = point.x;
        var cy = point.y;
        var add = 0;
        switch (quadrant) {
            case Quadrant.II:
                add = 270;
                cx = ((point.x * Cache.cos90) - (point.y * Cache.sin90));
                cy = ((point.x * Cache.sin90) + (point.y * Cache.cos90));
                break;
            case Quadrant.III:
                add = 180;
                cx = ((point.x * Cache.cos180) - (point.y * Cache.sin180));
                cy = ((point.x * Cache.sin180) + (point.y * Cache.cos180));
                break;
            case Quadrant.IV:
                add = 90;
                cx = ((point.x * Cache.cos270) - (point.y * Cache.sin270));
                cy = ((point.x * Cache.sin270) + (point.y * Cache.cos270));
                break;
        }
        var rotation = Math.atan((distanceOfSegmentByXYValues(0, cy, cx, cy)) / (distanceOfSegmentByXYValues(0, cy, 0, 0)));
        return (rotation * (180 / Math.PI)) + add;
    };

    var RotatableDirective = /** @class */ (function () {
        function RotatableDirective(el, renderer, platform) {
            this.el = el;
            this.renderer = renderer;
            this.platform = platform;
            this.dragging = false;
            this.rotateStart = new core.EventEmitter();
            this.rotating = new core.EventEmitter();
            this.rotateStop = new core.EventEmitter();
            if (this.platform.IOS || this.platform.ANDROID) {
                this.mouseDownEv = 'touchstart';
                this.mouseUpEv = 'touchend';
                this.mouseMoveEv = 'touchmove';
                this.cancelEv = 'touchcancel';
            }
            else {
                this.mouseDownEv = 'mousedown';
                this.mouseUpEv = 'mouseup';
                this.mouseMoveEv = 'mousemove';
                this.cancelEv = 'mouseout';
            }
        }
        Object.defineProperty(RotatableDirective.prototype, "isDisabled", {
            get: function () {
                return this.disable ? coercion.coerceBooleanProperty(this.disable) : false;
            },
            enumerable: true,
            configurable: true
        });
        RotatableDirective.prototype.ngOnInit = function () {
        };
        RotatableDirective.prototype.ngOnChanges = function (changes) {
            if (changes.angle && changes.angle.currentValue) {
                // console.log(changes.angle.currentValue);
                var angle = changes.angle.currentValue + 90;
                this.renderer.setStyle(this.el.nativeElement, 'transform', "rotate(" + angle + "deg)");
            }
        };
        RotatableDirective.prototype.ngAfterViewInit = function () {
            var _this = this;
            // console.log(this.isDisabled);
            requestAnimationFrame(this.initialRender.bind(this));
            this.rect = this.el.nativeElement.getBoundingClientRect();
            this.mouseUp$ = rxjs.fromEvent(this.el.nativeElement, this.mouseUpEv, { passive: true });
            this.mouseOut$ = rxjs.fromEvent(this.el.nativeElement, this.cancelEv, { passive: true });
            this.mouseDownSub = rxjs.fromEvent(this.el.nativeElement, this.mouseDownEv, { passive: true })
                .pipe(operators.filter(function (val) {
                return _this.active && !_this.isDisabled;
            }))
                .subscribe(function (downEvent) {
                _this.dragging = true;
                _this.rect = _this.el.nativeElement.getBoundingClientRect();
                // console.log('mouse down', downEvent, this.rect);
                _this.point = _this.createPoint(downEvent);
                _this.rotateStart.emit(_this.point);
                _this.applyRotation();
                _this.mouseMoveSub = rxjs.fromEvent(_this.el.nativeElement, _this.mouseMoveEv).pipe(operators.takeUntil(rxjs.merge(_this.mouseOut$, _this.mouseUp$).pipe(operators.tap(function (upEvent) {
                    _this.rect = _this.el.nativeElement.getBoundingClientRect();
                    // console.log('mouse up', upEvent, this.rect);
                    _this.dragging = false;
                    _this.mouseMoveSub.unsubscribe();
                    _this.rotateStop.emit(_this.point);
                })))).subscribe(function (moveEvent) {
                    _this.rect = _this.el.nativeElement.getBoundingClientRect();
                    // console.log('mouse move', moveEvent, this.rect);
                    _this.point = _this.createPoint(moveEvent);
                    // console.log(this.point);
                    _this.applyRotation();
                });
            });
        };
        RotatableDirective.prototype.initialRender = function () {
            var angle = this.angle + 90;
            this.renderer.setStyle(this.el.nativeElement, 'transform', "rotate(" + angle + "deg)");
        };
        RotatableDirective.prototype.rotationRender = function () {
            // console.log(this.rotation);
            this.renderer.setStyle(this.el.nativeElement, 'transform', "rotate(" + this.rotation + "deg)");
        };
        RotatableDirective.prototype.ngOnDestroy = function () {
            if (this.mouseDownSub) {
                this.mouseDownSub.unsubscribe();
            }
            if (this.mouseMoveSub) {
                this.mouseMoveSub.unsubscribe();
            }
            if (this.mouseUpSub) {
                this.mouseUpSub.unsubscribe();
            }
            // console.log('directive destroy');
        };
        RotatableDirective.prototype.applyRotation = function () {
            var quadrant = calculateQuadrant(this.point);
            var rotation = determineCSSRotationAngle(this.point, quadrant);
            // console.log(rotation);
            this.rotating.emit(rotation);
            this.rotation = rotation;
            requestAnimationFrame(this.rotationRender.bind(this));
        };
        RotatableDirective.prototype.createPoint = function (mouseEvent) {
            var point;
            if (mouseEvent.targetTouches) {
                point = {
                    x: this._normalizeX(mouseEvent.targetTouches[0].clientX),
                    y: this._normalizeY(mouseEvent.targetTouches[0].clientY)
                };
            }
            else {
                point = {
                    x: this._normalizeX(mouseEvent.clientX),
                    y: this._normalizeY(mouseEvent.clientY)
                };
            }
            // console.log('point', point);
            return point;
        };
        RotatableDirective.prototype._normalizeX = function (coordX) {
            return coordX - this.rect.left - this.rect.width / 2;
        };
        RotatableDirective.prototype._normalizeY = function (coordY) {
            return ((coordY - this.rect.top) * -1) + this.rect.height / 2;
        };
        RotatableDirective.ctorParameters = function () { return [
            { type: core.ElementRef },
            { type: core.Renderer2 },
            { type: platform.Platform }
        ]; };
        __decorate([
            core.Input()
        ], RotatableDirective.prototype, "angle", void 0);
        __decorate([
            core.Input()
        ], RotatableDirective.prototype, "disable", void 0);
        __decorate([
            core.Input()
        ], RotatableDirective.prototype, "active", void 0);
        __decorate([
            core.Output()
        ], RotatableDirective.prototype, "rotateStart", void 0);
        __decorate([
            core.Output()
        ], RotatableDirective.prototype, "rotating", void 0);
        __decorate([
            core.Output()
        ], RotatableDirective.prototype, "rotateStop", void 0);
        RotatableDirective = __decorate([
            core.Directive({
                selector: '[rcpRotatable]'
            })
        ], RotatableDirective);
        return RotatableDirective;
    }());

    var Animations = {
        buttonAnimation: animations.trigger('buttonAnimation', [
            animations.state('void', animations.style({ transform: 'scale3d(1, 1, 1)' })),
            animations.state('false', animations.style({ transform: 'scale3d(1, 1, 1)' })),
            animations.state('true', animations.style({ transform: 'scale3d(1, 1, 1)' })),
            animations.transition('* => 1', [
                animations.animate('400ms cubic-bezier(0.35, 0, 0.25, 1)', animations.keyframes([
                    animations.style({ transform: 'scale3d(1, 1, 1)', offset: 0 }),
                    animations.style({ transform: 'scale3d(0.8, 0.8, 1)', offset: 0.25 }),
                    animations.style({ transform: 'scale3d(1, 1, 1)', offset: 0.5 }),
                    animations.style({ transform: 'scale3d(1, 1, 1)', offset: 1.0 }),
                ])),
            ])
        ]),
        rippleAnimation: animations.trigger('rippleAnimation', [
            animations.state('void', animations.style({ opacity: 0, transform: 'scale3d(0.8, 0.8, 1)' })),
            animations.state('false', animations.style({ opacity: 0, transform: 'scale3d(0.8, 0.8, 1)' })),
            animations.state('true', animations.style({ opacity: 0, transform: 'scale3d(0.8, 0.8, 1)' })),
            animations.transition('* => 1', [
                animations.query(':self', animations.animate('400ms cubic-bezier(0.35, 0, 0.25, 1)', animations.keyframes([
                    animations.style({ opacity: 0.2, transform: 'scale3d(0.8, 0.8, 1)', offset: 0 }),
                    animations.style({ opacity: 0.2, transform: 'scale3d(0.8, 0.8, 1)', offset: 0.20 }),
                    animations.style({ opacity: 0, borderWidth: 0, transform: 'scale3d({{scale}}, {{scale}}, 1)', offset: 1.0 }),
                ])), {
                    params: {
                        scale: '3.8'
                    }
                })
            ])
        ])
    };
    var AnimationsMeta = {
        knobAnimationEnter: [
            animations.style({ opacity: 1, transform: 'scale3d(1, 1, 1)' }),
            animations.animate('150ms cubic-bezier(0.4, 0.0, 1, 1)', animations.keyframes([
                animations.style({ opacity: 1, transform: 'scale3d(0, 0, 1)', offset: 0 }),
                animations.style({ opacity: 1, transform: 'scale3d(1, 1, 1)', offset: 1.0 }),
            ]))
        ],
        knobAnimationExit: [
            animations.style({ opacity: 0, transform: 'scale3d(0, 0, 1)' }),
            animations.animate('100ms cubic-bezier(0.0, 0.0, 0.2, 1)', animations.keyframes([
                animations.style({ opacity: 1, transform: 'scale3d(1, 1, 1)', offset: 0 }),
                animations.style({ opacity: 1, transform: 'scale3d(0, 0, 1)', offset: 1.0 }),
            ]))
        ],
        gradientAnimationEnter: [
            animations.style({ opacity: 1, transform: 'scale3d(1, 1, 1)' }),
            animations.animate('200ms cubic-bezier(0.4, 0.0, 1, 1)', animations.keyframes([
                animations.style({ opacity: 1, transform: 'scale3d(0, 0, 1)', offset: 0 }),
                animations.style({ opacity: 1, transform: 'scale3d(1, 1, 1)', offset: 1.0 }),
            ]))
        ],
        gradientAnimationExit: [
            animations.style({ opacity: 0, transform: 'scale3d(0, 0, 1)' }),
            animations.animate('150ms cubic-bezier(0.0, 0.0, 0.2, 1)', animations.keyframes([
                animations.style({ opacity: 1, transform: 'scale3d(1, 1, 1)', offset: 0 }),
                animations.style({ opacity: 1, transform: 'scale3d(0, 0, 1)', offset: 1.0 }),
            ]))
        ],
    };

    var RADIAL_COLOR_PICKER_VALUE_ACCESSOR = {
        provide: forms.NG_VALUE_ACCESSOR,
        useExisting: core.forwardRef(function () { return RadialColorPickerComponent; }),
        multi: true
    };
    var nextUniqueId = 0;
    var rgbRegex = /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/;
    var hslRegex = /hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/;
    var RCPLifecycleEvents;
    (function (RCPLifecycleEvents) {
        RCPLifecycleEvents["show"] = "show";
        RCPLifecycleEvents["shown"] = "shown";
        RCPLifecycleEvents["selected"] = "selected";
        RCPLifecycleEvents["hide"] = "hide";
        RCPLifecycleEvents["hidden"] = "hidden";
    })(RCPLifecycleEvents || (RCPLifecycleEvents = {}));
    var RadialColorPickerComponent = /** @class */ (function () {
        function RadialColorPickerComponent(el, renderer, animationBuilder) {
            this.el = el;
            this.renderer = renderer;
            this.animationBuilder = animationBuilder;
            this._uid = "rcp-" + nextUniqueId++;
            this.coefficient = 0.77;
            this.hueValue = 266;
            this.disabled = false;
            this.active = false;
            this.knobState = false;
            this.gradientState = false;
            this._value = 'FF0000';
            this.defaultSize = 300;
            this.colorType = 'hex';
            this.enterAnimation = true;
            this.exitAnimation = true;
            this.selectToChange = false;
            this.collapsed = true;
            this.collapsible = true;
            this.selected = new core.EventEmitter();
            this.colorChange = new core.EventEmitter();
            this.lifecycle = new core.EventEmitter();
        }
        Object.defineProperty(RadialColorPickerComponent.prototype, "isExplicit", {
            get: function () {
                return coercion.coerceBooleanProperty(this.selectToChange);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(RadialColorPickerComponent.prototype, "hasEnterAnimation", {
            get: function () {
                return coercion.coerceBooleanProperty(this.enterAnimation);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(RadialColorPickerComponent.prototype, "hasExitAnimation", {
            get: function () {
                return coercion.coerceBooleanProperty(this.exitAnimation);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(RadialColorPickerComponent.prototype, "isCollapsible", {
            get: function () {
                return coercion.coerceBooleanProperty(this.collapsible);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(RadialColorPickerComponent.prototype, "isCollapsed", {
            get: function () {
                return coercion.coerceBooleanProperty(this.collapsed);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(RadialColorPickerComponent.prototype, "getSize", {
            get: function () {
                return this.size ? this.size : this.defaultSize;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(RadialColorPickerComponent.prototype, "value", {
            get: function () {
                var color = this._value;
                color = '#' + this._value;
                return color;
            },
            set: function (value) {
                var val = value;
                if (value) {
                    if (value instanceof Object) {
                        val = value.value;
                    }
                    this._value = val;
                    if (val.includes('#')) {
                        this._value = val.substring(1);
                        var rgb = hexToRgb(this._value);
                        var hsl = rgbToHsl(rgb.r, rgb.g, rgb.b);
                        this.hueValue = hsl.hue;
                    }
                    else if (val.includes('rgb')) {
                        var color = extractRGB(val);
                        var hsl = rgbToHsl(color.r, color.g, color.b);
                        this._value = rgbToHex(color.r, color.g, color.b);
                        this.hueValue = hsl.hue;
                    }
                    else if (val.includes('hsl')) {
                        var color = extractHSL(val);
                        this._value = hslToHex(color.h, 100, 50);
                        this.hueValue = color.h;
                    }
                    // console.log('set value hue', this.hueValue);
                }
                if (!this.isExplicit) {
                    this.notifyValueChange();
                }
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(RadialColorPickerComponent.prototype, "width", {
            get: function () {
                return this.size ? this.size : this.defaultSize;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(RadialColorPickerComponent.prototype, "height", {
            get: function () {
                return this.size ? this.size : this.defaultSize;
            },
            enumerable: true,
            configurable: true
        });
        RadialColorPickerComponent.prototype.notifyValueChange = function () {
            if (this.onChange) {
                var color = this.value;
                var rgb = hexToRgb(this._value);
                var hsl = rgbToHsl(rgb.r, rgb.g, rgb.b);
                switch (this.colorType) {
                    case 'hex':
                        color = '#' + this._value;
                        break;
                    case 'rgb':
                        color = "rgb(" + rgb.r + ", " + rgb.g + ", " + rgb.b + ")";
                        break;
                    case 'hsl':
                        color = "hsl(" + hsl.hue + ", " + hsl.saturation + "%, " + hsl.luminosity + "%)";
                        break;
                    default:
                        color = '#' + this._value;
                }
                this.onChange(color);
            }
        };
        RadialColorPickerComponent.prototype.writeValue = function (obj) {
            // console.log(obj);
            this.value = obj;
        };
        RadialColorPickerComponent.prototype.registerOnChange = function (fn) {
            this.onChange = fn;
        };
        RadialColorPickerComponent.prototype.registerOnTouched = function (fn) {
            this.onTouched = fn;
        };
        RadialColorPickerComponent.prototype.setDisabledState = function (isDisabled) {
            this.disabled = isDisabled;
        };
        RadialColorPickerComponent.prototype.ngOnInit = function () {
            var rgb = hexToRgb(this._value);
            var hsl = rgbToHsl(rgb.r, rgb.g, rgb.b);
            this.hueValue = hsl.hue;
        };
        RadialColorPickerComponent.prototype.ngOnChanges = function (changes) {
            // console.log(changes);
            if (changes.color && changes.color.currentValue) {
                this.value = changes.color.currentValue;
            }
            if (changes.size && changes.size.currentValue) {
                this.recalculateKnobPosition();
            }
        };
        RadialColorPickerComponent.prototype.ngAfterViewInit = function () {
            this.recalculateKnobPosition();
            this.rect = this.el.nativeElement.getBoundingClientRect();
            // console.log(this.rect);
            renderColorMap(this.canvas.nativeElement, this.getSize);
            // console.log(this.collapsed);
            if (this.isCollapsed) {
                this.introAnimation();
            }
        };
        RadialColorPickerComponent.prototype.open = function () {
            this.introAnimation();
        };
        RadialColorPickerComponent.prototype.close = function () {
            this.outroAnimation();
        };
        RadialColorPickerComponent.prototype.introAnimation = function () {
            var _this = this;
            this.lifecycle.emit(RCPLifecycleEvents.show);
            this.gradientState = true;
            this.createPlayerForGradient(this.hasEnterAnimation);
            this.gradientPlayer.onDone(function () {
                _this.knobState = true;
                _this.createPlayerForKnob(_this.hasEnterAnimation);
                _this.knobPlayer.onDone(function () {
                    _this.active = true;
                    _this.lifecycle.emit(RCPLifecycleEvents.shown);
                });
                if (_this.hasEnterAnimation) {
                    _this.knobPlayer.play();
                }
                else {
                    _this.knobPlayer.finish();
                }
            });
            if (this.hasEnterAnimation) {
                this.gradientPlayer.play();
            }
            else {
                this.gradientPlayer.finish();
            }
        };
        RadialColorPickerComponent.prototype.outroAnimation = function () {
            var _this = this;
            this.lifecycle.emit(RCPLifecycleEvents.hide);
            this.knobState = false;
            this.createPlayerForKnob();
            this.knobPlayer.onDone(function () {
                _this.gradientState = false;
                _this.createPlayerForGradient();
                _this.gradientPlayer.onDone(function () {
                    _this.active = false;
                    _this.lifecycle.emit(RCPLifecycleEvents.hidden);
                });
                if (_this.hasExitAnimation) {
                    _this.gradientPlayer.play();
                }
                else {
                    _this.gradientPlayer.finish();
                }
            });
            if (this.hasExitAnimation) {
                this.knobPlayer.play();
            }
            else {
                this.knobPlayer.finish();
            }
        };
        RadialColorPickerComponent.prototype.onRotate = function (rotation) {
            var hex = hslToHex(this.angleToHue(rotation), 100, 50);
            this.value = hex;
            // console.log('on rotate', this.isExplicit);
            if (!this.isExplicit) {
                this.colorChange.emit("#" + hex);
            }
        };
        RadialColorPickerComponent.prototype.angleToHue = function (rotation) {
            return rotation - 90;
        };
        RadialColorPickerComponent.prototype.recalculateKnobPosition = function () {
            var radius = (this.getSize / 2);
            var innerCircle = radius * this.coefficient;
            var areaSize = radius - innerCircle;
            if (this.knob) {
                var knobRect = this.knob.nativeElement.getBoundingClientRect();
                var knobPosition = radius - (areaSize / 2 + innerCircle) - knobRect.width / 2;
                this.renderer.setStyle(this.knob.nativeElement, 'top', knobPosition + 'px');
            }
        };
        RadialColorPickerComponent.prototype.confirmColor = function ($event) {
            // console.log('confirm color', $event);
            if (!this.isCollapsible) {
                this.selected.emit($event.color);
                this.lifecycle.emit(RCPLifecycleEvents.selected);
                this.notifyValueChange();
                return;
            }
            // is color picker collapsed
            if (this.knobState) {
                this.selected.emit($event.color);
                this.lifecycle.emit(RCPLifecycleEvents.selected);
                this.notifyValueChange();
                this.outroAnimation();
            }
            else {
                this.introAnimation();
            }
        };
        RadialColorPickerComponent.prototype.createPlayerForGradient = function (hasAnimation) {
            if (hasAnimation === void 0) { hasAnimation = true; }
            if (this.gradientPlayer) {
                this.gradientPlayer.destroy();
            }
            var animationFactory;
            if (this.gradientState) {
                animationFactory = this.animationBuilder
                    .build(AnimationsMeta.gradientAnimationEnter);
            }
            else {
                animationFactory = this.animationBuilder
                    .build(AnimationsMeta.gradientAnimationExit);
            }
            this.gradientPlayer = animationFactory.create(this.canvas.nativeElement);
        };
        RadialColorPickerComponent.prototype.createPlayerForKnob = function (hasAnimation) {
            if (hasAnimation === void 0) { hasAnimation = true; }
            if (this.knobPlayer) {
                this.knobPlayer.destroy();
            }
            var animationFactory;
            if (this.knobState) {
                animationFactory = this.animationBuilder
                    .build(AnimationsMeta.knobAnimationEnter);
            }
            else {
                animationFactory = this.animationBuilder
                    .build(AnimationsMeta.knobAnimationExit);
            }
            this.knobPlayer = animationFactory.create(this.knob.nativeElement);
        };
        RadialColorPickerComponent.prototype.ngOnDestroy = function () {
            if (this.knobPlayer) {
                this.knobPlayer.destroy();
            }
            if (this.gradientPlayer) {
                this.gradientPlayer.destroy();
            }
            // console.log('color picker destroy');
        };
        RadialColorPickerComponent.ctorParameters = function () { return [
            { type: core.ElementRef },
            { type: core.Renderer2 },
            { type: animations.AnimationBuilder }
        ]; };
        __decorate([
            core.Input()
        ], RadialColorPickerComponent.prototype, "color", void 0);
        __decorate([
            core.Input()
        ], RadialColorPickerComponent.prototype, "colorType", void 0);
        __decorate([
            core.Input()
        ], RadialColorPickerComponent.prototype, "size", void 0);
        __decorate([
            core.Input()
        ], RadialColorPickerComponent.prototype, "enterAnimation", void 0);
        __decorate([
            core.Input()
        ], RadialColorPickerComponent.prototype, "exitAnimation", void 0);
        __decorate([
            core.Input()
        ], RadialColorPickerComponent.prototype, "selectToChange", void 0);
        __decorate([
            core.Input()
        ], RadialColorPickerComponent.prototype, "collapsed", void 0);
        __decorate([
            core.Input()
        ], RadialColorPickerComponent.prototype, "collapsible", void 0);
        __decorate([
            core.Output()
        ], RadialColorPickerComponent.prototype, "selected", void 0);
        __decorate([
            core.Output()
        ], RadialColorPickerComponent.prototype, "colorChange", void 0);
        __decorate([
            core.Output()
        ], RadialColorPickerComponent.prototype, "lifecycle", void 0);
        __decorate([
            core.ViewChild('canvas', { static: false, read: core.ElementRef })
        ], RadialColorPickerComponent.prototype, "canvas", void 0);
        __decorate([
            core.ViewChild('knob', { static: false, read: core.ElementRef })
        ], RadialColorPickerComponent.prototype, "knob", void 0);
        __decorate([
            core.ViewChild('rotator', { static: false, read: core.ElementRef })
        ], RadialColorPickerComponent.prototype, "rotator", void 0);
        __decorate([
            core.HostBinding('style.width.px')
        ], RadialColorPickerComponent.prototype, "width", null);
        __decorate([
            core.HostBinding('style.height.px')
        ], RadialColorPickerComponent.prototype, "height", null);
        RadialColorPickerComponent = __decorate([
            core.Component({
                selector: 'rcp-radial-color-picker',
                template: "<div class=\"wrapper\">\r\n  <canvas #canvas ></canvas>\r\n  <div class=\"rotator\" #rotator rcpRotatable [disable]=\"disabled\"  [angle]=\"hueValue\" (rotating)=\"onRotate($event)\" [active]=\"active\">\r\n    <div class=\"knob\" #knob></div>\r\n  </div>\r\n  <rcp-color-preview [color]=\"value\" [size]=\"size\" [coefficient]=\"coefficient\" (confirm)=\"confirmColor($event)\"></rcp-color-preview>\r\n</div>\r\n",
                providers: [RADIAL_COLOR_PICKER_VALUE_ACCESSOR],
                styles: ["*{box-sizing:border-box}:host{box-sizing:border-box;display:block;overflow:hidden;border-radius:50%}:host *{box-sizing:border-box}:host .wrapper{position:relative;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;width:100%;height:100%;border-radius:50%}:host .wrapper canvas{position:absolute;z-index:1;top:0;right:0;bottom:0;left:0;opacity:0;border-radius:50%;box-shadow:0 0 5px 0 rgba(0,0,0,.6)}:host .wrapper .rotator{position:absolute;z-index:2;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;-webkit-box-flex:0;flex:0 0 100%;-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column;-webkit-box-pack:center;justify-content:center;width:100%;height:100%;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0);border-radius:50%;-webkit-backface-visibility:hidden;backface-visibility:hidden}:host .wrapper .rotator .knob{position:absolute;z-index:11;width:20px;height:20px;pointer-events:none;opacity:0;border-radius:50%;background-color:#fff;box-shadow:0 0 3px 0 rgba(0,0,0,.6)}"]
            })
        ], RadialColorPickerComponent);
        return RadialColorPickerComponent;
    }());

    var ColorPreviewComponent = /** @class */ (function () {
        function ColorPreviewComponent(sanitizer, el) {
            this.sanitizer = sanitizer;
            this.el = el;
            this.confirm = new core.EventEmitter();
        }
        Object.defineProperty(ColorPreviewComponent.prototype, "width", {
            get: function () {
                return (this.size && this.size < 200) ? '36px' : '70px';
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ColorPreviewComponent.prototype, "height", {
            get: function () {
                return (this.size && this.size < 200) ? '36px' : '70px';
            },
            enumerable: true,
            configurable: true
        });
        ColorPreviewComponent.prototype.onClick = function () {
            this.buttonState = {
                value: true,
                params: {
                    scale: this.relation
                }
            };
            this.rippleState = {
                value: true,
                params: {
                    scale: this.relation
                }
            };
        };
        ColorPreviewComponent.prototype.ngOnInit = function () {
        };
        ColorPreviewComponent.prototype.ngAfterViewInit = function () {
            // console.log(this.size);
            var rect = this.el.nativeElement.getBoundingClientRect();
            var innerCircle = this.size * this.coefficient;
            this.relation = innerCircle / rect.width;
            // console.log('relation', relation);
        };
        ColorPreviewComponent.prototype.ngOnChanges = function (changes) {
            if (changes.color && changes.color.currentValue) {
                this.background = this.sanitizer.bypassSecurityTrustStyle(this.color);
            }
        };
        ColorPreviewComponent.prototype.rippleAnimationDone = function ($event) {
            // console.log($event);
            if ($event.toState) {
                this.rippleState = false;
                this.confirm.emit({
                    color: this.color
                });
            }
        };
        ColorPreviewComponent.prototype.buttonAnimationDone = function ($event) {
            // console.log($event);
            if ($event.toState) {
                this.buttonState = false;
            }
        };
        ColorPreviewComponent.prototype.ngOnDestroy = function () {
            // console.log('color preview destroy');
        };
        ColorPreviewComponent.ctorParameters = function () { return [
            { type: platformBrowser.DomSanitizer },
            { type: core.ElementRef }
        ]; };
        __decorate([
            core.Input()
        ], ColorPreviewComponent.prototype, "coefficient", void 0);
        __decorate([
            core.Input()
        ], ColorPreviewComponent.prototype, "color", void 0);
        __decorate([
            core.Input()
        ], ColorPreviewComponent.prototype, "size", void 0);
        __decorate([
            core.Output()
        ], ColorPreviewComponent.prototype, "confirm", void 0);
        __decorate([
            core.HostBinding('style.width')
        ], ColorPreviewComponent.prototype, "width", null);
        __decorate([
            core.HostBinding('style.height')
        ], ColorPreviewComponent.prototype, "height", null);
        __decorate([
            core.HostListener('click')
        ], ColorPreviewComponent.prototype, "onClick", null);
        ColorPreviewComponent = __decorate([
            core.Component({
                selector: 'rcp-color-preview',
                template: "\r\n<div class=\"color\" [style.background-color]=\"background\" [@buttonAnimation]=\"buttonState\" (@buttonAnimation.done)=\"buttonAnimationDone($event)\"></div>\r\n<div class=\"color-shadow\" [style.border-color]=\"background\" [@rippleAnimation]=\"rippleState\" (@rippleAnimation.done)=\"rippleAnimationDone($event)\"></div>\r\n",
                animations: [
                    Animations.rippleAnimation,
                    Animations.buttonAnimation
                ],
                styles: ["*{box-sizing:border-box}:host{box-sizing:border-box;position:relative;z-index:10}:host *{box-sizing:border-box}:host .color{position:absolute;z-index:12;display:block;width:100%;height:100%;border:6px solid #fff;border-radius:50%;box-shadow:0 0 0 1px #b2b2b2}:host .color-shadow{position:absolute;z-index:11;width:100%;height:100%;border-width:10px;border-style:solid;border-radius:50%}:host.final-state-1{-webkit-transform:translate3d(0,0,0) scale3d(1,1,1);transform:translate3d(0,0,0) scale3d(1,1,1);box-shadow:0 0 1px 6px #fff,0 0 0 7px #b2b2b2}"]
            })
        ], ColorPreviewComponent);
        return ColorPreviewComponent;
    }());

    var RadialColorPickerModule = /** @class */ (function () {
        function RadialColorPickerModule() {
        }
        RadialColorPickerModule = __decorate([
            core.NgModule({
                imports: [
                    common.CommonModule,
                    forms.FormsModule,
                    platformBrowser.BrowserModule,
                    animations$1.BrowserAnimationsModule
                ],
                declarations: [
                    RotatableDirective,
                    ColorPreviewComponent,
                    RadialColorPickerComponent
                ],
                exports: [
                    RotatableDirective,
                    RadialColorPickerComponent
                ]
            })
        ], RadialColorPickerModule);
        return RadialColorPickerModule;
    }());

    exports.Cache = Cache;
    exports.ColorPreviewComponent = ColorPreviewComponent;
    exports.Quadrant = Quadrant;
    exports.RADIAL_COLOR_PICKER_VALUE_ACCESSOR = RADIAL_COLOR_PICKER_VALUE_ACCESSOR;
    exports.RadialColorPickerComponent = RadialColorPickerComponent;
    exports.RadialColorPickerModule = RadialColorPickerModule;
    exports.RotatableDirective = RotatableDirective;
    exports._hue2rgb = _hue2rgb;
    exports.bezierCurves = bezierCurves;
    exports.calculateQuadrant = calculateQuadrant;
    exports.determineCSSRotationAngle = determineCSSRotationAngle;
    exports.distanceOfSegmentByXYValues = distanceOfSegmentByXYValues;
    exports.extractHSL = extractHSL;
    exports.extractRGB = extractRGB;
    exports.hexToRgb = hexToRgb;
    exports.hslToHex = hslToHex;
    exports.hslToRgb = hslToRgb;
    exports.paintColorWheelToCanvas = paintColorWheelToCanvas;
    exports.renderColorMap = renderColorMap;
    exports.rgbToHex = rgbToHex;
    exports.rgbToHsl = rgbToHsl;
    exports.timings = timings;
    exports.ɵa = Animations;

    Object.defineProperty(exports, '__esModule', { value: true });

})));
//# sourceMappingURL=radial-color-picker-angular-color-picker.umd.js.map