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{w as x,x as C,y as k,z,A,B,o as S,C as j,D as q,F as E}from"./DpkolLiq.js";var r,n,h,p,m,_,v;class I{constructor(e,s=!0){w(this,"anchor");l(this,r,new Map);l(this,n,new Map);l(this,h,new Map);l(this,p,new Set);l(this,m,!0);l(this,_,()=>{var e=x;if(t(this,r).has(e)){var s=t(this,r).get(e),a=t(this,n).get(s);if(a)C(a),t(this,p).delete(s);else{var c=t(this,h).get(s);c&&(t(this,n).set(s,c.effect),t(this,h).delete(s),c.fragment.lastChild.remove(),this.anchor.before(c.fragment),a=c.effect)}for(const[f,o]of t(this,r)){if(t(this,r).delete(f),f===e)break;const d=t(this,h).get(o);d&&(k(d.effect),t(this,h).delete(o))}for(const[f,o]of t(this,n)){if(f===s||t(this,p).has(f))continue;const d=()=>{if(Array.from(t(this,r).values()).includes(f)){var b=document.createDocumentFragment();q(o,b),b.append(A()),t(this,h).set(f,{effect:o,fragment:b})}else k(o);t(this,p).delete(f),t(this,n).delete(f)};t(this,m)||!a?(t(this,p).add(f),z(o,d,!1)):d()}}});l(this,v,e=>{t(this,r).delete(e);const s=Array.from(t(this,r).values());for(const[a,c]of t(this,h))s.includes(a)||(k(c.effect),t(this,h).delete(a))});this.anchor=e,M(this,m,s)}ensure(e,s){var a=x,c=E();if(s&&!t(this,n).has(e)&&!t(this,h).has(e))if(c){var f=document.createDocumentFragment(),o=A();f.append(o),t(this,h).set(e,{effect:B(()=>s(o)),fragment:f})}else t(this,n).set(e,B(()=>s(this.anchor)));if(t(this,r).set(a,e),c){for(const[d,u]of t(this,n))d===e?a.skipped_effects.delete(u):a.skipped_effects.add(u);for(const[d,u]of t(this,h))d===e?a.skipped_effects.delete(u.effect):a.skipped_effects.add(u.effect);a.oncommit(t(this,_)),a.ondiscard(t(this,v))}else S&&(this.anchor=j),t(this,_).call(this)}}r=new WeakMap,n=new WeakMap,h=new WeakMap,p=new WeakMap,m=new WeakMap,_=new WeakMap,v=new WeakMap;export{I as B};
