@fluixi/compiler 1.0.0-alpha.79 → 1.0.0-alpha.80

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 (48) hide show
  1. package/dist/analyze/intrinsics.cjs +1 -1
  2. package/dist/analyze/intrinsics.js +1 -1
  3. package/dist/analyze/intrinsics.mjs +1 -1
  4. package/dist/analyze/reactive-bindings.cjs +1 -1
  5. package/dist/analyze/reactive-bindings.mjs +1 -1
  6. package/dist/babel-4JUDAR2G.mjs +1 -0
  7. package/dist/{chunk-5DJ424I7.mjs → chunk-PVR2SN3B.mjs} +1 -1
  8. package/dist/{chunk-SZPI4R7H.mjs → chunk-QUIYULS2.mjs} +1 -1
  9. package/dist/{chunk-Y7E6OX3A.mjs → chunk-YR3SAEO7.mjs} +1 -1
  10. package/dist/frontend/babel/index.cjs +1 -1
  11. package/dist/frontend/babel/index.mjs +1 -1
  12. package/dist/frontend/babel/plugin.cjs +1 -1
  13. package/dist/frontend/babel/plugin.d.ts +1 -1
  14. package/dist/frontend/babel/plugin.js +5 -5
  15. package/dist/frontend/babel/plugin.mjs +1 -1
  16. package/dist/index.cjs +1 -1
  17. package/dist/index.mjs +1 -1
  18. package/dist/integrations.cjs +2 -2
  19. package/dist/integrations.d.ts +1 -1
  20. package/dist/integrations.mjs +2 -2
  21. package/dist/lower/compile-template.cjs +1 -1
  22. package/dist/lower/compile-template.d.ts +3 -2
  23. package/dist/lower/compile-template.d.ts.map +1 -1
  24. package/dist/lower/compile-template.js +2 -2
  25. package/dist/lower/compile-template.mjs +1 -1
  26. package/dist/resolve/builtins.cjs +1 -1
  27. package/dist/resolve/builtins.d.ts +3 -3
  28. package/dist/resolve/builtins.d.ts.map +1 -1
  29. package/dist/resolve/builtins.js +3 -3
  30. package/dist/resolve/builtins.mjs +1 -1
  31. package/dist/resolve/component-globals.cjs +1 -1
  32. package/dist/resolve/component-globals.mjs +1 -1
  33. package/dist/resolve/resolve-ir.cjs +1 -1
  34. package/dist/resolve/resolve-ir.mjs +1 -1
  35. package/dist/resolve/write-globals.cjs +1 -1
  36. package/dist/resolve/write-globals.mjs +1 -1
  37. package/dist/transform/index.cjs +3 -3
  38. package/dist/transform/index.mjs +5 -5
  39. package/dist/transform/intrinsics.cjs +1 -1
  40. package/dist/transform/intrinsics.mjs +1 -1
  41. package/dist/transform/templates.cjs +3 -3
  42. package/dist/transform/templates.js +4 -4
  43. package/dist/transform/templates.mjs +3 -3
  44. package/dist/transform-5WC4FWJE.mjs +8 -0
  45. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  46. package/package.json +9 -3
  47. package/dist/babel-FPDLKOXR.mjs +0 -1
  48. package/dist/transform-ERQ6CKFE.mjs +0 -8
