vite-plugin-kiru 0.29.1 → 0.29.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2185,7 +2185,7 @@ function createVirtualModules(projectRoot, ssgOptions) {
|
|
|
2185
2185
|
throw new Error(`Document not found at ${fp}`);
|
|
2186
2186
|
}
|
|
2187
2187
|
function createRoutesModule() {
|
|
2188
|
-
const { dir, baseUrl, page, layout } = ssgOptions;
|
|
2188
|
+
const { dir, baseUrl, page, layout, transition } = ssgOptions;
|
|
2189
2189
|
return `
|
|
2190
2190
|
import { formatViteImportMap, normalizePrefixPath } from "kiru/router/utils"
|
|
2191
2191
|
|
|
@@ -2195,8 +2195,9 @@ const pagesMap = import.meta.glob(["/**/${page}"])
|
|
|
2195
2195
|
const layoutsMap = import.meta.glob(["/**/${layout}"])
|
|
2196
2196
|
const pages = formatViteImportMap(pagesMap, dir, baseUrl)
|
|
2197
2197
|
const layouts = formatViteImportMap(layoutsMap, dir, baseUrl)
|
|
2198
|
+
const transition = ${transition}
|
|
2198
2199
|
|
|
2199
|
-
export { dir, baseUrl, pages, layouts }
|
|
2200
|
+
export { dir, baseUrl, pages, layouts, transition }
|
|
2200
2201
|
`;
|
|
2201
2202
|
}
|
|
2202
2203
|
function createEntryServerModule() {
|
|
@@ -2222,10 +2223,10 @@ export async function generateStaticPaths() {
|
|
|
2222
2223
|
function createEntryClientModule() {
|
|
2223
2224
|
return `
|
|
2224
2225
|
import { initClient } from "kiru/router/client"
|
|
2225
|
-
import { dir, baseUrl, pages, layouts } from "${VIRTUAL_ROUTES_ID}"
|
|
2226
|
+
import { dir, baseUrl, pages, layouts, transition } from "${VIRTUAL_ROUTES_ID}"
|
|
2226
2227
|
import "${resolveUserDocument2()}"
|
|
2227
2228
|
|
|
2228
|
-
initClient({ dir, baseUrl, pages, layouts })
|
|
2229
|
+
initClient({ dir, baseUrl, pages, layouts, transition })
|
|
2229
2230
|
`;
|
|
2230
2231
|
}
|
|
2231
2232
|
return {
|
|
@@ -2436,7 +2437,7 @@ var dist_default2 = `var Ke="production";if(Ke!=="development"&&Ke!=="production
|
|
|
2436
2437
|
|
|
2437
2438
|
\${r.map(o=>\` at \${o}\`).join(\`
|
|
2438
2439
|
\`)}
|
|
2439
|
-
\`}function Kr(e){let t=Ot(e);if(l){let r=Ur(e);r&&(t=\`\${t} (\${r})\`)}return t}function Ot(e){return e.displayName??(e.name||"Anonymous Function")}function Ur(e){return e.toString().match(/\\/\\/ \\[kiru_devtools\\]:(.*)/)?.[1]??null}var te={parentStack:[],childIdxStack:[],eventDeferrals:new Map,parent:function(){return this.parentStack[this.parentStack.length-1]},clear:function(){this.parentStack.length=0,this.childIdxStack.length=0},pop:function(){this.parentStack.pop(),this.childIdxStack.pop()},push:function(e){this.parentStack.push(e),this.childIdxStack.push(0)},currentChild:function(){return this.parentStack[this.parentStack.length-1].childNodes[this.childIdxStack[this.childIdxStack.length-1]]},nextChild:function(){return this.parentStack[this.parentStack.length-1].childNodes[this.childIdxStack[this.childIdxStack.length-1]++]},bumpChildIndex:function(){this.childIdxStack[this.childIdxStack.length-1]++},captureEvents:function(e){Pt(e,!0),this.eventDeferrals.set(e,[])},resetEvents:function(e){this.eventDeferrals.delete(e)},releaseEvents:function(e){Pt(e,!1);let t=this.eventDeferrals.get(e);for(;t?.length;)t.shift()()}},Wr=e=>{let t=e.target;!e.isTrusted||!t||te.eventDeferrals.get(t)?.push(()=>t.dispatchEvent(e))},Pt=(e,t)=>{for(let r in e)if(r.startsWith("on")){let n=r.substring(2);e[t?"addEventListener":"removeEventListener"](n,Wr,{passive:!0})}};var rt=!1,Je=!1,Dt=e=>{e.preventDefault(),e.stopPropagation(),Je=!0},le=null;function Lt(){rt=!0,le=document.activeElement,le&&le!==document.body&&le.addEventListener("blur",Dt)}function Vt(){Je&&(le.removeEventListener("blur",Dt),le.isConnected&&le.focus(),Je=!1),rt=!1}function Ze(e,t){if(typeof e=="function"){e(t);return}if(w.isSignal(e)){e.sneak(t),e.notify({filter:r=>typeof r=="function"});return}e.current=t}function $t(e){let t=e.type;return t=="#text"?Ht(e):qe.has(t)?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t)}function Ht(e){let{nodeValue:t}=e.props;if(!w.isSignal(t))return document.createTextNode(t);let r=t.peek()??"",n=document.createTextNode(r);return et(e,n,t),n}function Br(e,t,r){let n=Qe.get(e)??{},o=n[t]=s=>{if(rt){s.preventDefault(),s.stopPropagation();return}r(s)};return Qe.set(e,n),o}var Qe=new WeakMap;function Ft(e){let t=e.dom,r=e.prev?.props??{},n=e.props??{},o=new Set([...Object.keys(r),...Object.keys(n)]),s=S.current==="hydrate";o.forEach(i=>{let a=r[i],u=n[i];if(ge.internalProps.includes(i)&&i!=="innerHTML"){i==="ref"&&a!==u&&(a&&Ze(a,null),u&&Ze(u,t));return}if(ge.isEvent(i)){if(a!==u||S.current==="hydrate"){let c=i.replace(At,""),p=c==="focus"||c==="blur";i in r&&t.removeEventListener(c,p?Qe.get(e)?.[c]:a),i in n&&t.addEventListener(c,p?Br(e,c,u):u)}return}if(!(t instanceof Text)){if(a===u||s&&t.getAttribute(i)===u)return;if(w.isSignal(a)&&e.cleanups){let c=e.cleanups[i];c&&(c(),delete e.cleanups[i])}if(w.isSignal(u))return Yr(e,t,i,u,a);Ce(t,i,u,a);return}w.isSignal(u)||t.nodeValue!==u&&(t.nodeValue=u)})}function qr(e){return e.multiple?Array.from(e.selectedOptions).map(t=>t.value):e.value}function Nt(e,t){if(!e.multiple||t===void 0||t===null||t===""){e.value=t;return}Array.from(e.options).forEach(r=>{r.selected=t.indexOf(r.value)>-1})}var Gr={value:"input",checked:"change",open:"toggle",volume:"volumechange",playbackRate:"ratechange",currentTime:"timeupdate"},Xr=["progress","meter","number","range"];function Yr(e,t,r,n,o){let s=e.cleanups??(e.cleanups={}),[i,a]=r.split(":");if(i!=="bind")return s[r]=n.subscribe((b,C)=>{Ce(t,r,b,C),l&&window.__kiru.profilingContext?.emit("signalAttrUpdate",J(e))}),Ce(t,r,n.peek(),Y(o));let u=Gr[a];if(!u){l&&console.error(\`[kiru]: \${a} is not a valid element binding attribute.\`);return}let c=t instanceof HTMLSelectElement,p=c?b=>Nt(t,b):b=>t[a]=b,v=b=>{p(b),l&&window.__kiru.profilingContext?.emit("signalAttrUpdate",J(e))},M=b=>{n.sneak(b),n.notify({filter:C=>C!==v})},h;if(a==="value"){let b=Xr.indexOf(t.type)!==-1;h=()=>{let C=t.value;c?C=qr(t):typeof n.peek()=="number"&&b&&(C=t.valueAsNumber),M(C)}}else h=b=>{let C=b.target[a];a==="currentTime"&&n.peek()===C||M(C)};t.addEventListener(u,h);let x=n.subscribe(v);return s[r]=()=>{t.removeEventListener(u,h),x()},Ce(t,a,n.peek(),Y(o))}function et(e,t,r){(e.cleanups??(e.cleanups={})).nodeValue=r.subscribe((n,o)=>{n!==o&&(t.nodeValue=n,l&&window.__kiru.profilingContext?.emit("signalTextUpdate",J(e)))})}function Jr(e){if(e.type!=="#text"||!w.isSignal(e.props.nodeValue))return;let t=Y(e.props.nodeValue);if(!Xe(t)){l&&console.error(\`[kiru]: Hydration mismatch - expected primitive child but received \${t}\`);return}let r=Ht(e),n=te.parent();return n&&n.appendChild(r),r}function It(e){let t=te.nextChild()??Jr(e);if(!t)throw new E({message:"Hydration mismatch - no node found",vNode:e});let r=t.nodeName;if(qe.has(r)||(r=r.toLowerCase()),e.type!==r)throw new E({message:\`Hydration mismatch - expected node of type \${e.type.toString()} but received \${r}\`,vNode:e});if(e.dom=t,e.type!=="#text"&&!(e.flags&V)){Ft(e);return}w.isSignal(e.props.nodeValue)&&et(e,t,e.props.nodeValue);let n=e,o=e.sibling;for(;o&&o.type==="#text";){let s=o;te.bumpChildIndex();let i=String(Y(n.props.nodeValue)??""),a=n.dom.splitText(i.length);s.dom=a,w.isSignal(s.props.nodeValue)&&et(s,a,s.props.nodeValue),n=o,o=o.sibling}}function zt(e,t,r,n=!1){if(r===null)return e.removeAttribute(t),!0;switch(typeof r){case"undefined":case"function":case"symbol":return e.removeAttribute(t),!0;case"boolean":if(n&&!r)return e.removeAttribute(t),!0}return!1}function Zr(e,t,r){let n=Ge.has(t);zt(e,t,r,n)||e.setAttribute(t,n&&typeof r=="boolean"?"":String(r))}var Qr=["INPUT","TEXTAREA"],en=e=>Qr.indexOf(e.nodeName)>-1;function Ce(e,t,r,n){if(r!==n)switch(t){case"style":return nn(e,r,n);case"className":return rn(e,r);case"innerHTML":return tn(e,r);case"muted":e.muted=!!r;return;case"value":if(e.nodeName==="SELECT")return Nt(e,r);let o=r==null?"":String(r);if(en(e)){e.value=o;return}e.setAttribute("value",o);return;case"checked":if(e.nodeName==="INPUT"){e.checked=!!r;return}e.setAttribute("checked",String(r));return;default:return Zr(e,qt(t),r)}}function tn(e,t){if(t==null||typeof t=="boolean"){e.innerHTML="";return}e.innerHTML=String(t)}function rn(e,t){let r=Y(t);if(!r)return e.removeAttribute("class");e.setAttribute("class",r)}function nn(e,t,r){if(zt(e,"style",t))return;if(typeof t=="string"){e.setAttribute("style",t);return}let n={};typeof r=="string"?e.setAttribute("style",""):typeof r=="object"&&r&&(n=r);let o=t;new Set([...Object.keys(n),...Object.keys(o)]).forEach(i=>{let a=n[i],u=o[i];if(a!==u){if(u===void 0){e.style[i]="";return}e.style[i]=u}})}function on(e){let t=e.parent,r=t?.dom;for(;t&&!r;)t=t.parent,r=t?.dom;if(!r||!t){if(!e.parent&&e.dom)return e;throw new E({message:"No DOM parent found while attempting to place node.",vNode:e})}return t}function sn(e,t){let{node:r,lastChild:n}=t,o=e.dom;if(n){n.after(o);return}let s=jt(e,r);if(s){r.dom.insertBefore(o,s);return}r.dom.appendChild(o)}function jt(e,t){let r=e;for(;r;){let n=r.sibling;for(;n;){if(!(n.flags&(T|V))){let o=an(n);if(o?.isConnected)return o}n=n.sibling}if(r=r.parent,!r||r.flags&V||r===t)return}}function an(e){let t=e;for(;t;){if(t.dom)return t.dom;if(t.flags&V)return;t=t.child}}function Kt(e){if(S.current==="hydrate")return Z(e,he);let t={node:e.dom?e:on(e)};tt(e,t,(e.flags&T)>0),e.dom&&!(e.flags&V)&&Ut(e,t,!1),he(e)}function tt(e,t,r){let n=e.child;for(;n;){if(n.flags&me){n.flags&T&&ln(n,t),he(n),n=n.sibling;continue}n.dom?(tt(n,{node:n},!1),n.flags&V||Ut(n,t,r)):tt(n,t,(n.flags&T)>0||r),he(n),n=n.sibling}}function Ut(e,t,r){(r||!e.dom.isConnected||e.flags&T)&&sn(e,t),(!e.prev||e.flags&P)&&Ft(e),t.lastChild=e.dom}function Wt(e){e===e.parent?.child&&(e.parent.child=e.sibling);let t;l&&(t=J(e)),Z(e,r=>{let{hooks:n,subs:o,cleanups:s,dom:i,props:{ref:a}}=r;for(o?.forEach(u=>u()),s&&Object.values(s).forEach(u=>u());n?.length;)n.pop().cleanup?.();l&&(window.__kiru.profilingContext?.emit("removeNode",t),i instanceof Element&&delete i.__kiruNode),i&&(a&&Ze(a,null),i.isConnected&&!(r.flags&V)&&i.remove(),delete r.dom)}),e.parent=null}function ln(e,t){if(!e.child)return;let r=[];if(Bt(e.child,r),r.length===0)return;let{node:n,lastChild:o}=t;if(o)o.after(...r);else{let s=jt(e,n),i=n.dom;s?s.before(...r):i.append(...r)}t.lastChild=r[r.length-1]}function Bt(e,t){let r=e;for(;r;)r.dom?t.push(r.dom):r.child&&Bt(r.child,t),r=r.sibling}function Gt(e){return typeof e=="function"&&typeof e[ke]?.arePropsEqual=="function"}function f(e,t=null,...r){if(e===Q)return Q({children:r,...t});let n={type:e,flags:0,index:0,depth:0,props:{},parent:null,sibling:null,child:null,prev:null,deletions:null};if(Gt(e)&&(n.flags|=_e,n.arePropsEqual=e[ke].arePropsEqual),t!==null){let{key:s,ref:i,...a}=t;Xt(s)&&(n.props.key=s.toString()),Yt(i)&&(n.props.ref=i),Object.assign(n.props,a)}let o=r.length===1?r[0]:r.length>1?r:null;return o!==null&&(n.props.children=o),n}function Q({children:e,key:t}){return f(G,t?{key:t}:null,e)}var it;function Me(e,t){return l&&(it=J(e)),Array.isArray(t)?(l&&(nr in t&&dn(e,t),pn(e,t)),cn(e,t)):un(e,t)}function un(e,t){let r=e.child;if(r===null)return er(e,t);let n=r.sibling,o=Zt(e,r,t);if(o!==null)return r&&r!==o&&!o.prev?ot(e,r):n&&ot(e,n),o;{let s=or(r),i=tr(s,e,0,t);if(i!==null){let a=i.prev;if(a!==null){let u=a.props.key;s.delete(u===void 0?a.index:u)}Te(i,0,0)}return s.forEach(a=>Ae(e,a)),i}}function cn(e,t){let r=null,n=null,o=e.child,s=null,i=0,a=0;for(;o!==null&&a<t.length;a++){o.index>a?(s=o,o=null):s=o.sibling;let c=Zt(e,o,t[a]);if(c===null){o===null&&(o=s);break}o&&!c.prev&&Ae(e,o),i=Te(c,i,a),n===null?r=c:n.sibling=c,n=c,o=s}if(a===t.length)return ot(e,o),r;if(o===null){for(;a<t.length;a++){let c=er(e,t[a]);c!==null&&(i=Te(c,i,a),n===null?r=c:n.sibling=c,n=c)}return r}let u=or(o);for(;a<t.length;a++){let c=tr(u,e,a,t[a]);if(c!==null){let p=c.prev;if(p!==null){let v=p.props.key;u.delete(v===void 0?p.index:v)}i=Te(c,i,a),n===null?r=c:n.sibling=c,n=c}}return u.forEach(c=>Ae(e,c)),r}function Zt(e,t,r){let n=t?.props.key;return Re(r)?n!==void 0||t?.type==="#text"&&w.isSignal(t.props.nodeValue)?null:Jt(e,t,""+r):w.isSignal(r)?t&&t.props.nodeValue!==r?null:Jt(e,t,r):ue(r)?r.props.key!==n?null:fn(e,t,r):Array.isArray(r)?n!==void 0?null:(l&&st(r),Qt(e,t,r)):null}function Jt(e,t,r){if(t===null||t.type!=="#text"){l&&U();let o=f("#text",{nodeValue:r});return K(o,e),o}return l&&we(),t.props.nodeValue!==r&&(t.props.nodeValue=r,t.flags|=P),t.sibling=null,t}function fn(e,t,r){let{type:n,props:o}=r;if(l&&typeof n=="function"&&(n=_(n)),n===G)return Qt(e,t,o.children||[],o);if(t?.type===n)return l&&we(),t.index=0,t.sibling=null,typeof n=="string"?rr(t.props,o)&&(t.flags|=P):t.flags|=P,t.props=o,t.memoizedProps=r.memoizedProps,t;l&&U();let s=f(n,o);return K(s,e),s}function Qt(e,t,r,n={}){if(t===null||t.type!==G){l&&U();let o=f(G,{children:r,...n});return K(o,e),o}return l&&we(),t.props={...t.props,...n,children:r},t.flags|=P,t.sibling=null,t}function er(e,t){if(Re(t)){l&&U();let r=f("#text",{nodeValue:""+t});return K(r,e),r}if(w.isSignal(t)){l&&U();let r=f("#text",{nodeValue:t});return K(r,e),r}if(ue(t)){l&&U();let r=f(t.type,t.props);return K(r,e),r.flags|=T,r}if(Array.isArray(t)){l&&(U(),st(t));let r=Q({children:t});return K(r,e),r}return null}function Te(e,t,r){e.index=r;let n=e.prev;if(n!==null){let o=n.index;return o<t?(e.flags|=T,t):o}else return e.flags|=T,t}function tr(e,t,r,n){if(w.isSignal(n)||Re(n)){let s=e.get(r);if(s){if(s.props.nodeValue===n)return s;s.type==="#text"&&w.isSignal(s.props.nodeValue)&&s.cleanups?.nodeValue?.()}l&&U();let i=f("#text",{nodeValue:n});return K(i,t),i.flags|=T,i.index=r,i}if(ue(n)){let{type:s,props:i}=n,a=i.key,u=e.get(a===void 0?r:a);if(u?.type===s)return l&&we(),typeof s=="string"?rr(u.props,i)&&(u.flags|=P):u.flags|=P,u.props=i,u.sibling=null,u.index=r,u;l&&U();let c=f(n.type,n.props);return K(c,t),c.flags|=T,c.index=r,c}if(Array.isArray(n)){let s=e.get(r);if(l&&st(n),s)return l&&we(),s.flags|=P,s.props.children=n,s;l&&U();let i=Q({children:n});return K(i,t),i.flags|=T,i.index=r,i}return null}function rr(e,t){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!0;for(let o of r)if(!(o==="children"||o==="key")&&e[o]!==t[o])return!0;return!1}function K(e,t){e.parent=t,e.depth=t.depth+1}function we(){"window"in globalThis&&window.__kiru.profilingContext?.emit("updateNode",it)}function U(){"window"in globalThis&&window.__kiru.profilingContext?.emit("createNode",it)}var nr=Symbol("kiru:marked-list-child");function st(e){Object.assign(e,{[nr]:!0})}function or(e){let t=new Map;for(;e;){let r=e.props.key;t.set(r===void 0?e.index:r,e),e=e.sibling}return t}function Ae(e,t){e.deletions===null?e.deletions=[t]:e.deletions.push(t)}function ot(e,t){for(;t;)Ae(e,t),t=t.sibling}function pn(e,t){let r=new Set,n=!1;for(let o of t){if(!ue(o))continue;let s=o.props.key;if(typeof s=="string"){if(!n&&r.has(s)){let i=sr(e);ir(\`\${i} component produced a child in a list with a duplicate key prop: "\${s}". Keys should be unique so that components maintain their identity across updates\`),n=!0}r.add(s)}}}function dn(e,t){let r=!1,n=!1;for(let o of t){if(!ue(o))continue;typeof o.props.key=="string"?r=!0:n=!0}if(n&&r){let o=sr(e);ir(\`\${o} component produced a child in a list without a valid key prop\`)}}function ir(e){let t=\`[kiru]: \${e}. See https://kirujs.dev/keys-warning for more information.\`;console.error(t)}var nt=new WeakMap;function sr(e){if(nt.has(e))return nt.get(e);let t=e.parent,r;for(;!r&&t;)typeof t.type=="function"&&(r=t.type),t=t.parent;let n=\`<\${r?.displayName||r?.name||"Anonymous Function"} />\`;return nt.set(e,n),n}var W,B=[],pe=!1,lt=[],Oe=[],ut=!1,ct=!1,ft=!1,pt=0,ar=[],dt=[],lr=-1;function gt(e){if(pe){lt.push(e);return}e()}function Pe(){pe&&(window.cancelAnimationFrame(lr),ur())}function ht(e){e.flags|=ae,B.push(e),pe=!0,Pe()}function R(e){if(S.current==="hydrate")return gt(()=>mt(e));mt(e)}function mn(){pe||(pe=!0,lr=window.requestAnimationFrame(ur))}function gn(){for(pe=!1;lt.length;)lt.shift()()}function mt(e){if(ut&&(ct=!0),k.current===e){l&&window.__kiru.profilingContext?.emit("updateDirtied",W),ft=!0;return}if(!(e.flags&(ae|fe))){if(e.flags|=ae,!B.length)return B.push(e),mn();B.push(e)}}function hn(e){Z(e,t=>t.flags|=fe),Oe.push(e)}var wn=(e,t)=>t.depth-e.depth,re=null;function ur(){if(l){let t=Oe[0]??B[0];t?(W=J(t),window.__kiru.profilingContext?.beginTick(W)):W=null}let e=1;for(Lt();B.length;){B.length>e&&B.sort(wn),re=B.shift(),e=B.length;let t=re.flags;if(!(t&fe)&&t&ae){let r=re;for(;r=bn(r););for(;Oe.length;)Wt(Oe.pop());Kt(re),re.flags&=~ae}}if(Vt(),ut=!0,at(ar),ut=!1,ct)return En(),at(dt),ct=!1,pt++,l&&(window.__kiru.profilingContext?.endTick(W),window.__kiru.profilingContext?.emit("updateDirtied",W)),Pe();pt=0,gn(),at(dt),l&&(window.__kiru.emit("update",W),window.__kiru.profilingContext?.emit("update",W),window.__kiru.profilingContext?.endTick(W))}function bn(e){let t=!0;try{typeof e.type=="string"?xn(e):wt(e.type)?yn(e):t=vn(e)}catch(n){l&&window.__kiru.emit("error",W,n instanceof Error?n:new Error(String(n)));let o=cr(e);if(o){let s=o.error=n instanceof Error?n:new Error(String(n));return o.props.onError?.(s),o.depth<re.depth&&(re=o),o}if(E.isKiruError(n)){if(n.customNodeStack&&setTimeout(()=>{throw new Error(n.customNodeStack)}),n.fatal)throw n;console.error(n);return}setTimeout(()=>{throw n})}if(e.deletions!==null&&(e.deletions.forEach(hn),e.deletions=null),t&&e.child)return e.child;let r=e;for(;r;){if(r.immediateEffects&&(ar.push(...r.immediateEffects),r.immediateEffects=void 0),r.effects&&(dt.push(...r.effects),r.effects=void 0),r===re)return;if(r.sibling)return r.sibling;r=r.parent,S.current==="hydrate"&&r?.dom&&te.pop()}}function yn(e){let{props:t,type:r}=e,n=t.children;if(r===ie){let{props:{dependents:o,value:s},prev:i}=e;o.size&&i&&i.props.value!==s&&o.forEach(mt)}else if(r===se){let o=e,{error:s}=o;s&&(n=typeof t.fallback=="function"?t.fallback(s):t.fallback,delete o.error)}e.child=Me(e,n)}function vn(e){let{type:t,props:r,subs:n,prev:o,flags:s}=e;if(s&_e){if(e.memoizedProps=r,o?.memoizedProps&&e.arePropsEqual(o.memoizedProps,r)&&!e.hmrUpdated)return e.flags|=me,!1;e.flags&=~me}try{k.current=e;let i,a=0;do{if(e.flags&=~ae,ft=!1,X.current=0,n&&(n.forEach(u=>u()),n.clear()),l){if(i=_(t)(r),e.hmrUpdated&&e.hooks&&e.hookSig){let u=e.hooks.length;if(X.current<u){for(let c=X.current;c<u;c++)e.hooks[c].cleanup?.();e.hooks.length=X.current,e.hookSig.length=X.current}}if(delete e.hmrUpdated,++a>Be)throw new E({message:"Too many re-renders. Kiru limits the number of renders to prevent an infinite loop.",fatal:!0,vNode:e});continue}i=t(r)}while(ft);return e.child=Me(e,i),!0}finally{k.current=null}}function xn(e){let{props:t,type:r}=e;l&&bt(e),e.dom||(S.current==="hydrate"?It(e):e.dom=$t(e),l&&e.dom instanceof Element&&(e.dom.__kiruNode=e)),r!=="#text"&&(e.child=Me(e,t.children),e.child&&S.current==="hydrate"&&te.push(e.dom))}function En(){if(pt>Be)throw new E("Maximum update depth exceeded. This can happen when a component repeatedly calls setState during render or in useLayoutEffect. Kiru limits the number of nested updates to prevent infinite loops.")}function at(e){for(let t=0;t<e.length;t++)e[t]();e.length=0}var fr;(function(e){e.Start="start",e.End="end"})(fr||(fr={}));var de=null,pr=new Set;function d(e,t,r){let n=k.current;if(n||Sn(e),l&&de!==null&&!pr.has(e+de))throw pr.add(e+de),new E({message:\`Nested primitive "useHook" calls are not supported. "\${e}" was called inside "\${de}". Strange will most certainly happen.\`,vNode:n});let o=(a,u)=>{if(u?.immediate){(n.immediateEffects??(n.immediateEffects=[])).push(a);return}(n.effects??(n.effects=[])).push(a)},s=X.current++,i=n.hooks?.at(s);if(l){de=e,n.hooks??(n.hooks=[]),n.hookSig??(n.hookSig=[]),n.hookSig[s]?n.hookSig[s]!==e&&(console.warn(\`[kiru]: hooks must be called in the same order. Hook "\${e}" was called in place of "\${n.hookSig[s]}". Strange things may happen.\`),i?.cleanup?.(),n.hooks.length=s,n.hookSig.length=s,i=void 0):n.hookSig[s]=e;let a;i?a=i:(a=typeof t=="function"?t():{...t},a.name=e),n.hooks[s]=a;try{return r({hook:a,isInit:!i,isHMR:n.hmrUpdated,update:()=>R(n),queueEffect:o,vNode:n,index:s})}catch(u){throw u}finally{de=null}}try{let a=i??(typeof t=="function"?t():{...t});return n.hooks??(n.hooks=[]),n.hooks[s]=a,r({hook:a,isInit:!i,update:()=>R(n),queueEffect:o,vNode:n,index:s})}catch(a){throw a}}function Sn(e){throw new E(\`Hook "\${e}" must be used at the top level of a component or inside another composite hook.\`)}function $(e){e.cleanup&&(e.cleanup(),e.cleanup=void 0)}function A(e,t){return e===void 0||t===void 0||e.length!==t.length||e.length>0&&t.some((r,n)=>!Object.is(r,e[n]))}var be={stack:new Array,current:function(){return this.stack[this.stack.length-1]}},H=new Map,F=new Map;var dr,w=class e{constructor(t,r){this[dr]=!0,this.$id=Le(),this.$value=t,r&&(this.displayName=r),l?(F.set(this.$id,new Set),this.$initialValue=yt(t),this[L]={provide:()=>this,inject:n=>{F.get(this.$id)?.clear?.(),F.delete(this.$id),this.$id=n.$id,n.__next=this,this.$initialValue===n.$initialValue?this.$value=n.$value:this.notify()},destroy:()=>{}}):this.$subs=new Set}get value(){if(this.onBeforeRead?.(),l){let t=_(this);return e.entangle(t),t.$value}return e.entangle(this),this.$value}set value(t){if(l){let r=_(this);if(Object.is(r.$value,t))return;r.$prevValue=r.$value,r.$value=t,r.notify();return}Object.is(this.$value,t)||(this.$prevValue=this.$value,this.$value=t,this.notify())}peek(){return this.onBeforeRead?.(),l?_(this).$value:this.$value}sneak(t){if(l){let r=_(this);r.$prevValue=r.$value,r.$value=t;return}this.$prevValue=this.$value,this.$value=t}toString(){if(this.onBeforeRead?.(),l){let t=_(this);return e.entangle(t),\`\${t.$value}\`}return e.entangle(this),\`\${this.$value}\`}subscribe(t){return l?(F.get(this.$id).add(t),()=>F.get(this.$id)?.delete(t)):(this.$subs.add(t),()=>this.$subs.delete(t))}notify(t){if(l)return F.get(this.$id)?.forEach(r=>{if(t?.filter&&!t.filter(r))return;let{$value:n,$prevValue:o}=_(this);return r(n,o)});this.$subs.forEach(r=>{if(!(t?.filter&&!t.filter(r)))return r(this.$value,this.$prevValue)})}static isSignal(t){return typeof t=="object"&&!!t&&Ue in t}static subscribers(t){return l?F.get(t.$id):t.$subs}static makeReadonly(t){let r=Object.getOwnPropertyDescriptor(t,"value");return r&&!r.writable?t:Object.defineProperty(t,"value",{get:function(){return e.entangle(this),this.$value},configurable:!0})}static makeWritable(t){let r=Object.getOwnPropertyDescriptor(t,"value");return r&&r.writable?t:Object.defineProperty(t,"value",{get:function(){return e.entangle(this),this.$value},set:function(n){this.$value=n,this.notify()},configurable:!0})}static entangle(t){let r=k.current,n=be.current();if(n){(!r||r&&m())&&n.set(t.$id,t);return}if(!r||!m())return;let o=t.subscribe(()=>R(r));(r.subs??(r.subs=new Set)).add(o)}static configure(t,r){t.onBeforeRead=r}static dispose(t){if(t.$isDisposed=!0,l){F.delete(t.$id);return}t.$subs.clear()}};dr=Ue;var De=(e,t)=>new w(e,t),y=(e,t)=>d("useSignal",{signal:null},({hook:r,isInit:n,isHMR:o})=>{if(l&&(n&&(r.dev={devtools:{get:()=>({displayName:r.signal.displayName,value:r.signal.peek()}),set:({value:s})=>{r.signal.value=s}},initialArgs:[e,t]}),o)){let[s,i]=r.dev.initialArgs;(s!==e||i!==t)&&(r.cleanup?.(),n=!0,r.dev.initialArgs=[e,t])}return n&&(r.cleanup=()=>w.dispose(r.signal),r.signal=new w(e,t)),r.signal});function Y(e,t=!1){return w.isSignal(e)?t?e.value:e.peek():e}var vt=()=>{H.forEach(e=>e()),H.clear()};var ge={internalProps:["children","ref","key","innerHTML"],isEvent:e=>e.startsWith("on"),isProperty:e=>!ge.internalProps.includes(e)&&!ge.isEvent(e)};function qt(e){switch(e){case"className":return"class";case"htmlFor":return"for";case"tabIndex":case"formAction":case"formMethod":case"formEncType":case"contentEditable":case"spellCheck":case"allowFullScreen":case"autoPlay":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"noModule":case"noValidate":case"popoverTarget":case"popoverTargetAction":case"playsInline":case"readOnly":case"itemscope":case"rowSpan":case"crossOrigin":return e.toLowerCase();default:return e.indexOf("-")>-1?e:e.startsWith("aria")?"aria-"+e.substring(4).toLowerCase():Mt.get(e)||e}}function yt(e,t={functions:!0}){let r=new WeakSet;return JSON.stringify(e,(n,o)=>{if(typeof o=="object"&&o!==null){if(r.has(o))return"[CIRCULAR]";r.add(o)}return typeof o=="function"?t.functions?o.toString():\`[FUNCTION (\${o.name||"anonymous"})]\`:o})}function _(e){let t=e;if(l)for(;"__next"in t;)t=t.__next;return t}function m(){return S.current==="dom"||S.current==="hydrate"}function ue(e){return typeof e=="object"&&e!==null&&"type"in e}function Re(e){return typeof e=="string"&&e!==""||typeof e=="number"||typeof e=="bigint"}function wt(e){return e===G||e===ie||e===se}function mr(e){return e.type===G}function J(e){let t=e;for(;t;){if(t.app)return e.app=t.app;t=t.parent}return null}function he(e){let{props:{children:t,...r},memoizedProps:n,index:o}=e;e.prev={props:r,memoizedProps:n,index:o},e.flags&=~(P|T|fe)}function gr(e,t){if(t.depth<e.depth)return!1;if(e===t)return!0;let r=!1,n=[e];for(;n.length;){let o=n.pop();if(o===t)return!0;o.child&&n.push(o.child),r&&o.sibling&&n.push(o.sibling),r=!0}return!1}function Z(e,t){t(e);let r=e.child;for(;r;)t(r),r.child&&Z(r,t),r=r.sibling}function Ye(e,t){let r=e.parent;for(;r;){if(t(r))return r;r=r.parent}return null}function cr(e){return Ye(e,t=>t.type===se)}function bt(e){if("children"in e.props&&e.props.innerHTML)throw new E({message:"Cannot use both children and innerHTML on an element",vNode:e});for(let t in e.props)if("bind:"+t in e.props)throw new E({message:\`Cannot use both bind:\${t} and \${t} on an element\`,vNode:e})}function Xt(e){return typeof e=="string"||typeof e=="number"}function Yt(e){return typeof e=="function"||typeof e=="object"&&!!e&&"current"in e||w.isSignal(e)}var kn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz-";function Le(e=10,t=kn){let r="";for(let n=0;n<e;n++)r+=t[Math.random()*t.length|0];return r}var j=Object.freeze(()=>{});function Ve(e){let{id:t,subs:r,fn:n,deps:o=[],onDepChanged:s}=e,i;H.delete(t);let a=!!k.current&&!m();a||(i=new Map,be.stack.push(i));let u=n(...o.map(c=>c.value));if(!a){for(let[p,v]of r)i.has(p)||(v(),r.delete(p));let c=()=>{H.size||queueMicrotask(vt),H.set(t,s)};for(let[p,v]of i){if(r.has(p))continue;let M=v.subscribe(c);r.set(p,M)}be.stack.pop()}return u}var ye=class e extends w{constructor(t,r){if(super(void 0,r),this.$getter=t,this.$unsubs=new Map,this.$isDirty=!0,l){let n=this[L].inject;this[L]={provide:()=>this,inject:o=>{n(o),e.stop(o),this.$isDirty=o.$isDirty},destroy:()=>{}}}w.configure(this,()=>{this.$isDirty&&(l&&this.$isDisposed||e.run(this))})}get value(){return super.value}set value(t){}subscribe(t){return this.$isDirty&&e.run(this),super.subscribe(t)}static dispose(t){e.stop(t),w.dispose(t)}static stop(t){let{$id:r,$unsubs:n}=_(t);H.delete(r),n.forEach(o=>o()),n.clear(),t.$isDirty=!0}static run(t){let r=_(t),{$id:n,$getter:o,$unsubs:s}=r,i=Ve({id:n,subs:s,fn:()=>o(r.$value),onDepChanged:()=>{if(r.$isDirty=!0,l){if(!F?.get(n)?.size)return}else if(!t.$subs.size)return;e.run(r),!Object.is(r.$value,r.$prevValue)&&r.notify()}});r.sneak(i),r.$isDirty=!1}},hr=(e,t)=>new ye(e,t),xt=(e,t)=>d("useComputedSignal",{signal:null},({hook:r,isInit:n,isHMR:o})=>(l&&(r.dev={devtools:{get:()=>({displayName:r.signal.displayName,value:r.signal.peek()})}},o&&(r.cleanup?.(),n=!0)),n&&(r.cleanup=()=>ye.dispose(r.signal),r.signal=hr(e,t)),r.signal));var ve=class e{constructor(t,r){if(this.id=Le(),this.getter=t,this.deps=r,this.unsubs=new Map,this.isRunning=!1,this.cleanup=null,l&&(this[L]={provide:()=>this,inject:n=>{n.isRunning||this.stop()},destroy:()=>{this.stop()}},"window"in globalThis)){let n=window.__kiru.HMRContext.signals;n.isWaitingForNextWatchCall()&&n.pushWatch(this)}this.start()}start(){if(!this.isRunning){if(this.isRunning=!0,l&&"window"in globalThis&&window.__kiru.HMRContext?.isReplacement())return queueMicrotask(()=>{this.isRunning&&e.run(this)});e.run(this)}}stop(){H.delete(this.id),this.unsubs.forEach(t=>t()),this.unsubs.clear(),this.cleanup?.(),this.cleanup=null,this.isRunning=!1}static run(t){let r=_(t),{id:n,getter:o,unsubs:s,deps:i}=r;r.cleanup=Ve({id:n,subs:s,fn:o,deps:i,onDepChanged:()=>{r.cleanup?.(),e.run(r)}})??null}};function wr(e,t){if(typeof e=="function")return new ve(e);let r=e,n=t;return new ve(n,r)}function xe(e,t){if(m())return d("useWatch",{watcher:null},({hook:r,isInit:n,isHMR:o})=>{if(l&&o&&(r.cleanup?.(),n=!0),n){let s=r.watcher=wr(e,t);r.cleanup=()=>s.stop()}return r.watcher})}var _n=0;function br(e,t,r){if(l&&t.__kiruNode)throw new Error("[kiru]: container in use - call unmount on the previous app first.");let n=f(t.nodeName.toLowerCase(),{});l&&(t.__kiruNode=n),n.dom=t,n.flags|=V;let o=_n++,s=r?.name??\`App-\${o}\`,i={id:o,name:s,rootNode:n,render:a,unmount:u};function a(c){n.props.children=c,ht(n)}function u(){n.props.children=null,ht(n),l&&(delete t.__kiruNode,delete n.app),window.__kiru.emit("unmount",i)}return l&&(n.app=i),a(e),window.__kiru.emit("mount",i),l&&queueMicrotask(()=>{window.dispatchEvent(new Event("kiru:ready"))}),i}function ce(e){return m()?d("useState",{state:void 0,dispatch:j},({hook:t,isInit:r,update:n,isHMR:o})=>{if(l&&(r&&(t.dev={devtools:{get:()=>({value:t.state}),set:({value:s})=>t.state=s},initialArgs:[e]}),o)){let[s]=t.dev.initialArgs;s!==e&&(r=!0,t.dev.initialArgs=[e])}return r&&(t.state=typeof e=="function"?e():e,t.dispatch=s=>{let i=typeof s=="function"?s(t.state):s;Object.is(t.state,i)||(t.state=i,n())}),[t.state,t.dispatch]}):[typeof e=="function"?e():e,j]}function yr(e){let t={[Ct]:!0,Provider:({value:r,children:n})=>{let[o]=ce(()=>new Set);return f(ie,{value:r,ctx:t,dependents:o},typeof n=="function"?n(r):n)},default:()=>e,set displayName(r){this.Provider.displayName=r},get displayName(){return this.Provider.displayName||"Anonymous Context"}};if(l){let r=t;r[L]={inject:n=>{let o=t.Provider;window.__kiru.apps.forEach(s=>{Z(s.rootNode,i=>{i.type===n.Provider&&(i.type=o,i.hmrUpdated=!0,R(i))})})},destroy:()=>{},provide:()=>t}}return t}function ee(e,t){return m()?d("useCallback",{callback:e,deps:t},({hook:r,isHMR:n})=>(l&&(r.dev={devtools:{get:()=>({callback:r.callback,dependencies:r.deps})}},n&&(r.deps=[])),A(t,r.deps)&&(r.deps=t,r.callback=e),r.callback)):e}function N(e,t){if(m())return d("useEffect",{deps:t},({hook:r,isInit:n,isHMR:o,queueEffect:s})=>{l&&(r.dev={devtools:{get:()=>({callback:e,dependencies:r.deps})}},o&&(n=!0)),(n||A(t,r.deps))&&(r.deps=t,$(r),s(()=>{let i=e();typeof i=="function"&&(r.cleanup=i)}))})}function ne(e,t){if(m())return d("useLayoutEffect",{deps:t},({hook:r,isInit:n,isHMR:o,queueEffect:s})=>{l&&(r.dev={devtools:{get:()=>({callback:e,dependencies:r.deps})}},o&&(n=!0)),(n||A(t,r.deps))&&(r.deps=t,$(r),s(()=>{let i=e();typeof i=="function"&&(r.cleanup=i)},{immediate:!0}))})}function Ee(e,t){return m()?d("useMemo",{deps:t,value:void 0},({hook:r,isInit:n,isHMR:o})=>(l&&(r.dev={devtools:{get:()=>({value:r.value,dependencies:r.deps})}},o&&(n=!0)),(n||A(t,r.deps))&&(r.deps=t,r.value=e()),r.value)):e()}function I(e){return m()?d("useRef",{ref:{current:e}},({hook:t,isInit:r,isHMR:n})=>{if(l&&(r&&(t.dev={devtools:{get:()=>({value:t.ref.current}),set:({value:o})=>t.ref.current=o},initialArgs:[t.ref.current]}),n)){let[o]=t.dev.initialArgs;o!==e&&(t.ref={current:e},t.dev.initialArgs=[e])}return t.ref}):{current:e}}var ja="window"in globalThis?window.__KIRU_LAZY_CACHE??(window.__KIRU_LAZY_CACHE=new Map):new Map;function Er(e){let[t,r]=ce(e.initialState||"exited"),n=I(null);ne(()=>{e.in&&t!=="entered"&&t!=="entering"?(o("entering"),s("entered")):!e.in&&t!=="exited"&&t!=="exiting"&&(o("exiting"),s("exited"))},[e.in,t]),N(()=>()=>xr(n.current),[]);let o=ee(i=>{xr(n.current),r(i),(i==="entered"||i==="exited")&&e.onTransitionEnd&&e.onTransitionEnd(i)},[]),s=ee(i=>{n.current=window.setTimeout(()=>o(i),Tn(i,e.duration))},[e.duration]);return e.element(t)}var vr=150;function Tn(e,t){if(typeof t=="number")return t;switch(e){case"entered":return t?.in??vr;case"exited":return t?.out??vr}}function xr(e){e!=null&&window.clearTimeout(e)}"window"in globalThis;var Sr=()=>f("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},f("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"}));var $e="kiru.devtools.anchorPosition",kr={x:-16,y:-16};var Et=(e,t,r)=>{if(!t.current)return{...kr};let n=window.innerWidth/e.width,o=window.innerHeight/e.height,s=null,i=null;return e.snapSide==="left"?s=(t.current.offsetWidth-r.width.value)*-1+16:e.snapSide==="right"?s=-16:e.snapSide==="bottom"?i=-16:e.snapSide==="top"&&(i=(window.innerHeight-r.height.value)*-1+16),{x:s??e.x*n,y:i??e.y*o}},_r=e=>{if(e==null)return null;let t=null,r=e?.__kiruNode?.parent;for(;r;){if(typeof r.type=="function"&&!mr(r)){t=r;break}r=r.parent}return t},Cr=(e,t)=>{let r=[],n=[t.__kiruNode];for(;n.length;){let s=n.pop();if(s===e)break;s?.dom&&r.push(s),s?.parent&&n.push(s.parent)}if(r.length===0)return;let o=r[r.length-1].dom;return o instanceof Element?o:void 0};var Ar={arrayChunkSize:10,objectKeysChunkSize:100};function Mr(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;let r=new Set([...Object.keys(e),...Object.keys(t)]);for(let n in r)if(typeof t[n]!=typeof e[n]||typeof e[n]=="object"&&!Mr(e[n],t[n]))return!1;return!0}var Rn={...Ar},Tr=localStorage.getItem("kiru.devtools.userSettings");if(Tr)try{let e=JSON.parse(Tr);Mr(Ar,e)&&(Rn=e)}catch(e){console.error("kiru.devtools.userSettings error",e)}var Ou=yr({userSettings:null,saveUserSettings:()=>{}});var Fu=Object.freeze(()=>{});var Ln="kiru-devtools";"window"in globalThis&&(window.__devtoolsSelection??(window.__devtoolsSelection=null));var St=class extends BroadcastChannel{send(t){super.postMessage(t)}removeEventListener(t){return super.removeEventListener("message",t)}addEventListener(t){return super.addEventListener("message",t)}},O=new St(Ln);var ac=Symbol.for("devtools.hookGroup");var D=(e,t,r={})=>{N(()=>{let n=window,o=r?.ref?.();return o?n=o:r.ref&&console.warn("useEventListener ref failed, using window"),n.addEventListener(e,t,r),()=>{n.removeEventListener(e,t,r)}},[t])};var He=()=>{let e=y({x:0,y:0}),t=y({x:0,y:0}),r=y({x:0,y:0});return D("mousemove",n=>{e.value={x:n.x,y:n.y},t.value={x:n.movementX,y:n.movementY},r.value={x:n.clientX,y:n.clientY}}),{mouse:e,delta:t,client:r}};var Fe="window"in globalThis&&"ResizeObserver"in globalThis.window,Rr=(e,t,r=void 0)=>m()?Fe?d("useResizeObserver",{resizeObserver:null,deps:[e.current]},({isInit:n,hook:o,queueEffect:s})=>(n&&(o.resizeObserver=new ResizeObserver(t),o.cleanup=()=>{o.resizeObserver?.disconnect?.(),o.resizeObserver=null}),s(()=>{A([e.current],o.deps)&&(o.deps=[e.current],o.resizeObserver?.disconnect?.(),e.current&&o.resizeObserver?.observe(e.current,r))}),{isSupported:Fe,start:()=>{o.resizeObserver==null&&(o.resizeObserver=new ResizeObserver(t),e.current&&o.resizeObserver.observe(e.current,r),o.cleanup=()=>{o.resizeObserver?.disconnect?.(),o.resizeObserver=null})},stop:()=>{$(o)}})):{isSupported:Fe,start:()=>{},stop:()=>{}}:{isSupported:Fe,start:()=>{},stop:()=>{}};var Ne="window"in globalThis&&"MutationObserver"in globalThis.window,Or=(e,t,r=void 0)=>m()?Ne?d("useMutationObserver",{mutationObserver:null,deps:[e.current]},({isInit:n,hook:o,queueEffect:s})=>(n?(s(()=>{o.deps=[e.current],o.mutationObserver=new MutationObserver(t),e.current&&o.mutationObserver.observe(e.current,r)}),o.cleanup=()=>{o.mutationObserver?.disconnect?.(),o.mutationObserver=null}):A([e.current],o.deps)&&(o.deps=[e.current],o.mutationObserver?.disconnect?.(),e.current&&o.mutationObserver?.observe(e.current,r)),{isSupported:Ne,start:()=>{o.mutationObserver==null&&(o.mutationObserver=new MutationObserver(t),e.current&&o.mutationObserver.observe(e.current,r),o.cleanup=()=>{o.mutationObserver?.disconnect?.(),o.mutationObserver=null})},stop:()=>{$(o)}})):{isSupported:Ne,start:()=>{},stop:()=>{}}:{isSupported:Ne,start:()=>{},stop:()=>{}};var Ie=(e,t={windowScroll:!0,windowResize:!0})=>{let r=t?.windowScroll??!0,n=t?.windowResize??!0,o=t.immediate??!0,s=y(0),i=y(0),a=y(0),u=y(0),c=y(0),p=y(0),v=y(0),M=y(0),h=()=>{let x=e.current;if(!x){s.value=0,i.value=0,a.value=0,u.value=0,c.value=0,p.value=0,v.value=0,M.value=0;return}let b=x.getBoundingClientRect();s.value=b.width,i.value=b.height,a.value=b.top,u.value=b.right,c.value=b.bottom,p.value=b.left,v.value=b.x,M.value=b.y};return Rr(e,h),Or(e,h,{attributeFilter:["style","class"]}),D("scroll",()=>{r&&h()},{capture:!0,passive:!0}),D("resize",()=>{n&&h()},{passive:!0}),ne(()=>{o&&h()},[]),{width:s,height:i,top:a,right:u,bottom:c,left:p,x:v,y:M,update:h}};var Pr=(e,t)=>{if(!m())return{isActive:t?.immediate??!1,start:()=>null,stop:()=>null};let r=t?.fpsLimit?1e3/t.fpsLimit:null;return d("useRafFn",()=>({callback:e,refId:null,previousFrameTimestamp:0,isActive:t?.immediate??!1,rafLoop:()=>{}}),({isInit:n,hook:o,update:s})=>(o.callback=e,n&&(o.rafLoop=i=>{if(o.isActive===!1)return;o.previousFrameTimestamp||(o.previousFrameTimestamp=i);let a=i-o.previousFrameTimestamp;if(r&&a<r){o.refId=window.requestAnimationFrame(o.rafLoop);return}o.previousFrameTimestamp=i,o.callback({delta:a,timestamp:i}),o.refId=window.requestAnimationFrame(o.rafLoop)}),n&&t?.immediate&&(o.isActive=!0,o.refId=window.requestAnimationFrame(o.rafLoop),o.cleanup=()=>{o.refId!=null&&window.cancelAnimationFrame(o.refId),o.isActive=!1},s()),{isActive:o.isActive,start:()=>{o.isActive!==!0&&(o.isActive=!0,o.refId=window.requestAnimationFrame(o.rafLoop),o.cleanup=()=>{o.refId!=null&&window.cancelAnimationFrame(o.refId),o.isActive=!1},s())},stop:()=>{$(o),s()}}))};var Dr=e=>{let{x:t,y:r,multiple:n,immediate:o=!0}=e,s=y(null),a=Pr(()=>{s.value=n?document.elementsFromPoint(t,r)??[]:document.elementFromPoint(t,r)??null},{immediate:o});return{element:s,...a}};var Lr=()=>{let{mouse:e}=He(),t=y(null),r=I(null),n=I(null),o=Ie(r),s=y({x:-16,y:-16}),i=y({x:-16,y:-16}),a=y({width:window.innerWidth,height:window.innerHeight}),u=y("bottom"),c=I(null);ne(()=>{let h=localStorage.getItem($e);if(h==null)return;let x=JSON.parse(h);a.value.width=window.innerWidth,a.value.height=window.innerHeight,u.value=x.snapSide,i.value=Et(x,n,o)},[Math.round(o.width.value),Math.round(o.height.value)]);let p=xt(()=>{let{x:h,y:x}=e.value;if(t.value===null)return null;let{x:b,y:C}=t.value;return{x:h-b,y:x-C}});D("dragstart",h=>{h.preventDefault(),t.value={x:h.x,y:h.y},s.value=i.value},{ref:()=>r.current}),D("mouseup",()=>{c.current&&(clearTimeout(c.current),c.current=null),t.peek()&&(t.value=null,localStorage.setItem($e,JSON.stringify({...i.value,...a.value,snapSide:u.value})))});let v=ee(()=>{if(n.current==null)return;let h=n.current.offsetWidth;if(u.value==="right"){let x=Math.min(-16,i.value.y);i.value={x:-16,y:Math.max(x,(window.innerHeight-o.height.value)*-1+16)}}else if(u.value==="left"){let x=Math.min(0,i.value.y);i.value={x:(h-o.width.value)*-1+16,y:Math.max(x,(window.innerHeight-o.height.value)*-1+16)}}else if(u.value==="top"){let x=Math.min(-16,i.value.x);i.value={x:Math.max(x,(h-o.width.value)*-1+16),y:(window.innerHeight-o.height.value)*-1+16};return}else{let x=Math.min(-16,i.value.x);i.value={x:Math.max(x,(h-o.width.value)*-1+16),y:-16}}},[]);xe([p,e],(h,x)=>{if(h===null||!n.current)return;let{x:b,y:C}=x,je=n.current.offsetWidth,Ir=C>=window.innerHeight-100,_t=C<=100;if(!_t&&!Ir){let oe=b>window.innerWidth/2;u.value=oe?"right":"left"}else u.value=_t?"top":"bottom";if(u.value==="right"){let oe=Math.min(-16,s.value.y+h.y);i.value={x:-16,y:Math.max(oe,(window.innerHeight-o.height.value)*-1+16)};return}else if(u.value==="left"){let oe=Math.min(0,s.value.y+h.y);i.value={x:(je-o.width.value)*-1+16,y:Math.max(oe,(window.innerHeight-o.height.value)*-1+16)};return}else if(u.value==="top"){let oe=Math.min(-16,s.value.x+h.x);i.value={x:Math.max(oe,(je-o.width.value)*-1+16),y:(window.innerHeight-o.height.value)*-1+16};return}let zr=Math.min(-16,s.value.x+h.x);i.value={y:-16,x:Math.max(zr,(je-o.width.value)*-1+16)}});let M=ee(()=>{n.current!==null&&(i.value=Et({width:a.value.width,height:a.value.height,x:i.value.x,y:i.value.y,snapSide:u.value},n,o),a.value.width=window.innerWidth,a.value.height=window.innerHeight,localStorage.setItem($e,JSON.stringify({...i.value,...a.value,snapSide:u.value})))},[Math.round(o.width.value),Math.round(o.height.value)]);return D("resize",M),{anchorRef:r,anchorCoords:i,viewPortRef:n,startMouse:t,elementBound:o,snapSide:u,updateAnchorPos:v}};var z=De(!1);"window"in globalThis&&O.addEventListener(e=>{e.data.type==="set-inspect-enabled"&&(z.value=e.data.value)});var q=De(null);var Vr="kiru-devtools-popup-size",ze=()=>{let e=q.value;return ee(()=>new Promise((r,n)=>{if(e)if(e.closed)q.value=null;else return e.focus(),r(e);let o=sessionStorage.getItem(Vr),s=o?JSON.parse(o):{width:Math.floor(Math.min(1920,window.screen.width)/2),height:Math.floor(Math.min(1080,window.screen.height)/2)},i=\`popup,width=\${s.width},height=\${s.height};\`,a=window.open(window.__KIRU_DEVTOOLS_PATHNAME__,"_blank",i);if(!a)return console.error("[kiru]: Unable to open devtools window"),n();let u=c=>{c.data.type==="ready"&&(O.removeEventListener(u),console.debug("[kiru]: devtools window opened"),r(a),q.value=a,a.onbeforeunload=()=>{console.debug("[kiru]: devtools window closed"),q.value=null})};O.addEventListener(u),a.onresize=()=>{sessionStorage.setItem(Vr,JSON.stringify({width:a.innerWidth,height:a.innerHeight}))}}),[e])};var $r=()=>{let e=ze(),{mouse:t}=He(),r=Dr({x:t.value.x,y:t.value.y,immediate:!1}),n=r.element.value,o=z.value?n:null,s=Ee(()=>{if(o&&window.__kiru){let c=window.__kiru.apps.find(p=>p.rootNode==null||o.__kiruNode==null?!1:gr(p.rootNode,o.__kiruNode));return c?.rootNode==null?null:c}return null},[o]),i=Ee(()=>o?_r(o):null,[o]),a=I(null),u=Ie(a);return N(()=>z.subscribe(p=>{r[p?"start":"stop"]()}),[]),N(()=>{i&&o?a.current=Cr(i,o)??null:a.current=null},[i,o]),D("click",c=>{if(z.value===!0&&i&&s){c.preventDefault();let p=v=>{v.__devtoolsSelection={node:i,app:s},O.send({type:"select-node"}),O.send({type:"set-inspect-enabled",value:!1}),z.value=!1,a.current=null,v.focus()};q.value?p(q.value):e().then(v=>p(v))}}),i&&f("div",{className:"bg-[crimson]/80 fixed grid place-content-center pointer-events-none z-10 top-0 left-0",style:{width:\`\${u?.width}px\`,height:\`\${u?.height}px\`,transform:\`translate(\${u.x}px, \${u.y}px)\`}},f("p",null,i.type.name))};function Hr(e){return f("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 -960 960 960",fill:"currentColor",...e},f("path",{d:"M710-150q-63 0-106.5-43.5T560-300q0-63 43.5-106.5T710-450q63 0 106.5 43.5T860-300q0 63-43.5 106.5T710-150Zm0-80q29 0 49.5-20.5T780-300q0-29-20.5-49.5T710-370q-29 0-49.5 20.5T640-300q0 29 20.5 49.5T710-230Zm-270-30H200q-17 0-28.5-11.5T160-300q0-17 11.5-28.5T200-340h240q17 0 28.5 11.5T480-300q0 17-11.5 28.5T440-260ZM250-510q-63 0-106.5-43.5T100-660q0-63 43.5-106.5T250-810q63 0 106.5 43.5T400-660q0 63-43.5 106.5T250-510Zm0-80q29 0 49.5-20.5T320-660q0-29-20.5-49.5T250-730q-29 0-49.5 20.5T180-660q0 29 20.5 49.5T250-590Zm510-30H520q-17 0-28.5-11.5T480-660q0-17 11.5-28.5T520-700h240q17 0 28.5 11.5T800-660q0 17-11.5 28.5T760-620Zm-50 320ZM250-660Z"}))}function Fr(e){return f("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-square-mouse-pointer",...e},f("path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"}),f("path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"}))}var Vn=()=>{z.value=!z.value,O.send({type:"set-inspect-enabled",value:z.value})};function $n(e,t){let{damping:r}=t,n=y(e),o=I(e);return N(()=>{let s=null,i=()=>{if(Math.sqrt(Math.pow(o.current.x-n.value.x,2)+Math.pow(o.current.y-n.value.y,2))<5)return;let u=n.value.x+(o.current.x-n.value.x)*r,c=n.value.y+(o.current.y-n.value.y)*r;n.value={x:u,y:c},s=window.requestAnimationFrame(i)};return s=window.requestAnimationFrame(i),()=>{s!=null&&window.cancelAnimationFrame(s)}},[e.x,e.y]),Object.assign(n,{set:(s,i)=>{o.current=s,i?.hard&&(n.value=s)}})}function kt(){let e=y(!1),t=ze(),{anchorCoords:r,anchorRef:n,viewPortRef:o,startMouse:s,snapSide:i}=Lr(),a=i.value==="left"||i.value==="right",u=I(!1),c=$n(r.value,{damping:.4});return xe([r],c.set),ne(()=>{u.current===!1&&c.set(r.value,{hard:!0}),u.current=!0},[]),f(Q,null,f("div",{ref:o,className:"w-full h-0 fixed top-0 left-0 z-[-9999] overflow-scroll pointer-events-none"}),f("div",{ref:n,draggable:!0,className:\`flex \${a?"flex-col":""} \${e.value?"rounded-3xl":"rounded-full"} p-1 gap-1 items-center will-change-transform bg-crimson\`,style:{transform:\`translate3d(\${Math.round(c.value.x)}px, \${Math.round(c.value.y)}px, 0)\`}},f(Er,{in:e.value,duration:{in:40,out:150},element:p=>{if(p==="exited")return null;let v=p==="entered"?"1":"0.5",M=p==="entered"?"1":"0";return f(Q,null,f("button",{title:"Open Devtools",onclick:t,style:{transform:\`scale(\${v})\`,opacity:M},className:"transition text-white rounded-full p-1 hover:bg-[#0003]"},f(Hr,{width:16,height:16})),f("button",{title:"Toggle Component Inspection",onclick:Vn,style:{transform:\`scale(\${v})\`,opacity:M},className:\`transition text-white rounded-full p-1 hover:bg-[#0003] \${z.value?"bg-[#0003]":""}\`},f(Fr,{width:16,height:16})))}}),f("button",{className:"bg-crimson rounded-full p-1"+(s.value?" pointer-events-none":""),onclick:()=>e.value=!e.value,tabIndex:-1},f(Sr,null))),f($r,null))}var Nr=\`*, ::before, ::after {
|
|
2440
|
+
\`}function Kr(e){let t=Ot(e);if(l){let r=Ur(e);r&&(t=\`\${t} (\${r})\`)}return t}function Ot(e){return e.displayName??(e.name||"Anonymous Function")}function Ur(e){return e.toString().match(/\\/\\/ \\[kiru_devtools\\]:(.*)/)?.[1]??null}var te={parentStack:[],childIdxStack:[],eventDeferrals:new Map,parent:function(){return this.parentStack[this.parentStack.length-1]},clear:function(){this.parentStack.length=0,this.childIdxStack.length=0},pop:function(){this.parentStack.pop(),this.childIdxStack.pop()},push:function(e){this.parentStack.push(e),this.childIdxStack.push(0)},currentChild:function(){return this.parentStack[this.parentStack.length-1].childNodes[this.childIdxStack[this.childIdxStack.length-1]]},nextChild:function(){return this.parentStack[this.parentStack.length-1].childNodes[this.childIdxStack[this.childIdxStack.length-1]++]},bumpChildIndex:function(){this.childIdxStack[this.childIdxStack.length-1]++},captureEvents:function(e){Pt(e,!0),this.eventDeferrals.set(e,[])},resetEvents:function(e){this.eventDeferrals.delete(e)},releaseEvents:function(e){Pt(e,!1);let t=this.eventDeferrals.get(e);for(;t?.length;)t.shift()()}},Wr=e=>{let t=e.target;!e.isTrusted||!t||te.eventDeferrals.get(t)?.push(()=>t.dispatchEvent(e))},Pt=(e,t)=>{for(let r in e)if(r.startsWith("on")){let n=r.substring(2);e[t?"addEventListener":"removeEventListener"](n,Wr,{passive:!0})}};var rt=!1,Je=!1,Dt=e=>{e.preventDefault(),e.stopPropagation(),Je=!0},le=null;function Lt(){rt=!0,le=document.activeElement,le&&le!==document.body&&le.addEventListener("blur",Dt)}function Vt(){Je&&(le.removeEventListener("blur",Dt),le.isConnected&&le.focus(),Je=!1),rt=!1}function Ze(e,t){if(typeof e=="function"){e(t);return}if(w.isSignal(e)){e.sneak(t),e.notify({filter:r=>typeof r=="function"});return}e.current=t}function $t(e){let t=e.type;return t=="#text"?Ht(e):qe.has(t)?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t)}function Ht(e){let{nodeValue:t}=e.props;if(!w.isSignal(t))return document.createTextNode(t);let r=t.peek()??"",n=document.createTextNode(r);return et(e,n,t),n}function Br(e,t,r){let n=Qe.get(e)??{},o=n[t]=s=>{if(rt){s.preventDefault(),s.stopPropagation();return}r(s)};return Qe.set(e,n),o}var Qe=new WeakMap;function Ft(e){let t=e.dom,r=e.prev?.props??{},n=e.props??{},o=new Set([...Object.keys(r),...Object.keys(n)]),s=S.current==="hydrate";o.forEach(i=>{let a=r[i],u=n[i];if(ge.internalProps.includes(i)&&i!=="innerHTML"){i==="ref"&&a!==u&&(a&&Ze(a,null),u&&Ze(u,t));return}if(ge.isEvent(i)){if(a!==u||S.current==="hydrate"){let c=i.replace(At,""),p=c==="focus"||c==="blur";i in r&&t.removeEventListener(c,p?Qe.get(e)?.[c]:a),i in n&&t.addEventListener(c,p?Br(e,c,u):u)}return}if(!(t instanceof Text)){if(a===u||s&&t.getAttribute(i)===u)return;if(w.isSignal(a)&&e.cleanups){let c=e.cleanups[i];c&&(c(),delete e.cleanups[i])}if(w.isSignal(u))return Yr(e,t,i,u,a);Ce(t,i,u,a);return}w.isSignal(u)||t.nodeValue!==u&&(t.nodeValue=u)})}function qr(e){return e.multiple?Array.from(e.selectedOptions).map(t=>t.value):e.value}function Nt(e,t){if(!e.multiple||t===void 0||t===null||t===""){e.value=t;return}Array.from(e.options).forEach(r=>{r.selected=t.indexOf(r.value)>-1})}var Gr={value:"input",checked:"change",open:"toggle",volume:"volumechange",playbackRate:"ratechange",currentTime:"timeupdate"},Xr=["progress","meter","number","range"];function Yr(e,t,r,n,o){let s=e.cleanups??(e.cleanups={}),[i,a]=r.split(":");if(i!=="bind")return s[r]=n.subscribe((b,C)=>{Ce(t,r,b,C),l&&window.__kiru.profilingContext?.emit("signalAttrUpdate",J(e))}),Ce(t,r,n.peek(),Y(o));let u=Gr[a];if(!u){l&&console.error(\`[kiru]: \${a} is not a valid element binding attribute.\`);return}let c=t instanceof HTMLSelectElement,p=c?b=>Nt(t,b):b=>t[a]=b,v=b=>{p(b),l&&window.__kiru.profilingContext?.emit("signalAttrUpdate",J(e))},M=b=>{n.sneak(b),n.notify({filter:C=>C!==v})},h;if(a==="value"){let b=Xr.indexOf(t.type)!==-1;h=()=>{let C=t.value;c?C=qr(t):typeof n.peek()=="number"&&b&&(C=t.valueAsNumber),M(C)}}else h=b=>{let C=b.target[a];a==="currentTime"&&n.peek()===C||M(C)};t.addEventListener(u,h);let x=n.subscribe(v);return s[r]=()=>{t.removeEventListener(u,h),x()},Ce(t,a,n.peek(),Y(o))}function et(e,t,r){(e.cleanups??(e.cleanups={})).nodeValue=r.subscribe((n,o)=>{n!==o&&(t.nodeValue=n,l&&window.__kiru.profilingContext?.emit("signalTextUpdate",J(e)))})}function Jr(e){if(e.type!=="#text"||!w.isSignal(e.props.nodeValue))return;let t=Y(e.props.nodeValue);if(!Xe(t)){l&&console.error(\`[kiru]: Hydration mismatch - expected primitive child but received \${t}\`);return}let r=Ht(e),n=te.parent();return n&&n.appendChild(r),r}function It(e){let t=te.nextChild()??Jr(e);if(!t)throw new E({message:"Hydration mismatch - no node found",vNode:e});let r=t.nodeName;if(qe.has(r)||(r=r.toLowerCase()),e.type!==r)throw new E({message:\`Hydration mismatch - expected node of type \${e.type.toString()} but received \${r}\`,vNode:e});if(e.dom=t,e.type!=="#text"&&!(e.flags&V)){Ft(e);return}w.isSignal(e.props.nodeValue)&&et(e,t,e.props.nodeValue);let n=e,o=e.sibling;for(;o&&o.type==="#text";){let s=o;te.bumpChildIndex();let i=String(Y(n.props.nodeValue)??""),a=n.dom.splitText(i.length);s.dom=a,w.isSignal(s.props.nodeValue)&&et(s,a,s.props.nodeValue),n=o,o=o.sibling}}function zt(e,t,r,n=!1){if(r===null)return e.removeAttribute(t),!0;switch(typeof r){case"undefined":case"function":case"symbol":return e.removeAttribute(t),!0;case"boolean":if(n&&!r)return e.removeAttribute(t),!0}return!1}function Zr(e,t,r){let n=Ge.has(t);zt(e,t,r,n)||e.setAttribute(t,n&&typeof r=="boolean"?"":String(r))}var Qr=["INPUT","TEXTAREA"],en=e=>Qr.indexOf(e.nodeName)>-1;function Ce(e,t,r,n){if(r!==n)switch(t){case"style":return nn(e,r,n);case"className":return rn(e,r);case"innerHTML":return tn(e,r);case"muted":e.muted=!!r;return;case"value":if(e.nodeName==="SELECT")return Nt(e,r);let o=r==null?"":String(r);if(en(e)){e.value=o;return}e.setAttribute("value",o);return;case"checked":if(e.nodeName==="INPUT"){e.checked=!!r;return}e.setAttribute("checked",String(r));return;default:return Zr(e,qt(t),r)}}function tn(e,t){if(t==null||typeof t=="boolean"){e.innerHTML="";return}e.innerHTML=String(t)}function rn(e,t){let r=Y(t);if(!r)return e.removeAttribute("class");e.setAttribute("class",r)}function nn(e,t,r){if(zt(e,"style",t))return;if(typeof t=="string"){e.setAttribute("style",t);return}let n={};typeof r=="string"?e.setAttribute("style",""):typeof r=="object"&&r&&(n=r);let o=t;new Set([...Object.keys(n),...Object.keys(o)]).forEach(i=>{let a=n[i],u=o[i];if(a!==u){if(u===void 0){e.style[i]="";return}e.style[i]=u}})}function on(e){let t=e.parent,r=t?.dom;for(;t&&!r;)t=t.parent,r=t?.dom;if(!r||!t){if(!e.parent&&e.dom)return e;throw new E({message:"No DOM parent found while attempting to place node.",vNode:e})}return t}function sn(e,t){let{node:r,lastChild:n}=t,o=e.dom;if(n){n.after(o);return}let s=jt(e,r);if(s){r.dom.insertBefore(o,s);return}r.dom.appendChild(o)}function jt(e,t){let r=e;for(;r;){let n=r.sibling;for(;n;){if(!(n.flags&(T|V))){let o=an(n);if(o?.isConnected)return o}n=n.sibling}if(r=r.parent,!r||r.flags&V||r===t)return}}function an(e){let t=e;for(;t;){if(t.dom)return t.dom;if(t.flags&V)return;t=t.child}}function Kt(e){if(S.current==="hydrate")return Z(e,he);let t={node:e.dom?e:on(e)};tt(e,t,(e.flags&T)>0),e.dom&&!(e.flags&V)&&Ut(e,t,!1),he(e)}function tt(e,t,r){let n=e.child;for(;n;){if(n.flags&me){n.flags&T&&ln(n,t),he(n),n=n.sibling;continue}n.dom?(tt(n,{node:n},!1),n.flags&V||Ut(n,t,r)):tt(n,t,(n.flags&T)>0||r),he(n),n=n.sibling}}function Ut(e,t,r){(r||!e.dom.isConnected||e.flags&T)&&sn(e,t),(!e.prev||e.flags&P)&&Ft(e),t.lastChild=e.dom}function Wt(e){e===e.parent?.child&&(e.parent.child=e.sibling);let t;l&&(t=J(e)),Z(e,r=>{let{hooks:n,subs:o,cleanups:s,dom:i,props:{ref:a}}=r;for(o?.forEach(u=>u()),s&&Object.values(s).forEach(u=>u());n?.length;)n.pop().cleanup?.();l&&(window.__kiru.profilingContext?.emit("removeNode",t),i instanceof Element&&delete i.__kiruNode),i&&(a&&Ze(a,null),i.isConnected&&!(r.flags&V)&&i.remove(),delete r.dom)}),e.parent=null}function ln(e,t){if(!e.child)return;let r=[];if(Bt(e.child,r),r.length===0)return;let{node:n,lastChild:o}=t;if(o)o.after(...r);else{let s=jt(e,n),i=n.dom;s?s.before(...r):i.append(...r)}t.lastChild=r[r.length-1]}function Bt(e,t){let r=e;for(;r;)r.dom?t.push(r.dom):r.child&&Bt(r.child,t),r=r.sibling}function Gt(e){return typeof e=="function"&&typeof e[ke]?.arePropsEqual=="function"}function f(e,t=null,...r){if(e===Q)return Q({children:r,...t});let n={type:e,flags:0,index:0,depth:0,props:{},parent:null,sibling:null,child:null,prev:null,deletions:null};if(Gt(e)&&(n.flags|=_e,n.arePropsEqual=e[ke].arePropsEqual),t!==null){let{key:s,ref:i,...a}=t;Xt(s)&&(n.props.key=s.toString()),Yt(i)&&(n.props.ref=i),Object.assign(n.props,a)}let o=r.length===1?r[0]:r.length>1?r:null;return o!==null&&(n.props.children=o),n}function Q({children:e,key:t}){return f(G,t?{key:t}:null,e)}var it;function Me(e,t){return l&&(it=J(e)),Array.isArray(t)?(l&&(nr in t&&dn(e,t),pn(e,t)),cn(e,t)):un(e,t)}function un(e,t){let r=e.child;if(r===null)return er(e,t);let n=r.sibling,o=Zt(e,r,t);if(o!==null)return r&&r!==o&&!o.prev?ot(e,r):n&&ot(e,n),o;{let s=or(r),i=tr(s,e,0,t);if(i!==null){let a=i.prev;if(a!==null){let u=a.props.key;s.delete(u===void 0?a.index:u)}Te(i,0,0)}return s.forEach(a=>Ae(e,a)),i}}function cn(e,t){let r=null,n=null,o=e.child,s=null,i=0,a=0;for(;o!==null&&a<t.length;a++){o.index>a?(s=o,o=null):s=o.sibling;let c=Zt(e,o,t[a]);if(c===null){o===null&&(o=s);break}o&&!c.prev&&Ae(e,o),i=Te(c,i,a),n===null?r=c:n.sibling=c,n=c,o=s}if(a===t.length)return ot(e,o),r;if(o===null){for(;a<t.length;a++){let c=er(e,t[a]);c!==null&&(i=Te(c,i,a),n===null?r=c:n.sibling=c,n=c)}return r}let u=or(o);for(;a<t.length;a++){let c=tr(u,e,a,t[a]);if(c!==null){let p=c.prev;if(p!==null){let v=p.props.key;u.delete(v===void 0?p.index:v)}i=Te(c,i,a),n===null?r=c:n.sibling=c,n=c}}return u.forEach(c=>Ae(e,c)),r}function Zt(e,t,r){let n=t?.props.key;return Re(r)?n!==void 0||t?.type==="#text"&&w.isSignal(t.props.nodeValue)?null:Jt(e,t,""+r):w.isSignal(r)?t&&t.props.nodeValue!==r?null:Jt(e,t,r):ue(r)?r.props.key!==n?null:fn(e,t,r):Array.isArray(r)?n!==void 0?null:(l&&st(r),Qt(e,t,r)):null}function Jt(e,t,r){if(t===null||t.type!=="#text"){l&&U();let o=f("#text",{nodeValue:r});return K(o,e),o}return l&&we(),t.props.nodeValue!==r&&(t.props.nodeValue=r,t.flags|=P),t.sibling=null,t}function fn(e,t,r){let{type:n,props:o}=r;if(l&&typeof n=="function"&&(n=_(n)),n===G)return Qt(e,t,o.children||[],o);if(t?.type===n)return l&&we(),t.index=0,t.sibling=null,typeof n=="string"?rr(t.props,o)&&(t.flags|=P):t.flags|=P,t.props=o,t.memoizedProps=r.memoizedProps,t;l&&U();let s=f(n,o);return K(s,e),s}function Qt(e,t,r,n={}){if(t===null||t.type!==G){l&&U();let o=f(G,{children:r,...n});return K(o,e),o}return l&&we(),t.props={...t.props,...n,children:r},t.flags|=P,t.sibling=null,t}function er(e,t){if(Re(t)){l&&U();let r=f("#text",{nodeValue:""+t});return K(r,e),r}if(w.isSignal(t)){l&&U();let r=f("#text",{nodeValue:t});return K(r,e),r}if(ue(t)){l&&U();let r=f(t.type,t.props);return K(r,e),r.flags|=T,r}if(Array.isArray(t)){l&&(U(),st(t));let r=Q({children:t});return K(r,e),r}return null}function Te(e,t,r){e.index=r;let n=e.prev;if(n!==null){let o=n.index;return o<t?(e.flags|=T,t):o}else return e.flags|=T,t}function tr(e,t,r,n){if(w.isSignal(n)||Re(n)){let s=e.get(r);if(s){if(s.props.nodeValue===n)return s;s.type==="#text"&&w.isSignal(s.props.nodeValue)&&s.cleanups?.nodeValue?.()}l&&U();let i=f("#text",{nodeValue:n});return K(i,t),i.flags|=T,i.index=r,i}if(ue(n)){let{type:s,props:i}=n,a=i.key,u=e.get(a===void 0?r:a);if(u?.type===s)return l&&we(),typeof s=="string"?rr(u.props,i)&&(u.flags|=P):u.flags|=P,u.props=i,u.sibling=null,u.index=r,u;l&&U();let c=f(n.type,n.props);return K(c,t),c.flags|=T,c.index=r,c}if(Array.isArray(n)){let s=e.get(r);if(l&&st(n),s)return l&&we(),s.flags|=P,s.props.children=n,s;l&&U();let i=Q({children:n});return K(i,t),i.flags|=T,i.index=r,i}return null}function rr(e,t){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!0;for(let o of r)if(!(o==="children"||o==="key")&&e[o]!==t[o])return!0;return!1}function K(e,t){e.parent=t,e.depth=t.depth+1}function we(){"window"in globalThis&&window.__kiru.profilingContext?.emit("updateNode",it)}function U(){"window"in globalThis&&window.__kiru.profilingContext?.emit("createNode",it)}var nr=Symbol("kiru:marked-list-child");function st(e){Object.assign(e,{[nr]:!0})}function or(e){let t=new Map;for(;e;){let r=e.props.key;t.set(r===void 0?e.index:r,e),e=e.sibling}return t}function Ae(e,t){e.deletions===null?e.deletions=[t]:e.deletions.push(t)}function ot(e,t){for(;t;)Ae(e,t),t=t.sibling}function pn(e,t){let r=new Set,n=!1;for(let o of t){if(!ue(o))continue;let s=o.props.key;if(typeof s=="string"){if(!n&&r.has(s)){let i=sr(e);ir(\`\${i} component produced a child in a list with a duplicate key prop: "\${s}". Keys should be unique so that components maintain their identity across updates\`),n=!0}r.add(s)}}}function dn(e,t){let r=!1,n=!1;for(let o of t){if(!ue(o))continue;typeof o.props.key=="string"?r=!0:n=!0}if(n&&r){let o=sr(e);ir(\`\${o} component produced a child in a list without a valid key prop\`)}}function ir(e){let t=\`[kiru]: \${e}. See https://kirujs.dev/keys-warning for more information.\`;console.error(t)}var nt=new WeakMap;function sr(e){if(nt.has(e))return nt.get(e);let t=e.parent,r;for(;!r&&t;)typeof t.type=="function"&&(r=t.type),t=t.parent;let n=\`<\${r?.displayName||r?.name||"Anonymous Function"} />\`;return nt.set(e,n),n}var W,B=[],pe=!1,lt=[],Oe=[],ut=!1,ct=!1,ft=!1,pt=0,ar=[],dt=[],lr=-1;function gt(e){if(pe){lt.push(e);return}e()}function Pe(){pe&&(window.cancelAnimationFrame(lr),ur())}function ht(e){e.flags|=ae,B.push(e),pe=!0,Pe()}function R(e){if(S.current==="hydrate")return gt(()=>mt(e));mt(e)}function mn(){pe||(pe=!0,lr=window.requestAnimationFrame(ur))}function gn(){for(pe=!1;lt.length;)lt.shift()()}function mt(e){if(ut&&(ct=!0),k.current===e){l&&window.__kiru.profilingContext?.emit("updateDirtied",W),ft=!0;return}if(!(e.flags&(ae|fe))){if(e.flags|=ae,!B.length)return B.push(e),mn();B.push(e)}}function hn(e){Z(e,t=>t.flags|=fe),Oe.push(e)}var wn=(e,t)=>t.depth-e.depth,re=null;function ur(){if(l){let t=Oe[0]??B[0];t?(W=J(t),window.__kiru.profilingContext?.beginTick(W)):W=null}let e=1;for(Lt();B.length;){B.length>e&&B.sort(wn),re=B.shift(),e=B.length;let t=re.flags;if(!(t&fe)&&t&ae){let r=re;for(;r=bn(r););for(;Oe.length;)Wt(Oe.pop());Kt(re),re.flags&=~ae}}if(Vt(),ut=!0,at(ar),ut=!1,ct)return En(),at(dt),ct=!1,pt++,l&&(window.__kiru.profilingContext?.endTick(W),window.__kiru.profilingContext?.emit("updateDirtied",W)),Pe();pt=0,gn(),at(dt),l&&(window.__kiru.emit("update",W),window.__kiru.profilingContext?.emit("update",W),window.__kiru.profilingContext?.endTick(W))}function bn(e){let t=!0;try{typeof e.type=="string"?xn(e):wt(e.type)?yn(e):t=vn(e)}catch(n){l&&window.__kiru.emit("error",W,n instanceof Error?n:new Error(String(n)));let o=cr(e);if(o){let s=o.error=n instanceof Error?n:new Error(String(n));return o.props.onError?.(s),o.depth<re.depth&&(re=o),o}if(E.isKiruError(n)){if(n.customNodeStack&&setTimeout(()=>{throw new Error(n.customNodeStack)}),n.fatal)throw n;console.error(n);return}setTimeout(()=>{throw n})}if(e.deletions!==null&&(e.deletions.forEach(hn),e.deletions=null),t&&e.child)return e.child;let r=e;for(;r;){if(r.immediateEffects&&(ar.push(...r.immediateEffects),r.immediateEffects=void 0),r.effects&&(dt.push(...r.effects),r.effects=void 0),r===re)return;if(r.sibling)return r.sibling;r=r.parent,S.current==="hydrate"&&r?.dom&&te.pop()}}function yn(e){let{props:t,type:r}=e,n=t.children;if(r===ie){let{props:{dependents:o,value:s},prev:i}=e;o.size&&i&&i.props.value!==s&&o.forEach(mt)}else if(r===se){let o=e,{error:s}=o;s&&(n=typeof t.fallback=="function"?t.fallback(s):t.fallback,delete o.error)}e.child=Me(e,n)}function vn(e){let{type:t,props:r,subs:n,prev:o,flags:s}=e;if(s&_e){if(e.memoizedProps=r,o?.memoizedProps&&e.arePropsEqual(o.memoizedProps,r)&&!e.hmrUpdated)return e.flags|=me,!1;e.flags&=~me}try{k.current=e;let i,a=0;do{if(e.flags&=~ae,ft=!1,X.current=0,n&&(n.forEach(u=>u()),n.clear()),l){if(i=_(t)(r),e.hmrUpdated&&e.hooks&&e.hookSig){let u=e.hooks.length;if(X.current<u){for(let c=X.current;c<u;c++)e.hooks[c].cleanup?.();e.hooks.length=X.current,e.hookSig.length=X.current}}if(delete e.hmrUpdated,++a>Be)throw new E({message:"Too many re-renders. Kiru limits the number of renders to prevent an infinite loop.",fatal:!0,vNode:e});continue}i=t(r)}while(ft);return e.child=Me(e,i),!0}finally{k.current=null}}function xn(e){let{props:t,type:r}=e;l&&bt(e),e.dom||(S.current==="hydrate"?It(e):e.dom=$t(e),l&&e.dom instanceof Element&&(e.dom.__kiruNode=e)),r!=="#text"&&(e.child=Me(e,t.children),e.child&&S.current==="hydrate"&&te.push(e.dom))}function En(){if(pt>Be)throw new E("Maximum update depth exceeded. This can happen when a component repeatedly calls setState during render or in useLayoutEffect. Kiru limits the number of nested updates to prevent infinite loops.")}function at(e){for(let t=0;t<e.length;t++)e[t]();e.length=0}var fr;(function(e){e.Start="start",e.End="end"})(fr||(fr={}));var de=null,pr=new Set;function d(e,t,r){let n=k.current;if(n||Sn(e),l&&de!==null&&!pr.has(e+de))throw pr.add(e+de),new E({message:\`Nested primitive "useHook" calls are not supported. "\${e}" was called inside "\${de}". Strange will most certainly happen.\`,vNode:n});let o=(a,u)=>{if(u?.immediate){(n.immediateEffects??(n.immediateEffects=[])).push(a);return}(n.effects??(n.effects=[])).push(a)},s=X.current++,i=n.hooks?.at(s);if(l){de=e,n.hooks??(n.hooks=[]),n.hookSig??(n.hookSig=[]),n.hookSig[s]?n.hookSig[s]!==e&&(console.warn(\`[kiru]: hooks must be called in the same order. Hook "\${e}" was called in place of "\${n.hookSig[s]}". Strange things may happen.\`),i?.cleanup?.(),n.hooks.length=s,n.hookSig.length=s,i=void 0):n.hookSig[s]=e;let a;i?a=i:(a=typeof t=="function"?t():{...t},a.name=e),n.hooks[s]=a;try{return r({hook:a,isInit:!i,isHMR:n.hmrUpdated,update:()=>R(n),queueEffect:o,vNode:n,index:s})}catch(u){throw u}finally{de=null}}try{let a=i??(typeof t=="function"?t():{...t});return n.hooks??(n.hooks=[]),n.hooks[s]=a,r({hook:a,isInit:!i,update:()=>R(n),queueEffect:o,vNode:n,index:s})}catch(a){throw a}}function Sn(e){throw new E(\`Hook "\${e}" must be used at the top level of a component or inside another composite hook.\`)}function $(e){e.cleanup&&(e.cleanup(),e.cleanup=void 0)}function A(e,t){return e===void 0||t===void 0||e.length!==t.length||e.length>0&&t.some((r,n)=>!Object.is(r,e[n]))}var be={stack:new Array,current:function(){return this.stack[this.stack.length-1]}},H=new Map,F=new Map;var dr,w=class e{constructor(t,r){this[dr]=!0,this.$id=Le(),this.$value=t,r&&(this.displayName=r),l?(F.set(this.$id,new Set),this.$initialValue=yt(t),this[L]={provide:()=>this,inject:n=>{F.get(this.$id)?.clear?.(),F.delete(this.$id),this.$id=n.$id,n.__next=this,this.$initialValue===n.$initialValue?this.$value=n.$value:this.notify()},destroy:()=>{}}):this.$subs=new Set}get value(){if(this.onBeforeRead?.(),l){let t=_(this);return e.entangle(t),t.$value}return e.entangle(this),this.$value}set value(t){if(l){let r=_(this);if(Object.is(r.$value,t))return;r.$prevValue=r.$value,r.$value=t,r.notify();return}Object.is(this.$value,t)||(this.$prevValue=this.$value,this.$value=t,this.notify())}peek(){return this.onBeforeRead?.(),l?_(this).$value:this.$value}sneak(t){if(l){let r=_(this);r.$prevValue=r.$value,r.$value=t;return}this.$prevValue=this.$value,this.$value=t}toString(){if(this.onBeforeRead?.(),l){let t=_(this);return e.entangle(t),\`\${t.$value}\`}return e.entangle(this),\`\${this.$value}\`}subscribe(t){return l?(F.get(this.$id).add(t),()=>F.get(this.$id)?.delete(t)):(this.$subs.add(t),()=>this.$subs.delete(t))}notify(t){if(l)return F.get(this.$id)?.forEach(r=>{if(t?.filter&&!t.filter(r))return;let{$value:n,$prevValue:o}=_(this);return r(n,o)});this.$subs.forEach(r=>{if(!(t?.filter&&!t.filter(r)))return r(this.$value,this.$prevValue)})}static isSignal(t){return typeof t=="object"&&!!t&&Ue in t}static subscribers(t){return l?F.get(t.$id):t.$subs}static makeReadonly(t){let r=Object.getOwnPropertyDescriptor(t,"value");return r&&!r.writable?t:Object.defineProperty(t,"value",{get:function(){return e.entangle(this),this.$value},configurable:!0})}static makeWritable(t){let r=Object.getOwnPropertyDescriptor(t,"value");return r&&r.writable?t:Object.defineProperty(t,"value",{get:function(){return e.entangle(this),this.$value},set:function(n){this.$value=n,this.notify()},configurable:!0})}static entangle(t){let r=k.current,n=be.current();if(n){(!r||r&&m())&&n.set(t.$id,t);return}if(!r||!m())return;let o=t.subscribe(()=>R(r));(r.subs??(r.subs=new Set)).add(o)}static configure(t,r){t.onBeforeRead=r}static dispose(t){if(t.$isDisposed=!0,l){F.delete(t.$id);return}t.$subs.clear()}};dr=Ue;var De=(e,t)=>new w(e,t),y=(e,t)=>d("useSignal",{signal:null},({hook:r,isInit:n,isHMR:o})=>{if(l&&(n&&(r.dev={devtools:{get:()=>({displayName:r.signal.displayName,value:r.signal.peek()}),set:({value:s})=>{r.signal.value=s}},initialArgs:[e,t]}),o)){let[s,i]=r.dev.initialArgs;(s!==e||i!==t)&&(r.cleanup?.(),n=!0,r.dev.initialArgs=[e,t])}return n&&(r.cleanup=()=>w.dispose(r.signal),r.signal=new w(e,t)),r.signal});function Y(e,t=!1){return w.isSignal(e)?t?e.value:e.peek():e}var vt=()=>{H.forEach(e=>e()),H.clear()};var ge={internalProps:["children","ref","key","innerHTML"],isEvent:e=>e.startsWith("on"),isProperty:e=>!ge.internalProps.includes(e)&&!ge.isEvent(e)};function qt(e){switch(e){case"className":return"class";case"htmlFor":return"for";case"tabIndex":case"formAction":case"formMethod":case"formEncType":case"contentEditable":case"spellCheck":case"allowFullScreen":case"autoPlay":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"noModule":case"noValidate":case"popoverTarget":case"popoverTargetAction":case"playsInline":case"readOnly":case"itemscope":case"rowSpan":case"crossOrigin":return e.toLowerCase();default:return e.indexOf("-")>-1?e:e.startsWith("aria")?"aria-"+e.substring(4).toLowerCase():Mt.get(e)||e}}function yt(e,t={functions:!0}){let r=new WeakSet;return JSON.stringify(e,(n,o)=>{if(typeof o=="object"&&o!==null){if(r.has(o))return"[CIRCULAR]";r.add(o)}return typeof o=="function"?t.functions?o.toString():\`[FUNCTION (\${o.name||"anonymous"})]\`:o})}function _(e){let t=e;if(l)for(;"__next"in t;)t=t.__next;return t}function m(){return S.current==="dom"||S.current==="hydrate"}function ue(e){return typeof e=="object"&&e!==null&&"type"in e}function Re(e){return typeof e=="string"&&e!==""||typeof e=="number"||typeof e=="bigint"}function wt(e){return e===G||e===ie||e===se}function mr(e){return e.type===G}function J(e){let t=e;for(;t;){if(t.app)return e.app=t.app;t=t.parent}return null}function he(e){let{props:{children:t,...r},memoizedProps:n,index:o}=e;e.prev={props:r,memoizedProps:n,index:o},e.flags&=~(P|T|fe)}function gr(e,t){if(t.depth<e.depth)return!1;if(e===t)return!0;let r=!1,n=[e];for(;n.length;){let o=n.pop();if(o===t)return!0;o.child&&n.push(o.child),r&&o.sibling&&n.push(o.sibling),r=!0}return!1}function Z(e,t){t(e);let r=e.child;for(;r;)t(r),r.child&&Z(r,t),r=r.sibling}function Ye(e,t){let r=e.parent;for(;r;){if(t(r))return r;r=r.parent}return null}function cr(e){return Ye(e,t=>t.type===se)}function bt(e){if("children"in e.props&&e.props.innerHTML)throw new E({message:"Cannot use both children and innerHTML on an element",vNode:e});for(let t in e.props)if("bind:"+t in e.props)throw new E({message:\`Cannot use both bind:\${t} and \${t} on an element\`,vNode:e})}function Xt(e){return typeof e=="string"||typeof e=="number"}function Yt(e){return typeof e=="function"||typeof e=="object"&&!!e&&"current"in e||w.isSignal(e)}var kn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz-";function Le(e=10,t=kn){let r="";for(let n=0;n<e;n++)r+=t[Math.random()*t.length|0];return r}var j=Object.freeze(()=>{});function Ve(e){let{id:t,subs:r,fn:n,deps:o=[],onDepChanged:s}=e,i;H.delete(t);let a=!!k.current&&!m();a||(i=new Map,be.stack.push(i));let u=n(...o.map(c=>c.value));if(!a){for(let[p,v]of r)i.has(p)||(v(),r.delete(p));let c=()=>{H.size||queueMicrotask(vt),H.set(t,s)};for(let[p,v]of i){if(r.has(p))continue;let M=v.subscribe(c);r.set(p,M)}be.stack.pop()}return u}var ye=class e extends w{constructor(t,r){if(super(void 0,r),this.$getter=t,this.$unsubs=new Map,this.$isDirty=!0,l){let n=this[L].inject;this[L]={provide:()=>this,inject:o=>{n(o),e.stop(o),this.$isDirty=o.$isDirty},destroy:()=>{}}}w.configure(this,()=>{this.$isDirty&&(l&&this.$isDisposed||e.run(this))})}get value(){return super.value}set value(t){}subscribe(t){return this.$isDirty&&e.run(this),super.subscribe(t)}static dispose(t){e.stop(t),w.dispose(t)}static stop(t){let{$id:r,$unsubs:n}=_(t);H.delete(r),n.forEach(o=>o()),n.clear(),t.$isDirty=!0}static run(t){let r=_(t),{$id:n,$getter:o,$unsubs:s}=r,i=Ve({id:n,subs:s,fn:()=>o(r.$value),onDepChanged:()=>{if(r.$isDirty=!0,l){if(!F?.get(n)?.size)return}else if(!t.$subs.size)return;e.run(r),!Object.is(r.$value,r.$prevValue)&&r.notify()}});r.sneak(i),r.$isDirty=!1}},hr=(e,t)=>new ye(e,t),xt=(e,t)=>d("useComputedSignal",{signal:null},({hook:r,isInit:n,isHMR:o})=>(l&&(r.dev={devtools:{get:()=>({displayName:r.signal.displayName,value:r.signal.peek()})}},o&&(r.cleanup?.(),n=!0)),n&&(r.cleanup=()=>ye.dispose(r.signal),r.signal=hr(e,t)),r.signal));var ve=class e{constructor(t,r){if(this.id=Le(),this.getter=t,this.deps=r,this.unsubs=new Map,this.isRunning=!1,this.cleanup=null,l&&(this[L]={provide:()=>this,inject:n=>{n.isRunning||this.stop()},destroy:()=>{this.stop()}},"window"in globalThis)){let n=window.__kiru.HMRContext.signals;n.isWaitingForNextWatchCall()&&n.pushWatch(this)}this.start()}start(){if(!this.isRunning){if(this.isRunning=!0,l&&"window"in globalThis&&window.__kiru.HMRContext?.isReplacement())return queueMicrotask(()=>{this.isRunning&&e.run(this)});e.run(this)}}stop(){H.delete(this.id),this.unsubs.forEach(t=>t()),this.unsubs.clear(),this.cleanup?.(),this.cleanup=null,this.isRunning=!1}static run(t){let r=_(t),{id:n,getter:o,unsubs:s,deps:i}=r;r.cleanup=Ve({id:n,subs:s,fn:o,deps:i,onDepChanged:()=>{r.cleanup?.(),e.run(r)}})??null}};function wr(e,t){if(typeof e=="function")return new ve(e);let r=e,n=t;return new ve(n,r)}function xe(e,t){if(m())return d("useWatch",{watcher:null},({hook:r,isInit:n,isHMR:o})=>{if(l&&o&&(r.cleanup?.(),n=!0),n){let s=r.watcher=wr(e,t);r.cleanup=()=>s.stop()}return r.watcher})}var _n=0;function br(e,t,r){if(l&&t.__kiruNode)throw new Error("[kiru]: container in use - call unmount on the previous app first.");let n=f(t.nodeName.toLowerCase(),{});l&&(t.__kiruNode=n),n.dom=t,n.flags|=V;let o=_n++,s=r?.name??\`App-\${o}\`,i={id:o,name:s,rootNode:n,render:a,unmount:u};function a(c){n.props.children=c,ht(n)}function u(){n.props.children=null,ht(n),l&&(delete t.__kiruNode,delete n.app),window.__kiru.emit("unmount",i)}return l&&(n.app=i),a(e),window.__kiru.emit("mount",i),l&&queueMicrotask(()=>{window.dispatchEvent(new Event("kiru:ready"))}),i}function ce(e){return m()?d("useState",{state:void 0,dispatch:j},({hook:t,isInit:r,update:n,isHMR:o})=>{if(l&&(r&&(t.dev={devtools:{get:()=>({value:t.state}),set:({value:s})=>t.state=s},initialArgs:[e]}),o)){let[s]=t.dev.initialArgs;s!==e&&(r=!0,t.dev.initialArgs=[e])}return r&&(t.state=typeof e=="function"?e():e,t.dispatch=s=>{let i=typeof s=="function"?s(t.state):s;Object.is(t.state,i)||(t.state=i,n())}),[t.state,t.dispatch]}):[typeof e=="function"?e():e,j]}function yr(e){let t={[Ct]:!0,Provider:({value:r,children:n})=>{let[o]=ce(()=>new Set);return f(ie,{value:r,ctx:t,dependents:o},typeof n=="function"?n(r):n)},default:()=>e,set displayName(r){this.Provider.displayName=r},get displayName(){return this.Provider.displayName||"Anonymous Context"}};if(l){let r=t;r[L]={inject:n=>{let o=t.Provider;window.__kiru.apps.forEach(s=>{Z(s.rootNode,i=>{i.type===n.Provider&&(i.type=o,i.hmrUpdated=!0,R(i))})})},destroy:()=>{},provide:()=>t}}return t}function ee(e,t){return m()?d("useCallback",{callback:e,deps:t},({hook:r,isHMR:n})=>(l&&(r.dev={devtools:{get:()=>({callback:r.callback,dependencies:r.deps})}},n&&(r.deps=[])),A(t,r.deps)&&(r.deps=t,r.callback=e),r.callback)):e}function N(e,t){if(m())return d("useEffect",{deps:t},({hook:r,isInit:n,isHMR:o,queueEffect:s})=>{l&&(r.dev={devtools:{get:()=>({callback:e,dependencies:r.deps})}},o&&(n=!0)),(n||A(t,r.deps))&&(r.deps=t,$(r),s(()=>{let i=e();typeof i=="function"&&(r.cleanup=i)}))})}function ne(e,t){if(m())return d("useLayoutEffect",{deps:t},({hook:r,isInit:n,isHMR:o,queueEffect:s})=>{l&&(r.dev={devtools:{get:()=>({callback:e,dependencies:r.deps})}},o&&(n=!0)),(n||A(t,r.deps))&&(r.deps=t,$(r),s(()=>{let i=e();typeof i=="function"&&(r.cleanup=i)},{immediate:!0}))})}function Ee(e,t){return m()?d("useMemo",{deps:t,value:void 0},({hook:r,isInit:n,isHMR:o})=>(l&&(r.dev={devtools:{get:()=>({value:r.value,dependencies:r.deps})}},o&&(n=!0)),(n||A(t,r.deps))&&(r.deps=t,r.value=e()),r.value)):e()}function I(e){return m()?d("useRef",{ref:{current:e}},({hook:t,isInit:r,isHMR:n})=>{if(l&&(r&&(t.dev={devtools:{get:()=>({value:t.ref.current}),set:({value:o})=>t.ref.current=o},initialArgs:[t.ref.current]}),n)){let[o]=t.dev.initialArgs;o!==e&&(t.ref={current:e},t.dev.initialArgs=[e])}return t.ref}):{current:e}}var Ka="window"in globalThis?window.__KIRU_LAZY_CACHE??(window.__KIRU_LAZY_CACHE=new Map):new Map;function Er(e){let[t,r]=ce(e.initialState||"exited"),n=I(null);ne(()=>{e.in&&t!=="entered"&&t!=="entering"?(o("entering"),s("entered")):!e.in&&t!=="exited"&&t!=="exiting"&&(o("exiting"),s("exited"))},[e.in,t]),N(()=>()=>xr(n.current),[]);let o=ee(i=>{xr(n.current),r(i),(i==="entered"||i==="exited")&&e.onTransitionEnd&&e.onTransitionEnd(i)},[]),s=ee(i=>{n.current=window.setTimeout(()=>o(i),Tn(i,e.duration))},[e.duration]);return e.element(t)}var vr=150;function Tn(e,t){if(typeof t=="number")return t;switch(e){case"entered":return t?.in??vr;case"exited":return t?.out??vr}}function xr(e){e!=null&&window.clearTimeout(e)}"window"in globalThis;var Sr=()=>f("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},f("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"}));var $e="kiru.devtools.anchorPosition",kr={x:-16,y:-16};var Et=(e,t,r)=>{if(!t.current)return{...kr};let n=window.innerWidth/e.width,o=window.innerHeight/e.height,s=null,i=null;return e.snapSide==="left"?s=(t.current.offsetWidth-r.width.value)*-1+16:e.snapSide==="right"?s=-16:e.snapSide==="bottom"?i=-16:e.snapSide==="top"&&(i=(window.innerHeight-r.height.value)*-1+16),{x:s??e.x*n,y:i??e.y*o}},_r=e=>{if(e==null)return null;let t=null,r=e?.__kiruNode?.parent;for(;r;){if(typeof r.type=="function"&&!mr(r)){t=r;break}r=r.parent}return t},Cr=(e,t)=>{let r=[],n=[t.__kiruNode];for(;n.length;){let s=n.pop();if(s===e)break;s?.dom&&r.push(s),s?.parent&&n.push(s.parent)}if(r.length===0)return;let o=r[r.length-1].dom;return o instanceof Element?o:void 0};var Ar={arrayChunkSize:10,objectKeysChunkSize:100};function Mr(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;let r=new Set([...Object.keys(e),...Object.keys(t)]);for(let n in r)if(typeof t[n]!=typeof e[n]||typeof e[n]=="object"&&!Mr(e[n],t[n]))return!1;return!0}var Rn={...Ar},Tr=localStorage.getItem("kiru.devtools.userSettings");if(Tr)try{let e=JSON.parse(Tr);Mr(Ar,e)&&(Rn=e)}catch(e){console.error("kiru.devtools.userSettings error",e)}var Pu=yr({userSettings:null,saveUserSettings:()=>{}});var Nu=Object.freeze(()=>{});var Ln="kiru-devtools";"window"in globalThis&&(window.__devtoolsSelection??(window.__devtoolsSelection=null));var St=class extends BroadcastChannel{send(t){super.postMessage(t)}removeEventListener(t){return super.removeEventListener("message",t)}addEventListener(t){return super.addEventListener("message",t)}},O=new St(Ln);var lc=Symbol.for("devtools.hookGroup");var D=(e,t,r={})=>{N(()=>{let n=window,o=r?.ref?.();return o?n=o:r.ref&&console.warn("useEventListener ref failed, using window"),n.addEventListener(e,t,r),()=>{n.removeEventListener(e,t,r)}},[t])};var He=()=>{let e=y({x:0,y:0}),t=y({x:0,y:0}),r=y({x:0,y:0});return D("mousemove",n=>{e.value={x:n.x,y:n.y},t.value={x:n.movementX,y:n.movementY},r.value={x:n.clientX,y:n.clientY}}),{mouse:e,delta:t,client:r}};var Fe="window"in globalThis&&"ResizeObserver"in globalThis.window,Rr=(e,t,r=void 0)=>m()?Fe?d("useResizeObserver",{resizeObserver:null,deps:[e.current]},({isInit:n,hook:o,queueEffect:s})=>(n&&(o.resizeObserver=new ResizeObserver(t),o.cleanup=()=>{o.resizeObserver?.disconnect?.(),o.resizeObserver=null}),s(()=>{A([e.current],o.deps)&&(o.deps=[e.current],o.resizeObserver?.disconnect?.(),e.current&&o.resizeObserver?.observe(e.current,r))}),{isSupported:Fe,start:()=>{o.resizeObserver==null&&(o.resizeObserver=new ResizeObserver(t),e.current&&o.resizeObserver.observe(e.current,r),o.cleanup=()=>{o.resizeObserver?.disconnect?.(),o.resizeObserver=null})},stop:()=>{$(o)}})):{isSupported:Fe,start:()=>{},stop:()=>{}}:{isSupported:Fe,start:()=>{},stop:()=>{}};var Ne="window"in globalThis&&"MutationObserver"in globalThis.window,Or=(e,t,r=void 0)=>m()?Ne?d("useMutationObserver",{mutationObserver:null,deps:[e.current]},({isInit:n,hook:o,queueEffect:s})=>(n?(s(()=>{o.deps=[e.current],o.mutationObserver=new MutationObserver(t),e.current&&o.mutationObserver.observe(e.current,r)}),o.cleanup=()=>{o.mutationObserver?.disconnect?.(),o.mutationObserver=null}):A([e.current],o.deps)&&(o.deps=[e.current],o.mutationObserver?.disconnect?.(),e.current&&o.mutationObserver?.observe(e.current,r)),{isSupported:Ne,start:()=>{o.mutationObserver==null&&(o.mutationObserver=new MutationObserver(t),e.current&&o.mutationObserver.observe(e.current,r),o.cleanup=()=>{o.mutationObserver?.disconnect?.(),o.mutationObserver=null})},stop:()=>{$(o)}})):{isSupported:Ne,start:()=>{},stop:()=>{}}:{isSupported:Ne,start:()=>{},stop:()=>{}};var Ie=(e,t={windowScroll:!0,windowResize:!0})=>{let r=t?.windowScroll??!0,n=t?.windowResize??!0,o=t.immediate??!0,s=y(0),i=y(0),a=y(0),u=y(0),c=y(0),p=y(0),v=y(0),M=y(0),h=()=>{let x=e.current;if(!x){s.value=0,i.value=0,a.value=0,u.value=0,c.value=0,p.value=0,v.value=0,M.value=0;return}let b=x.getBoundingClientRect();s.value=b.width,i.value=b.height,a.value=b.top,u.value=b.right,c.value=b.bottom,p.value=b.left,v.value=b.x,M.value=b.y};return Rr(e,h),Or(e,h,{attributeFilter:["style","class"]}),D("scroll",()=>{r&&h()},{capture:!0,passive:!0}),D("resize",()=>{n&&h()},{passive:!0}),ne(()=>{o&&h()},[]),{width:s,height:i,top:a,right:u,bottom:c,left:p,x:v,y:M,update:h}};var Pr=(e,t)=>{if(!m())return{isActive:t?.immediate??!1,start:()=>null,stop:()=>null};let r=t?.fpsLimit?1e3/t.fpsLimit:null;return d("useRafFn",()=>({callback:e,refId:null,previousFrameTimestamp:0,isActive:t?.immediate??!1,rafLoop:()=>{}}),({isInit:n,hook:o,update:s})=>(o.callback=e,n&&(o.rafLoop=i=>{if(o.isActive===!1)return;o.previousFrameTimestamp||(o.previousFrameTimestamp=i);let a=i-o.previousFrameTimestamp;if(r&&a<r){o.refId=window.requestAnimationFrame(o.rafLoop);return}o.previousFrameTimestamp=i,o.callback({delta:a,timestamp:i}),o.refId=window.requestAnimationFrame(o.rafLoop)}),n&&t?.immediate&&(o.isActive=!0,o.refId=window.requestAnimationFrame(o.rafLoop),o.cleanup=()=>{o.refId!=null&&window.cancelAnimationFrame(o.refId),o.isActive=!1},s()),{isActive:o.isActive,start:()=>{o.isActive!==!0&&(o.isActive=!0,o.refId=window.requestAnimationFrame(o.rafLoop),o.cleanup=()=>{o.refId!=null&&window.cancelAnimationFrame(o.refId),o.isActive=!1},s())},stop:()=>{$(o),s()}}))};var Dr=e=>{let{x:t,y:r,multiple:n,immediate:o=!0}=e,s=y(null),a=Pr(()=>{s.value=n?document.elementsFromPoint(t,r)??[]:document.elementFromPoint(t,r)??null},{immediate:o});return{element:s,...a}};var Lr=()=>{let{mouse:e}=He(),t=y(null),r=I(null),n=I(null),o=Ie(r),s=y({x:-16,y:-16}),i=y({x:-16,y:-16}),a=y({width:window.innerWidth,height:window.innerHeight}),u=y("bottom"),c=I(null);ne(()=>{let h=localStorage.getItem($e);if(h==null)return;let x=JSON.parse(h);a.value.width=window.innerWidth,a.value.height=window.innerHeight,u.value=x.snapSide,i.value=Et(x,n,o)},[Math.round(o.width.value),Math.round(o.height.value)]);let p=xt(()=>{let{x:h,y:x}=e.value;if(t.value===null)return null;let{x:b,y:C}=t.value;return{x:h-b,y:x-C}});D("dragstart",h=>{h.preventDefault(),t.value={x:h.x,y:h.y},s.value=i.value},{ref:()=>r.current}),D("mouseup",()=>{c.current&&(clearTimeout(c.current),c.current=null),t.peek()&&(t.value=null,localStorage.setItem($e,JSON.stringify({...i.value,...a.value,snapSide:u.value})))});let v=ee(()=>{if(n.current==null)return;let h=n.current.offsetWidth;if(u.value==="right"){let x=Math.min(-16,i.value.y);i.value={x:-16,y:Math.max(x,(window.innerHeight-o.height.value)*-1+16)}}else if(u.value==="left"){let x=Math.min(0,i.value.y);i.value={x:(h-o.width.value)*-1+16,y:Math.max(x,(window.innerHeight-o.height.value)*-1+16)}}else if(u.value==="top"){let x=Math.min(-16,i.value.x);i.value={x:Math.max(x,(h-o.width.value)*-1+16),y:(window.innerHeight-o.height.value)*-1+16};return}else{let x=Math.min(-16,i.value.x);i.value={x:Math.max(x,(h-o.width.value)*-1+16),y:-16}}},[]);xe([p,e],(h,x)=>{if(h===null||!n.current)return;let{x:b,y:C}=x,je=n.current.offsetWidth,Ir=C>=window.innerHeight-100,_t=C<=100;if(!_t&&!Ir){let oe=b>window.innerWidth/2;u.value=oe?"right":"left"}else u.value=_t?"top":"bottom";if(u.value==="right"){let oe=Math.min(-16,s.value.y+h.y);i.value={x:-16,y:Math.max(oe,(window.innerHeight-o.height.value)*-1+16)};return}else if(u.value==="left"){let oe=Math.min(0,s.value.y+h.y);i.value={x:(je-o.width.value)*-1+16,y:Math.max(oe,(window.innerHeight-o.height.value)*-1+16)};return}else if(u.value==="top"){let oe=Math.min(-16,s.value.x+h.x);i.value={x:Math.max(oe,(je-o.width.value)*-1+16),y:(window.innerHeight-o.height.value)*-1+16};return}let zr=Math.min(-16,s.value.x+h.x);i.value={y:-16,x:Math.max(zr,(je-o.width.value)*-1+16)}});let M=ee(()=>{n.current!==null&&(i.value=Et({width:a.value.width,height:a.value.height,x:i.value.x,y:i.value.y,snapSide:u.value},n,o),a.value.width=window.innerWidth,a.value.height=window.innerHeight,localStorage.setItem($e,JSON.stringify({...i.value,...a.value,snapSide:u.value})))},[Math.round(o.width.value),Math.round(o.height.value)]);return D("resize",M),{anchorRef:r,anchorCoords:i,viewPortRef:n,startMouse:t,elementBound:o,snapSide:u,updateAnchorPos:v}};var z=De(!1);"window"in globalThis&&O.addEventListener(e=>{e.data.type==="set-inspect-enabled"&&(z.value=e.data.value)});var q=De(null);var Vr="kiru-devtools-popup-size",ze=()=>{let e=q.value;return ee(()=>new Promise((r,n)=>{if(e)if(e.closed)q.value=null;else return e.focus(),r(e);let o=sessionStorage.getItem(Vr),s=o?JSON.parse(o):{width:Math.floor(Math.min(1920,window.screen.width)/2),height:Math.floor(Math.min(1080,window.screen.height)/2)},i=\`popup,width=\${s.width},height=\${s.height};\`,a=window.open(window.__KIRU_DEVTOOLS_PATHNAME__,"_blank",i);if(!a)return console.error("[kiru]: Unable to open devtools window"),n();let u=c=>{c.data.type==="ready"&&(O.removeEventListener(u),console.debug("[kiru]: devtools window opened"),r(a),q.value=a,a.onbeforeunload=()=>{console.debug("[kiru]: devtools window closed"),q.value=null})};O.addEventListener(u),a.onresize=()=>{sessionStorage.setItem(Vr,JSON.stringify({width:a.innerWidth,height:a.innerHeight}))}}),[e])};var $r=()=>{let e=ze(),{mouse:t}=He(),r=Dr({x:t.value.x,y:t.value.y,immediate:!1}),n=r.element.value,o=z.value?n:null,s=Ee(()=>{if(o&&window.__kiru){let c=window.__kiru.apps.find(p=>p.rootNode==null||o.__kiruNode==null?!1:gr(p.rootNode,o.__kiruNode));return c?.rootNode==null?null:c}return null},[o]),i=Ee(()=>o?_r(o):null,[o]),a=I(null),u=Ie(a);return N(()=>z.subscribe(p=>{r[p?"start":"stop"]()}),[]),N(()=>{i&&o?a.current=Cr(i,o)??null:a.current=null},[i,o]),D("click",c=>{if(z.value===!0&&i&&s){c.preventDefault();let p=v=>{v.__devtoolsSelection={node:i,app:s},O.send({type:"select-node"}),O.send({type:"set-inspect-enabled",value:!1}),z.value=!1,a.current=null,v.focus()};q.value?p(q.value):e().then(v=>p(v))}}),i&&f("div",{className:"bg-[crimson]/80 fixed grid place-content-center pointer-events-none z-10 top-0 left-0",style:{width:\`\${u?.width}px\`,height:\`\${u?.height}px\`,transform:\`translate(\${u.x}px, \${u.y}px)\`}},f("p",null,i.type.name))};function Hr(e){return f("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 -960 960 960",fill:"currentColor",...e},f("path",{d:"M710-150q-63 0-106.5-43.5T560-300q0-63 43.5-106.5T710-450q63 0 106.5 43.5T860-300q0 63-43.5 106.5T710-150Zm0-80q29 0 49.5-20.5T780-300q0-29-20.5-49.5T710-370q-29 0-49.5 20.5T640-300q0 29 20.5 49.5T710-230Zm-270-30H200q-17 0-28.5-11.5T160-300q0-17 11.5-28.5T200-340h240q17 0 28.5 11.5T480-300q0 17-11.5 28.5T440-260ZM250-510q-63 0-106.5-43.5T100-660q0-63 43.5-106.5T250-810q63 0 106.5 43.5T400-660q0 63-43.5 106.5T250-510Zm0-80q29 0 49.5-20.5T320-660q0-29-20.5-49.5T250-730q-29 0-49.5 20.5T180-660q0 29 20.5 49.5T250-590Zm510-30H520q-17 0-28.5-11.5T480-660q0-17 11.5-28.5T520-700h240q17 0 28.5 11.5T800-660q0 17-11.5 28.5T760-620Zm-50 320ZM250-660Z"}))}function Fr(e){return f("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-square-mouse-pointer",...e},f("path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"}),f("path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"}))}var Vn=()=>{z.value=!z.value,O.send({type:"set-inspect-enabled",value:z.value})};function $n(e,t){let{damping:r}=t,n=y(e),o=I(e);return N(()=>{let s=null,i=()=>{if(Math.sqrt(Math.pow(o.current.x-n.value.x,2)+Math.pow(o.current.y-n.value.y,2))<5)return;let u=n.value.x+(o.current.x-n.value.x)*r,c=n.value.y+(o.current.y-n.value.y)*r;n.value={x:u,y:c},s=window.requestAnimationFrame(i)};return s=window.requestAnimationFrame(i),()=>{s!=null&&window.cancelAnimationFrame(s)}},[e.x,e.y]),Object.assign(n,{set:(s,i)=>{o.current=s,i?.hard&&(n.value=s)}})}function kt(){let e=y(!1),t=ze(),{anchorCoords:r,anchorRef:n,viewPortRef:o,startMouse:s,snapSide:i}=Lr(),a=i.value==="left"||i.value==="right",u=I(!1),c=$n(r.value,{damping:.4});return xe([r],c.set),ne(()=>{u.current===!1&&c.set(r.value,{hard:!0}),u.current=!0},[]),f(Q,null,f("div",{ref:o,className:"w-full h-0 fixed top-0 left-0 z-[-9999] overflow-scroll pointer-events-none"}),f("div",{ref:n,draggable:!0,className:\`flex \${a?"flex-col":""} \${e.value?"rounded-3xl":"rounded-full"} p-1 gap-1 items-center will-change-transform bg-crimson\`,style:{transform:\`translate3d(\${Math.round(c.value.x)}px, \${Math.round(c.value.y)}px, 0)\`}},f(Er,{in:e.value,duration:{in:40,out:150},element:p=>{if(p==="exited")return null;let v=p==="entered"?"1":"0.5",M=p==="entered"?"1":"0";return f(Q,null,f("button",{title:"Open Devtools",onclick:t,style:{transform:\`scale(\${v})\`,opacity:M},className:"transition text-white rounded-full p-1 hover:bg-[#0003]"},f(Hr,{width:16,height:16})),f("button",{title:"Toggle Component Inspection",onclick:Vn,style:{transform:\`scale(\${v})\`,opacity:M},className:\`transition text-white rounded-full p-1 hover:bg-[#0003] \${z.value?"bg-[#0003]":""}\`},f(Fr,{width:16,height:16})))}}),f("button",{className:"bg-crimson rounded-full p-1"+(s.value?" pointer-events-none":""),onclick:()=>e.value=!e.value,tabIndex:-1},f(Sr,null))),f($r,null))}var Nr=\`*, ::before, ::after {
|
|
2440
2441
|
--tw-border-spacing-x: 0;
|
|
2441
2442
|
--tw-border-spacing-y: 0;
|
|
2442
2443
|
--tw-translate-x: 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-kiru",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"kiru": ">=0.51.
|
|
12
|
+
"kiru": ">=0.51.3"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/node": "^22.17.0",
|