@angular/core 17.1.0-next.4 → 17.1.0-rc.0

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 (87) hide show
  1. package/esm2022/primitives/signals/index.mjs +2 -2
  2. package/esm2022/primitives/signals/src/signal.mjs +2 -10
  3. package/esm2022/src/application/application_ref.mjs +24 -12
  4. package/esm2022/src/application/create_application.mjs +2 -2
  5. package/esm2022/src/authoring/input.mjs +12 -5
  6. package/esm2022/src/authoring/input_signal.mjs +28 -1
  7. package/esm2022/src/authoring/input_signal_node.mjs +22 -0
  8. package/esm2022/src/authoring.mjs +1 -4
  9. package/esm2022/src/change_detection/flags.mjs +16 -0
  10. package/esm2022/src/change_detection/scheduling/ng_zone_scheduling.mjs +164 -0
  11. package/esm2022/src/change_detection/scheduling/zoneless_scheduling.mjs +13 -0
  12. package/esm2022/src/change_detection/scheduling/zoneless_scheduling_impl.mjs +56 -0
  13. package/esm2022/src/compiler/compiler_facade_interface.mjs +1 -1
  14. package/esm2022/src/core.mjs +3 -3
  15. package/esm2022/src/core_private_export.mjs +5 -2
  16. package/esm2022/src/core_render3_private_export.mjs +2 -2
  17. package/esm2022/src/defer/dom_triggers.mjs +1 -5
  18. package/esm2022/src/di/inject_switch.mjs +2 -3
  19. package/esm2022/src/di/r3_injector.mjs +8 -6
  20. package/esm2022/src/errors.mjs +1 -1
  21. package/esm2022/src/event_emitter.mjs +1 -2
  22. package/esm2022/src/hydration/utils.mjs +2 -2
  23. package/esm2022/src/hydration/views.mjs +2 -2
  24. package/esm2022/src/linker/view_container_ref.mjs +2 -2
  25. package/esm2022/src/metadata/directives.mjs +1 -1
  26. package/esm2022/src/pending_tasks.mjs +57 -0
  27. package/esm2022/src/platform/platform_ref.mjs +2 -2
  28. package/esm2022/src/render3/after_render_hooks.mjs +16 -34
  29. package/esm2022/src/render3/apply_value_input_field.mjs +16 -0
  30. package/esm2022/src/render3/collect_native_nodes.mjs +2 -3
  31. package/esm2022/src/render3/component_ref.mjs +24 -13
  32. package/esm2022/src/render3/debug/injector_profiler.mjs +1 -1
  33. package/esm2022/src/render3/definition.mjs +27 -68
  34. package/esm2022/src/render3/errors_di.mjs +4 -3
  35. package/esm2022/src/render3/features/host_directives_feature.mjs +2 -3
  36. package/esm2022/src/render3/features/inherit_definition_feature.mjs +31 -9
  37. package/esm2022/src/render3/features/input_transforms_feature.mjs +4 -5
  38. package/esm2022/src/render3/features/ng_onchanges_feature.mjs +4 -3
  39. package/esm2022/src/render3/instructions/advance.mjs +2 -2
  40. package/esm2022/src/render3/instructions/change_detection.mjs +1 -6
  41. package/esm2022/src/render3/instructions/control_flow.mjs +5 -3
  42. package/esm2022/src/render3/instructions/listener.mjs +1 -1
  43. package/esm2022/src/render3/instructions/mark_view_dirty.mjs +4 -3
  44. package/esm2022/src/render3/instructions/shared.mjs +63 -59
  45. package/esm2022/src/render3/instructions/write_to_directive_input.mjs +43 -0
  46. package/esm2022/src/render3/interfaces/container.mjs +1 -6
  47. package/esm2022/src/render3/interfaces/definition.mjs +8 -2
  48. package/esm2022/src/render3/interfaces/node.mjs +1 -1
  49. package/esm2022/src/render3/interfaces/view.mjs +1 -1
  50. package/esm2022/src/render3/jit/environment.mjs +3 -1
  51. package/esm2022/src/render3/node_manipulation.mjs +8 -8
  52. package/esm2022/src/render3/reactivity/effect.mjs +8 -6
  53. package/esm2022/src/render3/reactivity/signal.mjs +1 -1
  54. package/esm2022/src/render3/styling/style_binding_list.mjs +4 -4
  55. package/esm2022/src/render3/util/discovery_utils.mjs +37 -5
  56. package/esm2022/src/render3/util/global_utils.mjs +28 -28
  57. package/esm2022/src/render3/util/injector_discovery_utils.mjs +1 -1
  58. package/esm2022/src/render3/util/injector_utils.mjs +6 -5
  59. package/esm2022/src/render3/util/view_traversal_utils.mjs +3 -12
  60. package/esm2022/src/render3/util/view_utils.mjs +36 -19
  61. package/esm2022/src/render3/view_ref.mjs +2 -1
  62. package/esm2022/src/testability/testability.mjs +3 -15
  63. package/esm2022/src/util/empty.mjs +1 -1
  64. package/esm2022/src/version.mjs +6 -5
  65. package/esm2022/src/zone/ng_zone.mjs +1 -61
  66. package/esm2022/testing/src/component_fixture.mjs +62 -58
  67. package/esm2022/testing/src/logger.mjs +3 -3
  68. package/fesm2022/core.mjs +699 -542
  69. package/fesm2022/core.mjs.map +1 -1
  70. package/fesm2022/primitives/signals.mjs +2 -10
  71. package/fesm2022/primitives/signals.mjs.map +1 -1
  72. package/fesm2022/rxjs-interop.mjs +1 -1
  73. package/fesm2022/testing.mjs +62 -58
  74. package/fesm2022/testing.mjs.map +1 -1
  75. package/index.d.ts +677 -252
  76. package/package.json +1 -1
  77. package/primitives/signals/index.d.ts +3 -4
  78. package/rxjs-interop/index.d.ts +1 -1
  79. package/schematics/migrations/block-template-entities/bundle.js +497 -392
  80. package/schematics/migrations/block-template-entities/bundle.js.map +4 -4
  81. package/schematics/ng-generate/control-flow-migration/bundle.js +663 -459
  82. package/schematics/ng-generate/control-flow-migration/bundle.js.map +4 -4
  83. package/schematics/ng-generate/standalone-migration/bundle.js +816 -616
  84. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  85. package/testing/index.d.ts +6 -2
  86. package/esm2022/src/change_detection/scheduling.mjs +0 -103
  87. package/esm2022/src/initial_render_pending_tasks.mjs +0 -49
@@ -457,6 +457,12 @@ var ChangeDetectionStrategy;
457
457
  ChangeDetectionStrategy2[ChangeDetectionStrategy2["OnPush"] = 0] = "OnPush";
458
458
  ChangeDetectionStrategy2[ChangeDetectionStrategy2["Default"] = 1] = "Default";
459
459
  })(ChangeDetectionStrategy || (ChangeDetectionStrategy = {}));
460
+ var InputFlags;
461
+ (function(InputFlags2) {
462
+ InputFlags2[InputFlags2["None"] = 0] = "None";
463
+ InputFlags2[InputFlags2["SignalBased"] = 1] = "SignalBased";
464
+ InputFlags2[InputFlags2["HasDecoratorInputTransform"] = 2] = "HasDecoratorInputTransform";
465
+ })(InputFlags || (InputFlags = {}));
460
466
  var CUSTOM_ELEMENTS_SCHEMA = {
461
467
  name: "custom-elements"
462
468
  };
@@ -817,12 +823,13 @@ var BinaryOperator;
817
823
  BinaryOperator2[BinaryOperator2["Modulo"] = 8] = "Modulo";
818
824
  BinaryOperator2[BinaryOperator2["And"] = 9] = "And";
819
825
  BinaryOperator2[BinaryOperator2["Or"] = 10] = "Or";
820
- BinaryOperator2[BinaryOperator2["BitwiseAnd"] = 11] = "BitwiseAnd";
821
- BinaryOperator2[BinaryOperator2["Lower"] = 12] = "Lower";
822
- BinaryOperator2[BinaryOperator2["LowerEquals"] = 13] = "LowerEquals";
823
- BinaryOperator2[BinaryOperator2["Bigger"] = 14] = "Bigger";
824
- BinaryOperator2[BinaryOperator2["BiggerEquals"] = 15] = "BiggerEquals";
825
- BinaryOperator2[BinaryOperator2["NullishCoalesce"] = 16] = "NullishCoalesce";
826
+ BinaryOperator2[BinaryOperator2["BitwiseOr"] = 11] = "BitwiseOr";
827
+ BinaryOperator2[BinaryOperator2["BitwiseAnd"] = 12] = "BitwiseAnd";
828
+ BinaryOperator2[BinaryOperator2["Lower"] = 13] = "Lower";
829
+ BinaryOperator2[BinaryOperator2["LowerEquals"] = 14] = "LowerEquals";
830
+ BinaryOperator2[BinaryOperator2["Bigger"] = 15] = "Bigger";
831
+ BinaryOperator2[BinaryOperator2["BiggerEquals"] = 16] = "BiggerEquals";
832
+ BinaryOperator2[BinaryOperator2["NullishCoalesce"] = 17] = "NullishCoalesce";
826
833
  })(BinaryOperator || (BinaryOperator = {}));
827
834
  function nullSafeIsEquivalent(base, other) {
828
835
  if (base == null || other == null) {
@@ -895,6 +902,9 @@ var Expression = class {
895
902
  and(rhs, sourceSpan) {
896
903
  return new BinaryOperatorExpr(BinaryOperator.And, this, rhs, null, sourceSpan);
897
904
  }
905
+ bitwiseOr(rhs, sourceSpan, parens = true) {
906
+ return new BinaryOperatorExpr(BinaryOperator.BitwiseOr, this, rhs, null, sourceSpan, parens);
907
+ }
898
908
  bitwiseAnd(rhs, sourceSpan, parens = true) {
899
909
  return new BinaryOperatorExpr(BinaryOperator.BitwiseAnd, this, rhs, null, sourceSpan, parens);
900
910
  }
@@ -1805,7 +1815,7 @@ var ConstantPool = class {
1805
1815
  }))));
1806
1816
  }
1807
1817
  }
1808
- getSharedFunctionReference(fn2, prefix) {
1818
+ getSharedFunctionReference(fn2, prefix, useUniqueName = true) {
1809
1819
  var _a2;
1810
1820
  const isArrow = fn2 instanceof ArrowFunctionExpr;
1811
1821
  for (const current of this.statements) {
@@ -1816,7 +1826,7 @@ var ConstantPool = class {
1816
1826
  return variable(current.name);
1817
1827
  }
1818
1828
  }
1819
- const name = this.uniqueName(prefix);
1829
+ const name = useUniqueName ? this.uniqueName(prefix) : prefix;
1820
1830
  this.statements.push(fn2.toDeclStmt(name, StmtModifier.Final));
1821
1831
  return variable(name);
1822
1832
  }
@@ -2490,6 +2500,12 @@ var Identifiers = _Identifiers;
2490
2500
  moduleName: CORE
2491
2501
  };
2492
2502
  })();
2503
+ (() => {
2504
+ _Identifiers.InputFlags = {
2505
+ name: "\u0275\u0275InputFlags",
2506
+ moduleName: CORE
2507
+ };
2508
+ })();
2493
2509
  (() => {
2494
2510
  _Identifiers.sanitizeHtml = { name: "\u0275\u0275sanitizeHtml", moduleName: CORE };
2495
2511
  })();
@@ -3089,6 +3105,9 @@ var AbstractEmitterVisitor = class {
3089
3105
  case BinaryOperator.And:
3090
3106
  opStr = "&&";
3091
3107
  break;
3108
+ case BinaryOperator.BitwiseOr:
3109
+ opStr = "|";
3110
+ break;
3092
3111
  case BinaryOperator.BitwiseAnd:
3093
3112
  opStr = "&";
3094
3113
  break;
@@ -3443,13 +3462,17 @@ var TagContentType;
3443
3462
  TagContentType2[TagContentType2["ESCAPABLE_RAW_TEXT"] = 1] = "ESCAPABLE_RAW_TEXT";
3444
3463
  TagContentType2[TagContentType2["PARSABLE_DATA"] = 2] = "PARSABLE_DATA";
3445
3464
  })(TagContentType || (TagContentType = {}));
3446
- function splitNsName(elementName) {
3465
+ function splitNsName(elementName, fatal = true) {
3447
3466
  if (elementName[0] != ":") {
3448
3467
  return [null, elementName];
3449
3468
  }
3450
3469
  const colonIndex = elementName.indexOf(":", 1);
3451
3470
  if (colonIndex === -1) {
3452
- throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
3471
+ if (fatal) {
3472
+ throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
3473
+ } else {
3474
+ return [null, elementName];
3475
+ }
3453
3476
  }
3454
3477
  return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)];
3455
3478
  }
@@ -3956,28 +3979,6 @@ var BlockPlaceholder = class {
3956
3979
  return visitor.visitBlockPlaceholder(this, context);
3957
3980
  }
3958
3981
  };
3959
- var RecurseVisitor = class {
3960
- visitText(text2, context) {
3961
- }
3962
- visitContainer(container, context) {
3963
- container.children.forEach((child) => child.visit(this));
3964
- }
3965
- visitIcu(icu, context) {
3966
- Object.keys(icu.cases).forEach((k) => {
3967
- icu.cases[k].visit(this);
3968
- });
3969
- }
3970
- visitTagPlaceholder(ph, context) {
3971
- ph.children.forEach((child) => child.visit(this));
3972
- }
3973
- visitPlaceholder(ph, context) {
3974
- }
3975
- visitIcuPlaceholder(ph, context) {
3976
- }
3977
- visitBlockPlaceholder(ph, context) {
3978
- ph.children.forEach((child) => child.visit(this));
3979
- }
3980
- };
3981
3982
  function serializeMessage(messageNodes) {
3982
3983
  const visitor = new LocalizeMessageStringVisitor();
3983
3984
  const str = messageNodes.map((n) => n.visit(visitor)).join("");
@@ -4233,7 +4234,7 @@ function asLiteral(value) {
4233
4234
  }
4234
4235
  return literal(value, INFERRED_TYPE);
4235
4236
  }
