@memoized-dom/compiler 0.0.1 → 0.0.3

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 +1 @@
1
- {"version":3,"file":"analysis.d.ts","sourceRoot":"","sources":["../src/analysis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EASL,KAAK,GAAG,EACT,MAAM,WAAW,CAAC;AAsCnB,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAonC3D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,CA6C5E"}
1
+ {"version":3,"file":"analysis.d.ts","sourceRoot":"","sources":["../src/analysis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAWL,KAAK,GAAG,EACT,MAAM,WAAW,CAAC;AAyCnB,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAgxC3D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,CA6C5E"}
@@ -147,6 +147,22 @@ export interface FnSummary {
147
147
  /** True when effects cannot be bounded to known roots or arguments. */
148
148
  unbounded: boolean;
149
149
  }
150
+ /** One owner-local list dependency addressable directly by its row key. */
151
+ export interface TargetedListDependency {
152
+ /** Instance-owned collection root whose writes require reconciliation. */
153
+ source: string;
154
+ /** Instance-state value compared directly with the authored row key. */
155
+ value: string;
156
+ }
157
+ /** Conservative direct-item mutation plan for one instance-owned keyed list. */
158
+ export interface KeyedListMutationPlan {
159
+ source: string;
160
+ keyPath: string[];
161
+ keysVariable: string;
162
+ targetedReason: string;
163
+ structuralReason: string;
164
+ call: t.CallExpression;
165
+ }
150
166
  /** One compiler-owned reactive side effect declared in a component body. */
151
167
  export interface EffectSite {
152
168
  /** Stable source-order suffix within the owning component. */
@@ -252,6 +268,16 @@ export interface Ctx {
252
268
  suffix: string;
253
269
  vars: Set<string>;
254
270
  }>;
271
+ /** Map call → owner-local values whose changes affect only old/new keyed rows. */
272
+ targetedListDependencies: WeakMap<t.CallExpression, TargetedListDependency[]>;
273
+ /** Components that need dirty reasons for targeted list refreshes. */
274
+ targetedListComponents: Set<string>;
275
+ /** Map call -> direct keyed-item mutation journal used by that one list. */
276
+ keyedListMutations: WeakMap<t.CallExpression, KeyedListMutationPlan>;
277
+ /** Component -> source root -> journal plan, for handler write analysis. */
278
+ keyedListMutationSources: Map<string, Map<string, KeyedListMutationPlan>>;
279
+ /** Sources used by multiple list sites deliberately keep full reconciliation. */
280
+ disabledKeyedListMutationSources: Set<string>;
255
281
  /**
256
282
  * R12: instance state — component name → top-level let/var names of its
257
283
  * body. Instance state lives in the factory closure of ONE instance: it
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/context/model.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,MAAM,WAAW,cAAc;IAC7B,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC7C,8EAA8E;IAC9E,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAChD,sEAAsE;IACtE,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAC9D,2EAA2E;IAC3E,0BAA0B,CAAC,EAAE,MAAM,CACjC,MAAM,EACN,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAC1C,CAAC;IACF,yEAAyE;IACzE,0BAA0B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAC;IACZ,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,yEAAyE;IACzE,mBAAmB,CAAC,EAAE,+BAA+B,EAAE,CAAC;CACzD;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,8DAA8D;IAC9D,mBAAmB,CAAC,EAAE,+BAA+B,EAAE,CAAC;IACxD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,oCAAoC;IACpC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,8DAA8D;IAC9D,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,0EAA0E;IAC1E,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,+DAA+D;IAC/D,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,WAAW,CAAC;IAClB,wDAAwD;IACxD,GAAG,EAAE,MAAM,CAAC;IACZ,yEAAyE;IACzE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,4EAA4E;IAC5E,mBAAmB,EAAE,OAAO,CAAC;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,yEAAyE;IACzE,eAAe,EAAE,OAAO,CAAC;IACzB,wEAAwE;IACxE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,+DAA+D;IAC/D,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,+BACf,SAAQ,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC;IAC3C,8DAA8D;IAC9D,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACzB,2EAA2E;IAC3E,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,yBAAyB;IACxC,4DAA4D;IAC5D,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,0EAA0E;IAC1E,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,MAAM,YAAY,GACpB,iBAAiB,GACjB,oBAAoB,GACpB,qBAAqB,CAAC;AAE1B,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;AAE/D,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,sFAAsF;AACtF,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,4EAA4E;AAC5E,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB,oCAAoC;IACpC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpB,0DAA0D;IAC1D,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,0EAA0E;IAC1E,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,uEAAuE;IACvE,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,4EAA4E;AAC5E,MAAM,WAAW,UAAU;IACzB,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC;IACvB,+DAA+D;IAC/D,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC;IACvB,uEAAuE;IACvE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,uEAAuE;IACvE,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACxB,uDAAuD;IACvD,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,yDAAyD;IACzD,SAAS,EAAE,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC;IAC/B,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACjC,6BAA6B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5C;AAED,uEAAuE;AACvE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC;IACvB,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC;IACvB,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,SAAS,EAAE,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC;IAC/B,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,eAAe,CAAC;IAC7C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,UAAU,GAAG,QAAQ,CAC/B,CAAC,CAAC,mBAAmB,GAAG,CAAC,CAAC,uBAAuB,GAAG,CAAC,CAAC,kBAAkB,CACzE,CAAC;AAEF,MAAM,WAAW,GAAG;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IAGjB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC9B,kDAAkD;IAClD,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,wEAAwE;IACxE,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1C,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAChD,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACnD,gCAAgC,EAAE,GAAG,CACnC,MAAM,EACN,+BAA+B,EAAE,CAClC,CAAC;IACF,iFAAiF;IACjF,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,+EAA+E;IAC/E,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC1C,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACvD,+DAA+D;IAC/D,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5C,oEAAoE;IACpE,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAC1D,0BAA0B,EAAE,GAAG,CAC7B,MAAM,EACN,GAAG,CAAC,MAAM,EAAE,yBAAyB,CAAC,CACvC,CAAC;IACF,0BAA0B,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAClD,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC7B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACxD,yFAAyF;IACzF,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACjC,mEAAmE;IACnE,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACpC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACxC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACpC,kEAAkE;IAClE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD;;;;OAIG;IACH,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B;;;;OAIG;IACH,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IACpC,2EAA2E;IAC3E,wBAAwB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,wEAAwE;IACxE,yBAAyB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAClD,kEAAkE;IAClE,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAC1C,mFAAmF;IACnF,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAChD,+FAA+F;IAC/F,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,oFAAoF;IACpF,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;IAC5E,iGAAiG;IACjG,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;IAC7E;;;;;;;;OAQG;IACH,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACxC,8EAA8E;IAC9E,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;IACpD,sEAAsE;IACtE,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAC1D,6EAA6E;IAC7E,uBAAuB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAClD,yDAAyD;IACzD,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,kEAAkE;IAClE,6BAA6B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,sEAAsE;IACtE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IACnC,uDAAuD;IACvD,aAAa,EAAE,gBAAgB,EAAE,CAAC;IAClC;;;;;;;;OAQG;IACH,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;IAC/C,2DAA2D;IAC3D,iBAAiB,EAAE,2BAA2B,EAAE,CAAC;IAGjD,MAAM,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;IACtB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAClC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,6EAA6E;IAC7E,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oDAAoD;IACpD,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,+EAA+E;IAC/E,iBAAiB,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACnC,0EAA0E;IAC1E,oBAAoB,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/C,2EAA2E;IAC3E,WAAW,EAAE,oBAAoB,GAAG,IAAI,CAAC;CAC1C;AAED,wBAAgB,SAAS,CAAC,IAAI,GAAE,cAAmB,GAAG,GAAG,CA8JxD"}
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/context/model.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,MAAM,WAAW,cAAc;IAC7B,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC7C,8EAA8E;IAC9E,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAChD,sEAAsE;IACtE,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAC9D,2EAA2E;IAC3E,0BAA0B,CAAC,EAAE,MAAM,CACjC,MAAM,EACN,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAC1C,CAAC;IACF,yEAAyE;IACzE,0BAA0B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAC;IACZ,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,yEAAyE;IACzE,mBAAmB,CAAC,EAAE,+BAA+B,EAAE,CAAC;CACzD;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,8DAA8D;IAC9D,mBAAmB,CAAC,EAAE,+BAA+B,EAAE,CAAC;IACxD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,oCAAoC;IACpC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,8DAA8D;IAC9D,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,0EAA0E;IAC1E,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,+DAA+D;IAC/D,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,WAAW,CAAC;IAClB,wDAAwD;IACxD,GAAG,EAAE,MAAM,CAAC;IACZ,yEAAyE;IACzE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,4EAA4E;IAC5E,mBAAmB,EAAE,OAAO,CAAC;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,yEAAyE;IACzE,eAAe,EAAE,OAAO,CAAC;IACzB,wEAAwE;IACxE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,+DAA+D;IAC/D,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,+BACf,SAAQ,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC;IAC3C,8DAA8D;IAC9D,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACzB,2EAA2E;IAC3E,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,yBAAyB;IACxC,4DAA4D;IAC5D,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,0EAA0E;IAC1E,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,MAAM,YAAY,GACpB,iBAAiB,GACjB,oBAAoB,GACpB,qBAAqB,CAAC;AAE1B,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;AAE/D,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,sFAAsF;AACtF,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,4EAA4E;AAC5E,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB,oCAAoC;IACpC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpB,0DAA0D;IAC1D,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,0EAA0E;IAC1E,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,uEAAuE;IACvE,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,2EAA2E;AAC3E,MAAM,WAAW,sBAAsB;IACrC,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,CAAC,CAAC,cAAc,CAAC;CACxB;AAED,4EAA4E;AAC5E,MAAM,WAAW,UAAU;IACzB,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC;IACvB,+DAA+D;IAC/D,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC;IACvB,uEAAuE;IACvE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,uEAAuE;IACvE,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACxB,uDAAuD;IACvD,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,yDAAyD;IACzD,SAAS,EAAE,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC;IAC/B,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACjC,6BAA6B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5C;AAED,uEAAuE;AACvE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC;IACvB,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC;IACvB,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,SAAS,EAAE,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC;IAC/B,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,eAAe,CAAC;IAC7C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,UAAU,GAAG,QAAQ,CAC/B,CAAC,CAAC,mBAAmB,GAAG,CAAC,CAAC,uBAAuB,GAAG,CAAC,CAAC,kBAAkB,CACzE,CAAC;AAEF,MAAM,WAAW,GAAG;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IAGjB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC9B,kDAAkD;IAClD,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,wEAAwE;IACxE,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1C,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAChD,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACnD,gCAAgC,EAAE,GAAG,CACnC,MAAM,EACN,+BAA+B,EAAE,CAClC,CAAC;IACF,iFAAiF;IACjF,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,+EAA+E;IAC/E,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC1C,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACvD,+DAA+D;IAC/D,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5C,oEAAoE;IACpE,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAC1D,0BAA0B,EAAE,GAAG,CAC7B,MAAM,EACN,GAAG,CAAC,MAAM,EAAE,yBAAyB,CAAC,CACvC,CAAC;IACF,0BAA0B,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAClD,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC7B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACxD,yFAAyF;IACzF,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACjC,mEAAmE;IACnE,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACpC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACxC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACpC,kEAAkE;IAClE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD;;;;OAIG;IACH,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B;;;;OAIG;IACH,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IACpC,2EAA2E;IAC3E,wBAAwB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,wEAAwE;IACxE,yBAAyB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAClD,kEAAkE;IAClE,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAC1C,mFAAmF;IACnF,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAChD,+FAA+F;IAC/F,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,oFAAoF;IACpF,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;IAC5E,iGAAiG;IACjG,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;IAC7E,kFAAkF;IAClF,wBAAwB,EAAE,OAAO,CAAC,CAAC,CAAC,cAAc,EAAE,sBAAsB,EAAE,CAAC,CAAC;IAC9E,sEAAsE;IACtE,sBAAsB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,4EAA4E;IAC5E,kBAAkB,EAAE,OAAO,CAAC,CAAC,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAC;IACrE,4EAA4E;IAC5E,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAC1E,iFAAiF;IACjF,gCAAgC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9C;;;;;;;;OAQG;IACH,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACxC,8EAA8E;IAC9E,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;IACpD,sEAAsE;IACtE,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAC1D,6EAA6E;IAC7E,uBAAuB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAClD,yDAAyD;IACzD,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,kEAAkE;IAClE,6BAA6B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,sEAAsE;IACtE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IACnC,uDAAuD;IACvD,aAAa,EAAE,gBAAgB,EAAE,CAAC;IAClC;;;;;;;;OAQG;IACH,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;IAC/C,2DAA2D;IAC3D,iBAAiB,EAAE,2BAA2B,EAAE,CAAC;IAGjD,MAAM,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;IACtB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAClC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,6EAA6E;IAC7E,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oDAAoD;IACpD,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,+EAA+E;IAC/E,iBAAiB,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACnC,0EAA0E;IAC1E,oBAAoB,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/C,2EAA2E;IAC3E,WAAW,EAAE,oBAAoB,GAAG,IAAI,CAAC;CAC1C;AAED,wBAAgB,SAAS,CAAC,IAAI,GAAE,cAAmB,GAAG,GAAG,CAmKxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/emission/component.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,OAAO,EAEL,KAAK,GAAG,EAET,MAAM,YAAY,CAAC;AAgCpB,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,EACrC,IAAI,EAAE,MAAM,GACX,IAAI,CA2RN"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/emission/component.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,OAAO,EAEL,KAAK,GAAG,EAET,MAAM,YAAY,CAAC;AAgCpB,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,EACrC,IAAI,EAAE,MAAM,GACX,IAAI,CAgSN"}
@@ -5,7 +5,7 @@
5
5
  * once, retained as a detached pristine node, and deep-cloned per row. Dynamic
6
6
  * setters and event/ref/lifecycle work remain in the row factory.
7
7
  */
8
- import type { Ctx } from '../context';
8
+ import { type Ctx } from '../context';
9
9
  import type { EmitScope } from './scope';
10
10
  export declare function applyRepeatedDomTemplate(ctx: Ctx, scope: EmitScope, rootVar: string): boolean;
11
11
  //# sourceMappingURL=dom-template.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dom-template.d.ts","sourceRoot":"","sources":["../../src/emission/dom-template.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAkBzC,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CA2GT"}
1
+ {"version":3,"file":"dom-template.d.ts","sourceRoot":"","sources":["../../src/emission/dom-template.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAa,KAAK,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAkBzC,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAoIT"}
@@ -1 +1 @@
1
- {"version":3,"file":"list-region.d.ts","sourceRoot":"","sources":["../../src/emission/list-region.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAIL,KAAK,GAAG,EACR,KAAK,MAAM,EACZ,MAAM,YAAY,CAAC;AAQpB,OAAO,EAGL,KAAK,QAAQ,EACd,MAAM,wBAAwB,CAAC;AAahC,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAKlD,MAAM,MAAM,2BAA2B,GAAG,CACxC,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,SAAS,EACrB,QAAQ,EAAE,SAAS,QAAQ,EAAE,EAC7B,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,EAC9C,QAAQ,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,EAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,aAAa,EAAE,CAAC,CAAC,UAAU,GAAG,SAAS,EACvC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,CAAC,CAAC,UAAU,KAClB,CAAC,CAAC,UAAU,CAAC;AAElB,oDAAoD;AACpD,wBAAgB,cAAc,CAC5B,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,CAAC,CAAC,cAAc,EACtB,qBAAqB,EAAE,MAAM,EAC7B,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,EAC9C,QAAQ,EAAE,WAAW,EACrB,yBAAyB,EAAE,2BAA2B,EACtD,KAAK,UAAQ,EACb,OAAO,GAAE,CAAC,CAAC,UAA4C,EACvD,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI,CAiHN"}
1
+ {"version":3,"file":"list-region.d.ts","sourceRoot":"","sources":["../../src/emission/list-region.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAIL,KAAK,GAAG,EACR,KAAK,MAAM,EACZ,MAAM,YAAY,CAAC;AAQpB,OAAO,EAGL,KAAK,QAAQ,EACd,MAAM,wBAAwB,CAAC;AAahC,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAYlD,MAAM,MAAM,2BAA2B,GAAG,CACxC,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,SAAS,EACrB,QAAQ,EAAE,SAAS,QAAQ,EAAE,EAC7B,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,EAC9C,QAAQ,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,EAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,aAAa,EAAE,CAAC,CAAC,UAAU,GAAG,SAAS,EACvC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,CAAC,CAAC,UAAU,KAClB,CAAC,CAAC,UAAU,CAAC;AAElB,oDAAoD;AACpD,wBAAgB,cAAc,CAC5B,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,CAAC,CAAC,cAAc,EACtB,qBAAqB,EAAE,MAAM,EAC7B,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,EAC9C,QAAQ,EAAE,WAAW,EACrB,yBAAyB,EAAE,2BAA2B,EACtD,KAAK,UAAQ,EACb,OAAO,GAAE,CAAC,CAAC,UAA4C,EACvD,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI,CAgKN"}
@@ -1 +1 @@
1
- {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../src/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAIL,KAAK,GAAG,EACR,KAAK,MAAM,EACZ,MAAM,WAAW,CAAC;AAMnB,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,kBAAkB,CAAC;AAc1B,OAAO,EAGL,KAAK,OAAO,EACb,MAAM,gBAAgB,CAAC;AAkIxB,wBAAgB,QAAQ,CACtB,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,EACzC,QAAQ,GAAE,KAAK,GAAG,MAAM,GAAG,IAAW,EACtC,MAAM,CAAC,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,CAAC,CAAC,UAAU,EAC5B,KAAK,UAAQ,EACb,OAAO,GAAE,CAAC,CAAC,UAAuC,GACjD,MAAM,CA0BR;AAm9BD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,EACzC,QAAQ,EAAE,CAAC,CAAC,UAAU,EACtB,KAAK,UAAQ,EACb,OAAO,GAAE,CAAC,CAAC,UAAqB,EAChC,eAAe,UAAQ,EACvB,SAAS,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAC5B,CAAC,CAAC,uBAAuB,CAa3B"}
1
+ {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../src/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAIL,KAAK,GAAG,EACR,KAAK,MAAM,EACZ,MAAM,WAAW,CAAC;AAMnB,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,kBAAkB,CAAC;AAc1B,OAAO,EAGL,KAAK,OAAO,EACb,MAAM,gBAAgB,CAAC;AAkIxB,wBAAgB,QAAQ,CACtB,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,EACzC,QAAQ,GAAE,KAAK,GAAG,MAAM,GAAG,IAAW,EACtC,MAAM,CAAC,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,CAAC,CAAC,UAAU,EAC5B,KAAK,UAAQ,EACb,OAAO,GAAE,CAAC,CAAC,UAAuC,GACjD,MAAM,CA0BR;AA29BD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,EACzC,QAAQ,EAAE,CAAC,CAAC,UAAU,EACtB,KAAK,UAAQ,EACb,OAAO,GAAE,CAAC,CAAC,UAAqB,EAChC,eAAe,UAAQ,EACvB,SAAS,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAC5B,CAAC,CAAC,uBAAuB,CAa3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../src/handlers/analyze.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAIL,KAAK,GAAG,EACR,KAAK,MAAM,EACZ,MAAM,YAAY,CAAC;AAsEpB,wBAAgB,cAAc,CAC5B,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,CAAC,CAAC,uBAAuB,GAAG,CAAC,CAAC,kBAAkB,GAAG,CAAC,CAAC,mBAAmB,EAChF,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,CAAC,EAAE,MAAM,EACf,aAAa,UAAQ,EACrB,aAAa,CAAC,EAAE,CAAC,CAAC,UAAU,EAC5B,kBAAkB,UAAQ,GACzB,IAAI,CAmwBN"}
1
+ {"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../src/handlers/analyze.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAIL,KAAK,GAAG,EAER,KAAK,MAAM,EACZ,MAAM,YAAY,CAAC;AAuHpB,wBAAgB,cAAc,CAC5B,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,CAAC,CAAC,uBAAuB,GAAG,CAAC,CAAC,kBAAkB,GAAG,CAAC,CAAC,mBAAmB,EAChF,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,CAAC,EAAE,MAAM,EACf,aAAa,UAAQ,EACrB,aAAa,CAAC,EAAE,CAAC,CAAC,UAAU,EAC5B,kBAAkB,UAAQ,GACzB,IAAI,CAszBN"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{transformSync as ia}from"@babel/core";import sa from"@babel/plugin-syntax-jsx";import aa from"@babel/plugin-transform-typescript";import*as j from"@babel/types";import"@babel/types";function Yt(e={}){let t=e.moduleId??"./component.tsx",n=new Map,o=new Map,r=new Map,i=new Map,s=new Map,a=new Map,l=new Map,d=new Set,u=new Map,c=new Map;for(let[y,p]of Object.entries(e.linkedImports??{}))p.type==="state"?(n.set(y,p.kind),o.set(y,p.key),p.tagCandidates!==void 0&&r.set(y,[...p.tagCandidates]),p.componentCandidates!==void 0&&l.set(y,p.componentCandidates.map(f=>({...f}))),d.add(y)):p.type==="function"?(p.tagCandidates!==void 0&&i.set(y,[...p.tagCandidates]),p.componentCandidates!==void 0&&l.set(y,p.componentCandidates.map(f=>({...f}))),u.set(y,{reads:new Set(p.reads),writes:new Set(p.writes),boundedWrites:new Set(p.boundedWrites),parameterWrites:p.parameterWrites.map(f=>({index:f.index,path:[...f.path]})),unbounded:p.unbounded})):c.set(y,{...p,props:[...p.props]});let g=new Map;for(let[y,p]of c)g.set(y,{mode:p.objectProps?"object":"positional",names:[...p.props],acceptsUnknown:p.acceptsUnknownProps,bindings:[],params:[],hasWholeDefault:p.hasWholeDefault,renderProps:[...p.renderProps??[]],renderCallbacks:[...p.renderCallbacks??[]],refProps:[...p.refProps??[]]});let S=new Map(Object.entries(e.linkedComponentRenderProps??{}).map(([y,p])=>[y,[...p]]));return{runtimePath:e.runtimePath??"@memoized-dom/runtime",rootId:e.rootId??"App",moduleId:t,state:n,stateKeys:o,stateTagCandidates:r,functionTagCandidates:i,stateComponentCandidates:s,functionComponentCandidates:a,linkedDynamicComponentCandidates:l,importedState:d,importedFunctions:u,importedComponents:c,linkedComponentPaths:new Map(Object.entries(e.linkedComponentPaths??{}).map(([y,p])=>[y,[...p]])),linkedComponentRows:new Map(Object.entries(e.linkedComponentRows??{}).map(([y,p])=>[y,p.map(f=>({keyPath:f.keyPath===null?null:[...f.keyPath],sourceKey:f.sourceKey,sourceLocal:f.sourceLocal}))])),linkedComponentPropSources:new Map(Object.entries(e.linkedComponentPropSources??{}).map(([y,p])=>[y,new Map(Object.entries(p).map(([f,v])=>[f,{keys:[...v.keys],rootFallback:v.rootFallback}]))])),comps:new Map,compPaths:new Map,helpers:new Map,jsxHelpers:new Map,helperSummaries:new Map,compReads:new Map,childRefCounts:new Map,renderSlotOwners:new Set,listedSites:new Map,componentsWithHostEvents:new Set,conditionalComponentSites:new Map,rowComponentSites:new Map,componentProps:g,linkedComponentRenderProps:S,lightweightCache:new Map,rowReads:new Map,condReads:new Map,instanceState:new Map,instanceDerivations:new Map,instanceControlFlow:new Map,instanceDerivedBindings:new Map,instanceReasonIds:new Map,selectiveDerivationComponents:new Set,effects:new Map,moduleEffects:[],computeds:new Map,moduleControlFlow:[],header:[],readers:new Map,writeConstCounter:0,writeConsts:new Map,reasonConstCounter:0,reasonConsts:new Map,analyzedFunctions:new WeakSet,handlerHasRootCommit:new WeakMap,identifiers:null}}import*as q from"@babel/types";import*as nt from"@babel/types";var Fn=class{constructor(t,n){this.scope=t;xi(n.node,o=>this.reserved.add(o)),this.runtimeId=this.generate("MD").name}scope;runtimeId;reserved=new Set;componentIds=new Map;generate(t){let n;do n=this.scope.generateUidIdentifier(t);while(this.reserved.has(n.name));return this.reserved.add(n.name),n}registerComponentId(t,n){this.componentIds.set(t,n)}componentId(t){let n=this.componentIds.get(t);if(n===void 0)throw new Error(`memo-dom: missing generated factory id for '${t}'`);return nt.identifier(n)}runtimeMember(t){return nt.memberExpression(nt.identifier(this.runtimeId),nt.identifier(t))}};function Qt(e,t){let n=new Fn(t.scope,t);return e.identifiers=n,n}function $(e,t){return xt(e).generate(t)}function Le(e,t){return xt(e).componentId(t)}function Z(e,t){return xt(e).runtimeMember(t)}function xt(e){if(e.identifiers===null)throw new Error("memo-dom: generated identifier allocator was not initialized");return e.identifiers}function xi(e,t){let n=o=>{nt.isIdentifier(o)&&t(o.name);for(let r of nt.VISITOR_KEYS[o.type]??[]){let i=o[r];if(Array.isArray(i))for(let s of i)s&&typeof s=="object"&&"type"in s&&n(s);else i&&typeof i=="object"&&"type"in i&&n(i)}};n(e)}function pt(e,t,n){e.state.set(t,n),e.stateKeys.has(t)||e.stateKeys.set(t,`${e.moduleId}#${t}`)}function Ue(e,t){if(t.includes("#"))return t;let n=t.indexOf("."),o=n===-1?t:t.slice(0,n),r=n===-1?"":t.slice(n);return`${e.stateKeys.get(o)??o}${r}`}function Ot(e,t){let n=[...new Set(t.map(s=>Ue(e,s)))].sort(),o=n.join(" "),r=e.writeConsts.get(o);if(r!==void 0)return q.identifier(r);let i=$(e,`WRITES_${e.writeConstCounter++}`);return e.writeConsts.set(o,i.name),e.header.push(q.variableDeclaration("const",[q.variableDeclarator(i,q.arrayExpression(n.map(s=>q.stringLiteral(s))))])),i}function bo(e,t){let n=[...new Set(t)].sort((s,a)=>s-a),o=n.join(" "),r=e.reasonConsts.get(o);if(r!==void 0)return q.identifier(r);let i=$(e,`REASONS_${e.reasonConstCounter++}`);return e.reasonConsts.set(o,i.name),e.header.push(q.variableDeclaration("const",[q.variableDeclarator(i,q.arrayExpression(n.map(s=>q.numericLiteral(s))))])),i}function ye(e){let t=[],n=e;for(;q.isMemberExpression(n);){if(n.computed){if(!q.isStringLiteral(n.property))return null;t.unshift(n.property.value)}else{if(!q.isIdentifier(n.property))return null;t.unshift(n.property.name)}if(q.isSuper(n.object))return null;n=n.object}for(;q.isTSNonNullExpression(n)||q.isTSAsExpression(n);)n=n.expression;return q.isIdentifier(n)?(t.unshift(n.name),t.join(".")):null}function at(e,t){if(e===null)return[];let n=[],o=e;for(;q.isMemberExpression(o)&&!o.computed;){if(!q.isIdentifier(o.property)||(n.unshift(o.property.name),q.isSuper(o.object)))return null;o=o.object}return!q.isIdentifier(o,{name:t})||n.length===0?null:n}function Rn(e,t){return t===null?!0:t.length===0||e.length>t.length?!1:e.every((n,o)=>t[o]===n)}function Pe(e){let t=e;for(;;){if(q.isMemberExpression(t)){if(q.isSuper(t.object))return null;t=t.object;continue}if(q.isTSNonNullExpression(t)||q.isTSAsExpression(t)){t=t.expression;continue}break}return q.isIdentifier(t)?t.name:null}function Ct(e){return!e||!q.isObjectExpression(e)?!1:e.properties.every(t=>q.isObjectProperty(t)&&!t.computed&&(q.isIdentifier(t.key)||q.isStringLiteral(t.key)))}function Pt(e){return e?q.isArrayExpression(e)||q.isNewExpression(e):!1}function $e(e){return e==null?null:q.isStringLiteral(e)?e:q.isJSXExpressionContainer(e)?q.isJSXEmptyExpression(e.expression)?null:e.expression:null}function Dn(e,t,n){let o=n!==void 0?e.instanceState.get(n):void 0,r=n!==void 0?e.instanceDerivedBindings.get(n):void 0,i=n!==void 0?e.componentProps.get(n)?.bindings:void 0,s=!1,a=l=>{if(!s){if(q.isIdentifier(l)&&(e.state.has(l.name)||o?.has(l.name)===!0||r?.has(l.name)===!0||i?.includes(l.name)===!0)){s=!0;return}for(let d of q.VISITOR_KEYS[l.type]??[]){let u=l[d];if(Array.isArray(u))for(let c of u)c&&typeof c=="object"&&"type"in c&&a(c);else u&&typeof u=="object"&&"type"in u&&a(u)}}};return a(t),s}function ho(e,t,n){let o=new Set([...e.instanceState.get(n)??[],...e.instanceDerivedBindings.get(n)??[],...e.componentProps.get(n)?.bindings??[]]);if(o.size===0)return!1;let r=!1;return Xe(t,i=>q.isIdentifier(i)&&o.has(i.name)?(r=!0,!1):r?!1:void 0),r}function Xe(e,t){let n=(o,r)=>{if(t(o,r)!==!1)for(let i of q.VISITOR_KEYS[o.type]??[]){let s=o[i];if(Array.isArray(s))for(let a of s)a&&typeof a=="object"&&"type"in a&&n(a,o);else s&&typeof s=="object"&&"type"in s&&n(s,o)}};n(e,null)}function ue(e){let t=!1;return Xe(e,n=>{(q.isJSXElement(n)||q.isJSXFragment(n))&&(t=!0)}),t}function en(e,t){let n=new Set;return Xe(t,o=>{if(q.isJSXAttribute(o)&&q.isJSXIdentifier(o.name,{name:"ref"}))return!1;q.isIdentifier(o)&&e.state.has(o.name)&&n.add(o.name)}),n}import*as k from"@babel/types";import*as ce from"@babel/types";import*as Ke from"@babel/types";function tn(e){let t=Ke.cloneNode(e,!0);return Ke.traverseFast(t,n=>{(Ke.isIdentifier(n)||Ke.isObjectPattern(n)||Ke.isArrayPattern(n)||Ke.isRestElement(n)||Ke.isAssignmentPattern(n))&&(n.typeAnnotation=null)}),t}import*as xe from"@babel/types";import*as U from"@babel/types";function nn(e){if(e.some(i=>U.isTSParameterProperty(i)))throw new Error("TypeScript parameter properties are not valid component props");let t=e;if(t.length===0)return{mode:"positional",names:[],acceptsUnknown:!1,bindings:[],params:[],hasWholeDefault:!1,renderProps:[],renderCallbacks:[],refProps:[]};let n=ft(t[0]);if(t.length===1&&(U.isObjectPattern(n)||U.isIdentifier(n)&&n.name==="props"))return{mode:"object",names:U.isObjectPattern(n)?Ci(n):[],acceptsUnknown:U.isIdentifier(n)||n.properties.some(s=>U.isRestElement(s)),bindings:Tt(n),params:t.map(s=>U.cloneNode(s)),hasWholeDefault:U.isAssignmentPattern(t[0]),renderProps:[],renderCallbacks:[],refProps:[]};let r=[];for(let i of t){let s=ft(i);if(!U.isIdentifier(s))throw new Error("object-destructured props must be the component's only parameter");r.push(s.name)}return{mode:"positional",names:r,acceptsUnknown:!1,bindings:t.flatMap(i=>Tt(ft(i))),params:t.map(i=>U.cloneNode(i)),hasWholeDefault:!1,renderProps:[],renderCallbacks:[],refProps:[]}}function Eo(e,t){return e.params.length===0?null:U.variableDeclaration("let",e.params.map((n,o)=>U.variableDeclarator(Pi(ft(n)),xo(n,t[o]??U.identifier("undefined")))))}function Mn(e,t){return e.params.map((n,o)=>U.expressionStatement(U.assignmentExpression("=",Co(ft(n)),xo(n,t[o]??U.identifier("undefined")))))}function yo(e){return U.expressionStatement(U.assignmentExpression("=",Co(e.target),U.cloneNode(e.source)))}function Tt(e){return Object.keys(U.getBindingIdentifiers(e))}function Be(e){if(e.mode!=="object"||e.params.length!==1)return null;let t=ft(e.params[0]);return U.isIdentifier(t)?t.name:null}function on(e,t){if(e.mode==="positional")return e.names.includes(t)?t:null;if(e.params.length!==1)return null;let n=ft(e.params[0]);if(!U.isObjectPattern(n))return null;for(let o of n.properties){if(!U.isObjectProperty(o)||o.computed||(U.isIdentifier(o.key)?o.key.name:U.isStringLiteral(o.key)?o.key.value:null)!==t)continue;let i=U.isAssignmentPattern(o.value)?o.value.left:o.value;return U.isIdentifier(i)?i.name:null}return null}function He(e,t){if(e.mode==="positional")return e.names.includes(t)?t:null;if(e.params.length!==1)return null;let n=ft(e.params[0]);if(!U.isObjectPattern(n))return null;for(let o of n.properties)if(!(!U.isObjectProperty(o)||o.computed)&&Object.keys(U.getBindingIdentifiers(o.value)).includes(t)){if(U.isIdentifier(o.key))return o.key.name;if(U.isStringLiteral(o.key))return o.key.value}return null}function ft(e){if(U.isRestElement(e))throw new Error("rest component parameters are not supported");let t=U.isAssignmentPattern(e)?e.left:e;if(!U.isIdentifier(t)&&!U.isObjectPattern(t)&&!U.isArrayPattern(t))throw new Error("unsupported component parameter target");return t}function So(e){let t=U.cloneNode(e);return Bt(t),t}function xo(e,t){return U.isAssignmentPattern(e)?U.conditionalExpression(U.binaryExpression("===",U.cloneNode(t),U.identifier("undefined")),U.cloneNode(e.right),U.cloneNode(t)):U.cloneNode(t)}function Ci(e){let t=[];for(let n of e.properties)if(!U.isRestElement(n)){if(n.computed)throw new Error("computed keys are not supported in component prop patterns");if(U.isIdentifier(n.key))t.push(n.key.name);else if(U.isStringLiteral(n.key))t.push(n.key.value);else throw new Error("component prop pattern keys must be identifiers or strings")}return t}function Pi(e){let t=U.cloneNode(e);return Bt(t),t}function Co(e){let t=U.cloneNode(e);return Bt(t),t}function Bt(e){let t=e;"typeAnnotation"in t&&(t.typeAnnotation=null),"optional"in t&&(t.optional=null);for(let n of U.VISITOR_KEYS[e.type]??[]){let o=e[n];if(Array.isArray(o))for(let r of o)r&&typeof r=="object"&&"type"in r&&Bt(r);else o&&typeof o=="object"&&"type"in o&&Bt(o)}}function Po(e,t){let n=t.findParent(d=>d.isArrowFunctionExpression()||d.isFunctionExpression());if(n===null||!n.isArrowFunctionExpression()&&!n.isFunctionExpression())return!1;let o=n.get("body");if(!(o.isJSXElement()&&o.node===t.node||o.isBlockStatement()&&o.node.body.length===1&&xe.isReturnStatement(o.node.body[0])&&o.node.body[0].argument===t.node))return!1;let i=n.parentPath,s=i?.parentPath,a=s?.parentPath;if(!i?.isJSXExpressionContainer()||!s?.isJSXAttribute()||!a?.isJSXOpeningElement()||!xe.isJSXIdentifier(a.node.name))return!1;let l=xe.isJSXIdentifier(s.node.name)?s.node.name.name:s.node.name.name.name;return e.componentProps.get(a.node.name.name)?.renderCallbacks.includes(l)===!0||/^[A-Z]/.test(a.node.name.name)}function wi(e){return xe.isMemberExpression(e.callee)&&!e.callee.computed&&xe.isIdentifier(e.callee.property,{name:"map"})}function vi(e,t,n){let o=e.componentProps.get(t);if(o===void 0)return null;let r=Be(o);return r!==null&&xe.isMemberExpression(n)&&!n.computed&&xe.isIdentifier(n.object,{name:r})&&xe.isIdentifier(n.property)?n.property.name:xe.isIdentifier(n)?He(o,n.name)??(on(o,n.name)!==null?n.name:null):null}function ki(e){return xe.isExpression(e.body)?e.body:e.body.body.length===1&&xe.isReturnStatement(e.body.body[0])&&xe.isExpression(e.body.body[0].argument)?e.body.body[0].argument:null}function Ft(e,t,n){if(!wi(n)||n.arguments.length!==1)return null;let o=n.arguments[0];if(!xe.isArrowFunctionExpression(o))return null;let r=ki(o);if(r===null||!xe.isCallExpression(r)||!xe.isExpression(r.callee)||r.arguments.some(s=>!xe.isExpression(s)))return null;let i=vi(e,t,r.callee);return i===null?null:{propName:i,target:xe.cloneNode(r.callee,!0),arguments:r.arguments.map(s=>xe.cloneNode(s,!0))}}function wo(e){for(let[t,n]of e.compPaths){let o=e.componentProps.get(t);n.traverse({CallExpression(r){let i=Ft(e,t,r.node);i!==null&&!o.renderCallbacks.includes(i.propName)&&o.renderCallbacks.push(i.propName)}})}}import*as ke from"@babel/types";function Ln(e){for(;ke.isTSAsExpression(e)||ke.isTSTypeAssertion(e)||ke.isTSNonNullExpression(e)||ke.isTSInstantiationExpression(e);)e=e.expression;return e}function rn(e){let t=Ln(e);return ke.isArrayExpression(t)&&t.elements.every(n=>n!==null&&!ke.isSpreadElement(n)&&(ke.isStringLiteral(n)||ke.isNumericLiteral(n)||ke.isBooleanLiteral(n)||ke.isNullLiteral(n)||ke.isBigIntLiteral(n)))}function Oe(e){if(!ce.isCallExpression(e))return null;let t=e.callee;return ce.isMemberExpression(t)&&!t.computed&&ce.isIdentifier(t.property,{name:"map"})?e:null}function De(e){let t=!1;return e.traverse({JSXElement(){t=!0},JSXFragment(){t=!0}}),t}function wt(e,t,n,o,r,i){let s=g=>{throw n.buildCodeFrameError(g)},a=t.callee,l=Ni(e,a.object,o,i,s),d=Ri(e,t,o,s),u=Di(e,d,s),c=Ai(l.suffixBase,r);return{sourceKey:l.key,sourceExpr:ce.cloneNode(l.expression),sourceLocal:l.local,itemPattern:d.itemPattern,itemParam:d.itemParam,indexParam:d.indexParam,keyExpr:Li(d.jsx?.openingElement??null,s),jsx:d.jsx,form:u.form,rowComp:u.rowComp,renderCallback:u.renderCallback,owner:o,suffix:c,prefix:`${o}/${c}`}}function Ni(e,t,n,o,r){return ce.isIdentifier(t)?Ii(e,t,n,r):ce.isMemberExpression(t)?Fi(e,t,n,o,r):ce.isExpression(t)&&rn(t)?{expression:t,key:"$static-list",local:!0,suffixBase:"$static-list"}:r("memo-dom: assign an ordered collection view to reactive state or a local derivation before mapping it")}function Ii(e,t,n,o){let r=e.componentProps.get(n)?.bindings??[],i=e.instanceState.get(n)?.has(t.name)===!0||e.instanceDerivedBindings.get(n)?.has(t.name)===!0||r.includes(t.name),s=e.state.get(t.name);return!i&&s!=="let"&&s!=="const"&&s!=="computed"?o("memo-dom: list views must come from reactive module state, component props, component state, or a local derivation"):{expression:t,key:t.name,local:i,suffixBase:t.name}}function Fi(e,t,n,o,r){let i=Pe(t),s=ye(t),a=e.componentProps.get(n)?.bindings??[],l=i!==null&&(e.instanceState.get(n)?.has(i)===!0||a.includes(i)),d=i!==null&&s!==null&&o!==void 0&&i===o.itemParam;return i===null||s===null||!s.includes(".")||!d&&!l&&e.state.get(i)!=="store"?r("memo-dom: list member views must be a static path on reactive module state, component props, or component state"):{expression:t,key:d?o.sourceKey:s,local:d?o.sourceLocal:l,suffixBase:s.slice(s.lastIndexOf(".")+1)}}function Ri(e,t,n,o){if(t.arguments.length!==1||!ce.isArrowFunctionExpression(t.arguments[0]))return o("memo-dom: list rendering expects items.map(item => <JSX />) \u2014 R7 L1");let r=t.arguments[0],i=r.params[0],s=r.params[1];if(r.params.length<1||r.params.length>2||!ce.isIdentifier(i)&&!ce.isObjectPattern(i)&&!ce.isArrayPattern(i)||s!==void 0&&!ce.isIdentifier(s))return o("memo-dom: list callback must take an item binding pattern and optional index identifier \u2014 R7 L1");let a=tn(i),l=Object.keys(ce.getBindingIdentifiers(a));if(l.length===0)return o("memo-dom: list callback item pattern must bind at least one name \u2014 R7 L1");let d=ce.isIdentifier(a)?a.name:l[0],u=ce.isIdentifier(s)?s.name:null,c=ce.isBlockStatement(r.body)&&r.body.body.length===1&&ce.isReturnStatement(r.body.body[0])?r.body.body[0].argument:null,g=ce.isJSXElement(r.body)?r.body:ce.isJSXElement(c)?c:null,S=Ft(e,n,t);return g===null&&S===null?o("memo-dom: list callback body must be one JSX element or a block containing only return <JSX /> \u2014 R7 L1"):{itemPattern:a,itemParam:d,indexParam:u,jsx:g,renderInvocation:S}}function Di(e,t,n){let o=t.jsx?.openingElement??null;if(o!==null&&!ce.isJSXIdentifier(o.name))return n("memo-dom: namespaced JSX tags are not supported (L1)");let r=o!==null&&ce.isJSXIdentifier(o.name)?o.name.name:null;return t.renderInvocation!==null?(Mi(t,n),{form:"callback",rowComp:null,renderCallback:ce.cloneNode(t.renderInvocation.target,!0)}):r!==null&&/^[A-Z]/.test(r)?!e.comps.has(r)&&!e.importedComponents.has(r)?n(`memo-dom: <${r} /> is not a linked component factory`):{form:"component",rowComp:r,renderCallback:null}:{form:"inline",rowComp:null,renderCallback:null}}function Mi(e,t){let n=e.renderInvocation;(!ce.isIdentifier(e.itemPattern)||n.arguments.length<1||n.arguments.length>2||!ce.isIdentifier(n.arguments[0],{name:e.itemPattern.name})||n.arguments.length===2&&(e.indexParam===null||!ce.isIdentifier(n.arguments[1],{name:e.indexParam})))&&t("memo-dom: render callback maps must pass their item and optional index bindings directly")}function Li(e,t){let n=null;for(let o of e?.attributes??[])if(ce.isJSXAttribute(o)&&ce.isJSXIdentifier(o.name,{name:"key"})&&(n=$e(o.value),n===null))return t("memo-dom: key={...} needs an expression");return n}function Ai(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}${n}`}import*as te from"@babel/types";function sn(e){return te.isConditionalExpression(e)||te.isLogicalExpression(e)&&(e.operator==="&&"||e.operator==="||")?e:null}function ji(e){return te.isNullLiteral(e)||te.isBooleanLiteral(e,{value:!1})||te.isIdentifier(e,{name:"undefined"})}function Ji(e,t){let n=[e];for(;n.length>0;){let o=n.pop();if(te.isJSXElement(o)){for(let r of o.openingElement.attributes)!te.isJSXSpreadAttribute(r)&&r.name.name==="key"&&t("memo-dom: key={...} is only meaningful on list rows");n.push(...o.children)}else if(te.isJSXFragment(o))n.push(...o.children);else if(te.isJSXExpressionContainer(o)&&te.isExpression(o.expression)){let r=o.expression;if(Oe(r)!==null&&ue(r))continue}}}function an(e,t,n){let o=l=>{throw t.buildCodeFrameError(l)},r,i;if(te.isConditionalExpression(e)){let l=[];i=[];let d=e;for(;te.isConditionalExpression(d);)l.push(te.cloneNode(d.test)),i.push(d.consequent),d=d.alternate;i.push(d),r=te.numericLiteral(i.length-1);for(let u=l.length-1;u>=0;u--)r=te.conditionalExpression(l[u],te.numericLiteral(u),r)}else e.operator==="&&"?(r=te.conditionalExpression(te.cloneNode(e.left),te.numericLiteral(0),te.numericLiteral(1)),i=[e.right,null]):(r=te.conditionalExpression(te.cloneNode(e.left),te.numericLiteral(1),te.numericLiteral(0)),i=[e.right,null]);let s=l=>l===null||ji(l)?null:te.isJSXElement(l)||te.isJSXFragment(l)?l:te.isExpression(l)?te.jsxFragment(te.jsxOpeningFragment(),te.jsxClosingFragment(),[te.jsxExpressionContainer(te.cloneNode(l,!0))]):o("memo-dom: conditional branches must be JSX, renderable text expressions, or null/false"),a=i.map(s);for(let l of a)l!==null&&Ji(l,o);return{pickExpr:r,branches:a,suffix:`when${n.count++}`}}import*as Fe from"@babel/types";import*as ge from"@babel/types";var Rt=class{constructor(t){this.fallback=t}fallback;origins=new WeakMap;trackDeclarator(t,n){if(!ge.isIdentifier(n.id)||n.init===null)return;let o=this.resolveExpression(t,n.init);if(o===null)return;let r=t.getBinding(n.id.name);r!==void 0&&this.origins.set(r.identifier,o)}referencedOrigins(t,n){let o=new Map,r=i=>{if(ge.isIdentifier(i)||ge.isMemberExpression(i)){let s=this.resolveExpression(t,i);if(s!==null){let a=[s.locality,s.root,s.key??"*"].join(":");o.set(a,s);return}}for(let s of ge.VISITOR_KEYS[i.type]??[]){let a=i[s];if(Array.isArray(a))for(let l of a)l&&typeof l=="object"&&"type"in l&&r(l);else a&&typeof a=="object"&&"type"in a&&r(a)}};return r(n),[...o.values()]}resolveName(t,n){let o=t.getBinding(n);if(o!==void 0){let r=this.origins.get(o.identifier);if(r!==void 0)return r}return this.fallback(n,o)}resolveExpression(t,n){let o=vo(n);if(ge.isIdentifier(o))return this.resolveName(t,o.name);if(!ge.isMemberExpression(o))return null;let r=$i(o);if(r===null)return null;let i=this.resolveName(t,r);if(i===null)return null;let s=ye(o);if(i.key===null||s===null)return{...i,key:null};let a=s.split(".").slice(1);return{...i,key:[i.key,...a].join(".")}}};function ln(e,t){return{locality:"module",root:e,key:e,stateKind:t}}function mt(e,t){return e.key===null?e:{...e,key:[e.key,...t].join(".")}}function dn(e,t){if(e.key===null)return null;let n=[];for(let o of t){if(!ge.isObjectExpression(o))return null;for(let r of o.properties){if(!ge.isObjectProperty(r)||r.computed||!ge.isIdentifier(r.key)&&!ge.isStringLiteral(r.key))return null;let i=ge.isIdentifier(r.key)?r.key.name:r.key.value;n.push(`${e.key}.${i}`)}}return n}function cn(e){let t=[];for(let n of e)ge.isExpression(n)?t.push(n):ge.isSpreadElement(n)&&t.push(n.argument);return t}function un(e){return!e.computed&&ge.isIdentifier(e.property)?e.property.name:e.computed&&ge.isStringLiteral(e.property)?e.property.value:null}function $i(e){let t=e;for(;ge.isMemberExpression(t);){if(ge.isSuper(t.object))return null;t=vo(t.object)}return ge.isIdentifier(t)?t.name:null}function vo(e){let t=e;for(;ge.isTSAsExpression(t)||ge.isTSTypeAssertion(t)||ge.isTSNonNullExpression(t)||ge.isTypeCastExpression(t)||ge.isTSSatisfiesExpression(t);)t=t.expression;return t}function Ve(e,t,n=new Set){let o=e.helperSummaries.get(t);if(o)return o;if(n.has(t))return{reads:new Set,writes:new Set,boundedWrites:new Set,parameterWrites:[],unbounded:!0};let r=e.helpers.get(t),i=new Set,s=new Map(r.node.params.flatMap((p,f)=>Fe.isIdentifier(p)?[[p.name,f]]:[])),a={reads:new Set,writes:new Set,boundedWrites:new Set,parameterWrites:[],unbounded:!1},l=new Rt((p,f)=>{if(s.has(p)&&f?.scope.block===r.node)return{locality:"prop",root:p,key:p};let v=e.state.get(p);return v===void 0||f!==void 0&&!f.scope.path.isProgram()?null:ln(p,v)}),d=p=>p.stateKind==="computed"||e.state.get(p.root)==="computed";n.add(t),r.traverse({VariableDeclarator(p){Fe.isIdentifier(p.node.id)&&(i.add(p.node.id.name),p.parentPath.isVariableDeclaration()&&l.trackDeclarator(p.scope,p.node))},Function(p){for(let f of p.node.params)Fe.isIdentifier(f)&&i.add(f.name)}});let u=(p,f)=>{a.parameterWrites.some(v=>v.index===p&&v.path.length===f.length&&v.path.every((x,I)=>x===f[I]))||a.parameterWrites.push({index:p,path:f})},c=p=>{if(!d(p)){if(p.locality==="module"){a.boundedWrites.add(p.key??p.root);return}if(p.locality==="prop"){let f=s.get(p.root);if(f!==void 0){let v=p.key===null?[]:p.key.split(".").slice(1);u(f,v);return}}a.unbounded=!0}},g=p=>{p.locality==="prop"?c(p):p.locality!=="module"?a.unbounded=!0:p.stateKind!=="store"?a.writes.add(p.root):p.key!==null&&p.key.includes(".")?a.writes.add(p.key):a.boundedWrites.add(p.root)},S=(p,f)=>{let v=l.resolveExpression(p.scope,f);v!==null&&g(v)},y=(p,f)=>{for(let v of cn(f)){if(!Fe.isIdentifier(v))continue;let x=l.resolveExpression(p.scope,v);x!==null&&!d(x)&&c(x)}};return r.traverse({VariableDeclarator(p){if(!Fe.isIdentifier(p.node.id)&&p.node.init!==null)for(let f of l.referencedOrigins(p.scope,p.node.init))c(f)},AssignmentExpression(p){let f=p.node.left;if(Fe.isIdentifier(f))if(i.has(f.name)){if(Fe.isIdentifier(p.node.right)){let v=l.resolveExpression(p.scope,p.node.right);v!==null&&c(v)}}else e.state.has(f.name)&&a.writes.add(f.name);else if(Fe.isMemberExpression(f))S(p,f);else for(let v of l.referencedOrigins(p.scope,p.node.right))c(v)},UpdateExpression(p){let f=p.node.argument;Fe.isIdentifier(f)?!i.has(f.name)&&e.state.has(f.name)&&a.writes.add(f.name):Fe.isMemberExpression(f)&&S(p,f)},UnaryExpression(p){p.node.operator==="delete"&&Fe.isMemberExpression(p.node.argument)&&S(p,p.node.argument)},CallExpression(p){let f=p.node.callee;if(Fe.isMemberExpression(f)){if(un(f)==="assign"&&Fe.isIdentifier(f.object,{name:"Object"})){let I=p.node.arguments[0],J=I!==void 0&&Fe.isExpression(I)?l.resolveExpression(p.scope,I):null;if(J!==null){let F=dn(J,p.node.arguments.slice(1));if(F===null)c(J);else for(let N of F)g({...J,key:N})}return}let x=Fe.isExpression(f.object)?l.resolveExpression(p.scope,f.object):null;x!==null?c(x):y(p,p.node.arguments);return}if(Fe.isIdentifier(f)&&(e.helpers.has(f.name)||e.importedFunctions.has(f.name))){let v=e.importedFunctions.get(f.name)??Ve(e,f.name,n);for(let x of v.reads)a.reads.add(x);for(let x of v.writes)a.writes.add(x);for(let x of v.boundedWrites)a.boundedWrites.add(x);for(let x of v.parameterWrites){let I=p.node.arguments[x.index];if(I===void 0||!Fe.isExpression(I))continue;let J=l.resolveExpression(p.scope,I);J!==null&&c(mt(J,x.path))}v.unbounded&&(a.unbounded=!0);return}y(p,p.node.arguments)},Identifier(p){let f=p.node.name;if(!e.state.has(f)||i.has(f))return;let v=p.parentPath;v.isAssignmentExpression({operator:"="})&&v.node.left===p.node||a.reads.add(f)},MemberExpression(p){let f=Xi(e,p);f!==null&&a.reads.add(f)}}),n.delete(t),e.helperSummaries.set(t,a),a}function Xi(e,t){let n=ye(t.node);if(!n||!n.includes("."))return null;let o=n.split(".")[0];if(e.state.get(o)!=="store"||t.scope.getBinding(o)?.scope.path.isProgram()!==!0)return null;let r=t.parentPath;return r.isAssignmentExpression({operator:"="})&&r.node.left===t.node||Oi(t)?null:n}function Oi(e){let t=e.parentPath;return t.isCallExpression()&&t.node.callee===e.node}import*as b from"@babel/types";import*as le from"@babel/types";function Ze(e,t=!1){return{slots:[],tempVar:$(e,"value").name,updateVar:$(e,"update").name,reasonVar:null,delegatedEventRootVar:null,creation:[],mounts:[],updaters:[],tagCounters:new Map,childCounts:new Map,usedPrefixes:new Map,usedConds:{count:0},textCounter:0,regionCounter:0,disposableRegions:[],disposableEntities:[],disposableCallbacks:[],forwardedSlotCounter:0,manualDisposal:t}}function Ye(e){return le.variableDeclaration("let",[...e.slots.map(t=>le.variableDeclarator(le.identifier(t))),le.variableDeclarator(le.identifier(e.tempVar))])}function An(e,t){let n=$(e,`slot${t.slots.length}`).name;return t.slots.push(n),n}function jn(e,t,n){let o=t.tagCounters.get(n)??0;return t.tagCounters.set(n,o+1),$(e,`${n}${o}`).name}function vt(e,t,n,o){let r=()=>le.identifier(e.tempVar),i=()=>le.identifier(t);return le.ifStatement(le.binaryExpression("!==",i(),le.assignmentExpression("=",r(),n)),le.blockStatement([le.expressionStatement(le.assignmentExpression("=",i(),r())),o(r())]))}function Qe(e){return le.variableDeclaration("const",[le.variableDeclarator(le.identifier(e.updateVar),le.arrowFunctionExpression(e.reasonVar===null?[]:[le.assignmentPattern(le.identifier(e.reasonVar),le.nullLiteral())],le.blockStatement(e.updaters.map(t=>t()))))])}function gt(e,t,n,o){return le.expressionStatement(le.callExpression(Z(e,"register"),[le.objectExpression([le.objectProperty(le.identifier("id"),t),le.objectProperty(le.identifier("parent"),n),le.objectProperty(le.identifier("render"),o)])]))}function Jn(e){let t=e.replace(/\s+/g," ");return/^\s*\n/.test(e)&&(t=t.replace(/^ /,"")),/\n\s*$/.test(e)&&(t=t.replace(/ $/,"")),t}function Vt(e){return e.some(t=>!b.isJSXText(t)||t.value.trim()!=="")}function lt(e,t,n){let o=e.componentProps.get(t);if(o===void 0)return null;let r=Be(o);if(r!==null&&b.isMemberExpression(n)&&!n.computed&&b.isIdentifier(n.object,{name:r})&&b.isIdentifier(n.property))return n.property.name;if(b.isIdentifier(n)){let i=He(o,n.name);if(i!==null)return i;if(n.name==="children"&&e.instanceDerivedBindings.get(t)?.has("children")===!0)return"children"}return null}function et(e,t,n){let o=lt(e,t,n);return o!==null&&e.componentProps.get(t)?.renderProps.includes(o)===!0}function ko(e,t,n,o){let r=Ze(e,!0);r.childCounts=t.childCounts,r.usedPrefixes=t.usedPrefixes,r.usedConds=t.usedConds;let i=$(e,"childrenUpdate"),s=$(e,"childrenUpdates"),a=$(e,"childrenMountSequence"),l=$(e,"children"),d=$(e,"childrenParent"),u=$(e,"childrenOwner"),c=$(e,"childrenKey"),g=$(e,"childrenSlot"),S=$(e,"childrenNextUpdate"),y=$(e,"childrenActive"),p=$(e,"childrenDispose");return o(r,d,g),t.creation.push(b.variableDeclaration("let",[b.variableDeclarator(b.cloneNode(i),b.nullLiteral()),b.variableDeclarator(b.cloneNode(s),b.nullLiteral()),b.variableDeclarator(b.cloneNode(a),b.numericLiteral(0))]),b.variableDeclaration("const",[b.variableDeclarator(b.cloneNode(l),b.arrowFunctionExpression([b.cloneNode(d),b.cloneNode(u),b.cloneNode(c)],b.blockStatement([b.variableDeclaration("const",[b.variableDeclarator(b.cloneNode(g),b.conditionalExpression(b.binaryExpression("===",b.cloneNode(a),b.numericLiteral(0)),b.cloneNode(n,!0),b.binaryExpression("+",b.binaryExpression("+",b.cloneNode(n,!0),b.stringLiteral("/$slot[")),b.binaryExpression("+",b.cloneNode(a),b.stringLiteral("]")))))]),b.expressionStatement(b.updateExpression("++",b.cloneNode(a))),b.variableDeclaration("let",[b.variableDeclarator(b.cloneNode(y),b.booleanLiteral(!0))]),Ye(r),Qe(r),...r.creation,...r.mounts,b.ifStatement(b.binaryExpression("===",b.cloneNode(i),b.nullLiteral()),b.expressionStatement(b.assignmentExpression("=",b.cloneNode(i),b.identifier(r.updateVar))),b.blockStatement([b.ifStatement(b.binaryExpression("===",b.cloneNode(s),b.nullLiteral()),b.expressionStatement(b.assignmentExpression("=",b.cloneNode(s),b.newExpression(b.identifier("Set"),[])))),b.expressionStatement(b.callExpression(b.memberExpression(b.cloneNode(s),b.identifier("add")),[b.identifier(r.updateVar)]))])),b.variableDeclaration("const",[b.variableDeclarator(b.cloneNode(p),b.arrowFunctionExpression([],b.blockStatement([b.ifStatement(b.unaryExpression("!",b.cloneNode(y)),b.returnStatement()),b.expressionStatement(b.assignmentExpression("=",b.cloneNode(y),b.booleanLiteral(!1))),b.ifStatement(b.binaryExpression("===",b.cloneNode(i),b.identifier(r.updateVar)),b.expressionStatement(b.assignmentExpression("=",b.cloneNode(i),b.nullLiteral())),b.ifStatement(b.binaryExpression("!==",b.cloneNode(s),b.nullLiteral()),b.expressionStatement(b.callExpression(b.memberExpression(b.cloneNode(s),b.identifier("delete")),[b.identifier(r.updateVar)])))),...r.disposableRegions.map(f=>b.expressionStatement(b.callExpression(b.memberExpression(b.identifier(f),b.identifier("dispose")),[]))),...[...r.disposableCallbacks].reverse().map(f=>b.ifStatement(b.binaryExpression("!==",b.cloneNode(f),b.nullLiteral()),b.expressionStatement(b.callExpression(b.cloneNode(f),[])))),...r.disposableEntities.map(f=>b.expressionStatement(b.callExpression(Z(e,"unregisterSubtree"),[b.cloneNode(f,!0)])))])))]),b.expressionStatement(b.callExpression(Z(e,"cleanup"),[b.cloneNode(u),b.cloneNode(p)])),b.returnStatement(b.cloneNode(p))])))])),t.updaters.push(()=>b.blockStatement([b.ifStatement(b.binaryExpression("!==",b.cloneNode(i),b.nullLiteral()),b.expressionStatement(b.callExpression(b.cloneNode(i),[]))),b.ifStatement(b.binaryExpression("!==",b.cloneNode(s),b.nullLiteral()),b.forOfStatement(b.variableDeclaration("const",[b.variableDeclarator(b.cloneNode(S))]),b.cloneNode(s),b.expressionStatement(b.callExpression(b.cloneNode(S),[]))))])),l}function $n(e,t,n,o,r){let i=$(e,"slotDispose"),s=t.forwardedSlotCounter++;t.creation.push(b.variableDeclaration("const",[b.variableDeclarator(b.cloneNode(i),b.conditionalExpression(b.binaryExpression("==",b.cloneNode(n,!0),b.nullLiteral()),b.nullLiteral(),b.callExpression(b.cloneNode(n,!0),[b.identifier(o),b.cloneNode(r,!0),b.stringLiteral(String(s))])))])),t.disposableCallbacks.push(i)}function No(e,t,n,o){let r=i=>{e.creation.push(b.expressionStatement(b.callExpression(b.memberExpression(b.identifier(n),b.identifier("appendChild")),[b.identifier(i)])))};for(let i of t){if(b.isJSXText(i)){let d=Jn(i.value);d!==""&&r(o.emitText(b.stringLiteral(d)));continue}if(b.isJSXElement(i)||b.isJSXFragment(i)){r(o.emitNode(i));continue}if(b.isJSXExpressionContainer(i)||o.fail("memo-dom: spread children are not supported (L1)"),b.isJSXEmptyExpression(i.expression))continue;b.isExpression(i.expression)||o.fail("memo-dom: unsupported expression in component children");let s=i.expression;if(b.isNullLiteral(s)||b.isBooleanLiteral(s)||b.isIdentifier(s,{name:"undefined"}))continue;if(o.isForwarded(s)){o.emitForwarded(s,n);continue}let a=Oe(s);if(a!==null){o.emitList(a,n);continue}let l=sn(s);if(l!==null&&ue(l)){o.emitCondition(l,n);continue}r(o.emitText(b.cloneNode(s)))}}import*as L from"@babel/types";function mn(e){return L.isIdentifier(e.node.callee,{name:"effect"})&&e.scope.getBinding("effect")===void 0}function fn(e,t){return L.binaryExpression("+",L.identifier(e),L.stringLiteral(`/$effects/${t}`))}function Ti(e,t){return L.binaryExpression("+",fn(e,t),L.stringLiteral("/$active"))}function Bi(e){if(e.isFunctionDeclaration())return e;if(!e.isVariableDeclarator())return null;let t=e.get("init");return t.isArrowFunctionExpression()||t.isFunctionExpression()?t:null}function Mo(e,t){let n=t.get("arguments"),o=n[0];if(n.length!==1||o===void 0)throw t.buildCodeFrameError("memo-dom: effect() requires exactly one callback");if(o.isArrowFunctionExpression()||o.isFunctionExpression()){if(o.node.async||o.node.generator)throw o.buildCodeFrameError("memo-dom: effect callback must be synchronous; start async work inside it and return a synchronous teardown");return{expression:o.node,path:o,importedReads:new Set}}if(!o.isIdentifier())throw o.buildCodeFrameError("memo-dom: effect callback must be an inline function or a resolvable function identifier");if(e.importedFunctions.get(o.node.name)!==void 0)throw o.buildCodeFrameError(`memo-dom: imported named effect callback '${o.node.name}' is not supported yet; define a local synchronous wrapper so its cleanup and writes can be instrumented`);let i=o.scope.getBinding(o.node.name),s=i===void 0?null:Bi(i.path);if(s===null)throw o.buildCodeFrameError(`memo-dom: cannot resolve effect callback '${o.node.name}' \u2014 use an inline function or a local/module-level function declaration or const`);if(s.node.async||s.node.generator)throw s.buildCodeFrameError("memo-dom: effect callback must be synchronous; start async work inside it and return a synchronous teardown");if(ue(s.node.body))throw s.buildCodeFrameError("memo-dom: a JSX component cannot be used as an effect callback");return{expression:L.cloneNode(o.node),path:s,importedReads:new Set}}function Io(e,t,n,o){let r=new Set,i=new Set,s=new Map,a=new Set([...e.componentProps.get(t)?.bindings??[],...e.instanceState.get(t)??[]]),l=new Map;for(let f of e.instanceDerivations.get(t)??[])for(let v of f.bindings)l.set(v,f.sources);for(let f of e.instanceControlFlow.get(t)??[])for(let v of f.bindings)l.set(v,f.sources);for(let f of a){let v=n.scope.getBinding(f);v!==void 0&&s.set(v,{source:f,local:!0})}for(let f of l.keys()){let v=n.scope.getBinding(f);v!==void 0&&s.set(v,{source:f,local:!0})}for(let f of e.state.keys()){let v=n.scope.getBinding(f);v?.scope.path.isProgram()===!0&&s.set(v,{source:f,local:!1})}let d=f=>{let v=f.scope.getBinding(f.node.name),x=v===void 0?void 0:s.get(v);if(x===void 0)return;let I=f.parentPath;!x.local&&e.state.get(x.source)==="store"&&I?.isMemberExpression()&&I.node.object===f.node||(x.local?i.add(x.source):r.add(x.source))},u=f=>{let v=ye(f.node),x=Pe(f.node);v===null||x===null||e.state.get(x)!=="store"||f.scope.getBinding(x)?.scope.path.isProgram()!==!0||r.add(v)},c=f=>{let v=f.node.callee;if(!L.isIdentifier(v)||f.scope.getBinding(v.name)?.scope.path.isProgram()!==!0||!e.helpers.has(v.name)&&!e.importedFunctions.has(v.name))return;let x=e.importedFunctions.get(v.name)??Ve(e,v.name);for(let I of x.reads)r.add(I)};o.isIdentifier()&&o.isReferencedIdentifier()&&d(o),o.isMemberExpression()&&u(o),o.isCallExpression()&&c(o),o.traverse({Function(f){f.skip()},ReferencedIdentifier(f){f.isIdentifier()&&d(f)},MemberExpression(f){u(f)},CallExpression(f){c(f)}});let g=new Set,S=new Set,y=new Set;for(let f of i)a.has(f)&&y.add(f);let p=(f,v)=>{if(v.has(f))return;let x=l.get(f);if(x===void 0){a.has(f)?g.add(f):e.state.has(f)&&r.add(f);return}v.add(f),x.some(J=>y.has(J))||S.add(f);for(let J of x)p(J,v);v.delete(f)};for(let f of i)p(f,new Set);return{moduleReads:r,localReads:g,localDerivationReads:S}}function Fo(e,t){let n=new Set,o=s=>{let a=s.node.name;if(!e.state.has(a)||s.scope.getBinding(a)?.scope.path.isProgram()!==!0)return;let l=s.parentPath;e.state.get(a)==="store"&&l?.isMemberExpression()&&l.node.object===s.node||n.add(a)},r=s=>{let a=ye(s.node),l=Pe(s.node);a!==null&&l!==null&&e.state.get(l)==="store"&&s.scope.getBinding(l)?.scope.path.isProgram()===!0&&n.add(a)},i=s=>{let a=s.node.callee;if(!L.isIdentifier(a)||s.scope.getBinding(a.name)?.scope.path.isProgram()!==!0||!e.helpers.has(a.name)&&!e.importedFunctions.has(a.name))return;let l=e.importedFunctions.get(a.name)??Ve(e,a.name);for(let d of l.reads)n.add(d)};return t.isIdentifier()&&t.isReferencedIdentifier()&&o(t),t.isMemberExpression()&&r(t),t.isCallExpression()&&i(t),t.traverse({Function(s){s.skip()},ReferencedIdentifier(s){s.isIdentifier()&&o(s)},MemberExpression(s){r(s)},CallExpression(s){i(s)}}),n}function Xn(e){if(!e.isExpressionStatement())return null;let t=e.get("expression");return t.isCallExpression()&&mn(t)?t:null}function Lo(e){if(Xn(e)!==null)return!0;let t=!1;return e.traverse({Function(n){n.skip()},CallExpression(n){mn(n)&&(t=!0,n.stop())}}),t}function pn(e,t,n,o){let r=Xn(e);if(r!==null){o.push({callPath:r,rootStatement:t,conditions:[...n]});return}if(!e.isEmptyStatement()){if(e.isBlockStatement()){for(let i of e.get("body"))if(!i.isEmptyStatement()){if(!Lo(i))throw i.buildCodeFrameError("memo-dom: a conditional effect branch may contain only effect() calls, nested if statements, or empty statements");pn(i,t,n,o)}return}if(e.isIfStatement()){let i=e.get("test");pn(e.get("consequent"),t,[...n,{path:i,negated:!1}],o);let s=e.get("alternate");s.node!==null&&pn(s,t,[...n,{path:i,negated:!0}],o);return}throw e.buildCodeFrameError("memo-dom: conditional effect() calls must be controlled by top-level if statements")}}function Ao(e){let t=[];for(let n of e){let o=Xn(n);if(o!==null){t.push({callPath:o,rootStatement:n.node,conditions:[]});continue}!n.isIfStatement()||!Lo(n)||pn(n,n.node,[],t)}return t}function jo(e){return e.length===0?null:e.map(({path:n,negated:o})=>o?L.unaryExpression("!",L.cloneNode(n.node,!0)):L.cloneNode(n.node,!0)).reduce((n,o)=>L.logicalExpression("&&",n,o))}function Vi(e,t){let n=[],o=Ao(t.get("body"));for(let r of o){let i=Mo(e,r.callPath),s=i.path===null?i.importedReads:Fo(e,i.path),a=new Set;for(let d of r.conditions)for(let u of Fo(e,d.path))a.add(u);let l=n.length;n.push({index:l,statement:r.rootStatement,callback:i.expression,moduleReads:s,condition:jo(r.conditions),conditionModuleReads:a,entityId:`${e.rootId}/$module-effects/${encodeURIComponent(e.moduleId)}/${l}`})}e.moduleEffects.push(...n)}function Jo(e,t){Vi(e,t);for(let[n,o]of e.compPaths){let r=[],i=new Set,s=Ao(o.get("body").get("body"));for(let l of s){let d=Mo(e,l.callPath),u=d.path===null?{moduleReads:d.importedReads,localReads:new Set,localDerivationReads:new Set}:Io(e,n,o,d.path),c=new Set,g=new Set,S=new Set;for(let y of l.conditions){let p=Io(e,n,o,y.path);for(let f of p.moduleReads)c.add(f);for(let f of p.localReads)g.add(f);for(let f of p.localDerivationReads)S.add(f)}r.push({index:r.length,statement:l.rootStatement,callback:d.expression,...u,condition:jo(l.conditions),conditionModuleReads:c,conditionLocalReads:g,conditionLocalDerivationReads:S}),i.add(l.callPath.node)}if(o.traverse({CallExpression(l){if(!(!mn(l)||i.has(l.node)))throw l.buildCodeFrameError("memo-dom: effect() must be a direct top-level statement in a component body")}}),r.length===0)continue;e.effects.set(n,r);let a=new Set([...e.instanceReasonIds.get(n)?.keys()??[],...e.instanceState.get(n)??[],...e.componentProps.get(n)?.bindings??[],...r.flatMap(l=>[...l.localReads]),...r.flatMap(l=>[...l.conditionLocalReads])]);a.size>0&&e.instanceReasonIds.set(n,new Map([...a].sort().map((l,d)=>[l,d])))}}function Ro(e){return e.reduce((t,n)=>L.logicalExpression("||",t,n))}function Wi(e,t,n,o){let r=e.instanceReasonIds.get(t);if(r===void 0)return null;let i=[...o].map(d=>r.get(d)).filter(d=>d!==void 0).sort((d,u)=>d-u);if(i.length===0||i.length!==o.size)return null;let s=()=>L.identifier(n),a=Ro(i.map(d=>L.binaryExpression("===",s(),L.numericLiteral(d)))),l=Ro(i.map(d=>L.callExpression(L.memberExpression(s(),L.identifier("has")),[L.numericLiteral(d)])));return L.logicalExpression("||",L.binaryExpression("===",s(),L.nullLiteral()),L.conditionalExpression(L.binaryExpression("===",L.unaryExpression("typeof",s()),L.stringLiteral("number")),a,l))}function $o(e,t,n,o,r,i){let s=(l,d,u,c,g)=>{if(u.size===0&&c.size===0)return null;let S=L.expressionStatement(L.callExpression(Z(e,"markDirty"),[d]));if(c.size>0&&i!==void 0){let p=[],f=[];for(let x of c){let I=$(e,`eff${l.index}_${g}_${x}`).name;i.creation.push(L.variableDeclaration("let",[L.variableDeclarator(L.identifier(I),L.identifier(x))])),p.push(L.binaryExpression("!==",L.identifier(I),L.identifier(x))),f.push(L.expressionStatement(L.assignmentExpression("=",L.identifier(I),L.identifier(x))))}let v=p.length===1?p[0]:p.reduce((x,I)=>L.logicalExpression("||",x,I));S=L.ifStatement(v,L.blockStatement([...f,S]))}if(o===null)return S;let y=Wi(e,t,o,u);return y===null?S:L.ifStatement(y,S)},a=r.flatMap(l=>{let d=l.condition===null?null:s(l,fn(n,l.index),l.conditionLocalReads,l.conditionLocalDerivationReads,"condition"),u=s(l,l.condition===null?fn(n,l.index):Ti(n,l.index),l.localReads,l.localDerivationReads,"callback");return[d,u].filter(c=>c!==null)});return L.blockStatement(a)}function Xo(e,t,n){return n.map(o=>L.expressionStatement(L.callExpression(Z(e,o.condition===null?"registerEffect":"registerConditionalEffect"),[fn(t,o.index),L.identifier(t),...o.condition===null?[]:[L.arrowFunctionExpression([],L.cloneNode(o.condition,!0))],L.cloneNode(o.callback,!0)])))}function Do(){return L.memberExpression(L.metaProperty(L.identifier("import"),L.identifier("meta")),L.identifier("hot"))}function Oo(e,t){if(e.moduleEffects.length===0)return;let n=new Map(t.get("body").map(r=>[r.node,r])),o=new Map;for(let r of e.moduleEffects){let i=o.get(r.statement)??[];i.push(r),o.set(r.statement,i)}for(let[r,i]of o){let s=n.get(r);if(s===void 0)continue;let a=[];for(let l of i)a.push(L.expressionStatement(L.callExpression(Z(e,l.condition===null?"registerEffect":"registerConditionalEffect"),[L.stringLiteral(l.entityId),L.nullLiteral(),...l.condition===null?[]:[L.arrowFunctionExpression([],L.cloneNode(l.condition,!0))],L.cloneNode(l.callback,!0)])),L.ifStatement(Do(),L.expressionStatement(L.callExpression(L.memberExpression(Do(),L.identifier("dispose")),[L.arrowFunctionExpression([],L.callExpression(Z(e,"unregisterSubtree"),[L.stringLiteral(l.entityId)]))]))));s.replaceWithMultiple(a)}}function To(e){e.traverse({CallExpression(t){if(mn(t))throw t.buildCodeFrameError("memo-dom: effect() must be a direct top-level statement or be controlled by a top-level effect-only if branch in a component or module")}})}import*as _e from"@babel/types";function Bo(e,t){return e.size===t.size&&[...e].every(n=>t.has(n))}function Vo(e){let t=new Set,n=[];for(let o of e){let r=gn(o);if(r===null)return null;for(let i of r.bindings){if(t.has(i))return null;t.add(i)}n.push(...r.expressions)}return t.size===0?null:{bindings:t,expressions:n}}function gn(e){if(_e.isExpressionStatement(e)&&_e.isAssignmentExpression(e.expression,{operator:"="})&&_e.isIdentifier(e.expression.left))return{bindings:new Set([e.expression.left.name]),expressions:[e.expression.right]};if(_e.isBlockStatement(e))return Vo(e.body);if(_e.isIfStatement(e)){let t=e.alternate;if(t==null)return null;let n=gn(e.consequent),o=gn(t);return n===null||o===null||!Bo(n.bindings,o.bindings)?null:{bindings:n.bindings,expressions:[e.test,...n.expressions,...o.expressions]}}return null}function zi(e){if(!e.cases.some(r=>r.test==null))return null;let t=null,n=!1,o=[e.discriminant];for(let r of e.cases){r.test!=null&&o.push(r.test);let i=[...r.consequent];if(i.length===0){n=!0;continue}if(i.at(-1)&&_e.isBreakStatement(i.at(-1))&&i.pop(),i.some(a=>_e.isBreakStatement(a)))return null;let s=Vo(i);if(s===null)return null;if(n=!1,t===null)t=s.bindings;else if(!Bo(t,s.bindings))return null;o.push(...s.expressions)}return t===null||n?null:{bindings:t,expressions:o}}function Ki(e,t){return e.node===t||e.findParent(n=>n.node===t)!==null}function Hi(e,t){let n=e;for(;n?.parentPath!==t;)n=n?.parentPath??null;return n}function Wo(e,t,n){let o=t.get("body"),r=new Map(o.map((i,s)=>[i.node,s]));for(let i of o){if(!i.isIfStatement()&&!i.isSwitchStatement())continue;let s=i.node,a=i.isIfStatement()?gn(s):zi(s);if(a===null)continue;let l=!0,d=[];for(let y of a.bindings){let p=t.scope.getBinding(y),f=p?.path,v=f?.parentPath,x=f===void 0?null:Hi(f,t);if(p===void 0||!f?.isVariableDeclarator()||!v?.isVariableDeclaration()||v.node.kind!=="let"&&v.node.kind!=="var"||x===null||(r.get(x.node)??Number.MAX_SAFE_INTEGER)>=(r.get(s)??-1)){l=!1;break}d.push(...p.constantViolations.filter(I=>!Ki(I,s)))}if(!l)continue;let u=new Set,c=null;for(let y of a.expressions){let p=n(e,y);for(let f of p.reads)u.add(f);p.impure&&c===null&&(c=p.reason??"cannot be analyzed")}if(u.size===0)continue;if(c!==null)throw i.buildCodeFrameError(`memo-dom: module control-flow derivation ${c}`);for(let y of a.bindings)if(u.has(y))throw i.buildCodeFrameError(`memo-dom: module control-flow derivation '${y}' reads its own previous value`);if(d.length>0)throw d[0].buildCodeFrameError(`memo-dom: cannot assign module control-flow computed '${[...a.bindings].sort().join(", ")}' outside its derivation`);let g=e.moduleControlFlow.length,S=[...a.bindings].sort();for(let y of S)pt(e,y,"computed");e.moduleControlFlow.push({statement:s,bindings:S,sources:[...u].sort(),entityId:`${e.rootId}/$computed/${encodeURIComponent(e.moduleId)}#$flow${g}`})}}import*as pe from"@babel/types";function On(e,t){let n=new Set,o=!1,r,i=new Set,s=l=>{o||(o=!0,r=l)},a=l=>{pe.isIdentifier(l)?i.add(l.name):Xe(l,d=>{pe.isIdentifier(d)&&i.add(d.name)})};return Xe(t,(l,d)=>{if(pe.isFunction(l)){if(!(d!==null&&(pe.isCallExpression(d)||pe.isNewExpression(d))))return!1;for(let c of l.params)pe.isLVal(c)&&a(c);return}if(pe.isVariableDeclarator(l)&&pe.isLVal(l.id)){a(l.id);return}if(pe.isAssignmentExpression(l)){let u=pe.isIdentifier(l.left)?l.left.name:pe.isMemberExpression(l.left)?Pe(l.left):null;(u===null||!i.has(u))&&s("contains an assignment \u2014 writes belong in handlers, not derivations");return}if(pe.isUpdateExpression(l)){let u=l.argument,c=pe.isIdentifier(u)?u.name:pe.isMemberExpression(u)?Pe(u):null;(c===null||!i.has(c))&&s("contains an update (++/--) \u2014 writes belong in handlers, not derivations");return}if(pe.isAwaitExpression(l)||pe.isYieldExpression(l)){s("uses await/yield \u2014 derivations must be synchronous");return}if(pe.isCallExpression(l)){let u=l.callee;if(pe.isIdentifier(u)&&(e.helpers.has(u.name)||e.importedFunctions.has(u.name))){let c=e.importedFunctions.get(u.name)??Ve(e,u.name);for(let g of c.reads)n.add(g);if(c.writes.size>0){for(let g of c.writes)n.add(g);s(`calls helper '${u.name}' which writes state \u2014 writes belong in handlers`)}else c.unbounded&&e.helpers.has(u.name)&&s(`calls recursive helper '${u.name}' which cannot be analyzed`)}return}if(pe.isIdentifier(l)){!i.has(l.name)&&e.state.has(l.name)&&n.add(l.name);return}if(pe.isMemberExpression(l)&&!l.computed){let u=ye(l);if(u!==null&&u.includes(".")){let c=u.split(".")[0];!i.has(c)&&e.state.get(c)==="store"&&n.add(u)}}}),{reads:n,impure:o,reason:r}}function zo(e,t){for(let n of t.node.body){let o=pe.isExportNamedDeclaration(n)?n.declaration:n;if(!(!pe.isVariableDeclaration(o)||o.kind!=="const"))for(let r of o.declarations){if(!pe.isIdentifier(r.id)||r.init==null)continue;let i=r.id.name;if(e.state.get(i)==="let"||e.state.get(i)==="computed"||pe.isFunction(r.init)||pe.isJSX(r.init))continue;let s=On(e,r.init);if(s.impure){if(s.reads.size>0)throw new Error(`memo-dom: const '${i}' is a state derivation but ${s.reason??"cannot be analyzed"}. Fix the derivation, or make it a 'let' you update in handlers.`);continue}s.reads.size!==0&&(pt(e,i,"computed"),e.computeds.set(i,{reads:s.reads}))}}}import*as Me from"@babel/types";function Ko(e){for(let[t,n]of e.compPaths){let o=new Set;for(let r of n.node.body.body)if(Me.isVariableDeclaration(r)&&!(r.kind!=="let"&&r.kind!=="var"&&r.kind!=="const"))for(let i of r.declarations)Me.isIdentifier(i.id)&&(r.kind==="let"||r.kind==="var"||Ct(i.init)||Pt(i.init))&&o.add(i.id.name);o.size>0&&e.instanceState.set(t,o)}}function Ho(e){for(let[t,n]of e.compPaths){let o=new Map;for(let c of e.componentProps.get(t)?.bindings??[]){let g=n.scope.getBinding(c);g&&o.set(g,c)}for(let c of e.instanceState.get(t)??[]){let g=n.scope.getBinding(c);g&&o.set(g,c)}for(let c of e.state.keys()){let g=n.scope.getBinding(c);g?.scope.path.isProgram()&&o.set(g,c)}let r=[],i=new Set,s=new Map,a=n.get("body").get("body");for(let c of a)if(c.isVariableDeclaration({kind:"const"}))for(let g of c.get("declarations")){let S=g.node;if(!Me.isIdentifier(S.id)&&!Me.isObjectPattern(S.id)&&!Me.isArrayPattern(S.id)||S.init==null||Me.isFunction(S.init)||Me.isIdentifier(S.id)&&e.instanceState.get(t)?.has(S.id.name)===!0&&(Ct(S.init)||Pt(S.init)))continue;let y=g.get("init");if(!y.isExpression())continue;let p=new Set,f=null,v=(N,K)=>{let _=K.scope.getBinding(N);return _!==void 0&&o.has(_)},x=N=>{if(!Me.isIdentifier(N.node))return;let K=N.scope.getBinding(N.node.name),_=K===void 0?void 0:o.get(K);_!==void 0&&p.add(_)},I=N=>Me.isIdentifier(N)?N.name:Me.isMemberExpression(N)?Pe(N):null;if(y.isReferencedIdentifier()&&x(y),y.isAssignmentExpression()){let N=I(y.node.left);N!==null&&v(N,y)&&(f="contains an assignment to reactive state")}else if(y.isUpdateExpression()){let N=I(y.node.argument);N!==null&&v(N,y)&&(f="contains an update (++/--) to reactive state")}else y.isAwaitExpression()?f="uses await; per-instance derivations must be synchronous":y.isYieldExpression()&&(f="uses yield; per-instance derivations must be synchronous");if(y.traverse({Function(N){N.skip()},ReferencedIdentifier(N){x(N)},AssignmentExpression(N){let K=I(N.node.left);K!==null&&v(K,N)&&(f="contains an assignment to reactive state")},UpdateExpression(N){let K=I(N.node.argument);K!==null&&v(K,N)&&(f="contains an update (++/--) to reactive state")},AwaitExpression(){f="uses await; per-instance derivations must be synchronous"},YieldExpression(){f="uses yield; per-instance derivations must be synchronous"}}),p.size===0)continue;if(y.traverse({ReferencedIdentifier(N){x(N)},AssignmentExpression(N){let K=I(N.node.left);K!==null&&v(K,N)&&(f="contains an assignment to reactive state")},UpdateExpression(N){let K=I(N.node.argument);K!==null&&v(K,N)&&(f="contains an update (++/--) to reactive state")}}),f!==null){let N=Tt(S.id);throw g.buildCodeFrameError(`memo-dom: local const '${N.join(", ")||"<pattern>"}' is a per-instance derivation but ${f}`)}let J=Tt(S.id),F=new Set;for(let N of p){let K=s.get(N);if(K===void 0)F.add(N);else for(let _ of K)F.add(_)}r.push({declaration:c.node,target:Me.cloneNode(S.id),source:Me.cloneNode(S.init),bindings:J,sources:[...F].sort()});for(let N of J){i.add(N),s.set(N,new Set(F));let K=n.scope.getBinding(N);K&&o.set(K,N),e.instanceState.get(t)?.delete(N)}}if(r.length===0)continue;e.instanceDerivations.set(t,r),e.instanceDerivedBindings.set(t,i);let l=new Set([...e.instanceState.get(t)??[],...e.componentProps.get(t)?.bindings??[]]);if(![...l].some(c=>r.some(g=>!g.sources.includes(c))))continue;let u=new Set([...l,...r.flatMap(c=>c.sources)]);e.instanceReasonIds.set(t,new Map([...u].sort().map((c,g)=>[c,g]))),e.selectiveDerivationComponents.add(t)}}import*as fe from"@babel/types";function zt(e){let t=!0;return fe.traverseFast(e,n=>{if(fe.isAssignmentExpression(n)||fe.isUpdateExpression(n)||fe.isAwaitExpression(n)||fe.isYieldExpression(n)||fe.isNewExpression(n)||fe.isTaggedTemplateExpression(n)||fe.isFunction(n)){t=!1;return}if(fe.isCallExpression(n)||fe.isOptionalCallExpression(n)){let o=n.callee;t=t&&fe.isMemberExpression(o)&&!o.computed&&fe.isIdentifier(o.object,{name:"Math"})&&fe.isIdentifier(o.property)}}),t}function Ui(e){return!fe.isExpressionStatement(e)||!fe.isAssignmentExpression(e.expression,{operator:"="})||!fe.isIdentifier(e.expression.left)||!zt(e.expression.right)?null:e.expression.left.name}function Uo(e,t){return e.size===t.size&&[...e].every(n=>t.has(n))}function Wt(e){if(fe.isExpressionStatement(e)){let t=Ui(e);return t===null?null:{bindings:new Set([t]),partial:new Set}}if(fe.isBlockStatement(e)){let t=new Set,n=new Set;for(let o of e.body){let r=Wt(o);if(r===null)return null;for(let i of r.bindings){if(t.has(i))return null;t.add(i)}for(let i of r.partial)n.add(i)}return t.size===0?null:{bindings:t,partial:n}}if(fe.isIfStatement(e)){if(!zt(e.test))return null;let t=Wt(e.consequent);if(t===null)return null;if(e.alternate==null)return{bindings:t.bindings,partial:new Set([...t.bindings,...t.partial])};let n=Wt(e.alternate);return n===null||!Uo(t.bindings,n.bindings)?null:{bindings:t.bindings,partial:new Set([...t.partial,...n.partial])}}return null}function _i(e){if(!zt(e.discriminant))return null;let t=null;for(let n of e.cases){if(n.test!=null&&!zt(n.test))return null;let o=[...n.consequent];if(o.at(-1)&&fe.isBreakStatement(o.at(-1))&&o.pop(),o.some(i=>fe.isBreakStatement(i)))return null;let r=Wt(fe.blockStatement(o));if(r===null)return null;if(t===null)t=r;else{if(!Uo(t.bindings,r.bindings))return null;for(let i of r.partial)t.partial.add(i)}}if(t!==null&&!e.cases.some(n=>n.test===null))for(let n of t.bindings)t.partial.add(n);return t}function qi(e,t){return e.node===t||e.findParent(n=>n.node===t)!==null}function _o(e){for(let[t,n]of e.compPaths){let o=new Map;for(let s of e.componentProps.get(t)?.bindings??[]){let a=n.scope.getBinding(s);a&&o.set(a,s)}for(let s of e.instanceState.get(t)??[]){let a=n.scope.getBinding(s);a&&o.set(a,s)}for(let s of e.instanceDerivedBindings.get(t)??[]){let a=n.scope.getBinding(s);a&&o.set(a,s)}for(let s of e.state.keys()){let a=n.scope.getBinding(s);a?.scope.path.isProgram()&&o.set(a,s)}let r=[],i=e.instanceDerivedBindings.get(t)??new Set;for(let s of n.get("body").get("body")){if(!s.isIfStatement()&&!s.isSwitchStatement())continue;let a=s,l=a.isIfStatement()?Wt(a.node):_i(a.node);if(l===null)continue;let d=!0,u=[],c=[];for(let p of l.bindings){let f=n.scope.getBinding(p),v=f?.path,x=v?.parentPath;if(f===void 0||!v?.isVariableDeclarator()||!x?.isVariableDeclaration()||x.node.kind!=="let"&&x.node.kind!=="var"||f.constantViolations.some(I=>!qi(I,a.node))){d=!1;break}if(l.partial.has(p)){let I=v.get("init");if(!I.isExpression()||!zt(I.node)){d=!1;break}u.push({binding:p,source:I.node}),c.push(I)}}if(!d)continue;let g=new Set,S=p=>{let f=p.scope.getBinding(p.node.name),v=f===void 0?void 0:o.get(f);v!==void 0&&g.add(v)},y={Function(p){p.skip()},ReferencedIdentifier(p){p.isIdentifier()&&S(p)}};a.traverse(y);for(let p of c)p.isReferencedIdentifier()&&S(p),p.traverse(y);if(g.size!==0){for(let p of l.bindings)if(g.has(p))throw a.buildCodeFrameError(`memo-dom: reactive control-flow derivation '${p}' reads its own previous value`);r.push({statement:a.node,bindings:[...l.bindings].sort(),resets:u,sources:[...g].sort()});for(let p of l.bindings){i.add(p);let f=n.scope.getBinding(p);f&&o.set(f,p),e.instanceState.get(t)?.delete(p)}}}r.length>0&&(e.instanceControlFlow.set(t,r),e.instanceDerivedBindings.set(t,i))}}function qo(e){for(let[t]of e.compPaths){let n=e.instanceDerivations.get(t)??[],o=e.instanceControlFlow.get(t)??[];if(n.length===0&&o.length===0)continue;let r=new Map;for(let u of n)for(let c of u.bindings)r.set(c,new Set(u.sources));for(let u of o)for(let c of u.bindings)r.set(c,new Set(u.sources));let i=(u,c=new Set)=>{let g=r.get(u);if(g===void 0)return new Set([u]);if(c.has(u))return new Set([u]);let S=new Set(c).add(u),y=new Set;for(let p of g)for(let f of i(p,S))y.add(f);return y};for(let u of n)u.sources=[...new Set(u.sources.flatMap(c=>[...i(c)]))].sort();for(let u of o)u.sources=[...new Set(u.sources.flatMap(c=>[...i(c)]))].sort();let s=new Set([...e.instanceState.get(t)??[],...e.componentProps.get(t)?.bindings??[]]),a=[...n,...o],l=[...s].some(u=>a.some(c=>!c.sources.includes(u)));if(e.selectiveDerivationComponents.delete(t),e.instanceReasonIds.delete(t),!l)continue;let d=new Set([...s,...a.flatMap(u=>u.sources)]);e.instanceReasonIds.set(t,new Map([...d].sort().map((u,c)=>[u,c]))),e.selectiveDerivationComponents.add(t)}}import*as Kt from"@babel/types";function Gi(e){let t=e.indexOf("[");return t<0?e:e.slice(0,t)}function bt(e,t){let n=new Set;for(let o of t){let r=o.split("/"),i=[[]];for(let s=0;s<r.length;s++){let a=r[s],l=i.map(d=>[...d,a]);if(s<r.length-1&&e.renderSlotOwners.has(Gi(a)))for(let d of i)l.push([...d,a,"$slot[*]"]);i=l}for(let s of i)n.add(s.join("/"))}return[...n]}function qe(e,t,n=new Set){let o=e.linkedComponentPaths.get(t);if(o!==void 0)return[...o];if(n.has(t))throw e.compPaths.get(t).buildCodeFrameError(`memo-dom: recursive component '${t}' \u2014 components cannot render themselves (L1)`);let r=e.listedSites.get(t);if(r!==void 0&&r.length>0){n.add(t);let d=r.flatMap(u=>qe(e,u.owner,n).map(c=>`${c}/${u.suffix}/Row[*]`));return n.delete(t),[...new Set(d)]}let i=e.comps.get(t),s=e.conditionalComponentSites.get(t)??[],a=e.rowComponentSites.get(t)??[];if(i.parents.size===0&&s.length===0&&a.length===0)return[e.rootId];n.add(t);let l=[];for(let d of s)for(let u of qe(e,d.owner,n))l.push(`${u}/${d.suffix}`);for(let d of a)for(let u of qe(e,d.owner,n))l.push(`${u}/${d.suffix}`);for(let d of i.parents){let u=e.childRefCounts.get(d)?.get(t)??1;for(let c of qe(e,d,n))u>1?l.push(`${c}/${t}`,`${c}/${t}[*]`):l.push(`${c}/${t}`)}return n.delete(t),l}function Tn(e,t){let n=e.linkedComponentPaths.get(t);if(n!==void 0)return bt(e,n.flatMap(i=>[i,`${i}/*`]));let o=e.listedSites.get(t),r=[];if(o&&o.length>0){if(Dt(e,t)){for(let i of o){let s=i.suffix.lastIndexOf("/"),a=s<0?"":`/${i.suffix.slice(0,s)}`;for(let l of qe(e,i.owner))r.push(`${l}${a}`,`${l}${a}/*`)}return bt(e,r)}for(let i of o)for(let s of qe(e,i.owner))r.push(`${s}/${i.suffix}/Row[*]`,`${s}/${i.suffix}/Row[*]/*`);return bt(e,r)}for(let i of qe(e,t))r.push(i,`${i}/*`);return bt(e,r)}function Dt(e,t){let n=e.importedComponents.get(t);if(n!==void 0)return n.listLightweight;let o=e.lightweightCache.get(t);if(o!==void 0)return o;let r=!1,i=e.listedSites.get(t),s=e.linkedComponentRows.get(t);return(i!==void 0&&i.length>0||s!==void 0&&s.length>0)&&e.comps.get(t).parents.size===0&&bn(e,t)&&(r=!0),e.lightweightCache.set(t,r),r}function bn(e,t){if((e.instanceState.get(t)?.size??0)>0)return!1;let n=!0;return e.compPaths.get(t).traverse({JSXElement(r){let i=r.node.openingElement.name;Kt.isJSXIdentifier(i)&&/^[A-Z]/.test(i.name)&&(n=!1)},CallExpression(r){(Kt.isIdentifier(r.node.callee,{name:"cleanup"})&&r.scope.getBinding("cleanup")===void 0||Kt.isIdentifier(r.node.callee,{name:"effect"})&&r.scope.getBinding("effect")===void 0)&&(n=!1),Oe(r.node)&&De(r)&&(n=!1)},ConditionalExpression(r){De(r)&&(n=!1)},LogicalExpression(r){De(r)&&(n=!1)}}),n}import*as W from"@babel/types";function Go(e,t){let n=e.findParent(o=>o.isFunctionDeclaration()||o.isFunctionExpression()||o.isArrowFunctionExpression());return n===t?!0:n?.findParent(o=>o===t)!==null}function Bn(e,t){let n=e;for(;n!==null;){let o=n.parentPath;if(o===null||o.isJSXAttribute()||o.isJSXSpreadAttribute())return!1;if(o.isJSXExpressionContainer()){if(o.parentPath?.isJSXAttribute()===!0){let r=o.parentPath.node,i=o.parentPath.parentPath;if(!i?.isJSXOpeningElement())return!1;let s=i.node.name;if(!W.isJSXIdentifier(s)||!/^[A-Z]/.test(s.name))return!1;let a=W.isJSXIdentifier(r.name)?r.name.name:r.name.name.name;return t.componentProps.get(s.name)?.renderProps.includes(a)===!0}return o.parentPath?.isJSXElement()===!0||o.parentPath?.isJSXFragment()===!0}if(o.isReturnStatement()&&o.node.argument===n.node||o.isArrowFunctionExpression()&&o.node.body===n.node||o.isVariableDeclarator()&&o.node.init===n.node)return!0;n=o}return!1}function Zi(e,t){if(W.isArrayExpression(e))return e;if(!W.isIdentifier(e))return null;let n=t.scope.getBinding(e.name);return n?.path.isVariableDeclarator()&&W.isArrayExpression(n.path.node.init)?n.path.node.init:null}function Vn(e,t,n=new Set){if(n.has(e))throw t.buildCodeFrameError("memo-dom: cyclic JSX array spread");n.add(e);let o=[];try{for(let r of e.elements)if(!(r==null||W.isNullLiteral(r)||W.isBooleanLiteral(r))){if(W.isSpreadElement(r)){if(!W.isExpression(r.argument))throw t.buildCodeFrameError("memo-dom: JSX array spreads must resolve to a static JSX array");let i=Zi(r.argument,t);if(i===null)throw t.buildCodeFrameError("memo-dom: JSX array spreads must resolve to a static JSX array");o.push(...Vn(i,t,n));continue}if(W.isArrayExpression(r)){o.push(...Vn(r,t,n));continue}if(W.isJSXElement(r)||W.isJSXFragment(r)){o.push(W.cloneNode(r,!0));continue}if(!W.isExpression(r))throw t.buildCodeFrameError("memo-dom: JSX arrays require renderable expression entries");o.push(W.jsxExpressionContainer(W.cloneNode(r,!0)))}}finally{n.delete(e)}return o}function Zo(e,t){return W.jsxFragment(W.jsxOpeningFragment(),W.jsxClosingFragment(),Vn(e,t))}function Yi(e,t){return W.isArrayExpression(e)?e.elements.map((n,o)=>{if(n==null||W.isSpreadElement(n))throw t.buildCodeFrameError("memo-dom: JSX arrays cannot contain holes or spread elements");return{key:W.numericLiteral(o),value:n}}):e.properties.map(n=>{if(!W.isObjectProperty(n)||n.computed||!W.isExpression(n.value))throw t.buildCodeFrameError("memo-dom: JSX objects require static data properties without spreads");let o=W.isIdentifier(n.key)?W.stringLiteral(n.key.name):W.isStringLiteral(n.key)||W.isNumericLiteral(n.key)?W.cloneNode(n.key):null;if(o===null)throw t.buildCodeFrameError("memo-dom: JSX objects require identifier, string, or numeric keys");return{key:o,value:n.value}})}function Qi(e,t){let n=e.node,o=null;if(!n.computed&&W.isIdentifier(n.property)?o=n.property.name:n.computed&&(W.isStringLiteral(n.property)||W.isNumericLiteral(n.property))&&(o=n.property.value),o!==null){let i=t.find(s=>(W.isStringLiteral(s.key)||W.isNumericLiteral(s.key))&&s.key.value===o);if(i===void 0)throw e.buildCodeFrameError(`memo-dom: JSX collection has no entry for '${o}'`);return W.cloneNode(i.value,!0)}if(!n.computed||!W.isExpression(n.property))throw e.buildCodeFrameError("memo-dom: JSX collection selection requires a static or expression key");let r=W.nullLiteral();for(let i=t.length-1;i>=0;i--){let s=t[i];r=W.conditionalExpression(W.binaryExpression("===",W.cloneNode(n.property,!0),W.cloneNode(s.key,!0)),W.cloneNode(s.value,!0),r)}return r}function Yo(e){for(let[,t]of e.compPaths){let n=!1;t.traverse({JSXExpressionContainer(r){if(!r.parentPath?.isJSXElement()&&!r.parentPath?.isJSXFragment())return;let i=r.get("expression");Array.isArray(i)||!i.isArrayExpression()||!ue(i.node)||(r.replaceWith(Zo(i.node,i)),n=!0)}});let o=!0;for(;o;){o=!1,t.scope.crawl();let r=t.get("body").get("body");for(let i of r)if(i.isVariableDeclaration({kind:"const"})){for(let s of i.get("declarations")){let a=s.node,l=a.init;if(!W.isIdentifier(a.id)||l==null||!ue(l))continue;let d=s.scope.getBinding(a.id.name);if(d?.path!==s)continue;let u=[...d.referencePaths];if(W.isObjectExpression(l)||W.isArrayExpression(l))for(let c of u){if(!c.isIdentifier()||!Go(c,t))throw c.buildCodeFrameError(`memo-dom: JSX collection '${a.id.name}' is used outside its component`);if(c.parentPath?.isMemberExpression()&&c.parentPath.node.object===c.node){let g=c.parentPath;if(!Bn(g,e))throw g.buildCodeFrameError(`memo-dom: JSX collection '${a.id.name}' is used outside a render position`);g.replaceWith(Qi(g,Yi(l,s)));continue}if(W.isArrayExpression(l)&&c.parentPath?.isSpreadElement()&&c.parentPath.parentPath?.isArrayExpression()){c.replaceWith(W.cloneNode(l,!0));continue}if(W.isArrayExpression(l)&&Bn(c,e)){c.replaceWith(Zo(l,c));continue}throw c.buildCodeFrameError(W.isArrayExpression(l)?`memo-dom: JSX collection '${a.id.name}' must be rendered directly or selected with a direct index access`:`memo-dom: JSX collection '${a.id.name}' is used outside a render position`)}else for(let c of u)if(!(!c.isIdentifier()||!Go(c,t))){if(!Bn(c,e))throw c.buildCodeFrameError(`memo-dom: JSX value '${a.id.name}' is used outside a render position`);c.replaceWith(W.cloneNode(l,!0))}i.node.declarations.length===1?i.remove():s.remove(),n=!0,o=!0;break}if(o)break}}n&&(t.traverse({JSXExpressionContainer(r){let i=r.node.expression;(r.parentPath?.isJSXElement()===!0||r.parentPath?.isJSXFragment()===!0)&&(W.isJSXElement(i)||W.isJSXFragment(i))&&r.replaceWith(i)}}),t.scope.crawl())}}import*as R from"@babel/types";function Wn(e){return R.isReturnStatement(e)&&R.isExpression(e.argument)?e.argument:R.isBlockStatement(e)&&e.body.length===1?Wn(e.body[0]):null}function Mt(e){let t=Wn(e);if(t!==null)return t;if(R.isIfStatement(e)&&e.alternate!=null){let n=Mt(e.consequent),o=Mt(e.alternate);return n===null||o===null?null:R.conditionalExpression(R.cloneNode(e.test,!0),R.cloneNode(n,!0),R.cloneNode(o,!0))}if(R.isSwitchStatement(e)){let n=e.cases.find(r=>r.test==null);if(n===void 0||n.consequent.length!==1)return null;let o=Mt(n.consequent[0]);if(o===null)return null;for(let r=e.cases.length-1;r>=0;r--){let i=e.cases[r];if(i.test==null)continue;if(i.consequent.length!==1)return null;let s=Mt(i.consequent[0]);if(s===null)return null;o=R.conditionalExpression(R.binaryExpression("===",R.cloneNode(e.discriminant,!0),R.cloneNode(i.test,!0)),R.cloneNode(s,!0),o)}return o}return null}function es(e,t){if(R.isExpression(e.body))return{expression:R.cloneNode(e.body,!0),locals:new Map};let n=new Map,o=[];for(let s of e.body.body){if(R.isVariableDeclaration(s,{kind:"const"})){for(let a of s.declarations)(!R.isIdentifier(a.id)||a.init==null||!R.isExpression(a.init))&&t("memo-dom: JSX render functions require identifier const declarations with expression initializers"),n.set(a.id.name,R.cloneNode(a.init,!0));continue}R.isTypeScript(s)||R.isEmptyStatement(s)||o.push(s)}if(o.length===1){let s=Mt(o[0]);if(s!==null)return{expression:s,locals:n}}let r=o.at(-1),i=r===void 0?null:Wn(r);if(i!==null){let s=R.cloneNode(i,!0);for(let a=o.length-2;a>=0;a--){let l=o[a];if(R.isIfStatement(l)&&l.alternate==null){let d=Mt(l.consequent);if(d!==null){s=R.conditionalExpression(R.cloneNode(l.test,!0),R.cloneNode(d,!0),s);continue}}t("memo-dom: JSX render functions support pure const setup, JSX return expressions, tail early-return if statements, exhaustive return if/else, or exhaustive return switch statements")}return{expression:s,locals:n}}return t("memo-dom: JSX render function does not have supported exhaustive return control flow")}function ts(e,t){return(R.isMemberExpression(e)||R.isOptionalMemberExpression(e))&&t==="property"&&!e.computed||(R.isObjectProperty(e)||R.isObjectMethod(e)||R.isClassMethod(e))&&t==="key"&&!e.computed||R.isVariableDeclarator(e)&&t==="id"||(R.isFunction(e)||R.isCatchClause(e))&&(t==="params"||t==="param"||t==="id")||R.isLabeledStatement(e)&&t==="label"}function Qo(e,t,n=new Set){let o=R.cloneNode(e,!0),r=(i,s,a,l)=>{if(R.isIdentifier(i)&&!l.has(i.name)&&t.has(i.name)&&(s===null||!ts(s,a)))return R.cloneNode(t.get(i.name),!0);let d=l;if(R.isFunction(i)&&i!==o){let u=i.params.flatMap(c=>Object.keys(R.getBindingIdentifiers(c)));d=new Set([...l,...u])}for(let u of R.VISITOR_KEYS[i.type]??[]){let c=i[u];Array.isArray(c)?i[u]=c.map(g=>g!=null&&typeof g=="object"&&"type"in g?r(g,i,u,d):g):c!=null&&typeof c=="object"&&"type"in c&&(i[u]=r(c,i,u,d))}return R.isObjectProperty(i)&&i.shorthand&&!R.isIdentifier(i.value,{name:R.isIdentifier(i.key)?i.key.name:""})&&(i.shorthand=!1),i};return r(o,null,"",n)}function ns(e,t){let n=a=>{throw t.buildCodeFrameError(a)},o=e.node;(o.async||o.generator)&&n("memo-dom: JSX render functions must be synchronous"),t.node.arguments.some(a=>R.isSpreadElement(a))&&n("memo-dom: JSX render function calls do not support spread arguments"),t.node.arguments.length>o.params.length&&n("memo-dom: JSX render function received more arguments than parameters");let r=new Map;for(let a=0;a<o.params.length;a++){let l=o.params[a],d=t.node.arguments[a],u=d!==void 0&&R.isExpression(d)?d:R.identifier("undefined");if(R.isIdentifier(l)){r.set(l.name,R.cloneNode(u,!0));continue}if(R.isAssignmentPattern(l)&&R.isIdentifier(l.left)){r.set(l.left.name,R.conditionalExpression(R.binaryExpression("===",R.cloneNode(u,!0),R.identifier("undefined")),R.cloneNode(l.right,!0),R.cloneNode(u,!0)));continue}n("memo-dom: JSX render functions currently require identifier parameters with optional defaults")}let i=es(o,n);for(let[a,l]of i.locals)r.set(a,Qo(l,r));let s=Qo(i.expression,r);return ue(s)||n("memo-dom: JSX render function expansion did not produce JSX"),s}function os(e,t){let n=t.get("callee");return Array.isArray(n)||!n.isIdentifier()?null:er(e,n)}function er(e,t){let n=t.node.name,o=e.jsxHelpers.get(n);if(o!==void 0)return{node:o.node,bindingPath:o};let r=t.scope.getBinding(n);if(r?.path.isFunctionDeclaration()&&ue(r.path.node))return{node:r.path.node,bindingPath:r.path};if(r?.path.isVariableDeclarator()){let i=r.path.node.init;if((R.isFunctionExpression(i)||R.isArrowFunctionExpression(i))&&ue(i.body))return{node:i,bindingPath:r.path}}return null}function tr(e){return R.isMemberExpression(e.callee)&&!e.callee.computed&&R.isIdentifier(e.callee.property,{name:"map"})}function rs(e){let t=e.parentPath;return t?.isCallExpression()===!0&&(t.node.callee===e.node||tr(t.node)&&t.node.arguments[0]===e.node)}function is(e,t){let n=e.node;if(n.async||n.generator)throw t.buildCodeFrameError("memo-dom: JSX render callbacks must be synchronous");return R.arrowFunctionExpression(n.params.map(o=>R.cloneNode(o,!0)),R.cloneNode(n.body,!0))}function hn(e){if(!e.removed){if(e.isFunctionDeclaration()){e.parentPath?.isExportNamedDeclaration()?e.parentPath.remove():e.remove();return}if(e.isVariableDeclarator()){let t=e.parentPath;if(!t?.isVariableDeclaration())return;t.node.declarations.length===1?t.parentPath?.isExportNamedDeclaration()?t.parentPath.remove():t.remove():e.remove();return}if(e.isArrowFunctionExpression()||e.isFunctionExpression()){let t=e.parentPath;t?.isVariableDeclarator()&&hn(t)}}}function ss(e,t){let n=t.findParent(o=>o.isProgram());if(n===null||!n.isProgram()){hn(t);return}for(let o of n.get("body")){let r=o.isExportNamedDeclaration()?o.get("declaration"):o;if(Array.isArray(r)||r==null)continue;if(r.isFunctionDeclaration()&&r.node.id?.name===e){o.remove();return}if(!r.isVariableDeclaration())continue;let i=r.get("declarations"),s=i.find(a=>a.isVariableDeclarator()&&R.isIdentifier(a.node.id,{name:e}));if(s!==void 0){i.length===1?o.remove():s.remove();return}}hn(t)}function as(e,t){let n=e.parentPath,o=n?.parentPath;if((R.isJSXElement(t)||R.isJSXFragment(t))&&n?.isJSXExpressionContainer()&&(o?.isJSXElement()||o?.isJSXFragment())&&o.node.children.includes(n.node)){n.replaceWith(t);return}e.replaceWith(t)}function nr(e){let t=new Set;for(let[n,o]of e.jsxHelpers)if((o.scope.parent?.getBinding(n)??o.parentPath?.scope.getBinding(n))?.referencePaths.some(i=>i.isIdentifier()&&!rs(i)))throw o.buildCodeFrameError("memo-dom: JSX render functions may only be called in local render composition or passed directly to collection map()");for(let[,n]of e.compPaths){n.scope.crawl(),n.traverse({CallExpression(r){if(!tr(r.node)||r.node.arguments.length!==1)return;let i=r.get("arguments")[0];if(i===void 0||Array.isArray(i)||!i.isIdentifier())return;let s=er(e,i);s!==null&&(i.replaceWith(is(s,i)),t.add(s.bindingPath))}});let o=!0;for(;o;){o=!1,n.scope.crawl();let r=[];n.traverse({CallExpression(i){r.push(i)}});for(let i of r.reverse()){if(i.removed)continue;let s=os(e,i);s!==null&&(as(i,ns(s,i)),t.add(s.bindingPath),o=!0)}}}for(let[n,o]of e.jsxHelpers)ss(n,o);for(let n of t)hn(n)}import*as We from"@babel/types";function ls(e){let t=Ln(e);return We.isIdentifier(t)||We.isMemberExpression(t)||rn(t)}function ds(e,t){let n=e,o=t.get("body");for(;n!==null&&n.parentPath!==o;)n=n.parentPath;return n?.isStatement()===!0?n:null}function cs(e,t){return e.findParent(n=>n.isFunctionDeclaration()||n.isFunctionExpression()||n.isArrowFunctionExpression())===t}function or(e){for(let[,t]of e.compPaths){let n=[];if(t.traverse({CallExpression(s){if(Oe(s.node)===null||!We.isMemberExpression(s.node.callee)||!We.isExpression(s.node.callee.object)||ls(s.node.callee.object)||!cs(s,t))return;let a=ds(s,t);a!==null&&n.push({path:s,source:We.cloneNode(s.node.callee.object,!0),statement:a})}}),n.length===0)continue;let o=t.get("body").get("body"),r=new Map(o.map((s,a)=>[s.node,a]));n.sort((s,a)=>(r.get(s.statement.node)??0)-(r.get(a.statement.node)??0));let i=[];for(let s of n){let a=$(e,"listView");i.push(We.variableDeclarator(We.cloneNode(a),s.source));let l=s.path.get("callee");if(Array.isArray(l)||!l.isMemberExpression())continue;let d=l.get("object");Array.isArray(d)||d.replaceWith(We.cloneNode(a))}n[0].statement.insertBefore(We.variableDeclaration("const",i)),t.scope.crawl()}}import*as P from"@babel/types";function us(e){return{mode:e.objectProps?"object":"positional",names:[...e.props],acceptsUnknown:e.acceptsUnknownProps,bindings:[],params:[],hasWholeDefault:e.hasWholeDefault,renderProps:[...e.renderProps??[]],renderCallbacks:[...e.renderCallbacks??[]],refProps:[...e.refProps??[]]}}function En(e,t){if(e.linkedDynamicComponentCandidates.size===0)return;t.scope.crawl();let n=new Set(Object.keys(t.scope.bindings)),o=new Map([...e.importedComponents].map(([i,s])=>[s.key,i])),r=[];for(let[i,s]of e.linkedDynamicComponentCandidates){let a=[];for(let d of s){let u=o.get(d.key);if(u===void 0){let c=`MDDynamic_${d.imported.replace(/[^A-Za-z0-9_$]/g,"_")}`;u=c;let g=1;for(;n.has(u);)u=`${c}${g++}`;n.add(u),o.set(d.key,u);let S={type:"component",key:d.key,props:[...d.props],objectProps:d.objectProps,acceptsUnknownProps:d.acceptsUnknownProps,hasWholeDefault:d.hasWholeDefault,listLightweight:d.listLightweight,delegatedEvents:d.delegatedEvents,renderProps:[...d.renderProps??[]],renderCallbacks:[...d.renderCallbacks??[]],refProps:[...d.refProps??[]],subtreeReads:[...d.subtreeReads??[]]};e.importedComponents.set(u,S),e.componentProps.set(u,us(S)),r.push(P.importDeclaration(d.imported==="default"?[P.importDefaultSpecifier(P.identifier(u))]:[P.importSpecifier(P.identifier(u),P.isValidIdentifier(d.imported)?P.identifier(d.imported):P.stringLiteral(d.imported))],P.stringLiteral(d.source)))}a.push(u)}let l=[...new Set(a)];e.state.has(i)?e.stateComponentCandidates.set(i,l):e.functionComponentCandidates.set(i,l)}for(let i of r.reverse())t.unshiftContainer("body",i);t.scope.crawl()}function zn(e){let t=e;for(;P.isTSAsExpression(t)||P.isTSTypeAssertion(t)||P.isTSNonNullExpression(t);)t=t.expression;return t}function rr(e){return P.isJSXIdentifier(e)?P.identifier(e.name):P.memberExpression(rr(e.object),P.identifier(e.property.name))}function ir(e,t){let n=ye(t);if(n===null)return null;let[o,...r]=n.split(".");if(o===void 0||r.length===0)return null;let i=e.scope.getBinding(o);if(!i?.path.isVariableDeclarator())return null;let s=i.path.node.init;if(s==null)return null;for(let a of r){if(s=zn(s),!P.isObjectExpression(s))return null;let l=s.properties.find(d=>!P.isObjectProperty(d)||d.computed?!1:(P.isIdentifier(d.key)?d.key.name:P.isStringLiteral(d.key)?d.key.value:null)===a);if(l===void 0||!P.isObjectProperty(l)||!P.isExpression(l.value))return null;s=l.value}return s}function ps(e,t){let n=e.scope.getBinding(t);if(n===void 0)return[];let o=null;return n.path.isFunctionDeclaration()?o=n.path.node:n.path.isVariableDeclarator()&&(P.isFunctionExpression(n.path.node.init)||P.isArrowFunctionExpression(n.path.node.init))&&(o=n.path.node.init),o===null?[]:sr(o)}function sr(e){if(P.isExpression(e.body))return[e.body];let t=[],n=o=>{if(!P.isFunction(o)){if(P.isReturnStatement(o)){P.isExpression(o.argument)&&t.push(o.argument);return}for(let r of P.VISITOR_KEYS[o.type]??[]){let i=o[r];if(Array.isArray(i))for(let s of i)s!=null&&typeof s=="object"&&"type"in s&&n(s);else i!=null&&typeof i=="object"&&"type"in i&&n(i)}}};for(let o of e.body.body)n(o);return t}function ht(e,t,n,o=new Set){let r=zn(t);if(!o.has(r)){if(o.add(r),P.isIdentifier(r)&&(e.comps.has(r.name)||e.importedComponents.has(r.name))){n.add(r.name);return}if(P.isIdentifier(r)){for(let i of e.stateComponentCandidates.get(r.name)??e.functionComponentCandidates.get(r.name)??[])n.add(i);return}if(P.isConditionalExpression(r)){ht(e,r.consequent,n,o),ht(e,r.alternate,n,o);return}if(P.isLogicalExpression(r)){ht(e,r.right,n,o);return}if(P.isObjectExpression(r)){for(let i of r.properties)P.isObjectProperty(i)&&P.isExpression(i.value)&&ht(e,i.value,n,o);return}if(P.isArrayExpression(r)){for(let i of r.elements)i!=null&&!P.isSpreadElement(i)&&ht(e,i,n,o);return}if(P.isCallExpression(r)&&P.isIdentifier(r.callee)){for(let i of e.functionComponentCandidates.get(r.callee.name)??[])n.add(i);return}if(P.isMemberExpression(r)){let i=Pe(r);if(i!==null)for(let s of e.stateComponentCandidates.get(i)??[])n.add(s)}}}function ar(e,t){for(let o of t.node.body){let r=P.isExportNamedDeclaration(o)?o.declaration:o;if(P.isVariableDeclaration(r))for(let i of r.declarations){if(!P.isIdentifier(i.id)||i.init==null)continue;let s=new Set;ht(e,i.init,s),s.size>0&&e.state.has(i.id.name)&&e.stateComponentCandidates.set(i.id.name,[...s])}}let n=!0;for(;n;){n=!1;for(let[o,r]of e.helpers){let i=new Set(e.functionComponentCandidates.get(o)??[]),s=[],a=r.node;(P.isFunctionDeclaration(a)||P.isFunctionExpression(a)||P.isArrowFunctionExpression(a))&&(s=sr(a));for(let l of s)ht(e,l,i);i.size>0&&i.size!==(e.functionComponentCandidates.get(o)?.length??0)&&(e.functionComponentCandidates.set(o,[...i]),n=!0)}}}function Ge(e,t,n,o,r=new Set){let i=zn(n);if(!r.has(i)){if(r.add(i),P.isConditionalExpression(i)){Ge(e,t,i.consequent,o,r),Ge(e,t,i.alternate,o,r);return}if(P.isStringLiteral(i)){if(!/^[A-Za-z][A-Za-z0-9:_-]*$/.test(i.value))throw t.buildCodeFrameError(`memo-dom: '${i.value}' is not a valid dynamic intrinsic tag name`);o.push({compare:P.cloneNode(i),tag:P.jsxIdentifier(i.value)});return}if(P.isIdentifier(i)){if(e.comps.has(i.name)||e.importedComponents.has(i.name)){o.push({compare:P.cloneNode(i),tag:P.jsxIdentifier(i.name)});return}let s=e.stateTagCandidates.get(i.name);if(s!==void 0)for(let l of s)Ge(e,t,P.stringLiteral(l),o,r);let a=t.scope.getBinding(i.name);a?.path.isVariableDeclarator()&&a.path.node.init!=null&&Ge(e,t,a.path.node.init,o,r);return}if(P.isCallExpression(i)&&P.isIdentifier(i.callee)){for(let s of e.functionTagCandidates.get(i.callee.name)??[])Ge(e,t,P.stringLiteral(s),o,r);for(let s of ps(t,i.callee.name))Ge(e,t,s,o,r);for(let s of e.functionComponentCandidates.get(i.callee.name)??[])Ge(e,t,P.identifier(s),o,r);return}if(P.isMemberExpression(i)){let s=ir(t,i);if(s!==null){Ge(e,t,s,o,r);return}let a=Pe(i);if(a===null)return;let l=t.scope.getBinding(a);if(l?.path.isVariableDeclarator()&&l.path.node.init!=null){let d=new Set;ht(e,l.path.node.init,d);for(let u of d)Ge(e,t,P.identifier(u),o,r)}for(let d of e.stateTagCandidates.get(a)??[])Ge(e,t,P.stringLiteral(d),o,r);for(let d of e.stateComponentCandidates.get(a)??[])Ge(e,t,P.identifier(d),o,r)}}}function fs(e){return P.isStringLiteral(e.compare)?`string:${e.compare.value}`:P.isIdentifier(e.compare)?`component:${e.compare.name}`:JSON.stringify(e.compare)}function ms(e,t){if(P.isIdentifier(t)){let n=e.scope.getBinding(t.name);return n?.path.isVariableDeclarator()?[...n.path.node.init==null?[]:[n.path.node.init],...n.constantViolations.flatMap(o=>o.isAssignmentExpression()&&o.node.operator==="="&&P.isExpression(o.node.right)?[o.node.right]:[])]:[]}if(P.isMemberExpression(t)){let n=ir(e,t),o=ye(t),r=[];return o!==null&&(e.getFunctionParent()??e.findParent(a=>a.isProgram()))?.traverse({AssignmentExpression(a){a.node.operator==="="&&P.isMemberExpression(a.node.left)&&ye(a.node.left)===o&&P.isExpression(a.node.right)&&r.push(a.node.right)}}),[...n===null?[]:[n],...r]}return[]}function lr(e,t){let n=P.cloneNode(e,!0);n.openingElement.name=P.cloneNode(t);let o=n.closingElement;return o!=null&&(o.name=P.cloneNode(t)),n}function gs(e,t,n){let o=P.nullLiteral();for(let r=n.length-1;r>=0;r--){let i=n[r];o=P.conditionalExpression(P.binaryExpression("===",P.cloneNode(e,!0),P.cloneNode(i.compare,!0)),lr(t,i.tag),o)}return o}function bs(e){return P.isIdentifier(e)?e.name:P.isMemberExpression(e)?ye(e)??"<member expression>":"<expression>"}function dr(e){let t=new Map;for(let[,n]of e.compPaths){n.scope.crawl();let o=[];n.traverse({JSXElement(r){o.push(r)}});for(let r of o.reverse()){if(r.removed)continue;let i=r.node.openingElement.name;if(P.isJSXNamespacedName(i))throw r.buildCodeFrameError("memo-dom: namespaced JSX tags are not supported");if(P.isJSXIdentifier(i)&&(!/^[A-Z]/.test(i.name)||e.comps.has(i.name)||e.importedComponents.has(i.name)))continue;let s=rr(i),a=ms(r,s),l=[];for(let u of a)Ge(e,r,u,l);let d=[...new Map(l.map(u=>[fs(u),u])).values()];if(d.length===0)throw r.buildCodeFrameError(`memo-dom: dynamic JSX tag '${bs(s)}' has no finite string or linked-component candidates`);for(let u of d){if(!P.isJSXIdentifier(u.tag))continue;let c=e.componentProps.get(u.tag.name);if(c===void 0||c.renderProps.length===0)continue;let g=t.get(u.tag.name);g===void 0&&(g=new Map,t.set(u.tag.name,g));for(let S of r.node.openingElement.attributes){if(P.isJSXSpreadAttribute(S)||!P.isJSXIdentifier(S.name)||!c.renderProps.includes(S.name.name))continue;let y=$e(S.value),p=g.get(S.name.name)??{scalar:!1,jsx:!1,at:r};y!==null&&ue(y)?p.jsx=!0:p.scalar=!0,g.set(S.name.name,p)}}if(d.length===1){r.replaceWith(lr(r.node,d[0].tag));continue}r.replaceWith(P.jsxFragment(P.jsxOpeningFragment(),P.jsxClosingFragment(),[P.jsxExpressionContainer(gs(s,r.node,d))]))}n.scope.crawl()}for(let[n,o]of t){let r=e.componentProps.get(n);for(let[i,s]of o){if(s.scalar&&s.jsx)throw s.at.buildCodeFrameError(`memo-dom: dynamic component prop '${i}' is used as both scalar data and JSX content`);s.scalar&&(r.renderProps=r.renderProps.filter(a=>a!==i))}}}import*as ee from"@babel/types";function Kn(e){return ee.isExportNamedDeclaration(e)?e.declaration??null:ee.isDeclaration(e)?e:null}function cr(e){let t=new Map;for(let n of e.body){let o=Kn(n);ee.isTSTypeAliasDeclaration(o)&&t.set(o.id.name,o.typeAnnotation)}return t}function dt(e,t,n=new Set){if(ee.isTSLiteralType(e)&&ee.isStringLiteral(e.literal))return[e.literal.value];if(ee.isTSUnionType(e))return e.types.flatMap(o=>dt(o,t,n));if(ee.isTSIntersectionType(e))return e.types.flatMap(o=>dt(o,t,n));if(ee.isTSParenthesizedType(e))return dt(e.typeAnnotation,t,n);if(ee.isTSTypeLiteral(e))return e.members.flatMap(o=>(ee.isTSPropertySignature(o)||ee.isTSIndexSignature(o))&&ee.isTSTypeAnnotation(o.typeAnnotation)&&ee.isTSType(o.typeAnnotation.typeAnnotation)?dt(o.typeAnnotation.typeAnnotation,t,n):[]);if(ee.isTSMappedType(e)&&e.typeAnnotation!=null&&ee.isTSType(e.typeAnnotation))return dt(e.typeAnnotation,t,n);if(ee.isTSTypeReference(e)&&ee.isIdentifier(e.typeName)){let o=e.typeName.name;if((o==="Record"||o==="Readonly"||o==="Partial")&&ee.isTSTypeParameterInstantiation(e.typeArguments)){let s=o==="Record"?e.typeArguments.params[1]:e.typeArguments.params[0];if(s!==void 0&&ee.isTSType(s))return dt(s,t,n)}if(n.has(o))return[];let r=t.get(o);if(r===void 0)return[];let i=new Set(n);return i.add(o),dt(r,t,i)}return[]}function yn(e){let t=cr(e),n=new Map;for(let o of e.body){let r=Kn(o);if(ee.isVariableDeclaration(r))for(let i of r.declarations){if(!ee.isIdentifier(i.id)||!ee.isTSTypeAnnotation(i.id.typeAnnotation))continue;let s=[...new Set(dt(i.id.typeAnnotation.typeAnnotation,t))];s.length>0&&n.set(i.id.name,s)}}return n}function Hn(e){let t=cr(e),n=new Map,o=(r,i)=>{if(!ee.isTSTypeAnnotation(i)||!ee.isTSType(i.typeAnnotation))return;let s=[...new Set(dt(i.typeAnnotation,t))];s.length>0&&n.set(r,s)};for(let r of e.body){let i=Kn(r);if(ee.isFunctionDeclaration(i)&&i.id!=null){o(i.id.name,i.returnType);continue}if(ee.isVariableDeclaration(i))for(let s of i.declarations)ee.isIdentifier(s.id)&&(ee.isArrowFunctionExpression(s.init)||ee.isFunctionExpression(s.init))&&o(s.id.name,s.init.returnType)}return n}import*as ot from"@babel/types";import*as Ee from"@babel/types";function Ht(e,t){let n=[],o=[],r=-1;for(let s=0;s<e.length;s++)Ee.isJSXSpreadAttribute(e[s])&&(r=s);let i=[];for(let s=0;s<e.length;s++){let a=e[s];if(Ee.isJSXSpreadAttribute(a)){n.push(Ee.spreadElement(Ee.cloneNode(a.argument))),o.push(Ee.cloneNode(a.argument));continue}let l=Ae(a.name);if(l==="key"&&t.skipKey)continue;let d=hs(a,t.fail),u=t.attributeValue?.(l,d)??d,c=/^on[A-Z]/.test(l)&&t.eventValue!==void 0?t.eventValue(l,u):u;n.push(Ee.objectProperty(Ee.isValidIdentifier(l)?Ee.identifier(l):Ee.stringLiteral(l),c,!1,Ee.isIdentifier(c)&&c.name===l)),o.push(Ee.cloneNode(d)),/^on[A-Z]/.test(l)&&s>r&&i.push(l)}return{expression:Ee.objectExpression(n),sources:o,safeEventKeys:i}}function Ae(e){return Ee.isJSXIdentifier(e)?e.name:`${e.namespace.name}:${e.name.name}`}function hs(e,t){return e.value==null?Ee.booleanLiteral(!0):Ee.isStringLiteral(e.value)?Ee.cloneNode(e.value):Ee.isJSXExpressionContainer(e.value)&&Ee.isExpression(e.value.expression)?Ee.cloneNode(e.value.expression):t(`memo-dom: attribute '${Ae(e.name)}' must contain a JavaScript expression`)}function Sn(e,t,n=new Set){let o=e.importedComponents.get(t);if(o!==void 0)return new Set(o.subtreeReads??[]);if(n.has(t))return new Set;n.add(t);let r=new Set(e.compReads.get(t)??[]);for(let s of e.effects.get(t)??[]){for(let a of s.moduleReads)r.add(a);for(let a of s.conditionModuleReads)r.add(a)}let i=e.compPaths.get(t);return i!==void 0&&i.traverse({JSXElement(s){let a=s.node.openingElement.name;if(!(!ot.isJSXIdentifier(a)||!/^[A-Z]/.test(a.name)))for(let l of Sn(e,a.name,n))r.add(l)}}),n.delete(t),r}function ur(e){for(let[t,n]of e.compPaths){let o=e.compReads.get(t);o!==void 0&&n.traverse({JSXAttribute(r){let i=r.parentPath;if(!i?.isJSXOpeningElement())return;let s=i.node.name;if(!ot.isJSXIdentifier(s))return;let a=Ae(r.node.name);if(e.componentProps.get(s.name)?.renderCallbacks.includes(a)!==!0)return;let l=r.node.value;!ot.isJSXExpressionContainer(l)||!ot.isExpression(l.expression)||Xe(l.expression,d=>{if(ot.isJSXOpeningElement(d)&&ot.isJSXIdentifier(d.name)&&/^[A-Z]/.test(d.name.name))for(let u of Sn(e,d.name.name))o.add(u)})}})}}import*as Et from"@babel/types";function pr(e){for(let[t,n]of e.compPaths){let o=e.componentProps.get(t);n.traverse({JSXAttribute(r){if(Ae(r.node.name)!=="ref")return;let i=r.node.value;if(!(!Et.isJSXExpressionContainer(i)||!Et.isExpression(i.expression)))for(let s of fr(e,t,i.expression))o.refProps.includes(s)||o.refProps.push(s)}})}}function fr(e,t,n){let o=lt(e,t,n);if(o!==null)return[o];if(!Et.isArrayExpression(n))return[];let r=[];for(let i of n.elements)i===null||Et.isSpreadElement(i)||r.push(...fr(e,t,i));return r}import*as kt from"@babel/types";function xn(e){let t=!1;return Xe(e,n=>{if(t||!kt.isJSXOpeningElement(n))return;let o=n.name;!kt.isJSXIdentifier(o)||!/^[a-z]/.test(o.name)||(t=n.attributes.some(r=>kt.isJSXAttribute(r)&&kt.isJSXIdentifier(r.name)&&/^on[A-Z]/.test(r.name.name)))}),t}import*as je from"@babel/types";function Un(e){let t=(o,r)=>{let i=Ue(e,o),s=e.readers.get(i);s||e.readers.set(i,s=new Set);for(let a of r)s.add(a)};for(let[o,r]of e.compReads){if(r.size===0)continue;let i=Tn(e,o);for(let s of r)t(s,i)}for(let{owner:o,suffix:r,vars:i}of e.rowReads.values()){let s=bt(e,qe(e,o).flatMap(a=>[`${a}/${r}/Row[*]`,`${a}/${r}/Row[*]/*`]));for(let a of i)t(a,s)}for(let{owner:o,suffix:r,vars:i}of e.condReads.values()){let s=bt(e,qe(e,o).flatMap(a=>[`${a}/${r}`,`${a}/${r}/*`]));for(let a of i)t(a,s)}for(let[o,r]of e.effects){let i=Tn(e,o).filter(s=>!s.endsWith("/*"));for(let s of r){let a=i.map(d=>`${d}/$effects/${s.index}`),l=s.condition===null?a:a.map(d=>`${d}/$active`);for(let d of s.moduleReads)t(d,l);for(let d of s.conditionModuleReads)t(d,a)}}for(let o of e.moduleEffects){let r=o.condition===null?o.entityId:`${o.entityId}/$active`;for(let i of o.moduleReads)t(i,[r]);for(let i of o.conditionModuleReads)t(i,[o.entityId])}for(let[o,r]of e.computeds){let i=`${e.rootId}/$computed/${encodeURIComponent(e.moduleId)}#${o}`;for(let s of r.reads)t(s,[i])}for(let o of e.moduleControlFlow)for(let r of o.sources)t(r,[o.entityId]);if(e.readers.size===0)return null;let n=[...e.readers.entries()].sort(([o],[r])=>o<r?-1:1).map(([o,r])=>je.objectProperty(je.stringLiteral(o),je.arrayExpression([...r].sort().map(i=>je.stringLiteral(i)))));return je.expressionStatement(je.callExpression(Z(e,"installAccessTable"),[je.objectExpression([je.objectProperty(je.identifier("readers"),je.objectExpression(n))]),je.stringLiteral(e.rootId)]))}function gr(e,t){let n=t?.parentPath;if(!n?.isJSXAttribute())return!1;let o=n.parentPath;if(!o.isJSXOpeningElement())return!1;let r=o.node.name;if(!k.isJSXIdentifier(r)||!/^[A-Z]/.test(r.name))return!1;let i=n.node.name,s=k.isJSXIdentifier(i)?i.name:i.name.name;return e.componentProps.get(r.name)?.renderProps.includes(s)===!0}function mr(e,t){let n=t.parentPath,o=n?.parentPath;if(!n?.isJSXExpressionContainer()||!o?.isJSXElement()&&!o?.isJSXFragment()&&!gr(e,n))throw t.buildCodeFrameError("memo-dom: conditional rendering must be a direct JSX child: <div>{cond ? <A/> : <B/>}</div>");t.skip()}function Es(e,t){for(let n of t.get("body"))if(!(!n.isImportDeclaration()||n.node.importKind==="type"))for(let o of n.node.specifiers){if(k.isImportSpecifier(o)&&o.importKind==="type")continue;let r=o.local.name;if(!(e.importedState.has(r)||e.importedFunctions.has(r)||e.importedComponents.has(r)))throw n.buildCodeFrameError(`memo-dom: value import '${r}' requires compileModules() so its reactive identity can be linked`)}}function ys(e,t){let n=yn(t.node);for(let o of t.node.body){let r=k.isExportNamedDeclaration(o)?o.declaration:o;if(k.isVariableDeclaration(r)){for(let i of r.declarations)if(k.isIdentifier(i.id)&&(r.kind==="let"||r.kind==="var"?pt(e,i.id.name,"let"):r.kind==="const"&&(Ct(i.init)?pt(e,i.id.name,"store"):Pt(i.init)&&pt(e,i.id.name,"const")),e.state.has(i.id.name))){let s=n.get(i.id.name);s!==void 0&&e.stateTagCandidates.set(i.id.name,[...s])}}}}function Ss(e,t){t.traverse({FunctionDeclaration(n){let o=n.node.id?.name;if(o&&!e.comps.has(o)&&!e.helpers.has(o)&&!e.jsxHelpers.has(o))if(De(n))if(/^[A-Z]/.test(o)){e.comps.set(o,{parents:new Set,jsxCount:0}),e.compPaths.set(o,n),xn(n.node.body)&&e.componentsWithHostEvents.add(o);try{e.componentProps.set(o,nn(n.node.params))}catch(r){throw n.buildCodeFrameError(`memo-dom: invalid props for component '${o}': ${r instanceof Error?r.message:String(r)}`)}}else e.jsxHelpers.set(o,n);else e.helpers.set(o,n);n.skip()},VariableDeclarator(n){if(!n.scope.path.isProgram()||!k.isIdentifier(n.node.id))return;let o=n.get("init");(o.isArrowFunctionExpression()||o.isFunctionExpression())&&(ue(o.node.body)?/^[A-Z]/.test(n.node.id.name)||e.jsxHelpers.set(n.node.id.name,o):e.helpers.set(n.node.id.name,o),o.skip())}});for(let n of t.get("body")){let o=n.isExportNamedDeclaration()?n.get("declaration"):n;if(!(Array.isArray(o)||!o.isVariableDeclaration()))for(let r of o.get("declarations")){if(!r.isVariableDeclarator())continue;let i=r.node.id,s=r.get("init");!k.isIdentifier(i)||/^[A-Z]/.test(i.name)||Array.isArray(s)||!s.isArrowFunctionExpression()&&!s.isFunctionExpression()||!ue(s.node.body)||(e.helpers.delete(i.name),e.jsxHelpers.set(i.name,s))}}}function Cn(e,t,n=new Set){if(k.isTSStringKeyword(e)||k.isTSNumberKeyword(e)||k.isTSBooleanKeyword(e)||k.isTSBigIntKeyword(e)||k.isTSSymbolKeyword(e)||k.isTSNullKeyword(e)||k.isTSUndefinedKeyword(e)||k.isTSLiteralType(e))return!0;if(k.isTSParenthesizedType(e))return Cn(e.typeAnnotation,t,n);if(k.isTSUnionType(e))return e.types.every(o=>Cn(o,t,n));if(k.isTSTypeReference(e)&&k.isIdentifier(e.typeName)){let o=e.typeName.name;if(n.has(o))return!1;let r=new Set(n);r.add(o);for(let i of t.body){let s=k.isExportNamedDeclaration(i)?i.declaration:i;if(k.isTSTypeAliasDeclaration(s)&&s.id.name===o)return Cn(s.typeAnnotation,t,r)}}return!1}function xs(e,t){let n=l=>k.isStringLiteral(l)||k.isNumericLiteral(l)||k.isBooleanLiteral(l)||k.isBigIntLiteral(l)||k.isUnaryExpression(l)&&(l.operator==="+"||l.operator==="-")&&k.isNumericLiteral(l.argument);for(let l of e.node.params){if(k.isTSParameterProperty(l))continue;if(k.isAssignmentPattern(l)&&k.isIdentifier(l.left,{name:t})&&n(l.right))return!0;if(k.isAssignmentPattern(l)&&k.isObjectPattern(l.left)&&k.isObjectExpression(l.right)){let u=l.right.properties.find(c=>!k.isObjectProperty(c)||c.computed?!1:(k.isIdentifier(c.key)?c.key.name:k.isStringLiteral(c.key)?c.key.value:null)===t);if(k.isObjectProperty(u)&&k.isExpression(u.value)&&n(u.value))return!0}let d=k.isAssignmentPattern(l)?l.left:l;if(k.isObjectPattern(d))for(let u of d.properties){if(!k.isObjectProperty(u)||u.computed)continue;if((k.isIdentifier(u.key)?u.key.name:k.isStringLiteral(u.key)?u.key.value:null)===t&&k.isAssignmentPattern(u.value)&&n(u.value.right))return!0}}let o=e.node.params[0];if(o==null||k.isTSParameterProperty(o))return!1;let r=k.isAssignmentPattern(o)?o.left:o;if(!k.isIdentifier(r)&&!k.isObjectPattern(r)&&!k.isArrayPattern(r))return!1;let i=r.typeAnnotation;if(!k.isTSTypeAnnotation(i))return!1;let s=e.findParent(l=>l.isProgram());if(!s?.isProgram())return!1;let a=i.typeAnnotation;if(k.isTSTypeReference(a)&&k.isIdentifier(a.typeName)){let l=a.typeName.name,d=s.node.body.map(u=>k.isExportNamedDeclaration(u)?u.declaration:u).find(u=>(k.isTSInterfaceDeclaration(u)||k.isTSTypeAliasDeclaration(u))&&u.id.name===l);k.isTSInterfaceDeclaration(d)?a=k.tsTypeLiteral(d.body.body):k.isTSTypeAliasDeclaration(d)&&(a=d.typeAnnotation)}if(!k.isTSTypeLiteral(a))return!1;for(let l of a.members){if(!k.isTSPropertySignature(l)||l.computed)continue;if((k.isIdentifier(l.key)?l.key.name:k.isStringLiteral(l.key)?l.key.value:null)===t&&k.isTSTypeAnnotation(l.typeAnnotation))return Cn(l.typeAnnotation.typeAnnotation,s.node)}return!1}function _n(e,t=new Set){if(ue(e.node))return!0;if(t.has(e.node))return!1;if(t.add(e.node),e.isIdentifier()){let n=e.scope.getBinding(e.node.name);if(n?.path.isVariableDeclarator()){let o=n.path.get("init");return!Array.isArray(o)&&o.node!=null?_n(o,t):!1}}if(e.isMemberExpression()){let n=e.get("object");return!Array.isArray(n)&&_n(n,t)}return!1}function Cs(e){let t=new Map;for(let[r,i]of e.compPaths){let s=new Set;if(t.set(r,s),i.traverse({JSXExpressionContainer(a){if(!a.parentPath?.isJSXElement()&&!a.parentPath?.isJSXFragment())return;let l=a.node.expression;if(!k.isExpression(l))return;let d=lt(e,r,l);d!==null&&(xs(i,d)||s.add(d))}}),(i.parentPath?.isExportNamedDeclaration()||i.parentPath?.isExportDefaultDeclaration())&&!e.linkedComponentRenderProps.has(r)){let a=e.componentProps.get(r);for(let l of s)a.renderProps.includes(l)||a.renderProps.push(l)}}let n=new Map;for(let[r,i]of e.compPaths)i.traverse({JSXElement(s){let a=s.node.openingElement.name;if(!k.isJSXIdentifier(a)||!e.comps.has(a.name))return;let l=e.componentProps.get(a.name),d=t.get(a.name);if(d===void 0)return;let u=n.get(a.name);u===void 0&&(u=new Map,n.set(a.name,u)),d.has("children")&&s.node.children.some(c=>!k.isJSXText(c)||c.value.trim()!=="")&&!l.renderProps.includes("children")&&(l.renderProps.push("children"),u.set("children",{scalar:!1,jsx:!0,at:s}));for(let c of s.get("openingElement").get("attributes")){if(!c.isJSXAttribute())continue;let g=c.node.name,S=k.isJSXIdentifier(g)?g.name:g.name.name;if(!d.has(S))continue;let y=u.get(S)??{scalar:!1,jsx:!1,at:c},p=c.get("value"),f=!1;if(p.isJSXExpressionContainer()&&k.isExpression(p.node.expression)){let v=p.get("expression");!Array.isArray(v)&&(_n(v)||k.isExpression(v.node)&&lt(e,r,v.node)!==null)&&(f=!0)}f?y.jsx=!0:y.scalar=!0,u.set(S,y)}}});for(let[r,i]of n){let s=e.componentProps.get(r);for(let[a,l]of i){if(l.scalar&&l.jsx){if(a==="children"){s.renderProps.includes(a)||s.renderProps.push(a);continue}throw l.at.buildCodeFrameError(`memo-dom: prop '${a}' on <${r}> is used as both scalar data and JSX content`)}l.jsx?s.renderProps.includes(a)||s.renderProps.push(a):l.scalar&&(s.renderProps=s.renderProps.filter(d=>d!==a))}}let o=!0;for(;o;){o=!1;for(let[r,i]of e.compPaths){let s=e.componentProps.get(r);i.traverse({JSXAttribute(a){let l=a.get("value");if(!l.isJSXExpressionContainer()||!k.isExpression(l.node.expression))return;let d=lt(e,r,l.node.expression);if(d===null||s.renderProps.includes(d))return;let u=a.parentPath;if(!u.isJSXOpeningElement())return;let c=u.node.name;if(!k.isJSXIdentifier(c)||!/^[A-Z]/.test(c.name))return;let g=e.componentProps.get(c.name),S=a.node.name,y=k.isJSXIdentifier(S)?S.name:S.name.name;g?.renderProps.includes(y)===!0&&(s.renderProps.push(d),o=!0)}})}}for(let[r,i]of e.linkedComponentRenderProps){let s=e.componentProps.get(r);s!==void 0&&(s.renderProps=[...i])}}function Ps(e,t){let n=e.compPaths.get(t),o=e.comps.get(t);n.traverse({JSXElement(r){let i=r.node.openingElement;if(!k.isJSXIdentifier(i.name))throw r.buildCodeFrameError("memo-dom: namespaced or member-expression JSX tags are not supported (L1)");for(let a of i.attributes)if(!k.isJSXSpreadAttribute(a)&&a.name.name==="key"){if(Po(e,r))continue;throw r.buildCodeFrameError("memo-dom: key={...} is only meaningful on list rows: items.map(item => <Row key={item.id} />)")}let s=i.name.name;if(/^[A-Z]/.test(s)){let a=e.comps.has(s);if(!a&&!e.importedComponents.has(s))throw r.buildCodeFrameError(`memo-dom: <${s} /> is not a linked component factory`);a&&e.comps.get(s).parents.add(t);let l=e.childRefCounts.get(t);l||e.childRefCounts.set(t,l=new Map),l.set(s,(l.get(s)??0)+1),(r.node.children.some(d=>!k.isJSXText(d)||d.value.trim()!=="")||i.attributes.some(d=>{if(k.isJSXSpreadAttribute(d)||e.componentProps.get(s)?.renderProps.includes(k.isJSXIdentifier(d.name)?d.name.name:d.name.name.name)!==!0)return!1;let u=$e(d.value);return u!==null&&ue(u)}))&&e.renderSlotOwners.add(t);return}o.jsxCount++},ConditionalExpression(r){De(r)&&mr(e,r)},LogicalExpression(r){if(De(r)){if(r.node.operator!=="&&"&&r.node.operator!=="||")throw r.buildCodeFrameError("memo-dom: only && / || conditionals are supported (R8 L1), not ??");mr(e,r)}},CallExpression(r){let i=Oe(r.node);if(i&&(De(r)||Ft(e,t,i)!==null)){let s=r.parentPath,a=s?.parentPath;if(!s?.isJSXExpressionContainer()||!a?.isJSXElement()&&!a?.isJSXFragment()&&!gr(e,s))throw r.buildCodeFrameError("memo-dom: list rendering must be a direct JSX child: <ul>{items.map(item => <Row />)}</ul>");r.skip()}}})}function ws(e){let t=e.parentPath;return t.isCallExpression()&&t.node.callee===e.node}function vs(e,t){let n=ye(t.node);if(!n||!n.includes("."))return null;let o=n.split(".")[0];if(e.state.get(o)!=="store"||t.scope.getBinding(o)?.scope.path.isProgram()!==!0)return null;let r=t.parentPath;return r.isAssignmentExpression({operator:"="})&&r.node.left===t.node||ws(t)?null:n}function ks(e){for(let[a]of e.comps){let g=function(x,I,J){let F=Oe(x.node);if(F===null||!De(x))return;let N=wt(e,F,x,a,J),K=`${I}/${N.suffix}`;if(N.form==="component"){let _=e.listedSites.get(N.rowComp)??[];_.some(H=>H.owner===a&&H.suffix===K)||_.push({owner:a,suffix:K,itemParam:N.itemParam,keyExpr:N.keyExpr,sourceKey:N.sourceKey,sourceLocal:N.sourceLocal}),e.listedSites.set(N.rowComp,_)}else f(x,N,K);x.skip()},S=function(x,I,J){let F=x.node.openingElement.name;if(!k.isJSXIdentifier(F)||!/^[A-Z]/.test(F.name))return;if(!e.comps.has(F.name)&&!e.importedComponents.has(F.name))throw x.buildCodeFrameError(`memo-dom: <${F.name} /> is not a linked component factory`);let N=J.get(F.name)??0;J.set(F.name,N+1);let K=N===0?F.name:`${F.name}[${N}]`,_=`${I}/${K}`,H=e.conditionalComponentSites.get(F.name)??[];H.some(T=>T.owner===a&&T.suffix===_)||H.push({owner:a,suffix:_}),e.conditionalComponentSites.set(F.name,H)},y=function(x,I,J){let F=x.node.openingElement.name;if(!k.isJSXIdentifier(F)||!/^[A-Z]/.test(F.name))return;if(!e.comps.has(F.name)&&!e.importedComponents.has(F.name))throw x.buildCodeFrameError(`memo-dom: <${F.name} /> is not a linked component factory`);let N=J.get(F.name)??0;J.set(F.name,N+1);let K=N===0?F.name:`${F.name}[${N}]`,_=`${I}/Row[*]/${K}`,H=e.rowComponentSites.get(F.name)??[];H.some(T=>T.owner===a&&T.suffix===_)||H.push({owner:a,suffix:_}),e.rowComponentSites.set(F.name,H)},p=function(x,I){let J=e.listedSites.get(x.rowComp)??[];J.some(F=>F.owner===a&&F.suffix===I)||J.push({owner:a,suffix:I,itemParam:x.itemParam,keyExpr:x.keyExpr,sourceKey:x.sourceKey,sourceLocal:x.sourceLocal}),e.listedSites.set(x.rowComp,J)},f=function(x,I,J){let F=x.get("arguments")[0];if(F===void 0)return;let N=new Set,K=new Map,_=new Map;F.traverse({Identifier(H){H.node.name!==I.itemParam&&e.state.has(H.node.name)&&H.scope.getBinding(H.node.name)?.scope.path.isProgram()===!0&&N.add(H.node.name)},JSXElement(H){y(H,J,K)},CallExpression(H){let T=Oe(H.node);if(T!==null&&De(H)){let ne=wt(e,T,H,a,_,I),G=`${J}/Row[*]/${ne.suffix}`;ne.form==="component"?p(ne,G):f(H,ne,G),H.skip();return}let re=H.node.callee;if(k.isIdentifier(re)&&(e.helpers.has(re.name)||e.importedFunctions.has(re.name))){let ne=e.importedFunctions.get(re.name)??Ve(e,re.name);for(let G of ne.reads)N.add(G)}}}),N.size>0&&e.rowReads.set(`${a}/${J}`,{owner:a,suffix:J,vars:N})},v=function(x,I=null){let J=x.node;if(!De(x))return;let F=an(J,x,c),N=I===null?F.suffix:`${I}/${F.suffix}`,K=[];if(x.isConditionalExpression()){let H=x;for(;H.isConditionalExpression();)K.push(H.get("consequent")),H=H.get("alternate");K.push(H)}else K.push(x.get("right"));for(let H of K){let T=new Map,re=new Map;if((H.isConditionalExpression()||H.isLogicalExpression())&&De(H)){v(H,N);continue}H.isJSXElement()&&S(H,N,re),H.traverse({ConditionalExpression(ne){De(ne)&&(v(ne,N),ne.skip())},LogicalExpression(ne){De(ne)&&(v(ne,N),ne.skip())},JSXElement(ne){S(ne,N,re)},CallExpression(ne){g(ne,N,T)}})}let _=en(e,J);_.size>0&&I===null&&e.condReads.set(`${a}/${N}`,{owner:a,suffix:N,vars:_}),x.skip()};var t=g,n=S,o=y,r=p,i=f,s=v;let l=e.compPaths.get(a),d=new Set,u=new Map,c={count:0};l.traverse({JSXAttribute(x){let I=x.node.name;(k.isJSXIdentifier(I,{name:"ref"})||k.isJSXNamespacedName(I)&&I.namespace.name==="ref")&&x.skip()},ConditionalExpression(x){v(x)},LogicalExpression(x){v(x)},CallExpression(x){if(k.isIdentifier(x.node.callee,{name:"effect"})&&x.scope.getBinding("effect")===void 0){x.skip();return}let I=Oe(x.node);if(I&&(De(x)||Ft(e,a,I)!==null)){let F=wt(e,I,x,a,u);if(F.sourceLocal||d.add(F.sourceKey),F.form==="component"){for(let K of F.jsx.openingElement.attributes){if(k.isJSXSpreadAttribute(K))continue;let _=K,H=k.isJSXIdentifier(_.name)?_.name.name:`${_.name.namespace.name}:${_.name.name.name}`;if(H==="key"||H==="ref"||e.componentProps.get(F.rowComp)?.refProps.includes(H)===!0)continue;let T=$e(_.value);T&&Xe(T,re=>{if(k.isIdentifier(re)&&e.state.has(re.name)&&x.scope.getBinding(re.name)?.scope.path.isProgram()===!0&&d.add(re.name),k.isMemberExpression(re)){let ne=ye(re);if(ne!==null&&ne.includes(".")){let G=ne.split(".")[0];e.state.get(G)==="store"&&x.scope.getBinding(G)?.scope.path.isProgram()===!0&&d.add(ne)}}})}let N=e.listedSites.get(F.rowComp)??[];N.some(K=>K.owner===a&&K.suffix===F.suffix)||N.push({owner:a,suffix:F.suffix,itemParam:F.itemParam,keyExpr:F.keyExpr,sourceKey:F.sourceKey,sourceLocal:F.sourceLocal}),e.listedSites.set(F.rowComp,N)}else f(x,F,F.suffix);x.skip();return}let J=x.node.callee;if(k.isIdentifier(J)&&(e.helpers.has(J.name)||e.importedFunctions.has(J.name))&&x.scope.getBinding(J.name)?.scope.path.isProgram()===!0){let F=e.importedFunctions.get(J.name)??Ve(e,J.name);for(let N of F.reads)d.add(N)}},Identifier(x){if(!e.state.has(x.node.name)||x.scope.getBinding(x.node.name)?.scope.path.isProgram()!==!0)return;let I=x.parentPath;I.isAssignmentExpression({operator:"="})&&I.node.left===x.node||d.add(x.node.name)},MemberExpression(x){let I=vs(e,x);I!==null&&d.add(I)}}),e.compReads.set(a,d)}}function Pn(e,t){Es(e,t),ys(e,t),Ss(e,t),pr(e),wo(e),nr(e),ar(e,t),Cs(e),Yo(e),dr(e),or(e),Ko(e),zo(e,t),Wo(e,t,On),Ho(e),_o(e),qo(e),Jo(e,t);for(let[o]of e.comps)Ps(e,o);ks(e),ur(e);for(let[o]of e.comps)qe(e,o);let n=new Set([...e.listedSites.keys(),...e.linkedComponentRows.keys()]);for(let o of n){if(e.importedComponents.has(o))continue;let r=e.listedSites.get(o)??[],i=e.compPaths.get(o);if((r.length>0||e.linkedComponentRows.has(o))&&(e.comps.get(o).parents.size>0||(e.conditionalComponentSites.get(o)?.length??0)>0))throw i.buildCodeFrameError(`memo-dom: <${o}> is used both as a list row and as a static child \u2014 split it into two components (R7 L1)`)}}import*as D from"@babel/types";import*as h from"@babel/types";import*as Ce from"@babel/types";import*as se from"@babel/types";function Nt(){return{writes:new Set,rootFallback:!1,rowLocal:!1,rowOwnerLocal:!1,instanceLocal:!1,instanceWrites:new Set,eventOrigin:null}}function ct(e,t){e.instanceLocal=!0,e.instanceWrites.add(t)}function Lt(e,t,n,o){let r=t.rowLocal&&o!==void 0?se.expressionStatement(o.refreshVar!==void 0?se.callExpression(se.identifier(o.refreshVar),[]):se.callExpression(Z(e,"markDirty"),[se.identifier(o.rowIdVar)])):null,i=null;if(t.instanceLocal&&n!==null){let d=e.instanceReasonIds.get(n),u=[...t.instanceWrites].map(g=>d?.get(g)).filter(g=>g!==void 0).sort((g,S)=>g-S),c=t.instanceWrites.size>0&&u.length===t.instanceWrites.size;i=se.expressionStatement(se.callExpression(Z(e,"markDirty"),[Le(e,n),...c?[u.length===1?se.numericLiteral(u[0]):bo(e,u)]:[]]))}let s=t.rowOwnerLocal&&o?.ownerIdVar!==void 0?se.expressionStatement(se.callExpression(Z(e,"markDirty"),[se.identifier(o.ownerIdVar)])):null,a=d=>{let u=[];return t.eventOrigin!==null&&u.push(t.eventOrigin),r!==null&&u.push(r),s!==null&&u.push(s),i!==null&&u.push(i),d!==null&&u.push(d),u.length===0?null:u.length===1?u[0]:se.blockStatement(u)};if(t.rootFallback)return a(se.expressionStatement(se.callExpression(Z(e,"markDirtySubtree"),[se.stringLiteral(e.rootId)])));if(t.writes.size===0)return a(null);let l=[...t.writes].sort();return a(se.expressionStatement(se.callExpression(Z(e,"commitWrites"),[Ot(e,l)])))}function br(e,t,n){if(se.isBlockStatement(t.body)){qn(t.body,n),t.body.body.push(n);return}let o=$(e,"returnValue");t.body=se.blockStatement([se.variableDeclaration("const",[se.variableDeclarator(o,t.body)]),n,se.returnStatement(se.cloneNode(o))])}function qn(e,t){if(!se.isFunction(e))for(let n of se.VISITOR_KEYS[e.type]??[]){let o=e[n];if(Array.isArray(o))for(let r=0;r<o.length;r++){let i=o[r];!i||typeof i!="object"||!("type"in i)||se.isFunction(i)||(se.isReturnStatement(i)?(o.splice(r,0,se.cloneNode(t)),r++):qn(i,t))}else if(o&&typeof o=="object"&&"type"in o){if(se.isFunction(o))continue;se.isReturnStatement(o)?e[n]=se.blockStatement([se.cloneNode(t),o]):qn(o,t)}}}import*as Se from"@babel/types";function yt(e,t,n,o){if(o===void 0&&n?.refreshVar!==void 0)return Se.expressionStatement(Se.callExpression(Se.identifier(n.refreshVar),[]));let r=o??(n!==void 0?Se.identifier(n.rowIdVar):t!==null?Le(e,t):Se.stringLiteral(e.rootId));return Se.expressionStatement(Se.callExpression(Z(e,"markDirty"),[Se.cloneNode(r)]))}function At(e,t,n){let o=$(e,"event"),r=$(e,"returnValue");return Se.arrowFunctionExpression([o],Se.blockStatement([Se.variableDeclaration("const",[Se.variableDeclarator(r,Se.callExpression(Se.cloneNode(t),[Se.cloneNode(o)]))]),n,Se.returnStatement(Se.cloneNode(r))]))}import yr from"@babel/traverse";import*as Y from"@babel/types";function Ns(e,t,n){if(n.key===null)return null;let o=e.componentProps.get(t);if(o===void 0)return null;let r=Be(o);if(n.root===r){let[s,...a]=n.key.split(".").slice(1);return s===void 0?null:{name:s,path:a}}let i=He(o,n.root);return i===null?null:{name:i,path:n.key.split(".").slice(1)}}function Gn(e,t,n,o,r){let i=Ns(e,t,o);if(i===null)return!1;n===void 0?ct(r,o.root):r.rowLocal=!0;let s=e.linkedComponentPropSources.get(t)?.get(i.name);if(s===void 0)return r.rootFallback=!0,!0;r.rootFallback||=s.rootFallback;let a=i.path.length===0?"":`.${i.path.join(".")}`;for(let l of s.keys)r.writes.add(`${l}${a}`);return!0}import*as he from"@babel/types";function wn(e){return he.isIdentifier(e)||he.isObjectPattern(e)||he.isArrayPattern(e)||he.isAssignmentPattern(e)||he.isRestElement(e)}function Is(e){let t=e;for(;he.isTSAsExpression(t)||he.isTSTypeAssertion(t)||he.isTSNonNullExpression(t)||he.isTSSatisfiesExpression(t);)t=t.expression;return t}function Ut(e,t,n){if(he.isIdentifier(t)){e.set(t.name,n);return}if(he.isAssignmentPattern(t)){wn(t.left)&&Ut(e,t.left,n);return}if(!he.isRestElement(t)){if(he.isArrayPattern(t)){for(let o=0;o<t.elements.length;o++){let r=t.elements[o];wn(r)&&Ut(e,r,mt(n,[String(o)]))}return}if(he.isObjectPattern(t))for(let o of t.properties){if(he.isRestElement(o))continue;if(o.computed||!he.isIdentifier(o.key)&&!he.isStringLiteral(o.key)&&!he.isNumericLiteral(o.key)){wn(o.value)&&Ut(e,o.value,{...n,key:null});continue}let r=he.isIdentifier(o.key)?o.key.name:String(o.key.value);wn(o.value)&&Ut(e,o.value,mt(n,[r]))}}}function hr(e,t,n,o){let r=Is(o),i=e.componentProps.get(t);if(i===void 0)return null;if(he.isIdentifier(r)){let d=n.get(r.name);return d!==void 0?d:Be(i)===r.name?{locality:"prop",root:r.name,key:r.name}:He(i,r.name)===null?null:{locality:"prop",root:r.name,key:r.name}}if(!he.isMemberExpression(r))return null;let s=Pe(r),a=ye(r);if(s===null)return null;let l=hr(e,t,n,he.identifier(s));return l===null?null:a===null?{...l,key:null}:mt(l,a.split(".").slice(1))}function Er(e,t){let n=new Map;for(let o of e.instanceDerivations.get(t)??[]){let r=hr(e,t,n,o.source);r!==null&&Ut(n,o.target,r)}return n}var Sr=yr.default??yr;function Fs(e,t){let n=new Set;for(let[o,r]of e.compReads)r.has(t)&&n.add(o);for(let o of e.rowReads.values())o.vars.has(t)&&n.add("__rows__");for(let o of e.condReads.values())o.vars.has(t)&&n.add("__regions__");return n}function xr(e,t,n){if(n.sourceLocal)return!0;let o=n.sourceKey;if(o==="")return!0;for(let i of e.computeds.values())if(i.reads.has(o))return!0;let r=new Set((e.listedSites.get(t??"")??[]).map(i=>i.owner));r.size===0&&t!==null&&r.add(t);for(let i of Fs(e,o))if(i==="__rows__"||i==="__regions__"||!r.has(i))return!0;return!1}function _t(e,t,n,o,r=!1,i,s=!1){let a=Y.cloneNode(t),l=a,d=Y.file(Y.program([Y.isFunctionDeclaration(a)?a:Y.expressionStatement(a)])),u=n!==null?e.instanceState.get(n):void 0,c=n!==null?e.instanceDerivedBindings.get(n):void 0,g=n===null?new Map:Er(e,n),S=n!==null?new Set(e.componentProps.get(n)?.bindings??[]):new Set,y=new Set([...S,...u??[],...c??[]]);if(n!==null)for(let E of e.compPaths.get(n)?.node.body.body??[])if(Y.isVariableDeclaration(E))for(let C of E.declarations)for(let M of Object.keys(Y.getBindingIdentifiers(C.id)))y.add(M);else Y.isFunctionDeclaration(E)&&E.id&&y.add(E.id.name);let p=new Rt((E,C)=>{if(C!==void 0)return null;let M=g.get(E);if(M!==void 0)return M;if(o!==void 0&&E===o.itemParam)return{locality:"row",root:E,key:E};if(u?.has(E)===!0)return{locality:"instance",root:E,key:E};if(S.has(E))return{locality:"prop",root:E,key:E};if(y.has(E))return null;let ie=e.state.get(E);return ie===void 0?null:ln(E,ie)}),f=E=>E.stateKind==="computed"||e.state.get(E.root)==="computed",v=new Set;for(let E of a.params)Y.isIdentifier(E)&&v.add(E.name);Sr(d,{VariableDeclarator(E){Y.isIdentifier(E.node.id)&&(v.add(E.node.id.name),E.parentPath.isVariableDeclaration()&&p.trackDeclarator(E.scope,E.node))},Function(E){for(let C of E.node.params)Y.isIdentifier(C)&&v.add(C.name)}});let x=new Map,I=new Map,J=E=>{let C=E.getFunctionParent()?.node??l,M=x.get(C);return M||x.set(C,M=Nt()),M},F=(E,C)=>{if(C(J(E)),!s||E.getFunctionParent()?.node!==l)return;let M=I.get(E.node);M===void 0&&(M={path:E,writes:Nt()},I.set(E.node,M)),C(M.writes)},N=E=>{F(E,C=>{o?.sourceLocal?C.rowOwnerLocal=!0:o!==void 0&&C.writes.add(o.sourceKey)})},K=E=>{if(o===void 0)return null;let C=E.split(".").slice(1);return o.itemPath.some((M,ie)=>C[ie]!==M)?null:C.slice(o.itemPath.length)},_=(E,C)=>{F(E,M=>{C!==void 0&&n!==null&&Gn(e,n,o,C,M)||(M.rowLocal=!0,M.rootFallback=!0)})},H=(E,C)=>{F(E,M=>{(n===null||!Gn(e,n,o,C,M))&&(o===void 0?(n!==null&&ct(M,C.root),M.rootFallback=!0):(M.rowLocal=!0,M.rootFallback=!0))})},T=(E,C)=>{if(o===void 0||Pe(C)!==o.itemParam)return!1;let M=ye(C);if(M===null)return o.itemPath.length===0?N(E):_(E),!0;let ie=M.split(".").slice(1);return o.itemPath.some((Je,Re)=>ie[Re]!==Je)?!1:(ie.splice(0,o.itemPath.length),Rn(ie,o.keyPath)?N(E):(F(E,Je=>{Je.rowLocal=!0}),xr(e,n,o)&&N(E)),!0)},re=(E,C)=>{if(C.locality==="instance"){F(E,M=>{ct(M,C.root)});return}if(C.locality==="row"){if(o===void 0){F(E,ie=>{ie.rootFallback=!0});return}if(C.key===null){o.itemPath.length===0?N(E):_(E);return}let M=K(C.key);if(M===null){_(E,C);return}Rn(M,o.keyPath)?N(E):(F(E,ie=>{ie.rowLocal=!0}),xr(e,n,o)&&N(E));return}if(C.locality==="prop"){H(E,C);return}if(C.stateKind==="computed")throw E.buildCodeFrameError(`memo-dom: cannot mutate computed '${C.root}' (R13) - it is derived; write its SOURCE state instead`);if(C.stateKind!=="store"){F(E,M=>{M.writes.add(C.root)});return}C.key!==null&&C.key.includes(".")?F(E,M=>{M.writes.add(C.key)}):F(E,M=>{M.writes.add(C.root)})},ne=(E,C)=>{if(C.locality==="instance"){F(E,M=>{ct(M,C.root)});return}if(C.locality==="row"){if(o===void 0){F(E,Je=>{Je.rootFallback=!0});return}if(C.key===null){o.itemPath.length===0?N(E):_(E);return}let M=K(C.key);if(M===null){_(E,C);return}M.length===0&&(o.keyPath===null||o.keyPath.length>0)?N(E):re(E,C);return}if(C.locality==="prop"){H(E,C);return}if(C.stateKind==="computed")throw E.buildCodeFrameError(`memo-dom: cannot mutate computed '${C.root}' (R13) - write its SOURCE state instead`);F(E,M=>{M.writes.add(C.key??C.root)})},G=(E,C)=>{if(!(s&&E.getFunctionParent()?.node===l))for(let M of cn(C)){if(!Y.isIdentifier(M))continue;let ie=p.resolveExpression(E.scope,M);ie!==null&&(f(ie)||ne(E,ie))}},oe=(E,C)=>{let M=Pe(C);if(M!==void 0&&u?.has(M??"")===!0){F(E,Re=>{ct(Re,M)});return}if(M!==null&&c?.has(M)&&!g.has(M))throw E.buildCodeFrameError(`memo-dom: cannot mutate per-instance derivation '${M}' (R14) \u2014 write its source instead`);if(T(E,C))return;let ie=p.resolveExpression(E.scope,C);if(ie!==null){re(E,ie);return}if(M!==null&&S.has(M)){H(E,{locality:"prop",root:M,key:ye(C)});return}if(M!==null&&y.has(M)||!M||!e.state.has(M))return;let Je=e.state.get(M);if(Je==="computed")throw E.buildCodeFrameError(`memo-dom: cannot mutate computed '${M}' (R13) \u2014 it is derived; write its SOURCE state instead`);F(E,Re=>{if(Je!=="store"){Re.writes.add(M);return}let tt=ye(C);tt!==null&&tt.includes(".")?Re.writes.add(tt):Re.writes.add(M)})};Sr(d,{VariableDeclarator(E){if(!Y.isIdentifier(E.node.id)&&E.node.init!==null)for(let C of p.referencedOrigins(E.scope,E.node.init))ne(E,C)},AssignmentExpression(E){let C=E.node.left;if(Y.isIdentifier(C)){if(v.has(C.name)){if(Y.isIdentifier(E.node.right)){let ie=p.resolveExpression(E.scope,E.node.right);ie!==null&&ne(E,ie)}return}if(c?.has(C.name))throw E.buildCodeFrameError(`memo-dom: cannot assign per-instance derivation '${C.name}' (R14) \u2014 write its source instead`);if(u?.has(C.name)===!0){F(E,ie=>{ct(ie,C.name)});return}if(S.has(C.name))throw E.buildCodeFrameError(`memo-dom: cannot assign prop '${C.name}' \u2014 copy it to component-local let state first`);if(y.has(C.name))throw E.buildCodeFrameError(`memo-dom: cannot assign component-local const '${C.name}'`);let M=e.state.get(C.name);if(!M)throw E.buildCodeFrameError(`memo-dom: handler assigns '${C.name}', which is neither module state nor a handler local \u2014 declare it at module level (let) or inside the handler`);if(e.importedState.has(C.name))throw E.buildCodeFrameError(`memo-dom: cannot reassign imported state '${C.name}' - ES module imports are read-only; export a mutator or mutate an imported store property`);if(M==="store")throw E.buildCodeFrameError(`memo-dom: cannot reassign store '${C.name}' \u2014 assign a property (${C.name}.field = \u2026) instead`);if(M==="const")throw E.buildCodeFrameError(`memo-dom: cannot reassign mutable const root '${C.name}' - mutate the object instead`);if(M==="computed")throw E.buildCodeFrameError(`memo-dom: cannot assign computed '${C.name}' (R13) \u2014 it is derived; write its SOURCE state instead and the derivation recomputes`);F(E,ie=>{ie.writes.add(C.name)})}else if(Y.isMemberExpression(C))oe(E,C);else for(let M of p.referencedOrigins(E.scope,E.node.right))ne(E,M)},UpdateExpression(E){let C=E.node.argument;if(Y.isIdentifier(C)){if(v.has(C.name))return;if(c?.has(C.name))throw E.buildCodeFrameError(`memo-dom: cannot update per-instance derivation '${C.name}' (R14) \u2014 write its source instead`);if(u?.has(C.name)===!0){F(E,ie=>{ct(ie,C.name)});return}if(S.has(C.name))throw E.buildCodeFrameError(`memo-dom: cannot update prop '${C.name}' \u2014 copy it to component-local let state first`);if(y.has(C.name))throw E.buildCodeFrameError(`memo-dom: cannot update component-local const '${C.name}'`);let M=e.state.get(C.name);if(!M)throw E.buildCodeFrameError(`memo-dom: handler updates '${C.name}', which is neither module state nor a handler local`);if(e.importedState.has(C.name))throw E.buildCodeFrameError(`memo-dom: cannot update imported state '${C.name}' - ES module imports are read-only; call an exported mutator instead`);if(M!=="let")throw E.buildCodeFrameError(M==="computed"?`memo-dom: cannot update computed '${C.name}' (R13) \u2014 it is derived; write its SOURCE state instead`:`memo-dom: cannot update '${C.name}' \u2014 it is a const binding; mutate its contents instead`);F(E,ie=>{ie.writes.add(C.name)})}else Y.isMemberExpression(C)&&oe(E,C)},UnaryExpression(E){E.node.operator==="delete"&&Y.isMemberExpression(E.node.argument)&&oe(E,E.node.argument)},CallExpression(E){let C=E.node.callee;if(Y.isMemberExpression(C)){if(un(C)==="assign"&&Y.isIdentifier(C.object,{name:"Object"})){let Re=E.node.arguments[0],tt=Re!==void 0&&Y.isExpression(Re)?p.resolveExpression(E.scope,Re):null;if(tt!==null)if(tt.locality==="module"&&tt.stateKind==="store"){let go=dn(tt,E.node.arguments.slice(1));go===null?ne(E,tt):F(E,yi=>{for(let Si of go)yi.writes.add(Si)})}else re(E,tt);return}let ie=Y.isIdentifier(C.object)?C.object.name:Y.isMemberExpression(C.object)?Pe(C.object):null;if(ie!==null&&c?.has(ie)&&!g.has(ie))throw E.buildCodeFrameError(`memo-dom: cannot mutate per-instance derivation '${ie}' (R14) - write its source instead`);let Je=Y.isExpression(C.object)?p.resolveExpression(E.scope,C.object):null;Je!==null?ne(E,Je):G(E,E.node.arguments);return}if(Y.isIdentifier(C)&&!y.has(C.name)&&(e.helpers.has(C.name)||e.importedFunctions.has(C.name))){let M=e.importedFunctions.get(C.name)??Ve(e,C.name);F(E,ie=>{for(let Re of M.writes)ie.writes.add(Re);for(let Re of M.boundedWrites)ie.writes.add(Re);let Je=s&&E.getFunctionParent()?.node===l;M.unbounded&&!Je&&(ie.rootFallback=!0)});for(let ie of M.parameterWrites){let Je=E.node.arguments[ie.index];if(Je===void 0||!Y.isExpression(Je))continue;let Re=p.resolveExpression(E.scope,Je);if(Re!==null){if(f(Re))continue;ne(E,mt(Re,ie.path))}}return}G(E,E.node.arguments)}});let Q=x.has(l);if(e.handlerHasRootCommit.set(t,Q),r&&!x.has(l)){let E=Nt();E.eventOrigin=yt(e,n,o,i),x.set(l,E)}let ae=[];if(s)for(let E of I.values()){let C=Lt(e,E.writes,n,o);C!==null&&ae.push({...E,commit:C})}for(let E of ae)E.flag=$(e,"didWrite");ae.sort((E,C)=>Cr(C.path)-Cr(E.path)).forEach(E=>Rs(E.path,E.flag));for(let[E,C]of x){let M=s&&E===l?ae.length===0?null:Y.blockStatement(ae.map(ie=>Y.ifStatement(Y.cloneNode(ie.flag),Y.cloneNode(ie.commit)))):Lt(e,C,n,o);M&&br(e,E,M)}if(ae.length>0){if(!Y.isBlockStatement(a.body))throw new Error("memo-dom: execution-aware callback commit did not produce a block body");a.body.body.unshift(Y.variableDeclaration("let",ae.map(E=>Y.variableDeclarator(Y.cloneNode(E.flag),Y.booleanLiteral(!1)))))}t.body=a.body}function Cr(e){let t=0,n=e;for(;n.parentPath!==null;)t++,n=n.parentPath;return t}function Rs(e,t){let n=Y.assignmentExpression("=",Y.cloneNode(t),Y.booleanLiteral(!0));if(e.isVariableDeclarator()){let o=e.node.init;if(o===null||!Y.isExpression(o))throw new Error("memo-dom: execution-aware variable site has no expression initializer");e.node.init=Y.sequenceExpression([n,o]);return}if(!e.isExpression())throw new Error(`memo-dom: unsupported execution-aware write site '${e.node.type}'`);e.replaceWith(Y.sequenceExpression([n,e.node]))}import*as rt from"@babel/types";function Pr(e,t){let n=!1,o=!0,r=i=>{if(o&&!(i!==e&&rt.isFunction(i))){if((rt.isCallExpression(i)||rt.isOptionalCallExpression(i))&&(n=!0,!rt.isIdentifier(i.callee)||!t(i.callee.name))){o=!1;return}for(let s of rt.VISITOR_KEYS[i.type]??[]){let a=i[s];if(Array.isArray(a))for(let l of a)l!==null&&typeof l=="object"&&"type"in l&&r(l);else a!==null&&typeof a=="object"&&"type"in a&&r(a)}}};return r(e),n&&o}function It(e,t){let o=e.scope.getBinding(t)?.path;if(!o||o.getFunctionParent()!==e)return null;if(o.isFunctionDeclaration())return o.node;if(!o.isVariableDeclarator())return null;let r=o.node.init;return r&&(Ce.isArrowFunctionExpression(r)||Ce.isFunctionExpression(r))?r:null}function it(e,t,n,o,r,i=!1){e.analyzedFunctions.has(n)||(Zn(e,t,n,o,r),e.analyzedFunctions.add(n),_t(e,n,o,r,!1,void 0,i))}function qt(e,t,n=!1){e.analyzedFunctions.has(t)||(e.analyzedFunctions.add(t),_t(e,t,null,void 0,!1,void 0,n))}function Zn(e,t,n,o,r){let i=new Set;Xe(n.body,s=>{Ce.isCallExpression(s)&&Ce.isIdentifier(s.callee)&&i.add(s.callee.name)});for(let s of i){let a=It(t,s);a===null||e.analyzedFunctions.has(a)||(e.analyzedFunctions.add(a),Zn(e,t,a,o,r),_t(e,a,o,r,!1))}}function Yn(e,t,n,o,r,i,s){let a=null,l=!1,d=e.componentProps.get(r),u=d===void 0?null:Be(d);if(d!==void 0&&(Ce.isIdentifier(n)&&He(d,n.name)!==null||Ce.isMemberExpression(n)&&u!==null&&Pe(n)===u))return At(e,n,yt(e,r,i,s));if(Ce.isArrowFunctionExpression(n)||Ce.isFunctionExpression(n))a=n;else if(Ce.isIdentifier(n)){let g=e.importedFunctions.get(n.name);if(g!==void 0){let p=Nt();for(let f of g.writes)p.writes.add(f);for(let f of g.boundedWrites)p.writes.add(f);return p.rootFallback=g.unbounded,At(e,n,Lt(e,p,null)??yt(e,r,i,s))}let S=t.scope.getBinding(n.name),y=S?.path;if(y&&y.isVariableDeclarator()){let p=y.node.init;p&&(Ce.isArrowFunctionExpression(p)||Ce.isFunctionExpression(p))&&(a=p,l=S?.scope.path.isProgram()===!0&&e.helpers.has(n.name))}else y&&y.isFunctionDeclaration()&&(e.helpers.has(n.name)?(a=y.node,l=!0):a=It(t,n.name));if(!a)throw t.buildCodeFrameError(`memo-dom: cannot resolve handler '${n.name}' \u2014 use an inline arrow, a component-local const, or a module-level function (L1)`)}else throw t.buildCodeFrameError(`memo-dom: unsupported ${o} handler form \u2014 expected an arrow function or a function reference (L1)`);if(Ce.isBlockStatement(a.body)||(a.body=Ce.blockStatement([Ce.expressionStatement(a.body)])),!e.analyzedFunctions.has(a)){l||Zn(e,t,a,r,i);let g=!l&&!Ce.isIdentifier(n)&&Pr(a,S=>{let y=It(t,S);return y!==null&&e.handlerHasRootCommit.get(y)===!0});e.analyzedFunctions.add(a),_t(e,a,l?null:r,l?void 0:i,!l&&!Ce.isIdentifier(n)&&!g,s)}if(l){let g=Ve(e,n.name);if(a.async){let S=Nt();for(let y of g.writes)S.writes.add(y);for(let y of g.boundedWrites)S.writes.add(y);return S.rootFallback=g.unbounded,At(e,n,Lt(e,S,null)??yt(e,r,i,s))}if(g.writes.size===0&&g.boundedWrites.size===0&&!g.unbounded)return At(e,n,yt(e,r,i,s))}return Ce.isIdentifier(n)&&!l&&(e.handlerHasRootCommit.get(a)===!1||a.async)?At(e,n,yt(e,r,i,s)):Ce.isIdentifier(n)?n:a}import*as ve from"@babel/types";function Qn(e,t){let n=[];for(let o of e){if(ve.isJSXText(o)){let a=Jn(o.value);a!==""&&n.push({type:"node",variable:t.emitText(ve.stringLiteral(a))});continue}if(ve.isJSXElement(o)||ve.isJSXFragment(o)){n.push({type:"node",variable:t.emitNode(o)});continue}if(ve.isJSXExpressionContainer(o)||t.fail("memo-dom: spread children are not supported"),ve.isJSXEmptyExpression(o.expression))continue;ve.isExpression(o.expression)||t.fail("memo-dom: unsupported expression in JSX child position");let r=o.expression;if(t.isForwarded(r)){n.push({type:"slot",expression:ve.cloneNode(r)});continue}if(ve.isNullLiteral(r)||ve.isBooleanLiteral(r)||ve.isIdentifier(r,{name:"undefined"}))continue;let i=Oe(r);if(i!==null){n.push({type:"list",expression:i});continue}let s=sn(r);if(s!==null&&ue(s)){n.push({type:"condition",expression:s});continue}n.push({type:"node",variable:t.emitText(ve.cloneNode(r))})}return n}import*as O from"@babel/types";var Ds=new Set(["innerHTML","checked","value","selected","disabled","hidden","multiple","required","readOnly","muted","open","controls","loop","autoFocus","autoPlay","tabIndex"]),wr={htmlFor:"for",crossOrigin:"crossorigin"};function eo(e,t){return!t&&Ds.has(e)?e:null}function to(e,t){return!t&&e in wr}function no(e,t,n){let o=O.identifier(e);if(t==="tabIndex")return O.isStringLiteral(n)?O.expressionStatement(O.assignmentExpression("=",O.memberExpression(o,O.identifier(t)),O.cloneNode(n))):O.expressionStatement(O.conditionalExpression(O.binaryExpression("==",O.cloneNode(n),O.nullLiteral()),O.callExpression(O.memberExpression(O.cloneNode(o),O.identifier("removeAttribute")),[O.stringLiteral("tabindex")]),O.assignmentExpression("=",O.memberExpression(O.cloneNode(o),O.identifier(t)),O.cloneNode(n))));let r=t==="value"||t==="innerHTML"?O.stringLiteral(""):O.booleanLiteral(!1),i=O.isStringLiteral(n)?O.cloneNode(n):O.conditionalExpression(O.binaryExpression("==",O.cloneNode(n),O.nullLiteral()),r,O.cloneNode(n));return O.expressionStatement(O.assignmentExpression("=",O.memberExpression(o,O.identifier(t)),i))}function vn(e,t,n){let o=O.identifier(e),r=wr[t]??t;return O.isStringLiteral(n)?O.expressionStatement(O.callExpression(O.memberExpression(o,O.identifier("setAttribute")),[O.stringLiteral(r),O.cloneNode(n)])):O.expressionStatement(O.conditionalExpression(O.logicalExpression("||",O.binaryExpression("==",O.cloneNode(n),O.nullLiteral()),O.binaryExpression("===",O.cloneNode(n),O.booleanLiteral(!1))),O.callExpression(O.memberExpression(O.cloneNode(o),O.identifier("removeAttribute")),[O.stringLiteral(r)]),O.callExpression(O.memberExpression(o,O.identifier("setAttribute")),[O.stringLiteral(r),O.conditionalExpression(O.binaryExpression("===",O.cloneNode(n),O.booleanLiteral(!0)),O.stringLiteral(""),O.callExpression(O.identifier("String"),[O.cloneNode(n)]))])))}import*as ze from"@babel/types";var Ms="http://www.w3.org/2000/svg",Ls=new Set(["animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","switch","symbol","text","textPath","tspan","use","view"]);function vr(e,t){return t||e==="svg"||Ls.has(e)}function kr(e,t){return t?ze.callExpression(ze.memberExpression(ze.identifier("document"),ze.identifier("createElementNS")),[ze.stringLiteral(Ms),ze.stringLiteral(e)]):ze.callExpression(ze.memberExpression(ze.identifier("document"),ze.identifier("createElement")),[ze.stringLiteral(e)])}import*as me from"@babel/types";function kn(e,t,n){let o=e.componentProps.get(t);if(o?.mode==="object"){if(!o.acceptsUnknown){for(let s of n)if(!o.names.includes(s.name))throw new Error(`memo-dom: unknown prop '${s.name}' on <${t}> - declared props: ${o.names.length>0?o.names.join(", "):"(none)"}`)}return n.length===0&&o.hasWholeDefault?[me.identifier("undefined")]:[me.objectExpression(n.map(s=>me.objectProperty(me.identifier(s.name),s.value,!1,me.isIdentifier(s.value)&&s.value.name===s.name)))]}let r=o?.names;if(r===void 0)return n.map(s=>s.value);let i=new Map(n.map(s=>[s.name,s.value]));for(let s of i.keys())if(!r.includes(s))throw new Error(`memo-dom: unknown prop '${s}' on <${t}> - declared props: ${r.length>0?r.join(", "):"(none)"}`);return r.map(s=>i.get(s)??me.identifier("undefined"))}function jt(e,t,n){let o=e.componentProps.get(t);return o?.mode==="object"?[me.cloneNode(n)]:(o?.names??[]).map(r=>me.memberExpression(me.cloneNode(n),me.isValidIdentifier(r)?me.identifier(r):me.stringLiteral(r),!me.isValidIdentifier(r)))}function Nr(e,t,n,o,r){let i=$(e,`${t}Props`);return me.blockStatement([me.variableDeclaration("const",[me.variableDeclarator(me.cloneNode(i),me.cloneNode(r))]),me.expressionStatement(me.callExpression(Z(e,"setProps"),[me.binaryExpression("+",me.cloneNode(n),me.stringLiteral(o)),me.arrayExpression(jt(e,t,i))]))])}import*as Ne from"@babel/types";function Jt(e){return(Ne.isArrowFunctionExpression(e)||Ne.isFunctionExpression(e))&&!As(e.body)}function oo(e,t,n,o="callback"){let r=$(e,o);return t.creation.push(Ne.variableDeclaration("const",[Ne.variableDeclarator(Ne.cloneNode(r),Ne.cloneNode(n,!0))])),r}function ro(e,t,n,o="callback"){let r=$(e,o);return t.push(Ne.variableDeclaration("const",[Ne.variableDeclarator(Ne.cloneNode(r),Ne.cloneNode(n,!0))])),r}function As(e){let t=!1;return Ne.traverseFast(e,n=>{if(Ne.isJSXElement(n)||Ne.isJSXFragment(n))return t=!0,Ne.traverseFast.stop}),t}import*as z from"@babel/types";function Ir(e,t,n,o,r,i,s,a=!1,l=Le(e,r),d=!1){let u=an(n,i,t.usedConds),c=$(e,u.suffix).name,g=z.binaryExpression("+",z.cloneNode(l),z.stringLiteral(`/${u.suffix}`)),S=z.arrowFunctionExpression([],z.cloneNode(u.pickExpr)),y=u.branches.map(p=>p!==null?io(e,p,r,i,g,s,a,g,!1,t.usedConds):z.nullLiteral());t.creation.push(gt(e,z.cloneNode(g),z.cloneNode(l),z.arrowFunctionExpression([],z.callExpression(z.memberExpression(z.identifier(c),z.identifier("update")),[])))),t.creation.push(z.variableDeclaration("const",[z.variableDeclarator(z.identifier(c),z.callExpression(Z(e,"createCondRegion"),[z.identifier(o),z.cloneNode(g),S,z.arrayExpression(y)]))])),(d||ho(e,n,r))&&t.updaters.push(()=>z.expressionStatement(z.callExpression(z.memberExpression(z.identifier(c),z.identifier("update")),[]))),t.disposableRegions.push(c),t.disposableEntities.push(z.cloneNode(g))}function io(e,t,n,o,r,i,s=!1,a=r,l=!1,d){let u=Ze(e,!0);d!==void 0&&(u.usedConds=d);let c=i(e,u,t,n,o,l?null:"cond",void 0,r,s,a),g=[z.objectProperty(z.identifier("nodes"),z.callExpression(Z(e,"rootNodes"),[z.identifier(c)])),z.objectProperty(z.identifier("update"),z.identifier(u.updateVar))];if(u.disposableRegions.length>0||u.disposableEntities.length>0||u.disposableCallbacks.length>0){let S=[...[...u.disposableCallbacks].reverse().map(y=>z.ifStatement(z.binaryExpression("!==",z.cloneNode(y),z.nullLiteral()),z.expressionStatement(z.callExpression(z.cloneNode(y),[])))),...u.disposableRegions.map(y=>z.expressionStatement(z.callExpression(z.memberExpression(z.identifier(y),z.identifier("dispose")),[]))),...u.disposableEntities.map(y=>z.expressionStatement(z.callExpression(Z(e,"unregisterSubtree"),[z.cloneNode(y)])))];g.push(z.objectProperty(z.identifier("dispose"),z.arrowFunctionExpression([],z.blockStatement(S))))}return z.arrowFunctionExpression([],z.blockStatement([Ye(u),Qe(u),...u.creation,...u.mounts,z.returnStatement(z.objectExpression(g))]))}import*as m from"@babel/types";import*as X from"@babel/types";function ut(e,t,n,o){return X.isArrayExpression(o)?X.arrayExpression(o.elements.map(r=>{if(r===null)return null;if(X.isSpreadElement(r))throw t.buildCodeFrameError("memo-dom: ref arrays must have a static shape; nested arrays are supported but array spreads are not");return ut(e,t,n,r)})):js(e,n,o)?X.cloneNode(o,!0):Js(t,o)||X.isMemberExpression(o)?Fr(e,o):X.cloneNode(o,!0)}function so(e,t,n,o,r){let i=$(e,"refDispose");t.mounts.push(X.variableDeclaration("const",[X.variableDeclarator(X.cloneNode(i),X.callExpression(Z(e,"mountRef"),[X.cloneNode(n,!0),X.cloneNode(r,!0)]))])),t.manualDisposal?t.disposableCallbacks.push(i):t.mounts.push(X.expressionStatement(X.callExpression(Z(e,"cleanup"),[X.cloneNode(o,!0),X.cloneNode(i)])))}function js(e,t,n){let o=lt(e,t,n);return o!==null&&e.componentProps.get(t)?.refProps.includes(o)===!0}function Js(e,t){if(!X.isIdentifier(t)||t.name==="undefined")return!1;let n=e.scope.getBinding(t.name);if(n===void 0||n.path.isFunctionDeclaration()||n.path.isImportSpecifier()||n.path.isImportDefaultSpecifier()||n.path.isImportNamespaceSpecifier())return!1;if(n.path.isVariableDeclarator()){if(n.path.parentPath.isVariableDeclaration({kind:"const"}))return!1;let r=n.path.node.init;if(X.isFunctionExpression(r)||X.isArrowFunctionExpression(r))return!1}return n.kind!=="param"}function Fr(e,t){let n=$(e,"refNode");if(X.isMemberExpression(t)){let o=$(e,"refTarget"),r=t.computed?$(e,"refKey"):null,i=()=>X.memberExpression(X.cloneNode(o),r===null?X.cloneNode(t.property,!0):X.cloneNode(r),t.computed);return X.arrowFunctionExpression([X.cloneNode(n)],X.blockStatement([X.variableDeclaration("const",[X.variableDeclarator(X.cloneNode(o),X.cloneNode(t.object,!0)),...r===null?[]:[X.variableDeclarator(X.cloneNode(r),X.cloneNode(t.property,!0))]]),X.expressionStatement(X.assignmentExpression("=",i(),X.cloneNode(n))),X.returnStatement(X.arrowFunctionExpression([],X.blockStatement([X.ifStatement(X.binaryExpression("===",i(),X.cloneNode(n)),X.expressionStatement(X.assignmentExpression("=",i(),X.identifier("undefined"))))])))]))}return X.arrowFunctionExpression([X.cloneNode(n)],X.blockStatement([X.expressionStatement(X.assignmentExpression("=",X.cloneNode(t,!0),X.cloneNode(n))),X.returnStatement(X.arrowFunctionExpression([],X.blockStatement([X.ifStatement(X.binaryExpression("===",X.cloneNode(t,!0),X.cloneNode(n)),X.expressionStatement(X.assignmentExpression("=",X.cloneNode(t,!0),X.identifier("undefined"))))])))]))}import*as A from"@babel/types";var $s=new Set(["setClassValue","setStyleValue","setDomValue"]);function $t(e,t,n){if(t.mounts.length!==0||t.disposableRegions.length!==0||t.disposableEntities.length!==0||t.disposableCallbacks.length!==0)return!1;let o=[],r=new Set;for(let p of t.creation){if(!A.isVariableDeclaration(p))continue;let f=Xs(p);if(f===null)return!1;o.push(f),r.add(f.name)}if(!r.has(n)||o.length<2)return!1;let i=new Map,s=new Map;for(let p of t.creation){let f=Rr(p);if(f===null)continue;if(!r.has(f.parent)||!r.has(f.child))return!1;let v=s.get(f.parent)??0;s.set(f.parent,v+1),i.set(f.child,{parent:f.parent,index:v})}let a=new Map;for(let p of r){let f=Os(p,n,i);if(f===null)return!1;a.set(p,f)}let l=[],d=[];for(let p of t.creation)A.isVariableDeclaration(p)||Bs(p,r)?l.push(A.cloneNode(p,!0)):d.push(p);let u=$(e,`${n}Template`);e.header.push(A.variableDeclaration("let",[A.variableDeclarator(A.cloneNode(u))]));let c=A.callExpression(A.arrowFunctionExpression([],A.blockStatement([...l,A.returnStatement(A.identifier(n))])),[]),g=A.conditionalExpression(A.binaryExpression("===",A.cloneNode(u),A.unaryExpression("void",A.numericLiteral(0))),A.assignmentExpression("=",A.cloneNode(u),c),A.cloneNode(u)),S=A.callExpression(A.memberExpression(g,A.identifier("cloneNode")),[A.booleanLiteral(!0)]),y=[...o].sort((p,f)=>a.get(p.name).length-a.get(f.name).length).map(({name:p})=>A.variableDeclaration("const",[A.variableDeclarator(A.identifier(p),p===n?A.cloneNode(S,!0):Ts(n,a.get(p)))]));return t.creation=[...y,...d],!0}function Xs(e){if(e.declarations.length!==1)return null;let t=e.declarations[0];if(!A.isIdentifier(t.id)||!A.isCallExpression(t.init)||!A.isMemberExpression(t.init.callee)||!A.isIdentifier(t.init.callee.object,{name:"document"})||!A.isIdentifier(t.init.callee.property))return null;let n=t.init.callee.property.name;if(n!=="createElement"&&n!=="createElementNS"&&n!=="createTextNode")return null;let o=t.init.arguments.at(-1);return(n==="createElement"||n==="createElementNS")&&A.isStringLiteral(o)&&o.value.includes("-")?null:{name:t.id.name,statement:e}}function Rr(e){return!A.isExpressionStatement(e)||!A.isCallExpression(e.expression)||!A.isMemberExpression(e.expression.callee)||!A.isIdentifier(e.expression.callee.object)||!A.isIdentifier(e.expression.callee.property,{name:"appendChild"})||e.expression.arguments.length!==1||!A.isIdentifier(e.expression.arguments[0])?null:{parent:e.expression.callee.object.name,child:e.expression.arguments[0].name}}function Os(e,t,n){if(e===t)return[];let o=[],r=new Set,i=e;for(;i!==t;){if(r.has(i))return null;r.add(i);let s=n.get(i);if(s===void 0)return null;o.push(s.index),i=s.parent}return o.reverse(),o}function Ts(e,t){let n=A.identifier(e);for(let o of t){n=A.memberExpression(n,A.identifier("firstChild"));for(let r=0;r<o;r++)n=A.memberExpression(n,A.identifier("nextSibling"))}return n}function Bs(e,t){let n=Rr(e);if(n!==null)return t.has(n.parent)&&t.has(n.child);if(!A.isExpressionStatement(e))return!1;let o=e.expression;return!!(A.isCallExpression(o)&&A.isMemberExpression(o.callee)&&(A.isIdentifier(o.callee.object)&&t.has(o.callee.object.name)&&A.isIdentifier(o.callee.property,{name:"setAttribute"})&&o.arguments.every(r=>A.isExpression(r)&&Nn(r))||A.isIdentifier(o.callee.object)&&A.isIdentifier(o.callee.property)&&$s.has(o.callee.property.name)&&o.arguments.length>=2&&A.isIdentifier(o.arguments[0])&&t.has(o.arguments[0].name)&&o.arguments.slice(1).every(r=>A.isExpression(r)&&Nn(r))))}function Nn(e){return A.isStringLiteral(e)||A.isNumericLiteral(e)||A.isBooleanLiteral(e)||A.isNullLiteral(e)?!0:A.isArrayExpression(e)?e.elements.every(t=>t===null||A.isExpression(t)&&Nn(t)):A.isObjectExpression(e)?e.properties.every(t=>A.isObjectProperty(t)&&!t.computed&&A.isExpression(t.value)&&Nn(t.value)):!1}function Dr(e,t,n,o,r,i,s,a,l=!1,d=Le(e,r),u){let c=wt(e,n,i,r,t.usedPrefixes,u===void 0?void 0:{itemParam:u.itemParam,sourceKey:u.sourceKey,sourceLocal:u.sourceLocal??!1}),g=$(e,`region${t.regionCounter++}`).name,S=c.form==="callback"?Vs(e,c,o):c.form==="component"?Ws(e,c,o,r,i,a,l,d):zs(e,c,o,r,i,s,l,d),y=[m.identifier(o),m.binaryExpression("+",m.cloneNode(d),m.stringLiteral(`/${c.suffix}`)),S];if(c.form==="callback"){let f=m.memberExpression(m.cloneNode(c.renderCallback,!0),m.identifier("key"));y.push(m.arrowFunctionExpression([m.cloneNode(c.itemPattern,!0),...c.indexParam===null?[]:[m.identifier(c.indexParam)]],m.conditionalExpression(m.binaryExpression("==",m.cloneNode(f),m.nullLiteral()),m.cloneNode(c.itemPattern,!0),m.callExpression(m.cloneNode(f),[m.cloneNode(c.itemPattern,!0),...c.indexParam===null?[]:[m.identifier(c.indexParam)]]))))}else c.keyExpr!==null&&y.push(m.arrowFunctionExpression([m.cloneNode(c.itemPattern,!0),...c.indexParam===null?[]:[m.identifier(c.indexParam)]],m.cloneNode(c.keyExpr)));t.creation.push(m.variableDeclaration("const",[m.variableDeclarator(m.identifier(g),m.callExpression(Z(e,"createListRegion"),y))])),t.disposableRegions.push(g);let p=()=>m.expressionStatement(m.callExpression(m.memberExpression(m.identifier(g),m.identifier("reconcile")),[m.cloneNode(c.sourceExpr)]));t.creation.push(p()),t.updaters.push(p)}function Vs(e,t,n){let o=$(e,"renderRowId");return m.arrowFunctionExpression([m.cloneNode(t.itemPattern,!0),m.cloneNode(o),...t.indexParam===null?[]:[m.identifier(t.indexParam)]],m.callExpression(m.memberExpression(m.cloneNode(t.renderCallback,!0),m.identifier("create")),[m.cloneNode(t.itemPattern,!0),m.cloneNode(o),...t.indexParam===null?[]:[m.identifier(t.indexParam)],m.identifier(n)]))}function Ws(e,t,n,o,r,i,s=!1,a=Le(e,o)){let l=t.rowComp,d=$(e,"rowId"),u=$(e,"nextItem"),c=t.indexParam===null?null:$(e,"nextIndex"),g=$(e,"refreshRow"),S=Ze(e),y=Dt(e,l),p=e.importedComponents.get(l)?.delegatedEvents===!0||e.componentsWithHostEvents.has(l),f={itemParam:t.itemParam,itemPath:[],rowIdVar:d.name,refreshVar:g.name,keyPath:at(t.keyExpr,t.itemParam),sourceKey:t.sourceKey,sourceLocal:t.sourceLocal,...t.sourceLocal&&m.isIdentifier(a)?{ownerIdVar:a.name}:{}},v=t.jsx.openingElement.attributes.filter(G=>m.isJSXSpreadAttribute(G)||Ae(G.name)!=="key"),x=v.some(G=>m.isJSXSpreadAttribute(G)),I=[],J=[],F=null,N=e.componentProps.get(l),K=G=>{let oe=m.isJSXElement(G)||m.isJSXFragment(G)?[G]:[m.jsxExpressionContainer(G)];return i(e,S,oe,o,r,"row",f,d,s,d)};if(x){F=Ht(v,{attributeValue:(G,oe)=>G==="ref"||N?.refProps.includes(G)===!0?ut(e,r,o,oe):oe,fail:G=>{throw r.buildCodeFrameError(G)}}).expression;for(let G of F.properties){if(!m.isObjectProperty(G)||G.computed||!m.isExpression(G.value))continue;let oe=m.isIdentifier(G.key)?G.key.name:m.isStringLiteral(G.key)?G.key.value:null;if(oe!==null)if(N?.renderProps.includes(oe)===!0){if(et(e,o,G.value))continue;if(!ue(G.value))throw r.buildCodeFrameError(`memo-dom: render prop '${oe}' on <${l}> must be JSX, a JSX-bearing conditional/list, or a forwarded render prop`);G.value=K(G.value)}else{if(ue(G.value))throw r.buildCodeFrameError(`memo-dom: JSX prop '${oe}' on <${l}> is not rendered by the callee; interpolate that prop in <${l}> to declare a render slot`);oe!=="ref"&&N?.refProps.includes(oe)!==!0&&Jt(G.value)&&(it(e,r,G.value,o,f),G.value=ro(e,J,G.value,`${oe}Callback`))}}}else for(let G of v){let oe=G,Q=Ae(oe.name),ae=oe.value==null?m.booleanLiteral(!0):$e(oe.value);if(ae===null)throw r.buildCodeFrameError(`memo-dom: prop '${Ae(oe.name)}' on <${l}> must be an expression`);if(N?.renderProps.includes(Q)===!0){if(et(e,o,ae)){I.push({name:Q,value:m.cloneNode(ae)});continue}if(!ue(ae))throw r.buildCodeFrameError(`memo-dom: render prop '${Q}' on <${l}> must be JSX, a JSX-bearing conditional/list, or a forwarded render prop`);I.push({name:Q,value:K(ae)});continue}if(Q==="ref"||N?.refProps.includes(Q)===!0){I.push({name:Q,value:ut(e,r,o,ae)});continue}if(ue(ae))throw r.buildCodeFrameError(`memo-dom: JSX prop '${Q}' on <${l}> is not rendered by the callee; interpolate that prop in <${l}> to declare a render slot`);let E=Jt(ae);E&&it(e,r,ae,o,f),I.push({name:Q,value:E?ro(e,J,ae,`${Q}Callback`):m.cloneNode(ae)})}if(Vt(t.jsx.children)){if(v.some(oe=>m.isJSXAttribute(oe)&&Ae(oe.name)==="children"))throw r.buildCodeFrameError(`memo-dom: <${l}> cannot use both a children prop and nested JSX children`);let G=i(e,S,t.jsx.children,o,r,"row",f,d,s,d);F!==null?F.properties.push(m.objectProperty(m.identifier("children"),m.cloneNode(G))):I.push({name:"children",value:m.cloneNode(G)})}let _;if(F!==null){let G=$(e,`${l}Props`);J.push(m.variableDeclaration("const",[m.variableDeclarator(m.cloneNode(G),m.cloneNode(F))])),_=jt(e,l,G)}else _=kn(e,l,I);let H=[m.expressionStatement(m.assignmentExpression("=",m.cloneNode(t.itemPattern,!0),m.cloneNode(u)))];c!==null&&t.indexParam!==null&&H.push(m.expressionStatement(m.assignmentExpression("=",m.identifier(t.indexParam),m.cloneNode(c))));let T=_.map(G=>m.cloneNode(G));if(F!==null){let G=$(e,`next${l}Props`);H.push(m.variableDeclaration("const",[m.variableDeclarator(m.cloneNode(G),m.cloneNode(F))])),T=jt(e,l,G)}let re=$(e,y?"entry":"rowElement");y?H.push(m.expressionStatement(m.callExpression(m.memberExpression(m.cloneNode(re),m.identifier("updateProps")),T))):H.push(m.expressionStatement(m.callExpression(Z(e,"setProps"),[m.cloneNode(d),m.arrayExpression(T)])),m.expressionStatement(m.callExpression(Z(e,"markDirty"),[m.cloneNode(d)]))),S.updaters.length>0&&H.push(m.expressionStatement(m.callExpression(m.identifier(S.updateVar),[])));let ne=y?[m.objectProperty(m.identifier("nodes"),m.memberExpression(m.cloneNode(re),m.identifier("nodes"))),m.objectProperty(m.identifier("entities"),m.arrayExpression([])),m.objectProperty(m.identifier("update"),m.memberExpression(m.cloneNode(re),m.identifier("update"))),m.objectProperty(m.identifier("dispose"),m.memberExpression(m.cloneNode(re),m.identifier("dispose")))]:[m.objectProperty(m.identifier("nodes"),m.callExpression(Z(e,"rootNodes"),[m.cloneNode(re)])),m.objectProperty(m.identifier("entities"),m.arrayExpression([m.cloneNode(d)]))];return(_.length>0||S.updaters.length>0)&&ne.push(m.objectProperty(m.identifier("updateProps"),m.arrowFunctionExpression([m.cloneNode(u),...c===null?[]:[m.cloneNode(c)]],m.blockStatement(H)))),m.arrowFunctionExpression([m.cloneNode(t.itemPattern,!0),m.cloneNode(d),...t.indexParam===null?[]:[m.identifier(t.indexParam)]],m.blockStatement([...S.updaters.length>0?[Ye(S),Qe(S)]:[],...S.creation,...S.mounts,...J,m.variableDeclaration("const",[m.variableDeclarator(m.cloneNode(re),y?m.callExpression(m.identifier(l),[..._.map(G=>m.cloneNode(G)),m.cloneNode(d),...t.sourceLocal?[m.cloneNode(a)]:[],...p?[m.identifier(n)]:[]]):m.callExpression(m.identifier(l),[m.cloneNode(d),m.cloneNode(a),..._.length>0?[m.arrayExpression(_)]:[]]))]),...S.updaters.length>0?[m.variableDeclaration("const",[m.variableDeclarator(m.cloneNode(g),m.arrowFunctionExpression([],m.blockStatement([m.expressionStatement(y?m.callExpression(m.memberExpression(m.cloneNode(re),m.identifier("update")),[]):m.callExpression(Z(e,"markDirty"),[m.cloneNode(d)])),m.expressionStatement(m.callExpression(m.identifier(S.updateVar),[]))])))])]:[],m.returnStatement(m.objectExpression(ne))]))}function zs(e,t,n,o,r,i,s=!1,a=Le(e,o)){t.jsx.openingElement.attributes=t.jsx.openingElement.attributes.filter(p=>m.isJSXSpreadAttribute(p)||p.name.name!=="key");let l=Ze(e);l.delegatedEventRootVar=n;let d=$(e,"rowId").name,u=$(e,"nextItem"),c=t.indexParam===null?null:$(e,"nextIndex"),g={itemParam:t.itemParam,itemPath:[],rowIdVar:d,keyPath:at(t.keyExpr,t.itemParam),sourceKey:t.sourceKey,sourceLocal:t.sourceLocal,...t.sourceLocal?{ownerIdVar:m.isIdentifier(a)?a.name:Le(e,o).name}:{}},S=i(e,l,t.jsx,o,r,"row",g,m.identifier(d),s,m.identifier(d));$t(e,l,S);let y=[m.expressionStatement(m.assignmentExpression("=",m.cloneNode(t.itemPattern,!0),m.cloneNode(u)))];return c!==null&&t.indexParam!==null&&y.push(m.expressionStatement(m.assignmentExpression("=",m.identifier(t.indexParam),m.cloneNode(c)))),m.arrowFunctionExpression([m.cloneNode(t.itemPattern,!0),m.identifier(d),...t.indexParam===null?[]:[m.identifier(t.indexParam)]],m.blockStatement([Ye(l),Qe(l),gt(e,m.identifier(d),m.cloneNode(a),m.identifier(l.updateVar)),...l.creation,...l.mounts,m.returnStatement(m.objectExpression([m.objectProperty(m.identifier("nodes"),m.arrayExpression([m.identifier(S)])),m.objectProperty(m.identifier("entities"),m.arrayExpression([m.identifier(d)])),m.objectProperty(m.identifier("updateProps"),m.arrowFunctionExpression([m.cloneNode(u),...c===null?[]:[m.cloneNode(c)]],m.blockStatement(y))),m.objectProperty(m.identifier("update"),m.identifier(l.updateVar))]))]))}import*as w from"@babel/types";function Ks(e){return w.isJSXElement(e.body)?e.body:w.isBlockStatement(e.body)&&e.body.body.length===1&&w.isReturnStatement(e.body.body[0])&&w.isJSXElement(e.body.body[0].argument)?e.body.body[0].argument:null}function ao(e,t,n,o,r,i,s,a){if(!w.isArrowFunctionExpression(n)&&!w.isFunctionExpression(n)||n.async||n.generator)throw r.buildCodeFrameError("memo-dom: render callbacks must be synchronous inline arrows or function expressions");let l=Ks(n),d=n.params[0],u=n.params[1];if(l===null||n.params.length<1||n.params.length>2||!w.isIdentifier(d)&&!w.isObjectPattern(d)&&!w.isArrayPattern(d)||u!==void 0&&!w.isIdentifier(u))throw r.buildCodeFrameError("memo-dom: render callbacks take an item binding pattern and optional index, then return one JSX element");let c=tn(d),g=Object.keys(w.getBindingIdentifiers(c));if(g.length===0)throw r.buildCodeFrameError("memo-dom: render callback item patterns must bind at least one name");let S=w.isIdentifier(c)?c.name:g[0],y=u===void 0?null:u.name,p=null;l.openingElement.attributes=l.openingElement.attributes.filter(oe=>{if(w.isJSXSpreadAttribute(oe)||!w.isJSXIdentifier(oe.name)||oe.name.name!=="key")return!0;if(p=$e(oe.value),p===null)throw r.buildCodeFrameError("memo-dom: key={...} needs an expression");return!1});let f=$(e,"renderCallback"),v=$(e,"renderRows"),x=$(e,"renderNextUpdate"),I=$(e,"renderRowId"),J=$(e,"renderEventRoot"),F=$(e,"refreshRenderRow"),N=$(e,"renderNextItem"),K=y===null?null:$(e,"renderNextIndex"),_=Ze(e);_.delegatedEventRootVar=J.name;let H={itemParam:S,itemPath:[],rowIdVar:I.name,keyPath:at(p,S),sourceKey:"$render-callback",sourceLocal:!0,...w.isIdentifier(a)?{ownerIdVar:a.name}:{}},T=i(e,_,l,o,r,"row",H,I,s,I);$t(e,_,T),t.creation.push(w.variableDeclaration("const",[w.variableDeclarator(w.cloneNode(v),w.newExpression(w.identifier("Set"),[]))])),t.updaters.push(()=>w.forOfStatement(w.variableDeclaration("const",[w.variableDeclarator(w.cloneNode(x))]),w.cloneNode(v),w.expressionStatement(w.callExpression(w.cloneNode(x),[]))));let re=[w.expressionStatement(w.assignmentExpression("=",w.cloneNode(c,!0),w.cloneNode(N)))];K!==null&&y!==null&&re.push(w.expressionStatement(w.assignmentExpression("=",w.identifier(y),w.cloneNode(K))));let ne=w.arrowFunctionExpression([w.cloneNode(c,!0),w.cloneNode(I),...y===null?[]:[w.identifier(y)],w.cloneNode(J)],w.blockStatement([Ye(_),Qe(_),w.variableDeclaration("const",[w.variableDeclarator(w.cloneNode(F),w.arrowFunctionExpression([],w.blockStatement([w.expressionStatement(w.callExpression(w.identifier(_.updateVar),[])),w.expressionStatement(w.callExpression(Z(e,"renderDescendants"),[w.cloneNode(I)]))])))]),gt(e,w.cloneNode(I),w.cloneNode(a,!0),w.cloneNode(F)),..._.creation,..._.mounts,w.expressionStatement(w.callExpression(w.memberExpression(w.cloneNode(v),w.identifier("add")),[w.cloneNode(F)])),w.returnStatement(w.objectExpression([w.objectProperty(w.identifier("nodes"),w.callExpression(Z(e,"rootNodes"),[w.identifier(T)])),w.objectProperty(w.identifier("entities"),w.arrayExpression([w.cloneNode(I)])),w.objectProperty(w.identifier("updateProps"),w.arrowFunctionExpression([w.cloneNode(N),...K===null?[]:[w.cloneNode(K)]],w.blockStatement(re))),w.objectProperty(w.identifier("update"),w.cloneNode(F)),w.objectProperty(w.identifier("dispose"),w.arrowFunctionExpression([],w.callExpression(w.memberExpression(w.cloneNode(v),w.identifier("delete")),[w.cloneNode(F)])))]))])),G=p===null?w.nullLiteral():w.arrowFunctionExpression([w.cloneNode(c,!0),...y===null?[]:[w.identifier(y)]],w.cloneNode(p));return t.creation.push(w.variableDeclaration("const",[w.variableDeclarator(w.cloneNode(f),w.objectExpression([w.objectProperty(w.identifier("create"),ne),w.objectProperty(w.identifier("key"),G)]))])),f}function Hs(e){return h.conditionalExpression(h.logicalExpression("||",h.binaryExpression("==",h.cloneNode(e),h.nullLiteral()),h.binaryExpression("===",h.unaryExpression("typeof",h.cloneNode(e),!0),h.stringLiteral("boolean"))),h.stringLiteral(""),h.callExpression(h.identifier("String"),[h.cloneNode(e)]))}function Us(e,t,n,o){return()=>vt(e,t,h.cloneNode(o),r=>h.expressionStatement(h.assignmentExpression("=",h.memberExpression(h.identifier(n),h.identifier("data")),Hs(r))))}function lo(e,t,n){let o=$(e,`text${t.textCounter++}`).name;if(h.isStringLiteral(n))return t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.identifier(o),h.callExpression(h.memberExpression(h.identifier("document"),h.identifier("createTextNode")),[h.stringLiteral(n.value)]))])),o;let r=An(e,t);t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.identifier(o),h.callExpression(h.memberExpression(h.identifier("document"),h.identifier("createTextNode")),[h.stringLiteral("")]))]));let i=Us(t,r,o,n);return t.creation.push(i()),t.updaters.push(i),o}function Mr(e,t){let n=!1;return h.traverseFast(e,o=>{h.isIdentifier(o,{name:t})&&(n=!0)}),n}function st(e,t,n,o,r,i=null,s,a,l=!1,d=Le(e,o)){return h.isJSXFragment(n)?_s(e,t,n,o,r,i,s,a,l,d):qs(e,t,n,o,r,i,s,a,l,d)}function _s(e,t,n,o,r,i,s,a,l=!1,d=Le(e,o)){let u=Qn(n.children,{emitText:g=>lo(e,t,g),emitNode:g=>st(e,t,g,o,r,i,s,a,l,d),isForwarded:g=>et(e,o,g),fail:g=>{throw r.buildCodeFrameError(g)}}),c=jn(e,t,"fragment");return t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.identifier(c),h.callExpression(h.memberExpression(h.identifier("document"),h.identifier("createDocumentFragment")),[]))])),Ar(e,t,u,c,o,r,i,s,l,d),c}function Ar(e,t,n,o,r,i,s=null,a,l=!1,d=Le(e,r)){for(let u of n)u.type==="node"?t.creation.push(h.expressionStatement(h.callExpression(h.memberExpression(h.identifier(o),h.identifier("appendChild")),[h.identifier(u.variable)]))):u.type==="slot"?$n(e,t,u.expression,o,d):u.type==="list"?jr(e,t,u.expression,o,r,i,l,d,a):Jr(e,t,u.expression,o,r,i,l,d,s!==null)}function co(e,t,n,o,r,i,s,a,l,d){return ko(e,t,d,(u,c,g)=>{No(u,n,c.name,{emitText:S=>lo(e,u,S),emitNode:S=>st(e,u,S,o,r,i,s,a,l,g),emitList:(S,y)=>jr(e,u,S,y,o,r,l,g,s),emitCondition:(S,y)=>Jr(e,u,S,y,o,r,l,g,i!==null),isForwarded:S=>et(e,o,S),emitForwarded:(S,y)=>$n(e,u,S,y,g),fail:S=>{throw r.buildCodeFrameError(S)}})})}function Lr(e,t,n,o,r,i,s,a,l,d){let u=h.isJSXElement(n)||h.isJSXFragment(n)?[n]:[h.jsxExpressionContainer(n)];return co(e,t,u,o,r,i,s,a,l,d)}function qs(e,t,n,o,r,i=null,s,a,l=!1,d=Le(e,o)){let u=n.openingElement,c=u.name.name;if(/^[A-Z]/.test(c)){let x=t.childCounts.get(c)??0;t.childCounts.set(c,x+1);let I=c.charAt(0).toLowerCase()+c.slice(1),J=x===0?I:`${I}${x}`,F=$(e,J).name,N=x===0?`/${c}`:`/${c}[${x}]`,K=[],_=e.componentProps.get(c);if(Vt(n.children)&&u.attributes.some(oe=>h.isJSXAttribute(oe)&&Ae(oe.name)==="children"))throw r.buildCodeFrameError(`memo-dom: <${c}> cannot use both a children prop and nested JSX children`);let H=u.attributes.some(oe=>h.isJSXSpreadAttribute(oe)),T=null,re=!1;if(H){T=Ht(u.attributes,{attributeValue:(Q,ae)=>Q==="ref"||_?.refProps.includes(Q)===!0?ut(e,r,o,ae):ae,fail:Q=>{throw r.buildCodeFrameError(Q)}}).expression;for(let Q of T.properties){if(!h.isObjectProperty(Q)||Q.computed||!h.isExpression(Q.value))continue;let ae=h.isIdentifier(Q.key)?Q.key.name:h.isStringLiteral(Q.key)?Q.key.value:null;if(ae!==null)if(_?.renderCallbacks.includes(ae)===!0)Q.value=ao(e,t,Q.value,o,r,st,l,d);else if(_?.renderProps.includes(ae)===!0){if(et(e,o,Q.value))continue;if(!ue(Q.value))throw r.buildCodeFrameError(`memo-dom: render prop '${ae}' on <${c}> must be JSX, a JSX-bearing conditional/list, or a forwarded render prop`);Q.value=Lr(e,t,Q.value,o,r,i,s,a,l,d)}else{if(ue(Q.value))throw r.buildCodeFrameError(`memo-dom: JSX prop '${ae}' on <${c}> is not rendered by the callee; interpolate that prop in <${c}> to declare a render slot`);ae!=="ref"&&_?.refProps.includes(ae)!==!0&&Jt(Q.value)&&(it(e,r,Q.value,o,s),Q.value=oo(e,t,Q.value,`${ae}Callback`))}}re=Dn(e,T,o)||s!==void 0&&Mr(T,s.itemParam)}else for(let oe of u.attributes){let Q=oe,ae=Ae(Q.name),E=Q.value==null?h.booleanLiteral(!0):$e(Q.value);if(E==null)throw r.buildCodeFrameError(`memo-dom: prop '${Ae(Q.name)}' on <${c}> must be an expression`);if(_?.renderCallbacks.includes(ae)===!0){K.push({name:ae,value:ao(e,t,E,o,r,st,l,d)});continue}if(ae==="ref"||_?.refProps.includes(ae)===!0){K.push({name:ae,value:ut(e,r,o,E)});continue}if(_?.renderProps.includes(ae)===!0){if(et(e,o,E)){K.push({name:ae,value:h.cloneNode(E)});continue}if(!ue(E))throw r.buildCodeFrameError(`memo-dom: render prop '${ae}' on <${c}> must be JSX, a JSX-bearing conditional/list, or a forwarded render prop`);K.push({name:ae,value:Lr(e,t,E,o,r,i,s,a,l,d)});continue}if(ue(E))throw r.buildCodeFrameError(`memo-dom: JSX prop '${ae}' on <${c}> is not rendered by the callee; interpolate that prop in <${c}> to declare a render slot`);let C=Jt(E);if(!C&&(Dn(e,E,o)||s!==void 0&&Mr(E,s.itemParam))&&(re=!0),C)it(e,r,E,o,s);else if(h.isIdentifier(E)){let M=It(r,E.name);M!==null&&!ue(M.body)&&it(e,r,M,o,s)}K.push({name:ae,value:C?oo(e,t,E,`${ae}Callback`):h.cloneNode(E)})}if(Vt(n.children)){if(u.attributes.some(Q=>h.isJSXAttribute(Q)&&Ae(Q.name)==="children"))throw r.buildCodeFrameError(`memo-dom: <${c}> cannot use both a children prop and nested JSX children`);let oe=co(e,t,n.children,o,r,i,s,a,l,d);T!==null?T.properties.push(h.objectProperty(h.identifier("children"),h.cloneNode(oe))):K.push({name:"children",value:h.cloneNode(oe)})}let ne;if(T!==null){let oe=$(e,`${I}Props`);t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.cloneNode(oe),h.cloneNode(T))])),ne=jt(e,c,oe)}else ne=kn(e,c,K);let G=h.binaryExpression("+",h.cloneNode(d),h.stringLiteral(N));return t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.identifier(F),h.callExpression(h.identifier(c),[G,h.cloneNode(d),...ne.length>0?[h.arrayExpression(ne)]:[]]))])),t.disposableEntities.push(h.cloneNode(G)),re&&t.updaters.push(()=>T===null?h.expressionStatement(h.callExpression(Z(e,"setProps"),[h.binaryExpression("+",h.cloneNode(d),h.stringLiteral(N)),h.arrayExpression(ne.map(oe=>h.cloneNode(oe)))])):Nr(e,c,d,N,T)),F}let g=vr(c,l),S=g&&c!=="foreignObject";if(u.attributes.find(x=>h.isJSXAttribute(x)&&Ae(x.name)==="innerHTML")!==void 0){if(g)throw r.buildCodeFrameError("memo-dom: innerHTML is only supported on HTML elements");if(n.children.some(I=>!h.isJSXText(I)||I.value.trim()!==""))throw r.buildCodeFrameError("memo-dom: an element using innerHTML cannot also have JSX children")}let p=Qn(n.children,{emitText:x=>lo(e,t,x),emitNode:x=>st(e,t,x,o,r,i,s,a,S,d),isForwarded:x=>et(e,o,x),fail:x=>{throw r.buildCodeFrameError(x)}}),f=jn(e,t,c);if(t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.identifier(f),kr(c,g))])),u.attributes.some(x=>h.isJSXSpreadAttribute(x))){let x=Ht(u.attributes,{attributeValue:(F,N)=>F==="ref"?ut(e,r,o,N):N,eventValue:(F,N)=>{let K=Yn(e,r,N,F,o,s,a),_=$(e,`${F}Handler`);return t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.cloneNode(_),K)])),_},fail:F=>{throw r.buildCodeFrameError(F)}}),I=$(e,`${c}Props`);t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.cloneNode(I),h.cloneNode(x.expression))]));let J=F=>h.expressionStatement(h.callExpression(Z(e,"patchDomProps"),[h.identifier(f),h.cloneNode(F),h.stringLiteral(e.rootId),h.arrayExpression(x.safeEventKeys.map(N=>h.stringLiteral(N)))]));t.creation.push(J(I)),so(e,t,h.identifier(f),d,h.memberExpression(h.cloneNode(I),h.identifier("ref"))),t.updaters.push(()=>J(x.expression))}else for(let x of u.attributes){let I=x,J=Ae(I.name);if(J==="ref"){let T=$e(I.value);if(T===null)throw r.buildCodeFrameError("memo-dom: ref needs an expression");so(e,t,h.identifier(f),d,ut(e,r,o,T));continue}if(J==="key")throw r.buildCodeFrameError("memo-dom: key={...} is only meaningful on list rows: items.map(item => <Row key={item.id} />)");if(/^on[A-Z]/.test(J)){let T=$e(I.value);if(T==null)throw r.buildCodeFrameError(`memo-dom: ${J} needs a handler expression (L1)`);let re=Yn(e,r,T,J,o,s,a);t.creation.push(t.delegatedEventRootVar===null?h.expressionStatement(h.assignmentExpression("=",h.memberExpression(h.identifier(f),h.identifier(J.toLowerCase())),re)):h.expressionStatement(h.callExpression(Z(e,"setDelegatedEvent"),[h.identifier(t.delegatedEventRootVar),h.identifier(f),h.stringLiteral(J),re])));continue}if(h.isStringLiteral(I.value)){J==="class"||J==="className"?t.creation.push(h.expressionStatement(h.callExpression(Z(e,"setClassValue"),[h.identifier(f),h.stringLiteral(I.value.value)]))):J==="style"?t.creation.push(h.expressionStatement(h.callExpression(Z(e,"setStyleValue"),[h.identifier(f),h.stringLiteral(I.value.value)]))):eo(J,g)!==null?t.creation.push(no(f,J,h.stringLiteral(I.value.value))):to(J,g)?t.creation.push(vn(f,J,h.stringLiteral(I.value.value))):g?t.creation.push(h.expressionStatement(h.callExpression(Z(e,"setDomValue"),[h.identifier(f),h.stringLiteral(J),h.stringLiteral(I.value.value)]))):t.creation.push(h.expressionStatement(h.callExpression(h.memberExpression(h.identifier(f),h.identifier("setAttribute")),[h.stringLiteral(J),h.stringLiteral(I.value.value)])));continue}let F=I.value==null?h.booleanLiteral(!0):$e(I.value);if(F==null||h.isStringLiteral(F))throw r.buildCodeFrameError(`memo-dom: attribute '${J}' needs a string or an expression (L1)`);let N=h.cloneNode(F);if(J==="style"){let T=()=>h.expressionStatement(h.callExpression(Z(e,"setStyleValue"),[h.identifier(f),h.cloneNode(N)]));t.creation.push(T()),t.updaters.push(T);continue}let K=An(e,t),_=eo(J,g),H=()=>J==="class"||J==="className"?vt(t,K,h.callExpression(Z(e,"classValue"),[h.cloneNode(N)]),T=>h.expressionStatement(h.callExpression(Z(e,"setClassValue"),[h.identifier(f),T]))):_!==null?vt(t,K,h.cloneNode(N),T=>no(f,_,T)):to(J,g)?vt(t,K,h.cloneNode(N),T=>vn(f,J,T)):g?vt(t,K,h.cloneNode(N),T=>h.expressionStatement(h.callExpression(Z(e,"setDomValue"),[h.identifier(f),h.stringLiteral(J),T]))):vt(t,K,h.cloneNode(N),T=>vn(f,J,T));t.creation.push(H()),t.updaters.push(H)}return Ar(e,t,p,f,o,r,i,s,S,d),f}function jr(e,t,n,o,r,i,s=!1,a=Le(e,r),l){Dr(e,t,n,o,r,i,st,co,s,a,l)}function Jr(e,t,n,o,r,i,s=!1,a=Le(e,r),l=!1){Ir(e,t,n,o,r,i,st,s,a,l)}function $r(e,t,n,o,r,i=!1,s=r,a=!1,l){return io(e,t,n,o,r,st,i,s,a,l)}import*as Ie from"@babel/types";function Tr(e){if(e.isFunctionDeclaration())return e.node;if(!e.isVariableDeclarator())return null;let t=e.node.init;return t&&(Ie.isArrowFunctionExpression(t)||Ie.isFunctionExpression(t))?t:null}function Br(e,t,n,o,r,i=!1){let s=It(t,n);if(s!==null){it(e,t,s,o,r,i);return}let a=t.scope.getBinding(n);if(a===void 0||a.scope.path.isProgram()!==!0||!e.helpers.has(n))return;let l=Tr(a.path);l!==null&&qt(e,l,i)}function Xr(e,t,n,o,r,i=!1){if(Ie.isArrowFunctionExpression(n)||Ie.isFunctionExpression(n)){if(ue(n.body))return;it(e,t,n,o,r,i)}else Ie.isIdentifier(n)&&Br(e,t,n.name,o,r,i)}function Vr(e,t,n,o=!1){let r=t.scope.getBinding(n);if(r===void 0||r.scope.path.isProgram()!==!0||!e.helpers.has(n))return;let i=Tr(r.path);i!==null&&qt(e,i,o)}function Or(e,t,n,o=!1){if(Ie.isArrowFunctionExpression(n)||Ie.isFunctionExpression(n)){if(ue(n.body))return;qt(e,n,o)}else Ie.isIdentifier(n)&&Vr(e,t,n.name,o)}function Wr(e,t,n,o,r){t.traverse({CallExpression(i){let s=i.getFunctionParent()===t,a=i.node.callee,l=Ie.isIdentifier(a,{name:"effect"})&&i.scope.getBinding("effect")===void 0;if(Ie.isIdentifier(a,{name:"cleanup"})&&i.scope.getBinding("cleanup")===void 0){if(!s)throw i.buildCodeFrameError("memo-dom: cleanup(disposer) must run directly during component factory initialization");let d=i.node.arguments[0];if(i.node.arguments.length!==1||d===void 0||!Ie.isExpression(d))throw i.buildCodeFrameError("memo-dom: cleanup(disposer) requires exactly one disposer expression");i.node.callee=Z(e,"cleanup"),i.node.arguments.unshift(Ie.identifier(o))}if(s){Ie.isIdentifier(a)&&Br(e,t,a.name,n,r);for(let d of i.node.arguments)Xr(e,t,d,n,r,l)}},NewExpression(i){if(i.getFunctionParent()===t)for(let s of i.node.arguments)Xr(e,t,s,n,r)}})}function zr(e,t){t.traverse({CallExpression(n){if(n.getFunctionParent()!==null)return;let o=Ie.isIdentifier(n.node.callee,{name:"effect"})&&n.scope.getBinding("effect")===void 0;Ie.isIdentifier(n.node.callee)&&Vr(e,t,n.node.callee.name);for(let r of n.node.arguments)Or(e,t,r,o)},NewExpression(n){if(n.getFunctionParent()===null)for(let o of n.node.arguments)Or(e,t,o)}})}function Kr(e){for(let t of e.helpers.values())t.node.async&&qt(e,t.node)}function Hr(e){e.traverse({CallExpression(t){if(Ie.isIdentifier(t.node.callee,{name:"cleanup"})&&t.scope.getBinding("cleanup")===void 0)throw t.buildCodeFrameError("memo-dom: cleanup(disposer) is only valid directly inside a component factory")}})}import*as Te from"@babel/types";import*as we from"@babel/types";function Ur(e){return e.reduce((t,n)=>we.logicalExpression("||",t,n))}function _r(e,t){let n=()=>we.identifier(e),o=Ur(t.map(i=>we.binaryExpression("===",n(),we.numericLiteral(i)))),r=Ur(t.map(i=>we.callExpression(we.memberExpression(n(),we.identifier("has")),[we.numericLiteral(i)])));return we.logicalExpression("||",we.binaryExpression("===",n(),we.nullLiteral()),we.conditionalExpression(we.binaryExpression("===",we.unaryExpression("typeof",n()),we.stringLiteral("number")),o,r))}function qr(e,t,n,o,r,i){let s=new Map(o.map((c,g)=>[c,g])),a=0,l=[...r.map(c=>({order:s.get(c.declaration)??Number.MAX_SAFE_INTEGER,sequence:a++,sources:c.sources,statement:yo(c)})),...i.map(c=>({order:s.get(c.statement)??Number.MAX_SAFE_INTEGER,sequence:a++,sources:c.sources,statement:Te.blockStatement([...c.resets.map(g=>Te.expressionStatement(Te.assignmentExpression("=",Te.identifier(g.binding),Te.cloneNode(g.source,!0)))),Te.cloneNode(c.statement,!0)])}))].sort((c,g)=>c.order-g.order||c.sequence-g.sequence),d=e.instanceReasonIds.get(t),u=[];for(let c of l){let g=n===null||d===void 0?null:c.sources.map(v=>d.get(v)).filter(v=>v!==void 0).sort((v,x)=>v-x),S=g===null||g.length===c.sources.length?g:null,y=S?.join(" ")??"*",p=u.at(-1),f=p?.reasons?.join(" ")??"*";p!==void 0&&f===y?p.statements.push(c.statement):u.push({reasons:S,statements:[c.statement]})}return Te.blockStatement(u.map(c=>c.reasons===null||n===null?Te.blockStatement(c.statements):Te.ifStatement(_r(n,c.reasons),Te.blockStatement(c.statements))))}import*as B from"@babel/types";function Gt(e){return!B.isReturnStatement(e)||!B.isJSXElement(e.argument)&&!B.isJSXFragment(e.argument)?null:{jsx:e.argument,statement:e}}function uo(e){return B.isBlockStatement(e)?e.body.length===1?Gt(e.body[0]):null:Gt(e)}function Gs(e){let t=[];return e.get("body").traverse({ReturnStatement(n){t.push(n.node)},Function(n){n.skip()}}),t}function Zs(e){if(B.isFunctionDeclaration(e))return!0;if(B.isVariableDeclaration(e))return e.declarations.every(t=>t.init==null||B.isFunction(t.init)||Ys(t.init));if(B.isSwitchStatement(e)||B.isIfStatement(e)){let t=!0;return B.traverseFast(e,n=>{(B.isCallExpression(n)||B.isOptionalCallExpression(n)||B.isNewExpression(n)||B.isAwaitExpression(n)||B.isYieldExpression(n)||B.isThrowStatement(n)||B.isTaggedTemplateExpression(n)||B.isUpdateExpression(n))&&(t=!1)}),t}return B.isTypeScript(e)}function Ys(e){let t=!0;return B.traverseFast(e,n=>{(B.isCallExpression(n)||B.isOptionalCallExpression(n)||B.isNewExpression(n)||B.isAwaitExpression(n)||B.isYieldExpression(n)||B.isTaggedTemplateExpression(n)||B.isAssignmentExpression(n)||B.isUpdateExpression(n))&&(t=!1)}),t}function Qs(e){if(!e.cases.some(o=>o.test==null))return null;let t=[],n=[];for(let o of e.cases){if(o.consequent.length!==1)return null;let r=Gt(o.consequent[0]);if(r===null)return null;let i=t.length;t.push(r.jsx),n.push(B.switchCase(o.test===null?null:B.cloneNode(o.test),[B.returnStatement(B.numericLiteral(i))]))}return{pick:B.arrowFunctionExpression([],B.blockStatement([B.switchStatement(B.cloneNode(e.discriminant),n)])),branches:t,statements:new Set([e])}}function Gr(e,t){let n=e.node.body.body,o=Gs(e),r=n.at(-1);if(o.length===1&&r!==void 0){let s=Gt(r);if(s!==null)return s}if(r&&B.isIfStatement(r)&&r.alternate!=null){let s=r.alternate,a=uo(r.consequent),l=uo(s);if(a!==null&&l!==null&&o.length===2)return{pick:B.arrowFunctionExpression([],B.conditionalExpression(B.cloneNode(r.test),B.numericLiteral(0),B.numericLiteral(1))),branches:[a.jsx,l.jsx],statements:new Set([r])}}if(r&&B.isSwitchStatement(r)){let s=Qs(r);if(s!==null&&s.branches.length===o.length)return s}let i=r===void 0?null:Gt(r);if(i!==null){let s=[],a=[],l=new Set([r]),d=-1,u=!0;for(let c=0;c<n.length-1;c++){let g=n[c];if(B.isIfStatement(g)&&g.alternate==null){let S=uo(g.consequent);if(S!==null){d===-1&&(d=c),s.push(B.cloneNode(g.test)),a.push(S.jsx),l.add(g);continue}}if(d!==-1&&!Zs(g)){u=!1;break}}if(a.push(i.jsx),u&&a.length===o.length&&a.length>1){let c=B.numericLiteral(a.length-1);for(let g=s.length-1;g>=0;g--)c=B.conditionalExpression(s[g],B.numericLiteral(g),c);return{pick:B.arrowFunctionExpression([],c),branches:a,statements:l}}}throw e.buildCodeFrameError(`memo-dom: component '${t}' has unsupported JSX return control flow; use a tail chain of JSX early returns, a terminal JSX if/else, or an exhaustive JSX switch`)}function Zr(e,t,n){let o=t.node,r=Gr(t,n),i=e.componentProps.get(n),s=i.params.length,a=e.listedSites.get(n)??[],l=e.linkedComponentRows.get(n)??[],d=a.some(T=>T.sourceLocal===!0)||l.some(T=>T.sourceLocal),u=Dt(e,n),c=Ze(e,u),g=e.instanceDerivations.get(n),S=e.instanceControlFlow.get(n),y=e.effects.get(n),p=y?.some(T=>T.localReads.size>0||T.localDerivationReads.size>0||T.conditionLocalReads.size>0||T.conditionLocalDerivationReads.size>0)===!0;(e.selectiveDerivationComponents.has(n)||p)&&(c.reasonVar=$(e,"reasons").name);let f=$(e,"id").name,v=u?null:$(e,"parent").name,x=u&&d?$(e,"owner").name:null,I=u&&e.componentsWithHostEvents.has(n)?$(e,"eventRoot").name:null;c.delegatedEventRootVar=I;let J=s>0&&!u?$(e,"props").name:null;xt(e).registerComponentId(n,f);let F;if((a.length>0||l.length>0)&&i.bindings.length>0){let T=[...a.map(Q=>at(Q.keyExpr??null,Q.itemParam??"")),...l.map(Q=>Q.keyPath)],re=JSON.stringify(T[0]),ne=T.every(Q=>JSON.stringify(Q)===re)?T[0]:null,G=on(i,"item"),oe=Be(i);F={itemParam:G??oe??i.bindings[0],itemPath:G===null&&oe!==null?["item"]:[],rowIdVar:f,...u?{refreshVar:c.updateVar}:{},keyPath:ne,sourceKey:a[0]?.sourceKey??l[0]?.sourceKey??"",sourceLocal:d,...d?{ownerIdVar:x??v}:{}}}Wr(e,t,n,f,F);let N="jsx"in r?st(e,c,r.jsx,n,t,null,F):ea(e,c,r,n,t,f);if(u&&$t(e,c,N),g!==void 0)for(let T of g)T.declaration.kind="let";(g!==void 0||S!==void 0)&&c.updaters.unshift(()=>qr(e,n,c.reasonVar,o.body.body,g??[],S??[])),y!==void 0&&p&&c.updaters.push(()=>$o(e,n,f,c.reasonVar,y,c));let K=new Set(y?.map(T=>T.statement)??[]),_=o.body.body.filter(T=>!("jsx"in r?T===r.statement:r.statements.has(T))&&!K.has(T));s>0&&!u&&c.updaters.unshift(()=>D.blockStatement(Mn(i,i.params.map((T,re)=>D.memberExpression(D.identifier(J),D.numericLiteral(re),!0)))));let H=[Ye(c)];if(s>0&&!u){let T=Eo(i,i.params.map((re,ne)=>D.memberExpression(D.identifier(J),D.numericLiteral(ne),!0)));T!==null&&H.push(T)}if(H.push(..._,Qe(c),...u?[]:[gt(e,D.identifier(f),D.identifier(v),D.identifier(c.updateVar))]),s>0&&!u&&H.push(D.expressionStatement(D.callExpression(Z(e,"registerProps"),[D.identifier(f),D.identifier(J)]))),H.push(...c.creation,...c.mounts),y!==void 0&&H.push(...Xo(e,f,y)),u){let T=i.params.map((re,ne)=>$(e,`nextProp${ne}`));H.push(D.returnStatement(D.objectExpression([D.objectProperty(D.identifier("nodes"),D.callExpression(Z(e,"rootNodes"),[D.identifier(N)])),D.objectProperty(D.identifier("entities"),D.arrayExpression([])),D.objectProperty(D.identifier("update"),D.identifier(c.updateVar)),...s>0?[D.objectProperty(D.identifier("updateProps"),D.arrowFunctionExpression(T,D.blockStatement(Mn(i,T))))]:[],...c.disposableCallbacks.length>0?[D.objectProperty(D.identifier("dispose"),D.arrowFunctionExpression([],D.blockStatement([...c.disposableCallbacks].reverse().map(re=>D.ifStatement(D.binaryExpression("!==",D.cloneNode(re),D.nullLiteral()),D.expressionStatement(D.callExpression(D.cloneNode(re),[])))))))]:[]])))}else H.push(D.returnStatement(D.identifier(N)));o.params=u?[...i.params.map(So),D.identifier(f),...x===null?[]:[D.identifier(x)],...I===null?[]:[D.identifier(I)]]:s>0?[D.identifier(f),D.identifier(v),D.identifier(J)]:[D.identifier(f),D.identifier(v)],o.body=D.blockStatement(H)}function ea(e,t,n,o,r,i){let s=$(e,"returnRoot").name,a=$(e,"returnRegion").name,l=D.identifier(i),d=D.binaryExpression("+",D.cloneNode(l),D.stringLiteral("/$return"));return t.creation.push(D.variableDeclaration("const",[D.variableDeclarator(D.identifier(s),D.callExpression(D.memberExpression(D.identifier("document"),D.identifier("createDocumentFragment")),[]))])),t.creation.push(D.variableDeclaration("const",[D.variableDeclarator(D.identifier(a),D.callExpression(Z(e,"createCondRegion"),[D.identifier(s),D.cloneNode(d),D.cloneNode(n.pick),D.arrayExpression(n.branches.map(u=>$r(e,u,o,r,d,!1,l,!0,t.usedConds)))]))])),t.updaters.push(()=>D.expressionStatement(D.callExpression(D.memberExpression(D.identifier(a),D.identifier("update")),[]))),s}import*as de from"@babel/types";function ta(e){return!de.isIdentifier(e.id)||!/^[A-Z]/.test(e.id.name)||!de.isArrowFunctionExpression(e.init)&&!de.isFunctionExpression(e.init)||!ue(e.init.body)?null:e.init}function na(e,t,n){if(t.async||t.generator)throw n.buildCodeFrameError(`memo-dom: component '${e}' must be synchronous`);if(de.isFunctionExpression(t)&&t.id!=null&&t.id.name!==e)throw n.buildCodeFrameError(`memo-dom: named component function expression '${t.id.name}' must match binding '${e}'`);let o=de.functionDeclaration(de.identifier(e),t.params.map(r=>de.cloneNode(r,!0)),de.isBlockStatement(t.body)?de.cloneNode(t.body,!0):de.blockStatement([de.returnStatement(de.cloneNode(t.body,!0))]));return o.returnType=t.returnType==null?null:de.cloneNode(t.returnType,!0),o.typeParameters=t.typeParameters==null?null:de.cloneNode(t.typeParameters,!0),o.loc=t.loc,o}function Yr(e,t,n){if(e.kind!=="const")return[t?de.exportNamedDeclaration(de.cloneNode(e,!0)):de.cloneNode(e,!0)];let o=[];for(let r of e.declarations){let i=ta(r),s;i===null?s=de.variableDeclaration("const",[de.cloneNode(r,!0)]):s=na(r.id.name,i,n),o.push(t?de.exportNamedDeclaration(s):s)}return o.length>0&&de.inheritsComments(o[0],e),o}function Zt(e){let t=[],n=!1;for(let o of e.get("body")){let r=o.node;if(de.isVariableDeclaration(r)){let i=Yr(r,!1,o);n||=i.some(s=>de.isFunctionDeclaration(s)),t.push(...i);continue}if(de.isExportNamedDeclaration(r)&&de.isVariableDeclaration(r.declaration)){let i=Yr(r.declaration,!0,o);n||=i.some(s=>de.isExportNamedDeclaration(s)&&de.isFunctionDeclaration(s.declaration)),t.push(...i);continue}t.push(r)}n&&(e.set("body",t),e.scope.crawl())}function oa(e,t){let n=`${e.rootId}/$computed/${encodeURIComponent(e.moduleId)}#`;for(let o of t.get("body")){let r=o.node;if(j.isExportNamedDeclaration(r)&&(r=r.declaration),!(!j.isVariableDeclaration(r)||r.kind!=="const"))for(let i of r.declarations){if(!j.isIdentifier(i.id)||i.init==null)continue;let s=i.id.name;if(!e.computeds.has(s))continue;r.kind="let";let a=j.cloneNode(i.init),l=$(e,`${s}Next`),d=j.expressionStatement(j.callExpression(Z(e,"register"),[j.objectExpression([j.objectProperty(j.identifier("id"),j.stringLiteral(`${n}${s}`)),j.objectProperty(j.identifier("parent"),j.nullLiteral()),j.objectProperty(j.identifier("depth"),j.unaryExpression("-",j.numericLiteral(1))),j.objectProperty(j.identifier("render"),j.arrowFunctionExpression([],j.blockStatement([j.variableDeclaration("const",[j.variableDeclarator(l,a)]),j.ifStatement(j.callExpression(Z(e,"computedChanged"),[j.identifier(s),j.cloneNode(l)]),j.blockStatement([j.expressionStatement(j.assignmentExpression("=",j.identifier(s),j.cloneNode(l))),j.expressionStatement(j.callExpression(Z(e,"commitWrites"),[Ot(e,[s])]))]))])))])]));o.insertAfter(d)}}}function ra(e,t){let n=new Map(t.get("body").map(o=>[o.node,o]));for(let o of e.moduleControlFlow){let r=n.get(o.statement);if(r===void 0)continue;let i=new Map(o.bindings.map(a=>[a,$(e,`${a}Previous`)])),s=[j.variableDeclaration("const",o.bindings.map(a=>j.variableDeclarator(j.cloneNode(i.get(a)),j.identifier(a)))),j.cloneNode(o.statement,!0),...o.bindings.map(a=>j.ifStatement(j.callExpression(Z(e,"computedChanged"),[j.cloneNode(i.get(a)),j.identifier(a)]),j.blockStatement([j.expressionStatement(j.callExpression(Z(e,"commitWrites"),[Ot(e,[a])]))])))];r.insertAfter(j.expressionStatement(j.callExpression(Z(e,"register"),[j.objectExpression([j.objectProperty(j.identifier("id"),j.stringLiteral(o.entityId)),j.objectProperty(j.identifier("parent"),j.nullLiteral()),j.objectProperty(j.identifier("depth"),j.unaryExpression("-",j.numericLiteral(1))),j.objectProperty(j.identifier("render"),j.arrowFunctionExpression([],j.blockStatement(s)))])])))}}function po(e,t={}){let n=Yt(t),o=new WeakSet;return{name:"memo-dom",visitor:{Program:{enter(i){Zt(i),En(n,i),Qt(n,i),Pn(n,i),zr(n,i),Kr(n)},exit(i){Oo(n,i),Hr(i),To(i),i.traverse({JSXElement(a){throw a.buildCodeFrameError("memo-dom: JSX outside a component function \u2014 components must be top-level function declarations (L1)")},JSXFragment(a){throw a.buildCodeFrameError("memo-dom: JSX outside a component function - components must be top-level function declarations")}});let s=Un(n);n.computeds.size>0&&oa(n,i),n.moduleControlFlow.length>0&&ra(n,i),s&&n.header.push(s);for(let a=n.header.length-1;a>=0;a--)i.unshiftContainer("body",n.header[a]);i.unshiftContainer("body",j.importDeclaration([j.importNamespaceSpecifier(j.identifier(xt(n).runtimeId))],j.stringLiteral(n.runtimePath)))}},FunctionDeclaration(i){let s=i.node.id?.name;!s||!n.comps.has(s)||o.has(i.node)||(o.add(i.node),Zr(n,i,s),i.skip())}}}}function fo(e,t={}){let n=ia(e,{filename:t.moduleId??"./component.tsx",plugins:[[sa,{}],[po,t],[aa,{isTSX:!0}]],configFile:!1,babelrc:!1});if(!n||n.code==null)throw new Error("memo-dom: compilation produced no output");return n.code}import{posix as Xt}from"node:path";import{transformSync as ui}from"@babel/core";import pi from"@babel/plugin-syntax-jsx";import fi from"@babel/plugin-transform-typescript";import*as V from"@babel/types";function la(e,t,n){let o=e.get(t);o===void 0&&(o=new Map,e.set(t,o));let r=o.get(n);return r===void 0&&(r={keys:new Set,rootFallback:!1},o.set(n,r)),r}function da(e,t,n,o){if(n.type==="state"){o.keys.add(n.key);return}if(n.type==="root"){o.rootFallback=!0;return}if(n.type==="local")return;let r=e.get(t)?.get(n.name);if(r===void 0){o.rootFallback=!0;return}o.rootFallback||=r.rootFallback;let i=n.path.length===0?"":`.${n.path.join(".")}`;for(let s of r.keys)o.keys.add(`${s}${i}`)}function Qr(e,t){let n=new Map;for(let s of e.values())for(let a of s.edges)n.set(a.target,(n.get(a.target)??0)+1);let o=new Map,r=new Map(n),i=[...t];for(;i.length>0;){let s=i.shift();for(let a of e.get(s)?.edges??[]){for(let[d,u]of Object.entries(a.propSources??{})){let c=la(o,a.target,d);for(let g of u)da(o,s,g,c)}let l=(r.get(a.target)??1)-1;r.set(a.target,l),l===0&&i.push(a.target)}}return new Map([...o].map(([s,a])=>[s,new Map([...a].map(([l,d])=>[l,{keys:[...d.keys].sort(),rootFallback:d.rootFallback}]))]))}function ca(e){let t=new Set,n=new Set,o=r=>{if(n.has(r))throw new Error(`memo-dom: recursive cross-module component graph at '${r}'`);if(!t.has(r)){n.add(r);for(let i of e.get(r)?.edges??[])o(i.target);n.delete(r),t.add(r)}};for(let r of e.keys())o(r)}function ei(e,t){let n=new Map(e.map(u=>[u.key,u]));ca(n);let o=new Map,r=new Map;for(let u of n.values())for(let c of u.edges){if(!n.has(c.target))throw new Error(`memo-dom: component '${u.key}' references unknown factory '${c.target}'`);let g=o.get(c.target)??new Set;if(g.add(c.mode),o.set(c.target,g),c.mode==="row"){let S=r.get(c.target)??[];S.push({keyPath:c.keyPath===void 0||c.keyPath===null?null:[...c.keyPath],sourceKey:c.sourceKey??"",sourceLocal:c.sourceLocal??!1}),r.set(c.target,S)}}for(let[u,c]of o)if(c.size>1)throw new Error(`memo-dom: component '${u}' is used both as a keyed row and a static child`);let i=new Map,s=[...n.keys()].filter(u=>!o.has(u));for(let u of s)i.set(u,new Set([t]));let a=[...s];for(;a.length>0;){let u=a.shift(),c=i.get(u);if(c!==void 0)for(let g of n.get(u)?.edges??[]){let S=i.get(g.target)??new Set,y=S.size;for(let p of c)S.add(`${p}${g.suffix}`);i.set(g.target,S),S.size!==y&&a.push(g.target)}}let l=new Map;for(let u of n.keys())l.set(u,[...i.get(u)??[]].sort());let d=Qr(n,s);return{paths:l,rows:r,propSources:d}}import"@babel/types";import*as be from"@babel/types";function ti(e){let t=e;for(;be.isTSAsExpression(t)||be.isTSTypeAssertion(t)||be.isTSNonNullExpression(t)||be.isTSSatisfiesExpression(t);)t=t.expression;return t}function ua(e,t,n){let o=ti(n);if(be.isIdentifier(o))return!e.state.has(o.name)||t.getBinding(o.name)?.scope.path.isProgram()!==!0?null:Ue(e,o.name);if(!be.isMemberExpression(o))return null;let r=Pe(o);return r===null||!e.state.has(r)||t.getBinding(r)?.scope.path.isProgram()!==!0?null:Ue(e,ye(o)??r)}function pa(e,t){let n=ti(t);if(be.isIdentifier(n)){let a=He(e,n.name);return a===null?null:{type:"prop",name:a,path:[]}}if(!be.isMemberExpression(n))return null;let o=Pe(n),r=ye(n);if(o===null||r===null)return null;if(Be(e)===o){let[a,...l]=r.split(".").slice(1);return a===void 0?null:{type:"prop",name:a,path:l}}let s=He(e,o);return s===null?null:{type:"prop",name:s,path:r.split(".").slice(1)}}function fa(e,t){let n=!1,o=Be(e);return Xe(t,r=>{be.isIdentifier(r)&&(r.name===o||He(e,r.name)!==null)&&(n=!0)}),n}function ma(e){return be.isStringLiteral(e)||be.isNumericLiteral(e)||be.isBooleanLiteral(e)||be.isNullLiteral(e)||be.isBigIntLiteral(e)||be.isTemplateLiteral(e)}function ga(e,t,n,o){let r=ua(e,n,o);if(r!==null)return{type:"state",key:r};let i=e.componentProps.get(t),s=pa(i,o);if(s!==null)return s;let a=be.isIdentifier(o)?o.name:be.isMemberExpression(o)?Pe(o):null;return a!==null&&(e.instanceState.get(t)?.has(a)===!0||e.instanceDerivedBindings.get(t)?.has(a)===!0)||en(e,o).size>0||fa(i,o)?{type:"root"}:ma(o)?{type:"local"}:{type:"root"}}function mo(e,t,n,o){let r=e.get(t)??{},i=r[n]??[],s=JSON.stringify(o);i.some(a=>JSON.stringify(a)===s)||(i.push(o),i.sort((a,l)=>JSON.stringify(a).localeCompare(JSON.stringify(l)))),r[n]=i,e.set(t,r)}function ba(e){return be.isJSXIdentifier(e.name)?e.name.name:null}function ni(e,t){let n=new Map;return e.compPaths.get(t).traverse({JSXOpeningElement(o){let r=o.node.name;if(!be.isJSXIdentifier(r)||!/^[A-Z]/.test(r.name))return;let i=e.componentProps.get(r.name);for(let s of o.get("attributes")){if(s.isJSXSpreadAttribute()){for(let d of i?.names??[])d==="ref"||i?.refProps.includes(d)||mo(n,r.name,d,{type:"root"});continue}if(!s.isJSXAttribute())continue;let a=ba(s.node);if(a===null||a==="key"||a==="ref"||i?.refProps.includes(a)===!0)continue;let l=s.node.value;if(!be.isJSXExpressionContainer(l)||!be.isExpression(l.expression)){mo(n,r.name,a,{type:"local"});continue}mo(n,r.name,a,ga(e,t,s.scope,l.expression))}}}),n}function oi(e,t){let n=new Map;return e.traverse({FunctionDeclaration(o){let r=o.node.id?.name;if(r!==void 0&&/^[A-Z]/.test(r)&&o.scope.parent?.path.isProgram()===!0&&De(o)){let i=nn(o.node.params);n.set(r,{key:`${t}#${r}`,props:[...i.names],objectProps:i.mode==="object",acceptsUnknownProps:i.acceptsUnknown,hasWholeDefault:i.hasWholeDefault,listLightweight:!1,delegatedEvents:xn(o.node.body),renderProps:[],renderCallbacks:[],refProps:[],subtreeReads:[]})}o.skip()}}),n}function ri(e,t,n){let o=e.componentProps.get(n);return{key:`${t}#${n}`,props:[...o.names],objectProps:o.mode==="object",acceptsUnknownProps:o.acceptsUnknown,hasWholeDefault:o.hasWholeDefault,listLightweight:bn(e,n),delegatedEvents:e.componentsWithHostEvents.has(n),renderProps:[...o.renderProps],renderCallbacks:[...o.renderCallbacks],refProps:[...o.refProps],subtreeReads:[...Sn(e,n)].map(r=>Ue(e,r)).sort()}}function In(e,t){return e.importedComponents.get(t)?.key??`${e.moduleId}#${t}`}function ii(e,t){let n=[];for(let o of t.comps.keys()){let r=[],i=ni(t,o);for(let[s,a]of t.childRefCounts.get(o)??[]){let l=In(t,s),d=i.get(s);r.push({target:l,suffix:`/${s}`,mode:"static",...d===void 0?{}:{propSources:d}}),a>1&&r.push({target:l,suffix:`/${s}[*]`,mode:"static",...d===void 0?{}:{propSources:d}})}for(let[s,a]of t.conditionalComponentSites)for(let l of a){if(l.owner!==o)continue;let d=i.get(s);r.push({target:In(t,s),suffix:`/${l.suffix}`,mode:"static",...d===void 0?{}:{propSources:d}})}for(let[s,a]of t.rowComponentSites)for(let l of a){if(l.owner!==o)continue;let d=i.get(s);r.push({target:In(t,s),suffix:`/${l.suffix}`,mode:"static",...d===void 0?{}:{propSources:d}})}for(let[s,a]of t.listedSites)for(let l of a)l.owner===o&&r.push({target:In(t,s),suffix:`/${l.suffix}/Row[*]`,mode:"row",keyPath:at(l.keyExpr??null,l.itemParam??""),sourceKey:l.sourceLocal===!0?l.sourceKey??"":Ue(t,l.sourceKey??""),sourceLocal:l.sourceLocal??!1,...i.get(s)===void 0?{}:{propSources:i.get(s)}});n.push({key:`${e}#${o}`,moduleId:e,local:o,edges:r})}return n}function mi(e){let t=e.replace(/\\/g,"/"),n=Xt.normalize(t);return t.startsWith("./")&&!n.startsWith("../")?`./${n}`:n}function gi(e){return{...e.runtimePath===void 0?{}:{runtimePath:e.runtimePath},...e.rootId===void 0?{}:{rootId:e.rootId}}}function ha(e){let t=new Map,n=(o,r,i)=>{t.set(`${o}\0${r}\0${i}`,{target:o,prop:r,kind:i})};for(let[o,r]of e.compPaths)r.traverse({JSXElement(i){let s=i.node.openingElement,a=s.name;if(!V.isJSXIdentifier(a)||!/^[A-Z]/.test(a.name))return;let l=e.importedComponents.get(a.name)?.key??(e.comps.has(a.name)?`${e.moduleId}#${a.name}`:null);if(l!==null){for(let d of s.attributes){if(!V.isJSXAttribute(d))continue;let u=V.isJSXIdentifier(d.name)?d.name.name:d.name.name.name,c=d.value;V.isJSXElement(c)||V.isJSXFragment(c)||V.isJSXExpressionContainer(c)&&V.isExpression(c.expression)&&(ue(c.expression)||et(e,o,c.expression))?n(l,u,"jsx"):n(l,u,"scalar")}i.node.children.some(d=>!V.isJSXText(d)||d.value.trim()!=="")&&n(l,"children","jsx")}}});return[...t.values()].sort((o,r)=>o.target.localeCompare(r.target)||o.prop.localeCompare(r.prop)||o.kind.localeCompare(r.kind))}function si(e,t){return[...new Set(t.flatMap(n=>{let o=e.importedComponents.get(n);return o!==void 0?[o.key]:e.comps.has(n)?[`${e.moduleId}#${n}`]:[]}))].sort()}function St(e,t,n){for(;V.isTSAsExpression(e)||V.isTSTypeAssertion(e)||V.isTSNonNullExpression(e);)e=e.expression;if(V.isIdentifier(e)){t.has(e.name)&&n.add(e.name);return}if(V.isConditionalExpression(e)){St(e.consequent,t,n),St(e.alternate,t,n);return}if(V.isLogicalExpression(e)){St(e.right,t,n);return}if(V.isObjectExpression(e)){for(let o of e.properties)V.isObjectProperty(o)&&V.isExpression(o.value)&&St(o.value,t,n);return}if(V.isArrayExpression(e))for(let o of e.elements)o!=null&&!V.isSpreadElement(o)&&St(o,t,n)}function ai(e,t){let n=new Set;if(V.isExpression(e.body))return St(e.body,t,n),[...n];let o=r=>{if(!V.isFunction(r)){if(V.isReturnStatement(r)){V.isExpression(r.argument)&&St(r.argument,t,n);return}for(let i of V.VISITOR_KEYS[r.type]??[]){let s=r[i];if(Array.isArray(s))for(let a of s)a!=null&&typeof a=="object"&&"type"in a&&o(a);else s!=null&&typeof s=="object"&&"type"in s&&o(s)}}};for(let r of e.body.body)o(r);return[...n]}function bi(e){let t=[];for(let n of e.body)if(!(!V.isImportDeclaration(n)||n.importKind==="type"))for(let o of n.specifiers)if(V.isImportSpecifier(o)){if(o.importKind==="type")continue;let r=V.isIdentifier(o.imported)?o.imported.name:o.imported.value;t.push({local:o.local.name,imported:r,source:n.source.value})}else V.isImportDefaultSpecifier(o)?t.push({local:o.local.name,imported:"default",source:n.source.value}):t.push({local:o.local.name,imported:"*",source:n.source.value});return t}function hi(e){let t=new Map;for(let n of e.body){if(V.isExportDefaultDeclaration(n)){(V.isFunctionDeclaration(n.declaration)||V.isClassDeclaration(n.declaration))&&n.declaration.id!=null?t.set("default",n.declaration.id.name):V.isIdentifier(n.declaration)&&t.set("default",n.declaration.name);continue}if(!V.isExportNamedDeclaration(n))continue;if(n.source!==null)throw new Error("memo-dom: re-export-from declarations are not supported by compileModules(); import then export the binding explicitly");let o=n.declaration;if(V.isVariableDeclaration(o))for(let r of o.declarations)V.isIdentifier(r.id)&&t.set(r.id.name,r.id.name);else V.isFunctionDeclaration(o)&&o.id!=null&&t.set(o.id.name,o.id.name);for(let r of n.specifiers){if(!V.isExportSpecifier(r))continue;let i=r.local.name,s=V.isIdentifier(r.exported)?r.exported.name:r.exported.value;t.set(s,i)}}return t}function Ea(e,t,n){let o,r=()=>({visitor:{Program(i){Zt(i);let s=bi(i.node),a=Yt({...gi(n),moduleId:e.id,linkedImports:t});En(a,i),Qt(a,i),Pn(a,i);let l={},d=Hn(i.node);for(let[u,c]of hi(i.node)){if(a.comps.has(c)){l[u]={type:"component",...ri(a,e.id,c)};continue}let g=a.state.get(c);if(g!==void 0){l[u]={type:"state",kind:g,key:a.stateKeys.get(c)??`${e.id}#${c}`,tagCandidates:[...a.stateTagCandidates.get(c)??[]],componentCandidates:si(a,a.stateComponentCandidates.get(c)??[])};continue}let S=a.importedFunctions.get(c)??(a.helpers.has(c)?Ve(a,c):void 0);S!==void 0&&(l[u]={type:"function",tagCandidates:[...d.get(c)??a.functionTagCandidates.get(c)??[]],componentCandidates:si(a,a.functionComponentCandidates.get(c)??[]),reads:[...S.reads].map(y=>Ue(a,y)).sort(),writes:[...S.writes].map(y=>Ue(a,y)).sort(),boundedWrites:[...S.boundedWrites].map(y=>Ue(a,y)).sort(),parameterWrites:S.parameterWrites.map(y=>({index:y.index,path:[...y.path]})).sort((y,p)=>y.index-p.index||y.path.join(".").localeCompare(p.path.join("."))),unbounded:S.unbounded})}o={exports:l,imports:s,components:ii(e.id,a),componentUsages:ha(a)}}}});if(ui(e.source,{filename:e.id,plugins:[[pi,{}],r,[fi,{isTSX:!0}]],configFile:!1,babelrc:!1}),o===void 0)throw new Error(`memo-dom: failed to analyze module '${e.id}'`);return o}function ya(e){let t,n=()=>({visitor:{Program(o){Zt(o);let r=new Map,i=yn(o.node),s=Hn(o.node),a=oi(o,e.id),l=new Set(a.keys());for(let[u,c]of a)r.set(u,{type:"component",...c});for(let u of o.node.body){let c=V.isExportNamedDeclaration(u)?u.declaration:u;if(V.isVariableDeclaration(c))for(let g of c.declarations){if(!V.isIdentifier(g.id))continue;if(V.isArrowFunctionExpression(g.init)||V.isFunctionExpression(g.init)){let y=ai(g.init,l).map(p=>`${e.id}#${p}`);r.set(g.id.name,{type:"function",tagCandidates:[...s.get(g.id.name)??[]],componentCandidates:y,reads:[],writes:[],boundedWrites:[],parameterWrites:[],unbounded:!0});continue}let S;if(c.kind==="let"||c.kind==="var"?S="let":Ct(g.init)?S="store":Pt(g.init)&&(S="const"),S!==void 0){let y=new Set;V.isExpression(g.init)&&St(g.init,l,y),r.set(g.id.name,{type:"state",kind:S,key:`${e.id}#${g.id.name}`,tagCandidates:[...i.get(g.id.name)??[]],componentCandidates:[...y].map(p=>`${e.id}#${p}`)})}}else if(V.isFunctionDeclaration(c)&&c.id!=null&&!a.has(c.id.name)){let g=ai(c,l).map(S=>`${e.id}#${S}`);r.set(c.id.name,{type:"function",tagCandidates:[...s.get(c.id.name)??[]],componentCandidates:g,reads:[],writes:[],boundedWrites:[],parameterWrites:[],unbounded:!0})}}let d={};for(let[u,c]of hi(o.node)){let g=r.get(c);g!==void 0&&(d[u]=g)}t={exports:d,imports:bi(o.node),components:[],componentUsages:[]}}}});if(ui(e.source,{filename:e.id,plugins:[[pi,{}],n,[fi,{isTSX:!0}]],configFile:!1,babelrc:!1}),t===void 0)throw new Error(`memo-dom: failed to discover module '${e.id}'`);return t}function Ei(e,t,n,o){let i=o.resolveImport?.(t,e);if(i===void 0){let l=Object.entries(o.aliases??{}).sort(([d],[u])=>u.length-d.length);for(let[d,u]of l)if(d.endsWith("/")?t.startsWith(d):t===d||t.startsWith(`${d}/`)){i=`${u}${t.slice(d.length)}`;break}}if(i===void 0)if(t.startsWith(".")){let l=Xt.normalize(Xt.join(Xt.dirname(e),t));i=e.startsWith("./")&&!l.startsWith("../")?`./${l}`:l}else i=t;let s=mi(i??t),a=[s,`${s}.ts`,`${s}.tsx`,`${s}.js`,`${s}.jsx`,`${s}/index.ts`,`${s}/index.tsx`,`${s}/index.js`,`${s}/index.jsx`];for(let l of a){let d=n.get(l);if(d!==void 0)return d}}function Sa(e,t){if(!t.startsWith("."))return t;let n=Xt.relative(Xt.dirname(e),t);return n.startsWith(".")?n:`./${n}`}function li(e,t,n){return t.map(o=>{for(let[r,i]of n)for(let[s,a]of Object.entries(i.exports))if(!(a.type!=="component"||a.key!==o))return{key:a.key,source:Sa(e.id,r),imported:s,props:[...a.props],objectProps:a.objectProps,acceptsUnknownProps:a.acceptsUnknownProps,hasWholeDefault:a.hasWholeDefault,listLightweight:a.listLightweight,delegatedEvents:a.delegatedEvents,renderProps:[...a.renderProps],renderCallbacks:[...a.renderCallbacks],refProps:[...a.refProps],subtreeReads:[...a.subtreeReads]};throw new Error(`memo-dom: dynamic component candidate '${o}' is not exported; export the component so consuming modules can link it`)})}function di(e,t,n,o,r,i){let s={};for(let a of t.imports){let l=Ei(e.id,a.source,o,r);if(l===void 0){s[a.local]={type:"function",tagCandidates:[],componentCandidates:[],reads:[],writes:[],boundedWrites:[],parameterWrites:[],unbounded:!0};continue}if(a.imported==="*")throw new Error(`memo-dom: namespace import '${a.local}' from '${a.source}' cannot identify a reactive export; use named imports`);let d=n.get(l.id)?.exports[a.imported];if(d===void 0){s[a.local]={type:"function",tagCandidates:[],componentCandidates:[],reads:[],writes:[],boundedWrites:[],parameterWrites:[],unbounded:!0};continue}if(d.type==="state")s[a.local]={type:"state",kind:d.kind,key:d.key,tagCandidates:[...d.tagCandidates],componentCandidates:li(e,d.componentCandidates,n)};else if(d.type==="component"){let u=i?.get(d.key),c=d.renderProps.filter(g=>u?.scalar.has(g)!==!0||u.jsx.has(g));s[a.local]={type:"component",key:d.key,props:[...d.props],objectProps:d.objectProps,acceptsUnknownProps:d.acceptsUnknownProps,hasWholeDefault:d.hasWholeDefault,listLightweight:d.listLightweight,delegatedEvents:d.delegatedEvents,renderProps:c,renderCallbacks:[...d.renderCallbacks],refProps:[...d.refProps],subtreeReads:[...d.subtreeReads]}}else s[a.local]={type:"function",tagCandidates:[...d.tagCandidates],componentCandidates:li(e,d.componentCandidates,n),reads:[...d.reads],writes:[...d.writes],boundedWrites:[...d.boundedWrites],parameterWrites:[...d.parameterWrites],unbounded:d.unbounded}}return s}function ci(e){return JSON.stringify(e)}function xa(e,t={}){let n=new Map;for(let[a,l]of Object.entries(e)){let d=mi(a);if(n.has(d))throw new Error(`memo-dom: duplicate module id after normalization: '${d}'`);n.set(d,{originalId:a,id:d,source:l})}let o=new Map;for(let a of n.values())o.set(a.id,ya(a));for(let a=0;a<=n.size;a++){let l=!1,d=new Map;for(let u of n.values()){let c=o.get(u.id),g=di(u,c,o,n,t),S=Ea(u,g,t);d.set(u.id,S),ci(S)!==ci(c)&&(l=!0)}if(o=d,!l)break;if(a===n.size)throw new Error("memo-dom: cross-module export summaries did not converge")}let r=new Map;for(let a of o.values())for(let l of a.componentUsages){let d=r.get(l.target);d===void 0&&(d={jsx:new Set,scalar:new Set},r.set(l.target,d)),d[l.kind].add(l.prop)}for(let[a,l]of r)for(let d of l.jsx)if(l.scalar.has(d))throw new Error(`memo-dom: component '${a}' prop '${d}' is used as both scalar data and JSX content; split the prop or component contract`);let i=ei([...o.values()].flatMap(a=>a.components),t.rootId??"App"),s={};for(let a of n.values()){let l=o.get(a.id),d=di(a,l,o,n,t,r);for(let y of l.imports){let p=Ei(a.id,y.source,n,t);if(p!==void 0&&o.get(p.id)?.exports[y.imported]===void 0)throw new Error(`memo-dom: '${y.imported}' is not a linkable state, function, or component export of '${y.source}'`)}let u={},c={},g={},S={};for(let y of l.components){u[y.local]=[...i.paths.get(y.key)??[]];let p=i.rows.get(y.key);p!==void 0&&(c[y.local]=p.map(x=>({keyPath:x.keyPath===null?null:[...x.keyPath],sourceKey:x.sourceKey,sourceLocal:x.sourceLocal})));let f=i.propSources.get(y.key);f!==void 0&&(g[y.local]=Object.fromEntries([...f].map(([x,I])=>[x,{keys:[...I.keys],rootFallback:I.rootFallback}])));let v=Object.values(l.exports).find(x=>x.type==="component"&&x.key===y.key);if(v?.type==="component"){let x=r.get(y.key);S[y.local]=v.renderProps.filter(I=>x?.scalar.has(I)!==!0||x.jsx.has(I))}}s[a.originalId]=fo(a.source,{...gi(t),moduleId:a.id,linkedImports:d,linkedComponentPaths:u,linkedComponentRows:c,linkedComponentPropSources:g,linkedComponentRenderProps:S})}return s}export{fo as compile,xa as compileModules};
1
+ import{transformSync as Ca}from"@babel/core";import Pa from"@babel/plugin-syntax-jsx";import wa from"@babel/plugin-transform-typescript";import*as $ from"@babel/types";import"@babel/types";function an(e={}){let t=e.moduleId??"./component.tsx",n=new Map,r=new Map,o=new Map,i=new Map,s=new Map,a=new Map,l=new Map,d=new Set,u=new Map,c=new Map;for(let[E,f]of Object.entries(e.linkedImports??{}))f.type==="state"?(n.set(E,f.kind),r.set(E,f.key),f.tagCandidates!==void 0&&o.set(E,[...f.tagCandidates]),f.componentCandidates!==void 0&&l.set(E,f.componentCandidates.map(m=>({...m}))),d.add(E)):f.type==="function"?(f.tagCandidates!==void 0&&i.set(E,[...f.tagCandidates]),f.componentCandidates!==void 0&&l.set(E,f.componentCandidates.map(m=>({...m}))),u.set(E,{reads:new Set(f.reads),writes:new Set(f.writes),boundedWrites:new Set(f.boundedWrites),parameterWrites:f.parameterWrites.map(m=>({index:m.index,path:[...m.path]})),unbounded:f.unbounded})):c.set(E,{...f,props:[...f.props]});let g=new Map;for(let[E,f]of c)g.set(E,{mode:f.objectProps?"object":"positional",names:[...f.props],acceptsUnknown:f.acceptsUnknownProps,bindings:[],params:[],hasWholeDefault:f.hasWholeDefault,renderProps:[...f.renderProps??[]],renderCallbacks:[...f.renderCallbacks??[]],refProps:[...f.refProps??[]]});let x=new Map(Object.entries(e.linkedComponentRenderProps??{}).map(([E,f])=>[E,[...f]]));return{runtimePath:e.runtimePath??"@memoized-dom/runtime",rootId:e.rootId??"App",moduleId:t,state:n,stateKeys:r,stateTagCandidates:o,functionTagCandidates:i,stateComponentCandidates:s,functionComponentCandidates:a,linkedDynamicComponentCandidates:l,importedState:d,importedFunctions:u,importedComponents:c,linkedComponentPaths:new Map(Object.entries(e.linkedComponentPaths??{}).map(([E,f])=>[E,[...f]])),linkedComponentRows:new Map(Object.entries(e.linkedComponentRows??{}).map(([E,f])=>[E,f.map(m=>({keyPath:m.keyPath===null?null:[...m.keyPath],sourceKey:m.sourceKey,sourceLocal:m.sourceLocal}))])),linkedComponentPropSources:new Map(Object.entries(e.linkedComponentPropSources??{}).map(([E,f])=>[E,new Map(Object.entries(f).map(([m,C])=>[m,{keys:[...C.keys],rootFallback:C.rootFallback}]))])),comps:new Map,compPaths:new Map,helpers:new Map,jsxHelpers:new Map,helperSummaries:new Map,compReads:new Map,childRefCounts:new Map,renderSlotOwners:new Set,listedSites:new Map,componentsWithHostEvents:new Set,conditionalComponentSites:new Map,rowComponentSites:new Map,componentProps:g,linkedComponentRenderProps:x,lightweightCache:new Map,rowReads:new Map,condReads:new Map,targetedListDependencies:new WeakMap,targetedListComponents:new Set,keyedListMutations:new WeakMap,keyedListMutationSources:new Map,disabledKeyedListMutationSources:new Set,instanceState:new Map,instanceDerivations:new Map,instanceControlFlow:new Map,instanceDerivedBindings:new Map,instanceReasonIds:new Map,selectiveDerivationComponents:new Set,effects:new Map,moduleEffects:[],computeds:new Map,moduleControlFlow:[],header:[],readers:new Map,writeConstCounter:0,writeConsts:new Map,reasonConstCounter:0,reasonConsts:new Map,analyzedFunctions:new WeakSet,handlerHasRootCommit:new WeakMap,identifiers:null}}import*as G from"@babel/types";import*as lt from"@babel/types";var On=class{constructor(t,n){this.scope=t;Mi(n.node,r=>this.reserved.add(r)),this.runtimeId=this.generate("MD").name}scope;runtimeId;reserved=new Set;componentIds=new Map;generate(t){let n;do n=this.scope.generateUidIdentifier(t);while(this.reserved.has(n.name));return this.reserved.add(n.name),n}registerComponentId(t,n){this.componentIds.set(t,n)}componentId(t){let n=this.componentIds.get(t);if(n===void 0)throw new Error(`memo-dom: missing generated factory id for '${t}'`);return lt.identifier(n)}runtimeMember(t){return lt.memberExpression(lt.identifier(this.runtimeId),lt.identifier(t))}};function ln(e,t){let n=new On(t.scope,t);return e.identifiers=n,n}function A(e,t){return vt(e).generate(t)}function Je(e,t){return vt(e).componentId(t)}function Q(e,t){return vt(e).runtimeMember(t)}function vt(e){if(e.identifiers===null)throw new Error("memo-dom: generated identifier allocator was not initialized");return e.identifiers}function Mi(e,t){let n=r=>{lt.isIdentifier(r)&&t(r.name);for(let o of lt.VISITOR_KEYS[r.type]??[]){let i=r[o];if(Array.isArray(i))for(let s of i)s&&typeof s=="object"&&"type"in s&&n(s);else i&&typeof i=="object"&&"type"in i&&n(i)}};n(e)}function bt(e,t,n){e.state.set(t,n),e.stateKeys.has(t)||e.stateKeys.set(t,`${e.moduleId}#${t}`)}function Ye(e,t){if(t.includes("#"))return t;let n=t.indexOf("."),r=n===-1?t:t.slice(0,n),o=n===-1?"":t.slice(n);return`${e.stateKeys.get(r)??r}${o}`}function Ut(e,t){let n=[...new Set(t.map(s=>Ye(e,s)))].sort(),r=n.join(" "),o=e.writeConsts.get(r);if(o!==void 0)return G.identifier(o);let i=A(e,`WRITES_${e.writeConstCounter++}`);return e.writeConsts.set(r,i.name),e.header.push(G.variableDeclaration("const",[G.variableDeclarator(i,G.arrayExpression(n.map(s=>G.stringLiteral(s))))])),i}function Cr(e,t){let n=[...new Set(t)].sort((s,a)=>s-a),r=n.join(" "),o=e.reasonConsts.get(r);if(o!==void 0)return G.identifier(o);let i=A(e,`REASONS_${e.reasonConstCounter++}`);return e.reasonConsts.set(r,i.name),e.header.push(G.variableDeclaration("const",[G.variableDeclarator(i,G.arrayExpression(n.map(s=>G.numericLiteral(s))))])),i}function ye(e){let t=[],n=e;for(;G.isMemberExpression(n);){if(n.computed){if(!G.isStringLiteral(n.property))return null;t.unshift(n.property.value)}else{if(!G.isIdentifier(n.property))return null;t.unshift(n.property.name)}if(G.isSuper(n.object))return null;n=n.object}for(;G.isTSNonNullExpression(n)||G.isTSAsExpression(n);)n=n.expression;return G.isIdentifier(n)?(t.unshift(n.name),t.join(".")):null}function nt(e,t){if(e===null)return[];let n=[],r=e;for(;G.isMemberExpression(r)&&!r.computed;){if(!G.isIdentifier(r.property)||(n.unshift(r.property.name),G.isSuper(r.object)))return null;r=r.object}return!G.isIdentifier(r,{name:t})||n.length===0?null:n}function At(e,t){return t===null?!0:t.length===0||e.length>t.length?!1:e.every((n,r)=>t[r]===n)}function ve(e){let t=e;for(;;){if(G.isMemberExpression(t)){if(G.isSuper(t.object))return null;t=t.object;continue}if(G.isTSNonNullExpression(t)||G.isTSAsExpression(t)){t=t.expression;continue}break}return G.isIdentifier(t)?t.name:null}function kt(e){return!e||!G.isObjectExpression(e)?!1:e.properties.every(t=>G.isObjectProperty(t)&&!t.computed&&(G.isIdentifier(t.key)||G.isStringLiteral(t.key)))}function Nt(e){return e?G.isArrayExpression(e)||G.isNewExpression(e):!1}function Be(e){return e==null?null:G.isStringLiteral(e)?e:G.isJSXExpressionContainer(e)?G.isJSXEmptyExpression(e.expression)?null:e.expression:null}function Xn(e,t,n){let r=n!==void 0?e.instanceState.get(n):void 0,o=n!==void 0?e.instanceDerivedBindings.get(n):void 0,i=n!==void 0?e.componentProps.get(n)?.bindings:void 0,s=!1,a=l=>{if(!s){if(G.isIdentifier(l)&&(e.state.has(l.name)||r?.has(l.name)===!0||o?.has(l.name)===!0||i?.includes(l.name)===!0)){s=!0;return}for(let d of G.VISITOR_KEYS[l.type]??[]){let u=l[d];if(Array.isArray(u))for(let c of u)c&&typeof c=="object"&&"type"in c&&a(c);else u&&typeof u=="object"&&"type"in u&&a(u)}}};return a(t),s}function Pr(e,t,n){let r=new Set([...e.instanceState.get(n)??[],...e.instanceDerivedBindings.get(n)??[],...e.componentProps.get(n)?.bindings??[]]);if(r.size===0)return!1;let o=!1;return Le(t,i=>G.isIdentifier(i)&&r.has(i.name)?(o=!0,!1):o?!1:void 0),o}function Le(e,t){let n=(r,o)=>{if(t(r,o)!==!1)for(let i of G.VISITOR_KEYS[r.type]??[]){let s=r[i];if(Array.isArray(s))for(let a of s)a&&typeof a=="object"&&"type"in a&&n(a,r);else s&&typeof s=="object"&&"type"in s&&n(s,r)}};n(e,null)}function de(e){let t=!1;return Le(e,n=>{(G.isJSXElement(n)||G.isJSXFragment(n))&&(t=!0)}),t}function dn(e,t){let n=new Set;return Le(t,r=>{if(G.isJSXAttribute(r)&&G.isJSXIdentifier(r.name,{name:"ref"}))return!1;G.isIdentifier(r)&&e.state.has(r.name)&&n.add(r.name)}),n}import*as P from"@babel/types";import*as ce from"@babel/types";import*as Ge from"@babel/types";function cn(e){let t=Ge.cloneNode(e,!0);return Ge.traverseFast(t,n=>{(Ge.isIdentifier(n)||Ge.isObjectPattern(n)||Ge.isArrayPattern(n)||Ge.isRestElement(n)||Ge.isAssignmentPattern(n))&&(n.typeAnnotation=null)}),t}import*as Ce from"@babel/types";import*as q from"@babel/types";function un(e){if(e.some(i=>q.isTSParameterProperty(i)))throw new Error("TypeScript parameter properties are not valid component props");let t=e;if(t.length===0)return{mode:"positional",names:[],acceptsUnknown:!1,bindings:[],params:[],hasWholeDefault:!1,renderProps:[],renderCallbacks:[],refProps:[]};let n=ht(t[0]);if(t.length===1&&(q.isObjectPattern(n)||q.isIdentifier(n)&&n.name==="props"))return{mode:"object",names:q.isObjectPattern(n)?Di(n):[],acceptsUnknown:q.isIdentifier(n)||n.properties.some(s=>q.isRestElement(s)),bindings:Ht(n),params:t.map(s=>q.cloneNode(s)),hasWholeDefault:q.isAssignmentPattern(t[0]),renderProps:[],renderCallbacks:[],refProps:[]};let o=[];for(let i of t){let s=ht(i);if(!q.isIdentifier(s))throw new Error("object-destructured props must be the component's only parameter");o.push(s.name)}return{mode:"positional",names:o,acceptsUnknown:!1,bindings:t.flatMap(i=>Ht(ht(i))),params:t.map(i=>q.cloneNode(i)),hasWholeDefault:!1,renderProps:[],renderCallbacks:[],refProps:[]}}function wr(e,t){return e.params.length===0?null:q.variableDeclaration("let",e.params.map((n,r)=>q.variableDeclarator(Li(ht(n)),Nr(n,t[r]??q.identifier("undefined")))))}function Tn(e,t){return e.params.map((n,r)=>q.expressionStatement(q.assignmentExpression("=",Ir(ht(n)),Nr(n,t[r]??q.identifier("undefined")))))}function vr(e){return q.expressionStatement(q.assignmentExpression("=",Ir(e.target),q.cloneNode(e.source)))}function Ht(e){return Object.keys(q.getBindingIdentifiers(e))}function Ke(e){if(e.mode!=="object"||e.params.length!==1)return null;let t=ht(e.params[0]);return q.isIdentifier(t)?t.name:null}function pn(e,t){if(e.mode==="positional")return e.names.includes(t)?t:null;if(e.params.length!==1)return null;let n=ht(e.params[0]);if(!q.isObjectPattern(n))return null;for(let r of n.properties){if(!q.isObjectProperty(r)||r.computed||(q.isIdentifier(r.key)?r.key.name:q.isStringLiteral(r.key)?r.key.value:null)!==t)continue;let i=q.isAssignmentPattern(r.value)?r.value.left:r.value;return q.isIdentifier(i)?i.name:null}return null}function Ze(e,t){if(e.mode==="positional")return e.names.includes(t)?t:null;if(e.params.length!==1)return null;let n=ht(e.params[0]);if(!q.isObjectPattern(n))return null;for(let r of n.properties)if(!(!q.isObjectProperty(r)||r.computed)&&Object.keys(q.getBindingIdentifiers(r.value)).includes(t)){if(q.isIdentifier(r.key))return r.key.name;if(q.isStringLiteral(r.key))return r.key.value}return null}function ht(e){if(q.isRestElement(e))throw new Error("rest component parameters are not supported");let t=q.isAssignmentPattern(e)?e.left:e;if(!q.isIdentifier(t)&&!q.isObjectPattern(t)&&!q.isArrayPattern(t))throw new Error("unsupported component parameter target");return t}function kr(e){let t=q.cloneNode(e);return _t(t),t}function Nr(e,t){return q.isAssignmentPattern(e)?q.conditionalExpression(q.binaryExpression("===",q.cloneNode(t),q.identifier("undefined")),q.cloneNode(e.right),q.cloneNode(t)):q.cloneNode(t)}function Di(e){let t=[];for(let n of e.properties)if(!q.isRestElement(n)){if(n.computed)throw new Error("computed keys are not supported in component prop patterns");if(q.isIdentifier(n.key))t.push(n.key.name);else if(q.isStringLiteral(n.key))t.push(n.key.value);else throw new Error("component prop pattern keys must be identifiers or strings")}return t}function Li(e){let t=q.cloneNode(e);return _t(t),t}function Ir(e){let t=q.cloneNode(e);return _t(t),t}function _t(e){let t=e;"typeAnnotation"in t&&(t.typeAnnotation=null),"optional"in t&&(t.optional=null);for(let n of q.VISITOR_KEYS[e.type]??[]){let r=e[n];if(Array.isArray(r))for(let o of r)o&&typeof o=="object"&&"type"in o&&_t(o);else r&&typeof r=="object"&&"type"in r&&_t(r)}}function Rr(e,t){let n=t.findParent(d=>d.isArrowFunctionExpression()||d.isFunctionExpression());if(n===null||!n.isArrowFunctionExpression()&&!n.isFunctionExpression())return!1;let r=n.get("body");if(!(r.isJSXElement()&&r.node===t.node||r.isBlockStatement()&&r.node.body.length===1&&Ce.isReturnStatement(r.node.body[0])&&r.node.body[0].argument===t.node))return!1;let i=n.parentPath,s=i?.parentPath,a=s?.parentPath;if(!i?.isJSXExpressionContainer()||!s?.isJSXAttribute()||!a?.isJSXOpeningElement()||!Ce.isJSXIdentifier(a.node.name))return!1;let l=Ce.isJSXIdentifier(s.node.name)?s.node.name.name:s.node.name.name.name;return e.componentProps.get(a.node.name.name)?.renderCallbacks.includes(l)===!0||/^[A-Z]/.test(a.node.name.name)}function Ai(e){return Ce.isMemberExpression(e.callee)&&!e.callee.computed&&Ce.isIdentifier(e.callee.property,{name:"map"})}function ji(e,t,n){let r=e.componentProps.get(t);if(r===void 0)return null;let o=Ke(r);return o!==null&&Ce.isMemberExpression(n)&&!n.computed&&Ce.isIdentifier(n.object,{name:o})&&Ce.isIdentifier(n.property)?n.property.name:Ce.isIdentifier(n)?Ze(r,n.name)??(pn(r,n.name)!==null?n.name:null):null}function Ji(e){return Ce.isExpression(e.body)?e.body:e.body.body.length===1&&Ce.isReturnStatement(e.body.body[0])&&Ce.isExpression(e.body.body[0].argument)?e.body.body[0].argument:null}function jt(e,t,n){if(!Ai(n)||n.arguments.length!==1)return null;let r=n.arguments[0];if(!Ce.isArrowFunctionExpression(r))return null;let o=Ji(r);if(o===null||!Ce.isCallExpression(o)||!Ce.isExpression(o.callee)||o.arguments.some(s=>!Ce.isExpression(s)))return null;let i=ji(e,t,o.callee);return i===null?null:{propName:i,target:Ce.cloneNode(o.callee,!0),arguments:o.arguments.map(s=>Ce.cloneNode(s,!0))}}function Fr(e){for(let[t,n]of e.compPaths){let r=e.componentProps.get(t);n.traverse({CallExpression(o){let i=jt(e,t,o.node);i!==null&&!r.renderCallbacks.includes(i.propName)&&r.renderCallbacks.push(i.propName)}})}}import*as Re from"@babel/types";function It(e){for(;Re.isTSAsExpression(e)||Re.isTSTypeAssertion(e)||Re.isTSNonNullExpression(e)||Re.isTSInstantiationExpression(e);)e=e.expression;return e}function fn(e){let t=It(e);return Re.isArrayExpression(t)&&t.elements.every(n=>n!==null&&!Re.isSpreadElement(n)&&(Re.isStringLiteral(n)||Re.isNumericLiteral(n)||Re.isBooleanLiteral(n)||Re.isNullLiteral(n)||Re.isBigIntLiteral(n)))}function Ve(e){if(!ce.isCallExpression(e))return null;let t=e.callee;return ce.isMemberExpression(t)&&!t.computed&&ce.isIdentifier(t.property,{name:"map"})?e:null}function Ae(e){let t=!1;return e.traverse({JSXElement(){t=!0},JSXFragment(){t=!0}}),t}function Rt(e,t,n,r,o,i){let s=g=>{throw n.buildCodeFrameError(g)},a=t.callee,l=$i(e,a.object,r,i,s),d=Ti(e,t,r,s),u=Bi(e,d,s),c=zi(l.suffixBase,o);return{sourceKey:l.key,sourceExpr:ce.cloneNode(l.expression),sourceLocal:l.local,itemPattern:d.itemPattern,itemParam:d.itemParam,indexParam:d.indexParam,keyExpr:Wi(d.jsx?.openingElement??null,s),jsx:d.jsx,form:u.form,rowComp:u.rowComp,renderCallback:u.renderCallback,owner:r,suffix:c,prefix:`${r}/${c}`}}function $i(e,t,n,r,o){return ce.isIdentifier(t)?Oi(e,t,n,o):ce.isMemberExpression(t)?Xi(e,t,n,r,o):ce.isExpression(t)&&fn(t)?{expression:t,key:"$static-list",local:!0,suffixBase:"$static-list"}:o("memo-dom: assign an ordered collection view to reactive state or a local derivation before mapping it")}function Oi(e,t,n,r){let o=e.componentProps.get(n)?.bindings??[],i=e.instanceState.get(n)?.has(t.name)===!0||e.instanceDerivedBindings.get(n)?.has(t.name)===!0||o.includes(t.name),s=e.state.get(t.name);return!i&&s!=="let"&&s!=="const"&&s!=="computed"?r("memo-dom: list views must come from reactive module state, component props, component state, or a local derivation"):{expression:t,key:t.name,local:i,suffixBase:t.name}}function Xi(e,t,n,r,o){let i=ve(t),s=ye(t),a=e.componentProps.get(n)?.bindings??[],l=i!==null&&(e.instanceState.get(n)?.has(i)===!0||a.includes(i)),d=i!==null&&s!==null&&r!==void 0&&i===r.itemParam;return i===null||s===null||!s.includes(".")||!d&&!l&&e.state.get(i)!=="store"?o("memo-dom: list member views must be a static path on reactive module state, component props, or component state"):{expression:t,key:d?r.sourceKey:s,local:d?r.sourceLocal:l,suffixBase:s.slice(s.lastIndexOf(".")+1)}}function Ti(e,t,n,r){if(t.arguments.length!==1||!ce.isArrowFunctionExpression(t.arguments[0]))return r("memo-dom: list rendering expects items.map(item => <JSX />) \u2014 R7 L1");let o=t.arguments[0],i=o.params[0],s=o.params[1];if(o.params.length<1||o.params.length>2||!ce.isIdentifier(i)&&!ce.isObjectPattern(i)&&!ce.isArrayPattern(i)||s!==void 0&&!ce.isIdentifier(s))return r("memo-dom: list callback must take an item binding pattern and optional index identifier \u2014 R7 L1");let a=cn(i),l=Object.keys(ce.getBindingIdentifiers(a));if(l.length===0)return r("memo-dom: list callback item pattern must bind at least one name \u2014 R7 L1");let d=ce.isIdentifier(a)?a.name:l[0],u=ce.isIdentifier(s)?s.name:null,c=ce.isBlockStatement(o.body)&&o.body.body.length===1&&ce.isReturnStatement(o.body.body[0])?o.body.body[0].argument:null,g=ce.isJSXElement(o.body)?o.body:ce.isJSXElement(c)?c:null,x=jt(e,n,t);return g===null&&x===null?r("memo-dom: list callback body must be one JSX element or a block containing only return <JSX /> \u2014 R7 L1"):{itemPattern:a,itemParam:d,indexParam:u,jsx:g,renderInvocation:x}}function Bi(e,t,n){let r=t.jsx?.openingElement??null;if(r!==null&&!ce.isJSXIdentifier(r.name))return n("memo-dom: namespaced JSX tags are not supported (L1)");let o=r!==null&&ce.isJSXIdentifier(r.name)?r.name.name:null;return t.renderInvocation!==null?(Vi(t,n),{form:"callback",rowComp:null,renderCallback:ce.cloneNode(t.renderInvocation.target,!0)}):o!==null&&/^[A-Z]/.test(o)?!e.comps.has(o)&&!e.importedComponents.has(o)?n(`memo-dom: <${o} /> is not a linked component factory`):{form:"component",rowComp:o,renderCallback:null}:{form:"inline",rowComp:null,renderCallback:null}}function Vi(e,t){let n=e.renderInvocation;(!ce.isIdentifier(e.itemPattern)||n.arguments.length<1||n.arguments.length>2||!ce.isIdentifier(n.arguments[0],{name:e.itemPattern.name})||n.arguments.length===2&&(e.indexParam===null||!ce.isIdentifier(n.arguments[1],{name:e.indexParam})))&&t("memo-dom: render callback maps must pass their item and optional index bindings directly")}function Wi(e,t){let n=null;for(let r of e?.attributes??[])if(ce.isJSXAttribute(r)&&ce.isJSXIdentifier(r.name,{name:"key"})&&(n=Be(r.value),n===null))return t("memo-dom: key={...} needs an expression");return n}function zi(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}${n}`}import*as re from"@babel/types";function mn(e){return re.isConditionalExpression(e)||re.isLogicalExpression(e)&&(e.operator==="&&"||e.operator==="||")?e:null}function Ki(e){return re.isNullLiteral(e)||re.isBooleanLiteral(e,{value:!1})||re.isIdentifier(e,{name:"undefined"})}function Ui(e,t){let n=[e];for(;n.length>0;){let r=n.pop();if(re.isJSXElement(r)){for(let o of r.openingElement.attributes)!re.isJSXSpreadAttribute(o)&&o.name.name==="key"&&t("memo-dom: key={...} is only meaningful on list rows");n.push(...r.children)}else if(re.isJSXFragment(r))n.push(...r.children);else if(re.isJSXExpressionContainer(r)&&re.isExpression(r.expression)){let o=r.expression;if(Ve(o)!==null&&de(o))continue}}}function gn(e,t,n){let r=l=>{throw t.buildCodeFrameError(l)},o,i;if(re.isConditionalExpression(e)){let l=[];i=[];let d=e;for(;re.isConditionalExpression(d);)l.push(re.cloneNode(d.test)),i.push(d.consequent),d=d.alternate;i.push(d),o=re.numericLiteral(i.length-1);for(let u=l.length-1;u>=0;u--)o=re.conditionalExpression(l[u],re.numericLiteral(u),o)}else e.operator==="&&"?(o=re.conditionalExpression(re.cloneNode(e.left),re.numericLiteral(0),re.numericLiteral(1)),i=[e.right,null]):(o=re.conditionalExpression(re.cloneNode(e.left),re.numericLiteral(1),re.numericLiteral(0)),i=[e.right,null]);let s=l=>l===null||Ki(l)?null:re.isJSXElement(l)||re.isJSXFragment(l)?l:re.isExpression(l)?re.jsxFragment(re.jsxOpeningFragment(),re.jsxClosingFragment(),[re.jsxExpressionContainer(re.cloneNode(l,!0))]):r("memo-dom: conditional branches must be JSX, renderable text expressions, or null/false"),a=i.map(s);for(let l of a)l!==null&&Ui(l,r);return{pickExpr:o,branches:a,suffix:`when${n.count++}`}}import*as De from"@babel/types";import*as me from"@babel/types";var Jt=class{constructor(t){this.fallback=t}fallback;origins=new WeakMap;trackDeclarator(t,n){if(!me.isIdentifier(n.id)||n.init===null)return;let r=this.resolveExpression(t,n.init);if(r===null)return;let o=t.getBinding(n.id.name);o!==void 0&&this.origins.set(o.identifier,r)}referencedOrigins(t,n){let r=new Map,o=i=>{if(me.isIdentifier(i)||me.isMemberExpression(i)){let s=this.resolveExpression(t,i);if(s!==null){let a=[s.locality,s.root,s.key??"*"].join(":");r.set(a,s);return}}for(let s of me.VISITOR_KEYS[i.type]??[]){let a=i[s];if(Array.isArray(a))for(let l of a)l&&typeof l=="object"&&"type"in l&&o(l);else a&&typeof a=="object"&&"type"in a&&o(a)}};return o(n),[...r.values()]}resolveName(t,n){let r=t.getBinding(n);if(r!==void 0){let o=this.origins.get(r.identifier);if(o!==void 0)return o}return this.fallback(n,r)}resolveExpression(t,n){let r=Mr(n);if(me.isIdentifier(r))return this.resolveName(t,r.name);if(!me.isMemberExpression(r))return null;let o=Hi(r);if(o===null)return null;let i=this.resolveName(t,o);if(i===null)return null;let s=ye(r);if(i.key===null||s===null)return{...i,key:null};let a=s.split(".").slice(1);return{...i,key:[i.key,...a].join(".")}}};function bn(e,t){return{locality:"module",root:e,key:e,stateKind:t}}function Et(e,t){return e.key===null?e:{...e,key:[e.key,...t].join(".")}}function hn(e,t){if(e.key===null)return null;let n=[];for(let r of t){if(!me.isObjectExpression(r))return null;for(let o of r.properties){if(!me.isObjectProperty(o)||o.computed||!me.isIdentifier(o.key)&&!me.isStringLiteral(o.key))return null;let i=me.isIdentifier(o.key)?o.key.name:o.key.value;n.push(`${e.key}.${i}`)}}return n}function En(e){let t=[];for(let n of e)me.isExpression(n)?t.push(n):me.isSpreadElement(n)&&t.push(n.argument);return t}function yn(e){return!e.computed&&me.isIdentifier(e.property)?e.property.name:e.computed&&me.isStringLiteral(e.property)?e.property.value:null}function Hi(e){let t=e;for(;me.isMemberExpression(t);){if(me.isSuper(t.object))return null;t=Mr(t.object)}return me.isIdentifier(t)?t.name:null}function Mr(e){let t=e;for(;me.isTSAsExpression(t)||me.isTSTypeAssertion(t)||me.isTSNonNullExpression(t)||me.isTypeCastExpression(t)||me.isTSSatisfiesExpression(t);)t=t.expression;return t}function Ue(e,t,n=new Set){let r=e.helperSummaries.get(t);if(r)return r;if(n.has(t))return{reads:new Set,writes:new Set,boundedWrites:new Set,parameterWrites:[],unbounded:!0};let o=e.helpers.get(t),i=new Set,s=new Map(o.node.params.flatMap((f,m)=>De.isIdentifier(f)?[[f.name,m]]:[])),a={reads:new Set,writes:new Set,boundedWrites:new Set,parameterWrites:[],unbounded:!1},l=new Jt((f,m)=>{if(s.has(f)&&m?.scope.block===o.node)return{locality:"prop",root:f,key:f};let C=e.state.get(f);return C===void 0||m!==void 0&&!m.scope.path.isProgram()?null:bn(f,C)}),d=f=>f.stateKind==="computed"||e.state.get(f.root)==="computed";n.add(t),o.traverse({VariableDeclarator(f){De.isIdentifier(f.node.id)&&(i.add(f.node.id.name),f.parentPath.isVariableDeclaration()&&l.trackDeclarator(f.scope,f.node))},Function(f){for(let m of f.node.params)De.isIdentifier(m)&&i.add(m.name)}});let u=(f,m)=>{a.parameterWrites.some(C=>C.index===f&&C.path.length===m.length&&C.path.every((y,v)=>y===m[v]))||a.parameterWrites.push({index:f,path:m})},c=f=>{if(!d(f)){if(f.locality==="module"){a.boundedWrites.add(f.key??f.root);return}if(f.locality==="prop"){let m=s.get(f.root);if(m!==void 0){let C=f.key===null?[]:f.key.split(".").slice(1);u(m,C);return}}a.unbounded=!0}},g=f=>{f.locality==="prop"?c(f):f.locality!=="module"?a.unbounded=!0:f.stateKind!=="store"?a.writes.add(f.root):f.key!==null&&f.key.includes(".")?a.writes.add(f.key):a.boundedWrites.add(f.root)},x=(f,m)=>{let C=l.resolveExpression(f.scope,m);C!==null&&g(C)},E=(f,m)=>{for(let C of En(m)){if(!De.isIdentifier(C))continue;let y=l.resolveExpression(f.scope,C);y!==null&&!d(y)&&c(y)}};return o.traverse({VariableDeclarator(f){if(!De.isIdentifier(f.node.id)&&f.node.init!==null)for(let m of l.referencedOrigins(f.scope,f.node.init))c(m)},AssignmentExpression(f){let m=f.node.left;if(De.isIdentifier(m))if(i.has(m.name)){if(De.isIdentifier(f.node.right)){let C=l.resolveExpression(f.scope,f.node.right);C!==null&&c(C)}}else e.state.has(m.name)&&a.writes.add(m.name);else if(De.isMemberExpression(m))x(f,m);else for(let C of l.referencedOrigins(f.scope,f.node.right))c(C)},UpdateExpression(f){let m=f.node.argument;De.isIdentifier(m)?!i.has(m.name)&&e.state.has(m.name)&&a.writes.add(m.name):De.isMemberExpression(m)&&x(f,m)},UnaryExpression(f){f.node.operator==="delete"&&De.isMemberExpression(f.node.argument)&&x(f,f.node.argument)},CallExpression(f){let m=f.node.callee;if(De.isMemberExpression(m)){if(yn(m)==="assign"&&De.isIdentifier(m.object,{name:"Object"})){let v=f.node.arguments[0],M=v!==void 0&&De.isExpression(v)?l.resolveExpression(f.scope,v):null;if(M!==null){let R=hn(M,f.node.arguments.slice(1));if(R===null)c(M);else for(let I of R)g({...M,key:I})}return}let y=De.isExpression(m.object)?l.resolveExpression(f.scope,m.object):null;y!==null?c(y):E(f,f.node.arguments);return}if(De.isIdentifier(m)&&(e.helpers.has(m.name)||e.importedFunctions.has(m.name))){let C=e.importedFunctions.get(m.name)??Ue(e,m.name,n);for(let y of C.reads)a.reads.add(y);for(let y of C.writes)a.writes.add(y);for(let y of C.boundedWrites)a.boundedWrites.add(y);for(let y of C.parameterWrites){let v=f.node.arguments[y.index];if(v===void 0||!De.isExpression(v))continue;let M=l.resolveExpression(f.scope,v);M!==null&&c(Et(M,y.path))}C.unbounded&&(a.unbounded=!0);return}E(f,f.node.arguments)},Identifier(f){let m=f.node.name;if(!e.state.has(m)||i.has(m))return;let C=f.parentPath;C.isAssignmentExpression({operator:"="})&&C.node.left===f.node||a.reads.add(m)},MemberExpression(f){let m=_i(e,f);m!==null&&a.reads.add(m)}}),n.delete(t),e.helperSummaries.set(t,a),a}function _i(e,t){let n=ye(t.node);if(!n||!n.includes("."))return null;let r=n.split(".")[0];if(e.state.get(r)!=="store"||t.scope.getBinding(r)?.scope.path.isProgram()!==!0)return null;let o=t.parentPath;return o.isAssignmentExpression({operator:"="})&&o.node.left===t.node||qi(t)?null:n}function qi(e){let t=e.parentPath;return t.isCallExpression()&&t.node.callee===e.node}import*as b from"@babel/types";import*as se from"@babel/types";function rt(e,t=!1){return{slots:[],tempVar:A(e,"value").name,updateVar:A(e,"update").name,reasonVar:null,delegatedEventRootVar:null,creation:[],mounts:[],updaters:[],tagCounters:new Map,childCounts:new Map,usedPrefixes:new Map,usedConds:{count:0},textCounter:0,regionCounter:0,disposableRegions:[],disposableEntities:[],disposableCallbacks:[],forwardedSlotCounter:0,manualDisposal:t}}function ot(e){return se.variableDeclaration("let",[...e.slots.map(t=>se.variableDeclarator(se.identifier(t))),se.variableDeclarator(se.identifier(e.tempVar))])}function Bn(e,t){let n=A(e,`slot${t.slots.length}`).name;return t.slots.push(n),n}function Vn(e,t,n){let r=t.tagCounters.get(n)??0;return t.tagCounters.set(n,r+1),A(e,`${n}${r}`).name}function Ft(e,t,n,r){let o=()=>se.identifier(e.tempVar),i=()=>se.identifier(t);return se.ifStatement(se.binaryExpression("!==",i(),se.assignmentExpression("=",o(),n)),se.blockStatement([se.expressionStatement(se.assignmentExpression("=",i(),o())),r(o())]))}function it(e){return se.variableDeclaration("const",[se.variableDeclarator(se.identifier(e.updateVar),se.arrowFunctionExpression(e.reasonVar===null?[]:[se.assignmentPattern(se.identifier(e.reasonVar),se.nullLiteral())],se.blockStatement(e.updaters.map(t=>t()))))])}function yt(e,t,n,r){return se.expressionStatement(se.callExpression(Q(e,"register"),[se.objectExpression([se.objectProperty(se.identifier("id"),t),se.objectProperty(se.identifier("parent"),n),se.objectProperty(se.identifier("render"),r)])]))}function Wn(e){let t=e.replace(/\s+/g," ");return/^\s*\n/.test(e)&&(t=t.replace(/^ /,"")),/\n\s*$/.test(e)&&(t=t.replace(/ $/,"")),t}function qt(e){return e.some(t=>!b.isJSXText(t)||t.value.trim()!=="")}function pt(e,t,n){let r=e.componentProps.get(t);if(r===void 0)return null;let o=Ke(r);if(o!==null&&b.isMemberExpression(n)&&!n.computed&&b.isIdentifier(n.object,{name:o})&&b.isIdentifier(n.property))return n.property.name;if(b.isIdentifier(n)){let i=Ze(r,n.name);if(i!==null)return i;if(n.name==="children"&&e.instanceDerivedBindings.get(t)?.has("children")===!0)return"children"}return null}function st(e,t,n){let r=pt(e,t,n);return r!==null&&e.componentProps.get(t)?.renderProps.includes(r)===!0}function Dr(e,t,n,r){let o=rt(e,!0);o.childCounts=t.childCounts,o.usedPrefixes=t.usedPrefixes,o.usedConds=t.usedConds;let i=A(e,"childrenUpdate"),s=A(e,"childrenUpdates"),a=A(e,"childrenMountSequence"),l=A(e,"children"),d=A(e,"childrenParent"),u=A(e,"childrenOwner"),c=A(e,"childrenKey"),g=A(e,"childrenSlot"),x=A(e,"childrenNextUpdate"),E=A(e,"childrenActive"),f=A(e,"childrenDispose");return r(o,d,g),t.creation.push(b.variableDeclaration("let",[b.variableDeclarator(b.cloneNode(i),b.nullLiteral()),b.variableDeclarator(b.cloneNode(s),b.nullLiteral()),b.variableDeclarator(b.cloneNode(a),b.numericLiteral(0))]),b.variableDeclaration("const",[b.variableDeclarator(b.cloneNode(l),b.arrowFunctionExpression([b.cloneNode(d),b.cloneNode(u),b.cloneNode(c)],b.blockStatement([b.variableDeclaration("const",[b.variableDeclarator(b.cloneNode(g),b.conditionalExpression(b.binaryExpression("===",b.cloneNode(a),b.numericLiteral(0)),b.cloneNode(n,!0),b.binaryExpression("+",b.binaryExpression("+",b.cloneNode(n,!0),b.stringLiteral("/$slot[")),b.binaryExpression("+",b.cloneNode(a),b.stringLiteral("]")))))]),b.expressionStatement(b.updateExpression("++",b.cloneNode(a))),b.variableDeclaration("let",[b.variableDeclarator(b.cloneNode(E),b.booleanLiteral(!0))]),ot(o),it(o),...o.creation,...o.mounts,b.ifStatement(b.binaryExpression("===",b.cloneNode(i),b.nullLiteral()),b.expressionStatement(b.assignmentExpression("=",b.cloneNode(i),b.identifier(o.updateVar))),b.blockStatement([b.ifStatement(b.binaryExpression("===",b.cloneNode(s),b.nullLiteral()),b.expressionStatement(b.assignmentExpression("=",b.cloneNode(s),b.newExpression(b.identifier("Set"),[])))),b.expressionStatement(b.callExpression(b.memberExpression(b.cloneNode(s),b.identifier("add")),[b.identifier(o.updateVar)]))])),b.variableDeclaration("const",[b.variableDeclarator(b.cloneNode(f),b.arrowFunctionExpression([],b.blockStatement([b.ifStatement(b.unaryExpression("!",b.cloneNode(E)),b.returnStatement()),b.expressionStatement(b.assignmentExpression("=",b.cloneNode(E),b.booleanLiteral(!1))),b.ifStatement(b.binaryExpression("===",b.cloneNode(i),b.identifier(o.updateVar)),b.expressionStatement(b.assignmentExpression("=",b.cloneNode(i),b.nullLiteral())),b.ifStatement(b.binaryExpression("!==",b.cloneNode(s),b.nullLiteral()),b.expressionStatement(b.callExpression(b.memberExpression(b.cloneNode(s),b.identifier("delete")),[b.identifier(o.updateVar)])))),...o.disposableRegions.map(m=>b.expressionStatement(b.callExpression(b.memberExpression(b.identifier(m),b.identifier("dispose")),[]))),...[...o.disposableCallbacks].reverse().map(m=>b.ifStatement(b.binaryExpression("!==",b.cloneNode(m),b.nullLiteral()),b.expressionStatement(b.callExpression(b.cloneNode(m),[])))),...o.disposableEntities.map(m=>b.expressionStatement(b.callExpression(Q(e,"unregisterSubtree"),[b.cloneNode(m,!0)])))])))]),b.expressionStatement(b.callExpression(Q(e,"cleanup"),[b.cloneNode(u),b.cloneNode(f)])),b.returnStatement(b.cloneNode(f))])))])),t.updaters.push(()=>b.blockStatement([b.ifStatement(b.binaryExpression("!==",b.cloneNode(i),b.nullLiteral()),b.expressionStatement(b.callExpression(b.cloneNode(i),[]))),b.ifStatement(b.binaryExpression("!==",b.cloneNode(s),b.nullLiteral()),b.forOfStatement(b.variableDeclaration("const",[b.variableDeclarator(b.cloneNode(x))]),b.cloneNode(s),b.expressionStatement(b.callExpression(b.cloneNode(x),[]))))])),l}function zn(e,t,n,r,o){let i=A(e,"slotDispose"),s=t.forwardedSlotCounter++;t.creation.push(b.variableDeclaration("const",[b.variableDeclarator(b.cloneNode(i),b.conditionalExpression(b.binaryExpression("==",b.cloneNode(n,!0),b.nullLiteral()),b.nullLiteral(),b.callExpression(b.cloneNode(n,!0),[b.identifier(r),b.cloneNode(o,!0),b.stringLiteral(String(s))])))])),t.disposableCallbacks.push(i)}function Lr(e,t,n,r){let o=i=>{e.creation.push(b.expressionStatement(b.callExpression(b.memberExpression(b.identifier(n),b.identifier("appendChild")),[b.identifier(i)])))};for(let i of t){if(b.isJSXText(i)){let d=Wn(i.value);d!==""&&o(r.emitText(b.stringLiteral(d)));continue}if(b.isJSXElement(i)||b.isJSXFragment(i)){o(r.emitNode(i));continue}if(b.isJSXExpressionContainer(i)||r.fail("memo-dom: spread children are not supported (L1)"),b.isJSXEmptyExpression(i.expression))continue;b.isExpression(i.expression)||r.fail("memo-dom: unsupported expression in component children");let s=i.expression;if(b.isNullLiteral(s)||b.isBooleanLiteral(s)||b.isIdentifier(s,{name:"undefined"}))continue;if(r.isForwarded(s)){r.emitForwarded(s,n);continue}let a=Ve(s);if(a!==null){r.emitList(a,n);continue}let l=mn(s);if(l!==null&&de(l)){r.emitCondition(l,n);continue}o(r.emitText(b.cloneNode(s)))}}import*as j from"@babel/types";function Cn(e){return j.isIdentifier(e.node.callee,{name:"effect"})&&e.scope.getBinding("effect")===void 0}function xn(e,t){return j.binaryExpression("+",j.identifier(e),j.stringLiteral(`/$effects/${t}`))}function Gi(e,t){return j.binaryExpression("+",xn(e,t),j.stringLiteral("/$active"))}function Zi(e){if(e.isFunctionDeclaration())return e;if(!e.isVariableDeclarator())return null;let t=e.get("init");return t.isArrowFunctionExpression()||t.isFunctionExpression()?t:null}function Or(e,t){let n=t.get("arguments"),r=n[0];if(n.length!==1||r===void 0)throw t.buildCodeFrameError("memo-dom: effect() requires exactly one callback");if(r.isArrowFunctionExpression()||r.isFunctionExpression()){if(r.node.async||r.node.generator)throw r.buildCodeFrameError("memo-dom: effect callback must be synchronous; start async work inside it and return a synchronous teardown");return{expression:r.node,path:r,importedReads:new Set}}if(!r.isIdentifier())throw r.buildCodeFrameError("memo-dom: effect callback must be an inline function or a resolvable function identifier");if(e.importedFunctions.get(r.node.name)!==void 0)throw r.buildCodeFrameError(`memo-dom: imported named effect callback '${r.node.name}' is not supported yet; define a local synchronous wrapper so its cleanup and writes can be instrumented`);let i=r.scope.getBinding(r.node.name),s=i===void 0?null:Zi(i.path);if(s===null)throw r.buildCodeFrameError(`memo-dom: cannot resolve effect callback '${r.node.name}' \u2014 use an inline function or a local/module-level function declaration or const`);if(s.node.async||s.node.generator)throw s.buildCodeFrameError("memo-dom: effect callback must be synchronous; start async work inside it and return a synchronous teardown");if(de(s.node.body))throw s.buildCodeFrameError("memo-dom: a JSX component cannot be used as an effect callback");return{expression:j.cloneNode(r.node),path:s,importedReads:new Set}}function Ar(e,t,n,r){let o=new Set,i=new Set,s=new Map,a=new Set([...e.componentProps.get(t)?.bindings??[],...e.instanceState.get(t)??[]]),l=new Map;for(let m of e.instanceDerivations.get(t)??[])for(let C of m.bindings)l.set(C,m.sources);for(let m of e.instanceControlFlow.get(t)??[])for(let C of m.bindings)l.set(C,m.sources);for(let m of a){let C=n.scope.getBinding(m);C!==void 0&&s.set(C,{source:m,local:!0})}for(let m of l.keys()){let C=n.scope.getBinding(m);C!==void 0&&s.set(C,{source:m,local:!0})}for(let m of e.state.keys()){let C=n.scope.getBinding(m);C?.scope.path.isProgram()===!0&&s.set(C,{source:m,local:!1})}let d=m=>{let C=m.scope.getBinding(m.node.name),y=C===void 0?void 0:s.get(C);if(y===void 0)return;let v=m.parentPath;!y.local&&e.state.get(y.source)==="store"&&v?.isMemberExpression()&&v.node.object===m.node||(y.local?i.add(y.source):o.add(y.source))},u=m=>{let C=ye(m.node),y=ve(m.node);C===null||y===null||e.state.get(y)!=="store"||m.scope.getBinding(y)?.scope.path.isProgram()!==!0||o.add(C)},c=m=>{let C=m.node.callee;if(!j.isIdentifier(C)||m.scope.getBinding(C.name)?.scope.path.isProgram()!==!0||!e.helpers.has(C.name)&&!e.importedFunctions.has(C.name))return;let y=e.importedFunctions.get(C.name)??Ue(e,C.name);for(let v of y.reads)o.add(v)};r.isIdentifier()&&r.isReferencedIdentifier()&&d(r),r.isMemberExpression()&&u(r),r.isCallExpression()&&c(r),r.traverse({Function(m){m.skip()},ReferencedIdentifier(m){m.isIdentifier()&&d(m)},MemberExpression(m){u(m)},CallExpression(m){c(m)}});let g=new Set,x=new Set,E=new Set;for(let m of i)a.has(m)&&E.add(m);let f=(m,C)=>{if(C.has(m))return;let y=l.get(m);if(y===void 0){a.has(m)?g.add(m):e.state.has(m)&&o.add(m);return}C.add(m),y.some(M=>E.has(M))||x.add(m);for(let M of y)f(M,C);C.delete(m)};for(let m of i)f(m,new Set);return{moduleReads:o,localReads:g,localDerivationReads:x}}function jr(e,t){let n=new Set,r=s=>{let a=s.node.name;if(!e.state.has(a)||s.scope.getBinding(a)?.scope.path.isProgram()!==!0)return;let l=s.parentPath;e.state.get(a)==="store"&&l?.isMemberExpression()&&l.node.object===s.node||n.add(a)},o=s=>{let a=ye(s.node),l=ve(s.node);a!==null&&l!==null&&e.state.get(l)==="store"&&s.scope.getBinding(l)?.scope.path.isProgram()===!0&&n.add(a)},i=s=>{let a=s.node.callee;if(!j.isIdentifier(a)||s.scope.getBinding(a.name)?.scope.path.isProgram()!==!0||!e.helpers.has(a.name)&&!e.importedFunctions.has(a.name))return;let l=e.importedFunctions.get(a.name)??Ue(e,a.name);for(let d of l.reads)n.add(d)};return t.isIdentifier()&&t.isReferencedIdentifier()&&r(t),t.isMemberExpression()&&o(t),t.isCallExpression()&&i(t),t.traverse({Function(s){s.skip()},ReferencedIdentifier(s){s.isIdentifier()&&r(s)},MemberExpression(s){o(s)},CallExpression(s){i(s)}}),n}function Kn(e){if(!e.isExpressionStatement())return null;let t=e.get("expression");return t.isCallExpression()&&Cn(t)?t:null}function Xr(e){if(Kn(e)!==null)return!0;let t=!1;return e.traverse({Function(n){n.skip()},CallExpression(n){Cn(n)&&(t=!0,n.stop())}}),t}function Sn(e,t,n,r){let o=Kn(e);if(o!==null){r.push({callPath:o,rootStatement:t,conditions:[...n]});return}if(!e.isEmptyStatement()){if(e.isBlockStatement()){for(let i of e.get("body"))if(!i.isEmptyStatement()){if(!Xr(i))throw i.buildCodeFrameError("memo-dom: a conditional effect branch may contain only effect() calls, nested if statements, or empty statements");Sn(i,t,n,r)}return}if(e.isIfStatement()){let i=e.get("test");Sn(e.get("consequent"),t,[...n,{path:i,negated:!1}],r);let s=e.get("alternate");s.node!==null&&Sn(s,t,[...n,{path:i,negated:!0}],r);return}throw e.buildCodeFrameError("memo-dom: conditional effect() calls must be controlled by top-level if statements")}}function Tr(e){let t=[];for(let n of e){let r=Kn(n);if(r!==null){t.push({callPath:r,rootStatement:n.node,conditions:[]});continue}!n.isIfStatement()||!Xr(n)||Sn(n,n.node,[],t)}return t}function Br(e){return e.length===0?null:e.map(({path:n,negated:r})=>r?j.unaryExpression("!",j.cloneNode(n.node,!0)):j.cloneNode(n.node,!0)).reduce((n,r)=>j.logicalExpression("&&",n,r))}function Yi(e,t){let n=[],r=Tr(t.get("body"));for(let o of r){let i=Or(e,o.callPath),s=i.path===null?i.importedReads:jr(e,i.path),a=new Set;for(let d of o.conditions)for(let u of jr(e,d.path))a.add(u);let l=n.length;n.push({index:l,statement:o.rootStatement,callback:i.expression,moduleReads:s,condition:Br(o.conditions),conditionModuleReads:a,entityId:`${e.rootId}/$module-effects/${encodeURIComponent(e.moduleId)}/${l}`})}e.moduleEffects.push(...n)}function Vr(e,t){Yi(e,t);for(let[n,r]of e.compPaths){let o=[],i=new Set,s=Tr(r.get("body").get("body"));for(let l of s){let d=Or(e,l.callPath),u=d.path===null?{moduleReads:d.importedReads,localReads:new Set,localDerivationReads:new Set}:Ar(e,n,r,d.path),c=new Set,g=new Set,x=new Set;for(let E of l.conditions){let f=Ar(e,n,r,E.path);for(let m of f.moduleReads)c.add(m);for(let m of f.localReads)g.add(m);for(let m of f.localDerivationReads)x.add(m)}o.push({index:o.length,statement:l.rootStatement,callback:d.expression,...u,condition:Br(l.conditions),conditionModuleReads:c,conditionLocalReads:g,conditionLocalDerivationReads:x}),i.add(l.callPath.node)}if(r.traverse({CallExpression(l){if(!(!Cn(l)||i.has(l.node)))throw l.buildCodeFrameError("memo-dom: effect() must be a direct top-level statement in a component body")}}),o.length===0)continue;e.effects.set(n,o);let a=new Set([...e.instanceReasonIds.get(n)?.keys()??[],...e.instanceState.get(n)??[],...e.componentProps.get(n)?.bindings??[],...o.flatMap(l=>[...l.localReads]),...o.flatMap(l=>[...l.conditionLocalReads])]);a.size>0&&e.instanceReasonIds.set(n,new Map([...a].sort().map((l,d)=>[l,d])))}}function Jr(e){return e.reduce((t,n)=>j.logicalExpression("||",t,n))}function Qi(e,t,n,r){let o=e.instanceReasonIds.get(t);if(o===void 0)return null;let i=[...r].map(d=>o.get(d)).filter(d=>d!==void 0).sort((d,u)=>d-u);if(i.length===0||i.length!==r.size)return null;let s=()=>j.identifier(n),a=Jr(i.map(d=>j.binaryExpression("===",s(),j.numericLiteral(d)))),l=Jr(i.map(d=>j.callExpression(j.memberExpression(s(),j.identifier("has")),[j.numericLiteral(d)])));return j.logicalExpression("||",j.binaryExpression("===",s(),j.nullLiteral()),j.conditionalExpression(j.binaryExpression("===",j.unaryExpression("typeof",s()),j.stringLiteral("number")),a,l))}function Wr(e,t,n,r,o,i){let s=(l,d,u,c,g)=>{if(u.size===0&&c.size===0)return null;let x=j.expressionStatement(j.callExpression(Q(e,"markDirty"),[d]));if(c.size>0&&i!==void 0){let f=[],m=[];for(let y of c){let v=A(e,`eff${l.index}_${g}_${y}`).name;i.creation.push(j.variableDeclaration("let",[j.variableDeclarator(j.identifier(v),j.identifier(y))])),f.push(j.binaryExpression("!==",j.identifier(v),j.identifier(y))),m.push(j.expressionStatement(j.assignmentExpression("=",j.identifier(v),j.identifier(y))))}let C=f.length===1?f[0]:f.reduce((y,v)=>j.logicalExpression("||",y,v));x=j.ifStatement(C,j.blockStatement([...m,x]))}if(r===null)return x;let E=Qi(e,t,r,u);return E===null?x:j.ifStatement(E,x)},a=o.flatMap(l=>{let d=l.condition===null?null:s(l,xn(n,l.index),l.conditionLocalReads,l.conditionLocalDerivationReads,"condition"),u=s(l,l.condition===null?xn(n,l.index):Gi(n,l.index),l.localReads,l.localDerivationReads,"callback");return[d,u].filter(c=>c!==null)});return j.blockStatement(a)}function zr(e,t,n){return n.map(r=>j.expressionStatement(j.callExpression(Q(e,r.condition===null?"registerEffect":"registerConditionalEffect"),[xn(t,r.index),j.identifier(t),...r.condition===null?[]:[j.arrowFunctionExpression([],j.cloneNode(r.condition,!0))],j.cloneNode(r.callback,!0)])))}function $r(){return j.memberExpression(j.metaProperty(j.identifier("import"),j.identifier("meta")),j.identifier("hot"))}function Kr(e,t){if(e.moduleEffects.length===0)return;let n=new Map(t.get("body").map(o=>[o.node,o])),r=new Map;for(let o of e.moduleEffects){let i=r.get(o.statement)??[];i.push(o),r.set(o.statement,i)}for(let[o,i]of r){let s=n.get(o);if(s===void 0)continue;let a=[];for(let l of i)a.push(j.expressionStatement(j.callExpression(Q(e,l.condition===null?"registerEffect":"registerConditionalEffect"),[j.stringLiteral(l.entityId),j.nullLiteral(),...l.condition===null?[]:[j.arrowFunctionExpression([],j.cloneNode(l.condition,!0))],j.cloneNode(l.callback,!0)])),j.ifStatement($r(),j.expressionStatement(j.callExpression(j.memberExpression($r(),j.identifier("dispose")),[j.arrowFunctionExpression([],j.callExpression(Q(e,"unregisterSubtree"),[j.stringLiteral(l.entityId)]))]))));s.replaceWithMultiple(a)}}function Ur(e){e.traverse({CallExpression(t){if(Cn(t))throw t.buildCodeFrameError("memo-dom: effect() must be a direct top-level statement or be controlled by a top-level effect-only if branch in a component or module")}})}import*as Qe from"@babel/types";function Hr(e,t){return e.size===t.size&&[...e].every(n=>t.has(n))}function _r(e){let t=new Set,n=[];for(let r of e){let o=Pn(r);if(o===null)return null;for(let i of o.bindings){if(t.has(i))return null;t.add(i)}n.push(...o.expressions)}return t.size===0?null:{bindings:t,expressions:n}}function Pn(e){if(Qe.isExpressionStatement(e)&&Qe.isAssignmentExpression(e.expression,{operator:"="})&&Qe.isIdentifier(e.expression.left))return{bindings:new Set([e.expression.left.name]),expressions:[e.expression.right]};if(Qe.isBlockStatement(e))return _r(e.body);if(Qe.isIfStatement(e)){let t=e.alternate;if(t==null)return null;let n=Pn(e.consequent),r=Pn(t);return n===null||r===null||!Hr(n.bindings,r.bindings)?null:{bindings:n.bindings,expressions:[e.test,...n.expressions,...r.expressions]}}return null}function es(e){if(!e.cases.some(o=>o.test==null))return null;let t=null,n=!1,r=[e.discriminant];for(let o of e.cases){o.test!=null&&r.push(o.test);let i=[...o.consequent];if(i.length===0){n=!0;continue}if(i.at(-1)&&Qe.isBreakStatement(i.at(-1))&&i.pop(),i.some(a=>Qe.isBreakStatement(a)))return null;let s=_r(i);if(s===null)return null;if(n=!1,t===null)t=s.bindings;else if(!Hr(t,s.bindings))return null;r.push(...s.expressions)}return t===null||n?null:{bindings:t,expressions:r}}function ts(e,t){return e.node===t||e.findParent(n=>n.node===t)!==null}function ns(e,t){let n=e;for(;n?.parentPath!==t;)n=n?.parentPath??null;return n}function qr(e,t,n){let r=t.get("body"),o=new Map(r.map((i,s)=>[i.node,s]));for(let i of r){if(!i.isIfStatement()&&!i.isSwitchStatement())continue;let s=i.node,a=i.isIfStatement()?Pn(s):es(s);if(a===null)continue;let l=!0,d=[];for(let E of a.bindings){let f=t.scope.getBinding(E),m=f?.path,C=m?.parentPath,y=m===void 0?null:ns(m,t);if(f===void 0||!m?.isVariableDeclarator()||!C?.isVariableDeclaration()||C.node.kind!=="let"&&C.node.kind!=="var"||y===null||(o.get(y.node)??Number.MAX_SAFE_INTEGER)>=(o.get(s)??-1)){l=!1;break}d.push(...f.constantViolations.filter(v=>!ts(v,s)))}if(!l)continue;let u=new Set,c=null;for(let E of a.expressions){let f=n(e,E);for(let m of f.reads)u.add(m);f.impure&&c===null&&(c=f.reason??"cannot be analyzed")}if(u.size===0)continue;if(c!==null)throw i.buildCodeFrameError(`memo-dom: module control-flow derivation ${c}`);for(let E of a.bindings)if(u.has(E))throw i.buildCodeFrameError(`memo-dom: module control-flow derivation '${E}' reads its own previous value`);if(d.length>0)throw d[0].buildCodeFrameError(`memo-dom: cannot assign module control-flow computed '${[...a.bindings].sort().join(", ")}' outside its derivation`);let g=e.moduleControlFlow.length,x=[...a.bindings].sort();for(let E of x)bt(e,E,"computed");e.moduleControlFlow.push({statement:s,bindings:x,sources:[...u].sort(),entityId:`${e.rootId}/$computed/${encodeURIComponent(e.moduleId)}#$flow${g}`})}}import*as ue from"@babel/types";function Un(e,t){let n=new Set,r=!1,o,i=new Set,s=l=>{r||(r=!0,o=l)},a=l=>{ue.isIdentifier(l)?i.add(l.name):Le(l,d=>{ue.isIdentifier(d)&&i.add(d.name)})};return Le(t,(l,d)=>{if(ue.isFunction(l)){if(!(d!==null&&(ue.isCallExpression(d)||ue.isNewExpression(d))))return!1;for(let c of l.params)ue.isLVal(c)&&a(c);return}if(ue.isVariableDeclarator(l)&&ue.isLVal(l.id)){a(l.id);return}if(ue.isAssignmentExpression(l)){let u=ue.isIdentifier(l.left)?l.left.name:ue.isMemberExpression(l.left)?ve(l.left):null;(u===null||!i.has(u))&&s("contains an assignment \u2014 writes belong in handlers, not derivations");return}if(ue.isUpdateExpression(l)){let u=l.argument,c=ue.isIdentifier(u)?u.name:ue.isMemberExpression(u)?ve(u):null;(c===null||!i.has(c))&&s("contains an update (++/--) \u2014 writes belong in handlers, not derivations");return}if(ue.isAwaitExpression(l)||ue.isYieldExpression(l)){s("uses await/yield \u2014 derivations must be synchronous");return}if(ue.isCallExpression(l)){let u=l.callee;if(ue.isIdentifier(u)&&(e.helpers.has(u.name)||e.importedFunctions.has(u.name))){let c=e.importedFunctions.get(u.name)??Ue(e,u.name);for(let g of c.reads)n.add(g);if(c.writes.size>0){for(let g of c.writes)n.add(g);s(`calls helper '${u.name}' which writes state \u2014 writes belong in handlers`)}else c.unbounded&&e.helpers.has(u.name)&&s(`calls recursive helper '${u.name}' which cannot be analyzed`)}return}if(ue.isIdentifier(l)){!i.has(l.name)&&e.state.has(l.name)&&n.add(l.name);return}if(ue.isMemberExpression(l)&&!l.computed){let u=ye(l);if(u!==null&&u.includes(".")){let c=u.split(".")[0];!i.has(c)&&e.state.get(c)==="store"&&n.add(u)}}}),{reads:n,impure:r,reason:o}}function Gr(e,t){for(let n of t.node.body){let r=ue.isExportNamedDeclaration(n)?n.declaration:n;if(!(!ue.isVariableDeclaration(r)||r.kind!=="const"))for(let o of r.declarations){if(!ue.isIdentifier(o.id)||o.init==null)continue;let i=o.id.name;if(e.state.get(i)==="let"||e.state.get(i)==="computed"||ue.isFunction(o.init)||ue.isJSX(o.init))continue;let s=Un(e,o.init);if(s.impure){if(s.reads.size>0)throw new Error(`memo-dom: const '${i}' is a state derivation but ${s.reason??"cannot be analyzed"}. Fix the derivation, or make it a 'let' you update in handlers.`);continue}s.reads.size!==0&&(bt(e,i,"computed"),e.computeds.set(i,{reads:s.reads}))}}}import*as je from"@babel/types";function Zr(e){for(let[t,n]of e.compPaths){let r=new Set;for(let o of n.node.body.body)if(je.isVariableDeclaration(o)&&!(o.kind!=="let"&&o.kind!=="var"&&o.kind!=="const"))for(let i of o.declarations)je.isIdentifier(i.id)&&(o.kind==="let"||o.kind==="var"||kt(i.init)||Nt(i.init))&&r.add(i.id.name);r.size>0&&e.instanceState.set(t,r)}}function Yr(e){for(let[t,n]of e.compPaths){let r=new Map;for(let c of e.componentProps.get(t)?.bindings??[]){let g=n.scope.getBinding(c);g&&r.set(g,c)}for(let c of e.instanceState.get(t)??[]){let g=n.scope.getBinding(c);g&&r.set(g,c)}for(let c of e.state.keys()){let g=n.scope.getBinding(c);g?.scope.path.isProgram()&&r.set(g,c)}let o=[],i=new Set,s=new Map,a=n.get("body").get("body");for(let c of a)if(c.isVariableDeclaration({kind:"const"}))for(let g of c.get("declarations")){let x=g.node;if(!je.isIdentifier(x.id)&&!je.isObjectPattern(x.id)&&!je.isArrayPattern(x.id)||x.init==null||je.isFunction(x.init)||je.isIdentifier(x.id)&&e.instanceState.get(t)?.has(x.id.name)===!0&&(kt(x.init)||Nt(x.init)))continue;let E=g.get("init");if(!E.isExpression())continue;let f=new Set,m=null,C=(I,H)=>{let O=H.scope.getBinding(I);return O!==void 0&&r.has(O)},y=I=>{if(!je.isIdentifier(I.node))return;let H=I.scope.getBinding(I.node.name),O=H===void 0?void 0:r.get(H);O!==void 0&&f.add(O)},v=I=>je.isIdentifier(I)?I.name:je.isMemberExpression(I)?ve(I):null;if(E.isReferencedIdentifier()&&y(E),E.isAssignmentExpression()){let I=v(E.node.left);I!==null&&C(I,E)&&(m="contains an assignment to reactive state")}else if(E.isUpdateExpression()){let I=v(E.node.argument);I!==null&&C(I,E)&&(m="contains an update (++/--) to reactive state")}else E.isAwaitExpression()?m="uses await; per-instance derivations must be synchronous":E.isYieldExpression()&&(m="uses yield; per-instance derivations must be synchronous");if(E.traverse({Function(I){I.skip()},ReferencedIdentifier(I){y(I)},AssignmentExpression(I){let H=v(I.node.left);H!==null&&C(H,I)&&(m="contains an assignment to reactive state")},UpdateExpression(I){let H=v(I.node.argument);H!==null&&C(H,I)&&(m="contains an update (++/--) to reactive state")},AwaitExpression(){m="uses await; per-instance derivations must be synchronous"},YieldExpression(){m="uses yield; per-instance derivations must be synchronous"}}),f.size===0)continue;if(E.traverse({ReferencedIdentifier(I){y(I)},AssignmentExpression(I){let H=v(I.node.left);H!==null&&C(H,I)&&(m="contains an assignment to reactive state")},UpdateExpression(I){let H=v(I.node.argument);H!==null&&C(H,I)&&(m="contains an update (++/--) to reactive state")}}),m!==null){let I=Ht(x.id);throw g.buildCodeFrameError(`memo-dom: local const '${I.join(", ")||"<pattern>"}' is a per-instance derivation but ${m}`)}let M=Ht(x.id),R=new Set;for(let I of f){let H=s.get(I);if(H===void 0)R.add(I);else for(let O of H)R.add(O)}o.push({declaration:c.node,target:je.cloneNode(x.id),source:je.cloneNode(x.init),bindings:M,sources:[...R].sort()});for(let I of M){i.add(I),s.set(I,new Set(R));let H=n.scope.getBinding(I);H&&r.set(H,I),e.instanceState.get(t)?.delete(I)}}if(o.length===0)continue;e.instanceDerivations.set(t,o),e.instanceDerivedBindings.set(t,i);let l=new Set([...e.instanceState.get(t)??[],...e.componentProps.get(t)?.bindings??[]]);if(![...l].some(c=>o.some(g=>!g.sources.includes(c))))continue;let u=new Set([...l,...o.flatMap(c=>c.sources)]);e.instanceReasonIds.set(t,new Map([...u].sort().map((c,g)=>[c,g]))),e.selectiveDerivationComponents.add(t)}}import*as pe from"@babel/types";function Zt(e){let t=!0;return pe.traverseFast(e,n=>{if(pe.isAssignmentExpression(n)||pe.isUpdateExpression(n)||pe.isAwaitExpression(n)||pe.isYieldExpression(n)||pe.isNewExpression(n)||pe.isTaggedTemplateExpression(n)||pe.isFunction(n)){t=!1;return}if(pe.isCallExpression(n)||pe.isOptionalCallExpression(n)){let r=n.callee;t=t&&pe.isMemberExpression(r)&&!r.computed&&pe.isIdentifier(r.object,{name:"Math"})&&pe.isIdentifier(r.property)}}),t}function rs(e){return!pe.isExpressionStatement(e)||!pe.isAssignmentExpression(e.expression,{operator:"="})||!pe.isIdentifier(e.expression.left)||!Zt(e.expression.right)?null:e.expression.left.name}function Qr(e,t){return e.size===t.size&&[...e].every(n=>t.has(n))}function Gt(e){if(pe.isExpressionStatement(e)){let t=rs(e);return t===null?null:{bindings:new Set([t]),partial:new Set}}if(pe.isBlockStatement(e)){let t=new Set,n=new Set;for(let r of e.body){let o=Gt(r);if(o===null)return null;for(let i of o.bindings){if(t.has(i))return null;t.add(i)}for(let i of o.partial)n.add(i)}return t.size===0?null:{bindings:t,partial:n}}if(pe.isIfStatement(e)){if(!Zt(e.test))return null;let t=Gt(e.consequent);if(t===null)return null;if(e.alternate==null)return{bindings:t.bindings,partial:new Set([...t.bindings,...t.partial])};let n=Gt(e.alternate);return n===null||!Qr(t.bindings,n.bindings)?null:{bindings:t.bindings,partial:new Set([...t.partial,...n.partial])}}return null}function os(e){if(!Zt(e.discriminant))return null;let t=null;for(let n of e.cases){if(n.test!=null&&!Zt(n.test))return null;let r=[...n.consequent];if(r.at(-1)&&pe.isBreakStatement(r.at(-1))&&r.pop(),r.some(i=>pe.isBreakStatement(i)))return null;let o=Gt(pe.blockStatement(r));if(o===null)return null;if(t===null)t=o;else{if(!Qr(t.bindings,o.bindings))return null;for(let i of o.partial)t.partial.add(i)}}if(t!==null&&!e.cases.some(n=>n.test===null))for(let n of t.bindings)t.partial.add(n);return t}function is(e,t){return e.node===t||e.findParent(n=>n.node===t)!==null}function eo(e){for(let[t,n]of e.compPaths){let r=new Map;for(let s of e.componentProps.get(t)?.bindings??[]){let a=n.scope.getBinding(s);a&&r.set(a,s)}for(let s of e.instanceState.get(t)??[]){let a=n.scope.getBinding(s);a&&r.set(a,s)}for(let s of e.instanceDerivedBindings.get(t)??[]){let a=n.scope.getBinding(s);a&&r.set(a,s)}for(let s of e.state.keys()){let a=n.scope.getBinding(s);a?.scope.path.isProgram()&&r.set(a,s)}let o=[],i=e.instanceDerivedBindings.get(t)??new Set;for(let s of n.get("body").get("body")){if(!s.isIfStatement()&&!s.isSwitchStatement())continue;let a=s,l=a.isIfStatement()?Gt(a.node):os(a.node);if(l===null)continue;let d=!0,u=[],c=[];for(let f of l.bindings){let m=n.scope.getBinding(f),C=m?.path,y=C?.parentPath;if(m===void 0||!C?.isVariableDeclarator()||!y?.isVariableDeclaration()||y.node.kind!=="let"&&y.node.kind!=="var"||m.constantViolations.some(v=>!is(v,a.node))){d=!1;break}if(l.partial.has(f)){let v=C.get("init");if(!v.isExpression()||!Zt(v.node)){d=!1;break}u.push({binding:f,source:v.node}),c.push(v)}}if(!d)continue;let g=new Set,x=f=>{let m=f.scope.getBinding(f.node.name),C=m===void 0?void 0:r.get(m);C!==void 0&&g.add(C)},E={Function(f){f.skip()},ReferencedIdentifier(f){f.isIdentifier()&&x(f)}};a.traverse(E);for(let f of c)f.isReferencedIdentifier()&&x(f),f.traverse(E);if(g.size!==0){for(let f of l.bindings)if(g.has(f))throw a.buildCodeFrameError(`memo-dom: reactive control-flow derivation '${f}' reads its own previous value`);o.push({statement:a.node,bindings:[...l.bindings].sort(),resets:u,sources:[...g].sort()});for(let f of l.bindings){i.add(f);let m=n.scope.getBinding(f);m&&r.set(m,f),e.instanceState.get(t)?.delete(f)}}}o.length>0&&(e.instanceControlFlow.set(t,o),e.instanceDerivedBindings.set(t,i))}}function to(e){for(let[t]of e.compPaths){let n=e.instanceDerivations.get(t)??[],r=e.instanceControlFlow.get(t)??[];if(n.length===0&&r.length===0)continue;let o=new Map;for(let u of n)for(let c of u.bindings)o.set(c,new Set(u.sources));for(let u of r)for(let c of u.bindings)o.set(c,new Set(u.sources));let i=(u,c=new Set)=>{let g=o.get(u);if(g===void 0)return new Set([u]);if(c.has(u))return new Set([u]);let x=new Set(c).add(u),E=new Set;for(let f of g)for(let m of i(f,x))E.add(m);return E};for(let u of n)u.sources=[...new Set(u.sources.flatMap(c=>[...i(c)]))].sort();for(let u of r)u.sources=[...new Set(u.sources.flatMap(c=>[...i(c)]))].sort();let s=new Set([...e.instanceState.get(t)??[],...e.componentProps.get(t)?.bindings??[]]),a=[...n,...r],l=[...s].some(u=>a.some(c=>!c.sources.includes(u)));if(e.selectiveDerivationComponents.delete(t),e.instanceReasonIds.delete(t),!l)continue;let d=new Set([...s,...a.flatMap(u=>u.sources)]);e.instanceReasonIds.set(t,new Map([...d].sort().map((u,c)=>[u,c]))),e.selectiveDerivationComponents.add(t)}}import*as Yt from"@babel/types";function ss(e){let t=e.indexOf("[");return t<0?e:e.slice(0,t)}function St(e,t){let n=new Set;for(let r of t){let o=r.split("/"),i=[[]];for(let s=0;s<o.length;s++){let a=o[s],l=i.map(d=>[...d,a]);if(s<o.length-1&&e.renderSlotOwners.has(ss(a)))for(let d of i)l.push([...d,a,"$slot[*]"]);i=l}for(let s of i)n.add(s.join("/"))}return[...n]}function et(e,t,n=new Set){let r=e.linkedComponentPaths.get(t);if(r!==void 0)return[...r];if(n.has(t))throw e.compPaths.get(t).buildCodeFrameError(`memo-dom: recursive component '${t}' \u2014 components cannot render themselves (L1)`);let o=e.listedSites.get(t);if(o!==void 0&&o.length>0){n.add(t);let d=o.flatMap(u=>et(e,u.owner,n).map(c=>`${c}/${u.suffix}/Row[*]`));return n.delete(t),[...new Set(d)]}let i=e.comps.get(t),s=e.conditionalComponentSites.get(t)??[],a=e.rowComponentSites.get(t)??[];if(i.parents.size===0&&s.length===0&&a.length===0)return[e.rootId];n.add(t);let l=[];for(let d of s)for(let u of et(e,d.owner,n))l.push(`${u}/${d.suffix}`);for(let d of a)for(let u of et(e,d.owner,n))l.push(`${u}/${d.suffix}`);for(let d of i.parents){let u=e.childRefCounts.get(d)?.get(t)??1;for(let c of et(e,d,n))u>1?l.push(`${c}/${t}`,`${c}/${t}[*]`):l.push(`${c}/${t}`)}return n.delete(t),l}function Hn(e,t){let n=e.linkedComponentPaths.get(t);if(n!==void 0)return St(e,n.flatMap(i=>[i,`${i}/*`]));let r=e.listedSites.get(t),o=[];if(r&&r.length>0){if($t(e,t)){for(let i of r){let s=i.suffix.lastIndexOf("/"),a=s<0?"":`/${i.suffix.slice(0,s)}`;for(let l of et(e,i.owner))o.push(`${l}${a}`,`${l}${a}/*`)}return St(e,o)}for(let i of r)for(let s of et(e,i.owner))o.push(`${s}/${i.suffix}/Row[*]`,`${s}/${i.suffix}/Row[*]/*`);return St(e,o)}for(let i of et(e,t))o.push(i,`${i}/*`);return St(e,o)}function $t(e,t){let n=e.importedComponents.get(t);if(n!==void 0)return n.listLightweight;let r=e.lightweightCache.get(t);if(r!==void 0)return r;let o=!1,i=e.listedSites.get(t),s=e.linkedComponentRows.get(t);return(i!==void 0&&i.length>0||s!==void 0&&s.length>0)&&e.comps.get(t).parents.size===0&&wn(e,t)&&(o=!0),e.lightweightCache.set(t,o),o}function wn(e,t){if((e.instanceState.get(t)?.size??0)>0)return!1;let n=!0;return e.compPaths.get(t).traverse({JSXElement(o){let i=o.node.openingElement.name;Yt.isJSXIdentifier(i)&&/^[A-Z]/.test(i.name)&&(n=!1)},CallExpression(o){(Yt.isIdentifier(o.node.callee,{name:"cleanup"})&&o.scope.getBinding("cleanup")===void 0||Yt.isIdentifier(o.node.callee,{name:"effect"})&&o.scope.getBinding("effect")===void 0)&&(n=!1),Ve(o.node)&&Ae(o)&&(n=!1)},ConditionalExpression(o){Ae(o)&&(n=!1)},LogicalExpression(o){Ae(o)&&(n=!1)}}),n}import*as K from"@babel/types";function no(e,t){let n=e.findParent(r=>r.isFunctionDeclaration()||r.isFunctionExpression()||r.isArrowFunctionExpression());return n===t?!0:n?.findParent(r=>r===t)!==null}function _n(e,t){let n=e;for(;n!==null;){let r=n.parentPath;if(r===null||r.isJSXAttribute()||r.isJSXSpreadAttribute())return!1;if(r.isJSXExpressionContainer()){if(r.parentPath?.isJSXAttribute()===!0){let o=r.parentPath.node,i=r.parentPath.parentPath;if(!i?.isJSXOpeningElement())return!1;let s=i.node.name;if(!K.isJSXIdentifier(s)||!/^[A-Z]/.test(s.name))return!1;let a=K.isJSXIdentifier(o.name)?o.name.name:o.name.name.name;return t.componentProps.get(s.name)?.renderProps.includes(a)===!0}return r.parentPath?.isJSXElement()===!0||r.parentPath?.isJSXFragment()===!0}if(r.isReturnStatement()&&r.node.argument===n.node||r.isArrowFunctionExpression()&&r.node.body===n.node||r.isVariableDeclarator()&&r.node.init===n.node)return!0;n=r}return!1}function as(e,t){if(K.isArrayExpression(e))return e;if(!K.isIdentifier(e))return null;let n=t.scope.getBinding(e.name);return n?.path.isVariableDeclarator()&&K.isArrayExpression(n.path.node.init)?n.path.node.init:null}function qn(e,t,n=new Set){if(n.has(e))throw t.buildCodeFrameError("memo-dom: cyclic JSX array spread");n.add(e);let r=[];try{for(let o of e.elements)if(!(o==null||K.isNullLiteral(o)||K.isBooleanLiteral(o))){if(K.isSpreadElement(o)){if(!K.isExpression(o.argument))throw t.buildCodeFrameError("memo-dom: JSX array spreads must resolve to a static JSX array");let i=as(o.argument,t);if(i===null)throw t.buildCodeFrameError("memo-dom: JSX array spreads must resolve to a static JSX array");r.push(...qn(i,t,n));continue}if(K.isArrayExpression(o)){r.push(...qn(o,t,n));continue}if(K.isJSXElement(o)||K.isJSXFragment(o)){r.push(K.cloneNode(o,!0));continue}if(!K.isExpression(o))throw t.buildCodeFrameError("memo-dom: JSX arrays require renderable expression entries");r.push(K.jsxExpressionContainer(K.cloneNode(o,!0)))}}finally{n.delete(e)}return r}function ro(e,t){return K.jsxFragment(K.jsxOpeningFragment(),K.jsxClosingFragment(),qn(e,t))}function ls(e,t){return K.isArrayExpression(e)?e.elements.map((n,r)=>{if(n==null||K.isSpreadElement(n))throw t.buildCodeFrameError("memo-dom: JSX arrays cannot contain holes or spread elements");return{key:K.numericLiteral(r),value:n}}):e.properties.map(n=>{if(!K.isObjectProperty(n)||n.computed||!K.isExpression(n.value))throw t.buildCodeFrameError("memo-dom: JSX objects require static data properties without spreads");let r=K.isIdentifier(n.key)?K.stringLiteral(n.key.name):K.isStringLiteral(n.key)||K.isNumericLiteral(n.key)?K.cloneNode(n.key):null;if(r===null)throw t.buildCodeFrameError("memo-dom: JSX objects require identifier, string, or numeric keys");return{key:r,value:n.value}})}function ds(e,t){let n=e.node,r=null;if(!n.computed&&K.isIdentifier(n.property)?r=n.property.name:n.computed&&(K.isStringLiteral(n.property)||K.isNumericLiteral(n.property))&&(r=n.property.value),r!==null){let i=t.find(s=>(K.isStringLiteral(s.key)||K.isNumericLiteral(s.key))&&s.key.value===r);if(i===void 0)throw e.buildCodeFrameError(`memo-dom: JSX collection has no entry for '${r}'`);return K.cloneNode(i.value,!0)}if(!n.computed||!K.isExpression(n.property))throw e.buildCodeFrameError("memo-dom: JSX collection selection requires a static or expression key");let o=K.nullLiteral();for(let i=t.length-1;i>=0;i--){let s=t[i];o=K.conditionalExpression(K.binaryExpression("===",K.cloneNode(n.property,!0),K.cloneNode(s.key,!0)),K.cloneNode(s.value,!0),o)}return o}function oo(e){for(let[,t]of e.compPaths){let n=!1;t.traverse({JSXExpressionContainer(o){if(!o.parentPath?.isJSXElement()&&!o.parentPath?.isJSXFragment())return;let i=o.get("expression");Array.isArray(i)||!i.isArrayExpression()||!de(i.node)||(o.replaceWith(ro(i.node,i)),n=!0)}});let r=!0;for(;r;){r=!1,t.scope.crawl();let o=t.get("body").get("body");for(let i of o)if(i.isVariableDeclaration({kind:"const"})){for(let s of i.get("declarations")){let a=s.node,l=a.init;if(!K.isIdentifier(a.id)||l==null||!de(l))continue;let d=s.scope.getBinding(a.id.name);if(d?.path!==s)continue;let u=[...d.referencePaths];if(K.isObjectExpression(l)||K.isArrayExpression(l))for(let c of u){if(!c.isIdentifier()||!no(c,t))throw c.buildCodeFrameError(`memo-dom: JSX collection '${a.id.name}' is used outside its component`);if(c.parentPath?.isMemberExpression()&&c.parentPath.node.object===c.node){let g=c.parentPath;if(!_n(g,e))throw g.buildCodeFrameError(`memo-dom: JSX collection '${a.id.name}' is used outside a render position`);g.replaceWith(ds(g,ls(l,s)));continue}if(K.isArrayExpression(l)&&c.parentPath?.isSpreadElement()&&c.parentPath.parentPath?.isArrayExpression()){c.replaceWith(K.cloneNode(l,!0));continue}if(K.isArrayExpression(l)&&_n(c,e)){c.replaceWith(ro(l,c));continue}throw c.buildCodeFrameError(K.isArrayExpression(l)?`memo-dom: JSX collection '${a.id.name}' must be rendered directly or selected with a direct index access`:`memo-dom: JSX collection '${a.id.name}' is used outside a render position`)}else for(let c of u)if(!(!c.isIdentifier()||!no(c,t))){if(!_n(c,e))throw c.buildCodeFrameError(`memo-dom: JSX value '${a.id.name}' is used outside a render position`);c.replaceWith(K.cloneNode(l,!0))}i.node.declarations.length===1?i.remove():s.remove(),n=!0,r=!0;break}if(r)break}}n&&(t.traverse({JSXExpressionContainer(o){let i=o.node.expression;(o.parentPath?.isJSXElement()===!0||o.parentPath?.isJSXFragment()===!0)&&(K.isJSXElement(i)||K.isJSXFragment(i))&&o.replaceWith(i)}}),t.scope.crawl())}}import*as F from"@babel/types";function Gn(e){return F.isReturnStatement(e)&&F.isExpression(e.argument)?e.argument:F.isBlockStatement(e)&&e.body.length===1?Gn(e.body[0]):null}function Ot(e){let t=Gn(e);if(t!==null)return t;if(F.isIfStatement(e)&&e.alternate!=null){let n=Ot(e.consequent),r=Ot(e.alternate);return n===null||r===null?null:F.conditionalExpression(F.cloneNode(e.test,!0),F.cloneNode(n,!0),F.cloneNode(r,!0))}if(F.isSwitchStatement(e)){let n=e.cases.find(o=>o.test==null);if(n===void 0||n.consequent.length!==1)return null;let r=Ot(n.consequent[0]);if(r===null)return null;for(let o=e.cases.length-1;o>=0;o--){let i=e.cases[o];if(i.test==null)continue;if(i.consequent.length!==1)return null;let s=Ot(i.consequent[0]);if(s===null)return null;r=F.conditionalExpression(F.binaryExpression("===",F.cloneNode(e.discriminant,!0),F.cloneNode(i.test,!0)),F.cloneNode(s,!0),r)}return r}return null}function cs(e,t){if(F.isExpression(e.body))return{expression:F.cloneNode(e.body,!0),locals:new Map};let n=new Map,r=[];for(let s of e.body.body){if(F.isVariableDeclaration(s,{kind:"const"})){for(let a of s.declarations)(!F.isIdentifier(a.id)||a.init==null||!F.isExpression(a.init))&&t("memo-dom: JSX render functions require identifier const declarations with expression initializers"),n.set(a.id.name,F.cloneNode(a.init,!0));continue}F.isTypeScript(s)||F.isEmptyStatement(s)||r.push(s)}if(r.length===1){let s=Ot(r[0]);if(s!==null)return{expression:s,locals:n}}let o=r.at(-1),i=o===void 0?null:Gn(o);if(i!==null){let s=F.cloneNode(i,!0);for(let a=r.length-2;a>=0;a--){let l=r[a];if(F.isIfStatement(l)&&l.alternate==null){let d=Ot(l.consequent);if(d!==null){s=F.conditionalExpression(F.cloneNode(l.test,!0),F.cloneNode(d,!0),s);continue}}t("memo-dom: JSX render functions support pure const setup, JSX return expressions, tail early-return if statements, exhaustive return if/else, or exhaustive return switch statements")}return{expression:s,locals:n}}return t("memo-dom: JSX render function does not have supported exhaustive return control flow")}function us(e,t){return(F.isMemberExpression(e)||F.isOptionalMemberExpression(e))&&t==="property"&&!e.computed||(F.isObjectProperty(e)||F.isObjectMethod(e)||F.isClassMethod(e))&&t==="key"&&!e.computed||F.isVariableDeclarator(e)&&t==="id"||(F.isFunction(e)||F.isCatchClause(e))&&(t==="params"||t==="param"||t==="id")||F.isLabeledStatement(e)&&t==="label"}function io(e,t,n=new Set){let r=F.cloneNode(e,!0),o=(i,s,a,l)=>{if(F.isIdentifier(i)&&!l.has(i.name)&&t.has(i.name)&&(s===null||!us(s,a)))return F.cloneNode(t.get(i.name),!0);let d=l;if(F.isFunction(i)&&i!==r){let u=i.params.flatMap(c=>Object.keys(F.getBindingIdentifiers(c)));d=new Set([...l,...u])}for(let u of F.VISITOR_KEYS[i.type]??[]){let c=i[u];Array.isArray(c)?i[u]=c.map(g=>g!=null&&typeof g=="object"&&"type"in g?o(g,i,u,d):g):c!=null&&typeof c=="object"&&"type"in c&&(i[u]=o(c,i,u,d))}return F.isObjectProperty(i)&&i.shorthand&&!F.isIdentifier(i.value,{name:F.isIdentifier(i.key)?i.key.name:""})&&(i.shorthand=!1),i};return o(r,null,"",n)}function ps(e,t){let n=a=>{throw t.buildCodeFrameError(a)},r=e.node;(r.async||r.generator)&&n("memo-dom: JSX render functions must be synchronous"),t.node.arguments.some(a=>F.isSpreadElement(a))&&n("memo-dom: JSX render function calls do not support spread arguments"),t.node.arguments.length>r.params.length&&n("memo-dom: JSX render function received more arguments than parameters");let o=new Map;for(let a=0;a<r.params.length;a++){let l=r.params[a],d=t.node.arguments[a],u=d!==void 0&&F.isExpression(d)?d:F.identifier("undefined");if(F.isIdentifier(l)){o.set(l.name,F.cloneNode(u,!0));continue}if(F.isAssignmentPattern(l)&&F.isIdentifier(l.left)){o.set(l.left.name,F.conditionalExpression(F.binaryExpression("===",F.cloneNode(u,!0),F.identifier("undefined")),F.cloneNode(l.right,!0),F.cloneNode(u,!0)));continue}n("memo-dom: JSX render functions currently require identifier parameters with optional defaults")}let i=cs(r,n);for(let[a,l]of i.locals)o.set(a,io(l,o));let s=io(i.expression,o);return de(s)||n("memo-dom: JSX render function expansion did not produce JSX"),s}function fs(e,t){let n=t.get("callee");return Array.isArray(n)||!n.isIdentifier()?null:so(e,n)}function so(e,t){let n=t.node.name,r=e.jsxHelpers.get(n);if(r!==void 0)return{node:r.node,bindingPath:r};let o=t.scope.getBinding(n);if(o?.path.isFunctionDeclaration()&&de(o.path.node))return{node:o.path.node,bindingPath:o.path};if(o?.path.isVariableDeclarator()){let i=o.path.node.init;if((F.isFunctionExpression(i)||F.isArrowFunctionExpression(i))&&de(i.body))return{node:i,bindingPath:o.path}}return null}function ao(e){return F.isMemberExpression(e.callee)&&!e.callee.computed&&F.isIdentifier(e.callee.property,{name:"map"})}function ms(e){let t=e.parentPath;return t?.isCallExpression()===!0&&(t.node.callee===e.node||ao(t.node)&&t.node.arguments[0]===e.node)}function gs(e,t){let n=e.node;if(n.async||n.generator)throw t.buildCodeFrameError("memo-dom: JSX render callbacks must be synchronous");return F.arrowFunctionExpression(n.params.map(r=>F.cloneNode(r,!0)),F.cloneNode(n.body,!0))}function vn(e){if(!e.removed){if(e.isFunctionDeclaration()){e.parentPath?.isExportNamedDeclaration()?e.parentPath.remove():e.remove();return}if(e.isVariableDeclarator()){let t=e.parentPath;if(!t?.isVariableDeclaration())return;t.node.declarations.length===1?t.parentPath?.isExportNamedDeclaration()?t.parentPath.remove():t.remove():e.remove();return}if(e.isArrowFunctionExpression()||e.isFunctionExpression()){let t=e.parentPath;t?.isVariableDeclarator()&&vn(t)}}}function bs(e,t){let n=t.findParent(r=>r.isProgram());if(n===null||!n.isProgram()){vn(t);return}for(let r of n.get("body")){let o=r.isExportNamedDeclaration()?r.get("declaration"):r;if(Array.isArray(o)||o==null)continue;if(o.isFunctionDeclaration()&&o.node.id?.name===e){r.remove();return}if(!o.isVariableDeclaration())continue;let i=o.get("declarations"),s=i.find(a=>a.isVariableDeclarator()&&F.isIdentifier(a.node.id,{name:e}));if(s!==void 0){i.length===1?r.remove():s.remove();return}}vn(t)}function hs(e,t){let n=e.parentPath,r=n?.parentPath;if((F.isJSXElement(t)||F.isJSXFragment(t))&&n?.isJSXExpressionContainer()&&(r?.isJSXElement()||r?.isJSXFragment())&&r.node.children.includes(n.node)){n.replaceWith(t);return}e.replaceWith(t)}function lo(e){let t=new Set;for(let[n,r]of e.jsxHelpers)if((r.scope.parent?.getBinding(n)??r.parentPath?.scope.getBinding(n))?.referencePaths.some(i=>i.isIdentifier()&&!ms(i)))throw r.buildCodeFrameError("memo-dom: JSX render functions may only be called in local render composition or passed directly to collection map()");for(let[,n]of e.compPaths){n.scope.crawl(),n.traverse({CallExpression(o){if(!ao(o.node)||o.node.arguments.length!==1)return;let i=o.get("arguments")[0];if(i===void 0||Array.isArray(i)||!i.isIdentifier())return;let s=so(e,i);s!==null&&(i.replaceWith(gs(s,i)),t.add(s.bindingPath))}});let r=!0;for(;r;){r=!1,n.scope.crawl();let o=[];n.traverse({CallExpression(i){o.push(i)}});for(let i of o.reverse()){if(i.removed)continue;let s=fs(e,i);s!==null&&(hs(i,ps(s,i)),t.add(s.bindingPath),r=!0)}}}for(let[n,r]of e.jsxHelpers)bs(n,r);for(let n of t)vn(n)}import*as He from"@babel/types";function Es(e){let t=It(e);return He.isIdentifier(t)||He.isMemberExpression(t)||fn(t)}function ys(e,t){let n=e,r=t.get("body");for(;n!==null&&n.parentPath!==r;)n=n.parentPath;return n?.isStatement()===!0?n:null}function Ss(e,t){return e.findParent(n=>n.isFunctionDeclaration()||n.isFunctionExpression()||n.isArrowFunctionExpression())===t}function co(e){for(let[,t]of e.compPaths){let n=[];if(t.traverse({CallExpression(s){if(Ve(s.node)===null||!He.isMemberExpression(s.node.callee)||!He.isExpression(s.node.callee.object)||Es(s.node.callee.object)||!Ss(s,t))return;let a=ys(s,t);a!==null&&n.push({path:s,source:He.cloneNode(s.node.callee.object,!0),statement:a})}}),n.length===0)continue;let r=t.get("body").get("body"),o=new Map(r.map((s,a)=>[s.node,a]));n.sort((s,a)=>(o.get(s.statement.node)??0)-(o.get(a.statement.node)??0));let i=[];for(let s of n){let a=A(e,"listView");i.push(He.variableDeclarator(He.cloneNode(a),s.source));let l=s.path.get("callee");if(Array.isArray(l)||!l.isMemberExpression())continue;let d=l.get("object");Array.isArray(d)||d.replaceWith(He.cloneNode(a))}n[0].statement.insertBefore(He.variableDeclaration("const",i)),t.scope.crawl()}}import*as We from"@babel/types";var xs=new Set(["==","==="]);function kn(e,t,n){if(n(e,t),!We.isFunction(e))for(let r of We.VISITOR_KEYS[e.type]??[]){let o=e[r];if(Array.isArray(o))for(let i of o)i&&kn(i,e,n);else o&&kn(o,e,n)}}function uo(e,t,n){if(!We.isBinaryExpression(t)||!xs.has(t.operator))return!1;let r=t.left===e?t.right:t.left;return We.isExpression(r)&&We.isNodesEquivalent(r,n)}function po(e,t){if(e.jsx===null||e.keyExpr===null||!e.sourceLocal||!We.isIdentifier(e.sourceExpr)||!t.has(e.sourceExpr.name))return[];let n=e.sourceExpr.name,r=new Set;if(kn(e.jsx,null,(i,s)=>{We.isIdentifier(i)&&t.has(i.name)&&i.name!==n&&uo(i,s,e.keyExpr)&&r.add(i.name)}),r.size===0)return[];let o=new Set;return kn(e.jsx,null,(i,s)=>{We.isIdentifier(i)&&r.has(i.name)&&We.isReferenced(i,s)&&!uo(i,s,e.keyExpr)&&o.add(i.name)}),[...r].filter(i=>!o.has(i)).sort()}import*as k from"@babel/types";function Cs(e){return{mode:e.objectProps?"object":"positional",names:[...e.props],acceptsUnknown:e.acceptsUnknownProps,bindings:[],params:[],hasWholeDefault:e.hasWholeDefault,renderProps:[...e.renderProps??[]],renderCallbacks:[...e.renderCallbacks??[]],refProps:[...e.refProps??[]]}}function Nn(e,t){if(e.linkedDynamicComponentCandidates.size===0)return;t.scope.crawl();let n=new Set(Object.keys(t.scope.bindings)),r=new Map([...e.importedComponents].map(([i,s])=>[s.key,i])),o=[];for(let[i,s]of e.linkedDynamicComponentCandidates){let a=[];for(let d of s){let u=r.get(d.key);if(u===void 0){let c=`MDDynamic_${d.imported.replace(/[^A-Za-z0-9_$]/g,"_")}`;u=c;let g=1;for(;n.has(u);)u=`${c}${g++}`;n.add(u),r.set(d.key,u);let x={type:"component",key:d.key,props:[...d.props],objectProps:d.objectProps,acceptsUnknownProps:d.acceptsUnknownProps,hasWholeDefault:d.hasWholeDefault,listLightweight:d.listLightweight,delegatedEvents:d.delegatedEvents,renderProps:[...d.renderProps??[]],renderCallbacks:[...d.renderCallbacks??[]],refProps:[...d.refProps??[]],subtreeReads:[...d.subtreeReads??[]]};e.importedComponents.set(u,x),e.componentProps.set(u,Cs(x)),o.push(k.importDeclaration(d.imported==="default"?[k.importDefaultSpecifier(k.identifier(u))]:[k.importSpecifier(k.identifier(u),k.isValidIdentifier(d.imported)?k.identifier(d.imported):k.stringLiteral(d.imported))],k.stringLiteral(d.source)))}a.push(u)}let l=[...new Set(a)];e.state.has(i)?e.stateComponentCandidates.set(i,l):e.functionComponentCandidates.set(i,l)}for(let i of o.reverse())t.unshiftContainer("body",i);t.scope.crawl()}function Zn(e){let t=e;for(;k.isTSAsExpression(t)||k.isTSTypeAssertion(t)||k.isTSNonNullExpression(t);)t=t.expression;return t}function fo(e){return k.isJSXIdentifier(e)?k.identifier(e.name):k.memberExpression(fo(e.object),k.identifier(e.property.name))}function mo(e,t){let n=ye(t);if(n===null)return null;let[r,...o]=n.split(".");if(r===void 0||o.length===0)return null;let i=e.scope.getBinding(r);if(!i?.path.isVariableDeclarator())return null;let s=i.path.node.init;if(s==null)return null;for(let a of o){if(s=Zn(s),!k.isObjectExpression(s))return null;let l=s.properties.find(d=>!k.isObjectProperty(d)||d.computed?!1:(k.isIdentifier(d.key)?d.key.name:k.isStringLiteral(d.key)?d.key.value:null)===a);if(l===void 0||!k.isObjectProperty(l)||!k.isExpression(l.value))return null;s=l.value}return s}function Ps(e,t){let n=e.scope.getBinding(t);if(n===void 0)return[];let r=null;return n.path.isFunctionDeclaration()?r=n.path.node:n.path.isVariableDeclarator()&&(k.isFunctionExpression(n.path.node.init)||k.isArrowFunctionExpression(n.path.node.init))&&(r=n.path.node.init),r===null?[]:go(r)}function go(e){if(k.isExpression(e.body))return[e.body];let t=[],n=r=>{if(!k.isFunction(r)){if(k.isReturnStatement(r)){k.isExpression(r.argument)&&t.push(r.argument);return}for(let o of k.VISITOR_KEYS[r.type]??[]){let i=r[o];if(Array.isArray(i))for(let s of i)s!=null&&typeof s=="object"&&"type"in s&&n(s);else i!=null&&typeof i=="object"&&"type"in i&&n(i)}}};for(let r of e.body.body)n(r);return t}function xt(e,t,n,r=new Set){let o=Zn(t);if(!r.has(o)){if(r.add(o),k.isIdentifier(o)&&(e.comps.has(o.name)||e.importedComponents.has(o.name))){n.add(o.name);return}if(k.isIdentifier(o)){for(let i of e.stateComponentCandidates.get(o.name)??e.functionComponentCandidates.get(o.name)??[])n.add(i);return}if(k.isConditionalExpression(o)){xt(e,o.consequent,n,r),xt(e,o.alternate,n,r);return}if(k.isLogicalExpression(o)){xt(e,o.right,n,r);return}if(k.isObjectExpression(o)){for(let i of o.properties)k.isObjectProperty(i)&&k.isExpression(i.value)&&xt(e,i.value,n,r);return}if(k.isArrayExpression(o)){for(let i of o.elements)i!=null&&!k.isSpreadElement(i)&&xt(e,i,n,r);return}if(k.isCallExpression(o)&&k.isIdentifier(o.callee)){for(let i of e.functionComponentCandidates.get(o.callee.name)??[])n.add(i);return}if(k.isMemberExpression(o)){let i=ve(o);if(i!==null)for(let s of e.stateComponentCandidates.get(i)??[])n.add(s)}}}function bo(e,t){for(let r of t.node.body){let o=k.isExportNamedDeclaration(r)?r.declaration:r;if(k.isVariableDeclaration(o))for(let i of o.declarations){if(!k.isIdentifier(i.id)||i.init==null)continue;let s=new Set;xt(e,i.init,s),s.size>0&&e.state.has(i.id.name)&&e.stateComponentCandidates.set(i.id.name,[...s])}}let n=!0;for(;n;){n=!1;for(let[r,o]of e.helpers){let i=new Set(e.functionComponentCandidates.get(r)??[]),s=[],a=o.node;(k.isFunctionDeclaration(a)||k.isFunctionExpression(a)||k.isArrowFunctionExpression(a))&&(s=go(a));for(let l of s)xt(e,l,i);i.size>0&&i.size!==(e.functionComponentCandidates.get(r)?.length??0)&&(e.functionComponentCandidates.set(r,[...i]),n=!0)}}}function tt(e,t,n,r,o=new Set){let i=Zn(n);if(!o.has(i)){if(o.add(i),k.isConditionalExpression(i)){tt(e,t,i.consequent,r,o),tt(e,t,i.alternate,r,o);return}if(k.isStringLiteral(i)){if(!/^[A-Za-z][A-Za-z0-9:_-]*$/.test(i.value))throw t.buildCodeFrameError(`memo-dom: '${i.value}' is not a valid dynamic intrinsic tag name`);r.push({compare:k.cloneNode(i),tag:k.jsxIdentifier(i.value)});return}if(k.isIdentifier(i)){if(e.comps.has(i.name)||e.importedComponents.has(i.name)){r.push({compare:k.cloneNode(i),tag:k.jsxIdentifier(i.name)});return}let s=e.stateTagCandidates.get(i.name);if(s!==void 0)for(let l of s)tt(e,t,k.stringLiteral(l),r,o);let a=t.scope.getBinding(i.name);a?.path.isVariableDeclarator()&&a.path.node.init!=null&&tt(e,t,a.path.node.init,r,o);return}if(k.isCallExpression(i)&&k.isIdentifier(i.callee)){for(let s of e.functionTagCandidates.get(i.callee.name)??[])tt(e,t,k.stringLiteral(s),r,o);for(let s of Ps(t,i.callee.name))tt(e,t,s,r,o);for(let s of e.functionComponentCandidates.get(i.callee.name)??[])tt(e,t,k.identifier(s),r,o);return}if(k.isMemberExpression(i)){let s=mo(t,i);if(s!==null){tt(e,t,s,r,o);return}let a=ve(i);if(a===null)return;let l=t.scope.getBinding(a);if(l?.path.isVariableDeclarator()&&l.path.node.init!=null){let d=new Set;xt(e,l.path.node.init,d);for(let u of d)tt(e,t,k.identifier(u),r,o)}for(let d of e.stateTagCandidates.get(a)??[])tt(e,t,k.stringLiteral(d),r,o);for(let d of e.stateComponentCandidates.get(a)??[])tt(e,t,k.identifier(d),r,o)}}}function ws(e){return k.isStringLiteral(e.compare)?`string:${e.compare.value}`:k.isIdentifier(e.compare)?`component:${e.compare.name}`:JSON.stringify(e.compare)}function vs(e,t){if(k.isIdentifier(t)){let n=e.scope.getBinding(t.name);return n?.path.isVariableDeclarator()?[...n.path.node.init==null?[]:[n.path.node.init],...n.constantViolations.flatMap(r=>r.isAssignmentExpression()&&r.node.operator==="="&&k.isExpression(r.node.right)?[r.node.right]:[])]:[]}if(k.isMemberExpression(t)){let n=mo(e,t),r=ye(t),o=[];return r!==null&&(e.getFunctionParent()??e.findParent(a=>a.isProgram()))?.traverse({AssignmentExpression(a){a.node.operator==="="&&k.isMemberExpression(a.node.left)&&ye(a.node.left)===r&&k.isExpression(a.node.right)&&o.push(a.node.right)}}),[...n===null?[]:[n],...o]}return[]}function ho(e,t){let n=k.cloneNode(e,!0);n.openingElement.name=k.cloneNode(t);let r=n.closingElement;return r!=null&&(r.name=k.cloneNode(t)),n}function ks(e,t,n){let r=k.nullLiteral();for(let o=n.length-1;o>=0;o--){let i=n[o];r=k.conditionalExpression(k.binaryExpression("===",k.cloneNode(e,!0),k.cloneNode(i.compare,!0)),ho(t,i.tag),r)}return r}function Ns(e){return k.isIdentifier(e)?e.name:k.isMemberExpression(e)?ye(e)??"<member expression>":"<expression>"}function Eo(e){let t=new Map;for(let[,n]of e.compPaths){n.scope.crawl();let r=[];n.traverse({JSXElement(o){r.push(o)}});for(let o of r.reverse()){if(o.removed)continue;let i=o.node.openingElement.name;if(k.isJSXNamespacedName(i))throw o.buildCodeFrameError("memo-dom: namespaced JSX tags are not supported");if(k.isJSXIdentifier(i)&&(!/^[A-Z]/.test(i.name)||e.comps.has(i.name)||e.importedComponents.has(i.name)))continue;let s=fo(i),a=vs(o,s),l=[];for(let u of a)tt(e,o,u,l);let d=[...new Map(l.map(u=>[ws(u),u])).values()];if(d.length===0)throw o.buildCodeFrameError(`memo-dom: dynamic JSX tag '${Ns(s)}' has no finite string or linked-component candidates`);for(let u of d){if(!k.isJSXIdentifier(u.tag))continue;let c=e.componentProps.get(u.tag.name);if(c===void 0||c.renderProps.length===0)continue;let g=t.get(u.tag.name);g===void 0&&(g=new Map,t.set(u.tag.name,g));for(let x of o.node.openingElement.attributes){if(k.isJSXSpreadAttribute(x)||!k.isJSXIdentifier(x.name)||!c.renderProps.includes(x.name.name))continue;let E=Be(x.value),f=g.get(x.name.name)??{scalar:!1,jsx:!1,at:o};E!==null&&de(E)?f.jsx=!0:f.scalar=!0,g.set(x.name.name,f)}}if(d.length===1){o.replaceWith(ho(o.node,d[0].tag));continue}o.replaceWith(k.jsxFragment(k.jsxOpeningFragment(),k.jsxClosingFragment(),[k.jsxExpressionContainer(ks(s,o.node,d))]))}n.scope.crawl()}for(let[n,r]of t){let o=e.componentProps.get(n);for(let[i,s]of r){if(s.scalar&&s.jsx)throw s.at.buildCodeFrameError(`memo-dom: dynamic component prop '${i}' is used as both scalar data and JSX content`);s.scalar&&(o.renderProps=o.renderProps.filter(a=>a!==i))}}}import*as te from"@babel/types";function Yn(e){return te.isExportNamedDeclaration(e)?e.declaration??null:te.isDeclaration(e)?e:null}function yo(e){let t=new Map;for(let n of e.body){let r=Yn(n);te.isTSTypeAliasDeclaration(r)&&t.set(r.id.name,r.typeAnnotation)}return t}function ft(e,t,n=new Set){if(te.isTSLiteralType(e)&&te.isStringLiteral(e.literal))return[e.literal.value];if(te.isTSUnionType(e))return e.types.flatMap(r=>ft(r,t,n));if(te.isTSIntersectionType(e))return e.types.flatMap(r=>ft(r,t,n));if(te.isTSParenthesizedType(e))return ft(e.typeAnnotation,t,n);if(te.isTSTypeLiteral(e))return e.members.flatMap(r=>(te.isTSPropertySignature(r)||te.isTSIndexSignature(r))&&te.isTSTypeAnnotation(r.typeAnnotation)&&te.isTSType(r.typeAnnotation.typeAnnotation)?ft(r.typeAnnotation.typeAnnotation,t,n):[]);if(te.isTSMappedType(e)&&e.typeAnnotation!=null&&te.isTSType(e.typeAnnotation))return ft(e.typeAnnotation,t,n);if(te.isTSTypeReference(e)&&te.isIdentifier(e.typeName)){let r=e.typeName.name;if((r==="Record"||r==="Readonly"||r==="Partial")&&te.isTSTypeParameterInstantiation(e.typeArguments)){let s=r==="Record"?e.typeArguments.params[1]:e.typeArguments.params[0];if(s!==void 0&&te.isTSType(s))return ft(s,t,n)}if(n.has(r))return[];let o=t.get(r);if(o===void 0)return[];let i=new Set(n);return i.add(r),ft(o,t,i)}return[]}function In(e){let t=yo(e),n=new Map;for(let r of e.body){let o=Yn(r);if(te.isVariableDeclaration(o))for(let i of o.declarations){if(!te.isIdentifier(i.id)||!te.isTSTypeAnnotation(i.id.typeAnnotation))continue;let s=[...new Set(ft(i.id.typeAnnotation.typeAnnotation,t))];s.length>0&&n.set(i.id.name,s)}}return n}function Qn(e){let t=yo(e),n=new Map,r=(o,i)=>{if(!te.isTSTypeAnnotation(i)||!te.isTSType(i.typeAnnotation))return;let s=[...new Set(ft(i.typeAnnotation,t))];s.length>0&&n.set(o,s)};for(let o of e.body){let i=Yn(o);if(te.isFunctionDeclaration(i)&&i.id!=null){r(i.id.name,i.returnType);continue}if(te.isVariableDeclaration(i))for(let s of i.declarations)te.isIdentifier(s.id)&&(te.isArrowFunctionExpression(s.init)||te.isFunctionExpression(s.init))&&r(s.id.name,s.init.returnType)}return n}import*as dt from"@babel/types";import*as Ee from"@babel/types";function Qt(e,t){let n=[],r=[],o=-1;for(let s=0;s<e.length;s++)Ee.isJSXSpreadAttribute(e[s])&&(o=s);let i=[];for(let s=0;s<e.length;s++){let a=e[s];if(Ee.isJSXSpreadAttribute(a)){n.push(Ee.spreadElement(Ee.cloneNode(a.argument))),r.push(Ee.cloneNode(a.argument));continue}let l=$e(a.name);if(l==="key"&&t.skipKey)continue;let d=Is(a,t.fail),u=t.attributeValue?.(l,d)??d,c=/^on[A-Z]/.test(l)&&t.eventValue!==void 0?t.eventValue(l,u):u;n.push(Ee.objectProperty(Ee.isValidIdentifier(l)?Ee.identifier(l):Ee.stringLiteral(l),c,!1,Ee.isIdentifier(c)&&c.name===l)),r.push(Ee.cloneNode(d)),/^on[A-Z]/.test(l)&&s>o&&i.push(l)}return{expression:Ee.objectExpression(n),sources:r,safeEventKeys:i}}function $e(e){return Ee.isJSXIdentifier(e)?e.name:`${e.namespace.name}:${e.name.name}`}function Is(e,t){return e.value==null?Ee.booleanLiteral(!0):Ee.isStringLiteral(e.value)?Ee.cloneNode(e.value):Ee.isJSXExpressionContainer(e.value)&&Ee.isExpression(e.value.expression)?Ee.cloneNode(e.value.expression):t(`memo-dom: attribute '${$e(e.name)}' must contain a JavaScript expression`)}function Rn(e,t,n=new Set){let r=e.importedComponents.get(t);if(r!==void 0)return new Set(r.subtreeReads??[]);if(n.has(t))return new Set;n.add(t);let o=new Set(e.compReads.get(t)??[]);for(let s of e.effects.get(t)??[]){for(let a of s.moduleReads)o.add(a);for(let a of s.conditionModuleReads)o.add(a)}let i=e.compPaths.get(t);return i!==void 0&&i.traverse({JSXElement(s){let a=s.node.openingElement.name;if(!(!dt.isJSXIdentifier(a)||!/^[A-Z]/.test(a.name)))for(let l of Rn(e,a.name,n))o.add(l)}}),n.delete(t),o}function So(e){for(let[t,n]of e.compPaths){let r=e.compReads.get(t);r!==void 0&&n.traverse({JSXAttribute(o){let i=o.parentPath;if(!i?.isJSXOpeningElement())return;let s=i.node.name;if(!dt.isJSXIdentifier(s))return;let a=$e(o.node.name);if(e.componentProps.get(s.name)?.renderCallbacks.includes(a)!==!0)return;let l=o.node.value;!dt.isJSXExpressionContainer(l)||!dt.isExpression(l.expression)||Le(l.expression,d=>{if(dt.isJSXOpeningElement(d)&&dt.isJSXIdentifier(d.name)&&/^[A-Z]/.test(d.name.name))for(let u of Rn(e,d.name.name))r.add(u)})}})}}import*as Ct from"@babel/types";function xo(e){for(let[t,n]of e.compPaths){let r=e.componentProps.get(t);n.traverse({JSXAttribute(o){if($e(o.node.name)!=="ref")return;let i=o.node.value;if(!(!Ct.isJSXExpressionContainer(i)||!Ct.isExpression(i.expression)))for(let s of Co(e,t,i.expression))r.refProps.includes(s)||r.refProps.push(s)}})}}function Co(e,t,n){let r=pt(e,t,n);if(r!==null)return[r];if(!Ct.isArrayExpression(n))return[];let o=[];for(let i of n.elements)i===null||Ct.isSpreadElement(i)||o.push(...Co(e,t,i));return o}import*as Mt from"@babel/types";function Fn(e){let t=!1;return Le(e,n=>{if(t||!Mt.isJSXOpeningElement(n))return;let r=n.name;!Mt.isJSXIdentifier(r)||!/^[a-z]/.test(r.name)||(t=n.attributes.some(o=>Mt.isJSXAttribute(o)&&Mt.isJSXIdentifier(o.name)&&/^on[A-Z]/.test(o.name.name)))}),t}import*as Oe from"@babel/types";function er(e){let t=(r,o)=>{let i=Ye(e,r),s=e.readers.get(i);s||e.readers.set(i,s=new Set);for(let a of o)s.add(a)};for(let[r,o]of e.compReads){if(o.size===0)continue;let i=Hn(e,r);for(let s of o)t(s,i)}for(let{owner:r,suffix:o,vars:i}of e.rowReads.values()){let s=St(e,et(e,r).flatMap(a=>[`${a}/${o}/Row[*]`,`${a}/${o}/Row[*]/*`]));for(let a of i)t(a,s)}for(let{owner:r,suffix:o,vars:i}of e.condReads.values()){let s=St(e,et(e,r).flatMap(a=>[`${a}/${o}`,`${a}/${o}/*`]));for(let a of i)t(a,s)}for(let[r,o]of e.effects){let i=Hn(e,r).filter(s=>!s.endsWith("/*"));for(let s of o){let a=i.map(d=>`${d}/$effects/${s.index}`),l=s.condition===null?a:a.map(d=>`${d}/$active`);for(let d of s.moduleReads)t(d,l);for(let d of s.conditionModuleReads)t(d,a)}}for(let r of e.moduleEffects){let o=r.condition===null?r.entityId:`${r.entityId}/$active`;for(let i of r.moduleReads)t(i,[o]);for(let i of r.conditionModuleReads)t(i,[r.entityId])}for(let[r,o]of e.computeds){let i=`${e.rootId}/$computed/${encodeURIComponent(e.moduleId)}#${r}`;for(let s of o.reads)t(s,[i])}for(let r of e.moduleControlFlow)for(let o of r.sources)t(o,[r.entityId]);if(e.readers.size===0)return null;let n=[...e.readers.entries()].sort(([r],[o])=>r<o?-1:1).map(([r,o])=>Oe.objectProperty(Oe.stringLiteral(r),Oe.arrayExpression([...o].sort().map(i=>Oe.stringLiteral(i)))));return Oe.expressionStatement(Oe.callExpression(Q(e,"installAccessTable"),[Oe.objectExpression([Oe.objectProperty(Oe.identifier("readers"),Oe.objectExpression(n))]),Oe.stringLiteral(e.rootId)]))}function wo(e,t){let n=t?.parentPath;if(!n?.isJSXAttribute())return!1;let r=n.parentPath;if(!r.isJSXOpeningElement())return!1;let o=r.node.name;if(!P.isJSXIdentifier(o)||!/^[A-Z]/.test(o.name))return!1;let i=n.node.name,s=P.isJSXIdentifier(i)?i.name:i.name.name;return e.componentProps.get(o.name)?.renderProps.includes(s)===!0}function Po(e,t){let n=t.parentPath,r=n?.parentPath;if(!n?.isJSXExpressionContainer()||!r?.isJSXElement()&&!r?.isJSXFragment()&&!wo(e,n))throw t.buildCodeFrameError("memo-dom: conditional rendering must be a direct JSX child: <div>{cond ? <A/> : <B/>}</div>");t.skip()}function Rs(e,t){for(let n of t.get("body"))if(!(!n.isImportDeclaration()||n.node.importKind==="type"))for(let r of n.node.specifiers){if(P.isImportSpecifier(r)&&r.importKind==="type")continue;let o=r.local.name;if(!(e.importedState.has(o)||e.importedFunctions.has(o)||e.importedComponents.has(o)))throw n.buildCodeFrameError(`memo-dom: value import '${o}' requires compileModules() so its reactive identity can be linked`)}}function Fs(e,t){let n=In(t.node);for(let r of t.node.body){let o=P.isExportNamedDeclaration(r)?r.declaration:r;if(P.isVariableDeclaration(o)){for(let i of o.declarations)if(P.isIdentifier(i.id)&&(o.kind==="let"||o.kind==="var"?bt(e,i.id.name,"let"):o.kind==="const"&&(kt(i.init)?bt(e,i.id.name,"store"):Nt(i.init)&&bt(e,i.id.name,"const")),e.state.has(i.id.name))){let s=n.get(i.id.name);s!==void 0&&e.stateTagCandidates.set(i.id.name,[...s])}}}}function Ms(e,t){t.traverse({FunctionDeclaration(n){let r=n.node.id?.name;if(r&&!e.comps.has(r)&&!e.helpers.has(r)&&!e.jsxHelpers.has(r))if(Ae(n))if(/^[A-Z]/.test(r)){e.comps.set(r,{parents:new Set,jsxCount:0}),e.compPaths.set(r,n),Fn(n.node.body)&&e.componentsWithHostEvents.add(r);try{e.componentProps.set(r,un(n.node.params))}catch(o){throw n.buildCodeFrameError(`memo-dom: invalid props for component '${r}': ${o instanceof Error?o.message:String(o)}`)}}else e.jsxHelpers.set(r,n);else e.helpers.set(r,n);n.skip()},VariableDeclarator(n){if(!n.scope.path.isProgram()||!P.isIdentifier(n.node.id))return;let r=n.get("init");(r.isArrowFunctionExpression()||r.isFunctionExpression())&&(de(r.node.body)?/^[A-Z]/.test(n.node.id.name)||e.jsxHelpers.set(n.node.id.name,r):e.helpers.set(n.node.id.name,r),r.skip())}});for(let n of t.get("body")){let r=n.isExportNamedDeclaration()?n.get("declaration"):n;if(!(Array.isArray(r)||!r.isVariableDeclaration()))for(let o of r.get("declarations")){if(!o.isVariableDeclarator())continue;let i=o.node.id,s=o.get("init");!P.isIdentifier(i)||/^[A-Z]/.test(i.name)||Array.isArray(s)||!s.isArrowFunctionExpression()&&!s.isFunctionExpression()||!de(s.node.body)||(e.helpers.delete(i.name),e.jsxHelpers.set(i.name,s))}}}function Mn(e,t,n=new Set){if(P.isTSStringKeyword(e)||P.isTSNumberKeyword(e)||P.isTSBooleanKeyword(e)||P.isTSBigIntKeyword(e)||P.isTSSymbolKeyword(e)||P.isTSNullKeyword(e)||P.isTSUndefinedKeyword(e)||P.isTSLiteralType(e))return!0;if(P.isTSParenthesizedType(e))return Mn(e.typeAnnotation,t,n);if(P.isTSUnionType(e))return e.types.every(r=>Mn(r,t,n));if(P.isTSTypeReference(e)&&P.isIdentifier(e.typeName)){let r=e.typeName.name;if(n.has(r))return!1;let o=new Set(n);o.add(r);for(let i of t.body){let s=P.isExportNamedDeclaration(i)?i.declaration:i;if(P.isTSTypeAliasDeclaration(s)&&s.id.name===r)return Mn(s.typeAnnotation,t,o)}}return!1}function Ds(e,t){let n=l=>P.isStringLiteral(l)||P.isNumericLiteral(l)||P.isBooleanLiteral(l)||P.isBigIntLiteral(l)||P.isUnaryExpression(l)&&(l.operator==="+"||l.operator==="-")&&P.isNumericLiteral(l.argument);for(let l of e.node.params){if(P.isTSParameterProperty(l))continue;if(P.isAssignmentPattern(l)&&P.isIdentifier(l.left,{name:t})&&n(l.right))return!0;if(P.isAssignmentPattern(l)&&P.isObjectPattern(l.left)&&P.isObjectExpression(l.right)){let u=l.right.properties.find(c=>!P.isObjectProperty(c)||c.computed?!1:(P.isIdentifier(c.key)?c.key.name:P.isStringLiteral(c.key)?c.key.value:null)===t);if(P.isObjectProperty(u)&&P.isExpression(u.value)&&n(u.value))return!0}let d=P.isAssignmentPattern(l)?l.left:l;if(P.isObjectPattern(d))for(let u of d.properties){if(!P.isObjectProperty(u)||u.computed)continue;if((P.isIdentifier(u.key)?u.key.name:P.isStringLiteral(u.key)?u.key.value:null)===t&&P.isAssignmentPattern(u.value)&&n(u.value.right))return!0}}let r=e.node.params[0];if(r==null||P.isTSParameterProperty(r))return!1;let o=P.isAssignmentPattern(r)?r.left:r;if(!P.isIdentifier(o)&&!P.isObjectPattern(o)&&!P.isArrayPattern(o))return!1;let i=o.typeAnnotation;if(!P.isTSTypeAnnotation(i))return!1;let s=e.findParent(l=>l.isProgram());if(!s?.isProgram())return!1;let a=i.typeAnnotation;if(P.isTSTypeReference(a)&&P.isIdentifier(a.typeName)){let l=a.typeName.name,d=s.node.body.map(u=>P.isExportNamedDeclaration(u)?u.declaration:u).find(u=>(P.isTSInterfaceDeclaration(u)||P.isTSTypeAliasDeclaration(u))&&u.id.name===l);P.isTSInterfaceDeclaration(d)?a=P.tsTypeLiteral(d.body.body):P.isTSTypeAliasDeclaration(d)&&(a=d.typeAnnotation)}if(!P.isTSTypeLiteral(a))return!1;for(let l of a.members){if(!P.isTSPropertySignature(l)||l.computed)continue;if((P.isIdentifier(l.key)?l.key.name:P.isStringLiteral(l.key)?l.key.value:null)===t&&P.isTSTypeAnnotation(l.typeAnnotation))return Mn(l.typeAnnotation.typeAnnotation,s.node)}return!1}function tr(e,t=new Set){if(de(e.node))return!0;if(t.has(e.node))return!1;if(t.add(e.node),e.isIdentifier()){let n=e.scope.getBinding(e.node.name);if(n?.path.isVariableDeclarator()){let r=n.path.get("init");return!Array.isArray(r)&&r.node!=null?tr(r,t):!1}}if(e.isMemberExpression()){let n=e.get("object");return!Array.isArray(n)&&tr(n,t)}return!1}function Ls(e){let t=new Map;for(let[o,i]of e.compPaths){let s=new Set;if(t.set(o,s),i.traverse({JSXExpressionContainer(a){if(!a.parentPath?.isJSXElement()&&!a.parentPath?.isJSXFragment())return;let l=a.node.expression;if(!P.isExpression(l))return;let d=pt(e,o,l);d!==null&&(Ds(i,d)||s.add(d))}}),(i.parentPath?.isExportNamedDeclaration()||i.parentPath?.isExportDefaultDeclaration())&&!e.linkedComponentRenderProps.has(o)){let a=e.componentProps.get(o);for(let l of s)a.renderProps.includes(l)||a.renderProps.push(l)}}let n=new Map;for(let[o,i]of e.compPaths)i.traverse({JSXElement(s){let a=s.node.openingElement.name;if(!P.isJSXIdentifier(a)||!e.comps.has(a.name))return;let l=e.componentProps.get(a.name),d=t.get(a.name);if(d===void 0)return;let u=n.get(a.name);u===void 0&&(u=new Map,n.set(a.name,u)),d.has("children")&&s.node.children.some(c=>!P.isJSXText(c)||c.value.trim()!=="")&&!l.renderProps.includes("children")&&(l.renderProps.push("children"),u.set("children",{scalar:!1,jsx:!0,at:s}));for(let c of s.get("openingElement").get("attributes")){if(!c.isJSXAttribute())continue;let g=c.node.name,x=P.isJSXIdentifier(g)?g.name:g.name.name;if(!d.has(x))continue;let E=u.get(x)??{scalar:!1,jsx:!1,at:c},f=c.get("value"),m=!1;if(f.isJSXExpressionContainer()&&P.isExpression(f.node.expression)){let C=f.get("expression");!Array.isArray(C)&&(tr(C)||P.isExpression(C.node)&&pt(e,o,C.node)!==null)&&(m=!0)}m?E.jsx=!0:E.scalar=!0,u.set(x,E)}}});for(let[o,i]of n){let s=e.componentProps.get(o);for(let[a,l]of i){if(l.scalar&&l.jsx){if(a==="children"){s.renderProps.includes(a)||s.renderProps.push(a);continue}throw l.at.buildCodeFrameError(`memo-dom: prop '${a}' on <${o}> is used as both scalar data and JSX content`)}l.jsx?s.renderProps.includes(a)||s.renderProps.push(a):l.scalar&&(s.renderProps=s.renderProps.filter(d=>d!==a))}}let r=!0;for(;r;){r=!1;for(let[o,i]of e.compPaths){let s=e.componentProps.get(o);i.traverse({JSXAttribute(a){let l=a.get("value");if(!l.isJSXExpressionContainer()||!P.isExpression(l.node.expression))return;let d=pt(e,o,l.node.expression);if(d===null||s.renderProps.includes(d))return;let u=a.parentPath;if(!u.isJSXOpeningElement())return;let c=u.node.name;if(!P.isJSXIdentifier(c)||!/^[A-Z]/.test(c.name))return;let g=e.componentProps.get(c.name),x=a.node.name,E=P.isJSXIdentifier(x)?x.name:x.name.name;g?.renderProps.includes(E)===!0&&(s.renderProps.push(d),r=!0)}})}}for(let[o,i]of e.linkedComponentRenderProps){let s=e.componentProps.get(o);s!==void 0&&(s.renderProps=[...i])}}function As(e,t){let n=e.compPaths.get(t),r=e.comps.get(t);n.traverse({JSXElement(o){let i=o.node.openingElement;if(!P.isJSXIdentifier(i.name))throw o.buildCodeFrameError("memo-dom: namespaced or member-expression JSX tags are not supported (L1)");for(let a of i.attributes)if(!P.isJSXSpreadAttribute(a)&&a.name.name==="key"){if(Rr(e,o))continue;throw o.buildCodeFrameError("memo-dom: key={...} is only meaningful on list rows: items.map(item => <Row key={item.id} />)")}let s=i.name.name;if(/^[A-Z]/.test(s)){let a=e.comps.has(s);if(!a&&!e.importedComponents.has(s))throw o.buildCodeFrameError(`memo-dom: <${s} /> is not a linked component factory`);a&&e.comps.get(s).parents.add(t);let l=e.childRefCounts.get(t);l||e.childRefCounts.set(t,l=new Map),l.set(s,(l.get(s)??0)+1),(o.node.children.some(d=>!P.isJSXText(d)||d.value.trim()!=="")||i.attributes.some(d=>{if(P.isJSXSpreadAttribute(d)||e.componentProps.get(s)?.renderProps.includes(P.isJSXIdentifier(d.name)?d.name.name:d.name.name.name)!==!0)return!1;let u=Be(d.value);return u!==null&&de(u)}))&&e.renderSlotOwners.add(t);return}r.jsxCount++},ConditionalExpression(o){Ae(o)&&Po(e,o)},LogicalExpression(o){if(Ae(o)){if(o.node.operator!=="&&"&&o.node.operator!=="||")throw o.buildCodeFrameError("memo-dom: only && / || conditionals are supported (R8 L1), not ??");Po(e,o)}},CallExpression(o){let i=Ve(o.node);if(i&&(Ae(o)||jt(e,t,i)!==null)){let s=o.parentPath,a=s?.parentPath;if(!s?.isJSXExpressionContainer()||!a?.isJSXElement()&&!a?.isJSXFragment()&&!wo(e,s))throw o.buildCodeFrameError("memo-dom: list rendering must be a direct JSX child: <ul>{items.map(item => <Row />)}</ul>");o.skip()}}})}function js(e){let t=e.parentPath;return t.isCallExpression()&&t.node.callee===e.node}function Js(e,t){let n=ye(t.node);if(!n||!n.includes("."))return null;let r=n.split(".")[0];if(e.state.get(r)!=="store"||t.scope.getBinding(r)?.scope.path.isProgram()!==!0)return null;let o=t.parentPath;return o.isAssignmentExpression({operator:"="})&&o.node.left===t.node||js(t)?null:n}function vo(e,t,n){let r=new Set([...e.instanceReasonIds.get(t)?.keys()??[],...n]);e.instanceReasonIds.set(t,new Map([...r].sort().map((o,i)=>[o,i])))}function $s(e,t){let n=[],r=e;for(;r=It(r),!!P.isMemberExpression(r);){if(n.unshift(r),P.isSuper(r.object))return null;r=r.object}if(!P.isIdentifier(r,{name:t}))return null;let o=n[0];if(o===void 0||!o.computed||!P.isExpression(o.property)||!(P.isIdentifier(o.property)||P.isNumericLiteral(o.property)||P.isStringLiteral(o.property))||n.length<2)return null;let i=[];for(let s of n.slice(1))if(!s.computed&&P.isIdentifier(s.property))i.push(s.property.name);else if(s.computed&&P.isStringLiteral(s.property))i.push(s.property.value);else return null;return i}function Os(e,t,n){let r=!1;return Le(e.node.body,o=>{if(r)return;let i=P.isAssignmentExpression(o)&&P.isMemberExpression(o.left)?o.left:P.isUpdateExpression(o)&&P.isMemberExpression(o.argument)||P.isUnaryExpression(o,{operator:"delete"})&&P.isMemberExpression(o.argument)?o.argument:null;if(i===null)return;let s=$s(i,t);s!==null&&!At(s,n)&&(r=!0)}),r}function Xs(e,t,n,r){if(!r.sourceLocal||!P.isIdentifier(r.sourceExpr))return;let o=r.sourceExpr.name;if(e.instanceState.get(t)?.has(o)!==!0)return;let i=nt(r.keyExpr,r.itemParam);if(i===null||i.length===0)return;let s=e.compPaths.get(t);if(s===void 0||!Os(s,o,i))return;let a=`${t}\0${o}`;if(e.disabledKeyedListMutationSources.has(a))return;let l=e.keyedListMutationSources.get(t);l===void 0&&(l=new Map,e.keyedListMutationSources.set(t,l));let d=l.get(o);if(d!==void 0){e.keyedListMutations.delete(d.call),l.delete(o),e.disabledKeyedListMutationSources.add(a);return}let u={source:o,keyPath:i,keysVariable:A(e,`${o}ChangedKeys`).name,targetedReason:`${a}\0content`,structuralReason:`${a}\0structure`,call:n};l.set(o,u),e.keyedListMutations.set(n,u),e.targetedListComponents.add(t),vo(e,t,[o,u.targetedReason,u.structuralReason])}function Ts(e){for(let[a]of e.comps){let g=function(y,v,M){let R=Ve(y.node);if(R===null||!Ae(y))return;let I=Rt(e,R,y,a,M),H=`${v}/${I.suffix}`;if(I.form==="component"){let O=e.listedSites.get(I.rowComp)??[];O.some(_=>_.owner===a&&_.suffix===H)||O.push({owner:a,suffix:H,itemParam:I.itemParam,keyExpr:I.keyExpr,sourceKey:I.sourceKey,sourceLocal:I.sourceLocal}),e.listedSites.set(I.rowComp,O)}else m(y,I,H);y.skip()},x=function(y,v,M){let R=y.node.openingElement.name;if(!P.isJSXIdentifier(R)||!/^[A-Z]/.test(R.name))return;if(!e.comps.has(R.name)&&!e.importedComponents.has(R.name))throw y.buildCodeFrameError(`memo-dom: <${R.name} /> is not a linked component factory`);let I=M.get(R.name)??0;M.set(R.name,I+1);let H=I===0?R.name:`${R.name}[${I}]`,O=`${v}/${H}`,_=e.conditionalComponentSites.get(R.name)??[];_.some(Y=>Y.owner===a&&Y.suffix===O)||_.push({owner:a,suffix:O}),e.conditionalComponentSites.set(R.name,_)},E=function(y,v,M){let R=y.node.openingElement.name;if(!P.isJSXIdentifier(R)||!/^[A-Z]/.test(R.name))return;if(!e.comps.has(R.name)&&!e.importedComponents.has(R.name))throw y.buildCodeFrameError(`memo-dom: <${R.name} /> is not a linked component factory`);let I=M.get(R.name)??0;M.set(R.name,I+1);let H=I===0?R.name:`${R.name}[${I}]`,O=`${v}/Row[*]/${H}`,_=e.rowComponentSites.get(R.name)??[];_.some(Y=>Y.owner===a&&Y.suffix===O)||_.push({owner:a,suffix:O}),e.rowComponentSites.set(R.name,_)},f=function(y,v){let M=e.listedSites.get(y.rowComp)??[];M.some(R=>R.owner===a&&R.suffix===v)||M.push({owner:a,suffix:v,itemParam:y.itemParam,keyExpr:y.keyExpr,sourceKey:y.sourceKey,sourceLocal:y.sourceLocal}),e.listedSites.set(y.rowComp,M)},m=function(y,v,M){let R=y.get("arguments")[0];if(R===void 0)return;let I=new Set,H=new Map,O=new Map;R.traverse({Identifier(_){_.node.name!==v.itemParam&&e.state.has(_.node.name)&&_.scope.getBinding(_.node.name)?.scope.path.isProgram()===!0&&I.add(_.node.name)},JSXElement(_){E(_,M,H)},CallExpression(_){let Y=Ve(_.node);if(Y!==null&&Ae(_)){let ne=Rt(e,Y,_,a,O,v),xe=`${M}/Row[*]/${ne.suffix}`;ne.form==="component"?f(ne,xe):m(_,ne,xe),_.skip();return}let Z=_.node.callee;if(P.isIdentifier(Z)&&(e.helpers.has(Z.name)||e.importedFunctions.has(Z.name))){let ne=e.importedFunctions.get(Z.name)??Ue(e,Z.name);for(let xe of ne.reads)I.add(xe)}}}),I.size>0&&e.rowReads.set(`${a}/${M}`,{owner:a,suffix:M,vars:I})},C=function(y,v=null){let M=y.node;if(!Ae(y))return;let R=gn(M,y,c),I=v===null?R.suffix:`${v}/${R.suffix}`,H=[];if(y.isConditionalExpression()){let _=y;for(;_.isConditionalExpression();)H.push(_.get("consequent")),_=_.get("alternate");H.push(_)}else H.push(y.get("right"));for(let _ of H){let Y=new Map,Z=new Map;if((_.isConditionalExpression()||_.isLogicalExpression())&&Ae(_)){C(_,I);continue}_.isJSXElement()&&x(_,I,Z),_.traverse({ConditionalExpression(ne){Ae(ne)&&(C(ne,I),ne.skip())},LogicalExpression(ne){Ae(ne)&&(C(ne,I),ne.skip())},JSXElement(ne){x(ne,I,Z)},CallExpression(ne){g(ne,I,Y)}})}let O=dn(e,M);O.size>0&&v===null&&e.condReads.set(`${a}/${I}`,{owner:a,suffix:I,vars:O}),y.skip()};var t=g,n=x,r=E,o=f,i=m,s=C;let l=e.compPaths.get(a),d=new Set,u=new Map,c={count:0};l.traverse({JSXAttribute(y){let v=y.node.name;(P.isJSXIdentifier(v,{name:"ref"})||P.isJSXNamespacedName(v)&&v.namespace.name==="ref")&&y.skip()},ConditionalExpression(y){C(y)},LogicalExpression(y){C(y)},CallExpression(y){if(P.isIdentifier(y.node.callee,{name:"effect"})&&y.scope.getBinding("effect")===void 0){y.skip();return}let v=Ve(y.node);if(v&&(Ae(y)||jt(e,a,v)!==null)){let R=Rt(e,v,y,a,u);Xs(e,a,v,R);let I=po(R,e.instanceState.get(a)??new Set);if(I.length>0&&P.isIdentifier(R.sourceExpr)){let H=R.sourceExpr.name;e.targetedListDependencies.set(v,I.map(O=>({source:H,value:O}))),e.targetedListComponents.add(a),vo(e,a,[H,...I])}if(R.sourceLocal||d.add(R.sourceKey),R.form==="component"){for(let O of R.jsx.openingElement.attributes){if(P.isJSXSpreadAttribute(O))continue;let _=O,Y=P.isJSXIdentifier(_.name)?_.name.name:`${_.name.namespace.name}:${_.name.name.name}`;if(Y==="key"||Y==="ref"||e.componentProps.get(R.rowComp)?.refProps.includes(Y)===!0)continue;let Z=Be(_.value);Z&&Le(Z,ne=>{if(P.isIdentifier(ne)&&e.state.has(ne.name)&&y.scope.getBinding(ne.name)?.scope.path.isProgram()===!0&&d.add(ne.name),P.isMemberExpression(ne)){let xe=ye(ne);if(xe!==null&&xe.includes(".")){let be=xe.split(".")[0];e.state.get(be)==="store"&&y.scope.getBinding(be)?.scope.path.isProgram()===!0&&d.add(xe)}}})}let H=e.listedSites.get(R.rowComp)??[];H.some(O=>O.owner===a&&O.suffix===R.suffix)||H.push({owner:a,suffix:R.suffix,itemParam:R.itemParam,keyExpr:R.keyExpr,sourceKey:R.sourceKey,sourceLocal:R.sourceLocal}),e.listedSites.set(R.rowComp,H)}else m(y,R,R.suffix);y.skip();return}let M=y.node.callee;if(P.isIdentifier(M)&&(e.helpers.has(M.name)||e.importedFunctions.has(M.name))&&y.scope.getBinding(M.name)?.scope.path.isProgram()===!0){let R=e.importedFunctions.get(M.name)??Ue(e,M.name);for(let I of R.reads)d.add(I)}},Identifier(y){if(!e.state.has(y.node.name)||y.scope.getBinding(y.node.name)?.scope.path.isProgram()!==!0)return;let v=y.parentPath;v.isAssignmentExpression({operator:"="})&&v.node.left===y.node||d.add(y.node.name)},MemberExpression(y){let v=Js(e,y);v!==null&&d.add(v)}}),e.compReads.set(a,d)}}function Dn(e,t){Rs(e,t),Fs(e,t),Ms(e,t),xo(e),Fr(e),lo(e),bo(e,t),Ls(e),oo(e),Eo(e),co(e),Zr(e),Gr(e,t),qr(e,t,Un),Yr(e),eo(e),to(e),Vr(e,t);for(let[r]of e.comps)As(e,r);Ts(e),So(e);for(let[r]of e.comps)et(e,r);let n=new Set([...e.listedSites.keys(),...e.linkedComponentRows.keys()]);for(let r of n){if(e.importedComponents.has(r))continue;let o=e.listedSites.get(r)??[],i=e.compPaths.get(r);if((o.length>0||e.linkedComponentRows.has(r))&&(e.comps.get(r).parents.size>0||(e.conditionalComponentSites.get(r)?.length??0)>0))throw i.buildCodeFrameError(`memo-dom: <${r}> is used both as a list row and as a static child \u2014 split it into two components (R7 L1)`)}}import*as D from"@babel/types";import*as h from"@babel/types";import*as Pe from"@babel/types";import*as oe from"@babel/types";function Dt(){return{writes:new Set,rootFallback:!1,rowLocal:!1,rowOwnerLocal:!1,instanceLocal:!1,instanceWrites:new Set,eventOrigin:null}}function Xt(e,t){e.instanceLocal=!0,e.instanceWrites.add(t)}function Tt(e,t,n,r){let o=t.rowLocal&&r!==void 0?oe.expressionStatement(r.refreshVar!==void 0?oe.callExpression(oe.identifier(r.refreshVar),[]):oe.callExpression(Q(e,"markDirty"),[oe.identifier(r.rowIdVar)])):null,i=null;if(t.instanceLocal&&n!==null){let d=e.instanceReasonIds.get(n),u=[...t.instanceWrites].map(g=>d?.get(g)).filter(g=>g!==void 0).sort((g,x)=>g-x),c=t.instanceWrites.size>0&&u.length===t.instanceWrites.size;i=oe.expressionStatement(oe.callExpression(Q(e,"markDirty"),[Je(e,n),...c?[u.length===1?oe.numericLiteral(u[0]):Cr(e,u)]:[]]))}let s=t.rowOwnerLocal&&r?.ownerIdVar!==void 0?oe.expressionStatement(oe.callExpression(Q(e,"markDirty"),[oe.identifier(r.ownerIdVar)])):null,a=d=>{let u=[];return t.eventOrigin!==null&&u.push(t.eventOrigin),o!==null&&u.push(o),s!==null&&u.push(s),i!==null&&u.push(i),d!==null&&u.push(d),u.length===0?null:u.length===1?u[0]:oe.blockStatement(u)};if(t.rootFallback)return a(oe.expressionStatement(oe.callExpression(Q(e,"markDirtySubtree"),[oe.stringLiteral(e.rootId)])));if(t.writes.size===0)return a(null);let l=[...t.writes].sort();return a(oe.expressionStatement(oe.callExpression(Q(e,"commitWrites"),[Ut(e,l)])))}function ko(e,t,n){if(oe.isBlockStatement(t.body)){nr(t.body,n),t.body.body.push(n);return}let r=A(e,"returnValue");t.body=oe.blockStatement([oe.variableDeclaration("const",[oe.variableDeclarator(r,t.body)]),n,oe.returnStatement(oe.cloneNode(r))])}function nr(e,t){if(!oe.isFunction(e))for(let n of oe.VISITOR_KEYS[e.type]??[]){let r=e[n];if(Array.isArray(r))for(let o=0;o<r.length;o++){let i=r[o];!i||typeof i!="object"||!("type"in i)||oe.isFunction(i)||(oe.isReturnStatement(i)?(r.splice(o,0,oe.cloneNode(t)),o++):nr(i,t))}else if(r&&typeof r=="object"&&"type"in r){if(oe.isFunction(r))continue;oe.isReturnStatement(r)?e[n]=oe.blockStatement([oe.cloneNode(t),r]):nr(r,t)}}}import*as Se from"@babel/types";function Pt(e,t,n,r){if(r===void 0&&n?.refreshVar!==void 0)return Se.expressionStatement(Se.callExpression(Se.identifier(n.refreshVar),[]));let o=r??(n!==void 0?Se.identifier(n.rowIdVar):t!==null?Je(e,t):Se.stringLiteral(e.rootId));return Se.expressionStatement(Se.callExpression(Q(e,"markDirty"),[Se.cloneNode(o)]))}function Bt(e,t,n){let r=A(e,"event"),o=A(e,"returnValue");return Se.arrowFunctionExpression([r],Se.blockStatement([Se.variableDeclaration("const",[Se.variableDeclarator(o,Se.callExpression(Se.cloneNode(t),[Se.cloneNode(r)]))]),n,Se.returnStatement(Se.cloneNode(o))]))}import Ro from"@babel/traverse";import*as T from"@babel/types";function Bs(e,t,n){if(n.key===null)return null;let r=e.componentProps.get(t);if(r===void 0)return null;let o=Ke(r);if(n.root===o){let[s,...a]=n.key.split(".").slice(1);return s===void 0?null:{name:s,path:a}}let i=Ze(r,n.root);return i===null?null:{name:i,path:n.key.split(".").slice(1)}}function rr(e,t,n,r,o){let i=Bs(e,t,r);if(i===null)return!1;n===void 0?Xt(o,r.root):o.rowLocal=!0;let s=e.linkedComponentPropSources.get(t)?.get(i.name);if(s===void 0)return o.rootFallback=!0,!0;o.rootFallback||=s.rootFallback;let a=i.path.length===0?"":`.${i.path.join(".")}`;for(let l of s.keys)o.writes.add(`${l}${a}`);return!0}import*as he from"@babel/types";function Ln(e){return he.isIdentifier(e)||he.isObjectPattern(e)||he.isArrayPattern(e)||he.isAssignmentPattern(e)||he.isRestElement(e)}function Vs(e){let t=e;for(;he.isTSAsExpression(t)||he.isTSTypeAssertion(t)||he.isTSNonNullExpression(t)||he.isTSSatisfiesExpression(t);)t=t.expression;return t}function en(e,t,n){if(he.isIdentifier(t)){e.set(t.name,n);return}if(he.isAssignmentPattern(t)){Ln(t.left)&&en(e,t.left,n);return}if(!he.isRestElement(t)){if(he.isArrayPattern(t)){for(let r=0;r<t.elements.length;r++){let o=t.elements[r];Ln(o)&&en(e,o,Et(n,[String(r)]))}return}if(he.isObjectPattern(t))for(let r of t.properties){if(he.isRestElement(r))continue;if(r.computed||!he.isIdentifier(r.key)&&!he.isStringLiteral(r.key)&&!he.isNumericLiteral(r.key)){Ln(r.value)&&en(e,r.value,{...n,key:null});continue}let o=he.isIdentifier(r.key)?r.key.name:String(r.key.value);Ln(r.value)&&en(e,r.value,Et(n,[o]))}}}function No(e,t,n,r){let o=Vs(r),i=e.componentProps.get(t);if(i===void 0)return null;if(he.isIdentifier(o)){let d=n.get(o.name);return d!==void 0?d:Ke(i)===o.name?{locality:"prop",root:o.name,key:o.name}:Ze(i,o.name)===null?null:{locality:"prop",root:o.name,key:o.name}}if(!he.isMemberExpression(o))return null;let s=ve(o),a=ye(o);if(s===null)return null;let l=No(e,t,n,he.identifier(s));return l===null?null:a===null?{...l,key:null}:Et(l,a.split(".").slice(1))}function Io(e,t){let n=new Map;for(let r of e.instanceDerivations.get(t)??[]){let o=No(e,t,n,r.source);o!==null&&en(n,r.target,o)}return n}var Fo=Ro.default??Ro;function Ws(e,t){let n=[],r=e;for(;r=It(r),!!T.isMemberExpression(r);){if(n.unshift(r),T.isSuper(r.object))return null;r=r.object}if(!T.isIdentifier(r,{name:t.source}))return null;let o=n[0];if(o===void 0||!o.computed||!T.isExpression(o.property)||!(T.isIdentifier(o.property)||T.isNumericLiteral(o.property)||T.isStringLiteral(o.property))||n.length<2)return null;let i=[];for(let a of n.slice(1))if(!a.computed&&T.isIdentifier(a.property))i.push(a.property.name);else if(a.computed&&T.isStringLiteral(a.property))i.push(a.property.value);else return null;if(At(i,t.keyPath))return null;let s=T.cloneNode(o,!0);for(let a of t.keyPath)s=T.memberExpression(s,T.identifier(a));return s}function zs(e,t){let n=new Set;for(let[r,o]of e.compReads)o.has(t)&&n.add(r);for(let r of e.rowReads.values())r.vars.has(t)&&n.add("__rows__");for(let r of e.condReads.values())r.vars.has(t)&&n.add("__regions__");return n}function Mo(e,t,n){if(n.sourceLocal)return!0;let r=n.sourceKey;if(r==="")return!0;for(let i of e.computeds.values())if(i.reads.has(r))return!0;let o=new Set((e.listedSites.get(t??"")??[]).map(i=>i.owner));o.size===0&&t!==null&&o.add(t);for(let i of zs(e,r))if(i==="__rows__"||i==="__regions__"||!o.has(i))return!0;return!1}function tn(e,t,n,r,o=!1,i,s=!1){let a=T.cloneNode(t),l=a,d=T.file(T.program([T.isFunctionDeclaration(a)?a:T.expressionStatement(a)])),u=n!==null?e.instanceState.get(n):void 0,c=n!==null?e.instanceDerivedBindings.get(n):void 0,g=n===null?new Map:Io(e,n),x=n!==null?new Set(e.componentProps.get(n)?.bindings??[]):new Set,E=new Set([...x,...u??[],...c??[]]);if(n!==null)for(let S of e.compPaths.get(n)?.node.body.body??[])if(T.isVariableDeclaration(S))for(let w of S.declarations)for(let L of Object.keys(T.getBindingIdentifiers(w.id)))E.add(L);else T.isFunctionDeclaration(S)&&S.id&&E.add(S.id.name);let f=new Jt((S,w)=>{if(w!==void 0)return null;let L=g.get(S);if(L!==void 0)return L;if(r!==void 0&&S===r.itemParam)return{locality:"row",root:S,key:S};if(u?.has(S)===!0)return{locality:"instance",root:S,key:S};if(x.has(S))return{locality:"prop",root:S,key:S};if(E.has(S))return null;let ee=e.state.get(S);return ee===void 0?null:bn(S,ee)}),m=S=>S.stateKind==="computed"||e.state.get(S.root)==="computed",C=n===null?void 0:e.keyedListMutationSources.get(n),y=(S,w,L="structural")=>{Xt(S,w);let ee=C?.get(w);ee!==void 0&&Xt(S,L==="targeted"?ee.targetedReason:ee.structuralReason)},v=(S,w,L)=>{S.isExpression()&&(S.replaceWith(T.sequenceExpression([T.callExpression(T.memberExpression(T.identifier(w.keysVariable),T.identifier("add")),[L]),S.node])),S.skip())},M=new Set;for(let S of a.params)T.isIdentifier(S)&&M.add(S.name);Fo(d,{VariableDeclarator(S){T.isIdentifier(S.node.id)&&(M.add(S.node.id.name),S.parentPath.isVariableDeclaration()&&f.trackDeclarator(S.scope,S.node))},Function(S){for(let w of S.node.params)T.isIdentifier(w)&&M.add(w.name)}});let R=new Map,I=new Map,H=S=>{let w=S.getFunctionParent()?.node??l,L=R.get(w);return L||R.set(w,L=Dt()),L},O=(S,w)=>{if(w(H(S)),!s||S.getFunctionParent()?.node!==l)return;let L=I.get(S.node);L===void 0&&(L={path:S,writes:Dt()},I.set(S.node,L)),w(L.writes)},_=S=>{O(S,w=>{r?.sourceLocal?w.rowOwnerLocal=!0:r!==void 0&&w.writes.add(r.sourceKey)})},Y=S=>{if(r===void 0)return null;let w=S.split(".").slice(1);return r.itemPath.some((L,ee)=>w[ee]!==L)?null:w.slice(r.itemPath.length)},Z=(S,w)=>{O(S,L=>{w!==void 0&&n!==null&&rr(e,n,r,w,L)||(L.rowLocal=!0,L.rootFallback=!0)})},ne=(S,w)=>{O(S,L=>{(n===null||!rr(e,n,r,w,L))&&(r===void 0?(n!==null&&Xt(L,w.root),L.rootFallback=!0):(L.rowLocal=!0,L.rootFallback=!0))})},xe=(S,w)=>{if(r===void 0||ve(w)!==r.itemParam)return!1;let L=ye(w);if(L===null)return r.itemPath.length===0?_(S):Z(S),!0;let ee=L.split(".").slice(1);return r.itemPath.some((Xe,Ie)=>ee[Ie]!==Xe)?!1:(ee.splice(0,r.itemPath.length),At(ee,r.keyPath)?_(S):(O(S,Xe=>{Xe.rowLocal=!0}),Mo(e,n,r)&&_(S)),!0)},be=(S,w)=>{if(w.locality==="instance"){O(S,L=>{y(L,w.root)});return}if(w.locality==="row"){if(r===void 0){O(S,ee=>{ee.rootFallback=!0});return}if(w.key===null){r.itemPath.length===0?_(S):Z(S);return}let L=Y(w.key);if(L===null){Z(S,w);return}At(L,r.keyPath)?_(S):(O(S,ee=>{ee.rowLocal=!0}),Mo(e,n,r)&&_(S));return}if(w.locality==="prop"){ne(S,w);return}if(w.stateKind==="computed")throw S.buildCodeFrameError(`memo-dom: cannot mutate computed '${w.root}' (R13) - it is derived; write its SOURCE state instead`);if(w.stateKind!=="store"){O(S,L=>{L.writes.add(w.root)});return}w.key!==null&&w.key.includes(".")?O(S,L=>{L.writes.add(w.key)}):O(S,L=>{L.writes.add(w.root)})},ie=(S,w)=>{if(w.locality==="instance"){O(S,L=>{y(L,w.root)});return}if(w.locality==="row"){if(r===void 0){O(S,Xe=>{Xe.rootFallback=!0});return}if(w.key===null){r.itemPath.length===0?_(S):Z(S);return}let L=Y(w.key);if(L===null){Z(S,w);return}L.length===0&&(r.keyPath===null||r.keyPath.length>0)?_(S):be(S,w);return}if(w.locality==="prop"){ne(S,w);return}if(w.stateKind==="computed")throw S.buildCodeFrameError(`memo-dom: cannot mutate computed '${w.root}' (R13) - write its SOURCE state instead`);O(S,L=>{L.writes.add(w.key??w.root)})},V=(S,w)=>{if(!(s&&S.getFunctionParent()?.node===l))for(let L of En(w)){if(!T.isIdentifier(L))continue;let ee=f.resolveExpression(S.scope,L);ee!==null&&(m(ee)||ie(S,ee))}},le=(S,w)=>{let L=ve(w);if(L!==void 0&&u?.has(L??"")===!0){let Ie=C?.get(L),qe=Ie===void 0?null:Ws(w,Ie);O(S,sn=>{y(sn,L,qe===null?"structural":"targeted")}),Ie!==void 0&&qe!==null&&v(S,Ie,qe);return}if(L!==null&&c?.has(L)&&!g.has(L))throw S.buildCodeFrameError(`memo-dom: cannot mutate per-instance derivation '${L}' (R14) \u2014 write its source instead`);if(xe(S,w))return;let ee=f.resolveExpression(S.scope,w);if(ee!==null){be(S,ee);return}if(L!==null&&x.has(L)){ne(S,{locality:"prop",root:L,key:ye(w)});return}if(L!==null&&E.has(L)||!L||!e.state.has(L))return;let Xe=e.state.get(L);if(Xe==="computed")throw S.buildCodeFrameError(`memo-dom: cannot mutate computed '${L}' (R13) \u2014 it is derived; write its SOURCE state instead`);O(S,Ie=>{if(Xe!=="store"){Ie.writes.add(L);return}let qe=ye(w);qe!==null&&qe.includes(".")?Ie.writes.add(qe):Ie.writes.add(L)})};Fo(d,{VariableDeclarator(S){if(!T.isIdentifier(S.node.id)&&S.node.init!==null)for(let w of f.referencedOrigins(S.scope,S.node.init))ie(S,w)},AssignmentExpression(S){let w=S.node.left;if(T.isIdentifier(w)){if(M.has(w.name)){if(T.isIdentifier(S.node.right)){let ee=f.resolveExpression(S.scope,S.node.right);ee!==null&&ie(S,ee)}return}if(c?.has(w.name))throw S.buildCodeFrameError(`memo-dom: cannot assign per-instance derivation '${w.name}' (R14) \u2014 write its source instead`);if(u?.has(w.name)===!0){O(S,ee=>{y(ee,w.name)});return}if(x.has(w.name))throw S.buildCodeFrameError(`memo-dom: cannot assign prop '${w.name}' \u2014 copy it to component-local let state first`);if(E.has(w.name))throw S.buildCodeFrameError(`memo-dom: cannot assign component-local const '${w.name}'`);let L=e.state.get(w.name);if(!L)throw S.buildCodeFrameError(`memo-dom: handler assigns '${w.name}', which is neither module state nor a handler local \u2014 declare it at module level (let) or inside the handler`);if(e.importedState.has(w.name))throw S.buildCodeFrameError(`memo-dom: cannot reassign imported state '${w.name}' - ES module imports are read-only; export a mutator or mutate an imported store property`);if(L==="store")throw S.buildCodeFrameError(`memo-dom: cannot reassign store '${w.name}' \u2014 assign a property (${w.name}.field = \u2026) instead`);if(L==="const")throw S.buildCodeFrameError(`memo-dom: cannot reassign mutable const root '${w.name}' - mutate the object instead`);if(L==="computed")throw S.buildCodeFrameError(`memo-dom: cannot assign computed '${w.name}' (R13) \u2014 it is derived; write its SOURCE state instead and the derivation recomputes`);O(S,ee=>{ee.writes.add(w.name)})}else if(T.isMemberExpression(w))le(S,w);else for(let L of f.referencedOrigins(S.scope,S.node.right))ie(S,L)},UpdateExpression(S){let w=S.node.argument;if(T.isIdentifier(w)){if(M.has(w.name))return;if(c?.has(w.name))throw S.buildCodeFrameError(`memo-dom: cannot update per-instance derivation '${w.name}' (R14) \u2014 write its source instead`);if(u?.has(w.name)===!0){O(S,ee=>{y(ee,w.name)});return}if(x.has(w.name))throw S.buildCodeFrameError(`memo-dom: cannot update prop '${w.name}' \u2014 copy it to component-local let state first`);if(E.has(w.name))throw S.buildCodeFrameError(`memo-dom: cannot update component-local const '${w.name}'`);let L=e.state.get(w.name);if(!L)throw S.buildCodeFrameError(`memo-dom: handler updates '${w.name}', which is neither module state nor a handler local`);if(e.importedState.has(w.name))throw S.buildCodeFrameError(`memo-dom: cannot update imported state '${w.name}' - ES module imports are read-only; call an exported mutator instead`);if(L!=="let")throw S.buildCodeFrameError(L==="computed"?`memo-dom: cannot update computed '${w.name}' (R13) \u2014 it is derived; write its SOURCE state instead`:`memo-dom: cannot update '${w.name}' \u2014 it is a const binding; mutate its contents instead`);O(S,ee=>{ee.writes.add(w.name)})}else T.isMemberExpression(w)&&le(S,w)},UnaryExpression(S){S.node.operator==="delete"&&T.isMemberExpression(S.node.argument)&&le(S,S.node.argument)},CallExpression(S){let w=S.node.callee;if(T.isMemberExpression(w)){if(yn(w)==="assign"&&T.isIdentifier(w.object,{name:"Object"})){let Ie=S.node.arguments[0],qe=Ie!==void 0&&T.isExpression(Ie)?f.resolveExpression(S.scope,Ie):null;if(qe!==null)if(qe.locality==="module"&&qe.stateKind==="store"){let sn=hn(qe,S.node.arguments.slice(1));sn===null?ie(S,qe):O(S,Ri=>{for(let Fi of sn)Ri.writes.add(Fi)})}else be(S,qe);return}let ee=T.isIdentifier(w.object)?w.object.name:T.isMemberExpression(w.object)?ve(w.object):null;if(ee!==null&&c?.has(ee)&&!g.has(ee))throw S.buildCodeFrameError(`memo-dom: cannot mutate per-instance derivation '${ee}' (R14) - write its source instead`);let Xe=T.isExpression(w.object)?f.resolveExpression(S.scope,w.object):null;Xe!==null?ie(S,Xe):V(S,S.node.arguments);return}if(T.isIdentifier(w)&&!E.has(w.name)&&(e.helpers.has(w.name)||e.importedFunctions.has(w.name))){let L=e.importedFunctions.get(w.name)??Ue(e,w.name);O(S,ee=>{for(let Ie of L.writes)ee.writes.add(Ie);for(let Ie of L.boundedWrites)ee.writes.add(Ie);let Xe=s&&S.getFunctionParent()?.node===l;L.unbounded&&!Xe&&(ee.rootFallback=!0)});for(let ee of L.parameterWrites){let Xe=S.node.arguments[ee.index];if(Xe===void 0||!T.isExpression(Xe))continue;let Ie=f.resolveExpression(S.scope,Xe);if(Ie!==null){if(m(Ie))continue;ie(S,Et(Ie,ee.path))}}return}V(S,S.node.arguments)}});let Te=R.has(l);if(e.handlerHasRootCommit.set(t,Te),o&&!R.has(l)){let S=Dt();S.eventOrigin=Pt(e,n,r,i),R.set(l,S)}let we=[];if(s)for(let S of I.values()){let w=Tt(e,S.writes,n,r);w!==null&&we.push({...S,commit:w})}for(let S of we)S.flag=A(e,"didWrite");we.sort((S,w)=>Do(w.path)-Do(S.path)).forEach(S=>Ks(S.path,S.flag));for(let[S,w]of R){let L=s&&S===l?we.length===0?null:T.blockStatement(we.map(ee=>T.ifStatement(T.cloneNode(ee.flag),T.cloneNode(ee.commit)))):Tt(e,w,n,r);L&&ko(e,S,L)}if(we.length>0){if(!T.isBlockStatement(a.body))throw new Error("memo-dom: execution-aware callback commit did not produce a block body");a.body.body.unshift(T.variableDeclaration("let",we.map(S=>T.variableDeclarator(T.cloneNode(S.flag),T.booleanLiteral(!1)))))}t.body=a.body}function Do(e){let t=0,n=e;for(;n.parentPath!==null;)t++,n=n.parentPath;return t}function Ks(e,t){let n=T.assignmentExpression("=",T.cloneNode(t),T.booleanLiteral(!0));if(e.isVariableDeclarator()){let r=e.node.init;if(r===null||!T.isExpression(r))throw new Error("memo-dom: execution-aware variable site has no expression initializer");e.node.init=T.sequenceExpression([n,r]);return}if(!e.isExpression())throw new Error(`memo-dom: unsupported execution-aware write site '${e.node.type}'`);e.replaceWith(T.sequenceExpression([n,e.node]))}import*as ct from"@babel/types";function Lo(e,t){let n=!1,r=!0,o=i=>{if(r&&!(i!==e&&ct.isFunction(i))){if((ct.isCallExpression(i)||ct.isOptionalCallExpression(i))&&(n=!0,!ct.isIdentifier(i.callee)||!t(i.callee.name))){r=!1;return}for(let s of ct.VISITOR_KEYS[i.type]??[]){let a=i[s];if(Array.isArray(a))for(let l of a)l!==null&&typeof l=="object"&&"type"in l&&o(l);else a!==null&&typeof a=="object"&&"type"in a&&o(a)}}};return o(e),n&&r}function mt(e,t){let r=e.scope.getBinding(t)?.path;if(!r||r.getFunctionParent()!==e)return null;if(r.isFunctionDeclaration())return r.node;if(!r.isVariableDeclarator())return null;let o=r.node.init;return o&&(Pe.isArrowFunctionExpression(o)||Pe.isFunctionExpression(o))?o:null}function at(e,t,n,r,o,i=!1){e.analyzedFunctions.has(n)||(or(e,t,n,r,o),e.analyzedFunctions.add(n),tn(e,n,r,o,!1,void 0,i))}function nn(e,t,n=!1){e.analyzedFunctions.has(t)||(e.analyzedFunctions.add(t),tn(e,t,null,void 0,!1,void 0,n))}function or(e,t,n,r,o){let i=new Set;Le(n.body,s=>{Pe.isCallExpression(s)&&Pe.isIdentifier(s.callee)&&i.add(s.callee.name)});for(let s of i){let a=mt(t,s);a===null||e.analyzedFunctions.has(a)||(e.analyzedFunctions.add(a),or(e,t,a,r,o),tn(e,a,r,o,!1))}}function ir(e,t,n,r,o,i,s){let a=null,l=!1,d=e.componentProps.get(o),u=d===void 0?null:Ke(d);if(d!==void 0&&(Pe.isIdentifier(n)&&Ze(d,n.name)!==null||Pe.isMemberExpression(n)&&u!==null&&ve(n)===u))return Bt(e,n,Pt(e,o,i,s));if(Pe.isArrowFunctionExpression(n)||Pe.isFunctionExpression(n))a=n;else if(Pe.isIdentifier(n)){let g=e.importedFunctions.get(n.name);if(g!==void 0){let f=Dt();for(let m of g.writes)f.writes.add(m);for(let m of g.boundedWrites)f.writes.add(m);return f.rootFallback=g.unbounded,Bt(e,n,Tt(e,f,null)??Pt(e,o,i,s))}let x=t.scope.getBinding(n.name),E=x?.path;if(E&&E.isVariableDeclarator()){let f=E.node.init;f&&(Pe.isArrowFunctionExpression(f)||Pe.isFunctionExpression(f))&&(a=f,l=x?.scope.path.isProgram()===!0&&e.helpers.has(n.name))}else E&&E.isFunctionDeclaration()&&(e.helpers.has(n.name)?(a=E.node,l=!0):a=mt(t,n.name));if(!a)throw t.buildCodeFrameError(`memo-dom: cannot resolve handler '${n.name}' \u2014 use an inline arrow, a component-local const, or a module-level function (L1)`)}else throw t.buildCodeFrameError(`memo-dom: unsupported ${r} handler form \u2014 expected an arrow function or a function reference (L1)`);if(Pe.isBlockStatement(a.body)||(a.body=Pe.blockStatement([Pe.expressionStatement(a.body)])),!e.analyzedFunctions.has(a)){l||or(e,t,a,o,i);let g=!l&&!Pe.isIdentifier(n)&&Lo(a,x=>{let E=mt(t,x);return E!==null&&e.handlerHasRootCommit.get(E)===!0});e.analyzedFunctions.add(a),tn(e,a,l?null:o,l?void 0:i,!l&&!Pe.isIdentifier(n)&&!g,s)}if(l){let g=Ue(e,n.name);if(a.async){let x=Dt();for(let E of g.writes)x.writes.add(E);for(let E of g.boundedWrites)x.writes.add(E);return x.rootFallback=g.unbounded,Bt(e,n,Tt(e,x,null)??Pt(e,o,i,s))}if(g.writes.size===0&&g.boundedWrites.size===0&&!g.unbounded)return Bt(e,n,Pt(e,o,i,s))}return Pe.isIdentifier(n)&&!l&&(e.handlerHasRootCommit.get(a)===!1||a.async)?Bt(e,n,Pt(e,o,i,s)):Pe.isIdentifier(n)?n:a}import*as Ne from"@babel/types";function sr(e,t){let n=[];for(let r of e){if(Ne.isJSXText(r)){let a=Wn(r.value);a!==""&&n.push({type:"node",variable:t.emitText(Ne.stringLiteral(a))});continue}if(Ne.isJSXElement(r)||Ne.isJSXFragment(r)){n.push({type:"node",variable:t.emitNode(r)});continue}if(Ne.isJSXExpressionContainer(r)||t.fail("memo-dom: spread children are not supported"),Ne.isJSXEmptyExpression(r.expression))continue;Ne.isExpression(r.expression)||t.fail("memo-dom: unsupported expression in JSX child position");let o=r.expression;if(t.isForwarded(o)){n.push({type:"slot",expression:Ne.cloneNode(o)});continue}if(Ne.isNullLiteral(o)||Ne.isBooleanLiteral(o)||Ne.isIdentifier(o,{name:"undefined"}))continue;let i=Ve(o);if(i!==null){n.push({type:"list",expression:i});continue}let s=mn(o);if(s!==null&&de(s)){n.push({type:"condition",expression:s});continue}n.push({type:"node",variable:t.emitText(Ne.cloneNode(o))})}return n}import*as B from"@babel/types";var Us=new Set(["innerHTML","checked","value","selected","disabled","hidden","multiple","required","readOnly","muted","open","controls","loop","autoFocus","autoPlay","tabIndex"]),Ao={htmlFor:"for",crossOrigin:"crossorigin"};function ar(e,t){return!t&&Us.has(e)?e:null}function lr(e,t){return!t&&e in Ao}function dr(e,t,n){let r=B.identifier(e);if(t==="tabIndex")return B.isStringLiteral(n)?B.expressionStatement(B.assignmentExpression("=",B.memberExpression(r,B.identifier(t)),B.cloneNode(n))):B.expressionStatement(B.conditionalExpression(B.binaryExpression("==",B.cloneNode(n),B.nullLiteral()),B.callExpression(B.memberExpression(B.cloneNode(r),B.identifier("removeAttribute")),[B.stringLiteral("tabindex")]),B.assignmentExpression("=",B.memberExpression(B.cloneNode(r),B.identifier(t)),B.cloneNode(n))));let o=t==="value"||t==="innerHTML"?B.stringLiteral(""):B.booleanLiteral(!1),i=B.isStringLiteral(n)?B.cloneNode(n):B.conditionalExpression(B.binaryExpression("==",B.cloneNode(n),B.nullLiteral()),o,B.cloneNode(n));return B.expressionStatement(B.assignmentExpression("=",B.memberExpression(r,B.identifier(t)),i))}function An(e,t,n){let r=B.identifier(e),o=Ao[t]??t;return B.isStringLiteral(n)?B.expressionStatement(B.callExpression(B.memberExpression(r,B.identifier("setAttribute")),[B.stringLiteral(o),B.cloneNode(n)])):B.expressionStatement(B.conditionalExpression(B.logicalExpression("||",B.binaryExpression("==",B.cloneNode(n),B.nullLiteral()),B.binaryExpression("===",B.cloneNode(n),B.booleanLiteral(!1))),B.callExpression(B.memberExpression(B.cloneNode(r),B.identifier("removeAttribute")),[B.stringLiteral(o)]),B.callExpression(B.memberExpression(r,B.identifier("setAttribute")),[B.stringLiteral(o),B.conditionalExpression(B.binaryExpression("===",B.cloneNode(n),B.booleanLiteral(!0)),B.stringLiteral(""),B.callExpression(B.identifier("String"),[B.cloneNode(n)]))])))}import*as _e from"@babel/types";var Hs="http://www.w3.org/2000/svg",_s=new Set(["animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","switch","symbol","text","textPath","tspan","use","view"]);function jo(e,t){return t||e==="svg"||_s.has(e)}function Jo(e,t){return t?_e.callExpression(_e.memberExpression(_e.identifier("document"),_e.identifier("createElementNS")),[_e.stringLiteral(Hs),_e.stringLiteral(e)]):_e.callExpression(_e.memberExpression(_e.identifier("document"),_e.identifier("createElement")),[_e.stringLiteral(e)])}import*as fe from"@babel/types";function jn(e,t,n){let r=e.componentProps.get(t);if(r?.mode==="object"){if(!r.acceptsUnknown){for(let s of n)if(!r.names.includes(s.name))throw new Error(`memo-dom: unknown prop '${s.name}' on <${t}> - declared props: ${r.names.length>0?r.names.join(", "):"(none)"}`)}return n.length===0&&r.hasWholeDefault?[fe.identifier("undefined")]:[fe.objectExpression(n.map(s=>fe.objectProperty(fe.identifier(s.name),s.value,!1,fe.isIdentifier(s.value)&&s.value.name===s.name)))]}let o=r?.names;if(o===void 0)return n.map(s=>s.value);let i=new Map(n.map(s=>[s.name,s.value]));for(let s of i.keys())if(!o.includes(s))throw new Error(`memo-dom: unknown prop '${s}' on <${t}> - declared props: ${o.length>0?o.join(", "):"(none)"}`);return o.map(s=>i.get(s)??fe.identifier("undefined"))}function Vt(e,t,n){let r=e.componentProps.get(t);return r?.mode==="object"?[fe.cloneNode(n)]:(r?.names??[]).map(o=>fe.memberExpression(fe.cloneNode(n),fe.isValidIdentifier(o)?fe.identifier(o):fe.stringLiteral(o),!fe.isValidIdentifier(o)))}function $o(e,t,n,r,o){let i=A(e,`${t}Props`);return fe.blockStatement([fe.variableDeclaration("const",[fe.variableDeclarator(fe.cloneNode(i),fe.cloneNode(o))]),fe.expressionStatement(fe.callExpression(Q(e,"setProps"),[fe.binaryExpression("+",fe.cloneNode(n),fe.stringLiteral(r)),fe.arrayExpression(Vt(e,t,i))]))])}import*as Fe from"@babel/types";function Wt(e){return(Fe.isArrowFunctionExpression(e)||Fe.isFunctionExpression(e))&&!qs(e.body)}function cr(e,t,n,r="callback"){let o=A(e,r);return t.creation.push(Fe.variableDeclaration("const",[Fe.variableDeclarator(Fe.cloneNode(o),Fe.cloneNode(n,!0))])),o}function ur(e,t,n,r="callback"){let o=A(e,r);return t.push(Fe.variableDeclaration("const",[Fe.variableDeclarator(Fe.cloneNode(o),Fe.cloneNode(n,!0))])),o}function qs(e){let t=!1;return Fe.traverseFast(e,n=>{if(Fe.isJSXElement(n)||Fe.isJSXFragment(n))return t=!0,Fe.traverseFast.stop}),t}import*as U from"@babel/types";function Oo(e,t,n,r,o,i,s,a=!1,l=Je(e,o),d=!1){let u=gn(n,i,t.usedConds),c=A(e,u.suffix).name,g=U.binaryExpression("+",U.cloneNode(l),U.stringLiteral(`/${u.suffix}`)),x=U.arrowFunctionExpression([],U.cloneNode(u.pickExpr)),E=u.branches.map(f=>f!==null?pr(e,f,o,i,g,s,a,g,!1,t.usedConds):U.nullLiteral());t.creation.push(yt(e,U.cloneNode(g),U.cloneNode(l),U.arrowFunctionExpression([],U.callExpression(U.memberExpression(U.identifier(c),U.identifier("update")),[])))),t.creation.push(U.variableDeclaration("const",[U.variableDeclarator(U.identifier(c),U.callExpression(Q(e,"createCondRegion"),[U.identifier(r),U.cloneNode(g),x,U.arrayExpression(E)]))])),(d||Pr(e,n,o))&&t.updaters.push(()=>U.expressionStatement(U.callExpression(U.memberExpression(U.identifier(c),U.identifier("update")),[]))),t.disposableRegions.push(c),t.disposableEntities.push(U.cloneNode(g))}function pr(e,t,n,r,o,i,s=!1,a=o,l=!1,d){let u=rt(e,!0);d!==void 0&&(u.usedConds=d);let c=i(e,u,t,n,r,l?null:"cond",void 0,o,s,a),g=[U.objectProperty(U.identifier("nodes"),U.callExpression(Q(e,"rootNodes"),[U.identifier(c)])),U.objectProperty(U.identifier("update"),U.identifier(u.updateVar))];if(u.disposableRegions.length>0||u.disposableEntities.length>0||u.disposableCallbacks.length>0){let x=[...[...u.disposableCallbacks].reverse().map(E=>U.ifStatement(U.binaryExpression("!==",U.cloneNode(E),U.nullLiteral()),U.expressionStatement(U.callExpression(U.cloneNode(E),[])))),...u.disposableRegions.map(E=>U.expressionStatement(U.callExpression(U.memberExpression(U.identifier(E),U.identifier("dispose")),[]))),...u.disposableEntities.map(E=>U.expressionStatement(U.callExpression(Q(e,"unregisterSubtree"),[U.cloneNode(E)])))];g.push(U.objectProperty(U.identifier("dispose"),U.arrowFunctionExpression([],U.blockStatement(x))))}return U.arrowFunctionExpression([],U.blockStatement([ot(u),it(u),...u.creation,...u.mounts,U.returnStatement(U.objectExpression(g))]))}import*as p from"@babel/types";import*as X from"@babel/types";function gt(e,t,n,r){return X.isArrayExpression(r)?X.arrayExpression(r.elements.map(o=>{if(o===null)return null;if(X.isSpreadElement(o))throw t.buildCodeFrameError("memo-dom: ref arrays must have a static shape; nested arrays are supported but array spreads are not");return gt(e,t,n,o)})):Gs(e,n,r)?X.cloneNode(r,!0):Zs(t,r)||X.isMemberExpression(r)?Xo(e,r):X.cloneNode(r,!0)}function fr(e,t,n,r,o){let i=A(e,"refDispose");t.mounts.push(X.variableDeclaration("const",[X.variableDeclarator(X.cloneNode(i),X.callExpression(Q(e,"mountRef"),[X.cloneNode(n,!0),X.cloneNode(o,!0)]))])),t.manualDisposal?t.disposableCallbacks.push(i):t.mounts.push(X.expressionStatement(X.callExpression(Q(e,"cleanup"),[X.cloneNode(r,!0),X.cloneNode(i)])))}function Gs(e,t,n){let r=pt(e,t,n);return r!==null&&e.componentProps.get(t)?.refProps.includes(r)===!0}function Zs(e,t){if(!X.isIdentifier(t)||t.name==="undefined")return!1;let n=e.scope.getBinding(t.name);if(n===void 0||n.path.isFunctionDeclaration()||n.path.isImportSpecifier()||n.path.isImportDefaultSpecifier()||n.path.isImportNamespaceSpecifier())return!1;if(n.path.isVariableDeclarator()){if(n.path.parentPath.isVariableDeclaration({kind:"const"}))return!1;let o=n.path.node.init;if(X.isFunctionExpression(o)||X.isArrowFunctionExpression(o))return!1}return n.kind!=="param"}function Xo(e,t){let n=A(e,"refNode");if(X.isMemberExpression(t)){let r=A(e,"refTarget"),o=t.computed?A(e,"refKey"):null,i=()=>X.memberExpression(X.cloneNode(r),o===null?X.cloneNode(t.property,!0):X.cloneNode(o),t.computed);return X.arrowFunctionExpression([X.cloneNode(n)],X.blockStatement([X.variableDeclaration("const",[X.variableDeclarator(X.cloneNode(r),X.cloneNode(t.object,!0)),...o===null?[]:[X.variableDeclarator(X.cloneNode(o),X.cloneNode(t.property,!0))]]),X.expressionStatement(X.assignmentExpression("=",i(),X.cloneNode(n))),X.returnStatement(X.arrowFunctionExpression([],X.blockStatement([X.ifStatement(X.binaryExpression("===",i(),X.cloneNode(n)),X.expressionStatement(X.assignmentExpression("=",i(),X.identifier("undefined"))))])))]))}return X.arrowFunctionExpression([X.cloneNode(n)],X.blockStatement([X.expressionStatement(X.assignmentExpression("=",X.cloneNode(t,!0),X.cloneNode(n))),X.returnStatement(X.arrowFunctionExpression([],X.blockStatement([X.ifStatement(X.binaryExpression("===",X.cloneNode(t,!0),X.cloneNode(n)),X.expressionStatement(X.assignmentExpression("=",X.cloneNode(t,!0),X.identifier("undefined"))))])))]))}import*as J from"@babel/types";var Ys=new Set(["setClassValue","setStyleValue","setDomValue"]);function zt(e,t,n){if(t.mounts.length!==0||t.disposableRegions.length!==0||t.disposableEntities.length!==0||t.disposableCallbacks.length!==0)return!1;let r=[],o=new Set;for(let C of t.creation){if(!J.isVariableDeclaration(C))continue;let y=ea(C);if(y===null)return!1;r.push(y),o.add(y.name)}if(!o.has(n)||r.length<2)return!1;let i=new Map,s=new Map;for(let C of t.creation){let y=To(C);if(y===null)continue;if(!o.has(y.parent)||!o.has(y.child))return!1;let v=s.get(y.parent)??0;s.set(y.parent,v+1),i.set(y.child,{parent:y.parent,index:v})}let a=new Map;for(let C of o){let y=ta(C,n,i);if(y===null)return!1;a.set(C,y)}let l=[],d=[];for(let C of t.creation)J.isVariableDeclaration(C)||ra(C,o)?l.push(J.cloneNode(C,!0)):d.push(C);let u=A(e,`${n}Template`);e.header.push(J.variableDeclaration("let",[J.variableDeclarator(J.cloneNode(u))]));let c=J.callExpression(J.arrowFunctionExpression([],J.blockStatement([...l,J.returnStatement(J.identifier(n))])),[]),g=J.conditionalExpression(J.binaryExpression("===",J.cloneNode(u),J.unaryExpression("void",J.numericLiteral(0))),J.assignmentExpression("=",J.cloneNode(u),c),J.cloneNode(u)),x=J.callExpression(J.memberExpression(g,J.identifier("cloneNode")),[J.booleanLiteral(!0)]),E=new Set([n]);for(let C of d)Le(C,y=>{J.isIdentifier(y)&&o.has(y.name)&&E.add(y.name)});let f=[],m=r.filter(({name:C})=>E.has(C)).sort((C,y)=>a.get(C.name).length-a.get(y.name).length).map(({name:C})=>{let y=a.get(C),v;if(C===n)v=J.cloneNode(x,!0);else{let M=f[0];for(let R of f)R.path.length>M.path.length&&Qs(R.path,y)&&(M=R);v=na(M.name,y.slice(M.path.length))}return f.push({name:C,path:y}),J.variableDeclaration("const",[J.variableDeclarator(J.identifier(C),v)])});return t.creation=[...m,...d],!0}function Qs(e,t){return e.length<=t.length&&e.every((n,r)=>t[r]===n)}function ea(e){if(e.declarations.length!==1)return null;let t=e.declarations[0];if(!J.isIdentifier(t.id)||!J.isCallExpression(t.init)||!J.isMemberExpression(t.init.callee)||!J.isIdentifier(t.init.callee.object,{name:"document"})||!J.isIdentifier(t.init.callee.property))return null;let n=t.init.callee.property.name;if(n!=="createElement"&&n!=="createElementNS"&&n!=="createTextNode")return null;let r=t.init.arguments.at(-1);return(n==="createElement"||n==="createElementNS")&&J.isStringLiteral(r)&&r.value.includes("-")?null:{name:t.id.name,statement:e}}function To(e){return!J.isExpressionStatement(e)||!J.isCallExpression(e.expression)||!J.isMemberExpression(e.expression.callee)||!J.isIdentifier(e.expression.callee.object)||!J.isIdentifier(e.expression.callee.property,{name:"appendChild"})||e.expression.arguments.length!==1||!J.isIdentifier(e.expression.arguments[0])?null:{parent:e.expression.callee.object.name,child:e.expression.arguments[0].name}}function ta(e,t,n){if(e===t)return[];let r=[],o=new Set,i=e;for(;i!==t;){if(o.has(i))return null;o.add(i);let s=n.get(i);if(s===void 0)return null;r.push(s.index),i=s.parent}return r.reverse(),r}function na(e,t){let n=J.identifier(e);for(let r of t){n=J.memberExpression(n,J.identifier("firstChild"));for(let o=0;o<r;o++)n=J.memberExpression(n,J.identifier("nextSibling"))}return n}function ra(e,t){let n=To(e);if(n!==null)return t.has(n.parent)&&t.has(n.child);if(!J.isExpressionStatement(e))return!1;let r=e.expression;return!!(J.isCallExpression(r)&&J.isMemberExpression(r.callee)&&(J.isIdentifier(r.callee.object)&&t.has(r.callee.object.name)&&J.isIdentifier(r.callee.property,{name:"setAttribute"})&&r.arguments.every(o=>J.isExpression(o)&&Jn(o))||J.isIdentifier(r.callee.object)&&J.isIdentifier(r.callee.property)&&Ys.has(r.callee.property.name)&&r.arguments.length>=2&&J.isIdentifier(r.arguments[0])&&t.has(r.arguments[0].name)&&r.arguments.slice(1).every(o=>J.isExpression(o)&&Jn(o))))}function Jn(e){return J.isStringLiteral(e)||J.isNumericLiteral(e)||J.isBooleanLiteral(e)||J.isNullLiteral(e)?!0:J.isArrayExpression(e)?e.elements.every(t=>t===null||J.isExpression(t)&&Jn(t)):J.isObjectExpression(e)?e.properties.every(t=>J.isObjectProperty(t)&&!t.computed&&J.isExpression(t.value)&&Jn(t.value)):!1}function Bo(e,t,n,r,o,i,s,a,l=!1,d=Je(e,o),u){let c=Rt(e,n,i,o,t.usedPrefixes,u===void 0?void 0:{itemParam:u.itemParam,sourceKey:u.sourceKey,sourceLocal:u.sourceLocal??!1}),g=A(e,`region${t.regionCounter++}`).name,x=c.form==="callback"?ia(e,c,r):c.form==="component"?sa(e,c,r,o,i,a,l,d):aa(e,c,r,o,i,s,l,d),E=[p.identifier(r),p.binaryExpression("+",p.cloneNode(d),p.stringLiteral(`/${c.suffix}`)),x];if(c.form==="callback"){let v=p.memberExpression(p.cloneNode(c.renderCallback,!0),p.identifier("key"));E.push(p.arrowFunctionExpression([p.cloneNode(c.itemPattern,!0),...c.indexParam===null?[]:[p.identifier(c.indexParam)]],p.conditionalExpression(p.binaryExpression("==",p.cloneNode(v),p.nullLiteral()),p.cloneNode(c.itemPattern,!0),p.callExpression(p.cloneNode(v),[p.cloneNode(c.itemPattern,!0),...c.indexParam===null?[]:[p.identifier(c.indexParam)]]))))}else c.keyExpr!==null&&E.push(p.arrowFunctionExpression([p.cloneNode(c.itemPattern,!0),...c.indexParam===null?[]:[p.identifier(c.indexParam)]],p.cloneNode(c.keyExpr)));t.creation.push(p.variableDeclaration("const",[p.variableDeclarator(p.identifier(g),p.callExpression(Q(e,"createListRegion"),E))])),t.disposableRegions.push(g);let f=e.targetedListDependencies.get(n)??[],m=e.keyedListMutations.get(n);m!==void 0&&t.creation.push(p.variableDeclaration("const",[p.variableDeclarator(p.identifier(m.keysVariable),p.newExpression(p.identifier("Set"),[]))]));let C=f.map(v=>({dependency:v,cache:A(e,`${v.value}ListKey`).name}));C.length>0&&t.creation.push(p.variableDeclaration("let",C.map(({dependency:v,cache:M})=>p.variableDeclarator(p.identifier(M),p.identifier(v.value)))));let y=()=>p.expressionStatement(p.callExpression(p.memberExpression(p.identifier(g),p.identifier("reconcile")),[p.cloneNode(c.sourceExpr)]));t.creation.push(y()),C.length===0&&m===void 0||t.reasonVar===null?t.updaters.push(y):t.updaters.push(()=>oa(e,o,t.reasonVar,g,c.sourceExpr,C,m))}function Lt(e,t){let n=()=>p.identifier(e);return p.logicalExpression("||",p.binaryExpression("===",n(),p.numericLiteral(t)),p.logicalExpression("&&",p.binaryExpression("!==",n(),p.nullLiteral()),p.logicalExpression("&&",p.binaryExpression("!==",p.unaryExpression("typeof",n()),p.stringLiteral("number")),p.callExpression(p.memberExpression(n(),p.identifier("has")),[p.numericLiteral(t)]))))}function mr(e,t){return p.expressionStatement(p.callExpression(p.memberExpression(p.identifier(e),p.identifier("refreshKey")),[t]))}function oa(e,t,n,r,o,i,s){let a=e.instanceReasonIds.get(t);if(a===void 0)return p.expressionStatement(p.callExpression(p.memberExpression(p.identifier(r),p.identifier("reconcile")),[p.cloneNode(o)]));let l=s?.source??i[0]?.dependency.source,d=l===void 0?void 0:a.get(l);if(d===void 0)return p.expressionStatement(p.callExpression(p.memberExpression(p.identifier(r),p.identifier("reconcile")),[p.cloneNode(o)]));let u=[p.expressionStatement(p.callExpression(p.memberExpression(p.identifier(r),p.identifier("reconcile")),[p.cloneNode(o)])),...i.map(({dependency:x,cache:E})=>p.expressionStatement(p.assignmentExpression("=",p.identifier(E),p.identifier(x.value)))),...s===void 0?[]:[p.expressionStatement(p.callExpression(p.memberExpression(p.identifier(s.keysVariable),p.identifier("clear")),[]))]],c=[];if(s!==void 0){let x=a.get(s.targetedReason);if(x!==void 0){let E=A(e,"changedListKey");c.push(p.ifStatement(Lt(n,x),p.blockStatement([p.forOfStatement(p.variableDeclaration("const",[p.variableDeclarator(p.cloneNode(E))]),p.identifier(s.keysVariable),p.blockStatement([mr(r,p.cloneNode(E))])),p.expressionStatement(p.callExpression(p.memberExpression(p.identifier(s.keysVariable),p.identifier("clear")),[]))])))}}for(let{dependency:x,cache:E}of i){let f=a.get(x.value);if(f===void 0)continue;let m=A(e,"previousListKey");c.push(p.ifStatement(Lt(n,f),p.blockStatement([p.variableDeclaration("const",[p.variableDeclarator(m,p.identifier(E))]),p.expressionStatement(p.assignmentExpression("=",p.identifier(E),p.identifier(x.value))),mr(r,p.cloneNode(m)),p.ifStatement(p.unaryExpression("!",p.callExpression(p.memberExpression(p.identifier("Object"),p.identifier("is")),[p.cloneNode(m),p.identifier(E)])),mr(r,p.identifier(E)))])))}let g=p.binaryExpression("===",p.identifier(n),p.nullLiteral());if(s!==void 0){let x=a.get(s.structuralReason),E=a.get(s.targetedReason);x!==void 0&&(g=p.logicalExpression("||",g,Lt(n,x))),g=p.logicalExpression("||",g,E===void 0?Lt(n,d):p.logicalExpression("&&",Lt(n,d),p.unaryExpression("!",Lt(n,E))))}else g=p.logicalExpression("||",g,Lt(n,d));return p.ifStatement(g,p.blockStatement(u),c.length===0?void 0:p.blockStatement(c))}function ia(e,t,n){let r=A(e,"renderRowId");return p.arrowFunctionExpression([p.cloneNode(t.itemPattern,!0),p.cloneNode(r),...t.indexParam===null?[]:[p.identifier(t.indexParam)]],p.callExpression(p.memberExpression(p.cloneNode(t.renderCallback,!0),p.identifier("create")),[p.cloneNode(t.itemPattern,!0),p.cloneNode(r),...t.indexParam===null?[]:[p.identifier(t.indexParam)],p.identifier(n)]))}function sa(e,t,n,r,o,i,s=!1,a=Je(e,r)){let l=t.rowComp,d=A(e,"rowId"),u=A(e,"nextItem"),c=t.indexParam===null?null:A(e,"nextIndex"),g=A(e,"refreshRow"),x=rt(e),E=$t(e,l),f=e.importedComponents.get(l)?.delegatedEvents===!0||e.componentsWithHostEvents.has(l),m={itemParam:t.itemParam,itemPath:[],rowIdVar:d.name,refreshVar:g.name,keyPath:nt(t.keyExpr,t.itemParam),sourceKey:t.sourceKey,sourceLocal:t.sourceLocal,...t.sourceLocal&&p.isIdentifier(a)?{ownerIdVar:a.name}:{}},C=t.jsx.openingElement.attributes.filter(V=>p.isJSXSpreadAttribute(V)||$e(V.name)!=="key"),y=C.some(V=>p.isJSXSpreadAttribute(V)),v=[],M=[],R=null,I=e.componentProps.get(l),H=V=>{let le=p.isJSXElement(V)||p.isJSXFragment(V)?[V]:[p.jsxExpressionContainer(V)];return i(e,x,le,r,o,"row",m,d,s,d)};if(y){R=Qt(C,{attributeValue:(V,le)=>V==="ref"||I?.refProps.includes(V)===!0?gt(e,o,r,le):le,fail:V=>{throw o.buildCodeFrameError(V)}}).expression;for(let V of R.properties){if(!p.isObjectProperty(V)||V.computed||!p.isExpression(V.value))continue;let le=p.isIdentifier(V.key)?V.key.name:p.isStringLiteral(V.key)?V.key.value:null;if(le!==null)if(I?.renderProps.includes(le)===!0){if(st(e,r,V.value))continue;if(!de(V.value))throw o.buildCodeFrameError(`memo-dom: render prop '${le}' on <${l}> must be JSX, a JSX-bearing conditional/list, or a forwarded render prop`);V.value=H(V.value)}else{if(de(V.value))throw o.buildCodeFrameError(`memo-dom: JSX prop '${le}' on <${l}> is not rendered by the callee; interpolate that prop in <${l}> to declare a render slot`);le!=="ref"&&I?.refProps.includes(le)!==!0&&Wt(V.value)&&(at(e,o,V.value,r,m,!0),V.value=ur(e,M,V.value,`${le}Callback`))}}}else for(let V of C){let le=V,Te=$e(le.name),we=le.value==null?p.booleanLiteral(!0):Be(le.value);if(we===null)throw o.buildCodeFrameError(`memo-dom: prop '${$e(le.name)}' on <${l}> must be an expression`);if(I?.renderProps.includes(Te)===!0){if(st(e,r,we)){v.push({name:Te,value:p.cloneNode(we)});continue}if(!de(we))throw o.buildCodeFrameError(`memo-dom: render prop '${Te}' on <${l}> must be JSX, a JSX-bearing conditional/list, or a forwarded render prop`);v.push({name:Te,value:H(we)});continue}if(Te==="ref"||I?.refProps.includes(Te)===!0){v.push({name:Te,value:gt(e,o,r,we)});continue}if(de(we))throw o.buildCodeFrameError(`memo-dom: JSX prop '${Te}' on <${l}> is not rendered by the callee; interpolate that prop in <${l}> to declare a render slot`);let S=Wt(we);if(S)at(e,o,we,r,m,!0);else if(p.isIdentifier(we)){let w=mt(o,we.name);w!==null&&!de(w.body)&&at(e,o,w,r,m,!0)}v.push({name:Te,value:S?ur(e,M,we,`${Te}Callback`):p.cloneNode(we)})}if(qt(t.jsx.children)){if(C.some(le=>p.isJSXAttribute(le)&&$e(le.name)==="children"))throw o.buildCodeFrameError(`memo-dom: <${l}> cannot use both a children prop and nested JSX children`);let V=i(e,x,t.jsx.children,r,o,"row",m,d,s,d);R!==null?R.properties.push(p.objectProperty(p.identifier("children"),p.cloneNode(V))):v.push({name:"children",value:p.cloneNode(V)})}let O;if(R!==null){let V=A(e,`${l}Props`);M.push(p.variableDeclaration("const",[p.variableDeclarator(p.cloneNode(V),p.cloneNode(R))])),O=Vt(e,l,V)}else O=jn(e,l,v);let _=[p.expressionStatement(p.assignmentExpression("=",p.cloneNode(t.itemPattern,!0),p.cloneNode(u)))];c!==null&&t.indexParam!==null&&_.push(p.expressionStatement(p.assignmentExpression("=",p.identifier(t.indexParam),p.cloneNode(c))));let Y=O.map(V=>p.cloneNode(V));if(R!==null){let V=A(e,`next${l}Props`);_.push(p.variableDeclaration("const",[p.variableDeclarator(p.cloneNode(V),p.cloneNode(R))])),Y=Vt(e,l,V)}let Z=A(e,E?"entry":"rowElement"),ne=O.length>0||x.updaters.length>0,xe=E&&ne,be=xe?A(e,"pushRowProps"):null;E?_.push(p.expressionStatement(p.callExpression(be===null?p.memberExpression(p.cloneNode(Z),p.identifier("updateProps")):p.cloneNode(be),Y))):_.push(p.expressionStatement(p.callExpression(Q(e,"setProps"),[p.cloneNode(d),p.arrayExpression(Y)])),p.expressionStatement(p.callExpression(Q(e,"markDirty"),[p.cloneNode(d)]))),x.updaters.length>0&&_.push(p.expressionStatement(p.callExpression(p.identifier(x.updateVar),[])));let ie=E?[p.objectProperty(p.identifier("nodes"),p.memberExpression(p.cloneNode(Z),p.identifier("nodes"))),p.objectProperty(p.identifier("entities"),p.arrayExpression([])),p.objectProperty(p.identifier("update"),p.memberExpression(p.cloneNode(Z),p.identifier("update"))),p.objectProperty(p.identifier("dispose"),p.memberExpression(p.cloneNode(Z),p.identifier("dispose")))]:[p.objectProperty(p.identifier("nodes"),p.callExpression(Q(e,"rootNodes"),[p.cloneNode(Z)])),p.objectProperty(p.identifier("entities"),p.arrayExpression([p.cloneNode(d)]))];return ne&&!xe&&ie.push(p.objectProperty(p.identifier("updateProps"),p.arrowFunctionExpression([p.cloneNode(u),...c===null?[]:[p.cloneNode(c)]],p.blockStatement(_)))),p.arrowFunctionExpression([p.cloneNode(t.itemPattern,!0),p.cloneNode(d),...t.indexParam===null?[]:[p.identifier(t.indexParam)]],p.blockStatement([...x.updaters.length>0?[ot(x),it(x)]:[],...x.creation,...x.mounts,...M,p.variableDeclaration("const",[p.variableDeclarator(p.cloneNode(Z),E?p.callExpression(p.identifier(l),[...O.map(V=>p.cloneNode(V)),p.cloneNode(d),...t.sourceLocal?[p.cloneNode(a)]:[],...f?[p.identifier(n)]:[]]):p.callExpression(p.identifier(l),[p.cloneNode(d),p.cloneNode(a),...O.length>0?[p.arrayExpression(O)]:[]]))]),...x.updaters.length>0?[p.variableDeclaration("const",[p.variableDeclarator(p.cloneNode(g),p.arrowFunctionExpression([],p.blockStatement([p.expressionStatement(E?p.callExpression(p.memberExpression(p.cloneNode(Z),p.identifier("update")),[]):p.callExpression(Q(e,"markDirty"),[p.cloneNode(d)])),p.expressionStatement(p.callExpression(p.identifier(x.updateVar),[]))])))])]:[],...be===null?[]:[p.variableDeclaration("const",[p.variableDeclarator(p.cloneNode(be),p.memberExpression(p.cloneNode(Z),p.identifier("updateProps")))]),p.expressionStatement(p.assignmentExpression("=",p.memberExpression(p.cloneNode(Z),p.identifier("updateProps")),p.arrowFunctionExpression([p.cloneNode(u),...c===null?[]:[p.cloneNode(c)]],p.blockStatement(_))))],p.returnStatement(xe?p.cloneNode(Z):p.objectExpression(ie))]))}function aa(e,t,n,r,o,i,s=!1,a=Je(e,r)){t.jsx.openingElement.attributes=t.jsx.openingElement.attributes.filter(f=>p.isJSXSpreadAttribute(f)||f.name.name!=="key");let l=rt(e);l.delegatedEventRootVar=n;let d=A(e,"rowId").name,u=A(e,"nextItem"),c=t.indexParam===null?null:A(e,"nextIndex"),g={itemParam:t.itemParam,itemPath:[],rowIdVar:d,keyPath:nt(t.keyExpr,t.itemParam),sourceKey:t.sourceKey,sourceLocal:t.sourceLocal,...t.sourceLocal?{ownerIdVar:p.isIdentifier(a)?a.name:Je(e,r).name}:{}},x=i(e,l,t.jsx,r,o,"row",g,p.identifier(d),s,p.identifier(d));zt(e,l,x);let E=[p.expressionStatement(p.assignmentExpression("=",p.cloneNode(t.itemPattern,!0),p.cloneNode(u)))];return c!==null&&t.indexParam!==null&&E.push(p.expressionStatement(p.assignmentExpression("=",p.identifier(t.indexParam),p.cloneNode(c)))),p.arrowFunctionExpression([p.cloneNode(t.itemPattern,!0),p.identifier(d),...t.indexParam===null?[]:[p.identifier(t.indexParam)]],p.blockStatement([ot(l),it(l),yt(e,p.identifier(d),p.cloneNode(a),p.identifier(l.updateVar)),...l.creation,...l.mounts,p.returnStatement(p.objectExpression([p.objectProperty(p.identifier("nodes"),p.arrayExpression([p.identifier(x)])),p.objectProperty(p.identifier("entities"),p.arrayExpression([p.identifier(d)])),p.objectProperty(p.identifier("updateProps"),p.arrowFunctionExpression([p.cloneNode(u),...c===null?[]:[p.cloneNode(c)]],p.blockStatement(E))),p.objectProperty(p.identifier("update"),p.identifier(l.updateVar))]))]))}import*as N from"@babel/types";function la(e){return N.isJSXElement(e.body)?e.body:N.isBlockStatement(e.body)&&e.body.body.length===1&&N.isReturnStatement(e.body.body[0])&&N.isJSXElement(e.body.body[0].argument)?e.body.body[0].argument:null}function gr(e,t,n,r,o,i,s,a){if(!N.isArrowFunctionExpression(n)&&!N.isFunctionExpression(n)||n.async||n.generator)throw o.buildCodeFrameError("memo-dom: render callbacks must be synchronous inline arrows or function expressions");let l=la(n),d=n.params[0],u=n.params[1];if(l===null||n.params.length<1||n.params.length>2||!N.isIdentifier(d)&&!N.isObjectPattern(d)&&!N.isArrayPattern(d)||u!==void 0&&!N.isIdentifier(u))throw o.buildCodeFrameError("memo-dom: render callbacks take an item binding pattern and optional index, then return one JSX element");let c=cn(d),g=Object.keys(N.getBindingIdentifiers(c));if(g.length===0)throw o.buildCodeFrameError("memo-dom: render callback item patterns must bind at least one name");let x=N.isIdentifier(c)?c.name:g[0],E=u===void 0?null:u.name,f=null;l.openingElement.attributes=l.openingElement.attributes.filter(be=>{if(N.isJSXSpreadAttribute(be)||!N.isJSXIdentifier(be.name)||be.name.name!=="key")return!0;if(f=Be(be.value),f===null)throw o.buildCodeFrameError("memo-dom: key={...} needs an expression");return!1});let m=A(e,"renderCallback"),C=A(e,"renderRows"),y=A(e,"renderNextUpdate"),v=A(e,"renderRowId"),M=A(e,"renderEventRoot"),R=A(e,"refreshRenderRow"),I=A(e,"renderNextItem"),H=E===null?null:A(e,"renderNextIndex"),O=rt(e);O.delegatedEventRootVar=M.name;let _={itemParam:x,itemPath:[],rowIdVar:v.name,keyPath:nt(f,x),sourceKey:"$render-callback",sourceLocal:!0,...N.isIdentifier(a)?{ownerIdVar:a.name}:{}},Y=i(e,O,l,r,o,"row",_,v,s,v);zt(e,O,Y),t.creation.push(N.variableDeclaration("const",[N.variableDeclarator(N.cloneNode(C),N.newExpression(N.identifier("Set"),[]))])),t.updaters.push(()=>N.forOfStatement(N.variableDeclaration("const",[N.variableDeclarator(N.cloneNode(y))]),N.cloneNode(C),N.expressionStatement(N.callExpression(N.cloneNode(y),[]))));let Z=[N.expressionStatement(N.assignmentExpression("=",N.cloneNode(c,!0),N.cloneNode(I)))];H!==null&&E!==null&&Z.push(N.expressionStatement(N.assignmentExpression("=",N.identifier(E),N.cloneNode(H))));let ne=N.arrowFunctionExpression([N.cloneNode(c,!0),N.cloneNode(v),...E===null?[]:[N.identifier(E)],N.cloneNode(M)],N.blockStatement([ot(O),it(O),N.variableDeclaration("const",[N.variableDeclarator(N.cloneNode(R),N.arrowFunctionExpression([],N.blockStatement([N.expressionStatement(N.callExpression(N.identifier(O.updateVar),[])),N.expressionStatement(N.callExpression(Q(e,"renderDescendants"),[N.cloneNode(v)]))])))]),yt(e,N.cloneNode(v),N.cloneNode(a,!0),N.cloneNode(R)),...O.creation,...O.mounts,N.expressionStatement(N.callExpression(N.memberExpression(N.cloneNode(C),N.identifier("add")),[N.cloneNode(R)])),N.returnStatement(N.objectExpression([N.objectProperty(N.identifier("nodes"),N.callExpression(Q(e,"rootNodes"),[N.identifier(Y)])),N.objectProperty(N.identifier("entities"),N.arrayExpression([N.cloneNode(v)])),N.objectProperty(N.identifier("updateProps"),N.arrowFunctionExpression([N.cloneNode(I),...H===null?[]:[N.cloneNode(H)]],N.blockStatement(Z))),N.objectProperty(N.identifier("update"),N.cloneNode(R)),N.objectProperty(N.identifier("dispose"),N.arrowFunctionExpression([],N.callExpression(N.memberExpression(N.cloneNode(C),N.identifier("delete")),[N.cloneNode(R)])))]))])),xe=f===null?N.nullLiteral():N.arrowFunctionExpression([N.cloneNode(c,!0),...E===null?[]:[N.identifier(E)]],N.cloneNode(f));return t.creation.push(N.variableDeclaration("const",[N.variableDeclarator(N.cloneNode(m),N.objectExpression([N.objectProperty(N.identifier("create"),ne),N.objectProperty(N.identifier("key"),xe)]))])),m}function da(e){return h.conditionalExpression(h.logicalExpression("||",h.binaryExpression("==",h.cloneNode(e),h.nullLiteral()),h.binaryExpression("===",h.unaryExpression("typeof",h.cloneNode(e),!0),h.stringLiteral("boolean"))),h.stringLiteral(""),h.callExpression(h.identifier("String"),[h.cloneNode(e)]))}function ca(e,t,n,r){return()=>Ft(e,t,h.cloneNode(r),o=>h.expressionStatement(h.assignmentExpression("=",h.memberExpression(h.identifier(n),h.identifier("data")),da(o))))}function br(e,t,n){let r=A(e,`text${t.textCounter++}`).name;if(h.isStringLiteral(n))return t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.identifier(r),h.callExpression(h.memberExpression(h.identifier("document"),h.identifier("createTextNode")),[h.stringLiteral(n.value)]))])),r;let o=Bn(e,t);t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.identifier(r),h.callExpression(h.memberExpression(h.identifier("document"),h.identifier("createTextNode")),[h.stringLiteral("")]))]));let i=ca(t,o,r,n);return t.creation.push(i()),t.updaters.push(i),r}function Vo(e,t){let n=!1;return h.traverseFast(e,r=>{h.isIdentifier(r,{name:t})&&(n=!0)}),n}function ut(e,t,n,r,o,i=null,s,a,l=!1,d=Je(e,r)){return h.isJSXFragment(n)?ua(e,t,n,r,o,i,s,a,l,d):pa(e,t,n,r,o,i,s,a,l,d)}function ua(e,t,n,r,o,i,s,a,l=!1,d=Je(e,r)){let u=sr(n.children,{emitText:g=>br(e,t,g),emitNode:g=>ut(e,t,g,r,o,i,s,a,l,d),isForwarded:g=>st(e,r,g),fail:g=>{throw o.buildCodeFrameError(g)}}),c=Vn(e,t,"fragment");return t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.identifier(c),h.callExpression(h.memberExpression(h.identifier("document"),h.identifier("createDocumentFragment")),[]))])),zo(e,t,u,c,r,o,i,s,l,d),c}function zo(e,t,n,r,o,i,s=null,a,l=!1,d=Je(e,o)){for(let u of n)u.type==="node"?t.creation.push(h.expressionStatement(h.callExpression(h.memberExpression(h.identifier(r),h.identifier("appendChild")),[h.identifier(u.variable)]))):u.type==="slot"?zn(e,t,u.expression,r,d):u.type==="list"?Ko(e,t,u.expression,r,o,i,l,d,a):Uo(e,t,u.expression,r,o,i,l,d,s!==null)}function hr(e,t,n,r,o,i,s,a,l,d){return Dr(e,t,d,(u,c,g)=>{Lr(u,n,c.name,{emitText:x=>br(e,u,x),emitNode:x=>ut(e,u,x,r,o,i,s,a,l,g),emitList:(x,E)=>Ko(e,u,x,E,r,o,l,g,s),emitCondition:(x,E)=>Uo(e,u,x,E,r,o,l,g,i!==null),isForwarded:x=>st(e,r,x),emitForwarded:(x,E)=>zn(e,u,x,E,g),fail:x=>{throw o.buildCodeFrameError(x)}})})}function Wo(e,t,n,r,o,i,s,a,l,d){let u=h.isJSXElement(n)||h.isJSXFragment(n)?[n]:[h.jsxExpressionContainer(n)];return hr(e,t,u,r,o,i,s,a,l,d)}function pa(e,t,n,r,o,i=null,s,a,l=!1,d=Je(e,r)){let u=n.openingElement,c=u.name.name;if(/^[A-Z]/.test(c)){let y=t.childCounts.get(c)??0;t.childCounts.set(c,y+1);let v=c.charAt(0).toLowerCase()+c.slice(1),M=y===0?v:`${v}${y}`,R=A(e,M).name,I=y===0?`/${c}`:`/${c}[${y}]`,H=[],O=e.componentProps.get(c);if(qt(n.children)&&u.attributes.some(be=>h.isJSXAttribute(be)&&$e(be.name)==="children"))throw o.buildCodeFrameError(`memo-dom: <${c}> cannot use both a children prop and nested JSX children`);let _=u.attributes.some(be=>h.isJSXSpreadAttribute(be)),Y=null,Z=!1;if(_){Y=Qt(u.attributes,{attributeValue:(ie,V)=>ie==="ref"||O?.refProps.includes(ie)===!0?gt(e,o,r,V):V,fail:ie=>{throw o.buildCodeFrameError(ie)}}).expression;for(let ie of Y.properties){if(!h.isObjectProperty(ie)||ie.computed||!h.isExpression(ie.value))continue;let V=h.isIdentifier(ie.key)?ie.key.name:h.isStringLiteral(ie.key)?ie.key.value:null;if(V!==null)if(O?.renderCallbacks.includes(V)===!0)ie.value=gr(e,t,ie.value,r,o,ut,l,d);else if(O?.renderProps.includes(V)===!0){if(st(e,r,ie.value))continue;if(!de(ie.value))throw o.buildCodeFrameError(`memo-dom: render prop '${V}' on <${c}> must be JSX, a JSX-bearing conditional/list, or a forwarded render prop`);ie.value=Wo(e,t,ie.value,r,o,i,s,a,l,d)}else{if(de(ie.value))throw o.buildCodeFrameError(`memo-dom: JSX prop '${V}' on <${c}> is not rendered by the callee; interpolate that prop in <${c}> to declare a render slot`);V!=="ref"&&O?.refProps.includes(V)!==!0&&Wt(ie.value)&&(at(e,o,ie.value,r,s,!0),ie.value=cr(e,t,ie.value,`${V}Callback`))}}Z=Xn(e,Y,r)||s!==void 0&&Vo(Y,s.itemParam)}else for(let be of u.attributes){let ie=be,V=$e(ie.name),le=ie.value==null?h.booleanLiteral(!0):Be(ie.value);if(le==null)throw o.buildCodeFrameError(`memo-dom: prop '${$e(ie.name)}' on <${c}> must be an expression`);if(O?.renderCallbacks.includes(V)===!0){H.push({name:V,value:gr(e,t,le,r,o,ut,l,d)});continue}if(V==="ref"||O?.refProps.includes(V)===!0){H.push({name:V,value:gt(e,o,r,le)});continue}if(O?.renderProps.includes(V)===!0){if(st(e,r,le)){H.push({name:V,value:h.cloneNode(le)});continue}if(!de(le))throw o.buildCodeFrameError(`memo-dom: render prop '${V}' on <${c}> must be JSX, a JSX-bearing conditional/list, or a forwarded render prop`);H.push({name:V,value:Wo(e,t,le,r,o,i,s,a,l,d)});continue}if(de(le))throw o.buildCodeFrameError(`memo-dom: JSX prop '${V}' on <${c}> is not rendered by the callee; interpolate that prop in <${c}> to declare a render slot`);let Te=Wt(le);if(!Te&&(Xn(e,le,r)||s!==void 0&&Vo(le,s.itemParam))&&(Z=!0),Te)at(e,o,le,r,s,!0);else if(h.isIdentifier(le)){let we=mt(o,le.name);we!==null&&!de(we.body)&&at(e,o,we,r,s,!0)}H.push({name:V,value:Te?cr(e,t,le,`${V}Callback`):h.cloneNode(le)})}if(qt(n.children)){if(u.attributes.some(ie=>h.isJSXAttribute(ie)&&$e(ie.name)==="children"))throw o.buildCodeFrameError(`memo-dom: <${c}> cannot use both a children prop and nested JSX children`);let be=hr(e,t,n.children,r,o,i,s,a,l,d);Y!==null?Y.properties.push(h.objectProperty(h.identifier("children"),h.cloneNode(be))):H.push({name:"children",value:h.cloneNode(be)})}let ne;if(Y!==null){let be=A(e,`${v}Props`);t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.cloneNode(be),h.cloneNode(Y))])),ne=Vt(e,c,be)}else ne=jn(e,c,H);let xe=h.binaryExpression("+",h.cloneNode(d),h.stringLiteral(I));return t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.identifier(R),h.callExpression(h.identifier(c),[xe,h.cloneNode(d),...ne.length>0?[h.arrayExpression(ne)]:[]]))])),t.disposableEntities.push(h.cloneNode(xe)),Z&&t.updaters.push(()=>Y===null?h.expressionStatement(h.callExpression(Q(e,"setProps"),[h.binaryExpression("+",h.cloneNode(d),h.stringLiteral(I)),h.arrayExpression(ne.map(be=>h.cloneNode(be)))])):$o(e,c,d,I,Y)),R}let g=jo(c,l),x=g&&c!=="foreignObject";if(u.attributes.find(y=>h.isJSXAttribute(y)&&$e(y.name)==="innerHTML")!==void 0){if(g)throw o.buildCodeFrameError("memo-dom: innerHTML is only supported on HTML elements");if(n.children.some(v=>!h.isJSXText(v)||v.value.trim()!==""))throw o.buildCodeFrameError("memo-dom: an element using innerHTML cannot also have JSX children")}let f=sr(n.children,{emitText:y=>br(e,t,y),emitNode:y=>ut(e,t,y,r,o,i,s,a,x,d),isForwarded:y=>st(e,r,y),fail:y=>{throw o.buildCodeFrameError(y)}}),m=Vn(e,t,c);if(t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.identifier(m),Jo(c,g))])),u.attributes.some(y=>h.isJSXSpreadAttribute(y))){let y=Qt(u.attributes,{attributeValue:(R,I)=>R==="ref"?gt(e,o,r,I):I,eventValue:(R,I)=>{let H=ir(e,o,I,R,r,s,a),O=A(e,`${R}Handler`);return t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.cloneNode(O),H)])),O},fail:R=>{throw o.buildCodeFrameError(R)}}),v=A(e,`${c}Props`);t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.cloneNode(v),h.cloneNode(y.expression))]));let M=R=>h.expressionStatement(h.callExpression(Q(e,"patchDomProps"),[h.identifier(m),h.cloneNode(R),h.stringLiteral(e.rootId),h.arrayExpression(y.safeEventKeys.map(I=>h.stringLiteral(I)))]));t.creation.push(M(v)),fr(e,t,h.identifier(m),d,h.memberExpression(h.cloneNode(v),h.identifier("ref"))),t.updaters.push(()=>M(y.expression))}else for(let y of u.attributes){let v=y,M=$e(v.name);if(M==="ref"){let Y=Be(v.value);if(Y===null)throw o.buildCodeFrameError("memo-dom: ref needs an expression");fr(e,t,h.identifier(m),d,gt(e,o,r,Y));continue}if(M==="key")throw o.buildCodeFrameError("memo-dom: key={...} is only meaningful on list rows: items.map(item => <Row key={item.id} />)");if(/^on[A-Z]/.test(M)){let Y=Be(v.value);if(Y==null)throw o.buildCodeFrameError(`memo-dom: ${M} needs a handler expression (L1)`);let Z=ir(e,o,Y,M,r,s,a);t.creation.push(t.delegatedEventRootVar===null?h.expressionStatement(h.assignmentExpression("=",h.memberExpression(h.identifier(m),h.identifier(M.toLowerCase())),Z)):h.expressionStatement(h.callExpression(Q(e,"setDelegatedEvent"),[h.identifier(t.delegatedEventRootVar),h.identifier(m),h.stringLiteral(M),Z])));continue}if(h.isStringLiteral(v.value)){M==="class"||M==="className"?t.creation.push(h.expressionStatement(h.callExpression(Q(e,"setClassValue"),[h.identifier(m),h.stringLiteral(v.value.value)]))):M==="style"?t.creation.push(h.expressionStatement(h.callExpression(Q(e,"setStyleValue"),[h.identifier(m),h.stringLiteral(v.value.value)]))):ar(M,g)!==null?t.creation.push(dr(m,M,h.stringLiteral(v.value.value))):lr(M,g)?t.creation.push(An(m,M,h.stringLiteral(v.value.value))):g?t.creation.push(h.expressionStatement(h.callExpression(Q(e,"setDomValue"),[h.identifier(m),h.stringLiteral(M),h.stringLiteral(v.value.value)]))):t.creation.push(h.expressionStatement(h.callExpression(h.memberExpression(h.identifier(m),h.identifier("setAttribute")),[h.stringLiteral(M),h.stringLiteral(v.value.value)])));continue}let R=v.value==null?h.booleanLiteral(!0):Be(v.value);if(R==null||h.isStringLiteral(R))throw o.buildCodeFrameError(`memo-dom: attribute '${M}' needs a string or an expression (L1)`);let I=h.cloneNode(R);if(M==="style"){let Y=()=>h.expressionStatement(h.callExpression(Q(e,"setStyleValue"),[h.identifier(m),h.cloneNode(I)]));t.creation.push(Y()),t.updaters.push(Y);continue}let H=Bn(e,t),O=ar(M,g),_=()=>M==="class"||M==="className"?Ft(t,H,h.callExpression(Q(e,"classValue"),[h.cloneNode(I)]),Y=>h.expressionStatement(h.callExpression(Q(e,"setClassValue"),[h.identifier(m),Y]))):O!==null?Ft(t,H,h.cloneNode(I),Y=>dr(m,O,Y)):lr(M,g)?Ft(t,H,h.cloneNode(I),Y=>An(m,M,Y)):g?Ft(t,H,h.cloneNode(I),Y=>h.expressionStatement(h.callExpression(Q(e,"setDomValue"),[h.identifier(m),h.stringLiteral(M),Y]))):Ft(t,H,h.cloneNode(I),Y=>An(m,M,Y));t.creation.push(_()),t.updaters.push(_)}return zo(e,t,f,m,r,o,i,s,x,d),m}function Ko(e,t,n,r,o,i,s=!1,a=Je(e,o),l){Bo(e,t,n,r,o,i,ut,hr,s,a,l)}function Uo(e,t,n,r,o,i,s=!1,a=Je(e,o),l=!1){Oo(e,t,n,r,o,i,ut,s,a,l)}function Ho(e,t,n,r,o,i=!1,s=o,a=!1,l){return pr(e,t,n,r,o,ut,i,s,a,l)}import*as Me from"@babel/types";function Go(e){if(e.isFunctionDeclaration())return e.node;if(!e.isVariableDeclarator())return null;let t=e.node.init;return t&&(Me.isArrowFunctionExpression(t)||Me.isFunctionExpression(t))?t:null}function Zo(e,t,n,r,o,i=!1){let s=mt(t,n);if(s!==null){at(e,t,s,r,o,i);return}let a=t.scope.getBinding(n);if(a===void 0||a.scope.path.isProgram()!==!0||!e.helpers.has(n))return;let l=Go(a.path);l!==null&&nn(e,l,i)}function _o(e,t,n,r,o,i=!1){if(Me.isArrowFunctionExpression(n)||Me.isFunctionExpression(n)){if(de(n.body))return;at(e,t,n,r,o,i)}else Me.isIdentifier(n)&&Zo(e,t,n.name,r,o,i)}function Yo(e,t,n,r=!1){let o=t.scope.getBinding(n);if(o===void 0||o.scope.path.isProgram()!==!0||!e.helpers.has(n))return;let i=Go(o.path);i!==null&&nn(e,i,r)}function qo(e,t,n,r=!1){if(Me.isArrowFunctionExpression(n)||Me.isFunctionExpression(n)){if(de(n.body))return;nn(e,n,r)}else Me.isIdentifier(n)&&Yo(e,t,n.name,r)}function Qo(e,t,n,r,o){t.traverse({CallExpression(i){let s=i.getFunctionParent()===t,a=i.node.callee,l=Me.isIdentifier(a,{name:"effect"})&&i.scope.getBinding("effect")===void 0;if(Me.isIdentifier(a,{name:"cleanup"})&&i.scope.getBinding("cleanup")===void 0){if(!s)throw i.buildCodeFrameError("memo-dom: cleanup(disposer) must run directly during component factory initialization");let d=i.node.arguments[0];if(i.node.arguments.length!==1||d===void 0||!Me.isExpression(d))throw i.buildCodeFrameError("memo-dom: cleanup(disposer) requires exactly one disposer expression");i.node.callee=Q(e,"cleanup"),i.node.arguments.unshift(Me.identifier(r))}if(s){Me.isIdentifier(a)&&Zo(e,t,a.name,n,o);for(let d of i.node.arguments)_o(e,t,d,n,o,l)}},NewExpression(i){if(i.getFunctionParent()===t)for(let s of i.node.arguments)_o(e,t,s,n,o)}})}function ei(e,t){t.traverse({CallExpression(n){if(n.getFunctionParent()!==null)return;let r=Me.isIdentifier(n.node.callee,{name:"effect"})&&n.scope.getBinding("effect")===void 0;Me.isIdentifier(n.node.callee)&&Yo(e,t,n.node.callee.name);for(let o of n.node.arguments)qo(e,t,o,r)},NewExpression(n){if(n.getFunctionParent()===null)for(let r of n.node.arguments)qo(e,t,r)}})}function ti(e){for(let t of e.helpers.values())t.node.async&&nn(e,t.node)}function ni(e){e.traverse({CallExpression(t){if(Me.isIdentifier(t.node.callee,{name:"cleanup"})&&t.scope.getBinding("cleanup")===void 0)throw t.buildCodeFrameError("memo-dom: cleanup(disposer) is only valid directly inside a component factory")}})}import*as ze from"@babel/types";import*as ke from"@babel/types";function ri(e){return e.reduce((t,n)=>ke.logicalExpression("||",t,n))}function oi(e,t){let n=()=>ke.identifier(e),r=ri(t.map(i=>ke.binaryExpression("===",n(),ke.numericLiteral(i)))),o=ri(t.map(i=>ke.callExpression(ke.memberExpression(n(),ke.identifier("has")),[ke.numericLiteral(i)])));return ke.logicalExpression("||",ke.binaryExpression("===",n(),ke.nullLiteral()),ke.conditionalExpression(ke.binaryExpression("===",ke.unaryExpression("typeof",n()),ke.stringLiteral("number")),r,o))}function ii(e,t,n,r,o,i){let s=new Map(r.map((c,g)=>[c,g])),a=0,l=[...o.map(c=>({order:s.get(c.declaration)??Number.MAX_SAFE_INTEGER,sequence:a++,sources:c.sources,statement:vr(c)})),...i.map(c=>({order:s.get(c.statement)??Number.MAX_SAFE_INTEGER,sequence:a++,sources:c.sources,statement:ze.blockStatement([...c.resets.map(g=>ze.expressionStatement(ze.assignmentExpression("=",ze.identifier(g.binding),ze.cloneNode(g.source,!0)))),ze.cloneNode(c.statement,!0)])}))].sort((c,g)=>c.order-g.order||c.sequence-g.sequence),d=e.instanceReasonIds.get(t),u=[];for(let c of l){let g=n===null||d===void 0?null:c.sources.map(C=>d.get(C)).filter(C=>C!==void 0).sort((C,y)=>C-y),x=g===null||g.length===c.sources.length?g:null,E=x?.join(" ")??"*",f=u.at(-1),m=f?.reasons?.join(" ")??"*";f!==void 0&&m===E?f.statements.push(c.statement):u.push({reasons:x,statements:[c.statement]})}return ze.blockStatement(u.map(c=>c.reasons===null||n===null?ze.blockStatement(c.statements):ze.ifStatement(oi(n,c.reasons),ze.blockStatement(c.statements))))}import*as W from"@babel/types";function rn(e){return!W.isReturnStatement(e)||!W.isJSXElement(e.argument)&&!W.isJSXFragment(e.argument)?null:{jsx:e.argument,statement:e}}function Er(e){return W.isBlockStatement(e)?e.body.length===1?rn(e.body[0]):null:rn(e)}function fa(e){let t=[];return e.get("body").traverse({ReturnStatement(n){t.push(n.node)},Function(n){n.skip()}}),t}function ma(e){if(W.isFunctionDeclaration(e))return!0;if(W.isVariableDeclaration(e))return e.declarations.every(t=>t.init==null||W.isFunction(t.init)||ga(t.init));if(W.isSwitchStatement(e)||W.isIfStatement(e)){let t=!0;return W.traverseFast(e,n=>{(W.isCallExpression(n)||W.isOptionalCallExpression(n)||W.isNewExpression(n)||W.isAwaitExpression(n)||W.isYieldExpression(n)||W.isThrowStatement(n)||W.isTaggedTemplateExpression(n)||W.isUpdateExpression(n))&&(t=!1)}),t}return W.isTypeScript(e)}function ga(e){let t=!0;return W.traverseFast(e,n=>{(W.isCallExpression(n)||W.isOptionalCallExpression(n)||W.isNewExpression(n)||W.isAwaitExpression(n)||W.isYieldExpression(n)||W.isTaggedTemplateExpression(n)||W.isAssignmentExpression(n)||W.isUpdateExpression(n))&&(t=!1)}),t}function ba(e){if(!e.cases.some(r=>r.test==null))return null;let t=[],n=[];for(let r of e.cases){if(r.consequent.length!==1)return null;let o=rn(r.consequent[0]);if(o===null)return null;let i=t.length;t.push(o.jsx),n.push(W.switchCase(r.test===null?null:W.cloneNode(r.test),[W.returnStatement(W.numericLiteral(i))]))}return{pick:W.arrowFunctionExpression([],W.blockStatement([W.switchStatement(W.cloneNode(e.discriminant),n)])),branches:t,statements:new Set([e])}}function si(e,t){let n=e.node.body.body,r=fa(e),o=n.at(-1);if(r.length===1&&o!==void 0){let s=rn(o);if(s!==null)return s}if(o&&W.isIfStatement(o)&&o.alternate!=null){let s=o.alternate,a=Er(o.consequent),l=Er(s);if(a!==null&&l!==null&&r.length===2)return{pick:W.arrowFunctionExpression([],W.conditionalExpression(W.cloneNode(o.test),W.numericLiteral(0),W.numericLiteral(1))),branches:[a.jsx,l.jsx],statements:new Set([o])}}if(o&&W.isSwitchStatement(o)){let s=ba(o);if(s!==null&&s.branches.length===r.length)return s}let i=o===void 0?null:rn(o);if(i!==null){let s=[],a=[],l=new Set([o]),d=-1,u=!0;for(let c=0;c<n.length-1;c++){let g=n[c];if(W.isIfStatement(g)&&g.alternate==null){let x=Er(g.consequent);if(x!==null){d===-1&&(d=c),s.push(W.cloneNode(g.test)),a.push(x.jsx),l.add(g);continue}}if(d!==-1&&!ma(g)){u=!1;break}}if(a.push(i.jsx),u&&a.length===r.length&&a.length>1){let c=W.numericLiteral(a.length-1);for(let g=s.length-1;g>=0;g--)c=W.conditionalExpression(s[g],W.numericLiteral(g),c);return{pick:W.arrowFunctionExpression([],c),branches:a,statements:l}}}throw e.buildCodeFrameError(`memo-dom: component '${t}' has unsupported JSX return control flow; use a tail chain of JSX early returns, a terminal JSX if/else, or an exhaustive JSX switch`)}function ai(e,t,n){let r=t.node,o=si(t,n),i=e.componentProps.get(n),s=i.params.length,a=e.listedSites.get(n)??[],l=e.linkedComponentRows.get(n)??[],d=a.some(Z=>Z.sourceLocal===!0)||l.some(Z=>Z.sourceLocal),u=$t(e,n),c=rt(e,u),g=e.instanceDerivations.get(n),x=e.instanceControlFlow.get(n),E=e.effects.get(n),f=E?.some(Z=>Z.localReads.size>0||Z.localDerivationReads.size>0||Z.conditionLocalReads.size>0||Z.conditionLocalDerivationReads.size>0)===!0;(e.selectiveDerivationComponents.has(n)||e.targetedListComponents.has(n)||f)&&(c.reasonVar=A(e,"reasons").name);let m=A(e,"id").name,C=u?null:A(e,"parent").name,y=u&&d?A(e,"owner").name:null,v=u&&e.componentsWithHostEvents.has(n)?A(e,"eventRoot").name:null;c.delegatedEventRootVar=v;let M=s>0&&!u?A(e,"props").name:null;vt(e).registerComponentId(n,m);let R;if((a.length>0||l.length>0)&&i.bindings.length>0){let Z=[...a.map(V=>nt(V.keyExpr??null,V.itemParam??"")),...l.map(V=>V.keyPath)],ne=JSON.stringify(Z[0]),xe=Z.every(V=>JSON.stringify(V)===ne)?Z[0]:null,be=pn(i,"item"),ie=Ke(i);R={itemParam:be??ie??i.bindings[0],itemPath:be===null&&ie!==null?["item"]:[],rowIdVar:m,...u?{refreshVar:c.updateVar}:{},keyPath:xe,sourceKey:a[0]?.sourceKey??l[0]?.sourceKey??"",sourceLocal:d,...d?{ownerIdVar:y??C}:{}}}Qo(e,t,n,m,R);let I="jsx"in o?ut(e,c,o.jsx,n,t,null,R):ha(e,c,o,n,t,m),H=u&&"jsx"in o&&D.isJSXElement(o.jsx);if(u&&zt(e,c,I),g!==void 0)for(let Z of g)Z.declaration.kind="let";(g!==void 0||x!==void 0)&&c.updaters.unshift(()=>ii(e,n,c.reasonVar,r.body.body,g??[],x??[])),E!==void 0&&f&&c.updaters.push(()=>Wr(e,n,m,c.reasonVar,E,c));let O=new Set(E?.map(Z=>Z.statement)??[]),_=r.body.body.filter(Z=>!("jsx"in o?Z===o.statement:o.statements.has(Z))&&!O.has(Z));s>0&&!u&&c.updaters.unshift(()=>D.blockStatement(Tn(i,i.params.map((Z,ne)=>D.memberExpression(D.identifier(M),D.numericLiteral(ne),!0)))));let Y=[ot(c)];if(s>0&&!u){let Z=wr(i,i.params.map((ne,xe)=>D.memberExpression(D.identifier(M),D.numericLiteral(xe),!0)));Z!==null&&Y.push(Z)}if(Y.push(..._,it(c),...u?[]:[yt(e,D.identifier(m),D.identifier(C),D.identifier(c.updateVar))]),s>0&&!u&&Y.push(D.expressionStatement(D.callExpression(Q(e,"registerProps"),[D.identifier(m),D.identifier(M)]))),Y.push(...c.creation,...c.mounts),E!==void 0&&Y.push(...zr(e,m,E)),u){let Z=i.params.map((ne,xe)=>A(e,`nextProp${xe}`));Y.push(D.returnStatement(D.objectExpression([D.objectProperty(D.identifier("nodes"),H?D.identifier(I):D.callExpression(Q(e,"rootNodes"),[D.identifier(I)])),D.objectProperty(D.identifier("entities"),D.arrayExpression([])),D.objectProperty(D.identifier("update"),D.identifier(c.updateVar)),...s>0?[D.objectProperty(D.identifier("updateProps"),D.arrowFunctionExpression(Z,D.blockStatement(Tn(i,Z))))]:[],...c.disposableCallbacks.length>0?[D.objectProperty(D.identifier("dispose"),D.arrowFunctionExpression([],D.blockStatement([...c.disposableCallbacks].reverse().map(ne=>D.ifStatement(D.binaryExpression("!==",D.cloneNode(ne),D.nullLiteral()),D.expressionStatement(D.callExpression(D.cloneNode(ne),[])))))))]:[]])))}else Y.push(D.returnStatement(D.identifier(I)));r.params=u?[...i.params.map(kr),D.identifier(m),...y===null?[]:[D.identifier(y)],...v===null?[]:[D.identifier(v)]]:s>0?[D.identifier(m),D.identifier(C),D.identifier(M)]:[D.identifier(m),D.identifier(C)],r.body=D.blockStatement(Y)}function ha(e,t,n,r,o,i){let s=A(e,"returnRoot").name,a=A(e,"returnRegion").name,l=D.identifier(i),d=D.binaryExpression("+",D.cloneNode(l),D.stringLiteral("/$return"));return t.creation.push(D.variableDeclaration("const",[D.variableDeclarator(D.identifier(s),D.callExpression(D.memberExpression(D.identifier("document"),D.identifier("createDocumentFragment")),[]))])),t.creation.push(D.variableDeclaration("const",[D.variableDeclarator(D.identifier(a),D.callExpression(Q(e,"createCondRegion"),[D.identifier(s),D.cloneNode(d),D.cloneNode(n.pick),D.arrayExpression(n.branches.map(u=>Ho(e,u,r,o,d,!1,l,!0,t.usedConds)))]))])),t.updaters.push(()=>D.expressionStatement(D.callExpression(D.memberExpression(D.identifier(a),D.identifier("update")),[]))),s}import*as ae from"@babel/types";function Ea(e){return!ae.isIdentifier(e.id)||!/^[A-Z]/.test(e.id.name)||!ae.isArrowFunctionExpression(e.init)&&!ae.isFunctionExpression(e.init)||!de(e.init.body)?null:e.init}function ya(e,t,n){if(t.async||t.generator)throw n.buildCodeFrameError(`memo-dom: component '${e}' must be synchronous`);if(ae.isFunctionExpression(t)&&t.id!=null&&t.id.name!==e)throw n.buildCodeFrameError(`memo-dom: named component function expression '${t.id.name}' must match binding '${e}'`);let r=ae.functionDeclaration(ae.identifier(e),t.params.map(o=>ae.cloneNode(o,!0)),ae.isBlockStatement(t.body)?ae.cloneNode(t.body,!0):ae.blockStatement([ae.returnStatement(ae.cloneNode(t.body,!0))]));return r.returnType=t.returnType==null?null:ae.cloneNode(t.returnType,!0),r.typeParameters=t.typeParameters==null?null:ae.cloneNode(t.typeParameters,!0),r.loc=t.loc,r}function li(e,t,n){if(e.kind!=="const")return[t?ae.exportNamedDeclaration(ae.cloneNode(e,!0)):ae.cloneNode(e,!0)];let r=[];for(let o of e.declarations){let i=Ea(o),s;i===null?s=ae.variableDeclaration("const",[ae.cloneNode(o,!0)]):s=ya(o.id.name,i,n),r.push(t?ae.exportNamedDeclaration(s):s)}return r.length>0&&ae.inheritsComments(r[0],e),r}function on(e){let t=[],n=!1;for(let r of e.get("body")){let o=r.node;if(ae.isVariableDeclaration(o)){let i=li(o,!1,r);n||=i.some(s=>ae.isFunctionDeclaration(s)),t.push(...i);continue}if(ae.isExportNamedDeclaration(o)&&ae.isVariableDeclaration(o.declaration)){let i=li(o.declaration,!0,r);n||=i.some(s=>ae.isExportNamedDeclaration(s)&&ae.isFunctionDeclaration(s.declaration)),t.push(...i);continue}t.push(o)}n&&(e.set("body",t),e.scope.crawl())}function Sa(e,t){let n=`${e.rootId}/$computed/${encodeURIComponent(e.moduleId)}#`;for(let r of t.get("body")){let o=r.node;if($.isExportNamedDeclaration(o)&&(o=o.declaration),!(!$.isVariableDeclaration(o)||o.kind!=="const"))for(let i of o.declarations){if(!$.isIdentifier(i.id)||i.init==null)continue;let s=i.id.name;if(!e.computeds.has(s))continue;o.kind="let";let a=$.cloneNode(i.init),l=A(e,`${s}Next`),d=$.expressionStatement($.callExpression(Q(e,"register"),[$.objectExpression([$.objectProperty($.identifier("id"),$.stringLiteral(`${n}${s}`)),$.objectProperty($.identifier("parent"),$.nullLiteral()),$.objectProperty($.identifier("depth"),$.unaryExpression("-",$.numericLiteral(1))),$.objectProperty($.identifier("render"),$.arrowFunctionExpression([],$.blockStatement([$.variableDeclaration("const",[$.variableDeclarator(l,a)]),$.ifStatement($.callExpression(Q(e,"computedChanged"),[$.identifier(s),$.cloneNode(l)]),$.blockStatement([$.expressionStatement($.assignmentExpression("=",$.identifier(s),$.cloneNode(l))),$.expressionStatement($.callExpression(Q(e,"commitWrites"),[Ut(e,[s])]))]))])))])]));r.insertAfter(d)}}}function xa(e,t){let n=new Map(t.get("body").map(r=>[r.node,r]));for(let r of e.moduleControlFlow){let o=n.get(r.statement);if(o===void 0)continue;let i=new Map(r.bindings.map(a=>[a,A(e,`${a}Previous`)])),s=[$.variableDeclaration("const",r.bindings.map(a=>$.variableDeclarator($.cloneNode(i.get(a)),$.identifier(a)))),$.cloneNode(r.statement,!0),...r.bindings.map(a=>$.ifStatement($.callExpression(Q(e,"computedChanged"),[$.cloneNode(i.get(a)),$.identifier(a)]),$.blockStatement([$.expressionStatement($.callExpression(Q(e,"commitWrites"),[Ut(e,[a])]))])))];o.insertAfter($.expressionStatement($.callExpression(Q(e,"register"),[$.objectExpression([$.objectProperty($.identifier("id"),$.stringLiteral(r.entityId)),$.objectProperty($.identifier("parent"),$.nullLiteral()),$.objectProperty($.identifier("depth"),$.unaryExpression("-",$.numericLiteral(1))),$.objectProperty($.identifier("render"),$.arrowFunctionExpression([],$.blockStatement(s)))])])))}}function yr(e,t={}){let n=an(t),r=new WeakSet;return{name:"memo-dom",visitor:{Program:{enter(i){on(i),Nn(n,i),ln(n,i),Dn(n,i),ei(n,i),ti(n)},exit(i){Kr(n,i),ni(i),Ur(i),i.traverse({JSXElement(a){throw a.buildCodeFrameError("memo-dom: JSX outside a component function \u2014 components must be top-level function declarations (L1)")},JSXFragment(a){throw a.buildCodeFrameError("memo-dom: JSX outside a component function - components must be top-level function declarations")}});let s=er(n);n.computeds.size>0&&Sa(n,i),n.moduleControlFlow.length>0&&xa(n,i),s&&n.header.push(s);for(let a=n.header.length-1;a>=0;a--)i.unshiftContainer("body",n.header[a]);i.unshiftContainer("body",$.importDeclaration([$.importNamespaceSpecifier($.identifier(vt(n).runtimeId))],$.stringLiteral(n.runtimePath)))}},FunctionDeclaration(i){let s=i.node.id?.name;!s||!n.comps.has(s)||r.has(i.node)||(r.add(i.node),ai(n,i,s),i.skip())}}}}function Sr(e,t={}){let n=Ca(e,{filename:t.moduleId??"./component.tsx",plugins:[[Pa,{}],[yr,t],[wa,{isTSX:!0}]],configFile:!1,babelrc:!1});if(!n||n.code==null)throw new Error("memo-dom: compilation produced no output");return n.code}import{posix as Kt}from"node:path";import{transformSync as xi}from"@babel/core";import Ci from"@babel/plugin-syntax-jsx";import Pi from"@babel/plugin-transform-typescript";import*as z from"@babel/types";function va(e,t,n){let r=e.get(t);r===void 0&&(r=new Map,e.set(t,r));let o=r.get(n);return o===void 0&&(o={keys:new Set,rootFallback:!1},r.set(n,o)),o}function ka(e,t,n,r){if(n.type==="state"){r.keys.add(n.key);return}if(n.type==="root"){r.rootFallback=!0;return}if(n.type==="local")return;let o=e.get(t)?.get(n.name);if(o===void 0){r.rootFallback=!0;return}r.rootFallback||=o.rootFallback;let i=n.path.length===0?"":`.${n.path.join(".")}`;for(let s of o.keys)r.keys.add(`${s}${i}`)}function di(e,t){let n=new Map;for(let s of e.values())for(let a of s.edges)n.set(a.target,(n.get(a.target)??0)+1);let r=new Map,o=new Map(n),i=[...t];for(;i.length>0;){let s=i.shift();for(let a of e.get(s)?.edges??[]){for(let[d,u]of Object.entries(a.propSources??{})){let c=va(r,a.target,d);for(let g of u)ka(r,s,g,c)}let l=(o.get(a.target)??1)-1;o.set(a.target,l),l===0&&i.push(a.target)}}return new Map([...r].map(([s,a])=>[s,new Map([...a].map(([l,d])=>[l,{keys:[...d.keys].sort(),rootFallback:d.rootFallback}]))]))}function Na(e){let t=new Set,n=new Set,r=o=>{if(n.has(o))throw new Error(`memo-dom: recursive cross-module component graph at '${o}'`);if(!t.has(o)){n.add(o);for(let i of e.get(o)?.edges??[])r(i.target);n.delete(o),t.add(o)}};for(let o of e.keys())r(o)}function ci(e,t){let n=new Map(e.map(u=>[u.key,u]));Na(n);let r=new Map,o=new Map;for(let u of n.values())for(let c of u.edges){if(!n.has(c.target))throw new Error(`memo-dom: component '${u.key}' references unknown factory '${c.target}'`);let g=r.get(c.target)??new Set;if(g.add(c.mode),r.set(c.target,g),c.mode==="row"){let x=o.get(c.target)??[];x.push({keyPath:c.keyPath===void 0||c.keyPath===null?null:[...c.keyPath],sourceKey:c.sourceKey??"",sourceLocal:c.sourceLocal??!1}),o.set(c.target,x)}}for(let[u,c]of r)if(c.size>1)throw new Error(`memo-dom: component '${u}' is used both as a keyed row and a static child`);let i=new Map,s=[...n.keys()].filter(u=>!r.has(u));for(let u of s)i.set(u,new Set([t]));let a=[...s];for(;a.length>0;){let u=a.shift(),c=i.get(u);if(c!==void 0)for(let g of n.get(u)?.edges??[]){let x=i.get(g.target)??new Set,E=x.size;for(let f of c)x.add(`${f}${g.suffix}`);i.set(g.target,x),x.size!==E&&a.push(g.target)}}let l=new Map;for(let u of n.keys())l.set(u,[...i.get(u)??[]].sort());let d=di(n,s);return{paths:l,rows:o,propSources:d}}import"@babel/types";import*as ge from"@babel/types";function ui(e){let t=e;for(;ge.isTSAsExpression(t)||ge.isTSTypeAssertion(t)||ge.isTSNonNullExpression(t)||ge.isTSSatisfiesExpression(t);)t=t.expression;return t}function Ia(e,t,n){let r=ui(n);if(ge.isIdentifier(r))return!e.state.has(r.name)||t.getBinding(r.name)?.scope.path.isProgram()!==!0?null:Ye(e,r.name);if(!ge.isMemberExpression(r))return null;let o=ve(r);return o===null||!e.state.has(o)||t.getBinding(o)?.scope.path.isProgram()!==!0?null:Ye(e,ye(r)??o)}function Ra(e,t){let n=ui(t);if(ge.isIdentifier(n)){let a=Ze(e,n.name);return a===null?null:{type:"prop",name:a,path:[]}}if(!ge.isMemberExpression(n))return null;let r=ve(n),o=ye(n);if(r===null||o===null)return null;if(Ke(e)===r){let[a,...l]=o.split(".").slice(1);return a===void 0?null:{type:"prop",name:a,path:l}}let s=Ze(e,r);return s===null?null:{type:"prop",name:s,path:o.split(".").slice(1)}}function Fa(e,t){let n=!1,r=Ke(e);return Le(t,o=>{ge.isIdentifier(o)&&(o.name===r||Ze(e,o.name)!==null)&&(n=!0)}),n}function Ma(e){return ge.isStringLiteral(e)||ge.isNumericLiteral(e)||ge.isBooleanLiteral(e)||ge.isNullLiteral(e)||ge.isBigIntLiteral(e)||ge.isTemplateLiteral(e)}function Da(e,t,n,r){let o=Ia(e,n,r);if(o!==null)return{type:"state",key:o};let i=e.componentProps.get(t),s=Ra(i,r);if(s!==null)return s;let a=ge.isIdentifier(r)?r.name:ge.isMemberExpression(r)?ve(r):null;return a!==null&&(e.instanceState.get(t)?.has(a)===!0||e.instanceDerivedBindings.get(t)?.has(a)===!0)||dn(e,r).size>0||Fa(i,r)?{type:"root"}:Ma(r)?{type:"local"}:{type:"root"}}function xr(e,t,n,r){let o=e.get(t)??{},i=o[n]??[],s=JSON.stringify(r);i.some(a=>JSON.stringify(a)===s)||(i.push(r),i.sort((a,l)=>JSON.stringify(a).localeCompare(JSON.stringify(l)))),o[n]=i,e.set(t,o)}function La(e){return ge.isJSXIdentifier(e.name)?e.name.name:null}function pi(e,t){let n=new Map;return e.compPaths.get(t).traverse({JSXOpeningElement(r){let o=r.node.name;if(!ge.isJSXIdentifier(o)||!/^[A-Z]/.test(o.name))return;let i=e.componentProps.get(o.name);for(let s of r.get("attributes")){if(s.isJSXSpreadAttribute()){for(let d of i?.names??[])d==="ref"||i?.refProps.includes(d)||xr(n,o.name,d,{type:"root"});continue}if(!s.isJSXAttribute())continue;let a=La(s.node);if(a===null||a==="key"||a==="ref"||i?.refProps.includes(a)===!0)continue;let l=s.node.value;if(!ge.isJSXExpressionContainer(l)||!ge.isExpression(l.expression)){xr(n,o.name,a,{type:"local"});continue}xr(n,o.name,a,Da(e,t,s.scope,l.expression))}}}),n}function fi(e,t){let n=new Map;return e.traverse({FunctionDeclaration(r){let o=r.node.id?.name;if(o!==void 0&&/^[A-Z]/.test(o)&&r.scope.parent?.path.isProgram()===!0&&Ae(r)){let i=un(r.node.params);n.set(o,{key:`${t}#${o}`,props:[...i.names],objectProps:i.mode==="object",acceptsUnknownProps:i.acceptsUnknown,hasWholeDefault:i.hasWholeDefault,listLightweight:!1,delegatedEvents:Fn(r.node.body),renderProps:[],renderCallbacks:[],refProps:[],subtreeReads:[]})}r.skip()}}),n}function mi(e,t,n){let r=e.componentProps.get(n);return{key:`${t}#${n}`,props:[...r.names],objectProps:r.mode==="object",acceptsUnknownProps:r.acceptsUnknown,hasWholeDefault:r.hasWholeDefault,listLightweight:wn(e,n),delegatedEvents:e.componentsWithHostEvents.has(n),renderProps:[...r.renderProps],renderCallbacks:[...r.renderCallbacks],refProps:[...r.refProps],subtreeReads:[...Rn(e,n)].map(o=>Ye(e,o)).sort()}}function $n(e,t){return e.importedComponents.get(t)?.key??`${e.moduleId}#${t}`}function gi(e,t){let n=[];for(let r of t.comps.keys()){let o=[],i=pi(t,r);for(let[s,a]of t.childRefCounts.get(r)??[]){let l=$n(t,s),d=i.get(s);o.push({target:l,suffix:`/${s}`,mode:"static",...d===void 0?{}:{propSources:d}}),a>1&&o.push({target:l,suffix:`/${s}[*]`,mode:"static",...d===void 0?{}:{propSources:d}})}for(let[s,a]of t.conditionalComponentSites)for(let l of a){if(l.owner!==r)continue;let d=i.get(s);o.push({target:$n(t,s),suffix:`/${l.suffix}`,mode:"static",...d===void 0?{}:{propSources:d}})}for(let[s,a]of t.rowComponentSites)for(let l of a){if(l.owner!==r)continue;let d=i.get(s);o.push({target:$n(t,s),suffix:`/${l.suffix}`,mode:"static",...d===void 0?{}:{propSources:d}})}for(let[s,a]of t.listedSites)for(let l of a)l.owner===r&&o.push({target:$n(t,s),suffix:`/${l.suffix}/Row[*]`,mode:"row",keyPath:nt(l.keyExpr??null,l.itemParam??""),sourceKey:l.sourceLocal===!0?l.sourceKey??"":Ye(t,l.sourceKey??""),sourceLocal:l.sourceLocal??!1,...i.get(s)===void 0?{}:{propSources:i.get(s)}});n.push({key:`${e}#${r}`,moduleId:e,local:r,edges:o})}return n}function wi(e){let t=e.replace(/\\/g,"/"),n=Kt.normalize(t);return t.startsWith("./")&&!n.startsWith("../")?`./${n}`:n}function vi(e){return{...e.runtimePath===void 0?{}:{runtimePath:e.runtimePath},...e.rootId===void 0?{}:{rootId:e.rootId}}}function Aa(e){let t=new Map,n=(r,o,i)=>{t.set(`${r}\0${o}\0${i}`,{target:r,prop:o,kind:i})};for(let[r,o]of e.compPaths)o.traverse({JSXElement(i){let s=i.node.openingElement,a=s.name;if(!z.isJSXIdentifier(a)||!/^[A-Z]/.test(a.name))return;let l=e.importedComponents.get(a.name)?.key??(e.comps.has(a.name)?`${e.moduleId}#${a.name}`:null);if(l!==null){for(let d of s.attributes){if(!z.isJSXAttribute(d))continue;let u=z.isJSXIdentifier(d.name)?d.name.name:d.name.name.name,c=d.value;z.isJSXElement(c)||z.isJSXFragment(c)||z.isJSXExpressionContainer(c)&&z.isExpression(c.expression)&&(de(c.expression)||st(e,r,c.expression))?n(l,u,"jsx"):n(l,u,"scalar")}i.node.children.some(d=>!z.isJSXText(d)||d.value.trim()!=="")&&n(l,"children","jsx")}}});return[...t.values()].sort((r,o)=>r.target.localeCompare(o.target)||r.prop.localeCompare(o.prop)||r.kind.localeCompare(o.kind))}function bi(e,t){return[...new Set(t.flatMap(n=>{let r=e.importedComponents.get(n);return r!==void 0?[r.key]:e.comps.has(n)?[`${e.moduleId}#${n}`]:[]}))].sort()}function wt(e,t,n){for(;z.isTSAsExpression(e)||z.isTSTypeAssertion(e)||z.isTSNonNullExpression(e);)e=e.expression;if(z.isIdentifier(e)){t.has(e.name)&&n.add(e.name);return}if(z.isConditionalExpression(e)){wt(e.consequent,t,n),wt(e.alternate,t,n);return}if(z.isLogicalExpression(e)){wt(e.right,t,n);return}if(z.isObjectExpression(e)){for(let r of e.properties)z.isObjectProperty(r)&&z.isExpression(r.value)&&wt(r.value,t,n);return}if(z.isArrayExpression(e))for(let r of e.elements)r!=null&&!z.isSpreadElement(r)&&wt(r,t,n)}function hi(e,t){let n=new Set;if(z.isExpression(e.body))return wt(e.body,t,n),[...n];let r=o=>{if(!z.isFunction(o)){if(z.isReturnStatement(o)){z.isExpression(o.argument)&&wt(o.argument,t,n);return}for(let i of z.VISITOR_KEYS[o.type]??[]){let s=o[i];if(Array.isArray(s))for(let a of s)a!=null&&typeof a=="object"&&"type"in a&&r(a);else s!=null&&typeof s=="object"&&"type"in s&&r(s)}}};for(let o of e.body.body)r(o);return[...n]}function ki(e){let t=[];for(let n of e.body)if(!(!z.isImportDeclaration(n)||n.importKind==="type"))for(let r of n.specifiers)if(z.isImportSpecifier(r)){if(r.importKind==="type")continue;let o=z.isIdentifier(r.imported)?r.imported.name:r.imported.value;t.push({local:r.local.name,imported:o,source:n.source.value})}else z.isImportDefaultSpecifier(r)?t.push({local:r.local.name,imported:"default",source:n.source.value}):t.push({local:r.local.name,imported:"*",source:n.source.value});return t}function Ni(e){let t=new Map;for(let n of e.body){if(z.isExportDefaultDeclaration(n)){(z.isFunctionDeclaration(n.declaration)||z.isClassDeclaration(n.declaration))&&n.declaration.id!=null?t.set("default",n.declaration.id.name):z.isIdentifier(n.declaration)&&t.set("default",n.declaration.name);continue}if(!z.isExportNamedDeclaration(n))continue;if(n.source!==null)throw new Error("memo-dom: re-export-from declarations are not supported by compileModules(); import then export the binding explicitly");let r=n.declaration;if(z.isVariableDeclaration(r))for(let o of r.declarations)z.isIdentifier(o.id)&&t.set(o.id.name,o.id.name);else z.isFunctionDeclaration(r)&&r.id!=null&&t.set(r.id.name,r.id.name);for(let o of n.specifiers){if(!z.isExportSpecifier(o))continue;let i=o.local.name,s=z.isIdentifier(o.exported)?o.exported.name:o.exported.value;t.set(s,i)}}return t}function ja(e,t,n){let r,o=()=>({visitor:{Program(i){on(i);let s=ki(i.node),a=an({...vi(n),moduleId:e.id,linkedImports:t});Nn(a,i),ln(a,i),Dn(a,i);let l={},d=Qn(i.node);for(let[u,c]of Ni(i.node)){if(a.comps.has(c)){l[u]={type:"component",...mi(a,e.id,c)};continue}let g=a.state.get(c);if(g!==void 0){l[u]={type:"state",kind:g,key:a.stateKeys.get(c)??`${e.id}#${c}`,tagCandidates:[...a.stateTagCandidates.get(c)??[]],componentCandidates:bi(a,a.stateComponentCandidates.get(c)??[])};continue}let x=a.importedFunctions.get(c)??(a.helpers.has(c)?Ue(a,c):void 0);x!==void 0&&(l[u]={type:"function",tagCandidates:[...d.get(c)??a.functionTagCandidates.get(c)??[]],componentCandidates:bi(a,a.functionComponentCandidates.get(c)??[]),reads:[...x.reads].map(E=>Ye(a,E)).sort(),writes:[...x.writes].map(E=>Ye(a,E)).sort(),boundedWrites:[...x.boundedWrites].map(E=>Ye(a,E)).sort(),parameterWrites:x.parameterWrites.map(E=>({index:E.index,path:[...E.path]})).sort((E,f)=>E.index-f.index||E.path.join(".").localeCompare(f.path.join("."))),unbounded:x.unbounded})}r={exports:l,imports:s,components:gi(e.id,a),componentUsages:Aa(a)}}}});if(xi(e.source,{filename:e.id,plugins:[[Ci,{}],o,[Pi,{isTSX:!0}]],configFile:!1,babelrc:!1}),r===void 0)throw new Error(`memo-dom: failed to analyze module '${e.id}'`);return r}function Ja(e){let t,n=()=>({visitor:{Program(r){on(r);let o=new Map,i=In(r.node),s=Qn(r.node),a=fi(r,e.id),l=new Set(a.keys());for(let[u,c]of a)o.set(u,{type:"component",...c});for(let u of r.node.body){let c=z.isExportNamedDeclaration(u)?u.declaration:u;if(z.isVariableDeclaration(c))for(let g of c.declarations){if(!z.isIdentifier(g.id))continue;if(z.isArrowFunctionExpression(g.init)||z.isFunctionExpression(g.init)){let E=hi(g.init,l).map(f=>`${e.id}#${f}`);o.set(g.id.name,{type:"function",tagCandidates:[...s.get(g.id.name)??[]],componentCandidates:E,reads:[],writes:[],boundedWrites:[],parameterWrites:[],unbounded:!0});continue}let x;if(c.kind==="let"||c.kind==="var"?x="let":kt(g.init)?x="store":Nt(g.init)&&(x="const"),x!==void 0){let E=new Set;z.isExpression(g.init)&&wt(g.init,l,E),o.set(g.id.name,{type:"state",kind:x,key:`${e.id}#${g.id.name}`,tagCandidates:[...i.get(g.id.name)??[]],componentCandidates:[...E].map(f=>`${e.id}#${f}`)})}}else if(z.isFunctionDeclaration(c)&&c.id!=null&&!a.has(c.id.name)){let g=hi(c,l).map(x=>`${e.id}#${x}`);o.set(c.id.name,{type:"function",tagCandidates:[...s.get(c.id.name)??[]],componentCandidates:g,reads:[],writes:[],boundedWrites:[],parameterWrites:[],unbounded:!0})}}let d={};for(let[u,c]of Ni(r.node)){let g=o.get(c);g!==void 0&&(d[u]=g)}t={exports:d,imports:ki(r.node),components:[],componentUsages:[]}}}});if(xi(e.source,{filename:e.id,plugins:[[Ci,{}],n,[Pi,{isTSX:!0}]],configFile:!1,babelrc:!1}),t===void 0)throw new Error(`memo-dom: failed to discover module '${e.id}'`);return t}function Ii(e,t,n,r){let i=r.resolveImport?.(t,e);if(i===void 0){let l=Object.entries(r.aliases??{}).sort(([d],[u])=>u.length-d.length);for(let[d,u]of l)if(d.endsWith("/")?t.startsWith(d):t===d||t.startsWith(`${d}/`)){i=`${u}${t.slice(d.length)}`;break}}if(i===void 0)if(t.startsWith(".")){let l=Kt.normalize(Kt.join(Kt.dirname(e),t));i=e.startsWith("./")&&!l.startsWith("../")?`./${l}`:l}else i=t;let s=wi(i??t),a=[s,`${s}.ts`,`${s}.tsx`,`${s}.js`,`${s}.jsx`,`${s}/index.ts`,`${s}/index.tsx`,`${s}/index.js`,`${s}/index.jsx`];for(let l of a){let d=n.get(l);if(d!==void 0)return d}}function $a(e,t){if(!t.startsWith("."))return t;let n=Kt.relative(Kt.dirname(e),t);return n.startsWith(".")?n:`./${n}`}function Ei(e,t,n){return t.map(r=>{for(let[o,i]of n)for(let[s,a]of Object.entries(i.exports))if(!(a.type!=="component"||a.key!==r))return{key:a.key,source:$a(e.id,o),imported:s,props:[...a.props],objectProps:a.objectProps,acceptsUnknownProps:a.acceptsUnknownProps,hasWholeDefault:a.hasWholeDefault,listLightweight:a.listLightweight,delegatedEvents:a.delegatedEvents,renderProps:[...a.renderProps],renderCallbacks:[...a.renderCallbacks],refProps:[...a.refProps],subtreeReads:[...a.subtreeReads]};throw new Error(`memo-dom: dynamic component candidate '${r}' is not exported; export the component so consuming modules can link it`)})}function yi(e,t,n,r,o,i){let s={};for(let a of t.imports){let l=Ii(e.id,a.source,r,o);if(l===void 0){s[a.local]={type:"function",tagCandidates:[],componentCandidates:[],reads:[],writes:[],boundedWrites:[],parameterWrites:[],unbounded:!0};continue}if(a.imported==="*")throw new Error(`memo-dom: namespace import '${a.local}' from '${a.source}' cannot identify a reactive export; use named imports`);let d=n.get(l.id)?.exports[a.imported];if(d===void 0){s[a.local]={type:"function",tagCandidates:[],componentCandidates:[],reads:[],writes:[],boundedWrites:[],parameterWrites:[],unbounded:!0};continue}if(d.type==="state")s[a.local]={type:"state",kind:d.kind,key:d.key,tagCandidates:[...d.tagCandidates],componentCandidates:Ei(e,d.componentCandidates,n)};else if(d.type==="component"){let u=i?.get(d.key),c=d.renderProps.filter(g=>u?.scalar.has(g)!==!0||u.jsx.has(g));s[a.local]={type:"component",key:d.key,props:[...d.props],objectProps:d.objectProps,acceptsUnknownProps:d.acceptsUnknownProps,hasWholeDefault:d.hasWholeDefault,listLightweight:d.listLightweight,delegatedEvents:d.delegatedEvents,renderProps:c,renderCallbacks:[...d.renderCallbacks],refProps:[...d.refProps],subtreeReads:[...d.subtreeReads]}}else s[a.local]={type:"function",tagCandidates:[...d.tagCandidates],componentCandidates:Ei(e,d.componentCandidates,n),reads:[...d.reads],writes:[...d.writes],boundedWrites:[...d.boundedWrites],parameterWrites:[...d.parameterWrites],unbounded:d.unbounded}}return s}function Si(e){return JSON.stringify(e)}function Oa(e,t={}){let n=new Map;for(let[a,l]of Object.entries(e)){let d=wi(a);if(n.has(d))throw new Error(`memo-dom: duplicate module id after normalization: '${d}'`);n.set(d,{originalId:a,id:d,source:l})}let r=new Map;for(let a of n.values())r.set(a.id,Ja(a));for(let a=0;a<=n.size;a++){let l=!1,d=new Map;for(let u of n.values()){let c=r.get(u.id),g=yi(u,c,r,n,t),x=ja(u,g,t);d.set(u.id,x),Si(x)!==Si(c)&&(l=!0)}if(r=d,!l)break;if(a===n.size)throw new Error("memo-dom: cross-module export summaries did not converge")}let o=new Map;for(let a of r.values())for(let l of a.componentUsages){let d=o.get(l.target);d===void 0&&(d={jsx:new Set,scalar:new Set},o.set(l.target,d)),d[l.kind].add(l.prop)}for(let[a,l]of o)for(let d of l.jsx)if(l.scalar.has(d))throw new Error(`memo-dom: component '${a}' prop '${d}' is used as both scalar data and JSX content; split the prop or component contract`);let i=ci([...r.values()].flatMap(a=>a.components),t.rootId??"App"),s={};for(let a of n.values()){let l=r.get(a.id),d=yi(a,l,r,n,t,o);for(let E of l.imports){let f=Ii(a.id,E.source,n,t);if(f!==void 0&&r.get(f.id)?.exports[E.imported]===void 0)throw new Error(`memo-dom: '${E.imported}' is not a linkable state, function, or component export of '${E.source}'`)}let u={},c={},g={},x={};for(let E of l.components){u[E.local]=[...i.paths.get(E.key)??[]];let f=i.rows.get(E.key);f!==void 0&&(c[E.local]=f.map(y=>({keyPath:y.keyPath===null?null:[...y.keyPath],sourceKey:y.sourceKey,sourceLocal:y.sourceLocal})));let m=i.propSources.get(E.key);m!==void 0&&(g[E.local]=Object.fromEntries([...m].map(([y,v])=>[y,{keys:[...v.keys],rootFallback:v.rootFallback}])));let C=Object.values(l.exports).find(y=>y.type==="component"&&y.key===E.key);if(C?.type==="component"){let y=o.get(E.key);x[E.local]=C.renderProps.filter(v=>y?.scalar.has(v)!==!0||y.jsx.has(v))}}s[a.originalId]=Sr(a.source,{...vi(t),moduleId:a.id,linkedImports:d,linkedComponentPaths:u,linkedComponentRows:c,linkedComponentPropSources:g,linkedComponentRenderProps:x})}return s}export{Sr as compile,Oa as compileModules};
@@ -0,0 +1,8 @@
1
+ import type { MapSite } from './map-site';
2
+ /**
3
+ * Finds instance-state values that affect exactly the row keyed by that value.
4
+ * Every visual reference must be an equality comparison with the authored key;
5
+ * mixed/general uses are rejected and retain full-list reconciliation.
6
+ */
7
+ export declare function findTargetedListDependencies(site: MapSite, instanceState: ReadonlySet<string>): string[];
8
+ //# sourceMappingURL=targeted-refresh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"targeted-refresh.d.ts","sourceRoot":"","sources":["../../src/lists/targeted-refresh.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAoC1C;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,OAAO,EACb,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,GACjC,MAAM,EAAE,CAqCV"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memoized-dom/compiler",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Binding-aware TypeScript and JSX compiler for memoized-dom",
5
5
  "type": "module",
6
6
  "sideEffects": false,