sprae
Version:
DOM microhydration
5 lines (4 loc) • 24.1 kB
JavaScript
var Oe=Object.defineProperty;var $t=(t,e)=>{for(var r in e)Oe(t,r,{get:e[r],enumerable:!0})};var y=Symbol.dispose||(Symbol.dispose=Symbol("dispose")),m=Symbol("state"),ft=Symbol("on"),M=Symbol("off"),gt=Symbol("init"),bt=":",k=t=>t.localName?.includes("-"),j,G,Q,it=t=>t(),I=it,Y={},F={},at=null,vt=null,Ne=t=>{if(!t?.tagName)return"";let e=t.tagName.toLowerCase();return t.id?e+="#"+t.id:t.className&&(e+="."+t.className.split(" ")[0]),`<${e}>`},yt=(t,e,r=vt)=>{let o=`\u2234 ${t}`;if(r&&(o+=`
in ${Ne(r)}`),e){let i=e.length>100?e.slice(0,80)+`\u2026 (${e.length} chars)`:e;o+=at?`
${at}="${i}"`:`
="${i}"`}console.error(o)},_t=(t=document.body,e)=>{if(t[m])return Object.assign(t[m],e);e=st(e||{});let r=t,o=[],i=[];r[ft]=()=>{if(i)return i;i=Array(o.length);for(let s=0;s<o.length;s++)i[s]=o[s]();return i},r[M]=()=>{if(!i)return;let s=i;i=null;for(let l=0;l<s.length;l++)s[l]?.()},r[y]||(r[y]=()=>{r[M]?.(),H?._root===r&&(H.disconnect(),H=null),r[M]=r[ft]=r[y]=r[gt]=r[m]=null});let n=r[gt]=s=>{let l=s.attributes,f;if(l)for(let c=0;c<l.length;){let{name:a,value:u}=l[c];if(a.startsWith(bt)){s.removeAttribute(a);let w=s[m];if(at=a,vt=s,o.push(f=qt(s,a.slice(bt.length),u,e)),i.push(f()),s[m]!==w)return}else c++}if(!(s!==t&&k(s)))if(s.firstChild!==void 0){let c=s.firstChild,a;for(;c;)a=c.nextSibling,c.nodeType==1&&n(c),c=a}else for(let c of s.childNodes)c.nodeType==1&&n(c)};return n(r),at=vt=null,r[m]===void 0&&!k(t)&&(r[m]=e),e};_t.version="13.3.8";var qt,Ht,x=t=>{let e=Rt[t=t.trim()];if(e)return e;try{e=Ht(t||"undefined")}catch(r){yt(r,t)}return Rt[t]=function(r,o,i){try{let n=e?.call(this,r);return o?n?.then?(n.then(s=>i=o(s)).catch(s=>yt(s,t,this)),()=>typeof i=="function"&&i()):o(n):n}catch(n){yt(n,t,this)}}},Rt={},nt=t=>(t.compile&&(Ht=t.compile),t.prefix&&(bt=t.prefix),t.signal&&(j=t.signal),t.effect&&(G=t.effect),t.computed&&(Q=t.computed),t.batch&&(it=t.batch),t.untracked&&(I=t.untracked),t.dir&&(qt=t.dir)),T=(t,e)=>{for(;e.length;){let[r,...o]=e.pop().split("-"),i=F[r],n;if(i&&(n=i(t,...o))!==t){for(let s in t)n[s]??(n[s]=t[s]);t=n}}return t},H=null,tt=t=>{H?.disconnect(),t(),H?.observe(H._root,{childList:!0,subtree:!0})},kt=(t=document.body,e)=>{let r=st(e);return _t(t,r),H=new MutationObserver(o=>{for(let i of o){for(let n of i.addedNodes)n.nodeType===1&&n[m]===void 0&&t.contains(n)&&t[gt](n);for(let n of i.removedNodes)n.nodeType===1&&!t.contains(n)&&n[y]?.()}}),H._root=t,H.observe(t,{childList:!0,subtree:!0}),r},L=t=>{if(!t.nodeType)return t;let e=t.ownerDocument,r=t.content.cloneNode(!0),o=[...t.attributes],i=e.createTextNode(""),n=(r.append(i),[...r.childNodes]);return{ownerDocument:e,childNodes:n,content:r,remove:()=>r.append(...n),replaceWith(s){s!==i&&(i.before(s),r.append(...n))},attributes:o,removeAttribute(s){o.splice(o.findIndex(l=>l.name===s),1)}}},It=t=>t.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,(e,r)=>(r?"-":"")+e.toLowerCase()),Ce=t=>t.replace(/-([a-z])/g,(e,r)=>r.toUpperCase()),$=(t,e,r)=>r==null||r===!1?t.removeAttribute(e):k(t)?t[Ce(e)]=r:t.setAttribute(e,r===!0?"":r),xt=t=>t?typeof t=="string"?t:(Array.isArray(t)?t.map(xt):Object.entries(t).reduce((e,[r,o])=>(o&&e.push(r),e),[])).join(" "):"",et=(t,e)=>{let r=0,o=0,i,n=typeof e=="function"?e:e?l=>setTimeout(l,e):queueMicrotask,s=l=>{i=l,r++||(t(i),n(()=>{let f=r>1;if(r=0,f){if(++o>50){o=0,console.error("\u2234 Reactive loop detected");return}s(i)}else o=0}))};return s},Kt=(t,e,r)=>{let o=typeof e=="function"?e:e?i=>setTimeout(i,e):queueMicrotask;return r?(i=>n=>!i&&(t(n),i=1,o(()=>i=0)))():((i=0)=>(n,s=++i)=>o(()=>s==i&&t(n)))()},b=_t;var D=Symbol("signals"),P=Symbol("change"),Ot=Symbol("touch"),lt=Symbol("set"),St=Symbol("parent"),wt=!0,rt=(t,e)=>{if(!t||t[Symbol.toStringTag]||t[D])return t;if(t.constructor!==Object)return Array.isArray(t)?Ut(t):t;let r=Object.keys(t).length,o={},i=new Proxy(Object.assign(o,{[P]:j(r),[D]:o}),{get:(s,l)=>l in o?o.hasOwnProperty(l)&&typeof o[l]=="function"&&!o[l].prototype?o[l].bind(i):o[l]?o[l].valueOf():o[l]:e?e[l]:typeof globalThis[l]=="function"&&!globalThis[l].prototype?globalThis[l].bind(globalThis):globalThis[l],set:(s,l,f)=>l in o?(zt(o,l,f),1):(wt=!1,e&&l in e?e[l]=f:(dt(o,l,f),o[P].value=++r),wt=!0,1),deleteProperty:(s,l)=>(l in o&&(l[0]!="_"&&o[l]?.[Symbol.dispose]?.(),delete o[l],o[P].value=--r),1),ownKeys:()=>(o[P].value,Reflect.ownKeys(o).filter(s=>s!==St)),has:(s,l)=>l in o?!0:e?l in e:wt});Object.defineProperty(o,St,{value:e,configurable:!0});let n=Object.getOwnPropertyDescriptors(t);for(let s in t)n[s]?.get?(o[s]=Q(n[s].get.bind(i)))[lt]=n[s].set?.bind(i):dt(o,s,t[s]);return i},Ut=(t,e=globalThis)=>{let r=t.map(a=>j(ut(a))),o=!1,i=a=>function(){return o=!0,a.apply(this,arguments)},n=j(t.length),s=j(0),l=()=>{s.value++},f=r.splice,c=new Proxy(Object.assign(r,{[P]:n,[Ot]:s,[D]:r,push:i(r.push),pop:i(r.pop),shift:i(r.shift),unshift:i(r.unshift),splice:i(function(){let a=f.apply(this,arguments);return l(),a})}),{get(a,u){return u==="length"?o?(o=!1,r.length):n.value:typeof u=="symbol"||isNaN(u)?r[u]?.valueOf()??e[u]:(r[u]??(r[u]=j(void 0))).valueOf()},set(a,u,w){if(u==="length"){for(let N=w;N<r.length;N++)delete c[N];n.value=r.length=w}else if(u>=r.length)dt(r,u,w,ut),c.length=+u+1;else if(r[u]){let N=r[u],A=N.peek?.()??N.valueOf();zt(r,u,w,ut),(N.peek?.()??N.valueOf())!==A&&l()}else dt(r,u,w,ut);return 1},deleteProperty:(a,u)=>(r[u]?.[Symbol.dispose]?.(),delete r[u],1)});return Object.defineProperty(r,St,{value:e,configurable:!0}),c},dt=(t,e,r,o=rt)=>t[e]=e[0]=="_"||r?.peek||typeof r=="function"?r:j(o(r)),ut=t=>{if(!t||typeof t!="object"||t.constructor!==Object||t[P])return t;let e=j(0);return new Proxy(t,{get:(r,o)=>o===D?r:o===P?e:(e.value,r[o]),set:(r,o,i)=>{let n=r[o];return r[o]=i,n!==i&&e.value++,1},has:()=>!0})},zt=(t,e,r,o=rt)=>{if(e[0]==="_"||typeof t[e]=="function")return t[e]=r;let i=t[e],n=i.peek?.()??i;if(r!==n){if(i[lt])return i[lt](r);Array.isArray(r)&&Array.isArray(n)?P in n?I(()=>it(()=>{for(let s=0;s<r.length;s++)n[s]=r[s];n.length=r.length})):i.value=P in r?r:Ut(r):i.value=o(r)}},st=rt;var Ct={};$t(Ct,{batch:()=>Ee,computed:()=>Ae,effect:()=>Zt,signal:()=>Vt,untracked:()=>Te});var K,Nt=0,ot,Vt=(t,e,r=new Set,o=()=>e.value)=>e={get value(){return K?.deps.add(r.add(K)),t},set value(i){if(i!==t){t=i;for(let n of r)ot?ot.add(n):n()}},peek(){return t},toJSON:o,toString:o,valueOf:o},Zt=(t,e,r,o)=>(r=i=>{if(!t)return;let n=e;if(e=null,n?.call?.(),i=K,K=r,Nt++>50){Nt--,K=i,e=t=r.fn=null;for(let s of o)s.delete(r);o.clear(),console.error("\u2234 Reactive loop detected");return}try{e=t()}finally{K=i,Nt--}},r.fn=t,o=r.deps=new Set,r(),i=>{e?.call?.(),e=t=r.fn=null;for(i of o)i.delete(r);o.clear()}),Ae=(t,e=Vt(),r,o,i=()=>r.value)=>r={get value(){return o||(o=Zt(()=>e.value=t())),e.value},peek:e.peek,toJSON:i,toString:i,valueOf:i},Ee=(t,e=!ot,r)=>{ot??(ot=new Set);try{t()}finally{if(e){[ot,r]=[null,ot];for(let o of r)o()}}},Te=(t,e,r)=>(e=K,K=null,r=t(),K=e,r);var Jt=(t,e)=>{var n,s;let r,o;t._holder?b(o=t,e):(t[n=m]??(t[n]=null),o=t.content?L(t):t,o[s=m]??(o[s]=null),tt(()=>t.replaceWith(r=t.ownerDocument.createTextNode(""))),o._holder=r._holder=r,r._clauses=[o._clause=[o,!1]],r._match=null,r.update=et(()=>{let l=r._clauses.find(([,f])=>f);l!=r._match&&tt(()=>{r._match?.[0].remove(),r._match?.[0][M]?.(),(r._match=l)&&(r.before(r._match[0].content||r._match[0]),r._match[0][m]?r._match[0][ft]?.():(delete r._match[0][m],b(r._match[0],e)))})}));let i=l=>{o._clause[1]=l,o._holder.update()};return i[M]=()=>{o._holder._match?.[0][M]?.(),o._holder._match=null},i};var Ft=t=>{var o;let e,r=t;for(e=t.content?L(t):t,e[o=m]??(e[o]=null);r&&!(e._holder=r._holder);)r=r.previousSibling;return t.remove(),t[m]=null,e._holder._clauses.push(e._clause=[e,!0]),e._holder.update};var Bt=t=>(t.content&&t.replaceWith(t=L(t).childNodes[0]),e=>{e=typeof e=="function"?e(t.textContent):e,e=e==null?"":""+e;let r=t.textContent;if(r===e)return;let o=t.firstChild;if(o&&e.startsWith(r)){o.appendData(e.slice(r.length));return}let i=t.ownerDocument,n=i.activeElement,s=n&&(n===t||t.contains(n))?i.getSelection?.():null,l=s?.rangeCount&&t.contains(s.anchorNode)?s.getRangeAt(0).startOffset:-1;if(t.textContent=e,l>=0&&t.firstChild){let f=Math.min(l,t.firstChild.textContent.length),c=new Range;c.setStart(t.firstChild,f),c.collapse(!0),s.removeAllRanges(),s.addRange(c)}});var Xt=(t,e,r,o)=>{let i=null,n,s=null,l=()=>!t.classList.length&&t.removeAttribute("class");return f=>{if(f=typeof f=="function"?f(t.className):f,f?.constructor===Object){if(s=null,i)for(let c of i)f[c]||(t.classList.remove(c),i.delete(c));i?.size||(i=null);for(let c in f)f[c]&&!i?.has(c)&&(t.classList.add(c),(i||(i=new Set)).add(c));i||l();return}if(f=xt(f),f!==s){if(s=f,n=null,f)for(let c of f.split(" "))c&&(n||(n=new Set)).add(c);if(i)for(let c of i)n?.has(c)||t.classList.remove(c);if(n)for(let c of n)i?.has(c)||t.classList.add(c);n||l(),i=n}}};var Gt=(t,e,r,o)=>{let i;return n=>{if(i===void 0&&(i=t.getAttribute("style")??""),n=typeof n=="function"?n(t.style):n,typeof n=="string")$(t,"style",i?i+"; "+n:n);else{i&&$(t,"style",i);for(let s in n)s[0]=="-"?t.style.setProperty(s,n[s]):s[0]>="A"&&(t.style[s]=n[s])}}};var Qt=()=>t=>typeof t=="function"&&t();var Yt=(t,e)=>(t.type?.startsWith("select")&&b(t,e),t.type==="text"||t.type===""||t.tagName==="TEXTAREA"?(r,o,i)=>(o=t.selectionStart,i=t.selectionEnd,t.setAttribute("value",t.value=r??""),o&&t.setSelectionRange(o,i)):t.type==="checkbox"?r=>(t.checked=r,$(t,"checked",r)):t.type==="radio"?r=>(t.checked=t.value===r,$(t,"checked",t.checked||null)):t.type==="select-one"?r=>{for(let o of t.options)o.value==r?o.setAttribute("selected",""):o.removeAttribute("selected");t.value=r}:t.type==="select-multiple"?r=>{for(let o of t.options)r.some(i=>i==o.value)?o.setAttribute("selected",""):o.removeAttribute("selected")}:r=>t.value=r);var je=(t,e=x(`${t}=__`))=>(r,o)=>{r.__=o,e(r),delete r.__},te=(t,e,r)=>{let o=x(r).call(t,e);typeof o=="function"?o(t):je(r)(e,t)};var ee=(t,e)=>{let r=t[m]=rt({},e),o=!1,i,n=t.content&&L(t);return n&&t.replaceWith(i=t.ownerDocument.createTextNode("")),s=>{if(s=typeof s=="function"?s(r):s,s!==r)for(let l in s){let f=Object.getOwnPropertyDescriptor(s,l);if(f?.get){(r[D][l]=Q(f.get.bind(r)))[lt]=f.set?.bind(r);continue}let c=typeof s[l]=="function"?s[l].bind(r):s[l];l in r[D]?r[l]=c:r[D][l]=l[0]=="_"||c?.peek?c:j(rt(c))}return!o&&(o=!0,!i&&delete t[m],I(()=>(i?.before(n.content||t),b(n||t,r))))}};var Le={get:(t,e)=>e===t.v?t.c?.[t.i]:e===t.k?t.o?t.o[t.i]:t.i:e===D?t:t.l?.[e]!==void 0?t.l[e]:t.p?.[e],set:(t,e,r)=>(e===t.v?t.c&&(t.c[t.i]=r):e===t.k||(t.l?.[e]!==void 0?t.l[e]=r:e in(t.p?.[D]||{})?t.p[e]=r:(t.l||(t.l={}))[e]=r),1),has:()=>!0},re={get:(t,e)=>e===t.v?t.r:e===t.k?t.i:e===D?t:t.l?.[e]!==void 0?t.l[e]:t.p?.[e],set:(t,e,r)=>(e===t.v?t.r=r:e===t.k||(t.l?.[e]!==void 0?t.l[e]=r:e in(t.p?.[D]||{})?t.p[e]=r:(t.l||(t.l={}))[e]=r),1),has:()=>!0},pt=t=>{t.el.remove(),t.el[Symbol.dispose]?.()},oe=(t,e,r)=>{let[o,i]=r.split(/\bin|of\b/),[n,s="$"]=o.trim().replace(/\(|\)/g,"").split(/\s*,\s*/),l=t.ownerDocument,f=t._eachHolder||(t._eachHolder=l.createTextNode("")),c=new Map,a=[],u,w,N,A=!1,R=(p,S)=>{let O=new Proxy(p,S),Z=t.content?L(t):t.cloneNode(!0);return{el:Z,scope:p,proxy:O,node:Z.content||Z,_di:p.i}},W=p=>{if(!p.length)return;let S=p.length>1?l.createDocumentFragment():null;for(let O of p)S?S.appendChild(O.node):f.before(O.node);S&&f.before(S);for(let O of p)b(O.el,O.proxy)},E=et(()=>tt(()=>{let p=u,S=p.length,O=a.length,Z=S!==O;A=!1;for(let h=0;h<S;h++)if(p[h]!=null){A=typeof p[h]=="object";break}if(A&&O){let h=[],q=[],J=new Set,Pt=!1;for(let v=0;v<S;v++){let g=p[v];if(g!=null&&typeof g=="object"){if(J.has(g))return;J.add(g)}let _=c.get(g);_?(!Z&&_.scope.i!==v&&(Pt=!0),_.scope.i=v,_.scope.r=g):(_=R({p:e,v:n,k:s,r:g,i:v,l:null},re),c.set(g,_),q.push(_)),h.push(_)}for(let[v,g]of c)J.has(v)||(pt(g),c.delete(v));if(W(q),Pt){let v=[];for(let g=0;g<h.length;g++){let _=h[g];_._di!==g&&v.push(_),_._di=g}if(v.length===2){let g=v[0].node,_=v[1].node,X=l.createTextNode("");g.replaceWith(X),_.replaceWith(g),X.replaceWith(_)}else{let g=f;for(let _=h.length-1;_>=0;_--){let X=h[_].node;X.nextSibling!==g&&g.before(X),g=X}}}else for(let v=0;v<h.length;v++)h[v]._di=v;a=h}else{if(O&&N!==p){for(let h of a)pt(h);a.length=0,O=0,c.clear()}if(N=p,S<O){for(let h=S;h<O;h++)pt(a[h]);a.length=S}for(let h=0;h<Math.min(O,S);h++)a[h].scope.c=p,w&&(a[h].scope.o=w);if(S>O){let h=[];for(let q=O;q<S;q++){let J=A?R({p:e,v:n,k:s,r:p[q],i:q,l:null},re):R({p:e,v:n,k:s,c:p,i:q,o:w,l:null},Le);a.push(J),A&&c.set(p[q],J),h.push(J)}W(h)}}}));t.parentNode&&tt(()=>t.replaceWith(f)),t[m]=null;let V=p=>{w=null,typeof p=="number"?u=Array.from({length:p},(O,Z)=>Z+1):p?.constructor===Object?(w=Object.keys(p),u=Object.values(p)):u=p||[];let S=G(()=>{u[P]?.value,u[Ot],E()});return()=>S()};return V.eval=x(i),V[M]=()=>{for(let p of a)pt(p);a.length=0,c.clear()},V};var ie=(t,e,r,o)=>i=>$(t,o,typeof i=="function"&&!k(t)?i(t.getAttribute(o)):i);var ne=t=>e=>{let r=k(t);for(let o in e)$(t,r?o:It(o),e[o])};var se=(t,e,r,o)=>{let[i,...n]=o.slice(2).split("."),s=x(r).bind(t),l=T(Object.assign(f=>s(e,c=>typeof c=="function"?c(f):c),{target:t}),n);return l.target.addEventListener(i,l,l),{[Symbol.dispose](){l.target.removeEventListener(i,l),l[Symbol.dispose]?.()}}};var le=(t,e,r,o)=>{let i,n,s=x(r).bind(t),l=o.split("..").map((f,c,{length:a})=>f.split(":").reduce((u,w)=>{let[N,...A]=w.slice(2).split("."),R=(E,V)=>i=typeof E=="function"?E(V):E,W=T(Object.assign(E=>(c?R(i,E):s(e,V=>R(V,E)),n(),n=l[(c+1)%a]()),{target:t}),A);return E=>(E=u?.(),W.target.addEventListener(N,W,W),()=>(E?.(),W.target.removeEventListener(N,W)))},null));return n=l[0](),{[Symbol.dispose](){n?.()}}};var ce=t=>!!t?.content,fe=(t,e)=>{if(t.content){let r,o=t.innerHTML,i=t.ownerDocument,n=t._holder;return n||t.replaceWith(n=i.createTextNode("")),s=>{if(typeof s=="function"&&(s=s(o)),t._holder&&(t.remove(),t.content.replaceChildren()),r?.[y]?.(),r?.remove(),s!=null&&s!=="")return r=ce(s)?(o=s.innerHTML,L(s)):L((r=i.createElement("template"),r.innerHTML=o=s,r)),I(()=>b(r,e)),n.before(r.content),t._holder&&t.childNodes.splice(0,1/0,...r.childNodes),r[y];t._holder&&(t.childNodes.length=0,o="")}}return r=>{var o;return r=typeof r=="function"?r(t.innerHTML):r,ce(r)?t.replaceChildren(r.content.cloneNode(!0)):t.innerHTML=r??"",t[o=m]&&(t[o]=null),I(()=>b(t,e)),t[y]}};var ae=(t,e,r)=>{let o=t.ownerDocument,i=o.createComment(":portal"),n=null;return t.before(i),s=>{let l=t.getRootNode(),f=typeof s=="string"?l.querySelector?.(s)||o.querySelector(s):s?.nodeType===1?s:s?o.body:null;if(f!==n)return f?f.appendChild(t):i.after(t),n=f,()=>{n&&(i.after(t),n=null)}}};var ue=t=>e=>t.hidden=!!e;var At=(t,e,r,o)=>{let[,...i]=o.split("."),n=x(r).bind(t),s;return T(Object.assign(()=>{let f=n(e,c=>typeof c=="function"?c(t):c);typeof f=="function"&&(s=f)},{target:t}),i)(),{[y](){s?.(),s=null}}};var Et=(t,e,r,o)=>{let[,...i]=o.split("."),n=x(r).bind(t),s=t.type==="checkbox"?()=>t.checked:t.type==="select-multiple"?()=>[...t.selectedOptions].map(f=>f.value):/^(date|time|month|week)/.test(t.type)?()=>t.value:()=>t.selectedIndex<0?null:isNaN(t.valueAsNumber)?t.value:t.valueAsNumber,l=T(Object.assign(()=>{n(e,f=>typeof f=="function"?f(s()):f)},{target:t}),i);return t.addEventListener("input",l),t.addEventListener("change",l),{[y](){t.removeEventListener("input",l),t.removeEventListener("change",l)}}};var de=(t,e,r,o)=>{let[,...i]=o.split("."),n=x(r).bind(t),s=i.includes("once"),l=T(Object.assign(c=>{n(e,a=>typeof a=="function"?a(c):a)},{target:t}),i),f=new IntersectionObserver(c=>{for(let a of c)a.isIntersecting&&(l(a),s&&f.disconnect())});return f.observe(t),{[y](){f.disconnect()}}};de.observer=!0;var pe=de;var he=(t,e,r,o)=>{let[,...i]=o.split("."),n=x(r).bind(t),s=T(Object.assign(f=>{n(e,c=>typeof c=="function"?c(f):c)},{target:t}),i),l=new ResizeObserver(f=>{for(let c of f){let a=c.contentRect;s({width:a.width,height:a.height,entry:c})}});return l.observe(t),{[y](){l.disconnect()}}};he.observer=!0;var me=he;At.observer=Et.observer=!0;Object.assign(Y,{_:ie,"":ne,class:Xt,text:Bt,html:fe,style:Gt,fx:Qt,value:Yt,ref:te,scope:ee,if:Jt,else:Ft,each:oe,portal:ae,hidden:ue,mount:At,change:Et,intersect:pe,resize:me});var De=(t,e,r,o)=>{let[i,...n]=e.split("."),s=Y[i]||Y._,l=n.length>0;return()=>{let f=t,c,a,u,w=0;if(l&&(a=j(0),u=T(Object.assign(()=>a.value++,{target:t}),n),f=u.target??t),c=s(f,o,r,i),!c?.call)return c?.[y];let N=c.eval??x(r).bind(f),A,R=()=>(typeof A=="function"&&A(),A=null);k(f)||(o=f[m]??o);let W=l?G(()=>(a.value==w?u():(w=a.value,A=N(o,c)),R)):G(()=>(A=N(o,c),R));if(!(m in f))return W;let E=0;return()=>{E||(E=1,W(),c[M]?c[M]():f[y]?.())}}},Me=t=>t?typeof t=="number"?t:(([,e,r]=t.match(/^(\d+)(ms|s|m)?$/)||[])=>(e=+e,r==="s"?e*1e3:r==="m"?e*6e4:e))():0,Tt=t=>t==="idle"?requestIdleCallback:t==="raf"?requestAnimationFrame:!t||t==="tick"?queueMicrotask:e=>setTimeout(e,Me(t));Object.assign(F,{debounce:(t,e,r)=>Kt(t,Tt(e==="immediate"?r:e),e==="immediate"||r==="immediate"),throttle:(t,e)=>et(t,Tt(e)),delay:(t,e)=>((r=Tt(e))=>o=>r(()=>t(o)))(),tick:t=>e=>queueMicrotask(()=>t(e)),raf:t=>e=>requestAnimationFrame(()=>t(e)),once:(t,e,r)=>(r=o=>!e&&(e=1,t(o)),r.once=!0,r),window:t=>(t.target=t.target.ownerDocument.defaultView,t),document:t=>(t.target=t.target.ownerDocument,t),root:t=>(t.target=t.target.ownerDocument.documentElement,t),body:t=>(t.target=t.target.ownerDocument.body,t),parent:t=>(t.target=t.target.parentNode,t),self:t=>e=>e.target===t.target&&t(e),away:(t,e)=>{let r=t.target.ownerDocument,o=n=>e=n.target,i=r.currentEvent||r.defaultView?.event;return r.addEventListener("pointerdown",o,!0),Object.assign(n=>n!==i&&!t.target.contains(n.type==="click"?e??n.target:n.target)&&n.target.isConnected&&t(n),{target:r,[y]:()=>r.removeEventListener("pointerdown",o,!0)})},prevent:t=>e=>(e?.preventDefault(),t(e)),stop:(t,e)=>r=>(e?.[0]==="i"?r?.stopImmediatePropagation():r?.stopPropagation(),t(r)),passive:t=>(t.passive=!0,t),capture:t=>(t.capture=!0,t)});F.outside=F.away;var jt={ctrl:t=>t.ctrlKey||t.key==="Control"||t.key==="Ctrl",shift:t=>t.shiftKey||t.key==="Shift",alt:t=>t.altKey||t.key==="Alt",meta:t=>t.metaKey||t.key==="Meta",cmd:t=>t.metaKey||t.key==="Command",arrow:t=>t.key?.startsWith("Arrow"),enter:t=>t.key==="Enter",esc:t=>t.key?.startsWith("Esc"),tab:t=>t.key==="Tab",space:t=>t.key==="\xA0"||t.key==="Space"||t.key===" ",delete:t=>t.key==="Delete"||t.key==="Backspace",digit:t=>/^\d$/.test(t.key),letter:t=>/^\p{L}$/gu.test(t.key),char:t=>/^\S$/.test(t.key)},ye=(t,e)=>jt[t]?.(e)||e.key?.toLowerCase()===t||e.keyCode==t;for(let t in jt)F[t]=(e,r,o)=>i=>jt[t](i)&&(!r||ye(r,i))&&(!o||ye(o,i))&&e(i);var We=t=>{let e=0,r="",o=0;for(let i of t){if(r){o?o=0:i==="\\"?o=1:i===r&&(r="");continue}if(i===";"&&!e)return!0;i==="{"?e++:i==="}"?e--:(i==='"'||i==="'"||i==="`")&&(r=i)}return!1};nt({compile:t=>(/^(if|let|const)\b/.test(t)||We(t)||(t=`return ${t}`),/\bawait\s/.test(t)&&(t=`return (async()=>{${t}})()`),b.constructor(`with(arguments[0]){${t}}`)),dir:(t,e,r,o)=>e.includes("..")?()=>le(t,o,r,e)[y]:e.split(":").reduce((i,n)=>{let s=n.split(".")[0],l=Y[s],f=n.startsWith("on")?()=>se(t,o,r,n)[y]:l?.observer?()=>l(t,o,r,n)[y]:De(t,n,r,o);return i?(c,a)=>(c=i(),a=f(),()=>{c(),a()}):f},null),...Ct});b.use=nt;b.store=st;b.directive=Y;b.modifier=F;var ao=b.dispose=t=>t[y]?.();b.start=kt;var ge=b;var Wt={};$t(Wt,{Computed:()=>z,Effect:()=>B,Signal:()=>C,batch:()=>$e,computed:()=>qe,effect:()=>Se,signal:()=>Re,untracked:()=>Dt});var Pe=Symbol.for("preact-signals");function mt(){if(U>1)U--;else{for(var t,e=!1;ct!==void 0;){var r=ct;for(ct=void 0,Lt++;r!==void 0;){var o=r.o;if(r.o=void 0,r.f&=-3,!(8&r.f)&&ve(r))try{r.c()}catch(i){e||(t=i,e=!0)}r=o}}if(Lt=0,U--,e)throw t}}function $e(t){if(U>0)return t();U++;try{return t()}finally{mt()}}var d=void 0;function Dt(t){var e=d;d=void 0;try{return t()}finally{d=e}}var ct=void 0,U=0,Lt=0,ht=0;function be(t){if(d!==void 0){var e=t.n;if(e===void 0||e.t!==d)return e={i:0,S:t,p:d.s,n:void 0,t:d,e:void 0,x:void 0,r:e},d.s!==void 0&&(d.s.n=e),d.s=e,t.n=e,32&d.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=d.s,e.n=void 0,d.s.n=e,d.s=e),e}}function C(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}C.prototype.brand=Pe;C.prototype.h=function(){return!0};C.prototype.S=function(t){var e=this,r=this.t;r!==t&&t.e===void 0&&(t.x=r,this.t=t,r!==void 0?r.e=t:Dt(function(){var o;(o=e.W)==null||o.call(e)}))};C.prototype.U=function(t){var e=this;if(this.t!==void 0){var r=t.e,o=t.x;r!==void 0&&(r.x=o,t.e=void 0),o!==void 0&&(o.e=r,t.x=void 0),t===this.t&&(this.t=o,o===void 0&&Dt(function(){var i;(i=e.Z)==null||i.call(e)}))}};C.prototype.subscribe=function(t){var e=this;return Se(function(){var r=e.value,o=d;d=void 0;try{t(r)}finally{d=o}},{name:"sub"})};C.prototype.valueOf=function(){return this.value};C.prototype.toString=function(){return this.value+""};C.prototype.toJSON=function(){return this.value};C.prototype.peek=function(){var t=d;d=void 0;try{return this.value}finally{d=t}};Object.defineProperty(C.prototype,"value",{get:function(){var t=be(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(Lt>100)throw new Error("Cycle detected");this.v=t,this.i++,ht++,U++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{mt()}}}});function Re(t,e){return new C(t,e)}function ve(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function _e(t){for(var e=t.s;e!==void 0;e=e.n){var r=e.S.n;if(r!==void 0&&(e.r=r),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function xe(t){for(var e=t.s,r=void 0;e!==void 0;){var o=e.p;e.i===-1?(e.S.U(e),o!==void 0&&(o.n=e.n),e.n!==void 0&&(e.n.p=o)):r=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=o}t.s=r}function z(t,e){C.call(this,void 0),this.x=t,this.s=void 0,this.g=ht-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}z.prototype=new C;z.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ht))return!0;if(this.g=ht,this.f|=1,this.i>0&&!ve(this))return this.f&=-2,!0;var t=d;try{_e(this),d=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(r){this.v=r,this.f|=16,this.i++}return d=t,xe(this),this.f&=-2,!0};z.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}C.prototype.S.call(this,t)};z.prototype.U=function(t){if(this.t!==void 0&&(C.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};z.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(z.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=be(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function qe(t,e){return new z(t,e)}function we(t){var e=t.u;if(t.u=void 0,typeof e=="function"){U++;var r=d;d=void 0;try{e()}catch(o){throw t.f&=-2,t.f|=8,Mt(t),o}finally{d=r,mt()}}}function Mt(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,we(t)}function He(t){if(d!==this)throw new Error("Out-of-order effect");xe(this),d=t,this.f&=-2,8&this.f&&Mt(this),mt()}function B(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}B.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{t()}};B.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,we(this),_e(this),U++;var t=d;return d=this,He.bind(this,t)};B.prototype.N=function(){2&this.f||(this.f|=2,this.o=ct,ct=this)};B.prototype.d=function(){this.f|=8,1&this.f||Mt(this)};B.prototype.dispose=function(){this.d()};function Se(t,e){var r=new B(t,e);try{r.c()}catch(i){throw r.d(),i}var o=r.d.bind(r);return o[Symbol.dispose]=o,o}nt(Wt);var ho=ge;export{it as batch,Q as computed,Kt as debounce,ho as default,ao as dispose,G as effect,j as signal,b as sprae,kt as start,st as store,et as throttle,I as untracked,nt as use};