@angular/core 17.1.0-next.4 → 17.1.0-next.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/esm2022/src/application/application_ref.mjs +4 -8
  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/core.mjs +2 -2
  7. package/esm2022/src/core_private_export.mjs +4 -2
  8. package/esm2022/src/event_emitter.mjs +1 -2
  9. package/esm2022/src/pending_tasks.mjs +57 -0
  10. package/esm2022/src/platform/platform_ref.mjs +2 -2
  11. package/esm2022/src/render3/after_render_hooks.mjs +2 -2
  12. package/esm2022/src/render3/component_ref.mjs +13 -9
  13. package/esm2022/src/render3/instructions/control_flow.mjs +5 -3
  14. package/esm2022/src/render3/instructions/mark_view_dirty.mjs +3 -2
  15. package/esm2022/src/render3/instructions/shared.mjs +3 -2
  16. package/esm2022/src/render3/interfaces/view.mjs +1 -1
  17. package/esm2022/src/render3/util/view_utils.mjs +18 -5
  18. package/esm2022/src/render3/view_ref.mjs +2 -1
  19. package/esm2022/src/version.mjs +6 -5
  20. package/esm2022/src/zone/ng_zone.mjs +1 -61
  21. package/esm2022/testing/src/logger.mjs +3 -3
  22. package/fesm2022/core.mjs +176 -138
  23. package/fesm2022/core.mjs.map +1 -1
  24. package/fesm2022/primitives/signals.mjs +1 -1
  25. package/fesm2022/rxjs-interop.mjs +1 -1
  26. package/fesm2022/testing.mjs +1 -1
  27. package/index.d.ts +41 -23
  28. package/package.json +1 -1
  29. package/primitives/signals/index.d.ts +1 -1
  30. package/rxjs-interop/index.d.ts +1 -1
  31. package/schematics/migrations/block-template-entities/bundle.js +378 -278
  32. package/schematics/migrations/block-template-entities/bundle.js.map +4 -4
  33. package/schematics/ng-generate/control-flow-migration/bundle.js +543 -344
  34. package/schematics/ng-generate/control-flow-migration/bundle.js.map +4 -4
  35. package/schematics/ng-generate/standalone-migration/bundle.js +412 -266
  36. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  37. package/testing/index.d.ts +1 -1
  38. package/esm2022/src/change_detection/scheduling.mjs +0 -103
  39. 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
  }
@@ -3443,13 +3443,17 @@ var TagContentType;
3443
3443
  TagContentType2[TagContentType2["ESCAPABLE_RAW_TEXT"] = 1] = "ESCAPABLE_RAW_TEXT";
3444
3444
  TagContentType2[TagContentType2["PARSABLE_DATA"] = 2] = "PARSABLE_DATA";
3445
3445
  })(TagContentType || (TagContentType = {}));
3446
- function splitNsName(elementName) {
3446
+ function splitNsName(elementName, fatal = true) {
3447
3447
  if (elementName[0] != ":") {
3448
3448
  return [null, elementName];
3449
3449
  }
3450
3450
  const colonIndex = elementName.indexOf(":", 1);
3451
3451
  if (colonIndex === -1) {
3452
- throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
3452
+ if (fatal) {
3453
+ throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
3454
+ } else {
3455
+ return [null, elementName];
3456
+ }
3453
3457
  }
3454
3458
  return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)];
3455
3459
  }
@@ -3956,28 +3960,6 @@ var BlockPlaceholder = class {
3956
3960
  return visitor.visitBlockPlaceholder(this, context);
3957
3961
  }
3958
3962
  };
3959
- var RecurseVisitor = class {
3960
- visitText(text2, context) {
3961
- }
3962
- visitContainer(container, context) {
3963
- container.children.forEach((child) => child.visit(this));
3964
- }
3965
- visitIcu(icu, context) {
3966
- Object.keys(icu.cases).forEach((k) => {
3967
- icu.cases[k].visit(this);
3968
- });
3969
- }
3970
- visitTagPlaceholder(ph, context) {
3971
- ph.children.forEach((child) => child.visit(this));
3972
- }
3973
- visitPlaceholder(ph, context) {
3974
- }
3975
- visitIcuPlaceholder(ph, context) {
3976
- }
3977
- visitBlockPlaceholder(ph, context) {
3978
- ph.children.forEach((child) => child.visit(this));
3979
- }
3980
- };
3981
3963
  function serializeMessage(messageNodes) {
3982
3964
  const visitor = new LocalizeMessageStringVisitor();
3983
3965
  const str = messageNodes.map((n) => n.visit(visitor)).join("");
@@ -7045,8 +7027,9 @@ var OpKind;
7045
7027
  OpKind2[OpKind2["I18nApply"] = 40] = "I18nApply";
7046
7028
  OpKind2[OpKind2["IcuStart"] = 41] = "IcuStart";
7047
7029
  OpKind2[OpKind2["IcuEnd"] = 42] = "IcuEnd";
7048
- OpKind2[OpKind2["I18nContext"] = 43] = "I18nContext";
7049
- OpKind2[OpKind2["I18nAttributes"] = 44] = "I18nAttributes";
7030
+ OpKind2[OpKind2["IcuPlaceholder"] = 43] = "IcuPlaceholder";
7031
+ OpKind2[OpKind2["I18nContext"] = 44] = "I18nContext";
7032
+ OpKind2[OpKind2["I18nAttributes"] = 45] = "I18nAttributes";
7050
7033
  })(OpKind || (OpKind = {}));
7051
7034
  var ExpressionKind;
