@ew-color-picker/utils 2.0.15 → 2.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,21 @@ export declare const extend: <T extends object, U extends object[]>(t: T, ...o:
10
10
  * @param v
11
11
  * @returns
12
12
  */
13
- export declare const toArray: <T>(v: Iterable<T> | ArrayLike<T> | any) => any[];
13
+ export declare function toArray<T>(v: ArrayLike<T> | Iterable<T>): T[];
14
+ export declare function toArray<T>(v: T): T;
15
+ /**
16
+ * 判断对象自身是否拥有某个属性
17
+ * @param v 目标对象
18
+ * @param prop 属性名
19
+ * @returns
20
+ */
21
+ export declare const hasOwn: <T extends object>(v: T, prop: string | number | symbol) => boolean;
22
+ /**
23
+ * 把值包装成数组(数组原样返回)
24
+ * @param v 任意值
25
+ * @returns
26
+ */
27
+ export declare const wrapperArrayValue: <T>(v: T | T[]) => T[];
14
28
  /**
15
29
  * 深度复制,受限于JSON的功能
16
30
  * @param v
@@ -4,10 +4,11 @@ export type SafeCSSStyleDeclaration = {
4
4
  export declare const create: <T extends HTMLElement>(tag: string) => T;
5
5
  export declare const createByTemplate: (temp: string) => DocumentFragment;
6
6
  export declare const hasClass: (el: HTMLElement, className: string) => boolean;
7
- export declare const addClass: (el: HTMLElement, className: string) => void;
8
- export declare const removeClass: (el: HTMLElement, className: string) => void;
7
+ export declare const addClass: (el: HTMLElement, className: string | string[]) => void;
8
+ export declare const removeClass: (el: HTMLElement, className: string | string[]) => void;
9
9
  export declare const isHTMLElement: (el: any) => el is HTMLElement;
10
- export declare const isDom: <T extends HTMLElement>(el: T) => boolean;
10
+ export declare const isDom: (el: any) => el is HTMLElement | HTMLCollection | NodeList;
11
+ export declare const isNode: (v: unknown) => v is Node;
11
12
  export declare const baseSetStyle: (el: HTMLElement, property: string, value: string) => void;
12
13
  export declare const setStyle: (el: HTMLElement, style?: Partial<SafeCSSStyleDeclaration> | string | Array<{
13
14
  prop: string;
@@ -25,6 +26,7 @@ export declare const normalizeClassName: (className?: string | string[]) => stri
25
26
  export declare const $: <T extends HTMLElement>(selector: string, el?: HTMLElement | Document) => T | null;
26
27
  export declare const $$: <T extends HTMLElement>(selector: string, el?: HTMLElement | Document) => NodeListOf<T>;
27
28
  export declare const removeElement: (el: HTMLElement) => void;
29
+ export declare const isRemoveNode: (el: HTMLElement) => boolean;
28
30
  export declare const insertNode: (el: HTMLElement, node: Node | null | undefined, oldNode?: Node | null, beforeNode?: Node | null) => void;
29
31
  export declare const checkContainer: (el: string | HTMLElement | undefined) => HTMLElement;
30
32
  export declare const removeNode: (el: HTMLElement) => void;
@@ -46,8 +48,8 @@ export declare const calculatePanelPosition: (triggerElement: HTMLElement, panel
46
48
  left: number;
47
49
  top: number;
48
50
  };
49
- export declare const on: (el: HTMLElement | Document | Window, type: string, fn: EventListenerOrEventListenerObject, capture?: AddEventListenerOptions) => void;
50
- export declare const off: (el: HTMLElement | Document | Window, type: string, fn: EventListenerOrEventListenerObject, capture?: EventListenerOptions) => void;
51
+ export declare const on: (el: HTMLElement | Document | Window, type: string, fn: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void;
52
+ export declare const off: (el: HTMLElement | Document | Window, type: string, fn: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void;
51
53
  /**
52
54
  * 写入元素内容。
53
55
  * - 字符串:默认按纯文本写入;`html: true` 时按 HTML 解析(存在 XSS 风险,仅限可信内容)
@@ -1,4 +1,5 @@
1
1
  export declare const isBrowser: boolean;
2
+ export declare const isDev: () => boolean;
2
3
  export declare const ua: string | false;
3
4
  export declare const isMobile: false | "" | RegExpMatchArray | null;
4
5
  export declare let supportsPassive: boolean;
@@ -2,6 +2,7 @@ export declare const isNull: <T>(v: T) => v is Extract<T, null>;
2
2
  export declare const isUndefined: <T>(v: T) => v is Extract<T, undefined>;
3
3
  export declare const isString: (v: any) => v is string;
4
4
  export declare const isNumber: (v: any) => v is number;
5
+ export declare const isValidNumber: (v: any) => v is number;
5
6
  export declare const isBoolean: (v: any) => v is boolean;
6
7
  export declare const isFunction: (v: any) => v is Function;
7
8
  export declare const isShallowObject: <T>(v: T) => v is Extract<T, object>;
package/dist/utils.esm.js CHANGED
@@ -141,6 +141,10 @@ var isNull = function (v) { return v === null; };
141
141
  var isUndefined = function (v) { return typeof v === 'undefined'; };
142
142
  var isString = function (v) { return typeof v === 'string'; };
143
143
  var isNumber = function (v) { return typeof v === 'number'; };
144
+ // 排除 NaN 的数值判断,用于需要参与运算的场景
145
+ var isValidNumber = function (v) {
146
+ return typeof v === 'number' && !Number.isNaN(v);
147
+ };
144
148
  var isBoolean = function (v) { return typeof v === 'boolean'; };
145
149
  var isFunction = function (v) { return typeof v === 'function'; };
146
150
  // 对象类型守卫函数
@@ -183,6 +187,8 @@ var objDataTypeList = ["Object", "Array", "RegExp"];
183
187
  var isNotEmptyObject = function (obj) { return isObject(obj) && Object.keys(obj).length > 0; };
184
188
 
185
189
  var isBrowser = typeof window !== 'undefined';
190
+ // 判断是否处于开发环境,true 未定义(如直接跑源码)时安全返回 false
191
+ var isDev = function () { return true; };
186
192
  var ua = isBrowser && navigator.userAgent.toLowerCase();
187
193
  var isMobile = ua && ua.match(/(iPhone|iPod|Android|ios)/i);
188
194
  var supportsPassive = false;
@@ -234,12 +240,7 @@ var extend = function (t) {
234
240
  return _;
235
241
  }
236
242
  };
237
- /**
238
- * 伪数组转换成数组
239
- * @param v
240
- * @returns
241
- */
242
- var toArray = function (v) {
243
+ function toArray(v) {
243
244
  if (!isShallowObject(v)) {
244
245
  return v;
245
246
  }
@@ -249,7 +250,22 @@ var toArray = function (v) {
249
250
  else {
250
251
  return _arrSlice.call(v);
251
252
  }
253
+ }
254
+ /**
255
+ * 判断对象自身是否拥有某个属性
256
+ * @param v 目标对象
257
+ * @param prop 属性名
258
+ * @returns
259
+ */
260
+ var hasOwn = function (v, prop) {
261
+ return _hasOwn.call(v, prop);
252
262
  };
263
+ /**
264
+ * 把值包装成数组(数组原样返回)
265
+ * @param v 任意值
266
+ * @returns
267
+ */
268
+ var wrapperArrayValue = function (v) { return (isArray(v) ? v : [v]); };
253
269
  /**
254
270
  * 深度复制,受限于JSON的功能
255
271
  * @param v
@@ -318,8 +334,7 @@ var hasClass = function (el, className) {
318
334
  return reg.test(el.className);
319
335
  };
320
336
  var addClass = function (el, className) {
321
- // 支持多个类名,用空格分隔
322
- var classNames = className.trim().split(/\s+/);
337
+ var classNames = normalizeClassName(className);
323
338
  for (var _i = 0, classNames_1 = classNames; _i < classNames_1.length; _i++) {
324
339
  var cls = classNames_1[_i];
325
340
  if (cls && !hasClass(el, cls)) {
@@ -330,22 +345,37 @@ var addClass = function (el, className) {
330
345
  }
331
346
  };
332
347
  var removeClass = function (el, className) {
333
- if (!hasClass(el, className)) {
348
+ var classNames = normalizeClassName(className).filter(function (cls) { return hasClass(el, cls); });
349
+ if (classNames.length === 0) {
334
350
  return;
335
351
  }
336
- var reg = new RegExp("(^|\\s)" + className + "(\\s|$)", "g");
337
- el.className = el.className.replace(reg, " ");
352
+ var reg = new RegExp("(^|\\s)(" + classNames.join("|") + ")(\\s|$)", "g");
353
+ el.className = el.className.replace(reg, " ").replace(/\s+/g, " ").trim();
338
354
  };
339
355
  var isHTMLElement = function (el) { return el instanceof HTMLElement; };
340
356
  var isDom = function (el) {
341
- return isShallowObject(HTMLElement)
342
- ? isHTMLElement(el)
343
- : (el &&
344
- isShallowObject(el) &&
345
- el.nodeType === 1 &&
346
- isString(el.nodeName)) ||
347
- el instanceof HTMLCollection ||
348
- el instanceof NodeList;
357
+ // SSR 环境下没有 window/HTMLElement,直接返回 false
358
+ if (typeof window === "undefined") {
359
+ return false;
360
+ }
361
+ if (!el) {
362
+ return false;
363
+ }
364
+ // 逐个判断构造函数是否存在:部分 Node/SSR 环境有 window 但没有
365
+ // HTMLCollection / NodeList 等 DOM 构造函数,直接 instanceof 会抛 ReferenceError
366
+ if (typeof HTMLElement !== "undefined" && el instanceof HTMLElement) {
367
+ return true;
368
+ }
369
+ if (typeof HTMLCollection !== "undefined" && el instanceof HTMLCollection) {
370
+ return true;
371
+ }
372
+ if (typeof NodeList !== "undefined" && el instanceof NodeList) {
373
+ return true;
374
+ }
375
+ return typeof el === "object" && el.nodeType === 1;
376
+ };
377
+ var isNode = function (v) {
378
+ return typeof Node !== "undefined" && v instanceof Node;
349
379
  };
350
380
  var baseSetStyle = function (el, property, value) {
351
381
  var prop = property.startsWith('--') ? property : property.replace(/([A-Z])/g, '-$1').toLowerCase();
@@ -458,6 +488,12 @@ var removeElement = function (el) {
458
488
  el === null || el === void 0 ? void 0 : el.remove();
459
489
  }
460
490
  };
491
+ // 是否可以通过父节点移除该元素
492
+ var isRemoveNode = function (el) {
493
+ return isDom(el) &&
494
+ isDom(el.parentElement) &&
495
+ isFunction(el.parentElement.removeChild);
496
+ };
461
497
  var insertNode = function (el, node, oldNode, beforeNode) {
462
498
  // 组件可能尚未挂载或已销毁,此时没有可插入节点
463
499
  if (!node)
@@ -616,19 +652,30 @@ var calculatePanelPosition = function (triggerElement, panelElement, placement,
616
652
  }
617
653
  return { left: left, top: top };
618
654
  };
619
- var on = function (el, type, fn, capture) {
620
- var useCapture = supportsPassive
621
- ? {
622
- passive: false,
623
- capture: !!capture,
624
- }
625
- : !!capture;
626
- el.addEventListener(type, fn, useCapture);
655
+ var on = function (el, type, fn, options) {
656
+ // 元素、事件名、回调缺失时直接忽略,避免抛错
657
+ if (!el || !type || !fn) {
658
+ return;
659
+ }
660
+ // 传入选项对象时原样转发 signal / once / capture,仅对 passive 做显式默认。
661
+ // 能传选项对象的运行环境必然支持 options 形态,不需要再走 supportsPassive 降级。
662
+ if (typeof options === "object" && options !== null) {
663
+ el.addEventListener(type, fn, __assign({ passive: false }, options));
664
+ return;
665
+ }
666
+ // 布尔值(或不传)保持旧行为;不支持 passive 的旧环境退化为 capture 布尔值
667
+ if (!supportsPassive) {
668
+ el.addEventListener(type, fn, !!options);
669
+ return;
670
+ }
671
+ el.addEventListener(type, fn, { passive: false, capture: !!options });
627
672
  };
628
- var off = function (el, type, fn, capture) {
629
- el.removeEventListener(type, fn, {
630
- capture: !!capture,
631
- });
673
+ var off = function (el, type, fn, options) {
674
+ if (!el || !type || !fn) {
675
+ return;
676
+ }
677
+ // removeEventListener 只关心 capture,布尔值与选项对象都原样转发
678
+ el.removeEventListener(type, fn, options);
632
679
  };
633
680
  /**
634
681
  * 写入元素内容。
@@ -703,7 +750,7 @@ var bindTouchDrag = function (move, end) {
703
750
  off(document, "touchend", handleEnd);
704
751
  end === null || end === void 0 ? void 0 : end();
705
752
  };
706
- on(document, "touchmove", handleMove, { });
753
+ on(document, "touchmove", handleMove, { passive: false });
707
754
  on(document, "touchend", handleEnd);
708
755
  return handleEnd;
709
756
  };
@@ -1800,7 +1847,7 @@ var copyIcon = function (className, size, prefix) {
1800
1847
  return "<svg class=\"".concat(prefix, "color-picker-icon").concat(handleClassName(className), "\" viewBox=\"0 0 24 24\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\"").concat(sizeAttr, "><path d=\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z\"></path></svg>");
1801
1848
  };
1802
1849
 
1803
- var version = "2.0.15" ;
1850
+ var version = "2.0.16" ;
1804
1851
  var tips = [
1805
1852
  "%c ew-color-picker@".concat(version, "%c \u8054\u7CFBQQ\uFF1A854806732 %c \u8054\u7CFB\u5FAE\u4FE1\uFF1Aeveningwater %c github:https://github.com/eveningwater/ew-color-picker %c "),
1806
1853
  "background:#0ca6dc ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff",
@@ -1859,4 +1906,4 @@ function toStyleStr(style) {
1859
1906
  .join(';');
1860
1907
  }
1861
1908
 
1862
- export { $, $$, Animation, ApplyOrder, ewColorPickerConsolePlugin as Console, DEFAULT_PANEL_HEIGHT, DEFAULT_PANEL_MODE, DEFAULT_PANEL_WIDTH, DEFAULT_PREFIX, EventEmitter, EventRegister, JSONClone, PANEL_MODE_SIZES, PLACEMENTS, addClass, ani, applyExtraAttrs, arrowIcon, assert, baseSetStyle, basicDataTypeList, bindMouseDrag, bindTouchDrag, calculatePanelPosition, camelCase, checkContainer, checkIcon, clamp, clearColorCache, clone, cloneColor, close, closeIcon, colorHexToRgba, colorHslaToRgba, colorHsvaToRgba, colorRegExp, colorRegHSL, colorRegHSLA, colorRegRGB, colorRegRGBA, colorRgbaToHex, colorRgbaToHsla, colorRgbaToHsva, colorRgbaToHsvaWithCache, colorToRgba, copyIcon, create, createByTemplate, debounce, downArrowIcon, error, extend, eyedropperIcon, getAnimationType, getAttr, getColorBrightness, getContrastColor, getElementSize, getOffset, getPrefix, getRatio, getRect, getStyle, handleClassName, hasClass, insertNode, isAlphaColor, isArray, isBoolean, isBrowser, isDarkColor, isDeepArray, isDeepObject, isDom, isFunction, isHTMLElement, isMobile, isNotEmptyObject, isNull, isNumber, isObject, isPlacement, isPromise, isRegExp, isShallowObject, isStrictColorFormat, isString, isTextTruncated, isUndefined, isValidColor, log, normalizeClassName, objDataTypeList, off, on, open, parsePlacement, parseRgbaString, removeAllSpace, removeClass, removeElement, removeNode, removeStyle, rgbToHsl, rgbaToHex, setAttr, setContent, setStyle, supportsPassive, throttle, throwError, tips, toArray, toStyleStr, tryErrorHandler, ua, upArrowIcon, warn };
1909
+ export { $, $$, Animation, ApplyOrder, ewColorPickerConsolePlugin as Console, DEFAULT_PANEL_HEIGHT, DEFAULT_PANEL_MODE, DEFAULT_PANEL_WIDTH, DEFAULT_PREFIX, EventEmitter, EventRegister, JSONClone, PANEL_MODE_SIZES, PLACEMENTS, addClass, ani, applyExtraAttrs, arrowIcon, assert, baseSetStyle, basicDataTypeList, bindMouseDrag, bindTouchDrag, calculatePanelPosition, camelCase, checkContainer, checkIcon, clamp, clearColorCache, clone, cloneColor, close, closeIcon, colorHexToRgba, colorHslaToRgba, colorHsvaToRgba, colorRegExp, colorRegHSL, colorRegHSLA, colorRegRGB, colorRegRGBA, colorRgbaToHex, colorRgbaToHsla, colorRgbaToHsva, colorRgbaToHsvaWithCache, colorToRgba, copyIcon, create, createByTemplate, debounce, downArrowIcon, error, extend, eyedropperIcon, getAnimationType, getAttr, getColorBrightness, getContrastColor, getElementSize, getOffset, getPrefix, getRatio, getRect, getStyle, handleClassName, hasClass, hasOwn, insertNode, isAlphaColor, isArray, isBoolean, isBrowser, isDarkColor, isDeepArray, isDeepObject, isDev, isDom, isFunction, isHTMLElement, isMobile, isNode, isNotEmptyObject, isNull, isNumber, isObject, isPlacement, isPromise, isRegExp, isRemoveNode, isShallowObject, isStrictColorFormat, isString, isTextTruncated, isUndefined, isValidColor, isValidNumber, log, normalizeClassName, objDataTypeList, off, on, open, parsePlacement, parseRgbaString, removeAllSpace, removeClass, removeElement, removeNode, removeStyle, rgbToHsl, rgbaToHex, setAttr, setContent, setStyle, supportsPassive, throttle, throwError, tips, toArray, toStyleStr, tryErrorHandler, ua, upArrowIcon, warn, wrapperArrayValue };
package/dist/utils.min.js CHANGED
@@ -1 +1 @@
1
- ((t,e)=>{"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Utils={})})(this,function(o){var i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function R(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||((r=r||Array.prototype.slice.call(e,0,o))[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}function t(){}function s(t){return void 0===t}function c(t){return"string"==typeof t}function j(t){return"number"==typeof t}function a(t){return"object"==typeof t&&!f(t)}function $(t){return"object"===u.call(t).slice(8,-1).toLowerCase()}function r(t){return"array"===u.call(t).slice(8,-1).toLowerCase()}function B(t,e){try{t()}catch(t){d(e)?e(t):l("[ewColorPicker error]: ".concat(t))}}var e={log:t,warn:t,error:t},n=(["warn","error","log"].forEach(function(t){e[t]=function(){}}),e.warn),l=e.error,F=e.log,u=Object.prototype.toString,z=Array.prototype.slice,W=Object.prototype.hasOwnProperty,f=function(t){return null===t},d=function(t){return"function"==typeof t},p="undefined"!=typeof window,h=p&&navigator.userAgent.toLowerCase(),U=h&&h.match(/(iPhone|iPod|Android|ios)/i);if(o.supportsPassive=!1,p)try{var g={};Object.defineProperty(g,"passive",{get:function(){o.supportsPassive=!0}}),window.addEventListener("test-passive",function(){},g)}catch(l){}function _(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(f(t))return{};if(Object.assign)return Object.assign.apply(Object,R([t],e,!1));for(var r=Object(t),o=0,i=e.length;o<i;o++){var a=e[o];if(a)for(var s in a)W.call(a,s)&&(r[s]=a[s])}return r}function q(t){if(!a(t))return t;var e,n=r(t)?[]:{};for(e in t)t.hasOwnProperty(e)&&(n[e]=a(t[e])?q(t[e]):t[e]);return n}function v(t){return t.replace(/\s+/g,"")}function m(t){return t?" ".concat(t):""}function y(t,e){return new RegExp("(^|\\s)"+e+"(\\s|$)").test(t.className)}function w(t){return t instanceof HTMLElement}function b(t,e,n){e=e.startsWith("--")?e:e.replace(/([A-Z])/g,"-$1").toLowerCase(),t.style.setProperty(e,n)}function V(t){return t.replace(/([\:\_\-]+(.))/g,function(t,e,n,r){return r?n.toUpperCase():n}).replace(/^moz([A-Z])/,"Moz$1")}function G(t,e){return(e=void 0===e?document:e).querySelector(t)}function J(t){var e;null!=t&&t.parentElement?null!=(e=null==t?void 0:t.parentElement)&&e.removeChild(t):null!=t&&t.remove()}var Z=function(t){return document.createElement(t)},M=function(n,t,e){if(c(t=void 0===t?{}:t)&&!s(e)){e=j(e)?"".concat(e,"px"):e;b(n,t,e)}else if(Array.isArray(t))t.forEach(function(t){var e=t.prop;b(n,e,t.value)});else for(var r=0,o=Object.entries(t);r<o.length;r++){var i=o[r],a=i[0];b(n,a,i[1])}},C=function(e,n,r){if(!e||!n)return null;"float"===(n=V(n))&&(n="cssFloat");var o=null;return B(function(){var t=(document.defaultView||window).getComputedStyle(e,r);o=e.style[n]||t?t[n]:null}),o||e.style[n]},g=J;function x(t){return t.getBoundingClientRect()}function A(t,e,n,r){r=o.supportsPassive?{passive:!1,capture:!!r}:!!r,t.addEventListener(e,n,r)}function E(t,e,n,r){t.removeEventListener(e,n,{capture:!!r})}var Q=["top","top-start","top-end","bottom","bottom-start","bottom-end","left","left-start","left-end","right","right-start","right-end"];o.ApplyOrder=void 0,(O=o.ApplyOrder||(o.ApplyOrder={})).Pre="pre",O.Post="post",T.prototype.on=function(t,e,n){return void 0===n&&(n=this),this.hasType(t),this.events[t]||(this.events[t]=[]),this.events[t].push([e,n]),this},T.prototype.once=function(r,o,i){var a=this,s=(void 0===i&&(i=this),this.hasType(r),function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];a.off(r,s);var n=o.apply(i,t);if(!0===n)return n});return s.fn=o,this.on(r,s),this},T.prototype.off=function(t,e){if(!t&&!e)return this.events={},this;if(t){if(this.hasType(t),e){var n=this.events[t];if(n)for(var r=n.length;r--;)(n[r][0]===e||n[r][0]&&n[r][0].fn===e)&&n.splice(r,1)}else this.events[t]=[];return this}},T.prototype.trigger=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];this.hasType(t);t=this.events[t];if(t)for(var r=t.length,o=R([],t,!0),i=0;i<r;i++){var a=o[i],s=a[0],a=a[1];if(s&&!0===(s=s.apply(a,e)))return s}},T.prototype.registerType=function(t){var e=this;t.forEach(function(t){e.eventTypes[t]=t})},T.prototype.destroy=function(){this.events={},this.eventTypes={}},T.prototype.hasType=function(t){var e=this.eventTypes;e[t]!==t&&n('[ewColorPicker warning]: EventEmitter has used unknown event type: "'.concat(t,'", should be oneof [')+"".concat(Object.keys(e).map(function(t){return JSON.stringify(t)}))+"]")};var O=T;function T(t){this.events={},this.eventTypes={},this.registerType(t)}k.prototype.destroy=function(){this.removeDOMEvents(),this.events=[]},k.prototype.addDOMEvents=function(){this.handleDOMEvents(A)},k.prototype.removeDOMEvents=function(){this.handleDOMEvents(E)},k.prototype.handleDOMEvents=function(e){var n=this,r=this.wrapper;this.events.forEach(function(t){e(r,t.name,n,!!t.capture)})},k.prototype.handleEvent=function(e){var n=e.type;this.events.some(function(t){return t.name===n&&(t.handler(e),!0)})};var X=k;function k(t,e){this.wrapper=t,this.events=e,this.addDOMEvents()}var P=/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/,K=/[rR][gG][Bb][Aa]?[\(]([\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?),){2}[\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?),?[\s]*(0\.\d{1,2}|1|0)?[\)]{1}/g,Y=/^[rR][gG][Bb][Aa][\(]([\\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)[\\s]*,){3}[\\s]*(1|1.0|0|0?.[0-9]{1,2})[\\s]*[\)]{1}$/,tt=/^[hH][Ss][Ll][\(]([\\s]*(2[0-9][0-9]|360|3[0-5][0-9]|[01]?[0-9][0-9]?)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*)[\)]$/,et=/^[hH][Ss][Ll][Aa][\(]([\\s]*(2[0-9][0-9]|360|3[0-5][0-9]|[01]?[0-9][0-9]?)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*,){2}([\\s]*(1|1.0|0|0?.[0-9]{1,2})[\\s]*)[\)]$/;function nt(t,e){var e=(e=void 0===e?1:e)||1,e=Math.round(10*e)/10,n=t.toLowerCase(),r=t.length,o=[];if(t&&P.test(n)){if(4===r){for(var i="#",a=1;a<r;a++){var s=n.slice(a,a+1);i+=s.concat(s)}n=i}for(var c=1,l=n.length;c<l;c+=2)o.push(parseInt("0X"+n.slice(c,c+2),16));return"rgba(".concat(o.join(", "),", ").concat(e,")")}return v(n)}function rt(t){if(!t||"string"!=typeof t)return{h:0,s:100,v:100,a:1};if(!/^rgba?\(/i.test(t.replace(/\s+/g," ").trim())){var e=L(t);if(!e)return{h:0,s:100,v:100,a:1};t=e}var n,r,o,i,a,s,c,e=t.replace(/\s+/g," ").trim().match(/rgba?\(([^)]+)\)/i);return e?(t=e[1].split(",").map(function(t){return t.trim()}),e=parseFloat(t[0])||0,n=parseFloat(t[1])||0,r=parseFloat(t[2])||0,t=4<=t.length?parseFloat(t[3]):Number.NaN,t=Number.isNaN(t)?1:t,e=e/255,n=n/255,r=r/255,o=(c=Math.max(e,n,r))-Math.min(e,n,r),(a=i=0)!==(s=c)&&(a=o/c),0!=o?(c===e?i=(n-r)/o*60:c===n?i=60*((r-e)/o+2):c===r&&(i=60*((e-n)/o+4)),i<0&&(i+=360)):i=0,c=Math.round(10*t)/10,{h:Math.round(i),s:Math.round(100*a),v:Math.round(100*s),a:c}):{h:0,s:100,v:100,a:1}}var ot={black:"rgba(0, 0, 0, 1)",silver:"rgba(192, 192, 192, 1)",gray:"rgba(128, 128, 128, 1)",white:"rgba(255, 255, 255, 1)",maroon:"rgba(128, 0, 0, 1)",red:"rgba(255, 0, 0, 1)",purple:"rgba(128, 0, 128, 1)",fuchsia:"rgba(255, 0, 255, 1)",green:"rgba(0, 128, 0, 1)",lime:"rgba(0, 255, 0, 1)",olive:"rgba(128, 128, 0, 1)",yellow:"rgba(255, 255, 0, 1)",navy:"rgba(0, 0, 128, 1)",blue:"rgba(0, 0, 255, 1)",teal:"rgba(0, 128, 128, 1)",aqua:"rgba(0, 255, 255, 1)",orange:"rgba(255, 165, 0, 1)",pink:"rgba(255, 192, 203, 1)",brown:"rgba(165, 42, 42, 1)"};function L(t){if(t&&"string"==typeof t){var e=t.trim().toLowerCase();if(ot[e])return ot[e];if(P.test(e))return nt(e).replace(/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*\)/,"rgba($1, $2, $3, $4)");var n=e.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i);if(n)return r=n[1],o=n[2],i=n[3],"rgba(".concat(r,", ").concat(o,", ").concat(i,", 1)");var r,o,i,n=e.match(/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(0|1|0?\.\d+)\s*\)$/i);if(n)return r=n[1],o=n[2],i=n[3],e=n[4],"rgba(".concat(r,", ").concat(o,", ").concat(i,", ").concat(e,")");try{var a=Z("div"),s=(M(a,{"background-color":t}),C(a,"backgroundColor"));if(s&&"rgba(0, 0, 0, 0)"!==s)return s.replace(/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*\)/,"rgba($1, $2, $3, $4)")}catch(t){}}return""}function it(t){t=L(t),t=t.slice(t.indexOf("(")+1,t.lastIndexOf(")")).split(",");return(299*parseInt(t[0])+587*parseInt(t[1])+114*parseInt(t[2]))/1e3}var H=new Map;function at(t){try{var e=t.slice(t.indexOf("(")+1,t.lastIndexOf(")")).split(",");return e.length<3?null:{r:parseInt(e[0]),g:parseInt(e[1]),b:parseInt(e[2]),a:e.length<4?1:parseFloat(e[3])}}catch(t){return null}}var st="origDisplay",S=(D.prototype.saveDisplay=function(){var t=window.getComputedStyle(this.element).display;this.element.dataset[st]=t},D.prototype.restoreDisplay=function(){return this.element.dataset[st]||""},D.prototype.show=function(){var e=this;return new Promise(function(t){M(e.element,{display:e.restoreDisplay()}),t()})},D.prototype.hide=function(){var e=this;return new Promise(function(t){"none"!==e.element.style.display&&e.saveDisplay(),M(e.element,{display:"none"}),t()})},D.prototype.slideDown=function(){var o=this;return new Promise(function(t){M(o.element,{display:o.restoreDisplay(),visibility:"hidden"});var e=C(o.element,"marginTop"),n=C(o.element,"marginBottom"),r=o.element.offsetHeight+parseInt(e)+parseInt(n);M(o.element,{height:"0px",overflow:"hidden",visibility:"visible"}),o.element.offsetHeight,setTimeout(function(){M(o.element,{transition:"height ".concat(o.options.duration,"ms ").concat(o.options.easing),height:"".concat(r,"px")}),setTimeout(function(){M(o.element,{height:"",overflow:"",transition:""}),t()},o.options.duration)},o.options.delay)})},D.prototype.slideUp=function(){var r=this;return new Promise(function(t){"none"!==r.element.style.display&&r.saveDisplay();var e=C(r.element,"marginTop"),n=C(r.element,"marginBottom"),e=r.element.offsetHeight+parseInt(e)+parseInt(n);M(r.element,{height:"".concat(e,"px"),overflow:"hidden"}),r.element.offsetHeight,setTimeout(function(){M(r.element,{height:"0px",transition:"height ".concat(r.options.duration,"ms ").concat(r.options.easing)}),setTimeout(function(){M(r.element,{height:"",overflow:"",transition:"",display:"none"}),t()},r.options.duration)},r.options.delay)})},D.prototype.fadeIn=function(){var t=this;return new Promise(function(n){function r(t){var t=Math.min((t-a)/i,1),e=1-Math.pow(1-t,3);M(o,{opacity:e.toString()}),t<1?requestAnimationFrame(r):(M(o,{opacity:"1"}),n())}var o=t.element,i=t.options.duration,a=(M(o,{display:t.restoreDisplay(),opacity:"0"}),o.offsetHeight,performance.now());requestAnimationFrame(r)})},D.prototype.fadeOut=function(){var t=this;return new Promise(function(n){function r(t){var t=Math.min((t-a)/i,1),e=Math.pow(t,3);M(o,{opacity:(1-e).toString()}),t<1?requestAnimationFrame(r):(M(o,{display:"none",opacity:"0"}),n())}var o=t.element,i=t.options.duration,a=("none"!==o.style.display&&t.saveDisplay(),M(o,{opacity:"1"}),performance.now());requestAnimationFrame(r)})},D);function D(t,e){void 0===e&&(e={}),this.element=t,this.options=i({duration:300,easing:"ease-out",delay:0},e)}var ct={show:function(t,e){return new S(t,{duration:e=void 0===e?300:e}).show()},hide:function(t,e){return new S(t,{duration:e=void 0===e?300:e}).hide()},slideDown:function(t,e){return new S(t,{duration:e=void 0===e?300:e}).slideDown()},slideUp:function(t,e){return new S(t,{duration:e=void 0===e?300:e}).slideUp()},fadeIn:function(t,e){return new S(t,{duration:e=void 0===e?300:e}).fadeIn()},fadeOut:function(t,e){return new S(t,{duration:e=void 0===e?300:e}).fadeOut()}};var N="ew-",lt=["%c ew-color-picker@".concat("2.0.15","%c 联系QQ:854806732 %c 联系微信:eveningwater %c github:https://github.com/eveningwater/ew-color-picker %c "),"background:#0ca6dc ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#ff7878 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:#ff7878 ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#ff7878 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent"],ut=!1,ft=(I.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=_(this.options,this.ewColorPicker.options))},I.prototype.run=function(){ut||(ut=!0,F.apply(void 0,lt))},I.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),t.on&&d(t.on)&&t.on("change",function(t){}),null!=(t=this.run)&&t.call(this)},I.pluginName="ewColorPickerConsole",I);function I(t){this.ewColorPicker=t,this.options={},this.handleOptions(),this.run()}o.$=G,o.$$=function(t,e){return(e=void 0===e?document:e).querySelectorAll(t)},o.Animation=S,o.Console=ft,o.DEFAULT_PANEL_HEIGHT=180,o.DEFAULT_PANEL_MODE="large",o.DEFAULT_PANEL_WIDTH=285,o.DEFAULT_PREFIX=N,o.EventEmitter=O,o.EventRegister=X,o.JSONClone=function(t){return JSON.parse(JSON.stringify(t))},o.PANEL_MODE_SIZES={mini:{width:180,height:140},small:{width:220,height:150},medium:{width:250,height:165},large:{width:285,height:180}},o.PLACEMENTS=Q,o.addClass=function(t,e){for(var n=0,r=e.trim().split(/\s+/);n<r.length;n++){var o,i=r[n];i&&!y(t,i)&&((o=t.className.split(" ").filter(Boolean)).push(i),t.className=o.join(" "))}},o.ani=ct,o.applyExtraAttrs=function(n,e,t){if(void 0===e&&(e={}),void 0===t&&(t={}),!n)return i({},e);Object.keys(t).forEach(function(t){t in e||n.removeAttribute(t)});var r={};return Object.entries(e).forEach(function(t){var e=t[0],t=t[1];f(t)||s(t)||""===t?n.removeAttribute(e):(n.setAttribute(e,String(t)),r[e]=t)}),r},o.arrowIcon=function(t,e,n){void 0===n&&(n=N);e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"";return'<svg t="1717384498630" class="'.concat(n,"color-picker-icon").concat(m(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4234"').concat(e,'><path d="M512 714.666667c-8.533333 0-17.066667-2.133333-23.466667-8.533334l-341.333333-341.333333c-12.8-12.8-12.8-32 0-44.8 12.8-12.8 32-12.8 44.8 0l320 317.866667 317.866667-320c12.8-12.8 32-12.8 44.8 0 12.8 12.8 12.8 32 0 44.8L533.333333 704c-4.266667 8.533333-12.8 10.666667-21.333333 10.666667z" fill="currentColor" p-id="4235"></path></svg>')},o.assert=function(t,e){if(!t)throw new Error(e||"Assertion failed")},o.baseSetStyle=b,o.basicDataTypeList=["Number","String","Function","Undefined","Boolean"],o.bindMouseDrag=function(e,t){function n(t){return e(t)}function r(){E(document,"mousemove",n),E(document,"mouseup",r),null!=t&&t()}return A(document,"mousemove",n),A(document,"mouseup",r),r},o.bindTouchDrag=function(e,t){function n(t){return e(t)}function r(){E(document,"touchmove",n),E(document,"touchend",r),null!=t&&t()}return A(document,"touchmove",n,{}),A(document,"touchend",r),r},o.calculatePanelPosition=function(t,e,n,r){void 0===n&&(n="bottom"),void 0===r&&(r=8);var o=x(t),i=x(e),t=window.innerWidth,e=window.innerHeight,a=0,s=0,n=n.split("-"),c=n[0],l=n[1];switch(c){case"top":s=o.top-i.height-r,a="start"===l?o.left:"end"===l?o.right-i.width:o.left+(o.width-i.width)/2;break;case"bottom":s=o.bottom+r,a="start"===l?o.left:"end"===l?o.right-i.width:o.left+(o.width-i.width)/2;break;case"left":a=o.left-i.width-r,s="start"===l?o.top:"end"===l?o.bottom-i.height:o.top+(o.height-i.height)/2;break;case"right":a=o.right+r,s="start"===l?o.top:"end"===l?o.bottom-i.height:o.top+(o.height-i.height)/2}return s<0&&(s=r),{left:a=(a=a<0?r:a)+i.width>t?t-i.width-r:a,top:s=s+i.height>e?e-i.height-r:s}},o.camelCase=V,o.checkContainer=function(t){return c(t)?G(t)||(n("[ewColorPicker warning]: Cannot find element with selector: ".concat(t)),document.body):w(t)?t:document.body},o.checkIcon=function(t,e,n){void 0===n&&(n=N);e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"";return'<svg class="'.concat(n,"color-picker-icon").concat(m(t),'" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"').concat(e,'><path d="M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path></svg>')},o.clamp=function(t,e,n){return Math.min(Math.max(t,e),n)},o.clearColorCache=function(){},o.clone=q,o.cloneColor=function(t){return i({},t)},o.close=function(t,e,n){n=1e4<(n=void 0===n?300:n)?1e4:n;var r="";switch(t){case"height":r="slideUp";break;case"opacity":r="fadeOut";break;default:r="hide"}return ct[r](e,n)},o.closeIcon=function(t,e,n){void 0===n&&(n=N);e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"";return'<svg t="1690189203554" class="'.concat(n,"color-picker-icon").concat(m(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2272" fill="currentColor"').concat(e,'><path d="M504.224 470.288l207.84-207.84a16 16 0 0 1 22.608 0l11.328 11.328a16 16 0 0 1 0 22.624l-207.84 207.824 207.84 207.84a16 16 0 0 1 0 22.608l-11.328 11.328a16 16 0 0 1-22.624 0l-207.824-207.84-207.84 207.84a16 16 0 0 1-22.608 0l-11.328-11.328a16 16 0 0 1 0-22.624l207.84-207.824-207.84-207.84a16 16 0 0 1 0-22.608l11.328-11.328a16 16 0 0 1 22.624 0l207.824 207.84z" p-id="2273"></path></svg>')},o.colorHexToRgba=nt,o.colorHslaToRgba=function(t){var e,n,r,o,i=t.h,a=t.s/100,s=t.l/100,t=t.a;return 0==a?n=r=o=s:(n=(e=function(t,e,n){return 1<n&&(n-=1),n<0&&(n+=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t})(a=2*s-(s=.5<=s?s+a-s*a:s*(1+a)),s,(i=i/360)+1/3),r=e(a,s,i),o=e(a,s,i-1/3)),t=Math.round(10*t)/10,"rgba(".concat(Math.round(255*n),", ").concat(Math.round(255*r),", ").concat(Math.round(255*o),", ").concat(t,")")},o.colorHsvaToRgba=function(t,e){var n,r,o,i,a=t.a,s=t.h,c=255*t.s/100,t=255*t.v/100;return 0==c?n=r=o=t:(t=s%60*((i=t)-(c=(255-c)*t/255))/60,360===s?(n=i,r=o=0):s<60?(n=i,r=c+t,o=c):s<120?(n=i-t,r=i,o=c):s<180?(r=i,o=(n=c)+t):s<240?(n=c,r=i-t,o=i):s<300?(n=c+t,r=c,o=i):s<360?(r=c,o=(n=i)-t):n=r=o=0),void 0!==e&&0<=e&&e<=1&&(a=e),a=Math.round(10*a)/10,"rgba(".concat(Math.round(n),", ").concat(Math.round(r),", ").concat(Math.round(o),", ").concat(a,")")},o.colorRegExp=P,o.colorRegHSL=tt,o.colorRegHSLA=et,o.colorRegRGB=K,o.colorRegRGBA=Y,o.colorRgbaToHex=function(t){var e,n,r={10:"A",11:"B",12:"C",13:"D",14:"E",15:"F"};return/rgba?/.test(t)?(e=t.replace(/rgba?\(/,"").replace(/\)/,"").replace(/[\s+]/g,"").split(","),n="",e.map(function(t,e){e<=2&&(n+=(e=+t,e=Math.min(Math.round(e),255),t=Math.floor(e/16),""+(r[t]||t)+(r[e%=16]||e)))}),v("#"+n)):t},o.colorRgbaToHsla=function(t){var e,n=(t=t.slice(t.indexOf("(")+1,t.lastIndexOf(")")).split(",")).length<4?1:Number(t[3]),n=Math.round(10*n)/10,r=parseInt(t[0])/255,o=parseInt(t[1])/255,i=parseInt(t[2])/255,t=Math.max(r,o,i),a=Math.min(r,o,i),s=(t+a)/2;if(t===a)e=l=0;else{var c=t-a,l=.5<s?c/(2-t-a):c/(t+a);switch(t){case r:e=(o-i)/c+(i<=o?0:6);break;case o:e=(i-r)/c+2;break;case i:e=(r-o)/c+4}}return{colorStr:v("hsla("+Math.ceil(60*e)+","+Math.ceil(100*l)+"%,"+Math.ceil(100*s)+"%,"+n+")"),colorObj:{h:Math.round(60*e),s:Math.round(100*l),l:Math.round(100*s),a:n}}},o.colorRgbaToHsva=rt,o.colorRgbaToHsvaWithCache=function(t){var e;return H.has(t)?H.get(t):(e=rt(t),H.set(t,e),1e3<H.size&&(t=H.keys().next().value)&&H.delete(t),e)},o.colorToRgba=L,o.copyIcon=function(t,e,n){void 0===n&&(n=N);e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"";return'<svg class="'.concat(n,"color-picker-icon").concat(m(t),'" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"').concat(e,'><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg>')},o.create=Z,o.createByTemplate=function(t){return document.createRange().createContextualFragment(t)},o.debounce=function(r,o,i){void 0===i&&(i=!1);var a=null;return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=i&&!a;a&&clearTimeout(a),a=setTimeout(function(){a=null,i||r.apply(void 0,t)},o),n&&r.apply(void 0,t)}},o.downArrowIcon=function(t,e,n){void 0===n&&(n=N);e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"";return'<svg t="1717384498632" class="'.concat(n,"color-picker-icon").concat(m(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4236"').concat(e,'><path d="M512 714.666667c-8.533333 0-17.066667-2.133333-23.466667-8.533334l-341.333333-341.333333c-12.8-12.8-12.8-32 0-44.8 12.8-12.8 32-12.8 44.8 0l320 317.866667 317.866667-320c12.8-12.8 32-12.8 44.8 0 12.8 12.8 12.8 32 0 44.8L533.333333 704c-4.266667 8.533333-12.8 10.666667-21.333333 10.666667z" fill="currentColor" p-id="4237"></path></svg>')},o.error=l,o.extend=_,o.eyedropperIcon=function(t,e,n){void 0===n&&(n=N);e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"";return'<svg class="'.concat(n,"color-picker-icon").concat(m(t),'" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"').concat(e,'><path d="M17.66 5.41l.92.92-2.69 2.69-.92-.92 2.69-2.69M17.67 3c-.26 0-.51.1-.71.29l-3.12 3.12-1.93-1.91-1.41 1.41 1.42 1.42L3 16.25V21h4.75l8.92-8.92 1.42 1.42 1.41-1.41-1.92-1.92 3.12-3.12c.4-.4.29-.71.29-.71L17.67 3z"></path></svg>')},o.getAnimationType=function(t){return(null==(t=t.options)?void 0:t.togglePickerAnimation)||"default"},o.getAttr=function(t,e){return t.getAttribute(e)},o.getColorBrightness=it,o.getContrastColor=function(t,e,n){var r;return void 0===e&&(e="#333333"),void 0===n&&(n="#ffffff"),(t=t&&L(t))&&(r=at(t))&&.5<.2126*(t=function(t){t=(t*r.a+255*(1-r.a))/255;return t<=.03928?t/12.92:Math.pow((.055+t)/1.055,2.4)})(r.r)+.7152*t(r.g)+.0722*t(r.b)?e:n},o.getElementSize=function(t){return{clientWidth:t.clientWidth,clientHeight:t.clientHeight,offsetWidth:t.offsetWidth,offsetHeight:t.offsetHeight,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight}},o.getOffset=function(t){for(var e=0,n=0;t;)e-=t.offsetLeft,n-=t.offsetTop,t=t.offsetParent;return{left:e,top:n}},o.getPrefix=function(t){t=null==(t=null==t?void 0:t.options)?void 0:t.prefix;return c(t)?t:N},o.getRatio=function(t,e,n,r){void 0===r&&(r=!1);t=Math.max(0,Math.min(1,0<n?(t-e)/n:0));return r?1-t:t},o.getRect=x,o.getStyle=C,o.handleClassName=m,o.hasClass=y,o.insertNode=function(t,e,n,r){e&&(r&&null!=t&&t.contains(r)?t.insertBefore(e,r):n&&null!=t&&t.contains(n)?t.replaceChild(e,n):null!=t&&t.appendChild(e))},o.isAlphaColor=function(t){return!!/^rgba\s*\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*(0|1|0?\.\d+)\s*\)$/i.test(t)||!!/^hsla\s*\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*,\s*(0|1|0?\.\d+)\s*\)$/i.test(t)||!!t.includes("hsva(")||"transparent"===t},o.isArray=r,o.isBoolean=function(t){return"boolean"==typeof t},o.isBrowser=p,o.isDarkColor=function(t){return it(t)<128},o.isDeepArray=function(t){return Array.isArray(t)},o.isDeepObject=function(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)},o.isDom=function(t){return a(HTMLElement)?w(t):t&&a(t)&&1===t.nodeType&&c(t.nodeName)||t instanceof HTMLCollection||t instanceof NodeList},o.isFunction=d,o.isHTMLElement=w,o.isMobile=U,o.isNotEmptyObject=function(t){return $(t)&&0<Object.keys(t).length},o.isNull=f,o.isNumber=j,o.isObject=$,o.isPlacement=function(t){return-1<Q.indexOf(t)},o.isPromise=function(t){return!s(t)&&!f(t)&&d((t=t).then)&&d(t.catch)},o.isRegExp=function(t){return"regexp"===u.call(t).slice(8,-1).toLowerCase()},o.isShallowObject=a,o.isStrictColorFormat=function(t){return!(!t||"string"!=typeof t||!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t)&&!(/^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/.test(t)||/^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*(0|1|0?\.\d+)\s*\)$/.test(t)||/^hsl\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*\)$/.test(t)||/^hsla\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*,\s*(0|1|0?\.\d+)\s*\)$/.test(t)||"transparent"===t))},o.isString=c,o.isTextTruncated=function(t){if(!t||!t.childNodes||!t.childNodes.length)return!1;if("undefined"!=typeof document&&"function"==typeof document.createRange)try{var e=document.createRange();if(e.setStart(t,0),e.setEnd(t,t.childNodes.length),e.getBoundingClientRect().width+(parseInt(C(t,"paddingLeft"),10)||0)+(parseInt(C(t,"paddingRight"),10)||0)>t.offsetWidth)return!0}catch(t){}return t.scrollWidth>t.offsetWidth},o.isUndefined=s,o.isValidColor=function(t){var e="transparent"===t;if(P.test(t))return!0;if(K.test(t)&&!t.includes("rgba"))return!0;if(Y.test(t))return!0;if(tt.test(t)&&!t.includes("hsla"))return!0;if(et.test(t))return!0;if(e)return!0;if("#invalid"===t||"invalid"===t)return!1;if(t.includes("rgb(")&&t.includes(", 0.5)"))return!1;if(t.includes("rgba(")&&!t.includes(", 0.5)")&&!t.includes(", 1)"))return!1;try{var n=document.createElement("div");return M(n,{"background-color":t}),"rgba(0, 0, 0, 0)"!==C(n,"backgroundColor")||e}catch(t){return!1}},o.log=F,o.normalizeClassName=function(t){return t?(r(t)?t:[t]).filter(Boolean):[]},o.objDataTypeList=["Object","Array","RegExp"],o.off=E,o.on=A,o.open=function(t,e,n){n=1e4<(n=void 0===n?300:n)?1e4:n;var r="";switch(t){case"height":r="slideDown";break;case"opacity":r="fadeIn";break;default:r="show"}return ct[r](e,n)},o.parsePlacement=function(t){return{side:(t=t.split("-"))[0],align:t[1]||"center"}},o.parseRgbaString=at,o.removeAllSpace=v,o.removeClass=function(t,e){y(t,e)&&(e=new RegExp("(^|\\s)"+e+"(\\s|$)","g"),t.className=t.className.replace(e," "))},o.removeElement=J,o.removeNode=g,o.removeStyle=function(t,e){for(var n=0,r=e=void 0===e?[]:e;n<r.length;n++){var o=r[n];t.style.removeProperty(o)}},o.rgbToHsl=function(t,e,n){t/=255,e/=255,n/=255;var r=Math.max(t,e,n),o=Math.min(t,e,n),i=0,a=0,s=(r+o)/2;if(r!==o){var c=r-o,a=.5<s?c/(2-r-o):c/(r+o);switch(r){case t:i=(e-n)/c+(e<n?6:0);break;case e:i=(n-t)/c+2;break;case n:i=(t-e)/c+4}i/=6}return{h:360*i,s:100*a,l:100*s}},o.rgbaToHex=function(t){function e(t){return Math.round(t).toString(16).padStart(2,"0")}return"#".concat(e(t.r)).concat(e(t.g)).concat(e(t.b))},o.setAttr=function(t,e){if(a(e))for(var n=0,r=Object.entries(e);n<r.length;n++){var o=r[n],i=o[0];t.setAttribute(i,"".concat(o[1]))}},o.setContent=function(t,e,n){var r=(n=void 0===n?{}:n).html,r=void 0!==r&&r,n=n.clone,n=void 0!==n&&n;t.textContent="","string"==typeof e?r?t.innerHTML=e:t.textContent=e:t.appendChild(n?e.cloneNode(!0):e)},o.setStyle=M,o.throttle=function(n,r){var o;return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];o||(n.apply(void 0,t),o=!0,setTimeout(function(){return o=!1},r))}},o.throwError=function(t){throw new Error("[ewColorPicker error]: ".concat(t))},o.tips=lt,o.toArray=function(t){return a(t)?Array.from?Array.from(t):z.call(t):t},o.toStyleStr=function(t){return t?c(t)?t:Object.entries(t).map(function(t){var e=t[0],t=t[1];return"".concat(e.replace(/([A-Z])/g,"-$1").toLowerCase(),":").concat(t)}).join(";"):""},o.tryErrorHandler=B,o.ua=h,o.upArrowIcon=function(t,e,n){void 0===n&&(n=N);e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"";return'<svg t="1717384498631" class="'.concat(n,"color-picker-icon").concat(m(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4235"').concat(e,'><path d="M512 309.333333c8.533333 0 17.066667 2.133333 23.466667 8.533334l341.333333 341.333333c12.8 12.8 12.8 32 0 44.8-12.8 12.8-32 12.8-44.8 0L533.333333 374.4 215.466667 692.266667c-12.8 12.8-32 12.8-44.8 0-12.8-12.8-12.8-32 0-44.8L488.533333 317.866667c4.266667-8.533333 12.8-10.666667 21.333334-10.666667z" fill="currentColor" p-id="4236"></path></svg>')},o.warn=n});
1
+ ((t,e)=>{"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Utils={})})(this,function(o){var i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function j(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||((r=r||Array.prototype.slice.call(e,0,o))[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}function t(){}function s(t){return void 0===t}function c(t){return"string"==typeof t}function R(t){return"number"==typeof t}function a(t){return"object"==typeof t&&!l(t)}function $(t){return"object"===u.call(t).slice(8,-1).toLowerCase()}function B(t,e){try{t()}catch(t){f(e)?e(t):r("[ewColorPicker error]: ".concat(t))}}var e={log:t,warn:t,error:t},n=(["warn","error","log"].forEach(function(t){e[t]=function(){}}),e.warn),r=e.error,F=e.log,u=Object.prototype.toString,z=Array.prototype.slice,W=Object.prototype.hasOwnProperty,l=function(t){return null===t},f=function(t){return"function"==typeof t},d=function(t){return"array"===u.call(t).slice(8,-1).toLowerCase()},p="undefined"!=typeof window,h=p&&navigator.userAgent.toLowerCase(),U=h&&h.match(/(iPhone|iPod|Android|ios)/i);if(o.supportsPassive=!1,p)try{var g={};Object.defineProperty(g,"passive",{get:function(){o.supportsPassive=!0}}),window.addEventListener("test-passive",function(){},g)}catch(r){}function _(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(l(t))return{};if(Object.assign)return Object.assign.apply(Object,j([t],e,!1));for(var r=Object(t),o=0,i=e.length;o<i;o++){var a=e[o];if(a)for(var s in a)W.call(a,s)&&(r[s]=a[s])}return r}function V(t){if(!a(t))return t;var e,n=d(t)?[]:{};for(e in t)t.hasOwnProperty(e)&&(n[e]=a(t[e])?V(t[e]):t[e]);return n}function v(t){return t.replace(/\s+/g,"")}function m(t){return t?" ".concat(t):""}function y(t,e){return new RegExp("(^|\\s)"+e+"(\\s|$)").test(t.className)}function q(t){return t instanceof HTMLElement}function w(t){return"undefined"!=typeof window&&!!t&&("undefined"!=typeof HTMLElement&&t instanceof HTMLElement||"undefined"!=typeof HTMLCollection&&t instanceof HTMLCollection||"undefined"!=typeof NodeList&&t instanceof NodeList||"object"==typeof t&&1===t.nodeType)}function b(t,e,n){e=e.startsWith("--")?e:e.replace(/([A-Z])/g,"-$1").toLowerCase(),t.style.setProperty(e,n)}function G(t){return t.replace(/([\:\_\-]+(.))/g,function(t,e,n,r){return r?n.toUpperCase():n}).replace(/^moz([A-Z])/,"Moz$1")}function M(t){return t?(d(t)?t:[t]).filter(Boolean):[]}function J(t,e){return(e=void 0===e?document:e).querySelector(t)}function Z(t){var e;null!=t&&t.parentElement?null!=(e=null==t?void 0:t.parentElement)&&e.removeChild(t):null!=t&&t.remove()}var Q=function(t){return document.createElement(t)},C=function(n,t,e){if(c(t=void 0===t?{}:t)&&!s(e)){e=R(e)?"".concat(e,"px"):e;b(n,t,e)}else if(Array.isArray(t))t.forEach(function(t){var e=t.prop;b(n,e,t.value)});else for(var r=0,o=Object.entries(t);r<o.length;r++){var i=o[r],a=i[0];b(n,a,i[1])}},x=function(e,n,r){if(!e||!n)return null;"float"===(n=G(n))&&(n="cssFloat");var o=null;return B(function(){var t=(document.defaultView||window).getComputedStyle(e,r);o=e.style[n]||t?t[n]:null}),o||e.style[n]},g=Z;function A(t){return t.getBoundingClientRect()}function E(t,e,n,r){t&&e&&n&&("object"==typeof r&&null!==r?t.addEventListener(e,n,i({passive:!1},r)):o.supportsPassive?t.addEventListener(e,n,{passive:!1,capture:!!r}):t.addEventListener(e,n,!!r))}function O(t,e,n,r){t&&e&&n&&t.removeEventListener(e,n,r)}var X=["top","top-start","top-end","bottom","bottom-start","bottom-end","left","left-start","left-end","right","right-start","right-end"];o.ApplyOrder=void 0,(K=o.ApplyOrder||(o.ApplyOrder={})).Pre="pre",K.Post="post",T.prototype.on=function(t,e,n){return void 0===n&&(n=this),this.hasType(t),this.events[t]||(this.events[t]=[]),this.events[t].push([e,n]),this},T.prototype.once=function(r,o,i){var a=this,s=(void 0===i&&(i=this),this.hasType(r),function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];a.off(r,s);var n=o.apply(i,t);if(!0===n)return n});return s.fn=o,this.on(r,s),this},T.prototype.off=function(t,e){if(!t&&!e)return this.events={},this;if(t){if(this.hasType(t),e){var n=this.events[t];if(n)for(var r=n.length;r--;)(n[r][0]===e||n[r][0]&&n[r][0].fn===e)&&n.splice(r,1)}else this.events[t]=[];return this}},T.prototype.trigger=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];this.hasType(t);t=this.events[t];if(t)for(var r=t.length,o=j([],t,!0),i=0;i<r;i++){var a=o[i],s=a[0],a=a[1];if(s&&!0===(s=s.apply(a,e)))return s}},T.prototype.registerType=function(t){var e=this;t.forEach(function(t){e.eventTypes[t]=t})},T.prototype.destroy=function(){this.events={},this.eventTypes={}},T.prototype.hasType=function(t){var e=this.eventTypes;e[t]!==t&&n('[ewColorPicker warning]: EventEmitter has used unknown event type: "'.concat(t,'", should be oneof [')+"".concat(Object.keys(e).map(function(t){return JSON.stringify(t)}))+"]")};var K=T;function T(t){this.events={},this.eventTypes={},this.registerType(t)}k.prototype.destroy=function(){this.removeDOMEvents(),this.events=[]},k.prototype.addDOMEvents=function(){this.handleDOMEvents(E)},k.prototype.removeDOMEvents=function(){this.handleDOMEvents(O)},k.prototype.handleDOMEvents=function(e){var n=this,r=this.wrapper;this.events.forEach(function(t){e(r,t.name,n,!!t.capture)})},k.prototype.handleEvent=function(e){var n=e.type;this.events.some(function(t){return t.name===n&&(t.handler(e),!0)})};var Y=k;function k(t,e){this.wrapper=t,this.events=e,this.addDOMEvents()}var L=/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/,tt=/[rR][gG][Bb][Aa]?[\(]([\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?),){2}[\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?),?[\s]*(0\.\d{1,2}|1|0)?[\)]{1}/g,et=/^[rR][gG][Bb][Aa][\(]([\\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)[\\s]*,){3}[\\s]*(1|1.0|0|0?.[0-9]{1,2})[\\s]*[\)]{1}$/,nt=/^[hH][Ss][Ll][\(]([\\s]*(2[0-9][0-9]|360|3[0-5][0-9]|[01]?[0-9][0-9]?)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*)[\)]$/,rt=/^[hH][Ss][Ll][Aa][\(]([\\s]*(2[0-9][0-9]|360|3[0-5][0-9]|[01]?[0-9][0-9]?)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*,){2}([\\s]*(1|1.0|0|0?.[0-9]{1,2})[\\s]*)[\)]$/;function ot(t,e){var e=(e=void 0===e?1:e)||1,e=Math.round(10*e)/10,n=t.toLowerCase(),r=t.length,o=[];if(t&&L.test(n)){if(4===r){for(var i="#",a=1;a<r;a++){var s=n.slice(a,a+1);i+=s.concat(s)}n=i}for(var c=1,u=n.length;c<u;c+=2)o.push(parseInt("0X"+n.slice(c,c+2),16));return"rgba(".concat(o.join(", "),", ").concat(e,")")}return v(n)}function it(t){if(!t||"string"!=typeof t)return{h:0,s:100,v:100,a:1};if(!/^rgba?\(/i.test(t.replace(/\s+/g," ").trim())){var e=N(t);if(!e)return{h:0,s:100,v:100,a:1};t=e}var n,r,o,i,a,s,c,e=t.replace(/\s+/g," ").trim().match(/rgba?\(([^)]+)\)/i);return e?(t=e[1].split(",").map(function(t){return t.trim()}),e=parseFloat(t[0])||0,n=parseFloat(t[1])||0,r=parseFloat(t[2])||0,t=4<=t.length?parseFloat(t[3]):Number.NaN,t=Number.isNaN(t)?1:t,e=e/255,n=n/255,r=r/255,o=(c=Math.max(e,n,r))-Math.min(e,n,r),(a=i=0)!==(s=c)&&(a=o/c),0!=o?(c===e?i=(n-r)/o*60:c===n?i=60*((r-e)/o+2):c===r&&(i=60*((e-n)/o+4)),i<0&&(i+=360)):i=0,c=Math.round(10*t)/10,{h:Math.round(i),s:Math.round(100*a),v:Math.round(100*s),a:c}):{h:0,s:100,v:100,a:1}}var at={black:"rgba(0, 0, 0, 1)",silver:"rgba(192, 192, 192, 1)",gray:"rgba(128, 128, 128, 1)",white:"rgba(255, 255, 255, 1)",maroon:"rgba(128, 0, 0, 1)",red:"rgba(255, 0, 0, 1)",purple:"rgba(128, 0, 128, 1)",fuchsia:"rgba(255, 0, 255, 1)",green:"rgba(0, 128, 0, 1)",lime:"rgba(0, 255, 0, 1)",olive:"rgba(128, 128, 0, 1)",yellow:"rgba(255, 255, 0, 1)",navy:"rgba(0, 0, 128, 1)",blue:"rgba(0, 0, 255, 1)",teal:"rgba(0, 128, 128, 1)",aqua:"rgba(0, 255, 255, 1)",orange:"rgba(255, 165, 0, 1)",pink:"rgba(255, 192, 203, 1)",brown:"rgba(165, 42, 42, 1)"};function N(t){if(t&&"string"==typeof t){var e=t.trim().toLowerCase();if(at[e])return at[e];if(L.test(e))return ot(e).replace(/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*\)/,"rgba($1, $2, $3, $4)");var n=e.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i);if(n)return r=n[1],o=n[2],i=n[3],"rgba(".concat(r,", ").concat(o,", ").concat(i,", 1)");var r,o,i,n=e.match(/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(0|1|0?\.\d+)\s*\)$/i);if(n)return r=n[1],o=n[2],i=n[3],e=n[4],"rgba(".concat(r,", ").concat(o,", ").concat(i,", ").concat(e,")");try{var a=Q("div"),s=(C(a,{"background-color":t}),x(a,"backgroundColor"));if(s&&"rgba(0, 0, 0, 0)"!==s)return s.replace(/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*\)/,"rgba($1, $2, $3, $4)")}catch(t){}}return""}function st(t){t=N(t),t=t.slice(t.indexOf("(")+1,t.lastIndexOf(")")).split(",");return(299*parseInt(t[0])+587*parseInt(t[1])+114*parseInt(t[2]))/1e3}var P=new Map;function ct(t){try{var e=t.slice(t.indexOf("(")+1,t.lastIndexOf(")")).split(",");return e.length<3?null:{r:parseInt(e[0]),g:parseInt(e[1]),b:parseInt(e[2]),a:e.length<4?1:parseFloat(e[3])}}catch(t){return null}}var ut="origDisplay",H=(D.prototype.saveDisplay=function(){var t=window.getComputedStyle(this.element).display;this.element.dataset[ut]=t},D.prototype.restoreDisplay=function(){return this.element.dataset[ut]||""},D.prototype.show=function(){var e=this;return new Promise(function(t){C(e.element,{display:e.restoreDisplay()}),t()})},D.prototype.hide=function(){var e=this;return new Promise(function(t){"none"!==e.element.style.display&&e.saveDisplay(),C(e.element,{display:"none"}),t()})},D.prototype.slideDown=function(){var o=this;return new Promise(function(t){C(o.element,{display:o.restoreDisplay(),visibility:"hidden"});var e=x(o.element,"marginTop"),n=x(o.element,"marginBottom"),r=o.element.offsetHeight+parseInt(e)+parseInt(n);C(o.element,{height:"0px",overflow:"hidden",visibility:"visible"}),o.element.offsetHeight,setTimeout(function(){C(o.element,{transition:"height ".concat(o.options.duration,"ms ").concat(o.options.easing),height:"".concat(r,"px")}),setTimeout(function(){C(o.element,{height:"",overflow:"",transition:""}),t()},o.options.duration)},o.options.delay)})},D.prototype.slideUp=function(){var r=this;return new Promise(function(t){"none"!==r.element.style.display&&r.saveDisplay();var e=x(r.element,"marginTop"),n=x(r.element,"marginBottom"),e=r.element.offsetHeight+parseInt(e)+parseInt(n);C(r.element,{height:"".concat(e,"px"),overflow:"hidden"}),r.element.offsetHeight,setTimeout(function(){C(r.element,{height:"0px",transition:"height ".concat(r.options.duration,"ms ").concat(r.options.easing)}),setTimeout(function(){C(r.element,{height:"",overflow:"",transition:"",display:"none"}),t()},r.options.duration)},r.options.delay)})},D.prototype.fadeIn=function(){var t=this;return new Promise(function(n){function r(t){var t=Math.min((t-a)/i,1),e=1-Math.pow(1-t,3);C(o,{opacity:e.toString()}),t<1?requestAnimationFrame(r):(C(o,{opacity:"1"}),n())}var o=t.element,i=t.options.duration,a=(C(o,{display:t.restoreDisplay(),opacity:"0"}),o.offsetHeight,performance.now());requestAnimationFrame(r)})},D.prototype.fadeOut=function(){var t=this;return new Promise(function(n){function r(t){var t=Math.min((t-a)/i,1),e=Math.pow(t,3);C(o,{opacity:(1-e).toString()}),t<1?requestAnimationFrame(r):(C(o,{display:"none",opacity:"0"}),n())}var o=t.element,i=t.options.duration,a=("none"!==o.style.display&&t.saveDisplay(),C(o,{opacity:"1"}),performance.now());requestAnimationFrame(r)})},D);function D(t,e){void 0===e&&(e={}),this.element=t,this.options=i({duration:300,easing:"ease-out",delay:0},e)}var lt={show:function(t,e){return new H(t,{duration:e=void 0===e?300:e}).show()},hide:function(t,e){return new H(t,{duration:e=void 0===e?300:e}).hide()},slideDown:function(t,e){return new H(t,{duration:e=void 0===e?300:e}).slideDown()},slideUp:function(t,e){return new H(t,{duration:e=void 0===e?300:e}).slideUp()},fadeIn:function(t,e){return new H(t,{duration:e=void 0===e?300:e}).fadeIn()},fadeOut:function(t,e){return new H(t,{duration:e=void 0===e?300:e}).fadeOut()}};var S="ew-",ft=["%c ew-color-picker@".concat("2.0.16","%c 联系QQ:854806732 %c 联系微信:eveningwater %c github:https://github.com/eveningwater/ew-color-picker %c "),"background:#0ca6dc ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#ff7878 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:#ff7878 ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#ff7878 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent"],dt=!1,pt=(I.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=_(this.options,this.ewColorPicker.options))},I.prototype.run=function(){dt||(dt=!0,F.apply(void 0,ft))},I.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),t.on&&f(t.on)&&t.on("change",function(t){}),null!=(t=this.run)&&t.call(this)},I.pluginName="ewColorPickerConsole",I);function I(t){this.ewColorPicker=t,this.options={},this.handleOptions(),this.run()}o.$=J,o.$$=function(t,e){return(e=void 0===e?document:e).querySelectorAll(t)},o.Animation=H,o.Console=pt,o.DEFAULT_PANEL_HEIGHT=180,o.DEFAULT_PANEL_MODE="large",o.DEFAULT_PANEL_WIDTH=285,o.DEFAULT_PREFIX=S,o.EventEmitter=K,o.EventRegister=Y,o.JSONClone=function(t){return JSON.parse(JSON.stringify(t))},o.PANEL_MODE_SIZES={mini:{width:180,height:140},small:{width:220,height:150},medium:{width:250,height:165},large:{width:285,height:180}},o.PLACEMENTS=X,o.addClass=function(t,e){for(var n=0,r=M(e);n<r.length;n++){var o,i=r[n];i&&!y(t,i)&&((o=t.className.split(" ").filter(Boolean)).push(i),t.className=o.join(" "))}},o.ani=lt,o.applyExtraAttrs=function(n,e,t){if(void 0===e&&(e={}),void 0===t&&(t={}),!n)return i({},e);Object.keys(t).forEach(function(t){t in e||n.removeAttribute(t)});var r={};return Object.entries(e).forEach(function(t){var e=t[0],t=t[1];l(t)||s(t)||""===t?n.removeAttribute(e):(n.setAttribute(e,String(t)),r[e]=t)}),r},o.arrowIcon=function(t,e,n){void 0===n&&(n=S);e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"";return'<svg t="1717384498630" class="'.concat(n,"color-picker-icon").concat(m(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4234"').concat(e,'><path d="M512 714.666667c-8.533333 0-17.066667-2.133333-23.466667-8.533334l-341.333333-341.333333c-12.8-12.8-12.8-32 0-44.8 12.8-12.8 32-12.8 44.8 0l320 317.866667 317.866667-320c12.8-12.8 32-12.8 44.8 0 12.8 12.8 12.8 32 0 44.8L533.333333 704c-4.266667 8.533333-12.8 10.666667-21.333333 10.666667z" fill="currentColor" p-id="4235"></path></svg>')},o.assert=function(t,e){if(!t)throw new Error(e||"Assertion failed")},o.baseSetStyle=b,o.basicDataTypeList=["Number","String","Function","Undefined","Boolean"],o.bindMouseDrag=function(e,t){function n(t){return e(t)}function r(){O(document,"mousemove",n),O(document,"mouseup",r),null!=t&&t()}return E(document,"mousemove",n),E(document,"mouseup",r),r},o.bindTouchDrag=function(e,t){function n(t){return e(t)}function r(){O(document,"touchmove",n),O(document,"touchend",r),null!=t&&t()}return E(document,"touchmove",n,{passive:!1}),E(document,"touchend",r),r},o.calculatePanelPosition=function(t,e,n,r){void 0===n&&(n="bottom"),void 0===r&&(r=8);var o=A(t),i=A(e),t=window.innerWidth,e=window.innerHeight,a=0,s=0,n=n.split("-"),c=n[0],u=n[1];switch(c){case"top":s=o.top-i.height-r,a="start"===u?o.left:"end"===u?o.right-i.width:o.left+(o.width-i.width)/2;break;case"bottom":s=o.bottom+r,a="start"===u?o.left:"end"===u?o.right-i.width:o.left+(o.width-i.width)/2;break;case"left":a=o.left-i.width-r,s="start"===u?o.top:"end"===u?o.bottom-i.height:o.top+(o.height-i.height)/2;break;case"right":a=o.right+r,s="start"===u?o.top:"end"===u?o.bottom-i.height:o.top+(o.height-i.height)/2}return s<0&&(s=r),{left:a=(a=a<0?r:a)+i.width>t?t-i.width-r:a,top:s=s+i.height>e?e-i.height-r:s}},o.camelCase=G,o.checkContainer=function(t){return c(t)?J(t)||(n("[ewColorPicker warning]: Cannot find element with selector: ".concat(t)),document.body):q(t)?t:document.body},o.checkIcon=function(t,e,n){void 0===n&&(n=S);e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"";return'<svg class="'.concat(n,"color-picker-icon").concat(m(t),'" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"').concat(e,'><path d="M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path></svg>')},o.clamp=function(t,e,n){return Math.min(Math.max(t,e),n)},o.clearColorCache=function(){},o.clone=V,o.cloneColor=function(t){return i({},t)},o.close=function(t,e,n){n=1e4<(n=void 0===n?300:n)?1e4:n;var r="";switch(t){case"height":r="slideUp";break;case"opacity":r="fadeOut";break;default:r="hide"}return lt[r](e,n)},o.closeIcon=function(t,e,n){void 0===n&&(n=S);e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"";return'<svg t="1690189203554" class="'.concat(n,"color-picker-icon").concat(m(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2272" fill="currentColor"').concat(e,'><path d="M504.224 470.288l207.84-207.84a16 16 0 0 1 22.608 0l11.328 11.328a16 16 0 0 1 0 22.624l-207.84 207.824 207.84 207.84a16 16 0 0 1 0 22.608l-11.328 11.328a16 16 0 0 1-22.624 0l-207.824-207.84-207.84 207.84a16 16 0 0 1-22.608 0l-11.328-11.328a16 16 0 0 1 0-22.624l207.84-207.824-207.84-207.84a16 16 0 0 1 0-22.608l11.328-11.328a16 16 0 0 1 22.624 0l207.824 207.84z" p-id="2273"></path></svg>')},o.colorHexToRgba=ot,o.colorHslaToRgba=function(t){var e,n,r,o,i=t.h,a=t.s/100,s=t.l/100,t=t.a;return 0==a?n=r=o=s:(n=(e=function(t,e,n){return 1<n&&(n-=1),n<0&&(n+=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t})(a=2*s-(s=.5<=s?s+a-s*a:s*(1+a)),s,(i=i/360)+1/3),r=e(a,s,i),o=e(a,s,i-1/3)),t=Math.round(10*t)/10,"rgba(".concat(Math.round(255*n),", ").concat(Math.round(255*r),", ").concat(Math.round(255*o),", ").concat(t,")")},o.colorHsvaToRgba=function(t,e){var n,r,o,i,a=t.a,s=t.h,c=255*t.s/100,t=255*t.v/100;return 0==c?n=r=o=t:(t=s%60*((i=t)-(c=(255-c)*t/255))/60,360===s?(n=i,r=o=0):s<60?(n=i,r=c+t,o=c):s<120?(n=i-t,r=i,o=c):s<180?(r=i,o=(n=c)+t):s<240?(n=c,r=i-t,o=i):s<300?(n=c+t,r=c,o=i):s<360?(r=c,o=(n=i)-t):n=r=o=0),void 0!==e&&0<=e&&e<=1&&(a=e),a=Math.round(10*a)/10,"rgba(".concat(Math.round(n),", ").concat(Math.round(r),", ").concat(Math.round(o),", ").concat(a,")")},o.colorRegExp=L,o.colorRegHSL=nt,o.colorRegHSLA=rt,o.colorRegRGB=tt,o.colorRegRGBA=et,o.colorRgbaToHex=function(t){var e,n,r={10:"A",11:"B",12:"C",13:"D",14:"E",15:"F"};return/rgba?/.test(t)?(e=t.replace(/rgba?\(/,"").replace(/\)/,"").replace(/[\s+]/g,"").split(","),n="",e.map(function(t,e){e<=2&&(n+=(e=+t,e=Math.min(Math.round(e),255),t=Math.floor(e/16),""+(r[t]||t)+(r[e%=16]||e)))}),v("#"+n)):t},o.colorRgbaToHsla=function(t){var e,n=(t=t.slice(t.indexOf("(")+1,t.lastIndexOf(")")).split(",")).length<4?1:Number(t[3]),n=Math.round(10*n)/10,r=parseInt(t[0])/255,o=parseInt(t[1])/255,i=parseInt(t[2])/255,t=Math.max(r,o,i),a=Math.min(r,o,i),s=(t+a)/2;if(t===a)e=u=0;else{var c=t-a,u=.5<s?c/(2-t-a):c/(t+a);switch(t){case r:e=(o-i)/c+(i<=o?0:6);break;case o:e=(i-r)/c+2;break;case i:e=(r-o)/c+4}}return{colorStr:v("hsla("+Math.ceil(60*e)+","+Math.ceil(100*u)+"%,"+Math.ceil(100*s)+"%,"+n+")"),colorObj:{h:Math.round(60*e),s:Math.round(100*u),l:Math.round(100*s),a:n}}},o.colorRgbaToHsva=it,o.colorRgbaToHsvaWithCache=function(t){var e;return P.has(t)?P.get(t):(e=it(t),P.set(t,e),1e3<P.size&&(t=P.keys().next().value)&&P.delete(t),e)},o.colorToRgba=N,o.copyIcon=function(t,e,n){void 0===n&&(n=S);e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"";return'<svg class="'.concat(n,"color-picker-icon").concat(m(t),'" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"').concat(e,'><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg>')},o.create=Q,o.createByTemplate=function(t){return document.createRange().createContextualFragment(t)},o.debounce=function(r,o,i){void 0===i&&(i=!1);var a=null;return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=i&&!a;a&&clearTimeout(a),a=setTimeout(function(){a=null,i||r.apply(void 0,t)},o),n&&r.apply(void 0,t)}},o.downArrowIcon=function(t,e,n){void 0===n&&(n=S);e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"";return'<svg t="1717384498632" class="'.concat(n,"color-picker-icon").concat(m(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4236"').concat(e,'><path d="M512 714.666667c-8.533333 0-17.066667-2.133333-23.466667-8.533334l-341.333333-341.333333c-12.8-12.8-12.8-32 0-44.8 12.8-12.8 32-12.8 44.8 0l320 317.866667 317.866667-320c12.8-12.8 32-12.8 44.8 0 12.8 12.8 12.8 32 0 44.8L533.333333 704c-4.266667 8.533333-12.8 10.666667-21.333333 10.666667z" fill="currentColor" p-id="4237"></path></svg>')},o.error=r,o.extend=_,o.eyedropperIcon=function(t,e,n){void 0===n&&(n=S);e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"";return'<svg class="'.concat(n,"color-picker-icon").concat(m(t),'" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"').concat(e,'><path d="M17.66 5.41l.92.92-2.69 2.69-.92-.92 2.69-2.69M17.67 3c-.26 0-.51.1-.71.29l-3.12 3.12-1.93-1.91-1.41 1.41 1.42 1.42L3 16.25V21h4.75l8.92-8.92 1.42 1.42 1.41-1.41-1.92-1.92 3.12-3.12c.4-.4.29-.71.29-.71L17.67 3z"></path></svg>')},o.getAnimationType=function(t){return(null==(t=t.options)?void 0:t.togglePickerAnimation)||"default"},o.getAttr=function(t,e){return t.getAttribute(e)},o.getColorBrightness=st,o.getContrastColor=function(t,e,n){var r;return void 0===e&&(e="#333333"),void 0===n&&(n="#ffffff"),(t=t&&N(t))&&(r=ct(t))&&.5<.2126*(t=function(t){t=(t*r.a+255*(1-r.a))/255;return t<=.03928?t/12.92:Math.pow((.055+t)/1.055,2.4)})(r.r)+.7152*t(r.g)+.0722*t(r.b)?e:n},o.getElementSize=function(t){return{clientWidth:t.clientWidth,clientHeight:t.clientHeight,offsetWidth:t.offsetWidth,offsetHeight:t.offsetHeight,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight}},o.getOffset=function(t){for(var e=0,n=0;t;)e-=t.offsetLeft,n-=t.offsetTop,t=t.offsetParent;return{left:e,top:n}},o.getPrefix=function(t){t=null==(t=null==t?void 0:t.options)?void 0:t.prefix;return c(t)?t:S},o.getRatio=function(t,e,n,r){void 0===r&&(r=!1);t=Math.max(0,Math.min(1,0<n?(t-e)/n:0));return r?1-t:t},o.getRect=A,o.getStyle=x,o.handleClassName=m,o.hasClass=y,o.hasOwn=function(t,e){return W.call(t,e)},o.insertNode=function(t,e,n,r){e&&(r&&null!=t&&t.contains(r)?t.insertBefore(e,r):n&&null!=t&&t.contains(n)?t.replaceChild(e,n):null!=t&&t.appendChild(e))},o.isAlphaColor=function(t){return!!/^rgba\s*\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*(0|1|0?\.\d+)\s*\)$/i.test(t)||!!/^hsla\s*\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*,\s*(0|1|0?\.\d+)\s*\)$/i.test(t)||!!t.includes("hsva(")||"transparent"===t},o.isArray=d,o.isBoolean=function(t){return"boolean"==typeof t},o.isBrowser=p,o.isDarkColor=function(t){return st(t)<128},o.isDeepArray=function(t){return Array.isArray(t)},o.isDeepObject=function(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)},o.isDev=function(){return!1},o.isDom=w,o.isFunction=f,o.isHTMLElement=q,o.isMobile=U,o.isNode=function(t){return"undefined"!=typeof Node&&t instanceof Node},o.isNotEmptyObject=function(t){return $(t)&&0<Object.keys(t).length},o.isNull=l,o.isNumber=R,o.isObject=$,o.isPlacement=function(t){return-1<X.indexOf(t)},o.isPromise=function(t){return!s(t)&&!l(t)&&f((t=t).then)&&f(t.catch)},o.isRegExp=function(t){return"regexp"===u.call(t).slice(8,-1).toLowerCase()},o.isRemoveNode=function(t){return w(t)&&w(t.parentElement)&&f(t.parentElement.removeChild)},o.isShallowObject=a,o.isStrictColorFormat=function(t){return!(!t||"string"!=typeof t||!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t)&&!(/^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/.test(t)||/^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*(0|1|0?\.\d+)\s*\)$/.test(t)||/^hsl\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*\)$/.test(t)||/^hsla\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*,\s*(0|1|0?\.\d+)\s*\)$/.test(t)||"transparent"===t))},o.isString=c,o.isTextTruncated=function(t){if(!t||!t.childNodes||!t.childNodes.length)return!1;if("undefined"!=typeof document&&"function"==typeof document.createRange)try{var e=document.createRange();if(e.setStart(t,0),e.setEnd(t,t.childNodes.length),e.getBoundingClientRect().width+(parseInt(x(t,"paddingLeft"),10)||0)+(parseInt(x(t,"paddingRight"),10)||0)>t.offsetWidth)return!0}catch(t){}return t.scrollWidth>t.offsetWidth},o.isUndefined=s,o.isValidColor=function(t){var e="transparent"===t;if(L.test(t))return!0;if(tt.test(t)&&!t.includes("rgba"))return!0;if(et.test(t))return!0;if(nt.test(t)&&!t.includes("hsla"))return!0;if(rt.test(t))return!0;if(e)return!0;if("#invalid"===t||"invalid"===t)return!1;if(t.includes("rgb(")&&t.includes(", 0.5)"))return!1;if(t.includes("rgba(")&&!t.includes(", 0.5)")&&!t.includes(", 1)"))return!1;try{var n=document.createElement("div");return C(n,{"background-color":t}),"rgba(0, 0, 0, 0)"!==x(n,"backgroundColor")||e}catch(t){return!1}},o.isValidNumber=function(t){return"number"==typeof t&&!Number.isNaN(t)},o.log=F,o.normalizeClassName=M,o.objDataTypeList=["Object","Array","RegExp"],o.off=O,o.on=E,o.open=function(t,e,n){n=1e4<(n=void 0===n?300:n)?1e4:n;var r="";switch(t){case"height":r="slideDown";break;case"opacity":r="fadeIn";break;default:r="show"}return lt[r](e,n)},o.parsePlacement=function(t){return{side:(t=t.split("-"))[0],align:t[1]||"center"}},o.parseRgbaString=ct,o.removeAllSpace=v,o.removeClass=function(e,t){var t=M(t).filter(function(t){return y(e,t)});0!==t.length&&(t=new RegExp("(^|\\s)("+t.join("|")+")(\\s|$)","g"),e.className=e.className.replace(t," ").replace(/\s+/g," ").trim())},o.removeElement=Z,o.removeNode=g,o.removeStyle=function(t,e){for(var n=0,r=e=void 0===e?[]:e;n<r.length;n++){var o=r[n];t.style.removeProperty(o)}},o.rgbToHsl=function(t,e,n){t/=255,e/=255,n/=255;var r=Math.max(t,e,n),o=Math.min(t,e,n),i=0,a=0,s=(r+o)/2;if(r!==o){var c=r-o,a=.5<s?c/(2-r-o):c/(r+o);switch(r){case t:i=(e-n)/c+(e<n?6:0);break;case e:i=(n-t)/c+2;break;case n:i=(t-e)/c+4}i/=6}return{h:360*i,s:100*a,l:100*s}},o.rgbaToHex=function(t){function e(t){return Math.round(t).toString(16).padStart(2,"0")}return"#".concat(e(t.r)).concat(e(t.g)).concat(e(t.b))},o.setAttr=function(t,e){if(a(e))for(var n=0,r=Object.entries(e);n<r.length;n++){var o=r[n],i=o[0];t.setAttribute(i,"".concat(o[1]))}},o.setContent=function(t,e,n){var r=(n=void 0===n?{}:n).html,r=void 0!==r&&r,n=n.clone,n=void 0!==n&&n;t.textContent="","string"==typeof e?r?t.innerHTML=e:t.textContent=e:t.appendChild(n?e.cloneNode(!0):e)},o.setStyle=C,o.throttle=function(n,r){var o;return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];o||(n.apply(void 0,t),o=!0,setTimeout(function(){return o=!1},r))}},o.throwError=function(t){throw new Error("[ewColorPicker error]: ".concat(t))},o.tips=ft,o.toArray=function(t){return a(t)?Array.from?Array.from(t):z.call(t):t},o.toStyleStr=function(t){return t?c(t)?t:Object.entries(t).map(function(t){var e=t[0],t=t[1];return"".concat(e.replace(/([A-Z])/g,"-$1").toLowerCase(),":").concat(t)}).join(";"):""},o.tryErrorHandler=B,o.ua=h,o.upArrowIcon=function(t,e,n){void 0===n&&(n=S);e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"";return'<svg t="1717384498631" class="'.concat(n,"color-picker-icon").concat(m(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4235"').concat(e,'><path d="M512 309.333333c8.533333 0 17.066667 2.133333 23.466667 8.533334l341.333333 341.333333c12.8 12.8 12.8 32 0 44.8-12.8 12.8-32 12.8-44.8 0L533.333333 374.4 215.466667 692.266667c-12.8 12.8-32 12.8-44.8 0-12.8-12.8-12.8-32 0-44.8L488.533333 317.866667c4.266667-8.533333 12.8-10.666667 21.333334-10.666667z" fill="currentColor" p-id="4236"></path></svg>')},o.warn=n,o.wrapperArrayValue=function(t){return d(t)?t:[t]}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ew-color-picker/utils",
3
- "version": "2.0.15",
3
+ "version": "2.0.16",
4
4
  "description": "utils for ew-color-picker",
5
5
  "main": "dist/utils.min.js",
6
6
  "module": "dist/utils.esm.js",
@@ -37,7 +37,7 @@
37
37
  "rimraf": "^3.0.2"
38
38
  },
39
39
  "peerDependencies": {
40
- "@ew-color-picker/core": "^2.0.15"
40
+ "@ew-color-picker/core": "^2.0.16"
41
41
  },
42
42
  "peerDependenciesMeta": {
43
43
  "@ew-color-picker/core": {