@fluixi/dom 1.0.0-alpha.82 → 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 (183) 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 +3 -3
  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.d.ts.map +1 -1
  40. package/dist/lib/dom/integration.js +15 -6
  41. package/dist/lib/dom/integration.mjs +51 -1
  42. package/dist/lib/dom/island.cjs +790 -1
  43. package/dist/lib/dom/island.d.ts +1 -1
  44. package/dist/lib/dom/island.js +12 -12
  45. package/dist/lib/dom/island.mjs +769 -1
  46. package/dist/lib/dom/runtime.cjs +1432 -1
  47. package/dist/lib/dom/runtime.d.ts +71 -19
  48. package/dist/lib/dom/runtime.d.ts.map +1 -1
  49. package/dist/lib/dom/runtime.js +261 -100
  50. package/dist/lib/dom/runtime.mjs +1414 -1
  51. package/dist/lib/dom/server/fx-data.cjs +53 -1
  52. package/dist/lib/dom/server/fx-data.d.ts +5 -5
  53. package/dist/lib/dom/server/fx-data.js +6 -6
  54. package/dist/lib/dom/server/fx-data.mjs +32 -1
  55. package/dist/lib/dom/server/host.cjs +66 -1
  56. package/dist/lib/dom/server/host.d.ts +14 -2
  57. package/dist/lib/dom/server/host.d.ts.map +1 -1
  58. package/dist/lib/dom/server/host.js +38 -10
  59. package/dist/lib/dom/server/host.mjs +45 -1
  60. package/dist/lib/dom/server/index.cjs +759 -1
  61. package/dist/lib/dom/server/index.d.ts +1 -1
  62. package/dist/lib/dom/server/index.js +1 -1
  63. package/dist/lib/dom/server/index.mjs +743 -1
  64. package/dist/lib/dom/server/nodes.cjs +302 -1
  65. package/dist/lib/dom/server/nodes.d.ts +2 -2
  66. package/dist/lib/dom/server/nodes.d.ts.map +1 -1
  67. package/dist/lib/dom/server/nodes.js +4 -4
  68. package/dist/lib/dom/server/nodes.mjs +279 -1
  69. package/dist/lib/dom/server/parse-template.cjs +395 -1
  70. package/dist/lib/dom/server/parse-template.d.ts +1 -1
  71. package/dist/lib/dom/server/parse-template.js +4 -4
  72. package/dist/lib/dom/server/parse-template.mjs +372 -1
  73. package/dist/lib/dom/server/render.cjs +691 -1
  74. package/dist/lib/dom/server/render.d.ts +9 -1
  75. package/dist/lib/dom/server/render.d.ts.map +1 -1
  76. package/dist/lib/dom/server/render.js +25 -17
  77. package/dist/lib/dom/server/render.mjs +677 -1
  78. package/dist/lib/dom/server/request-context.cjs +110 -1
  79. package/dist/lib/dom/server/request-context.d.ts +29 -9
  80. package/dist/lib/dom/server/request-context.d.ts.map +1 -1
  81. package/dist/lib/dom/server/request-context.js +28 -8
  82. package/dist/lib/dom/server/request-context.mjs +89 -1
  83. package/dist/lib/dom/server/serialize.cjs +187 -1
  84. package/dist/lib/dom/server/serialize.js +3 -3
  85. package/dist/lib/dom/server/serialize.mjs +164 -1
  86. package/dist/lib/dom/server-renderer.cjs +760 -1
  87. package/dist/lib/dom/server-renderer.js +1 -1
  88. package/dist/lib/dom/server-renderer.mjs +745 -1
  89. package/dist/lib/dom/types.cjs +18 -1
  90. package/dist/lib/dom/utils.cjs +381 -1
  91. package/dist/lib/dom/utils.d.ts +1 -88
  92. package/dist/lib/dom/utils.d.ts.map +1 -1
  93. package/dist/lib/dom/utils.js +2 -99
  94. package/dist/lib/dom/utils.mjs +361 -1
  95. package/dist/lib/dom/versions.cjs +60 -1
  96. package/dist/lib/dom/versions.d.ts +3 -3
  97. package/dist/lib/dom/versions.d.ts.map +1 -1
  98. package/dist/lib/dom/versions.js +17 -5
  99. package/dist/lib/dom/versions.mjs +37 -1
  100. package/dist/lib/element/attributes.cjs +19 -1
  101. package/dist/lib/element/attributes.d.ts +7 -7
  102. package/dist/lib/element/attributes.js +1 -1
  103. package/dist/lib/element/attributes.mjs +1 -0
  104. package/dist/lib/element/index.cjs +19 -1
  105. package/dist/lib/element/index.mjs +1 -0
  106. package/dist/lib/element/types.cjs +18 -1
  107. package/dist/lib/element/types.d.ts +4 -5
  108. package/dist/lib/element/types.d.ts.map +1 -1
  109. package/dist/lib/element/types.js +0 -1
  110. package/dist/lib/flow/class-map.cjs +38 -1
  111. package/dist/lib/flow/class-map.d.ts +3 -3
  112. package/dist/lib/flow/class-map.js +3 -3
  113. package/dist/lib/flow/class-map.mjs +17 -1
  114. package/dist/lib/flow/client-only.cjs +57 -1
  115. package/dist/lib/flow/client-only.d.ts +4 -4
  116. package/dist/lib/flow/client-only.js +4 -4
  117. package/dist/lib/flow/client-only.mjs +36 -1
  118. package/dist/lib/flow/dynamic.cjs +53 -1
  119. package/dist/lib/flow/dynamic.d.ts +2 -2
  120. package/dist/lib/flow/dynamic.js +4 -4
  121. package/dist/lib/flow/dynamic.mjs +32 -1
  122. package/dist/lib/flow/error-boundary.cjs +43 -1
  123. package/dist/lib/flow/error-boundary.d.ts +2 -2
  124. package/dist/lib/flow/error-boundary.js +4 -4
  125. package/dist/lib/flow/error-boundary.mjs +22 -1
  126. package/dist/lib/flow/for.cjs +66 -1
  127. package/dist/lib/flow/for.d.ts +9 -9
  128. package/dist/lib/flow/for.d.ts.map +1 -1
  129. package/dist/lib/flow/for.js +2 -2
  130. package/dist/lib/flow/for.mjs +45 -1
  131. package/dist/lib/flow/index-flow.cjs +67 -1
  132. package/dist/lib/flow/index-flow.d.ts +5 -5
  133. package/dist/lib/flow/index-flow.js +4 -4
  134. package/dist/lib/flow/index-flow.mjs +46 -1
  135. package/dist/lib/flow/index.cjs +805 -1
  136. package/dist/lib/flow/index.mjs +792 -1
  137. package/dist/lib/flow/portal.cjs +538 -1
  138. package/dist/lib/flow/portal.mjs +519 -1
  139. package/dist/lib/flow/show.cjs +81 -1
  140. package/dist/lib/flow/show.d.ts +1 -1
  141. package/dist/lib/flow/show.d.ts.map +1 -1
  142. package/dist/lib/flow/show.js +12 -118
  143. package/dist/lib/flow/show.mjs +67 -1
  144. package/dist/lib/flow/style-map.cjs +43 -1
  145. package/dist/lib/flow/style-map.d.ts +3 -3
  146. package/dist/lib/flow/style-map.js +4 -4
  147. package/dist/lib/flow/style-map.mjs +22 -1
  148. package/dist/lib/flow/switch.cjs +91 -1
  149. package/dist/lib/flow/switch.d.ts +3 -3
  150. package/dist/lib/flow/switch.d.ts.map +1 -1
  151. package/dist/lib/flow/switch.js +7 -7
  152. package/dist/lib/flow/switch.mjs +70 -1
  153. package/dist/lib/flow/utils.cjs +44 -1
  154. package/dist/lib/flow/utils.d.ts +1 -1
  155. package/dist/lib/flow/utils.js +1 -1
  156. package/dist/lib/flow/utils.mjs +23 -1
  157. package/dist/lib/html.cjs +32 -1
  158. package/dist/lib/html.d.ts +6 -6
  159. package/dist/lib/html.js +5 -5
  160. package/dist/lib/html.mjs +11 -1
  161. package/dist/lib/index.cjs +3104 -1
  162. package/dist/lib/index.d.ts +0 -1
  163. package/dist/lib/index.d.ts.map +1 -1
  164. package/dist/lib/index.js +2 -3
  165. package/dist/lib/index.mjs +3097 -1
  166. package/dist/lib/shared/types.cjs +18 -1
  167. package/dist/lib/shared/types.d.ts +8 -8
  168. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  169. package/dist/version.generated.cjs +26 -1
  170. package/dist/version.generated.d.ts +1 -1
  171. package/dist/version.generated.js +2 -2
  172. package/dist/version.generated.mjs +5 -1
  173. package/package.json +7 -6
  174. package/dist/lib/jsx/control-flow/flow.cjs +0 -1
  175. package/dist/lib/jsx/control-flow/flow.d.ts +0 -2
  176. package/dist/lib/jsx/control-flow/flow.d.ts.map +0 -1
  177. package/dist/lib/jsx/control-flow/flow.js +0 -627
  178. package/dist/lib/jsx/control-flow/flow.mjs +0 -0
  179. package/dist/lib/jsx/control-flow/for-flow.cjs +0 -1
  180. package/dist/lib/jsx/control-flow/for-flow.d.ts +0 -2
  181. package/dist/lib/jsx/control-flow/for-flow.d.ts.map +0 -1
  182. package/dist/lib/jsx/control-flow/for-flow.js +0 -1
  183. package/dist/lib/jsx/control-flow/for-flow.mjs +0 -0
