niucloud-admin/niucloud/public/admin/assets/el-switch-3d36d31d.js
全栈小学生 0e47055ccb v1.0.0-beta.1
2023-04-15 17:12:49 +08:00

2 lines
22 KiB
JavaScript

import{w as he,v as je,d as fe,a as qe,t as Ge}from"./error-492b6a5b.js";import{E as Ce}from"./index-4862d1b3.js";import{a as Be,b as Ae,E as W,i as we,u as Ze}from"./index-868cd458.js";import{d as Je,E as Qe}from"./index-cf47f151.js";import{E as xe}from"./index-95693143.js";import{f as et,n as tt,l as at}from"./index-a3cf5375.js";import{i as Fe,b as ee,a as re}from"./index-f02197a7.js";import{u as X,_ as U,b as Le,g as nt,d as He,r as ie,h as Oe,c as De,w as We,a as ot}from"./plugin-vue_export-helper-edbdb6f8.js";import{d as H,s as $e,r as C,w as I,o as J,b as k,e as S,f as w,n as h,h as L,K as ne,c as N,j as z,X as _e,D as lt,a as st,F as rt,t as it,M as ct,A as j,E as ut,m as P,p as A,L as Me,u as l,q as F,C as V,v as Se,x as q,U as ce,T as Ee}from"./runtime-core.esm-bundler-7c3fd514.js";import{U as R,C as ae,I as ve}from"./event-9519ab40.js";import{u as dt}from"./focus-trap-bb1e8c7a.js";import{C as ht}from"./index-47617222.js";import{i as ft}from"./validator-62f68fe3.js";const ra=(t,a)=>{if(!Fe||!t||!a)return!1;const n=t.getBoundingClientRect();let e;return a instanceof Element?e=a.getBoundingClientRect():e={top:0,right:window.innerWidth,bottom:window.innerHeight,left:0},n.top<e.bottom&&n.bottom>e.top&&n.right>e.left&&n.left<e.right},Ne=t=>{let a=0,n=t;for(;n;)a+=n.offsetTop,n=n.offsetParent;return a},ia=(t,a)=>Math.abs(Ne(t)-Ne(a)),me=t=>{let a,n;return t.type==="touchend"?(n=t.changedTouches[0].clientY,a=t.changedTouches[0].clientX):t.type.startsWith("touch")?(n=t.touches[0].clientY,a=t.touches[0].clientX):(n=t.clientY,a=t.clientX),{clientX:a,clientY:n}};let ue=!1;function Z(t,a){if(!Fe)return;const n=function(o){var r;(r=a.drag)==null||r.call(a,o)},e=function(o){var r;document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",e),document.removeEventListener("touchmove",n),document.removeEventListener("touchend",e),document.onselectstart=null,document.ondragstart=null,ue=!1,(r=a.end)==null||r.call(a,o)},s=function(o){var r;ue||(o.preventDefault(),document.onselectstart=()=>!1,document.ondragstart=()=>!1,document.addEventListener("mousemove",n),document.addEventListener("mouseup",e),document.addEventListener("touchmove",n),document.addEventListener("touchend",e),ue=!0,(r=a.start)==null||r.call(a,o))};t.addEventListener("mousedown",s),t.addEventListener("touchstart",s)}const vt=H({name:"ElColorAlphaSlider",props:{color:{type:Object,required:!0},vertical:{type:Boolean,default:!1}},setup(t){const a=X("color-alpha-slider"),n=ne(),e=$e(),s=$e(),o=C(0),r=C(0),i=C();I(()=>t.color.get("alpha"),()=>{b()}),I(()=>t.color.value,()=>{b()});function p(){if(!e.value||t.vertical)return 0;const d=n.vnode.el,v=t.color.get("alpha");return d?Math.round(v*(d.offsetWidth-e.value.offsetWidth/2)/100):0}function f(){if(!e.value)return 0;const d=n.vnode.el;if(!t.vertical)return 0;const v=t.color.get("alpha");return d?Math.round(v*(d.offsetHeight-e.value.offsetHeight/2)/100):0}function $(){if(t.color&&t.color.value){const{r:d,g:v,b:u}=t.color.toRgb();return`linear-gradient(to right, rgba(${d}, ${v}, ${u}, 0) 0%, rgba(${d}, ${v}, ${u}, 1) 100%)`}return""}function y(d){d.target!==e.value&&M(d)}function M(d){if(!s.value||!e.value)return;const u=n.vnode.el.getBoundingClientRect(),{clientX:T,clientY:_}=me(d);if(t.vertical){let m=_-u.top;m=Math.max(e.value.offsetHeight/2,m),m=Math.min(m,u.height-e.value.offsetHeight/2),t.color.set("alpha",Math.round((m-e.value.offsetHeight/2)/(u.height-e.value.offsetHeight)*100))}else{let m=T-u.left;m=Math.max(e.value.offsetWidth/2,m),m=Math.min(m,u.width-e.value.offsetWidth/2),t.color.set("alpha",Math.round((m-e.value.offsetWidth/2)/(u.width-e.value.offsetWidth)*100))}}function b(){o.value=p(),r.value=f(),i.value=$()}return J(()=>{if(!s.value||!e.value)return;const d={drag:v=>{M(v)},end:v=>{M(v)}};Z(s.value,d),Z(e.value,d),b()}),{thumb:e,bar:s,thumbLeft:o,thumbTop:r,background:i,handleClick:y,update:b,ns:a}}});function pt(t,a,n,e,s,o){return k(),S("div",{class:h([t.ns.b(),t.ns.is("vertical",t.vertical)])},[w("div",{ref:"bar",class:h(t.ns.e("bar")),style:L({background:t.background}),onClick:a[0]||(a[0]=(...r)=>t.handleClick&&t.handleClick(...r))},null,6),w("div",{ref:"thumb",class:h(t.ns.e("thumb")),style:L({left:t.thumbLeft+"px",top:t.thumbTop+"px"})},null,6)],2)}var mt=U(vt,[["render",pt],["__file","/home/runner/work/element-plus/element-plus/packages/components/color-picker/src/components/alpha-slider.vue"]]);const gt=H({name:"ElColorHueSlider",props:{color:{type:Object,required:!0},vertical:Boolean},setup(t){const a=X("color-hue-slider"),n=ne(),e=C(),s=C(),o=C(0),r=C(0),i=N(()=>t.color.get("hue"));I(()=>i.value,()=>{M()});function p(b){b.target!==e.value&&f(b)}function f(b){if(!s.value||!e.value)return;const v=n.vnode.el.getBoundingClientRect(),{clientX:u,clientY:T}=me(b);let _;if(t.vertical){let m=T-v.top;m=Math.min(m,v.height-e.value.offsetHeight/2),m=Math.max(e.value.offsetHeight/2,m),_=Math.round((m-e.value.offsetHeight/2)/(v.height-e.value.offsetHeight)*360)}else{let m=u-v.left;m=Math.min(m,v.width-e.value.offsetWidth/2),m=Math.max(e.value.offsetWidth/2,m),_=Math.round((m-e.value.offsetWidth/2)/(v.width-e.value.offsetWidth)*360)}t.color.set("hue",_)}function $(){if(!e.value)return 0;const b=n.vnode.el;if(t.vertical)return 0;const d=t.color.get("hue");return b?Math.round(d*(b.offsetWidth-e.value.offsetWidth/2)/360):0}function y(){if(!e.value)return 0;const b=n.vnode.el;if(!t.vertical)return 0;const d=t.color.get("hue");return b?Math.round(d*(b.offsetHeight-e.value.offsetHeight/2)/360):0}function M(){o.value=$(),r.value=y()}return J(()=>{if(!s.value||!e.value)return;const b={drag:d=>{f(d)},end:d=>{f(d)}};Z(s.value,b),Z(e.value,b),M()}),{bar:s,thumb:e,thumbLeft:o,thumbTop:r,hueValue:i,handleClick:p,update:M,ns:a}}});function bt(t,a,n,e,s,o){return k(),S("div",{class:h([t.ns.b(),t.ns.is("vertical",t.vertical)])},[w("div",{ref:"bar",class:h(t.ns.e("bar")),onClick:a[0]||(a[0]=(...r)=>t.handleClick&&t.handleClick(...r))},null,2),w("div",{ref:"thumb",class:h(t.ns.e("thumb")),style:L({left:t.thumbLeft+"px",top:t.thumbTop+"px"})},null,6)],2)}var kt=U(gt,[["render",bt],["__file","/home/runner/work/element-plus/element-plus/packages/components/color-picker/src/components/hue-slider.vue"]]);const yt=Le({modelValue:String,id:String,showAlpha:Boolean,colorFormat:String,disabled:Boolean,size:nt,popperClass:{type:String,default:""},label:{type:String,default:void 0},tabindex:{type:[String,Number],default:0},predefine:{type:He(Array)},validateEvent:{type:Boolean,default:!0}}),Ct={[R]:t=>z(t)||ie(t),[ae]:t=>z(t)||ie(t),activeChange:t=>z(t)||ie(t)},ze=Symbol("colorPickerContextKey"),Te=function(t,a,n){return[t,a*n/((t=(2-a)*n)<1?t:2-t)||0,t/2]},wt=function(t){return typeof t=="string"&&t.includes(".")&&Number.parseFloat(t)===1},$t=function(t){return typeof t=="string"&&t.includes("%")},K=function(t,a){wt(t)&&(t="100%");const n=$t(t);return t=Math.min(a,Math.max(0,Number.parseFloat(`${t}`))),n&&(t=Number.parseInt(`${t*a}`,10)/100),Math.abs(t-a)<1e-6?1:t%a/Number.parseFloat(a)},Ve={10:"A",11:"B",12:"C",13:"D",14:"E",15:"F"},te=t=>{t=Math.min(Math.round(t),255);const a=Math.floor(t/16),n=t%16;return`${Ve[a]||a}${Ve[n]||n}`},Ie=function({r:t,g:a,b:n}){return Number.isNaN(+t)||Number.isNaN(+a)||Number.isNaN(+n)?"":`#${te(t)}${te(a)}${te(n)}`},de={A:10,B:11,C:12,D:13,E:14,F:15},D=function(t){return t.length===2?(de[t[0].toUpperCase()]||+t[0])*16+(de[t[1].toUpperCase()]||+t[1]):de[t[1].toUpperCase()]||+t[1]},_t=function(t,a,n){a=a/100,n=n/100;let e=a;const s=Math.max(n,.01);n*=2,a*=n<=1?n:2-n,e*=s<=1?s:2-s;const o=(n+a)/2,r=n===0?2*e/(s+e):2*a/(n+a);return{h:t,s:r*100,v:o*100}},Pe=(t,a,n)=>{t=K(t,255),a=K(a,255),n=K(n,255);const e=Math.max(t,a,n),s=Math.min(t,a,n);let o;const r=e,i=e-s,p=e===0?0:i/e;if(e===s)o=0;else{switch(e){case t:{o=(a-n)/i+(a<n?6:0);break}case a:{o=(n-t)/i+2;break}case n:{o=(t-a)/i+4;break}}o/=6}return{h:o*360,s:p*100,v:r*100}},Y=function(t,a,n){t=K(t,360)*6,a=K(a,100),n=K(n,100);const e=Math.floor(t),s=t-e,o=n*(1-a),r=n*(1-s*a),i=n*(1-(1-s)*a),p=e%6,f=[n,r,o,o,i,n][p],$=[i,n,n,r,o,o][p],y=[o,o,i,n,n,r][p];return{r:Math.round(f*255),g:Math.round($*255),b:Math.round(y*255)}};class G{constructor(a={}){this._hue=0,this._saturation=100,this._value=100,this._alpha=100,this.enableAlpha=!1,this.format="hex",this.value="";for(const n in a)_e(a,n)&&(this[n]=a[n]);a.value?this.fromString(a.value):this.doOnChange()}set(a,n){if(arguments.length===1&&typeof a=="object"){for(const e in a)_e(a,e)&&this.set(e,a[e]);return}this[`_${a}`]=n,this.doOnChange()}get(a){return a==="alpha"?Math.floor(this[`_${a}`]):this[`_${a}`]}toRgb(){return Y(this._hue,this._saturation,this._value)}fromString(a){if(!a){this._hue=0,this._saturation=100,this._value=100,this.doOnChange();return}const n=(e,s,o)=>{this._hue=Math.max(0,Math.min(360,e)),this._saturation=Math.max(0,Math.min(100,s)),this._value=Math.max(0,Math.min(100,o)),this.doOnChange()};if(a.includes("hsl")){const e=a.replace(/hsla|hsl|\(|\)/gm,"").split(/\s|,/g).filter(s=>s!=="").map((s,o)=>o>2?Number.parseFloat(s):Number.parseInt(s,10));if(e.length===4?this._alpha=Number.parseFloat(e[3])*100:e.length===3&&(this._alpha=100),e.length>=3){const{h:s,s:o,v:r}=_t(e[0],e[1],e[2]);n(s,o,r)}}else if(a.includes("hsv")){const e=a.replace(/hsva|hsv|\(|\)/gm,"").split(/\s|,/g).filter(s=>s!=="").map((s,o)=>o>2?Number.parseFloat(s):Number.parseInt(s,10));e.length===4?this._alpha=Number.parseFloat(e[3])*100:e.length===3&&(this._alpha=100),e.length>=3&&n(e[0],e[1],e[2])}else if(a.includes("rgb")){const e=a.replace(/rgba|rgb|\(|\)/gm,"").split(/\s|,/g).filter(s=>s!=="").map((s,o)=>o>2?Number.parseFloat(s):Number.parseInt(s,10));if(e.length===4?this._alpha=Number.parseFloat(e[3])*100:e.length===3&&(this._alpha=100),e.length>=3){const{h:s,s:o,v:r}=Pe(e[0],e[1],e[2]);n(s,o,r)}}else if(a.includes("#")){const e=a.replace("#","").trim();if(!/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$|^[0-9a-fA-F]{8}$/.test(e))return;let s,o,r;e.length===3?(s=D(e[0]+e[0]),o=D(e[1]+e[1]),r=D(e[2]+e[2])):(e.length===6||e.length===8)&&(s=D(e.slice(0,2)),o=D(e.slice(2,4)),r=D(e.slice(4,6))),e.length===8?this._alpha=D(e.slice(6))/255*100:(e.length===3||e.length===6)&&(this._alpha=100);const{h:i,s:p,v:f}=Pe(s,o,r);n(i,p,f)}}compare(a){return Math.abs(a._hue-this._hue)<2&&Math.abs(a._saturation-this._saturation)<1&&Math.abs(a._value-this._value)<1&&Math.abs(a._alpha-this._alpha)<1}doOnChange(){const{_hue:a,_saturation:n,_value:e,_alpha:s,format:o}=this;if(this.enableAlpha)switch(o){case"hsl":{const r=Te(a,n/100,e/100);this.value=`hsla(${a}, ${Math.round(r[1]*100)}%, ${Math.round(r[2]*100)}%, ${this.get("alpha")/100})`;break}case"hsv":{this.value=`hsva(${a}, ${Math.round(n)}%, ${Math.round(e)}%, ${this.get("alpha")/100})`;break}case"hex":{this.value=`${Ie(Y(a,n,e))}${te(s*255/100)}`;break}default:{const{r,g:i,b:p}=Y(a,n,e);this.value=`rgba(${r}, ${i}, ${p}, ${this.get("alpha")/100})`}}else switch(o){case"hsl":{const r=Te(a,n/100,e/100);this.value=`hsl(${a}, ${Math.round(r[1]*100)}%, ${Math.round(r[2]*100)}%)`;break}case"hsv":{this.value=`hsv(${a}, ${Math.round(n)}%, ${Math.round(e)}%)`;break}case"rgb":{const{r,g:i,b:p}=Y(a,n,e);this.value=`rgb(${r}, ${i}, ${p})`;break}default:this.value=Ie(Y(a,n,e))}}}const Mt=H({props:{colors:{type:Array,required:!0},color:{type:Object,required:!0}},setup(t){const a=X("color-predefine"),{currentColor:n}=lt(ze),e=C(o(t.colors,t.color));I(()=>n.value,r=>{const i=new G;i.fromString(r),e.value.forEach(p=>{p.selected=i.compare(p)})}),st(()=>{e.value=o(t.colors,t.color)});function s(r){t.color.fromString(t.colors[r])}function o(r,i){return r.map(p=>{const f=new G;return f.enableAlpha=!0,f.format="rgba",f.fromString(p),f.selected=f.value===i.value,f})}return{rgbaColors:e,handleSelect:s,ns:a}}}),St=["onClick"];function Et(t,a,n,e,s,o){return k(),S("div",{class:h(t.ns.b())},[w("div",{class:h(t.ns.e("colors"))},[(k(!0),S(rt,null,it(t.rgbaColors,(r,i)=>(k(),S("div",{key:t.colors[i],class:h([t.ns.e("color-selector"),t.ns.is("alpha",r._alpha<100),{selected:r.selected}]),onClick:p=>t.handleSelect(i)},[w("div",{style:L({backgroundColor:r.value})},null,4)],10,St))),128))],2)],2)}var Nt=U(Mt,[["render",Et],["__file","/home/runner/work/element-plus/element-plus/packages/components/color-picker/src/components/predefine.vue"]]);const Tt=H({name:"ElSlPanel",props:{color:{type:Object,required:!0}},setup(t){const a=X("color-svpanel"),n=ne(),e=C(0),s=C(0),o=C("hsl(0, 100%, 50%)"),r=N(()=>{const f=t.color.get("hue"),$=t.color.get("value");return{hue:f,value:$}});function i(){const f=t.color.get("saturation"),$=t.color.get("value"),y=n.vnode.el,{clientWidth:M,clientHeight:b}=y;s.value=f*M/100,e.value=(100-$)*b/100,o.value=`hsl(${t.color.get("hue")}, 100%, 50%)`}function p(f){const y=n.vnode.el.getBoundingClientRect(),{clientX:M,clientY:b}=me(f);let d=M-y.left,v=b-y.top;d=Math.max(0,d),d=Math.min(d,y.width),v=Math.max(0,v),v=Math.min(v,y.height),s.value=d,e.value=v,t.color.set({saturation:d/y.width*100,value:100-v/y.height*100})}return I(()=>r.value,()=>{i()}),J(()=>{Z(n.vnode.el,{drag:f=>{p(f)},end:f=>{p(f)}}),i()}),{cursorTop:e,cursorLeft:s,background:o,colorValue:r,handleDrag:p,update:i,ns:a}}}),Vt=w("div",null,null,-1),It=[Vt];function Pt(t,a,n,e,s,o){return k(),S("div",{class:h(t.ns.b()),style:L({backgroundColor:t.background})},[w("div",{class:h(t.ns.e("white"))},null,2),w("div",{class:h(t.ns.e("black"))},null,2),w("div",{class:h(t.ns.e("cursor")),style:L({top:t.cursorTop+"px",left:t.cursorLeft+"px"})},It,6)],6)}var Bt=U(Tt,[["render",Pt],["__file","/home/runner/work/element-plus/element-plus/packages/components/color-picker/src/components/sv-panel.vue"]]);const At=["id","aria-label","aria-labelledby","aria-description","tabindex","onKeydown"],Ft=H({name:"ElColorPicker"}),Lt=H({...Ft,props:yt,emits:Ct,setup(t,{expose:a,emit:n}){const e=t,{t:s}=dt(),o=X("color"),{formItem:r}=Be(),i=Oe(),p=De(),{inputId:f,isLabeledByFormItem:$}=Ae(e,{formItemContext:r}),y=C(),M=C(),b=C(),d=C();let v=!0;const u=ct(new G({enableAlpha:e.showAlpha,format:e.colorFormat||"",value:e.modelValue})),T=C(!1),_=C(!1),m=C(""),oe=N(()=>!e.modelValue&&!_.value?"transparent":Ke(u,e.showAlpha)),c=N(()=>!e.modelValue&&!_.value?"":u.value),E=N(()=>$.value?void 0:e.label||s("el.colorpicker.defaultLabel")),le=N(()=>$.value?r==null?void 0:r.labelId:void 0),Q=N(()=>[o.b("picker"),o.is("disabled",p.value),o.bm("picker",i.value)]);function Ke(g,B){if(!(g instanceof G))throw new TypeError("color should be instance of _color Class");const{r:O,g:ke,b:ye}=g.toRgb();return B?`rgba(${O}, ${ke}, ${ye}, ${g.get("alpha")/100})`:`rgb(${O}, ${ke}, ${ye})`}function Re(g){T.value=g}const x=Je(Re,100);function Xe(){x(!1),se()}function se(){j(()=>{e.modelValue?u.fromString(e.modelValue):(u.value="",j(()=>{_.value=!1}))})}function ge(){p.value||x(!T.value)}function be(){u.fromString(m.value)}function Ue(){const g=u.value;n(R,g),n("change",g),e.validateEvent&&(r==null||r.validate("change").catch(B=>fe())),x(!1),j(()=>{const B=new G({enableAlpha:e.showAlpha,format:e.colorFormat||"",value:e.modelValue});u.compare(B)||se()})}function Ye(){x(!1),n(R,null),n("change",null),e.modelValue!==null&&e.validateEvent&&(r==null||r.validate("change").catch(g=>fe())),se()}return J(()=>{e.modelValue&&(m.value=c.value)}),I(()=>e.modelValue,g=>{g?g&&g!==u.value&&(v=!1,u.fromString(g)):_.value=!1}),I(()=>c.value,g=>{m.value=g,v&&n("activeChange",g),v=!0}),I(()=>u.value,()=>{!e.modelValue&&!_.value&&(_.value=!0)}),I(()=>T.value,()=>{j(()=>{var g,B,O;(g=y.value)==null||g.update(),(B=M.value)==null||B.update(),(O=b.value)==null||O.update()})}),ut(ze,{currentColor:c}),a({color:u}),(g,B)=>(k(),P(l(Qe),{ref_key:"popper",ref:d,visible:T.value,"show-arrow":!1,"fallback-placements":["bottom","top","right","left"],offset:0,"gpu-acceleration":!1,"popper-class":[l(o).be("picker","panel"),l(o).b("dropdown"),g.popperClass],"stop-popper-mouse-event":!1,effect:"light",trigger:"click",transition:`${l(o).namespace.value}-zoom-in-top`,persistent:""},{content:A(()=>[Me((k(),S("div",null,[w("div",{class:h(l(o).be("dropdown","main-wrapper"))},[F(kt,{ref_key:"hue",ref:y,class:"hue-slider",color:l(u),vertical:""},null,8,["color"]),F(Bt,{ref:"svPanel",color:l(u)},null,8,["color"])],2),g.showAlpha?(k(),P(mt,{key:0,ref_key:"alpha",ref:b,color:l(u)},null,8,["color"])):V("v-if",!0),g.predefine?(k(),P(Nt,{key:1,ref:"predefine",color:l(u),colors:g.predefine},null,8,["color","colors"])):V("v-if",!0),w("div",{class:h(l(o).be("dropdown","btns"))},[w("span",{class:h(l(o).be("dropdown","value"))},[F(l(xe),{modelValue:m.value,"onUpdate:modelValue":B[0]||(B[0]=O=>m.value=O),"validate-event":!1,size:"small",onKeyup:he(be,["enter"]),onBlur:be},null,8,["modelValue","onKeyup"])],2),F(l(Ce),{class:h(l(o).be("dropdown","link-btn")),text:"",size:"small",onClick:Ye},{default:A(()=>[Se(q(l(s)("el.colorpicker.clear")),1)]),_:1},8,["class"]),F(l(Ce),{plain:"",size:"small",class:h(l(o).be("dropdown","btn")),onClick:Ue},{default:A(()=>[Se(q(l(s)("el.colorpicker.confirm")),1)]),_:1},8,["class"])],2)])),[[l(ht),Xe]])]),default:A(()=>[w("div",{id:l(f),class:h(l(Q)),role:"button","aria-label":l(E),"aria-labelledby":l(le),"aria-description":l(s)("el.colorpicker.description",{color:g.modelValue||""}),tabindex:g.tabindex,onKeydown:he(ge,["enter"])},[l(p)?(k(),S("div",{key:0,class:h(l(o).be("picker","mask"))},null,2)):V("v-if",!0),w("div",{class:h(l(o).be("picker","trigger")),onClick:ge},[w("span",{class:h([l(o).be("picker","color"),l(o).is("alpha",g.showAlpha)])},[w("span",{class:h(l(o).be("picker","color-inner")),style:L({backgroundColor:l(oe)})},[Me(F(l(W),{class:h([l(o).be("picker","icon"),l(o).is("icon-arrow-down")])},{default:A(()=>[F(l(et))]),_:1},8,["class"]),[[je,g.modelValue||_.value]]),!g.modelValue&&!_.value?(k(),P(l(W),{key:0,class:h([l(o).be("picker","empty"),l(o).is("icon-close")])},{default:A(()=>[F(l(tt))]),_:1},8,["class"])):V("v-if",!0)],6)],2)],2)],42,At)]),_:1},8,["visible","popper-class","transition"]))}});var Ht=U(Lt,[["__file","/home/runner/work/element-plus/element-plus/packages/components/color-picker/src/color-picker.vue"]]);const ca=We(Ht),Ot=Le({modelValue:{type:[Boolean,String,Number],default:!1},value:{type:[Boolean,String,Number],default:!1},disabled:{type:Boolean,default:!1},width:{type:[String,Number],default:""},inlinePrompt:{type:Boolean,default:!1},activeIcon:{type:we},inactiveIcon:{type:we},activeText:{type:String,default:""},inactiveText:{type:String,default:""},activeColor:{type:String,default:""},inactiveColor:{type:String,default:""},borderColor:{type:String,default:""},activeValue:{type:[Boolean,String,Number],default:!0},inactiveValue:{type:[Boolean,String,Number],default:!1},name:{type:String,default:""},validateEvent:{type:Boolean,default:!0},id:String,loading:{type:Boolean,default:!1},beforeChange:{type:He(Function)},size:{type:String,validator:ft},tabindex:{type:[String,Number]}}),Dt={[R]:t=>ee(t)||z(t)||re(t),[ae]:t=>ee(t)||z(t)||re(t),[ve]:t=>ee(t)||z(t)||re(t)},Wt=["onClick"],zt=["id","aria-checked","aria-disabled","name","true-value","false-value","disabled","tabindex","onKeydown"],Kt=["aria-hidden"],Rt=["aria-hidden"],Xt=["aria-hidden"],pe="ElSwitch",Ut=H({name:pe}),Yt=H({...Ut,props:Ot,emits:Dt,setup(t,{expose:a,emit:n}){const e=t,s=ne(),{formItem:o}=Be(),r=Oe(),i=X("switch");Ze({from:'"value"',replacement:'"model-value" or "v-model"',scope:pe,version:"2.3.0",ref:"https://element-plus.org/en-US/component/switch.html#attributes",type:"Attribute"},N(()=>{var c;return!!((c=s.vnode.props)!=null&&c.value)}));const{inputId:p}=Ae(e,{formItemContext:o}),f=De(N(()=>e.loading)),$=C(e.modelValue!==!1),y=C(),M=C(),b=N(()=>[i.b(),i.m(r.value),i.is("disabled",f.value),i.is("checked",u.value)]),d=N(()=>({width:ot(e.width)}));I(()=>e.modelValue,()=>{$.value=!0}),I(()=>e.value,()=>{$.value=!1});const v=N(()=>$.value?e.modelValue:e.value),u=N(()=>v.value===e.activeValue);[e.activeValue,e.inactiveValue].includes(v.value)||(n(R,e.inactiveValue),n(ae,e.inactiveValue),n(ve,e.inactiveValue)),I(u,c=>{var E;y.value.checked=c,e.validateEvent&&((E=o==null?void 0:o.validate)==null||E.call(o,"change").catch(le=>fe()))});const T=()=>{const c=u.value?e.inactiveValue:e.activeValue;n(R,c),n(ae,c),n(ve,c),j(()=>{y.value.checked=u.value})},_=()=>{if(f.value)return;const{beforeChange:c}=e;if(!c){T();return}const E=c();[Ee(E),ee(E)].includes(!0)||Ge(pe,"beforeChange must return type `Promise<boolean>` or `boolean`"),Ee(E)?E.then(Q=>{Q&&T()}).catch(Q=>{}):E&&T()},m=N(()=>i.cssVarBlock({...e.activeColor?{"on-color":e.activeColor}:null,...e.inactiveColor?{"off-color":e.inactiveColor}:null,...e.borderColor?{"border-color":e.borderColor}:null})),oe=()=>{var c,E;(E=(c=y.value)==null?void 0:c.focus)==null||E.call(c)};return J(()=>{y.value.checked=u.value}),a({focus:oe,checked:u}),(c,E)=>(k(),S("div",{class:h(l(b)),style:L(l(m)),onClick:qe(_,["prevent"])},[w("input",{id:l(p),ref_key:"input",ref:y,class:h(l(i).e("input")),type:"checkbox",role:"switch","aria-checked":l(u),"aria-disabled":l(f),name:c.name,"true-value":c.activeValue,"false-value":c.inactiveValue,disabled:l(f),tabindex:c.tabindex,onChange:T,onKeydown:he(_,["enter"])},null,42,zt),!c.inlinePrompt&&(c.inactiveIcon||c.inactiveText)?(k(),S("span",{key:0,class:h([l(i).e("label"),l(i).em("label","left"),l(i).is("active",!l(u))])},[c.inactiveIcon?(k(),P(l(W),{key:0},{default:A(()=>[(k(),P(ce(c.inactiveIcon)))]),_:1})):V("v-if",!0),!c.inactiveIcon&&c.inactiveText?(k(),S("span",{key:1,"aria-hidden":l(u)},q(c.inactiveText),9,Kt)):V("v-if",!0)],2)):V("v-if",!0),w("span",{ref_key:"core",ref:M,class:h(l(i).e("core")),style:L(l(d))},[c.inlinePrompt?(k(),S("div",{key:0,class:h(l(i).e("inner"))},[c.activeIcon||c.inactiveIcon?(k(),P(l(W),{key:0,class:h(l(i).is("icon"))},{default:A(()=>[(k(),P(ce(l(u)?c.activeIcon:c.inactiveIcon)))]),_:1},8,["class"])):c.activeText||c.inactiveText?(k(),S("span",{key:1,class:h(l(i).is("text")),"aria-hidden":!l(u)},q(l(u)?c.activeText:c.inactiveText),11,Rt)):V("v-if",!0)],2)):V("v-if",!0),w("div",{class:h(l(i).e("action"))},[c.loading?(k(),P(l(W),{key:0,class:h(l(i).is("loading"))},{default:A(()=>[F(l(at))]),_:1},8,["class"])):V("v-if",!0)],2)],6),!c.inlinePrompt&&(c.activeIcon||c.activeText)?(k(),S("span",{key:1,class:h([l(i).e("label"),l(i).em("label","right"),l(i).is("active",l(u))])},[c.activeIcon?(k(),P(l(W),{key:0},{default:A(()=>[(k(),P(ce(c.activeIcon)))]),_:1})):V("v-if",!0),!c.activeIcon&&c.activeText?(k(),S("span",{key:1,"aria-hidden":!l(u)},q(c.activeText),9,Xt)):V("v-if",!0)],2)):V("v-if",!0)],14,Wt))}});var jt=U(Yt,[["__file","/home/runner/work/element-plus/element-plus/packages/components/switch/src/switch.vue"]]);const ua=We(jt);export{ca as E,ua as a,ia as g,ra as i};