var D=Object.defineProperty;var g=i=>{throw TypeError(i)};var F=(i,e,s)=>e in i?D(i,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[e]=s;var w=(i,e,s)=>F(i,typeof e!="symbol"?e+"":e,s),y=(i,e,s)=>e.has(i)||g("Cannot "+s);var t=(i,e,s)=>(y(i,e,"read from private field"),s?s.call(i):e.get(i)),l=(i,e,s)=>e.has(i)?g("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,s),M=(i,e,s,a)=>(y(i,e,"write to private field"),a?a.call(i,s):e.set(i,s),s);import{a$ as x,aa as k,aQ as C,a3 as A,Y as B,a4 as L,at as Q,as as S,aL as Y,bc as $}from"./DLYq8eCY.js";var c,n,r,u,p,_,v;class z{constructor(e,s=!0){w(this,"anchor");l(this,c,new Map);l(this,n,new Map);l(this,r,new Map);l(this,u,new Set);l(this,p,!0);l(this,_,e=>{if(t(this,c).has(e)){var s=t(this,c).get(e),a=t(this,n).get(s);if(a)x(a),t(this,u).delete(s);else{var h=t(this,r).get(s);h&&(x(h.effect),t(this,n).set(s,h.effect),t(this,r).delete(s),h.fragment.lastChild.remove(),this.anchor.before(h.fragment),a=h.effect)}for(const[f,o]of t(this,c)){if(t(this,c).delete(f),f===e)break;const d=t(this,r).get(o);d&&(k(d.effect),t(this,r).delete(o))}for(const[f,o]of t(this,n)){if(f===s||t(this,u).has(f))continue;const d=()=>{if(Array.from(t(this,c).values()).includes(f)){var b=document.createDocumentFragment();Y(o,b),b.append(A()),t(this,r).set(f,{effect:o,fragment:b})}else k(o);t(this,u).delete(f),t(this,n).delete(f)};t(this,p)||!a?(t(this,u).add(f),C(o,d,!1)):d()}}});l(this,v,e=>{t(this,c).delete(e);const s=Array.from(t(this,c).values());for(const[a,h]of t(this,r))s.includes(a)||(k(h.effect),t(this,r).delete(a))});this.anchor=e,M(this,p,s)}ensure(e,s){var a=L,h=$();if(s&&!t(this,n).has(e)&&!t(this,r).has(e))if(h){var f=document.createDocumentFragment(),o=A();f.append(o),t(this,r).set(e,{effect:B(()=>s(o)),fragment:f})}else t(this,n).set(e,B(()=>s(this.anchor)));if(t(this,c).set(a,e),h){for(const[d,m]of t(this,n))d===e?a.unskip_effect(m):a.skip_effect(m);for(const[d,m]of t(this,r))d===e?a.unskip_effect(m.effect):a.skip_effect(m.effect);a.oncommit(t(this,_)),a.ondiscard(t(this,v))}else Q&&(this.anchor=S),t(this,_).call(this,a)}}c=new WeakMap,n=new WeakMap,r=new WeakMap,u=new WeakMap,p=new WeakMap,_=new WeakMap,v=new WeakMap;export{z as B};
