@fluixi/dom 1.0.0-alpha.83 → 1.0.0-alpha.84

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 (182) hide show
  1. package/dist/cdn/dom-client.cjs +1427 -1
  2. package/dist/cdn/dom-client.d.ts +2 -2
  3. package/dist/cdn/dom-client.global.js +2 -1
  4. package/dist/cdn/dom-client.js +3 -3
  5. package/dist/cdn/dom-client.mjs +1430 -1
  6. package/dist/cdn/dom.cjs +3127 -1
  7. package/dist/cdn/dom.d.ts +2 -2
  8. package/dist/cdn/dom.global.js +2 -1
  9. package/dist/cdn/dom.js +4 -4
  10. package/dist/cdn/dom.mjs +3133 -1
  11. package/dist/index.cjs +3155 -1
  12. package/dist/index.js +2 -2
  13. package/dist/index.mjs +3149 -1
  14. package/dist/lib/component/index.cjs +128 -1
  15. package/dist/lib/component/index.mjs +105 -1
  16. package/dist/lib/component/modifiers.cjs +126 -1
  17. package/dist/lib/component/modifiers.d.ts +12 -0
  18. package/dist/lib/component/modifiers.d.ts.map +1 -1
  19. package/dist/lib/component/modifiers.js +12 -84
  20. package/dist/lib/component/modifiers.mjs +105 -1
  21. package/dist/lib/dom/delegate.cjs +60 -1
  22. package/dist/lib/dom/delegate.js +1 -1
  23. package/dist/lib/dom/delegate.mjs +39 -1
  24. package/dist/lib/dom/dynamic-element.cjs +949 -1
  25. package/dist/lib/dom/dynamic-element.d.ts +3 -3
  26. package/dist/lib/dom/dynamic-element.js +2 -2
  27. package/dist/lib/dom/dynamic-element.mjs +928 -1
  28. package/dist/lib/dom/hydration-state.cjs +93 -1
  29. package/dist/lib/dom/hydration-state.d.ts +1 -1
  30. package/dist/lib/dom/hydration-state.js +1 -1
  31. package/dist/lib/dom/hydration-state.mjs +72 -1
  32. package/dist/lib/dom/hydration.cjs +685 -1
  33. package/dist/lib/dom/hydration.js +8 -8
  34. package/dist/lib/dom/hydration.mjs +664 -1
  35. package/dist/lib/dom/index.cjs +2040 -1
  36. package/dist/lib/dom/index.js +1 -1
  37. package/dist/lib/dom/index.mjs +2020 -1
  38. package/dist/lib/dom/integration.cjs +71 -1
  39. package/dist/lib/dom/integration.js +3 -3
  40. package/dist/lib/dom/integration.mjs +51 -1
  41. package/dist/lib/dom/island.cjs +790 -1
  42. package/dist/lib/dom/island.d.ts +1 -1
  43. package/dist/lib/dom/island.js +11 -11
  44. package/dist/lib/dom/island.mjs +769 -1
  45. package/dist/lib/dom/runtime.cjs +1432 -1
  46. package/dist/lib/dom/runtime.d.ts +60 -17
  47. package/dist/lib/dom/runtime.d.ts.map +1 -1
  48. package/dist/lib/dom/runtime.js +122 -79
  49. package/dist/lib/dom/runtime.mjs +1414 -1
  50. package/dist/lib/dom/server/fx-data.cjs +53 -1
  51. package/dist/lib/dom/server/fx-data.d.ts +5 -5
  52. package/dist/lib/dom/server/fx-data.js +6 -6
  53. package/dist/lib/dom/server/fx-data.mjs +32 -1
  54. package/dist/lib/dom/server/host.cjs +66 -1
  55. package/dist/lib/dom/server/host.d.ts +6 -0
  56. package/dist/lib/dom/server/host.d.ts.map +1 -1
  57. package/dist/lib/dom/server/host.js +7 -1
  58. package/dist/lib/dom/server/host.mjs +45 -1
  59. package/dist/lib/dom/server/index.cjs +759 -1
  60. package/dist/lib/dom/server/index.d.ts +1 -1
  61. package/dist/lib/dom/server/index.js +1 -1
  62. package/dist/lib/dom/server/index.mjs +743 -1
  63. package/dist/lib/dom/server/nodes.cjs +302 -1
  64. package/dist/lib/dom/server/nodes.d.ts +2 -2
  65. package/dist/lib/dom/server/nodes.d.ts.map +1 -1
  66. package/dist/lib/dom/server/nodes.js +4 -4
  67. package/dist/lib/dom/server/nodes.mjs +279 -1
  68. package/dist/lib/dom/server/parse-template.cjs +395 -1
  69. package/dist/lib/dom/server/parse-template.d.ts +1 -1
  70. package/dist/lib/dom/server/parse-template.js +4 -4
  71. package/dist/lib/dom/server/parse-template.mjs +372 -1
  72. package/dist/lib/dom/server/render.cjs +691 -1
  73. package/dist/lib/dom/server/render.d.ts +9 -1
  74. package/dist/lib/dom/server/render.d.ts.map +1 -1
  75. package/dist/lib/dom/server/render.js +23 -15
  76. package/dist/lib/dom/server/render.mjs +677 -1
  77. package/dist/lib/dom/server/request-context.cjs +110 -1
  78. package/dist/lib/dom/server/request-context.d.ts +29 -9
  79. package/dist/lib/dom/server/request-context.d.ts.map +1 -1
  80. package/dist/lib/dom/server/request-context.js +28 -8
  81. package/dist/lib/dom/server/request-context.mjs +89 -1
  82. package/dist/lib/dom/server/serialize.cjs +187 -1
  83. package/dist/lib/dom/server/serialize.js +3 -3
  84. package/dist/lib/dom/server/serialize.mjs +164 -1
  85. package/dist/lib/dom/server-renderer.cjs +760 -1
  86. package/dist/lib/dom/server-renderer.js +1 -1
  87. package/dist/lib/dom/server-renderer.mjs +745 -1
  88. package/dist/lib/dom/types.cjs +18 -1
  89. package/dist/lib/dom/utils.cjs +381 -1
  90. package/dist/lib/dom/utils.d.ts +1 -88
  91. package/dist/lib/dom/utils.d.ts.map +1 -1
  92. package/dist/lib/dom/utils.js +2 -99
  93. package/dist/lib/dom/utils.mjs +361 -1
  94. package/dist/lib/dom/versions.cjs +60 -1
  95. package/dist/lib/dom/versions.d.ts +3 -3
  96. package/dist/lib/dom/versions.d.ts.map +1 -1
  97. package/dist/lib/dom/versions.js +17 -5
  98. package/dist/lib/dom/versions.mjs +37 -1
  99. package/dist/lib/element/attributes.cjs +19 -1
  100. package/dist/lib/element/attributes.d.ts +7 -7
  101. package/dist/lib/element/attributes.js +1 -1
  102. package/dist/lib/element/attributes.mjs +1 -0
  103. package/dist/lib/element/index.cjs +19 -1
  104. package/dist/lib/element/index.mjs +1 -0
  105. package/dist/lib/element/types.cjs +18 -1
  106. package/dist/lib/element/types.d.ts +4 -5
  107. package/dist/lib/element/types.d.ts.map +1 -1
  108. package/dist/lib/element/types.js +0 -1
  109. package/dist/lib/flow/class-map.cjs +38 -1
  110. package/dist/lib/flow/class-map.d.ts +3 -3
  111. package/dist/lib/flow/class-map.js +2 -2
  112. package/dist/lib/flow/class-map.mjs +17 -1
  113. package/dist/lib/flow/client-only.cjs +57 -1
  114. package/dist/lib/flow/client-only.d.ts +4 -4
  115. package/dist/lib/flow/client-only.js +3 -3
  116. package/dist/lib/flow/client-only.mjs +36 -1
  117. package/dist/lib/flow/dynamic.cjs +53 -1
  118. package/dist/lib/flow/dynamic.d.ts +2 -2
  119. package/dist/lib/flow/dynamic.js +3 -3
  120. package/dist/lib/flow/dynamic.mjs +32 -1
  121. package/dist/lib/flow/error-boundary.cjs +43 -1
  122. package/dist/lib/flow/error-boundary.d.ts +2 -2
  123. package/dist/lib/flow/error-boundary.js +3 -3
  124. package/dist/lib/flow/error-boundary.mjs +22 -1
  125. package/dist/lib/flow/for.cjs +66 -1
  126. package/dist/lib/flow/for.d.ts +9 -9
  127. package/dist/lib/flow/for.d.ts.map +1 -1
  128. package/dist/lib/flow/for.js +2 -2
  129. package/dist/lib/flow/for.mjs +45 -1
  130. package/dist/lib/flow/index-flow.cjs +67 -1
  131. package/dist/lib/flow/index-flow.d.ts +5 -5
  132. package/dist/lib/flow/index-flow.js +4 -4
  133. package/dist/lib/flow/index-flow.mjs +46 -1
  134. package/dist/lib/flow/index.cjs +805 -1
  135. package/dist/lib/flow/index.mjs +792 -1
  136. package/dist/lib/flow/portal.cjs +538 -1
  137. package/dist/lib/flow/portal.mjs +519 -1
  138. package/dist/lib/flow/show.cjs +81 -1
  139. package/dist/lib/flow/show.d.ts +1 -1
  140. package/dist/lib/flow/show.d.ts.map +1 -1
  141. package/dist/lib/flow/show.js +4 -115
  142. package/dist/lib/flow/show.mjs +67 -1
  143. package/dist/lib/flow/style-map.cjs +43 -1
  144. package/dist/lib/flow/style-map.d.ts +3 -3
  145. package/dist/lib/flow/style-map.js +3 -3
  146. package/dist/lib/flow/style-map.mjs +22 -1
  147. package/dist/lib/flow/switch.cjs +91 -1
  148. package/dist/lib/flow/switch.d.ts +3 -3
  149. package/dist/lib/flow/switch.d.ts.map +1 -1
  150. package/dist/lib/flow/switch.js +6 -6
  151. package/dist/lib/flow/switch.mjs +70 -1
  152. package/dist/lib/flow/utils.cjs +44 -1
  153. package/dist/lib/flow/utils.d.ts +1 -1
  154. package/dist/lib/flow/utils.js +1 -1
  155. package/dist/lib/flow/utils.mjs +23 -1
  156. package/dist/lib/html.cjs +32 -1
  157. package/dist/lib/html.d.ts +6 -6
  158. package/dist/lib/html.js +5 -5
  159. package/dist/lib/html.mjs +11 -1
  160. package/dist/lib/index.cjs +3104 -1
  161. package/dist/lib/index.d.ts +0 -1
  162. package/dist/lib/index.d.ts.map +1 -1
  163. package/dist/lib/index.js +2 -3
  164. package/dist/lib/index.mjs +3097 -1
  165. package/dist/lib/shared/types.cjs +18 -1
  166. package/dist/lib/shared/types.d.ts +8 -8
  167. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  168. package/dist/version.generated.cjs +26 -1
  169. package/dist/version.generated.d.ts +1 -1
  170. package/dist/version.generated.js +2 -2
  171. package/dist/version.generated.mjs +5 -1
  172. package/package.json +7 -6
  173. package/dist/lib/jsx/control-flow/flow.cjs +0 -1
  174. package/dist/lib/jsx/control-flow/flow.d.ts +0 -2
  175. package/dist/lib/jsx/control-flow/flow.d.ts.map +0 -1
  176. package/dist/lib/jsx/control-flow/flow.js +0 -627
  177. package/dist/lib/jsx/control-flow/flow.mjs +0 -0
  178. package/dist/lib/jsx/control-flow/for-flow.cjs +0 -1
  179. package/dist/lib/jsx/control-flow/for-flow.d.ts +0 -2
  180. package/dist/lib/jsx/control-flow/for-flow.d.ts.map +0 -1
  181. package/dist/lib/jsx/control-flow/for-flow.js +0 -1
  182. package/dist/lib/jsx/control-flow/for-flow.mjs +0 -0
