@angular/core 17.0.7 → 17.0.9

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 (63) hide show
  1. package/esm2022/src/application/application_ref.mjs +24 -12
  2. package/esm2022/src/application/create_application.mjs +2 -2
  3. package/esm2022/src/change_detection/flags.mjs +16 -0
  4. package/esm2022/src/change_detection/scheduling/ng_zone_scheduling.mjs +164 -0
  5. package/esm2022/src/change_detection/scheduling/zoneless_scheduling.mjs +13 -0
  6. package/esm2022/src/change_detection/scheduling/zoneless_scheduling_impl.mjs +56 -0
  7. package/esm2022/src/core.mjs +2 -2
  8. package/esm2022/src/core_private_export.mjs +5 -2
  9. package/esm2022/src/core_render3_private_export.mjs +1 -2
  10. package/esm2022/src/defer/dom_triggers.mjs +1 -5
  11. package/esm2022/src/di/inject_switch.mjs +2 -3
  12. package/esm2022/src/di/r3_injector.mjs +8 -6
  13. package/esm2022/src/errors.mjs +1 -1
  14. package/esm2022/src/event_emitter.mjs +1 -2
  15. package/esm2022/src/hydration/utils.mjs +2 -2
  16. package/esm2022/src/hydration/views.mjs +2 -2
  17. package/esm2022/src/linker/view_container_ref.mjs +2 -2
  18. package/esm2022/src/pending_tasks.mjs +57 -0
  19. package/esm2022/src/platform/platform_ref.mjs +2 -2
  20. package/esm2022/src/render3/after_render_hooks.mjs +16 -34
  21. package/esm2022/src/render3/collect_native_nodes.mjs +2 -3
  22. package/esm2022/src/render3/component_ref.mjs +13 -9
  23. package/esm2022/src/render3/debug/injector_profiler.mjs +1 -1
  24. package/esm2022/src/render3/errors_di.mjs +4 -3
  25. package/esm2022/src/render3/instructions/advance.mjs +2 -2
  26. package/esm2022/src/render3/instructions/change_detection.mjs +1 -6
  27. package/esm2022/src/render3/instructions/mark_view_dirty.mjs +4 -3
  28. package/esm2022/src/render3/instructions/shared.mjs +4 -3
  29. package/esm2022/src/render3/interfaces/container.mjs +1 -6
  30. package/esm2022/src/render3/interfaces/view.mjs +1 -1
  31. package/esm2022/src/render3/node_manipulation.mjs +8 -8
  32. package/esm2022/src/render3/reactivity/effect.mjs +8 -6
  33. package/esm2022/src/render3/styling/style_binding_list.mjs +4 -4
  34. package/esm2022/src/render3/util/discovery_utils.mjs +3 -3
  35. package/esm2022/src/render3/util/global_utils.mjs +28 -28
  36. package/esm2022/src/render3/util/injector_discovery_utils.mjs +1 -1
  37. package/esm2022/src/render3/util/injector_utils.mjs +6 -5
  38. package/esm2022/src/render3/util/view_traversal_utils.mjs +3 -12
  39. package/esm2022/src/render3/util/view_utils.mjs +36 -19
  40. package/esm2022/src/render3/view_ref.mjs +2 -1
  41. package/esm2022/src/version.mjs +6 -5
  42. package/esm2022/src/zone/ng_zone.mjs +1 -61
  43. package/esm2022/testing/src/component_fixture.mjs +62 -58
  44. package/esm2022/testing/src/logger.mjs +3 -3
  45. package/fesm2022/core.mjs +374 -309
  46. package/fesm2022/core.mjs.map +1 -1
  47. package/fesm2022/primitives/signals.mjs +1 -1
  48. package/fesm2022/rxjs-interop.mjs +1 -1
  49. package/fesm2022/testing.mjs +62 -58
  50. package/fesm2022/testing.mjs.map +1 -1
  51. package/index.d.ts +405 -46
  52. package/package.json +1 -1
  53. package/primitives/signals/index.d.ts +1 -1
  54. package/rxjs-interop/index.d.ts +1 -1
  55. package/schematics/migrations/block-template-entities/bundle.js +332 -330
  56. package/schematics/migrations/block-template-entities/bundle.js.map +4 -4
  57. package/schematics/ng-generate/control-flow-migration/bundle.js +498 -397
  58. package/schematics/ng-generate/control-flow-migration/bundle.js.map +4 -4
  59. package/schematics/ng-generate/standalone-migration/bundle.js +349 -323
  60. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  61. package/testing/index.d.ts +6 -2
  62. package/esm2022/src/change_detection/scheduling.mjs +0 -103
  63. package/esm2022/src/initial_render_pending_tasks.mjs +0 -49
@@ -1805,7 +1805,7 @@ var ConstantPool = class {
1805
1805
  }))));
1806
1806
  }
1807
1807
  }
1808
- getSharedFunctionReference(fn2, prefix) {
1808
+ getSharedFunctionReference(fn2, prefix, useUniqueName = true) {
1809
1809
  var _a2;
1810
1810
  const isArrow = fn2 instanceof ArrowFunctionExpr;
1811
1811
  for (const current of this.statements) {
@@ -1816,7 +1816,7 @@ var ConstantPool = class {
1816
1816
  return variable(current.name);
1817
1817
  }
1818
1818
  }
1819
- const name = this.uniqueName(prefix);
1819
+ const name = useUniqueName ? this.uniqueName(prefix) : prefix;
1820
1820
  this.statements.push(fn2.toDeclStmt(name, StmtModifier.Final));
1821
1821
  return variable(name);
1822
1822
  }
@@ -3437,13 +3437,17 @@ var TagContentType;
3437
3437
  TagContentType2[TagContentType2["ESCAPABLE_RAW_TEXT"] = 1] = "ESCAPABLE_RAW_TEXT";
3438
3438
  TagContentType2[TagContentType2["PARSABLE_DATA"] = 2] = "PARSABLE_DATA";
3439
3439
  })(TagContentType || (TagContentType = {}));
3440
- function splitNsName(elementName) {
3440
+ function splitNsName(elementName, fatal = true) {
3441
3441
  if (elementName[0] != ":") {
3442
3442
  return [null, elementName];
3443
3443
  }
3444
3444
  const colonIndex = elementName.indexOf(":", 1);
3445
3445
  if (colonIndex === -1) {
3446
- throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
3446
+ if (fatal) {
3447
+ throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
3448
+ } else {
3449
+ return [null, elementName];
3450
+ }
3447
3451
  }
3448
3452
  return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)];
3449
3453
  }
@@ -3950,28 +3954,6 @@ var BlockPlaceholder = class {
3950
3954
  return visitor.visitBlockPlaceholder(this, context);
3951
3955
  }
3952
3956
  };
3953
- var RecurseVisitor = class {
3954
- visitText(text2, context) {
3955
- }
3956
- visitContainer(container, context) {
3957
- container.children.forEach((child) => child.visit(this));
3958
- }
3959
- visitIcu(icu, context) {
3960
- Object.keys(icu.cases).forEach((k) => {
3961
- icu.cases[k].visit(this);
3962
- });
3963
- }
3964
- visitTagPlaceholder(ph, context) {
3965
- ph.children.forEach((child) => child.visit(this));
3966
- }
3967
- visitPlaceholder(ph, context) {
3968
- }
3969
- visitIcuPlaceholder(ph, context) {
3970
- }
3971
- visitBlockPlaceholder(ph, context) {
3972
- ph.children.forEach((child) => child.visit(this));
3973
- }
3974
- };
3975
3957
  function serializeMessage(messageNodes) {
3976
3958
  const visitor = new LocalizeMessageStringVisitor();
3977
3959
  const str = messageNodes.map((n) => n.visit(visitor)).join("");
@@ -7039,8 +7021,9 @@ var OpKind;
7039
7021
  OpKind2[OpKind2["I18nApply"] = 40] = "I18nApply";
7040
7022
  OpKind2[OpKind2["IcuStart"] = 41] = "IcuStart";
7041
7023
  OpKind2[OpKind2["IcuEnd"] = 42] = "IcuEnd";
7042
- OpKind2[OpKind2["I18nContext"] = 43] = "I18nContext";
7043
- OpKind2[OpKind2["I18nAttributes"] = 44] = "I18nAttributes";
7024
+ OpKind2[OpKind2["IcuPlaceholder"] = 43] = "IcuPlaceholder";
7025
+ OpKind2[OpKind2["I18nContext"] = 44] = "I18nContext";
7026
+ OpKind2[OpKind2["I18nAttributes"] = 45] = "I18nAttributes";
7044
7027
  })(OpKind || (OpKind = {}));
7045
7028
  var ExpressionKind;
7046
7029
  (function(ExpressionKind2) {
@@ -7138,13 +7121,6 @@ var DeferTriggerKind;
7138
7121
  DeferTriggerKind2[DeferTriggerKind2["Interaction"] = 4] = "Interaction";
7139
7122
  DeferTriggerKind2[DeferTriggerKind2["Viewport"] = 5] = "Viewport";
7140
7123
  })(DeferTriggerKind || (DeferTriggerKind = {}));
7141
- var DerivedRepeaterVarIdentity;
7142
- (function(DerivedRepeaterVarIdentity2) {
7143
- DerivedRepeaterVarIdentity2[DerivedRepeaterVarIdentity2["First"] = 0] = "First";
7144
- DerivedRepeaterVarIdentity2[DerivedRepeaterVarIdentity2["Last"] = 1] = "Last";
7145
- DerivedRepeaterVarIdentity2[DerivedRepeaterVarIdentity2["Even"] = 2] = "Even";
7146
- DerivedRepeaterVarIdentity2[DerivedRepeaterVarIdentity2["Odd"] = 3] = "Odd";
7147
- })(DerivedRepeaterVarIdentity || (DerivedRepeaterVarIdentity = {}));
7148
7124
  var I18nContextKind;
