@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
@@ -1 +1,1430 @@
1
- var Y="http://www.w3.org/2000/svg";var $=new Set(["className","value","checked","selected","innerHTML","innerText","textContent","indeterminate","htmlFor"]);function T(e,n,t,o=!1){if(t==null||t===!1){e.removeAttribute(n);return}if(t===!0){e.setAttribute(n,"");return}if(typeof t=="object"){e.setAttribute(n,JSON.stringify(t));return}e.setAttribute(n,String(t))}function je(e,n){Object.assign(e.style,n)}function $e(e,n={},...t){let o=document.createElement(e);return Object.entries(n).forEach(([i,a])=>{if(i==="class"||i==="className")o.className=a;else if(i==="style"&&typeof a=="object")je(o,a);else if(i.startsWith("on")&&typeof a=="function"){let c=i.slice(2).toLowerCase();o.addEventListener(c,a)}else T(o,i,a)}),t.forEach(i=>{typeof i=="string"?o.appendChild(document.createTextNode(i)):o.appendChild(i)}),o}var Wn=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;import{isSignal as h}from"@fluixi/reactive/signal";var Z="1.0.0-alpha.83";import{VERSION as Ie}from"@fluixi/reactive/version";var m={dom:Z,reactive:Ie};function Q(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 ee(){let e=[m.core,m.dom,m.reactive].filter(n=>n!==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 ne(e){return typeof e!="function"||Object.defineProperty(e,Symbol.for("fluixi-component"),{value:!0,enumerable:!0}),e}function S(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}import{batch as Ue,createEffect as it,createRenderEffect as g,createRoot as We,onCleanup as Ke,readChildren as st,reportReactiveBinding as w,reportReactiveDirective as v,untrack as Be}from"@fluixi/reactive/signal";var H=Symbol.for("fluixi.server-node"),He=Symbol.for("fluixi.dom.server-host"),Ve=globalThis,I=Ve[He]??={server:typeof document>"u",nodes:null};function V(){return I.server}function te(){if(!I.nodes)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return I.nodes}function R(e){return e!=null&&e[H]===!0?!0:typeof Node<"u"&&e instanceof Node}function oe(e){return e!=null&&e[H]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function re(e){return e!=null&&e[H]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var u={active:!1,cursor:null,parents:[]},ie=null;function se(e){ie=e}function ae(){return ie}function U(e,n){return u.active&&n.parentNode===e}function W(e){let n=u.parents.lastIndexOf(e);n!==-1&&(u.parents.length=n),u.cursor=e.nextSibling}function M(e){if(!u.active||e==null)return;let n=Array.isArray(e)?e[e.length-1]:e;n&&typeof n.nodeType=="number"&&W(n)}var qe={};var pe="__fx_at";var K=new Set,ye=new Set(["scroll","focus","blur","load","error","resize","mouseenter","mouseleave","pointerenter","pointerleave","gotpointercapture","lostpointercapture"]);function me(e){if(!V())for(let n of e)K.has(n)||ye.has(n)||(K.add(n),document.addEventListener(n,Ge))}function Ge(e){let n=`$$${e.type}`,t=e.composedPath&&e.composedPath()[0]||e.target;for(;t;){let o=t[n];if(o&&!t.disabled&&(o(e),e.cancelBubble))return;t=t.host&&t.host!==t&&t.host instanceof Element?t.host:t.parentNode}}function ze(e,n,t){if(e[`$$${n}`]=t,ye.has(n)){let o=`__fx_${n}`;if(!e[o]){let i=a=>{e[`$$${n}`]?.(a)};e.addEventListener(n,i),e[o]=i}return}K.has(n)||me([n])}function ce(e,n){delete e[`$$${n}`];let t=`__fx_${n}`,o=e[t];o&&(e.removeEventListener(n,o),delete e[t])}function E(e,n=!1){if(V())return te().createText(e);if(u.active&&!n){let t=ae()?.hydrateText(e);if(t)return t}return document.createTextNode(e)}var b=0,Xe=200;function Je(e,n,t,o,i){let a=o,c=new Map;return g(()=>{w(t??n,"content",void 0,e);let s;if(S(e)&&!h(e)){if(!c.has(e)){b++;try{let r=e();c.set(e,r)}finally{b--}}for(s=c.get(e);typeof s=="function"&&h(s);)s=s()}else for(s=e();typeof s=="function"&&h(s);)s=s();{let r=0;for(;typeof s=="function"&&r++<50;)if(S(s)){if(!c.has(s)){let l=s;b++;try{let f=l();c.set(l,f)}finally{b--}}s=c.get(s)}else if(h(s))s=s();else if(s=s(),typeof s!="function"||!h(s)&&!S(s))break}b++;try{a=L(n,s,t,a,c),i(a)}finally{b--}})}function P(e,n,t,o){if(b>Xe)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;t!==void 0&&!t&&(t=E("",!0),e.appendChild(t));let i=o??null,a=r=>Array.isArray(r)&&r.some(l=>typeof l=="function"),c=r=>typeof r=="function"?r:()=>r;if(typeof n!="function"&&!a(n)){b++;try{i=L(e,n,t,i)}finally{b--}return()=>i}let s=Je(c(n),e,t,i,r=>{i=r});return()=>(s?.(),i)}function L(e,n,t,o,i){if(n==null||typeof n=="boolean")return A(e,o,t);if(typeof n=="function")for(;typeof n=="function";)n=n();if(n==null||typeof n=="boolean")return A(e,o,t);if(k(n)){let c=E("",!0);return Array.isArray(o)?o.length>0?(e.replaceChild(c,o[0]),A(e,o.slice(1),t)):y(e,c,t):o?e.replaceChild(c,o):y(e,c,t),n.then(s=>{c.parentNode===e&&L(e,s,c.nextSibling,c)}).catch(s=>{console.error("Error resolving promise in insertExpression:",s)}),c}let a=typeof n;if(a==="string"||a==="number"){if(a==="number"&&(n=String(n)),Array.isArray(o)){if(o.length===0){let s=E(n);return y(e,s,t),s}if(o.length===1&&o[0].nodeType===3)return o[0].data=n,o;o=A(e,o,t)}if(o&&re(o))return o.data=n,o;let c=E(n);return o&&o.parentNode===e?e.replaceChild(c,o):U(e,c)||y(e,c,t),c}if(R(n))return U(e,n)?(W(n),n):Array.isArray(o)?(o.length===0?y(e,n,t):o[0].parentNode===e?(e.replaceChild(n,o[0]),A(e,o.slice(1),t)):y(e,n,t),n):(o?o!==n&&(o.parentNode===e?e.replaceChild(n,o):y(e,n,t)):y(e,n,t),n);if(Array.isArray(n)){let c=[],s=Array.isArray(o)?o:o?[o]:[],r=[];x(n,c,e,t,!0,i,r);let l=Ye(e,s,c,t);for(let f of r){let d=P(e,f.sig,f.marker);Ke(()=>{A(e,d()),f.marker.parentNode===e&&e.removeChild(f.marker)})}return l}if(a==="object"&&n!==null&&typeof n=="object"){let c=n;if("type"in c&&"props"in c){let s=c;if(typeof s.type=="function"){let r=s.type(s.props||{});return L(e,r,t,o)}}}return A(e,o,t)}function x(e,n,t,o,i=!0,a,c){for(let s=0;s<e.length;s++){let r=e[s];if(!(r==null||typeof r=="boolean")){for(;typeof r=="function"&&!k(r)&&!h(r)&&!S(r)&&(r=r(),!(r==null||typeof r=="boolean")););if(!(r==null||typeof r=="boolean")){if(typeof r=="function"){let l;for(S(r)&&!h(r)?(a||(a=new Map),a.has(r)||a.set(r,r()),l=a.get(r)):l=r();typeof l=="function"&&!k(l)&&!h(l)&&!S(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);n.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,n,t,o,i,a):x([f],n,t,o,i,a);continue}continue}Array.isArray(l)?x(l,n,t,o,i,a,c):x([l],n,t,o,i,a,c);continue}if(k(r)){let l=E("",!0);n.push(l),r.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(r)){x(r,n,t,o,i,a,c);continue}if(R(r)){n.push(r);continue}if(typeof r=="object"&&r!==null&&"type"in r&&"props"in r){let l=r;if(typeof l.type=="function"){let f=l.type(l.props||{});Array.isArray(f)?x(f,n,t,o,!1,a):x([f],n,t,o,!1,a);continue}}if(typeof r=="string"||typeof r=="number"){let l=String(r);if(l.trim()===""&&l!==" ")continue;n.push(E(l));continue}n.push(E(String(r)))}}}}function Ye(e,n,t,o){for(let d=0;d<t.length;d++){let p=t[d].parentNode;p!==null&&p!==e&&p.nodeType!==11&&(t=t.slice(),t[d]=t[d].cloneNode(!0))}let i=t.length,a=n.length,c=i,s=0,r=0,l=a>0?n[a-1].nextSibling??void 0:o,f=null;for(;s<a||r<c;){if(n[s]===t[r]){s++,r++;continue}for(;a>s&&c>r&&n[a-1]===t[c-1];)a--,c--;if(a===s){let d=c<i?r?t[r-1].nextSibling??void 0:t[c-r]:l;for(;r<c;)y(e,t[r++],d)}else if(c===r)for(;s<a;)(!f||!f.has(n[s]))&&n[s].parentNode===e&&e.removeChild(n[s]),s++;else if(n[s]===t[c-1]&&t[r]===n[a-1]){let d=n[--a].nextSibling;y(e,t[r++],n[s++].nextSibling),y(e,t[--c],d),n[a]=n[s-1]}else{if(!f){f=new Map;let p=r;for(;p<c;)f.set(t[p],p++)}let d=f.get(n[s]);if(d!=null)if(r<d&&d<c){let p=s,j=1;for(;++p<a&&p<c&&!(!f.has(n[p])||f.get(n[p])!==d+j);)j++;if(j>d-r){let Fe=n[s];for(;r<d;)y(e,t[r++],Fe)}else n[s].parentNode===e?e.replaceChild(t[r++],n[s++]):(y(e,t[r++],l),s++)}else s++;else n[s].parentNode===e&&e.removeChild(n[s]),s++}}return t}function A(e,n,t){if(n)if(Array.isArray(n))for(let o=0;o<n.length;o++)n[o].parentNode===e&&e.removeChild(n[o]);else n.parentNode===e&&e.removeChild(n);return null}function y(e,n,t){u.active&&n.parentNode===e||(t&&t.parentNode===e?e.insertBefore(n,t):e.appendChild(n))}function C(e,n,t){t==null?delete e[n]:e[n]=t}function Ze(e,n,t){let o=t,i;return Array.isArray(t)&&(o=t[0],i=t[1]),typeof o!="function"?()=>{}:(e.addEventListener(n,o,i),()=>e.removeEventListener(n,o,i))}function he(e,n){if(!n||typeof n!="function")return;let t=n[pe]?.name;if(!t)return;let o=t.indexOf(":");o!==-1&&v(e,t.slice(0,o),t.slice(o+1),n)}function le(e,n,t){let o=typeof t=="function"?Be(()=>t()):t;if(!(!o||typeof o!="object"))for(let i of Object.keys(o))v(e,n,i)}function Qe(e,n){let t=(o,i)=>{typeof o=="function"&&(v(e,"use",o.name||"use",i),o(e,i??(()=>{})))};if(typeof n=="function"){t(n);return}if(Array.isArray(n)){if(typeof n[0]=="function"){t(n[0],n[1]);return}for(let o of n)Array.isArray(o)?t(o[0],o[1]):t(o)}}function fe(e,n,t,o=!1){return he(e,t),typeof t!="function"?(T(e,n,t,o),()=>{}):g(()=>{w(e,"attribute",n,t);let i=typeof t=="function"?t():t;T(e,n,i,o)})}function ue(e,n,t){return typeof t!="function"?(C(e,n,t),()=>{}):(he(e,t),g(()=>{w(e,"property",n,t);let o=typeof t=="function"?t():t;C(e,n,o)}))}function en(e,n,t){return typeof t!="function"?(T(e,n,!!t),()=>{}):g(()=>{w(e,"attribute",n,t);let o=t();T(e,n,!!o)})}function O(e,n){if(n==null){e.removeAttribute("class");return}if(typeof n=="function"){g(()=>{w(e,"attribute","class",n),O(e,n())});return}if(typeof n=="string"){e.setAttribute("class",n);return}if(Array.isArray(n)){e.setAttribute("class",n.filter(Boolean).join(" "));return}if(typeof n=="object"){let t=Object.keys(n).filter(o=>{let i=n[o];return typeof i=="function"?i():!!i}).join(" ");e.setAttribute("class",t);return}e.setAttribute("class",String(n))}function de(e,n,t){if(!(!n||typeof n!="object"))for(let o in n){let i=n[o],a=o.split(/\s+/).filter(Boolean);if(typeof i=="function"&&t)t.push(g(()=>{let c=!!i();for(let s of a)e.classList.toggle(s,c)}));else{let c=!!(typeof i=="function"?i():i);for(let s of a)e.classList.toggle(s,c)}}}function B(e,n){let t=n;for(;typeof t=="function";)t=t();if(t==null){e.removeAttribute("style");return}if(typeof t=="string"){e.style.cssText=t;return}if(typeof t=="object")for(let o in t){let i=t[o];i==null?e.style[o]="":e.style[o]=i}}function nn(e){let{element:n,props:t,prevProps:o=qe,isSVG:i=!1,skipChildren:a=!1}=e;if(!n||!oe(n))return console.error("[spread] Error: element is not a DOM Element!"),()=>{};if(!t)return console.warn("[spread] Warning: props is undefined!"),()=>{};let c=i||n.namespaceURI===Y,s=[];for(let r in t){if(a&&r==="children")continue;let l=t[r],f=o[r];if(l===f)continue;if(r==="ref"){q(l,n);continue}if(r==="use"){Qe(n,l);continue}if(r.startsWith("on:")){s.push(Ze(n,r.slice(3),l));continue}if(r.startsWith("prop:")){v(n,"prop",r.slice(5),l),s.push(ue(n,r.slice(5),l));continue}if(r.startsWith("attr:")){v(n,"attr",r.slice(5),l),s.push(fe(n,r.slice(5),l,c));continue}if(r.startsWith("bool:")){v(n,"bool",r.slice(5),l),s.push(en(n,r.slice(5),l));continue}if(r==="class"||r==="className"){typeof l=="function"?s.push(g(()=>{w(n,"attribute","class",l),O(n,l())})):O(n,l);continue}if(r==="classList"){le(n,"class",l),typeof l=="function"?s.push(g(()=>{w(n,"attribute","class",l),de(n,l())})):de(n,l,s);continue}if(r==="style"){le(n,"style",l),typeof l=="function"?s.push(g(()=>{w(n,"attribute","style",l),B(n,l())})):B(n,l);continue}if(r.startsWith("on")){let p=r.slice(2).toLowerCase();f&&ce(n,p),l&&ze(n,p,l);continue}let d=$.has(r)||!c&&r in n;typeof l=="function"?s.push(d?ue(n,r,l):fe(n,r,l,c)):s.push(g(()=>d?C(n,r,t[r]):T(n,r,t[r],c)))}for(let r in o)if(!(r in t))if(r.startsWith("on")){let l=r.slice(2).toLowerCase();ce(n,l)}else $.has(r)?C(n,r,null):n.removeAttribute(r);return()=>{s.forEach(r=>r())}}function q(e,n){if(!e)return;let t=e[pe]?.name;if(v(n,"ref",t||typeof e=="function"&&e.name||"ref",e),R(e)){let o=n,i=e;if(!o)return;typeof o=="function"?o(i):typeof o=="object"&&"current"in o&&(o.current=i);return}typeof e=="function"?e(n):typeof e=="object"&&"current"in e&&(e.current=n)}function k(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function G(e,n,t){if(!n)throw new Error("Container element is required");let o,i,a=[];return We(c=>{Ue(()=>{u.active||(n.textContent=""),Q(n),ee(),P(n,e)}),i=c}),()=>{i?.(),o?.(),a.forEach(c=>c()),n.textContent=""}}import{untrack as tn,isSignal as on,reportReactiveProps as rn}from"@fluixi/reactive";var sn="__fx_dom_create_component__",ge=globalThis[sn]??={fn:null};function an(e,n){if(ge.fn)return ge.fn(e,n);n&&rn(n);let t=typeof e=="function"?tn(()=>e(n)):e,o=t!=null&&(typeof t=="function"||typeof t=="object");if(o)try{t.$name=e?.name}catch{}return o&&!on(t)?ne(t):t}import{setResourceIdSource as ln,setServerDataGetter as fn}from"@fluixi/reactive/signal";var cn="__FX_DATA__";var z;function xe(){let e=globalThis.__FX_DATA__;if(e)return e;if(z!==void 0)return z;let n=null;if(typeof document<"u"){let t=document.getElementById(cn)?.textContent;if(t)try{n=JSON.parse(t)}catch{n=null}}return z=n}function _(){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 un=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),D=typeof process<"u"&&process.env&&!1;function F(e,n){let t=n.nodeType===1?`<${n.tagName.toLowerCase()}>`:n.nodeType===3?`text ${JSON.stringify((n.nodeValue??"").slice(0,24))}`:n.nodeType===8?"comment":"node";console.warn(`[fluixi] hydration mismatch: expected ${e} but the server DOM has ${t}. 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 dn(e){_();let n=u.cursor;return n&&n.nodeType===1&&n.tagName.toLowerCase()===e.toLowerCase()?(un.has(e.toLowerCase())?u.cursor=n.nextSibling:(u.parents.push(n),u.cursor=n.firstChild),n):(D&&n&&F(`<${e}>`,n),null)}function pn(e){_();let n=u.cursor;return n&&n.nodeType===1&&n.tagName.toLowerCase()===e.toLowerCase()?(u.cursor=n.nextSibling,n):(D&&n&&F(`<${e}> (static)`,n),null)}function yn(e){if(e===""){let t=u.cursor;return t&&t.nodeType===3&&t.data!==""?(u.cursor=t.nextSibling,t.data="",t):null}_();let n=u.cursor;return n&&n.nodeType===3?(u.cursor=n.nextSibling,n.nodeValue!==e&&(n.nodeValue=e),n):(D&&n&&F(`text ${JSON.stringify(e.slice(0,24))}`,n),null)}function mn(e){_();let n=u.cursor;return n&&n.nodeType===8&&n.data===e?(u.cursor=n.nextSibling,n):(D&&n&&F(`marker <!--${e.slice(0,24)}-->`,n),null)}var be=!1;function hn(){be||(be=!0,se({hydrateElement:dn,hydrateText:yn,hydrateMarker:mn,hydrateStatic:pn}))}function Te(e,n,t){hn(),u.active=!0,u.cursor=n.firstChild,u.parents=[];let o=xe(),i=t?.resourceNamespace,a=0;ln(()=>i?`${i}:r${a++}`:`r${a++}`),fn(o?c=>c in o?{value:o[c]}:void 0:null);try{return G(e,n)}finally{u.active=!1,u.cursor=null,u.parents=[]}}import{createChildOwner as gn,createMemo as X,disposeScope as xn,getOwner as bn,runWithOwner as Tn,untrack as Se}from"@fluixi/reactive/signal";function Ee(e){return typeof e=="function"?e:(()=>e)}function N(e){return()=>{let n=e();return typeof n=="function"?n():n}}function we(e){return e!=null&&e!==!1}function Ne(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function Ae(e){let n=N(()=>e.when),t=X(n,void 0,{name:"Show.when"}),o=X(t,void 0,{name:"Show.cond"}),i=bn(),a=null,c=null,s=r=>{r!==c&&(a&&xn(a),a=gn(i),c=r)};return X(()=>{let r=o();return s(r?"when":"fallback"),Tn(a,()=>{if(r){let l=e.children;return typeof l=="function"&&!Ne(l)?typeof t=="function"?Se(()=>Se(t)?l(t()):e.fallback):l(t):l}return e.fallback});return e.fallback??null},void 0,{name:"Show.result"})}import{mapArray as En,keyArray as wn}from"@fluixi/reactive/signal";function ve(e){let n=N(()=>e.each),t=()=>e.fallback??null,o=(i,a)=>{let c=e.children,s=Array.isArray(c)?c.map(r=>typeof r=="function"?r(i,a):r):typeof c=="function"?c(i,a):c;return M(s),s};return e.by?wn(n,e.by,(i,a)=>o(i,a),{fallback:t}):En(n,(i,a)=>o(i,a),{fallback:t})}import{indexArray as Nn}from"@fluixi/reactive/signal";function Ce(e){let n=N(()=>e.each);return Nn(n,(t,o)=>{let i=e.children(t,o);return M(i),i},{fallback:()=>e.fallback??null})}import{mapArray as Hn,keyArray as Vn,indexArray as Un}from"@fluixi/reactive/signal";import{createMemo as Sn,createChildOwner as An,disposeScope as vn,getOwner as Cn,runWithOwner as Pe}from"@fluixi/reactive/signal";var J=Symbol("match");function Re(e){return{[J]:!0,when:N(()=>e.when),get children(){return e.children}}}function Me(e){let n=Array.isArray(e.children)?e.children:[e.children],t=Cn(),o=null,i=-1,a=c=>{c!==i&&(o&&vn(o),o=An(t),i=c)};return Sn(()=>{for(let c=0;c<n.length;c+=1){let r=n[c],l=0;for(;typeof r=="function"&&!r[J]&&l++<10;)r=r();if(!r||typeof r!="object"||r[J]!==!0)continue;let f=r.when();if(we(f))return a(c),Pe(o,()=>typeof r.children=="function"?r.children(f):r.children)}return a(-2),Pe(o,()=>e.fallback??null)},void 0,{name:"Switch"})}import{createMemo as Pn,createChildOwner as Rn,disposeScope as Mn,getOwner as kn,runWithOwner as Ln}from"@fluixi/reactive/signal";function ke(e){let n=Ee(e.component),{component:t,...o}=e,i=kn(),a=null,c;return Pn(()=>{let s=n();return s!==c&&(a&&Mn(a),a=Rn(i),c=s),s==null?null:typeof s=="string"?{tag:s,props:o}:Ln(a,()=>s(o))},void 0,{name:"Dynamic"})}import{createRoot as On,onCleanup as _n}from"@fluixi/reactive/signal";function Le(e){let n=()=>e.mount?typeof e.mount=="function"?e.mount():e.mount:document.body,t,o;return On(i=>{t=i,o=document.createElement("div"),o.style.display="contents",n().appendChild(o),P(o,e.children)&&q(e.ref,o)}),_n(()=>{t(),o.remove()}),null}import{createMemo as Dn,createSignal as Fn}from"@fluixi/reactive/signal";function Oe(e){let[n,t]=Fn(null),o=()=>t(null);return Dn(()=>{let i=n();if(i!==null)return typeof e.fallback=="function"?e.fallback(i,o):e.fallback;try{return typeof e.children=="function"?e.children():e.children}catch(a){return t(a),typeof e.fallback=="function"?e.fallback(a,o):e.fallback}},void 0,{name:"ErrorBoundary"})}import{createMemo as jn}from"@fluixi/reactive/signal";function _e(e){return jn(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,i]of Object.entries(n)){if(!o)continue;(typeof i=="function"?i():i)&&t.push(o)}return t.join(" ")},void 0,{name:"ClassMap"})}import{createMemo as $n}from"@fluixi/reactive/signal";function In(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}function De(e){return $n(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,i]of Object.entries(n)){if(!o)continue;let a=typeof i=="function"?i():i;a!=null&&t.push(`${In(o)}: ${a}`)}return t.join("; ")},void 0,{name:"StyleMap"})}import{signal as So,memo as Ao,effect as vo,store as Co,createSignal as Po,createMemo as Ro,createEffect as Mo,createComputed as ko,createRenderEffect as Lo,createRoot as Oo,createResource as _o,createContext as Do,useContext as Fo,onCleanup as jo,batch as $o,untrack as Io}from"@fluixi/reactive";export{ke as Dynamic,Oe as ErrorBoundary,ve as For,Ce as Index,Re as Match,Le as Portal,Ae as Show,Me as Switch,$o as batch,_e as classMap,an as createComponent,ko as createComputed,Do as createContext,Mo as createEffect,$e as createElement,Ro as createMemo,Lo as createRenderEffect,_o as createResource,Oo as createRoot,Po as createSignal,me as delegateEvents,vo as effect,Te as hydrate,Un as indexArray,P as insert,Vn as keyArray,Hn as mapArray,Ao as memo,jo as onCleanup,G as render,T as setAttribute,O as setClassName,C as setProperty,B as setStyle,So as signal,nn as spread,Co as store,De as styleMap,Io as untrack,Fo 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
+ };