4236
- function conditionallyCreateDirectiveBindingLiteral(map, keepDeclared) {
4237
+ function conditionallyCreateDirectiveBindingLiteral(map, forInputs) {
4237
4238
  const keys = Object.getOwnPropertyNames(map);
4238
4239
  if (keys.length === 0) {
4239
4240
  return null;
@@ -4253,12 +4254,25 @@ function conditionallyCreateDirectiveBindingLiteral(map, keepDeclared) {
4253
4254
  minifiedName = key;
4254
4255
  declaredName = value.classPropertyName;
4255
4256
  publicName = value.bindingPropertyName;
4256
- if (keepDeclared && (publicName !== declaredName || value.transformFunction != null)) {
4257
- const expressionKeys = [asLiteral(publicName), asLiteral(declaredName)];
4258
- if (value.transformFunction != null) {
4259
- expressionKeys.push(value.transformFunction);
4257
+ const differentDeclaringName = publicName !== declaredName;
4258
+ const hasDecoratorInputTransform = value.transformFunction !== null;
4259
+ let flags = null;
4260
+ if (value.isSignal) {
4261
+ flags = bitwiseOrInputFlagsExpr(InputFlags.SignalBased, flags);
4262
+ }
4263
+ if (hasDecoratorInputTransform) {
4264
+ flags = bitwiseOrInputFlagsExpr(InputFlags.HasDecoratorInputTransform, flags);
4265
+ }
4266
+ if (forInputs && (differentDeclaringName || hasDecoratorInputTransform || flags !== null)) {
4267
+ const flagsExpr = flags != null ? flags : importExpr(Identifiers.InputFlags).prop(InputFlags[InputFlags.None]);
4268
+ const result = [flagsExpr, asLiteral(publicName)];
4269
+ if (differentDeclaringName || hasDecoratorInputTransform) {
4270
+ result.push(asLiteral(declaredName));
4271
+ if (hasDecoratorInputTransform) {
4272
+ result.push(value.transformFunction);
4273
+ }
4260
4274
  }
4261
- expressionValue = literalArr(expressionKeys);
4275
+ expressionValue = literalArr(result);
4262
4276
  } else {
4263
4277
  expressionValue = asLiteral(publicName);
4264
4278
  }
@@ -4270,6 +4284,15 @@ function conditionallyCreateDirectiveBindingLiteral(map, keepDeclared) {
4270
4284
  };
4271
4285
  }));
4272
4286
  }
4287
+ function getInputFlagExpr(flag) {
4288
+ return importExpr(Identifiers.InputFlags).prop(InputFlags[flag]);
4289
+ }
4290
+ function bitwiseOrInputFlagsExpr(flag, expr) {
4291
+ if (expr === null) {
4292
+ return getInputFlagExpr(flag);
4293
+ }
4294
+ return getInputFlagExpr(flag).bitwiseOr(expr);
4295
+ }
4273
4296
  function trimTrailingNulls(parameters) {
4274
4297
  while (isNull(parameters[parameters.length - 1])) {
4275
4298
  parameters.pop();
@@ -7045,8 +7068,9 @@ var OpKind;
7045
7068
  OpKind2[OpKind2["I18nApply"] = 40] = "I18nApply";
7046
7069
  OpKind2[OpKind2["IcuStart"] = 41] = "IcuStart";
7047
7070
  OpKind2[OpKind2["IcuEnd"] = 42] = "IcuEnd";
7048
- OpKind2[OpKind2["I18nContext"] = 43] = "I18nContext";
7049
- OpKind2[OpKind2["I18nAttributes"] = 44] = "I18nAttributes";
7071
+ OpKind2[OpKind2["IcuPlaceholder"] = 43] = "IcuPlaceholder";
7072
+ OpKind2[OpKind2["I18nContext"] = 44] = "I18nContext";
7073
+ OpKind2[OpKind2["I18nAttributes"] = 45] = "I18nAttributes";
7050
7074
  })(OpKind || (OpKind = {}));
7051
7075
  var ExpressionKind;
7052
7076
  (function(ExpressionKind2) {
@@ -7144,13 +7168,6 @@ var DeferTriggerKind;
7144
7168
  DeferTriggerKind2[DeferTriggerKind2["Interaction"] = 4] = "Interaction";
7145
7169
  DeferTriggerKind2[DeferTriggerKind2["Viewport"] = 5] = "Viewport";
7146
7170
  })(DeferTriggerKind || (DeferTriggerKind = {}));
7147
- var DerivedRepeaterVarIdentity;
7148
- (function(DerivedRepeaterVarIdentity2) {
7149
- DerivedRepeaterVarIdentity2[DerivedRepeaterVarIdentity2["First"] = 0] = "First";
7150
- DerivedRepeaterVarIdentity2[DerivedRepeaterVarIdentity2["Last"] = 1] = "Last";
7151
- DerivedRepeaterVarIdentity2[DerivedRepeaterVarIdentity2["Even"] = 2] = "Even";
7152
- DerivedRepeaterVarIdentity2[DerivedRepeaterVarIdentity2["Odd"] = 3] = "Odd";
7153
- })(DerivedRepeaterVarIdentity || (DerivedRepeaterVarIdentity = {}));
7154
7171
  var I18nContextKind;
7155
7172
  (function(I18nContextKind2) {
7156
7173
  I18nContextKind2[I18nContextKind2["RootI18n"] = 0] = "RootI18n";
@@ -7305,10 +7322,11 @@ function createClassMapOp(xref, expression, sourceSpan) {
7305
7322
  sourceSpan
7306
7323
  }, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
7307
7324
  }
7308
- function createAttributeOp(target, name, expression, securityContext, isTextAttribute, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan) {
7325
+ function createAttributeOp(target, namespace, name, expression, securityContext, isTextAttribute, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan) {
7309
7326
  return __spreadValues(__spreadValues(__spreadValues({
7310
7327
  kind: OpKind.Attribute,
7311
7328
  target,
7329
+ namespace,
7312
7330
  name,
7313
7331
  expression,
7314
7332
  securityContext,
@@ -7350,15 +7368,15 @@ function createRepeaterOp(repeaterCreate2, targetSlot, collection, sourceSpan) {
7350
7368
  }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
7351
7369
  }
7352
7370
  function createDeferWhenOp(target, expr, prefetch, sourceSpan) {
7353
- return __spreadValues(__spreadValues({
7371
+ return __spreadValues(__spreadValues(__spreadValues({
7354
7372
  kind: OpKind.DeferWhen,
7355
7373
  target,
7356
7374
  expr,
7357
7375
  prefetch,
7358
7376
  sourceSpan
7359
- }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
7377
+ }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS);
7360
7378
  }
7361
- function createI18nExpressionOp(context, target, i18nOwner, handle, expression, i18nPlaceholder, resolutionTime, usage, name, sourceSpan) {
7379
+ function createI18nExpressionOp(context, target, i18nOwner, handle, expression, icuPlaceholder, i18nPlaceholder, resolutionTime, usage, name, sourceSpan) {
7362
7380
  return __spreadValues(__spreadValues(__spreadValues({
7363
7381
  kind: OpKind.I18nExpression,
7364
7382
  context,
@@ -7366,6 +7384,7 @@ function createI18nExpressionOp(context, target, i18nOwner, handle, expression,
7366
7384
  i18nOwner,
7367
7385
  handle,
7368
7386
  expression,
7387
+ icuPlaceholder,
7369
7388
  i18nPlaceholder,
7370
7389
  resolutionTime,
7371
7390
  usage,
@@ -7962,27 +7981,6 @@ var ConditionalCaseExpr = class extends ExpressionBase {
7962
7981
  }
7963
7982
  }
7964
7983
  };
7965
- var DerivedRepeaterVarExpr = class extends ExpressionBase {
7966
- constructor(xref, identity) {
7967
- super();
7968
- this.xref = xref;
7969
- this.identity = identity;
7970
- this.kind = ExpressionKind.DerivedRepeaterVar;
7971
- }
7972
- transformInternalExpressions(transform2, flags) {
7973
- }
7974
- visitExpression(visitor, context) {
7975
- }
7976
- isEquivalent(e) {
7977
- return e instanceof DerivedRepeaterVarExpr && e.identity === this.identity && e.xref === this.xref;
7978
- }
7979
- isConstant() {
7980
- return false;
7981
- }
7982
- clone() {
7983
- return new DerivedRepeaterVarExpr(this.xref, this.identity);
7984
- }
7985
- };
7986
7984
  var ConstCollectedExpr = class extends ExpressionBase {
7987
7985
  constructor(expr) {
7988
7986
  super();
@@ -8098,6 +8096,9 @@ function transformExpressionsInOp(op, transform2, flags) {
8098
8096
  if (op.placeholderConfig !== null) {
8099
8097
  op.placeholderConfig = transformExpressionsInExpression(op.placeholderConfig, transform2, flags);
8100
8098
  }
8099
+ if (op.resolverFn !== null) {
8100
+ op.resolverFn = transformExpressionsInExpression(op.resolverFn, transform2, flags);
8101
+ }
8101
8102
  break;
8102
8103
  case OpKind.I18nMessage:
8103
8104
  for (const [placeholder, expr] of op.params) {
@@ -8134,6 +8135,7 @@ function transformExpressionsInOp(op, transform2, flags) {
8134
8135
  case OpKind.Template:
8135
8136
  case OpKind.Text:
8136
8137
  case OpKind.I18nAttributes:
8138
+ case OpKind.IcuPlaceholder:
8137
8139
  break;
8138
8140
  default:
8139
8141
  throw new Error(`AssertionError: transformExpressionsInOp doesn't handle ${OpKind[op.kind]}`);
@@ -8191,6 +8193,14 @@ function transformExpressionsInExpression(expr, transform2, flags) {
8191
8193
  } else if (expr instanceof TaggedTemplateExpr) {
8192
8194
  expr.tag = transformExpressionsInExpression(expr.tag, transform2, flags);
8193
8195
  expr.template.expressions = expr.template.expressions.map((e) => transformExpressionsInExpression(e, transform2, flags));
8196
+ } else if (expr instanceof ArrowFunctionExpr) {
8197
+ if (Array.isArray(expr.body)) {
8198
+ for (let i = 0; i < expr.body.length; i++) {
8199
+ transformExpressionsInStatement(expr.body[i], transform2, flags);
8200
+ }
8201
+ } else {
8202
+ expr.body = transformExpressionsInExpression(expr.body, transform2, flags);
8203
+ }
8194
8204
  } else if (expr instanceof WrappedNodeExpr) {
8195
8205
  } else if (expr instanceof ReadVarExpr || expr instanceof ExternalExpr || expr instanceof LiteralExpr) {
8196
8206
  } else {
@@ -8433,7 +8443,7 @@ var elementContainerOpKinds = /* @__PURE__ */ new Set([
8433
8443
  function isElementOrContainerOp(op) {
8434
8444
  return elementContainerOpKinds.has(op.kind);
8435
8445
  }
8436
- function createElementStartOp(tag, xref, namespace, i18nPlaceholder, sourceSpan) {
8446
+ function createElementStartOp(tag, xref, namespace, i18nPlaceholder, startSourceSpan, wholeSourceSpan) {
8437
8447
  return __spreadValues(__spreadValues({
8438
8448
  kind: OpKind.ElementStart,
8439
8449
  xref,
@@ -8444,10 +8454,11 @@ function createElementStartOp(tag, xref, namespace, i18nPlaceholder, sourceSpan)
8444
8454
  nonBindable: false,
8445
8455
  namespace,
8446
8456
  i18nPlaceholder,
8447
- sourceSpan
8457
+ startSourceSpan,
8458
+ wholeSourceSpan
8448
8459
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8449
8460
  }
8450
- function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace, i18nPlaceholder, sourceSpan) {
8461
+ function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace, i18nPlaceholder, startSourceSpan, wholeSourceSpan) {
8451
8462
  return __spreadValues(__spreadValues({
8452
8463
  kind: OpKind.Template,
8453
8464
  xref,
@@ -8462,11 +8473,12 @@ function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace
8462
8473
  nonBindable: false,
8463
8474
  namespace,
8464
8475
  i18nPlaceholder,
8465
- sourceSpan
8476
+ startSourceSpan,
8477
+ wholeSourceSpan
8466
8478
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8467
8479
  }
8468
- function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, sourceSpan) {
8469
- return __spreadProps(__spreadValues(__spreadValues({
8480
+ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, emptyTag, i18nPlaceholder, emptyI18nPlaceholder, startSourceSpan, wholeSourceSpan) {
8481
+ return __spreadProps(__spreadValues(__spreadValues(__spreadValues({
8470
8482
  kind: OpKind.RepeaterCreate,
8471
8483
  attributes: null,
8472
8484
  xref: primaryView,
@@ -8475,6 +8487,8 @@ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i1
8475
8487
  track,
8476
8488
  trackByFn: null,
8477
8489
  tag,
8490
+ emptyTag,
8491
+ emptyAttributes: null,
8478
8492
  functionNameSuffix: "For",
8479
8493
  namespace: Namespace.HTML,
8480
8494
  nonBindable: false,
@@ -8485,8 +8499,9 @@ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i1
8485
8499
  usesComponentInstance: false,
8486
8500
  i18nPlaceholder,
8487
8501
  emptyI18nPlaceholder,
8488
- sourceSpan
8489
- }, TRAIT_CONSUMES_SLOT), NEW_OP), {
8502
+ startSourceSpan,
8503
+ wholeSourceSpan
8504
+ }, TRAIT_CONSUMES_SLOT), NEW_OP), TRAIT_CONSUMES_VARS), {
8490
8505
  numSlotsUsed: emptyView === null ? 2 : 3
8491
8506
  });
8492
8507
  }
@@ -8509,12 +8524,13 @@ function createEnableBindingsOp(xref) {
8509
8524
  xref
8510
8525
  }, NEW_OP);
8511
8526
  }
8512
- function createTextOp(xref, initialValue, sourceSpan) {
8527
+ function createTextOp(xref, initialValue, icuPlaceholder, sourceSpan) {
8513
8528
  return __spreadValues(__spreadValues({
8514
8529
  kind: OpKind.Text,
8515
8530
  xref,
8516
8531
  handle: new SlotHandle(),
8517
8532
  initialValue,
8533
+ icuPlaceholder,
8518
8534
  sourceSpan
8519
8535
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8520
8536
  }
@@ -8557,7 +8573,7 @@ function createProjectionDefOp(def) {
8557
8573
  def
8558
8574
  }, NEW_OP);
8559
8575
  }
8560
- function createProjectionOp(xref, selector, i18nPlaceholder, attributes, sourceSpan) {
8576
+ function createProjectionOp(xref, selector, i18nPlaceholder, sourceSpan) {
8561
8577
  return __spreadValues(__spreadValues({
8562
8578
  kind: OpKind.Projection,
8563
8579
  xref,
@@ -8565,16 +8581,17 @@ function createProjectionOp(xref, selector, i18nPlaceholder, attributes, sourceS
8565
8581
  selector,
8566
8582
  i18nPlaceholder,
8567
8583
  projectionSlotIndex: 0,
8568
- attributes,
8584
+ attributes: null,
8569
8585
  localRefs: [],
8570
8586
  sourceSpan
8571
8587
  }, NEW_OP), TRAIT_CONSUMES_SLOT);
8572
8588
  }
8573
- function createExtractedAttributeOp(target, bindingKind, name, expression, i18nContext, i18nMessage, securityContext) {
8589
+ function createExtractedAttributeOp(target, bindingKind, namespace, name, expression, i18nContext, i18nMessage, securityContext) {
8574
8590
  return __spreadValues({
8575
8591
  kind: OpKind.ExtractedAttribute,
8576
8592
  target,
8577
8593
  bindingKind,
8594
+ namespace,
8578
8595
  name,
8579
8596
  expression,
8580
8597
  i18nContext,
@@ -8631,7 +8648,7 @@ function createI18nMessageOp(xref, i18nContext, i18nBlock, message, messagePlace
8631
8648
  subMessages: []
8632
8649
  }, NEW_OP);
8633
8650
  }
8634
- function createI18nStartOp(xref, message, root) {
8651
+ function createI18nStartOp(xref, message, root, sourceSpan) {
8635
8652
  return __spreadValues(__spreadValues({
8636
8653
  kind: OpKind.I18nStart,
8637
8654
  xref,
@@ -8640,13 +8657,15 @@ function createI18nStartOp(xref, message, root) {
8640
8657
  message,
8641
8658
  messageIndex: null,
8642
8659
  subTemplateIndex: null,
8643
- context: null
8660
+ context: null,
8661
+ sourceSpan
8644
8662
  }, NEW_OP), TRAIT_CONSUMES_SLOT);
8645
8663
  }
8646
- function createI18nEndOp(xref) {
8664
+ function createI18nEndOp(xref, sourceSpan) {
8647
8665
  return __spreadValues({
8648
8666
  kind: OpKind.I18nEnd,
8649
- xref
8667
+ xref,
8668
+ sourceSpan
8650
8669
  }, NEW_OP);
8651
8670
  }
8652
8671
  function createIcuStartOp(xref, message, messagePlaceholder, sourceSpan) {
@@ -8665,6 +8684,15 @@ function createIcuEndOp(xref) {
8665
8684
  xref
8666
8685
  }, NEW_OP);
8667
8686
  }
8687
+ function createIcuPlaceholderOp(xref, name, strings) {
8688
+ return __spreadValues({
8689
+ kind: OpKind.IcuPlaceholder,
8690
+ xref,
8691
+ name,
8692
+ strings,
8693
+ expressionPlaceholders: []
8694
+ }, NEW_OP);
8695
+ }
8668
8696
  function createI18nContextOp(contextKind, xref, i18nBlock, message, sourceSpan) {
8669
8697
  if (i18nBlock === null && contextKind !== I18nContextKind.Attr) {
8670
8698
  throw new Error("AssertionError: i18nBlock must be provided for non-attribute contexts.");
@@ -8928,6 +8956,9 @@ function createOpXrefMap(unit) {
8928
8956
  continue;
8929
8957
  }
8930
8958
  map.set(op.xref, op);
8959
+ if (op.kind === OpKind.RepeaterCreate && op.emptyView !== null) {
8960
+ map.set(op.emptyView, op);
8961
+ }
8931
8962
  }
8932
8963
  return map;
8933
8964
  }
@@ -8955,6 +8986,7 @@ function extractAttributes(job) {
8955
8986
  createExtractedAttributeOp(
8956
8987
  op.target,
8957
8988
  bindingKind,
8989
+ null,
8958
8990
  op.name,
8959
8991
  null,
8960
8992
  null,
@@ -8971,6 +9003,7 @@ function extractAttributes(job) {
8971
9003
  OpList.insertBefore(createExtractedAttributeOp(
8972
9004
  op.target,
8973
9005
  BindingKind.Property,
9006
+ null,
8974
9007
  op.name,
8975
9008
  null,
8976
9009
  null,
@@ -8984,6 +9017,7 @@ function extractAttributes(job) {
8984
9017
  const extractedAttributeOp = createExtractedAttributeOp(
8985
9018
  op.target,
8986
9019
  BindingKind.Property,
9020
+ null,
8987
9021
  op.name,
8988
9022
  null,
8989
9023
  null,
@@ -8991,6 +9025,9 @@ function extractAttributes(job) {
8991
9025
  SecurityContext.NONE
8992
9026
  );
8993
9027
  if (job.kind === CompilationJobKind.Host) {
9028
+ if (job.compatibility) {
9029
+ break;
9030
+ }
8994
9031
  unit.create.push(extractedAttributeOp);
8995
9032
  } else {
8996
9033
  OpList.insertBefore(extractedAttributeOp, lookupElement(elements, op.target));
@@ -9012,18 +9049,12 @@ function extractAttributeOp(unit, op, elements) {
9012
9049
  if (op.expression instanceof Interpolation2) {
9013
9050
  return;
9014
9051
  }
9015
- let extractable = op.expression.isConstant();
9052
+ let extractable = op.isTextAttribute || op.expression.isConstant();
9016
9053
  if (unit.job.compatibility === CompatibilityMode.TemplateDefinitionBuilder) {
9017
- extractable = isStringLiteral(op.expression);
9018
- if (op.name === "style" || op.name === "class") {
9019
- extractable && (extractable = op.isTextAttribute);
9020
- }
9021
- if (unit.job.kind === CompilationJobKind.Host) {
9022
- extractable && (extractable = op.isTextAttribute);
9023
- }
9054
+ extractable && (extractable = op.isTextAttribute);
9024
9055
  }
9025
9056
  if (extractable) {
9026
- const extractedAttributeOp = createExtractedAttributeOp(op.target, op.isStructuralTemplateAttribute ? BindingKind.Template : BindingKind.Attribute, op.name, op.expression, op.i18nContext, op.i18nMessage, op.securityContext);
9057
+ const extractedAttributeOp = createExtractedAttributeOp(op.target, op.isStructuralTemplateAttribute ? BindingKind.Template : BindingKind.Attribute, op.namespace, op.name, op.expression, op.i18nContext, op.i18nMessage, op.securityContext);
9027
9058
  if (unit.job.kind === CompilationJobKind.Host) {
9028
9059
  unit.create.push(extractedAttributeOp);
9029
9060
  } else {
@@ -9064,7 +9095,8 @@ function specializeBindings(job) {
9064
9095
  const target = lookupElement2(elements, op.target);
9065
9096
  target.nonBindable = true;
9066
9097
  } else {
9067
- OpList.replace(op, createAttributeOp(op.target, op.name, op.expression, op.securityContext, op.isTextAttribute, op.isStructuralTemplateAttribute, op.templateKind, op.i18nMessage, op.sourceSpan));
9098
+ const [namespace, name] = splitNsName(op.name);
9099
+ OpList.replace(op, createAttributeOp(op.target, namespace, name, op.expression, op.securityContext, op.isTextAttribute, op.isStructuralTemplateAttribute, op.templateKind, op.i18nMessage, op.sourceSpan));
9068
9100
  }
9069
9101
  break;
9070
9102
  case BindingKind.Property:
@@ -9204,6 +9236,7 @@ var BINARY_OPERATORS = /* @__PURE__ */ new Map([
9204
9236
  ["&&", BinaryOperator.And],
9205
9237
  [">", BinaryOperator.Bigger],
9206
9238
  [">=", BinaryOperator.BiggerEquals],
9239
+ ["|", BinaryOperator.BitwiseOr],
9207
9240
  ["&", BinaryOperator.BitwiseAnd],
9208
9241
  ["/", BinaryOperator.Divide],
9209
9242
  ["==", BinaryOperator.Equals],
@@ -9255,9 +9288,9 @@ function collectElementConsts(job) {
9255
9288
  for (const unit of job.units) {
9256
9289
  for (const op of unit.create) {
9257
9290
  if (op.kind === OpKind.ExtractedAttribute) {
9258
- const attributes = allElementAttributes.get(op.target) || new ElementAttributes();
9291
+ const attributes = allElementAttributes.get(op.target) || new ElementAttributes(job.compatibility);
9259
9292
  allElementAttributes.set(op.target, attributes);
9260
- attributes.add(op.bindingKind, op.name, op.expression, op.trustedValueFn);
9293
+ attributes.add(op.bindingKind, op.name, op.expression, op.namespace, op.trustedValueFn);
9261
9294
  OpList.remove(op);
9262
9295
  }
9263
9296
  }
@@ -9265,14 +9298,19 @@ function collectElementConsts(job) {
9265
9298
  if (job instanceof ComponentCompilationJob) {
9266
9299
  for (const unit of job.units) {
9267
9300
  for (const op of unit.create) {
9268
- if (isElementOrContainerOp(op)) {
9301
+ if (op.kind == OpKind.Projection) {
9269
9302
  const attributes = allElementAttributes.get(op.xref);
9270
9303
  if (attributes !== void 0) {
9271
9304
  const attrArray = serializeAttributes(attributes);
9272
9305
  if (attrArray.entries.length > 0) {
9273
- op.attributes = job.addConst(attrArray);
9306
+ op.attributes = attrArray;
9274
9307
  }
9275
9308
  }
9309
+ } else if (isElementOrContainerOp(op)) {
9310
+ op.attributes = getConstIndex(job, allElementAttributes, op.xref);
9311
+ if (op.kind === OpKind.RepeaterCreate && op.emptyView !== null) {
9312
+ op.emptyAttributes = getConstIndex(job, allElementAttributes, op.emptyView);
9313
+ }
9276
9314
  }
9277
9315
  }
9278
9316
  }
@@ -9288,13 +9326,18 @@ function collectElementConsts(job) {
9288
9326
  }
9289
9327
  }
9290
9328
  }
9329
+ function getConstIndex(job, allElementAttributes, xref) {
9330
+ const attributes = allElementAttributes.get(xref);
9331
+ if (attributes !== void 0) {
9332
+ const attrArray = serializeAttributes(attributes);
9333
+ if (attrArray.entries.length > 0) {
9334
+ return job.addConst(attrArray);
9335
+ }
9336
+ }
9337
+ return null;
9338
+ }
9291
9339
  var FLYWEIGHT_ARRAY = Object.freeze([]);
9292
9340
  var ElementAttributes = class {
9293
- constructor() {
9294
- this.known = /* @__PURE__ */ new Set();
9295
- this.byKind = /* @__PURE__ */ new Map();
9296
- this.projectAs = null;
9297
- }
9298
9341
  get attributes() {
9299
9342
  var _a2;
9300
9343
  return (_a2 = this.byKind.get(BindingKind.Attribute)) != null ? _a2 : FLYWEIGHT_ARRAY;
@@ -9319,12 +9362,28 @@ var ElementAttributes = class {
9319
9362
  var _a2;
9320
9363
  return (_a2 = this.byKind.get(BindingKind.I18n)) != null ? _a2 : FLYWEIGHT_ARRAY;
9321
9364
  }
9322
- add(kind, name, value, trustedValueFn) {
9365
+ constructor(compatibility) {
9366
+ this.compatibility = compatibility;
9367
+ this.known = /* @__PURE__ */ new Map();
9368
+ this.byKind = /* @__PURE__ */ new Map();
9369
+ this.projectAs = null;
9370
+ }
9371
+ isKnown(kind, name, value) {
9372
+ var _a2;
9373
+ const nameToValue = (_a2 = this.known.get(kind)) != null ? _a2 : /* @__PURE__ */ new Set();
9374
+ this.known.set(kind, nameToValue);
9375
+ if (nameToValue.has(name)) {
9376
+ return true;
9377
+ }
9378
+ nameToValue.add(name);
9379
+ return false;
9380
+ }
9381
+ add(kind, name, value, namespace, trustedValueFn) {
9323
9382
  var _a2;
9324
- if (this.known.has(name)) {
9383
+ const allowDuplicates = this.compatibility === CompatibilityMode.TemplateDefinitionBuilder && (kind === BindingKind.Attribute || kind === BindingKind.ClassName || kind === BindingKind.StyleProperty);
9384
+ if (!allowDuplicates && this.isKnown(kind, name, value)) {
9325
9385
  return;
9326
9386
  }
9327
- this.known.add(name);
9328
9387
  if (name === "ngProjectAs") {
9329
9388
  if (value === null || !(value instanceof LiteralExpr) || value.value == null || typeof ((_a2 = value.value) == null ? void 0 : _a2.toString()) !== "string") {
9330
9389
  throw Error("ngProjectAs must have a string literal value");
@@ -9332,7 +9391,7 @@ var ElementAttributes = class {
9332
9391
  this.projectAs = value.value.toString();
9333
9392
  }
9334
9393
  const array = this.arrayFor(kind);
9335
- array.push(...getAttributeNameLiterals(name));
9394
+ array.push(...getAttributeNameLiterals(namespace, name));
9336
9395
  if (kind === BindingKind.Attribute || kind === BindingKind.StyleProperty) {
9337
9396
  if (value === null) {
9338
9397
  throw Error("Attribute, i18n attribute, & style element attributes must have a value");
@@ -9354,15 +9413,10 @@ var ElementAttributes = class {
9354
9413
  return this.byKind.get(kind);
9355
9414
  }
9356
9415
  };
9357
- function getAttributeNameLiterals(name) {
9358
- const [attributeNamespace, attributeName] = splitNsName(name);
9359
- const nameLiteral = literal(attributeName);
9360
- if (attributeNamespace) {
9361
- return [
9362
- literal(0),
9363
- literal(attributeNamespace),
9364
- nameLiteral
9365
- ];
9416
+ function getAttributeNameLiterals(namespace, name) {
9417
+ const nameLiteral = literal(name);
9418
+ if (namespace) {
9419
+ return [literal(0), literal(namespace), nameLiteral];
9366
9420
  }
9367
9421
  return [nameLiteral];
9368
9422
  }
@@ -9422,7 +9476,7 @@ function convertI18nBindings(job) {
9422
9476
  if (op.expression.i18nPlaceholders.length !== op.expression.expressions.length) {
9423
9477
  throw new Error(`AssertionError: An i18n attribute binding instruction requires the same number of expressions and placeholders, but found ${op.expression.i18nPlaceholders.length} placeholders and ${op.expression.expressions.length} expressions`);
9424
9478
  }
9425
- ops.push(createI18nExpressionOp(op.i18nContext, i18nAttributesForElem.target, i18nAttributesForElem.xref, i18nAttributesForElem.handle, expr, op.expression.i18nPlaceholders[i], I18nParamResolutionTime.Creation, I18nExpressionFor.I18nAttribute, op.name, op.sourceSpan));
9479
+ ops.push(createI18nExpressionOp(op.i18nContext, i18nAttributesForElem.target, i18nAttributesForElem.xref, i18nAttributesForElem.handle, expr, null, op.expression.i18nPlaceholders[i], I18nParamResolutionTime.Creation, I18nExpressionFor.I18nAttribute, op.name, op.sourceSpan));
9426
9480
  }
9427
9481
  OpList.replaceWithMany(op, ops);
9428
9482
  break;
@@ -9453,7 +9507,11 @@ function createDeferDepsFns(job) {
9453
9507
  if (op.handle.slot === null) {
9454
9508
  throw new Error("AssertionError: slot must be assigned bfore extracting defer deps functions");
9455
9509
  }
9456
- op.resolverFn = job.pool.getSharedFunctionReference(depsFnExpr, `${job.componentName}_Defer_${op.handle.slot}_DepsFn`);
9510
+ op.resolverFn = job.pool.getSharedFunctionReference(
9511
+ depsFnExpr,
9512
+ `${job.componentName}_Defer_${op.handle.slot}_DepsFn`,
9513
+ false
9514
+ );
9457
9515
  }
9458
9516
  }
9459
9517
  }
@@ -9461,62 +9519,99 @@ function createDeferDepsFns(job) {
9461
9519
 
9462
9520
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/create_i18n_contexts.mjs
9463
9521
  function createI18nContexts(job) {
9464
- const rootContexts = /* @__PURE__ */ new Map();
9465
- let currentI18nOp = null;
9466
- let xref;
9467
- const messageToContext = /* @__PURE__ */ new Map();
9522
+ const attrContextByMessage = /* @__PURE__ */ new Map();
9523
+ for (const unit of job.units) {
9524
+ for (const op of unit.ops()) {
9525
+ switch (op.kind) {
9526
+ case OpKind.Binding:
9527
+ case OpKind.Property:
9528
+ case OpKind.Attribute:
9529
+ case OpKind.ExtractedAttribute:
9530
+ if (op.i18nMessage === null) {
9531
+ continue;
9532
+ }
9533
+ if (!attrContextByMessage.has(op.i18nMessage)) {
9534
+ const i18nContext = createI18nContextOp(I18nContextKind.Attr, job.allocateXrefId(), null, op.i18nMessage, null);
9535
+ unit.create.push(i18nContext);
9536
+ attrContextByMessage.set(op.i18nMessage, i18nContext.xref);
9537
+ }
9538
+ op.i18nContext = attrContextByMessage.get(op.i18nMessage);
9539
+ break;
9540
+ }
9541
+ }
9542
+ }
9543
+ const blockContextByI18nBlock = /* @__PURE__ */ new Map();
9468
9544
  for (const unit of job.units) {
9469
9545
  for (const op of unit.create) {
9470
9546
  switch (op.kind) {
9471
9547
  case OpKind.I18nStart:
9472
- currentI18nOp = op;
9473
9548
  if (op.xref === op.root) {
9474
- xref = job.allocateXrefId();
9475
- unit.create.push(createI18nContextOp(I18nContextKind.RootI18n, xref, op.xref, op.message, null));
9476
- op.context = xref;
9477
- rootContexts.set(op.xref, xref);
9549
+ const contextOp = createI18nContextOp(I18nContextKind.RootI18n, job.allocateXrefId(), op.xref, op.message, null);
9550
+ unit.create.push(contextOp);
9551
+ op.context = contextOp.xref;
9552
+ blockContextByI18nBlock.set(op.xref, contextOp);
9478
9553
  }
9479
9554
  break;
9555
+ }
9556
+ }
9557
+ }
9558
+ for (const unit of job.units) {
9559
+ for (const op of unit.create) {
9560
+ if (op.kind === OpKind.I18nStart && op.xref !== op.root) {
9561
+ const rootContext = blockContextByI18nBlock.get(op.root);
9562
+ if (rootContext === void 0) {
9563
+ throw Error("AssertionError: Root i18n block i18n context should have been created.");
9564
+ }
9565
+ op.context = rootContext.xref;
9566
+ blockContextByI18nBlock.set(op.xref, rootContext);
9567
+ }
9568
+ }
9569
+ }
9570
+ let currentI18nOp = null;
9571
+ for (const unit of job.units) {
9572
+ for (const op of unit.create) {
9573
+ switch (op.kind) {
9574
+ case OpKind.I18nStart:
9575
+ currentI18nOp = op;
9576
+ break;
9480
9577
  case OpKind.I18nEnd:
9481
9578
  currentI18nOp = null;
9482
9579
  break;
9483
9580
  case OpKind.IcuStart:
9484
9581
  if (currentI18nOp === null) {
9485
- throw Error("Unexpected ICU outside of an i18n block.");
9582
+ throw Error("AssertionError: Unexpected ICU outside of an i18n block.");
9486
9583
  }
9487
9584
  if (op.message.id !== currentI18nOp.message.id) {
9488
- xref = job.allocateXrefId();
9489
- unit.create.push(createI18nContextOp(I18nContextKind.Icu, xref, currentI18nOp.xref, op.message, null));
9490
- op.context = xref;
9585
+ const contextOp = createI18nContextOp(I18nContextKind.Icu, job.allocateXrefId(), currentI18nOp.xref, op.message, null);
9586
+ unit.create.push(contextOp);
9587
+ op.context = contextOp.xref;
9491
9588
  } else {
9492
9589
  op.context = currentI18nOp.context;
9590
+ blockContextByI18nBlock.get(currentI18nOp.xref).contextKind = I18nContextKind.Icu;
9493
9591
  }
9494
9592
  break;
9495
9593
  }
9496
9594
  }
9497
- for (const op of unit.ops()) {
9498
- switch (op.kind) {
9499
- case OpKind.Binding:
9500
- case OpKind.Property:
9501
- case OpKind.Attribute:
9502
- case OpKind.ExtractedAttribute:
9503
- if (!op.i18nMessage) {
9504
- continue;
9505
- }
9506
- if (!messageToContext.has(op.i18nMessage)) {
9507
- const i18nContext = job.allocateXrefId();
9508
- unit.create.push(createI18nContextOp(I18nContextKind.Attr, i18nContext, null, op.i18nMessage, null));
9509
- messageToContext.set(op.i18nMessage, i18nContext);
9510
- }
9511
- op.i18nContext = messageToContext.get(op.i18nMessage);
9512
- break;
9513
- }
9514
- }
9515
9595
  }
9596
+ }
9597
+
9598
+ // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/deduplicate_text_bindings.mjs
9599
+ function deduplicateTextBindings(job) {
9600
+ const seen = /* @__PURE__ */ new Map();
9516
9601
  for (const unit of job.units) {
9517
- for (const op of unit.create) {
9518
- if (op.kind === OpKind.I18nStart && op.xref !== op.root) {
9519
- op.context = rootContexts.get(op.root);
9602
+ for (const op of unit.update.reversed()) {
9603
+ if (op.kind === OpKind.Binding && op.isTextAttribute) {
9604
+ const seenForElement = seen.get(op.target) || /* @__PURE__ */ new Set();
9605
+ if (seenForElement.has(op.name)) {
9606
+ if (job.compatibility === CompatibilityMode.TemplateDefinitionBuilder) {
9607
+ if (op.name === "style" || op.name === "class") {
9608
+ OpList.remove(op);
9609
+ }
9610
+ } else {
9611
+ }
9612
+ }
9613
+ seenForElement.add(op.name);
9614
+ seen.set(op.target, seenForElement);
9520
9615
  }
9521
9616
  }
9522
9617
  }
@@ -9806,12 +9901,16 @@ var LIST_START_MARKER = "[";
9806
9901
  var LIST_END_MARKER = "]";
9807
9902
  var LIST_DELIMITER = "|";
9808
9903
  function extractI18nMessages(job) {
9809
- const i18nContexts = /* @__PURE__ */ new Map();
9904
+ const i18nMessagesByContext = /* @__PURE__ */ new Map();
9810
9905
  const i18nBlocks = /* @__PURE__ */ new Map();
9906
+ const i18nContexts = /* @__PURE__ */ new Map();
9811
9907
  for (const unit of job.units) {
9812
9908
  for (const op of unit.create) {
9813
9909
  switch (op.kind) {
9814
9910
  case OpKind.I18nContext:
9911
+ const i18nMessageOp = createI18nMessage(job, op);
9912
+ unit.create.push(i18nMessageOp);
9913
+ i18nMessagesByContext.set(op.xref, i18nMessageOp);
9815
9914
  i18nContexts.set(op.xref, op);
9816
9915
  break;
9817
9916
  case OpKind.I18nStart:
@@ -9820,49 +9919,40 @@ function extractI18nMessages(job) {
9820
9919
  }
9821
9920
  }
9822
9921
  }
9823
- for (const unit of job.units) {
9824
- for (const op of unit.create) {
9825
- if (op.kind !== OpKind.I18nContext || op.contextKind !== I18nContextKind.Attr) {
9826
- continue;
9827
- }
9828
- const i18nMessageOp = createI18nMessage(job, op);
9829
- unit.create.push(i18nMessageOp);
9830
- }
9831
- }
9832
- const i18nBlockMessages = /* @__PURE__ */ new Map();
9833
- for (const unit of job.units) {
9834
- for (const op of unit.create) {
9835
- if (op.kind === OpKind.I18nStart && op.xref === op.root) {
9836
- if (!op.context) {
9837
- throw Error("I18n start op should have its context set.");
9838
- }
9839
- const i18nMessageOp = createI18nMessage(job, i18nContexts.get(op.context));
9840
- i18nBlockMessages.set(op.xref, i18nMessageOp);
9841
- unit.create.push(i18nMessageOp);
9842
- }
9843
- }
9844
- }
9922
+ let currentIcu = null;
9845
9923
  for (const unit of job.units) {
9846
9924
  for (const op of unit.create) {
9847
9925
  switch (op.kind) {
9848
9926
  case OpKind.IcuStart:
9849
- if (!op.context) {
9850
- throw Error("ICU op should have its context set.");
9927
+ currentIcu = op;
9928
+ OpList.remove(op);
9929
+ const icuContext = i18nContexts.get(op.context);
9930
+ if (icuContext.contextKind !== I18nContextKind.Icu) {
9931
+ continue;
9851
9932
  }
9852
- const i18nContext = i18nContexts.get(op.context);
9853
- if (i18nContext.contextKind === I18nContextKind.Icu) {
9854
- if (i18nContext.i18nBlock === null) {
9855
- throw Error("ICU context should have its i18n block set.");
9856
- }
9857
- const subMessage = createI18nMessage(job, i18nContext, op.messagePlaceholder);
9858
- unit.create.push(subMessage);
9859
- const rootI18nId = i18nBlocks.get(i18nContext.i18nBlock).root;
9860
- const parentMessage = i18nBlockMessages.get(rootI18nId);
9861
- parentMessage == null ? void 0 : parentMessage.subMessages.push(subMessage.xref);
9933
+ const i18nBlock = i18nBlocks.get(icuContext.i18nBlock);
9934
+ if (i18nBlock.context === icuContext.xref) {
9935
+ continue;
9862
9936
  }
9863
- OpList.remove(op);
9937
+ const rootI18nBlock = i18nBlocks.get(i18nBlock.root);
9938
+ const rootMessage = i18nMessagesByContext.get(rootI18nBlock.context);
9939
+ if (rootMessage === void 0) {
9940
+ throw Error("AssertionError: ICU sub-message should belong to a root message.");
9941
+ }
9942
+ const subMessage = i18nMessagesByContext.get(icuContext.xref);
9943
+ subMessage.messagePlaceholder = op.messagePlaceholder;
9944
+ rootMessage.subMessages.push(subMessage.xref);
9864
9945
  break;
9865
9946
  case OpKind.IcuEnd:
9947
+ currentIcu = null;
9948
+ OpList.remove(op);
9949
+ break;
9950
+ case OpKind.IcuPlaceholder:
9951
+ if (currentIcu === null || currentIcu.context == null) {
9952
+ throw Error("AssertionError: Unexpected ICU placeholder outside of i18n context");
9953
+ }
9954
+ const msg = i18nMessagesByContext.get(currentIcu.context);
9955
+ msg.postprocessingParams.set(op.name, literal(formatIcuPlaceholder(op)));
9866
9956
  OpList.remove(op);
9867
9957
  break;
9868
9958
  }
@@ -9872,14 +9962,16 @@ function extractI18nMessages(job) {
9872
9962
  function createI18nMessage(job, context, messagePlaceholder) {
9873
9963
  let formattedParams = formatParams(context.params);
9874
9964
  const formattedPostprocessingParams = formatParams(context.postprocessingParams);
9875
- let needsPostprocessing = formattedPostprocessingParams.size > 0;
9876
- for (const values of context.params.values()) {
9877
- if (values.length > 1) {
9878
- needsPostprocessing = true;
9879
- }
9880
- }
9965
+ let needsPostprocessing = [...context.params.values()].some((v) => v.length > 1);
9881
9966
  return createI18nMessageOp(job.allocateXrefId(), context.xref, context.i18nBlock, context.message, messagePlaceholder != null ? messagePlaceholder : null, formattedParams, formattedPostprocessingParams, needsPostprocessing);
9882
9967
  }
9968
+ function formatIcuPlaceholder(op) {
9969
+ if (op.strings.length !== op.expressionPlaceholders.length + 1) {
9970
+ throw Error(`AsserionError: Invalid ICU placeholder with ${op.strings.length} strings and ${op.expressionPlaceholders.length} expressions`);
9971
+ }
9972
+ const values = op.expressionPlaceholders.map(formatValue);
9973
+ return op.strings.flatMap((str, i) => [str, values[i] || ""]).join("");
9974
+ }
9883
9975
  function formatParams(params) {
9884
9976
  const formattedParams = /* @__PURE__ */ new Map();
9885
9977
  for (const [placeholder, placeholderValues] of params) {
@@ -10106,7 +10198,7 @@ var CLASS_BANG = "class!";
10106
10198
  var BANG_IMPORTANT = "!important";
10107
10199
  function parseHostStyleProperties(job) {
10108
10200
  for (const op of job.root.update) {
10109
- if (op.kind !== OpKind.Binding) {
10201
+ if (!(op.kind === OpKind.Binding && op.bindingKind === BindingKind.Property)) {
10110
10202
  continue;
10111
10203
  }
10112
10204
  if (op.name.endsWith(BANG_IMPORTANT)) {
@@ -10115,7 +10207,7 @@ function parseHostStyleProperties(job) {
10115
10207
  if (op.name.startsWith(STYLE_DOT)) {
10116
10208
  op.bindingKind = BindingKind.StyleProperty;
10117
10209
  op.name = op.name.substring(STYLE_DOT.length);
10118
- if (isCssCustomProperty(op.name)) {
10210
+ if (!isCssCustomProperty(op.name)) {
10119
10211
  op.name = hyphenate(op.name);
10120
10212
  }
10121
10213
  const { property: property2, suffix } = parseProperty(op.name);
@@ -16248,7 +16340,7 @@ function collectMessage(job, fileBasedI18nSuffix, messages, messageOp) {
16248
16340
  const mainVar = variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX2));
16249
16341
  const closureVar = i18nGenerateClosureVar(job.pool, messageOp.message.id, fileBasedI18nSuffix, job.i18nUseExternalIds);
16250
16342
  let transformFn = void 0;
16251
- if (messageOp.needsPostprocessing) {
16343
+ if (messageOp.needsPostprocessing || messageOp.postprocessingParams.size > 0) {
16252
16344
  const postprocessingParams = Object.fromEntries([...messageOp.postprocessingParams.entries()].sort());
16253
16345
  const formattedPostprocessingParams = formatI18nPlaceholderNamesInMap(postprocessingParams, false);
16254
16346
  const extraTransformFnParams = [];
@@ -16267,7 +16359,6 @@ function addSubMessageParams(messageOp, subMessagePlaceholders) {
16267
16359
  } else {
16268
16360
  messageOp.params.set(placeholder, literal(`${ESCAPE2}${I18N_ICU_MAPPING_PREFIX2}${placeholder}${ESCAPE2}`));
16269
16361
  messageOp.postprocessingParams.set(placeholder, literalArr(subMessages));
16270
- messageOp.needsPostprocessing = true;
16271
16362
  }
16272
16363
  }
16273
16364
  }
@@ -16301,12 +16392,13 @@ function i18nGenerateClosureVar(pool, messageId, fileBasedI18nSuffix, useExterna
16301
16392
 
16302
16393
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/i18n_text_extraction.mjs
16303
16394
  function convertI18nText(job) {
16304
- var _a2;
16395
+ var _a2, _b2, _c2;
16305
16396
  for (const unit of job.units) {
16306
16397
  let currentI18n = null;
16307
16398
  let currentIcu = null;
16308
16399
  const textNodeI18nBlocks = /* @__PURE__ */ new Map();
16309
16400
  const textNodeIcus = /* @__PURE__ */ new Map();
16401
+ const icuPlaceholderByText = /* @__PURE__ */ new Map();
16310
16402
  for (const op of unit.create) {
16311
16403
  switch (op.kind) {
16312
16404
  case OpKind.I18nStart:
@@ -16331,7 +16423,13 @@ function convertI18nText(job) {
16331
16423
  if (currentI18n !== null) {
16332
16424
  textNodeI18nBlocks.set(op.xref, currentI18n);
16333
16425
  textNodeIcus.set(op.xref, currentIcu);
16334
- OpList.remove(op);
16426
+ if (op.icuPlaceholder !== null) {
16427
+ const icuPlaceholderOp = createIcuPlaceholderOp(job.allocateXrefId(), op.icuPlaceholder, [op.initialValue]);
16428
+ OpList.replace(op, icuPlaceholderOp);
16429
+ icuPlaceholderByText.set(op.xref, icuPlaceholderOp);
16430
+ } else {
16431
+ OpList.remove(op);
16432
+ }
16335
16433
  }
16336
16434
  break;
16337
16435
  }
@@ -16344,14 +16442,18 @@ function convertI18nText(job) {
16344
16442
  }
16345
16443
  const i18nOp = textNodeI18nBlocks.get(op.target);
16346
16444
  const icuOp = textNodeIcus.get(op.target);
16445
+ const icuPlaceholder = icuPlaceholderByText.get(op.target);
16347
16446
  const contextId = icuOp ? icuOp.context : i18nOp.context;
16348
16447
  const resolutionTime = icuOp ? I18nParamResolutionTime.Postproccessing : I18nParamResolutionTime.Creation;
16349
16448
  const ops = [];
16350
16449
  for (let i = 0; i < op.interpolation.expressions.length; i++) {
16351
16450
  const expr = op.interpolation.expressions[i];
16352
- ops.push(createI18nExpressionOp(contextId, i18nOp.xref, i18nOp.xref, i18nOp.handle, expr, op.interpolation.i18nPlaceholders[i], resolutionTime, I18nExpressionFor.I18nText, "", (_a2 = expr.sourceSpan) != null ? _a2 : op.sourceSpan));
16451
+ ops.push(createI18nExpressionOp(contextId, i18nOp.xref, i18nOp.xref, i18nOp.handle, expr, (_a2 = icuPlaceholder == null ? void 0 : icuPlaceholder.xref) != null ? _a2 : null, (_b2 = op.interpolation.i18nPlaceholders[i]) != null ? _b2 : null, resolutionTime, I18nExpressionFor.I18nText, "", (_c2 = expr.sourceSpan) != null ? _c2 : op.sourceSpan));
16353
16452
  }
16354
16453
  OpList.replaceWithMany(op, ops);
16454
+ if (icuPlaceholder !== void 0) {
16455
+ icuPlaceholder.strings = op.interpolation.strings;
16456
+ }
16355
16457
  break;
16356
16458
  }
16357
16459
  }
@@ -16502,7 +16604,7 @@ function addNamesToView(unit, baseName, state, compatibility) {
16502
16604
  op.handlerFnName = sanitizeIdentifier(op.handlerFnName);
16503
16605
  break;
16504
16606
  case OpKind.Variable:
16505
- varNames.set(op.xref, getVariableName(op.variable, state));
16607
+ varNames.set(op.xref, getVariableName(unit, op.variable, state));
16506
16608
  break;
16507
16609
  case OpKind.RepeaterCreate:
16508
16610
  if (!(unit instanceof ViewCompilationUnit)) {
@@ -16553,14 +16655,19 @@ function addNamesToView(unit, baseName, state, compatibility) {
16553
16655
  });
16554
16656
  }
16555
16657
  }
16556
- function getVariableName(variable2, state) {
16658
+ function getVariableName(unit, variable2, state) {
16557
16659
  if (variable2.name === null) {
16558
16660
  switch (variable2.kind) {
16559
16661
  case SemanticVariableKind.Context:
16560
16662
  variable2.name = `ctx_r${state.index++}`;
16561
16663
  break;
16562
16664
  case SemanticVariableKind.Identifier:
16563
- variable2.name = `${variable2.identifier}_r${++state.index}`;
16665
+ if (unit.job.compatibility === CompatibilityMode.TemplateDefinitionBuilder) {
16666
+ const compatPrefix = variable2.identifier === "ctx" ? "i" : "";
16667
+ variable2.name = `${variable2.identifier}_${compatPrefix}r${++state.index}`;
16668
+ } else {
16669
+ variable2.name = `${variable2.identifier}_i${state.index++}`;
16670
+ }
16564
16671
  break;
16565
16672
  default:
16566
16673
  variable2.name = `_r${++state.index}`;
@@ -16703,17 +16810,24 @@ var CREATE_ORDERING = [
16703
16810
  { test: (op) => op.kind === OpKind.Listener && !(op.hostListener && op.isAnimationListener) }
16704
16811
  ];
16705
16812
  var UPDATE_ORDERING = [
16706
- { test: kindWithInterpolationTest(OpKind.HostProperty, true) },
16707
- { test: kindWithInterpolationTest(OpKind.HostProperty, false) },
16708
16813
  { test: kindTest(OpKind.StyleMap), transform: keepLast },
16709
16814
  { test: kindTest(OpKind.ClassMap), transform: keepLast },
16710
16815
  { test: kindTest(OpKind.StyleProp) },
16711
16816
  { test: kindTest(OpKind.ClassProp) },
16712
- { test: kindWithInterpolationTest(OpKind.Property, true) },
16713
16817
  { test: kindWithInterpolationTest(OpKind.Attribute, true) },
16818
+ { test: kindWithInterpolationTest(OpKind.Property, true) },
16714
16819
  { test: kindWithInterpolationTest(OpKind.Property, false) },
16715
16820
  { test: kindWithInterpolationTest(OpKind.Attribute, false) }
16716
16821
  ];
16822
+ var UPDATE_HOST_ORDERING = [
16823
+ { test: kindWithInterpolationTest(OpKind.HostProperty, true) },
16824
+ { test: kindWithInterpolationTest(OpKind.HostProperty, false) },
16825
+ { test: kindTest(OpKind.Attribute) },
16826
+ { test: kindTest(OpKind.StyleMap), transform: keepLast },
16827
+ { test: kindTest(OpKind.ClassMap), transform: keepLast },
16828
+ { test: kindTest(OpKind.StyleProp) },
16829
+ { test: kindTest(OpKind.ClassProp) }
16830
+ ];
16717
16831
  var handledOpKinds = /* @__PURE__ */ new Set([
16718
16832
  OpKind.Listener,
16719
16833
  OpKind.StyleMap,
@@ -16727,7 +16841,8 @@ var handledOpKinds = /* @__PURE__ */ new Set([
16727
16841
  function orderOps(job) {
16728
16842
  for (const unit of job.units) {
16729
16843
  orderWithin(unit.create, CREATE_ORDERING);
16730
- orderWithin(unit.update, UPDATE_ORDERING);
16844
+ const ordering = unit.job.kind === CompilationJobKind.Host ? UPDATE_HOST_ORDERING : UPDATE_ORDERING;
16845
+ orderWithin(unit.update, ordering);
16731
16846
  }
16732
16847
  }
16733
16848
  function orderWithin(opList, ordering) {
@@ -16765,19 +16880,31 @@ function keepLast(ops) {
16765
16880
 
16766
16881
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/parse_extracted_styles.mjs
16767
16882
  function parseExtractedStyles(job) {
16883
+ const elements = /* @__PURE__ */ new Map();
16884
+ for (const unit of job.units) {
16885
+ for (const op of unit.create) {
16886
+ if (isElementOrContainerOp(op)) {
16887
+ elements.set(op.xref, op);
16888
+ }
16889
+ }
16890
+ }
16768
16891
  for (const unit of job.units) {
16769
16892
  for (const op of unit.create) {
16770
16893
  if (op.kind === OpKind.ExtractedAttribute && op.bindingKind === BindingKind.Attribute && isStringLiteral(op.expression)) {
16894
+ const target = elements.get(op.target);
16895
+ if (target !== void 0 && target.kind === OpKind.Template && target.templateKind === TemplateKind.Structural) {
16896
+ continue;
16897
+ }
16771
16898
  if (op.name === "style") {
16772
16899
  const parsedStyles = parse(op.expression.value);
16773
16900
  for (let i = 0; i < parsedStyles.length - 1; i += 2) {
16774
- OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.StyleProperty, parsedStyles[i], literal(parsedStyles[i + 1]), null, null, SecurityContext.STYLE), op);
16901
+ OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.StyleProperty, null, parsedStyles[i], literal(parsedStyles[i + 1]), null, null, SecurityContext.STYLE), op);
16775
16902
  }
16776
16903
  OpList.remove(op);
16777
16904
  } else if (op.name === "class") {
16778
16905
  const parsedClasses = op.expression.value.trim().split(/\s+/g);
16779
16906
  for (const parsedClass of parsedClasses) {
16780
- OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.ClassName, parsedClass, null, null, null, SecurityContext.NONE), op);
16907
+ OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.ClassName, null, parsedClass, null, null, null, SecurityContext.NONE), op);
16781
16908
  }
16782
16909
  OpList.remove(op);
16783
16910
  }
@@ -16798,13 +16925,6 @@ function removeContentSelectors(job) {
16798
16925
  OpList.remove(op);
16799
16926
  }
16800
16927
  break;
16801
- case OpKind.Projection:
16802
- for (let i = op.attributes.length - 2; i >= 0; i -= 2) {
16803
- if (isSelectAttribute(op.attributes[i])) {
16804
- op.attributes.splice(i, 2);
16805
- }
16806
- }
16807
- break;
16808
16928
  }
16809
16929
  }
16810
16930
  }
@@ -16931,8 +17051,11 @@ function wrapTemplateWithI18n(unit, parentI18n) {
16931
17051
  var _a2;
16932
17052
  if (((_a2 = unit.create.head.next) == null ? void 0 : _a2.kind) !== OpKind.I18nStart) {
16933
17053
  const id = unit.job.allocateXrefId();
16934
- OpList.insertAfter(createI18nStartOp(id, parentI18n.message, parentI18n.root), unit.create.head);
16935
- OpList.insertBefore(createI18nEndOp(id), unit.create.tail);
17054
+ OpList.insertAfter(
17055
+ createI18nStartOp(id, parentI18n.message, parentI18n.root, null),
17056
+ unit.create.head
17057
+ );
17058
+ OpList.insertBefore(createI18nEndOp(id, null), unit.create.tail);
16936
17059
  }
16937
17060
  }
16938
17061
 
@@ -17107,9 +17230,7 @@ function namespaceMath() {
17107
17230
  return call(Identifiers.namespaceMathML, [], null);
17108
17231
  }
17109
17232
  function advance(delta, sourceSpan) {
17110
- return call(Identifiers.advance, [
17111
- literal(delta)
17112
- ], sourceSpan);
17233
+ return call(Identifiers.advance, delta > 1 ? [literal(delta)] : [], sourceSpan);
17113
17234
  }
17114
17235
  function reference(slot) {
17115
17236
  return importExpr(Identifiers.reference).callFn([
@@ -17187,22 +17308,22 @@ function projectionDef(def) {
17187
17308
  }
17188
17309
  function projection(slot, projectionSlotIndex, attributes, sourceSpan) {
17189
17310
  const args = [literal(slot)];
17190
- if (projectionSlotIndex !== 0 || attributes.length > 0) {
17311
+ if (projectionSlotIndex !== 0 || attributes !== null) {
17191
17312
  args.push(literal(projectionSlotIndex));
17192
- if (attributes.length > 0) {
17193
- args.push(literalArr(attributes.map((attr) => literal(attr))));
17313
+ if (attributes !== null) {
17314
+ args.push(attributes);
17194
17315
  }
17195
17316
  }
17196
17317
  return call(Identifiers.projection, args, sourceSpan);
17197
17318
  }
17198
- function i18nStart(slot, constIndex, subTemplateIndex) {
17319
+ function i18nStart(slot, constIndex, subTemplateIndex, sourceSpan) {
17199
17320
  const args = [literal(slot), literal(constIndex)];
17200
17321
  if (subTemplateIndex !== null) {
17201
17322
  args.push(literal(subTemplateIndex));
17202
17323
  }
17203
- return call(Identifiers.i18nStart, args, null);
17324
+ return call(Identifiers.i18nStart, args, sourceSpan);
17204
17325
  }
17205
- function repeaterCreate(slot, viewFnName, decls, vars, tag, constIndex, trackByFn, trackByUsesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, sourceSpan) {
17326
+ function repeaterCreate(slot, viewFnName, decls, vars, tag, constIndex, trackByFn, trackByUsesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, emptyTag, emptyConstIndex, sourceSpan) {
17206
17327
  const args = [
17207
17328
  literal(slot),
17208
17329
  variable(viewFnName),
@@ -17216,6 +17337,12 @@ function repeaterCreate(slot, viewFnName, decls, vars, tag, constIndex, trackByF
17216
17337
  args.push(literal(trackByUsesComponentInstance));
17217
17338
  if (emptyViewFnName !== null) {
17218
17339
  args.push(variable(emptyViewFnName), literal(emptyDecls), literal(emptyVars));
17340
+ if (emptyTag !== null || emptyConstIndex !== null) {
17341
+ args.push(literal(emptyTag));
17342
+ }
17343
+ if (emptyConstIndex !== null) {
17344
+ args.push(literal(emptyConstIndex));
17345
+ }
17219
17346
  }
17220
17347
  }
17221
17348
  return call(Identifiers.repeaterCreate, args, sourceSpan);
@@ -17226,15 +17353,15 @@ function repeater(collection, sourceSpan) {
17226
17353
  function deferWhen(prefetch, expr, sourceSpan) {
17227
17354
  return call(prefetch ? Identifiers.deferPrefetchWhen : Identifiers.deferWhen, [expr], sourceSpan);
17228
17355
  }
17229
- function i18n(slot, constIndex, subTemplateIndex) {
17356
+ function i18n(slot, constIndex, subTemplateIndex, sourceSpan) {
17230
17357
  const args = [literal(slot), literal(constIndex)];
17231
17358
  if (subTemplateIndex) {
17232
17359
  args.push(literal(subTemplateIndex));
17233
17360
  }
17234
- return call(Identifiers.i18n, args, null);
17361
+ return call(Identifiers.i18n, args, sourceSpan);
17235
17362
  }
17236
- function i18nEnd() {
17237
- return call(Identifiers.i18nEnd, [], null);
17363
+ function i18nEnd(endSourceSpan) {
17364
+ return call(Identifiers.i18nEnd, [], endSourceSpan);
17238
17365
  }
17239
17366
  function i18nAttributes(slot, i18nAttributesConfig) {
17240
17367
  const args = [literal(slot), literal(i18nAttributesConfig)];
@@ -17247,10 +17374,13 @@ function property(name, expression, sanitizer, sourceSpan) {
17247
17374
  }
17248
17375
  return call(Identifiers.property, args, sourceSpan);
17249
17376
  }
17250
- function attribute(name, expression, sanitizer) {
17377
+ function attribute(name, expression, sanitizer, namespace) {
17251
17378
  const args = [literal(name), expression];
17252
- if (sanitizer !== null) {
17253
- args.push(sanitizer);
17379
+ if (sanitizer !== null || namespace !== null) {
17380
+ args.push(sanitizer != null ? sanitizer : literal(null));
17381
+ }
17382
+ if (namespace !== null) {
17383
+ args.push(literal(namespace));
17254
17384
  }
17255
17385
  return call(Identifiers.attribute, args, null);
17256
17386
  }
@@ -17561,31 +17691,31 @@ function reifyCreateOperations(unit, ops) {
17561
17691
  OpList.replace(op, text(op.handle.slot, op.initialValue, op.sourceSpan));
17562
17692
  break;
17563
17693
  case OpKind.ElementStart:
17564
- OpList.replace(op, elementStart(op.handle.slot, op.tag, op.attributes, op.localRefs, op.sourceSpan));
17694
+ OpList.replace(op, elementStart(op.handle.slot, op.tag, op.attributes, op.localRefs, op.startSourceSpan));
17565
17695
  break;
17566
17696
  case OpKind.Element:
17567
- OpList.replace(op, element(op.handle.slot, op.tag, op.attributes, op.localRefs, op.sourceSpan));
17697
+ OpList.replace(op, element(op.handle.slot, op.tag, op.attributes, op.localRefs, op.wholeSourceSpan));
17568
17698
  break;
17569
17699
  case OpKind.ElementEnd:
17570
17700
  OpList.replace(op, elementEnd(op.sourceSpan));
17571
17701
  break;
17572
17702
  case OpKind.ContainerStart:
17573
- OpList.replace(op, elementContainerStart(op.handle.slot, op.attributes, op.localRefs, op.sourceSpan));
17703
+ OpList.replace(op, elementContainerStart(op.handle.slot, op.attributes, op.localRefs, op.startSourceSpan));
17574
17704
  break;
17575
17705
  case OpKind.Container:
17576
- OpList.replace(op, elementContainer(op.handle.slot, op.attributes, op.localRefs, op.sourceSpan));
17706
+ OpList.replace(op, elementContainer(op.handle.slot, op.attributes, op.localRefs, op.wholeSourceSpan));
17577
17707
  break;
17578
17708
  case OpKind.ContainerEnd:
17579
17709
  OpList.replace(op, elementContainerEnd());
17580
17710
  break;
17581
17711
  case OpKind.I18nStart:
17582
- OpList.replace(op, i18nStart(op.handle.slot, op.messageIndex, op.subTemplateIndex));
17712
+ OpList.replace(op, i18nStart(op.handle.slot, op.messageIndex, op.subTemplateIndex, op.sourceSpan));
17583
17713
  break;
17584
17714
  case OpKind.I18nEnd:
17585
- OpList.replace(op, i18nEnd());
17715
+ OpList.replace(op, i18nEnd(op.sourceSpan));
17586
17716
  break;
17587
17717
  case OpKind.I18n:
17588
- OpList.replace(op, i18n(op.handle.slot, op.messageIndex, op.subTemplateIndex));
17718
+ OpList.replace(op, i18n(op.handle.slot, op.messageIndex, op.subTemplateIndex, op.sourceSpan));
17589
17719
  break;
17590
17720
  case OpKind.I18nAttributes:
17591
17721
  if (op.i18nAttributesConfig === null) {
@@ -17601,7 +17731,7 @@ function reifyCreateOperations(unit, ops) {
17601
17731
  throw new Error(`AssertionError: local refs array should have been extracted into a constant`);
17602
17732
  }
17603
17733
  const childView = unit.job.views.get(op.xref);
17604
- OpList.replace(op, template(op.handle.slot, variable(childView.fnName), childView.decls, childView.vars, op.tag, op.attributes, op.localRefs, op.sourceSpan));
17734
+ OpList.replace(op, template(op.handle.slot, variable(childView.fnName), childView.decls, childView.vars, op.tag, op.attributes, op.localRefs, op.startSourceSpan));
17605
17735
  break;
17606
17736
  case OpKind.DisableBindings:
17607
17737
  OpList.replace(op, disableBindings2());
@@ -17616,7 +17746,7 @@ function reifyCreateOperations(unit, ops) {
17616
17746
  const listenerFn = reifyListenerHandler(unit, op.handlerFnName, op.handlerOps, op.consumesDollarEvent);
17617
17747
  const eventTargetResolver = op.eventTarget ? GLOBAL_TARGET_RESOLVERS.get(op.eventTarget) : null;
17618
17748
  if (eventTargetResolver === void 0) {
17619
- throw new Error(`AssertionError: unknown event target ${op.eventTarget}`);
17749
+ throw new Error(`Unexpected global target '${op.eventTarget}' defined for '${op.name}' event. Supported list of global targets: window,document,body.`);
17620
17750
  }
17621
17751
  OpList.replace(op, listener(op.name, listenerFn, eventTargetResolver, op.hostListener && op.isAnimationListener, op.sourceSpan));
17622
17752
  break;
@@ -17703,7 +17833,7 @@ function reifyCreateOperations(unit, ops) {
17703
17833
  emptyDecls = emptyView.decls;
17704
17834
  emptyVars = emptyView.vars;
17705
17835
  }
17706
- OpList.replace(op, repeaterCreate(op.handle.slot, repeaterView.fnName, op.decls, op.vars, op.tag, op.attributes, op.trackByFn, op.usesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, op.sourceSpan));
17836
+ OpList.replace(op, repeaterCreate(op.handle.slot, repeaterView.fnName, op.decls, op.vars, op.tag, op.attributes, op.trackByFn, op.usesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, op.emptyTag, op.emptyAttributes, op.wholeSourceSpan));
17707
17837
  break;
17708
17838
  case OpKind.Statement:
17709
17839
  break;
@@ -17763,7 +17893,7 @@ function reifyUpdateOperations(_unit, ops) {
17763
17893
  if (op.expression instanceof Interpolation2) {
17764
17894
  OpList.replace(op, attributeInterpolate(op.name, op.expression.strings, op.expression.expressions, op.sanitizer, op.sourceSpan));
17765
17895
  } else {
17766
- OpList.replace(op, attribute(op.name, op.expression, op.sanitizer));
17896
+ OpList.replace(op, attribute(op.name, op.expression, op.sanitizer, op.namespace));
17767
17897
  }
17768
17898
  break;
17769
17899
  case OpKind.HostProperty:
@@ -17932,38 +18062,6 @@ function removeUnusedI18nAttributesOps(job) {
17932
18062
  }
17933
18063
  }
17934
18064
 
17935
- // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/repeater_derived_vars.mjs
17936
- function generateRepeaterDerivedVars(job) {
17937
- const repeaters = /* @__PURE__ */ new Map();
17938
- for (const unit of job.units) {
17939
- for (const op of unit.ops()) {
17940
- if (op.kind === OpKind.RepeaterCreate) {
17941
- repeaters.set(op.xref, op);
17942
- }
17943
- }
17944
- }
17945
- for (const unit of job.units) {
17946
- for (const op of unit.ops()) {
17947
- transformExpressionsInOp(op, (expr) => {
17948
- if (!(expr instanceof DerivedRepeaterVarExpr)) {
17949
- return expr;
17950
- }
17951
- const repeaterOp = repeaters.get(expr.xref);
17952
- switch (expr.identity) {
17953
- case DerivedRepeaterVarIdentity.First:
17954
- return new BinaryOperatorExpr(BinaryOperator.Identical, new LexicalReadExpr(repeaterOp.varNames.$index), literal(0));
17955
- case DerivedRepeaterVarIdentity.Last:
17956
- return new BinaryOperatorExpr(BinaryOperator.Identical, new LexicalReadExpr(repeaterOp.varNames.$index), new BinaryOperatorExpr(BinaryOperator.Minus, new LexicalReadExpr(repeaterOp.varNames.$count), literal(1)));
17957
- case DerivedRepeaterVarIdentity.Even:
17958
- return new BinaryOperatorExpr(BinaryOperator.Identical, new BinaryOperatorExpr(BinaryOperator.Modulo, new LexicalReadExpr(repeaterOp.varNames.$index), literal(2)), literal(0));
17959
- case DerivedRepeaterVarIdentity.Odd:
17960
- return new BinaryOperatorExpr(BinaryOperator.NotIdentical, new BinaryOperatorExpr(BinaryOperator.Modulo, new LexicalReadExpr(repeaterOp.varNames.$index), literal(2)), literal(0));
17961
- }
17962
- }, VisitorContextFlag.None);
17963
- }
17964
- }
17965
- }
17966
-
17967
18065
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_contexts.mjs
17968
18066
  function resolveContexts(job) {
17969
18067
  for (const unit of job.units) {
@@ -18210,6 +18308,7 @@ function resolveI18nExpressionPlaceholders(job) {
18210
18308
  var _a2;
18211
18309
  const subTemplateIndicies = /* @__PURE__ */ new Map();
18212
18310
  const i18nContexts = /* @__PURE__ */ new Map();
18311
+ const icuPlaceholders = /* @__PURE__ */ new Map();
18213
18312
  for (const unit of job.units) {
18214
18313
  for (const op of unit.create) {
18215
18314
  switch (op.kind) {
@@ -18219,6 +18318,9 @@ function resolveI18nExpressionPlaceholders(job) {
18219
18318
  case OpKind.I18nContext:
18220
18319
  i18nContexts.set(op.xref, op);
18221
18320
  break;
18321
+ case OpKind.IcuPlaceholder:
18322
+ icuPlaceholders.set(op.xref, op);
18323
+ break;
18222
18324
  }
18223
18325
  }
18224
18326
  }
@@ -18227,66 +18329,32 @@ function resolveI18nExpressionPlaceholders(job) {
18227
18329
  for (const unit of job.units) {
18228
18330
  for (const op of unit.update) {
18229
18331
  if (op.kind === OpKind.I18nExpression) {
18230
- const i18nContext = i18nContexts.get(op.context);
18231
18332
  const index = expressionIndices.get(referenceIndex(op)) || 0;
18232
18333
  const subTemplateIndex = (_a2 = subTemplateIndicies.get(op.i18nOwner)) != null ? _a2 : null;
18233
- const params = op.resolutionTime === I18nParamResolutionTime.Creation ? i18nContext.params : i18nContext.postprocessingParams;
18234
- const values = params.get(op.i18nPlaceholder) || [];
18235
- values.push({
18334
+ const value = {
18236
18335
  value: index,
18237
18336
  subTemplateIndex,
18238
18337
  flags: I18nParamValueFlags.ExpressionIndex
18239
- });
18240
- params.set(op.i18nPlaceholder, values);
18338
+ };
18339
+ updatePlaceholder(op, value, i18nContexts, icuPlaceholders);
18241
18340
  expressionIndices.set(referenceIndex(op), index + 1);
18242
18341
  }
18243
18342
  }
18244
18343
  }
18245
18344
  }
18246
-
18247
- // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_i18n_icu_placeholders.mjs
18248
- function resolveI18nIcuPlaceholders(job) {
18249
- for (const unit of job.units) {
18250
- for (const op of unit.create) {
18251
- if (op.kind === OpKind.I18nContext && op.contextKind === I18nContextKind.Icu) {
18252
- for (const node of op.message.nodes) {
18253
- node.visit(new ResolveIcuPlaceholdersVisitor(op.postprocessingParams));
18254
- }
18255
- }
18256
- }
18257
- }
18258
- }
18259
- var ResolveIcuPlaceholdersVisitor = class extends RecurseVisitor {
18260
- constructor(params) {
18261
- super();
18262
- this.params = params;
18263
- }
18264
- visitContainerPlaceholder(placeholder) {
18265
- var _a2, _b2;
18266
- if (placeholder.startName && placeholder.startSourceSpan && !this.params.has(placeholder.startName)) {
18267
- this.params.set(placeholder.startName, [{
18268
- value: (_a2 = placeholder.startSourceSpan) == null ? void 0 : _a2.toString(),
18269
- subTemplateIndex: null,
18270
- flags: I18nParamValueFlags.None
18271
- }]);
18272
- }
18273
- if (placeholder.closeName && placeholder.endSourceSpan && !this.params.has(placeholder.closeName)) {
18274
- this.params.set(placeholder.closeName, [{
18275
- value: (_b2 = placeholder.endSourceSpan) == null ? void 0 : _b2.toString(),
18276
- subTemplateIndex: null,
18277
- flags: I18nParamValueFlags.None
18278
- }]);
18279
- }
18345
+ function updatePlaceholder(op, value, i18nContexts, icuPlaceholders) {
18346
+ if (op.i18nPlaceholder !== null) {
18347
+ const i18nContext = i18nContexts.get(op.context);
18348
+ const params = op.resolutionTime === I18nParamResolutionTime.Creation ? i18nContext.params : i18nContext.postprocessingParams;
18349
+ const values = params.get(op.i18nPlaceholder) || [];
18350
+ values.push(value);
18351
+ params.set(op.i18nPlaceholder, values);
18280
18352
  }
18281
- visitTagPlaceholder(placeholder) {
18282
- super.visitTagPlaceholder(placeholder);
18283
- this.visitContainerPlaceholder(placeholder);
18353
+ if (op.icuPlaceholder !== null) {
18354
+ const icuPlaceholderOp = icuPlaceholders.get(op.icuPlaceholder);
18355
+ icuPlaceholderOp == null ? void 0 : icuPlaceholderOp.expressionPlaceholders.push(value);
18284
18356
  }
18285
- visitBlockPlaceholder(placeholder) {
18286
- super.visitBlockPlaceholder(placeholder);
18287
- this.visitContainerPlaceholder(placeholder);
18288
- }
18289
- };
18357
+ }
18290
18358
 
18291
18359
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_names.mjs
18292
18360
  function resolveNames(job) {
@@ -18592,6 +18660,9 @@ function generateTrackFns(job) {
18592
18660
  }
18593
18661
  let usesComponentContext = false;
18594
18662
  op.track = transformExpressionsInExpression(op.track, (expr) => {
18663
+ if (expr instanceof PipeBindingExpr || expr instanceof PipeBindingVariadicExpr) {
18664
+ throw new Error(`Illegal State: Pipes are not allowed in this context`);
18665
+ }
18595
18666
  if (expr instanceof TrackContextExpr) {
18596
18667
  usesComponentContext = true;
18597
18668
  return variable("this");
@@ -18756,7 +18827,10 @@ function varsUsedByOp(op) {
18756
18827
  return op.interpolation.expressions.length;
18757
18828
  case OpKind.I18nExpression:
18758
18829
  case OpKind.Conditional:
18830
+ case OpKind.DeferWhen:
18759
18831
  return 1;
18832
+ case OpKind.RepeaterCreate:
18833
+ return op.emptyView ? 1 : 0;
18760
18834
  default:
18761
18835
  throw new Error(`Unhandled op: ${OpKind[op.kind]}`);
18762
18836
  }
@@ -19049,12 +19123,12 @@ function wrapI18nIcus(job) {
19049
19123
  case OpKind.IcuStart:
19050
19124
  if (currentI18nOp === null) {
19051
19125
  addedI18nId = job.allocateXrefId();
19052
- OpList.insertBefore(createI18nStartOp(addedI18nId, op.message), op);
19126
+ OpList.insertBefore(createI18nStartOp(addedI18nId, op.message, void 0, null), op);
19053
19127
  }
19054
19128
  break;
19055
19129
  case OpKind.IcuEnd:
19056
19130
  if (addedI18nId !== null) {
19057
- OpList.insertAfter(createI18nEndOp(addedI18nId), op);
19131
+ OpList.insertAfter(createI18nEndOp(addedI18nId, null), op);
19058
19132
  addedI18nId = null;
19059
19133
  }
19060
19134
  break;
@@ -19070,6 +19144,7 @@ var phases = [
19070
19144
  { kind: CompilationJobKind.Tmpl, fn: emitNamespaceChanges },
19071
19145
  { kind: CompilationJobKind.Tmpl, fn: propagateI18nBlocks },
19072
19146
  { kind: CompilationJobKind.Tmpl, fn: wrapI18nIcus },
19147
+ { kind: CompilationJobKind.Both, fn: deduplicateTextBindings },
19073
19148
  { kind: CompilationJobKind.Both, fn: specializeStyleBindings },
19074
19149
  { kind: CompilationJobKind.Both, fn: specializeBindings },
19075
19150
  { kind: CompilationJobKind.Both, fn: extractAttributes },
@@ -19093,7 +19168,6 @@ var phases = [
19093
19168
  { kind: CompilationJobKind.Tmpl, fn: saveAndRestoreView },
19094
19169
  { kind: CompilationJobKind.Both, fn: deleteAnyCasts },
19095
19170
  { kind: CompilationJobKind.Both, fn: resolveDollarEvent },
19096
- { kind: CompilationJobKind.Tmpl, fn: generateRepeaterDerivedVars },
19097
19171
  { kind: CompilationJobKind.Tmpl, fn: generateTrackVariables },
19098
19172
  { kind: CompilationJobKind.Both, fn: resolveNames },
19099
19173
  { kind: CompilationJobKind.Tmpl, fn: resolveDeferTargetNames },
@@ -19108,7 +19182,6 @@ var phases = [
19108
19182
  { kind: CompilationJobKind.Tmpl, fn: createDeferDepsFns },
19109
19183
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nElementPlaceholders },
19110
19184
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nExpressionPlaceholders },
19111
- { kind: CompilationJobKind.Tmpl, fn: resolveI18nIcuPlaceholders },
19112
19185
  { kind: CompilationJobKind.Tmpl, fn: extractI18nMessages },
19113
19186
  { kind: CompilationJobKind.Tmpl, fn: generateTrackFns },
19114
19187
  { kind: CompilationJobKind.Tmpl, fn: collectI18nConsts },
@@ -19251,7 +19324,7 @@ function ingestHostBinding(input, bindingParser, constantPool) {
19251
19324
  bindingKind = BindingKind.Animation;
19252
19325
  }
19253
19326
  const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, property2.name, bindingKind === BindingKind.Attribute).filter((context) => context !== SecurityContext.NONE);
19254
- ingestHostProperty(job, property2, bindingKind, false, securityContexts);
19327
+ ingestHostProperty(job, property2, bindingKind, securityContexts);
19255
19328
  }
19256
19329
  for (const [name, expr] of (_b2 = Object.entries(input.attributes)) != null ? _b2 : []) {
19257
19330
  const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, name, true).filter((context) => context !== SecurityContext.NONE);
@@ -19262,7 +19335,7 @@ function ingestHostBinding(input, bindingParser, constantPool) {
19262
19335
  }
19263
19336
  return job;
19264
19337
  }
19265
- function ingestHostProperty(job, property2, bindingKind, isTextAttribute, securityContexts) {
19338
+ function ingestHostProperty(job, property2, bindingKind, securityContexts) {
19266
19339
  let expression;
19267
19340
  const ast = property2.expression.ast;
19268
19341
  if (ast instanceof Interpolation) {
@@ -19270,7 +19343,7 @@ function ingestHostProperty(job, property2, bindingKind, isTextAttribute, securi
19270
19343
  } else {
19271
19344
  expression = convertAst(ast, job, property2.sourceSpan);
19272
19345
  }
19273
- job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, securityContexts, isTextAttribute, false, null, null, property2.sourceSpan));
19346
+ job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, securityContexts, false, false, null, null, property2.sourceSpan));
19274
19347
  }
19275
19348
  function ingestHostAttribute(job, name, value, securityContexts) {
19276
19349
  const attrBinding = createBindingOp(
@@ -19284,14 +19357,13 @@ function ingestHostAttribute(job, name, value, securityContexts) {
19284
19357
  false,
19285
19358
  null,
19286
19359
  null,
19287
- null
19360
+ value.sourceSpan
19288
19361
  );
19289
19362
  job.root.update.push(attrBinding);
19290
19363
  }
19291
19364
  function ingestHostEvent(job, event) {
19292
19365
  const [phase, target] = event.type === 0 ? [null, event.targetOrPhase] : [event.targetOrPhase, null];
19293
- const eventBinding = createListenerOp(job.root.xref, new SlotHandle(), event.name, null, [], phase, target, true, event.sourceSpan);
19294
- eventBinding.handlerOps.push(createStatementOp(new ReturnStatement(convertAst(event.handler.ast, job, event.sourceSpan), event.handlerSpan)));
19366
+ const eventBinding = createListenerOp(job.root.xref, new SlotHandle(), event.name, null, makeListenerHandlerOps(job.root, event.handler, event.handlerSpan), phase, target, true, event.sourceSpan);
19295
19367
  job.root.create.push(eventBinding);
19296
19368
  }
19297
19369
  function ingestNodes(unit, template2) {
@@ -19303,9 +19375,9 @@ function ingestNodes(unit, template2) {
19303
19375
  } else if (node instanceof Content) {
19304
19376
  ingestContent(unit, node);
19305
19377
  } else if (node instanceof Text) {
19306
- ingestText(unit, node);
19378
+ ingestText(unit, node, null);
19307
19379
  } else if (node instanceof BoundText) {
19308
- ingestBoundText(unit, node);
19380
+ ingestBoundText(unit, node, null);
19309
19381
  } else if (node instanceof IfBlock) {
19310
19382
  ingestIfBlock(unit, node);
19311
19383
  } else if (node instanceof SwitchBlock) {
@@ -19322,29 +19394,30 @@ function ingestNodes(unit, template2) {
19322
19394
  }
19323
19395
  }
19324
19396
  function ingestElement(unit, element2) {
19325
- var _a2;
19397
+ var _a2, _b2;
19326
19398
  if (element2.i18n !== void 0 && !(element2.i18n instanceof Message || element2.i18n instanceof TagPlaceholder)) {
19327
19399
  throw Error(`Unhandled i18n metadata type for element: ${element2.i18n.constructor.name}`);
19328
19400
  }
19329
19401
  const id = unit.job.allocateXrefId();
19330
19402
  const [namespaceKey, elementName] = splitNsName(element2.name);
19331
- const startOp = createElementStartOp(elementName, id, namespaceForKey(namespaceKey), element2.i18n instanceof TagPlaceholder ? element2.i18n : void 0, element2.startSourceSpan);
19403
+ const startOp = createElementStartOp(elementName, id, namespaceForKey(namespaceKey), element2.i18n instanceof TagPlaceholder ? element2.i18n : void 0, element2.startSourceSpan, element2.sourceSpan);
19332
19404
  unit.create.push(startOp);
19333
19405
  ingestElementBindings(unit, startOp, element2);
19334
19406
  ingestReferences(startOp, element2);
19335
19407
  let i18nBlockId = null;
19336
19408
  if (element2.i18n instanceof Message) {
19337
19409
  i18nBlockId = unit.job.allocateXrefId();
19338
- unit.create.push(createI18nStartOp(i18nBlockId, element2.i18n));
19410
+ unit.create.push(createI18nStartOp(i18nBlockId, element2.i18n, void 0, element2.startSourceSpan));
19339
19411
  }
19340
19412
  ingestNodes(unit, element2.children);
19341
19413
  const endOp = createElementEndOp(id, (_a2 = element2.endSourceSpan) != null ? _a2 : element2.startSourceSpan);
19342
19414
  unit.create.push(endOp);
19343
19415
  if (i18nBlockId !== null) {
19344
- OpList.insertBefore(createI18nEndOp(i18nBlockId), endOp);
19416
+ OpList.insertBefore(createI18nEndOp(i18nBlockId, (_b2 = element2.endSourceSpan) != null ? _b2 : element2.startSourceSpan), endOp);
19345
19417
  }
19346
19418
  }
19347
19419
  function ingestTemplate(unit, tmpl) {
19420
+ var _a2;
19348
19421
  if (tmpl.i18n !== void 0 && !(tmpl.i18n instanceof Message || tmpl.i18n instanceof TagPlaceholder)) {
19349
19422
  throw Error(`Unhandled i18n metadata type for template: ${tmpl.i18n.constructor.name}`);
19350
19423
  }
@@ -19358,7 +19431,7 @@ function ingestTemplate(unit, tmpl) {
19358
19431
  const namespace = namespaceForKey(namespacePrefix);
19359
19432
  const functionNameSuffix = tagNameWithoutNamespace === null ? "" : prefixWithNamespace(tagNameWithoutNamespace, namespace);
19360
19433
  const templateKind = isPlainTemplate(tmpl) ? TemplateKind.NgTemplate : TemplateKind.Structural;
19361
- const templateOp = createTemplateOp(childView.xref, templateKind, tagNameWithoutNamespace, functionNameSuffix, namespace, i18nPlaceholder, tmpl.startSourceSpan);
19434
+ const templateOp = createTemplateOp(childView.xref, templateKind, tagNameWithoutNamespace, functionNameSuffix, namespace, i18nPlaceholder, tmpl.startSourceSpan, tmpl.sourceSpan);
19362
19435
  unit.create.push(templateOp);
19363
19436
  ingestTemplateBindings(unit, templateOp, tmpl, templateKind);
19364
19437
  ingestReferences(templateOp, tmpl);
@@ -19368,26 +19441,25 @@ function ingestTemplate(unit, tmpl) {
19368
19441
  }
19369
19442
  if (templateKind === TemplateKind.NgTemplate && tmpl.i18n instanceof Message) {
19370
19443
  const id = unit.job.allocateXrefId();
19371
- OpList.insertAfter(createI18nStartOp(id, tmpl.i18n), childView.create.head);
19372
- OpList.insertBefore(createI18nEndOp(id), childView.create.tail);
19444
+ OpList.insertAfter(createI18nStartOp(id, tmpl.i18n, void 0, tmpl.startSourceSpan), childView.create.head);
19445
+ OpList.insertBefore(createI18nEndOp(id, (_a2 = tmpl.endSourceSpan) != null ? _a2 : tmpl.startSourceSpan), childView.create.tail);
19373
19446
  }
19374
19447
  }
19375
19448
  function ingestContent(unit, content) {
19376
19449
  if (content.i18n !== void 0 && !(content.i18n instanceof TagPlaceholder)) {
19377
19450
  throw Error(`Unhandled i18n metadata type for element: ${content.i18n.constructor.name}`);
19378
19451
  }
19379
- const attrs = content.attributes.flatMap((a) => [a.name, a.value]);
19380
- const op = createProjectionOp(unit.job.allocateXrefId(), content.selector, content.i18n, attrs, content.sourceSpan);
19452
+ const op = createProjectionOp(unit.job.allocateXrefId(), content.selector, content.i18n, content.sourceSpan);
19381
19453
  for (const attr of content.attributes) {
19382
19454
  const securityContext = domSchema.securityContext(content.name, attr.name, true);
19383
19455
  unit.update.push(createBindingOp(op.xref, BindingKind.Attribute, attr.name, literal(attr.value), null, securityContext, true, false, null, asMessage(attr.i18n), attr.sourceSpan));
19384
19456
  }
19385
19457
  unit.create.push(op);
19386
19458
  }
19387
- function ingestText(unit, text2) {
19388
- unit.create.push(createTextOp(unit.job.allocateXrefId(), text2.value, text2.sourceSpan));
19459
+ function ingestText(unit, text2, icuPlaceholder) {
19460
+ unit.create.push(createTextOp(unit.job.allocateXrefId(), text2.value, icuPlaceholder, text2.sourceSpan));
19389
19461
  }
19390
- function ingestBoundText(unit, text2, i18nPlaceholders) {
19462
+ function ingestBoundText(unit, text2, icuPlaceholder) {
19391
19463
  var _a2;
19392
19464
  let value = text2.value;
19393
19465
  if (value instanceof ASTWithSource) {
@@ -19399,14 +19471,12 @@ function ingestBoundText(unit, text2, i18nPlaceholders) {
19399
19471
  if (text2.i18n !== void 0 && !(text2.i18n instanceof Container)) {
19400
19472
  throw Error(`Unhandled i18n metadata type for text interpolation: ${(_a2 = text2.i18n) == null ? void 0 : _a2.constructor.name}`);
19401
19473
  }
19402
- if (i18nPlaceholders === void 0) {
19403
- i18nPlaceholders = text2.i18n instanceof Container ? text2.i18n.children.filter((node) => node instanceof Placeholder).map((placeholder) => placeholder.name) : [];
19404
- }
19474
+ const i18nPlaceholders = text2.i18n instanceof Container ? text2.i18n.children.filter((node) => node instanceof Placeholder).map((placeholder) => placeholder.name) : [];
19405
19475
  if (i18nPlaceholders.length > 0 && i18nPlaceholders.length !== value.expressions.length) {
19406
19476
  throw Error(`Unexpected number of i18n placeholders (${value.expressions.length}) for BoundText with ${value.expressions.length} expressions`);
19407
19477
  }
19408
19478
  const textXref = unit.job.allocateXrefId();
19409
- unit.create.push(createTextOp(textXref, "", text2.sourceSpan));
19479
+ unit.create.push(createTextOp(textXref, "", icuPlaceholder, text2.sourceSpan));
19410
19480
  const baseSourceSpan = unit.job.compatibility ? null : text2.sourceSpan;
19411
19481
  unit.update.push(createInterpolateTextOp(textXref, new Interpolation2(value.strings, value.expressions.map((expr) => convertAst(expr, unit.job, baseSourceSpan)), i18nPlaceholders), text2.sourceSpan));
19412
19482
  }
@@ -19432,7 +19502,7 @@ function ingestIfBlock(unit, ifBlock) {
19432
19502
  }
19433
19503
  ifCaseI18nMeta = ifCase.i18n;
19434
19504
  }
19435
- const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, tagName, "Conditional", Namespace.HTML, ifCaseI18nMeta, ifCase.sourceSpan);
19505
+ const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, tagName, "Conditional", Namespace.HTML, ifCaseI18nMeta, ifCase.startSourceSpan, ifCase.sourceSpan);
19436
19506
  unit.create.push(templateOp);
19437
19507
  if (firstXref === null) {
19438
19508
  firstXref = cView.xref;
@@ -19448,6 +19518,9 @@ function ingestIfBlock(unit, ifBlock) {
19448
19518
  }
19449
19519
  function ingestSwitchBlock(unit, switchBlock) {
19450
19520
  var _a2;
19521
+ if (switchBlock.cases.length === 0) {
19522
+ return;
19523
+ }
19451
19524
  let firstXref = null;
19452
19525
  let firstSlotHandle = null;
19453
19526
  let conditions = [];
@@ -19460,7 +19533,7 @@ function ingestSwitchBlock(unit, switchBlock) {
19460
19533
  }
19461
19534
  switchCaseI18nMeta = switchCase.i18n;
19462
19535
  }
19463
- const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, null, "Case", Namespace.HTML, switchCaseI18nMeta, switchCase.sourceSpan);
19536
+ const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, null, "Case", Namespace.HTML, switchCaseI18nMeta, switchCase.startSourceSpan, switchCase.sourceSpan);
19464
19537
  unit.create.push(templateOp);
19465
19538
  if (firstXref === null) {
19466
19539
  firstXref = cView.xref;
@@ -19483,7 +19556,7 @@ function ingestDeferView(unit, suffix, i18nMeta, children, sourceSpan) {
19483
19556
  }
19484
19557
  const secondaryView = unit.job.allocateView(unit.xref);
19485
19558
  ingestNodes(secondaryView, children);
19486
- const templateOp = createTemplateOp(secondaryView.xref, TemplateKind.Block, null, `Defer${suffix}`, Namespace.HTML, i18nMeta, sourceSpan);
19559
+ const templateOp = createTemplateOp(secondaryView.xref, TemplateKind.Block, null, `Defer${suffix}`, Namespace.HTML, i18nMeta, sourceSpan, sourceSpan);
19487
19560
  unit.create.push(templateOp);
19488
19561
  return templateOp;
19489
19562
  }
@@ -19557,6 +19630,9 @@ function ingestDeferBlock(unit, deferBlock) {
19557
19630
  deferOnOps.push(deferOnOp);
19558
19631
  }
19559
19632
  if (triggers.when !== void 0) {
19633
+ if (triggers.when.value instanceof Interpolation) {
19634
+ throw new Error(`Unexpected interpolation in defer block when trigger`);
19635
+ }
19560
19636
  const deferOnOp = createDeferWhenOp(deferXref, convertAst(triggers.when.value, unit.job, triggers.when.sourceSpan), prefetch, triggers.when.sourceSpan);
19561
19637
  deferWhenOps.push(deferOnOp);
19562
19638
  }
@@ -19576,9 +19652,9 @@ function ingestIcu(unit, icu) {
19576
19652
  unit.create.push(createIcuStartOp(xref, icu.i18n, icuFromI18nMessage(icu.i18n).name, null));
19577
19653
  for (const [placeholder, text2] of Object.entries(__spreadValues(__spreadValues({}, icu.vars), icu.placeholders))) {
19578
19654
  if (text2 instanceof BoundText) {
19579
- ingestBoundText(unit, text2, [placeholder]);
19655
+ ingestBoundText(unit, text2, placeholder);
19580
19656
  } else {
19581
- ingestText(unit, text2);
19657
+ ingestText(unit, text2, placeholder);
19582
19658
  }
19583
19659
  }
19584
19660
  unit.create.push(createIcuEndOp(xref));
@@ -19589,28 +19665,46 @@ function ingestIcu(unit, icu) {
19589
19665
  function ingestForBlock(unit, forBlock) {
19590
19666
  var _a2, _b2, _c2;
19591
19667
  const repeaterView = unit.job.allocateView(unit.xref);
19592
- const createRepeaterAlias = (ident, repeaterVar) => {
19593
- repeaterView.aliases.add({
19594
- kind: SemanticVariableKind.Alias,
19595
- name: null,
19596
- identifier: ident,
19597
- expression: new DerivedRepeaterVarExpr(repeaterView.xref, repeaterVar)
19598
- });
19599
- };
19600
19668
  repeaterView.contextVariables.set(forBlock.item.name, forBlock.item.value);
19601
19669
  repeaterView.contextVariables.set(forBlock.contextVariables.$index.name, forBlock.contextVariables.$index.value);
19602
19670
  repeaterView.contextVariables.set(forBlock.contextVariables.$count.name, forBlock.contextVariables.$count.value);
19603
- createRepeaterAlias(forBlock.contextVariables.$first.name, DerivedRepeaterVarIdentity.First);
19604
- createRepeaterAlias(forBlock.contextVariables.$last.name, DerivedRepeaterVarIdentity.Last);
19605
- createRepeaterAlias(forBlock.contextVariables.$even.name, DerivedRepeaterVarIdentity.Even);
19606
- createRepeaterAlias(forBlock.contextVariables.$odd.name, DerivedRepeaterVarIdentity.Odd);
19671
+ const indexName = `\u0275${forBlock.contextVariables.$index.name}_${repeaterView.xref}`;
19672
+ const countName = `\u0275${forBlock.contextVariables.$count.name}_${repeaterView.xref}`;
19673
+ repeaterView.contextVariables.set(indexName, forBlock.contextVariables.$index.value);
19674
+ repeaterView.contextVariables.set(countName, forBlock.contextVariables.$count.value);
19675
+ repeaterView.aliases.add({
19676
+ kind: SemanticVariableKind.Alias,
19677
+ name: null,
19678
+ identifier: forBlock.contextVariables.$first.name,
19679
+ expression: new LexicalReadExpr(indexName).identical(literal(0))
19680
+ });
19681
+ repeaterView.aliases.add({
19682
+ kind: SemanticVariableKind.Alias,
19683
+ name: null,
19684
+ identifier: forBlock.contextVariables.$last.name,
19685
+ expression: new LexicalReadExpr(indexName).identical(new LexicalReadExpr(countName).minus(literal(1)))
19686
+ });
19687
+ repeaterView.aliases.add({
19688
+ kind: SemanticVariableKind.Alias,
19689
+ name: null,
19690
+ identifier: forBlock.contextVariables.$even.name,
19691
+ expression: new LexicalReadExpr(indexName).modulo(literal(2)).identical(literal(0))
19692
+ });
19693
+ repeaterView.aliases.add({
19694
+ kind: SemanticVariableKind.Alias,
19695
+ name: null,
19696
+ identifier: forBlock.contextVariables.$odd.name,
19697
+ expression: new LexicalReadExpr(indexName).modulo(literal(2)).notIdentical(literal(0))
19698
+ });
19607
19699
  const sourceSpan = convertSourceSpan(forBlock.trackBy.span, forBlock.sourceSpan);
19608
19700
  const track = convertAst(forBlock.trackBy, unit.job, sourceSpan);
19609
19701
  ingestNodes(repeaterView, forBlock.children);
19610
19702
  let emptyView = null;
19703
+ let emptyTagName = null;
19611
19704
  if (forBlock.empty !== null) {
19612
19705
  emptyView = unit.job.allocateView(unit.xref);
19613
19706
  ingestNodes(emptyView, forBlock.empty.children);
19707
+ emptyTagName = ingestControlFlowInsertionPoint(unit, emptyView.xref, forBlock.empty);
19614
19708
  }
19615
19709
  const varNames = {
19616
19710
  $index: forBlock.contextVariables.$index.name,
@@ -19630,7 +19724,7 @@ function ingestForBlock(unit, forBlock) {
19630
19724
  const i18nPlaceholder = forBlock.i18n;
19631
19725
  const emptyI18nPlaceholder = (_b2 = forBlock.empty) == null ? void 0 : _b2.i18n;
19632
19726
  const tagName = ingestControlFlowInsertionPoint(unit, repeaterView.xref, forBlock);
19633
- const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (_c2 = emptyView == null ? void 0 : emptyView.xref) != null ? _c2 : null, tagName, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, forBlock.sourceSpan);
19727
+ const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (_c2 = emptyView == null ? void 0 : emptyView.xref) != null ? _c2 : null, tagName, track, varNames, emptyTagName, i18nPlaceholder, emptyI18nPlaceholder, forBlock.startSourceSpan, forBlock.sourceSpan);
19634
19728
  unit.create.push(repeaterCreate2);
19635
19729
  const expression = convertAst(forBlock.expression, unit.job, convertSourceSpan(forBlock.expression.span, forBlock.sourceSpan));
19636
19730
  const repeater2 = createRepeaterOp(repeaterCreate2.xref, repeaterCreate2.handle, expression, forBlock.sourceSpan);
@@ -19640,7 +19734,10 @@ function convertAst(ast, job, baseSourceSpan) {
19640
19734
  if (ast instanceof ASTWithSource) {
19641
19735
  return convertAst(ast.ast, job, baseSourceSpan);
19642
19736
  } else if (ast instanceof PropertyRead) {
19643
- if (ast.receiver instanceof ImplicitReceiver && !(ast.receiver instanceof ThisReceiver)) {
19737
+ const isThisReceiver = ast.receiver instanceof ThisReceiver;
19738
+ const isImplicitReceiver = ast.receiver instanceof ImplicitReceiver && !(ast.receiver instanceof ThisReceiver);
19739
+ const isSpecialNode = ast.name === "$any" || ast.name === "$event";
19740
+ if (isImplicitReceiver || isThisReceiver && !isSpecialNode) {
19644
19741
  return new LexicalReadExpr(ast.name);
19645
19742
  } else {
19646
19743
  return new ReadPropExpr(convertAst(ast.receiver, job, baseSourceSpan), ast.name, null, convertSourceSpan(ast.span, baseSourceSpan));
@@ -19718,13 +19815,13 @@ function convertAst(ast, job, baseSourceSpan) {
19718
19815
  throw new Error(`Unhandled expression type "${ast.constructor.name}" in file "${baseSourceSpan == null ? void 0 : baseSourceSpan.start.file.url}"`);
19719
19816
  }
19720
19817
  }
19721
- function convertAstWithInterpolation(job, value, i18nMeta) {
19818
+ function convertAstWithInterpolation(job, value, i18nMeta, sourceSpan) {
19722
19819
  var _a2, _b2;
19723
19820
  let expression;
19724
19821
  if (value instanceof Interpolation) {
19725
- expression = new Interpolation2(value.strings, value.expressions.map((e) => convertAst(e, job, null)), Object.keys((_b2 = (_a2 = asMessage(i18nMeta)) == null ? void 0 : _a2.placeholders) != null ? _b2 : {}));
19822
+ expression = new Interpolation2(value.strings, value.expressions.map((e) => convertAst(e, job, sourceSpan != null ? sourceSpan : null)), Object.keys((_b2 = (_a2 = asMessage(i18nMeta)) == null ? void 0 : _a2.placeholders) != null ? _b2 : {}));
19726
19823
  } else if (value instanceof AST) {
19727
- expression = convertAst(value, job, null);
19824
+ expression = convertAst(value, job, sourceSpan != null ? sourceSpan : null);
19728
19825
  } else {
19729
19826
  expression = literal(value);
19730
19827
  }
@@ -19800,7 +19897,7 @@ function ingestTemplateBindings(unit, op, template2, templateKind) {
19800
19897
  }
19801
19898
  if (templateKind === TemplateKind.Structural && output.type !== 1) {
19802
19899
  const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, output.name, false);
19803
- unit.create.push(createExtractedAttributeOp(op.xref, BindingKind.Property, output.name, null, null, null, securityContext));
19900
+ unit.create.push(createExtractedAttributeOp(op.xref, BindingKind.Property, null, output.name, null, null, null, securityContext));
19804
19901
  }
19805
19902
  }
19806
19903
  if (bindings.some((b) => b == null ? void 0 : b.i18nMessage) !== null) {
@@ -19811,7 +19908,7 @@ function createTemplateBinding(view, xref, type, name, value, unit, securityCont
19811
19908
  const isTextBinding = typeof value === "string";
19812
19909
  if (templateKind === TemplateKind.Structural) {
19813
19910
  if (!isStructuralTemplateAttribute && (type === 0 || type === 2 || type === 3)) {
19814
- return createExtractedAttributeOp(xref, BindingKind.Property, name, null, null, i18nMessage, securityContext);
19911
+ return createExtractedAttributeOp(xref, BindingKind.Property, null, name, null, null, i18nMessage, securityContext);
19815
19912
  }
19816
19913
  if (!isTextBinding && (type === 1 || type === 4)) {
19817
19914
  return null;
@@ -22670,6 +22767,9 @@ var TemplateDefinitionBuilder = class {
22670
22767
  this.updateInstructionWithAdvance(containerIndex, block.branches[0].sourceSpan, Identifiers.conditional, paramsCallback);
22671
22768
  }
22672
22769
  visitSwitchBlock(block) {
22770
+ if (block.cases.length === 0) {
22771
+ return;
22772
+ }
22673
22773
  const caseData = block.cases.map((currentCase) => {
22674
22774
  const index = this.createEmbeddedTemplateFn(null, currentCase.children, "_Case", currentCase.sourceSpan, void 0, void 0, void 0, currentCase.i18n);
22675
22775
  const expression = currentCase.expression === null ? null : currentCase.expression.visit(this._valueConverter);
@@ -22819,7 +22919,12 @@ var TemplateDefinitionBuilder = class {
22819
22919
  });
22820
22920
  const { expression: trackByExpression, usesComponentInstance: trackByUsesComponentInstance } = this.createTrackByFunction(block);
22821
22921
  let emptyData = null;
22922
+ let emptyTagName = null;
22923
+ let emptyAttrsExprs;
22822
22924
  if (block.empty !== null) {
22925
+ const emptyInferred = this.inferProjectionDataFromInsertionPoint(block.empty);
22926
+ emptyTagName = emptyInferred.tagName;
22927
+ emptyAttrsExprs = emptyInferred.attrsExprs;
22823
22928
  emptyData = this.prepareEmbeddedTemplateFn(block.empty.children, "_ForEmpty", void 0, block.empty.i18n);
22824
22929
  this.allocateBindingSlots(null);
22825
22930
  }
@@ -22835,11 +22940,11 @@ var TemplateDefinitionBuilder = class {
22835
22940
  trackByExpression
22836
22941
  ];
22837
22942
  if (emptyData !== null) {
22838
- params.push(literal(trackByUsesComponentInstance), variable(emptyData.name), literal(emptyData.getConstCount()), literal(emptyData.getVarCount()));
22943
+ params.push(literal(trackByUsesComponentInstance), variable(emptyData.name), literal(emptyData.getConstCount()), literal(emptyData.getVarCount()), literal(emptyTagName), this.addAttrsToConsts(emptyAttrsExprs || null));
22839
22944
  } else if (trackByUsesComponentInstance) {
22840
22945
  params.push(literal(trackByUsesComponentInstance));
22841
22946
  }
22842
- return params;
22947
+ return trimTrailingNulls(params);
22843
22948
  });
22844
22949
  const value = block.expression.visit(this._valueConverter);
22845
22950
  this.updateInstructionWithAdvance(blockIndex, block.sourceSpan, Identifiers.repeater, () => [this.convertPropertyBinding(value)]);
@@ -22992,7 +23097,7 @@ var TemplateDefinitionBuilder = class {
22992
23097
  if (delta < 1) {
22993
23098
  throw new Error("advance instruction can only go forwards");
22994
23099
  }
22995
- this.instructionFn(this._updateCodeFns, span, Identifiers.advance, [literal(delta)]);
23100
+ this.instructionFn(this._updateCodeFns, span, Identifiers.advance, delta > 1 ? [literal(delta)] : []);
22996
23101
  this._currentIndex = nodeIndex;
22997
23102
  }
22998
23103
  }
@@ -23402,12 +23507,15 @@ var BindingScope = class {
23402
23507
  }
23403
23508
  };
23404
23509
  var TrackByBindingScope = class extends BindingScope {
23405
- constructor(parentScope, globalAliases) {
23510
+ constructor(parentScope, globalOverrides) {
23406
23511
  super(parentScope.bindingLevel + 1, parentScope);
23407
- this.globalAliases = globalAliases;
23512
+ this.globalOverrides = globalOverrides;
23408
23513
  this.componentAccessCount = 0;
23409
23514
  }
23410
23515
  get(name) {
23516
+ if (this.globalOverrides.hasOwnProperty(name)) {
23517
+ return variable(this.globalOverrides[name]);
23518
+ }
23411
23519
  let current = this.parent;
23412
23520
  while (current) {
23413
23521
  if (current.hasLocal(name)) {
@@ -23415,9 +23523,6 @@ var TrackByBindingScope = class extends BindingScope {
23415
23523
  }
23416
23524
  current = current.parent;
23417
23525
  }
23418
- if (this.globalAliases[name]) {
23419
- return variable(this.globalAliases[name]);
23420
- }
23421
23526
  this.componentAccessCount++;
23422
23527
  return variable("this").prop(name);
23423
23528
  }
@@ -25082,7 +25187,7 @@ function convertDirectiveFacadeToMetadata(facade) {
25082
25187
  bindingPropertyName: ann.alias || field,
25083
25188
  classPropertyName: field,
25084
25189
  required: ann.required || false,
25085
- isSignal: false,
25190
+ isSignal: !!ann.isSignal,
25086
25191
  transformFunction: ann.transform != null ? new WrappedNodeExpr(ann.transform) : null
25087
25192
  };
25088
25193
  } else if (isOutput(ann)) {
@@ -25436,7 +25541,7 @@ function publishFacade(global) {
25436
25541
  }
25437
25542
 
25438
25543
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/version.mjs
25439
- var VERSION2 = new Version("17.1.0-next.4");
25544
+ var VERSION2 = new Version("17.1.0-rc.0");
25440
25545
 
25441
25546
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
25442
25547
  var _VisitorMode;
@@ -25480,6 +25585,20 @@ var FactoryTarget2;
25480
25585
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/compiler.mjs
25481
25586
  publishFacade(_global);
25482
25587
 
25588
+ // bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/identifier-lookup.mjs
25589
+ var import_typescript5 = __toESM(require("typescript"), 1);
25590
+ function lookupIdentifiersInSourceFile(sourceFile, names) {
25591
+ const results = /* @__PURE__ */ new Set();
25592
+ const visit = (node) => {
25593
+ if (import_typescript5.default.isIdentifier(node) && names.includes(node.text)) {
25594
+ results.add(node);
25595
+ }
25596
+ import_typescript5.default.forEachChild(node, visit);
25597
+ };
25598
+ visit(sourceFile);
25599
+ return results;
25600
+ }
25601
+
25483
25602
  // bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/types.mjs
25484
25603
  var ngtemplate = "ng-template";
25485
25604
  var boundngifelse = "[ngIfElse]";
@@ -25490,6 +25609,18 @@ var startMarker = "\u25EC";
25490
25609
  var endMarker = "\u2722";
25491
25610
  var startI18nMarker = "\u2688";
25492
25611
  var endI18nMarker = "\u2689";
25612
+ var importRemovals = [
25613
+ "NgIf",
25614
+ "NgIfElse",
25615
+ "NgIfThenElse",
25616
+ "NgFor",
25617
+ "NgForOf",
25618
+ "NgForTrackBy",
25619
+ "NgSwitch",
25620
+ "NgSwitchCase",
25621
+ "NgSwitchDefault"
25622
+ ];
25623
+ var importWithCommonRemovals = [...importRemovals, "CommonModule"];
25493
25624
  function allFormsOf(selector) {
25494
25625
  return [
25495
25626
  selector,
@@ -25639,22 +25770,24 @@ var Template2 = class {
25639
25770
  }
25640
25771
  };
25641
25772
  var AnalyzedFile = class {
25642
- constructor() {
25773
+ constructor(sourceFile) {
25643
25774
  __publicField(this, "ranges", []);
25644
25775
  __publicField(this, "removeCommonModule", false);
25645
25776
  __publicField(this, "canRemoveImports", false);
25646
- __publicField(this, "sourceFilePath", "");
25777
+ __publicField(this, "sourceFile");
25778
+ __publicField(this, "importRanges", []);
25779
+ __publicField(this, "templateRanges", []);
25780
+ this.sourceFile = sourceFile;
25647
25781
  }
25648
25782
  getSortedRanges() {
25649
- const templateRanges = this.ranges.slice().filter((x) => x.type !== "import").sort((aStart, bStart) => bStart.start - aStart.start);
25650
- const importRanges = this.ranges.slice().filter((x) => x.type === "import").sort((aStart, bStart) => bStart.start - aStart.start);
25651
- return [...templateRanges, ...importRanges];
25783
+ this.templateRanges = this.ranges.slice().filter((x) => x.type === "template" || x.type === "templateUrl").sort((aStart, bStart) => bStart.start - aStart.start);
25784
+ this.importRanges = this.ranges.slice().filter((x) => x.type === "importDecorator" || x.type === "importDeclaration").sort((aStart, bStart) => bStart.start - aStart.start);
25785
+ return [...this.templateRanges, ...this.importRanges];
25652
25786
  }
25653
- static addRange(path2, sourceFilePath, analyzedFiles, range) {
25787
+ static addRange(path2, sourceFile, analyzedFiles, range) {
25654
25788
  let analysis = analyzedFiles.get(path2);
25655
25789
  if (!analysis) {
25656
- analysis = new AnalyzedFile();
25657
- analysis.sourceFilePath = sourceFilePath;
25790
+ analysis = new AnalyzedFile(sourceFile);
25658
25791
  analyzedFiles.set(path2, analysis);
25659
25792
  }
25660
25793
  const duplicate = analysis.ranges.find((current) => current.start === range.start && current.end === range.end);
@@ -25662,6 +25795,25 @@ var AnalyzedFile = class {
25662
25795
  analysis.ranges.push(range);
25663
25796
  }
25664
25797
  }
25798
+ verifyCanRemoveImports() {
25799
+ const importDeclaration = this.importRanges.find((r) => r.type === "importDeclaration");
25800
+ const instances = lookupIdentifiersInSourceFile(this.sourceFile, importWithCommonRemovals);
25801
+ let foundImportDeclaration = false;
25802
+ let count = 0;
25803
+ for (let range of this.importRanges) {
25804
+ for (let instance of instances) {
25805
+ if (instance.getStart() >= range.start && instance.getEnd() <= range.end) {
25806
+ if (range === importDeclaration) {
25807
+ foundImportDeclaration = true;
25808
+ }
25809
+ count++;
25810
+ }
25811
+ }
25812
+ }
25813
+ if (instances.size !== count && importDeclaration !== void 0 && foundImportDeclaration) {
25814
+ importDeclaration.remove = false;
25815
+ }
25816
+ }
25665
25817
  };
25666
25818
  var CommonCollector = class extends RecursiveVisitor {
25667
25819
  constructor() {
@@ -25782,19 +25934,7 @@ var TemplateCollector = class extends RecursiveVisitor {
25782
25934
 
25783
25935
  // bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/util.mjs
25784
25936
  var import_path2 = require("path");
25785
- var import_typescript5 = __toESM(require("typescript"), 1);
25786
- var importRemovals = [
25787
- "NgIf",
25788
- "NgIfElse",
25789
- "NgIfThenElse",
25790
- "NgFor",
25791
- "NgForOf",
25792
- "NgForTrackBy",
25793
- "NgSwitch",
25794
- "NgSwitchCase",
25795
- "NgSwitchDefault"
25796
- ];
25797
- var importWithCommonRemovals = [...importRemovals, "CommonModule"];
25937
+ var import_typescript6 = __toESM(require("typescript"), 1);
25798
25938
  var startMarkerRegex = new RegExp(startMarker, "gm");
25799
25939
  var endMarkerRegex = new RegExp(endMarker, "gm");
25800
25940
  var startI18nMarkerRegex = new RegExp(startI18nMarker, "gm");
@@ -25802,16 +25942,20 @@ var endI18nMarkerRegex = new RegExp(endI18nMarker, "gm");
25802
25942
  var replaceMarkerRegex = new RegExp(`${startMarker}|${endMarker}`, "gm");
25803
25943
  function analyze(sourceFile, analyzedFiles) {
25804
25944
  forEachClass(sourceFile, (node) => {
25805
- if (import_typescript5.default.isClassDeclaration(node)) {
25945
+ if (import_typescript6.default.isClassDeclaration(node)) {
25806
25946
  analyzeDecorators(node, sourceFile, analyzedFiles);
25807
25947
  } else {
25808
25948
  analyzeImportDeclarations(node, sourceFile, analyzedFiles);
25809
25949
  }
25810
25950
  });
25811
25951
  }
25812
- function checkIfShouldChange(decl, removeCommonModule) {
25952
+ function checkIfShouldChange(decl, file) {
25953
+ const range = file.importRanges.find((r) => r.type === "importDeclaration");
25954
+ if (range === void 0 || !range.remove) {
25955
+ return false;
25956
+ }
25813
25957
  const clause = decl.getChildAt(1);
25814
- return !(!removeCommonModule && clause.namedBindings && import_typescript5.default.isNamedImports(clause.namedBindings) && clause.namedBindings.elements.length === 1 && clause.namedBindings.elements[0].getText() === "CommonModule");
25958
+ return !(!file.removeCommonModule && clause.namedBindings && import_typescript6.default.isNamedImports(clause.namedBindings) && clause.namedBindings.elements.length === 1 && clause.namedBindings.elements[0].getText() === "CommonModule");
25815
25959
  }
25816
25960
  function updateImportDeclaration(decl, removeCommonModule) {
25817
25961
  const clause = decl.getChildAt(1);
@@ -25819,81 +25963,89 @@ function updateImportDeclaration(decl, removeCommonModule) {
25819
25963
  if (updatedClause === null) {
25820
25964
  return "";
25821
25965
  }
25822
- const printer = import_typescript5.default.createPrinter({
25966
+ const printer = import_typescript6.default.createPrinter({
25823
25967
  removeComments: true
25824
25968
  });
25825
- const updated = import_typescript5.default.factory.updateImportDeclaration(decl, decl.modifiers, updatedClause, decl.moduleSpecifier, void 0);
25826
- return printer.printNode(import_typescript5.default.EmitHint.Unspecified, updated, clause.getSourceFile());
25969
+ const updated = import_typescript6.default.factory.updateImportDeclaration(decl, decl.modifiers, updatedClause, decl.moduleSpecifier, void 0);
25970
+ return printer.printNode(import_typescript6.default.EmitHint.Unspecified, updated, clause.getSourceFile());
25827
25971
  }
25828
25972
  function updateImportClause(clause, removeCommonModule) {
25829
- if (clause.namedBindings && import_typescript5.default.isNamedImports(clause.namedBindings)) {
25973
+ if (clause.namedBindings && import_typescript6.default.isNamedImports(clause.namedBindings)) {
25830
25974
  const removals = removeCommonModule ? importWithCommonRemovals : importRemovals;
25831
25975
  const elements = clause.namedBindings.elements.filter((el) => !removals.includes(el.getText()));
25832
25976
  if (elements.length === 0) {
25833
25977
  return null;
25834
25978
  }
25835
- clause = import_typescript5.default.factory.updateImportClause(clause, clause.isTypeOnly, clause.name, import_typescript5.default.factory.createNamedImports(elements));
25979
+ clause = import_typescript6.default.factory.updateImportClause(clause, clause.isTypeOnly, clause.name, import_typescript6.default.factory.createNamedImports(elements));
25836
25980
  }
25837
25981
  return clause;
25838
25982
  }
25839
25983
  function updateClassImports(propAssignment, removeCommonModule) {
25840
- const printer = import_typescript5.default.createPrinter();
25984
+ const printer = import_typescript6.default.createPrinter();
25841
25985
  const importList = propAssignment.initializer;
25842
25986
  const removals = removeCommonModule ? importWithCommonRemovals : importRemovals;
25843
25987
  const elements = importList.elements.filter((el) => !removals.includes(el.getText()));
25844
25988
  if (elements.length === importList.elements.length) {
25845
25989
  return null;
25846
25990
  }
25847
- const updatedElements = import_typescript5.default.factory.updateArrayLiteralExpression(importList, elements);
25848
- const updatedAssignment = import_typescript5.default.factory.updatePropertyAssignment(propAssignment, propAssignment.name, updatedElements);
25849
- return printer.printNode(import_typescript5.default.EmitHint.Unspecified, updatedAssignment, updatedAssignment.getSourceFile());
25991
+ const updatedElements = import_typescript6.default.factory.updateArrayLiteralExpression(importList, elements);
25992
+ const updatedAssignment = import_typescript6.default.factory.updatePropertyAssignment(propAssignment, propAssignment.name, updatedElements);
25993
+ return printer.printNode(import_typescript6.default.EmitHint.Unspecified, updatedAssignment, updatedAssignment.getSourceFile());
25850
25994
  }
25851
25995
  function analyzeImportDeclarations(node, sourceFile, analyzedFiles) {
25852
25996
  if (node.getText().indexOf("@angular/common") === -1) {
25853
25997
  return;
25854
25998
  }
25855
25999
  const clause = node.getChildAt(1);
25856
- if (clause.namedBindings && import_typescript5.default.isNamedImports(clause.namedBindings)) {
26000
+ if (clause.namedBindings && import_typescript6.default.isNamedImports(clause.namedBindings)) {
25857
26001
  const elements = clause.namedBindings.elements.filter((el) => importWithCommonRemovals.includes(el.getText()));
25858
26002
  if (elements.length > 0) {
25859
- AnalyzedFile.addRange(sourceFile.fileName, sourceFile.fileName, analyzedFiles, { start: node.getStart(), end: node.getEnd(), node, type: "import" });
26003
+ AnalyzedFile.addRange(sourceFile.fileName, sourceFile, analyzedFiles, {
26004
+ start: node.getStart(),
26005
+ end: node.getEnd(),
26006
+ node,
26007
+ type: "importDeclaration",
26008
+ remove: true
26009
+ });
25860
26010
  }
25861
26011
  }
25862
26012
  }
25863
26013
  function analyzeDecorators(node, sourceFile, analyzedFiles) {
25864
26014
  var _a2;
25865
- const decorator = (_a2 = import_typescript5.default.getDecorators(node)) == null ? void 0 : _a2.find((dec) => {
25866
- return import_typescript5.default.isCallExpression(dec.expression) && import_typescript5.default.isIdentifier(dec.expression.expression) && dec.expression.expression.text === "Component";
26015
+ const decorator = (_a2 = import_typescript6.default.getDecorators(node)) == null ? void 0 : _a2.find((dec) => {
26016
+ return import_typescript6.default.isCallExpression(dec.expression) && import_typescript6.default.isIdentifier(dec.expression.expression) && dec.expression.expression.text === "Component";
25867
26017
  });
25868
- const metadata = decorator && decorator.expression.arguments.length > 0 && import_typescript5.default.isObjectLiteralExpression(decorator.expression.arguments[0]) ? decorator.expression.arguments[0] : null;
26018
+ const metadata = decorator && decorator.expression.arguments.length > 0 && import_typescript6.default.isObjectLiteralExpression(decorator.expression.arguments[0]) ? decorator.expression.arguments[0] : null;
25869
26019
  if (!metadata) {
25870
26020
  return;
25871
26021
  }
25872
26022
  for (const prop of metadata.properties) {
25873
- if (!import_typescript5.default.isPropertyAssignment(prop) || !import_typescript5.default.isIdentifier(prop.name) && !import_typescript5.default.isStringLiteralLike(prop.name)) {
26023
+ if (!import_typescript6.default.isPropertyAssignment(prop) || !import_typescript6.default.isIdentifier(prop.name) && !import_typescript6.default.isStringLiteralLike(prop.name)) {
25874
26024
  continue;
25875
26025
  }
25876
26026
  switch (prop.name.text) {
25877
26027
  case "template":
25878
- AnalyzedFile.addRange(sourceFile.fileName, sourceFile.fileName, analyzedFiles, {
26028
+ AnalyzedFile.addRange(sourceFile.fileName, sourceFile, analyzedFiles, {
25879
26029
  start: prop.initializer.getStart() + 1,
25880
26030
  end: prop.initializer.getEnd() - 1,
25881
26031
  node: prop,
25882
- type: "template"
26032
+ type: "template",
26033
+ remove: true
25883
26034
  });
25884
26035
  break;
25885
26036
  case "imports":
25886
- AnalyzedFile.addRange(sourceFile.fileName, sourceFile.fileName, analyzedFiles, {
26037
+ AnalyzedFile.addRange(sourceFile.fileName, sourceFile, analyzedFiles, {
25887
26038
  start: prop.name.getStart(),
25888
26039
  end: prop.initializer.getEnd(),
25889
26040
  node: prop,
25890
- type: "import"
26041
+ type: "importDecorator",
26042
+ remove: true
25891
26043
  });
25892
26044
  break;
25893
26045
  case "templateUrl":
25894
- if (import_typescript5.default.isStringLiteralLike(prop.initializer)) {
26046
+ if (import_typescript6.default.isStringLiteralLike(prop.initializer)) {
25895
26047
  const path2 = (0, import_path2.join)((0, import_path2.dirname)(sourceFile.fileName), prop.initializer.text);
25896
- AnalyzedFile.addRange(path2, sourceFile.fileName, analyzedFiles, { start: 0, node: prop, type: "templateUrl" });
26048
+ AnalyzedFile.addRange(path2, sourceFile, analyzedFiles, { start: 0, node: prop, type: "templateUrl", remove: true });
25897
26049
  }
25898
26050
  break;
25899
26051
  }
@@ -25928,6 +26080,41 @@ function parseTemplate2(template2) {
25928
26080
  }
25929
26081
  return { tree: parsed, errors: [] };
25930
26082
  }
26083
+ function validateMigratedTemplate(migrated, fileName) {
26084
+ const parsed = parseTemplate2(migrated);
26085
+ let errors = [];
26086
+ if (parsed.errors.length > 0) {
26087
+ errors.push({
26088
+ type: "parse",
26089
+ error: new Error(`The migration resulted in invalid HTML for ${fileName}. Please check the template for valid HTML structures and run the migration again.`)
26090
+ });
26091
+ }
26092
+ if (parsed.tree) {
26093
+ const i18nError = validateI18nStructure(parsed.tree, fileName);
26094
+ if (i18nError !== null) {
26095
+ errors.push({ type: "i18n", error: i18nError });
26096
+ }
26097
+ }
26098
+ return errors;
26099
+ }
26100
+ function validateI18nStructure(parsed, fileName) {
26101
+ const visitor = new i18nCollector();
26102
+ visitAll2(visitor, parsed.rootNodes);
26103
+ const parents = visitor.elements.filter((el) => el.children.length > 0);
26104
+ for (const p of parents) {
26105
+ for (const el of visitor.elements) {
26106
+ if (el === p)
26107
+ continue;
26108
+ if (isChildOf(p, el)) {
26109
+ return new Error(`i18n Nesting error: The migration would result in invalid i18n nesting for ${fileName}. Element with i18n attribute "${p.name}" would result having a child of element with i18n attribute "${el.name}". Please fix and re-run the migration.`);
26110
+ }
26111
+ }
26112
+ }
26113
+ return null;
26114
+ }
26115
+ function isChildOf(parent, el) {
26116
+ return parent.sourceSpan.start.offset < el.sourceSpan.start.offset && parent.sourceSpan.end.offset > el.sourceSpan.end.offset;
26117
+ }
25931
26118
  function calculateNesting(visitor, hasLineBreaks2) {
25932
26119
  let nestedQueue = [];
25933
26120
  for (let i = 0; i < visitor.elements.length; i++) {
@@ -26049,12 +26236,12 @@ function canRemoveCommonModule(template2) {
26049
26236
  }
26050
26237
  return removeCommonModule;
26051
26238
  }
26052
- function removeImports(template2, node, removeCommonModule) {
26053
- if (template2.startsWith("imports") && import_typescript5.default.isPropertyAssignment(node)) {
26054
- const updatedImport = updateClassImports(node, removeCommonModule);
26239
+ function removeImports(template2, node, file) {
26240
+ if (template2.startsWith("imports") && import_typescript6.default.isPropertyAssignment(node)) {
26241
+ const updatedImport = updateClassImports(node, file.removeCommonModule);
26055
26242
  return updatedImport != null ? updatedImport : template2;
26056
- } else if (import_typescript5.default.isImportDeclaration(node) && checkIfShouldChange(node, removeCommonModule)) {
26057
- return updateImportDeclaration(node, removeCommonModule);
26243
+ } else if (import_typescript6.default.isImportDeclaration(node) && checkIfShouldChange(node, file)) {
26244
+ return updateImportDeclaration(node, file.removeCommonModule);
26058
26245
  }
26059
26246
  return template2;
26060
26247
  }
@@ -26114,7 +26301,7 @@ function getMainBlock(etm, tmpl, offset) {
26114
26301
  const { childStart: childStart2, childEnd: childEnd2 } = etm.getChildSpan(offset);
26115
26302
  middle2 = tmpl.slice(childStart2, childEnd2);
26116
26303
  } else {
26117
- middle2 = startMarker + endMarker;
26304
+ middle2 = "";
26118
26305
  }
26119
26306
  return { start: "", middle: middle2, end: "" };
26120
26307
  } else if (isI18nTemplate(etm, i18nAttr)) {
@@ -26159,6 +26346,10 @@ function formatTemplate(tmpl, templateType) {
26159
26346
  let openSelfClosingEl = false;
26160
26347
  const openBlockRegex = /^\s*\@(if|switch|case|default|for)|^\s*\}\s\@else/;
26161
26348
  const openElRegex = /^\s*<([a-z0-9]+)(?![^>]*\/>)[^>]*>?/;
26349
+ const openAttrDoubleRegex = /="([^"]|\\")*$/;
26350
+ const openAttrSingleRegex = /='([^']|\\')*$/;
26351
+ const closeAttrDoubleRegex = /^\s*([^><]|\\")*"/;
26352
+ const closeAttrSingleRegex = /^\s*([^><]|\\')*'/;
26162
26353
  const selfClosingRegex = new RegExp(`^\\s*<(${selfClosingList}).+\\/?>`);
26163
26354
  const openSelfClosingRegex = new RegExp(`^\\s*<(${selfClosingList})(?![^>]*\\/>)[^>]*$`);
26164
26355
  const closeBlockRegex = /^\s*\}\s*$|^\s*\}\s\@else/;
@@ -26174,6 +26365,8 @@ function formatTemplate(tmpl, templateType) {
26174
26365
  let i18nDepth = 0;
26175
26366
  let inMigratedBlock = false;
26176
26367
  let inI18nBlock = false;
26368
+ let inAttribute = false;
26369
+ let isDoubleQuotes = false;
26177
26370
  for (let [index, line] of lines.entries()) {
26178
26371
  depth += [...line.matchAll(startMarkerRegex)].length - [...line.matchAll(endMarkerRegex)].length;
26179
26372
  inMigratedBlock = depth > 0;
@@ -26183,7 +26376,7 @@ function formatTemplate(tmpl, templateType) {
26183
26376
  line = line.replace(replaceMarkerRegex, "");
26184
26377
  lineWasMigrated = true;
26185
26378
  }
26186
- if (line.trim() === "" && index !== 0 && index !== lines.length - 1 && (inMigratedBlock || lineWasMigrated)) {
26379
+ if (line.trim() === "" && index !== 0 && index !== lines.length - 1 && (inMigratedBlock || lineWasMigrated) && !inI18nBlock && !inAttribute) {
26187
26380
  continue;
26188
26381
  }
26189
26382
  if (templateType === "template" && index <= 1) {
@@ -26193,8 +26386,20 @@ function formatTemplate(tmpl, templateType) {
26193
26386
  if ((closeBlockRegex.test(line) || closeElRegex.test(line) && (!singleLineElRegex.test(line) && !closeMultiLineElRegex.test(line))) && indent !== "") {
26194
26387
  indent = indent.slice(2);
26195
26388
  }
26196
- const newLine = inI18nBlock ? line : mindent + (line.trim() !== "" ? indent : "") + line.trim();
26389
+ const isOpenDoubleAttr = openAttrDoubleRegex.test(line);
26390
+ const isOpenSingleAttr = openAttrSingleRegex.test(line);
26391
+ if (!inAttribute && isOpenDoubleAttr) {
26392
+ inAttribute = true;
26393
+ isDoubleQuotes = true;
26394
+ } else if (!inAttribute && isOpenSingleAttr) {
26395
+ inAttribute = true;
26396
+ isDoubleQuotes = false;
26397
+ }
26398
+ const newLine = inI18nBlock || inAttribute ? line : mindent + (line.trim() !== "" ? indent : "") + line.trim();
26197
26399
  formatted.push(newLine);
26400
+ if (!isOpenDoubleAttr && !isOpenSingleAttr && (inAttribute && isDoubleQuotes && closeAttrDoubleRegex.test(line) || inAttribute && !isDoubleQuotes && closeAttrSingleRegex.test(line))) {
26401
+ inAttribute = false;
26402
+ }
26198
26403
  if (closeMultiLineElRegex.test(line)) {
26199
26404
  indent = indent.slice(2);
26200
26405
  if (openSelfClosingEl) {
@@ -26220,7 +26425,7 @@ function formatTemplate(tmpl, templateType) {
26220
26425
  }
26221
26426
  function forEachClass(sourceFile, callback) {
26222
26427
  sourceFile.forEachChild(function walk(node) {
26223
- if (import_typescript5.default.isClassDeclaration(node) || import_typescript5.default.isImportDeclaration(node)) {
26428
+ if (import_typescript6.default.isClassDeclaration(node) || import_typescript6.default.isImportDeclaration(node)) {
26224
26429
  callback(node);
26225
26430
  }
26226
26431
  node.forEachChild(walk);
@@ -26461,10 +26666,10 @@ function getNgForParts(expression) {
26461
26666
  current = "";
26462
26667
  continue;
26463
26668
  }
26464
- if (stringPairs.has(char)) {
26465
- stringStack.push(stringPairs.get(char));
26466
- } else if (stringStack.length > 0 && stringStack[stringStack.length - 1] === char) {
26669
+ if (stringStack.length > 0 && stringStack[stringStack.length - 1] === char) {
26467
26670
  stringStack.pop();
26671
+ } else if (stringPairs.has(char)) {
26672
+ stringStack.push(stringPairs.get(char));
26468
26673
  }
26469
26674
  if (commaSeparatedSyntax.has(char)) {
26470
26675
  commaSeparatedStack.push(commaSeparatedSyntax.get(char));
@@ -26719,13 +26924,9 @@ function migrateTemplate(template2, templateType, node, file, format = true, ana
26719
26924
  migrated = templateResult.migrated;
26720
26925
  const changed = ifResult.changed || forResult.changed || switchResult.changed || caseResult.changed;
26721
26926
  if (changed) {
26722
- const parsed = parseTemplate2(migrated);
26723
- if (parsed.errors.length > 0) {
26724
- const parsingError = {
26725
- type: "parse",
26726
- error: new Error(`The migration resulted in invalid HTML for ${file.sourceFilePath}. Please check the template for valid HTML structures and run the migration again.`)
26727
- };
26728
- return { migrated: template2, errors: [parsingError] };
26927
+ const errors2 = validateMigratedTemplate(migrated, file.sourceFile.fileName);
26928
+ if (errors2.length > 0) {
26929
+ return { migrated: template2, errors: errors2 };
26729
26930
  }
26730
26931
  }
26731
26932
  if (format && changed) {
@@ -26735,11 +26936,14 @@ function migrateTemplate(template2, templateType, node, file, format = true, ana
26735
26936
  migrated = migrated.replace(markerRegex, "");
26736
26937
  file.removeCommonModule = canRemoveCommonModule(template2);
26737
26938
  file.canRemoveImports = true;
26738
- if (templateType === "templateUrl" && analyzedFiles !== null && analyzedFiles.has(file.sourceFilePath)) {
26739
- const componentFile = analyzedFiles.get(file.sourceFilePath);
26939
+ if (templateType === "templateUrl" && analyzedFiles !== null && analyzedFiles.has(file.sourceFile.fileName)) {
26940
+ const componentFile = analyzedFiles.get(file.sourceFile.fileName);
26941
+ componentFile.getSortedRanges();
26740
26942
  componentFile.removeCommonModule = file.removeCommonModule;
26741
26943
  componentFile.canRemoveImports = file.canRemoveImports;
26944
+ componentFile.verifyCanRemoveImports();
26742
26945
  }
26946
+ file.verifyCanRemoveImports();
26743
26947
  errors = [
26744
26948
  ...ifResult.errors,
26745
26949
  ...forResult.errors,
@@ -26747,7 +26951,7 @@ function migrateTemplate(template2, templateType, node, file, format = true, ana
26747
26951
  ...caseResult.errors
26748
26952
  ];
26749
26953
  } else if (file.canRemoveImports) {
26750
- migrated = removeImports(template2, node, file.removeCommonModule);
26954
+ migrated = removeImports(template2, node, file);
26751
26955
  }
26752
26956
  return { migrated, errors };
26753
26957
  }