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