UNPKG

sprae

Version:

DOM microhydration

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