@barefootjs/cli 0.31.3 → 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 +1127 -915
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -2384,6 +2384,30 @@ var init_template_parts = __esm({
2384
2384
  }
2385
2385
  });
2386
2386
 
2387
+ // ../jsx/src/identifier-pattern.ts
2388
+ function withUnicodeFlag(flags) {
2389
+ return flags.includes("u") ? flags : `${flags}u`;
2390
+ }
2391
+ function escapeIdentifierForRegex(name2) {
2392
+ return name2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2393
+ }
2394
+ function identifierPattern(name2, flags = "") {
2395
+ const esc = escapeIdentifierForRegex(name2);
2396
+ return new RegExp(`${ID_BOUNDARY_BEFORE}${esc}${ID_BOUNDARY_AFTER}`, withUnicodeFlag(flags));
2397
+ }
2398
+ function identifierCallPattern(name2, flags = "") {
2399
+ const esc = escapeIdentifierForRegex(name2);
2400
+ return new RegExp(`${ID_BOUNDARY_BEFORE}${esc}\\s*\\(`, withUnicodeFlag(flags));
2401
+ }
2402
+ var ID_BOUNDARY_BEFORE, ID_BOUNDARY_AFTER;
2403
+ var init_identifier_pattern = __esm({
2404
+ "../jsx/src/identifier-pattern.ts"() {
2405
+ "use strict";
2406
+ ID_BOUNDARY_BEFORE = "(?<![\\p{ID_Continue}$])";
2407
+ ID_BOUNDARY_AFTER = "(?![\\p{ID_Continue}$])";
2408
+ }
2409
+ });
2410
+
2387
2411
  // ../jsx/src/scanner/js-scanner.ts
2388
2412
  import ts2 from "typescript";
