@questwork/p-templates-model 0.1.0 → 0.1.2

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.
@@ -1,7 +1,7 @@
1
- import { TenantAwareEntity as Et, copySerializableProperties as w, copySerializableKeyValueObjects as Fe, Lifecycle as yt, TrackedEntity as Qe, EntityAction as Je, copySerializableValue as Ke } from "@questwork/q-utilities";
1
+ import { TenantAwareEntity as Et, copySerializableProperties as S, copySerializableKeyValueObjects as Fe, Lifecycle as yt, TrackedEntity as Qe, EntityAction as Je, copySerializableValue as Ke } from "@questwork/q-utilities";
2
2
  import { Liquid as gt, TypeGuards as A, Tokenizer as _t } from "liquidjs";
3
3
  import Ot from "juice/client";
4
- const Pe = 2, Ze = Object.freeze([2]), y = Object.freeze({
4
+ const we = 2, Ze = Object.freeze([2]), y = Object.freeze({
5
5
  BLOCK_CONTEXT_MISMATCH: "BLOCK_CONTEXT_MISMATCH",
6
6
  BLOCK_DEPRECATED: "BLOCK_DEPRECATED",
7
7
  BLOCK_ELEMENT_INVALID: "BLOCK_ELEMENT_INVALID",
@@ -27,40 +27,40 @@ const Pe = 2, Ze = Object.freeze([2]), y = Object.freeze({
27
27
  UNKNOWN_BLOCK: "UNKNOWN_BLOCK",
28
28
  UNKNOWN_FUNCTION: "UNKNOWN_FUNCTION",
29
29
  VARIABLE_INVALID: "VARIABLE_INVALID"
30
- }), H = Object.freeze({
30
+ }), X = Object.freeze({
31
31
  ERROR: "ERROR",
32
32
  WARNING: "WARNING"
33
- }), Ie = Object.freeze(["blank", "empty", "false", "forloop", "nil", "null", "params", "true"]), F = "params", Y = /^[A-Z_]\w*$/i, P = Object.freeze({
33
+ }), Ie = Object.freeze(["blank", "empty", "false", "forloop", "nil", "null", "params", "true"]), F = "params", Q = /^[A-Z_]\w*$/i, w = Object.freeze({
34
34
  BOOLEAN: "boolean",
35
35
  DATE: "date",
36
36
  LIST: "list",
37
37
  NUMBER: "number",
38
38
  OBJECT: "object",
39
39
  STRING: "string"
40
- }), Ct = /* @__PURE__ */ new Set([P.BOOLEAN, P.DATE, P.NUMBER, P.STRING]), ne = Symbol("templateProjectionNode"), At = 10;
40
+ }), Ct = /* @__PURE__ */ new Set([w.BOOLEAN, w.DATE, w.NUMBER, w.STRING]), re = Symbol("templateProjectionNode"), At = 10;
41
41
  class et {
42
42
  constructor({ projectionCode: e, label: n, description: r, fields: i } = {}) {
43
43
  if (!e || typeof e != "string")
44
44
  throw new TypeError("TemplateProjection requires a projectionCode.");
45
- Object.defineProperty(this, ne, {
45
+ Object.defineProperty(this, re, {
46
46
  enumerable: !1,
47
- value: ie({ description: r, fields: i, label: n, type: P.OBJECT }, e)
47
+ value: ie({ description: r, fields: i, label: n, type: w.OBJECT }, e)
48
48
  }), this.projectionCode = e, Object.freeze(this);
49
49
  }
50
50
  /** Serializable schema for editors and checks (no functions). */
51
51
  describe() {
52
- return se(this[ne]);
52
+ return se(this[re]);
53
53
  }
54
54
  /** Project a model (or plain object) onto plain data: declared fields plus the other values. */
55
55
  project(e) {
56
- return oe(this[ne], e);
56
+ return oe(this[re], e);
57
57
  }
58
58
  }
59
- function j(t) {
59
+ function B(t) {
60
60
  return new et(t);
61
61
  }
62
62
  function De(t, { label: e, description: n, value: r } = {}) {
63
- return { description: n, item: t, label: e, type: P.LIST, value: r };
63
+ return { description: n, item: t, label: e, type: w.LIST, value: r };
64
64
  }
65
65
  function Rt(t, e = "root") {
66
66
  return ie(t, e);
@@ -73,23 +73,23 @@ function St(t, e) {
73
73
  }
74
74
  function ie(t, e) {
75
75
  if (t instanceof et)
76
- return t[ne];
76
+ return t[re];
77
77
  if (!t || typeof t != "object")
78
78
  throw new TypeError(`Template field "${e}" must be an object definition.`);
79
79
  const { description: n, label: r, type: i, value: s } = t;
80
80
  if (s !== void 0 && typeof s != "function")
81
81
  throw new TypeError(`Template field "${e}" value must be a function.`);
82
82
  const o = { description: n, label: r, type: i, value: s };
83
- if (i === P.OBJECT)
83
+ if (i === w.OBJECT)
84
84
  o.fields = Object.entries(t.fields || {}).reduce((a, [l, c]) => (Lt(l, e), a[l] = ie(c, `${e}.${l}`), a), {});
85
- else if (i === P.LIST)
85
+ else if (i === w.LIST)
86
86
  o.item = ie(t.item, `${e}[]`);
87
87
  else if (!Ct.has(i))
88
88
  throw new TypeError(`Template field "${e}" has unsupported type "${i}".`);
89
89
  return Object.freeze(o);
90
90
  }
91
91
  function Lt(t, e) {
92
- if (!Y.test(t) || t.startsWith("__") || Ie.includes(t))
92
+ if (!Q.test(t) || t.startsWith("__") || Ie.includes(t))
93
93
  throw new TypeError(`Template field name "${e}.${t}" is not allowed.`);
94
94
  }
95
95
  function se(t) {
@@ -97,13 +97,13 @@ function se(t) {
97
97
  return t.label && (e.label = t.label), t.description && (e.description = t.description), t.fields && (e.fields = Object.entries(t.fields).reduce((n, [r, i]) => (n[r] = se(i), n), {})), t.item && (e.item = se(t.item)), e;
98
98
  }
99
99
  function oe(t, e) {
100
- if (t.type === P.OBJECT) {
100
+ if (t.type === w.OBJECT) {
101
101
  if (e === null || typeof e != "object")
102
102
  return null;
103
103
  const n = Ce(e, 0, /* @__PURE__ */ new WeakSet()) || {};
104
104
  return Object.entries(t.fields).reduce((r, [i, s]) => (r[i] = oe(s, s.value ? s.value(e) : e[i]), r), n);
105
105
  }
106
- return t.type === P.LIST ? Array.isArray(e) ? e.map((n) => oe(t.item, n)) : [] : e instanceof Date ? Number.isNaN(e.getTime()) ? null : e.getTime() : ["string", "number", "boolean"].includes(typeof e) ? typeof e == "number" && !Number.isFinite(e) ? null : e : null;
106
+ return t.type === w.LIST ? Array.isArray(e) ? e.map((n) => oe(t.item, n)) : [] : e instanceof Date ? Number.isNaN(e.getTime()) ? null : e.getTime() : ["string", "number", "boolean"].includes(typeof e) ? typeof e == "number" && !Number.isFinite(e) ? null : e : null;
107
107
  }
108
108
  function Ce(t, e, n) {
109
109
  if (t instanceof Date)
@@ -124,14 +124,14 @@ function Ce(t, e, n) {
124
124
  n.delete(t);
125
125
  }
126
126
  }
127
- class wt {
127
+ class Pt {
128
128
  constructor({ contextCode: e, name: n, subjectType: r, roots: i, recipientRules: s = [], functionNames: o = [], loadData: a, sampleData: l } = {}) {
129
129
  if (!e || typeof e != "string")
130
130
  throw new TypeError("DataContext requires a contextCode.");
131
131
  if (a !== void 0 && typeof a != "function")
132
132
  throw new TypeError(`DataContext ${e} loadData must be a function.`);
133
133
  const c = Object.entries(i || {}).reduce((f, [u, p]) => {
134
- if (!Y.test(u) || u.startsWith("__") || Ie.includes(u))
134
+ if (!Q.test(u) || u.startsWith("__") || Ie.includes(u))
135
135
  throw new TypeError(`DataContext ${e} root name "${u}" is not allowed.`);
136
136
  return f[u] = Rt(p, u), f;
137
137
  }, {});
@@ -188,7 +188,7 @@ class wt {
188
188
  }
189
189
  }
190
190
  function ue(t) {
191
- return new wt(t);
191
+ return new Pt(t);
192
192
  }
193
193
  function de(t) {
194
194
  return t ? typeof t.describe == "function" ? t.describe() : t : null;
@@ -200,7 +200,7 @@ const U = Object.freeze({
200
200
  NUMBER: "number",
201
201
  OBJECT: "object",
202
202
  STRING: "string"
203
- }), Pt = new Set(Object.values(U)), It = /^__[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/, V = /* @__PURE__ */ new Map();
203
+ }), wt = new Set(Object.values(U)), It = /^__[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/, V = /* @__PURE__ */ new Map();
204
204
  let ve = 0;
205
205
  function Dt({ name: t, fn: e, signature: n = [], trustedHtml: r = !1, label: i, description: s } = {}) {
206
206
  if (!It.test(t || ""))
@@ -213,7 +213,7 @@ function Dt({ name: t, fn: e, signature: n = [], trustedHtml: r = !1, label: i,
213
213
  throw new TypeError(`Template function ${t} requires a signature with at least the piped value.`);
214
214
  const o = n.map((a, l) => {
215
215
  const c = (a == null ? void 0 : a.types) || [];
216
- if (!c.length || c.some((f) => !Pt.has(f)))
216
+ if (!c.length || c.some((f) => !wt.has(f)))
217
217
  throw new TypeError(`Template function ${t} argument #${l + 1} has invalid types.`);
218
218
  return Object.freeze({
219
219
  ...a.optional ? { optional: !0 } : {},
@@ -279,22 +279,22 @@ function Bt(t, e) {
279
279
  return typeof t == "string";
280
280
  }
281
281
  }
282
- function O({ code: t, message: e, severity: n = H.ERROR, ...r } = {}) {
282
+ function O({ code: t, message: e, severity: n = X.ERROR, ...r } = {}) {
283
283
  const i = { code: t, message: e, severity: n };
284
284
  return ["partCode", "offset", "line", "column", "source", "blockRef", "detail"].forEach((s) => {
285
285
  typeof r[s] < "u" && (i[s] = r[s]);
286
286
  }), i;
287
287
  }
288
288
  function K(t = []) {
289
- return t.some((e) => e.severity === H.ERROR);
289
+ return t.some((e) => e.severity === X.ERROR);
290
290
  }
291
- class Q extends Error {
291
+ class Z extends Error {
292
292
  constructor(e = [], n) {
293
- const r = e.filter((i) => i.severity === H.ERROR);
293
+ const r = e.filter((i) => i.severity === X.ERROR);
294
294
  super(n || xt(r)), this.name = "TemplateSyntaxError", this.code = "TEMPLATE_SYNTAX_INVALID", this.issues = e;
295
295
  }
296
296
  }
297
- class v extends Error {
297
+ class j extends Error {
298
298
  constructor({ message: e, partCode: n, source: r, cause: i } = {}) {
299
299
  super(e || "Template rendering failed.", i ? { cause: i } : void 0), this.name = "TemplateRenderError", this.code = "TEMPLATE_RENDER_FAILED", this.partCode = n, this.source = r;
300
300
  }
@@ -389,7 +389,7 @@ function ct({ escape: t = !1, limits: e = {}, tags: n } = {}) {
389
389
  return r;
390
390
  }
391
391
  const k = "data-qw-block", Re = "data-qw-params", Kt = /^([A-Z][A-Z0-9_]*)@([1-9]\d*)$/, qt = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "source", "track", "wbr"]), Gt = ct();
392
- function J(t, { partCode: e, allowBlocks: n = !0 } = {}) {
392
+ function ee(t, { partCode: e, allowBlocks: n = !0 } = {}) {
393
393
  const r = Ft(typeof t == "string" ? t : ""), i = Zt(r, e), s = [], o = [], a = [];
394
394
  let l = 0, c = ae(r, l);
395
395
  for (; c; )
@@ -534,10 +534,11 @@ function Zt(t, e) {
534
534
  };
535
535
  };
536
536
  }
537
- const en = ["active", "created", "creator", "deleted", "modified", "owner", "revision"], tn = ["contextCode", "name", "templateCode", "templateSyntaxVersion"], nn = ["contextCode", "name", "templateSyntaxVersion"];
537
+ const en = ["active", "created", "creator", "deleted", "modified", "owner", "revision"], tn = ["contextCode", "name", "templateCode", "templateRevision", "templateSyntaxVersion"], nn = ["contextCode", "name", "templateSyntaxVersion"];
538
538
  class rn extends Et {
539
539
  constructor(e = {}) {
540
- e = e || {}, super(e), this._type = e._type || "Template", this.contextCode = e.contextCode, this.name = e.name, this.partContent = Ge(e.partContent), this.templateCode = e.templateCode, this.templateSyntaxVersion = Number(e.templateSyntaxVersion || Pe);
540
+ var n;
541
+ e = e || {}, super(e), this._type = e._type || "Template", this.contextCode = e.contextCode, this.name = e.name, this.partContent = Ge(e.partContent), this.templateCode = e.templateCode, this.templateRevision = Number(e.templateRevision || ((n = e.meta) == null ? void 0 : n.revision) || 1), this.templateSyntaxVersion = Number(e.templateSyntaxVersion || we);
541
542
  }
542
543
  static get _classname() {
543
544
  return "Template";
@@ -554,7 +555,7 @@ class rn extends Et {
554
555
  return ((e = this.kind) == null ? void 0 : e.partDefinitions) || [];
555
556
  }
556
557
  get isValid() {
557
- return super.isValid && !!this.templateCode && !!this.contextCode;
558
+ return super.isValid && !!this.templateCode && !!this.contextCode && Number.isInteger(this.templateRevision) && this.templateRevision > 0;
558
559
  }
559
560
  getCode() {
560
561
  return this.templateCode;
@@ -605,12 +606,12 @@ class rn extends Et {
605
606
  toObject() {
606
607
  const e = {
607
608
  _type: this._type,
608
- meta: w(this.meta, en),
609
+ meta: S(this.meta, en),
609
610
  metadata: Fe(this.metadata),
610
611
  partContent: Ge(this.partContent),
611
612
  remarks: Fe(this.remarks),
612
613
  tenantCode: this.tenantCode,
613
- ...w(this, tn)
614
+ ...S(this, tn)
614
615
  };
615
616
  return typeof this.id < "u" && (e.id = this.id), e;
616
617
  }
@@ -666,11 +667,11 @@ const R = Object.freeze({
666
667
  SELECT: "select",
667
668
  TEXT: "text"
668
669
  }), an = new Set(Object.values(R)), We = /* @__PURE__ */ new Set([R.MULTI_SELECT, R.SELECT]);
669
- function X(t = []) {
670
+ function J(t = []) {
670
671
  const e = [], n = /* @__PURE__ */ new Set();
671
672
  return { definitions: (Array.isArray(t) ? t : []).map((i, s) => {
672
673
  const { paramCode: o, type: a, label: l, description: c, required: f = !1, options: u = [] } = i || {};
673
- return !Y.test(o || "") || o.startsWith("__") ? e.push(`Param #${s + 1} has an invalid paramCode "${o}".`) : n.has(o) && e.push(`Param "${o}" is declared twice.`), n.add(o), an.has(a) || e.push(`Param "${o}" has unsupported type "${a}".`), We.has(a) && (!Array.isArray(u) || !u.length ? e.push(`Param "${o}" requires options.`) : u.some((p) => !Y.test(String((p == null ? void 0 : p.value) ?? ""))) && e.push(`Param "${o}" option values must match [A-Za-z_]\\w*.`)), {
674
+ return !Q.test(o || "") || o.startsWith("__") ? e.push(`Param #${s + 1} has an invalid paramCode "${o}".`) : n.has(o) && e.push(`Param "${o}" is declared twice.`), n.add(o), an.has(a) || e.push(`Param "${o}" has unsupported type "${a}".`), We.has(a) && (!Array.isArray(u) || !u.length ? e.push(`Param "${o}" requires options.`) : u.some((p) => !Q.test(String((p == null ? void 0 : p.value) ?? ""))) && e.push(`Param "${o}" option values must match [A-Za-z_]\\w*.`)), {
674
675
  ...c ? { description: c } : {},
675
676
  ..."default" in (i || {}) ? { default: i.default } : {},
676
677
  label: l || o,
@@ -728,16 +729,17 @@ const xe = Object.freeze({
728
729
  }), x = Object.freeze({
729
730
  TEXT_HTML: "text/html",
730
731
  TEXT_PLAIN: "text/plain"
731
- }), B = Object.freeze({
732
+ }), v = Object.freeze({
732
733
  MAILBOX: "mailbox",
733
734
  MAILBOX_LIST: "mailboxList",
734
735
  TEXT: "text"
735
736
  }), $e = Object.freeze({
736
737
  fieldDefinitions: Object.freeze([
737
- Object.freeze({ emailExpression: !1, fieldCode: "from", label: "From", nameExpression: !0, type: B.MAILBOX }),
738
- Object.freeze({ emailExpression: !0, fieldCode: "replyTo", label: "Reply to", nameExpression: !0, type: B.MAILBOX }),
739
- Object.freeze({ emailExpression: !0, fieldCode: "cc", label: "CC", nameExpression: !0, type: B.MAILBOX_LIST }),
740
- Object.freeze({ emailExpression: !0, fieldCode: "bcc", label: "BCC", nameExpression: !0, type: B.MAILBOX_LIST })
738
+ Object.freeze({ emailExpression: !1, fieldCode: "to", label: "To", nameExpression: !0, type: v.MAILBOX }),
739
+ Object.freeze({ emailExpression: !1, fieldCode: "from", label: "From", nameExpression: !0, type: v.MAILBOX }),
740
+ Object.freeze({ emailExpression: !0, fieldCode: "replyTo", label: "Reply to", nameExpression: !0, type: v.MAILBOX }),
741
+ Object.freeze({ emailExpression: !0, fieldCode: "cc", label: "CC", nameExpression: !0, type: v.MAILBOX_LIST }),
742
+ Object.freeze({ emailExpression: !0, fieldCode: "bcc", label: "BCC", nameExpression: !0, type: v.MAILBOX_LIST })
741
743
  ]),
742
744
  label: "Email",
743
745
  partDefinitions: Object.freeze([
@@ -775,8 +777,8 @@ function Cr(t) {
775
777
  function dn(t, e = {}) {
776
778
  return (t.fieldDefinitions || []).flatMap(({ fieldCode: n, type: r, emailExpression: i, nameExpression: s, expressionAllowed: o = !1 }) => {
777
779
  const a = e[n];
778
- return r === B.TEXT ? typeof a == "string" && a ? [{ content: a, expressionAllowed: !!o, fieldPath: n }] : [] : (r === B.MAILBOX_LIST ? Array.isArray(a) ? a : [] : a ? [a] : []).flatMap((c, f) => {
779
- const u = r === B.MAILBOX_LIST ? `${n}[${f}]` : n;
780
+ return r === v.TEXT ? typeof a == "string" && a ? [{ content: a, expressionAllowed: !!o, fieldPath: n }] : [] : (r === v.MAILBOX_LIST ? Array.isArray(a) ? a : [] : a ? [a] : []).flatMap((c, f) => {
781
+ const u = r === v.MAILBOX_LIST ? `${n}[${f}]` : n;
780
782
  return [
781
783
  { content: (c == null ? void 0 : c.email) || "", expressionAllowed: i, fieldPath: `${u}.email` },
782
784
  { content: (c == null ? void 0 : c.name) || "", expressionAllowed: s, fieldPath: `${u}.name` }
@@ -784,8 +786,8 @@ function dn(t, e = {}) {
784
786
  });
785
787
  });
786
788
  }
787
- const dt = new Map(ot.map((t) => [t.name, t])), S = Object.freeze({ type: "number" }), Me = Object.freeze({ type: "string" }), Le = Object.freeze({ type: "boolean" }), pn = Object.freeze({
788
- fields: Object.freeze({ first: Le, index: S, index0: S, last: Le, length: S, rindex: S, rindex0: S }),
789
+ const dt = new Map(ot.map((t) => [t.name, t])), L = Object.freeze({ type: "number" }), Me = Object.freeze({ type: "string" }), Le = Object.freeze({ type: "boolean" }), pn = Object.freeze({
790
+ fields: Object.freeze({ first: Le, index: L, index0: L, last: Le, length: L, rindex: L, rindex0: L }),
789
791
  label: "Loop",
790
792
  type: "object"
791
793
  }), mn = /* @__PURE__ */ new Set([F, "forloop"]), fn = /* @__PURE__ */ new Set(["where", "where_exp"]), hn = /* @__PURE__ */ new Set(["date", "downcase", "join", "strip_html", "truncate", "upcase"]), Tn = /* @__PURE__ */ new Set(["divided_by", "minus", "plus", "round", "size", "times"]);
@@ -810,7 +812,7 @@ function D(t, e, n) {
810
812
  (t || []).forEach((r) => {
811
813
  const { token: i } = r;
812
814
  if (A.isOutputToken(i)) {
813
- const s = ce(n, i), o = G(r.value, e, n, s);
815
+ const s = ce(n, i), o = H(r.value, e, n, s);
814
816
  o && (o.type === "list" || o.type === "object") && N(n, y.OUTPUT_NOT_SCALAR, `"${s}" outputs a ${o.type}; output a field of it or use a filter such as join or size.`, i, s);
815
817
  return;
816
818
  }
@@ -829,11 +831,11 @@ function bn(t, e, n) {
829
831
  case "if":
830
832
  case "unless":
831
833
  t.branches.forEach((a) => {
832
- G(a.value, e, n, s), D(a.templates, e, n);
834
+ H(a.value, e, n, s), D(a.templates, e, n);
833
835
  }), D(t.elseTemplates, e, n);
834
836
  break;
835
837
  case "case":
836
- G(t.value, e, n, s), t.branches.forEach((a) => {
838
+ H(t.value, e, n, s), t.branches.forEach((a) => {
837
839
  a.values.forEach((l) => I(l, e, n, s)), D(a.templates, e, n);
838
840
  }), D(t.elseTemplates, e, n);
839
841
  break;
@@ -842,13 +844,13 @@ function bn(t, e, n) {
842
844
  ye(a, e, n, i, s);
843
845
  const l = I(t.collection, e, n, s);
844
846
  let c = null;
845
- A.isRangeToken(t.collection) ? c = S : l && l.type !== "list" ? N(n, y.LOOP_SOURCE_NOT_LIST, `"${ce(n, t.collection)}" is not a list.`, t.collection, s) : l && (c = l.item || null), Object.values(((o = t.hash) == null ? void 0 : o.hash) || {}).forEach((f) => {
847
+ A.isRangeToken(t.collection) ? c = L : l && l.type !== "list" ? N(n, y.LOOP_SOURCE_NOT_LIST, `"${ce(n, t.collection)}" is not a list.`, t.collection, s) : l && (c = l.item || null), Object.values(((o = t.hash) == null ? void 0 : o.hash) || {}).forEach((f) => {
846
848
  f && I(f, e, n, s);
847
849
  }), D(t.templates, new Map([...e, [a, c], ["forloop", pn]]), n), D(t.elseTemplates, e, n);
848
850
  break;
849
851
  }
850
852
  case "assign": {
851
- ye(t.key, e, n, i, s), n.assigned.set(t.key, G(t.value, e, n, s));
853
+ ye(t.key, e, n, i, s), n.assigned.set(t.key, H(t.value, e, n, s));
852
854
  break;
853
855
  }
854
856
  case "capture":
@@ -857,9 +859,9 @@ function bn(t, e, n) {
857
859
  }
858
860
  }
859
861
  function ye(t, e, n, r, i) {
860
- !Y.test(t || "") || t.startsWith("__") ? N(n, y.VARIABLE_INVALID, `Variable "${t}" must match [A-Za-z_]\\w* and must not start with "__".`, r, i) : (Ie.includes(t) || e.has(t) || n.roots && Object.hasOwn(n.roots, t)) && N(n, y.VARIABLE_INVALID, `Variable "${t}" conflicts with a data root, a loop variable or a reserved name.`, r, i);
862
+ !Q.test(t || "") || t.startsWith("__") ? N(n, y.VARIABLE_INVALID, `Variable "${t}" must match [A-Za-z_]\\w* and must not start with "__".`, r, i) : (Ie.includes(t) || e.has(t) || n.roots && Object.hasOwn(n.roots, t)) && N(n, y.VARIABLE_INVALID, `Variable "${t}" conflicts with a data root, a loop variable or a reserved name.`, r, i);
861
863
  }
862
- function G(t, e, n, r) {
864
+ function H(t, e, n, r) {
863
865
  if (!t)
864
866
  return null;
865
867
  let i = pt(t.initial, e, n, r);
@@ -872,7 +874,7 @@ function pt(t, e, n, r) {
872
874
  return i.length === 1 ? s[0] : i.some((o) => A.isOperatorToken(o)) ? Le : null;
873
875
  }
874
876
  function I(t, e, n, r) {
875
- return t ? A.isPropertyAccessToken(t) ? En(t, e, n, r) : A.isRangeToken(t) ? (I(t.lhs, e, n, r), I(t.rhs, e, n, r), { item: S, type: "list" }) : A.isNumberToken(t) ? S : A.isQuotedToken(t) ? Me : t.initial ? G(t, e, n, r) : null : null;
877
+ return t ? A.isPropertyAccessToken(t) ? En(t, e, n, r) : A.isRangeToken(t) ? (I(t.lhs, e, n, r), I(t.rhs, e, n, r), { item: L, type: "list" }) : A.isNumberToken(t) ? L : A.isQuotedToken(t) ? Me : t.initial ? H(t, e, n, r) : null : null;
876
878
  }
877
879
  function En(t, e, n, r) {
878
880
  const [i, ...s] = t.props || [], o = i == null ? void 0 : i.content;
@@ -897,31 +899,31 @@ function En(t, e, n, r) {
897
899
  a = a.item || null;
898
900
  continue;
899
901
  }
900
- return a.type === "object" ? null : ee(n, t, r, "only a list or an object can be indexed.");
902
+ return a.type === "object" ? null : ne(n, t, r, "only a list or an object can be indexed.");
901
903
  }
902
904
  if (A.isNumberToken(l)) {
903
905
  if (a.type !== "list")
904
- return ee(n, t, r, "only a list can be indexed.");
906
+ return ne(n, t, r, "only a list can be indexed.");
905
907
  a = a.item || null;
906
908
  continue;
907
909
  }
908
910
  const c = l.content;
909
911
  if (a.type === "list")
910
912
  if (c === "size")
911
- a = S;
913
+ a = L;
912
914
  else if (c === "first" || c === "last")
913
915
  a = a.item || null;
914
916
  else
915
- return ee(n, t, r, `a list has no field "${c}" (use size, first, last or a loop).`);
917
+ return ne(n, t, r, `a list has no field "${c}" (use size, first, last or a loop).`);
916
918
  else if (a.type === "string" && c === "size")
917
- a = S;
919
+ a = L;
918
920
  else if (a.type === "object" && a.fields && Object.hasOwn(a.fields, c))
919
921
  a = a.fields[c];
920
- else return a.type === "object" && !mn.has(o) ? null : ee(n, t, r, `field "${c}" does not exist.`);
922
+ else return a.type === "object" && !mn.has(o) ? null : ne(n, t, r, `field "${c}" does not exist.`);
921
923
  }
922
924
  return a;
923
925
  }
924
- function ee(t, e, n, r) {
926
+ function ne(t, e, n, r) {
925
927
  return N(t, y.PATH_UNKNOWN, `"${ce(t, e)}": ${r}`, e, n), null;
926
928
  }
927
929
  function yn(t, e, n, r, i) {
@@ -955,7 +957,7 @@ function gn(t, e, n, r, i, s) {
955
957
  const c = a(l(n[0]));
956
958
  return (e == null ? void 0 : e.type) === "list" ? { item: c, type: "list" } : null;
957
959
  }
958
- return t === "first" ? o : t === "default" ? e : Tn.has(t) ? S : hn.has(t) ? Me : null;
960
+ return t === "first" ? o : t === "default" ? e : Tn.has(t) ? L : hn.has(t) ? Me : null;
959
961
  }
960
962
  function _n(t, e, n, r, i, s) {
961
963
  if (!t || !e || !A.isQuotedToken(e))
@@ -982,7 +984,7 @@ function Rr({ template: t, kind: e, context: n, functions: r, blocks: i, allowed
982
984
  const a = typeof (t == null ? void 0 : t.toObject) == "function" ? t.toObject() : t || {}, l = e || ((T = t == null ? void 0 : t.constructor) == null ? void 0 : T.kind) || ut(a.templateKindCode), c = [], f = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
983
985
  if (!l)
984
986
  throw new TypeError("checkTemplate requires a template kind.");
985
- const p = a.templateSyntaxVersion ?? Pe;
987
+ const p = a.templateSyntaxVersion ?? we;
986
988
  if (!Ze.includes(p))
987
989
  return c.push(O({ code: y.SYNTAX_VERSION_UNSUPPORTED, message: `Template syntax version ${p} is not supported.` })), { blockRefs: [], issues: c, layoutCodes: [], valid: !1 };
988
990
  const b = ft({ allowedDeprecatedBlockRefs: s, blocks: i, context: n, functions: r }), _ = a.partContent || {}, m = new Set(l.partDefinitions.map(({ partCode: d }) => d));
@@ -993,8 +995,8 @@ function Rr({ template: t, kind: e, context: n, functions: r, blocks: i, allowed
993
995
  return;
994
996
  }
995
997
  const C = le(E, { allowBlocks: !0, env: b, partCode: d });
996
- c.push(...C.issues), C.blockRefs.forEach((L) => f.add(L)), je(E).forEach((L) => {
997
- u.has(L) || c.push(...Cn(L, { env: b, layouts: o, partCode: d })), u.add(L);
998
+ c.push(...C.issues), C.blockRefs.forEach((P) => f.add(P)), je(E).forEach((P) => {
999
+ u.has(P) || c.push(...Cn(P, { env: b, layouts: o, partCode: d })), u.add(P);
998
1000
  });
999
1001
  }), Object.keys(_).forEach((d) => {
1000
1002
  m.has(d) || c.push(O({ code: y.PART_UNKNOWN, message: `Part "${d}" is not declared by template kind ${l.templateKindCode}.`, partCode: d }));
@@ -1021,7 +1023,7 @@ function Nr({ content: t, partCode: e, allowBlocks: n = !0, context: r, function
1021
1023
  return { ...l, valid: !K(l.issues) };
1022
1024
  }
1023
1025
  function An({ fragment: t, params: e, functions: n, context: r } = {}) {
1024
- const { definitions: i, errors: s } = X(e), o = s.map((l) => O({ code: y.BLOCK_PARAMS_INVALID, message: l })), a = mt(t, { allowAssign: !0, context: r, functions: n, paramsRoot: Be(i) });
1026
+ const { definitions: i, errors: s } = J(e), o = s.map((l) => O({ code: y.BLOCK_PARAMS_INVALID, message: l })), a = mt(t, { allowAssign: !0, context: r, functions: n, paramsRoot: Be(i) });
1025
1027
  return o.push(...a.issues), { issues: o, requiredRoots: a.requiredRoots, valid: !K(o) };
1026
1028
  }
1027
1029
  function Rn({ html: t, functions: e } = {}) {
@@ -1029,7 +1031,7 @@ function Rn({ html: t, functions: e } = {}) {
1029
1031
  return { issues: r, requiredRoots: n.requiredRoots, valid: !K(r) };
1030
1032
  }
1031
1033
  function mt(t, { allowAssign: e, context: n, functions: r, paramsRoot: i }) {
1032
- const s = de(n), o = J(t, { allowBlocks: !1 }), a = r || (s ? pe() : null), l = me(o.templates, {
1034
+ const s = de(n), o = ee(t, { allowBlocks: !1 }), a = r || (s ? pe() : null), l = me(o.templates, {
1033
1035
  allowAssign: e,
1034
1036
  allowedFunctionNames: s ? new Set(s.functionNames || []) : null,
1035
1037
  functionsByName: a ? new Map(a.map((c) => [c.name, c])) : null,
@@ -1058,7 +1060,7 @@ function ft({ allowedDeprecatedBlockRefs: t = [], blocks: e = [], context: n, fu
1058
1060
  };
1059
1061
  }
1060
1062
  function le(t, { allowBlocks: e, env: n, partCode: r }) {
1061
- const i = J(t, { allowBlocks: e, partCode: r }), s = [...i.issues];
1063
+ const i = ee(t, { allowBlocks: e, partCode: r }), s = [...i.issues];
1062
1064
  return s.push(...me(i.templates, {
1063
1065
  allowedFunctionNames: n.allowedFunctionNames,
1064
1066
  functionsByName: n.functionsByName,
@@ -1083,7 +1085,7 @@ function Nn(t, e, n) {
1083
1085
  s(
1084
1086
  y.BLOCK_DEPRECATED,
1085
1087
  u ? `Block ${r} is deprecated; consider a newer version.` : `Block ${r} is deprecated and cannot be added.`,
1086
- u ? H.WARNING : H.ERROR
1088
+ u ? X.WARNING : X.ERROR
1087
1089
  );
1088
1090
  }
1089
1091
  if (o.contextCode !== e.contextCode) {
@@ -1092,9 +1094,9 @@ function Nn(t, e, n) {
1092
1094
  }
1093
1095
  const l = (o.requiredRoots || []).filter((u) => !Object.hasOwn(e.roots, u));
1094
1096
  l.length && s(y.BLOCK_ROOT_NOT_IN_CONTEXT, `Block ${r} requires data roots not in this context: ${l.join(", ")}.`);
1095
- const { definitions: c } = X(o.params), { errors: f } = lt(c, t.params);
1097
+ const { definitions: c } = J(o.params), { errors: f } = lt(c, t.params);
1096
1098
  if (f.forEach((u) => s(y.BLOCK_PARAMS_INVALID, `${r}: ${u}`)), typeof o.fragment == "string" && !l.length) {
1097
- const u = J(o.fragment, { allowBlocks: !1 }), p = me(u.templates, {
1099
+ const u = ee(o.fragment, { allowBlocks: !1 }), p = me(u.templates, {
1098
1100
  allowAssign: !0,
1099
1101
  allowedFunctionNames: e.allowedFunctionNames,
1100
1102
  functionsByName: e.functionsByName,
@@ -1112,13 +1114,13 @@ function Nn(t, e, n) {
1112
1114
  })));
1113
1115
  }
1114
1116
  }
1115
- const Sn = ["active", "created", "creator", "deleted", "modified", "owner", "revision"], Ln = ["blockCode", "category", "contextCode", "description", "fragment", "name", "tenantCode", "version"], He = ["category", "contextCode", "description", "fragment", "name", "params"], wn = /^[A-Z][A-Z0-9_]*$/, Sr = Object.freeze({
1117
+ const Sn = ["active", "created", "creator", "deleted", "modified", "owner", "revision"], Ln = ["blockCode", "category", "contextCode", "description", "fragment", "name", "tenantCode", "version"], He = ["category", "contextCode", "description", "fragment", "name", "params"], Pn = /^[A-Z][A-Z0-9_]*$/, Sr = Object.freeze({
1116
1118
  DEPRECATED: "TEMPLATE_BLOCK_DEPRECATED",
1117
1119
  PUBLISHED: "TEMPLATE_BLOCK_PUBLISHED"
1118
1120
  });
1119
- class Pn extends Qe {
1121
+ class wn extends Qe {
1120
1122
  constructor(e = {}) {
1121
- e = e || {}, super(e), this._type = e._type || "TemplateBlock", this.blockCode = e.blockCode, this.category = e.category || "", this.contextCode = e.contextCode || "", this.description = e.description || "", this.fragment = typeof e.fragment == "string" ? e.fragment : "", this.lifecycle = e.lifecycle ? Se.init(e.lifecycle) : null, this.name = e.name || "", this.params = X(e.params).definitions, this.requiredRoots = Array.isArray(e.requiredRoots) ? [...e.requiredRoots] : [], this.tenantCode = e.tenantCode || void 0, this.version = Number(e.version);
1123
+ e = e || {}, super(e), this._type = e._type || "TemplateBlock", this.blockCode = e.blockCode, this.category = e.category || "", this.contextCode = e.contextCode || "", this.description = e.description || "", this.fragment = typeof e.fragment == "string" ? e.fragment : "", this.lifecycle = e.lifecycle ? Se.init(e.lifecycle) : null, this.name = e.name || "", this.params = J(e.params).definitions, this.requiredRoots = Array.isArray(e.requiredRoots) ? [...e.requiredRoots] : [], this.tenantCode = e.tenantCode || void 0, this.version = Number(e.version);
1122
1124
  }
1123
1125
  static get _classname() {
1124
1126
  return "TemplateBlock";
@@ -1136,7 +1138,7 @@ class Pn extends Qe {
1136
1138
  }
1137
1139
  get isValid() {
1138
1140
  var e;
1139
- return super.isValid && wn.test(this.blockCode || "") && !!this.contextCode && Number.isInteger(this.version) && this.version >= 1 && !!((e = this.lifecycle) != null && e.isValid);
1141
+ return super.isValid && Pn.test(this.blockCode || "") && !!this.contextCode && Number.isInteger(this.version) && this.version >= 1 && !!((e = this.lifecycle) != null && e.isValid);
1140
1142
  }
1141
1143
  get blockRef() {
1142
1144
  return `${this.blockCode}@${this.version}`;
@@ -1168,7 +1170,7 @@ class Pn extends Qe {
1168
1170
  if (He.some((r) => Object.hasOwn(e, r)) && !this.isDraft)
1169
1171
  throw new Error(`TemplateBlock ${this.blockRef} is ${this.stateCode}; publish changes as a new version.`);
1170
1172
  return He.forEach((r) => {
1171
- Object.hasOwn(e, r) && (this[r] = r === "params" ? X(e.params).definitions : e[r] ?? "");
1173
+ Object.hasOwn(e, r) && (this[r] = r === "params" ? J(e.params).definitions : e[r] ?? "");
1172
1174
  }), super.update(e);
1173
1175
  }
1174
1176
  /**
@@ -1178,7 +1180,7 @@ class Pn extends Qe {
1178
1180
  publish({ actionRevision: e = this.revision + 1, context: n, modified: r = Date.now(), functions: i } = {}) {
1179
1181
  const s = this.check({ context: n, functions: i });
1180
1182
  if (!s.valid)
1181
- throw new Q(s.issues.map((o) => ({ ...o, blockRef: this.blockRef })));
1183
+ throw new Z(s.issues.map((o) => ({ ...o, blockRef: this.blockRef })));
1182
1184
  return this.lifecycle.transition("publication", { actionRevision: e, modified: r, stateCode: z.PUBLISHED }), this.requiredRoots = s.requiredRoots, this.meta.revision = e, this.setModified();
1183
1185
  }
1184
1186
  /** Hide this version from editors; templates that use it still render. */
@@ -1224,20 +1226,18 @@ class Pn extends Qe {
1224
1226
  const e = {
1225
1227
  _type: this._type,
1226
1228
  ...this.lifecycle ? { lifecycle: this.lifecycle.toObject() } : {},
1227
- meta: w(this.meta, Sn),
1229
+ meta: S(this.meta, Sn),
1228
1230
  params: Ke(this.params),
1229
1231
  requiredRoots: [...this.requiredRoots],
1230
- ...w(this, Ln)
1232
+ ...S(this, Ln)
1231
1233
  };
1232
1234
  return typeof this.id < "u" && (e.id = this.id), e;
1233
1235
  }
1234
1236
  }
1235
- const te = ["email", "name"], In = ["bcc", "cc", "from", "replyTo"];
1237
+ const G = ["email", "name"], In = ["bcc", "cc", "from", "replyTo", "to"];
1236
1238
  class Dn extends rn {
1237
1239
  constructor(e = {}) {
1238
- if (e = e || {}, Array.isArray(e.to) ? e.to.length : e.to)
1239
- throw new TypeError('TemplateEmail does not accept "to"; recipients come from the sending job.');
1240
- super(e), this._type = e._type || "TemplateEmail", this.bcc = _e(e.bcc), this.cc = _e(e.cc), this.from = re(e.from), this.replyTo = re(e.replyTo);
1240
+ e = e || {}, super(e), this._type = e._type || "TemplateEmail", this.bcc = _e(e.bcc), this.cc = _e(e.cc), this.from = W(e.from), this.replyTo = W(e.replyTo), this.to = W(e.to);
1241
1241
  }
1242
1242
  static get _classname() {
1243
1243
  return "TemplateEmail";
@@ -1246,30 +1246,29 @@ class Dn extends rn {
1246
1246
  return $e;
1247
1247
  }
1248
1248
  update(e = {}) {
1249
- if (Array.isArray(e.to) ? e.to.length : e.to)
1250
- throw new TypeError('TemplateEmail does not accept "to"; recipients come from the sending job.');
1251
1249
  return In.forEach((n) => {
1252
- Object.hasOwn(e, n) && (this[n] = n === "cc" || n === "bcc" ? _e(e[n]) : re(e[n]));
1250
+ Object.hasOwn(e, n) && (this[n] = n === "cc" || n === "bcc" ? _e(e[n]) : W(e[n]));
1253
1251
  }), super.update(e);
1254
1252
  }
1255
1253
  toObject() {
1256
1254
  return {
1257
1255
  ...super.toObject(),
1258
- bcc: this.bcc.map((e) => w(e, te)),
1259
- cc: this.cc.map((e) => w(e, te)),
1260
- from: this.from ? w(this.from, te) : null,
1261
- replyTo: this.replyTo ? w(this.replyTo, te) : null
1256
+ bcc: this.bcc.map((e) => S(e, G)),
1257
+ cc: this.cc.map((e) => S(e, G)),
1258
+ from: this.from ? S(this.from, G) : null,
1259
+ replyTo: this.replyTo ? S(this.replyTo, G) : null,
1260
+ to: this.to ? S(this.to, G) : null
1262
1261
  };
1263
1262
  }
1264
1263
  }
1265
- function re(t) {
1264
+ function W(t) {
1266
1265
  return t ? typeof t == "string" ? t.trim() ? { email: t.trim() } : null : typeof t != "object" || !t.email ? null : {
1267
1266
  email: String(t.email).trim(),
1268
1267
  ...t.name ? { name: String(t.name) } : {}
1269
1268
  } : null;
1270
1269
  }
1271
1270
  function _e(t) {
1272
- return (Array.isArray(t) ? t : []).map(re).filter(Boolean);
1271
+ return (Array.isArray(t) ? t : []).map(W).filter(Boolean);
1273
1272
  }
1274
1273
  const Oe = z;
1275
1274
  class Ye extends Se {
@@ -1284,7 +1283,7 @@ const vn = ["active", "created", "creator", "deleted", "modified", "owner", "rev
1284
1283
  DEPRECATED: "TEMPLATE_LAYOUT_DEPRECATED",
1285
1284
  PUBLISHED: "TEMPLATE_LAYOUT_PUBLISHED"
1286
1285
  });
1287
- class wr extends Qe {
1286
+ class Pr extends Qe {
1288
1287
  constructor(e = {}) {
1289
1288
  e = e || {}, super(e), this._type = e._type || "TemplateLayout", this.description = e.description || "", this.eventShortCode = e.eventShortCode || void 0, this.html = typeof e.html == "string" ? e.html : "", this.layoutCode = e.layoutCode, this.lifecycle = e.lifecycle ? Ye.init(e.lifecycle) : null, this.name = e.name || "", this.requiredRoots = Array.isArray(e.requiredRoots) ? [...e.requiredRoots] : [], this.templateKindCode = e.templateKindCode || xe.EMAIL, this.tenantCode = e.tenantCode || void 0, this.version = Number(e.version);
1290
1289
  }
@@ -1340,7 +1339,7 @@ class wr extends Qe {
1340
1339
  publish({ actionRevision: e = this.revision + 1, modified: n = Date.now(), functions: r } = {}) {
1341
1340
  const i = this.check({ functions: r });
1342
1341
  if (!i.valid)
1343
- throw new Q(i.issues.map((s) => ({ ...s, layoutRef: this.layoutRef })));
1342
+ throw new Z(i.issues.map((s) => ({ ...s, layoutRef: this.layoutRef })));
1344
1343
  return this.lifecycle.transition("publication", { actionRevision: e, modified: n, stateCode: Oe.PUBLISHED }), this.requiredRoots = i.requiredRoots, this.meta.revision = e, this.setModified();
1345
1344
  }
1346
1345
  /** Retire this version; templates fall back to an older published version, if any. */
@@ -1385,9 +1384,9 @@ class wr extends Qe {
1385
1384
  const e = {
1386
1385
  _type: this._type,
1387
1386
  ...this.lifecycle ? { lifecycle: this.lifecycle.toObject() } : {},
1388
- meta: w(this.meta, vn),
1387
+ meta: S(this.meta, vn),
1389
1388
  requiredRoots: [...this.requiredRoots],
1390
- ...w(this, jn)
1389
+ ...S(this, jn)
1391
1390
  };
1392
1391
  return typeof this.id < "u" && (e.id = this.id), e;
1393
1392
  }
@@ -1397,10 +1396,10 @@ const xn = Object.freeze({
1397
1396
  parseLimit: 1024 * 1024,
1398
1397
  renderLimit: 1e3
1399
1398
  }), ht = "qw_block";
1400
- let W = null;
1399
+ let Y = null;
1401
1400
  const $n = {
1402
1401
  parse(t) {
1403
- if (this.block = W == null ? void 0 : W[Number(t.args)], !this.block)
1402
+ if (this.block = Y == null ? void 0 : Y[Number(t.args)], !this.block)
1404
1403
  throw new Error(`Unknown block instance ${t.args}.`);
1405
1404
  },
1406
1405
  *render(t, e) {
@@ -1459,27 +1458,27 @@ function Mn({ maxCacheEntries: t = 500, limits: e = {} } = {}) {
1459
1458
  if (!C)
1460
1459
  throw new TypeError("renderTemplate requires a template kind.");
1461
1460
  Un(E.templateSyntaxVersion);
1462
- const L = d ? null : T ?? kn(E), Te = {};
1461
+ const P = d ? null : T ?? kn(E), Te = {};
1463
1462
  return C.partDefinitions.forEach(({ partCode: $, contentType: be }) => {
1464
1463
  var Ve;
1465
- const Z = (Ve = E.partContent) == null ? void 0 : Ve[$];
1466
- if (typeof Z != "string" || !Z)
1464
+ const te = (Ve = E.partContent) == null ? void 0 : Ve[$];
1465
+ if (typeof te != "string" || !te)
1467
1466
  return;
1468
1467
  if (be !== x.TEXT_HTML) {
1469
- Te[$] = a({ blocks: m, cacheKey: L, content: Z, context: _, contentType: be, data: b, partCode: $ });
1468
+ Te[$] = a({ blocks: m, cacheKey: P, content: te, context: _, contentType: be, data: b, partCode: $ });
1470
1469
  return;
1471
1470
  }
1472
- const q = kt({ html: Z, layouts: h });
1471
+ const q = kt({ html: te, layouts: h });
1473
1472
  if (q.missingLayoutCodes.length)
1474
- throw new v({ message: `Layout ${q.missingLayoutCodes.join(", ")} has no published version.`, partCode: $ });
1475
- const bt = L && q.layoutRefs.length ? `${L}\0${q.layoutRefs.join(",")}` : L;
1473
+ throw new j({ message: `Layout ${q.missingLayoutCodes.join(", ")} has no published version.`, partCode: $ });
1474
+ const bt = P && q.layoutRefs.length ? `${P}\0${q.layoutRefs.join(",")}` : P;
1476
1475
  Te[$] = a({ blocks: m, cacheKey: bt, content: q.html, context: _, contentType: be, data: b, partCode: $ });
1477
1476
  }), { partContent: Te };
1478
1477
  } });
1479
1478
  }
1480
- function Un(t = Pe) {
1479
+ function Un(t = we) {
1481
1480
  if (!Ze.includes(t))
1482
- throw new Q([O({
1481
+ throw new Z([O({
1483
1482
  code: y.SYNTAX_VERSION_UNSUPPORTED,
1484
1483
  message: `Template syntax version ${t} is not supported.`
1485
1484
  })]);
@@ -1495,9 +1494,9 @@ function zn(t = []) {
1495
1494
  }));
1496
1495
  }
1497
1496
  function Vn({ content: t, contentType: e, partCode: n, allowedFunctions: r, blocks: i, allowBlocks: s, engines: o }) {
1498
- const a = new Map(pe().map((d) => [d.name, d])), l = new Set(r), c = J(t, { allowBlocks: s, partCode: n }), f = (d, h) => me(d.templates, { allowedFunctionNames: l, functionsByName: a, locate: d.locate, text: d.text, ...h }).issues, u = [...c.issues, ...f(c, {})];
1497
+ const a = new Map(pe().map((d) => [d.name, d])), l = new Set(r), c = ee(t, { allowBlocks: s, partCode: n }), f = (d, h) => me(d.templates, { allowedFunctionNames: l, functionsByName: a, locate: d.locate, text: d.text, ...h }).issues, u = [...c.issues, ...f(c, {})];
1499
1498
  if (K(u))
1500
- throw new Q(u);
1499
+ throw new Z(u);
1501
1500
  const p = e === x.TEXT_PLAIN ? o.text : o.html, b = c.blocks.map((d) => Fn(d, { blocks: i, engine: p, partCode: n, policy: f }));
1502
1501
  let _ = "", m = 0;
1503
1502
  c.blocks.forEach(({ start: d, end: h }, E) => {
@@ -1510,10 +1509,10 @@ function Vn({ content: t, contentType: e, partCode: n, allowedFunctions: r, bloc
1510
1509
  return p.renderSync(T, { ...d });
1511
1510
  } catch (h) {
1512
1511
  const E = (h == null ? void 0 : h.originalError) || h;
1513
- if (E instanceof v)
1512
+ if (E instanceof j)
1514
1513
  throw E;
1515
1514
  const C = String((E == null ? void 0 : E.message) || h.message).replace(/, line:\d+, col:\d+$/, "");
1516
- throw new v({ cause: h, message: `Failed to render ${n || "content"}: ${C}`, partCode: n });
1515
+ throw new j({ cause: h, message: `Failed to render ${n || "content"}: ${C}`, partCode: n });
1517
1516
  }
1518
1517
  }
1519
1518
  });
@@ -1521,30 +1520,30 @@ function Vn({ content: t, contentType: e, partCode: n, allowedFunctions: r, bloc
1521
1520
  function Fn(t, { blocks: e, engine: n, partCode: r, policy: i }) {
1522
1521
  const { blockRef: s } = t, o = e.get(s);
1523
1522
  if (!o || typeof o.fragment != "string")
1524
- throw new v({ message: `Block ${s} is not available for rendering.`, partCode: r, source: s });
1523
+ throw new j({ message: `Block ${s} is not available for rendering.`, partCode: r, source: s });
1525
1524
  if (o.stateCode === "DRAFT")
1526
- throw new v({ message: `Block ${s} is not published.`, partCode: r, source: s });
1527
- const { definitions: a, errors: l } = X(o.params), { errors: c, values: f } = lt(a, t.params);
1525
+ throw new j({ message: `Block ${s} is not published.`, partCode: r, source: s });
1526
+ const { definitions: a, errors: l } = J(o.params), { errors: c, values: f } = lt(a, t.params);
1528
1527
  if (l.length || c.length)
1529
- throw new v({ message: `Block ${s} params are invalid: ${[...l, ...c].join(" ")}`, partCode: r, source: s });
1530
- const u = J(o.fragment, { allowBlocks: !1 }), p = [...u.issues, ...i(u, { allowAssign: !0, variables: /* @__PURE__ */ new Map([[F, null]]) })];
1528
+ throw new j({ message: `Block ${s} params are invalid: ${[...l, ...c].join(" ")}`, partCode: r, source: s });
1529
+ const u = ee(o.fragment, { allowBlocks: !1 }), p = [...u.issues, ...i(u, { allowAssign: !0, variables: /* @__PURE__ */ new Map([[F, null]]) })];
1531
1530
  if (K(p))
1532
- throw new Q(p.map((b) => ({ ...b, blockRef: s })));
1531
+ throw new Z(p.map((b) => ({ ...b, blockRef: s })));
1533
1532
  return {
1534
1533
  params: Object.freeze(cn(a, f)),
1535
1534
  templates: Tt(n, u.text, [])
1536
1535
  };
1537
1536
  }
1538
1537
  function Tt(t, e, n) {
1539
- W = n;
1538
+ Y = n;
1540
1539
  try {
1541
1540
  return t.parse(e);
1542
1541
  } finally {
1543
- W = null;
1542
+ Y = null;
1544
1543
  }
1545
1544
  }
1546
1545
  const Kn = /^[^\s@<>()[\]\\,;:"]+@[^\s"(),:;<>@[\\\]][^\s"(),.:;<>@[\\\]]*\.[^\s"(),:;<>@[\\\]]+$/, qn = /cid:([^\s"'<>)]+)/g, Gn = Mn();
1547
- async function Pr({ template: t, data: e, context: n, blocks: r, layouts: i, renderer: s = Gn, resolveInlineImage: o, juiceOptions: a, draft: l = !1 } = {}) {
1546
+ async function wr({ template: t, data: e, context: n, blocks: r, layouts: i, renderer: s = Gn, resolveInlineImage: o, juiceOptions: a, draft: l = !1 } = {}) {
1548
1547
  const c = typeof (t == null ? void 0 : t.toObject) == "function" ? t.toObject() : t || {}, { partContent: f } = s.renderTemplate({ blocks: r, context: n, data: e, draft: l, kind: $e, layouts: i, template: c }), u = (T, d) => s.renderContent({
1549
1548
  allowBlocks: !1,
1550
1549
  content: T,
@@ -1556,12 +1555,12 @@ async function Pr({ template: t, data: e, context: n, blocks: r, layouts: i, ren
1556
1555
  if (!(T != null && T.email))
1557
1556
  return null;
1558
1557
  if (h && /\{\{|\{%/.test(T.email))
1559
- throw new v({ message: `${d}.email must be a fixed address.`, partCode: `${d}.email` });
1558
+ throw new j({ message: `${d}.email must be a fixed address.`, partCode: `${d}.email` });
1560
1559
  const E = h ? T.email.trim() : u(T.email, `${d}.email`);
1561
1560
  if (!E)
1562
1561
  return null;
1563
1562
  if (!Kn.test(E))
1564
- throw new v({ message: `${d}.email "${E}" is not a valid email address.`, partCode: `${d}.email` });
1563
+ throw new j({ message: `${d}.email "${E}" is not a valid email address.`, partCode: `${d}.email` });
1565
1564
  const C = T.name ? u(T.name, `${d}.name`) : "";
1566
1565
  return { email: E, ...C ? { name: C } : {} };
1567
1566
  }, b = (T, d) => (Array.isArray(T) ? T : []).map((h, E) => p(typeof h == "string" ? { email: h } : h, `${d}[${E}]`)).filter(Boolean);
@@ -1581,7 +1580,8 @@ async function Pr({ template: t, data: e, context: n, blocks: r, layouts: i, ren
1581
1580
  inlineAttachments: m.map((T) => ({ contentId: T })),
1582
1581
  replyTo: p(c.replyTo, "replyTo"),
1583
1582
  subject: (f.subject || "").replace(/\s+/g, " ").trim(),
1584
- text: f.text ?? null
1583
+ text: f.text ?? null,
1584
+ to: p(c.to, "to", { fixedEmail: !0 })
1585
1585
  };
1586
1586
  }
1587
1587
  const Wn = Object.freeze({
@@ -1709,7 +1709,7 @@ const Wn = Object.freeze({
1709
1709
  version: 2
1710
1710
  });
1711
1711
  function Ir({ modified: t = Date.UTC(2027, 0, 1) } = {}) {
1712
- const e = (n) => Pn.create({ ...n, modified: t }).publish({ modified: t });
1712
+ const e = (n) => wn.create({ ...n, modified: t }).publish({ modified: t });
1713
1713
  return [
1714
1714
  e(Wn).deprecate({ modified: t }),
1715
1715
  e(Hn),
@@ -1717,7 +1717,7 @@ function Ir({ modified: t = Date.UTC(2027, 0, 1) } = {}) {
1717
1717
  e(Xn)
1718
1718
  ];
1719
1719
  }
1720
- const fe = j({
1720
+ const fe = B({
1721
1721
  fields: {
1722
1722
  code: { description: "The recipient's event registration code.", label: "Registration code", type: "string" },
1723
1723
  displayName: { description: "Prefix, first name and last name, for greetings.", label: "Display name", type: "string", value: (t) => [t.prefix, t.firstName, t.lastName].filter(Boolean).join(" ") },
@@ -1729,7 +1729,7 @@ const fe = j({
1729
1729
  description: "Current email recipient values.",
1730
1730
  label: "Recipient",
1731
1731
  projectionCode: "PERSON"
1732
- }), he = j({
1732
+ }), he = B({
1733
1733
  fields: {
1734
1734
  badge: {
1735
1735
  fields: {
@@ -1748,7 +1748,7 @@ const fe = j({
1748
1748
  description: "Current congress or event display information.",
1749
1749
  label: "Event",
1750
1750
  projectionCode: "EVENT"
1751
- }), Qn = j({
1751
+ }), Qn = B({
1752
1752
  fields: {
1753
1753
  amount: { description: "Amount of the line: quantity times unit price.", label: "Amount", type: "number" },
1754
1754
  name: { description: "Name of the item bought.", label: "Item", type: "string", value: (t) => {
@@ -1761,7 +1761,7 @@ const fe = j({
1761
1761
  description: "One line of an invoice.",
1762
1762
  label: "Invoice line",
1763
1763
  projectionCode: "INVOICE_LINE"
1764
- }), Jn = j({
1764
+ }), Jn = B({
1765
1765
  fields: {
1766
1766
  created: { description: "Date the invoice was issued.", label: "Invoice date", type: "date" },
1767
1767
  currencyCode: { description: "Currency code of the invoice, such as AUD.", label: "Currency", type: "string" },
@@ -1773,7 +1773,7 @@ const fe = j({
1773
1773
  description: "Invoice header and number values.",
1774
1774
  label: "Invoice",
1775
1775
  projectionCode: "INVOICE"
1776
- }), Zn = j({
1776
+ }), Zn = B({
1777
1777
  fields: {
1778
1778
  paidAmount: { description: "Amount paid in this payment.", label: "Paid amount", type: "number" },
1779
1779
  paymentDate: { description: "Date the payment was made.", label: "Payment date", type: "date" },
@@ -1784,7 +1784,7 @@ const fe = j({
1784
1784
  description: "Payment result, paid amount and payment details.",
1785
1785
  label: "Payment result",
1786
1786
  projectionCode: "PAYMENT_RESULT"
1787
- }), er = j({
1787
+ }), er = B({
1788
1788
  fields: {
1789
1789
  affiliation: { description: "The author's institution.", label: "Affiliation", type: "string" },
1790
1790
  capacity: { description: "The author's role on the abstract, such as co-author.", label: "Capacity", type: "string" },
@@ -1795,7 +1795,7 @@ const fe = j({
1795
1795
  description: "One author of an abstract.",
1796
1796
  label: "Author",
1797
1797
  projectionCode: "AUTHOR"
1798
- }), tr = j({
1798
+ }), tr = B({
1799
1799
  fields: {
1800
1800
  abstractCode: { description: "Reference ID of the submitted abstract.", label: "Abstract code", type: "string" },
1801
1801
  authors: De(er, { description: "Authors attached to the abstract.", label: "Authors" }),
@@ -1812,7 +1812,7 @@ const fe = j({
1812
1812
  description: "Abstract submission values.",
1813
1813
  label: "Abstract",
1814
1814
  projectionCode: "ABSTRACT"
1815
- }), nr = j({
1815
+ }), nr = B({
1816
1816
  fields: {
1817
1817
  eventRegistrationCode: { description: "Code of the event registration.", label: "Registration code", type: "string" },
1818
1818
  hasBadge: { description: "Whether the registration includes a badge.", label: "Has badge", type: "boolean" },
@@ -1993,11 +1993,11 @@ Line two`,
1993
1993
  RECEIPT: "RECEIPT",
1994
1994
  STORE: "RECEIPT"
1995
1995
  });
1996
- function we(t) {
1996
+ function Pe(t) {
1997
1997
  return ur[t] || null;
1998
1998
  }
1999
1999
  function vr(t) {
2000
- return lr[we(t)] || null;
2000
+ return lr[Pe(t)] || null;
2001
2001
  }
2002
2002
  const dr = Object.freeze([
2003
2003
  {
@@ -2068,7 +2068,7 @@ const pr = Object.freeze({
2068
2068
  }), Br = Object.freeze([pr, mr, fr]), hr = ["mobileWalletBadgePass", "subTemplateGroupName", "templateGroupName"];
2069
2069
  class xr extends Dn {
2070
2070
  constructor(e = {}) {
2071
- e = e || {}, super({ ...e, contextCode: we(e.templateGroupName) || e.contextCode }), this._type = e._type || "TemplateEmailCongress", this.eventShortCode = e.eventShortCode, this.mobileWalletBadgePass = !!e.mobileWalletBadgePass, this.subTemplateGroupName = e.subTemplateGroupName || null, this.templateGroupName = e.templateGroupName;
2071
+ e = e || {}, super({ ...e, contextCode: Pe(e.templateGroupName) || e.contextCode }), this._type = e._type || "TemplateEmailCongress", this.eventShortCode = e.eventShortCode, this.mobileWalletBadgePass = !!e.mobileWalletBadgePass, this.subTemplateGroupName = e.subTemplateGroupName || null, this.templateGroupName = e.templateGroupName;
2072
2072
  }
2073
2073
  static get _classname() {
2074
2074
  return "TemplateEmailCongress";
@@ -2079,7 +2079,7 @@ class xr extends Dn {
2079
2079
  update(e = {}) {
2080
2080
  return hr.forEach((n) => {
2081
2081
  Object.hasOwn(e, n) && (this[n] = n === "mobileWalletBadgePass" ? !!e[n] : e[n]);
2082
- }), Object.hasOwn(e, "templateGroupName") && (this.contextCode = we(e.templateGroupName)), super.update(e);
2082
+ }), Object.hasOwn(e, "templateGroupName") && (this.contextCode = Pe(e.templateGroupName)), super.update(e);
2083
2083
  }
2084
2084
  toObject() {
2085
2085
  return {
@@ -2174,7 +2174,7 @@ export {
2174
2174
  mr as CONGRESS_FOOTER_V1,
2175
2175
  Br as CONGRESS_LAYOUTS,
2176
2176
  dr as CONGRESS_TEMPLATE_FUNCTIONS,
2177
- wt as DataContext,
2177
+ Pt as DataContext,
2178
2178
  Wn as INVOICE_LINES_TABLE_V1,
2179
2179
  Hn as INVOICE_LINES_TABLE_V2,
2180
2180
  tt as LAYOUT_ATTRIBUTE,
@@ -2195,25 +2195,25 @@ export {
2195
2195
  x as TEMPLATE_CONTENT_TYPE,
2196
2196
  $e as TEMPLATE_EMAIL_KIND,
2197
2197
  xn as TEMPLATE_EVALUATION_LIMITS,
2198
- B as TEMPLATE_FIELD_KIND,
2199
- P as TEMPLATE_FIELD_TYPE,
2198
+ v as TEMPLATE_FIELD_KIND,
2199
+ w as TEMPLATE_FIELD_TYPE,
2200
2200
  Ae as TEMPLATE_FRAGMENT_TAGS,
2201
2201
  U as TEMPLATE_FUNCTION_ARG_TYPE,
2202
2202
  y as TEMPLATE_ISSUE_CODE,
2203
- H as TEMPLATE_ISSUE_SEVERITY,
2203
+ X as TEMPLATE_ISSUE_SEVERITY,
2204
2204
  xe as TEMPLATE_KIND_CODE,
2205
2205
  Lr as TEMPLATE_LAYOUT_ACTION_CODE,
2206
2206
  Oe as TEMPLATE_LAYOUT_STATE_CODE,
2207
- Pe as TEMPLATE_SYNTAX_VERSION,
2207
+ we as TEMPLATE_SYNTAX_VERSION,
2208
2208
  st as TEMPLATE_TAGS,
2209
2209
  rn as Template,
2210
- Pn as TemplateBlock,
2210
+ wn as TemplateBlock,
2211
2211
  Dn as TemplateEmail,
2212
2212
  xr as TemplateEmailCongress,
2213
- wr as TemplateLayout,
2213
+ Pr as TemplateLayout,
2214
2214
  et as TemplateProjection,
2215
- v as TemplateRenderError,
2216
- Q as TemplateSyntaxError,
2215
+ j as TemplateRenderError,
2216
+ Z as TemplateSyntaxError,
2217
2217
  or as abstractContext,
2218
2218
  tr as abstractProjection,
2219
2219
  er as authorProjection,
@@ -2222,13 +2222,13 @@ export {
2222
2222
  Nr as checkTemplateContent,
2223
2223
  Rn as checkTemplateLayoutContent,
2224
2224
  gr as clearCustomFunctions,
2225
- we as contextCodeForTemplateGroup,
2225
+ Pe as contextCodeForTemplateGroup,
2226
2226
  vr as contextForTemplateGroup,
2227
2227
  Or as createBlockElement,
2228
2228
  Ir as createCongressBlocks,
2229
2229
  Mn as createTemplateRenderer,
2230
2230
  ue as defineDataContext,
2231
- j as defineTemplateProjection,
2231
+ B as defineTemplateProjection,
2232
2232
  Ar as describeTemplateFilter,
2233
2233
  pe as describeTemplateFunctions,
2234
2234
  Cr as describeTemplateKind,
@@ -2248,16 +2248,16 @@ export {
2248
2248
  _r as layoutElementHtml,
2249
2249
  it as layoutHtmlIssues,
2250
2250
  De as listOf,
2251
- X as normalizeBlockParamDefinitions,
2251
+ J as normalizeBlockParamDefinitions,
2252
2252
  Ft as normalizeTemplateMarkup,
2253
2253
  Yt as parseBlockRef,
2254
- J as parseTemplateContent,
2254
+ ee as parseTemplateContent,
2255
2255
  Zn as paymentResultProjection,
2256
2256
  fe as personProjection,
2257
2257
  cr as receiptContext,
2258
2258
  jr as registerCongressTemplateFunctions,
2259
2259
  Dt as registerTemplateFunction,
2260
- Pr as renderTemplateEmail,
2260
+ wr as renderTemplateEmail,
2261
2261
  lt as resolveBlockParams,
2262
2262
  rt as resolveTemplateLayout,
2263
2263
  de as toDataContextDescriptor