UNPKG

vue-pick-colors

Version:
2 lines (1 loc) 44.5 kB
import{defineComponent as e,computed as t,openBlock as r,createElementBlock as n,normalizeStyle as o,withModifiers as a,createElementVNode as i,ref as c,onMounted as l,watch as u,unref as s,nextTick as f,onBeforeUnmount as d,onUnmounted as p,toDisplayString as v,createCommentVNode as h,createVNode as m,Transition as g,withCtx as y,Fragment as b,renderList as x,resolveComponent as w,withKeys as S,inject as k,createBlock as C,provide as O,toRaw as E,Teleport as A}from"vue";import{createPopper as N}from"@popperjs/core";function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function F(e,t){if(e){if("string"==typeof e)return I(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(e,t):void 0}}function _(e){return function(e){if(Array.isArray(e))return I(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||F(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function L(e){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},L(e)}function P(e,t,r,n,o,a,i){try{var c=e[a](i),l=c.value}catch(e){return void r(e)}c.done?t(l):Promise.resolve(l).then(n,o)}function j(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){P(a,n,o,i,c,"next",e)}function c(e){P(a,n,o,i,c,"throw",e)}i(void 0)}))}}var M={exports:{}},B={exports:{}};!function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(B),function(e){var t=B.exports.default;function r(){e.exports=r=function(){return o},e.exports.__esModule=!0,e.exports.default=e.exports;var n,o={},a=Object.prototype,i=a.hasOwnProperty,c=Object.defineProperty||function(e,t,r){e[t]=r.value},l="function"==typeof Symbol?Symbol:{},u=l.iterator||"@@iterator",s=l.asyncIterator||"@@asyncIterator",f=l.toStringTag||"@@toStringTag";function d(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{d({},"")}catch(n){d=function(e,t,r){return e[t]=r}}function p(e,t,r,n){var o=t&&t.prototype instanceof x?t:x,a=Object.create(o.prototype),i=new P(n||[]);return c(a,"_invoke",{value:I(e,r,i)}),a}function v(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}o.wrap=p;var h="suspendedStart",m="suspendedYield",g="executing",y="completed",b={};function x(){}function w(){}function S(){}var k={};d(k,u,(function(){return this}));var C=Object.getPrototypeOf,O=C&&C(C(j([])));O&&O!==a&&i.call(O,u)&&(k=O);var E=S.prototype=x.prototype=Object.create(k);function A(e){["next","throw","return"].forEach((function(t){d(e,t,(function(e){return this._invoke(t,e)}))}))}function N(e,r){function n(o,a,c,l){var u=v(e[o],e,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==t(f)&&i.call(f,"__await")?r.resolve(f.__await).then((function(e){n("next",e,c,l)}),(function(e){n("throw",e,c,l)})):r.resolve(f).then((function(e){s.value=e,c(s)}),(function(e){return n("throw",e,c,l)}))}l(u.arg)}var o;c(this,"_invoke",{value:function(e,t){function a(){return new r((function(r,o){n(e,t,r,o)}))}return o=o?o.then(a,a):a()}})}function I(e,t,r){var o=h;return function(a,i){if(o===g)throw Error("Generator is already running");if(o===y){if("throw"===a)throw i;return{value:n,done:!0}}for(r.method=a,r.arg=i;;){var c=r.delegate;if(c){var l=F(c,r);if(l){if(l===b)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=g;var u=v(e,t,r);if("normal"===u.type){if(o=r.done?y:m,u.arg===b)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=y,r.method="throw",r.arg=u.arg)}}}function F(e,t){var r=t.method,o=e.iterator[r];if(o===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=n,F(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var a=v(o,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,b;var i=a.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=n),t.delegate=null,b):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,b)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function j(e){if(e||""===e){var r=e[u];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function t(){for(;++o<e.length;)if(i.call(e,o))return t.value=e[o],t.done=!1,t;return t.value=n,t.done=!0,t};return a.next=a}}throw new TypeError(t(e)+" is not iterable")}return w.prototype=S,c(E,"constructor",{value:S,configurable:!0}),c(S,"constructor",{value:w,configurable:!0}),w.displayName=d(S,f,"GeneratorFunction"),o.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},o.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,d(e,f,"GeneratorFunction")),e.prototype=Object.create(E),e},o.awrap=function(e){return{__await:e}},A(N.prototype),d(N.prototype,s,(function(){return this})),o.AsyncIterator=N,o.async=function(e,t,r,n,a){void 0===a&&(a=Promise);var i=new N(p(e,t,r,n),a);return o.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},A(E),d(E,f,"Generator"),d(E,u,(function(){return this})),d(E,"toString",(function(){return"[object Generator]"})),o.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},o.values=j,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(L),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=n)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,o){return c.type="throw",c.arg=e,t.next=r,o&&(t.method="next",t.arg=n),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var l=i.call(a,"catchLoc"),u=i.call(a,"finallyLoc");if(l&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),L(r),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:j(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=n),b}},o}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(M);var R=M.exports(),z=R;try{regeneratorRuntime=R}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=R:Function("r","regeneratorRuntime = r")(R)}function T(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,c=[],l=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=a.call(r)).done)&&(c.push(n.value),c.length!==t);l=!0);}catch(e){u=!0,o=e}finally{try{if(!l&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||F(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function D(e){var t=function(e,t){if("object"!=L(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=L(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==L(t)?t:t+""}function H(e,t,r){return(t=D(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var G=e({name:"Saturation",props:{size:{type:Number,default:160},hue:{type:Number,default:0},saturation:{type:Number,default:0},value:{type:Number,default:0}},emits:["change"],setup:function(e,r){var n=r.emit,o=t((function(){return{width:"".concat(e.size,"px"),height:"".concat(e.size,"px"),background:"hsl(".concat(e.hue,", 100%, 50%)")}}));return{saturationStyle:o,sliderStyle:t((function(){return{top:"".concat((100-e.value)/100*e.size-5,"px"),left:"".concat(e.saturation*e.size/100-5,"px"),width:"".concat(10,"px"),height:"".concat(10,"px")}})),onSelect:function(t){var r=t.target.getBoundingClientRect(),o=r.left,a=r.top,i=function(t){var r,i;t instanceof MouseEvent?(r=t.clientX,i=t.clientY):t instanceof TouchEvent&&(r=t.touches[0].clientX,i=t.touches[0].clientY);var c=r-o,l=i-a;c<0&&(c=0),l<0&&(l=0),c>e.size&&(c=e.size),l>e.size&&(l=e.size);var u=c/e.size*100,s=100-l/e.size*100;n("change",u,s)};i(t);var c=function(){document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",c),document.removeEventListener("touchmove",i),document.removeEventListener("touchend",c)};i(t),t instanceof MouseEvent&&(document.addEventListener("mousemove",i),document.addEventListener("mouseup",c)),t instanceof TouchEvent&&(t.preventDefault(),document.addEventListener("touchmove",i,{passive:!1}),document.addEventListener("touchend",c))}}}});function V(e,t){void 0===t&&(t={});var r=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===r&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}V(".saturation[data-v-24517fec]{position:relative}.saturation-black[data-v-24517fec],.saturation-white[data-v-24517fec]{cursor:pointer;height:100%;left:0;position:absolute;top:0;width:100%}.saturation-white[data-v-24517fec]{background:linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.saturation-black[data-v-24517fec]{background:linear-gradient(0deg,#000,transparent)}.slider[data-v-24517fec]{border:1px solid #fff;border-radius:50%;box-shadow:0 0 1px 1px rgba(0,0,0,.3);left:0;pointer-events:none;position:absolute;top:0;z-index:1}"),G.render=function(e,t,c,l,u,s){return r(),n("div",{class:"saturation",style:o(e.saturationStyle),onMousedown:t[0]||(t[0]=a((function(){return e.onSelect&&e.onSelect.apply(e,arguments)}),["prevent","stop"])),onTouchstart:t[1]||(t[1]=a((function(){return e.onSelect&&e.onSelect.apply(e,arguments)}),["prevent","stop"]))},[t[2]||(t[2]=i("div",{class:"saturation-white"},null,-1)),t[3]||(t[3]=i("div",{class:"saturation-black"},null,-1)),i("div",{class:"slider",style:o(e.sliderStyle)},null,4)],36)},G.__scopeId="data-v-24517fec",G.__file="src/picker/Saturation.vue";var Y=e({name:"Hue",props:{width:{type:Number,default:15},height:{type:Number,default:160},hue:{type:Number,default:0}},emits:["change"],setup:function(e,r){var n=r.emit,o=t((function(){return{top:"".concat((1-e.hue/360)*e.height-2,"px"),height:"".concat(4,"px")}})),a=c();l((function(){!function(){if(a.value){a.value.width=e.width,a.value.height=e.height;var t=a.value.getContext("2d");if(t){var r=t.createLinearGradient(0,0,0,e.height);r.addColorStop(0,"#FF0000"),r.addColorStop(.17,"#FF00FF"),r.addColorStop(.34,"#0000FF"),r.addColorStop(.51,"#00FFFF"),r.addColorStop(.68,"#00FF00"),r.addColorStop(.17*5,"#FFFF00"),r.addColorStop(1,"#FF0000"),t.fillStyle=r,t.fillRect(0,0,e.width,e.height)}}}()}));return{canvas:a,sliderStyle:o,onSelect:function(t){var r=t.target.getBoundingClientRect().top,o=function(t){var o;t instanceof MouseEvent?o=t.clientY:t instanceof TouchEvent&&(o=t.touches[0].clientY);var a=o-r;a<0&&(a=0),a>e.height&&(a=e.height);var i=-100*a/e.height+100;n("change",360*i/100)},a=function(){document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a),document.removeEventListener("touchmove",o),document.removeEventListener("touchend",a)};o(t),t instanceof MouseEvent&&(document.addEventListener("mousemove",o),document.addEventListener("mouseup",a)),t instanceof TouchEvent&&(t.preventDefault(),document.addEventListener("touchmove",o,{passive:!1}),document.addEventListener("touchend",a))}}}}),$={ref:"canvas"};V(".hue[data-v-78b9f4f0]{position:relative;touch-action:none}.slider[data-v-78b9f4f0]{background:#fff;box-shadow:0 0 1px 0 rgba(0,0,0,.3);left:0;pointer-events:none;position:absolute;width:100%;z-index:1}"),Y.render=function(e,t,c,l,u,s){return r(),n("div",{class:"hue",onMousedown:t[0]||(t[0]=a((function(){return e.onSelect&&e.onSelect.apply(e,arguments)}),["prevent","stop"])),onTouchstart:t[1]||(t[1]=a((function(){return e.onSelect&&e.onSelect.apply(e,arguments)}),["prevent","stop"]))},[i("canvas",$,null,512),i("div",{class:"slider",style:o(e.sliderStyle)},null,4)],32)},Y.__scopeId="data-v-78b9f4f0",Y.__file="src/picker/Hue.vue";var X=e({name:"Alpha",props:{width:{type:Number,default:15},height:{type:Number,default:160},color:{type:String,default:"#000000"},alpha:{type:Number,default:1}},setup:function(e,r){var n=r.emit,o=t((function(){return{top:"".concat(e.alpha*e.height-2,"px"),height:"".concat(4,"px")}})),a=c(),i=function(){var t=a.value.getContext("2d");a.value.width=e.width,a.value.height=e.height;var r=function(e){var t=document.createElement("canvas"),r=t.getContext("2d"),n=2*e;return t.width=n,t.height=n,r.fillStyle="#ffffff",r.fillRect(0,0,n,n),r.fillStyle="#ccd5db",r.fillRect(0,0,e,e),r.fillRect(e,e,e,e),t}(5);t.fillStyle=t.createPattern(r,"repeat"),t.fillRect(0,0,e.width,e.height);var n=t.createLinearGradient(0,0,0,e.height);n.addColorStop(.01,"rgba(255,255,255,0)"),n.addColorStop(.99,e.color),t.fillStyle=n,t.fillRect(0,0,e.width,e.height)};u((function(){return e.color}),(function(){i()})),l((function(){i()}));return{canvas:a,sliderStyle:o,onSelect:function(t){var r=t.target.getBoundingClientRect().top,o=function(t){var o;t instanceof MouseEvent?o=t.clientY:t instanceof TouchEvent&&(o=t.touches[0].clientY);var a=o-r;a<0&&(a=0),a>e.height&&(a=e.height);var i=parseFloat((a/e.height).toFixed(2));n("change",i)},a=function(){document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a),document.removeEventListener("touchmove",o),document.removeEventListener("touchend",a)};o(t),t instanceof MouseEvent&&(document.addEventListener("mousemove",o),document.addEventListener("mouseup",a)),t instanceof TouchEvent&&(t.preventDefault(),document.addEventListener("touchmove",o,{passive:!1}),document.addEventListener("touchend",a))}}}}),J={ref:"canvas"};V(".alpha[data-v-24dc9656]{position:relative;touch-action:none}.slider[data-v-24dc9656]{background:#fff;box-shadow:0 0 1px 0 rgba(0,0,0,.3);left:0;pointer-events:none;position:absolute;width:100%;z-index:1}"),X.render=function(e,t,c,l,u,s){return r(),n("div",{class:"alpha",onMousedown:t[0]||(t[0]=a((function(){return e.onSelect&&e.onSelect.apply(e,arguments)}),["prevent","stop"])),onTouchstart:t[1]||(t[1]=a((function(){return e.onSelect&&e.onSelect.apply(e,arguments)}),["prevent","stop"]))},[i("canvas",J,null,512),i("div",{class:"slider",style:o(e.sliderStyle)},null,4)],32)},X.__scopeId="data-v-24dc9656",X.__file="src/picker/Alpha.vue";var q={rgb:"RGBA",hex:"HEX",hsl:"HSLA",hsv:"HSVA"},U={rgb:"RGB",hex:"HEX",hsl:"HSL",hsv:"HSV"},W={RGB:"rgb",RGBA:"rgb",HEX:"hex",HSL:"hsl",HSLA:"hsl",HSV:"hsv",HSVA:"hsv"};function K(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?K(Object(r),!0).forEach((function(t){H(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):K(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Z=null,ee=function(e,t,r){var n=c({}),o=r||{},a=o.placement,i=o.defaultStyle,l={strategy:o.strategy||"absolute",placement:a||"auto",onFirstUpdate:function(){Z.update()},modifiers:[{name:"offset",options:{offset:[0,5]}},{name:"computeStyles",options:{gpuAcceleration:!1,adaptive:!0}},{name:"flip",options:{allowedAutoPlacements:["top","bottom"]}},{name:"applyStyles",enabled:!1},{name:"updateState",enabled:!0,phase:"write",requires:["computeStyles"],fn:function(e){var t=e.state,r=t.styles,o=t.placement,a=r.popper;n.value=Q(Q(Q({},a),i),{},{transformOrigin:"top"===o?"center bottom":"center top"})}}]};return u((function(){return[s(e),s(t)]}),(function(e,t){var r,n=T(e,2),o=n[0],a=n[1],i=T(t,2),c=i[0],u=i[1];if(o&&a&&(c!==o||u!==c)){null===(r=Z)||void 0===r||r.destroy();var s=o.$el||o,d=a.$el||a;f((function(){Z=N(s,d,l)}))}})),d((function(){var e;Z&&(null===(e=Z)||void 0===e||e.destroy(),Z=null)})),{instance:Z,style:n}},te=e({props:{value:{type:String,default:"RGBA"},showAlpha:{type:Boolean},options:{type:[Boolean,Array]}},emits:["change"],setup:function(e,r){var n=r.emit,o=c(null),a=c(null),i=c(!1),u=ee(o,a,{strategy:"fixed",defaultStyle:{zIndex:2}}).style,f=t((function(){return Array.isArray(e.options)&&e.options.length>1})),d=t((function(){var t=e.options,r=e.showAlpha,n=e.value;return Array.isArray(t)?r?t.map((function(e){return q[e]})).filter((function(e){return!e.includes(n)})):t.map((function(e){return U[e]})).filter((function(e){return!e.includes(n)})):[]})),v=function(e){var t,r,n=e.target;!(null!==(t=s(o))&&void 0!==t&&t.isEqualNode(n))&&(null===(r=s(o))||void 0===r?void 0:r.contains(n))||(i.value=!1)};return l((function(){document.addEventListener("mouseup",v,!1)})),p((function(){document.removeEventListener("mouseup",v,!1)})),{targetRef:o,selectorRef:a,selectorStyle:u,isShowSelector:i,isNeedSelect:f,formatOptions:d,onShow:function(){f.value&&(i.value=!0)},onFormatChange:function(e){n("change",W[e])}}}}),re={class:"format"},ne={key:0,class:"arrow"},oe=["onClick"];V(".format[data-v-5f6e8f5e]{position:relative}.label[data-v-5f6e8f5e]{align-items:center;background:#e7e8e9;color:#999;display:flex;float:left;font-weight:500;height:30px;justify-content:center;position:relative;width:60px}[pick-colors-theme=dark] .label[data-v-5f6e8f5e]{background:#252930;color:#999}.arrow[data-v-5f6e8f5e]{height:6px;margin-bottom:4px;margin-left:5px;transform:rotate(135deg);width:6px}.arrow[data-v-5f6e8f5e],[pick-colors-theme=dark] .arrow[data-v-5f6e8f5e]{border-right:1px solid #999;border-top:1px solid #999}.selector[data-v-5f6e8f5e]{align-items:center;background:#f7f8f9;border-radius:5px;box-shadow:0 0 16px 0 rgba(0,0,0,.16);cursor:pointer;display:flex;flex-direction:column;font-weight:400;justify-content:center;padding:4px}[pick-colors-theme=dark] .selector[data-v-5f6e8f5e]{background:#252930;color:#999}.selector-item[data-v-5f6e8f5e]{align-items:center;display:flex;height:30px;justify-content:center;width:60px}.selector-item[data-v-5f6e8f5e]:hover{background:#e1f2fe}[pick-colors-theme=dark] .selector-item[data-v-5f6e8f5e]{color:#fff}[pick-colors-theme=dark] .selector-item[data-v-5f6e8f5e]:hover{background:#0087fa}.active-selector-item[data-v-5f6e8f5e]{background:#e1f2fe}[pick-colors-theme=dark] .active-selector-item[data-v-5f6e8f5e]{background:#0087fa}.v-enter-active[data-v-5f6e8f5e],.v-leave-active[data-v-5f6e8f5e]{opacity:1;transform:scaleY(1);transform-origin:center top;transition:opacity .2s ease-in-out,transform .2s ease-in-out}.v-enter-from[data-v-5f6e8f5e],.v-leave-to[data-v-5f6e8f5e]{opacity:0;transform:scaleY(0)}"),te.render=function(e,t,a,c,l,u){return r(),n("div",re,[i("div",{class:"label",ref:"targetRef",onClick:t[0]||(t[0]=function(){return e.onShow&&e.onShow.apply(e,arguments)})},[i("span",null,v(e.value),1),e.isNeedSelect?(r(),n("div",ne)):h("v-if",!0)],512),m(g,null,{default:y((function(){return[e.isShowSelector?(r(),n("div",{key:0,class:"selector",ref:"selectorRef",style:o(e.selectorStyle)},[(r(!0),n(b,null,x(e.formatOptions,(function(t){return r(),n("div",{class:"selector-item",key:t,onClick:function(r){return e.onFormatChange(t)}},v(t),9,oe)})),128))],4)):h("v-if",!0)]})),_:1})])},te.__scopeId="data-v-5f6e8f5e",te.__file="src/picker/input-value/FormatValue.vue";var ae=e({name:"Input",components:{FormatValue:te},props:{format:{type:String,default:"RGBA"},value:{type:String,default:""},width:{type:Number},showAlpha:{type:Boolean},formatOptions:{type:[Boolean,Array]}},emits:["change","focus","blur","enter","formatChange"],setup:function(e,r){var n=r.emit;return{onInput:function(e){var t;n("change",null===(t=e.target)||void 0===t?void 0:t.value)},valueStyle:t((function(){return{minWidth:"".concat(e.width,"px"),maxWidth:"".concat(e.width,"px"),width:"".concat(e.width,"px")}})),onFocus:function(){n("focus")},onBlur:function(){n("blur")},onEnter:function(){n("enter")},onFormatChange:function(e){n("formatChange",e)}}}}),ie={class:"input"},ce=[".value"];function le(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ue(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?le(Object(r),!0).forEach((function(t){H(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):le(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}V(".input[data-v-2c454c00]{display:flex;font-size:12px}.value[data-v-2c454c00]{background:#eceef0;border:1px solid #eceef0;box-sizing:border-box;color:#666;flex:1;height:30px;text-align:center}[pick-colors-theme=dark] .value[data-v-2c454c00]{background:#2e333a;border:1px solid #2e333a;color:#fff}.value[data-v-2c454c00]:focus{border:1px solid #1890ff;outline:none}"),ae.render=function(e,t,a,c,l,u){var s=w("FormatValue");return r(),n("div",ie,[m(s,{value:e.format,showAlpha:e.showAlpha,options:e.formatOptions,onChange:e.onFormatChange},null,8,["value","showAlpha","options","onChange"]),i("input",{class:"value",style:o(e.valueStyle),".value":e.value,onFocus:t[0]||(t[0]=function(){return e.onFocus&&e.onFocus.apply(e,arguments)}),onInput:t[1]||(t[1]=function(){return e.onInput&&e.onInput.apply(e,arguments)}),onBlur:t[2]||(t[2]=function(){return e.onBlur&&e.onBlur.apply(e,arguments)}),onKeydown:t[3]||(t[3]=S((function(){return e.onEnter&&e.onEnter.apply(e,arguments)}),["enter"]))},null,44,ce)])},ae.__scopeId="data-v-2c454c00",ae.__file="src/picker/input-value/InputValue.vue";var se=function(e,t,r){return[e,t*r/((e=(2-t)*r)<1?e:2-e)||0,e/2]},fe={10:"A",11:"B",12:"C",13:"D",14:"E",15:"F"},de=function(e){e=Math.min(Math.round(e),255);var t=Math.floor(e/16),r=e%16;return"".concat(fe[t]||t).concat(fe[r]||r)},pe=function(e){var t=e.r,r=e.g,n=e.b;return isNaN(t)||isNaN(r)||isNaN(n)?"":"#".concat(de(t)).concat(de(r)).concat(de(n))},ve=function(e,t){var r;"string"==typeof(r=e)&&-1!==r.indexOf(".")&&1===parseFloat(r)&&(e="100%");var n=function(e){return"string"==typeof e&&-1!==e.indexOf("%")}(e);return e=Math.min(t,Math.max(0,parseFloat("".concat(e)))),n&&(e=parseInt("".concat(e*t),10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)},he=function(e,t,r){e=6*ve(e,360),t=ve(t,100),r=ve(r,100);var n=Math.floor(e),o=e-n,a=r*(1-t),i=r*(1-o*t),c=r*(1-(1-o)*t),l=n%6,u=[r,i,a,a,c,r][l],s=[c,r,r,i,a,a][l],f=[a,a,c,r,r,i][l];return{r:Math.round(255*u),g:Math.round(255*s),b:Math.round(255*f)}},me=function(e,t,r){var n,o,a=e.h,i=e.s,c=e.v,l=e.a;if(r)switch(["hsl","hsv","rga"].includes(t)&&(l=(o=(n=l).toString().match(/\.(\d{1,2})(\d*)/))&&o[2].length>0?parseFloat(n.toFixed(2)):n),t){case"hsl":var u=se(a,i/100,c/100);return"hsla(".concat(a.toFixed(0),", ").concat(Math.round(100*u[1]),"%, ").concat(Math.round(100*u[2]),"%, ").concat(l,")");case"hsv":return"hsva(".concat(a.toFixed(0),", ").concat(Math.round(i),"%, ").concat(Math.round(c),"%, ").concat(l,")");case"rgb":var s=he(a,i,c),f=s.r,d=s.g,p=s.b;return"rgba(".concat(f,", ").concat(d,", ").concat(p,", ").concat(l,")");default:return"".concat(pe(he(a,i,c))).concat(de(255*l))}else switch(t){case"hsl":var v=se(a,i/100,c/100);return"hsl(".concat(a.toFixed(0),", ").concat(Math.round(100*v[1]),"%, ").concat(Math.round(100*v[2]),"%)");case"hsv":return"hsv(".concat(a.toFixed(0),", ").concat(Math.round(i),"%, ").concat(Math.round(c),"%)");case"rgb":var h=he(a,i,c),m=h.r,g=h.g,y=h.b;return"rgb(".concat(m,", ").concat(g,", ").concat(y,")");default:return pe(he(a,i,c))}},ge=function(e){var t=e.r,r=e.g,n=e.b;t=ve(t,255),r=ve(r,255),n=ve(n,255);var o,a=Math.max(t,r,n),i=Math.min(t,r,n),c=a,l=a-i,u=0===a?0:l/a;if(a===i)o=0;else{switch(a){case t:o=(r-n)/l+(r<n?6:0);break;case r:o=(n-t)/l+2;break;case n:o=(t-r)/l+4}o/=6}return{h:360*o,s:100*u,v:100*c}},ye=function(e){var t=e.h,r=e.s,n=e.l;n/=100;var o=r/=100,a=Math.max(n,.01);return r*=(n*=2)<=1?n:2-n,o*=a<=1?a:2-a,{h:+t,s:100*(0===n?2*o/(a+o):2*r/(n+r)),v:100*((n+r)/2)}},be=function(e){var t=[];if(e.match(/^#([0-9a-fA-f]{3,4})$/g))for(var r=1;r<e.length;r++)t.push(parseInt("0x"+e[r].repeat(2)));else if(e.match(/^#([0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/g))for(var n=1;n<e.length;n+=2)t.push(parseInt("0x"+e.slice(n,n+2)));return{r:t[0],g:t[1],b:t[2],a:t[3]}},xe=function(e,t,r){if("string"==typeof e&&""!==e){var n=Ce(e,Oe(e),r),o=Ee(n);return null==o?"":me(o,t,r)}return""},we=function(e){var t=T(e.match(/(\d(\.\d+)?)+/g),4);return{r:t[0],g:t[1],b:t[2],a:t[3]}},Se=function(e){var t=T(e.match(/(\d(\.\d+)?)+/g),4),r=t[0],n=t[1],o=t[2],a=t[3];return{h:r,s:parseFloat(n),l:parseFloat(o),a:a}},ke=function(e){var t=T(e.match(/(\d(\.\d+)?)+/g),4),r=t[0],n=t[1],o=t[2],a=t[3];return{h:parseFloat(r),s:parseFloat(n),v:parseFloat(o),a:parseFloat(a)}},Ce=function(e,t){if(!(arguments.length>2&&void 0!==arguments[2])||arguments[2])switch(t){case"rgb":var r=we(e),n=r.r,o=r.g,a=r.b,i=r.a;return ue(ue({},ge({r:n,g:o,b:a})),{},{a:+i});case"hsv":var c=ke(e);return{h:c.h,s:c.s,v:c.v,a:c.a};case"hsl":var l=Se(e),u=l.h,s=l.s,f=l.l,d=l.a;return ue(ue({},ye({h:u,s:s,l:f})),{},{a:+d});default:var p=be(e),v=p.r,h=p.g,m=p.b,g=p.a;return ue(ue({},ge({r:v,g:h,b:m})),{},{a:g/255})}else{switch(t){case"rgb":return ue(ue({},ge(we(e))),{},{a:1});case"hsv":var y=ke(e);return{h:y.h,s:y.s,v:y.v,a:1};case"hsl":return ue(ue({},ye(Se(e))),{},{a:1});default:return ue(ue({},ge(be(e))),{},{a:1})}}},Oe=function(e){return e.match(/^#/)?"hex":e.match(/^rgb/)?"rgb":e.match(/^hsl/)?"hsl":e.match(/^hsv/)?"hsv":"hex"},Ee=function(e){var t=e.h,r=e.s,n=e.v,o=e.a;return isNaN(t)&&isNaN(r)&&isNaN(n)?null:(isNaN(t)&&(t=0),isNaN(r)&&(r=0),isNaN(n)&&(n=0),isNaN(o)&&(o=1),{h:t,s:r,v:n,a:o})},Ae=e({name:"ColorItem",props:{size:{type:[Number,String],default:20},width:{type:[Number,String]},height:{type:[Number,String]},value:{type:String,default:""},border:{type:Boolean,default:!0},borderRadius:{type:Number,default:5},selected:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1}},emits:["select"],setup:function(e){var r=c(),n=k("theme",{theme:"light"}).theme,o=t((function(){return parseFloat((e.width||e.size)+"")})),a=t((function(){return parseFloat((e.height||e.size)+"")})),i=t((function(){return{width:"".concat(s(o),"px"),height:"".concat(s(a),"px"),border:e.border?"1px solid ".concat("dark"===s(n)?"#434345":"#d9d9d9"):"",borderRadius:"".concat(e.borderRadius,"px"),boxShadow:e.selected?"0 0 3px 2px ".concat("dark"===s(n)?"#2681ff":"#1890ff"):""}})),f=function(){var t=r.value.getContext("2d");r.value.width=s(o),r.value.height=s(a);var n=function(e){var t=document.createElement("canvas"),r=t.getContext("2d"),n=2*e;return t.width=n,t.height=n,r.fillStyle="#ffffff",r.fillRect(0,0,n,n),r.fillStyle="#ccd5db",r.fillRect(0,0,e,e),r.fillRect(e,e,e,e),t}(5);t.fillStyle=t.createPattern(n,"repeat"),t.fillRect(0,0,s(o),s(a)),t.fillStyle=e.value,t.fillRect(0,0,s(o),s(a))};return u((function(){return e.value}),(function(){f()})),l((function(){f()})),{canvas:r,colorItemStyle:i}}}),Ne=["draggable"];V(".color-item[data-v-02da71fd]{display:inline-block;vertical-align:top}"),Ae.render=function(e,t,a,i,c,l){return r(),n("canvas",{class:"color-item",style:o(e.colorItemStyle),ref:"canvas",draggable:e.draggable},null,12,Ne)},Ae.__scopeId="data-v-02da71fd",Ae.__file="src/color-item/ColorItem.vue";var Ie=e({name:"Colors",components:{ColorItem:Ae},props:{colors:{type:Array,default:function(){return[]}},selectedIndex:{type:Number,default:-1}},emits:["change"],setup:function(e,r){var n=r.emit;return{onSelectColor:function(e,t){n("change",e,t)},useColors:t((function(){return e.colors.map((function(e){return xe(e,"hex",!0)}))}))}}}),Fe={class:"colors"};function _e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Le(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_e(Object(r),!0).forEach((function(t){H(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_e(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}V(".colors[data-v-0f8b52a8]{align-items:center;display:flex;flex-wrap:wrap;margin-top:5px}.color-item[data-v-0f8b52a8]{margin:5px}"),Ie.render=function(e,t,o,i,c,l){var u=w("color-item");return r(),n("div",Fe,[(r(!0),n(b,null,x(e.useColors,(function(t,n){return r(),C(u,{key:n,class:"color-item",size:16,value:t,border:!1,"border-radius":3,selected:e.selectedIndex===n,onClick:a((function(r){return e.onSelectColor(t,+n)}),["stop","prevent"])},null,8,["value","selected","onClick"])})),128))])},Ie.__scopeId="data-v-0f8b52a8",Ie.__file="src/picker/Colors.vue";var Pe=e({name:"Picker",components:{Colors:Ie,Saturation:G,Hue:Y,Alpha:X,InputValue:ae},props:{format:{type:String,default:"hex"},showAlpha:{type:Boolean,default:!1},value:{type:String,default:""},colors:{type:Array,default:function(){return[]}},style:{type:Object,default:function(){return{}}},formatOptions:{type:[Boolean,Array]}},emits:["change","formatChange"],setup:function(e,r){var n=r.emit,o=t((function(){return Le(Le({},e.style),{},{width:e.showAlpha?"230px":"205px"})})),a=c(),i=c(),l=c(),f=function(){var t,r=null===(t=e.value)||void 0===t?void 0:t.trim();if(null!=r&&""!==r){var n=Oe(r);return Ee(Ce(r,n,e.showAlpha))}return null};u((function(){return e.value}),(function(){e.value!==s(l)&&(a.value=f())}),{immediate:!0}),u((function(){return[s(a),e.format]}),(function(t){var r=T(t,2),o=r[0],a=r[1],c="";null!=o?(c=me(Le({},o),e.format,e.showAlpha),i.value=Le({},o)):i.value=null,l.value=c;var u=f();JSON.stringify(o)!==JSON.stringify(u)&&JSON.stringify(o)!==JSON.stringify(a)&&n("change",c)}),{immediate:!0});var d=t((function(){var e;return(null===(e=s(a))||void 0===e?void 0:e.h)||0})),p=t((function(){var e;return(null===(e=s(a))||void 0===e?void 0:e.s)||0})),v=t((function(){var e;return(null===(e=s(a))||void 0===e?void 0:e.v)||0})),h=t((function(){var e,t;return null!=(null===(e=s(a))||void 0===e?void 0:e.a)?null===(t=s(a))||void 0===t?void 0:t.a:1})),m=t((function(){return he(s(d),s(p),s(v))})),g=t((function(){return"rgb(".concat(s(m).r,", ").concat(s(m).g,", ").concat(s(m).b,")")})),y=c(-1);return{h:d,s:p,v:v,a:h,rgbStr:g,onSelectSaturation:function(e,t){y.value=-1,null==s(a)?a.value={h:s(d),s:e,v:t,a:s(h)}:a.value=Le(Le({},s(a)),{},{s:e,v:t})},onSelectHue:function(e){y.value=-1,null==s(a)&&(a.value={h:e,s:s(p),v:s(v),a:s(h)}),a.value=Le(Le({},s(a)),{},{h:e})},onSelectAlpha:function(e){y.value=-1,null==s(a)?a.value={h:s(d),s:s(p),v:s(v),a:e}:a.value=Le(Le({},s(a)),{},{a:e})},handleInputFormat:function(t){return e.showAlpha?q[t]:U[t]},colorValue:l,pickerStyle:o,onInputChange:function(e){y.value=-1,l.value=e},handleChange:function(){var t,r=null===(t=s(l))||void 0===t?void 0:t.trim();if(""!==r){var n=e.showAlpha,o=Oe(r),c=Ee(Ce(r,o,n)),u=function(e){if(!e)return!1;var t=e.h,r=e.s,n=e.v,o=e.a;return!(isNaN(t)||isNaN(r)||isNaN(n)||isNaN(o))}(c);u?a.value=c:null!=s(i)?a.value=s(i):l.value=""}else a.value=null},selectColorIndex:y,onSelectColor:function(e,t){if(y.value=t,""===(e=e.trim()))a.value=null;else{var r=Oe(e);r?function(e,t,r){if(0!==e.length){var n=Ce(e,t,r),o=n.h,i=n.s,c=n.v;if(!(isNaN(o)||isNaN(i)||isNaN(c))){var l=1,u=n.a;isNaN(u)||(l=u),a.value={h:o,s:i,v:c,a:l}}}}(e,r,!0):a.value=null}},onFormatChange:function(e){n("formatChange",e)}}}}),je={class:"picker-inner"},Me={class:"picker-header"};V(".picker[data-v-6ceadec6]{background:#f7f8f9;border-radius:4px;box-shadow:0 0 16px 0 rgba(0,0,0,.16)}.picker-inner[data-v-6ceadec6]{padding:10px}[pick-colors-theme=dark] .picker-inner[data-v-6ceadec6]{background:#1d2024;box-shadow:0 0 16px 0 rgba(0,0,0,.16)}.picker-header[data-v-6ceadec6]{display:flex;margin-bottom:5px}.alpha[data-v-6ceadec6],.hue[data-v-6ceadec6]{margin-left:10px}.colors[data-v-6ceadec6]{margin-top:5px}"),Pe.render=function(e,t,a,c,l,u){var s=w("saturation"),f=w("hue"),d=w("alpha"),p=w("input-value"),v=w("Colors");return r(),n("div",{class:"picker",style:o(e.pickerStyle)},[i("div",je,[i("div",Me,[m(s,{class:"saturation",hue:e.h,saturation:e.s,value:e.v,onChange:e.onSelectSaturation},null,8,["hue","saturation","value","onChange"]),m(f,{class:"hue",hue:e.h,onChange:e.onSelectHue},null,8,["hue","onChange"]),e.showAlpha?(r(),C(d,{key:0,class:"alpha",alpha:e.a,color:e.rgbStr,onChange:e.onSelectAlpha},null,8,["alpha","color","onChange"])):h("v-if",!0)]),m(p,{format:e.handleInputFormat(e.format),value:e.colorValue,showAlpha:e.showAlpha,width:e.showAlpha?150:125,formatOptions:e.formatOptions,onChange:e.onInputChange,onBlur:e.handleChange,onEnter:e.handleChange,onFormatChange:e.onFormatChange},null,8,["format","value","showAlpha","width","formatOptions","onChange","onBlur","onEnter","onFormatChange"]),e.colors.length>0?(r(),C(v,{key:0,class:"colors",colors:e.colors,"selected-index":e.selectColorIndex,onChange:e.onSelectColor},null,8,["colors","selected-index","onChange"])):h("v-if",!0)])],4)},Pe.__scopeId="data-v-6ceadec6",Pe.__file="src/picker/Picker.vue";var Be=e({name:"AddColorItem",props:{size:{type:Number,default:20},selected:{type:Boolean,default:!1}},setup:function(e){var r=k("theme",{theme:"light"}).theme;return{addColorItemStyle:t((function(){return{width:"".concat(e.size,"px"),height:"".concat(e.size,"px"),lineHeight:"".concat(e.size,"px"),boxShadow:e.selected?"0 0 3px 2px ".concat("dark"===s(r)?"#2681ff":"#1890ff"):""}}))}}});V(".add-color-item[data-v-ceb1719c]{background:#fff;border:1px solid #d9d9d9;border-radius:5px;vertical-align:top}.container[data-v-ceb1719c]{pointer-events:none;transform:scale(.9);transform-origin:center}[pick-colors-theme=dark] .add-color-item[data-v-ceb1719c]{background:#141414;border:1px solid #434343}path[data-v-ceb1719c]{fill:#000}[pick-colors-theme=dark] path[data-v-ceb1719c]{fill:#fff}"),Be.render=function(e,t,a,c,l,u){return r(),n("svg",{class:"add-color-item",style:o(e.addColorItemStyle),viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},t[0]||(t[0]=[i("g",{class:"container"},[i("path",{d:"M544 464V160h-80v304H160v80h304v304h80V544h304v-80z"})],-1)]),4)},Be.__scopeId="data-v-ceb1719c",Be.__file="src/add-color-item/AddColorItem.vue";var Re=e({name:"ColorPicker",components:{ColorItem:Ae,Picker:Pe,AddColorItem:Be},props:{value:{type:[String,Array]},theme:{type:String,default:"light"},size:{type:[Number,String],default:20},width:{type:[Number,String]},height:{type:[Number,String]},format:{type:String},showPicker:{type:Boolean,default:void 0},showAlpha:{type:Boolean,default:!1},addColor:{type:Boolean,default:!1},deleteColor:{type:Boolean,default:!0},max:{type:Number,default:13},popupContainer:{type:[String,Object,Boolean],default:"body"},zIndex:{type:Number,default:1e3},colors:{type:Array,default:function(){return["#ff4500","#ff8c00","#ffd700","#90ee90","#00ced1","#1e90ff","#c71585","#ff4500","#ff7d4d","#00babd","#1f93ff","#fa64c3"]}},position:{type:String},placement:{type:String},formatOptions:{type:[Boolean,Array],default:!1}},emits:["change","update:value","update:showPicker","overflowMax","closePicker","formatChange"],setup:function(e,r){var n=r.emit,o=c([]),a=t((function(){return s(o).map((function(t){return xe(t,"hex",e.showAlpha)}))})),i=c("hex");u((function(){return e.format}),(function(){i.value=e.format}),{immediate:!0});u((function(){return e.value}),(function(){var t=e.value||"",r=Array.isArray(t)?t:[t];o.value=r.map((function(t){return xe(t,s(i),e.showAlpha)}))}),{immediate:!0});var d=c(void 0),v=t((function(){return s(o)[s(d)]})),h=c(!1);u((function(){return e.showPicker}),(function(){h.value=e.showPicker}),{immediate:!0});var m,g,y=c(null),b=c(null),x=ee(y,b,{defaultStyle:{zIndex:e.zIndex},strategy:e.position,placement:e.placement}).style,w=function(){null==s(y)&&(y.value=s(B)[0]),null==s(d)&&(d.value=0),void 0===e.showPicker?h.value=!0:n("update:showPicker",!0)},S=function(){d.value=void 0,void 0===e.showPicker?h.value=!1:n("update:showPicker",!1),n("closePicker",E(Array.isArray(e.value)||e.addColor?s(o):s(o)[0]))},k=c(),C=function(){var e=j(z.mark((function e(t){var r,n,o,a;return z.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.target,null!=(o=null===(r=n.dataset)||void 0===r?void 0:r.index)&&""!==o){e.next=4;break}return e.abrupt("return");case 4:if(a=+o,s(d)!==a){e.next=7;break}return e.abrupt("return");case 7:null!=s(d)&&s(d)!==a?(S(),m&&clearTimeout(m),m=setTimeout((function(){w(),clearTimeout(m)}),100)):w(),d.value=a,y.value=n;case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),A=function(){var e=j(z.mark((function e(t){var r,n,o,a,i;return z.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=t.target,!(!(null!==(r=s(k))&&void 0!==r&&r.isEqualNode(a))&&(null===(n=s(k))||void 0===n?void 0:n.contains(a)))){e.next=4;break}return e.abrupt("return");case 4:if(i=null===(o=s(b))||void 0===o?void 0:o.$el,!((null==i?void 0:i.contains(a))||!1)){e.next=8;break}return e.abrupt("return");case 8:g&&clearTimeout(g),g=setTimeout((function(){s(h)&&S()}),0);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();u(h,(function(){s(h)&&(w(),clearTimeout(g))}));var N,I=c(e.max>s(o).length),F=t((function(){return"string"==typeof e.popupContainer||"object"===L(e.popupContainer)&&null!=e.popupContainer?e.popupContainer:"body"})),P=t((function(){return"boolean"==typeof e.popupContainer&&!1===e.popupContainer})),M=t((function(){return e.theme}));u((function(){return[e.theme,s(b)]}),(function(){f((function(){var e,t;null===(e=s(k))||void 0===e||e.setAttribute("pick-colors-theme",s(M)),null===(t=s(b))||void 0===t||null===(t=t.$el)||void 0===t||t.setAttribute("pick-colors-theme",s(M))}))}),{immediate:!0}),O("theme",{theme:M});var B=c([]);return l((function(){document.addEventListener("mouseup",A,!1),e.showPicker&&w()})),p((function(){document.removeEventListener("mouseup",A,!1),m&&(clearTimeout(m),m=null),g&&(clearTimeout(g),g=null)})),{valueList:o,colorItemSelected:function(t){return(e.addColor?s(o).length>0:s(o).length>1)&&s(d)===t},selectedColor:v,selectedIndex:d,isShowPicker:h,addColorItemShow:I,onPickerChange:function(t){var r=s(d),a=s(o).slice(),i=s(o).length;if(null!=r){r>=0?a[r]=t:(d.value=i,a.push(t));var c="";c=Array.isArray(e.value)||e.addColor?a:t,o.value=Array.isArray(c)?c:[c],n("update:value",c),n("change",c,t,r),e.addColor&&i>=e.max&&(I.value=!1,n("overflowMax"))}},colorPicker:k,onColorClick:C,pickerRef:b,onColorItemDragStart:function(e){e.dataTransfer.effectAllowed="move";var t=e.target;N=+t.dataset.index},onColorItemDragOver:function(e){},onColorItemDrop:function(e){var t=+e.target.dataset.index,r=_(s(o)),a=r[N];r.splice(N,1);var i=r.slice(0,t),c=r.splice(t),l=i.concat([a]).concat(c);n("update:value",l),n("change",l,l[N],N)},colorItemsRef:B,pickerStyle:x,values:a,teleportDisabled:P,toPopupContainer:F,formatValue:i,onFormatChange:function(e){i.value=e,n("formatChange",e)}}}});V(".color-picker[data-v-3c43ade8]{display:inline-block}.color-item[data-v-3c43ade8]{margin:5px}.add-color-item[data-v-3c43ade8]{display:inline-block;margin:5px}.picker[data-v-3c43ade8]{overflow:hidden}.v-enter-active[data-v-3c43ade8],.v-leave-active[data-v-3c43ade8]{opacity:1;transform:scaleY(1);transform-origin:center top;transition:opacity .2s ease-in-out,transform .2s ease-in-out}.v-enter-from[data-v-3c43ade8],.v-leave-to[data-v-3c43ade8]{opacity:0;transform:scaleY(0)}"),Re.render=function(e,t,i,c,l,u){var s=w("color-item"),f=w("add-color-item"),d=w("picker");return r(),n("div",{class:"color-picker",ref:"colorPicker",onDragstart:t[0]||(t[0]=a((function(){return e.onColorItemDragStart&&e.onColorItemDragStart.apply(e,arguments)}),["stop"])),onDragover:t[1]||(t[1]=a((function(){return e.onColorItemDragOver&&e.onColorItemDragOver.apply(e,arguments)}),["prevent","stop"])),onDrop:t[2]||(t[2]=a((function(){return e.onColorItemDrop&&e.onColorItemDrop.apply(e,arguments)}),["prevent","stop"])),onClick:t[3]||(t[3]=a((function(){return e.onColorClick&&e.onColorClick.apply(e,arguments)}),["stop"]))},[(r(!0),n(b,null,x(e.values,(function(t,n){return r(),C(s,{class:"color-item",key:n,ref_for:!0,ref:function(t){return e.colorItemsRef[n]=t},size:e.size,width:e.width,height:e.height,value:t,selected:e.colorItemSelected(n),"data-index":n,draggable:e.valueList.length>1,format:e.formatValue},null,8,["size","width","height","value","selected","data-index","draggable","format"])})),128)),e.addColor&&e.addColorItemShow?(r(),C(f,{key:0,class:"add-color-item",ref:"addColorItem",selected:e.colorItemSelected(-1),"data-index":-1},null,8,["selected"])):h("v-if",!0),(r(),C(A,{to:e.toPopupContainer,disabled:e.teleportDisabled},[m(g,null,{default:y((function(){return[e.isShowPicker?(r(),C(d,{key:0,class:"picker",style:o(e.pickerStyle),ref:"pickerRef",value:e.selectedColor,format:e.formatValue,"show-alpha":e.showAlpha,colors:e.colors,formatOptions:e.formatOptions,onChange:e.onPickerChange,onFormatChange:e.onFormatChange},null,8,["style","value","format","show-alpha","colors","formatOptions","onChange","onFormatChange"])):h("v-if",!0)]})),_:1})],8,["to","disabled"]))],544)},Re.__scopeId="data-v-3c43ade8",Re.__file="src/ColorPicker.vue";export{q as ALPHA_FORMAT_MAP,U as FORMAT_MAP,W as FORMAT_VALUE_MAP,Re as default};