2389
2413
  function* iterateJsTokens(text, start2 = 0, end2 = text.length) {
@@ -2914,9 +2938,6 @@ function inferDefaultValue(type2) {
2914
2938
  if (type2.kind === "object") return "{}";
2915
2939
  return "undefined";
2916
2940
  }
2917
- function escapeRegExp(s) {
2918
- return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2919
- }
2920
2941
  function freeIdsFromRefs(refs) {
2921
2942
  const out = /* @__PURE__ */ new Set();
2922
2943
  if (!refs) return out;
@@ -3031,15 +3052,15 @@ function wrapLoopParamAsAccessor(expr, paramName, bindings) {
3031
3052
  if (bindings && bindings.length > 0) {
3032
3053
  return rewriteLoopBindingRefs(expr, bindings, "__bfItem()");
3033
3054
  }
3034
- const re = new RegExp(`\\b${escapeRegExp(paramName)}\\b(?!\\s*\\()(?!-)`, "g");
3035
- return replaceInExprContexts(expr, re, `${paramName}()`);
3055
+ const re = new RegExp(`${ID_BOUNDARY_BEFORE}${escapeIdentifierForRegex(paramName)}(?!\\s*\\()(?!-)${ID_BOUNDARY_AFTER}`, "gu");
3056
+ return replaceInExprContexts(expr, re, () => `${paramName}()`);
3036
3057
  }
3037
3058
  function rewriteLoopBindingRefs(expr, bindings, accessor) {
3038
3059
  const byName = /* @__PURE__ */ new Map();
3039
3060
  for (const b of bindings) byName.set(b.name, b);
3040
3061
  const preprocessed = expandShorthandBindings(expr, new Set(byName.keys()));
3041
- const alt = bindings.map((b) => escapeRegExp(b.name)).join("|");
3042
- const re = new RegExp(`\\b(${alt})\\b`, "g");
3062
+ const alt = bindings.map((b) => escapeIdentifierForRegex(b.name)).join("|");
3063
+ const re = new RegExp(`${ID_BOUNDARY_BEFORE}(${alt})${ID_BOUNDARY_AFTER}`, "gu");
3043
3064
  return replaceInExprContexts(
3044
3065
  preprocessed,
3045
3066
  re,
@@ -3094,6 +3115,7 @@ var init_utils = __esm({
3094
3115
  "use strict";
3095
3116
  init_loop_chain();
3096
3117
  init_template_parts();
3118
+ init_identifier_pattern();
3097
3119
  init_js_scanner();
3098
3120
  init_src();
3099
3121
  PROPS_PARAM = "_p";
@@ -3341,7 +3363,7 @@ var init_walker = __esm({
3341
3363
 
3342
3364
  // ../jsx/src/ir-to-client-js/csr-substitute.ts
3343
3365
  import ts4 from "typescript";
3344
- function csrSubstitute(value2, env) {
3366
+ function csrSubstitute(value2, env, enclosingScope) {
3345
3367
  if (!value2 || value2.trim().length === 0) {
3346
3368
  return { rewritten: value2, freeIdentifiers: /* @__PURE__ */ new Set() };
3347
3369
  }
@@ -3349,14 +3371,14 @@ function csrSubstitute(value2, env) {
3349
3371
  let current = value2;
3350
3372
  let lastFreeIdentifiers = /* @__PURE__ */ new Set();
3351
3373
  for (let i = 0; i < maxIter; i++) {
3352
- const step = csrSubstituteOnce(current, env);
3374
+ const step = csrSubstituteOnce(current, env, enclosingScope);
3353
3375
  lastFreeIdentifiers = step.freeIdentifiers;
3354
3376
  if (step.rewritten === current) break;
3355
3377
  current = step.rewritten;
3356
3378
  }
3357
3379
  return { rewritten: current, freeIdentifiers: lastFreeIdentifiers };
3358
3380
  }
3359
- function csrSubstituteOnce(value2, env) {
3381
+ function csrSubstituteOnce(value2, env, enclosingScope) {
3360
3382
  if (!value2 || value2.trim().length === 0) {
3361
3383
  return { rewritten: value2, freeIdentifiers: /* @__PURE__ */ new Set() };
3362
3384
  }
@@ -3380,7 +3402,7 @@ function csrSubstituteOnce(value2, env) {
3380
3402
  for (let i = boundStack.length - 1; i >= 0; i--) {
3381
3403
  if (boundStack[i].has(name2)) return true;
3382
3404
  }
3383
- return false;
3405
+ return enclosingScope?.isBound(name2) ?? false;
3384
3406
  };
3385
3407
  const recordSubstitution = (start2, end2, sub2) => {
3386
3408
  splices.push({ start: start2 - OFFSET, end: end2 - OFFSET, text: `(${sub2.replacement})` });
@@ -3584,6 +3606,176 @@ var init_child_scope = __esm({
3584
3606
  }
3585
3607
  });
3586
3608
 
3609
+ // ../jsx/src/scope/binding-scope.ts
3610
+ var BindingScope;
3611
+ var init_binding_scope = __esm({
3612
+ "../jsx/src/scope/binding-scope.ts"() {
3613
+ "use strict";
3614
+ BindingScope = class _BindingScope {
3615
+ constructor(frames2) {
3616
+ this.frames = frames2;
3617
+ }
3618
+ static EMPTY = new _BindingScope([]);
3619
+ /**
3620
+ * Child scope with a new `'loop-row'` frame for one loop's per-item
3621
+ * bindings. Parent (`this`) is not mutated; the returned scope is a
3622
+ * NEW object with `frames = [newFrame, ...this.frames]`.
3623
+ *
3624
+ * Binding semantics mirror `jsx-to-ir.ts`'s `ctx.loopParams` add site
3625
+ * EXACTLY (verified against lines ~4320-4345 and the matching delete
3626
+ * site ~4695-4710 of `packages/jsx/src/jsx-to-ir.ts`):
3627
+ *
3628
+ * - When `loop.paramBindings` is non-empty (a destructured callback
3629
+ * param, e.g. `.map(({ id, name }) => ...)`), each `paramBindings[i].name`
3630
+ * is bound with source `'destructure'` and the raw `param` text
3631
+ * (which for a destructured callback holds the ORIGINAL pattern
3632
+ * source, e.g. `"{ id, name }"`, not a usable identifier) is NOT
3633
+ * bound. This matches `jsx-to-ir.ts`:
3634
+ * `if (paramBindings) { for (const b of paramBindings) ctx.loopParams.add(b.name) }`
3635
+ * — the `else` branch (`ctx.loopParams.add(param)`) is skipped
3636
+ * entirely when `paramBindings` is present.
3637
+ * - Otherwise (a plain identifier param, e.g. `.map(item => ...)`),
3638
+ * `param` itself is bound with source `'item'`.
3639
+ * - `index` (the second callback param, e.g. `.map((item, i) => ...)`)
3640
+ * is bound with source `'index'` when non-null/non-undefined.
3641
+ * - Every name in `preamble.declaredNames` (a `.map()` callback's
3642
+ * pre-return `const`/`let`/`function` locals, #2447) is bound with
3643
+ * source `'preamble'`.
3644
+ *
3645
+ * NOTE on a sibling mechanism this method does NOT mirror:
3646
+ * `adapters/loop-bound-names.ts`'s `collectLoopBoundNames` adds BOTH
3647
+ * `node.param` AND every `paramBindings[i].name` unconditionally
3648
+ * (never skipping `param` in the destructured case) — a deliberately
3649
+ * coarser, over-inclusive collection used only to subtract names from
3650
+ * a flat string-typing Set (safe to over-exclude there). This method
3651
+ * follows the precise `jsx-to-ir.ts` `ctx.loopParams` semantics, since
3652
+ * that is the mechanism actually doing scope-shadowed name RESOLUTION
3653
+ * (the behavior `BindingScope` replaces), not coarse exclusion.
3654
+ */
3655
+ enterLoopRow(loop) {
3656
+ const bindings = /* @__PURE__ */ new Map();
3657
+ if (loop.paramBindings && loop.paramBindings.length > 0) {
3658
+ for (const b of loop.paramBindings) bindings.set(b.name, { source: "destructure" });
3659
+ } else {
3660
+ bindings.set(loop.param, { source: "item" });
3661
+ }
3662
+ if (loop.index != null) bindings.set(loop.index, { source: "index" });
3663
+ for (const name2 of loop.preamble?.declaredNames ?? []) bindings.set(name2, { source: "preamble" });
3664
+ const frame = { kind: "loop-row", bindings };
3665
+ return new _BindingScope([frame, ...this.frames]);
3666
+ }
3667
+ /**
3668
+ * Child scope with a new `'callback'` frame binding `params` (a filter
3669
+ * predicate's `x`, a sort comparator's `(a, b)`, or a nested arrow's
3670
+ * parameter list) with source `'param'`. Parent is not mutated.
3671
+ */
3672
+ enterCallback(params) {
3673
+ const bindings = /* @__PURE__ */ new Map();
3674
+ for (const name2 of params) bindings.set(name2, { source: "param" });
3675
+ const frame = { kind: "callback", bindings };
3676
+ return new _BindingScope([frame, ...this.frames]);
3677
+ }
3678
+ /** Innermost-first membership check across every frame in the stack. */
3679
+ isBound(name2) {
3680
+ for (const frame of this.frames) {
3681
+ if (frame.bindings.has(name2)) return true;
3682
+ }
3683
+ return false;
3684
+ }
3685
+ /**
3686
+ * Resolves `name` against the frame stack innermost-first. `depth 0`
3687
+ * means the innermost (most recently entered) frame; `null` when `name`
3688
+ * is not bound in any frame.
3689
+ */
3690
+ lookup(name2) {
3691
+ for (let depth = 0; depth < this.frames.length; depth++) {
3692
+ const frame = this.frames[depth];
3693
+ const binding = frame.bindings.get(name2);
3694
+ if (binding) return { depth, frame, binding };
3695
+ }
3696
+ return null;
3697
+ }
3698
+ /**
3699
+ * Union of every frame's bound names (every `ScopeBindingSource`), for
3700
+ * migration interop with legacy `Set<string>`-shaped consumers (e.g.
3701
+ * `collectLoopBoundNames`'s return type) as later stages migrate them
3702
+ * onto `BindingScope`.
3703
+ *
3704
+ * This is the SHADOW-GUARD query — see {@link valueBoundNames} for the
3705
+ * other consumer class and why the two must not be conflated.
3706
+ */
3707
+ boundNames() {
3708
+ if (this.boundNamesCache) return this.boundNamesCache;
3709
+ const names = /* @__PURE__ */ new Set();
3710
+ for (const frame of this.frames) {
3711
+ for (const name2 of frame.bindings.keys()) names.add(name2);
3712
+ }
3713
+ this.boundNamesCache = names;
3714
+ return names;
3715
+ }
3716
+ // Both name queries are hot (shadow guards, slot/reactivity classifiers,
3717
+ // binding-env memo keying) and the scope is immutable, so each computes
3718
+ // once per instance. Callers receive the cached set as ReadonlySet —
3719
+ // never mutate it.
3720
+ boundNamesCache;
3721
+ valueBoundNamesCache;
3722
+ /**
3723
+ * Union of names bound via `'item'`/`'index'`/`'destructure'` sources
3724
+ * only — the loop row's own per-item identity — excluding `'preamble'`
3725
+ * (a `.map()` callback's pre-return `const`/`let`/`function` locals,
3726
+ * #2447) and `'param'` (an `enterCallback` frame's filter/sort/nested-
3727
+ * arrow parameters).
3728
+ *
3729
+ * `BindingScope` has exactly two consumer classes, and conflating them
3730
+ * is the #2482 Stage 1a Commit 2 regression this split exists to
3731
+ * prevent (a `ctx.scope`-wide preamble merge flipped `tag-cloud` and
3732
+ * `preamble-cells` conformance fixtures before this method existed):
3733
+ *
3734
+ * - SHADOW GUARDS (`tryResolveTemplateSpanFromConst`,
3735
+ * `tryResolveIdentifierAsTemplateLiteral`, `rewriteBarePropRefs`
3736
+ * in `jsx-to-ir.ts`) ask "is this name resolved to SOMETHING in
3737
+ * this scope, so an outer const/prop of the same name must not be
3738
+ * substituted here at this transform position" — every source
3739
+ * qualifies, including a preamble local shadowing a module const.
3740
+ * These call `isBound` / `boundNames()`.
3741
+ * - REACTIVITY / SLOT-ID CLASSIFIERS (`referencesLoopParam`,
3742
+ * `hasReactiveAttributes`, and the `BindingEnvironment.loopValueBoundNames`
3743
+ * feed built from `makeBindingEnv`, all in `jsx-to-ir.ts`) ask
3744
+ * "does this expression read a value that changes per row and so
3745
+ * needs its own patchable slot" — a preamble local already gets
3746
+ * ITS OWN dedicated slot/region-patch machinery
3747
+ * (`preambleRegions` / `markPreambleAttrSlots`, #2447), so folding
3748
+ * it into this classification double-counts it. Worse: widening a
3749
+ * text child's `reactive` flag this way is read by
3750
+ * `hasDynamicContent` to decide whether the loop ROW's own root
3751
+ * element needs a slot — an unrelated, narrower decision that must
3752
+ * not move just because a preamble local is now scope-visible.
3753
+ * These call `valueBoundNames()`.
3754
+ */
3755
+ valueBoundNames() {
3756
+ if (this.valueBoundNamesCache) return this.valueBoundNamesCache;
3757
+ const names = /* @__PURE__ */ new Set();
3758
+ for (const frame of this.frames) {
3759
+ for (const [name2, binding] of frame.bindings) {
3760
+ if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
3761
+ names.add(name2);
3762
+ }
3763
+ }
3764
+ }
3765
+ this.valueBoundNamesCache = names;
3766
+ return names;
3767
+ }
3768
+ /**
3769
+ * Drop-in for `resolveStaticLoopSource`'s `opts.isNameShadowed`
3770
+ * (`packages/jsx/src/static-literal.ts:112-128`).
3771
+ */
3772
+ asShadowPredicate() {
3773
+ return (name2) => this.isBound(name2);
3774
+ }
3775
+ };
3776
+ }
3777
+ });
3778
+
3587
3779
  // ../jsx/src/ir-to-client-js/html-template.ts
3588
3780
  function createStringProtector() {
3589
3781
  const strings = [];
@@ -4705,7 +4897,7 @@ function generateCsrTemplateWithOpts(node, opts) {
4705
4897
  const transformExpr = (expr, templateExpr) => {
4706
4898
  const source = templateExpr ?? expr;
4707
4899
  if (!source) return source;
4708
- const { rewritten, freeIdentifiers: freeIdentifiers2 } = csrSubstitute(source, env);
4900
+ const { rewritten, freeIdentifiers: freeIdentifiers2 } = csrSubstitute(source, env, opts.scope);
4709
4901
  if (unsafeLocalNames && unsafeLocalNames.size > 0 && setIntersects(freeIdentifiers2, unsafeLocalNames)) {
4710
4902
  return UNSAFE_TEMPLATE_EXPR;
4711
4903
  }
@@ -4838,13 +5030,8 @@ function generateCsrTemplateWithOpts(node, opts) {
4838
5030
  return `\${renderChild('${nameForRegistryRef(node.name)}', ${propsExpr}${keyArg || (slotArg ? ", undefined" : "")}${slotArg})}`;
4839
5031
  }
4840
5032
  case "loop": {
4841
- const boundHere = new Set(opts.loopBoundNames ?? []);
4842
- if (node.paramBindings && node.paramBindings.length > 0) {
4843
- for (const b of node.paramBindings) boundHere.add(b.name);
4844
- } else if (!node.param.startsWith("[") && !node.param.startsWith("{")) {
4845
- boundHere.add(node.param);
4846
- }
4847
- if (node.index) boundHere.add(node.index);
5033
+ const childScope = (opts.scope ?? BindingScope.EMPTY).enterLoopRow(node);
5034
+ const boundHere = childScope.boundNames();
4848
5035
  const childEnv = {
4849
5036
  ...env,
4850
5037
  substitutions: new Map([...env.substitutions].filter(([name2]) => !boundHere.has(name2)))
@@ -4853,7 +5040,7 @@ function generateCsrTemplateWithOpts(node, opts) {
4853
5040
  ...opts,
4854
5041
  loopDepth: loopDepth + 1,
4855
5042
  inHoistedChildren: false,
4856
- loopBoundNames: boundHere,
5043
+ scope: childScope,
4857
5044
  csrEnv: childEnv
4858
5045
  });
4859
5046
  let childTemplate = node.children.map(recurseInLoopBody).join("");
@@ -4923,6 +5110,7 @@ var init_html_template = __esm({
4923
5110
  init_src();
4924
5111
  init_loop_chain();
4925
5112
  init_child_scope();
5113
+ init_binding_scope();
4926
5114
  VOID_ELEMENTS = /* @__PURE__ */ new Set([
4927
5115
  "area",
4928
5116
  "base",
@@ -9216,6 +9404,7 @@ var init_types = __esm({
9216
9404
  });
9217
9405
 
9218
9406
  // ../jsx/src/module-exports.ts
9407
+ import ts10 from "typescript";
9219
9408
  function generateModuleExports(ir, extraInlineExported = /* @__PURE__ */ new Set(), rewriteRelativeImport, options2) {
9220
9409
  const lines = [];
9221
9410
  for (const constant of options2?.skipValueDeclarations ? [] : ir.metadata.localConstants) {
@@ -9286,7 +9475,7 @@ function findReachableNames(primaryRefs, declarations) {
9286
9475
  const reachable = /* @__PURE__ */ new Set();
9287
9476
  const queue = [];
9288
9477
  for (const name2 of allNames) {
9289
- if (new RegExp(`\\b${name2}\\b`).test(primaryRefs)) {
9478
+ if (identifierPattern(name2).test(primaryRefs)) {
9290
9479
  reachable.add(name2);
9291
9480
  queue.push(name2);
9292
9481
  }
@@ -9295,7 +9484,7 @@ function findReachableNames(primaryRefs, declarations) {
9295
9484
  const current = queue.shift();
9296
9485
  const body2 = bodyMap.get(current) || "";
9297
9486
  for (const name2 of allNames) {
9298
- if (!reachable.has(name2) && new RegExp(`\\b${name2}\\b`).test(body2)) {
9487
+ if (!reachable.has(name2) && identifierPattern(name2).test(body2)) {
9299
9488
  reachable.add(name2);
9300
9489
  queue.push(name2);
9301
9490
  }
@@ -9303,6 +9492,52 @@ function findReachableNames(primaryRefs, declarations) {
9303
9492
  }
9304
9493
  return reachable;
9305
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
+ }
9306
9541
  function extractFunctionParams(value2) {
9307
9542
  const arrowMatch = value2.match(/^(?:async\s*)?\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/);
9308
9543
  if (arrowMatch) {
@@ -9321,6 +9556,7 @@ function extractFunctionParams(value2) {
9321
9556
  var init_module_exports = __esm({
9322
9557
  "../jsx/src/module-exports.ts"() {
9323
9558
  "use strict";
9559
+ init_identifier_pattern();
9324
9560
  }
9325
9561
  });
9326
9562
 
@@ -9354,7 +9590,7 @@ var init_builtins = __esm({
9354
9590
  });
9355
9591
 
9356
9592
  // ../jsx/src/reactivity-checker.ts
9357
- import ts10 from "typescript";
9593
+ import ts11 from "typescript";
9358
9594
  function queryType(checker, node) {
9359
9595
  incrementCounter("typeCheckerQueries");
9360
9596
  return checker.getTypeAtLocation(node);
@@ -9370,7 +9606,7 @@ function safeGetText(node) {
9370
9606
  }
9371
9607
  }
9372
9608
  function analyze(node, checker) {
9373
- if (ts10.isPropertyAccessExpression(node)) {
9609
+ if (ts11.isPropertyAccessExpression(node)) {
9374
9610
  try {
9375
9611
  const type2 = queryType(checker, node);
9376
9612
  if (isReactiveType(type2)) {
@@ -9395,7 +9631,7 @@ function analyze(node, checker) {
9395
9631
  }
9396
9632
  return NOT_REACTIVE;
9397
9633
  }
9398
- if (ts10.isIdentifier(node)) {
9634
+ if (ts11.isIdentifier(node)) {
9399
9635
  try {
9400
9636
  const type2 = queryType(checker, node);
9401
9637
  if (isReactiveType(type2)) {
@@ -9408,7 +9644,7 @@ function analyze(node, checker) {
9408
9644
  }
9409
9645
  return NOT_REACTIVE;
9410
9646
  }
9411
- if (ts10.isCallExpression(node)) {
9647
+ if (ts11.isCallExpression(node)) {
9412
9648
  try {
9413
9649
  const calleeType = queryType(checker, node.expression);
9414
9650
  if (isReactiveType(calleeType)) {
@@ -9422,7 +9658,7 @@ function analyze(node, checker) {
9422
9658
  }
9423
9659
  let foundChild;
9424
9660
  let foundChildText = "";
9425
- ts10.forEachChild(node, (child) => {
9661
+ ts11.forEachChild(node, (child) => {
9426
9662
  if (foundChild?.isReactive) return;
9427
9663
  const result2 = analyze(child, checker);
9428
9664
  if (result2.isReactive) {
@@ -9459,7 +9695,7 @@ var init_reactivity_checker = __esm({
9459
9695
  });
9460
9696
 
9461
9697
  // ../jsx/src/free-refs.ts
9462
- import ts11 from "typescript";
9698
+ import ts12 from "typescript";
9463
9699
  function buildBindingMap(env) {
9464
9700
  const cached = _bindingMapCache.get(env);
9465
9701
  if (cached) return cached;
@@ -9493,8 +9729,8 @@ function buildBindingMap(env) {
9493
9729
  for (const m of env.memos) {
9494
9730
  map.set(m.name, "memo-getter");
9495
9731
  }
9496
- if (env.loopParams) {
9497
- 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");
9498
9734
  }
9499
9735
  _bindingMapCache.set(env, map);
9500
9736
  return map;
@@ -9523,17 +9759,17 @@ function defaultBindingScope(kind2) {
9523
9759
  function collectIdentifiers2(node) {
9524
9760
  const out = [];
9525
9761
  const visit3 = (n, parent2) => {
9526
- if (ts11.isIdentifier(n)) {
9527
- if (parent2 && ts11.isPropertyAccessExpression(parent2) && parent2.name === n) return;
9528
- if (parent2 && ts11.isPropertyAssignment(parent2) && parent2.name === n) return;
9529
- 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) {
9530
9766
  return;
9531
9767
  }
9532
- if (parent2 && ts11.isJsxAttribute(parent2) && parent2.name === n) return;
9768
+ if (parent2 && ts12.isJsxAttribute(parent2) && parent2.name === n) return;
9533
9769
  out.push(n);
9534
9770
  return;
9535
9771
  }
9536
- ts11.forEachChild(n, (child) => visit3(child, n));
9772
+ ts12.forEachChild(n, (child) => visit3(child, n));
9537
9773
  };
9538
9774
  visit3(node);
9539
9775
  return out;
@@ -9542,7 +9778,7 @@ function collectReactiveBrandRefs(node, checker) {
9542
9778
  const out = [];
9543
9779
  const seen = /* @__PURE__ */ new Set();
9544
9780
  const visit3 = (n) => {
9545
- if (ts11.isPropertyAccessExpression(n)) {
9781
+ if (ts12.isPropertyAccessExpression(n)) {
9546
9782
  try {
9547
9783
  const type2 = checker.getTypeAtLocation(n);
9548
9784
  if (isReactiveType(type2)) {
@@ -9560,7 +9796,7 @@ function collectReactiveBrandRefs(node, checker) {
9560
9796
  incrementCounter("freeRefsTypeLookupFailures");
9561
9797
  }
9562
9798
  }
9563
- ts11.forEachChild(n, visit3);
9799
+ ts12.forEachChild(n, visit3);
9564
9800
  };
9565
9801
  visit3(node);
9566
9802
  return out;
@@ -9568,17 +9804,17 @@ function collectReactiveBrandRefs(node, checker) {
9568
9804
  function resolveConstantInitializerRefs(c, env, visited) {
9569
9805
  if (c.value === void 0) return [];
9570
9806
  if (c.containsArrow) return [];
9571
- const sf = ts11.createSourceFile(
9807
+ const sf = ts12.createSourceFile(
9572
9808
  "__const_init.ts",
9573
9809
  `const __probe = (${c.value});`,
9574
- ts11.ScriptTarget.Latest,
9810
+ ts12.ScriptTarget.Latest,
9575
9811
  true
9576
9812
  );
9577
9813
  const stmt = sf.statements[0];
9578
- if (!stmt || !ts11.isVariableStatement(stmt)) return [];
9814
+ if (!stmt || !ts12.isVariableStatement(stmt)) return [];
9579
9815
  const decl = stmt.declarationList.declarations[0];
9580
9816
  if (!decl || !decl.initializer) return [];
9581
- const expr = ts11.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
9817
+ const expr = ts12.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
9582
9818
  return resolveFreeRefsInternal(expr, env, visited);
9583
9819
  }
9584
9820
  function resolveFreeRefsInternal(node, env, visited) {
@@ -9590,7 +9826,7 @@ function resolveFreeRefsInternal(node, env, visited) {
9590
9826
  const name2 = ident.text;
9591
9827
  if (env.propsObjectName === name2) {
9592
9828
  const parent2 = ident.parent;
9593
- 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") {
9594
9830
  continue;
9595
9831
  }
9596
9832
  }
@@ -9984,178 +10220,8 @@ var init_to_locale_date_lowering = __esm({
9984
10220
  }
9985
10221
  });
9986
10222
 
9987
- // ../jsx/src/scope/binding-scope.ts
9988
- var BindingScope;
9989
- var init_binding_scope = __esm({
9990
- "../jsx/src/scope/binding-scope.ts"() {
9991
- "use strict";
9992
- BindingScope = class _BindingScope {
9993
- constructor(frames2) {
9994
- this.frames = frames2;
9995
- }
9996
- static EMPTY = new _BindingScope([]);
9997
- /**
9998
- * Child scope with a new `'loop-row'` frame for one loop's per-item
9999
- * bindings. Parent (`this`) is not mutated; the returned scope is a
10000
- * NEW object with `frames = [newFrame, ...this.frames]`.
10001
- *
10002
- * Binding semantics mirror `jsx-to-ir.ts`'s `ctx.loopParams` add site
10003
- * EXACTLY (verified against lines ~4320-4345 and the matching delete
10004
- * site ~4695-4710 of `packages/jsx/src/jsx-to-ir.ts`):
10005
- *
10006
- * - When `loop.paramBindings` is non-empty (a destructured callback
10007
- * param, e.g. `.map(({ id, name }) => ...)`), each `paramBindings[i].name`
10008
- * is bound with source `'destructure'` and the raw `param` text
10009
- * (which for a destructured callback holds the ORIGINAL pattern
10010
- * source, e.g. `"{ id, name }"`, not a usable identifier) is NOT
10011
- * bound. This matches `jsx-to-ir.ts`:
10012
- * `if (paramBindings) { for (const b of paramBindings) ctx.loopParams.add(b.name) }`
10013
- * — the `else` branch (`ctx.loopParams.add(param)`) is skipped
10014
- * entirely when `paramBindings` is present.
10015
- * - Otherwise (a plain identifier param, e.g. `.map(item => ...)`),
10016
- * `param` itself is bound with source `'item'`.
10017
- * - `index` (the second callback param, e.g. `.map((item, i) => ...)`)
10018
- * is bound with source `'index'` when non-null/non-undefined.
10019
- * - Every name in `preamble.declaredNames` (a `.map()` callback's
10020
- * pre-return `const`/`let`/`function` locals, #2447) is bound with
10021
- * source `'preamble'`.
10022
- *
10023
- * NOTE on a sibling mechanism this method does NOT mirror:
10024
- * `adapters/loop-bound-names.ts`'s `collectLoopBoundNames` adds BOTH
10025
- * `node.param` AND every `paramBindings[i].name` unconditionally
10026
- * (never skipping `param` in the destructured case) — a deliberately
10027
- * coarser, over-inclusive collection used only to subtract names from
10028
- * a flat string-typing Set (safe to over-exclude there). This method
10029
- * follows the precise `jsx-to-ir.ts` `ctx.loopParams` semantics, since
10030
- * that is the mechanism actually doing scope-shadowed name RESOLUTION
10031
- * (the behavior `BindingScope` replaces), not coarse exclusion.
10032
- */
10033
- enterLoopRow(loop) {
10034
- const bindings = /* @__PURE__ */ new Map();
10035
- if (loop.paramBindings && loop.paramBindings.length > 0) {
10036
- for (const b of loop.paramBindings) bindings.set(b.name, { source: "destructure" });
10037
- } else {
10038
- bindings.set(loop.param, { source: "item" });
10039
- }
10040
- if (loop.index != null) bindings.set(loop.index, { source: "index" });
10041
- for (const name2 of loop.preamble?.declaredNames ?? []) bindings.set(name2, { source: "preamble" });
10042
- const frame = { kind: "loop-row", bindings };
10043
- return new _BindingScope([frame, ...this.frames]);
10044
- }
10045
- /**
10046
- * Child scope with a new `'callback'` frame binding `params` (a filter
10047
- * predicate's `x`, a sort comparator's `(a, b)`, or a nested arrow's
10048
- * parameter list) with source `'param'`. Parent is not mutated.
10049
- */
10050
- enterCallback(params) {
10051
- const bindings = /* @__PURE__ */ new Map();
10052
- for (const name2 of params) bindings.set(name2, { source: "param" });
10053
- const frame = { kind: "callback", bindings };
10054
- return new _BindingScope([frame, ...this.frames]);
10055
- }
10056
- /** Innermost-first membership check across every frame in the stack. */
10057
- isBound(name2) {
10058
- for (const frame of this.frames) {
10059
- if (frame.bindings.has(name2)) return true;
10060
- }
10061
- return false;
10062
- }
10063
- /**
10064
- * Resolves `name` against the frame stack innermost-first. `depth 0`
10065
- * means the innermost (most recently entered) frame; `null` when `name`
10066
- * is not bound in any frame.
10067
- */
10068
- lookup(name2) {
10069
- for (let depth = 0; depth < this.frames.length; depth++) {
10070
- const frame = this.frames[depth];
10071
- const binding = frame.bindings.get(name2);
10072
- if (binding) return { depth, frame, binding };
10073
- }
10074
- return null;
10075
- }
10076
- /**
10077
- * Union of every frame's bound names (every `ScopeBindingSource`), for
10078
- * migration interop with legacy `Set<string>`-shaped consumers (e.g.
10079
- * `collectLoopBoundNames`'s return type) as later stages migrate them
10080
- * onto `BindingScope`.
10081
- *
10082
- * This is the SHADOW-GUARD query — see {@link valueBoundNames} for the
10083
- * other consumer class and why the two must not be conflated.
10084
- */
10085
- boundNames() {
10086
- if (this.boundNamesCache) return this.boundNamesCache;
10087
- const names = /* @__PURE__ */ new Set();
10088
- for (const frame of this.frames) {
10089
- for (const name2 of frame.bindings.keys()) names.add(name2);
10090
- }
10091
- this.boundNamesCache = names;
10092
- return names;
10093
- }
10094
- // Both name queries are hot (shadow guards, slot/reactivity classifiers,
10095
- // binding-env memo keying) and the scope is immutable, so each computes
10096
- // once per instance. Callers receive the cached set as ReadonlySet —
10097
- // never mutate it.
10098
- boundNamesCache;
10099
- valueBoundNamesCache;
10100
- /**
10101
- * Union of names bound via `'item'`/`'index'`/`'destructure'` sources
10102
- * only — the loop row's own per-item identity — excluding `'preamble'`
10103
- * (a `.map()` callback's pre-return `const`/`let`/`function` locals,
10104
- * #2447) and `'param'` (an `enterCallback` frame's filter/sort/nested-
10105
- * arrow parameters).
10106
- *
10107
- * `BindingScope` has exactly two consumer classes, and conflating them
10108
- * is the #2482 Stage 1a Commit 2 regression this split exists to
10109
- * prevent (a `ctx.scope`-wide preamble merge flipped `tag-cloud` and
10110
- * `preamble-cells` conformance fixtures before this method existed):
10111
- *
10112
- * - SHADOW GUARDS (`tryResolveTemplateSpanFromConst`,
10113
- * `tryResolveIdentifierAsTemplateLiteral`, `rewriteBarePropRefs`
10114
- * in `jsx-to-ir.ts`) ask "is this name resolved to SOMETHING in
10115
- * this scope, so an outer const/prop of the same name must not be
10116
- * substituted here at this transform position" — every source
10117
- * qualifies, including a preamble local shadowing a module const.
10118
- * These call `isBound` / `boundNames()`.
10119
- * - REACTIVITY / SLOT-ID CLASSIFIERS (`referencesLoopParam`,
10120
- * `hasReactiveAttributes`, and the `BindingEnvironment.loopParams`
10121
- * feed built from `makeBindingEnv`, all in `jsx-to-ir.ts`) ask
10122
- * "does this expression read a value that changes per row and so
10123
- * needs its own patchable slot" — a preamble local already gets
10124
- * ITS OWN dedicated slot/region-patch machinery
10125
- * (`preambleRegions` / `markPreambleAttrSlots`, #2447), so folding
10126
- * it into this classification double-counts it. Worse: widening a
10127
- * text child's `reactive` flag this way is read by
10128
- * `hasDynamicContent` to decide whether the loop ROW's own root
10129
- * element needs a slot — an unrelated, narrower decision that must
10130
- * not move just because a preamble local is now scope-visible.
10131
- * These call `valueBoundNames()`.
10132
- */
10133
- valueBoundNames() {
10134
- if (this.valueBoundNamesCache) return this.valueBoundNamesCache;
10135
- const names = /* @__PURE__ */ new Set();
10136
- for (const frame of this.frames) {
10137
- for (const [name2, binding] of frame.bindings) {
10138
- if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
10139
- names.add(name2);
10140
- }
10141
- }
10142
- }
10143
- this.valueBoundNamesCache = names;
10144
- return names;
10145
- }
10146
- /**
10147
- * Drop-in for `resolveStaticLoopSource`'s `opts.isNameShadowed`
10148
- * (`packages/jsx/src/static-literal.ts:112-128`).
10149
- */
10150
- asShadowPredicate() {
10151
- return (name2) => this.isBound(name2);
10152
- }
10153
- };
10154
- }
10155
- });
10156
-
10157
10223
  // ../jsx/src/jsx-to-ir.ts
10158
- import ts12 from "typescript";
10224
+ import ts13 from "typescript";
10159
10225
  function hasLeadingClientDirective(expr, sourceFile) {
10160
10226
  const trivia = sourceFile.text.slice(expr.pos, expr.getStart(sourceFile));
10161
10227
  BLOCK_COMMENT_RE2.lastIndex = 0;
@@ -10176,13 +10242,13 @@ function exprCallsReactiveGetters(expr, ctx2) {
10176
10242
  let found = false;
10177
10243
  function visit3(n) {
10178
10244
  if (found) return;
10179
- if (ts12.isCallExpression(n) && ts12.isIdentifier(n.expression)) {
10245
+ if (ts13.isCallExpression(n) && ts13.isIdentifier(n.expression)) {
10180
10246
  if (names.has(n.expression.text)) {
10181
10247
  found = true;
10182
10248
  return;
10183
10249
  }
10184
10250
  }
10185
- ts12.forEachChild(n, visit3);
10251
+ ts13.forEachChild(n, visit3);
10186
10252
  }
10187
10253
  visit3(expr);
10188
10254
  return found;
@@ -10205,11 +10271,11 @@ function exprReferencesModuleClientSignal(expr, ctx2) {
10205
10271
  let found = false;
10206
10272
  function visit3(n) {
10207
10273
  if (found) return;
10208
- 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)) {
10209
10275
  found = true;
10210
10276
  return;
10211
10277
  }
10212
- ts12.forEachChild(n, visit3);
10278
+ ts13.forEachChild(n, visit3);
10213
10279
  }
10214
10280
  visit3(expr);
10215
10281
  return found;
@@ -10218,11 +10284,11 @@ function exprHasFunctionCalls(expr) {
10218
10284
  let found = false;
10219
10285
  function visit3(n) {
10220
10286
  if (found) return;
10221
- if (ts12.isCallExpression(n)) {
10287
+ if (ts13.isCallExpression(n)) {
10222
10288
  found = true;
10223
10289
  return;
10224
10290
  }
10225
- ts12.forEachChild(n, visit3);
10291
+ ts13.forEachChild(n, visit3);
10226
10292
  }
10227
10293
  visit3(expr);
10228
10294
  return found;
@@ -10258,10 +10324,10 @@ function lowerDateCalls(text, expr, ctx2) {
10258
10324
  if (!matcher) return text;
10259
10325
  const candidates = [];
10260
10326
  function visit3(n) {
10261
- 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)) {
10262
10328
  candidates.push(n);
10263
10329
  }
10264
- ts12.forEachChild(n, visit3);
10330
+ ts13.forEachChild(n, visit3);
10265
10331
  }
10266
10332
  visit3(expr);
10267
10333
  if (candidates.length === 0) return text;
@@ -10283,10 +10349,10 @@ function lowerToLocaleDateCalls(text, expr, ctx2) {
10283
10349
  if (!matcher) return text;
10284
10350
  const candidates = [];
10285
10351
  function visit3(n) {
10286
- 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") {
10287
10353
  candidates.push(n);
10288
10354
  }
10289
- ts12.forEachChild(n, visit3);
10355
+ ts13.forEachChild(n, visit3);
10290
10356
  }
10291
10357
  visit3(expr);
10292
10358
  if (candidates.length === 0) return text;
@@ -10339,10 +10405,10 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx2) {
10339
10405
  if (!propDepsMap || !branchVars || propDepsMap.size === 0) return void 0;
10340
10406
  let acc;
10341
10407
  function visit3(n, parent2) {
10342
- if (ts12.isIdentifier(n) && propDepsMap.has(n.text)) {
10343
- const isObjectKey = parent2 && ts12.isPropertyAssignment(parent2) && parent2.name === n;
10344
- const isShorthand = parent2 && ts12.isShorthandPropertyAssignment(parent2) && parent2.name === n;
10345
- 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;
10346
10412
  if (!isObjectKey && !isShorthand && !isAccessName) {
10347
10413
  const deps = propDepsMap.get(n.text);
10348
10414
  if (deps && deps.size > 0) {
@@ -10351,7 +10417,7 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx2) {
10351
10417
  }
10352
10418
  }
10353
10419
  }
10354
- ts12.forEachChild(n, (child) => visit3(child, n));
10420
+ ts13.forEachChild(n, (child) => visit3(child, n));
10355
10421
  }
10356
10422
  visit3(node);
10357
10423
  return acc;
@@ -10398,17 +10464,17 @@ function createTransformContext(analyzer) {
10398
10464
  patterns: {
10399
10465
  signals: analyzer.signals.map((s) => ({
10400
10466
  getter: s.getter,
10401
- pattern: new RegExp(`\\b${s.getter}\\s*\\(`)
10467
+ pattern: identifierCallPattern(s.getter)
10402
10468
  })),
10403
10469
  memos: analyzer.memos.map((m) => ({
10404
10470
  name: m.name,
10405
- pattern: new RegExp(`\\b${m.name}\\s*\\(`)
10471
+ pattern: identifierCallPattern(m.name)
10406
10472
  })),
10407
- props: analyzer.propsParams.filter((p) => p.name !== "children").map((p) => ({ name: p.name, pattern: new RegExp(`\\b${p.name}\\b`) })),
10473
+ props: analyzer.propsParams.filter((p) => p.name !== "children").map((p) => ({ name: p.name, pattern: identifierPattern(p.name) })),
10408
10474
  constants: analyzer.localConstants.map((c) => ({
10409
10475
  name: c.name,
10410
10476
  value: c.value,
10411
- pattern: new RegExp(`\\b${c.name}\\b`)
10477
+ pattern: identifierPattern(c.name)
10412
10478
  }))
10413
10479
  },
10414
10480
  getJS(node) {
@@ -10423,17 +10489,17 @@ function createTransformContext(analyzer) {
10423
10489
  function buildComponentNamespaces(ctx2) {
10424
10490
  const result2 = /* @__PURE__ */ new Map();
10425
10491
  for (const stmt of ctx2.sourceFile.statements) {
10426
- if (!ts12.isVariableStatement(stmt)) continue;
10492
+ if (!ts13.isVariableStatement(stmt)) continue;
10427
10493
  for (const decl of stmt.declarationList.declarations) {
10428
- if (!decl.initializer || !ts12.isIdentifier(decl.name)) continue;
10494
+ if (!decl.initializer || !ts13.isIdentifier(decl.name)) continue;
10429
10495
  let init = decl.initializer;
10430
- while (ts12.isParenthesizedExpression(init)) init = init.expression;
10431
- if (!ts12.isObjectLiteralExpression(init)) continue;
10496
+ while (ts13.isParenthesizedExpression(init)) init = init.expression;
10497
+ if (!ts13.isObjectLiteralExpression(init)) continue;
10432
10498
  const members = /* @__PURE__ */ new Map();
10433
10499
  for (const prop of init.properties) {
10434
- if (ts12.isShorthandPropertyAssignment(prop)) {
10500
+ if (ts13.isShorthandPropertyAssignment(prop)) {
10435
10501
  members.set(prop.name.text, prop.name.text);
10436
- } 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)) {
10437
10503
  members.set(prop.name.text, prop.initializer.text);
10438
10504
  }
10439
10505
  }
@@ -10445,9 +10511,9 @@ function buildComponentNamespaces(ctx2) {
10445
10511
  return result2;
10446
10512
  }
10447
10513
  function resolveMemberExpressionTag(tagNode, ctx2) {
10448
- if (!ts12.isPropertyAccessExpression(tagNode)) return null;
10449
- if (!ts12.isIdentifier(tagNode.expression)) return null;
10450
- 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;
10451
10517
  if (!ctx2._componentNamespaces) {
10452
10518
  ctx2._componentNamespaces = buildComponentNamespaces(ctx2);
10453
10519
  }
@@ -10482,7 +10548,7 @@ function makeBindingEnv(ctx2) {
10482
10548
  // mutated (cached on the immutable `BindingScope`) — a stable
10483
10549
  // snapshot even if `ctx.scope` is later reassigned by an enclosing
10484
10550
  // visitor frame, which swaps the instance rather than mutating it.
10485
- loopParams: boundNames,
10551
+ loopValueBoundNames: boundNames,
10486
10552
  checker: a.checker
10487
10553
  };
10488
10554
  ctx2._bindingEnv = env;
@@ -10588,7 +10654,7 @@ function buildIRRoot(analyzer) {
10588
10654
  if (!analyzer.jsxReturn) return null;
10589
10655
  const ctx2 = createTransformContext(analyzer);
10590
10656
  const jsxReturn = analyzer.jsxReturn;
10591
- if (ts12.isJsxElement(jsxReturn) || ts12.isJsxSelfClosingElement(jsxReturn) || ts12.isJsxFragment(jsxReturn)) {
10657
+ if (ts13.isJsxElement(jsxReturn) || ts13.isJsxSelfClosingElement(jsxReturn) || ts13.isJsxFragment(jsxReturn)) {
10592
10658
  const ir2 = transformNode(jsxReturn, ctx2);
10593
10659
  if (ir2 && needsScopeWrapper(ir2)) {
10594
10660
  return wrapInScopeElement(ir2);
@@ -10641,22 +10707,22 @@ function wrapInScopeElement(node) {
10641
10707
  };
10642
10708
  }
10643
10709
  function transformNode(node, ctx2) {
10644
- if (ts12.isJsxElement(node)) {
10710
+ if (ts13.isJsxElement(node)) {
10645
10711
  return transformJsxElement(node, ctx2);
10646
10712
  }
10647
- if (ts12.isJsxSelfClosingElement(node)) {
10713
+ if (ts13.isJsxSelfClosingElement(node)) {
10648
10714
  return transformSelfClosingElement(node, ctx2);
10649
10715
  }
10650
- if (ts12.isJsxFragment(node)) {
10716
+ if (ts13.isJsxFragment(node)) {
10651
10717
  return transformFragment(node, ctx2);
10652
10718
  }
10653
- if (ts12.isJsxText(node)) {
10719
+ if (ts13.isJsxText(node)) {
10654
10720
  return transformText(node, ctx2);
10655
10721
  }
10656
- if (ts12.isJsxExpression(node)) {
10722
+ if (ts13.isJsxExpression(node)) {
10657
10723
  return transformExpression(node, ctx2);
10658
10724
  }
10659
- if (ts12.isConditionalExpression(node)) {
10725
+ if (ts13.isConditionalExpression(node)) {
10660
10726
  return transformConditional(node, ctx2);
10661
10727
  }
10662
10728
  return null;
@@ -11035,14 +11101,14 @@ function transformSelfClosingComponent(node, ctx2, name2) {
11035
11101
  }
11036
11102
  function isTransparentFragment(node, ctx2) {
11037
11103
  const children2 = node.children.filter((child2) => {
11038
- if (ts12.isJsxText(child2)) {
11104
+ if (ts13.isJsxText(child2)) {
11039
11105
  return child2.text.trim() !== "";
11040
11106
  }
11041
11107
  return true;
11042
11108
  });
11043
11109
  if (children2.length !== 1) return false;
11044
11110
  const child = children2[0];
11045
- if (!ts12.isJsxExpression(child)) return false;
11111
+ if (!ts13.isJsxExpression(child)) return false;
11046
11112
  if (!child.expression) return false;
11047
11113
  const exprText = child.expression.getText(ctx2.sourceFile);
11048
11114
  if (exprText === "children") return true;
@@ -11081,7 +11147,7 @@ function transformChildren(children2, ctx2) {
11081
11147
  const result2 = [];
11082
11148
  for (let i = 0; i < children2.length; i++) {
11083
11149
  const child = children2[i];
11084
- if (ts12.isJsxExpression(child) && !child.expression) {
11150
+ if (ts13.isJsxExpression(child) && !child.expression) {
11085
11151
  continue;
11086
11152
  }
11087
11153
  const transformed = transformNode(child, ctx2);
@@ -11096,10 +11162,10 @@ function transformChildren(children2, ctx2) {
11096
11162
  }
11097
11163
  function isRenderNothingLiteral(expr, ctx2) {
11098
11164
  let e = expr;
11099
- 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)) {
11100
11166
  e = e.expression;
11101
11167
  }
11102
- 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));
11103
11169
  }
11104
11170
  function transformText(node, ctx2) {
11105
11171
  const text = node.text.replace(/\s+/g, " ");
@@ -11129,7 +11195,7 @@ function transformExpressionInner(expr, ctx2, node, isClientOnly) {
11129
11195
  return null;
11130
11196
  }
11131
11197
  checkBareSignalOrMemoIdentifier(expr, ctx2);
11132
- if (ts12.isIdentifier(expr)) {
11198
+ if (ts13.isIdentifier(expr)) {
11133
11199
  const jsxNode = ctx2.analyzer.jsxConstants.get(expr.text);
11134
11200
  if (jsxNode) {
11135
11201
  return transformNode(jsxNode, ctx2);
@@ -11180,7 +11246,7 @@ function transformExpressionInner(expr, ctx2, node, isClientOnly) {
11180
11246
  };
11181
11247
  const reactive = isReactiveExpression(exprText, ctx2, expr) || isReactiveOrigin(origin);
11182
11248
  const scopeValueNames = ctx2.scope.valueBoundNames();
11183
- const refsLoopParam = scopeValueNames.size > 0 && Array.from(scopeValueNames).some((p) => new RegExp(`\\b${p}\\b`).test(exprText));
11249
+ const refsLoopParam = scopeValueNames.size > 0 && Array.from(scopeValueNames).some((p) => identifierPattern(p).test(exprText));
11184
11250
  const callsReactive = exprCallsReactiveGetters(expr, ctx2);
11185
11251
  const hasCalls = exprHasFunctionCalls(expr);
11186
11252
  const needsSlot = reactive || isClientOnly || refsLoopParam || callsReactive || hasCalls;
@@ -11215,7 +11281,7 @@ function transformJsxFunctionCall(callExpr, jsxFunc, ctx2, _isClientOnly) {
11215
11281
  const substitutedGetJS = (node) => {
11216
11282
  let text = baseGetJS(node);
11217
11283
  for (const [paramName, argExpr] of substitutions) {
11218
- text = text.replace(new RegExp(`\\b${paramName}\\b`, "g"), argExpr);
11284
+ text = text.replace(identifierPattern(paramName, "g"), () => argExpr);
11219
11285
  }
11220
11286
  return text;
11221
11287
  };
@@ -11257,7 +11323,7 @@ function transformMultiReturnJsxFunctionCall(callExpr, info, ctx2) {
11257
11323
  const substitutedGetJS = (node) => {
11258
11324
  let text = baseGetJS(node);
11259
11325
  for (const [paramName, argExpr] of substitutions) {
11260
- text = text.replace(new RegExp(`\\b${paramName}\\b`, "g"), argExpr);
11326
+ text = text.replace(identifierPattern(paramName, "g"), () => argExpr);
11261
11327
  }
11262
11328
  return text;
11263
11329
  };
@@ -11417,35 +11483,35 @@ function transformLogicalAnd(node, ctx2) {
11417
11483
  };
11418
11484
  }
11419
11485
  function containsJsxInExpression(node) {
11420
- if (ts12.isJsxElement(node) || ts12.isJsxSelfClosingElement(node) || ts12.isJsxFragment(node)) {
11486
+ if (ts13.isJsxElement(node) || ts13.isJsxSelfClosingElement(node) || ts13.isJsxFragment(node)) {
11421
11487
  return true;
11422
11488
  }
11423
- return ts12.forEachChild(node, containsJsxInExpression) ?? false;
11489
+ return ts13.forEachChild(node, containsJsxInExpression) ?? false;
11424
11490
  }
11425
11491
  function callsJsxHelper(node, ctx2) {
11426
11492
  let found = false;
11427
11493
  const visit3 = (n) => {
11428
11494
  if (found) return;
11429
- if (ts12.isCallExpression(n) && ts12.isIdentifier(n.expression)) {
11495
+ if (ts13.isCallExpression(n) && ts13.isIdentifier(n.expression)) {
11430
11496
  const name2 = n.expression.text;
11431
11497
  if (ctx2.analyzer.jsxFunctions.has(name2) || ctx2.analyzer.jsxMultiReturnFunctions.has(name2)) {
11432
11498
  found = true;
11433
11499
  return;
11434
11500
  }
11435
11501
  }
11436
- ts12.forEachChild(n, visit3);
11502
+ ts13.forEachChild(n, visit3);
11437
11503
  };
11438
11504
  visit3(node);
11439
11505
  return found;
11440
11506
  }
11441
11507
  function containsAwaitExpression(node) {
11442
- if (ts12.isAwaitExpression(node)) return true;
11443
- if (ts12.isFunctionDeclaration(node) || ts12.isFunctionExpression(node) || ts12.isArrowFunction(node)) return false;
11444
- 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;
11445
11511
  }
11446
11512
  function transformNullishCoalescing(node, ctx2) {
11447
11513
  const leftText = ctx2.getJS(node.left);
11448
- const isNullish = node.operatorToken.kind === ts12.SyntaxKind.QuestionQuestionToken;
11514
+ const isNullish = node.operatorToken.kind === ts13.SyntaxKind.QuestionQuestionToken;
11449
11515
  const condition = isNullish ? `${leftText} != null` : leftText;
11450
11516
  const leftOrigin = {
11451
11517
  phase: "tick",
@@ -11492,46 +11558,46 @@ function transformNullishCoalescing(node, ctx2) {
11492
11558
  function assertNever2(expr) {
11493
11559
  const kind2 = expr?.kind;
11494
11560
  throw new Error(
11495
- `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.`
11496
11562
  );
11497
11563
  }
11498
11564
  function transformJsxExpression(expr, ctx2, isClientOnly = false) {
11499
11565
  const node = expr;
11500
11566
  switch (node.kind) {
11501
11567
  // --- Transparent: unwrap and recurse ---
11502
- case ts12.SyntaxKind.ParenthesizedExpression:
11503
- case ts12.SyntaxKind.AsExpression:
11504
- case ts12.SyntaxKind.SatisfiesExpression:
11505
- case ts12.SyntaxKind.NonNullExpression:
11506
- case ts12.SyntaxKind.TypeAssertionExpression:
11507
- 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:
11508
11574
  return transformJsxExpression(node.expression, ctx2, isClientOnly);
11509
11575
  // --- JSX-structural: delegate to shape transformer ---
11510
- case ts12.SyntaxKind.JsxElement:
11576
+ case ts13.SyntaxKind.JsxElement:
11511
11577
  return transformJsxElement(node, ctx2);
11512
- case ts12.SyntaxKind.JsxFragment:
11578
+ case ts13.SyntaxKind.JsxFragment:
11513
11579
  return transformFragment(node, ctx2);
11514
- case ts12.SyntaxKind.JsxSelfClosingElement:
11580
+ case ts13.SyntaxKind.JsxSelfClosingElement:
11515
11581
  return transformSelfClosingElement(node, ctx2);
11516
- case ts12.SyntaxKind.ConditionalExpression:
11582
+ case ts13.SyntaxKind.ConditionalExpression:
11517
11583
  return transformConditional(node, ctx2);
11518
- case ts12.SyntaxKind.BinaryExpression: {
11519
- if (node.operatorToken.kind === ts12.SyntaxKind.AmpersandAmpersandToken) {
11584
+ case ts13.SyntaxKind.BinaryExpression: {
11585
+ if (node.operatorToken.kind === ts13.SyntaxKind.AmpersandAmpersandToken) {
11520
11586
  return transformLogicalAnd(node, ctx2);
11521
11587
  }
11522
- 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))) {
11523
11589
  return transformNullishCoalescing(node, ctx2);
11524
11590
  }
11525
11591
  return null;
11526
11592
  }
11527
- case ts12.SyntaxKind.CallExpression: {
11593
+ case ts13.SyntaxKind.CallExpression: {
11528
11594
  const mapMethod = getMapLikeMethod(node);
11529
11595
  if (mapMethod) {
11530
11596
  const mapResult = transformMapCall(node, ctx2, isClientOnly, mapMethod);
11531
11597
  if (mapResult) return mapResult;
11532
11598
  }
11533
11599
  const callee = node.expression;
11534
- if (ts12.isIdentifier(callee)) {
11600
+ if (ts13.isIdentifier(callee)) {
11535
11601
  const jsxFunc = ctx2.analyzer.jsxFunctions.get(callee.text);
11536
11602
  if (jsxFunc) {
11537
11603
  return transformJsxFunctionCall(node, jsxFunc, ctx2, isClientOnly);
@@ -11544,40 +11610,40 @@ function transformJsxExpression(expr, ctx2, isClientOnly = false) {
11544
11610
  return null;
11545
11611
  }
11546
11612
  // --- Scalar leaf: caller emits IRExpression ---
11547
- case ts12.SyntaxKind.Identifier:
11548
- case ts12.SyntaxKind.StringLiteral:
11549
- case ts12.SyntaxKind.NumericLiteral:
11550
- case ts12.SyntaxKind.BigIntLiteral:
11551
- case ts12.SyntaxKind.RegularExpressionLiteral:
11552
- case ts12.SyntaxKind.NoSubstitutionTemplateLiteral:
11553
- case ts12.SyntaxKind.TemplateExpression:
11554
- case ts12.SyntaxKind.TaggedTemplateExpression:
11555
- case ts12.SyntaxKind.TrueKeyword:
11556
- case ts12.SyntaxKind.FalseKeyword:
11557
- case ts12.SyntaxKind.NullKeyword:
11558
- case ts12.SyntaxKind.ThisKeyword:
11559
- case ts12.SyntaxKind.SuperKeyword:
11560
- case ts12.SyntaxKind.ImportKeyword:
11561
- case ts12.SyntaxKind.PropertyAccessExpression:
11562
- case ts12.SyntaxKind.ElementAccessExpression:
11563
- case ts12.SyntaxKind.PrefixUnaryExpression:
11564
- case ts12.SyntaxKind.PostfixUnaryExpression:
11565
- case ts12.SyntaxKind.TypeOfExpression:
11566
- case ts12.SyntaxKind.VoidExpression:
11567
- case ts12.SyntaxKind.DeleteExpression:
11568
- case ts12.SyntaxKind.NewExpression:
11569
- case ts12.SyntaxKind.ObjectLiteralExpression:
11570
- case ts12.SyntaxKind.ArrowFunction:
11571
- case ts12.SyntaxKind.FunctionExpression:
11572
- case ts12.SyntaxKind.ClassExpression:
11573
- case ts12.SyntaxKind.MetaProperty:
11574
- case ts12.SyntaxKind.ExpressionWithTypeArguments:
11575
- case ts12.SyntaxKind.CommaListExpression:
11576
- case ts12.SyntaxKind.SyntheticExpression:
11577
- 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:
11578
11644
  return null;
11579
11645
  // --- Forbidden in render position ---
11580
- case ts12.SyntaxKind.AwaitExpression:
11646
+ case ts13.SyntaxKind.AwaitExpression:
11581
11647
  ctx2.analyzer.errors.push(
11582
11648
  createError(
11583
11649
  ErrorCodes.STAGE_AWAIT_IN_TEMPLATE,
@@ -11593,20 +11659,20 @@ function transformJsxExpression(expr, ctx2, isClientOnly = false) {
11593
11659
  loc: getSourceLocation(node, ctx2.sourceFile, ctx2.filePath),
11594
11660
  origin: { phase: "tick", scope: "template", effect: "pure", freeRefs: [] }
11595
11661
  };
11596
- case ts12.SyntaxKind.YieldExpression:
11662
+ case ts13.SyntaxKind.YieldExpression:
11597
11663
  return null;
11598
11664
  // --- Unreachable at render position ---
11599
11665
  // Parser prevents these in well-formed sources; listed for exhaustiveness
11600
11666
  // so an upstream TypeScript change that repurposes one of these kinds
11601
11667
  // surfaces as a compile error here instead of silently drifting.
11602
- case ts12.SyntaxKind.SpreadElement:
11603
- case ts12.SyntaxKind.OmittedExpression:
11604
- case ts12.SyntaxKind.JsxExpression:
11605
- case ts12.SyntaxKind.JsxOpeningElement:
11606
- case ts12.SyntaxKind.JsxOpeningFragment:
11607
- case ts12.SyntaxKind.JsxClosingFragment:
11608
- case ts12.SyntaxKind.JsxAttributes:
11609
- 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:
11610
11676
  return null;
11611
11677
  default:
11612
11678
  return assertNever2(node);
@@ -11642,15 +11708,15 @@ function transformConditionalBranch(node, ctx2) {
11642
11708
  };
11643
11709
  }
11644
11710
  function getMapLikeMethod(node) {
11645
- if (!ts12.isPropertyAccessExpression(node.expression)) return null;
11711
+ if (!ts13.isPropertyAccessExpression(node.expression)) return null;
11646
11712
  const name2 = node.expression.name.text;
11647
11713
  if (name2 === "map") return "map";
11648
11714
  if (name2 === "flatMap") return "flatMap";
11649
11715
  return null;
11650
11716
  }
11651
11717
  function isFilterCall(node) {
11652
- if (!ts12.isCallExpression(node)) return null;
11653
- if (!ts12.isPropertyAccessExpression(node.expression)) return null;
11718
+ if (!ts13.isCallExpression(node)) return null;
11719
+ if (!ts13.isPropertyAccessExpression(node.expression)) return null;
11654
11720
  if (node.expression.name.text !== "filter") return null;
11655
11721
  if (node.arguments.length !== 1) return null;
11656
11722
  return {
@@ -11659,8 +11725,8 @@ function isFilterCall(node) {
11659
11725
  };
11660
11726
  }
11661
11727
  function isSortCall(node) {
11662
- if (!ts12.isCallExpression(node)) return null;
11663
- if (!ts12.isPropertyAccessExpression(node.expression)) return null;
11728
+ if (!ts13.isCallExpression(node)) return null;
11729
+ if (!ts13.isPropertyAccessExpression(node.expression)) return null;
11664
11730
  const methodName = node.expression.name.text;
11665
11731
  if (methodName !== "sort" && methodName !== "toSorted") return null;
11666
11732
  if (node.arguments.length !== 1) return null;
@@ -11671,17 +11737,17 @@ function isSortCall(node) {
11671
11737
  };
11672
11738
  }
11673
11739
  function isIteratorShapeCall(node) {
11674
- if (!ts12.isCallExpression(node)) return null;
11675
- if (!ts12.isPropertyAccessExpression(node.expression)) return null;
11740
+ if (!ts13.isCallExpression(node)) return null;
11741
+ if (!ts13.isPropertyAccessExpression(node.expression)) return null;
11676
11742
  if (node.arguments.length !== 0) return null;
11677
11743
  const name2 = node.expression.name.text;
11678
11744
  if (name2 !== "entries" && name2 !== "keys" && name2 !== "values") return null;
11679
11745
  return { array: node.expression.expression, shape: name2 };
11680
11746
  }
11681
11747
  function isObjectIteratorCall(node) {
11682
- if (!ts12.isCallExpression(node)) return null;
11683
- if (!ts12.isPropertyAccessExpression(node.expression)) return null;
11684
- 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;
11685
11751
  if (node.expression.expression.text !== "Object") return null;
11686
11752
  if (node.arguments.length !== 1) return null;
11687
11753
  const name2 = node.expression.name.text;
@@ -11702,7 +11768,7 @@ function extractSortComparator(callback, _method, ctx2) {
11702
11768
  (reverse the operands for descending order).`
11703
11769
  });
11704
11770
  let resolvedNode = callback;
11705
- if (ts12.isIdentifier(callback)) {
11771
+ if (ts13.isIdentifier(callback)) {
11706
11772
  const resolved = resolveSortComparatorIdentifier(callback.text, ctx2);
11707
11773
  if (!resolved) {
11708
11774
  return {
@@ -11712,7 +11778,7 @@ function extractSortComparator(callback, _method, ctx2) {
11712
11778
  }
11713
11779
  resolvedNode = resolved;
11714
11780
  }
11715
- if (!ts12.isArrowFunction(resolvedNode) && !ts12.isFunctionExpression(resolvedNode)) {
11781
+ if (!ts13.isArrowFunction(resolvedNode) && !ts13.isFunctionExpression(resolvedNode)) {
11716
11782
  return {
11717
11783
  result: null,
11718
11784
  unsupportedReason: "Sort comparator must be an arrow function or function expression"
@@ -11736,11 +11802,11 @@ function resolveSortComparatorIdentifier(name2, ctx2) {
11736
11802
  if (constInfo && fnInfo) return null;
11737
11803
  if (constInfo) {
11738
11804
  const ast = parseConstInitializer(constInfo);
11739
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11805
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11740
11806
  }
11741
11807
  if (fnInfo) {
11742
11808
  const ast = parseFunctionInfoAsExpr(fnInfo);
11743
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11809
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11744
11810
  }
11745
11811
  return null;
11746
11812
  }
@@ -11750,11 +11816,11 @@ function resolveCallbackMethodFunctionReferenceIdentifier(name2, analyzer) {
11750
11816
  if (constInfo && fnInfo) return null;
11751
11817
  if (constInfo) {
11752
11818
  const ast = parseConstInitializer(constInfo);
11753
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11819
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11754
11820
  }
11755
11821
  if (fnInfo) {
11756
11822
  const ast = parseFunctionInfoAsExpr(fnInfo);
11757
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11823
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11758
11824
  }
11759
11825
  return null;
11760
11826
  }
@@ -11809,11 +11875,11 @@ function resolveCallbackMethodFunctionReferences(expr, analyzer, bound = EMPTY_B
11809
11875
  return visit3(expr, bound);
11810
11876
  }
11811
11877
  function extractFilterPredicate(callback, ctx2) {
11812
- if (!ts12.isArrowFunction(callback)) return { result: null };
11878
+ if (!ts13.isArrowFunction(callback)) return { result: null };
11813
11879
  if (callback.parameters.length < 1) return { result: null };
11814
11880
  const firstParam = callback.parameters[0];
11815
- if (!ts12.isIdentifier(firstParam.name)) {
11816
- if (ts12.isBlock(callback.body)) {
11881
+ if (!ts13.isIdentifier(firstParam.name)) {
11882
+ if (ts13.isBlock(callback.body)) {
11817
11883
  return {
11818
11884
  result: null,
11819
11885
  unsupportedReason: "Block body in a destructured filter param is not supported. Workaround: use an expression-body arrow, or add /* @client */."
@@ -11833,7 +11899,7 @@ function extractFilterPredicate(callback, ctx2) {
11833
11899
  return { result: null };
11834
11900
  }
11835
11901
  const param = firstParam.name.getText(ctx2.sourceFile);
11836
- if (ts12.isBlock(callback.body)) {
11902
+ if (ts13.isBlock(callback.body)) {
11837
11903
  const raw2 = ctx2.getJS(callback.body);
11838
11904
  const statements = parseBlockBody(callback.body, ctx2.sourceFile, (n) => ctx2.getJS(n));
11839
11905
  if (!statements) {
@@ -11859,14 +11925,14 @@ function extractFilterPredicate(callback, ctx2) {
11859
11925
  return { result: { param, predicate, raw } };
11860
11926
  }
11861
11927
  function extractLoopParamBindings(pattern) {
11862
- if (ts12.isIdentifier(pattern)) return null;
11928
+ if (ts13.isIdentifier(pattern)) return null;
11863
11929
  const bindings = [];
11864
11930
  let unsupported = false;
11865
11931
  const isIdent = (key) => {
11866
11932
  if (key.length === 0) return false;
11867
11933
  for (let i = 0; i < key.length; ) {
11868
11934
  const cp = key.codePointAt(i);
11869
- 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);
11870
11936
  if (!ok) return false;
11871
11937
  i += cp > 65535 ? 2 : 1;
11872
11938
  }
@@ -11877,19 +11943,19 @@ function extractLoopParamBindings(pattern) {
11877
11943
  };
11878
11944
  const walk = (p, prefix2, segments) => {
11879
11945
  if (unsupported) return;
11880
- if (ts12.isArrayBindingPattern(p)) {
11946
+ if (ts13.isArrayBindingPattern(p)) {
11881
11947
  const elements3 = p.elements;
11882
11948
  for (let index = 0; index < elements3.length; index++) {
11883
11949
  if (unsupported) return;
11884
11950
  const el = elements3[index];
11885
- if (ts12.isOmittedExpression(el)) continue;
11951
+ if (ts13.isOmittedExpression(el)) continue;
11886
11952
  if (el.dotDotDotToken) {
11887
11953
  internalInvariant(
11888
11954
  index === elements3.length - 1,
11889
11955
  "extractLoopParamBindings: array rest token in non-final position (parser should reject)"
11890
11956
  );
11891
11957
  internalInvariant(
11892
- ts12.isIdentifier(el.name),
11958
+ ts13.isIdentifier(el.name),
11893
11959
  "extractLoopParamBindings: array rest target is not an identifier (parser should reject)"
11894
11960
  );
11895
11961
  bindings.push({
@@ -11902,7 +11968,7 @@ function extractLoopParamBindings(pattern) {
11902
11968
  }
11903
11969
  const path25 = `${prefix2}[${index}]`;
11904
11970
  const nextSegments = [...segments, { kind: "index", index }];
11905
- if (ts12.isIdentifier(el.name)) {
11971
+ if (ts13.isIdentifier(el.name)) {
11906
11972
  bindings.push({ name: el.name.text, path: path25, segments: nextSegments });
11907
11973
  } else {
11908
11974
  walk(el.name, path25, nextSegments);
@@ -11921,7 +11987,7 @@ function extractLoopParamBindings(pattern) {
11921
11987
  "extractLoopParamBindings: object rest token in non-final position (parser should reject)"
11922
11988
  );
11923
11989
  internalInvariant(
11924
- ts12.isIdentifier(el.name),
11990
+ ts13.isIdentifier(el.name),
11925
11991
  "extractLoopParamBindings: object rest target is not an identifier (parser should reject)"
11926
11992
  );
11927
11993
  bindings.push({
@@ -11935,14 +12001,14 @@ function extractLoopParamBindings(pattern) {
11935
12001
  let keyText2 = null;
11936
12002
  if (el.propertyName) {
11937
12003
  const pn = el.propertyName;
11938
- if (ts12.isIdentifier(pn)) keyText2 = pn.text;
11939
- else if (ts12.isStringLiteral(pn)) keyText2 = pn.text;
11940
- 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;
11941
12007
  else {
11942
12008
  unsupported = true;
11943
12009
  return;
11944
12010
  }
11945
- } else if (ts12.isIdentifier(el.name)) {
12011
+ } else if (ts13.isIdentifier(el.name)) {
11946
12012
  keyText2 = el.name.text;
11947
12013
  } else {
11948
12014
  unsupported = true;
@@ -11952,14 +12018,14 @@ function extractLoopParamBindings(pattern) {
11952
12018
  collectedKeys.push({ key: keyText2, isIdent: keyIsIdent });
11953
12019
  const path25 = appendDotAccess(prefix2, keyText2);
11954
12020
  const nextSegments = [...segments, { kind: "field", key: keyText2, isIdent: keyIsIdent }];
11955
- if (ts12.isIdentifier(el.name)) {
12021
+ if (ts13.isIdentifier(el.name)) {
11956
12022
  bindings.push({ name: el.name.text, path: path25, segments: nextSegments });
11957
12023
  } else {
11958
12024
  walk(el.name, path25, nextSegments);
11959
12025
  }
11960
12026
  }
11961
12027
  };
11962
- if (ts12.isArrayBindingPattern(pattern) || ts12.isObjectBindingPattern(pattern)) {
12028
+ if (ts13.isArrayBindingPattern(pattern) || ts13.isObjectBindingPattern(pattern)) {
11963
12029
  walk(pattern, "", []);
11964
12030
  if (unsupported) return { unsupported: true };
11965
12031
  return bindings;
@@ -11968,7 +12034,7 @@ function extractLoopParamBindings(pattern) {
11968
12034
  }
11969
12035
  function findKeyJsxAttribute(opening) {
11970
12036
  for (const prop of opening.attributes.properties) {
11971
- if (ts12.isJsxAttribute(prop) && prop.name.getText() === "key") {
12037
+ if (ts13.isJsxAttribute(prop) && prop.name.getText() === "key") {
11972
12038
  return prop;
11973
12039
  }
11974
12040
  }
@@ -12009,7 +12075,7 @@ function keyAttrValueToExpr(v) {
12009
12075
  function normalizeKeyExpr(expr) {
12010
12076
  let out = "";
12011
12077
  for (const tok of iterateJsTokens(expr)) {
12012
- if (tok.kind === ts12.SyntaxKind.WhitespaceTrivia || tok.kind === ts12.SyntaxKind.NewLineTrivia) {
12078
+ if (tok.kind === ts13.SyntaxKind.WhitespaceTrivia || tok.kind === ts13.SyntaxKind.NewLineTrivia) {
12013
12079
  continue;
12014
12080
  }
12015
12081
  out += expr.slice(tok.pos, tok.end);
@@ -12021,33 +12087,33 @@ function conditionalHasExplicitNullishBranch(cond) {
12021
12087
  }
12022
12088
  function branchHasExplicitNullish(branch) {
12023
12089
  let b = branch;
12024
- while (ts12.isParenthesizedExpression(b)) b = b.expression;
12025
- if (b.kind === ts12.SyntaxKind.NullKeyword) return true;
12026
- if (ts12.isIdentifier(b) && b.text === "undefined") return true;
12027
- 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);
12028
12094
  return false;
12029
12095
  }
12030
12096
  function classifyKeyProblem(keyAttr, checker) {
12031
12097
  if (!keyAttr) return "missing";
12032
12098
  if (!keyAttr.initializer) return "missing";
12033
- if (ts12.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
12099
+ if (ts13.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
12034
12100
  return "missing";
12035
12101
  }
12036
12102
  let expr;
12037
- if (ts12.isStringLiteral(keyAttr.initializer)) {
12103
+ if (ts13.isStringLiteral(keyAttr.initializer)) {
12038
12104
  return null;
12039
- } else if (ts12.isJsxExpression(keyAttr.initializer)) {
12105
+ } else if (ts13.isJsxExpression(keyAttr.initializer)) {
12040
12106
  expr = keyAttr.initializer.expression;
12041
12107
  }
12042
12108
  if (!expr) return null;
12043
- if (expr.kind === ts12.SyntaxKind.NullKeyword) return null;
12044
- if (ts12.isIdentifier(expr) && expr.text === "undefined") return null;
12045
- 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;
12046
12112
  if (checker) {
12047
12113
  const type2 = checker.getTypeAtLocation(expr);
12048
12114
  const isNullable = type2.isUnion() ? type2.types.some(
12049
- (t) => (t.flags & (ts12.TypeFlags.Null | ts12.TypeFlags.Undefined | ts12.TypeFlags.Void)) !== 0
12050
- ) : (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;
12051
12117
  if (isNullable) return "nullable-type";
12052
12118
  }
12053
12119
  return null;
@@ -12076,70 +12142,70 @@ function checkLoopKey(callback, ctx2, isNested) {
12076
12142
  );
12077
12143
  }
12078
12144
  let body2 = callback.body;
12079
- if (ts12.isBlock(body2)) {
12145
+ if (ts13.isBlock(body2)) {
12080
12146
  const ret = body2.statements.find(
12081
- (s) => ts12.isReturnStatement(s) && s.expression != null
12147
+ (s) => ts13.isReturnStatement(s) && s.expression != null
12082
12148
  );
12083
12149
  if (!ret?.expression) return;
12084
12150
  body2 = ret.expression;
12085
12151
  }
12086
- while (ts12.isParenthesizedExpression(body2)) body2 = body2.expression;
12152
+ while (ts13.isParenthesizedExpression(body2)) body2 = body2.expression;
12087
12153
  function checkJsxOperand(node) {
12088
12154
  let n = node;
12089
- while (ts12.isParenthesizedExpression(n)) n = n.expression;
12090
- if (ts12.isJsxElement(n)) checkOpening(n.openingElement);
12091
- 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);
12092
12158
  }
12093
- if (ts12.isConditionalExpression(body2)) {
12159
+ if (ts13.isConditionalExpression(body2)) {
12094
12160
  checkJsxOperand(body2.whenTrue);
12095
12161
  checkJsxOperand(body2.whenFalse);
12096
12162
  return;
12097
12163
  }
12098
- 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)) {
12099
12165
  checkJsxOperand(body2.left);
12100
12166
  checkJsxOperand(body2.right);
12101
12167
  return;
12102
12168
  }
12103
- if (ts12.isJsxElement(body2)) {
12169
+ if (ts13.isJsxElement(body2)) {
12104
12170
  checkOpening(body2.openingElement);
12105
12171
  return;
12106
12172
  }
12107
- if (ts12.isJsxSelfClosingElement(body2)) {
12173
+ if (ts13.isJsxSelfClosingElement(body2)) {
12108
12174
  checkOpening(body2);
12109
12175
  return;
12110
12176
  }
12111
12177
  }
12112
12178
  function flatMapProjectionCall(body2) {
12113
12179
  let expr;
12114
- if (ts12.isBlock(body2)) {
12180
+ if (ts13.isBlock(body2)) {
12115
12181
  const real = body2.statements;
12116
- 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;
12117
12183
  expr = real[0].expression;
12118
12184
  } else {
12119
12185
  expr = body2;
12120
12186
  }
12121
- while (ts12.isParenthesizedExpression(expr)) expr = expr.expression;
12122
- if (!ts12.isCallExpression(expr)) return null;
12187
+ while (ts13.isParenthesizedExpression(expr)) expr = expr.expression;
12188
+ if (!ts13.isCallExpression(expr)) return null;
12123
12189
  if (!getMapLikeMethod(expr)) return null;
12124
12190
  const cb = expr.arguments[0];
12125
- if (!cb || !ts12.isArrowFunction(cb) && !ts12.isFunctionExpression(cb)) return null;
12191
+ if (!cb || !ts13.isArrowFunction(cb) && !ts13.isFunctionExpression(cb)) return null;
12126
12192
  for (const p of cb.parameters) {
12127
- if (!ts12.isIdentifier(p.name)) return null;
12193
+ if (!ts13.isIdentifier(p.name)) return null;
12128
12194
  }
12129
12195
  let innerBody = cb.body;
12130
- if (ts12.isBlock(innerBody)) {
12196
+ if (ts13.isBlock(innerBody)) {
12131
12197
  const ret = innerBody.statements.find(
12132
- (s) => ts12.isReturnStatement(s) && s.expression != null
12198
+ (s) => ts13.isReturnStatement(s) && s.expression != null
12133
12199
  );
12134
12200
  if (innerBody.statements.length !== 1 || !ret?.expression) return null;
12135
12201
  innerBody = ret.expression;
12136
12202
  }
12137
- while (ts12.isParenthesizedExpression(innerBody)) innerBody = innerBody.expression;
12203
+ while (ts13.isParenthesizedExpression(innerBody)) innerBody = innerBody.expression;
12138
12204
  const isElementish = (n) => {
12139
12205
  let m = n;
12140
- while (ts12.isParenthesizedExpression(m)) m = m.expression;
12141
- if (ts12.isJsxElement(m) || ts12.isJsxSelfClosingElement(m)) return leafIsWirelessElement(m);
12142
- 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);
12143
12209
  return false;
12144
12210
  };
12145
12211
  if (!isElementish(innerBody)) return null;
@@ -12149,19 +12215,19 @@ function leafIsWirelessElement(el) {
12149
12215
  let ok = true;
12150
12216
  const visit3 = (n) => {
12151
12217
  if (!ok) return;
12152
- if (ts12.isJsxOpeningElement(n) || ts12.isJsxSelfClosingElement(n)) {
12218
+ if (ts13.isJsxOpeningElement(n) || ts13.isJsxSelfClosingElement(n)) {
12153
12219
  const tagNode = n.tagName;
12154
- 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);
12155
12221
  if (!isIntrinsic) {
12156
12222
  ok = false;
12157
12223
  return;
12158
12224
  }
12159
12225
  for (const attr of n.attributes.properties) {
12160
- if (ts12.isJsxSpreadAttribute(attr)) {
12226
+ if (ts13.isJsxSpreadAttribute(attr)) {
12161
12227
  ok = false;
12162
12228
  return;
12163
12229
  }
12164
- if (ts12.isJsxAttribute(attr)) {
12230
+ if (ts13.isJsxAttribute(attr)) {
12165
12231
  const name2 = attr.name.getText();
12166
12232
  if (/^on[A-Z]/.test(name2)) {
12167
12233
  ok = false;
@@ -12170,11 +12236,11 @@ function leafIsWirelessElement(el) {
12170
12236
  }
12171
12237
  }
12172
12238
  }
12173
- if (ts12.isCallExpression(n) && getMapLikeMethod(n) && containsJsxInExpression(n)) {
12239
+ if (ts13.isCallExpression(n) && getMapLikeMethod(n) && containsJsxInExpression(n)) {
12174
12240
  ok = false;
12175
12241
  return;
12176
12242
  }
12177
- ts12.forEachChild(n, visit3);
12243
+ ts13.forEachChild(n, visit3);
12178
12244
  };
12179
12245
  visit3(el);
12180
12246
  return ok;
@@ -12378,7 +12444,7 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12378
12444
  let children2 = [];
12379
12445
  let paramBindings;
12380
12446
  let flatMapCallback;
12381
- if (ts12.isArrowFunction(callback)) {
12447
+ if (ts13.isArrowFunction(callback)) {
12382
12448
  if (callback.parameters.length > 0) {
12383
12449
  const firstParam = callback.parameters[0];
12384
12450
  param = firstParam.name.getText(ctx2.sourceFile);
@@ -12386,11 +12452,11 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12386
12452
  paramType = firstParam.type.getText(ctx2.sourceFile);
12387
12453
  }
12388
12454
  const isEntriesShape = iterationShape === "entries" || objectIteration === "entries";
12389
- if (isEntriesShape && ts12.isArrayBindingPattern(firstParam.name)) {
12455
+ if (isEntriesShape && ts13.isArrayBindingPattern(firstParam.name)) {
12390
12456
  const elements2 = firstParam.name.elements.filter(
12391
- (el) => !ts12.isOmittedExpression(el)
12457
+ (el) => !ts13.isOmittedExpression(el)
12392
12458
  );
12393
- 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)) {
12394
12460
  index = elements2[0].name.text;
12395
12461
  param = elements2[1].name.text;
12396
12462
  } else {
@@ -12431,9 +12497,9 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12431
12497
  ctx2.scope = ctx2.scope.enterLoopRow({ param, index, paramBindings });
12432
12498
  ctx2.loopDepth++;
12433
12499
  const tryTransformRenderableBody = (expr) => {
12434
- if (!ts12.isBinaryExpression(expr)) return;
12500
+ if (!ts13.isBinaryExpression(expr)) return;
12435
12501
  const op = expr.operatorToken.kind;
12436
- 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) {
12437
12503
  return;
12438
12504
  }
12439
12505
  if (!containsJsxInExpression(expr) && !callsJsxHelper(expr, ctx2)) return;
@@ -12441,33 +12507,33 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12441
12507
  if (transformed) children2 = [transformed];
12442
12508
  };
12443
12509
  const body2 = callback.body;
12444
- if (ts12.isJsxElement(body2) || ts12.isJsxSelfClosingElement(body2) || ts12.isJsxFragment(body2)) {
12510
+ if (ts13.isJsxElement(body2) || ts13.isJsxSelfClosingElement(body2) || ts13.isJsxFragment(body2)) {
12445
12511
  const transformed = transformNode(body2, ctx2);
12446
12512
  if (transformed) {
12447
12513
  children2 = [transformed];
12448
12514
  }
12449
- } else if (ts12.isConditionalExpression(body2)) {
12515
+ } else if (ts13.isConditionalExpression(body2)) {
12450
12516
  children2 = [transformConditional(body2, ctx2)];
12451
- } else if (ts12.isParenthesizedExpression(body2)) {
12517
+ } else if (ts13.isParenthesizedExpression(body2)) {
12452
12518
  let inner = body2.expression;
12453
- while (ts12.isParenthesizedExpression(inner)) {
12519
+ while (ts13.isParenthesizedExpression(inner)) {
12454
12520
  inner = inner.expression;
12455
12521
  }
12456
- if (ts12.isJsxElement(inner) || ts12.isJsxSelfClosingElement(inner) || ts12.isJsxFragment(inner)) {
12522
+ if (ts13.isJsxElement(inner) || ts13.isJsxSelfClosingElement(inner) || ts13.isJsxFragment(inner)) {
12457
12523
  const transformed = transformNode(inner, ctx2);
12458
12524
  if (transformed) {
12459
12525
  children2 = [transformed];
12460
12526
  }
12461
- } else if (ts12.isConditionalExpression(inner)) {
12527
+ } else if (ts13.isConditionalExpression(inner)) {
12462
12528
  children2 = [transformConditional(inner, ctx2)];
12463
- } else if (method2 === "flatMap" && ts12.isArrayLiteralExpression(inner)) {
12529
+ } else if (method2 === "flatMap" && ts13.isArrayLiteralExpression(inner)) {
12464
12530
  children2 = transformArrayLiteralChildren(inner, ctx2);
12465
12531
  } else {
12466
12532
  tryTransformRenderableBody(inner);
12467
12533
  }
12468
- } else if (method2 === "flatMap" && ts12.isArrayLiteralExpression(body2)) {
12534
+ } else if (method2 === "flatMap" && ts13.isArrayLiteralExpression(body2)) {
12469
12535
  children2 = transformArrayLiteralChildren(body2, ctx2);
12470
- } else if (ts12.isBlock(body2)) {
12536
+ } else if (ts13.isBlock(body2)) {
12471
12537
  const multiReturn = method2 !== "flatMap" ? extractMultiReturnJsxBranches(body2, true) : null;
12472
12538
  if (multiReturn && multiReturn.branches.length > 0) {
12473
12539
  const loc = getSourceLocation(body2, ctx2.sourceFile, ctx2.filePath);
@@ -12488,7 +12554,7 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12488
12554
  }
12489
12555
  }
12490
12556
  const returnStmt = children2.length === 0 ? body2.statements.find(
12491
- (s) => ts12.isReturnStatement(s) && s.expression != null
12557
+ (s) => ts13.isReturnStatement(s) && s.expression != null
12492
12558
  ) : void 0;
12493
12559
  let rowScopeBeforePreamble = null;
12494
12560
  if (returnStmt) {
@@ -12509,10 +12575,10 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12509
12575
  }
12510
12576
  if (returnStmt && returnStmt.expression) {
12511
12577
  let returnExpr = returnStmt.expression;
12512
- while (ts12.isParenthesizedExpression(returnExpr)) {
12578
+ while (ts13.isParenthesizedExpression(returnExpr)) {
12513
12579
  returnExpr = returnExpr.expression;
12514
12580
  }
12515
- if (ts12.isJsxElement(returnExpr) || ts12.isJsxSelfClosingElement(returnExpr) || ts12.isJsxFragment(returnExpr)) {
12581
+ if (ts13.isJsxElement(returnExpr) || ts13.isJsxSelfClosingElement(returnExpr) || ts13.isJsxFragment(returnExpr)) {
12516
12582
  const transformed = transformNode(returnExpr, ctx2);
12517
12583
  if (transformed) {
12518
12584
  children2 = [transformed];
@@ -12616,7 +12682,7 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12616
12682
  }
12617
12683
  }
12618
12684
  }
12619
- if (method2 === "flatMap" && children2.length === 0 && !flatMapCallback && !ts12.isBlock(body2)) {
12685
+ if (method2 === "flatMap" && children2.length === 0 && !flatMapCallback && !ts13.isBlock(body2)) {
12620
12686
  flatMapCallback = buildFlatMapCallback(callback, body2, ctx2);
12621
12687
  }
12622
12688
  if (flatMapCallback) preamble = void 0;
@@ -12639,7 +12705,7 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12639
12705
  }
12640
12706
  if (children2.length === 0 && !flatMapCallback) {
12641
12707
  const cb = node.arguments[0];
12642
- 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;
12643
12709
  if (cbBody && containsJsxInExpression(cbBody) && ctx2.analyzer.errors.length === diagCountAtEntry) {
12644
12710
  ctx2.analyzer.errors.push(
12645
12711
  createError(
@@ -12656,7 +12722,7 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12656
12722
  }
12657
12723
  return null;
12658
12724
  }
12659
- if (ts12.isArrowFunction(node.arguments[0]) && children2.length > 0) {
12725
+ if (ts13.isArrowFunction(node.arguments[0]) && children2.length > 0) {
12660
12726
  checkLoopKey(node.arguments[0], ctx2, isNested);
12661
12727
  }
12662
12728
  const itemConditional = children2.length > 0 ? loopBodyItemConditional(children2) : null;
@@ -12714,6 +12780,9 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12714
12780
  const preambleRegions = preamble && !isStaticArray ? collectPreambleRegions(children2, new Set(preamble.declaredNames), ctx2) : void 0;
12715
12781
  if (preamble && !isStaticArray) {
12716
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
+ }
12717
12786
  }
12718
12787
  const nestedComponents = collectNestedComponents(children2).filter((c) => c.name !== childComponent?.name);
12719
12788
  return {
@@ -12764,10 +12833,10 @@ function transformMapCall(node, ctx2, isClientOnly = false, method2 = "map") {
12764
12833
  function transformArrayLiteralChildren(arrayLiteral, ctx2) {
12765
12834
  const children2 = [];
12766
12835
  for (const element of arrayLiteral.elements) {
12767
- if (ts12.isSpreadElement(element)) continue;
12836
+ if (ts13.isSpreadElement(element)) continue;
12768
12837
  let inner = element;
12769
- while (ts12.isParenthesizedExpression(inner)) inner = inner.expression;
12770
- 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)) {
12771
12840
  const transformed = transformNode(inner, ctx2);
12772
12841
  if (transformed) children2.push(transformed);
12773
12842
  }
@@ -12775,7 +12844,7 @@ function transformArrayLiteralChildren(arrayLiteral, ctx2) {
12775
12844
  return children2;
12776
12845
  }
12777
12846
  function containsJsx(node) {
12778
- 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;
12779
12848
  let found = false;
12780
12849
  node.forEachChild((child) => {
12781
12850
  if (!found) found = containsJsx(child);
@@ -12788,14 +12857,14 @@ function buildFlatMapCallback(callback, body2, ctx2) {
12788
12857
  const leafIrs = [];
12789
12858
  let refusalNode;
12790
12859
  const collectJsx = (n, underTemplate) => {
12791
- if (ts12.isJsxElement(n) || ts12.isJsxSelfClosingElement(n) || ts12.isJsxFragment(n)) {
12860
+ if (ts13.isJsxElement(n) || ts13.isJsxSelfClosingElement(n) || ts13.isJsxFragment(n)) {
12792
12861
  if (underTemplate) refusalNode ??= n;
12793
12862
  leafSpans.push({ start: n.getStart(ctx2.sourceFile), end: n.getEnd() });
12794
12863
  const ir = transformNode(n, ctx2);
12795
12864
  leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx2.sourceFile, ctx2.filePath) });
12796
12865
  return;
12797
12866
  }
12798
- const inTemplate = underTemplate || ts12.isTemplateExpression(n) || ts12.isTaggedTemplateExpression(n);
12867
+ const inTemplate = underTemplate || ts13.isTemplateExpression(n) || ts13.isTaggedTemplateExpression(n);
12799
12868
  n.forEachChild((c) => collectJsx(c, inTemplate));
12800
12869
  };
12801
12870
  collectJsx(body2, false);
@@ -12980,6 +13049,31 @@ function markPreambleAttrSlots(nodes, declared, ctx2) {
12980
13049
  };
12981
13050
  visit3(nodes);
12982
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
+ }
12983
13077
  function attrValueText(value2) {
12984
13078
  if (value2.kind === "expression") return value2.expr;
12985
13079
  if (value2.kind !== "template") return "";
@@ -12991,23 +13085,42 @@ function attrValueText(value2) {
12991
13085
  return out.join(" ");
12992
13086
  }
12993
13087
  function collectBindingNames2(name2, out) {
12994
- if (ts12.isIdentifier(name2)) {
13088
+ if (ts13.isIdentifier(name2)) {
12995
13089
  out.add(name2.text);
12996
13090
  return;
12997
13091
  }
12998
13092
  for (const el of name2.elements) {
12999
- if (ts12.isBindingElement(el)) collectBindingNames2(el.name, out);
13093
+ if (ts13.isBindingElement(el)) collectBindingNames2(el.name, out);
13000
13094
  }
13001
13095
  }
13002
13096
  function collectPreambleDeclaredNames(stmt, out) {
13003
- if (ts12.isVariableStatement(stmt)) {
13097
+ if (ts13.isVariableStatement(stmt)) {
13004
13098
  for (const decl of stmt.declarationList.declarations) {
13005
13099
  collectBindingNames2(decl.name, out);
13006
13100
  }
13007
- } else if (ts12.isFunctionDeclaration(stmt) && stmt.name) {
13101
+ } else if (ts13.isFunctionDeclaration(stmt) && stmt.name) {
13008
13102
  out.add(stmt.name.text);
13009
13103
  }
13010
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
+ }
13011
13124
  function preambleFromValueStatements(statements, ctx2) {
13012
13125
  const segments = [];
13013
13126
  const typedParts = [];
@@ -13022,21 +13135,23 @@ function preambleFromValueStatements(statements, ctx2) {
13022
13135
  typedParts.push(raw0.endsWith(";") ? raw0 : raw0 + ";");
13023
13136
  segments.push(tjs !== js ? { kind: "js", text: js, templateText: tjs } : { kind: "js", text: js });
13024
13137
  }
13138
+ const reactiveNames = computePreambleReactiveNames(statements, ctx2);
13025
13139
  return {
13026
13140
  segments: trimPreambleSegments(segments),
13027
13141
  ssrText: tsxSourceText(typedParts.join(" ")),
13028
13142
  declaredNames: [...declared],
13029
13143
  // Value-only preambles accumulate no JSX, so no child needs the array join.
13030
13144
  builderNames: [],
13031
- declarations: neutralPreambleDeclarations(statements, ctx2) ?? void 0
13145
+ declarations: neutralPreambleDeclarations(statements, ctx2) ?? void 0,
13146
+ reactiveNames: reactiveNames.size > 0 ? [...reactiveNames] : void 0
13032
13147
  };
13033
13148
  }
13034
13149
  function neutralPreambleDeclarations(statements, ctx2) {
13035
13150
  const out = [];
13036
13151
  for (const stmt of statements) {
13037
- if (!ts12.isVariableStatement(stmt)) return null;
13152
+ if (!ts13.isVariableStatement(stmt)) return null;
13038
13153
  for (const decl of stmt.declarationList.declarations) {
13039
- if (!ts12.isIdentifier(decl.name)) return null;
13154
+ if (!ts13.isIdentifier(decl.name)) return null;
13040
13155
  if (!decl.initializer) return null;
13041
13156
  const valueParsed = tsNodeToParsedExpr(decl.initializer);
13042
13157
  if (!isSupported(valueParsed).supported) return null;
@@ -13066,11 +13181,11 @@ function buildPreambleSegments(statements, returnStmt, ctx2) {
13066
13181
  let refusalNode;
13067
13182
  const recordBuilderTarget = (leaf, stmt) => {
13068
13183
  for (let n = leaf.parent; n && n !== stmt.parent; n = n.parent) {
13069
- 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)) {
13070
13185
  builders.add(n.expression.expression.text);
13071
13186
  return;
13072
13187
  }
13073
- if (ts12.isVariableDeclaration(n) && ts12.isIdentifier(n.name)) {
13188
+ if (ts13.isVariableDeclaration(n) && ts13.isIdentifier(n.name)) {
13074
13189
  builders.add(n.name.text);
13075
13190
  return;
13076
13191
  }
@@ -13082,7 +13197,7 @@ function buildPreambleSegments(statements, returnStmt, ctx2) {
13082
13197
  const leafSpans = [];
13083
13198
  const leafIrs = [];
13084
13199
  const collect = (n, underTemplate) => {
13085
- if (ts12.isJsxElement(n) || ts12.isJsxSelfClosingElement(n) || ts12.isJsxFragment(n)) {
13200
+ if (ts13.isJsxElement(n) || ts13.isJsxSelfClosingElement(n) || ts13.isJsxFragment(n)) {
13086
13201
  if (underTemplate) refusalNode ??= n;
13087
13202
  recordBuilderTarget(n, stmt);
13088
13203
  leafSpans.push({ start: n.getStart(ctx2.sourceFile), end: n.getEnd() });
@@ -13091,7 +13206,7 @@ function buildPreambleSegments(statements, returnStmt, ctx2) {
13091
13206
  leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx2.sourceFile, ctx2.filePath) });
13092
13207
  return;
13093
13208
  }
13094
- const inTemplate = underTemplate || ts12.isTemplateExpression(n) || ts12.isTaggedTemplateExpression(n);
13209
+ const inTemplate = underTemplate || ts13.isTemplateExpression(n) || ts13.isTaggedTemplateExpression(n);
13095
13210
  n.forEachChild((c) => collect(c, inTemplate));
13096
13211
  };
13097
13212
  collect(stmt, false);
@@ -13195,13 +13310,13 @@ function expandSpreadAttribute(attr, ctx2) {
13195
13310
  }];
13196
13311
  }
13197
13312
  function attrFreeIdentifiers(attr) {
13198
- if (!attr.initializer || !ts12.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13313
+ if (!attr.initializer || !ts13.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13199
13314
  return void 0;
13200
13315
  }
13201
13316
  return extractFreeIdentifiersFromNode(attr.initializer.expression);
13202
13317
  }
13203
13318
  function computeReactivityFlags(attr, ctx2) {
13204
- if (!attr.initializer || !ts12.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13319
+ if (!attr.initializer || !ts13.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13205
13320
  return {};
13206
13321
  }
13207
13322
  const expr = attr.initializer.expression;
@@ -13232,21 +13347,21 @@ function processAttributes(attributes2, ctx2) {
13232
13347
  const events = [];
13233
13348
  let ref = null;
13234
13349
  for (const attr of attributes2.properties) {
13235
- if (ts12.isJsxSpreadAttribute(attr)) {
13350
+ if (ts13.isJsxSpreadAttribute(attr)) {
13236
13351
  attrs.push(...expandSpreadAttribute(attr, ctx2));
13237
13352
  continue;
13238
13353
  }
13239
- if (!ts12.isJsxAttribute(attr)) continue;
13354
+ if (!ts13.isJsxAttribute(attr)) continue;
13240
13355
  const rawName = attr.name.getText(ctx2.sourceFile);
13241
13356
  if (rawName === "ref") {
13242
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13357
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13243
13358
  reportJsxBranchLocalInCallback(attr.initializer.expression, ctx2);
13244
13359
  ref = ctx2.getJS(attr.initializer.expression);
13245
13360
  }
13246
13361
  continue;
13247
13362
  }
13248
13363
  if (/^on[A-Z]/.test(rawName)) {
13249
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13364
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13250
13365
  const eventName = rawName.slice(2).toLowerCase();
13251
13366
  reportJsxBranchLocalInCallback(attr.initializer.expression, ctx2);
13252
13367
  events.push({
@@ -13261,7 +13376,7 @@ function processAttributes(attributes2, ctx2) {
13261
13376
  const name2 = toHTMLAttrName(rawName);
13262
13377
  let value2 = getAttributeValue(attr, ctx2);
13263
13378
  let clientOnly;
13264
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13379
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13265
13380
  if (value2.kind === "expression" && value2.templateExpr === void 0) {
13266
13381
  const rewritten = rewriteBarePropRefs2(value2.expr, attr.initializer.expression, ctx2);
13267
13382
  if (rewritten !== value2.expr) {
@@ -13288,19 +13403,19 @@ function getAttributeValue(attr, ctx2) {
13288
13403
  if (!attr.initializer) {
13289
13404
  return AttrValueOf.booleanAttr();
13290
13405
  }
13291
- if (ts12.isStringLiteral(attr.initializer)) {
13406
+ if (ts13.isStringLiteral(attr.initializer)) {
13292
13407
  return AttrValueOf.literal(decodeEntities(attr.initializer.text));
13293
13408
  }
13294
- if (ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13409
+ if (ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13295
13410
  let expr = attr.initializer.expression;
13296
- if (ts12.isIdentifier(expr)) {
13411
+ if (ts13.isIdentifier(expr)) {
13297
13412
  const branchInit = ctx2._branchScopeVars?.get(expr.text);
13298
13413
  if (branchInit && !initializerShapeContainsJsx(branchInit)) {
13299
13414
  expr = branchInit;
13300
13415
  }
13301
13416
  }
13302
13417
  expr = tryDesugarInterleaveTaggedTemplate(expr, ctx2);
13303
- if (ts12.isAwaitExpression(expr)) {
13418
+ if (ts13.isAwaitExpression(expr)) {
13304
13419
  ctx2.analyzer.errors.push(
13305
13420
  createError(
13306
13421
  ErrorCodes.STAGE_AWAIT_IN_TEMPLATE,
@@ -13310,38 +13425,38 @@ function getAttributeValue(attr, ctx2) {
13310
13425
  return AttrValueOf.expression("undefined");
13311
13426
  }
13312
13427
  checkBareSignalOrMemoIdentifier(expr, ctx2);
13313
- if (attr.name.getText(ctx2.sourceFile) === "style" && ts12.isObjectLiteralExpression(expr)) {
13428
+ if (attr.name.getText(ctx2.sourceFile) === "style" && ts13.isObjectLiteralExpression(expr)) {
13314
13429
  const cssString = tryStaticStyleObjectToCss(expr);
13315
13430
  if (cssString !== null) {
13316
13431
  return AttrValueOf.literal(cssString);
13317
13432
  }
13318
13433
  }
13319
- if (ts12.isTemplateExpression(expr)) {
13434
+ if (ts13.isTemplateExpression(expr)) {
13320
13435
  const parts = parseTemplateLiteral(expr, ctx2);
13321
13436
  if (parts.some((p) => p.type === "ternary" || p.type === "lookup")) {
13322
13437
  return AttrValueOf.template(parts);
13323
13438
  }
13324
13439
  }
13325
- 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)) {
13326
13441
  const parts = tryResolveTemplateSpanFromConst(expr, ctx2);
13327
13442
  if (parts) {
13328
13443
  return AttrValueOf.template(parts);
13329
13444
  }
13330
13445
  }
13331
- if (ts12.isIdentifier(expr)) {
13446
+ if (ts13.isIdentifier(expr)) {
13332
13447
  const resolved = tryResolveIdentifierAsTemplateLiteral(expr, ctx2);
13333
13448
  if (resolved) {
13334
13449
  return AttrValueOf.template(resolved);
13335
13450
  }
13336
13451
  }
13337
- if (ts12.isConditionalExpression(expr)) {
13452
+ if (ts13.isConditionalExpression(expr)) {
13338
13453
  const ternary = parseTernary(expr, ctx2);
13339
13454
  if (ternary) {
13340
13455
  return AttrValueOf.template([ternary]);
13341
13456
  }
13342
13457
  }
13343
- if (ts12.isBinaryExpression(expr) && expr.operatorToken.kind === ts12.SyntaxKind.BarBarToken) {
13344
- 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") {
13345
13460
  const baseExpr = ctx2.getJS(expr.left);
13346
13461
  return AttrValueOf.expression(baseExpr, { presenceOrUndefined: true });
13347
13462
  }
@@ -13354,9 +13469,9 @@ function getAttributeValue(attr, ctx2) {
13354
13469
  function tryStaticStyleObjectToCss(expr) {
13355
13470
  const parts = [];
13356
13471
  for (const prop of expr.properties) {
13357
- if (!ts12.isPropertyAssignment(prop)) return null;
13358
- if (!ts12.isIdentifier(prop.name) && !ts12.isStringLiteral(prop.name)) return null;
13359
- 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;
13360
13475
  const key = cssKebabCase(prop.name.text);
13361
13476
  parts.push(`${key}:${prop.initializer.text}`);
13362
13477
  }
@@ -13368,7 +13483,7 @@ function parseTemplateLiteral(expr, ctx2) {
13368
13483
  parts.push({ type: "string", value: expr.head.text });
13369
13484
  }
13370
13485
  for (const span of expr.templateSpans) {
13371
- if (ts12.isConditionalExpression(span.expression)) {
13486
+ if (ts13.isConditionalExpression(span.expression)) {
13372
13487
  const ternary = parseTernary(span.expression, ctx2);
13373
13488
  if (ternary) {
13374
13489
  parts.push(ternary);
@@ -13394,31 +13509,31 @@ function parseTemplateLiteral(expr, ctx2) {
13394
13509
  return parts;
13395
13510
  }
13396
13511
  function tryResolveTemplateSpanFromConst(expr, ctx2) {
13397
- if (ts12.isIdentifier(expr)) {
13512
+ if (ts13.isIdentifier(expr)) {
13398
13513
  if (ctx2.scope.isBound(expr.text)) return null;
13399
13514
  const constInfo = findLocalConst(expr.text, ctx2.analyzer);
13400
13515
  if (!constInfo) return null;
13401
13516
  const ast = parseConstInitializer(constInfo);
13402
13517
  if (!ast) return null;
13403
- if (ts12.isStringLiteral(ast) || ts12.isNoSubstitutionTemplateLiteral(ast)) {
13518
+ if (ts13.isStringLiteral(ast) || ts13.isNoSubstitutionTemplateLiteral(ast)) {
13404
13519
  return [{ type: "string", value: ast.text }];
13405
13520
  }
13406
13521
  return null;
13407
13522
  }
13408
- if (ts12.isElementAccessExpression(expr)) {
13409
- if (!ts12.isIdentifier(expr.expression)) return null;
13523
+ if (ts13.isElementAccessExpression(expr)) {
13524
+ if (!ts13.isIdentifier(expr.expression)) return null;
13410
13525
  if (ctx2.scope.isBound(expr.expression.text)) return null;
13411
13526
  const constInfo = findLocalConst(expr.expression.text, ctx2.analyzer);
13412
13527
  if (!constInfo) return null;
13413
13528
  const ast = parseConstInitializer(constInfo);
13414
- if (!ast || !ts12.isObjectLiteralExpression(ast)) return null;
13529
+ if (!ast || !ts13.isObjectLiteralExpression(ast)) return null;
13415
13530
  const cases = {};
13416
13531
  for (const prop of ast.properties) {
13417
- if (!ts12.isPropertyAssignment(prop)) return null;
13418
- 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;
13419
13534
  if (!keyName) return null;
13420
13535
  const value2 = prop.initializer;
13421
- if (ts12.isStringLiteral(value2) || ts12.isNoSubstitutionTemplateLiteral(value2)) {
13536
+ if (ts13.isStringLiteral(value2) || ts13.isNoSubstitutionTemplateLiteral(value2)) {
13422
13537
  cases[keyName] = value2.text;
13423
13538
  } else {
13424
13539
  return null;
@@ -13457,17 +13572,17 @@ function hasDynamicTagBinding(name2, sourceFile) {
13457
13572
  let found = false;
13458
13573
  const visit3 = (node) => {
13459
13574
  if (found) return;
13460
- 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) {
13461
13576
  let init = node.initializer;
13462
- 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)) {
13463
13578
  init = init.expression;
13464
13579
  }
13465
- if (ts12.isPropertyAccessExpression(init) && init.name.text === "tag") {
13580
+ if (ts13.isPropertyAccessExpression(init) && init.name.text === "tag") {
13466
13581
  found = true;
13467
13582
  return;
13468
13583
  }
13469
13584
  }
13470
- ts12.forEachChild(node, visit3);
13585
+ ts13.forEachChild(node, visit3);
13471
13586
  };
13472
13587
  visit3(sourceFile);
13473
13588
  return found;
@@ -13478,13 +13593,13 @@ function tryResolveIdentifierAsTemplateLiteral(ident, ctx2) {
13478
13593
  if (!constInfo) return null;
13479
13594
  const ast = parseConstInitializer(constInfo);
13480
13595
  if (!ast) return null;
13481
- if (ts12.isNoSubstitutionTemplateLiteral(ast) || ts12.isStringLiteral(ast)) {
13596
+ if (ts13.isNoSubstitutionTemplateLiteral(ast) || ts13.isStringLiteral(ast)) {
13482
13597
  return [{ type: "string", value: ast.text }];
13483
13598
  }
13484
- 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)) {
13485
13600
  return tryResolveTemplateSpanFromConst(ast, ctx2);
13486
13601
  }
13487
- if (!ts12.isTemplateExpression(ast)) return null;
13602
+ if (!ts13.isTemplateExpression(ast)) return null;
13488
13603
  let resolvedAny = false;
13489
13604
  const parts = [];
13490
13605
  if (ast.head.text) parts.push({ type: "string", value: ast.head.text });
@@ -13516,19 +13631,19 @@ function parseConstInitializer(c) {
13516
13631
  function parseConstInitializerImpl(c) {
13517
13632
  if (!c.value) return null;
13518
13633
  const wrapped = `const __bf_resolve__ = (${c.value})`;
13519
- const sf = ts12.createSourceFile(
13634
+ const sf = ts13.createSourceFile(
13520
13635
  "__bf_resolve.ts",
13521
13636
  wrapped,
13522
- ts12.ScriptTarget.Latest,
13637
+ ts13.ScriptTarget.Latest,
13523
13638
  /* setParentNodes */
13524
13639
  true,
13525
- ts12.ScriptKind.TS
13640
+ ts13.ScriptKind.TS
13526
13641
  );
13527
13642
  const stmt = sf.statements[0];
13528
- if (!stmt || !ts12.isVariableStatement(stmt)) return null;
13643
+ if (!stmt || !ts13.isVariableStatement(stmt)) return null;
13529
13644
  const decl = stmt.declarationList.declarations[0];
13530
13645
  if (!decl?.initializer) return null;
13531
- return ts12.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13646
+ return ts13.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13532
13647
  }
13533
13648
  function astText(node) {
13534
13649
  return node.getText(node.getSourceFile());
@@ -13545,23 +13660,23 @@ function parseFunctionInfoAsExprImpl(fn) {
13545
13660
  const params = fn.typedParams !== void 0 ? fn.typedParams : fn.params.map(formatParamWithType).join(", ");
13546
13661
  const body2 = fn.typedBody ?? fn.body;
13547
13662
  const wrapped = `const __bf_resolve_fn__ = function(${params}) ${body2}`;
13548
- const sf = ts12.createSourceFile(
13663
+ const sf = ts13.createSourceFile(
13549
13664
  "__bf_resolve_fn.ts",
13550
13665
  wrapped,
13551
- ts12.ScriptTarget.Latest,
13666
+ ts13.ScriptTarget.Latest,
13552
13667
  /* setParentNodes */
13553
13668
  true,
13554
- ts12.ScriptKind.TS
13669
+ ts13.ScriptKind.TS
13555
13670
  );
13556
13671
  const stmt = sf.statements[0];
13557
- if (!stmt || !ts12.isVariableStatement(stmt)) return null;
13672
+ if (!stmt || !ts13.isVariableStatement(stmt)) return null;
13558
13673
  const decl = stmt.declarationList.declarations[0];
13559
13674
  if (!decl?.initializer) return null;
13560
13675
  return decl.initializer;
13561
13676
  }
13562
13677
  function tryDesugarInterleaveTaggedTemplate(expr, ctx2) {
13563
- if (!ts12.isTaggedTemplateExpression(expr)) return expr;
13564
- if (!ts12.isIdentifier(expr.tag)) return expr;
13678
+ if (!ts13.isTaggedTemplateExpression(expr)) return expr;
13679
+ if (!ts13.isIdentifier(expr.tag)) return expr;
13565
13680
  const resolvedTag = resolveInterleaveTagIdentifier(expr.tag.text, ctx2);
13566
13681
  if (!resolvedTag) return expr;
13567
13682
  if (!isInterleaveTagFunction(resolvedTag)) return expr;
@@ -13574,20 +13689,20 @@ function resolveInterleaveTagIdentifier(name2, ctx2) {
13574
13689
  if (constInfo && fnInfo) return null;
13575
13690
  if (constInfo) {
13576
13691
  const ast = parseConstInitializer(constInfo);
13577
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
13692
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
13578
13693
  }
13579
13694
  if (fnInfo) {
13580
13695
  const ast = parseFunctionInfoAsExpr(fnInfo);
13581
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
13696
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
13582
13697
  }
13583
13698
  return null;
13584
13699
  }
13585
13700
  function isInterleaveTagFunction(fn) {
13586
- if (!ts12.isArrowFunction(fn) && !ts12.isFunctionExpression(fn)) return false;
13701
+ if (!ts13.isArrowFunction(fn) && !ts13.isFunctionExpression(fn)) return false;
13587
13702
  if (fn.parameters.length !== 2) return false;
13588
13703
  const [partsParam, argsParam] = fn.parameters;
13589
- if (!ts12.isIdentifier(partsParam.name) || partsParam.dotDotDotToken) return false;
13590
- 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;
13591
13706
  const parsed = tsNodeToParsedExpr(fn);
13592
13707
  if (parsed.kind !== "arrow") return false;
13593
13708
  return isInterleaveReduceCall(parsed.body, partsParam.name.text, argsParam.name.text);
@@ -13629,7 +13744,7 @@ function isInterleaveSpanExpr(expr, i, argsName) {
13629
13744
  function buildUntaggedTemplateLiteral(node, ctx2) {
13630
13745
  const template = node.template;
13631
13746
  let text;
13632
- if (ts12.isNoSubstitutionTemplateLiteral(template)) {
13747
+ if (ts13.isNoSubstitutionTemplateLiteral(template)) {
13633
13748
  text = "`" + (template.rawText ?? template.text) + "`";
13634
13749
  } else {
13635
13750
  let body2 = template.head.rawText ?? template.head.text;
@@ -13641,20 +13756,20 @@ function buildUntaggedTemplateLiteral(node, ctx2) {
13641
13756
  text = "`" + body2 + "`";
13642
13757
  }
13643
13758
  const wrapped = `const __bf_resolve_tagged__ = (${text})`;
13644
- const sf = ts12.createSourceFile(
13759
+ const sf = ts13.createSourceFile(
13645
13760
  "__bf_resolve_tagged.tsx",
13646
13761
  wrapped,
13647
- ts12.ScriptTarget.Latest,
13762
+ ts13.ScriptTarget.Latest,
13648
13763
  /* setParentNodes */
13649
13764
  true,
13650
- ts12.ScriptKind.TSX
13765
+ ts13.ScriptKind.TSX
13651
13766
  );
13652
13767
  const stmt = sf.statements[0];
13653
- if (!stmt || !ts12.isVariableStatement(stmt)) return null;
13768
+ if (!stmt || !ts13.isVariableStatement(stmt)) return null;
13654
13769
  const decl = stmt.declarationList.declarations[0];
13655
13770
  if (!decl?.initializer) return null;
13656
- const result2 = ts12.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13657
- 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;
13658
13773
  return result2;
13659
13774
  }
13660
13775
  function parseTernary(expr, ctx2) {
@@ -13673,10 +13788,10 @@ function parseTernary(expr, ctx2) {
13673
13788
  return null;
13674
13789
  }
13675
13790
  function getStringValue(node) {
13676
- if (ts12.isStringLiteral(node)) {
13791
+ if (ts13.isStringLiteral(node)) {
13677
13792
  return node.text;
13678
13793
  }
13679
- if (ts12.isNoSubstitutionTemplateLiteral(node)) {
13794
+ if (ts13.isNoSubstitutionTemplateLiteral(node)) {
13680
13795
  return node.text;
13681
13796
  }
13682
13797
  return null;
@@ -13684,18 +13799,18 @@ function getStringValue(node) {
13684
13799
  function processComponentProps(attributes2, ctx2) {
13685
13800
  const props = [];
13686
13801
  for (const attr of attributes2.properties) {
13687
- if (ts12.isJsxSpreadAttribute(attr)) {
13802
+ if (ts13.isJsxSpreadAttribute(attr)) {
13688
13803
  props.push(...expandSpreadAttribute(attr, ctx2));
13689
13804
  continue;
13690
13805
  }
13691
- if (!ts12.isJsxAttribute(attr)) continue;
13806
+ if (!ts13.isJsxAttribute(attr)) continue;
13692
13807
  const name2 = attr.name.getText(ctx2.sourceFile);
13693
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13808
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13694
13809
  let jsxExpr = attr.initializer.expression;
13695
- while (ts12.isParenthesizedExpression(jsxExpr)) {
13810
+ while (ts13.isParenthesizedExpression(jsxExpr)) {
13696
13811
  jsxExpr = jsxExpr.expression;
13697
13812
  }
13698
- if (ts12.isJsxElement(jsxExpr) || ts12.isJsxSelfClosingElement(jsxExpr) || ts12.isJsxFragment(jsxExpr)) {
13813
+ if (ts13.isJsxElement(jsxExpr) || ts13.isJsxSelfClosingElement(jsxExpr) || ts13.isJsxFragment(jsxExpr)) {
13699
13814
  const prevInsideComponentChildren = ctx2.insideComponentChildren;
13700
13815
  ctx2.insideComponentChildren = true;
13701
13816
  const irNode = transformNode(jsxExpr, ctx2);
@@ -13722,7 +13837,7 @@ function processComponentProps(attributes2, ctx2) {
13722
13837
  value2 = AttrValueOf.booleanShorthand();
13723
13838
  }
13724
13839
  let clientOnly;
13725
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13840
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13726
13841
  if (value2.kind === "expression" && value2.templateExpr === void 0) {
13727
13842
  const rewritten = rewriteBarePropRefs2(value2.expr, attr.initializer.expression, ctx2);
13728
13843
  if (rewritten !== value2.expr) {
@@ -13746,7 +13861,7 @@ function processComponentProps(attributes2, ctx2) {
13746
13861
  return props;
13747
13862
  }
13748
13863
  function checkBareSignalOrMemoIdentifier(expr, ctx2) {
13749
- if (!ts12.isIdentifier(expr)) return;
13864
+ if (!ts13.isIdentifier(expr)) return;
13750
13865
  const name2 = expr.text;
13751
13866
  for (const signal2 of ctx2.analyzer.signals) {
13752
13867
  if (signal2.getter === name2) {
@@ -13788,12 +13903,12 @@ function checkBareSignalOrMemoIdentifier(expr, ctx2) {
13788
13903
  function isArrayExprDirectPropRef(arrayExpr, ctx2) {
13789
13904
  const propNames = new Set(ctx2.patterns.props.map((p) => p.name));
13790
13905
  const propsObjName = ctx2.analyzer.propsObjectName;
13791
- if (ts12.isIdentifier(arrayExpr)) {
13906
+ if (ts13.isIdentifier(arrayExpr)) {
13792
13907
  return propNames.has(arrayExpr.text);
13793
13908
  }
13794
- if (ts12.isPropertyAccessExpression(arrayExpr) && propsObjName) {
13909
+ if (ts13.isPropertyAccessExpression(arrayExpr) && propsObjName) {
13795
13910
  const obj = arrayExpr.expression;
13796
- if (ts12.isIdentifier(obj) && obj.text === propsObjName) {
13911
+ if (ts13.isIdentifier(obj) && obj.text === propsObjName) {
13797
13912
  return true;
13798
13913
  }
13799
13914
  }
@@ -13812,7 +13927,7 @@ function referencesLoopParam(expr, ctx2) {
13812
13927
  const boundNames = ctx2.scope.valueBoundNames();
13813
13928
  if (boundNames.size === 0) return false;
13814
13929
  for (const p of boundNames) {
13815
- if (new RegExp(`\\b${p}\\b`).test(expr)) return true;
13930
+ if (identifierPattern(p).test(expr)) return true;
13816
13931
  }
13817
13932
  return false;
13818
13933
  }
@@ -13880,7 +13995,7 @@ function hasReactiveAttributes(attrs, ctx2) {
13880
13995
  const scopeValueNames = ctx2.scope.valueBoundNames();
13881
13996
  if (scopeValueNames.size > 0) {
13882
13997
  for (const p of scopeValueNames) {
13883
- if (new RegExp(`\\b${p}\\b`).test(valueToCheck)) return true;
13998
+ if (identifierPattern(p).test(valueToCheck)) return true;
13884
13999
  }
13885
14000
  }
13886
14001
  }
@@ -13965,7 +14080,7 @@ function buildIfStatementChain(analyzer, ctx2, opts) {
13965
14080
  for (const n of prevJsxBranchLocalNames) jsxBranchLocalNames.add(n);
13966
14081
  }
13967
14082
  for (const decl of condReturn.scopeVariables) {
13968
- if (ts12.isIdentifier(decl.name) && decl.initializer) {
14083
+ if (ts13.isIdentifier(decl.name) && decl.initializer) {
13969
14084
  branchScopeVars.set(decl.name.text, decl.initializer);
13970
14085
  if (initializerShapeContainsJsx(decl.initializer)) {
13971
14086
  jsxBranchLocalNames.add(decl.name.text);
@@ -14029,7 +14144,7 @@ function buildIfStatementChain(analyzer, ctx2, opts) {
14029
14144
  }
14030
14145
  const scopeVariables = [];
14031
14146
  for (const decl of condReturn.scopeVariables) {
14032
- if (ts12.isIdentifier(decl.name) && decl.initializer) {
14147
+ if (ts13.isIdentifier(decl.name) && decl.initializer) {
14033
14148
  const init = ctx2.getJS(decl.initializer);
14034
14149
  const typedInit = decl.initializer.getText(ctx2.sourceFile);
14035
14150
  scopeVariables.push({
@@ -14104,6 +14219,7 @@ var init_jsx_to_ir = __esm({
14104
14219
  init_template_parts();
14105
14220
  init_src();
14106
14221
  init_binding_scope();
14222
+ init_identifier_pattern();
14107
14223
  CLIENT_DIRECTIVE_INTERIOR_RE2 = /^\s*@client\s*$/;
14108
14224
  BLOCK_COMMENT_RE2 = /\/\*([\s\S]*?)\*\//g;
14109
14225
  EMPTY_BOUND = /* @__PURE__ */ new Set();
@@ -14113,17 +14229,19 @@ var init_jsx_to_ir = __esm({
14113
14229
  });
14114
14230
 
14115
14231
  // ../jsx/src/ir-to-client-js/prop-handling.ts
14116
- function expandDynamicPropValue(value2, ctx2) {
14232
+ function expandDynamicPropValue(value2, ctx2, scope) {
14117
14233
  const trimmedValue = value2.trim();
14234
+ if (scope?.isBound(trimmedValue)) return value2;
14118
14235
  const constant = ctx2.localConstants.find((c) => c.name === trimmedValue);
14119
14236
  if (constant && constant.value) {
14120
14237
  return constant.value;
14121
14238
  }
14122
14239
  return value2;
14123
14240
  }
14124
- function expandConstantForReactivity(expr, ctx2, originalFreeIds) {
14241
+ function expandConstantForReactivity(expr, ctx2, originalFreeIds, scope) {
14125
14242
  if (ctx2.propsObjectName) return { expr, freeIds: originalFreeIds };
14126
14243
  const trimmedValue = expr.trim();
14244
+ if (scope?.isBound(trimmedValue)) return { expr, freeIds: originalFreeIds };
14127
14245
  const constant = ctx2.localConstants.find((c) => c.name === trimmedValue);
14128
14246
  if (constant && constant.value) {
14129
14247
  return { expr: constant.value, freeIds: constant.freeIdentifiers };
@@ -14164,6 +14282,15 @@ var init_prop_handling = __esm({
14164
14282
  });
14165
14283
 
14166
14284
  // ../jsx/src/ir-to-client-js/reactivity.ts
14285
+ function buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex) {
14286
+ if (!loopParam) return void 0;
14287
+ return BindingScope.EMPTY.enterLoopRow({
14288
+ param: loopParam,
14289
+ paramBindings: loopParamBindings,
14290
+ index: loopIndex,
14291
+ preamble: preambleNames && preambleNames.size > 0 ? { declaredNames: [...preambleNames] } : void 0
14292
+ });
14293
+ }
14167
14294
  function decideWrapFromAstFlags(node) {
14168
14295
  if (node.origin && isReactiveOrigin(node.origin)) {
14169
14296
  return { wrap: true, reason: "proven-reactive" };
@@ -14185,12 +14312,12 @@ function decideWrapForChildProp(expandedValue, ctx2, prop) {
14185
14312
  }
14186
14313
  function needsEffectWrapper(expr, ctx2, freeIdentifiers2) {
14187
14314
  for (const signal2 of ctx2.signals) {
14188
- if (new RegExp(`\\b${signal2.getter}\\s*\\(`).test(expr)) {
14315
+ if (identifierCallPattern(signal2.getter).test(expr)) {
14189
14316
  return true;
14190
14317
  }
14191
14318
  }
14192
14319
  for (const memo of ctx2.memos) {
14193
- if (new RegExp(`\\b${memo.name}\\s*\\(`).test(expr)) {
14320
+ if (identifierCallPattern(memo.name).test(expr)) {
14194
14321
  return true;
14195
14322
  }
14196
14323
  }
@@ -14386,8 +14513,9 @@ function traverseForComponents(node, components, skipConditionals = false) {
14386
14513
  }
14387
14514
  });
14388
14515
  }
14389
- function collectLoopChildReactiveTexts(node, ctx2, loopParam, loopParamBindings, stopAtReactiveConditionals = false) {
14516
+ function collectLoopChildReactiveTexts(node, ctx2, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex) {
14390
14517
  const texts = [];
14518
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
14391
14519
  walkIR(node, false, {
14392
14520
  // Skip loop/async/if-statement subtrees — the original walker omitted
14393
14521
  // them; they have their own scopes (inner-loop reconciliation, async
@@ -14397,7 +14525,7 @@ function collectLoopChildReactiveTexts(node, ctx2, loopParam, loopParamBindings,
14397
14525
  if (!n.slotId) return;
14398
14526
  if (n.preambleRegion) return;
14399
14527
  const originFreeIds = freeIdsFromRefs(n.origin?.freeRefs);
14400
- const expanded = expandConstantForReactivity(n.expr, ctx2, originFreeIds);
14528
+ const expanded = expandConstantForReactivity(n.expr, ctx2, originFreeIds, scope);
14401
14529
  const reactive = classifyReactivity(expanded.expr, ctx2, loopParam, loopParamBindings, expanded.freeIds).kind !== "none" || decideWrapFromAstFlags(n).wrap;
14402
14530
  if (!reactive) return;
14403
14531
  texts.push({
@@ -14417,8 +14545,9 @@ function anyNameIn(names, set) {
14417
14545
  for (const n of names) if (set.has(n)) return true;
14418
14546
  return false;
14419
14547
  }
14420
- function collectLoopChildReactiveAttrs(node, ctx2, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames) {
14548
+ function collectLoopChildReactiveAttrs(node, ctx2, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex) {
14421
14549
  const attrs = [];
14550
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
14422
14551
  traverseElements(node, (el) => {
14423
14552
  if (el.slotId) {
14424
14553
  for (const attr of el.attrs) {
@@ -14427,7 +14556,7 @@ function collectLoopChildReactiveAttrs(node, ctx2, loopParam, loopParamBindings,
14427
14556
  if (attr.name === "key") continue;
14428
14557
  const valueStr = attrValueToString(attr.value);
14429
14558
  if (!valueStr) continue;
14430
- const expanded = expandConstantForReactivity(valueStr, ctx2, attr.freeIdentifiers);
14559
+ const expanded = expandConstantForReactivity(valueStr, ctx2, attr.freeIdentifiers, scope);
14431
14560
  const readsPreamble = preambleNames !== void 0 && preambleNames.size > 0 && anyNameIn(expanded.freeIds ?? extractFreeIdentifiersFromText(expanded.expr), preambleNames);
14432
14561
  const reactive = classifyReactivity(expanded.expr, ctx2, loopParam, loopParamBindings, expanded.freeIds).kind !== "none" || readsPreamble || attr.callsReactiveGetters || attr.hasFunctionCalls;
14433
14562
  if (!attr.clientOnly && !reactive) continue;
@@ -14452,6 +14581,8 @@ var init_reactivity = __esm({
14452
14581
  init_prop_handling();
14453
14582
  init_csr_substitute();
14454
14583
  init_walker();
14584
+ init_binding_scope();
14585
+ init_identifier_pattern();
14455
14586
  }
14456
14587
  });
14457
14588
 
@@ -14724,13 +14855,13 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx2, options2
14724
14855
  const emitDepth = fixedDepth ?? scope.depth + 1;
14725
14856
  const loopParamsForTemplate = outerLoopParam ? [outerLoopParam, { param: n.param, bindings: n.paramBindings }] : void 0;
14726
14857
  const template = n.children.map((c) => irToPlaceholderTemplate(c, void 0, emitDepth, loopParamsForTemplate)).join("");
14727
- const refsOuter = outerLoopParam ? new RegExp(`\\b${outerLoopParam}\\b`).test(n.array) : false;
14858
+ const refsOuter = outerLoopParam ? identifierPattern(outerLoopParam).test(n.array) : false;
14728
14859
  const bindings = emptyLoopChildBindings();
14729
14860
  const innerPreambleNames = preambleNamesOf(n);
14730
14861
  if (ctx2) {
14731
14862
  for (const child of n.children) {
14732
- bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx2, n.param, n.paramBindings));
14733
- bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx2, n.param, n.paramBindings, false, innerPreambleNames));
14863
+ bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx2, n.param, n.paramBindings, false, innerPreambleNames, n.index));
14864
+ bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx2, n.param, n.paramBindings, false, innerPreambleNames, n.index));
14734
14865
  bindings.refs.push(...collectLoopChildRefs(child));
14735
14866
  }
14736
14867
  }
@@ -14762,7 +14893,9 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx2, options2
14762
14893
  ctx2,
14763
14894
  siblingOffsets,
14764
14895
  n.param,
14765
- n.paramBindings
14896
+ n.paramBindings,
14897
+ innerPreambleNames,
14898
+ n.index
14766
14899
  ));
14767
14900
  }
14768
14901
  }
@@ -14944,7 +15077,7 @@ function collectElements(node, ctx2, siblingOffsets, insideConditional = false)
14944
15077
  if (!l.slotId || inCond) return;
14945
15078
  const projectionInner = l.method === "flatMap" && l.children.length === 1 && l.children[0].type === "loop" ? l.children[0] : void 0;
14946
15079
  const childHandlers = [];
14947
- const bindings = projectionInner ? emptyLoopChildBindings() : collectLoopChildBindings(l.children, ctx2, siblingOffsets, l.param, l.paramBindings, preambleNamesOf(l));
15080
+ const bindings = projectionInner ? emptyLoopChildBindings() : collectLoopChildBindings(l.children, ctx2, siblingOffsets, l.param, l.paramBindings, preambleNamesOf(l), l.index);
14948
15081
  if (!projectionInner) {
14949
15082
  for (const child of l.children) {
14950
15083
  childHandlers.push(...collectEventHandlersFromIR(child));
@@ -15196,7 +15329,7 @@ function collectBranchLoops(node, ctx2, siblingOffsets) {
15196
15329
  } else {
15197
15330
  childTemplate = n.children.map((c) => irToHtmlTemplate(c, void 0, 0, branchLoopParamSpec)).join("");
15198
15331
  }
15199
- const branchBindings = ctx2 && !projectionInner ? collectLoopChildBindings(n.children, ctx2, siblingOffsets, n.param, n.paramBindings, preambleNamesOf(n)) : emptyLoopChildBindings();
15332
+ const branchBindings = ctx2 && !projectionInner ? collectLoopChildBindings(n.children, ctx2, siblingOffsets, n.param, n.paramBindings, preambleNamesOf(n), n.index) : emptyLoopChildBindings();
15200
15333
  loops.push({
15201
15334
  kind: "branch",
15202
15335
  array: n.array,
@@ -15282,19 +15415,20 @@ function preambleNamesOf(loop) {
15282
15415
  const declared = loop.preamble?.declaredNames;
15283
15416
  return declared && declared.length > 0 ? new Set(declared) : void 0;
15284
15417
  }
15285
- function collectLoopChildBindings(children2, ctx2, siblingOffsets, loopParam, loopParamBindings, preambleNames) {
15418
+ function collectLoopChildBindings(children2, ctx2, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex) {
15286
15419
  const bindings = emptyLoopChildBindings();
15287
15420
  for (const child of children2) {
15288
15421
  bindings.events.push(...collectLoopChildEventsWithNesting(child));
15289
- bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx2, loopParam, loopParamBindings, true, preambleNames));
15290
- bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx2, loopParam, loopParamBindings, true));
15422
+ bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx2, loopParam, loopParamBindings, true, preambleNames, loopIndex));
15423
+ bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx2, loopParam, loopParamBindings, true, preambleNames, loopIndex));
15291
15424
  bindings.refs.push(...collectLoopChildRefs(child));
15292
- bindings.conditionals.push(...collectLoopChildConditionals(child, ctx2, siblingOffsets, loopParam, loopParamBindings));
15425
+ bindings.conditionals.push(...collectLoopChildConditionals(child, ctx2, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex));
15293
15426
  }
15294
15427
  return bindings;
15295
15428
  }
15296
- function collectLoopChildConditionals(node, ctx2, siblingOffsets, loopParam, loopParamBindings) {
15429
+ function collectLoopChildConditionals(node, ctx2, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex) {
15297
15430
  const conditionals = [];
15431
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
15298
15432
  const refsAnyBindingViaFreeIds = (freeIds) => {
15299
15433
  if (loopParamBindings && loopParamBindings.length > 0) {
15300
15434
  for (const b of loopParamBindings) {
@@ -15314,8 +15448,9 @@ function collectLoopChildConditionals(node, ctx2, siblingOffsets, loopParam, loo
15314
15448
  const sourceFreeIds = freeIdsFromRefs(n.origin?.freeRefs);
15315
15449
  const refsLoopParamInSource = refsAnyBindingViaFreeIds(sourceFreeIds);
15316
15450
  if (!n.reactive && !refsLoopParamInSource) return;
15317
- const expanded = expandConstantForReactivity(n.condition, ctx2, sourceFreeIds);
15318
- if (classifyReactivity(expanded.expr, ctx2, loopParam, loopParamBindings, expanded.freeIds).kind === "none") return;
15451
+ const expanded = expandConstantForReactivity(n.condition, ctx2, sourceFreeIds, scope);
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;
15319
15454
  const loopParamsForCond = loopParam ? [{ param: loopParam, bindings: loopParamBindings }] : void 0;
15320
15455
  const whenTrueHtml = irToHtmlTemplate(n.whenTrue, void 0, 0, loopParamsForCond, "__slots");
15321
15456
  const whenFalseHtml = irToHtmlTemplate(n.whenFalse, void 0, 0, loopParamsForCond, "__slots");
@@ -15324,27 +15459,28 @@ function collectLoopChildConditionals(node, ctx2, siblingOffsets, loopParam, loo
15324
15459
  condition: expanded.expr,
15325
15460
  whenTrueHtml,
15326
15461
  whenFalseHtml,
15327
- whenTrue: summarizeLoopChildBranch(n.whenTrue, ctx2, siblingOffsets, loopParam, loopParamBindings),
15328
- whenFalse: summarizeLoopChildBranch(n.whenFalse, ctx2, siblingOffsets, loopParam, loopParamBindings),
15329
- ...expanded.freeIds !== void 0 && { conditionFreeIdentifiers: expanded.freeIds }
15462
+ whenTrue: summarizeLoopChildBranch(n.whenTrue, ctx2, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex),
15463
+ whenFalse: summarizeLoopChildBranch(n.whenFalse, ctx2, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex),
15464
+ ...expanded.freeIds !== void 0 && { conditionFreeIdentifiers: expanded.freeIds },
15465
+ ...readsPreamble && { readsPreamble: true }
15330
15466
  });
15331
15467
  }
15332
15468
  });
15333
15469
  return conditionals;
15334
15470
  }
15335
- function summarizeLoopChildBranch(node, ctx2, siblingOffsets, loopParam, loopParamBindings) {
15471
+ function summarizeLoopChildBranch(node, ctx2, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex) {
15336
15472
  const inner = collectInnerLoops([node], siblingOffsets, loopParam, ctx2, branchInnerLoopOptions);
15337
15473
  return {
15338
15474
  childComponents: collectConditionalBranchChildComponents(node),
15339
15475
  innerLoops: inner.length > 0 ? inner : void 0,
15340
- conditionals: collectLoopChildConditionals(node, ctx2, siblingOffsets, loopParam, loopParamBindings),
15476
+ conditionals: collectLoopChildConditionals(node, ctx2, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex),
15341
15477
  events: collectConditionalBranchEvents(node),
15342
15478
  // Loop-param-aware — reuses the flat loop-item collectors scoped to just
15343
15479
  // this branch's subtree. Both already stop descending into any further
15344
15480
  // nested reactive conditional (own insert()/arm), so calling them here
15345
15481
  // on the branch root yields exactly this branch's direct bindings
15346
15482
  // without re-collecting what a nested arm already owns (#2347).
15347
- reactiveAttrs: collectLoopChildReactiveAttrs(node, ctx2, loopParam, loopParamBindings, true),
15483
+ reactiveAttrs: collectLoopChildReactiveAttrs(node, ctx2, loopParam, loopParamBindings, true, preambleNames, loopIndex),
15348
15484
  // Skip ONLY when the branch's entire content is a single bare
15349
15485
  // `expression` (no wrapping element) that MAY yield a live DOM node —
15350
15486
  // i.e. it contains a call anywhere (`node.hasFunctionCalls`, computed
@@ -15392,7 +15528,7 @@ function summarizeLoopChildBranch(node, ctx2, siblingOffsets, loopParam, loopPar
15392
15528
  // makes `irToHtmlTemplate` emit its `<!--bf:sN-->…<!--/-->` marker (the
15393
15529
  // same call builds both the SSR and the CSR/hydration template, so the
15394
15530
  // two can't disagree on shape).
15395
- reactiveTexts: node.type === "expression" && node.hasFunctionCalls ? [] : collectLoopChildReactiveTexts(node, ctx2, loopParam, loopParamBindings, true)
15531
+ reactiveTexts: node.type === "expression" && node.hasFunctionCalls ? [] : collectLoopChildReactiveTexts(node, ctx2, loopParam, loopParamBindings, true, preambleNames, loopIndex)
15396
15532
  };
15397
15533
  }
15398
15534
  var EMPTY_RENDER_EXPRS, branchInnerLoopOptions;
@@ -15405,8 +15541,10 @@ var init_collect_elements = __esm({
15405
15541
  init_html_template();
15406
15542
  init_template_parse();
15407
15543
  init_prop_handling();
15544
+ init_csr_substitute();
15408
15545
  init_walker();
15409
15546
  init_loop_chain();
15547
+ init_identifier_pattern();
15410
15548
  EMPTY_RENDER_EXPRS = /* @__PURE__ */ new Set(["null", "undefined", "false", "''", '""', "``"]);
15411
15549
  branchInnerLoopOptions = {
15412
15550
  collectItemBindings: true,
@@ -15761,7 +15899,7 @@ var init_build_references = __esm({
15761
15899
  });
15762
15900
 
15763
15901
  // ../jsx/src/ir-to-client-js/walk-prop-accesses.ts
15764
- import ts13 from "typescript";
15902
+ import ts14 from "typescript";
15765
15903
  function collectPropAccesses(source, propNames, out) {
15766
15904
  if (propNames.size === 0) return;
15767
15905
  let anyMentioned = false;
@@ -15773,13 +15911,13 @@ function collectPropAccesses(source, propNames, out) {
15773
15911
  }
15774
15912
  if (!anyMentioned) return;
15775
15913
  for (const expr of normaliseExpressionParts(source)) {
15776
- const sourceFile = ts13.createSourceFile(
15914
+ const sourceFile = ts14.createSourceFile(
15777
15915
  "p.ts",
15778
15916
  expr,
15779
- ts13.ScriptTarget.Latest,
15917
+ ts14.ScriptTarget.Latest,
15780
15918
  /*setParentNodes*/
15781
15919
  false,
15782
- ts13.ScriptKind.TS
15920
+ ts14.ScriptKind.TS
15783
15921
  );
15784
15922
  visit2(sourceFile, propNames, out);
15785
15923
  }
@@ -15789,15 +15927,15 @@ function normaliseExpressionParts(source) {
15789
15927
  return extractTemplateExpressions(source);
15790
15928
  }
15791
15929
  function visit2(node, propNames, out) {
15792
- if (ts13.isPropertyAccessExpression(node)) {
15930
+ if (ts14.isPropertyAccessExpression(node)) {
15793
15931
  recordIfPropAccess(node.expression, "property", propNames, out);
15794
- } else if (ts13.isElementAccessExpression(node)) {
15932
+ } else if (ts14.isElementAccessExpression(node)) {
15795
15933
  recordIfPropAccess(node.expression, "index", propNames, out);
15796
15934
  }
15797
- ts13.forEachChild(node, (child) => visit2(child, propNames, out));
15935
+ ts14.forEachChild(node, (child) => visit2(child, propNames, out));
15798
15936
  }
15799
15937
  function recordIfPropAccess(receiver, kind2, propNames, out) {
15800
- if (!ts13.isIdentifier(receiver)) return;
15938
+ if (!ts14.isIdentifier(receiver)) return;
15801
15939
  const name2 = receiver.text;
15802
15940
  if (!propNames.has(name2)) return;
15803
15941
  let kinds = out.get(name2);
@@ -15858,43 +15996,43 @@ var init_compute_prop_usage = __esm({
15858
15996
  });
15859
15997
 
15860
15998
  // ../jsx/src/value-references.ts
15861
- import ts14 from "typescript";
15999
+ import ts15 from "typescript";
15862
16000
  function isValueReferenceIdentifier(id2) {
15863
16001
  const parent2 = id2.parent;
15864
16002
  if (!parent2) return false;
15865
- if (ts14.isPropertyAccessExpression(parent2) && parent2.name === id2) return false;
15866
- if (ts14.isPropertyAssignment(parent2) && parent2.name === id2) return false;
15867
- 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) {
15868
16006
  return false;
15869
16007
  }
15870
- if (ts14.isPropertyDeclaration(parent2) && parent2.name === id2) return false;
15871
- if (ts14.isMetaProperty(parent2) && parent2.name === id2) return false;
15872
- if (ts14.isVariableDeclaration(parent2) && parent2.name === id2) return false;
15873
- if (ts14.isFunctionDeclaration(parent2) && parent2.name === id2) return false;
15874
- if (ts14.isFunctionExpression(parent2) && parent2.name === id2) return false;
15875
- if (ts14.isClassDeclaration(parent2) && parent2.name === id2) return false;
15876
- if (ts14.isClassExpression(parent2) && parent2.name === id2) return false;
15877
- if (ts14.isParameter(parent2) && parent2.name === id2) return false;
15878
- if (ts14.isBindingElement(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
15879
- if (ts14.isLabeledStatement(parent2) && parent2.label === id2) return false;
15880
- if (ts14.isBreakOrContinueStatement(parent2) && parent2.label === id2) return false;
15881
- if (ts14.isImportSpecifier(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
15882
- if (ts14.isExportSpecifier(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
15883
- if (ts14.isImportClause(parent2) && parent2.name === id2) return false;
15884
- if (ts14.isNamespaceImport(parent2) && parent2.name === id2) return false;
15885
- 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;
15886
16024
  return true;
15887
16025
  }
15888
16026
  function collectValueReferencedNames(code) {
15889
16027
  let sourceFile;
15890
16028
  try {
15891
- sourceFile = ts14.createSourceFile(
16029
+ sourceFile = ts15.createSourceFile(
15892
16030
  "generated.js",
15893
16031
  code,
15894
- ts14.ScriptTarget.Latest,
16032
+ ts15.ScriptTarget.Latest,
15895
16033
  /*setParentNodes*/
15896
16034
  true,
15897
- ts14.ScriptKind.JS
16035
+ ts15.ScriptKind.JS
15898
16036
  );
15899
16037
  } catch {
15900
16038
  return null;
@@ -15903,10 +16041,10 @@ function collectValueReferencedNames(code) {
15903
16041
  if (diagnostics && diagnostics.length > 0) return null;
15904
16042
  const names = /* @__PURE__ */ new Set();
15905
16043
  function visit3(node) {
15906
- if (ts14.isIdentifier(node) && isValueReferenceIdentifier(node)) {
16044
+ if (ts15.isIdentifier(node) && isValueReferenceIdentifier(node)) {
15907
16045
  names.add(node.text);
15908
16046
  }
15909
- ts14.forEachChild(node, visit3);
16047
+ ts15.forEachChild(node, visit3);
15910
16048
  }
15911
16049
  visit3(sourceFile);
15912
16050
  return names;
@@ -15921,7 +16059,7 @@ var init_value_references = __esm({
15921
16059
  function detectUsedImports(code) {
15922
16060
  const used = /* @__PURE__ */ new Set();
15923
16061
  for (const name2 of RUNTIME_IMPORT_CANDIDATES) {
15924
- if (new RegExp(`\\b${name2}\\s*\\(`).test(code)) {
16062
+ if (identifierCallPattern(name2).test(code)) {
15925
16063
  used.add(name2);
15926
16064
  }
15927
16065
  }
@@ -16021,6 +16159,7 @@ var init_imports = __esm({
16021
16159
  "use strict";
16022
16160
  init_builtins();
16023
16161
  init_value_references();
16162
+ init_identifier_pattern();
16024
16163
  RUNTIME_IMPORT_CANDIDATES = [
16025
16164
  "createSignal",
16026
16165
  "createMemo",
@@ -16138,23 +16277,23 @@ var init_lowering_registry = __esm({
16138
16277
  });
16139
16278
 
16140
16279
  // ../jsx/src/relocate.ts
16141
- import ts15 from "typescript";
16280
+ import ts16 from "typescript";
16142
16281
  function classify(name2, env) {
16143
16282
  return env.bindings.get(name2) ?? "global";
16144
16283
  }
16145
16284
  function collectFreeRefs(node) {
16146
16285
  const refs = /* @__PURE__ */ new Map();
16147
16286
  function visit3(n, parent2) {
16148
- if (ts15.isIdentifier(n)) {
16149
- if (parent2 && ts15.isPropertyAccessExpression(parent2) && parent2.name === n) return;
16150
- if (parent2 && ts15.isPropertyAssignment(parent2) && parent2.name === n) return;
16151
- 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;
16152
16291
  const list = refs.get(n.text) ?? [];
16153
16292
  list.push(n);
16154
16293
  refs.set(n.text, list);
16155
16294
  return;
16156
16295
  }
16157
- ts15.forEachChild(n, (child) => visit3(child, n));
16296
+ ts16.forEachChild(n, (child) => visit3(child, n));
16158
16297
  }
16159
16298
  visit3(node);
16160
16299
  return refs;
@@ -16256,9 +16395,9 @@ function isInlinableInTemplate(value2, env) {
16256
16395
  return { ok: true, rewrittenValue: r2.text, decisions: r2.decisions };
16257
16396
  }
16258
16397
  function getCalleeIdentifierPath(callee) {
16259
- if (ts15.isParenthesizedExpression(callee)) return getCalleeIdentifierPath(callee.expression);
16260
- if (ts15.isIdentifier(callee)) return callee.text;
16261
- 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)) {
16262
16401
  const left = getCalleeIdentifierPath(callee.expression);
16263
16402
  if (left === null) return null;
16264
16403
  return `${left}.${callee.name.text}`;
@@ -16266,9 +16405,9 @@ function getCalleeIdentifierPath(callee) {
16266
16405
  return null;
16267
16406
  }
16268
16407
  function getCalleeLeftmostIdentifier(callee) {
16269
- if (ts15.isParenthesizedExpression(callee)) return getCalleeLeftmostIdentifier(callee.expression);
16270
- if (ts15.isIdentifier(callee)) return callee.text;
16271
- 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)) {
16272
16411
  return getCalleeLeftmostIdentifier(callee.expression);
16273
16412
  }
16274
16413
  return null;
@@ -16307,17 +16446,17 @@ function isCallAcceptedByAdapter(call, env) {
16307
16446
  }
16308
16447
  function parseExpressionNode(text) {
16309
16448
  try {
16310
- const sf = ts15.createSourceFile(
16449
+ const sf = ts16.createSourceFile(
16311
16450
  "__inline_check__.ts",
16312
16451
  `(${text});`,
16313
- ts15.ScriptTarget.Latest,
16452
+ ts16.ScriptTarget.Latest,
16314
16453
  false,
16315
- ts15.ScriptKind.TS
16454
+ ts16.ScriptKind.TS
16316
16455
  );
16317
16456
  const stmt = sf.statements[0];
16318
- if (!stmt || !ts15.isExpressionStatement(stmt)) return null;
16457
+ if (!stmt || !ts16.isExpressionStatement(stmt)) return null;
16319
16458
  const inner = stmt.expression;
16320
- return ts15.isParenthesizedExpression(inner) ? inner.expression : inner;
16459
+ return ts16.isParenthesizedExpression(inner) ? inner.expression : inner;
16321
16460
  } catch {
16322
16461
  return null;
16323
16462
  }
@@ -16331,8 +16470,8 @@ function hasCallWithBridgedArg(node, decisions, env) {
16331
16470
  let found = false;
16332
16471
  function visit3(n) {
16333
16472
  if (found) return;
16334
- if (ts15.isCallExpression(n) || ts15.isNewExpression(n)) {
16335
- 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);
16336
16475
  if (!accepted) {
16337
16476
  const args2 = n.arguments;
16338
16477
  if (args2) {
@@ -16345,7 +16484,7 @@ function hasCallWithBridgedArg(node, decisions, env) {
16345
16484
  }
16346
16485
  }
16347
16486
  }
16348
- ts15.forEachChild(n, visit3);
16487
+ ts16.forEachChild(n, visit3);
16349
16488
  }
16350
16489
  visit3(node);
16351
16490
  return found;
@@ -16354,13 +16493,13 @@ function hasZeroArgCall(node, env) {
16354
16493
  let found = false;
16355
16494
  function visit3(n) {
16356
16495
  if (found) return;
16357
- if (ts15.isCallExpression(n) && n.arguments.length === 0) {
16496
+ if (ts16.isCallExpression(n) && n.arguments.length === 0) {
16358
16497
  if (!isCallAcceptedByAdapter(n, env)) {
16359
16498
  found = true;
16360
16499
  return;
16361
16500
  }
16362
16501
  }
16363
- ts15.forEachChild(n, visit3);
16502
+ ts16.forEachChild(n, visit3);
16364
16503
  }
16365
16504
  visit3(node);
16366
16505
  return found;
@@ -16369,25 +16508,25 @@ function containsAnyIdentifier(node, names) {
16369
16508
  let found = false;
16370
16509
  function visit3(n) {
16371
16510
  if (found) return;
16372
- if (ts15.isPropertyAccessExpression(n)) {
16511
+ if (ts16.isPropertyAccessExpression(n)) {
16373
16512
  visit3(n.expression);
16374
16513
  return;
16375
16514
  }
16376
- if (ts15.isPropertyAssignment(n)) {
16515
+ if (ts16.isPropertyAssignment(n)) {
16377
16516
  visit3(n.initializer);
16378
16517
  return;
16379
16518
  }
16380
- if (ts15.isShorthandPropertyAssignment(n)) {
16381
- 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)) {
16382
16521
  found = true;
16383
16522
  }
16384
16523
  return;
16385
16524
  }
16386
- if (ts15.isIdentifier(n) && names.has(n.text)) {
16525
+ if (ts16.isIdentifier(n) && names.has(n.text)) {
16387
16526
  found = true;
16388
16527
  return;
16389
16528
  }
16390
- ts15.forEachChild(n, visit3);
16529
+ ts16.forEachChild(n, visit3);
16391
16530
  }
16392
16531
  visit3(node);
16393
16532
  return found;
@@ -16395,7 +16534,7 @@ function containsAnyIdentifier(node, names) {
16395
16534
  function scanRefsByName(text, bindings) {
16396
16535
  const result2 = /* @__PURE__ */ new Map();
16397
16536
  for (const name2 of bindings.keys()) {
16398
- const re = new RegExp(`\\b${name2}\\b`);
16537
+ const re = identifierPattern(name2);
16399
16538
  if (re.test(text)) result2.set(name2, []);
16400
16539
  }
16401
16540
  return result2;
@@ -16488,6 +16627,7 @@ var init_relocate = __esm({
16488
16627
  init_props_binding();
16489
16628
  init_expression_parser();
16490
16629
  init_lowering_registry();
16630
+ init_identifier_pattern();
16491
16631
  REGISTRY_SAFE_BINDING_KINDS = /* @__PURE__ */ new Set([
16492
16632
  "global",
16493
16633
  "module-import",
@@ -17716,19 +17856,19 @@ var init_emit_module_level = __esm({
17716
17856
  });
17717
17857
 
17718
17858
  // ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
17719
- import ts16 from "typescript";
17859
+ import ts17 from "typescript";
17720
17860
  function propExtractionName(stmt) {
17721
- if (!ts16.isVariableStatement(stmt)) return null;
17861
+ if (!ts17.isVariableStatement(stmt)) return null;
17722
17862
  const decls = stmt.declarationList.declarations;
17723
17863
  if (decls.length !== 1) return null;
17724
17864
  const decl = decls[0];
17725
- if (!ts16.isIdentifier(decl.name) || !decl.initializer) return null;
17865
+ if (!ts17.isIdentifier(decl.name) || !decl.initializer) return null;
17726
17866
  let core = decl.initializer;
17727
- if (ts16.isBinaryExpression(core) && core.operatorToken.kind === ts16.SyntaxKind.QuestionQuestionToken) {
17867
+ if (ts17.isBinaryExpression(core) && core.operatorToken.kind === ts17.SyntaxKind.QuestionQuestionToken) {
17728
17868
  core = core.left;
17729
17869
  }
17730
- if (!ts16.isPropertyAccessExpression(core)) return null;
17731
- 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;
17732
17872
  if (core.name.text !== decl.name.text) return null;
17733
17873
  return decl.name.text;
17734
17874
  }
@@ -17739,17 +17879,17 @@ function pruneUnusedPropExtractions(code) {
17739
17879
  console.warn("[barefootjs] pruneUnusedPropExtractions: generated code did not parse; skipping prune");
17740
17880
  return code;
17741
17881
  }
17742
- const sourceFile = ts16.createSourceFile(
17882
+ const sourceFile = ts17.createSourceFile(
17743
17883
  "generated.js",
17744
17884
  code,
17745
- ts16.ScriptTarget.Latest,
17885
+ ts17.ScriptTarget.Latest,
17746
17886
  /*setParentNodes*/
17747
17887
  false,
17748
- ts16.ScriptKind.JS
17888
+ ts17.ScriptKind.JS
17749
17889
  );
17750
17890
  const spans = [];
17751
17891
  for (const stmt of sourceFile.statements) {
17752
- 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;
17753
17893
  for (const inner of stmt.body.statements) {
17754
17894
  const name2 = propExtractionName(inner);
17755
17895
  if (name2 !== null && !referenced.has(name2)) {
@@ -18794,7 +18934,8 @@ function buildReactiveEffectsPlan(args2) {
18794
18934
  whenTrueTemplateHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
18795
18935
  whenFalseTemplateHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId),
18796
18936
  whenTrueArm: buildOuterArm(cond.whenTrue, wrap, loopParam, loopParamBindings, profileComponentName),
18797
- whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, profileComponentName)
18937
+ whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, profileComponentName),
18938
+ ...cond.readsPreamble && { readsPreamble: true }
18798
18939
  });
18799
18940
  }
18800
18941
  }
@@ -19242,7 +19383,7 @@ function buildStaticArrayDelegationPlan(elem, profileComponentName) {
19242
19383
  function buildKeyedOrIndexLookup(args2) {
19243
19384
  const hasBindings = (args2.paramBindings?.length ?? 0) > 0;
19244
19385
  if (args2.key !== null) {
19245
- const keyWithItem = hasBindings ? substituteLoopBindings(args2.key, args2.paramBindings, "item") : args2.key.replace(new RegExp(`\\b${args2.param}\\b`, "g"), "item");
19386
+ const keyWithItem = hasBindings ? substituteLoopBindings(args2.key, args2.paramBindings, "item") : args2.key.replace(identifierPattern(args2.param, "g"), "item");
19246
19387
  return {
19247
19388
  kind: "keyed",
19248
19389
  arrayExpr: args2.array,
@@ -19269,6 +19410,7 @@ var init_build_event_delegation = __esm({
19269
19410
  "../jsx/src/ir-to-client-js/control-flow/plan/build-event-delegation.ts"() {
19270
19411
  "use strict";
19271
19412
  init_utils();
19413
+ init_identifier_pattern();
19272
19414
  init_html_template();
19273
19415
  }
19274
19416
  });
@@ -19327,7 +19469,7 @@ var init_lazy_conditional = __esm({
19327
19469
  });
19328
19470
 
19329
19471
  // ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
19330
- import ts17 from "typescript";
19472
+ import ts18 from "typescript";
19331
19473
  function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19332
19474
  if (!preamble) return NO_PREAMBLE;
19333
19475
  if (preamble.builderNames.length > 0) {
@@ -19339,19 +19481,19 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19339
19481
  const text = preambleAnalysisText(preamble);
19340
19482
  if (text.trim().length === 0) return NO_PREAMBLE;
19341
19483
  const declaredNames = /* @__PURE__ */ new Set();
19342
- const sf = ts17.createSourceFile(
19484
+ const sf = ts18.createSourceFile(
19343
19485
  "__lazy_preamble__.ts",
19344
19486
  text,
19345
- ts17.ScriptTarget.Latest,
19487
+ ts18.ScriptTarget.Latest,
19346
19488
  /* setParentNodes */
19347
19489
  true,
19348
- ts17.ScriptKind.TS
19490
+ ts18.ScriptKind.TS
19349
19491
  );
19350
19492
  for (const stmt of sf.statements) {
19351
- if (!ts17.isVariableStatement(stmt)) {
19352
- 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]})`);
19353
19495
  }
19354
- const isConst = (stmt.declarationList.flags & ts17.NodeFlags.Const) !== 0;
19496
+ const isConst = (stmt.declarationList.flags & ts18.NodeFlags.Const) !== 0;
19355
19497
  if (!isConst) return NO2("map-callback preamble declares a mutable binding (let/var)");
19356
19498
  for (const decl of stmt.declarationList.declarations) {
19357
19499
  collectBindingNames3(decl.name, declaredNames);
@@ -19378,12 +19520,12 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19378
19520
  return { lazySafe: true, facts: { declaredNames, freeNames } };
19379
19521
  }
19380
19522
  function collectBindingNames3(name2, out) {
19381
- if (ts17.isIdentifier(name2)) {
19523
+ if (ts18.isIdentifier(name2)) {
19382
19524
  out.add(name2.text);
19383
19525
  return;
19384
19526
  }
19385
19527
  for (const element of name2.elements) {
19386
- if (ts17.isOmittedExpression(element)) continue;
19528
+ if (ts18.isOmittedExpression(element)) continue;
19387
19529
  collectBindingNames3(element.name, out);
19388
19530
  }
19389
19531
  }
@@ -19391,56 +19533,56 @@ function findImpureNode(root2, primableNames) {
19391
19533
  let found = null;
19392
19534
  const visit3 = (node) => {
19393
19535
  if (found) return;
19394
- if (ts17.isCallExpression(node)) {
19536
+ if (ts18.isCallExpression(node)) {
19395
19537
  const callee = node.expression;
19396
- 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;
19397
19539
  if (!isSignalRead) {
19398
19540
  found = `call to ${callee.getText(callee.getSourceFile())}`;
19399
19541
  return;
19400
19542
  }
19401
19543
  }
19402
- if (ts17.isNewExpression(node)) {
19544
+ if (ts18.isNewExpression(node)) {
19403
19545
  found = "new expression";
19404
19546
  return;
19405
19547
  }
19406
- if (ts17.isTaggedTemplateExpression(node)) {
19548
+ if (ts18.isTaggedTemplateExpression(node)) {
19407
19549
  found = "tagged template";
19408
19550
  return;
19409
19551
  }
19410
- if (ts17.isAwaitExpression(node)) {
19552
+ if (ts18.isAwaitExpression(node)) {
19411
19553
  found = "await";
19412
19554
  return;
19413
19555
  }
19414
- if (ts17.isYieldExpression(node)) {
19556
+ if (ts18.isYieldExpression(node)) {
19415
19557
  found = "yield";
19416
19558
  return;
19417
19559
  }
19418
- if (ts17.isPrefixUnaryExpression(node) || ts17.isPostfixUnaryExpression(node)) {
19560
+ if (ts18.isPrefixUnaryExpression(node) || ts18.isPostfixUnaryExpression(node)) {
19419
19561
  const op = node.operator;
19420
- if (op === ts17.SyntaxKind.PlusPlusToken || op === ts17.SyntaxKind.MinusMinusToken) {
19562
+ if (op === ts18.SyntaxKind.PlusPlusToken || op === ts18.SyntaxKind.MinusMinusToken) {
19421
19563
  found = "increment/decrement";
19422
19564
  return;
19423
19565
  }
19424
19566
  }
19425
- if (ts17.isDeleteExpression(node)) {
19567
+ if (ts18.isDeleteExpression(node)) {
19426
19568
  found = "delete";
19427
19569
  return;
19428
19570
  }
19429
- if (ts17.isFunctionExpression(node) || ts17.isArrowFunction(node) || ts17.isClassExpression(node)) {
19571
+ if (ts18.isFunctionExpression(node) || ts18.isArrowFunction(node) || ts18.isClassExpression(node)) {
19430
19572
  found = "function or class expression";
19431
19573
  return;
19432
19574
  }
19433
- if (ts17.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
19575
+ if (ts18.isBinaryExpression(node) && isAssignmentOperator2(node.operatorToken.kind)) {
19434
19576
  found = "assignment";
19435
19577
  return;
19436
19578
  }
19437
- ts17.forEachChild(node, visit3);
19579
+ ts18.forEachChild(node, visit3);
19438
19580
  };
19439
19581
  visit3(root2);
19440
19582
  return found;
19441
19583
  }
19442
- function isAssignmentOperator(kind2) {
19443
- return kind2 >= ts17.SyntaxKind.FirstAssignment && kind2 <= ts17.SyntaxKind.LastAssignment;
19584
+ function isAssignmentOperator2(kind2) {
19585
+ return kind2 >= ts18.SyntaxKind.FirstAssignment && kind2 <= ts18.SyntaxKind.LastAssignment;
19444
19586
  }
19445
19587
  var NO_PREAMBLE, NO2;
19446
19588
  var init_lazy_preamble = __esm({
@@ -20038,7 +20180,7 @@ var init_claim_plan = __esm({
20038
20180
  });
20039
20181
 
20040
20182
  // ../jsx/src/ir-to-client-js/emit-reactive.ts
20041
- import ts18 from "typescript";
20183
+ import ts19 from "typescript";
20042
20184
  function bindingIdArg(ctx2, slotId) {
20043
20185
  if (!ctx2.profile || !slotId) return "";
20044
20186
  return `, ${JSON.stringify(`${ctx2.componentName}#binding:${slotId}`)}`;
@@ -20119,19 +20261,19 @@ function lowerToLocaleCallsInReactiveExpr(expr, matcher) {
20119
20261
  if (!matcher) return expr;
20120
20262
  let sourceFile;
20121
20263
  try {
20122
- 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);
20123
20265
  } catch {
20124
20266
  return expr;
20125
20267
  }
20126
20268
  const stmt = sourceFile.statements[0];
20127
- if (!stmt || !ts18.isExpressionStatement(stmt)) return expr;
20128
- 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;
20129
20271
  const candidates = [];
20130
20272
  const visit3 = (n) => {
20131
- 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") {
20132
20274
  candidates.push(n);
20133
20275
  }
20134
- ts18.forEachChild(n, visit3);
20276
+ ts19.forEachChild(n, visit3);
20135
20277
  };
20136
20278
  visit3(root2);
20137
20279
  if (candidates.length === 0) return expr;
@@ -20168,19 +20310,19 @@ function lowerDateCallsInReactiveExpr(expr, matcher) {
20168
20310
  if (!matcher) return expr;
20169
20311
  let sourceFile;
20170
20312
  try {
20171
- 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);
20172
20314
  } catch {
20173
20315
  return expr;
20174
20316
  }
20175
20317
  const stmt = sourceFile.statements[0];
20176
- if (!stmt || !ts18.isExpressionStatement(stmt)) return expr;
20177
- 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;
20178
20320
  const candidates = [];
20179
20321
  const visit3 = (n) => {
20180
- 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)) {
20181
20323
  candidates.push(n);
20182
20324
  }
20183
- ts18.forEachChild(n, visit3);
20325
+ ts19.forEachChild(n, visit3);
20184
20326
  };
20185
20327
  visit3(root2);
20186
20328
  if (candidates.length === 0) return expr;
@@ -20538,7 +20680,7 @@ function stringifyReactiveEffects(lines, plan, opts) {
20538
20680
  );
20539
20681
  }
20540
20682
  for (const cond of conditionals) {
20541
- emitOuterConditional(lines, indent, elVar, cond, pc);
20683
+ emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped);
20542
20684
  }
20543
20685
  }
20544
20686
  function emitAttrSlotsGranular(lines, indent, elVar, lookup, attrSlots, elementIndexBySlot, bindingBfId, mapPreambleWrapped) {
@@ -20636,9 +20778,10 @@ function emitOuterTexts(lines, indent, elVar, texts, bindingBfId, textClaimPathE
20636
20778
  lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}', String(${text.wrappedExpression})) }${bindingBfId(text.slotId)})`);
20637
20779
  }
20638
20780
  }
20639
- function emitOuterConditional(lines, indent, elVar, cond, pc) {
20781
+ function emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped) {
20640
20782
  const armIndent = `${indent} `;
20641
- 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}, {`);
20642
20785
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenTrueTemplateHtml}\`, slots: __slots } },`);
20643
20786
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
20644
20787
  stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc);
@@ -21558,7 +21701,7 @@ function emitKeyedLookup(ls, ev, handlerCall, lookup) {
21558
21701
  }
21559
21702
  for (const nested of ev.nestedLoops) {
21560
21703
  const rawKey = nested.key ?? "";
21561
- const innerKeyExpr = nested.paramBindings && nested.paramBindings.length > 0 ? substituteLoopBindings(rawKey, nested.paramBindings, "item") : rawKey.replace(new RegExp(`\\b${nested.param}\\b`, "g"), "item");
21704
+ const innerKeyExpr = nested.paramBindings && nested.paramBindings.length > 0 ? substituteLoopBindings(rawKey, nested.paramBindings, "item") : rawKey.replace(identifierPattern(nested.param, "g"), "item");
21562
21705
  const outerRef = hasBindings ? "__bfLoopItem" : param;
21563
21706
  ls.push(` const ${nested.param} = ${outerRef} && ${nested.array}.find(item => String(${innerKeyExpr}) === innerKey${nested.depth})`);
21564
21707
  }
@@ -21619,6 +21762,7 @@ var init_event_delegation = __esm({
21619
21762
  "use strict";
21620
21763
  init_utils();
21621
21764
  init_csr_substitute();
21765
+ init_identifier_pattern();
21622
21766
  NON_BUBBLING_EVENTS = /* @__PURE__ */ new Set([
21623
21767
  "blur",
21624
21768
  "focus",
@@ -22363,25 +22507,25 @@ var init_phases = __esm({
22363
22507
  });
22364
22508
 
22365
22509
  // ../jsx/src/ir-to-client-js/rewrite-props-object.ts
22366
- import ts19 from "typescript";
22510
+ import ts20 from "typescript";
22367
22511
  function rewritePropsObjectRef(code, propsObjectName) {
22368
22512
  const srcPropsName = propsObjectName ?? "props";
22369
22513
  if (srcPropsName === PROPS_PARAM) return code;
22370
- if (!new RegExp(`\\b${srcPropsName}\\b`).test(code)) return code;
22371
- const sourceFile = ts19.createSourceFile(
22514
+ if (!identifierPattern(srcPropsName).test(code)) return code;
22515
+ const sourceFile = ts20.createSourceFile(
22372
22516
  "init-body.ts",
22373
22517
  code,
22374
- ts19.ScriptTarget.Latest,
22518
+ ts20.ScriptTarget.Latest,
22375
22519
  /*setParentNodes*/
22376
22520
  true,
22377
- ts19.ScriptKind.TS
22521
+ ts20.ScriptKind.TS
22378
22522
  );
22379
22523
  const spans = [];
22380
22524
  function visit3(node) {
22381
- if (ts19.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
22525
+ if (ts20.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
22382
22526
  spans.push([node.getStart(sourceFile), node.getEnd()]);
22383
22527
  }
22384
- ts19.forEachChild(node, visit3);
22528
+ ts20.forEachChild(node, visit3);
22385
22529
  }
22386
22530
  visit3(sourceFile);
22387
22531
  if (spans.length === 0) return code;
@@ -22395,18 +22539,19 @@ function rewritePropsObjectRef(code, propsObjectName) {
22395
22539
  function shouldRewrite(node) {
22396
22540
  const parent2 = node.parent;
22397
22541
  if (!parent2) return true;
22398
- if (ts19.isPropertyAccessExpression(parent2) && parent2.name === node) return false;
22399
- if (ts19.isPropertyAssignment(parent2) && parent2.name === node) return false;
22400
- if (ts19.isShorthandPropertyAssignment(parent2) && parent2.name === node) return false;
22401
- if (ts19.isPropertySignature(parent2) && parent2.name === node) return false;
22402
- if (ts19.isPropertyDeclaration(parent2) && parent2.name === node) return false;
22403
- 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;
22404
22548
  return true;
22405
22549
  }
22406
22550
  var init_rewrite_props_object = __esm({
22407
22551
  "../jsx/src/ir-to-client-js/rewrite-props-object.ts"() {
22408
22552
  "use strict";
22409
22553
  init_utils();
22554
+ init_identifier_pattern();
22410
22555
  }
22411
22556
  });
22412
22557
 
@@ -23106,7 +23251,7 @@ var init_css_layer_prefixer = __esm({
23106
23251
  });
23107
23252
 
23108
23253
  // ../jsx/src/preprocess-inline-jsx-callbacks.ts
23109
- import ts20 from "typescript";
23254
+ import ts21 from "typescript";
23110
23255
  function preprocessInlineJsxCallbacks(source, filePath) {
23111
23256
  const errors = [];
23112
23257
  const syntheticNames = [];
@@ -23126,15 +23271,15 @@ function preprocessInlineJsxCallbacks(source, filePath) {
23126
23271
  return { source: current, errors, syntheticNames };
23127
23272
  }
23128
23273
  function runSinglePass(source, filePath, startingCounter) {
23129
- const sourceFile = ts20.createSourceFile(
23274
+ const sourceFile = ts21.createSourceFile(
23130
23275
  filePath,
23131
23276
  source,
23132
- ts20.ScriptTarget.Latest,
23277
+ ts21.ScriptTarget.Latest,
23133
23278
  true,
23134
- ts20.ScriptKind.TSX
23279
+ ts21.ScriptKind.TSX
23135
23280
  );
23136
23281
  const hasUseClient = sourceFile.statements.some(
23137
- (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'")
23138
23283
  );
23139
23284
  if (!hasUseClient) {
23140
23285
  return { source, errors: [], syntheticNames: [], counterAfter: startingCounter };
@@ -23157,20 +23302,20 @@ function runSinglePass(source, filePath, startingCounter) {
23157
23302
  }
23158
23303
  }
23159
23304
  function visit3(node) {
23160
- 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) {
23161
23306
  if (tryHandleArrowValue(node.initializer.expression)) {
23162
23307
  return;
23163
23308
  }
23164
23309
  }
23165
- if (ts20.isPropertyAssignment(node) && node.initializer) {
23310
+ if (ts21.isPropertyAssignment(node) && node.initializer) {
23166
23311
  if (tryHandleArrowValue(node.initializer)) return;
23167
23312
  }
23168
- ts20.forEachChild(node, visit3);
23313
+ ts21.forEachChild(node, visit3);
23169
23314
  }
23170
23315
  function tryHandleArrowValue(initializer) {
23171
23316
  let expr = initializer;
23172
- while (ts20.isParenthesizedExpression(expr)) expr = expr.expression;
23173
- if (ts20.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
23317
+ while (ts21.isParenthesizedExpression(expr)) expr = expr.expression;
23318
+ if (ts21.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
23174
23319
  return handleInlineArrow(expr);
23175
23320
  }
23176
23321
  return false;
@@ -23205,7 +23350,7 @@ function runSinglePass(source, filePath, startingCounter) {
23205
23350
  replacements.push({ start: arrowStart, end: arrowEnd, text: name2 });
23206
23351
  return true;
23207
23352
  }
23208
- ts20.forEachChild(sourceFile, visit3);
23353
+ ts21.forEachChild(sourceFile, visit3);
23209
23354
  if (replacements.length === 0) {
23210
23355
  return { source, errors, syntheticNames, counterAfter: counter };
23211
23356
  }
@@ -23224,33 +23369,33 @@ function errorMessageForCapture(captures) {
23224
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.`;
23225
23370
  }
23226
23371
  function arrowBodyContainsJsx(arrow) {
23227
- if (ts20.isBlock(arrow.body)) {
23372
+ if (ts21.isBlock(arrow.body)) {
23228
23373
  return blockReturnsJsx(arrow.body);
23229
23374
  }
23230
23375
  let body2 = arrow.body;
23231
- while (ts20.isParenthesizedExpression(body2)) body2 = body2.expression;
23376
+ while (ts21.isParenthesizedExpression(body2)) body2 = body2.expression;
23232
23377
  return isJsxLike(body2);
23233
23378
  }
23234
23379
  function blockReturnsJsx(block) {
23235
23380
  let found = false;
23236
23381
  function visit3(n) {
23237
23382
  if (found) return;
23238
- if (ts20.isReturnStatement(n) && n.expression) {
23383
+ if (ts21.isReturnStatement(n) && n.expression) {
23239
23384
  let e = n.expression;
23240
- while (ts20.isParenthesizedExpression(e)) e = e.expression;
23385
+ while (ts21.isParenthesizedExpression(e)) e = e.expression;
23241
23386
  if (isJsxLike(e)) {
23242
23387
  found = true;
23243
23388
  return;
23244
23389
  }
23245
23390
  }
23246
- if (ts20.isArrowFunction(n) || ts20.isFunctionDeclaration(n) || ts20.isFunctionExpression(n)) return;
23247
- ts20.forEachChild(n, visit3);
23391
+ if (ts21.isArrowFunction(n) || ts21.isFunctionDeclaration(n) || ts21.isFunctionExpression(n)) return;
23392
+ ts21.forEachChild(n, visit3);
23248
23393
  }
23249
- ts20.forEachChild(block, visit3);
23394
+ ts21.forEachChild(block, visit3);
23250
23395
  return found;
23251
23396
  }
23252
23397
  function isJsxLike(expr) {
23253
- return ts20.isJsxElement(expr) || ts20.isJsxSelfClosingElement(expr) || ts20.isJsxFragment(expr);
23398
+ return ts21.isJsxElement(expr) || ts21.isJsxSelfClosingElement(expr) || ts21.isJsxFragment(expr);
23254
23399
  }
23255
23400
  function collectArrowParamNames(arrow) {
23256
23401
  const names = /* @__PURE__ */ new Set();
@@ -23259,13 +23404,13 @@ function collectArrowParamNames(arrow) {
23259
23404
  }
23260
23405
  function collectBindingNames4(name2, out) {
23261
23406
  const push = Array.isArray(out) ? (n) => out.push(n) : (n) => out.add(n);
23262
- if (ts20.isIdentifier(name2)) {
23407
+ if (ts21.isIdentifier(name2)) {
23263
23408
  push(name2.text);
23264
- } else if (ts20.isObjectBindingPattern(name2)) {
23409
+ } else if (ts21.isObjectBindingPattern(name2)) {
23265
23410
  name2.elements.forEach((el) => collectBindingNames4(el.name, out));
23266
- } else if (ts20.isArrayBindingPattern(name2)) {
23411
+ } else if (ts21.isArrayBindingPattern(name2)) {
23267
23412
  name2.elements.forEach((el) => {
23268
- if (!ts20.isOmittedExpression(el)) collectBindingNames4(el.name, out);
23413
+ if (!ts21.isOmittedExpression(el)) collectBindingNames4(el.name, out);
23269
23414
  });
23270
23415
  }
23271
23416
  }
@@ -23290,71 +23435,71 @@ function collectFreeIdentifiers(arrow) {
23290
23435
  return bound.includes(name2);
23291
23436
  }
23292
23437
  function visit3(node) {
23293
- if (ts20.isIdentifier(node)) {
23438
+ if (ts21.isIdentifier(node)) {
23294
23439
  const parent2 = node.parent;
23295
- if (parent2 && ts20.isPropertyAccessExpression(parent2) && parent2.name === node) return;
23296
- if (parent2 && ts20.isPropertyAssignment(parent2) && parent2.name === node) return;
23297
- if (parent2 && ts20.isPropertySignature(parent2) && parent2.name === node) return;
23298
- if (parent2 && ts20.isPropertyDeclaration(parent2) && parent2.name === node) return;
23299
- if (parent2 && ts20.isMethodDeclaration(parent2) && parent2.name === node) return;
23300
- if (parent2 && ts20.isMethodSignature(parent2) && parent2.name === node) return;
23301
- if (parent2 && ts20.isGetAccessorDeclaration(parent2) && parent2.name === node) return;
23302
- if (parent2 && ts20.isSetAccessorDeclaration(parent2) && parent2.name === node) return;
23303
- if (parent2 && ts20.isEnumMember(parent2) && parent2.name === node) return;
23304
- if (parent2 && ts20.isBindingElement(parent2) && parent2.propertyName === node) return;
23305
- 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) {
23306
23451
  if (!isBound(node.text)) ids.add(node.text);
23307
23452
  return;
23308
23453
  }
23309
- if (parent2 && ts20.isParameter(parent2) && parent2.name === node) return;
23310
- if (parent2 && ts20.isVariableDeclaration(parent2) && parent2.name === node) return;
23311
- if (parent2 && ts20.isFunctionDeclaration(parent2) && parent2.name === node) return;
23312
- if (parent2 && ts20.isClassDeclaration(parent2) && parent2.name === node) return;
23313
- if (parent2 && ts20.isJsxAttribute(parent2) && parent2.name === node) return;
23314
- 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) {
23315
23460
  if (/^[a-z]/.test(node.text)) return;
23316
23461
  }
23317
- if (parent2 && ts20.isJsxClosingElement(parent2) && parent2.tagName === node) {
23462
+ if (parent2 && ts21.isJsxClosingElement(parent2) && parent2.tagName === node) {
23318
23463
  if (/^[a-z]/.test(node.text)) return;
23319
23464
  }
23320
23465
  if (isBound(node.text)) return;
23321
23466
  ids.add(node.text);
23322
23467
  return;
23323
23468
  }
23324
- if (ts20.isVariableDeclaration(node)) {
23469
+ if (ts21.isVariableDeclaration(node)) {
23325
23470
  const declared = pushBindings(node.name);
23326
23471
  if (node.initializer) visit3(node.initializer);
23327
23472
  declared;
23328
23473
  return;
23329
23474
  }
23330
- if (ts20.isFunctionDeclaration(node)) {
23475
+ if (ts21.isFunctionDeclaration(node)) {
23331
23476
  if (node.name) bound.push(node.name.text);
23332
23477
  visitInsideNewScope(node);
23333
23478
  return;
23334
23479
  }
23335
- if (ts20.isClassDeclaration(node)) {
23480
+ if (ts21.isClassDeclaration(node)) {
23336
23481
  if (node.name) bound.push(node.name.text);
23337
- ts20.forEachChild(node, visit3);
23482
+ ts21.forEachChild(node, visit3);
23338
23483
  return;
23339
23484
  }
23340
- if (ts20.isArrowFunction(node) || ts20.isFunctionExpression(node)) {
23485
+ if (ts21.isArrowFunction(node) || ts21.isFunctionExpression(node)) {
23341
23486
  visitInsideNewScope(node);
23342
23487
  return;
23343
23488
  }
23344
- if (ts20.isCatchClause(node)) {
23489
+ if (ts21.isCatchClause(node)) {
23345
23490
  const before = bound.length;
23346
23491
  if (node.variableDeclaration) pushBindings(node.variableDeclaration.name);
23347
- ts20.forEachChild(node, visit3);
23492
+ ts21.forEachChild(node, visit3);
23348
23493
  popN(bound.length - before);
23349
23494
  return;
23350
23495
  }
23351
- if (ts20.isBlock(node)) {
23496
+ if (ts21.isBlock(node)) {
23352
23497
  const before = bound.length;
23353
- ts20.forEachChild(node, visit3);
23498
+ ts21.forEachChild(node, visit3);
23354
23499
  popN(bound.length - before);
23355
23500
  return;
23356
23501
  }
23357
- ts20.forEachChild(node, visit3);
23502
+ ts21.forEachChild(node, visit3);
23358
23503
  }
23359
23504
  function visitInsideNewScope(fn) {
23360
23505
  const before = bound.length;
@@ -23374,27 +23519,27 @@ function collectFreeIdentifiers(arrow) {
23374
23519
  function collectModuleScopeNames(sourceFile) {
23375
23520
  const names = /* @__PURE__ */ new Set();
23376
23521
  for (const stmt of sourceFile.statements) {
23377
- if (ts20.isFunctionDeclaration(stmt) && stmt.name) names.add(stmt.name.text);
23378
- else if (ts20.isClassDeclaration(stmt) && stmt.name) names.add(stmt.name.text);
23379
- 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)) {
23380
23525
  for (const decl of stmt.declarationList.declarations) collectBindingNames4(decl.name, names);
23381
- } else if (ts20.isImportDeclaration(stmt) && stmt.importClause) {
23526
+ } else if (ts21.isImportDeclaration(stmt) && stmt.importClause) {
23382
23527
  const ic = stmt.importClause;
23383
23528
  if (ic.name) names.add(ic.name.text);
23384
23529
  if (ic.namedBindings) {
23385
- if (ts20.isNamespaceImport(ic.namedBindings)) names.add(ic.namedBindings.name.text);
23530
+ if (ts21.isNamespaceImport(ic.namedBindings)) names.add(ic.namedBindings.name.text);
23386
23531
  else for (const e of ic.namedBindings.elements) names.add(e.name.text);
23387
23532
  }
23388
- } else if (ts20.isTypeAliasDeclaration(stmt)) names.add(stmt.name.text);
23389
- else if (ts20.isInterfaceDeclaration(stmt)) names.add(stmt.name.text);
23390
- 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);
23391
23536
  }
23392
23537
  return names;
23393
23538
  }
23394
23539
  function buildSyntheticDeclaration(name2, arrow, sourceFile) {
23395
23540
  const paramsText = arrow.parameters.length === 0 ? "" : arrow.parameters.map((p) => p.getText(sourceFile)).join(", ");
23396
23541
  let bodyText;
23397
- if (ts20.isBlock(arrow.body)) {
23542
+ if (ts21.isBlock(arrow.body)) {
23398
23543
  bodyText = arrow.body.getText(sourceFile);
23399
23544
  } else {
23400
23545
  const expr = arrow.body.getText(sourceFile);
@@ -23413,7 +23558,7 @@ var init_preprocess_inline_jsx_callbacks = __esm({
23413
23558
  });
23414
23559
 
23415
23560
  // ../jsx/src/ssr-defaults.ts
23416
- import ts21 from "typescript";
23561
+ import ts22 from "typescript";
23417
23562
  function deriveStashFromDefaults(defaults, props) {
23418
23563
  const extra = {};
23419
23564
  for (const [name2, d] of Object.entries(defaults)) {
@@ -23493,11 +23638,11 @@ function collectPropRefs(expr, propsObjectName, out) {
23493
23638
  const node = parseExpression2(expr);
23494
23639
  if (!node) return;
23495
23640
  const visit3 = (n) => {
23496
- 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)) {
23497
23642
  out.add(n.name.text);
23498
23643
  return;
23499
23644
  }
23500
- ts21.forEachChild(n, visit3);
23645
+ ts22.forEachChild(n, visit3);
23501
23646
  };
23502
23647
  visit3(node);
23503
23648
  }
@@ -23514,21 +23659,21 @@ function tryStaticEval(expr, ctx2) {
23514
23659
  }
23515
23660
  function evalStatementsForReturn(statements, ctx2) {
23516
23661
  for (const stmt of statements) {
23517
- if (ts21.isVariableStatement(stmt)) {
23662
+ if (ts22.isVariableStatement(stmt)) {
23518
23663
  for (const d of stmt.declarationList.declarations) {
23519
- if (!ts21.isIdentifier(d.name) || !d.initializer) continue;
23664
+ if (!ts22.isIdentifier(d.name) || !d.initializer) continue;
23520
23665
  const v = evalNode(d.initializer, ctx2);
23521
23666
  if (v !== UNRESOLVED) ctx2.bindings[d.name.text] = v;
23522
23667
  }
23523
- } else if (ts21.isReturnStatement(stmt)) {
23668
+ } else if (ts22.isReturnStatement(stmt)) {
23524
23669
  return stmt.expression ? evalNode(stmt.expression, ctx2) : UNRESOLVED;
23525
- } else if (ts21.isIfStatement(stmt)) {
23670
+ } else if (ts22.isIfStatement(stmt)) {
23526
23671
  const cond = evalNode(stmt.expression, ctx2);
23527
23672
  if (cond === UNRESOLVED) return UNRESOLVED;
23528
23673
  const branch = cond ? stmt.thenStatement : stmt.elseStatement;
23529
23674
  if (branch) {
23530
23675
  const taken = evalStatementsForReturn(
23531
- ts21.isBlock(branch) ? branch.statements : [branch],
23676
+ ts22.isBlock(branch) ? branch.statements : [branch],
23532
23677
  ctx2
23533
23678
  );
23534
23679
  if (taken !== NO_RETURN) return taken;
@@ -23540,64 +23685,64 @@ function evalStatementsForReturn(statements, ctx2) {
23540
23685
  return NO_RETURN;
23541
23686
  }
23542
23687
  function parseExpression2(expr) {
23543
- const sf = ts21.createSourceFile(
23688
+ const sf = ts22.createSourceFile(
23544
23689
  "__ssr_default__.ts",
23545
23690
  `(${expr})`,
23546
- ts21.ScriptTarget.Latest,
23691
+ ts22.ScriptTarget.Latest,
23547
23692
  false,
23548
- ts21.ScriptKind.TS
23693
+ ts22.ScriptKind.TS
23549
23694
  );
23550
23695
  const stmt = sf.statements[0];
23551
- if (!stmt || !ts21.isExpressionStatement(stmt)) return null;
23552
- 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;
23553
23698
  return inner;
23554
23699
  }
23555
23700
  function evalNode(node, ctx2) {
23556
- if (ts21.isParenthesizedExpression(node)) return evalNode(node.expression, ctx2);
23557
- if (ts21.isAsExpression(node)) return evalNode(node.expression, ctx2);
23558
- if (ts21.isSatisfiesExpression(node)) return evalNode(node.expression, ctx2);
23559
- if (ts21.isTypeAssertionExpression(node)) return evalNode(node.expression, ctx2);
23560
- if (ts21.isNonNullExpression(node)) return evalNode(node.expression, ctx2);
23561
- 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)) {
23562
23707
  if (node.parameters.length !== 0) return UNRESOLVED;
23563
- if (!ts21.isBlock(node.body)) return evalNode(node.body, ctx2);
23708
+ if (!ts22.isBlock(node.body)) return evalNode(node.body, ctx2);
23564
23709
  const localBindings = { ...ctx2.bindings };
23565
23710
  const localCtx = { ...ctx2, bindings: localBindings };
23566
23711
  const result2 = evalStatementsForReturn(node.body.statements, localCtx);
23567
23712
  return result2 === NO_RETURN ? UNRESOLVED : result2;
23568
23713
  }
23569
- if (ts21.isNumericLiteral(node)) return Number(node.text);
23570
- if (ts21.isStringLiteralLike(node)) return node.text;
23571
- if (node.kind === ts21.SyntaxKind.TrueKeyword) return true;
23572
- if (node.kind === ts21.SyntaxKind.FalseKeyword) return false;
23573
- if (node.kind === ts21.SyntaxKind.NullKeyword) return null;
23574
- 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)) {
23575
23720
  if (node.text === "undefined") return void 0;
23576
23721
  if (node.text in ctx2.bindings) return ctx2.bindings[node.text];
23577
23722
  if (ctx2.propsLike.has(node.text)) return void 0;
23578
23723
  return UNRESOLVED;
23579
23724
  }
23580
- if (ts21.isPrefixUnaryExpression(node)) {
23725
+ if (ts22.isPrefixUnaryExpression(node)) {
23581
23726
  const arg = evalNode(node.operand, ctx2);
23582
23727
  if (arg === UNRESOLVED) return UNRESOLVED;
23583
23728
  switch (node.operator) {
23584
- case ts21.SyntaxKind.MinusToken:
23729
+ case ts22.SyntaxKind.MinusToken:
23585
23730
  return typeof arg === "number" ? -arg : UNRESOLVED;
23586
- case ts21.SyntaxKind.PlusToken:
23731
+ case ts22.SyntaxKind.PlusToken:
23587
23732
  return typeof arg === "number" ? +arg : UNRESOLVED;
23588
- case ts21.SyntaxKind.ExclamationToken:
23733
+ case ts22.SyntaxKind.ExclamationToken:
23589
23734
  return !arg;
23590
23735
  }
23591
23736
  return UNRESOLVED;
23592
23737
  }
23593
- if (ts21.isObjectLiteralExpression(node)) {
23738
+ if (ts22.isObjectLiteralExpression(node)) {
23594
23739
  const obj = {};
23595
23740
  for (const prop of node.properties) {
23596
- if (!ts21.isPropertyAssignment(prop)) return UNRESOLVED;
23741
+ if (!ts22.isPropertyAssignment(prop)) return UNRESOLVED;
23597
23742
  let key;
23598
- if (ts21.isIdentifier(prop.name) || ts21.isStringLiteralLike(prop.name)) {
23743
+ if (ts22.isIdentifier(prop.name) || ts22.isStringLiteralLike(prop.name)) {
23599
23744
  key = prop.name.text;
23600
- } else if (ts21.isNumericLiteral(prop.name)) {
23745
+ } else if (ts22.isNumericLiteral(prop.name)) {
23601
23746
  key = prop.name.text;
23602
23747
  } else {
23603
23748
  return UNRESOLVED;
@@ -23608,17 +23753,17 @@ function evalNode(node, ctx2) {
23608
23753
  }
23609
23754
  return obj;
23610
23755
  }
23611
- if (ts21.isArrayLiteralExpression(node)) {
23756
+ if (ts22.isArrayLiteralExpression(node)) {
23612
23757
  const arr = [];
23613
23758
  for (const elem of node.elements) {
23614
- if (ts21.isOmittedExpression(elem)) return UNRESOLVED;
23759
+ if (ts22.isOmittedExpression(elem)) return UNRESOLVED;
23615
23760
  const v = evalNode(elem, ctx2);
23616
23761
  if (v === UNRESOLVED) return UNRESOLVED;
23617
23762
  arr.push(v === void 0 ? null : v);
23618
23763
  }
23619
23764
  return arr;
23620
23765
  }
23621
- if (ts21.isElementAccessExpression(node)) {
23766
+ if (ts22.isElementAccessExpression(node)) {
23622
23767
  const base = evalNode(node.expression, ctx2);
23623
23768
  if (base === void 0) return void 0;
23624
23769
  if (base === UNRESOLVED || base === null || typeof base !== "object") return UNRESOLVED;
@@ -23628,16 +23773,16 @@ function evalNode(node, ctx2) {
23628
23773
  const k = String(key);
23629
23774
  return Object.prototype.hasOwnProperty.call(base, k) ? base[k] : void 0;
23630
23775
  }
23631
- if (ts21.isPropertyAccessExpression(node)) {
23776
+ if (ts22.isPropertyAccessExpression(node)) {
23632
23777
  const baseResult = evalNode(node.expression, ctx2);
23633
23778
  if (baseResult === void 0) return void 0;
23634
23779
  return UNRESOLVED;
23635
23780
  }
23636
- if (ts21.isCallExpression(node)) {
23637
- 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) {
23638
23783
  return ctx2.bindings[node.expression.text];
23639
23784
  }
23640
- if (ts21.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
23785
+ if (ts22.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
23641
23786
  const recv = evalNode(node.expression.expression, ctx2);
23642
23787
  if (Array.isArray(recv)) {
23643
23788
  let sep = ",";
@@ -23652,24 +23797,24 @@ function evalNode(node, ctx2) {
23652
23797
  }
23653
23798
  return UNRESOLVED;
23654
23799
  }
23655
- if (ts21.isConditionalExpression(node)) {
23800
+ if (ts22.isConditionalExpression(node)) {
23656
23801
  const cond = evalNode(node.condition, ctx2);
23657
23802
  if (cond === UNRESOLVED) return UNRESOLVED;
23658
23803
  return cond ? evalNode(node.whenTrue, ctx2) : evalNode(node.whenFalse, ctx2);
23659
23804
  }
23660
- if (ts21.isBinaryExpression(node)) {
23805
+ if (ts22.isBinaryExpression(node)) {
23661
23806
  const op = node.operatorToken.kind;
23662
- if (op === ts21.SyntaxKind.QuestionQuestionToken) {
23807
+ if (op === ts22.SyntaxKind.QuestionQuestionToken) {
23663
23808
  const l2 = evalNode(node.left, ctx2);
23664
23809
  if (l2 !== UNRESOLVED && l2 !== null && l2 !== void 0) return l2;
23665
23810
  return evalNode(node.right, ctx2);
23666
23811
  }
23667
- if (op === ts21.SyntaxKind.BarBarToken) {
23812
+ if (op === ts22.SyntaxKind.BarBarToken) {
23668
23813
  const l2 = evalNode(node.left, ctx2);
23669
23814
  if (l2 !== UNRESOLVED && l2) return l2;
23670
23815
  return evalNode(node.right, ctx2);
23671
23816
  }
23672
- if (op === ts21.SyntaxKind.AmpersandAmpersandToken) {
23817
+ if (op === ts22.SyntaxKind.AmpersandAmpersandToken) {
23673
23818
  const l2 = evalNode(node.left, ctx2);
23674
23819
  if (l2 === UNRESOLVED) return UNRESOLVED;
23675
23820
  if (!l2) return l2;
@@ -23679,28 +23824,28 @@ function evalNode(node, ctx2) {
23679
23824
  const r2 = evalNode(node.right, ctx2);
23680
23825
  if (l === UNRESOLVED || r2 === UNRESOLVED) return UNRESOLVED;
23681
23826
  switch (op) {
23682
- case ts21.SyntaxKind.PlusToken:
23827
+ case ts22.SyntaxKind.PlusToken:
23683
23828
  if (typeof l === "string" || typeof r2 === "string") return `${l}${r2}`;
23684
23829
  if (typeof l === "number" && typeof r2 === "number") return l + r2;
23685
23830
  return UNRESOLVED;
23686
- case ts21.SyntaxKind.MinusToken:
23831
+ case ts22.SyntaxKind.MinusToken:
23687
23832
  return typeof l === "number" && typeof r2 === "number" ? l - r2 : UNRESOLVED;
23688
- case ts21.SyntaxKind.AsteriskToken:
23833
+ case ts22.SyntaxKind.AsteriskToken:
23689
23834
  return typeof l === "number" && typeof r2 === "number" ? l * r2 : UNRESOLVED;
23690
- case ts21.SyntaxKind.SlashToken:
23835
+ case ts22.SyntaxKind.SlashToken:
23691
23836
  return typeof l === "number" && typeof r2 === "number" && r2 !== 0 ? l / r2 : UNRESOLVED;
23692
- case ts21.SyntaxKind.PercentToken:
23837
+ case ts22.SyntaxKind.PercentToken:
23693
23838
  return typeof l === "number" && typeof r2 === "number" && r2 !== 0 ? l % r2 : UNRESOLVED;
23694
- case ts21.SyntaxKind.EqualsEqualsEqualsToken:
23695
- case ts21.SyntaxKind.EqualsEqualsToken:
23839
+ case ts22.SyntaxKind.EqualsEqualsEqualsToken:
23840
+ case ts22.SyntaxKind.EqualsEqualsToken:
23696
23841
  return l === r2;
23697
- case ts21.SyntaxKind.ExclamationEqualsEqualsToken:
23698
- case ts21.SyntaxKind.ExclamationEqualsToken:
23842
+ case ts22.SyntaxKind.ExclamationEqualsEqualsToken:
23843
+ case ts22.SyntaxKind.ExclamationEqualsToken:
23699
23844
  return l !== r2;
23700
23845
  }
23701
23846
  return UNRESOLVED;
23702
23847
  }
23703
- if (ts21.isTemplateExpression(node)) {
23848
+ if (ts22.isTemplateExpression(node)) {
23704
23849
  if (node.templateSpans.length === 0) return node.head.text;
23705
23850
  let acc = node.head.text;
23706
23851
  for (const span of node.templateSpans) {
@@ -23710,7 +23855,7 @@ function evalNode(node, ctx2) {
23710
23855
  }
23711
23856
  return acc;
23712
23857
  }
23713
- if (ts21.isNoSubstitutionTemplateLiteral(node)) return node.text;
23858
+ if (ts22.isNoSubstitutionTemplateLiteral(node)) return node.text;
23714
23859
  return UNRESOLVED;
23715
23860
  }
23716
23861
  var UNRESOLVED, NO_RETURN;
@@ -23723,7 +23868,7 @@ var init_ssr_defaults = __esm({
23723
23868
  });
23724
23869
 
23725
23870
  // ../jsx/src/augment-inherited-props.ts
23726
- import ts22 from "typescript";
23871
+ import ts23 from "typescript";
23727
23872
  function collectContextConsumers(metadata) {
23728
23873
  const constants = metadata.localConstants ?? [];
23729
23874
  const contextDefaults = /* @__PURE__ */ new Map();
@@ -23750,35 +23895,35 @@ function collectContextConsumers(metadata) {
23750
23895
  }
23751
23896
  function parseUseContextArg(source) {
23752
23897
  const expr = parseSingleExpression(source);
23753
- if (!expr || !ts22.isCallExpression(expr)) return null;
23754
- 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;
23755
23900
  if (expr.arguments.length !== 1) return null;
23756
23901
  const arg = expr.arguments[0];
23757
- return ts22.isIdentifier(arg) ? arg.text : null;
23902
+ return ts23.isIdentifier(arg) ? arg.text : null;
23758
23903
  }
23759
23904
  function parseCreateContextDefault(source) {
23760
23905
  const expr = parseSingleExpression(source);
23761
- if (!expr || !ts22.isCallExpression(expr)) return null;
23906
+ if (!expr || !ts23.isCallExpression(expr)) return null;
23762
23907
  if (expr.arguments.length === 0) return null;
23763
23908
  const arg = expr.arguments[0];
23764
- if (ts22.isStringLiteral(arg) || ts22.isNoSubstitutionTemplateLiteral(arg)) return arg.text;
23765
- if (ts22.isNumericLiteral(arg)) return Number(arg.text);
23766
- if (arg.kind === ts22.SyntaxKind.TrueKeyword) return true;
23767
- 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;
23768
23913
  return null;
23769
23914
  }
23770
23915
  function isObjectLiteralCreateContextDefault(source) {
23771
23916
  const expr = parseSingleExpression(source);
23772
- if (!expr || !ts22.isCallExpression(expr)) return false;
23917
+ if (!expr || !ts23.isCallExpression(expr)) return false;
23773
23918
  if (expr.arguments.length === 0) return false;
23774
- return ts22.isObjectLiteralExpression(expr.arguments[0]);
23919
+ return ts23.isObjectLiteralExpression(expr.arguments[0]);
23775
23920
  }
23776
23921
  function parseSingleExpression(source) {
23777
- const sf = ts22.createSourceFile("__ctx.ts", `(${source})`, ts22.ScriptTarget.Latest, false);
23922
+ const sf = ts23.createSourceFile("__ctx.ts", `(${source})`, ts23.ScriptTarget.Latest, false);
23778
23923
  const stmt = sf.statements[0];
23779
- if (!stmt || !ts22.isExpressionStatement(stmt)) return null;
23924
+ if (!stmt || !ts23.isExpressionStatement(stmt)) return null;
23780
23925
  let e = stmt.expression;
23781
- while (ts22.isParenthesizedExpression(e)) e = e.expression;
23926
+ while (ts23.isParenthesizedExpression(e)) e = e.expression;
23782
23927
  return e;
23783
23928
  }
23784
23929
  function augmentInheritedPropAccesses(ir) {
@@ -23799,21 +23944,21 @@ function augmentInheritedPropAccesses(ir) {
23799
23944
  const coalesceLiteralTypes = /* @__PURE__ */ new Map();
23800
23945
  const pinCoalesceLiterals = (s) => {
23801
23946
  if (!s || !s.includes(propsObj)) return;
23802
- const sf = ts22.createSourceFile("__aug.ts", `(${s})`, ts22.ScriptTarget.Latest, false);
23947
+ const sf = ts23.createSourceFile("__aug.ts", `(${s})`, ts23.ScriptTarget.Latest, false);
23803
23948
  const visit3 = (n) => {
23804
- 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)) {
23805
23950
  let left = n.left;
23806
- while (ts22.isParenthesizedExpression(left)) left = left.expression;
23807
- 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) {
23808
23953
  const name2 = left.name.text;
23809
23954
  let right = n.right;
23810
- while (ts22.isParenthesizedExpression(right)) right = right.expression;
23811
- if (ts22.isPrefixUnaryExpression(right)) right = right.operand;
23812
- 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;
23813
23958
  if (kind2 && !coalesceLiteralTypes.has(name2)) coalesceLiteralTypes.set(name2, kind2);
23814
23959
  }
23815
23960
  }
23816
- ts22.forEachChild(n, visit3);
23961
+ ts23.forEachChild(n, visit3);
23817
23962
  };
23818
23963
  visit3(sf);
23819
23964
  };
@@ -23909,39 +24054,39 @@ function augmentInheritedPropAccesses(ir) {
23909
24054
  }
23910
24055
  }
23911
24056
  function parseStaticStringConst(source) {
23912
- const sf = ts22.createSourceFile(
24057
+ const sf = ts23.createSourceFile(
23913
24058
  "__const.ts",
23914
24059
  `const __x = (${source});`,
23915
- ts22.ScriptTarget.Latest,
24060
+ ts23.ScriptTarget.Latest,
23916
24061
  /*setParentNodes*/
23917
24062
  false
23918
24063
  );
23919
24064
  const stmt = sf.statements[0];
23920
- if (!stmt || !ts22.isVariableStatement(stmt)) return null;
24065
+ if (!stmt || !ts23.isVariableStatement(stmt)) return null;
23921
24066
  let init = stmt.declarationList.declarations[0]?.initializer;
23922
- while (init && ts22.isParenthesizedExpression(init)) init = init.expression;
24067
+ while (init && ts23.isParenthesizedExpression(init)) init = init.expression;
23923
24068
  if (!init) return null;
23924
- if (ts22.isStringLiteral(init) || ts22.isNoSubstitutionTemplateLiteral(init)) {
24069
+ if (ts23.isStringLiteral(init) || ts23.isNoSubstitutionTemplateLiteral(init)) {
23925
24070
  return init.text;
23926
24071
  }
23927
24072
  return evalStringArrayJoin(source);
23928
24073
  }
23929
24074
  function evalTemplateOfStringConsts(source, resolved) {
23930
- const sf = ts22.createSourceFile(
24075
+ const sf = ts23.createSourceFile(
23931
24076
  "__const.ts",
23932
24077
  `const __x = (${source});`,
23933
- ts22.ScriptTarget.Latest,
24078
+ ts23.ScriptTarget.Latest,
23934
24079
  /*setParentNodes*/
23935
24080
  false
23936
24081
  );
23937
24082
  const stmt = sf.statements[0];
23938
- if (!stmt || !ts22.isVariableStatement(stmt)) return null;
24083
+ if (!stmt || !ts23.isVariableStatement(stmt)) return null;
23939
24084
  let init = stmt.declarationList.declarations[0]?.initializer;
23940
- while (init && ts22.isParenthesizedExpression(init)) init = init.expression;
23941
- if (!init || !ts22.isTemplateExpression(init)) return null;
24085
+ while (init && ts23.isParenthesizedExpression(init)) init = init.expression;
24086
+ if (!init || !ts23.isTemplateExpression(init)) return null;
23942
24087
  let out = init.head.text;
23943
24088
  for (const span of init.templateSpans) {
23944
- if (!ts22.isIdentifier(span.expression)) return null;
24089
+ if (!ts23.isIdentifier(span.expression)) return null;
23945
24090
  const value2 = resolved.get(span.expression.text);
23946
24091
  if (value2 === void 0) return null;
23947
24092
  out += value2 + span.literal.text;
@@ -23967,31 +24112,32 @@ function collectModuleStringConsts(constants) {
23967
24112
  }
23968
24113
  return map;
23969
24114
  }
23970
- function lookupStaticRecordLiteral(objectName, key, constants) {
24115
+ function lookupStaticRecordLiteral(objectName, key, constants, isShadowed) {
24116
+ if (isShadowed(objectName)) return null;
23971
24117
  const constInfo = (constants ?? []).find((c) => c.name === objectName && c.isModule);
23972
24118
  if (constInfo?.value === void 0) return null;
23973
- const sf = ts22.createSourceFile(
24119
+ const sf = ts23.createSourceFile(
23974
24120
  "__rec.ts",
23975
24121
  `(${constInfo.value})`,
23976
- ts22.ScriptTarget.Latest,
24122
+ ts23.ScriptTarget.Latest,
23977
24123
  /*setParentNodes*/
23978
24124
  true
23979
24125
  );
23980
24126
  if (sf.statements.length !== 1) return null;
23981
24127
  const stmt = sf.statements[0];
23982
- if (!ts22.isExpressionStatement(stmt)) return null;
24128
+ if (!ts23.isExpressionStatement(stmt)) return null;
23983
24129
  let parsed = stmt.expression;
23984
- while (ts22.isParenthesizedExpression(parsed)) parsed = parsed.expression;
23985
- if (!ts22.isObjectLiteralExpression(parsed)) return null;
24130
+ while (ts23.isParenthesizedExpression(parsed)) parsed = parsed.expression;
24131
+ if (!ts23.isObjectLiteralExpression(parsed)) return null;
23986
24132
  for (const prop of parsed.properties) {
23987
- if (!ts22.isPropertyAssignment(prop)) continue;
24133
+ if (!ts23.isPropertyAssignment(prop)) continue;
23988
24134
  const name2 = prop.name;
23989
- 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;
23990
24136
  if (propKey !== key) continue;
23991
24137
  let v = prop.initializer;
23992
- while (ts22.isParenthesizedExpression(v)) v = v.expression;
23993
- if (ts22.isNumericLiteral(v)) return { kind: "number", text: v.text };
23994
- 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)) {
23995
24141
  return { kind: "string", text: v.text };
23996
24142
  }
23997
24143
  return null;
@@ -23999,27 +24145,27 @@ function lookupStaticRecordLiteral(objectName, key, constants) {
23999
24145
  return null;
24000
24146
  }
24001
24147
  function evalStringArrayJoin(source) {
24002
- const sf = ts22.createSourceFile(
24148
+ const sf = ts23.createSourceFile(
24003
24149
  "__join.ts",
24004
24150
  `const __x = (${source});`,
24005
- ts22.ScriptTarget.Latest,
24151
+ ts23.ScriptTarget.Latest,
24006
24152
  /*setParentNodes*/
24007
24153
  false
24008
24154
  );
24009
24155
  const stmt = sf.statements[0];
24010
- if (!stmt || !ts22.isVariableStatement(stmt)) return null;
24156
+ if (!stmt || !ts23.isVariableStatement(stmt)) return null;
24011
24157
  let node = stmt.declarationList.declarations[0]?.initializer;
24012
- while (node && ts22.isParenthesizedExpression(node)) node = node.expression;
24013
- if (!node || !ts22.isCallExpression(node)) return null;
24158
+ while (node && ts23.isParenthesizedExpression(node)) node = node.expression;
24159
+ if (!node || !ts23.isCallExpression(node)) return null;
24014
24160
  const callee = node.expression;
24015
- if (!ts22.isPropertyAccessExpression(callee)) return null;
24161
+ if (!ts23.isPropertyAccessExpression(callee)) return null;
24016
24162
  if (callee.name.text !== "join") return null;
24017
24163
  let recv = callee.expression;
24018
- while (ts22.isParenthesizedExpression(recv)) recv = recv.expression;
24019
- if (!ts22.isArrayLiteralExpression(recv)) return null;
24164
+ while (ts23.isParenthesizedExpression(recv)) recv = recv.expression;
24165
+ if (!ts23.isArrayLiteralExpression(recv)) return null;
24020
24166
  const parts = [];
24021
24167
  for (const el of recv.elements) {
24022
- if (ts22.isStringLiteral(el) || ts22.isNoSubstitutionTemplateLiteral(el)) {
24168
+ if (ts23.isStringLiteral(el) || ts23.isNoSubstitutionTemplateLiteral(el)) {
24023
24169
  parts.push(el.text);
24024
24170
  } else {
24025
24171
  return null;
@@ -24028,16 +24174,16 @@ function evalStringArrayJoin(source) {
24028
24174
  let sep = ",";
24029
24175
  if (node.arguments.length >= 1) {
24030
24176
  const arg = node.arguments[0];
24031
- if (ts22.isStringLiteral(arg) || ts22.isNoSubstitutionTemplateLiteral(arg)) sep = arg.text;
24177
+ if (ts23.isStringLiteral(arg) || ts23.isNoSubstitutionTemplateLiteral(arg)) sep = arg.text;
24032
24178
  else return null;
24033
24179
  }
24034
24180
  return parts.join(sep);
24035
24181
  }
24036
24182
  function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
24037
- if (!ts22.isElementAccessExpression(val)) return null;
24183
+ if (!ts23.isElementAccessExpression(val)) return null;
24038
24184
  const obj = val.expression;
24039
24185
  const arg = val.argumentExpression;
24040
- if (!ts22.isIdentifier(obj) || !ts22.isIdentifier(arg)) return null;
24186
+ if (!ts23.isIdentifier(obj) || !ts23.isIdentifier(arg)) return null;
24041
24187
  let indexPropName;
24042
24188
  let defaultKey;
24043
24189
  const resolved = resolveKey?.(arg.text);
@@ -24051,35 +24197,35 @@ function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
24051
24197
  }
24052
24198
  const constInfo = localConstants.find((c) => c.name === obj.text && c.isModule);
24053
24199
  if (constInfo?.value === void 0) return null;
24054
- const sf = ts22.createSourceFile(
24200
+ const sf = ts23.createSourceFile(
24055
24201
  "__rec.ts",
24056
24202
  `(${constInfo.value})`,
24057
- ts22.ScriptTarget.Latest,
24203
+ ts23.ScriptTarget.Latest,
24058
24204
  /* setParentNodes */
24059
24205
  true
24060
24206
  );
24061
24207
  if (sf.statements.length !== 1) return null;
24062
24208
  const stmt = sf.statements[0];
24063
- if (!ts22.isExpressionStatement(stmt)) return null;
24209
+ if (!ts23.isExpressionStatement(stmt)) return null;
24064
24210
  let parsed = stmt.expression;
24065
- while (ts22.isParenthesizedExpression(parsed)) parsed = parsed.expression;
24066
- if (!ts22.isObjectLiteralExpression(parsed)) return null;
24211
+ while (ts23.isParenthesizedExpression(parsed)) parsed = parsed.expression;
24212
+ if (!ts23.isObjectLiteralExpression(parsed)) return null;
24067
24213
  const entries2 = [];
24068
24214
  for (const prop of parsed.properties) {
24069
- if (!ts22.isPropertyAssignment(prop)) return null;
24215
+ if (!ts23.isPropertyAssignment(prop)) return null;
24070
24216
  let key;
24071
- if (ts22.isIdentifier(prop.name)) {
24217
+ if (ts23.isIdentifier(prop.name)) {
24072
24218
  key = prop.name.text;
24073
- } else if (ts22.isStringLiteral(prop.name) || ts22.isNoSubstitutionTemplateLiteral(prop.name)) {
24219
+ } else if (ts23.isStringLiteral(prop.name) || ts23.isNoSubstitutionTemplateLiteral(prop.name)) {
24074
24220
  key = prop.name.text;
24075
24221
  } else {
24076
24222
  return null;
24077
24223
  }
24078
24224
  let v = prop.initializer;
24079
- while (ts22.isParenthesizedExpression(v)) v = v.expression;
24080
- if (ts22.isNumericLiteral(v)) {
24225
+ while (ts23.isParenthesizedExpression(v)) v = v.expression;
24226
+ if (ts23.isNumericLiteral(v)) {
24081
24227
  entries2.push({ key, value: { kind: "number", text: v.text } });
24082
- } else if (ts22.isStringLiteral(v) || ts22.isNoSubstitutionTemplateLiteral(v)) {
24228
+ } else if (ts23.isStringLiteral(v) || ts23.isNoSubstitutionTemplateLiteral(v)) {
24083
24229
  entries2.push({ key, value: { kind: "string", text: v.text } });
24084
24230
  } else {
24085
24231
  return null;
@@ -24351,7 +24497,7 @@ var init_rich_type_refusal = __esm({
24351
24497
  });
24352
24498
 
24353
24499
  // ../jsx/src/compiler.ts
24354
- import ts23 from "typescript";
24500
+ import ts24 from "typescript";
24355
24501
  function mergeTemplateImports(lines) {
24356
24502
  const result2 = [];
24357
24503
  const valueIdx = /* @__PURE__ */ new Map();
@@ -24416,12 +24562,12 @@ function compileMultipleComponents(source, filePath, componentNames, options2) {
24416
24562
  if (entries2.some((e) => e.componentIR.metadata.isClientComponent)) {
24417
24563
  const topLevelNames = /* @__PURE__ */ new Set();
24418
24564
  {
24419
- 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);
24420
24566
  for (const stmt of sf.statements) {
24421
- if (ts23.isFunctionDeclaration(stmt) && stmt.name) topLevelNames.add(stmt.name.text);
24422
- else if (ts23.isVariableStatement(stmt)) {
24567
+ if (ts24.isFunctionDeclaration(stmt) && stmt.name) topLevelNames.add(stmt.name.text);
24568
+ else if (ts24.isVariableStatement(stmt)) {
24423
24569
  for (const d of stmt.declarationList.declarations) {
24424
- if (ts23.isIdentifier(d.name)) topLevelNames.add(d.name.text);
24570
+ if (ts24.isIdentifier(d.name)) topLevelNames.add(d.name.text);
24425
24571
  }
24426
24572
  }
24427
24573
  }
@@ -24482,13 +24628,13 @@ function compileMultipleComponents(source, filePath, componentNames, options2) {
24482
24628
  const moduleStatementSeen = /* @__PURE__ */ new Set();
24483
24629
  const moduleStatementsOrdered = [];
24484
24630
  const collectModuleStatements = (block) => {
24485
- const sf = ts23.createSourceFile(
24631
+ const sf = ts24.createSourceFile(
24486
24632
  "__bf_module_decls.tsx",
24487
24633
  block,
24488
- ts23.ScriptTarget.Latest,
24634
+ ts24.ScriptTarget.Latest,
24489
24635
  /* setParentNodes */
24490
24636
  false,
24491
- ts23.ScriptKind.TSX
24637
+ ts24.ScriptKind.TSX
24492
24638
  );
24493
24639
  for (const stmt of sf.statements) {
24494
24640
  const text = stmt.getText(sf);
@@ -24720,6 +24866,11 @@ function compileMultipleComponents(source, filePath, componentNames, options2) {
24720
24866
  }
24721
24867
  return { files: files2, errors };
24722
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
+ }
24723
24874
  function buildMetadata(ctx2) {
24724
24875
  const metadata = {
24725
24876
  componentName: ctx2.componentName || "Unknown",
@@ -24728,6 +24879,7 @@ function buildMetadata(ctx2) {
24728
24879
  isClientComponent: ctx2.hasUseClientDirective,
24729
24880
  typeDefinitions: ctx2.typeDefinitions,
24730
24881
  propsType: ctx2.propsType,
24882
+ typeParameters: componentTypeParametersText(ctx2.componentNode, ctx2.sourceFile),
24731
24883
  propsParams: ctx2.propsParams,
24732
24884
  propsObjectName: ctx2.propsObjectName,
24733
24885
  restPropsName: ctx2.restPropsName,
@@ -24953,7 +25105,7 @@ var init_compiler = __esm({
24953
25105
  });
24954
25106
 
24955
25107
  // ../jsx/src/shared-program.ts
24956
- import ts24 from "typescript";
25108
+ import ts25 from "typescript";
24957
25109
  import path6 from "node:path";
24958
25110
  function commonParent(paths) {
24959
25111
  if (paths.length === 0) return process.cwd();
@@ -24971,10 +25123,10 @@ function commonParent(paths) {
24971
25123
  function createProgramForCorpus(files2, options2 = {}) {
24972
25124
  const baseUrl = options2.baseUrl ?? commonParent(files2);
24973
25125
  const compilerOptions = {
24974
- target: ts24.ScriptTarget.Latest,
24975
- module: ts24.ModuleKind.ESNext,
24976
- moduleResolution: ts24.ModuleResolutionKind.Bundler,
24977
- jsx: ts24.JsxEmit.ReactJSX,
25126
+ target: ts25.ScriptTarget.Latest,
25127
+ module: ts25.ModuleKind.ESNext,
25128
+ moduleResolution: ts25.ModuleResolutionKind.Bundler,
25129
+ jsx: ts25.JsxEmit.ReactJSX,
24978
25130
  strict: true,
24979
25131
  skipLibCheck: true,
24980
25132
  noEmit: true,
@@ -24984,7 +25136,7 @@ function createProgramForCorpus(files2, options2 = {}) {
24984
25136
  ...options2.compilerOptions
24985
25137
  };
24986
25138
  const absolute = files2.map((f) => path6.resolve(f));
24987
- return ts24.createProgram(absolute, compilerOptions, void 0, options2.oldProgram);
25139
+ return ts25.createProgram(absolute, compilerOptions, void 0, options2.oldProgram);
24988
25140
  }
24989
25141
  var init_shared_program = __esm({
24990
25142
  "../jsx/src/shared-program.ts"() {
@@ -25020,6 +25172,7 @@ var init_jsx_adapter = __esm({
25020
25172
  init_env_signal();
25021
25173
  init_module_exports();
25022
25174
  init_csr_substitute();
25175
+ init_identifier_pattern();
25023
25176
  JsxAdapter = class extends BaseAdapter {
25024
25177
  componentName = "";
25025
25178
  /**
@@ -25083,7 +25236,13 @@ var init_jsx_adapter = __esm({
25083
25236
  ...localFunctions.map((f) => ({ name: f.name, body: f.body })),
25084
25237
  ...localConstants.map((c) => ({ name: c.name, body: c.value }))
25085
25238
  ];
25086
- 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
+ );
25087
25246
  const reachableBodies = [...reachable].map((name2) => {
25088
25247
  const func = localFunctions.find((f) => f.name === name2);
25089
25248
  if (func) return func.body;
@@ -25111,9 +25270,12 @@ var init_jsx_adapter = __esm({
25111
25270
  lines.push(` const ${signal2.getter} = () => ${initialValue}`);
25112
25271
  }
25113
25272
  if (signal2.setter) {
25114
- const setterUsed = new RegExp(`\\b${signal2.setter}\\b`).test(setterRefText);
25273
+ const setterUsed = identifierPattern(signal2.setter).test(setterRefText);
25115
25274
  if (setterUsed) {
25116
- 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
+ );
25117
25279
  }
25118
25280
  }
25119
25281
  }
@@ -25380,6 +25542,7 @@ var init_jsx_adapter = __esm({
25380
25542
  });
25381
25543
 
25382
25544
  // ../jsx/src/adapters/template-imports.ts
25545
+ import ts26 from "typescript";
25383
25546
  function rewriteImportsForTemplate(imports, shimSource, rewriteRelative) {
25384
25547
  const remap = (imp) => {
25385
25548
  if (!rewriteRelative || !imp.source.startsWith(".")) return imp;
@@ -25421,6 +25584,48 @@ function rewriteImportsForTemplate(imports, shimSource, rewriteRelative) {
25421
25584
  function specKey(s) {
25422
25585
  return `${s.isDefault ? "d" : ""}${s.isNamespace ? "n" : ""}:${s.name}:${s.alias ?? ""}`;
25423
25586
  }
25587
+ function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
25588
+ if (!sourceText.includes("import")) return sourceText;
25589
+ const sf = ts26.createSourceFile(
25590
+ "bf-template-fragment.tsx",
25591
+ sourceText,
25592
+ ts26.ScriptTarget.Latest,
25593
+ /* setParentNodes */
25594
+ false,
25595
+ ts26.ScriptKind.TSX
25596
+ );
25597
+ const edits = [];
25598
+ const visit3 = (node) => {
25599
+ if (ts26.isCallExpression(node) && node.expression.kind === ts26.SyntaxKind.ImportKeyword && node.arguments.length > 0 && ts26.isStringLiteralLike(node.arguments[0])) {
25600
+ collect(node.arguments[0]);
25601
+ }
25602
+ if (ts26.isImportTypeNode(node) && ts26.isLiteralTypeNode(node.argument)) {
25603
+ const literal = node.argument.literal;
25604
+ if (ts26.isStringLiteralLike(literal)) collect(literal);
25605
+ }
25606
+ ts26.forEachChild(node, visit3);
25607
+ };
25608
+ const collect = (literal) => {
25609
+ const specifier = literal.text;
25610
+ if (!specifier.startsWith(".")) return;
25611
+ const next = rewriteRelative(specifier);
25612
+ if (next === specifier) return;
25613
+ edits.push({
25614
+ start: literal.getStart(sf),
25615
+ end: literal.getEnd(),
25616
+ // Re-quote rather than reusing the original delimiters: a rewritten
25617
+ // POSIX-relative path never contains a quote to escape.
25618
+ text: `'${next}'`
25619
+ });
25620
+ };
25621
+ ts26.forEachChild(sf, visit3);
25622
+ if (edits.length === 0) return sourceText;
25623
+ let out = sourceText;
25624
+ for (const edit of edits.sort((a, b) => b.start - a.start)) {
25625
+ out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
25626
+ }
25627
+ return out;
25628
+ }
25424
25629
  var CLIENT_PACKAGE_SOURCES;
25425
25630
  var init_template_imports = __esm({
25426
25631
  "../jsx/src/adapters/template-imports.ts"() {
@@ -25530,7 +25735,8 @@ export default ${this.componentName}` : "";
25530
25735
  const noArgDefault = hasRequiredProps ? "" : ` = {} as ${propsTypeExpr}`;
25531
25736
  const lines = [];
25532
25737
  const exportPrefix = ir.metadata.isExported === false ? "" : "export ";
25533
- lines.push(`${exportPrefix}function ${name2}(${fullPropsDestructure}${typeAnnotation}${noArgDefault}) {`);
25738
+ const typeParameters = ir.metadata.typeParameters ?? "";
25739
+ lines.push(`${exportPrefix}function ${name2}${typeParameters}(${fullPropsDestructure}${typeAnnotation}${noArgDefault}) {`);
25534
25740
  if (hasClientInteractivity) {
25535
25741
  lines.push(` const __scopeId = (/_s\\d/.test(__bfScope || '') ? __bfScope : null) || __instanceId || \`${name2}_\${Math.random().toString(36).slice(2, 8)}\``);
25536
25742
  } else {
@@ -26259,7 +26465,7 @@ var init_dangerous_inner_html = __esm({
26259
26465
  });
26260
26466
 
26261
26467
  // ../jsx/src/combine-client-js.ts
26262
- import ts25 from "typescript";
26468
+ import ts27 from "typescript";
26263
26469
  function combineParentChildClientJs(files2) {
26264
26470
  const result2 = /* @__PURE__ */ new Map();
26265
26471
  const lookup = /* @__PURE__ */ new Map();
@@ -26316,17 +26522,17 @@ function combineParentChildClientJs(files2) {
26316
26522
  return result2;
26317
26523
  }
26318
26524
  function parseAndMerge(content2, importsBySource, otherImports, codeSections) {
26319
- const sourceFile = ts25.createSourceFile(
26525
+ const sourceFile = ts27.createSourceFile(
26320
26526
  "combine.js",
26321
26527
  content2,
26322
- ts25.ScriptTarget.Latest,
26528
+ ts27.ScriptTarget.Latest,
26323
26529
  /*setParentNodes*/
26324
26530
  false,
26325
- ts25.ScriptKind.JS
26531
+ ts27.ScriptKind.JS
26326
26532
  );
26327
26533
  const importSpans = [];
26328
26534
  for (const stmt of sourceFile.statements) {
26329
- if (!ts25.isImportDeclaration(stmt)) continue;
26535
+ if (!ts27.isImportDeclaration(stmt)) continue;
26330
26536
  const start2 = stmt.getStart(sourceFile);
26331
26537
  const end2 = stmt.getEnd();
26332
26538
  importSpans.push([start2, end2]);
@@ -26334,8 +26540,8 @@ function parseAndMerge(content2, importsBySource, otherImports, codeSections) {
26334
26540
  if (stmtText.includes("@bf-child:")) continue;
26335
26541
  const clause = stmt.importClause;
26336
26542
  const bindings = clause?.namedBindings;
26337
- const specifier = ts25.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
26338
- if (clause && !clause.name && bindings && ts25.isNamedImports(bindings)) {
26543
+ const specifier = ts27.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
26544
+ if (clause && !clause.name && bindings && ts27.isNamedImports(bindings)) {
26339
26545
  if (!importsBySource.has(specifier)) {
26340
26546
  importsBySource.set(specifier, /* @__PURE__ */ new Set());
26341
26547
  }
@@ -26510,7 +26716,7 @@ var init_loop_destructure = __esm({
26510
26716
  });
26511
26717
 
26512
26718
  // ../jsx/src/debug.ts
26513
- import ts26 from "typescript";
26719
+ import ts28 from "typescript";
26514
26720
  function buildComponentGraph(source, filePath, componentName) {
26515
26721
  const ctx2 = analyzeComponent(source, filePath, componentName);
26516
26722
  if (!ctx2.jsxReturn) {
@@ -26583,7 +26789,7 @@ function buildGraphFromIR(ir) {
26583
26789
  return propsObjectName ? exprReadsPropMember(expr, propsObjectName) : false;
26584
26790
  };
26585
26791
  const domBindings = [];
26586
- collectDomBindings(ir.root, domBindings, signalGetters, memoNames, void 0, /* @__PURE__ */ new Set(), exprReadsProp);
26792
+ collectDomBindings(ir.root, domBindings, signalGetters, memoNames, void 0, BindingScope.EMPTY, exprReadsProp);
26587
26793
  const signalConsumers = /* @__PURE__ */ new Map();
26588
26794
  for (const s of meta.signals) signalConsumers.set(s.getter, []);
26589
26795
  for (const memo of meta.memos) {
@@ -27550,14 +27756,19 @@ function inferWrapReasonForAttrLike(hasStringReactive, hasPropsRef, flags) {
27550
27756
  const decision = decideWrapFromAstFlags(flags);
27551
27757
  return decision.wrap ? decision.reason : void 0;
27552
27758
  }
27553
- function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag, loopParams = /* @__PURE__ */ new Set(), readsProp = () => false) {
27554
- const exprReadsLoopParam = (n) => loopParams.size > 0 && (n.origin?.freeRefs?.some((r2) => loopParams.has(r2.name)) ?? false);
27555
- 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);
27556
27767
  switch (node.type) {
27557
27768
  case "element": {
27558
27769
  for (const attr of node.attrs) {
27559
27770
  if (attr.value.kind !== "expression" && attr.value.kind !== "template" && attr.value.kind !== "spread") continue;
27560
- if (attr.name === "key" && loopParams.size > 0) continue;
27771
+ if (attr.name === "key" && boundNames.size > 0) continue;
27561
27772
  const expr = attrValueToString2(attr.value);
27562
27773
  if (!expr) continue;
27563
27774
  const deps = extractReactiveDeps(expr, signalGetters, memoNames);
@@ -27592,7 +27803,7 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27592
27803
  });
27593
27804
  }
27594
27805
  for (const child of node.children) {
27595
- collectDomBindings(child, bindings, signalGetters, memoNames, node.tag, loopParams, readsProp);
27806
+ collectDomBindings(child, bindings, signalGetters, memoNames, node.tag, scope, readsProp);
27596
27807
  }
27597
27808
  break;
27598
27809
  }
@@ -27619,7 +27830,7 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27619
27830
  }
27620
27831
  case "conditional": {
27621
27832
  const decision = decideWrapFromAstFlags(node);
27622
- 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);
27623
27834
  if ((decision.wrap || loopReactive) && node.slotId) {
27624
27835
  const deps = extractReactiveDeps(node.condition, signalGetters, memoNames);
27625
27836
  bindings.push({
@@ -27635,14 +27846,14 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27635
27846
  jsxPreview: `{${truncateExpr(node.condition)} ? ... : ...}`
27636
27847
  });
27637
27848
  }
27638
- collectDomBindings(node.whenTrue, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27639
- 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);
27640
27851
  break;
27641
27852
  }
27642
27853
  case "loop": {
27643
27854
  if (node.slotId) {
27644
27855
  const deps = extractReactiveDeps(node.array, signalGetters, memoNames);
27645
- 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);
27646
27857
  const isReactive = deps.length > 0 || node.callsReactiveGetters === true || loopReactive;
27647
27858
  const isFallback = !isReactive && node.hasFunctionCalls === true;
27648
27859
  if (isReactive || isFallback) {
@@ -27661,11 +27872,9 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27661
27872
  });
27662
27873
  }
27663
27874
  }
27664
- const childLoopParams = new Set(loopParams);
27665
- for (const p of extractLoopParamNames(node.param, node)) childLoopParams.add(p);
27666
- if (node.index) childLoopParams.add(node.index);
27875
+ const childScope = scope.enterLoopRow(node);
27667
27876
  for (const child of node.children) {
27668
- collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, childLoopParams, readsProp);
27877
+ collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, childScope, readsProp);
27669
27878
  }
27670
27879
  break;
27671
27880
  }
@@ -27695,21 +27904,21 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27695
27904
  }
27696
27905
  }
27697
27906
  for (const child of node.children) {
27698
- collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27907
+ collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27699
27908
  }
27700
27909
  break;
27701
27910
  }
27702
27911
  case "fragment":
27703
27912
  case "provider": {
27704
27913
  for (const child of node.children) {
27705
- collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27914
+ collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27706
27915
  }
27707
27916
  break;
27708
27917
  }
27709
27918
  case "if-statement": {
27710
- collectDomBindings(node.consequent, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27919
+ collectDomBindings(node.consequent, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27711
27920
  if (node.alternate) {
27712
- collectDomBindings(node.alternate, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27921
+ collectDomBindings(node.alternate, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27713
27922
  }
27714
27923
  break;
27715
27924
  }
@@ -27722,18 +27931,18 @@ function truncateExpr(expr, max = 40) {
27722
27931
  function exprReadsPropMember(expr, propsObjectName) {
27723
27932
  let sf;
27724
27933
  try {
27725
- sf = ts26.createSourceFile("__attr.tsx", `(${expr})`, ts26.ScriptTarget.Latest, true, ts26.ScriptKind.TSX);
27934
+ sf = ts28.createSourceFile("__attr.tsx", `(${expr})`, ts28.ScriptTarget.Latest, true, ts28.ScriptKind.TSX);
27726
27935
  } catch {
27727
27936
  return false;
27728
27937
  }
27729
27938
  let found = false;
27730
27939
  const visit3 = (n) => {
27731
27940
  if (found) return;
27732
- if (ts26.isPropertyAccessExpression(n) && ts26.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") {
27733
27942
  found = true;
27734
27943
  return;
27735
27944
  }
27736
- ts26.forEachChild(n, visit3);
27945
+ ts28.forEachChild(n, visit3);
27737
27946
  };
27738
27947
  visit3(sf);
27739
27948
  return found;
@@ -27761,12 +27970,12 @@ function attrValueToString2(value2) {
27761
27970
  function extractReactiveDeps(expr, signalGetters, memoNames) {
27762
27971
  const deps = [];
27763
27972
  for (const getter of signalGetters) {
27764
- if (new RegExp(`\\b${getter}\\s*\\(`).test(expr)) {
27973
+ if (identifierCallPattern(getter).test(expr)) {
27765
27974
  deps.push(getter);
27766
27975
  }
27767
27976
  }
27768
27977
  for (const memo of memoNames) {
27769
- if (new RegExp(`\\b${memo}\\s*\\(`).test(expr)) {
27978
+ if (identifierCallPattern(memo).test(expr)) {
27770
27979
  deps.push(memo);
27771
27980
  }
27772
27981
  }
@@ -27779,7 +27988,7 @@ function extractSetterRefs(expr, signalGetters) {
27779
27988
  refs.push(match[1]);
27780
27989
  }
27781
27990
  for (const getter of signalGetters) {
27782
- if (new RegExp(`\\b${getter}\\s*\\(`).test(expr)) {
27991
+ if (identifierCallPattern(getter).test(expr)) {
27783
27992
  refs.push(getter);
27784
27993
  }
27785
27994
  }
@@ -27806,11 +28015,13 @@ var init_debug = __esm({
27806
28015
  init_ir_to_client_js();
27807
28016
  init_reactivity();
27808
28017
  init_utils();
28018
+ init_identifier_pattern();
28019
+ init_binding_scope();
27809
28020
  }
27810
28021
  });
27811
28022
 
27812
28023
  // ../jsx/src/profiler.ts
27813
- import ts27 from "typescript";
28024
+ import ts29 from "typescript";
27814
28025
  function buildStaticBudget(source, filePath, componentName, options2 = {}) {
27815
28026
  const threshold = options2.fanOutThreshold ?? DEFAULT_FANOUT_THRESHOLD;
27816
28027
  const program = createProgramForFile(source, filePath)?.program;
@@ -28065,14 +28276,14 @@ function joinProfilerEvents(events, index) {
28065
28276
  return { joined, unattributed, diagnostics };
28066
28277
  }
28067
28278
  function findUninstrumentedEffects(source, filePath, instrumentedLines) {
28068
- const sf = ts27.createSourceFile(filePath, source, ts27.ScriptTarget.Latest, true, ts27.ScriptKind.TSX);
28279
+ const sf = ts29.createSourceFile(filePath, source, ts29.ScriptTarget.Latest, true, ts29.ScriptKind.TSX);
28069
28280
  const out = [];
28070
28281
  const visit3 = (node) => {
28071
- if (ts27.isCallExpression(node) && ts27.isIdentifier(node.expression) && node.expression.text === "createEffect") {
28282
+ if (ts29.isCallExpression(node) && ts29.isIdentifier(node.expression) && node.expression.text === "createEffect") {
28072
28283
  const line = sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;
28073
28284
  if (!instrumentedLines.has(line)) out.push({ file: filePath, line });
28074
28285
  }
28075
- ts27.forEachChild(node, visit3);
28286
+ ts29.forEachChild(node, visit3);
28076
28287
  };
28077
28288
  visit3(sf);
28078
28289
  out.sort((a, b) => a.line - b.line);
@@ -28358,19 +28569,19 @@ function assessBatchSafety(args2) {
28358
28569
  const signalGetters = new Set(args2.graph.signals.map((s) => s.name));
28359
28570
  let sf;
28360
28571
  try {
28361
- sf = ts27.createSourceFile("__h.ts", `const __h = ${args2.handler}`, ts27.ScriptTarget.Latest, true);
28572
+ sf = ts29.createSourceFile("__h.ts", `const __h = ${args2.handler}`, ts29.ScriptTarget.Latest, true);
28362
28573
  } catch {
28363
28574
  return "unverified";
28364
28575
  }
28365
28576
  const calls = [];
28366
28577
  const visit3 = (node) => {
28367
- if (ts27.isCallExpression(node) && ts27.isIdentifier(node.expression)) {
28578
+ if (ts29.isCallExpression(node) && ts29.isIdentifier(node.expression)) {
28368
28579
  const name2 = node.expression.text;
28369
28580
  if (setters.has(name2)) calls.push({ pos: node.getStart(sf), kind: "write" });
28370
28581
  else if (D.has(name2) && node.arguments.length === 0) calls.push({ pos: node.getStart(sf), kind: "memoRead" });
28371
28582
  else if (!signalGetters.has(name2) && !memoNames.has(name2)) calls.push({ pos: node.getStart(sf), kind: "risky" });
28372
28583
  }
28373
- ts27.forEachChild(node, visit3);
28584
+ ts29.forEachChild(node, visit3);
28374
28585
  };
28375
28586
  visit3(sf);
28376
28587
  calls.sort((a, b) => a.pos - b.pos);
@@ -29175,6 +29386,7 @@ __export(src_exports, {
29175
29386
  resolveDangerousInnerHtml: () => resolveDangerousInnerHtml,
29176
29387
  resolveSetters: () => resolveSetters,
29177
29388
  resolveStaticLoopSource: () => resolveStaticLoopSource,
29389
+ rewriteDynamicImportsInSource: () => rewriteDynamicImportsInSource,
29178
29390
  rewriteImportsForTemplate: () => rewriteImportsForTemplate,
29179
29391
  searchParamsLocalNames: () => searchParamsLocalNames,
29180
29392
  serializeParsedExpr: () => serializeParsedExpr,
@@ -110033,7 +110245,7 @@ __export(scenario_driver_exports, {
110033
110245
  import { writeFileSync as writeFileSync9, mkdtempSync, rmSync, readFileSync as readFileSync19, existsSync as existsSync23, statSync as statSync3 } from "node:fs";
110034
110246
  import { join as join2, dirname as dirname4, resolve as resolve6 } from "node:path";
110035
110247
  import { tmpdir } from "node:os";
110036
- import ts28 from "typescript";
110248
+ import ts30 from "typescript";
110037
110249
  function externalRuntimeImport(clientJs) {
110038
110250
  const chunks = Array.isArray(clientJs) ? clientJs : [clientJs];
110039
110251
  for (const chunk of chunks) {
@@ -110103,11 +110315,11 @@ function resolveLocalFile(spec) {
110103
110315
  }
110104
110316
  function rewriteLocalImports(js, chunkPath, inlined) {
110105
110317
  const chunkDir = dirname4(chunkPath);
110106
- const sf = ts28.createSourceFile("chunk.mjs", js, ts28.ScriptTarget.Latest, false, ts28.ScriptKind.JS);
110318
+ const sf = ts30.createSourceFile("chunk.mjs", js, ts30.ScriptTarget.Latest, false, ts30.ScriptKind.JS);
110107
110319
  const edits = [];
110108
110320
  for (const stmt of sf.statements) {
110109
- if (!ts28.isImportDeclaration(stmt)) continue;
110110
- if (!ts28.isStringLiteral(stmt.moduleSpecifier)) continue;
110321
+ if (!ts30.isImportDeclaration(stmt)) continue;
110322
+ if (!ts30.isStringLiteral(stmt.moduleSpecifier)) continue;
110111
110323
  const spec = stmt.moduleSpecifier.text;
110112
110324
  if (!spec.startsWith(".")) continue;
110113
110325
  const resolved = resolveLocalFile(join2(chunkDir, spec.replace(/\.client\.js$/, "")));
@@ -110119,13 +110331,13 @@ function rewriteLocalImports(js, chunkPath, inlined) {
110119
110331
  const abs = resolve6(resolved);
110120
110332
  if (inlined.has(abs)) {
110121
110333
  const clause = stmt.importClause;
110122
- if (clause && (clause.name || clause.namedBindings && ts28.isNamespaceImport(clause.namedBindings))) {
110334
+ if (clause && (clause.name || clause.namedBindings && ts30.isNamespaceImport(clause.namedBindings))) {
110123
110335
  throw new Error(
110124
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.`
110125
110337
  );
110126
110338
  }
110127
110339
  const shims = [];
110128
- if (clause?.namedBindings && ts28.isNamedImports(clause.namedBindings)) {
110340
+ if (clause?.namedBindings && ts30.isNamedImports(clause.namedBindings)) {
110129
110341
  for (const el of clause.namedBindings.elements) {
110130
110342
  if (el.propertyName) shims.push(`var ${el.name.text} = ${el.propertyName.text}`);
110131
110343
  }