package/dist/cdn/dom.cjs CHANGED
@@ -1 +1,3127 @@
1
- "use strict";var je=Object.defineProperty;var Pn=Object.getOwnPropertyDescriptor;var kn=Object.getOwnPropertyNames;var On=Object.prototype.hasOwnProperty;var Ln=(e,t)=>{for(var n in t)je(e,n,{get:t[n],enumerable:!0})},Dn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of kn(t))!On.call(e,o)&&o!==n&&je(e,o,{get:()=>t[o],enumerable:!(r=Pn(t,o))||r.enumerable});return e};var _n=e=>Dn(je({},"__esModule",{value:!0}),e);var wo={};Ln(wo,{ClientOnly:()=>st,Dynamic:()=>un,ErrorBoundary:()=>pn,FX_DATA_ID:()=>z,For:()=>on,Index:()=>an,Island:()=>Xt,JSX_PROPERTIES:()=>de,Match:()=>ln,NoSsr:()=>dn,Portal:()=>fn,SVG_ELEMENTS:()=>Fn,SVG_NAMESPACE:()=>F,Show:()=>rn,Switch:()=>cn,VOID_ELEMENTS:()=>Hn,addClass:()=>Un,addDelegatedEventListener:()=>Ht,addNativeEventListener:()=>ze,appendChildren:()=>Qn,applyElementProp:()=>fe,applyProps:()=>Je,applyUse:()=>Ge,asComponent:()=>Fe,asContext:()=>Tr,asOutlet:()=>hr,asProvider:()=>xr,asRoute:()=>gr,asRouter:()=>yr,asRoutes:()=>mr,asSuspense:()=>br,batch:()=>g.batch,bindPair:()=>Xr,captureHydrationCursor:()=>Dt,checkRenderType:()=>Er,classMap:()=>mn,cleanChildren:()=>L,cloneTemplate:()=>Vt,closest:()=>Wn,createComponent:()=>Qe,createComputed:()=>g.createComputed,createContext:()=>g.createContext,createDynamicElement:()=>co,createEffect:()=>g.createEffect,createElement:()=>Yn,createMemo:()=>g.createMemo,createNativeElement:()=>Ke,createPortal:()=>Br,createRenderEffect:()=>g.createRenderEffect,createRequestContext:()=>B,createResource:()=>g.createResource,createRoot:()=>g.createRoot,createSignal:()=>g.createSignal,createStore:()=>Mn.createStore,createTemplate:()=>Ft,delegate:()=>rr,delegateEvents:()=>Be,effect:()=>Y.effect,escapeFxJson:()=>ce,escapeHTML:()=>zr,fnName:()=>Ir,generateID:()=>Rr,getAttribute:()=>Gn,getGlobal:()=>pr,getLitEventName:()=>qn,getLocals:()=>nt,getOffset:()=>nr,getRequestContext:()=>M,getRequestEvent:()=>Ne,getRequestLocals:()=>Se,getServerData:()=>ue,getStableElementId:()=>Ar,getStyle:()=>Jn,handleRef:()=>le,hasClass:()=>zn,holeContent:()=>$r,holeEnd:()=>_r,holeScope:()=>Lr,html:()=>Yt,hydrate:()=>Me,hydrateAdvancePast:()=>W,hydrateIslands:()=>Jt,indexArray:()=>G.indexArray,initializeIntegration:()=>Zr,insert:()=>C,insertExpression:()=>re,intergartionInitialized:()=>Qr,isAccessor:()=>Gr,isComponent:()=>S,isContext:()=>Mt,isCustomElement:()=>ht,isDOMNode:()=>fr,isDelegatedEvent:()=>Pr,isDomElement:()=>pe,isDomNode:()=>I,isDomText:()=>ye,isEventHandler:()=>In,isFunction:()=>kr,isIntegrationInitialized:()=>eo,isJSXTemplate:()=>ur,isLitTemplateResult:()=>Tt,isNativeElement:()=>Kr,isOutlet:()=>Rt,isPromise:()=>ne,isProvider:()=>Ct,isReactElement:()=>lr,isRoute:()=>At,isRouter:()=>St,isRoutes:()=>vt,isSVGElement:()=>Ye,isServer:()=>h,isSuspense:()=>Pt,isTemplateFactory:()=>cr,isVisible:()=>er,iterateFn:()=>qr,keyArray:()=>G.keyArray,makeArrayFlat:()=>Wt,mapArray:()=>G.mapArray,memo:()=>Y.memo,mergeProps:()=>Wr,observeIntersection:()=>ir,observeResize:()=>sr,onCleanup:()=>g.onCleanup,query:()=>He,queryAll:()=>Vn,registerCreateComponent:()=>Yr,registerGlobal:()=>dr,removeAttribute:()=>Xn,removeChildren:()=>Zn,removeClass:()=>Bn,removeDelegatedEventListener:()=>Ue,render:()=>Ze,renderToString:()=>yt,renderToStringAsync:()=>gt,resetIntegration:()=>to,runHydrationAt:()=>te,runWithRequestContext:()=>K,runWithoutHydration:()=>_t,scrollIntoView:()=>tr,serializeNode:()=>A,serializeResourceData:()=>$e,setAttribute:()=>w,setClassList:()=>se,setClassName:()=>ie,setDataRedactor:()=>mt,setDynamicAttribute:()=>Te,setDynamicBoolAttribute:()=>Xe,setDynamicProperty:()=>be,setProperty:()=>oe,setRequestStore:()=>tt,setServerMode:()=>$,setStyle:()=>ae,setStyles:()=>xt,shouldSetAsProperty:()=>jn,signal:()=>Y.signal,splitProps:()=>Ur,spread:()=>Vr,store:()=>Cn.store,styleMap:()=>hn,svg:()=>Zt,templateNode:()=>Or,toAttributeName:()=>$n,toggleClass:()=>Kn,untrack:()=>g.untrack,useContext:()=>g.useContext,waitForElement:()=>or});module.exports=_n(wo);function $n(e){return e.startsWith("aria-")||e.startsWith("data-")?e:/[A-Z]/.test(e)?e.replace(/([A-Z])/g,"-$1").toLowerCase():e}function In(e){return e.startsWith("@")||e.startsWith("on")&&e.length>2}function qn(e){return e.startsWith("@")?e.slice(1):e.startsWith("on")?e.slice(2).toLowerCase():e}function jn(e,t){let n=new Set(["checked","value","selected","disabled","readonly","required","multiple","open","contenteditable","draggable","spellcheck"]),r={input:new Set(["value","checked","indeterminate"]),textarea:new Set(["value"]),select:new Set(["value"]),option:new Set(["selected","value"]),audio:new Set(["volume","currentTime","paused"]),video:new Set(["volume","currentTime","paused"]),img:new Set(["src","srcset"]),iframe:new Set(["src"]),a:new Set(["href"])};return n.has(t)||r[e]&&r[e].has(t)}var Hn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Fn=new Set(["svg","g","path","circle","rect","line","polyline","polygon","ellipse","text","tspan","use","defs","symbol","mask","clipPath","pattern","linearGradient","radialGradient","stop","filter","feGaussianBlur","feOffset","feMerge","feMergeNode","foreignObject"]),F="http://www.w3.org/2000/svg";function ht(e){return e.localName.includes("-")}function fe(e,t,n,r=!1){if(n==null){e.removeAttribute(t);return}if(ht(e)){e[t]=n;return}w(e,t,n,r)}var de=new Set(["className","value","checked","selected","innerHTML","innerText","textContent","indeterminate","htmlFor"]);function He(e,t=document){return t.querySelector(e)}function Vn(e,t=document){return Array.from(t.querySelectorAll(e))}function Wn(e,t){return e.closest(t)}function Un(e,...t){e.classList.add(...t)}function Bn(e,...t){e.classList.remove(...t)}function Kn(e,...t){t.forEach(n=>e.classList.toggle(n))}function zn(e,t){return e.classList.contains(t)}function w(e,t,n,r=!1){if(n==null||n===!1){e.removeAttribute(t);return}if(n===!0){e.setAttribute(t,"");return}if(typeof n=="object"){e.setAttribute(t,JSON.stringify(n));return}e.setAttribute(t,String(n))}function Gn(e,t){return e.getAttribute(t)}function Xn(e,t){e.removeAttribute(t)}function xt(e,t){Object.assign(e.style,t)}function Jn(e,t){return window.getComputedStyle(e).getPropertyValue(t)}function Yn(e,t={},...n){let r=document.createElement(e);return Object.entries(t).forEach(([o,i])=>{if(o==="class"||o==="className")r.className=i;else if(o==="style"&&typeof i=="object")xt(r,i);else if(o.startsWith("on")&&typeof i=="function"){let s=o.slice(2).toLowerCase();r.addEventListener(s,i)}else w(r,o,i)}),n.forEach(o=>{typeof o=="string"?r.appendChild(document.createTextNode(o)):r.appendChild(o)}),r}function Zn(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function Qn(e,...t){t.forEach(n=>{typeof n=="string"?e.appendChild(document.createTextNode(n)):e.appendChild(n)})}function er(e){let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=window.innerHeight&&t.right<=window.innerWidth}function tr(e,t={behavior:"smooth",block:"nearest"}){e.scrollIntoView(t)}function nr(e){let t=e.getBoundingClientRect();return{top:t.top+window.pageYOffset,left:t.left+window.pageXOffset}}function rr(e,t,n,r){let o=i=>{let s=i.target.closest(n);s&&e.contains(s)&&r(i,s)};return e.addEventListener(t,o),()=>{e.removeEventListener(t,o)}}function or(e,t=5e3){return new Promise((n,r)=>{let o=He(e);if(o){n(o);return}let i=new MutationObserver(()=>{let a=He(e);a&&(i.disconnect(),clearTimeout(s),n(a))});i.observe(document.body,{childList:!0,subtree:!0});let s=setTimeout(()=>{i.disconnect(),r(new Error(`Element ${e} not found within ${t}ms`))},t)})}function ir(e,t,n={}){let r=new IntersectionObserver(o=>{o.forEach(i=>{t(i.isIntersecting)})},n);return r.observe(e),()=>{r.disconnect()}}function sr(e,t){let n=new ResizeObserver(r=>{r.forEach(t)});return n.observe(e),()=>{n.disconnect()}}var ar=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;function lr(e){return typeof e=="object"&&e!==null&&e.$$typeof===ar}function Tt(e){return e&&typeof e=="object"&&e.strings&&Array.isArray(e.strings)&&e.values&&Array.isArray(e.values)}function cr(e){if(typeof e!="function")return!1;try{let t=e();return Tt(t)}catch{return!1}}function ur(e){return typeof e=="object"&&e!==null&&(e.$$typeof==="template"||typeof e.type=="function")}function fr(e){return e instanceof Node}function dr(e,t,n="Fluixi"){typeof globalThis<"u"&&(typeof globalThis[n]>"u"&&(globalThis[n]={}),typeof globalThis[n][e]>"u"&&(globalThis[n][e]=t))}function pr(e,t,n="Fluixi"){return typeof globalThis<"u"&&typeof globalThis[n]<"u"&&typeof globalThis[n][e]<"u"?globalThis[n][e]:t}var T=require("@fluixi/reactive/signal");var bt="1.0.0-alpha.83";var Et=require("@fluixi/reactive/version"),N={dom:bt,reactive:Et.VERSION};function wt(e){N.core&&e.setAttribute("fluixi",N.core),e.setAttribute("fx-dom",N.dom),e.setAttribute("fx-reactive",N.reactive),typeof globalThis<"u"&&(globalThis.Fluixi=N)}function Nt(){let e=[N.core,N.dom,N.reactive].filter(t=>t!==void 0);new Set(e).size<=1||console.warn(`[fluixi] package versions disagree — core ${N.core??"(absent)"}, dom ${N.dom}, reactive ${N.reactive}. These ship as one release, so a mismatch usually means a stale lockfile or two copies resolved side by side. Reinstall, or check for duplicates with \`pnpm why @fluixi/dom\`.`)}function yr(e){return Object.defineProperty(e,Symbol.for("fluixi-router"),{value:!0,enumerable:!0}),e}function mr(e){return Object.defineProperty(e,Symbol.for("fluixi-routes"),{value:!0,enumerable:!0}),e}function gr(e){return Object.defineProperty(e,Symbol.for("fluixi-route"),{value:!0,enumerable:!0}),e}function hr(e){return typeof e!="function"||Object.defineProperty(e,Symbol.for("fluixi-outlet"),{value:!0,enumerable:!0}),e}function xr(e){return Object.defineProperty(e,Symbol.for("fluixi-provider"),{value:!0,enumerable:!0}),e}function Tr(e){return Object.defineProperty(e,Symbol.for("fluixi-context"),{value:!0,enumerable:!0}),e}function Fe(e){return typeof e!="function"||Object.defineProperty(e,Symbol.for("fluixi-component"),{value:!0,enumerable:!0}),e}function br(e){return Object.defineProperty(e,Symbol.for("fluixi-suspense"),{value:!0,enumerable:!0}),e}function St(e){return typeof e=="function"&&e[Symbol.for("fluixi-router")]===!0}function vt(e){return typeof e=="function"&&e[Symbol.for("fluixi-routes")]===!0}function At(e){return typeof e=="function"&&e[Symbol.for("fluixi-route")]===!0}function Rt(e){return typeof e=="function"&&e[Symbol.for("fluixi-outlet")]===!0}function Ct(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Mt(e){return typeof e=="function"&&e[Symbol.for("fluixi-context")]===!0}function S(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Pt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Er(e){return St(e)?{type:"router",value:e}:At(e)?{type:"route",value:e}:vt(e)?{type:"routes",value:e}:Rt(e)?{type:"outlet",value:e}:S(e)?{type:"component",value:e}:Pt(e)?{type:"suspense",value:e}:Ct(e)?{type:"provider",value:e}:Mt(e)?{type:"context",value:e}:{type:"none",value:e}}var u=require("@fluixi/reactive/signal");var ee=Symbol.for("fluixi.server-node"),wr=Symbol.for("fluixi.dom.server-host"),Nr=globalThis,Q=Nr[wr]??={server:typeof document>"u",nodes:null};function h(){return Q.server}function $(e){Q.server=e}function kt(e){Q.nodes=e}function V(){if(!Q.nodes)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return Q.nodes}function I(e){return e!=null&&e[ee]===!0?!0:typeof Node<"u"&&e instanceof Node}function pe(e){return e!=null&&e[ee]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function ye(e){return e!=null&&e[ee]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var f={active:!1,cursor:null,parents:[]},Ot=null;function Lt(e){Ot=e}function me(){return Ot}function Ve(e,t){return f.active&&t.parentNode===e}function We(e){let t=f.parents.lastIndexOf(e);t!==-1&&(f.parents.length=t),f.cursor=e.nextSibling}function Dt(){return f.active?f.cursor:null}function te(e,t){if(!e||e.parentNode==null)return t();let n=f.active,r=f.cursor,o=f.parents;f.active=!0,f.cursor=e,f.parents=[];try{return t()}finally{f.active=n,f.cursor=r,f.parents=o}}function _t(e){if(!f.active)return e();let t=f.cursor,n=f.parents;f.active=!1,f.parents=[];try{return e()}finally{f.active=!0,f.cursor=t,f.parents=n}}function W(e){if(!f.active||e==null)return;let t=Array.isArray(e)?e[e.length-1]:e;t&&typeof t.nodeType=="number"&&We(t)}function Sr(e){let t=[];for(;e&&e.nodeType===1;){let n=e.tagName.toLowerCase();if(e.id){n+=`#${e.id}`,t.unshift(n);break}e.getAttribute("data-id")&&(n+=`[data-id="${e.getAttribute("data-id")}"]`);let r=0,o=e;for(;o=o.previousElementSibling;)o.tagName===e.tagName&&r++;n+=`:nth-of-type(${r+1})`,t.unshift(n),e=e.parentElement}return t.join(">")}function vr(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return`el_${Math.abs(t)}`}function Ar(e){return vr(Sr(e))}var Rr=()=>"xxyxxxxxxy-4xx8".replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),Cr={};var ge="__fx_at",jt="__fx_loc";function $t(e,t){return t&&(e[jt]=t),e}var It=new Map,he=new Set,Ee=new Set(["scroll","focus","blur","load","error","resize","mouseenter","mouseleave","pointerenter","pointerleave","gotpointercapture","lostpointercapture"]);function Be(e){if(!h())for(let t of e)he.has(t)||Ee.has(t)||(he.add(t),document.addEventListener(t,Mr))}function Mr(e){let t=`$$${e.type}`,n=e.composedPath&&e.composedPath()[0]||e.target;for(;n;){let r=n[t];if(r&&!n.disabled&&(r(e),e.cancelBubble))return;n=n.host&&n.host!==n&&n.host instanceof Element?n.host:n.parentNode}}function Ht(e,t,n){if(e[`$$${t}`]=n,Ee.has(t)){let r=`__fx_${t}`;if(!e[r]){let o=i=>{e[`$$${t}`]?.(i)};e.addEventListener(t,o),e[r]=o}return}he.has(t)||Be([t])}function Ue(e,t){delete e[`$$${t}`];let n=`__fx_${t}`,r=e[n];r&&(e.removeEventListener(t,r),delete e[n])}function Pr(e){return!Ee.has(e)}function kr(e){return typeof e=="function"}function D(e,t=!1){if(h())return V().createText(e);if(f.active&&!t){let n=me()?.hydrateText(e);if(n)return n}return document.createTextNode(e)}function Ke(e,t=!1,n){if(h())return V().createElement(e,t);if(f.active){let r=me()?.hydrateElement(e);if(r)return n?$t(r,n):r}return $t(t?document.createElementNS(F,e):document.createElement(e),n)}function Ft(e,t=!1){let n=It.get(e);if(n)return n;let r=document.createElement("template");return t?r.innerHTML=`<svg>${e}</svg>`:r.innerHTML=e,It.set(e,r),r}function Or(e,t,n=!1,r=!1,o){if(h()){let i=V();return n?i.parseTemplate(e,r):i.createRaw(e)}if(f.active){let i=me()?.hydrateStatic(t);if(i)return qt(i,o)}return qt(Vt(Ft(e,r),r).firstChild,o)}function qt(e,t){let n=e;if(!t||typeof n?.querySelectorAll!="function")return e;let r=[n,...n.querySelectorAll("*")];for(let o=0;o<r.length&&o*2+1<t.pos.length;o++){let i=t.pos[o*2];i&&(r[o][jt]={file:t.file,line:i,column:t.pos[o*2+1]})}return e}function Lr(e,t){if(!f.active)return t();let n=te(e.nextSibling,t);if(typeof n=="function"){let r=n;return Dr(r,(...i)=>f.active?te(e.nextSibling,()=>r(...i)):r(...i))}return n}function Dr(e,t){let n=e[ge];return n!==void 0&&(t[ge]=n),t}function _r(e){for(let t=e.nextSibling;t;t=t.nextSibling)if(t.nodeType===8&&t.data==="fx/")return t;throw new Error("[fluixi] template hole is missing its closing marker")}function $r(e,t){let n=[];for(let r=e.nextSibling;r&&r!==t;r=r.nextSibling)n.push(r);return n}function Vt(e,t=!1){let n=e.content.cloneNode(!0);return t?n.firstChild:n}function Wt(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Wt(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}function Ir(e){return typeof e!="function"?null:e._name||e.name||"anonymous"}function qr(e){if((0,T.isSignal)(e)||S(e)||typeof e!="function")return e;let t=e();for(;typeof t=="function"&&!(0,T.isSignal)(t)&&!S(t);)t=t();return t}var O=0,jr=200;function Hr(e,t,n,r,o){let i=r,s=new Map;return(0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(n??t,"content",void 0,e);let a;if(S(e)&&!(0,T.isSignal)(e)){if(!s.has(e)){O++;try{let l=e();s.set(e,l)}finally{O--}}for(a=s.get(e);typeof a=="function"&&(0,T.isSignal)(a);)a=a()}else for(a=e();typeof a=="function"&&(0,T.isSignal)(a);)a=a();{let l=0;for(;typeof a=="function"&&l++<50;)if(S(a)){if(!s.has(a)){let c=a;O++;try{let d=c();s.set(c,d)}finally{O--}}a=s.get(a)}else if((0,T.isSignal)(a))a=a();else if(a=a(),typeof a!="function"||!(0,T.isSignal)(a)&&!S(a))break}O++;try{i=re(t,a,n,i,s),o(i)}finally{O--}})}function C(e,t,n,r){if(O>jr)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;n!==void 0&&!n&&(n=D("",!0),e.appendChild(n));let o=r??null,i=l=>Array.isArray(l)&&l.some(c=>typeof c=="function"),s=l=>typeof l=="function"?l:()=>l;if(typeof t!="function"&&!i(t)){O++;try{o=re(e,t,n,o)}finally{O--}return()=>o}let a=Hr(s(t),e,n,o,l=>{o=l});return()=>(a?.(),o)}function re(e,t,n,r,o){if(t==null||typeof t=="boolean")return L(e,r,n);if(typeof t=="function")for(;typeof t=="function";)t=t();if(t==null||typeof t=="boolean")return L(e,r,n);if(ne(t)){let s=D("",!0);return Array.isArray(r)?r.length>0?(e.replaceChild(s,r[0]),L(e,r.slice(1),n)):b(e,s,n):r?e.replaceChild(s,r):b(e,s,n),t.then(a=>{s.parentNode===e&&re(e,a,s.nextSibling,s)}).catch(a=>{console.error("Error resolving promise in insertExpression:",a)}),s}let i=typeof t;if(i==="string"||i==="number"){if(i==="number"&&(t=String(t)),Array.isArray(r)){if(r.length===0){let a=D(t);return b(e,a,n),a}if(r.length===1&&r[0].nodeType===3)return r[0].data=t,r;r=L(e,r,n)}if(r&&ye(r))return r.data=t,r;let s=D(t);return r&&r.parentNode===e?e.replaceChild(s,r):Ve(e,s)||b(e,s,n),s}if(I(t))return Ve(e,t)?(We(t),t):Array.isArray(r)?(r.length===0?b(e,t,n):r[0].parentNode===e?(e.replaceChild(t,r[0]),L(e,r.slice(1),n)):b(e,t,n),t):(r?r!==t&&(r.parentNode===e?e.replaceChild(t,r):b(e,t,n)):b(e,t,n),t);if(Array.isArray(t)){let s=[],a=Array.isArray(r)?r:r?[r]:[],l=[];k(t,s,e,n,!0,o,l);let c=Fr(e,a,s,n);for(let d of l){let p=C(e,d.sig,d.marker);(0,u.onCleanup)(()=>{L(e,p()),d.marker.parentNode===e&&e.removeChild(d.marker)})}return c}if(i==="object"&&t!==null&&typeof t=="object"){let s=t;if("type"in s&&"props"in s){let a=s;if(typeof a.type=="function"){let l=a.type(a.props||{});return re(e,l,n,r)}}}return L(e,r,n)}function k(e,t,n,r,o=!0,i,s){for(let a=0;a<e.length;a++){let l=e[a];if(!(l==null||typeof l=="boolean")){for(;typeof l=="function"&&!ne(l)&&!(0,T.isSignal)(l)&&!S(l)&&(l=l(),!(l==null||typeof l=="boolean")););if(!(l==null||typeof l=="boolean")){if(typeof l=="function"){let c;for(S(l)&&!(0,T.isSignal)(l)?(i||(i=new Map),i.has(l)||i.set(l,l()),c=i.get(l)):c=l();typeof c=="function"&&!ne(c)&&!(0,T.isSignal)(c)&&!S(c);)i||(i=new Map),i.has(c)||i.set(c,c()),c=i.get(c);if(c==null||typeof c=="boolean")continue;if(typeof c=="function"){if((0,T.isSignal)(c)){if(s){let p=D("",!0);t.push(p),s.push({marker:p,sig:c});continue}let d=c();for(;typeof d=="function"&&(0,T.isSignal)(d);)d=d();if(d==null||typeof d=="boolean")continue;Array.isArray(d)?k(d,t,n,r,o,i):k([d],t,n,r,o,i);continue}continue}Array.isArray(c)?k(c,t,n,r,o,i,s):k([c],t,n,r,o,i,s);continue}if(ne(l)){let c=D("",!0);t.push(c),l.then(d=>{if(c.parentNode){let p=[];if(k([d],p,c.parentNode,void 0,!1,i),p.length>0){c.parentNode.replaceChild(p[0],c);for(let y=1;y<p.length;y++)c.parentNode?.insertBefore(p[y],p[y-1].nextSibling)}}}).catch(d=>console.error("Error resolving promise in array:",d));continue}if(Array.isArray(l)){k(l,t,n,r,o,i,s);continue}if(I(l)){t.push(l);continue}if(typeof l=="object"&&l!==null&&"type"in l&&"props"in l){let c=l;if(typeof c.type=="function"){let d=c.type(c.props||{});Array.isArray(d)?k(d,t,n,r,!1,i):k([d],t,n,r,!1,i);continue}}if(typeof l=="string"||typeof l=="number"){let c=String(l);if(c.trim()===""&&c!==" ")continue;t.push(D(c));continue}t.push(D(String(l)))}}}}function Fr(e,t,n,r){for(let p=0;p<n.length;p++){let y=n[p].parentNode;y!==null&&y!==e&&y.nodeType!==11&&(n=n.slice(),n[p]=n[p].cloneNode(!0))}let o=n.length,i=t.length,s=o,a=0,l=0,c=i>0?t[i-1].nextSibling??void 0:r,d=null;for(;a<i||l<s;){if(t[a]===n[l]){a++,l++;continue}for(;i>a&&s>l&&t[i-1]===n[s-1];)i--,s--;if(i===a){let p=s<o?l?n[l-1].nextSibling??void 0:n[s-l]:c;for(;l<s;)b(e,n[l++],p)}else if(s===l)for(;a<i;)(!d||!d.has(t[a]))&&t[a].parentNode===e&&e.removeChild(t[a]),a++;else if(t[a]===n[s-1]&&n[l]===t[i-1]){let p=t[--i].nextSibling;b(e,n[l++],t[a++].nextSibling),b(e,n[--s],p),t[i]=t[a-1]}else{if(!d){d=new Map;let y=l;for(;y<s;)d.set(n[y],y++)}let p=d.get(t[a]);if(p!=null)if(l<p&&p<s){let y=a,m=1;for(;++y<i&&y<s&&!(!d.has(t[y])||d.get(t[y])!==p+m);)m++;if(m>p-l){let Ie=t[a];for(;l<p;)b(e,n[l++],Ie)}else t[a].parentNode===e?e.replaceChild(n[l++],t[a++]):(b(e,n[l++],c),a++)}else a++;else t[a].parentNode===e&&e.removeChild(t[a]),a++}}return n}function L(e,t,n){if(t)if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r].parentNode===e&&e.removeChild(t[r]);else t.parentNode===e&&e.removeChild(t);return null}function b(e,t,n){f.active&&t.parentNode===e||(n&&n.parentNode===e?e.insertBefore(t,n):e.appendChild(t))}function oe(e,t,n){n==null?delete e[t]:e[t]=n}function ze(e,t,n){let r=n,o;return Array.isArray(n)&&(r=n[0],o=n[1]),typeof r!="function"?()=>{}:(e.addEventListener(t,r,o),()=>e.removeEventListener(t,r,o))}function Ut(e,t){if(!t||typeof t!="function")return;let n=t[ge]?.name;if(!n)return;let r=n.indexOf(":");r!==-1&&(0,u.reportReactiveDirective)(e,n.slice(0,r),n.slice(r+1),t)}function xe(e,t,n){let r=typeof n=="function"?(0,u.untrack)(()=>n()):n;if(!(!r||typeof r!="object"))for(let o of Object.keys(r))(0,u.reportReactiveDirective)(e,t,o)}function Ge(e,t){let n=(r,o)=>{typeof r=="function"&&((0,u.reportReactiveDirective)(e,"use",r.name||"use",o),r(e,o??(()=>{})))};if(typeof t=="function"){n(t);return}if(Array.isArray(t)){if(typeof t[0]=="function"){n(t[0],t[1]);return}for(let r of t)Array.isArray(r)?n(r[0],r[1]):n(r)}}function Te(e,t,n,r=!1){return Ut(e,n),typeof n!="function"?(w(e,t,n,r),()=>{}):(0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(e,"attribute",t,n);let o=typeof n=="function"?n():n;w(e,t,o,r)})}function be(e,t,n){return typeof n!="function"?(oe(e,t,n),()=>{}):(Ut(e,n),(0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(e,"property",t,n);let r=typeof n=="function"?n():n;oe(e,t,r)}))}function Xe(e,t,n){return typeof n!="function"?(w(e,t,!!n),()=>{}):(0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(e,"attribute",t,n);let r=n();w(e,t,!!r)})}function ie(e,t){if(t==null){e.removeAttribute("class");return}if(typeof t=="function"){(0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(e,"attribute","class",t),ie(e,t())});return}if(typeof t=="string"){e.setAttribute("class",t);return}if(Array.isArray(t)){e.setAttribute("class",t.filter(Boolean).join(" "));return}if(typeof t=="object"){let n=Object.keys(t).filter(r=>{let o=t[r];return typeof o=="function"?o():!!o}).join(" ");e.setAttribute("class",n);return}e.setAttribute("class",String(t))}function se(e,t,n){if(!(!t||typeof t!="object"))for(let r in t){let o=t[r],i=r.split(/\s+/).filter(Boolean);if(typeof o=="function"&&n)n.push((0,u.createRenderEffect)(()=>{let s=!!o();for(let a of i)e.classList.toggle(a,s)}));else{let s=!!(typeof o=="function"?o():o);for(let a of i)e.classList.toggle(a,s)}}}function ae(e,t){let n=t;for(;typeof n=="function";)n=n();if(n==null){e.removeAttribute("style");return}if(typeof n=="string"){e.style.cssText=n;return}if(typeof n=="object")for(let r in n){let o=n[r];o==null?e.style[r]="":e.style[r]=o}}function Vr(e){let{element:t,props:n,prevProps:r=Cr,isSVG:o=!1,skipChildren:i=!1}=e;if(!t||!pe(t))return console.error("[spread] Error: element is not a DOM Element!"),()=>{};if(!n)return console.warn("[spread] Warning: props is undefined!"),()=>{};let s=o||t.namespaceURI===F,a=[];for(let l in n){if(i&&l==="children")continue;let c=n[l],d=r[l];if(c===d)continue;if(l==="ref"){le(c,t);continue}if(l==="use"){Ge(t,c);continue}if(l.startsWith("on:")){a.push(ze(t,l.slice(3),c));continue}if(l.startsWith("prop:")){(0,u.reportReactiveDirective)(t,"prop",l.slice(5),c),a.push(be(t,l.slice(5),c));continue}if(l.startsWith("attr:")){(0,u.reportReactiveDirective)(t,"attr",l.slice(5),c),a.push(Te(t,l.slice(5),c,s));continue}if(l.startsWith("bool:")){(0,u.reportReactiveDirective)(t,"bool",l.slice(5),c),a.push(Xe(t,l.slice(5),c));continue}if(l==="class"||l==="className"){typeof c=="function"?a.push((0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(t,"attribute","class",c),ie(t,c())})):ie(t,c);continue}if(l==="classList"){xe(t,"class",c),typeof c=="function"?a.push((0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(t,"attribute","class",c),se(t,c())})):se(t,c,a);continue}if(l==="style"){xe(t,"style",c),typeof c=="function"?a.push((0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(t,"attribute","style",c),ae(t,c())})):ae(t,c);continue}if(l.startsWith("on")){let y=l.slice(2).toLowerCase();d&&Ue(t,y),c&&Ht(t,y,c);continue}let p=de.has(l)||!s&&l in t;typeof c=="function"?a.push(p?be(t,l,c):Te(t,l,c,s)):a.push((0,u.createRenderEffect)(()=>p?oe(t,l,n[l]):w(t,l,n[l],s)))}for(let l in r)if(!(l in n))if(l.startsWith("on")){let c=l.slice(2).toLowerCase();Ue(t,c)}else de.has(l)?oe(t,l,null):t.removeAttribute(l);return()=>{a.forEach(l=>l())}}function Je(e,t,n=!1){for(let r in t){let o=t[r];if(r==="ref"){le(o,e);continue}if(r!=="children"){if(r==="use"){Ge(e,o);continue}if(r.startsWith("on:")){ze(e,r.slice(3),o);continue}if(r.startsWith("prop:")){(0,u.reportReactiveDirective)(e,"prop",r.slice(5),o),be(e,r.slice(5),o);continue}if(r.startsWith("attr:")){(0,u.reportReactiveDirective)(e,"attr",r.slice(5),o),Te(e,r.slice(5),o,n);continue}if(r.startsWith("bool:")){(0,u.reportReactiveDirective)(e,"bool",r.slice(5),o),Xe(e,r.slice(5),o);continue}if(r.startsWith("on")&&r.length>2){let i=r.slice(2).toLowerCase();if(typeof o=="function")if(Ee.has(i)){e[`$$${i}`]=o;let s=`__fx_${i}`;if(!e[s]){let a=l=>{e[`$$${i}`]?.(l)};e.addEventListener(i,a),e[s]=a}}else e[`$$${i}`]=o,he.has(i)||Be([i]);continue}if(r==="class"||r==="className"){ie(e,o);continue}if(r==="classList"){xe(e,"class",o),typeof o=="function"?(0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(e,"attribute","class",o),se(e,o())}):se(e,o);continue}if(r==="style"){xe(e,"style",o),typeof o=="function"?(0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(e,"attribute","style",o),ae(e,o())}):ae(e,o);continue}if(r==="innerHTML"){if(typeof o=="function"){let i=(0,u.createEffect)(()=>{let s=o();for(;typeof s=="function";)s=s();e.innerHTML=s});(0,u.onCleanup)(()=>i())}else e.innerHTML=o;continue}if(r==="value"&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA")){if(typeof o=="function"){let i=(0,u.createEffect)(()=>{let s=o();for(;typeof s=="function"&&s.length===0;)s=s();document.activeElement!==e&&(e.value=s??"")});(0,u.onCleanup)(()=>{i()})}else(0,u.createRenderEffect)(()=>{document.activeElement!==e&&(e.value=t[r]??"")});continue}if(r==="checked"&&e.tagName==="INPUT"){if(typeof o=="function"){let i=(0,u.createEffect)(()=>{let s=o();for(;typeof s=="function"&&s.length===0;)s=s();document.activeElement!==e&&(e.checked=s??"")});(0,u.onCleanup)(()=>{i()})}else(0,u.createRenderEffect)(()=>{document.activeElement!==e&&(e.checked=t[r]??"")});continue}if(r==="value"&&e.tagName==="SELECT"){if(typeof o=="function"){let i=!0,s=(0,u.createEffect)(()=>{let a=o();for(;typeof a=="function"&&a.length===0;)a=a();i?(i=!1,queueMicrotask(()=>{e.value=a??""})):e.value=a??""});(0,u.onCleanup)(()=>{s()})}else{let i=!0;(0,u.createRenderEffect)(()=>{let s=t[r];i?(i=!1,queueMicrotask(()=>{e.value=s??""})):e.value=s??""})}continue}if(typeof o=="function"){let i=(0,u.createEffect)(()=>{let s=o();for(;typeof s=="function"&&s.length===0;)s=s();fe(e,r,s,n)});(0,u.onCleanup)(()=>{i()})}else(0,u.createRenderEffect)(()=>fe(e,r,t[r],n))}}}function Wr(...e){let t=r=>{for(let o=e.length-1;o>=0;o--){let i=e[o];if(i&&r in i&&i[r]!==void 0)return i[r]}},n=r=>{for(let o of e)if(o&&r in o)return!0;return!1};return new Proxy({},{get:(r,o)=>t(o),has:(r,o)=>n(o),ownKeys:()=>{let r=new Set;for(let o of e)if(o)for(let i of Reflect.ownKeys(o))r.add(i);return[...r]},getOwnPropertyDescriptor:(r,o)=>n(o)?{enumerable:!0,configurable:!0,get:()=>t(o)}:void 0})}function Ur(e,...t){let n=new Set;for(let s of t)for(let a of s)n.add(a);let r=s=>({enumerable:!0,configurable:!0,get:()=>e[s]}),o=t.map(s=>{let a=new Set(s);return new Proxy({},{get:(l,c)=>a.has(c)?e[c]:void 0,has:(l,c)=>a.has(c)&&c in e,ownKeys:()=>Array.from(a).filter(l=>l in e),getOwnPropertyDescriptor:(l,c)=>a.has(c)&&c in e?r(c):void 0})}),i=new Proxy({},{get:(s,a)=>n.has(a)?void 0:e[a],has:(s,a)=>!n.has(a)&&a in e,ownKeys:()=>Reflect.ownKeys(e).filter(s=>!n.has(s)),getOwnPropertyDescriptor:(s,a)=>!n.has(a)&&a in e?r(a):void 0});return[...o,i]}function le(e,t){if(!e)return;let n=e[ge]?.name;if((0,u.reportReactiveDirective)(t,"ref",n||typeof e=="function"&&e.name||"ref",e),I(e)){let r=t,o=e;if(!r)return;typeof r=="function"?r(o):typeof r=="object"&&"current"in r&&(r.current=o);return}typeof e=="function"?e(t):typeof e=="object"&&"current"in e&&(e.current=t)}function Br(e,t,n){let r=t||document.body,o=(0,u.readChildren)(()=>e),i=[];return(0,u.batch)(()=>{let s=(0,u.createRenderEffect)(()=>{let a=o();Array.isArray(a)?(a.forEach(l=>r.appendChild(l)),i.push(()=>{a.forEach(l=>{l.parentNode===r&&r.removeChild(l)})})):I(a)&&(r.appendChild(a),i.push(()=>{a.parentNode===r&&r.removeChild(a)}))});i.push(s),(0,u.onCleanup)(()=>{i.forEach(a=>a())})}),null}function Kr(e){return typeof e=="string"&&e.toLowerCase()===e}function Ye(e){return e==="svg"||e==="path"||e==="circle"||e==="rect"||e==="line"||e==="polygon"||e==="polyline"||e==="ellipse"||e==="g"||e==="defs"||e==="clipPath"||e==="text"}function zr(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ne(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function Gr(e){return typeof e=="function"&&e.length===0&&(0,T.isSignal)(e)}function Ze(e,t,n){if(!t)throw new Error("Container element is required");let r,o,i=[];return(0,u.createRoot)(s=>{(0,u.batch)(()=>{f.active||(t.textContent=""),wt(t),Nt(),C(t,e)}),o=s}),()=>{o?.(),r?.(),i.forEach(s=>s()),t.textContent=""}}function Xr(e){if(Array.isArray(e))return e;if(typeof e=="function"&&typeof e.set=="function")return[e,e.set];throw new TypeError("[fluixi] bind: needs a signal — either `signal(…)` or the `[get, set]` pair from `createSignal(…)`.")}var U=require("@fluixi/reactive");var Jr="__fx_dom_create_component__",q=globalThis[Jr]??={fn:null};function Yr(e){q.fn=e}function Zr(e={}){let t=e.signalSystem?.createComponent;t&&(q.fn=t)}function Qe(e,t){if(q.fn)return q.fn(e,t);t&&(0,U.reportReactiveProps)(t);let n=typeof e=="function"?(0,U.untrack)(()=>e(t)):e,r=n!=null&&(typeof n=="function"||typeof n=="object");if(r)try{n.$name=e?.name}catch{}return r&&!(0,U.isSignal)(n)?Fe(n):n}var Qr=()=>q.fn!==null,eo=()=>q.fn!==null;function to(){q.fn=null}var we,Kt={getStore:()=>we,run(e,t){let n=we;we=e;try{return t()}finally{we=n}}},et=Kt;function tt(e){et=e??Kt}function B(e={}){e.locals||(e.locals=e.request?Se(e.request):{});let t=0,n=0,r=null,o=new Map,i=new Map;return{event:e,routeData:new Map,matchedRoute:new Map,nextId:()=>`s${t++}`,nextResourceId:()=>{if(r===null)return`r${n++}`;let s=o.get(r)??0;return o.set(r,s+1),`${r}:r${s}`},nextIslandNamespace:s=>{let a=i.get(s)??0;return i.set(s,a+1),`${s}#${a}`},withResourceScope(s,a){let l=r;r=s;try{return a()}finally{r=l}},pending:new Set,data:new Map}}function K(e,t){return et.run(e,t)}function M(){return et.getStore()}function Ne(){return M()?.event}function nt(){let e=Ne();return e?(e.locals||(e.locals={}),e.locals):{}}var Bt=new WeakMap;function Se(e){let t=Bt.get(e);return t||(t={},Bt.set(e,t)),t}var ve=require("@fluixi/reactive/signal");var z="__FX_DATA__";function ce(e){return e.replace(/[<>&\u2028\u2029]/g,t=>"\\u"+t.charCodeAt(0).toString(16).padStart(4,"0"))}var rt;function ue(){let e=globalThis.__FX_DATA__;if(e)return e;if(rt!==void 0)return rt;let t=null;if(typeof document<"u"){let n=document.getElementById(z)?.textContent;if(n)try{t=JSON.parse(n)}catch{t=null}}return rt=t}function Ae(){for(;;){for(;f.cursor&&f.cursor.nodeType===3&&f.cursor.data==="";)f.cursor=f.cursor.nextSibling;if(f.cursor!=null||!f.parents.length)return;f.cursor=f.parents.pop().nextSibling}}var no=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Re=typeof process<"u"&&process.env&&!1;function Ce(e,t){let n=t.nodeType===1?`<${t.tagName.toLowerCase()}>`:t.nodeType===3?`text ${JSON.stringify((t.nodeValue??"").slice(0,24))}`:t.nodeType===8?"comment":"node";console.warn(`[fluixi] hydration mismatch: expected ${e} but the server DOM has ${n}. Server and client rendered different markup; recreating this node on the client. Check for non-deterministic render (Date.now(), Math.random(), browser-only branches, untransported data).`)}function ro(e){Ae();let t=f.cursor;return t&&t.nodeType===1&&t.tagName.toLowerCase()===e.toLowerCase()?(no.has(e.toLowerCase())?f.cursor=t.nextSibling:(f.parents.push(t),f.cursor=t.firstChild),t):(Re&&t&&Ce(`<${e}>`,t),null)}function oo(e){Ae();let t=f.cursor;return t&&t.nodeType===1&&t.tagName.toLowerCase()===e.toLowerCase()?(f.cursor=t.nextSibling,t):(Re&&t&&Ce(`<${e}> (static)`,t),null)}function io(e){if(e===""){let n=f.cursor;return n&&n.nodeType===3&&n.data!==""?(f.cursor=n.nextSibling,n.data="",n):null}Ae();let t=f.cursor;return t&&t.nodeType===3?(f.cursor=t.nextSibling,t.nodeValue!==e&&(t.nodeValue=e),t):(Re&&t&&Ce(`text ${JSON.stringify(e.slice(0,24))}`,t),null)}function so(e){Ae();let t=f.cursor;return t&&t.nodeType===8&&t.data===e?(f.cursor=t.nextSibling,t):(Re&&t&&Ce(`marker <!--${e.slice(0,24)}-->`,t),null)}var zt=!1;function ao(){zt||(zt=!0,Lt({hydrateElement:ro,hydrateText:io,hydrateMarker:so,hydrateStatic:oo}))}function Me(e,t,n){ao(),f.active=!0,f.cursor=t.firstChild,f.parents=[];let r=ue(),o=n?.resourceNamespace,i=0;(0,ve.setResourceIdSource)(()=>o?`${o}:r${i++}`:`r${i++}`),(0,ve.setServerDataGetter)(r?s=>s in r?{value:r[s]}:void 0:null);try{return Ze(e,t)}finally{f.active=!1,f.cursor=null,f.parents=[]}}var ot="fluixi-island";function Xt(e){let{component:t,props:n={},name:r}=e,o=Ke(ot),i=r??t.name??"Island";w(o,"name",i),w(o,"props",JSON.stringify(n??{}));let s=h()?M():void 0;if(s){let a=s.nextIslandNamespace(i);C(o,()=>s.withResourceScope(a,()=>t(n)))}else C(o,()=>t(n));return o}var Gt=!1;function lo(){if(Gt||typeof document>"u")return;Gt=!0;let e=document.createElement("style");e.textContent=`${ot}{display:contents}`,document.head.appendChild(e)}function Jt(e){if(typeof document>"u")return;lo();let t=document.querySelectorAll(ot),n=new Map;t.forEach(r=>{let o=r.getAttribute("name")??"",i=n.get(o)??0;n.set(o,i+1);let s=e[o];if(!s){typeof process>"u"&&console.warn(`[fluixi] island "${o}" has no component in the registry — left static.`);return}let a={};try{a=JSON.parse(r.getAttribute("props")||"{}")}catch{}Me(()=>s(a),r,{resourceNamespace:`${o}#${i}`})})}function Yt(e,...t){throw new Error("html`` was not compiled — enable the lit format: fluixi({ format: 'lit' }).")}function Zt(e,...t){throw new Error("svg`` was not compiled — enable the lit format: fluixi({ format: 'lit' }).")}var Qt=require("@fluixi/reactive/signal");function co(e,t={}){if(typeof e=="function")return Qe(e,t);if(typeof e!="string"||e.length===0)return null;let n=Ye(e);if(h())return V().createElement(e,n);let r=n?document.createElementNS(F,e):document.createElement(e);return Je(r,t,n),uo(r,t),r}function uo(e,t){if(!t||t.children===void 0)return;let n=(0,Qt.readChildren)(()=>t.children),r=o=>{C(e,o,typeof o=="function"?null:void 0)};Array.isArray(n)?n.forEach(r):r(n)}var x=require("@fluixi/reactive/signal");function en(e){return typeof e=="function"?e:(()=>e)}function _(e){return()=>{let t=e();return typeof t=="function"?t():t}}function tn(e){return e!=null&&e!==!1}function nn(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function rn(e){let t=_(()=>e.when),n=(0,x.createMemo)(t,void 0,{name:"Show.when"}),r=(0,x.createMemo)(n,void 0,{name:"Show.cond"}),o=(0,x.getOwner)(),i=null,s=null,a=l=>{l!==s&&(i&&(0,x.disposeScope)(i),i=(0,x.createChildOwner)(o),s=l)};return(0,x.createMemo)(()=>{let l=r();return a(l?"when":"fallback"),(0,x.runWithOwner)(i,()=>{if(l){let c=e.children;return typeof c=="function"&&!nn(c)?typeof n=="function"?(0,x.untrack)(()=>(0,x.untrack)(n)?c(n()):e.fallback):c(n):c}return e.fallback});return e.fallback??null},void 0,{name:"Show.result"})}var Pe=require("@fluixi/reactive/signal");function on(e){let t=_(()=>e.each),n=()=>e.fallback??null,r=(o,i)=>{let s=e.children,a=Array.isArray(s)?s.map(l=>typeof l=="function"?l(o,i):l):typeof s=="function"?s(o,i):s;return W(a),a};return e.by?(0,Pe.keyArray)(t,e.by,(o,i)=>r(o,i),{fallback:n}):(0,Pe.mapArray)(t,(o,i)=>r(o,i),{fallback:n})}var sn=require("@fluixi/reactive/signal");function an(e){let t=_(()=>e.each);return(0,sn.indexArray)(t,(n,r)=>{let o=e.children(n,r);return W(o),o},{fallback:()=>e.fallback??null})}var G=require("@fluixi/reactive/signal");var v=require("@fluixi/reactive/signal");var it=Symbol("match");function ln(e){return{[it]:!0,when:_(()=>e.when),get children(){return e.children}}}function cn(e){let t=Array.isArray(e.children)?e.children:[e.children],n=(0,v.getOwner)(),r=null,o=-1,i=s=>{s!==o&&(r&&(0,v.disposeScope)(r),r=(0,v.createChildOwner)(n),o=s)};return(0,v.createMemo)(()=>{for(let s=0;s<t.length;s+=1){let l=t[s],c=0;for(;typeof l=="function"&&!l[it]&&c++<10;)l=l();if(!l||typeof l!="object"||l[it]!==!0)continue;let d=l.when();if(tn(d))return i(s),(0,v.runWithOwner)(r,()=>typeof l.children=="function"?l.children(d):l.children)}return i(-2),(0,v.runWithOwner)(r,()=>e.fallback??null)},void 0,{name:"Switch"})}var P=require("@fluixi/reactive/signal");function un(e){let t=en(e.component),{component:n,...r}=e,o=(0,P.getOwner)(),i=null,s;return(0,P.createMemo)(()=>{let a=t();return a!==s&&(i&&(0,P.disposeScope)(i),i=(0,P.createChildOwner)(o),s=a),a==null?null:typeof a=="string"?{tag:a,props:r}:(0,P.runWithOwner)(i,()=>a(r))},void 0,{name:"Dynamic"})}var ke=require("@fluixi/reactive/signal");function fn(e){let t=()=>e.mount?typeof e.mount=="function"?e.mount():e.mount:document.body,n,r;return(0,ke.createRoot)(o=>{n=o,r=document.createElement("div"),r.style.display="contents",t().appendChild(r),C(r,e.children)&&le(e.ref,r)}),(0,ke.onCleanup)(()=>{n(),r.remove()}),null}var Oe=require("@fluixi/reactive/signal");function st(e){if(h())return e.fallback??null;let t=f.active,[n,r]=(0,Oe.createSignal)(!t);return t&&queueMicrotask(()=>r(!0)),(0,Oe.createMemo)(()=>n()?e.children:e.fallback??null,void 0,{name:"client-only"})}var dn=st;var Le=require("@fluixi/reactive/signal");function pn(e){let[t,n]=(0,Le.createSignal)(null),r=()=>n(null);return(0,Le.createMemo)(()=>{let o=t();if(o!==null)return typeof e.fallback=="function"?e.fallback(o,r):e.fallback;try{return typeof e.children=="function"?e.children():e.children}catch(i){return n(i),typeof e.fallback=="function"?e.fallback(i,r):e.fallback}},void 0,{name:"ErrorBoundary"})}var yn=require("@fluixi/reactive/signal");function mn(e){return(0,yn.createMemo)(()=>{let t=typeof e=="function"?e():e,n=[];for(let[r,o]of Object.entries(t)){if(!r)continue;(typeof o=="function"?o():o)&&n.push(r)}return n.join(" ")},void 0,{name:"ClassMap"})}var gn=require("@fluixi/reactive/signal");function fo(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function hn(e){return(0,gn.createMemo)(()=>{let t=typeof e=="function"?e():e,n=[];for(let[r,o]of Object.entries(t)){if(!r)continue;let i=typeof o=="function"?o():o;i!=null&&n.push(`${fo(r)}: ${i}`)}return n.join("; ")},void 0,{name:"StyleMap"})}var _e=1,ct=3,ut=8,xn;xn=ee;var X=class{constructor(){this[xn]=!0;this.parentNode=null;this.childNodes=[]}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get nextSibling(){let t=this.parentNode;if(!t)return null;let n=t.childNodes.indexOf(this);return n>=0?t.childNodes[n+1]??null:null}get previousSibling(){let t=this.parentNode;if(!t)return null;let n=t.childNodes.indexOf(this);return n>0?t.childNodes[n-1]??null:null}get parentElement(){return this.parentNode}appendChild(t){return t.parentNode&&t.parentNode.removeChild(t),t.parentNode=this,this.childNodes.push(t),t}insertBefore(t,n){if(n==null)return this.appendChild(t);t.parentNode&&t.parentNode.removeChild(t);let r=this.childNodes.indexOf(n);return t.parentNode=this,r<0?this.childNodes.push(t):this.childNodes.splice(r,0,t),t}removeChild(t){let n=this.childNodes.indexOf(t);return n>=0&&this.childNodes.splice(n,1),t.parentNode=null,t}replaceChild(t,n){let r=this.childNodes.indexOf(n);return r>=0&&(t.parentNode&&t.parentNode.removeChild(t),t.parentNode=this,this.childNodes[r]=t,n.parentNode=null),n}addEventListener(){}removeEventListener(){}},j=class e extends X{constructor(n){super();this.nodeType=ct;this.data=n}get nodeValue(){return this.data}set nodeValue(n){this.data=n==null?"":String(n)}get textContent(){return this.data}set textContent(n){this.data=n==null?"":String(n)}cloneNode(){return new e(this.data)}},De=class e extends X{constructor(n){super();this.nodeType=_e;this.rawOuterHTML=n}get textContent(){return this.rawOuterHTML.replace(/<[^>]*>/g,"")}cloneNode(){return new e(this.rawOuterHTML)}},J=class e extends X{constructor(n){super();this.nodeType=ut;this.data=n}get nodeValue(){return this.data}set nodeValue(n){this.data=n==null?"":String(n)}cloneNode(){return new e(this.data)}},at=class{constructor(){this.cssText=""}setProperty(t,n){this[t]=n}removeProperty(t){delete this[t]}},lt=class{constructor(t){this.el=t}list(){let t=this.el.getAttribute("class");return t?t.split(/\s+/).filter(Boolean):[]}write(t){t.length?this.el.setAttribute("class",t.join(" ")):this.el.removeAttribute("class")}add(...t){let n=this.list();for(let r of t)n.includes(r)||n.push(r);this.write(n)}remove(...t){this.write(this.list().filter(n=>!t.includes(n)))}contains(t){return this.list().includes(t)}toggle(t,n){let r=this.contains(t),o=n===void 0?!r:n;return o?this.add(t):this.remove(t),o}},H=class e extends X{constructor(n,r=!1){super();this.nodeType=_e;this.attributes=new Map;this.style=new at;this.classList=new lt(this);this.rawHTML=null;this.localName=n.toLowerCase(),this.tagName=r?n:n.toUpperCase(),this.isSVG=r,this.namespaceURI=r?"http://www.w3.org/2000/svg":null}setAttribute(n,r){this.attributes.set(n,String(r))}removeAttribute(n){this.attributes.delete(n)}getAttribute(n){return this.attributes.has(n)?this.attributes.get(n):null}hasAttribute(n){return this.attributes.has(n)}get id(){return this.getAttribute("id")??""}set id(n){n==null?this.removeAttribute("id"):this.setAttribute("id",n)}get className(){return this.getAttribute("class")??""}set className(n){n==null?this.removeAttribute("class"):this.setAttribute("class",n)}get htmlFor(){return this.getAttribute("for")??""}set htmlFor(n){n==null?this.removeAttribute("for"):this.setAttribute("for",n)}set value(n){n==null?this.removeAttribute("value"):this.setAttribute("value",String(n))}set checked(n){n?this.setAttribute("checked",""):this.removeAttribute("checked")}set selected(n){n?this.setAttribute("selected",""):this.removeAttribute("selected")}set indeterminate(n){}get textContent(){return this.childNodes.map(n=>n.textContent??"").join("")}set textContent(n){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=null,n!=null&&n!==""&&this.appendChild(new j(String(n)))}set innerText(n){this.textContent=n}set innerHTML(n){for(let r of this.childNodes)r.parentNode=null;this.childNodes=[],this.rawHTML=n==null?"":String(n)}cloneNode(n=!1){let r=new e(this.localName,this.isSVG);if(r.attributes=new Map(this.attributes),r.style.cssText=this.style.cssText,r.rawHTML=this.rawHTML,n)for(let o of this.childNodes)r.appendChild(o.cloneNode(!0));return r}};var po=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),bn=/&/g,En=/</g,wn=/>/g,yo=/"/g;function ft(e){return e.replace(bn,"&amp;").replace(En,"&lt;").replace(wn,"&gt;")}function Tn(e){return e.replace(bn,"&amp;").replace(yo,"&quot;").replace(En,"&lt;").replace(wn,"&gt;")}function mo(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function go(e){if(!e)return"";let t=[];e.cssText&&t.push(e.cssText.trim().replace(/;\s*$/,""));for(let n of Object.keys(e)){if(n==="cssText")continue;let r=e[n];r==null||r===""||t.push(`${mo(n)}: ${r}`)}return t.join("; ")}function ho(e){let t="",n=go(e.style);for(let[r,o]of e.attributes)r==="style"&&n||(t+=` ${r}="${Tn(o)}"`);if(n){let r=e.attributes.get("style"),o=r?`${r.replace(/;\s*$/,"")}; ${n}`:n;t+=` style="${Tn(o)}"`}return t}function A(e){if(e==null||e===!1||e===!0)return"";if(typeof e=="string")return ft(e);if(typeof e=="number")return ft(String(e));if(typeof e=="function")return A(e());if(Array.isArray(e))return e.map(A).join("");if(typeof e.rawOuterHTML=="string")return e.rawOuterHTML;switch(e.nodeType){case ct:return ft(e.data??"");case ut:return`<!--${e.data??""}-->`;case _e:{let t=e.localName,n=`<${t}${ho(e)}>`;if(po.has(t))return n;let r=e.rawHTML!=null?e.rawHTML:(e.childNodes??[]).map(A).join("");return`${n}${r}</${t}>`}}return Array.isArray(e.childNodes)?e.childNodes.map(A).join(""):""}var pt=require("@fluixi/reactive/signal"),E=require("@fluixi/reactive/signal");var xo=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),To={amp:"&",lt:"<",gt:">",quot:'"',"#39":"'"};function Nn(e){return e.replace(/&(#?\w+);/g,(t,n)=>To[n]??t)}var R=class extends Error{};function Sn(e,t=!1){let n=0,r=[],o=[],i=c=>{let d=o[o.length-1];d?d.appendChild(c):r.push(c)};for(;n<e.length;){let c=e.indexOf("<",n);if(c===-1){a(e.slice(n));break}if(c>n&&a(e.slice(n,c)),e.startsWith("<!--",c)){let d=e.indexOf("-->",c);if(d===-1)throw new R(`unterminated comment at ${c}`);i(new J(e.slice(c+4,d))),n=d+3;continue}if(e[c+1]==="/"){let d=e.indexOf(">",c);if(d===-1)throw new R(`unterminated closing tag at ${c}`);let p=e.slice(c+2,d).trim().toLowerCase(),y=o.pop();if(!y||y.localName!==p)throw new R(`</${p}> does not close <${y?.localName??"nothing"}>`);n=d+1;continue}n=l(c)}if(o.length>0)throw new R(`unclosed <${o[o.length-1].localName}>`);let s=r[0];if(r.length!==1||!(s instanceof H))throw new R(`expected exactly one root element, got ${r.length}`);return s;function a(c){c!==""&&i(new j(Nn(c)))}function l(c){let d=/[\s/>]/.exec(e.slice(c+1));if(!d)throw new R(`unterminated tag at ${c}`);let p=e.slice(c+1,c+1+d.index).toLowerCase(),y=new H(p,t),m=c+1+d.index;for(;m<e.length;){for(;m<e.length&&/\s/.test(e[m]);)m++;if(e[m]===">"){m++;break}if(e[m]==="/"&&e[m+1]===">"){m+=2;break}let Ie=m;for(;m<e.length&&!/[\s=/>]/.test(e[m]);)m++;let Z=e.slice(Ie,m);if(Z==="")throw new R(`malformed attribute at ${m}`);if(e[m]==="="){if(e[m+1]!=='"')throw new R(`attribute ${Z} must have a double-quoted value`);let qe=e.indexOf('"',m+2);if(qe===-1)throw new R(`unterminated value for ${Z}`);y.setAttribute(Z,Nn(e.slice(m+2,qe))),m=qe+1}else y.setAttribute(Z,"")}return i(y),xo.has(p)||o.push(y),m}}var vn=!1;function Rn(){vn||(vn=!0,kt({createElement:(e,t)=>new H(e,t),createText:e=>new j(e),createRaw:e=>new De(e),parseTemplate:(e,t)=>Sn(e,t),createComment:e=>new J(e)}))}function yt(e,t={}){let n=h();Rn(),$(!0);let r=B(t.event);try{return K(r,()=>(0,pt.createRoot)(o=>{try{let i=typeof e=="function"?e():e;return A(i)}finally{o()}}))}finally{$(n)}}var An=!1;function bo(){An||(An=!0,(0,E.setResourceTracker)(e=>{M()?.pending.add(e)}),(0,E.setResourceIdSource)(()=>M()?.nextResourceId()??""),(0,E.setResourceDataSink)((e,t)=>{e&&M()?.data.set(e,t)}))}var dt=null;function mt(e){dt=e}function $e(e){if(e.data.size===0)return"";let t={};for(let[r,o]of e.data){let i=o;if(dt)try{i=dt(o,r)}catch{continue}i!==void 0&&(typeof i=="function"||typeof i=="symbol"||(t[r]=i))}if(Object.keys(t).length===0)return"";let n=ce(JSON.stringify(t));return n==="{}"?"":`<script type="application/json" id="${z}">${n}<\/script>`}var Eo=50;async function gt(e,t={}){let n=h();Rn(),$(!0),bo();let r=B(t.event);try{return await K(r,async()=>{t.preload&&await t.preload(t.event);let o,i=null,s=()=>{};(0,pt.createRoot)(d=>{s=d,i=(0,E.getOwner)(),o=typeof e=="function"?e():e});let a=()=>{try{(0,E.runWithOwner)(i,()=>A(o))}catch{}};a();let l=0;for(;r.pending.size>0&&l++<Eo;){let d=Array.from(r.pending);r.pending.clear(),await Promise.allSettled(d),await(0,E.flush)(),a()}let c=(0,E.runWithOwner)(i,()=>A(o))+$e(r);return s(),c})}finally{$(n)}}var Y=require("@fluixi/reactive/signal"),Cn=require("@fluixi/reactive/store"),g=require("@fluixi/reactive/signal"),Mn=require("@fluixi/reactive/store");
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/cdn/dom.ts
21
+ var dom_exports = {};
22
+ __export(dom_exports, {
23
+ ClientOnly: () => ClientOnly,
24
+ Dynamic: () => Dynamic,
25
+ ErrorBoundary: () => ErrorBoundary,
26
+ FX_DATA_ID: () => FX_DATA_ID,
27
+ For: () => For,
28
+ Index: () => Index,
29
+ Island: () => Island,
30
+ JSX_PROPERTIES: () => JSX_PROPERTIES,
31
+ Match: () => Match,
32
+ NoSsr: () => NoSsr,
33
+ Portal: () => Portal,
34
+ SVG_ELEMENTS: () => SVG_ELEMENTS,
35
+ SVG_NAMESPACE: () => SVG_NAMESPACE,
36
+ Show: () => Show,
37
+ Switch: () => Switch,
38
+ VOID_ELEMENTS: () => VOID_ELEMENTS,
39
+ addClass: () => addClass,
40
+ addDelegatedEventListener: () => addDelegatedEventListener,
41
+ addNativeEventListener: () => addNativeEventListener,
42
+ appendChildren: () => appendChildren,
43
+ applyElementProp: () => applyElementProp,
44
+ applyProps: () => applyProps,
45
+ applyUse: () => applyUse,
46
+ asComponent: () => asComponent,
47
+ asContext: () => asContext,
48
+ asOutlet: () => asOutlet,
49
+ asProvider: () => asProvider,
50
+ asRoute: () => asRoute,
51
+ asRouter: () => asRouter,
52
+ asRoutes: () => asRoutes,
53
+ asSuspense: () => asSuspense,
54
+ batch: () => import_signal20.batch,
55
+ bindPair: () => bindPair,
56
+ captureHydrationCursor: () => captureHydrationCursor,
57
+ checkRenderType: () => checkRenderType,
58
+ classMap: () => classMap,
59
+ cleanChildren: () => cleanChildren,
60
+ cloneTemplate: () => cloneTemplate,
61
+ closest: () => closest,
62
+ createComponent: () => createComponent,
63
+ createComputed: () => import_signal20.createComputed,
64
+ createContext: () => import_signal20.createContext,
65
+ createDynamicElement: () => createDynamicElement,
66
+ createEffect: () => import_signal20.createEffect,
67
+ createElement: () => createElement,
68
+ createMemo: () => import_signal20.createMemo,
69
+ createNativeElement: () => createNativeElement,
70
+ createPortal: () => createPortal,
71
+ createRenderEffect: () => import_signal20.createRenderEffect,
72
+ createRequestContext: () => createRequestContext,
73
+ createResource: () => import_signal20.createResource,
74
+ createRoot: () => import_signal20.createRoot,
75
+ createSignal: () => import_signal20.createSignal,
76
+ createStore: () => import_store2.createStore,
77
+ createTemplate: () => createTemplate,
78
+ delegate: () => delegate,
79
+ delegateEvents: () => delegateEvents,
80
+ effect: () => import_signal19.effect,
81
+ escapeFxJson: () => escapeFxJson,
82
+ escapeHTML: () => escapeHTML,
83
+ fnName: () => fnName,
84
+ generateID: () => generateID,
85
+ getAttribute: () => getAttribute,
86
+ getGlobal: () => getGlobal,
87
+ getLitEventName: () => getLitEventName,
88
+ getLocals: () => getLocals,
89
+ getOffset: () => getOffset,
90
+ getRequestContext: () => getRequestContext,
91
+ getRequestEvent: () => getRequestEvent,
92
+ getRequestLocals: () => getRequestLocals,
93
+ getServerData: () => getServerData,
94
+ getStableElementId: () => getStableElementId,
95
+ getStyle: () => getStyle,
96
+ handleRef: () => handleRef,
97
+ hasClass: () => hasClass,
98
+ holeContent: () => holeContent,
99
+ holeEnd: () => holeEnd,
100
+ holeScope: () => holeScope,
101
+ html: () => html,
102
+ hydrate: () => hydrate,
103
+ hydrateAdvancePast: () => hydrateAdvancePast,
104
+ hydrateIslands: () => hydrateIslands,
105
+ indexArray: () => import_signal16.indexArray,
106
+ initializeIntegration: () => initializeIntegration,
107
+ insert: () => insert,
108
+ insertExpression: () => insertExpression,
109
+ intergartionInitialized: () => intergartionInitialized,
110
+ isAccessor: () => isAccessor,
111
+ isComponent: () => isComponent,
112
+ isContext: () => isContext,
113
+ isCustomElement: () => isCustomElement,
114
+ isDOMNode: () => isDOMNode,
115
+ isDelegatedEvent: () => isDelegatedEvent,
116
+ isDomElement: () => isDomElement,
117
+ isDomNode: () => isDomNode,
118
+ isDomText: () => isDomText,
119
+ isEventHandler: () => isEventHandler,
120
+ isFunction: () => isFunction,
121
+ isIntegrationInitialized: () => isIntegrationInitialized,
122
+ isJSXTemplate: () => isJSXTemplate,
123
+ isLitTemplateResult: () => isLitTemplateResult,
124
+ isNativeElement: () => isNativeElement,
125
+ isOutlet: () => isOutlet,
126
+ isPromise: () => isPromise,
127
+ isProvider: () => isProvider,
128
+ isReactElement: () => isReactElement,
129
+ isRoute: () => isRoute,
130
+ isRouter: () => isRouter,
131
+ isRoutes: () => isRoutes,
132
+ isSVGElement: () => isSVGElement,
133
+ isServer: () => isServer,
134
+ isSuspense: () => isSuspense,
135
+ isTemplateFactory: () => isTemplateFactory,
136
+ isVisible: () => isVisible,
137
+ iterateFn: () => iterateFn,
138
+ keyArray: () => import_signal16.keyArray,
139
+ makeArrayFlat: () => makeArrayFlat,
140
+ mapArray: () => import_signal16.mapArray,
141
+ memo: () => import_signal19.memo,
142
+ mergeProps: () => mergeProps,
143
+ observeIntersection: () => observeIntersection,
144
+ observeResize: () => observeResize,
145
+ onCleanup: () => import_signal20.onCleanup,
146
+ query: () => query,
147
+ queryAll: () => queryAll,
148
+ registerCreateComponent: () => registerCreateComponent,
149
+ registerGlobal: () => registerGlobal,
150
+ removeAttribute: () => removeAttribute,
151
+ removeChildren: () => removeChildren,
152
+ removeClass: () => removeClass,
153
+ removeDelegatedEventListener: () => removeDelegatedEventListener,
154
+ render: () => render,
155
+ renderToString: () => renderToString,
156
+ renderToStringAsync: () => renderToStringAsync,
157
+ resetIntegration: () => resetIntegration,
158
+ runHydrationAt: () => runHydrationAt,
159
+ runWithRequestContext: () => runWithRequestContext,
160
+ runWithoutHydration: () => runWithoutHydration,
161
+ scrollIntoView: () => scrollIntoView,
162
+ serializeNode: () => serializeNode,
163
+ serializeResourceData: () => serializeResourceData,
164
+ setAttribute: () => setAttribute,
165
+ setClassList: () => setClassList,
166
+ setClassName: () => setClassName,
167
+ setDataRedactor: () => setDataRedactor,
168
+ setDynamicAttribute: () => setDynamicAttribute,
169
+ setDynamicBoolAttribute: () => setDynamicBoolAttribute,
170
+ setDynamicProperty: () => setDynamicProperty,
171
+ setProperty: () => setProperty,
172
+ setRequestStore: () => setRequestStore,
173
+ setServerMode: () => setServerMode,
174
+ setStyle: () => setStyle,
175
+ setStyles: () => setStyles,
176
+ shouldSetAsProperty: () => shouldSetAsProperty,
177
+ signal: () => import_signal19.signal,
178
+ splitProps: () => splitProps,
179
+ spread: () => spread,
180
+ store: () => import_store.store,
181
+ styleMap: () => styleMap,
182
+ svg: () => svg,
183
+ templateNode: () => templateNode,
184
+ toAttributeName: () => toAttributeName,
185
+ toggleClass: () => toggleClass,
186
+ untrack: () => import_signal20.untrack,
187
+ useContext: () => import_signal20.useContext,
188
+ waitForElement: () => waitForElement
189
+ });
190
+ module.exports = __toCommonJS(dom_exports);
191
+
192
+ // src/lib/dom/utils.ts
193
+ function toAttributeName(key) {
194
+ if (key.startsWith("aria-") || key.startsWith("data-")) {
195
+ return key;
196
+ }
197
+ if (/[A-Z]/.test(key)) {
198
+ return key.replace(/([A-Z])/g, "-$1").toLowerCase();
199
+ }
200
+ return key;
201
+ }
202
+ function isEventHandler(key) {
203
+ return key.startsWith("@") || key.startsWith("on") && key.length > 2;
204
+ }
205
+ function getLitEventName(key) {
206
+ if (key.startsWith("@")) {
207
+ return key.slice(1);
208
+ }
209
+ if (key.startsWith("on")) {
210
+ const eventName = key.slice(2);
211
+ return eventName.toLowerCase();
212
+ }
213
+ return key;
214
+ }
215
+ function shouldSetAsProperty(element, key) {
216
+ const propertyAttributes = /* @__PURE__ */ new Set([
217
+ "checked",
218
+ "value",
219
+ "selected",
220
+ "disabled",
221
+ "readonly",
222
+ "required",
223
+ "multiple",
224
+ "open",
225
+ "contenteditable",
226
+ "draggable",
227
+ "spellcheck"
228
+ ]);
229
+ const elementSpecificProps = {
230
+ input: /* @__PURE__ */ new Set(["value", "checked", "indeterminate"]),
231
+ textarea: /* @__PURE__ */ new Set(["value"]),
232
+ select: /* @__PURE__ */ new Set(["value"]),
233
+ option: /* @__PURE__ */ new Set(["selected", "value"]),
234
+ audio: /* @__PURE__ */ new Set(["volume", "currentTime", "paused"]),
235
+ video: /* @__PURE__ */ new Set(["volume", "currentTime", "paused"]),
236
+ img: /* @__PURE__ */ new Set(["src", "srcset"]),
237
+ iframe: /* @__PURE__ */ new Set(["src"]),
238
+ a: /* @__PURE__ */ new Set(["href"])
239
+ };
240
+ return propertyAttributes.has(key) || elementSpecificProps[element] && elementSpecificProps[element].has(key);
241
+ }
242
+ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
243
+ "area",
244
+ "base",
245
+ "br",
246
+ "col",
247
+ "embed",
248
+ "hr",
249
+ "img",
250
+ "input",
251
+ "link",
252
+ "meta",
253
+ "param",
254
+ "source",
255
+ "track",
256
+ "wbr"
257
+ ]);
258
+ var SVG_ELEMENTS = /* @__PURE__ */ new Set([
259
+ "svg",
260
+ "g",
261
+ "path",
262
+ "circle",
263
+ "rect",
264
+ "line",
265
+ "polyline",
266
+ "polygon",
267
+ "ellipse",
268
+ "text",
269
+ "tspan",
270
+ "use",
271
+ "defs",
272
+ "symbol",
273
+ "mask",
274
+ "clipPath",
275
+ "pattern",
276
+ "linearGradient",
277
+ "radialGradient",
278
+ "stop",
279
+ "filter",
280
+ "feGaussianBlur",
281
+ "feOffset",
282
+ "feMerge",
283
+ "feMergeNode",
284
+ "foreignObject"
285
+ ]);
286
+ var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
287
+ function isCustomElement(element) {
288
+ return element.localName.includes("-");
289
+ }
290
+ function applyElementProp(element, name, value, isSVG = false) {
291
+ if (value == null) {
292
+ element.removeAttribute(name);
293
+ return;
294
+ }
295
+ if (isCustomElement(element)) {
296
+ element[name] = value;
297
+ return;
298
+ }
299
+ setAttribute(element, name, value, isSVG);
300
+ }
301
+ var JSX_PROPERTIES = /* @__PURE__ */ new Set([
302
+ "className",
303
+ "value",
304
+ "checked",
305
+ "selected",
306
+ "innerHTML",
307
+ "innerText",
308
+ "textContent",
309
+ "indeterminate",
310
+ "htmlFor"
311
+ ]);
312
+ function query(selector, root = document) {
313
+ return root.querySelector(selector);
314
+ }
315
+ function queryAll(selector, root = document) {
316
+ return Array.from(root.querySelectorAll(selector));
317
+ }
318
+ function closest(element, selector) {
319
+ return element.closest(selector);
320
+ }
321
+ function addClass(element, ...classes) {
322
+ element.classList.add(...classes);
323
+ }
324
+ function removeClass(element, ...classes) {
325
+ element.classList.remove(...classes);
326
+ }
327
+ function toggleClass(element, ...classes) {
328
+ classes.forEach((cls) => element.classList.toggle(cls));
329
+ }
330
+ function hasClass(element, className) {
331
+ return element.classList.contains(className);
332
+ }
333
+ function setAttribute(element, name, value, isSVG = false) {
334
+ if (value == null || value === false) {
335
+ element.removeAttribute(name);
336
+ return;
337
+ }
338
+ if (value === true) {
339
+ element.setAttribute(name, "");
340
+ return;
341
+ }
342
+ if (typeof value === "object") {
343
+ element.setAttribute(name, JSON.stringify(value));
344
+ return;
345
+ }
346
+ element.setAttribute(name, String(value));
347
+ }
348
+ function getAttribute(element, name) {
349
+ return element.getAttribute(name);
350
+ }
351
+ function removeAttribute(element, name) {
352
+ element.removeAttribute(name);
353
+ }
354
+ function setStyles(element, styles) {
355
+ Object.assign(element.style, styles);
356
+ }
357
+ function getStyle(element, property) {
358
+ return window.getComputedStyle(element).getPropertyValue(property);
359
+ }
360
+ function createElement(tagName, attributes = {}, ...children) {
361
+ const element = document.createElement(tagName);
362
+ Object.entries(attributes).forEach(([key, value]) => {
363
+ if (key === "class" || key === "className") {
364
+ element.className = value;
365
+ } else if (key === "style" && typeof value === "object") {
366
+ setStyles(element, value);
367
+ } else if (key.startsWith("on") && typeof value === "function") {
368
+ const event = key.slice(2).toLowerCase();
369
+ element.addEventListener(event, value);
370
+ } else {
371
+ setAttribute(element, key, value);
372
+ }
373
+ });
374
+ children.forEach((child) => {
375
+ if (typeof child === "string") {
376
+ element.appendChild(document.createTextNode(child));
377
+ } else {
378
+ element.appendChild(child);
379
+ }
380
+ });
381
+ return element;
382
+ }
383
+ function removeChildren(element) {
384
+ while (element.firstChild) {
385
+ element.removeChild(element.firstChild);
386
+ }
387
+ }
388
+ function appendChildren(parent, ...children) {
389
+ children.forEach((child) => {
390
+ if (typeof child === "string") {
391
+ parent.appendChild(document.createTextNode(child));
392
+ } else {
393
+ parent.appendChild(child);
394
+ }
395
+ });
396
+ }
397
+ function isVisible(element) {
398
+ const rect = element.getBoundingClientRect();
399
+ return rect.top >= 0 && rect.left >= 0 && rect.bottom <= window.innerHeight && rect.right <= window.innerWidth;
400
+ }
401
+ function scrollIntoView(element, options = { behavior: "smooth", block: "nearest" }) {
402
+ element.scrollIntoView(options);
403
+ }
404
+ function getOffset(element) {
405
+ const rect = element.getBoundingClientRect();
406
+ return {
407
+ top: rect.top + window.pageYOffset,
408
+ left: rect.left + window.pageXOffset
409
+ };
410
+ }
411
+ function delegate(parent, eventName, selector, handler) {
412
+ const listener = (event) => {
413
+ const target = event.target.closest(selector);
414
+ if (target && parent.contains(target)) {
415
+ handler(event, target);
416
+ }
417
+ };
418
+ parent.addEventListener(eventName, listener);
419
+ return () => {
420
+ parent.removeEventListener(eventName, listener);
421
+ };
422
+ }
423
+ function waitForElement(selector, timeout = 5e3) {
424
+ return new Promise((resolve, reject) => {
425
+ const element = query(selector);
426
+ if (element) {
427
+ resolve(element);
428
+ return;
429
+ }
430
+ const observer = new MutationObserver(() => {
431
+ const element2 = query(selector);
432
+ if (element2) {
433
+ observer.disconnect();
434
+ clearTimeout(timeoutId);
435
+ resolve(element2);
436
+ }
437
+ });
438
+ observer.observe(document.body, {
439
+ childList: true,
440
+ subtree: true
441
+ });
442
+ const timeoutId = setTimeout(() => {
443
+ observer.disconnect();
444
+ reject(new Error(`Element ${selector} not found within ${timeout}ms`));
445
+ }, timeout);
446
+ });
447
+ }
448
+ function observeIntersection(element, callback, options = {}) {
449
+ const observer = new IntersectionObserver((entries) => {
450
+ entries.forEach((entry) => {
451
+ callback(entry.isIntersecting);
452
+ });
453
+ }, options);
454
+ observer.observe(element);
455
+ return () => {
456
+ observer.disconnect();
457
+ };
458
+ }
459
+ function observeResize(element, callback) {
460
+ const observer = new ResizeObserver((entries) => {
461
+ entries.forEach(callback);
462
+ });
463
+ observer.observe(element);
464
+ return () => {
465
+ observer.disconnect();
466
+ };
467
+ }
468
+ var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
469
+ function isReactElement(value) {
470
+ return typeof value === "object" && value !== null && value.$$typeof === REACT_ELEMENT_TYPE;
471
+ }
472
+ function isLitTemplateResult(value) {
473
+ return value && typeof value === "object" && value.strings && Array.isArray(value.strings) && value.values && Array.isArray(value.values);
474
+ }
475
+ function isTemplateFactory(value) {
476
+ if (typeof value !== "function") return false;
477
+ try {
478
+ const result = value();
479
+ return isLitTemplateResult(result);
480
+ } catch {
481
+ return false;
482
+ }
483
+ }
484
+ function isJSXTemplate(value) {
485
+ return typeof value === "object" && value !== null && (value.$$typeof === "template" || typeof value.type === "function");
486
+ }
487
+ function isDOMNode(value) {
488
+ return value instanceof Node;
489
+ }
490
+ function registerGlobal(key, value, _Key = "Fluixi") {
491
+ if (typeof globalThis !== "undefined") {
492
+ if (typeof globalThis[_Key] === "undefined") {
493
+ globalThis[_Key] = {};
494
+ }
495
+ if (typeof globalThis[_Key][key] === "undefined") {
496
+ globalThis[_Key][key] = value;
497
+ }
498
+ }
499
+ }
500
+ function getGlobal(key, value, _Key = "Fluixi") {
501
+ if (typeof globalThis !== "undefined") {
502
+ if (typeof globalThis[_Key] !== "undefined") {
503
+ if (typeof globalThis[_Key][key] !== "undefined") {
504
+ return globalThis[_Key][key];
505
+ }
506
+ }
507
+ }
508
+ return value;
509
+ }
510
+
511
+ // src/lib/dom/runtime.ts
512
+ var import_signal2 = require("@fluixi/reactive/signal");
513
+
514
+ // src/version.generated.ts
515
+ var VERSION = "1.0.0-alpha.84";
516
+
517
+ // src/lib/dom/versions.ts
518
+ var import_version = require("@fluixi/reactive/version");
519
+ var import_signal = require("@fluixi/reactive/signal");
520
+ var versions = { dom: VERSION, reactive: import_version.VERSION };
521
+ function stampVersions(container) {
522
+ if (versions.core) container.setAttribute("fluixi", versions.core);
523
+ container.setAttribute("fx-dom", versions.dom);
524
+ container.setAttribute("fx-reactive", versions.reactive);
525
+ if (typeof globalThis !== "undefined") globalThis.Fluixi = versions;
526
+ }
527
+ function warnOnVersionSkew() {
528
+ const builds = (0, import_signal.joinedVersions)();
529
+ if (builds.length > 1) {
530
+ console.warn(
531
+ `[fluixi] ${builds.length} builds of @fluixi/reactive are driving one reactive graph: ${builds.join(", ")}. They share it on purpose, so signals still cross between them, but the oldest one decided what the graph looks like. Build the components on one release, or load them as shared-runtime bundles.`
532
+ );
533
+ }
534
+ const present = [versions.core, versions.dom, versions.reactive].filter(
535
+ (v) => v !== void 0
536
+ );
537
+ if (new Set(present).size <= 1) return;
538
+ console.warn(
539
+ `[fluixi] package versions disagree: core ${versions.core ?? "(absent)"}, dom ${versions.dom}, reactive ${versions.reactive}. These ship as one release, so a mismatch usually means a stale lockfile or two copies resolved side by side. Reinstall, or check for duplicates with \`pnpm why @fluixi/dom\`.`
540
+ );
541
+ }
542
+
543
+ // src/lib/component/modifiers.ts
544
+ function asRouter(value) {
545
+ Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-router"), { value: true, enumerable: true });
546
+ return value;
547
+ }
548
+ function asRoutes(value) {
549
+ Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-routes"), { value: true, enumerable: true });
550
+ return value;
551
+ }
552
+ function asRoute(value) {
553
+ Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-route"), { value: true, enumerable: true });
554
+ return value;
555
+ }
556
+ function asOutlet(value) {
557
+ if (typeof value !== "function") return value;
558
+ Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-outlet"), { value: true, enumerable: true });
559
+ return value;
560
+ }
561
+ function asProvider(value) {
562
+ Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-provider"), { value: true, enumerable: true });
563
+ return value;
564
+ }
565
+ function asContext(value) {
566
+ Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-context"), { value: true, enumerable: true });
567
+ return value;
568
+ }
569
+ function asComponent(value) {
570
+ if (typeof value !== "function") return value;
571
+ Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-component"), { value: true, enumerable: true });
572
+ return value;
573
+ }
574
+ function asSuspense(value) {
575
+ Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-suspense"), { value: true, enumerable: true });
576
+ return value;
577
+ }
578
+ function isRouter(value) {
579
+ return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-router")] === true;
580
+ }
581
+ function isRoutes(value) {
582
+ return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-routes")] === true;
583
+ }
584
+ function isRoute(value) {
585
+ return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-route")] === true;
586
+ }
587
+ function isOutlet(value) {
588
+ return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-outlet")] === true;
589
+ }
590
+ function isProvider(value) {
591
+ return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-provider")] === true;
592
+ }
593
+ function isContext(value) {
594
+ return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-context")] === true;
595
+ }
596
+ function isComponent(value) {
597
+ return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-component")] === true;
598
+ }
599
+ function isSuspense(value) {
600
+ return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-suspense")] === true;
601
+ }
602
+ function checkRenderType(value) {
603
+ if (isRouter(value)) {
604
+ return { type: "router", value };
605
+ }
606
+ if (isRoute(value)) {
607
+ return { type: "route", value };
608
+ }
609
+ if (isRoutes(value)) {
610
+ return { type: "routes", value };
611
+ }
612
+ if (isOutlet(value)) {
613
+ return { type: "outlet", value };
614
+ }
615
+ if (isComponent(value)) {
616
+ return { type: "component", value };
617
+ }
618
+ if (isSuspense(value)) {
619
+ return { type: "suspense", value };
620
+ }
621
+ if (isProvider(value)) {
622
+ return { type: "provider", value };
623
+ }
624
+ if (isContext(value)) {
625
+ return { type: "context", value };
626
+ }
627
+ return { type: "none", value };
628
+ }
629
+
630
+ // src/lib/dom/runtime.ts
631
+ var import_signal3 = require("@fluixi/reactive/signal");
632
+
633
+ // src/lib/dom/server/host.ts
634
+ var SERVER_NODE = /* @__PURE__ */ Symbol.for("fluixi.server-node");
635
+ var STATE = /* @__PURE__ */ Symbol.for("fluixi.dom.server-host");
636
+ var realm = globalThis;
637
+ var state = realm[STATE] ??= {
638
+ server: typeof document === "undefined",
639
+ nodes: null
640
+ };
641
+ function isServer() {
642
+ return state.server;
643
+ }
644
+ function setServerMode(on) {
645
+ state.server = on;
646
+ }
647
+ function registerServerNodes(factory) {
648
+ state.nodes = factory;
649
+ }
650
+ function getServerNodes() {
651
+ if (!state.nodes) {
652
+ throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");
653
+ }
654
+ return state.nodes;
655
+ }
656
+ function isDomNode(x) {
657
+ if (x != null && x[SERVER_NODE] === true) return true;
658
+ return typeof Node !== "undefined" && x instanceof Node;
659
+ }
660
+ function isDomElement(x) {
661
+ if (x != null && x[SERVER_NODE] === true) return x.nodeType === 1;
662
+ return typeof Element !== "undefined" && x instanceof Element;
663
+ }
664
+ function isDomText(x) {
665
+ if (x != null && x[SERVER_NODE] === true) return x.nodeType === 3;
666
+ return typeof Text !== "undefined" && x instanceof Text;
667
+ }
668
+
669
+ // src/lib/dom/hydration-state.ts
670
+ var hydration = {
671
+ active: false,
672
+ cursor: null,
673
+ parents: []
674
+ };
675
+ var _walker = null;
676
+ function registerHydrationWalker(walker) {
677
+ _walker = walker;
678
+ }
679
+ function getHydrationWalker() {
680
+ return _walker;
681
+ }
682
+ function isAdopted(parent, node) {
683
+ return hydration.active && node.parentNode === parent;
684
+ }
685
+ function ascendPast(node) {
686
+ const idx = hydration.parents.lastIndexOf(node);
687
+ if (idx !== -1) hydration.parents.length = idx;
688
+ hydration.cursor = node.nextSibling;
689
+ }
690
+ function captureHydrationCursor() {
691
+ return hydration.active ? hydration.cursor : null;
692
+ }
693
+ function runHydrationAt(cursor, fn) {
694
+ if (!cursor || cursor.parentNode == null) return fn();
695
+ const prevActive = hydration.active;
696
+ const prevCursor = hydration.cursor;
697
+ const prevParents = hydration.parents;
698
+ hydration.active = true;
699
+ hydration.cursor = cursor;
700
+ hydration.parents = [];
701
+ try {
702
+ return fn();
703
+ } finally {
704
+ hydration.active = prevActive;
705
+ hydration.cursor = prevCursor;
706
+ hydration.parents = prevParents;
707
+ }
708
+ }
709
+ function runWithoutHydration(fn) {
710
+ if (!hydration.active) return fn();
711
+ const prevCursor = hydration.cursor;
712
+ const prevParents = hydration.parents;
713
+ hydration.active = false;
714
+ hydration.parents = [];
715
+ try {
716
+ return fn();
717
+ } finally {
718
+ hydration.active = true;
719
+ hydration.cursor = prevCursor;
720
+ hydration.parents = prevParents;
721
+ }
722
+ }
723
+ function hydrateAdvancePast(rendered) {
724
+ if (!hydration.active || rendered == null) return;
725
+ const last = Array.isArray(rendered) ? rendered[rendered.length - 1] : rendered;
726
+ if (last && typeof last.nodeType === "number") {
727
+ ascendPast(last);
728
+ }
729
+ }
730
+
731
+ // src/lib/dom/runtime.ts
732
+ function getElementFingerprint(el) {
733
+ const parts = [];
734
+ while (el && el.nodeType === 1) {
735
+ let part = el.tagName.toLowerCase();
736
+ if (el.id) {
737
+ part += `#${el.id}`;
738
+ parts.unshift(part);
739
+ break;
740
+ }
741
+ if (el.getAttribute("data-id")) {
742
+ part += `[data-id="${el.getAttribute("data-id")}"]`;
743
+ }
744
+ let index = 0;
745
+ let sibling = el;
746
+ while (sibling = sibling.previousElementSibling) {
747
+ if (sibling.tagName === el.tagName) index++;
748
+ }
749
+ part += `:nth-of-type(${index + 1})`;
750
+ parts.unshift(part);
751
+ el = el.parentElement;
752
+ }
753
+ return parts.join(">");
754
+ }
755
+ function hashString(str) {
756
+ let hash = 0;
757
+ for (let i = 0; i < str.length; i++) {
758
+ hash = (hash << 5) - hash + str.charCodeAt(i);
759
+ hash |= 0;
760
+ }
761
+ return `el_${Math.abs(hash)}`;
762
+ }
763
+ function getStableElementId(el) {
764
+ return hashString(getElementFingerprint(el));
765
+ }
766
+ var generateID = () => {
767
+ return "xxyxxxxxxy-4xx8".replace(/[xy]/g, function(c) {
768
+ let r = Math.random() * 16 | 0;
769
+ let v = c === "x" ? r : r & 3 | 8;
770
+ return v.toString(16);
771
+ });
772
+ };
773
+ var EMPTY_OBJ = {};
774
+ var HOLE_TAG = "__fx_at";
775
+ var LOC_TAG = "__fx_loc";
776
+ function located(element, at) {
777
+ if (at) element[LOC_TAG] = at;
778
+ return element;
779
+ }
780
+ var templateCache = /* @__PURE__ */ new Map();
781
+ var delegatedSet = /* @__PURE__ */ new Set();
782
+ var NON_DELEGATED = /* @__PURE__ */ new Set(["scroll", "focus", "blur", "load", "error", "resize", "mouseenter", "mouseleave", "pointerenter", "pointerleave", "gotpointercapture", "lostpointercapture"]);
783
+ function delegateEvents(eventNames) {
784
+ if (isServer()) return;
785
+ for (const name of eventNames) {
786
+ if (delegatedSet.has(name) || NON_DELEGATED.has(name)) continue;
787
+ delegatedSet.add(name);
788
+ document.addEventListener(name, delegatedEventHandler);
789
+ }
790
+ }
791
+ function delegatedEventHandler(e) {
792
+ const key = `$$${e.type}`;
793
+ let node = e.composedPath && e.composedPath()[0] || e.target;
794
+ while (node) {
795
+ const handler = node[key];
796
+ if (handler && !node.disabled) {
797
+ handler(e);
798
+ if (e.cancelBubble) return;
799
+ }
800
+ node = node.host && node.host !== node && node.host instanceof Element ? node.host : node.parentNode;
801
+ }
802
+ }
803
+ function addDelegatedEventListener(element, name, handler) {
804
+ element[`$$${name}`] = handler;
805
+ if (NON_DELEGATED.has(name)) {
806
+ const key = `__fx_${name}`;
807
+ if (!element[key]) {
808
+ const forwarder = (e) => {
809
+ element[`$$${name}`]?.(e);
810
+ };
811
+ element.addEventListener(name, forwarder);
812
+ element[key] = forwarder;
813
+ }
814
+ return;
815
+ }
816
+ if (!delegatedSet.has(name)) {
817
+ delegateEvents([name]);
818
+ }
819
+ }
820
+ function removeDelegatedEventListener(element, name) {
821
+ delete element[`$$${name}`];
822
+ const key = `__fx_${name}`;
823
+ const forwarder = element[key];
824
+ if (forwarder) {
825
+ element.removeEventListener(name, forwarder);
826
+ delete element[key];
827
+ }
828
+ }
829
+ function isDelegatedEvent(name) {
830
+ return !NON_DELEGATED.has(name);
831
+ }
832
+ function isFunction(value) {
833
+ return typeof value === "function";
834
+ }
835
+ function createTextNode(value, anchor = false) {
836
+ if (isServer()) return getServerNodes().createText(value);
837
+ if (hydration.active && !anchor) {
838
+ const node = getHydrationWalker()?.hydrateText(value);
839
+ if (node) return node;
840
+ }
841
+ return document.createTextNode(value);
842
+ }
843
+ function createNativeElement(tag, isSVG = false, at) {
844
+ if (isServer()) return getServerNodes().createElement(tag, isSVG);
845
+ if (hydration.active) {
846
+ const node = getHydrationWalker()?.hydrateElement(tag);
847
+ if (node) return at ? located(node, at) : node;
848
+ }
849
+ return located(
850
+ isSVG ? document.createElementNS(SVG_NAMESPACE, tag) : document.createElement(tag),
851
+ at
852
+ );
853
+ }
854
+ function createTemplate(html2, isSVG = false) {
855
+ const cached = templateCache.get(html2);
856
+ if (cached) return cached;
857
+ const template = document.createElement("template");
858
+ if (isSVG) {
859
+ template.innerHTML = `<svg>${html2}</svg>`;
860
+ } else {
861
+ template.innerHTML = html2;
862
+ }
863
+ templateCache.set(html2, template);
864
+ return template;
865
+ }
866
+ function templateNode(html2, tag, holes = false, isSVG = false, at) {
867
+ if (isServer()) {
868
+ const nodes = getServerNodes();
869
+ return holes ? nodes.parseTemplate(html2, isSVG) : nodes.createRaw(html2);
870
+ }
871
+ if (hydration.active) {
872
+ const node = getHydrationWalker()?.hydrateStatic(tag);
873
+ if (node) return stampPositions(node, at);
874
+ }
875
+ return stampPositions(cloneTemplate(createTemplate(html2, isSVG), isSVG).firstChild, at);
876
+ }
877
+ function stampPositions(node, at) {
878
+ const root = node;
879
+ if (!at || typeof root?.querySelectorAll !== "function") return node;
880
+ const all = [root, ...root.querySelectorAll("*")];
881
+ for (let i = 0; i < all.length && i * 2 + 1 < at.pos.length; i++) {
882
+ const line = at.pos[i * 2];
883
+ if (line) all[i][LOC_TAG] = { file: at.file, line, column: at.pos[i * 2 + 1] };
884
+ }
885
+ return node;
886
+ }
887
+ function holeScope(start, produce) {
888
+ if (!hydration.active) return produce();
889
+ const value = runHydrationAt(start.nextSibling, produce);
890
+ if (typeof value === "function") {
891
+ const accessor = value;
892
+ const wrapped = (...args) => hydration.active ? runHydrationAt(start.nextSibling, () => accessor(...args)) : accessor(...args);
893
+ return carryHoleTag(accessor, wrapped);
894
+ }
895
+ return value;
896
+ }
897
+ function carryHoleTag(from, to) {
898
+ const tag = from[HOLE_TAG];
899
+ if (tag !== void 0) to[HOLE_TAG] = tag;
900
+ return to;
901
+ }
902
+ function holeEnd(start) {
903
+ for (let n = start.nextSibling; n; n = n.nextSibling) {
904
+ if (n.nodeType === 8 && n.data === "fx/") return n;
905
+ }
906
+ throw new Error("[fluixi] template hole is missing its closing marker");
907
+ }
908
+ function holeContent(start, end) {
909
+ const nodes = [];
910
+ for (let n = start.nextSibling; n && n !== end; n = n.nextSibling) nodes.push(n);
911
+ return nodes;
912
+ }
913
+ function cloneTemplate(template, isSVG = false) {
914
+ const clone = template.content.cloneNode(true);
915
+ if (isSVG) return clone.firstChild;
916
+ return clone;
917
+ }
918
+ function makeArrayFlat(values) {
919
+ if (!Array.isArray(values)) return values;
920
+ if (values.length === 2 && values[1] === " ") {
921
+ if (Array.isArray(values[0])) return makeArrayFlat(values[0]);
922
+ if (typeof values[0] === "function") return values[0];
923
+ return values[0];
924
+ }
925
+ if (values.length === 1 && typeof values[0] === "function") return values[0];
926
+ return values;
927
+ }
928
+ function fnName(fn) {
929
+ if (typeof fn !== "function") return null;
930
+ return fn._name || fn.name || "anonymous";
931
+ }
932
+ function iterateFn(item) {
933
+ if ((0, import_signal2.isSignal)(item)) return item;
934
+ if (isComponent(item)) return item;
935
+ if (typeof item !== "function") return item;
936
+ let content = item();
937
+ while (typeof content === "function" && !(0, import_signal2.isSignal)(content) && !isComponent(content)) {
938
+ content = content();
939
+ }
940
+ return content;
941
+ }
942
+ var _insertDepth = 0;
943
+ var MAX_INSERT_DEPTH = 200;
944
+ function _createInsertEffect(getAccessor, parent, marker, initialCurrent, setCurrent) {
945
+ let current = initialCurrent;
946
+ const componentCache = /* @__PURE__ */ new Map();
947
+ return (0, import_signal3.createRenderEffect)(() => {
948
+ (0, import_signal3.reportReactiveBinding)(marker ?? parent, "content", void 0, getAccessor);
949
+ let value;
950
+ if (isComponent(getAccessor) && !(0, import_signal2.isSignal)(getAccessor)) {
951
+ if (!componentCache.has(getAccessor)) {
952
+ _insertDepth++;
953
+ try {
954
+ const inst = getAccessor();
955
+ componentCache.set(getAccessor, inst);
956
+ } finally {
957
+ _insertDepth--;
958
+ }
959
+ }
960
+ value = componentCache.get(getAccessor);
961
+ while (typeof value === "function" && (0, import_signal2.isSignal)(value)) value = value();
962
+ } else {
963
+ value = getAccessor();
964
+ while (typeof value === "function" && (0, import_signal2.isSignal)(value)) {
965
+ value = value();
966
+ }
967
+ }
968
+ {
969
+ let chainDepth = 0;
970
+ while (typeof value === "function" && chainDepth++ < 50) {
971
+ if (isComponent(value)) {
972
+ if (!componentCache.has(value)) {
973
+ const thunk = value;
974
+ _insertDepth++;
975
+ try {
976
+ const inst = thunk();
977
+ componentCache.set(thunk, inst);
978
+ } finally {
979
+ _insertDepth--;
980
+ }
981
+ }
982
+ value = componentCache.get(value);
983
+ } else if ((0, import_signal2.isSignal)(value)) {
984
+ value = value();
985
+ } else {
986
+ value = value();
987
+ if (typeof value !== "function" || !(0, import_signal2.isSignal)(value) && !isComponent(value)) break;
988
+ }
989
+ }
990
+ }
991
+ _insertDepth++;
992
+ try {
993
+ current = insertExpression(parent, value, marker, current, componentCache);
994
+ setCurrent(current);
995
+ } finally {
996
+ _insertDepth--;
997
+ }
998
+ });
999
+ }
1000
+ function insert(parent, accessor, marker, init) {
1001
+ if (_insertDepth > MAX_INSERT_DEPTH) {
1002
+ console.error("[insert] Exceeded max call depth, possible infinite loop.");
1003
+ return () => null;
1004
+ }
1005
+ if (marker !== void 0 && !marker) {
1006
+ marker = createTextNode("", true);
1007
+ parent.appendChild(marker);
1008
+ }
1009
+ let current = init ?? null;
1010
+ const isReactiveArray = (element) => {
1011
+ return Array.isArray(element) && element.some((v) => typeof v === "function");
1012
+ };
1013
+ const normalizeAccessor3 = (accessor2) => {
1014
+ if (typeof accessor2 === "function") return accessor2;
1015
+ return () => accessor2;
1016
+ };
1017
+ if (typeof accessor !== "function" && !isReactiveArray(accessor)) {
1018
+ _insertDepth++;
1019
+ try {
1020
+ current = insertExpression(parent, accessor, marker, current);
1021
+ } finally {
1022
+ _insertDepth--;
1023
+ }
1024
+ return () => current;
1025
+ }
1026
+ const dispose = _createInsertEffect(
1027
+ normalizeAccessor3(accessor),
1028
+ parent,
1029
+ marker,
1030
+ current,
1031
+ (v) => {
1032
+ current = v;
1033
+ }
1034
+ );
1035
+ return () => {
1036
+ dispose?.();
1037
+ return current;
1038
+ };
1039
+ }
1040
+ function insertExpression(parent, value, marker, current, componentCache) {
1041
+ if (value == null || typeof value === "boolean") {
1042
+ return cleanChildren(parent, current, marker);
1043
+ }
1044
+ if (typeof value === "function") {
1045
+ while (typeof value === "function") {
1046
+ value = value();
1047
+ }
1048
+ }
1049
+ if (value == null || typeof value === "boolean") {
1050
+ return cleanChildren(parent, current, marker);
1051
+ }
1052
+ if (isPromise(value)) {
1053
+ const placeholder = createTextNode("", true);
1054
+ if (Array.isArray(current)) {
1055
+ if (current.length > 0) {
1056
+ parent.replaceChild(placeholder, current[0]);
1057
+ cleanChildren(parent, current.slice(1), marker);
1058
+ } else {
1059
+ insertBefore(parent, placeholder, marker);
1060
+ }
1061
+ } else if (current) {
1062
+ parent.replaceChild(placeholder, current);
1063
+ } else {
1064
+ insertBefore(parent, placeholder, marker);
1065
+ }
1066
+ value.then((resolved) => {
1067
+ if (placeholder.parentNode === parent) {
1068
+ insertExpression(parent, resolved, placeholder.nextSibling, placeholder);
1069
+ }
1070
+ }).catch((err) => {
1071
+ console.error("Error resolving promise in insertExpression:", err);
1072
+ });
1073
+ return placeholder;
1074
+ }
1075
+ const t = typeof value;
1076
+ if (t === "string" || t === "number") {
1077
+ if (t === "number") value = String(value);
1078
+ if (Array.isArray(current)) {
1079
+ if (current.length === 0) {
1080
+ const node2 = createTextNode(value);
1081
+ insertBefore(parent, node2, marker);
1082
+ return node2;
1083
+ }
1084
+ if (current.length === 1 && current[0].nodeType === 3) {
1085
+ current[0].data = value;
1086
+ return current;
1087
+ }
1088
+ current = cleanChildren(parent, current, marker);
1089
+ }
1090
+ if (current && isDomText(current)) {
1091
+ current.data = value;
1092
+ return current;
1093
+ }
1094
+ const node = createTextNode(value);
1095
+ if (current && current.parentNode === parent) {
1096
+ parent.replaceChild(node, current);
1097
+ } else if (!isAdopted(parent, node)) {
1098
+ insertBefore(parent, node, marker);
1099
+ }
1100
+ return node;
1101
+ }
1102
+ if (isDomNode(value)) {
1103
+ if (isAdopted(parent, value)) {
1104
+ ascendPast(value);
1105
+ return value;
1106
+ }
1107
+ if (Array.isArray(current)) {
1108
+ if (current.length === 0) {
1109
+ insertBefore(parent, value, marker);
1110
+ } else if (current[0].parentNode === parent) {
1111
+ parent.replaceChild(value, current[0]);
1112
+ cleanChildren(parent, current.slice(1), marker);
1113
+ } else {
1114
+ insertBefore(parent, value, marker);
1115
+ }
1116
+ return value;
1117
+ }
1118
+ if (!current) {
1119
+ insertBefore(parent, value, marker);
1120
+ } else if (current !== value) {
1121
+ if (current.parentNode === parent) {
1122
+ parent.replaceChild(value, current);
1123
+ } else {
1124
+ insertBefore(parent, value, marker);
1125
+ }
1126
+ }
1127
+ return value;
1128
+ }
1129
+ if (Array.isArray(value)) {
1130
+ const array = [];
1131
+ const currentArray = Array.isArray(current) ? current : current ? [current] : [];
1132
+ const reactiveSlots = [];
1133
+ flattenArray(value, array, parent, marker, true, componentCache, reactiveSlots);
1134
+ const reconciled = reconcileArrays(parent, currentArray, array, marker);
1135
+ for (const slot of reactiveSlots) {
1136
+ const disposeSlot = insert(parent, slot.sig, slot.marker);
1137
+ (0, import_signal3.onCleanup)(() => {
1138
+ cleanChildren(parent, disposeSlot());
1139
+ if (slot.marker.parentNode === parent) parent.removeChild(slot.marker);
1140
+ });
1141
+ }
1142
+ return reconciled;
1143
+ }
1144
+ if (t === "object" && value !== null && typeof value === "object") {
1145
+ const objValue = value;
1146
+ if ("type" in objValue && "props" in objValue) {
1147
+ const jsxValue = objValue;
1148
+ if (typeof jsxValue.type === "function") {
1149
+ const result = jsxValue.type(jsxValue.props || {});
1150
+ return insertExpression(parent, result, marker, current);
1151
+ }
1152
+ }
1153
+ }
1154
+ return cleanChildren(parent, current, marker);
1155
+ }
1156
+ function flattenArray(arr, result, parent, marker, track = true, componentCache, reactiveSlots) {
1157
+ for (let i = 0; i < arr.length; i++) {
1158
+ let item = arr[i];
1159
+ if (item == null || typeof item === "boolean") continue;
1160
+ while (typeof item === "function" && !isPromise(item) && !(0, import_signal2.isSignal)(item) && !isComponent(item)) {
1161
+ item = item();
1162
+ if (item == null || typeof item === "boolean") break;
1163
+ }
1164
+ if (item == null || typeof item === "boolean") continue;
1165
+ if (typeof item === "function") {
1166
+ let resolved;
1167
+ if (isComponent(item) && !(0, import_signal2.isSignal)(item)) {
1168
+ if (!componentCache) componentCache = /* @__PURE__ */ new Map();
1169
+ if (!componentCache.has(item)) componentCache.set(item, item());
1170
+ resolved = componentCache.get(item);
1171
+ } else {
1172
+ resolved = item();
1173
+ }
1174
+ while (typeof resolved === "function" && !isPromise(resolved) && !(0, import_signal2.isSignal)(resolved) && !isComponent(resolved)) {
1175
+ if (!componentCache) componentCache = /* @__PURE__ */ new Map();
1176
+ if (!componentCache.has(resolved)) componentCache.set(resolved, resolved());
1177
+ resolved = componentCache.get(resolved);
1178
+ }
1179
+ if (resolved == null || typeof resolved === "boolean") continue;
1180
+ if (typeof resolved === "function") {
1181
+ if ((0, import_signal2.isSignal)(resolved)) {
1182
+ if (reactiveSlots) {
1183
+ const slot = createTextNode("", true);
1184
+ result.push(slot);
1185
+ reactiveSlots.push({ marker: slot, sig: resolved });
1186
+ continue;
1187
+ }
1188
+ let val = resolved();
1189
+ while (typeof val === "function" && (0, import_signal2.isSignal)(val)) val = val();
1190
+ if (val == null || typeof val === "boolean") continue;
1191
+ if (Array.isArray(val)) {
1192
+ flattenArray(val, result, parent, marker, track, componentCache);
1193
+ } else flattenArray([val], result, parent, marker, track, componentCache);
1194
+ continue;
1195
+ }
1196
+ continue;
1197
+ }
1198
+ if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, track, componentCache, reactiveSlots);
1199
+ else flattenArray([resolved], result, parent, marker, track, componentCache, reactiveSlots);
1200
+ continue;
1201
+ }
1202
+ if (isPromise(item)) {
1203
+ const placeholder = createTextNode("", true);
1204
+ result.push(placeholder);
1205
+ item.then((resolved) => {
1206
+ if (placeholder.parentNode) {
1207
+ const tempNodes = [];
1208
+ flattenArray([resolved], tempNodes, placeholder.parentNode, void 0, false, componentCache);
1209
+ if (tempNodes.length > 0) {
1210
+ placeholder.parentNode.replaceChild(tempNodes[0], placeholder);
1211
+ for (let j = 1; j < tempNodes.length; j++) {
1212
+ placeholder.parentNode?.insertBefore(tempNodes[j], tempNodes[j - 1].nextSibling);
1213
+ }
1214
+ }
1215
+ }
1216
+ }).catch((err) => console.error("Error resolving promise in array:", err));
1217
+ continue;
1218
+ }
1219
+ if (Array.isArray(item)) {
1220
+ flattenArray(item, result, parent, marker, track, componentCache, reactiveSlots);
1221
+ continue;
1222
+ }
1223
+ if (isDomNode(item)) {
1224
+ result.push(item);
1225
+ continue;
1226
+ }
1227
+ if (typeof item === "object" && item !== null && "type" in item && "props" in item) {
1228
+ const jsxItem = item;
1229
+ if (typeof jsxItem.type === "function") {
1230
+ const resolved = jsxItem.type(jsxItem.props || {});
1231
+ if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, false, componentCache);
1232
+ else flattenArray([resolved], result, parent, marker, false, componentCache);
1233
+ continue;
1234
+ }
1235
+ }
1236
+ if (typeof item === "string" || typeof item === "number") {
1237
+ const str = String(item);
1238
+ if (str.trim() === "" && str !== " ") continue;
1239
+ result.push(createTextNode(str));
1240
+ continue;
1241
+ }
1242
+ result.push(createTextNode(String(item)));
1243
+ }
1244
+ }
1245
+ function reconcileArrays(parent, a, b, marker) {
1246
+ for (let i = 0; i < b.length; i++) {
1247
+ const owner = b[i].parentNode;
1248
+ if (owner !== null && owner !== parent && owner.nodeType !== 11) {
1249
+ b = b.slice();
1250
+ b[i] = b[i].cloneNode(true);
1251
+ }
1252
+ }
1253
+ let bLength = b.length, aEnd = a.length, bEnd = bLength, aStart = 0, bStart = 0, after = aEnd > 0 ? a[aEnd - 1].nextSibling ?? void 0 : marker, map = null;
1254
+ while (aStart < aEnd || bStart < bEnd) {
1255
+ if (a[aStart] === b[bStart]) {
1256
+ aStart++;
1257
+ bStart++;
1258
+ continue;
1259
+ }
1260
+ while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
1261
+ aEnd--;
1262
+ bEnd--;
1263
+ }
1264
+ if (aEnd === aStart) {
1265
+ const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling ?? void 0 : b[bEnd - bStart] : after;
1266
+ while (bStart < bEnd) insertBefore(parent, b[bStart++], node);
1267
+ } else if (bEnd === bStart) {
1268
+ while (aStart < aEnd) {
1269
+ if ((!map || !map.has(a[aStart])) && a[aStart].parentNode === parent)
1270
+ parent.removeChild(a[aStart]);
1271
+ aStart++;
1272
+ }
1273
+ } else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
1274
+ const node = a[--aEnd].nextSibling;
1275
+ insertBefore(parent, b[bStart++], a[aStart++].nextSibling);
1276
+ insertBefore(parent, b[--bEnd], node);
1277
+ a[aEnd] = a[aStart - 1];
1278
+ } else {
1279
+ if (!map) {
1280
+ map = /* @__PURE__ */ new Map();
1281
+ let i = bStart;
1282
+ while (i < bEnd) map.set(b[i], i++);
1283
+ }
1284
+ const index = map.get(a[aStart]);
1285
+ if (index != null) {
1286
+ if (bStart < index && index < bEnd) {
1287
+ let i = aStart, sequence = 1;
1288
+ while (++i < aEnd && i < bEnd) {
1289
+ if (!map.has(a[i]) || map.get(a[i]) !== index + sequence) break;
1290
+ sequence++;
1291
+ }
1292
+ if (sequence > index - bStart) {
1293
+ const node = a[aStart];
1294
+ while (bStart < index) insertBefore(parent, b[bStart++], node);
1295
+ } else {
1296
+ if (a[aStart].parentNode === parent) {
1297
+ parent.replaceChild(b[bStart++], a[aStart++]);
1298
+ } else {
1299
+ insertBefore(parent, b[bStart++], after);
1300
+ aStart++;
1301
+ }
1302
+ }
1303
+ } else {
1304
+ aStart++;
1305
+ }
1306
+ } else {
1307
+ if (a[aStart].parentNode === parent) parent.removeChild(a[aStart]);
1308
+ aStart++;
1309
+ }
1310
+ }
1311
+ }
1312
+ return b;
1313
+ }
1314
+ function cleanChildren(parent, current, marker) {
1315
+ if (current) {
1316
+ if (Array.isArray(current)) {
1317
+ for (let i = 0; i < current.length; i++) {
1318
+ if (current[i].parentNode === parent) parent.removeChild(current[i]);
1319
+ }
1320
+ } else if (current.parentNode === parent) {
1321
+ parent.removeChild(current);
1322
+ }
1323
+ }
1324
+ return null;
1325
+ }
1326
+ function insertBefore(parent, node, marker) {
1327
+ if (hydration.active && node.parentNode === parent) return;
1328
+ if (marker) {
1329
+ if (marker.parentNode === parent) {
1330
+ parent.insertBefore(node, marker);
1331
+ } else {
1332
+ parent.appendChild(node);
1333
+ }
1334
+ } else {
1335
+ parent.appendChild(node);
1336
+ }
1337
+ }
1338
+ function setProperty(element, name, value) {
1339
+ if (value == null) delete element[name];
1340
+ else element[name] = value;
1341
+ }
1342
+ function addNativeEventListener(element, name, value) {
1343
+ let handler = value;
1344
+ let options;
1345
+ if (Array.isArray(value)) {
1346
+ handler = value[0];
1347
+ options = value[1];
1348
+ }
1349
+ if (typeof handler !== "function") return () => {
1350
+ };
1351
+ element.addEventListener(name, handler, options);
1352
+ return () => element.removeEventListener(name, handler, options);
1353
+ }
1354
+ function reportMarked(element, accessor) {
1355
+ if (!accessor || typeof accessor !== "function") return;
1356
+ const written = accessor[HOLE_TAG]?.name;
1357
+ if (!written) return;
1358
+ const colon = written.indexOf(":");
1359
+ if (colon === -1) return;
1360
+ (0, import_signal3.reportReactiveDirective)(element, written.slice(0, colon), written.slice(colon + 1), accessor);
1361
+ }
1362
+ function reportKeys(element, kind, value) {
1363
+ const from = typeof value === "function" ? (0, import_signal3.untrack)(() => value()) : value;
1364
+ if (!from || typeof from !== "object") return;
1365
+ for (const key of Object.keys(from)) (0, import_signal3.reportReactiveDirective)(element, kind, key);
1366
+ }
1367
+ function applyUse(element, value) {
1368
+ const call = (dir, accessor) => {
1369
+ if (typeof dir !== "function") return;
1370
+ (0, import_signal3.reportReactiveDirective)(element, "use", dir.name || "use", accessor);
1371
+ dir(element, accessor ?? (() => void 0));
1372
+ };
1373
+ if (typeof value === "function") {
1374
+ call(value);
1375
+ return;
1376
+ }
1377
+ if (!Array.isArray(value)) return;
1378
+ if (typeof value[0] === "function") {
1379
+ call(value[0], value[1]);
1380
+ return;
1381
+ }
1382
+ for (const pair of value) {
1383
+ if (Array.isArray(pair)) call(pair[0], pair[1]);
1384
+ else call(pair);
1385
+ }
1386
+ }
1387
+ function setDynamicAttribute(element, name, accessor, isSVG = false) {
1388
+ reportMarked(element, accessor);
1389
+ if (typeof accessor !== "function") {
1390
+ setAttribute(element, name, accessor, isSVG);
1391
+ return () => {
1392
+ };
1393
+ }
1394
+ return (0, import_signal3.createRenderEffect)(() => {
1395
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", name, accessor);
1396
+ const value = typeof accessor === "function" ? accessor() : accessor;
1397
+ setAttribute(element, name, value, isSVG);
1398
+ });
1399
+ }
1400
+ function setDynamicProperty(element, name, accessor) {
1401
+ if (typeof accessor !== "function") {
1402
+ setProperty(element, name, accessor);
1403
+ return () => {
1404
+ };
1405
+ }
1406
+ reportMarked(element, accessor);
1407
+ return (0, import_signal3.createRenderEffect)(() => {
1408
+ (0, import_signal3.reportReactiveBinding)(element, "property", name, accessor);
1409
+ const value = typeof accessor === "function" ? accessor() : accessor;
1410
+ setProperty(element, name, value);
1411
+ });
1412
+ }
1413
+ function setDynamicBoolAttribute(element, name, accessor) {
1414
+ if (typeof accessor !== "function") {
1415
+ setAttribute(element, name, !!accessor);
1416
+ return () => {
1417
+ };
1418
+ }
1419
+ return (0, import_signal3.createRenderEffect)(() => {
1420
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", name, accessor);
1421
+ const value = accessor();
1422
+ setAttribute(element, name, !!value);
1423
+ });
1424
+ }
1425
+ function setClassName(element, value) {
1426
+ if (value == null) {
1427
+ element.removeAttribute("class");
1428
+ return;
1429
+ }
1430
+ if (typeof value === "function") {
1431
+ (0, import_signal3.createRenderEffect)(() => {
1432
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", "class", value);
1433
+ setClassName(element, value());
1434
+ });
1435
+ return;
1436
+ }
1437
+ if (typeof value === "string") {
1438
+ element.setAttribute("class", value);
1439
+ return;
1440
+ }
1441
+ if (Array.isArray(value)) {
1442
+ element.setAttribute("class", value.filter(Boolean).join(" "));
1443
+ return;
1444
+ }
1445
+ if (typeof value === "object") {
1446
+ const classes = Object.keys(value).filter((key) => {
1447
+ const v = value[key];
1448
+ return typeof v === "function" ? v() : Boolean(v);
1449
+ }).join(" ");
1450
+ element.setAttribute("class", classes);
1451
+ return;
1452
+ }
1453
+ element.setAttribute("class", String(value));
1454
+ }
1455
+ function setClassList(element, value, disposers) {
1456
+ if (!value || typeof value !== "object") return;
1457
+ for (const name in value) {
1458
+ const cond = value[name];
1459
+ const names = name.split(/\s+/).filter(Boolean);
1460
+ if (typeof cond === "function" && disposers) {
1461
+ disposers.push(
1462
+ (0, import_signal3.createRenderEffect)(() => {
1463
+ const on = !!cond();
1464
+ for (const n of names) element.classList.toggle(n, on);
1465
+ })
1466
+ );
1467
+ } else {
1468
+ const on = !!(typeof cond === "function" ? cond() : cond);
1469
+ for (const n of names) element.classList.toggle(n, on);
1470
+ }
1471
+ }
1472
+ }
1473
+ function setStyle(element, _value) {
1474
+ let value = _value;
1475
+ while (typeof value === "function") value = value();
1476
+ if (value == null) {
1477
+ element.removeAttribute("style");
1478
+ return;
1479
+ }
1480
+ if (typeof value === "string") {
1481
+ element.style.cssText = value;
1482
+ return;
1483
+ }
1484
+ if (typeof value === "object") {
1485
+ for (const key in value) {
1486
+ const styleValue = value[key];
1487
+ if (styleValue == null) element.style[key] = "";
1488
+ else element.style[key] = styleValue;
1489
+ }
1490
+ }
1491
+ }
1492
+ function spread(options) {
1493
+ const {
1494
+ element,
1495
+ props,
1496
+ prevProps = EMPTY_OBJ,
1497
+ isSVG = false,
1498
+ skipChildren = false
1499
+ } = options;
1500
+ if (!element || !isDomElement(element)) {
1501
+ console.error("[spread] Error: element is not a DOM Element!");
1502
+ return () => {
1503
+ };
1504
+ }
1505
+ if (!props) {
1506
+ console.warn("[spread] Warning: props is undefined!");
1507
+ return () => {
1508
+ };
1509
+ }
1510
+ const elementIsSVG = isSVG || element.namespaceURI === SVG_NAMESPACE;
1511
+ const disposers = [];
1512
+ for (const key in props) {
1513
+ if (skipChildren && key === "children") continue;
1514
+ const value = props[key];
1515
+ const prev = prevProps[key];
1516
+ if (value === prev) continue;
1517
+ if (key === "ref") {
1518
+ handleRef(value, element);
1519
+ continue;
1520
+ }
1521
+ if (key === "use") {
1522
+ applyUse(element, value);
1523
+ continue;
1524
+ }
1525
+ if (key.startsWith("on:")) {
1526
+ disposers.push(addNativeEventListener(element, key.slice(3), value));
1527
+ continue;
1528
+ }
1529
+ if (key.startsWith("prop:")) {
1530
+ (0, import_signal3.reportReactiveDirective)(element, "prop", key.slice(5), value);
1531
+ disposers.push(setDynamicProperty(element, key.slice(5), value));
1532
+ continue;
1533
+ }
1534
+ if (key.startsWith("attr:")) {
1535
+ (0, import_signal3.reportReactiveDirective)(element, "attr", key.slice(5), value);
1536
+ disposers.push(setDynamicAttribute(element, key.slice(5), value, elementIsSVG));
1537
+ continue;
1538
+ }
1539
+ if (key.startsWith("bool:")) {
1540
+ (0, import_signal3.reportReactiveDirective)(element, "bool", key.slice(5), value);
1541
+ disposers.push(setDynamicBoolAttribute(element, key.slice(5), value));
1542
+ continue;
1543
+ }
1544
+ if (key === "class" || key === "className") {
1545
+ if (typeof value === "function") {
1546
+ disposers.push(
1547
+ (0, import_signal3.createRenderEffect)(() => {
1548
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", "class", value);
1549
+ setClassName(element, value());
1550
+ })
1551
+ );
1552
+ } else {
1553
+ setClassName(element, value);
1554
+ }
1555
+ continue;
1556
+ }
1557
+ if (key === "classList") {
1558
+ reportKeys(element, "class", value);
1559
+ if (typeof value === "function") {
1560
+ disposers.push(
1561
+ (0, import_signal3.createRenderEffect)(() => {
1562
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", "class", value);
1563
+ setClassList(element, value());
1564
+ })
1565
+ );
1566
+ } else {
1567
+ setClassList(element, value, disposers);
1568
+ }
1569
+ continue;
1570
+ }
1571
+ if (key === "style") {
1572
+ reportKeys(element, "style", value);
1573
+ if (typeof value === "function") {
1574
+ disposers.push(
1575
+ (0, import_signal3.createRenderEffect)(() => {
1576
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", "style", value);
1577
+ setStyle(element, value());
1578
+ })
1579
+ );
1580
+ } else {
1581
+ setStyle(element, value);
1582
+ }
1583
+ continue;
1584
+ }
1585
+ if (key.startsWith("on")) {
1586
+ const eventName = key.slice(2).toLowerCase();
1587
+ if (prev) removeDelegatedEventListener(element, eventName);
1588
+ if (value) addDelegatedEventListener(element, eventName, value);
1589
+ continue;
1590
+ }
1591
+ const asProperty = JSX_PROPERTIES.has(key) || !elementIsSVG && key in element;
1592
+ if (typeof value === "function") {
1593
+ disposers.push(
1594
+ asProperty ? setDynamicProperty(element, key, value) : setDynamicAttribute(element, key, value, elementIsSVG)
1595
+ );
1596
+ } else {
1597
+ disposers.push(
1598
+ (0, import_signal3.createRenderEffect)(
1599
+ () => asProperty ? setProperty(element, key, props[key]) : setAttribute(element, key, props[key], elementIsSVG)
1600
+ )
1601
+ );
1602
+ }
1603
+ }
1604
+ for (const key in prevProps) {
1605
+ if (!(key in props)) {
1606
+ if (key.startsWith("on")) {
1607
+ const eventName = key.slice(2).toLowerCase();
1608
+ removeDelegatedEventListener(element, eventName);
1609
+ } else if (JSX_PROPERTIES.has(key)) {
1610
+ setProperty(element, key, null);
1611
+ } else {
1612
+ element.removeAttribute(key);
1613
+ }
1614
+ }
1615
+ }
1616
+ return () => {
1617
+ disposers.forEach((d) => d());
1618
+ };
1619
+ }
1620
+ function applyProps(element, props, isSVG = false) {
1621
+ for (const key in props) {
1622
+ const val = props[key];
1623
+ if (key === "ref") {
1624
+ handleRef(val, element);
1625
+ continue;
1626
+ }
1627
+ if (key === "children") continue;
1628
+ if (key === "use") {
1629
+ applyUse(element, val);
1630
+ continue;
1631
+ }
1632
+ if (key.startsWith("on:")) {
1633
+ addNativeEventListener(element, key.slice(3), val);
1634
+ continue;
1635
+ }
1636
+ if (key.startsWith("prop:")) {
1637
+ (0, import_signal3.reportReactiveDirective)(element, "prop", key.slice(5), val);
1638
+ setDynamicProperty(element, key.slice(5), val);
1639
+ continue;
1640
+ }
1641
+ if (key.startsWith("attr:")) {
1642
+ (0, import_signal3.reportReactiveDirective)(element, "attr", key.slice(5), val);
1643
+ setDynamicAttribute(element, key.slice(5), val, isSVG);
1644
+ continue;
1645
+ }
1646
+ if (key.startsWith("bool:")) {
1647
+ (0, import_signal3.reportReactiveDirective)(element, "bool", key.slice(5), val);
1648
+ setDynamicBoolAttribute(element, key.slice(5), val);
1649
+ continue;
1650
+ }
1651
+ if (key.startsWith("on") && key.length > 2) {
1652
+ const name = key.slice(2).toLowerCase();
1653
+ if (typeof val === "function") {
1654
+ if (NON_DELEGATED.has(name)) {
1655
+ element[`$$${name}`] = val;
1656
+ const listenerKey = `__fx_${name}`;
1657
+ if (!element[listenerKey]) {
1658
+ const forwarder = (e) => {
1659
+ element[`$$${name}`]?.(e);
1660
+ };
1661
+ element.addEventListener(name, forwarder);
1662
+ element[listenerKey] = forwarder;
1663
+ }
1664
+ } else {
1665
+ element[`$$${name}`] = val;
1666
+ if (!delegatedSet.has(name)) delegateEvents([name]);
1667
+ }
1668
+ }
1669
+ continue;
1670
+ }
1671
+ if (key === "class" || key === "className") {
1672
+ setClassName(element, val);
1673
+ continue;
1674
+ }
1675
+ if (key === "classList") {
1676
+ reportKeys(element, "class", val);
1677
+ if (typeof val === "function")
1678
+ (0, import_signal3.createRenderEffect)(() => {
1679
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", "class", val);
1680
+ setClassList(element, val());
1681
+ });
1682
+ else setClassList(element, val);
1683
+ continue;
1684
+ }
1685
+ if (key === "style") {
1686
+ reportKeys(element, "style", val);
1687
+ if (typeof val === "function")
1688
+ (0, import_signal3.createRenderEffect)(() => {
1689
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", "style", val);
1690
+ setStyle(element, val());
1691
+ });
1692
+ else setStyle(element, val);
1693
+ continue;
1694
+ }
1695
+ if (key === "innerHTML") {
1696
+ if (typeof val === "function") {
1697
+ const dispose = (0, import_signal3.createEffect)(() => {
1698
+ let v = val();
1699
+ while (typeof v === "function") v = v();
1700
+ element.innerHTML = v;
1701
+ });
1702
+ (0, import_signal3.onCleanup)(() => dispose());
1703
+ } else {
1704
+ element.innerHTML = val;
1705
+ }
1706
+ continue;
1707
+ }
1708
+ if (key === "value" && (element.tagName === "INPUT" || element.tagName === "TEXTAREA")) {
1709
+ if (typeof val === "function") {
1710
+ const dispose = (0, import_signal3.createEffect)(() => {
1711
+ let v = val();
1712
+ while (typeof v === "function" && v.length === 0) v = v();
1713
+ if (document.activeElement !== element) {
1714
+ element.value = v ?? "";
1715
+ }
1716
+ });
1717
+ (0, import_signal3.onCleanup)(() => {
1718
+ dispose();
1719
+ });
1720
+ } else {
1721
+ (0, import_signal3.createRenderEffect)(() => {
1722
+ if (document.activeElement !== element) {
1723
+ element.value = props[key] ?? "";
1724
+ }
1725
+ });
1726
+ }
1727
+ continue;
1728
+ }
1729
+ if (key === "checked" && element.tagName === "INPUT") {
1730
+ if (typeof val === "function") {
1731
+ const dispose = (0, import_signal3.createEffect)(() => {
1732
+ let v = val();
1733
+ while (typeof v === "function" && v.length === 0) v = v();
1734
+ if (document.activeElement !== element) {
1735
+ element.checked = v ?? "";
1736
+ }
1737
+ });
1738
+ (0, import_signal3.onCleanup)(() => {
1739
+ dispose();
1740
+ });
1741
+ } else {
1742
+ (0, import_signal3.createRenderEffect)(() => {
1743
+ if (document.activeElement !== element) {
1744
+ element.checked = props[key] ?? "";
1745
+ }
1746
+ });
1747
+ }
1748
+ continue;
1749
+ }
1750
+ if (key === "value" && element.tagName === "SELECT") {
1751
+ if (typeof val === "function") {
1752
+ let firstRun = true;
1753
+ const dispose = (0, import_signal3.createEffect)(() => {
1754
+ let v = val();
1755
+ while (typeof v === "function" && v.length === 0) v = v();
1756
+ if (firstRun) {
1757
+ firstRun = false;
1758
+ queueMicrotask(() => {
1759
+ element.value = v ?? "";
1760
+ });
1761
+ } else {
1762
+ element.value = v ?? "";
1763
+ }
1764
+ });
1765
+ (0, import_signal3.onCleanup)(() => {
1766
+ dispose();
1767
+ });
1768
+ } else {
1769
+ let firstRun = true;
1770
+ (0, import_signal3.createRenderEffect)(() => {
1771
+ const v = props[key];
1772
+ if (firstRun) {
1773
+ firstRun = false;
1774
+ queueMicrotask(() => {
1775
+ element.value = v ?? "";
1776
+ });
1777
+ } else {
1778
+ element.value = v ?? "";
1779
+ }
1780
+ });
1781
+ }
1782
+ continue;
1783
+ }
1784
+ if (typeof val === "function") {
1785
+ const dispose = (0, import_signal3.createEffect)(() => {
1786
+ let v = val();
1787
+ while (typeof v === "function" && v.length === 0) v = v();
1788
+ applyElementProp(element, key, v, isSVG);
1789
+ });
1790
+ (0, import_signal3.onCleanup)(() => {
1791
+ dispose();
1792
+ });
1793
+ } else {
1794
+ (0, import_signal3.createRenderEffect)(() => applyElementProp(element, key, props[key], isSVG));
1795
+ }
1796
+ }
1797
+ }
1798
+ function mergeProps(...sources) {
1799
+ const resolve = (key) => {
1800
+ for (let i = sources.length - 1; i >= 0; i--) {
1801
+ const s = sources[i];
1802
+ if (s && key in s && s[key] !== void 0) return s[key];
1803
+ }
1804
+ return void 0;
1805
+ };
1806
+ const hasKey = (key) => {
1807
+ for (const s of sources) if (s && key in s) return true;
1808
+ return false;
1809
+ };
1810
+ return new Proxy({}, {
1811
+ get: (_, key) => resolve(key),
1812
+ has: (_, key) => hasKey(key),
1813
+ ownKeys: () => {
1814
+ const keys = /* @__PURE__ */ new Set();
1815
+ for (const s of sources) if (s) for (const k of Reflect.ownKeys(s)) keys.add(k);
1816
+ return [...keys];
1817
+ },
1818
+ getOwnPropertyDescriptor: (_, key) => hasKey(key) ? { enumerable: true, configurable: true, get: () => resolve(key) } : void 0
1819
+ });
1820
+ }
1821
+ function splitProps(props, ...keys) {
1822
+ const taken = /* @__PURE__ */ new Set();
1823
+ for (const group of keys) for (const k of group) taken.add(k);
1824
+ const descriptor = (p) => ({
1825
+ enumerable: true,
1826
+ configurable: true,
1827
+ get: () => props[p]
1828
+ });
1829
+ const groups = keys.map((group) => {
1830
+ const keySet = new Set(group);
1831
+ return new Proxy({}, {
1832
+ get: (_, p) => keySet.has(p) ? props[p] : void 0,
1833
+ has: (_, p) => keySet.has(p) && p in props,
1834
+ ownKeys: () => Array.from(keySet).filter((k) => k in props),
1835
+ getOwnPropertyDescriptor: (_, p) => keySet.has(p) && p in props ? descriptor(p) : void 0
1836
+ });
1837
+ });
1838
+ const rest = new Proxy({}, {
1839
+ get: (_, p) => taken.has(p) ? void 0 : props[p],
1840
+ has: (_, p) => !taken.has(p) && p in props,
1841
+ ownKeys: () => Reflect.ownKeys(props).filter((k) => !taken.has(k)),
1842
+ getOwnPropertyDescriptor: (_, p) => !taken.has(p) && p in props ? descriptor(p) : void 0
1843
+ });
1844
+ return [...groups, rest];
1845
+ }
1846
+ function handleRef(ref, element) {
1847
+ if (!ref) return;
1848
+ const held = ref[HOLE_TAG]?.name;
1849
+ (0, import_signal3.reportReactiveDirective)(
1850
+ element,
1851
+ "ref",
1852
+ held || (typeof ref === "function" ? ref.name || "ref" : "ref"),
1853
+ ref
1854
+ );
1855
+ if (isDomNode(ref)) {
1856
+ const actualRef = element;
1857
+ const actualElement = ref;
1858
+ if (!actualRef) return;
1859
+ if (typeof actualRef === "function") actualRef(actualElement);
1860
+ else if (typeof actualRef === "object" && "current" in actualRef) actualRef.current = actualElement;
1861
+ return;
1862
+ }
1863
+ if (typeof ref === "function") ref(element);
1864
+ else if (typeof ref === "object" && "current" in ref) ref.current = element;
1865
+ }
1866
+ function createPortal(children, element, props) {
1867
+ const container = element || document.body;
1868
+ const resolved = (0, import_signal3.readChildren)(() => children);
1869
+ const cleanups = [];
1870
+ (0, import_signal3.batch)(() => {
1871
+ const dispose = (0, import_signal3.createRenderEffect)(() => {
1872
+ const nodes = resolved();
1873
+ if (Array.isArray(nodes)) {
1874
+ nodes.forEach((node) => container.appendChild(node));
1875
+ cleanups.push(() => {
1876
+ nodes.forEach((node) => {
1877
+ if (node.parentNode === container) {
1878
+ container.removeChild(node);
1879
+ }
1880
+ });
1881
+ });
1882
+ } else if (isDomNode(nodes)) {
1883
+ container.appendChild(nodes);
1884
+ cleanups.push(() => {
1885
+ if (nodes.parentNode === container) {
1886
+ container.removeChild(nodes);
1887
+ }
1888
+ });
1889
+ }
1890
+ });
1891
+ cleanups.push(dispose);
1892
+ (0, import_signal3.onCleanup)(() => {
1893
+ cleanups.forEach((fn) => fn());
1894
+ });
1895
+ });
1896
+ return null;
1897
+ }
1898
+ function isNativeElement(tag) {
1899
+ return typeof tag === "string" && tag.toLowerCase() === tag;
1900
+ }
1901
+ function isSVGElement(tag) {
1902
+ return tag === "svg" || tag === "path" || tag === "circle" || tag === "rect" || tag === "line" || tag === "polygon" || tag === "polyline" || tag === "ellipse" || tag === "g" || tag === "defs" || tag === "clipPath" || tag === "text";
1903
+ }
1904
+ function escapeHTML(str) {
1905
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
1906
+ }
1907
+ function isPromise(v) {
1908
+ return v != null && (typeof v === "object" || typeof v === "function") && typeof v.then === "function" || v instanceof Promise;
1909
+ }
1910
+ function isAccessor(value) {
1911
+ return typeof value === "function" && value.length === 0 && (0, import_signal2.isSignal)(value);
1912
+ }
1913
+ function render(element, container, context) {
1914
+ if (!container) {
1915
+ throw new Error("Container element is required");
1916
+ }
1917
+ let rendererDispose;
1918
+ let disposeRoot;
1919
+ const disposers = [];
1920
+ (0, import_signal3.createRoot)((dispose) => {
1921
+ (0, import_signal3.batch)(() => {
1922
+ if (!hydration.active) {
1923
+ container.textContent = "";
1924
+ }
1925
+ stampVersions(container);
1926
+ warnOnVersionSkew();
1927
+ insert(container, element);
1928
+ return;
1929
+ });
1930
+ disposeRoot = dispose;
1931
+ });
1932
+ return () => {
1933
+ disposeRoot?.();
1934
+ rendererDispose?.();
1935
+ disposers.forEach((d) => d());
1936
+ container.textContent = "";
1937
+ };
1938
+ }
1939
+ function bindPair(source) {
1940
+ if (Array.isArray(source)) return source;
1941
+ if (typeof source === "function" && typeof source.set === "function") {
1942
+ return [source, source.set];
1943
+ }
1944
+ throw new TypeError(
1945
+ "[fluixi] bind: needs a signal, either `signal(...)` or the `[get, set]` pair from `createSignal(...)`."
1946
+ );
1947
+ }
1948
+
1949
+ // src/lib/dom/integration.ts
1950
+ var import_reactive = require("@fluixi/reactive");
1951
+ var _slotKey = "__fx_dom_create_component__";
1952
+ var _slot = globalThis[_slotKey] ??= { fn: null };
1953
+ function registerCreateComponent(createComponent2) {
1954
+ _slot.fn = createComponent2;
1955
+ }
1956
+ function initializeIntegration(options = {}) {
1957
+ const cc = options.signalSystem?.createComponent;
1958
+ if (cc) _slot.fn = cc;
1959
+ }
1960
+ function createComponent(Comp, props) {
1961
+ if (_slot.fn) return _slot.fn(Comp, props);
1962
+ if (props) (0, import_reactive.reportReactiveProps)(props);
1963
+ const component = typeof Comp === "function" ? (0, import_reactive.untrack)(() => Comp(props)) : Comp;
1964
+ const nameable = component != null && (typeof component === "function" || typeof component === "object");
1965
+ if (nameable) {
1966
+ try {
1967
+ component["$name"] = Comp?.name;
1968
+ } catch {
1969
+ }
1970
+ }
1971
+ if (nameable && !(0, import_reactive.isSignal)(component)) {
1972
+ return asComponent(component);
1973
+ }
1974
+ return component;
1975
+ }
1976
+ var intergartionInitialized = () => _slot.fn !== null;
1977
+ var isIntegrationInitialized = () => _slot.fn !== null;
1978
+ function resetIntegration() {
1979
+ _slot.fn = null;
1980
+ }
1981
+
1982
+ // src/lib/dom/server/request-context.ts
1983
+ var _current;
1984
+ var syncStore = {
1985
+ getStore: () => _current,
1986
+ run(ctx, fn) {
1987
+ const prev = _current;
1988
+ _current = ctx;
1989
+ try {
1990
+ return fn();
1991
+ } finally {
1992
+ _current = prev;
1993
+ }
1994
+ }
1995
+ };
1996
+ var _store = syncStore;
1997
+ function setRequestStore(store2) {
1998
+ _store = store2 ?? syncStore;
1999
+ }
2000
+ function createRequestContext(event = {}) {
2001
+ if (!event.locals) {
2002
+ event.locals = event.request ? getRequestLocals(event.request) : {};
2003
+ }
2004
+ let id = 0;
2005
+ let rid = 0;
2006
+ let scope = null;
2007
+ const scopeCounters = /* @__PURE__ */ new Map();
2008
+ const islandCounts = /* @__PURE__ */ new Map();
2009
+ return {
2010
+ event,
2011
+ routeData: /* @__PURE__ */ new Map(),
2012
+ matchedRoute: /* @__PURE__ */ new Map(),
2013
+ nextId: () => `s${id++}`,
2014
+ nextResourceId: () => {
2015
+ if (scope === null) return `r${rid++}`;
2016
+ const n = scopeCounters.get(scope) ?? 0;
2017
+ scopeCounters.set(scope, n + 1);
2018
+ return `${scope}:r${n}`;
2019
+ },
2020
+ nextIslandNamespace: (name) => {
2021
+ const n = islandCounts.get(name) ?? 0;
2022
+ islandCounts.set(name, n + 1);
2023
+ return `${name}#${n}`;
2024
+ },
2025
+ withResourceScope(ns, fn) {
2026
+ const prev = scope;
2027
+ scope = ns;
2028
+ try {
2029
+ return fn();
2030
+ } finally {
2031
+ scope = prev;
2032
+ }
2033
+ },
2034
+ pending: /* @__PURE__ */ new Set(),
2035
+ data: /* @__PURE__ */ new Map()
2036
+ };
2037
+ }
2038
+ function runWithRequestContext(ctx, fn) {
2039
+ return _store.run(ctx, fn);
2040
+ }
2041
+ function getRequestContext() {
2042
+ return _store.getStore();
2043
+ }
2044
+ function getRequestEvent() {
2045
+ return getRequestContext()?.event;
2046
+ }
2047
+ function getLocals() {
2048
+ const event = getRequestEvent();
2049
+ if (!event) return {};
2050
+ if (!event.locals) event.locals = {};
2051
+ return event.locals;
2052
+ }
2053
+ var _requestLocals = /* @__PURE__ */ new WeakMap();
2054
+ function getRequestLocals(request) {
2055
+ let bag = _requestLocals.get(request);
2056
+ if (!bag) {
2057
+ bag = {};
2058
+ _requestLocals.set(request, bag);
2059
+ }
2060
+ return bag;
2061
+ }
2062
+
2063
+ // src/lib/dom/hydration.ts
2064
+ var import_signal4 = require("@fluixi/reactive/signal");
2065
+
2066
+ // src/lib/dom/server/fx-data.ts
2067
+ var FX_DATA_ID = "__FX_DATA__";
2068
+ function escapeFxJson(json) {
2069
+ return json.replace(/[<>&\u2028\u2029]/g, (c) => "\\u" + c.charCodeAt(0).toString(16).padStart(4, "0"));
2070
+ }
2071
+ var _scriptCache;
2072
+ function getServerData() {
2073
+ const g = globalThis.__FX_DATA__;
2074
+ if (g) return g;
2075
+ if (_scriptCache !== void 0) return _scriptCache;
2076
+ let parsed = null;
2077
+ if (typeof document !== "undefined") {
2078
+ const text = document.getElementById(FX_DATA_ID)?.textContent;
2079
+ if (text) {
2080
+ try {
2081
+ parsed = JSON.parse(text);
2082
+ } catch {
2083
+ parsed = null;
2084
+ }
2085
+ }
2086
+ }
2087
+ return _scriptCache = parsed;
2088
+ }
2089
+
2090
+ // src/lib/dom/hydration.ts
2091
+ function recoverCursor() {
2092
+ for (; ; ) {
2093
+ while (hydration.cursor && hydration.cursor.nodeType === 3 && hydration.cursor.data === "") {
2094
+ hydration.cursor = hydration.cursor.nextSibling;
2095
+ }
2096
+ if (hydration.cursor != null || !hydration.parents.length) return;
2097
+ hydration.cursor = hydration.parents.pop().nextSibling;
2098
+ }
2099
+ }
2100
+ var VOID_ELEMENTS2 = /* @__PURE__ */ new Set([
2101
+ "area",
2102
+ "base",
2103
+ "br",
2104
+ "col",
2105
+ "embed",
2106
+ "hr",
2107
+ "img",
2108
+ "input",
2109
+ "link",
2110
+ "meta",
2111
+ "param",
2112
+ "source",
2113
+ "track",
2114
+ "wbr"
2115
+ ]);
2116
+ var DEV = typeof process !== "undefined" && process.env && false;
2117
+ function warnMismatch(expected, found) {
2118
+ const f = found.nodeType === 1 ? `<${found.tagName.toLowerCase()}>` : found.nodeType === 3 ? `text ${JSON.stringify((found.nodeValue ?? "").slice(0, 24))}` : found.nodeType === 8 ? "comment" : "node";
2119
+ console.warn(
2120
+ `[fluixi] hydration mismatch: expected ${expected} but the server DOM has ${f}. Server and client rendered different markup; recreating this node on the client. Check for non-deterministic render (Date.now(), Math.random(), browser-only branches, untransported data).`
2121
+ );
2122
+ }
2123
+ function hydrateElement(tag) {
2124
+ recoverCursor();
2125
+ const c = hydration.cursor;
2126
+ if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
2127
+ if (VOID_ELEMENTS2.has(tag.toLowerCase())) {
2128
+ hydration.cursor = c.nextSibling;
2129
+ } else {
2130
+ hydration.parents.push(c);
2131
+ hydration.cursor = c.firstChild;
2132
+ }
2133
+ return c;
2134
+ }
2135
+ if (DEV && c) warnMismatch(`<${tag}>`, c);
2136
+ return null;
2137
+ }
2138
+ function hydrateStatic(tag) {
2139
+ recoverCursor();
2140
+ const c = hydration.cursor;
2141
+ if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
2142
+ hydration.cursor = c.nextSibling;
2143
+ return c;
2144
+ }
2145
+ if (DEV && c) warnMismatch(`<${tag}> (static)`, c);
2146
+ return null;
2147
+ }
2148
+ function hydrateText(value) {
2149
+ if (value === "") {
2150
+ const c2 = hydration.cursor;
2151
+ if (c2 && c2.nodeType === 3 && c2.data !== "") {
2152
+ hydration.cursor = c2.nextSibling;
2153
+ c2.data = "";
2154
+ return c2;
2155
+ }
2156
+ return null;
2157
+ }
2158
+ recoverCursor();
2159
+ const c = hydration.cursor;
2160
+ if (c && c.nodeType === 3) {
2161
+ hydration.cursor = c.nextSibling;
2162
+ if (c.nodeValue !== value) c.nodeValue = value;
2163
+ return c;
2164
+ }
2165
+ if (DEV && c) warnMismatch(`text ${JSON.stringify(value.slice(0, 24))}`, c);
2166
+ return null;
2167
+ }
2168
+ function hydrateMarker(value) {
2169
+ recoverCursor();
2170
+ const c = hydration.cursor;
2171
+ if (c && c.nodeType === 8 && c.data === value) {
2172
+ hydration.cursor = c.nextSibling;
2173
+ return c;
2174
+ }
2175
+ if (DEV && c) warnMismatch(`marker <!--${value.slice(0, 24)}-->`, c);
2176
+ return null;
2177
+ }
2178
+ var _walkerRegistered = false;
2179
+ function ensureWalker() {
2180
+ if (_walkerRegistered) return;
2181
+ _walkerRegistered = true;
2182
+ registerHydrationWalker({ hydrateElement, hydrateText, hydrateMarker, hydrateStatic });
2183
+ }
2184
+ function hydrate(element, container, options) {
2185
+ ensureWalker();
2186
+ hydration.active = true;
2187
+ hydration.cursor = container.firstChild;
2188
+ hydration.parents = [];
2189
+ const data = getServerData();
2190
+ const ns = options?.resourceNamespace;
2191
+ let rid = 0;
2192
+ (0, import_signal4.setResourceIdSource)(() => ns ? `${ns}:r${rid++}` : `r${rid++}`);
2193
+ (0, import_signal4.setServerDataGetter)(data ? (id) => id in data ? { value: data[id] } : void 0 : null);
2194
+ try {
2195
+ return render(element, container);
2196
+ } finally {
2197
+ hydration.active = false;
2198
+ hydration.cursor = null;
2199
+ hydration.parents = [];
2200
+ }
2201
+ }
2202
+
2203
+ // src/lib/dom/island.ts
2204
+ var TAG = "fluixi-island";
2205
+ function Island(props) {
2206
+ const { component, props: cprops = {}, name } = props;
2207
+ const el = createNativeElement(TAG);
2208
+ const islandName = name ?? component.name ?? "Island";
2209
+ setAttribute(el, "name", islandName);
2210
+ setAttribute(el, "props", JSON.stringify(cprops ?? {}));
2211
+ const ctx = isServer() ? getRequestContext() : void 0;
2212
+ if (ctx) {
2213
+ const ns = ctx.nextIslandNamespace(islandName);
2214
+ insert(el, () => ctx.withResourceScope(ns, () => component(cprops)));
2215
+ } else {
2216
+ insert(el, () => component(cprops));
2217
+ }
2218
+ return el;
2219
+ }
2220
+ var _styleInjected = false;
2221
+ function ensureDisplayContents() {
2222
+ if (_styleInjected || typeof document === "undefined") return;
2223
+ _styleInjected = true;
2224
+ const style = document.createElement("style");
2225
+ style.textContent = `${TAG}{display:contents}`;
2226
+ document.head.appendChild(style);
2227
+ }
2228
+ function hydrateIslands(registry) {
2229
+ if (typeof document === "undefined") return;
2230
+ ensureDisplayContents();
2231
+ const els = document.querySelectorAll(TAG);
2232
+ const counts = /* @__PURE__ */ new Map();
2233
+ els.forEach((el) => {
2234
+ const name = el.getAttribute("name") ?? "";
2235
+ const occ = counts.get(name) ?? 0;
2236
+ counts.set(name, occ + 1);
2237
+ const Comp = registry[name];
2238
+ if (!Comp) {
2239
+ if (typeof process === "undefined" || false) {
2240
+ console.warn(`[fluixi] island "${name}" has no component in the registry, left static.`);
2241
+ }
2242
+ return;
2243
+ }
2244
+ let props = {};
2245
+ try {
2246
+ props = JSON.parse(el.getAttribute("props") || "{}");
2247
+ } catch {
2248
+ }
2249
+ hydrate(() => Comp(props), el, { resourceNamespace: `${name}#${occ}` });
2250
+ });
2251
+ }
2252
+
2253
+ // src/lib/html.ts
2254
+ function html(_strings, ..._values) {
2255
+ throw new Error("html`` was not compiled, enable the lit format: fluixi({ format: 'lit' }).");
2256
+ }
2257
+ function svg(_strings, ..._values) {
2258
+ throw new Error("svg`` was not compiled, enable the lit format: fluixi({ format: 'lit' }).");
2259
+ }
2260
+
2261
+ // src/lib/dom/dynamic-element.ts
2262
+ var import_signal5 = require("@fluixi/reactive/signal");
2263
+ function createDynamicElement(type, props = {}) {
2264
+ if (typeof type === "function") return createComponent(type, props);
2265
+ if (typeof type !== "string" || type.length === 0) return null;
2266
+ const svgTag = isSVGElement(type);
2267
+ if (isServer()) return getServerNodes().createElement(type, svgTag);
2268
+ const element = svgTag ? document.createElementNS(SVG_NAMESPACE, type) : document.createElement(type);
2269
+ applyProps(element, props, svgTag);
2270
+ insertChildren(element, props);
2271
+ return element;
2272
+ }
2273
+ function insertChildren(element, props) {
2274
+ if (!props || props.children === void 0) return;
2275
+ const children = (0, import_signal5.readChildren)(() => props.children);
2276
+ const insertOne = (child) => {
2277
+ insert(element, child, typeof child === "function" ? null : void 0);
2278
+ };
2279
+ if (Array.isArray(children)) children.forEach(insertOne);
2280
+ else insertOne(children);
2281
+ }
2282
+
2283
+ // src/lib/flow/show.ts
2284
+ var import_signal6 = require("@fluixi/reactive/signal");
2285
+
2286
+ // src/lib/flow/utils.ts
2287
+ function normalizeAccessor(value) {
2288
+ return typeof value === "function" ? value : (() => value);
2289
+ }
2290
+ function resolveReactiveProp(read) {
2291
+ return () => {
2292
+ const value = read();
2293
+ return typeof value === "function" ? value() : value;
2294
+ };
2295
+ }
2296
+ function isTruthy(value) {
2297
+ return value !== null && value !== void 0 && value !== false;
2298
+ }
2299
+ function isLitResult(value) {
2300
+ if (!value || typeof value !== "object") return false;
2301
+ return !!(typeof value["_$litType$"] !== "undefined" || typeof value["_$litDirective$"] !== "undefined" || Array.isArray(value.strings) && Array.isArray(value.values));
2302
+ }
2303
+
2304
+ // src/lib/flow/show.ts
2305
+ function Show(props) {
2306
+ const when = resolveReactiveProp(() => props.when);
2307
+ const value = (0, import_signal6.createMemo)(when, void 0, { name: "Show.when" });
2308
+ const cond = (0, import_signal6.createMemo)(value, void 0, { name: "Show.cond" });
2309
+ const parentOwner = (0, import_signal6.getOwner)();
2310
+ let branchScope = null;
2311
+ let shown = null;
2312
+ const enterBranch = (next) => {
2313
+ if (next === shown) return;
2314
+ if (branchScope) (0, import_signal6.disposeScope)(branchScope);
2315
+ branchScope = (0, import_signal6.createChildOwner)(parentOwner);
2316
+ shown = next;
2317
+ };
2318
+ return (0, import_signal6.createMemo)(
2319
+ () => {
2320
+ const evaluate = cond();
2321
+ enterBranch(evaluate ? "when" : "fallback");
2322
+ return (0, import_signal6.runWithOwner)(branchScope, () => {
2323
+ if (evaluate) {
2324
+ let children = props.children;
2325
+ if (typeof children === "function" && !isLitResult(children)) {
2326
+ if (typeof value === "function") {
2327
+ return (0, import_signal6.untrack)(() => {
2328
+ if (!(0, import_signal6.untrack)(value)) return props.fallback;
2329
+ return children(value());
2330
+ });
2331
+ }
2332
+ return children(value);
2333
+ }
2334
+ return children;
2335
+ }
2336
+ return props.fallback;
2337
+ });
2338
+ return props.fallback ?? null;
2339
+ },
2340
+ void 0,
2341
+ // Not `Show`: the compiler already marks the memo it wraps the component in with that,
2342
+ // and two cards of the same name in one graph is worse than a longer one.
2343
+ { name: "Show.result" }
2344
+ );
2345
+ }
2346
+
2347
+ // src/lib/flow/for.ts
2348
+ var import_signal7 = require("@fluixi/reactive/signal");
2349
+ function For(props) {
2350
+ const each = resolveReactiveProp(() => props.each);
2351
+ const fallback = () => props.fallback ?? null;
2352
+ const render2 = (item, index) => {
2353
+ const children = props.children;
2354
+ const rendered = Array.isArray(children) ? children.map((c) => typeof c === "function" ? c(item, index) : c) : typeof children === "function" ? children(item, index) : children;
2355
+ hydrateAdvancePast(rendered);
2356
+ return rendered;
2357
+ };
2358
+ return props.by ? (0, import_signal7.keyArray)(each, props.by, (item, index) => render2(item, index), { fallback }) : (0, import_signal7.mapArray)(each, (item, index) => render2(item, index), { fallback });
2359
+ }
2360
+
2361
+ // src/lib/flow/index-flow.ts
2362
+ var import_signal8 = require("@fluixi/reactive/signal");
2363
+ function Index(props) {
2364
+ const each = resolveReactiveProp(() => props.each);
2365
+ return (0, import_signal8.indexArray)(
2366
+ each,
2367
+ (item, index) => {
2368
+ const rendered = props.children(item, index);
2369
+ hydrateAdvancePast(rendered);
2370
+ return rendered;
2371
+ },
2372
+ { fallback: () => props.fallback ?? null }
2373
+ );
2374
+ }
2375
+
2376
+ // src/lib/flow/index.ts
2377
+ var import_signal16 = require("@fluixi/reactive/signal");
2378
+
2379
+ // src/lib/flow/switch.ts
2380
+ var import_signal9 = require("@fluixi/reactive/signal");
2381
+ var MATCH_MARKER = /* @__PURE__ */ Symbol("match");
2382
+ function Match(props) {
2383
+ return {
2384
+ [MATCH_MARKER]: true,
2385
+ // Lazy read through the prop getter. Switch calls `branch.when()` inside its memo,
2386
+ // so `when={cond()}` reacts; `when={cond}` unwraps via resolveReactiveProp.
2387
+ when: resolveReactiveProp(() => props.when),
2388
+ // Lazy, like `when`. Read eagerly, every branch's children were built the
2389
+ // moment the Match node was, before Switch had chosen one, so they were
2390
+ // created outside the branch's scope (and non-matching branches were built
2391
+ // for nothing). Switch reads this inside the selected branch's scope.
2392
+ get children() {
2393
+ return props.children;
2394
+ }
2395
+ };
2396
+ }
2397
+ function Switch(props) {
2398
+ const branches = Array.isArray(props.children) ? props.children : [props.children];
2399
+ const parentOwner = (0, import_signal9.getOwner)();
2400
+ let branchScope = null;
2401
+ let shown = -1;
2402
+ const enterBranch = (index) => {
2403
+ if (index === shown) return;
2404
+ if (branchScope) (0, import_signal9.disposeScope)(branchScope);
2405
+ branchScope = (0, import_signal9.createChildOwner)(parentOwner);
2406
+ shown = index;
2407
+ };
2408
+ return (0, import_signal9.createMemo)(() => {
2409
+ for (let i = 0; i < branches.length; i += 1) {
2410
+ const raw = branches[i];
2411
+ let branch = raw;
2412
+ let guard = 0;
2413
+ while (typeof branch === "function" && !branch[MATCH_MARKER] && guard++ < 10) {
2414
+ branch = branch();
2415
+ }
2416
+ if (!branch || typeof branch !== "object" || branch[MATCH_MARKER] !== true) {
2417
+ continue;
2418
+ }
2419
+ const value = branch.when();
2420
+ if (isTruthy(value)) {
2421
+ enterBranch(i);
2422
+ return (0, import_signal9.runWithOwner)(
2423
+ branchScope,
2424
+ () => typeof branch.children === "function" ? branch.children(value) : branch.children
2425
+ );
2426
+ }
2427
+ }
2428
+ enterBranch(-2);
2429
+ return (0, import_signal9.runWithOwner)(branchScope, () => props.fallback ?? null);
2430
+ }, void 0, { name: "Switch" });
2431
+ }
2432
+
2433
+ // src/lib/flow/dynamic.ts
2434
+ var import_signal10 = require("@fluixi/reactive/signal");
2435
+ function Dynamic(props) {
2436
+ const getComponent = normalizeAccessor(props.component);
2437
+ const { component: _c, ...rest } = props;
2438
+ const parentOwner = (0, import_signal10.getOwner)();
2439
+ let scope = null;
2440
+ let current;
2441
+ return (0, import_signal10.createMemo)(() => {
2442
+ const C = getComponent();
2443
+ if (C !== current) {
2444
+ if (scope) (0, import_signal10.disposeScope)(scope);
2445
+ scope = (0, import_signal10.createChildOwner)(parentOwner);
2446
+ current = C;
2447
+ }
2448
+ if (C == null) return null;
2449
+ if (typeof C === "string") {
2450
+ return { tag: C, props: rest };
2451
+ }
2452
+ return (0, import_signal10.runWithOwner)(scope, () => C(rest));
2453
+ }, void 0, { name: "Dynamic" });
2454
+ }
2455
+
2456
+ // src/lib/flow/portal.ts
2457
+ var import_signal11 = require("@fluixi/reactive/signal");
2458
+ function Portal(props) {
2459
+ const getMount = () => {
2460
+ if (!props.mount) return document.body;
2461
+ return typeof props.mount === "function" ? props.mount() : props.mount;
2462
+ };
2463
+ let dispose;
2464
+ let container;
2465
+ (0, import_signal11.createRoot)((d) => {
2466
+ dispose = d;
2467
+ container = document.createElement("div");
2468
+ container.style.display = "contents";
2469
+ const target = getMount();
2470
+ target.appendChild(container);
2471
+ const inserted = insert(container, props.children);
2472
+ if (inserted) {
2473
+ handleRef(props.ref, container);
2474
+ }
2475
+ });
2476
+ (0, import_signal11.onCleanup)(() => {
2477
+ dispose();
2478
+ container.remove();
2479
+ });
2480
+ return null;
2481
+ }
2482
+
2483
+ // src/lib/flow/client-only.ts
2484
+ var import_signal12 = require("@fluixi/reactive/signal");
2485
+ function ClientOnly(props) {
2486
+ if (isServer()) return props.fallback ?? null;
2487
+ const hydrating = hydration.active;
2488
+ const [ready, setReady] = (0, import_signal12.createSignal)(!hydrating);
2489
+ if (hydrating) queueMicrotask(() => setReady(true));
2490
+ return (0, import_signal12.createMemo)(() => ready() ? props.children : props.fallback ?? null, void 0, {
2491
+ name: "client-only"
2492
+ });
2493
+ }
2494
+ var NoSsr = ClientOnly;
2495
+
2496
+ // src/lib/flow/error-boundary.ts
2497
+ var import_signal13 = require("@fluixi/reactive/signal");
2498
+ function ErrorBoundary(props) {
2499
+ const [error, setError] = (0, import_signal13.createSignal)(null);
2500
+ const reset = () => setError(null);
2501
+ return (0, import_signal13.createMemo)(() => {
2502
+ const err = error();
2503
+ if (err !== null) {
2504
+ return typeof props.fallback === "function" ? props.fallback(err, reset) : props.fallback;
2505
+ }
2506
+ try {
2507
+ const content = typeof props.children === "function" ? props.children() : props.children;
2508
+ return content;
2509
+ } catch (e) {
2510
+ setError(e);
2511
+ return typeof props.fallback === "function" ? props.fallback(e, reset) : props.fallback;
2512
+ }
2513
+ }, void 0, { name: "ErrorBoundary" });
2514
+ }
2515
+
2516
+ // src/lib/flow/class-map.ts
2517
+ var import_signal14 = require("@fluixi/reactive/signal");
2518
+ function classMap(input) {
2519
+ return (0, import_signal14.createMemo)(() => {
2520
+ const map = typeof input === "function" ? input() : input;
2521
+ const classes = [];
2522
+ for (const [cls, cond] of Object.entries(map)) {
2523
+ if (!cls) continue;
2524
+ const active = typeof cond === "function" ? cond() : cond;
2525
+ if (active) classes.push(cls);
2526
+ }
2527
+ return classes.join(" ");
2528
+ }, void 0, { name: "ClassMap" });
2529
+ }
2530
+
2531
+ // src/lib/flow/style-map.ts
2532
+ var import_signal15 = require("@fluixi/reactive/signal");
2533
+ function toKebab(prop) {
2534
+ return prop.startsWith("--") ? prop : prop.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
2535
+ }
2536
+ function styleMap(input) {
2537
+ return (0, import_signal15.createMemo)(() => {
2538
+ const map = typeof input === "function" ? input() : input;
2539
+ const parts = [];
2540
+ for (const [prop, val] of Object.entries(map)) {
2541
+ if (!prop) continue;
2542
+ const resolved = typeof val === "function" ? val() : val;
2543
+ if (resolved != null) {
2544
+ parts.push(`${toKebab(prop)}: ${resolved}`);
2545
+ }
2546
+ }
2547
+ return parts.join("; ");
2548
+ }, void 0, { name: "StyleMap" });
2549
+ }
2550
+
2551
+ // src/lib/dom/server/nodes.ts
2552
+ var NODE_ELEMENT = 1;
2553
+ var NODE_TEXT = 3;
2554
+ var NODE_COMMENT = 8;
2555
+ var _a;
2556
+ _a = SERVER_NODE;
2557
+ var ServerNode = class {
2558
+ constructor() {
2559
+ // Brand the host.ts guards check for (lets them skip an instanceof on these classes).
2560
+ this[_a] = true;
2561
+ this.parentNode = null;
2562
+ this.childNodes = [];
2563
+ }
2564
+ get firstChild() {
2565
+ return this.childNodes[0] ?? null;
2566
+ }
2567
+ get lastChild() {
2568
+ return this.childNodes[this.childNodes.length - 1] ?? null;
2569
+ }
2570
+ get nextSibling() {
2571
+ const p = this.parentNode;
2572
+ if (!p) return null;
2573
+ const i = p.childNodes.indexOf(this);
2574
+ return i >= 0 ? p.childNodes[i + 1] ?? null : null;
2575
+ }
2576
+ get previousSibling() {
2577
+ const p = this.parentNode;
2578
+ if (!p) return null;
2579
+ const i = p.childNodes.indexOf(this);
2580
+ return i > 0 ? p.childNodes[i - 1] ?? null : null;
2581
+ }
2582
+ get parentElement() {
2583
+ return this.parentNode;
2584
+ }
2585
+ appendChild(child) {
2586
+ if (child.parentNode) child.parentNode.removeChild(child);
2587
+ child.parentNode = this;
2588
+ this.childNodes.push(child);
2589
+ return child;
2590
+ }
2591
+ insertBefore(child, ref) {
2592
+ if (ref == null) return this.appendChild(child);
2593
+ if (child.parentNode) child.parentNode.removeChild(child);
2594
+ const i = this.childNodes.indexOf(ref);
2595
+ child.parentNode = this;
2596
+ if (i < 0) this.childNodes.push(child);
2597
+ else this.childNodes.splice(i, 0, child);
2598
+ return child;
2599
+ }
2600
+ removeChild(child) {
2601
+ const i = this.childNodes.indexOf(child);
2602
+ if (i >= 0) this.childNodes.splice(i, 1);
2603
+ child.parentNode = null;
2604
+ return child;
2605
+ }
2606
+ replaceChild(next, old) {
2607
+ const i = this.childNodes.indexOf(old);
2608
+ if (i >= 0) {
2609
+ if (next.parentNode) next.parentNode.removeChild(next);
2610
+ next.parentNode = this;
2611
+ this.childNodes[i] = next;
2612
+ old.parentNode = null;
2613
+ }
2614
+ return old;
2615
+ }
2616
+ // Event listeners are inert on the server.
2617
+ addEventListener() {
2618
+ }
2619
+ removeEventListener() {
2620
+ }
2621
+ };
2622
+ var ServerText = class _ServerText extends ServerNode {
2623
+ constructor(value) {
2624
+ super();
2625
+ this.nodeType = NODE_TEXT;
2626
+ this.data = value;
2627
+ }
2628
+ get nodeValue() {
2629
+ return this.data;
2630
+ }
2631
+ set nodeValue(v) {
2632
+ this.data = v == null ? "" : String(v);
2633
+ }
2634
+ get textContent() {
2635
+ return this.data;
2636
+ }
2637
+ set textContent(v) {
2638
+ this.data = v == null ? "" : String(v);
2639
+ }
2640
+ cloneNode() {
2641
+ return new _ServerText(this.data);
2642
+ }
2643
+ };
2644
+ var ServerRaw = class _ServerRaw extends ServerNode {
2645
+ constructor(html2) {
2646
+ super();
2647
+ this.nodeType = NODE_ELEMENT;
2648
+ this.rawOuterHTML = html2;
2649
+ }
2650
+ get textContent() {
2651
+ return this.rawOuterHTML.replace(/<[^>]*>/g, "");
2652
+ }
2653
+ cloneNode() {
2654
+ return new _ServerRaw(this.rawOuterHTML);
2655
+ }
2656
+ };
2657
+ var ServerComment = class _ServerComment extends ServerNode {
2658
+ constructor(value) {
2659
+ super();
2660
+ this.nodeType = NODE_COMMENT;
2661
+ this.data = value;
2662
+ }
2663
+ get nodeValue() {
2664
+ return this.data;
2665
+ }
2666
+ set nodeValue(v) {
2667
+ this.data = v == null ? "" : String(v);
2668
+ }
2669
+ cloneNode() {
2670
+ return new _ServerComment(this.data);
2671
+ }
2672
+ };
2673
+ var ServerStyle = class {
2674
+ constructor() {
2675
+ // declared keys are stored as own props; cssText holds a raw string blob.
2676
+ this.cssText = "";
2677
+ }
2678
+ setProperty(name, value) {
2679
+ this[name] = value;
2680
+ }
2681
+ removeProperty(name) {
2682
+ delete this[name];
2683
+ }
2684
+ };
2685
+ var ServerClassList = class {
2686
+ constructor(el) {
2687
+ this.el = el;
2688
+ }
2689
+ list() {
2690
+ const c = this.el.getAttribute("class");
2691
+ return c ? c.split(/\s+/).filter(Boolean) : [];
2692
+ }
2693
+ write(arr) {
2694
+ if (arr.length) this.el.setAttribute("class", arr.join(" "));
2695
+ else this.el.removeAttribute("class");
2696
+ }
2697
+ add(...names) {
2698
+ const arr = this.list();
2699
+ for (const n of names) if (!arr.includes(n)) arr.push(n);
2700
+ this.write(arr);
2701
+ }
2702
+ remove(...names) {
2703
+ this.write(this.list().filter((c) => !names.includes(c)));
2704
+ }
2705
+ contains(name) {
2706
+ return this.list().includes(name);
2707
+ }
2708
+ toggle(name, force) {
2709
+ const has = this.contains(name);
2710
+ const on = force === void 0 ? !has : force;
2711
+ if (on) this.add(name);
2712
+ else this.remove(name);
2713
+ return on;
2714
+ }
2715
+ };
2716
+ var ServerElement = class _ServerElement extends ServerNode {
2717
+ constructor(tag, isSVG = false) {
2718
+ super();
2719
+ this.nodeType = NODE_ELEMENT;
2720
+ this.attributes = /* @__PURE__ */ new Map();
2721
+ this.style = new ServerStyle();
2722
+ this.classList = new ServerClassList(this);
2723
+ /** raw HTML set via innerHTML: emitted verbatim, bypassing childNodes. */
2724
+ this.rawHTML = null;
2725
+ this.localName = tag.toLowerCase();
2726
+ this.tagName = isSVG ? tag : tag.toUpperCase();
2727
+ this.isSVG = isSVG;
2728
+ this.namespaceURI = isSVG ? "http://www.w3.org/2000/svg" : null;
2729
+ }
2730
+ setAttribute(name, value) {
2731
+ this.attributes.set(name, String(value));
2732
+ }
2733
+ removeAttribute(name) {
2734
+ this.attributes.delete(name);
2735
+ }
2736
+ getAttribute(name) {
2737
+ return this.attributes.has(name) ? this.attributes.get(name) : null;
2738
+ }
2739
+ hasAttribute(name) {
2740
+ return this.attributes.has(name);
2741
+ }
2742
+ get id() {
2743
+ return this.getAttribute("id") ?? "";
2744
+ }
2745
+ set id(v) {
2746
+ if (v == null) this.removeAttribute("id");
2747
+ else this.setAttribute("id", v);
2748
+ }
2749
+ // JSX_PROPERTIES: className/value/checked/selected/innerHTML/innerText/
2750
+ // textContent/indeterminate/htmlFor flow through setProperty (element[k]=v).
2751
+ get className() {
2752
+ return this.getAttribute("class") ?? "";
2753
+ }
2754
+ set className(v) {
2755
+ if (v == null) this.removeAttribute("class");
2756
+ else this.setAttribute("class", v);
2757
+ }
2758
+ get htmlFor() {
2759
+ return this.getAttribute("for") ?? "";
2760
+ }
2761
+ set htmlFor(v) {
2762
+ if (v == null) this.removeAttribute("for");
2763
+ else this.setAttribute("for", v);
2764
+ }
2765
+ set value(v) {
2766
+ if (v == null) this.removeAttribute("value");
2767
+ else this.setAttribute("value", String(v));
2768
+ }
2769
+ set checked(v) {
2770
+ if (v) this.setAttribute("checked", "");
2771
+ else this.removeAttribute("checked");
2772
+ }
2773
+ set selected(v) {
2774
+ if (v) this.setAttribute("selected", "");
2775
+ else this.removeAttribute("selected");
2776
+ }
2777
+ // indeterminate is a live-only DOM property with no HTML serialization.
2778
+ set indeterminate(_v) {
2779
+ }
2780
+ get textContent() {
2781
+ return this.childNodes.map((c) => c.textContent ?? "").join("");
2782
+ }
2783
+ set textContent(v) {
2784
+ for (const c of this.childNodes) c.parentNode = null;
2785
+ this.childNodes = [];
2786
+ this.rawHTML = null;
2787
+ if (v != null && v !== "") this.appendChild(new ServerText(String(v)));
2788
+ }
2789
+ set innerText(v) {
2790
+ this.textContent = v;
2791
+ }
2792
+ set innerHTML(v) {
2793
+ for (const c of this.childNodes) c.parentNode = null;
2794
+ this.childNodes = [];
2795
+ this.rawHTML = v == null ? "" : String(v);
2796
+ }
2797
+ cloneNode(deep = false) {
2798
+ const el = new _ServerElement(this.localName, this.isSVG);
2799
+ el.attributes = new Map(this.attributes);
2800
+ el.style.cssText = this.style.cssText;
2801
+ el.rawHTML = this.rawHTML;
2802
+ if (deep) for (const c of this.childNodes) el.appendChild(c.cloneNode(true));
2803
+ return el;
2804
+ }
2805
+ };
2806
+
2807
+ // src/lib/dom/server/serialize.ts
2808
+ var VOID_ELEMENTS3 = /* @__PURE__ */ new Set([
2809
+ "area",
2810
+ "base",
2811
+ "br",
2812
+ "col",
2813
+ "embed",
2814
+ "hr",
2815
+ "img",
2816
+ "input",
2817
+ "link",
2818
+ "meta",
2819
+ "param",
2820
+ "source",
2821
+ "track",
2822
+ "wbr"
2823
+ ]);
2824
+ var AMP = /&/g;
2825
+ var LT = /</g;
2826
+ var GT = />/g;
2827
+ var QUOT = /"/g;
2828
+ function escapeText(s) {
2829
+ return s.replace(AMP, "&amp;").replace(LT, "&lt;").replace(GT, "&gt;");
2830
+ }
2831
+ function escapeAttr(s) {
2832
+ return s.replace(AMP, "&amp;").replace(QUOT, "&quot;").replace(LT, "&lt;").replace(GT, "&gt;");
2833
+ }
2834
+ function camelToKebab(k) {
2835
+ if (k.startsWith("--")) return k;
2836
+ return k.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
2837
+ }
2838
+ function serializeStyle(style) {
2839
+ if (!style) return "";
2840
+ const parts = [];
2841
+ if (style.cssText) parts.push(style.cssText.trim().replace(/;\s*$/, ""));
2842
+ for (const key of Object.keys(style)) {
2843
+ if (key === "cssText") continue;
2844
+ const v = style[key];
2845
+ if (v == null || v === "") continue;
2846
+ parts.push(`${camelToKebab(key)}: ${v}`);
2847
+ }
2848
+ return parts.join("; ");
2849
+ }
2850
+ function serializeAttrs(el) {
2851
+ let out = "";
2852
+ const inlineStyle = serializeStyle(el.style);
2853
+ for (const [name, value] of el.attributes) {
2854
+ if (name === "style" && inlineStyle) continue;
2855
+ out += ` ${name}="${escapeAttr(value)}"`;
2856
+ }
2857
+ if (inlineStyle) {
2858
+ const attrStyle = el.attributes.get("style");
2859
+ const merged = attrStyle ? `${attrStyle.replace(/;\s*$/, "")}; ${inlineStyle}` : inlineStyle;
2860
+ out += ` style="${escapeAttr(merged)}"`;
2861
+ }
2862
+ return out;
2863
+ }
2864
+ function serializeNode(node) {
2865
+ if (node == null || node === false || node === true) return "";
2866
+ if (typeof node === "string") return escapeText(node);
2867
+ if (typeof node === "number") return escapeText(String(node));
2868
+ if (typeof node === "function") return serializeNode(node());
2869
+ if (Array.isArray(node)) return node.map(serializeNode).join("");
2870
+ if (typeof node.rawOuterHTML === "string") return node.rawOuterHTML;
2871
+ switch (node.nodeType) {
2872
+ case NODE_TEXT:
2873
+ return escapeText(node.data ?? "");
2874
+ case NODE_COMMENT:
2875
+ return `<!--${node.data ?? ""}-->`;
2876
+ case NODE_ELEMENT: {
2877
+ const tag = node.localName;
2878
+ const open = `<${tag}${serializeAttrs(node)}>`;
2879
+ if (VOID_ELEMENTS3.has(tag)) return open;
2880
+ const inner = node.rawHTML != null ? node.rawHTML : (node.childNodes ?? []).map(serializeNode).join("");
2881
+ return `${open}${inner}</${tag}>`;
2882
+ }
2883
+ }
2884
+ if (Array.isArray(node.childNodes)) return node.childNodes.map(serializeNode).join("");
2885
+ return "";
2886
+ }
2887
+
2888
+ // src/lib/dom/server/render.ts
2889
+ var import_signal17 = require("@fluixi/reactive/signal");
2890
+ var import_signal18 = require("@fluixi/reactive/signal");
2891
+
2892
+ // src/lib/dom/server/parse-template.ts
2893
+ var VOID_ELEMENTS4 = /* @__PURE__ */ new Set([
2894
+ "area",
2895
+ "base",
2896
+ "br",
2897
+ "col",
2898
+ "embed",
2899
+ "hr",
2900
+ "img",
2901
+ "input",
2902
+ "link",
2903
+ "meta",
2904
+ "param",
2905
+ "source",
2906
+ "track",
2907
+ "wbr"
2908
+ ]);
2909
+ var ENTITIES = {
2910
+ amp: "&",
2911
+ lt: "<",
2912
+ gt: ">",
2913
+ quot: '"',
2914
+ "#39": "'"
2915
+ };
2916
+ function unescape(text) {
2917
+ return text.replace(/&(#?\w+);/g, (whole, name) => ENTITIES[name] ?? whole);
2918
+ }
2919
+ var TemplateParseError = class extends Error {
2920
+ };
2921
+ function parseTemplate(html2, isSVG = false) {
2922
+ let i = 0;
2923
+ const roots = [];
2924
+ const stack = [];
2925
+ const append = (node) => {
2926
+ const parent = stack[stack.length - 1];
2927
+ if (parent) parent.appendChild(node);
2928
+ else roots.push(node);
2929
+ };
2930
+ while (i < html2.length) {
2931
+ const lt = html2.indexOf("<", i);
2932
+ if (lt === -1) {
2933
+ addText(html2.slice(i));
2934
+ break;
2935
+ }
2936
+ if (lt > i) addText(html2.slice(i, lt));
2937
+ if (html2.startsWith("<!--", lt)) {
2938
+ const end = html2.indexOf("-->", lt);
2939
+ if (end === -1) throw new TemplateParseError(`unterminated comment at ${lt}`);
2940
+ append(new ServerComment(html2.slice(lt + 4, end)));
2941
+ i = end + 3;
2942
+ continue;
2943
+ }
2944
+ if (html2[lt + 1] === "/") {
2945
+ const end = html2.indexOf(">", lt);
2946
+ if (end === -1) throw new TemplateParseError(`unterminated closing tag at ${lt}`);
2947
+ const tag = html2.slice(lt + 2, end).trim().toLowerCase();
2948
+ const open = stack.pop();
2949
+ if (!open || open.localName !== tag) {
2950
+ throw new TemplateParseError(
2951
+ `</${tag}> does not close <${open?.localName ?? "nothing"}>`
2952
+ );
2953
+ }
2954
+ i = end + 1;
2955
+ continue;
2956
+ }
2957
+ i = openTag(lt);
2958
+ }
2959
+ if (stack.length > 0) {
2960
+ throw new TemplateParseError(`unclosed <${stack[stack.length - 1].localName}>`);
2961
+ }
2962
+ const root = roots[0];
2963
+ if (roots.length !== 1 || !(root instanceof ServerElement)) {
2964
+ throw new TemplateParseError(`expected exactly one root element, got ${roots.length}`);
2965
+ }
2966
+ return root;
2967
+ function addText(raw) {
2968
+ if (raw === "") return;
2969
+ append(new ServerText(unescape(raw)));
2970
+ }
2971
+ function openTag(lt) {
2972
+ const nameEnd = /[\s/>]/.exec(html2.slice(lt + 1));
2973
+ if (!nameEnd) throw new TemplateParseError(`unterminated tag at ${lt}`);
2974
+ const tag = html2.slice(lt + 1, lt + 1 + nameEnd.index).toLowerCase();
2975
+ const el = new ServerElement(tag, isSVG);
2976
+ let j = lt + 1 + nameEnd.index;
2977
+ while (j < html2.length) {
2978
+ while (j < html2.length && /\s/.test(html2[j])) j++;
2979
+ if (html2[j] === ">") {
2980
+ j++;
2981
+ break;
2982
+ }
2983
+ if (html2[j] === "/" && html2[j + 1] === ">") {
2984
+ j += 2;
2985
+ break;
2986
+ }
2987
+ const attrStart = j;
2988
+ while (j < html2.length && !/[\s=/>]/.test(html2[j])) j++;
2989
+ const name = html2.slice(attrStart, j);
2990
+ if (name === "") throw new TemplateParseError(`malformed attribute at ${j}`);
2991
+ if (html2[j] === "=") {
2992
+ if (html2[j + 1] !== '"') {
2993
+ throw new TemplateParseError(`attribute ${name} must have a double-quoted value`);
2994
+ }
2995
+ const close = html2.indexOf('"', j + 2);
2996
+ if (close === -1) throw new TemplateParseError(`unterminated value for ${name}`);
2997
+ el.setAttribute(name, unescape(html2.slice(j + 2, close)));
2998
+ j = close + 1;
2999
+ } else {
3000
+ el.setAttribute(name, "");
3001
+ }
3002
+ }
3003
+ append(el);
3004
+ if (!VOID_ELEMENTS4.has(tag)) stack.push(el);
3005
+ return j;
3006
+ }
3007
+ }
3008
+
3009
+ // src/lib/dom/server/render.ts
3010
+ var _nodesRegistered = false;
3011
+ function ensureServerNodes() {
3012
+ if (_nodesRegistered) return;
3013
+ _nodesRegistered = true;
3014
+ registerServerNodes({
3015
+ createElement: (tag, isSVG) => new ServerElement(tag, isSVG),
3016
+ createText: (value) => new ServerText(value),
3017
+ createRaw: (html2) => new ServerRaw(html2),
3018
+ parseTemplate: (html2, isSVG) => parseTemplate(html2, isSVG),
3019
+ createComment: (value) => new ServerComment(value)
3020
+ });
3021
+ }
3022
+ function renderToString(app, options = {}) {
3023
+ const prev = isServer();
3024
+ ensureServerNodes();
3025
+ setServerMode(true);
3026
+ const ctx = createRequestContext(options.event);
3027
+ try {
3028
+ return runWithRequestContext(
3029
+ ctx,
3030
+ () => (0, import_signal17.createRoot)((dispose) => {
3031
+ try {
3032
+ const tree = typeof app === "function" ? app() : app;
3033
+ return serializeNode(tree);
3034
+ } finally {
3035
+ dispose();
3036
+ }
3037
+ })
3038
+ );
3039
+ } finally {
3040
+ setServerMode(prev);
3041
+ }
3042
+ }
3043
+ var _hooksInstalled = false;
3044
+ function ensureResourceHooks() {
3045
+ if (_hooksInstalled) return;
3046
+ _hooksInstalled = true;
3047
+ (0, import_signal18.setResourceTracker)((p) => {
3048
+ getRequestContext()?.pending.add(p);
3049
+ });
3050
+ (0, import_signal18.setResourceIdSource)(() => getRequestContext()?.nextResourceId() ?? "");
3051
+ (0, import_signal18.setResourceDataSink)((id, value) => {
3052
+ if (id) getRequestContext()?.data.set(id, value);
3053
+ });
3054
+ }
3055
+ var _redactor = null;
3056
+ function setDataRedactor(fn) {
3057
+ _redactor = fn;
3058
+ }
3059
+ function serializeResourceData(ctx) {
3060
+ if (ctx.data.size === 0) return "";
3061
+ const obj = {};
3062
+ for (const [k, v] of ctx.data) {
3063
+ let out = v;
3064
+ if (_redactor) {
3065
+ try {
3066
+ out = _redactor(v, k);
3067
+ } catch {
3068
+ continue;
3069
+ }
3070
+ }
3071
+ if (out === void 0) continue;
3072
+ if (typeof out === "function" || typeof out === "symbol") continue;
3073
+ obj[k] = out;
3074
+ }
3075
+ if (Object.keys(obj).length === 0) return "";
3076
+ const json = escapeFxJson(JSON.stringify(obj));
3077
+ if (json === "{}") return "";
3078
+ return `<script type="application/json" id="${FX_DATA_ID}">${json}<\/script>`;
3079
+ }
3080
+ var MAX_ASYNC_ROUNDS = 50;
3081
+ async function renderToStringAsync(app, options = {}) {
3082
+ const prev = isServer();
3083
+ ensureServerNodes();
3084
+ setServerMode(true);
3085
+ ensureResourceHooks();
3086
+ const ctx = createRequestContext(options.event);
3087
+ try {
3088
+ return await runWithRequestContext(ctx, async () => {
3089
+ if (options.preload) await options.preload(options.event);
3090
+ let tree;
3091
+ let rootOwner = null;
3092
+ let dispose = () => {
3093
+ };
3094
+ (0, import_signal17.createRoot)((d) => {
3095
+ dispose = d;
3096
+ rootOwner = (0, import_signal18.getOwner)();
3097
+ tree = typeof app === "function" ? app() : app;
3098
+ });
3099
+ const probe = () => {
3100
+ try {
3101
+ (0, import_signal18.runWithOwner)(rootOwner, () => serializeNode(tree));
3102
+ } catch {
3103
+ }
3104
+ };
3105
+ probe();
3106
+ let rounds = 0;
3107
+ while (ctx.pending.size > 0 && rounds++ < MAX_ASYNC_ROUNDS) {
3108
+ const batch3 = Array.from(ctx.pending);
3109
+ ctx.pending.clear();
3110
+ await Promise.allSettled(batch3);
3111
+ await (0, import_signal18.flush)();
3112
+ probe();
3113
+ }
3114
+ const html2 = (0, import_signal18.runWithOwner)(rootOwner, () => serializeNode(tree)) + serializeResourceData(ctx);
3115
+ dispose();
3116
+ return html2;
3117
+ });
3118
+ } finally {
3119
+ setServerMode(prev);
3120
+ }
3121
+ }
3122
+
3123
+ // src/cdn/dom.ts
3124
+ var import_signal19 = require("@fluixi/reactive/signal");
3125
+ var import_store = require("@fluixi/reactive/store");
3126
+ var import_signal20 = require("@fluixi/reactive/signal");
3127
+ var import_store2 = require("@fluixi/reactive/store");