vite-plugin-kiru 0.28.1 → 0.28.2

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.
Files changed (2) hide show
  1. package/dist/index.js +3 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1762,11 +1762,11 @@ var dist_default = `<!DOCTYPE html>
1762
1762
  `;
1763
1763
 
1764
1764
  // ../devtools-host/dist/index.js
1765
- var dist_default2 = `var We=Symbol.for("kiru.signal"),_t=Symbol.for("kiru.context"),oe=Symbol.for("kiru.contextProvider"),X=Symbol.for("kiru.fragment"),Ke=Symbol.for("kiru.error"),k=Symbol.for("kiru.hmrAccept"),Ce=Symbol.for("kiru.memo"),ie=Symbol.for("kiru.errorBoundary"),Ct=Symbol.for("kiru.suspenseThrow"),Ue=50;var D=2,A=4,pe=8,V=16,Te=32,he=64,se=128,Tt=/^on:?/;var Be=new Set(["animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","path","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","title","tspan","use"]),Ge=new Set(["allowfullscreen","autofocus","autoplay","async","checked","compact","controls","contenteditable","declare","default","defer","disabled","download","hidden","inert","ismap","multiple","nohref","noresize","noshade","novalidate","nowrap","open","popover","readonly","required","sandbox","scoped","selected","sortable","spellcheck","translate","wrap"]),At=new Map([["acceptCharset","accept-charset"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["httpEquiv","http-equiv"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]);var we={internalProps:["children","ref","key","innerHTML"],isEvent:e=>e.startsWith("on"),isProperty:e=>!we.internalProps.includes(e)&&!we.isEvent(e)};function Mt(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():At.get(e)||e}}function qe(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})}var Xe="production";if(Xe!=="development"&&Xe!=="production")throw new Error("NODE_ENV must either be set to development or production.");var l=Xe==="development";var M={current:null},Y={current:0},C={current:"window"in globalThis?"dom":"string"};function T(e){let t=e;if(l)for(;"__next"in t;)t=t.__next;return t}function w(){return C.current==="dom"||C.current==="hydrate"}var Rt,_=class extends Error{constructor(t){let r=typeof t=="string"?t:t.message;super(r),this[Rt]=!0,typeof t!="string"&&(l&&t?.vNode&&(this.customNodeStack=Kr(t.vNode)),this.fatal=t?.fatal)}static isKiruError(t){return t instanceof Error&&t[Ke]===!0}};Rt=Ke;function Kr(e){let t=e,r=[];for(;t&&t.parent;)typeof t.type=="function"?r.push(Ur(t.type)):typeof t.type=="string"&&r.push(t.type),t=t.parent;let n=typeof e.type=="function"?e:Ye(e,o=>typeof o.type=="function");return\`The above error occurred in the <\${Ot(n?.type||j)}> component:
1765
+ var dist_default2 = `var We=Symbol.for("kiru.signal"),_t=Symbol.for("kiru.context"),oe=Symbol.for("kiru.contextProvider"),X=Symbol.for("kiru.fragment"),Ke=Symbol.for("kiru.error"),k=Symbol.for("kiru.hmrAccept"),Ce=Symbol.for("kiru.memo"),ie=Symbol.for("kiru.errorBoundary"),Ct=Symbol.for("kiru.suspenseThrow"),Ue=50;var D=2,A=4,pe=8,V=16,Te=32,he=64,se=128,Tt=/^on:?/;var Be=new Set(["animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","path","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","title","tspan","use"]),qe=new Set(["allowfullscreen","autofocus","autoplay","async","checked","compact","controls","contenteditable","declare","default","defer","disabled","download","hidden","inert","ismap","multiple","nohref","noresize","noshade","novalidate","nowrap","open","popover","readonly","required","sandbox","scoped","selected","sortable","spellcheck","translate","wrap"]),At=new Map([["acceptCharset","accept-charset"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["httpEquiv","http-equiv"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]);var we={internalProps:["children","ref","key","innerHTML"],isEvent:e=>e.startsWith("on"),isProperty:e=>!we.internalProps.includes(e)&&!we.isEvent(e)};function Mt(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():At.get(e)||e}}function Ge(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})}var Xe="production";if(Xe!=="development"&&Xe!=="production")throw new Error("NODE_ENV must either be set to development or production.");var l=Xe==="development";var M={current:null},Y={current:0},C={current:"window"in globalThis?"dom":"string"};function T(e){let t=e;if(l)for(;"__next"in t;)t=t.__next;return t}function w(){return C.current==="dom"||C.current==="hydrate"}var Rt,_=class extends Error{constructor(t){let r=typeof t=="string"?t:t.message;super(r),this[Rt]=!0,typeof t!="string"&&(l&&t?.vNode&&(this.customNodeStack=Kr(t.vNode)),this.fatal=t?.fatal)}static isKiruError(t){return t instanceof Error&&t[Ke]===!0}};Rt=Ke;function Kr(e){let t=e,r=[];for(;t&&t.parent;)typeof t.type=="function"?r.push(Ur(t.type)):typeof t.type=="string"&&r.push(t.type),t=t.parent;let n=typeof e.type=="function"?e:Ye(e,o=>typeof o.type=="function");return\`The above error occurred in the <\${Ot(n?.type||j)}> component:
1766
1766
 
1767
1767
  \${r.map(o=>\` at \${o}\`).join(\`
1768
1768
  \`)}
1769
- \`}function Ur(e){let t=Ot(e);if(l){let r=Br(e);r&&(t=\`\${t} (\${r})\`)}return t}function Ot(e){return e.displayName??(e.name||"Anonymous Function")}function Br(e){return e.toString().match(/\\/\\/ \\[kiru_devtools\\]:(.*)/)?.[1]??null}function ae(e){return typeof e=="object"&&e!==null&&"type"in e}function Je(e){return e===X||e===oe||e===ie}function Pt(e){return e.type===X}function J(e){let t=e;for(;t;){if(t.app)return e.app=t.app;t=t.parent}return null}function be(e){let{props:{children:t,...r},memoizedProps:n,index:o}=e;e.prev={props:r,memoizedProps:n,index:o},e.flags&=~(D|A|pe)}function Dt(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 W(e,t){t(e);let r=e.child;for(;r;)t(r),r.child&&W(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 Lt(e){return Ye(e,t=>t.type===ie)}function Ze(e){if("children"in e.props&&e.props.innerHTML)throw new _({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 _({message:\`Cannot use both bind:\${t} and \${t} on an element\`,vNode:e})}function Vt(e){return typeof e=="string"||typeof e=="number"}function $t(e){return typeof e=="function"||typeof e=="object"&&!!e&&"current"in e||y.isSignal(e)}var Gr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz-";function Ae(e=10,t=Gr){let r="";for(let n=0;n<e;n++)r+=t[Math.random()*t.length|0];return r}var j=Object.freeze(()=>{});var ye={stack:new Array,current:function(){return this.stack[this.stack.length-1]}},$=new Map,H=new Map;function ee(e,t=!1){return y.isSignal(e)?t?e.value:e.peek():e}var Qe=()=>{$.forEach(e=>e()),$.clear()};var le={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){Ht(e,!0),this.eventDeferrals.set(e,[])},resetEvents:function(e){this.eventDeferrals.delete(e)},releaseEvents:function(e){Ht(e,!1);let t=this.eventDeferrals.get(e);for(;t?.length;)t.shift()()}},qr=e=>{let t=e.target;!e.isTrusted||!t||le.eventDeferrals.get(t)?.push(()=>t.dispatchEvent(e))},Ht=(e,t)=>{for(let r in e)if(r.startsWith("on")){let n=r.substring(2);e[t?"addEventListener":"removeEventListener"](n,qr,{passive:!0})}};var it=!1,et=!1,Ft=e=>{e.preventDefault(),e.stopPropagation(),et=!0},ue=null;function Nt(){it=!0,ue=document.activeElement,ue&&ue!==document.body&&ue.addEventListener("blur",Ft)}function It(){et&&(ue.removeEventListener("blur",Ft),ue.isConnected&&ue.focus(),et=!1),it=!1}function tt(e,t){if(typeof e=="function"){e(t);return}if(y.isSignal(e)){e.sneak(t),e.notify({filter:r=>typeof r=="function"});return}e.current=t}function zt(e){let t=e.type;return t=="#text"?Xr(e):Be.has(t)?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t)}function Xr(e){let{nodeValue:t}=e.props;if(!y.isSignal(t))return document.createTextNode(t);let r=t.peek()??"",n=document.createTextNode(r);return nt(e,n,t),n}function Yr(e,t,r){let n=rt.get(e)??{},o=n[t]=s=>{if(it){s.preventDefault(),s.stopPropagation();return}r(s)};return rt.set(e,n),o}var rt=new WeakMap;function jt(e){let t=e.dom,r=e.prev?.props??{},n=e.props??{},o=new Set([...Object.keys(r),...Object.keys(n)]),s=C.current==="hydrate";o.forEach(i=>{let a=r[i],u=n[i];if(we.internalProps.includes(i)&&i!=="innerHTML"){i==="ref"&&a!==u&&(a&&tt(a,null),u&&tt(u,t));return}if(we.isEvent(i)){if(a!==u||C.current==="hydrate"){let c=i.replace(Tt,""),m=c==="focus"||c==="blur";i in r&&t.removeEventListener(c,m?rt.get(e)?.[c]:a),i in n&&t.addEventListener(c,m?Yr(e,c,u):u)}return}if(!(t instanceof Text)){if(a===u||s&&t.getAttribute(i)===u)return;if(y.isSignal(a)&&e.cleanups){let c=e.cleanups[i];c&&(c(),delete e.cleanups[i])}if(y.isSignal(u))return en(e,t,i,u,a);Me(t,i,u,a);return}y.isSignal(u)||t.nodeValue!==u&&(t.nodeValue=u)})}function Jr(e){return e.multiple?Array.from(e.selectedOptions).map(t=>t.value):e.value}function Wt(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 Zr={value:"input",checked:"change",open:"toggle",volume:"volumechange",playbackRate:"ratechange",currentTime:"timeupdate"},Qr=["progress","meter","number","range"];function en(e,t,r,n,o){let s=e.cleanups??(e.cleanups={}),[i,a]=r.split(":");if(i!=="bind")return s[r]=n.subscribe((p,v)=>{Me(t,r,p,v),l&&window.__kiru.profilingContext?.emit("signalAttrUpdate",J(e))}),Me(t,r,n.peek(),ee(o));let u=Zr[a];if(!u){l&&console.error(\`[kiru]: \${a} is not a valid element binding attribute.\`);return}let c=t instanceof HTMLSelectElement,m=c?p=>Wt(t,p):p=>t[a]=p,E=p=>{m(p),l&&window.__kiru.profilingContext?.emit("signalAttrUpdate",J(e))},S=p=>{n.sneak(p),n.notify({filter:v=>v!==E})},d;if(a==="value"){let p=Qr.indexOf(t.type)!==-1;d=()=>{let v=t.value;c?v=Jr(t):typeof n.peek()=="number"&&p&&(v=t.valueAsNumber),S(v)}}else d=p=>{let v=p.target[a];a==="currentTime"&&n.peek()===v||S(v)};t.addEventListener(u,d);let g=n.subscribe(E);return s[r]=()=>{t.removeEventListener(u,d),g()},Me(t,a,n.peek(),ee(o))}function nt(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 Kt(e){let t=le.nextChild();if(!t)throw new _({message:"Hydration mismatch - no node found",vNode:e});let r=t.nodeName;if(Be.has(r)||(r=r.toLowerCase()),e.type!==r)throw new _({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)){jt(e);return}y.isSignal(e.props.nodeValue)&&nt(e,t,e.props.nodeValue);let n=e,o=e.sibling;for(;o&&o.type==="#text";){let s=o;le.bumpChildIndex();let i=String(ee(n.props.nodeValue)??""),a=n.dom.splitText(i.length);s.dom=a,y.isSignal(s.props.nodeValue)&&nt(s,a,s.props.nodeValue),n=o,o=o.sibling}}function Ut(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 tn(e,t,r){let n=Ge.has(t);Ut(e,t,r,n)||e.setAttribute(t,n&&typeof r=="boolean"?"":String(r))}var rn=["INPUT","TEXTAREA"],nn=e=>rn.indexOf(e.nodeName)>-1;function Me(e,t,r,n){if(r!==n)switch(t){case"style":return an(e,r,n);case"className":return sn(e,r);case"innerHTML":return on(e,r);case"muted":e.muted=!!r;return;case"value":if(e.nodeName==="SELECT")return Wt(e,r);let o=r==null?"":String(r);if(nn(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 tn(e,Mt(t),r)}}function on(e,t){if(t==null||typeof t=="boolean"){e.innerHTML="";return}e.innerHTML=String(t)}function sn(e,t){let r=ee(t);if(!r)return e.removeAttribute("class");e.setAttribute("class",r)}function an(e,t,r){if(Ut(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 ln(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 _({message:"No DOM parent found while attempting to place node.",vNode:e})}return t}function un(e,t){let{node:r,lastChild:n}=t,o=e.dom;if(n){n.after(o);return}let s=Bt(e,r);if(s){r.dom.insertBefore(o,s);return}r.dom.appendChild(o)}function Bt(e,t){let r=e;for(;r;){let n=r.sibling;for(;n;){if(!(n.flags&(A|V))){let o=cn(n);if(o?.isConnected)return o}n=n.sibling}if(r=r.parent,!r||r.flags&V||r===t)return}}function cn(e){let t=e;for(;t;){if(t.dom)return t.dom;if(t.flags&V)return;t=t.child}}function Gt(e){if(C.current==="hydrate")return W(e,be);let t={node:e.dom?e:ln(e)};ot(e,t,(e.flags&A)>0),e.dom&&!(e.flags&V)&&qt(e,t,!1),be(e)}function ot(e,t,r){let n=e.child;for(;n;){if(n.flags&he){n.flags&A&&fn(n,t),be(n),n=n.sibling;continue}n.dom?(ot(n,{node:n},!1),n.flags&V||qt(n,t,r)):ot(n,t,(n.flags&A)>0||r),be(n),n=n.sibling}}function qt(e,t,r){(r||!e.dom.isConnected||e.flags&A)&&un(e,t),(!e.prev||e.flags&D)&&jt(e),t.lastChild=e.dom}function Xt(e){e===e.parent?.child&&(e.parent.child=e.sibling);let t;l&&(t=J(e)),W(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&&tt(a,null),i.isConnected&&!(r.flags&V)&&i.remove(),delete r.dom)}),e.parent=null}function fn(e,t){if(!e.child)return;let r=[];if(Yt(e.child,r),r.length===0)return;let{node:n,lastChild:o}=t;if(o)o.after(...r);else{let s=Bt(e,n),i=n.dom;s?s.before(...r):i.append(...r)}t.lastChild=r[r.length-1]}function Yt(e,t){let r=e;for(;r;)r.dom?t.push(r.dom):r.child&&Yt(r.child,t),r=r.sibling}function Jt(e){return typeof e=="function"&&typeof e[Ce]?.arePropsEqual=="function"}function f(e,t=null,...r){if(e===Z)return Z({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(Jt(e)&&(n.flags|=Te,n.arePropsEqual=e[Ce].arePropsEqual),t!==null){let{key:s,ref:i,...a}=t;Vt(s)&&(n.props.key=s.toString()),$t(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 Z({children:e,key:t}){return f(X,t?{key:t}:null,e)}var lt;function Pe(e,t){return l&&(lt=J(e)),Array.isArray(t)?(l&&(ir in t&&hn(e,t),gn(e,t)),dn(e,t)):pn(e,t)}function pn(e,t){let r=e.child;if(r===null)return tr(e,t);let n=r.sibling,o=Qt(e,r,t);if(o!==null)return r&&r!==o&&!o.prev?at(e,r):n&&at(e,n),o;{let s=sr(r),i=rr(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)}Re(i,0,0)}return s.forEach(a=>Oe(e,a)),i}}function dn(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=Qt(e,o,t[a]);if(c===null){o===null&&(o=s);break}o&&!c.prev&&Oe(e,o),i=Re(c,i,a),n===null?r=c:n.sibling=c,n=c,o=s}if(a===t.length)return at(e,o),r;if(o===null){for(;a<t.length;a++){let c=tr(e,t[a]);c!==null&&(i=Re(c,i,a),n===null?r=c:n.sibling=c,n=c)}return r}let u=sr(o);for(;a<t.length;a++){let c=rr(u,e,a,t[a]);if(c!==null){let m=c.prev;if(m!==null){let E=m.props.key;u.delete(E===void 0?m.index:E)}i=Re(c,i,a),n===null?r=c:n.sibling=c,n=c}}return u.forEach(c=>Oe(e,c)),r}function Qt(e,t,r){let n=t?.props.key;return nr(r)?n!==void 0||t?.type==="#text"&&y.isSignal(t.props.nodeValue)?null:Zt(e,t,""+r):y.isSignal(r)?t&&t.props.nodeValue!==r?null:Zt(e,t,r):ae(r)?r.props.key!==n?null:mn(e,t,r):Array.isArray(r)?n!==void 0?null:(l&&ut(r),er(e,t,r)):null}function Zt(e,t,r){if(t===null||t.type!=="#text"){l&&U();let o=f("#text",{nodeValue:r});return K(o,e),o}return l&&ve(),t.props.nodeValue!==r&&(t.props.nodeValue=r,t.flags|=D),t.sibling=null,t}function mn(e,t,r){let{type:n,props:o}=r;if(l&&typeof n=="function"&&(n=T(n)),n===X)return er(e,t,o.children||[],o);if(t?.type===n)return l&&ve(),t.index=0,t.sibling=null,typeof n=="string"?or(t.props,o)&&(t.flags|=D):t.flags|=D,t.props=o,t.memoizedProps=r.memoizedProps,t;l&&U();let s=f(n,o);return K(s,e),s}function er(e,t,r,n={}){if(t===null||t.type!==X){l&&U();let o=f(X,{children:r,...n});return K(o,e),o}return l&&ve(),t.props={...t.props,...n,children:r},t.flags|=D,t.sibling=null,t}function tr(e,t){if(nr(t)){l&&U();let r=f("#text",{nodeValue:""+t});return K(r,e),r}if(y.isSignal(t)){l&&U();let r=f("#text",{nodeValue:t});return K(r,e),r}if(ae(t)){l&&U();let r=f(t.type,t.props);return K(r,e),r.flags|=A,r}if(Array.isArray(t)){l&&(U(),ut(t));let r=Z({children:t});return K(r,e),r}return null}function Re(e,t,r){e.index=r;let n=e.prev;if(n!==null){let o=n.index;return o<t?(e.flags|=A,t):o}else return e.flags|=A,t}function rr(e,t,r,n){if(y.isSignal(n)||typeof n=="string"&&n!==""||typeof n=="number"||typeof n=="bigint"){let s=e.get(r);if(s){if(s.props.nodeValue===n)return s;s.type==="#text"&&y.isSignal(s.props.nodeValue)&&s.cleanups?.nodeValue?.()}l&&U();let i=f("#text",{nodeValue:n});return K(i,t),i.flags|=A,i.index=r,i}if(ae(n)){let{type:s,props:i}=n,a=i.key,u=e.get(a===void 0?r:a);if(u?.type===s)return l&&ve(),typeof s=="string"?or(u.props,i)&&(u.flags|=D):u.flags|=D,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|=A,c.index=r,c}if(Array.isArray(n)){let s=e.get(r);if(l&&ut(n),s)return l&&ve(),s.flags|=D,s.props.children=n,s;l&&U();let i=Z({children:n});return K(i,t),i.flags|=A,i.index=r,i}return null}function nr(e){return typeof e=="string"&&e!==""||typeof e=="number"||typeof e=="bigint"}function or(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 ve(){"window"in globalThis&&window.__kiru.profilingContext?.emit("updateNode",lt)}function U(){"window"in globalThis&&window.__kiru.profilingContext?.emit("createNode",lt)}var ir=Symbol("kiru:marked-list-child");function ut(e){Object.assign(e,{[ir]:!0})}function sr(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 Oe(e,t){e.deletions===null?e.deletions=[t]:e.deletions.push(t)}function at(e,t){for(;t;)Oe(e,t),t=t.sibling}function gn(e,t){let r=new Set,n=!1;for(let o of t){if(!ae(o))continue;let s=o.props.key;if(typeof s=="string"){if(!n&&r.has(s)){let i=lr(e);ar(\`\${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 hn(e,t){let r=!1,n=!1;for(let o of t){if(!ae(o))continue;typeof o.props.key=="string"?r=!0:n=!0}if(n&&r){let o=lr(e);ar(\`\${o} component produced a child in a list without a valid key prop\`)}}function ar(e){let t=\`[kiru]: \${e}. See https://kirujs.dev/keys-warning for more information.\`;console.error(t)}var st=new WeakMap;function lr(e){if(st.has(e))return st.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 st.set(e,n),n}var B,G=[],de=!1,ft=[],De=[],pt=!1,dt=!1,mt=!1,gt=0,ur=[],ht=[],cr=-1;function bt(e){if(de){ft.push(e);return}e()}function Le(){de&&(window.cancelAnimationFrame(cr),fr())}function yt(e){e.flags|=se,G.push(e),de=!0,Le()}function O(e){if(C.current==="hydrate")return bt(()=>wt(e));wt(e)}function wn(){de||(de=!0,cr=window.requestAnimationFrame(fr))}function bn(){for(de=!1;ft.length;)ft.shift()()}function wt(e){if(pt&&(dt=!0),M.current===e){l&&window.__kiru.profilingContext?.emit("updateDirtied",B),mt=!0;return}if(!(e.flags&(se|pe))){if(e.flags|=se,!G.length)return G.push(e),wn();G.push(e)}}function yn(e){W(e,t=>t.flags|=pe),De.push(e)}var vn=(e,t)=>t.depth-e.depth,te=null;function fr(){if(l){let t=De[0]??G[0];t?(B=J(t),window.__kiru.profilingContext?.beginTick(B)):B=null}let e=1;for(Nt();G.length;){G.length>e&&G.sort(vn),te=G.shift(),e=G.length;let t=te.flags;if(!(t&pe)&&t&se){let r=te;for(;r=xn(r););for(;De.length;)Xt(De.pop());Gt(te),te.flags&=~se}}if(It(),pt=!0,ct(ur),pt=!1,dt)return _n(),ct(ht),dt=!1,gt++,l&&(window.__kiru.profilingContext?.endTick(B),window.__kiru.profilingContext?.emit("updateDirtied",B)),Le();gt=0,bn(),ct(ht),l&&(window.__kiru.emit("update",B),window.__kiru.profilingContext?.emit("update",B),window.__kiru.profilingContext?.endTick(B))}function xn(e){let t=!0;try{typeof e.type=="string"?kn(e):Je(e.type)?En(e):t=Sn(e)}catch(n){l&&window.__kiru.emit("error",B,n instanceof Error?n:new Error(String(n)));let o=Lt(e);if(o){let s=o.error=n instanceof Error?n:new Error(String(n));return o.props.onError?.(s),o.depth<te.depth&&(te=o),o}if(_.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(yn),e.deletions=null),t&&e.child)return e.child;let r=e;for(;r;){if(r.immediateEffects&&(ur.push(...r.immediateEffects),r.immediateEffects=void 0),r.effects&&(ht.push(...r.effects),r.effects=void 0),r===te)return;if(r.sibling)return r.sibling;r=r.parent,C.current==="hydrate"&&r?.dom&&le.pop()}}function En(e){let{props:t,type:r}=e,n=t.children;if(r===oe){let{props:{dependents:o,value:s},prev:i}=e;o.size&&i&&i.props.value!==s&&o.forEach(wt)}else if(r===ie){let o=e,{error:s}=o;s&&(n=typeof t.fallback=="function"?t.fallback(s):t.fallback,delete o.error)}e.child=Pe(e,n)}function Sn(e){let{type:t,props:r,subs:n,prev:o,flags:s}=e;if(s&Te){if(e.memoizedProps=r,o?.memoizedProps&&e.arePropsEqual(o.memoizedProps,r)&&!e.hmrUpdated)return e.flags|=he,!1;e.flags&=~he}try{M.current=e;let i,a=0;do{if(e.flags&=~se,mt=!1,Y.current=0,n&&(n.forEach(u=>u()),n.clear()),l){if(i=T(t)(r),e.hmrUpdated&&e.hooks&&e.hookSig){let u=e.hooks.length;if(Y.current<u){for(let c=Y.current;c<u;c++)e.hooks[c].cleanup?.();e.hooks.length=Y.current,e.hookSig.length=Y.current}}if(delete e.hmrUpdated,++a>Ue)throw new _({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(mt);return e.child=Pe(e,i),!0}finally{M.current=null}}function kn(e){let{props:t,type:r}=e;l&&Ze(e),e.dom||(C.current==="hydrate"?Kt(e):e.dom=zt(e),l&&e.dom instanceof Element&&(e.dom.__kiruNode=e)),r!=="#text"&&(e.child=Pe(e,t.children),e.child&&C.current==="hydrate"&&le.push(e.dom))}function _n(){if(gt>Ue)throw new _("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 ct(e){for(let t=0;t<e.length;t++)e[t]();e.length=0}var pr;(function(e){e.Start="start",e.End="end"})(pr||(pr={}));var me=null,dr=new Set;function h(e,t,r){let n=M.current;if(n||Cn(e),l&&me!==null&&!dr.has(e+me))throw dr.add(e+me),new _({message:\`Nested primitive "useHook" calls are not supported. "\${e}" was called inside "\${me}". 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=Y.current++,i=n.hooks?.at(s);if(l){me=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:()=>O(n),queueEffect:o,vNode:n,index:s})}catch(u){throw u}finally{me=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:()=>O(n),queueEffect:o,vNode:n,index:s})}catch(a){throw a}}function Cn(e){throw new _(\`Hook "\${e}" must be used at the top level of a component or inside another composite hook.\`)}function F(e){e.cleanup&&(e.cleanup(),e.cleanup=void 0)}function R(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 mr,y=class e{constructor(t,r){this[mr]=!0,this.$id=Ae(),this.$value=t,r&&(this.displayName=r),l?(H.set(this.$id,new Set),this.$initialValue=qe(t),this[k]={provide:()=>this,inject:n=>{H.get(this.$id)?.clear?.(),H.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=T(this);return e.entangle(t),t.$value}return e.entangle(this),this.$value}set value(t){if(l){let r=T(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?T(this).$value:this.$value}sneak(t){if(l){let r=T(this);r.$prevValue=r.$value,r.$value=t;return}this.$prevValue=this.$value,this.$value=t}toString(){if(this.onBeforeRead?.(),l){let t=T(this);return e.entangle(t),\`\${t.$value}\`}return e.entangle(this),\`\${this.$value}\`}subscribe(t){return l?(H.get(this.$id).add(t),()=>H.get(this.$id)?.delete(t)):(this.$subs.add(t),()=>this.$subs.delete(t))}notify(t){if(l)return H.get(this.$id)?.forEach(r=>{if(t?.filter&&!t.filter(r))return;let{$value:n,$prevValue:o}=T(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&&We in t}static subscribers(t){return l?H.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=M.current,n=ye.current();if(n){(!r||r&&w())&&n.set(t.$id,t);return}if(!r||!w())return;let o=t.subscribe(()=>O(r));(r.subs??(r.subs=new Set)).add(o)}static configure(t,r){t.onBeforeRead=r}static dispose(t){if(t.$isDisposed=!0,l){H.delete(t.$id);return}t.$subs.clear()}};mr=We;var Ve=(e,t)=>new y(e,t),x=(e,t)=>h("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=()=>y.dispose(r.signal),r.signal=new y(e,t)),r.signal});function $e(e){let{id:t,subs:r,fn:n,deps:o=[],onDepChanged:s}=e,i;$.delete(t);let a=!!M.current&&!w();a||(i=new Map,ye.stack.push(i));let u=n(...o.map(c=>c.value));if(!a){for(let[m,E]of r)i.has(m)||(E(),r.delete(m));let c=()=>{$.size||queueMicrotask(Qe),$.set(t,s)};for(let[m,E]of i){if(r.has(m))continue;let S=E.subscribe(c);r.set(m,S)}ye.stack.pop()}return u}var xe=class e extends y{constructor(t,r){if(super(void 0,r),this.$getter=t,this.$unsubs=new Map,this.$isDirty=!0,l){let n=this[k].inject;this[k]={provide:()=>this,inject:o=>{n(o),e.stop(o),this.$isDirty=o.$isDirty},destroy:()=>{}}}y.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),y.dispose(t)}static stop(t){let{$id:r,$unsubs:n}=T(t);$.delete(r),n.forEach(o=>o()),n.clear(),t.$isDirty=!0}static run(t){let r=T(t),{$id:n,$getter:o,$unsubs:s}=r,i=$e({id:n,subs:s,fn:()=>o(r.$value),onDepChanged:()=>{if(r.$isDirty=!0,l){if(!H?.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}},gr=(e,t)=>new xe(e,t),vt=(e,t)=>h("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=()=>xe.dispose(r.signal),r.signal=gr(e,t)),r.signal));var Ee=class e{constructor(t,r){if(this.id=Ae(),this.getter=t,this.deps=r,this.unsubs=new Map,this.isRunning=!1,this.cleanup=null,l&&(this[k]={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(){$.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(t),{id:n,getter:o,unsubs:s,deps:i}=r;r.cleanup=$e({id:n,subs:s,fn:o,deps:i,onDepChanged:()=>{r.cleanup?.(),e.run(r)}})??null}};function hr(e,t){if(typeof e=="function")return new Ee(e);let r=e,n=t;return new Ee(n,r)}function Se(e,t){if(w())return h("useWatch",{watcher:null},({hook:r,isInit:n,isHMR:o})=>{if(l&&o&&(r.cleanup?.(),n=!0),n){let s=r.watcher=hr(e,t);r.cleanup=()=>s.stop()}return r.watcher})}function wr(e){return!!e&&(typeof e=="object"||typeof e=="function")&&k in e&&typeof e[k]=="object"&&!!e[k]}function br(){let e=new Map,t=null,r=null,n=!1,o=()=>n,s=!1,i=[],a=[];return{register:S=>{if(r===null)throw new Error("[kiru]: HMR could not register: No active module");let d=new Set;for(let[g,p]of Object.entries(S)){let v=r.hotVars.get(g);if(p.value.__devtoolsFileLink=p.link,typeof p.value=="function"&&v?.value&&(v.value.__next=p.value),p.type==="createStore"&&window.__kiru.stores.add(g,p.value),r.hotVars.set(g,p),!!v){if(wr(v.value)&&wr(p.value)){p.value[k].inject(v.value[k].provide()),v.value[k].destroy();continue}v.type==="component"&&p.type==="component"&&window.__kiru.apps.forEach(fe=>{W(fe.rootNode,ge=>{ge.type===v.value&&(ge.type=p.value,d.add(fe),ge.hmrUpdated=!0)})})}}if(d.forEach(g=>g.rootNode&&O(g.rootNode)),n=!1,i.length){let g=0;for(;g<i.length;g++){let p=i[g],v=r.unnamedWatchers[g];v&&(p[k].inject(v[k].provide()),v[k].destroy()),r.unnamedWatchers[g]=p}for(;g<r.unnamedWatchers.length;g++)r.unnamedWatchers[g][k].destroy();r.unnamedWatchers.length=i.length,i.length=0}r=null,t=null},prepare:S=>{let d=e.get(S);if(n=!!d,!d)d={hotVars:new Map,unnamedWatchers:[]},e.set(S,d);else for(;a.length;)a.shift()();r=d,t=S},isReplacement:o,signals:{registerNextWatch(){s=!0},isWaitingForNextWatchCall(){return s},pushWatch(S){i.push(S),s=!1}},onHmr:S=>{a.push(S)},getCurrentFilePath(){return t}}}function yr(){let e=new Map,t=new Map;return{appStats:t,emit:(r,n)=>{e.get(r)?.forEach(o=>o(n))},addEventListener:(r,n)=>{e.has(r)||e.set(r,new Set),e.get(r).add(n)},removeEventListener:(r,n)=>{e.has(r)&&e.get(r).delete(n)},mountDuration:r=>{let n=t.get(r);return n?n.mountDuration:0},totalTicks:r=>{let n=t.get(r);return n?n.totalTicks:0},lastTickDuration:r=>{let n=t.get(r);if(!n)return 0;let o=n.timestamps[n.timestamps.length-1];return o.end-o.start},averageTickDuration:r=>{let n=t.get(r);if(!n)return 0;let o=n.timestamps.filter(s=>s.end!==1/0);return o.reduce((s,i)=>s+(i.end-i.start),0)/o.length},beginTick:r=>{t.has(r)||t.set(r,{mountDuration:1/0,timestamps:[],totalTicks:0});let n=t.get(r);n.totalTicks++,n.timestamps.push({start:performance.now(),end:1/0})},endTick:r=>{if(!t.has(r))return;let n=t.get(r),o=n.timestamps[n.timestamps.length-1];o.end=performance.now(),n.mountDuration===1/0&&(n.mountDuration=o.end-o.start),n.timestamps.length>100&&n.timestamps.shift()}}}function Tn(){let e=new Map,t=new Set;function r(i,a){e.has(i)||(e.set(i,a),o())}function n(i){e.has(i)&&(e.delete(i),o())}function o(){let i=Object.fromEntries(e);t.forEach(a=>a(i))}function s(i){return t.add(i),i(Object.fromEntries(e)),()=>t.delete(i)}return{add:r,delete:n,subscribe:s,get size(){return e.size}}}function vr(){let e=new Set,t=new Map;function r(i,a,u){t.get(i)?.forEach(c=>c(a,u))}function n(i,a){t.has(i)||t.set(i,new Set),t.get(i).add(a)}function o(i,a){t.get(i)?.delete(a)}let s={get apps(){return Array.from(e)},emit:r,on:n,off:o};return n("mount",i=>e.add(i)),n("unmount",i=>e.delete(i)),l&&(s.HMRContext=br(),s.profilingContext=yr(),s.stores=Tn()),s}var An=0;function xr(e,t,r){var n;if(l&&t.__kiruNode)throw new Error("[kiru]: container in use - call unmount on the previous app first.");let o=f(t.nodeName.toLowerCase(),{});l&&(t.__kiruNode=o),o.dom=t,o.flags|=V;let s=An++,i=r?.name??\`App-\${s}\`,a={id:s,name:i,rootNode:o,render:u,unmount:c};function u(m){o.props.children=m,yt(o)}function c(){o.props.children=null,yt(o),l&&(delete t.__kiruNode,delete o.app),window.__kiru.emit("unmount",a)}return l&&(o.app=a),(n=globalThis.window).__kiru??(n.__kiru=vr()),u(e),window.__kiru.emit("mount",a),a}function ce(e){return w()?h("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 Er(e){let t={[_t]:!0,Provider:({value:r,children:n})=>{let[o]=ce(()=>new Set);return f(oe,{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[k]={inject:n=>{let o=t.Provider;window.__kiru.apps.forEach(s=>{W(s.rootNode,i=>{i.type===n.Provider&&(i.type=o,i.hmrUpdated=!0,O(i))})})},destroy:()=>{},provide:()=>t}}return t}function Q(e,t){return w()?h("useCallback",{callback:e,deps:t},({hook:r,isHMR:n})=>(l&&(r.dev={devtools:{get:()=>({callback:r.callback,dependencies:r.deps})}},n&&(r.deps=[])),R(t,r.deps)&&(r.deps=t,r.callback=e),r.callback)):e}function N(e,t){if(w())return h("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||R(t,r.deps))&&(r.deps=t,F(r),s(()=>{let i=e();typeof i=="function"&&(r.cleanup=i)}))})}function re(e,t){if(w())return h("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||R(t,r.deps))&&(r.deps=t,F(r),s(()=>{let i=e();typeof i=="function"&&(r.cleanup=i)},{immediate:!0}))})}function ke(e,t){return w()?h("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||R(t,r.deps))&&(r.deps=t,r.value=e()),r.value)):e()}function I(e){return w()?h("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 Pa="window"in globalThis?window.__KIRU_LAZY_CACHE??(window.__KIRU_LAZY_CACHE=new Map):new Map;function _r(e){let[t,r]=ce(e.initialState||"exited"),n=I(null);re(()=>{e.in&&t!=="entered"&&t!=="entering"?(o("entering"),s("entered")):!e.in&&t!=="exited"&&t!=="exiting"&&(o("exiting"),s("exited"))},[e.in,t]),N(()=>()=>kr(n.current),[]);let o=Q(i=>{kr(n.current),r(i),(i==="entered"||i==="exited")&&e.onTransitionEnd&&e.onTransitionEnd(i)},[]),s=Q(i=>{n.current=window.setTimeout(()=>o(i),Rn(i,e.duration))},[e.duration]);return e.element(t)}var Sr=150;function Rn(e,t){if(typeof t=="number")return t;switch(e){case"entered":return t?.in??Sr;case"exited":return t?.out??Sr}}function kr(e){e!=null&&window.clearTimeout(e)}var Cr=()=>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 He="kiru.devtools.anchorPosition",Tr={x:-16,y:-16};var xt=(e,t,r)=>{if(!t.current)return{...Tr};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}},Ar=e=>{if(e==null)return null;let t=null,r=e?.__kiruNode?.parent;for(;r;){if(typeof r.type=="function"&&!Pt(r)){t=r;break}r=r.parent}return t},Mr=(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 Or={arrayChunkSize:10,objectKeysChunkSize:100};function Pr(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"&&!Pr(e[n],t[n]))return!1;return!0}var Dn={...Or},Rr=localStorage.getItem("kiru.devtools.userSettings");if(Rr)try{let e=JSON.parse(Rr);Pr(Or,e)&&(Dn=e)}catch(e){console.error("kiru.devtools.userSettings error",e)}var _u=Er({userSettings:null,saveUserSettings:()=>{}});var Pu=Object.freeze(()=>{});var Hn="kiru-devtools";"window"in globalThis&&(window.__devtoolsSelection??(window.__devtoolsSelection=null));var Et=class extends BroadcastChannel{send(t){super.postMessage(t)}removeEventListener(t){return super.removeEventListener("message",t)}addEventListener(t){return super.addEventListener("message",t)}},P=new Et(Hn);var tc=Symbol.for("devtools.hookGroup");var L=(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 Fe=()=>{let e=x({x:0,y:0}),t=x({x:0,y:0}),r=x({x:0,y:0});return L("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 Ne="window"in globalThis&&"ResizeObserver"in globalThis.window,Dr=(e,t,r=void 0)=>w()?Ne?h("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(()=>{R([e.current],o.deps)&&(o.deps=[e.current],o.resizeObserver?.disconnect?.(),e.current&&o.resizeObserver?.observe(e.current,r))}),{isSupported:Ne,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:()=>{F(o)}})):{isSupported:Ne,start:()=>{},stop:()=>{}}:{isSupported:Ne,start:()=>{},stop:()=>{}};var Ie="window"in globalThis&&"MutationObserver"in globalThis.window,Lr=(e,t,r=void 0)=>w()?Ie?h("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}):R([e.current],o.deps)&&(o.deps=[e.current],o.mutationObserver?.disconnect?.(),e.current&&o.mutationObserver?.observe(e.current,r)),{isSupported:Ie,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:()=>{F(o)}})):{isSupported:Ie,start:()=>{},stop:()=>{}}:{isSupported:Ie,start:()=>{},stop:()=>{}};var ze=(e,t={windowScroll:!0,windowResize:!0})=>{let r=t?.windowScroll??!0,n=t?.windowResize??!0,o=t.immediate??!0,s=x(0),i=x(0),a=x(0),u=x(0),c=x(0),m=x(0),E=x(0),S=x(0),d=()=>{let g=e.current;if(!g){s.value=0,i.value=0,a.value=0,u.value=0,c.value=0,m.value=0,E.value=0,S.value=0;return}let p=g.getBoundingClientRect();s.value=p.width,i.value=p.height,a.value=p.top,u.value=p.right,c.value=p.bottom,m.value=p.left,E.value=p.x,S.value=p.y};return Dr(e,d),Lr(e,d,{attributeFilter:["style","class"]}),L("scroll",()=>{r&&d()},{capture:!0,passive:!0}),L("resize",()=>{n&&d()},{passive:!0}),re(()=>{o&&d()},[]),{width:s,height:i,top:a,right:u,bottom:c,left:m,x:E,y:S,update:d}};var Vr=(e,t)=>{if(!w())return{isActive:t?.immediate??!1,start:()=>null,stop:()=>null};let r=t?.fpsLimit?1e3/t.fpsLimit:null;return h("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:()=>{F(o),s()}}))};var $r=e=>{let{x:t,y:r,multiple:n,immediate:o=!0}=e,s=x(null),a=Vr(()=>{s.value=n?document.elementsFromPoint(t,r)??[]:document.elementFromPoint(t,r)??null},{immediate:o});return{element:s,...a}};var Hr=()=>{let{mouse:e}=Fe(),t=x(null),r=I(null),n=I(null),o=ze(r),s=x({x:-16,y:-16}),i=x({x:-16,y:-16}),a=x({width:window.innerWidth,height:window.innerHeight}),u=x("bottom"),c=I(null);re(()=>{let d=localStorage.getItem(He);if(d==null)return;let g=JSON.parse(d);a.value.width=window.innerWidth,a.value.height=window.innerHeight,u.value=g.snapSide,i.value=xt(g,n,o)},[Math.round(o.width.value),Math.round(o.height.value)]);let m=vt(()=>{let{x:d,y:g}=e.value;if(t.value===null)return null;let{x:p,y:v}=t.value;return{x:d-p,y:g-v}});L("dragstart",d=>{d.preventDefault(),t.value={x:d.x,y:d.y},s.value=i.value},{ref:()=>r.current}),L("mouseup",()=>{c.current&&(clearTimeout(c.current),c.current=null),t.peek()&&(t.value=null,localStorage.setItem(He,JSON.stringify({...i.value,...a.value,snapSide:u.value})))});let E=Q(()=>{if(n.current==null)return;let d=n.current.offsetWidth;if(u.value==="right"){let g=Math.min(-16,i.value.y);i.value={x:-16,y:Math.max(g,(window.innerHeight-o.height.value)*-1+16)}}else if(u.value==="left"){let g=Math.min(0,i.value.y);i.value={x:(d-o.width.value)*-1+16,y:Math.max(g,(window.innerHeight-o.height.value)*-1+16)}}else if(u.value==="top"){let g=Math.min(-16,i.value.x);i.value={x:Math.max(g,(d-o.width.value)*-1+16),y:(window.innerHeight-o.height.value)*-1+16};return}else{let g=Math.min(-16,i.value.x);i.value={x:Math.max(g,(d-o.width.value)*-1+16),y:-16}}},[]);Se([m,e],(d,g)=>{if(d===null||!n.current)return;let{x:p,y:v}=g,fe=n.current.offsetWidth,ge=v>=window.innerHeight-100,kt=v<=100;if(!kt&&!ge){let ne=p>window.innerWidth/2;u.value=ne?"right":"left"}else u.value=kt?"top":"bottom";if(u.value==="right"){let ne=Math.min(-16,s.value.y+d.y);i.value={x:-16,y:Math.max(ne,(window.innerHeight-o.height.value)*-1+16)};return}else if(u.value==="left"){let ne=Math.min(0,s.value.y+d.y);i.value={x:(fe-o.width.value)*-1+16,y:Math.max(ne,(window.innerHeight-o.height.value)*-1+16)};return}else if(u.value==="top"){let ne=Math.min(-16,s.value.x+d.x);i.value={x:Math.max(ne,(fe-o.width.value)*-1+16),y:(window.innerHeight-o.height.value)*-1+16};return}let Wr=Math.min(-16,s.value.x+d.x);i.value={y:-16,x:Math.max(Wr,(fe-o.width.value)*-1+16)}});let S=Q(()=>{n.current!==null&&(i.value=xt({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(He,JSON.stringify({...i.value,...a.value,snapSide:u.value})))},[Math.round(o.width.value),Math.round(o.height.value)]);return L("resize",S),{anchorRef:r,anchorCoords:i,viewPortRef:n,startMouse:t,elementBound:o,snapSide:u,updateAnchorPos:E}};var z=Ve(!1);"window"in globalThis&&P.addEventListener(e=>{e.data.type==="set-inspect-enabled"&&(z.value=e.data.value)});var q=Ve(null);var Fr="kiru-devtools-popup-size",je=()=>{let e=q.value;return Q(()=>new Promise((r,n)=>{if(e)if(e.closed)q.value=null;else return e.focus(),r(e);let o=sessionStorage.getItem(Fr),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"&&(P.removeEventListener(u),console.debug("[kiru]: devtools window opened"),r(a),q.value=a,a.onbeforeunload=()=>{console.debug("[kiru]: devtools window closed"),q.value=null})};P.addEventListener(u),a.onresize=()=>{sessionStorage.setItem(Fr,JSON.stringify({width:a.innerWidth,height:a.innerHeight}))}}),[e])};var Nr=()=>{let e=je(),{mouse:t}=Fe(),r=$r({x:t.value.x,y:t.value.y,immediate:!1}),n=r.element.value,o=z.value?n:null,s=ke(()=>{if(o&&window.__kiru){let c=window.__kiru.apps.find(m=>m.rootNode==null||o.__kiruNode==null?!1:Dt(m.rootNode,o.__kiruNode));return c?.rootNode==null?null:c}return null},[o]),i=ke(()=>o?Ar(o):null,[o]),a=I(null),u=ze(a);return N(()=>z.subscribe(m=>{r[m?"start":"stop"]()}),[]),N(()=>{i&&o?a.current=Mr(i,o)??null:a.current=null},[i,o]),L("click",c=>{if(z.value===!0&&i&&s){c.preventDefault();let m=E=>{E.__devtoolsSelection={node:i,app:s},P.send({type:"select-node"}),P.send({type:"set-inspect-enabled",value:!1}),z.value=!1,a.current=null,E.focus()};q.value?m(q.value):e().then(E=>m(E))}}),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 Ir(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 zr(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 Fn=()=>{z.value=!z.value,P.send({type:"set-inspect-enabled",value:z.value})};function Nn(e,t){let{damping:r}=t,n=x(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 St(){let e=x(!1),t=je(),{anchorCoords:r,anchorRef:n,viewPortRef:o,startMouse:s,snapSide:i}=Hr(),a=i.value==="left"||i.value==="right",u=I(!1),c=Nn(r.value,{damping:.4});return Se([r],c.set),re(()=>{u.current===!1&&c.set(r.value,{hard:!0}),u.current=!0},[]),f(Z,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(_r,{in:e.value,duration:{in:40,out:150},element:m=>{if(m==="exited")return null;let E=m==="entered"?"1":"0.5",S=m==="entered"?"1":"0";return f(Z,null,f("button",{title:"Open Devtools",onclick:t,style:{transform:\`scale(\${E})\`,opacity:S},className:"transition text-white rounded-full p-1 hover:bg-[#0003]"},f(Ir,{width:16,height:16})),f("button",{title:"Toggle Component Inspection",onclick:Fn,style:{transform:\`scale(\${E})\`,opacity:S},className:\`transition text-white rounded-full p-1 hover:bg-[#0003] \${z.value?"bg-[#0003]":""}\`},f(zr,{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(Cr,null))),f(Nr,null))}var jr=\`*, ::before, ::after {
1769
+ \`}function Ur(e){let t=Ot(e);if(l){let r=Br(e);r&&(t=\`\${t} (\${r})\`)}return t}function Ot(e){return e.displayName??(e.name||"Anonymous Function")}function Br(e){return e.toString().match(/\\/\\/ \\[kiru_devtools\\]:(.*)/)?.[1]??null}function ae(e){return typeof e=="object"&&e!==null&&"type"in e}function Je(e){return e===X||e===oe||e===ie}function Pt(e){return e.type===X}function J(e){let t=e;for(;t;){if(t.app)return e.app=t.app;t=t.parent}return null}function be(e){let{props:{children:t,...r},memoizedProps:n,index:o}=e;e.prev={props:r,memoizedProps:n,index:o},e.flags&=~(D|A|pe)}function Dt(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 W(e,t){t(e);let r=e.child;for(;r;)t(r),r.child&&W(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 Lt(e){return Ye(e,t=>t.type===ie)}function Ze(e){if("children"in e.props&&e.props.innerHTML)throw new _({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 _({message:\`Cannot use both bind:\${t} and \${t} on an element\`,vNode:e})}function Vt(e){return typeof e=="string"||typeof e=="number"}function $t(e){return typeof e=="function"||typeof e=="object"&&!!e&&"current"in e||y.isSignal(e)}var qr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz-";function Ae(e=10,t=qr){let r="";for(let n=0;n<e;n++)r+=t[Math.random()*t.length|0];return r}var j=Object.freeze(()=>{});var ye={stack:new Array,current:function(){return this.stack[this.stack.length-1]}},$=new Map,H=new Map;function ee(e,t=!1){return y.isSignal(e)?t?e.value:e.peek():e}var Qe=()=>{$.forEach(e=>e()),$.clear()};var le={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){Ht(e,!0),this.eventDeferrals.set(e,[])},resetEvents:function(e){this.eventDeferrals.delete(e)},releaseEvents:function(e){Ht(e,!1);let t=this.eventDeferrals.get(e);for(;t?.length;)t.shift()()}},Gr=e=>{let t=e.target;!e.isTrusted||!t||le.eventDeferrals.get(t)?.push(()=>t.dispatchEvent(e))},Ht=(e,t)=>{for(let r in e)if(r.startsWith("on")){let n=r.substring(2);e[t?"addEventListener":"removeEventListener"](n,Gr,{passive:!0})}};var it=!1,et=!1,Ft=e=>{e.preventDefault(),e.stopPropagation(),et=!0},ue=null;function Nt(){it=!0,ue=document.activeElement,ue&&ue!==document.body&&ue.addEventListener("blur",Ft)}function It(){et&&(ue.removeEventListener("blur",Ft),ue.isConnected&&ue.focus(),et=!1),it=!1}function tt(e,t){if(typeof e=="function"){e(t);return}if(y.isSignal(e)){e.sneak(t),e.notify({filter:r=>typeof r=="function"});return}e.current=t}function zt(e){let t=e.type;return t=="#text"?Xr(e):Be.has(t)?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t)}function Xr(e){let{nodeValue:t}=e.props;if(!y.isSignal(t))return document.createTextNode(t);let r=t.peek()??"",n=document.createTextNode(r);return nt(e,n,t),n}function Yr(e,t,r){let n=rt.get(e)??{},o=n[t]=s=>{if(it){s.preventDefault(),s.stopPropagation();return}r(s)};return rt.set(e,n),o}var rt=new WeakMap;function jt(e){let t=e.dom,r=e.prev?.props??{},n=e.props??{},o=new Set([...Object.keys(r),...Object.keys(n)]),s=C.current==="hydrate";o.forEach(i=>{let a=r[i],u=n[i];if(we.internalProps.includes(i)&&i!=="innerHTML"){i==="ref"&&a!==u&&(a&&tt(a,null),u&&tt(u,t));return}if(we.isEvent(i)){if(a!==u||C.current==="hydrate"){let c=i.replace(Tt,""),m=c==="focus"||c==="blur";i in r&&t.removeEventListener(c,m?rt.get(e)?.[c]:a),i in n&&t.addEventListener(c,m?Yr(e,c,u):u)}return}if(!(t instanceof Text)){if(a===u||s&&t.getAttribute(i)===u)return;if(y.isSignal(a)&&e.cleanups){let c=e.cleanups[i];c&&(c(),delete e.cleanups[i])}if(y.isSignal(u))return en(e,t,i,u,a);Me(t,i,u,a);return}y.isSignal(u)||t.nodeValue!==u&&(t.nodeValue=u)})}function Jr(e){return e.multiple?Array.from(e.selectedOptions).map(t=>t.value):e.value}function Wt(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 Zr={value:"input",checked:"change",open:"toggle",volume:"volumechange",playbackRate:"ratechange",currentTime:"timeupdate"},Qr=["progress","meter","number","range"];function en(e,t,r,n,o){let s=e.cleanups??(e.cleanups={}),[i,a]=r.split(":");if(i!=="bind")return s[r]=n.subscribe((p,v)=>{Me(t,r,p,v),l&&window.__kiru.profilingContext?.emit("signalAttrUpdate",J(e))}),Me(t,r,n.peek(),ee(o));let u=Zr[a];if(!u){l&&console.error(\`[kiru]: \${a} is not a valid element binding attribute.\`);return}let c=t instanceof HTMLSelectElement,m=c?p=>Wt(t,p):p=>t[a]=p,E=p=>{m(p),l&&window.__kiru.profilingContext?.emit("signalAttrUpdate",J(e))},S=p=>{n.sneak(p),n.notify({filter:v=>v!==E})},d;if(a==="value"){let p=Qr.indexOf(t.type)!==-1;d=()=>{let v=t.value;c?v=Jr(t):typeof n.peek()=="number"&&p&&(v=t.valueAsNumber),S(v)}}else d=p=>{let v=p.target[a];a==="currentTime"&&n.peek()===v||S(v)};t.addEventListener(u,d);let g=n.subscribe(E);return s[r]=()=>{t.removeEventListener(u,d),g()},Me(t,a,n.peek(),ee(o))}function nt(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 Kt(e){let t=le.nextChild();if(!t)throw new _({message:"Hydration mismatch - no node found",vNode:e});let r=t.nodeName;if(Be.has(r)||(r=r.toLowerCase()),e.type!==r)throw new _({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)){jt(e);return}y.isSignal(e.props.nodeValue)&&nt(e,t,e.props.nodeValue);let n=e,o=e.sibling;for(;o&&o.type==="#text";){let s=o;le.bumpChildIndex();let i=String(ee(n.props.nodeValue)??""),a=n.dom.splitText(i.length);s.dom=a,y.isSignal(s.props.nodeValue)&&nt(s,a,s.props.nodeValue),n=o,o=o.sibling}}function Ut(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 tn(e,t,r){let n=qe.has(t);Ut(e,t,r,n)||e.setAttribute(t,n&&typeof r=="boolean"?"":String(r))}var rn=["INPUT","TEXTAREA"],nn=e=>rn.indexOf(e.nodeName)>-1;function Me(e,t,r,n){if(r!==n)switch(t){case"style":return an(e,r,n);case"className":return sn(e,r);case"innerHTML":return on(e,r);case"muted":e.muted=!!r;return;case"value":if(e.nodeName==="SELECT")return Wt(e,r);let o=r==null?"":String(r);if(nn(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 tn(e,Mt(t),r)}}function on(e,t){if(t==null||typeof t=="boolean"){e.innerHTML="";return}e.innerHTML=String(t)}function sn(e,t){let r=ee(t);if(!r)return e.removeAttribute("class");e.setAttribute("class",r)}function an(e,t,r){if(Ut(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 ln(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 _({message:"No DOM parent found while attempting to place node.",vNode:e})}return t}function un(e,t){let{node:r,lastChild:n}=t,o=e.dom;if(n){n.after(o);return}let s=Bt(e,r);if(s){r.dom.insertBefore(o,s);return}r.dom.appendChild(o)}function Bt(e,t){let r=e;for(;r;){let n=r.sibling;for(;n;){if(!(n.flags&(A|V))){let o=cn(n);if(o?.isConnected)return o}n=n.sibling}if(r=r.parent,!r||r.flags&V||r===t)return}}function cn(e){let t=e;for(;t;){if(t.dom)return t.dom;if(t.flags&V)return;t=t.child}}function qt(e){if(C.current==="hydrate")return W(e,be);let t={node:e.dom?e:ln(e)};ot(e,t,(e.flags&A)>0),e.dom&&!(e.flags&V)&&Gt(e,t,!1),be(e)}function ot(e,t,r){let n=e.child;for(;n;){if(n.flags&he){n.flags&A&&fn(n,t),be(n),n=n.sibling;continue}n.dom?(ot(n,{node:n},!1),n.flags&V||Gt(n,t,r)):ot(n,t,(n.flags&A)>0||r),be(n),n=n.sibling}}function Gt(e,t,r){(r||!e.dom.isConnected||e.flags&A)&&un(e,t),(!e.prev||e.flags&D)&&jt(e),t.lastChild=e.dom}function Xt(e){e===e.parent?.child&&(e.parent.child=e.sibling);let t;l&&(t=J(e)),W(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&&tt(a,null),i.isConnected&&!(r.flags&V)&&i.remove(),delete r.dom)}),e.parent=null}function fn(e,t){if(!e.child)return;let r=[];if(Yt(e.child,r),r.length===0)return;let{node:n,lastChild:o}=t;if(o)o.after(...r);else{let s=Bt(e,n),i=n.dom;s?s.before(...r):i.append(...r)}t.lastChild=r[r.length-1]}function Yt(e,t){let r=e;for(;r;)r.dom?t.push(r.dom):r.child&&Yt(r.child,t),r=r.sibling}function Jt(e){return typeof e=="function"&&typeof e[Ce]?.arePropsEqual=="function"}function f(e,t=null,...r){if(e===Z)return Z({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(Jt(e)&&(n.flags|=Te,n.arePropsEqual=e[Ce].arePropsEqual),t!==null){let{key:s,ref:i,...a}=t;Vt(s)&&(n.props.key=s.toString()),$t(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 Z({children:e,key:t}){return f(X,t?{key:t}:null,e)}var lt;function Pe(e,t){return l&&(lt=J(e)),Array.isArray(t)?(l&&(ir in t&&hn(e,t),gn(e,t)),dn(e,t)):pn(e,t)}function pn(e,t){let r=e.child;if(r===null)return tr(e,t);let n=r.sibling,o=Qt(e,r,t);if(o!==null)return r&&r!==o&&!o.prev?at(e,r):n&&at(e,n),o;{let s=sr(r),i=rr(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)}Re(i,0,0)}return s.forEach(a=>Oe(e,a)),i}}function dn(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=Qt(e,o,t[a]);if(c===null){o===null&&(o=s);break}o&&!c.prev&&Oe(e,o),i=Re(c,i,a),n===null?r=c:n.sibling=c,n=c,o=s}if(a===t.length)return at(e,o),r;if(o===null){for(;a<t.length;a++){let c=tr(e,t[a]);c!==null&&(i=Re(c,i,a),n===null?r=c:n.sibling=c,n=c)}return r}let u=sr(o);for(;a<t.length;a++){let c=rr(u,e,a,t[a]);if(c!==null){let m=c.prev;if(m!==null){let E=m.props.key;u.delete(E===void 0?m.index:E)}i=Re(c,i,a),n===null?r=c:n.sibling=c,n=c}}return u.forEach(c=>Oe(e,c)),r}function Qt(e,t,r){let n=t?.props.key;return nr(r)?n!==void 0||t?.type==="#text"&&y.isSignal(t.props.nodeValue)?null:Zt(e,t,""+r):y.isSignal(r)?t&&t.props.nodeValue!==r?null:Zt(e,t,r):ae(r)?r.props.key!==n?null:mn(e,t,r):Array.isArray(r)?n!==void 0?null:(l&&ut(r),er(e,t,r)):null}function Zt(e,t,r){if(t===null||t.type!=="#text"){l&&U();let o=f("#text",{nodeValue:r});return K(o,e),o}return l&&ve(),t.props.nodeValue!==r&&(t.props.nodeValue=r,t.flags|=D),t.sibling=null,t}function mn(e,t,r){let{type:n,props:o}=r;if(l&&typeof n=="function"&&(n=T(n)),n===X)return er(e,t,o.children||[],o);if(t?.type===n)return l&&ve(),t.index=0,t.sibling=null,typeof n=="string"?or(t.props,o)&&(t.flags|=D):t.flags|=D,t.props=o,t.memoizedProps=r.memoizedProps,t;l&&U();let s=f(n,o);return K(s,e),s}function er(e,t,r,n={}){if(t===null||t.type!==X){l&&U();let o=f(X,{children:r,...n});return K(o,e),o}return l&&ve(),t.props={...t.props,...n,children:r},t.flags|=D,t.sibling=null,t}function tr(e,t){if(nr(t)){l&&U();let r=f("#text",{nodeValue:""+t});return K(r,e),r}if(y.isSignal(t)){l&&U();let r=f("#text",{nodeValue:t});return K(r,e),r}if(ae(t)){l&&U();let r=f(t.type,t.props);return K(r,e),r.flags|=A,r}if(Array.isArray(t)){l&&(U(),ut(t));let r=Z({children:t});return K(r,e),r}return null}function Re(e,t,r){e.index=r;let n=e.prev;if(n!==null){let o=n.index;return o<t?(e.flags|=A,t):o}else return e.flags|=A,t}function rr(e,t,r,n){if(y.isSignal(n)||typeof n=="string"&&n!==""||typeof n=="number"||typeof n=="bigint"){let s=e.get(r);if(s){if(s.props.nodeValue===n)return s;s.type==="#text"&&y.isSignal(s.props.nodeValue)&&s.cleanups?.nodeValue?.()}l&&U();let i=f("#text",{nodeValue:n});return K(i,t),i.flags|=A,i.index=r,i}if(ae(n)){let{type:s,props:i}=n,a=i.key,u=e.get(a===void 0?r:a);if(u?.type===s)return l&&ve(),typeof s=="string"?or(u.props,i)&&(u.flags|=D):u.flags|=D,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|=A,c.index=r,c}if(Array.isArray(n)){let s=e.get(r);if(l&&ut(n),s)return l&&ve(),s.flags|=D,s.props.children=n,s;l&&U();let i=Z({children:n});return K(i,t),i.flags|=A,i.index=r,i}return null}function nr(e){return typeof e=="string"&&e!==""||typeof e=="number"||typeof e=="bigint"}function or(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 ve(){"window"in globalThis&&window.__kiru.profilingContext?.emit("updateNode",lt)}function U(){"window"in globalThis&&window.__kiru.profilingContext?.emit("createNode",lt)}var ir=Symbol("kiru:marked-list-child");function ut(e){Object.assign(e,{[ir]:!0})}function sr(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 Oe(e,t){e.deletions===null?e.deletions=[t]:e.deletions.push(t)}function at(e,t){for(;t;)Oe(e,t),t=t.sibling}function gn(e,t){let r=new Set,n=!1;for(let o of t){if(!ae(o))continue;let s=o.props.key;if(typeof s=="string"){if(!n&&r.has(s)){let i=lr(e);ar(\`\${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 hn(e,t){let r=!1,n=!1;for(let o of t){if(!ae(o))continue;typeof o.props.key=="string"?r=!0:n=!0}if(n&&r){let o=lr(e);ar(\`\${o} component produced a child in a list without a valid key prop\`)}}function ar(e){let t=\`[kiru]: \${e}. See https://kirujs.dev/keys-warning for more information.\`;console.error(t)}var st=new WeakMap;function lr(e){if(st.has(e))return st.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 st.set(e,n),n}var B,q=[],de=!1,ft=[],De=[],pt=!1,dt=!1,mt=!1,gt=0,ur=[],ht=[],cr=-1;function bt(e){if(de){ft.push(e);return}e()}function Le(){de&&(window.cancelAnimationFrame(cr),fr())}function yt(e){e.flags|=se,q.push(e),de=!0,Le()}function O(e){if(C.current==="hydrate")return bt(()=>wt(e));wt(e)}function wn(){de||(de=!0,cr=window.requestAnimationFrame(fr))}function bn(){for(de=!1;ft.length;)ft.shift()()}function wt(e){if(pt&&(dt=!0),M.current===e){l&&window.__kiru.profilingContext?.emit("updateDirtied",B),mt=!0;return}if(!(e.flags&(se|pe))){if(e.flags|=se,!q.length)return q.push(e),wn();q.push(e)}}function yn(e){W(e,t=>t.flags|=pe),De.push(e)}var vn=(e,t)=>t.depth-e.depth,te=null;function fr(){if(l){let t=De[0]??q[0];t?(B=J(t),window.__kiru.profilingContext?.beginTick(B)):B=null}let e=1;for(Nt();q.length;){q.length>e&&q.sort(vn),te=q.shift(),e=q.length;let t=te.flags;if(!(t&pe)&&t&se){let r=te;for(;r=xn(r););for(;De.length;)Xt(De.pop());qt(te),te.flags&=~se}}if(It(),pt=!0,ct(ur),pt=!1,dt)return _n(),ct(ht),dt=!1,gt++,l&&(window.__kiru.profilingContext?.endTick(B),window.__kiru.profilingContext?.emit("updateDirtied",B)),Le();gt=0,bn(),ct(ht),l&&(window.__kiru.emit("update",B),window.__kiru.profilingContext?.emit("update",B),window.__kiru.profilingContext?.endTick(B))}function xn(e){let t=!0;try{typeof e.type=="string"?kn(e):Je(e.type)?En(e):t=Sn(e)}catch(n){l&&window.__kiru.emit("error",B,n instanceof Error?n:new Error(String(n)));let o=Lt(e);if(o){let s=o.error=n instanceof Error?n:new Error(String(n));return o.props.onError?.(s),o.depth<te.depth&&(te=o),o}if(_.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(yn),e.deletions=null),t&&e.child)return e.child;let r=e;for(;r;){if(r.immediateEffects&&(ur.push(...r.immediateEffects),r.immediateEffects=void 0),r.effects&&(ht.push(...r.effects),r.effects=void 0),r===te)return;if(r.sibling)return r.sibling;r=r.parent,C.current==="hydrate"&&r?.dom&&le.pop()}}function En(e){let{props:t,type:r}=e,n=t.children;if(r===oe){let{props:{dependents:o,value:s},prev:i}=e;o.size&&i&&i.props.value!==s&&o.forEach(wt)}else if(r===ie){let o=e,{error:s}=o;s&&(n=typeof t.fallback=="function"?t.fallback(s):t.fallback,delete o.error)}e.child=Pe(e,n)}function Sn(e){let{type:t,props:r,subs:n,prev:o,flags:s}=e;if(s&Te){if(e.memoizedProps=r,o?.memoizedProps&&e.arePropsEqual(o.memoizedProps,r)&&!e.hmrUpdated)return e.flags|=he,!1;e.flags&=~he}try{M.current=e;let i,a=0;do{if(e.flags&=~se,mt=!1,Y.current=0,n&&(n.forEach(u=>u()),n.clear()),l){if(i=T(t)(r),e.hmrUpdated&&e.hooks&&e.hookSig){let u=e.hooks.length;if(Y.current<u){for(let c=Y.current;c<u;c++)e.hooks[c].cleanup?.();e.hooks.length=Y.current,e.hookSig.length=Y.current}}if(delete e.hmrUpdated,++a>Ue)throw new _({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(mt);return e.child=Pe(e,i),!0}finally{M.current=null}}function kn(e){let{props:t,type:r}=e;l&&Ze(e),e.dom||(C.current==="hydrate"?Kt(e):e.dom=zt(e),l&&e.dom instanceof Element&&(e.dom.__kiruNode=e)),r!=="#text"&&(e.child=Pe(e,t.children),e.child&&C.current==="hydrate"&&le.push(e.dom))}function _n(){if(gt>Ue)throw new _("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 ct(e){for(let t=0;t<e.length;t++)e[t]();e.length=0}var pr;(function(e){e.Start="start",e.End="end"})(pr||(pr={}));var me=null,dr=new Set;function h(e,t,r){let n=M.current;if(n||Cn(e),l&&me!==null&&!dr.has(e+me))throw dr.add(e+me),new _({message:\`Nested primitive "useHook" calls are not supported. "\${e}" was called inside "\${me}". 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=Y.current++,i=n.hooks?.at(s);if(l){me=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:()=>O(n),queueEffect:o,vNode:n,index:s})}catch(u){throw u}finally{me=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:()=>O(n),queueEffect:o,vNode:n,index:s})}catch(a){throw a}}function Cn(e){throw new _(\`Hook "\${e}" must be used at the top level of a component or inside another composite hook.\`)}function F(e){e.cleanup&&(e.cleanup(),e.cleanup=void 0)}function R(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 mr,y=class e{constructor(t,r){this[mr]=!0,this.$id=Ae(),this.$value=t,r&&(this.displayName=r),l?(H.set(this.$id,new Set),this.$initialValue=Ge(t),this[k]={provide:()=>this,inject:n=>{H.get(this.$id)?.clear?.(),H.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=T(this);return e.entangle(t),t.$value}return e.entangle(this),this.$value}set value(t){if(l){let r=T(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?T(this).$value:this.$value}sneak(t){if(l){let r=T(this);r.$prevValue=r.$value,r.$value=t;return}this.$prevValue=this.$value,this.$value=t}toString(){if(this.onBeforeRead?.(),l){let t=T(this);return e.entangle(t),\`\${t.$value}\`}return e.entangle(this),\`\${this.$value}\`}subscribe(t){return l?(H.get(this.$id).add(t),()=>H.get(this.$id)?.delete(t)):(this.$subs.add(t),()=>this.$subs.delete(t))}notify(t){if(l)return H.get(this.$id)?.forEach(r=>{if(t?.filter&&!t.filter(r))return;let{$value:n,$prevValue:o}=T(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&&We in t}static subscribers(t){return l?H.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=M.current,n=ye.current();if(n){(!r||r&&w())&&n.set(t.$id,t);return}if(!r||!w())return;let o=t.subscribe(()=>O(r));(r.subs??(r.subs=new Set)).add(o)}static configure(t,r){t.onBeforeRead=r}static dispose(t){if(t.$isDisposed=!0,l){H.delete(t.$id);return}t.$subs.clear()}};mr=We;var Ve=(e,t)=>new y(e,t),x=(e,t)=>h("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=()=>y.dispose(r.signal),r.signal=new y(e,t)),r.signal});function $e(e){let{id:t,subs:r,fn:n,deps:o=[],onDepChanged:s}=e,i;$.delete(t);let a=!!M.current&&!w();a||(i=new Map,ye.stack.push(i));let u=n(...o.map(c=>c.value));if(!a){for(let[m,E]of r)i.has(m)||(E(),r.delete(m));let c=()=>{$.size||queueMicrotask(Qe),$.set(t,s)};for(let[m,E]of i){if(r.has(m))continue;let S=E.subscribe(c);r.set(m,S)}ye.stack.pop()}return u}var xe=class e extends y{constructor(t,r){if(super(void 0,r),this.$getter=t,this.$unsubs=new Map,this.$isDirty=!0,l){let n=this[k].inject;this[k]={provide:()=>this,inject:o=>{n(o),e.stop(o),this.$isDirty=o.$isDirty},destroy:()=>{}}}y.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),y.dispose(t)}static stop(t){let{$id:r,$unsubs:n}=T(t);$.delete(r),n.forEach(o=>o()),n.clear(),t.$isDirty=!0}static run(t){let r=T(t),{$id:n,$getter:o,$unsubs:s}=r,i=$e({id:n,subs:s,fn:()=>o(r.$value),onDepChanged:()=>{if(r.$isDirty=!0,l){if(!H?.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}},gr=(e,t)=>new xe(e,t),vt=(e,t)=>h("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=()=>xe.dispose(r.signal),r.signal=gr(e,t)),r.signal));var Ee=class e{constructor(t,r){if(this.id=Ae(),this.getter=t,this.deps=r,this.unsubs=new Map,this.isRunning=!1,this.cleanup=null,l&&(this[k]={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(){$.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(t),{id:n,getter:o,unsubs:s,deps:i}=r;r.cleanup=$e({id:n,subs:s,fn:o,deps:i,onDepChanged:()=>{r.cleanup?.(),e.run(r)}})??null}};function hr(e,t){if(typeof e=="function")return new Ee(e);let r=e,n=t;return new Ee(n,r)}function Se(e,t){if(w())return h("useWatch",{watcher:null},({hook:r,isInit:n,isHMR:o})=>{if(l&&o&&(r.cleanup?.(),n=!0),n){let s=r.watcher=hr(e,t);r.cleanup=()=>s.stop()}return r.watcher})}function wr(e){return!!e&&(typeof e=="object"||typeof e=="function")&&k in e&&typeof e[k]=="object"&&!!e[k]}function br(){let e=new Map,t=null,r=null,n=!1,o=()=>n,s=!1,i=[],a=[];return{register:S=>{if(r===null)throw new Error("[kiru]: HMR could not register: No active module");let d=new Set;for(let[g,p]of Object.entries(S)){let v=r.hotVars.get(g);if(p.value.__devtoolsFileLink=p.link,typeof p.value=="function"&&v?.value&&(v.value.__next=p.value),p.type==="createStore"&&window.__kiru.stores.add(g,p.value),r.hotVars.set(g,p),!!v){if(wr(v.value)&&wr(p.value)){p.value[k].inject(v.value[k].provide()),v.value[k].destroy();continue}v.type==="component"&&p.type==="component"&&window.__kiru.apps.forEach(fe=>{W(fe.rootNode,ge=>{ge.type===v.value&&(ge.type=p.value,d.add(fe),ge.hmrUpdated=!0)})})}}if(d.forEach(g=>g.rootNode&&O(g.rootNode)),n=!1,i.length){let g=0;for(;g<i.length;g++){let p=i[g],v=r.unnamedWatchers[g];v&&(p[k].inject(v[k].provide()),v[k].destroy()),r.unnamedWatchers[g]=p}for(;g<r.unnamedWatchers.length;g++)r.unnamedWatchers[g][k].destroy();r.unnamedWatchers.length=i.length,i.length=0}r=null,t=null},prepare:S=>{let d=e.get(S);if(n=!!d,!d)d={hotVars:new Map,unnamedWatchers:[]},e.set(S,d);else for(;a.length;)a.shift()();r=d,t=S},isReplacement:o,signals:{registerNextWatch(){s=!0},isWaitingForNextWatchCall(){return s},pushWatch(S){i.push(S),s=!1}},onHmr:S=>{a.push(S)},getCurrentFilePath(){return t}}}function yr(){let e=new Map,t=new Map;return{appStats:t,emit:(r,n)=>{e.get(r)?.forEach(o=>o(n))},addEventListener:(r,n)=>{e.has(r)||e.set(r,new Set),e.get(r).add(n)},removeEventListener:(r,n)=>{e.has(r)&&e.get(r).delete(n)},mountDuration:r=>{let n=t.get(r);return n?n.mountDuration:0},totalTicks:r=>{let n=t.get(r);return n?n.totalTicks:0},lastTickDuration:r=>{let n=t.get(r);if(!n)return 0;let o=n.timestamps[n.timestamps.length-1];return o.end-o.start},averageTickDuration:r=>{let n=t.get(r);if(!n)return 0;let o=n.timestamps.filter(s=>s.end!==1/0);return o.reduce((s,i)=>s+(i.end-i.start),0)/o.length},beginTick:r=>{t.has(r)||t.set(r,{mountDuration:1/0,timestamps:[],totalTicks:0});let n=t.get(r);n.totalTicks++,n.timestamps.push({start:performance.now(),end:1/0})},endTick:r=>{if(!t.has(r))return;let n=t.get(r),o=n.timestamps[n.timestamps.length-1];o.end=performance.now(),n.mountDuration===1/0&&(n.mountDuration=o.end-o.start),n.timestamps.length>100&&n.timestamps.shift()}}}function Tn(){let e=new Map,t=new Set;function r(i,a){e.has(i)||(e.set(i,a),o())}function n(i){e.has(i)&&(e.delete(i),o())}function o(){let i=Object.fromEntries(e);t.forEach(a=>a(i))}function s(i){return t.add(i),i(Object.fromEntries(e)),()=>t.delete(i)}return{add:r,delete:n,subscribe:s,get size(){return e.size}}}function vr(){let e=new Set,t=new Map;function r(i,a,u){t.get(i)?.forEach(c=>c(a,u))}function n(i,a){t.has(i)||t.set(i,new Set),t.get(i).add(a)}function o(i,a){t.get(i)?.delete(a)}let s={get apps(){return Array.from(e)},emit:r,on:n,off:o};return n("mount",i=>e.add(i)),n("unmount",i=>e.delete(i)),l&&(s.HMRContext=br(),s.profilingContext=yr(),s.stores=Tn()),s}var An=0;function xr(e,t,r){var n;if(l&&t.__kiruNode)throw new Error("[kiru]: container in use - call unmount on the previous app first.");let o=f(t.nodeName.toLowerCase(),{});l&&(t.__kiruNode=o),o.dom=t,o.flags|=V;let s=An++,i=r?.name??\`App-\${s}\`,a={id:s,name:i,rootNode:o,render:u,unmount:c};function u(m){o.props.children=m,yt(o)}function c(){o.props.children=null,yt(o),l&&(delete t.__kiruNode,delete o.app),window.__kiru.emit("unmount",a)}return l&&(o.app=a),(n=globalThis.window).__kiru??(n.__kiru=vr()),u(e),window.__kiru.emit("mount",a),l&&queueMicrotask(()=>{window.dispatchEvent(new Event("kiru:ready"))}),a}function ce(e){return w()?h("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 Er(e){let t={[_t]:!0,Provider:({value:r,children:n})=>{let[o]=ce(()=>new Set);return f(oe,{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[k]={inject:n=>{let o=t.Provider;window.__kiru.apps.forEach(s=>{W(s.rootNode,i=>{i.type===n.Provider&&(i.type=o,i.hmrUpdated=!0,O(i))})})},destroy:()=>{},provide:()=>t}}return t}function Q(e,t){return w()?h("useCallback",{callback:e,deps:t},({hook:r,isHMR:n})=>(l&&(r.dev={devtools:{get:()=>({callback:r.callback,dependencies:r.deps})}},n&&(r.deps=[])),R(t,r.deps)&&(r.deps=t,r.callback=e),r.callback)):e}function N(e,t){if(w())return h("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||R(t,r.deps))&&(r.deps=t,F(r),s(()=>{let i=e();typeof i=="function"&&(r.cleanup=i)}))})}function re(e,t){if(w())return h("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||R(t,r.deps))&&(r.deps=t,F(r),s(()=>{let i=e();typeof i=="function"&&(r.cleanup=i)},{immediate:!0}))})}function ke(e,t){return w()?h("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||R(t,r.deps))&&(r.deps=t,r.value=e()),r.value)):e()}function I(e){return w()?h("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 Da="window"in globalThis?window.__KIRU_LAZY_CACHE??(window.__KIRU_LAZY_CACHE=new Map):new Map;function _r(e){let[t,r]=ce(e.initialState||"exited"),n=I(null);re(()=>{e.in&&t!=="entered"&&t!=="entering"?(o("entering"),s("entered")):!e.in&&t!=="exited"&&t!=="exiting"&&(o("exiting"),s("exited"))},[e.in,t]),N(()=>()=>kr(n.current),[]);let o=Q(i=>{kr(n.current),r(i),(i==="entered"||i==="exited")&&e.onTransitionEnd&&e.onTransitionEnd(i)},[]),s=Q(i=>{n.current=window.setTimeout(()=>o(i),Rn(i,e.duration))},[e.duration]);return e.element(t)}var Sr=150;function Rn(e,t){if(typeof t=="number")return t;switch(e){case"entered":return t?.in??Sr;case"exited":return t?.out??Sr}}function kr(e){e!=null&&window.clearTimeout(e)}var Cr=()=>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 He="kiru.devtools.anchorPosition",Tr={x:-16,y:-16};var xt=(e,t,r)=>{if(!t.current)return{...Tr};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}},Ar=e=>{if(e==null)return null;let t=null,r=e?.__kiruNode?.parent;for(;r;){if(typeof r.type=="function"&&!Pt(r)){t=r;break}r=r.parent}return t},Mr=(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 Or={arrayChunkSize:10,objectKeysChunkSize:100};function Pr(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"&&!Pr(e[n],t[n]))return!1;return!0}var Dn={...Or},Rr=localStorage.getItem("kiru.devtools.userSettings");if(Rr)try{let e=JSON.parse(Rr);Pr(Or,e)&&(Dn=e)}catch(e){console.error("kiru.devtools.userSettings error",e)}var Cu=Er({userSettings:null,saveUserSettings:()=>{}});var Du=Object.freeze(()=>{});var Hn="kiru-devtools";"window"in globalThis&&(window.__devtoolsSelection??(window.__devtoolsSelection=null));var Et=class extends BroadcastChannel{send(t){super.postMessage(t)}removeEventListener(t){return super.removeEventListener("message",t)}addEventListener(t){return super.addEventListener("message",t)}},P=new Et(Hn);var rc=Symbol.for("devtools.hookGroup");var L=(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 Fe=()=>{let e=x({x:0,y:0}),t=x({x:0,y:0}),r=x({x:0,y:0});return L("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 Ne="window"in globalThis&&"ResizeObserver"in globalThis.window,Dr=(e,t,r=void 0)=>w()?Ne?h("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(()=>{R([e.current],o.deps)&&(o.deps=[e.current],o.resizeObserver?.disconnect?.(),e.current&&o.resizeObserver?.observe(e.current,r))}),{isSupported:Ne,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:()=>{F(o)}})):{isSupported:Ne,start:()=>{},stop:()=>{}}:{isSupported:Ne,start:()=>{},stop:()=>{}};var Ie="window"in globalThis&&"MutationObserver"in globalThis.window,Lr=(e,t,r=void 0)=>w()?Ie?h("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}):R([e.current],o.deps)&&(o.deps=[e.current],o.mutationObserver?.disconnect?.(),e.current&&o.mutationObserver?.observe(e.current,r)),{isSupported:Ie,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:()=>{F(o)}})):{isSupported:Ie,start:()=>{},stop:()=>{}}:{isSupported:Ie,start:()=>{},stop:()=>{}};var ze=(e,t={windowScroll:!0,windowResize:!0})=>{let r=t?.windowScroll??!0,n=t?.windowResize??!0,o=t.immediate??!0,s=x(0),i=x(0),a=x(0),u=x(0),c=x(0),m=x(0),E=x(0),S=x(0),d=()=>{let g=e.current;if(!g){s.value=0,i.value=0,a.value=0,u.value=0,c.value=0,m.value=0,E.value=0,S.value=0;return}let p=g.getBoundingClientRect();s.value=p.width,i.value=p.height,a.value=p.top,u.value=p.right,c.value=p.bottom,m.value=p.left,E.value=p.x,S.value=p.y};return Dr(e,d),Lr(e,d,{attributeFilter:["style","class"]}),L("scroll",()=>{r&&d()},{capture:!0,passive:!0}),L("resize",()=>{n&&d()},{passive:!0}),re(()=>{o&&d()},[]),{width:s,height:i,top:a,right:u,bottom:c,left:m,x:E,y:S,update:d}};var Vr=(e,t)=>{if(!w())return{isActive:t?.immediate??!1,start:()=>null,stop:()=>null};let r=t?.fpsLimit?1e3/t.fpsLimit:null;return h("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:()=>{F(o),s()}}))};var $r=e=>{let{x:t,y:r,multiple:n,immediate:o=!0}=e,s=x(null),a=Vr(()=>{s.value=n?document.elementsFromPoint(t,r)??[]:document.elementFromPoint(t,r)??null},{immediate:o});return{element:s,...a}};var Hr=()=>{let{mouse:e}=Fe(),t=x(null),r=I(null),n=I(null),o=ze(r),s=x({x:-16,y:-16}),i=x({x:-16,y:-16}),a=x({width:window.innerWidth,height:window.innerHeight}),u=x("bottom"),c=I(null);re(()=>{let d=localStorage.getItem(He);if(d==null)return;let g=JSON.parse(d);a.value.width=window.innerWidth,a.value.height=window.innerHeight,u.value=g.snapSide,i.value=xt(g,n,o)},[Math.round(o.width.value),Math.round(o.height.value)]);let m=vt(()=>{let{x:d,y:g}=e.value;if(t.value===null)return null;let{x:p,y:v}=t.value;return{x:d-p,y:g-v}});L("dragstart",d=>{d.preventDefault(),t.value={x:d.x,y:d.y},s.value=i.value},{ref:()=>r.current}),L("mouseup",()=>{c.current&&(clearTimeout(c.current),c.current=null),t.peek()&&(t.value=null,localStorage.setItem(He,JSON.stringify({...i.value,...a.value,snapSide:u.value})))});let E=Q(()=>{if(n.current==null)return;let d=n.current.offsetWidth;if(u.value==="right"){let g=Math.min(-16,i.value.y);i.value={x:-16,y:Math.max(g,(window.innerHeight-o.height.value)*-1+16)}}else if(u.value==="left"){let g=Math.min(0,i.value.y);i.value={x:(d-o.width.value)*-1+16,y:Math.max(g,(window.innerHeight-o.height.value)*-1+16)}}else if(u.value==="top"){let g=Math.min(-16,i.value.x);i.value={x:Math.max(g,(d-o.width.value)*-1+16),y:(window.innerHeight-o.height.value)*-1+16};return}else{let g=Math.min(-16,i.value.x);i.value={x:Math.max(g,(d-o.width.value)*-1+16),y:-16}}},[]);Se([m,e],(d,g)=>{if(d===null||!n.current)return;let{x:p,y:v}=g,fe=n.current.offsetWidth,ge=v>=window.innerHeight-100,kt=v<=100;if(!kt&&!ge){let ne=p>window.innerWidth/2;u.value=ne?"right":"left"}else u.value=kt?"top":"bottom";if(u.value==="right"){let ne=Math.min(-16,s.value.y+d.y);i.value={x:-16,y:Math.max(ne,(window.innerHeight-o.height.value)*-1+16)};return}else if(u.value==="left"){let ne=Math.min(0,s.value.y+d.y);i.value={x:(fe-o.width.value)*-1+16,y:Math.max(ne,(window.innerHeight-o.height.value)*-1+16)};return}else if(u.value==="top"){let ne=Math.min(-16,s.value.x+d.x);i.value={x:Math.max(ne,(fe-o.width.value)*-1+16),y:(window.innerHeight-o.height.value)*-1+16};return}let Wr=Math.min(-16,s.value.x+d.x);i.value={y:-16,x:Math.max(Wr,(fe-o.width.value)*-1+16)}});let S=Q(()=>{n.current!==null&&(i.value=xt({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(He,JSON.stringify({...i.value,...a.value,snapSide:u.value})))},[Math.round(o.width.value),Math.round(o.height.value)]);return L("resize",S),{anchorRef:r,anchorCoords:i,viewPortRef:n,startMouse:t,elementBound:o,snapSide:u,updateAnchorPos:E}};var z=Ve(!1);"window"in globalThis&&P.addEventListener(e=>{e.data.type==="set-inspect-enabled"&&(z.value=e.data.value)});var G=Ve(null);var Fr="kiru-devtools-popup-size",je=()=>{let e=G.value;return Q(()=>new Promise((r,n)=>{if(e)if(e.closed)G.value=null;else return e.focus(),r(e);let o=sessionStorage.getItem(Fr),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"&&(P.removeEventListener(u),console.debug("[kiru]: devtools window opened"),r(a),G.value=a,a.onbeforeunload=()=>{console.debug("[kiru]: devtools window closed"),G.value=null})};P.addEventListener(u),a.onresize=()=>{sessionStorage.setItem(Fr,JSON.stringify({width:a.innerWidth,height:a.innerHeight}))}}),[e])};var Nr=()=>{let e=je(),{mouse:t}=Fe(),r=$r({x:t.value.x,y:t.value.y,immediate:!1}),n=r.element.value,o=z.value?n:null,s=ke(()=>{if(o&&window.__kiru){let c=window.__kiru.apps.find(m=>m.rootNode==null||o.__kiruNode==null?!1:Dt(m.rootNode,o.__kiruNode));return c?.rootNode==null?null:c}return null},[o]),i=ke(()=>o?Ar(o):null,[o]),a=I(null),u=ze(a);return N(()=>z.subscribe(m=>{r[m?"start":"stop"]()}),[]),N(()=>{i&&o?a.current=Mr(i,o)??null:a.current=null},[i,o]),L("click",c=>{if(z.value===!0&&i&&s){c.preventDefault();let m=E=>{E.__devtoolsSelection={node:i,app:s},P.send({type:"select-node"}),P.send({type:"set-inspect-enabled",value:!1}),z.value=!1,a.current=null,E.focus()};G.value?m(G.value):e().then(E=>m(E))}}),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 Ir(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 zr(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 Fn=()=>{z.value=!z.value,P.send({type:"set-inspect-enabled",value:z.value})};function Nn(e,t){let{damping:r}=t,n=x(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 St(){let e=x(!1),t=je(),{anchorCoords:r,anchorRef:n,viewPortRef:o,startMouse:s,snapSide:i}=Hr(),a=i.value==="left"||i.value==="right",u=I(!1),c=Nn(r.value,{damping:.4});return Se([r],c.set),re(()=>{u.current===!1&&c.set(r.value,{hard:!0}),u.current=!0},[]),f(Z,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(_r,{in:e.value,duration:{in:40,out:150},element:m=>{if(m==="exited")return null;let E=m==="entered"?"1":"0.5",S=m==="entered"?"1":"0";return f(Z,null,f("button",{title:"Open Devtools",onclick:t,style:{transform:\`scale(\${E})\`,opacity:S},className:"transition text-white rounded-full p-1 hover:bg-[#0003]"},f(Ir,{width:16,height:16})),f("button",{title:"Toggle Component Inspection",onclick:Fn,style:{transform:\`scale(\${E})\`,opacity:S},className:\`transition text-white rounded-full p-1 hover:bg-[#0003] \${z.value?"bg-[#0003]":""}\`},f(zr,{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(Cr,null))),f(Nr,null))}var jr=\`*, ::before, ::after {
1770
1770
  --tw-border-spacing-x: 0;
1771
1771
  --tw-border-spacing-y: 0;
1772
1772
  --tw-translate-x: 0;
@@ -2533,7 +2533,7 @@ video {
2533
2533
  .focus\\\\:outline:focus {
2534
2534
  outline-style: solid;
2535
2535
  }
2536
- \`;if("window"in globalThis){let e=document.createElement("kiru-devtools");e.setAttribute("style","display: contents"),document.body.appendChild(e);let t=e.attachShadow({mode:"open"}),r=new CSSStyleSheet;r.replaceSync(jr),t.adoptedStyleSheets=[r];let n=Object.assign(document.createElement("div"),{id:"devtools-root",className:"fixed flex bottom-0 right-0 z-[9999999]"});t.appendChild(n),xr(f(St,{}),n,{name:"kiru.devtools"});let o=()=>q.value?.close();window.addEventListener("close",o),window.addEventListener("beforeunload",o),P.addEventListener(s=>{s.data.type==="open-editor"&&window.open(s.data.fileLink)})}
2536
+ \`;if("window"in globalThis){let e=function(){let t=document.createElement("kiru-devtools");t.setAttribute("style","display: contents"),document.body.appendChild(t);let r=t.attachShadow({mode:"open"}),n=new CSSStyleSheet;n.replaceSync(jr),r.adoptedStyleSheets=[n];let o=Object.assign(document.createElement("div"),{id:"devtools-root",className:"fixed flex bottom-0 right-0 z-[9999999]"});r.appendChild(o),xr(f(St,{}),o,{name:"kiru.devtools"});let s=()=>G.value?.close();window.addEventListener("close",s),window.addEventListener("beforeunload",s),P.addEventListener(i=>{i.data.type==="open-editor"&&window.open(i.data.fileLink)})};zn=e,window.addEventListener("kiru:ready",e,{once:!0})}var zn;
2537
2537
 
2538
2538
  `;
2539
2539
 
@@ -3045,7 +3045,6 @@ function kiru(opts = {}) {
3045
3045
  },
3046
3046
  {
3047
3047
  tag: "script",
3048
- injectTo: "body",
3049
3048
  attrs: {
3050
3049
  type: "module",
3051
3050
  src: dtHostScriptPath
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-kiru",
3
- "version": "0.28.1",
3
+ "version": "0.28.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",