import{au as K,g as q,a7 as U,S as z,u as Q,av as k,Y as w,C as u,v as p,a8 as y,aw as H,q as X,y as Z,H as ee,ax as Y,K as c,o as V,W as F,I as B,a0 as te,ay as se,an as M,am as $,az as L,aA as re,aB as ie,ao as ne,ap as j,G as ae,a1 as S,w as R,n as he,A as fe,aC as b,at as oe,aD as de,aE as _e,aF as le,aG as x,x as ce,D as G,aH as ue,a2 as pe,ac as O,B as E,aI as ge,$ as ve,aJ as ye,P as me,b as be,a9 as Ee,F as Te,ab as we,p as Re}from"./template.CyUWgh-J.js";import{b as Ae,r as P,h as W,i as De}from"./utils.DonxBMOE.js";function Ne(i){let e=0,t=z(0),r;return()=>{K()&&(q(t),U(()=>(e===0&&(r=Q(()=>i(()=>k(t)))),e+=1,()=>{w(()=>{e-=1,e===0&&(r?.(),r=void 0,k(t))})})))}}var Fe=oe|de;function Se(i,e,t,r){new xe(i,e,t,r)}class xe{parent;is_pending=!1;transform_error;#t;#u=p?u:null;#i;#o;#e;#n=null;#s=null;#r=null;#a=null;#d=0;#f=0;#_=!1;#p=new Set;#g=new Set;#h=null;#m=Ne(()=>(this.#h=z(this.#d),()=>{this.#h=null}));constructor(e,t,r,f){this.#t=e,this.#i=t,this.#o=s=>{var n=y;n.b=this,n.f|=H,r(s)},this.parent=y.b,this.transform_error=f??this.parent?.transform_error??(s=>s),this.#e=X(()=>{if(p){const s=this.#u;Z();const n=s.data===ee;if(s.data.startsWith(Y)){const a=JSON.parse(s.data.slice(Y.length));this.#E(a)}else n?this.#T():this.#b()}else this.#v()},Fe),p&&(this.#t=u)}#b(){try{this.#n=c(()=>this.#o(this.#t))}catch(e){this.error(e)}}#E(e){const t=this.#i.failed;t&&(this.#r=c(()=>{t(this.#t,()=>e,()=>()=>{})}))}#T(){const e=this.#i.pending;e&&(this.is_pending=!0,this.#s=c(()=>e(this.#t)),w(()=>{var t=this.#a=document.createDocumentFragment(),r=V();t.append(r),this.#n=this.#c(()=>c(()=>this.#o(r))),this.#f===0&&(this.#t.before(t),this.#a=null,F(this.#s,()=>{this.#s=null}),this.#l(B))}))}#v(){try{if(this.is_pending=this.has_pending_snippet(),this.#f=0,this.#d=0,this.#n=c(()=>{this.#o(this.#t)}),this.#f>0){var e=this.#a=document.createDocumentFragment();te(this.#n,e);const t=this.#i.pending;this.#s=c(()=>t(this.#t))}else this.#l(B)}catch(t){this.error(t)}}#l(e){this.is_pending=!1,e.transfer_effects(this.#p,this.#g)}defer_effect(e){se(e,this.#p,this.#g)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#i.pending}#c(e){var t=y,r=ne,f=j;M(this.#e),$(this.#e),L(this.#e.ctx);try{return re.ensure(),e()}catch(s){return ie(s),null}finally{M(t),$(r),L(f)}}#y(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#y(e,t);return}this.#f+=e,this.#f===0&&(this.#l(t),this.#s&&F(this.#s,()=>{this.#s=null}),this.#a&&(this.#t.before(this.#a),this.#a=null))}update_pending_count(e,t){this.#y(e,t),this.#d+=e,!(!this.#h||this.#_)&&(this.#_=!0,w(()=>{this.#_=!1,this.#h&&ae(this.#h,this.#d)}))}get_effect_pending(){return this.#m(),q(this.#h)}error(e){var t=this.#i.onerror;let r=this.#i.failed;if(!t&&!r)throw e;this.#n&&(S(this.#n),this.#n=null),this.#s&&(S(this.#s),this.#s=null),this.#r&&(S(this.#r),this.#r=null),p&&(R(this.#u),he(),R(fe()));var f=!1,s=!1;const n=()=>{if(f){le();return}f=!0,s&&_e(),this.#r!==null&&F(this.#r,()=>{this.#r=null}),this.#c(()=>{this.#v()})},l=a=>{try{s=!0,t?.(a,n),s=!1}catch(h){b(h,this.#e&&this.#e.parent)}r&&(this.#r=this.#c(()=>{try{return c(()=>{var h=y;h.b=this,h.f|=H,r(this.#t,()=>a,()=>n)})}catch(h){return b(h,this.#e.parent),null}}))};w(()=>{var a;try{a=this.transform_error(e)}catch(h){b(h,this.#e&&this.#e.parent);return}a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(l,h=>b(h,this.#e&&this.#e.parent)):l(a)})}}function ke(i,e){var t=e==null?"":typeof e=="object"?`${e}`:e;t!==(i.__t??=i.nodeValue)&&(i.__t=t,i.nodeValue=`${t}`)}function Oe(i,e){return J(i,e)}function He(i,e){x(),e.intro=e.intro??!1;const t=e.target,r=p,f=u;try{for(var s=ce(t);s&&(s.nodeType!==G||s.data!==ue);)s=pe(s);if(!s)throw O;E(!0),R(s);const n=J(i,{...e,anchor:s});return E(!1),n}catch(n){if(n instanceof Error&&n.message.split(` `).some(l=>l.startsWith("https://svelte.dev/e/")))throw n;return n!==O&&console.warn("Failed to hydrate: ",n),e.recover===!1&&ge(),x(),ve(t),E(!1),Oe(i,e)}finally{E(r),R(f)}}const T=new Map;function J(i,{target:e,anchor:t,props:r={},events:f,context:s,intro:n=!0,transformError:l}){x();var a=void 0,h=ye(()=>{var m=t??e.appendChild(V());Se(m,{pending:()=>{}},o=>{be({});var d=j;if(s&&(d.c=s),f&&(r.$$events=f),p&&Ee(o,null),a=i(o,r)||{},p&&(y.nodes.end=u,u===null||u.nodeType!==G||u.data!==Te))throw we(),O;Re()},l);var A=new Set,D=o=>{for(var d=0;d{for(var o of A)for(const v of[e,document]){var d=T.get(v),_=d.get(o);--_==0?(v.removeEventListener(o,W),d.delete(o),d.size===0&&T.delete(v)):d.set(o,_)}P.delete(D),m!==t&&m.parentNode?.removeChild(m)}});return C.set(a,h),a}let C=new WeakMap;function Ye(i,e){const t=C.get(i);return t?(C.delete(i),t(e)):Promise.resolve()}export{He as h,Oe as m,ke as s,Ye as u};