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