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

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 (69) hide show
  1. package/esm2022/primitives/signals/src/signal.mjs +2 -9
  2. package/esm2022/src/application/application_config.mjs +21 -0
  3. package/esm2022/src/application/application_init.mjs +188 -0
  4. package/esm2022/src/application/application_module.mjs +29 -0
  5. package/esm2022/src/application/application_ref.mjs +509 -0
  6. package/esm2022/src/application/application_tokens.mjs +121 -0
  7. package/esm2022/src/application/create_application.mjs +102 -0
  8. package/esm2022/src/authoring/input.mjs +41 -0
  9. package/esm2022/src/authoring/input_signal.mjs +10 -0
  10. package/esm2022/src/authoring/input_type_checking.mjs +9 -0
  11. package/esm2022/src/authoring.mjs +12 -0
  12. package/esm2022/src/change_detection/scheduling.mjs +103 -0
  13. package/esm2022/src/compiler/compiler_facade_interface.mjs +1 -1
  14. package/esm2022/src/core.mjs +15 -7
  15. package/esm2022/src/core_private_export.mjs +5 -3
  16. package/esm2022/src/core_reactivity_export_internal.mjs +2 -2
  17. package/esm2022/src/core_render3_private_export.mjs +2 -2
  18. package/esm2022/src/error_handler.mjs +15 -1
  19. package/esm2022/src/hydration/annotate.mjs +30 -20
  20. package/esm2022/src/hydration/api.mjs +2 -2
  21. package/esm2022/src/hydration/cleanup.mjs +1 -1
  22. package/esm2022/src/hydration/interfaces.mjs +1 -1
  23. package/esm2022/src/hydration/node_lookup_utils.mjs +23 -2
  24. package/esm2022/src/image_performance_warning.mjs +2 -2
  25. package/esm2022/src/linker/query_list.mjs +8 -6
  26. package/esm2022/src/metadata/do_bootstrap.mjs +1 -1
  27. package/esm2022/src/platform/platform.mjs +135 -0
  28. package/esm2022/src/platform/platform_core_providers.mjs +15 -0
  29. package/esm2022/src/platform/platform_ref.mjs +179 -0
  30. package/esm2022/src/render3/instructions/change_detection.mjs +2 -4
  31. package/esm2022/src/render3/interfaces/definition.mjs +1 -1
  32. package/esm2022/src/render3/interfaces/public_definitions.mjs +1 -1
  33. package/esm2022/src/render3/list_reconciliation.mjs +58 -24
  34. package/esm2022/src/render3/node_manipulation.mjs +2 -2
  35. package/esm2022/src/render3/util/change_detection_utils.mjs +3 -1
  36. package/esm2022/src/render3/util/misc_utils.mjs +2 -2
  37. package/esm2022/src/render3/view_manipulation.mjs +13 -5
  38. package/esm2022/src/render3/view_ref.mjs +7 -1
  39. package/esm2022/src/transfer_state.mjs +2 -2
  40. package/esm2022/src/util/performance.mjs +2 -2
  41. package/esm2022/src/version.mjs +1 -1
  42. package/esm2022/src/zone/ng_zone.mjs +10 -1
  43. package/esm2022/testing/src/component_fixture.mjs +20 -36
  44. package/esm2022/testing/src/logger.mjs +3 -3
  45. package/esm2022/testing/src/test_bed.mjs +5 -6
  46. package/fesm2022/core.mjs +1280 -1169
  47. package/fesm2022/core.mjs.map +1 -1
  48. package/fesm2022/primitives/signals.mjs +2 -9
  49. package/fesm2022/primitives/signals.mjs.map +1 -1
  50. package/fesm2022/rxjs-interop.mjs +1 -1
  51. package/fesm2022/testing.mjs +46 -64
  52. package/fesm2022/testing.mjs.map +1 -1
  53. package/index.d.ts +161 -21
  54. package/package.json +1 -1
  55. package/primitives/signals/index.d.ts +1 -1
  56. package/rxjs-interop/index.d.ts +1 -1
  57. package/schematics/migrations/block-template-entities/bundle.js +951 -429
  58. package/schematics/migrations/block-template-entities/bundle.js.map +4 -4
  59. package/schematics/ng-generate/control-flow-migration/bundle.js +1214 -497
  60. package/schematics/ng-generate/control-flow-migration/bundle.js.map +4 -4
  61. package/schematics/ng-generate/standalone-migration/bundle.js +2023 -1223
  62. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  63. package/testing/index.d.ts +6 -10
  64. package/esm2022/src/application_config.mjs +0 -21
  65. package/esm2022/src/application_init.mjs +0 -188
  66. package/esm2022/src/application_module.mjs +0 -29
  67. package/esm2022/src/application_ref.mjs +0 -997
  68. package/esm2022/src/application_tokens.mjs +0 -121
  69. package/esm2022/src/platform_core_providers.mjs +0 -15
@@ -2517,6 +2517,12 @@ var Identifiers = _Identifiers;
2517
2517
  (() => {
2518
2518
  _Identifiers.validateIframeAttribute = { name: "\u0275\u0275validateIframeAttribute", moduleName: CORE };
2519
2519
  })();
2520
+ (() => {
2521
+ _Identifiers.InputSignalBrandWriteType = { name: "\u0275INPUT_SIGNAL_BRAND_WRITE_TYPE", moduleName: CORE };
2522
+ })();
2523
+ (() => {
2524
+ _Identifiers.UnwrapDirectiveSignalInputs = { name: "\u0275UnwrapDirectiveSignalInputs", moduleName: CORE };
2525
+ })();
2520
2526
 
2521
2527
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/util.mjs
2522
2528
  var DASH_CASE_REGEXP = /-+([a-z0-9])/g;
@@ -7040,6 +7046,7 @@ var OpKind;
7040
7046
  OpKind2[OpKind2["IcuStart"] = 41] = "IcuStart";
7041
7047
  OpKind2[OpKind2["IcuEnd"] = 42] = "IcuEnd";
7042
7048
  OpKind2[OpKind2["I18nContext"] = 43] = "I18nContext";
7049
+ OpKind2[OpKind2["I18nAttributes"] = 44] = "I18nAttributes";
7043
7050
  })(OpKind || (OpKind = {}));
7044
7051
  var ExpressionKind;
7045
7052
  (function(ExpressionKind2) {
@@ -7064,10 +7071,11 @@ var ExpressionKind;
7064
7071
  ExpressionKind2[ExpressionKind2["AssignTemporaryExpr"] = 18] = "AssignTemporaryExpr";
7065
7072
  ExpressionKind2[ExpressionKind2["ReadTemporaryExpr"] = 19] = "ReadTemporaryExpr";
7066
7073
  ExpressionKind2[ExpressionKind2["SanitizerExpr"] = 20] = "SanitizerExpr";
7067
- ExpressionKind2[ExpressionKind2["SlotLiteralExpr"] = 21] = "SlotLiteralExpr";
7068
- ExpressionKind2[ExpressionKind2["ConditionalCase"] = 22] = "ConditionalCase";
7069
- ExpressionKind2[ExpressionKind2["DerivedRepeaterVar"] = 23] = "DerivedRepeaterVar";
7070
- ExpressionKind2[ExpressionKind2["ConstCollected"] = 24] = "ConstCollected";
7074
+ ExpressionKind2[ExpressionKind2["TrustedValueFnExpr"] = 21] = "TrustedValueFnExpr";
7075
+ ExpressionKind2[ExpressionKind2["SlotLiteralExpr"] = 22] = "SlotLiteralExpr";
7076
+ ExpressionKind2[ExpressionKind2["ConditionalCase"] = 23] = "ConditionalCase";
7077
+ ExpressionKind2[ExpressionKind2["DerivedRepeaterVar"] = 24] = "DerivedRepeaterVar";
7078
+ ExpressionKind2[ExpressionKind2["ConstCollected"] = 25] = "ConstCollected";
7071
7079
  })(ExpressionKind || (ExpressionKind = {}));
7072
7080
  var VariableFlags;
7073
7081
  (function(VariableFlags2) {
@@ -7086,15 +7094,6 @@ var CompatibilityMode;
7086
7094
  CompatibilityMode2[CompatibilityMode2["Normal"] = 0] = "Normal";
7087
7095
  CompatibilityMode2[CompatibilityMode2["TemplateDefinitionBuilder"] = 1] = "TemplateDefinitionBuilder";
7088
7096
  })(CompatibilityMode || (CompatibilityMode = {}));
7089
- var SanitizerFn;
7090
- (function(SanitizerFn2) {
7091
- SanitizerFn2[SanitizerFn2["Html"] = 0] = "Html";
7092
- SanitizerFn2[SanitizerFn2["Script"] = 1] = "Script";
7093
- SanitizerFn2[SanitizerFn2["Style"] = 2] = "Style";
7094
- SanitizerFn2[SanitizerFn2["Url"] = 3] = "Url";
7095
- SanitizerFn2[SanitizerFn2["ResourceUrl"] = 4] = "ResourceUrl";
7096
- SanitizerFn2[SanitizerFn2["IframeAttribute"] = 5] = "IframeAttribute";
7097
- })(SanitizerFn || (SanitizerFn = {}));
7098
7097
  var DeferSecondaryKind;
7099
7098
  (function(DeferSecondaryKind2) {
7100
7099
  DeferSecondaryKind2[DeferSecondaryKind2["Loading"] = 0] = "Loading";
@@ -7116,6 +7115,11 @@ var I18nParamResolutionTime;
7116
7115
  I18nParamResolutionTime2[I18nParamResolutionTime2["Creation"] = 0] = "Creation";
7117
7116
  I18nParamResolutionTime2[I18nParamResolutionTime2["Postproccessing"] = 1] = "Postproccessing";
7118
7117
  })(I18nParamResolutionTime || (I18nParamResolutionTime = {}));
7118
+ var I18nExpressionFor;
7119
+ (function(I18nExpressionFor2) {
7120
+ I18nExpressionFor2[I18nExpressionFor2["I18nText"] = 0] = "I18nText";
7121
+ I18nExpressionFor2[I18nExpressionFor2["I18nAttribute"] = 1] = "I18nAttribute";
7122
+ })(I18nExpressionFor || (I18nExpressionFor = {}));
7119
7123
  var I18nParamValueFlags;
