diff --git a/modules/backend/formwidgets/colorpicker/assets/js/dist/colorpicker.js b/modules/backend/formwidgets/colorpicker/assets/js/dist/colorpicker.js index 5fd8bf6d6c..d5fd2c5935 100644 --- a/modules/backend/formwidgets/colorpicker/assets/js/dist/colorpicker.js +++ b/modules/backend/formwidgets/colorpicker/assets/js/dist/colorpicker.js @@ -1,3 +1 @@ -(self.webpackChunk_wintercms_wn_backend_module=self.webpackChunk_wintercms_wn_backend_module||[]).push([[728],{562:function(t){ -/*! Pickr 1.8.2 MIT | https://github.com/Simonwep/pickr */ -self,t.exports=(()=>{"use strict";var t={d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{default:()=>E});var o={};function r(t,e,o,r,i={}){e instanceof HTMLCollection||e instanceof NodeList?e=Array.from(e):Array.isArray(e)||(e=[e]),Array.isArray(o)||(o=[o]);for(const n of e)for(const e of o)n[t](e,r,{capture:!1,...i});return Array.prototype.slice.call(arguments,1)}t.r(o),t.d(o,{adjustableInputNumbers:()=>p,createElementFromString:()=>s,createFromTemplate:()=>a,eventPath:()=>c,off:()=>n,on:()=>i,resolveElement:()=>l});const i=r.bind(null,"addEventListener"),n=r.bind(null,"removeEventListener");function s(t){const e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild}function a(t){const e=(t,e)=>{const o=t.getAttribute(e);return t.removeAttribute(e),o},o=(t,r={})=>{const i=e(t,":obj"),n=e(t,":ref"),s=i?r[i]={}:r;n&&(r[n]=t);for(const r of Array.from(t.children)){const t=e(r,":arr"),i=o(r,t?{}:s);t&&(s[t]||(s[t]=[])).push(Object.keys(i).length?i:r)}return r};return o(s(t))}function c(t){let e=t.path||t.composedPath&&t.composedPath();if(e)return e;let o=t.target.parentElement;for(e=[t.target,o];o=o.parentElement;)e.push(o);return e.push(document,window),e}function l(t){return t instanceof Element?t:"string"==typeof t?t.split(/>>/g).reduce(((t,e,o,r)=>(t=t.querySelector(e),ot)){function o(o){const r=[.001,.01,.1][Number(o.shiftKey||2*o.ctrlKey)]*(o.deltaY<0?1:-1);let i=0,n=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,((t,o)=>o<=n&&o+t.length>=n?(n=o,e(Number(t),r,i)):(i++,t))),t.focus(),t.setSelectionRange(n,n),o.preventDefault(),t.dispatchEvent(new Event("input"))}i(t,"focus",(()=>i(window,"wheel",o,{passive:!1}))),i(t,"blur",(()=>n(window,"wheel",o)))}const{min:h,max:u,floor:d,round:g}=Math;function f(t,e,o){e/=100,o/=100;const r=d(t=t/360*6),i=t-r,n=o*(1-e),s=o*(1-i*e),a=o*(1-(1-i)*e),c=r%6;return[255*[o,s,n,n,a,o][c],255*[a,o,o,s,n,n][c],255*[n,n,a,o,o,s][c]]}function m(t,e,o){const r=(2-(e/=100))*(o/=100)/2;return 0!==r&&(e=1===r?0:r<.5?e*o/(2*r):e*o/(2-2*r)),[t,100*e,100*r]}function v(t,e,o){const r=h(t/=255,e/=255,o/=255),i=u(t,e,o),n=i-r;let s,a;if(0===n)s=a=0;else{a=n/i;const r=((i-t)/6+n/2)/n,c=((i-e)/6+n/2)/n,l=((i-o)/6+n/2)/n;t===i?s=l-c:e===i?s=1/3+r-l:o===i&&(s=2/3+c-r),s<0?s+=1:s>1&&(s-=1)}return[360*s,100*a,100*i]}function b(t,e,o,r){return e/=100,o/=100,[...v(255*(1-h(1,(t/=100)*(1-(r/=100))+r)),255*(1-h(1,e*(1-r)+r)),255*(1-h(1,o*(1-r)+r)))]}function k(t,e,o){e/=100;const r=2*(e*=(o/=100)<.5?o:1-o)/(o+e)*100,i=100*(o+e);return[t,isNaN(r)?0:r,i]}function w(t){return v(...t.match(/.{2}/g).map((t=>parseInt(t,16))))}function y(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return"#000";const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000"===e.fillStyle?null:e.fillStyle}(t):t;const e={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},o=t=>t.map((t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0));let r;t:for(const i in e){if(!(r=e[i].exec(t)))continue;const n=t=>!!r[2]==("number"==typeof t);switch(i){case"cmyk":{const[,t,e,n,s]=o(r);if(t>100||e>100||n>100||s>100)break t;return{values:b(t,e,n,s),type:i}}case"rgba":{const[,,,t,e,s,a]=o(r);if(t>255||e>255||s>255||a<0||a>1||!n(a))break t;return{values:[...v(t,e,s),a],a:a,type:i}}case"hexa":{let[,t]=r;4!==t.length&&3!==t.length||(t=t.split("").map((t=>t+t)).join(""));const e=t.substring(0,6);let o=t.substring(6);return o=o?parseInt(o,16)/255:void 0,{values:[...w(e),o],a:o,type:i}}case"hsla":{const[,,,t,e,s,a]=o(r);if(t>360||e>100||s>100||a<0||a>1||!n(a))break t;return{values:[...k(t,e,s),a],a:a,type:i}}case"hsva":{const[,,,t,e,s,a]=o(r);if(t>360||e>100||s>100||a<0||a>1||!n(a))break t;return{values:[t,e,s,a],a:a,type:i}}}}return{values:null,type:null}}function _(t=0,e=0,o=0,r=1){const i=(t,e)=>(o=-1)=>e(~o?t.map((t=>Number(t.toFixed(o)))):t),n={h:t,s:e,v:o,a:r,toHSVA(){const t=[n.h,n.s,n.v,n.a];return t.toString=i(t,(t=>`hsva(${t[0]}, ${t[1]}%, ${t[2]}%, ${n.a})`)),t},toHSLA(){const t=[...m(n.h,n.s,n.v),n.a];return t.toString=i(t,(t=>`hsla(${t[0]}, ${t[1]}%, ${t[2]}%, ${n.a})`)),t},toRGBA(){const t=[...f(n.h,n.s,n.v),n.a];return t.toString=i(t,(t=>`rgba(${t[0]}, ${t[1]}, ${t[2]}, ${n.a})`)),t},toCMYK(){const t=function(t,e,o){const r=f(t,e,o),i=r[0]/255,n=r[1]/255,s=r[2]/255,a=h(1-i,1-n,1-s);return[100*(1===a?0:(1-i-a)/(1-a)),100*(1===a?0:(1-n-a)/(1-a)),100*(1===a?0:(1-s-a)/(1-a)),100*a]}(n.h,n.s,n.v);return t.toString=i(t,(t=>`cmyk(${t[0]}%, ${t[1]}%, ${t[2]}%, ${t[3]}%)`)),t},toHEXA(){const t=function(t,e,o){return f(t,e,o).map((t=>g(t).toString(16).padStart(2,"0")))}(n.h,n.s,n.v),e=n.a>=1?"":Number((255*n.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return e&&t.push(e),t.toString=()=>`#${t.join("").toUpperCase()}`,t},clone:()=>_(n.h,n.s,n.v,n.a)};return n}const C=t=>Math.max(Math.min(t,1),0);function x(t){const e={options:Object.assign({lock:null,onchange:()=>0,onstop:()=>0},t),_keyboard(t){const{options:o}=e,{type:r,key:i}=t;if(document.activeElement===o.wrapper){const{lock:o}=e.options,n="ArrowUp"===i,s="ArrowRight"===i,a="ArrowDown"===i,c="ArrowLeft"===i;if("keydown"===r&&(n||s||a||c)){let r=0,i=0;"v"===o?r=n||s?1:-1:"h"===o?r=n||s?-1:1:(i=n?-1:a?1:0,r=c?-1:s?1:0),e.update(C(e.cache.x+.01*r),C(e.cache.y+.01*i)),t.preventDefault()}else i.startsWith("Arrow")&&(e.options.onstop(),t.preventDefault())}},_tapstart(t){i(document,["mouseup","touchend","touchcancel"],e._tapstop),i(document,["mousemove","touchmove"],e._tapmove),t.cancelable&&t.preventDefault(),e._tapmove(t)},_tapmove(t){const{options:o,cache:r}=e,{lock:i,element:n,wrapper:s}=o,a=s.getBoundingClientRect();let c=0,l=0;if(t){const e=t&&t.touches&&t.touches[0];c=t?(e||t).clientX:0,l=t?(e||t).clientY:0,ca.left+a.width&&(c=a.left+a.width),la.top+a.height&&(l=a.top+a.height),c-=a.left,l-=a.top}else r&&(c=r.x*a.width,l=r.y*a.height);"h"!==i&&(n.style.left=`calc(${c/a.width*100}% - ${n.offsetWidth/2}px)`),"v"!==i&&(n.style.top=`calc(${l/a.height*100}% - ${n.offsetHeight/2}px)`),e.cache={x:c/a.width,y:l/a.height};const p=C(c/a.width),h=C(l/a.height);switch(i){case"v":return o.onchange(p);case"h":return o.onchange(h);default:return o.onchange(p,h)}},_tapstop(){e.options.onstop(),n(document,["mouseup","touchend","touchcancel"],e._tapstop),n(document,["mousemove","touchmove"],e._tapmove)},trigger(){e._tapmove()},update(t=0,o=0){const{left:r,top:i,width:n,height:s}=e.options.wrapper.getBoundingClientRect();"h"===e.options.lock&&(o=t),e._tapmove({clientX:r+n*t,clientY:i+s*o})},destroy(){const{options:t,_tapstart:o,_keyboard:r}=e;n(document,["keydown","keyup"],r),n([t.wrapper,t.element],"mousedown",o),n([t.wrapper,t.element],"touchstart",o,{passive:!1})}},{options:o,_tapstart:r,_keyboard:s}=e;return i([o.wrapper,o.element],"mousedown",r),i([o.wrapper,o.element],"touchstart",r,{passive:!1}),i(document,["keydown","keyup"],s),e}function A(t={}){t=Object.assign({onchange:()=>0,className:"",elements:[]},t);const e=i(t.elements,"click",(e=>{t.elements.forEach((o=>o.classList[e.target===o?"add":"remove"](t.className))),t.onchange(e),e.stopPropagation()}));return{destroy:()=>n(...e)}}const S={variantFlipOrder:{start:"sme",middle:"mse",end:"ems"},positionFlipOrder:{top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},position:"bottom",margin:8},H=(t,e,o)=>{const{container:r,margin:i,position:n,variantFlipOrder:s,positionFlipOrder:a}={container:document.documentElement.getBoundingClientRect(),...S,...o},{left:c,top:l}=e.style;e.style.left="0",e.style.top="0";const p=t.getBoundingClientRect(),h=e.getBoundingClientRect(),u={t:p.top-h.height-i,b:p.bottom+i,r:p.right+i,l:p.left-h.width-i},d={vs:p.left,vm:p.left+p.width/2+-h.width/2,ve:p.left+p.width-h.width,hs:p.top,hm:p.bottom-p.height/2-h.height/2,he:p.bottom-h.height},[g,f="middle"]=n.split("-"),m=a[g],v=s[f],{top:b,left:k,bottom:w,right:y}=r;for(const t of m){const o="t"===t||"b"===t,r=u[t],[i,n]=o?["top","left"]:["left","top"],[s,a]=o?[h.height,h.width]:[h.width,h.height],[c,l]=o?[w,y]:[y,w],[p,g]=o?[b,k]:[k,b];if(!(rc))for(const s of v){const c=d[(o?"v":"h")+s];if(!(cl))return e.style[n]=c-h[n]+"px",e.style[i]=r-h[i]+"px",t+s}}return e.style.left=c,e.style.top=l,null};function V(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class E{constructor(t){V(this,"_initializingActive",!0),V(this,"_recalc",!0),V(this,"_nanopop",null),V(this,"_root",null),V(this,"_color",_()),V(this,"_lastColor",_()),V(this,"_swatchColors",[]),V(this,"_setupAnimationFrame",null),V(this,"_eventListener",{init:[],save:[],hide:[],show:[],clear:[],change:[],changestop:[],cancel:[],swatchselect:[]}),this.options=t=Object.assign({...E.DEFAULT_OPTIONS},t);const{swatches:e,components:o,theme:r,sliders:i,lockOpacity:n,padding:s}=t;["nano","monolith"].includes(r)&&!i&&(t.sliders="h"),o.interaction||(o.interaction={});const{preview:a,opacity:c,hue:l,palette:p}=o;o.opacity=!n&&c,o.palette=p||a||c||l,this._preBuild(),this._buildComponents(),this._bindEvents(),this._finalBuild(),e&&e.length&&e.forEach((t=>this.addSwatch(t)));const{button:h,app:u}=this._root;this._nanopop=((t,e,o)=>{const r="object"!=typeof t||t instanceof HTMLElement?{reference:t,popper:e,...o}:t;return{update(t=r){const{reference:e,popper:o}=Object.assign(r,t);if(!o||!e)throw new Error("Popper- or reference-element missing.");return H(e,o,r)}}})(h,u,{margin:s}),h.setAttribute("role","button"),h.setAttribute("aria-label",this._t("btn:toggle"));const d=this;this._setupAnimationFrame=requestAnimationFrame((function e(){if(!u.offsetWidth)return requestAnimationFrame(e);d.setColor(t.default),d._rePositioningPicker(),t.defaultRepresentation&&(d._representation=t.defaultRepresentation,d.setColorRepresentation(d._representation)),t.showAlways&&d.show(),d._initializingActive=!1,d._emit("init")}))}_preBuild(){const{options:t}=this;for(const e of["el","container"])t[e]=l(t[e]);this._root=(t=>{const{components:e,useAsButton:o,inline:r,appClass:i,theme:n,lockOpacity:s}=t.options,c=t=>t?"":'style="display:none" hidden',l=e=>t._t(e),p=a(`\n
\n\n ${o?"":''}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n
\n `),h=p.interaction;return h.options.find((t=>!t.hidden&&!t.classList.add("active"))),h.type=()=>h.options.find((t=>t.classList.contains("active"))),p})(this),t.useAsButton&&(this._root.button=t.el),t.container.appendChild(this._root.root)}_finalBuild(){const t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){const o=t.el.parentElement;t.el.nextSibling?o.insertBefore(e.app,t.el.nextSibling):o.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}_buildComponents(){const t=this,e=this.options.components,o=(t.options.sliders||"v").repeat(2),[r,i]=o.match(/^[vh]+$/g)?o:[],n=()=>this._color||(this._color=this._lastColor.clone()),s={palette:x({element:t._root.palette.picker,wrapper:t._root.palette.palette,onstop:()=>t._emit("changestop","slider",t),onchange(o,r){if(!e.palette)return;const i=n(),{_root:s,options:a}=t,{lastColor:c,currentColor:l}=s.preview;t._recalc&&(i.s=100*o,i.v=100-100*r,i.v<0&&(i.v=0),t._updateOutput("slider"));const p=i.toRGBA().toString(0);this.element.style.background=p,this.wrapper.style.background=`\n linear-gradient(to top, rgba(0, 0, 0, ${i.a}), transparent),\n linear-gradient(to left, hsla(${i.h}, 100%, 50%, ${i.a}), rgba(255, 255, 255, ${i.a}))\n `,a.comparison?a.useAsButton||t._lastColor||c.style.setProperty("--pcr-color",p):(s.button.style.setProperty("--pcr-color",p),s.button.classList.remove("clear"));const h=i.toHEXA().toString();for(const{el:e,color:o}of t._swatchColors)e.classList[h===o.toHEXA().toString()?"add":"remove"]("pcr-active");l.style.setProperty("--pcr-color",p)}}),hue:x({lock:"v"===i?"h":"v",element:t._root.hue.picker,wrapper:t._root.hue.slider,onstop:()=>t._emit("changestop","slider",t),onchange(o){if(!e.hue||!e.palette)return;const r=n();t._recalc&&(r.h=360*o),this.element.style.backgroundColor=`hsl(${r.h}, 100%, 50%)`,s.palette.trigger()}}),opacity:x({lock:"v"===r?"h":"v",element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onstop:()=>t._emit("changestop","slider",t),onchange(o){if(!e.opacity||!e.palette)return;const r=n();t._recalc&&(r.a=Math.round(100*o)/100),this.element.style.background=`rgba(0, 0, 0, ${r.a})`,s.palette.trigger()}}),selectable:A({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._recalc&&t._updateOutput("swatch")}})};this._components=s}_bindEvents(){const{_root:t,options:e}=this,o=[i(t.interaction.clear,"click",(()=>this._clearColor())),i([t.interaction.cancel,t.preview.lastColor],"click",(()=>{this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0),this._emit("cancel")})),i(t.interaction.save,"click",(()=>{!this.applyColor()&&!e.showAlways&&this.hide()})),i(t.interaction.result,["keyup","input"],(t=>{this.setColor(t.target.value,!0)&&!this._initializingActive&&(this._emit("change",this._color,"input",this),this._emit("changestop","input",this)),t.stopImmediatePropagation()})),i(t.interaction.result,["focus","blur"],(t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput(null)})),i([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],(()=>this._recalc=!0),{passive:!0})];if(!e.showAlways){const r=e.closeWithKey;o.push(i(t.button,"click",(()=>this.isOpen()?this.hide():this.show())),i(document,"keyup",(t=>this.isOpen()&&(t.key===r||t.code===r)&&this.hide())),i(document,["touchstart","mousedown"],(e=>{this.isOpen()&&!c(e).some((e=>e===t.app||e===t.button))&&this.hide()}),{capture:!0}))}if(e.adjustableNumbers){const e={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};p(t.interaction.result,((t,o,r)=>{const i=e[this.getColorRepresentation().toLowerCase()];if(i){const e=i[r],n=t+(e>=100?1e3*o:o);return n<=0?0:Number((n{r.isOpen()&&(e.closeOnScroll&&r.hide(),null===t?(t=setTimeout((()=>t=null),100),requestAnimationFrame((function e(){r._rePositioningPicker(),null!==t&&requestAnimationFrame(e)}))):(clearTimeout(t),t=setTimeout((()=>t=null),100)))}),{capture:!0}))}this._eventBindings=o}_rePositioningPicker(){const{options:t}=this;if(!t.inline&&!this._nanopop.update({container:document.body.getBoundingClientRect(),position:t.position})){const t=this._root.app,e=t.getBoundingClientRect();t.style.top=(window.innerHeight-e.height)/2+"px",t.style.left=(window.innerWidth-e.width)/2+"px"}}_updateOutput(t){const{_root:e,_color:o,options:r}=this;if(e.interaction.type()){const t=`to${e.interaction.type().getAttribute("data-type")}`;e.interaction.result.value="function"==typeof o[t]?o[t]().toString(r.outputPrecision):""}!this._initializingActive&&this._recalc&&this._emit("change",o,t,this)}_clearColor(t=!1){const{_root:e,options:o}=this;o.useAsButton||e.button.style.setProperty("--pcr-color","rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),o.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear"))}_parseLocalColor(t){const{values:e,type:o,a:r}=y(t),{lockOpacity:i}=this.options,n=void 0!==r&&1!==r;return e&&3===e.length&&(e[3]=void 0),{values:!e||i&&n?null:e,type:o}}_t(t){return this.options.i18n[t]||E.I18N_DEFAULTS[t]}_emit(t,...e){this._eventListener[t].forEach((t=>t(...e,this)))}on(t,e){return this._eventListener[t].push(e),this}off(t,e){const o=this._eventListener[t]||[],r=o.indexOf(e);return~r&&o.splice(r,1),this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:o}=this,r=_(...e),n=s(`'}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `),h=p.interaction;return h.options.find((t=>!t.hidden&&!t.classList.add("active"))),h.type=()=>h.options.find((t=>t.classList.contains("active"))),p})(this),t.useAsButton&&(this._root.button=t.el),t.container.appendChild(this._root.root)}_finalBuild(){const t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){const o=t.el.parentElement;t.el.nextSibling?o.insertBefore(e.app,t.el.nextSibling):o.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}_buildComponents(){const t=this,e=this.options.components,o=(t.options.sliders||"v").repeat(2),[r,i]=o.match(/^[vh]+$/g)?o:[],n=()=>this._color||(this._color=this._lastColor.clone()),s={palette:C({element:t._root.palette.picker,wrapper:t._root.palette.palette,onstop:()=>t._emit("changestop","slider",t),onchange(o,r){if(!e.palette)return;const i=n(),{_root:s,options:a}=t,{lastColor:c,currentColor:l}=s.preview;t._recalc&&(i.s=100*o,i.v=100-100*r,i.v<0&&(i.v=0),t._updateOutput("slider"));const p=i.toRGBA().toString(0);this.element.style.background=p,this.wrapper.style.background=`\n linear-gradient(to top, rgba(0, 0, 0, ${i.a}), transparent),\n linear-gradient(to left, hsla(${i.h}, 100%, 50%, ${i.a}), rgba(255, 255, 255, ${i.a}))\n `,a.comparison?a.useAsButton||t._lastColor||c.style.setProperty("--pcr-color",p):(s.button.style.setProperty("--pcr-color",p),s.button.classList.remove("clear"));const h=i.toHEXA().toString();for(const{el:e,color:o}of t._swatchColors)e.classList[h===o.toHEXA().toString()?"add":"remove"]("pcr-active");l.style.setProperty("--pcr-color",p)}}),hue:C({lock:"v"===i?"h":"v",element:t._root.hue.picker,wrapper:t._root.hue.slider,onstop:()=>t._emit("changestop","slider",t),onchange(o){if(!e.hue||!e.palette)return;const r=n();t._recalc&&(r.h=360*o),this.element.style.backgroundColor=`hsl(${r.h}, 100%, 50%)`,s.palette.trigger()}}),opacity:C({lock:"v"===r?"h":"v",element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onstop:()=>t._emit("changestop","slider",t),onchange(o){if(!e.opacity||!e.palette)return;const r=n();t._recalc&&(r.a=Math.round(100*o)/100),this.element.style.background=`rgba(0, 0, 0, ${r.a})`,s.palette.trigger()}}),selectable:x({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._recalc&&t._updateOutput("swatch")}})};this._components=s}_bindEvents(){const{_root:t,options:e}=this,o=[i(t.interaction.clear,"click",(()=>this._clearColor())),i([t.interaction.cancel,t.preview.lastColor],"click",(()=>{this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0),this._emit("cancel")})),i(t.interaction.save,"click",(()=>{!this.applyColor()&&!e.showAlways&&this.hide()})),i(t.interaction.result,["keyup","input"],(t=>{this.setColor(t.target.value,!0)&&!this._initializingActive&&(this._emit("change",this._color,"input",this),this._emit("changestop","input",this)),t.stopImmediatePropagation()})),i(t.interaction.result,["focus","blur"],(t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput(null)})),i([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],(()=>this._recalc=!0),{passive:!0})];if(!e.showAlways){const r=e.closeWithKey;o.push(i(t.button,"click",(()=>this.isOpen()?this.hide():this.show())),i(document,"keyup",(t=>this.isOpen()&&(t.key===r||t.code===r)&&this.hide())),i(document,["touchstart","mousedown"],(e=>{this.isOpen()&&!c(e).some((e=>e===t.app||e===t.button))&&this.hide()}),{capture:!0}))}if(e.adjustableNumbers){const e={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};p(t.interaction.result,((t,o,r)=>{const i=e[this.getColorRepresentation().toLowerCase()];if(i){const e=i[r],n=t+(e>=100?1e3*o:o);return n<=0?0:Number((n{r.isOpen()&&(e.closeOnScroll&&r.hide(),null===t?(t=setTimeout((()=>t=null),100),requestAnimationFrame((function e(){r._rePositioningPicker(),null!==t&&requestAnimationFrame(e)}))):(clearTimeout(t),t=setTimeout((()=>t=null),100)))}),{capture:!0}))}this._eventBindings=o}_rePositioningPicker(){const{options:t}=this;if(!t.inline&&!this._nanopop.update({container:document.body.getBoundingClientRect(),position:t.position})){const t=this._root.app,e=t.getBoundingClientRect();t.style.top=(window.innerHeight-e.height)/2+"px",t.style.left=(window.innerWidth-e.width)/2+"px"}}_updateOutput(t){const{_root:e,_color:o,options:r}=this;if(e.interaction.type()){const t=`to${e.interaction.type().getAttribute("data-type")}`;e.interaction.result.value="function"==typeof o[t]?o[t]().toString(r.outputPrecision):""}!this._initializingActive&&this._recalc&&this._emit("change",o,t,this)}_clearColor(t=!1){const{_root:e,options:o}=this;o.useAsButton||e.button.style.setProperty("--pcr-color","rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),o.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear"))}_parseLocalColor(t){const{values:e,type:o,a:r}=function(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return"#000";const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000"===e.fillStyle?null:e.fillStyle}(t):t;const e={cmyk:/^cmyk\D+([\d.]+)\D+([\d.]+)\D+([\d.]+)\D+([\d.]+)/i,rgba:/^rgba?\D+([\d.]+)(%?)\D+([\d.]+)(%?)\D+([\d.]+)(%?)\D*?(([\d.]+)(%?)|$)/i,hsla:/^hsla?\D+([\d.]+)\D+([\d.]+)\D+([\d.]+)\D*?(([\d.]+)(%?)|$)/i,hsva:/^hsva?\D+([\d.]+)\D+([\d.]+)\D+([\d.]+)\D*?(([\d.]+)(%?)|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},o=t=>t.map((t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0));let r;t:for(const i in e)if(r=e[i].exec(t))switch(i){case"cmyk":{const[,t,e,n,s]=o(r);if(t>100||e>100||n>100||s>100)break t;return{values:b(t,e,n,s),type:i}}case"rgba":{let[,t,,e,,n,,,s]=o(r);if(t="%"===r[2]?t/100*255:t,e="%"===r[4]?e/100*255:e,n="%"===r[6]?n/100*255:n,s="%"===r[9]?s/100:s,t>255||e>255||n>255||s<0||s>1)break t;return{values:[...v(t,e,n),s],a:s,type:i}}case"hexa":{let[,t]=r;4!==t.length&&3!==t.length||(t=t.split("").map((t=>t+t)).join(""));const e=t.substring(0,6);let o=t.substring(6);return o=o?parseInt(o,16)/255:void 0,{values:[...w(e),o],a:o,type:i}}case"hsla":{let[,t,e,n,,s]=o(r);if(s="%"===r[6]?s/100:s,t>360||e>100||n>100||s<0||s>1)break t;return{values:[...k(t,e,n),s],a:s,type:i}}case"hsva":{let[,t,e,n,,s]=o(r);if(s="%"===r[6]?s/100:s,t>360||e>100||n>100||s<0||s>1)break t;return{values:[t,e,n,s],a:s,type:i}}}return{values:null,type:null}}(t),{lockOpacity:i}=this.options,n=void 0!==r&&1!==r;return e&&3===e.length&&(e[3]=void 0),{values:!e||i&&n?null:e,type:o}}_t(t){return this.options.i18n[t]||S.I18N_DEFAULTS[t]}_emit(t,...e){this._eventListener[t].forEach((t=>t(...e,this)))}on(t,e){return this._eventListener[t].push(e),this}off(t,e){const o=this._eventListener[t]||[],r=o.indexOf(e);return~r&&o.splice(r,1),this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:o}=this,r=y(...e),n=s(`