@@ -1 +1,1430 @@
1
- var G="http://www.w3.org/2000/svg";var D=new Set(["className","value","checked","selected","innerHTML","innerText","textContent","indeterminate","htmlFor"]);function T(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 Le(e,t){Object.assign(e.style,t)}function Oe(e,t={},...n){let r=document.createElement(e);return Object.entries(t).forEach(([s,a])=>{if(s==="class"||s==="className")r.className=a;else if(s==="style"&&typeof a=="object")Le(r,a);else if(s.startsWith("on")&&typeof a=="function"){let c=s.slice(2).toLowerCase();r.addEventListener(c,a)}else T(r,s,a)}),n.forEach(s=>{typeof s=="string"?r.appendChild(document.createTextNode(s)):r.appendChild(s)}),r}var Ot=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;import{isSignal as h}from"@fluixi/reactive/signal";var X="1.0.0-alpha.82";import{VERSION as _e}from"@fluixi/reactive/version";var m={dom:X,reactive:_e};function J(e){m.core&&e.setAttribute("fluixi",m.core),e.setAttribute("fx-dom",m.dom),e.setAttribute("fx-reactive",m.reactive),typeof globalThis<"u"&&(globalThis.Fluixi=m)}function Y(){let e=[m.core,m.dom,m.reactive].filter(t=>t!==void 0);new Set(e).size<=1||console.warn(`[fluixi] package versions disagree — core ${m.core??"(absent)"}, dom ${m.dom}, reactive ${m.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 Z(e){return typeof e!="function"||Object.defineProperty(e,Symbol.for("fluixi-component"),{value:!0,enumerable:!0}),e}function N(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}import{batch as Fe,createEffect as Xt,createRenderEffect as g,createRoot as De,onCleanup as $e,readChildren as Jt}from"@fluixi/reactive/signal";var $=typeof document>"u";var I=Symbol.for("fluixi.server-node"),Q=null;function ee(){if(!Q)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return Q}function C(e){return e!=null&&e[I]===!0?!0:typeof Node<"u"&&e instanceof Node}function te(e){return e!=null&&e[I]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function ne(e){return e!=null&&e[I]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var u={active:!1,cursor:null,parents:[]},re=null;function oe(e){re=e}function ie(){return re}function j(e,t){return u.active&&t.parentNode===e}function H(e){let t=u.parents.lastIndexOf(e);t!==-1&&(u.parents.length=t),u.cursor=e.nextSibling}function P(e){if(!u.active||e==null)return;let t=Array.isArray(e)?e[e.length-1]:e;t&&typeof t.nodeType=="number"&&H(t)}var Ie={};var V=new Set,fe=new Set(["scroll","focus","blur","load","error","resize","mouseenter","mouseleave","pointerenter","pointerleave","gotpointercapture","lostpointercapture"]);function ue(e){if(!$)for(let t of e)V.has(t)||fe.has(t)||(V.add(t),document.addEventListener(t,je))}function je(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 He(e,t,n){if(e[`$$${t}`]=n,fe.has(t)){let r=`__fx_${t}`;if(!e[r]){let s=a=>{e[`$$${t}`]?.(a)};e.addEventListener(t,s),e[r]=s}return}V.has(t)||ue([t])}function se(e,t){delete e[`$$${t}`];let n=`__fx_${t}`,r=e[n];r&&(e.removeEventListener(t,r),delete e[n])}function E(e,t=!1){if($)return ee().createText(e);if(u.active&&!t){let n=ie()?.hydrateText(e);if(n)return n}return document.createTextNode(e)}var b=0,Ve=200;function Ue(e,t,n,r,s){let a=r,c=new Map;return g(()=>{let i;if(N(e)&&!h(e)){if(!c.has(e)){b++;try{let o=e();c.set(e,o)}finally{b--}}for(i=c.get(e);typeof i=="function"&&h(i);)i=i()}else for(i=e();typeof i=="function"&&h(i);)i=i();{let o=0;for(;typeof i=="function"&&o++<50;)if(N(i)){if(!c.has(i)){let l=i;b++;try{let f=l();c.set(l,f)}finally{b--}}i=c.get(i)}else if(h(i))i=i();else if(i=i(),typeof i!="function"||!h(i)&&!N(i))break}b++;try{a=R(t,i,n,a,c),s(a)}finally{b--}})}function v(e,t,n,r){if(b>Ve)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;n!==void 0&&!n&&(n=E("",!0),e.appendChild(n));let s=r??null,a=o=>Array.isArray(o)&&o.some(l=>typeof l=="function"),c=o=>typeof o=="function"?o:()=>o;if(typeof t!="function"&&!a(t)){b++;try{s=R(e,t,n,s)}finally{b--}return()=>s}let i=Ue(c(t),e,n,s,o=>{s=o});return()=>(i?.(),s)}function R(e,t,n,r,s){if(t==null||typeof t=="boolean")return A(e,r,n);if(typeof t=="function")for(;typeof t=="function";)t=t();if(t==null||typeof t=="boolean")return A(e,r,n);if(M(t)){let c=E("",!0);return Array.isArray(r)?r.length>0?(e.replaceChild(c,r[0]),A(e,r.slice(1),n)):y(e,c,n):r?e.replaceChild(c,r):y(e,c,n),t.then(i=>{c.parentNode===e&&R(e,i,c.nextSibling,c)}).catch(i=>{console.error("Error resolving promise in insertExpression:",i)}),c}let a=typeof t;if(a==="string"||a==="number"){if(a==="number"&&(t=String(t)),Array.isArray(r)){if(r.length===0){let i=E(t);return y(e,i,n),i}if(r.length===1&&r[0].nodeType===3)return r[0].data=t,r;r=A(e,r,n)}if(r&&ne(r))return r.data=t,r;let c=E(t);return r&&r.parentNode===e?e.replaceChild(c,r):j(e,c)||y(e,c,n),c}if(C(t))return j(e,t)?(H(t),t):Array.isArray(r)?(r.length===0?y(e,t,n):r[0].parentNode===e?(e.replaceChild(t,r[0]),A(e,r.slice(1),n)):y(e,t,n),t):(r?r!==t&&(r.parentNode===e?e.replaceChild(t,r):y(e,t,n)):y(e,t,n),t);if(Array.isArray(t)){let c=[],i=Array.isArray(r)?r:r?[r]:[],o=[];x(t,c,e,n,!0,s,o);let l=We(e,i,c,n);for(let f of o){let d=v(e,f.sig,f.marker);$e(()=>{A(e,d()),f.marker.parentNode===e&&e.removeChild(f.marker)})}return l}if(a==="object"&&t!==null&&typeof t=="object"){let c=t;if("type"in c&&"props"in c){let i=c;if(typeof i.type=="function"){let o=i.type(i.props||{});return R(e,o,n,r)}}}return A(e,r,n)}function x(e,t,n,r,s=!0,a,c){for(let i=0;i<e.length;i++){let o=e[i];if(!(o==null||typeof o=="boolean")){for(;typeof o=="function"&&!M(o)&&!h(o)&&!N(o)&&(o=o(),!(o==null||typeof o=="boolean")););if(!(o==null||typeof o=="boolean")){if(typeof o=="function"){let l;for(N(o)&&!h(o)?(a||(a=new Map),a.has(o)||a.set(o,o()),l=a.get(o)):l=o();typeof l=="function"&&!M(l)&&!h(l)&&!N(l);)a||(a=new Map),a.has(l)||a.set(l,l()),l=a.get(l);if(l==null||typeof l=="boolean")continue;if(typeof l=="function"){if(h(l)){if(c){let d=E("",!0);t.push(d),c.push({marker:d,sig:l});continue}let f=l();for(;typeof f=="function"&&h(f);)f=f();if(f==null||typeof f=="boolean")continue;Array.isArray(f)?x(f,t,n,r,s,a):x([f],t,n,r,s,a);continue}continue}Array.isArray(l)?x(l,t,n,r,s,a,c):x([l],t,n,r,s,a,c);continue}if(M(o)){let l=E("",!0);t.push(l),o.then(f=>{if(l.parentNode){let d=[];if(x([f],d,l.parentNode,void 0,!1,a),d.length>0){l.parentNode.replaceChild(d[0],l);for(let p=1;p<d.length;p++)l.parentNode?.insertBefore(d[p],d[p-1].nextSibling)}}}).catch(f=>console.error("Error resolving promise in array:",f));continue}if(Array.isArray(o)){x(o,t,n,r,s,a,c);continue}if(C(o)){t.push(o);continue}if(typeof o=="object"&&o!==null&&"type"in o&&"props"in o){let l=o;if(typeof l.type=="function"){let f=l.type(l.props||{});Array.isArray(f)?x(f,t,n,r,!1,a):x([f],t,n,r,!1,a);continue}}if(typeof o=="string"||typeof o=="number"){let l=String(o);if(l.trim()===""&&l!==" ")continue;t.push(E(l));continue}t.push(E(String(o)))}}}}function We(e,t,n,r){for(let d=0;d<n.length;d++){let p=n[d].parentNode;p!==null&&p!==e&&p.nodeType!==11&&(n=n.slice(),n[d]=n[d].cloneNode(!0))}let s=n.length,a=t.length,c=s,i=0,o=0,l=a>0?t[a-1].nextSibling??void 0:r,f=null;for(;i<a||o<c;){if(t[i]===n[o]){i++,o++;continue}for(;a>i&&c>o&&t[a-1]===n[c-1];)a--,c--;if(a===i){let d=c<s?o?n[o-1].nextSibling??void 0:n[c-o]:l;for(;o<c;)y(e,n[o++],d)}else if(c===o)for(;i<a;)(!f||!f.has(t[i]))&&t[i].parentNode===e&&e.removeChild(t[i]),i++;else if(t[i]===n[c-1]&&n[o]===t[a-1]){let d=t[--a].nextSibling;y(e,n[o++],t[i++].nextSibling),y(e,n[--c],d),t[a]=t[i-1]}else{if(!f){f=new Map;let p=o;for(;p<c;)f.set(n[p],p++)}let d=f.get(t[i]);if(d!=null)if(o<d&&d<c){let p=i,F=1;for(;++p<a&&p<c&&!(!f.has(t[p])||f.get(t[p])!==d+F);)F++;if(F>d-o){let ke=t[i];for(;o<d;)y(e,n[o++],ke)}else t[i].parentNode===e?e.replaceChild(n[o++],t[i++]):(y(e,n[o++],l),i++)}else i++;else t[i].parentNode===e&&e.removeChild(t[i]),i++}}return n}function A(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 y(e,t,n){u.active&&t.parentNode===e||(n&&n.parentNode===e?e.insertBefore(t,n):e.appendChild(t))}function S(e,t,n){n==null?delete e[t]:e[t]=n}function Ke(e,t,n){let r=n,s;return Array.isArray(n)&&(r=n[0],s=n[1]),typeof r!="function"?()=>{}:(e.addEventListener(t,r,s),()=>e.removeEventListener(t,r,s))}function Be(e,t){let n=(r,s)=>{typeof r=="function"&&r(e,s??(()=>{}))};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 ae(e,t,n,r=!1){return typeof n!="function"?(T(e,t,n,r),()=>{}):g(()=>{let s=typeof n=="function"?n():n;T(e,t,s,r)})}function ce(e,t,n){return typeof n!="function"?(S(e,t,n),()=>{}):g(()=>{let r=typeof n=="function"?n():n;S(e,t,r)})}function ze(e,t,n){return typeof n!="function"?(T(e,t,!!n),()=>{}):g(()=>{let r=n();T(e,t,!!r)})}function k(e,t){if(t==null){e.removeAttribute("class");return}if(typeof t=="function"){g(()=>k(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 s=t[r];return typeof s=="function"?s():!!s}).join(" ");e.setAttribute("class",n);return}e.setAttribute("class",String(t))}function le(e,t,n){if(!(!t||typeof t!="object"))for(let r in t){let s=t[r],a=r.split(/\s+/).filter(Boolean);if(typeof s=="function"&&n)n.push(g(()=>{let c=!!s();for(let i of a)e.classList.toggle(i,c)}));else{let c=!!(typeof s=="function"?s():s);for(let i of a)e.classList.toggle(i,c)}}}function U(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 s=n[r];s==null?e.style[r]="":e.style[r]=s}}function qe(e){let{element:t,props:n,prevProps:r=Ie,isSVG:s=!1,skipChildren:a=!1}=e;if(!t||!te(t))return console.error("[spread] Error: element is not a DOM Element!"),()=>{};if(!n)return console.warn("[spread] Warning: props is undefined!"),()=>{};let c=s||t.namespaceURI===G,i=[];for(let o in n){if(a&&o==="children")continue;let l=n[o],f=r[o];if(l===f)continue;if(o==="ref"){W(l,t);continue}if(o==="use"){Be(t,l);continue}if(o.startsWith("on:")){i.push(Ke(t,o.slice(3),l));continue}if(o.startsWith("prop:")){i.push(ce(t,o.slice(5),l));continue}if(o.startsWith("attr:")){i.push(ae(t,o.slice(5),l,c));continue}if(o.startsWith("bool:")){i.push(ze(t,o.slice(5),l));continue}if(o==="class"||o==="className"){typeof l=="function"?i.push(g(()=>k(t,l()))):k(t,l);continue}if(o==="classList"){typeof l=="function"?i.push(g(()=>le(t,l()))):le(t,l,i);continue}if(o==="style"){typeof l=="function"?i.push(g(()=>U(t,l()))):U(t,l);continue}if(o.startsWith("on")){let p=o.slice(2).toLowerCase();f&&se(t,p),l&&He(t,p,l);continue}let d=D.has(o)||!c&&o in t;typeof l=="function"?i.push(d?ce(t,o,l):ae(t,o,l,c)):i.push(g(()=>d?S(t,o,n[o]):T(t,o,n[o],c)))}for(let o in r)if(!(o in n))if(o.startsWith("on")){let l=o.slice(2).toLowerCase();se(t,l)}else D.has(o)?S(t,o,null):t.removeAttribute(o);return()=>{i.forEach(o=>o())}}function W(e,t){if(e){if(C(e)){let n=t,r=e;if(!n)return;typeof n=="function"?n(r):typeof n=="object"&&"current"in n&&(n.current=r);return}typeof e=="function"?e(t):typeof e=="object"&&"current"in e&&(e.current=t)}}function M(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function K(e,t,n){if(!t)throw new Error("Container element is required");let r,s,a=[];return De(c=>{Fe(()=>{u.active||(t.textContent=""),J(t),Y(),v(t,e)}),s=c}),()=>{s?.(),r?.(),a.forEach(c=>c()),t.textContent=""}}import{untrack as Ge,isSignal as Xe}from"@fluixi/reactive";var Je="__fx_dom_create_component__",de=globalThis[Je]??={fn:null};function Ye(e,t){if(de.fn)return de.fn(e,t);let n=typeof e=="function"?Ge(()=>e(t)):e;if(n!=null&&(typeof n=="function"||typeof n=="object")&&!Xe(n)){try{n.$name=e?.name}catch{}return Z(n)}return n}import{setResourceIdSource as Qe,setServerDataGetter as et}from"@fluixi/reactive/signal";var Ze="__FX_DATA__";var B;function pe(){let e=globalThis.__FX_DATA__;if(e)return e;if(B!==void 0)return B;let t=null;if(typeof document<"u"){let n=document.getElementById(Ze)?.textContent;if(n)try{t=JSON.parse(n)}catch{t=null}}return B=t}function L(){for(;;){for(;u.cursor&&u.cursor.nodeType===3&&u.cursor.data==="";)u.cursor=u.cursor.nextSibling;if(u.cursor!=null||!u.parents.length)return;u.cursor=u.parents.pop().nextSibling}}var tt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),O=typeof process<"u"&&process.env&&!1;function _(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 nt(e){L();let t=u.cursor;return t&&t.nodeType===1&&t.tagName.toLowerCase()===e.toLowerCase()?(tt.has(e.toLowerCase())?u.cursor=t.nextSibling:(u.parents.push(t),u.cursor=t.firstChild),t):(O&&t&&_(`<${e}>`,t),null)}function rt(e){L();let t=u.cursor;return t&&t.nodeType===1&&t.tagName.toLowerCase()===e.toLowerCase()?(u.cursor=t.nextSibling,t):(O&&t&&_(`<${e}> (static)`,t),null)}function ot(e){if(e===""){let n=u.cursor;return n&&n.nodeType===3&&n.data!==""?(u.cursor=n.nextSibling,n.data="",n):null}L();let t=u.cursor;return t&&t.nodeType===3?(u.cursor=t.nextSibling,t.nodeValue!==e&&(t.nodeValue=e),t):(O&&t&&_(`text ${JSON.stringify(e.slice(0,24))}`,t),null)}function it(e){L();let t=u.cursor;return t&&t.nodeType===8&&t.data===e?(u.cursor=t.nextSibling,t):(O&&t&&_(`marker <!--${e.slice(0,24)}-->`,t),null)}var ye=!1;function st(){ye||(ye=!0,oe({hydrateElement:nt,hydrateText:ot,hydrateMarker:it,hydrateStatic:rt}))}function me(e,t,n){st(),u.active=!0,u.cursor=t.firstChild,u.parents=[];let r=pe(),s=n?.resourceNamespace,a=0;Qe(()=>s?`${s}:r${a++}`:`r${a++}`),et(r?c=>c in r?{value:r[c]}:void 0:null);try{return K(e,t)}finally{u.active=!1,u.cursor=null,u.parents=[]}}import{createChildOwner as at,createMemo as z,disposeScope as ct,getOwner as lt,runWithOwner as ft,untrack as be}from"@fluixi/reactive/signal";function he(e){return typeof e=="function"?e:(()=>e)}function w(e){return()=>{let t=e();return typeof t=="function"?t():t}}function ge(e){return e!=null&&e!==!1}function xe(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function Te(e){let t=w(()=>e.when),n=z(t,void 0),r=z(n,void 0),s=lt(),a=null,c=null,i=o=>{o!==c&&(a&&ct(a),a=at(s),c=o)};return z(()=>{let o=r();return i(o?"when":"fallback"),ft(a,()=>{if(o){let l=e.children;return typeof l=="function"&&!xe(l)?typeof n=="function"?be(()=>be(n)?l(n()):e.fallback):l(n):l}return e.fallback});return e.fallback??null},void 0,{name:"show"})}import{mapArray as ut,keyArray as dt}from"@fluixi/reactive/signal";function Ee(e){let t=w(()=>e.each),n=()=>e.fallback??null,r=(s,a)=>{let c=e.children,i=Array.isArray(c)?c.map(o=>typeof o=="function"?o(s,a):o):typeof c=="function"?c(s,a):c;return P(i),i};return e.by?dt(t,e.by,(s,a)=>r(s,a),{fallback:n}):ut(t,(s,a)=>r(s,a),{fallback:n})}import{indexArray as pt}from"@fluixi/reactive/signal";function we(e){let t=w(()=>e.each);return pt(t,(n,r)=>{let s=e.children(n,r);return P(s),s},{fallback:()=>e.fallback??null})}import{mapArray as Rt,keyArray as kt,indexArray as Lt}from"@fluixi/reactive/signal";import{createMemo as yt,createChildOwner as mt,disposeScope as ht,getOwner as gt,runWithOwner as Ne}from"@fluixi/reactive/signal";var q=Symbol("match");function Ae(e){return{[q]:!0,when:w(()=>e.when),get children(){return e.children}}}function Se(e){let t=Array.isArray(e.children)?e.children:[e.children],n=gt(),r=null,s=-1,a=c=>{c!==s&&(r&&ht(r),r=mt(n),s=c)};return yt(()=>{for(let c=0;c<t.length;c+=1){let o=t[c],l=0;for(;typeof o=="function"&&!o[q]&&l++<10;)o=o();if(!o||typeof o!="object"||o[q]!==!0)continue;let f=o.when();if(ge(f))return a(c),Ne(r,()=>typeof o.children=="function"?o.children(f):o.children)}return a(-2),Ne(r,()=>e.fallback??null)})}import{createMemo as xt,createChildOwner as bt,disposeScope as Tt,getOwner as Et,runWithOwner as wt}from"@fluixi/reactive/signal";function ve(e){let t=he(e.component),{component:n,...r}=e,s=Et(),a=null,c;return xt(()=>{let i=t();return i!==c&&(a&&Tt(a),a=bt(s),c=i),i==null?null:typeof i=="string"?{tag:i,props:r}:wt(a,()=>i(r))})}import{createRoot as Nt,onCleanup as At}from"@fluixi/reactive/signal";function Ce(e){let t=()=>e.mount?typeof e.mount=="function"?e.mount():e.mount:document.body,n,r;return Nt(s=>{n=s,r=document.createElement("div"),r.style.display="contents",t().appendChild(r),v(r,e.children)&&W(e.ref,r)}),At(()=>{n(),r.remove()}),null}import{createMemo as St,createSignal as vt}from"@fluixi/reactive/signal";function Pe(e){let[t,n]=vt(null),r=()=>n(null);return St(()=>{let s=t();if(s!==null)return typeof e.fallback=="function"?e.fallback(s,r):e.fallback;try{return typeof e.children=="function"?e.children():e.children}catch(a){return n(a),typeof e.fallback=="function"?e.fallback(a,r):e.fallback}})}import{createMemo as Ct}from"@fluixi/reactive/signal";function Me(e){return Ct(()=>{let t=typeof e=="function"?e():e,n=[];for(let[r,s]of Object.entries(t)){if(!r)continue;(typeof s=="function"?s():s)&&n.push(r)}return n.join(" ")})}import{createMemo as Pt}from"@fluixi/reactive/signal";function Mt(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Re(e){return Pt(()=>{let t=typeof e=="function"?e():e,n=[];for(let[r,s]of Object.entries(t)){if(!r)continue;let a=typeof s=="function"?s():s;a!=null&&n.push(`${Mt(r)}: ${a}`)}return n.join("; ")})}import{signal as mr,memo as hr,effect as gr,store as xr,createSignal as br,createMemo as Tr,createEffect as Er,createComputed as wr,createRenderEffect as Nr,createRoot as Ar,createResource as Sr,createContext as vr,useContext as Cr,onCleanup as Pr,batch as Mr,untrack as Rr}from"@fluixi/reactive";export{ve as Dynamic,Pe as ErrorBoundary,Ee as For,we as Index,Ae as Match,Ce as Portal,Te as Show,Se as Switch,Mr as batch,Me as classMap,Ye as createComponent,wr as createComputed,vr as createContext,Er as createEffect,Oe as createElement,Tr as createMemo,Nr as createRenderEffect,Sr as createResource,Ar as createRoot,br as createSignal,ue as delegateEvents,gr as effect,me as hydrate,Lt as indexArray,v as insert,kt as keyArray,Rt as mapArray,hr as memo,Pr as onCleanup,K as render,T as setAttribute,k as setClassName,S as setProperty,U as setStyle,mr as signal,qe as spread,xr as store,Re as styleMap,Rr as untrack,Cr as useContext};
1
+ // src/lib/dom/utils.ts
2
+ var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
3
+ var JSX_PROPERTIES = /* @__PURE__ */ new Set([
4
+ "className",
5
+ "value",
6
+ "checked",
7
+ "selected",
8
+ "innerHTML",
9
+ "innerText",
10
+ "textContent",
11
+ "indeterminate",
12
+ "htmlFor"
13
+ ]);
14
+ function setAttribute(element, name, value, isSVG = false) {
15
+ if (value == null || value === false) {
16
+ element.removeAttribute(name);
17
+ return;
18
+ }
19
+ if (value === true) {
20
+ element.setAttribute(name, "");
21
+ return;
22
+ }
23
+ if (typeof value === "object") {
24
+ element.setAttribute(name, JSON.stringify(value));
25
+ return;
26
+ }
27
+ element.setAttribute(name, String(value));
28
+ }
29
+ function setStyles(element, styles) {
30
+ Object.assign(element.style, styles);
31
+ }
32
+ function createElement(tagName, attributes = {}, ...children) {
33
+ const element = document.createElement(tagName);
34
+ Object.entries(attributes).forEach(([key, value]) => {
35
+ if (key === "class" || key === "className") {
36
+ element.className = value;
37
+ } else if (key === "style" && typeof value === "object") {
38
+ setStyles(element, value);
39
+ } else if (key.startsWith("on") && typeof value === "function") {
40
+ const event = key.slice(2).toLowerCase();
41
+ element.addEventListener(event, value);
42
+ } else {
43
+ setAttribute(element, key, value);
44
+ }
45
+ });
46
+ children.forEach((child) => {
47
+ if (typeof child === "string") {
48
+ element.appendChild(document.createTextNode(child));
49
+ } else {
50
+ element.appendChild(child);
51
+ }
52
+ });
53
+ return element;
54
+ }
55
+ var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
56
+
57
+ // src/lib/dom/runtime.ts
58
+ import {
59
+ isSignal
60
+ } from "@fluixi/reactive/signal";
61
+
62
+ // src/version.generated.ts
63
+ var VERSION = "1.0.0-alpha.84";
64
+
65
+ // src/lib/dom/versions.ts
66
+ import { VERSION as REACTIVE } from "@fluixi/reactive/version";
67
+ import { joinedVersions } from "@fluixi/reactive/signal";
68
+ var versions = { dom: VERSION, reactive: REACTIVE };
69
+ function stampVersions(container) {
70
+ if (versions.core) container.setAttribute("fluixi", versions.core);
71
+ container.setAttribute("fx-dom", versions.dom);
72
+ container.setAttribute("fx-reactive", versions.reactive);
73
+ if (typeof globalThis !== "undefined") globalThis.Fluixi = versions;
74
+ }
75
+ function warnOnVersionSkew() {
76
+ const builds = joinedVersions();
77
+ if (builds.length > 1) {
78
+ console.warn(
79
+ `[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.`
80
+ );
81
+ }
82
+ const present = [versions.core, versions.dom, versions.reactive].filter(
83
+ (v) => v !== void 0
84
+ );
85
+ if (new Set(present).size <= 1) return;
86
+ console.warn(
87
+ `[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\`.`
88
+ );
89
+ }
90
+
91
+ // src/lib/component/modifiers.ts
92
+ function asComponent(value) {
93
+ if (typeof value !== "function") return value;
94
+ Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-component"), { value: true, enumerable: true });
95
+ return value;
96
+ }
97
+ function isComponent(value) {
98
+ return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-component")] === true;
99
+ }
100
+
101
+ // src/lib/dom/runtime.ts
102
+ import { batch, createEffect, createRenderEffect, createRoot, onCleanup, readChildren, reportReactiveBinding, reportReactiveDirective, untrack } from "@fluixi/reactive/signal";
103
+
104
+ // src/lib/dom/server/host.ts
105
+ var SERVER_NODE = /* @__PURE__ */ Symbol.for("fluixi.server-node");
106
+ var STATE = /* @__PURE__ */ Symbol.for("fluixi.dom.server-host");
107
+ var realm = globalThis;
108
+ var state = realm[STATE] ??= {
109
+ server: typeof document === "undefined",
110
+ nodes: null
111
+ };
112
+ function isServer() {
113
+ return state.server;
114
+ }
115
+ function getServerNodes() {
116
+ if (!state.nodes) {
117
+ throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");
118
+ }
119
+ return state.nodes;
120
+ }
121
+ function isDomNode(x) {
122
+ if (x != null && x[SERVER_NODE] === true) return true;
123
+ return typeof Node !== "undefined" && x instanceof Node;
124
+ }
125
+ function isDomElement(x) {
126
+ if (x != null && x[SERVER_NODE] === true) return x.nodeType === 1;
127
+ return typeof Element !== "undefined" && x instanceof Element;
128
+ }
129
+ function isDomText(x) {
130
+ if (x != null && x[SERVER_NODE] === true) return x.nodeType === 3;
131
+ return typeof Text !== "undefined" && x instanceof Text;
132
+ }
133
+
134
+ // src/lib/dom/hydration-state.ts
135
+ var hydration = {
136
+ active: false,
137
+ cursor: null,
138
+ parents: []
139
+ };
140
+ var _walker = null;
141
+ function registerHydrationWalker(walker) {
142
+ _walker = walker;
143
+ }
144
+ function getHydrationWalker() {
145
+ return _walker;
146
+ }
147
+ function isAdopted(parent, node) {
148
+ return hydration.active && node.parentNode === parent;
149
+ }
150
+ function ascendPast(node) {
151
+ const idx = hydration.parents.lastIndexOf(node);
152
+ if (idx !== -1) hydration.parents.length = idx;
153
+ hydration.cursor = node.nextSibling;
154
+ }
155
+ function hydrateAdvancePast(rendered) {
156
+ if (!hydration.active || rendered == null) return;
157
+ const last = Array.isArray(rendered) ? rendered[rendered.length - 1] : rendered;
158
+ if (last && typeof last.nodeType === "number") {
159
+ ascendPast(last);
160
+ }
161
+ }
162
+
163
+ // src/lib/dom/runtime.ts
164
+ var EMPTY_OBJ = {};
165
+ var HOLE_TAG = "__fx_at";
166
+ var delegatedSet = /* @__PURE__ */ new Set();
167
+ var NON_DELEGATED = /* @__PURE__ */ new Set(["scroll", "focus", "blur", "load", "error", "resize", "mouseenter", "mouseleave", "pointerenter", "pointerleave", "gotpointercapture", "lostpointercapture"]);
168
+ function delegateEvents(eventNames) {
169
+ if (isServer()) return;
170
+ for (const name of eventNames) {
171
+ if (delegatedSet.has(name) || NON_DELEGATED.has(name)) continue;
172
+ delegatedSet.add(name);
173
+ document.addEventListener(name, delegatedEventHandler);
174
+ }
175
+ }
176
+ function delegatedEventHandler(e) {
177
+ const key = `$$${e.type}`;
178
+ let node = e.composedPath && e.composedPath()[0] || e.target;
179
+ while (node) {
180
+ const handler = node[key];
181
+ if (handler && !node.disabled) {
182
+ handler(e);
183
+ if (e.cancelBubble) return;
184
+ }
185
+ node = node.host && node.host !== node && node.host instanceof Element ? node.host : node.parentNode;
186
+ }
187
+ }
188
+ function addDelegatedEventListener(element, name, handler) {
189
+ element[`$$${name}`] = handler;
190
+ if (NON_DELEGATED.has(name)) {
191
+ const key = `__fx_${name}`;
192
+ if (!element[key]) {
193
+ const forwarder = (e) => {
194
+ element[`$$${name}`]?.(e);
195
+ };
196
+ element.addEventListener(name, forwarder);
197
+ element[key] = forwarder;
198
+ }
199
+ return;
200
+ }
201
+ if (!delegatedSet.has(name)) {
202
+ delegateEvents([name]);
203
+ }
204
+ }
205
+ function removeDelegatedEventListener(element, name) {
206
+ delete element[`$$${name}`];
207
+ const key = `__fx_${name}`;
208
+ const forwarder = element[key];
209
+ if (forwarder) {
210
+ element.removeEventListener(name, forwarder);
211
+ delete element[key];
212
+ }
213
+ }
214
+ function createTextNode(value, anchor = false) {
215
+ if (isServer()) return getServerNodes().createText(value);
216
+ if (hydration.active && !anchor) {
217
+ const node = getHydrationWalker()?.hydrateText(value);
218
+ if (node) return node;
219
+ }
220
+ return document.createTextNode(value);
221
+ }
222
+ var _insertDepth = 0;
223
+ var MAX_INSERT_DEPTH = 200;
224
+ function _createInsertEffect(getAccessor, parent, marker, initialCurrent, setCurrent) {
225
+ let current = initialCurrent;
226
+ const componentCache = /* @__PURE__ */ new Map();
227
+ return createRenderEffect(() => {
228
+ reportReactiveBinding(marker ?? parent, "content", void 0, getAccessor);
229
+ let value;
230
+ if (isComponent(getAccessor) && !isSignal(getAccessor)) {
231
+ if (!componentCache.has(getAccessor)) {
232
+ _insertDepth++;
233
+ try {
234
+ const inst = getAccessor();
235
+ componentCache.set(getAccessor, inst);
236
+ } finally {
237
+ _insertDepth--;
238
+ }
239
+ }
240
+ value = componentCache.get(getAccessor);
241
+ while (typeof value === "function" && isSignal(value)) value = value();
242
+ } else {
243
+ value = getAccessor();
244
+ while (typeof value === "function" && isSignal(value)) {
245
+ value = value();
246
+ }
247
+ }
248
+ {
249
+ let chainDepth = 0;
250
+ while (typeof value === "function" && chainDepth++ < 50) {
251
+ if (isComponent(value)) {
252
+ if (!componentCache.has(value)) {
253
+ const thunk = value;
254
+ _insertDepth++;
255
+ try {
256
+ const inst = thunk();
257
+ componentCache.set(thunk, inst);
258
+ } finally {
259
+ _insertDepth--;
260
+ }
261
+ }
262
+ value = componentCache.get(value);
263
+ } else if (isSignal(value)) {
264
+ value = value();
265
+ } else {
266
+ value = value();
267
+ if (typeof value !== "function" || !isSignal(value) && !isComponent(value)) break;
268
+ }
269
+ }
270
+ }
271
+ _insertDepth++;
272
+ try {
273
+ current = insertExpression(parent, value, marker, current, componentCache);
274
+ setCurrent(current);
275
+ } finally {
276
+ _insertDepth--;
277
+ }
278
+ });
279
+ }
280
+ function insert(parent, accessor, marker, init) {
281
+ if (_insertDepth > MAX_INSERT_DEPTH) {
282
+ console.error("[insert] Exceeded max call depth, possible infinite loop.");
283
+ return () => null;
284
+ }
285
+ if (marker !== void 0 && !marker) {
286
+ marker = createTextNode("", true);
287
+ parent.appendChild(marker);
288
+ }
289
+ let current = init ?? null;
290
+ const isReactiveArray = (element) => {
291
+ return Array.isArray(element) && element.some((v) => typeof v === "function");
292
+ };
293
+ const normalizeAccessor3 = (accessor2) => {
294
+ if (typeof accessor2 === "function") return accessor2;
295
+ return () => accessor2;
296
+ };
297
+ if (typeof accessor !== "function" && !isReactiveArray(accessor)) {
298
+ _insertDepth++;
299
+ try {
300
+ current = insertExpression(parent, accessor, marker, current);
301
+ } finally {
302
+ _insertDepth--;
303
+ }
304
+ return () => current;
305
+ }
306
+ const dispose = _createInsertEffect(
307
+ normalizeAccessor3(accessor),
308
+ parent,
309
+ marker,
310
+ current,
311
+ (v) => {
312
+ current = v;
313
+ }
314
+ );
315
+ return () => {
316
+ dispose?.();
317
+ return current;
318
+ };
319
+ }
320
+ function insertExpression(parent, value, marker, current, componentCache) {
321
+ if (value == null || typeof value === "boolean") {
322
+ return cleanChildren(parent, current, marker);
323
+ }
324
+ if (typeof value === "function") {
325
+ while (typeof value === "function") {
326
+ value = value();
327
+ }
328
+ }
329
+ if (value == null || typeof value === "boolean") {
330
+ return cleanChildren(parent, current, marker);
331
+ }
332
+ if (isPromise(value)) {
333
+ const placeholder = createTextNode("", true);
334
+ if (Array.isArray(current)) {
335
+ if (current.length > 0) {
336
+ parent.replaceChild(placeholder, current[0]);
337
+ cleanChildren(parent, current.slice(1), marker);
338
+ } else {
339
+ insertBefore(parent, placeholder, marker);
340
+ }
341
+ } else if (current) {
342
+ parent.replaceChild(placeholder, current);
343
+ } else {
344
+ insertBefore(parent, placeholder, marker);
345
+ }
346
+ value.then((resolved) => {
347
+ if (placeholder.parentNode === parent) {
348
+ insertExpression(parent, resolved, placeholder.nextSibling, placeholder);
349
+ }
350
+ }).catch((err) => {
351
+ console.error("Error resolving promise in insertExpression:", err);
352
+ });
353
+ return placeholder;
354
+ }
355
+ const t = typeof value;
356
+ if (t === "string" || t === "number") {
357
+ if (t === "number") value = String(value);
358
+ if (Array.isArray(current)) {
359
+ if (current.length === 0) {
360
+ const node2 = createTextNode(value);
361
+ insertBefore(parent, node2, marker);
362
+ return node2;
363
+ }
364
+ if (current.length === 1 && current[0].nodeType === 3) {
365
+ current[0].data = value;
366
+ return current;
367
+ }
368
+ current = cleanChildren(parent, current, marker);
369
+ }
370
+ if (current && isDomText(current)) {
371
+ current.data = value;
372
+ return current;
373
+ }
374
+ const node = createTextNode(value);
375
+ if (current && current.parentNode === parent) {
376
+ parent.replaceChild(node, current);
377
+ } else if (!isAdopted(parent, node)) {
378
+ insertBefore(parent, node, marker);
379
+ }
380
+ return node;
381
+ }
382
+ if (isDomNode(value)) {
383
+ if (isAdopted(parent, value)) {
384
+ ascendPast(value);
385
+ return value;
386
+ }
387
+ if (Array.isArray(current)) {
388
+ if (current.length === 0) {
389
+ insertBefore(parent, value, marker);
390
+ } else if (current[0].parentNode === parent) {
391
+ parent.replaceChild(value, current[0]);
392
+ cleanChildren(parent, current.slice(1), marker);
393
+ } else {
394
+ insertBefore(parent, value, marker);
395
+ }
396
+ return value;
397
+ }
398
+ if (!current) {
399
+ insertBefore(parent, value, marker);
400
+ } else if (current !== value) {
401
+ if (current.parentNode === parent) {
402
+ parent.replaceChild(value, current);
403
+ } else {
404
+ insertBefore(parent, value, marker);
405
+ }
406
+ }
407
+ return value;
408
+ }
409
+ if (Array.isArray(value)) {
410
+ const array = [];
411
+ const currentArray = Array.isArray(current) ? current : current ? [current] : [];
412
+ const reactiveSlots = [];
413
+ flattenArray(value, array, parent, marker, true, componentCache, reactiveSlots);
414
+ const reconciled = reconcileArrays(parent, currentArray, array, marker);
415
+ for (const slot of reactiveSlots) {
416
+ const disposeSlot = insert(parent, slot.sig, slot.marker);
417
+ onCleanup(() => {
418
+ cleanChildren(parent, disposeSlot());
419
+ if (slot.marker.parentNode === parent) parent.removeChild(slot.marker);
420
+ });
421
+ }
422
+ return reconciled;
423
+ }
424
+ if (t === "object" && value !== null && typeof value === "object") {
425
+ const objValue = value;
426
+ if ("type" in objValue && "props" in objValue) {
427
+ const jsxValue = objValue;
428
+ if (typeof jsxValue.type === "function") {
429
+ const result = jsxValue.type(jsxValue.props || {});
430
+ return insertExpression(parent, result, marker, current);
431
+ }
432
+ }
433
+ }
434
+ return cleanChildren(parent, current, marker);
435
+ }
436
+ function flattenArray(arr, result, parent, marker, track = true, componentCache, reactiveSlots) {
437
+ for (let i = 0; i < arr.length; i++) {
438
+ let item = arr[i];
439
+ if (item == null || typeof item === "boolean") continue;
440
+ while (typeof item === "function" && !isPromise(item) && !isSignal(item) && !isComponent(item)) {
441
+ item = item();
442
+ if (item == null || typeof item === "boolean") break;
443
+ }
444
+ if (item == null || typeof item === "boolean") continue;
445
+ if (typeof item === "function") {
446
+ let resolved;
447
+ if (isComponent(item) && !isSignal(item)) {
448
+ if (!componentCache) componentCache = /* @__PURE__ */ new Map();
449
+ if (!componentCache.has(item)) componentCache.set(item, item());
450
+ resolved = componentCache.get(item);
451
+ } else {
452
+ resolved = item();
453
+ }
454
+ while (typeof resolved === "function" && !isPromise(resolved) && !isSignal(resolved) && !isComponent(resolved)) {
455
+ if (!componentCache) componentCache = /* @__PURE__ */ new Map();
456
+ if (!componentCache.has(resolved)) componentCache.set(resolved, resolved());
457
+ resolved = componentCache.get(resolved);
458
+ }
459
+ if (resolved == null || typeof resolved === "boolean") continue;
460
+ if (typeof resolved === "function") {
461
+ if (isSignal(resolved)) {
462
+ if (reactiveSlots) {
463
+ const slot = createTextNode("", true);
464
+ result.push(slot);
465
+ reactiveSlots.push({ marker: slot, sig: resolved });
466
+ continue;
467
+ }
468
+ let val = resolved();
469
+ while (typeof val === "function" && isSignal(val)) val = val();
470
+ if (val == null || typeof val === "boolean") continue;
471
+ if (Array.isArray(val)) {
472
+ flattenArray(val, result, parent, marker, track, componentCache);
473
+ } else flattenArray([val], result, parent, marker, track, componentCache);
474
+ continue;
475
+ }
476
+ continue;
477
+ }
478
+ if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, track, componentCache, reactiveSlots);
479
+ else flattenArray([resolved], result, parent, marker, track, componentCache, reactiveSlots);
480
+ continue;
481
+ }
482
+ if (isPromise(item)) {
483
+ const placeholder = createTextNode("", true);
484
+ result.push(placeholder);
485
+ item.then((resolved) => {
486
+ if (placeholder.parentNode) {
487
+ const tempNodes = [];
488
+ flattenArray([resolved], tempNodes, placeholder.parentNode, void 0, false, componentCache);
489
+ if (tempNodes.length > 0) {
490
+ placeholder.parentNode.replaceChild(tempNodes[0], placeholder);
491
+ for (let j = 1; j < tempNodes.length; j++) {
492
+ placeholder.parentNode?.insertBefore(tempNodes[j], tempNodes[j - 1].nextSibling);
493
+ }
494
+ }
495
+ }
496
+ }).catch((err) => console.error("Error resolving promise in array:", err));
497
+ continue;
498
+ }
499
+ if (Array.isArray(item)) {
500
+ flattenArray(item, result, parent, marker, track, componentCache, reactiveSlots);
501
+ continue;
502
+ }
503
+ if (isDomNode(item)) {
504
+ result.push(item);
505
+ continue;
506
+ }
507
+ if (typeof item === "object" && item !== null && "type" in item && "props" in item) {
508
+ const jsxItem = item;
509
+ if (typeof jsxItem.type === "function") {
510
+ const resolved = jsxItem.type(jsxItem.props || {});
511
+ if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, false, componentCache);
512
+ else flattenArray([resolved], result, parent, marker, false, componentCache);
513
+ continue;
514
+ }
515
+ }
516
+ if (typeof item === "string" || typeof item === "number") {
517
+ const str = String(item);
518
+ if (str.trim() === "" && str !== " ") continue;
519
+ result.push(createTextNode(str));
520
+ continue;
521
+ }
522
+ result.push(createTextNode(String(item)));
523
+ }
524
+ }
525
+ function reconcileArrays(parent, a, b, marker) {
526
+ for (let i = 0; i < b.length; i++) {
527
+ const owner = b[i].parentNode;
528
+ if (owner !== null && owner !== parent && owner.nodeType !== 11) {
529
+ b = b.slice();
530
+ b[i] = b[i].cloneNode(true);
531
+ }
532
+ }
533
+ 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;
534
+ while (aStart < aEnd || bStart < bEnd) {
535
+ if (a[aStart] === b[bStart]) {
536
+ aStart++;
537
+ bStart++;
538
+ continue;
539
+ }
540
+ while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
541
+ aEnd--;
542
+ bEnd--;
543
+ }
544
+ if (aEnd === aStart) {
545
+ const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling ?? void 0 : b[bEnd - bStart] : after;
546
+ while (bStart < bEnd) insertBefore(parent, b[bStart++], node);
547
+ } else if (bEnd === bStart) {
548
+ while (aStart < aEnd) {
549
+ if ((!map || !map.has(a[aStart])) && a[aStart].parentNode === parent)
550
+ parent.removeChild(a[aStart]);
551
+ aStart++;
552
+ }
553
+ } else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
554
+ const node = a[--aEnd].nextSibling;
555
+ insertBefore(parent, b[bStart++], a[aStart++].nextSibling);
556
+ insertBefore(parent, b[--bEnd], node);
557
+ a[aEnd] = a[aStart - 1];
558
+ } else {
559
+ if (!map) {
560
+ map = /* @__PURE__ */ new Map();
561
+ let i = bStart;
562
+ while (i < bEnd) map.set(b[i], i++);
563
+ }
564
+ const index = map.get(a[aStart]);
565
+ if (index != null) {
566
+ if (bStart < index && index < bEnd) {
567
+ let i = aStart, sequence = 1;
568
+ while (++i < aEnd && i < bEnd) {
569
+ if (!map.has(a[i]) || map.get(a[i]) !== index + sequence) break;
570
+ sequence++;
571
+ }
572
+ if (sequence > index - bStart) {
573
+ const node = a[aStart];
574
+ while (bStart < index) insertBefore(parent, b[bStart++], node);
575
+ } else {
576
+ if (a[aStart].parentNode === parent) {
577
+ parent.replaceChild(b[bStart++], a[aStart++]);
578
+ } else {
579
+ insertBefore(parent, b[bStart++], after);
580
+ aStart++;
581
+ }
582
+ }
583
+ } else {
584
+ aStart++;
585
+ }
586
+ } else {
587
+ if (a[aStart].parentNode === parent) parent.removeChild(a[aStart]);
588
+ aStart++;
589
+ }
590
+ }
591
+ }
592
+ return b;
593
+ }
594
+ function cleanChildren(parent, current, marker) {
595
+ if (current) {
596
+ if (Array.isArray(current)) {
597
+ for (let i = 0; i < current.length; i++) {
598
+ if (current[i].parentNode === parent) parent.removeChild(current[i]);
599
+ }
600
+ } else if (current.parentNode === parent) {
601
+ parent.removeChild(current);
602
+ }
603
+ }
604
+ return null;
605
+ }
606
+ function insertBefore(parent, node, marker) {
607
+ if (hydration.active && node.parentNode === parent) return;
608
+ if (marker) {
609
+ if (marker.parentNode === parent) {
610
+ parent.insertBefore(node, marker);
611
+ } else {
612
+ parent.appendChild(node);
613
+ }
614
+ } else {
615
+ parent.appendChild(node);
616
+ }
617
+ }
618
+ function setProperty(element, name, value) {
619
+ if (value == null) delete element[name];
620
+ else element[name] = value;
621
+ }
622
+ function addNativeEventListener(element, name, value) {
623
+ let handler = value;
624
+ let options;
625
+ if (Array.isArray(value)) {
626
+ handler = value[0];
627
+ options = value[1];
628
+ }
629
+ if (typeof handler !== "function") return () => {
630
+ };
631
+ element.addEventListener(name, handler, options);
632
+ return () => element.removeEventListener(name, handler, options);
633
+ }
634
+ function reportMarked(element, accessor) {
635
+ if (!accessor || typeof accessor !== "function") return;
636
+ const written = accessor[HOLE_TAG]?.name;
637
+ if (!written) return;
638
+ const colon = written.indexOf(":");
639
+ if (colon === -1) return;
640
+ reportReactiveDirective(element, written.slice(0, colon), written.slice(colon + 1), accessor);
641
+ }
642
+ function reportKeys(element, kind, value) {
643
+ const from = typeof value === "function" ? untrack(() => value()) : value;
644
+ if (!from || typeof from !== "object") return;
645
+ for (const key of Object.keys(from)) reportReactiveDirective(element, kind, key);
646
+ }
647
+ function applyUse(element, value) {
648
+ const call = (dir, accessor) => {
649
+ if (typeof dir !== "function") return;
650
+ reportReactiveDirective(element, "use", dir.name || "use", accessor);
651
+ dir(element, accessor ?? (() => void 0));
652
+ };
653
+ if (typeof value === "function") {
654
+ call(value);
655
+ return;
656
+ }
657
+ if (!Array.isArray(value)) return;
658
+ if (typeof value[0] === "function") {
659
+ call(value[0], value[1]);
660
+ return;
661
+ }
662
+ for (const pair of value) {
663
+ if (Array.isArray(pair)) call(pair[0], pair[1]);
664
+ else call(pair);
665
+ }
666
+ }
667
+ function setDynamicAttribute(element, name, accessor, isSVG = false) {
668
+ reportMarked(element, accessor);
669
+ if (typeof accessor !== "function") {
670
+ setAttribute(element, name, accessor, isSVG);
671
+ return () => {
672
+ };
673
+ }
674
+ return createRenderEffect(() => {
675
+ reportReactiveBinding(element, "attribute", name, accessor);
676
+ const value = typeof accessor === "function" ? accessor() : accessor;
677
+ setAttribute(element, name, value, isSVG);
678
+ });
679
+ }
680
+ function setDynamicProperty(element, name, accessor) {
681
+ if (typeof accessor !== "function") {
682
+ setProperty(element, name, accessor);
683
+ return () => {
684
+ };
685
+ }
686
+ reportMarked(element, accessor);
687
+ return createRenderEffect(() => {
688
+ reportReactiveBinding(element, "property", name, accessor);
689
+ const value = typeof accessor === "function" ? accessor() : accessor;
690
+ setProperty(element, name, value);
691
+ });
692
+ }
693
+ function setDynamicBoolAttribute(element, name, accessor) {
694
+ if (typeof accessor !== "function") {
695
+ setAttribute(element, name, !!accessor);
696
+ return () => {
697
+ };
698
+ }
699
+ return createRenderEffect(() => {
700
+ reportReactiveBinding(element, "attribute", name, accessor);
701
+ const value = accessor();
702
+ setAttribute(element, name, !!value);
703
+ });
704
+ }
705
+ function setClassName(element, value) {
706
+ if (value == null) {
707
+ element.removeAttribute("class");
708
+ return;
709
+ }
710
+ if (typeof value === "function") {
711
+ createRenderEffect(() => {
712
+ reportReactiveBinding(element, "attribute", "class", value);
713
+ setClassName(element, value());
714
+ });
715
+ return;
716
+ }
717
+ if (typeof value === "string") {
718
+ element.setAttribute("class", value);
719
+ return;
720
+ }
721
+ if (Array.isArray(value)) {
722
+ element.setAttribute("class", value.filter(Boolean).join(" "));
723
+ return;
724
+ }
725
+ if (typeof value === "object") {
726
+ const classes = Object.keys(value).filter((key) => {
727
+ const v = value[key];
728
+ return typeof v === "function" ? v() : Boolean(v);
729
+ }).join(" ");
730
+ element.setAttribute("class", classes);
731
+ return;
732
+ }
733
+ element.setAttribute("class", String(value));
734
+ }
735
+ function setClassList(element, value, disposers) {
736
+ if (!value || typeof value !== "object") return;
737
+ for (const name in value) {
738
+ const cond = value[name];
739
+ const names = name.split(/\s+/).filter(Boolean);
740
+ if (typeof cond === "function" && disposers) {
741
+ disposers.push(
742
+ createRenderEffect(() => {
743
+ const on = !!cond();
744
+ for (const n of names) element.classList.toggle(n, on);
745
+ })
746
+ );
747
+ } else {
748
+ const on = !!(typeof cond === "function" ? cond() : cond);
749
+ for (const n of names) element.classList.toggle(n, on);
750
+ }
751
+ }
752
+ }
753
+ function setStyle(element, _value) {
754
+ let value = _value;
755
+ while (typeof value === "function") value = value();
756
+ if (value == null) {
757
+ element.removeAttribute("style");
758
+ return;
759
+ }
760
+ if (typeof value === "string") {
761
+ element.style.cssText = value;
762
+ return;
763
+ }
764
+ if (typeof value === "object") {
765
+ for (const key in value) {
766
+ const styleValue = value[key];
767
+ if (styleValue == null) element.style[key] = "";
768
+ else element.style[key] = styleValue;
769
+ }
770
+ }
771
+ }
772
+ function spread(options) {
773
+ const {
774
+ element,
775
+ props,
776
+ prevProps = EMPTY_OBJ,
777
+ isSVG = false,
778
+ skipChildren = false
779
+ } = options;
780
+ if (!element || !isDomElement(element)) {
781
+ console.error("[spread] Error: element is not a DOM Element!");
782
+ return () => {
783
+ };
784
+ }
785
+ if (!props) {
786
+ console.warn("[spread] Warning: props is undefined!");
787
+ return () => {
788
+ };
789
+ }
790
+ const elementIsSVG = isSVG || element.namespaceURI === SVG_NAMESPACE;
791
+ const disposers = [];
792
+ for (const key in props) {
793
+ if (skipChildren && key === "children") continue;
794
+ const value = props[key];
795
+ const prev = prevProps[key];
796
+ if (value === prev) continue;
797
+ if (key === "ref") {
798
+ handleRef(value, element);
799
+ continue;
800
+ }
801
+ if (key === "use") {
802
+ applyUse(element, value);
803
+ continue;
804
+ }
805
+ if (key.startsWith("on:")) {
806
+ disposers.push(addNativeEventListener(element, key.slice(3), value));
807
+ continue;
808
+ }
809
+ if (key.startsWith("prop:")) {
810
+ reportReactiveDirective(element, "prop", key.slice(5), value);
811
+ disposers.push(setDynamicProperty(element, key.slice(5), value));
812
+ continue;
813
+ }
814
+ if (key.startsWith("attr:")) {
815
+ reportReactiveDirective(element, "attr", key.slice(5), value);
816
+ disposers.push(setDynamicAttribute(element, key.slice(5), value, elementIsSVG));
817
+ continue;
818
+ }
819
+ if (key.startsWith("bool:")) {
820
+ reportReactiveDirective(element, "bool", key.slice(5), value);
821
+ disposers.push(setDynamicBoolAttribute(element, key.slice(5), value));
822
+ continue;
823
+ }
824
+ if (key === "class" || key === "className") {
825
+ if (typeof value === "function") {
826
+ disposers.push(
827
+ createRenderEffect(() => {
828
+ reportReactiveBinding(element, "attribute", "class", value);
829
+ setClassName(element, value());
830
+ })
831
+ );
832
+ } else {
833
+ setClassName(element, value);
834
+ }
835
+ continue;
836
+ }
837
+ if (key === "classList") {
838
+ reportKeys(element, "class", value);
839
+ if (typeof value === "function") {
840
+ disposers.push(
841
+ createRenderEffect(() => {
842
+ reportReactiveBinding(element, "attribute", "class", value);
843
+ setClassList(element, value());
844
+ })
845
+ );
846
+ } else {
847
+ setClassList(element, value, disposers);
848
+ }
849
+ continue;
850
+ }
851
+ if (key === "style") {
852
+ reportKeys(element, "style", value);
853
+ if (typeof value === "function") {
854
+ disposers.push(
855
+ createRenderEffect(() => {
856
+ reportReactiveBinding(element, "attribute", "style", value);
857
+ setStyle(element, value());
858
+ })
859
+ );
860
+ } else {
861
+ setStyle(element, value);
862
+ }
863
+ continue;
864
+ }
865
+ if (key.startsWith("on")) {
866
+ const eventName = key.slice(2).toLowerCase();
867
+ if (prev) removeDelegatedEventListener(element, eventName);
868
+ if (value) addDelegatedEventListener(element, eventName, value);
869
+ continue;
870
+ }
871
+ const asProperty = JSX_PROPERTIES.has(key) || !elementIsSVG && key in element;
872
+ if (typeof value === "function") {
873
+ disposers.push(
874
+ asProperty ? setDynamicProperty(element, key, value) : setDynamicAttribute(element, key, value, elementIsSVG)
875
+ );
876
+ } else {
877
+ disposers.push(
878
+ createRenderEffect(
879
+ () => asProperty ? setProperty(element, key, props[key]) : setAttribute(element, key, props[key], elementIsSVG)
880
+ )
881
+ );
882
+ }
883
+ }
884
+ for (const key in prevProps) {
885
+ if (!(key in props)) {
886
+ if (key.startsWith("on")) {
887
+ const eventName = key.slice(2).toLowerCase();
888
+ removeDelegatedEventListener(element, eventName);
889
+ } else if (JSX_PROPERTIES.has(key)) {
890
+ setProperty(element, key, null);
891
+ } else {
892
+ element.removeAttribute(key);
893
+ }
894
+ }
895
+ }
896
+ return () => {
897
+ disposers.forEach((d) => d());
898
+ };
899
+ }
900
+ function handleRef(ref, element) {
901
+ if (!ref) return;
902
+ const held = ref[HOLE_TAG]?.name;
903
+ reportReactiveDirective(
904
+ element,
905
+ "ref",
906
+ held || (typeof ref === "function" ? ref.name || "ref" : "ref"),
907
+ ref
908
+ );
909
+ if (isDomNode(ref)) {
910
+ const actualRef = element;
911
+ const actualElement = ref;
912
+ if (!actualRef) return;
913
+ if (typeof actualRef === "function") actualRef(actualElement);
914
+ else if (typeof actualRef === "object" && "current" in actualRef) actualRef.current = actualElement;
915
+ return;
916
+ }
917
+ if (typeof ref === "function") ref(element);
918
+ else if (typeof ref === "object" && "current" in ref) ref.current = element;
919
+ }
920
+ function isPromise(v) {
921
+ return v != null && (typeof v === "object" || typeof v === "function") && typeof v.then === "function" || v instanceof Promise;
922
+ }
923
+ function render(element, container, context) {
924
+ if (!container) {
925
+ throw new Error("Container element is required");
926
+ }
927
+ let rendererDispose;
928
+ let disposeRoot;
929
+ const disposers = [];
930
+ createRoot((dispose) => {
931
+ batch(() => {
932
+ if (!hydration.active) {
933
+ container.textContent = "";
934
+ }
935
+ stampVersions(container);
936
+ warnOnVersionSkew();
937
+ insert(container, element);
938
+ return;
939
+ });
940
+ disposeRoot = dispose;
941
+ });
942
+ return () => {
943
+ disposeRoot?.();
944
+ rendererDispose?.();
945
+ disposers.forEach((d) => d());
946
+ container.textContent = "";
947
+ };
948
+ }
949
+
950
+ // src/lib/dom/integration.ts
951
+ import { untrack as untrack2, isSignal as isSignal2, reportReactiveProps } from "@fluixi/reactive";
952
+ var _slotKey = "__fx_dom_create_component__";
953
+ var _slot = globalThis[_slotKey] ??= { fn: null };
954
+ function createComponent(Comp, props) {
955
+ if (_slot.fn) return _slot.fn(Comp, props);
956
+ if (props) reportReactiveProps(props);
957
+ const component = typeof Comp === "function" ? untrack2(() => Comp(props)) : Comp;
958
+ const nameable = component != null && (typeof component === "function" || typeof component === "object");
959
+ if (nameable) {
960
+ try {
961
+ component["$name"] = Comp?.name;
962
+ } catch {
963
+ }
964
+ }
965
+ if (nameable && !isSignal2(component)) {
966
+ return asComponent(component);
967
+ }
968
+ return component;
969
+ }
970
+
971
+ // src/lib/dom/hydration.ts
972
+ import { setResourceIdSource, setServerDataGetter } from "@fluixi/reactive/signal";
973
+
974
+ // src/lib/dom/server/fx-data.ts
975
+ var FX_DATA_ID = "__FX_DATA__";
976
+ var _scriptCache;
977
+ function getServerData() {
978
+ const g = globalThis.__FX_DATA__;
979
+ if (g) return g;
980
+ if (_scriptCache !== void 0) return _scriptCache;
981
+ let parsed = null;
982
+ if (typeof document !== "undefined") {
983
+ const text = document.getElementById(FX_DATA_ID)?.textContent;
984
+ if (text) {
985
+ try {
986
+ parsed = JSON.parse(text);
987
+ } catch {
988
+ parsed = null;
989
+ }
990
+ }
991
+ }
992
+ return _scriptCache = parsed;
993
+ }
994
+
995
+ // src/lib/dom/hydration.ts
996
+ function recoverCursor() {
997
+ for (; ; ) {
998
+ while (hydration.cursor && hydration.cursor.nodeType === 3 && hydration.cursor.data === "") {
999
+ hydration.cursor = hydration.cursor.nextSibling;
1000
+ }
1001
+ if (hydration.cursor != null || !hydration.parents.length) return;
1002
+ hydration.cursor = hydration.parents.pop().nextSibling;
1003
+ }
1004
+ }
1005
+ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
1006
+ "area",
1007
+ "base",
1008
+ "br",
1009
+ "col",
1010
+ "embed",
1011
+ "hr",
1012
+ "img",
1013
+ "input",
1014
+ "link",
1015
+ "meta",
1016
+ "param",
1017
+ "source",
1018
+ "track",
1019
+ "wbr"
1020
+ ]);
1021
+ var DEV = typeof process !== "undefined" && process.env && false;
1022
+ function warnMismatch(expected, found) {
1023
+ const f = found.nodeType === 1 ? `<${found.tagName.toLowerCase()}>` : found.nodeType === 3 ? `text ${JSON.stringify((found.nodeValue ?? "").slice(0, 24))}` : found.nodeType === 8 ? "comment" : "node";
1024
+ console.warn(
1025
+ `[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).`
1026
+ );
1027
+ }
1028
+ function hydrateElement(tag) {
1029
+ recoverCursor();
1030
+ const c = hydration.cursor;
1031
+ if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
1032
+ if (VOID_ELEMENTS.has(tag.toLowerCase())) {
1033
+ hydration.cursor = c.nextSibling;
1034
+ } else {
1035
+ hydration.parents.push(c);
1036
+ hydration.cursor = c.firstChild;
1037
+ }
1038
+ return c;
1039
+ }
1040
+ if (DEV && c) warnMismatch(`<${tag}>`, c);
1041
+ return null;
1042
+ }
1043
+ function hydrateStatic(tag) {
1044
+ recoverCursor();
1045
+ const c = hydration.cursor;
1046
+ if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
1047
+ hydration.cursor = c.nextSibling;
1048
+ return c;
1049
+ }
1050
+ if (DEV && c) warnMismatch(`<${tag}> (static)`, c);
1051
+ return null;
1052
+ }
1053
+ function hydrateText(value) {
1054
+ if (value === "") {
1055
+ const c2 = hydration.cursor;
1056
+ if (c2 && c2.nodeType === 3 && c2.data !== "") {
1057
+ hydration.cursor = c2.nextSibling;
1058
+ c2.data = "";
1059
+ return c2;
1060
+ }
1061
+ return null;
1062
+ }
1063
+ recoverCursor();
1064
+ const c = hydration.cursor;
1065
+ if (c && c.nodeType === 3) {
1066
+ hydration.cursor = c.nextSibling;
1067
+ if (c.nodeValue !== value) c.nodeValue = value;
1068
+ return c;
1069
+ }
1070
+ if (DEV && c) warnMismatch(`text ${JSON.stringify(value.slice(0, 24))}`, c);
1071
+ return null;
1072
+ }
1073
+ function hydrateMarker(value) {
1074
+ recoverCursor();
1075
+ const c = hydration.cursor;
1076
+ if (c && c.nodeType === 8 && c.data === value) {
1077
+ hydration.cursor = c.nextSibling;
1078
+ return c;
1079
+ }
1080
+ if (DEV && c) warnMismatch(`marker <!--${value.slice(0, 24)}-->`, c);
1081
+ return null;
1082
+ }
1083
+ var _walkerRegistered = false;
1084
+ function ensureWalker() {
1085
+ if (_walkerRegistered) return;
1086
+ _walkerRegistered = true;
1087
+ registerHydrationWalker({ hydrateElement, hydrateText, hydrateMarker, hydrateStatic });
1088
+ }
1089
+ function hydrate(element, container, options) {
1090
+ ensureWalker();
1091
+ hydration.active = true;
1092
+ hydration.cursor = container.firstChild;
1093
+ hydration.parents = [];
1094
+ const data = getServerData();
1095
+ const ns = options?.resourceNamespace;
1096
+ let rid = 0;
1097
+ setResourceIdSource(() => ns ? `${ns}:r${rid++}` : `r${rid++}`);
1098
+ setServerDataGetter(data ? (id) => id in data ? { value: data[id] } : void 0 : null);
1099
+ try {
1100
+ return render(element, container);
1101
+ } finally {
1102
+ hydration.active = false;
1103
+ hydration.cursor = null;
1104
+ hydration.parents = [];
1105
+ }
1106
+ }
1107
+
1108
+ // src/lib/flow/show.ts
1109
+ import {
1110
+ createChildOwner,
1111
+ createMemo,
1112
+ disposeScope,
1113
+ getOwner,
1114
+ runWithOwner,
1115
+ untrack as untrack3
1116
+ } from "@fluixi/reactive/signal";
1117
+
1118
+ // src/lib/flow/utils.ts
1119
+ function normalizeAccessor(value) {
1120
+ return typeof value === "function" ? value : (() => value);
1121
+ }
1122
+ function resolveReactiveProp(read) {
1123
+ return () => {
1124
+ const value = read();
1125
+ return typeof value === "function" ? value() : value;
1126
+ };
1127
+ }
1128
+ function isTruthy(value) {
1129
+ return value !== null && value !== void 0 && value !== false;
1130
+ }
1131
+ function isLitResult(value) {
1132
+ if (!value || typeof value !== "object") return false;
1133
+ return !!(typeof value["_$litType$"] !== "undefined" || typeof value["_$litDirective$"] !== "undefined" || Array.isArray(value.strings) && Array.isArray(value.values));
1134
+ }
1135
+
1136
+ // src/lib/flow/show.ts
1137
+ function Show(props) {
1138
+ const when = resolveReactiveProp(() => props.when);
1139
+ const value = createMemo(when, void 0, { name: "Show.when" });
1140
+ const cond = createMemo(value, void 0, { name: "Show.cond" });
1141
+ const parentOwner = getOwner();
1142
+ let branchScope = null;
1143
+ let shown = null;
1144
+ const enterBranch = (next) => {
1145
+ if (next === shown) return;
1146
+ if (branchScope) disposeScope(branchScope);
1147
+ branchScope = createChildOwner(parentOwner);
1148
+ shown = next;
1149
+ };
1150
+ return createMemo(
1151
+ () => {
1152
+ const evaluate = cond();
1153
+ enterBranch(evaluate ? "when" : "fallback");
1154
+ return runWithOwner(branchScope, () => {
1155
+ if (evaluate) {
1156
+ let children = props.children;
1157
+ if (typeof children === "function" && !isLitResult(children)) {
1158
+ if (typeof value === "function") {
1159
+ return untrack3(() => {
1160
+ if (!untrack3(value)) return props.fallback;
1161
+ return children(value());
1162
+ });
1163
+ }
1164
+ return children(value);
1165
+ }
1166
+ return children;
1167
+ }
1168
+ return props.fallback;
1169
+ });
1170
+ return props.fallback ?? null;
1171
+ },
1172
+ void 0,
1173
+ // Not `Show`: the compiler already marks the memo it wraps the component in with that,
1174
+ // and two cards of the same name in one graph is worse than a longer one.
1175
+ { name: "Show.result" }
1176
+ );
1177
+ }
1178
+
1179
+ // src/lib/flow/for.ts
1180
+ import { mapArray, keyArray } from "@fluixi/reactive/signal";
1181
+ function For(props) {
1182
+ const each = resolveReactiveProp(() => props.each);
1183
+ const fallback = () => props.fallback ?? null;
1184
+ const render2 = (item, index) => {
1185
+ const children = props.children;
1186
+ const rendered = Array.isArray(children) ? children.map((c) => typeof c === "function" ? c(item, index) : c) : typeof children === "function" ? children(item, index) : children;
1187
+ hydrateAdvancePast(rendered);
1188
+ return rendered;
1189
+ };
1190
+ return props.by ? keyArray(each, props.by, (item, index) => render2(item, index), { fallback }) : mapArray(each, (item, index) => render2(item, index), { fallback });
1191
+ }
1192
+
1193
+ // src/lib/flow/index-flow.ts
1194
+ import { indexArray } from "@fluixi/reactive/signal";
1195
+ function Index(props) {
1196
+ const each = resolveReactiveProp(() => props.each);
1197
+ return indexArray(
1198
+ each,
1199
+ (item, index) => {
1200
+ const rendered = props.children(item, index);
1201
+ hydrateAdvancePast(rendered);
1202
+ return rendered;
1203
+ },
1204
+ { fallback: () => props.fallback ?? null }
1205
+ );
1206
+ }
1207
+
1208
+ // src/lib/flow/index.ts
1209
+ import { mapArray as mapArray2, keyArray as keyArray2, indexArray as indexArray2 } from "@fluixi/reactive/signal";
1210
+
1211
+ // src/lib/flow/switch.ts
1212
+ import { createMemo as createMemo2, createChildOwner as createChildOwner2, disposeScope as disposeScope2, getOwner as getOwner2, runWithOwner as runWithOwner2 } from "@fluixi/reactive/signal";
1213
+ var MATCH_MARKER = /* @__PURE__ */ Symbol("match");
1214
+ function Match(props) {
1215
+ return {
1216
+ [MATCH_MARKER]: true,
1217
+ // Lazy read through the prop getter. Switch calls `branch.when()` inside its memo,
1218
+ // so `when={cond()}` reacts; `when={cond}` unwraps via resolveReactiveProp.
1219
+ when: resolveReactiveProp(() => props.when),
1220
+ // Lazy, like `when`. Read eagerly, every branch's children were built the
1221
+ // moment the Match node was, before Switch had chosen one, so they were
1222
+ // created outside the branch's scope (and non-matching branches were built
1223
+ // for nothing). Switch reads this inside the selected branch's scope.
1224
+ get children() {
1225
+ return props.children;
1226
+ }
1227
+ };
1228
+ }
1229
+ function Switch(props) {
1230
+ const branches = Array.isArray(props.children) ? props.children : [props.children];
1231
+ const parentOwner = getOwner2();
1232
+ let branchScope = null;
1233
+ let shown = -1;
1234
+ const enterBranch = (index) => {
1235
+ if (index === shown) return;
1236
+ if (branchScope) disposeScope2(branchScope);
1237
+ branchScope = createChildOwner2(parentOwner);
1238
+ shown = index;
1239
+ };
1240
+ return createMemo2(() => {
1241
+ for (let i = 0; i < branches.length; i += 1) {
1242
+ const raw = branches[i];
1243
+ let branch = raw;
1244
+ let guard = 0;
1245
+ while (typeof branch === "function" && !branch[MATCH_MARKER] && guard++ < 10) {
1246
+ branch = branch();
1247
+ }
1248
+ if (!branch || typeof branch !== "object" || branch[MATCH_MARKER] !== true) {
1249
+ continue;
1250
+ }
1251
+ const value = branch.when();
1252
+ if (isTruthy(value)) {
1253
+ enterBranch(i);
1254
+ return runWithOwner2(
1255
+ branchScope,
1256
+ () => typeof branch.children === "function" ? branch.children(value) : branch.children
1257
+ );
1258
+ }
1259
+ }
1260
+ enterBranch(-2);
1261
+ return runWithOwner2(branchScope, () => props.fallback ?? null);
1262
+ }, void 0, { name: "Switch" });
1263
+ }
1264
+
1265
+ // src/lib/flow/dynamic.ts
1266
+ import { createMemo as createMemo3, createChildOwner as createChildOwner3, disposeScope as disposeScope3, getOwner as getOwner3, runWithOwner as runWithOwner3 } from "@fluixi/reactive/signal";
1267
+ function Dynamic(props) {
1268
+ const getComponent = normalizeAccessor(props.component);
1269
+ const { component: _c, ...rest } = props;
1270
+ const parentOwner = getOwner3();
1271
+ let scope = null;
1272
+ let current;
1273
+ return createMemo3(() => {
1274
+ const C = getComponent();
1275
+ if (C !== current) {
1276
+ if (scope) disposeScope3(scope);
1277
+ scope = createChildOwner3(parentOwner);
1278
+ current = C;
1279
+ }
1280
+ if (C == null) return null;
1281
+ if (typeof C === "string") {
1282
+ return { tag: C, props: rest };
1283
+ }
1284
+ return runWithOwner3(scope, () => C(rest));
1285
+ }, void 0, { name: "Dynamic" });
1286
+ }
1287
+
1288
+ // src/lib/flow/portal.ts
1289
+ import { createRoot as createRoot2, onCleanup as onCleanup2 } from "@fluixi/reactive/signal";
1290
+ function Portal(props) {
1291
+ const getMount = () => {
1292
+ if (!props.mount) return document.body;
1293
+ return typeof props.mount === "function" ? props.mount() : props.mount;
1294
+ };
1295
+ let dispose;
1296
+ let container;
1297
+ createRoot2((d) => {
1298
+ dispose = d;
1299
+ container = document.createElement("div");
1300
+ container.style.display = "contents";
1301
+ const target = getMount();
1302
+ target.appendChild(container);
1303
+ const inserted = insert(container, props.children);
1304
+ if (inserted) {
1305
+ handleRef(props.ref, container);
1306
+ }
1307
+ });
1308
+ onCleanup2(() => {
1309
+ dispose();
1310
+ container.remove();
1311
+ });
1312
+ return null;
1313
+ }
1314
+
1315
+ // src/lib/flow/error-boundary.ts
1316
+ import { createMemo as createMemo4, createSignal } from "@fluixi/reactive/signal";
1317
+ function ErrorBoundary(props) {
1318
+ const [error, setError] = createSignal(null);
1319
+ const reset = () => setError(null);
1320
+ return createMemo4(() => {
1321
+ const err = error();
1322
+ if (err !== null) {
1323
+ return typeof props.fallback === "function" ? props.fallback(err, reset) : props.fallback;
1324
+ }
1325
+ try {
1326
+ const content = typeof props.children === "function" ? props.children() : props.children;
1327
+ return content;
1328
+ } catch (e) {
1329
+ setError(e);
1330
+ return typeof props.fallback === "function" ? props.fallback(e, reset) : props.fallback;
1331
+ }
1332
+ }, void 0, { name: "ErrorBoundary" });
1333
+ }
1334
+
1335
+ // src/lib/flow/class-map.ts
1336
+ import { createMemo as createMemo5 } from "@fluixi/reactive/signal";
1337
+ function classMap(input) {
1338
+ return createMemo5(() => {
1339
+ const map = typeof input === "function" ? input() : input;
1340
+ const classes = [];
1341
+ for (const [cls, cond] of Object.entries(map)) {
1342
+ if (!cls) continue;
1343
+ const active = typeof cond === "function" ? cond() : cond;
1344
+ if (active) classes.push(cls);
1345
+ }
1346
+ return classes.join(" ");
1347
+ }, void 0, { name: "ClassMap" });
1348
+ }
1349
+
1350
+ // src/lib/flow/style-map.ts
1351
+ import { createMemo as createMemo6 } from "@fluixi/reactive/signal";
1352
+ function toKebab(prop) {
1353
+ return prop.startsWith("--") ? prop : prop.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
1354
+ }
1355
+ function styleMap(input) {
1356
+ return createMemo6(() => {
1357
+ const map = typeof input === "function" ? input() : input;
1358
+ const parts = [];
1359
+ for (const [prop, val] of Object.entries(map)) {
1360
+ if (!prop) continue;
1361
+ const resolved = typeof val === "function" ? val() : val;
1362
+ if (resolved != null) {
1363
+ parts.push(`${toKebab(prop)}: ${resolved}`);
1364
+ }
1365
+ }
1366
+ return parts.join("; ");
1367
+ }, void 0, { name: "StyleMap" });
1368
+ }
1369
+
1370
+ // src/cdn/dom-client.ts
1371
+ import {
1372
+ signal,
1373
+ memo,
1374
+ effect,
1375
+ store,
1376
+ createSignal as createSignal2,
1377
+ createMemo as createMemo7,
1378
+ createEffect as createEffect2,
1379
+ createComputed,
1380
+ createRenderEffect as createRenderEffect2,
1381
+ createRoot as createRoot4,
1382
+ createResource,
1383
+ createContext,
1384
+ useContext,
1385
+ onCleanup as onCleanup4,
1386
+ batch as batch2,
1387
+ untrack as untrack4
1388
+ } from "@fluixi/reactive";
1389
+ export {
1390
+ Dynamic,
1391
+ ErrorBoundary,
1392
+ For,
1393
+ Index,
1394
+ Match,
1395
+ Portal,
1396
+ Show,
1397
+ Switch,
1398
+ batch2 as batch,
1399
+ classMap,
1400
+ createComponent,
1401
+ createComputed,
1402
+ createContext,
1403
+ createEffect2 as createEffect,
1404
+ createElement,
1405
+ createMemo7 as createMemo,
1406
+ createRenderEffect2 as createRenderEffect,
1407
+ createResource,
1408
+ createRoot4 as createRoot,
1409
+ createSignal2 as createSignal,
1410
+ delegateEvents,
1411
+ effect,
1412
+ hydrate,
1413
+ indexArray2 as indexArray,
1414
+ insert,
1415
+ keyArray2 as keyArray,
1416
+ mapArray2 as mapArray,
1417
+ memo,
1418
+ onCleanup4 as onCleanup,
1419
+ render,
1420
+ setAttribute,
1421
+ setClassName,
1422
+ setProperty,
1423
+ setStyle,
1424
+ signal,
1425
+ spread,
1426
+ store,
1427
+ styleMap,
1428
+ untrack4 as untrack,
1429
+ useContext
1430
+ };