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