7149
7125
  (function(I18nContextKind2) {
7150
7126
  I18nContextKind2[I18nContextKind2["RootI18n"] = 0] = "RootI18n";
@@ -7299,10 +7275,11 @@ function createClassMapOp(xref, expression, sourceSpan) {
7299
7275
  sourceSpan
7300
7276
  }, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
7301
7277
  }
7302
- function createAttributeOp(target, name, expression, securityContext, isTextAttribute, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan) {
7278
+ function createAttributeOp(target, namespace, name, expression, securityContext, isTextAttribute, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan) {
7303
7279
  return __spreadValues(__spreadValues(__spreadValues({
7304
7280
  kind: OpKind.Attribute,
7305
7281
  target,
7282
+ namespace,
7306
7283
  name,
7307
7284
  expression,
7308
7285
  securityContext,
@@ -7344,15 +7321,15 @@ function createRepeaterOp(repeaterCreate2, targetSlot, collection, sourceSpan) {
7344
7321
  }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
7345
7322
  }
7346
7323
  function createDeferWhenOp(target, expr, prefetch, sourceSpan) {
7347
- return __spreadValues(__spreadValues({
7324
+ return __spreadValues(__spreadValues(__spreadValues({
7348
7325
  kind: OpKind.DeferWhen,
7349
7326
  target,
7350
7327
  expr,
7351
7328
  prefetch,
7352
7329
  sourceSpan
7353
- }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
7330
+ }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS);
7354
7331
  }
7355
- function createI18nExpressionOp(context, target, i18nOwner, handle, expression, i18nPlaceholder, resolutionTime, usage, name, sourceSpan) {
7332
+ function createI18nExpressionOp(context, target, i18nOwner, handle, expression, icuPlaceholder, i18nPlaceholder, resolutionTime, usage, name, sourceSpan) {
7356
7333
  return __spreadValues(__spreadValues(__spreadValues({
7357
7334
  kind: OpKind.I18nExpression,
7358
7335
  context,
@@ -7360,6 +7337,7 @@ function createI18nExpressionOp(context, target, i18nOwner, handle, expression,
7360
7337
  i18nOwner,
7361
7338
  handle,
7362
7339
  expression,
7340
+ icuPlaceholder,
7363
7341
  i18nPlaceholder,
7364
7342
  resolutionTime,
7365
7343
  usage,
@@ -7956,27 +7934,6 @@ var ConditionalCaseExpr = class extends ExpressionBase {
7956
7934
  }
7957
7935
  }
7958
7936
  };
7959
- var DerivedRepeaterVarExpr = class extends ExpressionBase {
7960
- constructor(xref, identity) {
7961
- super();
7962
- this.xref = xref;
7963
- this.identity = identity;
7964
- this.kind = ExpressionKind.DerivedRepeaterVar;
7965
- }
7966
- transformInternalExpressions(transform2, flags) {
7967
- }
7968
- visitExpression(visitor, context) {
7969
- }
7970
- isEquivalent(e) {
7971
- return e instanceof DerivedRepeaterVarExpr && e.identity === this.identity && e.xref === this.xref;
7972
- }
7973
- isConstant() {
7974
- return false;
7975
- }
7976
- clone() {
7977
- return new DerivedRepeaterVarExpr(this.xref, this.identity);
7978
- }
7979
- };
7980
7937
  var ConstCollectedExpr = class extends ExpressionBase {
7981
7938
  constructor(expr) {
7982
7939
  super();
@@ -8092,6 +8049,9 @@ function transformExpressionsInOp(op, transform2, flags) {
8092
8049
  if (op.placeholderConfig !== null) {
8093
8050
  op.placeholderConfig = transformExpressionsInExpression(op.placeholderConfig, transform2, flags);
8094
8051
  }
8052
+ if (op.resolverFn !== null) {
8053
+ op.resolverFn = transformExpressionsInExpression(op.resolverFn, transform2, flags);
8054
+ }
8095
8055
  break;
8096
8056
  case OpKind.I18nMessage:
8097
8057
  for (const [placeholder, expr] of op.params) {
@@ -8128,6 +8088,7 @@ function transformExpressionsInOp(op, transform2, flags) {
8128
8088
  case OpKind.Template:
8129
8089
  case OpKind.Text:
8130
8090
  case OpKind.I18nAttributes:
8091
+ case OpKind.IcuPlaceholder:
8131
8092
  break;
8132
8093
  default:
8133
8094
  throw new Error(`AssertionError: transformExpressionsInOp doesn't handle ${OpKind[op.kind]}`);
@@ -8427,7 +8388,7 @@ var elementContainerOpKinds = /* @__PURE__ */ new Set([
8427
8388
  function isElementOrContainerOp(op) {
8428
8389
  return elementContainerOpKinds.has(op.kind);
8429
8390
  }
8430
- function createElementStartOp(tag, xref, namespace, i18nPlaceholder, sourceSpan) {
8391
+ function createElementStartOp(tag, xref, namespace, i18nPlaceholder, startSourceSpan, wholeSourceSpan) {
8431
8392
  return __spreadValues(__spreadValues({
8432
8393
  kind: OpKind.ElementStart,
8433
8394
  xref,
@@ -8438,10 +8399,11 @@ function createElementStartOp(tag, xref, namespace, i18nPlaceholder, sourceSpan)
8438
8399
  nonBindable: false,
8439
8400
  namespace,
8440
8401
  i18nPlaceholder,
8441
- sourceSpan
8402
+ startSourceSpan,
8403
+ wholeSourceSpan
8442
8404
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8443
8405
  }
8444
- function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace, i18nPlaceholder, sourceSpan) {
8406
+ function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace, i18nPlaceholder, startSourceSpan, wholeSourceSpan) {
8445
8407
  return __spreadValues(__spreadValues({
8446
8408
  kind: OpKind.Template,
8447
8409
  xref,
@@ -8456,11 +8418,12 @@ function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace
8456
8418
  nonBindable: false,
8457
8419
  namespace,
8458
8420
  i18nPlaceholder,
8459
- sourceSpan
8421
+ startSourceSpan,
8422
+ wholeSourceSpan
8460
8423
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8461
8424
  }
8462
- function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, sourceSpan) {
8463
- return __spreadProps(__spreadValues(__spreadValues({
8425
+ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, startSourceSpan, wholeSourceSpan) {
8426
+ return __spreadProps(__spreadValues(__spreadValues(__spreadValues({
8464
8427
  kind: OpKind.RepeaterCreate,
8465
8428
  attributes: null,
8466
8429
  xref: primaryView,
@@ -8479,8 +8442,9 @@ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i1
8479
8442
  usesComponentInstance: false,
8480
8443
  i18nPlaceholder,
8481
8444
  emptyI18nPlaceholder,
8482
- sourceSpan
8483
- }, TRAIT_CONSUMES_SLOT), NEW_OP), {
8445
+ startSourceSpan,
8446
+ wholeSourceSpan
8447
+ }, TRAIT_CONSUMES_SLOT), NEW_OP), TRAIT_CONSUMES_VARS), {
8484
8448
  numSlotsUsed: emptyView === null ? 2 : 3
8485
8449
  });
8486
8450
  }
@@ -8503,12 +8467,13 @@ function createEnableBindingsOp(xref) {
8503
8467
  xref
8504
8468
  }, NEW_OP);
8505
8469
  }
8506
- function createTextOp(xref, initialValue, sourceSpan) {
8470
+ function createTextOp(xref, initialValue, icuPlaceholder, sourceSpan) {
8507
8471
  return __spreadValues(__spreadValues({
8508
8472
  kind: OpKind.Text,
8509
8473
  xref,
8510
8474
  handle: new SlotHandle(),
8511
8475
  initialValue,
8476
+ icuPlaceholder,
8512
8477
  sourceSpan
8513
8478
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8514
8479
  }
@@ -8564,11 +8529,12 @@ function createProjectionOp(xref, selector, i18nPlaceholder, attributes, sourceS
8564
8529
  sourceSpan
8565
8530
  }, NEW_OP), TRAIT_CONSUMES_SLOT);
8566
8531
  }
8567
- function createExtractedAttributeOp(target, bindingKind, name, expression, i18nContext, i18nMessage, securityContext) {
8532
+ function createExtractedAttributeOp(target, bindingKind, namespace, name, expression, i18nContext, i18nMessage, securityContext) {
8568
8533
  return __spreadValues({
8569
8534
  kind: OpKind.ExtractedAttribute,
8570
8535
  target,
8571
8536
  bindingKind,
8537
+ namespace,
8572
8538
  name,
8573
8539
  expression,
8574
8540
  i18nContext,
@@ -8659,6 +8625,15 @@ function createIcuEndOp(xref) {
8659
8625
  xref
8660
8626
  }, NEW_OP);
8661
8627
  }
8628
+ function createIcuPlaceholderOp(xref, name, strings) {
8629
+ return __spreadValues({
8630
+ kind: OpKind.IcuPlaceholder,
8631
+ xref,
8632
+ name,
8633
+ strings,
8634
+ expressionPlaceholders: []
8635
+ }, NEW_OP);
8636
+ }
8662
8637
  function createI18nContextOp(contextKind, xref, i18nBlock, message, sourceSpan) {
8663
8638
  if (i18nBlock === null && contextKind !== I18nContextKind.Attr) {
8664
8639
  throw new Error("AssertionError: i18nBlock must be provided for non-attribute contexts.");
@@ -8949,6 +8924,7 @@ function extractAttributes(job) {
8949
8924
  createExtractedAttributeOp(
8950
8925
  op.target,
8951
8926
  bindingKind,
8927
+ null,
8952
8928
  op.name,
8953
8929
  null,
8954
8930
  null,
@@ -8965,6 +8941,7 @@ function extractAttributes(job) {
8965
8941
  OpList.insertBefore(createExtractedAttributeOp(
8966
8942
  op.target,
8967
8943
  BindingKind.Property,
8944
+ null,
8968
8945
  op.name,
8969
8946
  null,
8970
8947
  null,
@@ -8978,6 +8955,7 @@ function extractAttributes(job) {
8978
8955
  const extractedAttributeOp = createExtractedAttributeOp(
8979
8956
  op.target,
8980
8957
  BindingKind.Property,
8958
+ null,
8981
8959
  op.name,
8982
8960
  null,
8983
8961
  null,
@@ -9006,18 +8984,12 @@ function extractAttributeOp(unit, op, elements) {
9006
8984
  if (op.expression instanceof Interpolation2) {
9007
8985
  return;
9008
8986
  }
9009
- let extractable = op.expression.isConstant();
8987
+ let extractable = op.isTextAttribute || op.expression.isConstant();
9010
8988
  if (unit.job.compatibility === CompatibilityMode.TemplateDefinitionBuilder) {
9011
- extractable = isStringLiteral(op.expression);
9012
- if (op.name === "style" || op.name === "class") {
9013
- extractable && (extractable = op.isTextAttribute);
9014
- }
9015
- if (unit.job.kind === CompilationJobKind.Host) {
9016
- extractable && (extractable = op.isTextAttribute);
9017
- }
8989
+ extractable && (extractable = op.isTextAttribute);
9018
8990
  }
9019
8991
  if (extractable) {
9020
- const extractedAttributeOp = createExtractedAttributeOp(op.target, op.isStructuralTemplateAttribute ? BindingKind.Template : BindingKind.Attribute, op.name, op.expression, op.i18nContext, op.i18nMessage, op.securityContext);
8992
+ const extractedAttributeOp = createExtractedAttributeOp(op.target, op.isStructuralTemplateAttribute ? BindingKind.Template : BindingKind.Attribute, op.namespace, op.name, op.expression, op.i18nContext, op.i18nMessage, op.securityContext);
9021
8993
  if (unit.job.kind === CompilationJobKind.Host) {
9022
8994
  unit.create.push(extractedAttributeOp);
9023
8995
  } else {
@@ -9058,7 +9030,8 @@ function specializeBindings(job) {
9058
9030
  const target = lookupElement2(elements, op.target);
9059
9031
  target.nonBindable = true;
9060
9032
  } else {
9061
- OpList.replace(op, createAttributeOp(op.target, op.name, op.expression, op.securityContext, op.isTextAttribute, op.isStructuralTemplateAttribute, op.templateKind, op.i18nMessage, op.sourceSpan));
9033
+ const [namespace, name] = splitNsName(op.name);
9034
+ OpList.replace(op, createAttributeOp(op.target, namespace, name, op.expression, op.securityContext, op.isTextAttribute, op.isStructuralTemplateAttribute, op.templateKind, op.i18nMessage, op.sourceSpan));
9062
9035
  }
9063
9036
  break;
9064
9037
  case BindingKind.Property:
@@ -9249,9 +9222,9 @@ function collectElementConsts(job) {
9249
9222
  for (const unit of job.units) {
9250
9223
  for (const op of unit.create) {
9251
9224
  if (op.kind === OpKind.ExtractedAttribute) {
9252
- const attributes = allElementAttributes.get(op.target) || new ElementAttributes();
9225
+ const attributes = allElementAttributes.get(op.target) || new ElementAttributes(job.compatibility);
9253
9226
  allElementAttributes.set(op.target, attributes);
9254
- attributes.add(op.bindingKind, op.name, op.expression, op.trustedValueFn);
9227
+ attributes.add(op.bindingKind, op.name, op.expression, op.namespace, op.trustedValueFn);
9255
9228
  OpList.remove(op);
9256
9229
  }
9257
9230
  }
@@ -9284,11 +9257,6 @@ function collectElementConsts(job) {
9284
9257
  }
9285
9258
  var FLYWEIGHT_ARRAY = Object.freeze([]);
9286
9259
  var ElementAttributes = class {
9287
- constructor() {
9288
- this.known = /* @__PURE__ */ new Set();
9289
- this.byKind = /* @__PURE__ */ new Map();
9290
- this.projectAs = null;
9291
- }
9292
9260
  get attributes() {
9293
9261
  var _a2;
9294
9262
  return (_a2 = this.byKind.get(BindingKind.Attribute)) != null ? _a2 : FLYWEIGHT_ARRAY;
@@ -9313,12 +9281,28 @@ var ElementAttributes = class {
9313
9281
  var _a2;
9314
9282
  return (_a2 = this.byKind.get(BindingKind.I18n)) != null ? _a2 : FLYWEIGHT_ARRAY;
9315
9283
  }
9316
- add(kind, name, value, trustedValueFn) {
9284
+ constructor(compatibility) {
9285
+ this.compatibility = compatibility;
9286
+ this.known = /* @__PURE__ */ new Map();
9287
+ this.byKind = /* @__PURE__ */ new Map();
9288
+ this.projectAs = null;
9289
+ }
9290
+ isKnown(kind, name, value) {
9317
9291
  var _a2;
9318
- if (this.known.has(name)) {
9292
+ const nameToValue = (_a2 = this.known.get(kind)) != null ? _a2 : /* @__PURE__ */ new Set();
9293
+ this.known.set(kind, nameToValue);
9294
+ if (nameToValue.has(name)) {
9295
+ return true;
9296
+ }
9297
+ nameToValue.add(name);
9298
+ return false;
9299
+ }
9300
+ add(kind, name, value, namespace, trustedValueFn) {
9301
+ var _a2;
9302
+ const allowDuplicates = this.compatibility === CompatibilityMode.TemplateDefinitionBuilder && (kind === BindingKind.Attribute || kind === BindingKind.ClassName || kind === BindingKind.StyleProperty);
9303
+ if (!allowDuplicates && this.isKnown(kind, name, value)) {
9319
9304
  return;
9320
9305
  }
9321
- this.known.add(name);
9322
9306
  if (name === "ngProjectAs") {
9323
9307
  if (value === null || !(value instanceof LiteralExpr) || value.value == null || typeof ((_a2 = value.value) == null ? void 0 : _a2.toString()) !== "string") {
9324
9308
  throw Error("ngProjectAs must have a string literal value");
@@ -9326,7 +9310,7 @@ var ElementAttributes = class {
9326
9310
  this.projectAs = value.value.toString();
9327
9311
  }
9328
9312
  const array = this.arrayFor(kind);
9329
- array.push(...getAttributeNameLiterals(name));
9313
+ array.push(...getAttributeNameLiterals(namespace, name));
9330
9314
  if (kind === BindingKind.Attribute || kind === BindingKind.StyleProperty) {
9331
9315
  if (value === null) {
9332
9316
  throw Error("Attribute, i18n attribute, & style element attributes must have a value");
@@ -9348,15 +9332,10 @@ var ElementAttributes = class {
9348
9332
  return this.byKind.get(kind);
9349
9333
  }
9350
9334
  };
9351
- function getAttributeNameLiterals(name) {
9352
- const [attributeNamespace, attributeName] = splitNsName(name);
9353
- const nameLiteral = literal(attributeName);
9354
- if (attributeNamespace) {
9355
- return [
9356
- literal(0),
9357
- literal(attributeNamespace),
9358
- nameLiteral
9359
- ];
9335
+ function getAttributeNameLiterals(namespace, name) {
9336
+ const nameLiteral = literal(name);
9337
+ if (namespace) {
9338
+ return [literal(0), literal(namespace), nameLiteral];
9360
9339
  }
9361
9340
  return [nameLiteral];
9362
9341
  }
@@ -9416,7 +9395,7 @@ function convertI18nBindings(job) {
9416
9395
  if (op.expression.i18nPlaceholders.length !== op.expression.expressions.length) {
9417
9396
  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`);
9418
9397
  }
9419
- ops.push(createI18nExpressionOp(op.i18nContext, i18nAttributesForElem.target, i18nAttributesForElem.xref, i18nAttributesForElem.handle, expr, op.expression.i18nPlaceholders[i], I18nParamResolutionTime.Creation, I18nExpressionFor.I18nAttribute, op.name, op.sourceSpan));
9398
+ 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));
9420
9399
  }
9421
9400
  OpList.replaceWithMany(op, ops);
9422
9401
  break;
@@ -9447,7 +9426,11 @@ function createDeferDepsFns(job) {
9447
9426
  if (op.handle.slot === null) {
9448
9427
  throw new Error("AssertionError: slot must be assigned bfore extracting defer deps functions");
9449
9428
  }
9450
- op.resolverFn = job.pool.getSharedFunctionReference(depsFnExpr, `${job.componentName}_Defer_${op.handle.slot}_DepsFn`);
9429
+ op.resolverFn = job.pool.getSharedFunctionReference(
9430
+ depsFnExpr,
9431
+ `${job.componentName}_Defer_${op.handle.slot}_DepsFn`,
9432
+ false
9433
+ );
9451
9434
  }
9452
9435
  }
9453
9436
  }
@@ -9455,62 +9438,99 @@ function createDeferDepsFns(job) {
9455
9438
 
9456
9439
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/create_i18n_contexts.mjs
9457
9440
  function createI18nContexts(job) {
9458
- const rootContexts = /* @__PURE__ */ new Map();
9459
- let currentI18nOp = null;
9460
- let xref;
9461
- const messageToContext = /* @__PURE__ */ new Map();
9441
+ const attrContextByMessage = /* @__PURE__ */ new Map();
9442
+ for (const unit of job.units) {
9443
+ for (const op of unit.ops()) {
9444
+ switch (op.kind) {
9445
+ case OpKind.Binding:
9446
+ case OpKind.Property:
9447
+ case OpKind.Attribute:
9448
+ case OpKind.ExtractedAttribute:
9449
+ if (op.i18nMessage === null) {
9450
+ continue;
9451
+ }
9452
+ if (!attrContextByMessage.has(op.i18nMessage)) {
9453
+ const i18nContext = createI18nContextOp(I18nContextKind.Attr, job.allocateXrefId(), null, op.i18nMessage, null);
9454
+ unit.create.push(i18nContext);
9455
+ attrContextByMessage.set(op.i18nMessage, i18nContext.xref);
9456
+ }
9457
+ op.i18nContext = attrContextByMessage.get(op.i18nMessage);
9458
+ break;
9459
+ }
9460
+ }
9461
+ }
9462
+ const blockContextByI18nBlock = /* @__PURE__ */ new Map();
9462
9463
  for (const unit of job.units) {
9463
9464
  for (const op of unit.create) {
9464
9465
  switch (op.kind) {
9465
9466
  case OpKind.I18nStart:
9466
- currentI18nOp = op;
9467
9467
  if (op.xref === op.root) {
9468
- xref = job.allocateXrefId();
9469
- unit.create.push(createI18nContextOp(I18nContextKind.RootI18n, xref, op.xref, op.message, null));
9470
- op.context = xref;
9471
- rootContexts.set(op.xref, xref);
9468
+ const contextOp = createI18nContextOp(I18nContextKind.RootI18n, job.allocateXrefId(), op.xref, op.message, null);
9469
+ unit.create.push(contextOp);
9470
+ op.context = contextOp.xref;
9471
+ blockContextByI18nBlock.set(op.xref, contextOp);
9472
9472
  }
9473
9473
  break;
9474
+ }
9475
+ }
9476
+ }
9477
+ for (const unit of job.units) {
9478
+ for (const op of unit.create) {
9479
+ if (op.kind === OpKind.I18nStart && op.xref !== op.root) {
9480
+ const rootContext = blockContextByI18nBlock.get(op.root);
9481
+ if (rootContext === void 0) {
9482
+ throw Error("AssertionError: Root i18n block i18n context should have been created.");
9483
+ }
9484
+ op.context = rootContext.xref;
9485
+ blockContextByI18nBlock.set(op.xref, rootContext);
9486
+ }
9487
+ }
9488
+ }
9489
+ let currentI18nOp = null;
9490
+ for (const unit of job.units) {
9491
+ for (const op of unit.create) {
9492
+ switch (op.kind) {
9493
+ case OpKind.I18nStart:
9494
+ currentI18nOp = op;
9495
+ break;
9474
9496
  case OpKind.I18nEnd:
9475
9497
  currentI18nOp = null;
9476
9498
  break;
9477
9499
  case OpKind.IcuStart:
9478
9500
  if (currentI18nOp === null) {
9479
- throw Error("Unexpected ICU outside of an i18n block.");
9501
+ throw Error("AssertionError: Unexpected ICU outside of an i18n block.");
9480
9502
  }
9481
9503
  if (op.message.id !== currentI18nOp.message.id) {
9482
- xref = job.allocateXrefId();
9483
- unit.create.push(createI18nContextOp(I18nContextKind.Icu, xref, currentI18nOp.xref, op.message, null));
9484
- op.context = xref;
9504
+ const contextOp = createI18nContextOp(I18nContextKind.Icu, job.allocateXrefId(), currentI18nOp.xref, op.message, null);
9505
+ unit.create.push(contextOp);
9506
+ op.context = contextOp.xref;
9485
9507
  } else {
9486
9508
  op.context = currentI18nOp.context;
9509
+ blockContextByI18nBlock.get(currentI18nOp.xref).contextKind = I18nContextKind.Icu;
9487
9510
  }
9488
9511
  break;
9489
9512
  }
9490
9513
  }
9491
- for (const op of unit.ops()) {
9492
- switch (op.kind) {
9493
- case OpKind.Binding:
9494
- case OpKind.Property:
9495
- case OpKind.Attribute:
9496
- case OpKind.ExtractedAttribute:
9497
- if (!op.i18nMessage) {
9498
- continue;
9499
- }
9500
- if (!messageToContext.has(op.i18nMessage)) {
9501
- const i18nContext = job.allocateXrefId();
9502
- unit.create.push(createI18nContextOp(I18nContextKind.Attr, i18nContext, null, op.i18nMessage, null));
9503
- messageToContext.set(op.i18nMessage, i18nContext);
9504
- }
9505
- op.i18nContext = messageToContext.get(op.i18nMessage);
9506
- break;
9507
- }
9508
- }
9509
9514
  }
9515
+ }
9516
+
9517
+ // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/deduplicate_text_bindings.mjs
9518
+ function deduplicateTextBindings(job) {
9519
+ const seen = /* @__PURE__ */ new Map();
9510
9520
  for (const unit of job.units) {
9511
- for (const op of unit.create) {
9512
- if (op.kind === OpKind.I18nStart && op.xref !== op.root) {
9513
- op.context = rootContexts.get(op.root);
9521
+ for (const op of unit.update.reversed()) {
9522
+ if (op.kind === OpKind.Binding && op.isTextAttribute) {
9523
+ const seenForElement = seen.get(op.target) || /* @__PURE__ */ new Set();
9524
+ if (seenForElement.has(op.name)) {
9525
+ if (job.compatibility === CompatibilityMode.TemplateDefinitionBuilder) {
9526
+ if (op.name === "style" || op.name === "class") {
9527
+ OpList.remove(op);
9528
+ }
9529
+ } else {
9530
+ }
9531
+ }
9532
+ seenForElement.add(op.name);
9533
+ seen.set(op.target, seenForElement);
9514
9534
  }
9515
9535
  }
9516
9536
  }
@@ -9800,12 +9820,16 @@ var LIST_START_MARKER = "[";
9800
9820
  var LIST_END_MARKER = "]";
9801
9821
  var LIST_DELIMITER = "|";
9802
9822
  function extractI18nMessages(job) {
9803
- const i18nContexts = /* @__PURE__ */ new Map();
9823
+ const i18nMessagesByContext = /* @__PURE__ */ new Map();
9804
9824
  const i18nBlocks = /* @__PURE__ */ new Map();
9825
+ const i18nContexts = /* @__PURE__ */ new Map();
9805
9826
  for (const unit of job.units) {
9806
9827
  for (const op of unit.create) {
9807
9828
  switch (op.kind) {
9808
9829
  case OpKind.I18nContext:
9830
+ const i18nMessageOp = createI18nMessage(job, op);
9831
+ unit.create.push(i18nMessageOp);
9832
+ i18nMessagesByContext.set(op.xref, i18nMessageOp);
9809
9833
  i18nContexts.set(op.xref, op);
9810
9834
  break;
9811
9835
  case OpKind.I18nStart:
@@ -9814,49 +9838,40 @@ function extractI18nMessages(job) {
9814
9838
  }
9815
9839
  }
9816
9840
  }
9817
- for (const unit of job.units) {
9818
- for (const op of unit.create) {
9819
- if (op.kind !== OpKind.I18nContext || op.contextKind !== I18nContextKind.Attr) {
9820
- continue;
9821
- }
9822
- const i18nMessageOp = createI18nMessage(job, op);
9823
- unit.create.push(i18nMessageOp);
9824
- }
9825
- }
9826
- const i18nBlockMessages = /* @__PURE__ */ new Map();
9827
- for (const unit of job.units) {
9828
- for (const op of unit.create) {
9829
- if (op.kind === OpKind.I18nStart && op.xref === op.root) {
9830
- if (!op.context) {
9831
- throw Error("I18n start op should have its context set.");
9832
- }
9833
- const i18nMessageOp = createI18nMessage(job, i18nContexts.get(op.context));
9834
- i18nBlockMessages.set(op.xref, i18nMessageOp);
9835
- unit.create.push(i18nMessageOp);
9836
- }
9837
- }
9838
- }
9841
+ let currentIcu = null;
9839
9842
  for (const unit of job.units) {
9840
9843
  for (const op of unit.create) {
9841
9844
  switch (op.kind) {
9842
9845
  case OpKind.IcuStart:
9843
- if (!op.context) {
9844
- throw Error("ICU op should have its context set.");
9846
+ currentIcu = op;
9847
+ OpList.remove(op);
9848
+ const icuContext = i18nContexts.get(op.context);
9849
+ if (icuContext.contextKind !== I18nContextKind.Icu) {
9850
+ continue;
9845
9851
  }
9846
- const i18nContext = i18nContexts.get(op.context);
9847
- if (i18nContext.contextKind === I18nContextKind.Icu) {
9848
- if (i18nContext.i18nBlock === null) {
9849
- throw Error("ICU context should have its i18n block set.");
9850
- }
9851
- const subMessage = createI18nMessage(job, i18nContext, op.messagePlaceholder);
9852
- unit.create.push(subMessage);
9853
- const rootI18nId = i18nBlocks.get(i18nContext.i18nBlock).root;
9854
- const parentMessage = i18nBlockMessages.get(rootI18nId);
9855
- parentMessage == null ? void 0 : parentMessage.subMessages.push(subMessage.xref);
9852
+ const i18nBlock = i18nBlocks.get(icuContext.i18nBlock);
9853
+ if (i18nBlock.context === icuContext.xref) {
9854
+ continue;
9856
9855
  }
9857
- OpList.remove(op);
9856
+ const rootI18nBlock = i18nBlocks.get(i18nBlock.root);
9857
+ const rootMessage = i18nMessagesByContext.get(rootI18nBlock.context);
9858
+ if (rootMessage === void 0) {
9859
+ throw Error("AssertionError: ICU sub-message should belong to a root message.");
9860
+ }
9861
+ const subMessage = i18nMessagesByContext.get(icuContext.xref);
9862
+ subMessage.messagePlaceholder = op.messagePlaceholder;
9863
+ rootMessage.subMessages.push(subMessage.xref);
9858
9864
  break;
9859
9865
  case OpKind.IcuEnd:
9866
+ currentIcu = null;
9867
+ OpList.remove(op);
9868
+ break;
9869
+ case OpKind.IcuPlaceholder:
9870
+ if (currentIcu === null || currentIcu.context == null) {
9871
+ throw Error("AssertionError: Unexpected ICU placeholder outside of i18n context");
9872
+ }
9873
+ const msg = i18nMessagesByContext.get(currentIcu.context);
9874
+ msg.postprocessingParams.set(op.name, literal(formatIcuPlaceholder(op)));
9860
9875
  OpList.remove(op);
9861
9876
  break;
9862
9877
  }
@@ -9866,14 +9881,16 @@ function extractI18nMessages(job) {
9866
9881
  function createI18nMessage(job, context, messagePlaceholder) {
9867
9882
  let formattedParams = formatParams(context.params);
9868
9883
  const formattedPostprocessingParams = formatParams(context.postprocessingParams);
9869
- let needsPostprocessing = formattedPostprocessingParams.size > 0;
9870
- for (const values of context.params.values()) {
9871
- if (values.length > 1) {
9872
- needsPostprocessing = true;
9873
- }
9874
- }
9884
+ let needsPostprocessing = [...context.params.values()].some((v) => v.length > 1);
9875
9885
  return createI18nMessageOp(job.allocateXrefId(), context.xref, context.i18nBlock, context.message, messagePlaceholder != null ? messagePlaceholder : null, formattedParams, formattedPostprocessingParams, needsPostprocessing);
9876
9886
  }
9887
+ function formatIcuPlaceholder(op) {
9888
+ if (op.strings.length !== op.expressionPlaceholders.length + 1) {
9889
+ throw Error(`AsserionError: Invalid ICU placeholder with ${op.strings.length} strings and ${op.expressionPlaceholders.length} expressions`);
9890
+ }
9891
+ const values = op.expressionPlaceholders.map(formatValue);
9892
+ return op.strings.flatMap((str, i) => [str, values[i] || ""]).join("");
9893
+ }
9877
9894
  function formatParams(params) {
9878
9895
  const formattedParams = /* @__PURE__ */ new Map();
9879
9896
  for (const [placeholder, placeholderValues] of params) {
@@ -10100,7 +10117,7 @@ var CLASS_BANG = "class!";
10100
10117
  var BANG_IMPORTANT = "!important";
10101
10118
  function parseHostStyleProperties(job) {
10102
10119
  for (const op of job.root.update) {
10103
- if (op.kind !== OpKind.Binding) {
10120
+ if (!(op.kind === OpKind.Binding && op.bindingKind === BindingKind.Property)) {
10104
10121
  continue;
10105
10122
  }
10106
10123
  if (op.name.endsWith(BANG_IMPORTANT)) {
@@ -10109,7 +10126,7 @@ function parseHostStyleProperties(job) {
10109
10126
  if (op.name.startsWith(STYLE_DOT)) {
10110
10127
  op.bindingKind = BindingKind.StyleProperty;
10111
10128
  op.name = op.name.substring(STYLE_DOT.length);
10112
- if (isCssCustomProperty(op.name)) {
10129
+ if (!isCssCustomProperty(op.name)) {
10113
10130
  op.name = hyphenate(op.name);
10114
10131
  }
10115
10132
  const { property: property2, suffix } = parseProperty(op.name);
@@ -16242,7 +16259,7 @@ function collectMessage(job, fileBasedI18nSuffix, messages, messageOp) {
16242
16259
  const mainVar = variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX2));
16243
16260
  const closureVar = i18nGenerateClosureVar(job.pool, messageOp.message.id, fileBasedI18nSuffix, job.i18nUseExternalIds);
16244
16261
  let transformFn = void 0;
16245
- if (messageOp.needsPostprocessing) {
16262
+ if (messageOp.needsPostprocessing || messageOp.postprocessingParams.size > 0) {
16246
16263
  const postprocessingParams = Object.fromEntries([...messageOp.postprocessingParams.entries()].sort());
16247
16264
  const formattedPostprocessingParams = formatI18nPlaceholderNamesInMap(postprocessingParams, false);
16248
16265
  const extraTransformFnParams = [];
@@ -16261,7 +16278,6 @@ function addSubMessageParams(messageOp, subMessagePlaceholders) {
16261
16278
  } else {
16262
16279
  messageOp.params.set(placeholder, literal(`${ESCAPE2}${I18N_ICU_MAPPING_PREFIX2}${placeholder}${ESCAPE2}`));
16263
16280
  messageOp.postprocessingParams.set(placeholder, literalArr(subMessages));
16264
- messageOp.needsPostprocessing = true;
16265
16281
  }
16266
16282
  }
16267
16283
  }
@@ -16295,12 +16311,13 @@ function i18nGenerateClosureVar(pool, messageId, fileBasedI18nSuffix, useExterna
16295
16311
 
16296
16312
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/i18n_text_extraction.mjs
16297
16313
  function convertI18nText(job) {
16298
- var _a2;
16314
+ var _a2, _b2, _c2;
16299
16315
  for (const unit of job.units) {
16300
16316
  let currentI18n = null;
16301
16317
  let currentIcu = null;
16302
16318
  const textNodeI18nBlocks = /* @__PURE__ */ new Map();
16303
16319
  const textNodeIcus = /* @__PURE__ */ new Map();
16320
+ const icuPlaceholderByText = /* @__PURE__ */ new Map();
16304
16321
  for (const op of unit.create) {
16305
16322
  switch (op.kind) {
16306
16323
  case OpKind.I18nStart:
@@ -16325,7 +16342,13 @@ function convertI18nText(job) {
16325
16342
  if (currentI18n !== null) {
16326
16343
  textNodeI18nBlocks.set(op.xref, currentI18n);
16327
16344
  textNodeIcus.set(op.xref, currentIcu);
16328
- OpList.remove(op);
16345
+ if (op.icuPlaceholder !== null) {
16346
+ const icuPlaceholderOp = createIcuPlaceholderOp(job.allocateXrefId(), op.icuPlaceholder, [op.initialValue]);
16347
+ OpList.replace(op, icuPlaceholderOp);
16348
+ icuPlaceholderByText.set(op.xref, icuPlaceholderOp);
16349
+ } else {
16350
+ OpList.remove(op);
16351
+ }
16329
16352
  }
16330
16353
  break;
16331
16354
  }
@@ -16338,14 +16361,18 @@ function convertI18nText(job) {
16338
16361
  }
16339
16362
  const i18nOp = textNodeI18nBlocks.get(op.target);
16340
16363
  const icuOp = textNodeIcus.get(op.target);
16364
+ const icuPlaceholder = icuPlaceholderByText.get(op.target);
16341
16365
  const contextId = icuOp ? icuOp.context : i18nOp.context;
16342
16366
  const resolutionTime = icuOp ? I18nParamResolutionTime.Postproccessing : I18nParamResolutionTime.Creation;
16343
16367
  const ops = [];
16344
16368
  for (let i = 0; i < op.interpolation.expressions.length; i++) {
16345
16369
  const expr = op.interpolation.expressions[i];
16346
- 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));
16370
+ 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));
16347
16371
  }
16348
16372
  OpList.replaceWithMany(op, ops);
16373
+ if (icuPlaceholder !== void 0) {
16374
+ icuPlaceholder.strings = op.interpolation.strings;
16375
+ }
16349
16376
  break;
16350
16377
  }
16351
16378
  }
@@ -16759,19 +16786,31 @@ function keepLast(ops) {
16759
16786
 
16760
16787
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/parse_extracted_styles.mjs
16761
16788
  function parseExtractedStyles(job) {
16789
+ const elements = /* @__PURE__ */ new Map();
16790
+ for (const unit of job.units) {
16791
+ for (const op of unit.create) {
16792
+ if (isElementOrContainerOp(op)) {
16793
+ elements.set(op.xref, op);
16794
+ }
16795
+ }
16796
+ }
16762
16797
  for (const unit of job.units) {
16763
16798
  for (const op of unit.create) {
16764
16799
  if (op.kind === OpKind.ExtractedAttribute && op.bindingKind === BindingKind.Attribute && isStringLiteral(op.expression)) {
16800
+ const target = elements.get(op.target);
16801
+ if (target !== void 0 && target.kind === OpKind.Template && target.templateKind === TemplateKind.Structural) {
16802
+ continue;
16803
+ }
16765
16804
  if (op.name === "style") {
16766
16805
  const parsedStyles = parse(op.expression.value);
16767
16806
  for (let i = 0; i < parsedStyles.length - 1; i += 2) {
16768
- OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.StyleProperty, parsedStyles[i], literal(parsedStyles[i + 1]), null, null, SecurityContext.STYLE), op);
16807
+ OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.StyleProperty, null, parsedStyles[i], literal(parsedStyles[i + 1]), null, null, SecurityContext.STYLE), op);
16769
16808
  }
16770
16809
  OpList.remove(op);
16771
16810
  } else if (op.name === "class") {
16772
16811
  const parsedClasses = op.expression.value.trim().split(/\s+/g);
16773
16812
  for (const parsedClass of parsedClasses) {
16774
- OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.ClassName, parsedClass, null, null, null, SecurityContext.NONE), op);
16813
+ OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.ClassName, null, parsedClass, null, null, null, SecurityContext.NONE), op);
16775
16814
  }
16776
16815
  OpList.remove(op);
16777
16816
  }
@@ -17101,9 +17140,7 @@ function namespaceMath() {
17101
17140
  return call(Identifiers.namespaceMathML, [], null);
17102
17141
  }
17103
17142
  function advance(delta, sourceSpan) {
17104
- return call(Identifiers.advance, [
17105
- literal(delta)
17106
- ], sourceSpan);
17143
+ return call(Identifiers.advance, delta > 1 ? [literal(delta)] : [], sourceSpan);
17107
17144
  }
17108
17145
  function reference(slot) {
17109
17146
  return importExpr(Identifiers.reference).callFn([
@@ -17241,10 +17278,13 @@ function property(name, expression, sanitizer, sourceSpan) {
17241
17278
  }
17242
17279
  return call(Identifiers.property, args, sourceSpan);
17243
17280
  }
17244
- function attribute(name, expression, sanitizer) {
17281
+ function attribute(name, expression, sanitizer, namespace) {
17245
17282
  const args = [literal(name), expression];
17246
- if (sanitizer !== null) {
17247
- args.push(sanitizer);
17283
+ if (sanitizer !== null || namespace !== null) {
17284
+ args.push(sanitizer != null ? sanitizer : literal(null));
17285
+ }
17286
+ if (namespace !== null) {
17287
+ args.push(literal(namespace));
17248
17288
  }
17249
17289
  return call(Identifiers.attribute, args, null);
17250
17290
  }
@@ -17555,19 +17595,19 @@ function reifyCreateOperations(unit, ops) {
17555
17595
  OpList.replace(op, text(op.handle.slot, op.initialValue, op.sourceSpan));
17556
17596
  break;
17557
17597
  case OpKind.ElementStart:
17558
- OpList.replace(op, elementStart(op.handle.slot, op.tag, op.attributes, op.localRefs, op.sourceSpan));
17598
+ OpList.replace(op, elementStart(op.handle.slot, op.tag, op.attributes, op.localRefs, op.startSourceSpan));
17559
17599
  break;
17560
17600
  case OpKind.Element:
17561
- OpList.replace(op, element(op.handle.slot, op.tag, op.attributes, op.localRefs, op.sourceSpan));
17601
+ OpList.replace(op, element(op.handle.slot, op.tag, op.attributes, op.localRefs, op.wholeSourceSpan));
17562
17602
  break;
17563
17603
  case OpKind.ElementEnd:
17564
17604
  OpList.replace(op, elementEnd(op.sourceSpan));
17565
17605
  break;
17566
17606
  case OpKind.ContainerStart:
17567
- OpList.replace(op, elementContainerStart(op.handle.slot, op.attributes, op.localRefs, op.sourceSpan));
17607
+ OpList.replace(op, elementContainerStart(op.handle.slot, op.attributes, op.localRefs, op.startSourceSpan));
17568
17608
  break;
17569
17609
  case OpKind.Container:
17570
- OpList.replace(op, elementContainer(op.handle.slot, op.attributes, op.localRefs, op.sourceSpan));
17610
+ OpList.replace(op, elementContainer(op.handle.slot, op.attributes, op.localRefs, op.wholeSourceSpan));
17571
17611
  break;
17572
17612
  case OpKind.ContainerEnd:
17573
17613
  OpList.replace(op, elementContainerEnd());
@@ -17595,7 +17635,7 @@ function reifyCreateOperations(unit, ops) {
17595
17635
  throw new Error(`AssertionError: local refs array should have been extracted into a constant`);
17596
17636
  }
17597
17637
  const childView = unit.job.views.get(op.xref);
17598
- OpList.replace(op, template(op.handle.slot, variable(childView.fnName), childView.decls, childView.vars, op.tag, op.attributes, op.localRefs, op.sourceSpan));
17638
+ OpList.replace(op, template(op.handle.slot, variable(childView.fnName), childView.decls, childView.vars, op.tag, op.attributes, op.localRefs, op.startSourceSpan));
17599
17639
  break;
17600
17640
  case OpKind.DisableBindings:
17601
17641
  OpList.replace(op, disableBindings2());
@@ -17610,7 +17650,7 @@ function reifyCreateOperations(unit, ops) {
17610
17650
  const listenerFn = reifyListenerHandler(unit, op.handlerFnName, op.handlerOps, op.consumesDollarEvent);
17611
17651
  const eventTargetResolver = op.eventTarget ? GLOBAL_TARGET_RESOLVERS.get(op.eventTarget) : null;
17612
17652
  if (eventTargetResolver === void 0) {
17613
- throw new Error(`AssertionError: unknown event target ${op.eventTarget}`);
17653
+ throw new Error(`Unexpected global target '${op.eventTarget}' defined for '${op.name}' event. Supported list of global targets: window,document,body.`);
17614
17654
  }
17615
17655
  OpList.replace(op, listener(op.name, listenerFn, eventTargetResolver, op.hostListener && op.isAnimationListener, op.sourceSpan));
17616
17656
  break;
@@ -17697,7 +17737,7 @@ function reifyCreateOperations(unit, ops) {
17697
17737
  emptyDecls = emptyView.decls;
17698
17738
  emptyVars = emptyView.vars;
17699
17739
  }
17700
- 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));
17740
+ 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.wholeSourceSpan));
17701
17741
  break;
17702
17742
  case OpKind.Statement:
17703
17743
  break;
@@ -17757,7 +17797,7 @@ function reifyUpdateOperations(_unit, ops) {
17757
17797
  if (op.expression instanceof Interpolation2) {
17758
17798
  OpList.replace(op, attributeInterpolate(op.name, op.expression.strings, op.expression.expressions, op.sanitizer, op.sourceSpan));
17759
17799
  } else {
17760
- OpList.replace(op, attribute(op.name, op.expression, op.sanitizer));
17800
+ OpList.replace(op, attribute(op.name, op.expression, op.sanitizer, op.namespace));
17761
17801
  }
17762
17802
  break;
17763
17803
  case OpKind.HostProperty:
@@ -17926,38 +17966,6 @@ function removeUnusedI18nAttributesOps(job) {
17926
17966
  }
17927
17967
  }
17928
17968
 
17929
- // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/repeater_derived_vars.mjs
17930
- function generateRepeaterDerivedVars(job) {
17931
- const repeaters = /* @__PURE__ */ new Map();
17932
- for (const unit of job.units) {
17933
- for (const op of unit.ops()) {
17934
- if (op.kind === OpKind.RepeaterCreate) {
17935
- repeaters.set(op.xref, op);
17936
- }
17937
- }
17938
- }
17939
- for (const unit of job.units) {
17940
- for (const op of unit.ops()) {
17941
- transformExpressionsInOp(op, (expr) => {
17942
- if (!(expr instanceof DerivedRepeaterVarExpr)) {
17943
- return expr;
17944
- }
17945
- const repeaterOp = repeaters.get(expr.xref);
17946
- switch (expr.identity) {
17947
- case DerivedRepeaterVarIdentity.First:
17948
- return new BinaryOperatorExpr(BinaryOperator.Identical, new LexicalReadExpr(repeaterOp.varNames.$index), literal(0));
17949
- case DerivedRepeaterVarIdentity.Last:
17950
- return new BinaryOperatorExpr(BinaryOperator.Identical, new LexicalReadExpr(repeaterOp.varNames.$index), new BinaryOperatorExpr(BinaryOperator.Minus, new LexicalReadExpr(repeaterOp.varNames.$count), literal(1)));
17951
- case DerivedRepeaterVarIdentity.Even:
17952
- return new BinaryOperatorExpr(BinaryOperator.Identical, new BinaryOperatorExpr(BinaryOperator.Modulo, new LexicalReadExpr(repeaterOp.varNames.$index), literal(2)), literal(0));
17953
- case DerivedRepeaterVarIdentity.Odd:
17954
- return new BinaryOperatorExpr(BinaryOperator.NotIdentical, new BinaryOperatorExpr(BinaryOperator.Modulo, new LexicalReadExpr(repeaterOp.varNames.$index), literal(2)), literal(0));
17955
- }
17956
- }, VisitorContextFlag.None);
17957
- }
17958
- }
17959
- }
17960
-
17961
17969
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_contexts.mjs
17962
17970
  function resolveContexts(job) {
17963
17971
  for (const unit of job.units) {
@@ -18204,6 +18212,7 @@ function resolveI18nExpressionPlaceholders(job) {
18204
18212
  var _a2;
18205
18213
  const subTemplateIndicies = /* @__PURE__ */ new Map();
18206
18214
  const i18nContexts = /* @__PURE__ */ new Map();
18215
+ const icuPlaceholders = /* @__PURE__ */ new Map();
18207
18216
  for (const unit of job.units) {
18208
18217
  for (const op of unit.create) {
18209
18218
  switch (op.kind) {
@@ -18213,6 +18222,9 @@ function resolveI18nExpressionPlaceholders(job) {
18213
18222
  case OpKind.I18nContext:
18214
18223
  i18nContexts.set(op.xref, op);
18215
18224
  break;
18225
+ case OpKind.IcuPlaceholder:
18226
+ icuPlaceholders.set(op.xref, op);
18227
+ break;
18216
18228
  }
18217
18229
  }
18218
18230
  }
@@ -18221,66 +18233,32 @@ function resolveI18nExpressionPlaceholders(job) {
18221
18233
  for (const unit of job.units) {
18222
18234
  for (const op of unit.update) {
18223
18235
  if (op.kind === OpKind.I18nExpression) {
18224
- const i18nContext = i18nContexts.get(op.context);
18225
18236
  const index = expressionIndices.get(referenceIndex(op)) || 0;
18226
18237
  const subTemplateIndex = (_a2 = subTemplateIndicies.get(op.i18nOwner)) != null ? _a2 : null;
18227
- const params = op.resolutionTime === I18nParamResolutionTime.Creation ? i18nContext.params : i18nContext.postprocessingParams;
18228
- const values = params.get(op.i18nPlaceholder) || [];
18229
- values.push({
18238
+ const value = {
18230
18239
  value: index,
18231
18240
  subTemplateIndex,
18232
18241
  flags: I18nParamValueFlags.ExpressionIndex
18233
- });
18234
- params.set(op.i18nPlaceholder, values);
18242
+ };
18243
+ updatePlaceholder(op, value, i18nContexts, icuPlaceholders);
18235
18244
  expressionIndices.set(referenceIndex(op), index + 1);
18236
18245
  }
18237
18246
  }
18238
18247
  }
18239
18248
  }
18240
-
18241
- // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_i18n_icu_placeholders.mjs
18242
- function resolveI18nIcuPlaceholders(job) {
18243
- for (const unit of job.units) {
18244
- for (const op of unit.create) {
18245
- if (op.kind === OpKind.I18nContext && op.contextKind === I18nContextKind.Icu) {
18246
- for (const node of op.message.nodes) {
18247
- node.visit(new ResolveIcuPlaceholdersVisitor(op.postprocessingParams));
18248
- }
18249
- }
18250
- }
18251
- }
18252
- }
18253
- var ResolveIcuPlaceholdersVisitor = class extends RecurseVisitor {
18254
- constructor(params) {
18255
- super();
18256
- this.params = params;
18257
- }
18258
- visitContainerPlaceholder(placeholder) {
18259
- var _a2, _b2;
18260
- if (placeholder.startName && placeholder.startSourceSpan && !this.params.has(placeholder.startName)) {
18261
- this.params.set(placeholder.startName, [{
18262
- value: (_a2 = placeholder.startSourceSpan) == null ? void 0 : _a2.toString(),
18263
- subTemplateIndex: null,
18264
- flags: I18nParamValueFlags.None
18265
- }]);
18266
- }
18267
- if (placeholder.closeName && placeholder.endSourceSpan && !this.params.has(placeholder.closeName)) {
18268
- this.params.set(placeholder.closeName, [{
18269
- value: (_b2 = placeholder.endSourceSpan) == null ? void 0 : _b2.toString(),
18270
- subTemplateIndex: null,
18271
- flags: I18nParamValueFlags.None
18272
- }]);
18273
- }
18274
- }
18275
- visitTagPlaceholder(placeholder) {
18276
- super.visitTagPlaceholder(placeholder);
18277
- this.visitContainerPlaceholder(placeholder);
18249
+ function updatePlaceholder(op, value, i18nContexts, icuPlaceholders) {
18250
+ if (op.i18nPlaceholder !== null) {
18251
+ const i18nContext = i18nContexts.get(op.context);
18252
+ const params = op.resolutionTime === I18nParamResolutionTime.Creation ? i18nContext.params : i18nContext.postprocessingParams;
18253
+ const values = params.get(op.i18nPlaceholder) || [];
18254
+ values.push(value);
18255
+ params.set(op.i18nPlaceholder, values);
18278
18256
  }
18279
- visitBlockPlaceholder(placeholder) {
18280
- super.visitBlockPlaceholder(placeholder);
18281
- this.visitContainerPlaceholder(placeholder);
18257
+ if (op.icuPlaceholder !== null) {
18258
+ const icuPlaceholderOp = icuPlaceholders.get(op.icuPlaceholder);
18259
+ icuPlaceholderOp == null ? void 0 : icuPlaceholderOp.expressionPlaceholders.push(value);
18282
18260
  }
18283
- };
18261
+ }
18284
18262
 
18285
18263
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_names.mjs
18286
18264
  function resolveNames(job) {
@@ -18750,7 +18728,10 @@ function varsUsedByOp(op) {
18750
18728
  return op.interpolation.expressions.length;
18751
18729
  case OpKind.I18nExpression:
18752
18730
  case OpKind.Conditional:
18731
+ case OpKind.DeferWhen:
18753
18732
  return 1;
18733
+ case OpKind.RepeaterCreate:
18734
+ return op.emptyView ? 1 : 0;
18754
18735
  default:
18755
18736
  throw new Error(`Unhandled op: ${OpKind[op.kind]}`);
18756
18737
  }
@@ -19064,6 +19045,7 @@ var phases = [
19064
19045
  { kind: CompilationJobKind.Tmpl, fn: emitNamespaceChanges },
19065
19046
  { kind: CompilationJobKind.Tmpl, fn: propagateI18nBlocks },
19066
19047
  { kind: CompilationJobKind.Tmpl, fn: wrapI18nIcus },
19048
+ { kind: CompilationJobKind.Both, fn: deduplicateTextBindings },
19067
19049
  { kind: CompilationJobKind.Both, fn: specializeStyleBindings },
19068
19050
  { kind: CompilationJobKind.Both, fn: specializeBindings },
19069
19051
  { kind: CompilationJobKind.Both, fn: extractAttributes },
@@ -19087,7 +19069,6 @@ var phases = [
19087
19069
  { kind: CompilationJobKind.Tmpl, fn: saveAndRestoreView },
19088
19070
  { kind: CompilationJobKind.Both, fn: deleteAnyCasts },
19089
19071
  { kind: CompilationJobKind.Both, fn: resolveDollarEvent },
19090
- { kind: CompilationJobKind.Tmpl, fn: generateRepeaterDerivedVars },
19091
19072
  { kind: CompilationJobKind.Tmpl, fn: generateTrackVariables },
19092
19073
  { kind: CompilationJobKind.Both, fn: resolveNames },
19093
19074
  { kind: CompilationJobKind.Tmpl, fn: resolveDeferTargetNames },
@@ -19102,7 +19083,6 @@ var phases = [
19102
19083
  { kind: CompilationJobKind.Tmpl, fn: createDeferDepsFns },
19103
19084
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nElementPlaceholders },
19104
19085
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nExpressionPlaceholders },
19105
- { kind: CompilationJobKind.Tmpl, fn: resolveI18nIcuPlaceholders },
19106
19086
  { kind: CompilationJobKind.Tmpl, fn: extractI18nMessages },
19107
19087
  { kind: CompilationJobKind.Tmpl, fn: generateTrackFns },
19108
19088
  { kind: CompilationJobKind.Tmpl, fn: collectI18nConsts },
@@ -19245,7 +19225,7 @@ function ingestHostBinding(input, bindingParser, constantPool) {
19245
19225
  bindingKind = BindingKind.Animation;
19246
19226
  }
19247
19227
  const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, property2.name, bindingKind === BindingKind.Attribute).filter((context) => context !== SecurityContext.NONE);
19248
- ingestHostProperty(job, property2, bindingKind, false, securityContexts);
19228
+ ingestHostProperty(job, property2, bindingKind, securityContexts);
19249
19229
  }
19250
19230
  for (const [name, expr] of (_b2 = Object.entries(input.attributes)) != null ? _b2 : []) {
19251
19231
  const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, name, true).filter((context) => context !== SecurityContext.NONE);
@@ -19256,7 +19236,7 @@ function ingestHostBinding(input, bindingParser, constantPool) {
19256
19236
  }
19257
19237
  return job;
19258
19238
  }
19259
- function ingestHostProperty(job, property2, bindingKind, isTextAttribute, securityContexts) {
19239
+ function ingestHostProperty(job, property2, bindingKind, securityContexts) {
19260
19240
  let expression;
19261
19241
  const ast = property2.expression.ast;
19262
19242
  if (ast instanceof Interpolation) {
@@ -19264,7 +19244,7 @@ function ingestHostProperty(job, property2, bindingKind, isTextAttribute, securi
19264
19244
  } else {
19265
19245
  expression = convertAst(ast, job, property2.sourceSpan);
19266
19246
  }
19267
- job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, securityContexts, isTextAttribute, false, null, null, property2.sourceSpan));
19247
+ job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, securityContexts, false, false, null, null, property2.sourceSpan));
19268
19248
  }
19269
19249
  function ingestHostAttribute(job, name, value, securityContexts) {
19270
19250
  const attrBinding = createBindingOp(
@@ -19278,14 +19258,13 @@ function ingestHostAttribute(job, name, value, securityContexts) {
19278
19258
  false,
19279
19259
  null,
19280
19260
  null,
19281
- null
19261
+ value.sourceSpan
19282
19262
  );
19283
19263
  job.root.update.push(attrBinding);
19284
19264
  }
19285
19265
  function ingestHostEvent(job, event) {
19286
19266
  const [phase, target] = event.type === 0 ? [null, event.targetOrPhase] : [event.targetOrPhase, null];
19287
- const eventBinding = createListenerOp(job.root.xref, new SlotHandle(), event.name, null, [], phase, target, true, event.sourceSpan);
19288
- eventBinding.handlerOps.push(createStatementOp(new ReturnStatement(convertAst(event.handler.ast, job, event.sourceSpan), event.handlerSpan)));
19267
+ const eventBinding = createListenerOp(job.root.xref, new SlotHandle(), event.name, null, makeListenerHandlerOps(job.root, event.handler, event.handlerSpan), phase, target, true, event.sourceSpan);
19289
19268
  job.root.create.push(eventBinding);
19290
19269
  }
19291
19270
  function ingestNodes(unit, template2) {
@@ -19297,9 +19276,9 @@ function ingestNodes(unit, template2) {
19297
19276
  } else if (node instanceof Content) {
19298
19277
  ingestContent(unit, node);
19299
19278
  } else if (node instanceof Text) {
19300
- ingestText(unit, node);
19279
+ ingestText(unit, node, null);
19301
19280
  } else if (node instanceof BoundText) {
19302
- ingestBoundText(unit, node);
19281
+ ingestBoundText(unit, node, null);
19303
19282
  } else if (node instanceof IfBlock) {
19304
19283
  ingestIfBlock(unit, node);
19305
19284
  } else if (node instanceof SwitchBlock) {
@@ -19322,7 +19301,7 @@ function ingestElement(unit, element2) {
19322
19301
  }
19323
19302
  const id = unit.job.allocateXrefId();
19324
19303
  const [namespaceKey, elementName] = splitNsName(element2.name);
19325
- const startOp = createElementStartOp(elementName, id, namespaceForKey(namespaceKey), element2.i18n instanceof TagPlaceholder ? element2.i18n : void 0, element2.startSourceSpan);
19304
+ const startOp = createElementStartOp(elementName, id, namespaceForKey(namespaceKey), element2.i18n instanceof TagPlaceholder ? element2.i18n : void 0, element2.startSourceSpan, element2.sourceSpan);
19326
19305
  unit.create.push(startOp);
19327
19306
  ingestElementBindings(unit, startOp, element2);
19328
19307
  ingestReferences(startOp, element2);
@@ -19352,7 +19331,7 @@ function ingestTemplate(unit, tmpl) {
19352
19331
  const namespace = namespaceForKey(namespacePrefix);
19353
19332
  const functionNameSuffix = tagNameWithoutNamespace === null ? "" : prefixWithNamespace(tagNameWithoutNamespace, namespace);
19354
19333
  const templateKind = isPlainTemplate(tmpl) ? TemplateKind.NgTemplate : TemplateKind.Structural;
19355
- const templateOp = createTemplateOp(childView.xref, templateKind, tagNameWithoutNamespace, functionNameSuffix, namespace, i18nPlaceholder, tmpl.startSourceSpan);
19334
+ const templateOp = createTemplateOp(childView.xref, templateKind, tagNameWithoutNamespace, functionNameSuffix, namespace, i18nPlaceholder, tmpl.startSourceSpan, tmpl.sourceSpan);
19356
19335
  unit.create.push(templateOp);
19357
19336
  ingestTemplateBindings(unit, templateOp, tmpl, templateKind);
19358
19337
  ingestReferences(templateOp, tmpl);
@@ -19378,10 +19357,10 @@ function ingestContent(unit, content) {
19378
19357
  }
19379
19358
  unit.create.push(op);
19380
19359
  }
19381
- function ingestText(unit, text2) {
19382
- unit.create.push(createTextOp(unit.job.allocateXrefId(), text2.value, text2.sourceSpan));
19360
+ function ingestText(unit, text2, icuPlaceholder) {
19361
+ unit.create.push(createTextOp(unit.job.allocateXrefId(), text2.value, icuPlaceholder, text2.sourceSpan));
19383
19362
  }
19384
- function ingestBoundText(unit, text2, i18nPlaceholders) {
19363
+ function ingestBoundText(unit, text2, icuPlaceholder) {
19385
19364
  var _a2;
19386
19365
  let value = text2.value;
19387
19366
  if (value instanceof ASTWithSource) {
@@ -19393,14 +19372,12 @@ function ingestBoundText(unit, text2, i18nPlaceholders) {
19393
19372
  if (text2.i18n !== void 0 && !(text2.i18n instanceof Container)) {
19394
19373
  throw Error(`Unhandled i18n metadata type for text interpolation: ${(_a2 = text2.i18n) == null ? void 0 : _a2.constructor.name}`);
19395
19374
  }
19396
- if (i18nPlaceholders === void 0) {
19397
- i18nPlaceholders = text2.i18n instanceof Container ? text2.i18n.children.filter((node) => node instanceof Placeholder).map((placeholder) => placeholder.name) : [];
19398
- }
19375
+ const i18nPlaceholders = text2.i18n instanceof Container ? text2.i18n.children.filter((node) => node instanceof Placeholder).map((placeholder) => placeholder.name) : [];
19399
19376
  if (i18nPlaceholders.length > 0 && i18nPlaceholders.length !== value.expressions.length) {
19400
19377
  throw Error(`Unexpected number of i18n placeholders (${value.expressions.length}) for BoundText with ${value.expressions.length} expressions`);
19401
19378
  }
19402
19379
  const textXref = unit.job.allocateXrefId();
19403
- unit.create.push(createTextOp(textXref, "", text2.sourceSpan));
19380
+ unit.create.push(createTextOp(textXref, "", icuPlaceholder, text2.sourceSpan));
19404
19381
  const baseSourceSpan = unit.job.compatibility ? null : text2.sourceSpan;
19405
19382
  unit.update.push(createInterpolateTextOp(textXref, new Interpolation2(value.strings, value.expressions.map((expr) => convertAst(expr, unit.job, baseSourceSpan)), i18nPlaceholders), text2.sourceSpan));
19406
19383
  }
@@ -19426,7 +19403,7 @@ function ingestIfBlock(unit, ifBlock) {
19426
19403
  }
19427
19404
  ifCaseI18nMeta = ifCase.i18n;
19428
19405
  }
19429
- const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, tagName, "Conditional", Namespace.HTML, ifCaseI18nMeta, ifCase.sourceSpan);
19406
+ const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, tagName, "Conditional", Namespace.HTML, ifCaseI18nMeta, ifCase.startSourceSpan, ifCase.sourceSpan);
19430
19407
  unit.create.push(templateOp);
19431
19408
  if (firstXref === null) {
19432
19409
  firstXref = cView.xref;
@@ -19442,6 +19419,9 @@ function ingestIfBlock(unit, ifBlock) {
19442
19419
  }
19443
19420
  function ingestSwitchBlock(unit, switchBlock) {
19444
19421
  var _a2;
19422
+ if (switchBlock.cases.length === 0) {
19423
+ return;
19424
+ }
19445
19425
  let firstXref = null;
19446
19426
  let firstSlotHandle = null;
19447
19427
  let conditions = [];
@@ -19454,7 +19434,7 @@ function ingestSwitchBlock(unit, switchBlock) {
19454
19434
  }
19455
19435
  switchCaseI18nMeta = switchCase.i18n;
19456
19436
  }
19457
- const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, null, "Case", Namespace.HTML, switchCaseI18nMeta, switchCase.sourceSpan);
19437
+ const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, null, "Case", Namespace.HTML, switchCaseI18nMeta, switchCase.startSourceSpan, switchCase.sourceSpan);
19458
19438
  unit.create.push(templateOp);
19459
19439
  if (firstXref === null) {
19460
19440
  firstXref = cView.xref;
@@ -19477,7 +19457,7 @@ function ingestDeferView(unit, suffix, i18nMeta, children, sourceSpan) {
19477
19457
  }
19478
19458
  const secondaryView = unit.job.allocateView(unit.xref);
19479
19459
  ingestNodes(secondaryView, children);
19480
- const templateOp = createTemplateOp(secondaryView.xref, TemplateKind.Block, null, `Defer${suffix}`, Namespace.HTML, i18nMeta, sourceSpan);
19460
+ const templateOp = createTemplateOp(secondaryView.xref, TemplateKind.Block, null, `Defer${suffix}`, Namespace.HTML, i18nMeta, sourceSpan, sourceSpan);
19481
19461
  unit.create.push(templateOp);
19482
19462
  return templateOp;
19483
19463
  }
@@ -19551,6 +19531,9 @@ function ingestDeferBlock(unit, deferBlock) {
19551
19531
  deferOnOps.push(deferOnOp);
19552
19532
  }
19553
19533
  if (triggers.when !== void 0) {
19534
+ if (triggers.when.value instanceof Interpolation) {
19535
+ throw new Error(`Unexpected interpolation in defer block when trigger`);
19536
+ }
19554
19537
  const deferOnOp = createDeferWhenOp(deferXref, convertAst(triggers.when.value, unit.job, triggers.when.sourceSpan), prefetch, triggers.when.sourceSpan);
19555
19538
  deferWhenOps.push(deferOnOp);
19556
19539
  }
@@ -19570,9 +19553,9 @@ function ingestIcu(unit, icu) {
19570
19553
  unit.create.push(createIcuStartOp(xref, icu.i18n, icuFromI18nMessage(icu.i18n).name, null));
19571
19554
  for (const [placeholder, text2] of Object.entries(__spreadValues(__spreadValues({}, icu.vars), icu.placeholders))) {
19572
19555
  if (text2 instanceof BoundText) {
19573
- ingestBoundText(unit, text2, [placeholder]);
19556
+ ingestBoundText(unit, text2, placeholder);
19574
19557
  } else {
19575
- ingestText(unit, text2);
19558
+ ingestText(unit, text2, placeholder);
19576
19559
  }
19577
19560
  }
19578
19561
  unit.create.push(createIcuEndOp(xref));
@@ -19583,21 +19566,37 @@ function ingestIcu(unit, icu) {
19583
19566
  function ingestForBlock(unit, forBlock) {
19584
19567
  var _a2, _b2, _c2;
19585
19568
  const repeaterView = unit.job.allocateView(unit.xref);
19586
- const createRepeaterAlias = (ident, repeaterVar) => {
19587
- repeaterView.aliases.add({
19588
- kind: SemanticVariableKind.Alias,
19589
- name: null,
19590
- identifier: ident,
19591
- expression: new DerivedRepeaterVarExpr(repeaterView.xref, repeaterVar)
19592
- });
19593
- };
19594
19569
  repeaterView.contextVariables.set(forBlock.item.name, forBlock.item.value);
19595
19570
  repeaterView.contextVariables.set(forBlock.contextVariables.$index.name, forBlock.contextVariables.$index.value);
19596
19571
  repeaterView.contextVariables.set(forBlock.contextVariables.$count.name, forBlock.contextVariables.$count.value);
19597
- createRepeaterAlias(forBlock.contextVariables.$first.name, DerivedRepeaterVarIdentity.First);
19598
- createRepeaterAlias(forBlock.contextVariables.$last.name, DerivedRepeaterVarIdentity.Last);
19599
- createRepeaterAlias(forBlock.contextVariables.$even.name, DerivedRepeaterVarIdentity.Even);
19600
- createRepeaterAlias(forBlock.contextVariables.$odd.name, DerivedRepeaterVarIdentity.Odd);
19572
+ const indexName = `\u0275${forBlock.contextVariables.$index.name}_${repeaterView.xref}`;
19573
+ const countName = `\u0275${forBlock.contextVariables.$count.name}_${repeaterView.xref}`;
19574
+ repeaterView.contextVariables.set(indexName, forBlock.contextVariables.$index.value);
19575
+ repeaterView.contextVariables.set(countName, forBlock.contextVariables.$count.value);
19576
+ repeaterView.aliases.add({
19577
+ kind: SemanticVariableKind.Alias,
19578
+ name: null,
19579
+ identifier: forBlock.contextVariables.$first.name,
19580
+ expression: new LexicalReadExpr(indexName).identical(literal(0))
19581
+ });
19582
+ repeaterView.aliases.add({
19583
+ kind: SemanticVariableKind.Alias,
19584
+ name: null,
19585
+ identifier: forBlock.contextVariables.$last.name,
19586
+ expression: new LexicalReadExpr(indexName).identical(new LexicalReadExpr(countName).minus(literal(1)))
19587
+ });
19588
+ repeaterView.aliases.add({
19589
+ kind: SemanticVariableKind.Alias,
19590
+ name: null,
19591
+ identifier: forBlock.contextVariables.$even.name,
19592
+ expression: new LexicalReadExpr(indexName).modulo(literal(2)).identical(literal(0))
19593
+ });
19594
+ repeaterView.aliases.add({
19595
+ kind: SemanticVariableKind.Alias,
19596
+ name: null,
19597
+ identifier: forBlock.contextVariables.$odd.name,
19598
+ expression: new LexicalReadExpr(indexName).modulo(literal(2)).notIdentical(literal(0))
19599
+ });
19601
19600
  const sourceSpan = convertSourceSpan(forBlock.trackBy.span, forBlock.sourceSpan);
19602
19601
  const track = convertAst(forBlock.trackBy, unit.job, sourceSpan);
19603
19602
  ingestNodes(repeaterView, forBlock.children);
@@ -19624,7 +19623,7 @@ function ingestForBlock(unit, forBlock) {
19624
19623
  const i18nPlaceholder = forBlock.i18n;
19625
19624
  const emptyI18nPlaceholder = (_b2 = forBlock.empty) == null ? void 0 : _b2.i18n;
19626
19625
  const tagName = ingestControlFlowInsertionPoint(unit, repeaterView.xref, forBlock);
19627
- const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (_c2 = emptyView == null ? void 0 : emptyView.xref) != null ? _c2 : null, tagName, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, forBlock.sourceSpan);
19626
+ const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (_c2 = emptyView == null ? void 0 : emptyView.xref) != null ? _c2 : null, tagName, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, forBlock.startSourceSpan, forBlock.sourceSpan);
19628
19627
  unit.create.push(repeaterCreate2);
19629
19628
  const expression = convertAst(forBlock.expression, unit.job, convertSourceSpan(forBlock.expression.span, forBlock.sourceSpan));
19630
19629
  const repeater2 = createRepeaterOp(repeaterCreate2.xref, repeaterCreate2.handle, expression, forBlock.sourceSpan);
@@ -19712,13 +19711,13 @@ function convertAst(ast, job, baseSourceSpan) {
19712
19711
  throw new Error(`Unhandled expression type "${ast.constructor.name}" in file "${baseSourceSpan == null ? void 0 : baseSourceSpan.start.file.url}"`);
19713
19712
  }
19714
19713
  }
19715
- function convertAstWithInterpolation(job, value, i18nMeta) {
19714
+ function convertAstWithInterpolation(job, value, i18nMeta, sourceSpan) {
19716
19715
  var _a2, _b2;
19717
19716
  let expression;
19718
19717
  if (value instanceof Interpolation) {
19719
- 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 : {}));
19718
+ 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 : {}));
19720
19719
  } else if (value instanceof AST) {
19721
- expression = convertAst(value, job, null);
19720
+ expression = convertAst(value, job, sourceSpan != null ? sourceSpan : null);
19722
19721
  } else {
19723
19722
  expression = literal(value);
19724
19723
  }
@@ -19794,7 +19793,7 @@ function ingestTemplateBindings(unit, op, template2, templateKind) {
19794
19793
  }
19795
19794
  if (templateKind === TemplateKind.Structural && output.type !== 1) {
19796
19795
  const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, output.name, false);
19797
- unit.create.push(createExtractedAttributeOp(op.xref, BindingKind.Property, output.name, null, null, null, securityContext));
19796
+ unit.create.push(createExtractedAttributeOp(op.xref, BindingKind.Property, null, output.name, null, null, null, securityContext));
19798
19797
  }
19799
19798
  }
19800
19799
  if (bindings.some((b) => b == null ? void 0 : b.i18nMessage) !== null) {
@@ -19805,7 +19804,7 @@ function createTemplateBinding(view, xref, type, name, value, unit, securityCont
19805
19804
  const isTextBinding = typeof value === "string";
19806
19805
  if (templateKind === TemplateKind.Structural) {
19807
19806
  if (!isStructuralTemplateAttribute && (type === 0 || type === 2 || type === 3)) {
19808
- return createExtractedAttributeOp(xref, BindingKind.Property, name, null, null, i18nMessage, securityContext);
19807
+ return createExtractedAttributeOp(xref, BindingKind.Property, null, name, null, null, i18nMessage, securityContext);
19809
19808
  }
19810
19809
  if (!isTextBinding && (type === 1 || type === 4)) {
19811
19810
  return null;
@@ -22664,6 +22663,9 @@ var TemplateDefinitionBuilder = class {
22664
22663
  this.updateInstructionWithAdvance(containerIndex, block.branches[0].sourceSpan, Identifiers.conditional, paramsCallback);
22665
22664
  }
22666
22665
  visitSwitchBlock(block) {
22666
+ if (block.cases.length === 0) {
22667
+ return;
22668
+ }
22667
22669
  const caseData = block.cases.map((currentCase) => {
22668
22670
  const index = this.createEmbeddedTemplateFn(null, currentCase.children, "_Case", currentCase.sourceSpan, void 0, void 0, void 0, currentCase.i18n);
22669
22671
  const expression = currentCase.expression === null ? null : currentCase.expression.visit(this._valueConverter);
@@ -22986,7 +22988,7 @@ var TemplateDefinitionBuilder = class {
22986
22988
  if (delta < 1) {
22987
22989
  throw new Error("advance instruction can only go forwards");
22988
22990
  }
22989
- this.instructionFn(this._updateCodeFns, span, Identifiers.advance, [literal(delta)]);
22991
+ this.instructionFn(this._updateCodeFns, span, Identifiers.advance, delta > 1 ? [literal(delta)] : []);
22990
22992
  this._currentIndex = nodeIndex;
22991
22993
  }
22992
22994
  }
@@ -23396,12 +23398,15 @@ var BindingScope = class {
23396
23398
  }
23397
23399
  };
23398
23400
  var TrackByBindingScope = class extends BindingScope {
23399
- constructor(parentScope, globalAliases) {
23401
+ constructor(parentScope, globalOverrides) {
23400
23402
  super(parentScope.bindingLevel + 1, parentScope);
23401
- this.globalAliases = globalAliases;
23403
+ this.globalOverrides = globalOverrides;
23402
23404
  this.componentAccessCount = 0;
23403
23405
  }
23404
23406
  get(name) {
23407
+ if (this.globalOverrides.hasOwnProperty(name)) {
23408
+ return variable(this.globalOverrides[name]);
23409
+ }
23405
23410
  let current = this.parent;
23406
23411
  while (current) {
23407
23412
  if (current.hasLocal(name)) {
@@ -23409,9 +23414,6 @@ var TrackByBindingScope = class extends BindingScope {
23409
23414
  }
23410
23415
  current = current.parent;
23411
23416
  }
23412
- if (this.globalAliases[name]) {
23413
- return variable(this.globalAliases[name]);
23414
- }
23415
23417
  this.componentAccessCount++;
23416
23418
  return variable("this").prop(name);
23417
23419
  }
@@ -25413,7 +25415,7 @@ function publishFacade(global) {
25413
25415
  }
25414
25416
 
25415
25417
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/version.mjs
25416
- var VERSION2 = new Version("17.0.7");
25418
+ var VERSION2 = new Version("17.0.9");
25417
25419
 
25418
25420
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
25419
25421
  var _VisitorMode;
@@ -25457,6 +25459,20 @@ var FactoryTarget2;
25457
25459
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/compiler.mjs
25458
25460
  publishFacade(_global);
25459
25461
 
25462
+ // bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/identifier-lookup.mjs
25463
+ var import_typescript5 = __toESM(require("typescript"), 1);
25464
+ function lookupIdentifiersInSourceFile(sourceFile, names) {
25465
+ const results = /* @__PURE__ */ new Set();
25466
+ const visit = (node) => {
25467
+ if (import_typescript5.default.isIdentifier(node) && names.includes(node.text)) {
25468
+ results.add(node);
25469
+ }
25470
+ import_typescript5.default.forEachChild(node, visit);
25471
+ };
25472
+ visit(sourceFile);
25473
+ return results;
25474
+ }
25475
+
25460
25476
  // bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/types.mjs
25461
25477
  var ngtemplate = "ng-template";
25462
25478
  var boundngifelse = "[ngIfElse]";
@@ -25467,6 +25483,18 @@ var startMarker = "\u25EC";
25467
25483
  var endMarker = "\u2722";
25468
25484
  var startI18nMarker = "\u2688";
25469
25485
  var endI18nMarker = "\u2689";
25486
+ var importRemovals = [
25487
+ "NgIf",
25488
+ "NgIfElse",
25489
+ "NgIfThenElse",
25490
+ "NgFor",
25491
+ "NgForOf",
25492
+ "NgForTrackBy",
25493
+ "NgSwitch",
25494
+ "NgSwitchCase",
25495
+ "NgSwitchDefault"
25496
+ ];
25497
+ var importWithCommonRemovals = [...importRemovals, "CommonModule"];
25470
25498
  function allFormsOf(selector) {
25471
25499
  return [
25472
25500
  selector,
@@ -25616,22 +25644,24 @@ var Template2 = class {
25616
25644
  }
25617
25645
  };
25618
25646
  var AnalyzedFile = class {
25619
- constructor() {
25647
+ constructor(sourceFile) {
25620
25648
  __publicField(this, "ranges", []);
25621
25649
  __publicField(this, "removeCommonModule", false);
25622
25650
  __publicField(this, "canRemoveImports", false);
25623
- __publicField(this, "sourceFilePath", "");
25651
+ __publicField(this, "sourceFile");
25652
+ __publicField(this, "importRanges", []);
25653
+ __publicField(this, "templateRanges", []);
25654
+ this.sourceFile = sourceFile;
25624
25655
  }
25625
25656
  getSortedRanges() {
25626
- const templateRanges = this.ranges.slice().filter((x) => x.type !== "import").sort((aStart, bStart) => bStart.start - aStart.start);
25627
- const importRanges = this.ranges.slice().filter((x) => x.type === "import").sort((aStart, bStart) => bStart.start - aStart.start);
25628
- return [...templateRanges, ...importRanges];
25657
+ this.templateRanges = this.ranges.slice().filter((x) => x.type === "template" || x.type === "templateUrl").sort((aStart, bStart) => bStart.start - aStart.start);
25658
+ this.importRanges = this.ranges.slice().filter((x) => x.type === "importDecorator" || x.type === "importDeclaration").sort((aStart, bStart) => bStart.start - aStart.start);
25659
+ return [...this.templateRanges, ...this.importRanges];
25629
25660
  }
25630
- static addRange(path2, sourceFilePath, analyzedFiles, range) {
25661
+ static addRange(path2, sourceFile, analyzedFiles, range) {
25631
25662
  let analysis = analyzedFiles.get(path2);
25632
25663
  if (!analysis) {
25633
- analysis = new AnalyzedFile();
25634
- analysis.sourceFilePath = sourceFilePath;
25664
+ analysis = new AnalyzedFile(sourceFile);
25635
25665
  analyzedFiles.set(path2, analysis);
25636
25666
  }
25637
25667
  const duplicate = analysis.ranges.find((current) => current.start === range.start && current.end === range.end);
@@ -25639,6 +25669,25 @@ var AnalyzedFile = class {
25639
25669
  analysis.ranges.push(range);
25640
25670
  }
25641
25671
  }
25672
+ verifyCanRemoveImports() {
25673
+ const importDeclaration = this.importRanges.find((r) => r.type === "importDeclaration");
25674
+ const instances = lookupIdentifiersInSourceFile(this.sourceFile, importWithCommonRemovals);
25675
+ let foundImportDeclaration = false;
25676
+ let count = 0;
25677
+ for (let range of this.importRanges) {
25678
+ for (let instance of instances) {
25679
+ if (instance.getStart() >= range.start && instance.getEnd() <= range.end) {
25680
+ if (range === importDeclaration) {
25681
+ foundImportDeclaration = true;
25682
+ }
25683
+ count++;
25684
+ }
25685
+ }
25686
+ }
25687
+ if (instances.size !== count && importDeclaration !== void 0 && foundImportDeclaration) {
25688
+ importDeclaration.remove = false;
25689
+ }
25690
+ }
25642
25691
  };
25643
25692
  var CommonCollector = class extends RecursiveVisitor {
25644
25693
  constructor() {
@@ -25759,19 +25808,7 @@ var TemplateCollector = class extends RecursiveVisitor {
25759
25808
 
25760
25809
  // bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/util.mjs
25761
25810
  var import_path2 = require("path");
25762
- var import_typescript5 = __toESM(require("typescript"), 1);
25763
- var importRemovals = [
25764
- "NgIf",
25765
- "NgIfElse",
25766
- "NgIfThenElse",
25767
- "NgFor",
25768
- "NgForOf",
25769
- "NgForTrackBy",
25770
- "NgSwitch",
25771
- "NgSwitchCase",
25772
- "NgSwitchDefault"
25773
- ];
25774
- var importWithCommonRemovals = [...importRemovals, "CommonModule"];
25811
+ var import_typescript6 = __toESM(require("typescript"), 1);
25775
25812
  var startMarkerRegex = new RegExp(startMarker, "gm");
25776
25813
  var endMarkerRegex = new RegExp(endMarker, "gm");
25777
25814
  var startI18nMarkerRegex = new RegExp(startI18nMarker, "gm");
@@ -25779,16 +25816,20 @@ var endI18nMarkerRegex = new RegExp(endI18nMarker, "gm");
25779
25816
  var replaceMarkerRegex = new RegExp(`${startMarker}|${endMarker}`, "gm");
25780
25817
  function analyze(sourceFile, analyzedFiles) {
25781
25818
  forEachClass(sourceFile, (node) => {
25782
- if (import_typescript5.default.isClassDeclaration(node)) {
25819
+ if (import_typescript6.default.isClassDeclaration(node)) {
25783
25820
  analyzeDecorators(node, sourceFile, analyzedFiles);
25784
25821
  } else {
25785
25822
  analyzeImportDeclarations(node, sourceFile, analyzedFiles);
25786
25823
  }
25787
25824
  });
25788
25825
  }
25789
- function checkIfShouldChange(decl, removeCommonModule) {
25826
+ function checkIfShouldChange(decl, file) {
25827
+ const range = file.importRanges.find((r) => r.type === "importDeclaration");
25828
+ if (range === void 0 || !range.remove) {
25829
+ return false;
25830
+ }
25790
25831
  const clause = decl.getChildAt(1);
25791
- return !(!removeCommonModule && clause.namedBindings && import_typescript5.default.isNamedImports(clause.namedBindings) && clause.namedBindings.elements.length === 1 && clause.namedBindings.elements[0].getText() === "CommonModule");
25832
+ return !(!file.removeCommonModule && clause.namedBindings && import_typescript6.default.isNamedImports(clause.namedBindings) && clause.namedBindings.elements.length === 1 && clause.namedBindings.elements[0].getText() === "CommonModule");
25792
25833
  }
25793
25834
  function updateImportDeclaration(decl, removeCommonModule) {
25794
25835
  const clause = decl.getChildAt(1);
@@ -25796,81 +25837,89 @@ function updateImportDeclaration(decl, removeCommonModule) {
25796
25837
  if (updatedClause === null) {
25797
25838
  return "";
25798
25839
  }
25799
- const printer = import_typescript5.default.createPrinter({
25840
+ const printer = import_typescript6.default.createPrinter({
25800
25841
  removeComments: true
25801
25842
  });
25802
- const updated = import_typescript5.default.factory.updateImportDeclaration(decl, decl.modifiers, updatedClause, decl.moduleSpecifier, void 0);
25803
- return printer.printNode(import_typescript5.default.EmitHint.Unspecified, updated, clause.getSourceFile());
25843
+ const updated = import_typescript6.default.factory.updateImportDeclaration(decl, decl.modifiers, updatedClause, decl.moduleSpecifier, void 0);
25844
+ return printer.printNode(import_typescript6.default.EmitHint.Unspecified, updated, clause.getSourceFile());
25804
25845
  }
25805
25846
  function updateImportClause(clause, removeCommonModule) {
25806
- if (clause.namedBindings && import_typescript5.default.isNamedImports(clause.namedBindings)) {
25847
+ if (clause.namedBindings && import_typescript6.default.isNamedImports(clause.namedBindings)) {
25807
25848
  const removals = removeCommonModule ? importWithCommonRemovals : importRemovals;
25808
25849
  const elements = clause.namedBindings.elements.filter((el) => !removals.includes(el.getText()));
25809
25850
  if (elements.length === 0) {
25810
25851
  return null;
25811
25852
  }
25812
- clause = import_typescript5.default.factory.updateImportClause(clause, clause.isTypeOnly, clause.name, import_typescript5.default.factory.createNamedImports(elements));
25853
+ clause = import_typescript6.default.factory.updateImportClause(clause, clause.isTypeOnly, clause.name, import_typescript6.default.factory.createNamedImports(elements));
25813
25854
  }
25814
25855
  return clause;
25815
25856
  }
25816
25857
  function updateClassImports(propAssignment, removeCommonModule) {
25817
- const printer = import_typescript5.default.createPrinter();
25858
+ const printer = import_typescript6.default.createPrinter();
25818
25859
  const importList = propAssignment.initializer;
25819
25860
  const removals = removeCommonModule ? importWithCommonRemovals : importRemovals;
25820
25861
  const elements = importList.elements.filter((el) => !removals.includes(el.getText()));
25821
25862
  if (elements.length === importList.elements.length) {
25822
25863
  return null;
25823
25864
  }
25824
- const updatedElements = import_typescript5.default.factory.updateArrayLiteralExpression(importList, elements);
25825
- const updatedAssignment = import_typescript5.default.factory.updatePropertyAssignment(propAssignment, propAssignment.name, updatedElements);
25826
- return printer.printNode(import_typescript5.default.EmitHint.Unspecified, updatedAssignment, updatedAssignment.getSourceFile());
25865
+ const updatedElements = import_typescript6.default.factory.updateArrayLiteralExpression(importList, elements);
25866
+ const updatedAssignment = import_typescript6.default.factory.updatePropertyAssignment(propAssignment, propAssignment.name, updatedElements);
25867
+ return printer.printNode(import_typescript6.default.EmitHint.Unspecified, updatedAssignment, updatedAssignment.getSourceFile());
25827
25868
  }
25828
25869
  function analyzeImportDeclarations(node, sourceFile, analyzedFiles) {
25829
25870
  if (node.getText().indexOf("@angular/common") === -1) {
25830
25871
  return;
25831
25872
  }
25832
25873
  const clause = node.getChildAt(1);
25833
- if (clause.namedBindings && import_typescript5.default.isNamedImports(clause.namedBindings)) {
25874
+ if (clause.namedBindings && import_typescript6.default.isNamedImports(clause.namedBindings)) {
25834
25875
  const elements = clause.namedBindings.elements.filter((el) => importWithCommonRemovals.includes(el.getText()));
25835
25876
  if (elements.length > 0) {
25836
- AnalyzedFile.addRange(sourceFile.fileName, sourceFile.fileName, analyzedFiles, { start: node.getStart(), end: node.getEnd(), node, type: "import" });
25877
+ AnalyzedFile.addRange(sourceFile.fileName, sourceFile, analyzedFiles, {
25878
+ start: node.getStart(),
25879
+ end: node.getEnd(),
25880
+ node,
25881
+ type: "importDeclaration",
25882
+ remove: true
25883
+ });
25837
25884
  }
25838
25885
  }
25839
25886
  }
25840
25887
  function analyzeDecorators(node, sourceFile, analyzedFiles) {
25841
25888
  var _a2;
25842
- const decorator = (_a2 = import_typescript5.default.getDecorators(node)) == null ? void 0 : _a2.find((dec) => {
25843
- return import_typescript5.default.isCallExpression(dec.expression) && import_typescript5.default.isIdentifier(dec.expression.expression) && dec.expression.expression.text === "Component";
25889
+ const decorator = (_a2 = import_typescript6.default.getDecorators(node)) == null ? void 0 : _a2.find((dec) => {
25890
+ return import_typescript6.default.isCallExpression(dec.expression) && import_typescript6.default.isIdentifier(dec.expression.expression) && dec.expression.expression.text === "Component";
25844
25891
  });
25845
- const metadata = decorator && decorator.expression.arguments.length > 0 && import_typescript5.default.isObjectLiteralExpression(decorator.expression.arguments[0]) ? decorator.expression.arguments[0] : null;
25892
+ const metadata = decorator && decorator.expression.arguments.length > 0 && import_typescript6.default.isObjectLiteralExpression(decorator.expression.arguments[0]) ? decorator.expression.arguments[0] : null;
25846
25893
  if (!metadata) {
25847
25894
  return;
25848
25895
  }
25849
25896
  for (const prop of metadata.properties) {
25850
- if (!import_typescript5.default.isPropertyAssignment(prop) || !import_typescript5.default.isIdentifier(prop.name) && !import_typescript5.default.isStringLiteralLike(prop.name)) {
25897
+ if (!import_typescript6.default.isPropertyAssignment(prop) || !import_typescript6.default.isIdentifier(prop.name) && !import_typescript6.default.isStringLiteralLike(prop.name)) {
25851
25898
  continue;
25852
25899
  }
25853
25900
  switch (prop.name.text) {
25854
25901
  case "template":
25855
- AnalyzedFile.addRange(sourceFile.fileName, sourceFile.fileName, analyzedFiles, {
25902
+ AnalyzedFile.addRange(sourceFile.fileName, sourceFile, analyzedFiles, {
25856
25903
  start: prop.initializer.getStart() + 1,
25857
25904
  end: prop.initializer.getEnd() - 1,
25858
25905
  node: prop,
25859
- type: "template"
25906
+ type: "template",
25907
+ remove: true
25860
25908
  });
25861
25909
  break;
25862
25910
  case "imports":
25863
- AnalyzedFile.addRange(sourceFile.fileName, sourceFile.fileName, analyzedFiles, {
25911
+ AnalyzedFile.addRange(sourceFile.fileName, sourceFile, analyzedFiles, {
25864
25912
  start: prop.name.getStart(),
25865
25913
  end: prop.initializer.getEnd(),
25866
25914
  node: prop,
25867
- type: "import"
25915
+ type: "importDecorator",
25916
+ remove: true
25868
25917
  });
25869
25918
  break;
25870
25919
  case "templateUrl":
25871
- if (import_typescript5.default.isStringLiteralLike(prop.initializer)) {
25920
+ if (import_typescript6.default.isStringLiteralLike(prop.initializer)) {
25872
25921
  const path2 = (0, import_path2.join)((0, import_path2.dirname)(sourceFile.fileName), prop.initializer.text);
25873
- AnalyzedFile.addRange(path2, sourceFile.fileName, analyzedFiles, { start: 0, node: prop, type: "templateUrl" });
25922
+ AnalyzedFile.addRange(path2, sourceFile, analyzedFiles, { start: 0, node: prop, type: "templateUrl", remove: true });
25874
25923
  }
25875
25924
  break;
25876
25925
  }
@@ -25905,6 +25954,41 @@ function parseTemplate2(template2) {
25905
25954
  }
25906
25955
  return { tree: parsed, errors: [] };
25907
25956
  }
25957
+ function validateMigratedTemplate(migrated, fileName) {
25958
+ const parsed = parseTemplate2(migrated);
25959
+ let errors = [];
25960
+ if (parsed.errors.length > 0) {
25961
+ errors.push({
25962
+ type: "parse",
25963
+ error: new Error(`The migration resulted in invalid HTML for ${fileName}. Please check the template for valid HTML structures and run the migration again.`)
25964
+ });
25965
+ }
25966
+ if (parsed.tree) {
25967
+ const i18nError = validateI18nStructure(parsed.tree, fileName);
25968
+ if (i18nError !== null) {
25969
+ errors.push({ type: "i18n", error: i18nError });
25970
+ }
25971
+ }
25972
+ return errors;
25973
+ }
25974
+ function validateI18nStructure(parsed, fileName) {
25975
+ const visitor = new i18nCollector();
25976
+ visitAll2(visitor, parsed.rootNodes);
25977
+ const parents = visitor.elements.filter((el) => el.children.length > 0);
25978
+ for (const p of parents) {
25979
+ for (const el of visitor.elements) {
25980
+ if (el === p)
25981
+ continue;
25982
+ if (isChildOf(p, el)) {
25983
+ 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.`);
25984
+ }
25985
+ }
25986
+ }
25987
+ return null;
25988
+ }
25989
+ function isChildOf(parent, el) {
25990
+ return parent.sourceSpan.start.offset < el.sourceSpan.start.offset && parent.sourceSpan.end.offset > el.sourceSpan.end.offset;
25991
+ }
25908
25992
  function calculateNesting(visitor, hasLineBreaks2) {
25909
25993
  let nestedQueue = [];
25910
25994
  for (let i = 0; i < visitor.elements.length; i++) {
@@ -26026,12 +26110,12 @@ function canRemoveCommonModule(template2) {
26026
26110
  }
26027
26111
  return removeCommonModule;
26028
26112
  }
26029
- function removeImports(template2, node, removeCommonModule) {
26030
- if (template2.startsWith("imports") && import_typescript5.default.isPropertyAssignment(node)) {
26031
- const updatedImport = updateClassImports(node, removeCommonModule);
26113
+ function removeImports(template2, node, file) {
26114
+ if (template2.startsWith("imports") && import_typescript6.default.isPropertyAssignment(node)) {
26115
+ const updatedImport = updateClassImports(node, file.removeCommonModule);
26032
26116
  return updatedImport != null ? updatedImport : template2;
26033
- } else if (import_typescript5.default.isImportDeclaration(node) && checkIfShouldChange(node, removeCommonModule)) {
26034
- return updateImportDeclaration(node, removeCommonModule);
26117
+ } else if (import_typescript6.default.isImportDeclaration(node) && checkIfShouldChange(node, file)) {
26118
+ return updateImportDeclaration(node, file.removeCommonModule);
26035
26119
  }
26036
26120
  return template2;
26037
26121
  }
@@ -26091,7 +26175,7 @@ function getMainBlock(etm, tmpl, offset) {
26091
26175
  const { childStart: childStart2, childEnd: childEnd2 } = etm.getChildSpan(offset);
26092
26176
  middle2 = tmpl.slice(childStart2, childEnd2);
26093
26177
  } else {
26094
- middle2 = startMarker + endMarker;
26178
+ middle2 = "";
26095
26179
  }
26096
26180
  return { start: "", middle: middle2, end: "" };
26097
26181
  } else if (isI18nTemplate(etm, i18nAttr)) {
@@ -26136,6 +26220,10 @@ function formatTemplate(tmpl, templateType) {
26136
26220
  let openSelfClosingEl = false;
26137
26221
  const openBlockRegex = /^\s*\@(if|switch|case|default|for)|^\s*\}\s\@else/;
26138
26222
  const openElRegex = /^\s*<([a-z0-9]+)(?![^>]*\/>)[^>]*>?/;
26223
+ const openAttrDoubleRegex = /="([^"]|\\")*$/;
26224
+ const openAttrSingleRegex = /='([^']|\\')*$/;
26225
+ const closeAttrDoubleRegex = /^\s*([^><]|\\")*"/;
26226
+ const closeAttrSingleRegex = /^\s*([^><]|\\')*'/;
26139
26227
  const selfClosingRegex = new RegExp(`^\\s*<(${selfClosingList}).+\\/?>`);
26140
26228
  const openSelfClosingRegex = new RegExp(`^\\s*<(${selfClosingList})(?![^>]*\\/>)[^>]*$`);
26141
26229
  const closeBlockRegex = /^\s*\}\s*$|^\s*\}\s\@else/;
@@ -26151,6 +26239,8 @@ function formatTemplate(tmpl, templateType) {
26151
26239
  let i18nDepth = 0;
26152
26240
  let inMigratedBlock = false;
26153
26241
  let inI18nBlock = false;
26242
+ let inAttribute = false;
26243
+ let isDoubleQuotes = false;
26154
26244
  for (let [index, line] of lines.entries()) {
26155
26245
  depth += [...line.matchAll(startMarkerRegex)].length - [...line.matchAll(endMarkerRegex)].length;
26156
26246
  inMigratedBlock = depth > 0;
@@ -26160,7 +26250,7 @@ function formatTemplate(tmpl, templateType) {
26160
26250
  line = line.replace(replaceMarkerRegex, "");
26161
26251
  lineWasMigrated = true;
26162
26252
  }
26163
- if (line.trim() === "" && index !== 0 && index !== lines.length - 1 && (inMigratedBlock || lineWasMigrated)) {
26253
+ if (line.trim() === "" && index !== 0 && index !== lines.length - 1 && (inMigratedBlock || lineWasMigrated) && !inI18nBlock && !inAttribute) {
26164
26254
  continue;
26165
26255
  }
26166
26256
  if (templateType === "template" && index <= 1) {
@@ -26170,8 +26260,20 @@ function formatTemplate(tmpl, templateType) {
26170
26260
  if ((closeBlockRegex.test(line) || closeElRegex.test(line) && (!singleLineElRegex.test(line) && !closeMultiLineElRegex.test(line))) && indent !== "") {
26171
26261
  indent = indent.slice(2);
26172
26262
  }
26173
- const newLine = inI18nBlock ? line : mindent + (line.trim() !== "" ? indent : "") + line.trim();
26263
+ const isOpenDoubleAttr = openAttrDoubleRegex.test(line);
26264
+ const isOpenSingleAttr = openAttrSingleRegex.test(line);
26265
+ if (!inAttribute && isOpenDoubleAttr) {
26266
+ inAttribute = true;
26267
+ isDoubleQuotes = true;
26268
+ } else if (!inAttribute && isOpenSingleAttr) {
26269
+ inAttribute = true;
26270
+ isDoubleQuotes = false;
26271
+ }
26272
+ const newLine = inI18nBlock || inAttribute ? line : mindent + (line.trim() !== "" ? indent : "") + line.trim();
26174
26273
  formatted.push(newLine);
26274
+ if (!isOpenDoubleAttr && !isOpenSingleAttr && (inAttribute && isDoubleQuotes && closeAttrDoubleRegex.test(line) || inAttribute && !isDoubleQuotes && closeAttrSingleRegex.test(line))) {
26275
+ inAttribute = false;
26276
+ }
26175
26277
  if (closeMultiLineElRegex.test(line)) {
26176
26278
  indent = indent.slice(2);
26177
26279
  if (openSelfClosingEl) {
@@ -26197,7 +26299,7 @@ function formatTemplate(tmpl, templateType) {
26197
26299
  }
26198
26300
  function forEachClass(sourceFile, callback) {
26199
26301
  sourceFile.forEachChild(function walk(node) {
26200
- if (import_typescript5.default.isClassDeclaration(node) || import_typescript5.default.isImportDeclaration(node)) {
26302
+ if (import_typescript6.default.isClassDeclaration(node) || import_typescript6.default.isImportDeclaration(node)) {
26201
26303
  callback(node);
26202
26304
  }
26203
26305
  node.forEachChild(walk);
@@ -26438,10 +26540,10 @@ function getNgForParts(expression) {
26438
26540
  current = "";
26439
26541
  continue;
26440
26542
  }
26441
- if (stringPairs.has(char)) {
26442
- stringStack.push(stringPairs.get(char));
26443
- } else if (stringStack.length > 0 && stringStack[stringStack.length - 1] === char) {
26543
+ if (stringStack.length > 0 && stringStack[stringStack.length - 1] === char) {
26444
26544
  stringStack.pop();
26545
+ } else if (stringPairs.has(char)) {
26546
+ stringStack.push(stringPairs.get(char));
26445
26547
  }
26446
26548
  if (commaSeparatedSyntax.has(char)) {
26447
26549
  commaSeparatedStack.push(commaSeparatedSyntax.get(char));
@@ -26696,13 +26798,9 @@ function migrateTemplate(template2, templateType, node, file, format = true, ana
26696
26798
  migrated = templateResult.migrated;
26697
26799
  const changed = ifResult.changed || forResult.changed || switchResult.changed || caseResult.changed;
26698
26800
  if (changed) {
26699
- const parsed = parseTemplate2(migrated);
26700
- if (parsed.errors.length > 0) {
26701
- const parsingError = {
26702
- type: "parse",
26703
- 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.`)
26704
- };
26705
- return { migrated: template2, errors: [parsingError] };
26801
+ const errors2 = validateMigratedTemplate(migrated, file.sourceFile.fileName);
26802
+ if (errors2.length > 0) {
26803
+ return { migrated: template2, errors: errors2 };
26706
26804
  }
26707
26805
  }
26708
26806
  if (format && changed) {
@@ -26712,11 +26810,14 @@ function migrateTemplate(template2, templateType, node, file, format = true, ana
26712
26810
  migrated = migrated.replace(markerRegex, "");
26713
26811
  file.removeCommonModule = canRemoveCommonModule(template2);
26714
26812
  file.canRemoveImports = true;
26715
- if (templateType === "templateUrl" && analyzedFiles !== null && analyzedFiles.has(file.sourceFilePath)) {
26716
- const componentFile = analyzedFiles.get(file.sourceFilePath);
26813
+ if (templateType === "templateUrl" && analyzedFiles !== null && analyzedFiles.has(file.sourceFile.fileName)) {
26814
+ const componentFile = analyzedFiles.get(file.sourceFile.fileName);
26815
+ componentFile.getSortedRanges();
26717
26816
  componentFile.removeCommonModule = file.removeCommonModule;
26718
26817
  componentFile.canRemoveImports = file.canRemoveImports;
26818
+ componentFile.verifyCanRemoveImports();
26719
26819
  }
26820
+ file.verifyCanRemoveImports();
26720
26821
  errors = [
26721
26822
  ...ifResult.errors,
26722
26823
  ...forResult.errors,
@@ -26724,7 +26825,7 @@ function migrateTemplate(template2, templateType, node, file, format = true, ana
26724
26825
  ...caseResult.errors
26725
26826
  ];
26726
26827
  } else if (file.canRemoveImports) {
26727
- migrated = removeImports(template2, node, file.removeCommonModule);
26828
+ migrated = removeImports(template2, node, file);
26728
26829
  }
26729
26830
  return { migrated, errors };
26730
26831
  }