7052
7035
  (function(ExpressionKind2) {
@@ -7350,15 +7333,15 @@ function createRepeaterOp(repeaterCreate2, targetSlot, collection, sourceSpan) {
7350
7333
  }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
7351
7334
  }
7352
7335
  function createDeferWhenOp(target, expr, prefetch, sourceSpan) {
7353
- return __spreadValues(__spreadValues({
7336
+ return __spreadValues(__spreadValues(__spreadValues({
7354
7337
  kind: OpKind.DeferWhen,
7355
7338
  target,
7356
7339
  expr,
7357
7340
  prefetch,
7358
7341
  sourceSpan
7359
- }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
7342
+ }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS);
7360
7343
  }
7361
- function createI18nExpressionOp(context, target, i18nOwner, handle, expression, i18nPlaceholder, resolutionTime, usage, name, sourceSpan) {
7344
+ function createI18nExpressionOp(context, target, i18nOwner, handle, expression, icuPlaceholder, i18nPlaceholder, resolutionTime, usage, name, sourceSpan) {
7362
7345
  return __spreadValues(__spreadValues(__spreadValues({
7363
7346
  kind: OpKind.I18nExpression,
7364
7347
  context,
@@ -7366,6 +7349,7 @@ function createI18nExpressionOp(context, target, i18nOwner, handle, expression,
7366
7349
  i18nOwner,
7367
7350
  handle,
7368
7351
  expression,
7352
+ icuPlaceholder,
7369
7353
  i18nPlaceholder,
7370
7354
  resolutionTime,
7371
7355
  usage,
@@ -8098,6 +8082,9 @@ function transformExpressionsInOp(op, transform2, flags) {
8098
8082
  if (op.placeholderConfig !== null) {
8099
8083
  op.placeholderConfig = transformExpressionsInExpression(op.placeholderConfig, transform2, flags);
8100
8084
  }
8085
+ if (op.resolverFn !== null) {
8086
+ op.resolverFn = transformExpressionsInExpression(op.resolverFn, transform2, flags);
8087
+ }
8101
8088
  break;
8102
8089
  case OpKind.I18nMessage:
8103
8090
  for (const [placeholder, expr] of op.params) {
@@ -8134,6 +8121,7 @@ function transformExpressionsInOp(op, transform2, flags) {
8134
8121
  case OpKind.Template:
8135
8122
  case OpKind.Text:
8136
8123
  case OpKind.I18nAttributes:
8124
+ case OpKind.IcuPlaceholder:
8137
8125
  break;
8138
8126
  default:
8139
8127
  throw new Error(`AssertionError: transformExpressionsInOp doesn't handle ${OpKind[op.kind]}`);
@@ -8191,6 +8179,14 @@ function transformExpressionsInExpression(expr, transform2, flags) {
8191
8179
  } else if (expr instanceof TaggedTemplateExpr) {
8192
8180
  expr.tag = transformExpressionsInExpression(expr.tag, transform2, flags);
8193
8181
  expr.template.expressions = expr.template.expressions.map((e) => transformExpressionsInExpression(e, transform2, flags));
8182
+ } else if (expr instanceof ArrowFunctionExpr) {
8183
+ if (Array.isArray(expr.body)) {
8184
+ for (let i = 0; i < expr.body.length; i++) {
8185
+ transformExpressionsInStatement(expr.body[i], transform2, flags);
8186
+ }
8187
+ } else {
8188
+ expr.body = transformExpressionsInExpression(expr.body, transform2, flags);
8189
+ }
8194
8190
  } else if (expr instanceof WrappedNodeExpr) {
8195
8191
  } else if (expr instanceof ReadVarExpr || expr instanceof ExternalExpr || expr instanceof LiteralExpr) {
8196
8192
  } else {
@@ -8433,7 +8429,7 @@ var elementContainerOpKinds = /* @__PURE__ */ new Set([
8433
8429
  function isElementOrContainerOp(op) {
8434
8430
  return elementContainerOpKinds.has(op.kind);
8435
8431
  }
8436
- function createElementStartOp(tag, xref, namespace, i18nPlaceholder, sourceSpan) {
8432
+ function createElementStartOp(tag, xref, namespace, i18nPlaceholder, startSourceSpan, wholeSourceSpan) {
8437
8433
  return __spreadValues(__spreadValues({
8438
8434
  kind: OpKind.ElementStart,
8439
8435
  xref,
@@ -8444,10 +8440,11 @@ function createElementStartOp(tag, xref, namespace, i18nPlaceholder, sourceSpan)
8444
8440
  nonBindable: false,
8445
8441
  namespace,
8446
8442
  i18nPlaceholder,
8447
- sourceSpan
8443
+ startSourceSpan,
8444
+ wholeSourceSpan
8448
8445
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8449
8446
  }
8450
- function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace, i18nPlaceholder, sourceSpan) {
8447
+ function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace, i18nPlaceholder, startSourceSpan, wholeSourceSpan) {
8451
8448
  return __spreadValues(__spreadValues({
8452
8449
  kind: OpKind.Template,
8453
8450
  xref,
@@ -8462,11 +8459,12 @@ function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace
8462
8459
  nonBindable: false,
8463
8460
  namespace,
8464
8461
  i18nPlaceholder,
8465
- sourceSpan
8462
+ startSourceSpan,
8463
+ wholeSourceSpan
8466
8464
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8467
8465
  }
8468
- function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, sourceSpan) {
8469
- return __spreadProps(__spreadValues(__spreadValues({
8466
+ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, emptyTag, i18nPlaceholder, emptyI18nPlaceholder, startSourceSpan, wholeSourceSpan) {
8467
+ return __spreadProps(__spreadValues(__spreadValues(__spreadValues({
8470
8468
  kind: OpKind.RepeaterCreate,
8471
8469
  attributes: null,
8472
8470
  xref: primaryView,
@@ -8475,6 +8473,8 @@ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i1
8475
8473
  track,
8476
8474
  trackByFn: null,
8477
8475
  tag,
8476
+ emptyTag,
8477
+ emptyAttributes: null,
8478
8478
  functionNameSuffix: "For",
8479
8479
  namespace: Namespace.HTML,
8480
8480
  nonBindable: false,
@@ -8485,8 +8485,9 @@ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i1
8485
8485
  usesComponentInstance: false,
8486
8486
  i18nPlaceholder,
8487
8487
  emptyI18nPlaceholder,
8488
- sourceSpan
8489
- }, TRAIT_CONSUMES_SLOT), NEW_OP), {
8488
+ startSourceSpan,
8489
+ wholeSourceSpan
8490
+ }, TRAIT_CONSUMES_SLOT), NEW_OP), TRAIT_CONSUMES_VARS), {
8490
8491
  numSlotsUsed: emptyView === null ? 2 : 3
8491
8492
  });
8492
8493
  }
@@ -8509,12 +8510,13 @@ function createEnableBindingsOp(xref) {
8509
8510
  xref
8510
8511
  }, NEW_OP);
8511
8512
  }
8512
- function createTextOp(xref, initialValue, sourceSpan) {
8513
+ function createTextOp(xref, initialValue, icuPlaceholder, sourceSpan) {
8513
8514
  return __spreadValues(__spreadValues({
8514
8515
  kind: OpKind.Text,
8515
8516
  xref,
8516
8517
  handle: new SlotHandle(),
8517
8518
  initialValue,
8519
+ icuPlaceholder,
8518
8520
  sourceSpan
8519
8521
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8520
8522
  }
@@ -8557,7 +8559,7 @@ function createProjectionDefOp(def) {
8557
8559
  def
8558
8560
  }, NEW_OP);
8559
8561
  }
8560
- function createProjectionOp(xref, selector, i18nPlaceholder, attributes, sourceSpan) {
8562
+ function createProjectionOp(xref, selector, i18nPlaceholder, sourceSpan) {
8561
8563
  return __spreadValues(__spreadValues({
8562
8564
  kind: OpKind.Projection,
8563
8565
  xref,
@@ -8565,7 +8567,7 @@ function createProjectionOp(xref, selector, i18nPlaceholder, attributes, sourceS
8565
8567
  selector,
8566
8568
  i18nPlaceholder,
8567
8569
  projectionSlotIndex: 0,
8568
- attributes,
8570
+ attributes: null,
8569
8571
  localRefs: [],
8570
8572
  sourceSpan
8571
8573
  }, NEW_OP), TRAIT_CONSUMES_SLOT);
@@ -8631,7 +8633,7 @@ function createI18nMessageOp(xref, i18nContext, i18nBlock, message, messagePlace
8631
8633
  subMessages: []
8632
8634
  }, NEW_OP);
8633
8635
  }
8634
- function createI18nStartOp(xref, message, root) {
8636
+ function createI18nStartOp(xref, message, root, sourceSpan) {
8635
8637
  return __spreadValues(__spreadValues({
8636
8638
  kind: OpKind.I18nStart,
8637
8639
  xref,
@@ -8640,13 +8642,15 @@ function createI18nStartOp(xref, message, root) {
8640
8642
  message,
8641
8643
  messageIndex: null,
8642
8644
  subTemplateIndex: null,
8643
- context: null
8645
+ context: null,
8646
+ sourceSpan
8644
8647
  }, NEW_OP), TRAIT_CONSUMES_SLOT);
8645
8648
  }
8646
- function createI18nEndOp(xref) {
8649
+ function createI18nEndOp(xref, sourceSpan) {
8647
8650
  return __spreadValues({
8648
8651
  kind: OpKind.I18nEnd,
8649
- xref
8652
+ xref,
8653
+ sourceSpan
8650
8654
  }, NEW_OP);
8651
8655
  }
8652
8656
  function createIcuStartOp(xref, message, messagePlaceholder, sourceSpan) {
@@ -8665,6 +8669,15 @@ function createIcuEndOp(xref) {
8665
8669
  xref
8666
8670
  }, NEW_OP);
8667
8671
  }
8672
+ function createIcuPlaceholderOp(xref, name, strings) {
8673
+ return __spreadValues({
8674
+ kind: OpKind.IcuPlaceholder,
8675
+ xref,
8676
+ name,
8677
+ strings,
8678
+ expressionPlaceholders: []
8679
+ }, NEW_OP);
8680
+ }
8668
8681
  function createI18nContextOp(contextKind, xref, i18nBlock, message, sourceSpan) {
8669
8682
  if (i18nBlock === null && contextKind !== I18nContextKind.Attr) {
8670
8683
  throw new Error("AssertionError: i18nBlock must be provided for non-attribute contexts.");
@@ -8928,6 +8941,9 @@ function createOpXrefMap(unit) {
8928
8941
  continue;
8929
8942
  }
8930
8943
  map.set(op.xref, op);
8944
+ if (op.kind === OpKind.RepeaterCreate && op.emptyView !== null) {
8945
+ map.set(op.emptyView, op);
8946
+ }
8931
8947
  }
8932
8948
  return map;
8933
8949
  }
@@ -8991,6 +9007,9 @@ function extractAttributes(job) {
8991
9007
  SecurityContext.NONE
8992
9008
  );
8993
9009
  if (job.kind === CompilationJobKind.Host) {
9010
+ if (job.compatibility) {
9011
+ break;
9012
+ }
8994
9013
  unit.create.push(extractedAttributeOp);
8995
9014
  } else {
8996
9015
  OpList.insertBefore(extractedAttributeOp, lookupElement(elements, op.target));
@@ -9012,15 +9031,9 @@ function extractAttributeOp(unit, op, elements) {
9012
9031
  if (op.expression instanceof Interpolation2) {
9013
9032
  return;
9014
9033
  }
9015
- let extractable = op.expression.isConstant();
9034
+ let extractable = op.isTextAttribute || op.expression.isConstant();
9016
9035
  if (unit.job.compatibility === CompatibilityMode.TemplateDefinitionBuilder) {
9017
- extractable = isStringLiteral(op.expression);
9018
- if (op.name === "style" || op.name === "class") {
9019
- extractable && (extractable = op.isTextAttribute);
9020
- }
9021
- if (unit.job.kind === CompilationJobKind.Host) {
9022
- extractable && (extractable = op.isTextAttribute);
9023
- }
9036
+ extractable && (extractable = op.isTextAttribute);
9024
9037
  }
9025
9038
  if (extractable) {
9026
9039
  const extractedAttributeOp = createExtractedAttributeOp(op.target, op.isStructuralTemplateAttribute ? BindingKind.Template : BindingKind.Attribute, op.name, op.expression, op.i18nContext, op.i18nMessage, op.securityContext);
@@ -9255,7 +9268,7 @@ function collectElementConsts(job) {
9255
9268
  for (const unit of job.units) {
9256
9269
  for (const op of unit.create) {
9257
9270
  if (op.kind === OpKind.ExtractedAttribute) {
9258
- const attributes = allElementAttributes.get(op.target) || new ElementAttributes();
9271
+ const attributes = allElementAttributes.get(op.target) || new ElementAttributes(job.compatibility);
9259
9272
  allElementAttributes.set(op.target, attributes);
9260
9273
  attributes.add(op.bindingKind, op.name, op.expression, op.trustedValueFn);
9261
9274
  OpList.remove(op);
@@ -9265,14 +9278,19 @@ function collectElementConsts(job) {
9265
9278
  if (job instanceof ComponentCompilationJob) {
9266
9279
  for (const unit of job.units) {
9267
9280
  for (const op of unit.create) {
9268
- if (isElementOrContainerOp(op)) {
9281
+ if (op.kind == OpKind.Projection) {
9269
9282
  const attributes = allElementAttributes.get(op.xref);
9270
9283
  if (attributes !== void 0) {
9271
9284
  const attrArray = serializeAttributes(attributes);
9272
9285
  if (attrArray.entries.length > 0) {
9273
- op.attributes = job.addConst(attrArray);
9286
+ op.attributes = attrArray;
9274
9287
  }
9275
9288
  }
9289
+ } else if (isElementOrContainerOp(op)) {
9290
+ op.attributes = getConstIndex(job, allElementAttributes, op.xref);
9291
+ if (op.kind === OpKind.RepeaterCreate && op.emptyView !== null) {
9292
+ op.emptyAttributes = getConstIndex(job, allElementAttributes, op.emptyView);
9293
+ }
9276
9294
  }
9277
9295
  }
9278
9296
  }
@@ -9288,13 +9306,18 @@ function collectElementConsts(job) {
9288
9306
  }
9289
9307
  }
9290
9308
  }
9309
+ function getConstIndex(job, allElementAttributes, xref) {
9310
+ const attributes = allElementAttributes.get(xref);
9311
+ if (attributes !== void 0) {
9312
+ const attrArray = serializeAttributes(attributes);
9313
+ if (attrArray.entries.length > 0) {
9314
+ return job.addConst(attrArray);
9315
+ }
9316
+ }
9317
+ return null;
9318
+ }
9291
9319
  var FLYWEIGHT_ARRAY = Object.freeze([]);
9292
9320
  var ElementAttributes = class {
9293
- constructor() {
9294
- this.known = /* @__PURE__ */ new Set();
9295
- this.byKind = /* @__PURE__ */ new Map();
9296
- this.projectAs = null;
9297
- }
9298
9321
  get attributes() {
9299
9322
  var _a2;
9300
9323
  return (_a2 = this.byKind.get(BindingKind.Attribute)) != null ? _a2 : FLYWEIGHT_ARRAY;
@@ -9319,12 +9342,28 @@ var ElementAttributes = class {
9319
9342
  var _a2;
9320
9343
  return (_a2 = this.byKind.get(BindingKind.I18n)) != null ? _a2 : FLYWEIGHT_ARRAY;
9321
9344
  }
9345
+ constructor(compatibility) {
9346
+ this.compatibility = compatibility;
9347
+ this.known = /* @__PURE__ */ new Map();
9348
+ this.byKind = /* @__PURE__ */ new Map();
9349
+ this.projectAs = null;
9350
+ }
9351
+ isKnown(kind, name, value) {
9352
+ var _a2;
9353
+ const nameToValue = (_a2 = this.known.get(kind)) != null ? _a2 : /* @__PURE__ */ new Set();
9354
+ this.known.set(kind, nameToValue);
9355
+ if (nameToValue.has(name)) {
9356
+ return true;
9357
+ }
9358
+ nameToValue.add(name);
9359
+ return false;
9360
+ }
9322
9361
  add(kind, name, value, trustedValueFn) {
9323
9362
  var _a2;
9324
- if (this.known.has(name)) {
9363
+ const allowDuplicates = this.compatibility === CompatibilityMode.TemplateDefinitionBuilder && (kind === BindingKind.Attribute || kind === BindingKind.ClassName || kind === BindingKind.StyleProperty);
9364
+ if (!allowDuplicates && this.isKnown(kind, name, value)) {
9325
9365
  return;
9326
9366
  }
9327
- this.known.add(name);
9328
9367
  if (name === "ngProjectAs") {
9329
9368
  if (value === null || !(value instanceof LiteralExpr) || value.value == null || typeof ((_a2 = value.value) == null ? void 0 : _a2.toString()) !== "string") {
9330
9369
  throw Error("ngProjectAs must have a string literal value");
@@ -9355,7 +9394,7 @@ var ElementAttributes = class {
9355
9394
  }
9356
9395
  };
9357
9396
  function getAttributeNameLiterals(name) {
9358
- const [attributeNamespace, attributeName] = splitNsName(name);
9397
+ const [attributeNamespace, attributeName] = splitNsName(name, false);
9359
9398
  const nameLiteral = literal(attributeName);
9360
9399
  if (attributeNamespace) {
9361
9400
  return [
@@ -9422,7 +9461,7 @@ function convertI18nBindings(job) {
9422
9461
  if (op.expression.i18nPlaceholders.length !== op.expression.expressions.length) {
9423
9462
  throw new Error(`AssertionError: An i18n attribute binding instruction requires the same number of expressions and placeholders, but found ${op.expression.i18nPlaceholders.length} placeholders and ${op.expression.expressions.length} expressions`);
9424
9463
  }
9425
- ops.push(createI18nExpressionOp(op.i18nContext, i18nAttributesForElem.target, i18nAttributesForElem.xref, i18nAttributesForElem.handle, expr, op.expression.i18nPlaceholders[i], I18nParamResolutionTime.Creation, I18nExpressionFor.I18nAttribute, op.name, op.sourceSpan));
9464
+ ops.push(createI18nExpressionOp(op.i18nContext, i18nAttributesForElem.target, i18nAttributesForElem.xref, i18nAttributesForElem.handle, expr, null, op.expression.i18nPlaceholders[i], I18nParamResolutionTime.Creation, I18nExpressionFor.I18nAttribute, op.name, op.sourceSpan));
9426
9465
  }
9427
9466
  OpList.replaceWithMany(op, ops);
9428
9467
  break;
@@ -9453,7 +9492,11 @@ function createDeferDepsFns(job) {
9453
9492
  if (op.handle.slot === null) {
9454
9493
  throw new Error("AssertionError: slot must be assigned bfore extracting defer deps functions");
9455
9494
  }
9456
- op.resolverFn = job.pool.getSharedFunctionReference(depsFnExpr, `${job.componentName}_Defer_${op.handle.slot}_DepsFn`);
9495
+ op.resolverFn = job.pool.getSharedFunctionReference(
9496
+ depsFnExpr,
9497
+ `${job.componentName}_Defer_${op.handle.slot}_DepsFn`,
9498
+ false
9499
+ );
9457
9500
  }
9458
9501
  }
9459
9502
  }
@@ -9461,62 +9504,99 @@ function createDeferDepsFns(job) {
9461
9504
 
9462
9505
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/create_i18n_contexts.mjs
9463
9506
  function createI18nContexts(job) {
9464
- const rootContexts = /* @__PURE__ */ new Map();
9465
- let currentI18nOp = null;
9466
- let xref;
9467
- const messageToContext = /* @__PURE__ */ new Map();
9507
+ const attrContextByMessage = /* @__PURE__ */ new Map();
9508
+ for (const unit of job.units) {
9509
+ for (const op of unit.ops()) {
9510
+ switch (op.kind) {
9511
+ case OpKind.Binding:
9512
+ case OpKind.Property:
9513
+ case OpKind.Attribute:
9514
+ case OpKind.ExtractedAttribute:
9515
+ if (op.i18nMessage === null) {
9516
+ continue;
9517
+ }
9518
+ if (!attrContextByMessage.has(op.i18nMessage)) {
9519
+ const i18nContext = createI18nContextOp(I18nContextKind.Attr, job.allocateXrefId(), null, op.i18nMessage, null);
9520
+ unit.create.push(i18nContext);
9521
+ attrContextByMessage.set(op.i18nMessage, i18nContext.xref);
9522
+ }
9523
+ op.i18nContext = attrContextByMessage.get(op.i18nMessage);
9524
+ break;
9525
+ }
9526
+ }
9527
+ }
9528
+ const blockContextByI18nBlock = /* @__PURE__ */ new Map();
9468
9529
  for (const unit of job.units) {
9469
9530
  for (const op of unit.create) {
9470
9531
  switch (op.kind) {
9471
9532
  case OpKind.I18nStart:
9472
- currentI18nOp = op;
9473
9533
  if (op.xref === op.root) {
9474
- xref = job.allocateXrefId();
9475
- unit.create.push(createI18nContextOp(I18nContextKind.RootI18n, xref, op.xref, op.message, null));
9476
- op.context = xref;
9477
- rootContexts.set(op.xref, xref);
9534
+ const contextOp = createI18nContextOp(I18nContextKind.RootI18n, job.allocateXrefId(), op.xref, op.message, null);
9535
+ unit.create.push(contextOp);
9536
+ op.context = contextOp.xref;
9537
+ blockContextByI18nBlock.set(op.xref, contextOp);
9478
9538
  }
9479
9539
  break;
9540
+ }
9541
+ }
9542
+ }
9543
+ for (const unit of job.units) {
9544
+ for (const op of unit.create) {
9545
+ if (op.kind === OpKind.I18nStart && op.xref !== op.root) {
9546
+ const rootContext = blockContextByI18nBlock.get(op.root);
9547
+ if (rootContext === void 0) {
9548
+ throw Error("AssertionError: Root i18n block i18n context should have been created.");
9549
+ }
9550
+ op.context = rootContext.xref;
9551
+ blockContextByI18nBlock.set(op.xref, rootContext);
9552
+ }
9553
+ }
9554
+ }
9555
+ let currentI18nOp = null;
9556
+ for (const unit of job.units) {
9557
+ for (const op of unit.create) {
9558
+ switch (op.kind) {
9559
+ case OpKind.I18nStart:
9560
+ currentI18nOp = op;
9561
+ break;
9480
9562
  case OpKind.I18nEnd:
9481
9563
  currentI18nOp = null;
9482
9564
  break;
9483
9565
  case OpKind.IcuStart:
9484
9566
  if (currentI18nOp === null) {
9485
- throw Error("Unexpected ICU outside of an i18n block.");
9567
+ throw Error("AssertionError: Unexpected ICU outside of an i18n block.");
9486
9568
  }
9487
9569
  if (op.message.id !== currentI18nOp.message.id) {
9488
- xref = job.allocateXrefId();
9489
- unit.create.push(createI18nContextOp(I18nContextKind.Icu, xref, currentI18nOp.xref, op.message, null));
9490
- op.context = xref;
9570
+ const contextOp = createI18nContextOp(I18nContextKind.Icu, job.allocateXrefId(), currentI18nOp.xref, op.message, null);
9571
+ unit.create.push(contextOp);
9572
+ op.context = contextOp.xref;
9491
9573
  } else {
9492
9574
  op.context = currentI18nOp.context;
9575
+ blockContextByI18nBlock.get(currentI18nOp.xref).contextKind = I18nContextKind.Icu;
9493
9576
  }
9494
9577
  break;
9495
9578
  }
9496
9579
  }
9497
- for (const op of unit.ops()) {
9498
- switch (op.kind) {
9499
- case OpKind.Binding:
9500
- case OpKind.Property:
9501
- case OpKind.Attribute:
9502
- case OpKind.ExtractedAttribute:
9503
- if (!op.i18nMessage) {
9504
- continue;
9505
- }
9506
- if (!messageToContext.has(op.i18nMessage)) {
9507
- const i18nContext = job.allocateXrefId();
9508
- unit.create.push(createI18nContextOp(I18nContextKind.Attr, i18nContext, null, op.i18nMessage, null));
9509
- messageToContext.set(op.i18nMessage, i18nContext);
9510
- }
9511
- op.i18nContext = messageToContext.get(op.i18nMessage);
9512
- break;
9513
- }
9514
- }
9515
9580
  }
9581
+ }
9582
+
9583
+ // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/deduplicate_text_bindings.mjs
9584
+ function deduplicateTextBindings(job) {
9585
+ const seen = /* @__PURE__ */ new Map();
9516
9586
  for (const unit of job.units) {
9517
- for (const op of unit.create) {
9518
- if (op.kind === OpKind.I18nStart && op.xref !== op.root) {
9519
- op.context = rootContexts.get(op.root);
9587
+ for (const op of unit.update.reversed()) {
9588
+ if (op.kind === OpKind.Binding && op.isTextAttribute) {
9589
+ const seenForElement = seen.get(op.target) || /* @__PURE__ */ new Set();
9590
+ if (seenForElement.has(op.name)) {
9591
+ if (job.compatibility === CompatibilityMode.TemplateDefinitionBuilder) {
9592
+ if (op.name === "style" || op.name === "class") {
9593
+ OpList.remove(op);
9594
+ }
9595
+ } else {
9596
+ }
9597
+ }
9598
+ seenForElement.add(op.name);
9599
+ seen.set(op.target, seenForElement);
9520
9600
  }
9521
9601
  }
9522
9602
  }
@@ -9806,12 +9886,16 @@ var LIST_START_MARKER = "[";
9806
9886
  var LIST_END_MARKER = "]";
9807
9887
  var LIST_DELIMITER = "|";
9808
9888
  function extractI18nMessages(job) {
9809
- const i18nContexts = /* @__PURE__ */ new Map();
9889
+ const i18nMessagesByContext = /* @__PURE__ */ new Map();
9810
9890
  const i18nBlocks = /* @__PURE__ */ new Map();
9891
+ const i18nContexts = /* @__PURE__ */ new Map();
9811
9892
  for (const unit of job.units) {
9812
9893
  for (const op of unit.create) {
9813
9894
  switch (op.kind) {
9814
9895
  case OpKind.I18nContext:
9896
+ const i18nMessageOp = createI18nMessage(job, op);
9897
+ unit.create.push(i18nMessageOp);
9898
+ i18nMessagesByContext.set(op.xref, i18nMessageOp);
9815
9899
  i18nContexts.set(op.xref, op);
9816
9900
  break;
9817
9901
  case OpKind.I18nStart:
@@ -9820,49 +9904,40 @@ function extractI18nMessages(job) {
9820
9904
  }
9821
9905
  }
9822
9906
  }
9823
- for (const unit of job.units) {
9824
- for (const op of unit.create) {
9825
- if (op.kind !== OpKind.I18nContext || op.contextKind !== I18nContextKind.Attr) {
9826
- continue;
9827
- }
9828
- const i18nMessageOp = createI18nMessage(job, op);
9829
- unit.create.push(i18nMessageOp);
9830
- }
9831
- }
9832
- const i18nBlockMessages = /* @__PURE__ */ new Map();
9833
- for (const unit of job.units) {
9834
- for (const op of unit.create) {
9835
- if (op.kind === OpKind.I18nStart && op.xref === op.root) {
9836
- if (!op.context) {
9837
- throw Error("I18n start op should have its context set.");
9838
- }
9839
- const i18nMessageOp = createI18nMessage(job, i18nContexts.get(op.context));
9840
- i18nBlockMessages.set(op.xref, i18nMessageOp);
9841
- unit.create.push(i18nMessageOp);
9842
- }
9843
- }
9844
- }
9907
+ let currentIcu = null;
9845
9908
  for (const unit of job.units) {
9846
9909
  for (const op of unit.create) {
9847
9910
  switch (op.kind) {
9848
9911
  case OpKind.IcuStart:
9849
- if (!op.context) {
9850
- throw Error("ICU op should have its context set.");
9912
+ currentIcu = op;
9913
+ OpList.remove(op);
9914
+ const icuContext = i18nContexts.get(op.context);
9915
+ if (icuContext.contextKind !== I18nContextKind.Icu) {
9916
+ continue;
9851
9917
  }
9852
- const i18nContext = i18nContexts.get(op.context);
9853
- if (i18nContext.contextKind === I18nContextKind.Icu) {
9854
- if (i18nContext.i18nBlock === null) {
9855
- throw Error("ICU context should have its i18n block set.");
9856
- }
9857
- const subMessage = createI18nMessage(job, i18nContext, op.messagePlaceholder);
9858
- unit.create.push(subMessage);
9859
- const rootI18nId = i18nBlocks.get(i18nContext.i18nBlock).root;
9860
- const parentMessage = i18nBlockMessages.get(rootI18nId);
9861
- parentMessage == null ? void 0 : parentMessage.subMessages.push(subMessage.xref);
9918
+ const i18nBlock = i18nBlocks.get(icuContext.i18nBlock);
9919
+ if (i18nBlock.context === icuContext.xref) {
9920
+ continue;
9862
9921
  }
9863
- OpList.remove(op);
9922
+ const rootI18nBlock = i18nBlocks.get(i18nBlock.root);
9923
+ const rootMessage = i18nMessagesByContext.get(rootI18nBlock.context);
9924
+ if (rootMessage === void 0) {
9925
+ throw Error("AssertionError: ICU sub-message should belong to a root message.");
9926
+ }
9927
+ const subMessage = i18nMessagesByContext.get(icuContext.xref);
9928
+ subMessage.messagePlaceholder = op.messagePlaceholder;
9929
+ rootMessage.subMessages.push(subMessage.xref);
9864
9930
  break;
9865
9931
  case OpKind.IcuEnd:
9932
+ currentIcu = null;
9933
+ OpList.remove(op);
9934
+ break;
9935
+ case OpKind.IcuPlaceholder:
9936
+ if (currentIcu === null || currentIcu.context == null) {
9937
+ throw Error("AssertionError: Unexpected ICU placeholder outside of i18n context");
9938
+ }
9939
+ const msg = i18nMessagesByContext.get(currentIcu.context);
9940
+ msg.postprocessingParams.set(op.name, literal(formatIcuPlaceholder(op)));
9866
9941
  OpList.remove(op);
9867
9942
  break;
9868
9943
  }
@@ -9872,14 +9947,16 @@ function extractI18nMessages(job) {
9872
9947
  function createI18nMessage(job, context, messagePlaceholder) {
9873
9948
  let formattedParams = formatParams(context.params);
9874
9949
  const formattedPostprocessingParams = formatParams(context.postprocessingParams);
9875
- let needsPostprocessing = formattedPostprocessingParams.size > 0;
9876
- for (const values of context.params.values()) {
9877
- if (values.length > 1) {
9878
- needsPostprocessing = true;
9879
- }
9880
- }
9950
+ let needsPostprocessing = [...context.params.values()].some((v) => v.length > 1);
9881
9951
  return createI18nMessageOp(job.allocateXrefId(), context.xref, context.i18nBlock, context.message, messagePlaceholder != null ? messagePlaceholder : null, formattedParams, formattedPostprocessingParams, needsPostprocessing);
9882
9952
  }
9953
+ function formatIcuPlaceholder(op) {
9954
+ if (op.strings.length !== op.expressionPlaceholders.length + 1) {
9955
+ throw Error(`AsserionError: Invalid ICU placeholder with ${op.strings.length} strings and ${op.expressionPlaceholders.length} expressions`);
9956
+ }
9957
+ const values = op.expressionPlaceholders.map(formatValue);
9958
+ return op.strings.flatMap((str, i) => [str, values[i] || ""]).join("");
9959
+ }
9883
9960
  function formatParams(params) {
9884
9961
  const formattedParams = /* @__PURE__ */ new Map();
9885
9962
  for (const [placeholder, placeholderValues] of params) {
@@ -10106,7 +10183,7 @@ var CLASS_BANG = "class!";
10106
10183
  var BANG_IMPORTANT = "!important";
10107
10184
  function parseHostStyleProperties(job) {
10108
10185
  for (const op of job.root.update) {
10109
- if (op.kind !== OpKind.Binding) {
10186
+ if (!(op.kind === OpKind.Binding && op.bindingKind === BindingKind.Property)) {
10110
10187
  continue;
10111
10188
  }
10112
10189
  if (op.name.endsWith(BANG_IMPORTANT)) {
@@ -16248,7 +16325,7 @@ function collectMessage(job, fileBasedI18nSuffix, messages, messageOp) {
16248
16325
  const mainVar = variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX2));
16249
16326
  const closureVar = i18nGenerateClosureVar(job.pool, messageOp.message.id, fileBasedI18nSuffix, job.i18nUseExternalIds);
16250
16327
  let transformFn = void 0;
16251
- if (messageOp.needsPostprocessing) {
16328
+ if (messageOp.needsPostprocessing || messageOp.postprocessingParams.size > 0) {
16252
16329
  const postprocessingParams = Object.fromEntries([...messageOp.postprocessingParams.entries()].sort());
16253
16330
  const formattedPostprocessingParams = formatI18nPlaceholderNamesInMap(postprocessingParams, false);
16254
16331
  const extraTransformFnParams = [];
@@ -16267,7 +16344,6 @@ function addSubMessageParams(messageOp, subMessagePlaceholders) {
16267
16344
  } else {
16268
16345
  messageOp.params.set(placeholder, literal(`${ESCAPE2}${I18N_ICU_MAPPING_PREFIX2}${placeholder}${ESCAPE2}`));
16269
16346
  messageOp.postprocessingParams.set(placeholder, literalArr(subMessages));
16270
- messageOp.needsPostprocessing = true;
16271
16347
  }
16272
16348
  }
16273
16349
  }
@@ -16301,12 +16377,13 @@ function i18nGenerateClosureVar(pool, messageId, fileBasedI18nSuffix, useExterna
16301
16377
 
16302
16378
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/i18n_text_extraction.mjs
16303
16379
  function convertI18nText(job) {
16304
- var _a2;
16380
+ var _a2, _b2, _c2;
16305
16381
  for (const unit of job.units) {
16306
16382
  let currentI18n = null;
16307
16383
  let currentIcu = null;
16308
16384
  const textNodeI18nBlocks = /* @__PURE__ */ new Map();
16309
16385
  const textNodeIcus = /* @__PURE__ */ new Map();
16386
+ const icuPlaceholderByText = /* @__PURE__ */ new Map();
16310
16387
  for (const op of unit.create) {
16311
16388
  switch (op.kind) {
16312
16389
  case OpKind.I18nStart:
@@ -16331,7 +16408,13 @@ function convertI18nText(job) {
16331
16408
  if (currentI18n !== null) {
16332
16409
  textNodeI18nBlocks.set(op.xref, currentI18n);
16333
16410
  textNodeIcus.set(op.xref, currentIcu);
16334
- OpList.remove(op);
16411
+ if (op.icuPlaceholder !== null) {
16412
+ const icuPlaceholderOp = createIcuPlaceholderOp(job.allocateXrefId(), op.icuPlaceholder, [op.initialValue]);
16413
+ OpList.replace(op, icuPlaceholderOp);
16414
+ icuPlaceholderByText.set(op.xref, icuPlaceholderOp);
16415
+ } else {
16416
+ OpList.remove(op);
16417
+ }
16335
16418
  }
16336
16419
  break;
16337
16420
  }
@@ -16344,14 +16427,18 @@ function convertI18nText(job) {
16344
16427
  }
16345
16428
  const i18nOp = textNodeI18nBlocks.get(op.target);
16346
16429
  const icuOp = textNodeIcus.get(op.target);
16430
+ const icuPlaceholder = icuPlaceholderByText.get(op.target);
16347
16431
  const contextId = icuOp ? icuOp.context : i18nOp.context;
16348
16432
  const resolutionTime = icuOp ? I18nParamResolutionTime.Postproccessing : I18nParamResolutionTime.Creation;
16349
16433
  const ops = [];
16350
16434
  for (let i = 0; i < op.interpolation.expressions.length; i++) {
16351
16435
  const expr = op.interpolation.expressions[i];
16352
- ops.push(createI18nExpressionOp(contextId, i18nOp.xref, i18nOp.xref, i18nOp.handle, expr, op.interpolation.i18nPlaceholders[i], resolutionTime, I18nExpressionFor.I18nText, "", (_a2 = expr.sourceSpan) != null ? _a2 : op.sourceSpan));
16436
+ ops.push(createI18nExpressionOp(contextId, i18nOp.xref, i18nOp.xref, i18nOp.handle, expr, (_a2 = icuPlaceholder == null ? void 0 : icuPlaceholder.xref) != null ? _a2 : null, (_b2 = op.interpolation.i18nPlaceholders[i]) != null ? _b2 : null, resolutionTime, I18nExpressionFor.I18nText, "", (_c2 = expr.sourceSpan) != null ? _c2 : op.sourceSpan));
16353
16437
  }
16354
16438
  OpList.replaceWithMany(op, ops);
16439
+ if (icuPlaceholder !== void 0) {
16440
+ icuPlaceholder.strings = op.interpolation.strings;
16441
+ }
16355
16442
  break;
16356
16443
  }
16357
16444
  }
@@ -16502,7 +16589,7 @@ function addNamesToView(unit, baseName, state, compatibility) {
16502
16589
  op.handlerFnName = sanitizeIdentifier(op.handlerFnName);
16503
16590
  break;
16504
16591
  case OpKind.Variable:
16505
- varNames.set(op.xref, getVariableName(op.variable, state));
16592
+ varNames.set(op.xref, getVariableName(unit, op.variable, state));
16506
16593
  break;
16507
16594
  case OpKind.RepeaterCreate:
16508
16595
  if (!(unit instanceof ViewCompilationUnit)) {
@@ -16553,14 +16640,19 @@ function addNamesToView(unit, baseName, state, compatibility) {
16553
16640
  });
16554
16641
  }
16555
16642
  }
16556
- function getVariableName(variable2, state) {
16643
+ function getVariableName(unit, variable2, state) {
16557
16644
  if (variable2.name === null) {
16558
16645
  switch (variable2.kind) {
16559
16646
  case SemanticVariableKind.Context:
16560
16647
  variable2.name = `ctx_r${state.index++}`;
16561
16648
  break;
16562
16649
  case SemanticVariableKind.Identifier:
16563
- variable2.name = `${variable2.identifier}_r${++state.index}`;
16650
+ if (unit.job.compatibility === CompatibilityMode.TemplateDefinitionBuilder) {
16651
+ const compatPrefix = variable2.identifier === "ctx" ? "i" : "";
16652
+ variable2.name = `${variable2.identifier}_${compatPrefix}r${++state.index}`;
16653
+ } else {
16654
+ variable2.name = `${variable2.identifier}_i${state.index++}`;
16655
+ }
16564
16656
  break;
16565
16657
  default:
16566
16658
  variable2.name = `_r${++state.index}`;
@@ -16703,17 +16795,24 @@ var CREATE_ORDERING = [
16703
16795
  { test: (op) => op.kind === OpKind.Listener && !(op.hostListener && op.isAnimationListener) }
16704
16796
  ];
16705
16797
  var UPDATE_ORDERING = [
16706
- { test: kindWithInterpolationTest(OpKind.HostProperty, true) },
16707
- { test: kindWithInterpolationTest(OpKind.HostProperty, false) },
16708
16798
  { test: kindTest(OpKind.StyleMap), transform: keepLast },
16709
16799
  { test: kindTest(OpKind.ClassMap), transform: keepLast },
16710
16800
  { test: kindTest(OpKind.StyleProp) },
16711
16801
  { test: kindTest(OpKind.ClassProp) },
16712
- { test: kindWithInterpolationTest(OpKind.Property, true) },
16713
16802
  { test: kindWithInterpolationTest(OpKind.Attribute, true) },
16803
+ { test: kindWithInterpolationTest(OpKind.Property, true) },
16714
16804
  { test: kindWithInterpolationTest(OpKind.Property, false) },
16715
16805
  { test: kindWithInterpolationTest(OpKind.Attribute, false) }
16716
16806
  ];
16807
+ var UPDATE_HOST_ORDERING = [
16808
+ { test: kindWithInterpolationTest(OpKind.HostProperty, true) },
16809
+ { test: kindWithInterpolationTest(OpKind.HostProperty, false) },
16810
+ { test: kindTest(OpKind.Attribute) },
16811
+ { test: kindTest(OpKind.StyleMap), transform: keepLast },
16812
+ { test: kindTest(OpKind.ClassMap), transform: keepLast },
16813
+ { test: kindTest(OpKind.StyleProp) },
16814
+ { test: kindTest(OpKind.ClassProp) }
16815
+ ];
16717
16816
  var handledOpKinds = /* @__PURE__ */ new Set([
16718
16817
  OpKind.Listener,
16719
16818
  OpKind.StyleMap,
@@ -16727,7 +16826,8 @@ var handledOpKinds = /* @__PURE__ */ new Set([
16727
16826
  function orderOps(job) {
16728
16827
  for (const unit of job.units) {
16729
16828
  orderWithin(unit.create, CREATE_ORDERING);
16730
- orderWithin(unit.update, UPDATE_ORDERING);
16829
+ const ordering = unit.job.kind === CompilationJobKind.Host ? UPDATE_HOST_ORDERING : UPDATE_ORDERING;
16830
+ orderWithin(unit.update, ordering);
16731
16831
  }
16732
16832
  }
16733
16833
  function orderWithin(opList, ordering) {
@@ -16765,9 +16865,21 @@ function keepLast(ops) {
16765
16865
 
16766
16866
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/parse_extracted_styles.mjs
16767
16867
  function parseExtractedStyles(job) {
16868
+ const elements = /* @__PURE__ */ new Map();
16869
+ for (const unit of job.units) {
16870
+ for (const op of unit.create) {
16871
+ if (isElementOrContainerOp(op)) {
16872
+ elements.set(op.xref, op);
16873
+ }
16874
+ }
16875
+ }
16768
16876
  for (const unit of job.units) {
16769
16877
  for (const op of unit.create) {
16770
16878
  if (op.kind === OpKind.ExtractedAttribute && op.bindingKind === BindingKind.Attribute && isStringLiteral(op.expression)) {
16879
+ const target = elements.get(op.target);
16880
+ if (target !== void 0 && target.kind === OpKind.Template && target.templateKind === TemplateKind.Structural) {
16881
+ continue;
16882
+ }
16771
16883
  if (op.name === "style") {
16772
16884
  const parsedStyles = parse(op.expression.value);
16773
16885
  for (let i = 0; i < parsedStyles.length - 1; i += 2) {
@@ -16798,13 +16910,6 @@ function removeContentSelectors(job) {
16798
16910
  OpList.remove(op);
16799
16911
  }
16800
16912
  break;
16801
- case OpKind.Projection:
16802
- for (let i = op.attributes.length - 2; i >= 0; i -= 2) {
16803
- if (isSelectAttribute(op.attributes[i])) {
16804
- op.attributes.splice(i, 2);
16805
- }
16806
- }
16807
- break;
16808
16913
  }
16809
16914
  }
16810
16915
  }
@@ -16931,8 +17036,11 @@ function wrapTemplateWithI18n(unit, parentI18n) {
16931
17036
  var _a2;
16932
17037
  if (((_a2 = unit.create.head.next) == null ? void 0 : _a2.kind) !== OpKind.I18nStart) {
16933
17038
  const id = unit.job.allocateXrefId();
16934
- OpList.insertAfter(createI18nStartOp(id, parentI18n.message, parentI18n.root), unit.create.head);
16935
- OpList.insertBefore(createI18nEndOp(id), unit.create.tail);
17039
+ OpList.insertAfter(
17040
+ createI18nStartOp(id, parentI18n.message, parentI18n.root, null),
17041
+ unit.create.head
17042
+ );
17043
+ OpList.insertBefore(createI18nEndOp(id, null), unit.create.tail);
16936
17044
  }
16937
17045
  }
16938
17046
 
@@ -17187,22 +17295,22 @@ function projectionDef(def) {
17187
17295
  }
17188
17296
  function projection(slot, projectionSlotIndex, attributes, sourceSpan) {
17189
17297
  const args = [literal(slot)];
17190
- if (projectionSlotIndex !== 0 || attributes.length > 0) {
17298
+ if (projectionSlotIndex !== 0 || attributes !== null) {
17191
17299
  args.push(literal(projectionSlotIndex));
17192
- if (attributes.length > 0) {
17193
- args.push(literalArr(attributes.map((attr) => literal(attr))));
17300
+ if (attributes !== null) {
17301
+ args.push(attributes);
17194
17302
  }
17195
17303
  }
17196
17304
  return call(Identifiers.projection, args, sourceSpan);
17197
17305
  }
17198
- function i18nStart(slot, constIndex, subTemplateIndex) {
17306
+ function i18nStart(slot, constIndex, subTemplateIndex, sourceSpan) {
17199
17307
  const args = [literal(slot), literal(constIndex)];
17200
17308
  if (subTemplateIndex !== null) {
17201
17309
  args.push(literal(subTemplateIndex));
17202
17310
  }
17203
- return call(Identifiers.i18nStart, args, null);
17311
+ return call(Identifiers.i18nStart, args, sourceSpan);
17204
17312
  }
17205
- function repeaterCreate(slot, viewFnName, decls, vars, tag, constIndex, trackByFn, trackByUsesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, sourceSpan) {
17313
+ function repeaterCreate(slot, viewFnName, decls, vars, tag, constIndex, trackByFn, trackByUsesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, emptyTag, emptyConstIndex, sourceSpan) {
17206
17314
  const args = [
17207
17315
  literal(slot),
17208
17316
  variable(viewFnName),
@@ -17216,6 +17324,12 @@ function repeaterCreate(slot, viewFnName, decls, vars, tag, constIndex, trackByF
17216
17324
  args.push(literal(trackByUsesComponentInstance));
17217
17325
  if (emptyViewFnName !== null) {
17218
17326
  args.push(variable(emptyViewFnName), literal(emptyDecls), literal(emptyVars));
17327
+ if (emptyTag !== null || emptyConstIndex !== null) {
17328
+ args.push(literal(emptyTag));
17329
+ }
17330
+ if (emptyConstIndex !== null) {
17331
+ args.push(literal(emptyConstIndex));
17332
+ }
17219
17333
  }
17220
17334
  }
17221
17335
  return call(Identifiers.repeaterCreate, args, sourceSpan);
@@ -17226,15 +17340,15 @@ function repeater(collection, sourceSpan) {
17226
17340
  function deferWhen(prefetch, expr, sourceSpan) {
17227
17341
  return call(prefetch ? Identifiers.deferPrefetchWhen : Identifiers.deferWhen, [expr], sourceSpan);
17228
17342
  }
17229
- function i18n(slot, constIndex, subTemplateIndex) {
17343
+ function i18n(slot, constIndex, subTemplateIndex, sourceSpan) {
17230
17344
  const args = [literal(slot), literal(constIndex)];
17231
17345
  if (subTemplateIndex) {
17232
17346
  args.push(literal(subTemplateIndex));
17233
17347
  }
17234
- return call(Identifiers.i18n, args, null);
17348
+ return call(Identifiers.i18n, args, sourceSpan);
17235
17349
  }
17236
- function i18nEnd() {
17237
- return call(Identifiers.i18nEnd, [], null);
17350
+ function i18nEnd(endSourceSpan) {
17351
+ return call(Identifiers.i18nEnd, [], endSourceSpan);
17238
17352
  }
17239
17353
  function i18nAttributes(slot, i18nAttributesConfig) {
17240
17354
  const args = [literal(slot), literal(i18nAttributesConfig)];
@@ -17561,31 +17675,31 @@ function reifyCreateOperations(unit, ops) {
17561
17675
  OpList.replace(op, text(op.handle.slot, op.initialValue, op.sourceSpan));
17562
17676
  break;
17563
17677
  case OpKind.ElementStart:
17564
- OpList.replace(op, elementStart(op.handle.slot, op.tag, op.attributes, op.localRefs, op.sourceSpan));
17678
+ OpList.replace(op, elementStart(op.handle.slot, op.tag, op.attributes, op.localRefs, op.startSourceSpan));
17565
17679
  break;
17566
17680
  case OpKind.Element:
17567
- OpList.replace(op, element(op.handle.slot, op.tag, op.attributes, op.localRefs, op.sourceSpan));
17681
+ OpList.replace(op, element(op.handle.slot, op.tag, op.attributes, op.localRefs, op.wholeSourceSpan));
17568
17682
  break;
17569
17683
  case OpKind.ElementEnd:
17570
17684
  OpList.replace(op, elementEnd(op.sourceSpan));
17571
17685
  break;
17572
17686
  case OpKind.ContainerStart:
17573
- OpList.replace(op, elementContainerStart(op.handle.slot, op.attributes, op.localRefs, op.sourceSpan));
17687
+ OpList.replace(op, elementContainerStart(op.handle.slot, op.attributes, op.localRefs, op.startSourceSpan));
17574
17688
  break;
17575
17689
  case OpKind.Container:
17576
- OpList.replace(op, elementContainer(op.handle.slot, op.attributes, op.localRefs, op.sourceSpan));
17690
+ OpList.replace(op, elementContainer(op.handle.slot, op.attributes, op.localRefs, op.wholeSourceSpan));
17577
17691
  break;
17578
17692
  case OpKind.ContainerEnd:
17579
17693
  OpList.replace(op, elementContainerEnd());
17580
17694
  break;
17581
17695
  case OpKind.I18nStart:
17582
- OpList.replace(op, i18nStart(op.handle.slot, op.messageIndex, op.subTemplateIndex));
17696
+ OpList.replace(op, i18nStart(op.handle.slot, op.messageIndex, op.subTemplateIndex, op.sourceSpan));
17583
17697
  break;
17584
17698
  case OpKind.I18nEnd:
17585
- OpList.replace(op, i18nEnd());
17699
+ OpList.replace(op, i18nEnd(op.sourceSpan));
17586
17700
  break;
17587
17701
  case OpKind.I18n:
17588
- OpList.replace(op, i18n(op.handle.slot, op.messageIndex, op.subTemplateIndex));
17702
+ OpList.replace(op, i18n(op.handle.slot, op.messageIndex, op.subTemplateIndex, op.sourceSpan));
17589
17703
  break;
17590
17704
  case OpKind.I18nAttributes:
17591
17705
  if (op.i18nAttributesConfig === null) {
@@ -17601,7 +17715,7 @@ function reifyCreateOperations(unit, ops) {
17601
17715
  throw new Error(`AssertionError: local refs array should have been extracted into a constant`);
17602
17716
  }
17603
17717
  const childView = unit.job.views.get(op.xref);
17604
- OpList.replace(op, template(op.handle.slot, variable(childView.fnName), childView.decls, childView.vars, op.tag, op.attributes, op.localRefs, op.sourceSpan));
17718
+ OpList.replace(op, template(op.handle.slot, variable(childView.fnName), childView.decls, childView.vars, op.tag, op.attributes, op.localRefs, op.startSourceSpan));
17605
17719
  break;
17606
17720
  case OpKind.DisableBindings:
17607
17721
  OpList.replace(op, disableBindings2());
@@ -17616,7 +17730,7 @@ function reifyCreateOperations(unit, ops) {
17616
17730
  const listenerFn = reifyListenerHandler(unit, op.handlerFnName, op.handlerOps, op.consumesDollarEvent);
17617
17731
  const eventTargetResolver = op.eventTarget ? GLOBAL_TARGET_RESOLVERS.get(op.eventTarget) : null;
17618
17732
  if (eventTargetResolver === void 0) {
17619
- throw new Error(`AssertionError: unknown event target ${op.eventTarget}`);
17733
+ throw new Error(`Unexpected global target '${op.eventTarget}' defined for '${op.name}' event. Supported list of global targets: window,document,body.`);
17620
17734
  }
17621
17735
  OpList.replace(op, listener(op.name, listenerFn, eventTargetResolver, op.hostListener && op.isAnimationListener, op.sourceSpan));
17622
17736
  break;
@@ -17703,7 +17817,7 @@ function reifyCreateOperations(unit, ops) {
17703
17817
  emptyDecls = emptyView.decls;
17704
17818
  emptyVars = emptyView.vars;
17705
17819
  }
17706
- OpList.replace(op, repeaterCreate(op.handle.slot, repeaterView.fnName, op.decls, op.vars, op.tag, op.attributes, op.trackByFn, op.usesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, op.sourceSpan));
17820
+ OpList.replace(op, repeaterCreate(op.handle.slot, repeaterView.fnName, op.decls, op.vars, op.tag, op.attributes, op.trackByFn, op.usesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, op.emptyTag, op.emptyAttributes, op.wholeSourceSpan));
17707
17821
  break;
17708
17822
  case OpKind.Statement:
17709
17823
  break;
@@ -18210,6 +18324,7 @@ function resolveI18nExpressionPlaceholders(job) {
18210
18324
  var _a2;
18211
18325
  const subTemplateIndicies = /* @__PURE__ */ new Map();
18212
18326
  const i18nContexts = /* @__PURE__ */ new Map();
18327
+ const icuPlaceholders = /* @__PURE__ */ new Map();
18213
18328
  for (const unit of job.units) {
18214
18329
  for (const op of unit.create) {
18215
18330
  switch (op.kind) {
@@ -18219,6 +18334,9 @@ function resolveI18nExpressionPlaceholders(job) {
18219
18334
  case OpKind.I18nContext:
18220
18335
  i18nContexts.set(op.xref, op);
18221
18336
  break;
18337
+ case OpKind.IcuPlaceholder:
18338
+ icuPlaceholders.set(op.xref, op);
18339
+ break;
18222
18340
  }
18223
18341
  }
18224
18342
  }
@@ -18227,66 +18345,32 @@ function resolveI18nExpressionPlaceholders(job) {
18227
18345
  for (const unit of job.units) {
18228
18346
  for (const op of unit.update) {
18229
18347
  if (op.kind === OpKind.I18nExpression) {
18230
- const i18nContext = i18nContexts.get(op.context);
18231
18348
  const index = expressionIndices.get(referenceIndex(op)) || 0;
18232
18349
  const subTemplateIndex = (_a2 = subTemplateIndicies.get(op.i18nOwner)) != null ? _a2 : null;
18233
- const params = op.resolutionTime === I18nParamResolutionTime.Creation ? i18nContext.params : i18nContext.postprocessingParams;
18234
- const values = params.get(op.i18nPlaceholder) || [];
18235
- values.push({
18350
+ const value = {
18236
18351
  value: index,
18237
18352
  subTemplateIndex,
18238
18353
  flags: I18nParamValueFlags.ExpressionIndex
18239
- });
18240
- params.set(op.i18nPlaceholder, values);
18354
+ };
18355
+ updatePlaceholder(op, value, i18nContexts, icuPlaceholders);
18241
18356
  expressionIndices.set(referenceIndex(op), index + 1);
18242
18357
  }
18243
18358
  }
18244
18359
  }
18245
18360
  }
18246
-
18247
- // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_i18n_icu_placeholders.mjs
18248
- function resolveI18nIcuPlaceholders(job) {
18249
- for (const unit of job.units) {
18250
- for (const op of unit.create) {
18251
- if (op.kind === OpKind.I18nContext && op.contextKind === I18nContextKind.Icu) {
18252
- for (const node of op.message.nodes) {
18253
- node.visit(new ResolveIcuPlaceholdersVisitor(op.postprocessingParams));
18254
- }
18255
- }
18256
- }
18257
- }
18258
- }
18259
- var ResolveIcuPlaceholdersVisitor = class extends RecurseVisitor {
18260
- constructor(params) {
18261
- super();
18262
- this.params = params;
18361
+ function updatePlaceholder(op, value, i18nContexts, icuPlaceholders) {
18362
+ if (op.i18nPlaceholder !== null) {
18363
+ const i18nContext = i18nContexts.get(op.context);
18364
+ const params = op.resolutionTime === I18nParamResolutionTime.Creation ? i18nContext.params : i18nContext.postprocessingParams;
18365
+ const values = params.get(op.i18nPlaceholder) || [];
18366
+ values.push(value);
18367
+ params.set(op.i18nPlaceholder, values);
18263
18368
  }
18264
- visitContainerPlaceholder(placeholder) {
18265
- var _a2, _b2;
18266
- if (placeholder.startName && placeholder.startSourceSpan && !this.params.has(placeholder.startName)) {
18267
- this.params.set(placeholder.startName, [{
18268
- value: (_a2 = placeholder.startSourceSpan) == null ? void 0 : _a2.toString(),
18269
- subTemplateIndex: null,
18270
- flags: I18nParamValueFlags.None
18271
- }]);
18272
- }
18273
- if (placeholder.closeName && placeholder.endSourceSpan && !this.params.has(placeholder.closeName)) {
18274
- this.params.set(placeholder.closeName, [{
18275
- value: (_b2 = placeholder.endSourceSpan) == null ? void 0 : _b2.toString(),
18276
- subTemplateIndex: null,
18277
- flags: I18nParamValueFlags.None
18278
- }]);
18279
- }
18280
- }
18281
- visitTagPlaceholder(placeholder) {
18282
- super.visitTagPlaceholder(placeholder);
18283
- this.visitContainerPlaceholder(placeholder);
18284
- }
18285
- visitBlockPlaceholder(placeholder) {
18286
- super.visitBlockPlaceholder(placeholder);
18287
- this.visitContainerPlaceholder(placeholder);
18369
+ if (op.icuPlaceholder !== null) {
18370
+ const icuPlaceholderOp = icuPlaceholders.get(op.icuPlaceholder);
18371
+ icuPlaceholderOp == null ? void 0 : icuPlaceholderOp.expressionPlaceholders.push(value);
18288
18372
  }
18289
- };
18373
+ }
18290
18374
 
18291
18375
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_names.mjs
18292
18376
  function resolveNames(job) {
@@ -18592,6 +18676,9 @@ function generateTrackFns(job) {
18592
18676
  }
18593
18677
  let usesComponentContext = false;
18594
18678
  op.track = transformExpressionsInExpression(op.track, (expr) => {
18679
+ if (expr instanceof PipeBindingExpr || expr instanceof PipeBindingVariadicExpr) {
18680
+ throw new Error(`Illegal State: Pipes are not allowed in this context`);
18681
+ }
18595
18682
  if (expr instanceof TrackContextExpr) {
18596
18683
  usesComponentContext = true;
18597
18684
  return variable("this");
@@ -18756,7 +18843,10 @@ function varsUsedByOp(op) {
18756
18843
  return op.interpolation.expressions.length;
18757
18844
  case OpKind.I18nExpression:
18758
18845
  case OpKind.Conditional:
18846
+ case OpKind.DeferWhen:
18759
18847
  return 1;
18848
+ case OpKind.RepeaterCreate:
18849
+ return op.emptyView ? 1 : 0;
18760
18850
  default:
18761
18851
  throw new Error(`Unhandled op: ${OpKind[op.kind]}`);
18762
18852
  }
@@ -19049,12 +19139,12 @@ function wrapI18nIcus(job) {
19049
19139
  case OpKind.IcuStart:
19050
19140
  if (currentI18nOp === null) {
19051
19141
  addedI18nId = job.allocateXrefId();
19052
- OpList.insertBefore(createI18nStartOp(addedI18nId, op.message), op);
19142
+ OpList.insertBefore(createI18nStartOp(addedI18nId, op.message, void 0, null), op);
19053
19143
  }
19054
19144
  break;
19055
19145
  case OpKind.IcuEnd:
19056
19146
  if (addedI18nId !== null) {
19057
- OpList.insertAfter(createI18nEndOp(addedI18nId), op);
19147
+ OpList.insertAfter(createI18nEndOp(addedI18nId, null), op);
19058
19148
  addedI18nId = null;
19059
19149
  }
19060
19150
  break;
@@ -19070,6 +19160,7 @@ var phases = [
19070
19160
  { kind: CompilationJobKind.Tmpl, fn: emitNamespaceChanges },
19071
19161
  { kind: CompilationJobKind.Tmpl, fn: propagateI18nBlocks },
19072
19162
  { kind: CompilationJobKind.Tmpl, fn: wrapI18nIcus },
19163
+ { kind: CompilationJobKind.Both, fn: deduplicateTextBindings },
19073
19164
  { kind: CompilationJobKind.Both, fn: specializeStyleBindings },
19074
19165
  { kind: CompilationJobKind.Both, fn: specializeBindings },
19075
19166
  { kind: CompilationJobKind.Both, fn: extractAttributes },
@@ -19108,7 +19199,6 @@ var phases = [
19108
19199
  { kind: CompilationJobKind.Tmpl, fn: createDeferDepsFns },
19109
19200
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nElementPlaceholders },
19110
19201
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nExpressionPlaceholders },
19111
- { kind: CompilationJobKind.Tmpl, fn: resolveI18nIcuPlaceholders },
19112
19202
  { kind: CompilationJobKind.Tmpl, fn: extractI18nMessages },
19113
19203
  { kind: CompilationJobKind.Tmpl, fn: generateTrackFns },
19114
19204
  { kind: CompilationJobKind.Tmpl, fn: collectI18nConsts },
@@ -19251,7 +19341,7 @@ function ingestHostBinding(input, bindingParser, constantPool) {
19251
19341
  bindingKind = BindingKind.Animation;
19252
19342
  }
19253
19343
  const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, property2.name, bindingKind === BindingKind.Attribute).filter((context) => context !== SecurityContext.NONE);
19254
- ingestHostProperty(job, property2, bindingKind, false, securityContexts);
19344
+ ingestHostProperty(job, property2, bindingKind, securityContexts);
19255
19345
  }
19256
19346
  for (const [name, expr] of (_b2 = Object.entries(input.attributes)) != null ? _b2 : []) {
19257
19347
  const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, name, true).filter((context) => context !== SecurityContext.NONE);
@@ -19262,7 +19352,7 @@ function ingestHostBinding(input, bindingParser, constantPool) {
19262
19352
  }
19263
19353
  return job;
19264
19354
  }
19265
- function ingestHostProperty(job, property2, bindingKind, isTextAttribute, securityContexts) {
19355
+ function ingestHostProperty(job, property2, bindingKind, securityContexts) {
19266
19356
  let expression;
19267
19357
  const ast = property2.expression.ast;
19268
19358
  if (ast instanceof Interpolation) {
@@ -19270,7 +19360,7 @@ function ingestHostProperty(job, property2, bindingKind, isTextAttribute, securi
19270
19360
  } else {
19271
19361
  expression = convertAst(ast, job, property2.sourceSpan);
19272
19362
  }
19273
- job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, securityContexts, isTextAttribute, false, null, null, property2.sourceSpan));
19363
+ job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, securityContexts, false, false, null, null, property2.sourceSpan));
19274
19364
  }
19275
19365
  function ingestHostAttribute(job, name, value, securityContexts) {
19276
19366
  const attrBinding = createBindingOp(
@@ -19284,14 +19374,13 @@ function ingestHostAttribute(job, name, value, securityContexts) {
19284
19374
  false,
19285
19375
  null,
19286
19376
  null,
19287
- null
19377
+ value.sourceSpan
19288
19378
  );
19289
19379
  job.root.update.push(attrBinding);
19290
19380
  }
19291
19381
  function ingestHostEvent(job, event) {
19292
19382
  const [phase, target] = event.type === 0 ? [null, event.targetOrPhase] : [event.targetOrPhase, null];
19293
- const eventBinding = createListenerOp(job.root.xref, new SlotHandle(), event.name, null, [], phase, target, true, event.sourceSpan);
19294
- eventBinding.handlerOps.push(createStatementOp(new ReturnStatement(convertAst(event.handler.ast, job, event.sourceSpan), event.handlerSpan)));
19383
+ const eventBinding = createListenerOp(job.root.xref, new SlotHandle(), event.name, null, makeListenerHandlerOps(job.root, event.handler, event.handlerSpan), phase, target, true, event.sourceSpan);
19295
19384
  job.root.create.push(eventBinding);
19296
19385
  }
19297
19386
  function ingestNodes(unit, template2) {
@@ -19303,9 +19392,9 @@ function ingestNodes(unit, template2) {
19303
19392
  } else if (node instanceof Content) {
19304
19393
  ingestContent(unit, node);
19305
19394
  } else if (node instanceof Text) {
19306
- ingestText(unit, node);
19395
+ ingestText(unit, node, null);
19307
19396
  } else if (node instanceof BoundText) {
19308
- ingestBoundText(unit, node);
19397
+ ingestBoundText(unit, node, null);
19309
19398
  } else if (node instanceof IfBlock) {
19310
19399
  ingestIfBlock(unit, node);
19311
19400
  } else if (node instanceof SwitchBlock) {
@@ -19322,29 +19411,30 @@ function ingestNodes(unit, template2) {
19322
19411
  }
19323
19412
  }
19324
19413
  function ingestElement(unit, element2) {
19325
- var _a2;
19414
+ var _a2, _b2;
19326
19415
  if (element2.i18n !== void 0 && !(element2.i18n instanceof Message || element2.i18n instanceof TagPlaceholder)) {
19327
19416
  throw Error(`Unhandled i18n metadata type for element: ${element2.i18n.constructor.name}`);
19328
19417
  }
19329
19418
  const id = unit.job.allocateXrefId();
19330
19419
  const [namespaceKey, elementName] = splitNsName(element2.name);
19331
- const startOp = createElementStartOp(elementName, id, namespaceForKey(namespaceKey), element2.i18n instanceof TagPlaceholder ? element2.i18n : void 0, element2.startSourceSpan);
19420
+ const startOp = createElementStartOp(elementName, id, namespaceForKey(namespaceKey), element2.i18n instanceof TagPlaceholder ? element2.i18n : void 0, element2.startSourceSpan, element2.sourceSpan);
19332
19421
  unit.create.push(startOp);
19333
19422
  ingestElementBindings(unit, startOp, element2);
19334
19423
  ingestReferences(startOp, element2);
19335
19424
  let i18nBlockId = null;
19336
19425
  if (element2.i18n instanceof Message) {
19337
19426
  i18nBlockId = unit.job.allocateXrefId();
19338
- unit.create.push(createI18nStartOp(i18nBlockId, element2.i18n));
19427
+ unit.create.push(createI18nStartOp(i18nBlockId, element2.i18n, void 0, element2.startSourceSpan));
19339
19428
  }
19340
19429
  ingestNodes(unit, element2.children);
19341
19430
  const endOp = createElementEndOp(id, (_a2 = element2.endSourceSpan) != null ? _a2 : element2.startSourceSpan);
19342
19431
  unit.create.push(endOp);
19343
19432
  if (i18nBlockId !== null) {
19344
- OpList.insertBefore(createI18nEndOp(i18nBlockId), endOp);
19433
+ OpList.insertBefore(createI18nEndOp(i18nBlockId, (_b2 = element2.endSourceSpan) != null ? _b2 : element2.startSourceSpan), endOp);
19345
19434
  }
19346
19435
  }
19347
19436
  function ingestTemplate(unit, tmpl) {
19437
+ var _a2;
19348
19438
  if (tmpl.i18n !== void 0 && !(tmpl.i18n instanceof Message || tmpl.i18n instanceof TagPlaceholder)) {
19349
19439
  throw Error(`Unhandled i18n metadata type for template: ${tmpl.i18n.constructor.name}`);
19350
19440
  }
@@ -19358,7 +19448,7 @@ function ingestTemplate(unit, tmpl) {
19358
19448
  const namespace = namespaceForKey(namespacePrefix);
19359
19449
  const functionNameSuffix = tagNameWithoutNamespace === null ? "" : prefixWithNamespace(tagNameWithoutNamespace, namespace);
19360
19450
  const templateKind = isPlainTemplate(tmpl) ? TemplateKind.NgTemplate : TemplateKind.Structural;
19361
- const templateOp = createTemplateOp(childView.xref, templateKind, tagNameWithoutNamespace, functionNameSuffix, namespace, i18nPlaceholder, tmpl.startSourceSpan);
19451
+ const templateOp = createTemplateOp(childView.xref, templateKind, tagNameWithoutNamespace, functionNameSuffix, namespace, i18nPlaceholder, tmpl.startSourceSpan, tmpl.sourceSpan);
19362
19452
  unit.create.push(templateOp);
19363
19453
  ingestTemplateBindings(unit, templateOp, tmpl, templateKind);
19364
19454
  ingestReferences(templateOp, tmpl);
@@ -19368,26 +19458,25 @@ function ingestTemplate(unit, tmpl) {
19368
19458
  }
19369
19459
  if (templateKind === TemplateKind.NgTemplate && tmpl.i18n instanceof Message) {
19370
19460
  const id = unit.job.allocateXrefId();
19371
- OpList.insertAfter(createI18nStartOp(id, tmpl.i18n), childView.create.head);
19372
- OpList.insertBefore(createI18nEndOp(id), childView.create.tail);
19461
+ OpList.insertAfter(createI18nStartOp(id, tmpl.i18n, void 0, tmpl.startSourceSpan), childView.create.head);
19462
+ OpList.insertBefore(createI18nEndOp(id, (_a2 = tmpl.endSourceSpan) != null ? _a2 : tmpl.startSourceSpan), childView.create.tail);
19373
19463
  }
19374
19464
  }
19375
19465
  function ingestContent(unit, content) {
19376
19466
  if (content.i18n !== void 0 && !(content.i18n instanceof TagPlaceholder)) {
19377
19467
  throw Error(`Unhandled i18n metadata type for element: ${content.i18n.constructor.name}`);
19378
19468
  }
19379
- const attrs = content.attributes.flatMap((a) => [a.name, a.value]);
19380
- const op = createProjectionOp(unit.job.allocateXrefId(), content.selector, content.i18n, attrs, content.sourceSpan);
19469
+ const op = createProjectionOp(unit.job.allocateXrefId(), content.selector, content.i18n, content.sourceSpan);
19381
19470
  for (const attr of content.attributes) {
19382
19471
  const securityContext = domSchema.securityContext(content.name, attr.name, true);
19383
19472
  unit.update.push(createBindingOp(op.xref, BindingKind.Attribute, attr.name, literal(attr.value), null, securityContext, true, false, null, asMessage(attr.i18n), attr.sourceSpan));
19384
19473
  }
19385
19474
  unit.create.push(op);
19386
19475
  }
19387
- function ingestText(unit, text2) {
19388
- unit.create.push(createTextOp(unit.job.allocateXrefId(), text2.value, text2.sourceSpan));
19476
+ function ingestText(unit, text2, icuPlaceholder) {
19477
+ unit.create.push(createTextOp(unit.job.allocateXrefId(), text2.value, icuPlaceholder, text2.sourceSpan));
19389
19478
  }
19390
- function ingestBoundText(unit, text2, i18nPlaceholders) {
19479
+ function ingestBoundText(unit, text2, icuPlaceholder) {
19391
19480
  var _a2;
19392
19481
  let value = text2.value;
19393
19482
  if (value instanceof ASTWithSource) {
@@ -19399,14 +19488,12 @@ function ingestBoundText(unit, text2, i18nPlaceholders) {
19399
19488
  if (text2.i18n !== void 0 && !(text2.i18n instanceof Container)) {
19400
19489
  throw Error(`Unhandled i18n metadata type for text interpolation: ${(_a2 = text2.i18n) == null ? void 0 : _a2.constructor.name}`);
19401
19490
  }
19402
- if (i18nPlaceholders === void 0) {
19403
- i18nPlaceholders = text2.i18n instanceof Container ? text2.i18n.children.filter((node) => node instanceof Placeholder).map((placeholder) => placeholder.name) : [];
19404
- }
19491
+ const i18nPlaceholders = text2.i18n instanceof Container ? text2.i18n.children.filter((node) => node instanceof Placeholder).map((placeholder) => placeholder.name) : [];
19405
19492
  if (i18nPlaceholders.length > 0 && i18nPlaceholders.length !== value.expressions.length) {
19406
19493
  throw Error(`Unexpected number of i18n placeholders (${value.expressions.length}) for BoundText with ${value.expressions.length} expressions`);
19407
19494
  }
19408
19495
  const textXref = unit.job.allocateXrefId();
19409
- unit.create.push(createTextOp(textXref, "", text2.sourceSpan));
19496
+ unit.create.push(createTextOp(textXref, "", icuPlaceholder, text2.sourceSpan));
19410
19497
  const baseSourceSpan = unit.job.compatibility ? null : text2.sourceSpan;
19411
19498
  unit.update.push(createInterpolateTextOp(textXref, new Interpolation2(value.strings, value.expressions.map((expr) => convertAst(expr, unit.job, baseSourceSpan)), i18nPlaceholders), text2.sourceSpan));
19412
19499
  }
@@ -19432,7 +19519,7 @@ function ingestIfBlock(unit, ifBlock) {
19432
19519
  }
19433
19520
  ifCaseI18nMeta = ifCase.i18n;
19434
19521
  }
19435
- const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, tagName, "Conditional", Namespace.HTML, ifCaseI18nMeta, ifCase.sourceSpan);
19522
+ const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, tagName, "Conditional", Namespace.HTML, ifCaseI18nMeta, ifCase.startSourceSpan, ifCase.sourceSpan);
19436
19523
  unit.create.push(templateOp);
19437
19524
  if (firstXref === null) {
19438
19525
  firstXref = cView.xref;
@@ -19460,7 +19547,7 @@ function ingestSwitchBlock(unit, switchBlock) {
19460
19547
  }
19461
19548
  switchCaseI18nMeta = switchCase.i18n;
19462
19549
  }
19463
- const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, null, "Case", Namespace.HTML, switchCaseI18nMeta, switchCase.sourceSpan);
19550
+ const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, null, "Case", Namespace.HTML, switchCaseI18nMeta, switchCase.startSourceSpan, switchCase.sourceSpan);
19464
19551
  unit.create.push(templateOp);
19465
19552
  if (firstXref === null) {
19466
19553
  firstXref = cView.xref;
@@ -19483,7 +19570,7 @@ function ingestDeferView(unit, suffix, i18nMeta, children, sourceSpan) {
19483
19570
  }
19484
19571
  const secondaryView = unit.job.allocateView(unit.xref);
19485
19572
  ingestNodes(secondaryView, children);
19486
- const templateOp = createTemplateOp(secondaryView.xref, TemplateKind.Block, null, `Defer${suffix}`, Namespace.HTML, i18nMeta, sourceSpan);
19573
+ const templateOp = createTemplateOp(secondaryView.xref, TemplateKind.Block, null, `Defer${suffix}`, Namespace.HTML, i18nMeta, sourceSpan, sourceSpan);
19487
19574
  unit.create.push(templateOp);
19488
19575
  return templateOp;
19489
19576
  }
@@ -19557,6 +19644,9 @@ function ingestDeferBlock(unit, deferBlock) {
19557
19644
  deferOnOps.push(deferOnOp);
19558
19645
  }
19559
19646
  if (triggers.when !== void 0) {
19647
+ if (triggers.when.value instanceof Interpolation) {
19648
+ throw new Error(`Unexpected interpolation in defer block when trigger`);
19649
+ }
19560
19650
  const deferOnOp = createDeferWhenOp(deferXref, convertAst(triggers.when.value, unit.job, triggers.when.sourceSpan), prefetch, triggers.when.sourceSpan);
19561
19651
  deferWhenOps.push(deferOnOp);
19562
19652
  }
@@ -19576,9 +19666,9 @@ function ingestIcu(unit, icu) {
19576
19666
  unit.create.push(createIcuStartOp(xref, icu.i18n, icuFromI18nMessage(icu.i18n).name, null));
19577
19667
  for (const [placeholder, text2] of Object.entries(__spreadValues(__spreadValues({}, icu.vars), icu.placeholders))) {
19578
19668
  if (text2 instanceof BoundText) {
19579
- ingestBoundText(unit, text2, [placeholder]);
19669
+ ingestBoundText(unit, text2, placeholder);
19580
19670
  } else {
19581
- ingestText(unit, text2);
19671
+ ingestText(unit, text2, placeholder);
19582
19672
  }
19583
19673
  }
19584
19674
  unit.create.push(createIcuEndOp(xref));
@@ -19608,9 +19698,11 @@ function ingestForBlock(unit, forBlock) {
19608
19698
  const track = convertAst(forBlock.trackBy, unit.job, sourceSpan);
19609
19699
  ingestNodes(repeaterView, forBlock.children);
19610
19700
  let emptyView = null;
19701
+ let emptyTagName = null;
19611
19702
  if (forBlock.empty !== null) {
19612
19703
  emptyView = unit.job.allocateView(unit.xref);
19613
19704
  ingestNodes(emptyView, forBlock.empty.children);
19705
+ emptyTagName = ingestControlFlowInsertionPoint(unit, emptyView.xref, forBlock.empty);
19614
19706
  }
19615
19707
  const varNames = {
19616
19708
  $index: forBlock.contextVariables.$index.name,
@@ -19630,7 +19722,7 @@ function ingestForBlock(unit, forBlock) {
19630
19722
  const i18nPlaceholder = forBlock.i18n;
19631
19723
  const emptyI18nPlaceholder = (_b2 = forBlock.empty) == null ? void 0 : _b2.i18n;
19632
19724
  const tagName = ingestControlFlowInsertionPoint(unit, repeaterView.xref, forBlock);
19633
- const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (_c2 = emptyView == null ? void 0 : emptyView.xref) != null ? _c2 : null, tagName, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, forBlock.sourceSpan);
19725
+ const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (_c2 = emptyView == null ? void 0 : emptyView.xref) != null ? _c2 : null, tagName, track, varNames, emptyTagName, i18nPlaceholder, emptyI18nPlaceholder, forBlock.startSourceSpan, forBlock.sourceSpan);
19634
19726
  unit.create.push(repeaterCreate2);
19635
19727
  const expression = convertAst(forBlock.expression, unit.job, convertSourceSpan(forBlock.expression.span, forBlock.sourceSpan));
19636
19728
  const repeater2 = createRepeaterOp(repeaterCreate2.xref, repeaterCreate2.handle, expression, forBlock.sourceSpan);
@@ -19640,7 +19732,10 @@ function convertAst(ast, job, baseSourceSpan) {
19640
19732
  if (ast instanceof ASTWithSource) {
19641
19733
  return convertAst(ast.ast, job, baseSourceSpan);
19642
19734
  } else if (ast instanceof PropertyRead) {
19643
- if (ast.receiver instanceof ImplicitReceiver && !(ast.receiver instanceof ThisReceiver)) {
19735
+ const isThisReceiver = ast.receiver instanceof ThisReceiver;
19736
+ const isImplicitReceiver = ast.receiver instanceof ImplicitReceiver && !(ast.receiver instanceof ThisReceiver);
19737
+ const isSpecialNode = ast.name === "$any" || ast.name === "$event";
19738
+ if (isImplicitReceiver || isThisReceiver && !isSpecialNode) {
19644
19739
  return new LexicalReadExpr(ast.name);
19645
19740
  } else {
19646
19741
  return new ReadPropExpr(convertAst(ast.receiver, job, baseSourceSpan), ast.name, null, convertSourceSpan(ast.span, baseSourceSpan));
@@ -19718,13 +19813,13 @@ function convertAst(ast, job, baseSourceSpan) {
19718
19813
  throw new Error(`Unhandled expression type "${ast.constructor.name}" in file "${baseSourceSpan == null ? void 0 : baseSourceSpan.start.file.url}"`);
19719
19814
  }
19720
19815
  }
19721
- function convertAstWithInterpolation(job, value, i18nMeta) {
19816
+ function convertAstWithInterpolation(job, value, i18nMeta, sourceSpan) {
19722
19817
  var _a2, _b2;
19723
19818
  let expression;
19724
19819
  if (value instanceof Interpolation) {
19725
- expression = new Interpolation2(value.strings, value.expressions.map((e) => convertAst(e, job, null)), Object.keys((_b2 = (_a2 = asMessage(i18nMeta)) == null ? void 0 : _a2.placeholders) != null ? _b2 : {}));
19820
+ expression = new Interpolation2(value.strings, value.expressions.map((e) => convertAst(e, job, sourceSpan != null ? sourceSpan : null)), Object.keys((_b2 = (_a2 = asMessage(i18nMeta)) == null ? void 0 : _a2.placeholders) != null ? _b2 : {}));
19726
19821
  } else if (value instanceof AST) {
19727
- expression = convertAst(value, job, null);
19822
+ expression = convertAst(value, job, sourceSpan != null ? sourceSpan : null);
19728
19823
  } else {
19729
19824
  expression = literal(value);
19730
19825
  }
@@ -22819,7 +22914,12 @@ var TemplateDefinitionBuilder = class {
22819
22914
  });
22820
22915
  const { expression: trackByExpression, usesComponentInstance: trackByUsesComponentInstance } = this.createTrackByFunction(block);
22821
22916
  let emptyData = null;
22917
+ let emptyTagName = null;
22918
+ let emptyAttrsExprs;
22822
22919
  if (block.empty !== null) {
22920
+ const emptyInferred = this.inferProjectionDataFromInsertionPoint(block.empty);
22921
+ emptyTagName = emptyInferred.tagName;
22922
+ emptyAttrsExprs = emptyInferred.attrsExprs;
22823
22923
  emptyData = this.prepareEmbeddedTemplateFn(block.empty.children, "_ForEmpty", void 0, block.empty.i18n);
22824
22924
  this.allocateBindingSlots(null);
22825
22925
  }
@@ -22835,11 +22935,11 @@ var TemplateDefinitionBuilder = class {
22835
22935
  trackByExpression
22836
22936
  ];
22837
22937
  if (emptyData !== null) {
22838
- params.push(literal(trackByUsesComponentInstance), variable(emptyData.name), literal(emptyData.getConstCount()), literal(emptyData.getVarCount()));
22938
+ params.push(literal(trackByUsesComponentInstance), variable(emptyData.name), literal(emptyData.getConstCount()), literal(emptyData.getVarCount()), literal(emptyTagName), this.addAttrsToConsts(emptyAttrsExprs || null));
22839
22939
  } else if (trackByUsesComponentInstance) {
22840
22940
  params.push(literal(trackByUsesComponentInstance));
22841
22941
  }
22842
- return params;
22942
+ return trimTrailingNulls(params);
22843
22943
  });
22844
22944
  const value = block.expression.visit(this._valueConverter);
22845
22945
  this.updateInstructionWithAdvance(blockIndex, block.sourceSpan, Identifiers.repeater, () => [this.convertPropertyBinding(value)]);
@@ -23402,12 +23502,15 @@ var BindingScope = class {
23402
23502
  }
23403
23503
  };
23404
23504
  var TrackByBindingScope = class extends BindingScope {
23405
- constructor(parentScope, globalAliases) {
23505
+ constructor(parentScope, globalOverrides) {
23406
23506
  super(parentScope.bindingLevel + 1, parentScope);
23407
- this.globalAliases = globalAliases;
23507
+ this.globalOverrides = globalOverrides;
23408
23508
  this.componentAccessCount = 0;
23409
23509
  }
23410
23510
  get(name) {
23511
+ if (this.globalOverrides.hasOwnProperty(name)) {
23512
+ return variable(this.globalOverrides[name]);
23513
+ }
23411
23514
  let current = this.parent;
23412
23515
  while (current) {
23413
23516
  if (current.hasLocal(name)) {
@@ -23415,9 +23518,6 @@ var TrackByBindingScope = class extends BindingScope {
23415
23518
  }
23416
23519
  current = current.parent;
23417
23520
  }
23418
- if (this.globalAliases[name]) {
23419
- return variable(this.globalAliases[name]);
23420
- }
23421
23521
  this.componentAccessCount++;
23422
23522
  return variable("this").prop(name);
23423
23523
  }
@@ -25436,7 +25536,7 @@ function publishFacade(global) {
25436
25536
  }
25437
25537
 
25438
25538
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/version.mjs
25439
- var VERSION2 = new Version("17.1.0-next.4");
25539
+ var VERSION2 = new Version("17.1.0-next.5");
25440
25540
 
25441
25541
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
25442
25542
  var _VisitorMode;
@@ -25480,6 +25580,20 @@ var FactoryTarget2;
25480
25580
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/compiler.mjs
25481
25581
  publishFacade(_global);
25482
25582
 
25583
+ // bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/identifier-lookup.mjs
25584
+ var import_typescript5 = __toESM(require("typescript"), 1);
25585
+ function lookupIdentifiersInSourceFile(sourceFile, names) {
25586
+ const results = /* @__PURE__ */ new Set();
25587
+ const visit = (node) => {
25588
+ if (import_typescript5.default.isIdentifier(node) && names.includes(node.text)) {
25589
+ results.add(node);
25590
+ }
25591
+ import_typescript5.default.forEachChild(node, visit);
25592
+ };
25593
+ visit(sourceFile);
25594
+ return results;
25595
+ }
25596
+
25483
25597
  // bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/types.mjs
25484
25598
  var ngtemplate = "ng-template";
25485
25599
  var boundngifelse = "[ngIfElse]";
@@ -25490,6 +25604,18 @@ var startMarker = "\u25EC";
25490
25604
  var endMarker = "\u2722";
25491
25605
  var startI18nMarker = "\u2688";
25492
25606
  var endI18nMarker = "\u2689";
25607
+ var importRemovals = [
25608
+ "NgIf",
25609
+ "NgIfElse",
25610
+ "NgIfThenElse",
25611
+ "NgFor",
25612
+ "NgForOf",
25613
+ "NgForTrackBy",
25614
+ "NgSwitch",
25615
+ "NgSwitchCase",
25616
+ "NgSwitchDefault"
25617
+ ];
25618
+ var importWithCommonRemovals = [...importRemovals, "CommonModule"];
25493
25619
  function allFormsOf(selector) {
25494
25620
  return [
25495
25621
  selector,
@@ -25639,22 +25765,24 @@ var Template2 = class {
25639
25765
  }
25640
25766
  };
25641
25767
  var AnalyzedFile = class {
25642
- constructor() {
25768
+ constructor(sourceFile) {
25643
25769
  __publicField(this, "ranges", []);
25644
25770
  __publicField(this, "removeCommonModule", false);
25645
25771
  __publicField(this, "canRemoveImports", false);
25646
- __publicField(this, "sourceFilePath", "");
25772
+ __publicField(this, "sourceFile");
25773
+ __publicField(this, "importRanges", []);
25774
+ __publicField(this, "templateRanges", []);
25775
+ this.sourceFile = sourceFile;
25647
25776
  }
25648
25777
  getSortedRanges() {
25649
- const templateRanges = this.ranges.slice().filter((x) => x.type !== "import").sort((aStart, bStart) => bStart.start - aStart.start);
25650
- const importRanges = this.ranges.slice().filter((x) => x.type === "import").sort((aStart, bStart) => bStart.start - aStart.start);
25651
- return [...templateRanges, ...importRanges];
25778
+ this.templateRanges = this.ranges.slice().filter((x) => x.type === "template" || x.type === "templateUrl").sort((aStart, bStart) => bStart.start - aStart.start);
25779
+ this.importRanges = this.ranges.slice().filter((x) => x.type === "importDecorator" || x.type === "importDeclaration").sort((aStart, bStart) => bStart.start - aStart.start);
25780
+ return [...this.templateRanges, ...this.importRanges];
25652
25781
  }
25653
- static addRange(path2, sourceFilePath, analyzedFiles, range) {
25782
+ static addRange(path2, sourceFile, analyzedFiles, range) {
25654
25783
  let analysis = analyzedFiles.get(path2);
25655
25784
  if (!analysis) {
25656
- analysis = new AnalyzedFile();
25657
- analysis.sourceFilePath = sourceFilePath;
25785
+ analysis = new AnalyzedFile(sourceFile);
25658
25786
  analyzedFiles.set(path2, analysis);
25659
25787
  }
25660
25788
  const duplicate = analysis.ranges.find((current) => current.start === range.start && current.end === range.end);
@@ -25662,6 +25790,25 @@ var AnalyzedFile = class {
25662
25790
  analysis.ranges.push(range);
25663
25791
  }
25664
25792
  }
25793
+ verifyCanRemoveImports() {
25794
+ const importDeclaration = this.importRanges.find((r) => r.type === "importDeclaration");
25795
+ const instances = lookupIdentifiersInSourceFile(this.sourceFile, importWithCommonRemovals);
25796
+ let foundImportDeclaration = false;
25797
+ let count = 0;
25798
+ for (let range of this.importRanges) {
25799
+ for (let instance of instances) {
25800
+ if (instance.getStart() >= range.start && instance.getEnd() <= range.end) {
25801
+ if (range === importDeclaration) {
25802
+ foundImportDeclaration = true;
25803
+ }
25804
+ count++;
25805
+ }
25806
+ }
25807
+ }
25808
+ if (instances.size !== count && importDeclaration !== void 0 && foundImportDeclaration) {
25809
+ importDeclaration.remove = false;
25810
+ }
25811
+ }
25665
25812
  };
25666
25813
  var CommonCollector = class extends RecursiveVisitor {
25667
25814
  constructor() {
@@ -25782,19 +25929,7 @@ var TemplateCollector = class extends RecursiveVisitor {
25782
25929
 
25783
25930
  // bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/util.mjs
25784
25931
  var import_path2 = require("path");
25785
- var import_typescript5 = __toESM(require("typescript"), 1);
25786
- var importRemovals = [
25787
- "NgIf",
25788
- "NgIfElse",
25789
- "NgIfThenElse",
25790
- "NgFor",
25791
- "NgForOf",
25792
- "NgForTrackBy",
25793
- "NgSwitch",
25794
- "NgSwitchCase",
25795
- "NgSwitchDefault"
25796
- ];
25797
- var importWithCommonRemovals = [...importRemovals, "CommonModule"];
25932
+ var import_typescript6 = __toESM(require("typescript"), 1);
25798
25933
  var startMarkerRegex = new RegExp(startMarker, "gm");
25799
25934
  var endMarkerRegex = new RegExp(endMarker, "gm");
25800
25935
  var startI18nMarkerRegex = new RegExp(startI18nMarker, "gm");
@@ -25802,16 +25937,20 @@ var endI18nMarkerRegex = new RegExp(endI18nMarker, "gm");
25802
25937
  var replaceMarkerRegex = new RegExp(`${startMarker}|${endMarker}`, "gm");
25803
25938
  function analyze(sourceFile, analyzedFiles) {
25804
25939
  forEachClass(sourceFile, (node) => {
25805
- if (import_typescript5.default.isClassDeclaration(node)) {
25940
+ if (import_typescript6.default.isClassDeclaration(node)) {
25806
25941
  analyzeDecorators(node, sourceFile, analyzedFiles);
25807
25942
  } else {
25808
25943
  analyzeImportDeclarations(node, sourceFile, analyzedFiles);
25809
25944
  }
25810
25945
  });
25811
25946
  }
25812
- function checkIfShouldChange(decl, removeCommonModule) {
25947
+ function checkIfShouldChange(decl, file) {
25948
+ const range = file.importRanges.find((r) => r.type === "importDeclaration");
25949
+ if (range === void 0 || !range.remove) {
25950
+ return false;
25951
+ }
25813
25952
  const clause = decl.getChildAt(1);
25814
- return !(!removeCommonModule && clause.namedBindings && import_typescript5.default.isNamedImports(clause.namedBindings) && clause.namedBindings.elements.length === 1 && clause.namedBindings.elements[0].getText() === "CommonModule");
25953
+ return !(!file.removeCommonModule && clause.namedBindings && import_typescript6.default.isNamedImports(clause.namedBindings) && clause.namedBindings.elements.length === 1 && clause.namedBindings.elements[0].getText() === "CommonModule");
25815
25954
  }
25816
25955
  function updateImportDeclaration(decl, removeCommonModule) {
25817
25956
  const clause = decl.getChildAt(1);
@@ -25819,81 +25958,89 @@ function updateImportDeclaration(decl, removeCommonModule) {
25819
25958
  if (updatedClause === null) {
25820
25959
  return "";
25821
25960
  }
25822
- const printer = import_typescript5.default.createPrinter({
25961
+ const printer = import_typescript6.default.createPrinter({
25823
25962
  removeComments: true
25824
25963
  });
25825
- const updated = import_typescript5.default.factory.updateImportDeclaration(decl, decl.modifiers, updatedClause, decl.moduleSpecifier, void 0);
25826
- return printer.printNode(import_typescript5.default.EmitHint.Unspecified, updated, clause.getSourceFile());
25964
+ const updated = import_typescript6.default.factory.updateImportDeclaration(decl, decl.modifiers, updatedClause, decl.moduleSpecifier, void 0);
25965
+ return printer.printNode(import_typescript6.default.EmitHint.Unspecified, updated, clause.getSourceFile());
25827
25966
  }
25828
25967
  function updateImportClause(clause, removeCommonModule) {
25829
- if (clause.namedBindings && import_typescript5.default.isNamedImports(clause.namedBindings)) {
25968
+ if (clause.namedBindings && import_typescript6.default.isNamedImports(clause.namedBindings)) {
25830
25969
  const removals = removeCommonModule ? importWithCommonRemovals : importRemovals;
25831
25970
  const elements = clause.namedBindings.elements.filter((el) => !removals.includes(el.getText()));
25832
25971
  if (elements.length === 0) {
25833
25972
  return null;
25834
25973
  }
25835
- clause = import_typescript5.default.factory.updateImportClause(clause, clause.isTypeOnly, clause.name, import_typescript5.default.factory.createNamedImports(elements));
25974
+ clause = import_typescript6.default.factory.updateImportClause(clause, clause.isTypeOnly, clause.name, import_typescript6.default.factory.createNamedImports(elements));
25836
25975
  }
25837
25976
  return clause;
25838
25977
  }
25839
25978
  function updateClassImports(propAssignment, removeCommonModule) {
25840
- const printer = import_typescript5.default.createPrinter();
25979
+ const printer = import_typescript6.default.createPrinter();
25841
25980
  const importList = propAssignment.initializer;
25842
25981
  const removals = removeCommonModule ? importWithCommonRemovals : importRemovals;
25843
25982
  const elements = importList.elements.filter((el) => !removals.includes(el.getText()));
25844
25983
  if (elements.length === importList.elements.length) {
25845
25984
  return null;
25846
25985
  }
25847
- const updatedElements = import_typescript5.default.factory.updateArrayLiteralExpression(importList, elements);
25848
- const updatedAssignment = import_typescript5.default.factory.updatePropertyAssignment(propAssignment, propAssignment.name, updatedElements);
25849
- return printer.printNode(import_typescript5.default.EmitHint.Unspecified, updatedAssignment, updatedAssignment.getSourceFile());
25986
+ const updatedElements = import_typescript6.default.factory.updateArrayLiteralExpression(importList, elements);
25987
+ const updatedAssignment = import_typescript6.default.factory.updatePropertyAssignment(propAssignment, propAssignment.name, updatedElements);
25988
+ return printer.printNode(import_typescript6.default.EmitHint.Unspecified, updatedAssignment, updatedAssignment.getSourceFile());
25850
25989
  }
25851
25990
  function analyzeImportDeclarations(node, sourceFile, analyzedFiles) {
25852
25991
  if (node.getText().indexOf("@angular/common") === -1) {
25853
25992
  return;
25854
25993
  }
25855
25994
  const clause = node.getChildAt(1);
25856
- if (clause.namedBindings && import_typescript5.default.isNamedImports(clause.namedBindings)) {
25995
+ if (clause.namedBindings && import_typescript6.default.isNamedImports(clause.namedBindings)) {
25857
25996
  const elements = clause.namedBindings.elements.filter((el) => importWithCommonRemovals.includes(el.getText()));
25858
25997
  if (elements.length > 0) {
25859
- AnalyzedFile.addRange(sourceFile.fileName, sourceFile.fileName, analyzedFiles, { start: node.getStart(), end: node.getEnd(), node, type: "import" });
25998
+ AnalyzedFile.addRange(sourceFile.fileName, sourceFile, analyzedFiles, {
25999
+ start: node.getStart(),
26000
+ end: node.getEnd(),
26001
+ node,
26002
+ type: "importDeclaration",
26003
+ remove: true
26004
+ });
25860
26005
  }
25861
26006
  }
25862
26007
  }
25863
26008
  function analyzeDecorators(node, sourceFile, analyzedFiles) {
25864
26009
  var _a2;
25865
- const decorator = (_a2 = import_typescript5.default.getDecorators(node)) == null ? void 0 : _a2.find((dec) => {
25866
- return import_typescript5.default.isCallExpression(dec.expression) && import_typescript5.default.isIdentifier(dec.expression.expression) && dec.expression.expression.text === "Component";
26010
+ const decorator = (_a2 = import_typescript6.default.getDecorators(node)) == null ? void 0 : _a2.find((dec) => {
26011
+ return import_typescript6.default.isCallExpression(dec.expression) && import_typescript6.default.isIdentifier(dec.expression.expression) && dec.expression.expression.text === "Component";
25867
26012
  });
25868
- const metadata = decorator && decorator.expression.arguments.length > 0 && import_typescript5.default.isObjectLiteralExpression(decorator.expression.arguments[0]) ? decorator.expression.arguments[0] : null;
26013
+ const metadata = decorator && decorator.expression.arguments.length > 0 && import_typescript6.default.isObjectLiteralExpression(decorator.expression.arguments[0]) ? decorator.expression.arguments[0] : null;
25869
26014
  if (!metadata) {
25870
26015
  return;
25871
26016
  }
25872
26017
  for (const prop of metadata.properties) {
25873
- if (!import_typescript5.default.isPropertyAssignment(prop) || !import_typescript5.default.isIdentifier(prop.name) && !import_typescript5.default.isStringLiteralLike(prop.name)) {
26018
+ if (!import_typescript6.default.isPropertyAssignment(prop) || !import_typescript6.default.isIdentifier(prop.name) && !import_typescript6.default.isStringLiteralLike(prop.name)) {
25874
26019
  continue;
25875
26020
  }
25876
26021
  switch (prop.name.text) {
25877
26022
  case "template":
25878
- AnalyzedFile.addRange(sourceFile.fileName, sourceFile.fileName, analyzedFiles, {
26023
+ AnalyzedFile.addRange(sourceFile.fileName, sourceFile, analyzedFiles, {
25879
26024
  start: prop.initializer.getStart() + 1,
25880
26025
  end: prop.initializer.getEnd() - 1,
25881
26026
  node: prop,
25882
- type: "template"
26027
+ type: "template",
26028
+ remove: true
25883
26029
  });
25884
26030
  break;
25885
26031
  case "imports":
25886
- AnalyzedFile.addRange(sourceFile.fileName, sourceFile.fileName, analyzedFiles, {
26032
+ AnalyzedFile.addRange(sourceFile.fileName, sourceFile, analyzedFiles, {
25887
26033
  start: prop.name.getStart(),
25888
26034
  end: prop.initializer.getEnd(),
25889
26035
  node: prop,
25890
- type: "import"
26036
+ type: "importDecorator",
26037
+ remove: true
25891
26038
  });
25892
26039
  break;
25893
26040
  case "templateUrl":
25894
- if (import_typescript5.default.isStringLiteralLike(prop.initializer)) {
26041
+ if (import_typescript6.default.isStringLiteralLike(prop.initializer)) {
25895
26042
  const path2 = (0, import_path2.join)((0, import_path2.dirname)(sourceFile.fileName), prop.initializer.text);
25896
- AnalyzedFile.addRange(path2, sourceFile.fileName, analyzedFiles, { start: 0, node: prop, type: "templateUrl" });
26043
+ AnalyzedFile.addRange(path2, sourceFile, analyzedFiles, { start: 0, node: prop, type: "templateUrl", remove: true });
25897
26044
  }
25898
26045
  break;
25899
26046
  }
@@ -25928,6 +26075,41 @@ function parseTemplate2(template2) {
25928
26075
  }
25929
26076
  return { tree: parsed, errors: [] };
25930
26077
  }
26078
+ function validateMigratedTemplate(migrated, fileName) {
26079
+ const parsed = parseTemplate2(migrated);
26080
+ let errors = [];
26081
+ if (parsed.errors.length > 0) {
26082
+ errors.push({
26083
+ type: "parse",
26084
+ error: new Error(`The migration resulted in invalid HTML for ${fileName}. Please check the template for valid HTML structures and run the migration again.`)
26085
+ });
26086
+ }
26087
+ if (parsed.tree) {
26088
+ const i18nError = validateI18nStructure(parsed.tree, fileName);
26089
+ if (i18nError !== null) {
26090
+ errors.push({ type: "i18n", error: i18nError });
26091
+ }
26092
+ }
26093
+ return errors;
26094
+ }
26095
+ function validateI18nStructure(parsed, fileName) {
26096
+ const visitor = new i18nCollector();
26097
+ visitAll2(visitor, parsed.rootNodes);
26098
+ const parents = visitor.elements.filter((el) => el.children.length > 0);
26099
+ for (const p of parents) {
26100
+ for (const el of visitor.elements) {
26101
+ if (el === p)
26102
+ continue;
26103
+ if (isChildOf(p, el)) {
26104
+ 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.`);
26105
+ }
26106
+ }
26107
+ }
26108
+ return null;
26109
+ }
26110
+ function isChildOf(parent, el) {
26111
+ return parent.sourceSpan.start.offset < el.sourceSpan.start.offset && parent.sourceSpan.end.offset > el.sourceSpan.end.offset;
26112
+ }
25931
26113
  function calculateNesting(visitor, hasLineBreaks2) {
25932
26114
  let nestedQueue = [];
25933
26115
  for (let i = 0; i < visitor.elements.length; i++) {
@@ -26049,12 +26231,12 @@ function canRemoveCommonModule(template2) {
26049
26231
  }
26050
26232
  return removeCommonModule;
26051
26233
  }
26052
- function removeImports(template2, node, removeCommonModule) {
26053
- if (template2.startsWith("imports") && import_typescript5.default.isPropertyAssignment(node)) {
26054
- const updatedImport = updateClassImports(node, removeCommonModule);
26234
+ function removeImports(template2, node, file) {
26235
+ if (template2.startsWith("imports") && import_typescript6.default.isPropertyAssignment(node)) {
26236
+ const updatedImport = updateClassImports(node, file.removeCommonModule);
26055
26237
  return updatedImport != null ? updatedImport : template2;
26056
- } else if (import_typescript5.default.isImportDeclaration(node) && checkIfShouldChange(node, removeCommonModule)) {
26057
- return updateImportDeclaration(node, removeCommonModule);
26238
+ } else if (import_typescript6.default.isImportDeclaration(node) && checkIfShouldChange(node, file)) {
26239
+ return updateImportDeclaration(node, file.removeCommonModule);
26058
26240
  }
26059
26241
  return template2;
26060
26242
  }
@@ -26159,6 +26341,10 @@ function formatTemplate(tmpl, templateType) {
26159
26341
  let openSelfClosingEl = false;
26160
26342
  const openBlockRegex = /^\s*\@(if|switch|case|default|for)|^\s*\}\s\@else/;
26161
26343
  const openElRegex = /^\s*<([a-z0-9]+)(?![^>]*\/>)[^>]*>?/;
26344
+ const openAttrDoubleRegex = /="([^"]|\\")*$/;
26345
+ const openAttrSingleRegex = /='([^']|\\')*$/;
26346
+ const closeAttrDoubleRegex = /^\s*([^><]|\\")*"/;
26347
+ const closeAttrSingleRegex = /^\s*([^><]|\\')*'/;
26162
26348
  const selfClosingRegex = new RegExp(`^\\s*<(${selfClosingList}).+\\/?>`);
26163
26349
  const openSelfClosingRegex = new RegExp(`^\\s*<(${selfClosingList})(?![^>]*\\/>)[^>]*$`);
26164
26350
  const closeBlockRegex = /^\s*\}\s*$|^\s*\}\s\@else/;
@@ -26174,6 +26360,8 @@ function formatTemplate(tmpl, templateType) {
26174
26360
  let i18nDepth = 0;
26175
26361
  let inMigratedBlock = false;
26176
26362
  let inI18nBlock = false;
26363
+ let inAttribute = false;
26364
+ let isDoubleQuotes = false;
26177
26365
  for (let [index, line] of lines.entries()) {
26178
26366
  depth += [...line.matchAll(startMarkerRegex)].length - [...line.matchAll(endMarkerRegex)].length;
26179
26367
  inMigratedBlock = depth > 0;
@@ -26183,7 +26371,7 @@ function formatTemplate(tmpl, templateType) {
26183
26371
  line = line.replace(replaceMarkerRegex, "");
26184
26372
  lineWasMigrated = true;
26185
26373
  }
26186
- if (line.trim() === "" && index !== 0 && index !== lines.length - 1 && (inMigratedBlock || lineWasMigrated)) {
26374
+ if (line.trim() === "" && index !== 0 && index !== lines.length - 1 && (inMigratedBlock || lineWasMigrated) && !inI18nBlock && !inAttribute) {
26187
26375
  continue;
26188
26376
  }
26189
26377
  if (templateType === "template" && index <= 1) {
@@ -26193,8 +26381,20 @@ function formatTemplate(tmpl, templateType) {
26193
26381
  if ((closeBlockRegex.test(line) || closeElRegex.test(line) && (!singleLineElRegex.test(line) && !closeMultiLineElRegex.test(line))) && indent !== "") {
26194
26382
  indent = indent.slice(2);
26195
26383
  }
26196
- const newLine = inI18nBlock ? line : mindent + (line.trim() !== "" ? indent : "") + line.trim();
26384
+ const isOpenDoubleAttr = openAttrDoubleRegex.test(line);
26385
+ const isOpenSingleAttr = openAttrSingleRegex.test(line);
26386
+ if (!inAttribute && isOpenDoubleAttr) {
26387
+ inAttribute = true;
26388
+ isDoubleQuotes = true;
26389
+ } else if (!inAttribute && isOpenSingleAttr) {
26390
+ inAttribute = true;
26391
+ isDoubleQuotes = false;
26392
+ }
26393
+ const newLine = inI18nBlock || inAttribute ? line : mindent + (line.trim() !== "" ? indent : "") + line.trim();
26197
26394
  formatted.push(newLine);
26395
+ if (!isOpenDoubleAttr && !isOpenSingleAttr && (inAttribute && isDoubleQuotes && closeAttrDoubleRegex.test(line) || inAttribute && !isDoubleQuotes && closeAttrSingleRegex.test(line))) {
26396
+ inAttribute = false;
26397
+ }
26198
26398
  if (closeMultiLineElRegex.test(line)) {
26199
26399
  indent = indent.slice(2);
26200
26400
  if (openSelfClosingEl) {
@@ -26220,7 +26420,7 @@ function formatTemplate(tmpl, templateType) {
26220
26420
  }
26221
26421
  function forEachClass(sourceFile, callback) {
26222
26422
  sourceFile.forEachChild(function walk(node) {
26223
- if (import_typescript5.default.isClassDeclaration(node) || import_typescript5.default.isImportDeclaration(node)) {
26423
+ if (import_typescript6.default.isClassDeclaration(node) || import_typescript6.default.isImportDeclaration(node)) {
26224
26424
  callback(node);
26225
26425
  }
26226
26426
  node.forEachChild(walk);
@@ -26461,10 +26661,10 @@ function getNgForParts(expression) {
26461
26661
  current = "";
26462
26662
  continue;
26463
26663
  }
26464
- if (stringPairs.has(char)) {
26465
- stringStack.push(stringPairs.get(char));
26466
- } else if (stringStack.length > 0 && stringStack[stringStack.length - 1] === char) {
26664
+ if (stringStack.length > 0 && stringStack[stringStack.length - 1] === char) {
26467
26665
  stringStack.pop();
26666
+ } else if (stringPairs.has(char)) {
26667
+ stringStack.push(stringPairs.get(char));
26468
26668
  }
26469
26669
  if (commaSeparatedSyntax.has(char)) {
26470
26670
  commaSeparatedStack.push(commaSeparatedSyntax.get(char));
@@ -26719,13 +26919,9 @@ function migrateTemplate(template2, templateType, node, file, format = true, ana
26719
26919
  migrated = templateResult.migrated;
26720
26920
  const changed = ifResult.changed || forResult.changed || switchResult.changed || caseResult.changed;
26721
26921
  if (changed) {
26722
- const parsed = parseTemplate2(migrated);
26723
- if (parsed.errors.length > 0) {
26724
- const parsingError = {
26725
- type: "parse",
26726
- error: new Error(`The migration resulted in invalid HTML for ${file.sourceFilePath}. Please check the template for valid HTML structures and run the migration again.`)
26727
- };
26728
- return { migrated: template2, errors: [parsingError] };
26922
+ const errors2 = validateMigratedTemplate(migrated, file.sourceFile.fileName);
26923
+ if (errors2.length > 0) {
26924
+ return { migrated: template2, errors: errors2 };
26729
26925
  }
26730
26926
  }
26731
26927
  if (format && changed) {
@@ -26735,11 +26931,14 @@ function migrateTemplate(template2, templateType, node, file, format = true, ana
26735
26931
  migrated = migrated.replace(markerRegex, "");
26736
26932
  file.removeCommonModule = canRemoveCommonModule(template2);
26737
26933
  file.canRemoveImports = true;
26738
- if (templateType === "templateUrl" && analyzedFiles !== null && analyzedFiles.has(file.sourceFilePath)) {
26739
- const componentFile = analyzedFiles.get(file.sourceFilePath);
26934
+ if (templateType === "templateUrl" && analyzedFiles !== null && analyzedFiles.has(file.sourceFile.fileName)) {
26935
+ const componentFile = analyzedFiles.get(file.sourceFile.fileName);
26936
+ componentFile.getSortedRanges();
26740
26937
  componentFile.removeCommonModule = file.removeCommonModule;
26741
26938
  componentFile.canRemoveImports = file.canRemoveImports;
26939
+ componentFile.verifyCanRemoveImports();
26742
26940
  }
26941
+ file.verifyCanRemoveImports();
26743
26942
  errors = [
26744
26943
  ...ifResult.errors,
26745
26944
  ...forResult.errors,
@@ -26747,7 +26946,7 @@ function migrateTemplate(template2, templateType, node, file, format = true, ana
26747
26946
  ...caseResult.errors
26748
26947
  ];
26749
26948
  } else if (file.canRemoveImports) {
26750
- migrated = removeImports(template2, node, file.removeCommonModule);
26949
+ migrated = removeImports(template2, node, file);
26751
26950
  }
26752
26951
  return { migrated, errors };
26753
26952
  }