import{r as e,b as n,x as t,y as o,z as l,k as s,w as i,f as a,A as r,T as u,B as d,C as c,D as v,G as m,H as b,I as g,J as f,K as p,L as x,i as y,M as C}from"./index.286e9b79.js";function k(m){let b;const g=e(!1),f=n({...m,originalPosition:"",originalOverflow:"",visible:!1});function p(){var e,n;null==(n=null==(e=k.$el)?void 0:e.parentNode)||n.removeChild(k.$el)}function x(){if(!g.value)return;const e=f.parent;g.value=!1,e.vLoadingAddClassList=void 0,function(){const e=f.parent,n=k.ns;if(!e.vLoadingAddClassList){let t=e.getAttribute("loading-number");t=Number.parseInt(t)-1,t?e.setAttribute("loading-number",t.toString()):(v(e,n.bm("parent","relative")),e.removeAttribute("loading-number")),v(e,n.bm("parent","hidden"))}p(),C.unmount()}()}const y=t({name:"ElLoading",setup(e,{expose:n}){const{ns:t,zIndex:d}=o("loading");return n({ns:t,zIndex:d}),()=>{const e=f.spinner||f.svg,n=l("svg",{class:"circular",viewBox:f.svgViewBox?f.svgViewBox:"0 0 50 50",...e?{innerHTML:e}:{}},[l("circle",{class:"path",cx:"25",cy:"25",r:"20",fill:"none"})]),o=f.text?l("p",{class:t.b("text")},[f.text]):void 0;return l(u,{name:t.b("fade"),onAfterLeave:x},{default:s((()=>[i(a("div",{style:{backgroundColor:f.background||""},class:[t.b("mask"),f.customClass,f.fullscreen?"is-fullscreen":""]},[l("div",{class:t.b("spinner")},[n,o])]),[[r,f.visible]])]))})}}}),C=d(y),k=C.mount(document.createElement("div"));return{...c(f),setText:function(e){f.text=e},removeElLoadingChild:p,close:function(){var e;m.beforeClose&&!m.beforeClose()||(g.value=!0,clearTimeout(b),b=window.setTimeout(x,400),f.visible=!1,null==(e=m.closed)||e.call(m))},handleAfterLeave:x,vm:k,get $el(){return k.$el}}}let w;const L=function(e={}){if(!m)return;const n=A(e);if(n.fullscreen&&w)return w;const t=k({...n,closed:()=>{var e;null==(e=n.closed)||e.call(n),n.fullscreen&&(w=void 0)}});h(n,n.parent,t),B(n,n.parent,t),n.parent.vLoadingAddClassList=()=>B(n,n.parent,t);let o=n.parent.getAttribute("loading-number");return o=o?`${Number.parseInt(o)+1}`:"1",n.parent.setAttribute("loading-number",o),n.parent.appendChild(t.$el),b((()=>t.visible.value=n.visible)),n.fullscreen&&(w=t),t},A=e=>{var n,t,o,l;let s;return s=g(e.target)?null!=(n=document.querySelector(e.target))?n:document.body:e.target||document.body,{parent:s===document.body||e.body?document.body:s,background:e.background||"",svg:e.svg||"",svgViewBox:e.svgViewBox||"",spinner:e.spinner||!1,text:e.text||"",fullscreen:s===document.body&&(null==(t=e.fullscreen)||t),lock:null!=(o=e.lock)&&o,customClass:e.customClass||"",visible:null==(l=e.visible)||l,target:s}},h=async(e,n,t)=>{const{nextZIndex:o}=t.vm.zIndex||t.vm._.exposed.zIndex,l={};if(e.fullscreen)t.originalPosition.value=f(document.body,"position"),t.originalOverflow.value=f(document.body,"overflow"),l.zIndex=o();else if(e.parent===document.body){t.originalPosition.value=f(document.body,"position"),await b();for(const n of["top","left"]){const t="top"===n?"scrollTop":"scrollLeft";l[n]=e.target.getBoundingClientRect()[n]+document.body[t]+document.documentElement[t]-Number.parseInt(f(document.body,`margin-${n}`),10)+"px"}for(const n of["height","width"])l[n]=`${e.target.getBoundingClientRect()[n]}px`}else t.originalPosition.value=f(n,"position");for(const[s,i]of Object.entries(l))t.$el.style[s]=i},B=(e,n,t)=>{const o=t.vm.ns||t.vm._.exposed.ns;["absolute","fixed","sticky"].includes(t.originalPosition.value)?v(n,o.bm("parent","relative")):p(n,o.bm("parent","relative")),e.fullscreen&&e.lock?p(n,o.bm("parent","hidden")):v(n,o.bm("parent","hidden"))},I=Symbol("ElLoading"),$=(n,t)=>{var o,l,s,i;const a=t.instance,r=e=>x(t.value)?t.value[e]:void 0,u=t=>(n=>{const t=g(n)&&(null==a?void 0:a[n])||n;return t?e(t):t})(r(t)||n.getAttribute(`element-loading-${C(t)}`)),d=null!=(o=r("fullscreen"))?o:t.modifiers.fullscreen,c={text:u("text"),svg:u("svg"),svgViewBox:u("svgViewBox"),spinner:u("spinner"),background:u("background"),customClass:u("customClass"),fullscreen:d,target:null!=(l=r("target"))?l:d?void 0:n,body:null!=(s=r("body"))?s:t.modifiers.body,lock:null!=(i=r("lock"))?i:t.modifiers.lock};n[I]={options:c,instance:L(c)}},V={mounted(e,n){n.value&&$(e,n)},updated(e,n){const t=e[I];n.oldValue!==n.value&&(n.value&&!n.oldValue?$(e,n):n.value&&n.oldValue?x(n.value)&&((e,n)=>{for(const t of Object.keys(n))y(n[t])&&(n[t].value=e[t])})(n.value,t.options):null==t||t.instance.close())},unmounted(e){var n;null==(n=e[I])||n.instance.close(),e[I]=null}};export{L,V as v};