7120
7124
  (function(I18nParamValueFlags2) {
7121
7125
  I18nParamValueFlags2[I18nParamValueFlags2["None"] = 0] = "None";
@@ -7151,7 +7155,14 @@ var I18nContextKind;
7151
7155
  (function(I18nContextKind2) {
7152
7156
  I18nContextKind2[I18nContextKind2["RootI18n"] = 0] = "RootI18n";
7153
7157
  I18nContextKind2[I18nContextKind2["Icu"] = 1] = "Icu";
7158
+ I18nContextKind2[I18nContextKind2["Attr"] = 2] = "Attr";
7154
7159
  })(I18nContextKind || (I18nContextKind = {}));
7160
+ var TemplateKind;
7161
+ (function(TemplateKind2) {
7162
+ TemplateKind2[TemplateKind2["NgTemplate"] = 0] = "NgTemplate";
7163
+ TemplateKind2[TemplateKind2["Structural"] = 1] = "Structural";
7164
+ TemplateKind2[TemplateKind2["Block"] = 2] = "Block";
7165
+ })(TemplateKind || (TemplateKind = {}));
7155
7166
 
7156
7167
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/ir/src/traits.mjs
7157
7168
  var ConsumesSlot = Symbol("ConsumesSlot");
@@ -7208,22 +7219,25 @@ var NEW_OP = {
7208
7219
  };
7209
7220
 
7210
7221
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/ir/src/ops/update.mjs
7211
- function createInterpolateTextOp(xref, interpolation, i18nPlaceholders, sourceSpan) {
7222
+ function createInterpolateTextOp(xref, interpolation, sourceSpan) {
7212
7223
  return __spreadValues(__spreadValues(__spreadValues({
7213
7224
  kind: OpKind.InterpolateText,
7214
7225
  target: xref,
7215
7226
  interpolation,
7216
- i18nPlaceholders,
7217
7227
  sourceSpan
7218
7228
  }, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
7219
7229
  }
7220
7230
  var Interpolation2 = class {
7221
- constructor(strings, expressions) {
7231
+ constructor(strings, expressions, i18nPlaceholders) {
7222
7232
  this.strings = strings;
7223
7233
  this.expressions = expressions;
7234
+ this.i18nPlaceholders = i18nPlaceholders;
7235
+ if (i18nPlaceholders.length !== 0 && i18nPlaceholders.length !== expressions.length) {
7236
+ throw new Error(`Expected ${expressions.length} placeholders to match interpolation expression count, but got ${i18nPlaceholders.length}`);
7237
+ }
7224
7238
  }
7225
7239
  };
7226
- function createBindingOp(target, kind, name, expression, unit, securityContext, isTextAttribute, isTemplate, sourceSpan) {
7240
+ function createBindingOp(target, kind, name, expression, unit, securityContext, isTextAttribute, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan) {
7227
7241
  return __spreadValues({
7228
7242
  kind: OpKind.Binding,
7229
7243
  bindingKind: kind,
@@ -7233,11 +7247,14 @@ function createBindingOp(target, kind, name, expression, unit, securityContext,
7233
7247
  unit,
7234
7248
  securityContext,
7235
7249
  isTextAttribute,
7236
- isTemplate,
7250
+ isStructuralTemplateAttribute,
7251
+ templateKind,
7252
+ i18nContext: null,
7253
+ i18nMessage,
7237
7254
  sourceSpan
7238
7255
  }, NEW_OP);
7239
7256
  }
7240
- function createPropertyOp(target, name, expression, isAnimationTrigger, securityContext, isTemplate, sourceSpan) {
7257
+ function createPropertyOp(target, name, expression, isAnimationTrigger, securityContext, isStructuralTemplateAttribute, templateKind, i18nContext, i18nMessage, sourceSpan) {
7241
7258
  return __spreadValues(__spreadValues(__spreadValues({
7242
7259
  kind: OpKind.Property,
7243
7260
  target,
@@ -7246,7 +7263,10 @@ function createPropertyOp(target, name, expression, isAnimationTrigger, security
7246
7263
  isAnimationTrigger,
7247
7264
  securityContext,
7248
7265
  sanitizer: null,
7249
- isTemplate,
7266
+ isStructuralTemplateAttribute,
7267
+ templateKind,
7268
+ i18nContext,
7269
+ i18nMessage,
7250
7270
  sourceSpan
7251
7271
  }, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
7252
7272
  }
@@ -7285,7 +7305,7 @@ function createClassMapOp(xref, expression, sourceSpan) {
7285
7305
  sourceSpan
7286
7306
  }, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
7287
7307
  }
7288
- function createAttributeOp(target, name, expression, securityContext, isTextAttribute, isTemplate, sourceSpan) {
7308
+ function createAttributeOp(target, name, expression, securityContext, isTextAttribute, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan) {
7289
7309
  return __spreadValues(__spreadValues(__spreadValues({
7290
7310
  kind: OpKind.Attribute,
7291
7311
  target,
@@ -7294,7 +7314,10 @@ function createAttributeOp(target, name, expression, securityContext, isTextAttr
7294
7314
  securityContext,
7295
7315
  sanitizer: null,
7296
7316
  isTextAttribute,
7297
- isTemplate,
7317
+ isStructuralTemplateAttribute,
7318
+ templateKind,
7319
+ i18nContext: null,
7320
+ i18nMessage,
7298
7321
  sourceSpan
7299
7322
  }, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
7300
7323
  }
@@ -7335,22 +7358,25 @@ function createDeferWhenOp(target, expr, prefetch, sourceSpan) {
7335
7358
  sourceSpan
7336
7359
  }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
7337
7360
  }
7338
- function createI18nExpressionOp(context, target, handle, expression, i18nPlaceholder, resolutionTime, sourceSpan) {
7361
+ function createI18nExpressionOp(context, target, i18nOwner, handle, expression, i18nPlaceholder, resolutionTime, usage, name, sourceSpan) {
7339
7362
  return __spreadValues(__spreadValues(__spreadValues({
7340
7363
  kind: OpKind.I18nExpression,
7341
7364
  context,
7342
7365
  target,
7366
+ i18nOwner,
7343
7367
  handle,
7344
7368
  expression,
7345
7369
  i18nPlaceholder,
7346
7370
  resolutionTime,
7371
+ usage,
7372
+ name,
7347
7373
  sourceSpan
7348
7374
  }, NEW_OP), TRAIT_CONSUMES_VARS), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
7349
7375
  }
7350
- function createI18nApplyOp(target, handle, sourceSpan) {
7376
+ function createI18nApplyOp(owner, handle, sourceSpan) {
7351
7377
  return __spreadValues({
7352
7378
  kind: OpKind.I18nApply,
7353
- target,
7379
+ owner,
7354
7380
  handle,
7355
7381
  sourceSpan
7356
7382
  }, NEW_OP);
@@ -7887,26 +7913,6 @@ var ReadTemporaryExpr = class extends ExpressionBase {
7887
7913
  return r;
7888
7914
  }
7889
7915
  };
7890
- var SanitizerExpr = class extends ExpressionBase {
7891
- constructor(fn2) {
7892
- super();
7893
- this.fn = fn2;
7894
- this.kind = ExpressionKind.SanitizerExpr;
7895
- }
7896
- visitExpression(visitor, context) {
7897
- }
7898
- isEquivalent(e) {
7899
- return e instanceof SanitizerExpr && e.fn === this.fn;
7900
- }
7901
- isConstant() {
7902
- return true;
7903
- }
7904
- clone() {
7905
- return new SanitizerExpr(this.fn);
7906
- }
7907
- transformInternalExpressions() {
7908
- }
7909
- };
7910
7916
  var SlotLiteralExpr = class extends ExpressionBase {
7911
7917
  constructor(slot) {
7912
7918
  super();
@@ -8025,7 +8031,6 @@ function transformExpressionsInOp(op, transform2, flags) {
8025
8031
  case OpKind.ClassProp:
8026
8032
  case OpKind.ClassMap:
8027
8033
  case OpKind.Binding:
8028
- case OpKind.HostProperty:
8029
8034
  if (op.expression instanceof Interpolation2) {
8030
8035
  transformExpressionsInInterpolation(op.expression, transform2, flags);
8031
8036
  } else {
@@ -8033,6 +8038,7 @@ function transformExpressionsInOp(op, transform2, flags) {
8033
8038
  }
8034
8039
  break;
8035
8040
  case OpKind.Property:
8041
+ case OpKind.HostProperty:
8036
8042
  case OpKind.Attribute:
8037
8043
  if (op.expression instanceof Interpolation2) {
8038
8044
  transformExpressionsInInterpolation(op.expression, transform2, flags);
@@ -8074,6 +8080,7 @@ function transformExpressionsInOp(op, transform2, flags) {
8074
8080
  break;
8075
8081
  case OpKind.ExtractedAttribute:
8076
8082
  op.expression = op.expression && transformExpressionsInExpression(op.expression, transform2, flags);
8083
+ op.trustedValueFn = op.trustedValueFn && transformExpressionsInExpression(op.trustedValueFn, transform2, flags);
8077
8084
  break;
8078
8085
  case OpKind.RepeaterCreate:
8079
8086
  op.track = transformExpressionsInExpression(op.track, transform2, flags);
@@ -8126,6 +8133,7 @@ function transformExpressionsInOp(op, transform2, flags) {
8126
8133
  case OpKind.ProjectionDef:
8127
8134
  case OpKind.Template:
8128
8135
  case OpKind.Text:
8136
+ case OpKind.I18nAttributes:
8129
8137
  break;
8130
8138
  default:
8131
8139
  throw new Error(`AssertionError: transformExpressionsInOp doesn't handle ${OpKind[op.kind]}`);
@@ -8137,6 +8145,8 @@ function transformExpressionsInExpression(expr, transform2, flags) {
8137
8145
  } else if (expr instanceof BinaryOperatorExpr) {
8138
8146
  expr.lhs = transformExpressionsInExpression(expr.lhs, transform2, flags);
8139
8147
  expr.rhs = transformExpressionsInExpression(expr.rhs, transform2, flags);
8148
+ } else if (expr instanceof UnaryOperatorExpr) {
8149
+ expr.expr = transformExpressionsInExpression(expr.expr, transform2, flags);
8140
8150
  } else if (expr instanceof ReadPropExpr) {
8141
8151
  expr.receiver = transformExpressionsInExpression(expr.receiver, transform2, flags);
8142
8152
  } else if (expr instanceof ReadKeyExpr) {
@@ -8176,6 +8186,12 @@ function transformExpressionsInExpression(expr, transform2, flags) {
8176
8186
  for (let i = 0; i < expr.expressions.length; i++) {
8177
8187
  expr.expressions[i] = transformExpressionsInExpression(expr.expressions[i], transform2, flags);
8178
8188
  }
8189
+ } else if (expr instanceof NotExpr) {
8190
+ expr.condition = transformExpressionsInExpression(expr.condition, transform2, flags);
8191
+ } else if (expr instanceof TaggedTemplateExpr) {
8192
+ expr.tag = transformExpressionsInExpression(expr.tag, transform2, flags);
8193
+ expr.template.expressions = expr.template.expressions.map((e) => transformExpressionsInExpression(e, transform2, flags));
8194
+ } else if (expr instanceof WrappedNodeExpr) {
8179
8195
  } else if (expr instanceof ReadVarExpr || expr instanceof ExternalExpr || expr instanceof LiteralExpr) {
8180
8196
  } else {
8181
8197
  throw new Error(`Unhandled expression kind: ${expr.constructor.name}`);
@@ -8431,10 +8447,11 @@ function createElementStartOp(tag, xref, namespace, i18nPlaceholder, sourceSpan)
8431
8447
  sourceSpan
8432
8448
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8433
8449
  }
8434
- function createTemplateOp(xref, tag, functionNameSuffix, namespace, i18nPlaceholder, sourceSpan) {
8450
+ function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace, i18nPlaceholder, sourceSpan) {
8435
8451
  return __spreadValues(__spreadValues({
8436
8452
  kind: OpKind.Template,
8437
8453
  xref,
8454
+ templateKind,
8438
8455
  attributes: null,
8439
8456
  tag,
8440
8457
  handle: new SlotHandle(),
@@ -8448,7 +8465,7 @@ function createTemplateOp(xref, tag, functionNameSuffix, namespace, i18nPlacehol
8448
8465
  sourceSpan
8449
8466
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8450
8467
  }
8451
- function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, sourceSpan) {
8468
+ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, sourceSpan) {
8452
8469
  return __spreadProps(__spreadValues(__spreadValues({
8453
8470
  kind: OpKind.RepeaterCreate,
8454
8471
  attributes: null,
@@ -8466,6 +8483,8 @@ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, so
8466
8483
  vars: null,
8467
8484
  varNames,
8468
8485
  usesComponentInstance: false,
8486
+ i18nPlaceholder,
8487
+ emptyI18nPlaceholder,
8469
8488
  sourceSpan
8470
8489
  }, TRAIT_CONSUMES_SLOT), NEW_OP), {
8471
8490
  numSlotsUsed: emptyView === null ? 2 : 3
@@ -8499,7 +8518,9 @@ function createTextOp(xref, initialValue, sourceSpan) {
8499
8518
  sourceSpan
8500
8519
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8501
8520
  }
8502
- function createListenerOp(target, targetSlot, name, tag, animationPhase, hostListener, sourceSpan) {
8521
+ function createListenerOp(target, targetSlot, name, tag, handlerOps, animationPhase, eventTarget, hostListener, sourceSpan) {
8522
+ const handlerList = new OpList();
8523
+ handlerList.push(handlerOps);
8503
8524
  return __spreadValues({
8504
8525
  kind: OpKind.Listener,
8505
8526
  target,
@@ -8507,11 +8528,12 @@ function createListenerOp(target, targetSlot, name, tag, animationPhase, hostLis
8507
8528
  tag,
8508
8529
  hostListener,
8509
8530
  name,
8510
- handlerOps: new OpList(),
8531
+ handlerOps: handlerList,
8511
8532
  handlerFnName: null,
8512
8533
  consumesDollarEvent: false,
8513
8534
  isAnimationListener: animationPhase !== null,
8514
8535
  animationPhase,
8536
+ eventTarget,
8515
8537
  sourceSpan
8516
8538
  }, NEW_OP);
8517
8539
  }
@@ -8535,25 +8557,30 @@ function createProjectionDefOp(def) {
8535
8557
  def
8536
8558
  }, NEW_OP);
8537
8559
  }
8538
- function createProjectionOp(xref, selector, sourceSpan) {
8560
+ function createProjectionOp(xref, selector, i18nPlaceholder, attributes, sourceSpan) {
8539
8561
  return __spreadValues(__spreadValues({
8540
8562
  kind: OpKind.Projection,
8541
8563
  xref,
8542
8564
  handle: new SlotHandle(),
8543
8565
  selector,
8566
+ i18nPlaceholder,
8544
8567
  projectionSlotIndex: 0,
8545
- attributes: [],
8568
+ attributes,
8546
8569
  localRefs: [],
8547
8570
  sourceSpan
8548
8571
  }, NEW_OP), TRAIT_CONSUMES_SLOT);
8549
8572
  }
8550
- function createExtractedAttributeOp(target, bindingKind, name, expression) {
8573
+ function createExtractedAttributeOp(target, bindingKind, name, expression, i18nContext, i18nMessage, securityContext) {
8551
8574
  return __spreadValues({
8552
8575
  kind: OpKind.ExtractedAttribute,
8553
8576
  target,
8554
8577
  bindingKind,
8555
8578
  name,
8556
- expression
8579
+ expression,
8580
+ i18nContext,
8581
+ i18nMessage,
8582
+ securityContext,
8583
+ trustedValueFn: null
8557
8584
  }, NEW_OP);
8558
8585
  }
8559
8586
  function createDeferOp(xref, main, mainSlot, metadata, sourceSpan) {
@@ -8590,10 +8617,11 @@ function createDeferOnOp(defer2, trigger, prefetch, sourceSpan) {
8590
8617
  sourceSpan
8591
8618
  }, NEW_OP);
8592
8619
  }
8593
- function createI18nMessageOp(xref, i18nBlock, message, messagePlaceholder, params, postprocessingParams, needsPostprocessing) {
8620
+ function createI18nMessageOp(xref, i18nContext, i18nBlock, message, messagePlaceholder, params, postprocessingParams, needsPostprocessing) {
8594
8621
  return __spreadValues({
8595
8622
  kind: OpKind.I18nMessage,
8596
8623
  xref,
8624
+ i18nContext,
8597
8625
  i18nBlock,
8598
8626
  message,
8599
8627
  messagePlaceholder,
@@ -8638,6 +8666,9 @@ function createIcuEndOp(xref) {
8638
8666
  }, NEW_OP);
8639
8667
  }
8640
8668
  function createI18nContextOp(contextKind, xref, i18nBlock, message, sourceSpan) {
8669
+ if (i18nBlock === null && contextKind !== I18nContextKind.Attr) {
8670
+ throw new Error("AssertionError: i18nBlock must be provided for non-attribute contexts.");
8671
+ }
8641
8672
  return __spreadValues({
8642
8673
  kind: OpKind.I18nContext,
8643
8674
  contextKind,
@@ -8649,14 +8680,26 @@ function createI18nContextOp(contextKind, xref, i18nBlock, message, sourceSpan)
8649
8680
  postprocessingParams: /* @__PURE__ */ new Map()
8650
8681
  }, NEW_OP);
8651
8682
  }
8683
+ function createI18nAttributesOp(xref, handle, target) {
8684
+ return __spreadValues(__spreadValues({
8685
+ kind: OpKind.I18nAttributes,
8686
+ xref,
8687
+ handle,
8688
+ target,
8689
+ i18nAttributesConfig: null
8690
+ }, NEW_OP), TRAIT_CONSUMES_SLOT);
8691
+ }
8652
8692
 
8653
8693
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/ir/src/ops/host.mjs
8654
- function createHostPropertyOp(name, expression, isAnimationTrigger, sourceSpan) {
8694
+ function createHostPropertyOp(name, expression, isAnimationTrigger, i18nContext, securityContext, sourceSpan) {
8655
8695
  return __spreadValues(__spreadValues({
8656
8696
  kind: OpKind.HostProperty,
8657
8697
  name,
8658
8698
  expression,
8659
8699
  isAnimationTrigger,
8700
+ i18nContext,
8701
+ securityContext,
8702
+ sanitizer: null,
8660
8703
  sourceSpan
8661
8704
  }, TRAIT_CONSUMES_VARS), NEW_OP);
8662
8705
  }
@@ -8802,7 +8845,7 @@ function applyI18nExpressions(job) {
8802
8845
  for (const unit of job.units) {
8803
8846
  for (const op of unit.update) {
8804
8847
  if (op.kind === OpKind.I18nExpression && needsApplication(i18nContexts, op)) {
8805
- OpList.insertAfter(createI18nApplyOp(op.target, op.handle, null), op);
8848
+ OpList.insertAfter(createI18nApplyOp(op.i18nOwner, op.handle, null), op);
8806
8849
  }
8807
8850
  }
8808
8851
  }
@@ -8814,7 +8857,19 @@ function needsApplication(i18nContexts, op) {
8814
8857
  }
8815
8858
  const context = i18nContexts.get(op.context);
8816
8859
  const nextContext2 = i18nContexts.get(op.next.context);
8817
- if (context.i18nBlock !== nextContext2.i18nBlock) {
8860
+ if (context === void 0) {
8861
+ throw new Error("AssertionError: expected an I18nContextOp to exist for the I18nExpressionOp's context");
8862
+ }
8863
+ if (nextContext2 === void 0) {
8864
+ throw new Error("AssertionError: expected an I18nContextOp to exist for the next I18nExpressionOp's context");
8865
+ }
8866
+ if (context.i18nBlock !== null) {
8867
+ if (context.i18nBlock !== nextContext2.i18nBlock) {
8868
+ return true;
8869
+ }
8870
+ return false;
8871
+ }
8872
+ if (op.i18nOwner !== op.next.i18nOwner) {
8818
8873
  return true;
8819
8874
  }
8820
8875
  return false;
@@ -8822,27 +8877,44 @@ function needsApplication(i18nContexts, op) {
8822
8877
 
8823
8878
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/assign_i18n_slot_dependencies.mjs
8824
8879
  function assignI18nSlotDependencies(job) {
8825
- const i18nLastSlotConsumers = /* @__PURE__ */ new Map();
8826
- let lastSlotConsumer = null;
8827
- let currentI18nOp = null;
8828
8880
  for (const unit of job.units) {
8829
- for (const op of unit.create) {
8830
- if (hasConsumesSlotTrait(op)) {
8831
- lastSlotConsumer = op.xref;
8832
- }
8833
- switch (op.kind) {
8834
- case OpKind.I18nStart:
8835
- currentI18nOp = op;
8836
- break;
8837
- case OpKind.I18nEnd:
8838
- i18nLastSlotConsumers.set(currentI18nOp.xref, lastSlotConsumer);
8839
- currentI18nOp = null;
8840
- break;
8881
+ let updateOp = unit.update.head;
8882
+ let i18nExpressionsInProgress = [];
8883
+ let state = null;
8884
+ for (const createOp of unit.create) {
8885
+ if (createOp.kind === OpKind.I18nStart) {
8886
+ state = {
8887
+ blockXref: createOp.xref,
8888
+ lastSlotConsumer: createOp.xref
8889
+ };
8890
+ } else if (createOp.kind === OpKind.I18nEnd) {
8891
+ for (const op of i18nExpressionsInProgress) {
8892
+ op.target = state.lastSlotConsumer;
8893
+ OpList.insertBefore(op, updateOp);
8894
+ }
8895
+ i18nExpressionsInProgress.length = 0;
8896
+ state = null;
8841
8897
  }
8842
- }
8843
- for (const op of unit.update) {
8844
- if (op.kind === OpKind.I18nExpression) {
8845
- op.target = i18nLastSlotConsumers.get(op.target);
8898
+ if (hasConsumesSlotTrait(createOp)) {
8899
+ if (state !== null) {
8900
+ state.lastSlotConsumer = createOp.xref;
8901
+ }
8902
+ while (true) {
8903
+ if (updateOp.next === null) {
8904
+ break;
8905
+ }
8906
+ if (state !== null && updateOp.kind === OpKind.I18nExpression && updateOp.usage === I18nExpressionFor.I18nText && updateOp.i18nOwner === state.blockXref) {
8907
+ const opToRemove = updateOp;
8908
+ updateOp = updateOp.next;
8909
+ OpList.remove(opToRemove);
8910
+ i18nExpressionsInProgress.push(opToRemove);
8911
+ continue;
8912
+ }
8913
+ if (hasDependsOnSlotContextTrait(updateOp) && updateOp.target !== createOp.xref) {
8914
+ break;
8915
+ }
8916
+ updateOp = updateOp.next;
8917
+ }
8846
8918
  }
8847
8919
  }
8848
8920
  }
@@ -8871,18 +8943,53 @@ function extractAttributes(job) {
8871
8943
  break;
8872
8944
  case OpKind.Property:
8873
8945
  if (!op.isAnimationTrigger) {
8874
- OpList.insertBefore(createExtractedAttributeOp(op.target, op.isTemplate ? BindingKind.Template : BindingKind.Property, op.name, null), lookupElement(elements, op.target));
8946
+ let bindingKind;
8947
+ if (op.i18nMessage !== null && op.templateKind === null) {
8948
+ bindingKind = BindingKind.I18n;
8949
+ } else if (op.isStructuralTemplateAttribute) {
8950
+ bindingKind = BindingKind.Template;
8951
+ } else {
8952
+ bindingKind = BindingKind.Property;
8953
+ }
8954
+ OpList.insertBefore(
8955
+ createExtractedAttributeOp(
8956
+ op.target,
8957
+ bindingKind,
8958
+ op.name,
8959
+ null,
8960
+ null,
8961
+ null,
8962
+ op.securityContext
8963
+ ),
8964
+ lookupElement(elements, op.target)
8965
+ );
8875
8966
  }
8876
8967
  break;
8877
8968
  case OpKind.StyleProp:
8878
8969
  case OpKind.ClassProp:
8879
8970
  if (unit.job.compatibility === CompatibilityMode.TemplateDefinitionBuilder && op.expression instanceof EmptyExpr2) {
8880
- OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.Property, op.name, null), lookupElement(elements, op.target));
8971
+ OpList.insertBefore(createExtractedAttributeOp(
8972
+ op.target,
8973
+ BindingKind.Property,
8974
+ op.name,
8975
+ null,
8976
+ null,
8977
+ null,
8978
+ SecurityContext.STYLE
8979
+ ), lookupElement(elements, op.target));
8881
8980
  }
8882
8981
  break;
8883
8982
  case OpKind.Listener:
8884
8983
  if (!op.isAnimationListener) {
8885
- const extractedAttributeOp = createExtractedAttributeOp(op.target, BindingKind.Property, op.name, null);
8984
+ const extractedAttributeOp = createExtractedAttributeOp(
8985
+ op.target,
8986
+ BindingKind.Property,
8987
+ op.name,
8988
+ null,
8989
+ null,
8990
+ null,
8991
+ SecurityContext.NONE
8992
+ );
8886
8993
  if (job.kind === CompilationJobKind.Host) {
8887
8994
  unit.create.push(extractedAttributeOp);
8888
8995
  } else {
@@ -8916,7 +9023,7 @@ function extractAttributeOp(unit, op, elements) {
8916
9023
  }
8917
9024
  }
8918
9025
  if (extractable) {
8919
- const extractedAttributeOp = createExtractedAttributeOp(op.target, op.isTemplate ? BindingKind.Template : BindingKind.Attribute, op.name, op.expression);
9026
+ const extractedAttributeOp = createExtractedAttributeOp(op.target, op.isStructuralTemplateAttribute ? BindingKind.Template : BindingKind.Attribute, op.name, op.expression, op.i18nContext, op.i18nMessage, op.securityContext);
8920
9027
  if (unit.job.kind === CompilationJobKind.Host) {
8921
9028
  unit.create.push(extractedAttributeOp);
8922
9029
  } else {
@@ -8957,15 +9064,15 @@ function specializeBindings(job) {
8957
9064
  const target = lookupElement2(elements, op.target);
8958
9065
  target.nonBindable = true;
8959
9066
  } else {
8960
- OpList.replace(op, createAttributeOp(op.target, op.name, op.expression, op.securityContext, op.isTextAttribute, op.isTemplate, op.sourceSpan));
9067
+ OpList.replace(op, createAttributeOp(op.target, op.name, op.expression, op.securityContext, op.isTextAttribute, op.isStructuralTemplateAttribute, op.templateKind, op.i18nMessage, op.sourceSpan));
8961
9068
  }
8962
9069
  break;
8963
9070
  case BindingKind.Property:
8964
9071
  case BindingKind.Animation:
8965
9072
  if (job.kind === CompilationJobKind.Host) {
8966
- OpList.replace(op, createHostPropertyOp(op.name, op.expression, op.bindingKind === BindingKind.Animation, op.sourceSpan));
9073
+ OpList.replace(op, createHostPropertyOp(op.name, op.expression, op.bindingKind === BindingKind.Animation, op.i18nContext, op.securityContext, op.sourceSpan));
8967
9074
  } else {
8968
- OpList.replace(op, createPropertyOp(op.target, op.name, op.expression, op.bindingKind === BindingKind.Animation, op.securityContext, op.isTemplate, op.sourceSpan));
9075
+ OpList.replace(op, createPropertyOp(op.target, op.name, op.expression, op.bindingKind === BindingKind.Animation, op.securityContext, op.isStructuralTemplateAttribute, op.templateKind, op.i18nContext, op.i18nMessage, op.sourceSpan));
8969
9076
  }
8970
9077
  break;
8971
9078
  case BindingKind.I18n:
@@ -9150,7 +9257,7 @@ function collectElementConsts(job) {
9150
9257
  if (op.kind === OpKind.ExtractedAttribute) {
9151
9258
  const attributes = allElementAttributes.get(op.target) || new ElementAttributes();
9152
9259
  allElementAttributes.set(op.target, attributes);
9153
- attributes.add(op.bindingKind, op.name, op.expression);
9260
+ attributes.add(op.bindingKind, op.name, op.expression, op.trustedValueFn);
9154
9261
  OpList.remove(op);
9155
9262
  }
9156
9263
  }
@@ -9212,7 +9319,7 @@ var ElementAttributes = class {
9212
9319
  var _a2;
9213
9320
  return (_a2 = this.byKind.get(BindingKind.I18n)) != null ? _a2 : FLYWEIGHT_ARRAY;
9214
9321
  }
9215
- add(kind, name, value) {
9322
+ add(kind, name, value, trustedValueFn) {
9216
9323
  var _a2;
9217
9324
  if (this.known.has(name)) {
9218
9325
  return;
@@ -9228,9 +9335,16 @@ var ElementAttributes = class {
9228
9335
  array.push(...getAttributeNameLiterals(name));
9229
9336
  if (kind === BindingKind.Attribute || kind === BindingKind.StyleProperty) {
9230
9337
  if (value === null) {
9231
- throw Error("Attribute & style element attributes must have a value");
9338
+ throw Error("Attribute, i18n attribute, & style element attributes must have a value");
9339
+ }
9340
+ if (trustedValueFn !== null) {
9341
+ if (!isStringLiteral(value)) {
9342
+ throw Error("AssertionError: extracted attribute value should be string literal");
9343
+ }
9344
+ array.push(taggedTemplate(trustedValueFn, new TemplateLiteral([new TemplateLiteralElement(value.value)], []), void 0, value.sourceSpan));
9345
+ } else {
9346
+ array.push(value);
9232
9347
  }
9233
- array.push(value);
9234
9348
  }
9235
9349
  }
9236
9350
  arrayFor(kind) {
@@ -9276,6 +9390,47 @@ function serializeAttributes({ attributes, bindings, classes, i18n: i18n2, proje
9276
9390
  return literalArr(attrArray);
9277
9391
  }
9278
9392
 
9393
+ // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/convert_i18n_bindings.mjs
9394
+ function convertI18nBindings(job) {
9395
+ const i18nAttributesByElem = /* @__PURE__ */ new Map();
9396
+ for (const unit of job.units) {
9397
+ for (const op of unit.create) {
9398
+ if (op.kind === OpKind.I18nAttributes) {
9399
+ i18nAttributesByElem.set(op.target, op);
9400
+ }
9401
+ }
9402
+ for (const op of unit.update) {
9403
+ switch (op.kind) {
9404
+ case OpKind.Property:
9405
+ case OpKind.Attribute:
9406
+ if (op.i18nContext === null) {
9407
+ continue;
9408
+ }
9409
+ if (!(op.expression instanceof Interpolation2)) {
9410
+ continue;
9411
+ }
9412
+ const i18nAttributesForElem = i18nAttributesByElem.get(op.target);
9413
+ if (i18nAttributesForElem === void 0) {
9414
+ throw new Error("AssertionError: An i18n attribute binding instruction requires the owning element to have an I18nAttributes create instruction");
9415
+ }
9416
+ if (i18nAttributesForElem.target !== op.target) {
9417
+ throw new Error("AssertionError: Expected i18nAttributes target element to match binding target element");
9418
+ }
9419
+ const ops = [];
9420
+ for (let i = 0; i < op.expression.expressions.length; i++) {
9421
+ const expr = op.expression.expressions[i];
9422
+ if (op.expression.i18nPlaceholders.length !== op.expression.expressions.length) {
9423
+ 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
+ }
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));
9426
+ }
9427
+ OpList.replaceWithMany(op, ops);
9428
+ break;
9429
+ }
9430
+ }
9431
+ }
9432
+ }
9433
+
9279
9434
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/create_defer_deps_fns.mjs
9280
9435
  function createDeferDepsFns(job) {
9281
9436
  for (const unit of job.units) {
@@ -9309,6 +9464,7 @@ function createI18nContexts(job) {
9309
9464
  const rootContexts = /* @__PURE__ */ new Map();
9310
9465
  let currentI18nOp = null;
9311
9466
  let xref;
9467
+ const messageToContext = /* @__PURE__ */ new Map();
9312
9468
  for (const unit of job.units) {
9313
9469
  for (const op of unit.create) {
9314
9470
  switch (op.kind) {
@@ -9338,6 +9494,24 @@ function createI18nContexts(job) {
9338
9494
  break;
9339
9495
  }
9340
9496
  }
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
+ }
9341
9515
  }
9342
9516
  for (const unit of job.units) {
9343
9517
  for (const op of unit.create) {
@@ -9646,6 +9820,15 @@ function extractI18nMessages(job) {
9646
9820
  }
9647
9821
  }
9648
9822
  }
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
+ }
9649
9832
  const i18nBlockMessages = /* @__PURE__ */ new Map();
9650
9833
  for (const unit of job.units) {
9651
9834
  for (const op of unit.create) {
@@ -9668,6 +9851,9 @@ function extractI18nMessages(job) {
9668
9851
  }
9669
9852
  const i18nContext = i18nContexts.get(op.context);
9670
9853
  if (i18nContext.contextKind === I18nContextKind.Icu) {
9854
+ if (i18nContext.i18nBlock === null) {
9855
+ throw Error("ICU context should have its i18n block set.");
9856
+ }
9671
9857
  const subMessage = createI18nMessage(job, i18nContext, op.messagePlaceholder);
9672
9858
  unit.create.push(subMessage);
9673
9859
  const rootI18nId = i18nBlocks.get(i18nContext.i18nBlock).root;
@@ -9684,69 +9870,54 @@ function extractI18nMessages(job) {
9684
9870
  }
9685
9871
  }
9686
9872
  function createI18nMessage(job, context, messagePlaceholder) {
9687
- let [formattedParams, needsPostprocessing] = formatParams(context.params);
9688
- const [formattedPostprocessingParams] = formatParams(context.postprocessingParams);
9689
- needsPostprocessing || (needsPostprocessing = formattedPostprocessingParams.size > 0);
9690
- return createI18nMessageOp(job.allocateXrefId(), context.i18nBlock, context.message, messagePlaceholder != null ? messagePlaceholder : null, formattedParams, formattedPostprocessingParams, needsPostprocessing);
9873
+ let formattedParams = formatParams(context.params);
9874
+ 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
+ }
9881
+ return createI18nMessageOp(job.allocateXrefId(), context.xref, context.i18nBlock, context.message, messagePlaceholder != null ? messagePlaceholder : null, formattedParams, formattedPostprocessingParams, needsPostprocessing);
9691
9882
  }
9692
9883
  function formatParams(params) {
9693
9884
  const formattedParams = /* @__PURE__ */ new Map();
9694
- let needsPostprocessing = false;
9695
9885
  for (const [placeholder, placeholderValues] of params) {
9696
- const [serializedValues, paramNeedsPostprocessing] = formatParamValues(placeholderValues);
9697
- needsPostprocessing || (needsPostprocessing = paramNeedsPostprocessing);
9886
+ const serializedValues = formatParamValues(placeholderValues);
9698
9887
  if (serializedValues !== null) {
9699
9888
  formattedParams.set(placeholder, literal(serializedValues));
9700
9889
  }
9701
9890
  }
9702
- return [formattedParams, needsPostprocessing];
9891
+ return formattedParams;
9703
9892
  }
9704
9893
  function formatParamValues(values) {
9705
9894
  if (values.length === 0) {
9706
- return [null, false];
9895
+ return null;
9707
9896
  }
9708
- collapseElementTemplatePairs(values);
9709
9897
  const serializedValues = values.map((value) => formatValue(value));
9710
- return serializedValues.length === 1 ? [serializedValues[0], false] : [`${LIST_START_MARKER}${serializedValues.join(LIST_DELIMITER)}${LIST_END_MARKER}`, true];
9898
+ return serializedValues.length === 1 ? serializedValues[0] : `${LIST_START_MARKER}${serializedValues.join(LIST_DELIMITER)}${LIST_END_MARKER}`;
9711
9899
  }
9712
- function collapseElementTemplatePairs(values) {
9713
- var _a2;
9714
- const valueIndiciesBySubTemplateIndex = /* @__PURE__ */ new Map();
9715
- for (let i = 0; i < values.length; i++) {
9716
- const value = values[i];
9717
- if (value.subTemplateIndex !== null && value.flags & (I18nParamValueFlags.ElementTag | I18nParamValueFlags.TemplateTag)) {
9718
- const valueIndicies = (_a2 = valueIndiciesBySubTemplateIndex.get(value.subTemplateIndex)) != null ? _a2 : [];
9719
- valueIndicies.push(i);
9720
- valueIndiciesBySubTemplateIndex.set(value.subTemplateIndex, valueIndicies);
9721
- }
9722
- }
9723
- for (const [subTemplateIndex, valueIndicies] of valueIndiciesBySubTemplateIndex) {
9724
- if (valueIndicies.length > 1) {
9725
- const elementIndex = valueIndicies.find((index) => values[index].flags & I18nParamValueFlags.ElementTag);
9726
- const templateIndex = valueIndicies.find((index) => values[index].flags & I18nParamValueFlags.TemplateTag);
9727
- if (elementIndex !== void 0 && templateIndex !== void 0) {
9728
- const elementValue = values[elementIndex];
9729
- const templateValue = values[templateIndex];
9730
- let compundValue;
9731
- if (elementValue.flags & I18nParamValueFlags.OpenTag && elementValue.flags & I18nParamValueFlags.CloseTag) {
9732
- compundValue = `${formatValue(templateValue)}${formatValue(elementValue)}${formatValue(templateValue)}`;
9733
- } else if (elementValue.flags & I18nParamValueFlags.OpenTag) {
9734
- compundValue = `${formatValue(templateValue)}${formatValue(elementValue)}`;
9735
- } else {
9736
- compundValue = `${formatValue(elementValue)}${formatValue(templateValue)}`;
9737
- }
9738
- values.splice(elementIndex, 1, { value: compundValue, subTemplateIndex, flags: I18nParamValueFlags.None });
9739
- values.splice(templateIndex, 1, null);
9740
- }
9900
+ function formatValue(value) {
9901
+ if (value.flags & I18nParamValueFlags.ElementTag && value.flags & I18nParamValueFlags.TemplateTag) {
9902
+ if (typeof value.value !== "object") {
9903
+ throw Error("AssertionError: Expected i18n param value to have an element and template slot");
9741
9904
  }
9742
- }
9743
- for (let i = values.length - 1; i >= 0; i--) {
9744
- if (values[i] === null) {
9745
- values.splice(i, 1);
9905
+ const elementValue = formatValue(__spreadProps(__spreadValues({}, value), {
9906
+ value: value.value.element,
9907
+ flags: value.flags & ~I18nParamValueFlags.TemplateTag
9908
+ }));
9909
+ const templateValue = formatValue(__spreadProps(__spreadValues({}, value), {
9910
+ value: value.value.template,
9911
+ flags: value.flags & ~I18nParamValueFlags.ElementTag
9912
+ }));
9913
+ if (value.flags & I18nParamValueFlags.OpenTag && value.flags & I18nParamValueFlags.CloseTag) {
9914
+ return `${templateValue}${elementValue}${templateValue}`;
9746
9915
  }
9916
+ return value.flags & I18nParamValueFlags.CloseTag ? `${elementValue}${templateValue}` : `${templateValue}${elementValue}`;
9917
+ }
9918
+ if (value.flags & I18nParamValueFlags.OpenTag && value.flags & I18nParamValueFlags.CloseTag) {
9919
+ return `${formatValue(__spreadProps(__spreadValues({}, value), { flags: value.flags & ~I18nParamValueFlags.CloseTag }))}${formatValue(__spreadProps(__spreadValues({}, value), { flags: value.flags & ~I18nParamValueFlags.OpenTag }))}`;
9747
9920
  }
9748
- }
9749
- function formatValue(value) {
9750
9921
  if (value.flags === I18nParamValueFlags.None) {
9751
9922
  return `${value.value}`;
9752
9923
  }
@@ -9761,9 +9932,6 @@ function formatValue(value) {
9761
9932
  closeMarker = value.flags & I18nParamValueFlags.CloseTag ? TAG_CLOSE_MARKER : "";
9762
9933
  }
9763
9934
  const context = value.subTemplateIndex === null ? "" : `${CONTEXT_MARKER}${value.subTemplateIndex}`;
9764
- if (value.flags & I18nParamValueFlags.OpenTag && value.flags & I18nParamValueFlags.CloseTag) {
9765
- return `${ESCAPE}${tagMarker}${value.value}${context}${ESCAPE}${ESCAPE}${closeMarker}${tagMarker}${value.value}${context}${ESCAPE}`;
9766
- }
9767
9935
  return `${ESCAPE}${closeMarker}${tagMarker}${value.value}${context}${ESCAPE}`;
9768
9936
  }
9769
9937
 
@@ -9784,7 +9952,7 @@ function generateAdvance(job) {
9784
9952
  if (!hasDependsOnSlotContextTrait(op)) {
9785
9953
  continue;
9786
9954
  } else if (!slotMap.has(op.target)) {
9787
- throw new Error(`AssertionError: reference to unknown slot for var ${op.target}`);
9955
+ throw new Error(`AssertionError: reference to unknown slot for target ${op.target}`);
9788
9956
  }
9789
9957
  const slot = slotMap.get(op.target);
9790
9958
  if (slotContext !== slot) {
@@ -9832,8 +10000,13 @@ function recursivelyProcessView(view, parentScope) {
9832
10000
  for (const op of view.create) {
9833
10001
  switch (op.kind) {
9834
10002
  case OpKind.Template:
10003
+ recursivelyProcessView(view.job.views.get(op.xref), scope);
10004
+ break;
9835
10005
  case OpKind.RepeaterCreate:
9836
10006
  recursivelyProcessView(view.job.views.get(op.xref), scope);
10007
+ if (op.emptyView) {
10008
+ recursivelyProcessView(view.job.views.get(op.emptyView), scope);
10009
+ }
9837
10010
  break;
9838
10011
  case OpKind.Listener:
9839
10012
  op.handlerOps.prepend(generateVariablesInScopeForView(view, scope));
@@ -15967,56 +16140,137 @@ function createEmptyMessagePart(location) {
15967
16140
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/i18n_const_collection.mjs
15968
16141
  var NG_I18N_CLOSURE_MODE = "ngI18nClosureMode";
15969
16142
  var TRANSLATION_VAR_PREFIX2 = "i18n_";
16143
+ var I18N_ICU_MAPPING_PREFIX2 = "I18N_EXP_";
16144
+ var ESCAPE2 = "\uFFFD";
15970
16145
  function collectI18nConsts(job) {
16146
+ var _a2, _b2;
15971
16147
  const fileBasedI18nSuffix = job.relativeContextFilePath.replace(/[^A-Za-z0-9]/g, "_").toUpperCase() + "_";
15972
- const messageConstIndices = /* @__PURE__ */ new Map();
16148
+ const extractedAttributesByI18nContext = /* @__PURE__ */ new Map();
16149
+ const i18nAttributesByElement = /* @__PURE__ */ new Map();
16150
+ const i18nExpressionsByElement = /* @__PURE__ */ new Map();
15973
16151
  const messages = /* @__PURE__ */ new Map();
16152
+ for (const unit of job.units) {
16153
+ for (const op of unit.ops()) {
16154
+ if (op.kind === OpKind.ExtractedAttribute && op.i18nContext !== null) {
16155
+ const attributes = (_a2 = extractedAttributesByI18nContext.get(op.i18nContext)) != null ? _a2 : [];
16156
+ attributes.push(op);
16157
+ extractedAttributesByI18nContext.set(op.i18nContext, attributes);
16158
+ } else if (op.kind === OpKind.I18nAttributes) {
16159
+ i18nAttributesByElement.set(op.target, op);
16160
+ } else if (op.kind === OpKind.I18nExpression && op.usage === I18nExpressionFor.I18nAttribute) {
16161
+ const expressions = (_b2 = i18nExpressionsByElement.get(op.target)) != null ? _b2 : [];
16162
+ expressions.push(op);
16163
+ i18nExpressionsByElement.set(op.target, expressions);
16164
+ } else if (op.kind === OpKind.I18nMessage) {
16165
+ messages.set(op.xref, op);
16166
+ }
16167
+ }
16168
+ }
16169
+ const i18nValuesByContext = /* @__PURE__ */ new Map();
16170
+ const messageConstIndices = /* @__PURE__ */ new Map();
15974
16171
  for (const unit of job.units) {
15975
16172
  for (const op of unit.create) {
15976
16173
  if (op.kind === OpKind.I18nMessage) {
15977
- messages.set(op.xref, op);
16174
+ if (op.messagePlaceholder === null) {
16175
+ const { mainVar, statements } = collectMessage(job, fileBasedI18nSuffix, messages, op);
16176
+ if (op.i18nBlock !== null) {
16177
+ const i18nConst = job.addConst(mainVar, statements);
16178
+ messageConstIndices.set(op.i18nBlock, i18nConst);
16179
+ } else {
16180
+ job.constsInitializers.push(...statements);
16181
+ i18nValuesByContext.set(op.i18nContext, mainVar);
16182
+ const attributesForMessage = extractedAttributesByI18nContext.get(op.i18nContext);
16183
+ if (attributesForMessage !== void 0) {
16184
+ for (const attr of attributesForMessage) {
16185
+ attr.expression = mainVar.clone();
16186
+ }
16187
+ }
16188
+ }
16189
+ }
15978
16190
  OpList.remove(op);
15979
16191
  }
15980
16192
  }
15981
16193
  }
15982
- for (const op of messages.values()) {
15983
- if (op.kind === OpKind.I18nMessage && op.messagePlaceholder === null) {
15984
- const { mainVar, statements } = collectMessage(job, fileBasedI18nSuffix, messages, op);
15985
- messageConstIndices.set(op.i18nBlock, job.addConst(mainVar, statements));
16194
+ for (const unit of job.units) {
16195
+ for (const elem of unit.create) {
16196
+ if (isElementOrContainerOp(elem)) {
16197
+ const i18nAttributes2 = i18nAttributesByElement.get(elem.xref);
16198
+ if (i18nAttributes2 === void 0) {
16199
+ continue;
16200
+ }
16201
+ let i18nExpressions = i18nExpressionsByElement.get(elem.xref);
16202
+ if (i18nExpressions === void 0) {
16203
+ throw new Error("AssertionError: Could not find any i18n expressions associated with an I18nAttributes instruction");
16204
+ }
16205
+ const seenPropertyNames = /* @__PURE__ */ new Set();
16206
+ i18nExpressions = i18nExpressions.filter((i18nExpr) => {
16207
+ const seen = seenPropertyNames.has(i18nExpr.name);
16208
+ seenPropertyNames.add(i18nExpr.name);
16209
+ return !seen;
16210
+ });
16211
+ const i18nAttributeConfig = i18nExpressions.flatMap((i18nExpr) => {
16212
+ const i18nExprValue = i18nValuesByContext.get(i18nExpr.context);
16213
+ if (i18nExprValue === void 0) {
16214
+ throw new Error("AssertionError: Could not find i18n expression's value");
16215
+ }
16216
+ return [literal(i18nExpr.name), i18nExprValue];
16217
+ });
16218
+ i18nAttributes2.i18nAttributesConfig = job.addConst(new LiteralArrayExpr(i18nAttributeConfig));
16219
+ }
15986
16220
  }
15987
16221
  }
15988
16222
  for (const unit of job.units) {
15989
16223
  for (const op of unit.create) {
15990
16224
  if (op.kind === OpKind.I18nStart) {
15991
- op.messageIndex = messageConstIndices.get(op.root);
16225
+ const msgIndex = messageConstIndices.get(op.root);
16226
+ if (msgIndex === void 0) {
16227
+ throw new Error("AssertionError: Could not find corresponding i18n block index for an i18n message op; was an i18n message incorrectly assumed to correspond to an attribute?");
16228
+ }
16229
+ op.messageIndex = msgIndex;
15992
16230
  }
15993
16231
  }
15994
16232
  }
15995
16233
  }
15996
16234
  function collectMessage(job, fileBasedI18nSuffix, messages, messageOp) {
16235
+ var _a2;
15997
16236
  const statements = [];
16237
+ const subMessagePlaceholders = /* @__PURE__ */ new Map();
15998
16238
  for (const subMessageId of messageOp.subMessages) {
15999
16239
  const subMessage = messages.get(subMessageId);
16000
16240
  const { mainVar: subMessageVar, statements: subMessageStatements } = collectMessage(job, fileBasedI18nSuffix, messages, subMessage);
16001
16241
  statements.push(...subMessageStatements);
16002
- messageOp.params.set(subMessage.messagePlaceholder, subMessageVar);
16242
+ const subMessages = (_a2 = subMessagePlaceholders.get(subMessage.messagePlaceholder)) != null ? _a2 : [];
16243
+ subMessages.push(subMessageVar);
16244
+ subMessagePlaceholders.set(subMessage.messagePlaceholder, subMessages);
16003
16245
  }
16246
+ addSubMessageParams(messageOp, subMessagePlaceholders);
16004
16247
  messageOp.params = new Map([...messageOp.params.entries()].sort());
16005
- assertAllParamsResolved(messageOp);
16006
16248
  const mainVar = variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX2));
16007
16249
  const closureVar = i18nGenerateClosureVar(job.pool, messageOp.message.id, fileBasedI18nSuffix, job.i18nUseExternalIds);
16008
16250
  let transformFn = void 0;
16009
16251
  if (messageOp.needsPostprocessing) {
16010
- messageOp.postprocessingParams = new Map([...messageOp.postprocessingParams.entries()].sort());
16252
+ const postprocessingParams = Object.fromEntries([...messageOp.postprocessingParams.entries()].sort());
16253
+ const formattedPostprocessingParams = formatI18nPlaceholderNamesInMap(postprocessingParams, false);
16011
16254
  const extraTransformFnParams = [];
16012
16255
  if (messageOp.postprocessingParams.size > 0) {
16013
- extraTransformFnParams.push(literalMap([...messageOp.postprocessingParams].map(([key, value]) => ({ key, value, quoted: true }))));
16256
+ extraTransformFnParams.push(mapLiteral(formattedPostprocessingParams, true));
16014
16257
  }
16015
16258
  transformFn = (expr) => importExpr(Identifiers.i18nPostprocess).callFn([expr, ...extraTransformFnParams]);
16016
16259
  }
16017
16260
  statements.push(...getTranslationDeclStmts(messageOp.message, mainVar, closureVar, messageOp.params, transformFn));
16018
16261
  return { mainVar, statements };
16019
16262
  }
16263
+ function addSubMessageParams(messageOp, subMessagePlaceholders) {
16264
+ for (const [placeholder, subMessages] of subMessagePlaceholders) {
16265
+ if (subMessages.length === 1) {
16266
+ messageOp.params.set(placeholder, subMessages[0]);
16267
+ } else {
16268
+ messageOp.params.set(placeholder, literal(`${ESCAPE2}${I18N_ICU_MAPPING_PREFIX2}${placeholder}${ESCAPE2}`));
16269
+ messageOp.postprocessingParams.set(placeholder, literalArr(subMessages));
16270
+ messageOp.needsPostprocessing = true;
16271
+ }
16272
+ }
16273
+ }
16020
16274
  function getTranslationDeclStmts(message, variable2, closureVar, params, transformFn) {
16021
16275
  const paramsObject = Object.fromEntries(params);
16022
16276
  const statements = [
@@ -16044,23 +16298,9 @@ function i18nGenerateClosureVar(pool, messageId, fileBasedI18nSuffix, useExterna
16044
16298
  }
16045
16299
  return variable(name);
16046
16300
  }
16047
- function assertAllParamsResolved(op) {
16048
- for (let placeholder in op.message.placeholders) {
16049
- placeholder = placeholder.trimEnd();
16050
- if (!op.params.has(placeholder) && !op.postprocessingParams.has(placeholder)) {
16051
- throw Error(`Failed to resolve i18n placeholder: ${placeholder}`);
16052
- }
16053
- }
16054
- for (let placeholder in op.message.placeholderToMessage) {
16055
- placeholder = placeholder.trimEnd();
16056
- if (!op.params.has(placeholder) && !op.postprocessingParams.has(placeholder)) {
16057
- throw Error(`Failed to resolve i18n message placeholder: ${placeholder}`);
16058
- }
16059
- }
16060
- }
16061
16301
 
16062
16302
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/i18n_text_extraction.mjs
16063
- function extractI18nText(job) {
16303
+ function convertI18nText(job) {
16064
16304
  var _a2;
16065
16305
  for (const unit of job.units) {
16066
16306
  let currentI18n = null;
@@ -16109,7 +16349,7 @@ function extractI18nText(job) {
16109
16349
  const ops = [];
16110
16350
  for (let i = 0; i < op.interpolation.expressions.length; i++) {
16111
16351
  const expr = op.interpolation.expressions[i];
16112
- ops.push(createI18nExpressionOp(contextId, i18nOp.xref, i18nOp.handle, expr, op.i18nPlaceholders[i], resolutionTime, (_a2 = expr.sourceSpan) != null ? _a2 : op.sourceSpan));
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));
16113
16353
  }
16114
16354
  OpList.replaceWithMany(op, ops);
16115
16355
  break;
@@ -16531,13 +16771,13 @@ function parseExtractedStyles(job) {
16531
16771
  if (op.name === "style") {
16532
16772
  const parsedStyles = parse(op.expression.value);
16533
16773
  for (let i = 0; i < parsedStyles.length - 1; i += 2) {
16534
- OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.StyleProperty, parsedStyles[i], literal(parsedStyles[i + 1])), op);
16774
+ OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.StyleProperty, parsedStyles[i], literal(parsedStyles[i + 1]), null, null, SecurityContext.STYLE), op);
16535
16775
  }
16536
16776
  OpList.remove(op);
16537
16777
  } else if (op.name === "class") {
16538
16778
  const parsedClasses = op.expression.value.trim().split(/\s+/g);
16539
16779
  for (const parsedClass of parsedClasses) {
16540
- OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.ClassName, parsedClass, null), op);
16780
+ OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.ClassName, parsedClass, null, null, null, SecurityContext.NONE), op);
16541
16781
  }
16542
16782
  OpList.remove(op);
16543
16783
  }
@@ -16550,18 +16790,28 @@ function parseExtractedStyles(job) {
16550
16790
  function removeContentSelectors(job) {
16551
16791
  for (const unit of job.units) {
16552
16792
  const elements = createOpXrefMap(unit);
16553
- for (const op of unit.update) {
16793
+ for (const op of unit.ops()) {
16554
16794
  switch (op.kind) {
16555
16795
  case OpKind.Binding:
16556
16796
  const target = lookupInXrefMap(elements, op.target);
16557
- if (op.name.toLowerCase() === "select" && target.kind === OpKind.Projection) {
16797
+ if (isSelectAttribute(op.name) && target.kind === OpKind.Projection) {
16558
16798
  OpList.remove(op);
16559
16799
  }
16560
16800
  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;
16561
16808
  }
16562
16809
  }
16563
16810
  }
16564
16811
  }
16812
+ function isSelectAttribute(name) {
16813
+ return name.toLowerCase() === "select";
16814
+ }
16565
16815
  function lookupInXrefMap(map, xref) {
16566
16816
  const el = map.get(xref);
16567
16817
  if (el === void 0) {
@@ -16648,22 +16898,35 @@ function propagateI18nBlocksToTemplates(unit, subTemplateIndex) {
16648
16898
  i18nBlock = op;
16649
16899
  break;
16650
16900
  case OpKind.I18nEnd:
16901
+ if (i18nBlock.subTemplateIndex === null) {
16902
+ subTemplateIndex = 0;
16903
+ }
16651
16904
  i18nBlock = null;
16652
16905
  break;
16653
16906
  case OpKind.Template:
16654
- const templateView = unit.job.views.get(op.xref);
16655
- if (op.i18nPlaceholder !== void 0) {
16656
- if (i18nBlock === null) {
16657
- throw Error("Expected template with i18n placeholder to be in an i18n block.");
16658
- }
16659
- subTemplateIndex++;
16660
- wrapTemplateWithI18n(templateView, i18nBlock);
16907
+ subTemplateIndex = propagateI18nBlocksForView(unit.job.views.get(op.xref), i18nBlock, op.i18nPlaceholder, subTemplateIndex);
16908
+ break;
16909
+ case OpKind.RepeaterCreate:
16910
+ const forView = unit.job.views.get(op.xref);
16911
+ subTemplateIndex = propagateI18nBlocksForView(unit.job.views.get(op.xref), i18nBlock, op.i18nPlaceholder, subTemplateIndex);
16912
+ if (op.emptyView !== null) {
16913
+ subTemplateIndex = propagateI18nBlocksForView(unit.job.views.get(op.emptyView), i18nBlock, op.emptyI18nPlaceholder, subTemplateIndex);
16661
16914
  }
16662
- subTemplateIndex = propagateI18nBlocksToTemplates(templateView, subTemplateIndex);
16915
+ break;
16663
16916
  }
16664
16917
  }
16665
16918
  return subTemplateIndex;
16666
16919
  }
16920
+ function propagateI18nBlocksForView(view, i18nBlock, i18nPlaceholder, subTemplateIndex) {
16921
+ if (i18nPlaceholder !== void 0) {
16922
+ if (i18nBlock === null) {
16923
+ throw Error("Expected template with i18n placeholder to be in an i18n block.");
16924
+ }
16925
+ subTemplateIndex++;
16926
+ wrapTemplateWithI18n(view, i18nBlock);
16927
+ }
16928
+ return propagateI18nBlocksToTemplates(view, subTemplateIndex);
16929
+ }
16667
16930
  function wrapTemplateWithI18n(unit, parentI18n) {
16668
16931
  var _a2;
16669
16932
  if (((_a2 = unit.create.head.next) == null ? void 0 : _a2.kind) !== OpKind.I18nStart) {
@@ -16820,17 +17083,13 @@ function disableBindings2() {
16820
17083
  function enableBindings() {
16821
17084
  return call(Identifiers.enableBindings, [], null);
16822
17085
  }
16823
- function listener(name, handlerFn, sourceSpan) {
16824
- return call(Identifiers.listener, [
16825
- literal(name),
16826
- handlerFn
16827
- ], sourceSpan);
16828
- }
16829
- function syntheticHostListener(name, handlerFn, sourceSpan) {
16830
- return call(Identifiers.syntheticHostListener, [
16831
- literal(name),
16832
- handlerFn
16833
- ], sourceSpan);
17086
+ function listener(name, handlerFn, eventTargetResolver, syntheticHost, sourceSpan) {
17087
+ const args = [literal(name), handlerFn];
17088
+ if (eventTargetResolver !== null) {
17089
+ args.push(literal(false));
17090
+ args.push(importExpr(eventTargetResolver));
17091
+ }
17092
+ return call(syntheticHost ? Identifiers.syntheticHostListener : Identifiers.listener, args, sourceSpan);
16834
17093
  }
16835
17094
  function pipe(slot, name) {
16836
17095
  return call(Identifiers.pipe, [
@@ -16977,6 +17236,10 @@ function i18n(slot, constIndex, subTemplateIndex) {
16977
17236
  function i18nEnd() {
16978
17237
  return call(Identifiers.i18nEnd, [], null);
16979
17238
  }
17239
+ function i18nAttributes(slot, i18nAttributesConfig) {
17240
+ const args = [literal(slot), literal(i18nAttributesConfig)];
17241
+ return call(Identifiers.i18nAttributes, args, null);
17242
+ }
16980
17243
  function property(name, expression, sanitizer, sourceSpan) {
16981
17244
  const args = [literal(name), expression];
16982
17245
  if (sanitizer !== null) {
@@ -17085,8 +17348,12 @@ function classMapInterpolate(strings, expressions, sourceSpan) {
17085
17348
  const interpolationArgs = collateInterpolationArgs(strings, expressions);
17086
17349
  return callVariadicInstruction(CLASS_MAP_INTERPOLATE_CONFIG, [], interpolationArgs, [], sourceSpan);
17087
17350
  }
17088
- function hostProperty(name, expression, sourceSpan) {
17089
- return call(Identifiers.hostProperty, [literal(name), expression], sourceSpan);
17351
+ function hostProperty(name, expression, sanitizer, sourceSpan) {
17352
+ const args = [literal(name), expression];
17353
+ if (sanitizer !== null) {
17354
+ args.push(sanitizer);
17355
+ }
17356
+ return call(Identifiers.hostProperty, args, sourceSpan);
17090
17357
  }
17091
17358
  function syntheticHostProperty(name, expression, sourceSpan) {
17092
17359
  return call(Identifiers.syntheticHostProperty, [literal(name), expression], sourceSpan);
@@ -17274,13 +17541,10 @@ function callVariadicInstruction(config, baseArgs, interpolationArgs, extraArgs,
17274
17541
  }
17275
17542
 
17276
17543
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/reify.mjs
17277
- var sanitizerIdentifierMap = /* @__PURE__ */ new Map([
17278
- [SanitizerFn.Html, Identifiers.sanitizeHtml],
17279
- [SanitizerFn.IframeAttribute, Identifiers.validateIframeAttribute],
17280
- [SanitizerFn.ResourceUrl, Identifiers.sanitizeResourceUrl],
17281
- [SanitizerFn.Script, Identifiers.sanitizeScript],
17282
- [SanitizerFn.Style, Identifiers.sanitizeStyle],
17283
- [SanitizerFn.Url, Identifiers.sanitizeUrl]
17544
+ var GLOBAL_TARGET_RESOLVERS = /* @__PURE__ */ new Map([
17545
+ ["window", Identifiers.resolveWindow],
17546
+ ["document", Identifiers.resolveDocument],
17547
+ ["body", Identifiers.resolveBody]
17284
17548
  ]);
17285
17549
  function reify(job) {
17286
17550
  for (const unit of job.units) {
@@ -17323,6 +17587,12 @@ function reifyCreateOperations(unit, ops) {
17323
17587
  case OpKind.I18n:
17324
17588
  OpList.replace(op, i18n(op.handle.slot, op.messageIndex, op.subTemplateIndex));
17325
17589
  break;
17590
+ case OpKind.I18nAttributes:
17591
+ if (op.i18nAttributesConfig === null) {
17592
+ throw new Error(`AssertionError: i18nAttributesConfig was not set`);
17593
+ }
17594
+ OpList.replace(op, i18nAttributes(op.handle.slot, op.i18nAttributesConfig));
17595
+ break;
17326
17596
  case OpKind.Template:
17327
17597
  if (!(unit instanceof ViewCompilationUnit)) {
17328
17598
  throw new Error(`AssertionError: must be compiling a component`);
@@ -17344,8 +17614,11 @@ function reifyCreateOperations(unit, ops) {
17344
17614
  break;
17345
17615
  case OpKind.Listener:
17346
17616
  const listenerFn = reifyListenerHandler(unit, op.handlerFnName, op.handlerOps, op.consumesDollarEvent);
17347
- const reified = op.hostListener && op.isAnimationListener ? syntheticHostListener(op.name, listenerFn, op.sourceSpan) : listener(op.name, listenerFn, op.sourceSpan);
17348
- OpList.replace(op, reified);
17617
+ const eventTargetResolver = op.eventTarget ? GLOBAL_TARGET_RESOLVERS.get(op.eventTarget) : null;
17618
+ if (eventTargetResolver === void 0) {
17619
+ throw new Error(`AssertionError: unknown event target ${op.eventTarget}`);
17620
+ }
17621
+ OpList.replace(op, listener(op.name, listenerFn, eventTargetResolver, op.hostListener && op.isAnimationListener, op.sourceSpan));
17349
17622
  break;
17350
17623
  case OpKind.Variable:
17351
17624
  if (op.variable.name === null) {
@@ -17500,7 +17773,7 @@ function reifyUpdateOperations(_unit, ops) {
17500
17773
  if (op.isAnimationTrigger) {
17501
17774
  OpList.replace(op, syntheticHostProperty(op.name, op.expression, op.sourceSpan));
17502
17775
  } else {
17503
- OpList.replace(op, hostProperty(op.name, op.expression, op.sourceSpan));
17776
+ OpList.replace(op, hostProperty(op.name, op.expression, op.sanitizer, op.sourceSpan));
17504
17777
  }
17505
17778
  }
17506
17779
  break;
@@ -17578,8 +17851,6 @@ function reifyIrExpression(expr) {
17578
17851
  return pipeBind(expr.targetSlot.slot, expr.varOffset, expr.args);
17579
17852
  case ExpressionKind.PipeBindingVariadic:
17580
17853
  return pipeBindV(expr.targetSlot.slot, expr.varOffset, expr.args);
17581
- case ExpressionKind.SanitizerExpr:
17582
- return importExpr(sanitizerIdentifierMap.get(expr.fn));
17583
17854
  case ExpressionKind.SlotLiteralExpr:
17584
17855
  return literal(expr.slot.slot);
17585
17856
  default:
@@ -17639,6 +17910,28 @@ function removeI18nContexts(job) {
17639
17910
  }
17640
17911
  }
17641
17912
 
17913
+ // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/remove_unused_i18n_attrs.mjs
17914
+ function removeUnusedI18nAttributesOps(job) {
17915
+ for (const unit of job.units) {
17916
+ const ownersWithI18nExpressions = /* @__PURE__ */ new Set();
17917
+ for (const op of unit.update) {
17918
+ switch (op.kind) {
17919
+ case OpKind.I18nExpression:
17920
+ ownersWithI18nExpressions.add(op.i18nOwner);
17921
+ }
17922
+ }
17923
+ for (const op of unit.create) {
17924
+ switch (op.kind) {
17925
+ case OpKind.I18nAttributes:
17926
+ if (ownersWithI18nExpressions.has(op.xref)) {
17927
+ continue;
17928
+ }
17929
+ OpList.remove(op);
17930
+ }
17931
+ }
17932
+ }
17933
+ }
17934
+
17642
17935
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/repeater_derived_vars.mjs
17643
17936
  function generateRepeaterDerivedVars(job) {
17644
17937
  const repeaters = /* @__PURE__ */ new Map();
@@ -17751,8 +18044,9 @@ function resolveI18nElementPlaceholders(job) {
17751
18044
  }
17752
18045
  resolvePlaceholdersForView(job, job.root, i18nContexts, elements);
17753
18046
  }
17754
- function resolvePlaceholdersForView(job, unit, i18nContexts, elements) {
18047
+ function resolvePlaceholdersForView(job, unit, i18nContexts, elements, pendingStructuralDirective) {
17755
18048
  let currentOps = null;
18049
+ let pendingStructuralDirectiveCloses = /* @__PURE__ */ new Map();
17756
18050
  for (const op of unit.create) {
17757
18051
  switch (op.kind) {
17758
18052
  case OpKind.I18nStart:
@@ -17769,52 +18063,135 @@ function resolvePlaceholdersForView(job, unit, i18nContexts, elements) {
17769
18063
  if (currentOps === null) {
17770
18064
  throw Error("i18n tag placeholder should only occur inside an i18n block");
17771
18065
  }
17772
- const { startName, closeName } = op.i18nPlaceholder;
17773
- let flags = I18nParamValueFlags.ElementTag | I18nParamValueFlags.OpenTag;
17774
- if (closeName === "") {
17775
- flags |= I18nParamValueFlags.CloseTag;
18066
+ recordElementStart(op, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18067
+ if (pendingStructuralDirective && op.i18nPlaceholder.closeName) {
18068
+ pendingStructuralDirectiveCloses.set(op.xref, pendingStructuralDirective);
17776
18069
  }
17777
- addParam(currentOps.i18nContext.params, startName, op.handle.slot, currentOps.i18nBlock.subTemplateIndex, flags);
18070
+ pendingStructuralDirective = void 0;
17778
18071
  }
17779
18072
  break;
17780
18073
  case OpKind.ElementEnd:
17781
18074
  const startOp = elements.get(op.xref);
17782
18075
  if (startOp && startOp.i18nPlaceholder !== void 0) {
17783
18076
  if (currentOps === null) {
17784
- throw Error("i18n tag placeholder should only occur inside an i18n block");
17785
- }
17786
- const { closeName } = startOp.i18nPlaceholder;
17787
- if (closeName !== "") {
17788
- addParam(currentOps.i18nContext.params, closeName, startOp.handle.slot, currentOps.i18nBlock.subTemplateIndex, I18nParamValueFlags.ElementTag | I18nParamValueFlags.CloseTag);
18077
+ throw Error("AssertionError: i18n tag placeholder should only occur inside an i18n block");
17789
18078
  }
18079
+ recordElementClose(startOp, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirectiveCloses.get(op.xref));
18080
+ pendingStructuralDirectiveCloses.delete(op.xref);
17790
18081
  }
17791
18082
  break;
17792
- case OpKind.Template:
18083
+ case OpKind.Projection:
17793
18084
  if (op.i18nPlaceholder !== void 0) {
17794
18085
  if (currentOps === null) {
17795
18086
  throw Error("i18n tag placeholder should only occur inside an i18n block");
17796
18087
  }
17797
- let startFlags = I18nParamValueFlags.TemplateTag | I18nParamValueFlags.OpenTag;
17798
- const subTemplateIndex = getSubTemplateIndexForTemplateTag(job, currentOps.i18nBlock, op);
17799
- const { startName, closeName } = op.i18nPlaceholder;
17800
- const isSelfClosing = closeName === "";
17801
- if (isSelfClosing) {
17802
- startFlags |= I18nParamValueFlags.CloseTag;
18088
+ recordElementStart(op, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18089
+ recordElementClose(op, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18090
+ pendingStructuralDirective = void 0;
18091
+ }
18092
+ break;
18093
+ case OpKind.Template:
18094
+ const view = job.views.get(op.xref);
18095
+ if (op.i18nPlaceholder === void 0) {
18096
+ resolvePlaceholdersForView(job, view, i18nContexts, elements);
18097
+ } else {
18098
+ if (currentOps === null) {
18099
+ throw Error("i18n tag placeholder should only occur inside an i18n block");
17803
18100
  }
17804
- addParam(currentOps.i18nContext.params, startName, op.handle.slot, subTemplateIndex, startFlags);
17805
- resolvePlaceholdersForView(job, job.views.get(op.xref), i18nContexts, elements);
17806
- if (!isSelfClosing) {
17807
- addParam(currentOps.i18nContext.params, closeName, op.handle.slot, subTemplateIndex, I18nParamValueFlags.TemplateTag | I18nParamValueFlags.CloseTag);
18101
+ if (op.templateKind === TemplateKind.Structural) {
18102
+ resolvePlaceholdersForView(job, view, i18nContexts, elements, op);
18103
+ } else {
18104
+ recordTemplateStart(job, view, op.handle.slot, op.i18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18105
+ resolvePlaceholdersForView(job, view, i18nContexts, elements);
18106
+ recordTemplateClose(job, view, op.handle.slot, op.i18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18107
+ pendingStructuralDirective = void 0;
17808
18108
  }
18109
+ }
18110
+ break;
18111
+ case OpKind.RepeaterCreate:
18112
+ if (pendingStructuralDirective !== void 0) {
18113
+ throw Error("AssertionError: Unexpected structural directive associated with @for block");
18114
+ }
18115
+ const forSlot = op.handle.slot + 1;
18116
+ const forView = job.views.get(op.xref);
18117
+ if (op.i18nPlaceholder === void 0) {
18118
+ resolvePlaceholdersForView(job, forView, i18nContexts, elements);
17809
18119
  } else {
17810
- resolvePlaceholdersForView(job, job.views.get(op.xref), i18nContexts, elements);
18120
+ if (currentOps === null) {
18121
+ throw Error("i18n tag placeholder should only occur inside an i18n block");
18122
+ }
18123
+ recordTemplateStart(job, forView, forSlot, op.i18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18124
+ resolvePlaceholdersForView(job, forView, i18nContexts, elements);
18125
+ recordTemplateClose(job, forView, forSlot, op.i18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18126
+ pendingStructuralDirective = void 0;
18127
+ }
18128
+ if (op.emptyView !== null) {
18129
+ const emptySlot = op.handle.slot + 2;
18130
+ const emptyView = job.views.get(op.emptyView);
18131
+ if (op.emptyI18nPlaceholder === void 0) {
18132
+ resolvePlaceholdersForView(job, emptyView, i18nContexts, elements);
18133
+ } else {
18134
+ if (currentOps === null) {
18135
+ throw Error("i18n tag placeholder should only occur inside an i18n block");
18136
+ }
18137
+ recordTemplateStart(job, emptyView, emptySlot, op.emptyI18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18138
+ resolvePlaceholdersForView(job, emptyView, i18nContexts, elements);
18139
+ recordTemplateClose(job, emptyView, emptySlot, op.emptyI18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18140
+ pendingStructuralDirective = void 0;
18141
+ }
17811
18142
  }
17812
18143
  break;
17813
18144
  }
17814
18145
  }
17815
18146
  }
17816
- function getSubTemplateIndexForTemplateTag(job, i18nOp, op) {
17817
- for (const childOp of job.views.get(op.xref).create) {
18147
+ function recordElementStart(op, i18nContext, i18nBlock, structuralDirective) {
18148
+ const { startName, closeName } = op.i18nPlaceholder;
18149
+ let flags = I18nParamValueFlags.ElementTag | I18nParamValueFlags.OpenTag;
18150
+ let value = op.handle.slot;
18151
+ if (structuralDirective !== void 0) {
18152
+ flags |= I18nParamValueFlags.TemplateTag;
18153
+ value = { element: value, template: structuralDirective.handle.slot };
18154
+ }
18155
+ if (!closeName) {
18156
+ flags |= I18nParamValueFlags.CloseTag;
18157
+ }
18158
+ addParam(i18nContext.params, startName, value, i18nBlock.subTemplateIndex, flags);
18159
+ }
18160
+ function recordElementClose(op, i18nContext, i18nBlock, structuralDirective) {
18161
+ const { closeName } = op.i18nPlaceholder;
18162
+ if (closeName) {
18163
+ let flags = I18nParamValueFlags.ElementTag | I18nParamValueFlags.CloseTag;
18164
+ let value = op.handle.slot;
18165
+ if (structuralDirective !== void 0) {
18166
+ flags |= I18nParamValueFlags.TemplateTag;
18167
+ value = { element: value, template: structuralDirective.handle.slot };
18168
+ }
18169
+ addParam(i18nContext.params, closeName, value, i18nBlock.subTemplateIndex, flags);
18170
+ }
18171
+ }
18172
+ function recordTemplateStart(job, view, slot, i18nPlaceholder, i18nContext, i18nBlock, structuralDirective) {
18173
+ let { startName, closeName } = i18nPlaceholder;
18174
+ let flags = I18nParamValueFlags.TemplateTag | I18nParamValueFlags.OpenTag;
18175
+ if (!closeName) {
18176
+ flags |= I18nParamValueFlags.CloseTag;
18177
+ }
18178
+ if (structuralDirective !== void 0) {
18179
+ addParam(i18nContext.params, startName, structuralDirective.handle.slot, i18nBlock.subTemplateIndex, flags);
18180
+ }
18181
+ addParam(i18nContext.params, startName, slot, getSubTemplateIndexForTemplateTag(job, i18nBlock, view), flags);
18182
+ }
18183
+ function recordTemplateClose(job, view, slot, i18nPlaceholder, i18nContext, i18nBlock, structuralDirective) {
18184
+ const { startName, closeName } = i18nPlaceholder;
18185
+ const flags = I18nParamValueFlags.TemplateTag | I18nParamValueFlags.CloseTag;
18186
+ if (closeName) {
18187
+ addParam(i18nContext.params, closeName, slot, getSubTemplateIndexForTemplateTag(job, i18nBlock, view), flags);
18188
+ if (structuralDirective !== void 0) {
18189
+ addParam(i18nContext.params, closeName, structuralDirective.handle.slot, i18nBlock.subTemplateIndex, flags);
18190
+ }
18191
+ }
18192
+ }
18193
+ function getSubTemplateIndexForTemplateTag(job, i18nOp, view) {
18194
+ for (const childOp of view.create) {
17818
18195
  if (childOp.kind === OpKind.I18nStart) {
17819
18196
  return childOp.subTemplateIndex;
17820
18197
  }
@@ -17830,6 +18207,7 @@ function addParam(params, placeholder, value, subTemplateIndex, flags) {
17830
18207
 
17831
18208
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_i18n_expression_placeholders.mjs
17832
18209
  function resolveI18nExpressionPlaceholders(job) {
18210
+ var _a2;
17833
18211
  const subTemplateIndicies = /* @__PURE__ */ new Map();
17834
18212
  const i18nContexts = /* @__PURE__ */ new Map();
17835
18213
  for (const unit of job.units) {
@@ -17845,12 +18223,13 @@ function resolveI18nExpressionPlaceholders(job) {
17845
18223
  }
17846
18224
  }
17847
18225
  const expressionIndices = /* @__PURE__ */ new Map();
18226
+ const referenceIndex = (op) => op.usage === I18nExpressionFor.I18nText ? op.i18nOwner : op.context;
17848
18227
  for (const unit of job.units) {
17849
18228
  for (const op of unit.update) {
17850
18229
  if (op.kind === OpKind.I18nExpression) {
17851
18230
  const i18nContext = i18nContexts.get(op.context);
17852
- const index = expressionIndices.get(op.target) || 0;
17853
- const subTemplateIndex = subTemplateIndicies.get(op.target);
18231
+ const index = expressionIndices.get(referenceIndex(op)) || 0;
18232
+ const subTemplateIndex = (_a2 = subTemplateIndicies.get(op.i18nOwner)) != null ? _a2 : null;
17854
18233
  const params = op.resolutionTime === I18nParamResolutionTime.Creation ? i18nContext.params : i18nContext.postprocessingParams;
17855
18234
  const values = params.get(op.i18nPlaceholder) || [];
17856
18235
  values.push({
@@ -17859,7 +18238,7 @@ function resolveI18nExpressionPlaceholders(job) {
17859
18238
  flags: I18nParamValueFlags.ExpressionIndex
17860
18239
  });
17861
18240
  params.set(op.i18nPlaceholder, values);
17862
- expressionIndices.set(op.target, index + 1);
18241
+ expressionIndices.set(referenceIndex(op), index + 1);
17863
18242
  }
17864
18243
  }
17865
18244
  }
@@ -17974,30 +18353,54 @@ function processLexicalScope2(unit, ops, savedView) {
17974
18353
  }
17975
18354
 
17976
18355
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_sanitizers.mjs
17977
- var sanitizers = /* @__PURE__ */ new Map([
17978
- [SecurityContext.HTML, SanitizerFn.Html],
17979
- [SecurityContext.SCRIPT, SanitizerFn.Script],
17980
- [SecurityContext.STYLE, SanitizerFn.Style],
17981
- [SecurityContext.URL, SanitizerFn.Url],
17982
- [SecurityContext.RESOURCE_URL, SanitizerFn.ResourceUrl]
18356
+ var sanitizerFns = /* @__PURE__ */ new Map([
18357
+ [SecurityContext.HTML, Identifiers.sanitizeHtml],
18358
+ [SecurityContext.RESOURCE_URL, Identifiers.sanitizeResourceUrl],
18359
+ [SecurityContext.SCRIPT, Identifiers.sanitizeScript],
18360
+ [SecurityContext.STYLE, Identifiers.sanitizeStyle],
18361
+ [SecurityContext.URL, Identifiers.sanitizeUrl]
18362
+ ]);
18363
+ var trustedValueFns = /* @__PURE__ */ new Map([
18364
+ [SecurityContext.HTML, Identifiers.trustConstantHtml],
18365
+ [SecurityContext.RESOURCE_URL, Identifiers.trustConstantResourceUrl]
17983
18366
  ]);
17984
18367
  function resolveSanitizers(job) {
18368
+ var _a2, _b2;
17985
18369
  for (const unit of job.units) {
17986
18370
  const elements = createOpXrefMap(unit);
17987
- let sanitizerFn;
18371
+ if (job.kind !== CompilationJobKind.Host) {
18372
+ for (const op of unit.create) {
18373
+ if (op.kind === OpKind.ExtractedAttribute) {
18374
+ const trustedValueFn = (_a2 = trustedValueFns.get(getOnlySecurityContext(op.securityContext))) != null ? _a2 : null;
18375
+ op.trustedValueFn = trustedValueFn !== null ? importExpr(trustedValueFn) : null;
18376
+ }
18377
+ }
18378
+ }
17988
18379
  for (const op of unit.update) {
17989
18380
  switch (op.kind) {
17990
18381
  case OpKind.Property:
17991
18382
  case OpKind.Attribute:
17992
- sanitizerFn = sanitizers.get(op.securityContext) || null;
17993
- op.sanitizer = sanitizerFn ? new SanitizerExpr(sanitizerFn) : null;
18383
+ case OpKind.HostProperty:
18384
+ let sanitizerFn = null;
18385
+ if (Array.isArray(op.securityContext) && op.securityContext.length === 2 && op.securityContext.indexOf(SecurityContext.URL) > -1 && op.securityContext.indexOf(SecurityContext.RESOURCE_URL) > -1) {
18386
+ sanitizerFn = Identifiers.sanitizeUrlOrResourceUrl;
18387
+ } else {
18388
+ sanitizerFn = (_b2 = sanitizerFns.get(getOnlySecurityContext(op.securityContext))) != null ? _b2 : null;
18389
+ }
18390
+ op.sanitizer = sanitizerFn !== null ? importExpr(sanitizerFn) : null;
17994
18391
  if (op.sanitizer === null) {
17995
- const ownerOp = elements.get(op.target);
17996
- if (ownerOp === void 0 || !isElementOrContainerOp(ownerOp)) {
17997
- throw Error("Property should have an element-like owner");
18392
+ let isIframe = false;
18393
+ if (job.kind === CompilationJobKind.Host || op.kind === OpKind.HostProperty) {
18394
+ isIframe = true;
18395
+ } else {
18396
+ const ownerOp = elements.get(op.target);
18397
+ if (ownerOp === void 0 || !isElementOrContainerOp(ownerOp)) {
18398
+ throw Error("Property should have an element-like owner");
18399
+ }
18400
+ isIframe = isIframeElement(ownerOp);
17998
18401
  }
17999
- if (isIframeElement(ownerOp) && isIframeSecuritySensitiveAttr(op.name)) {
18000
- op.sanitizer = new SanitizerExpr(SanitizerFn.IframeAttribute);
18402
+ if (isIframe && isIframeSecuritySensitiveAttr(op.name)) {
18403
+ op.sanitizer = importExpr(Identifiers.validateIframeAttribute);
18001
18404
  }
18002
18405
  }
18003
18406
  break;
@@ -18009,6 +18412,15 @@ function isIframeElement(op) {
18009
18412
  var _a2;
18010
18413
  return op.kind === OpKind.ElementStart && ((_a2 = op.tag) == null ? void 0 : _a2.toLowerCase()) === "iframe";
18011
18414
  }
18415
+ function getOnlySecurityContext(securityContext) {
18416
+ if (Array.isArray(securityContext)) {
18417
+ if (securityContext.length > 1) {
18418
+ throw Error(`AssertionError: Ambiguous security context`);
18419
+ }
18420
+ return securityContext[0] || SecurityContext.NONE;
18421
+ }
18422
+ return securityContext;
18423
+ }
18012
18424
 
18013
18425
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/save_restore_view.mjs
18014
18426
  function saveAndRestoreView(job) {
@@ -18656,12 +19068,12 @@ var phases = [
18656
19068
  { kind: CompilationJobKind.Tmpl, fn: removeContentSelectors },
18657
19069
  { kind: CompilationJobKind.Host, fn: parseHostStyleProperties },
18658
19070
  { kind: CompilationJobKind.Tmpl, fn: emitNamespaceChanges },
18659
- { kind: CompilationJobKind.Both, fn: specializeStyleBindings },
18660
- { kind: CompilationJobKind.Both, fn: specializeBindings },
18661
19071
  { kind: CompilationJobKind.Tmpl, fn: propagateI18nBlocks },
18662
19072
  { kind: CompilationJobKind.Tmpl, fn: wrapI18nIcus },
18663
- { kind: CompilationJobKind.Tmpl, fn: createI18nContexts },
19073
+ { kind: CompilationJobKind.Both, fn: specializeStyleBindings },
19074
+ { kind: CompilationJobKind.Both, fn: specializeBindings },
18664
19075
  { kind: CompilationJobKind.Both, fn: extractAttributes },
19076
+ { kind: CompilationJobKind.Tmpl, fn: createI18nContexts },
18665
19077
  { kind: CompilationJobKind.Both, fn: parseExtractedStyles },
18666
19078
  { kind: CompilationJobKind.Tmpl, fn: removeEmptyBindings },
18667
19079
  { kind: CompilationJobKind.Both, fn: collapseSingletonInterpolations },
@@ -18669,14 +19081,17 @@ var phases = [
18669
19081
  { kind: CompilationJobKind.Tmpl, fn: generateConditionalExpressions },
18670
19082
  { kind: CompilationJobKind.Tmpl, fn: createPipes },
18671
19083
  { kind: CompilationJobKind.Tmpl, fn: configureDeferInstructions },
18672
- { kind: CompilationJobKind.Tmpl, fn: extractI18nText },
19084
+ { kind: CompilationJobKind.Tmpl, fn: convertI18nText },
19085
+ { kind: CompilationJobKind.Tmpl, fn: convertI18nBindings },
19086
+ { kind: CompilationJobKind.Tmpl, fn: removeUnusedI18nAttributesOps },
19087
+ { kind: CompilationJobKind.Tmpl, fn: assignI18nSlotDependencies },
18673
19088
  { kind: CompilationJobKind.Tmpl, fn: applyI18nExpressions },
18674
19089
  { kind: CompilationJobKind.Tmpl, fn: createVariadicPipes },
18675
19090
  { kind: CompilationJobKind.Both, fn: generatePureLiteralStructures },
18676
19091
  { kind: CompilationJobKind.Tmpl, fn: generateProjectionDefs },
18677
19092
  { kind: CompilationJobKind.Tmpl, fn: generateVariables },
18678
19093
  { kind: CompilationJobKind.Tmpl, fn: saveAndRestoreView },
18679
- { kind: CompilationJobKind.Tmpl, fn: deleteAnyCasts },
19094
+ { kind: CompilationJobKind.Both, fn: deleteAnyCasts },
18680
19095
  { kind: CompilationJobKind.Both, fn: resolveDollarEvent },
18681
19096
  { kind: CompilationJobKind.Tmpl, fn: generateRepeaterDerivedVars },
18682
19097
  { kind: CompilationJobKind.Tmpl, fn: generateTrackVariables },
@@ -18684,7 +19099,7 @@ var phases = [
18684
19099
  { kind: CompilationJobKind.Tmpl, fn: resolveDeferTargetNames },
18685
19100
  { kind: CompilationJobKind.Tmpl, fn: optimizeTrackFns },
18686
19101
  { kind: CompilationJobKind.Both, fn: resolveContexts },
18687
- { kind: CompilationJobKind.Tmpl, fn: resolveSanitizers },
19102
+ { kind: CompilationJobKind.Both, fn: resolveSanitizers },
18688
19103
  { kind: CompilationJobKind.Tmpl, fn: liftLocalRefs },
18689
19104
  { kind: CompilationJobKind.Both, fn: generateNullishCoalesceExpressions },
18690
19105
  { kind: CompilationJobKind.Both, fn: expandSafeReads },
@@ -18699,7 +19114,6 @@ var phases = [
18699
19114
  { kind: CompilationJobKind.Tmpl, fn: collectI18nConsts },
18700
19115
  { kind: CompilationJobKind.Tmpl, fn: collectConstExpressions },
18701
19116
  { kind: CompilationJobKind.Both, fn: collectElementConsts },
18702
- { kind: CompilationJobKind.Tmpl, fn: assignI18nSlotDependencies },
18703
19117
  { kind: CompilationJobKind.Tmpl, fn: removeI18nContexts },
18704
19118
  { kind: CompilationJobKind.Both, fn: countVariables },
18705
19119
  { kind: CompilationJobKind.Tmpl, fn: generateAdvance },
@@ -18817,6 +19231,8 @@ function emitHostBindingFunction(job) {
18817
19231
 
18818
19232
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/ingest.mjs
18819
19233
  var compatibilityMode = CompatibilityMode.TemplateDefinitionBuilder;
19234
+ var domSchema = new DomElementSchemaRegistry();
19235
+ var NG_TEMPLATE_TAG_NAME = "ng-template";
18820
19236
  function ingestComponent(componentName, template2, constantPool, relativeContextFilePath, i18nUseExternalIds, deferBlocksMeta) {
18821
19237
  const job = new ComponentCompilationJob(componentName, constantPool, compatibilityMode, relativeContextFilePath, i18nUseExternalIds, deferBlocksMeta);
18822
19238
  ingestNodes(job.root, template2);
@@ -18826,50 +19242,55 @@ function ingestHostBinding(input, bindingParser, constantPool) {
18826
19242
  var _a2, _b2, _c2;
18827
19243
  const job = new HostBindingCompilationJob(input.componentName, constantPool, compatibilityMode);
18828
19244
  for (const property2 of (_a2 = input.properties) != null ? _a2 : []) {
18829
- ingestHostProperty(job, property2, false);
19245
+ let bindingKind = BindingKind.Property;
19246
+ if (property2.name.startsWith("attr.")) {
19247
+ property2.name = property2.name.substring("attr.".length);
19248
+ bindingKind = BindingKind.Attribute;
19249
+ }
19250
+ if (property2.isAnimation) {
19251
+ bindingKind = BindingKind.Animation;
19252
+ }
19253
+ const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, property2.name, bindingKind === BindingKind.Attribute).filter((context) => context !== SecurityContext.NONE);
19254
+ ingestHostProperty(job, property2, bindingKind, false, securityContexts);
18830
19255
  }
18831
19256
  for (const [name, expr] of (_b2 = Object.entries(input.attributes)) != null ? _b2 : []) {
18832
- ingestHostAttribute(job, name, expr);
19257
+ const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, name, true).filter((context) => context !== SecurityContext.NONE);
19258
+ ingestHostAttribute(job, name, expr, securityContexts);
18833
19259
  }
18834
19260
  for (const event of (_c2 = input.events) != null ? _c2 : []) {
18835
19261
  ingestHostEvent(job, event);
18836
19262
  }
18837
19263
  return job;
18838
19264
  }
18839
- function ingestHostProperty(job, property2, isTextAttribute) {
19265
+ function ingestHostProperty(job, property2, bindingKind, isTextAttribute, securityContexts) {
18840
19266
  let expression;
18841
19267
  const ast = property2.expression.ast;
18842
19268
  if (ast instanceof Interpolation) {
18843
- expression = new Interpolation2(ast.strings, ast.expressions.map((expr) => convertAst(expr, job, property2.sourceSpan)));
19269
+ expression = new Interpolation2(ast.strings, ast.expressions.map((expr) => convertAst(expr, job, property2.sourceSpan)), []);
18844
19270
  } else {
18845
19271
  expression = convertAst(ast, job, property2.sourceSpan);
18846
19272
  }
18847
- let bindingKind = BindingKind.Property;
18848
- if (property2.name.startsWith("attr.")) {
18849
- property2.name = property2.name.substring("attr.".length);
18850
- bindingKind = BindingKind.Attribute;
18851
- }
18852
- if (property2.isAnimation) {
18853
- bindingKind = BindingKind.Animation;
18854
- }
18855
- job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, SecurityContext.NONE, isTextAttribute, false, property2.sourceSpan));
19273
+ job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, securityContexts, isTextAttribute, false, null, null, property2.sourceSpan));
18856
19274
  }
18857
- function ingestHostAttribute(job, name, value) {
19275
+ function ingestHostAttribute(job, name, value, securityContexts) {
18858
19276
  const attrBinding = createBindingOp(
18859
19277
  job.root.xref,
18860
19278
  BindingKind.Attribute,
18861
19279
  name,
18862
19280
  value,
18863
19281
  null,
18864
- SecurityContext.NONE,
19282
+ securityContexts,
18865
19283
  true,
18866
19284
  false,
19285
+ null,
19286
+ null,
18867
19287
  null
18868
19288
  );
18869
19289
  job.root.update.push(attrBinding);
18870
19290
  }
18871
19291
  function ingestHostEvent(job, event) {
18872
- const eventBinding = createListenerOp(job.root.xref, new SlotHandle(), event.name, null, event.targetOrPhase, true, event.sourceSpan);
19292
+ 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);
18873
19294
  eventBinding.handlerOps.push(createStatementOp(new ReturnStatement(convertAst(event.handler.ast, job, event.sourceSpan), event.handlerSpan)));
18874
19295
  job.root.create.push(eventBinding);
18875
19296
  }
@@ -18909,14 +19330,17 @@ function ingestElement(unit, element2) {
18909
19330
  const [namespaceKey, elementName] = splitNsName(element2.name);
18910
19331
  const startOp = createElementStartOp(elementName, id, namespaceForKey(namespaceKey), element2.i18n instanceof TagPlaceholder ? element2.i18n : void 0, element2.startSourceSpan);
18911
19332
  unit.create.push(startOp);
18912
- ingestBindings(unit, startOp, element2);
19333
+ ingestElementBindings(unit, startOp, element2);
18913
19334
  ingestReferences(startOp, element2);
19335
+ let i18nBlockId = null;
19336
+ if (element2.i18n instanceof Message) {
19337
+ i18nBlockId = unit.job.allocateXrefId();
19338
+ unit.create.push(createI18nStartOp(i18nBlockId, element2.i18n));
19339
+ }
18914
19340
  ingestNodes(unit, element2.children);
18915
19341
  const endOp = createElementEndOp(id, (_a2 = element2.endSourceSpan) != null ? _a2 : element2.startSourceSpan);
18916
19342
  unit.create.push(endOp);
18917
- if (element2.i18n instanceof Message) {
18918
- const i18nBlockId = unit.job.allocateXrefId();
18919
- OpList.insertAfter(createI18nStartOp(i18nBlockId, element2.i18n), startOp);
19343
+ if (i18nBlockId !== null) {
18920
19344
  OpList.insertBefore(createI18nEndOp(i18nBlockId), endOp);
18921
19345
  }
18922
19346
  }
@@ -18933,24 +19357,30 @@ function ingestTemplate(unit, tmpl) {
18933
19357
  const i18nPlaceholder = tmpl.i18n instanceof TagPlaceholder ? tmpl.i18n : void 0;
18934
19358
  const namespace = namespaceForKey(namespacePrefix);
18935
19359
  const functionNameSuffix = tagNameWithoutNamespace === null ? "" : prefixWithNamespace(tagNameWithoutNamespace, namespace);
18936
- const tplOp = createTemplateOp(childView.xref, tagNameWithoutNamespace, functionNameSuffix, namespace, i18nPlaceholder, tmpl.startSourceSpan);
18937
- unit.create.push(tplOp);
18938
- ingestBindings(unit, tplOp, tmpl);
18939
- ingestReferences(tplOp, tmpl);
19360
+ const templateKind = isPlainTemplate(tmpl) ? TemplateKind.NgTemplate : TemplateKind.Structural;
19361
+ const templateOp = createTemplateOp(childView.xref, templateKind, tagNameWithoutNamespace, functionNameSuffix, namespace, i18nPlaceholder, tmpl.startSourceSpan);
19362
+ unit.create.push(templateOp);
19363
+ ingestTemplateBindings(unit, templateOp, tmpl, templateKind);
19364
+ ingestReferences(templateOp, tmpl);
18940
19365
  ingestNodes(childView, tmpl.children);
18941
19366
  for (const { name, value } of tmpl.variables) {
18942
19367
  childView.contextVariables.set(name, value !== "" ? value : "$implicit");
18943
19368
  }
18944
- if (isPlainTemplate(tmpl) && tmpl.i18n instanceof Message) {
19369
+ if (templateKind === TemplateKind.NgTemplate && tmpl.i18n instanceof Message) {
18945
19370
  const id = unit.job.allocateXrefId();
18946
19371
  OpList.insertAfter(createI18nStartOp(id, tmpl.i18n), childView.create.head);
18947
19372
  OpList.insertBefore(createI18nEndOp(id), childView.create.tail);
18948
19373
  }
18949
19374
  }
18950
19375
  function ingestContent(unit, content) {
18951
- const op = createProjectionOp(unit.job.allocateXrefId(), content.selector, content.sourceSpan);
19376
+ if (content.i18n !== void 0 && !(content.i18n instanceof TagPlaceholder)) {
19377
+ throw Error(`Unhandled i18n metadata type for element: ${content.i18n.constructor.name}`);
19378
+ }
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);
18952
19381
  for (const attr of content.attributes) {
18953
- ingestBinding(unit, op.xref, attr.name, literal(attr.value), 1, null, SecurityContext.NONE, attr.sourceSpan, BindingFlags.TextValue);
19382
+ const securityContext = domSchema.securityContext(content.name, attr.name, true);
19383
+ unit.update.push(createBindingOp(op.xref, BindingKind.Attribute, attr.name, literal(attr.value), null, securityContext, true, false, null, asMessage(attr.i18n), attr.sourceSpan));
18954
19384
  }
18955
19385
  unit.create.push(op);
18956
19386
  }
@@ -18978,9 +19408,10 @@ function ingestBoundText(unit, text2, i18nPlaceholders) {
18978
19408
  const textXref = unit.job.allocateXrefId();
18979
19409
  unit.create.push(createTextOp(textXref, "", text2.sourceSpan));
18980
19410
  const baseSourceSpan = unit.job.compatibility ? null : text2.sourceSpan;
18981
- unit.update.push(createInterpolateTextOp(textXref, new Interpolation2(value.strings, value.expressions.map((expr) => convertAst(expr, unit.job, baseSourceSpan))), i18nPlaceholders, text2.sourceSpan));
19411
+ unit.update.push(createInterpolateTextOp(textXref, new Interpolation2(value.strings, value.expressions.map((expr) => convertAst(expr, unit.job, baseSourceSpan)), i18nPlaceholders), text2.sourceSpan));
18982
19412
  }
18983
19413
  function ingestIfBlock(unit, ifBlock) {
19414
+ var _a2;
18984
19415
  let firstXref = null;
18985
19416
  let firstSlotHandle = null;
18986
19417
  let conditions = [];
@@ -18994,14 +19425,21 @@ function ingestIfBlock(unit, ifBlock) {
18994
19425
  if (ifCase.expressionAlias !== null) {
18995
19426
  cView.contextVariables.set(ifCase.expressionAlias.name, CTX_REF);
18996
19427
  }
18997
- const tmplOp = createTemplateOp(cView.xref, tagName, "Conditional", Namespace.HTML, void 0, ifCase.sourceSpan);
18998
- unit.create.push(tmplOp);
19428
+ let ifCaseI18nMeta = void 0;
19429
+ if (ifCase.i18n !== void 0) {
19430
+ if (!(ifCase.i18n instanceof BlockPlaceholder)) {
19431
+ throw Error(`Unhandled i18n metadata type for if block: ${(_a2 = ifCase.i18n) == null ? void 0 : _a2.constructor.name}`);
19432
+ }
19433
+ ifCaseI18nMeta = ifCase.i18n;
19434
+ }
19435
+ const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, tagName, "Conditional", Namespace.HTML, ifCaseI18nMeta, ifCase.sourceSpan);
19436
+ unit.create.push(templateOp);
18999
19437
  if (firstXref === null) {
19000
19438
  firstXref = cView.xref;
19001
- firstSlotHandle = tmplOp.handle;
19439
+ firstSlotHandle = templateOp.handle;
19002
19440
  }
19003
19441
  const caseExpr = ifCase.expression ? convertAst(ifCase.expression, unit.job, null) : null;
19004
- const conditionalCaseExpr = new ConditionalCaseExpr(caseExpr, tmplOp.xref, tmplOp.handle, ifCase.expressionAlias);
19442
+ const conditionalCaseExpr = new ConditionalCaseExpr(caseExpr, templateOp.xref, templateOp.handle, ifCase.expressionAlias);
19005
19443
  conditions.push(conditionalCaseExpr);
19006
19444
  ingestNodes(cView, ifCase.children);
19007
19445
  }
@@ -19009,54 +19447,65 @@ function ingestIfBlock(unit, ifBlock) {
19009
19447
  unit.update.push(conditional2);
19010
19448
  }
19011
19449
  function ingestSwitchBlock(unit, switchBlock) {
19450
+ var _a2;
19012
19451
  let firstXref = null;
19013
19452
  let firstSlotHandle = null;
19014
19453
  let conditions = [];
19015
19454
  for (const switchCase of switchBlock.cases) {
19016
19455
  const cView = unit.job.allocateView(unit.xref);
19017
- const tmplOp = createTemplateOp(cView.xref, null, "Case", Namespace.HTML, void 0, switchCase.sourceSpan);
19018
- unit.create.push(tmplOp);
19456
+ let switchCaseI18nMeta = void 0;
19457
+ if (switchCase.i18n !== void 0) {
19458
+ if (!(switchCase.i18n instanceof BlockPlaceholder)) {
19459
+ throw Error(`Unhandled i18n metadata type for switch block: ${(_a2 = switchCase.i18n) == null ? void 0 : _a2.constructor.name}`);
19460
+ }
19461
+ switchCaseI18nMeta = switchCase.i18n;
19462
+ }
19463
+ const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, null, "Case", Namespace.HTML, switchCaseI18nMeta, switchCase.sourceSpan);
19464
+ unit.create.push(templateOp);
19019
19465
  if (firstXref === null) {
19020
19466
  firstXref = cView.xref;
19021
- firstSlotHandle = tmplOp.handle;
19467
+ firstSlotHandle = templateOp.handle;
19022
19468
  }
19023
19469
  const caseExpr = switchCase.expression ? convertAst(switchCase.expression, unit.job, switchBlock.startSourceSpan) : null;
19024
- const conditionalCaseExpr = new ConditionalCaseExpr(caseExpr, tmplOp.xref, tmplOp.handle);
19470
+ const conditionalCaseExpr = new ConditionalCaseExpr(caseExpr, templateOp.xref, templateOp.handle);
19025
19471
  conditions.push(conditionalCaseExpr);
19026
19472
  ingestNodes(cView, switchCase.children);
19027
19473
  }
19028
19474
  const conditional2 = createConditionalOp(firstXref, firstSlotHandle, convertAst(switchBlock.expression, unit.job, null), conditions, switchBlock.sourceSpan);
19029
19475
  unit.update.push(conditional2);
19030
19476
  }
19031
- function ingestDeferView(unit, suffix, children, sourceSpan) {
19477
+ function ingestDeferView(unit, suffix, i18nMeta, children, sourceSpan) {
19478
+ if (i18nMeta !== void 0 && !(i18nMeta instanceof BlockPlaceholder)) {
19479
+ throw Error("Unhandled i18n metadata type for defer block");
19480
+ }
19032
19481
  if (children === void 0) {
19033
19482
  return null;
19034
19483
  }
19035
19484
  const secondaryView = unit.job.allocateView(unit.xref);
19036
19485
  ingestNodes(secondaryView, children);
19037
- const templateOp = createTemplateOp(secondaryView.xref, null, `Defer${suffix}`, Namespace.HTML, void 0, sourceSpan);
19486
+ const templateOp = createTemplateOp(secondaryView.xref, TemplateKind.Block, null, `Defer${suffix}`, Namespace.HTML, i18nMeta, sourceSpan);
19038
19487
  unit.create.push(templateOp);
19039
19488
  return templateOp;
19040
19489
  }
19041
19490
  function ingestDeferBlock(unit, deferBlock) {
19042
- var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
19491
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
19043
19492
  const blockMeta = unit.job.deferBlocksMeta.get(deferBlock);
19044
19493
  if (blockMeta === void 0) {
19045
19494
  throw new Error(`AssertionError: unable to find metadata for deferred block`);
19046
19495
  }
19047
- const main = ingestDeferView(unit, "", deferBlock.children, deferBlock.sourceSpan);
19048
- const loading = ingestDeferView(unit, "Loading", (_a2 = deferBlock.loading) == null ? void 0 : _a2.children, (_b2 = deferBlock.loading) == null ? void 0 : _b2.sourceSpan);
19049
- const placeholder = ingestDeferView(unit, "Placeholder", (_c2 = deferBlock.placeholder) == null ? void 0 : _c2.children, (_d2 = deferBlock.placeholder) == null ? void 0 : _d2.sourceSpan);
19050
- const error2 = ingestDeferView(unit, "Error", (_e2 = deferBlock.error) == null ? void 0 : _e2.children, (_f2 = deferBlock.error) == null ? void 0 : _f2.sourceSpan);
19496
+ const main = ingestDeferView(unit, "", deferBlock.i18n, deferBlock.children, deferBlock.sourceSpan);
19497
+ const loading = ingestDeferView(unit, "Loading", (_a2 = deferBlock.loading) == null ? void 0 : _a2.i18n, (_b2 = deferBlock.loading) == null ? void 0 : _b2.children, (_c2 = deferBlock.loading) == null ? void 0 : _c2.sourceSpan);
19498
+ const placeholder = ingestDeferView(unit, "Placeholder", (_d2 = deferBlock.placeholder) == null ? void 0 : _d2.i18n, (_e2 = deferBlock.placeholder) == null ? void 0 : _e2.children, (_f2 = deferBlock.placeholder) == null ? void 0 : _f2.sourceSpan);
19499
+ const error2 = ingestDeferView(unit, "Error", (_g = deferBlock.error) == null ? void 0 : _g.i18n, (_h = deferBlock.error) == null ? void 0 : _h.children, (_i = deferBlock.error) == null ? void 0 : _i.sourceSpan);
19051
19500
  const deferXref = unit.job.allocateXrefId();
19052
19501
  const deferOp = createDeferOp(deferXref, main.xref, main.handle, blockMeta, deferBlock.sourceSpan);
19053
- deferOp.placeholderView = (_g = placeholder == null ? void 0 : placeholder.xref) != null ? _g : null;
19054
- deferOp.placeholderSlot = (_h = placeholder == null ? void 0 : placeholder.handle) != null ? _h : null;
19055
- deferOp.loadingSlot = (_i = loading == null ? void 0 : loading.handle) != null ? _i : null;
19056
- deferOp.errorSlot = (_j = error2 == null ? void 0 : error2.handle) != null ? _j : null;
19057
- deferOp.placeholderMinimumTime = (_l = (_k = deferBlock.placeholder) == null ? void 0 : _k.minimumTime) != null ? _l : null;
19058
- deferOp.loadingMinimumTime = (_n = (_m = deferBlock.loading) == null ? void 0 : _m.minimumTime) != null ? _n : null;
19059
- deferOp.loadingAfterTime = (_p = (_o = deferBlock.loading) == null ? void 0 : _o.afterTime) != null ? _p : null;
19502
+ deferOp.placeholderView = (_j = placeholder == null ? void 0 : placeholder.xref) != null ? _j : null;
19503
+ deferOp.placeholderSlot = (_k = placeholder == null ? void 0 : placeholder.handle) != null ? _k : null;
19504
+ deferOp.loadingSlot = (_l = loading == null ? void 0 : loading.handle) != null ? _l : null;
19505
+ deferOp.errorSlot = (_m = error2 == null ? void 0 : error2.handle) != null ? _m : null;
19506
+ deferOp.placeholderMinimumTime = (_o = (_n = deferBlock.placeholder) == null ? void 0 : _n.minimumTime) != null ? _o : null;
19507
+ deferOp.loadingMinimumTime = (_q = (_p = deferBlock.loading) == null ? void 0 : _p.minimumTime) != null ? _q : null;
19508
+ deferOp.loadingAfterTime = (_s = (_r = deferBlock.loading) == null ? void 0 : _r.afterTime) != null ? _s : null;
19060
19509
  unit.create.push(deferOp);
19061
19510
  let prefetch = false;
19062
19511
  let deferOnOps = [];
@@ -19120,17 +19569,12 @@ function ingestDeferBlock(unit, deferBlock) {
19120
19569
  unit.update.push(deferWhenOps);
19121
19570
  }
19122
19571
  function ingestIcu(unit, icu) {
19123
- var _a2, _b2;
19572
+ var _a2;
19124
19573
  if (icu.i18n instanceof Message && isSingleI18nIcu(icu.i18n)) {
19125
19574
  const xref = unit.job.allocateXrefId();
19126
19575
  const icuNode = icu.i18n.nodes[0];
19127
19576
  unit.create.push(createIcuStartOp(xref, icu.i18n, icuFromI18nMessage(icu.i18n).name, null));
19128
- const expressionPlaceholder = (_a2 = icuNode.expressionPlaceholder) == null ? void 0 : _a2.trimEnd();
19129
- if (expressionPlaceholder === void 0 || icu.vars[expressionPlaceholder] === void 0) {
19130
- throw Error("ICU should have a text binding");
19131
- }
19132
- ingestBoundText(unit, icu.vars[expressionPlaceholder], [expressionPlaceholder]);
19133
- for (const [placeholder, text2] of Object.entries(icu.placeholders)) {
19577
+ for (const [placeholder, text2] of Object.entries(__spreadValues(__spreadValues({}, icu.vars), icu.placeholders))) {
19134
19578
  if (text2 instanceof BoundText) {
19135
19579
  ingestBoundText(unit, text2, [placeholder]);
19136
19580
  } else {
@@ -19139,11 +19583,11 @@ function ingestIcu(unit, icu) {
19139
19583
  }
19140
19584
  unit.create.push(createIcuEndOp(xref));
19141
19585
  } else {
19142
- throw Error(`Unhandled i18n metadata type for ICU: ${(_b2 = icu.i18n) == null ? void 0 : _b2.constructor.name}`);
19586
+ throw Error(`Unhandled i18n metadata type for ICU: ${(_a2 = icu.i18n) == null ? void 0 : _a2.constructor.name}`);
19143
19587
  }
19144
19588
  }
19145
19589
  function ingestForBlock(unit, forBlock) {
19146
- var _a2;
19590
+ var _a2, _b2, _c2;
19147
19591
  const repeaterView = unit.job.allocateView(unit.xref);
19148
19592
  const createRepeaterAlias = (ident, repeaterVar) => {
19149
19593
  repeaterView.aliases.add({
@@ -19177,8 +19621,16 @@ function ingestForBlock(unit, forBlock) {
19177
19621
  $odd: forBlock.contextVariables.$odd.name,
19178
19622
  $implicit: forBlock.item.name
19179
19623
  };
19624
+ if (forBlock.i18n !== void 0 && !(forBlock.i18n instanceof BlockPlaceholder)) {
19625
+ throw Error("AssertionError: Unhandled i18n metadata type or @for");
19626
+ }
19627
+ if (((_a2 = forBlock.empty) == null ? void 0 : _a2.i18n) !== void 0 && !(forBlock.empty.i18n instanceof BlockPlaceholder)) {
19628
+ throw Error("AssertionError: Unhandled i18n metadata type or @empty");
19629
+ }
19630
+ const i18nPlaceholder = forBlock.i18n;
19631
+ const emptyI18nPlaceholder = (_b2 = forBlock.empty) == null ? void 0 : _b2.i18n;
19180
19632
  const tagName = ingestControlFlowInsertionPoint(unit, repeaterView.xref, forBlock);
19181
- const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (_a2 = emptyView == null ? void 0 : emptyView.xref) != null ? _a2 : null, tagName, track, varNames, forBlock.sourceSpan);
19633
+ const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (_c2 = emptyView == null ? void 0 : emptyView.xref) != null ? _c2 : null, tagName, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, forBlock.sourceSpan);
19182
19634
  unit.create.push(repeaterCreate2);
19183
19635
  const expression = convertAst(forBlock.expression, unit.job, convertSourceSpan(forBlock.expression.span, forBlock.sourceSpan));
19184
19636
  const repeater2 = createRepeaterOp(repeaterCreate2.xref, repeaterCreate2.handle, expression, forBlock.sourceSpan);
@@ -19214,6 +19666,15 @@ function convertAst(ast, job, baseSourceSpan) {
19214
19666
  }
19215
19667
  } else if (ast instanceof LiteralPrimitive) {
19216
19668
  return literal(ast.value, void 0, convertSourceSpan(ast.span, baseSourceSpan));
19669
+ } else if (ast instanceof Unary) {
19670
+ switch (ast.operator) {
19671
+ case "+":
19672
+ return new UnaryOperatorExpr(UnaryOperator.Plus, convertAst(ast.expr, job, baseSourceSpan), void 0, convertSourceSpan(ast.span, baseSourceSpan));
19673
+ case "-":
19674
+ return new UnaryOperatorExpr(UnaryOperator.Minus, convertAst(ast.expr, job, baseSourceSpan), void 0, convertSourceSpan(ast.span, baseSourceSpan));
19675
+ default:
19676
+ throw new Error(`AssertionError: unknown unary operator ${ast.operator}`);
19677
+ }
19217
19678
  } else if (ast instanceof Binary) {
19218
19679
  const operator = BINARY_OPERATORS.get(ast.operation);
19219
19680
  if (operator === void 0) {
@@ -19251,104 +19712,134 @@ function convertAst(ast, job, baseSourceSpan) {
19251
19712
  return new SafeInvokeFunctionExpr(convertAst(ast.receiver, job, baseSourceSpan), ast.args.map((a) => convertAst(a, job, baseSourceSpan)));
19252
19713
  } else if (ast instanceof EmptyExpr) {
19253
19714
  return new EmptyExpr2(convertSourceSpan(ast.span, baseSourceSpan));
19715
+ } else if (ast instanceof PrefixNot) {
19716
+ return not(convertAst(ast.expression, job, baseSourceSpan), convertSourceSpan(ast.span, baseSourceSpan));
19254
19717
  } else {
19255
19718
  throw new Error(`Unhandled expression type "${ast.constructor.name}" in file "${baseSourceSpan == null ? void 0 : baseSourceSpan.start.file.url}"`);
19256
19719
  }
19257
19720
  }
19721
+ function convertAstWithInterpolation(job, value, i18nMeta) {
19722
+ var _a2, _b2;
19723
+ let expression;
19724
+ 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 : {}));
19726
+ } else if (value instanceof AST) {
19727
+ expression = convertAst(value, job, null);
19728
+ } else {
19729
+ expression = literal(value);
19730
+ }
19731
+ return expression;
19732
+ }
19733
+ var BINDING_KINDS = /* @__PURE__ */ new Map([
19734
+ [0, BindingKind.Property],
19735
+ [1, BindingKind.Attribute],
19736
+ [2, BindingKind.ClassName],
19737
+ [3, BindingKind.StyleProperty],
19738
+ [4, BindingKind.Animation]
19739
+ ]);
19258
19740
  function isPlainTemplate(tmpl) {
19259
19741
  var _a2;
19260
- return splitNsName((_a2 = tmpl.tagName) != null ? _a2 : "")[1] === "ng-template";
19261
- }
19262
- function ingestBindings(unit, op, element2) {
19263
- let flags = BindingFlags.None;
19264
- if (element2 instanceof Template) {
19265
- flags |= BindingFlags.OnNgTemplateElement;
19266
- if (element2 instanceof Template && isPlainTemplate(element2)) {
19267
- flags |= BindingFlags.BindingTargetsTemplate;
19268
- }
19269
- const templateAttrFlags = flags | BindingFlags.BindingTargetsTemplate | BindingFlags.IsStructuralTemplateAttribute;
19270
- for (const attr of element2.templateAttrs) {
19271
- if (attr instanceof TextAttribute) {
19272
- ingestBinding(unit, op.xref, attr.name, literal(attr.value), 1, null, SecurityContext.NONE, attr.sourceSpan, templateAttrFlags | BindingFlags.TextValue);
19273
- } else {
19274
- ingestBinding(unit, op.xref, attr.name, attr.value, attr.type, attr.unit, attr.securityContext, attr.sourceSpan, templateAttrFlags);
19275
- }
19276
- }
19742
+ return splitNsName((_a2 = tmpl.tagName) != null ? _a2 : "")[1] === NG_TEMPLATE_TAG_NAME;
19743
+ }
19744
+ function asMessage(i18nMeta) {
19745
+ if (i18nMeta == null) {
19746
+ return null;
19277
19747
  }
19748
+ if (!(i18nMeta instanceof Message)) {
19749
+ throw Error(`Expected i18n meta to be a Message, but got: ${i18nMeta.constructor.name}`);
19750
+ }
19751
+ return i18nMeta;
19752
+ }
19753
+ function ingestElementBindings(unit, op, element2) {
19754
+ var _a2;
19755
+ let bindings = new Array();
19278
19756
  for (const attr of element2.attributes) {
19279
- ingestBinding(unit, op.xref, attr.name, literal(attr.value), 1, null, SecurityContext.NONE, attr.sourceSpan, flags | BindingFlags.TextValue);
19757
+ const securityContext = domSchema.securityContext(element2.name, attr.name, true);
19758
+ bindings.push(createBindingOp(op.xref, BindingKind.Attribute, attr.name, convertAstWithInterpolation(unit.job, attr.value, attr.i18n), null, securityContext, true, false, null, asMessage(attr.i18n), attr.sourceSpan));
19280
19759
  }
19281
19760
  for (const input of element2.inputs) {
19282
- ingestBinding(unit, op.xref, input.name, input.value, input.type, input.unit, input.securityContext, input.sourceSpan, flags);
19761
+ bindings.push(createBindingOp(op.xref, BINDING_KINDS.get(input.type), input.name, convertAstWithInterpolation(unit.job, astOf(input.value), input.i18n), input.unit, input.securityContext, false, false, null, (_a2 = asMessage(input.i18n)) != null ? _a2 : null, input.sourceSpan));
19283
19762
  }
19763
+ unit.create.push(bindings.filter((b) => (b == null ? void 0 : b.kind) === OpKind.ExtractedAttribute));
19764
+ unit.update.push(bindings.filter((b) => (b == null ? void 0 : b.kind) === OpKind.Binding));
19284
19765
  for (const output of element2.outputs) {
19285
- let listenerOp;
19286
- if (output.type === 1) {
19287
- if (output.phase === null) {
19288
- throw Error("Animation listener should have a phase");
19289
- }
19290
- }
19291
- if (element2 instanceof Template && !isPlainTemplate(element2)) {
19292
- unit.create.push(createExtractedAttributeOp(op.xref, BindingKind.Property, output.name, null));
19293
- continue;
19294
- }
19295
- listenerOp = createListenerOp(op.xref, op.handle, output.name, op.tag, output.phase, false, output.sourceSpan);
19296
- let handlerExprs;
19297
- let handler = output.handler;
19298
- if (handler instanceof ASTWithSource) {
19299
- handler = handler.ast;
19766
+ if (output.type === 1 && output.phase === null) {
19767
+ throw Error("Animation listener should have a phase");
19300
19768
  }
19301
- if (handler instanceof Chain) {
19302
- handlerExprs = handler.expressions;
19769
+ unit.create.push(createListenerOp(op.xref, op.handle, output.name, op.tag, makeListenerHandlerOps(unit, output.handler, output.handlerSpan), output.phase, output.target, false, output.sourceSpan));
19770
+ }
19771
+ if (bindings.some((b) => b == null ? void 0 : b.i18nMessage) !== null) {
19772
+ unit.create.push(createI18nAttributesOp(unit.job.allocateXrefId(), new SlotHandle(), op.xref));
19773
+ }
19774
+ }
19775
+ function ingestTemplateBindings(unit, op, template2, templateKind) {
19776
+ let bindings = new Array();
19777
+ for (const attr of template2.templateAttrs) {
19778
+ if (attr instanceof TextAttribute) {
19779
+ const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, attr.name, true);
19780
+ bindings.push(createTemplateBinding(unit, op.xref, 1, attr.name, attr.value, null, securityContext, true, templateKind, asMessage(attr.i18n), attr.sourceSpan));
19303
19781
  } else {
19304
- handlerExprs = [handler];
19782
+ bindings.push(createTemplateBinding(unit, op.xref, attr.type, attr.name, astOf(attr.value), attr.unit, attr.securityContext, true, templateKind, asMessage(attr.i18n), attr.sourceSpan));
19783
+ }
19784
+ }
19785
+ for (const attr of template2.attributes) {
19786
+ const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, attr.name, true);
19787
+ bindings.push(createTemplateBinding(unit, op.xref, 1, attr.name, attr.value, null, securityContext, false, templateKind, asMessage(attr.i18n), attr.sourceSpan));
19788
+ }
19789
+ for (const input of template2.inputs) {
19790
+ bindings.push(createTemplateBinding(unit, op.xref, input.type, input.name, astOf(input.value), input.unit, input.securityContext, false, templateKind, asMessage(input.i18n), input.sourceSpan));
19791
+ }
19792
+ unit.create.push(bindings.filter((b) => (b == null ? void 0 : b.kind) === OpKind.ExtractedAttribute));
19793
+ unit.update.push(bindings.filter((b) => (b == null ? void 0 : b.kind) === OpKind.Binding));
19794
+ for (const output of template2.outputs) {
19795
+ if (output.type === 1 && output.phase === null) {
19796
+ throw Error("Animation listener should have a phase");
19305
19797
  }
19306
- if (handlerExprs.length === 0) {
19307
- throw new Error("Expected listener to have non-empty expression list.");
19798
+ if (templateKind === TemplateKind.NgTemplate) {
19799
+ unit.create.push(createListenerOp(op.xref, op.handle, output.name, op.tag, makeListenerHandlerOps(unit, output.handler, output.handlerSpan), output.phase, output.target, false, output.sourceSpan));
19308
19800
  }
19309
- const expressions = handlerExprs.map((expr) => convertAst(expr, unit.job, output.handlerSpan));
19310
- const returnExpr = expressions.pop();
19311
- for (const expr of expressions) {
19312
- const stmtOp = createStatementOp(new ExpressionStatement(expr, expr.sourceSpan));
19313
- listenerOp.handlerOps.push(stmtOp);
19801
+ if (templateKind === TemplateKind.Structural && output.type !== 1) {
19802
+ const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, output.name, false);
19803
+ unit.create.push(createExtractedAttributeOp(op.xref, BindingKind.Property, output.name, null, null, null, securityContext));
19314
19804
  }
19315
- listenerOp.handlerOps.push(createStatementOp(new ReturnStatement(returnExpr, returnExpr.sourceSpan)));
19316
- unit.create.push(listenerOp);
19805
+ }
19806
+ if (bindings.some((b) => b == null ? void 0 : b.i18nMessage) !== null) {
19807
+ unit.create.push(createI18nAttributesOp(unit.job.allocateXrefId(), new SlotHandle(), op.xref));
19317
19808
  }
19318
19809
  }
19319
- var BINDING_KINDS = /* @__PURE__ */ new Map([
19320
- [0, BindingKind.Property],
19321
- [1, BindingKind.Attribute],
19322
- [2, BindingKind.ClassName],
19323
- [3, BindingKind.StyleProperty],
19324
- [4, BindingKind.Animation]
19325
- ]);
19326
- var BindingFlags;
19327
- (function(BindingFlags2) {
19328
- BindingFlags2[BindingFlags2["None"] = 0] = "None";
19329
- BindingFlags2[BindingFlags2["TextValue"] = 1] = "TextValue";
19330
- BindingFlags2[BindingFlags2["BindingTargetsTemplate"] = 2] = "BindingTargetsTemplate";
19331
- BindingFlags2[BindingFlags2["IsStructuralTemplateAttribute"] = 4] = "IsStructuralTemplateAttribute";
19332
- BindingFlags2[BindingFlags2["OnNgTemplateElement"] = 8] = "OnNgTemplateElement";
19333
- })(BindingFlags || (BindingFlags = {}));
19334
- function ingestBinding(view, xref, name, value, type, unit, securityContext, sourceSpan, flags) {
19335
- if (value instanceof ASTWithSource) {
19336
- value = value.ast;
19810
+ function createTemplateBinding(view, xref, type, name, value, unit, securityContext, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan) {
19811
+ const isTextBinding = typeof value === "string";
19812
+ if (templateKind === TemplateKind.Structural) {
19813
+ if (!isStructuralTemplateAttribute && (type === 0 || type === 2 || type === 3)) {
19814
+ return createExtractedAttributeOp(xref, BindingKind.Property, name, null, null, i18nMessage, securityContext);
19815
+ }
19816
+ if (!isTextBinding && (type === 1 || type === 4)) {
19817
+ return null;
19818
+ }
19337
19819
  }
19338
- if (flags & BindingFlags.OnNgTemplateElement && !(flags & BindingFlags.BindingTargetsTemplate) && type === 0) {
19339
- view.create.push(createExtractedAttributeOp(xref, BindingKind.Property, name, null));
19340
- return;
19820
+ let bindingType = BINDING_KINDS.get(type);
19821
+ if (templateKind === TemplateKind.NgTemplate) {
19822
+ if (type === 2 || type === 3 || type === 1 && !isTextBinding) {
19823
+ bindingType = BindingKind.Property;
19824
+ }
19341
19825
  }
19342
- let expression;
19343
- if (value instanceof Interpolation) {
19344
- expression = new Interpolation2(value.strings, value.expressions.map((expr) => convertAst(expr, view.job, null)));
19345
- } else if (value instanceof AST) {
19346
- expression = convertAst(value, view.job, null);
19347
- } else {
19348
- expression = value;
19826
+ return createBindingOp(xref, bindingType, name, convertAstWithInterpolation(view.job, value, i18nMessage), unit, securityContext, isTextBinding, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan);
19827
+ }
19828
+ function makeListenerHandlerOps(unit, handler, handlerSpan) {
19829
+ handler = astOf(handler);
19830
+ const handlerOps = new Array();
19831
+ let handlerExprs = handler instanceof Chain ? handler.expressions : [handler];
19832
+ if (handlerExprs.length === 0) {
19833
+ throw new Error("Expected listener to have non-empty expression list.");
19349
19834
  }
19350
- const kind = BINDING_KINDS.get(type);
19351
- view.update.push(createBindingOp(xref, kind, name, expression, unit, securityContext, !!(flags & BindingFlags.TextValue), !!(flags & BindingFlags.IsStructuralTemplateAttribute), sourceSpan));
19835
+ const expressions = handlerExprs.map((expr) => convertAst(expr, unit.job, handlerSpan));
19836
+ const returnExpr = expressions.pop();
19837
+ handlerOps.push(...expressions.map((e) => createStatementOp(new ExpressionStatement(e, e.sourceSpan))));
19838
+ handlerOps.push(createStatementOp(new ReturnStatement(returnExpr, returnExpr.sourceSpan)));
19839
+ return handlerOps;
19840
+ }
19841
+ function astOf(ast) {
19842
+ return ast instanceof ASTWithSource ? ast.ast : ast;
19352
19843
  }
19353
19844
  function ingestReferences(op, element2) {
19354
19845
  assertIsArray(op.localRefs);
@@ -19388,10 +19879,11 @@ function ingestControlFlowInsertionPoint(unit, xref, node) {
19388
19879
  }
19389
19880
  if (root !== null) {
19390
19881
  for (const attr of root.attributes) {
19391
- ingestBinding(unit, xref, attr.name, literal(attr.value), 1, null, SecurityContext.NONE, attr.sourceSpan, BindingFlags.TextValue);
19882
+ const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, attr.name, true);
19883
+ unit.update.push(createBindingOp(xref, BindingKind.Attribute, attr.name, literal(attr.value), null, securityContext, true, false, null, asMessage(attr.i18n), attr.sourceSpan));
19392
19884
  }
19393
19885
  const tagName = root instanceof Element ? root.name : root.tagName;
19394
- return tagName === "ng-template" ? null : tagName;
19886
+ return tagName === NG_TEMPLATE_TAG_NAME ? null : tagName;
19395
19887
  }
19396
19888
  return null;
19397
19889
  }
@@ -21477,17 +21969,17 @@ function serializePlaceholderValue(value) {
21477
21969
  var NG_CONTENT_SELECT_ATTR2 = "select";
21478
21970
  var NG_PROJECT_AS_ATTR_NAME = "ngProjectAs";
21479
21971
  var EVENT_BINDING_SCOPE_GLOBALS = /* @__PURE__ */ new Set(["$event"]);
21480
- var NG_TEMPLATE_TAG_NAME = "ng-template";
21481
- var GLOBAL_TARGET_RESOLVERS = /* @__PURE__ */ new Map([["window", Identifiers.resolveWindow], ["document", Identifiers.resolveDocument], ["body", Identifiers.resolveBody]]);
21972
+ var NG_TEMPLATE_TAG_NAME2 = "ng-template";
21973
+ var GLOBAL_TARGET_RESOLVERS2 = /* @__PURE__ */ new Map([["window", Identifiers.resolveWindow], ["document", Identifiers.resolveDocument], ["body", Identifiers.resolveBody]]);
21482
21974
  var LEADING_TRIVIA_CHARS = [" ", "\n", "\r", " "];
21483
21975
  function renderFlagCheckIfStmt(flags, statements) {
21484
21976
  return ifStmt(variable(RENDER_FLAGS).bitwiseAnd(literal(flags), null, false), statements);
21485
21977
  }
21486
21978
  function prepareEventListenerParameters(eventAst, handlerName = null, scope = null) {
21487
21979
  const { type, name, target, phase, handler } = eventAst;
21488
- if (target && !GLOBAL_TARGET_RESOLVERS.has(target)) {
21980
+ if (target && !GLOBAL_TARGET_RESOLVERS2.has(target)) {
21489
21981
  throw new Error(`Unexpected global target '${target}' defined for '${name}' event.
21490
- Supported list of global targets: ${Array.from(GLOBAL_TARGET_RESOLVERS.keys())}.`);
21982
+ Supported list of global targets: ${Array.from(GLOBAL_TARGET_RESOLVERS2.keys())}.`);
21491
21983
  }
21492
21984
  const eventArgumentName = "$event";
21493
21985
  const implicitReceiverAccesses = /* @__PURE__ */ new Set();
@@ -21520,7 +22012,7 @@ function prepareEventListenerParameters(eventAst, handlerName = null, scope = nu
21520
22012
  if (target) {
21521
22013
  params.push(
21522
22014
  literal(false),
21523
- importExpr(GLOBAL_TARGET_RESOLVERS.get(target))
22015
+ importExpr(GLOBAL_TARGET_RESOLVERS2.get(target))
21524
22016
  );
21525
22017
  }
21526
22018
  return params;
@@ -22066,10 +22558,10 @@ var TemplateDefinitionBuilder = class {
22066
22558
  var _a2;
22067
22559
  const tagNameWithoutNamespace = template2.tagName ? splitNsName(template2.tagName)[1] : template2.tagName;
22068
22560
  const contextNameSuffix = template2.tagName ? "_" + sanitizeIdentifier(template2.tagName) : "";
22069
- const attrsExprs = this.getAttributeExpressions(NG_TEMPLATE_TAG_NAME, template2.attributes, template2.inputs, template2.outputs, void 0, template2.templateAttrs);
22561
+ const attrsExprs = this.getAttributeExpressions(NG_TEMPLATE_TAG_NAME2, template2.attributes, template2.inputs, template2.outputs, void 0, template2.templateAttrs);
22070
22562
  const templateIndex = this.createEmbeddedTemplateFn(tagNameWithoutNamespace, template2.children, contextNameSuffix, template2.sourceSpan, template2.variables, attrsExprs, template2.references, template2.i18n);
22071
22563
  this.templatePropertyBindings(templateIndex, template2.templateAttrs);
22072
- if (tagNameWithoutNamespace === NG_TEMPLATE_TAG_NAME) {
22564
+ if (tagNameWithoutNamespace === NG_TEMPLATE_TAG_NAME2) {
22073
22565
  const [i18nInputs, inputs] = partitionArray(template2.inputs, hasI18nMeta);
22074
22566
  if (i18nInputs.length > 0) {
22075
22567
  this.i18nAttributesInstruction(templateIndex, i18nInputs, (_a2 = template2.startSourceSpan) != null ? _a2 : template2.sourceSpan);
@@ -22310,8 +22802,8 @@ var TemplateDefinitionBuilder = class {
22310
22802
  }
22311
22803
  if (root !== null) {
22312
22804
  const name = root instanceof Element ? root.name : root.tagName;
22313
- tagName = name === NG_TEMPLATE_TAG_NAME ? null : name;
22314
- attrsExprs = this.getAttributeExpressions(NG_TEMPLATE_TAG_NAME, root.attributes, root.inputs, []);
22805
+ tagName = name === NG_TEMPLATE_TAG_NAME2 ? null : name;
22806
+ attrsExprs = this.getAttributeExpressions(NG_TEMPLATE_TAG_NAME2, root.attributes, root.inputs, []);
22315
22807
  }
22316
22808
  return { tagName, attrsExprs };
22317
22809
  }
@@ -23420,14 +23912,14 @@ function createBaseDirectiveTypeParams(meta) {
23420
23912
  function getInputsTypeExpression(meta) {
23421
23913
  return literalMap(Object.keys(meta.inputs).map((key) => {
23422
23914
  const value = meta.inputs[key];
23423
- return {
23424
- key,
23425
- value: literalMap([
23426
- { key: "alias", value: literal(value.bindingPropertyName), quoted: true },
23427
- { key: "required", value: literal(value.required), quoted: true }
23428
- ]),
23429
- quoted: true
23430
- };
23915
+ const values = [
23916
+ { key: "alias", value: literal(value.bindingPropertyName), quoted: true },
23917
+ { key: "required", value: literal(value.required), quoted: true }
23918
+ ];
23919
+ if (value.isSignal) {
23920
+ values.push({ key: "isSignal", value: literal(value.isSignal), quoted: true });
23921
+ }
23922
+ return { key, value: literalMap(values), quoted: true };
23431
23923
  }));
23432
23924
  }
23433
23925
  function createDirectiveType(meta) {
@@ -23471,6 +23963,7 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
23471
23963
  }
23472
23964
  const hostJob = ingestHostBinding({
23473
23965
  componentName: name,
23966
+ componentSelector: selector,
23474
23967
  properties: bindings,
23475
23968
  events: eventBindings,
23476
23969
  attributes: hostBindingsMetadata.attributes
@@ -23483,6 +23976,8 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
23483
23976
  }
23484
23977
  return emitHostBindingFunction(hostJob);
23485
23978
  }
23979
+ let bindingId = 0;
23980
+ const getNextBindingId = () => `${bindingId++}`;
23486
23981
  const bindingContext = variable(CONTEXT_NAME);
23487
23982
  const styleBuilder = new StylingBuilder(bindingContext);
23488
23983
  const { styleAttr, classAttr } = hostBindingsMetadata.specialAttributes;
@@ -23532,7 +24027,7 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
23532
24027
  const syntheticHostBindings = [];
23533
24028
  for (const binding of allOtherBindings) {
23534
24029
  const value = binding.expression.visit(getValueConverter());
23535
- const bindingExpr = bindingFn(bindingContext, value);
24030
+ const bindingExpr = bindingFn(bindingContext, value, getNextBindingId);
23536
24031
  const { bindingName, instruction, isAttribute } = getBindingNameAndInstruction(binding);
23537
24032
  const securityContexts = bindingParser.calcPossibleSecurityContexts(selector, bindingName, isAttribute).filter((context) => context !== SecurityContext.NONE);
23538
24033
  let sanitizerFn = null;
@@ -23577,9 +24072,11 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
23577
24072
  styleBuilder.buildUpdateLevelInstructions(getValueConverter()).forEach((instruction) => {
23578
24073
  for (const call2 of instruction.calls) {
23579
24074
  totalHostVarsCount += Math.max(call2.allocateBindingSlots - MIN_STYLING_BINDING_SLOTS_REQUIRED, 0);
24075
+ const { params, stmts } = convertStylingCall(call2, bindingContext, bindingFn, getNextBindingId);
24076
+ updateVariables.push(...stmts);
23580
24077
  updateInstructions.push({
23581
24078
  reference: instruction.reference,
23582
- paramsOrFn: convertStylingCall(call2, bindingContext, bindingFn),
24079
+ paramsOrFn: params,
23583
24080
  span: null
23584
24081
  });
23585
24082
  }
@@ -23601,11 +24098,19 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
23601
24098
  }
23602
24099
  return null;
23603
24100
  }
23604
- function bindingFn(implicit, value) {
23605
- return convertPropertyBinding(null, implicit, value, "b");
24101
+ function bindingFn(implicit, value, getNextBindingIdFn) {
24102
+ return convertPropertyBinding(null, implicit, value, getNextBindingIdFn());
23606
24103
  }
23607
- function convertStylingCall(call2, bindingContext, bindingFn2) {
23608
- return call2.params((value) => bindingFn2(bindingContext, value).currValExpr);
24104
+ function convertStylingCall(call2, bindingContext, bindingFn2, getNextBindingIdFn) {
24105
+ const stmts = [];
24106
+ const params = call2.params((value) => {
24107
+ const result = bindingFn2(bindingContext, value, getNextBindingIdFn);
24108
+ if (Array.isArray(result.stmts) && result.stmts.length > 0) {
24109
+ stmts.push(...result.stmts);
24110
+ }
24111
+ return result.currValExpr;
24112
+ });
24113
+ return { params, stmts };
23609
24114
  }
23610
24115
  function getBindingNameAndInstruction(binding) {
23611
24116
  let bindingName = binding.name;
@@ -24577,6 +25082,7 @@ function convertDirectiveFacadeToMetadata(facade) {
24577
25082
  bindingPropertyName: ann.alias || field,
24578
25083
  classPropertyName: field,
24579
25084
  required: ann.required || false,
25085
+ isSignal: false,
24580
25086
  transformFunction: ann.transform != null ? new WrappedNodeExpr(ann.transform) : null
24581
25087
  };
24582
25088
  } else if (isOutput(ann)) {
@@ -24607,7 +25113,7 @@ function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
24607
25113
  type: wrapReference(declaration.type),
24608
25114
  typeSourceSpan,
24609
25115
  selector: (_a2 = declaration.selector) != null ? _a2 : null,
24610
- inputs: declaration.inputs ? inputsMappingToInputMetadata(declaration.inputs) : {},
25116
+ inputs: declaration.inputs ? inputsPartialMetadataToInputMetadata(declaration.inputs) : {},
24611
25117
  outputs: (_b2 = declaration.outputs) != null ? _b2 : {},
24612
25118
  host: convertHostDeclarationToMetadata(declaration.host),
24613
25119
  queries: ((_c2 = declaration.queries) != null ? _c2 : []).map(convertQueryDeclarationToMetadata),
@@ -24835,27 +25341,41 @@ function isInput(value) {
24835
25341
  function isOutput(value) {
24836
25342
  return value.ngMetadataName === "Output";
24837
25343
  }
24838
- function inputsMappingToInputMetadata(inputs) {
24839
- return Object.keys(inputs).reduce((result, key) => {
24840
- const value = inputs[key];
24841
- if (typeof value === "string") {
24842
- result[key] = {
24843
- bindingPropertyName: value,
24844
- classPropertyName: value,
24845
- transformFunction: null,
24846
- required: false
24847
- };
25344
+ function inputsPartialMetadataToInputMetadata(inputs) {
25345
+ return Object.keys(inputs).reduce((result, minifiedClassName) => {
25346
+ const value = inputs[minifiedClassName];
25347
+ if (typeof value === "string" || Array.isArray(value)) {
25348
+ result[minifiedClassName] = parseLegacyInputPartialOutput(value);
24848
25349
  } else {
24849
- result[key] = {
24850
- bindingPropertyName: value[0],
24851
- classPropertyName: value[1],
24852
- transformFunction: value[2] ? new WrappedNodeExpr(value[2]) : null,
24853
- required: false
25350
+ result[minifiedClassName] = {
25351
+ bindingPropertyName: value.publicName,
25352
+ classPropertyName: minifiedClassName,
25353
+ transformFunction: value.transformFunction !== null ? new WrappedNodeExpr(value.transformFunction) : null,
25354
+ required: value.isRequired,
25355
+ isSignal: value.isSignal
24854
25356
  };
24855
25357
  }
24856
25358
  return result;
24857
25359
  }, {});
24858
25360
  }
25361
+ function parseLegacyInputPartialOutput(value) {
25362
+ if (typeof value === "string") {
25363
+ return {
25364
+ bindingPropertyName: value,
25365
+ classPropertyName: value,
25366
+ transformFunction: null,
25367
+ required: false,
25368
+ isSignal: false
25369
+ };
25370
+ }
25371
+ return {
25372
+ bindingPropertyName: value[0],
25373
+ classPropertyName: value[1],
25374
+ transformFunction: value[2] ? new WrappedNodeExpr(value[2]) : null,
25375
+ required: false,
25376
+ isSignal: false
25377
+ };
25378
+ }
24859
25379
  function parseInputsArray(values) {
24860
25380
  return values.reduce((results, value) => {
24861
25381
  if (typeof value === "string") {
@@ -24864,6 +25384,7 @@ function parseInputsArray(values) {
24864
25384
  bindingPropertyName,
24865
25385
  classPropertyName,
24866
25386
  required: false,
25387
+ isSignal: false,
24867
25388
  transformFunction: null
24868
25389
  };
24869
25390
  } else {
@@ -24871,6 +25392,7 @@ function parseInputsArray(values) {
24871
25392
  bindingPropertyName: value.alias || value.name,
24872
25393
  classPropertyName: value.name,
24873
25394
  required: value.required || false,
25395
+ isSignal: false,
24874
25396
  transformFunction: value.transform != null ? new WrappedNodeExpr(value.transform) : null
24875
25397
  };
24876
25398
  }
@@ -24914,7 +25436,7 @@ function publishFacade(global) {
24914
25436
  }
24915
25437
 
24916
25438
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/version.mjs
24917
- var VERSION2 = new Version("17.1.0-next.2");
25439
+ var VERSION2 = new Version("17.1.0-next.4");
24918
25440
 
24919
25441
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
24920
25442
  var _VisitorMode;
@@ -24964,6 +25486,10 @@ var boundngifelse = "[ngIfElse]";
24964
25486
  var boundngifthenelse = "[ngIfThenElse]";
24965
25487
  var boundngifthen = "[ngIfThen]";
24966
25488
  var nakedngfor = "ngFor";
25489
+ var startMarker = "\u25EC";
25490
+ var endMarker = "\u2722";
25491
+ var startI18nMarker = "\u2688";
25492
+ var endI18nMarker = "\u2689";
24967
25493
  function allFormsOf(selector) {
24968
25494
  return [
24969
25495
  selector,
@@ -25005,12 +25531,13 @@ var commonModulePipes = [
25005
25531
  "titlecase"
25006
25532
  ].map((name) => pipeMatchRegExpFor(name));
25007
25533
  var ElementToMigrate = class {
25008
- constructor(el, attr, elseAttr = void 0, thenAttr = void 0, forAttrs = void 0) {
25534
+ constructor(el, attr, elseAttr = void 0, thenAttr = void 0, forAttrs = void 0, aliasAttrs = void 0) {
25009
25535
  __publicField(this, "el");
25010
25536
  __publicField(this, "attr");
25011
25537
  __publicField(this, "elseAttr");
25012
25538
  __publicField(this, "thenAttr");
25013
25539
  __publicField(this, "forAttrs");
25540
+ __publicField(this, "aliasAttrs");
25014
25541
  __publicField(this, "nestCount", 0);
25015
25542
  __publicField(this, "hasLineBreaks", false);
25016
25543
  this.el = el;
@@ -25018,6 +25545,7 @@ var ElementToMigrate = class {
25018
25545
  this.elseAttr = elseAttr;
25019
25546
  this.thenAttr = thenAttr;
25020
25547
  this.forAttrs = forAttrs;
25548
+ this.aliasAttrs = aliasAttrs;
25021
25549
  }
25022
25550
  getCondition() {
25023
25551
  const chunks = this.attr.value.split(";");
@@ -25035,7 +25563,11 @@ var ElementToMigrate = class {
25035
25563
  getTemplateName(targetStr, secondStr) {
25036
25564
  const targetLocation = this.attr.value.indexOf(targetStr);
25037
25565
  const secondTargetLocation = secondStr ? this.attr.value.indexOf(secondStr) : void 0;
25038
- return this.attr.value.slice(targetLocation + targetStr.length, secondTargetLocation).replace(":", "").trim().split(";")[0].trim();
25566
+ let templateName = this.attr.value.slice(targetLocation + targetStr.length, secondTargetLocation);
25567
+ if (templateName.startsWith(":")) {
25568
+ templateName = templateName.slice(1).trim();
25569
+ }
25570
+ return templateName.split(";")[0].trim();
25039
25571
  }
25040
25572
  getValueEnd(offset) {
25041
25573
  return (this.attr.valueSpan ? this.attr.valueSpan.end.offset + 1 : this.attr.keySpan.end.offset) - offset;
@@ -25110,6 +25642,7 @@ var AnalyzedFile = class {
25110
25642
  constructor() {
25111
25643
  __publicField(this, "ranges", []);
25112
25644
  __publicField(this, "removeCommonModule", false);
25645
+ __publicField(this, "canRemoveImports", false);
25113
25646
  __publicField(this, "sourceFilePath", "");
25114
25647
  }
25115
25648
  getSortedRanges() {
@@ -25157,6 +25690,18 @@ var CommonCollector = class extends RecursiveVisitor {
25157
25690
  return commonModulePipes.some((regexp) => regexp.test(input));
25158
25691
  }
25159
25692
  };
25693
+ var i18nCollector = class extends RecursiveVisitor {
25694
+ constructor() {
25695
+ super(...arguments);
25696
+ __publicField(this, "elements", []);
25697
+ }
25698
+ visitElement(el) {
25699
+ if (el.attrs.find((a) => a.name === "i18n") !== void 0) {
25700
+ this.elements.push(el);
25701
+ }
25702
+ super.visitElement(el, null);
25703
+ }
25704
+ };
25160
25705
  var ElementCollector = class extends RecursiveVisitor {
25161
25706
  constructor(_attributes = []) {
25162
25707
  super();
@@ -25171,15 +25716,14 @@ var ElementCollector = class extends RecursiveVisitor {
25171
25716
  const elseAttr = el.attrs.find((x) => x.name === boundngifelse);
25172
25717
  const thenAttr = el.attrs.find((x) => x.name === boundngifthenelse || x.name === boundngifthen);
25173
25718
  const forAttrs = attr.name === nakedngfor ? this.getForAttrs(el) : void 0;
25174
- this.elements.push(new ElementToMigrate(el, attr, elseAttr, thenAttr, forAttrs));
25719
+ const aliasAttrs = this.getAliasAttrs(el);
25720
+ this.elements.push(new ElementToMigrate(el, attr, elseAttr, thenAttr, forAttrs, aliasAttrs));
25175
25721
  }
25176
25722
  }
25177
25723
  }
25178
25724
  super.visitElement(el, null);
25179
25725
  }
25180
25726
  getForAttrs(el) {
25181
- const aliases = /* @__PURE__ */ new Map();
25182
- let item = "";
25183
25727
  let trackBy = "";
25184
25728
  let forOf = "";
25185
25729
  for (const attr of el.attrs) {
@@ -25189,6 +25733,13 @@ var ElementCollector = class extends RecursiveVisitor {
25189
25733
  if (attr.name === "[ngForOf]") {
25190
25734
  forOf = attr.value;
25191
25735
  }
25736
+ }
25737
+ return { forOf, trackBy };
25738
+ }
25739
+ getAliasAttrs(el) {
25740
+ const aliases = /* @__PURE__ */ new Map();
25741
+ let item = "";
25742
+ for (const attr of el.attrs) {
25192
25743
  if (attr.name.startsWith("let-")) {
25193
25744
  if (attr.value === "") {
25194
25745
  item = attr.name.replace("let-", "");
@@ -25197,7 +25748,7 @@ var ElementCollector = class extends RecursiveVisitor {
25197
25748
  }
25198
25749
  }
25199
25750
  }
25200
- return { forOf, trackBy, item, aliases };
25751
+ return { item, aliases };
25201
25752
  }
25202
25753
  };
25203
25754
  var TemplateCollector = class extends RecursiveVisitor {
@@ -25244,6 +25795,11 @@ var importRemovals = [
25244
25795
  "NgSwitchDefault"
25245
25796
  ];
25246
25797
  var importWithCommonRemovals = [...importRemovals, "CommonModule"];
25798
+ var startMarkerRegex = new RegExp(startMarker, "gm");
25799
+ var endMarkerRegex = new RegExp(endMarker, "gm");
25800
+ var startI18nMarkerRegex = new RegExp(startI18nMarker, "gm");
25801
+ var endI18nMarkerRegex = new RegExp(endI18nMarker, "gm");
25802
+ var replaceMarkerRegex = new RegExp(`${startMarker}|${endMarker}`, "gm");
25247
25803
  function analyze(sourceFile, analyzedFiles) {
25248
25804
  forEachClass(sourceFile, (node) => {
25249
25805
  if (import_typescript5.default.isClassDeclaration(node)) {
@@ -25281,9 +25837,7 @@ function updateImportClause(clause, removeCommonModule) {
25281
25837
  return clause;
25282
25838
  }
25283
25839
  function updateClassImports(propAssignment, removeCommonModule) {
25284
- const printer = import_typescript5.default.createPrinter({
25285
- removeComments: true
25286
- });
25840
+ const printer = import_typescript5.default.createPrinter();
25287
25841
  const importList = propAssignment.initializer;
25288
25842
  const removals = removeCommonModule ? importWithCommonRemovals : importRemovals;
25289
25843
  const elements = importList.elements.filter((el) => !removals.includes(el.getText()));
@@ -25366,12 +25920,13 @@ function parseTemplate2(template2) {
25366
25920
  preserveLineEndings: true
25367
25921
  });
25368
25922
  if (parsed.errors && parsed.errors.length > 0) {
25369
- return null;
25923
+ const errors = parsed.errors.map((e) => ({ type: "parse", error: e }));
25924
+ return { tree: void 0, errors };
25370
25925
  }
25371
25926
  } catch (e) {
25372
- return null;
25927
+ return { tree: void 0, errors: [{ type: "parse", error: e }] };
25373
25928
  }
25374
- return parsed;
25929
+ return { tree: parsed, errors: [] };
25375
25930
  }
25376
25931
  function calculateNesting(visitor, hasLineBreaks2) {
25377
25932
  let nestedQueue = [];
@@ -25408,12 +25963,12 @@ function reduceNestingOffset(el, nestLevel, offset, postOffsets) {
25408
25963
  function getTemplates(template2) {
25409
25964
  var _a2;
25410
25965
  const parsed = parseTemplate2(template2);
25411
- if (parsed !== null) {
25966
+ if (parsed.tree !== void 0) {
25412
25967
  const visitor = new TemplateCollector();
25413
- visitAll2(visitor, parsed.rootNodes);
25968
+ visitAll2(visitor, parsed.tree.rootNodes);
25414
25969
  for (let [key, tmpl] of visitor.templates) {
25415
25970
  const escapeKey = escapeRegExp(key.slice(1));
25416
- const regex = new RegExp(`[^a-zA-Z0-9-<']${escapeKey}\\W`, "gm");
25971
+ const regex = new RegExp(`[^a-zA-Z0-9-<(']${escapeKey}\\W`, "gm");
25417
25972
  const matches = template2.match(regex);
25418
25973
  tmpl.count = (_a2 = matches == null ? void 0 : matches.length) != null ? _a2 : 0;
25419
25974
  tmpl.generateContents(template2);
@@ -25422,6 +25977,13 @@ function getTemplates(template2) {
25422
25977
  }
25423
25978
  return /* @__PURE__ */ new Map();
25424
25979
  }
25980
+ function updateTemplates(template2, templates) {
25981
+ const updatedTemplates = getTemplates(template2);
25982
+ for (let [key, tmpl] of updatedTemplates) {
25983
+ templates.set(key, tmpl);
25984
+ }
25985
+ return templates;
25986
+ }
25425
25987
  function wrapIntoI18nContainer(i18nAttr, content) {
25426
25988
  const { start, middle, end } = generatei18nContainer(i18nAttr, content);
25427
25989
  return `${start}${middle}${end}`;
@@ -25434,8 +25996,8 @@ function processNgTemplates(template2) {
25434
25996
  try {
25435
25997
  const templates = getTemplates(template2);
25436
25998
  for (const [name, t] of templates) {
25437
- const replaceRegex = new RegExp(`${name}\\|`, "g");
25438
- const forRegex = new RegExp(`${name}\\#`, "g");
25999
+ const replaceRegex = new RegExp(`\u03B8${name.slice(1)}\\\u03B4`, "g");
26000
+ const forRegex = new RegExp(`\u03B8${name.slice(1)}\\\u03C6`, "g");
25439
26001
  const forMatches = [...template2.matchAll(forRegex)];
25440
26002
  const matches = [...forMatches, ...template2.matchAll(replaceRegex)];
25441
26003
  let safeToRemove = true;
@@ -25456,21 +26018,33 @@ function processNgTemplates(template2) {
25456
26018
  template2 = template2.replace(replaceRegex, t.children);
25457
26019
  }
25458
26020
  if (t.count === matches.length + 1 && safeToRemove) {
25459
- template2 = template2.replace(t.contents, "");
26021
+ template2 = template2.replace(t.contents, `${startMarker}${endMarker}`);
25460
26022
  }
26023
+ updateTemplates(template2, templates);
25461
26024
  }
25462
26025
  }
26026
+ template2 = replaceRemainingPlaceholders(template2);
25463
26027
  return { migrated: template2, err: void 0 };
25464
26028
  } catch (err) {
25465
26029
  return { migrated: template2, err };
25466
26030
  }
25467
26031
  }
26032
+ function replaceRemainingPlaceholders(template2) {
26033
+ const replaceRegex = new RegExp(`\u03B8.*\u03B4`, "g");
26034
+ const placeholders = [...template2.matchAll(replaceRegex)];
26035
+ for (let ph of placeholders) {
26036
+ const placeholder = ph[0];
26037
+ const name = placeholder.slice(1, placeholder.length - 1);
26038
+ template2 = template2.replace(placeholder, `<ng-template [ngTemplateOutlet]="${name}"></ng-template>`);
26039
+ }
26040
+ return template2;
26041
+ }
25468
26042
  function canRemoveCommonModule(template2) {
25469
26043
  const parsed = parseTemplate2(template2);
25470
26044
  let removeCommonModule = false;
25471
- if (parsed !== null) {
26045
+ if (parsed.tree !== void 0) {
25472
26046
  const visitor = new CommonCollector();
25473
- visitAll2(visitor, parsed.rootNodes);
26047
+ visitAll2(visitor, parsed.tree.rootNodes);
25474
26048
  removeCommonModule = visitor.count === 0;
25475
26049
  }
25476
26050
  return removeCommonModule;
@@ -25491,16 +26065,46 @@ function getOriginals(etm, tmpl, offset) {
25491
26065
  const start2 = tmpl.slice(etm.el.sourceSpan.start.offset - offset, etm.el.children[0].sourceSpan.start.offset - offset);
25492
26066
  const end = tmpl.slice(etm.el.children[etm.el.children.length - 1].sourceSpan.end.offset - offset, etm.el.sourceSpan.end.offset - offset);
25493
26067
  const childLength = childEnd - childStart;
25494
- return { start: start2, end, childLength };
26068
+ return {
26069
+ start: start2,
26070
+ end,
26071
+ childLength,
26072
+ children: getOriginalChildren(etm.el.children, tmpl, offset),
26073
+ childNodes: etm.el.children
26074
+ };
25495
26075
  }
25496
26076
  const start = tmpl.slice(etm.el.sourceSpan.start.offset - offset, etm.el.sourceSpan.end.offset - offset);
25497
- return { start, end: "", childLength: 0 };
26077
+ return { start, end: "", childLength: 0, children: [], childNodes: [] };
26078
+ }
26079
+ function getOriginalChildren(children, tmpl, offset) {
26080
+ return children.map((child) => {
26081
+ return tmpl.slice(child.sourceSpan.start.offset - offset, child.sourceSpan.end.offset - offset);
26082
+ });
25498
26083
  }
25499
26084
  function isI18nTemplate(etm, i18nAttr) {
25500
- return etm.el.name === "ng-template" && i18nAttr !== void 0 && (etm.el.attrs.length === 2 || etm.el.attrs.length === 3 && etm.elseAttr !== void 0);
26085
+ let attrCount = countAttributes(etm);
26086
+ const safeToRemove = etm.el.attrs.length === attrCount + (i18nAttr !== void 0 ? 1 : 0);
26087
+ return etm.el.name === "ng-template" && i18nAttr !== void 0 && safeToRemove;
25501
26088
  }
25502
26089
  function isRemovableContainer(etm) {
25503
- return (etm.el.name === "ng-container" || etm.el.name === "ng-template") && (etm.el.attrs.length === 1 || etm.forAttrs !== void 0 || etm.el.attrs.length === 2 && etm.elseAttr !== void 0 || etm.el.attrs.length === 3 && etm.elseAttr !== void 0 && etm.thenAttr !== void 0);
26090
+ let attrCount = countAttributes(etm);
26091
+ const safeToRemove = etm.el.attrs.length === attrCount;
26092
+ return (etm.el.name === "ng-container" || etm.el.name === "ng-template") && safeToRemove;
26093
+ }
26094
+ function countAttributes(etm) {
26095
+ var _a2, _b2, _c2, _d2, _e2;
26096
+ let attrCount = 1;
26097
+ if (etm.elseAttr !== void 0) {
26098
+ attrCount++;
26099
+ }
26100
+ if (etm.thenAttr !== void 0) {
26101
+ attrCount++;
26102
+ }
26103
+ attrCount += (_b2 = (_a2 = etm.aliasAttrs) == null ? void 0 : _a2.aliases.size) != null ? _b2 : 0;
26104
+ attrCount += ((_c2 = etm.aliasAttrs) == null ? void 0 : _c2.item) ? 1 : 0;
26105
+ attrCount += ((_d2 = etm.forAttrs) == null ? void 0 : _d2.trackBy) ? 1 : 0;
26106
+ attrCount += ((_e2 = etm.forAttrs) == null ? void 0 : _e2.forOf) ? 1 : 0;
26107
+ return attrCount;
25504
26108
  }
25505
26109
  function getMainBlock(etm, tmpl, offset) {
25506
26110
  const i18nAttr = etm.el.attrs.find((x) => x.name === "i18n");
@@ -25509,6 +26113,8 @@ function getMainBlock(etm, tmpl, offset) {
25509
26113
  if (etm.hasChildren()) {
25510
26114
  const { childStart: childStart2, childEnd: childEnd2 } = etm.getChildSpan(offset);
25511
26115
  middle2 = tmpl.slice(childStart2, childEnd2);
26116
+ } else {
26117
+ middle2 = startMarker + endMarker;
25512
26118
  }
25513
26119
  return { start: "", middle: middle2, end: "" };
25514
26120
  } else if (isI18nTemplate(etm, i18nAttr)) {
@@ -25519,16 +26125,37 @@ function getMainBlock(etm, tmpl, offset) {
25519
26125
  const valEnd = etm.getValueEnd(offset);
25520
26126
  const { childStart, childEnd } = etm.hasChildren() ? etm.getChildSpan(offset) : { childStart: valEnd, childEnd: valEnd };
25521
26127
  let start = tmpl.slice(etm.start(offset), attrStart) + tmpl.slice(valEnd, childStart);
26128
+ const middle = tmpl.slice(childStart, childEnd);
26129
+ let end = tmpl.slice(childEnd, etm.end(offset));
25522
26130
  if (etm.shouldRemoveElseAttr()) {
25523
26131
  start = start.replace(etm.getElseAttrStr(), "");
26132
+ end = end.replace(etm.getElseAttrStr(), "");
25524
26133
  }
25525
- const middle = tmpl.slice(childStart, childEnd);
25526
- const end = tmpl.slice(childEnd, etm.end(offset));
25527
26134
  return { start, middle, end };
25528
26135
  }
26136
+ function generateI18nMarkers(tmpl) {
26137
+ let parsed = parseTemplate2(tmpl);
26138
+ if (parsed.tree !== void 0) {
26139
+ const visitor = new i18nCollector();
26140
+ visitAll2(visitor, parsed.tree.rootNodes);
26141
+ for (const [ix, el] of visitor.elements.entries()) {
26142
+ const offset = ix * 2;
26143
+ if (el.children.length > 0) {
26144
+ tmpl = addI18nMarkers(tmpl, el, offset);
26145
+ }
26146
+ }
26147
+ }
26148
+ return tmpl;
26149
+ }
26150
+ function addI18nMarkers(tmpl, el, offset) {
26151
+ const startPos = el.children[0].sourceSpan.start.offset + offset;
26152
+ const endPos = el.children[el.children.length - 1].sourceSpan.end.offset + offset;
26153
+ return tmpl.slice(0, startPos) + startI18nMarker + tmpl.slice(startPos, endPos) + endI18nMarker + tmpl.slice(endPos);
26154
+ }
25529
26155
  var selfClosingList = "input|br|img|base|wbr|area|col|embed|hr|link|meta|param|source|track";
25530
26156
  function formatTemplate(tmpl, templateType) {
25531
26157
  if (tmpl.indexOf("\n") > -1) {
26158
+ tmpl = generateI18nMarkers(tmpl);
25532
26159
  let openSelfClosingEl = false;
25533
26160
  const openBlockRegex = /^\s*\@(if|switch|case|default|for)|^\s*\}\s\@else/;
25534
26161
  const openElRegex = /^\s*<([a-z0-9]+)(?![^>]*\/>)[^>]*>?/;
@@ -25543,8 +26170,20 @@ function formatTemplate(tmpl, templateType) {
25543
26170
  const formatted = [];
25544
26171
  let indent = "";
25545
26172
  let mindent = "";
26173
+ let depth = 0;
26174
+ let i18nDepth = 0;
26175
+ let inMigratedBlock = false;
26176
+ let inI18nBlock = false;
25546
26177
  for (let [index, line] of lines.entries()) {
25547
- if (line.trim() === "" && index !== 0 && index !== lines.length - 1) {
26178
+ depth += [...line.matchAll(startMarkerRegex)].length - [...line.matchAll(endMarkerRegex)].length;
26179
+ inMigratedBlock = depth > 0;
26180
+ i18nDepth += [...line.matchAll(startI18nMarkerRegex)].length - [...line.matchAll(endI18nMarkerRegex)].length;
26181
+ let lineWasMigrated = false;
26182
+ if (line.match(replaceMarkerRegex)) {
26183
+ line = line.replace(replaceMarkerRegex, "");
26184
+ lineWasMigrated = true;
26185
+ }
26186
+ if (line.trim() === "" && index !== 0 && index !== lines.length - 1 && (inMigratedBlock || lineWasMigrated)) {
25548
26187
  continue;
25549
26188
  }
25550
26189
  if (templateType === "template" && index <= 1) {
@@ -25554,7 +26193,8 @@ function formatTemplate(tmpl, templateType) {
25554
26193
  if ((closeBlockRegex.test(line) || closeElRegex.test(line) && (!singleLineElRegex.test(line) && !closeMultiLineElRegex.test(line))) && indent !== "") {
25555
26194
  indent = indent.slice(2);
25556
26195
  }
25557
- formatted.push(mindent + indent + line.trim());
26196
+ const newLine = inI18nBlock ? line : mindent + (line.trim() !== "" ? indent : "") + line.trim();
26197
+ formatted.push(newLine);
25558
26198
  if (closeMultiLineElRegex.test(line)) {
25559
26199
  indent = indent.slice(2);
25560
26200
  if (openSelfClosingEl) {
@@ -25572,6 +26212,7 @@ function formatTemplate(tmpl, templateType) {
25572
26212
  openSelfClosingEl = true;
25573
26213
  indent += " ";
25574
26214
  }
26215
+ inI18nBlock = i18nDepth > 0;
25575
26216
  }
25576
26217
  tmpl = formatted.join("\n");
25577
26218
  }
@@ -25602,12 +26243,12 @@ var cases = [
25602
26243
  function migrateCase(template2) {
25603
26244
  let errors = [];
25604
26245
  let parsed = parseTemplate2(template2);
25605
- if (parsed === null) {
26246
+ if (parsed.tree === void 0) {
25606
26247
  return { migrated: template2, errors, changed: false };
25607
26248
  }
25608
26249
  let result = template2;
25609
26250
  const visitor = new ElementCollector(cases);
25610
- visitAll2(visitor, parsed.rootNodes);
26251
+ visitAll2(visitor, parsed.tree.rootNodes);
25611
26252
  calculateNesting(visitor, hasLineBreaks(template2));
25612
26253
  let offset = 0;
25613
26254
  let nestLevel = -1;
@@ -25642,8 +26283,8 @@ function migrateNgSwitchCase(etm, tmpl, offset) {
25642
26283
  const condition = etm.attr.value;
25643
26284
  const originals = getOriginals(etm, tmpl, offset);
25644
26285
  const { start, middle, end } = getMainBlock(etm, tmpl, offset);
25645
- const startBlock = `${leadingSpace}@case (${condition}) {${leadingSpace}${lbString}${start}`;
25646
- const endBlock = `${end}${lbString}${leadingSpace}}`;
26286
+ const startBlock = `${startMarker}${leadingSpace}@case (${condition}) {${leadingSpace}${lbString}${start}`;
26287
+ const endBlock = `${end}${lbString}${leadingSpace}}${endMarker}`;
25647
26288
  const defaultBlock = startBlock + middle + endBlock;
25648
26289
  const updatedTmpl = tmpl.slice(0, etm.start(offset)) + defaultBlock + tmpl.slice(etm.end(offset));
25649
26290
  const pre = originals.start.length - startBlock.length;
@@ -25655,8 +26296,8 @@ function migrateNgSwitchDefault(etm, tmpl, offset) {
25655
26296
  const leadingSpace = etm.hasLineBreaks ? "" : " ";
25656
26297
  const originals = getOriginals(etm, tmpl, offset);
25657
26298
  const { start, middle, end } = getMainBlock(etm, tmpl, offset);
25658
- const startBlock = `${leadingSpace}@default {${leadingSpace}${lbString}${start}`;
25659
- const endBlock = `${end}${lbString}${leadingSpace}}`;
26299
+ const startBlock = `${startMarker}${leadingSpace}@default {${leadingSpace}${lbString}${start}`;
26300
+ const endBlock = `${end}${lbString}${leadingSpace}}${endMarker}`;
25660
26301
  const defaultBlock = startBlock + middle + endBlock;
25661
26302
  const updatedTmpl = tmpl.slice(0, etm.start(offset)) + defaultBlock + tmpl.slice(etm.end(offset));
25662
26303
  const pre = originals.start.length - startBlock.length;
@@ -25683,12 +26324,12 @@ var stringPairs = /* @__PURE__ */ new Map([
25683
26324
  function migrateFor(template2) {
25684
26325
  let errors = [];
25685
26326
  let parsed = parseTemplate2(template2);
25686
- if (parsed === null) {
26327
+ if (parsed.tree === void 0) {
25687
26328
  return { migrated: template2, errors, changed: false };
25688
26329
  }
25689
26330
  let result = template2;
25690
26331
  const visitor = new ElementCollector(fors);
25691
- visitAll2(visitor, parsed.rootNodes);
26332
+ visitAll2(visitor, parsed.tree.rootNodes);
25692
26333
  calculateNesting(visitor, hasLineBreaks(template2));
25693
26334
  let offset = 0;
25694
26335
  let nestLevel = -1;
@@ -25738,7 +26379,7 @@ function migrateStandardNgFor(etm, tmpl, offset) {
25738
26379
  trackBy = `${trackByFn}($index, ${loopVar})`;
25739
26380
  }
25740
26381
  if (part.startsWith("template:")) {
25741
- tmplPlaceholder = `#${part.split(":")[1].trim()}#`;
26382
+ tmplPlaceholder = `\u03B8${part.split(":")[1].trim()}\u03C6`;
25742
26383
  }
25743
26384
  if (part.match(aliasWithEqualRegexp)) {
25744
26385
  const aliasParts = part.split("=");
@@ -25759,8 +26400,8 @@ function migrateStandardNgFor(etm, tmpl, offset) {
25759
26400
  trackBy = trackBy.replace("$index", aliasedIndex);
25760
26401
  }
25761
26402
  const aliasStr = aliases.length > 0 ? `;${aliases.join(";")}` : "";
25762
- let startBlock = `@for (${condition}; track ${trackBy}${aliasStr}) {${lbString}`;
25763
- let endBlock = `${lbString}}`;
26403
+ let startBlock = `${startMarker}@for (${condition}; track ${trackBy}${aliasStr}) {${lbString}`;
26404
+ let endBlock = `${lbString}}${endMarker}`;
25764
26405
  let forBlock = "";
25765
26406
  if (tmplPlaceholder !== "") {
25766
26407
  startBlock = startBlock + tmplPlaceholder;
@@ -25778,9 +26419,10 @@ function migrateStandardNgFor(etm, tmpl, offset) {
25778
26419
  }
25779
26420
  function migrateBoundNgFor(etm, tmpl, offset) {
25780
26421
  const forAttrs = etm.forAttrs;
25781
- const aliasMap = forAttrs.aliases;
26422
+ const aliasAttrs = etm.aliasAttrs;
26423
+ const aliasMap = aliasAttrs.aliases;
25782
26424
  const originals = getOriginals(etm, tmpl, offset);
25783
- const condition = `${forAttrs.item} of ${forAttrs.forOf}`;
26425
+ const condition = `${aliasAttrs.item} of ${forAttrs.forOf}`;
25784
26426
  const aliases = [];
25785
26427
  let aliasedIndex = "$index";
25786
26428
  for (const [key, val] of aliasMap) {
@@ -25790,15 +26432,15 @@ function migrateBoundNgFor(etm, tmpl, offset) {
25790
26432
  }
25791
26433
  }
25792
26434
  const aliasStr = aliases.length > 0 ? `;${aliases.join(";")}` : "";
25793
- let trackBy = forAttrs.item;
26435
+ let trackBy = aliasAttrs.item;
25794
26436
  if (forAttrs.trackBy !== "") {
25795
- trackBy = `${forAttrs.trackBy.trim()}(${aliasedIndex}, ${forAttrs.item})`;
26437
+ trackBy = `${forAttrs.trackBy.trim()}(${aliasedIndex}, ${aliasAttrs.item})`;
25796
26438
  }
25797
26439
  const { start, middle, end } = getMainBlock(etm, tmpl, offset);
25798
- const startBlock = `@for (${condition}; track ${trackBy}${aliasStr}) {
26440
+ const startBlock = `${startMarker}@for (${condition}; track ${trackBy}${aliasStr}) {
25799
26441
  ${start}`;
25800
26442
  const endBlock = `${end}
25801
- }`;
26443
+ }${endMarker}`;
25802
26444
  const forBlock = startBlock + middle + endBlock;
25803
26445
  const updatedTmpl = tmpl.slice(0, etm.start(offset)) + forBlock + tmpl.slice(etm.end(offset));
25804
26446
  const pre = originals.start.length - startBlock.length;
@@ -25849,12 +26491,12 @@ var ifs = [
25849
26491
  function migrateIf(template2) {
25850
26492
  let errors = [];
25851
26493
  let parsed = parseTemplate2(template2);
25852
- if (parsed === null) {
26494
+ if (parsed.tree === void 0) {
25853
26495
  return { migrated: template2, errors, changed: false };
25854
26496
  }
25855
26497
  let result = template2;
25856
26498
  const visitor = new ElementCollector(ifs);
25857
- visitAll2(visitor, parsed.rootNodes);
26499
+ visitAll2(visitor, parsed.tree.rootNodes);
25858
26500
  calculateNesting(visitor, hasLineBreaks(template2));
25859
26501
  let offset = 0;
25860
26502
  let nestLevel = -1;
@@ -25876,24 +26518,36 @@ function migrateIf(template2) {
25876
26518
  return { migrated: result, errors, changed };
25877
26519
  }
25878
26520
  function migrateNgIf(etm, tmpl, offset) {
25879
- const matchThen = etm.attr.value.match(/;?\s*then/gm);
25880
- const matchElse = etm.attr.value.match(/;?\s*else/gm);
26521
+ const matchThen = etm.attr.value.match(/[^\w\d];?\s*then/gm);
26522
+ const matchElse = etm.attr.value.match(/[^\w\d];?\s*else/gm);
25881
26523
  if (etm.thenAttr !== void 0 || etm.elseAttr !== void 0) {
25882
26524
  return buildBoundIfElseBlock(etm, tmpl, offset);
25883
- } else if (matchThen && matchThen.length > 0) {
26525
+ } else if (matchThen && matchThen.length > 0 && matchElse && matchElse.length > 0) {
25884
26526
  return buildStandardIfThenElseBlock(etm, tmpl, matchThen[0], matchElse[0], offset);
26527
+ } else if (matchThen && matchThen.length > 0) {
26528
+ return buildStandardIfThenBlock(etm, tmpl, matchThen[0], offset);
25885
26529
  } else if (matchElse && matchElse.length > 0) {
25886
26530
  return buildStandardIfElseBlock(etm, tmpl, matchElse[0], offset);
25887
26531
  }
25888
26532
  return buildIfBlock(etm, tmpl, offset);
25889
26533
  }
25890
26534
  function buildIfBlock(etm, tmpl, offset) {
26535
+ const aliasAttrs = etm.aliasAttrs;
26536
+ const aliases = [...aliasAttrs.aliases.keys()];
26537
+ if (aliasAttrs.item) {
26538
+ aliases.push(aliasAttrs.item);
26539
+ }
25891
26540
  const lbString = etm.hasLineBreaks ? "\n" : "";
25892
- const condition = etm.attr.value.replace(" as ", "; as ").replace(/;\s*let/g, "; as");
26541
+ let condition = etm.attr.value.replace(" as ", "; as ").replace(/;\s*let/g, "; as");
26542
+ if (aliases.length > 1 || aliases.length === 1 && condition.indexOf("; as") > -1) {
26543
+ throw new Error("Found more than one alias on your ngIf. Remove one of them and re-run the migration.");
26544
+ } else if (aliases.length === 1) {
26545
+ condition += `; as ${aliases[0]}`;
26546
+ }
25893
26547
  const originals = getOriginals(etm, tmpl, offset);
25894
26548
  const { start, middle, end } = getMainBlock(etm, tmpl, offset);
25895
- const startBlock = `@if (${condition}) {${lbString}${start}`;
25896
- const endBlock = `${end}${lbString}}`;
26549
+ const startBlock = `${startMarker}@if (${condition}) {${lbString}${start}`;
26550
+ const endBlock = `${end}${lbString}}${endMarker}`;
25897
26551
  const ifBlock = startBlock + middle + endBlock;
25898
26552
  const updatedTmpl = tmpl.slice(0, etm.start(offset)) + ifBlock + tmpl.slice(etm.end(offset));
25899
26553
  const pre = originals.start.length - startBlock.length;
@@ -25902,14 +26556,24 @@ function buildIfBlock(etm, tmpl, offset) {
25902
26556
  }
25903
26557
  function buildStandardIfElseBlock(etm, tmpl, elseString, offset) {
25904
26558
  const condition = etm.getCondition().replace(" as ", "; as ").replace(/;\s*let/g, "; as");
25905
- const elsePlaceholder = `#${etm.getTemplateName(elseString)}|`;
26559
+ const elsePlaceholder = `\u03B8${etm.getTemplateName(elseString)}\u03B4`;
25906
26560
  return buildIfElseBlock(etm, tmpl, condition, elsePlaceholder, offset);
25907
26561
  }
25908
26562
  function buildBoundIfElseBlock(etm, tmpl, offset) {
25909
- const condition = etm.attr.value.replace(" as ", "; as ");
25910
- const elsePlaceholder = `#${etm.elseAttr.value}|`;
26563
+ const aliasAttrs = etm.aliasAttrs;
26564
+ const aliases = [...aliasAttrs.aliases.keys()];
26565
+ if (aliasAttrs.item) {
26566
+ aliases.push(aliasAttrs.item);
26567
+ }
26568
+ let condition = etm.attr.value.replace(" as ", "; as ");
26569
+ if (aliases.length > 1 || aliases.length === 1 && condition.indexOf("; as") > -1) {
26570
+ throw new Error("Found more than one alias on your ngIf. Remove one of them and re-run the migration.");
26571
+ } else if (aliases.length === 1) {
26572
+ condition += `; as ${aliases[0]}`;
26573
+ }
26574
+ const elsePlaceholder = `\u03B8${etm.elseAttr.value.trim()}\u03B4`;
25911
26575
  if (etm.thenAttr !== void 0) {
25912
- const thenPlaceholder = `#${etm.thenAttr.value}|`;
26576
+ const thenPlaceholder = `\u03B8${etm.thenAttr.value.trim()}\u03B4`;
25913
26577
  return buildIfThenElseBlock(etm, tmpl, condition, thenPlaceholder, elsePlaceholder, offset);
25914
26578
  }
25915
26579
  return buildIfElseBlock(etm, tmpl, condition, elsePlaceholder, offset);
@@ -25918,9 +26582,9 @@ function buildIfElseBlock(etm, tmpl, condition, elsePlaceholder, offset) {
25918
26582
  const lbString = etm.hasLineBreaks ? "\n" : "";
25919
26583
  const originals = getOriginals(etm, tmpl, offset);
25920
26584
  const { start, middle, end } = getMainBlock(etm, tmpl, offset);
25921
- const startBlock = `@if (${condition}) {${lbString}${start}`;
26585
+ const startBlock = `${startMarker}@if (${condition}) {${lbString}${start}`;
25922
26586
  const elseBlock = `${end}${lbString}} @else {${lbString}`;
25923
- const postBlock = elseBlock + elsePlaceholder + `${lbString}}`;
26587
+ const postBlock = elseBlock + elsePlaceholder + `${lbString}}${endMarker}`;
25924
26588
  const ifElseBlock = startBlock + middle + postBlock;
25925
26589
  const tmplStart = tmpl.slice(0, etm.start(offset));
25926
26590
  const tmplEnd = tmpl.slice(etm.end(offset));
@@ -25931,16 +26595,21 @@ function buildIfElseBlock(etm, tmpl, condition, elsePlaceholder, offset) {
25931
26595
  }
25932
26596
  function buildStandardIfThenElseBlock(etm, tmpl, thenString, elseString, offset) {
25933
26597
  const condition = etm.getCondition().replace(" as ", "; as ").replace(/;\s*let/g, "; as");
25934
- const thenPlaceholder = `#${etm.getTemplateName(thenString, elseString)}|`;
25935
- const elsePlaceholder = `#${etm.getTemplateName(elseString)}|`;
26598
+ const thenPlaceholder = `\u03B8${etm.getTemplateName(thenString, elseString)}\u03B4`;
26599
+ const elsePlaceholder = `\u03B8${etm.getTemplateName(elseString)}\u03B4`;
25936
26600
  return buildIfThenElseBlock(etm, tmpl, condition, thenPlaceholder, elsePlaceholder, offset);
25937
26601
  }
26602
+ function buildStandardIfThenBlock(etm, tmpl, thenString, offset) {
26603
+ const condition = etm.getCondition().replace(" as ", "; as ").replace(/;\s*let/g, "; as");
26604
+ const thenPlaceholder = `\u03B8${etm.getTemplateName(thenString)}\u03B4`;
26605
+ return buildIfThenBlock(etm, tmpl, condition, thenPlaceholder, offset);
26606
+ }
25938
26607
  function buildIfThenElseBlock(etm, tmpl, condition, thenPlaceholder, elsePlaceholder, offset) {
25939
26608
  const lbString = etm.hasLineBreaks ? "\n" : "";
25940
26609
  const originals = getOriginals(etm, tmpl, offset);
25941
- const startBlock = `@if (${condition}) {${lbString}`;
26610
+ const startBlock = `${startMarker}@if (${condition}) {${lbString}`;
25942
26611
  const elseBlock = `${lbString}} @else {${lbString}`;
25943
- const postBlock = thenPlaceholder + elseBlock + elsePlaceholder + `${lbString}}`;
26612
+ const postBlock = thenPlaceholder + elseBlock + elsePlaceholder + `${lbString}}${endMarker}`;
25944
26613
  const ifThenElseBlock = startBlock + postBlock;
25945
26614
  const tmplStart = tmpl.slice(0, etm.start(offset));
25946
26615
  const tmplEnd = tmpl.slice(etm.end(offset));
@@ -25949,6 +26618,19 @@ function buildIfThenElseBlock(etm, tmpl, condition, thenPlaceholder, elsePlaceho
25949
26618
  const post = originals.end.length - postBlock.length;
25950
26619
  return { tmpl: updatedTmpl, offsets: { pre, post } };
25951
26620
  }
26621
+ function buildIfThenBlock(etm, tmpl, condition, thenPlaceholder, offset) {
26622
+ const lbString = etm.hasLineBreaks ? "\n" : "";
26623
+ const originals = getOriginals(etm, tmpl, offset);
26624
+ const startBlock = `${startMarker}@if (${condition}) {${lbString}`;
26625
+ const postBlock = thenPlaceholder + `${lbString}}${endMarker}`;
26626
+ const ifThenBlock = startBlock + postBlock;
26627
+ const tmplStart = tmpl.slice(0, etm.start(offset));
26628
+ const tmplEnd = tmpl.slice(etm.end(offset));
26629
+ const updatedTmpl = tmplStart + ifThenBlock + tmplEnd;
26630
+ const pre = originals.start.length + originals.childLength - startBlock.length;
26631
+ const post = originals.end.length - postBlock.length;
26632
+ return { tmpl: updatedTmpl, offsets: { pre, post } };
26633
+ }
25952
26634
 
25953
26635
  // bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/switches.mjs
25954
26636
  var ngswitch = "[ngSwitch]";
@@ -25958,12 +26640,12 @@ var switches = [
25958
26640
  function migrateSwitch(template2) {
25959
26641
  let errors = [];
25960
26642
  let parsed = parseTemplate2(template2);
25961
- if (parsed === null) {
26643
+ if (parsed.tree === void 0) {
25962
26644
  return { migrated: template2, errors, changed: false };
25963
26645
  }
25964
26646
  let result = template2;
25965
26647
  const visitor = new ElementCollector(switches);
25966
- visitAll2(visitor, parsed.rootNodes);
26648
+ visitAll2(visitor, parsed.tree.rootNodes);
25967
26649
  calculateNesting(visitor, hasLineBreaks(template2));
25968
26650
  let offset = 0;
25969
26651
  let nestLevel = -1;
@@ -25986,13 +26668,31 @@ function migrateSwitch(template2) {
25986
26668
  const changed = visitor.elements.length > 0;
25987
26669
  return { migrated: result, errors, changed };
25988
26670
  }
26671
+ function assertValidSwitchStructure(children) {
26672
+ for (const child of children) {
26673
+ if (child instanceof Text4 && child.value.trim() !== "") {
26674
+ throw new Error(`Text node: "${child.value}" would result in invalid migrated @switch block structure. @switch can only have @case or @default as children.`);
26675
+ } else if (child instanceof Element2) {
26676
+ let hasCase = false;
26677
+ for (const attr of child.attrs) {
26678
+ if (cases.includes(attr.name)) {
26679
+ hasCase = true;
26680
+ }
26681
+ }
26682
+ if (!hasCase) {
26683
+ throw new Error(`Element node: "${child.name}" would result in invalid migrated @switch block structure. @switch can only have @case or @default as children.`);
26684
+ }
26685
+ }
26686
+ }
26687
+ }
25989
26688
  function migrateNgSwitch(etm, tmpl, offset) {
25990
26689
  const lbString = etm.hasLineBreaks ? "\n" : "";
25991
26690
  const condition = etm.attr.value;
25992
26691
  const originals = getOriginals(etm, tmpl, offset);
26692
+ assertValidSwitchStructure(originals.childNodes);
25993
26693
  const { start, middle, end } = getMainBlock(etm, tmpl, offset);
25994
- const startBlock = `${start}${lbString}@switch (${condition}) {`;
25995
- const endBlock = `}${lbString}${end}`;
26694
+ const startBlock = `${startMarker}${start}${lbString}@switch (${condition}) {`;
26695
+ const endBlock = `}${lbString}${end}${endMarker}`;
25996
26696
  const switchBlock = startBlock + middle + endBlock;
25997
26697
  const updatedTmpl = tmpl.slice(0, etm.start(offset)) + switchBlock + tmpl.slice(etm.end(offset));
25998
26698
  const pre = originals.start.length - startBlock.length;
@@ -26008,6 +26708,9 @@ function migrateTemplate(template2, templateType, node, file, format = true, ana
26008
26708
  const ifResult = migrateIf(template2);
26009
26709
  const forResult = migrateFor(ifResult.migrated);
26010
26710
  const switchResult = migrateSwitch(forResult.migrated);
26711
+ if (switchResult.errors.length > 0) {
26712
+ return { migrated: template2, errors: switchResult.errors };
26713
+ }
26011
26714
  const caseResult = migrateCase(switchResult.migrated);
26012
26715
  const templateResult = processNgTemplates(caseResult.migrated);
26013
26716
  if (templateResult.err !== void 0) {
@@ -26015,13 +26718,27 @@ function migrateTemplate(template2, templateType, node, file, format = true, ana
26015
26718
  }
26016
26719
  migrated = templateResult.migrated;
26017
26720
  const changed = ifResult.changed || forResult.changed || switchResult.changed || caseResult.changed;
26721
+ 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] };
26729
+ }
26730
+ }
26018
26731
  if (format && changed) {
26019
26732
  migrated = formatTemplate(migrated, templateType);
26020
26733
  }
26734
+ const markerRegex = new RegExp(`${startMarker}|${endMarker}|${startI18nMarker}|${endI18nMarker}`, "gm");
26735
+ migrated = migrated.replace(markerRegex, "");
26021
26736
  file.removeCommonModule = canRemoveCommonModule(template2);
26737
+ file.canRemoveImports = true;
26022
26738
  if (templateType === "templateUrl" && analyzedFiles !== null && analyzedFiles.has(file.sourceFilePath)) {
26023
26739
  const componentFile = analyzedFiles.get(file.sourceFilePath);
26024
26740
  componentFile.removeCommonModule = file.removeCommonModule;
26741
+ componentFile.canRemoveImports = file.canRemoveImports;
26025
26742
  }
26026
26743
  errors = [
26027
26744
  ...ifResult.errors,
@@ -26029,7 +26746,7 @@ function migrateTemplate(template2, templateType, node, file, format = true, ana
26029
26746
  ...switchResult.errors,
26030
26747
  ...caseResult.errors
26031
26748
  ];
26032
- } else {
26749
+ } else if (file.canRemoveImports) {
26033
26750
  migrated = removeImports(template2, node, file.removeCommonModule);
26034
26751
  }
26035
26752
  return { migrated, errors };