@fluixi/compiler 1.0.0-alpha.77 → 1.0.0-alpha.78

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.
@@ -1,8 +1,8 @@
1
- import{a as h}from"./chunk-545LMC5W.mjs";import{a as C,f as M}from"./chunk-E2PW2OZU.mjs";import{a as j}from"./chunk-3SAEGOMQ.mjs";import{mkdirSync as H,readFileSync as w,writeFileSync as X}from"node:fs";import{dirname as E,relative as D,sep as G,resolve as b}from"node:path";var q=new Set(["Text","Image","Option","Audio","Comment","Range","Selection","Notification","Event","Document","Element","Node","Screen","Window","Location","History","Storage","Response","Request","Headers"]);function V(e){if(e.startsWith(".")||e.startsWith("/")||/^[~@]\//.test(e))return;let t=e.split("/");return e.startsWith("@")?t.slice(0,2).join("/"):t[0]}function x(e){return`_${e.replace(/[^A-Za-z0-9]/g,"_")}`}function O(e,t={}){let{available:n,builtins:s=!0,intrinsics:r=!0,generator:i="@fluixi/compiler",specifier:l=o=>o}=t,a=[...e];s&&a.push({components:M()});let c=C(a),d=n?new Set(n):void 0,p=[],f=[],$=[],v=new Map;for(let o of[...c.names()].sort()){let u=c.resolve(o);if(!u)continue;let m=V(u.module);q.has(o)?f.push(o):d&&m&&!d.has(m)?$.push(o):(p.push(o),v.set(o,u))}let W=r?[...new Set(Object.values(h).map(o=>o.module))]:[],R=[...new Set([...p.map(o=>v.get(o).module),...W])].sort().map(o=>`import * as ${x(o)} from '${l(o)}';`),L=p.map(o=>{let u=v.get(o),m=x(u.module);return u.export==="default"?` const ${o}: typeof ${m}.default;`:` export import ${o} = ${m}.${u.export};`}),_=f.length>0?`//
1
+ import{a as h}from"./chunk-SGDQZDEV.mjs";import{a as C,f as M}from"./chunk-E2PW2OZU.mjs";import{a as j}from"./chunk-3SAEGOMQ.mjs";import{mkdirSync as X,readFileSync as w,writeFileSync as U}from"node:fs";import{dirname as D,relative as F,sep as k,resolve as b}from"node:path";var V=new Set(["Text","Image","Option","Audio","Comment","Range","Selection","Notification","Event","Document","Element","Node","Screen","Window","Location","History","Storage","Response","Request","Headers"]);function H(e){if(e.startsWith(".")||e.startsWith("/")||/^[~@]\//.test(e))return;let t=e.split("/");return e.startsWith("@")?t.slice(0,2).join("/"):t[0]}function x(e){return`_${e.replace(/[^A-Za-z0-9]/g,"_")}`}function O(e,t={}){let{available:n,builtins:s=!0,intrinsics:r=!0,generator:i="@fluixi/compiler",specifier:a=o=>o}=t,l=[...e];s&&l.push({components:M()});let c=C(l),d=n?new Set(n):void 0,p=[],f=[],T=[],v=new Map;for(let o of[...c.names()].sort()){let u=c.resolve(o);if(!u)continue;let m=H(u.module);V.has(o)?f.push(o):d&&m&&!d.has(m)?T.push(o):(p.push(o),v.set(o,u))}let L=r?[...new Set(Object.values(h).map(o=>o.module))]:[],R=[...new Set([...p.map(o=>v.get(o).module),...L])].sort().map(o=>`import * as ${x(o)} from '${a(o)}';`),_=p.map(o=>{let u=v.get(o),m=x(u.module);return u.export==="default"?` const ${o}: typeof ${m}.default;`:` export import ${o} = ${m}.${u.export};`}),B=f.length>0?`//
2
2
  // Import these explicitly — lib.dom already declares the name, so an ambient
3
3
  // declaration cannot win:
4
- `+f.map(o=>{let u=c.resolve(o)?.module;return`// import { ${o} } from '${u?l(u):""}';
5
- `}).join(""):"",B=r?Object.entries(h).map(([o,u])=>` const ${o}: typeof ${x(u.module)}.${u.export};`):[],g=e.filter(o=>"match"in o).length,J=g>0?`//
4
+ `+f.map(o=>{let u=c.resolve(o)?.module;return`// import { ${o} } from '${u?a(u):""}';
5
+ `}).join(""):"",J=r?Object.entries(h).map(([o,u])=>` const ${o}: typeof ${x(u.module)}.${u.export};`):[],g=e.filter(o=>"match"in o).length,q=g>0?`//
6
6
  // ${g} pattern rule${g===1?"":"s"} cannot be declared:
7
7
  // a pattern matches unboundedly many names, so there is no list to emit. Those
8
8
  // tags still resolve at build time; declare them by hand if the editor needs them.
@@ -10,17 +10,17 @@ import{a as h}from"./chunk-545LMC5W.mjs";import{a as C,f as M}from"./chunk-E2PW2
10
10
  //
11
11
  // The components \`resolve\` supplies without an import. This describes what the
12
12
  // compiler already does; it does not enable it.
13
- `+_+J+(R.length>0?`
13
+ `+B+q+(R.length>0?`
14
14
  ${R.join(`
15
15
  `)}
16
16
  `:`
17
17
  `)+`
18
18
  declare global {
19
- ${[...L,...B].join(`
19
+ ${[..._,...J].join(`
20
20
  `)}
21
21
  }
22
- `,declared:p,shadowedByDom:f,unavailable:$,patternRules:g}}var U="GENERATED by @fluixi/compiler",z="fluixi.d.ts";function K(e,t){let n;try{let r=w(b(e,"tsconfig.json"),"utf8");n=JSON.parse(r.replace(/^\s*\/\/.*$/gm,""))}catch{return}if(n.extends!==void 0)return;if(!Array.isArray(n.include))return!0;let s=k(e,t);return n.include.some(r=>{if(typeof r!="string")return!1;let i=r.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\//g,"(?:.*/)?").replace(/\*/g,"[^/]*");return new RegExp(`^${i}(?:/.*)?$`).test(s)})}function k(e,t){return D(e,t).split(G).join("/")}function Z(e,t,n){if(!e.startsWith("/"))return e;let s=b(n,e.slice(1)),r=D(t,s).split(G).join("/");return r.startsWith(".")||(r=`./${r}`),r.replace(/\.(tsx|ts|jsx|mts|cts)$/,".js")}function Q(e){try{let t=JSON.parse(w(b(e,"package.json"),"utf8"));return[...Object.keys(t.dependencies??{}),...Object.keys(t.devDependencies??{}),...Object.keys(t.peerDependencies??{})]}catch{return}}function A(e,t){if(e.globals===!1)return{status:"skipped",reason:"disabled"};let n=e.resolve??[],s=b(t,e.globals??z),r;try{r=w(s,"utf8")}catch{r=void 0}if(r!==void 0&&!r.includes(U))return{status:"skipped",reason:"foreign-file",path:s};let{source:i,declared:l}=O(n,{available:Q(t),specifier:a=>Z(a,E(s),t)});return r===i?{status:"unchanged",path:s,declared:l.length,warning:F(t,s)}:(H(E(s),{recursive:!0}),X(s,i),{status:"written",path:s,declared:l.length,warning:F(t,s)})}function F(e,t){if(K(e,t)!==!1)return;let n=k(e,t);return`[fluixi] ${n} is not covered by "include" in tsconfig.json, so TypeScript will ignore it and every resolved component stays "Cannot find name". Add "${n}" to "include".`}import{readdirSync as ue,readFileSync as ce}from"node:fs";import{join as N}from"node:path";async function T(e={}){let t=null;try{t=await import("./babel-YQ42WUS3.mjs")}catch(n){console.warn("Could not load the babel front-end:",n)}return{name:"babel-fluixi-jsx",plugin:t?t.default||t:null,getOptions(){return{importSource:e.importSource||"@fluixi/jsx",development:e.development||!1,delegateEvents:e.delegateEvents!==!1,...e.format?{format:e.format}:{},...e.resolve?{resolve:e.resolve}:{},...e.templateClone!==void 0?{templateClone:e.templateClone}:{},...e.partialTemplates!==void 0?{partialTemplates:e.partialTemplates}:{},...e.litTag?{litTag:e.litTag}:{},...e.signalModule?{signalModule:e.signalModule}:{},...e.controlFlowModule?{controlFlowModule:e.controlFlowModule}:{},...e.routerModule?{routerModule:e.routerModule}:{},...e.reactiveModule?{reactiveModule:e.reactiveModule}:{}}}}}function Y(e={}){let t=te("typescript");return t?n=>{let s=r=>t.isJsxElement(r)||t.isJsxSelfClosingElement(r)?ee(r,e,t):t.visitEachChild(r,s,n);return r=>t.visitNode(r,s)}:(console.warn("TypeScript not found, transformer unavailable"),n=>s=>s)}function ee(e,t,n){return e}function te(e){try{return j(e)}catch{return null}}function ne(e={}){return{name:"vite-fluixi-jsx",enforce:"pre",config(){return{esbuild:{jsx:"automatic",jsxImportSource:e.importSource||"@fluixi/jsx"}}},configResolved(t){let n=A(e,t?.root??process.cwd());n.warning&&console.warn(n.warning)},async transform(t,n){if(!/\.(jsx|tsx|ts)$/i.test(n))return null;if(!e.babel)return y(t,n,e);let s=await T(e);try{let r=await import("@babel/core").catch(()=>null);if(!r)throw new Error(`[fluixi] @babel/core is required to compile ${n} but could not be loaded. Install it alongside @fluixi/compiler.`);let i=/\.tsx$/.test(n),l=/\.ts$/.test(n),a=[],c=[];if(i||l){let p=await import("@babel/preset-typescript").then(f=>f.default||f).catch(()=>null);p&&a.push([p,{isTSX:i,allExtensions:!0,jsxPragma:"jsx",jsxPragmaFrag:"Fragment",onlyRemoveTypeImports:!0}])}s&&s.plugin?c.push([s.plugin,s.getOptions()]):console.warn("[createVitePlugin] custom babel plugin not found");let d=await r.transformAsync(t,{filename:n,configFile:!1,babelrc:!1,presets:a,plugins:c,sourceMaps:e.sourceMaps!==!1});return{code:d?.code||t,map:d?.map}}catch(r){throw r}}}}function re(e){return{resolve:e.resolve,litTag:e.litTag,templateClone:e.templateClone,partialTemplates:e.partialTemplates,runtimeModule:e.signalModule,controlFlowModule:e.controlFlowModule,routerModule:e.routerModule,reactiveModule:e.reactiveModule,propsDestructure:e.propsDestructure}}async function se(e,t,n){if(n.propsDestructure===!1)return e;let{transformProps:s}=await import("./transform-ZGXUDFEZ.mjs"),r=s(e,t);return r.rewritten>0?r.code:e}var P=new Set;function oe(e,t){let n=e,s=r=>{let i=`${t}\0${r}`;P.has(i)||(P.add(i),console.warn(`[fluixi] ${t}: ${r}`))};for(let r of n?.unresolvedDiagnostics??[])s(r.message);for(let r of n?.loadDiagnostics??[])s(r.message)}async function y(e,t,n){if(!n.babel){let{transformTemplates:a}=await import("./transform-ZGXUDFEZ.mjs"),c=a(e,t,re(n));return oe(c,t),c}let s=await se(e,t,n),r=await import("@babel/core").catch(()=>null),i=await T(n);if(!r||!i.plugin)throw new Error(`[fluixi] babel: true needs @babel/core, which could not be loaded for ${t}. Install it, or drop the option to use the built-in compiler.`);let l=await r.transformAsync(s,{filename:t,configFile:!1,babelrc:!1,plugins:[[i.plugin,i.getOptions()]],sourceMaps:n.sourceMaps!==!1});return l?.code?{code:l.code,map:l.map}:null}function ie(e={}){return async function(t){let n=this.async();y(t,this.resourcePath,e).then(s=>{n(null,s?.code,s?.map)}).catch(s=>{n(s)})}}function le(e={}){return{name:"rollup-fluixi-jsx",async transform(t,n){return/\.[jt]sx?$/.test(n)?y(t,n,e):null}}}function ae(e={}){return{name:"esbuild-fluixi-jsx",setup(t){t.onLoad({filter:/\.[jt]sx?$/},async n=>{let{readFileSync:s}=await import("node:fs"),r=s(n.path,"utf8");try{return{contents:(await y(r,n.path,e))?.code??r,loader:n.path.endsWith("x")?"tsx":"ts"}}catch(i){return{errors:[{text:`Transform error: ${i}`}]}}})}}}var S="virtual:fluixi-server-fns";function I(e,t=[]){let n;try{n=ue(e,{withFileTypes:!0})}catch{return t}for(let s of n){if(s.name==="node_modules"||s.name==="dist"||s.name.startsWith("."))continue;let r=N(e,s.name);if(s.isDirectory())I(r,t);else if(/\.[jt]sx?$/.test(s.name))try{ce(r,"utf8").includes("use server")&&t.push(r)}catch{}}return t}function $e(e={}){let t=process.cwd();return{name:"fluixi-server-functions",enforce:"pre",configResolved(n){t=n.root||t},resolveId(n){return n===S||n==="@fluixi/start/server-fns"?"\0"+S:null},load(n){if(n!=="\0"+S)return null;let s=I(N(t,"src")),r=`import '@fluixi/start/server-fn-setup';
23
- `,i=s.map(a=>`import ${JSON.stringify(a)};`).join(`
22
+ `,declared:p,shadowedByDom:f,unavailable:T,patternRules:g}}var z="GENERATED by @fluixi/compiler",K="fluixi.d.ts";function Z(e,t){let n;try{let r=w(b(e,"tsconfig.json"),"utf8");n=JSON.parse(r.replace(/^\s*\/\/.*$/gm,""))}catch{return}if(n.extends!==void 0)return;if(!Array.isArray(n.include))return!0;let s=G(e,t);return n.include.some(r=>{if(typeof r!="string")return!1;let i=r.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\//g,"(?:.*/)?").replace(/\*/g,"[^/]*");return new RegExp(`^${i}(?:/.*)?$`).test(s)})}function G(e,t){return F(e,t).split(k).join("/")}function Q(e,t,n){if(!e.startsWith("/"))return e;let s=b(n,e.slice(1)),r=F(t,s).split(k).join("/");return r.startsWith(".")||(r=`./${r}`),r.replace(/\.(tsx|ts|jsx|mts|cts)$/,".js")}function Y(e){try{let t=JSON.parse(w(b(e,"package.json"),"utf8"));return[...Object.keys(t.dependencies??{}),...Object.keys(t.devDependencies??{}),...Object.keys(t.peerDependencies??{})]}catch{return}}function A(e,t){if(e.globals===!1)return{status:"skipped",reason:"disabled"};let n=e.resolve??[],s=b(t,e.globals??K),r;try{r=w(s,"utf8")}catch{r=void 0}if(r!==void 0&&!r.includes(z))return{status:"skipped",reason:"foreign-file",path:s};let{source:i,declared:a}=O(n,{available:Y(t),specifier:l=>Q(l,D(s),t)});return r===i?{status:"unchanged",path:s,declared:a.length,warning:E(t,s)}:(X(D(s),{recursive:!0}),U(s,i),{status:"written",path:s,declared:a.length,warning:E(t,s)})}function E(e,t){if(Z(e,t)!==!1)return;let n=G(e,t);return`[fluixi] ${n} is not covered by "include" in tsconfig.json, so TypeScript will ignore it and every resolved component stays "Cannot find name". Add "${n}" to "include".`}import{readdirSync as ue,readFileSync as ce}from"node:fs";import{join as N}from"node:path";async function $(e={}){let t=null;try{t=await import("./babel-YQ42WUS3.mjs")}catch(n){console.warn("Could not load the babel front-end:",n)}return{name:"babel-fluixi-jsx",plugin:t?t.default||t:null,getOptions(){return{importSource:e.importSource||"@fluixi/jsx",development:e.development||!1,delegateEvents:e.delegateEvents!==!1,...e.format?{format:e.format}:{},...e.resolve?{resolve:e.resolve}:{},...e.templateClone!==void 0?{templateClone:e.templateClone}:{},...e.partialTemplates!==void 0?{partialTemplates:e.partialTemplates}:{},...e.litTag?{litTag:e.litTag}:{},...e.signalModule?{signalModule:e.signalModule}:{},...e.controlFlowModule?{controlFlowModule:e.controlFlowModule}:{},...e.routerModule?{routerModule:e.routerModule}:{},...e.reactiveModule?{reactiveModule:e.reactiveModule}:{}}}}}function ee(e={}){let t=ne("typescript");return t?n=>{let s=r=>t.isJsxElement(r)||t.isJsxSelfClosingElement(r)?te(r,e,t):t.visitEachChild(r,s,n);return r=>t.visitNode(r,s)}:(console.warn("TypeScript not found, transformer unavailable"),n=>s=>s)}function te(e,t,n){return e}function ne(e){try{return j(e)}catch{return null}}function re(e={}){return{name:"vite-fluixi-jsx",enforce:"pre",config(){return{esbuild:{jsx:"automatic",jsxImportSource:e.importSource||"@fluixi/jsx"}}},configResolved(t){let n=A(e,t?.root??process.cwd());n.warning&&console.warn(n.warning)},async transform(t,n){if(!/\.(jsx|tsx|ts)$/i.test(n))return null;if(!e.babel)return y(t,n,e);let s=await $(e);try{let r=await import("@babel/core").catch(()=>null);if(!r)throw new Error(`[fluixi] @babel/core is required to compile ${n} but could not be loaded. Install it alongside @fluixi/compiler.`);let i=/\.tsx$/.test(n),a=/\.ts$/.test(n),l=[],c=[];if(i||a){let p=await import("@babel/preset-typescript").then(f=>f.default||f).catch(()=>null);p&&l.push([p,{isTSX:i,allExtensions:!0,jsxPragma:"jsx",jsxPragmaFrag:"Fragment",onlyRemoveTypeImports:!0}])}s&&s.plugin?c.push([s.plugin,s.getOptions()]):console.warn("[createVitePlugin] custom babel plugin not found");let d=await r.transformAsync(t,{filename:n,configFile:!1,babelrc:!1,presets:l,plugins:c,sourceMaps:e.sourceMaps!==!1});return{code:d?.code||t,map:d?.map}}catch(r){throw r}}}}function se(e){return{resolve:e.resolve,litTag:e.litTag,templateClone:e.templateClone,partialTemplates:e.partialTemplates,runtimeModule:e.signalModule,controlFlowModule:e.controlFlowModule,routerModule:e.routerModule,reactiveModule:e.reactiveModule,propsDestructure:e.propsDestructure}}async function oe(e,t,n){if(n.propsDestructure===!1)return e;let{transformProps:s}=await import("./transform-ATMT4MSA.mjs"),r=s(e,t);return I({propsDiagnostics:r.diagnostics},t),r.rewritten>0?r.code:e}var P=new Set;function I(e,t){let n=e,s=r=>{let i=`${t}\0${r}`;P.has(i)||(P.add(i),console.warn(`[fluixi] ${t}: ${r}`))};for(let r of n?.unresolvedDiagnostics??[])s(r.message);for(let r of n?.loadDiagnostics??[])s(r.message);for(let r of n?.intrinsicDiagnostics??[])s(r.message);for(let r of n?.propsDiagnostics??[])s(`\`${r.name}\` was left destructured: ${r.message}. It reads once instead of tracking.`)}async function y(e,t,n){if(!n.babel){let{transformTemplates:l}=await import("./transform-ATMT4MSA.mjs"),c=l(e,t,se(n));return I(c,t),c}let s=await oe(e,t,n),r=await import("@babel/core").catch(()=>null),i=await $(n);if(!r||!i.plugin)throw new Error(`[fluixi] babel: true needs @babel/core, which could not be loaded for ${t}. Install it, or drop the option to use the built-in compiler.`);let a=await r.transformAsync(s,{filename:t,configFile:!1,babelrc:!1,plugins:[[i.plugin,i.getOptions()]],sourceMaps:n.sourceMaps!==!1});return a?.code?{code:a.code,map:a.map}:null}function ie(e={}){return async function(t){let n=this.async();y(t,this.resourcePath,e).then(s=>{n(null,s?.code,s?.map)}).catch(s=>{n(s)})}}function ae(e={}){return{name:"rollup-fluixi-jsx",async transform(t,n){return/\.[jt]sx?$/.test(n)?y(t,n,e):null}}}function le(e={}){return{name:"esbuild-fluixi-jsx",setup(t){t.onLoad({filter:/\.[jt]sx?$/},async n=>{let{readFileSync:s}=await import("node:fs"),r=s(n.path,"utf8");try{return{contents:(await y(r,n.path,e))?.code??r,loader:n.path.endsWith("x")?"tsx":"ts"}}catch(i){return{errors:[{text:`Transform error: ${i}`}]}}})}}}var S="virtual:fluixi-server-fns";function W(e,t=[]){let n;try{n=ue(e,{withFileTypes:!0})}catch{return t}for(let s of n){if(s.name==="node_modules"||s.name==="dist"||s.name.startsWith("."))continue;let r=N(e,s.name);if(s.isDirectory())W(r,t);else if(/\.[jt]sx?$/.test(s.name))try{ce(r,"utf8").includes("use server")&&t.push(r)}catch{}}return t}function Te(e={}){let t=process.cwd();return{name:"fluixi-server-functions",enforce:"pre",configResolved(n){t=n.root||t},resolveId(n){return n===S||n==="@fluixi/start/server-fns"?"\0"+S:null},load(n){if(n!=="\0"+S)return null;let s=W(N(t,"src")),r=`import '@fluixi/start/server-fn-setup';
23
+ `,i=s.map(l=>`import ${JSON.stringify(l)};`).join(`
24
24
  `);return r+i+`
25
25
  export { isServerFnRequest, handleServerFn } from '@fluixi/start/server-fn';
26
- `},async transform(n,s,r){if(!/\.[jt]sx?$/.test(s)||!n.includes("use server"))return null;let i={ssr:!!r?.ssr,filename:s,root:t};if(e.babel){let{transformServerFunctions:a}=await import("./server-functions-E3LKCZ4R.mjs");return a(n,i)}let{transformServerFns:l}=await import("./server-fns-6QM243HC.mjs");return l(n,i)}}}var Re={createBabelPlugin:T,createTypeScriptTransformer:Y,createVitePlugin:ne,createWebpackLoader:ie,createRollupPlugin:le,createESBuildPlugin:ae};export{T as createBabelPlugin,ae as createESBuildPlugin,le as createRollupPlugin,Y as createTypeScriptTransformer,ne as createVitePlugin,ie as createWebpackLoader,Re as default,$e as serverFunctionsVitePlugin};
26
+ `},async transform(n,s,r){if(!/\.[jt]sx?$/.test(s)||!n.includes("use server"))return null;let i={ssr:!!r?.ssr,filename:s,root:t};if(e.babel){let{transformServerFunctions:l}=await import("./server-functions-E3LKCZ4R.mjs");return l(n,i)}let{transformServerFns:a}=await import("./server-fns-6QM243HC.mjs");return a(n,i)}}}var Re={createBabelPlugin:$,createTypeScriptTransformer:ee,createVitePlugin:re,createWebpackLoader:ie,createRollupPlugin:ae,createESBuildPlugin:le};export{$ as createBabelPlugin,le as createESBuildPlugin,ae as createRollupPlugin,ee as createTypeScriptTransformer,re as createVitePlugin,ie as createWebpackLoader,Re as default,Te as serverFunctionsVitePlugin};
@@ -1,8 +1,8 @@
1
- "use strict";var C=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var k=(e,t)=>{for(var r in t)C(e,r,{get:t[r],enumerable:!0})},A=(e,t,r,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of D(t))!P.call(e,n)&&n!==r&&C(e,n,{get:()=>t[n],enumerable:!(c=_(t,n))||c.enumerable});return e};var B=e=>A(C({},"__esModule",{value:!0}),e);var H={};k(H,{componentGlobals:()=>V});module.exports=B(H);var G=e=>"components"in e;function S(e,t){return e.replace(/\$(\d+)/g,(r,c)=>t[Number(c)]??r)}function W(e,t){return typeof t=="string"?{module:t,export:e}:t}function $(e=[]){let t=new Map,r=[],c=[];for(let s of e){if(!G(s)){c.push(s);continue}for(let[i,a]of Object.entries(s.components)){let u=W(i,a),m=t.get(i);if(m&&m.module!==u.module){let d=r.find(R=>R.name===i);d?d.modules.push(u.module):r.push({name:i,modules:[m.module,u.module]});continue}t.set(i,u)}}let n=new Map;return{resolve:s=>{if(n.has(s))return n.get(s);let i=t.get(s);if(!i)for(let a of c){let u=s.match(new RegExp(a.match.source,a.match.flags.replace("g","")));if(u){i={module:S(a.module,u),export:a.export?S(a.export,u):s};break}}return n.set(s,i),i},names:()=>[...t.keys()],conflicts:()=>r}}var b=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],M=["Suspense","SuspenseList","Await"],E=["Router","Outlet","Redirect","Link"],J=[...b,...M,...E],Q=new Set([...b,...M]);function I(e={}){let{controlFlowModule:t="@fluixi/dom",coreModule:r="@fluixi/core",routerModule:c="@fluixi/core/router-next"}=e,n={};for(let p of b)n[p]=t;for(let p of M)n[p]=r;for(let p of E)n[p]=c;return n}var f="@fluixi/reactive/signal",v={$signal:{export:"signal",module:f,returns:"signal-handle"},$memo:{export:"memo",module:f,returns:"memo-handle"},$effect:{export:"effect",module:f,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:f,returns:"resource-handle"},$selector:{export:"createSelector",module:f,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:f,returns:"memo-accessor"},$untrack:{export:"untrack",module:f,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}};var Y=new RegExp(`\\$(?:${Object.keys(v).map(e=>e.slice(1)).join("|")})\\s*\\(`);var F=new Set(["Text","Image","Option","Audio","Comment","Range","Selection","Notification","Event","Document","Element","Node","Screen","Window","Location","History","Storage","Response","Request","Headers"]);function U(e){if(e.startsWith(".")||e.startsWith("/")||/^[~@]\//.test(e))return;let t=e.split("/");return e.startsWith("@")?t.slice(0,2).join("/"):t[0]}function y(e){return`_${e.replace(/[^A-Za-z0-9]/g,"_")}`}function V(e,t={}){let{available:r,builtins:c=!0,intrinsics:n=!0,generator:p="@fluixi/compiler",specifier:s=o=>o}=t,i=[...e];c&&i.push({components:I()});let a=$(i),u=r?new Set(r):void 0,m=[],d=[],R=[],h=new Map;for(let o of[...a.names()].sort()){let l=a.resolve(o);if(!l)continue;let g=U(l.module);F.has(o)?d.push(o):u&&g&&!u.has(g)?R.push(o):(m.push(o),h.set(o,l))}let w=n?[...new Set(Object.values(v).map(o=>o.module))]:[],O=[...new Set([...m.map(o=>h.get(o).module),...w])].sort().map(o=>`import * as ${y(o)} from '${s(o)}';`),N=m.map(o=>{let l=h.get(o),g=y(l.module);return l.export==="default"?` const ${o}: typeof ${g}.default;`:` export import ${o} = ${g}.${l.export};`}),T=d.length>0?`//
1
+ "use strict";var C=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var k=(e,t)=>{for(var r in t)C(e,r,{get:t[r],enumerable:!0})},A=(e,t,r,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of D(t))!P.call(e,n)&&n!==r&&C(e,n,{get:()=>t[n],enumerable:!(c=_(t,n))||c.enumerable});return e};var B=e=>A(C({},"__esModule",{value:!0}),e);var H={};k(H,{componentGlobals:()=>V});module.exports=B(H);var G=e=>"components"in e;function S(e,t){return e.replace(/\$(\d+)/g,(r,c)=>t[Number(c)]??r)}function W(e,t){return typeof t=="string"?{module:t,export:e}:t}function $(e=[]){let t=new Map,r=[],c=[];for(let s of e){if(!G(s)){c.push(s);continue}for(let[i,a]of Object.entries(s.components)){let u=W(i,a),m=t.get(i);if(m&&m.module!==u.module){let d=r.find(R=>R.name===i);d?d.modules.push(u.module):r.push({name:i,modules:[m.module,u.module]});continue}t.set(i,u)}}let n=new Map;return{resolve:s=>{if(n.has(s))return n.get(s);let i=t.get(s);if(!i)for(let a of c){let u=s.match(new RegExp(a.match.source,a.match.flags.replace("g","")));if(u){i={module:S(a.module,u),export:a.export?S(a.export,u):s};break}}return n.set(s,i),i},names:()=>[...t.keys()],conflicts:()=>r}}var b=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],M=["Suspense","SuspenseList","Await"],E=["Router","Outlet","Redirect","Link"],J=[...b,...M,...E],Q=new Set([...b,...M]);function I(e={}){let{controlFlowModule:t="@fluixi/dom",coreModule:r="@fluixi/core",routerModule:c="@fluixi/core/router-next"}=e,n={};for(let p of b)n[p]=t;for(let p of M)n[p]=r;for(let p of E)n[p]=c;return n}var f="@fluixi/reactive/signal",h={$signal:{export:"signal",module:f,returns:"signal-handle"},$memo:{export:"memo",module:f,returns:"memo-handle"},$effect:{export:"effect",module:f,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:f,returns:"resource-handle"},$selector:{export:"createSelector",module:f,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:f,returns:"memo-accessor"},$untrack:{export:"untrack",module:f,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}};var Y=new RegExp(`\\$(?:${Object.keys(h).map(e=>e.slice(1)).join("|")})\\s*\\(`);var F=new Set(["Text","Image","Option","Audio","Comment","Range","Selection","Notification","Event","Document","Element","Node","Screen","Window","Location","History","Storage","Response","Request","Headers"]);function U(e){if(e.startsWith(".")||e.startsWith("/")||/^[~@]\//.test(e))return;let t=e.split("/");return e.startsWith("@")?t.slice(0,2).join("/"):t[0]}function y(e){return`_${e.replace(/[^A-Za-z0-9]/g,"_")}`}function V(e,t={}){let{available:r,builtins:c=!0,intrinsics:n=!0,generator:p="@fluixi/compiler",specifier:s=o=>o}=t,i=[...e];c&&i.push({components:I()});let a=$(i),u=r?new Set(r):void 0,m=[],d=[],R=[],v=new Map;for(let o of[...a.names()].sort()){let l=a.resolve(o);if(!l)continue;let g=U(l.module);F.has(o)?d.push(o):u&&g&&!u.has(g)?R.push(o):(m.push(o),v.set(o,l))}let w=n?[...new Set(Object.values(h).map(o=>o.module))]:[],O=[...new Set([...m.map(o=>v.get(o).module),...w])].sort().map(o=>`import * as ${y(o)} from '${s(o)}';`),N=m.map(o=>{let l=v.get(o),g=y(l.module);return l.export==="default"?` const ${o}: typeof ${g}.default;`:` export import ${o} = ${g}.${l.export};`}),T=d.length>0?`//
2
2
  // Import these explicitly — lib.dom already declares the name, so an ambient
3
3
  // declaration cannot win:
4
4
  `+d.map(o=>{let l=a.resolve(o)?.module;return`// import { ${o} } from '${l?s(l):""}';
5
- `}).join(""):"",L=n?Object.entries(v).map(([o,l])=>` const ${o}: typeof ${y(l.module)}.${l.export};`):[],x=e.filter(o=>"match"in o).length,j=x>0?`//
5
+ `}).join(""):"",L=n?Object.entries(h).map(([o,l])=>` const ${o}: typeof ${y(l.module)}.${l.export};`):[],x=e.filter(o=>"match"in o).length,j=x>0?`//
6
6
  // ${x} pattern rule${x===1?"":"s"} cannot be declared:
7
7
  // a pattern matches unboundedly many names, so there is no list to emit. Those
8
8
  // tags still resolve at build time; declare them by hand if the editor needs them.
@@ -1,8 +1,8 @@
1
- var j=t=>"components"in t;function O(t,o){return t.replace(/\$(\d+)/g,(a,u)=>o[Number(u)]??a)}function _(t,o){return typeof o=="string"?{module:o,export:t}:o}function S(t=[]){let o=new Map,a=[],u=[];for(let n of t){if(!j(n)){u.push(n);continue}for(let[r,l]of Object.entries(n.components)){let c=_(r,l),m=o.get(r);if(m&&m.module!==c.module){let d=a.find(R=>R.name===r);d?d.modules.push(c.module):a.push({name:r,modules:[m.module,c.module]});continue}o.set(r,c)}}let i=new Map;return{resolve:n=>{if(i.has(n))return i.get(n);let r=o.get(n);if(!r)for(let l of u){let c=n.match(new RegExp(l.match.source,l.match.flags.replace("g","")));if(c){r={module:O(l.module,c),export:l.export?O(l.export,c):n};break}}return i.set(n,r),r},names:()=>[...o.keys()],conflicts:()=>a}}var C=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],b=["Suspense","SuspenseList","Await"],$=["Router","Outlet","Redirect","Link"],G=[...C,...b,...$],W=new Set([...C,...b]);function E(t={}){let{controlFlowModule:o="@fluixi/dom",coreModule:a="@fluixi/core",routerModule:u="@fluixi/core/router-next"}=t,i={};for(let p of C)i[p]=o;for(let p of b)i[p]=a;for(let p of $)i[p]=u;return i}var f="@fluixi/reactive/signal",v={$signal:{export:"signal",module:f,returns:"signal-handle"},$memo:{export:"memo",module:f,returns:"memo-handle"},$effect:{export:"effect",module:f,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:f,returns:"resource-handle"},$selector:{export:"createSelector",module:f,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:f,returns:"memo-accessor"},$untrack:{export:"untrack",module:f,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}};var U=new RegExp(`\\$(?:${Object.keys(v).map(t=>t.slice(1)).join("|")})\\s*\\(`);var D=new Set(["Text","Image","Option","Audio","Comment","Range","Selection","Notification","Event","Document","Element","Node","Screen","Window","Location","History","Storage","Response","Request","Headers"]);function P(t){if(t.startsWith(".")||t.startsWith("/")||/^[~@]\//.test(t))return;let o=t.split("/");return t.startsWith("@")?o.slice(0,2).join("/"):o[0]}function M(t){return`_${t.replace(/[^A-Za-z0-9]/g,"_")}`}function z(t,o={}){let{available:a,builtins:u=!0,intrinsics:i=!0,generator:p="@fluixi/compiler",specifier:n=e=>e}=o,r=[...t];u&&r.push({components:E()});let l=S(r),c=a?new Set(a):void 0,m=[],d=[],R=[],h=new Map;for(let e of[...l.names()].sort()){let s=l.resolve(e);if(!s)continue;let g=P(s.module);D.has(e)?d.push(e):c&&g&&!c.has(g)?R.push(e):(m.push(e),h.set(e,s))}let I=i?[...new Set(Object.values(v).map(e=>e.module))]:[],y=[...new Set([...m.map(e=>h.get(e).module),...I])].sort().map(e=>`import * as ${M(e)} from '${n(e)}';`),w=m.map(e=>{let s=h.get(e),g=M(s.module);return s.export==="default"?` const ${e}: typeof ${g}.default;`:` export import ${e} = ${g}.${s.export};`}),N=d.length>0?`//
1
+ var j=t=>"components"in t;function O(t,o){return t.replace(/\$(\d+)/g,(a,u)=>o[Number(u)]??a)}function _(t,o){return typeof o=="string"?{module:o,export:t}:o}function S(t=[]){let o=new Map,a=[],u=[];for(let n of t){if(!j(n)){u.push(n);continue}for(let[r,l]of Object.entries(n.components)){let c=_(r,l),m=o.get(r);if(m&&m.module!==c.module){let d=a.find(R=>R.name===r);d?d.modules.push(c.module):a.push({name:r,modules:[m.module,c.module]});continue}o.set(r,c)}}let i=new Map;return{resolve:n=>{if(i.has(n))return i.get(n);let r=o.get(n);if(!r)for(let l of u){let c=n.match(new RegExp(l.match.source,l.match.flags.replace("g","")));if(c){r={module:O(l.module,c),export:l.export?O(l.export,c):n};break}}return i.set(n,r),r},names:()=>[...o.keys()],conflicts:()=>a}}var C=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],b=["Suspense","SuspenseList","Await"],$=["Router","Outlet","Redirect","Link"],G=[...C,...b,...$],W=new Set([...C,...b]);function E(t={}){let{controlFlowModule:o="@fluixi/dom",coreModule:a="@fluixi/core",routerModule:u="@fluixi/core/router-next"}=t,i={};for(let p of C)i[p]=o;for(let p of b)i[p]=a;for(let p of $)i[p]=u;return i}var f="@fluixi/reactive/signal",h={$signal:{export:"signal",module:f,returns:"signal-handle"},$memo:{export:"memo",module:f,returns:"memo-handle"},$effect:{export:"effect",module:f,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:f,returns:"resource-handle"},$selector:{export:"createSelector",module:f,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:f,returns:"memo-accessor"},$untrack:{export:"untrack",module:f,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}};var U=new RegExp(`\\$(?:${Object.keys(h).map(t=>t.slice(1)).join("|")})\\s*\\(`);var D=new Set(["Text","Image","Option","Audio","Comment","Range","Selection","Notification","Event","Document","Element","Node","Screen","Window","Location","History","Storage","Response","Request","Headers"]);function P(t){if(t.startsWith(".")||t.startsWith("/")||/^[~@]\//.test(t))return;let o=t.split("/");return t.startsWith("@")?o.slice(0,2).join("/"):o[0]}function M(t){return`_${t.replace(/[^A-Za-z0-9]/g,"_")}`}function z(t,o={}){let{available:a,builtins:u=!0,intrinsics:i=!0,generator:p="@fluixi/compiler",specifier:n=e=>e}=o,r=[...t];u&&r.push({components:E()});let l=S(r),c=a?new Set(a):void 0,m=[],d=[],R=[],v=new Map;for(let e of[...l.names()].sort()){let s=l.resolve(e);if(!s)continue;let g=P(s.module);D.has(e)?d.push(e):c&&g&&!c.has(g)?R.push(e):(m.push(e),v.set(e,s))}let I=i?[...new Set(Object.values(h).map(e=>e.module))]:[],y=[...new Set([...m.map(e=>v.get(e).module),...I])].sort().map(e=>`import * as ${M(e)} from '${n(e)}';`),w=m.map(e=>{let s=v.get(e),g=M(s.module);return s.export==="default"?` const ${e}: typeof ${g}.default;`:` export import ${e} = ${g}.${s.export};`}),N=d.length>0?`//
2
2
  // Import these explicitly — lib.dom already declares the name, so an ambient
3
3
  // declaration cannot win:
4
4
  `+d.map(e=>{let s=l.resolve(e)?.module;return`// import { ${e} } from '${s?n(s):""}';
5
- `}).join(""):"",T=i?Object.entries(v).map(([e,s])=>` const ${e}: typeof ${M(s.module)}.${s.export};`):[],x=t.filter(e=>"match"in e).length,L=x>0?`//
5
+ `}).join(""):"",T=i?Object.entries(h).map(([e,s])=>` const ${e}: typeof ${M(s.module)}.${s.export};`):[],x=t.filter(e=>"match"in e).length,L=x>0?`//
6
6
  // ${x} pattern rule${x===1?"":"s"} cannot be declared:
7
7
  // a pattern matches unboundedly many names, so there is no list to emit. Those
8
8
  // tags still resolve at build time; declare them by hand if the editor needs them.
@@ -1,6 +1,6 @@
1
1
  "use strict";var xt=Object.create;var G=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var bt=Object.getPrototypeOf,St=Object.prototype.hasOwnProperty;var It=(e,t)=>{for(var n in t)G(e,n,{get:t[n],enumerable:!0})},Ce=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of kt(t))!St.call(e,o)&&o!==n&&G(e,o,{get:()=>t[o],enumerable:!(r=Rt(t,o))||r.enumerable});return e};var $e=(e,t,n)=>(n=e!=null?xt(bt(e)):{},Ce(t||!e||!e.__esModule?G(n,"default",{value:e,enumerable:!0}):n,e)),Et=e=>Ce(G({},"__esModule",{value:!0}),e);var Mn={};It(Mn,{explainBail:()=>le,moduleBindings:()=>L,planPropsDestructure:()=>ae,shapeOf:()=>w,transformProps:()=>st,transformTemplates:()=>Nt});module.exports=Et(Mn);var mt=require("@babel/parser"),gt=$e(require("magic-string"),1);function wt(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 M(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 i of o.children)r(i)||(s=!1);let a;for(let i of o.props)if(a=wt(i),a)break;return!a&&!s&&(a=Ct(o)),o.static=!a,a?n.set(o,a):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 Ct(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 Z={kind:"eager"},$t=["pointerdown","focusin","keydown"],Te=new Set(["eager","idle","visible","interaction","media","never"]),E=class extends Error{};function de(e){return e.startsWith("load:")}function Y(e,t){let n=e.slice(5);if(!Te.has(n))throw new E(`Unknown load strategy 'load:${n}'. Expected one of ${[...Te].join(", ")}.`);switch(n){case"eager":return Z;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?Tt(t):[...$t]};case"media":if(!t)throw new E(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:t};default:throw new E(`Unhandled load strategy '${n}'.`)}}function Tt(e){let t=e.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean);if(t.length===0)throw new E("'load:interaction' was given no event names.");return t}function j(e){return e.kind!=="eager"&&e.kind!=="never"}var J=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],B=["Suspense","SuspenseList","Await"],O=["Router","Outlet","Redirect","Link"],Ln=[...J,...B,...O],ue=new Set([...J,...B]);function Pe(e={}){let{controlFlowModule:t="@fluixi/dom",coreModule:n="@fluixi/core",routerModule:r="@fluixi/core/router-next"}=e,o={};for(let s of J)o[s]=t;for(let s of B)o[s]=n;for(let s of O)o[s]=r;return o}function Q(e,t={}){let{resolver:n,isBound:r,modules:o,strategyFor:s}=t,a=Pe(o),i=new Map,l=new Set,c=f=>{let{name:u}=f;if(!u||u.includes(".")||r?.(u))return;let g=p(u);if(!g){l.add(u);return}let m=g.origin==="builtin"&&ue.has(u)?Z:s?.(f)??Z;f.source={...g,loading:m},i.set(u,f.source)},p=f=>{if(ue.has(f))return{module:a[f],export:f,origin:"builtin"};let u=n?.resolve(f);if(u)return{module:u.module,export:u.export,origin:"rule"};if(O.includes(f))return{module:a[f],export:f,origin:"builtin"}};return ee(e,f=>{f.kind==="component"&&c(f)}),{resolved:i,unresolved:[...l]}}function ee(e,t){let n=Array.isArray(e)?e:[e];for(let r of n){t(r);let o=r.children;o&&ee(o,t)}}function te(e){let t=[];ee(e,s=>{s.kind==="component"&&s.source&&t.push(s)});let n=new Set,r=new Set;for(let s of t){let{module:a,loading:i}=s.source;i.kind==="eager"&&n.add(a),i.kind==="never"&&r.add(a)}let o=new Map;for(let s of t){let a=s.source;j(a.loading)&&n.has(a.module)&&(a.loading={kind:"eager"},o.set(a.module,(o.get(a.module)??0)+1))}return{collapsed:o,conflicted:[...r].filter(s=>n.has(s))}}var Pt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Me={className:"class",htmlFor:"for"},Mt=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),Ot=new Set(["script","style","textarea","title"]);function fe(e){return Ot.has(e)}function Oe(e){return Me[e]??e}function _(e){return e.kind!=="attr"||e.expr!==void 0||e.name.includes(":")?!1:!Mt.has(e.name)}function me(e){if(!e.static||fe(e.tag))return!1;for(let t of e.props)if(!_(t))return!1;for(let t of e.children)if(t.kind!=="text"&&!(t.kind==="element"&&me(t)))return!1;return!0}function F(e){let t=e.props.map(At).filter(Boolean).join(""),n=`<${e.tag}${t}>`;return Pt.has(e.tag)?n:`${n}${e.children.map(Dt).join("")}</${e.tag}>`}function Dt(e){if(e.kind==="text")return jt(e.value);if(e.kind!=="element")throw new Error(`serializeStatic: unexpected ${e.kind}`);return F(e)}function At(e){let t=Me[e.name]??e.name,n=e.literal;return n===!0||n===void 0?` ${t}`:n===!1||n===null?"":` ${t}="${Lt(String(n))}"`}function Lt(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function jt(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var Jt="<!--fx-->",Bt="<!--fx/-->";function re(e){return e.kind==="expr"||e.kind==="component"||e.kind==="control"}function _t(e){return e.kind==="text"||e.kind==="element"&&De(e)}function De(e){return e.svg||fe(e.tag)||!e.props.every(t=>_(t))?!1:e.children.every(t=>_t(t)||re(t))}function ne(e){if(re(e))return!0;let t=e.children;return t?t.some(ne):!1}function Ae(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"||Ae(t))}function Le(e){if(!De(e)||!Ae(e)||!e.children.some(ne))return null;let t=[],n=[],r=0,o=a=>{let i=`_n$${r++}`;return t.push({ref:i,expr:a}),i};return s(e,"_el$"),{html:Ft(e),tag:e.tag,steps:t,holes:n};function s(a,i){let l=-1;a.children.forEach((p,f)=>{ne(p)&&(l=f)});let c=null;for(let p=0;p<=l;p++){let f=a.children[p],u=c?`${c}.nextSibling`:`${i}.firstChild`;if(re(f)){let m=o(u),h=o(`holeEnd(${m})`);n.push({parentRef:i,startRef:m,endRef:h,node:f}),c=h;continue}let g=o(u);f.kind==="element"&&ne(f)&&s(f,g),c=g}}}function Ft(e){return F(je(e)).split(Je).join(Jt+Bt)}function je(e){return{...e,children:e.children.map(t=>re(t)?{kind:"text",value:Je}:t.kind==="element"?je(t):t)}}var Je="\0fx-hole\0";var ge={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},Wn={version:2,module:"@fluixi/dom",symbols:[...ge.symbols,"template","cloneTemplate","walk"]};var Ht={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function Vt(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function _e(e){return Vt(e)?e:JSON.stringify(e)}function Xt(e){return e.expr!==void 0?e.reactive?`() => (${e.expr})`:`(${e.expr})`:JSON.stringify(e.literal??!0)}function zt(e){return e.expr!==void 0?`(${e.expr})`:JSON.stringify(e.literal??!0)}function Ut(e,t,n){let r=e.filter(i=>i.kind==="spread"),s=e.filter(i=>i.kind!=="spread").map(i=>`${_e(i.name)}: ${Xt(i)}`);t!=null&&s.push(`children: ${t}`);let a=`{ ${s.join(", ")} }`;return r.length>0?(n.add("mergeProps"),`mergeProps(${r.map(i=>i.expr).join(", ")}, ${a})`):a}function Fe(e,t,n){return e.length===1?H(e[0],t,n):`[${e.map(r=>H(r,t,n)).join(", ")}]`}function Be(e,t,n,r,o){r.add("createMemo"),r.add("createComponent");let s=t.filter(c=>c.kind==="spread"),i=t.filter(c=>c.kind!=="spread").map(c=>`get ${_e(c.name)}() { return ${zt(c)}; }`);n.length>0&&i.push(`get children() { return ${Fe(n,r,o)}; }`);let l=`{ ${i.join(", ")} }`;return s.length>0&&(r.add("mergeProps"),l=`mergeProps(${s.map(c=>c.expr).join(", ")}, ${l})`),`createMemo(() => createComponent(${e}, ${l}))`}function Wt(e,t){let n=Oe(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 He=!1;function H(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":Fe(e.children,t,n);case"component":return Be(e.name,e.props,e.children,t,n);case"control":{let r=Ht[e.control]??e.control;return t.add(r),Be(r,e.props,e.children,t,n)}case"element":{if(n&&e.static&&!e.svg&&me(e)){t.add("templateNode");let i=`_tmpl$${n.length}`;return n.push({id:i,html:F(e),tag:e.tag,svg:!1}),`templateNode(${i}, ${JSON.stringify(e.tag)})`}if(n&&He){let i=Le(e);if(i){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:i.html,tag:i.tag,svg:!1});let c=[`const _el$ = templateNode(${l}, ${JSON.stringify(i.tag)}, true);`];for(let p of i.steps)c.push(`const ${p.ref} = ${p.expr};`);for(let p of i.holes)c.push(`insert(${p.parentRef}, holeScope(${p.startRef}, () => (${H(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=[],a=e.svg?`${r}, true`:r;if(s.push(`const ${o} = createNativeElement(${a});`),e.props.length>0)if(!e.svg&&e.props.every(_))for(let i of e.props)s.push(Wt(o,i));else{t.add("spread");let i=e.svg?", isSVG: true":"";s.push(`spread({ element: ${o}, props: ${Ut(e.props,null,t)}${i} });`)}for(let i of e.children){t.add("insert");let l=H(i,t,n),c=i.kind==="expr"&&i.reactive||i.kind==="component"||i.kind==="control";s.push(c?`insert(${o}, ${l}, null);`:`insert(${o}, ${l});`)}return s.push(`return ${o};`),`(() => { ${s.join(" ")} })()`}}}function oe(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 D={name:"imperative",contract:ge,emit(e,t){let n=new Set,r=t?.templateClone!==!1?[]:void 0;return He=t?.partialTemplates===!0,{code:H(e,n,r),imports:Array.from(n),templates:r}}};var qt=e=>"components"in e;function Ve(e,t){return e.replace(/\$(\d+)/g,(n,r)=>t[Number(r)]??n)}function Kt(e,t){return typeof t=="string"?{module:t,export:e}:t}function se(e=[]){let t=new Map,n=[],r=[];for(let a of e){if(!qt(a)){r.push(a);continue}for(let[i,l]of Object.entries(a.components)){let c=Kt(i,l),p=t.get(i);if(p&&p.module!==c.module){let f=n.find(u=>u.name===i);f?f.modules.push(c.module):n.push({name:i,modules:[p.module,c.module]});continue}t.set(i,c)}}let o=new Map;return{resolve:a=>{if(o.has(a))return o.get(a);let i=t.get(a);if(!i)for(let l of r){let c=a.match(new RegExp(l.match.source,l.match.flags.replace("g","")));if(c){i={module:Ve(l.module,c),export:l.export?Ve(l.export,c):a};break}}return o.set(a,i),i},names:()=>[...t.keys()],conflicts:()=>n}}var Ue=require("@fluixi/template-parser");function V(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 Xe=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function Gt(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function ze(e){return e.charAt(0).toUpperCase()+e.slice(1)}var he=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}=D.emit(t,{});for(let s of r)this.used.add(s);return oe(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 a=o.attributes.find(i=>i.kind==="IfDirective");if(a&&a.kind==="IfDirective"){let i=r+1;i<t.length&&this.isBlankText(t[i])&&i++;let l=t[i],c=l&&(l.kind==="Element"||l.kind==="Component")&&l.attributes.some(p=>p.kind==="ElseDirective");n.push(this.lowerIf(o,a.hole,c?l:null)),c&&(r=i);continue}if(o.attributes.some(i=>i.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&&V(t.value)===""}lowerNode(t){switch(t.kind){case"Text":{if(t.raw)return{kind:"text",value:t.value};let n=V(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},u=r.findIndex(g=>g.name===l);u>=0?r[u]=f:r.push(f)}let a=t.attributes.find(l=>l.kind==="LoadDirective"),i=a?Y(`load:${a.strategy}`,a.modifier):void 0;return{kind:"component",name:n,props:r,children:this.lowerChildren(s),...i?{load:i}:{}}}partitionSlots(t){let n=new Map,r=[];for(let o of t){if(o.kind==="Element"||o.kind==="Component"){let s=o.attributes.find(a=>a.kind==="Attribute"&&a.name==="slot");if(s&&s.value&&s.value.kind==="static"){let a={...o,attributes:o.attributes.filter(c=>c!==s)},i=a.kind==="Element"?this.lowerElement(a):this.lowerComponent(a),l=n.get(s.value.value)??[];l.push(i),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 i=this.stripAndLower(r,l=>l.kind==="ElseDirective");s.push({name:"fallback",kind:"attr",expr:this.emit(i),jsxElement:!0})}let a=this.stripAndLower(t,i=>i.kind==="IfDirective");return{kind:"component",name:"Show",props:s,children:[a]}}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),a;if(s){let l={kind:"expr",code:s.body,reactive:s.bodyReactive},c=this.rebuildWithChildren(t,[l]);a=`(${s.params.join(", ")}) => (${this.emit(c)})`}else{let l=this.stripAndLower(t,c=>c.kind==="EachDirective");a=`() => (${this.emit(l)})`}return{kind:"component",name:"For",props:o,children:[{kind:"expr",code:a,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=[],a=!1,i=[];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}`),a=a||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;i.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:a}),i.length>0&&n.push({name:"use",kind:"attr",expr:`[${i.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"+ze(t.name),kind:"event",event:{name:n,delegated:Xe.has(n)},expr:r};let s=this.wrapHandler(r,t.modifiers),a=this.eventOptions(t.modifiers),i=a?`[${s}, ${a}]`:s;return{name:"on:"+n,kind:"attr",expr:i}}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 a=`bindPair(${n})`;return[{name:t,kind:"attr",expr:`${a}[0]()`,reactive:!0},{name:"on"+ze(o),kind:"event",event:{name:o,delegated:Xe.has(o)},expr:`(e) => ${a}[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 a=!1,i=n.parts.map(l=>{if("text"in l)return Gt(l.text);let c=this.hole(l.hole);return a=a||c.reactive,"${"+c.code+"}"}).join("");return s.expr="`"+i+"`",s.reactive=a,s}};function We(e,t,n,r={}){let{root:o}=(0,Ue.parseTemplate)(e,{svg:r.svg});return new he(t,n).lowerRoot(o.children)}function qe(e,t,n={}){let r=new Set,o=We(e,[...t],r,{svg:n.svg});M(o),Q(o,{resolver:se(n.resolve??[]),modules:{controlFlowModule:n.controlFlowModule??"@fluixi/dom",coreModule:n.coreModule??"@fluixi/core",routerModule:n.routerModule??"@fluixi/core/router-next"},strategyFor:l=>l.load}),te(o);let{code:s,imports:a,templates:i}=D.emit(o,{templateClone:n.templateClone,partialTemplates:n.partialTemplates});for(let l of a)r.add(l);return n.hoistTemplates?{code:s,imports:[...r],ir:o,templates:i}:{code:oe(s,i),imports:[...r],ir:o}}var Zt="children";function A(e){switch(e.kind){case"call":return!0;case"member":return e.property!==Zt;case"compound":return e.parts.some(A);case"opaque":return!1}}var Yt=new Set(["CallExpression","OptionalCallExpression"]),Qt=new Set(["MemberExpression","OptionalMemberExpression"]);function w(e){if(!e)return{kind:"opaque"};if(Yt.has(e.type))return{kind:"call"};if(Qt.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(X)}:e.type==="LogicalExpression"||e.type==="BinaryExpression"?{kind:"compound",parts:[e.left,e.right].map(X)}:e.type==="TemplateLiteral"?{kind:"compound",parts:e.expressions.map(X)}:e.type==="ObjectExpression"?{kind:"compound",parts:e.properties.filter(n=>(n.type==="ObjectProperty"||n.type==="Property")&&n.computed!==!0).map(n=>X(n.value))}:e.type==="ArrayExpression"?{kind:"compound",parts:e.elements.filter(n=>n!=null&&n.type!=="SpreadElement").map(X)}:{kind:"opaque"}}var X=e=>w(e);var en=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),tn=/^on[A-Z]/,nn=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]),Ze=e=>A(w(e));function z(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 ye=e=>!!e&&typeof z(e)=="string";function rn(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 Ne(e){return e.type==="JSXIdentifier"?e.name==="class"?"className":e.name:e.type==="JSXNamespacedName"?`${e.namespace.name}:${e.name.name}`:"unknown"}function on(e,t){let n=Ne(e.name),r=tn.test(n),o=r||n.startsWith("on:")||n==="ref",a={name:n,kind:r?"event":"attr"};if(r){let l=n.slice(2).toLowerCase();a.event={name:l,delegated:nn.has(l)}}let i=e.value;if(i==null)return a.literal=!0,a;if(ye(i))return a.literal=z(i),a;if(i.type==="JSXExpressionContainer"&&i.expression?.type!=="JSXEmptyExpression"){let l=i.expression,c=z(l);return c!==void 0?(a.literal=c,a):(a.expr=t.code(l),a.reactive=o?!1:Ze(l),(l.type==="JSXElement"||l.type==="JSXFragment")&&(a.jsxElement=!0),a)}return a.literal=!0,a}function Ke(e,t){let n=e.value;return n==null?null:ye(n)?JSON.stringify(z(n)):n.type==="JSXExpressionContainer"&&n.expression?.type!=="JSXEmptyExpression"?t.code(n.expression):null}function sn(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"||de(Ne(o.name)))continue;let s=o.name.type==="JSXNamespacedName"?o.name.namespace.name:null;if(s==="use"){let a=o.name.name.name;t.used.add(a);let i=Ke(o,t);r.push(i!=null?`[${a}, () => (${i})]`:`[${a}]`);continue}if(s==="oncapture"){let a=o.name.name.name.toLowerCase(),i=Ke(o,t)??"undefined";n.push({name:"on:"+a,kind:"attr",expr:`[${i}, { capture: true }]`});continue}n.push(on(o,t))}return r.length>0&&n.push({name:"use",kind:"attr",expr:`[${r.join(", ")}]`}),n}function Ge(e,t){let n=[];for(let r of e)if(r.type==="JSXText"){let o=V(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:Ze(o)})}}else r.type==="JSXElement"||r.type==="JSXFragment"?n.push(Ye(r,t)):r.type==="JSXSpreadChild"&&n.push({kind:"expr",code:t.code(r.expression),reactive:!1});return n}function an(e){for(let t of e){if(t.type!=="JSXAttribute")continue;let n=Ne(t.name);if(de(n)){if(t.value&&!ye(t.value))throw new E(`'${n}' needs a literal value, not an expression — the strategy is compile-time.`);return Y(n,t.value?z(t.value):null)}}}function Ye(e,t){if(e.type==="JSXFragment")return{kind:"fragment",children:Ge(e.children,t)};let{tag:n,component:r}=rn(e.openingElement.name,t),o=sn(e.openingElement.attributes,t),s=Ge(e.children,t);if(r){let a=an(e.openingElement.attributes);return{kind:"component",name:n,props:o,children:s,...a?{load:a}:{}}}return{kind:"element",tag:n,svg:en.has(n),props:o,children:s,static:!1}}function Qe(e,t){let n=Ye(e,t);return M(n),n}function C(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"?C(n.argument,t):C(n.value,t);return;case"ArrayPattern":for(let n of e.elements)C(n,t);return;case"AssignmentPattern":C(e.left,t);return;case"RestElement":C(e.argument,t);return}}function et(e,t){switch(e.type){case"ImportDeclaration":for(let n of e.specifiers)C(n.local,t);return;case"VariableDeclaration":for(let n of e.declarations)C(n.id,t);return;case"FunctionDeclaration":case"ClassDeclaration":C(e.id,t);return;case"ExportNamedDeclaration":case"ExportDefaultDeclaration":e.declaration&&et(e.declaration,t);return}}function L(e){let t=new Set;for(let n of e.body)et(n,t);return t}var rt=require("@babel/parser"),ot=$e(require("magic-string"),1);function b(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"?b(n.argument,t):b(n.value,t);return;case"ArrayPattern":for(let n of e.elements)b(n,t);return;case"AssignmentPattern":b(e.left,t);return;case"RestElement":b(e.argument,t);return}}function ve(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(ve);case"UnaryExpression":return ve(e.argument);case"MemberExpression":return!1;default:return!1}}function ie(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"&&ie(o,t);else r&&typeof r=="object"&&typeof r.type=="string"&&ie(r,t)}}}function ln(e){let t=new Set;return ie(e,n=>{if(n.type==="AssignmentExpression")b(n.left,t);else if(n.type==="UpdateExpression"){let r=n.argument;r?.type==="Identifier"&&t.add(r.name)}}),t}function cn(e,t){let n=new Set,r=o=>{let s=new Set;b(o,s);for(let a of s)t.has(a)&&n.add(a)};return ie(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 tt(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;b(p,f);for(let u of f)n.bails.push({name:u,reason:"rest"});continue}n.rest={name:p.name,keys:[]};continue}if(r.computed){let p=new Set;b(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,a=r.value,i;a.type==="AssignmentPattern"&&(i=a.right,a=a.left);let l=[...t,s];if(a.type==="Identifier"){if(i&&!ve(i)){n.bails.push({name:a.name,reason:"unsafe-default"});continue}n.reads.push({name:a.name,path:l,...i?{fallback:i}:{}});continue}if(a.type==="ObjectPattern"){if(i){let p=new Set;b(a,p);for(let f of p)n.bails.push({name:f,reason:"unsafe-default"});continue}tt(a,l,n);continue}let c=new Set;b(a,c);for(let p of c)n.bails.push({name:p,reason:"computed"})}}function ae(e,t){let n={reads:[],bails:[]};if(e?.type!=="ObjectPattern"||(tt(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(i=>i.type!=="RestElement"&&!i.computed).map(i=>{let l=i.key;return l.type==="Identifier"?l.name:l.value})),n.reads.length===0&&!n.rest))return n;let r=new Set(n.reads.map(i=>i.name));n.rest&&r.add(n.rest.name);let o=ln(t),s=cn(t,r),a=[];for(let i of n.reads)o.has(i.name)?n.bails.push({name:i.name,reason:"reassigned"}):s.has(i.name)?n.bails.push({name:i.name,reason:"shadowed"}):a.push(i);return n.reads=a,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 le(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 nt(e){return!!e&&e[0]>="A"&&e[0]<="Z"}function pn(e){let t=[];return U(e,n=>{if(n.type==="FunctionDeclaration"&&nt(n.id?.name)){t.push(n);return}if(n.type==="VariableDeclarator"&&nt(n.id?.name)){let r=n.init;r&&(r.type==="ArrowFunctionExpression"||r.type==="FunctionExpression")&&t.push(r)}}),t}function dn(e){let t=new Set;return U(e,n=>{n.type==="Identifier"&&t.add(n.name)}),t}function un(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 xe(e,t,n={}){let r=[],o=[],s=new Set;for(let a of pn(e)){let i=a.params?.[0];if(i?.type!=="ObjectPattern")continue;let l=ae(i,a.body);for(let m of l.bails)o.push({name:m.name,reason:m.reason,message:le(m.reason),start:i.start});if(l.bails.length>0||l.reads.length===0&&!l.rest)continue;let c=dn(a),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 u=i.typeAnnotation;if(r.push({start:i.start,end:u?.start??i.end,code:p}),l.rest){let m=l.rest.keys.map(v=>JSON.stringify(v)).join(", "),h=a.body;r.push({start:h.start+1,end:h.start+1,code:`
2
2
  const [, ${l.rest.name}] = splitProps(${p}, [${m}]);`}),s.add("splitProps")}let g=[];U(a.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&&!un(m,h))return;let R=l.reads.find($=>$.name===m.name).path;g.push({node:m,parent:S?h:null,text:v,property:R[R.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}),fn(m.node,p,m.property)}return{edits:r,diagnostics:o,used:s}}function fn(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}function st(e,t="module.tsx",n={}){let r=(0,rt.parse)(e,{sourceType:"module",plugins:["typescript","jsx"],errorRecovery:!0}),{edits:o,diagnostics:s,used:a}=xe(r.program,e,n),i=new ot.default(e);for(let l of o)l.start===l.end?i.appendLeft(l.start,l.code):i.overwrite(l.start,l.end,l.code);return a.has("splitProps")&&!L(r.program).has("splitProps")&&i.prepend(`import { splitProps } from ${JSON.stringify(n.runtimeModule??"@fluixi/dom")};
3
- `),{code:i.toString(),map:i.generateMap({source:t,includeContent:!0,hires:!0}),diagnostics:s,rewritten:o.filter(l=>l.code!==(n.parameterName??"props")).length}}var T="@fluixi/reactive/signal",P={$signal:{export:"signal",module:T,returns:"signal-handle"},$memo:{export:"memo",module:T,returns:"memo-handle"},$effect:{export:"effect",module:T,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:T,returns:"resource-handle"},$selector:{export:"createSelector",module:T,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:T,returns:"memo-accessor"},$untrack:{export:"untrack",module:T,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}},it={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"},mn=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/signal-next","@fluixi/reactive/store","@fluixi/core","@fluixi/core/rx"],gn=new RegExp(`\\$(?:${Object.keys(P).map(e=>e.slice(1)).join("|")})\\s*\\(`);function at(e){return gn.test(e)}function lt(e){return Object.prototype.hasOwnProperty.call(P,e)}function ct(e){return mn.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 W(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)W(o,t);else r&&typeof r=="object"&&W(r,t)}}}function hn(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=P[r];if(s&&!t.shadowed.has(r))return s.returns}function yn(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 pt(e){let t=new Set;return W(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 dt(e){let t={kinds:new Map,primitives:new Map,shadowed:new Set},n=e;W(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)P[s]&&t.shadowed.add(s)});for(let r of n.body??[])if(r.type==="ImportDeclaration"&&ct(r.source?.value))for(let o of r.specifiers??[]){if(o.type!=="ImportSpecifier")continue;let s=o.imported,a=s.type==="Identifier"?s.name:s.value,i=it[a];i&&t.primitives.set(o.local.name,i)}return W(n,r=>{if(r.type!=="VariableDeclarator"||!r.init)return;let o=hn(r.init,t);o&&yn(r.id,o,t.kinds)}),t}function Re(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)Re(o,t);else r&&typeof r=="object"&&Re(r,t)}}}function ut(e){let t=[],n=[],r=new Map,o=new Set,{shadowed:s}=dt(e);return Re(e,a=>{if(a.type!=="CallExpression")return;let i=a.callee;if(i?.type!=="Identifier")return;let l=i.name;if(!lt(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:i.start}));return}let c=P[l];t.push({start:i.start,end:i.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 ft(e,t){let n=[];for(let[r,o]of[...e.imports].sort(([s],[a])=>s.localeCompare(a))){let s=[...o].filter(a=>!t.has(a)).sort();s.length&&n.push(`import { ${s.join(", ")} } from ${JSON.stringify(r)};`)}return n.length?`${n.join(`
3
+ `),{code:i.toString(),map:i.generateMap({source:t,includeContent:!0,hires:!0}),diagnostics:s,rewritten:o.filter(l=>l.code!==(n.parameterName??"props")).length}}var T="@fluixi/reactive/signal",P={$signal:{export:"signal",module:T,returns:"signal-handle"},$memo:{export:"memo",module:T,returns:"memo-handle"},$effect:{export:"effect",module:T,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:T,returns:"resource-handle"},$selector:{export:"createSelector",module:T,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:T,returns:"memo-accessor"},$untrack:{export:"untrack",module:T,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}},it={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"},mn=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/store","@fluixi/core","@fluixi/core/rx"],gn=new RegExp(`\\$(?:${Object.keys(P).map(e=>e.slice(1)).join("|")})\\s*\\(`);function at(e){return gn.test(e)}function lt(e){return Object.prototype.hasOwnProperty.call(P,e)}function ct(e){return mn.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 W(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)W(o,t);else r&&typeof r=="object"&&W(r,t)}}}function hn(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=P[r];if(s&&!t.shadowed.has(r))return s.returns}function yn(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 pt(e){let t=new Set;return W(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 dt(e){let t={kinds:new Map,primitives:new Map,shadowed:new Set},n=e;W(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)P[s]&&t.shadowed.add(s)});for(let r of n.body??[])if(r.type==="ImportDeclaration"&&ct(r.source?.value))for(let o of r.specifiers??[]){if(o.type!=="ImportSpecifier")continue;let s=o.imported,a=s.type==="Identifier"?s.name:s.value,i=it[a];i&&t.primitives.set(o.local.name,i)}return W(n,r=>{if(r.type!=="VariableDeclarator"||!r.init)return;let o=hn(r.init,t);o&&yn(r.id,o,t.kinds)}),t}function Re(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)Re(o,t);else r&&typeof r=="object"&&Re(r,t)}}}function ut(e){let t=[],n=[],r=new Map,o=new Set,{shadowed:s}=dt(e);return Re(e,a=>{if(a.type!=="CallExpression")return;let i=a.callee;if(i?.type!=="Identifier")return;let l=i.name;if(!lt(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:i.start}));return}let c=P[l];t.push({start:i.start,end:i.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 ft(e,t){let n=[];for(let[r,o]of[...e.imports].sort(([s],[a])=>s.localeCompare(a))){let s=[...o].filter(a=>!t.has(a)).sort();s.length&&n.push(`import { ${s.join(", ")} } from ${JSON.stringify(r)};`)}return n.length?`${n.join(`
4
4
  `)}
5
5
  `:""}var Nn=new Set(J),vn=new Set(B),xn=new Set(O),Rn=new Set(["createMemo","createEffect","createRenderEffect","createRoot","createSignal","onCleanup","batch","untrack"]);function pe(e,t,n=null,r=""){if(!(!e||typeof e!="object")){if(Array.isArray(e)){for(let o of e)pe(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"||pe(e[o],t,typeof e.type=="string"?e:n,o)}}var ke=e=>e.type==="JSXElement"||e.type==="JSXFragment";function kn(e,t,n){return ke(e)?!(t&&ke(t)&&n==="children"):!1}function bn(e,t){return e.type==="TaggedTemplateExpression"&&e.tag?.type==="Identifier"&&(e.tag.name===t||e.tag.name==="svg")}function ht(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 ce(e,t,n,r){let o=ht(r.filter(a=>a.start>=t&&a.end<=n)).sort((a,i)=>i.start-a.start),s=e.slice(t,n);for(let a of o)s=s.slice(0,a.start-t)+a.code+s.slice(a.end-t);return s}function Sn(e,t,n){let r={code:ce(e,t.start,t.end,n),reactive:A(w(t))};return t.type==="ArrowFunctionExpression"&&t.body?.type!=="BlockStatement"&&(r.arrow={params:t.params.map(o=>ce(e,o.start,o.end,n)),body:ce(e,t.body.start,t.body.end,n),bodyReactive:A(w(t.body))}),t.type==="ObjectExpression"&&(r.object=!0),r}function yt(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}`,a=n.get(s);a||(a=`_fxTmpl$${n.size}`,n.set(s,a)),r.set(o.id,a)}return e.replace(/_tmpl\$\d+/g,o=>r.get(o)??o)}function be(e,t){if(e.kind==="component"&&e.load&&!e.source&&j(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):j(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)be(n,t)}function In(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 En(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 wn(e,t,n){let r=!1;return pe(e,o=>{r||o.type!=="Identifier"||o.name!==t||o.start===n.local?.start&&o.end===n.local?.end||(r=!0)}),r}function Cn(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 $n(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 Nt(e,t,n={}){let r=n.litTag??"html",o=n.format??"both",s=o!=="jsx",a=o!=="lit",i=s&&(e.includes(`${r}\``)||e.includes("svg`")),l=n.intrinsics!==!1&&at(e);if(!i&&!(a&&e.includes("<"))&&!l)return null;let c=(0,mt.parse)(e,{sourceType:"module",plugins:["jsx","typescript"],errorRecovery:!0}),p=[];pe(c.program,(d,x,N)=>{(s&&bn(d,r)||a&&kn(d,x,N))&&p.push(d)});let f=n.propsDestructure===!1?{edits:[],diagnostics:[],used:new Set}:xe(c.program,e,{runtimeModule:n.runtimeModule}),u=n.intrinsics===!1?{edits:[],diagnostics:[],imports:new Map}:ut(c.program);if(p.length===0&&f.edits.length===0&&u.edits.length===0&&u.diagnostics.length===0&&f.diagnostics.length===0)return null;p.sort((d,x)=>x.start-d.start||d.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:pt(c.program)},v=new Map,S=[...f.edits,...u.edits];for(let d of p){let x=p.some(k=>k!==d&&k.start<=d.start&&k.end>=d.end&&k.end-k.start>d.end-d.start);if(ke(d)){S.push({start:d.start,end:d.end,code:Tn(e,d,S,x,m,h,v,n)});continue}let N=d.quasi.expressions.map(k=>Sn(e,k,S)),I=qe($n(d),N,{...n,hoistTemplates:!0,templateClone:n.templateClone??!0,partialTemplates:x?!1:n.partialTemplates??!0,svg:d.tag.name==="svg"});for(let k of I.imports)m.add(k);be(I.ir,h),S.push({start:d.start,end:d.end,code:yt(I.code,I.templates,v)})}let R=new gt.default(e);for(let d of ht(S))d.start===d.end?R.appendLeft(d.start,d.code):R.overwrite(d.start,d.end,d.code);let $=L(c.program),q=new Map;for(let[d]of h.ignoredLoad)$.has(d)||q.set(d,"unsupplied");for(let[d,x]of[...h.ignoredLoad]){if(!$.has(d))continue;let N=In(c.program,d);if(!N){q.set(d,En(c.program,d)?"namespace":"local");continue}if(wn(c.program,d,N.specifier)){q.set(d,"value");continue}let I=N.declaration.specifiers.filter(K=>K!==N.specifier),k=I.length===0&&e[N.declaration.end]===`
6
6
  `?N.declaration.end+1:N.declaration.end;R.overwrite(N.declaration.start,k,I.length===0?"":`import { ${I.map(K=>e.slice(K.start,K.end)).join(", ")} } from ${JSON.stringify(N.declaration.source.value)};`),h.deferred.set(d,{module:N.module,export:N.export,origin:"rule",loading:x}),$.delete(d),h.ignoredLoad.delete(d)}let Se=Pn(m,h,v,$,n);Se&&R.prepend(Se);let Ie=ft(u,$);Ie&&R.prepend(Ie);for(let d of c.program.body)d.type==="ImportDeclaration"&&d.source?.value==="@fluixi/core/rx"&&R.overwrite(d.source.start,d.source.end,JSON.stringify("@fluixi/reactive"));let vt={value:d=>`${d} 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:d=>`${d} came in through a namespace import, which has no single export to defer. Import ${d} by name.`,local:d=>`${d} is declared in this file, so there is no module to load separately. Move it to its own file and import it.`,unsupplied:d=>`nothing supplies ${d}, so there is no import to defer. Import it, or add a \`resolve\` rule for it.`},Ee=[...h.ignoredLoad].map(([d,x])=>({name:d,strategy:x,message:`load:${x.kind} has no effect on <${d}>: ${vt[q.get(d)??"unsupplied"](d)}`})),we=[...h.unresolved].map(d=>({name:d,message:`<${d}> 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 ${d}, or add a \`resolve\` rule for it.`}));return{code:R.toString(),map:R.generateMap({source:t,includeContent:!0,hires:!0}),...Ee.length?{loadDiagnostics:Ee}:{},...we.length?{unresolvedDiagnostics:we}:{},...f.diagnostics.length?{propsDiagnostics:f.diagnostics}:{},...u.diagnostics.length?{intrinsicDiagnostics:u.diagnostics}:{}}}function Tn(e,t,n,r,o,s,a,i){let l=Qe(t,{code:f=>ce(e,f.start,f.end,n),used:o});M(l);let c=Q(l,{resolver:se(i.resolve??[]),isBound:f=>s.declared.has(f),modules:{controlFlowModule:i.controlFlowModule??i.runtimeModule??"@fluixi/dom",coreModule:i.coreModule??"@fluixi/core",routerModule:i.routerModule??"@fluixi/core/router-next"},strategyFor:f=>f.load});for(let f of c.unresolved)s.unresolved.add(f);te(l);let p=D.emit(l,{templateClone:i.templateClone??!0,partialTemplates:r?!1:i.partialTemplates??!0});for(let f of p.imports)o.add(f);return be(l,s),yt(p.code,p.templates,a)}function Pn(e,t,n,r,o){let s=o.runtimeModule??"@fluixi/dom",a=o.coreModule??"@fluixi/core",i=new Map,l=(u,g)=>i.set(u,[...i.get(u)??[],g]),c=new Set(e);for(let u of t.builtins)c.add(u);t.delegatedEvents.size>0&&c.add("delegateEvents");for(let u of[...c].sort())r.has(u)||(Rn.has(u)?l(o.reactiveModule??"@fluixi/reactive/signal",u):xn.has(u)?l(o.routerModule??"@fluixi/core/router-next",u):vn.has(u)?l(a,u):Nn.has(u)?l(o.controlFlowModule??s,u):l(s,u));for(let[u,g]of t.resolved)r.has(u)||l(g.module,g.export==="default"?`default as ${u}`:u===g.export?u:`${g.export} as ${u}`);let p=[];for(let[u,g]of i)p.push(`import { ${g.join(", ")} } from ${JSON.stringify(u)};`);let f=[...t.deferred].filter(([u])=>!r.has(u));if(f.length>0){r.has("deferred")||p.push(`import { deferred } from ${JSON.stringify(a)};`);for(let[u,g]of f)p.push(`const ${u} = deferred(() => import(${JSON.stringify(g.module)}), { strategy: ${Cn(g.loading)}, export: ${JSON.stringify(g.export)} });`)}for(let[u,g]of n)p.push(`const ${g} = ${JSON.stringify(u.startsWith("svg:")?u.slice(4):u)};`);return t.delegatedEvents.size>0&&p.push(`delegateEvents(${JSON.stringify([...t.delegatedEvents])});`),p.length>0?p.join(`
@@ -9,7 +9,7 @@ import{parse as $n}from"@babel/parser";var St=44,kt=59,De="ABCDEFGHIJKLMNOPQRSTU
9
9
  `));else for(a=l.start;a<c;){if(!i[a]){let u=this.original[a];u===`
10
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 P.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),P.insertLeft=!0),this.appendLeft(e,t)}insertRight(e,t){return P.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),P.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&&(P.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),P.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 te(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(B);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(B),e!==-1)return r.outro.substr(e+1)+t;t=r.outro+t}if(r.content.length>0){if(e=r.content.lastIndexOf(B),e!==-1)return r.content.substr(e+1)+t;t=r.content+t}if(r.intro.length>0){if(e=r.intro.lastIndexOf(B),e!==-1)return r.intro.substr(e+1)+t;t=r.intro+t}}while(r=r.previous);return e=this.intro.lastIndexOf(B),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 M(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 ne={kind:"eager"},jt=["pointerdown","focusin","keydown"],Fe=new Set(["eager","idle","visible","interaction","media","never"]),E=class extends Error{};function ge(n){return n.startsWith("load:")}function re(n,e){let t=n.slice(5);if(!Fe.has(t))throw new E(`Unknown load strategy 'load:${t}'. Expected one of ${[...Fe].join(", ")}.`);switch(t){case"eager":return ne;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 F=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],U=["Suspense","SuspenseList","Await"],D=["Router","Outlet","Redirect","Link"],Yn=[...F,...U,...D],ye=new Set([...F,...U]);function Ue(n={}){let{controlFlowModule:e="@fluixi/dom",coreModule:t="@fluixi/core",routerModule:r="@fluixi/core/router-next"}=n,i={};for(let s of F)i[s]=e;for(let s of U)i[s]=t;for(let s of D)i[s]=r;return i}function ie(n,e={}){let{resolver:t,isBound:r,modules:i,strategyFor:s}=e,o=Ue(i),a=new Map,l=new Set,c=p=>{let{name:f}=p;if(!f||f.includes(".")||r?.(f))return;let m=u(f);if(!m){l.add(f);return}let h=m.origin==="builtin"&&ye.has(f)?ne:s?.(p)??ne;p.source={...m,loading:h},a.set(f,p.source)},u=p=>{if(ye.has(p))return{module:o[p],export:p,origin:"builtin"};let f=t?.resolve(p);if(f)return{module:f.module,export:f.export,origin:"rule"};if(D.includes(p))return{module:o[p],export:p,origin:"builtin"}};return se(n,p=>{p.kind==="component"&&c(p)}),{resolved:a,unresolved:[...l]}}function se(n,e){let t=Array.isArray(n)?n:[n];for(let r of t){e(r);let i=r.children;i&&se(i,e)}}function oe(n){let e=[];se(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 Bt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),He={className:"class",htmlFor:"for"},Jt=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),Ft=new Set(["script","style","textarea","title"]);function ve(n){return Ft.has(n)}function qe(n){return He[n]??n}function H(n){return n.kind!=="attr"||n.expr!==void 0||n.name.includes(":")?!1:!Jt.has(n.name)}function xe(n){if(!n.static||ve(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"&&xe(e)))return!1;return!0}function q(n){let e=n.props.map(Ht).filter(Boolean).join(""),t=`<${n.tag}${e}>`;return Bt.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 q(n)}function Ht(n){let e=He[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 le(n){return n.kind==="expr"||n.kind==="component"||n.kind==="control"}function Wt(n){return n.kind==="text"||n.kind==="element"&&Xe(n)}function Xe(n){return n.svg||ve(n.tag)||!n.props.every(e=>H(e))?!1:n.children.every(e=>Wt(e)||le(e))}function ae(n){if(le(n))return!0;let e=n.children;return e?e.some(ae):!1}function ze(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"||ze(e))}function Ve(n){if(!Xe(n)||!ze(n)||!n.children.some(ae))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,p)=>{ae(u)&&(l=p)});let c=null;for(let u=0;u<=l;u++){let p=o.children[u],f=c?`${c}.nextSibling`:`${a}.firstChild`;if(le(p)){let h=i(f),g=i(`holeEnd(${h})`);t.push({parentRef:a,startRef:h,endRef:g,node:p}),c=g;continue}let m=i(f);p.kind==="element"&&ae(p)&&s(p,m),c=m}}}function Kt(n){return q(We(n)).split(Ke).join(zt+Vt)}function We(n){return{...n,children:n.children.map(e=>le(e)?{kind:"text",value:Ke}:e.kind==="element"?We(e):e)}}var Ke="\0fx-hole\0";var Ne={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},lr={version:2,module:"@fluixi/dom",symbols:[...Ne.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 Ye(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=>`${Ye(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 Ze(n,e,t){return n.length===1?X(n[0],e,t):`[${n.map(r=>X(r,e,t)).join(", ")}]`}function Ge(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 ${Ye(c.name)}() { return ${Qt(c)}; }`);t.length>0&&a.push(`get children() { return ${Ze(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=qe(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 Qe=!1;function X(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":Ze(n.children,e,t);case"component":return Ge(n.name,n.props,n.children,e,t);case"control":{let r=Gt[n.control]??n.control;return e.add(r),Ge(r,n.props,n.children,e,t)}case"element":{if(t&&n.static&&!n.svg&&xe(n)){e.add("templateNode");let a=`_tmpl$${t.length}`;return t.push({id:a,html:q(n),tag:n.tag,svg:!1}),`templateNode(${a}, ${JSON.stringify(n.tag)})`}if(t&&Qe){let a=Ve(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}, () => (${X(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=X(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 ce(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 A={name:"imperative",contract:Ne,emit(n,e){let t=new Set,r=e?.templateClone!==!1?[]:void 0;return Qe=e?.partialTemplates===!0,{code:X(n,t,r),imports:Array.from(t),templates:r}}};var nn=n=>"components"in n;function et(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 ue(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 p=t.find(f=>f.name===a);p?p.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:et(l.module,c),export:l.export?et(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 z(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 tt=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 nt(n){return n.charAt(0).toUpperCase()+n.slice(1)}var be=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}=A.emit(e,{});for(let s of r)this.used.add(s);return ce(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&&z(e.value)===""}lowerNode(e){switch(e.kind){case"Text":{if(e.raw)return{kind:"text",value:e.value};let t=z(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},p={name:l,kind:"attr",expr:this.emit(u),jsxElement:!0},f=r.findIndex(m=>m.name===l);f>=0?r[f]=p:r.push(p)}let o=e.attributes.find(l=>l.kind==="LoadDirective"),a=o?re(`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"+nt(e.name),kind:"event",event:{name:t,delegated:tt.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"+nt(i),kind:"event",event:{name:i,delegated:tt.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 rt(n,e,t,r={}){let{root:i}=sn(n,{svg:r.svg});return new be(e,t).lowerRoot(i.children)}function it(n,e,t={}){let r=new Set,i=rt(n,[...e],r,{svg:t.svg});M(i),ie(i,{resolver:ue(t.resolve??[]),modules:{controlFlowModule:t.controlFlowModule??"@fluixi/dom",coreModule:t.coreModule??"@fluixi/core",routerModule:t.routerModule??"@fluixi/core/router-next"},strategyFor:l=>l.load}),oe(i);let{code:s,imports:o,templates:a}=A.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:ce(s,a),imports:[...r],ir:i}}var an="children";function j(n){switch(n.kind){case"call":return!0;case"member":return n.property!==an;case"compound":return n.parts.some(j);case"opaque":return!1}}var ln=new Set(["CallExpression","OptionalCallExpression"]),cn=new Set(["MemberExpression","OptionalMemberExpression"]);function $(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(V)}:n.type==="LogicalExpression"||n.type==="BinaryExpression"?{kind:"compound",parts:[n.left,n.right].map(V)}:n.type==="TemplateLiteral"?{kind:"compound",parts:n.expressions.map(V)}:n.type==="ObjectExpression"?{kind:"compound",parts:n.properties.filter(t=>(t.type==="ObjectProperty"||t.type==="Property")&&t.computed!==!0).map(t=>V(t.value))}:n.type==="ArrayExpression"?{kind:"compound",parts:n.elements.filter(t=>t!=null&&t.type!=="SpreadElement").map(V)}:{kind:"opaque"}}var V=n=>$(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"]),at=n=>j($(n));function W(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 we=n=>!!n&&typeof W(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 Re(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=Re(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(we(a))return o.literal=W(a),o;if(a.type==="JSXExpressionContainer"&&a.expression?.type!=="JSXEmptyExpression"){let l=a.expression,c=W(l);return c!==void 0?(o.literal=c,o):(o.expr=e.code(l),o.reactive=i?!1:at(l),(l.type==="JSXElement"||l.type==="JSXFragment")&&(o.jsxElement=!0),o)}return o.literal=!0,o}function st(n,e){let t=n.value;return t==null?null:we(t)?JSON.stringify(W(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"||ge(Re(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=st(i,e);r.push(a!=null?`[${o}, () => (${a})]`:`[${o}]`);continue}if(s==="oncapture"){let o=i.name.name.name.toLowerCase(),a=st(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 ot(n,e){let t=[];for(let r of n)if(r.type==="JSXText"){let i=z(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:at(i)})}}else r.type==="JSXElement"||r.type==="JSXFragment"?t.push(lt(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=Re(e.name);if(ge(t)){if(e.value&&!we(e.value))throw new E(`'${t}' needs a literal value, not an expression — the strategy is compile-time.`);return re(t,e.value?W(e.value):null)}}}function lt(n,e){if(n.type==="JSXFragment")return{kind:"fragment",children:ot(n.children,e)};let{tag:t,component:r}=fn(n.openingElement.name,e),i=mn(n.openingElement.attributes,e),s=ot(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 ct(n,e){let t=lt(n,e);return M(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 ut(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&&ut(n.declaration,e);return}}function K(n){let e=new Set;for(let t of n.body)ut(t,e);return e}import{parse as xn}from"@babel/parser";function R(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"?R(t.argument,e):R(t.value,e);return;case"ArrayPattern":for(let t of n.elements)R(t,e);return;case"AssignmentPattern":R(n.left,e);return;case"RestElement":R(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 de(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"&&de(i,e);else r&&typeof r=="object"&&typeof r.type=="string"&&de(r,e)}}}function yn(n){let e=new Set;return de(n,t=>{if(t.type==="AssignmentExpression")R(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;R(i,s);for(let o of s)e.has(o)&&t.add(o)};return de(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 dt(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 p=new Set;R(u,p);for(let f of p)t.bails.push({name:f,reason:"rest"});continue}t.rest={name:u.name,keys:[]};continue}if(r.computed){let u=new Set;R(r.value,u);for(let p of u)t.bails.push({name:p,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;R(o,u);for(let p of u)t.bails.push({name:p,reason:"unsafe-default"});continue}dt(o,l,t);continue}let c=new Set;R(o,c);for(let u of c)t.bails.push({name:u,reason:"computed"})}}function ke(n,e){let t={reads:[],bails:[]};if(n?.type!=="ObjectPattern"||(dt(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 Ee(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 G(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)G(s,e,n);else i&&typeof i=="object"&&G(i,e,n)}}function pt(n){return!!n&&n[0]>="A"&&n[0]<="Z"}function Nn(n){let e=[];return G(n,t=>{if(t.type==="FunctionDeclaration"&&pt(t.id?.name)){e.push(t);return}if(t.type==="VariableDeclarator"&&pt(t.id?.name)){let r=t.init;r&&(r.type==="ArrowFunctionExpression"||r.type==="FunctionExpression")&&e.push(r)}}),e}function bn(n){let e=new Set;return G(n,t=>{t.type==="Identifier"&&e.add(t.name)}),e}function wn(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 Ce(n,e,t={}){let r=[],i=[],s=new Set;for(let o of Nn(n)){let a=o.params?.[0];if(a?.type!=="ObjectPattern")continue;let l=ke(a,o.body);for(let h of l.bails)i.push({name:h.name,reason:h.reason,message:Ee(h.reason),start:a.start});if(l.bails.length>0||l.reads.length===0&&!l.rest)continue;let c=bn(o),u=t.parameterName??"props";for(;c.has(u);)u=`_${u}`;let p=new Map;for(let h of l.reads){let g=`${u}.${h.path.join(".")}`,x=h.fallback;p.set(h.name,x?`(${g} === undefined ? ${e.slice(x.start,x.end)} : ${g})`:g)}let f=a.typeAnnotation;if(r.push({start:a.start,end:f?.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
11
  const [, ${l.rest.name}] = splitProps(${u}, [${h}]);`}),s.add("splitProps")}let m=[];G(o.body,(h,g)=>{if(h.type!=="Identifier")return;let x=p.get(h.name);if(!x)return;let S=g?.type==="ObjectProperty"&&g.shorthand&&g.value===h;if(!S&&!wn(h,g))return;let b=l.reads.find(I=>I.name===h.name).path;m.push({node:h,parent:S?g:null,text:x,property:b[b.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}),Rn(h.node,u,h.property)}return{edits:r,diagnostics:i,used:s}}function Rn(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}function Sn(n,e="module.tsx",t={}){let r=xn(n,{sourceType:"module",plugins:["typescript","jsx"],errorRecovery:!0}),{edits:i,diagnostics:s,used:o}=Ce(r.program,n,t),a=new L(n);for(let l of i)l.start===l.end?a.appendLeft(l.start,l.code):a.overwrite(l.start,l.end,l.code);return o.has("splitProps")&&!K(r.program).has("splitProps")&&a.prepend(`import { splitProps } from ${JSON.stringify(t.runtimeModule??"@fluixi/dom")};
12
- `),{code:a.toString(),map:a.generateMap({source:e,includeContent:!0,hires:!0}),diagnostics:s,rewritten:i.filter(l=>l.code!==(t.parameterName??"props")).length}}var T="@fluixi/reactive/signal",O={$signal:{export:"signal",module:T,returns:"signal-handle"},$memo:{export:"memo",module:T,returns:"memo-handle"},$effect:{export:"effect",module:T,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:T,returns:"resource-handle"},$selector:{export:"createSelector",module:T,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:T,returns:"memo-accessor"},$untrack:{export:"untrack",module:T,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"},kn=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/signal-next","@fluixi/reactive/store","@fluixi/core","@fluixi/core/rx"],En=new RegExp(`\\$(?:${Object.keys(O).map(n=>n.slice(1)).join("|")})\\s*\\(`);function ht(n){return En.test(n)}function mt(n){return Object.prototype.hasOwnProperty.call(O,n)}function gt(n){return kn.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 Y(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)Y(i,e);else r&&typeof r=="object"&&Y(r,e)}}}function Cn(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=O[r];if(s&&!e.shadowed.has(r))return s.returns}function In(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 Y(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;Y(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)O[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 Y(t,r=>{if(r.type!=="VariableDeclarator"||!r.init)return;let i=Cn(r.init,e);i&&In(r.id,i,e.kinds)}),e}function Ie(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)Ie(i,e);else r&&typeof r=="object"&&Ie(r,e)}}}function xt(n){let e=[],t=[],r=new Map,i=new Set,{shadowed:s}=vt(n);return Ie(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=O[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
+ `),{code:a.toString(),map:a.generateMap({source:e,includeContent:!0,hires:!0}),diagnostics:s,rewritten:i.filter(l=>l.code!==(t.parameterName??"props")).length}}var T="@fluixi/reactive/signal",O={$signal:{export:"signal",module:T,returns:"signal-handle"},$memo:{export:"memo",module:T,returns:"memo-handle"},$effect:{export:"effect",module:T,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:T,returns:"resource-handle"},$selector:{export:"createSelector",module:T,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:T,returns:"memo-accessor"},$untrack:{export:"untrack",module:T,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"},kn=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/store","@fluixi/core","@fluixi/core/rx"],En=new RegExp(`\\$(?:${Object.keys(O).map(n=>n.slice(1)).join("|")})\\s*\\(`);function ht(n){return En.test(n)}function mt(n){return Object.prototype.hasOwnProperty.call(O,n)}function gt(n){return kn.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 Y(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)Y(i,e);else r&&typeof r=="object"&&Y(r,e)}}}function Cn(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=O[r];if(s&&!e.shadowed.has(r))return s.returns}function In(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 Y(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;Y(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)O[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 Y(t,r=>{if(r.type!=="VariableDeclarator"||!r.init)return;let i=Cn(r.init,e);i&&In(r.id,i,e.kinds)}),e}function Ie(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)Ie(i,e);else r&&typeof r=="object"&&Ie(r,e)}}}function xt(n){let e=[],t=[],r=new Map,i=new Set,{shadowed:s}=vt(n);return Ie(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=O[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(`
13
13
  `)}
14
14
  `:""}var Tn=new Set(F),On=new Set(U),Pn=new Set(D),Ln=new Set(["createMemo","createEffect","createRenderEffect","createRoot","createSignal","onCleanup","batch","untrack"]);function fe(n,e,t=null,r=""){if(!(!n||typeof n!="object")){if(Array.isArray(n)){for(let i of n)fe(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"||fe(n[i],e,typeof n.type=="string"?n:t,i)}}var $e=n=>n.type==="JSXElement"||n.type==="JSXFragment";function Mn(n,e,t){return $e(n)?!(e&&$e(e)&&t==="children"):!1}function Dn(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 pe(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 An(n,e,t){let r={code:pe(n,e.start,e.end,t),reactive:j($(e))};return e.type==="ArrowFunctionExpression"&&e.body?.type!=="BlockStatement"&&(r.arrow={params:e.params.map(i=>pe(n,i.start,i.end,t)),body:pe(n,e.body.start,e.body.end,t),bodyReactive:j($(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 Te(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)Te(t,e)}function jn(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 _n(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 Bn(n,e,t){let r=!1;return fe(n,i=>{r||i.type!=="Identifier"||i.name!==e||i.start===t.local?.start&&i.end===t.local?.end||(r=!0)}),r}function Jn(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 Fn(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 Un(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=$n(n,{sourceType:"module",plugins:["jsx","typescript"],errorRecovery:!0}),u=[];fe(c.program,(d,N,v)=>{(s&&Dn(d,r)||o&&Mn(d,N,v))&&u.push(d)});let p=t.propsDestructure===!1?{edits:[],diagnostics:[],used:new Set}:Ce(c.program,n,{runtimeModule:t.runtimeModule}),f=t.intrinsics===!1?{edits:[],diagnostics:[],imports:new Map}:xt(c.program);if(u.length===0&&p.edits.length===0&&f.edits.length===0&&f.diagnostics.length===0&&p.diagnostics.length===0)return null;u.sort((d,N)=>N.start-d.start||d.end-N.end);let h=new Set(p.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=[...p.edits,...f.edits];for(let d of u){let N=u.some(w=>w!==d&&w.start<=d.start&&w.end>=d.end&&w.end-w.start>d.end-d.start);if($e(d)){S.push({start:d.start,end:d.end,code:Hn(n,d,S,N,h,g,x,t)});continue}let v=d.quasi.expressions.map(w=>An(n,w,S)),k=it(Fn(d),v,{...t,hoistTemplates:!0,templateClone:t.templateClone??!0,partialTemplates:N?!1:t.partialTemplates??!0,svg:d.tag.name==="svg"});for(let w of k.imports)h.add(w);Te(k.ir,g),S.push({start:d.start,end:d.end,code:wt(k.code,k.templates,x)})}let b=new L(n);for(let d of bt(S))d.start===d.end?b.appendLeft(d.start,d.code):b.overwrite(d.start,d.end,d.code);let I=K(c.program),Z=new Map;for(let[d]of g.ignoredLoad)I.has(d)||Z.set(d,"unsupplied");for(let[d,N]of[...g.ignoredLoad]){if(!I.has(d))continue;let v=jn(c.program,d);if(!v){Z.set(d,_n(c.program,d)?"namespace":"local");continue}if(Bn(c.program,d,v.specifier)){Z.set(d,"value");continue}let k=v.declaration.specifiers.filter(Q=>Q!==v.specifier),w=k.length===0&&n[v.declaration.end]===`
15
15
  `?v.declaration.end+1:v.declaration.end;b.overwrite(v.declaration.start,w,k.length===0?"":`import { ${k.map(Q=>n.slice(Q.start,Q.end)).join(", ")} } from ${JSON.stringify(v.declaration.source.value)};`),g.deferred.set(d,{module:v.module,export:v.export,origin:"rule",loading:N}),I.delete(d),g.ignoredLoad.delete(d)}let Oe=qn(h,g,x,I,t);Oe&&b.prepend(Oe);let Pe=Nt(f,I);Pe&&b.prepend(Pe);for(let d of c.program.body)d.type==="ImportDeclaration"&&d.source?.value==="@fluixi/core/rx"&&b.overwrite(d.source.start,d.source.end,JSON.stringify("@fluixi/reactive"));let Rt={value:d=>`${d} 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:d=>`${d} came in through a namespace import, which has no single export to defer. Import ${d} by name.`,local:d=>`${d} is declared in this file, so there is no module to load separately. Move it to its own file and import it.`,unsupplied:d=>`nothing supplies ${d}, so there is no import to defer. Import it, or add a \`resolve\` rule for it.`},Le=[...g.ignoredLoad].map(([d,N])=>({name:d,strategy:N,message:`load:${N.kind} has no effect on <${d}>: ${Rt[Z.get(d)??"unsupplied"](d)}`})),Me=[...g.unresolved].map(d=>({name:d,message:`<${d}> 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 ${d}, or add a \`resolve\` rule for it.`}));return{code:b.toString(),map:b.generateMap({source:e,includeContent:!0,hires:!0}),...Le.length?{loadDiagnostics:Le}:{},...Me.length?{unresolvedDiagnostics:Me}:{},...p.diagnostics.length?{propsDiagnostics:p.diagnostics}:{},...f.diagnostics.length?{intrinsicDiagnostics:f.diagnostics}:{}}}function Hn(n,e,t,r,i,s,o,a){let l=ct(e,{code:p=>pe(n,p.start,p.end,t),used:i});M(l);let c=ie(l,{resolver:ue(a.resolve??[]),isBound:p=>s.declared.has(p),modules:{controlFlowModule:a.controlFlowModule??a.runtimeModule??"@fluixi/dom",coreModule:a.coreModule??"@fluixi/core",routerModule:a.routerModule??"@fluixi/core/router-next"},strategyFor:p=>p.load});for(let p of c.unresolved)s.unresolved.add(p);oe(l);let u=A.emit(l,{templateClone:a.templateClone??!0,partialTemplates:r?!1:a.partialTemplates??!0});for(let p of u.imports)i.add(p);return Te(l,s),wt(u.code,u.templates,o)}function qn(n,e,t,r,i){let s=i.runtimeModule??"@fluixi/dom",o=i.coreModule??"@fluixi/core",a=new Map,l=(f,m)=>a.set(f,[...a.get(f)??[],m]),c=new Set(n);for(let f of e.builtins)c.add(f);e.delegatedEvents.size>0&&c.add("delegateEvents");for(let f of[...c].sort())r.has(f)||(Ln.has(f)?l(i.reactiveModule??"@fluixi/reactive/signal",f):Pn.has(f)?l(i.routerModule??"@fluixi/core/router-next",f):On.has(f)?l(o,f):Tn.has(f)?l(i.controlFlowModule??s,f):l(s,f));for(let[f,m]of e.resolved)r.has(f)||l(m.module,m.export==="default"?`default as ${f}`:f===m.export?f:`${m.export} as ${f}`);let u=[];for(let[f,m]of a)u.push(`import { ${m.join(", ")} } from ${JSON.stringify(f)};`);let p=[...e.deferred].filter(([f])=>!r.has(f));if(p.length>0){r.has("deferred")||u.push(`import { deferred } from ${JSON.stringify(o)};`);for(let[f,m]of p)u.push(`const ${f} = deferred(() => import(${JSON.stringify(m.module)}), { strategy: ${Jn(m.loading)}, export: ${JSON.stringify(m.export)} });`)}for(let[f,m]of t)u.push(`const ${m} = ${JSON.stringify(f.startsWith("svg:")?f.slice(4):f)};`);return e.delegatedEvents.size>0&&u.push(`delegateEvents(${JSON.stringify([...e.delegatedEvents])});`),u.length>0?u.join(`
@@ -1,3 +1,3 @@
1
- "use strict";var m=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var w=(t,r)=>{for(var n in r)m(t,n,{get:r[n],enumerable:!0})},b=(t,r,n,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of h(r))!S.call(t,i)&&i!==n&&m(t,i,{get:()=>r[i],enumerable:!(e=R(r,i))||e.enumerable});return t};var E=t=>b(m({},"__esModule",{value:!0}),t);var $={};w($,{collectIntrinsicEdits:()=>M,intrinsicImports:()=>j});module.exports=E($);var f="@fluixi/reactive/signal",d={$signal:{export:"signal",module:f,returns:"signal-handle"},$memo:{export:"memo",module:f,returns:"memo-handle"},$effect:{export:"effect",module:f,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:f,returns:"resource-handle"},$selector:{export:"createSelector",module:f,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:f,returns:"memo-accessor"},$untrack:{export:"untrack",module:f,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}},I={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"},k=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/signal-next","@fluixi/reactive/store","@fluixi/core","@fluixi/core/rx"],P=new RegExp(`\\$(?:${Object.keys(d).map(t=>t.slice(1)).join("|")})\\s*\\(`);function N(t){return Object.prototype.hasOwnProperty.call(d,t)}function x(t){return k.includes(t)}function o(t,r){if(t)switch(t.type){case"Identifier":r.add(t.name);return;case"ObjectPattern":for(let n of t.properties??[])n.type==="RestElement"?o(n.argument,r):o(n.value,r);return;case"ArrayPattern":for(let n of t.elements??[])o(n,r);return;case"AssignmentPattern":o(t.left,r);return;case"RestElement":o(t.argument,r);return}}function p(t,r){if(!(!t||typeof t!="object"||typeof t.type!="string")){r(t);for(let n of Object.keys(t)){if(n==="loc"||n==="leadingComments"||n==="trailingComments")continue;let e=t[n];if(Array.isArray(e))for(let i of e)p(i,r);else e&&typeof e=="object"&&p(e,r)}}}function C(t,r){if(t.type!=="CallExpression")return;let n=t.callee;if(n?.type!=="Identifier")return;let e=n.name,i=r.primitives.get(e);if(i)return i;let s=d[e];if(s&&!r.shadowed.has(e))return s.returns}function D(t,r,n){if(Array.isArray(r)){t.type==="ArrayPattern"&&t.elements.forEach((e,i)=>{let s=r[i];e?.type==="Identifier"&&s&&n.set(e.name,s)});return}t.type==="Identifier"&&n.set(t.name,r)}function v(t){let r={kinds:new Map,primitives:new Map,shadowed:new Set},n=t;p(n,e=>{let i=new Set;if(e.type==="VariableDeclarator")o(e.id,i);else if(e.type==="FunctionDeclaration"||e.type==="ClassDeclaration")o(e.id,i);else if(e.type==="ImportDefaultSpecifier"||e.type==="ImportNamespaceSpecifier")o(e.local,i);else if(e.type==="ImportSpecifier")o(e.local,i);else if(e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"||e.type==="FunctionDeclaration")for(let s of e.params??[])o(s,i);for(let s of i)d[s]&&r.shadowed.add(s)});for(let e of n.body??[])if(e.type==="ImportDeclaration"&&x(e.source?.value))for(let i of e.specifiers??[]){if(i.type!=="ImportSpecifier")continue;let s=i.imported,a=s.type==="Identifier"?s.name:s.value,c=I[a];c&&r.primitives.set(i.local.name,c)}return p(n,e=>{if(e.type!=="VariableDeclarator"||!e.init)return;let i=C(e.init,r);i&&D(e.id,i,r.kinds)}),r}function g(t,r){if(!(!t||typeof t!="object"||typeof t.type!="string")){r(t);for(let n of Object.keys(t)){if(n==="loc"||n==="leadingComments"||n==="trailingComments")continue;let e=t[n];if(Array.isArray(e))for(let i of e)g(i,r);else e&&typeof e=="object"&&g(e,r)}}}function M(t){let r=[],n=[],e=new Map,i=new Set,{shadowed:s}=v(t);return g(t,a=>{if(a.type!=="CallExpression")return;let c=a.callee;if(c?.type!=="Identifier")return;let l=c.name;if(!N(l))return;if(s.has(l)){i.has(l)||(i.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:c.start}));return}let u=d[l];r.push({start:c.start,end:c.end,code:u.export});let y=e.get(u.module)??new Set;y.add(u.export),e.set(u.module,y)}),{edits:r,diagnostics:n,imports:e}}function j(t,r){let n=[];for(let[e,i]of[...t.imports].sort(([s],[a])=>s.localeCompare(a))){let s=[...i].filter(a=>!r.has(a)).sort();s.length&&n.push(`import { ${s.join(", ")} } from ${JSON.stringify(e)};`)}return n.length?`${n.join(`
1
+ "use strict";var m=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var w=(t,r)=>{for(var n in r)m(t,n,{get:r[n],enumerable:!0})},b=(t,r,n,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of h(r))!S.call(t,i)&&i!==n&&m(t,i,{get:()=>r[i],enumerable:!(e=R(r,i))||e.enumerable});return t};var E=t=>b(m({},"__esModule",{value:!0}),t);var $={};w($,{collectIntrinsicEdits:()=>M,intrinsicImports:()=>j});module.exports=E($);var f="@fluixi/reactive/signal",d={$signal:{export:"signal",module:f,returns:"signal-handle"},$memo:{export:"memo",module:f,returns:"memo-handle"},$effect:{export:"effect",module:f,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:f,returns:"resource-handle"},$selector:{export:"createSelector",module:f,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:f,returns:"memo-accessor"},$untrack:{export:"untrack",module:f,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}},I={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"},k=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/store","@fluixi/core","@fluixi/core/rx"],P=new RegExp(`\\$(?:${Object.keys(d).map(t=>t.slice(1)).join("|")})\\s*\\(`);function N(t){return Object.prototype.hasOwnProperty.call(d,t)}function x(t){return k.includes(t)}function o(t,r){if(t)switch(t.type){case"Identifier":r.add(t.name);return;case"ObjectPattern":for(let n of t.properties??[])n.type==="RestElement"?o(n.argument,r):o(n.value,r);return;case"ArrayPattern":for(let n of t.elements??[])o(n,r);return;case"AssignmentPattern":o(t.left,r);return;case"RestElement":o(t.argument,r);return}}function p(t,r){if(!(!t||typeof t!="object"||typeof t.type!="string")){r(t);for(let n of Object.keys(t)){if(n==="loc"||n==="leadingComments"||n==="trailingComments")continue;let e=t[n];if(Array.isArray(e))for(let i of e)p(i,r);else e&&typeof e=="object"&&p(e,r)}}}function C(t,r){if(t.type!=="CallExpression")return;let n=t.callee;if(n?.type!=="Identifier")return;let e=n.name,i=r.primitives.get(e);if(i)return i;let s=d[e];if(s&&!r.shadowed.has(e))return s.returns}function D(t,r,n){if(Array.isArray(r)){t.type==="ArrayPattern"&&t.elements.forEach((e,i)=>{let s=r[i];e?.type==="Identifier"&&s&&n.set(e.name,s)});return}t.type==="Identifier"&&n.set(t.name,r)}function v(t){let r={kinds:new Map,primitives:new Map,shadowed:new Set},n=t;p(n,e=>{let i=new Set;if(e.type==="VariableDeclarator")o(e.id,i);else if(e.type==="FunctionDeclaration"||e.type==="ClassDeclaration")o(e.id,i);else if(e.type==="ImportDefaultSpecifier"||e.type==="ImportNamespaceSpecifier")o(e.local,i);else if(e.type==="ImportSpecifier")o(e.local,i);else if(e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"||e.type==="FunctionDeclaration")for(let s of e.params??[])o(s,i);for(let s of i)d[s]&&r.shadowed.add(s)});for(let e of n.body??[])if(e.type==="ImportDeclaration"&&x(e.source?.value))for(let i of e.specifiers??[]){if(i.type!=="ImportSpecifier")continue;let s=i.imported,a=s.type==="Identifier"?s.name:s.value,c=I[a];c&&r.primitives.set(i.local.name,c)}return p(n,e=>{if(e.type!=="VariableDeclarator"||!e.init)return;let i=C(e.init,r);i&&D(e.id,i,r.kinds)}),r}function g(t,r){if(!(!t||typeof t!="object"||typeof t.type!="string")){r(t);for(let n of Object.keys(t)){if(n==="loc"||n==="leadingComments"||n==="trailingComments")continue;let e=t[n];if(Array.isArray(e))for(let i of e)g(i,r);else e&&typeof e=="object"&&g(e,r)}}}function M(t){let r=[],n=[],e=new Map,i=new Set,{shadowed:s}=v(t);return g(t,a=>{if(a.type!=="CallExpression")return;let c=a.callee;if(c?.type!=="Identifier")return;let l=c.name;if(!N(l))return;if(s.has(l)){i.has(l)||(i.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:c.start}));return}let u=d[l];r.push({start:c.start,end:c.end,code:u.export});let y=e.get(u.module)??new Set;y.add(u.export),e.set(u.module,y)}),{edits:r,diagnostics:n,imports:e}}function j(t,r){let n=[];for(let[e,i]of[...t.imports].sort(([s],[a])=>s.localeCompare(a))){let s=[...i].filter(a=>!r.has(a)).sort();s.length&&n.push(`import { ${s.join(", ")} } from ${JSON.stringify(e)};`)}return n.length?`${n.join(`
2
2
  `)}
3
3
  `:""}
@@ -1,3 +1,3 @@
1
- var f="@fluixi/reactive/signal",d={$signal:{export:"signal",module:f,returns:"signal-handle"},$memo:{export:"memo",module:f,returns:"memo-handle"},$effect:{export:"effect",module:f,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:f,returns:"resource-handle"},$selector:{export:"createSelector",module:f,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:f,returns:"memo-accessor"},$untrack:{export:"untrack",module:f,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}},y={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"},v=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/signal-next","@fluixi/reactive/store","@fluixi/core","@fluixi/core/rx"],S=new RegExp(`\\$(?:${Object.keys(d).map(t=>t.slice(1)).join("|")})\\s*\\(`);function I(t){return Object.prototype.hasOwnProperty.call(d,t)}function N(t){return v.includes(t)}function o(t,r){if(t)switch(t.type){case"Identifier":r.add(t.name);return;case"ObjectPattern":for(let n of t.properties??[])n.type==="RestElement"?o(n.argument,r):o(n.value,r);return;case"ArrayPattern":for(let n of t.elements??[])o(n,r);return;case"AssignmentPattern":o(t.left,r);return;case"RestElement":o(t.argument,r);return}}function p(t,r){if(!(!t||typeof t!="object"||typeof t.type!="string")){r(t);for(let n of Object.keys(t)){if(n==="loc"||n==="leadingComments"||n==="trailingComments")continue;let e=t[n];if(Array.isArray(e))for(let i of e)p(i,r);else e&&typeof e=="object"&&p(e,r)}}}function R(t,r){if(t.type!=="CallExpression")return;let n=t.callee;if(n?.type!=="Identifier")return;let e=n.name,i=r.primitives.get(e);if(i)return i;let s=d[e];if(s&&!r.shadowed.has(e))return s.returns}function h(t,r,n){if(Array.isArray(r)){t.type==="ArrayPattern"&&t.elements.forEach((e,i)=>{let s=r[i];e?.type==="Identifier"&&s&&n.set(e.name,s)});return}t.type==="Identifier"&&n.set(t.name,r)}function x(t){let r={kinds:new Map,primitives:new Map,shadowed:new Set},n=t;p(n,e=>{let i=new Set;if(e.type==="VariableDeclarator")o(e.id,i);else if(e.type==="FunctionDeclaration"||e.type==="ClassDeclaration")o(e.id,i);else if(e.type==="ImportDefaultSpecifier"||e.type==="ImportNamespaceSpecifier")o(e.local,i);else if(e.type==="ImportSpecifier")o(e.local,i);else if(e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"||e.type==="FunctionDeclaration")for(let s of e.params??[])o(s,i);for(let s of i)d[s]&&r.shadowed.add(s)});for(let e of n.body??[])if(e.type==="ImportDeclaration"&&N(e.source?.value))for(let i of e.specifiers??[]){if(i.type!=="ImportSpecifier")continue;let s=i.imported,a=s.type==="Identifier"?s.name:s.value,c=y[a];c&&r.primitives.set(i.local.name,c)}return p(n,e=>{if(e.type!=="VariableDeclarator"||!e.init)return;let i=R(e.init,r);i&&h(e.id,i,r.kinds)}),r}function m(t,r){if(!(!t||typeof t!="object"||typeof t.type!="string")){r(t);for(let n of Object.keys(t)){if(n==="loc"||n==="leadingComments"||n==="trailingComments")continue;let e=t[n];if(Array.isArray(e))for(let i of e)m(i,r);else e&&typeof e=="object"&&m(e,r)}}}function D(t){let r=[],n=[],e=new Map,i=new Set,{shadowed:s}=x(t);return m(t,a=>{if(a.type!=="CallExpression")return;let c=a.callee;if(c?.type!=="Identifier")return;let l=c.name;if(!I(l))return;if(s.has(l)){i.has(l)||(i.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:c.start}));return}let u=d[l];r.push({start:c.start,end:c.end,code:u.export});let g=e.get(u.module)??new Set;g.add(u.export),e.set(u.module,g)}),{edits:r,diagnostics:n,imports:e}}function M(t,r){let n=[];for(let[e,i]of[...t.imports].sort(([s],[a])=>s.localeCompare(a))){let s=[...i].filter(a=>!r.has(a)).sort();s.length&&n.push(`import { ${s.join(", ")} } from ${JSON.stringify(e)};`)}return n.length?`${n.join(`
1
+ var f="@fluixi/reactive/signal",d={$signal:{export:"signal",module:f,returns:"signal-handle"},$memo:{export:"memo",module:f,returns:"memo-handle"},$effect:{export:"effect",module:f,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:f,returns:"resource-handle"},$selector:{export:"createSelector",module:f,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:f,returns:"memo-accessor"},$untrack:{export:"untrack",module:f,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}},y={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"},v=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/store","@fluixi/core","@fluixi/core/rx"],S=new RegExp(`\\$(?:${Object.keys(d).map(t=>t.slice(1)).join("|")})\\s*\\(`);function I(t){return Object.prototype.hasOwnProperty.call(d,t)}function N(t){return v.includes(t)}function o(t,r){if(t)switch(t.type){case"Identifier":r.add(t.name);return;case"ObjectPattern":for(let n of t.properties??[])n.type==="RestElement"?o(n.argument,r):o(n.value,r);return;case"ArrayPattern":for(let n of t.elements??[])o(n,r);return;case"AssignmentPattern":o(t.left,r);return;case"RestElement":o(t.argument,r);return}}function p(t,r){if(!(!t||typeof t!="object"||typeof t.type!="string")){r(t);for(let n of Object.keys(t)){if(n==="loc"||n==="leadingComments"||n==="trailingComments")continue;let e=t[n];if(Array.isArray(e))for(let i of e)p(i,r);else e&&typeof e=="object"&&p(e,r)}}}function R(t,r){if(t.type!=="CallExpression")return;let n=t.callee;if(n?.type!=="Identifier")return;let e=n.name,i=r.primitives.get(e);if(i)return i;let s=d[e];if(s&&!r.shadowed.has(e))return s.returns}function h(t,r,n){if(Array.isArray(r)){t.type==="ArrayPattern"&&t.elements.forEach((e,i)=>{let s=r[i];e?.type==="Identifier"&&s&&n.set(e.name,s)});return}t.type==="Identifier"&&n.set(t.name,r)}function x(t){let r={kinds:new Map,primitives:new Map,shadowed:new Set},n=t;p(n,e=>{let i=new Set;if(e.type==="VariableDeclarator")o(e.id,i);else if(e.type==="FunctionDeclaration"||e.type==="ClassDeclaration")o(e.id,i);else if(e.type==="ImportDefaultSpecifier"||e.type==="ImportNamespaceSpecifier")o(e.local,i);else if(e.type==="ImportSpecifier")o(e.local,i);else if(e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"||e.type==="FunctionDeclaration")for(let s of e.params??[])o(s,i);for(let s of i)d[s]&&r.shadowed.add(s)});for(let e of n.body??[])if(e.type==="ImportDeclaration"&&N(e.source?.value))for(let i of e.specifiers??[]){if(i.type!=="ImportSpecifier")continue;let s=i.imported,a=s.type==="Identifier"?s.name:s.value,c=y[a];c&&r.primitives.set(i.local.name,c)}return p(n,e=>{if(e.type!=="VariableDeclarator"||!e.init)return;let i=R(e.init,r);i&&h(e.id,i,r.kinds)}),r}function m(t,r){if(!(!t||typeof t!="object"||typeof t.type!="string")){r(t);for(let n of Object.keys(t)){if(n==="loc"||n==="leadingComments"||n==="trailingComments")continue;let e=t[n];if(Array.isArray(e))for(let i of e)m(i,r);else e&&typeof e=="object"&&m(e,r)}}}function D(t){let r=[],n=[],e=new Map,i=new Set,{shadowed:s}=x(t);return m(t,a=>{if(a.type!=="CallExpression")return;let c=a.callee;if(c?.type!=="Identifier")return;let l=c.name;if(!I(l))return;if(s.has(l)){i.has(l)||(i.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:c.start}));return}let u=d[l];r.push({start:c.start,end:c.end,code:u.export});let g=e.get(u.module)??new Set;g.add(u.export),e.set(u.module,g)}),{edits:r,diagnostics:n,imports:e}}function M(t,r){let n=[];for(let[e,i]of[...t.imports].sort(([s],[a])=>s.localeCompare(a))){let s=[...i].filter(a=>!r.has(a)).sort();s.length&&n.push(`import { ${s.join(", ")} } from ${JSON.stringify(e)};`)}return n.length?`${n.join(`
2
2
  `)}
3
3
  `:""}export{D as collectIntrinsicEdits,M as intrinsicImports};