@barefootjs/cli 0.31.4 → 0.31.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +811 -689
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -3739,7 +3739,7 @@ var init_binding_scope = __esm({
3739
3739
  * qualifies, including a preamble local shadowing a module const.
3740
3740
  * These call `isBound` / `boundNames()`.
3741
3741
  * - REACTIVITY / SLOT-ID CLASSIFIERS (`referencesLoopParam`,
3742
- * `hasReactiveAttributes`, and the `BindingEnvironment.loopParams`
3742
+ * `hasReactiveAttributes`, and the `BindingEnvironment.loopValueBoundNames`
3743
3743
  * feed built from `makeBindingEnv`, all in `jsx-to-ir.ts`) ask
3744
3744
  * "does this expression read a value that changes per row and so
3745
3745
  * needs its own patchable slot" — a preamble local already gets
@@ -9404,6 +9404,7 @@ var init_types = __esm({
9404
9404
  });
9405
9405
 
9406
9406
  // ../jsx/src/module-exports.ts
9407
+ import ts10 from "typescript";
9407
9408
  function generateModuleExports(ir, extraInlineExported = /* @__PURE__ */ new Set(), rewriteRelativeImport, options2) {
9408
9409
  const lines = [];
9409
9410
  for (const constant of options2?.skipValueDeclarations ? [] : ir.metadata.localConstants) {
@@ -9491,6 +9492,52 @@ function findReachableNames(primaryRefs, declarations) {
9491
9492
  }
9492
9493
  return reachable;
9493
9494
  }
9495
+ function findAssignedNames(bodyText, candidates) {
9496
+ const assigned = /* @__PURE__ */ new Set();
9497
+ if (candidates.size === 0) return assigned;
9498
+ const sf = ts10.createSourceFile(
9499
+ "bf-assignment-scan.tsx",
9500
+ bodyText,
9501
+ ts10.ScriptTarget.Latest,
9502
+ /* setParentNodes */
9503
+ false,
9504
+ ts10.ScriptKind.TSX
9505
+ );
9506
+ const record = (target2) => {
9507
+ if (ts10.isIdentifier(target2) && candidates.has(target2.text)) {
9508
+ assigned.add(target2.text);
9509
+ }
9510
+ };
9511
+ const visit3 = (node) => {
9512
+ if (ts10.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
9513
+ record(node.left);
9514
+ } else if ((ts10.isPrefixUnaryExpression(node) || ts10.isPostfixUnaryExpression(node)) && (node.operator === ts10.SyntaxKind.PlusPlusToken || node.operator === ts10.SyntaxKind.MinusMinusToken)) {
9515
+ record(node.operand);
9516
+ }
9517
+ ts10.forEachChild(node, visit3);
9518
+ };
9519
+ ts10.forEachChild(sf, visit3);
9520
+ return assigned;
9521
+ }
9522
+ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
9523
+ let reachable = findReachableNames(primaryRefs, declarations);
9524
+ if (mutableNames.size === 0) return reachable;
9525
+ let seedText = primaryRefs;
9526
+ for (let round = 0; round <= declarations.length; round++) {
9527
+ const survivingMutables = new Set(
9528
+ [...reachable].filter((name2) => mutableNames.has(name2))
9529
+ );
9530
+ if (survivingMutables.size === 0) return reachable;
9531
+ const added = declarations.filter((d) => !reachable.has(d.name)).filter((d) => findAssignedNames(d.body, survivingMutables).size > 0).map((d) => d.name);
9532
+ if (added.length === 0) return reachable;
9533
+ seedText += "\n" + added.join("\n");
9534
+ reachable = findReachableNames(seedText, declarations);
9535
+ }
9536
+ return reachable;
9537
+ }
9538
+ function isAssignmentOperator(kind2) {
9539
+ return kind2 >= ts10.SyntaxKind.FirstAssignment && kind2 <= ts10.SyntaxKind.LastAssignment;
9540
+ }
9494
9541
  function extractFunctionParams(value2) {
9495
9542
  const arrowMatch = value2.match(/^(?:async\s*)?\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/);
9496
9543
  if (arrowMatch) {
@@ -9543,7 +9590,7 @@ var init_builtins = __esm({
9543
9590
  });
9544
9591
 
9545
9592
  // ../jsx/src/reactivity-checker.ts
9546
- import ts10 from "typescript";
9593
+ import ts11 from "typescript";
9547
9594
  function queryType(checker, node) {
9548
9595
  incrementCounter("typeCheckerQueries");
9549
9596
  return checker.getTypeAtLocation(node);
@@ -9559,7 +9606,7 @@ function safeGetText(node) {
9559
9606
  }
9560
9607
  }
9561
9608
  function analyze(node, checker) {
9562
- if (ts10.isPropertyAccessExpression(node)) {
9609
+ if (ts11.isPropertyAccessExpression(node)) {
9563
9610
  try {
9564
9611
  const type2 = queryType(checker, node);
9565
9612
  if (isReactiveType(type2)) {
@@ -9584,7 +9631,7 @@ function analyze(node, checker) {
9584
9631
  }
9585
9632
  return NOT_REACTIVE;
9586
9633
  }
9587
- if (ts10.isIdentifier(node)) {
9634
+ if (ts11.isIdentifier(node)) {
9588
9635
  try {
9589
9636
  const type2 = queryType(checker, node);
9590
9637
  if (isReactiveType(type2)) {
@@ -9597,7 +9644,7 @@ function analyze(node, checker) {
9597
9644
  }
9598
9645
  return NOT_REACTIVE;
9599
9646
  }
9600
- if (ts10.isCallExpression(node)) {
9647
+ if (ts11.isCallExpression(node)) {
9601
9648
  try {
9602
9649
  const calleeType = queryType(checker, node.expression);
9603
9650
  if (isReactiveType(calleeType)) {
@@ -9611,7 +9658,7 @@ function analyze(node, checker) {
9611
9658
  }
9612
9659
  let foundChild;
9613
9660
  let foundChildText = "";
9614
- ts10.forEachChild(node, (child) => {
9661
+ ts11.forEachChild(node, (child) => {
9615
9662
  if (foundChild?.isReactive) return;
9616
9663
  const result2 = analyze(child, checker);
9617
9664
  if (result2.isReactive) {
@@ -9648,7 +9695,7 @@ var init_reactivity_checker = __esm({
9648
9695
  });
9649
9696
 
9650
9697
  // ../jsx/src/free-refs.ts
9651
- import ts11 from "typescript";
9698
+ import ts12 from "typescript";
9652
9699
  function buildBindingMap(env) {
9653
9700
  const cached = _bindingMapCache.get(env);
9654
9701
  if (cached) return cached;
@@ -9682,8 +9729,8 @@ function buildBindingMap(env) {
9682
9729
  for (const m of env.memos) {
9683
9730
  map.set(m.name, "memo-getter");
9684
9731
  }
9685
- if (env.loopParams) {
9686
- for (const name2 of env.loopParams) map.set(name2, "render-item");
9732
+ if (env.loopValueBoundNames) {
9733
+ for (const name2 of env.loopValueBoundNames) map.set(name2, "render-item");
9687
9734
  }
9688
9735
  _bindingMapCache.set(env, map);
9689
9736
  return map;
@@ -9712,17 +9759,17 @@ function defaultBindingScope(kind2) {
9712
9759
  function collectIdentifiers2(node) {
9713
9760
  const out = [];
9714
9761
  const visit3 = (n, parent2) => {
9715
- if (ts11.isIdentifier(n)) {
9716
- if (parent2 && ts11.isPropertyAccessExpression(parent2) && parent2.name === n) return;
9717
- if (parent2 && ts11.isPropertyAssignment(parent2) && parent2.name === n) return;
9718
- if (parent2 && (ts11.isJsxOpeningElement(parent2) || ts11.isJsxClosingElement(parent2) || ts11.isJsxSelfClosingElement(parent2)) && parent2.tagName === n) {
9762
+ if (ts12.isIdentifier(n)) {
9763
+ if (parent2 && ts12.isPropertyAccessExpression(parent2) && parent2.name === n) return;
9764
+ if (parent2 && ts12.isPropertyAssignment(parent2) && parent2.name === n) return;
9765
+ if (parent2 && (ts12.isJsxOpeningElement(parent2) || ts12.isJsxClosingElement(parent2) || ts12.isJsxSelfClosingElement(parent2)) && parent2.tagName === n) {
9719
9766
  return;
9720
9767
  }
9721
- if (parent2 && ts11.isJsxAttribute(parent2) && parent2.name === n) return;
9768
+ if (parent2 && ts12.isJsxAttribute(parent2) && parent2.name === n) return;
9722
9769
  out.push(n);
9723
9770
  return;
9724
9771
  }
9725
- ts11.forEachChild(n, (child) => visit3(child, n));
9772
+ ts12.forEachChild(n, (child) => visit3(child, n));
9726
9773
  };
9727
9774
  visit3(node);
9728
9775
  return out;
@@ -9731,7 +9778,7 @@ function collectReactiveBrandRefs(node, checker) {
9731
9778
  const out = [];
9732
9779
  const seen = /* @__PURE__ */ new Set();
9733
9780
  const visit3 = (n) => {
9734
- if (ts11.isPropertyAccessExpression(n)) {
9781
+ if (ts12.isPropertyAccessExpression(n)) {
9735
9782
  try {
9736
9783
  const type2 = checker.getTypeAtLocation(n);
9737
9784
  if (isReactiveType(type2)) {
@@ -9749,7 +9796,7 @@ function collectReactiveBrandRefs(node, checker) {
9749
9796
  incrementCounter("freeRefsTypeLookupFailures");
9750
9797
  }
9751
9798
  }
9752
- ts11.forEachChild(n, visit3);
9799
+ ts12.forEachChild(n, visit3);
9753
9800
  };
9754
9801
  visit3(node);
9755
9802
  return out;
@@ -9757,17 +9804,17 @@ function collectReactiveBrandRefs(node, checker) {
9757
9804
  function resolveConstantInitializerRefs(c, env, visited) {
9758
9805
  if (c.value === void 0) return [];
9759
9806
  if (c.containsArrow) return [];
9760
- const sf = ts11.createSourceFile(
9807
+ const sf = ts12.createSourceFile(
9761
9808
  "__const_init.ts",
9762
9809
  `const __probe = (${c.value});`,
9763
- ts11.ScriptTarget.Latest,
9810
+ ts12.ScriptTarget.Latest,
9764
9811
  true
9765
9812
  );
9766
9813
  const stmt = sf.statements[0];
9767
- if (!stmt || !ts11.isVariableStatement(stmt)) return [];
9814
+ if (!stmt || !ts12.isVariableStatement(stmt)) return [];
9768
9815
  const decl = stmt.declarationList.declarations[0];
9769
9816
  if (!decl || !decl.initializer) return [];
9770
- const expr = ts11.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
9817
+ const expr = ts12.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
9771
9818
  return resolveFreeRefsInternal(expr, env, visited);
9772
9819
  }
9773
9820
  function resolveFreeRefsInternal(node, env, visited) {
@@ -9779,7 +9826,7 @@ function resolveFreeRefsInternal(node, env, visited) {
9779
9826
  const name2 = ident.text;
9780
9827
  if (env.propsObjectName === name2) {
9781
9828
  const parent2 = ident.parent;
9782
- if (parent2 && ts11.isPropertyAccessExpression(parent2) && parent2.expression === ident && parent2.name.text === "children") {
9829
+ if (parent2 && ts12.isPropertyAccessExpression(parent2) && parent2.expression === ident && parent2.name.text === "children") {
9783
9830
  continue;
9784
9831
  }
9785
9832
  }
@@ -10174,7 +10221,7 @@ var init_to_locale_date_lowering = __esm({
10174
10221
  });
10175
10222
 
10176
10223
  // ../jsx/src/jsx-to-ir.ts
10177
- import ts12 from "typescript";
10224
+ import ts13 from "typescript";
10178
10225
  function hasLeadingClientDirective(expr, sourceFile) {
10179
10226
  const trivia = sourceFile.text.slice(expr.pos, expr.getStart(sourceFile));
10180
10227
  BLOCK_COMMENT_RE2.lastIndex = 0;
@@ -10195,13 +10242,13 @@ function exprCallsReactiveGetters(expr, ctx2) {
10195
10242
  let found = false;
10196
10243
  function visit3(n) {
10197
10244
  if (found) return;
10198
- if (ts12.isCallExpression(n) && ts12.isIdentifier(n.expression)) {
10245
+ if (ts13.isCallExpression(n) && ts13.isIdentifier(n.expression)) {
10199
10246
  if (names.has(n.expression.text)) {
10200
10247
  found = true;
10201
10248
  return;
10202
10249
  }
10203
10250
  }
10204
- ts12.forEachChild(n, visit3);
10251
+ ts13.forEachChild(n, visit3);
10205
10252
  }
10206
10253
  visit3(expr);
10207
10254
  return found;
@@ -10224,11 +10271,11 @@ function exprReferencesModuleClientSignal(expr, ctx2) {
10224
10271
  let found = false;
10225
10272
  function visit3(n) {
10226
10273
  if (found) return;
10227
- if (ts12.isCallExpression(n) && ts12.isIdentifier(n.expression) && names.has(n.expression.text)) {
10274
+ if (ts13.isCallExpression(n) && ts13.isIdentifier(n.expression) && names.has(n.expression.text)) {
10228
10275
  found = true;
10229
10276
  return;
10230
10277
  }
10231
- ts12.forEachChild(n, visit3);
10278
+ ts13.forEachChild(n, visit3);
10232
10279
  }
10233
10280
  visit3(expr);
10234
10281
  return found;
@@ -10237,11 +10284,11 @@ function exprHasFunctionCalls(expr) {
10237
10284
  let found = false;
10238
10285
  function visit3(n) {
10239
10286
  if (found) return;
10240
- if (ts12.isCallExpression(n)) {
10287
+ if (ts13.isCallExpression(n)) {
10241
10288
  found = true;
10242
10289
  return;
10243
10290
  }
10244
- ts12.forEachChild(n, visit3);
10291
+ ts13.forEachChild(n, visit3);
10245
10292
  }
10246
10293
  visit3(expr);
10247
10294
  return found;
@@ -10277,10 +10324,10 @@ function lowerDateCalls(text, expr, ctx2) {
10277
10324
  if (!matcher) return text;
10278
10325
  const candidates = [];
10279
10326
  function visit3(n) {
10280
- if (ts12.isCallExpression(n) && n.arguments.length === 0 && ts12.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
10327
+ if (ts13.isCallExpression(n) && n.arguments.length === 0 && ts13.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
10281
10328
  candidates.push(n);
10282
10329
  }
10283
- ts12.forEachChild(n, visit3);
10330
+ ts13.forEachChild(n, visit3);
10284
10331
  }
10285
10332
  visit3(expr);
10286
10333
  if (candidates.length === 0) return text;
@@ -10302,10 +10349,10 @@ function lowerToLocaleDateCalls(text, expr, ctx2) {
10302
10349
  if (!matcher) return text;
10303
10350
  const candidates = [];
10304
10351
  function visit3(n) {
10305
- if (ts12.isCallExpression(n) && n.arguments.length === 2 && ts12.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
10352
+ if (ts13.isCallExpression(n) && n.arguments.length === 2 && ts13.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
10306
10353
  candidates.push(n);
10307
10354
  }
10308
- ts12.forEachChild(n, visit3);
10355
+ ts13.forEachChild(n, visit3);
10309
10356
  }
10310
10357
  visit3(expr);
10311
10358
  if (candidates.length === 0) return text;
@@ -10358,10 +10405,10 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx2) {
10358
10405
  if (!propDepsMap || !branchVars || propDepsMap.size === 0) return void 0;
10359
10406
  let acc;
10360
10407
  function visit3(n, parent2) {
10361
- if (ts12.isIdentifier(n) && propDepsMap.has(n.text)) {
10362
- const isObjectKey = parent2 && ts12.isPropertyAssignment(parent2) && parent2.name === n;
10363
- const isShorthand = parent2 && ts12.isShorthandPropertyAssignment(parent2) && parent2.name === n;
10364
- const isAccessName = parent2 && ts12.isPropertyAccessExpression(parent2) && parent2.name === n;
10408
+ if (ts13.isIdentifier(n) && propDepsMap.has(n.text)) {
10409
+ const isObjectKey = parent2 && ts13.isPropertyAssignment(parent2) && parent2.name === n;
10410
+ const isShorthand = parent2 && ts13.isShorthandPropertyAssignment(parent2) && parent2.name === n;
10411
+ const isAccessName = parent2 && ts13.isPropertyAccessExpression(parent2) && parent2.name === n;
10365
10412
  if (!isObjectKey && !isShorthand && !isAccessName) {
10366
10413
  const deps = propDepsMap.get(n.text);
10367
10414
  if (deps && deps.size > 0) {
@@ -10370,7 +10417,7 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx2) {
10370
10417
  }
10371
10418
  }
10372
10419
  }
10373
- ts12.forEachChild(n, (child) => visit3(child, n));
10420
+ ts13.forEachChild(n, (child) => visit3(child, n));
10374
10421
  }
10375
10422
  visit3(node);
10376
10423
  return acc;
@@ -10442,17 +10489,17 @@ function createTransformContext(analyzer) {
10442
10489
  function buildComponentNamespaces(ctx2) {
10443
10490
  const result2 = /* @__PURE__ */ new Map();
10444
10491
  for (const stmt of ctx2.sourceFile.statements) {
10445
- if (!ts12.isVariableStatement(stmt)) continue;
10492
+ if (!ts13.isVariableStatement(stmt)) continue;
10446
10493
  for (const decl of stmt.declarationList.declarations) {
10447
- if (!decl.initializer || !ts12.isIdentifier(decl.name)) continue;
10494
+ if (!decl.initializer || !ts13.isIdentifier(decl.name)) continue;
10448
10495
  let init = decl.initializer;
10449
- while (ts12.isParenthesizedExpression(init)) init = init.expression;
10450
- if (!ts12.isObjectLiteralExpression(init)) continue;
10496
+ while (ts13.isParenthesizedExpression(init)) init = init.expression;
10497
+ if (!ts13.isObjectLiteralExpression(init)) continue;
10451
10498
  const members = /* @__PURE__ */ new Map();
10452
10499
  for (const prop of init.properties) {
10453
- if (ts12.isShorthandPropertyAssignment(prop)) {
10500
+ if (ts13.isShorthandPropertyAssignment(prop)) {
10454
10501
  members.set(prop.name.text, prop.name.text);
10455
- } else if (ts12.isPropertyAssignment(prop) && (ts12.isIdentifier(prop.name) || ts12.isStringLiteral(prop.name)) && ts12.isIdentifier(prop.initializer)) {
10502
+ } else if (ts13.isPropertyAssignment(prop) && (ts13.isIdentifier(prop.name) || ts13.isStringLiteral(prop.name)) && ts13.isIdentifier(prop.initializer)) {
10456
10503
  members.set(prop.name.text, prop.initializer.text);
10457
10504
  }
10458
10505
  }
@@ -10464,9 +10511,9 @@ function buildComponentNamespaces(ctx2) {
10464
10511
  return result2;
10465
10512
  }
10466
10513
  function resolveMemberExpressionTag(tagNode, ctx2) {
10467
- if (!ts12.isPropertyAccessExpression(tagNode)) return null;
10468
- if (!ts12.isIdentifier(tagNode.expression)) return null;
10469
- if (!ts12.isIdentifier(tagNode.name)) return null;
10514
+ if (!ts13.isPropertyAccessExpression(tagNode)) return null;
10515
+ if (!ts13.isIdentifier(tagNode.expression)) return null;
10516
+ if (!ts13.isIdentifier(tagNode.name)) return null;
10470
10517
  if (!ctx2._componentNamespaces) {
10471
10518
  ctx2._componentNamespaces = buildComponentNamespaces(ctx2);
10472
10519
  }
@@ -10501,7 +10548,7 @@ function makeBindingEnv(ctx2) {
10501
10548
  // mutated (cached on the immutable `BindingScope`) — a stable
10502
10549
  // snapshot even if `ctx.scope` is later reassigned by an enclosing
10503
10550
  // visitor frame, which swaps the instance rather than mutating it.
10504
- loopParams: boundNames,
10551
+ loopValueBoundNames: boundNames,
10505
10552
  checker: a.checker
10506
10553
  };
10507
10554
  ctx2._bindingEnv = env;
@@ -10607,7 +10654,7 @@ function buildIRRoot(analyzer) {
10607
10654
  if (!analyzer.jsxReturn) return null;
10608
10655
  const ctx2 = createTransformContext(analyzer);
10609
10656
  const jsxReturn = analyzer.jsxReturn;
10610
- if (ts12.isJsxElement(jsxReturn) || ts12.isJsxSelfClosingElement(jsxReturn) || ts12.isJsxFragment(jsxReturn)) {
10657
+ if (ts13.isJsxElement(jsxReturn) || ts13.isJsxSelfClosingElement(jsxReturn) || ts13.isJsxFragment(jsxReturn)) {
10611
10658
  const ir2 = transformNode(jsxReturn, ctx2);
10612
10659
  if (ir2 && needsScopeWrapper(ir2)) {
10613
10660
  return wrapInScopeElement(ir2);
@@ -10660,22 +10707,22 @@ function wrapInScopeElement(node) {
10660
10707
  };
10661
10708
  }
10662
10709
  function transformNode(node, ctx2) {
10663
- if (ts12.isJsxElement(node)) {
10710
+ if (ts13.isJsxElement(node)) {
10664
10711
  return transformJsxElement(node, ctx2);
10665
10712
  }
10666
- if (ts12.isJsxSelfClosingElement(node)) {
10713
+ if (ts13.isJsxSelfClosingElement(node)) {
10667
10714
  return transformSelfClosingElement(node, ctx2);
10668
10715
  }
10669
- if (ts12.isJsxFragment(node)) {
10716
+ if (ts13.isJsxFragment(node)) {
10670
10717
  return transformFragment(node, ctx2);
10671
10718
  }
10672
- if (ts12.isJsxText(node)) {
10719
+ if (ts13.isJsxText(node)) {
10673
10720
  return transformText(node, ctx2);
10674
10721
  }
10675
- if (ts12.isJsxExpression(node)) {
10722
+ if (ts13.isJsxExpression(node)) {
10676
10723
  return transformExpression(node, ctx2);
10677
10724
  }
10678
- if (ts12.isConditionalExpression(node)) {
10725
+ if (ts13.isConditionalExpression(node)) {
10679
10726
  return transformConditional(node, ctx2);
10680
10727
  }
10681
10728
  return null;
@@ -11054,14 +11101,14 @@ function transformSelfClosingComponent(node, ctx2, name2) {
11054
11101
  }
11055
11102
  function isTransparentFragment(node, ctx2) {
11056
11103
  const children2 = node.children.filter((child2) => {
11057
- if (ts12.isJsxText(child2)) {
11104
+ if (ts13.isJsxText(child2)) {
11058
11105
  return child2.text.trim() !== "";
11059
11106
  }
11060
11107
  return true;
11061
11108
  });
11062
11109
  if (children2.length !== 1) return false;
11063
11110
  const child = children2[0];
11064
- if (!ts12.isJsxExpression(child)) return false;
11111
+ if (!ts13.isJsxExpression(child)) return false;
11065
11112
  if (!child.expression) return false;
11066
11113
  const exprText = child.expression.getText(ctx2.sourceFile);
11067
11114
  if (exprText === "children") return true;
@@ -11100,7 +11147,7 @@ function transformChildren(children2, ctx2) {
11100
11147
  const result2 = [];
11101
11148
  for (let i = 0; i < children2.length; i++) {
11102
11149
  const child = children2[i];
11103
- if (ts12.isJsxExpression(child) && !child.expression) {
11150
+ if (ts13.isJsxExpression(child) && !child.expression) {
11104
11151
  continue;
11105
11152
  }
11106
11153
  const transformed = transformNode(child, ctx2);
@@ -11115,10 +11162,10 @@ function transformChildren(children2, ctx2) {
11115
11162
  }
11116
11163
  function isRenderNothingLiteral(expr, ctx2) {
11117
11164
  let e = expr;
11118
- while (ts12.isParenthesizedExpression(e) || ts12.isAsExpression(e) || ts12.isSatisfiesExpression(e) || ts12.isNonNullExpression(e)) {
11165
+ while (ts13.isParenthesizedExpression(e) || ts13.isAsExpression(e) || ts13.isSatisfiesExpression(e) || ts13.isNonNullExpression(e)) {
11119
11166
  e = e.expression;
11120
11167
  }
11121
- return e.kind === ts12.SyntaxKind.NullKeyword || e.kind === ts12.SyntaxKind.TrueKeyword || e.kind === ts12.SyntaxKind.FalseKeyword || ts12.isIdentifier(e) && e.text === "undefined" && !isNameBound("undefined", makeBindingEnv(ctx2));
11168
+ return e.kind === ts13.SyntaxKind.NullKeyword || e.kind === ts13.SyntaxKind.TrueKeyword || e.kind === ts13.SyntaxKind.FalseKeyword || ts13.isIdentifier(e) && e.text === "undefined" && !isNameBound("undefined", makeBindingEnv(ctx2));
11122
11169
  }
11123
11170
  function transformText(node, ctx2) {
11124
11171
  const text = node.text.replace(/\s+/g, " ");
@@ -11148,7 +11195,7 @@ function transformExpressionInner(expr, ctx2, node, isClientOnly) {
11148
11195
  return null;
11149
11196
  }
11150
11197
  checkBareSignalOrMemoIdentifier(expr, ctx2);
11151
- if (ts12.isIdentifier(expr)) {
11198
+ if (ts13.isIdentifier(expr)) {
11152
11199
  const jsxNode = ctx2.analyzer.jsxConstants.get(expr.text);
11153
11200
  if (jsxNode) {
11154
11201
  return transformNode(jsxNode, ctx2);
@@ -11436,35 +11483,35 @@ function transformLogicalAnd(node, ctx2) {
11436
11483
  };
11437
11484
  }
11438
11485
  function containsJsxInExpression(node) {
11439
- if (ts12.isJsxElement(node) || ts12.isJsxSelfClosingElement(node) || ts12.isJsxFragment(node)) {
11486
+ if (ts13.isJsxElement(node) || ts13.isJsxSelfClosingElement(node) || ts13.isJsxFragment(node)) {
11440
11487
  return true;
11441
11488
  }
11442
- return ts12.forEachChild(node, containsJsxInExpression) ?? false;
11489
+ return ts13.forEachChild(node, containsJsxInExpression) ?? false;
11443
11490
  }
11444
11491
  function callsJsxHelper(node, ctx2) {
11445
11492
  let found = false;
11446
11493
  const visit3 = (n) => {
11447
11494
  if (found) return;
11448
- if (ts12.isCallExpression(n) && ts12.isIdentifier(n.expression)) {
11495
+ if (ts13.isCallExpression(n) && ts13.isIdentifier(n.expression)) {
11449
11496
  const name2 = n.expression.text;
11450
11497
  if (ctx2.analyzer.jsxFunctions.has(name2) || ctx2.analyzer.jsxMultiReturnFunctions.has(name2)) {
11451
11498
  found = true;
11452
11499
  return;
11453
11500
  }
11454
11501
  }
11455
- ts12.forEachChild(n, visit3);
11502
+ ts13.forEachChild(n, visit3);
11456
11503
  };
11457
11504
  visit3(node);
11458
11505
  return found;
11459
11506
  }
11460
11507
  function containsAwaitExpression(node) {
11461
- if (ts12.isAwaitExpression(node)) return true;
11462
- if (ts12.isFunctionDeclaration(node) || ts12.isFunctionExpression(node) || ts12.isArrowFunction(node)) return false;
11463
- return ts12.forEachChild(node, containsAwaitExpression) ?? false;
11508
+ if (ts13.isAwaitExpression(node)) return true;
11509
+ if (ts13.isFunctionDeclaration(node) || ts13.isFunctionExpression(node) || ts13.isArrowFunction(node)) return false;
11510
+ return ts13.forEachChild(node, containsAwaitExpression) ?? false;
11464
11511
  }
11465
11512
  function transformNullishCoalescing(node, ctx2) {
11466
11513
  const leftText = ctx2.getJS(node.left);
11467
- const isNullish = node.operatorToken.kind === ts12.SyntaxKind.QuestionQuestionToken;
11514
+ const isNullish = node.operatorToken.kind === ts13.SyntaxKind.QuestionQuestionToken;
11468
11515
  const condition = isNullish ? `${leftText} != null` : leftText;
11469
11516
  const leftOrigin = {
11470
11517
  phase: "tick",
@@ -11511,46 +11558,46 @@ function transformNullishCoalescing(node, ctx2) {
11511
11558
  function assertNever2(expr) {
11512
11559
  const kind2 = expr?.kind;
11513
11560
  throw new Error(
11514
- `transformJsxExpression: unhandled ts.SyntaxKind ${kind2 !== void 0 ? ts12.SyntaxKind[kind2] : "unknown"} (kind=${kind2}). Update spec/compiler.md Appendix A and the switch in jsx-to-ir.ts.`
11561
+ `transformJsxExpression: unhandled ts.SyntaxKind ${kind2 !== void 0 ? ts13.SyntaxKind[kind2] : "unknown"} (kind=${kind2}). Update spec/compiler.md Appendix A and the switch in jsx-to-ir.ts.`
11515
11562
  );
11516
11563
  }
11517
11564
  function transformJsxExpression(expr, ctx2, isClientOnly = false) {
11518
11565
  const node = expr;
11519
11566
  switch (node.kind) {
11520
11567
  // --- Transparent: unwrap and recurse ---
11521
- case ts12.SyntaxKind.ParenthesizedExpression:
11522
- case ts12.SyntaxKind.AsExpression:
11523
- case ts12.SyntaxKind.SatisfiesExpression:
11524
- case ts12.SyntaxKind.NonNullExpression:
11525
- case ts12.SyntaxKind.TypeAssertionExpression:
11526
- case ts12.SyntaxKind.PartiallyEmittedExpression:
11568
+ case ts13.SyntaxKind.ParenthesizedExpression:
11569
+ case ts13.SyntaxKind.AsExpression:
11570
+ case ts13.SyntaxKind.SatisfiesExpression:
11571
+ case ts13.SyntaxKind.NonNullExpression:
11572
+ case ts13.SyntaxKind.TypeAssertionExpression:
11573
+ case ts13.SyntaxKind.PartiallyEmittedExpression:
11527
11574
  return transformJsxExpression(node.expression, ctx2, isClientOnly);
11528
11575
  // --- JSX-structural: delegate to shape transformer ---
11529
- case ts12.SyntaxKind.JsxElement:
11576
+ case ts13.SyntaxKind.JsxElement:
11530
11577
  return transformJsxElement(node, ctx2);
11531
- case ts12.SyntaxKind.JsxFragment:
11578
+ case ts13.SyntaxKind.JsxFragment:
11532
11579
  return transformFragment(node, ctx2);
11533
- case ts12.SyntaxKind.JsxSelfClosingElement:
11580
+ case ts13.SyntaxKind.JsxSelfClosingElement:
11534
11581
  return transformSelfClosingElement(node, ctx2);
11535
- case ts12.SyntaxKind.ConditionalExpression:
11582
+ case ts13.SyntaxKind.ConditionalExpression:
11536
11583
  return transformConditional(node, ctx2);
11537
- case ts12.SyntaxKind.BinaryExpression: {
11538
- if (node.operatorToken.kind === ts12.SyntaxKind.AmpersandAmpersandToken) {
11584
+ case ts13.SyntaxKind.BinaryExpression: {
11585
+ if (node.operatorToken.kind === ts13.SyntaxKind.AmpersandAmpersandToken) {
11539
11586
  return transformLogicalAnd(node, ctx2);
11540
11587
  }
11541
- if ((node.operatorToken.kind === ts12.SyntaxKind.QuestionQuestionToken || node.operatorToken.kind === ts12.SyntaxKind.BarBarToken) && (containsJsxInExpression(node.right) || callsJsxHelper(node.right, ctx2))) {
11588
+ if ((node.operatorToken.kind === ts13.SyntaxKind.QuestionQuestionToken || node.operatorToken.kind === ts13.SyntaxKind.BarBarToken) && (containsJsxInExpression(node.right) || callsJsxHelper(node.right, ctx2))) {
11542
11589
  return transformNullishCoalescing(node, ctx2);
11543
11590
  }
11544
11591
  return null;
11545
11592
  }
11546
- case ts12.SyntaxKind.CallExpression: {
11593
+ case ts13.SyntaxKind.CallExpression: {
11547
11594
  const mapMethod = getMapLikeMethod(node);
11548
11595
  if (mapMethod) {
11549
11596
  const mapResult = transformMapCall(node, ctx2, isClientOnly, mapMethod);
11550
11597
  if (mapResult) return mapResult;
11551
11598
  }
11552
11599
  const callee = node.expression;
11553
- if (ts12.isIdentifier(callee)) {
11600
+ if (ts13.isIdentifier(callee)) {
11554
11601
  const jsxFunc = ctx2.analyzer.jsxFunctions.get(callee.text);
11555
11602
  if (jsxFunc) {
11556
11603
  return transformJsxFunctionCall(node, jsxFunc, ctx2, isClientOnly);
@@ -11563,40 +11610,40 @@ function transformJsxExpression(expr, ctx2, isClientOnly = false) {
11563
11610
  return null;
11564
11611
  }
11565
11612
  // --- Scalar leaf: caller emits IRExpression ---
11566
- case ts12.SyntaxKind.Identifier:
11567
- case ts12.SyntaxKind.StringLiteral:
11568
- case ts12.SyntaxKind.NumericLiteral:
11569
- case ts12.SyntaxKind.BigIntLiteral:
11570
- case ts12.SyntaxKind.RegularExpressionLiteral:
11571
- case ts12.SyntaxKind.NoSubstitutionTemplateLiteral:
11572
- case ts12.SyntaxKind.TemplateExpression:
11573
- case ts12.SyntaxKind.TaggedTemplateExpression:
11574
- case ts12.SyntaxKind.TrueKeyword:
11575
- case ts12.SyntaxKind.FalseKeyword:
11576
- case ts12.SyntaxKind.NullKeyword:
11577
- case ts12.SyntaxKind.ThisKeyword:
11578
- case ts12.SyntaxKind.SuperKeyword:
11579
- case ts12.SyntaxKind.ImportKeyword:
11580
- case ts12.SyntaxKind.PropertyAccessExpression:
11581
- case ts12.SyntaxKind.ElementAccessExpression:
11582
- case ts12.SyntaxKind.PrefixUnaryExpression:
11583
- case ts12.SyntaxKind.PostfixUnaryExpression:
11584
- case ts12.SyntaxKind.TypeOfExpression:
11585
- case ts12.SyntaxKind.VoidExpression:
11586
- case ts12.SyntaxKind.DeleteExpression:
11587
- case ts12.SyntaxKind.NewExpression:
11588
- case ts12.SyntaxKind.ObjectLiteralExpression:
11589
- case ts12.SyntaxKind.ArrowFunction:
11590
- case ts12.SyntaxKind.FunctionExpression:
11591
- case ts12.SyntaxKind.ClassExpression:
11592
- case ts12.SyntaxKind.MetaProperty:
11593
- case ts12.SyntaxKind.ExpressionWithTypeArguments:
11594
- case ts12.SyntaxKind.CommaListExpression:
11595
- case ts12.SyntaxKind.SyntheticExpression:
11596
- case ts12.SyntaxKind.ArrayLiteralExpression:
11613
+ case ts13.SyntaxKind.Identifier:
11614
+ case ts13.SyntaxKind.StringLiteral:
11615
+ case ts13.SyntaxKind.NumericLiteral:
11616
+ case ts13.SyntaxKind.BigIntLiteral:
11617
+ case ts13.SyntaxKind.RegularExpressionLiteral:
11618
+ case ts13.SyntaxKind.NoSubstitutionTemplateLiteral:
11619
+ case ts13.SyntaxKind.TemplateExpression:
11620
+ case ts13.SyntaxKind.TaggedTemplateExpression:
11621
+ case ts13.SyntaxKind.TrueKeyword:
11622
+ case ts13.SyntaxKind.FalseKeyword:
11623
+ case ts13.SyntaxKind.NullKeyword:
11624
+ case ts13.SyntaxKind.ThisKeyword:
11625
+ case ts13.SyntaxKind.SuperKeyword:
11626
+ case ts13.SyntaxKind.ImportKeyword:
11627
+ case ts13.SyntaxKind.PropertyAccessExpression:
11628
+ case ts13.SyntaxKind.ElementAccessExpression:
11629
+ case ts13.SyntaxKind.PrefixUnaryExpression:
11630
+ case ts13.SyntaxKind.PostfixUnaryExpression:
11631
+ case ts13.SyntaxKind.TypeOfExpression:
11632
+ case ts13.SyntaxKind.VoidExpression:
11633
+ case ts13.SyntaxKind.DeleteExpression:
11634
+ case ts13.SyntaxKind.NewExpression:
11635
+ case ts13.SyntaxKind.ObjectLiteralExpression:
11636
+ case ts13.SyntaxKind.ArrowFunction:
11637
+ case ts13.SyntaxKind.FunctionExpression:
11638
+ case ts13.SyntaxKind.ClassExpression:
11639
+ case ts13.SyntaxKind.MetaProperty:
11640
+ case ts13.SyntaxKind.ExpressionWithTypeArguments:
11641
+ case ts13.SyntaxKind.CommaListExpression:
11642
+ case ts13.SyntaxKind.SyntheticExpression:
11643
+ case ts13.SyntaxKind.ArrayLiteralExpression:
11597
11644
  return null;
11598
11645
  // --- Forbidden in render position ---
11599
- case ts12.SyntaxKind.AwaitExpression:
11646
+ case ts13.SyntaxKind.AwaitExpression:
11600
11647
  ctx2.analyzer.errors.push(
11601
11648
  createError(
11602
11649
  ErrorCodes.STAGE_AWAIT_IN_TEMPLATE,
@@ -11612,20 +11659,20 @@ function transformJsxExpression(expr, ctx2, isClientOnly = false) {
11612
11659
  loc: getSourceLocation(node, ctx2.sourceFile, ctx2.filePath),
11613
11660
  origin: { phase: "tick", scope: "template", effect: "pure", freeRefs: [] }
11614
11661
  };
11615
- case ts12.SyntaxKind.YieldExpression:
11662
+ case ts13.SyntaxKind.YieldExpression:
11616
11663
  return null;
11617
11664
  // --- Unreachable at render position ---
11618
11665
  // Parser prevents these in well-formed sources; listed for exhaustiveness
11619
11666
  // so an upstream TypeScript change that repurposes one of these kinds
11620
11667
  // surfaces as a compile error here instead of silently drifting.
11621
- case ts12.SyntaxKind.SpreadElement:
11622
- case ts12.SyntaxKind.OmittedExpression:
11623
- case ts12.SyntaxKind.JsxExpression:
11624
- case ts12.SyntaxKind.JsxOpeningElement:
11625
- case ts12.SyntaxKind.JsxOpeningFragment:
11626
- case ts12.SyntaxKind.JsxClosingFragment:
11627
- case ts12.SyntaxKind.JsxAttributes:
11628
- case ts12.SyntaxKind.MissingDeclaration:
11668
+ case ts13.SyntaxKind.SpreadElement:
11669
+ case ts13.SyntaxKind.OmittedExpression:
11670
+ case ts13.SyntaxKind.JsxExpression:
11671
+ case ts13.SyntaxKind.JsxOpeningElement:
11672
+ case ts13.SyntaxKind.JsxOpeningFragment:
11673
+ case ts13.SyntaxKind.JsxClosingFragment:
11674
+ case ts13.SyntaxKind.JsxAttributes:
11675
+ case ts13.SyntaxKind.MissingDeclaration:
11629
11676
  return null;
11630
11677
  default:
11631
11678
  return assertNever2(node);
@@ -11661,15 +11708,15 @@ function transformConditionalBranch(node, ctx2) {
11661
11708
  };
11662
11709
  }
11663
11710
  function getMapLikeMethod(node) {
11664
- if (!ts12.isPropertyAccessExpression(node.expression)) return null;
11711
+ if (!ts13.isPropertyAccessExpression(node.expression)) return null;
11665
11712
  const name2 = node.expression.name.text;
11666
11713
  if (name2 === "map") return "map";
11667
11714
  if (name2 === "flatMap") return "flatMap";
11668
11715
  return null;
11669
11716
  }
11670
11717
  function isFilterCall(node) {
11671
- if (!ts12.isCallExpression(node)) return null;
11672
- if (!ts12.isPropertyAccessExpression(node.expression)) return null;
11718
+ if (!ts13.isCallExpression(node)) return null;
11719
+ if (!ts13.isPropertyAccessExpression(node.expression)) return null;
11673
11720
  if (node.expression.name.text !== "filter") return null;
11674
11721
  if (node.arguments.length !== 1) return null;
11675
11722
  return {
@@ -11678,8 +11725,8 @@ function isFilterCall(node) {
11678
11725
  };
11679
11726
  }
11680
11727
  function isSortCall(node) {
11681
- if (!ts12.isCallExpression(node)) return null;
11682
- if (!ts12.isPropertyAccessExpression(node.expression)) return null;
11728
+ if (!ts13.isCallExpression(node)) return null;
11729
+ if (!ts13.isPropertyAccessExpression(node.expression)) return null;
11683
11730
  const methodName = node.expression.name.text;
11684
11731
  if (methodName !== "sort" && methodName !== "toSorted") return null;
11685
11732
  if (node.arguments.length !== 1) return null;
@@ -11690,17 +11737,17 @@ function isSortCall(node) {
11690
11737
  };
11691
11738
  }
11692
11739
  function isIteratorShapeCall(node) {
11693
- if (!ts12.isCallExpression(node)) return null;
11694
- if (!ts12.isPropertyAccessExpression(node.expression)) return null;
11740
+ if (!ts13.isCallExpression(node)) return null;
11741
+ if (!ts13.isPropertyAccessExpression(node.expression)) return null;
11695
11742
  if (node.arguments.length !== 0) return null;
11696
11743
  const name2 = node.expression.name.text;
11697
11744
  if (name2 !== "entries" && name2 !== "keys" && name2 !== "values") return null;
11698
11745
  return { array: node.expression.expression, shape: name2 };
11699
11746
  }
11700
11747
  function isObjectIteratorCall(node) {
11701
- if (!ts12.isCallExpression(node)) return null;
11702
- if (!ts12.isPropertyAccessExpression(node.expression)) return null;
11703
- if (!ts12.isIdentifier(node.expression.expression)) return null;
11748
+ if (!ts13.isCallExpression(node)) return null;
11749
+ if (!ts13.isPropertyAccessExpression(node.expression)) return null;
11750
+ if (!ts13.isIdentifier(node.expression.expression)) return null;
11704
11751
  if (node.expression.expression.text !== "Object") return null;
11705
11752
  if (node.arguments.length !== 1) return null;
11706
11753
  const name2 = node.expression.name.text;
@@ -11721,7 +11768,7 @@ function extractSortComparator(callback, _method, ctx2) {
11721
11768
  (reverse the operands for descending order).`
11722
11769
  });
11723
11770
  let resolvedNode = callback;
11724
- if (ts12.isIdentifier(callback)) {
11771
+ if (ts13.isIdentifier(callback)) {
11725
11772
  const resolved = resolveSortComparatorIdentifier(callback.text, ctx2);
11726
11773
  if (!resolved) {
11727
11774
  return {
@@ -11731,7 +11778,7 @@ function extractSortComparator(callback, _method, ctx2) {
11731
11778
  }
11732
11779
  resolvedNode = resolved;
11733
11780
  }
11734
- if (!ts12.isArrowFunction(resolvedNode) && !ts12.isFunctionExpression(resolvedNode)) {
11781
+ if (!ts13.isArrowFunction(resolvedNode) && !ts13.isFunctionExpression(resolvedNode)) {
11735
11782
  return {
11736
11783
  result: null,
11737
11784
  unsupportedReason: "Sort comparator must be an arrow function or function expression"
@@ -11755,11 +11802,11 @@ function resolveSortComparatorIdentifier(name2, ctx2) {
11755
11802
  if (constInfo && fnInfo) return null;
11756
11803
  if (constInfo) {
11757
11804
  const ast = parseConstInitializer(constInfo);
11758
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11805
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11759
11806
  }
11760
11807
  if (fnInfo) {
11761
11808
  const ast = parseFunctionInfoAsExpr(fnInfo);
11762
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11809
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11763
11810
  }
11764
11811
  return null;
11765
11812
  }
@@ -11769,11 +11816,11 @@ function resolveCallbackMethodFunctionReferenceIdentifier(name2, analyzer) {
11769
11816
  if (constInfo && fnInfo) return null;
11770
11817
  if (constInfo) {
11771
11818
  const ast = parseConstInitializer(constInfo);
11772
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11819
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11773
11820
  }
11774
11821
  if (fnInfo) {
11775
11822
  const ast = parseFunctionInfoAsExpr(fnInfo);
11776
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11823
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11777
11824
  }
11778
11825
  return null;
11779
11826
  }
@@ -11828,11 +11875,11 @@ function resolveCallbackMethodFunctionReferences(expr, analyzer, bound = EMPTY_B
11828
11875
  return visit3(expr, bound);
11829
11876
  }
11830
11877
  function extractFilterPredicate(callback, ctx2) {
11831
- if (!ts12.isArrowFunction(callback)) return { result: null };
11878
+ if (!ts13.isArrowFunction(callback)) return { result: null };
11832
11879
  if (callback.parameters.length < 1) return { result: null };
11833
11880
  const firstParam = callback.parameters[0];
11834
- if (!ts12.isIdentifier(firstParam.name)) {
11835
- if (ts12.isBlock(callback.body)) {
11881
+ if (!ts13.isIdentifier(firstParam.name)) {
11882
+ if (ts13.isBlock(callback.body)) {
11836
11883
  return {
11837
11884
  result: null,
11838
11885
  unsupportedReason: "Block body in a destructured filter param is not supported. Workaround: use an expression-body arrow, or add /* @client */."
@@ -11852,7 +11899,7 @@ function extractFilterPredicate(callback, ctx2) {
11852
11899
  return { result: null };
11853
11900
  }
11854
11901
  const param = firstParam.name.getText(ctx2.sourceFile);
11855
- if (ts12.isBlock(callback.body)) {
11902
+ if (ts13.isBlock(callback.body)) {
11856
11903
  const raw2 = ctx2.getJS(callback.body);
11857
11904
  const statements = parseBlockBody(callback.body, ctx2.sourceFile, (n) => ctx2.getJS(n));
11858
11905
  if (!statements) {
@@ -11878,14 +11925,14 @@ function extractFilterPredicate(callback, ctx2) {
11878
11925
  return { result: { param, predicate, raw } };
11879
11926
  }
11880
11927
  function extractLoopParamBindings(pattern) {
11881
- if (ts12.isIdentifier(pattern)) return null;
11928
+ if (ts13.isIdentifier(pattern)) return null;
11882
11929
  const bindings = [];
11883
11930
  let unsupported = false;
11884
11931
  const isIdent = (key) => {
11885
11932
  if (key.length === 0) return false;
11886
11933
  for (let i = 0; i < key.length; ) {
11887
11934
  const cp = key.codePointAt(i);
11888
- const ok = i === 0 ? ts12.isIdentifierStart(cp, ts12.ScriptTarget.Latest) : ts12.isIdentifierPart(cp, ts12.ScriptTarget.Latest);
11935
+ const ok = i === 0 ? ts13.isIdentifierStart(cp, ts13.ScriptTarget.Latest) : ts13.isIdentifierPart(cp, ts13.ScriptTarget.Latest);
11889
11936
  if (!ok) return false;
11890
11937
  i += cp > 65535 ? 2 : 1;
11891
11938
  }
@@ -11896,19 +11943,19 @@ function extractLoopParamBindings(pattern) {
11896
11943
  };
11897
11944
  const walk = (p, prefix2, segments) => {
11898
11945
  if (unsupported) return;
11899
- if (ts12.isArrayBindingPattern(p)) {
11946
+ if (ts13.isArrayBindingPattern(p)) {
11900
11947
  const elements3 = p.elements;
11901
11948
  for (let index = 0; index < elements3.length; index++) {
11902
11949
  if (unsupported) return;
11903
11950
  const el = elements3[index];
11904
- if (ts12.isOmittedExpression(el)) continue;
11951
+ if (ts13.isOmittedExpression(el)) continue;
11905
11952
  if (el.dotDotDotToken) {
11906
11953
  internalInvariant(
11907
11954
  index === elements3.length - 1,
11908
11955
  "extractLoopParamBindings: array rest token in non-final position (parser should reject)"
11909
11956
  );
11910
11957
  internalInvariant(
11911
- ts12.isIdentifier(el.name),
11958
+ ts13.isIdentifier(el.name),
11912
11959
  "extractLoopParamBindings: array rest target is not an identifier (parser should reject)"
11913
11960
  );
11914
11961
  bindings.push({
@@ -11921,7 +11968,7 @@ function extractLoopParamBindings(pattern) {
11921
11968
  }
11922
11969
  const path25 = `${prefix2}[${index}]`;
11923
11970
  const nextSegments = [...segments, { kind: "index", index }];
11924
- if (ts12.isIdentifier(el.name)) {
11971
+ if (ts13.isIdentifier(el.name)) {
11925
11972
  bindings.push({ name: el.name.text, path: path25, segments: nextSegments });
11926
11973
  } else {
11927
11974
  walk(el.name, path25, nextSegments);
@@ -11940,7 +11987,7 @@ function extractLoopParamBindings(pattern) {
11940
11987
  "extractLoopParamBindings: object rest token in non-final position (parser should reject)"
11941
11988
  );
11942
11989
  internalInvariant(
11943
- ts12.isIdentifier(el.name),
11990
+ ts13.isIdentifier(el.name),
11944
11991
  "extractLoopParamBindings: object rest target is not an identifier (parser should reject)"
11945
11992
  );
11946
11993
  bindings.push({
@@ -11954,14 +12001,14 @@ function extractLoopParamBindings(pattern) {
11954
12001
  let keyText2 = null;
11955
12002
  if (el.propertyName) {
11956
12003
  const pn = el.propertyName;
11957
- if (ts12.isIdentifier(pn)) keyText2 = pn.text;
11958
- else if (ts12.isStringLiteral(pn)) keyText2 = pn.text;
11959
- else if (ts12.isNumericLiteral(pn)) keyText2 = pn.text;
12004
+ if (ts13.isIdentifier(pn)) keyText2 = pn.text;
12005
+ else if (ts13.isStringLiteral(pn)) keyText2 = pn.text;
12006
+ else if (ts13.isNumericLiteral(pn)) keyText2 = pn.text;
11960
12007
  else {
11961
12008
  unsupported = true;
11962
12009
  return;
11963
12010
  }
11964
- } else if (ts12.isIdentifier(el.name)) {
12011
+ } else if (ts13.isIdentifier(el.name)) {
11965
12012
  keyText2 = el.name.text;
11966
12013
  } else {
11967
12014
  unsupported = true;
@@ -11971,14 +12018,14 @@ function extractLoopParamBindings(pattern) {
11971
12018
  collectedKeys.push({ key: keyText2, isIdent: keyIsIdent });
11972
12019
  const path25 = appendDotAccess(prefix2, keyText2);
11973
12020
  const nextSegments = [...segments, { kind: "field", key: keyText2, isIdent: keyIsIdent }];
11974
- if (ts12.isIdentifier(el.name)) {
12021
+ if (ts13.isIdentifier(el.name)) {
11975
12022
  bindings.push({ name: el.name.text, path: path25, segments: nextSegments });
11976
12023
  } else {
11977
12024
  walk(el.name, path25, nextSegments);
11978
12025
  }
11979
12026
  }
11980
12027
  };
11981
- if (ts12.isArrayBindingPattern(pattern) || ts12.isObjectBindingPattern(pattern)) {
12028
+ if (ts13.isArrayBindingPattern(pattern) || ts13.isObjectBindingPattern(pattern)) {
11982
12029
  walk(pattern, "", []);
11983
12030
  if (unsupported) return { unsupported: true };
11984
12031
  return bindings;
@@ -11987,7 +12034,7 @@ function extractLoopParamBindings(pattern) {
11987
12034
  }
11988
12035
  function findKeyJsxAttribute(opening) {
11989
12036
  for (const prop of opening.attributes.properties) {
11990
- if (ts12.isJsxAttribute(prop) && prop.name.getText() === "key") {
12037
+ if (ts13.isJsxAttribute(prop) && prop.name.getText() === "key") {
11991
12038
  return prop;
11992
12039
  }
11993
12040
  }
@@ -12028,7 +12075,7 @@ function keyAttrValueToExpr(v) {
12028
12075
  function normalizeKeyExpr(expr) {
12029
12076
  let out = "";
12030
12077
  for (const tok of iterateJsTokens(expr)) {
12031
- if (tok.kind === ts12.SyntaxKind.WhitespaceTrivia || tok.kind === ts12.SyntaxKind.NewLineTrivia) {
12078
+ if (tok.kind === ts13.SyntaxKind.WhitespaceTrivia || tok.kind === ts13.SyntaxKind.NewLineTrivia) {
12032
12079
  continue;
12033
12080
  }
12034
12081
  out += expr.slice(tok.pos, tok.end);
@@ -12040,33 +12087,33 @@ function conditionalHasExplicitNullishBranch(cond) {
12040
12087
  }
12041
12088
  function branchHasExplicitNullish(branch) {
12042
12089
  let b = branch;
12043
- while (ts12.isParenthesizedExpression(b)) b = b.expression;
12044
- if (b.kind === ts12.SyntaxKind.NullKeyword) return true;
12045
- if (ts12.isIdentifier(b) && b.text === "undefined") return true;
12046
- if (ts12.isConditionalExpression(b)) return conditionalHasExplicitNullishBranch(b);
12090
+ while (ts13.isParenthesizedExpression(b)) b = b.expression;
12091
+ if (b.kind === ts13.SyntaxKind.NullKeyword) return true;
12092
+ if (ts13.isIdentifier(b) && b.text === "undefined") return true;
12093
+ if (ts13.isConditionalExpression(b)) return conditionalHasExplicitNullishBranch(b);
12047
12094
  return false;
12048
12095
  }
12049
12096
  function classifyKeyProblem(keyAttr, checker) {
12050
12097
  if (!keyAttr) return "missing";
12051
12098
  if (!keyAttr.initializer) return "missing";
12052
- if (ts12.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
12099
+ if (ts13.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
12053
12100
  return "missing";
12054
12101
  }
12055
12102
  let expr;
12056
- if (ts12.isStringLiteral(keyAttr.initializer)) {
12103
+ if (ts13.isStringLiteral(keyAttr.initializer)) {
12057
12104
  return null;
12058
- } else if (ts12.isJsxExpression(keyAttr.initializer)) {
12105
+ } else if (ts13.isJsxExpression(keyAttr.initializer)) {
12059
12106
  expr = keyAttr.initializer.expression;
12060
12107
  }
12061
12108
  if (!expr) return null;
12062
- if (expr.kind === ts12.SyntaxKind.NullKeyword) return null;
12063
- if (ts12.isIdentifier(expr) && expr.text === "undefined") return null;
12064
- if (ts12.isConditionalExpression(expr) && conditionalHasExplicitNullishBranch(expr)) return null;
12109
+ if (expr.kind === ts13.SyntaxKind.NullKeyword) return null;
12110
+ if (ts13.isIdentifier(expr) && expr.text === "undefined") return null;
12111
+ if (ts13.isConditionalExpression(expr) && conditionalHasExplicitNullishBranch(expr)) return null;
12065
12112
  if (checker) {
12066
12113
  const type2 = checker.getTypeAtLocation(expr);
12067
12114
  const isNullable = type2.isUnion() ? type2.types.some(
12068
- (t) => (t.flags & (ts12.TypeFlags.Null | ts12.TypeFlags.Undefined | ts12.TypeFlags.Void)) !== 0
12069
- ) : (type2.flags & (ts12.TypeFlags.Null | ts12.TypeFlags.Undefined | ts12.TypeFlags.Void)) !== 0;
12115
+ (t) => (t.flags & (ts13.TypeFlags.Null | ts13.TypeFlags.Undefined | ts13.TypeFlags.Void)) !== 0
12116
+ ) : (type2.flags & (ts13.TypeFlags.Null | ts13.TypeFlags.Undefined | ts13.TypeFlags.Void)) !== 0;
12070
12117
  if (isNullable) return "nullable-type";
12071
12118
  }
12072
12119
  return null;
@@ -12095,70 +12142,70 @@ function checkLoopKey(callback, ctx2, isNested) {
12095
12142
  );
12096
12143
  }
12097
12144
  let body2 = callback.body;
12098
- if (ts12.isBlock(body2)) {
12145
+ if (ts13.isBlock(body2)) {
12099
12146
  const ret = body2.statements.find(
12100
- (s) => ts12.isReturnStatement(s) && s.expression != null
12147
+ (s) => ts13.isReturnStatement(s) && s.expression != null
12101
12148
  );
12102
12149
  if (!ret?.expression) return;
12103
12150
  body2 = ret.expression;
12104
12151
  }
12105
- while (ts12.isParenthesizedExpression(body2)) body2 = body2.expression;
12152
+ while (ts13.isParenthesizedExpression(body2)) body2 = body2.expression;
12106
12153
  function checkJsxOperand(node) {
12107
12154
  let n = node;
12108
- while (ts12.isParenthesizedExpression(n)) n = n.expression;
12109
- if (ts12.isJsxElement(n)) checkOpening(n.openingElement);
12110
- else if (ts12.isJsxSelfClosingElement(n)) checkOpening(n);
12155
+ while (ts13.isParenthesizedExpression(n)) n = n.expression;
12156
+ if (ts13.isJsxElement(n)) checkOpening(n.openingElement);
12157
+ else if (ts13.isJsxSelfClosingElement(n)) checkOpening(n);
12111
12158
  }
12112
- if (ts12.isConditionalExpression(body2)) {
12159
+ if (ts13.isConditionalExpression(body2)) {
12113
12160
  checkJsxOperand(body2.whenTrue);
12114
12161
  checkJsxOperand(body2.whenFalse);
12115
12162
  return;
12116
12163
  }
12117
- if (ts12.isBinaryExpression(body2) && (body2.operatorToken.kind === ts12.SyntaxKind.AmpersandAmpersandToken || body2.operatorToken.kind === ts12.SyntaxKind.BarBarToken || body2.operatorToken.kind === ts12.SyntaxKind.QuestionQuestionToken)) {
12164
+ if (ts13.isBinaryExpression(body2) && (body2.operatorToken.kind === ts13.SyntaxKind.AmpersandAmpersandToken || body2.operatorToken.kind === ts13.SyntaxKind.BarBarToken || body2.operatorToken.kind === ts13.SyntaxKind.QuestionQuestionToken)) {
12118
12165
  checkJsxOperand(body2.left);
12119
12166
  checkJsxOperand(body2.right);
12120
12167
  return;
12121
12168
  }
12122
- if (ts12.isJsxElement(body2)) {
12169
+ if (ts13.isJsxElement(body2)) {
12123
12170
  checkOpening(body2.openingElement);
12124
12171
  return;
12125
12172
  }
12126
- if (ts12.isJsxSelfClosingElement(body2)) {
12173
+ if (ts13.isJsxSelfClosingElement(body2)) {
12127
12174
  checkOpening(body2);
12128
12175
  return;
12129
12176
  }
12130
12177
  }
12131
12178
  function flatMapProjectionCall(body2) {
12132
12179
  let expr;
12133
- if (ts12.isBlock(body2)) {
12180
+ if (ts13.isBlock(body2)) {
12134
12181
  const real = body2.statements;
12135
- if (real.length !== 1 || !ts12.isReturnStatement(real[0]) || !real[0].expression) return null;
12182
+ if (real.length !== 1 || !ts13.isReturnStatement(real[0]) || !real[0].expression) return null;
12136
12183
  expr = real[0].expression;
12137
12184
  } else {
12138
12185
  expr = body2;
12139
12186
  }
12140
- while (ts12.isParenthesizedExpression(expr)) expr = expr.expression;
12141
- if (!ts12.isCallExpression(expr)) return null;
12187
+ while (ts13.isParenthesizedExpression(expr)) expr = expr.expression;
12188
+ if (!ts13.isCallExpression(expr)) return null;
12142
12189
  if (!getMapLikeMethod(expr)) return null;
12143
12190
  const cb = expr.arguments[0];
12144
- if (!cb || !ts12.isArrowFunction(cb) && !ts12.isFunctionExpression(cb)) return null;
12191
+ if (!cb || !ts13.isArrowFunction(cb) && !ts13.isFunctionExpression(cb)) return null;
12145
12192
  for (const p of cb.parameters) {
12146
- if (!ts12.isIdentifier(p.name)) return null;
12193
+ if (!ts13.isIdentifier(p.name)) return null;
12147
12194
  }
12148
12195
  let innerBody = cb.body;
12149
- if (ts12.isBlock(innerBody)) {
12196
+ if (ts13.isBlock(innerBody)) {
12150
12197
  const ret = innerBody.statements.find(
12151
- (s) => ts12.isReturnStatement(s) && s.expression != null
12198
+ (s) => ts13.isReturnStatement(s) && s.expression != null
12152
12199
  );
12153
12200
  if (innerBody.statements.length !== 1 || !ret?.expression) return null;
12154
12201
  innerBody = ret.expression;
12155
12202
  }
12156
- while (ts12.isParenthesizedExpression(innerBody)) innerBody = innerBody.expression;
12203
+ while (ts13.isParenthesizedExpression(innerBody)) innerBody = innerBody.expression;
12157
12204
  const isElementish = (n) => {
12158
12205
  let m = n;
12159
- while (ts12.isParenthesizedExpression(m)) m = m.expression;
12160
- if (ts12.isJsxElement(m) || ts12.isJsxSelfClosingElement(m)) return leafIsWirelessElement(m);
12161
- if (ts12.isConditionalExpression(m)) return isElementish(m.whenTrue) && isElementish(m.whenFalse);
12206
+ while (ts13.isParenthesizedExpression(m)) m = m.expression;
12207
+ if (ts13.isJsxElement(m) || ts13.isJsxSelfClosingElement(m)) return leafIsWirelessElement(m);
12208
+ if (ts13.isConditionalExpression(m)) return isElementish(m.whenTrue) && isElementish(m.whenFalse);
12162
12209
  return false;
12163
12210
  };
12164
12211
  if (!isElementish(innerBody)) return null;
@@ -12168,19 +12215,19 @@ function leafIsWirelessElement(el) {
12168
12215
  let ok = true;
12169
12216
  const visit3 = (n) => {
12170
12217
  if (!ok) return;
12171
- if (ts12.isJsxOpeningElement(n) || ts12.isJsxSelfClosingElement(n)) {
12218
+ if (ts13.isJsxOpeningElement(n) || ts13.isJsxSelfClosingElement(n)) {
12172
12219
  const tagNode = n.tagName;
12173
- const isIntrinsic = ts12.isIdentifier(tagNode) ? !/^[A-Z]/.test(tagNode.text) : ts12.isJsxNamespacedName(tagNode);
12220
+ const isIntrinsic = ts13.isIdentifier(tagNode) ? !/^[A-Z]/.test(tagNode.text) : ts13.isJsxNamespacedName(tagNode);
12174
12221
  if (!isIntrinsic) {
12175
12222
  ok = false;
12176
12223
  return;
12177
12224
  }
12178
12225
  for (const attr of n.attributes.properties) {
12179
- if (ts12.isJsxSpreadAttribute(attr)) {
12226
+ if (ts13.isJsxSpreadAttribute(attr)) {
12180
12227
  ok = false;
12181
12228
  return;
12182
12229
  }
12183
- if (ts12.isJsxAttribute(attr)) {
12230
+ if (ts13.isJsxAttribute(attr)) {
12184
12231
  const name2 = attr.name.getText();
12185
12232
  if (/^on[A-Z]/.test(name2)) {
12186
12233
  ok = false;
@@ -12189,11 +12236,11 @@ function leafIsWirelessElement(el) {
12189
12236
  }
12190
12237
  }
12191
12238
  }
12192
- if (ts12.isCallExpression(n) && getMapLikeMethod(n) && containsJsxInExpression(n)) {
12239
+ if (ts13.isCallExpression(n) && getMapLikeMethod(n) && containsJsxInExpression(n)) {
12193
12240
  ok = false;
12194
12241
  return;
12195
12242
  }
12196
- ts12.forEachChild(n, visit3);
12243
+ ts13.forEachChild(n, visit3);
12197
12244
  };
12198
12245
  visit3(el);
12199
12246
  return ok;
@@ -12397,7 +12444,7 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12397
12444
  let children2 = [];
12398
12445
  let paramBindings;
12399
12446
  let flatMapCallback;
12400
- if (ts12.isArrowFunction(callback)) {
12447
+ if (ts13.isArrowFunction(callback)) {
12401
12448
  if (callback.parameters.length > 0) {
12402
12449
  const firstParam = callback.parameters[0];
12403
12450
  param = firstParam.name.getText(ctx2.sourceFile);
@@ -12405,11 +12452,11 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12405
12452
  paramType = firstParam.type.getText(ctx2.sourceFile);
12406
12453
  }
12407
12454
  const isEntriesShape = iterationShape === "entries" || objectIteration === "entries";
12408
- if (isEntriesShape && ts12.isArrayBindingPattern(firstParam.name)) {
12455
+ if (isEntriesShape && ts13.isArrayBindingPattern(firstParam.name)) {
12409
12456
  const elements2 = firstParam.name.elements.filter(
12410
- (el) => !ts12.isOmittedExpression(el)
12457
+ (el) => !ts13.isOmittedExpression(el)
12411
12458
  );
12412
- if (elements2.length === 2 && ts12.isBindingElement(elements2[0]) && ts12.isIdentifier(elements2[0].name) && ts12.isBindingElement(elements2[1]) && ts12.isIdentifier(elements2[1].name)) {
12459
+ if (elements2.length === 2 && ts13.isBindingElement(elements2[0]) && ts13.isIdentifier(elements2[0].name) && ts13.isBindingElement(elements2[1]) && ts13.isIdentifier(elements2[1].name)) {
12413
12460
  index = elements2[0].name.text;
12414
12461
  param = elements2[1].name.text;
12415
12462
  } else {
@@ -12450,9 +12497,9 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12450
12497
  ctx2.scope = ctx2.scope.enterLoopRow({ param, index, paramBindings });
12451
12498
  ctx2.loopDepth++;
12452
12499
  const tryTransformRenderableBody = (expr) => {
12453
- if (!ts12.isBinaryExpression(expr)) return;
12500
+ if (!ts13.isBinaryExpression(expr)) return;
12454
12501
  const op = expr.operatorToken.kind;
12455
- if (op !== ts12.SyntaxKind.AmpersandAmpersandToken && op !== ts12.SyntaxKind.BarBarToken && op !== ts12.SyntaxKind.QuestionQuestionToken) {
12502
+ if (op !== ts13.SyntaxKind.AmpersandAmpersandToken && op !== ts13.SyntaxKind.BarBarToken && op !== ts13.SyntaxKind.QuestionQuestionToken) {
12456
12503
  return;
12457
12504
  }
12458
12505
  if (!containsJsxInExpression(expr) && !callsJsxHelper(expr, ctx2)) return;
@@ -12460,33 +12507,33 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12460
12507
  if (transformed) children2 = [transformed];
12461
12508
  };
12462
12509
  const body2 = callback.body;
12463
- if (ts12.isJsxElement(body2) || ts12.isJsxSelfClosingElement(body2) || ts12.isJsxFragment(body2)) {
12510
+ if (ts13.isJsxElement(body2) || ts13.isJsxSelfClosingElement(body2) || ts13.isJsxFragment(body2)) {
12464
12511
  const transformed = transformNode(body2, ctx2);
12465
12512
  if (transformed) {
12466
12513
  children2 = [transformed];
12467
12514
  }
12468
- } else if (ts12.isConditionalExpression(body2)) {
12515
+ } else if (ts13.isConditionalExpression(body2)) {
12469
12516
  children2 = [transformConditional(body2, ctx2)];
12470
- } else if (ts12.isParenthesizedExpression(body2)) {
12517
+ } else if (ts13.isParenthesizedExpression(body2)) {
12471
12518
  let inner = body2.expression;
12472
- while (ts12.isParenthesizedExpression(inner)) {
12519
+ while (ts13.isParenthesizedExpression(inner)) {
12473
12520
  inner = inner.expression;
12474
12521
  }
12475
- if (ts12.isJsxElement(inner) || ts12.isJsxSelfClosingElement(inner) || ts12.isJsxFragment(inner)) {
12522
+ if (ts13.isJsxElement(inner) || ts13.isJsxSelfClosingElement(inner) || ts13.isJsxFragment(inner)) {
12476
12523
  const transformed = transformNode(inner, ctx2);
12477
12524
  if (transformed) {
12478
12525
  children2 = [transformed];
12479
12526
  }
12480
- } else if (ts12.isConditionalExpression(inner)) {
12527
+ } else if (ts13.isConditionalExpression(inner)) {
12481
12528
  children2 = [transformConditional(inner, ctx2)];
12482
- } else if (method2 === "flatMap" && ts12.isArrayLiteralExpression(inner)) {
12529
+ } else if (method2 === "flatMap" && ts13.isArrayLiteralExpression(inner)) {
12483
12530
  children2 = transformArrayLiteralChildren(inner, ctx2);
12484
12531
  } else {
12485
12532
  tryTransformRenderableBody(inner);
12486
12533
  }
12487
- } else if (method2 === "flatMap" && ts12.isArrayLiteralExpression(body2)) {
12534
+ } else if (method2 === "flatMap" && ts13.isArrayLiteralExpression(body2)) {
12488
12535
  children2 = transformArrayLiteralChildren(body2, ctx2);
12489
- } else if (ts12.isBlock(body2)) {
12536
+ } else if (ts13.isBlock(body2)) {
12490
12537
  const multiReturn = method2 !== "flatMap" ? extractMultiReturnJsxBranches(body2, true) : null;
12491
12538
  if (multiReturn && multiReturn.branches.length > 0) {
12492
12539
  const loc = getSourceLocation(body2, ctx2.sourceFile, ctx2.filePath);
@@ -12507,7 +12554,7 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12507
12554
  }
12508
12555
  }
12509
12556
  const returnStmt = children2.length === 0 ? body2.statements.find(
12510
- (s) => ts12.isReturnStatement(s) && s.expression != null
12557
+ (s) => ts13.isReturnStatement(s) && s.expression != null
12511
12558
  ) : void 0;
12512
12559
  let rowScopeBeforePreamble = null;
12513
12560
  if (returnStmt) {
@@ -12528,10 +12575,10 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12528
12575
  }
12529
12576
  if (returnStmt && returnStmt.expression) {
12530
12577
  let returnExpr = returnStmt.expression;
12531
- while (ts12.isParenthesizedExpression(returnExpr)) {
12578
+ while (ts13.isParenthesizedExpression(returnExpr)) {
12532
12579
  returnExpr = returnExpr.expression;
12533
12580
  }
12534
- if (ts12.isJsxElement(returnExpr) || ts12.isJsxSelfClosingElement(returnExpr) || ts12.isJsxFragment(returnExpr)) {
12581
+ if (ts13.isJsxElement(returnExpr) || ts13.isJsxSelfClosingElement(returnExpr) || ts13.isJsxFragment(returnExpr)) {
12535
12582
  const transformed = transformNode(returnExpr, ctx2);
12536
12583
  if (transformed) {
12537
12584
  children2 = [transformed];
@@ -12635,7 +12682,7 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12635
12682
  }
12636
12683
  }
12637
12684
  }
12638
- if (method2 === "flatMap" && children2.length === 0 && !flatMapCallback && !ts12.isBlock(body2)) {
12685
+ if (method2 === "flatMap" && children2.length === 0 && !flatMapCallback && !ts13.isBlock(body2)) {
12639
12686
  flatMapCallback = buildFlatMapCallback(callback, body2, ctx2);
12640
12687
  }
12641
12688
  if (flatMapCallback) preamble = void 0;
@@ -12658,7 +12705,7 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12658
12705
  }
12659
12706
  if (children2.length === 0 && !flatMapCallback) {
12660
12707
  const cb = node.arguments[0];
12661
- const cbBody = cb && (ts12.isArrowFunction(cb) || ts12.isFunctionExpression(cb)) ? cb.body : void 0;
12708
+ const cbBody = cb && (ts13.isArrowFunction(cb) || ts13.isFunctionExpression(cb)) ? cb.body : void 0;
12662
12709
  if (cbBody && containsJsxInExpression(cbBody) && ctx2.analyzer.errors.length === diagCountAtEntry) {
12663
12710
  ctx2.analyzer.errors.push(
12664
12711
  createError(
@@ -12675,7 +12722,7 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12675
12722
  }
12676
12723
  return null;
12677
12724
  }
12678
- if (ts12.isArrowFunction(node.arguments[0]) && children2.length > 0) {
12725
+ if (ts13.isArrowFunction(node.arguments[0]) && children2.length > 0) {
12679
12726
  checkLoopKey(node.arguments[0], ctx2, isNested);
12680
12727
  }
12681
12728
  const itemConditional = children2.length > 0 ? loopBodyItemConditional(children2) : null;
@@ -12733,6 +12780,9 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12733
12780
  const preambleRegions = preamble && !isStaticArray ? collectPreambleRegions(children2, new Set(preamble.declaredNames), ctx2) : void 0;
12734
12781
  if (preamble && !isStaticArray) {
12735
12782
  markPreambleAttrSlots(children2, new Set(preamble.declaredNames), ctx2);
12783
+ if (preamble.reactiveNames && preamble.reactiveNames.length > 0) {
12784
+ markPreambleConditionalReactivity(children2, new Set(preamble.reactiveNames), ctx2);
12785
+ }
12736
12786
  }
12737
12787
  const nestedComponents = collectNestedComponents(children2).filter((c) => c.name !== childComponent?.name);
12738
12788
  return {
@@ -12783,10 +12833,10 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12783
12833
  function transformArrayLiteralChildren(arrayLiteral, ctx2) {
12784
12834
  const children2 = [];
12785
12835
  for (const element of arrayLiteral.elements) {
12786
- if (ts12.isSpreadElement(element)) continue;
12836
+ if (ts13.isSpreadElement(element)) continue;
12787
12837
  let inner = element;
12788
- while (ts12.isParenthesizedExpression(inner)) inner = inner.expression;
12789
- if (ts12.isJsxElement(inner) || ts12.isJsxSelfClosingElement(inner) || ts12.isJsxFragment(inner)) {
12838
+ while (ts13.isParenthesizedExpression(inner)) inner = inner.expression;
12839
+ if (ts13.isJsxElement(inner) || ts13.isJsxSelfClosingElement(inner) || ts13.isJsxFragment(inner)) {
12790
12840
  const transformed = transformNode(inner, ctx2);
12791
12841
  if (transformed) children2.push(transformed);
12792
12842
  }
@@ -12794,7 +12844,7 @@ function transformArrayLiteralChildren(arrayLiteral, ctx2) {
12794
12844
  return children2;
12795
12845
  }
12796
12846
  function containsJsx(node) {
12797
- if (ts12.isJsxElement(node) || ts12.isJsxSelfClosingElement(node) || ts12.isJsxFragment(node)) return true;
12847
+ if (ts13.isJsxElement(node) || ts13.isJsxSelfClosingElement(node) || ts13.isJsxFragment(node)) return true;
12798
12848
  let found = false;
12799
12849
  node.forEachChild((child) => {
12800
12850
  if (!found) found = containsJsx(child);
@@ -12807,14 +12857,14 @@ function buildFlatMapCallback(callback, body2, ctx2) {
12807
12857
  const leafIrs = [];
12808
12858
  let refusalNode;
12809
12859
  const collectJsx = (n, underTemplate) => {
12810
- if (ts12.isJsxElement(n) || ts12.isJsxSelfClosingElement(n) || ts12.isJsxFragment(n)) {
12860
+ if (ts13.isJsxElement(n) || ts13.isJsxSelfClosingElement(n) || ts13.isJsxFragment(n)) {
12811
12861
  if (underTemplate) refusalNode ??= n;
12812
12862
  leafSpans.push({ start: n.getStart(ctx2.sourceFile), end: n.getEnd() });
12813
12863
  const ir = transformNode(n, ctx2);
12814
12864
  leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx2.sourceFile, ctx2.filePath) });
12815
12865
  return;
12816
12866
  }
12817
- const inTemplate = underTemplate || ts12.isTemplateExpression(n) || ts12.isTaggedTemplateExpression(n);
12867
+ const inTemplate = underTemplate || ts13.isTemplateExpression(n) || ts13.isTaggedTemplateExpression(n);
12818
12868
  n.forEachChild((c) => collectJsx(c, inTemplate));
12819
12869
  };
12820
12870
  collectJsx(body2, false);
@@ -12999,6 +13049,31 @@ function markPreambleAttrSlots(nodes, declared, ctx2) {
12999
13049
  };
13000
13050
  visit3(nodes);
13001
13051
  }
13052
+ function markPreambleConditionalReactivity(nodes, reactiveNames, ctx2) {
13053
+ if (reactiveNames.size === 0) return;
13054
+ const visit3 = (list) => {
13055
+ for (const node of list) {
13056
+ switch (node.type) {
13057
+ case "element":
13058
+ case "fragment":
13059
+ visit3(node.children);
13060
+ break;
13061
+ case "conditional": {
13062
+ if (!node.reactive) {
13063
+ const refs = extractFreeIdentifiersFromText(node.condition);
13064
+ if ([...refs].some((r2) => reactiveNames.has(r2))) {
13065
+ node.reactive = true;
13066
+ if (!node.slotId) node.slotId = generateSlotId(ctx2);
13067
+ }
13068
+ }
13069
+ visit3([node.whenTrue, ...node.whenFalse ? [node.whenFalse] : []]);
13070
+ break;
13071
+ }
13072
+ }
13073
+ }
13074
+ };
13075
+ visit3(nodes);
13076
+ }
13002
13077
  function attrValueText(value2) {
13003
13078
  if (value2.kind === "expression") return value2.expr;
13004
13079
  if (value2.kind !== "template") return "";
@@ -13010,23 +13085,42 @@ function attrValueText(value2) {
13010
13085
  return out.join(" ");
13011
13086
  }
13012
13087
  function collectBindingNames2(name2, out) {
13013
- if (ts12.isIdentifier(name2)) {
13088
+ if (ts13.isIdentifier(name2)) {
13014
13089
  out.add(name2.text);
13015
13090
  return;
13016
13091
  }
13017
13092
  for (const el of name2.elements) {
13018
- if (ts12.isBindingElement(el)) collectBindingNames2(el.name, out);
13093
+ if (ts13.isBindingElement(el)) collectBindingNames2(el.name, out);
13019
13094
  }
13020
13095
  }
13021
13096
  function collectPreambleDeclaredNames(stmt, out) {
13022
- if (ts12.isVariableStatement(stmt)) {
13097
+ if (ts13.isVariableStatement(stmt)) {
13023
13098
  for (const decl of stmt.declarationList.declarations) {
13024
13099
  collectBindingNames2(decl.name, out);
13025
13100
  }
13026
- } else if (ts12.isFunctionDeclaration(stmt) && stmt.name) {
13101
+ } else if (ts13.isFunctionDeclaration(stmt) && stmt.name) {
13027
13102
  out.add(stmt.name.text);
13028
13103
  }
13029
13104
  }
13105
+ function computePreambleReactiveNames(statements, ctx2) {
13106
+ const reactiveNames = /* @__PURE__ */ new Set();
13107
+ for (const stmt of statements) {
13108
+ if (!ts13.isVariableStatement(stmt)) continue;
13109
+ for (const decl of stmt.declarationList.declarations) {
13110
+ if (!decl.initializer) continue;
13111
+ const boundNames = /* @__PURE__ */ new Set();
13112
+ collectBindingNames2(decl.name, boundNames);
13113
+ const initText = ctx2.getJS(decl.initializer);
13114
+ const initFreeRefs = extractFreeIdentifiersFromNode(decl.initializer);
13115
+ const readsEarlierReactive = [...initFreeRefs].some((r2) => reactiveNames.has(r2));
13116
+ const isReactive = readsEarlierReactive || isReactiveExpression(initText, ctx2, decl.initializer);
13117
+ if (isReactive) {
13118
+ for (const n of boundNames) reactiveNames.add(n);
13119
+ }
13120
+ }
13121
+ }
13122
+ return reactiveNames;
13123
+ }
13030
13124
  function preambleFromValueStatements(statements, ctx2) {
13031
13125
  const segments = [];
13032
13126
  const typedParts = [];
@@ -13041,21 +13135,23 @@ function preambleFromValueStatements(statements, ctx2) {
13041
13135
  typedParts.push(raw0.endsWith(";") ? raw0 : raw0 + ";");
13042
13136
  segments.push(tjs !== js ? { kind: "js", text: js, templateText: tjs } : { kind: "js", text: js });
13043
13137
  }
13138
+ const reactiveNames = computePreambleReactiveNames(statements, ctx2);
13044
13139
  return {
13045
13140
  segments: trimPreambleSegments(segments),
13046
13141
  ssrText: tsxSourceText(typedParts.join(" ")),
13047
13142
  declaredNames: [...declared],
13048
13143
  // Value-only preambles accumulate no JSX, so no child needs the array join.
13049
13144
  builderNames: [],
13050
- declarations: neutralPreambleDeclarations(statements, ctx2) ?? void 0
13145
+ declarations: neutralPreambleDeclarations(statements, ctx2) ?? void 0,
13146
+ reactiveNames: reactiveNames.size > 0 ? [...reactiveNames] : void 0
13051
13147
  };
13052
13148
  }
13053
13149
  function neutralPreambleDeclarations(statements, ctx2) {
13054
13150
  const out = [];
13055
13151
  for (const stmt of statements) {
13056
- if (!ts12.isVariableStatement(stmt)) return null;
13152
+ if (!ts13.isVariableStatement(stmt)) return null;
13057
13153
  for (const decl of stmt.declarationList.declarations) {
13058
- if (!ts12.isIdentifier(decl.name)) return null;
13154
+ if (!ts13.isIdentifier(decl.name)) return null;
13059
13155
  if (!decl.initializer) return null;
13060
13156
  const valueParsed = tsNodeToParsedExpr(decl.initializer);
13061
13157
  if (!isSupported(valueParsed).supported) return null;
@@ -13085,11 +13181,11 @@ function buildPreambleSegments(statements, returnStmt, ctx2) {
13085
13181
  let refusalNode;
13086
13182
  const recordBuilderTarget = (leaf, stmt) => {
13087
13183
  for (let n = leaf.parent; n && n !== stmt.parent; n = n.parent) {
13088
- if (ts12.isCallExpression(n) && ts12.isPropertyAccessExpression(n.expression) && (n.expression.name.text === "push" || n.expression.name.text === "unshift") && ts12.isIdentifier(n.expression.expression)) {
13184
+ if (ts13.isCallExpression(n) && ts13.isPropertyAccessExpression(n.expression) && (n.expression.name.text === "push" || n.expression.name.text === "unshift") && ts13.isIdentifier(n.expression.expression)) {
13089
13185
  builders.add(n.expression.expression.text);
13090
13186
  return;
13091
13187
  }
13092
- if (ts12.isVariableDeclaration(n) && ts12.isIdentifier(n.name)) {
13188
+ if (ts13.isVariableDeclaration(n) && ts13.isIdentifier(n.name)) {
13093
13189
  builders.add(n.name.text);
13094
13190
  return;
13095
13191
  }
@@ -13101,7 +13197,7 @@ function buildPreambleSegments(statements, returnStmt, ctx2) {
13101
13197
  const leafSpans = [];
13102
13198
  const leafIrs = [];
13103
13199
  const collect = (n, underTemplate) => {
13104
- if (ts12.isJsxElement(n) || ts12.isJsxSelfClosingElement(n) || ts12.isJsxFragment(n)) {
13200
+ if (ts13.isJsxElement(n) || ts13.isJsxSelfClosingElement(n) || ts13.isJsxFragment(n)) {
13105
13201
  if (underTemplate) refusalNode ??= n;
13106
13202
  recordBuilderTarget(n, stmt);
13107
13203
  leafSpans.push({ start: n.getStart(ctx2.sourceFile), end: n.getEnd() });
@@ -13110,7 +13206,7 @@ function buildPreambleSegments(statements, returnStmt, ctx2) {
13110
13206
  leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx2.sourceFile, ctx2.filePath) });
13111
13207
  return;
13112
13208
  }
13113
- const inTemplate = underTemplate || ts12.isTemplateExpression(n) || ts12.isTaggedTemplateExpression(n);
13209
+ const inTemplate = underTemplate || ts13.isTemplateExpression(n) || ts13.isTaggedTemplateExpression(n);
13114
13210
  n.forEachChild((c) => collect(c, inTemplate));
13115
13211
  };
13116
13212
  collect(stmt, false);
@@ -13214,13 +13310,13 @@ function expandSpreadAttribute(attr, ctx2) {
13214
13310
  }];
13215
13311
  }
13216
13312
  function attrFreeIdentifiers(attr) {
13217
- if (!attr.initializer || !ts12.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13313
+ if (!attr.initializer || !ts13.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13218
13314
  return void 0;
13219
13315
  }
13220
13316
  return extractFreeIdentifiersFromNode(attr.initializer.expression);
13221
13317
  }
13222
13318
  function computeReactivityFlags(attr, ctx2) {
13223
- if (!attr.initializer || !ts12.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13319
+ if (!attr.initializer || !ts13.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13224
13320
  return {};
13225
13321
  }
13226
13322
  const expr = attr.initializer.expression;
@@ -13251,21 +13347,21 @@ function processAttributes(attributes2, ctx2) {
13251
13347
  const events = [];
13252
13348
  let ref = null;
13253
13349
  for (const attr of attributes2.properties) {
13254
- if (ts12.isJsxSpreadAttribute(attr)) {
13350
+ if (ts13.isJsxSpreadAttribute(attr)) {
13255
13351
  attrs.push(...expandSpreadAttribute(attr, ctx2));
13256
13352
  continue;
13257
13353
  }
13258
- if (!ts12.isJsxAttribute(attr)) continue;
13354
+ if (!ts13.isJsxAttribute(attr)) continue;
13259
13355
  const rawName = attr.name.getText(ctx2.sourceFile);
13260
13356
  if (rawName === "ref") {
13261
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13357
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13262
13358
  reportJsxBranchLocalInCallback(attr.initializer.expression, ctx2);
13263
13359
  ref = ctx2.getJS(attr.initializer.expression);
13264
13360
  }
13265
13361
  continue;
13266
13362
  }
13267
13363
  if (/^on[A-Z]/.test(rawName)) {
13268
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13364
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13269
13365
  const eventName = rawName.slice(2).toLowerCase();
13270
13366
  reportJsxBranchLocalInCallback(attr.initializer.expression, ctx2);
13271
13367
  events.push({
@@ -13280,7 +13376,7 @@ function processAttributes(attributes2, ctx2) {
13280
13376
  const name2 = toHTMLAttrName(rawName);
13281
13377
  let value2 = getAttributeValue(attr, ctx2);
13282
13378
  let clientOnly;
13283
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13379
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13284
13380
  if (value2.kind === "expression" && value2.templateExpr === void 0) {
13285
13381
  const rewritten = rewriteBarePropRefs2(value2.expr, attr.initializer.expression, ctx2);
13286
13382
  if (rewritten !== value2.expr) {
@@ -13307,19 +13403,19 @@ function getAttributeValue(attr, ctx2) {
13307
13403
  if (!attr.initializer) {
13308
13404
  return AttrValueOf.booleanAttr();
13309
13405
  }
13310
- if (ts12.isStringLiteral(attr.initializer)) {
13406
+ if (ts13.isStringLiteral(attr.initializer)) {
13311
13407
  return AttrValueOf.literal(decodeEntities(attr.initializer.text));
13312
13408
  }
13313
- if (ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13409
+ if (ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13314
13410
  let expr = attr.initializer.expression;
13315
- if (ts12.isIdentifier(expr)) {
13411
+ if (ts13.isIdentifier(expr)) {
13316
13412
  const branchInit = ctx2._branchScopeVars?.get(expr.text);
13317
13413
  if (branchInit && !initializerShapeContainsJsx(branchInit)) {
13318
13414
  expr = branchInit;
13319
13415
  }
13320
13416
  }
13321
13417
  expr = tryDesugarInterleaveTaggedTemplate(expr, ctx2);
13322
- if (ts12.isAwaitExpression(expr)) {
13418
+ if (ts13.isAwaitExpression(expr)) {
13323
13419
  ctx2.analyzer.errors.push(
13324
13420
  createError(
13325
13421
  ErrorCodes.STAGE_AWAIT_IN_TEMPLATE,
@@ -13329,38 +13425,38 @@ function getAttributeValue(attr, ctx2) {
13329
13425
  return AttrValueOf.expression("undefined");
13330
13426
  }
13331
13427
  checkBareSignalOrMemoIdentifier(expr, ctx2);
13332
- if (attr.name.getText(ctx2.sourceFile) === "style" && ts12.isObjectLiteralExpression(expr)) {
13428
+ if (attr.name.getText(ctx2.sourceFile) === "style" && ts13.isObjectLiteralExpression(expr)) {
13333
13429
  const cssString = tryStaticStyleObjectToCss(expr);
13334
13430
  if (cssString !== null) {
13335
13431
  return AttrValueOf.literal(cssString);
13336
13432
  }
13337
13433
  }
13338
- if (ts12.isTemplateExpression(expr)) {
13434
+ if (ts13.isTemplateExpression(expr)) {
13339
13435
  const parts = parseTemplateLiteral(expr, ctx2);
13340
13436
  if (parts.some((p) => p.type === "ternary" || p.type === "lookup")) {
13341
13437
  return AttrValueOf.template(parts);
13342
13438
  }
13343
13439
  }
13344
- if (ts12.isElementAccessExpression(expr) && !ts12.isStringLiteralLike(expr.argumentExpression) && !ts12.isNumericLiteral(expr.argumentExpression)) {
13440
+ if (ts13.isElementAccessExpression(expr) && !ts13.isStringLiteralLike(expr.argumentExpression) && !ts13.isNumericLiteral(expr.argumentExpression)) {
13345
13441
  const parts = tryResolveTemplateSpanFromConst(expr, ctx2);
13346
13442
  if (parts) {
13347
13443
  return AttrValueOf.template(parts);
13348
13444
  }
13349
13445
  }
13350
- if (ts12.isIdentifier(expr)) {
13446
+ if (ts13.isIdentifier(expr)) {
13351
13447
  const resolved = tryResolveIdentifierAsTemplateLiteral(expr, ctx2);
13352
13448
  if (resolved) {
13353
13449
  return AttrValueOf.template(resolved);
13354
13450
  }
13355
13451
  }
13356
- if (ts12.isConditionalExpression(expr)) {
13452
+ if (ts13.isConditionalExpression(expr)) {
13357
13453
  const ternary = parseTernary(expr, ctx2);
13358
13454
  if (ternary) {
13359
13455
  return AttrValueOf.template([ternary]);
13360
13456
  }
13361
13457
  }
13362
- if (ts12.isBinaryExpression(expr) && expr.operatorToken.kind === ts12.SyntaxKind.BarBarToken) {
13363
- if (ts12.isIdentifier(expr.right) && expr.right.text === "undefined") {
13458
+ if (ts13.isBinaryExpression(expr) && expr.operatorToken.kind === ts13.SyntaxKind.BarBarToken) {
13459
+ if (ts13.isIdentifier(expr.right) && expr.right.text === "undefined") {
13364
13460
  const baseExpr = ctx2.getJS(expr.left);
13365
13461
  return AttrValueOf.expression(baseExpr, { presenceOrUndefined: true });
13366
13462
  }
@@ -13373,9 +13469,9 @@ function getAttributeValue(attr, ctx2) {
13373
13469
  function tryStaticStyleObjectToCss(expr) {
13374
13470
  const parts = [];
13375
13471
  for (const prop of expr.properties) {
13376
- if (!ts12.isPropertyAssignment(prop)) return null;
13377
- if (!ts12.isIdentifier(prop.name) && !ts12.isStringLiteral(prop.name)) return null;
13378
- if (!ts12.isStringLiteral(prop.initializer)) return null;
13472
+ if (!ts13.isPropertyAssignment(prop)) return null;
13473
+ if (!ts13.isIdentifier(prop.name) && !ts13.isStringLiteral(prop.name)) return null;
13474
+ if (!ts13.isStringLiteral(prop.initializer)) return null;
13379
13475
  const key = cssKebabCase(prop.name.text);
13380
13476
  parts.push(`${key}:${prop.initializer.text}`);
13381
13477
  }
@@ -13387,7 +13483,7 @@ function parseTemplateLiteral(expr, ctx2) {
13387
13483
  parts.push({ type: "string", value: expr.head.text });
13388
13484
  }
13389
13485
  for (const span of expr.templateSpans) {
13390
- if (ts12.isConditionalExpression(span.expression)) {
13486
+ if (ts13.isConditionalExpression(span.expression)) {
13391
13487
  const ternary = parseTernary(span.expression, ctx2);
13392
13488
  if (ternary) {
13393
13489
  parts.push(ternary);
@@ -13413,31 +13509,31 @@ function parseTemplateLiteral(expr, ctx2) {
13413
13509
  return parts;
13414
13510
  }
13415
13511
  function tryResolveTemplateSpanFromConst(expr, ctx2) {
13416
- if (ts12.isIdentifier(expr)) {
13512
+ if (ts13.isIdentifier(expr)) {
13417
13513
  if (ctx2.scope.isBound(expr.text)) return null;
13418
13514
  const constInfo = findLocalConst(expr.text, ctx2.analyzer);
13419
13515
  if (!constInfo) return null;
13420
13516
  const ast = parseConstInitializer(constInfo);
13421
13517
  if (!ast) return null;
13422
- if (ts12.isStringLiteral(ast) || ts12.isNoSubstitutionTemplateLiteral(ast)) {
13518
+ if (ts13.isStringLiteral(ast) || ts13.isNoSubstitutionTemplateLiteral(ast)) {
13423
13519
  return [{ type: "string", value: ast.text }];
13424
13520
  }
13425
13521
  return null;
13426
13522
  }
13427
- if (ts12.isElementAccessExpression(expr)) {
13428
- if (!ts12.isIdentifier(expr.expression)) return null;
13523
+ if (ts13.isElementAccessExpression(expr)) {
13524
+ if (!ts13.isIdentifier(expr.expression)) return null;
13429
13525
  if (ctx2.scope.isBound(expr.expression.text)) return null;
13430
13526
  const constInfo = findLocalConst(expr.expression.text, ctx2.analyzer);
13431
13527
  if (!constInfo) return null;
13432
13528
  const ast = parseConstInitializer(constInfo);
13433
- if (!ast || !ts12.isObjectLiteralExpression(ast)) return null;
13529
+ if (!ast || !ts13.isObjectLiteralExpression(ast)) return null;
13434
13530
  const cases = {};
13435
13531
  for (const prop of ast.properties) {
13436
- if (!ts12.isPropertyAssignment(prop)) return null;
13437
- const keyName = prop.name && (ts12.isStringLiteral(prop.name) || ts12.isIdentifier(prop.name)) ? prop.name.text : null;
13532
+ if (!ts13.isPropertyAssignment(prop)) return null;
13533
+ const keyName = prop.name && (ts13.isStringLiteral(prop.name) || ts13.isIdentifier(prop.name)) ? prop.name.text : null;
13438
13534
  if (!keyName) return null;
13439
13535
  const value2 = prop.initializer;
13440
- if (ts12.isStringLiteral(value2) || ts12.isNoSubstitutionTemplateLiteral(value2)) {
13536
+ if (ts13.isStringLiteral(value2) || ts13.isNoSubstitutionTemplateLiteral(value2)) {
13441
13537
  cases[keyName] = value2.text;
13442
13538
  } else {
13443
13539
  return null;
@@ -13476,17 +13572,17 @@ function hasDynamicTagBinding(name2, sourceFile) {
13476
13572
  let found = false;
13477
13573
  const visit3 = (node) => {
13478
13574
  if (found) return;
13479
- if (ts12.isVariableDeclaration(node) && ts12.isIdentifier(node.name) && node.name.text === name2 && node.initializer) {
13575
+ if (ts13.isVariableDeclaration(node) && ts13.isIdentifier(node.name) && node.name.text === name2 && node.initializer) {
13480
13576
  let init = node.initializer;
13481
- while (ts12.isAsExpression(init) || ts12.isSatisfiesExpression(init) || ts12.isParenthesizedExpression(init) || ts12.isNonNullExpression(init)) {
13577
+ while (ts13.isAsExpression(init) || ts13.isSatisfiesExpression(init) || ts13.isParenthesizedExpression(init) || ts13.isNonNullExpression(init)) {
13482
13578
  init = init.expression;
13483
13579
  }
13484
- if (ts12.isPropertyAccessExpression(init) && init.name.text === "tag") {
13580
+ if (ts13.isPropertyAccessExpression(init) && init.name.text === "tag") {
13485
13581
  found = true;
13486
13582
  return;
13487
13583
  }
13488
13584
  }
13489
- ts12.forEachChild(node, visit3);
13585
+ ts13.forEachChild(node, visit3);
13490
13586
  };
13491
13587
  visit3(sourceFile);
13492
13588
  return found;
@@ -13497,13 +13593,13 @@ function tryResolveIdentifierAsTemplateLiteral(ident, ctx2) {
13497
13593
  if (!constInfo) return null;
13498
13594
  const ast = parseConstInitializer(constInfo);
13499
13595
  if (!ast) return null;
13500
- if (ts12.isNoSubstitutionTemplateLiteral(ast) || ts12.isStringLiteral(ast)) {
13596
+ if (ts13.isNoSubstitutionTemplateLiteral(ast) || ts13.isStringLiteral(ast)) {
13501
13597
  return [{ type: "string", value: ast.text }];
13502
13598
  }
13503
- if (ts12.isElementAccessExpression(ast) && !ts12.isStringLiteralLike(ast.argumentExpression) && !ts12.isNumericLiteral(ast.argumentExpression)) {
13599
+ if (ts13.isElementAccessExpression(ast) && !ts13.isStringLiteralLike(ast.argumentExpression) && !ts13.isNumericLiteral(ast.argumentExpression)) {
13504
13600
  return tryResolveTemplateSpanFromConst(ast, ctx2);
13505
13601
  }
13506
- if (!ts12.isTemplateExpression(ast)) return null;
13602
+ if (!ts13.isTemplateExpression(ast)) return null;
13507
13603
  let resolvedAny = false;
13508
13604
  const parts = [];
13509
13605
  if (ast.head.text) parts.push({ type: "string", value: ast.head.text });
@@ -13535,19 +13631,19 @@ function parseConstInitializer(c) {
13535
13631
  function parseConstInitializerImpl(c) {
13536
13632
  if (!c.value) return null;
13537
13633
  const wrapped = `const __bf_resolve__ = (${c.value})`;
13538
- const sf = ts12.createSourceFile(
13634
+ const sf = ts13.createSourceFile(
13539
13635
  "__bf_resolve.ts",
13540
13636
  wrapped,
13541
- ts12.ScriptTarget.Latest,
13637
+ ts13.ScriptTarget.Latest,
13542
13638
  /* setParentNodes */
13543
13639
  true,
13544
- ts12.ScriptKind.TS
13640
+ ts13.ScriptKind.TS
13545
13641
  );
13546
13642
  const stmt = sf.statements[0];
13547
- if (!stmt || !ts12.isVariableStatement(stmt)) return null;
13643
+ if (!stmt || !ts13.isVariableStatement(stmt)) return null;
13548
13644
  const decl = stmt.declarationList.declarations[0];
13549
13645
  if (!decl?.initializer) return null;
13550
- return ts12.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13646
+ return ts13.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13551
13647
  }
13552
13648
  function astText(node) {
13553
13649
  return node.getText(node.getSourceFile());
@@ -13564,23 +13660,23 @@ function parseFunctionInfoAsExprImpl(fn) {
13564
13660
  const params = fn.typedParams !== void 0 ? fn.typedParams : fn.params.map(formatParamWithType).join(", ");
13565
13661
  const body2 = fn.typedBody ?? fn.body;
13566
13662
  const wrapped = `const __bf_resolve_fn__ = function(${params}) ${body2}`;
13567
- const sf = ts12.createSourceFile(
13663
+ const sf = ts13.createSourceFile(
13568
13664
  "__bf_resolve_fn.ts",
13569
13665
  wrapped,
13570
- ts12.ScriptTarget.Latest,
13666
+ ts13.ScriptTarget.Latest,
13571
13667
  /* setParentNodes */
13572
13668
  true,
13573
- ts12.ScriptKind.TS
13669
+ ts13.ScriptKind.TS
13574
13670
  );
13575
13671
  const stmt = sf.statements[0];
13576
- if (!stmt || !ts12.isVariableStatement(stmt)) return null;
13672
+ if (!stmt || !ts13.isVariableStatement(stmt)) return null;
13577
13673
  const decl = stmt.declarationList.declarations[0];
13578
13674
  if (!decl?.initializer) return null;
13579
13675
  return decl.initializer;
13580
13676
  }
13581
13677
  function tryDesugarInterleaveTaggedTemplate(expr, ctx2) {
13582
- if (!ts12.isTaggedTemplateExpression(expr)) return expr;
13583
- if (!ts12.isIdentifier(expr.tag)) return expr;
13678
+ if (!ts13.isTaggedTemplateExpression(expr)) return expr;
13679
+ if (!ts13.isIdentifier(expr.tag)) return expr;
13584
13680
  const resolvedTag = resolveInterleaveTagIdentifier(expr.tag.text, ctx2);
13585
13681
  if (!resolvedTag) return expr;
13586
13682
  if (!isInterleaveTagFunction(resolvedTag)) return expr;
@@ -13593,20 +13689,20 @@ function resolveInterleaveTagIdentifier(name2, ctx2) {
13593
13689
  if (constInfo && fnInfo) return null;
13594
13690
  if (constInfo) {
13595
13691
  const ast = parseConstInitializer(constInfo);
13596
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
13692
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
13597
13693
  }
13598
13694
  if (fnInfo) {
13599
13695
  const ast = parseFunctionInfoAsExpr(fnInfo);
13600
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
13696
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
13601
13697
  }
13602
13698
  return null;
13603
13699
  }
13604
13700
  function isInterleaveTagFunction(fn) {
13605
- if (!ts12.isArrowFunction(fn) && !ts12.isFunctionExpression(fn)) return false;
13701
+ if (!ts13.isArrowFunction(fn) && !ts13.isFunctionExpression(fn)) return false;
13606
13702
  if (fn.parameters.length !== 2) return false;
13607
13703
  const [partsParam, argsParam] = fn.parameters;
13608
- if (!ts12.isIdentifier(partsParam.name) || partsParam.dotDotDotToken) return false;
13609
- if (!ts12.isIdentifier(argsParam.name) || !argsParam.dotDotDotToken) return false;
13704
+ if (!ts13.isIdentifier(partsParam.name) || partsParam.dotDotDotToken) return false;
13705
+ if (!ts13.isIdentifier(argsParam.name) || !argsParam.dotDotDotToken) return false;
13610
13706
  const parsed = tsNodeToParsedExpr(fn);
13611
13707
  if (parsed.kind !== "arrow") return false;
13612
13708
  return isInterleaveReduceCall(parsed.body, partsParam.name.text, argsParam.name.text);
@@ -13648,7 +13744,7 @@ function isInterleaveSpanExpr(expr, i, argsName) {
13648
13744
  function buildUntaggedTemplateLiteral(node, ctx2) {
13649
13745
  const template = node.template;
13650
13746
  let text;
13651
- if (ts12.isNoSubstitutionTemplateLiteral(template)) {
13747
+ if (ts13.isNoSubstitutionTemplateLiteral(template)) {
13652
13748
  text = "`" + (template.rawText ?? template.text) + "`";
13653
13749
  } else {
13654
13750
  let body2 = template.head.rawText ?? template.head.text;
@@ -13660,20 +13756,20 @@ function buildUntaggedTemplateLiteral(node, ctx2) {
13660
13756
  text = "`" + body2 + "`";
13661
13757
  }
13662
13758
  const wrapped = `const __bf_resolve_tagged__ = (${text})`;
13663
- const sf = ts12.createSourceFile(
13759
+ const sf = ts13.createSourceFile(
13664
13760
  "__bf_resolve_tagged.tsx",
13665
13761
  wrapped,
13666
- ts12.ScriptTarget.Latest,
13762
+ ts13.ScriptTarget.Latest,
13667
13763
  /* setParentNodes */
13668
13764
  true,
13669
- ts12.ScriptKind.TSX
13765
+ ts13.ScriptKind.TSX
13670
13766
  );
13671
13767
  const stmt = sf.statements[0];
13672
- if (!stmt || !ts12.isVariableStatement(stmt)) return null;
13768
+ if (!stmt || !ts13.isVariableStatement(stmt)) return null;
13673
13769
  const decl = stmt.declarationList.declarations[0];
13674
13770
  if (!decl?.initializer) return null;
13675
- const result2 = ts12.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13676
- if (!ts12.isTemplateExpression(result2) && !ts12.isNoSubstitutionTemplateLiteral(result2)) return null;
13771
+ const result2 = ts13.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13772
+ if (!ts13.isTemplateExpression(result2) && !ts13.isNoSubstitutionTemplateLiteral(result2)) return null;
13677
13773
  return result2;
13678
13774
  }
13679
13775
  function parseTernary(expr, ctx2) {
@@ -13692,10 +13788,10 @@ function parseTernary(expr, ctx2) {
13692
13788
  return null;
13693
13789
  }
13694
13790
  function getStringValue(node) {
13695
- if (ts12.isStringLiteral(node)) {
13791
+ if (ts13.isStringLiteral(node)) {
13696
13792
  return node.text;
13697
13793
  }
13698
- if (ts12.isNoSubstitutionTemplateLiteral(node)) {
13794
+ if (ts13.isNoSubstitutionTemplateLiteral(node)) {
13699
13795
  return node.text;
13700
13796
  }
13701
13797
  return null;
@@ -13703,18 +13799,18 @@ function getStringValue(node) {
13703
13799
  function processComponentProps(attributes2, ctx2) {
13704
13800
  const props = [];
13705
13801
  for (const attr of attributes2.properties) {
13706
- if (ts12.isJsxSpreadAttribute(attr)) {
13802
+ if (ts13.isJsxSpreadAttribute(attr)) {
13707
13803
  props.push(...expandSpreadAttribute(attr, ctx2));
13708
13804
  continue;
13709
13805
  }
13710
- if (!ts12.isJsxAttribute(attr)) continue;
13806
+ if (!ts13.isJsxAttribute(attr)) continue;
13711
13807
  const name2 = attr.name.getText(ctx2.sourceFile);
13712
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13808
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13713
13809
  let jsxExpr = attr.initializer.expression;
13714
- while (ts12.isParenthesizedExpression(jsxExpr)) {
13810
+ while (ts13.isParenthesizedExpression(jsxExpr)) {
13715
13811
  jsxExpr = jsxExpr.expression;
13716
13812
  }
13717
- if (ts12.isJsxElement(jsxExpr) || ts12.isJsxSelfClosingElement(jsxExpr) || ts12.isJsxFragment(jsxExpr)) {
13813
+ if (ts13.isJsxElement(jsxExpr) || ts13.isJsxSelfClosingElement(jsxExpr) || ts13.isJsxFragment(jsxExpr)) {
13718
13814
  const prevInsideComponentChildren = ctx2.insideComponentChildren;
13719
13815
  ctx2.insideComponentChildren = true;
13720
13816
  const irNode = transformNode(jsxExpr, ctx2);
@@ -13741,7 +13837,7 @@ function processComponentProps(attributes2, ctx2) {
13741
13837
  value2 = AttrValueOf.booleanShorthand();
13742
13838
  }
13743
13839
  let clientOnly;
13744
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13840
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13745
13841
  if (value2.kind === "expression" && value2.templateExpr === void 0) {
13746
13842
  const rewritten = rewriteBarePropRefs2(value2.expr, attr.initializer.expression, ctx2);
13747
13843
  if (rewritten !== value2.expr) {
@@ -13765,7 +13861,7 @@ function processComponentProps(attributes2, ctx2) {
13765
13861
  return props;
13766
13862
  }
13767
13863
  function checkBareSignalOrMemoIdentifier(expr, ctx2) {
13768
- if (!ts12.isIdentifier(expr)) return;
13864
+ if (!ts13.isIdentifier(expr)) return;
13769
13865
  const name2 = expr.text;
13770
13866
  for (const signal2 of ctx2.analyzer.signals) {
13771
13867
  if (signal2.getter === name2) {
@@ -13807,12 +13903,12 @@ function checkBareSignalOrMemoIdentifier(expr, ctx2) {
13807
13903
  function isArrayExprDirectPropRef(arrayExpr, ctx2) {
13808
13904
  const propNames = new Set(ctx2.patterns.props.map((p) => p.name));
13809
13905
  const propsObjName = ctx2.analyzer.propsObjectName;
13810
- if (ts12.isIdentifier(arrayExpr)) {
13906
+ if (ts13.isIdentifier(arrayExpr)) {
13811
13907
  return propNames.has(arrayExpr.text);
13812
13908
  }
13813
- if (ts12.isPropertyAccessExpression(arrayExpr) && propsObjName) {
13909
+ if (ts13.isPropertyAccessExpression(arrayExpr) && propsObjName) {
13814
13910
  const obj = arrayExpr.expression;
13815
- if (ts12.isIdentifier(obj) && obj.text === propsObjName) {
13911
+ if (ts13.isIdentifier(obj) && obj.text === propsObjName) {
13816
13912
  return true;
13817
13913
  }
13818
13914
  }
@@ -13984,7 +14080,7 @@ function buildIfStatementChain(analyzer, ctx2, opts) {
13984
14080
  for (const n of prevJsxBranchLocalNames) jsxBranchLocalNames.add(n);
13985
14081
  }
13986
14082
  for (const decl of condReturn.scopeVariables) {
13987
- if (ts12.isIdentifier(decl.name) && decl.initializer) {
14083
+ if (ts13.isIdentifier(decl.name) && decl.initializer) {
13988
14084
  branchScopeVars.set(decl.name.text, decl.initializer);
13989
14085
  if (initializerShapeContainsJsx(decl.initializer)) {
13990
14086
  jsxBranchLocalNames.add(decl.name.text);
@@ -14048,7 +14144,7 @@ function buildIfStatementChain(analyzer, ctx2, opts) {
14048
14144
  }
14049
14145
  const scopeVariables = [];
14050
14146
  for (const decl of condReturn.scopeVariables) {
14051
- if (ts12.isIdentifier(decl.name) && decl.initializer) {
14147
+ if (ts13.isIdentifier(decl.name) && decl.initializer) {
14052
14148
  const init = ctx2.getJS(decl.initializer);
14053
14149
  const typedInit = decl.initializer.getText(ctx2.sourceFile);
14054
14150
  scopeVariables.push({
@@ -15353,7 +15449,8 @@ function collectLoopChildConditionals(node, ctx2, siblingOffsets, loopParam, loo
15353
15449
  const refsLoopParamInSource = refsAnyBindingViaFreeIds(sourceFreeIds);
15354
15450
  if (!n.reactive && !refsLoopParamInSource) return;
15355
15451
  const expanded = expandConstantForReactivity(n.condition, ctx2, sourceFreeIds, scope);
15356
- if (classifyReactivity(expanded.expr, ctx2, loopParam, loopParamBindings, expanded.freeIds).kind === "none") return;
15452
+ const readsPreamble = preambleNames !== void 0 && preambleNames.size > 0 && anyNameIn(expanded.freeIds ?? extractFreeIdentifiersFromText(expanded.expr), preambleNames);
15453
+ if (!readsPreamble && classifyReactivity(expanded.expr, ctx2, loopParam, loopParamBindings, expanded.freeIds).kind === "none") return;
15357
15454
  const loopParamsForCond = loopParam ? [{ param: loopParam, bindings: loopParamBindings }] : void 0;
15358
15455
  const whenTrueHtml = irToHtmlTemplate(n.whenTrue, void 0, 0, loopParamsForCond, "__slots");
15359
15456
  const whenFalseHtml = irToHtmlTemplate(n.whenFalse, void 0, 0, loopParamsForCond, "__slots");
@@ -15364,7 +15461,8 @@ function collectLoopChildConditionals(node, ctx2, siblingOffsets, loopParam, loo
15364
15461
  whenFalseHtml,
15365
15462
  whenTrue: summarizeLoopChildBranch(n.whenTrue, ctx2, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex),
15366
15463
  whenFalse: summarizeLoopChildBranch(n.whenFalse, ctx2, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex),
15367
- ...expanded.freeIds !== void 0 && { conditionFreeIdentifiers: expanded.freeIds }
15464
+ ...expanded.freeIds !== void 0 && { conditionFreeIdentifiers: expanded.freeIds },
15465
+ ...readsPreamble && { readsPreamble: true }
15368
15466
  });
15369
15467
  }
15370
15468
  });
@@ -15443,6 +15541,7 @@ var init_collect_elements = __esm({
15443
15541
  init_html_template();
15444
15542
  init_template_parse();
15445
15543
  init_prop_handling();
15544
+ init_csr_substitute();
15446
15545
  init_walker();
15447
15546
  init_loop_chain();
15448
15547
  init_identifier_pattern();
@@ -15800,7 +15899,7 @@ var init_build_references = __esm({
15800
15899
  });
15801
15900
 
15802
15901
  // ../jsx/src/ir-to-client-js/walk-prop-accesses.ts
15803
- import ts13 from "typescript";
15902
+ import ts14 from "typescript";
15804
15903
  function collectPropAccesses(source, propNames, out) {
15805
15904
  if (propNames.size === 0) return;
15806
15905
  let anyMentioned = false;
@@ -15812,13 +15911,13 @@ function collectPropAccesses(source, propNames, out) {
15812
15911
  }
15813
15912
  if (!anyMentioned) return;
15814
15913
  for (const expr of normaliseExpressionParts(source)) {
15815
- const sourceFile = ts13.createSourceFile(
15914
+ const sourceFile = ts14.createSourceFile(
15816
15915
  "p.ts",
15817
15916
  expr,
15818
- ts13.ScriptTarget.Latest,
15917
+ ts14.ScriptTarget.Latest,
15819
15918
  /*setParentNodes*/
15820
15919
  false,
15821
- ts13.ScriptKind.TS
15920
+ ts14.ScriptKind.TS
15822
15921
  );
15823
15922
  visit2(sourceFile, propNames, out);
15824
15923
  }
@@ -15828,15 +15927,15 @@ function normaliseExpressionParts(source) {
15828
15927
  return extractTemplateExpressions(source);
15829
15928
  }
15830
15929
  function visit2(node, propNames, out) {
15831
- if (ts13.isPropertyAccessExpression(node)) {
15930
+ if (ts14.isPropertyAccessExpression(node)) {
15832
15931
  recordIfPropAccess(node.expression, "property", propNames, out);
15833
- } else if (ts13.isElementAccessExpression(node)) {
15932
+ } else if (ts14.isElementAccessExpression(node)) {
15834
15933
  recordIfPropAccess(node.expression, "index", propNames, out);
15835
15934
  }
15836
- ts13.forEachChild(node, (child) => visit2(child, propNames, out));
15935
+ ts14.forEachChild(node, (child) => visit2(child, propNames, out));
15837
15936
  }
15838
15937
  function recordIfPropAccess(receiver, kind2, propNames, out) {
15839
- if (!ts13.isIdentifier(receiver)) return;
15938
+ if (!ts14.isIdentifier(receiver)) return;
15840
15939
  const name2 = receiver.text;
15841
15940
  if (!propNames.has(name2)) return;
15842
15941
  let kinds = out.get(name2);
@@ -15897,43 +15996,43 @@ var init_compute_prop_usage = __esm({
15897
15996
  });
15898
15997
 
15899
15998
  // ../jsx/src/value-references.ts
15900
- import ts14 from "typescript";
15999
+ import ts15 from "typescript";
15901
16000
  function isValueReferenceIdentifier(id2) {
15902
16001
  const parent2 = id2.parent;
15903
16002
  if (!parent2) return false;
15904
- if (ts14.isPropertyAccessExpression(parent2) && parent2.name === id2) return false;
15905
- if (ts14.isPropertyAssignment(parent2) && parent2.name === id2) return false;
15906
- if ((ts14.isMethodDeclaration(parent2) || ts14.isGetAccessorDeclaration(parent2) || ts14.isSetAccessorDeclaration(parent2)) && parent2.name === id2) {
16003
+ if (ts15.isPropertyAccessExpression(parent2) && parent2.name === id2) return false;
16004
+ if (ts15.isPropertyAssignment(parent2) && parent2.name === id2) return false;
16005
+ if ((ts15.isMethodDeclaration(parent2) || ts15.isGetAccessorDeclaration(parent2) || ts15.isSetAccessorDeclaration(parent2)) && parent2.name === id2) {
15907
16006
  return false;
15908
16007
  }
15909
- if (ts14.isPropertyDeclaration(parent2) && parent2.name === id2) return false;
15910
- if (ts14.isMetaProperty(parent2) && parent2.name === id2) return false;
15911
- if (ts14.isVariableDeclaration(parent2) && parent2.name === id2) return false;
15912
- if (ts14.isFunctionDeclaration(parent2) && parent2.name === id2) return false;
15913
- if (ts14.isFunctionExpression(parent2) && parent2.name === id2) return false;
15914
- if (ts14.isClassDeclaration(parent2) && parent2.name === id2) return false;
15915
- if (ts14.isClassExpression(parent2) && parent2.name === id2) return false;
15916
- if (ts14.isParameter(parent2) && parent2.name === id2) return false;
15917
- if (ts14.isBindingElement(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
15918
- if (ts14.isLabeledStatement(parent2) && parent2.label === id2) return false;
15919
- if (ts14.isBreakOrContinueStatement(parent2) && parent2.label === id2) return false;
15920
- if (ts14.isImportSpecifier(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
15921
- if (ts14.isExportSpecifier(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
15922
- if (ts14.isImportClause(parent2) && parent2.name === id2) return false;
15923
- if (ts14.isNamespaceImport(parent2) && parent2.name === id2) return false;
15924
- if (ts14.isQualifiedName(parent2) && parent2.right === id2) return false;
16008
+ if (ts15.isPropertyDeclaration(parent2) && parent2.name === id2) return false;
16009
+ if (ts15.isMetaProperty(parent2) && parent2.name === id2) return false;
16010
+ if (ts15.isVariableDeclaration(parent2) && parent2.name === id2) return false;
16011
+ if (ts15.isFunctionDeclaration(parent2) && parent2.name === id2) return false;
16012
+ if (ts15.isFunctionExpression(parent2) && parent2.name === id2) return false;
16013
+ if (ts15.isClassDeclaration(parent2) && parent2.name === id2) return false;
16014
+ if (ts15.isClassExpression(parent2) && parent2.name === id2) return false;
16015
+ if (ts15.isParameter(parent2) && parent2.name === id2) return false;
16016
+ if (ts15.isBindingElement(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
16017
+ if (ts15.isLabeledStatement(parent2) && parent2.label === id2) return false;
16018
+ if (ts15.isBreakOrContinueStatement(parent2) && parent2.label === id2) return false;
16019
+ if (ts15.isImportSpecifier(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
16020
+ if (ts15.isExportSpecifier(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
16021
+ if (ts15.isImportClause(parent2) && parent2.name === id2) return false;
16022
+ if (ts15.isNamespaceImport(parent2) && parent2.name === id2) return false;
16023
+ if (ts15.isQualifiedName(parent2) && parent2.right === id2) return false;
15925
16024
  return true;
15926
16025
  }
15927
16026
  function collectValueReferencedNames(code) {
15928
16027
  let sourceFile;
15929
16028
  try {
15930
- sourceFile = ts14.createSourceFile(
16029
+ sourceFile = ts15.createSourceFile(
15931
16030
  "generated.js",
15932
16031
  code,
15933
- ts14.ScriptTarget.Latest,
16032
+ ts15.ScriptTarget.Latest,
15934
16033
  /*setParentNodes*/
15935
16034
  true,
15936
- ts14.ScriptKind.JS
16035
+ ts15.ScriptKind.JS
15937
16036
  );
15938
16037
  } catch {
15939
16038
  return null;
@@ -15942,10 +16041,10 @@ function collectValueReferencedNames(code) {
15942
16041
  if (diagnostics && diagnostics.length > 0) return null;
15943
16042
  const names = /* @__PURE__ */ new Set();
15944
16043
  function visit3(node) {
15945
- if (ts14.isIdentifier(node) && isValueReferenceIdentifier(node)) {
16044
+ if (ts15.isIdentifier(node) && isValueReferenceIdentifier(node)) {
15946
16045
  names.add(node.text);
15947
16046
  }
15948
- ts14.forEachChild(node, visit3);
16047
+ ts15.forEachChild(node, visit3);
15949
16048
  }
15950
16049
  visit3(sourceFile);
15951
16050
  return names;
@@ -16178,23 +16277,23 @@ var init_lowering_registry = __esm({
16178
16277
  });
16179
16278
 
16180
16279
  // ../jsx/src/relocate.ts
16181
- import ts15 from "typescript";
16280
+ import ts16 from "typescript";
16182
16281
  function classify(name2, env) {
16183
16282
  return env.bindings.get(name2) ?? "global";
16184
16283
  }
16185
16284
  function collectFreeRefs(node) {
16186
16285
  const refs = /* @__PURE__ */ new Map();
16187
16286
  function visit3(n, parent2) {
16188
- if (ts15.isIdentifier(n)) {
16189
- if (parent2 && ts15.isPropertyAccessExpression(parent2) && parent2.name === n) return;
16190
- if (parent2 && ts15.isPropertyAssignment(parent2) && parent2.name === n) return;
16191
- if (parent2 && ts15.isShorthandPropertyAssignment(parent2) && parent2.name === n) return;
16287
+ if (ts16.isIdentifier(n)) {
16288
+ if (parent2 && ts16.isPropertyAccessExpression(parent2) && parent2.name === n) return;
16289
+ if (parent2 && ts16.isPropertyAssignment(parent2) && parent2.name === n) return;
16290
+ if (parent2 && ts16.isShorthandPropertyAssignment(parent2) && parent2.name === n) return;
16192
16291
  const list = refs.get(n.text) ?? [];
16193
16292
  list.push(n);
16194
16293
  refs.set(n.text, list);
16195
16294
  return;
16196
16295
  }
16197
- ts15.forEachChild(n, (child) => visit3(child, n));
16296
+ ts16.forEachChild(n, (child) => visit3(child, n));
16198
16297
  }
16199
16298
  visit3(node);
16200
16299
  return refs;
@@ -16296,9 +16395,9 @@ function isInlinableInTemplate(value2, env) {
16296
16395
  return { ok: true, rewrittenValue: r2.text, decisions: r2.decisions };
16297
16396
  }
16298
16397
  function getCalleeIdentifierPath(callee) {
16299
- if (ts15.isParenthesizedExpression(callee)) return getCalleeIdentifierPath(callee.expression);
16300
- if (ts15.isIdentifier(callee)) return callee.text;
16301
- if (ts15.isPropertyAccessExpression(callee)) {
16398
+ if (ts16.isParenthesizedExpression(callee)) return getCalleeIdentifierPath(callee.expression);
16399
+ if (ts16.isIdentifier(callee)) return callee.text;
16400
+ if (ts16.isPropertyAccessExpression(callee)) {
16302
16401
  const left = getCalleeIdentifierPath(callee.expression);
16303
16402
  if (left === null) return null;
16304
16403
  return `${left}.${callee.name.text}`;
@@ -16306,9 +16405,9 @@ function getCalleeIdentifierPath(callee) {
16306
16405
  return null;
16307
16406
  }
16308
16407
  function getCalleeLeftmostIdentifier(callee) {
16309
- if (ts15.isParenthesizedExpression(callee)) return getCalleeLeftmostIdentifier(callee.expression);
16310
- if (ts15.isIdentifier(callee)) return callee.text;
16311
- if (ts15.isPropertyAccessExpression(callee)) {
16408
+ if (ts16.isParenthesizedExpression(callee)) return getCalleeLeftmostIdentifier(callee.expression);
16409
+ if (ts16.isIdentifier(callee)) return callee.text;
16410
+ if (ts16.isPropertyAccessExpression(callee)) {
16312
16411
  return getCalleeLeftmostIdentifier(callee.expression);
16313
16412
  }
16314
16413
  return null;
@@ -16347,17 +16446,17 @@ function isCallAcceptedByAdapter(call, env) {
16347
16446
  }
16348
16447
  function parseExpressionNode(text) {
16349
16448
  try {
16350
- const sf = ts15.createSourceFile(
16449
+ const sf = ts16.createSourceFile(
16351
16450
  "__inline_check__.ts",
16352
16451
  `(${text});`,
16353
- ts15.ScriptTarget.Latest,
16452
+ ts16.ScriptTarget.Latest,
16354
16453
  false,
16355
- ts15.ScriptKind.TS
16454
+ ts16.ScriptKind.TS
16356
16455
  );
16357
16456
  const stmt = sf.statements[0];
16358
- if (!stmt || !ts15.isExpressionStatement(stmt)) return null;
16457
+ if (!stmt || !ts16.isExpressionStatement(stmt)) return null;
16359
16458
  const inner = stmt.expression;
16360
- return ts15.isParenthesizedExpression(inner) ? inner.expression : inner;
16459
+ return ts16.isParenthesizedExpression(inner) ? inner.expression : inner;
16361
16460
  } catch {
16362
16461
  return null;
16363
16462
  }
@@ -16371,8 +16470,8 @@ function hasCallWithBridgedArg(node, decisions, env) {
16371
16470
  let found = false;
16372
16471
  function visit3(n) {
16373
16472
  if (found) return;
16374
- if (ts15.isCallExpression(n) || ts15.isNewExpression(n)) {
16375
- const accepted = ts15.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
16473
+ if (ts16.isCallExpression(n) || ts16.isNewExpression(n)) {
16474
+ const accepted = ts16.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
16376
16475
  if (!accepted) {
16377
16476
  const args2 = n.arguments;
16378
16477
  if (args2) {
@@ -16385,7 +16484,7 @@ function hasCallWithBridgedArg(node, decisions, env) {
16385
16484
  }
16386
16485
  }
16387
16486
  }
16388
- ts15.forEachChild(n, visit3);
16487
+ ts16.forEachChild(n, visit3);
16389
16488
  }
16390
16489
  visit3(node);
16391
16490
  return found;
@@ -16394,13 +16493,13 @@ function hasZeroArgCall(node, env) {
16394
16493
  let found = false;
16395
16494
  function visit3(n) {
16396
16495
  if (found) return;
16397
- if (ts15.isCallExpression(n) && n.arguments.length === 0) {
16496
+ if (ts16.isCallExpression(n) && n.arguments.length === 0) {
16398
16497
  if (!isCallAcceptedByAdapter(n, env)) {
16399
16498
  found = true;
16400
16499
  return;
16401
16500
  }
16402
16501
  }
16403
- ts15.forEachChild(n, visit3);
16502
+ ts16.forEachChild(n, visit3);
16404
16503
  }
16405
16504
  visit3(node);
16406
16505
  return found;
@@ -16409,25 +16508,25 @@ function containsAnyIdentifier(node, names) {
16409
16508
  let found = false;
16410
16509
  function visit3(n) {
16411
16510
  if (found) return;
16412
- if (ts15.isPropertyAccessExpression(n)) {
16511
+ if (ts16.isPropertyAccessExpression(n)) {
16413
16512
  visit3(n.expression);
16414
16513
  return;
16415
16514
  }
16416
- if (ts15.isPropertyAssignment(n)) {
16515
+ if (ts16.isPropertyAssignment(n)) {
16417
16516
  visit3(n.initializer);
16418
16517
  return;
16419
16518
  }
16420
- if (ts15.isShorthandPropertyAssignment(n)) {
16421
- if (ts15.isIdentifier(n.name) && names.has(n.name.text)) {
16519
+ if (ts16.isShorthandPropertyAssignment(n)) {
16520
+ if (ts16.isIdentifier(n.name) && names.has(n.name.text)) {
16422
16521
  found = true;
16423
16522
  }
16424
16523
  return;
16425
16524
  }
16426
- if (ts15.isIdentifier(n) && names.has(n.text)) {
16525
+ if (ts16.isIdentifier(n) && names.has(n.text)) {
16427
16526
  found = true;
16428
16527
  return;
16429
16528
  }
16430
- ts15.forEachChild(n, visit3);
16529
+ ts16.forEachChild(n, visit3);
16431
16530
  }
16432
16531
  visit3(node);
16433
16532
  return found;
@@ -17757,19 +17856,19 @@ var init_emit_module_level = __esm({
17757
17856
  });
17758
17857
 
17759
17858
  // ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
17760
- import ts16 from "typescript";
17859
+ import ts17 from "typescript";
17761
17860
  function propExtractionName(stmt) {
17762
- if (!ts16.isVariableStatement(stmt)) return null;
17861
+ if (!ts17.isVariableStatement(stmt)) return null;
17763
17862
  const decls = stmt.declarationList.declarations;
17764
17863
  if (decls.length !== 1) return null;
17765
17864
  const decl = decls[0];
17766
- if (!ts16.isIdentifier(decl.name) || !decl.initializer) return null;
17865
+ if (!ts17.isIdentifier(decl.name) || !decl.initializer) return null;
17767
17866
  let core = decl.initializer;
17768
- if (ts16.isBinaryExpression(core) && core.operatorToken.kind === ts16.SyntaxKind.QuestionQuestionToken) {
17867
+ if (ts17.isBinaryExpression(core) && core.operatorToken.kind === ts17.SyntaxKind.QuestionQuestionToken) {
17769
17868
  core = core.left;
17770
17869
  }
17771
- if (!ts16.isPropertyAccessExpression(core)) return null;
17772
- if (!ts16.isIdentifier(core.expression) || core.expression.text !== PROPS_PARAM) return null;
17870
+ if (!ts17.isPropertyAccessExpression(core)) return null;
17871
+ if (!ts17.isIdentifier(core.expression) || core.expression.text !== PROPS_PARAM) return null;
17773
17872
  if (core.name.text !== decl.name.text) return null;
17774
17873
  return decl.name.text;
17775
17874
  }
@@ -17780,17 +17879,17 @@ function pruneUnusedPropExtractions(code) {
17780
17879
  console.warn("[barefootjs] pruneUnusedPropExtractions: generated code did not parse; skipping prune");
17781
17880
  return code;
17782
17881
  }
17783
- const sourceFile = ts16.createSourceFile(
17882
+ const sourceFile = ts17.createSourceFile(
17784
17883
  "generated.js",
17785
17884
  code,
17786
- ts16.ScriptTarget.Latest,
17885
+ ts17.ScriptTarget.Latest,
17787
17886
  /*setParentNodes*/
17788
17887
  false,
17789
- ts16.ScriptKind.JS
17888
+ ts17.ScriptKind.JS
17790
17889
  );
17791
17890
  const spans = [];
17792
17891
  for (const stmt of sourceFile.statements) {
17793
- if (!ts16.isFunctionDeclaration(stmt) || !stmt.name?.text.startsWith("init") || !stmt.body) continue;
17892
+ if (!ts17.isFunctionDeclaration(stmt) || !stmt.name?.text.startsWith("init") || !stmt.body) continue;
17794
17893
  for (const inner of stmt.body.statements) {
17795
17894
  const name2 = propExtractionName(inner);
17796
17895
  if (name2 !== null && !referenced.has(name2)) {
@@ -18835,7 +18934,8 @@ function buildReactiveEffectsPlan(args2) {
18835
18934
  whenTrueTemplateHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
18836
18935
  whenFalseTemplateHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId),
18837
18936
  whenTrueArm: buildOuterArm(cond.whenTrue, wrap, loopParam, loopParamBindings, profileComponentName),
18838
- whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, profileComponentName)
18937
+ whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, profileComponentName),
18938
+ ...cond.readsPreamble && { readsPreamble: true }
18839
18939
  });
18840
18940
  }
18841
18941
  }
@@ -19369,7 +19469,7 @@ var init_lazy_conditional = __esm({
19369
19469
  });
19370
19470
 
19371
19471
  // ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
19372
- import ts17 from "typescript";
19472
+ import ts18 from "typescript";
19373
19473
  function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19374
19474
  if (!preamble) return NO_PREAMBLE;
19375
19475
  if (preamble.builderNames.length > 0) {
@@ -19381,19 +19481,19 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19381
19481
  const text = preambleAnalysisText(preamble);
19382
19482
  if (text.trim().length === 0) return NO_PREAMBLE;
19383
19483
  const declaredNames = /* @__PURE__ */ new Set();
19384
- const sf = ts17.createSourceFile(
19484
+ const sf = ts18.createSourceFile(
19385
19485
  "__lazy_preamble__.ts",
19386
19486
  text,
19387
- ts17.ScriptTarget.Latest,
19487
+ ts18.ScriptTarget.Latest,
19388
19488
  /* setParentNodes */
19389
19489
  true,
19390
- ts17.ScriptKind.TS
19490
+ ts18.ScriptKind.TS
19391
19491
  );
19392
19492
  for (const stmt of sf.statements) {
19393
- if (!ts17.isVariableStatement(stmt)) {
19394
- return NO2(`map-callback preamble has a non-declaration statement (${ts17.SyntaxKind[stmt.kind]})`);
19493
+ if (!ts18.isVariableStatement(stmt)) {
19494
+ return NO2(`map-callback preamble has a non-declaration statement (${ts18.SyntaxKind[stmt.kind]})`);
19395
19495
  }
19396
- const isConst = (stmt.declarationList.flags & ts17.NodeFlags.Const) !== 0;
19496
+ const isConst = (stmt.declarationList.flags & ts18.NodeFlags.Const) !== 0;
19397
19497
  if (!isConst) return NO2("map-callback preamble declares a mutable binding (let/var)");
19398
19498
  for (const decl of stmt.declarationList.declarations) {
19399
19499
  collectBindingNames3(decl.name, declaredNames);
@@ -19420,12 +19520,12 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19420
19520
  return { lazySafe: true, facts: { declaredNames, freeNames } };
19421
19521
  }
19422
19522
  function collectBindingNames3(name2, out) {
19423
- if (ts17.isIdentifier(name2)) {
19523
+ if (ts18.isIdentifier(name2)) {
19424
19524
  out.add(name2.text);
19425
19525
  return;
19426
19526
  }
19427
19527
  for (const element of name2.elements) {
19428
- if (ts17.isOmittedExpression(element)) continue;
19528
+ if (ts18.isOmittedExpression(element)) continue;
19429
19529
  collectBindingNames3(element.name, out);
19430
19530
  }
19431
19531
  }
@@ -19433,56 +19533,56 @@ function findImpureNode(root2, primableNames) {
19433
19533
  let found = null;
19434
19534
  const visit3 = (node) => {
19435
19535
  if (found) return;
19436
- if (ts17.isCallExpression(node)) {
19536
+ if (ts18.isCallExpression(node)) {
19437
19537
  const callee = node.expression;
19438
- const isSignalRead = ts17.isIdentifier(callee) && primableNames.has(callee.text) && node.arguments.length === 0 && node.questionDotToken === void 0;
19538
+ const isSignalRead = ts18.isIdentifier(callee) && primableNames.has(callee.text) && node.arguments.length === 0 && node.questionDotToken === void 0;
19439
19539
  if (!isSignalRead) {
19440
19540
  found = `call to ${callee.getText(callee.getSourceFile())}`;
19441
19541
  return;
19442
19542
  }
19443
19543
  }
19444
- if (ts17.isNewExpression(node)) {
19544
+ if (ts18.isNewExpression(node)) {
19445
19545
  found = "new expression";
19446
19546
  return;
19447
19547
  }
19448
- if (ts17.isTaggedTemplateExpression(node)) {
19548
+ if (ts18.isTaggedTemplateExpression(node)) {
19449
19549
  found = "tagged template";
19450
19550
  return;
19451
19551
  }
19452
- if (ts17.isAwaitExpression(node)) {
19552
+ if (ts18.isAwaitExpression(node)) {
19453
19553
  found = "await";
19454
19554
  return;
19455
19555
  }
19456
- if (ts17.isYieldExpression(node)) {
19556
+ if (ts18.isYieldExpression(node)) {
19457
19557
  found = "yield";
19458
19558
  return;
19459
19559
  }
19460
- if (ts17.isPrefixUnaryExpression(node) || ts17.isPostfixUnaryExpression(node)) {
19560
+ if (ts18.isPrefixUnaryExpression(node) || ts18.isPostfixUnaryExpression(node)) {
19461
19561
  const op = node.operator;
19462
- if (op === ts17.SyntaxKind.PlusPlusToken || op === ts17.SyntaxKind.MinusMinusToken) {
19562
+ if (op === ts18.SyntaxKind.PlusPlusToken || op === ts18.SyntaxKind.MinusMinusToken) {
19463
19563
  found = "increment/decrement";
19464
19564
  return;
19465
19565
  }
19466
19566
  }
19467
- if (ts17.isDeleteExpression(node)) {
19567
+ if (ts18.isDeleteExpression(node)) {
19468
19568
  found = "delete";
19469
19569
  return;
19470
19570
  }
19471
- if (ts17.isFunctionExpression(node) || ts17.isArrowFunction(node) || ts17.isClassExpression(node)) {
19571
+ if (ts18.isFunctionExpression(node) || ts18.isArrowFunction(node) || ts18.isClassExpression(node)) {
19472
19572
  found = "function or class expression";
19473
19573
  return;
19474
19574
  }
19475
- if (ts17.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
19575
+ if (ts18.isBinaryExpression(node) && isAssignmentOperator2(node.operatorToken.kind)) {
19476
19576
  found = "assignment";
19477
19577
  return;
19478
19578
  }
19479
- ts17.forEachChild(node, visit3);
19579
+ ts18.forEachChild(node, visit3);
19480
19580
  };
19481
19581
  visit3(root2);
19482
19582
  return found;
19483
19583
  }
19484
- function isAssignmentOperator(kind2) {
19485
- return kind2 >= ts17.SyntaxKind.FirstAssignment && kind2 <= ts17.SyntaxKind.LastAssignment;
19584
+ function isAssignmentOperator2(kind2) {
19585
+ return kind2 >= ts18.SyntaxKind.FirstAssignment && kind2 <= ts18.SyntaxKind.LastAssignment;
19486
19586
  }
19487
19587
  var NO_PREAMBLE, NO2;
19488
19588
  var init_lazy_preamble = __esm({
@@ -20080,7 +20180,7 @@ var init_claim_plan = __esm({
20080
20180
  });
20081
20181
 
20082
20182
  // ../jsx/src/ir-to-client-js/emit-reactive.ts
20083
- import ts18 from "typescript";
20183
+ import ts19 from "typescript";
20084
20184
  function bindingIdArg(ctx2, slotId) {
20085
20185
  if (!ctx2.profile || !slotId) return "";
20086
20186
  return `, ${JSON.stringify(`${ctx2.componentName}#binding:${slotId}`)}`;
@@ -20161,19 +20261,19 @@ function lowerToLocaleCallsInReactiveExpr(expr, matcher) {
20161
20261
  if (!matcher) return expr;
20162
20262
  let sourceFile;
20163
20263
  try {
20164
- sourceFile = ts18.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts18.ScriptTarget.Latest, true, ts18.ScriptKind.TS);
20264
+ sourceFile = ts19.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts19.ScriptTarget.Latest, true, ts19.ScriptKind.TS);
20165
20265
  } catch {
20166
20266
  return expr;
20167
20267
  }
20168
20268
  const stmt = sourceFile.statements[0];
20169
- if (!stmt || !ts18.isExpressionStatement(stmt)) return expr;
20170
- const root2 = ts18.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20269
+ if (!stmt || !ts19.isExpressionStatement(stmt)) return expr;
20270
+ const root2 = ts19.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20171
20271
  const candidates = [];
20172
20272
  const visit3 = (n) => {
20173
- if (ts18.isCallExpression(n) && n.arguments.length === 2 && ts18.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
20273
+ if (ts19.isCallExpression(n) && n.arguments.length === 2 && ts19.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
20174
20274
  candidates.push(n);
20175
20275
  }
20176
- ts18.forEachChild(n, visit3);
20276
+ ts19.forEachChild(n, visit3);
20177
20277
  };
20178
20278
  visit3(root2);
20179
20279
  if (candidates.length === 0) return expr;
@@ -20210,19 +20310,19 @@ function lowerDateCallsInReactiveExpr(expr, matcher) {
20210
20310
  if (!matcher) return expr;
20211
20311
  let sourceFile;
20212
20312
  try {
20213
- sourceFile = ts18.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts18.ScriptTarget.Latest, true, ts18.ScriptKind.TS);
20313
+ sourceFile = ts19.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts19.ScriptTarget.Latest, true, ts19.ScriptKind.TS);
20214
20314
  } catch {
20215
20315
  return expr;
20216
20316
  }
20217
20317
  const stmt = sourceFile.statements[0];
20218
- if (!stmt || !ts18.isExpressionStatement(stmt)) return expr;
20219
- const root2 = ts18.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20318
+ if (!stmt || !ts19.isExpressionStatement(stmt)) return expr;
20319
+ const root2 = ts19.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20220
20320
  const candidates = [];
20221
20321
  const visit3 = (n) => {
20222
- if (ts18.isCallExpression(n) && n.arguments.length === 0 && ts18.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
20322
+ if (ts19.isCallExpression(n) && n.arguments.length === 0 && ts19.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
20223
20323
  candidates.push(n);
20224
20324
  }
20225
- ts18.forEachChild(n, visit3);
20325
+ ts19.forEachChild(n, visit3);
20226
20326
  };
20227
20327
  visit3(root2);
20228
20328
  if (candidates.length === 0) return expr;
@@ -20580,7 +20680,7 @@ function stringifyReactiveEffects(lines, plan, opts) {
20580
20680
  );
20581
20681
  }
20582
20682
  for (const cond of conditionals) {
20583
- emitOuterConditional(lines, indent, elVar, cond, pc);
20683
+ emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped);
20584
20684
  }
20585
20685
  }
20586
20686
  function emitAttrSlotsGranular(lines, indent, elVar, lookup, attrSlots, elementIndexBySlot, bindingBfId, mapPreambleWrapped) {
@@ -20678,9 +20778,10 @@ function emitOuterTexts(lines, indent, elVar, texts, bindingBfId, textClaimPathE
20678
20778
  lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}', String(${text.wrappedExpression})) }${bindingBfId(text.slotId)})`);
20679
20779
  }
20680
20780
  }
20681
- function emitOuterConditional(lines, indent, elVar, cond, pc) {
20781
+ function emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped) {
20682
20782
  const armIndent = `${indent} `;
20683
- lines.push(`${indent}insert(${elVar}, '${cond.slotId}', () => ${cond.wrappedCondition}, {`);
20783
+ const conditionGetter = cond.readsPreamble && mapPreambleWrapped ? `() => { ${mapPreambleWrapped}; return (${cond.wrappedCondition}) }` : `() => ${cond.wrappedCondition}`;
20784
+ lines.push(`${indent}insert(${elVar}, '${cond.slotId}', ${conditionGetter}, {`);
20684
20785
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenTrueTemplateHtml}\`, slots: __slots } },`);
20685
20786
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
20686
20787
  stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc);
@@ -22406,25 +22507,25 @@ var init_phases = __esm({
22406
22507
  });
22407
22508
 
22408
22509
  // ../jsx/src/ir-to-client-js/rewrite-props-object.ts
22409
- import ts19 from "typescript";
22510
+ import ts20 from "typescript";
22410
22511
  function rewritePropsObjectRef(code, propsObjectName) {
22411
22512
  const srcPropsName = propsObjectName ?? "props";
22412
22513
  if (srcPropsName === PROPS_PARAM) return code;
22413
22514
  if (!identifierPattern(srcPropsName).test(code)) return code;
22414
- const sourceFile = ts19.createSourceFile(
22515
+ const sourceFile = ts20.createSourceFile(
22415
22516
  "init-body.ts",
22416
22517
  code,
22417
- ts19.ScriptTarget.Latest,
22518
+ ts20.ScriptTarget.Latest,
22418
22519
  /*setParentNodes*/
22419
22520
  true,
22420
- ts19.ScriptKind.TS
22521
+ ts20.ScriptKind.TS
22421
22522
  );
22422
22523
  const spans = [];
22423
22524
  function visit3(node) {
22424
- if (ts19.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
22525
+ if (ts20.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
22425
22526
  spans.push([node.getStart(sourceFile), node.getEnd()]);
22426
22527
  }
22427
- ts19.forEachChild(node, visit3);
22528
+ ts20.forEachChild(node, visit3);
22428
22529
  }
22429
22530
  visit3(sourceFile);
22430
22531
  if (spans.length === 0) return code;
@@ -22438,12 +22539,12 @@ function rewritePropsObjectRef(code, propsObjectName) {
22438
22539
  function shouldRewrite(node) {
22439
22540
  const parent2 = node.parent;
22440
22541
  if (!parent2) return true;
22441
- if (ts19.isPropertyAccessExpression(parent2) && parent2.name === node) return false;
22442
- if (ts19.isPropertyAssignment(parent2) && parent2.name === node) return false;
22443
- if (ts19.isShorthandPropertyAssignment(parent2) && parent2.name === node) return false;
22444
- if (ts19.isPropertySignature(parent2) && parent2.name === node) return false;
22445
- if (ts19.isPropertyDeclaration(parent2) && parent2.name === node) return false;
22446
- if (ts19.isBindingElement(parent2) && parent2.name === node) return false;
22542
+ if (ts20.isPropertyAccessExpression(parent2) && parent2.name === node) return false;
22543
+ if (ts20.isPropertyAssignment(parent2) && parent2.name === node) return false;
22544
+ if (ts20.isShorthandPropertyAssignment(parent2) && parent2.name === node) return false;
22545
+ if (ts20.isPropertySignature(parent2) && parent2.name === node) return false;
22546
+ if (ts20.isPropertyDeclaration(parent2) && parent2.name === node) return false;
22547
+ if (ts20.isBindingElement(parent2) && parent2.name === node) return false;
22447
22548
  return true;
22448
22549
  }
22449
22550
  var init_rewrite_props_object = __esm({
@@ -23150,7 +23251,7 @@ var init_css_layer_prefixer = __esm({
23150
23251
  });
23151
23252
 
23152
23253
  // ../jsx/src/preprocess-inline-jsx-callbacks.ts
23153
- import ts20 from "typescript";
23254
+ import ts21 from "typescript";
23154
23255
  function preprocessInlineJsxCallbacks(source, filePath) {
23155
23256
  const errors = [];
23156
23257
  const syntheticNames = [];
@@ -23170,15 +23271,15 @@ function preprocessInlineJsxCallbacks(source, filePath) {
23170
23271
  return { source: current, errors, syntheticNames };
23171
23272
  }
23172
23273
  function runSinglePass(source, filePath, startingCounter) {
23173
- const sourceFile = ts20.createSourceFile(
23274
+ const sourceFile = ts21.createSourceFile(
23174
23275
  filePath,
23175
23276
  source,
23176
- ts20.ScriptTarget.Latest,
23277
+ ts21.ScriptTarget.Latest,
23177
23278
  true,
23178
- ts20.ScriptKind.TSX
23279
+ ts21.ScriptKind.TSX
23179
23280
  );
23180
23281
  const hasUseClient = sourceFile.statements.some(
23181
- (stmt) => ts20.isExpressionStatement(stmt) && ts20.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'")
23282
+ (stmt) => ts21.isExpressionStatement(stmt) && ts21.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'")
23182
23283
  );
23183
23284
  if (!hasUseClient) {
23184
23285
  return { source, errors: [], syntheticNames: [], counterAfter: startingCounter };
@@ -23201,20 +23302,20 @@ function runSinglePass(source, filePath, startingCounter) {
23201
23302
  }
23202
23303
  }
23203
23304
  function visit3(node) {
23204
- if (ts20.isJsxAttribute(node) && node.initializer && ts20.isJsxExpression(node.initializer) && node.initializer.expression) {
23305
+ if (ts21.isJsxAttribute(node) && node.initializer && ts21.isJsxExpression(node.initializer) && node.initializer.expression) {
23205
23306
  if (tryHandleArrowValue(node.initializer.expression)) {
23206
23307
  return;
23207
23308
  }
23208
23309
  }
23209
- if (ts20.isPropertyAssignment(node) && node.initializer) {
23310
+ if (ts21.isPropertyAssignment(node) && node.initializer) {
23210
23311
  if (tryHandleArrowValue(node.initializer)) return;
23211
23312
  }
23212
- ts20.forEachChild(node, visit3);
23313
+ ts21.forEachChild(node, visit3);
23213
23314
  }
23214
23315
  function tryHandleArrowValue(initializer) {
23215
23316
  let expr = initializer;
23216
- while (ts20.isParenthesizedExpression(expr)) expr = expr.expression;
23217
- if (ts20.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
23317
+ while (ts21.isParenthesizedExpression(expr)) expr = expr.expression;
23318
+ if (ts21.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
23218
23319
  return handleInlineArrow(expr);
23219
23320
  }
23220
23321
  return false;
@@ -23249,7 +23350,7 @@ function runSinglePass(source, filePath, startingCounter) {
23249
23350
  replacements.push({ start: arrowStart, end: arrowEnd, text: name2 });
23250
23351
  return true;
23251
23352
  }
23252
- ts20.forEachChild(sourceFile, visit3);
23353
+ ts21.forEachChild(sourceFile, visit3);
23253
23354
  if (replacements.length === 0) {
23254
23355
  return { source, errors, syntheticNames, counterAfter: counter };
23255
23356
  }
@@ -23268,33 +23369,33 @@ function errorMessageForCapture(captures) {
23268
23369
  return `Inline JSX-returning arrow function captures non-module identifier(s): ${captures.sort().join(", ")}. Extract the callback into a top-level '\\'use client\\'' component (e.g. \`function MyNode(n) { return <div/> }\` then \`renderNode={MyNode}\`) or pass captured values via component props.`;
23269
23370
  }
23270
23371
  function arrowBodyContainsJsx(arrow) {
23271
- if (ts20.isBlock(arrow.body)) {
23372
+ if (ts21.isBlock(arrow.body)) {
23272
23373
  return blockReturnsJsx(arrow.body);
23273
23374
  }
23274
23375
  let body2 = arrow.body;
23275
- while (ts20.isParenthesizedExpression(body2)) body2 = body2.expression;
23376
+ while (ts21.isParenthesizedExpression(body2)) body2 = body2.expression;
23276
23377
  return isJsxLike(body2);
23277
23378
  }
23278
23379
  function blockReturnsJsx(block) {
23279
23380
  let found = false;
23280
23381
  function visit3(n) {
23281
23382
  if (found) return;
23282
- if (ts20.isReturnStatement(n) && n.expression) {
23383
+ if (ts21.isReturnStatement(n) && n.expression) {
23283
23384
  let e = n.expression;
23284
- while (ts20.isParenthesizedExpression(e)) e = e.expression;
23385
+ while (ts21.isParenthesizedExpression(e)) e = e.expression;
23285
23386
  if (isJsxLike(e)) {
23286
23387
  found = true;
23287
23388
  return;
23288
23389
  }
23289
23390
  }
23290
- if (ts20.isArrowFunction(n) || ts20.isFunctionDeclaration(n) || ts20.isFunctionExpression(n)) return;
23291
- ts20.forEachChild(n, visit3);
23391
+ if (ts21.isArrowFunction(n) || ts21.isFunctionDeclaration(n) || ts21.isFunctionExpression(n)) return;
23392
+ ts21.forEachChild(n, visit3);
23292
23393
  }
23293
- ts20.forEachChild(block, visit3);
23394
+ ts21.forEachChild(block, visit3);
23294
23395
  return found;
23295
23396
  }
23296
23397
  function isJsxLike(expr) {
23297
- return ts20.isJsxElement(expr) || ts20.isJsxSelfClosingElement(expr) || ts20.isJsxFragment(expr);
23398
+ return ts21.isJsxElement(expr) || ts21.isJsxSelfClosingElement(expr) || ts21.isJsxFragment(expr);
23298
23399
  }
23299
23400
  function collectArrowParamNames(arrow) {
23300
23401
  const names = /* @__PURE__ */ new Set();
@@ -23303,13 +23404,13 @@ function collectArrowParamNames(arrow) {
23303
23404
  }
23304
23405
  function collectBindingNames4(name2, out) {
23305
23406
  const push = Array.isArray(out) ? (n) => out.push(n) : (n) => out.add(n);
23306
- if (ts20.isIdentifier(name2)) {
23407
+ if (ts21.isIdentifier(name2)) {
23307
23408
  push(name2.text);
23308
- } else if (ts20.isObjectBindingPattern(name2)) {
23409
+ } else if (ts21.isObjectBindingPattern(name2)) {
23309
23410
  name2.elements.forEach((el) => collectBindingNames4(el.name, out));
23310
- } else if (ts20.isArrayBindingPattern(name2)) {
23411
+ } else if (ts21.isArrayBindingPattern(name2)) {
23311
23412
  name2.elements.forEach((el) => {
23312
- if (!ts20.isOmittedExpression(el)) collectBindingNames4(el.name, out);
23413
+ if (!ts21.isOmittedExpression(el)) collectBindingNames4(el.name, out);
23313
23414
  });
23314
23415
  }
23315
23416
  }
@@ -23334,71 +23435,71 @@ function collectFreeIdentifiers(arrow) {
23334
23435
  return bound.includes(name2);
23335
23436
  }
23336
23437
  function visit3(node) {
23337
- if (ts20.isIdentifier(node)) {
23438
+ if (ts21.isIdentifier(node)) {
23338
23439
  const parent2 = node.parent;
23339
- if (parent2 && ts20.isPropertyAccessExpression(parent2) && parent2.name === node) return;
23340
- if (parent2 && ts20.isPropertyAssignment(parent2) && parent2.name === node) return;
23341
- if (parent2 && ts20.isPropertySignature(parent2) && parent2.name === node) return;
23342
- if (parent2 && ts20.isPropertyDeclaration(parent2) && parent2.name === node) return;
23343
- if (parent2 && ts20.isMethodDeclaration(parent2) && parent2.name === node) return;
23344
- if (parent2 && ts20.isMethodSignature(parent2) && parent2.name === node) return;
23345
- if (parent2 && ts20.isGetAccessorDeclaration(parent2) && parent2.name === node) return;
23346
- if (parent2 && ts20.isSetAccessorDeclaration(parent2) && parent2.name === node) return;
23347
- if (parent2 && ts20.isEnumMember(parent2) && parent2.name === node) return;
23348
- if (parent2 && ts20.isBindingElement(parent2) && parent2.propertyName === node) return;
23349
- if (parent2 && ts20.isShorthandPropertyAssignment(parent2) && parent2.name === node) {
23440
+ if (parent2 && ts21.isPropertyAccessExpression(parent2) && parent2.name === node) return;
23441
+ if (parent2 && ts21.isPropertyAssignment(parent2) && parent2.name === node) return;
23442
+ if (parent2 && ts21.isPropertySignature(parent2) && parent2.name === node) return;
23443
+ if (parent2 && ts21.isPropertyDeclaration(parent2) && parent2.name === node) return;
23444
+ if (parent2 && ts21.isMethodDeclaration(parent2) && parent2.name === node) return;
23445
+ if (parent2 && ts21.isMethodSignature(parent2) && parent2.name === node) return;
23446
+ if (parent2 && ts21.isGetAccessorDeclaration(parent2) && parent2.name === node) return;
23447
+ if (parent2 && ts21.isSetAccessorDeclaration(parent2) && parent2.name === node) return;
23448
+ if (parent2 && ts21.isEnumMember(parent2) && parent2.name === node) return;
23449
+ if (parent2 && ts21.isBindingElement(parent2) && parent2.propertyName === node) return;
23450
+ if (parent2 && ts21.isShorthandPropertyAssignment(parent2) && parent2.name === node) {
23350
23451
  if (!isBound(node.text)) ids.add(node.text);
23351
23452
  return;
23352
23453
  }
23353
- if (parent2 && ts20.isParameter(parent2) && parent2.name === node) return;
23354
- if (parent2 && ts20.isVariableDeclaration(parent2) && parent2.name === node) return;
23355
- if (parent2 && ts20.isFunctionDeclaration(parent2) && parent2.name === node) return;
23356
- if (parent2 && ts20.isClassDeclaration(parent2) && parent2.name === node) return;
23357
- if (parent2 && ts20.isJsxAttribute(parent2) && parent2.name === node) return;
23358
- if (parent2 && ts20.isJsxOpeningElement(parent2) && parent2.tagName === node) {
23454
+ if (parent2 && ts21.isParameter(parent2) && parent2.name === node) return;
23455
+ if (parent2 && ts21.isVariableDeclaration(parent2) && parent2.name === node) return;
23456
+ if (parent2 && ts21.isFunctionDeclaration(parent2) && parent2.name === node) return;
23457
+ if (parent2 && ts21.isClassDeclaration(parent2) && parent2.name === node) return;
23458
+ if (parent2 && ts21.isJsxAttribute(parent2) && parent2.name === node) return;
23459
+ if (parent2 && ts21.isJsxOpeningElement(parent2) && parent2.tagName === node) {
23359
23460
  if (/^[a-z]/.test(node.text)) return;
23360
23461
  }
23361
- if (parent2 && ts20.isJsxClosingElement(parent2) && parent2.tagName === node) {
23462
+ if (parent2 && ts21.isJsxClosingElement(parent2) && parent2.tagName === node) {
23362
23463
  if (/^[a-z]/.test(node.text)) return;
23363
23464
  }
23364
23465
  if (isBound(node.text)) return;
23365
23466
  ids.add(node.text);
23366
23467
  return;
23367
23468
  }
23368
- if (ts20.isVariableDeclaration(node)) {
23469
+ if (ts21.isVariableDeclaration(node)) {
23369
23470
  const declared = pushBindings(node.name);
23370
23471
  if (node.initializer) visit3(node.initializer);
23371
23472
  declared;
23372
23473
  return;
23373
23474
  }
23374
- if (ts20.isFunctionDeclaration(node)) {
23475
+ if (ts21.isFunctionDeclaration(node)) {
23375
23476
  if (node.name) bound.push(node.name.text);
23376
23477
  visitInsideNewScope(node);
23377
23478
  return;
23378
23479
  }
23379
- if (ts20.isClassDeclaration(node)) {
23480
+ if (ts21.isClassDeclaration(node)) {
23380
23481
  if (node.name) bound.push(node.name.text);
23381
- ts20.forEachChild(node, visit3);
23482
+ ts21.forEachChild(node, visit3);
23382
23483
  return;
23383
23484
  }
23384
- if (ts20.isArrowFunction(node) || ts20.isFunctionExpression(node)) {
23485
+ if (ts21.isArrowFunction(node) || ts21.isFunctionExpression(node)) {
23385
23486
  visitInsideNewScope(node);
23386
23487
  return;
23387
23488
  }
23388
- if (ts20.isCatchClause(node)) {
23489
+ if (ts21.isCatchClause(node)) {
23389
23490
  const before = bound.length;
23390
23491
  if (node.variableDeclaration) pushBindings(node.variableDeclaration.name);
23391
- ts20.forEachChild(node, visit3);
23492
+ ts21.forEachChild(node, visit3);
23392
23493
  popN(bound.length - before);
23393
23494
  return;
23394
23495
  }
23395
- if (ts20.isBlock(node)) {
23496
+ if (ts21.isBlock(node)) {
23396
23497
  const before = bound.length;
23397
- ts20.forEachChild(node, visit3);
23498
+ ts21.forEachChild(node, visit3);
23398
23499
  popN(bound.length - before);
23399
23500
  return;
23400
23501
  }
23401
- ts20.forEachChild(node, visit3);
23502
+ ts21.forEachChild(node, visit3);
23402
23503
  }
23403
23504
  function visitInsideNewScope(fn) {
23404
23505
  const before = bound.length;
@@ -23418,27 +23519,27 @@ function collectFreeIdentifiers(arrow) {
23418
23519
  function collectModuleScopeNames(sourceFile) {
23419
23520
  const names = /* @__PURE__ */ new Set();
23420
23521
  for (const stmt of sourceFile.statements) {
23421
- if (ts20.isFunctionDeclaration(stmt) && stmt.name) names.add(stmt.name.text);
23422
- else if (ts20.isClassDeclaration(stmt) && stmt.name) names.add(stmt.name.text);
23423
- else if (ts20.isVariableStatement(stmt)) {
23522
+ if (ts21.isFunctionDeclaration(stmt) && stmt.name) names.add(stmt.name.text);
23523
+ else if (ts21.isClassDeclaration(stmt) && stmt.name) names.add(stmt.name.text);
23524
+ else if (ts21.isVariableStatement(stmt)) {
23424
23525
  for (const decl of stmt.declarationList.declarations) collectBindingNames4(decl.name, names);
23425
- } else if (ts20.isImportDeclaration(stmt) && stmt.importClause) {
23526
+ } else if (ts21.isImportDeclaration(stmt) && stmt.importClause) {
23426
23527
  const ic = stmt.importClause;
23427
23528
  if (ic.name) names.add(ic.name.text);
23428
23529
  if (ic.namedBindings) {
23429
- if (ts20.isNamespaceImport(ic.namedBindings)) names.add(ic.namedBindings.name.text);
23530
+ if (ts21.isNamespaceImport(ic.namedBindings)) names.add(ic.namedBindings.name.text);
23430
23531
  else for (const e of ic.namedBindings.elements) names.add(e.name.text);
23431
23532
  }
23432
- } else if (ts20.isTypeAliasDeclaration(stmt)) names.add(stmt.name.text);
23433
- else if (ts20.isInterfaceDeclaration(stmt)) names.add(stmt.name.text);
23434
- else if (ts20.isEnumDeclaration(stmt)) names.add(stmt.name.text);
23533
+ } else if (ts21.isTypeAliasDeclaration(stmt)) names.add(stmt.name.text);
23534
+ else if (ts21.isInterfaceDeclaration(stmt)) names.add(stmt.name.text);
23535
+ else if (ts21.isEnumDeclaration(stmt)) names.add(stmt.name.text);
23435
23536
  }
23436
23537
  return names;
23437
23538
  }
23438
23539
  function buildSyntheticDeclaration(name2, arrow, sourceFile) {
23439
23540
  const paramsText = arrow.parameters.length === 0 ? "" : arrow.parameters.map((p) => p.getText(sourceFile)).join(", ");
23440
23541
  let bodyText;
23441
- if (ts20.isBlock(arrow.body)) {
23542
+ if (ts21.isBlock(arrow.body)) {
23442
23543
  bodyText = arrow.body.getText(sourceFile);
23443
23544
  } else {
23444
23545
  const expr = arrow.body.getText(sourceFile);
@@ -23457,7 +23558,7 @@ var init_preprocess_inline_jsx_callbacks = __esm({
23457
23558
  });
23458
23559
 
23459
23560
  // ../jsx/src/ssr-defaults.ts
23460
- import ts21 from "typescript";
23561
+ import ts22 from "typescript";
23461
23562
  function deriveStashFromDefaults(defaults, props) {
23462
23563
  const extra = {};
23463
23564
  for (const [name2, d] of Object.entries(defaults)) {
@@ -23537,11 +23638,11 @@ function collectPropRefs(expr, propsObjectName, out) {
23537
23638
  const node = parseExpression2(expr);
23538
23639
  if (!node) return;
23539
23640
  const visit3 = (n) => {
23540
- if (ts21.isPropertyAccessExpression(n) && ts21.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts21.isIdentifier(n.name)) {
23641
+ if (ts22.isPropertyAccessExpression(n) && ts22.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts22.isIdentifier(n.name)) {
23541
23642
  out.add(n.name.text);
23542
23643
  return;
23543
23644
  }
23544
- ts21.forEachChild(n, visit3);
23645
+ ts22.forEachChild(n, visit3);
23545
23646
  };
23546
23647
  visit3(node);
23547
23648
  }
@@ -23558,21 +23659,21 @@ function tryStaticEval(expr, ctx2) {
23558
23659
  }
23559
23660
  function evalStatementsForReturn(statements, ctx2) {
23560
23661
  for (const stmt of statements) {
23561
- if (ts21.isVariableStatement(stmt)) {
23662
+ if (ts22.isVariableStatement(stmt)) {
23562
23663
  for (const d of stmt.declarationList.declarations) {
23563
- if (!ts21.isIdentifier(d.name) || !d.initializer) continue;
23664
+ if (!ts22.isIdentifier(d.name) || !d.initializer) continue;
23564
23665
  const v = evalNode(d.initializer, ctx2);
23565
23666
  if (v !== UNRESOLVED) ctx2.bindings[d.name.text] = v;
23566
23667
  }
23567
- } else if (ts21.isReturnStatement(stmt)) {
23668
+ } else if (ts22.isReturnStatement(stmt)) {
23568
23669
  return stmt.expression ? evalNode(stmt.expression, ctx2) : UNRESOLVED;
23569
- } else if (ts21.isIfStatement(stmt)) {
23670
+ } else if (ts22.isIfStatement(stmt)) {
23570
23671
  const cond = evalNode(stmt.expression, ctx2);
23571
23672
  if (cond === UNRESOLVED) return UNRESOLVED;
23572
23673
  const branch = cond ? stmt.thenStatement : stmt.elseStatement;
23573
23674
  if (branch) {
23574
23675
  const taken = evalStatementsForReturn(
23575
- ts21.isBlock(branch) ? branch.statements : [branch],
23676
+ ts22.isBlock(branch) ? branch.statements : [branch],
23576
23677
  ctx2
23577
23678
  );
23578
23679
  if (taken !== NO_RETURN) return taken;
@@ -23584,64 +23685,64 @@ function evalStatementsForReturn(statements, ctx2) {
23584
23685
  return NO_RETURN;
23585
23686
  }
23586
23687
  function parseExpression2(expr) {
23587
- const sf = ts21.createSourceFile(
23688
+ const sf = ts22.createSourceFile(
23588
23689
  "__ssr_default__.ts",
23589
23690
  `(${expr})`,
23590
- ts21.ScriptTarget.Latest,
23691
+ ts22.ScriptTarget.Latest,
23591
23692
  false,
23592
- ts21.ScriptKind.TS
23693
+ ts22.ScriptKind.TS
23593
23694
  );
23594
23695
  const stmt = sf.statements[0];
23595
- if (!stmt || !ts21.isExpressionStatement(stmt)) return null;
23596
- const inner = ts21.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
23696
+ if (!stmt || !ts22.isExpressionStatement(stmt)) return null;
23697
+ const inner = ts22.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
23597
23698
  return inner;
23598
23699
  }
23599
23700
  function evalNode(node, ctx2) {
23600
- if (ts21.isParenthesizedExpression(node)) return evalNode(node.expression, ctx2);
23601
- if (ts21.isAsExpression(node)) return evalNode(node.expression, ctx2);
23602
- if (ts21.isSatisfiesExpression(node)) return evalNode(node.expression, ctx2);
23603
- if (ts21.isTypeAssertionExpression(node)) return evalNode(node.expression, ctx2);
23604
- if (ts21.isNonNullExpression(node)) return evalNode(node.expression, ctx2);
23605
- if (ts21.isArrowFunction(node)) {
23701
+ if (ts22.isParenthesizedExpression(node)) return evalNode(node.expression, ctx2);
23702
+ if (ts22.isAsExpression(node)) return evalNode(node.expression, ctx2);
23703
+ if (ts22.isSatisfiesExpression(node)) return evalNode(node.expression, ctx2);
23704
+ if (ts22.isTypeAssertionExpression(node)) return evalNode(node.expression, ctx2);
23705
+ if (ts22.isNonNullExpression(node)) return evalNode(node.expression, ctx2);
23706
+ if (ts22.isArrowFunction(node)) {
23606
23707
  if (node.parameters.length !== 0) return UNRESOLVED;
23607
- if (!ts21.isBlock(node.body)) return evalNode(node.body, ctx2);
23708
+ if (!ts22.isBlock(node.body)) return evalNode(node.body, ctx2);
23608
23709
  const localBindings = { ...ctx2.bindings };
23609
23710
  const localCtx = { ...ctx2, bindings: localBindings };
23610
23711
  const result2 = evalStatementsForReturn(node.body.statements, localCtx);
23611
23712
  return result2 === NO_RETURN ? UNRESOLVED : result2;
23612
23713
  }
23613
- if (ts21.isNumericLiteral(node)) return Number(node.text);
23614
- if (ts21.isStringLiteralLike(node)) return node.text;
23615
- if (node.kind === ts21.SyntaxKind.TrueKeyword) return true;
23616
- if (node.kind === ts21.SyntaxKind.FalseKeyword) return false;
23617
- if (node.kind === ts21.SyntaxKind.NullKeyword) return null;
23618
- if (ts21.isIdentifier(node)) {
23714
+ if (ts22.isNumericLiteral(node)) return Number(node.text);
23715
+ if (ts22.isStringLiteralLike(node)) return node.text;
23716
+ if (node.kind === ts22.SyntaxKind.TrueKeyword) return true;
23717
+ if (node.kind === ts22.SyntaxKind.FalseKeyword) return false;
23718
+ if (node.kind === ts22.SyntaxKind.NullKeyword) return null;
23719
+ if (ts22.isIdentifier(node)) {
23619
23720
  if (node.text === "undefined") return void 0;
23620
23721
  if (node.text in ctx2.bindings) return ctx2.bindings[node.text];
23621
23722
  if (ctx2.propsLike.has(node.text)) return void 0;
23622
23723
  return UNRESOLVED;
23623
23724
  }
23624
- if (ts21.isPrefixUnaryExpression(node)) {
23725
+ if (ts22.isPrefixUnaryExpression(node)) {
23625
23726
  const arg = evalNode(node.operand, ctx2);
23626
23727
  if (arg === UNRESOLVED) return UNRESOLVED;
23627
23728
  switch (node.operator) {
23628
- case ts21.SyntaxKind.MinusToken:
23729
+ case ts22.SyntaxKind.MinusToken:
23629
23730
  return typeof arg === "number" ? -arg : UNRESOLVED;
23630
- case ts21.SyntaxKind.PlusToken:
23731
+ case ts22.SyntaxKind.PlusToken:
23631
23732
  return typeof arg === "number" ? +arg : UNRESOLVED;
23632
- case ts21.SyntaxKind.ExclamationToken:
23733
+ case ts22.SyntaxKind.ExclamationToken:
23633
23734
  return !arg;
23634
23735
  }
23635
23736
  return UNRESOLVED;
23636
23737
  }
23637
- if (ts21.isObjectLiteralExpression(node)) {
23738
+ if (ts22.isObjectLiteralExpression(node)) {
23638
23739
  const obj = {};
23639
23740
  for (const prop of node.properties) {
23640
- if (!ts21.isPropertyAssignment(prop)) return UNRESOLVED;
23741
+ if (!ts22.isPropertyAssignment(prop)) return UNRESOLVED;
23641
23742
  let key;
23642
- if (ts21.isIdentifier(prop.name) || ts21.isStringLiteralLike(prop.name)) {
23743
+ if (ts22.isIdentifier(prop.name) || ts22.isStringLiteralLike(prop.name)) {
23643
23744
  key = prop.name.text;
23644
- } else if (ts21.isNumericLiteral(prop.name)) {
23745
+ } else if (ts22.isNumericLiteral(prop.name)) {
23645
23746
  key = prop.name.text;
23646
23747
  } else {
23647
23748
  return UNRESOLVED;
@@ -23652,17 +23753,17 @@ function evalNode(node, ctx2) {
23652
23753
  }
23653
23754
  return obj;
23654
23755
  }
23655
- if (ts21.isArrayLiteralExpression(node)) {
23756
+ if (ts22.isArrayLiteralExpression(node)) {
23656
23757
  const arr = [];
23657
23758
  for (const elem of node.elements) {
23658
- if (ts21.isOmittedExpression(elem)) return UNRESOLVED;
23759
+ if (ts22.isOmittedExpression(elem)) return UNRESOLVED;
23659
23760
  const v = evalNode(elem, ctx2);
23660
23761
  if (v === UNRESOLVED) return UNRESOLVED;
23661
23762
  arr.push(v === void 0 ? null : v);
23662
23763
  }
23663
23764
  return arr;
23664
23765
  }
23665
- if (ts21.isElementAccessExpression(node)) {
23766
+ if (ts22.isElementAccessExpression(node)) {
23666
23767
  const base = evalNode(node.expression, ctx2);
23667
23768
  if (base === void 0) return void 0;
23668
23769
  if (base === UNRESOLVED || base === null || typeof base !== "object") return UNRESOLVED;
@@ -23672,16 +23773,16 @@ function evalNode(node, ctx2) {
23672
23773
  const k = String(key);
23673
23774
  return Object.prototype.hasOwnProperty.call(base, k) ? base[k] : void 0;
23674
23775
  }
23675
- if (ts21.isPropertyAccessExpression(node)) {
23776
+ if (ts22.isPropertyAccessExpression(node)) {
23676
23777
  const baseResult = evalNode(node.expression, ctx2);
23677
23778
  if (baseResult === void 0) return void 0;
23678
23779
  return UNRESOLVED;
23679
23780
  }
23680
- if (ts21.isCallExpression(node)) {
23681
- if (node.arguments.length === 0 && ts21.isIdentifier(node.expression) && node.expression.text in ctx2.bindings) {
23781
+ if (ts22.isCallExpression(node)) {
23782
+ if (node.arguments.length === 0 && ts22.isIdentifier(node.expression) && node.expression.text in ctx2.bindings) {
23682
23783
  return ctx2.bindings[node.expression.text];
23683
23784
  }
23684
- if (ts21.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
23785
+ if (ts22.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
23685
23786
  const recv = evalNode(node.expression.expression, ctx2);
23686
23787
  if (Array.isArray(recv)) {
23687
23788
  let sep = ",";
@@ -23696,24 +23797,24 @@ function evalNode(node, ctx2) {
23696
23797
  }
23697
23798
  return UNRESOLVED;
23698
23799
  }
23699
- if (ts21.isConditionalExpression(node)) {
23800
+ if (ts22.isConditionalExpression(node)) {
23700
23801
  const cond = evalNode(node.condition, ctx2);
23701
23802
  if (cond === UNRESOLVED) return UNRESOLVED;
23702
23803
  return cond ? evalNode(node.whenTrue, ctx2) : evalNode(node.whenFalse, ctx2);
23703
23804
  }
23704
- if (ts21.isBinaryExpression(node)) {
23805
+ if (ts22.isBinaryExpression(node)) {
23705
23806
  const op = node.operatorToken.kind;
23706
- if (op === ts21.SyntaxKind.QuestionQuestionToken) {
23807
+ if (op === ts22.SyntaxKind.QuestionQuestionToken) {
23707
23808
  const l2 = evalNode(node.left, ctx2);
23708
23809
  if (l2 !== UNRESOLVED && l2 !== null && l2 !== void 0) return l2;
23709
23810
  return evalNode(node.right, ctx2);
23710
23811
  }
23711
- if (op === ts21.SyntaxKind.BarBarToken) {
23812
+ if (op === ts22.SyntaxKind.BarBarToken) {
23712
23813
  const l2 = evalNode(node.left, ctx2);
23713
23814
  if (l2 !== UNRESOLVED && l2) return l2;
23714
23815
  return evalNode(node.right, ctx2);
23715
23816
  }
23716
- if (op === ts21.SyntaxKind.AmpersandAmpersandToken) {
23817
+ if (op === ts22.SyntaxKind.AmpersandAmpersandToken) {
23717
23818
  const l2 = evalNode(node.left, ctx2);
23718
23819
  if (l2 === UNRESOLVED) return UNRESOLVED;
23719
23820
  if (!l2) return l2;
@@ -23723,28 +23824,28 @@ function evalNode(node, ctx2) {
23723
23824
  const r2 = evalNode(node.right, ctx2);
23724
23825
  if (l === UNRESOLVED || r2 === UNRESOLVED) return UNRESOLVED;
23725
23826
  switch (op) {
23726
- case ts21.SyntaxKind.PlusToken:
23827
+ case ts22.SyntaxKind.PlusToken:
23727
23828
  if (typeof l === "string" || typeof r2 === "string") return `${l}${r2}`;
23728
23829
  if (typeof l === "number" && typeof r2 === "number") return l + r2;
23729
23830
  return UNRESOLVED;
23730
- case ts21.SyntaxKind.MinusToken:
23831
+ case ts22.SyntaxKind.MinusToken:
23731
23832
  return typeof l === "number" && typeof r2 === "number" ? l - r2 : UNRESOLVED;
23732
- case ts21.SyntaxKind.AsteriskToken:
23833
+ case ts22.SyntaxKind.AsteriskToken:
23733
23834
  return typeof l === "number" && typeof r2 === "number" ? l * r2 : UNRESOLVED;
23734
- case ts21.SyntaxKind.SlashToken:
23835
+ case ts22.SyntaxKind.SlashToken:
23735
23836
  return typeof l === "number" && typeof r2 === "number" && r2 !== 0 ? l / r2 : UNRESOLVED;
23736
- case ts21.SyntaxKind.PercentToken:
23837
+ case ts22.SyntaxKind.PercentToken:
23737
23838
  return typeof l === "number" && typeof r2 === "number" && r2 !== 0 ? l % r2 : UNRESOLVED;
23738
- case ts21.SyntaxKind.EqualsEqualsEqualsToken:
23739
- case ts21.SyntaxKind.EqualsEqualsToken:
23839
+ case ts22.SyntaxKind.EqualsEqualsEqualsToken:
23840
+ case ts22.SyntaxKind.EqualsEqualsToken:
23740
23841
  return l === r2;
23741
- case ts21.SyntaxKind.ExclamationEqualsEqualsToken:
23742
- case ts21.SyntaxKind.ExclamationEqualsToken:
23842
+ case ts22.SyntaxKind.ExclamationEqualsEqualsToken:
23843
+ case ts22.SyntaxKind.ExclamationEqualsToken:
23743
23844
  return l !== r2;
23744
23845
  }
23745
23846
  return UNRESOLVED;
23746
23847
  }
23747
- if (ts21.isTemplateExpression(node)) {
23848
+ if (ts22.isTemplateExpression(node)) {
23748
23849
  if (node.templateSpans.length === 0) return node.head.text;
23749
23850
  let acc = node.head.text;
23750
23851
  for (const span of node.templateSpans) {
@@ -23754,7 +23855,7 @@ function evalNode(node, ctx2) {
23754
23855
  }
23755
23856
  return acc;
23756
23857
  }
23757
- if (ts21.isNoSubstitutionTemplateLiteral(node)) return node.text;
23858
+ if (ts22.isNoSubstitutionTemplateLiteral(node)) return node.text;
23758
23859
  return UNRESOLVED;
23759
23860
  }
23760
23861
  var UNRESOLVED, NO_RETURN;
@@ -23767,7 +23868,7 @@ var init_ssr_defaults = __esm({
23767
23868
  });
23768
23869
 
23769
23870
  // ../jsx/src/augment-inherited-props.ts
23770
- import ts22 from "typescript";
23871
+ import ts23 from "typescript";
23771
23872
  function collectContextConsumers(metadata) {
23772
23873
  const constants = metadata.localConstants ?? [];
23773
23874
  const contextDefaults = /* @__PURE__ */ new Map();
@@ -23794,35 +23895,35 @@ function collectContextConsumers(metadata) {
23794
23895
  }
23795
23896
  function parseUseContextArg(source) {
23796
23897
  const expr = parseSingleExpression(source);
23797
- if (!expr || !ts22.isCallExpression(expr)) return null;
23798
- if (!ts22.isIdentifier(expr.expression) || expr.expression.text !== "useContext") return null;
23898
+ if (!expr || !ts23.isCallExpression(expr)) return null;
23899
+ if (!ts23.isIdentifier(expr.expression) || expr.expression.text !== "useContext") return null;
23799
23900
  if (expr.arguments.length !== 1) return null;
23800
23901
  const arg = expr.arguments[0];
23801
- return ts22.isIdentifier(arg) ? arg.text : null;
23902
+ return ts23.isIdentifier(arg) ? arg.text : null;
23802
23903
  }
23803
23904
  function parseCreateContextDefault(source) {
23804
23905
  const expr = parseSingleExpression(source);
23805
- if (!expr || !ts22.isCallExpression(expr)) return null;
23906
+ if (!expr || !ts23.isCallExpression(expr)) return null;
23806
23907
  if (expr.arguments.length === 0) return null;
23807
23908
  const arg = expr.arguments[0];
23808
- if (ts22.isStringLiteral(arg) || ts22.isNoSubstitutionTemplateLiteral(arg)) return arg.text;
23809
- if (ts22.isNumericLiteral(arg)) return Number(arg.text);
23810
- if (arg.kind === ts22.SyntaxKind.TrueKeyword) return true;
23811
- if (arg.kind === ts22.SyntaxKind.FalseKeyword) return false;
23909
+ if (ts23.isStringLiteral(arg) || ts23.isNoSubstitutionTemplateLiteral(arg)) return arg.text;
23910
+ if (ts23.isNumericLiteral(arg)) return Number(arg.text);
23911
+ if (arg.kind === ts23.SyntaxKind.TrueKeyword) return true;
23912
+ if (arg.kind === ts23.SyntaxKind.FalseKeyword) return false;
23812
23913
  return null;
23813
23914
  }
23814
23915
  function isObjectLiteralCreateContextDefault(source) {
23815
23916
  const expr = parseSingleExpression(source);
23816
- if (!expr || !ts22.isCallExpression(expr)) return false;
23917
+ if (!expr || !ts23.isCallExpression(expr)) return false;
23817
23918
  if (expr.arguments.length === 0) return false;
23818
- return ts22.isObjectLiteralExpression(expr.arguments[0]);
23919
+ return ts23.isObjectLiteralExpression(expr.arguments[0]);
23819
23920
  }
23820
23921
  function parseSingleExpression(source) {
23821
- const sf = ts22.createSourceFile("__ctx.ts", `(${source})`, ts22.ScriptTarget.Latest, false);
23922
+ const sf = ts23.createSourceFile("__ctx.ts", `(${source})`, ts23.ScriptTarget.Latest, false);
23822
23923
  const stmt = sf.statements[0];
23823
- if (!stmt || !ts22.isExpressionStatement(stmt)) return null;
23924
+ if (!stmt || !ts23.isExpressionStatement(stmt)) return null;
23824
23925
  let e = stmt.expression;
23825
- while (ts22.isParenthesizedExpression(e)) e = e.expression;
23926
+ while (ts23.isParenthesizedExpression(e)) e = e.expression;
23826
23927
  return e;
23827
23928
  }
23828
23929
  function augmentInheritedPropAccesses(ir) {
@@ -23843,21 +23944,21 @@ function augmentInheritedPropAccesses(ir) {
23843
23944
  const coalesceLiteralTypes = /* @__PURE__ */ new Map();
23844
23945
  const pinCoalesceLiterals = (s) => {
23845
23946
  if (!s || !s.includes(propsObj)) return;
23846
- const sf = ts22.createSourceFile("__aug.ts", `(${s})`, ts22.ScriptTarget.Latest, false);
23947
+ const sf = ts23.createSourceFile("__aug.ts", `(${s})`, ts23.ScriptTarget.Latest, false);
23847
23948
  const visit3 = (n) => {
23848
- if (ts22.isBinaryExpression(n) && (n.operatorToken.kind === ts22.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts22.SyntaxKind.BarBarToken)) {
23949
+ if (ts23.isBinaryExpression(n) && (n.operatorToken.kind === ts23.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts23.SyntaxKind.BarBarToken)) {
23849
23950
  let left = n.left;
23850
- while (ts22.isParenthesizedExpression(left)) left = left.expression;
23851
- if (ts22.isPropertyAccessExpression(left) && ts22.isIdentifier(left.expression) && left.expression.text === propsObj) {
23951
+ while (ts23.isParenthesizedExpression(left)) left = left.expression;
23952
+ if (ts23.isPropertyAccessExpression(left) && ts23.isIdentifier(left.expression) && left.expression.text === propsObj) {
23852
23953
  const name2 = left.name.text;
23853
23954
  let right = n.right;
23854
- while (ts22.isParenthesizedExpression(right)) right = right.expression;
23855
- if (ts22.isPrefixUnaryExpression(right)) right = right.operand;
23856
- const kind2 = ts22.isNumericLiteral(right) ? "number" : right.kind === ts22.SyntaxKind.TrueKeyword || right.kind === ts22.SyntaxKind.FalseKeyword ? "boolean" : ts22.isStringLiteralLike(right) ? "string" : null;
23955
+ while (ts23.isParenthesizedExpression(right)) right = right.expression;
23956
+ if (ts23.isPrefixUnaryExpression(right)) right = right.operand;
23957
+ const kind2 = ts23.isNumericLiteral(right) ? "number" : right.kind === ts23.SyntaxKind.TrueKeyword || right.kind === ts23.SyntaxKind.FalseKeyword ? "boolean" : ts23.isStringLiteralLike(right) ? "string" : null;
23857
23958
  if (kind2 && !coalesceLiteralTypes.has(name2)) coalesceLiteralTypes.set(name2, kind2);
23858
23959
  }
23859
23960
  }
23860
- ts22.forEachChild(n, visit3);
23961
+ ts23.forEachChild(n, visit3);
23861
23962
  };
23862
23963
  visit3(sf);
23863
23964
  };
@@ -23953,39 +24054,39 @@ function augmentInheritedPropAccesses(ir) {
23953
24054
  }
23954
24055
  }
23955
24056
  function parseStaticStringConst(source) {
23956
- const sf = ts22.createSourceFile(
24057
+ const sf = ts23.createSourceFile(
23957
24058
  "__const.ts",
23958
24059
  `const __x = (${source});`,
23959
- ts22.ScriptTarget.Latest,
24060
+ ts23.ScriptTarget.Latest,
23960
24061
  /*setParentNodes*/
23961
24062
  false
23962
24063
  );
23963
24064
  const stmt = sf.statements[0];
23964
- if (!stmt || !ts22.isVariableStatement(stmt)) return null;
24065
+ if (!stmt || !ts23.isVariableStatement(stmt)) return null;
23965
24066
  let init = stmt.declarationList.declarations[0]?.initializer;
23966
- while (init && ts22.isParenthesizedExpression(init)) init = init.expression;
24067
+ while (init && ts23.isParenthesizedExpression(init)) init = init.expression;
23967
24068
  if (!init) return null;
23968
- if (ts22.isStringLiteral(init) || ts22.isNoSubstitutionTemplateLiteral(init)) {
24069
+ if (ts23.isStringLiteral(init) || ts23.isNoSubstitutionTemplateLiteral(init)) {
23969
24070
  return init.text;
23970
24071
  }
23971
24072
  return evalStringArrayJoin(source);
23972
24073
  }
23973
24074
  function evalTemplateOfStringConsts(source, resolved) {
23974
- const sf = ts22.createSourceFile(
24075
+ const sf = ts23.createSourceFile(
23975
24076
  "__const.ts",
23976
24077
  `const __x = (${source});`,
23977
- ts22.ScriptTarget.Latest,
24078
+ ts23.ScriptTarget.Latest,
23978
24079
  /*setParentNodes*/
23979
24080
  false
23980
24081
  );
23981
24082
  const stmt = sf.statements[0];
23982
- if (!stmt || !ts22.isVariableStatement(stmt)) return null;
24083
+ if (!stmt || !ts23.isVariableStatement(stmt)) return null;
23983
24084
  let init = stmt.declarationList.declarations[0]?.initializer;
23984
- while (init && ts22.isParenthesizedExpression(init)) init = init.expression;
23985
- if (!init || !ts22.isTemplateExpression(init)) return null;
24085
+ while (init && ts23.isParenthesizedExpression(init)) init = init.expression;
24086
+ if (!init || !ts23.isTemplateExpression(init)) return null;
23986
24087
  let out = init.head.text;
23987
24088
  for (const span of init.templateSpans) {
23988
- if (!ts22.isIdentifier(span.expression)) return null;
24089
+ if (!ts23.isIdentifier(span.expression)) return null;
23989
24090
  const value2 = resolved.get(span.expression.text);
23990
24091
  if (value2 === void 0) return null;
23991
24092
  out += value2 + span.literal.text;
@@ -24011,31 +24112,32 @@ function collectModuleStringConsts(constants) {
24011
24112
  }
24012
24113
  return map;
24013
24114
  }
24014
- function lookupStaticRecordLiteral(objectName, key, constants) {
24115
+ function lookupStaticRecordLiteral(objectName, key, constants, isShadowed) {
24116
+ if (isShadowed(objectName)) return null;
24015
24117
  const constInfo = (constants ?? []).find((c) => c.name === objectName && c.isModule);
24016
24118
  if (constInfo?.value === void 0) return null;
24017
- const sf = ts22.createSourceFile(
24119
+ const sf = ts23.createSourceFile(
24018
24120
  "__rec.ts",
24019
24121
  `(${constInfo.value})`,
24020
- ts22.ScriptTarget.Latest,
24122
+ ts23.ScriptTarget.Latest,
24021
24123
  /*setParentNodes*/
24022
24124
  true
24023
24125
  );
24024
24126
  if (sf.statements.length !== 1) return null;
24025
24127
  const stmt = sf.statements[0];
24026
- if (!ts22.isExpressionStatement(stmt)) return null;
24128
+ if (!ts23.isExpressionStatement(stmt)) return null;
24027
24129
  let parsed = stmt.expression;
24028
- while (ts22.isParenthesizedExpression(parsed)) parsed = parsed.expression;
24029
- if (!ts22.isObjectLiteralExpression(parsed)) return null;
24130
+ while (ts23.isParenthesizedExpression(parsed)) parsed = parsed.expression;
24131
+ if (!ts23.isObjectLiteralExpression(parsed)) return null;
24030
24132
  for (const prop of parsed.properties) {
24031
- if (!ts22.isPropertyAssignment(prop)) continue;
24133
+ if (!ts23.isPropertyAssignment(prop)) continue;
24032
24134
  const name2 = prop.name;
24033
- const propKey = ts22.isIdentifier(name2) || ts22.isStringLiteral(name2) || ts22.isNoSubstitutionTemplateLiteral(name2) ? name2.text : null;
24135
+ const propKey = ts23.isIdentifier(name2) || ts23.isStringLiteral(name2) || ts23.isNoSubstitutionTemplateLiteral(name2) ? name2.text : null;
24034
24136
  if (propKey !== key) continue;
24035
24137
  let v = prop.initializer;
24036
- while (ts22.isParenthesizedExpression(v)) v = v.expression;
24037
- if (ts22.isNumericLiteral(v)) return { kind: "number", text: v.text };
24038
- if (ts22.isStringLiteral(v) || ts22.isNoSubstitutionTemplateLiteral(v)) {
24138
+ while (ts23.isParenthesizedExpression(v)) v = v.expression;
24139
+ if (ts23.isNumericLiteral(v)) return { kind: "number", text: v.text };
24140
+ if (ts23.isStringLiteral(v) || ts23.isNoSubstitutionTemplateLiteral(v)) {
24039
24141
  return { kind: "string", text: v.text };
24040
24142
  }
24041
24143
  return null;
@@ -24043,27 +24145,27 @@ function lookupStaticRecordLiteral(objectName, key, constants) {
24043
24145
  return null;
24044
24146
  }
24045
24147
  function evalStringArrayJoin(source) {
24046
- const sf = ts22.createSourceFile(
24148
+ const sf = ts23.createSourceFile(
24047
24149
  "__join.ts",
24048
24150
  `const __x = (${source});`,
24049
- ts22.ScriptTarget.Latest,
24151
+ ts23.ScriptTarget.Latest,
24050
24152
  /*setParentNodes*/
24051
24153
  false
24052
24154
  );
24053
24155
  const stmt = sf.statements[0];
24054
- if (!stmt || !ts22.isVariableStatement(stmt)) return null;
24156
+ if (!stmt || !ts23.isVariableStatement(stmt)) return null;
24055
24157
  let node = stmt.declarationList.declarations[0]?.initializer;
24056
- while (node && ts22.isParenthesizedExpression(node)) node = node.expression;
24057
- if (!node || !ts22.isCallExpression(node)) return null;
24158
+ while (node && ts23.isParenthesizedExpression(node)) node = node.expression;
24159
+ if (!node || !ts23.isCallExpression(node)) return null;
24058
24160
  const callee = node.expression;
24059
- if (!ts22.isPropertyAccessExpression(callee)) return null;
24161
+ if (!ts23.isPropertyAccessExpression(callee)) return null;
24060
24162
  if (callee.name.text !== "join") return null;
24061
24163
  let recv = callee.expression;
24062
- while (ts22.isParenthesizedExpression(recv)) recv = recv.expression;
24063
- if (!ts22.isArrayLiteralExpression(recv)) return null;
24164
+ while (ts23.isParenthesizedExpression(recv)) recv = recv.expression;
24165
+ if (!ts23.isArrayLiteralExpression(recv)) return null;
24064
24166
  const parts = [];
24065
24167
  for (const el of recv.elements) {
24066
- if (ts22.isStringLiteral(el) || ts22.isNoSubstitutionTemplateLiteral(el)) {
24168
+ if (ts23.isStringLiteral(el) || ts23.isNoSubstitutionTemplateLiteral(el)) {
24067
24169
  parts.push(el.text);
24068
24170
  } else {
24069
24171
  return null;
@@ -24072,16 +24174,16 @@ function evalStringArrayJoin(source) {
24072
24174
  let sep = ",";
24073
24175
  if (node.arguments.length >= 1) {
24074
24176
  const arg = node.arguments[0];
24075
- if (ts22.isStringLiteral(arg) || ts22.isNoSubstitutionTemplateLiteral(arg)) sep = arg.text;
24177
+ if (ts23.isStringLiteral(arg) || ts23.isNoSubstitutionTemplateLiteral(arg)) sep = arg.text;
24076
24178
  else return null;
24077
24179
  }
24078
24180
  return parts.join(sep);
24079
24181
  }
24080
24182
  function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
24081
- if (!ts22.isElementAccessExpression(val)) return null;
24183
+ if (!ts23.isElementAccessExpression(val)) return null;
24082
24184
  const obj = val.expression;
24083
24185
  const arg = val.argumentExpression;
24084
- if (!ts22.isIdentifier(obj) || !ts22.isIdentifier(arg)) return null;
24186
+ if (!ts23.isIdentifier(obj) || !ts23.isIdentifier(arg)) return null;
24085
24187
  let indexPropName;
24086
24188
  let defaultKey;
24087
24189
  const resolved = resolveKey?.(arg.text);
@@ -24095,35 +24197,35 @@ function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
24095
24197
  }
24096
24198
  const constInfo = localConstants.find((c) => c.name === obj.text && c.isModule);
24097
24199
  if (constInfo?.value === void 0) return null;
24098
- const sf = ts22.createSourceFile(
24200
+ const sf = ts23.createSourceFile(
24099
24201
  "__rec.ts",
24100
24202
  `(${constInfo.value})`,
24101
- ts22.ScriptTarget.Latest,
24203
+ ts23.ScriptTarget.Latest,
24102
24204
  /* setParentNodes */
24103
24205
  true
24104
24206
  );
24105
24207
  if (sf.statements.length !== 1) return null;
24106
24208
  const stmt = sf.statements[0];
24107
- if (!ts22.isExpressionStatement(stmt)) return null;
24209
+ if (!ts23.isExpressionStatement(stmt)) return null;
24108
24210
  let parsed = stmt.expression;
24109
- while (ts22.isParenthesizedExpression(parsed)) parsed = parsed.expression;
24110
- if (!ts22.isObjectLiteralExpression(parsed)) return null;
24211
+ while (ts23.isParenthesizedExpression(parsed)) parsed = parsed.expression;
24212
+ if (!ts23.isObjectLiteralExpression(parsed)) return null;
24111
24213
  const entries2 = [];
24112
24214
  for (const prop of parsed.properties) {
24113
- if (!ts22.isPropertyAssignment(prop)) return null;
24215
+ if (!ts23.isPropertyAssignment(prop)) return null;
24114
24216
  let key;
24115
- if (ts22.isIdentifier(prop.name)) {
24217
+ if (ts23.isIdentifier(prop.name)) {
24116
24218
  key = prop.name.text;
24117
- } else if (ts22.isStringLiteral(prop.name) || ts22.isNoSubstitutionTemplateLiteral(prop.name)) {
24219
+ } else if (ts23.isStringLiteral(prop.name) || ts23.isNoSubstitutionTemplateLiteral(prop.name)) {
24118
24220
  key = prop.name.text;
24119
24221
  } else {
24120
24222
  return null;
24121
24223
  }
24122
24224
  let v = prop.initializer;
24123
- while (ts22.isParenthesizedExpression(v)) v = v.expression;
24124
- if (ts22.isNumericLiteral(v)) {
24225
+ while (ts23.isParenthesizedExpression(v)) v = v.expression;
24226
+ if (ts23.isNumericLiteral(v)) {
24125
24227
  entries2.push({ key, value: { kind: "number", text: v.text } });
24126
- } else if (ts22.isStringLiteral(v) || ts22.isNoSubstitutionTemplateLiteral(v)) {
24228
+ } else if (ts23.isStringLiteral(v) || ts23.isNoSubstitutionTemplateLiteral(v)) {
24127
24229
  entries2.push({ key, value: { kind: "string", text: v.text } });
24128
24230
  } else {
24129
24231
  return null;
@@ -24395,7 +24497,7 @@ var init_rich_type_refusal = __esm({
24395
24497
  });
24396
24498
 
24397
24499
  // ../jsx/src/compiler.ts
24398
- import ts23 from "typescript";
24500
+ import ts24 from "typescript";
24399
24501
  function mergeTemplateImports(lines) {
24400
24502
  const result2 = [];
24401
24503
  const valueIdx = /* @__PURE__ */ new Map();
@@ -24460,12 +24562,12 @@ function compileMultipleComponents(source, filePath, componentNames, options2) {
24460
24562
  if (entries2.some((e) => e.componentIR.metadata.isClientComponent)) {
24461
24563
  const topLevelNames = /* @__PURE__ */ new Set();
24462
24564
  {
24463
- const sf = ts23.createSourceFile(filePath, source, ts23.ScriptTarget.Latest, true, ts23.ScriptKind.TSX);
24565
+ const sf = ts24.createSourceFile(filePath, source, ts24.ScriptTarget.Latest, true, ts24.ScriptKind.TSX);
24464
24566
  for (const stmt of sf.statements) {
24465
- if (ts23.isFunctionDeclaration(stmt) && stmt.name) topLevelNames.add(stmt.name.text);
24466
- else if (ts23.isVariableStatement(stmt)) {
24567
+ if (ts24.isFunctionDeclaration(stmt) && stmt.name) topLevelNames.add(stmt.name.text);
24568
+ else if (ts24.isVariableStatement(stmt)) {
24467
24569
  for (const d of stmt.declarationList.declarations) {
24468
- if (ts23.isIdentifier(d.name)) topLevelNames.add(d.name.text);
24570
+ if (ts24.isIdentifier(d.name)) topLevelNames.add(d.name.text);
24469
24571
  }
24470
24572
  }
24471
24573
  }
@@ -24526,13 +24628,13 @@ function compileMultipleComponents(source, filePath, componentNames, options2) {
24526
24628
  const moduleStatementSeen = /* @__PURE__ */ new Set();
24527
24629
  const moduleStatementsOrdered = [];
24528
24630
  const collectModuleStatements = (block) => {
24529
- const sf = ts23.createSourceFile(
24631
+ const sf = ts24.createSourceFile(
24530
24632
  "__bf_module_decls.tsx",
24531
24633
  block,
24532
- ts23.ScriptTarget.Latest,
24634
+ ts24.ScriptTarget.Latest,
24533
24635
  /* setParentNodes */
24534
24636
  false,
24535
- ts23.ScriptKind.TSX
24637
+ ts24.ScriptKind.TSX
24536
24638
  );
24537
24639
  for (const stmt of sf.statements) {
24538
24640
  const text = stmt.getText(sf);
@@ -24764,6 +24866,11 @@ function compileMultipleComponents(source, filePath, componentNames, options2) {
24764
24866
  }
24765
24867
  return { files: files2, errors };
24766
24868
  }
24869
+ function componentTypeParametersText(componentNode, sourceFile) {
24870
+ const typeParameters = componentNode?.typeParameters;
24871
+ if (!typeParameters || typeParameters.length === 0) return null;
24872
+ return `<${typeParameters.map((p) => p.getText(sourceFile)).join(", ")}>`;
24873
+ }
24767
24874
  function buildMetadata(ctx2) {
24768
24875
  const metadata = {
24769
24876
  componentName: ctx2.componentName || "Unknown",
@@ -24772,6 +24879,7 @@ function buildMetadata(ctx2) {
24772
24879
  isClientComponent: ctx2.hasUseClientDirective,
24773
24880
  typeDefinitions: ctx2.typeDefinitions,
24774
24881
  propsType: ctx2.propsType,
24882
+ typeParameters: componentTypeParametersText(ctx2.componentNode, ctx2.sourceFile),
24775
24883
  propsParams: ctx2.propsParams,
24776
24884
  propsObjectName: ctx2.propsObjectName,
24777
24885
  restPropsName: ctx2.restPropsName,
@@ -24997,7 +25105,7 @@ var init_compiler = __esm({
24997
25105
  });
24998
25106
 
24999
25107
  // ../jsx/src/shared-program.ts
25000
- import ts24 from "typescript";
25108
+ import ts25 from "typescript";
25001
25109
  import path6 from "node:path";
25002
25110
  function commonParent(paths) {
25003
25111
  if (paths.length === 0) return process.cwd();
@@ -25015,10 +25123,10 @@ function commonParent(paths) {
25015
25123
  function createProgramForCorpus(files2, options2 = {}) {
25016
25124
  const baseUrl = options2.baseUrl ?? commonParent(files2);
25017
25125
  const compilerOptions = {
25018
- target: ts24.ScriptTarget.Latest,
25019
- module: ts24.ModuleKind.ESNext,
25020
- moduleResolution: ts24.ModuleResolutionKind.Bundler,
25021
- jsx: ts24.JsxEmit.ReactJSX,
25126
+ target: ts25.ScriptTarget.Latest,
25127
+ module: ts25.ModuleKind.ESNext,
25128
+ moduleResolution: ts25.ModuleResolutionKind.Bundler,
25129
+ jsx: ts25.JsxEmit.ReactJSX,
25022
25130
  strict: true,
25023
25131
  skipLibCheck: true,
25024
25132
  noEmit: true,
@@ -25028,7 +25136,7 @@ function createProgramForCorpus(files2, options2 = {}) {
25028
25136
  ...options2.compilerOptions
25029
25137
  };
25030
25138
  const absolute = files2.map((f) => path6.resolve(f));
25031
- return ts24.createProgram(absolute, compilerOptions, void 0, options2.oldProgram);
25139
+ return ts25.createProgram(absolute, compilerOptions, void 0, options2.oldProgram);
25032
25140
  }
25033
25141
  var init_shared_program = __esm({
25034
25142
  "../jsx/src/shared-program.ts"() {
@@ -25128,7 +25236,13 @@ var init_jsx_adapter = __esm({
25128
25236
  ...localFunctions.map((f) => ({ name: f.name, body: f.body })),
25129
25237
  ...localConstants.map((c) => ({ name: c.name, body: c.value }))
25130
25238
  ];
25131
- const reachable = findReachableNames(primaryRefText, declarations);
25239
+ const reachable = closeOverWritersOfMutableBindings(
25240
+ primaryRefText,
25241
+ declarations,
25242
+ new Set(
25243
+ ir.metadata.localConstants.filter((c) => (c.declarationKind ?? "const") !== "const").map((c) => c.name)
25244
+ )
25245
+ );
25132
25246
  const reachableBodies = [...reachable].map((name2) => {
25133
25247
  const func = localFunctions.find((f) => f.name === name2);
25134
25248
  if (func) return func.body;
@@ -25158,7 +25272,10 @@ var init_jsx_adapter = __esm({
25158
25272
  if (signal2.setter) {
25159
25273
  const setterUsed = identifierPattern(signal2.setter).test(setterRefText);
25160
25274
  if (setterUsed) {
25161
- lines.push(` const ${signal2.setter} = (..._args: any[]) => {}`);
25275
+ const setterType = preserveTypes && signal2.type.kind !== "unknown" ? `(valueOrFn: ${signal2.type.raw} | ((prev: ${signal2.type.raw}) => ${signal2.type.raw})) => void` : null;
25276
+ lines.push(
25277
+ setterType ? ` const ${signal2.setter}: ${setterType} = () => {}` : ` const ${signal2.setter} = (..._args: any[]) => {}`
25278
+ );
25162
25279
  }
25163
25280
  }
25164
25281
  }
@@ -25425,7 +25542,7 @@ var init_jsx_adapter = __esm({
25425
25542
  });
25426
25543
 
25427
25544
  // ../jsx/src/adapters/template-imports.ts
25428
- import ts25 from "typescript";
25545
+ import ts26 from "typescript";
25429
25546
  function rewriteImportsForTemplate(imports, shimSource, rewriteRelative) {
25430
25547
  const remap = (imp) => {
25431
25548
  if (!rewriteRelative || !imp.source.startsWith(".")) return imp;
@@ -25469,24 +25586,24 @@ function specKey(s) {
25469
25586
  }
25470
25587
  function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
25471
25588
  if (!sourceText.includes("import")) return sourceText;
25472
- const sf = ts25.createSourceFile(
25589
+ const sf = ts26.createSourceFile(
25473
25590
  "bf-template-fragment.tsx",
25474
25591
  sourceText,
25475
- ts25.ScriptTarget.Latest,
25592
+ ts26.ScriptTarget.Latest,
25476
25593
  /* setParentNodes */
25477
25594
  false,
25478
- ts25.ScriptKind.TSX
25595
+ ts26.ScriptKind.TSX
25479
25596
  );
25480
25597
  const edits = [];
25481
25598
  const visit3 = (node) => {
25482
- if (ts25.isCallExpression(node) && node.expression.kind === ts25.SyntaxKind.ImportKeyword && node.arguments.length > 0 && ts25.isStringLiteralLike(node.arguments[0])) {
25599
+ if (ts26.isCallExpression(node) && node.expression.kind === ts26.SyntaxKind.ImportKeyword && node.arguments.length > 0 && ts26.isStringLiteralLike(node.arguments[0])) {
25483
25600
  collect(node.arguments[0]);
25484
25601
  }
25485
- if (ts25.isImportTypeNode(node) && ts25.isLiteralTypeNode(node.argument)) {
25602
+ if (ts26.isImportTypeNode(node) && ts26.isLiteralTypeNode(node.argument)) {
25486
25603
  const literal = node.argument.literal;
25487
- if (ts25.isStringLiteralLike(literal)) collect(literal);
25604
+ if (ts26.isStringLiteralLike(literal)) collect(literal);
25488
25605
  }
25489
- ts25.forEachChild(node, visit3);
25606
+ ts26.forEachChild(node, visit3);
25490
25607
  };
25491
25608
  const collect = (literal) => {
25492
25609
  const specifier = literal.text;
@@ -25501,7 +25618,7 @@ function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
25501
25618
  text: `'${next}'`
25502
25619
  });
25503
25620
  };
25504
- ts25.forEachChild(sf, visit3);
25621
+ ts26.forEachChild(sf, visit3);
25505
25622
  if (edits.length === 0) return sourceText;
25506
25623
  let out = sourceText;
25507
25624
  for (const edit of edits.sort((a, b) => b.start - a.start)) {
@@ -25618,7 +25735,8 @@ export default ${this.componentName}` : "";
25618
25735
  const noArgDefault = hasRequiredProps ? "" : ` = {} as ${propsTypeExpr}`;
25619
25736
  const lines = [];
25620
25737
  const exportPrefix = ir.metadata.isExported === false ? "" : "export ";
25621
- lines.push(`${exportPrefix}function ${name2}(${fullPropsDestructure}${typeAnnotation}${noArgDefault}) {`);
25738
+ const typeParameters = ir.metadata.typeParameters ?? "";
25739
+ lines.push(`${exportPrefix}function ${name2}${typeParameters}(${fullPropsDestructure}${typeAnnotation}${noArgDefault}) {`);
25622
25740
  if (hasClientInteractivity) {
25623
25741
  lines.push(` const __scopeId = (/_s\\d/.test(__bfScope || '') ? __bfScope : null) || __instanceId || \`${name2}_\${Math.random().toString(36).slice(2, 8)}\``);
25624
25742
  } else {
@@ -26347,7 +26465,7 @@ var init_dangerous_inner_html = __esm({
26347
26465
  });
26348
26466
 
26349
26467
  // ../jsx/src/combine-client-js.ts
26350
- import ts26 from "typescript";
26468
+ import ts27 from "typescript";
26351
26469
  function combineParentChildClientJs(files2) {
26352
26470
  const result2 = /* @__PURE__ */ new Map();
26353
26471
  const lookup = /* @__PURE__ */ new Map();
@@ -26404,17 +26522,17 @@ function combineParentChildClientJs(files2) {
26404
26522
  return result2;
26405
26523
  }
26406
26524
  function parseAndMerge(content2, importsBySource, otherImports, codeSections) {
26407
- const sourceFile = ts26.createSourceFile(
26525
+ const sourceFile = ts27.createSourceFile(
26408
26526
  "combine.js",
26409
26527
  content2,
26410
- ts26.ScriptTarget.Latest,
26528
+ ts27.ScriptTarget.Latest,
26411
26529
  /*setParentNodes*/
26412
26530
  false,
26413
- ts26.ScriptKind.JS
26531
+ ts27.ScriptKind.JS
26414
26532
  );
26415
26533
  const importSpans = [];
26416
26534
  for (const stmt of sourceFile.statements) {
26417
- if (!ts26.isImportDeclaration(stmt)) continue;
26535
+ if (!ts27.isImportDeclaration(stmt)) continue;
26418
26536
  const start2 = stmt.getStart(sourceFile);
26419
26537
  const end2 = stmt.getEnd();
26420
26538
  importSpans.push([start2, end2]);
@@ -26422,8 +26540,8 @@ function parseAndMerge(content2, importsBySource, otherImports, codeSections) {
26422
26540
  if (stmtText.includes("@bf-child:")) continue;
26423
26541
  const clause = stmt.importClause;
26424
26542
  const bindings = clause?.namedBindings;
26425
- const specifier = ts26.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
26426
- if (clause && !clause.name && bindings && ts26.isNamedImports(bindings)) {
26543
+ const specifier = ts27.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
26544
+ if (clause && !clause.name && bindings && ts27.isNamedImports(bindings)) {
26427
26545
  if (!importsBySource.has(specifier)) {
26428
26546
  importsBySource.set(specifier, /* @__PURE__ */ new Set());
26429
26547
  }
@@ -26598,7 +26716,7 @@ var init_loop_destructure = __esm({
26598
26716
  });
26599
26717
 
26600
26718
  // ../jsx/src/debug.ts
26601
- import ts27 from "typescript";
26719
+ import ts28 from "typescript";
26602
26720
  function buildComponentGraph(source, filePath, componentName) {
26603
26721
  const ctx2 = analyzeComponent(source, filePath, componentName);
26604
26722
  if (!ctx2.jsxReturn) {
@@ -26671,7 +26789,7 @@ function buildGraphFromIR(ir) {
26671
26789
  return propsObjectName ? exprReadsPropMember(expr, propsObjectName) : false;
26672
26790
  };
26673
26791
  const domBindings = [];
26674
- collectDomBindings(ir.root, domBindings, signalGetters, memoNames, void 0, /* @__PURE__ */ new Set(), exprReadsProp);
26792
+ collectDomBindings(ir.root, domBindings, signalGetters, memoNames, void 0, BindingScope.EMPTY, exprReadsProp);
26675
26793
  const signalConsumers = /* @__PURE__ */ new Map();
26676
26794
  for (const s of meta.signals) signalConsumers.set(s.getter, []);
26677
26795
  for (const memo of meta.memos) {
@@ -27638,14 +27756,19 @@ function inferWrapReasonForAttrLike(hasStringReactive, hasPropsRef, flags) {
27638
27756
  const decision = decideWrapFromAstFlags(flags);
27639
27757
  return decision.wrap ? decision.reason : void 0;
27640
27758
  }
27641
- function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag, loopParams = /* @__PURE__ */ new Set(), readsProp = () => false) {
27642
- const exprReadsLoopParam = (n) => loopParams.size > 0 && (n.origin?.freeRefs?.some((r2) => loopParams.has(r2.name)) ?? false);
27643
- const attrReadsLoopParam = (free) => loopParams.size > 0 && free !== void 0 && [...loopParams].some((p) => free.has(p));
27759
+ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag, scope = BindingScope.EMPTY, readsProp = () => false) {
27760
+ const boundNames = scope.valueBoundNames();
27761
+ const setSomeIn = (names, other) => {
27762
+ for (const n of names) if (other.has(n)) return true;
27763
+ return false;
27764
+ };
27765
+ const exprReadsLoopParam = (n) => boundNames.size > 0 && (n.origin?.freeRefs?.some((r2) => boundNames.has(r2.name)) ?? false);
27766
+ const attrReadsLoopParam = (free) => boundNames.size > 0 && free !== void 0 && setSomeIn(boundNames, free);
27644
27767
  switch (node.type) {
27645
27768
  case "element": {
27646
27769
  for (const attr of node.attrs) {
27647
27770
  if (attr.value.kind !== "expression" && attr.value.kind !== "template" && attr.value.kind !== "spread") continue;
27648
- if (attr.name === "key" && loopParams.size > 0) continue;
27771
+ if (attr.name === "key" && boundNames.size > 0) continue;
27649
27772
  const expr = attrValueToString2(attr.value);
27650
27773
  if (!expr) continue;
27651
27774
  const deps = extractReactiveDeps(expr, signalGetters, memoNames);
@@ -27680,7 +27803,7 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27680
27803
  });
27681
27804
  }
27682
27805
  for (const child of node.children) {
27683
- collectDomBindings(child, bindings, signalGetters, memoNames, node.tag, loopParams, readsProp);
27806
+ collectDomBindings(child, bindings, signalGetters, memoNames, node.tag, scope, readsProp);
27684
27807
  }
27685
27808
  break;
27686
27809
  }
@@ -27707,7 +27830,7 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27707
27830
  }
27708
27831
  case "conditional": {
27709
27832
  const decision = decideWrapFromAstFlags(node);
27710
- const loopReactive = loopParams.size > 0 && (node.origin?.freeRefs?.some((r2) => loopParams.has(r2.name)) ?? false);
27833
+ const loopReactive = boundNames.size > 0 && (node.origin?.freeRefs?.some((r2) => boundNames.has(r2.name)) ?? false);
27711
27834
  if ((decision.wrap || loopReactive) && node.slotId) {
27712
27835
  const deps = extractReactiveDeps(node.condition, signalGetters, memoNames);
27713
27836
  bindings.push({
@@ -27723,14 +27846,14 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27723
27846
  jsxPreview: `{${truncateExpr(node.condition)} ? ... : ...}`
27724
27847
  });
27725
27848
  }
27726
- collectDomBindings(node.whenTrue, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27727
- collectDomBindings(node.whenFalse, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27849
+ collectDomBindings(node.whenTrue, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27850
+ collectDomBindings(node.whenFalse, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27728
27851
  break;
27729
27852
  }
27730
27853
  case "loop": {
27731
27854
  if (node.slotId) {
27732
27855
  const deps = extractReactiveDeps(node.array, signalGetters, memoNames);
27733
- const loopReactive = loopParams.size > 0 && node.arrayFreeIdentifiers !== void 0 && [...loopParams].some((p) => node.arrayFreeIdentifiers.has(p));
27856
+ const loopReactive = boundNames.size > 0 && node.arrayFreeIdentifiers !== void 0 && setSomeIn(boundNames, node.arrayFreeIdentifiers);
27734
27857
  const isReactive = deps.length > 0 || node.callsReactiveGetters === true || loopReactive;
27735
27858
  const isFallback = !isReactive && node.hasFunctionCalls === true;
27736
27859
  if (isReactive || isFallback) {
@@ -27749,11 +27872,9 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27749
27872
  });
27750
27873
  }
27751
27874
  }
27752
- const childLoopParams = new Set(loopParams);
27753
- for (const p of extractLoopParamNames(node.param, node)) childLoopParams.add(p);
27754
- if (node.index) childLoopParams.add(node.index);
27875
+ const childScope = scope.enterLoopRow(node);
27755
27876
  for (const child of node.children) {
27756
- collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, childLoopParams, readsProp);
27877
+ collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, childScope, readsProp);
27757
27878
  }
27758
27879
  break;
27759
27880
  }
@@ -27783,21 +27904,21 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27783
27904
  }
27784
27905
  }
27785
27906
  for (const child of node.children) {
27786
- collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27907
+ collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27787
27908
  }
27788
27909
  break;
27789
27910
  }
27790
27911
  case "fragment":
27791
27912
  case "provider": {
27792
27913
  for (const child of node.children) {
27793
- collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27914
+ collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27794
27915
  }
27795
27916
  break;
27796
27917
  }
27797
27918
  case "if-statement": {
27798
- collectDomBindings(node.consequent, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27919
+ collectDomBindings(node.consequent, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27799
27920
  if (node.alternate) {
27800
- collectDomBindings(node.alternate, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27921
+ collectDomBindings(node.alternate, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27801
27922
  }
27802
27923
  break;
27803
27924
  }
@@ -27810,18 +27931,18 @@ function truncateExpr(expr, max = 40) {
27810
27931
  function exprReadsPropMember(expr, propsObjectName) {
27811
27932
  let sf;
27812
27933
  try {
27813
- sf = ts27.createSourceFile("__attr.tsx", `(${expr})`, ts27.ScriptTarget.Latest, true, ts27.ScriptKind.TSX);
27934
+ sf = ts28.createSourceFile("__attr.tsx", `(${expr})`, ts28.ScriptTarget.Latest, true, ts28.ScriptKind.TSX);
27814
27935
  } catch {
27815
27936
  return false;
27816
27937
  }
27817
27938
  let found = false;
27818
27939
  const visit3 = (n) => {
27819
27940
  if (found) return;
27820
- if (ts27.isPropertyAccessExpression(n) && ts27.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
27941
+ if (ts28.isPropertyAccessExpression(n) && ts28.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
27821
27942
  found = true;
27822
27943
  return;
27823
27944
  }
27824
- ts27.forEachChild(n, visit3);
27945
+ ts28.forEachChild(n, visit3);
27825
27946
  };
27826
27947
  visit3(sf);
27827
27948
  return found;
@@ -27895,11 +28016,12 @@ var init_debug = __esm({
27895
28016
  init_reactivity();
27896
28017
  init_utils();
27897
28018
  init_identifier_pattern();
28019
+ init_binding_scope();
27898
28020
  }
27899
28021
  });
27900
28022
 
27901
28023
  // ../jsx/src/profiler.ts
27902
- import ts28 from "typescript";
28024
+ import ts29 from "typescript";
27903
28025
  function buildStaticBudget(source, filePath, componentName, options2 = {}) {
27904
28026
  const threshold = options2.fanOutThreshold ?? DEFAULT_FANOUT_THRESHOLD;
27905
28027
  const program = createProgramForFile(source, filePath)?.program;
@@ -28154,14 +28276,14 @@ function joinProfilerEvents(events, index) {
28154
28276
  return { joined, unattributed, diagnostics };
28155
28277
  }
28156
28278
  function findUninstrumentedEffects(source, filePath, instrumentedLines) {
28157
- const sf = ts28.createSourceFile(filePath, source, ts28.ScriptTarget.Latest, true, ts28.ScriptKind.TSX);
28279
+ const sf = ts29.createSourceFile(filePath, source, ts29.ScriptTarget.Latest, true, ts29.ScriptKind.TSX);
28158
28280
  const out = [];
28159
28281
  const visit3 = (node) => {
28160
- if (ts28.isCallExpression(node) && ts28.isIdentifier(node.expression) && node.expression.text === "createEffect") {
28282
+ if (ts29.isCallExpression(node) && ts29.isIdentifier(node.expression) && node.expression.text === "createEffect") {
28161
28283
  const line = sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;
28162
28284
  if (!instrumentedLines.has(line)) out.push({ file: filePath, line });
28163
28285
  }
28164
- ts28.forEachChild(node, visit3);
28286
+ ts29.forEachChild(node, visit3);
28165
28287
  };
28166
28288
  visit3(sf);
28167
28289
  out.sort((a, b) => a.line - b.line);
@@ -28447,19 +28569,19 @@ function assessBatchSafety(args2) {
28447
28569
  const signalGetters = new Set(args2.graph.signals.map((s) => s.name));
28448
28570
  let sf;
28449
28571
  try {
28450
- sf = ts28.createSourceFile("__h.ts", `const __h = ${args2.handler}`, ts28.ScriptTarget.Latest, true);
28572
+ sf = ts29.createSourceFile("__h.ts", `const __h = ${args2.handler}`, ts29.ScriptTarget.Latest, true);
28451
28573
  } catch {
28452
28574
  return "unverified";
28453
28575
  }
28454
28576
  const calls = [];
28455
28577
  const visit3 = (node) => {
28456
- if (ts28.isCallExpression(node) && ts28.isIdentifier(node.expression)) {
28578
+ if (ts29.isCallExpression(node) && ts29.isIdentifier(node.expression)) {
28457
28579
  const name2 = node.expression.text;
28458
28580
  if (setters.has(name2)) calls.push({ pos: node.getStart(sf), kind: "write" });
28459
28581
  else if (D.has(name2) && node.arguments.length === 0) calls.push({ pos: node.getStart(sf), kind: "memoRead" });
28460
28582
  else if (!signalGetters.has(name2) && !memoNames.has(name2)) calls.push({ pos: node.getStart(sf), kind: "risky" });
28461
28583
  }
28462
- ts28.forEachChild(node, visit3);
28584
+ ts29.forEachChild(node, visit3);
28463
28585
  };
28464
28586
  visit3(sf);
28465
28587
  calls.sort((a, b) => a.pos - b.pos);
@@ -110123,7 +110245,7 @@ __export(scenario_driver_exports, {
110123
110245
  import { writeFileSync as writeFileSync9, mkdtempSync, rmSync, readFileSync as readFileSync19, existsSync as existsSync23, statSync as statSync3 } from "node:fs";
110124
110246
  import { join as join2, dirname as dirname4, resolve as resolve6 } from "node:path";
110125
110247
  import { tmpdir } from "node:os";
110126
- import ts29 from "typescript";
110248
+ import ts30 from "typescript";
110127
110249
  function externalRuntimeImport(clientJs) {
110128
110250
  const chunks = Array.isArray(clientJs) ? clientJs : [clientJs];
110129
110251
  for (const chunk of chunks) {
@@ -110193,11 +110315,11 @@ function resolveLocalFile(spec) {
110193
110315
  }
110194
110316
  function rewriteLocalImports(js, chunkPath, inlined) {
110195
110317
  const chunkDir = dirname4(chunkPath);
110196
- const sf = ts29.createSourceFile("chunk.mjs", js, ts29.ScriptTarget.Latest, false, ts29.ScriptKind.JS);
110318
+ const sf = ts30.createSourceFile("chunk.mjs", js, ts30.ScriptTarget.Latest, false, ts30.ScriptKind.JS);
110197
110319
  const edits = [];
110198
110320
  for (const stmt of sf.statements) {
110199
- if (!ts29.isImportDeclaration(stmt)) continue;
110200
- if (!ts29.isStringLiteral(stmt.moduleSpecifier)) continue;
110321
+ if (!ts30.isImportDeclaration(stmt)) continue;
110322
+ if (!ts30.isStringLiteral(stmt.moduleSpecifier)) continue;
110201
110323
  const spec = stmt.moduleSpecifier.text;
110202
110324
  if (!spec.startsWith(".")) continue;
110203
110325
  const resolved = resolveLocalFile(join2(chunkDir, spec.replace(/\.client\.js$/, "")));
@@ -110209,13 +110331,13 @@ function rewriteLocalImports(js, chunkPath, inlined) {
110209
110331
  const abs = resolve6(resolved);
110210
110332
  if (inlined.has(abs)) {
110211
110333
  const clause = stmt.importClause;
110212
- if (clause && (clause.name || clause.namedBindings && ts29.isNamespaceImport(clause.namedBindings))) {
110334
+ if (clause && (clause.name || clause.namedBindings && ts30.isNamespaceImport(clause.namedBindings))) {
110213
110335
  throw new Error(
110214
110336
  `"${spec}" (imported by ${chunkPath}) uses a default or namespace import of a sibling client file, which the dynamic scenario runner cannot bind after inlining that file into the run. Import its exports by name, or use the static budget (\`bf debug profile <component>\`), which needs no run.`
110215
110337
  );
110216
110338
  }
110217
110339
  const shims = [];
110218
- if (clause?.namedBindings && ts29.isNamedImports(clause.namedBindings)) {
110340
+ if (clause?.namedBindings && ts30.isNamedImports(clause.namedBindings)) {
110219
110341
  for (const el of clause.namedBindings.elements) {
110220
110342
  if (el.propertyName) shims.push(`var ${el.name.text} = ${el.propertyName.text}`);
110221
110343
  }