@@ -1,7 +1,7 @@
1
- "use strict";var ht=Object.create;var K=Object.defineProperty;var yt=Object.getOwnPropertyDescriptor;var Nt=Object.getOwnPropertyNames;var vt=Object.getPrototypeOf,xt=Object.prototype.hasOwnProperty;var Rt=(e,t)=>{for(var n in t)K(e,n,{get:t[n],enumerable:!0})},Ee=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Nt(t))!xt.call(e,o)&&o!==n&&K(e,o,{get:()=>t[o],enumerable:!(r=yt(t,o))||r.enumerable});return e};var Ie=(e,t,n)=>(n=e!=null?ht(vt(e)):{},Ee(t||!e||!e.__esModule?K(n,"default",{value:e,enumerable:!0}):n,e)),kt=e=>Ee(K({},"__esModule",{value:!0}),e);var Pn={};Rt(Pn,{transformTemplates:()=>Cn});module.exports=kt(Pn);var dt=require("@babel/parser"),ut=Ie(require("magic-string"),1);function bt(e){switch(e.kind){case"event":return"event";case"ref":return"ref";case"spread":return"spread";case"class":case"style":return"class-or-style-directive";case"attr":case"prop":return e.reactive?"reactive-prop":e.expr!==void 0?"expression-prop":void 0;default:return"expression-prop"}}function P(e){let t=[],n=new Map,r=o=>{switch(o.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let s of o.children)r(s);return!1;case"fragment":for(let s of o.children)r(s);return!1;case"element":{let s=!0;for(let a of o.children)r(a)||(s=!1);let i;for(let a of o.props)if(i=bt(a),i)break;return!i&&!s&&(i=St(o)),o.static=!i,i?n.set(o,i):t.push(o),o.static}default:return!1}};for(let o of Array.isArray(e)?e:[e])r(o);return{staticElements:t,reasons:n}}function St(e){for(let t of e.children){if(t.kind==="expr")return"expression-child";if(t.kind==="component")return"component-child";if(t.kind==="control")return"control-child";if(t.kind==="element"&&!t.static||t.kind==="fragment")return"expression-child"}return"expression-child"}var G={kind:"eager"},Et=["pointerdown","focusin","keydown"],we=new Set(["eager","idle","visible","interaction","media","never"]),I=class extends Error{};function le(e){return e.startsWith("load:")}function Z(e,t){let n=e.slice(5);if(!we.has(n))throw new I(`Unknown load strategy 'load:${n}'. Expected one of ${[...we].join(", ")}.`);switch(n){case"eager":return G;case"idle":return{kind:"idle"};case"never":return{kind:"never"};case"visible":return t?{kind:"visible",rootMargin:t}:{kind:"visible"};case"interaction":return{kind:"interaction",events:t?It(t):[...Et]};case"media":if(!t)throw new I(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:t};default:throw new I(`Unhandled load strategy '${n}'.`)}}function It(e){let t=e.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean);if(t.length===0)throw new I("'load:interaction' was given no event names.");return t}function L(e){return e.kind!=="eager"&&e.kind!=="never"}var j=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],J=["Suspense","SuspenseList","Await"],M=["Router","Outlet","Redirect","Link"],An=[...j,...J,...M],ce=new Set([...j,...J]);function Ce(e={}){let{controlFlowModule:t="@fluixi/dom",coreModule:n="fluixi",routerModule:r="fluixi/router"}=e,o={};for(let s of j)o[s]=t;for(let s of J)o[s]=n;for(let s of M)o[s]=r;return o}function Y(e,t={}){let{resolver:n,isBound:r,modules:o,strategyFor:s}=t,i=Ce(o),a=new Map,l=new Set,c=f=>{let{name:d}=f;if(!d||d.includes(".")||r?.(d))return;let g=p(d);if(!g){l.add(d);return}let m=g.origin==="builtin"&&ce.has(d)?G:s?.(f)??G;f.source={...g,loading:m},a.set(d,f.source)},p=f=>{if(ce.has(f))return{module:i[f],export:f,origin:"builtin"};let d=n?.resolve(f);if(d)return{module:d.module,export:d.export,origin:"rule"};if(M.includes(f))return{module:i[f],export:f,origin:"builtin"}};return Q(e,f=>{f.kind==="component"&&c(f)}),{resolved:a,unresolved:[...l]}}function Q(e,t){let n=Array.isArray(e)?e:[e];for(let r of n){t(r);let o=r.children;o&&Q(o,t)}}function ee(e){let t=[];Q(e,s=>{s.kind==="component"&&s.source&&t.push(s)});let n=new Set,r=new Set;for(let s of t){let{module:i,loading:a}=s.source;a.kind==="eager"&&n.add(i),a.kind==="never"&&r.add(i)}let o=new Map;for(let s of t){let i=s.source;L(i.loading)&&n.has(i.module)&&(i.loading={kind:"eager"},o.set(i.module,(o.get(i.module)??0)+1))}return{collapsed:o,conflicted:[...r].filter(s=>n.has(s))}}var wt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$e={className:"class",htmlFor:"for"},Ct=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),$t=new Set(["script","style","textarea","title"]);function pe(e){return $t.has(e)}function Te(e){return $e[e]??e}function B(e){return e.kind!=="attr"||e.expr!==void 0||e.name.includes(":")?!1:!Ct.has(e.name)}function de(e){if(!e.static||pe(e.tag))return!1;for(let t of e.props)if(!B(t))return!1;for(let t of e.children)if(t.kind!=="text"&&!(t.kind==="element"&&de(t)))return!1;return!0}function _(e){let t=e.props.map(Pt).filter(Boolean).join(""),n=`<${e.tag}${t}>`;return wt.has(e.tag)?n:`${n}${e.children.map(Tt).join("")}</${e.tag}>`}function Tt(e){if(e.kind==="text")return Ot(e.value);if(e.kind!=="element")throw new Error(`serializeStatic: unexpected ${e.kind}`);return _(e)}function Pt(e){let t=$e[e.name]??e.name,n=e.literal;return n===!0||n===void 0?` ${t}`:n===!1||n===null?"":` ${t}="${Mt(String(n))}"`}function Mt(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ot(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var Dt="<!--fx-->",At="<!--fx/-->";function ne(e){return e.kind==="expr"||e.kind==="component"||e.kind==="control"}function Lt(e){return e.kind==="text"||e.kind==="element"&&Pe(e)}function Pe(e){return e.svg||pe(e.tag)||!e.props.every(t=>B(t))?!1:e.children.every(t=>Lt(t)||ne(t))}function te(e){if(ne(e))return!0;let t=e.children;return t?t.some(te):!1}function Me(e){for(let t=0;t<e.children.length;t++){let n=e.children[t];if(n.kind==="text"&&(n.value===""||e.children[t+1]?.kind==="text"))return!1}return e.children.every(t=>t.kind!=="element"||Me(t))}function Oe(e){if(!Pe(e)||!Me(e)||!e.children.some(te))return null;let t=[],n=[],r=0,o=i=>{let a=`_n$${r++}`;return t.push({ref:a,expr:i}),a};return s(e,"_el$"),{html:jt(e),tag:e.tag,steps:t,holes:n};function s(i,a){let l=-1;i.children.forEach((p,f)=>{te(p)&&(l=f)});let c=null;for(let p=0;p<=l;p++){let f=i.children[p],d=c?`${c}.nextSibling`:`${a}.firstChild`;if(ne(f)){let m=o(d),h=o(`holeEnd(${m})`);n.push({parentRef:a,startRef:m,endRef:h,node:f}),c=h;continue}let g=o(d);f.kind==="element"&&te(f)&&s(f,g),c=g}}}function jt(e){return _(De(e)).split(Ae).join(Dt+At)}function De(e){return{...e,children:e.children.map(t=>ne(t)?{kind:"text",value:Ae}:t.kind==="element"?De(t):t)}}var Ae="\0fx-hole\0";var ue={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},zn={version:2,module:"@fluixi/dom",symbols:[...ue.symbols,"template","cloneTemplate","walk"]};var Jt={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function Bt(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function je(e){return Bt(e)?e:JSON.stringify(e)}function _t(e){return e.expr!==void 0?e.reactive?`() => (${e.expr})`:`(${e.expr})`:JSON.stringify(e.literal??!0)}function Ft(e){return e.expr!==void 0?`(${e.expr})`:JSON.stringify(e.literal??!0)}function Ht(e,t,n){let r=e.filter(a=>a.kind==="spread"),s=e.filter(a=>a.kind!=="spread").map(a=>`${je(a.name)}: ${_t(a)}`);t!=null&&s.push(`children: ${t}`);let i=`{ ${s.join(", ")} }`;return r.length>0?(n.add("mergeProps"),`mergeProps(${r.map(a=>a.expr).join(", ")}, ${i})`):i}function Je(e,t,n){return e.length===1?F(e[0],t,n):`[${e.map(r=>F(r,t,n)).join(", ")}]`}function Le(e,t,n,r,o){r.add("createMemo"),r.add("createComponent");let s=t.filter(c=>c.kind==="spread"),a=t.filter(c=>c.kind!=="spread").map(c=>`get ${je(c.name)}() { return ${Ft(c)}; }`);n.length>0&&a.push(`get children() { return ${Je(n,r,o)}; }`);let l=`{ ${a.join(", ")} }`;return s.length>0&&(r.add("mergeProps"),l=`mergeProps(${s.map(c=>c.expr).join(", ")}, ${l})`),`createMemo(() => createComponent(${e}, ${l}))`}function Vt(e,t){let n=Te(t.name),r=t.literal;return r===!0||r===void 0?`${e}.setAttribute(${JSON.stringify(n)}, "");`:r===!1||r===null?"":`${e}.setAttribute(${JSON.stringify(n)}, ${JSON.stringify(String(r))});`}var Be=!1;function F(e,t,n){switch(e.kind){case"text":return JSON.stringify(e.value);case"expr":return e.reactive?`() => (${e.code})`:`(${e.code})`;case"fragment":return e.children.length===0?"null":Je(e.children,t,n);case"component":return Le(e.name,e.props,e.children,t,n);case"control":{let r=Jt[e.control]??e.control;return t.add(r),Le(r,e.props,e.children,t,n)}case"element":{if(n&&e.static&&!e.svg&&de(e)){t.add("templateNode");let a=`_tmpl$${n.length}`;return n.push({id:a,html:_(e),tag:e.tag,svg:!1}),`templateNode(${a}, ${JSON.stringify(e.tag)})`}if(n&&Be){let a=Oe(e);if(a){t.add("templateNode"),t.add("insert"),t.add("holeEnd"),t.add("holeContent"),t.add("holeScope");let l=`_tmpl$${n.length}`;n.push({id:l,html:a.html,tag:a.tag,svg:!1});let c=[`const _el$ = templateNode(${l}, ${JSON.stringify(a.tag)}, true);`];for(let p of a.steps)c.push(`const ${p.ref} = ${p.expr};`);for(let p of a.holes)c.push(`insert(${p.parentRef}, holeScope(${p.startRef}, () => (${F(p.node,t,n)})), ${p.endRef}, holeContent(${p.startRef}, ${p.endRef}));`);return c.push("return _el$;"),`(() => { ${c.join(" ")} })()`}}t.add("createNativeElement");let r=JSON.stringify(e.tag),o="_el$",s=[],i=e.svg?`${r}, true`:r;if(s.push(`const ${o} = createNativeElement(${i});`),e.props.length>0)if(!e.svg&&e.props.every(B))for(let a of e.props)s.push(Vt(o,a));else{t.add("spread");let a=e.svg?", isSVG: true":"";s.push(`spread({ element: ${o}, props: ${Ht(e.props,null,t)}${a} });`)}for(let a of e.children){t.add("insert");let l=F(a,t,n),c=a.kind==="expr"&&a.reactive||a.kind==="component"||a.kind==="control";s.push(c?`insert(${o}, ${l}, null);`:`insert(${o}, ${l});`)}return s.push(`return ${o};`),`(() => { ${s.join(" ")} })()`}}}function re(e,t){if(!t||t.length===0)return e;let n=new Map(t.map(r=>[r.id,JSON.stringify(r.html)]));return e.replace(/_tmpl\$\d+/g,r=>n.get(r)??r)}var O={name:"imperative",contract:ue,emit(e,t){let n=new Set,r=t?.templateClone!==!1?[]:void 0;return Be=t?.partialTemplates===!0,{code:F(e,n,r),imports:Array.from(n),templates:r}}};var Xt=e=>"components"in e;function _e(e,t){return e.replace(/\$(\d+)/g,(n,r)=>t[Number(r)]??n)}function Ut(e,t){return typeof t=="string"?{module:t,export:e}:t}function oe(e=[]){let t=new Map,n=[],r=[];for(let i of e){if(!Xt(i)){r.push(i);continue}for(let[a,l]of Object.entries(i.components)){let c=Ut(a,l),p=t.get(a);if(p&&p.module!==c.module){let f=n.find(d=>d.name===a);f?f.modules.push(c.module):n.push({name:a,modules:[p.module,c.module]});continue}t.set(a,c)}}let o=new Map;return{resolve:i=>{if(o.has(i))return o.get(i);let a=t.get(i);if(!a)for(let l of r){let c=i.match(new RegExp(l.match.source,l.match.flags.replace("g","")));if(c){a={module:_e(l.module,c),export:l.export?_e(l.export,c):i};break}}return o.set(i,a),a},names:()=>[...t.keys()],conflicts:()=>n}}var Ve=require("@fluixi/template-parser");function H(e){let t=e.split(/\r\n|\n|\r/),n=0;for(let o=0;o<t.length;o++)/[^ \t]/.test(t[o])&&(n=o);let r="";for(let o=0;o<t.length;o++){let s=t[o].replace(/\t/g," ");o!==0&&(s=s.replace(/^ +/,"")),o!==t.length-1&&(s=s.replace(/ +$/,"")),s&&(o!==n&&(s+=" "),r+=s)}return r}var Fe=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function zt(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function He(e){return e.charAt(0).toUpperCase()+e.slice(1)}var fe=class{constructor(t,n){this.holes=t;this.used=n}hole(t){return this.holes[t]??{code:"undefined",reactive:!1}}emit(t){let{code:n,imports:r,templates:o}=O.emit(t,{});for(let s of r)this.used.add(s);return re(n,o)}lowerRoot(t){let n=this.lowerChildren(t);return n.length===1?n[0]:{kind:"fragment",children:n}}lowerChildren(t){let n=[];for(let r=0;r<t.length;r++){let o=t[r];if(o.kind==="Element"||o.kind==="Component"){let i=o.attributes.find(a=>a.kind==="IfDirective");if(i&&i.kind==="IfDirective"){let a=r+1;a<t.length&&this.isBlankText(t[a])&&a++;let l=t[a],c=l&&(l.kind==="Element"||l.kind==="Component")&&l.attributes.some(p=>p.kind==="ElseDirective");n.push(this.lowerIf(o,i.hole,c?l:null)),c&&(r=a);continue}if(o.attributes.some(a=>a.kind==="EachDirective")){n.push(this.lowerEach(o));continue}}let s=this.lowerNode(o);s&&n.push(s)}return n}isBlankText(t){return t.kind==="Text"&&!t.raw&&H(t.value)===""}lowerNode(t){switch(t.kind){case"Text":{if(t.raw)return{kind:"text",value:t.value};let n=H(t.value);return n?{kind:"text",value:n}:null}case"Comment":return null;case"Expression":{let n=this.hole(t.hole);return{kind:"expr",code:n.code,reactive:n.reactive}}case"Fragment":return{kind:"fragment",children:this.lowerChildren(t.children)};case"Element":return this.lowerElement(t);case"Component":return this.lowerComponent(t);default:return null}}lowerElement(t){let n=t.attributes.find(r=>r.kind==="Attribute"&&r.name==="is");if(t.tag==="component"&&n&&n.value&&n.value.kind==="hole"){let r=t.attributes.filter(s=>s!==n),o=this.lowerComponent({...t,kind:"Component",tag:"Dynamic",tagHole:null,attributes:r});return o.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(n.value.hole).code})`}),o}return{kind:"element",tag:t.tag,svg:t.namespace==="svg",props:this.lowerAttributes(t.attributes),children:this.lowerChildren(t.children),static:!1}}lowerComponent(t){let n=t.tagHole!=null?this.hole(t.tagHole).code:t.tag,r=this.lowerAttributes(t.attributes),{slots:o,rest:s}=this.partitionSlots(t.children);for(let[l,c]of o){let p=c.length===1?c[0]:{kind:"fragment",children:c},f={name:l,kind:"attr",expr:this.emit(p),jsxElement:!0},d=r.findIndex(g=>g.name===l);d>=0?r[d]=f:r.push(f)}let i=t.attributes.find(l=>l.kind==="LoadDirective"),a=i?Z(`load:${i.strategy}`,i.modifier):void 0;return{kind:"component",name:n,props:r,children:this.lowerChildren(s),...a?{load:a}:{}}}partitionSlots(t){let n=new Map,r=[];for(let o of t){if(o.kind==="Element"||o.kind==="Component"){let s=o.attributes.find(i=>i.kind==="Attribute"&&i.name==="slot");if(s&&s.value&&s.value.kind==="static"){let i={...o,attributes:o.attributes.filter(c=>c!==s)},a=i.kind==="Element"?this.lowerElement(i):this.lowerComponent(i),l=n.get(s.value.value)??[];l.push(a),n.set(s.value.value,l);continue}}r.push(o)}return{slots:n,rest:r}}lowerIf(t,n,r){let o=this.hole(n),s=[{name:"when",kind:"attr",expr:o.code,reactive:o.reactive}];if(r){let a=this.stripAndLower(r,l=>l.kind==="ElseDirective");s.push({name:"fallback",kind:"attr",expr:this.emit(a),jsxElement:!0})}let i=this.stripAndLower(t,a=>a.kind==="IfDirective");return{kind:"component",name:"Show",props:s,children:[i]}}lowerEach(t){let n=t.attributes.find(l=>l.kind==="EachDirective");if(!n||n.kind!=="EachDirective")return this.lowerNode(t);let r=this.hole(n.hole),o=[{name:"each",kind:"attr",expr:r.code,reactive:r.reactive}];if(n.key){let l="static"in n.key?`(item) => item[${JSON.stringify(n.key.static)}]`:this.hole(n.key.hole).code;o.push({name:"by",kind:"attr",expr:l})}let s=this.itemArrow(t),i;if(s){let l={kind:"expr",code:s.body,reactive:s.bodyReactive},c=this.rebuildWithChildren(t,[l]);i=`(${s.params.join(", ")}) => (${this.emit(c)})`}else{let l=this.stripAndLower(t,c=>c.kind==="EachDirective");i=`() => (${this.emit(l)})`}return{kind:"component",name:"For",props:o,children:[{kind:"expr",code:i,reactive:!1}]}}itemArrow(t){let n=t.children.filter(r=>!this.isBlankText(r));return n.length!==1||n[0].kind!=="Expression"?null:this.hole(n[0].hole).arrow??null}stripAndLower(t,n){let r={...t,attributes:t.attributes.filter(o=>!n(o))};return r.kind==="Element"?this.lowerElement(r):this.lowerComponent(r)}rebuildWithChildren(t,n){let r=this.lowerAttributes(t.attributes.filter(o=>o.kind!=="EachDirective"));return t.kind==="Element"?{kind:"element",tag:t.tag,svg:t.namespace==="svg",props:r,children:n,static:!1}:{kind:"component",name:t.tag,props:r,children:n}}lowerAttributes(t){let n=[],r=[],o=!1,s=[],i=!1,a=[];for(let l of t)switch(l.kind){case"IfDirective":case"EachDirective":case"ElseDirective":break;case"Attribute":n.push(this.plainAttr(l));break;case"PropertyBinding":n.push({name:l.name,kind:"prop",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"EventBinding":n.push(this.eventProp(l));break;case"RefBinding":n.push({name:"ref",kind:"ref",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"Spread":n.push({name:"",kind:"spread",expr:this.hole(l.hole).code});break;case"ClassDirective":{let c=this.hole(l.hole);r.push(`${JSON.stringify(l.name)}: ${c.code}`),o=o||c.reactive;break}case"StyleDirective":{let c=this.hole(l.hole);s.push(`${JSON.stringify(l.name)}: ${c.code}`),i=i||c.reactive;break}case"BindDirective":n.push(...this.bindProps(l.name,this.hole(l.hole).code));break;case"UseDirective":{let c=l.name??(l.hole!=null?this.hole(l.hole).code:null);if(!c)break;a.push(l.name!=null&&l.hole!=null?`[${c}, () => (${this.hole(l.hole).code})]`:`[${c}]`);break}}return r.length>0&&n.push({name:"classList",kind:"attr",expr:`{ ${r.join(", ")} }`,reactive:o}),s.length>0&&n.push({name:"style",kind:"attr",expr:`{ ${s.join(", ")} }`,reactive:i}),a.length>0&&n.push({name:"use",kind:"attr",expr:`[${a.join(", ")}]`}),n}eventProp(t){let n=t.name.toLowerCase(),r=this.hole(t.hole).code;if(!(t.syntax==="colon"||t.modifiers.length>0))return{name:"on"+He(t.name),kind:"event",event:{name:n,delegated:Fe.has(n)},expr:r};let s=this.wrapHandler(r,t.modifiers),i=this.eventOptions(t.modifiers),a=i?`[${s}, ${i}]`:s;return{name:"on:"+n,kind:"attr",expr:a}}wrapHandler(t,n){let r=n.includes("self")?"if (e.target !== e.currentTarget) return; ":"",o=[];return n.includes("prevent")&&o.push("e.preventDefault();"),n.includes("stop")&&o.push("e.stopPropagation();"),!r&&o.length===0?t:`(e) => { ${r}${o.join(" ")} return (${t})(e); }`}eventOptions(t){let n=[];return t.includes("capture")&&n.push("capture: true"),t.includes("once")&&n.push("once: true"),t.includes("passive")&&n.push("passive: true"),n.length?`{ ${n.join(", ")} }`:null}bindProps(t,n){let r=t==="checked",o=r?"change":"input",s=r?"checked":"value";this.used.add("bindPair");let i=`bindPair(${n})`;return[{name:t,kind:"attr",expr:`${i}[0]()`,reactive:!0},{name:"on"+He(o),kind:"event",event:{name:o,delegated:Fe.has(o)},expr:`(e) => ${i}[1](e.target.${s})`}]}plainAttr(t){let n=t.value,r=t.name;t.name==="class"?r=n&&n.kind==="hole"&&this.hole(n.hole).object?"classList":"className":t.name==="html"&&(r="innerHTML");let s={name:r,kind:"attr"};if(n==null)return s.literal=!0,s;if(n.kind==="static")return s.literal=n.value,s;if(n.kind==="hole"){let l=this.hole(n.hole);return s.expr=l.code,s.reactive=l.reactive,s}let i=!1,a=n.parts.map(l=>{if("text"in l)return zt(l.text);let c=this.hole(l.hole);return i=i||c.reactive,"${"+c.code+"}"}).join("");return s.expr="`"+a+"`",s.reactive=i,s}};function Xe(e,t,n,r={}){let{root:o}=(0,Ve.parseTemplate)(e,{svg:r.svg});return new fe(t,n).lowerRoot(o.children)}function Ue(e,t,n={}){let r=new Set,o=Xe(e,[...t],r,{svg:n.svg});P(o),Y(o,{resolver:oe(n.resolve??[]),modules:{controlFlowModule:n.controlFlowModule??"@fluixi/dom",coreModule:n.coreModule??"fluixi",routerModule:n.routerModule??"fluixi/router"},strategyFor:l=>l.load}),ee(o);let{code:s,imports:i,templates:a}=O.emit(o,{templateClone:n.templateClone,partialTemplates:n.partialTemplates});for(let l of i)r.add(l);return n.hoistTemplates?{code:s,imports:[...r],ir:o,templates:a}:{code:re(s,a),imports:[...r],ir:o}}var Wt="children";function D(e){switch(e.kind){case"call":return!0;case"member":return e.property!==Wt;case"compound":return e.parts.some(D);case"opaque":return!1}}var qt=new Set(["CallExpression","OptionalCallExpression"]),Kt=new Set(["MemberExpression","OptionalMemberExpression"]);function A(e){if(!e)return{kind:"opaque"};if(qt.has(e.type))return{kind:"call"};if(Kt.has(e.type)){let t=e.property;return{kind:"member",property:!(e.computed===!0)&&t?.type==="Identifier"?t.name:null}}return e.type==="ConditionalExpression"?{kind:"compound",parts:[e.test,e.consequent,e.alternate].map(V)}:e.type==="LogicalExpression"||e.type==="BinaryExpression"?{kind:"compound",parts:[e.left,e.right].map(V)}:e.type==="TemplateLiteral"?{kind:"compound",parts:e.expressions.map(V)}:e.type==="ObjectExpression"?{kind:"compound",parts:e.properties.filter(n=>(n.type==="ObjectProperty"||n.type==="Property")&&n.computed!==!0).map(n=>V(n.value))}:e.type==="ArrayExpression"?{kind:"compound",parts:e.elements.filter(n=>n!=null&&n.type!=="SpreadElement").map(V)}:{kind:"opaque"}}var V=e=>A(e);var Gt=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),Zt=/^on[A-Z]/,Yt=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]),qe=e=>D(A(e));function X(e){if(e.type==="StringLiteral"||e.type==="NumericLiteral"||e.type==="BooleanLiteral"||e.type==="Literal"&&(typeof e.value=="string"||typeof e.value=="number"||typeof e.value=="boolean"))return e.value}var me=e=>!!e&&typeof X(e)=="string";function Qt(e,t){return e.type==="JSXIdentifier"?{tag:e.name,component:e.name[0]!==e.name[0].toLowerCase()}:e.type==="JSXMemberExpression"?{tag:t.code(e),component:!0}:e.type==="JSXNamespacedName"?{tag:`${e.namespace.name}:${e.name.name}`,component:!1}:{tag:"div",component:!1}}function ge(e){return e.type==="JSXIdentifier"?e.name==="class"?"className":e.name:e.type==="JSXNamespacedName"?`${e.namespace.name}:${e.name.name}`:"unknown"}function en(e,t){let n=ge(e.name),r=Zt.test(n),o=r||n.startsWith("on:")||n==="ref",i={name:n,kind:r?"event":"attr"};if(r){let l=n.slice(2).toLowerCase();i.event={name:l,delegated:Yt.has(l)}}let a=e.value;if(a==null)return i.literal=!0,i;if(me(a))return i.literal=X(a),i;if(a.type==="JSXExpressionContainer"&&a.expression?.type!=="JSXEmptyExpression"){let l=a.expression,c=X(l);return c!==void 0?(i.literal=c,i):(i.expr=t.code(l),i.reactive=o?!1:qe(l),(l.type==="JSXElement"||l.type==="JSXFragment")&&(i.jsxElement=!0),i)}return i.literal=!0,i}function ze(e,t){let n=e.value;return n==null?null:me(n)?JSON.stringify(X(n)):n.type==="JSXExpressionContainer"&&n.expression?.type!=="JSXEmptyExpression"?t.code(n.expression):null}function tn(e,t){let n=[],r=[];for(let o of e){if(o.type==="JSXSpreadAttribute"){n.push({name:"",kind:"spread",expr:t.code(o.argument)});continue}if(o.type!=="JSXAttribute"||le(ge(o.name)))continue;let s=o.name.type==="JSXNamespacedName"?o.name.namespace.name:null;if(s==="use"){let i=o.name.name.name;t.used.add(i);let a=ze(o,t);r.push(a!=null?`[${i}, () => (${a})]`:`[${i}]`);continue}if(s==="oncapture"){let i=o.name.name.name.toLowerCase(),a=ze(o,t)??"undefined";n.push({name:"on:"+i,kind:"attr",expr:`[${a}, { capture: true }]`});continue}n.push(en(o,t))}return r.length>0&&n.push({name:"use",kind:"attr",expr:`[${r.join(", ")}]`}),n}function We(e,t){let n=[];for(let r of e)if(r.type==="JSXText"){let o=H(r.value);o&&n.push({kind:"text",value:o})}else if(r.type==="JSXExpressionContainer"){if(r.expression?.type!=="JSXEmptyExpression"){let o=r.expression;n.push({kind:"expr",code:t.code(o),reactive:qe(o)})}}else r.type==="JSXElement"||r.type==="JSXFragment"?n.push(Ke(r,t)):r.type==="JSXSpreadChild"&&n.push({kind:"expr",code:t.code(r.expression),reactive:!1});return n}function nn(e){for(let t of e){if(t.type!=="JSXAttribute")continue;let n=ge(t.name);if(le(n)){if(t.value&&!me(t.value))throw new I(`'${n}' needs a literal value, not an expression — the strategy is compile-time.`);return Z(n,t.value?X(t.value):null)}}}function Ke(e,t){if(e.type==="JSXFragment")return{kind:"fragment",children:We(e.children,t)};let{tag:n,component:r}=Qt(e.openingElement.name,t),o=tn(e.openingElement.attributes,t),s=We(e.children,t);if(r){let i=nn(e.openingElement.attributes);return{kind:"component",name:n,props:o,children:s,...i?{load:i}:{}}}return{kind:"element",tag:n,svg:Gt.has(n),props:o,children:s,static:!1}}function Ge(e,t){let n=Ke(e,t);return P(n),n}function w(e,t){if(e)switch(e.type){case"Identifier":t.add(e.name);return;case"ObjectPattern":for(let n of e.properties)n.type==="RestElement"?w(n.argument,t):w(n.value,t);return;case"ArrayPattern":for(let n of e.elements)w(n,t);return;case"AssignmentPattern":w(e.left,t);return;case"RestElement":w(e.argument,t);return}}function Ze(e,t){switch(e.type){case"ImportDeclaration":for(let n of e.specifiers)w(n.local,t);return;case"VariableDeclaration":for(let n of e.declarations)w(n.id,t);return;case"FunctionDeclaration":case"ClassDeclaration":w(e.id,t);return;case"ExportNamedDeclaration":case"ExportDefaultDeclaration":e.declaration&&Ze(e.declaration,t);return}}function he(e){let t=new Set;for(let n of e.body)Ze(n,t);return t}var sn=require("@babel/parser"),an=Ie(require("magic-string"),1);function k(e,t){if(e)switch(e.type){case"Identifier":t.add(e.name);return;case"ObjectPattern":for(let n of e.properties)n.type==="RestElement"?k(n.argument,t):k(n.value,t);return;case"ArrayPattern":for(let n of e.elements)k(n,t);return;case"AssignmentPattern":k(e.left,t);return;case"RestElement":k(e.argument,t);return}}function ye(e){switch(e.type){case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":case"NullLiteral":case"BigIntLiteral":case"RegExpLiteral":case"Identifier":return!0;case"Literal":return!0;case"TemplateLiteral":return e.expressions.every(ye);case"UnaryExpression":return ye(e.argument);case"MemberExpression":return!1;default:return!1}}function se(e,t){if(!(!e||typeof e!="object")){t(e);for(let n of Object.keys(e)){if(n==="loc"||n==="range"||n==="leadingComments"||n==="trailingComments")continue;let r=e[n];if(Array.isArray(r))for(let o of r)o&&typeof o=="object"&&se(o,t);else r&&typeof r=="object"&&typeof r.type=="string"&&se(r,t)}}}function rn(e){let t=new Set;return se(e,n=>{if(n.type==="AssignmentExpression")k(n.left,t);else if(n.type==="UpdateExpression"){let r=n.argument;r?.type==="Identifier"&&t.add(r.name)}}),t}function on(e,t){let n=new Set,r=o=>{let s=new Set;k(o,s);for(let i of s)t.has(i)&&n.add(i)};return se(e,o=>{switch(o.type){case"VariableDeclarator":r(o.id);return;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":r(o.id);for(let s of o.params??[])r(s);return;case"CatchClause":r(o.param);return;case"ClassDeclaration":case"ClassExpression":r(o.id);return}}),n}function Ye(e,t,n){for(let r of e.properties??[]){if(r.type==="RestElement"){let p=r.argument;if(p?.type!=="Identifier"||t.length>0){let f=new Set;k(p,f);for(let d of f)n.bails.push({name:d,reason:"rest"});continue}n.rest={name:p.name,keys:[]};continue}if(r.computed){let p=new Set;k(r.value,p);for(let f of p)n.bails.push({name:f,reason:"computed"});continue}let o=r.key,s=o.type==="Identifier"?o.name:o.value,i=r.value,a;i.type==="AssignmentPattern"&&(a=i.right,i=i.left);let l=[...t,s];if(i.type==="Identifier"){if(a&&!ye(a)){n.bails.push({name:i.name,reason:"unsafe-default"});continue}n.reads.push({name:i.name,path:l,...a?{fallback:a}:{}});continue}if(i.type==="ObjectPattern"){if(a){let p=new Set;k(i,p);for(let f of p)n.bails.push({name:f,reason:"unsafe-default"});continue}Ye(i,l,n);continue}let c=new Set;k(i,c);for(let p of c)n.bails.push({name:p,reason:"computed"})}}function Qe(e,t){let n={reads:[],bails:[]};if(e?.type!=="ObjectPattern"||(Ye(e,[],n),n.rest&&(t?.type!=="BlockStatement"?(n.bails.push({name:n.rest.name,reason:"rest"}),delete n.rest):n.rest.keys=(e.properties??[]).filter(a=>a.type!=="RestElement"&&!a.computed).map(a=>{let l=a.key;return l.type==="Identifier"?l.name:l.value})),n.reads.length===0&&!n.rest))return n;let r=new Set(n.reads.map(a=>a.name));n.rest&&r.add(n.rest.name);let o=rn(t),s=on(t,r),i=[];for(let a of n.reads)o.has(a.name)?n.bails.push({name:a.name,reason:"reassigned"}):s.has(a.name)?n.bails.push({name:a.name,reason:"shadowed"}):i.push(a);return n.reads=i,n.rest&&o.has(n.rest.name)?(n.bails.push({name:n.rest.name,reason:"reassigned"}),delete n.rest):n.rest&&s.has(n.rest.name)&&(n.bails.push({name:n.rest.name,reason:"shadowed"}),delete n.rest),n}function et(e){switch(e){case"rest":return"this rest element cannot be served by splitProps, and copying the props into a plain object would lose the getters";case"computed":return"the property is not known until it runs";case"reassigned":return"the binding is assigned to, and props are read-only";case"shadowed":return"an inner scope binds the same name";case"unsafe-default":return"the default would have to run again on every read"}}function U(e,t,n=null){if(!(!e||typeof e!="object"||typeof e.type!="string")&&!e.type.startsWith("TS")&&t(e,n)!==!1)for(let r of Object.keys(e)){if(r==="loc"||r==="leadingComments"||r==="trailingComments")continue;let o=e[r];if(Array.isArray(o))for(let s of o)U(s,t,e);else o&&typeof o=="object"&&U(o,t,e)}}function tt(e){return!!e&&e[0]>="A"&&e[0]<="Z"}function ln(e){let t=[];return U(e,n=>{if(n.type==="FunctionDeclaration"&&tt(n.id?.name)){t.push(n);return}if(n.type==="VariableDeclarator"&&tt(n.id?.name)){let r=n.init;r&&(r.type==="ArrowFunctionExpression"||r.type==="FunctionExpression")&&t.push(r)}}),t}function cn(e){let t=new Set;return U(e,n=>{n.type==="Identifier"&&t.add(n.name)}),t}function pn(e,t){if(!t)return!0;switch(t.type){case"MemberExpression":case"OptionalMemberExpression":return!(t.property===e&&!t.computed);case"ObjectProperty":case"ObjectMethod":case"ClassProperty":case"ClassMethod":return!(t.key===e&&!t.computed);case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return t.label!==e;case"ImportSpecifier":case"ExportSpecifier":return!1;default:return!0}}function nt(e,t,n={}){let r=[],o=[],s=new Set;for(let i of ln(e)){let a=i.params?.[0];if(a?.type!=="ObjectPattern")continue;let l=Qe(a,i.body);for(let m of l.bails)o.push({name:m.name,reason:m.reason,message:et(m.reason),start:a.start});if(l.bails.length>0||l.reads.length===0&&!l.rest)continue;let c=cn(i),p=n.parameterName??"props";for(;c.has(p);)p=`_${p}`;let f=new Map;for(let m of l.reads){let h=`${p}.${m.path.join(".")}`,v=m.fallback;f.set(m.name,v?`(${h} === undefined ? ${t.slice(v.start,v.end)} : ${h})`:h)}let d=a.typeAnnotation;if(r.push({start:a.start,end:d?.start??a.end,code:p}),l.rest){let m=l.rest.keys.map(v=>JSON.stringify(v)).join(", "),h=i.body;r.push({start:h.start+1,end:h.start+1,code:`
2
- const [, ${l.rest.name}] = splitProps(${p}, [${m}]);`}),s.add("splitProps")}let g=[];U(i.body,(m,h)=>{if(m.type!=="Identifier")return;let v=f.get(m.name);if(!v)return;let S=h?.type==="ObjectProperty"&&h.shorthand&&h.value===m;if(!S&&!pn(m,h))return;let b=l.reads.find(C=>C.name===m.name).path;g.push({node:m,parent:S?h:null,text:v,property:b[b.length-1]})});for(let m of g)m.parent?r.push({start:m.parent.start,end:m.parent.end,code:`${m.node.name}: ${m.text}`}):r.push({start:m.node.start,end:m.node.end,code:m.text}),dn(m.node,p,m.property)}return{edits:r,diagnostics:o,used:s}}function dn(e,t,n){e.type="MemberExpression",e.computed=!1,e.optional=!1,e.object={type:"Identifier",name:t,start:e.start,end:e.start},e.property={type:"Identifier",name:n,start:e.end,end:e.end},delete e.name}var $="@fluixi/reactive/signal",T={$signal:{export:"signal",module:$,returns:"signal-handle"},$memo:{export:"memo",module:$,returns:"memo-handle"},$effect:{export:"effect",module:$,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:$,returns:"resource-handle"},$selector:{export:"createSelector",module:$,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:$,returns:"memo-accessor"},$untrack:{export:"untrack",module:$,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}},rt={signal:"signal-handle",memo:"memo-handle",effect:"effect",store:"store-handle",createSignal:["signal-accessor","signal-setter"],createMemo:"memo-accessor",createEffect:"effect",createRenderEffect:"effect",createStore:"reactive-object",resource:"resource-handle",createResource:"reactive-object",createSelector:"memo-accessor",createDeferred:"memo-accessor"},un=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/store","fluixi"],fn=new RegExp(`\\$(?:${Object.keys(T).map(e=>e.slice(1)).join("|")})\\s*\\(`);function ot(e){return fn.test(e)}function st(e){return Object.prototype.hasOwnProperty.call(T,e)}function it(e){return un.includes(e)}function y(e,t){if(e)switch(e.type){case"Identifier":t.add(e.name);return;case"ObjectPattern":for(let n of e.properties??[])n.type==="RestElement"?y(n.argument,t):y(n.value,t);return;case"ArrayPattern":for(let n of e.elements??[])y(n,t);return;case"AssignmentPattern":y(e.left,t);return;case"RestElement":y(e.argument,t);return}}function z(e,t){if(!(!e||typeof e!="object"||typeof e.type!="string")){t(e);for(let n of Object.keys(e)){if(n==="loc"||n==="leadingComments"||n==="trailingComments")continue;let r=e[n];if(Array.isArray(r))for(let o of r)z(o,t);else r&&typeof r=="object"&&z(r,t)}}}function mn(e,t){if(e.type!=="CallExpression")return;let n=e.callee;if(n?.type!=="Identifier")return;let r=n.name,o=t.primitives.get(r);if(o)return o;let s=T[r];if(s&&!t.shadowed.has(r))return s.returns}function gn(e,t,n){if(Array.isArray(t)){e.type==="ArrayPattern"&&e.elements.forEach((r,o)=>{let s=t[o];r?.type==="Identifier"&&s&&n.set(r.name,s)});return}e.type==="Identifier"&&n.set(e.name,t)}function at(e){let t=new Set;return z(e,n=>{switch(n.type){case"VariableDeclarator":y(n.id,t);return;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":y(n.id,t);for(let r of n.params??[])y(r,t);return;case"ClassDeclaration":case"ClassExpression":y(n.id,t);return;case"ImportSpecifier":case"ImportDefaultSpecifier":case"ImportNamespaceSpecifier":y(n.local,t);return;case"CatchClause":y(n.param,t);return}}),t}function lt(e){let t={kinds:new Map,primitives:new Map,shadowed:new Set},n=e;z(n,r=>{let o=new Set;if(r.type==="VariableDeclarator")y(r.id,o);else if(r.type==="FunctionDeclaration"||r.type==="ClassDeclaration")y(r.id,o);else if(r.type==="ImportDefaultSpecifier"||r.type==="ImportNamespaceSpecifier")y(r.local,o);else if(r.type==="ImportSpecifier")y(r.local,o);else if(r.type==="FunctionExpression"||r.type==="ArrowFunctionExpression"||r.type==="FunctionDeclaration")for(let s of r.params??[])y(s,o);for(let s of o)T[s]&&t.shadowed.add(s)});for(let r of n.body??[])if(r.type==="ImportDeclaration"&&it(r.source?.value))for(let o of r.specifiers??[]){if(o.type!=="ImportSpecifier")continue;let s=o.imported,i=s.type==="Identifier"?s.name:s.value,a=rt[i];a&&t.primitives.set(o.local.name,a)}return z(n,r=>{if(r.type!=="VariableDeclarator"||!r.init)return;let o=mn(r.init,t);o&&gn(r.id,o,t.kinds)}),t}function Ne(e,t){if(!(!e||typeof e!="object"||typeof e.type!="string")){t(e);for(let n of Object.keys(e)){if(n==="loc"||n==="leadingComments"||n==="trailingComments")continue;let r=e[n];if(Array.isArray(r))for(let o of r)Ne(o,t);else r&&typeof r=="object"&&Ne(r,t)}}}function ct(e){let t=[],n=[],r=new Map,o=new Set,{shadowed:s}=lt(e);return Ne(e,i=>{if(i.type!=="CallExpression")return;let a=i.callee;if(a?.type!=="Identifier")return;let l=a.name;if(!st(l))return;if(s.has(l)){o.has(l)||(o.add(l),n.push({name:l,message:`${l} is reserved for the compiler, and this module binds it. The call keeps your binding's meaning; rename it to use the intrinsic.`,start:a.start}));return}let c=T[l];t.push({start:a.start,end:a.end,code:c.export});let p=r.get(c.module)??new Set;p.add(c.export),r.set(c.module,p)}),{edits:t,diagnostics:n,imports:r}}function pt(e,t){let n=[];for(let[r,o]of[...e.imports].sort(([s],[i])=>s.localeCompare(i))){let s=[...o].filter(i=>!t.has(i)).sort();s.length&&n.push(`import { ${s.join(", ")} } from ${JSON.stringify(r)};`)}return n.length?`${n.join(`
1
+ "use strict";var ht=Object.create;var K=Object.defineProperty;var yt=Object.getOwnPropertyDescriptor;var Nt=Object.getOwnPropertyNames;var vt=Object.getPrototypeOf,xt=Object.prototype.hasOwnProperty;var Rt=(e,t)=>{for(var n in t)K(e,n,{get:t[n],enumerable:!0})},Ee=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Nt(t))!xt.call(e,o)&&o!==n&&K(e,o,{get:()=>t[o],enumerable:!(r=yt(t,o))||r.enumerable});return e};var Ie=(e,t,n)=>(n=e!=null?ht(vt(e)):{},Ee(t||!e||!e.__esModule?K(n,"default",{value:e,enumerable:!0}):n,e)),kt=e=>Ee(K({},"__esModule",{value:!0}),e);var Pn={};Rt(Pn,{transformTemplates:()=>Cn});module.exports=kt(Pn);var dt=require("@babel/parser"),ut=Ie(require("magic-string"),1);function bt(e){switch(e.kind){case"event":return"event";case"ref":return"ref";case"spread":return"spread";case"class":case"style":return"class-or-style-directive";case"attr":case"prop":return e.reactive?"reactive-prop":e.expr!==void 0?"expression-prop":void 0;default:return"expression-prop"}}function P(e){let t=[],n=new Map,r=o=>{switch(o.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let s of o.children)r(s);return!1;case"fragment":for(let s of o.children)r(s);return!1;case"element":{let s=!0;for(let a of o.children)r(a)||(s=!1);let i;for(let a of o.props)if(i=bt(a),i)break;return!i&&!s&&(i=St(o)),o.static=!i,i?n.set(o,i):t.push(o),o.static}default:return!1}};for(let o of Array.isArray(e)?e:[e])r(o);return{staticElements:t,reasons:n}}function St(e){for(let t of e.children){if(t.kind==="expr")return"expression-child";if(t.kind==="component")return"component-child";if(t.kind==="control")return"control-child";if(t.kind==="element"&&!t.static||t.kind==="fragment")return"expression-child"}return"expression-child"}var G={kind:"eager"},Et=["pointerdown","focusin","keydown"],we=new Set(["eager","idle","visible","interaction","media","never"]),I=class extends Error{};function le(e){return e.startsWith("load:")}function Z(e,t){let n=e.slice(5);if(!we.has(n))throw new I(`Unknown load strategy 'load:${n}'. Expected one of ${[...we].join(", ")}.`);switch(n){case"eager":return G;case"idle":return{kind:"idle"};case"never":return{kind:"never"};case"visible":return t?{kind:"visible",rootMargin:t}:{kind:"visible"};case"interaction":return{kind:"interaction",events:t?It(t):[...Et]};case"media":if(!t)throw new I(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:t};default:throw new I(`Unhandled load strategy '${n}'.`)}}function It(e){let t=e.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean);if(t.length===0)throw new I("'load:interaction' was given no event names.");return t}function L(e){return e.kind!=="eager"&&e.kind!=="never"}var j=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],J=["Suspense","SuspenseList","Await"],M=["Router","Outlet","Redirect","Link"],An=[...j,...J,...M],ce=new Set([...j,...J]);function Ce(e={}){let{controlFlowModule:t="@fluixi/dom",coreModule:n="@fluixi/core",routerModule:r="@fluixi/core/router"}=e,o={};for(let s of j)o[s]=t;for(let s of J)o[s]=n;for(let s of M)o[s]=r;return o}function Y(e,t={}){let{resolver:n,isBound:r,modules:o,strategyFor:s}=t,i=Ce(o),a=new Map,l=new Set,c=f=>{let{name:d}=f;if(!d||d.includes(".")||r?.(d))return;let g=p(d);if(!g){l.add(d);return}let m=g.origin==="builtin"&&ce.has(d)?G:s?.(f)??G;f.source={...g,loading:m},a.set(d,f.source)},p=f=>{if(ce.has(f))return{module:i[f],export:f,origin:"builtin"};let d=n?.resolve(f);if(d)return{module:d.module,export:d.export,origin:"rule"};if(M.includes(f))return{module:i[f],export:f,origin:"builtin"}};return Q(e,f=>{f.kind==="component"&&c(f)}),{resolved:a,unresolved:[...l]}}function Q(e,t){let n=Array.isArray(e)?e:[e];for(let r of n){t(r);let o=r.children;o&&Q(o,t)}}function ee(e){let t=[];Q(e,s=>{s.kind==="component"&&s.source&&t.push(s)});let n=new Set,r=new Set;for(let s of t){let{module:i,loading:a}=s.source;a.kind==="eager"&&n.add(i),a.kind==="never"&&r.add(i)}let o=new Map;for(let s of t){let i=s.source;L(i.loading)&&n.has(i.module)&&(i.loading={kind:"eager"},o.set(i.module,(o.get(i.module)??0)+1))}return{collapsed:o,conflicted:[...r].filter(s=>n.has(s))}}var wt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$e={className:"class",htmlFor:"for"},Ct=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),$t=new Set(["script","style","textarea","title"]);function pe(e){return $t.has(e)}function Te(e){return $e[e]??e}function B(e){return e.kind!=="attr"||e.expr!==void 0||e.name.includes(":")?!1:!Ct.has(e.name)}function de(e){if(!e.static||pe(e.tag))return!1;for(let t of e.props)if(!B(t))return!1;for(let t of e.children)if(t.kind!=="text"&&!(t.kind==="element"&&de(t)))return!1;return!0}function _(e){let t=e.props.map(Pt).filter(Boolean).join(""),n=`<${e.tag}${t}>`;return wt.has(e.tag)?n:`${n}${e.children.map(Tt).join("")}</${e.tag}>`}function Tt(e){if(e.kind==="text")return Ot(e.value);if(e.kind!=="element")throw new Error(`serializeStatic: unexpected ${e.kind}`);return _(e)}function Pt(e){let t=$e[e.name]??e.name,n=e.literal;return n===!0||n===void 0?` ${t}`:n===!1||n===null?"":` ${t}="${Mt(String(n))}"`}function Mt(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ot(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var Dt="<!--fx-->",At="<!--fx/-->";function ne(e){return e.kind==="expr"||e.kind==="component"||e.kind==="control"}function Lt(e){return e.kind==="text"||e.kind==="element"&&Pe(e)}function Pe(e){return e.svg||pe(e.tag)||!e.props.every(t=>B(t))?!1:e.children.every(t=>Lt(t)||ne(t))}function te(e){if(ne(e))return!0;let t=e.children;return t?t.some(te):!1}function Me(e){for(let t=0;t<e.children.length;t++){let n=e.children[t];if(n.kind==="text"&&(n.value===""||e.children[t+1]?.kind==="text"))return!1}return e.children.every(t=>t.kind!=="element"||Me(t))}function Oe(e){if(!Pe(e)||!Me(e)||!e.children.some(te))return null;let t=[],n=[],r=0,o=i=>{let a=`_n$${r++}`;return t.push({ref:a,expr:i}),a};return s(e,"_el$"),{html:jt(e),tag:e.tag,steps:t,holes:n};function s(i,a){let l=-1;i.children.forEach((p,f)=>{te(p)&&(l=f)});let c=null;for(let p=0;p<=l;p++){let f=i.children[p],d=c?`${c}.nextSibling`:`${a}.firstChild`;if(ne(f)){let m=o(d),h=o(`holeEnd(${m})`);n.push({parentRef:a,startRef:m,endRef:h,node:f}),c=h;continue}let g=o(d);f.kind==="element"&&te(f)&&s(f,g),c=g}}}function jt(e){return _(De(e)).split(Ae).join(Dt+At)}function De(e){return{...e,children:e.children.map(t=>ne(t)?{kind:"text",value:Ae}:t.kind==="element"?De(t):t)}}var Ae="\0fx-hole\0";var ue={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},zn={version:2,module:"@fluixi/dom",symbols:[...ue.symbols,"template","cloneTemplate","walk"]};var Jt={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function Bt(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function je(e){return Bt(e)?e:JSON.stringify(e)}function _t(e){return e.expr!==void 0?e.reactive?`() => (${e.expr})`:`(${e.expr})`:JSON.stringify(e.literal??!0)}function Ft(e){return e.expr!==void 0?`(${e.expr})`:JSON.stringify(e.literal??!0)}function Ht(e,t,n){let r=e.filter(a=>a.kind==="spread"),s=e.filter(a=>a.kind!=="spread").map(a=>`${je(a.name)}: ${_t(a)}`);t!=null&&s.push(`children: ${t}`);let i=`{ ${s.join(", ")} }`;return r.length>0?(n.add("mergeProps"),`mergeProps(${r.map(a=>a.expr).join(", ")}, ${i})`):i}function Je(e,t,n){return e.length===1?F(e[0],t,n):`[${e.map(r=>F(r,t,n)).join(", ")}]`}function Le(e,t,n,r,o){r.add("createMemo"),r.add("createComponent");let s=t.filter(c=>c.kind==="spread"),a=t.filter(c=>c.kind!=="spread").map(c=>`get ${je(c.name)}() { return ${Ft(c)}; }`);n.length>0&&a.push(`get children() { return ${Je(n,r,o)}; }`);let l=`{ ${a.join(", ")} }`;return s.length>0&&(r.add("mergeProps"),l=`mergeProps(${s.map(c=>c.expr).join(", ")}, ${l})`),`createMemo(() => createComponent(${e}, ${l}))`}function Vt(e,t){let n=Te(t.name),r=t.literal;return r===!0||r===void 0?`${e}.setAttribute(${JSON.stringify(n)}, "");`:r===!1||r===null?"":`${e}.setAttribute(${JSON.stringify(n)}, ${JSON.stringify(String(r))});`}var Be=!1;function F(e,t,n){switch(e.kind){case"text":return JSON.stringify(e.value);case"expr":return e.reactive?`() => (${e.code})`:`(${e.code})`;case"fragment":return e.children.length===0?"null":Je(e.children,t,n);case"component":return Le(e.name,e.props,e.children,t,n);case"control":{let r=Jt[e.control]??e.control;return t.add(r),Le(r,e.props,e.children,t,n)}case"element":{if(n&&e.static&&!e.svg&&de(e)){t.add("templateNode");let a=`_tmpl$${n.length}`;return n.push({id:a,html:_(e),tag:e.tag,svg:!1}),`templateNode(${a}, ${JSON.stringify(e.tag)})`}if(n&&Be){let a=Oe(e);if(a){t.add("templateNode"),t.add("insert"),t.add("holeEnd"),t.add("holeContent"),t.add("holeScope");let l=`_tmpl$${n.length}`;n.push({id:l,html:a.html,tag:a.tag,svg:!1});let c=[`const _el$ = templateNode(${l}, ${JSON.stringify(a.tag)}, true);`];for(let p of a.steps)c.push(`const ${p.ref} = ${p.expr};`);for(let p of a.holes)c.push(`insert(${p.parentRef}, holeScope(${p.startRef}, () => (${F(p.node,t,n)})), ${p.endRef}, holeContent(${p.startRef}, ${p.endRef}));`);return c.push("return _el$;"),`(() => { ${c.join(" ")} })()`}}t.add("createNativeElement");let r=JSON.stringify(e.tag),o="_el$",s=[],i=e.svg?`${r}, true`:r;if(s.push(`const ${o} = createNativeElement(${i});`),e.props.length>0)if(!e.svg&&e.props.every(B))for(let a of e.props)s.push(Vt(o,a));else{t.add("spread");let a=e.svg?", isSVG: true":"";s.push(`spread({ element: ${o}, props: ${Ht(e.props,null,t)}${a} });`)}for(let a of e.children){t.add("insert");let l=F(a,t,n),c=a.kind==="expr"&&a.reactive||a.kind==="component"||a.kind==="control";s.push(c?`insert(${o}, ${l}, null);`:`insert(${o}, ${l});`)}return s.push(`return ${o};`),`(() => { ${s.join(" ")} })()`}}}function re(e,t){if(!t||t.length===0)return e;let n=new Map(t.map(r=>[r.id,JSON.stringify(r.html)]));return e.replace(/_tmpl\$\d+/g,r=>n.get(r)??r)}var O={name:"imperative",contract:ue,emit(e,t){let n=new Set,r=t?.templateClone!==!1?[]:void 0;return Be=t?.partialTemplates===!0,{code:F(e,n,r),imports:Array.from(n),templates:r}}};var Xt=e=>"components"in e;function _e(e,t){return e.replace(/\$(\d+)/g,(n,r)=>t[Number(r)]??n)}function Ut(e,t){return typeof t=="string"?{module:t,export:e}:t}function oe(e=[]){let t=new Map,n=[],r=[];for(let i of e){if(!Xt(i)){r.push(i);continue}for(let[a,l]of Object.entries(i.components)){let c=Ut(a,l),p=t.get(a);if(p&&p.module!==c.module){let f=n.find(d=>d.name===a);f?f.modules.push(c.module):n.push({name:a,modules:[p.module,c.module]});continue}t.set(a,c)}}let o=new Map;return{resolve:i=>{if(o.has(i))return o.get(i);let a=t.get(i);if(!a)for(let l of r){let c=i.match(new RegExp(l.match.source,l.match.flags.replace("g","")));if(c){a={module:_e(l.module,c),export:l.export?_e(l.export,c):i};break}}return o.set(i,a),a},names:()=>[...t.keys()],conflicts:()=>n}}var Ve=require("@fluixi/template-parser");function H(e){let t=e.split(/\r\n|\n|\r/),n=0;for(let o=0;o<t.length;o++)/[^ \t]/.test(t[o])&&(n=o);let r="";for(let o=0;o<t.length;o++){let s=t[o].replace(/\t/g," ");o!==0&&(s=s.replace(/^ +/,"")),o!==t.length-1&&(s=s.replace(/ +$/,"")),s&&(o!==n&&(s+=" "),r+=s)}return r}var Fe=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function zt(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function He(e){return e.charAt(0).toUpperCase()+e.slice(1)}var fe=class{constructor(t,n){this.holes=t;this.used=n}hole(t){return this.holes[t]??{code:"undefined",reactive:!1}}emit(t){let{code:n,imports:r,templates:o}=O.emit(t,{});for(let s of r)this.used.add(s);return re(n,o)}lowerRoot(t){let n=this.lowerChildren(t);return n.length===1?n[0]:{kind:"fragment",children:n}}lowerChildren(t){let n=[];for(let r=0;r<t.length;r++){let o=t[r];if(o.kind==="Element"||o.kind==="Component"){let i=o.attributes.find(a=>a.kind==="IfDirective");if(i&&i.kind==="IfDirective"){let a=r+1;a<t.length&&this.isBlankText(t[a])&&a++;let l=t[a],c=l&&(l.kind==="Element"||l.kind==="Component")&&l.attributes.some(p=>p.kind==="ElseDirective");n.push(this.lowerIf(o,i.hole,c?l:null)),c&&(r=a);continue}if(o.attributes.some(a=>a.kind==="EachDirective")){n.push(this.lowerEach(o));continue}}let s=this.lowerNode(o);s&&n.push(s)}return n}isBlankText(t){return t.kind==="Text"&&!t.raw&&H(t.value)===""}lowerNode(t){switch(t.kind){case"Text":{if(t.raw)return{kind:"text",value:t.value};let n=H(t.value);return n?{kind:"text",value:n}:null}case"Comment":return null;case"Expression":{let n=this.hole(t.hole);return{kind:"expr",code:n.code,reactive:n.reactive}}case"Fragment":return{kind:"fragment",children:this.lowerChildren(t.children)};case"Element":return this.lowerElement(t);case"Component":return this.lowerComponent(t);default:return null}}lowerElement(t){let n=t.attributes.find(r=>r.kind==="Attribute"&&r.name==="is");if(t.tag==="component"&&n&&n.value&&n.value.kind==="hole"){let r=t.attributes.filter(s=>s!==n),o=this.lowerComponent({...t,kind:"Component",tag:"Dynamic",tagHole:null,attributes:r});return o.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(n.value.hole).code})`}),o}return{kind:"element",tag:t.tag,svg:t.namespace==="svg",props:this.lowerAttributes(t.attributes),children:this.lowerChildren(t.children),static:!1}}lowerComponent(t){let n=t.tagHole!=null?this.hole(t.tagHole).code:t.tag,r=this.lowerAttributes(t.attributes),{slots:o,rest:s}=this.partitionSlots(t.children);for(let[l,c]of o){let p=c.length===1?c[0]:{kind:"fragment",children:c},f={name:l,kind:"attr",expr:this.emit(p),jsxElement:!0},d=r.findIndex(g=>g.name===l);d>=0?r[d]=f:r.push(f)}let i=t.attributes.find(l=>l.kind==="LoadDirective"),a=i?Z(`load:${i.strategy}`,i.modifier):void 0;return{kind:"component",name:n,props:r,children:this.lowerChildren(s),...a?{load:a}:{}}}partitionSlots(t){let n=new Map,r=[];for(let o of t){if(o.kind==="Element"||o.kind==="Component"){let s=o.attributes.find(i=>i.kind==="Attribute"&&i.name==="slot");if(s&&s.value&&s.value.kind==="static"){let i={...o,attributes:o.attributes.filter(c=>c!==s)},a=i.kind==="Element"?this.lowerElement(i):this.lowerComponent(i),l=n.get(s.value.value)??[];l.push(a),n.set(s.value.value,l);continue}}r.push(o)}return{slots:n,rest:r}}lowerIf(t,n,r){let o=this.hole(n),s=[{name:"when",kind:"attr",expr:o.code,reactive:o.reactive}];if(r){let a=this.stripAndLower(r,l=>l.kind==="ElseDirective");s.push({name:"fallback",kind:"attr",expr:this.emit(a),jsxElement:!0})}let i=this.stripAndLower(t,a=>a.kind==="IfDirective");return{kind:"component",name:"Show",props:s,children:[i]}}lowerEach(t){let n=t.attributes.find(l=>l.kind==="EachDirective");if(!n||n.kind!=="EachDirective")return this.lowerNode(t);let r=this.hole(n.hole),o=[{name:"each",kind:"attr",expr:r.code,reactive:r.reactive}];if(n.key){let l="static"in n.key?`(item) => item[${JSON.stringify(n.key.static)}]`:this.hole(n.key.hole).code;o.push({name:"by",kind:"attr",expr:l})}let s=this.itemArrow(t),i;if(s){let l={kind:"expr",code:s.body,reactive:s.bodyReactive},c=this.rebuildWithChildren(t,[l]);i=`(${s.params.join(", ")}) => (${this.emit(c)})`}else{let l=this.stripAndLower(t,c=>c.kind==="EachDirective");i=`() => (${this.emit(l)})`}return{kind:"component",name:"For",props:o,children:[{kind:"expr",code:i,reactive:!1}]}}itemArrow(t){let n=t.children.filter(r=>!this.isBlankText(r));return n.length!==1||n[0].kind!=="Expression"?null:this.hole(n[0].hole).arrow??null}stripAndLower(t,n){let r={...t,attributes:t.attributes.filter(o=>!n(o))};return r.kind==="Element"?this.lowerElement(r):this.lowerComponent(r)}rebuildWithChildren(t,n){let r=this.lowerAttributes(t.attributes.filter(o=>o.kind!=="EachDirective"));return t.kind==="Element"?{kind:"element",tag:t.tag,svg:t.namespace==="svg",props:r,children:n,static:!1}:{kind:"component",name:t.tag,props:r,children:n}}lowerAttributes(t){let n=[],r=[],o=!1,s=[],i=!1,a=[];for(let l of t)switch(l.kind){case"IfDirective":case"EachDirective":case"ElseDirective":break;case"Attribute":n.push(this.plainAttr(l));break;case"PropertyBinding":n.push({name:l.name,kind:"prop",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"EventBinding":n.push(this.eventProp(l));break;case"RefBinding":n.push({name:"ref",kind:"ref",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"Spread":n.push({name:"",kind:"spread",expr:this.hole(l.hole).code});break;case"ClassDirective":{let c=this.hole(l.hole);r.push(`${JSON.stringify(l.name)}: ${c.code}`),o=o||c.reactive;break}case"StyleDirective":{let c=this.hole(l.hole);s.push(`${JSON.stringify(l.name)}: ${c.code}`),i=i||c.reactive;break}case"BindDirective":n.push(...this.bindProps(l.name,this.hole(l.hole).code));break;case"UseDirective":{let c=l.name??(l.hole!=null?this.hole(l.hole).code:null);if(!c)break;a.push(l.name!=null&&l.hole!=null?`[${c}, () => (${this.hole(l.hole).code})]`:`[${c}]`);break}}return r.length>0&&n.push({name:"classList",kind:"attr",expr:`{ ${r.join(", ")} }`,reactive:o}),s.length>0&&n.push({name:"style",kind:"attr",expr:`{ ${s.join(", ")} }`,reactive:i}),a.length>0&&n.push({name:"use",kind:"attr",expr:`[${a.join(", ")}]`}),n}eventProp(t){let n=t.name.toLowerCase(),r=this.hole(t.hole).code;if(!(t.syntax==="colon"||t.modifiers.length>0))return{name:"on"+He(t.name),kind:"event",event:{name:n,delegated:Fe.has(n)},expr:r};let s=this.wrapHandler(r,t.modifiers),i=this.eventOptions(t.modifiers),a=i?`[${s}, ${i}]`:s;return{name:"on:"+n,kind:"attr",expr:a}}wrapHandler(t,n){let r=n.includes("self")?"if (e.target !== e.currentTarget) return; ":"",o=[];return n.includes("prevent")&&o.push("e.preventDefault();"),n.includes("stop")&&o.push("e.stopPropagation();"),!r&&o.length===0?t:`(e) => { ${r}${o.join(" ")} return (${t})(e); }`}eventOptions(t){let n=[];return t.includes("capture")&&n.push("capture: true"),t.includes("once")&&n.push("once: true"),t.includes("passive")&&n.push("passive: true"),n.length?`{ ${n.join(", ")} }`:null}bindProps(t,n){let r=t==="checked",o=r?"change":"input",s=r?"checked":"value";this.used.add("bindPair");let i=`bindPair(${n})`;return[{name:t,kind:"attr",expr:`${i}[0]()`,reactive:!0},{name:"on"+He(o),kind:"event",event:{name:o,delegated:Fe.has(o)},expr:`(e) => ${i}[1](e.target.${s})`}]}plainAttr(t){let n=t.value,r=t.name;t.name==="class"?r=n&&n.kind==="hole"&&this.hole(n.hole).object?"classList":"className":t.name==="html"&&(r="innerHTML");let s={name:r,kind:"attr"};if(n==null)return s.literal=!0,s;if(n.kind==="static")return s.literal=n.value,s;if(n.kind==="hole"){let l=this.hole(n.hole);return s.expr=l.code,s.reactive=l.reactive,s}let i=!1,a=n.parts.map(l=>{if("text"in l)return zt(l.text);let c=this.hole(l.hole);return i=i||c.reactive,"${"+c.code+"}"}).join("");return s.expr="`"+a+"`",s.reactive=i,s}};function Xe(e,t,n,r={}){let{root:o}=(0,Ve.parseTemplate)(e,{svg:r.svg});return new fe(t,n).lowerRoot(o.children)}function Ue(e,t,n={}){let r=new Set,o=Xe(e,[...t],r,{svg:n.svg});P(o),Y(o,{resolver:oe(n.resolve??[]),modules:{controlFlowModule:n.controlFlowModule??"@fluixi/dom",coreModule:n.coreModule??"@fluixi/core",routerModule:n.routerModule??"@fluixi/core/router"},strategyFor:l=>l.load}),ee(o);let{code:s,imports:i,templates:a}=O.emit(o,{templateClone:n.templateClone,partialTemplates:n.partialTemplates});for(let l of i)r.add(l);return n.hoistTemplates?{code:s,imports:[...r],ir:o,templates:a}:{code:re(s,a),imports:[...r],ir:o}}var Wt="children";function D(e){switch(e.kind){case"call":return!0;case"member":return e.property!==Wt;case"compound":return e.parts.some(D);case"opaque":return!1}}var qt=new Set(["CallExpression","OptionalCallExpression"]),Kt=new Set(["MemberExpression","OptionalMemberExpression"]);function A(e){if(!e)return{kind:"opaque"};if(qt.has(e.type))return{kind:"call"};if(Kt.has(e.type)){let t=e.property;return{kind:"member",property:!(e.computed===!0)&&t?.type==="Identifier"?t.name:null}}return e.type==="ConditionalExpression"?{kind:"compound",parts:[e.test,e.consequent,e.alternate].map(V)}:e.type==="LogicalExpression"||e.type==="BinaryExpression"?{kind:"compound",parts:[e.left,e.right].map(V)}:e.type==="TemplateLiteral"?{kind:"compound",parts:e.expressions.map(V)}:e.type==="ObjectExpression"?{kind:"compound",parts:e.properties.filter(n=>(n.type==="ObjectProperty"||n.type==="Property")&&n.computed!==!0).map(n=>V(n.value))}:e.type==="ArrayExpression"?{kind:"compound",parts:e.elements.filter(n=>n!=null&&n.type!=="SpreadElement").map(V)}:{kind:"opaque"}}var V=e=>A(e);var Gt=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),Zt=/^on[A-Z]/,Yt=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]),qe=e=>D(A(e));function X(e){if(e.type==="StringLiteral"||e.type==="NumericLiteral"||e.type==="BooleanLiteral"||e.type==="Literal"&&(typeof e.value=="string"||typeof e.value=="number"||typeof e.value=="boolean"))return e.value}var me=e=>!!e&&typeof X(e)=="string";function Qt(e,t){return e.type==="JSXIdentifier"?{tag:e.name,component:e.name[0]!==e.name[0].toLowerCase()}:e.type==="JSXMemberExpression"?{tag:t.code(e),component:!0}:e.type==="JSXNamespacedName"?{tag:`${e.namespace.name}:${e.name.name}`,component:!1}:{tag:"div",component:!1}}function ge(e){return e.type==="JSXIdentifier"?e.name==="class"?"className":e.name:e.type==="JSXNamespacedName"?`${e.namespace.name}:${e.name.name}`:"unknown"}function en(e,t){let n=ge(e.name),r=Zt.test(n),o=r||n.startsWith("on:")||n==="ref",i={name:n,kind:r?"event":"attr"};if(r){let l=n.slice(2).toLowerCase();i.event={name:l,delegated:Yt.has(l)}}let a=e.value;if(a==null)return i.literal=!0,i;if(me(a))return i.literal=X(a),i;if(a.type==="JSXExpressionContainer"&&a.expression?.type!=="JSXEmptyExpression"){let l=a.expression,c=X(l);return c!==void 0?(i.literal=c,i):(i.expr=t.code(l),i.reactive=o?!1:qe(l),(l.type==="JSXElement"||l.type==="JSXFragment")&&(i.jsxElement=!0),i)}return i.literal=!0,i}function ze(e,t){let n=e.value;return n==null?null:me(n)?JSON.stringify(X(n)):n.type==="JSXExpressionContainer"&&n.expression?.type!=="JSXEmptyExpression"?t.code(n.expression):null}function tn(e,t){let n=[],r=[];for(let o of e){if(o.type==="JSXSpreadAttribute"){n.push({name:"",kind:"spread",expr:t.code(o.argument)});continue}if(o.type!=="JSXAttribute"||le(ge(o.name)))continue;let s=o.name.type==="JSXNamespacedName"?o.name.namespace.name:null;if(s==="use"){let i=o.name.name.name;t.used.add(i);let a=ze(o,t);r.push(a!=null?`[${i}, () => (${a})]`:`[${i}]`);continue}if(s==="oncapture"){let i=o.name.name.name.toLowerCase(),a=ze(o,t)??"undefined";n.push({name:"on:"+i,kind:"attr",expr:`[${a}, { capture: true }]`});continue}n.push(en(o,t))}return r.length>0&&n.push({name:"use",kind:"attr",expr:`[${r.join(", ")}]`}),n}function We(e,t){let n=[];for(let r of e)if(r.type==="JSXText"){let o=H(r.value);o&&n.push({kind:"text",value:o})}else if(r.type==="JSXExpressionContainer"){if(r.expression?.type!=="JSXEmptyExpression"){let o=r.expression;n.push({kind:"expr",code:t.code(o),reactive:qe(o)})}}else r.type==="JSXElement"||r.type==="JSXFragment"?n.push(Ke(r,t)):r.type==="JSXSpreadChild"&&n.push({kind:"expr",code:t.code(r.expression),reactive:!1});return n}function nn(e){for(let t of e){if(t.type!=="JSXAttribute")continue;let n=ge(t.name);if(le(n)){if(t.value&&!me(t.value))throw new I(`'${n}' needs a literal value, not an expression — the strategy is compile-time.`);return Z(n,t.value?X(t.value):null)}}}function Ke(e,t){if(e.type==="JSXFragment")return{kind:"fragment",children:We(e.children,t)};let{tag:n,component:r}=Qt(e.openingElement.name,t),o=tn(e.openingElement.attributes,t),s=We(e.children,t);if(r){let i=nn(e.openingElement.attributes);return{kind:"component",name:n,props:o,children:s,...i?{load:i}:{}}}return{kind:"element",tag:n,svg:Gt.has(n),props:o,children:s,static:!1}}function Ge(e,t){let n=Ke(e,t);return P(n),n}function w(e,t){if(e)switch(e.type){case"Identifier":t.add(e.name);return;case"ObjectPattern":for(let n of e.properties)n.type==="RestElement"?w(n.argument,t):w(n.value,t);return;case"ArrayPattern":for(let n of e.elements)w(n,t);return;case"AssignmentPattern":w(e.left,t);return;case"RestElement":w(e.argument,t);return}}function Ze(e,t){switch(e.type){case"ImportDeclaration":for(let n of e.specifiers)w(n.local,t);return;case"VariableDeclaration":for(let n of e.declarations)w(n.id,t);return;case"FunctionDeclaration":case"ClassDeclaration":w(e.id,t);return;case"ExportNamedDeclaration":case"ExportDefaultDeclaration":e.declaration&&Ze(e.declaration,t);return}}function he(e){let t=new Set;for(let n of e.body)Ze(n,t);return t}var sn=require("@babel/parser"),an=Ie(require("magic-string"),1);function k(e,t){if(e)switch(e.type){case"Identifier":t.add(e.name);return;case"ObjectPattern":for(let n of e.properties)n.type==="RestElement"?k(n.argument,t):k(n.value,t);return;case"ArrayPattern":for(let n of e.elements)k(n,t);return;case"AssignmentPattern":k(e.left,t);return;case"RestElement":k(e.argument,t);return}}function ye(e){switch(e.type){case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":case"NullLiteral":case"BigIntLiteral":case"RegExpLiteral":case"Identifier":return!0;case"Literal":return!0;case"TemplateLiteral":return e.expressions.every(ye);case"UnaryExpression":return ye(e.argument);case"MemberExpression":return!1;default:return!1}}function se(e,t){if(!(!e||typeof e!="object")){t(e);for(let n of Object.keys(e)){if(n==="loc"||n==="range"||n==="leadingComments"||n==="trailingComments")continue;let r=e[n];if(Array.isArray(r))for(let o of r)o&&typeof o=="object"&&se(o,t);else r&&typeof r=="object"&&typeof r.type=="string"&&se(r,t)}}}function rn(e){let t=new Set;return se(e,n=>{if(n.type==="AssignmentExpression")k(n.left,t);else if(n.type==="UpdateExpression"){let r=n.argument;r?.type==="Identifier"&&t.add(r.name)}}),t}function on(e,t){let n=new Set,r=o=>{let s=new Set;k(o,s);for(let i of s)t.has(i)&&n.add(i)};return se(e,o=>{switch(o.type){case"VariableDeclarator":r(o.id);return;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":r(o.id);for(let s of o.params??[])r(s);return;case"CatchClause":r(o.param);return;case"ClassDeclaration":case"ClassExpression":r(o.id);return}}),n}function Ye(e,t,n){for(let r of e.properties??[]){if(r.type==="RestElement"){let p=r.argument;if(p?.type!=="Identifier"||t.length>0){let f=new Set;k(p,f);for(let d of f)n.bails.push({name:d,reason:"rest"});continue}n.rest={name:p.name,keys:[]};continue}if(r.computed){let p=new Set;k(r.value,p);for(let f of p)n.bails.push({name:f,reason:"computed"});continue}let o=r.key,s=o.type==="Identifier"?o.name:o.value,i=r.value,a;i.type==="AssignmentPattern"&&(a=i.right,i=i.left);let l=[...t,s];if(i.type==="Identifier"){if(a&&!ye(a)){n.bails.push({name:i.name,reason:"unsafe-default"});continue}n.reads.push({name:i.name,path:l,...a?{fallback:a}:{}});continue}if(i.type==="ObjectPattern"){if(a){let p=new Set;k(i,p);for(let f of p)n.bails.push({name:f,reason:"unsafe-default"});continue}Ye(i,l,n);continue}let c=new Set;k(i,c);for(let p of c)n.bails.push({name:p,reason:"computed"})}}function Qe(e,t){let n={reads:[],bails:[]};if(e?.type!=="ObjectPattern"||(Ye(e,[],n),n.rest&&(t?.type!=="BlockStatement"?(n.bails.push({name:n.rest.name,reason:"rest"}),delete n.rest):n.rest.keys=(e.properties??[]).filter(a=>a.type!=="RestElement"&&!a.computed).map(a=>{let l=a.key;return l.type==="Identifier"?l.name:l.value})),n.reads.length===0&&!n.rest))return n;let r=new Set(n.reads.map(a=>a.name));n.rest&&r.add(n.rest.name);let o=rn(t),s=on(t,r),i=[];for(let a of n.reads)o.has(a.name)?n.bails.push({name:a.name,reason:"reassigned"}):s.has(a.name)?n.bails.push({name:a.name,reason:"shadowed"}):i.push(a);return n.reads=i,n.rest&&o.has(n.rest.name)?(n.bails.push({name:n.rest.name,reason:"reassigned"}),delete n.rest):n.rest&&s.has(n.rest.name)&&(n.bails.push({name:n.rest.name,reason:"shadowed"}),delete n.rest),n}function et(e){switch(e){case"rest":return"this rest element cannot be served by splitProps, and copying the props into a plain object would lose the getters";case"computed":return"the property is not known until it runs";case"reassigned":return"the binding is assigned to, and props are read-only";case"shadowed":return"an inner scope binds the same name";case"unsafe-default":return"the default would have to run again on every read"}}function U(e,t,n=null){if(!(!e||typeof e!="object"||typeof e.type!="string")&&!e.type.startsWith("TS")&&t(e,n)!==!1)for(let r of Object.keys(e)){if(r==="loc"||r==="leadingComments"||r==="trailingComments")continue;let o=e[r];if(Array.isArray(o))for(let s of o)U(s,t,e);else o&&typeof o=="object"&&U(o,t,e)}}function tt(e){return!!e&&e[0]>="A"&&e[0]<="Z"}function ln(e){let t=[];return U(e,n=>{if(n.type==="FunctionDeclaration"&&tt(n.id?.name)){t.push(n);return}if(n.type==="VariableDeclarator"&&tt(n.id?.name)){let r=n.init;r&&(r.type==="ArrowFunctionExpression"||r.type==="FunctionExpression")&&t.push(r)}}),t}function cn(e){let t=new Set;return U(e,n=>{n.type==="Identifier"&&t.add(n.name)}),t}function pn(e,t){if(!t)return!0;switch(t.type){case"MemberExpression":case"OptionalMemberExpression":return!(t.property===e&&!t.computed);case"ObjectProperty":case"ObjectMethod":case"ClassProperty":case"ClassMethod":return!(t.key===e&&!t.computed);case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return t.label!==e;case"ImportSpecifier":case"ExportSpecifier":return!1;default:return!0}}function nt(e,t,n={}){let r=[],o=[],s=new Set;for(let i of ln(e)){let a=i.params?.[0];if(a?.type!=="ObjectPattern")continue;let l=Qe(a,i.body);for(let m of l.bails)o.push({name:m.name,reason:m.reason,message:et(m.reason),start:a.start});if(l.bails.length>0||l.reads.length===0&&!l.rest)continue;let c=cn(i),p=n.parameterName??"props";for(;c.has(p);)p=`_${p}`;let f=new Map;for(let m of l.reads){let h=`${p}.${m.path.join(".")}`,v=m.fallback;f.set(m.name,v?`(${h} === undefined ? ${t.slice(v.start,v.end)} : ${h})`:h)}let d=a.typeAnnotation;if(r.push({start:a.start,end:d?.start??a.end,code:p}),l.rest){let m=l.rest.keys.map(v=>JSON.stringify(v)).join(", "),h=i.body;r.push({start:h.start+1,end:h.start+1,code:`
2
+ const [, ${l.rest.name}] = splitProps(${p}, [${m}]);`}),s.add("splitProps")}let g=[];U(i.body,(m,h)=>{if(m.type!=="Identifier")return;let v=f.get(m.name);if(!v)return;let S=h?.type==="ObjectProperty"&&h.shorthand&&h.value===m;if(!S&&!pn(m,h))return;let b=l.reads.find(C=>C.name===m.name).path;g.push({node:m,parent:S?h:null,text:v,property:b[b.length-1]})});for(let m of g)m.parent?r.push({start:m.parent.start,end:m.parent.end,code:`${m.node.name}: ${m.text}`}):r.push({start:m.node.start,end:m.node.end,code:m.text}),dn(m.node,p,m.property)}return{edits:r,diagnostics:o,used:s}}function dn(e,t,n){e.type="MemberExpression",e.computed=!1,e.optional=!1,e.object={type:"Identifier",name:t,start:e.start,end:e.start},e.property={type:"Identifier",name:n,start:e.end,end:e.end},delete e.name}var $="@fluixi/reactive/signal",T={$signal:{export:"signal",module:$,returns:"signal-handle"},$memo:{export:"memo",module:$,returns:"memo-handle"},$effect:{export:"effect",module:$,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:$,returns:"resource-handle"},$selector:{export:"createSelector",module:$,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:$,returns:"memo-accessor"},$untrack:{export:"untrack",module:$,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}},rt={signal:"signal-handle",memo:"memo-handle",effect:"effect",store:"store-handle",createSignal:["signal-accessor","signal-setter"],createMemo:"memo-accessor",createEffect:"effect",createRenderEffect:"effect",createStore:"reactive-object",resource:"resource-handle",createResource:"reactive-object",createSelector:"memo-accessor",createDeferred:"memo-accessor"},un=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/store","@fluixi/core"],fn=new RegExp(`\\$(?:${Object.keys(T).map(e=>e.slice(1)).join("|")})\\s*\\(`);function ot(e){return fn.test(e)}function st(e){return Object.prototype.hasOwnProperty.call(T,e)}function it(e){return un.includes(e)}function y(e,t){if(e)switch(e.type){case"Identifier":t.add(e.name);return;case"ObjectPattern":for(let n of e.properties??[])n.type==="RestElement"?y(n.argument,t):y(n.value,t);return;case"ArrayPattern":for(let n of e.elements??[])y(n,t);return;case"AssignmentPattern":y(e.left,t);return;case"RestElement":y(e.argument,t);return}}function z(e,t){if(!(!e||typeof e!="object"||typeof e.type!="string")){t(e);for(let n of Object.keys(e)){if(n==="loc"||n==="leadingComments"||n==="trailingComments")continue;let r=e[n];if(Array.isArray(r))for(let o of r)z(o,t);else r&&typeof r=="object"&&z(r,t)}}}function mn(e,t){if(e.type!=="CallExpression")return;let n=e.callee;if(n?.type!=="Identifier")return;let r=n.name,o=t.primitives.get(r);if(o)return o;let s=T[r];if(s&&!t.shadowed.has(r))return s.returns}function gn(e,t,n){if(Array.isArray(t)){e.type==="ArrayPattern"&&e.elements.forEach((r,o)=>{let s=t[o];r?.type==="Identifier"&&s&&n.set(r.name,s)});return}e.type==="Identifier"&&n.set(e.name,t)}function at(e){let t=new Set;return z(e,n=>{switch(n.type){case"VariableDeclarator":y(n.id,t);return;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":y(n.id,t);for(let r of n.params??[])y(r,t);return;case"ClassDeclaration":case"ClassExpression":y(n.id,t);return;case"ImportSpecifier":case"ImportDefaultSpecifier":case"ImportNamespaceSpecifier":y(n.local,t);return;case"CatchClause":y(n.param,t);return}}),t}function lt(e){let t={kinds:new Map,primitives:new Map,shadowed:new Set},n=e;z(n,r=>{let o=new Set;if(r.type==="VariableDeclarator")y(r.id,o);else if(r.type==="FunctionDeclaration"||r.type==="ClassDeclaration")y(r.id,o);else if(r.type==="ImportDefaultSpecifier"||r.type==="ImportNamespaceSpecifier")y(r.local,o);else if(r.type==="ImportSpecifier")y(r.local,o);else if(r.type==="FunctionExpression"||r.type==="ArrowFunctionExpression"||r.type==="FunctionDeclaration")for(let s of r.params??[])y(s,o);for(let s of o)T[s]&&t.shadowed.add(s)});for(let r of n.body??[])if(r.type==="ImportDeclaration"&&it(r.source?.value))for(let o of r.specifiers??[]){if(o.type!=="ImportSpecifier")continue;let s=o.imported,i=s.type==="Identifier"?s.name:s.value,a=rt[i];a&&t.primitives.set(o.local.name,a)}return z(n,r=>{if(r.type!=="VariableDeclarator"||!r.init)return;let o=mn(r.init,t);o&&gn(r.id,o,t.kinds)}),t}function Ne(e,t){if(!(!e||typeof e!="object"||typeof e.type!="string")){t(e);for(let n of Object.keys(e)){if(n==="loc"||n==="leadingComments"||n==="trailingComments")continue;let r=e[n];if(Array.isArray(r))for(let o of r)Ne(o,t);else r&&typeof r=="object"&&Ne(r,t)}}}function ct(e){let t=[],n=[],r=new Map,o=new Set,{shadowed:s}=lt(e);return Ne(e,i=>{if(i.type!=="CallExpression")return;let a=i.callee;if(a?.type!=="Identifier")return;let l=a.name;if(!st(l))return;if(s.has(l)){o.has(l)||(o.add(l),n.push({name:l,message:`${l} is reserved for the compiler, and this module binds it. The call keeps your binding's meaning; rename it to use the intrinsic.`,start:a.start}));return}let c=T[l];t.push({start:a.start,end:a.end,code:c.export});let p=r.get(c.module)??new Set;p.add(c.export),r.set(c.module,p)}),{edits:t,diagnostics:n,imports:r}}function pt(e,t){let n=[];for(let[r,o]of[...e.imports].sort(([s],[i])=>s.localeCompare(i))){let s=[...o].filter(i=>!t.has(i)).sort();s.length&&n.push(`import { ${s.join(", ")} } from ${JSON.stringify(r)};`)}return n.length?`${n.join(`
3
3
  `)}
4
4
  `:""}var hn=new Set(j),yn=new Set(J),Nn=new Set(M),vn=new Set(["createMemo","createEffect","createRenderEffect","createRoot","createSignal","onCleanup","batch","untrack"]);function ae(e,t,n=null,r=""){if(!(!e||typeof e!="object")){if(Array.isArray(e)){for(let o of e)ae(o,t,n,r);return}typeof e.type=="string"&&t(e,n,r);for(let o of Object.keys(e))o==="loc"||o==="leadingComments"||o==="trailingComments"||ae(e[o],t,typeof e.type=="string"?e:n,o)}}var ve=e=>e.type==="JSXElement"||e.type==="JSXFragment";function xn(e,t,n){return ve(e)?!(t&&ve(t)&&n==="children"):!1}function Rn(e,t){return e.type==="TaggedTemplateExpression"&&e.tag?.type==="Identifier"&&(e.tag.name===t||e.tag.name==="svg")}function ft(e){return e.filter(t=>!e.some(n=>n!==t&&n.start<=t.start&&n.end>=t.end&&n.end-n.start>t.end-t.start))}function ie(e,t,n,r){let o=ft(r.filter(i=>i.start>=t&&i.end<=n)).sort((i,a)=>a.start-i.start),s=e.slice(t,n);for(let i of o)s=s.slice(0,i.start-t)+i.code+s.slice(i.end-t);return s}function kn(e,t,n){let r={code:ie(e,t.start,t.end,n),reactive:D(A(t))};return t.type==="ArrowFunctionExpression"&&t.body?.type!=="BlockStatement"&&(r.arrow={params:t.params.map(o=>ie(e,o.start,o.end,n)),body:ie(e,t.body.start,t.body.end,n),bodyReactive:D(A(t.body))}),t.type==="ObjectExpression"&&(r.object=!0),r}function mt(e,t,n){if(!t||t.length===0)return e;let r=new Map;for(let o of t){let s=`${o.svg?"svg:":""}${o.html}`,i=n.get(s);i||(i=`_fxTmpl$${n.size}`,n.set(s,i)),r.set(o.id,i)}return e.replace(/_tmpl\$\d+/g,o=>r.get(o)??o)}function xe(e,t){if(e.kind==="component"&&e.load&&!e.source&&L(e.load)&&(t.ignoredLoad.has(e.name)||t.ignoredLoad.set(e.name,e.load)),e.kind==="component"&&e.source){let n=e.source;n.origin==="builtin"?t.builtins.add(e.name):L(n.loading)&&!t.resolved.has(e.name)?t.deferred.set(e.name,n):(t.deferred.delete(e.name),t.resolved.set(e.name,n))}if("props"in e&&e.props)for(let n of e.props)n.kind==="event"&&n.event?.delegated&&t.delegatedEvents.add(n.event.name);if("children"in e&&e.children)for(let n of e.children)xe(n,t)}function bn(e,t){for(let n of e.body??[])if(n.type==="ImportDeclaration")for(let r of n.specifiers??[]){if(r.local?.name!==t)continue;if(r.type==="ImportNamespaceSpecifier")return;let o=r.type==="ImportDefaultSpecifier"?"default":r.imported?.name??r.imported?.value;return{module:n.source.value,export:o,declaration:n,specifier:r}}}function Sn(e,t){for(let n of e.body??[])if(n.type==="ImportDeclaration"){for(let r of n.specifiers??[])if(r.type==="ImportNamespaceSpecifier"&&r.local?.name===t)return!0}return!1}function En(e,t,n){let r=!1;return ae(e,o=>{r||o.type!=="Identifier"||o.name!==t||o.start===n.local?.start&&o.end===n.local?.end||(r=!0)}),r}function In(e){let t=[`kind: ${JSON.stringify(e.kind)}`];return e.kind==="visible"&&e.rootMargin&&t.push(`rootMargin: ${JSON.stringify(e.rootMargin)}`),e.kind==="interaction"&&t.push(`events: ${JSON.stringify(e.events)}`),e.kind==="media"&&t.push(`query: ${JSON.stringify(e.query)}`),`{ ${t.join(", ")} }`}function wn(e){let t=[];return e.quasi.quasis.forEach((n,r)=>{if(t.push({kind:"static",text:n.value.cooked??n.value.raw,start:n.start}),r<e.quasi.expressions.length){let o=e.quasi.expressions[r];t.push({kind:"hole",index:r,start:o.start,end:o.end})}}),t}function Cn(e,t,n={}){let r=n.litTag??"html",o=n.format??"both",s=o!=="jsx",i=o!=="lit",a=s&&(e.includes(`${r}\``)||e.includes("svg`")),l=n.intrinsics!==!1&&ot(e);if(!a&&!(i&&e.includes("<"))&&!l)return null;let c=(0,dt.parse)(e,{sourceType:"module",plugins:["jsx","typescript"],errorRecovery:!0}),p=[];ae(c.program,(u,x,N)=>{(s&&Rn(u,r)||i&&xn(u,x,N))&&p.push(u)});let f=n.propsDestructure===!1?{edits:[],diagnostics:[],used:new Set}:nt(c.program,e,{runtimeModule:n.runtimeModule}),d=n.intrinsics===!1?{edits:[],diagnostics:[],imports:new Map}:ct(c.program);if(p.length===0&&f.edits.length===0&&d.edits.length===0&&d.diagnostics.length===0&&f.diagnostics.length===0)return null;p.sort((u,x)=>x.start-u.start||u.end-x.end);let m=new Set(f.used),h={builtins:new Set,resolved:new Map,deferred:new Map,delegatedEvents:new Set,ignoredLoad:new Map,unresolved:new Set,declared:at(c.program)},v=new Map,S=[...f.edits,...d.edits];for(let u of p){let x=p.some(R=>R!==u&&R.start<=u.start&&R.end>=u.end&&R.end-R.start>u.end-u.start);if(ve(u)){S.push({start:u.start,end:u.end,code:$n(e,u,S,x,m,h,v,n)});continue}let N=u.quasi.expressions.map(R=>kn(e,R,S)),E=Ue(wn(u),N,{...n,hoistTemplates:!0,templateClone:n.templateClone??!0,partialTemplates:x?!1:n.partialTemplates??!0,svg:u.tag.name==="svg"});for(let R of E.imports)m.add(R);xe(E.ir,h),S.push({start:u.start,end:u.end,code:mt(E.code,E.templates,v)})}let b=new ut.default(e);for(let u of ft(S))u.start===u.end?b.appendLeft(u.start,u.code):b.overwrite(u.start,u.end,u.code);let C=he(c.program),W=new Map;for(let[u]of h.ignoredLoad)C.has(u)||W.set(u,"unsupplied");for(let[u,x]of[...h.ignoredLoad]){if(!C.has(u))continue;let N=bn(c.program,u);if(!N){W.set(u,Sn(c.program,u)?"namespace":"local");continue}if(En(c.program,u,N.specifier)){W.set(u,"value");continue}let E=N.declaration.specifiers.filter(q=>q!==N.specifier),R=E.length===0&&e[N.declaration.end]===`
5
- `?N.declaration.end+1:N.declaration.end;b.overwrite(N.declaration.start,R,E.length===0?"":`import { ${E.map(q=>e.slice(q.start,q.end)).join(", ")} } from ${JSON.stringify(N.declaration.source.value)};`),h.deferred.set(u,{module:N.module,export:N.export,origin:"rule",loading:x}),C.delete(u),h.ignoredLoad.delete(u)}let Re=Tn(m,h,v,C,n);Re&&b.prepend(Re);let ke=pt(d,C);ke&&b.prepend(ke);let gt={value:u=>`${u} is used as a value here, not only as a tag, so its import has to stay — deferring would hand those references a lazy wrapper instead of the component. Defer it at the point it is rendered, or keep it eager.`,namespace:u=>`${u} came in through a namespace import, which has no single export to defer. Import ${u} by name.`,local:u=>`${u} is declared in this file, so there is no module to load separately. Move it to its own file and import it.`,unsupplied:u=>`nothing supplies ${u}, so there is no import to defer. Import it, or add a \`resolve\` rule for it.`},be=[...h.ignoredLoad].map(([u,x])=>({name:u,strategy:x,message:`load:${x.kind} has no effect on <${u}>: ${gt[W.get(u)??"unsupplied"](u)}`})),Se=[...h.unresolved].map(u=>({name:u,message:`<${u}> is not defined: nothing imports it and no \`resolve\` rule supplies it. This compiles to a reference to a name that does not exist, so the component renders nothing. Import ${u}, or add a \`resolve\` rule for it.`}));return{code:b.toString(),map:b.generateMap({source:t,includeContent:!0,hires:!0}),...be.length?{loadDiagnostics:be}:{},...Se.length?{unresolvedDiagnostics:Se}:{},...f.diagnostics.length?{propsDiagnostics:f.diagnostics}:{},...d.diagnostics.length?{intrinsicDiagnostics:d.diagnostics}:{}}}function $n(e,t,n,r,o,s,i,a){let l=Ge(t,{code:f=>ie(e,f.start,f.end,n),used:o});P(l);let c=Y(l,{resolver:oe(a.resolve??[]),isBound:f=>s.declared.has(f),modules:{controlFlowModule:a.controlFlowModule??a.runtimeModule??"@fluixi/dom",coreModule:a.coreModule??"fluixi",routerModule:a.routerModule??"fluixi/router"},strategyFor:f=>f.load});for(let f of c.unresolved)s.unresolved.add(f);ee(l);let p=O.emit(l,{templateClone:a.templateClone??!0,partialTemplates:r?!1:a.partialTemplates??!0});for(let f of p.imports)o.add(f);return xe(l,s),mt(p.code,p.templates,i)}function Tn(e,t,n,r,o){let s=o.runtimeModule??"@fluixi/dom",i=o.coreModule??"fluixi",a=new Map,l=(d,g)=>a.set(d,[...a.get(d)??[],g]),c=new Set(e);for(let d of t.builtins)c.add(d);t.delegatedEvents.size>0&&c.add("delegateEvents");for(let d of[...c].sort())r.has(d)||(vn.has(d)?l(o.reactiveModule??"@fluixi/reactive/signal",d):Nn.has(d)?l(o.routerModule??"fluixi/router",d):yn.has(d)?l(i,d):hn.has(d)?l(o.controlFlowModule??s,d):l(s,d));for(let[d,g]of t.resolved)r.has(d)||l(g.module,g.export==="default"?`default as ${d}`:d===g.export?d:`${g.export} as ${d}`);let p=[];for(let[d,g]of a)p.push(`import { ${g.join(", ")} } from ${JSON.stringify(d)};`);let f=[...t.deferred].filter(([d])=>!r.has(d));if(f.length>0){r.has("deferred")||p.push(`import { deferred } from ${JSON.stringify(i)};`);for(let[d,g]of f)p.push(`const ${d} = deferred(() => import(${JSON.stringify(g.module)}), { strategy: ${In(g.loading)}, export: ${JSON.stringify(g.export)} });`)}for(let[d,g]of n)p.push(`const ${g} = ${JSON.stringify(d.startsWith("svg:")?d.slice(4):d)};`);return t.delegatedEvents.size>0&&p.push(`delegateEvents(${JSON.stringify([...t.delegatedEvents])});`),p.length>0?p.join(`
5
+ `?N.declaration.end+1:N.declaration.end;b.overwrite(N.declaration.start,R,E.length===0?"":`import { ${E.map(q=>e.slice(q.start,q.end)).join(", ")} } from ${JSON.stringify(N.declaration.source.value)};`),h.deferred.set(u,{module:N.module,export:N.export,origin:"rule",loading:x}),C.delete(u),h.ignoredLoad.delete(u)}let Re=Tn(m,h,v,C,n);Re&&b.prepend(Re);let ke=pt(d,C);ke&&b.prepend(ke);let gt={value:u=>`${u} is used as a value here, not only as a tag, so its import has to stay — deferring would hand those references a lazy wrapper instead of the component. Defer it at the point it is rendered, or keep it eager.`,namespace:u=>`${u} came in through a namespace import, which has no single export to defer. Import ${u} by name.`,local:u=>`${u} is declared in this file, so there is no module to load separately. Move it to its own file and import it.`,unsupplied:u=>`nothing supplies ${u}, so there is no import to defer. Import it, or add a \`resolve\` rule for it.`},be=[...h.ignoredLoad].map(([u,x])=>({name:u,strategy:x,message:`load:${x.kind} has no effect on <${u}>: ${gt[W.get(u)??"unsupplied"](u)}`})),Se=[...h.unresolved].map(u=>({name:u,message:`<${u}> is not defined: nothing imports it and no \`resolve\` rule supplies it. This compiles to a reference to a name that does not exist, so the component renders nothing. Import ${u}, or add a \`resolve\` rule for it.`}));return{code:b.toString(),map:b.generateMap({source:t,includeContent:!0,hires:!0}),...be.length?{loadDiagnostics:be}:{},...Se.length?{unresolvedDiagnostics:Se}:{},...f.diagnostics.length?{propsDiagnostics:f.diagnostics}:{},...d.diagnostics.length?{intrinsicDiagnostics:d.diagnostics}:{}}}function $n(e,t,n,r,o,s,i,a){let l=Ge(t,{code:f=>ie(e,f.start,f.end,n),used:o});P(l);let c=Y(l,{resolver:oe(a.resolve??[]),isBound:f=>s.declared.has(f),modules:{controlFlowModule:a.controlFlowModule??a.runtimeModule??"@fluixi/dom",coreModule:a.coreModule??"@fluixi/core",routerModule:a.routerModule??"@fluixi/core/router"},strategyFor:f=>f.load});for(let f of c.unresolved)s.unresolved.add(f);ee(l);let p=O.emit(l,{templateClone:a.templateClone??!0,partialTemplates:r?!1:a.partialTemplates??!0});for(let f of p.imports)o.add(f);return xe(l,s),mt(p.code,p.templates,i)}function Tn(e,t,n,r,o){let s=o.runtimeModule??"@fluixi/dom",i=o.coreModule??"@fluixi/core",a=new Map,l=(d,g)=>a.set(d,[...a.get(d)??[],g]),c=new Set(e);for(let d of t.builtins)c.add(d);t.delegatedEvents.size>0&&c.add("delegateEvents");for(let d of[...c].sort())r.has(d)||(vn.has(d)?l(o.reactiveModule??"@fluixi/reactive/signal",d):Nn.has(d)?l(o.routerModule??"@fluixi/core/router",d):yn.has(d)?l(i,d):hn.has(d)?l(o.controlFlowModule??s,d):l(s,d));for(let[d,g]of t.resolved)r.has(d)||l(g.module,g.export==="default"?`default as ${d}`:d===g.export?d:`${g.export} as ${d}`);let p=[];for(let[d,g]of a)p.push(`import { ${g.join(", ")} } from ${JSON.stringify(d)};`);let f=[...t.deferred].filter(([d])=>!r.has(d));if(f.length>0){r.has("deferred")||p.push(`import { deferred } from ${JSON.stringify(i)};`);for(let[d,g]of f)p.push(`const ${d} = deferred(() => import(${JSON.stringify(g.module)}), { strategy: ${In(g.loading)}, export: ${JSON.stringify(g.export)} });`)}for(let[d,g]of n)p.push(`const ${g} = ${JSON.stringify(d.startsWith("svg:")?d.slice(4):d)};`);return t.delegatedEvents.size>0&&p.push(`delegateEvents(${JSON.stringify([...t.delegatedEvents])});`),p.length>0?p.join(`
6
6
  `)+`
7
7
  `:null}
@@ -430,8 +430,8 @@ function compileJsx(code, node, edits, nested, used, needs, hoisted, options) {
430
430
  isBound: (name) => needs.declared.has(name),
431
431
  modules: {
432
432
  controlFlowModule: options.controlFlowModule ?? options.runtimeModule ?? '@fluixi/dom',
433
- coreModule: options.coreModule ?? 'fluixi',
434
- routerModule: options.routerModule ?? 'fluixi/router',
433
+ coreModule: options.coreModule ?? '@fluixi/core',
434
+ routerModule: options.routerModule ?? '@fluixi/core/router',
435
435
  },
436
436
  strategyFor: (n) => n.load,
437
437
  });
@@ -455,7 +455,7 @@ function compileJsx(code, node, edits, nested, used, needs, hoisted, options) {
455
455
  */
456
456
  function buildPrologue(used, needs, hoisted, bound, options) {
457
457
  const runtime = options.runtimeModule ?? '@fluixi/dom';
458
- const core = options.coreModule ?? 'fluixi';
458
+ const core = options.coreModule ?? '@fluixi/core';
459
459
  const groups = new Map();
460
460
  const add = (mod, name) => groups.set(mod, [...(groups.get(mod) ?? []), name]);
461
461
  const wanted = new Set(used);
@@ -469,7 +469,7 @@ function buildPrologue(used, needs, hoisted, bound, options) {
469
469
  if (REACTIVE.has(name))
470
470
  add(options.reactiveModule ?? '@fluixi/reactive/signal', name);
471
471
  else if (ROUTER.has(name))
472
- add(options.routerModule ?? 'fluixi/router', name);
472
+ add(options.routerModule ?? '@fluixi/core/router', name);
473
473
  else if (CORE_ONLY.has(name))
474
474
  add(core, name);
475
475
  else if (CONTROL_FLOW.has(name))
@@ -7,10 +7,10 @@ import{parse as Cn}from"@babel/parser";var St=44,kt=59,Le="ABCDEFGHIJKLMNOPQRSTU
7
7
  `);if(t.length>1){for(let r=0;r<t.length-1;r++)this.generatedCodeLine++,this.raw[this.generatedCodeLine]=this.rawSegments=[];this.generatedCodeColumn=0}this.generatedCodeColumn+=t[t.length-1].length}},_=`
8
8
  `,O={insertLeft:!1,insertRight:!1,storeName:!1},ee=class n{constructor(e,t={}){let r=new Q(0,e.length,e);Object.defineProperties(this,{original:{writable:!0,value:e},outro:{writable:!0,value:""},intro:{writable:!0,value:""},firstChunk:{writable:!0,value:r},lastChunk:{writable:!0,value:r},lastSearchedChunk:{writable:!0,value:r},byStart:{writable:!0,value:{}},byEnd:{writable:!0,value:{}},filename:{writable:!0,value:t.filename},indentExclusionRanges:{writable:!0,value:t.indentExclusionRanges},sourcemapLocations:{writable:!0,value:new Z},storedNames:{writable:!0,value:{}},indentStr:{writable:!0,value:void 0},ignoreList:{writable:!0,value:t.ignoreList},offset:{writable:!0,value:t.offset||0}}),this.byStart[0]=r,this.byEnd[e.length]=r}addSourcemapLocation(e){this.sourcemapLocations.add(e)}append(e){if(typeof e!="string")throw new TypeError("outro content must be a string");return this.outro+=e,this}appendLeft(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let r=this.byEnd[e];return r?r.appendLeft(t):this.intro+=t,this}appendRight(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let r=this.byStart[e];return r?r.appendRight(t):this.outro+=t,this}clone(){let e=new n(this.original,{filename:this.filename,offset:this.offset}),t=this.firstChunk,r=e.firstChunk=e.lastSearchedChunk=t.clone();for(;t;){e.byStart[r.start]=r,e.byEnd[r.end]=r;let i=t.next,s=i&&i.clone();s&&(r.next=s,s.previous=r,r=s),t=i}return e.lastChunk=r,this.indentExclusionRanges&&(e.indentExclusionRanges=this.indentExclusionRanges.slice()),e.sourcemapLocations=new Z(this.sourcemapLocations),e.intro=this.intro,e.outro=this.outro,e}generateDecodedMap(e){e=e||{};let t=0,r=Object.keys(this.storedNames),i=new he(e.hires),s=je(this.original);return this.intro&&i.advance(this.intro),this.firstChunk.eachNext(o=>{let a=s(o.start);o.intro.length&&i.advance(o.intro),o.edited?i.addEdit(t,o.content,a,o.storeName?r.indexOf(o.original):-1):i.addUneditedChunk(t,o,this.original,a,this.sourcemapLocations),o.outro.length&&i.advance(o.outro)}),this.outro&&i.advance(this.outro),{file:e.file?e.file.split(/[/\\]/).pop():void 0,sources:[e.source?Ot(e.file||"",e.source):e.file||""],sourcesContent:e.includeContent?[this.original]:void 0,names:r,mappings:i.raw,x_google_ignoreList:this.ignoreList?[t]:void 0}}generateMap(e){return new fe(this.generateDecodedMap(e))}_ensureindentStr(){this.indentStr===void 0&&(this.indentStr=Tt(this.original))}_getRawIndentString(){return this._ensureindentStr(),this.indentStr}getIndentString(){return this._ensureindentStr(),this.indentStr===null?" ":this.indentStr}indent(e,t){let r=/^[^\r\n]/gm;if(Pt(e)&&(t=e,e=void 0),e===void 0&&(this._ensureindentStr(),e=this.indentStr||" "),e==="")return this;t=t||{};let i={};t.exclude&&(typeof t.exclude[0]=="number"?[t.exclude]:t.exclude).forEach(u=>{for(let d=u[0];d<u[1];d+=1)i[d]=!0});let s=t.indentStart!==!1,o=c=>s?`${e}${c}`:(s=!0,c);this.intro=this.intro.replace(r,o);let a=0,l=this.firstChunk;for(;l;){let c=l.end;if(l.edited)i[a]||(l.content=l.content.replace(r,o),l.content.length&&(s=l.content[l.content.length-1]===`
9
9
  `));else for(a=l.start;a<c;){if(!i[a]){let u=this.original[a];u===`
10
- `?s=!0:u!=="\r"&&s&&(s=!1,a===l.start||(this._splitChunk(l,a),l=l.next),l.prependRight(e))}a+=1}a=l.end,l=l.next}return this.outro=this.outro.replace(r,o),this}insert(){throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)")}insertLeft(e,t){return O.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),O.insertLeft=!0),this.appendLeft(e,t)}insertRight(e,t){return O.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),O.insertRight=!0),this.prependRight(e,t)}move(e,t,r){if(e=e+this.offset,t=t+this.offset,r=r+this.offset,r>=e&&r<=t)throw new Error("Cannot move a selection inside itself");this._split(e),this._split(t),this._split(r);let i=this.byStart[e],s=this.byEnd[t],o=i.previous,a=s.next,l=this.byStart[r];if(!l&&s===this.lastChunk)return this;let c=l?l.previous:this.lastChunk;return o&&(o.next=a),a&&(a.previous=o),c&&(c.next=i),l&&(l.previous=s),i.previous||(this.firstChunk=s.next),s.next||(this.lastChunk=i.previous,this.lastChunk.next=null),i.previous=c,s.next=l||null,c||(this.firstChunk=i),l||(this.lastChunk=s),this}overwrite(e,t,r,i){return i=i||{},this.update(e,t,r,{...i,overwrite:!i.contentOnly})}update(e,t,r,i){if(e=e+this.offset,t=t+this.offset,typeof r!="string")throw new TypeError("replacement content must be a string");if(this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}if(t>this.original.length)throw new Error("end is out of bounds");if(e===t)throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");this._split(e),this._split(t),i===!0&&(O.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),O.storeName=!0),i={storeName:!0});let s=i!==void 0?i.storeName:!1,o=i!==void 0?i.overwrite:!1;if(s){let c=this.original.slice(e,t);Object.defineProperty(this.storedNames,c,{writable:!0,value:!0,enumerable:!0})}let a=this.byStart[e],l=this.byEnd[t];if(a){let c=a;for(;c!==l;){if(c.next!==this.byStart[c.end])throw new Error("Cannot overwrite across a split point");c=c.next,c.edit("",!1)}a.edit(r,s,!o)}else{let c=new Q(e,t,"").edit(r,s);l.next=c,c.previous=l}return this}prepend(e){if(typeof e!="string")throw new TypeError("outro content must be a string");return this.intro=e+this.intro,this}prependLeft(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let r=this.byEnd[e];return r?r.prependLeft(t):this.intro=t+this.intro,this}prependRight(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let r=this.byStart[e];return r?r.prependRight(t):this.outro=t+this.outro,this}remove(e,t){if(e=e+this.offset,t=t+this.offset,this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}if(e===t)return this;if(e<0||t>this.original.length)throw new Error("Character is out of bounds");if(e>t)throw new Error("end must be greater than start");this._split(e),this._split(t);let r=this.byStart[e];for(;r;)r.intro="",r.outro="",r.edit(""),r=t>r.end?this.byStart[r.end]:null;return this}reset(e,t){if(e=e+this.offset,t=t+this.offset,this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}if(e===t)return this;if(e<0||t>this.original.length)throw new Error("Character is out of bounds");if(e>t)throw new Error("end must be greater than start");this._split(e),this._split(t);let r=this.byStart[e];for(;r;)r.reset(),r=t>r.end?this.byStart[r.end]:null;return this}lastChar(){if(this.outro.length)return this.outro[this.outro.length-1];let e=this.lastChunk;do{if(e.outro.length)return e.outro[e.outro.length-1];if(e.content.length)return e.content[e.content.length-1];if(e.intro.length)return e.intro[e.intro.length-1]}while(e=e.previous);return this.intro.length?this.intro[this.intro.length-1]:""}lastLine(){let e=this.outro.lastIndexOf(_);if(e!==-1)return this.outro.substr(e+1);let t=this.outro,r=this.lastChunk;do{if(r.outro.length>0){if(e=r.outro.lastIndexOf(_),e!==-1)return r.outro.substr(e+1)+t;t=r.outro+t}if(r.content.length>0){if(e=r.content.lastIndexOf(_),e!==-1)return r.content.substr(e+1)+t;t=r.content+t}if(r.intro.length>0){if(e=r.intro.lastIndexOf(_),e!==-1)return r.intro.substr(e+1)+t;t=r.intro+t}}while(r=r.previous);return e=this.intro.lastIndexOf(_),e!==-1?this.intro.substr(e+1)+t:this.intro+t}slice(e=0,t=this.original.length-this.offset){if(e=e+this.offset,t=t+this.offset,this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}let r="",i=this.firstChunk;for(;i&&(i.start>e||i.end<=e);){if(i.start<t&&i.end>=t)return r;i=i.next}if(i&&i.edited&&i.start!==e)throw new Error(`Cannot use replaced character ${e} as slice start anchor.`);let s=i;for(;i;){i.intro&&(s!==i||i.start===e)&&(r+=i.intro);let o=i.start<t&&i.end>=t;if(o&&i.edited&&i.end!==t)throw new Error(`Cannot use replaced character ${t} as slice end anchor.`);let a=s===i?e-i.start:0,l=o?i.content.length+t-i.end:i.content.length;if(r+=i.content.slice(a,l),i.outro&&(!o||i.end===t)&&(r+=i.outro),o)break;i=i.next}return r}snip(e,t){let r=this.clone();return r.remove(0,e),r.remove(t,r.original.length),r}_split(e){if(this.byStart[e]||this.byEnd[e])return;let t=this.lastSearchedChunk,r=t,i=e>t.end;for(;t;){if(t.contains(e))return this._splitChunk(t,e);if(t=i?this.byStart[t.end]:this.byEnd[t.start],t===r)return;r=t}}_splitChunk(e,t){if(e.edited&&e.content.length){let i=je(this.original)(t);throw new Error(`Cannot split a chunk that has already been edited (${i.line}:${i.column} – "${e.original}")`)}let r=e.split(t);return this.byEnd[t]=e,this.byStart[t]=r,this.byEnd[r.end]=r,e===this.lastChunk&&(this.lastChunk=r),this.lastSearchedChunk=e,!0}toString(){let e=this.intro,t=this.firstChunk;for(;t;)e+=t.toString(),t=t.next;return e+this.outro}isEmpty(){let e=this.firstChunk;do if(e.intro.length&&e.intro.trim()||e.content.length&&e.content.trim()||e.outro.length&&e.outro.trim())return!1;while(e=e.next);return!0}length(){let e=this.firstChunk,t=0;do t+=e.intro.length+e.content.length+e.outro.length;while(e=e.next);return t}trimLines(){return this.trim("[\\r\\n]")}trim(e){return this.trimStart(e).trimEnd(e)}trimEndAborted(e){let t=new RegExp((e||"\\s")+"+$");if(this.outro=this.outro.replace(t,""),this.outro.length)return!0;let r=this.lastChunk;do{let i=r.end,s=r.trimEnd(t);if(r.end!==i&&(this.lastChunk===r&&(this.lastChunk=r.next),this.byEnd[r.end]=r,this.byStart[r.next.start]=r.next,this.byEnd[r.next.end]=r.next),s)return!0;r=r.previous}while(r);return!1}trimEnd(e){return this.trimEndAborted(e),this}trimStartAborted(e){let t=new RegExp("^"+(e||"\\s")+"+");if(this.intro=this.intro.replace(t,""),this.intro.length)return!0;let r=this.firstChunk;do{let i=r.end,s=r.trimStart(t);if(r.end!==i&&(r===this.lastChunk&&(this.lastChunk=r.next),this.byEnd[r.end]=r,this.byStart[r.next.start]=r.next,this.byEnd[r.next.end]=r.next),s)return!0;r=r.next}while(r);return!1}trimStart(e){return this.trimStartAborted(e),this}hasChanged(){return this.original!==this.toString()}_replaceRegexp(e,t){function r(s,o){return typeof t=="string"?t.replace(/\$(\$|&|\d+)/g,(a,l)=>l==="$"?"$":l==="&"?s[0]:+l<s.length?s[+l]:`$${l}`):t(...s,s.index,o,s.groups)}function i(s,o){let a,l=[];for(;a=s.exec(o);)l.push(a);return l}if(e.global)i(e,this.original).forEach(o=>{if(o.index!=null){let a=r(o,this.original);a!==o[0]&&this.overwrite(o.index,o.index+o[0].length,a)}});else{let s=this.original.match(e);if(s&&s.index!=null){let o=r(s,this.original);o!==s[0]&&this.overwrite(s.index,s.index+s[0].length,o)}}return this}_replaceString(e,t){let{original:r}=this,i=r.indexOf(e);return i!==-1&&(typeof t=="function"&&(t=t(e,i,r)),e!==t&&this.overwrite(i,i+e.length,t)),this}replace(e,t){return typeof e=="string"?this._replaceString(e,t):this._replaceRegexp(e,t)}_replaceAllString(e,t){let{original:r}=this,i=e.length;for(let s=r.indexOf(e);s!==-1;s=r.indexOf(e,s+i)){let o=r.slice(s,s+i),a=t;typeof t=="function"&&(a=t(o,s,r)),o!==a&&this.overwrite(s,s+i,a)}return this}replaceAll(e,t){if(typeof e=="string")return this._replaceAllString(e,t);if(!e.global)throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");return this._replaceRegexp(e,t)}};function Dt(n){switch(n.kind){case"event":return"event";case"ref":return"ref";case"spread":return"spread";case"class":case"style":return"class-or-style-directive";case"attr":case"prop":return n.reactive?"reactive-prop":n.expr!==void 0?"expression-prop":void 0;default:return"expression-prop"}}function L(n){let e=[],t=new Map,r=i=>{switch(i.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let s of i.children)r(s);return!1;case"fragment":for(let s of i.children)r(s);return!1;case"element":{let s=!0;for(let a of i.children)r(a)||(s=!1);let o;for(let a of i.props)if(o=Dt(a),o)break;return!o&&!s&&(o=At(i)),i.static=!o,o?t.set(i,o):e.push(i),i.static}default:return!1}};for(let i of Array.isArray(n)?n:[n])r(i);return{staticElements:e,reasons:t}}function At(n){for(let e of n.children){if(e.kind==="expr")return"expression-child";if(e.kind==="component")return"component-child";if(e.kind==="control")return"control-child";if(e.kind==="element"&&!e.static||e.kind==="fragment")return"expression-child"}return"expression-child"}var te={kind:"eager"},jt=["pointerdown","focusin","keydown"],_e=new Set(["eager","idle","visible","interaction","media","never"]),E=class extends Error{};function me(n){return n.startsWith("load:")}function ne(n,e){let t=n.slice(5);if(!_e.has(t))throw new E(`Unknown load strategy 'load:${t}'. Expected one of ${[..._e].join(", ")}.`);switch(t){case"eager":return te;case"idle":return{kind:"idle"};case"never":return{kind:"never"};case"visible":return e?{kind:"visible",rootMargin:e}:{kind:"visible"};case"interaction":return{kind:"interaction",events:e?_t(e):[...jt]};case"media":if(!e)throw new E(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:e};default:throw new E(`Unhandled load strategy '${t}'.`)}}function _t(n){let e=n.split(/[\s,]+/).map(t=>t.trim()).filter(Boolean);if(e.length===0)throw new E("'load:interaction' was given no event names.");return e}function J(n){return n.kind!=="eager"&&n.kind!=="never"}var B=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],F=["Suspense","SuspenseList","Await"],P=["Router","Outlet","Redirect","Link"],Wn=[...B,...F,...P],ge=new Set([...B,...F]);function Je(n={}){let{controlFlowModule:e="@fluixi/dom",coreModule:t="fluixi",routerModule:r="fluixi/router"}=n,i={};for(let s of B)i[s]=e;for(let s of F)i[s]=t;for(let s of P)i[s]=r;return i}function re(n,e={}){let{resolver:t,isBound:r,modules:i,strategyFor:s}=e,o=Je(i),a=new Map,l=new Set,c=d=>{let{name:p}=d;if(!p||p.includes(".")||r?.(p))return;let m=u(p);if(!m){l.add(p);return}let h=m.origin==="builtin"&&ge.has(p)?te:s?.(d)??te;d.source={...m,loading:h},a.set(p,d.source)},u=d=>{if(ge.has(d))return{module:o[d],export:d,origin:"builtin"};let p=t?.resolve(d);if(p)return{module:p.module,export:p.export,origin:"rule"};if(P.includes(d))return{module:o[d],export:d,origin:"builtin"}};return ie(n,d=>{d.kind==="component"&&c(d)}),{resolved:a,unresolved:[...l]}}function ie(n,e){let t=Array.isArray(n)?n:[n];for(let r of t){e(r);let i=r.children;i&&ie(i,e)}}function se(n){let e=[];ie(n,s=>{s.kind==="component"&&s.source&&e.push(s)});let t=new Set,r=new Set;for(let s of e){let{module:o,loading:a}=s.source;a.kind==="eager"&&t.add(o),a.kind==="never"&&r.add(o)}let i=new Map;for(let s of e){let o=s.source;J(o.loading)&&t.has(o.module)&&(o.loading={kind:"eager"},i.set(o.module,(i.get(o.module)??0)+1))}return{collapsed:i,conflicted:[...r].filter(s=>t.has(s))}}var Jt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Be={className:"class",htmlFor:"for"},Bt=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),Ft=new Set(["script","style","textarea","title"]);function ye(n){return Ft.has(n)}function Fe(n){return Be[n]??n}function U(n){return n.kind!=="attr"||n.expr!==void 0||n.name.includes(":")?!1:!Bt.has(n.name)}function ve(n){if(!n.static||ye(n.tag))return!1;for(let e of n.props)if(!U(e))return!1;for(let e of n.children)if(e.kind!=="text"&&!(e.kind==="element"&&ve(e)))return!1;return!0}function H(n){let e=n.props.map(Ht).filter(Boolean).join(""),t=`<${n.tag}${e}>`;return Jt.has(n.tag)?t:`${t}${n.children.map(Ut).join("")}</${n.tag}>`}function Ut(n){if(n.kind==="text")return Xt(n.value);if(n.kind!=="element")throw new Error(`serializeStatic: unexpected ${n.kind}`);return H(n)}function Ht(n){let e=Be[n.name]??n.name,t=n.literal;return t===!0||t===void 0?` ${e}`:t===!1||t===null?"":` ${e}="${qt(String(t))}"`}function qt(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Xt(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var zt="<!--fx-->",Vt="<!--fx/-->";function ae(n){return n.kind==="expr"||n.kind==="component"||n.kind==="control"}function Wt(n){return n.kind==="text"||n.kind==="element"&&Ue(n)}function Ue(n){return n.svg||ye(n.tag)||!n.props.every(e=>U(e))?!1:n.children.every(e=>Wt(e)||ae(e))}function oe(n){if(ae(n))return!0;let e=n.children;return e?e.some(oe):!1}function He(n){for(let e=0;e<n.children.length;e++){let t=n.children[e];if(t.kind==="text"&&(t.value===""||n.children[e+1]?.kind==="text"))return!1}return n.children.every(e=>e.kind!=="element"||He(e))}function qe(n){if(!Ue(n)||!He(n)||!n.children.some(oe))return null;let e=[],t=[],r=0,i=o=>{let a=`_n$${r++}`;return e.push({ref:a,expr:o}),a};return s(n,"_el$"),{html:Kt(n),tag:n.tag,steps:e,holes:t};function s(o,a){let l=-1;o.children.forEach((u,d)=>{oe(u)&&(l=d)});let c=null;for(let u=0;u<=l;u++){let d=o.children[u],p=c?`${c}.nextSibling`:`${a}.firstChild`;if(ae(d)){let h=i(p),g=i(`holeEnd(${h})`);t.push({parentRef:a,startRef:h,endRef:g,node:d}),c=g;continue}let m=i(p);d.kind==="element"&&oe(d)&&s(d,m),c=m}}}function Kt(n){return H(Xe(n)).split(ze).join(zt+Vt)}function Xe(n){return{...n,children:n.children.map(e=>ae(e)?{kind:"text",value:ze}:e.kind==="element"?Xe(e):e)}}var ze="\0fx-hole\0";var xe={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},sr={version:2,module:"@fluixi/dom",symbols:[...xe.symbols,"template","cloneTemplate","walk"]};var Gt={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function Yt(n){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(n)}function We(n){return Yt(n)?n:JSON.stringify(n)}function Zt(n){return n.expr!==void 0?n.reactive?`() => (${n.expr})`:`(${n.expr})`:JSON.stringify(n.literal??!0)}function Qt(n){return n.expr!==void 0?`(${n.expr})`:JSON.stringify(n.literal??!0)}function en(n,e,t){let r=n.filter(a=>a.kind==="spread"),s=n.filter(a=>a.kind!=="spread").map(a=>`${We(a.name)}: ${Zt(a)}`);e!=null&&s.push(`children: ${e}`);let o=`{ ${s.join(", ")} }`;return r.length>0?(t.add("mergeProps"),`mergeProps(${r.map(a=>a.expr).join(", ")}, ${o})`):o}function Ke(n,e,t){return n.length===1?q(n[0],e,t):`[${n.map(r=>q(r,e,t)).join(", ")}]`}function Ve(n,e,t,r,i){r.add("createMemo"),r.add("createComponent");let s=e.filter(c=>c.kind==="spread"),a=e.filter(c=>c.kind!=="spread").map(c=>`get ${We(c.name)}() { return ${Qt(c)}; }`);t.length>0&&a.push(`get children() { return ${Ke(t,r,i)}; }`);let l=`{ ${a.join(", ")} }`;return s.length>0&&(r.add("mergeProps"),l=`mergeProps(${s.map(c=>c.expr).join(", ")}, ${l})`),`createMemo(() => createComponent(${n}, ${l}))`}function tn(n,e){let t=Fe(e.name),r=e.literal;return r===!0||r===void 0?`${n}.setAttribute(${JSON.stringify(t)}, "");`:r===!1||r===null?"":`${n}.setAttribute(${JSON.stringify(t)}, ${JSON.stringify(String(r))});`}var Ge=!1;function q(n,e,t){switch(n.kind){case"text":return JSON.stringify(n.value);case"expr":return n.reactive?`() => (${n.code})`:`(${n.code})`;case"fragment":return n.children.length===0?"null":Ke(n.children,e,t);case"component":return Ve(n.name,n.props,n.children,e,t);case"control":{let r=Gt[n.control]??n.control;return e.add(r),Ve(r,n.props,n.children,e,t)}case"element":{if(t&&n.static&&!n.svg&&ve(n)){e.add("templateNode");let a=`_tmpl$${t.length}`;return t.push({id:a,html:H(n),tag:n.tag,svg:!1}),`templateNode(${a}, ${JSON.stringify(n.tag)})`}if(t&&Ge){let a=qe(n);if(a){e.add("templateNode"),e.add("insert"),e.add("holeEnd"),e.add("holeContent"),e.add("holeScope");let l=`_tmpl$${t.length}`;t.push({id:l,html:a.html,tag:a.tag,svg:!1});let c=[`const _el$ = templateNode(${l}, ${JSON.stringify(a.tag)}, true);`];for(let u of a.steps)c.push(`const ${u.ref} = ${u.expr};`);for(let u of a.holes)c.push(`insert(${u.parentRef}, holeScope(${u.startRef}, () => (${q(u.node,e,t)})), ${u.endRef}, holeContent(${u.startRef}, ${u.endRef}));`);return c.push("return _el$;"),`(() => { ${c.join(" ")} })()`}}e.add("createNativeElement");let r=JSON.stringify(n.tag),i="_el$",s=[],o=n.svg?`${r}, true`:r;if(s.push(`const ${i} = createNativeElement(${o});`),n.props.length>0)if(!n.svg&&n.props.every(U))for(let a of n.props)s.push(tn(i,a));else{e.add("spread");let a=n.svg?", isSVG: true":"";s.push(`spread({ element: ${i}, props: ${en(n.props,null,e)}${a} });`)}for(let a of n.children){e.add("insert");let l=q(a,e,t),c=a.kind==="expr"&&a.reactive||a.kind==="component"||a.kind==="control";s.push(c?`insert(${i}, ${l}, null);`:`insert(${i}, ${l});`)}return s.push(`return ${i};`),`(() => { ${s.join(" ")} })()`}}}function le(n,e){if(!e||e.length===0)return n;let t=new Map(e.map(r=>[r.id,JSON.stringify(r.html)]));return n.replace(/_tmpl\$\d+/g,r=>t.get(r)??r)}var M={name:"imperative",contract:xe,emit(n,e){let t=new Set,r=e?.templateClone!==!1?[]:void 0;return Ge=e?.partialTemplates===!0,{code:q(n,t,r),imports:Array.from(t),templates:r}}};var nn=n=>"components"in n;function Ye(n,e){return n.replace(/\$(\d+)/g,(t,r)=>e[Number(r)]??t)}function rn(n,e){return typeof e=="string"?{module:e,export:n}:e}function ce(n=[]){let e=new Map,t=[],r=[];for(let o of n){if(!nn(o)){r.push(o);continue}for(let[a,l]of Object.entries(o.components)){let c=rn(a,l),u=e.get(a);if(u&&u.module!==c.module){let d=t.find(p=>p.name===a);d?d.modules.push(c.module):t.push({name:a,modules:[u.module,c.module]});continue}e.set(a,c)}}let i=new Map;return{resolve:o=>{if(i.has(o))return i.get(o);let a=e.get(o);if(!a)for(let l of r){let c=o.match(new RegExp(l.match.source,l.match.flags.replace("g","")));if(c){a={module:Ye(l.module,c),export:l.export?Ye(l.export,c):o};break}}return i.set(o,a),a},names:()=>[...e.keys()],conflicts:()=>t}}import{parseTemplate as sn}from"@fluixi/template-parser";function X(n){let e=n.split(/\r\n|\n|\r/),t=0;for(let i=0;i<e.length;i++)/[^ \t]/.test(e[i])&&(t=i);let r="";for(let i=0;i<e.length;i++){let s=e[i].replace(/\t/g," ");i!==0&&(s=s.replace(/^ +/,"")),i!==e.length-1&&(s=s.replace(/ +$/,"")),s&&(i!==t&&(s+=" "),r+=s)}return r}var Ze=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function on(n){return n.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function Qe(n){return n.charAt(0).toUpperCase()+n.slice(1)}var Ne=class{constructor(e,t){this.holes=e;this.used=t}hole(e){return this.holes[e]??{code:"undefined",reactive:!1}}emit(e){let{code:t,imports:r,templates:i}=M.emit(e,{});for(let s of r)this.used.add(s);return le(t,i)}lowerRoot(e){let t=this.lowerChildren(e);return t.length===1?t[0]:{kind:"fragment",children:t}}lowerChildren(e){let t=[];for(let r=0;r<e.length;r++){let i=e[r];if(i.kind==="Element"||i.kind==="Component"){let o=i.attributes.find(a=>a.kind==="IfDirective");if(o&&o.kind==="IfDirective"){let a=r+1;a<e.length&&this.isBlankText(e[a])&&a++;let l=e[a],c=l&&(l.kind==="Element"||l.kind==="Component")&&l.attributes.some(u=>u.kind==="ElseDirective");t.push(this.lowerIf(i,o.hole,c?l:null)),c&&(r=a);continue}if(i.attributes.some(a=>a.kind==="EachDirective")){t.push(this.lowerEach(i));continue}}let s=this.lowerNode(i);s&&t.push(s)}return t}isBlankText(e){return e.kind==="Text"&&!e.raw&&X(e.value)===""}lowerNode(e){switch(e.kind){case"Text":{if(e.raw)return{kind:"text",value:e.value};let t=X(e.value);return t?{kind:"text",value:t}:null}case"Comment":return null;case"Expression":{let t=this.hole(e.hole);return{kind:"expr",code:t.code,reactive:t.reactive}}case"Fragment":return{kind:"fragment",children:this.lowerChildren(e.children)};case"Element":return this.lowerElement(e);case"Component":return this.lowerComponent(e);default:return null}}lowerElement(e){let t=e.attributes.find(r=>r.kind==="Attribute"&&r.name==="is");if(e.tag==="component"&&t&&t.value&&t.value.kind==="hole"){let r=e.attributes.filter(s=>s!==t),i=this.lowerComponent({...e,kind:"Component",tag:"Dynamic",tagHole:null,attributes:r});return i.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(t.value.hole).code})`}),i}return{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:this.lowerAttributes(e.attributes),children:this.lowerChildren(e.children),static:!1}}lowerComponent(e){let t=e.tagHole!=null?this.hole(e.tagHole).code:e.tag,r=this.lowerAttributes(e.attributes),{slots:i,rest:s}=this.partitionSlots(e.children);for(let[l,c]of i){let u=c.length===1?c[0]:{kind:"fragment",children:c},d={name:l,kind:"attr",expr:this.emit(u),jsxElement:!0},p=r.findIndex(m=>m.name===l);p>=0?r[p]=d:r.push(d)}let o=e.attributes.find(l=>l.kind==="LoadDirective"),a=o?ne(`load:${o.strategy}`,o.modifier):void 0;return{kind:"component",name:t,props:r,children:this.lowerChildren(s),...a?{load:a}:{}}}partitionSlots(e){let t=new Map,r=[];for(let i of e){if(i.kind==="Element"||i.kind==="Component"){let s=i.attributes.find(o=>o.kind==="Attribute"&&o.name==="slot");if(s&&s.value&&s.value.kind==="static"){let o={...i,attributes:i.attributes.filter(c=>c!==s)},a=o.kind==="Element"?this.lowerElement(o):this.lowerComponent(o),l=t.get(s.value.value)??[];l.push(a),t.set(s.value.value,l);continue}}r.push(i)}return{slots:t,rest:r}}lowerIf(e,t,r){let i=this.hole(t),s=[{name:"when",kind:"attr",expr:i.code,reactive:i.reactive}];if(r){let a=this.stripAndLower(r,l=>l.kind==="ElseDirective");s.push({name:"fallback",kind:"attr",expr:this.emit(a),jsxElement:!0})}let o=this.stripAndLower(e,a=>a.kind==="IfDirective");return{kind:"component",name:"Show",props:s,children:[o]}}lowerEach(e){let t=e.attributes.find(l=>l.kind==="EachDirective");if(!t||t.kind!=="EachDirective")return this.lowerNode(e);let r=this.hole(t.hole),i=[{name:"each",kind:"attr",expr:r.code,reactive:r.reactive}];if(t.key){let l="static"in t.key?`(item) => item[${JSON.stringify(t.key.static)}]`:this.hole(t.key.hole).code;i.push({name:"by",kind:"attr",expr:l})}let s=this.itemArrow(e),o;if(s){let l={kind:"expr",code:s.body,reactive:s.bodyReactive},c=this.rebuildWithChildren(e,[l]);o=`(${s.params.join(", ")}) => (${this.emit(c)})`}else{let l=this.stripAndLower(e,c=>c.kind==="EachDirective");o=`() => (${this.emit(l)})`}return{kind:"component",name:"For",props:i,children:[{kind:"expr",code:o,reactive:!1}]}}itemArrow(e){let t=e.children.filter(r=>!this.isBlankText(r));return t.length!==1||t[0].kind!=="Expression"?null:this.hole(t[0].hole).arrow??null}stripAndLower(e,t){let r={...e,attributes:e.attributes.filter(i=>!t(i))};return r.kind==="Element"?this.lowerElement(r):this.lowerComponent(r)}rebuildWithChildren(e,t){let r=this.lowerAttributes(e.attributes.filter(i=>i.kind!=="EachDirective"));return e.kind==="Element"?{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:r,children:t,static:!1}:{kind:"component",name:e.tag,props:r,children:t}}lowerAttributes(e){let t=[],r=[],i=!1,s=[],o=!1,a=[];for(let l of e)switch(l.kind){case"IfDirective":case"EachDirective":case"ElseDirective":break;case"Attribute":t.push(this.plainAttr(l));break;case"PropertyBinding":t.push({name:l.name,kind:"prop",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"EventBinding":t.push(this.eventProp(l));break;case"RefBinding":t.push({name:"ref",kind:"ref",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"Spread":t.push({name:"",kind:"spread",expr:this.hole(l.hole).code});break;case"ClassDirective":{let c=this.hole(l.hole);r.push(`${JSON.stringify(l.name)}: ${c.code}`),i=i||c.reactive;break}case"StyleDirective":{let c=this.hole(l.hole);s.push(`${JSON.stringify(l.name)}: ${c.code}`),o=o||c.reactive;break}case"BindDirective":t.push(...this.bindProps(l.name,this.hole(l.hole).code));break;case"UseDirective":{let c=l.name??(l.hole!=null?this.hole(l.hole).code:null);if(!c)break;a.push(l.name!=null&&l.hole!=null?`[${c}, () => (${this.hole(l.hole).code})]`:`[${c}]`);break}}return r.length>0&&t.push({name:"classList",kind:"attr",expr:`{ ${r.join(", ")} }`,reactive:i}),s.length>0&&t.push({name:"style",kind:"attr",expr:`{ ${s.join(", ")} }`,reactive:o}),a.length>0&&t.push({name:"use",kind:"attr",expr:`[${a.join(", ")}]`}),t}eventProp(e){let t=e.name.toLowerCase(),r=this.hole(e.hole).code;if(!(e.syntax==="colon"||e.modifiers.length>0))return{name:"on"+Qe(e.name),kind:"event",event:{name:t,delegated:Ze.has(t)},expr:r};let s=this.wrapHandler(r,e.modifiers),o=this.eventOptions(e.modifiers),a=o?`[${s}, ${o}]`:s;return{name:"on:"+t,kind:"attr",expr:a}}wrapHandler(e,t){let r=t.includes("self")?"if (e.target !== e.currentTarget) return; ":"",i=[];return t.includes("prevent")&&i.push("e.preventDefault();"),t.includes("stop")&&i.push("e.stopPropagation();"),!r&&i.length===0?e:`(e) => { ${r}${i.join(" ")} return (${e})(e); }`}eventOptions(e){let t=[];return e.includes("capture")&&t.push("capture: true"),e.includes("once")&&t.push("once: true"),e.includes("passive")&&t.push("passive: true"),t.length?`{ ${t.join(", ")} }`:null}bindProps(e,t){let r=e==="checked",i=r?"change":"input",s=r?"checked":"value";this.used.add("bindPair");let o=`bindPair(${t})`;return[{name:e,kind:"attr",expr:`${o}[0]()`,reactive:!0},{name:"on"+Qe(i),kind:"event",event:{name:i,delegated:Ze.has(i)},expr:`(e) => ${o}[1](e.target.${s})`}]}plainAttr(e){let t=e.value,r=e.name;e.name==="class"?r=t&&t.kind==="hole"&&this.hole(t.hole).object?"classList":"className":e.name==="html"&&(r="innerHTML");let s={name:r,kind:"attr"};if(t==null)return s.literal=!0,s;if(t.kind==="static")return s.literal=t.value,s;if(t.kind==="hole"){let l=this.hole(t.hole);return s.expr=l.code,s.reactive=l.reactive,s}let o=!1,a=t.parts.map(l=>{if("text"in l)return on(l.text);let c=this.hole(l.hole);return o=o||c.reactive,"${"+c.code+"}"}).join("");return s.expr="`"+a+"`",s.reactive=o,s}};function et(n,e,t,r={}){let{root:i}=sn(n,{svg:r.svg});return new Ne(e,t).lowerRoot(i.children)}function tt(n,e,t={}){let r=new Set,i=et(n,[...e],r,{svg:t.svg});L(i),re(i,{resolver:ce(t.resolve??[]),modules:{controlFlowModule:t.controlFlowModule??"@fluixi/dom",coreModule:t.coreModule??"fluixi",routerModule:t.routerModule??"fluixi/router"},strategyFor:l=>l.load}),se(i);let{code:s,imports:o,templates:a}=M.emit(i,{templateClone:t.templateClone,partialTemplates:t.partialTemplates});for(let l of o)r.add(l);return t.hoistTemplates?{code:s,imports:[...r],ir:i,templates:a}:{code:le(s,a),imports:[...r],ir:i}}var an="children";function D(n){switch(n.kind){case"call":return!0;case"member":return n.property!==an;case"compound":return n.parts.some(D);case"opaque":return!1}}var ln=new Set(["CallExpression","OptionalCallExpression"]),cn=new Set(["MemberExpression","OptionalMemberExpression"]);function A(n){if(!n)return{kind:"opaque"};if(ln.has(n.type))return{kind:"call"};if(cn.has(n.type)){let e=n.property;return{kind:"member",property:!(n.computed===!0)&&e?.type==="Identifier"?e.name:null}}return n.type==="ConditionalExpression"?{kind:"compound",parts:[n.test,n.consequent,n.alternate].map(z)}:n.type==="LogicalExpression"||n.type==="BinaryExpression"?{kind:"compound",parts:[n.left,n.right].map(z)}:n.type==="TemplateLiteral"?{kind:"compound",parts:n.expressions.map(z)}:n.type==="ObjectExpression"?{kind:"compound",parts:n.properties.filter(t=>(t.type==="ObjectProperty"||t.type==="Property")&&t.computed!==!0).map(t=>z(t.value))}:n.type==="ArrayExpression"?{kind:"compound",parts:n.elements.filter(t=>t!=null&&t.type!=="SpreadElement").map(z)}:{kind:"opaque"}}var z=n=>A(n);var un=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),dn=/^on[A-Z]/,pn=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]),it=n=>D(A(n));function V(n){if(n.type==="StringLiteral"||n.type==="NumericLiteral"||n.type==="BooleanLiteral"||n.type==="Literal"&&(typeof n.value=="string"||typeof n.value=="number"||typeof n.value=="boolean"))return n.value}var be=n=>!!n&&typeof V(n)=="string";function fn(n,e){return n.type==="JSXIdentifier"?{tag:n.name,component:n.name[0]!==n.name[0].toLowerCase()}:n.type==="JSXMemberExpression"?{tag:e.code(n),component:!0}:n.type==="JSXNamespacedName"?{tag:`${n.namespace.name}:${n.name.name}`,component:!1}:{tag:"div",component:!1}}function we(n){return n.type==="JSXIdentifier"?n.name==="class"?"className":n.name:n.type==="JSXNamespacedName"?`${n.namespace.name}:${n.name.name}`:"unknown"}function hn(n,e){let t=we(n.name),r=dn.test(t),i=r||t.startsWith("on:")||t==="ref",o={name:t,kind:r?"event":"attr"};if(r){let l=t.slice(2).toLowerCase();o.event={name:l,delegated:pn.has(l)}}let a=n.value;if(a==null)return o.literal=!0,o;if(be(a))return o.literal=V(a),o;if(a.type==="JSXExpressionContainer"&&a.expression?.type!=="JSXEmptyExpression"){let l=a.expression,c=V(l);return c!==void 0?(o.literal=c,o):(o.expr=e.code(l),o.reactive=i?!1:it(l),(l.type==="JSXElement"||l.type==="JSXFragment")&&(o.jsxElement=!0),o)}return o.literal=!0,o}function nt(n,e){let t=n.value;return t==null?null:be(t)?JSON.stringify(V(t)):t.type==="JSXExpressionContainer"&&t.expression?.type!=="JSXEmptyExpression"?e.code(t.expression):null}function mn(n,e){let t=[],r=[];for(let i of n){if(i.type==="JSXSpreadAttribute"){t.push({name:"",kind:"spread",expr:e.code(i.argument)});continue}if(i.type!=="JSXAttribute"||me(we(i.name)))continue;let s=i.name.type==="JSXNamespacedName"?i.name.namespace.name:null;if(s==="use"){let o=i.name.name.name;e.used.add(o);let a=nt(i,e);r.push(a!=null?`[${o}, () => (${a})]`:`[${o}]`);continue}if(s==="oncapture"){let o=i.name.name.name.toLowerCase(),a=nt(i,e)??"undefined";t.push({name:"on:"+o,kind:"attr",expr:`[${a}, { capture: true }]`});continue}t.push(hn(i,e))}return r.length>0&&t.push({name:"use",kind:"attr",expr:`[${r.join(", ")}]`}),t}function rt(n,e){let t=[];for(let r of n)if(r.type==="JSXText"){let i=X(r.value);i&&t.push({kind:"text",value:i})}else if(r.type==="JSXExpressionContainer"){if(r.expression?.type!=="JSXEmptyExpression"){let i=r.expression;t.push({kind:"expr",code:e.code(i),reactive:it(i)})}}else r.type==="JSXElement"||r.type==="JSXFragment"?t.push(st(r,e)):r.type==="JSXSpreadChild"&&t.push({kind:"expr",code:e.code(r.expression),reactive:!1});return t}function gn(n){for(let e of n){if(e.type!=="JSXAttribute")continue;let t=we(e.name);if(me(t)){if(e.value&&!be(e.value))throw new E(`'${t}' needs a literal value, not an expression — the strategy is compile-time.`);return ne(t,e.value?V(e.value):null)}}}function st(n,e){if(n.type==="JSXFragment")return{kind:"fragment",children:rt(n.children,e)};let{tag:t,component:r}=fn(n.openingElement.name,e),i=mn(n.openingElement.attributes,e),s=rt(n.children,e);if(r){let o=gn(n.openingElement.attributes);return{kind:"component",name:t,props:i,children:s,...o?{load:o}:{}}}return{kind:"element",tag:t,svg:un.has(t),props:i,children:s,static:!1}}function ot(n,e){let t=st(n,e);return L(t),t}function C(n,e){if(n)switch(n.type){case"Identifier":e.add(n.name);return;case"ObjectPattern":for(let t of n.properties)t.type==="RestElement"?C(t.argument,e):C(t.value,e);return;case"ArrayPattern":for(let t of n.elements)C(t,e);return;case"AssignmentPattern":C(n.left,e);return;case"RestElement":C(n.argument,e);return}}function at(n,e){switch(n.type){case"ImportDeclaration":for(let t of n.specifiers)C(t.local,e);return;case"VariableDeclaration":for(let t of n.declarations)C(t.id,e);return;case"FunctionDeclaration":case"ClassDeclaration":C(n.id,e);return;case"ExportNamedDeclaration":case"ExportDefaultDeclaration":n.declaration&&at(n.declaration,e);return}}function Re(n){let e=new Set;for(let t of n.body)at(t,e);return e}import{parse as Ar}from"@babel/parser";function w(n,e){if(n)switch(n.type){case"Identifier":e.add(n.name);return;case"ObjectPattern":for(let t of n.properties)t.type==="RestElement"?w(t.argument,e):w(t.value,e);return;case"ArrayPattern":for(let t of n.elements)w(t,e);return;case"AssignmentPattern":w(n.left,e);return;case"RestElement":w(n.argument,e);return}}function Se(n){switch(n.type){case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":case"NullLiteral":case"BigIntLiteral":case"RegExpLiteral":case"Identifier":return!0;case"Literal":return!0;case"TemplateLiteral":return n.expressions.every(Se);case"UnaryExpression":return Se(n.argument);case"MemberExpression":return!1;default:return!1}}function ue(n,e){if(!(!n||typeof n!="object")){e(n);for(let t of Object.keys(n)){if(t==="loc"||t==="range"||t==="leadingComments"||t==="trailingComments")continue;let r=n[t];if(Array.isArray(r))for(let i of r)i&&typeof i=="object"&&ue(i,e);else r&&typeof r=="object"&&typeof r.type=="string"&&ue(r,e)}}}function yn(n){let e=new Set;return ue(n,t=>{if(t.type==="AssignmentExpression")w(t.left,e);else if(t.type==="UpdateExpression"){let r=t.argument;r?.type==="Identifier"&&e.add(r.name)}}),e}function vn(n,e){let t=new Set,r=i=>{let s=new Set;w(i,s);for(let o of s)e.has(o)&&t.add(o)};return ue(n,i=>{switch(i.type){case"VariableDeclarator":r(i.id);return;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":r(i.id);for(let s of i.params??[])r(s);return;case"CatchClause":r(i.param);return;case"ClassDeclaration":case"ClassExpression":r(i.id);return}}),t}function lt(n,e,t){for(let r of n.properties??[]){if(r.type==="RestElement"){let u=r.argument;if(u?.type!=="Identifier"||e.length>0){let d=new Set;w(u,d);for(let p of d)t.bails.push({name:p,reason:"rest"});continue}t.rest={name:u.name,keys:[]};continue}if(r.computed){let u=new Set;w(r.value,u);for(let d of u)t.bails.push({name:d,reason:"computed"});continue}let i=r.key,s=i.type==="Identifier"?i.name:i.value,o=r.value,a;o.type==="AssignmentPattern"&&(a=o.right,o=o.left);let l=[...e,s];if(o.type==="Identifier"){if(a&&!Se(a)){t.bails.push({name:o.name,reason:"unsafe-default"});continue}t.reads.push({name:o.name,path:l,...a?{fallback:a}:{}});continue}if(o.type==="ObjectPattern"){if(a){let u=new Set;w(o,u);for(let d of u)t.bails.push({name:d,reason:"unsafe-default"});continue}lt(o,l,t);continue}let c=new Set;w(o,c);for(let u of c)t.bails.push({name:u,reason:"computed"})}}function ct(n,e){let t={reads:[],bails:[]};if(n?.type!=="ObjectPattern"||(lt(n,[],t),t.rest&&(e?.type!=="BlockStatement"?(t.bails.push({name:t.rest.name,reason:"rest"}),delete t.rest):t.rest.keys=(n.properties??[]).filter(a=>a.type!=="RestElement"&&!a.computed).map(a=>{let l=a.key;return l.type==="Identifier"?l.name:l.value})),t.reads.length===0&&!t.rest))return t;let r=new Set(t.reads.map(a=>a.name));t.rest&&r.add(t.rest.name);let i=yn(e),s=vn(e,r),o=[];for(let a of t.reads)i.has(a.name)?t.bails.push({name:a.name,reason:"reassigned"}):s.has(a.name)?t.bails.push({name:a.name,reason:"shadowed"}):o.push(a);return t.reads=o,t.rest&&i.has(t.rest.name)?(t.bails.push({name:t.rest.name,reason:"reassigned"}),delete t.rest):t.rest&&s.has(t.rest.name)&&(t.bails.push({name:t.rest.name,reason:"shadowed"}),delete t.rest),t}function ut(n){switch(n){case"rest":return"this rest element cannot be served by splitProps, and copying the props into a plain object would lose the getters";case"computed":return"the property is not known until it runs";case"reassigned":return"the binding is assigned to, and props are read-only";case"shadowed":return"an inner scope binds the same name";case"unsafe-default":return"the default would have to run again on every read"}}function W(n,e,t=null){if(!(!n||typeof n!="object"||typeof n.type!="string")&&!n.type.startsWith("TS")&&e(n,t)!==!1)for(let r of Object.keys(n)){if(r==="loc"||r==="leadingComments"||r==="trailingComments")continue;let i=n[r];if(Array.isArray(i))for(let s of i)W(s,e,n);else i&&typeof i=="object"&&W(i,e,n)}}function dt(n){return!!n&&n[0]>="A"&&n[0]<="Z"}function xn(n){let e=[];return W(n,t=>{if(t.type==="FunctionDeclaration"&&dt(t.id?.name)){e.push(t);return}if(t.type==="VariableDeclarator"&&dt(t.id?.name)){let r=t.init;r&&(r.type==="ArrowFunctionExpression"||r.type==="FunctionExpression")&&e.push(r)}}),e}function Nn(n){let e=new Set;return W(n,t=>{t.type==="Identifier"&&e.add(t.name)}),e}function bn(n,e){if(!e)return!0;switch(e.type){case"MemberExpression":case"OptionalMemberExpression":return!(e.property===n&&!e.computed);case"ObjectProperty":case"ObjectMethod":case"ClassProperty":case"ClassMethod":return!(e.key===n&&!e.computed);case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return e.label!==n;case"ImportSpecifier":case"ExportSpecifier":return!1;default:return!0}}function pt(n,e,t={}){let r=[],i=[],s=new Set;for(let o of xn(n)){let a=o.params?.[0];if(a?.type!=="ObjectPattern")continue;let l=ct(a,o.body);for(let h of l.bails)i.push({name:h.name,reason:h.reason,message:ut(h.reason),start:a.start});if(l.bails.length>0||l.reads.length===0&&!l.rest)continue;let c=Nn(o),u=t.parameterName??"props";for(;c.has(u);)u=`_${u}`;let d=new Map;for(let h of l.reads){let g=`${u}.${h.path.join(".")}`,x=h.fallback;d.set(h.name,x?`(${g} === undefined ? ${e.slice(x.start,x.end)} : ${g})`:g)}let p=a.typeAnnotation;if(r.push({start:a.start,end:p?.start??a.end,code:u}),l.rest){let h=l.rest.keys.map(x=>JSON.stringify(x)).join(", "),g=o.body;r.push({start:g.start+1,end:g.start+1,code:`
11
- const [, ${l.rest.name}] = splitProps(${u}, [${h}]);`}),s.add("splitProps")}let m=[];W(o.body,(h,g)=>{if(h.type!=="Identifier")return;let x=d.get(h.name);if(!x)return;let S=g?.type==="ObjectProperty"&&g.shorthand&&g.value===h;if(!S&&!bn(h,g))return;let R=l.reads.find(I=>I.name===h.name).path;m.push({node:h,parent:S?g:null,text:x,property:R[R.length-1]})});for(let h of m)h.parent?r.push({start:h.parent.start,end:h.parent.end,code:`${h.node.name}: ${h.text}`}):r.push({start:h.node.start,end:h.node.end,code:h.text}),wn(h.node,u,h.property)}return{edits:r,diagnostics:i,used:s}}function wn(n,e,t){n.type="MemberExpression",n.computed=!1,n.optional=!1,n.object={type:"Identifier",name:e,start:n.start,end:n.start},n.property={type:"Identifier",name:t,start:n.end,end:n.end},delete n.name}var $="@fluixi/reactive/signal",T={$signal:{export:"signal",module:$,returns:"signal-handle"},$memo:{export:"memo",module:$,returns:"memo-handle"},$effect:{export:"effect",module:$,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:$,returns:"resource-handle"},$selector:{export:"createSelector",module:$,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:$,returns:"memo-accessor"},$untrack:{export:"untrack",module:$,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}},ft={signal:"signal-handle",memo:"memo-handle",effect:"effect",store:"store-handle",createSignal:["signal-accessor","signal-setter"],createMemo:"memo-accessor",createEffect:"effect",createRenderEffect:"effect",createStore:"reactive-object",resource:"resource-handle",createResource:"reactive-object",createSelector:"memo-accessor",createDeferred:"memo-accessor"},Rn=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/store","fluixi"],Sn=new RegExp(`\\$(?:${Object.keys(T).map(n=>n.slice(1)).join("|")})\\s*\\(`);function ht(n){return Sn.test(n)}function mt(n){return Object.prototype.hasOwnProperty.call(T,n)}function gt(n){return Rn.includes(n)}function y(n,e){if(n)switch(n.type){case"Identifier":e.add(n.name);return;case"ObjectPattern":for(let t of n.properties??[])t.type==="RestElement"?y(t.argument,e):y(t.value,e);return;case"ArrayPattern":for(let t of n.elements??[])y(t,e);return;case"AssignmentPattern":y(n.left,e);return;case"RestElement":y(n.argument,e);return}}function K(n,e){if(!(!n||typeof n!="object"||typeof n.type!="string")){e(n);for(let t of Object.keys(n)){if(t==="loc"||t==="leadingComments"||t==="trailingComments")continue;let r=n[t];if(Array.isArray(r))for(let i of r)K(i,e);else r&&typeof r=="object"&&K(r,e)}}}function kn(n,e){if(n.type!=="CallExpression")return;let t=n.callee;if(t?.type!=="Identifier")return;let r=t.name,i=e.primitives.get(r);if(i)return i;let s=T[r];if(s&&!e.shadowed.has(r))return s.returns}function En(n,e,t){if(Array.isArray(e)){n.type==="ArrayPattern"&&n.elements.forEach((r,i)=>{let s=e[i];r?.type==="Identifier"&&s&&t.set(r.name,s)});return}n.type==="Identifier"&&t.set(n.name,e)}function yt(n){let e=new Set;return K(n,t=>{switch(t.type){case"VariableDeclarator":y(t.id,e);return;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":y(t.id,e);for(let r of t.params??[])y(r,e);return;case"ClassDeclaration":case"ClassExpression":y(t.id,e);return;case"ImportSpecifier":case"ImportDefaultSpecifier":case"ImportNamespaceSpecifier":y(t.local,e);return;case"CatchClause":y(t.param,e);return}}),e}function vt(n){let e={kinds:new Map,primitives:new Map,shadowed:new Set},t=n;K(t,r=>{let i=new Set;if(r.type==="VariableDeclarator")y(r.id,i);else if(r.type==="FunctionDeclaration"||r.type==="ClassDeclaration")y(r.id,i);else if(r.type==="ImportDefaultSpecifier"||r.type==="ImportNamespaceSpecifier")y(r.local,i);else if(r.type==="ImportSpecifier")y(r.local,i);else if(r.type==="FunctionExpression"||r.type==="ArrowFunctionExpression"||r.type==="FunctionDeclaration")for(let s of r.params??[])y(s,i);for(let s of i)T[s]&&e.shadowed.add(s)});for(let r of t.body??[])if(r.type==="ImportDeclaration"&&gt(r.source?.value))for(let i of r.specifiers??[]){if(i.type!=="ImportSpecifier")continue;let s=i.imported,o=s.type==="Identifier"?s.name:s.value,a=ft[o];a&&e.primitives.set(i.local.name,a)}return K(t,r=>{if(r.type!=="VariableDeclarator"||!r.init)return;let i=kn(r.init,e);i&&En(r.id,i,e.kinds)}),e}function ke(n,e){if(!(!n||typeof n!="object"||typeof n.type!="string")){e(n);for(let t of Object.keys(n)){if(t==="loc"||t==="leadingComments"||t==="trailingComments")continue;let r=n[t];if(Array.isArray(r))for(let i of r)ke(i,e);else r&&typeof r=="object"&&ke(r,e)}}}function xt(n){let e=[],t=[],r=new Map,i=new Set,{shadowed:s}=vt(n);return ke(n,o=>{if(o.type!=="CallExpression")return;let a=o.callee;if(a?.type!=="Identifier")return;let l=a.name;if(!mt(l))return;if(s.has(l)){i.has(l)||(i.add(l),t.push({name:l,message:`${l} is reserved for the compiler, and this module binds it. The call keeps your binding's meaning; rename it to use the intrinsic.`,start:a.start}));return}let c=T[l];e.push({start:a.start,end:a.end,code:c.export});let u=r.get(c.module)??new Set;u.add(c.export),r.set(c.module,u)}),{edits:e,diagnostics:t,imports:r}}function Nt(n,e){let t=[];for(let[r,i]of[...n.imports].sort(([s],[o])=>s.localeCompare(o))){let s=[...i].filter(o=>!e.has(o)).sort();s.length&&t.push(`import { ${s.join(", ")} } from ${JSON.stringify(r)};`)}return t.length?`${t.join(`
10
+ `?s=!0:u!=="\r"&&s&&(s=!1,a===l.start||(this._splitChunk(l,a),l=l.next),l.prependRight(e))}a+=1}a=l.end,l=l.next}return this.outro=this.outro.replace(r,o),this}insert(){throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)")}insertLeft(e,t){return O.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),O.insertLeft=!0),this.appendLeft(e,t)}insertRight(e,t){return O.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),O.insertRight=!0),this.prependRight(e,t)}move(e,t,r){if(e=e+this.offset,t=t+this.offset,r=r+this.offset,r>=e&&r<=t)throw new Error("Cannot move a selection inside itself");this._split(e),this._split(t),this._split(r);let i=this.byStart[e],s=this.byEnd[t],o=i.previous,a=s.next,l=this.byStart[r];if(!l&&s===this.lastChunk)return this;let c=l?l.previous:this.lastChunk;return o&&(o.next=a),a&&(a.previous=o),c&&(c.next=i),l&&(l.previous=s),i.previous||(this.firstChunk=s.next),s.next||(this.lastChunk=i.previous,this.lastChunk.next=null),i.previous=c,s.next=l||null,c||(this.firstChunk=i),l||(this.lastChunk=s),this}overwrite(e,t,r,i){return i=i||{},this.update(e,t,r,{...i,overwrite:!i.contentOnly})}update(e,t,r,i){if(e=e+this.offset,t=t+this.offset,typeof r!="string")throw new TypeError("replacement content must be a string");if(this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}if(t>this.original.length)throw new Error("end is out of bounds");if(e===t)throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");this._split(e),this._split(t),i===!0&&(O.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),O.storeName=!0),i={storeName:!0});let s=i!==void 0?i.storeName:!1,o=i!==void 0?i.overwrite:!1;if(s){let c=this.original.slice(e,t);Object.defineProperty(this.storedNames,c,{writable:!0,value:!0,enumerable:!0})}let a=this.byStart[e],l=this.byEnd[t];if(a){let c=a;for(;c!==l;){if(c.next!==this.byStart[c.end])throw new Error("Cannot overwrite across a split point");c=c.next,c.edit("",!1)}a.edit(r,s,!o)}else{let c=new Q(e,t,"").edit(r,s);l.next=c,c.previous=l}return this}prepend(e){if(typeof e!="string")throw new TypeError("outro content must be a string");return this.intro=e+this.intro,this}prependLeft(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let r=this.byEnd[e];return r?r.prependLeft(t):this.intro=t+this.intro,this}prependRight(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let r=this.byStart[e];return r?r.prependRight(t):this.outro=t+this.outro,this}remove(e,t){if(e=e+this.offset,t=t+this.offset,this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}if(e===t)return this;if(e<0||t>this.original.length)throw new Error("Character is out of bounds");if(e>t)throw new Error("end must be greater than start");this._split(e),this._split(t);let r=this.byStart[e];for(;r;)r.intro="",r.outro="",r.edit(""),r=t>r.end?this.byStart[r.end]:null;return this}reset(e,t){if(e=e+this.offset,t=t+this.offset,this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}if(e===t)return this;if(e<0||t>this.original.length)throw new Error("Character is out of bounds");if(e>t)throw new Error("end must be greater than start");this._split(e),this._split(t);let r=this.byStart[e];for(;r;)r.reset(),r=t>r.end?this.byStart[r.end]:null;return this}lastChar(){if(this.outro.length)return this.outro[this.outro.length-1];let e=this.lastChunk;do{if(e.outro.length)return e.outro[e.outro.length-1];if(e.content.length)return e.content[e.content.length-1];if(e.intro.length)return e.intro[e.intro.length-1]}while(e=e.previous);return this.intro.length?this.intro[this.intro.length-1]:""}lastLine(){let e=this.outro.lastIndexOf(_);if(e!==-1)return this.outro.substr(e+1);let t=this.outro,r=this.lastChunk;do{if(r.outro.length>0){if(e=r.outro.lastIndexOf(_),e!==-1)return r.outro.substr(e+1)+t;t=r.outro+t}if(r.content.length>0){if(e=r.content.lastIndexOf(_),e!==-1)return r.content.substr(e+1)+t;t=r.content+t}if(r.intro.length>0){if(e=r.intro.lastIndexOf(_),e!==-1)return r.intro.substr(e+1)+t;t=r.intro+t}}while(r=r.previous);return e=this.intro.lastIndexOf(_),e!==-1?this.intro.substr(e+1)+t:this.intro+t}slice(e=0,t=this.original.length-this.offset){if(e=e+this.offset,t=t+this.offset,this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}let r="",i=this.firstChunk;for(;i&&(i.start>e||i.end<=e);){if(i.start<t&&i.end>=t)return r;i=i.next}if(i&&i.edited&&i.start!==e)throw new Error(`Cannot use replaced character ${e} as slice start anchor.`);let s=i;for(;i;){i.intro&&(s!==i||i.start===e)&&(r+=i.intro);let o=i.start<t&&i.end>=t;if(o&&i.edited&&i.end!==t)throw new Error(`Cannot use replaced character ${t} as slice end anchor.`);let a=s===i?e-i.start:0,l=o?i.content.length+t-i.end:i.content.length;if(r+=i.content.slice(a,l),i.outro&&(!o||i.end===t)&&(r+=i.outro),o)break;i=i.next}return r}snip(e,t){let r=this.clone();return r.remove(0,e),r.remove(t,r.original.length),r}_split(e){if(this.byStart[e]||this.byEnd[e])return;let t=this.lastSearchedChunk,r=t,i=e>t.end;for(;t;){if(t.contains(e))return this._splitChunk(t,e);if(t=i?this.byStart[t.end]:this.byEnd[t.start],t===r)return;r=t}}_splitChunk(e,t){if(e.edited&&e.content.length){let i=je(this.original)(t);throw new Error(`Cannot split a chunk that has already been edited (${i.line}:${i.column} – "${e.original}")`)}let r=e.split(t);return this.byEnd[t]=e,this.byStart[t]=r,this.byEnd[r.end]=r,e===this.lastChunk&&(this.lastChunk=r),this.lastSearchedChunk=e,!0}toString(){let e=this.intro,t=this.firstChunk;for(;t;)e+=t.toString(),t=t.next;return e+this.outro}isEmpty(){let e=this.firstChunk;do if(e.intro.length&&e.intro.trim()||e.content.length&&e.content.trim()||e.outro.length&&e.outro.trim())return!1;while(e=e.next);return!0}length(){let e=this.firstChunk,t=0;do t+=e.intro.length+e.content.length+e.outro.length;while(e=e.next);return t}trimLines(){return this.trim("[\\r\\n]")}trim(e){return this.trimStart(e).trimEnd(e)}trimEndAborted(e){let t=new RegExp((e||"\\s")+"+$");if(this.outro=this.outro.replace(t,""),this.outro.length)return!0;let r=this.lastChunk;do{let i=r.end,s=r.trimEnd(t);if(r.end!==i&&(this.lastChunk===r&&(this.lastChunk=r.next),this.byEnd[r.end]=r,this.byStart[r.next.start]=r.next,this.byEnd[r.next.end]=r.next),s)return!0;r=r.previous}while(r);return!1}trimEnd(e){return this.trimEndAborted(e),this}trimStartAborted(e){let t=new RegExp("^"+(e||"\\s")+"+");if(this.intro=this.intro.replace(t,""),this.intro.length)return!0;let r=this.firstChunk;do{let i=r.end,s=r.trimStart(t);if(r.end!==i&&(r===this.lastChunk&&(this.lastChunk=r.next),this.byEnd[r.end]=r,this.byStart[r.next.start]=r.next,this.byEnd[r.next.end]=r.next),s)return!0;r=r.next}while(r);return!1}trimStart(e){return this.trimStartAborted(e),this}hasChanged(){return this.original!==this.toString()}_replaceRegexp(e,t){function r(s,o){return typeof t=="string"?t.replace(/\$(\$|&|\d+)/g,(a,l)=>l==="$"?"$":l==="&"?s[0]:+l<s.length?s[+l]:`$${l}`):t(...s,s.index,o,s.groups)}function i(s,o){let a,l=[];for(;a=s.exec(o);)l.push(a);return l}if(e.global)i(e,this.original).forEach(o=>{if(o.index!=null){let a=r(o,this.original);a!==o[0]&&this.overwrite(o.index,o.index+o[0].length,a)}});else{let s=this.original.match(e);if(s&&s.index!=null){let o=r(s,this.original);o!==s[0]&&this.overwrite(s.index,s.index+s[0].length,o)}}return this}_replaceString(e,t){let{original:r}=this,i=r.indexOf(e);return i!==-1&&(typeof t=="function"&&(t=t(e,i,r)),e!==t&&this.overwrite(i,i+e.length,t)),this}replace(e,t){return typeof e=="string"?this._replaceString(e,t):this._replaceRegexp(e,t)}_replaceAllString(e,t){let{original:r}=this,i=e.length;for(let s=r.indexOf(e);s!==-1;s=r.indexOf(e,s+i)){let o=r.slice(s,s+i),a=t;typeof t=="function"&&(a=t(o,s,r)),o!==a&&this.overwrite(s,s+i,a)}return this}replaceAll(e,t){if(typeof e=="string")return this._replaceAllString(e,t);if(!e.global)throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");return this._replaceRegexp(e,t)}};function Dt(n){switch(n.kind){case"event":return"event";case"ref":return"ref";case"spread":return"spread";case"class":case"style":return"class-or-style-directive";case"attr":case"prop":return n.reactive?"reactive-prop":n.expr!==void 0?"expression-prop":void 0;default:return"expression-prop"}}function L(n){let e=[],t=new Map,r=i=>{switch(i.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let s of i.children)r(s);return!1;case"fragment":for(let s of i.children)r(s);return!1;case"element":{let s=!0;for(let a of i.children)r(a)||(s=!1);let o;for(let a of i.props)if(o=Dt(a),o)break;return!o&&!s&&(o=At(i)),i.static=!o,o?t.set(i,o):e.push(i),i.static}default:return!1}};for(let i of Array.isArray(n)?n:[n])r(i);return{staticElements:e,reasons:t}}function At(n){for(let e of n.children){if(e.kind==="expr")return"expression-child";if(e.kind==="component")return"component-child";if(e.kind==="control")return"control-child";if(e.kind==="element"&&!e.static||e.kind==="fragment")return"expression-child"}return"expression-child"}var te={kind:"eager"},jt=["pointerdown","focusin","keydown"],_e=new Set(["eager","idle","visible","interaction","media","never"]),E=class extends Error{};function me(n){return n.startsWith("load:")}function ne(n,e){let t=n.slice(5);if(!_e.has(t))throw new E(`Unknown load strategy 'load:${t}'. Expected one of ${[..._e].join(", ")}.`);switch(t){case"eager":return te;case"idle":return{kind:"idle"};case"never":return{kind:"never"};case"visible":return e?{kind:"visible",rootMargin:e}:{kind:"visible"};case"interaction":return{kind:"interaction",events:e?_t(e):[...jt]};case"media":if(!e)throw new E(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:e};default:throw new E(`Unhandled load strategy '${t}'.`)}}function _t(n){let e=n.split(/[\s,]+/).map(t=>t.trim()).filter(Boolean);if(e.length===0)throw new E("'load:interaction' was given no event names.");return e}function J(n){return n.kind!=="eager"&&n.kind!=="never"}var B=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],F=["Suspense","SuspenseList","Await"],P=["Router","Outlet","Redirect","Link"],Wn=[...B,...F,...P],ge=new Set([...B,...F]);function Je(n={}){let{controlFlowModule:e="@fluixi/dom",coreModule:t="@fluixi/core",routerModule:r="@fluixi/core/router"}=n,i={};for(let s of B)i[s]=e;for(let s of F)i[s]=t;for(let s of P)i[s]=r;return i}function re(n,e={}){let{resolver:t,isBound:r,modules:i,strategyFor:s}=e,o=Je(i),a=new Map,l=new Set,c=d=>{let{name:p}=d;if(!p||p.includes(".")||r?.(p))return;let m=u(p);if(!m){l.add(p);return}let h=m.origin==="builtin"&&ge.has(p)?te:s?.(d)??te;d.source={...m,loading:h},a.set(p,d.source)},u=d=>{if(ge.has(d))return{module:o[d],export:d,origin:"builtin"};let p=t?.resolve(d);if(p)return{module:p.module,export:p.export,origin:"rule"};if(P.includes(d))return{module:o[d],export:d,origin:"builtin"}};return ie(n,d=>{d.kind==="component"&&c(d)}),{resolved:a,unresolved:[...l]}}function ie(n,e){let t=Array.isArray(n)?n:[n];for(let r of t){e(r);let i=r.children;i&&ie(i,e)}}function se(n){let e=[];ie(n,s=>{s.kind==="component"&&s.source&&e.push(s)});let t=new Set,r=new Set;for(let s of e){let{module:o,loading:a}=s.source;a.kind==="eager"&&t.add(o),a.kind==="never"&&r.add(o)}let i=new Map;for(let s of e){let o=s.source;J(o.loading)&&t.has(o.module)&&(o.loading={kind:"eager"},i.set(o.module,(i.get(o.module)??0)+1))}return{collapsed:i,conflicted:[...r].filter(s=>t.has(s))}}var Jt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Be={className:"class",htmlFor:"for"},Bt=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),Ft=new Set(["script","style","textarea","title"]);function ye(n){return Ft.has(n)}function Fe(n){return Be[n]??n}function H(n){return n.kind!=="attr"||n.expr!==void 0||n.name.includes(":")?!1:!Bt.has(n.name)}function ve(n){if(!n.static||ye(n.tag))return!1;for(let e of n.props)if(!H(e))return!1;for(let e of n.children)if(e.kind!=="text"&&!(e.kind==="element"&&ve(e)))return!1;return!0}function U(n){let e=n.props.map(Ut).filter(Boolean).join(""),t=`<${n.tag}${e}>`;return Jt.has(n.tag)?t:`${t}${n.children.map(Ht).join("")}</${n.tag}>`}function Ht(n){if(n.kind==="text")return Xt(n.value);if(n.kind!=="element")throw new Error(`serializeStatic: unexpected ${n.kind}`);return U(n)}function Ut(n){let e=Be[n.name]??n.name,t=n.literal;return t===!0||t===void 0?` ${e}`:t===!1||t===null?"":` ${e}="${qt(String(t))}"`}function qt(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Xt(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var zt="<!--fx-->",Vt="<!--fx/-->";function ae(n){return n.kind==="expr"||n.kind==="component"||n.kind==="control"}function Wt(n){return n.kind==="text"||n.kind==="element"&&He(n)}function He(n){return n.svg||ye(n.tag)||!n.props.every(e=>H(e))?!1:n.children.every(e=>Wt(e)||ae(e))}function oe(n){if(ae(n))return!0;let e=n.children;return e?e.some(oe):!1}function Ue(n){for(let e=0;e<n.children.length;e++){let t=n.children[e];if(t.kind==="text"&&(t.value===""||n.children[e+1]?.kind==="text"))return!1}return n.children.every(e=>e.kind!=="element"||Ue(e))}function qe(n){if(!He(n)||!Ue(n)||!n.children.some(oe))return null;let e=[],t=[],r=0,i=o=>{let a=`_n$${r++}`;return e.push({ref:a,expr:o}),a};return s(n,"_el$"),{html:Kt(n),tag:n.tag,steps:e,holes:t};function s(o,a){let l=-1;o.children.forEach((u,d)=>{oe(u)&&(l=d)});let c=null;for(let u=0;u<=l;u++){let d=o.children[u],p=c?`${c}.nextSibling`:`${a}.firstChild`;if(ae(d)){let h=i(p),g=i(`holeEnd(${h})`);t.push({parentRef:a,startRef:h,endRef:g,node:d}),c=g;continue}let m=i(p);d.kind==="element"&&oe(d)&&s(d,m),c=m}}}function Kt(n){return U(Xe(n)).split(ze).join(zt+Vt)}function Xe(n){return{...n,children:n.children.map(e=>ae(e)?{kind:"text",value:ze}:e.kind==="element"?Xe(e):e)}}var ze="\0fx-hole\0";var xe={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},sr={version:2,module:"@fluixi/dom",symbols:[...xe.symbols,"template","cloneTemplate","walk"]};var Gt={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function Yt(n){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(n)}function We(n){return Yt(n)?n:JSON.stringify(n)}function Zt(n){return n.expr!==void 0?n.reactive?`() => (${n.expr})`:`(${n.expr})`:JSON.stringify(n.literal??!0)}function Qt(n){return n.expr!==void 0?`(${n.expr})`:JSON.stringify(n.literal??!0)}function en(n,e,t){let r=n.filter(a=>a.kind==="spread"),s=n.filter(a=>a.kind!=="spread").map(a=>`${We(a.name)}: ${Zt(a)}`);e!=null&&s.push(`children: ${e}`);let o=`{ ${s.join(", ")} }`;return r.length>0?(t.add("mergeProps"),`mergeProps(${r.map(a=>a.expr).join(", ")}, ${o})`):o}function Ke(n,e,t){return n.length===1?q(n[0],e,t):`[${n.map(r=>q(r,e,t)).join(", ")}]`}function Ve(n,e,t,r,i){r.add("createMemo"),r.add("createComponent");let s=e.filter(c=>c.kind==="spread"),a=e.filter(c=>c.kind!=="spread").map(c=>`get ${We(c.name)}() { return ${Qt(c)}; }`);t.length>0&&a.push(`get children() { return ${Ke(t,r,i)}; }`);let l=`{ ${a.join(", ")} }`;return s.length>0&&(r.add("mergeProps"),l=`mergeProps(${s.map(c=>c.expr).join(", ")}, ${l})`),`createMemo(() => createComponent(${n}, ${l}))`}function tn(n,e){let t=Fe(e.name),r=e.literal;return r===!0||r===void 0?`${n}.setAttribute(${JSON.stringify(t)}, "");`:r===!1||r===null?"":`${n}.setAttribute(${JSON.stringify(t)}, ${JSON.stringify(String(r))});`}var Ge=!1;function q(n,e,t){switch(n.kind){case"text":return JSON.stringify(n.value);case"expr":return n.reactive?`() => (${n.code})`:`(${n.code})`;case"fragment":return n.children.length===0?"null":Ke(n.children,e,t);case"component":return Ve(n.name,n.props,n.children,e,t);case"control":{let r=Gt[n.control]??n.control;return e.add(r),Ve(r,n.props,n.children,e,t)}case"element":{if(t&&n.static&&!n.svg&&ve(n)){e.add("templateNode");let a=`_tmpl$${t.length}`;return t.push({id:a,html:U(n),tag:n.tag,svg:!1}),`templateNode(${a}, ${JSON.stringify(n.tag)})`}if(t&&Ge){let a=qe(n);if(a){e.add("templateNode"),e.add("insert"),e.add("holeEnd"),e.add("holeContent"),e.add("holeScope");let l=`_tmpl$${t.length}`;t.push({id:l,html:a.html,tag:a.tag,svg:!1});let c=[`const _el$ = templateNode(${l}, ${JSON.stringify(a.tag)}, true);`];for(let u of a.steps)c.push(`const ${u.ref} = ${u.expr};`);for(let u of a.holes)c.push(`insert(${u.parentRef}, holeScope(${u.startRef}, () => (${q(u.node,e,t)})), ${u.endRef}, holeContent(${u.startRef}, ${u.endRef}));`);return c.push("return _el$;"),`(() => { ${c.join(" ")} })()`}}e.add("createNativeElement");let r=JSON.stringify(n.tag),i="_el$",s=[],o=n.svg?`${r}, true`:r;if(s.push(`const ${i} = createNativeElement(${o});`),n.props.length>0)if(!n.svg&&n.props.every(H))for(let a of n.props)s.push(tn(i,a));else{e.add("spread");let a=n.svg?", isSVG: true":"";s.push(`spread({ element: ${i}, props: ${en(n.props,null,e)}${a} });`)}for(let a of n.children){e.add("insert");let l=q(a,e,t),c=a.kind==="expr"&&a.reactive||a.kind==="component"||a.kind==="control";s.push(c?`insert(${i}, ${l}, null);`:`insert(${i}, ${l});`)}return s.push(`return ${i};`),`(() => { ${s.join(" ")} })()`}}}function le(n,e){if(!e||e.length===0)return n;let t=new Map(e.map(r=>[r.id,JSON.stringify(r.html)]));return n.replace(/_tmpl\$\d+/g,r=>t.get(r)??r)}var M={name:"imperative",contract:xe,emit(n,e){let t=new Set,r=e?.templateClone!==!1?[]:void 0;return Ge=e?.partialTemplates===!0,{code:q(n,t,r),imports:Array.from(t),templates:r}}};var nn=n=>"components"in n;function Ye(n,e){return n.replace(/\$(\d+)/g,(t,r)=>e[Number(r)]??t)}function rn(n,e){return typeof e=="string"?{module:e,export:n}:e}function ce(n=[]){let e=new Map,t=[],r=[];for(let o of n){if(!nn(o)){r.push(o);continue}for(let[a,l]of Object.entries(o.components)){let c=rn(a,l),u=e.get(a);if(u&&u.module!==c.module){let d=t.find(p=>p.name===a);d?d.modules.push(c.module):t.push({name:a,modules:[u.module,c.module]});continue}e.set(a,c)}}let i=new Map;return{resolve:o=>{if(i.has(o))return i.get(o);let a=e.get(o);if(!a)for(let l of r){let c=o.match(new RegExp(l.match.source,l.match.flags.replace("g","")));if(c){a={module:Ye(l.module,c),export:l.export?Ye(l.export,c):o};break}}return i.set(o,a),a},names:()=>[...e.keys()],conflicts:()=>t}}import{parseTemplate as sn}from"@fluixi/template-parser";function X(n){let e=n.split(/\r\n|\n|\r/),t=0;for(let i=0;i<e.length;i++)/[^ \t]/.test(e[i])&&(t=i);let r="";for(let i=0;i<e.length;i++){let s=e[i].replace(/\t/g," ");i!==0&&(s=s.replace(/^ +/,"")),i!==e.length-1&&(s=s.replace(/ +$/,"")),s&&(i!==t&&(s+=" "),r+=s)}return r}var Ze=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function on(n){return n.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function Qe(n){return n.charAt(0).toUpperCase()+n.slice(1)}var Ne=class{constructor(e,t){this.holes=e;this.used=t}hole(e){return this.holes[e]??{code:"undefined",reactive:!1}}emit(e){let{code:t,imports:r,templates:i}=M.emit(e,{});for(let s of r)this.used.add(s);return le(t,i)}lowerRoot(e){let t=this.lowerChildren(e);return t.length===1?t[0]:{kind:"fragment",children:t}}lowerChildren(e){let t=[];for(let r=0;r<e.length;r++){let i=e[r];if(i.kind==="Element"||i.kind==="Component"){let o=i.attributes.find(a=>a.kind==="IfDirective");if(o&&o.kind==="IfDirective"){let a=r+1;a<e.length&&this.isBlankText(e[a])&&a++;let l=e[a],c=l&&(l.kind==="Element"||l.kind==="Component")&&l.attributes.some(u=>u.kind==="ElseDirective");t.push(this.lowerIf(i,o.hole,c?l:null)),c&&(r=a);continue}if(i.attributes.some(a=>a.kind==="EachDirective")){t.push(this.lowerEach(i));continue}}let s=this.lowerNode(i);s&&t.push(s)}return t}isBlankText(e){return e.kind==="Text"&&!e.raw&&X(e.value)===""}lowerNode(e){switch(e.kind){case"Text":{if(e.raw)return{kind:"text",value:e.value};let t=X(e.value);return t?{kind:"text",value:t}:null}case"Comment":return null;case"Expression":{let t=this.hole(e.hole);return{kind:"expr",code:t.code,reactive:t.reactive}}case"Fragment":return{kind:"fragment",children:this.lowerChildren(e.children)};case"Element":return this.lowerElement(e);case"Component":return this.lowerComponent(e);default:return null}}lowerElement(e){let t=e.attributes.find(r=>r.kind==="Attribute"&&r.name==="is");if(e.tag==="component"&&t&&t.value&&t.value.kind==="hole"){let r=e.attributes.filter(s=>s!==t),i=this.lowerComponent({...e,kind:"Component",tag:"Dynamic",tagHole:null,attributes:r});return i.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(t.value.hole).code})`}),i}return{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:this.lowerAttributes(e.attributes),children:this.lowerChildren(e.children),static:!1}}lowerComponent(e){let t=e.tagHole!=null?this.hole(e.tagHole).code:e.tag,r=this.lowerAttributes(e.attributes),{slots:i,rest:s}=this.partitionSlots(e.children);for(let[l,c]of i){let u=c.length===1?c[0]:{kind:"fragment",children:c},d={name:l,kind:"attr",expr:this.emit(u),jsxElement:!0},p=r.findIndex(m=>m.name===l);p>=0?r[p]=d:r.push(d)}let o=e.attributes.find(l=>l.kind==="LoadDirective"),a=o?ne(`load:${o.strategy}`,o.modifier):void 0;return{kind:"component",name:t,props:r,children:this.lowerChildren(s),...a?{load:a}:{}}}partitionSlots(e){let t=new Map,r=[];for(let i of e){if(i.kind==="Element"||i.kind==="Component"){let s=i.attributes.find(o=>o.kind==="Attribute"&&o.name==="slot");if(s&&s.value&&s.value.kind==="static"){let o={...i,attributes:i.attributes.filter(c=>c!==s)},a=o.kind==="Element"?this.lowerElement(o):this.lowerComponent(o),l=t.get(s.value.value)??[];l.push(a),t.set(s.value.value,l);continue}}r.push(i)}return{slots:t,rest:r}}lowerIf(e,t,r){let i=this.hole(t),s=[{name:"when",kind:"attr",expr:i.code,reactive:i.reactive}];if(r){let a=this.stripAndLower(r,l=>l.kind==="ElseDirective");s.push({name:"fallback",kind:"attr",expr:this.emit(a),jsxElement:!0})}let o=this.stripAndLower(e,a=>a.kind==="IfDirective");return{kind:"component",name:"Show",props:s,children:[o]}}lowerEach(e){let t=e.attributes.find(l=>l.kind==="EachDirective");if(!t||t.kind!=="EachDirective")return this.lowerNode(e);let r=this.hole(t.hole),i=[{name:"each",kind:"attr",expr:r.code,reactive:r.reactive}];if(t.key){let l="static"in t.key?`(item) => item[${JSON.stringify(t.key.static)}]`:this.hole(t.key.hole).code;i.push({name:"by",kind:"attr",expr:l})}let s=this.itemArrow(e),o;if(s){let l={kind:"expr",code:s.body,reactive:s.bodyReactive},c=this.rebuildWithChildren(e,[l]);o=`(${s.params.join(", ")}) => (${this.emit(c)})`}else{let l=this.stripAndLower(e,c=>c.kind==="EachDirective");o=`() => (${this.emit(l)})`}return{kind:"component",name:"For",props:i,children:[{kind:"expr",code:o,reactive:!1}]}}itemArrow(e){let t=e.children.filter(r=>!this.isBlankText(r));return t.length!==1||t[0].kind!=="Expression"?null:this.hole(t[0].hole).arrow??null}stripAndLower(e,t){let r={...e,attributes:e.attributes.filter(i=>!t(i))};return r.kind==="Element"?this.lowerElement(r):this.lowerComponent(r)}rebuildWithChildren(e,t){let r=this.lowerAttributes(e.attributes.filter(i=>i.kind!=="EachDirective"));return e.kind==="Element"?{kind:"element",tag:e.tag,svg:e.namespace==="svg",props:r,children:t,static:!1}:{kind:"component",name:e.tag,props:r,children:t}}lowerAttributes(e){let t=[],r=[],i=!1,s=[],o=!1,a=[];for(let l of e)switch(l.kind){case"IfDirective":case"EachDirective":case"ElseDirective":break;case"Attribute":t.push(this.plainAttr(l));break;case"PropertyBinding":t.push({name:l.name,kind:"prop",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"EventBinding":t.push(this.eventProp(l));break;case"RefBinding":t.push({name:"ref",kind:"ref",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"Spread":t.push({name:"",kind:"spread",expr:this.hole(l.hole).code});break;case"ClassDirective":{let c=this.hole(l.hole);r.push(`${JSON.stringify(l.name)}: ${c.code}`),i=i||c.reactive;break}case"StyleDirective":{let c=this.hole(l.hole);s.push(`${JSON.stringify(l.name)}: ${c.code}`),o=o||c.reactive;break}case"BindDirective":t.push(...this.bindProps(l.name,this.hole(l.hole).code));break;case"UseDirective":{let c=l.name??(l.hole!=null?this.hole(l.hole).code:null);if(!c)break;a.push(l.name!=null&&l.hole!=null?`[${c}, () => (${this.hole(l.hole).code})]`:`[${c}]`);break}}return r.length>0&&t.push({name:"classList",kind:"attr",expr:`{ ${r.join(", ")} }`,reactive:i}),s.length>0&&t.push({name:"style",kind:"attr",expr:`{ ${s.join(", ")} }`,reactive:o}),a.length>0&&t.push({name:"use",kind:"attr",expr:`[${a.join(", ")}]`}),t}eventProp(e){let t=e.name.toLowerCase(),r=this.hole(e.hole).code;if(!(e.syntax==="colon"||e.modifiers.length>0))return{name:"on"+Qe(e.name),kind:"event",event:{name:t,delegated:Ze.has(t)},expr:r};let s=this.wrapHandler(r,e.modifiers),o=this.eventOptions(e.modifiers),a=o?`[${s}, ${o}]`:s;return{name:"on:"+t,kind:"attr",expr:a}}wrapHandler(e,t){let r=t.includes("self")?"if (e.target !== e.currentTarget) return; ":"",i=[];return t.includes("prevent")&&i.push("e.preventDefault();"),t.includes("stop")&&i.push("e.stopPropagation();"),!r&&i.length===0?e:`(e) => { ${r}${i.join(" ")} return (${e})(e); }`}eventOptions(e){let t=[];return e.includes("capture")&&t.push("capture: true"),e.includes("once")&&t.push("once: true"),e.includes("passive")&&t.push("passive: true"),t.length?`{ ${t.join(", ")} }`:null}bindProps(e,t){let r=e==="checked",i=r?"change":"input",s=r?"checked":"value";this.used.add("bindPair");let o=`bindPair(${t})`;return[{name:e,kind:"attr",expr:`${o}[0]()`,reactive:!0},{name:"on"+Qe(i),kind:"event",event:{name:i,delegated:Ze.has(i)},expr:`(e) => ${o}[1](e.target.${s})`}]}plainAttr(e){let t=e.value,r=e.name;e.name==="class"?r=t&&t.kind==="hole"&&this.hole(t.hole).object?"classList":"className":e.name==="html"&&(r="innerHTML");let s={name:r,kind:"attr"};if(t==null)return s.literal=!0,s;if(t.kind==="static")return s.literal=t.value,s;if(t.kind==="hole"){let l=this.hole(t.hole);return s.expr=l.code,s.reactive=l.reactive,s}let o=!1,a=t.parts.map(l=>{if("text"in l)return on(l.text);let c=this.hole(l.hole);return o=o||c.reactive,"${"+c.code+"}"}).join("");return s.expr="`"+a+"`",s.reactive=o,s}};function et(n,e,t,r={}){let{root:i}=sn(n,{svg:r.svg});return new Ne(e,t).lowerRoot(i.children)}function tt(n,e,t={}){let r=new Set,i=et(n,[...e],r,{svg:t.svg});L(i),re(i,{resolver:ce(t.resolve??[]),modules:{controlFlowModule:t.controlFlowModule??"@fluixi/dom",coreModule:t.coreModule??"@fluixi/core",routerModule:t.routerModule??"@fluixi/core/router"},strategyFor:l=>l.load}),se(i);let{code:s,imports:o,templates:a}=M.emit(i,{templateClone:t.templateClone,partialTemplates:t.partialTemplates});for(let l of o)r.add(l);return t.hoistTemplates?{code:s,imports:[...r],ir:i,templates:a}:{code:le(s,a),imports:[...r],ir:i}}var an="children";function D(n){switch(n.kind){case"call":return!0;case"member":return n.property!==an;case"compound":return n.parts.some(D);case"opaque":return!1}}var ln=new Set(["CallExpression","OptionalCallExpression"]),cn=new Set(["MemberExpression","OptionalMemberExpression"]);function A(n){if(!n)return{kind:"opaque"};if(ln.has(n.type))return{kind:"call"};if(cn.has(n.type)){let e=n.property;return{kind:"member",property:!(n.computed===!0)&&e?.type==="Identifier"?e.name:null}}return n.type==="ConditionalExpression"?{kind:"compound",parts:[n.test,n.consequent,n.alternate].map(z)}:n.type==="LogicalExpression"||n.type==="BinaryExpression"?{kind:"compound",parts:[n.left,n.right].map(z)}:n.type==="TemplateLiteral"?{kind:"compound",parts:n.expressions.map(z)}:n.type==="ObjectExpression"?{kind:"compound",parts:n.properties.filter(t=>(t.type==="ObjectProperty"||t.type==="Property")&&t.computed!==!0).map(t=>z(t.value))}:n.type==="ArrayExpression"?{kind:"compound",parts:n.elements.filter(t=>t!=null&&t.type!=="SpreadElement").map(z)}:{kind:"opaque"}}var z=n=>A(n);var un=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),dn=/^on[A-Z]/,pn=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]),it=n=>D(A(n));function V(n){if(n.type==="StringLiteral"||n.type==="NumericLiteral"||n.type==="BooleanLiteral"||n.type==="Literal"&&(typeof n.value=="string"||typeof n.value=="number"||typeof n.value=="boolean"))return n.value}var be=n=>!!n&&typeof V(n)=="string";function fn(n,e){return n.type==="JSXIdentifier"?{tag:n.name,component:n.name[0]!==n.name[0].toLowerCase()}:n.type==="JSXMemberExpression"?{tag:e.code(n),component:!0}:n.type==="JSXNamespacedName"?{tag:`${n.namespace.name}:${n.name.name}`,component:!1}:{tag:"div",component:!1}}function we(n){return n.type==="JSXIdentifier"?n.name==="class"?"className":n.name:n.type==="JSXNamespacedName"?`${n.namespace.name}:${n.name.name}`:"unknown"}function hn(n,e){let t=we(n.name),r=dn.test(t),i=r||t.startsWith("on:")||t==="ref",o={name:t,kind:r?"event":"attr"};if(r){let l=t.slice(2).toLowerCase();o.event={name:l,delegated:pn.has(l)}}let a=n.value;if(a==null)return o.literal=!0,o;if(be(a))return o.literal=V(a),o;if(a.type==="JSXExpressionContainer"&&a.expression?.type!=="JSXEmptyExpression"){let l=a.expression,c=V(l);return c!==void 0?(o.literal=c,o):(o.expr=e.code(l),o.reactive=i?!1:it(l),(l.type==="JSXElement"||l.type==="JSXFragment")&&(o.jsxElement=!0),o)}return o.literal=!0,o}function nt(n,e){let t=n.value;return t==null?null:be(t)?JSON.stringify(V(t)):t.type==="JSXExpressionContainer"&&t.expression?.type!=="JSXEmptyExpression"?e.code(t.expression):null}function mn(n,e){let t=[],r=[];for(let i of n){if(i.type==="JSXSpreadAttribute"){t.push({name:"",kind:"spread",expr:e.code(i.argument)});continue}if(i.type!=="JSXAttribute"||me(we(i.name)))continue;let s=i.name.type==="JSXNamespacedName"?i.name.namespace.name:null;if(s==="use"){let o=i.name.name.name;e.used.add(o);let a=nt(i,e);r.push(a!=null?`[${o}, () => (${a})]`:`[${o}]`);continue}if(s==="oncapture"){let o=i.name.name.name.toLowerCase(),a=nt(i,e)??"undefined";t.push({name:"on:"+o,kind:"attr",expr:`[${a}, { capture: true }]`});continue}t.push(hn(i,e))}return r.length>0&&t.push({name:"use",kind:"attr",expr:`[${r.join(", ")}]`}),t}function rt(n,e){let t=[];for(let r of n)if(r.type==="JSXText"){let i=X(r.value);i&&t.push({kind:"text",value:i})}else if(r.type==="JSXExpressionContainer"){if(r.expression?.type!=="JSXEmptyExpression"){let i=r.expression;t.push({kind:"expr",code:e.code(i),reactive:it(i)})}}else r.type==="JSXElement"||r.type==="JSXFragment"?t.push(st(r,e)):r.type==="JSXSpreadChild"&&t.push({kind:"expr",code:e.code(r.expression),reactive:!1});return t}function gn(n){for(let e of n){if(e.type!=="JSXAttribute")continue;let t=we(e.name);if(me(t)){if(e.value&&!be(e.value))throw new E(`'${t}' needs a literal value, not an expression — the strategy is compile-time.`);return ne(t,e.value?V(e.value):null)}}}function st(n,e){if(n.type==="JSXFragment")return{kind:"fragment",children:rt(n.children,e)};let{tag:t,component:r}=fn(n.openingElement.name,e),i=mn(n.openingElement.attributes,e),s=rt(n.children,e);if(r){let o=gn(n.openingElement.attributes);return{kind:"component",name:t,props:i,children:s,...o?{load:o}:{}}}return{kind:"element",tag:t,svg:un.has(t),props:i,children:s,static:!1}}function ot(n,e){let t=st(n,e);return L(t),t}function C(n,e){if(n)switch(n.type){case"Identifier":e.add(n.name);return;case"ObjectPattern":for(let t of n.properties)t.type==="RestElement"?C(t.argument,e):C(t.value,e);return;case"ArrayPattern":for(let t of n.elements)C(t,e);return;case"AssignmentPattern":C(n.left,e);return;case"RestElement":C(n.argument,e);return}}function at(n,e){switch(n.type){case"ImportDeclaration":for(let t of n.specifiers)C(t.local,e);return;case"VariableDeclaration":for(let t of n.declarations)C(t.id,e);return;case"FunctionDeclaration":case"ClassDeclaration":C(n.id,e);return;case"ExportNamedDeclaration":case"ExportDefaultDeclaration":n.declaration&&at(n.declaration,e);return}}function Re(n){let e=new Set;for(let t of n.body)at(t,e);return e}import{parse as Ar}from"@babel/parser";function w(n,e){if(n)switch(n.type){case"Identifier":e.add(n.name);return;case"ObjectPattern":for(let t of n.properties)t.type==="RestElement"?w(t.argument,e):w(t.value,e);return;case"ArrayPattern":for(let t of n.elements)w(t,e);return;case"AssignmentPattern":w(n.left,e);return;case"RestElement":w(n.argument,e);return}}function Se(n){switch(n.type){case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":case"NullLiteral":case"BigIntLiteral":case"RegExpLiteral":case"Identifier":return!0;case"Literal":return!0;case"TemplateLiteral":return n.expressions.every(Se);case"UnaryExpression":return Se(n.argument);case"MemberExpression":return!1;default:return!1}}function ue(n,e){if(!(!n||typeof n!="object")){e(n);for(let t of Object.keys(n)){if(t==="loc"||t==="range"||t==="leadingComments"||t==="trailingComments")continue;let r=n[t];if(Array.isArray(r))for(let i of r)i&&typeof i=="object"&&ue(i,e);else r&&typeof r=="object"&&typeof r.type=="string"&&ue(r,e)}}}function yn(n){let e=new Set;return ue(n,t=>{if(t.type==="AssignmentExpression")w(t.left,e);else if(t.type==="UpdateExpression"){let r=t.argument;r?.type==="Identifier"&&e.add(r.name)}}),e}function vn(n,e){let t=new Set,r=i=>{let s=new Set;w(i,s);for(let o of s)e.has(o)&&t.add(o)};return ue(n,i=>{switch(i.type){case"VariableDeclarator":r(i.id);return;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":r(i.id);for(let s of i.params??[])r(s);return;case"CatchClause":r(i.param);return;case"ClassDeclaration":case"ClassExpression":r(i.id);return}}),t}function lt(n,e,t){for(let r of n.properties??[]){if(r.type==="RestElement"){let u=r.argument;if(u?.type!=="Identifier"||e.length>0){let d=new Set;w(u,d);for(let p of d)t.bails.push({name:p,reason:"rest"});continue}t.rest={name:u.name,keys:[]};continue}if(r.computed){let u=new Set;w(r.value,u);for(let d of u)t.bails.push({name:d,reason:"computed"});continue}let i=r.key,s=i.type==="Identifier"?i.name:i.value,o=r.value,a;o.type==="AssignmentPattern"&&(a=o.right,o=o.left);let l=[...e,s];if(o.type==="Identifier"){if(a&&!Se(a)){t.bails.push({name:o.name,reason:"unsafe-default"});continue}t.reads.push({name:o.name,path:l,...a?{fallback:a}:{}});continue}if(o.type==="ObjectPattern"){if(a){let u=new Set;w(o,u);for(let d of u)t.bails.push({name:d,reason:"unsafe-default"});continue}lt(o,l,t);continue}let c=new Set;w(o,c);for(let u of c)t.bails.push({name:u,reason:"computed"})}}function ct(n,e){let t={reads:[],bails:[]};if(n?.type!=="ObjectPattern"||(lt(n,[],t),t.rest&&(e?.type!=="BlockStatement"?(t.bails.push({name:t.rest.name,reason:"rest"}),delete t.rest):t.rest.keys=(n.properties??[]).filter(a=>a.type!=="RestElement"&&!a.computed).map(a=>{let l=a.key;return l.type==="Identifier"?l.name:l.value})),t.reads.length===0&&!t.rest))return t;let r=new Set(t.reads.map(a=>a.name));t.rest&&r.add(t.rest.name);let i=yn(e),s=vn(e,r),o=[];for(let a of t.reads)i.has(a.name)?t.bails.push({name:a.name,reason:"reassigned"}):s.has(a.name)?t.bails.push({name:a.name,reason:"shadowed"}):o.push(a);return t.reads=o,t.rest&&i.has(t.rest.name)?(t.bails.push({name:t.rest.name,reason:"reassigned"}),delete t.rest):t.rest&&s.has(t.rest.name)&&(t.bails.push({name:t.rest.name,reason:"shadowed"}),delete t.rest),t}function ut(n){switch(n){case"rest":return"this rest element cannot be served by splitProps, and copying the props into a plain object would lose the getters";case"computed":return"the property is not known until it runs";case"reassigned":return"the binding is assigned to, and props are read-only";case"shadowed":return"an inner scope binds the same name";case"unsafe-default":return"the default would have to run again on every read"}}function W(n,e,t=null){if(!(!n||typeof n!="object"||typeof n.type!="string")&&!n.type.startsWith("TS")&&e(n,t)!==!1)for(let r of Object.keys(n)){if(r==="loc"||r==="leadingComments"||r==="trailingComments")continue;let i=n[r];if(Array.isArray(i))for(let s of i)W(s,e,n);else i&&typeof i=="object"&&W(i,e,n)}}function dt(n){return!!n&&n[0]>="A"&&n[0]<="Z"}function xn(n){let e=[];return W(n,t=>{if(t.type==="FunctionDeclaration"&&dt(t.id?.name)){e.push(t);return}if(t.type==="VariableDeclarator"&&dt(t.id?.name)){let r=t.init;r&&(r.type==="ArrowFunctionExpression"||r.type==="FunctionExpression")&&e.push(r)}}),e}function Nn(n){let e=new Set;return W(n,t=>{t.type==="Identifier"&&e.add(t.name)}),e}function bn(n,e){if(!e)return!0;switch(e.type){case"MemberExpression":case"OptionalMemberExpression":return!(e.property===n&&!e.computed);case"ObjectProperty":case"ObjectMethod":case"ClassProperty":case"ClassMethod":return!(e.key===n&&!e.computed);case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return e.label!==n;case"ImportSpecifier":case"ExportSpecifier":return!1;default:return!0}}function pt(n,e,t={}){let r=[],i=[],s=new Set;for(let o of xn(n)){let a=o.params?.[0];if(a?.type!=="ObjectPattern")continue;let l=ct(a,o.body);for(let h of l.bails)i.push({name:h.name,reason:h.reason,message:ut(h.reason),start:a.start});if(l.bails.length>0||l.reads.length===0&&!l.rest)continue;let c=Nn(o),u=t.parameterName??"props";for(;c.has(u);)u=`_${u}`;let d=new Map;for(let h of l.reads){let g=`${u}.${h.path.join(".")}`,x=h.fallback;d.set(h.name,x?`(${g} === undefined ? ${e.slice(x.start,x.end)} : ${g})`:g)}let p=a.typeAnnotation;if(r.push({start:a.start,end:p?.start??a.end,code:u}),l.rest){let h=l.rest.keys.map(x=>JSON.stringify(x)).join(", "),g=o.body;r.push({start:g.start+1,end:g.start+1,code:`
11
+ const [, ${l.rest.name}] = splitProps(${u}, [${h}]);`}),s.add("splitProps")}let m=[];W(o.body,(h,g)=>{if(h.type!=="Identifier")return;let x=d.get(h.name);if(!x)return;let S=g?.type==="ObjectProperty"&&g.shorthand&&g.value===h;if(!S&&!bn(h,g))return;let R=l.reads.find(I=>I.name===h.name).path;m.push({node:h,parent:S?g:null,text:x,property:R[R.length-1]})});for(let h of m)h.parent?r.push({start:h.parent.start,end:h.parent.end,code:`${h.node.name}: ${h.text}`}):r.push({start:h.node.start,end:h.node.end,code:h.text}),wn(h.node,u,h.property)}return{edits:r,diagnostics:i,used:s}}function wn(n,e,t){n.type="MemberExpression",n.computed=!1,n.optional=!1,n.object={type:"Identifier",name:e,start:n.start,end:n.start},n.property={type:"Identifier",name:t,start:n.end,end:n.end},delete n.name}var $="@fluixi/reactive/signal",T={$signal:{export:"signal",module:$,returns:"signal-handle"},$memo:{export:"memo",module:$,returns:"memo-handle"},$effect:{export:"effect",module:$,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:$,returns:"resource-handle"},$selector:{export:"createSelector",module:$,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:$,returns:"memo-accessor"},$untrack:{export:"untrack",module:$,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}},ft={signal:"signal-handle",memo:"memo-handle",effect:"effect",store:"store-handle",createSignal:["signal-accessor","signal-setter"],createMemo:"memo-accessor",createEffect:"effect",createRenderEffect:"effect",createStore:"reactive-object",resource:"resource-handle",createResource:"reactive-object",createSelector:"memo-accessor",createDeferred:"memo-accessor"},Rn=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/store","@fluixi/core"],Sn=new RegExp(`\\$(?:${Object.keys(T).map(n=>n.slice(1)).join("|")})\\s*\\(`);function ht(n){return Sn.test(n)}function mt(n){return Object.prototype.hasOwnProperty.call(T,n)}function gt(n){return Rn.includes(n)}function y(n,e){if(n)switch(n.type){case"Identifier":e.add(n.name);return;case"ObjectPattern":for(let t of n.properties??[])t.type==="RestElement"?y(t.argument,e):y(t.value,e);return;case"ArrayPattern":for(let t of n.elements??[])y(t,e);return;case"AssignmentPattern":y(n.left,e);return;case"RestElement":y(n.argument,e);return}}function K(n,e){if(!(!n||typeof n!="object"||typeof n.type!="string")){e(n);for(let t of Object.keys(n)){if(t==="loc"||t==="leadingComments"||t==="trailingComments")continue;let r=n[t];if(Array.isArray(r))for(let i of r)K(i,e);else r&&typeof r=="object"&&K(r,e)}}}function kn(n,e){if(n.type!=="CallExpression")return;let t=n.callee;if(t?.type!=="Identifier")return;let r=t.name,i=e.primitives.get(r);if(i)return i;let s=T[r];if(s&&!e.shadowed.has(r))return s.returns}function En(n,e,t){if(Array.isArray(e)){n.type==="ArrayPattern"&&n.elements.forEach((r,i)=>{let s=e[i];r?.type==="Identifier"&&s&&t.set(r.name,s)});return}n.type==="Identifier"&&t.set(n.name,e)}function yt(n){let e=new Set;return K(n,t=>{switch(t.type){case"VariableDeclarator":y(t.id,e);return;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":y(t.id,e);for(let r of t.params??[])y(r,e);return;case"ClassDeclaration":case"ClassExpression":y(t.id,e);return;case"ImportSpecifier":case"ImportDefaultSpecifier":case"ImportNamespaceSpecifier":y(t.local,e);return;case"CatchClause":y(t.param,e);return}}),e}function vt(n){let e={kinds:new Map,primitives:new Map,shadowed:new Set},t=n;K(t,r=>{let i=new Set;if(r.type==="VariableDeclarator")y(r.id,i);else if(r.type==="FunctionDeclaration"||r.type==="ClassDeclaration")y(r.id,i);else if(r.type==="ImportDefaultSpecifier"||r.type==="ImportNamespaceSpecifier")y(r.local,i);else if(r.type==="ImportSpecifier")y(r.local,i);else if(r.type==="FunctionExpression"||r.type==="ArrowFunctionExpression"||r.type==="FunctionDeclaration")for(let s of r.params??[])y(s,i);for(let s of i)T[s]&&e.shadowed.add(s)});for(let r of t.body??[])if(r.type==="ImportDeclaration"&&gt(r.source?.value))for(let i of r.specifiers??[]){if(i.type!=="ImportSpecifier")continue;let s=i.imported,o=s.type==="Identifier"?s.name:s.value,a=ft[o];a&&e.primitives.set(i.local.name,a)}return K(t,r=>{if(r.type!=="VariableDeclarator"||!r.init)return;let i=kn(r.init,e);i&&En(r.id,i,e.kinds)}),e}function ke(n,e){if(!(!n||typeof n!="object"||typeof n.type!="string")){e(n);for(let t of Object.keys(n)){if(t==="loc"||t==="leadingComments"||t==="trailingComments")continue;let r=n[t];if(Array.isArray(r))for(let i of r)ke(i,e);else r&&typeof r=="object"&&ke(r,e)}}}function xt(n){let e=[],t=[],r=new Map,i=new Set,{shadowed:s}=vt(n);return ke(n,o=>{if(o.type!=="CallExpression")return;let a=o.callee;if(a?.type!=="Identifier")return;let l=a.name;if(!mt(l))return;if(s.has(l)){i.has(l)||(i.add(l),t.push({name:l,message:`${l} is reserved for the compiler, and this module binds it. The call keeps your binding's meaning; rename it to use the intrinsic.`,start:a.start}));return}let c=T[l];e.push({start:a.start,end:a.end,code:c.export});let u=r.get(c.module)??new Set;u.add(c.export),r.set(c.module,u)}),{edits:e,diagnostics:t,imports:r}}function Nt(n,e){let t=[];for(let[r,i]of[...n.imports].sort(([s],[o])=>s.localeCompare(o))){let s=[...i].filter(o=>!e.has(o)).sort();s.length&&t.push(`import { ${s.join(", ")} } from ${JSON.stringify(r)};`)}return t.length?`${t.join(`
12
12
  `)}
13
13
  `:""}var In=new Set(B),$n=new Set(F),Tn=new Set(P),On=new Set(["createMemo","createEffect","createRenderEffect","createRoot","createSignal","onCleanup","batch","untrack"]);function pe(n,e,t=null,r=""){if(!(!n||typeof n!="object")){if(Array.isArray(n)){for(let i of n)pe(i,e,t,r);return}typeof n.type=="string"&&e(n,t,r);for(let i of Object.keys(n))i==="loc"||i==="leadingComments"||i==="trailingComments"||pe(n[i],e,typeof n.type=="string"?n:t,i)}}var Ee=n=>n.type==="JSXElement"||n.type==="JSXFragment";function Ln(n,e,t){return Ee(n)?!(e&&Ee(e)&&t==="children"):!1}function Pn(n,e){return n.type==="TaggedTemplateExpression"&&n.tag?.type==="Identifier"&&(n.tag.name===e||n.tag.name==="svg")}function bt(n){return n.filter(e=>!n.some(t=>t!==e&&t.start<=e.start&&t.end>=e.end&&t.end-t.start>e.end-e.start))}function de(n,e,t,r){let i=bt(r.filter(o=>o.start>=e&&o.end<=t)).sort((o,a)=>a.start-o.start),s=n.slice(e,t);for(let o of i)s=s.slice(0,o.start-e)+o.code+s.slice(o.end-e);return s}function Mn(n,e,t){let r={code:de(n,e.start,e.end,t),reactive:D(A(e))};return e.type==="ArrowFunctionExpression"&&e.body?.type!=="BlockStatement"&&(r.arrow={params:e.params.map(i=>de(n,i.start,i.end,t)),body:de(n,e.body.start,e.body.end,t),bodyReactive:D(A(e.body))}),e.type==="ObjectExpression"&&(r.object=!0),r}function wt(n,e,t){if(!e||e.length===0)return n;let r=new Map;for(let i of e){let s=`${i.svg?"svg:":""}${i.html}`,o=t.get(s);o||(o=`_fxTmpl$${t.size}`,t.set(s,o)),r.set(i.id,o)}return n.replace(/_tmpl\$\d+/g,i=>r.get(i)??i)}function Ce(n,e){if(n.kind==="component"&&n.load&&!n.source&&J(n.load)&&(e.ignoredLoad.has(n.name)||e.ignoredLoad.set(n.name,n.load)),n.kind==="component"&&n.source){let t=n.source;t.origin==="builtin"?e.builtins.add(n.name):J(t.loading)&&!e.resolved.has(n.name)?e.deferred.set(n.name,t):(e.deferred.delete(n.name),e.resolved.set(n.name,t))}if("props"in n&&n.props)for(let t of n.props)t.kind==="event"&&t.event?.delegated&&e.delegatedEvents.add(t.event.name);if("children"in n&&n.children)for(let t of n.children)Ce(t,e)}function Dn(n,e){for(let t of n.body??[])if(t.type==="ImportDeclaration")for(let r of t.specifiers??[]){if(r.local?.name!==e)continue;if(r.type==="ImportNamespaceSpecifier")return;let i=r.type==="ImportDefaultSpecifier"?"default":r.imported?.name??r.imported?.value;return{module:t.source.value,export:i,declaration:t,specifier:r}}}function An(n,e){for(let t of n.body??[])if(t.type==="ImportDeclaration"){for(let r of t.specifiers??[])if(r.type==="ImportNamespaceSpecifier"&&r.local?.name===e)return!0}return!1}function jn(n,e,t){let r=!1;return pe(n,i=>{r||i.type!=="Identifier"||i.name!==e||i.start===t.local?.start&&i.end===t.local?.end||(r=!0)}),r}function _n(n){let e=[`kind: ${JSON.stringify(n.kind)}`];return n.kind==="visible"&&n.rootMargin&&e.push(`rootMargin: ${JSON.stringify(n.rootMargin)}`),n.kind==="interaction"&&e.push(`events: ${JSON.stringify(n.events)}`),n.kind==="media"&&e.push(`query: ${JSON.stringify(n.query)}`),`{ ${e.join(", ")} }`}function Jn(n){let e=[];return n.quasi.quasis.forEach((t,r)=>{if(e.push({kind:"static",text:t.value.cooked??t.value.raw,start:t.start}),r<n.quasi.expressions.length){let i=n.quasi.expressions[r];e.push({kind:"hole",index:r,start:i.start,end:i.end})}}),e}function ui(n,e,t={}){let r=t.litTag??"html",i=t.format??"both",s=i!=="jsx",o=i!=="lit",a=s&&(n.includes(`${r}\``)||n.includes("svg`")),l=t.intrinsics!==!1&&ht(n);if(!a&&!(o&&n.includes("<"))&&!l)return null;let c=Cn(n,{sourceType:"module",plugins:["jsx","typescript"],errorRecovery:!0}),u=[];pe(c.program,(f,N,v)=>{(s&&Pn(f,r)||o&&Ln(f,N,v))&&u.push(f)});let d=t.propsDestructure===!1?{edits:[],diagnostics:[],used:new Set}:pt(c.program,n,{runtimeModule:t.runtimeModule}),p=t.intrinsics===!1?{edits:[],diagnostics:[],imports:new Map}:xt(c.program);if(u.length===0&&d.edits.length===0&&p.edits.length===0&&p.diagnostics.length===0&&d.diagnostics.length===0)return null;u.sort((f,N)=>N.start-f.start||f.end-N.end);let h=new Set(d.used),g={builtins:new Set,resolved:new Map,deferred:new Map,delegatedEvents:new Set,ignoredLoad:new Map,unresolved:new Set,declared:yt(c.program)},x=new Map,S=[...d.edits,...p.edits];for(let f of u){let N=u.some(b=>b!==f&&b.start<=f.start&&b.end>=f.end&&b.end-b.start>f.end-f.start);if(Ee(f)){S.push({start:f.start,end:f.end,code:Bn(n,f,S,N,h,g,x,t)});continue}let v=f.quasi.expressions.map(b=>Mn(n,b,S)),k=tt(Jn(f),v,{...t,hoistTemplates:!0,templateClone:t.templateClone??!0,partialTemplates:N?!1:t.partialTemplates??!0,svg:f.tag.name==="svg"});for(let b of k.imports)h.add(b);Ce(k.ir,g),S.push({start:f.start,end:f.end,code:wt(k.code,k.templates,x)})}let R=new ee(n);for(let f of bt(S))f.start===f.end?R.appendLeft(f.start,f.code):R.overwrite(f.start,f.end,f.code);let I=Re(c.program),G=new Map;for(let[f]of g.ignoredLoad)I.has(f)||G.set(f,"unsupplied");for(let[f,N]of[...g.ignoredLoad]){if(!I.has(f))continue;let v=Dn(c.program,f);if(!v){G.set(f,An(c.program,f)?"namespace":"local");continue}if(jn(c.program,f,v.specifier)){G.set(f,"value");continue}let k=v.declaration.specifiers.filter(Y=>Y!==v.specifier),b=k.length===0&&n[v.declaration.end]===`
14
- `?v.declaration.end+1:v.declaration.end;R.overwrite(v.declaration.start,b,k.length===0?"":`import { ${k.map(Y=>n.slice(Y.start,Y.end)).join(", ")} } from ${JSON.stringify(v.declaration.source.value)};`),g.deferred.set(f,{module:v.module,export:v.export,origin:"rule",loading:N}),I.delete(f),g.ignoredLoad.delete(f)}let Ie=Fn(h,g,x,I,t);Ie&&R.prepend(Ie);let $e=Nt(p,I);$e&&R.prepend($e);let Rt={value:f=>`${f} is used as a value here, not only as a tag, so its import has to stay — deferring would hand those references a lazy wrapper instead of the component. Defer it at the point it is rendered, or keep it eager.`,namespace:f=>`${f} came in through a namespace import, which has no single export to defer. Import ${f} by name.`,local:f=>`${f} is declared in this file, so there is no module to load separately. Move it to its own file and import it.`,unsupplied:f=>`nothing supplies ${f}, so there is no import to defer. Import it, or add a \`resolve\` rule for it.`},Te=[...g.ignoredLoad].map(([f,N])=>({name:f,strategy:N,message:`load:${N.kind} has no effect on <${f}>: ${Rt[G.get(f)??"unsupplied"](f)}`})),Oe=[...g.unresolved].map(f=>({name:f,message:`<${f}> is not defined: nothing imports it and no \`resolve\` rule supplies it. This compiles to a reference to a name that does not exist, so the component renders nothing. Import ${f}, or add a \`resolve\` rule for it.`}));return{code:R.toString(),map:R.generateMap({source:e,includeContent:!0,hires:!0}),...Te.length?{loadDiagnostics:Te}:{},...Oe.length?{unresolvedDiagnostics:Oe}:{},...d.diagnostics.length?{propsDiagnostics:d.diagnostics}:{},...p.diagnostics.length?{intrinsicDiagnostics:p.diagnostics}:{}}}function Bn(n,e,t,r,i,s,o,a){let l=ot(e,{code:d=>de(n,d.start,d.end,t),used:i});L(l);let c=re(l,{resolver:ce(a.resolve??[]),isBound:d=>s.declared.has(d),modules:{controlFlowModule:a.controlFlowModule??a.runtimeModule??"@fluixi/dom",coreModule:a.coreModule??"fluixi",routerModule:a.routerModule??"fluixi/router"},strategyFor:d=>d.load});for(let d of c.unresolved)s.unresolved.add(d);se(l);let u=M.emit(l,{templateClone:a.templateClone??!0,partialTemplates:r?!1:a.partialTemplates??!0});for(let d of u.imports)i.add(d);return Ce(l,s),wt(u.code,u.templates,o)}function Fn(n,e,t,r,i){let s=i.runtimeModule??"@fluixi/dom",o=i.coreModule??"fluixi",a=new Map,l=(p,m)=>a.set(p,[...a.get(p)??[],m]),c=new Set(n);for(let p of e.builtins)c.add(p);e.delegatedEvents.size>0&&c.add("delegateEvents");for(let p of[...c].sort())r.has(p)||(On.has(p)?l(i.reactiveModule??"@fluixi/reactive/signal",p):Tn.has(p)?l(i.routerModule??"fluixi/router",p):$n.has(p)?l(o,p):In.has(p)?l(i.controlFlowModule??s,p):l(s,p));for(let[p,m]of e.resolved)r.has(p)||l(m.module,m.export==="default"?`default as ${p}`:p===m.export?p:`${m.export} as ${p}`);let u=[];for(let[p,m]of a)u.push(`import { ${m.join(", ")} } from ${JSON.stringify(p)};`);let d=[...e.deferred].filter(([p])=>!r.has(p));if(d.length>0){r.has("deferred")||u.push(`import { deferred } from ${JSON.stringify(o)};`);for(let[p,m]of d)u.push(`const ${p} = deferred(() => import(${JSON.stringify(m.module)}), { strategy: ${_n(m.loading)}, export: ${JSON.stringify(m.export)} });`)}for(let[p,m]of t)u.push(`const ${m} = ${JSON.stringify(p.startsWith("svg:")?p.slice(4):p)};`);return e.delegatedEvents.size>0&&u.push(`delegateEvents(${JSON.stringify([...e.delegatedEvents])});`),u.length>0?u.join(`
14
+ `?v.declaration.end+1:v.declaration.end;R.overwrite(v.declaration.start,b,k.length===0?"":`import { ${k.map(Y=>n.slice(Y.start,Y.end)).join(", ")} } from ${JSON.stringify(v.declaration.source.value)};`),g.deferred.set(f,{module:v.module,export:v.export,origin:"rule",loading:N}),I.delete(f),g.ignoredLoad.delete(f)}let Ie=Fn(h,g,x,I,t);Ie&&R.prepend(Ie);let $e=Nt(p,I);$e&&R.prepend($e);let Rt={value:f=>`${f} is used as a value here, not only as a tag, so its import has to stay — deferring would hand those references a lazy wrapper instead of the component. Defer it at the point it is rendered, or keep it eager.`,namespace:f=>`${f} came in through a namespace import, which has no single export to defer. Import ${f} by name.`,local:f=>`${f} is declared in this file, so there is no module to load separately. Move it to its own file and import it.`,unsupplied:f=>`nothing supplies ${f}, so there is no import to defer. Import it, or add a \`resolve\` rule for it.`},Te=[...g.ignoredLoad].map(([f,N])=>({name:f,strategy:N,message:`load:${N.kind} has no effect on <${f}>: ${Rt[G.get(f)??"unsupplied"](f)}`})),Oe=[...g.unresolved].map(f=>({name:f,message:`<${f}> is not defined: nothing imports it and no \`resolve\` rule supplies it. This compiles to a reference to a name that does not exist, so the component renders nothing. Import ${f}, or add a \`resolve\` rule for it.`}));return{code:R.toString(),map:R.generateMap({source:e,includeContent:!0,hires:!0}),...Te.length?{loadDiagnostics:Te}:{},...Oe.length?{unresolvedDiagnostics:Oe}:{},...d.diagnostics.length?{propsDiagnostics:d.diagnostics}:{},...p.diagnostics.length?{intrinsicDiagnostics:p.diagnostics}:{}}}function Bn(n,e,t,r,i,s,o,a){let l=ot(e,{code:d=>de(n,d.start,d.end,t),used:i});L(l);let c=re(l,{resolver:ce(a.resolve??[]),isBound:d=>s.declared.has(d),modules:{controlFlowModule:a.controlFlowModule??a.runtimeModule??"@fluixi/dom",coreModule:a.coreModule??"@fluixi/core",routerModule:a.routerModule??"@fluixi/core/router"},strategyFor:d=>d.load});for(let d of c.unresolved)s.unresolved.add(d);se(l);let u=M.emit(l,{templateClone:a.templateClone??!0,partialTemplates:r?!1:a.partialTemplates??!0});for(let d of u.imports)i.add(d);return Ce(l,s),wt(u.code,u.templates,o)}function Fn(n,e,t,r,i){let s=i.runtimeModule??"@fluixi/dom",o=i.coreModule??"@fluixi/core",a=new Map,l=(p,m)=>a.set(p,[...a.get(p)??[],m]),c=new Set(n);for(let p of e.builtins)c.add(p);e.delegatedEvents.size>0&&c.add("delegateEvents");for(let p of[...c].sort())r.has(p)||(On.has(p)?l(i.reactiveModule??"@fluixi/reactive/signal",p):Tn.has(p)?l(i.routerModule??"@fluixi/core/router",p):$n.has(p)?l(o,p):In.has(p)?l(i.controlFlowModule??s,p):l(s,p));for(let[p,m]of e.resolved)r.has(p)||l(m.module,m.export==="default"?`default as ${p}`:p===m.export?p:`${m.export} as ${p}`);let u=[];for(let[p,m]of a)u.push(`import { ${m.join(", ")} } from ${JSON.stringify(p)};`);let d=[...e.deferred].filter(([p])=>!r.has(p));if(d.length>0){r.has("deferred")||u.push(`import { deferred } from ${JSON.stringify(o)};`);for(let[p,m]of d)u.push(`const ${p} = deferred(() => import(${JSON.stringify(m.module)}), { strategy: ${_n(m.loading)}, export: ${JSON.stringify(m.export)} });`)}for(let[p,m]of t)u.push(`const ${m} = ${JSON.stringify(p.startsWith("svg:")?p.slice(4):p)};`);return e.delegatedEvents.size>0&&u.push(`delegateEvents(${JSON.stringify([...e.delegatedEvents])});`),u.length>0?u.join(`
15
15
  `)+`
16
16
  `:null}export{ui as transformTemplates};