@memoized-dom/compiler 0.0.1 → 0.0.2

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,EASL,KAAK,GAAG,EACT,MAAM,WAAW,CAAC;AAuCnB,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAgpC3D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,CA6C5E"}
@@ -147,6 +147,13 @@ 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
+ }
150
157
  /** One compiler-owned reactive side effect declared in a component body. */
151
158
  export interface EffectSite {
152
159
  /** Stable source-order suffix within the owning component. */
@@ -252,6 +259,10 @@ export interface Ctx {
252
259
  suffix: string;
253
260
  vars: Set<string>;
254
261
  }>;
262
+ /** Map call → owner-local values whose changes affect only old/new keyed rows. */
263
+ targetedListDependencies: WeakMap<t.CallExpression, TargetedListDependency[]>;
264
+ /** Components that need dirty reasons for targeted list refreshes. */
265
+ targetedListComponents: Set<string>;
255
266
  /**
256
267
  * R12: instance state — component name → top-level let/var names of its
257
268
  * 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,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;;;;;;;;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,CAgKxD"}
@@ -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,CA4RN"}
@@ -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;AASlD,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,CAiJN"}
@@ -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"}
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 fa}from"@babel/core";import ma from"@babel/plugin-syntax-jsx";import ga from"@babel/plugin-transform-typescript";import*as J from"@babel/types";import"@babel/types";function Qt(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[y,f]of Object.entries(e.linkedImports??{}))f.type==="state"?(n.set(y,f.kind),r.set(y,f.key),f.tagCandidates!==void 0&&o.set(y,[...f.tagCandidates]),f.componentCandidates!==void 0&&l.set(y,f.componentCandidates.map(m=>({...m}))),d.add(y)):f.type==="function"?(f.tagCandidates!==void 0&&i.set(y,[...f.tagCandidates]),f.componentCandidates!==void 0&&l.set(y,f.componentCandidates.map(m=>({...m}))),u.set(y,{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(y,{...f,props:[...f.props]});let g=new Map;for(let[y,f]of c)g.set(y,{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(([y,f])=>[y,[...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(([y,f])=>[y,[...f]])),linkedComponentRows:new Map(Object.entries(e.linkedComponentRows??{}).map(([y,f])=>[y,f.map(m=>({keyPath:m.keyPath===null?null:[...m.keyPath],sourceKey:m.sourceKey,sourceLocal:m.sourceLocal}))])),linkedComponentPropSources:new Map(Object.entries(e.linkedComponentPropSources??{}).map(([y,f])=>[y,new Map(Object.entries(f).map(([m,w])=>[m,{keys:[...w.keys],rootFallback:w.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,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 ot from"@babel/types";var Dn=class{constructor(t,n){this.scope=t;Ni(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 ot.identifier(n)}runtimeMember(t){return ot.memberExpression(ot.identifier(this.runtimeId),ot.identifier(t))}};function en(e,t){let n=new Dn(t.scope,t);return e.identifiers=n,n}function j(e,t){return wt(e).generate(t)}function Le(e,t){return wt(e).componentId(t)}function Z(e,t){return wt(e).runtimeMember(t)}function wt(e){if(e.identifiers===null)throw new Error("memo-dom: generated identifier allocator was not initialized");return e.identifiers}function Ni(e,t){let n=r=>{ot.isIdentifier(r)&&t(r.name);for(let o of ot.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 mt(e,t,n){e.state.set(t,n),e.stateKeys.has(t)||e.stateKeys.set(t,`${e.moduleId}#${t}`)}function _e(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 Tt(e,t){let n=[...new Set(t.map(s=>_e(e,s)))].sort(),r=n.join(" "),o=e.writeConsts.get(r);if(o!==void 0)return G.identifier(o);let i=j(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 hr(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=j(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 lt(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 Mn(e,t){return t===null?!0:t.length===0||e.length>t.length?!1:e.every((n,r)=>t[r]===n)}function we(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 Pt(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 vt(e){return e?G.isArrayExpression(e)||G.isNewExpression(e):!1}function $e(e){return e==null?null:G.isStringLiteral(e)?e:G.isJSXExpressionContainer(e)?G.isJSXEmptyExpression(e.expression)?null:e.expression:null}function Ln(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 Er(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 Xe(t,i=>G.isIdentifier(i)&&r.has(i.name)?(o=!0,!1):o?!1:void 0),o}function Xe(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 ce(e){let t=!1;return Xe(e,n=>{(G.isJSXElement(n)||G.isJSXFragment(n))&&(t=!0)}),t}function tn(e,t){let n=new Set;return Xe(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 k from"@babel/types";import*as ue from"@babel/types";import*as Ue from"@babel/types";function nn(e){let t=Ue.cloneNode(e,!0);return Ue.traverseFast(t,n=>{(Ue.isIdentifier(n)||Ue.isObjectPattern(n)||Ue.isArrayPattern(n)||Ue.isRestElement(n)||Ue.isAssignmentPattern(n))&&(n.typeAnnotation=null)}),t}import*as xe from"@babel/types";import*as H from"@babel/types";function rn(e){if(e.some(i=>H.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=gt(t[0]);if(t.length===1&&(H.isObjectPattern(n)||H.isIdentifier(n)&&n.name==="props"))return{mode:"object",names:H.isObjectPattern(n)?Ii(n):[],acceptsUnknown:H.isIdentifier(n)||n.properties.some(s=>H.isRestElement(s)),bindings:Bt(n),params:t.map(s=>H.cloneNode(s)),hasWholeDefault:H.isAssignmentPattern(t[0]),renderProps:[],renderCallbacks:[],refProps:[]};let o=[];for(let i of t){let s=gt(i);if(!H.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=>Bt(gt(i))),params:t.map(i=>H.cloneNode(i)),hasWholeDefault:!1,renderProps:[],renderCallbacks:[],refProps:[]}}function yr(e,t){return e.params.length===0?null:H.variableDeclaration("let",e.params.map((n,r)=>H.variableDeclarator(Fi(gt(n)),Cr(n,t[r]??H.identifier("undefined")))))}function An(e,t){return e.params.map((n,r)=>H.expressionStatement(H.assignmentExpression("=",wr(gt(n)),Cr(n,t[r]??H.identifier("undefined")))))}function Sr(e){return H.expressionStatement(H.assignmentExpression("=",wr(e.target),H.cloneNode(e.source)))}function Bt(e){return Object.keys(H.getBindingIdentifiers(e))}function Ve(e){if(e.mode!=="object"||e.params.length!==1)return null;let t=gt(e.params[0]);return H.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=gt(e.params[0]);if(!H.isObjectPattern(n))return null;for(let r of n.properties){if(!H.isObjectProperty(r)||r.computed||(H.isIdentifier(r.key)?r.key.name:H.isStringLiteral(r.key)?r.key.value:null)!==t)continue;let i=H.isAssignmentPattern(r.value)?r.value.left:r.value;return H.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=gt(e.params[0]);if(!H.isObjectPattern(n))return null;for(let r of n.properties)if(!(!H.isObjectProperty(r)||r.computed)&&Object.keys(H.getBindingIdentifiers(r.value)).includes(t)){if(H.isIdentifier(r.key))return r.key.name;if(H.isStringLiteral(r.key))return r.key.value}return null}function gt(e){if(H.isRestElement(e))throw new Error("rest component parameters are not supported");let t=H.isAssignmentPattern(e)?e.left:e;if(!H.isIdentifier(t)&&!H.isObjectPattern(t)&&!H.isArrayPattern(t))throw new Error("unsupported component parameter target");return t}function xr(e){let t=H.cloneNode(e);return Vt(t),t}function Cr(e,t){return H.isAssignmentPattern(e)?H.conditionalExpression(H.binaryExpression("===",H.cloneNode(t),H.identifier("undefined")),H.cloneNode(e.right),H.cloneNode(t)):H.cloneNode(t)}function Ii(e){let t=[];for(let n of e.properties)if(!H.isRestElement(n)){if(n.computed)throw new Error("computed keys are not supported in component prop patterns");if(H.isIdentifier(n.key))t.push(n.key.name);else if(H.isStringLiteral(n.key))t.push(n.key.value);else throw new Error("component prop pattern keys must be identifiers or strings")}return t}function Fi(e){let t=H.cloneNode(e);return Vt(t),t}function wr(e){let t=H.cloneNode(e);return Vt(t),t}function Vt(e){let t=e;"typeAnnotation"in t&&(t.typeAnnotation=null),"optional"in t&&(t.optional=null);for(let n of H.VISITOR_KEYS[e.type]??[]){let r=e[n];if(Array.isArray(r))for(let o of r)o&&typeof o=="object"&&"type"in o&&Vt(o);else r&&typeof r=="object"&&"type"in r&&Vt(r)}}function Pr(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&&xe.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()||!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 Ri(e){return xe.isMemberExpression(e.callee)&&!e.callee.computed&&xe.isIdentifier(e.callee.property,{name:"map"})}function Di(e,t,n){let r=e.componentProps.get(t);if(r===void 0)return null;let o=Ve(r);return o!==null&&xe.isMemberExpression(n)&&!n.computed&&xe.isIdentifier(n.object,{name:o})&&xe.isIdentifier(n.property)?n.property.name:xe.isIdentifier(n)?He(r,n.name)??(on(r,n.name)!==null?n.name:null):null}function Mi(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 Rt(e,t,n){if(!Ri(n)||n.arguments.length!==1)return null;let r=n.arguments[0];if(!xe.isArrowFunctionExpression(r))return null;let o=Mi(r);if(o===null||!xe.isCallExpression(o)||!xe.isExpression(o.callee)||o.arguments.some(s=>!xe.isExpression(s)))return null;let i=Di(e,t,o.callee);return i===null?null:{propName:i,target:xe.cloneNode(o.callee,!0),arguments:o.arguments.map(s=>xe.cloneNode(s,!0))}}function vr(e){for(let[t,n]of e.compPaths){let r=e.componentProps.get(t);n.traverse({CallExpression(o){let i=Rt(e,t,o.node);i!==null&&!r.renderCallbacks.includes(i.propName)&&r.renderCallbacks.push(i.propName)}})}}import*as ke from"@babel/types";function jn(e){for(;ke.isTSAsExpression(e)||ke.isTSTypeAssertion(e)||ke.isTSNonNullExpression(e)||ke.isTSInstantiationExpression(e);)e=e.expression;return e}function sn(e){let t=jn(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(!ue.isCallExpression(e))return null;let t=e.callee;return ue.isMemberExpression(t)&&!t.computed&&ue.isIdentifier(t.property,{name:"map"})?e:null}function De(e){let t=!1;return e.traverse({JSXElement(){t=!0},JSXFragment(){t=!0}}),t}function kt(e,t,n,r,o,i){let s=g=>{throw n.buildCodeFrameError(g)},a=t.callee,l=Li(e,a.object,r,i,s),d=Ji(e,t,r,s),u=$i(e,d,s),c=Ti(l.suffixBase,o);return{sourceKey:l.key,sourceExpr:ue.cloneNode(l.expression),sourceLocal:l.local,itemPattern:d.itemPattern,itemParam:d.itemParam,indexParam:d.indexParam,keyExpr:Oi(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 Li(e,t,n,r,o){return ue.isIdentifier(t)?Ai(e,t,n,o):ue.isMemberExpression(t)?ji(e,t,n,r,o):ue.isExpression(t)&&sn(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 Ai(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 ji(e,t,n,r,o){let i=we(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 Ji(e,t,n,r){if(t.arguments.length!==1||!ue.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||!ue.isIdentifier(i)&&!ue.isObjectPattern(i)&&!ue.isArrayPattern(i)||s!==void 0&&!ue.isIdentifier(s))return r("memo-dom: list callback must take an item binding pattern and optional index identifier \u2014 R7 L1");let a=nn(i),l=Object.keys(ue.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=ue.isIdentifier(a)?a.name:l[0],u=ue.isIdentifier(s)?s.name:null,c=ue.isBlockStatement(o.body)&&o.body.body.length===1&&ue.isReturnStatement(o.body.body[0])?o.body.body[0].argument:null,g=ue.isJSXElement(o.body)?o.body:ue.isJSXElement(c)?c:null,x=Rt(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 $i(e,t,n){let r=t.jsx?.openingElement??null;if(r!==null&&!ue.isJSXIdentifier(r.name))return n("memo-dom: namespaced JSX tags are not supported (L1)");let o=r!==null&&ue.isJSXIdentifier(r.name)?r.name.name:null;return t.renderInvocation!==null?(Xi(t,n),{form:"callback",rowComp:null,renderCallback:ue.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 Xi(e,t){let n=e.renderInvocation;(!ue.isIdentifier(e.itemPattern)||n.arguments.length<1||n.arguments.length>2||!ue.isIdentifier(n.arguments[0],{name:e.itemPattern.name})||n.arguments.length===2&&(e.indexParam===null||!ue.isIdentifier(n.arguments[1],{name:e.indexParam})))&&t("memo-dom: render callback maps must pass their item and optional index bindings directly")}function Oi(e,t){let n=null;for(let r of e?.attributes??[])if(ue.isJSXAttribute(r)&&ue.isJSXIdentifier(r.name,{name:"key"})&&(n=$e(r.value),n===null))return t("memo-dom: key={...} needs an expression");return n}function Ti(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 an(e){return re.isConditionalExpression(e)||re.isLogicalExpression(e)&&(e.operator==="&&"||e.operator==="||")?e:null}function Bi(e){return re.isNullLiteral(e)||re.isBooleanLiteral(e,{value:!1})||re.isIdentifier(e,{name:"undefined"})}function Vi(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(Oe(o)!==null&&ce(o))continue}}}function ln(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||Bi(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&&Vi(l,r);return{pickExpr:o,branches:a,suffix:`when${n.count++}`}}import*as Fe from"@babel/types";import*as ge from"@babel/types";var Dt=class{constructor(t){this.fallback=t}fallback;origins=new WeakMap;trackDeclarator(t,n){if(!ge.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(ge.isIdentifier(i)||ge.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 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&&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=kr(n);if(ge.isIdentifier(r))return this.resolveName(t,r.name);if(!ge.isMemberExpression(r))return null;let o=Wi(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 dn(e,t){return{locality:"module",root:e,key:e,stateKind:t}}function bt(e,t){return e.key===null?e:{...e,key:[e.key,...t].join(".")}}function cn(e,t){if(e.key===null)return null;let n=[];for(let r of t){if(!ge.isObjectExpression(r))return null;for(let o of r.properties){if(!ge.isObjectProperty(o)||o.computed||!ge.isIdentifier(o.key)&&!ge.isStringLiteral(o.key))return null;let i=ge.isIdentifier(o.key)?o.key.name:o.key.value;n.push(`${e.key}.${i}`)}}return n}function un(e){let t=[];for(let n of e)ge.isExpression(n)?t.push(n):ge.isSpreadElement(n)&&t.push(n.argument);return t}function pn(e){return!e.computed&&ge.isIdentifier(e.property)?e.property.name:e.computed&&ge.isStringLiteral(e.property)?e.property.value:null}function Wi(e){let t=e;for(;ge.isMemberExpression(t);){if(ge.isSuper(t.object))return null;t=kr(t.object)}return ge.isIdentifier(t)?t.name:null}function kr(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 We(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)=>Fe.isIdentifier(f)?[[f.name,m]]:[])),a={reads:new Set,writes:new Set,boundedWrites:new Set,parameterWrites:[],unbounded:!1},l=new Dt((f,m)=>{if(s.has(f)&&m?.scope.block===o.node)return{locality:"prop",root:f,key:f};let w=e.state.get(f);return w===void 0||m!==void 0&&!m.scope.path.isProgram()?null:dn(f,w)}),d=f=>f.stateKind==="computed"||e.state.get(f.root)==="computed";n.add(t),o.traverse({VariableDeclarator(f){Fe.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)Fe.isIdentifier(m)&&i.add(m.name)}});let u=(f,m)=>{a.parameterWrites.some(w=>w.index===f&&w.path.length===m.length&&w.path.every((S,I)=>S===m[I]))||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 w=f.key===null?[]:f.key.split(".").slice(1);u(m,w);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 w=l.resolveExpression(f.scope,m);w!==null&&g(w)},y=(f,m)=>{for(let w of un(m)){if(!Fe.isIdentifier(w))continue;let S=l.resolveExpression(f.scope,w);S!==null&&!d(S)&&c(S)}};return o.traverse({VariableDeclarator(f){if(!Fe.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(Fe.isIdentifier(m))if(i.has(m.name)){if(Fe.isIdentifier(f.node.right)){let w=l.resolveExpression(f.scope,f.node.right);w!==null&&c(w)}}else e.state.has(m.name)&&a.writes.add(m.name);else if(Fe.isMemberExpression(m))x(f,m);else for(let w of l.referencedOrigins(f.scope,f.node.right))c(w)},UpdateExpression(f){let m=f.node.argument;Fe.isIdentifier(m)?!i.has(m.name)&&e.state.has(m.name)&&a.writes.add(m.name):Fe.isMemberExpression(m)&&x(f,m)},UnaryExpression(f){f.node.operator==="delete"&&Fe.isMemberExpression(f.node.argument)&&x(f,f.node.argument)},CallExpression(f){let m=f.node.callee;if(Fe.isMemberExpression(m)){if(pn(m)==="assign"&&Fe.isIdentifier(m.object,{name:"Object"})){let I=f.node.arguments[0],$=I!==void 0&&Fe.isExpression(I)?l.resolveExpression(f.scope,I):null;if($!==null){let F=cn($,f.node.arguments.slice(1));if(F===null)c($);else for(let N of F)g({...$,key:N})}return}let S=Fe.isExpression(m.object)?l.resolveExpression(f.scope,m.object):null;S!==null?c(S):y(f,f.node.arguments);return}if(Fe.isIdentifier(m)&&(e.helpers.has(m.name)||e.importedFunctions.has(m.name))){let w=e.importedFunctions.get(m.name)??We(e,m.name,n);for(let S of w.reads)a.reads.add(S);for(let S of w.writes)a.writes.add(S);for(let S of w.boundedWrites)a.boundedWrites.add(S);for(let S of w.parameterWrites){let I=f.node.arguments[S.index];if(I===void 0||!Fe.isExpression(I))continue;let $=l.resolveExpression(f.scope,I);$!==null&&c(bt($,S.path))}w.unbounded&&(a.unbounded=!0);return}y(f,f.node.arguments)},Identifier(f){let m=f.node.name;if(!e.state.has(m)||i.has(m))return;let w=f.parentPath;w.isAssignmentExpression({operator:"="})&&w.node.left===f.node||a.reads.add(m)},MemberExpression(f){let m=zi(e,f);m!==null&&a.reads.add(m)}}),n.delete(t),e.helperSummaries.set(t,a),a}function zi(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||Ki(t)?null:n}function Ki(e){let t=e.parentPath;return t.isCallExpression()&&t.node.callee===e.node}import*as b from"@babel/types";import*as ae from"@babel/types";function Ye(e,t=!1){return{slots:[],tempVar:j(e,"value").name,updateVar:j(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 Qe(e){return ae.variableDeclaration("let",[...e.slots.map(t=>ae.variableDeclarator(ae.identifier(t))),ae.variableDeclarator(ae.identifier(e.tempVar))])}function Jn(e,t){let n=j(e,`slot${t.slots.length}`).name;return t.slots.push(n),n}function $n(e,t,n){let r=t.tagCounters.get(n)??0;return t.tagCounters.set(n,r+1),j(e,`${n}${r}`).name}function Nt(e,t,n,r){let o=()=>ae.identifier(e.tempVar),i=()=>ae.identifier(t);return ae.ifStatement(ae.binaryExpression("!==",i(),ae.assignmentExpression("=",o(),n)),ae.blockStatement([ae.expressionStatement(ae.assignmentExpression("=",i(),o())),r(o())]))}function et(e){return ae.variableDeclaration("const",[ae.variableDeclarator(ae.identifier(e.updateVar),ae.arrowFunctionExpression(e.reasonVar===null?[]:[ae.assignmentPattern(ae.identifier(e.reasonVar),ae.nullLiteral())],ae.blockStatement(e.updaters.map(t=>t()))))])}function ht(e,t,n,r){return ae.expressionStatement(ae.callExpression(Z(e,"register"),[ae.objectExpression([ae.objectProperty(ae.identifier("id"),t),ae.objectProperty(ae.identifier("parent"),n),ae.objectProperty(ae.identifier("render"),r)])]))}function Xn(e){let t=e.replace(/\s+/g," ");return/^\s*\n/.test(e)&&(t=t.replace(/^ /,"")),/\n\s*$/.test(e)&&(t=t.replace(/ $/,"")),t}function Wt(e){return e.some(t=>!b.isJSXText(t)||t.value.trim()!=="")}function dt(e,t,n){let r=e.componentProps.get(t);if(r===void 0)return null;let o=Ve(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=He(r,n.name);if(i!==null)return i;if(n.name==="children"&&e.instanceDerivedBindings.get(t)?.has("children")===!0)return"children"}return null}function tt(e,t,n){let r=dt(e,t,n);return r!==null&&e.componentProps.get(t)?.renderProps.includes(r)===!0}function Nr(e,t,n,r){let o=Ye(e,!0);o.childCounts=t.childCounts,o.usedPrefixes=t.usedPrefixes,o.usedConds=t.usedConds;let i=j(e,"childrenUpdate"),s=j(e,"childrenUpdates"),a=j(e,"childrenMountSequence"),l=j(e,"children"),d=j(e,"childrenParent"),u=j(e,"childrenOwner"),c=j(e,"childrenKey"),g=j(e,"childrenSlot"),x=j(e,"childrenNextUpdate"),y=j(e,"childrenActive"),f=j(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(y),b.booleanLiteral(!0))]),Qe(o),et(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(y)),b.returnStatement()),b.expressionStatement(b.assignmentExpression("=",b.cloneNode(y),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(Z(e,"unregisterSubtree"),[b.cloneNode(m,!0)])))])))]),b.expressionStatement(b.callExpression(Z(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 On(e,t,n,r,o){let i=j(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 Ir(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=Xn(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=Oe(s);if(a!==null){r.emitList(a,n);continue}let l=an(s);if(l!==null&&ce(l)){r.emitCondition(l,n);continue}o(r.emitText(b.cloneNode(s)))}}import*as L from"@babel/types";function gn(e){return L.isIdentifier(e.node.callee,{name:"effect"})&&e.scope.getBinding("effect")===void 0}function mn(e,t){return L.binaryExpression("+",L.identifier(e),L.stringLiteral(`/$effects/${t}`))}function Ui(e,t){return L.binaryExpression("+",mn(e,t),L.stringLiteral("/$active"))}function Hi(e){if(e.isFunctionDeclaration())return e;if(!e.isVariableDeclarator())return null;let t=e.get("init");return t.isArrowFunctionExpression()||t.isFunctionExpression()?t:null}function Lr(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:Hi(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(ce(s.node.body))throw s.buildCodeFrameError("memo-dom: a JSX component cannot be used as an effect callback");return{expression:L.cloneNode(r.node),path:s,importedReads:new Set}}function Fr(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 w of m.bindings)l.set(w,m.sources);for(let m of e.instanceControlFlow.get(t)??[])for(let w of m.bindings)l.set(w,m.sources);for(let m of a){let w=n.scope.getBinding(m);w!==void 0&&s.set(w,{source:m,local:!0})}for(let m of l.keys()){let w=n.scope.getBinding(m);w!==void 0&&s.set(w,{source:m,local:!0})}for(let m of e.state.keys()){let w=n.scope.getBinding(m);w?.scope.path.isProgram()===!0&&s.set(w,{source:m,local:!1})}let d=m=>{let w=m.scope.getBinding(m.node.name),S=w===void 0?void 0:s.get(w);if(S===void 0)return;let I=m.parentPath;!S.local&&e.state.get(S.source)==="store"&&I?.isMemberExpression()&&I.node.object===m.node||(S.local?i.add(S.source):o.add(S.source))},u=m=>{let w=ye(m.node),S=we(m.node);w===null||S===null||e.state.get(S)!=="store"||m.scope.getBinding(S)?.scope.path.isProgram()!==!0||o.add(w)},c=m=>{let w=m.node.callee;if(!L.isIdentifier(w)||m.scope.getBinding(w.name)?.scope.path.isProgram()!==!0||!e.helpers.has(w.name)&&!e.importedFunctions.has(w.name))return;let S=e.importedFunctions.get(w.name)??We(e,w.name);for(let I of S.reads)o.add(I)};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,y=new Set;for(let m of i)a.has(m)&&y.add(m);let f=(m,w)=>{if(w.has(m))return;let S=l.get(m);if(S===void 0){a.has(m)?g.add(m):e.state.has(m)&&o.add(m);return}w.add(m),S.some($=>y.has($))||x.add(m);for(let $ of S)f($,w);w.delete(m)};for(let m of i)f(m,new Set);return{moduleReads:o,localReads:g,localDerivationReads:x}}function Rr(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=we(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)??We(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 Tn(e){if(!e.isExpressionStatement())return null;let t=e.get("expression");return t.isCallExpression()&&gn(t)?t:null}function Ar(e){if(Tn(e)!==null)return!0;let t=!1;return e.traverse({Function(n){n.skip()},CallExpression(n){gn(n)&&(t=!0,n.stop())}}),t}function fn(e,t,n,r){let o=Tn(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(!Ar(i))throw i.buildCodeFrameError("memo-dom: a conditional effect branch may contain only effect() calls, nested if statements, or empty statements");fn(i,t,n,r)}return}if(e.isIfStatement()){let i=e.get("test");fn(e.get("consequent"),t,[...n,{path:i,negated:!1}],r);let s=e.get("alternate");s.node!==null&&fn(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 jr(e){let t=[];for(let n of e){let r=Tn(n);if(r!==null){t.push({callPath:r,rootStatement:n.node,conditions:[]});continue}!n.isIfStatement()||!Ar(n)||fn(n,n.node,[],t)}return t}function Jr(e){return e.length===0?null:e.map(({path:n,negated:r})=>r?L.unaryExpression("!",L.cloneNode(n.node,!0)):L.cloneNode(n.node,!0)).reduce((n,r)=>L.logicalExpression("&&",n,r))}function _i(e,t){let n=[],r=jr(t.get("body"));for(let o of r){let i=Lr(e,o.callPath),s=i.path===null?i.importedReads:Rr(e,i.path),a=new Set;for(let d of o.conditions)for(let u of Rr(e,d.path))a.add(u);let l=n.length;n.push({index:l,statement:o.rootStatement,callback:i.expression,moduleReads:s,condition:Jr(o.conditions),conditionModuleReads:a,entityId:`${e.rootId}/$module-effects/${encodeURIComponent(e.moduleId)}/${l}`})}e.moduleEffects.push(...n)}function $r(e,t){_i(e,t);for(let[n,r]of e.compPaths){let o=[],i=new Set,s=jr(r.get("body").get("body"));for(let l of s){let d=Lr(e,l.callPath),u=d.path===null?{moduleReads:d.importedReads,localReads:new Set,localDerivationReads:new Set}:Fr(e,n,r,d.path),c=new Set,g=new Set,x=new Set;for(let y of l.conditions){let f=Fr(e,n,r,y.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:Jr(l.conditions),conditionModuleReads:c,conditionLocalReads:g,conditionLocalDerivationReads:x}),i.add(l.callPath.node)}if(r.traverse({CallExpression(l){if(!(!gn(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 Dr(e){return e.reduce((t,n)=>L.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=()=>L.identifier(n),a=Dr(i.map(d=>L.binaryExpression("===",s(),L.numericLiteral(d)))),l=Dr(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 Xr(e,t,n,r,o,i){let s=(l,d,u,c,g)=>{if(u.size===0&&c.size===0)return null;let x=L.expressionStatement(L.callExpression(Z(e,"markDirty"),[d]));if(c.size>0&&i!==void 0){let f=[],m=[];for(let S of c){let I=j(e,`eff${l.index}_${g}_${S}`).name;i.creation.push(L.variableDeclaration("let",[L.variableDeclarator(L.identifier(I),L.identifier(S))])),f.push(L.binaryExpression("!==",L.identifier(I),L.identifier(S))),m.push(L.expressionStatement(L.assignmentExpression("=",L.identifier(I),L.identifier(S))))}let w=f.length===1?f[0]:f.reduce((S,I)=>L.logicalExpression("||",S,I));x=L.ifStatement(w,L.blockStatement([...m,x]))}if(r===null)return x;let y=qi(e,t,r,u);return y===null?x:L.ifStatement(y,x)},a=o.flatMap(l=>{let d=l.condition===null?null:s(l,mn(n,l.index),l.conditionLocalReads,l.conditionLocalDerivationReads,"condition"),u=s(l,l.condition===null?mn(n,l.index):Ui(n,l.index),l.localReads,l.localDerivationReads,"callback");return[d,u].filter(c=>c!==null)});return L.blockStatement(a)}function Or(e,t,n){return n.map(r=>L.expressionStatement(L.callExpression(Z(e,r.condition===null?"registerEffect":"registerConditionalEffect"),[mn(t,r.index),L.identifier(t),...r.condition===null?[]:[L.arrowFunctionExpression([],L.cloneNode(r.condition,!0))],L.cloneNode(r.callback,!0)])))}function Mr(){return L.memberExpression(L.metaProperty(L.identifier("import"),L.identifier("meta")),L.identifier("hot"))}function Tr(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(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(Mr(),L.expressionStatement(L.callExpression(L.memberExpression(Mr(),L.identifier("dispose")),[L.arrowFunctionExpression([],L.callExpression(Z(e,"unregisterSubtree"),[L.stringLiteral(l.entityId)]))]))));s.replaceWithMultiple(a)}}function Br(e){e.traverse({CallExpression(t){if(gn(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 Vr(e,t){return e.size===t.size&&[...e].every(n=>t.has(n))}function Wr(e){let t=new Set,n=[];for(let r of e){let o=bn(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 bn(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 Wr(e.body);if(qe.isIfStatement(e)){let t=e.alternate;if(t==null)return null;let n=bn(e.consequent),r=bn(t);return n===null||r===null||!Vr(n.bindings,r.bindings)?null:{bindings:n.bindings,expressions:[e.test,...n.expressions,...r.expressions]}}return null}function Gi(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=Wr(i);if(s===null)return null;if(n=!1,t===null)t=s.bindings;else if(!Vr(t,s.bindings))return null;r.push(...s.expressions)}return t===null||n?null:{bindings:t,expressions:r}}function Zi(e,t){return e.node===t||e.findParent(n=>n.node===t)!==null}function Yi(e,t){let n=e;for(;n?.parentPath!==t;)n=n?.parentPath??null;return n}function zr(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()?bn(s):Gi(s);if(a===null)continue;let l=!0,d=[];for(let y of a.bindings){let f=t.scope.getBinding(y),m=f?.path,w=m?.parentPath,S=m===void 0?null:Yi(m,t);if(f===void 0||!m?.isVariableDeclarator()||!w?.isVariableDeclaration()||w.node.kind!=="let"&&w.node.kind!=="var"||S===null||(o.get(S.node)??Number.MAX_SAFE_INTEGER)>=(o.get(s)??-1)){l=!1;break}d.push(...f.constantViolations.filter(I=>!Zi(I,s)))}if(!l)continue;let u=new Set,c=null;for(let y of a.expressions){let f=n(e,y);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 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,x=[...a.bindings].sort();for(let y of x)mt(e,y,"computed");e.moduleControlFlow.push({statement:s,bindings:x,sources:[...u].sort(),entityId:`${e.rootId}/$computed/${encodeURIComponent(e.moduleId)}#$flow${g}`})}}import*as pe from"@babel/types";function Bn(e,t){let n=new Set,r=!1,o,i=new Set,s=l=>{r||(r=!0,o=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)?we(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)?we(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)??We(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:r,reason:o}}function Kr(e,t){for(let n of t.node.body){let r=pe.isExportNamedDeclaration(n)?n.declaration:n;if(!(!pe.isVariableDeclaration(r)||r.kind!=="const"))for(let o of r.declarations){if(!pe.isIdentifier(o.id)||o.init==null)continue;let i=o.id.name;if(e.state.get(i)==="let"||e.state.get(i)==="computed"||pe.isFunction(o.init)||pe.isJSX(o.init))continue;let s=Bn(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&&(mt(e,i,"computed"),e.computeds.set(i,{reads:s.reads}))}}}import*as Me from"@babel/types";function Ur(e){for(let[t,n]of e.compPaths){let r=new Set;for(let o of n.node.body.body)if(Me.isVariableDeclaration(o)&&!(o.kind!=="let"&&o.kind!=="var"&&o.kind!=="const"))for(let i of o.declarations)Me.isIdentifier(i.id)&&(o.kind==="let"||o.kind==="var"||Pt(i.init)||vt(i.init))&&r.add(i.id.name);r.size>0&&e.instanceState.set(t,r)}}function Hr(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(!Me.isIdentifier(x.id)&&!Me.isObjectPattern(x.id)&&!Me.isArrayPattern(x.id)||x.init==null||Me.isFunction(x.init)||Me.isIdentifier(x.id)&&e.instanceState.get(t)?.has(x.id.name)===!0&&(Pt(x.init)||vt(x.init)))continue;let y=g.get("init");if(!y.isExpression())continue;let f=new Set,m=null,w=(N,K)=>{let _=K.scope.getBinding(N);return _!==void 0&&r.has(_)},S=N=>{if(!Me.isIdentifier(N.node))return;let K=N.scope.getBinding(N.node.name),_=K===void 0?void 0:r.get(K);_!==void 0&&f.add(_)},I=N=>Me.isIdentifier(N)?N.name:Me.isMemberExpression(N)?we(N):null;if(y.isReferencedIdentifier()&&S(y),y.isAssignmentExpression()){let N=I(y.node.left);N!==null&&w(N,y)&&(m="contains an assignment to reactive state")}else if(y.isUpdateExpression()){let N=I(y.node.argument);N!==null&&w(N,y)&&(m="contains an update (++/--) to reactive state")}else y.isAwaitExpression()?m="uses await; per-instance derivations must be synchronous":y.isYieldExpression()&&(m="uses yield; per-instance derivations must be synchronous");if(y.traverse({Function(N){N.skip()},ReferencedIdentifier(N){S(N)},AssignmentExpression(N){let K=I(N.node.left);K!==null&&w(K,N)&&(m="contains an assignment to reactive state")},UpdateExpression(N){let K=I(N.node.argument);K!==null&&w(K,N)&&(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(y.traverse({ReferencedIdentifier(N){S(N)},AssignmentExpression(N){let K=I(N.node.left);K!==null&&w(K,N)&&(m="contains an assignment to reactive state")},UpdateExpression(N){let K=I(N.node.argument);K!==null&&w(K,N)&&(m="contains an update (++/--) to reactive state")}}),m!==null){let N=Bt(x.id);throw g.buildCodeFrameError(`memo-dom: local const '${N.join(", ")||"<pattern>"}' is a per-instance derivation but ${m}`)}let $=Bt(x.id),F=new Set;for(let N of f){let K=s.get(N);if(K===void 0)F.add(N);else for(let _ of K)F.add(_)}o.push({declaration:c.node,target:Me.cloneNode(x.id),source:Me.cloneNode(x.init),bindings:$,sources:[...F].sort()});for(let N of $){i.add(N),s.set(N,new Set(F));let K=n.scope.getBinding(N);K&&r.set(K,N),e.instanceState.get(t)?.delete(N)}}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 fe from"@babel/types";function Kt(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 r=n.callee;t=t&&fe.isMemberExpression(r)&&!r.computed&&fe.isIdentifier(r.object,{name:"Math"})&&fe.isIdentifier(r.property)}}),t}function Qi(e){return!fe.isExpressionStatement(e)||!fe.isAssignmentExpression(e.expression,{operator:"="})||!fe.isIdentifier(e.expression.left)||!Kt(e.expression.right)?null:e.expression.left.name}function _r(e,t){return e.size===t.size&&[...e].every(n=>t.has(n))}function zt(e){if(fe.isExpressionStatement(e)){let t=Qi(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 r of e.body){let o=zt(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(fe.isIfStatement(e)){if(!Kt(e.test))return null;let t=zt(e.consequent);if(t===null)return null;if(e.alternate==null)return{bindings:t.bindings,partial:new Set([...t.bindings,...t.partial])};let n=zt(e.alternate);return n===null||!_r(t.bindings,n.bindings)?null:{bindings:t.bindings,partial:new Set([...t.partial,...n.partial])}}return null}function es(e){if(!Kt(e.discriminant))return null;let t=null;for(let n of e.cases){if(n.test!=null&&!Kt(n.test))return null;let r=[...n.consequent];if(r.at(-1)&&fe.isBreakStatement(r.at(-1))&&r.pop(),r.some(i=>fe.isBreakStatement(i)))return null;let o=zt(fe.blockStatement(r));if(o===null)return null;if(t===null)t=o;else{if(!_r(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 ts(e,t){return e.node===t||e.findParent(n=>n.node===t)!==null}function qr(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()?zt(a.node):es(a.node);if(l===null)continue;let d=!0,u=[],c=[];for(let f of l.bindings){let m=n.scope.getBinding(f),w=m?.path,S=w?.parentPath;if(m===void 0||!w?.isVariableDeclarator()||!S?.isVariableDeclaration()||S.node.kind!=="let"&&S.node.kind!=="var"||m.constantViolations.some(I=>!ts(I,a.node))){d=!1;break}if(l.partial.has(f)){let I=w.get("init");if(!I.isExpression()||!Kt(I.node)){d=!1;break}u.push({binding:f,source:I.node}),c.push(I)}}if(!d)continue;let g=new Set,x=f=>{let m=f.scope.getBinding(f.node.name),w=m===void 0?void 0:r.get(m);w!==void 0&&g.add(w)},y={Function(f){f.skip()},ReferencedIdentifier(f){f.isIdentifier()&&x(f)}};a.traverse(y);for(let f of c)f.isReferencedIdentifier()&&x(f),f.traverse(y);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 Gr(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),y=new Set;for(let f of g)for(let m of i(f,x))y.add(m);return y};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 Ut from"@babel/types";function ns(e){let t=e.indexOf("[");return t<0?e:e.slice(0,t)}function Et(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(ns(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 Ge(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=>Ge(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 Ge(e,d.owner,n))l.push(`${u}/${d.suffix}`);for(let d of a)for(let u of Ge(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 Ge(e,d,n))u>1?l.push(`${c}/${t}`,`${c}/${t}[*]`):l.push(`${c}/${t}`)}return n.delete(t),l}function Vn(e,t){let n=e.linkedComponentPaths.get(t);if(n!==void 0)return Et(e,n.flatMap(i=>[i,`${i}/*`]));let r=e.listedSites.get(t),o=[];if(r&&r.length>0){if(Mt(e,t)){for(let i of r){let s=i.suffix.lastIndexOf("/"),a=s<0?"":`/${i.suffix.slice(0,s)}`;for(let l of Ge(e,i.owner))o.push(`${l}${a}`,`${l}${a}/*`)}return Et(e,o)}for(let i of r)for(let s of Ge(e,i.owner))o.push(`${s}/${i.suffix}/Row[*]`,`${s}/${i.suffix}/Row[*]/*`);return Et(e,o)}for(let i of Ge(e,t))o.push(i,`${i}/*`);return Et(e,o)}function Mt(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&&hn(e,t)&&(o=!0),e.lightweightCache.set(t,o),o}function hn(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;Ut.isJSXIdentifier(i)&&/^[A-Z]/.test(i.name)&&(n=!1)},CallExpression(o){(Ut.isIdentifier(o.node.callee,{name:"cleanup"})&&o.scope.getBinding("cleanup")===void 0||Ut.isIdentifier(o.node.callee,{name:"effect"})&&o.scope.getBinding("effect")===void 0)&&(n=!1),Oe(o.node)&&De(o)&&(n=!1)},ConditionalExpression(o){De(o)&&(n=!1)},LogicalExpression(o){De(o)&&(n=!1)}}),n}import*as z from"@babel/types";function Zr(e,t){let n=e.findParent(r=>r.isFunctionDeclaration()||r.isFunctionExpression()||r.isArrowFunctionExpression());return n===t?!0:n?.findParent(r=>r===t)!==null}function Wn(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(!z.isJSXIdentifier(s)||!/^[A-Z]/.test(s.name))return!1;let a=z.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 rs(e,t){if(z.isArrayExpression(e))return e;if(!z.isIdentifier(e))return null;let n=t.scope.getBinding(e.name);return n?.path.isVariableDeclarator()&&z.isArrayExpression(n.path.node.init)?n.path.node.init:null}function zn(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||z.isNullLiteral(o)||z.isBooleanLiteral(o))){if(z.isSpreadElement(o)){if(!z.isExpression(o.argument))throw t.buildCodeFrameError("memo-dom: JSX array spreads must resolve to a static JSX array");let i=rs(o.argument,t);if(i===null)throw t.buildCodeFrameError("memo-dom: JSX array spreads must resolve to a static JSX array");r.push(...zn(i,t,n));continue}if(z.isArrayExpression(o)){r.push(...zn(o,t,n));continue}if(z.isJSXElement(o)||z.isJSXFragment(o)){r.push(z.cloneNode(o,!0));continue}if(!z.isExpression(o))throw t.buildCodeFrameError("memo-dom: JSX arrays require renderable expression entries");r.push(z.jsxExpressionContainer(z.cloneNode(o,!0)))}}finally{n.delete(e)}return r}function Yr(e,t){return z.jsxFragment(z.jsxOpeningFragment(),z.jsxClosingFragment(),zn(e,t))}function os(e,t){return z.isArrayExpression(e)?e.elements.map((n,r)=>{if(n==null||z.isSpreadElement(n))throw t.buildCodeFrameError("memo-dom: JSX arrays cannot contain holes or spread elements");return{key:z.numericLiteral(r),value:n}}):e.properties.map(n=>{if(!z.isObjectProperty(n)||n.computed||!z.isExpression(n.value))throw t.buildCodeFrameError("memo-dom: JSX objects require static data properties without spreads");let r=z.isIdentifier(n.key)?z.stringLiteral(n.key.name):z.isStringLiteral(n.key)||z.isNumericLiteral(n.key)?z.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 is(e,t){let n=e.node,r=null;if(!n.computed&&z.isIdentifier(n.property)?r=n.property.name:n.computed&&(z.isStringLiteral(n.property)||z.isNumericLiteral(n.property))&&(r=n.property.value),r!==null){let i=t.find(s=>(z.isStringLiteral(s.key)||z.isNumericLiteral(s.key))&&s.key.value===r);if(i===void 0)throw e.buildCodeFrameError(`memo-dom: JSX collection has no entry for '${r}'`);return z.cloneNode(i.value,!0)}if(!n.computed||!z.isExpression(n.property))throw e.buildCodeFrameError("memo-dom: JSX collection selection requires a static or expression key");let o=z.nullLiteral();for(let i=t.length-1;i>=0;i--){let s=t[i];o=z.conditionalExpression(z.binaryExpression("===",z.cloneNode(n.property,!0),z.cloneNode(s.key,!0)),z.cloneNode(s.value,!0),o)}return o}function Qr(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()||!ce(i.node)||(o.replaceWith(Yr(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(!z.isIdentifier(a.id)||l==null||!ce(l))continue;let d=s.scope.getBinding(a.id.name);if(d?.path!==s)continue;let u=[...d.referencePaths];if(z.isObjectExpression(l)||z.isArrayExpression(l))for(let c of u){if(!c.isIdentifier()||!Zr(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(!Wn(g,e))throw g.buildCodeFrameError(`memo-dom: JSX collection '${a.id.name}' is used outside a render position`);g.replaceWith(is(g,os(l,s)));continue}if(z.isArrayExpression(l)&&c.parentPath?.isSpreadElement()&&c.parentPath.parentPath?.isArrayExpression()){c.replaceWith(z.cloneNode(l,!0));continue}if(z.isArrayExpression(l)&&Wn(c,e)){c.replaceWith(Yr(l,c));continue}throw c.buildCodeFrameError(z.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()||!Zr(c,t))){if(!Wn(c,e))throw c.buildCodeFrameError(`memo-dom: JSX value '${a.id.name}' is used outside a render position`);c.replaceWith(z.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)&&(z.isJSXElement(i)||z.isJSXFragment(i))&&o.replaceWith(i)}}),t.scope.crawl())}}import*as R from"@babel/types";function Kn(e){return R.isReturnStatement(e)&&R.isExpression(e.argument)?e.argument:R.isBlockStatement(e)&&e.body.length===1?Kn(e.body[0]):null}function Lt(e){let t=Kn(e);if(t!==null)return t;if(R.isIfStatement(e)&&e.alternate!=null){let n=Lt(e.consequent),r=Lt(e.alternate);return n===null||r===null?null:R.conditionalExpression(R.cloneNode(e.test,!0),R.cloneNode(n,!0),R.cloneNode(r,!0))}if(R.isSwitchStatement(e)){let n=e.cases.find(o=>o.test==null);if(n===void 0||n.consequent.length!==1)return null;let r=Lt(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=Lt(i.consequent[0]);if(s===null)return null;r=R.conditionalExpression(R.binaryExpression("===",R.cloneNode(e.discriminant,!0),R.cloneNode(i.test,!0)),R.cloneNode(s,!0),r)}return r}return null}function ss(e,t){if(R.isExpression(e.body))return{expression:R.cloneNode(e.body,!0),locals:new Map};let n=new Map,r=[];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)||r.push(s)}if(r.length===1){let s=Lt(r[0]);if(s!==null)return{expression:s,locals:n}}let o=r.at(-1),i=o===void 0?null:Kn(o);if(i!==null){let s=R.cloneNode(i,!0);for(let a=r.length-2;a>=0;a--){let l=r[a];if(R.isIfStatement(l)&&l.alternate==null){let d=Lt(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 as(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 eo(e,t,n=new Set){let r=R.cloneNode(e,!0),o=(i,s,a,l)=>{if(R.isIdentifier(i)&&!l.has(i.name)&&t.has(i.name)&&(s===null||!as(s,a)))return R.cloneNode(t.get(i.name),!0);let d=l;if(R.isFunction(i)&&i!==r){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?o(g,i,u,d):g):c!=null&&typeof c=="object"&&"type"in c&&(i[u]=o(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 o(r,null,"",n)}function ls(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=>R.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&&R.isExpression(d)?d:R.identifier("undefined");if(R.isIdentifier(l)){o.set(l.name,R.cloneNode(u,!0));continue}if(R.isAssignmentPattern(l)&&R.isIdentifier(l.left)){o.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=ss(r,n);for(let[a,l]of i.locals)o.set(a,eo(l,o));let s=eo(i.expression,o);return ce(s)||n("memo-dom: JSX render function expansion did not produce JSX"),s}function ds(e,t){let n=t.get("callee");return Array.isArray(n)||!n.isIdentifier()?null:to(e,n)}function to(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()&&ce(o.path.node))return{node:o.path.node,bindingPath:o.path};if(o?.path.isVariableDeclarator()){let i=o.path.node.init;if((R.isFunctionExpression(i)||R.isArrowFunctionExpression(i))&&ce(i.body))return{node:i,bindingPath:o.path}}return null}function no(e){return R.isMemberExpression(e.callee)&&!e.callee.computed&&R.isIdentifier(e.callee.property,{name:"map"})}function cs(e){let t=e.parentPath;return t?.isCallExpression()===!0&&(t.node.callee===e.node||no(t.node)&&t.node.arguments[0]===e.node)}function us(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(r=>R.cloneNode(r,!0)),R.cloneNode(n.body,!0))}function En(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()&&En(t)}}}function ps(e,t){let n=t.findParent(r=>r.isProgram());if(n===null||!n.isProgram()){En(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()&&R.isIdentifier(a.node.id,{name:e}));if(s!==void 0){i.length===1?r.remove():s.remove();return}}En(t)}function fs(e,t){let n=e.parentPath,r=n?.parentPath;if((R.isJSXElement(t)||R.isJSXFragment(t))&&n?.isJSXExpressionContainer()&&(r?.isJSXElement()||r?.isJSXFragment())&&r.node.children.includes(n.node)){n.replaceWith(t);return}e.replaceWith(t)}function ro(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()&&!cs(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(!no(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=to(e,i);s!==null&&(i.replaceWith(us(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=ds(e,i);s!==null&&(fs(i,ls(s,i)),t.add(s.bindingPath),r=!0)}}}for(let[n,r]of e.jsxHelpers)ps(n,r);for(let n of t)En(n)}import*as ze from"@babel/types";function ms(e){let t=jn(e);return ze.isIdentifier(t)||ze.isMemberExpression(t)||sn(t)}function gs(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 bs(e,t){return e.findParent(n=>n.isFunctionDeclaration()||n.isFunctionExpression()||n.isArrowFunctionExpression())===t}function oo(e){for(let[,t]of e.compPaths){let n=[];if(t.traverse({CallExpression(s){if(Oe(s.node)===null||!ze.isMemberExpression(s.node.callee)||!ze.isExpression(s.node.callee.object)||ms(s.node.callee.object)||!bs(s,t))return;let a=gs(s,t);a!==null&&n.push({path:s,source:ze.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=j(e,"listView");i.push(ze.variableDeclarator(ze.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(ze.cloneNode(a))}n[0].statement.insertBefore(ze.variableDeclaration("const",i)),t.scope.crawl()}}import*as Te from"@babel/types";var hs=new Set(["==","==="]);function yn(e,t,n){if(n(e,t),!Te.isFunction(e))for(let r of Te.VISITOR_KEYS[e.type]??[]){let o=e[r];if(Array.isArray(o))for(let i of o)i&&yn(i,e,n);else o&&yn(o,e,n)}}function io(e,t,n){if(!Te.isBinaryExpression(t)||!hs.has(t.operator))return!1;let r=t.left===e?t.right:t.left;return Te.isExpression(r)&&Te.isNodesEquivalent(r,n)}function so(e,t){if(e.jsx===null||e.keyExpr===null||!e.sourceLocal||!Te.isIdentifier(e.sourceExpr)||!t.has(e.sourceExpr.name))return[];let n=e.sourceExpr.name,r=new Set;if(yn(e.jsx,null,(i,s)=>{Te.isIdentifier(i)&&t.has(i.name)&&i.name!==n&&io(i,s,e.keyExpr)&&r.add(i.name)}),r.size===0)return[];let o=new Set;return yn(e.jsx,null,(i,s)=>{Te.isIdentifier(i)&&r.has(i.name)&&Te.isReferenced(i,s)&&!io(i,s,e.keyExpr)&&o.add(i.name)}),[...r].filter(i=>!o.has(i)).sort()}import*as P from"@babel/types";function Es(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 Sn(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,Es(x)),o.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 o.reverse())t.unshiftContainer("body",i);t.scope.crawl()}function Un(e){let t=e;for(;P.isTSAsExpression(t)||P.isTSTypeAssertion(t)||P.isTSNonNullExpression(t);)t=t.expression;return t}function ao(e){return P.isJSXIdentifier(e)?P.identifier(e.name):P.memberExpression(ao(e.object),P.identifier(e.property.name))}function lo(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=Un(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 ys(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()&&(P.isFunctionExpression(n.path.node.init)||P.isArrowFunctionExpression(n.path.node.init))&&(r=n.path.node.init),r===null?[]:co(r)}function co(e){if(P.isExpression(e.body))return[e.body];let t=[],n=r=>{if(!P.isFunction(r)){if(P.isReturnStatement(r)){P.isExpression(r.argument)&&t.push(r.argument);return}for(let o of P.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 yt(e,t,n,r=new Set){let o=Un(t);if(!r.has(o)){if(r.add(o),P.isIdentifier(o)&&(e.comps.has(o.name)||e.importedComponents.has(o.name))){n.add(o.name);return}if(P.isIdentifier(o)){for(let i of e.stateComponentCandidates.get(o.name)??e.functionComponentCandidates.get(o.name)??[])n.add(i);return}if(P.isConditionalExpression(o)){yt(e,o.consequent,n,r),yt(e,o.alternate,n,r);return}if(P.isLogicalExpression(o)){yt(e,o.right,n,r);return}if(P.isObjectExpression(o)){for(let i of o.properties)P.isObjectProperty(i)&&P.isExpression(i.value)&&yt(e,i.value,n,r);return}if(P.isArrayExpression(o)){for(let i of o.elements)i!=null&&!P.isSpreadElement(i)&&yt(e,i,n,r);return}if(P.isCallExpression(o)&&P.isIdentifier(o.callee)){for(let i of e.functionComponentCandidates.get(o.callee.name)??[])n.add(i);return}if(P.isMemberExpression(o)){let i=we(o);if(i!==null)for(let s of e.stateComponentCandidates.get(i)??[])n.add(s)}}}function uo(e,t){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)||i.init==null)continue;let s=new Set;yt(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;(P.isFunctionDeclaration(a)||P.isFunctionExpression(a)||P.isArrowFunctionExpression(a))&&(s=co(a));for(let l of s)yt(e,l,i);i.size>0&&i.size!==(e.functionComponentCandidates.get(r)?.length??0)&&(e.functionComponentCandidates.set(r,[...i]),n=!0)}}}function Ze(e,t,n,r,o=new Set){let i=Un(n);if(!o.has(i)){if(o.add(i),P.isConditionalExpression(i)){Ze(e,t,i.consequent,r,o),Ze(e,t,i.alternate,r,o);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`);r.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)){r.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)Ze(e,t,P.stringLiteral(l),r,o);let a=t.scope.getBinding(i.name);a?.path.isVariableDeclarator()&&a.path.node.init!=null&&Ze(e,t,a.path.node.init,r,o);return}if(P.isCallExpression(i)&&P.isIdentifier(i.callee)){for(let s of e.functionTagCandidates.get(i.callee.name)??[])Ze(e,t,P.stringLiteral(s),r,o);for(let s of ys(t,i.callee.name))Ze(e,t,s,r,o);for(let s of e.functionComponentCandidates.get(i.callee.name)??[])Ze(e,t,P.identifier(s),r,o);return}if(P.isMemberExpression(i)){let s=lo(t,i);if(s!==null){Ze(e,t,s,r,o);return}let a=we(i);if(a===null)return;let l=t.scope.getBinding(a);if(l?.path.isVariableDeclarator()&&l.path.node.init!=null){let d=new Set;yt(e,l.path.node.init,d);for(let u of d)Ze(e,t,P.identifier(u),r,o)}for(let d of e.stateTagCandidates.get(a)??[])Ze(e,t,P.stringLiteral(d),r,o);for(let d of e.stateComponentCandidates.get(a)??[])Ze(e,t,P.identifier(d),r,o)}}}function Ss(e){return P.isStringLiteral(e.compare)?`string:${e.compare.value}`:P.isIdentifier(e.compare)?`component:${e.compare.name}`:JSON.stringify(e.compare)}function xs(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(r=>r.isAssignmentExpression()&&r.node.operator==="="&&P.isExpression(r.node.right)?[r.node.right]:[])]:[]}if(P.isMemberExpression(t)){let n=lo(e,t),r=ye(t),o=[];return r!==null&&(e.getFunctionParent()??e.findParent(a=>a.isProgram()))?.traverse({AssignmentExpression(a){a.node.operator==="="&&P.isMemberExpression(a.node.left)&&ye(a.node.left)===r&&P.isExpression(a.node.right)&&o.push(a.node.right)}}),[...n===null?[]:[n],...o]}return[]}function po(e,t){let n=P.cloneNode(e,!0);n.openingElement.name=P.cloneNode(t);let r=n.closingElement;return r!=null&&(r.name=P.cloneNode(t)),n}function Cs(e,t,n){let r=P.nullLiteral();for(let o=n.length-1;o>=0;o--){let i=n[o];r=P.conditionalExpression(P.binaryExpression("===",P.cloneNode(e,!0),P.cloneNode(i.compare,!0)),po(t,i.tag),r)}return r}function ws(e){return P.isIdentifier(e)?e.name:P.isMemberExpression(e)?ye(e)??"<member expression>":"<expression>"}function fo(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(P.isJSXNamespacedName(i))throw o.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=ao(i),a=xs(o,s),l=[];for(let u of a)Ze(e,o,u,l);let d=[...new Map(l.map(u=>[Ss(u),u])).values()];if(d.length===0)throw o.buildCodeFrameError(`memo-dom: dynamic JSX tag '${ws(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 x of o.node.openingElement.attributes){if(P.isJSXSpreadAttribute(x)||!P.isJSXIdentifier(x.name)||!c.renderProps.includes(x.name.name))continue;let y=$e(x.value),f=g.get(x.name.name)??{scalar:!1,jsx:!1,at:o};y!==null&&ce(y)?f.jsx=!0:f.scalar=!0,g.set(x.name.name,f)}}if(d.length===1){o.replaceWith(po(o.node,d[0].tag));continue}o.replaceWith(P.jsxFragment(P.jsxOpeningFragment(),P.jsxClosingFragment(),[P.jsxExpressionContainer(Cs(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 ne from"@babel/types";function Hn(e){return ne.isExportNamedDeclaration(e)?e.declaration??null:ne.isDeclaration(e)?e:null}function mo(e){let t=new Map;for(let n of e.body){let r=Hn(n);ne.isTSTypeAliasDeclaration(r)&&t.set(r.id.name,r.typeAnnotation)}return t}function ct(e,t,n=new Set){if(ne.isTSLiteralType(e)&&ne.isStringLiteral(e.literal))return[e.literal.value];if(ne.isTSUnionType(e))return e.types.flatMap(r=>ct(r,t,n));if(ne.isTSIntersectionType(e))return e.types.flatMap(r=>ct(r,t,n));if(ne.isTSParenthesizedType(e))return ct(e.typeAnnotation,t,n);if(ne.isTSTypeLiteral(e))return e.members.flatMap(r=>(ne.isTSPropertySignature(r)||ne.isTSIndexSignature(r))&&ne.isTSTypeAnnotation(r.typeAnnotation)&&ne.isTSType(r.typeAnnotation.typeAnnotation)?ct(r.typeAnnotation.typeAnnotation,t,n):[]);if(ne.isTSMappedType(e)&&e.typeAnnotation!=null&&ne.isTSType(e.typeAnnotation))return ct(e.typeAnnotation,t,n);if(ne.isTSTypeReference(e)&&ne.isIdentifier(e.typeName)){let r=e.typeName.name;if((r==="Record"||r==="Readonly"||r==="Partial")&&ne.isTSTypeParameterInstantiation(e.typeArguments)){let s=r==="Record"?e.typeArguments.params[1]:e.typeArguments.params[0];if(s!==void 0&&ne.isTSType(s))return ct(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),ct(o,t,i)}return[]}function xn(e){let t=mo(e),n=new Map;for(let r of e.body){let o=Hn(r);if(ne.isVariableDeclaration(o))for(let i of o.declarations){if(!ne.isIdentifier(i.id)||!ne.isTSTypeAnnotation(i.id.typeAnnotation))continue;let s=[...new Set(ct(i.id.typeAnnotation.typeAnnotation,t))];s.length>0&&n.set(i.id.name,s)}}return n}function _n(e){let t=mo(e),n=new Map,r=(o,i)=>{if(!ne.isTSTypeAnnotation(i)||!ne.isTSType(i.typeAnnotation))return;let s=[...new Set(ct(i.typeAnnotation,t))];s.length>0&&n.set(o,s)};for(let o of e.body){let i=Hn(o);if(ne.isFunctionDeclaration(i)&&i.id!=null){r(i.id.name,i.returnType);continue}if(ne.isVariableDeclaration(i))for(let s of i.declarations)ne.isIdentifier(s.id)&&(ne.isArrowFunctionExpression(s.init)||ne.isFunctionExpression(s.init))&&r(s.id.name,s.init.returnType)}return n}import*as it from"@babel/types";import*as Ee from"@babel/types";function Ht(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=Ae(a.name);if(l==="key"&&t.skipKey)continue;let d=Ps(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 Ae(e){return Ee.isJSXIdentifier(e)?e.name:`${e.namespace.name}:${e.name.name}`}function Ps(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 Cn(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(!(!it.isJSXIdentifier(a)||!/^[A-Z]/.test(a.name)))for(let l of Cn(e,a.name,n))o.add(l)}}),n.delete(t),o}function go(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(!it.isJSXIdentifier(s))return;let a=Ae(o.node.name);if(e.componentProps.get(s.name)?.renderCallbacks.includes(a)!==!0)return;let l=o.node.value;!it.isJSXExpressionContainer(l)||!it.isExpression(l.expression)||Xe(l.expression,d=>{if(it.isJSXOpeningElement(d)&&it.isJSXIdentifier(d.name)&&/^[A-Z]/.test(d.name.name))for(let u of Cn(e,d.name.name))r.add(u)})}})}}import*as St from"@babel/types";function bo(e){for(let[t,n]of e.compPaths){let r=e.componentProps.get(t);n.traverse({JSXAttribute(o){if(Ae(o.node.name)!=="ref")return;let i=o.node.value;if(!(!St.isJSXExpressionContainer(i)||!St.isExpression(i.expression)))for(let s of ho(e,t,i.expression))r.refProps.includes(s)||r.refProps.push(s)}})}}function ho(e,t,n){let r=dt(e,t,n);if(r!==null)return[r];if(!St.isArrayExpression(n))return[];let o=[];for(let i of n.elements)i===null||St.isSpreadElement(i)||o.push(...ho(e,t,i));return o}import*as It from"@babel/types";function wn(e){let t=!1;return Xe(e,n=>{if(t||!It.isJSXOpeningElement(n))return;let r=n.name;!It.isJSXIdentifier(r)||!/^[a-z]/.test(r.name)||(t=n.attributes.some(o=>It.isJSXAttribute(o)&&It.isJSXIdentifier(o.name)&&/^on[A-Z]/.test(o.name.name)))}),t}import*as je from"@babel/types";function qn(e){let t=(r,o)=>{let i=_e(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=Vn(e,r);for(let s of o)t(s,i)}for(let{owner:r,suffix:o,vars:i}of e.rowReads.values()){let s=Et(e,Ge(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=Et(e,Ge(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=Vn(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])=>je.objectProperty(je.stringLiteral(r),je.arrayExpression([...o].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 yo(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(!k.isJSXIdentifier(o)||!/^[A-Z]/.test(o.name))return!1;let i=n.node.name,s=k.isJSXIdentifier(i)?i.name:i.name.name;return e.componentProps.get(o.name)?.renderProps.includes(s)===!0}function Eo(e,t){let n=t.parentPath,r=n?.parentPath;if(!n?.isJSXExpressionContainer()||!r?.isJSXElement()&&!r?.isJSXFragment()&&!yo(e,n))throw t.buildCodeFrameError("memo-dom: conditional rendering must be a direct JSX child: <div>{cond ? <A/> : <B/>}</div>");t.skip()}function vs(e,t){for(let n of t.get("body"))if(!(!n.isImportDeclaration()||n.node.importKind==="type"))for(let r of n.node.specifiers){if(k.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 ks(e,t){let n=xn(t.node);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)&&(o.kind==="let"||o.kind==="var"?mt(e,i.id.name,"let"):o.kind==="const"&&(Pt(i.init)?mt(e,i.id.name,"store"):vt(i.init)&&mt(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 Ns(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(De(n))if(/^[A-Z]/.test(r)){e.comps.set(r,{parents:new Set,jsxCount:0}),e.compPaths.set(r,n),wn(n.node.body)&&e.componentsWithHostEvents.add(r);try{e.componentProps.set(r,rn(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()||!k.isIdentifier(n.node.id))return;let r=n.get("init");(r.isArrowFunctionExpression()||r.isFunctionExpression())&&(ce(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");!k.isIdentifier(i)||/^[A-Z]/.test(i.name)||Array.isArray(s)||!s.isArrowFunctionExpression()&&!s.isFunctionExpression()||!ce(s.node.body)||(e.helpers.delete(i.name),e.jsxHelpers.set(i.name,s))}}}function Pn(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 Pn(e.typeAnnotation,t,n);if(k.isTSUnionType(e))return e.types.every(r=>Pn(r,t,n));if(k.isTSTypeReference(e)&&k.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=k.isExportNamedDeclaration(i)?i.declaration:i;if(k.isTSTypeAliasDeclaration(s)&&s.id.name===r)return Pn(s.typeAnnotation,t,o)}}return!1}function Is(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 r=e.node.params[0];if(r==null||k.isTSParameterProperty(r))return!1;let o=k.isAssignmentPattern(r)?r.left:r;if(!k.isIdentifier(o)&&!k.isObjectPattern(o)&&!k.isArrayPattern(o))return!1;let i=o.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 Pn(l.typeAnnotation.typeAnnotation,s.node)}return!1}function Gn(e,t=new Set){if(ce(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?Gn(r,t):!1}}if(e.isMemberExpression()){let n=e.get("object");return!Array.isArray(n)&&Gn(n,t)}return!1}function Fs(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(!k.isExpression(l))return;let d=dt(e,o,l);d!==null&&(Is(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(!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,x=k.isJSXIdentifier(g)?g.name:g.name.name;if(!d.has(x))continue;let y=u.get(x)??{scalar:!1,jsx:!1,at:c},f=c.get("value"),m=!1;if(f.isJSXExpressionContainer()&&k.isExpression(f.node.expression)){let w=f.get("expression");!Array.isArray(w)&&(Gn(w)||k.isExpression(w.node)&&dt(e,o,w.node)!==null)&&(m=!0)}m?y.jsx=!0:y.scalar=!0,u.set(x,y)}}});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()||!k.isExpression(l.node.expression))return;let d=dt(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(!k.isJSXIdentifier(c)||!/^[A-Z]/.test(c.name))return;let g=e.componentProps.get(c.name),x=a.node.name,y=k.isJSXIdentifier(x)?x.name:x.name.name;g?.renderProps.includes(y)===!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 Rs(e,t){let n=e.compPaths.get(t),r=e.comps.get(t);n.traverse({JSXElement(o){let i=o.node.openingElement;if(!k.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(!k.isJSXSpreadAttribute(a)&&a.name.name==="key"){if(Pr(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=>!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&&ce(u)}))&&e.renderSlotOwners.add(t);return}r.jsxCount++},ConditionalExpression(o){De(o)&&Eo(e,o)},LogicalExpression(o){if(De(o)){if(o.node.operator!=="&&"&&o.node.operator!=="||")throw o.buildCodeFrameError("memo-dom: only && / || conditionals are supported (R8 L1), not ??");Eo(e,o)}},CallExpression(o){let i=Oe(o.node);if(i&&(De(o)||Rt(e,t,i)!==null)){let s=o.parentPath,a=s?.parentPath;if(!s?.isJSXExpressionContainer()||!a?.isJSXElement()&&!a?.isJSXFragment()&&!yo(e,s))throw o.buildCodeFrameError("memo-dom: list rendering must be a direct JSX child: <ul>{items.map(item => <Row />)}</ul>");o.skip()}}})}function Ds(e){let t=e.parentPath;return t.isCallExpression()&&t.node.callee===e.node}function Ms(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||Ds(t)?null:n}function Ls(e){for(let[a]of e.comps){let g=function(S,I,$){let F=Oe(S.node);if(F===null||!De(S))return;let N=kt(e,F,S,a,$),K=`${I}/${N.suffix}`;if(N.form==="component"){let _=e.listedSites.get(N.rowComp)??[];_.some(V=>V.owner===a&&V.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 m(S,N,K);S.skip()},x=function(S,I,$){let F=S.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 S.buildCodeFrameError(`memo-dom: <${F.name} /> is not a linked component factory`);let N=$.get(F.name)??0;$.set(F.name,N+1);let K=N===0?F.name:`${F.name}[${N}]`,_=`${I}/${K}`,V=e.conditionalComponentSites.get(F.name)??[];V.some(O=>O.owner===a&&O.suffix===_)||V.push({owner:a,suffix:_}),e.conditionalComponentSites.set(F.name,V)},y=function(S,I,$){let F=S.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 S.buildCodeFrameError(`memo-dom: <${F.name} /> is not a linked component factory`);let N=$.get(F.name)??0;$.set(F.name,N+1);let K=N===0?F.name:`${F.name}[${N}]`,_=`${I}/Row[*]/${K}`,V=e.rowComponentSites.get(F.name)??[];V.some(O=>O.owner===a&&O.suffix===_)||V.push({owner:a,suffix:_}),e.rowComponentSites.set(F.name,V)},f=function(S,I){let $=e.listedSites.get(S.rowComp)??[];$.some(F=>F.owner===a&&F.suffix===I)||$.push({owner:a,suffix:I,itemParam:S.itemParam,keyExpr:S.keyExpr,sourceKey:S.sourceKey,sourceLocal:S.sourceLocal}),e.listedSites.set(S.rowComp,$)},m=function(S,I,$){let F=S.get("arguments")[0];if(F===void 0)return;let N=new Set,K=new Map,_=new Map;F.traverse({Identifier(V){V.node.name!==I.itemParam&&e.state.has(V.node.name)&&V.scope.getBinding(V.node.name)?.scope.path.isProgram()===!0&&N.add(V.node.name)},JSXElement(V){y(V,$,K)},CallExpression(V){let O=Oe(V.node);if(O!==null&&De(V)){let te=kt(e,O,V,a,_,I),q=`${$}/Row[*]/${te.suffix}`;te.form==="component"?f(te,q):m(V,te,q),V.skip();return}let le=V.node.callee;if(k.isIdentifier(le)&&(e.helpers.has(le.name)||e.importedFunctions.has(le.name))){let te=e.importedFunctions.get(le.name)??We(e,le.name);for(let q of te.reads)N.add(q)}}}),N.size>0&&e.rowReads.set(`${a}/${$}`,{owner:a,suffix:$,vars:N})},w=function(S,I=null){let $=S.node;if(!De(S))return;let F=ln($,S,c),N=I===null?F.suffix:`${I}/${F.suffix}`,K=[];if(S.isConditionalExpression()){let V=S;for(;V.isConditionalExpression();)K.push(V.get("consequent")),V=V.get("alternate");K.push(V)}else K.push(S.get("right"));for(let V of K){let O=new Map,le=new Map;if((V.isConditionalExpression()||V.isLogicalExpression())&&De(V)){w(V,N);continue}V.isJSXElement()&&x(V,N,le),V.traverse({ConditionalExpression(te){De(te)&&(w(te,N),te.skip())},LogicalExpression(te){De(te)&&(w(te,N),te.skip())},JSXElement(te){x(te,N,le)},CallExpression(te){g(te,N,O)}})}let _=tn(e,$);_.size>0&&I===null&&e.condReads.set(`${a}/${N}`,{owner:a,suffix:N,vars:_}),S.skip()};var t=g,n=x,r=y,o=f,i=m,s=w;let l=e.compPaths.get(a),d=new Set,u=new Map,c={count:0};l.traverse({JSXAttribute(S){let I=S.node.name;(k.isJSXIdentifier(I,{name:"ref"})||k.isJSXNamespacedName(I)&&I.namespace.name==="ref")&&S.skip()},ConditionalExpression(S){w(S)},LogicalExpression(S){w(S)},CallExpression(S){if(k.isIdentifier(S.node.callee,{name:"effect"})&&S.scope.getBinding("effect")===void 0){S.skip();return}let I=Oe(S.node);if(I&&(De(S)||Rt(e,a,I)!==null)){let F=kt(e,I,S,a,u),N=so(F,e.instanceState.get(a)??new Set);if(N.length>0&&k.isIdentifier(F.sourceExpr)){let K=F.sourceExpr.name;e.targetedListDependencies.set(I,N.map(V=>({source:K,value:V}))),e.targetedListComponents.add(a);let _=new Set([...e.instanceReasonIds.get(a)?.keys()??[],K,...N]);e.instanceReasonIds.set(a,new Map([..._].sort().map((V,O)=>[V,O])))}if(F.sourceLocal||d.add(F.sourceKey),F.form==="component"){for(let _ of F.jsx.openingElement.attributes){if(k.isJSXSpreadAttribute(_))continue;let V=_,O=k.isJSXIdentifier(V.name)?V.name.name:`${V.name.namespace.name}:${V.name.name.name}`;if(O==="key"||O==="ref"||e.componentProps.get(F.rowComp)?.refProps.includes(O)===!0)continue;let le=$e(V.value);le&&Xe(le,te=>{if(k.isIdentifier(te)&&e.state.has(te.name)&&S.scope.getBinding(te.name)?.scope.path.isProgram()===!0&&d.add(te.name),k.isMemberExpression(te)){let q=ye(te);if(q!==null&&q.includes(".")){let Q=q.split(".")[0];e.state.get(Q)==="store"&&S.scope.getBinding(Q)?.scope.path.isProgram()===!0&&d.add(q)}}})}let K=e.listedSites.get(F.rowComp)??[];K.some(_=>_.owner===a&&_.suffix===F.suffix)||K.push({owner:a,suffix:F.suffix,itemParam:F.itemParam,keyExpr:F.keyExpr,sourceKey:F.sourceKey,sourceLocal:F.sourceLocal}),e.listedSites.set(F.rowComp,K)}else m(S,F,F.suffix);S.skip();return}let $=S.node.callee;if(k.isIdentifier($)&&(e.helpers.has($.name)||e.importedFunctions.has($.name))&&S.scope.getBinding($.name)?.scope.path.isProgram()===!0){let F=e.importedFunctions.get($.name)??We(e,$.name);for(let N of F.reads)d.add(N)}},Identifier(S){if(!e.state.has(S.node.name)||S.scope.getBinding(S.node.name)?.scope.path.isProgram()!==!0)return;let I=S.parentPath;I.isAssignmentExpression({operator:"="})&&I.node.left===S.node||d.add(S.node.name)},MemberExpression(S){let I=Ms(e,S);I!==null&&d.add(I)}}),e.compReads.set(a,d)}}function vn(e,t){vs(e,t),ks(e,t),Ns(e,t),bo(e),vr(e),ro(e),uo(e,t),Fs(e),Qr(e),fo(e),oo(e),Ur(e),Kr(e,t),zr(e,t,Bn),Hr(e),qr(e),Gr(e),$r(e,t);for(let[r]of e.comps)Rs(e,r);Ls(e),go(e);for(let[r]of e.comps)Ge(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 Ce from"@babel/types";import*as se from"@babel/types";function Ft(){return{writes:new Set,rootFallback:!1,rowLocal:!1,rowOwnerLocal:!1,instanceLocal:!1,instanceWrites:new Set,eventOrigin:null}}function ut(e,t){e.instanceLocal=!0,e.instanceWrites.add(t)}function At(e,t,n,r){let o=t.rowLocal&&r!==void 0?se.expressionStatement(r.refreshVar!==void 0?se.callExpression(se.identifier(r.refreshVar),[]):se.callExpression(Z(e,"markDirty"),[se.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=se.expressionStatement(se.callExpression(Z(e,"markDirty"),[Le(e,n),...c?[u.length===1?se.numericLiteral(u[0]):hr(e,u)]:[]]))}let s=t.rowOwnerLocal&&r?.ownerIdVar!==void 0?se.expressionStatement(se.callExpression(Z(e,"markDirty"),[se.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]: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"),[Tt(e,l)])))}function So(e,t,n){if(se.isBlockStatement(t.body)){Zn(t.body,n),t.body.body.push(n);return}let r=j(e,"returnValue");t.body=se.blockStatement([se.variableDeclaration("const",[se.variableDeclarator(r,t.body)]),n,se.returnStatement(se.cloneNode(r))])}function Zn(e,t){if(!se.isFunction(e))for(let n of se.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)||se.isFunction(i)||(se.isReturnStatement(i)?(r.splice(o,0,se.cloneNode(t)),o++):Zn(i,t))}else if(r&&typeof r=="object"&&"type"in r){if(se.isFunction(r))continue;se.isReturnStatement(r)?e[n]=se.blockStatement([se.cloneNode(t),r]):Zn(r,t)}}}import*as Se from"@babel/types";function xt(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?Le(e,t):Se.stringLiteral(e.rootId));return Se.expressionStatement(Se.callExpression(Z(e,"markDirty"),[Se.cloneNode(o)]))}function jt(e,t,n){let r=j(e,"event"),o=j(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 wo from"@babel/traverse";import*as Y from"@babel/types";function As(e,t,n){if(n.key===null)return null;let r=e.componentProps.get(t);if(r===void 0)return null;let o=Ve(r);if(n.root===o){let[s,...a]=n.key.split(".").slice(1);return s===void 0?null:{name:s,path:a}}let i=He(r,n.root);return i===null?null:{name:i,path:n.key.split(".").slice(1)}}function Yn(e,t,n,r,o){let i=As(e,t,r);if(i===null)return!1;n===void 0?ut(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 kn(e){return he.isIdentifier(e)||he.isObjectPattern(e)||he.isArrayPattern(e)||he.isAssignmentPattern(e)||he.isRestElement(e)}function js(e){let t=e;for(;he.isTSAsExpression(t)||he.isTSTypeAssertion(t)||he.isTSNonNullExpression(t)||he.isTSSatisfiesExpression(t);)t=t.expression;return t}function _t(e,t,n){if(he.isIdentifier(t)){e.set(t.name,n);return}if(he.isAssignmentPattern(t)){kn(t.left)&&_t(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];kn(o)&&_t(e,o,bt(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)){kn(r.value)&&_t(e,r.value,{...n,key:null});continue}let o=he.isIdentifier(r.key)?r.key.name:String(r.key.value);kn(r.value)&&_t(e,r.value,bt(n,[o]))}}}function xo(e,t,n,r){let o=js(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:Ve(i)===o.name?{locality:"prop",root:o.name,key:o.name}:He(i,o.name)===null?null:{locality:"prop",root:o.name,key:o.name}}if(!he.isMemberExpression(o))return null;let s=we(o),a=ye(o);if(s===null)return null;let l=xo(e,t,n,he.identifier(s));return l===null?null:a===null?{...l,key:null}:bt(l,a.split(".").slice(1))}function Co(e,t){let n=new Map;for(let r of e.instanceDerivations.get(t)??[]){let o=xo(e,t,n,r.source);o!==null&&_t(n,r.target,o)}return n}var Po=wo.default??wo;function Js(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 vo(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 Js(e,r))if(i==="__rows__"||i==="__regions__"||!o.has(i))return!0;return!1}function qt(e,t,n,r,o=!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:Co(e,n),x=n!==null?new Set(e.componentProps.get(n)?.bindings??[]):new Set,y=new Set([...x,...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 f=new Dt((E,C)=>{if(C!==void 0)return null;let M=g.get(E);if(M!==void 0)return M;if(r!==void 0&&E===r.itemParam)return{locality:"row",root:E,key:E};if(u?.has(E)===!0)return{locality:"instance",root:E,key:E};if(x.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:dn(E,ie)}),m=E=>E.stateKind==="computed"||e.state.get(E.root)==="computed",w=new Set;for(let E of a.params)Y.isIdentifier(E)&&w.add(E.name);Po(d,{VariableDeclarator(E){Y.isIdentifier(E.node.id)&&(w.add(E.node.id.name),E.parentPath.isVariableDeclaration()&&f.trackDeclarator(E.scope,E.node))},Function(E){for(let C of E.node.params)Y.isIdentifier(C)&&w.add(C.name)}});let S=new Map,I=new Map,$=E=>{let C=E.getFunctionParent()?.node??l,M=S.get(C);return M||S.set(C,M=Ft()),M},F=(E,C)=>{if(C($(E)),!s||E.getFunctionParent()?.node!==l)return;let M=I.get(E.node);M===void 0&&(M={path:E,writes:Ft()},I.set(E.node,M)),C(M.writes)},N=E=>{F(E,C=>{r?.sourceLocal?C.rowOwnerLocal=!0:r!==void 0&&C.writes.add(r.sourceKey)})},K=E=>{if(r===void 0)return null;let C=E.split(".").slice(1);return r.itemPath.some((M,ie)=>C[ie]!==M)?null:C.slice(r.itemPath.length)},_=(E,C)=>{F(E,M=>{C!==void 0&&n!==null&&Yn(e,n,r,C,M)||(M.rowLocal=!0,M.rootFallback=!0)})},V=(E,C)=>{F(E,M=>{(n===null||!Yn(e,n,r,C,M))&&(r===void 0?(n!==null&&ut(M,C.root),M.rootFallback=!0):(M.rowLocal=!0,M.rootFallback=!0))})},O=(E,C)=>{if(r===void 0||we(C)!==r.itemParam)return!1;let M=ye(C);if(M===null)return r.itemPath.length===0?N(E):_(E),!0;let ie=M.split(".").slice(1);return r.itemPath.some((Je,Re)=>ie[Re]!==Je)?!1:(ie.splice(0,r.itemPath.length),Mn(ie,r.keyPath)?N(E):(F(E,Je=>{Je.rowLocal=!0}),vo(e,n,r)&&N(E)),!0)},le=(E,C)=>{if(C.locality==="instance"){F(E,M=>{ut(M,C.root)});return}if(C.locality==="row"){if(r===void 0){F(E,ie=>{ie.rootFallback=!0});return}if(C.key===null){r.itemPath.length===0?N(E):_(E);return}let M=K(C.key);if(M===null){_(E,C);return}Mn(M,r.keyPath)?N(E):(F(E,ie=>{ie.rowLocal=!0}),vo(e,n,r)&&N(E));return}if(C.locality==="prop"){V(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)})},te=(E,C)=>{if(C.locality==="instance"){F(E,M=>{ut(M,C.root)});return}if(C.locality==="row"){if(r===void 0){F(E,Je=>{Je.rootFallback=!0});return}if(C.key===null){r.itemPath.length===0?N(E):_(E);return}let M=K(C.key);if(M===null){_(E,C);return}M.length===0&&(r.keyPath===null||r.keyPath.length>0)?N(E):le(E,C);return}if(C.locality==="prop"){V(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)})},q=(E,C)=>{if(!(s&&E.getFunctionParent()?.node===l))for(let M of un(C)){if(!Y.isIdentifier(M))continue;let ie=f.resolveExpression(E.scope,M);ie!==null&&(m(ie)||te(E,ie))}},Q=(E,C)=>{let M=we(C);if(M!==void 0&&u?.has(M??"")===!0){F(E,Re=>{ut(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(O(E,C))return;let ie=f.resolveExpression(E.scope,C);if(ie!==null){le(E,ie);return}if(M!==null&&x.has(M)){V(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 rt=ye(C);rt!==null&&rt.includes(".")?Re.writes.add(rt):Re.writes.add(M)})};Po(d,{VariableDeclarator(E){if(!Y.isIdentifier(E.node.id)&&E.node.init!==null)for(let C of f.referencedOrigins(E.scope,E.node.init))te(E,C)},AssignmentExpression(E){let C=E.node.left;if(Y.isIdentifier(C)){if(w.has(C.name)){if(Y.isIdentifier(E.node.right)){let ie=f.resolveExpression(E.scope,E.node.right);ie!==null&&te(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=>{ut(ie,C.name)});return}if(x.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))Q(E,C);else for(let M of f.referencedOrigins(E.scope,E.node.right))te(E,M)},UpdateExpression(E){let C=E.node.argument;if(Y.isIdentifier(C)){if(w.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=>{ut(ie,C.name)});return}if(x.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)&&Q(E,C)},UnaryExpression(E){E.node.operator==="delete"&&Y.isMemberExpression(E.node.argument)&&Q(E,E.node.argument)},CallExpression(E){let C=E.node.callee;if(Y.isMemberExpression(C)){if(pn(C)==="assign"&&Y.isIdentifier(C.object,{name:"Object"})){let Re=E.node.arguments[0],rt=Re!==void 0&&Y.isExpression(Re)?f.resolveExpression(E.scope,Re):null;if(rt!==null)if(rt.locality==="module"&&rt.stateKind==="store"){let br=cn(rt,E.node.arguments.slice(1));br===null?te(E,rt):F(E,vi=>{for(let ki of br)vi.writes.add(ki)})}else le(E,rt);return}let ie=Y.isIdentifier(C.object)?C.object.name:Y.isMemberExpression(C.object)?we(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)?f.resolveExpression(E.scope,C.object):null;Je!==null?te(E,Je):q(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)??We(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=f.resolveExpression(E.scope,Je);if(Re!==null){if(m(Re))continue;te(E,bt(Re,ie.path))}}return}q(E,E.node.arguments)}});let ee=S.has(l);if(e.handlerHasRootCommit.set(t,ee),o&&!S.has(l)){let E=Ft();E.eventOrigin=xt(e,n,r,i),S.set(l,E)}let oe=[];if(s)for(let E of I.values()){let C=At(e,E.writes,n,r);C!==null&&oe.push({...E,commit:C})}for(let E of oe)E.flag=j(e,"didWrite");oe.sort((E,C)=>ko(C.path)-ko(E.path)).forEach(E=>$s(E.path,E.flag));for(let[E,C]of S){let M=s&&E===l?oe.length===0?null:Y.blockStatement(oe.map(ie=>Y.ifStatement(Y.cloneNode(ie.flag),Y.cloneNode(ie.commit)))):At(e,C,n,r);M&&So(e,E,M)}if(oe.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",oe.map(E=>Y.variableDeclarator(Y.cloneNode(E.flag),Y.booleanLiteral(!1)))))}t.body=a.body}function ko(e){let t=0,n=e;for(;n.parentPath!==null;)t++,n=n.parentPath;return t}function $s(e,t){let n=Y.assignmentExpression("=",Y.cloneNode(t),Y.booleanLiteral(!0));if(e.isVariableDeclarator()){let r=e.node.init;if(r===null||!Y.isExpression(r))throw new Error("memo-dom: execution-aware variable site has no expression initializer");e.node.init=Y.sequenceExpression([n,r]);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 st from"@babel/types";function No(e,t){let n=!1,r=!0,o=i=>{if(r&&!(i!==e&&st.isFunction(i))){if((st.isCallExpression(i)||st.isOptionalCallExpression(i))&&(n=!0,!st.isIdentifier(i.callee)||!t(i.callee.name))){r=!1;return}for(let s of st.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 pt(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&&(Ce.isArrowFunctionExpression(o)||Ce.isFunctionExpression(o))?o:null}function nt(e,t,n,r,o,i=!1){e.analyzedFunctions.has(n)||(Qn(e,t,n,r,o),e.analyzedFunctions.add(n),qt(e,n,r,o,!1,void 0,i))}function Gt(e,t,n=!1){e.analyzedFunctions.has(t)||(e.analyzedFunctions.add(t),qt(e,t,null,void 0,!1,void 0,n))}function Qn(e,t,n,r,o){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=pt(t,s);a===null||e.analyzedFunctions.has(a)||(e.analyzedFunctions.add(a),Qn(e,t,a,r,o),qt(e,a,r,o,!1))}}function er(e,t,n,r,o,i,s){let a=null,l=!1,d=e.componentProps.get(o),u=d===void 0?null:Ve(d);if(d!==void 0&&(Ce.isIdentifier(n)&&He(d,n.name)!==null||Ce.isMemberExpression(n)&&u!==null&&we(n)===u))return jt(e,n,xt(e,o,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 f=Ft();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,jt(e,n,At(e,f,null)??xt(e,o,i,s))}let x=t.scope.getBinding(n.name),y=x?.path;if(y&&y.isVariableDeclarator()){let f=y.node.init;f&&(Ce.isArrowFunctionExpression(f)||Ce.isFunctionExpression(f))&&(a=f,l=x?.scope.path.isProgram()===!0&&e.helpers.has(n.name))}else y&&y.isFunctionDeclaration()&&(e.helpers.has(n.name)?(a=y.node,l=!0):a=pt(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(Ce.isBlockStatement(a.body)||(a.body=Ce.blockStatement([Ce.expressionStatement(a.body)])),!e.analyzedFunctions.has(a)){l||Qn(e,t,a,o,i);let g=!l&&!Ce.isIdentifier(n)&&No(a,x=>{let y=pt(t,x);return y!==null&&e.handlerHasRootCommit.get(y)===!0});e.analyzedFunctions.add(a),qt(e,a,l?null:o,l?void 0:i,!l&&!Ce.isIdentifier(n)&&!g,s)}if(l){let g=We(e,n.name);if(a.async){let x=Ft();for(let y of g.writes)x.writes.add(y);for(let y of g.boundedWrites)x.writes.add(y);return x.rootFallback=g.unbounded,jt(e,n,At(e,x,null)??xt(e,o,i,s))}if(g.writes.size===0&&g.boundedWrites.size===0&&!g.unbounded)return jt(e,n,xt(e,o,i,s))}return Ce.isIdentifier(n)&&!l&&(e.handlerHasRootCommit.get(a)===!1||a.async)?jt(e,n,xt(e,o,i,s)):Ce.isIdentifier(n)?n:a}import*as ve from"@babel/types";function tr(e,t){let n=[];for(let r of e){if(ve.isJSXText(r)){let a=Xn(r.value);a!==""&&n.push({type:"node",variable:t.emitText(ve.stringLiteral(a))});continue}if(ve.isJSXElement(r)||ve.isJSXFragment(r)){n.push({type:"node",variable:t.emitNode(r)});continue}if(ve.isJSXExpressionContainer(r)||t.fail("memo-dom: spread children are not supported"),ve.isJSXEmptyExpression(r.expression))continue;ve.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:ve.cloneNode(o)});continue}if(ve.isNullLiteral(o)||ve.isBooleanLiteral(o)||ve.isIdentifier(o,{name:"undefined"}))continue;let i=Oe(o);if(i!==null){n.push({type:"list",expression:i});continue}let s=an(o);if(s!==null&&ce(s)){n.push({type:"condition",expression:s});continue}n.push({type:"node",variable:t.emitText(ve.cloneNode(o))})}return n}import*as T from"@babel/types";var Xs=new Set(["innerHTML","checked","value","selected","disabled","hidden","multiple","required","readOnly","muted","open","controls","loop","autoFocus","autoPlay","tabIndex"]),Io={htmlFor:"for",crossOrigin:"crossorigin"};function nr(e,t){return!t&&Xs.has(e)?e:null}function rr(e,t){return!t&&e in Io}function or(e,t,n){let r=T.identifier(e);if(t==="tabIndex")return T.isStringLiteral(n)?T.expressionStatement(T.assignmentExpression("=",T.memberExpression(r,T.identifier(t)),T.cloneNode(n))):T.expressionStatement(T.conditionalExpression(T.binaryExpression("==",T.cloneNode(n),T.nullLiteral()),T.callExpression(T.memberExpression(T.cloneNode(r),T.identifier("removeAttribute")),[T.stringLiteral("tabindex")]),T.assignmentExpression("=",T.memberExpression(T.cloneNode(r),T.identifier(t)),T.cloneNode(n))));let o=t==="value"||t==="innerHTML"?T.stringLiteral(""):T.booleanLiteral(!1),i=T.isStringLiteral(n)?T.cloneNode(n):T.conditionalExpression(T.binaryExpression("==",T.cloneNode(n),T.nullLiteral()),o,T.cloneNode(n));return T.expressionStatement(T.assignmentExpression("=",T.memberExpression(r,T.identifier(t)),i))}function Nn(e,t,n){let r=T.identifier(e),o=Io[t]??t;return T.isStringLiteral(n)?T.expressionStatement(T.callExpression(T.memberExpression(r,T.identifier("setAttribute")),[T.stringLiteral(o),T.cloneNode(n)])):T.expressionStatement(T.conditionalExpression(T.logicalExpression("||",T.binaryExpression("==",T.cloneNode(n),T.nullLiteral()),T.binaryExpression("===",T.cloneNode(n),T.booleanLiteral(!1))),T.callExpression(T.memberExpression(T.cloneNode(r),T.identifier("removeAttribute")),[T.stringLiteral(o)]),T.callExpression(T.memberExpression(r,T.identifier("setAttribute")),[T.stringLiteral(o),T.conditionalExpression(T.binaryExpression("===",T.cloneNode(n),T.booleanLiteral(!0)),T.stringLiteral(""),T.callExpression(T.identifier("String"),[T.cloneNode(n)]))])))}import*as Ke from"@babel/types";var Os="http://www.w3.org/2000/svg",Ts=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 Fo(e,t){return t||e==="svg"||Ts.has(e)}function Ro(e,t){return t?Ke.callExpression(Ke.memberExpression(Ke.identifier("document"),Ke.identifier("createElementNS")),[Ke.stringLiteral(Os),Ke.stringLiteral(e)]):Ke.callExpression(Ke.memberExpression(Ke.identifier("document"),Ke.identifier("createElement")),[Ke.stringLiteral(e)])}import*as me from"@babel/types";function In(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?[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 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)??me.identifier("undefined"))}function Jt(e,t,n){let r=e.componentProps.get(t);return r?.mode==="object"?[me.cloneNode(n)]:(r?.names??[]).map(o=>me.memberExpression(me.cloneNode(n),me.isValidIdentifier(o)?me.identifier(o):me.stringLiteral(o),!me.isValidIdentifier(o)))}function Do(e,t,n,r,o){let i=j(e,`${t}Props`);return me.blockStatement([me.variableDeclaration("const",[me.variableDeclarator(me.cloneNode(i),me.cloneNode(o))]),me.expressionStatement(me.callExpression(Z(e,"setProps"),[me.binaryExpression("+",me.cloneNode(n),me.stringLiteral(r)),me.arrayExpression(Jt(e,t,i))]))])}import*as Ne from"@babel/types";function $t(e){return(Ne.isArrowFunctionExpression(e)||Ne.isFunctionExpression(e))&&!Bs(e.body)}function ir(e,t,n,r="callback"){let o=j(e,r);return t.creation.push(Ne.variableDeclaration("const",[Ne.variableDeclarator(Ne.cloneNode(o),Ne.cloneNode(n,!0))])),o}function sr(e,t,n,r="callback"){let o=j(e,r);return t.push(Ne.variableDeclaration("const",[Ne.variableDeclarator(Ne.cloneNode(o),Ne.cloneNode(n,!0))])),o}function Bs(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 U from"@babel/types";function Mo(e,t,n,r,o,i,s,a=!1,l=Le(e,o),d=!1){let u=ln(n,i,t.usedConds),c=j(e,u.suffix).name,g=U.binaryExpression("+",U.cloneNode(l),U.stringLiteral(`/${u.suffix}`)),x=U.arrowFunctionExpression([],U.cloneNode(u.pickExpr)),y=u.branches.map(f=>f!==null?ar(e,f,o,i,g,s,a,g,!1,t.usedConds):U.nullLiteral());t.creation.push(ht(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(Z(e,"createCondRegion"),[U.identifier(r),U.cloneNode(g),x,U.arrayExpression(y)]))])),(d||Er(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 ar(e,t,n,r,o,i,s=!1,a=o,l=!1,d){let u=Ye(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(Z(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(y=>U.ifStatement(U.binaryExpression("!==",U.cloneNode(y),U.nullLiteral()),U.expressionStatement(U.callExpression(U.cloneNode(y),[])))),...u.disposableRegions.map(y=>U.expressionStatement(U.callExpression(U.memberExpression(U.identifier(y),U.identifier("dispose")),[]))),...u.disposableEntities.map(y=>U.expressionStatement(U.callExpression(Z(e,"unregisterSubtree"),[U.cloneNode(y)])))];g.push(U.objectProperty(U.identifier("dispose"),U.arrowFunctionExpression([],U.blockStatement(x))))}return U.arrowFunctionExpression([],U.blockStatement([Qe(u),et(u),...u.creation,...u.mounts,U.returnStatement(U.objectExpression(g))]))}import*as p from"@babel/types";import*as X from"@babel/types";function ft(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 ft(e,t,n,o)})):Vs(e,n,r)?X.cloneNode(r,!0):Ws(t,r)||X.isMemberExpression(r)?Lo(e,r):X.cloneNode(r,!0)}function lr(e,t,n,r,o){let i=j(e,"refDispose");t.mounts.push(X.variableDeclaration("const",[X.variableDeclarator(X.cloneNode(i),X.callExpression(Z(e,"mountRef"),[X.cloneNode(n,!0),X.cloneNode(o,!0)]))])),t.manualDisposal?t.disposableCallbacks.push(i):t.mounts.push(X.expressionStatement(X.callExpression(Z(e,"cleanup"),[X.cloneNode(r,!0),X.cloneNode(i)])))}function Vs(e,t,n){let r=dt(e,t,n);return r!==null&&e.componentProps.get(t)?.refProps.includes(r)===!0}function Ws(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 Lo(e,t){let n=j(e,"refNode");if(X.isMemberExpression(t)){let r=j(e,"refTarget"),o=t.computed?j(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 A from"@babel/types";var zs=new Set(["setClassValue","setStyleValue","setDomValue"]);function Xt(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 f of t.creation){if(!A.isVariableDeclaration(f))continue;let m=Ks(f);if(m===null)return!1;r.push(m),o.add(m.name)}if(!o.has(n)||r.length<2)return!1;let i=new Map,s=new Map;for(let f of t.creation){let m=Ao(f);if(m===null)continue;if(!o.has(m.parent)||!o.has(m.child))return!1;let w=s.get(m.parent)??0;s.set(m.parent,w+1),i.set(m.child,{parent:m.parent,index:w})}let a=new Map;for(let f of o){let m=Us(f,n,i);if(m===null)return!1;a.set(f,m)}let l=[],d=[];for(let f of t.creation)A.isVariableDeclaration(f)||_s(f,o)?l.push(A.cloneNode(f,!0)):d.push(f);let u=j(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)),x=A.callExpression(A.memberExpression(g,A.identifier("cloneNode")),[A.booleanLiteral(!0)]),y=[...r].sort((f,m)=>a.get(f.name).length-a.get(m.name).length).map(({name:f})=>A.variableDeclaration("const",[A.variableDeclarator(A.identifier(f),f===n?A.cloneNode(x,!0):Hs(n,a.get(f)))]));return t.creation=[...y,...d],!0}function Ks(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 r=t.init.arguments.at(-1);return(n==="createElement"||n==="createElementNS")&&A.isStringLiteral(r)&&r.value.includes("-")?null:{name:t.id.name,statement:e}}function Ao(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 Us(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 Hs(e,t){let n=A.identifier(e);for(let r of t){n=A.memberExpression(n,A.identifier("firstChild"));for(let o=0;o<r;o++)n=A.memberExpression(n,A.identifier("nextSibling"))}return n}function _s(e,t){let n=Ao(e);if(n!==null)return t.has(n.parent)&&t.has(n.child);if(!A.isExpressionStatement(e))return!1;let r=e.expression;return!!(A.isCallExpression(r)&&A.isMemberExpression(r.callee)&&(A.isIdentifier(r.callee.object)&&t.has(r.callee.object.name)&&A.isIdentifier(r.callee.property,{name:"setAttribute"})&&r.arguments.every(o=>A.isExpression(o)&&Fn(o))||A.isIdentifier(r.callee.object)&&A.isIdentifier(r.callee.property)&&zs.has(r.callee.property.name)&&r.arguments.length>=2&&A.isIdentifier(r.arguments[0])&&t.has(r.arguments[0].name)&&r.arguments.slice(1).every(o=>A.isExpression(o)&&Fn(o))))}function Fn(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)&&Fn(t)):A.isObjectExpression(e)?e.properties.every(t=>A.isObjectProperty(t)&&!t.computed&&A.isExpression(t.value)&&Fn(t.value)):!1}function $o(e,t,n,r,o,i,s,a,l=!1,d=Le(e,o),u){let c=kt(e,n,i,o,t.usedPrefixes,u===void 0?void 0:{itemParam:u.itemParam,sourceKey:u.sourceKey,sourceLocal:u.sourceLocal??!1}),g=j(e,`region${t.regionCounter++}`).name,x=c.form==="callback"?Gs(e,c,r):c.form==="component"?Zs(e,c,r,o,i,a,l,d):Ys(e,c,r,o,i,s,l,d),y=[p.identifier(r),p.binaryExpression("+",p.cloneNode(d),p.stringLiteral(`/${c.suffix}`)),x];if(c.form==="callback"){let S=p.memberExpression(p.cloneNode(c.renderCallback,!0),p.identifier("key"));y.push(p.arrowFunctionExpression([p.cloneNode(c.itemPattern,!0),...c.indexParam===null?[]:[p.identifier(c.indexParam)]],p.conditionalExpression(p.binaryExpression("==",p.cloneNode(S),p.nullLiteral()),p.cloneNode(c.itemPattern,!0),p.callExpression(p.cloneNode(S),[p.cloneNode(c.itemPattern,!0),...c.indexParam===null?[]:[p.identifier(c.indexParam)]]))))}else c.keyExpr!==null&&y.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(Z(e,"createListRegion"),y))])),t.disposableRegions.push(g);let m=(e.targetedListDependencies.get(n)??[]).map(S=>({dependency:S,cache:j(e,`${S.value}ListKey`).name}));m.length>0&&t.creation.push(p.variableDeclaration("let",m.map(({dependency:S,cache:I})=>p.variableDeclarator(p.identifier(I),p.identifier(S.value)))));let w=()=>p.expressionStatement(p.callExpression(p.memberExpression(p.identifier(g),p.identifier("reconcile")),[p.cloneNode(c.sourceExpr)]));t.creation.push(w()),m.length===0||t.reasonVar===null?t.updaters.push(w):t.updaters.push(()=>qs(e,o,t.reasonVar,g,c.sourceExpr,m))}function jo(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 Jo(e,t){return p.expressionStatement(p.callExpression(p.memberExpression(p.identifier(e),p.identifier("refreshKey")),[t]))}function qs(e,t,n,r,o,i){let s=e.instanceReasonIds.get(t);if(s===void 0)return p.expressionStatement(p.callExpression(p.memberExpression(p.identifier(r),p.identifier("reconcile")),[p.cloneNode(o)]));let a=s.get(i[0].dependency.source);if(a===void 0)return p.expressionStatement(p.callExpression(p.memberExpression(p.identifier(r),p.identifier("reconcile")),[p.cloneNode(o)]));let l=[p.expressionStatement(p.callExpression(p.memberExpression(p.identifier(r),p.identifier("reconcile")),[p.cloneNode(o)])),...i.map(({dependency:u,cache:c})=>p.expressionStatement(p.assignmentExpression("=",p.identifier(c),p.identifier(u.value))))],d=[];for(let{dependency:u,cache:c}of i){let g=s.get(u.value);if(g===void 0)continue;let x=j(e,"previousListKey");d.push(p.ifStatement(jo(n,g),p.blockStatement([p.variableDeclaration("const",[p.variableDeclarator(x,p.identifier(c))]),p.expressionStatement(p.assignmentExpression("=",p.identifier(c),p.identifier(u.value))),Jo(r,p.cloneNode(x)),p.ifStatement(p.unaryExpression("!",p.callExpression(p.memberExpression(p.identifier("Object"),p.identifier("is")),[p.cloneNode(x),p.identifier(c)])),Jo(r,p.identifier(c)))])))}return p.ifStatement(p.logicalExpression("||",p.binaryExpression("===",p.identifier(n),p.nullLiteral()),jo(n,a)),p.blockStatement(l),d.length===0?void 0:p.blockStatement(d))}function Gs(e,t,n){let r=j(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 Zs(e,t,n,r,o,i,s=!1,a=Le(e,r)){let l=t.rowComp,d=j(e,"rowId"),u=j(e,"nextItem"),c=t.indexParam===null?null:j(e,"nextIndex"),g=j(e,"refreshRow"),x=Ye(e),y=Mt(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:lt(t.keyExpr,t.itemParam),sourceKey:t.sourceKey,sourceLocal:t.sourceLocal,...t.sourceLocal&&p.isIdentifier(a)?{ownerIdVar:a.name}:{}},w=t.jsx.openingElement.attributes.filter(q=>p.isJSXSpreadAttribute(q)||Ae(q.name)!=="key"),S=w.some(q=>p.isJSXSpreadAttribute(q)),I=[],$=[],F=null,N=e.componentProps.get(l),K=q=>{let Q=p.isJSXElement(q)||p.isJSXFragment(q)?[q]:[p.jsxExpressionContainer(q)];return i(e,x,Q,r,o,"row",m,d,s,d)};if(S){F=Ht(w,{attributeValue:(q,Q)=>q==="ref"||N?.refProps.includes(q)===!0?ft(e,o,r,Q):Q,fail:q=>{throw o.buildCodeFrameError(q)}}).expression;for(let q of F.properties){if(!p.isObjectProperty(q)||q.computed||!p.isExpression(q.value))continue;let Q=p.isIdentifier(q.key)?q.key.name:p.isStringLiteral(q.key)?q.key.value:null;if(Q!==null)if(N?.renderProps.includes(Q)===!0){if(tt(e,r,q.value))continue;if(!ce(q.value))throw o.buildCodeFrameError(`memo-dom: render prop '${Q}' on <${l}> must be JSX, a JSX-bearing conditional/list, or a forwarded render prop`);q.value=K(q.value)}else{if(ce(q.value))throw o.buildCodeFrameError(`memo-dom: JSX prop '${Q}' on <${l}> is not rendered by the callee; interpolate that prop in <${l}> to declare a render slot`);Q!=="ref"&&N?.refProps.includes(Q)!==!0&&$t(q.value)&&(nt(e,o,q.value,r,m,!0),q.value=sr(e,$,q.value,`${Q}Callback`))}}}else for(let q of w){let Q=q,ee=Ae(Q.name),oe=Q.value==null?p.booleanLiteral(!0):$e(Q.value);if(oe===null)throw o.buildCodeFrameError(`memo-dom: prop '${Ae(Q.name)}' on <${l}> must be an expression`);if(N?.renderProps.includes(ee)===!0){if(tt(e,r,oe)){I.push({name:ee,value:p.cloneNode(oe)});continue}if(!ce(oe))throw o.buildCodeFrameError(`memo-dom: render prop '${ee}' on <${l}> must be JSX, a JSX-bearing conditional/list, or a forwarded render prop`);I.push({name:ee,value:K(oe)});continue}if(ee==="ref"||N?.refProps.includes(ee)===!0){I.push({name:ee,value:ft(e,o,r,oe)});continue}if(ce(oe))throw o.buildCodeFrameError(`memo-dom: JSX prop '${ee}' on <${l}> is not rendered by the callee; interpolate that prop in <${l}> to declare a render slot`);let E=$t(oe);if(E)nt(e,o,oe,r,m,!0);else if(p.isIdentifier(oe)){let C=pt(o,oe.name);C!==null&&!ce(C.body)&&nt(e,o,C,r,m,!0)}I.push({name:ee,value:E?sr(e,$,oe,`${ee}Callback`):p.cloneNode(oe)})}if(Wt(t.jsx.children)){if(w.some(Q=>p.isJSXAttribute(Q)&&Ae(Q.name)==="children"))throw o.buildCodeFrameError(`memo-dom: <${l}> cannot use both a children prop and nested JSX children`);let q=i(e,x,t.jsx.children,r,o,"row",m,d,s,d);F!==null?F.properties.push(p.objectProperty(p.identifier("children"),p.cloneNode(q))):I.push({name:"children",value:p.cloneNode(q)})}let _;if(F!==null){let q=j(e,`${l}Props`);$.push(p.variableDeclaration("const",[p.variableDeclarator(p.cloneNode(q),p.cloneNode(F))])),_=Jt(e,l,q)}else _=In(e,l,I);let V=[p.expressionStatement(p.assignmentExpression("=",p.cloneNode(t.itemPattern,!0),p.cloneNode(u)))];c!==null&&t.indexParam!==null&&V.push(p.expressionStatement(p.assignmentExpression("=",p.identifier(t.indexParam),p.cloneNode(c))));let O=_.map(q=>p.cloneNode(q));if(F!==null){let q=j(e,`next${l}Props`);V.push(p.variableDeclaration("const",[p.variableDeclarator(p.cloneNode(q),p.cloneNode(F))])),O=Jt(e,l,q)}let le=j(e,y?"entry":"rowElement");y?V.push(p.expressionStatement(p.callExpression(p.memberExpression(p.cloneNode(le),p.identifier("updateProps")),O))):V.push(p.expressionStatement(p.callExpression(Z(e,"setProps"),[p.cloneNode(d),p.arrayExpression(O)])),p.expressionStatement(p.callExpression(Z(e,"markDirty"),[p.cloneNode(d)]))),x.updaters.length>0&&V.push(p.expressionStatement(p.callExpression(p.identifier(x.updateVar),[])));let te=y?[p.objectProperty(p.identifier("nodes"),p.memberExpression(p.cloneNode(le),p.identifier("nodes"))),p.objectProperty(p.identifier("entities"),p.arrayExpression([])),p.objectProperty(p.identifier("update"),p.memberExpression(p.cloneNode(le),p.identifier("update"))),p.objectProperty(p.identifier("dispose"),p.memberExpression(p.cloneNode(le),p.identifier("dispose")))]:[p.objectProperty(p.identifier("nodes"),p.callExpression(Z(e,"rootNodes"),[p.cloneNode(le)])),p.objectProperty(p.identifier("entities"),p.arrayExpression([p.cloneNode(d)]))];return(_.length>0||x.updaters.length>0)&&te.push(p.objectProperty(p.identifier("updateProps"),p.arrowFunctionExpression([p.cloneNode(u),...c===null?[]:[p.cloneNode(c)]],p.blockStatement(V)))),p.arrowFunctionExpression([p.cloneNode(t.itemPattern,!0),p.cloneNode(d),...t.indexParam===null?[]:[p.identifier(t.indexParam)]],p.blockStatement([...x.updaters.length>0?[Qe(x),et(x)]:[],...x.creation,...x.mounts,...$,p.variableDeclaration("const",[p.variableDeclarator(p.cloneNode(le),y?p.callExpression(p.identifier(l),[..._.map(q=>p.cloneNode(q)),p.cloneNode(d),...t.sourceLocal?[p.cloneNode(a)]:[],...f?[p.identifier(n)]:[]]):p.callExpression(p.identifier(l),[p.cloneNode(d),p.cloneNode(a),..._.length>0?[p.arrayExpression(_)]:[]]))]),...x.updaters.length>0?[p.variableDeclaration("const",[p.variableDeclarator(p.cloneNode(g),p.arrowFunctionExpression([],p.blockStatement([p.expressionStatement(y?p.callExpression(p.memberExpression(p.cloneNode(le),p.identifier("update")),[]):p.callExpression(Z(e,"markDirty"),[p.cloneNode(d)])),p.expressionStatement(p.callExpression(p.identifier(x.updateVar),[]))])))])]:[],p.returnStatement(p.objectExpression(te))]))}function Ys(e,t,n,r,o,i,s=!1,a=Le(e,r)){t.jsx.openingElement.attributes=t.jsx.openingElement.attributes.filter(f=>p.isJSXSpreadAttribute(f)||f.name.name!=="key");let l=Ye(e);l.delegatedEventRootVar=n;let d=j(e,"rowId").name,u=j(e,"nextItem"),c=t.indexParam===null?null:j(e,"nextIndex"),g={itemParam:t.itemParam,itemPath:[],rowIdVar:d,keyPath:lt(t.keyExpr,t.itemParam),sourceKey:t.sourceKey,sourceLocal:t.sourceLocal,...t.sourceLocal?{ownerIdVar:p.isIdentifier(a)?a.name:Le(e,r).name}:{}},x=i(e,l,t.jsx,r,o,"row",g,p.identifier(d),s,p.identifier(d));Xt(e,l,x);let y=[p.expressionStatement(p.assignmentExpression("=",p.cloneNode(t.itemPattern,!0),p.cloneNode(u)))];return c!==null&&t.indexParam!==null&&y.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([Qe(l),et(l),ht(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(y))),p.objectProperty(p.identifier("update"),p.identifier(l.updateVar))]))]))}import*as v from"@babel/types";function Qs(e){return v.isJSXElement(e.body)?e.body:v.isBlockStatement(e.body)&&e.body.body.length===1&&v.isReturnStatement(e.body.body[0])&&v.isJSXElement(e.body.body[0].argument)?e.body.body[0].argument:null}function dr(e,t,n,r,o,i,s,a){if(!v.isArrowFunctionExpression(n)&&!v.isFunctionExpression(n)||n.async||n.generator)throw o.buildCodeFrameError("memo-dom: render callbacks must be synchronous inline arrows or function expressions");let l=Qs(n),d=n.params[0],u=n.params[1];if(l===null||n.params.length<1||n.params.length>2||!v.isIdentifier(d)&&!v.isObjectPattern(d)&&!v.isArrayPattern(d)||u!==void 0&&!v.isIdentifier(u))throw o.buildCodeFrameError("memo-dom: render callbacks take an item binding pattern and optional index, then return one JSX element");let c=nn(d),g=Object.keys(v.getBindingIdentifiers(c));if(g.length===0)throw o.buildCodeFrameError("memo-dom: render callback item patterns must bind at least one name");let x=v.isIdentifier(c)?c.name:g[0],y=u===void 0?null:u.name,f=null;l.openingElement.attributes=l.openingElement.attributes.filter(Q=>{if(v.isJSXSpreadAttribute(Q)||!v.isJSXIdentifier(Q.name)||Q.name.name!=="key")return!0;if(f=$e(Q.value),f===null)throw o.buildCodeFrameError("memo-dom: key={...} needs an expression");return!1});let m=j(e,"renderCallback"),w=j(e,"renderRows"),S=j(e,"renderNextUpdate"),I=j(e,"renderRowId"),$=j(e,"renderEventRoot"),F=j(e,"refreshRenderRow"),N=j(e,"renderNextItem"),K=y===null?null:j(e,"renderNextIndex"),_=Ye(e);_.delegatedEventRootVar=$.name;let V={itemParam:x,itemPath:[],rowIdVar:I.name,keyPath:lt(f,x),sourceKey:"$render-callback",sourceLocal:!0,...v.isIdentifier(a)?{ownerIdVar:a.name}:{}},O=i(e,_,l,r,o,"row",V,I,s,I);Xt(e,_,O),t.creation.push(v.variableDeclaration("const",[v.variableDeclarator(v.cloneNode(w),v.newExpression(v.identifier("Set"),[]))])),t.updaters.push(()=>v.forOfStatement(v.variableDeclaration("const",[v.variableDeclarator(v.cloneNode(S))]),v.cloneNode(w),v.expressionStatement(v.callExpression(v.cloneNode(S),[]))));let le=[v.expressionStatement(v.assignmentExpression("=",v.cloneNode(c,!0),v.cloneNode(N)))];K!==null&&y!==null&&le.push(v.expressionStatement(v.assignmentExpression("=",v.identifier(y),v.cloneNode(K))));let te=v.arrowFunctionExpression([v.cloneNode(c,!0),v.cloneNode(I),...y===null?[]:[v.identifier(y)],v.cloneNode($)],v.blockStatement([Qe(_),et(_),v.variableDeclaration("const",[v.variableDeclarator(v.cloneNode(F),v.arrowFunctionExpression([],v.blockStatement([v.expressionStatement(v.callExpression(v.identifier(_.updateVar),[])),v.expressionStatement(v.callExpression(Z(e,"renderDescendants"),[v.cloneNode(I)]))])))]),ht(e,v.cloneNode(I),v.cloneNode(a,!0),v.cloneNode(F)),..._.creation,..._.mounts,v.expressionStatement(v.callExpression(v.memberExpression(v.cloneNode(w),v.identifier("add")),[v.cloneNode(F)])),v.returnStatement(v.objectExpression([v.objectProperty(v.identifier("nodes"),v.callExpression(Z(e,"rootNodes"),[v.identifier(O)])),v.objectProperty(v.identifier("entities"),v.arrayExpression([v.cloneNode(I)])),v.objectProperty(v.identifier("updateProps"),v.arrowFunctionExpression([v.cloneNode(N),...K===null?[]:[v.cloneNode(K)]],v.blockStatement(le))),v.objectProperty(v.identifier("update"),v.cloneNode(F)),v.objectProperty(v.identifier("dispose"),v.arrowFunctionExpression([],v.callExpression(v.memberExpression(v.cloneNode(w),v.identifier("delete")),[v.cloneNode(F)])))]))])),q=f===null?v.nullLiteral():v.arrowFunctionExpression([v.cloneNode(c,!0),...y===null?[]:[v.identifier(y)]],v.cloneNode(f));return t.creation.push(v.variableDeclaration("const",[v.variableDeclarator(v.cloneNode(m),v.objectExpression([v.objectProperty(v.identifier("create"),te),v.objectProperty(v.identifier("key"),q)]))])),m}function ea(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 ta(e,t,n,r){return()=>Nt(e,t,h.cloneNode(r),o=>h.expressionStatement(h.assignmentExpression("=",h.memberExpression(h.identifier(n),h.identifier("data")),ea(o))))}function cr(e,t,n){let r=j(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=Jn(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=ta(t,o,r,n);return t.creation.push(i()),t.updaters.push(i),r}function Xo(e,t){let n=!1;return h.traverseFast(e,r=>{h.isIdentifier(r,{name:t})&&(n=!0)}),n}function at(e,t,n,r,o,i=null,s,a,l=!1,d=Le(e,r)){return h.isJSXFragment(n)?na(e,t,n,r,o,i,s,a,l,d):ra(e,t,n,r,o,i,s,a,l,d)}function na(e,t,n,r,o,i,s,a,l=!1,d=Le(e,r)){let u=tr(n.children,{emitText:g=>cr(e,t,g),emitNode:g=>at(e,t,g,r,o,i,s,a,l,d),isForwarded:g=>tt(e,r,g),fail:g=>{throw o.buildCodeFrameError(g)}}),c=$n(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")),[]))])),To(e,t,u,c,r,o,i,s,l,d),c}function To(e,t,n,r,o,i,s=null,a,l=!1,d=Le(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"?On(e,t,u.expression,r,d):u.type==="list"?Bo(e,t,u.expression,r,o,i,l,d,a):Vo(e,t,u.expression,r,o,i,l,d,s!==null)}function ur(e,t,n,r,o,i,s,a,l,d){return Nr(e,t,d,(u,c,g)=>{Ir(u,n,c.name,{emitText:x=>cr(e,u,x),emitNode:x=>at(e,u,x,r,o,i,s,a,l,g),emitList:(x,y)=>Bo(e,u,x,y,r,o,l,g,s),emitCondition:(x,y)=>Vo(e,u,x,y,r,o,l,g,i!==null),isForwarded:x=>tt(e,r,x),emitForwarded:(x,y)=>On(e,u,x,y,g),fail:x=>{throw o.buildCodeFrameError(x)}})})}function Oo(e,t,n,r,o,i,s,a,l,d){let u=h.isJSXElement(n)||h.isJSXFragment(n)?[n]:[h.jsxExpressionContainer(n)];return ur(e,t,u,r,o,i,s,a,l,d)}function ra(e,t,n,r,o,i=null,s,a,l=!1,d=Le(e,r)){let u=n.openingElement,c=u.name.name;if(/^[A-Z]/.test(c)){let S=t.childCounts.get(c)??0;t.childCounts.set(c,S+1);let I=c.charAt(0).toLowerCase()+c.slice(1),$=S===0?I:`${I}${S}`,F=j(e,$).name,N=S===0?`/${c}`:`/${c}[${S}]`,K=[],_=e.componentProps.get(c);if(Wt(n.children)&&u.attributes.some(Q=>h.isJSXAttribute(Q)&&Ae(Q.name)==="children"))throw o.buildCodeFrameError(`memo-dom: <${c}> cannot use both a children prop and nested JSX children`);let V=u.attributes.some(Q=>h.isJSXSpreadAttribute(Q)),O=null,le=!1;if(V){O=Ht(u.attributes,{attributeValue:(ee,oe)=>ee==="ref"||_?.refProps.includes(ee)===!0?ft(e,o,r,oe):oe,fail:ee=>{throw o.buildCodeFrameError(ee)}}).expression;for(let ee of O.properties){if(!h.isObjectProperty(ee)||ee.computed||!h.isExpression(ee.value))continue;let oe=h.isIdentifier(ee.key)?ee.key.name:h.isStringLiteral(ee.key)?ee.key.value:null;if(oe!==null)if(_?.renderCallbacks.includes(oe)===!0)ee.value=dr(e,t,ee.value,r,o,at,l,d);else if(_?.renderProps.includes(oe)===!0){if(tt(e,r,ee.value))continue;if(!ce(ee.value))throw o.buildCodeFrameError(`memo-dom: render prop '${oe}' on <${c}> must be JSX, a JSX-bearing conditional/list, or a forwarded render prop`);ee.value=Oo(e,t,ee.value,r,o,i,s,a,l,d)}else{if(ce(ee.value))throw o.buildCodeFrameError(`memo-dom: JSX prop '${oe}' on <${c}> is not rendered by the callee; interpolate that prop in <${c}> to declare a render slot`);oe!=="ref"&&_?.refProps.includes(oe)!==!0&&$t(ee.value)&&(nt(e,o,ee.value,r,s,!0),ee.value=ir(e,t,ee.value,`${oe}Callback`))}}le=Ln(e,O,r)||s!==void 0&&Xo(O,s.itemParam)}else for(let Q of u.attributes){let ee=Q,oe=Ae(ee.name),E=ee.value==null?h.booleanLiteral(!0):$e(ee.value);if(E==null)throw o.buildCodeFrameError(`memo-dom: prop '${Ae(ee.name)}' on <${c}> must be an expression`);if(_?.renderCallbacks.includes(oe)===!0){K.push({name:oe,value:dr(e,t,E,r,o,at,l,d)});continue}if(oe==="ref"||_?.refProps.includes(oe)===!0){K.push({name:oe,value:ft(e,o,r,E)});continue}if(_?.renderProps.includes(oe)===!0){if(tt(e,r,E)){K.push({name:oe,value:h.cloneNode(E)});continue}if(!ce(E))throw o.buildCodeFrameError(`memo-dom: render prop '${oe}' on <${c}> must be JSX, a JSX-bearing conditional/list, or a forwarded render prop`);K.push({name:oe,value:Oo(e,t,E,r,o,i,s,a,l,d)});continue}if(ce(E))throw o.buildCodeFrameError(`memo-dom: JSX prop '${oe}' on <${c}> is not rendered by the callee; interpolate that prop in <${c}> to declare a render slot`);let C=$t(E);if(!C&&(Ln(e,E,r)||s!==void 0&&Xo(E,s.itemParam))&&(le=!0),C)nt(e,o,E,r,s,!0);else if(h.isIdentifier(E)){let M=pt(o,E.name);M!==null&&!ce(M.body)&&nt(e,o,M,r,s,!0)}K.push({name:oe,value:C?ir(e,t,E,`${oe}Callback`):h.cloneNode(E)})}if(Wt(n.children)){if(u.attributes.some(ee=>h.isJSXAttribute(ee)&&Ae(ee.name)==="children"))throw o.buildCodeFrameError(`memo-dom: <${c}> cannot use both a children prop and nested JSX children`);let Q=ur(e,t,n.children,r,o,i,s,a,l,d);O!==null?O.properties.push(h.objectProperty(h.identifier("children"),h.cloneNode(Q))):K.push({name:"children",value:h.cloneNode(Q)})}let te;if(O!==null){let Q=j(e,`${I}Props`);t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.cloneNode(Q),h.cloneNode(O))])),te=Jt(e,c,Q)}else te=In(e,c,K);let q=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),[q,h.cloneNode(d),...te.length>0?[h.arrayExpression(te)]:[]]))])),t.disposableEntities.push(h.cloneNode(q)),le&&t.updaters.push(()=>O===null?h.expressionStatement(h.callExpression(Z(e,"setProps"),[h.binaryExpression("+",h.cloneNode(d),h.stringLiteral(N)),h.arrayExpression(te.map(Q=>h.cloneNode(Q)))])):Do(e,c,d,N,O)),F}let g=Fo(c,l),x=g&&c!=="foreignObject";if(u.attributes.find(S=>h.isJSXAttribute(S)&&Ae(S.name)==="innerHTML")!==void 0){if(g)throw o.buildCodeFrameError("memo-dom: innerHTML is only supported on HTML elements");if(n.children.some(I=>!h.isJSXText(I)||I.value.trim()!==""))throw o.buildCodeFrameError("memo-dom: an element using innerHTML cannot also have JSX children")}let f=tr(n.children,{emitText:S=>cr(e,t,S),emitNode:S=>at(e,t,S,r,o,i,s,a,x,d),isForwarded:S=>tt(e,r,S),fail:S=>{throw o.buildCodeFrameError(S)}}),m=$n(e,t,c);if(t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.identifier(m),Ro(c,g))])),u.attributes.some(S=>h.isJSXSpreadAttribute(S))){let S=Ht(u.attributes,{attributeValue:(F,N)=>F==="ref"?ft(e,o,r,N):N,eventValue:(F,N)=>{let K=er(e,o,N,F,r,s,a),_=j(e,`${F}Handler`);return t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.cloneNode(_),K)])),_},fail:F=>{throw o.buildCodeFrameError(F)}}),I=j(e,`${c}Props`);t.creation.push(h.variableDeclaration("const",[h.variableDeclarator(h.cloneNode(I),h.cloneNode(S.expression))]));let $=F=>h.expressionStatement(h.callExpression(Z(e,"patchDomProps"),[h.identifier(m),h.cloneNode(F),h.stringLiteral(e.rootId),h.arrayExpression(S.safeEventKeys.map(N=>h.stringLiteral(N)))]));t.creation.push($(I)),lr(e,t,h.identifier(m),d,h.memberExpression(h.cloneNode(I),h.identifier("ref"))),t.updaters.push(()=>$(S.expression))}else for(let S of u.attributes){let I=S,$=Ae(I.name);if($==="ref"){let O=$e(I.value);if(O===null)throw o.buildCodeFrameError("memo-dom: ref needs an expression");lr(e,t,h.identifier(m),d,ft(e,o,r,O));continue}if($==="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($)){let O=$e(I.value);if(O==null)throw o.buildCodeFrameError(`memo-dom: ${$} needs a handler expression (L1)`);let le=er(e,o,O,$,r,s,a);t.creation.push(t.delegatedEventRootVar===null?h.expressionStatement(h.assignmentExpression("=",h.memberExpression(h.identifier(m),h.identifier($.toLowerCase())),le)):h.expressionStatement(h.callExpression(Z(e,"setDelegatedEvent"),[h.identifier(t.delegatedEventRootVar),h.identifier(m),h.stringLiteral($),le])));continue}if(h.isStringLiteral(I.value)){$==="class"||$==="className"?t.creation.push(h.expressionStatement(h.callExpression(Z(e,"setClassValue"),[h.identifier(m),h.stringLiteral(I.value.value)]))):$==="style"?t.creation.push(h.expressionStatement(h.callExpression(Z(e,"setStyleValue"),[h.identifier(m),h.stringLiteral(I.value.value)]))):nr($,g)!==null?t.creation.push(or(m,$,h.stringLiteral(I.value.value))):rr($,g)?t.creation.push(Nn(m,$,h.stringLiteral(I.value.value))):g?t.creation.push(h.expressionStatement(h.callExpression(Z(e,"setDomValue"),[h.identifier(m),h.stringLiteral($),h.stringLiteral(I.value.value)]))):t.creation.push(h.expressionStatement(h.callExpression(h.memberExpression(h.identifier(m),h.identifier("setAttribute")),[h.stringLiteral($),h.stringLiteral(I.value.value)])));continue}let F=I.value==null?h.booleanLiteral(!0):$e(I.value);if(F==null||h.isStringLiteral(F))throw o.buildCodeFrameError(`memo-dom: attribute '${$}' needs a string or an expression (L1)`);let N=h.cloneNode(F);if($==="style"){let O=()=>h.expressionStatement(h.callExpression(Z(e,"setStyleValue"),[h.identifier(m),h.cloneNode(N)]));t.creation.push(O()),t.updaters.push(O);continue}let K=Jn(e,t),_=nr($,g),V=()=>$==="class"||$==="className"?Nt(t,K,h.callExpression(Z(e,"classValue"),[h.cloneNode(N)]),O=>h.expressionStatement(h.callExpression(Z(e,"setClassValue"),[h.identifier(m),O]))):_!==null?Nt(t,K,h.cloneNode(N),O=>or(m,_,O)):rr($,g)?Nt(t,K,h.cloneNode(N),O=>Nn(m,$,O)):g?Nt(t,K,h.cloneNode(N),O=>h.expressionStatement(h.callExpression(Z(e,"setDomValue"),[h.identifier(m),h.stringLiteral($),O]))):Nt(t,K,h.cloneNode(N),O=>Nn(m,$,O));t.creation.push(V()),t.updaters.push(V)}return To(e,t,f,m,r,o,i,s,x,d),m}function Bo(e,t,n,r,o,i,s=!1,a=Le(e,o),l){$o(e,t,n,r,o,i,at,ur,s,a,l)}function Vo(e,t,n,r,o,i,s=!1,a=Le(e,o),l=!1){Mo(e,t,n,r,o,i,at,s,a,l)}function Wo(e,t,n,r,o,i=!1,s=o,a=!1,l){return ar(e,t,n,r,o,at,i,s,a,l)}import*as Ie from"@babel/types";function Uo(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 Ho(e,t,n,r,o,i=!1){let s=pt(t,n);if(s!==null){nt(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=Uo(a.path);l!==null&&Gt(e,l,i)}function zo(e,t,n,r,o,i=!1){if(Ie.isArrowFunctionExpression(n)||Ie.isFunctionExpression(n)){if(ce(n.body))return;nt(e,t,n,r,o,i)}else Ie.isIdentifier(n)&&Ho(e,t,n.name,r,o,i)}function _o(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=Uo(o.path);i!==null&&Gt(e,i,r)}function Ko(e,t,n,r=!1){if(Ie.isArrowFunctionExpression(n)||Ie.isFunctionExpression(n)){if(ce(n.body))return;Gt(e,n,r)}else Ie.isIdentifier(n)&&_o(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=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(r))}if(s){Ie.isIdentifier(a)&&Ho(e,t,a.name,n,o);for(let d of i.node.arguments)zo(e,t,d,n,o,l)}},NewExpression(i){if(i.getFunctionParent()===t)for(let s of i.node.arguments)zo(e,t,s,n,o)}})}function Go(e,t){t.traverse({CallExpression(n){if(n.getFunctionParent()!==null)return;let r=Ie.isIdentifier(n.node.callee,{name:"effect"})&&n.scope.getBinding("effect")===void 0;Ie.isIdentifier(n.node.callee)&&_o(e,t,n.node.callee.name);for(let o of n.node.arguments)Ko(e,t,o,r)},NewExpression(n){if(n.getFunctionParent()===null)for(let r of n.node.arguments)Ko(e,t,r)}})}function Zo(e){for(let t of e.helpers.values())t.node.async&&Gt(e,t.node)}function Yo(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 Be from"@babel/types";import*as Pe from"@babel/types";function Qo(e){return e.reduce((t,n)=>Pe.logicalExpression("||",t,n))}function ei(e,t){let n=()=>Pe.identifier(e),r=Qo(t.map(i=>Pe.binaryExpression("===",n(),Pe.numericLiteral(i)))),o=Qo(t.map(i=>Pe.callExpression(Pe.memberExpression(n(),Pe.identifier("has")),[Pe.numericLiteral(i)])));return Pe.logicalExpression("||",Pe.binaryExpression("===",n(),Pe.nullLiteral()),Pe.conditionalExpression(Pe.binaryExpression("===",Pe.unaryExpression("typeof",n()),Pe.stringLiteral("number")),r,o))}function ti(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:Sr(c)})),...i.map(c=>({order:s.get(c.statement)??Number.MAX_SAFE_INTEGER,sequence:a++,sources:c.sources,statement:Be.blockStatement([...c.resets.map(g=>Be.expressionStatement(Be.assignmentExpression("=",Be.identifier(g.binding),Be.cloneNode(g.source,!0)))),Be.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(w=>d.get(w)).filter(w=>w!==void 0).sort((w,S)=>w-S),x=g===null||g.length===c.sources.length?g:null,y=x?.join(" ")??"*",f=u.at(-1),m=f?.reasons?.join(" ")??"*";f!==void 0&&m===y?f.statements.push(c.statement):u.push({reasons:x,statements:[c.statement]})}return Be.blockStatement(u.map(c=>c.reasons===null||n===null?Be.blockStatement(c.statements):Be.ifStatement(ei(n,c.reasons),Be.blockStatement(c.statements))))}import*as B from"@babel/types";function Zt(e){return!B.isReturnStatement(e)||!B.isJSXElement(e.argument)&&!B.isJSXFragment(e.argument)?null:{jsx:e.argument,statement:e}}function pr(e){return B.isBlockStatement(e)?e.body.length===1?Zt(e.body[0]):null:Zt(e)}function oa(e){let t=[];return e.get("body").traverse({ReturnStatement(n){t.push(n.node)},Function(n){n.skip()}}),t}function ia(e){if(B.isFunctionDeclaration(e))return!0;if(B.isVariableDeclaration(e))return e.declarations.every(t=>t.init==null||B.isFunction(t.init)||sa(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 sa(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 aa(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=Zt(r.consequent[0]);if(o===null)return null;let i=t.length;t.push(o.jsx),n.push(B.switchCase(r.test===null?null:B.cloneNode(r.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 ni(e,t){let n=e.node.body.body,r=oa(e),o=n.at(-1);if(r.length===1&&o!==void 0){let s=Zt(o);if(s!==null)return s}if(o&&B.isIfStatement(o)&&o.alternate!=null){let s=o.alternate,a=pr(o.consequent),l=pr(s);if(a!==null&&l!==null&&r.length===2)return{pick:B.arrowFunctionExpression([],B.conditionalExpression(B.cloneNode(o.test),B.numericLiteral(0),B.numericLiteral(1))),branches:[a.jsx,l.jsx],statements:new Set([o])}}if(o&&B.isSwitchStatement(o)){let s=aa(o);if(s!==null&&s.branches.length===r.length)return s}let i=o===void 0?null:Zt(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(B.isIfStatement(g)&&g.alternate==null){let x=pr(g.consequent);if(x!==null){d===-1&&(d=c),s.push(B.cloneNode(g.test)),a.push(x.jsx),l.add(g);continue}}if(d!==-1&&!ia(g)){u=!1;break}}if(a.push(i.jsx),u&&a.length===r.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 ri(e,t,n){let r=t.node,o=ni(t,n),i=e.componentProps.get(n),s=i.params.length,a=e.listedSites.get(n)??[],l=e.linkedComponentRows.get(n)??[],d=a.some(O=>O.sourceLocal===!0)||l.some(O=>O.sourceLocal),u=Mt(e,n),c=Ye(e,u),g=e.instanceDerivations.get(n),x=e.instanceControlFlow.get(n),y=e.effects.get(n),f=y?.some(O=>O.localReads.size>0||O.localDerivationReads.size>0||O.conditionLocalReads.size>0||O.conditionLocalDerivationReads.size>0)===!0;(e.selectiveDerivationComponents.has(n)||e.targetedListComponents.has(n)||f)&&(c.reasonVar=j(e,"reasons").name);let m=j(e,"id").name,w=u?null:j(e,"parent").name,S=u&&d?j(e,"owner").name:null,I=u&&e.componentsWithHostEvents.has(n)?j(e,"eventRoot").name:null;c.delegatedEventRootVar=I;let $=s>0&&!u?j(e,"props").name:null;wt(e).registerComponentId(n,m);let F;if((a.length>0||l.length>0)&&i.bindings.length>0){let O=[...a.map(ee=>lt(ee.keyExpr??null,ee.itemParam??"")),...l.map(ee=>ee.keyPath)],le=JSON.stringify(O[0]),te=O.every(ee=>JSON.stringify(ee)===le)?O[0]:null,q=on(i,"item"),Q=Ve(i);F={itemParam:q??Q??i.bindings[0],itemPath:q===null&&Q!==null?["item"]:[],rowIdVar:m,...u?{refreshVar:c.updateVar}:{},keyPath:te,sourceKey:a[0]?.sourceKey??l[0]?.sourceKey??"",sourceLocal:d,...d?{ownerIdVar:S??w}:{}}}qo(e,t,n,m,F);let N="jsx"in o?at(e,c,o.jsx,n,t,null,F):la(e,c,o,n,t,m);if(u&&Xt(e,c,N),g!==void 0)for(let O of g)O.declaration.kind="let";(g!==void 0||x!==void 0)&&c.updaters.unshift(()=>ti(e,n,c.reasonVar,r.body.body,g??[],x??[])),y!==void 0&&f&&c.updaters.push(()=>Xr(e,n,m,c.reasonVar,y,c));let K=new Set(y?.map(O=>O.statement)??[]),_=r.body.body.filter(O=>!("jsx"in o?O===o.statement:o.statements.has(O))&&!K.has(O));s>0&&!u&&c.updaters.unshift(()=>D.blockStatement(An(i,i.params.map((O,le)=>D.memberExpression(D.identifier($),D.numericLiteral(le),!0)))));let V=[Qe(c)];if(s>0&&!u){let O=yr(i,i.params.map((le,te)=>D.memberExpression(D.identifier($),D.numericLiteral(te),!0)));O!==null&&V.push(O)}if(V.push(..._,et(c),...u?[]:[ht(e,D.identifier(m),D.identifier(w),D.identifier(c.updateVar))]),s>0&&!u&&V.push(D.expressionStatement(D.callExpression(Z(e,"registerProps"),[D.identifier(m),D.identifier($)]))),V.push(...c.creation,...c.mounts),y!==void 0&&V.push(...Or(e,m,y)),u){let O=i.params.map((le,te)=>j(e,`nextProp${te}`));V.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(O,D.blockStatement(An(i,O))))]:[],...c.disposableCallbacks.length>0?[D.objectProperty(D.identifier("dispose"),D.arrowFunctionExpression([],D.blockStatement([...c.disposableCallbacks].reverse().map(le=>D.ifStatement(D.binaryExpression("!==",D.cloneNode(le),D.nullLiteral()),D.expressionStatement(D.callExpression(D.cloneNode(le),[])))))))]:[]])))}else V.push(D.returnStatement(D.identifier(N)));r.params=u?[...i.params.map(xr),D.identifier(m),...S===null?[]:[D.identifier(S)],...I===null?[]:[D.identifier(I)]]:s>0?[D.identifier(m),D.identifier(w),D.identifier($)]:[D.identifier(m),D.identifier(w)],r.body=D.blockStatement(V)}function la(e,t,n,r,o,i){let s=j(e,"returnRoot").name,a=j(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=>Wo(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 de from"@babel/types";function da(e){return!de.isIdentifier(e.id)||!/^[A-Z]/.test(e.id.name)||!de.isArrowFunctionExpression(e.init)&&!de.isFunctionExpression(e.init)||!ce(e.init.body)?null:e.init}function ca(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 r=de.functionDeclaration(de.identifier(e),t.params.map(o=>de.cloneNode(o,!0)),de.isBlockStatement(t.body)?de.cloneNode(t.body,!0):de.blockStatement([de.returnStatement(de.cloneNode(t.body,!0))]));return r.returnType=t.returnType==null?null:de.cloneNode(t.returnType,!0),r.typeParameters=t.typeParameters==null?null:de.cloneNode(t.typeParameters,!0),r.loc=t.loc,r}function oi(e,t,n){if(e.kind!=="const")return[t?de.exportNamedDeclaration(de.cloneNode(e,!0)):de.cloneNode(e,!0)];let r=[];for(let o of e.declarations){let i=da(o),s;i===null?s=de.variableDeclaration("const",[de.cloneNode(o,!0)]):s=ca(o.id.name,i,n),r.push(t?de.exportNamedDeclaration(s):s)}return r.length>0&&de.inheritsComments(r[0],e),r}function Yt(e){let t=[],n=!1;for(let r of e.get("body")){let o=r.node;if(de.isVariableDeclaration(o)){let i=oi(o,!1,r);n||=i.some(s=>de.isFunctionDeclaration(s)),t.push(...i);continue}if(de.isExportNamedDeclaration(o)&&de.isVariableDeclaration(o.declaration)){let i=oi(o.declaration,!0,r);n||=i.some(s=>de.isExportNamedDeclaration(s)&&de.isFunctionDeclaration(s.declaration)),t.push(...i);continue}t.push(o)}n&&(e.set("body",t),e.scope.crawl())}function ua(e,t){let n=`${e.rootId}/$computed/${encodeURIComponent(e.moduleId)}#`;for(let r of t.get("body")){let o=r.node;if(J.isExportNamedDeclaration(o)&&(o=o.declaration),!(!J.isVariableDeclaration(o)||o.kind!=="const"))for(let i of o.declarations){if(!J.isIdentifier(i.id)||i.init==null)continue;let s=i.id.name;if(!e.computeds.has(s))continue;o.kind="let";let a=J.cloneNode(i.init),l=j(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"),[Tt(e,[s])]))]))])))])]));r.insertAfter(d)}}}function pa(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,j(e,`${a}Previous`)])),s=[J.variableDeclaration("const",r.bindings.map(a=>J.variableDeclarator(J.cloneNode(i.get(a)),J.identifier(a)))),J.cloneNode(r.statement,!0),...r.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"),[Tt(e,[a])]))])))];o.insertAfter(J.expressionStatement(J.callExpression(Z(e,"register"),[J.objectExpression([J.objectProperty(J.identifier("id"),J.stringLiteral(r.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 fr(e,t={}){let n=Qt(t),r=new WeakSet;return{name:"memo-dom",visitor:{Program:{enter(i){Yt(i),Sn(n,i),en(n,i),vn(n,i),Go(n,i),Zo(n)},exit(i){Tr(n,i),Yo(i),Br(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=qn(n);n.computeds.size>0&&ua(n,i),n.moduleControlFlow.length>0&&pa(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(wt(n).runtimeId))],J.stringLiteral(n.runtimePath)))}},FunctionDeclaration(i){let s=i.node.id?.name;!s||!n.comps.has(s)||r.has(i.node)||(r.add(i.node),ri(n,i,s),i.skip())}}}}function mr(e,t={}){let n=fa(e,{filename:t.moduleId??"./component.tsx",plugins:[[ma,{}],[fr,t],[ga,{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 Ot}from"node:path";import{transformSync as hi}from"@babel/core";import Ei from"@babel/plugin-syntax-jsx";import yi from"@babel/plugin-transform-typescript";import*as W from"@babel/types";function ba(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 ha(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 ii(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=ba(r,a.target,d);for(let g of u)ha(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 Ea(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 si(e,t){let n=new Map(e.map(u=>[u.key,u]));Ea(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,y=x.size;for(let f of c)x.add(`${f}${g.suffix}`);i.set(g.target,x),x.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=ii(n,s);return{paths:l,rows:o,propSources:d}}import"@babel/types";import*as be from"@babel/types";function ai(e){let t=e;for(;be.isTSAsExpression(t)||be.isTSTypeAssertion(t)||be.isTSNonNullExpression(t)||be.isTSSatisfiesExpression(t);)t=t.expression;return t}function ya(e,t,n){let r=ai(n);if(be.isIdentifier(r))return!e.state.has(r.name)||t.getBinding(r.name)?.scope.path.isProgram()!==!0?null:_e(e,r.name);if(!be.isMemberExpression(r))return null;let o=we(r);return o===null||!e.state.has(o)||t.getBinding(o)?.scope.path.isProgram()!==!0?null:_e(e,ye(r)??o)}function Sa(e,t){let n=ai(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 r=we(n),o=ye(n);if(r===null||o===null)return null;if(Ve(e)===r){let[a,...l]=o.split(".").slice(1);return a===void 0?null:{type:"prop",name:a,path:l}}let s=He(e,r);return s===null?null:{type:"prop",name:s,path:o.split(".").slice(1)}}function xa(e,t){let n=!1,r=Ve(e);return Xe(t,o=>{be.isIdentifier(o)&&(o.name===r||He(e,o.name)!==null)&&(n=!0)}),n}function Ca(e){return be.isStringLiteral(e)||be.isNumericLiteral(e)||be.isBooleanLiteral(e)||be.isNullLiteral(e)||be.isBigIntLiteral(e)||be.isTemplateLiteral(e)}function wa(e,t,n,r){let o=ya(e,n,r);if(o!==null)return{type:"state",key:o};let i=e.componentProps.get(t),s=Sa(i,r);if(s!==null)return s;let a=be.isIdentifier(r)?r.name:be.isMemberExpression(r)?we(r):null;return a!==null&&(e.instanceState.get(t)?.has(a)===!0||e.instanceDerivedBindings.get(t)?.has(a)===!0)||tn(e,r).size>0||xa(i,r)?{type:"root"}:Ca(r)?{type:"local"}:{type:"root"}}function gr(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 Pa(e){return be.isJSXIdentifier(e.name)?e.name.name:null}function li(e,t){let n=new Map;return e.compPaths.get(t).traverse({JSXOpeningElement(r){let o=r.node.name;if(!be.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)||gr(n,o.name,d,{type:"root"});continue}if(!s.isJSXAttribute())continue;let a=Pa(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)){gr(n,o.name,a,{type:"local"});continue}gr(n,o.name,a,wa(e,t,s.scope,l.expression))}}}),n}function di(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&&De(r)){let i=rn(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:wn(r.node.body),renderProps:[],renderCallbacks:[],refProps:[],subtreeReads:[]})}r.skip()}}),n}function ci(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:hn(e,n),delegatedEvents:e.componentsWithHostEvents.has(n),renderProps:[...r.renderProps],renderCallbacks:[...r.renderCallbacks],refProps:[...r.refProps],subtreeReads:[...Cn(e,n)].map(o=>_e(e,o)).sort()}}function Rn(e,t){return e.importedComponents.get(t)?.key??`${e.moduleId}#${t}`}function ui(e,t){let n=[];for(let r of t.comps.keys()){let o=[],i=li(t,r);for(let[s,a]of t.childRefCounts.get(r)??[]){let l=Rn(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:Rn(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:Rn(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:Rn(t,s),suffix:`/${l.suffix}/Row[*]`,mode:"row",keyPath:lt(l.keyExpr??null,l.itemParam??""),sourceKey:l.sourceLocal===!0?l.sourceKey??"":_e(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 Si(e){let t=e.replace(/\\/g,"/"),n=Ot.normalize(t);return t.startsWith("./")&&!n.startsWith("../")?`./${n}`:n}function xi(e){return{...e.runtimePath===void 0?{}:{runtimePath:e.runtimePath},...e.rootId===void 0?{}:{rootId:e.rootId}}}function va(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(!W.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(!W.isJSXAttribute(d))continue;let u=W.isJSXIdentifier(d.name)?d.name.name:d.name.name.name,c=d.value;W.isJSXElement(c)||W.isJSXFragment(c)||W.isJSXExpressionContainer(c)&&W.isExpression(c.expression)&&(ce(c.expression)||tt(e,r,c.expression))?n(l,u,"jsx"):n(l,u,"scalar")}i.node.children.some(d=>!W.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 pi(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 Ct(e,t,n){for(;W.isTSAsExpression(e)||W.isTSTypeAssertion(e)||W.isTSNonNullExpression(e);)e=e.expression;if(W.isIdentifier(e)){t.has(e.name)&&n.add(e.name);return}if(W.isConditionalExpression(e)){Ct(e.consequent,t,n),Ct(e.alternate,t,n);return}if(W.isLogicalExpression(e)){Ct(e.right,t,n);return}if(W.isObjectExpression(e)){for(let r of e.properties)W.isObjectProperty(r)&&W.isExpression(r.value)&&Ct(r.value,t,n);return}if(W.isArrayExpression(e))for(let r of e.elements)r!=null&&!W.isSpreadElement(r)&&Ct(r,t,n)}function fi(e,t){let n=new Set;if(W.isExpression(e.body))return Ct(e.body,t,n),[...n];let r=o=>{if(!W.isFunction(o)){if(W.isReturnStatement(o)){W.isExpression(o.argument)&&Ct(o.argument,t,n);return}for(let i of W.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 Ci(e){let t=[];for(let n of e.body)if(!(!W.isImportDeclaration(n)||n.importKind==="type"))for(let r of n.specifiers)if(W.isImportSpecifier(r)){if(r.importKind==="type")continue;let o=W.isIdentifier(r.imported)?r.imported.name:r.imported.value;t.push({local:r.local.name,imported:o,source:n.source.value})}else W.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 wi(e){let t=new Map;for(let n of e.body){if(W.isExportDefaultDeclaration(n)){(W.isFunctionDeclaration(n.declaration)||W.isClassDeclaration(n.declaration))&&n.declaration.id!=null?t.set("default",n.declaration.id.name):W.isIdentifier(n.declaration)&&t.set("default",n.declaration.name);continue}if(!W.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(W.isVariableDeclaration(r))for(let o of r.declarations)W.isIdentifier(o.id)&&t.set(o.id.name,o.id.name);else W.isFunctionDeclaration(r)&&r.id!=null&&t.set(r.id.name,r.id.name);for(let o of n.specifiers){if(!W.isExportSpecifier(o))continue;let i=o.local.name,s=W.isIdentifier(o.exported)?o.exported.name:o.exported.value;t.set(s,i)}}return t}function ka(e,t,n){let r,o=()=>({visitor:{Program(i){Yt(i);let s=Ci(i.node),a=Qt({...xi(n),moduleId:e.id,linkedImports:t});Sn(a,i),en(a,i),vn(a,i);let l={},d=_n(i.node);for(let[u,c]of wi(i.node)){if(a.comps.has(c)){l[u]={type:"component",...ci(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:pi(a,a.stateComponentCandidates.get(c)??[])};continue}let x=a.importedFunctions.get(c)??(a.helpers.has(c)?We(a,c):void 0);x!==void 0&&(l[u]={type:"function",tagCandidates:[...d.get(c)??a.functionTagCandidates.get(c)??[]],componentCandidates:pi(a,a.functionComponentCandidates.get(c)??[]),reads:[...x.reads].map(y=>_e(a,y)).sort(),writes:[...x.writes].map(y=>_e(a,y)).sort(),boundedWrites:[...x.boundedWrites].map(y=>_e(a,y)).sort(),parameterWrites:x.parameterWrites.map(y=>({index:y.index,path:[...y.path]})).sort((y,f)=>y.index-f.index||y.path.join(".").localeCompare(f.path.join("."))),unbounded:x.unbounded})}r={exports:l,imports:s,components:ui(e.id,a),componentUsages:va(a)}}}});if(hi(e.source,{filename:e.id,plugins:[[Ei,{}],o,[yi,{isTSX:!0}]],configFile:!1,babelrc:!1}),r===void 0)throw new Error(`memo-dom: failed to analyze module '${e.id}'`);return r}function Na(e){let t,n=()=>({visitor:{Program(r){Yt(r);let o=new Map,i=xn(r.node),s=_n(r.node),a=di(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=W.isExportNamedDeclaration(u)?u.declaration:u;if(W.isVariableDeclaration(c))for(let g of c.declarations){if(!W.isIdentifier(g.id))continue;if(W.isArrowFunctionExpression(g.init)||W.isFunctionExpression(g.init)){let y=fi(g.init,l).map(f=>`${e.id}#${f}`);o.set(g.id.name,{type:"function",tagCandidates:[...s.get(g.id.name)??[]],componentCandidates:y,reads:[],writes:[],boundedWrites:[],parameterWrites:[],unbounded:!0});continue}let x;if(c.kind==="let"||c.kind==="var"?x="let":Pt(g.init)?x="store":vt(g.init)&&(x="const"),x!==void 0){let y=new Set;W.isExpression(g.init)&&Ct(g.init,l,y),o.set(g.id.name,{type:"state",kind:x,key:`${e.id}#${g.id.name}`,tagCandidates:[...i.get(g.id.name)??[]],componentCandidates:[...y].map(f=>`${e.id}#${f}`)})}}else if(W.isFunctionDeclaration(c)&&c.id!=null&&!a.has(c.id.name)){let g=fi(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 wi(r.node)){let g=o.get(c);g!==void 0&&(d[u]=g)}t={exports:d,imports:Ci(r.node),components:[],componentUsages:[]}}}});if(hi(e.source,{filename:e.id,plugins:[[Ei,{}],n,[yi,{isTSX:!0}]],configFile:!1,babelrc:!1}),t===void 0)throw new Error(`memo-dom: failed to discover module '${e.id}'`);return t}function Pi(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=Ot.normalize(Ot.join(Ot.dirname(e),t));i=e.startsWith("./")&&!l.startsWith("../")?`./${l}`:l}else i=t;let s=Si(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 Ia(e,t){if(!t.startsWith("."))return t;let n=Ot.relative(Ot.dirname(e),t);return n.startsWith(".")?n:`./${n}`}function mi(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:Ia(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 gi(e,t,n,r,o,i){let s={};for(let a of t.imports){let l=Pi(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:mi(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:mi(e,d.componentCandidates,n),reads:[...d.reads],writes:[...d.writes],boundedWrites:[...d.boundedWrites],parameterWrites:[...d.parameterWrites],unbounded:d.unbounded}}return s}function bi(e){return JSON.stringify(e)}function Fa(e,t={}){let n=new Map;for(let[a,l]of Object.entries(e)){let d=Si(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,Na(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=gi(u,c,r,n,t),x=ka(u,g,t);d.set(u.id,x),bi(x)!==bi(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=si([...r.values()].flatMap(a=>a.components),t.rootId??"App"),s={};for(let a of n.values()){let l=r.get(a.id),d=gi(a,l,r,n,t,o);for(let y of l.imports){let f=Pi(a.id,y.source,n,t);if(f!==void 0&&r.get(f.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={},x={};for(let y of l.components){u[y.local]=[...i.paths.get(y.key)??[]];let f=i.rows.get(y.key);f!==void 0&&(c[y.local]=f.map(S=>({keyPath:S.keyPath===null?null:[...S.keyPath],sourceKey:S.sourceKey,sourceLocal:S.sourceLocal})));let m=i.propSources.get(y.key);m!==void 0&&(g[y.local]=Object.fromEntries([...m].map(([S,I])=>[S,{keys:[...I.keys],rootFallback:I.rootFallback}])));let w=Object.values(l.exports).find(S=>S.type==="component"&&S.key===y.key);if(w?.type==="component"){let S=o.get(y.key);x[y.local]=w.renderProps.filter(I=>S?.scalar.has(I)!==!0||S.jsx.has(I))}}s[a.originalId]=mr(a.source,{...xi(t),moduleId:a.id,linkedImports:d,linkedComponentPaths:u,linkedComponentRows:c,linkedComponentPropSources:g,linkedComponentRenderProps:x})}return s}export{mr as compile,Fa 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.2",
4
4
  "description": "Binding-aware TypeScript and JSX compiler for memoized-dom",
5
5
  "type": "module",
6
6
  "sideEffects": false,