@lipsjs/lips 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +122 -9
  2. package/dist/lips.js +917 -669
  3. package/dist/lips.js.map +15 -12
  4. package/dist/lips.min.js +12 -12
  5. package/dist/lips.min.js.map +15 -12
  6. package/dist/lynx-background.min.js +3 -0
  7. package/dist/lynx-background.min.js.map +13 -0
  8. package/dist/lynx-main.min.js +3 -0
  9. package/dist/lynx-main.min.js.map +11 -0
  10. package/dist/lynx-plugin.mjs +1487 -0
  11. package/dist/lynx.min.js +8 -8
  12. package/dist/lynx.min.js.map +12 -10
  13. package/dist/mf2.min.js.map +1 -1
  14. package/dist/parts.min.js +100 -0
  15. package/dist/parts.min.js.map +19 -0
  16. package/dist/precompile.min.js +15 -15
  17. package/dist/precompile.min.js.map +8 -7
  18. package/dist/runtime.min.js +4 -4
  19. package/dist/runtime.min.js.map +11 -9
  20. package/dist/stylis.min.js.map +1 -1
  21. package/dist/types/component.d.ts +32 -0
  22. package/dist/types/ir/compiler.d.ts +2 -4
  23. package/dist/types/ir/facade.d.ts +63 -12
  24. package/dist/types/ir/host.d.ts +9 -1
  25. package/dist/types/ir/initial.d.ts +16 -0
  26. package/dist/types/ir/router.d.ts +2 -0
  27. package/dist/types/ir/tags.d.ts +16 -0
  28. package/dist/types/lips.d.ts +7 -7
  29. package/dist/types/lynx/a11y.d.ts +1 -0
  30. package/dist/types/lynx/background.d.ts +52 -3
  31. package/dist/types/lynx/components.d.ts +28 -0
  32. package/dist/types/lynx/main.d.ts +9 -5
  33. package/dist/types/lynx/plugin.d.ts +8 -0
  34. package/dist/types/lynx/protocol.d.ts +55 -4
  35. package/dist/types/lynx/style.d.ts +7 -0
  36. package/dist/types/lynx/template.d.ts +6 -0
  37. package/dist/types/lynx.d.ts +1 -0
  38. package/dist/types/parts/combobox.d.ts +40 -0
  39. package/dist/types/parts/date.d.ts +75 -0
  40. package/dist/types/parts/dialog.d.ts +42 -0
  41. package/dist/types/parts/icon.d.ts +31 -0
  42. package/dist/types/parts/layer.d.ts +28 -0
  43. package/dist/types/parts/list.d.ts +45 -0
  44. package/dist/types/parts/menu.d.ts +44 -0
  45. package/dist/types/parts/popover.d.ts +81 -0
  46. package/dist/types/parts/reveal.d.ts +24 -0
  47. package/dist/types/parts/toast.d.ts +36 -0
  48. package/dist/types/parts.d.ts +24 -0
  49. package/dist/types/precompile.d.ts +8 -11
  50. package/dist/types/runtime.d.ts +1 -0
  51. package/dist/types/types.d.ts +188 -57
  52. package/dist/untrusted.min.js +4 -4
  53. package/dist/untrusted.min.js.map +7 -7
  54. package/package.json +24 -3
  55. package/dist/types/i18n/formatters.d.ts +0 -3
package/dist/lips.js CHANGED
@@ -519,13 +519,13 @@ function gen(node) {
519
519
  case "id":
520
520
  return ID_RENAMES[node.name] ?? node.name;
521
521
  case "member": {
522
- const obj = gen(node.obj);
522
+ const obj = link(node.obj);
523
523
  if (node.computed)
524
- return `(${obj})${node.optional ? "?." : ""}[${gen(node.prop)}]`;
525
- return `(${obj})${node.optional ? "?." : "."}${node.prop}`;
524
+ return `${obj}${node.optional ? "?." : ""}[${gen(node.prop)}]`;
525
+ return `${obj}${node.optional ? "?." : "."}${node.prop}`;
526
526
  }
527
527
  case "call":
528
- return `(${gen(node.callee)})${node.optional ? "?." : ""}(${node.args.map(gen).join(",")})`;
528
+ return `${link(node.callee)}${node.optional ? "?." : ""}(${node.args.map(gen).join(",")})`;
529
529
  case "unary":
530
530
  return `(${node.op}(${gen(node.arg)}))`;
531
531
  case "update":
@@ -548,6 +548,7 @@ function gen(node) {
548
548
  return "undefined";
549
549
  }
550
550
  }
551
+ var link = (node) => node.t === "member" || node.t === "call" || node.t === "id" ? gen(node) : `(${gen(node)})`;
551
552
  function genTarget(node) {
552
553
  if (node.t === "id")
553
554
  return ID_RENAMES[node.name] ?? node.name;
@@ -596,6 +597,7 @@ var GLOBALS = {
596
597
  decodeURIComponent,
597
598
  console
598
599
  };
600
+ var ENDED = Symbol("lips.ended");
599
601
  function interpretExpression(ast, env) {
600
602
  const scope = env.scope || Object.create(null);
601
603
  const resolveId = (name, locals) => {
@@ -637,28 +639,10 @@ function interpretExpression(ast, env) {
637
639
  return node.v;
638
640
  case "id":
639
641
  return resolveId(node.name, locals);
640
- case "member": {
641
- const obj = ev(node.obj, locals);
642
- if (node.optional && obj == null)
643
- return;
644
- const prop = node.computed ? ev(node.prop, locals) : node.prop;
645
- return obj?.[prop];
646
- }
642
+ case "member":
647
643
  case "call": {
648
- if (node.callee.t === "member") {
649
- const obj = ev(node.callee.obj, locals);
650
- if ((node.callee.optional || node.optional) && obj == null)
651
- return;
652
- const prop = node.callee.computed ? ev(node.callee.prop, locals) : node.callee.prop;
653
- const fn2 = obj?.[prop];
654
- if (node.optional && fn2 == null)
655
- return;
656
- return fn2.apply(obj, node.args.map((a) => ev(a, locals)));
657
- }
658
- const fn = ev(node.callee, locals);
659
- if (node.optional && fn == null)
660
- return;
661
- return fn(...node.args.map((a) => ev(a, locals)));
644
+ const v = chain(node, locals);
645
+ return v === ENDED ? undefined : v;
662
646
  }
663
647
  case "unary": {
664
648
  const v = ev(node.arg, locals);
@@ -774,6 +758,23 @@ function interpretExpression(ast, env) {
774
758
  return;
775
759
  }
776
760
  };
761
+ const chain = (node, locals) => {
762
+ if (node.t !== "member" && node.t !== "call")
763
+ return ev(node, locals);
764
+ const m = node.t === "member" ? node : node.callee.t === "member" ? node.callee : null;
765
+ let obj, fn;
766
+ if (m) {
767
+ obj = chain(m.obj, locals);
768
+ if (obj === ENDED || m.optional && obj == null)
769
+ return ENDED;
770
+ fn = obj[m.computed ? ev(m.prop, locals) : m.prop];
771
+ if (node === m)
772
+ return fn;
773
+ } else if ((fn = chain(node.callee, locals)) === ENDED)
774
+ return ENDED;
775
+ const call = node;
776
+ return call.optional && fn == null ? ENDED : Reflect.apply(fn, obj, call.args.map((a) => ev(a, locals)));
777
+ };
777
778
  const setTarget = (target, value, locals) => {
778
779
  if (target.t === "id")
779
780
  return assignId(target.name, value, locals);
@@ -1034,6 +1035,7 @@ function reactive(obj, deep = false) {
1034
1035
  if (obj[IS_REACTIVE])
1035
1036
  return obj;
1036
1037
  const sigs = new Map;
1038
+ const [keys, , touchKeys] = signal(0);
1037
1039
  const sigFor = (key, initial) => {
1038
1040
  let s = sigs.get(key);
1039
1041
  if (!s) {
@@ -1053,10 +1055,11 @@ function reactive(obj, deep = false) {
1053
1055
  return target[key];
1054
1056
  },
1055
1057
  set(target, key, value) {
1056
- const prev = target[key];
1058
+ const had = key in target, prev = target[key];
1057
1059
  target[key] = value;
1058
1060
  if (typeof key !== "string")
1059
1061
  return true;
1062
+ had || touchKeys();
1060
1063
  const sig = sigFor(key, value);
1061
1064
  Object.is(prev, value) && isCollection(value) ? sig[2]() : sig[1](value);
1062
1065
  return true;
@@ -1064,9 +1067,15 @@ function reactive(obj, deep = false) {
1064
1067
  has(target, key) {
1065
1068
  return key in target;
1066
1069
  },
1070
+ ownKeys(target) {
1071
+ keys();
1072
+ return Reflect.ownKeys(target);
1073
+ },
1067
1074
  deleteProperty(target, key) {
1075
+ const had = key in target;
1068
1076
  delete target[key];
1069
1077
  typeof key === "string" && sigs.get(key)?.[1](undefined);
1078
+ had && touchKeys();
1070
1079
  return true;
1071
1080
  }
1072
1081
  });
@@ -1074,6 +1083,8 @@ function reactive(obj, deep = false) {
1074
1083
 
1075
1084
  // src/ir/host.ts
1076
1085
  var SKELETONS = new WeakMap;
1086
+ var present = (v) => v !== null;
1087
+ var LIVE = { __proto__: null, value: (v) => v ?? "", checked: present, selected: present };
1077
1088
  var domHost = {
1078
1089
  clone(block) {
1079
1090
  let tpl = SKELETONS.get(block);
@@ -1116,7 +1127,11 @@ var domHost = {
1116
1127
  isElement: (node) => node.nodeType === 1,
1117
1128
  connected: (node) => node.isConnected,
1118
1129
  precedes: (a, b) => !!(a.compareDocumentPosition(b) & 4),
1119
- attr: (el, name, value) => value === null ? el.removeAttribute(name) : el.setAttribute(name, value),
1130
+ attr(el, name, value) {
1131
+ value === null ? el.removeAttribute(name) : el.setAttribute(name, value);
1132
+ const live = LIVE[name];
1133
+ live && name in el && (el[name] = live(value));
1134
+ },
1120
1135
  setText: (node, value) => {
1121
1136
  node.data = value;
1122
1137
  },
@@ -1131,8 +1146,9 @@ var domHost = {
1131
1146
  el.hasAttribute("rel") || el.setAttribute("rel", nsp);
1132
1147
  },
1133
1148
  listen(el, name, fn) {
1134
- el.addEventListener(name, fn);
1135
- return () => el.removeEventListener(name, fn);
1149
+ const type = name.split(".")[0], outside = name.includes(".outside"), at = outside ? document : el, capture = outside || name.includes(".capture"), stop = !outside && name.includes(".stop"), on = (e) => outside && el.contains(e.target) || (stop && e.stopPropagation(), fn(e));
1150
+ at.addEventListener(type, on, capture);
1151
+ return () => at.removeEventListener(type, on, capture);
1136
1152
  },
1137
1153
  keepFocus() {
1138
1154
  const focused = document.activeElement;
@@ -1242,9 +1258,86 @@ var sameLets = (a, ax, b, bx) => {
1242
1258
  return lets(a, ax) === lets(b, bx);
1243
1259
  };
1244
1260
 
1261
+ // src/ir/initial.ts
1262
+ function initial(value, seen = new WeakMap) {
1263
+ if (value === null || typeof value !== "object")
1264
+ return value;
1265
+ const v = value;
1266
+ if (seen.has(v))
1267
+ return seen.get(v);
1268
+ if (Array.isArray(v)) {
1269
+ const out = [];
1270
+ seen.set(v, out);
1271
+ for (const each of v)
1272
+ out.push(initial(each, seen));
1273
+ return out;
1274
+ }
1275
+ if (v instanceof Map) {
1276
+ const out = new Map;
1277
+ seen.set(v, out);
1278
+ v.forEach((each, key) => out.set(initial(key, seen), initial(each, seen)));
1279
+ return out;
1280
+ }
1281
+ if (v instanceof Set) {
1282
+ const out = new Set;
1283
+ seen.set(v, out);
1284
+ v.forEach((each) => out.add(initial(each, seen)));
1285
+ return out;
1286
+ }
1287
+ if (v instanceof Date)
1288
+ return new Date(v.getTime());
1289
+ if (v instanceof RegExp)
1290
+ return new RegExp(v.source, v.flags);
1291
+ if (ArrayBuffer.isView(v))
1292
+ return new v.constructor(v);
1293
+ const proto = Object.getPrototypeOf(v);
1294
+ if (proto !== Object.prototype && proto !== null)
1295
+ return value;
1296
+ const out = Object.create(proto);
1297
+ seen.set(v, out);
1298
+ for (const key of Reflect.ownKeys(v)) {
1299
+ const d = Object.getOwnPropertyDescriptor(v, key);
1300
+ "value" in d && (d.value = initial(d.value, seen));
1301
+ Object.defineProperty(out, key, d);
1302
+ }
1303
+ return out;
1304
+ }
1305
+
1245
1306
  // src/ir/runtime.ts
1246
1307
  var SLOT = Symbol("lips.slot");
1247
1308
  var isSlot = (v) => !!v && typeof v === "object" && v[SLOT] === true;
1309
+ function watchInput(self, input, hooks) {
1310
+ if (!input || typeof self.onInput !== "function")
1311
+ return () => {};
1312
+ let first = true, scheduled = false, live = true;
1313
+ const { dispose } = effect(() => {
1314
+ for (const k of Object.keys(input))
1315
+ input[k];
1316
+ if (first) {
1317
+ first = false;
1318
+ return;
1319
+ }
1320
+ if (scheduled)
1321
+ return;
1322
+ scheduled = true;
1323
+ Promise.resolve().then(() => {
1324
+ scheduled = false;
1325
+ if (!live)
1326
+ return;
1327
+ untrack(() => {
1328
+ try {
1329
+ self.onInput(input);
1330
+ } catch (error) {
1331
+ hooks.onError(error);
1332
+ }
1333
+ });
1334
+ });
1335
+ });
1336
+ return () => {
1337
+ live = false;
1338
+ dispose();
1339
+ };
1340
+ }
1248
1341
  function makeHooks(self) {
1249
1342
  let scheduled = false;
1250
1343
  let isReady = false;
@@ -1316,6 +1409,7 @@ function release(h, rec) {
1316
1409
  }
1317
1410
  function place(h, ref, inst) {
1318
1411
  h.insertAfter(ref, nodesOf(h, inst));
1412
+ PENDING_ATTACH.length && h.connected(ref) && flushAttach();
1319
1413
  return inst;
1320
1414
  }
1321
1415
  var scopeRoots = (h, inst) => nodesOf(h, inst).filter((n) => h.isElement(n));
@@ -1345,7 +1439,22 @@ function destroy(h, inst) {
1345
1439
  for (const n of nodesOf(h, inst))
1346
1440
  h.remove(n, true);
1347
1441
  }
1348
- var applyAttr = (h, el, name, v) => h.attr(el, name, v === false || v == null ? null : v === true ? "" : String(v));
1442
+ var refTo = (benv, node, name, watch) => {
1443
+ const refs = benv.self.refs ||= {};
1444
+ let at = "";
1445
+ const drop = () => {
1446
+ refs[at] === node && delete refs[at];
1447
+ };
1448
+ const eff = watch(() => {
1449
+ drop();
1450
+ refs[at = String(name())] = node;
1451
+ });
1452
+ return () => {
1453
+ eff.dispose();
1454
+ drop();
1455
+ };
1456
+ };
1457
+ var applyAttr = (h, el, name, v) => h.attr(el, name, v == null || v === false && !name.startsWith("aria-") ? null : v === true && !name.startsWith("aria-") ? "" : String(v));
1349
1458
  var defineGetter = (scope, name, get) => Object.defineProperty(scope, name, { get, enumerable: true, configurable: true });
1350
1459
  var SELF = Symbol.for("lips.self");
1351
1460
  var LAYER = Symbol("lips.ctx.layer");
@@ -1522,7 +1631,7 @@ class IRRenderer {
1522
1631
  const [get, set] = signal(undefined);
1523
1632
  defineGetter(scope, name, get);
1524
1633
  const run = this.runner(input.e, block.scope);
1525
- letDisposers.push(effect(() => set(run(benv))).dispose);
1634
+ letDisposers.push(this.guarded(() => set(run(benv))).dispose);
1526
1635
  }
1527
1636
  }
1528
1637
  inst.childHandles[i] = {
@@ -1532,7 +1641,8 @@ class IRRenderer {
1532
1641
  dispose: () => letDisposers.forEach((d) => d())
1533
1642
  };
1534
1643
  });
1535
- inst.bindHandles = block.binds.map((bind, i) => this.bindOne(bind, bindNodes[i], benv, block.scope));
1644
+ const late = (b) => b.t === "attr" && b.name === "value";
1645
+ inst.bindHandles = block.binds.map((bind, i) => late(bind) ? null : this.bindOne(bind, bindNodes[i], benv, block.scope));
1536
1646
  block.blocks.forEach((child, i) => {
1537
1647
  if (child.t === "let")
1538
1648
  return;
@@ -1543,6 +1653,10 @@ class IRRenderer {
1543
1653
  dispose: this.execBlock(child, anchorNodes[i], benv, block.scope)
1544
1654
  };
1545
1655
  });
1656
+ block.binds.forEach((bind, i) => {
1657
+ if (late(bind))
1658
+ inst.bindHandles[i] = this.bindOne(bind, bindNodes[i], benv, block.scope);
1659
+ });
1546
1660
  return inst;
1547
1661
  }
1548
1662
  bindOne(bind, node, benv, scopeNames, reuseText) {
@@ -1571,14 +1685,16 @@ class IRRenderer {
1571
1685
  }
1572
1686
  case "prop": {
1573
1687
  const run = this.runner(bind.e, scopeNames);
1688
+ if (bind.name === "ref")
1689
+ return { bind, node, dispose: refTo(benv, node, () => run(benv), (fn) => this.guarded(fn)) };
1574
1690
  if (bind.name === "format") {
1575
1691
  const ref = bind.ref || "";
1576
- const eff2 = this.guarded(() => {
1692
+ const eff = this.guarded(() => {
1577
1693
  const params = run(benv);
1578
1694
  const text = this.options.i18n?.format(ref, params, benv.lang?.());
1579
1695
  h.content(node, text == null ? "" : String(text));
1580
1696
  });
1581
- return { bind, node, dispose: eff2.dispose };
1697
+ return { bind, node, dispose: eff.dispose };
1582
1698
  }
1583
1699
  const eff = this.guarded(() => {
1584
1700
  const v = run(benv);
@@ -1667,7 +1783,7 @@ class IRRenderer {
1667
1783
  const runs = child.branches.map((b) => b.when != null ? this.runner(b.when, scopeNames) : null);
1668
1784
  let current = null;
1669
1785
  let activeIdx = -2;
1670
- const eff = effect(() => {
1786
+ const eff = this.guarded(() => {
1671
1787
  let idx = -1;
1672
1788
  for (let i = 0;i < child.branches.length; i++) {
1673
1789
  const run = runs[i];
@@ -1698,7 +1814,7 @@ class IRRenderer {
1698
1814
  const caseRuns = child.cases.map((c) => c.is && ("e" in c.is) ? this.runner(c.is.e, scopeNames) : null);
1699
1815
  let current = null;
1700
1816
  let activeIdx = -2;
1701
- const eff = effect(() => {
1817
+ const eff = this.guarded(() => {
1702
1818
  const value = onRun(benv);
1703
1819
  let idx = -1, defaultIdx = -1;
1704
1820
  for (let i = 0;i < child.cases.length; i++) {
@@ -1751,7 +1867,7 @@ class IRRenderer {
1751
1867
  return { kind: "value", name: s.name, value: () => run(benv) };
1752
1868
  });
1753
1869
  let prevKeys = new Set;
1754
- disposers.push(effect(() => {
1870
+ disposers.push(this.guarded(() => {
1755
1871
  const next = {};
1756
1872
  for (const r of runners) {
1757
1873
  if (r.kind === "spread") {
@@ -1797,8 +1913,13 @@ class IRRenderer {
1797
1913
  }
1798
1914
  current = place(h, anchor, this.renderBlock(isArm ? arm.block : arm, { ...benv, scope: scope2 }));
1799
1915
  };
1800
- const eff = effect(() => {
1801
- const p = awaitRun(benv);
1916
+ const eff = this.guarded(() => {
1917
+ let p;
1918
+ try {
1919
+ p = awaitRun(benv);
1920
+ } catch (error) {
1921
+ p = Promise.reject(error);
1922
+ }
1802
1923
  const my = ++token;
1803
1924
  untrack(() => {
1804
1925
  child.loading ? swapTo(child.loading) : swapTo(undefined);
@@ -1823,7 +1944,7 @@ class IRRenderer {
1823
1944
  if ("lit" in input)
1824
1945
  continue;
1825
1946
  const run = this.runner(input.e, scopeNames);
1826
- disposers.push(effect(() => set(run(benv))).dispose);
1947
+ disposers.push(this.guarded(() => set(run(benv))).dispose);
1827
1948
  }
1828
1949
  let lang = benv.lang;
1829
1950
  if (child.lang) {
@@ -1833,7 +1954,7 @@ class IRRenderer {
1833
1954
  } else {
1834
1955
  const [get, set] = signal(undefined);
1835
1956
  const run = this.runner(child.lang.e, scopeNames);
1836
- disposers.push(effect(() => set(run(benv))).dispose);
1957
+ disposers.push(this.guarded(() => set(run(benv))).dispose);
1837
1958
  lang = () => get() ?? benv.lang?.();
1838
1959
  }
1839
1960
  }
@@ -1843,7 +1964,7 @@ class IRRenderer {
1843
1964
  }
1844
1965
  case "log": {
1845
1966
  const segs = splitTopLevel(this.ir.exprs[child.e]).map((s) => this.srcRunner(s, scopeNames));
1846
- disposers.push(effect(() => console.log(...segs.map((run) => run(benv)))).dispose);
1967
+ disposers.push(this.guarded(() => console.log(...segs.map((run) => run(benv)))).dispose);
1847
1968
  break;
1848
1969
  }
1849
1970
  case "comp": {
@@ -1855,7 +1976,7 @@ class IRRenderer {
1855
1976
  const tagRun = this.runner(child.tag, scopeNames);
1856
1977
  let inner = [];
1857
1978
  let activeVerb = Symbol("init");
1858
- const eff = effect(() => {
1979
+ const eff = this.guarded(() => {
1859
1980
  const verb = tagRun(benv);
1860
1981
  if (verb === activeVerb)
1861
1982
  return;
@@ -1867,10 +1988,12 @@ class IRRenderer {
1867
1988
  if (verb == null)
1868
1989
  return;
1869
1990
  if (isSlot(verb)) {
1870
- const argvalues = {};
1871
- for (const [name, ci] of Object.entries(child.inputs))
1872
- argvalues[name] = "lit" in ci ? ci.lit : this.runner(ci.e, scopeNames)(benv);
1873
- const slotInst = place(h, anchor, verb.render(argvalues));
1991
+ const args = {};
1992
+ for (const [name, ci] of Object.entries(child.inputs)) {
1993
+ const run = "lit" in ci ? undefined : this.runner(ci.e, scopeNames);
1994
+ args[name] = run ? () => run(benv) : () => ci.lit;
1995
+ }
1996
+ const slotInst = place(h, anchor, verb.render(args, benv));
1874
1997
  inner.push(() => destroy(h, slotInst));
1875
1998
  return;
1876
1999
  }
@@ -1926,7 +2049,7 @@ class IRRenderer {
1926
2049
  return Object.entries(src).map(([k, v], i) => ({ key: k, values: [k, v, i] }));
1927
2050
  return [];
1928
2051
  };
1929
- const eff = effect(() => {
2052
+ const eff = this.guarded(() => {
1930
2053
  const next = tuples();
1931
2054
  untrack(() => {
1932
2055
  const seen = new Set;
@@ -1986,12 +2109,12 @@ class IRRenderer {
1986
2109
  input[name] = ci.lit;
1987
2110
  else {
1988
2111
  const run = this.runner(ci.e, scopeNames);
1989
- wiring.push(effect(() => input[name] = run(benv)).dispose);
2112
+ wiring.push(this.guarded(() => input[name] = run(benv)).dispose);
1990
2113
  }
1991
2114
  }
1992
2115
  for (const e of child.spreads) {
1993
2116
  const run = this.runner(e, scopeNames);
1994
- wiring.push(effect(() => {
2117
+ wiring.push(this.guarded(() => {
1995
2118
  const obj = run(benv) || {};
1996
2119
  untrack(() => Object.entries(obj).forEach(([k, v]) => {
1997
2120
  written?.add(k);
@@ -2012,13 +2135,12 @@ class IRRenderer {
2012
2135
  return {
2013
2136
  [SLOT]: true,
2014
2137
  args: contents.args,
2015
- render(argvalues) {
2138
+ render(args, at) {
2016
2139
  const scope = Object.create(penv.scope ?? null);
2017
- contents.args.forEach((name) => {
2018
- const [get] = signal(argvalues?.[name]);
2019
- defineGetter(scope, name, get);
2020
- });
2021
- return parent.renderBlock(contents.block, { ...penv, scope });
2140
+ contents.args.forEach((name) => defineGetter(scope, name, args?.[name] ?? (() => {
2141
+ return;
2142
+ })));
2143
+ return parent.renderBlock(contents.block, at ? { ...penv, scope, context: at.context, lang: at.lang } : { ...penv, scope });
2022
2144
  }
2023
2145
  };
2024
2146
  }
@@ -2034,10 +2156,10 @@ class IRRenderer {
2034
2156
  this.wireEvents(child.events, benv, scopeNames, rec.self, wiring);
2035
2157
  rec.wiring = wiring;
2036
2158
  rec.anchor = anchor;
2037
- const gen2 = rec.gen;
2159
+ const gen = rec.gen;
2038
2160
  place(this.h, anchor, rec.inst);
2039
2161
  disposers.push(() => {
2040
- if (gen2 !== rec.gen)
2162
+ if (gen !== rec.gen)
2041
2163
  return;
2042
2164
  for (const d of rec.wiring)
2043
2165
  d();
@@ -2053,7 +2175,7 @@ class IRRenderer {
2053
2175
  this.wireInputs(child, benv, scopeNames, input, wiring);
2054
2176
  if (child.contents)
2055
2177
  input.renderer = this.slotRenderer(child.contents, benv);
2056
- const state = reactive({ ...def.state || {} }, def.deep ?? false);
2178
+ const state = reactive(initial(def.state || {}), def.deep ?? false), statics = initial(def.statics ?? {});
2057
2179
  let selfInst = null;
2058
2180
  const irr = this;
2059
2181
  const bus = selfBus(this.h, () => benv.lang?.() ?? irr.options.i18n?.lang() ?? "");
@@ -2061,8 +2183,9 @@ class IRRenderer {
2061
2183
  ...this.options.expose || {},
2062
2184
  state,
2063
2185
  input,
2064
- static: def.statics,
2186
+ static: statics,
2065
2187
  context: benv.context,
2188
+ refs: {},
2066
2189
  setContext(arg, value) {
2067
2190
  const write = (k, v) => writeContext(benv.context, k, v, irr.options.expose?.setContext);
2068
2191
  typeof arg === "string" ? write(arg, value) : Object.entries(arg || {}).forEach(([k, v]) => write(k, v));
@@ -2081,12 +2204,13 @@ class IRRenderer {
2081
2204
  } catch (error) {
2082
2205
  hooks.onError(error);
2083
2206
  }
2207
+ const unwatchInput = watchInput(self, input, hooks);
2084
2208
  const cenv = {
2085
2209
  state,
2086
2210
  input,
2087
2211
  context: benv.context,
2088
2212
  lang: benv.lang,
2089
- static: def.statics,
2213
+ static: statics,
2090
2214
  self,
2091
2215
  scope: undefined
2092
2216
  };
@@ -2157,6 +2281,7 @@ class IRRenderer {
2157
2281
  const i = this.live.indexOf(rec);
2158
2282
  i > -1 && this.live.splice(i, 1);
2159
2283
  unwatchContext?.();
2284
+ unwatchInput();
2160
2285
  clearStyleBinds?.();
2161
2286
  clearStyles?.();
2162
2287
  destroy(this.h, inst);
@@ -2173,9 +2298,9 @@ class IRRenderer {
2173
2298
  }
2174
2299
  };
2175
2300
  this.live.push(rec);
2176
- const gen2 = rec.gen;
2301
+ const gen = rec.gen;
2177
2302
  disposers.push(() => {
2178
- if (gen2 !== rec.gen)
2303
+ if (gen !== rec.gen)
2179
2304
  return;
2180
2305
  for (const d of rec.wiring)
2181
2306
  d();
@@ -2186,11 +2311,16 @@ class IRRenderer {
2186
2311
  execElement(child, anchor, benv, scopeNames, disposers) {
2187
2312
  const h = this.h, el = h.element(child.name);
2188
2313
  for (const [name, ci] of Object.entries(child.inputs)) {
2189
- if ("lit" in ci)
2314
+ if (name === "@ref") {
2315
+ const run = "lit" in ci ? () => ci.lit : this.runner(ci.e, scopeNames);
2316
+ disposers.push(refTo(benv, el, () => run(benv), (fn) => this.guarded(fn)));
2317
+ } else if (name[0] === "@")
2318
+ disposers.push(this.contentOf(el, name, ci, benv, scopeNames));
2319
+ else if ("lit" in ci)
2190
2320
  applyAttr(h, el, name, ci.lit);
2191
2321
  else {
2192
2322
  const run = this.runner(ci.e, scopeNames);
2193
- disposers.push(effect(() => applyAttr(h, el, name, run(benv))).dispose);
2323
+ disposers.push(this.guarded(() => applyAttr(h, el, name, run(benv))).dispose);
2194
2324
  }
2195
2325
  }
2196
2326
  for (const ev of child.events)
@@ -2204,38 +2334,59 @@ class IRRenderer {
2204
2334
  h.insertAfter(anchor, [el]);
2205
2335
  disposers.push(() => h.remove(el, true));
2206
2336
  }
2337
+ contentOf(el, name, ci, benv, scopeNames) {
2338
+ const h = this.h;
2339
+ if (name === "@format") {
2340
+ const { ref, e } = "lit" in ci ? ci.lit : {};
2341
+ const run = e === undefined ? () => ({}) : this.runner(e, scopeNames);
2342
+ return this.guarded(() => {
2343
+ const text = this.options.i18n?.format(ref || "", run(benv), benv.lang?.());
2344
+ h.content(el, text == null ? "" : String(text));
2345
+ }).dispose;
2346
+ }
2347
+ const run = "lit" in ci ? () => ci.lit : this.runner(ci.e, scopeNames);
2348
+ return this.guarded(() => {
2349
+ const v = run(benv), s = v == null ? "" : String(v);
2350
+ name === "@html" && h.html ? h.html(el, s) : h.content(el, s);
2351
+ }).dispose;
2352
+ }
2207
2353
  eventDispatcher(instruction, scopeNames, benv) {
2208
- const segs = splitTopLevel(instruction);
2354
+ const segs = splitTopLevel(instruction), named = /^[A-Za-z_$][\w$]*$/.test(segs[0] || "") && !scopeNames.includes(segs[0]);
2209
2355
  return (...params) => untrack(() => {
2210
2356
  const resolveFn = (src) => {
2211
- let v;
2357
+ if (named && benv.self && !this.options.guard?.self(src) && typeof benv.self[src] === "function")
2358
+ return benv.self[src];
2212
2359
  try {
2213
- v = this.srcRunner(src, scopeNames)(benv);
2360
+ return this.srcRunner(src, scopeNames)(benv);
2214
2361
  } catch (e) {
2215
- v = undefined;
2362
+ return;
2216
2363
  }
2217
- if (typeof v !== "function" && benv.self && !this.options.guard?.self(src) && typeof benv.self[src] === "function")
2218
- v = benv.self[src];
2219
- return v;
2220
2364
  };
2221
2365
  if (!segs.length)
2222
2366
  return;
2223
2367
  const fn = resolveFn(segs[0]);
2224
2368
  if (typeof fn !== "function")
2225
2369
  return;
2226
- const args = segs.slice(1).map((src) => this.srcRunner(src, scopeNames)(benv));
2227
- fn(...args, ...params);
2370
+ const failed = (error) => this.hooks ? this.hooks.onError(error) : console.error("[lips:ir]", error);
2371
+ try {
2372
+ const args = segs.slice(1).map((src) => this.srcRunner(src, scopeNames)(benv));
2373
+ const out = fn(...args, ...params);
2374
+ out && typeof out.then === "function" && out.then(undefined, failed);
2375
+ } catch (error) {
2376
+ failed(error);
2377
+ }
2228
2378
  });
2229
2379
  }
2230
2380
  }
2231
2381
  function renderIR(ir, setup = {}, options = {}) {
2232
- const h = options.host || domHost, state = reactive(setup.state || {}, setup.deep ?? false), input = setup.input ? reactive(setup.input, setup.deep ?? false) : undefined;
2382
+ const h = options.host || domHost, state = reactive(setup.state || {}, setup.deep ?? false), input = reactive(setup.input || {}, setup.deep ?? false), statics = setup.static || {};
2233
2383
  let rootInst = null;
2234
2384
  const bus = selfBus(h, () => options.i18n?.lang() ?? "");
2235
2385
  const self = bus.bind(Object.assign(Object.create(bus.proto), {
2236
2386
  state,
2237
2387
  input,
2238
- static: setup.static,
2388
+ static: statics,
2389
+ refs: {},
2239
2390
  ...options.expose || {},
2240
2391
  ...setup.expose || {}
2241
2392
  }), () => rootInst);
@@ -2244,7 +2395,7 @@ function renderIR(ir, setup = {}, options = {}) {
2244
2395
  state,
2245
2396
  input,
2246
2397
  context: setup.context,
2247
- static: setup.static,
2398
+ static: statics,
2248
2399
  self,
2249
2400
  scope: undefined
2250
2401
  };
@@ -2255,10 +2406,11 @@ function renderIR(ir, setup = {}, options = {}) {
2255
2406
  hooks.onError(error);
2256
2407
  }
2257
2408
  try {
2258
- input && Object.keys(input).length && typeof self.onInput === "function" && self.onInput(input);
2409
+ Object.keys(input).length && typeof self.onInput === "function" && self.onInput(input);
2259
2410
  } catch (error) {
2260
2411
  hooks.onError(error);
2261
2412
  }
2413
+ const unwatchInput = watchInput(self, input, hooks);
2262
2414
  let renderer = new IRRenderer(ir, options, hooks);
2263
2415
  let current = renderer.renderBlock(ir.root, env);
2264
2416
  rootInst = current;
@@ -2311,6 +2463,7 @@ function renderIR(ir, setup = {}, options = {}) {
2311
2463
  return { changes, salvaged: renderer.salvaged };
2312
2464
  },
2313
2465
  dispose() {
2466
+ unwatchInput();
2314
2467
  clearStyleBinds?.();
2315
2468
  clearStyles?.();
2316
2469
  destroy(h, current);
@@ -2545,7 +2698,11 @@ var BUILTINS = {};
2545
2698
  function registerBuiltin(name, template) {
2546
2699
  BUILTINS[name] = template;
2547
2700
  }
2548
- var RESERVED_MEMBERS = new Set([
2701
+ var TAKEN = null;
2702
+ function setNameCheck(fn) {
2703
+ TAKEN = fn;
2704
+ }
2705
+ var RESERVED = [
2549
2706
  "state",
2550
2707
  "input",
2551
2708
  "static",
@@ -2564,7 +2721,8 @@ var RESERVED_MEMBERS = new Set([
2564
2721
  "replaceWith",
2565
2722
  "render",
2566
2723
  "swap"
2567
- ]);
2724
+ ];
2725
+ var RESERVED_MEMBERS = new Set(RESERVED);
2568
2726
  function guardHandlers(handler) {
2569
2727
  if (!handler)
2570
2728
  return;
@@ -2586,14 +2744,14 @@ class IRFacadeComponent extends Events {
2586
2744
  this.lips = lips;
2587
2745
  this.template = template;
2588
2746
  const handlers = guardHandlers(template.handler);
2589
- this.state = reactive({ ...template.state || {} }, true);
2590
- const inputR = input ? reactive({ ...input }, true) : undefined;
2747
+ this.state = reactive(initial(template.state || {}), true);
2748
+ const inputR = reactive({ ...input }, true);
2591
2749
  const emitExternal = (event, ...args) => super.emit(event, ...args);
2592
2750
  this.instance = renderIR(ir, {
2593
2751
  state: this.state,
2594
2752
  input: inputR,
2595
2753
  context: lips.getContext(),
2596
- static: template.static ?? template._static,
2754
+ static: initial(template.static ?? template._static),
2597
2755
  handlers,
2598
2756
  deep: true,
2599
2757
  stylesheet: lips.styleFor(name, template),
@@ -2606,7 +2764,7 @@ class IRFacadeComponent extends Events {
2606
2764
  context: lips.getContext()
2607
2765
  }
2608
2766
  }, options);
2609
- const watched = template.watchContext ?? template.context;
2767
+ const watched = template.watchContext;
2610
2768
  if (watched?.length && typeof handlers?.onContext === "function")
2611
2769
  this.contextWatcher = lips.watchContext(watched, () => {
2612
2770
  try {
@@ -2646,6 +2804,7 @@ class IRLips {
2646
2804
  config;
2647
2805
  debug;
2648
2806
  store = new Map;
2807
+ plugins = new Map;
2649
2808
  irCache = new WeakMap;
2650
2809
  defCache = new WeakMap;
2651
2810
  styleCache = new WeakMap;
@@ -2686,9 +2845,30 @@ class IRLips {
2686
2845
  });
2687
2846
  }
2688
2847
  register(name, template) {
2848
+ const is = TAKEN?.(name);
2849
+ if (is)
2850
+ throw new Error(`[lips] <${name}> is ${is}: the compiler reads the tag as one, so a component of that name never renders. Register it under another name`);
2851
+ guardHandlers(template.handler);
2689
2852
  this.store.set(name, template);
2690
2853
  return this;
2691
2854
  }
2855
+ use(plugin, options) {
2856
+ const had = this.plugins.get(plugin.name);
2857
+ if (had && had !== plugin)
2858
+ throw new Error(`[lips] two plugins named <${plugin.name}>: one is installed already`);
2859
+ if (had)
2860
+ return this;
2861
+ this.plugins.set(plugin.name, plugin);
2862
+ plugin.requires?.forEach((each) => this.use(each));
2863
+ for (const [name, template] of Object.entries(plugin.components || {})) {
2864
+ const held = this.store.get(name);
2865
+ if (held && held !== template)
2866
+ throw new Error(`[lips] <${name}> of plugin <${plugin.name}> is registered already, by something else`);
2867
+ this.register(name, template);
2868
+ }
2869
+ plugin.install?.(this, options);
2870
+ return this;
2871
+ }
2692
2872
  unregister(name) {
2693
2873
  this.store.delete(name);
2694
2874
  return this;
@@ -2732,6 +2912,13 @@ class IRLips {
2732
2912
  }
2733
2913
  return style;
2734
2914
  }
2915
+ unnamed(template) {
2916
+ let name = this.anonymous.get(template);
2917
+ !name && this.anonymous.set(template, name = `dynamic-${++this.anonymousCount}`);
2918
+ return name;
2919
+ }
2920
+ anonymous = new WeakMap;
2921
+ anonymousCount = 0;
2735
2922
  defFor(name, template) {
2736
2923
  let def = this.defCache.get(template);
2737
2924
  if (!def) {
@@ -2739,7 +2926,7 @@ class IRLips {
2739
2926
  ir: this.compile(template),
2740
2927
  state: template.state,
2741
2928
  statics: template.static ?? template._static,
2742
- context: template.watchContext ?? template.context,
2929
+ context: template.watchContext,
2743
2930
  stylesheet: this.styleFor(name, template),
2744
2931
  nsp: name,
2745
2932
  handlers: guardHandlers(template.handler),
@@ -2753,7 +2940,7 @@ class IRLips {
2753
2940
  const options = {
2754
2941
  mode: this.config?.mode,
2755
2942
  components: this.componentsProxy,
2756
- resolveTemplate: (value) => value && (typeof value.default === "string" || value.ir) ? this.defFor(value.name || "dynamic", value) : undefined,
2943
+ resolveTemplate: (value) => value && (typeof value.default === "string" || value.ir) ? this.defFor(value.name || this.unnamed(value), value) : undefined,
2757
2944
  expose: {
2758
2945
  setContext: (arg, value) => this.setContext(arg, value),
2759
2946
  setLanguage: (lang) => this.setLanguage(lang)
@@ -2779,9 +2966,10 @@ class IRLips {
2779
2966
  return new IRFacadeComponent(this, name, template, input, this.compile(template), this.u ? this.u.runtime(options) : options);
2780
2967
  }
2781
2968
  root(template, selector) {
2782
- this.__root = this.render("__ROOT__", template);
2783
- this.__root.appendTo(selector);
2784
- return this.__root;
2969
+ const root = this.render("__ROOT__", template);
2970
+ this.__root = root;
2971
+ root.appendTo(selector);
2972
+ return root;
2785
2973
  }
2786
2974
  setLanguage(lang) {
2787
2975
  this.i18n.lang = lang;
@@ -2829,6 +3017,162 @@ class IRLips {
2829
3017
  }
2830
3018
  }
2831
3019
 
3020
+ // src/ir/tags.ts
3021
+ var CONTROL_TAGS = new Set([
3022
+ "if",
3023
+ "else-if",
3024
+ "else",
3025
+ "for",
3026
+ "switch",
3027
+ "async",
3028
+ "let",
3029
+ "const",
3030
+ "log",
3031
+ "context",
3032
+ "i18n"
3033
+ ]);
3034
+ var ARM_TAGS = new Set(["case", "default", "then", "catch", "loading"]);
3035
+ var HTML_TAGS = new Set([
3036
+ "a",
3037
+ "abbr",
3038
+ "address",
3039
+ "area",
3040
+ "article",
3041
+ "aside",
3042
+ "audio",
3043
+ "b",
3044
+ "base",
3045
+ "bdi",
3046
+ "bdo",
3047
+ "blockquote",
3048
+ "body",
3049
+ "br",
3050
+ "button",
3051
+ "canvas",
3052
+ "caption",
3053
+ "cite",
3054
+ "code",
3055
+ "col",
3056
+ "colgroup",
3057
+ "data",
3058
+ "datalist",
3059
+ "dd",
3060
+ "del",
3061
+ "details",
3062
+ "dfn",
3063
+ "dialog",
3064
+ "div",
3065
+ "dl",
3066
+ "dt",
3067
+ "em",
3068
+ "embed",
3069
+ "fieldset",
3070
+ "figcaption",
3071
+ "figure",
3072
+ "footer",
3073
+ "form",
3074
+ "h1",
3075
+ "h2",
3076
+ "h3",
3077
+ "h4",
3078
+ "h5",
3079
+ "h6",
3080
+ "head",
3081
+ "header",
3082
+ "hgroup",
3083
+ "hr",
3084
+ "html",
3085
+ "i",
3086
+ "iframe",
3087
+ "img",
3088
+ "input",
3089
+ "ins",
3090
+ "kbd",
3091
+ "label",
3092
+ "legend",
3093
+ "li",
3094
+ "link",
3095
+ "main",
3096
+ "map",
3097
+ "mark",
3098
+ "menu",
3099
+ "meta",
3100
+ "meter",
3101
+ "nav",
3102
+ "noscript",
3103
+ "object",
3104
+ "ol",
3105
+ "optgroup",
3106
+ "option",
3107
+ "output",
3108
+ "p",
3109
+ "picture",
3110
+ "pre",
3111
+ "progress",
3112
+ "q",
3113
+ "rp",
3114
+ "rt",
3115
+ "ruby",
3116
+ "s",
3117
+ "samp",
3118
+ "script",
3119
+ "section",
3120
+ "select",
3121
+ "slot",
3122
+ "small",
3123
+ "source",
3124
+ "span",
3125
+ "strong",
3126
+ "style",
3127
+ "sub",
3128
+ "summary",
3129
+ "sup",
3130
+ "table",
3131
+ "tbody",
3132
+ "td",
3133
+ "template",
3134
+ "textarea",
3135
+ "tfoot",
3136
+ "th",
3137
+ "thead",
3138
+ "time",
3139
+ "title",
3140
+ "tr",
3141
+ "track",
3142
+ "u",
3143
+ "ul",
3144
+ "var",
3145
+ "video",
3146
+ "wbr",
3147
+ "svg",
3148
+ "circle",
3149
+ "clippath",
3150
+ "defs",
3151
+ "ellipse",
3152
+ "foreignobject",
3153
+ "g",
3154
+ "image",
3155
+ "line",
3156
+ "lineargradient",
3157
+ "marker",
3158
+ "mask",
3159
+ "path",
3160
+ "pattern",
3161
+ "polygon",
3162
+ "polyline",
3163
+ "radialgradient",
3164
+ "rect",
3165
+ "stop",
3166
+ "symbol",
3167
+ "text",
3168
+ "tspan",
3169
+ "use"
3170
+ ]);
3171
+ function taken(name) {
3172
+ const tag = name.toLowerCase();
3173
+ return HTML_TAGS.has(tag) ? "an HTML or SVG element" : CONTROL_TAGS.has(tag) || ARM_TAGS.has(tag) || tag === "macro" ? "a template syntax tag" : undefined;
3174
+ }
3175
+
2832
3176
  // src/i18n/intl.ts
2833
3177
  var g = globalThis;
2834
3178
  var I = g.Intl ??= {};
@@ -2956,7 +3300,7 @@ var whitespaceChars = new Set(`
2956
3300
  \r  `);
2957
3301
  var pos;
2958
3302
  var source;
2959
- var MissingSyntax = (pos2, expected) => new MessageSyntaxError("missing-syntax", pos2, pos2 + expected.length, expected);
3303
+ var MissingSyntax = (pos, expected) => new MessageSyntaxError("missing-syntax", pos, pos + expected.length, expected);
2960
3304
  var SyntaxError = (...args) => new MessageSyntaxError(...args);
2961
3305
  function expect(searchString, consume) {
2962
3306
  if (source.startsWith(searchString, pos)) {
@@ -3026,12 +3370,12 @@ function pattern(quoted) {
3026
3370
  else
3027
3371
  throw MissingSyntax(pos, "{{");
3028
3372
  }
3029
- const pattern2 = [];
3373
+ const pattern = [];
3030
3374
  loop:
3031
3375
  while (pos < source.length) {
3032
3376
  switch (source[pos]) {
3033
3377
  case "{": {
3034
- pattern2.push(expression(true));
3378
+ pattern.push(expression(true));
3035
3379
  break;
3036
3380
  }
3037
3381
  case "}":
@@ -3039,7 +3383,7 @@ function pattern(quoted) {
3039
3383
  throw SyntaxError("parse-error", pos);
3040
3384
  break loop;
3041
3385
  default: {
3042
- pattern2.push(text());
3386
+ pattern.push(text());
3043
3387
  }
3044
3388
  }
3045
3389
  }
@@ -3049,20 +3393,20 @@ function pattern(quoted) {
3049
3393
  else
3050
3394
  throw MissingSyntax(pos, "}}");
3051
3395
  }
3052
- return pattern2;
3396
+ return pattern;
3053
3397
  }
3054
3398
  function declarations() {
3055
- const declarations2 = [];
3399
+ const declarations = [];
3056
3400
  ws();
3057
3401
  loop:
3058
3402
  while (source[pos] === ".") {
3059
3403
  const keyword = source.substr(pos, 6);
3060
3404
  switch (keyword) {
3061
3405
  case ".input":
3062
- declarations2.push(inputDeclaration());
3406
+ declarations.push(inputDeclaration());
3063
3407
  break;
3064
3408
  case ".local":
3065
- declarations2.push(localDeclaration());
3409
+ declarations.push(localDeclaration());
3066
3410
  break;
3067
3411
  case ".match":
3068
3412
  break loop;
@@ -3071,7 +3415,7 @@ function declarations() {
3071
3415
  }
3072
3416
  ws();
3073
3417
  }
3074
- return declarations2;
3418
+ return declarations;
3075
3419
  }
3076
3420
  function inputDeclaration() {
3077
3421
  pos += 6;
@@ -3156,7 +3500,7 @@ function expression(allowMarkup) {
3156
3500
  }
3157
3501
  function options() {
3158
3502
  ws("/}");
3159
- const options2 = {};
3503
+ const options = {};
3160
3504
  let isEmpty = true;
3161
3505
  while (pos < source.length) {
3162
3506
  const next = source[pos];
@@ -3164,40 +3508,40 @@ function options() {
3164
3508
  break;
3165
3509
  const start = pos;
3166
3510
  const name_ = identifier();
3167
- if (Object.hasOwn(options2, name_)) {
3511
+ if (Object.hasOwn(options, name_)) {
3168
3512
  throw SyntaxError("duplicate-option-name", start, pos);
3169
3513
  }
3170
3514
  ws();
3171
3515
  expect("=", true);
3172
3516
  ws();
3173
- options2[name_] = value(true);
3517
+ options[name_] = value(true);
3174
3518
  isEmpty = false;
3175
3519
  ws("/}");
3176
3520
  }
3177
- return isEmpty ? null : options2;
3521
+ return isEmpty ? null : options;
3178
3522
  }
3179
3523
  function attributes() {
3180
- const attributes2 = {};
3524
+ const attributes = {};
3181
3525
  let isEmpty = true;
3182
3526
  while (source[pos] === "@") {
3183
3527
  const start = pos;
3184
3528
  pos += 1;
3185
3529
  const name_ = identifier();
3186
- if (Object.hasOwn(attributes2, name_)) {
3530
+ if (Object.hasOwn(attributes, name_)) {
3187
3531
  throw SyntaxError("duplicate-attribute", start, pos);
3188
3532
  }
3189
3533
  ws("=/}");
3190
3534
  if (source[pos] === "=") {
3191
3535
  pos += 1;
3192
3536
  ws();
3193
- attributes2[name_] = literal(true);
3537
+ attributes[name_] = literal(true);
3194
3538
  ws("/}");
3195
3539
  } else {
3196
- attributes2[name_] = true;
3540
+ attributes[name_] = true;
3197
3541
  }
3198
3542
  isEmpty = false;
3199
3543
  }
3200
- return isEmpty ? null : attributes2;
3544
+ return isEmpty ? null : attributes;
3201
3545
  }
3202
3546
  function text() {
3203
3547
  let value = "";
@@ -3233,34 +3577,34 @@ function variable() {
3233
3577
  function literal(required) {
3234
3578
  if (source[pos] === "|")
3235
3579
  return quotedLiteral();
3236
- const value2 = parseUnquotedLiteralValue(source, pos);
3237
- if (!value2) {
3580
+ const value = parseUnquotedLiteralValue(source, pos);
3581
+ if (!value) {
3238
3582
  if (required)
3239
3583
  throw SyntaxError("empty-token", pos);
3240
3584
  else
3241
3585
  return;
3242
3586
  }
3243
- pos += value2.length;
3244
- return { type: "literal", value: value2 };
3587
+ pos += value.length;
3588
+ return { type: "literal", value };
3245
3589
  }
3246
3590
  function quotedLiteral() {
3247
3591
  pos += 1;
3248
- let value2 = "";
3592
+ let value = "";
3249
3593
  for (let i = pos;i < source.length; ++i) {
3250
3594
  switch (source[i]) {
3251
3595
  case "\\": {
3252
3596
  const esc = source[i + 1];
3253
3597
  if (!"\\{|}".includes(esc))
3254
3598
  throw SyntaxError("bad-escape", i, i + 2);
3255
- value2 += source.substring(pos, i) + esc;
3599
+ value += source.substring(pos, i) + esc;
3256
3600
  i += 1;
3257
3601
  pos = i + 1;
3258
3602
  break;
3259
3603
  }
3260
3604
  case "|":
3261
- value2 += source.substring(pos, i);
3605
+ value += source.substring(pos, i);
3262
3606
  pos = i + 1;
3263
- return { type: "literal", value: value2 };
3607
+ return { type: "literal", value };
3264
3608
  }
3265
3609
  }
3266
3610
  throw MissingSyntax(source.length, "|");
@@ -3274,11 +3618,11 @@ function identifier() {
3274
3618
  return name_;
3275
3619
  }
3276
3620
  function name() {
3277
- const name2 = parseNameValue(source, pos);
3278
- if (!name2)
3621
+ const name = parseNameValue(source, pos);
3622
+ if (!name)
3279
3623
  throw SyntaxError("empty-token", pos);
3280
- pos = name2.end;
3281
- return name2.value;
3624
+ pos = name.end;
3625
+ return name.value;
3282
3626
  }
3283
3627
  function ws(req = false) {
3284
3628
  let next = source[pos];
@@ -3299,14 +3643,14 @@ function ws(req = false) {
3299
3643
  }
3300
3644
  // node_modules/messageformat/lib/data-model/visit.js
3301
3645
  function visit(msg, visitors) {
3302
- const { node, pattern: pattern2 } = visitors;
3303
- const { functionRef = node, attributes: attributes2 = null, declaration = node, expression: expression2 = node, key = node, markup = node, options: options2 = null, value: value2 = node, variant: variant2 = node } = visitors;
3646
+ const { node, pattern } = visitors;
3647
+ const { functionRef = node, attributes = null, declaration = node, expression = node, key = node, markup = node, options = null, value = node, variant = node } = visitors;
3304
3648
  const handleOptions = (options_, context) => {
3305
3649
  if (options_) {
3306
- const end = options2?.(options_, context);
3307
- if (value2) {
3650
+ const end = options?.(options_, context);
3651
+ if (value) {
3308
3652
  for (const value_ of Object.values(options_)) {
3309
- value2(value_, context, "option");
3653
+ value(value_, context, "option");
3310
3654
  }
3311
3655
  }
3312
3656
  end?.();
@@ -3314,11 +3658,11 @@ function visit(msg, visitors) {
3314
3658
  };
3315
3659
  const handleAttributes = (attributes_, context) => {
3316
3660
  if (attributes_) {
3317
- const end = attributes2?.(attributes_, context);
3318
- if (value2) {
3661
+ const end = attributes?.(attributes_, context);
3662
+ if (value) {
3319
3663
  for (const value_ of Object.values(attributes_)) {
3320
3664
  if (value_ !== true)
3321
- value2(value_, context, "attribute");
3665
+ value(value_, context, "attribute");
3322
3666
  }
3323
3667
  }
3324
3668
  end?.();
@@ -3329,9 +3673,9 @@ function visit(msg, visitors) {
3329
3673
  let end;
3330
3674
  switch (exp.type) {
3331
3675
  case "expression": {
3332
- end = expression2?.(exp, context);
3676
+ end = expression?.(exp, context);
3333
3677
  if (exp.arg)
3334
- value2?.(exp.arg, context, "arg");
3678
+ value?.(exp.arg, context, "arg");
3335
3679
  if (exp.functionRef) {
3336
3680
  const endA = functionRef?.(exp.functionRef, context, exp.arg);
3337
3681
  handleOptions(exp.functionRef.options, context);
@@ -3351,7 +3695,7 @@ function visit(msg, visitors) {
3351
3695
  }
3352
3696
  };
3353
3697
  const handlePattern = (pat) => {
3354
- const end = pattern2?.(pat);
3698
+ const end = pattern?.(pat);
3355
3699
  for (const el of pat)
3356
3700
  handleElement(el, "placeholder");
3357
3701
  end?.();
@@ -3365,11 +3709,11 @@ function visit(msg, visitors) {
3365
3709
  if (msg.type === "message") {
3366
3710
  handlePattern(msg.pattern);
3367
3711
  } else {
3368
- if (value2)
3712
+ if (value)
3369
3713
  for (const sel of msg.selectors)
3370
- value2(sel, "selector", "arg");
3714
+ value(sel, "selector", "arg");
3371
3715
  for (const vari of msg.variants) {
3372
- const end = variant2?.(vari);
3716
+ const end = variant?.(vari);
3373
3717
  if (key)
3374
3718
  vari.keys.forEach(key);
3375
3719
  handlePattern(vari.value);
@@ -3412,34 +3756,34 @@ function validate(msg, onError = (type, node) => {
3412
3756
  if (functionRef)
3413
3757
  functions.add(functionRef.name);
3414
3758
  },
3415
- value(value2, context, position) {
3416
- if (value2.type !== "variable")
3759
+ value(value, context, position) {
3760
+ if (value.type !== "variable")
3417
3761
  return;
3418
- variables.add(value2.name);
3762
+ variables.add(value.name);
3419
3763
  switch (context) {
3420
3764
  case "declaration":
3421
3765
  if (position !== "arg" || setArgAsDeclared) {
3422
- declared.add(value2.name);
3766
+ declared.add(value.name);
3423
3767
  }
3424
3768
  break;
3425
3769
  case "selector":
3426
3770
  selectorCount += 1;
3427
- missingFallback = value2;
3428
- if (!annotated.has(value2.name)) {
3429
- onError("missing-selector-annotation", value2);
3771
+ missingFallback = value;
3772
+ if (!annotated.has(value.name)) {
3773
+ onError("missing-selector-annotation", value);
3430
3774
  }
3431
3775
  }
3432
3776
  },
3433
- variant(variant2) {
3434
- const { keys } = variant2;
3777
+ variant(variant) {
3778
+ const { keys } = variant;
3435
3779
  if (keys.length !== selectorCount)
3436
- onError("key-mismatch", variant2);
3780
+ onError("key-mismatch", variant);
3437
3781
  const strKeys = JSON.stringify(keys.map((key) => key.type === "literal" ? key.value : 0));
3438
3782
  if (variants.has(strKeys))
3439
- onError("duplicate-variant", variant2);
3783
+ onError("duplicate-variant", variant);
3440
3784
  else
3441
3785
  variants.add(strKeys);
3442
- missingFallback &&= keys.every((key) => key.type === "*") ? null : variant2;
3786
+ missingFallback &&= keys.every((key) => key.type === "*") ? null : variant;
3443
3787
  }
3444
3788
  });
3445
3789
  if (missingFallback)
@@ -3470,66 +3814,66 @@ function getLocaleDir(locale) {
3470
3814
  return "auto";
3471
3815
  }
3472
3816
  // node_modules/messageformat/lib/functions/utils.js
3473
- function asBoolean(value2) {
3474
- if (value2 && typeof value2 === "object")
3475
- value2 = value2.valueOf();
3476
- if (typeof value2 === "boolean")
3477
- return value2;
3478
- if (value2 && typeof value2 === "object")
3479
- value2 = String(value2);
3480
- if (value2 === "true")
3817
+ function asBoolean(value) {
3818
+ if (value && typeof value === "object")
3819
+ value = value.valueOf();
3820
+ if (typeof value === "boolean")
3821
+ return value;
3822
+ if (value && typeof value === "object")
3823
+ value = String(value);
3824
+ if (value === "true")
3481
3825
  return true;
3482
- if (value2 === "false")
3826
+ if (value === "false")
3483
3827
  return false;
3484
3828
  throw new RangeError("Not a boolean");
3485
3829
  }
3486
- function asPositiveInteger(value2) {
3487
- if (value2 && typeof value2 === "object")
3488
- value2 = value2.valueOf();
3489
- if (value2 && typeof value2 === "object")
3490
- value2 = String(value2);
3491
- if (typeof value2 === "string" && /^(0|[1-9][0-9]*)$/.test(value2)) {
3492
- value2 = Number(value2);
3493
- }
3494
- if (typeof value2 === "number" && value2 >= 0 && Number.isInteger(value2)) {
3495
- return value2;
3830
+ function asPositiveInteger(value) {
3831
+ if (value && typeof value === "object")
3832
+ value = value.valueOf();
3833
+ if (value && typeof value === "object")
3834
+ value = String(value);
3835
+ if (typeof value === "string" && /^(0|[1-9][0-9]*)$/.test(value)) {
3836
+ value = Number(value);
3837
+ }
3838
+ if (typeof value === "number" && value >= 0 && Number.isInteger(value)) {
3839
+ return value;
3496
3840
  }
3497
3841
  throw new RangeError("Not a positive integer");
3498
3842
  }
3499
- function asString(value2) {
3500
- if (value2 && typeof value2 === "object")
3501
- value2 = value2.valueOf();
3502
- if (typeof value2 === "string")
3503
- return value2;
3504
- if (value2 && typeof value2 === "object")
3505
- return String(value2);
3843
+ function asString(value) {
3844
+ if (value && typeof value === "object")
3845
+ value = value.valueOf();
3846
+ if (typeof value === "string")
3847
+ return value;
3848
+ if (value && typeof value === "object")
3849
+ return String(value);
3506
3850
  throw new RangeError("Not a string");
3507
3851
  }
3508
3852
  // node_modules/messageformat/lib/functions/number.js
3509
- function readNumericOperand(value2) {
3510
- let options2 = undefined;
3511
- if (typeof value2 === "object") {
3512
- const valueOf = value2?.valueOf;
3853
+ function readNumericOperand(value) {
3854
+ let options = undefined;
3855
+ if (typeof value === "object") {
3856
+ const valueOf = value?.valueOf;
3513
3857
  if (typeof valueOf === "function") {
3514
- options2 = value2.options;
3515
- value2 = valueOf.call(value2);
3858
+ options = value.options;
3859
+ value = valueOf.call(value);
3516
3860
  }
3517
3861
  }
3518
- if (typeof value2 === "string") {
3862
+ if (typeof value === "string") {
3519
3863
  try {
3520
- value2 = JSON.parse(value2);
3864
+ value = JSON.parse(value);
3521
3865
  } catch {}
3522
3866
  }
3523
- if (typeof value2 !== "bigint" && typeof value2 !== "number") {
3867
+ if (typeof value !== "bigint" && typeof value !== "number") {
3524
3868
  throw new MessageFunctionError("bad-operand", "Input is not numeric");
3525
3869
  }
3526
- return { value: value2, options: options2 };
3870
+ return { value, options };
3527
3871
  }
3528
- function getMessageNumber(ctx, value2, options2, canSelect) {
3872
+ function getMessageNumber(ctx, value, options, canSelect) {
3529
3873
  let { dir, locales } = ctx;
3530
- if (options2.useGrouping === "never")
3531
- options2.useGrouping = false;
3532
- if (canSelect && "select" in options2 && !ctx.literalOptionKeys.has("select")) {
3874
+ if (options.useGrouping === "never")
3875
+ options.useGrouping = false;
3876
+ if (canSelect && "select" in options && !ctx.literalOptionKeys.has("select")) {
3533
3877
  ctx.onError("bad-option", "The option select may only be set by a literal value");
3534
3878
  canSelect = false;
3535
3879
  }
@@ -3541,65 +3885,65 @@ function getMessageNumber(ctx, value2, options2, canSelect) {
3541
3885
  type: "number",
3542
3886
  get dir() {
3543
3887
  if (dir == null) {
3544
- locale ??= Intl.NumberFormat.supportedLocalesOf(locales, options2)[0];
3888
+ locale ??= Intl.NumberFormat.supportedLocalesOf(locales, options)[0];
3545
3889
  dir = getLocaleDir(locale);
3546
3890
  }
3547
3891
  return dir;
3548
3892
  },
3549
3893
  get options() {
3550
- return { ...options2 };
3894
+ return { ...options };
3551
3895
  },
3552
3896
  selectKey: canSelect ? (keys) => {
3553
- let numVal = value2;
3554
- if (options2.style === "percent") {
3897
+ let numVal = value;
3898
+ if (options.style === "percent") {
3555
3899
  if (typeof numVal === "bigint")
3556
3900
  numVal *= 100n;
3557
3901
  else
3558
3902
  numVal *= 100;
3559
3903
  }
3560
- const str2 = String(numVal);
3561
- if (keys.has(str2))
3562
- return str2;
3563
- if (options2.select === "exact")
3904
+ const str = String(numVal);
3905
+ if (keys.has(str))
3906
+ return str;
3907
+ if (options.select === "exact")
3564
3908
  return null;
3565
- const pluralOpt = options2.select ? { ...options2, select: undefined, type: options2.select } : options2;
3909
+ const pluralOpt = options.select ? { ...options, select: undefined, type: options.select } : options;
3566
3910
  cat ??= new Intl.PluralRules(locales, pluralOpt).select(Number(numVal));
3567
3911
  return keys.has(cat) ? cat : null;
3568
3912
  } : undefined,
3569
3913
  toParts() {
3570
- nf ??= new Intl.NumberFormat(locales, options2);
3571
- const parts = nf.formatToParts(value2);
3914
+ nf ??= new Intl.NumberFormat(locales, options);
3915
+ const parts = nf.formatToParts(value);
3572
3916
  locale ??= nf.resolvedOptions().locale;
3573
3917
  dir ??= getLocaleDir(locale);
3574
3918
  return dir === "ltr" || dir === "rtl" ? [{ type: "number", dir, locale, parts }] : [{ type: "number", locale, parts }];
3575
3919
  },
3576
3920
  toString() {
3577
- nf ??= new Intl.NumberFormat(locales, options2);
3578
- str ??= nf.format(value2);
3921
+ nf ??= new Intl.NumberFormat(locales, options);
3922
+ str ??= nf.format(value);
3579
3923
  return str;
3580
3924
  },
3581
- valueOf: () => value2
3925
+ valueOf: () => value
3582
3926
  };
3583
3927
  }
3584
3928
  function number(ctx, exprOpt, operand) {
3585
3929
  const input = readNumericOperand(operand);
3586
- const value2 = input.value;
3587
- const options2 = Object.assign({}, input.options, {
3930
+ const value = input.value;
3931
+ const options = Object.assign({}, input.options, {
3588
3932
  localeMatcher: ctx.localeMatcher,
3589
3933
  style: "decimal"
3590
3934
  });
3591
- for (const [name2, optval] of Object.entries(exprOpt)) {
3935
+ for (const [name, optval] of Object.entries(exprOpt)) {
3592
3936
  if (optval === undefined)
3593
3937
  continue;
3594
3938
  try {
3595
- switch (name2) {
3939
+ switch (name) {
3596
3940
  case "minimumIntegerDigits":
3597
3941
  case "minimumFractionDigits":
3598
3942
  case "maximumFractionDigits":
3599
3943
  case "minimumSignificantDigits":
3600
3944
  case "maximumSignificantDigits":
3601
3945
  case "roundingIncrement":
3602
- options2[name2] = asPositiveInteger(optval);
3946
+ options[name] = asPositiveInteger(optval);
3603
3947
  break;
3604
3948
  case "roundingMode":
3605
3949
  case "roundingPriority":
@@ -3607,100 +3951,100 @@ function number(ctx, exprOpt, operand) {
3607
3951
  case "signDisplay":
3608
3952
  case "trailingZeroDisplay":
3609
3953
  case "useGrouping":
3610
- options2[name2] = asString(optval);
3954
+ options[name] = asString(optval);
3611
3955
  }
3612
3956
  } catch {
3613
- ctx.onError("bad-option", `Value ${optval} is not valid for :number option ${name2}`);
3957
+ ctx.onError("bad-option", `Value ${optval} is not valid for :number option ${name}`);
3614
3958
  }
3615
3959
  }
3616
- return getMessageNumber(ctx, value2, options2, true);
3960
+ return getMessageNumber(ctx, value, options, true);
3617
3961
  }
3618
3962
  function integer(ctx, exprOpt, operand) {
3619
3963
  const input = readNumericOperand(operand);
3620
- const value2 = Number.isFinite(input.value) ? Math.round(input.value) : input.value;
3621
- const options2 = Object.assign({}, input.options, {
3964
+ const value = Number.isFinite(input.value) ? Math.round(input.value) : input.value;
3965
+ const options = Object.assign({}, input.options, {
3622
3966
  maximumFractionDigits: 0,
3623
3967
  minimumFractionDigits: undefined,
3624
3968
  minimumSignificantDigits: undefined,
3625
3969
  style: "decimal"
3626
3970
  });
3627
- for (const [name2, optval] of Object.entries(exprOpt)) {
3971
+ for (const [name, optval] of Object.entries(exprOpt)) {
3628
3972
  if (optval === undefined)
3629
3973
  continue;
3630
3974
  try {
3631
- switch (name2) {
3975
+ switch (name) {
3632
3976
  case "minimumIntegerDigits":
3633
3977
  case "maximumSignificantDigits":
3634
- options2[name2] = asPositiveInteger(optval);
3978
+ options[name] = asPositiveInteger(optval);
3635
3979
  break;
3636
3980
  case "select":
3637
3981
  case "signDisplay":
3638
3982
  case "useGrouping":
3639
- options2[name2] = asString(optval);
3983
+ options[name] = asString(optval);
3640
3984
  }
3641
3985
  } catch {
3642
- ctx.onError("bad-option", `Value ${optval} is not valid for :integer option ${name2}`);
3986
+ ctx.onError("bad-option", `Value ${optval} is not valid for :integer option ${name}`);
3643
3987
  }
3644
3988
  }
3645
- return getMessageNumber(ctx, value2, options2, true);
3989
+ return getMessageNumber(ctx, value, options, true);
3646
3990
  }
3647
3991
 
3648
3992
  // node_modules/messageformat/lib/functions/currency.js
3649
3993
  function currency(ctx, exprOpt, operand) {
3650
3994
  const input = readNumericOperand(operand);
3651
- const options2 = Object.assign({}, input.options, {
3995
+ const options = Object.assign({}, input.options, {
3652
3996
  localeMatcher: ctx.localeMatcher,
3653
3997
  style: "currency"
3654
3998
  });
3655
- for (const [name2, optval] of Object.entries(exprOpt)) {
3999
+ for (const [name, optval] of Object.entries(exprOpt)) {
3656
4000
  if (optval === undefined)
3657
4001
  continue;
3658
4002
  try {
3659
- switch (name2) {
4003
+ switch (name) {
3660
4004
  case "currency":
3661
4005
  case "currencySign":
3662
4006
  case "roundingMode":
3663
4007
  case "roundingPriority":
3664
4008
  case "trailingZeroDisplay":
3665
4009
  case "useGrouping":
3666
- options2[name2] = asString(optval);
4010
+ options[name] = asString(optval);
3667
4011
  break;
3668
4012
  case "minimumIntegerDigits":
3669
4013
  case "minimumSignificantDigits":
3670
4014
  case "maximumSignificantDigits":
3671
4015
  case "roundingIncrement":
3672
- options2[name2] = asPositiveInteger(optval);
4016
+ options[name] = asPositiveInteger(optval);
3673
4017
  break;
3674
4018
  case "currencyDisplay": {
3675
4019
  const strval = asString(optval);
3676
4020
  if (strval === "never") {
3677
4021
  ctx.onError("unsupported-operation", 'Currency display "never" is not yet supported');
3678
4022
  } else {
3679
- options2[name2] = strval;
4023
+ options[name] = strval;
3680
4024
  }
3681
4025
  break;
3682
4026
  }
3683
4027
  case "fractionDigits": {
3684
4028
  const strval = asString(optval);
3685
4029
  if (strval === "auto") {
3686
- options2.minimumFractionDigits = undefined;
3687
- options2.maximumFractionDigits = undefined;
4030
+ options.minimumFractionDigits = undefined;
4031
+ options.maximumFractionDigits = undefined;
3688
4032
  } else {
3689
4033
  const numval = asPositiveInteger(strval);
3690
- options2.minimumFractionDigits = numval;
3691
- options2.maximumFractionDigits = numval;
4034
+ options.minimumFractionDigits = numval;
4035
+ options.maximumFractionDigits = numval;
3692
4036
  }
3693
4037
  break;
3694
4038
  }
3695
4039
  }
3696
4040
  } catch {
3697
- ctx.onError("bad-option", `Value ${optval} is not valid for :currency option ${name2}`);
4041
+ ctx.onError("bad-option", `Value ${optval} is not valid for :currency option ${name}`);
3698
4042
  }
3699
4043
  }
3700
- if (!options2.currency) {
4044
+ if (!options.currency) {
3701
4045
  throw new MessageFunctionError("bad-operand", "A currency code is required for :currency");
3702
4046
  }
3703
- return getMessageNumber(ctx, input.value, options2, false);
4047
+ return getMessageNumber(ctx, input.value, options, false);
3704
4048
  }
3705
4049
 
3706
4050
  // node_modules/messageformat/lib/functions/datetime.js
@@ -3715,43 +4059,43 @@ var dateFieldsValues = new Set([
3715
4059
  var dateLengthValues = new Set(["long", "medium", "short"]);
3716
4060
  var timePrecisionValues = new Set(["hour", "minute", "second"]);
3717
4061
  var timeZoneStyleValues = new Set(["long", "short"]);
3718
- var datetime = (ctx, options2, operand) => dateTimeImplementation("datetime", ctx, options2, operand);
3719
- var date = (ctx, options2, operand) => dateTimeImplementation("date", ctx, options2, operand);
3720
- var time = (ctx, options2, operand) => dateTimeImplementation("time", ctx, options2, operand);
4062
+ var datetime = (ctx, options, operand) => dateTimeImplementation("datetime", ctx, options, operand);
4063
+ var date = (ctx, options, operand) => dateTimeImplementation("date", ctx, options, operand);
4064
+ var time = (ctx, options, operand) => dateTimeImplementation("time", ctx, options, operand);
3721
4065
  function dateTimeImplementation(functionName, ctx, exprOpt, operand) {
3722
- const options2 = {
4066
+ const options = {
3723
4067
  localeMatcher: ctx.localeMatcher
3724
4068
  };
3725
- let value2 = operand;
3726
- if (typeof value2 === "object" && value2 !== null) {
3727
- const opt = value2.options;
4069
+ let value = operand;
4070
+ if (typeof value === "object" && value !== null) {
4071
+ const opt = value.options;
3728
4072
  if (opt) {
3729
- options2.calendar = opt.calendar;
4073
+ options.calendar = opt.calendar;
3730
4074
  if (functionName !== "date")
3731
- options2.hour12 = opt.hour12;
3732
- options2.timeZone = opt.timeZone;
4075
+ options.hour12 = opt.hour12;
4076
+ options.timeZone = opt.timeZone;
3733
4077
  }
3734
- if (typeof value2.valueOf === "function")
3735
- value2 = value2.valueOf();
4078
+ if (typeof value.valueOf === "function")
4079
+ value = value.valueOf();
3736
4080
  }
3737
- switch (typeof value2) {
4081
+ switch (typeof value) {
3738
4082
  case "number":
3739
4083
  case "string":
3740
- value2 = new Date(value2);
4084
+ value = new Date(value);
3741
4085
  }
3742
- if (!(value2 instanceof Date) || isNaN(value2.getTime())) {
4086
+ if (!(value instanceof Date) || isNaN(value.getTime())) {
3743
4087
  throw new MessageFunctionError("bad-operand", "Input is not a valid date");
3744
4088
  }
3745
4089
  if (exprOpt.calendar !== undefined) {
3746
4090
  try {
3747
- options2.calendar = asString(exprOpt.calendar);
4091
+ options.calendar = asString(exprOpt.calendar);
3748
4092
  } catch {
3749
4093
  ctx.onError("bad-option", `Invalid :${functionName} calendar option value`);
3750
4094
  }
3751
4095
  }
3752
4096
  if (exprOpt.hour12 !== undefined && functionName !== "date") {
3753
4097
  try {
3754
- options2.hour12 = asBoolean(exprOpt.hour12);
4098
+ options.hour12 = asBoolean(exprOpt.hour12);
3755
4099
  } catch {
3756
4100
  ctx.onError("bad-option", `Invalid :${functionName} hour12 option value`);
3757
4101
  }
@@ -3764,14 +4108,14 @@ function dateTimeImplementation(functionName, ctx, exprOpt, operand) {
3764
4108
  ctx.onError("bad-option", `Invalid :${functionName} timeZone option value`);
3765
4109
  }
3766
4110
  if (tz === "input") {
3767
- if (options2.timeZone === undefined) {
4111
+ if (options.timeZone === undefined) {
3768
4112
  ctx.onError("bad-operand", `Missing input timeZone value for :${functionName}`);
3769
4113
  }
3770
4114
  } else if (tz !== undefined) {
3771
- if (options2.timeZone !== undefined && tz !== options2.timeZone) {
4115
+ if (options.timeZone !== undefined && tz !== options.timeZone) {
3772
4116
  throw new MessageFunctionError("bad-option", "Time zone conversion is not supported");
3773
4117
  }
3774
- options2.timeZone = tz;
4118
+ options.timeZone = tz;
3775
4119
  }
3776
4120
  }
3777
4121
  if (functionName !== "time") {
@@ -3781,34 +4125,34 @@ function dateTimeImplementation(functionName, ctx, exprOpt, operand) {
3781
4125
  const dateLength = readStringOption(ctx, exprOpt, dlName, dateLengthValues);
3782
4126
  const dateFields = new Set(dateFieldsValue.split("-"));
3783
4127
  if (dateFields.has("year"))
3784
- options2.year = "numeric";
4128
+ options.year = "numeric";
3785
4129
  if (dateFields.has("month")) {
3786
- options2.month = dateLength === "long" ? "long" : dateLength === "short" ? "numeric" : "short";
4130
+ options.month = dateLength === "long" ? "long" : dateLength === "short" ? "numeric" : "short";
3787
4131
  }
3788
4132
  if (dateFields.has("day"))
3789
- options2.day = "numeric";
4133
+ options.day = "numeric";
3790
4134
  if (dateFields.has("weekday")) {
3791
- options2.weekday = dateLength === "long" ? "long" : "short";
4135
+ options.weekday = dateLength === "long" ? "long" : "short";
3792
4136
  }
3793
4137
  }
3794
4138
  if (functionName !== "date") {
3795
4139
  const tpName = functionName === "time" ? "precision" : "timePrecision";
3796
4140
  switch (readStringOption(ctx, exprOpt, tpName, timePrecisionValues)) {
3797
4141
  case "hour":
3798
- options2.hour = "numeric";
4142
+ options.hour = "numeric";
3799
4143
  break;
3800
4144
  case "second":
3801
- options2.hour = "numeric";
3802
- options2.minute = "numeric";
3803
- options2.second = "numeric";
4145
+ options.hour = "numeric";
4146
+ options.minute = "numeric";
4147
+ options.second = "numeric";
3804
4148
  break;
3805
4149
  default:
3806
- options2.hour = "numeric";
3807
- options2.minute = "numeric";
4150
+ options.hour = "numeric";
4151
+ options.minute = "numeric";
3808
4152
  }
3809
- options2.timeZoneName = readStringOption(ctx, exprOpt, "timeZoneStyle", timeZoneStyleValues);
4153
+ options.timeZoneName = readStringOption(ctx, exprOpt, "timeZoneStyle", timeZoneStyleValues);
3810
4154
  }
3811
- const dtf = new Intl.DateTimeFormat(ctx.locales, options2);
4155
+ const dtf = new Intl.DateTimeFormat(ctx.locales, options);
3812
4156
  let dir = ctx.dir;
3813
4157
  let locale;
3814
4158
  let str;
@@ -3822,31 +4166,31 @@ function dateTimeImplementation(functionName, ctx, exprOpt, operand) {
3822
4166
  return dir;
3823
4167
  },
3824
4168
  get options() {
3825
- return { ...options2 };
4169
+ return { ...options };
3826
4170
  },
3827
4171
  toParts() {
3828
- const parts = dtf.formatToParts(value2);
4172
+ const parts = dtf.formatToParts(value);
3829
4173
  locale ??= dtf.resolvedOptions().locale;
3830
4174
  dir ??= getLocaleDir(locale);
3831
4175
  return dir === "ltr" || dir === "rtl" ? [{ type: "datetime", dir, locale, parts }] : [{ type: "datetime", locale, parts }];
3832
4176
  },
3833
4177
  toString() {
3834
- str ??= dtf.format(value2);
4178
+ str ??= dtf.format(value);
3835
4179
  return str;
3836
4180
  },
3837
- valueOf: () => value2
4181
+ valueOf: () => value
3838
4182
  };
3839
4183
  }
3840
- function readStringOption(ctx, options2, name2, allowed) {
3841
- const value2 = options2[name2];
3842
- if (value2 !== undefined) {
4184
+ function readStringOption(ctx, options, name, allowed) {
4185
+ const value = options[name];
4186
+ if (value !== undefined) {
3843
4187
  try {
3844
- const str = asString(value2);
4188
+ const str = asString(value);
3845
4189
  if (allowed && !allowed.has(str))
3846
4190
  throw Error();
3847
4191
  return str;
3848
4192
  } catch {
3849
- ctx.onError("bad-option", `Invalid value for ${name2} option`);
4193
+ ctx.onError("bad-option", `Invalid value for ${name} option`);
3850
4194
  }
3851
4195
  }
3852
4196
  return;
@@ -3854,7 +4198,7 @@ function readStringOption(ctx, options2, name2, allowed) {
3854
4198
 
3855
4199
  // node_modules/messageformat/lib/functions/offset.js
3856
4200
  function offset(ctx, exprOpt, operand) {
3857
- let { value: value2, options: options2 } = readNumericOperand(operand);
4201
+ let { value, options } = readNumericOperand(operand);
3858
4202
  let add;
3859
4203
  try {
3860
4204
  add = "add" in exprOpt ? asPositiveInteger(exprOpt.add) : -1;
@@ -3872,44 +4216,44 @@ function offset(ctx, exprOpt, operand) {
3872
4216
  throw new MessageFunctionError("bad-option", msg);
3873
4217
  }
3874
4218
  const delta = add < 0 ? -sub : add;
3875
- if (typeof value2 === "number")
3876
- value2 += delta;
4219
+ if (typeof value === "number")
4220
+ value += delta;
3877
4221
  else
3878
- value2 += BigInt(delta);
3879
- return number(ctx, {}, { valueOf: () => value2, options: options2 });
4222
+ value += BigInt(delta);
4223
+ return number(ctx, {}, { valueOf: () => value, options });
3880
4224
  }
3881
4225
 
3882
4226
  // node_modules/messageformat/lib/functions/percent.js
3883
4227
  function percent(ctx, exprOpt, operand) {
3884
4228
  const input = readNumericOperand(operand);
3885
- const options2 = Object.assign({}, input.options, {
4229
+ const options = Object.assign({}, input.options, {
3886
4230
  localeMatcher: ctx.localeMatcher,
3887
4231
  style: "percent"
3888
4232
  });
3889
- for (const [name2, optval] of Object.entries(exprOpt)) {
4233
+ for (const [name, optval] of Object.entries(exprOpt)) {
3890
4234
  if (optval === undefined)
3891
4235
  continue;
3892
4236
  try {
3893
- switch (name2) {
4237
+ switch (name) {
3894
4238
  case "roundingMode":
3895
4239
  case "roundingPriority":
3896
4240
  case "signDisplay":
3897
4241
  case "trailingZeroDisplay":
3898
4242
  case "useGrouping":
3899
- options2[name2] = asString(optval);
4243
+ options[name] = asString(optval);
3900
4244
  break;
3901
4245
  case "minimumFractionDigits":
3902
4246
  case "maximumFractionDigits":
3903
4247
  case "minimumSignificantDigits":
3904
4248
  case "maximumSignificantDigits":
3905
- options2[name2] = asPositiveInteger(optval);
4249
+ options[name] = asPositiveInteger(optval);
3906
4250
  break;
3907
4251
  }
3908
4252
  } catch {
3909
- ctx.onError("bad-option", `Value ${optval} is not valid for :percent option ${name2}`);
4253
+ ctx.onError("bad-option", `Value ${optval} is not valid for :percent option ${name}`);
3910
4254
  }
3911
4255
  }
3912
- return getMessageNumber(ctx, input.value, options2, true);
4256
+ return getMessageNumber(ctx, input.value, options, true);
3913
4257
  }
3914
4258
 
3915
4259
  // node_modules/messageformat/lib/functions/string.js
@@ -3933,15 +4277,15 @@ function string(ctx, _options, operand) {
3933
4277
  // node_modules/messageformat/lib/functions/unit.js
3934
4278
  function unit(ctx, exprOpt, operand) {
3935
4279
  const input = readNumericOperand(operand);
3936
- const options2 = Object.assign({}, input.options, {
4280
+ const options = Object.assign({}, input.options, {
3937
4281
  localeMatcher: ctx.localeMatcher,
3938
4282
  style: "unit"
3939
4283
  });
3940
- for (const [name2, optval] of Object.entries(exprOpt)) {
4284
+ for (const [name, optval] of Object.entries(exprOpt)) {
3941
4285
  if (optval === undefined)
3942
4286
  continue;
3943
4287
  try {
3944
- switch (name2) {
4288
+ switch (name) {
3945
4289
  case "signDisplay":
3946
4290
  case "roundingMode":
3947
4291
  case "roundingPriority":
@@ -3949,7 +4293,7 @@ function unit(ctx, exprOpt, operand) {
3949
4293
  case "unit":
3950
4294
  case "unitDisplay":
3951
4295
  case "useGrouping":
3952
- options2[name2] = asString(optval);
4296
+ options[name] = asString(optval);
3953
4297
  break;
3954
4298
  case "minimumIntegerDigits":
3955
4299
  case "minimumFractionDigits":
@@ -3957,21 +4301,21 @@ function unit(ctx, exprOpt, operand) {
3957
4301
  case "minimumSignificantDigits":
3958
4302
  case "maximumSignificantDigits":
3959
4303
  case "roundingIncrement":
3960
- options2[name2] = asPositiveInteger(optval);
4304
+ options[name] = asPositiveInteger(optval);
3961
4305
  break;
3962
4306
  }
3963
4307
  } catch (error) {
3964
4308
  if (error instanceof MessageError) {
3965
4309
  ctx.onError(error);
3966
4310
  } else {
3967
- ctx.onError("bad-option", `Value ${optval} is not valid for :currency option ${name2}`);
4311
+ ctx.onError("bad-option", `Value ${optval} is not valid for :currency option ${name}`);
3968
4312
  }
3969
4313
  }
3970
4314
  }
3971
- if (!options2.unit) {
4315
+ if (!options.unit) {
3972
4316
  throw new MessageFunctionError("bad-operand", "A unit identifier is required for :unit");
3973
4317
  }
3974
- return getMessageNumber(ctx, input.value, options2, false);
4318
+ return getMessageNumber(ctx, input.value, options, false);
3975
4319
  }
3976
4320
 
3977
4321
  // node_modules/messageformat/lib/functions/index.js
@@ -3996,17 +4340,17 @@ DraftFunctions = Object.freeze(Object.assign(Object.create(null), DraftFunctions
3996
4340
  var BIDI_ISOLATE = Symbol("bidi-isolate");
3997
4341
 
3998
4342
  // node_modules/messageformat/lib/functions/fallback.js
3999
- var fallback = (source2 = "�") => ({
4343
+ var fallback = (source = "�") => ({
4000
4344
  type: "fallback",
4001
- source: source2,
4002
- toParts: () => [{ type: "fallback", source: source2 }],
4003
- toString: () => `{${source2}}`
4345
+ source,
4346
+ toParts: () => [{ type: "fallback", source }],
4347
+ toString: () => `{${source}}`
4004
4348
  });
4005
4349
 
4006
4350
  // node_modules/messageformat/lib/functions/unknown.js
4007
- var unknown = (source2, input) => ({
4351
+ var unknown = (source, input) => ({
4008
4352
  type: "unknown",
4009
- source: source2,
4353
+ source,
4010
4354
  dir: "auto",
4011
4355
  toParts: () => [{ type: "unknown", value: input }],
4012
4356
  toString: () => String(input),
@@ -4020,11 +4364,11 @@ class MessageFunctionContext {
4020
4364
  #source;
4021
4365
  dir;
4022
4366
  id;
4023
- constructor(ctx, source2, options2) {
4367
+ constructor(ctx, source, options) {
4024
4368
  this.#ctx = ctx;
4025
- this.#source = source2;
4369
+ this.#source = source;
4026
4370
  this.dir = undefined;
4027
- const dirOpt = options2 && Object.hasOwn(options2, "u:dir") ? options2["u:dir"] : undefined;
4371
+ const dirOpt = options && Object.hasOwn(options, "u:dir") ? options["u:dir"] : undefined;
4028
4372
  if (dirOpt) {
4029
4373
  const dir = String(resolveValue(ctx, dirOpt));
4030
4374
  if (dir === "ltr" || dir === "rtl" || dir === "auto") {
@@ -4035,12 +4379,12 @@ class MessageFunctionContext {
4035
4379
  ctx.onError(error);
4036
4380
  }
4037
4381
  }
4038
- const idOpt = options2 && Object.hasOwn(options2, "u:id") ? options2["u:id"] : undefined;
4382
+ const idOpt = options && Object.hasOwn(options, "u:id") ? options["u:id"] : undefined;
4039
4383
  this.id = idOpt ? String(resolveValue(ctx, idOpt)) : undefined;
4040
- if (options2) {
4384
+ if (options) {
4041
4385
  this.#litKeys = new Set;
4042
- for (const [key, value2] of Object.entries(options2)) {
4043
- if (value2.type === "literal")
4386
+ for (const [key, value] of Object.entries(options)) {
4387
+ if (value.type === "literal")
4044
4388
  this.#litKeys.add(key);
4045
4389
  }
4046
4390
  }
@@ -4070,22 +4414,22 @@ class MessageFunctionContext {
4070
4414
  }
4071
4415
 
4072
4416
  // node_modules/messageformat/lib/resolve/resolve-function-ref.js
4073
- function resolveFunctionRef(ctx, operand, { name: name2, options: options2 }) {
4074
- const fnSource = `:${name2}`;
4075
- const source2 = getValueSource(operand) ?? fnSource;
4417
+ function resolveFunctionRef(ctx, operand, { name, options }) {
4418
+ const fnSource = `:${name}`;
4419
+ const source = getValueSource(operand) ?? fnSource;
4076
4420
  try {
4077
4421
  const fnInput = operand ? [resolveValue(ctx, operand)] : [];
4078
- const rf = ctx.functions[name2];
4422
+ const rf = ctx.functions[name];
4079
4423
  if (!rf) {
4080
- throw new MessageResolutionError("unknown-function", `Unknown function ${fnSource}`, source2);
4424
+ throw new MessageResolutionError("unknown-function", `Unknown function ${fnSource}`, source);
4081
4425
  }
4082
- const msgCtx = new MessageFunctionContext(ctx, source2, options2);
4083
- const opt = resolveOptions(ctx, options2);
4426
+ const msgCtx = new MessageFunctionContext(ctx, source, options);
4427
+ const opt = resolveOptions(ctx, options);
4084
4428
  const res = rf(msgCtx, opt, ...fnInput);
4085
4429
  if (res === null || typeof res !== "object" || typeof res.type !== "string") {
4086
- throw new MessageResolutionError("bad-function-result", `Function ${fnSource} did not return a MessageValue`, source2);
4430
+ throw new MessageResolutionError("bad-function-result", `Function ${fnSource} did not return a MessageValue`, source);
4087
4431
  }
4088
- const override = { source: source2 };
4432
+ const override = { source };
4089
4433
  if (msgCtx.dir) {
4090
4434
  override.dir = msgCtx.dir;
4091
4435
  override[BIDI_ISOLATE] = true;
@@ -4100,16 +4444,16 @@ function resolveFunctionRef(ctx, operand, { name: name2, options: options2 }) {
4100
4444
  }
4101
4445
  return { ...res, ...override };
4102
4446
  } catch (error) {
4103
- ctx.onError(error instanceof MessageError ? error : new MessageResolutionError("bad-function-result", String(error), source2, error));
4104
- return fallback(source2);
4447
+ ctx.onError(error instanceof MessageError ? error : new MessageResolutionError("bad-function-result", String(error), source, error));
4448
+ return fallback(source);
4105
4449
  }
4106
4450
  }
4107
- function resolveOptions(ctx, options2) {
4451
+ function resolveOptions(ctx, options) {
4108
4452
  const opt = Object.create(null);
4109
- if (options2) {
4110
- for (const [name2, value2] of Object.entries(options2)) {
4111
- if (!name2.startsWith("u:"))
4112
- opt[name2] = resolveValue(ctx, value2);
4453
+ if (options) {
4454
+ for (const [name, value] of Object.entries(options)) {
4455
+ if (!name.startsWith("u:"))
4456
+ opt[name] = resolveValue(ctx, value);
4113
4457
  }
4114
4458
  }
4115
4459
  return opt;
@@ -4122,10 +4466,10 @@ function resolveExpression(ctx, { arg, functionRef }) {
4122
4466
  }
4123
4467
  switch (arg?.type) {
4124
4468
  case "literal": {
4125
- const source2 = `|${arg.value}|`;
4126
- const msgCtx = new MessageFunctionContext(ctx, source2);
4469
+ const source = `|${arg.value}|`;
4470
+ const msgCtx = new MessageFunctionContext(ctx, source);
4127
4471
  const msgStr = string(msgCtx, {}, arg.value);
4128
- msgStr.source = source2;
4472
+ msgStr.source = source;
4129
4473
  return msgStr;
4130
4474
  }
4131
4475
  case "variable":
@@ -4139,17 +4483,17 @@ function resolveExpression(ctx, { arg, functionRef }) {
4139
4483
  class UnresolvedExpression {
4140
4484
  expression;
4141
4485
  scope;
4142
- constructor(expression2, scope) {
4143
- this.expression = expression2;
4486
+ constructor(expression, scope) {
4487
+ this.expression = expression;
4144
4488
  this.scope = scope;
4145
4489
  }
4146
4490
  }
4147
4491
  var isScope = (scope) => scope !== null && (typeof scope === "object" || typeof scope === "function");
4148
- function getValue(scope, name2) {
4492
+ function getValue(scope, name) {
4149
4493
  if (isScope(scope)) {
4150
- if (name2 in scope)
4151
- return scope[name2];
4152
- const parts = name2.split(".");
4494
+ if (name in scope)
4495
+ return scope[name];
4496
+ const parts = name.split(".");
4153
4497
  for (let i = parts.length - 1;i > 0; --i) {
4154
4498
  const head = parts.slice(0, i).join(".");
4155
4499
  if (head in scope) {
@@ -4157,44 +4501,44 @@ function getValue(scope, name2) {
4157
4501
  return getValue(scope[head], tail);
4158
4502
  }
4159
4503
  }
4160
- for (const [key, value2] of Object.entries(scope)) {
4161
- if (key.normalize() === name2)
4162
- return value2;
4504
+ for (const [key, value] of Object.entries(scope)) {
4505
+ if (key.normalize() === name)
4506
+ return value;
4163
4507
  }
4164
4508
  }
4165
4509
  return;
4166
4510
  }
4167
- function lookupVariableRef(ctx, { name: name2 }) {
4168
- const value2 = getValue(ctx.scope, name2);
4169
- if (value2 === undefined) {
4170
- const source2 = "$" + name2;
4171
- const msg = `Variable not available: ${source2}`;
4172
- ctx.onError(new MessageResolutionError("unresolved-variable", msg, source2));
4173
- } else if (value2 instanceof UnresolvedExpression) {
4174
- const local = resolveExpression(value2.scope ? { ...ctx, scope: value2.scope } : ctx, value2.expression);
4175
- ctx.scope[name2] = local;
4511
+ function lookupVariableRef(ctx, { name }) {
4512
+ const value = getValue(ctx.scope, name);
4513
+ if (value === undefined) {
4514
+ const source = "$" + name;
4515
+ const msg = `Variable not available: ${source}`;
4516
+ ctx.onError(new MessageResolutionError("unresolved-variable", msg, source));
4517
+ } else if (value instanceof UnresolvedExpression) {
4518
+ const local = resolveExpression(value.scope ? { ...ctx, scope: value.scope } : ctx, value.expression);
4519
+ ctx.scope[name] = local;
4176
4520
  ctx.localVars.add(local);
4177
4521
  return local;
4178
4522
  }
4179
- return value2;
4523
+ return value;
4180
4524
  }
4181
4525
  function resolveVariableRef(ctx, ref) {
4182
- const source2 = "$" + ref.name;
4183
- const value2 = lookupVariableRef(ctx, ref);
4184
- if (value2 === undefined)
4185
- return fallback(source2);
4186
- let type = typeof value2;
4526
+ const source = "$" + ref.name;
4527
+ const value = lookupVariableRef(ctx, ref);
4528
+ if (value === undefined)
4529
+ return fallback(source);
4530
+ let type = typeof value;
4187
4531
  if (type === "object") {
4188
- const mv2 = value2;
4189
- if (mv2.type === "fallback")
4190
- return fallback(source2);
4191
- if (ctx.localVars.has(mv2)) {
4192
- mv2.source = source2;
4193
- return mv2;
4194
- }
4195
- if (value2 instanceof Number)
4532
+ const mv = value;
4533
+ if (mv.type === "fallback")
4534
+ return fallback(source);
4535
+ if (ctx.localVars.has(mv)) {
4536
+ mv.source = source;
4537
+ return mv;
4538
+ }
4539
+ if (value instanceof Number)
4196
4540
  type = "number";
4197
- else if (value2 instanceof String)
4541
+ else if (value instanceof String)
4198
4542
  type = "string";
4199
4543
  }
4200
4544
  let msgFn;
@@ -4207,56 +4551,56 @@ function resolveVariableRef(ctx, ref) {
4207
4551
  msgFn = ctx.functions.string;
4208
4552
  break;
4209
4553
  default:
4210
- return unknown(source2, value2);
4554
+ return unknown(source, value);
4211
4555
  }
4212
- const msgCtx = new MessageFunctionContext(ctx, source2);
4213
- const mv = msgFn(msgCtx, {}, value2);
4214
- mv.source = source2;
4556
+ const msgCtx = new MessageFunctionContext(ctx, source);
4557
+ const mv = msgFn(msgCtx, {}, value);
4558
+ mv.source = source;
4215
4559
  return mv;
4216
4560
  }
4217
4561
 
4218
4562
  // node_modules/messageformat/lib/resolve/resolve-value.js
4219
- function resolveValue(ctx, value2) {
4220
- switch (value2.type) {
4563
+ function resolveValue(ctx, value) {
4564
+ switch (value.type) {
4221
4565
  case "literal":
4222
- return value2.value;
4566
+ return value.value;
4223
4567
  case "variable":
4224
- return lookupVariableRef(ctx, value2);
4568
+ return lookupVariableRef(ctx, value);
4225
4569
  default:
4226
- throw new Error(`Unsupported value: ${value2.type}`);
4570
+ throw new Error(`Unsupported value: ${value.type}`);
4227
4571
  }
4228
4572
  }
4229
- function getValueSource(value2) {
4230
- switch (value2?.type) {
4573
+ function getValueSource(value) {
4574
+ switch (value?.type) {
4231
4575
  case "literal":
4232
- return "|" + value2.value.replaceAll("\\", "\\\\").replaceAll("|", "\\|") + "|";
4576
+ return "|" + value.value.replaceAll("\\", "\\\\").replaceAll("|", "\\|") + "|";
4233
4577
  case "variable":
4234
- return "$" + value2.name;
4578
+ return "$" + value.name;
4235
4579
  default:
4236
4580
  return;
4237
4581
  }
4238
4582
  }
4239
4583
 
4240
4584
  // node_modules/messageformat/lib/resolve/format-markup.js
4241
- function formatMarkup(ctx, { kind, name: name2, options: options2 }) {
4242
- const part = { type: "markup", kind, name: name2 };
4243
- const entries = options2 ? Object.entries(options2) : null;
4585
+ function formatMarkup(ctx, { kind, name, options }) {
4586
+ const part = { type: "markup", kind, name };
4587
+ const entries = options ? Object.entries(options) : null;
4244
4588
  if (entries?.length) {
4245
4589
  part.options = {};
4246
- for (const [name3, value2] of entries) {
4247
- if (name3 === "u:dir") {
4248
- const error = new MessageFunctionError("bad-option", `The option ${name3} is not valid for markup`);
4249
- error.source = getValueSource(value2);
4590
+ for (const [name, value] of entries) {
4591
+ if (name === "u:dir") {
4592
+ const error = new MessageFunctionError("bad-option", `The option ${name} is not valid for markup`);
4593
+ error.source = getValueSource(value);
4250
4594
  ctx.onError(error);
4251
4595
  } else {
4252
- let rv = resolveValue(ctx, value2);
4596
+ let rv = resolveValue(ctx, value);
4253
4597
  if (typeof rv === "object" && typeof rv?.valueOf === "function") {
4254
4598
  rv = rv.valueOf();
4255
4599
  }
4256
- if (name3 === "u:id")
4600
+ if (name === "u:id")
4257
4601
  part.id = String(rv);
4258
4602
  else
4259
- part.options[name3] = rv;
4603
+ part.options[name] = rv;
4260
4604
  }
4261
4605
  }
4262
4606
  }
@@ -4343,14 +4687,14 @@ class MessageFormat {
4343
4687
  #locales;
4344
4688
  #message;
4345
4689
  #functions;
4346
- constructor(locales, source2, options2) {
4347
- this.#bidiIsolation = options2?.bidiIsolation !== "none";
4348
- this.#localeMatcher = options2?.localeMatcher ?? "best fit";
4690
+ constructor(locales, source, options) {
4691
+ this.#bidiIsolation = options?.bidiIsolation !== "none";
4692
+ this.#localeMatcher = options?.localeMatcher ?? "best fit";
4349
4693
  this.#locales = Array.isArray(locales) ? locales.map((lc) => new Intl.Locale(lc)) : locales ? [new Intl.Locale(locales)] : [];
4350
- this.#dir = options2?.dir ?? getLocaleDir(this.#locales[0]);
4351
- this.#message = typeof source2 === "string" ? parseMessage(source2) : source2;
4694
+ this.#dir = options?.dir ?? getLocaleDir(this.#locales[0]);
4695
+ this.#message = typeof source === "string" ? parseMessage(source) : source;
4352
4696
  validate(this.#message);
4353
- this.#functions = options2?.functions ? Object.assign(Object.create(null), DefaultFunctions, options2.functions) : DefaultFunctions;
4697
+ this.#functions = options?.functions ? Object.assign(Object.create(null), DefaultFunctions, options.functions) : DefaultFunctions;
4354
4698
  }
4355
4699
  format(msgParams, onError) {
4356
4700
  const ctx = this.#createContext(msgParams, onError);
@@ -4485,16 +4829,16 @@ function skipLine(src, i) {
4485
4829
  `, i + 2);
4486
4830
  return end < 0 ? src.length : end;
4487
4831
  }
4488
- var quote = (value2) => value2.replace(/["\\]/g, "\\$&");
4489
- function locOf(src, offset2, length) {
4832
+ var quote = (value) => value.replace(/["\\]/g, "\\$&");
4833
+ function locOf(src, offset, length) {
4490
4834
  let line = 1, last = -1;
4491
- for (let i = 0;i < offset2; i++)
4835
+ for (let i = 0;i < offset; i++)
4492
4836
  if (src[i] === `
4493
4837
  `) {
4494
4838
  line++;
4495
4839
  last = i;
4496
4840
  }
4497
- return { line, col: offset2 - last, offset: offset2, length };
4841
+ return { line, col: offset - last, offset, length };
4498
4842
  }
4499
4843
  function readInterpolation(src, open) {
4500
4844
  let i = open + 1, nest = 0, question = false, colon = false;
@@ -4566,9 +4910,9 @@ function readValue(src, from, keepComments, onUnterminated) {
4566
4910
  }
4567
4911
  parts.push(src.slice(lit, i));
4568
4912
  const m = UNIT.exec(src.slice(interp.end + 1));
4569
- const unit2 = m ? m[1] : "";
4570
- parts.push({ expr: interp.expr, unit: unit2, at: i });
4571
- i = interp.end + 1 + unit2.length;
4913
+ const unit = m ? m[1] : "";
4914
+ parts.push({ expr: interp.expr, unit, at: i });
4915
+ i = interp.end + 1 + unit.length;
4572
4916
  lit = i;
4573
4917
  continue;
4574
4918
  }
@@ -4590,7 +4934,7 @@ var QUOTED = /"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'/g;
4590
4934
  var STRING_OR_SPACE = new RegExp(`(${QUOTED.source})|\\s+`, "g");
4591
4935
  var COMMENTS = /\/\*[\s\S]*?\*\//g;
4592
4936
  var LAYER2 = /^@layer\b/i;
4593
- var squash = (text2) => text2.replace(STRING_OR_SPACE, (_, str) => str || " ");
4937
+ var squash = (text) => text.replace(STRING_OR_SPACE, (_, str) => str || " ");
4594
4938
  function nestSelector(prelude) {
4595
4939
  const parts = [];
4596
4940
  let from = 0, nest = 0;
@@ -4624,8 +4968,8 @@ function nestSelector(prelude) {
4624
4968
  return s.includes("&") ? s.replace(LEAD_TOKEN, ":is($&)") : `& ${s}`;
4625
4969
  }).join(",");
4626
4970
  }
4627
- function scan(src, options2, native, diagnostics) {
4628
- const exprs = [], binds = [], props = [], prefix = `--${options2.nsp.replace(/[^a-zA-Z0-9_-]/g, "-")}`, report = (code, message, offset2, length, hint) => diagnostics.push({ code, severity: "error", message, hint, loc: locOf(src, offset2, length) }), warn = (code, message, offset2, length, hint) => diagnostics.push({ code, severity: "warning", message, hint, loc: locOf(src, offset2, length) }), lint = (text2, from, to, value3) => options2.lint?.(text2, value3)?.forEach((d) => diagnostics.push({ ...d, loc: locOf(src, from, to - from) }));
4971
+ function scan(src, options, native, diagnostics) {
4972
+ const exprs = [], binds = [], props = [], prefix = `--${options.nsp.replace(/[^a-zA-Z0-9_-]/g, "-")}`, report = (code, message, offset, length, hint) => diagnostics.push({ code, severity: "error", message, hint, loc: locOf(src, offset, length) }), warn = (code, message, offset, length, hint) => diagnostics.push({ code, severity: "warning", message, hint, loc: locOf(src, offset, length) }), lint = (text, from, to, value) => options.lint?.(text, value)?.forEach((d) => diagnostics.push({ ...d, loc: locOf(src, from, to - from) }));
4629
4973
  const slot = (expr) => {
4630
4974
  let e = exprs.indexOf(expr);
4631
4975
  if (e < 0)
@@ -4639,20 +4983,20 @@ function scan(src, options2, native, diagnostics) {
4639
4983
  report("LIPS-S004", `Invalid expression: ${errors[0].message}`, s.at, length);
4640
4984
  return;
4641
4985
  }
4642
- for (const name2 of freeRoots(ast))
4643
- if (!STYLE_SCOPE.has(name2) && !(name2 in globalThis))
4644
- report("LIPS-S003", `'${name2}' is not readable from a stylesheet`, s.at, length, "Stylesheets see state, input, static, context and self — not <for> iterators or <let> names, " + "which are local to a template position.");
4986
+ for (const name of freeRoots(ast))
4987
+ if (!STYLE_SCOPE.has(name) && !(name in globalThis))
4988
+ report("LIPS-S003", `'${name}' is not readable from a stylesheet`, s.at, length, "Stylesheets see state, input, static, context and self — not <for> iterators or <let> names, " + "which are local to a template position.");
4645
4989
  s.unit && ast.t === "lit" && typeof ast.v === "string" && warn("LIPS-S005", `Unit '${s.unit}' after a string value`, s.at, length, `A unit suffix multiplies a number: drop the unit, or return ${s.unit === "%" ? "50" : "8"} instead of a string.`);
4646
4990
  };
4647
4991
  let out = "", cur = "", tail = "", gap = false;
4648
- const emit = (text2) => {
4649
- if (!text2)
4992
+ const emit = (text) => {
4993
+ if (!text)
4650
4994
  return;
4651
- if (gap && tail && !BREAK.test(tail) && !BREAK.test(text2[0]))
4995
+ if (gap && tail && !BREAK.test(tail) && !BREAK.test(text[0]))
4652
4996
  cur += " ";
4653
4997
  gap = false;
4654
- cur += text2;
4655
- tail = text2[text2.length - 1];
4998
+ cur += text;
4999
+ tail = text[text.length - 1];
4656
5000
  };
4657
5001
  const flush = (end) => {
4658
5002
  out += cur + end;
@@ -4661,14 +5005,14 @@ function scan(src, options2, native, diagnostics) {
4661
5005
  gap = false;
4662
5006
  };
4663
5007
  const drop = () => {
4664
- const text2 = cur;
5008
+ const text = cur;
4665
5009
  cur = tail = "";
4666
5010
  gap = false;
4667
- return text2;
5011
+ return text;
4668
5012
  };
4669
- const value2 = (text2) => ":" + (squash(text2).trim() || " ");
5013
+ const value = (text) => ":" + (squash(text).trim() || " ");
4670
5014
  let i = 0, paren = 0, stmt = 0, statements = "", hoisted = "", lastGroups = "", unterminated = false;
4671
- const stack = [{ ctx: options2.meta ? "top" : "style" }];
5015
+ const stack = [{ ctx: options.meta ? "top" : "style" }];
4672
5016
  const open = () => {
4673
5017
  const parent = stack[stack.length - 1], prelude = cur;
4674
5018
  let block;
@@ -4704,10 +5048,10 @@ function scan(src, options2, native, diagnostics) {
4704
5048
  flush("}");
4705
5049
  if (block.hoist === undefined)
4706
5050
  return;
4707
- const text2 = out.slice(block.hoist), groups = stack.filter((b) => b.group), key = groups.map((b) => b.group).join("{"), shut = "}".repeat(groups.length);
5051
+ const text = out.slice(block.hoist), groups = stack.filter((b) => b.group), key = groups.map((b) => b.group).join("{"), shut = "}".repeat(groups.length);
4708
5052
  out = out.slice(0, block.hoist);
4709
5053
  tail = "";
4710
- hoisted = key && key === lastGroups ? hoisted.slice(0, hoisted.length - shut.length) + text2 + shut : hoisted + groups.map((b) => b.group + "{").join("") + text2 + shut;
5054
+ hoisted = key && key === lastGroups ? hoisted.slice(0, hoisted.length - shut.length) + text + shut : hoisted + groups.map((b) => b.group + "{").join("") + text + shut;
4711
5055
  lastGroups = key;
4712
5056
  };
4713
5057
  while (i < src.length) {
@@ -4745,8 +5089,8 @@ function scan(src, options2, native, diagnostics) {
4745
5089
  else if (c === ")")
4746
5090
  paren--;
4747
5091
  if (c === ":" && paren === 0) {
4748
- const name2 = src.slice(stmt, i).replace(COMMENTS, "").trim();
4749
- if (PROP_NAME.test(name2)) {
5092
+ const name = src.slice(stmt, i).replace(COMMENTS, "").trim();
5093
+ if (PROP_NAME.test(name)) {
4750
5094
  const parsed = readValue(src, i + 1, !native, (at) => {
4751
5095
  unterminated = true;
4752
5096
  report("LIPS-S004", "Unterminated interpolation", at, src.length - at, "Close the expression with `}`.");
@@ -4756,18 +5100,18 @@ function scan(src, options2, native, diagnostics) {
4756
5100
  for (const s of slots)
4757
5101
  checkExpr(s);
4758
5102
  gap = false;
4759
- const bare = name2.startsWith("--") && slots.length === 1 && !slots[0].unit && parsed.parts.every((p) => typeof p !== "string" || !p.trim());
5103
+ const bare = name.startsWith("--") && slots.length === 1 && !slots[0].unit && parsed.parts.every((p) => typeof p !== "string" || !p.trim());
4760
5104
  if (bare) {
4761
- binds.push({ prop: name2, e: slot(slots[0].expr) });
5105
+ binds.push({ prop: name, e: slot(slots[0].expr) });
4762
5106
  drop();
4763
5107
  i = parsed.end + (src[parsed.end] === ";" ? 1 : 0);
4764
5108
  stmt = i;
4765
5109
  continue;
4766
5110
  }
4767
- let text2 = "";
5111
+ let text = "";
4768
5112
  for (const part of parsed.parts) {
4769
5113
  if (typeof part === "string") {
4770
- text2 += part;
5114
+ text += part;
4771
5115
  continue;
4772
5116
  }
4773
5117
  const e = slot(part.expr), prop = `${prefix}-${e}`;
@@ -4781,10 +5125,10 @@ function scan(src, options2, native, diagnostics) {
4781
5125
  initial: NUMBER_SYNTAX[1]
4782
5126
  });
4783
5127
  }
4784
- text2 += part.unit ? `calc(var(${prop}) * 1${part.unit})` : `var(${prop})`;
5128
+ text += part.unit ? `calc(var(${prop}) * 1${part.unit})` : `var(${prop})`;
4785
5129
  }
4786
- lint(name2, stmt, parsed.end, text2);
4787
- emit(value2(text2));
5130
+ lint(name, stmt, parsed.end, text);
5131
+ emit(value(text));
4788
5132
  i = parsed.end;
4789
5133
  continue;
4790
5134
  }
@@ -4844,13 +5188,13 @@ function scan(src, options2, native, diagnostics) {
4844
5188
  flush("");
4845
5189
  return { css: out, statements, hoisted, exprs, binds, props };
4846
5190
  }
4847
- function compileStyle(src, options2) {
4848
- const diagnostics = [], preprocess = options2.preprocess || PREPROCESSOR, { css, statements, hoisted, exprs, binds, props } = scan(src, options2, !preprocess, diagnostics);
4849
- const empty = { v: 1, nsp: options2.nsp, css: "", exprs: [], binds: [] };
4850
- const scoped = options2.meta || !css ? css : `${options2.scope || `[rel="${quote(options2.nsp)}"]`}{${css}}`, body = hoisted + scoped, source2 = options2.layer ? `@layer ${options2.layer}{${body}}` : body;
5191
+ function compileStyle(src, options) {
5192
+ const diagnostics = [], preprocess = options.preprocess || PREPROCESSOR, { css, statements, hoisted, exprs, binds, props } = scan(src, options, !preprocess, diagnostics);
5193
+ const empty = { v: 1, nsp: options.nsp, css: "", exprs: [], binds: [] };
5194
+ const scoped = options.meta || !css ? css : `${options.scope || `[rel="${quote(options.nsp)}"]`}{${css}}`, body = hoisted + scoped, source = options.layer ? `@layer ${options.layer}{${body}}` : body;
4851
5195
  let sheet;
4852
5196
  try {
4853
- sheet = preprocess ? preprocess(source2) : source2;
5197
+ sheet = preprocess ? preprocess(source) : source;
4854
5198
  } catch (error) {
4855
5199
  diagnostics.push({
4856
5200
  code: "LIPS-S006",
@@ -4861,7 +5205,7 @@ function compileStyle(src, options2) {
4861
5205
  return { ir: empty, diagnostics };
4862
5206
  }
4863
5207
  const registrations = props.map((p) => `@property ${p.name}{syntax:"${p.syntax}";inherits:${p.inherits};initial-value:${p.initial}}`).join("");
4864
- const ir = { v: 1, nsp: options2.nsp, css: statements + registrations + sheet, exprs, binds };
5208
+ const ir = { v: 1, nsp: options.nsp, css: statements + registrations + sheet, exprs, binds };
4865
5209
  if (props.length)
4866
5210
  ir.props = props;
4867
5211
  return { ir, diagnostics };
@@ -4887,15 +5231,26 @@ var VOID_ELEMENTS = new Set([
4887
5231
  var RAW_WHITESPACE_TAGS = new Set(["pre", "textarea"]);
4888
5232
  var HEAD_SUGAR_TAGS = new Set(["if", "else-if", "switch", "log"]);
4889
5233
  var NAMED_ENTITIES = {
4890
- "&amp;": "&",
4891
- "&lt;": "<",
4892
- "&gt;": ">",
4893
- "&quot;": '"',
4894
- "&#39;": "'",
4895
- "&nbsp;": " "
5234
+ __proto__: null,
5235
+ amp: "&",
5236
+ lt: "<",
5237
+ gt: ">",
5238
+ quot: '"',
5239
+ apos: "'",
5240
+ nbsp: " "
4896
5241
  };
4897
- function decodeEntities(text2) {
4898
- return text2.replace(/&(?:amp|lt|gt|quot|#39|nbsp);/g, (m) => NAMED_ENTITIES[m]);
5242
+ var REFERENCE = /&(?:#(\d+)|#[xX]([0-9a-fA-F]+)|([A-Za-z][A-Za-z0-9]*));/g;
5243
+ function decodeEntities(text, unknown) {
5244
+ return text.replace(REFERENCE, (m, dec, hex, name, index) => {
5245
+ if (name === undefined) {
5246
+ const code = dec !== undefined ? parseInt(dec, 10) : parseInt(hex, 16);
5247
+ return code > 0 && code <= 1114111 ? String.fromCodePoint(code) : m;
5248
+ }
5249
+ if (name in NAMED_ENTITIES)
5250
+ return NAMED_ENTITIES[name];
5251
+ unknown?.(name, index);
5252
+ return m;
5253
+ });
4899
5254
  }
4900
5255
 
4901
5256
  class TemplateParser {
@@ -4906,7 +5261,7 @@ class TemplateParser {
4906
5261
  constructor(src) {
4907
5262
  this.src = src;
4908
5263
  }
4909
- locate(offset2) {
5264
+ locate(offset) {
4910
5265
  if (!this.lineStarts) {
4911
5266
  this.lineStarts = [0];
4912
5267
  for (let i = 0;i < this.src.length; i++)
@@ -4917,19 +5272,22 @@ class TemplateParser {
4917
5272
  let lo = 0, hi = this.lineStarts.length - 1;
4918
5273
  while (lo < hi) {
4919
5274
  const mid = lo + hi + 1 >> 1;
4920
- this.lineStarts[mid] <= offset2 ? lo = mid : hi = mid - 1;
5275
+ this.lineStarts[mid] <= offset ? lo = mid : hi = mid - 1;
4921
5276
  }
4922
- return { line: lo + 1, col: offset2 - this.lineStarts[lo] + 1 };
5277
+ return { line: lo + 1, col: offset - this.lineStarts[lo] + 1 };
5278
+ }
5279
+ report(code, severity, message, offset, length = 1, hint) {
5280
+ const { line, col } = this.locate(offset);
5281
+ this.diagnostics.push({ code, severity, message, hint, loc: { line, col, offset, length } });
4923
5282
  }
4924
- report(code, severity, message, offset2, length = 1, hint) {
4925
- const { line, col } = this.locate(offset2);
4926
- this.diagnostics.push({ code, severity, message, hint, loc: { line, col, offset: offset2, length } });
5283
+ decode(text, at) {
5284
+ return decodeEntities(text, (name, index) => this.report("LIPS-P013", "warning", `&${name}; is not decoded`, at + index, name.length + 2, "Write the character, or its number: &#169;"));
4927
5285
  }
4928
5286
  eof() {
4929
5287
  return this.pos >= this.src.length;
4930
5288
  }
4931
- peek(offset2 = 0) {
4932
- return this.src[this.pos + offset2];
5289
+ peek(offset = 0) {
5290
+ return this.src[this.pos + offset];
4933
5291
  }
4934
5292
  startsWith(str) {
4935
5293
  return this.src.startsWith(str, this.pos);
@@ -5001,8 +5359,8 @@ class TemplateParser {
5001
5359
  const node = this.parseTag(stack);
5002
5360
  node && nodes.push(node);
5003
5361
  } else {
5004
- const text2 = this.parseText(stack);
5005
- text2 && nodes.push(text2);
5362
+ const text = this.parseText(stack);
5363
+ text && nodes.push(text);
5006
5364
  }
5007
5365
  if (this.pos === before)
5008
5366
  this.pos++;
@@ -5032,14 +5390,14 @@ class TemplateParser {
5032
5390
  if (parts.some((p) => typeof p !== "string"))
5033
5391
  return {
5034
5392
  t: "interp",
5035
- parts: parts.map((p) => typeof p === "string" ? decodeEntities(p) : p),
5393
+ parts: parts.map((p) => typeof p === "string" ? this.decode(p, start) : p),
5036
5394
  loc
5037
5395
  };
5038
5396
  const raw = parts.length ? parts[0] : "";
5039
5397
  const inRaw = stack.some((tag) => RAW_WHITESPACE_TAGS.has(tag));
5040
5398
  if (!raw || !inRaw && !raw.trim())
5041
5399
  return null;
5042
- return { t: "text", value: decodeEntities(raw), loc };
5400
+ return { t: "text", value: this.decode(raw, start), loc };
5043
5401
  }
5044
5402
  parseTag(stack) {
5045
5403
  const start = this.pos;
@@ -5050,9 +5408,9 @@ class TemplateParser {
5050
5408
  this.pos = this.src.length;
5051
5409
  return null;
5052
5410
  }
5053
- const value2 = this.src.slice(this.pos + 4, end);
5411
+ const value = this.src.slice(this.pos + 4, end);
5054
5412
  this.pos = end + 3;
5055
- return { t: "comment", value: value2, loc: { offset: start, length: this.pos - start } };
5413
+ return { t: "comment", value, loc: { offset: start, length: this.pos - start } };
5056
5414
  }
5057
5415
  if (this.startsWith("<>")) {
5058
5416
  this.pos += 2;
@@ -5069,7 +5427,7 @@ class TemplateParser {
5069
5427
  const region = this.scanBalanced("}", "LIPS-P008");
5070
5428
  if (!region)
5071
5429
  return null;
5072
- const el2 = {
5430
+ const el = {
5073
5431
  t: "element",
5074
5432
  tag: "#dynamic",
5075
5433
  dynamicTag: { expr: region.content.trim(), loc: region.loc },
@@ -5078,8 +5436,8 @@ class TemplateParser {
5078
5436
  selfClosed: false,
5079
5437
  loc: { offset: start, length: 0 }
5080
5438
  };
5081
- this.finishTag(el2, stack, start);
5082
- return el2;
5439
+ this.finishTag(el, stack, start);
5440
+ return el;
5083
5441
  }
5084
5442
  this.pos++;
5085
5443
  const nameStart = this.pos;
@@ -5175,8 +5533,8 @@ class TemplateParser {
5175
5533
  const attrStart = this.pos;
5176
5534
  if (this.startsWith("...")) {
5177
5535
  this.pos += 3;
5178
- const source2 = this.readUnquotedValue();
5179
- el.attrs.push({ k: "spread", source: source2, loc: { offset: attrStart, length: this.pos - attrStart } });
5536
+ const source = this.readUnquotedValue();
5537
+ el.attrs.push({ k: "spread", source, loc: { offset: attrStart, length: this.pos - attrStart } });
5180
5538
  continue;
5181
5539
  }
5182
5540
  if (this.peek() === "[") {
@@ -5196,8 +5554,8 @@ class TemplateParser {
5196
5554
  const nameStart = this.pos;
5197
5555
  while (!this.eof() && /[^\s=/>()]/.test(this.peek()))
5198
5556
  this.pos++;
5199
- const name2 = this.src.slice(nameStart, this.pos);
5200
- if (!name2) {
5557
+ const name = this.src.slice(nameStart, this.pos);
5558
+ if (!name) {
5201
5559
  this.report("LIPS-P009", "error", `Invalid attribute syntax at '${this.peek()}'`, this.pos);
5202
5560
  this.pos++;
5203
5561
  continue;
@@ -5205,20 +5563,20 @@ class TemplateParser {
5205
5563
  if (this.peek() === "(") {
5206
5564
  this.pos++;
5207
5565
  const region = this.scanBalanced(")", "LIPS-P010");
5208
- const source2 = region ? region.content.trim() : "";
5566
+ const source = region ? region.content.trim() : "";
5209
5567
  const loc = { offset: attrStart, length: this.pos - attrStart };
5210
- name2.startsWith("on-") ? el.attrs.push({ k: "event", name: name2.slice(3), source: source2, loc }) : el.attrs.push({ k: "fn", name: name2, source: source2, loc });
5568
+ name.startsWith("on-") ? el.attrs.push({ k: "event", name: name.slice(3), source, loc }) : el.attrs.push({ k: "fn", name, source, loc });
5211
5569
  continue;
5212
5570
  }
5213
5571
  if (this.peek() === "=") {
5214
5572
  this.pos++;
5215
- this.parseAttrValue(el, name2, attrStart);
5573
+ this.parseAttrValue(el, name, attrStart);
5216
5574
  continue;
5217
5575
  }
5218
- el.attrs.push({ k: "bool", name: name2, value: !negated, loc: { offset: attrStart, length: this.pos - attrStart } });
5576
+ el.attrs.push({ k: "bool", name, value: !negated, loc: { offset: attrStart, length: this.pos - attrStart } });
5219
5577
  }
5220
5578
  }
5221
- parseAttrValue(el, name2, attrStart) {
5579
+ parseAttrValue(el, name, attrStart) {
5222
5580
  const q = this.peek();
5223
5581
  if (q === '"' || q === "'") {
5224
5582
  this.pos++;
@@ -5240,9 +5598,9 @@ class TemplateParser {
5240
5598
  this.pos++;
5241
5599
  }
5242
5600
  buffer && parts.push(buffer);
5243
- this.eof() ? this.report("LIPS-P010", "error", `Unterminated value for '${name2}'`, valueStart, this.pos - valueStart) : this.pos++;
5601
+ this.eof() ? this.report("LIPS-P010", "error", `Unterminated value for '${name}'`, valueStart, this.pos - valueStart) : this.pos++;
5244
5602
  const loc = { offset: attrStart, length: this.pos - attrStart };
5245
- parts.some((p) => typeof p !== "string") ? el.attrs.push({ k: "interp", name: name2, parts: parts.map((p) => typeof p === "string" ? decodeEntities(p) : p), loc }) : el.attrs.push({ k: "literal", name: name2, value: decodeEntities(parts[0] ?? ""), loc });
5603
+ parts.some((p) => typeof p !== "string") ? el.attrs.push({ k: "interp", name, parts: parts.map((p) => typeof p === "string" ? this.decode(p, valueStart) : p), loc }) : el.attrs.push({ k: "literal", name, value: this.decode(parts[0] ?? "", valueStart), loc });
5246
5604
  return;
5247
5605
  }
5248
5606
  if (q === "{") {
@@ -5250,14 +5608,14 @@ class TemplateParser {
5250
5608
  const region = this.scanBalanced("}", "LIPS-P007");
5251
5609
  el.attrs.push({
5252
5610
  k: "expr",
5253
- name: name2,
5611
+ name,
5254
5612
  source: region ? region.content.trim() : "",
5255
5613
  loc: { offset: attrStart, length: this.pos - attrStart }
5256
5614
  });
5257
5615
  return;
5258
5616
  }
5259
- const source2 = this.readUnquotedValue();
5260
- source2 ? el.attrs.push({ k: "expr", name: name2, source: source2, loc: { offset: attrStart, length: this.pos - attrStart } }) : this.report("LIPS-P010", "error", `Missing value for attribute '${name2}'`, attrStart);
5617
+ const source = this.readUnquotedValue();
5618
+ source ? el.attrs.push({ k: "expr", name, source, loc: { offset: attrStart, length: this.pos - attrStart } }) : this.report("LIPS-P010", "error", `Missing value for attribute '${name}'`, attrStart);
5261
5619
  }
5262
5620
  readUnquotedValue() {
5263
5621
  const start = this.pos;
@@ -5311,9 +5669,9 @@ function findTemplateStart(src) {
5311
5669
  for (let i = 0;i < src.length; i++) {
5312
5670
  const c = src[i];
5313
5671
  if (c === "'" || c === '"' || c === "`") {
5314
- const quote2 = c;
5672
+ const quote = c;
5315
5673
  i++;
5316
- while (i < src.length && src[i] !== quote2) {
5674
+ while (i < src.length && src[i] !== quote) {
5317
5675
  if (src[i] === "\\")
5318
5676
  i++;
5319
5677
  i++;
@@ -5352,156 +5710,7 @@ function findTemplateStart(src) {
5352
5710
 
5353
5711
  // src/ir/compiler.ts
5354
5712
  var ANCHOR = "<!--$-->";
5355
- var CONTROL_TAGS = new Set([
5356
- "if",
5357
- "else-if",
5358
- "else",
5359
- "for",
5360
- "switch",
5361
- "async",
5362
- "let",
5363
- "const",
5364
- "log",
5365
- "context",
5366
- "i18n"
5367
- ]);
5368
- var ARM_TAGS = new Set(["case", "default", "then", "catch", "loading"]);
5369
- var HTML_TAGS = new Set([
5370
- "a",
5371
- "abbr",
5372
- "address",
5373
- "area",
5374
- "article",
5375
- "aside",
5376
- "audio",
5377
- "b",
5378
- "base",
5379
- "bdi",
5380
- "bdo",
5381
- "blockquote",
5382
- "body",
5383
- "br",
5384
- "button",
5385
- "canvas",
5386
- "caption",
5387
- "cite",
5388
- "code",
5389
- "col",
5390
- "colgroup",
5391
- "data",
5392
- "datalist",
5393
- "dd",
5394
- "del",
5395
- "details",
5396
- "dfn",
5397
- "dialog",
5398
- "div",
5399
- "dl",
5400
- "dt",
5401
- "em",
5402
- "embed",
5403
- "fieldset",
5404
- "figcaption",
5405
- "figure",
5406
- "footer",
5407
- "form",
5408
- "h1",
5409
- "h2",
5410
- "h3",
5411
- "h4",
5412
- "h5",
5413
- "h6",
5414
- "head",
5415
- "header",
5416
- "hgroup",
5417
- "hr",
5418
- "html",
5419
- "i",
5420
- "iframe",
5421
- "img",
5422
- "input",
5423
- "ins",
5424
- "kbd",
5425
- "label",
5426
- "legend",
5427
- "li",
5428
- "link",
5429
- "main",
5430
- "map",
5431
- "mark",
5432
- "menu",
5433
- "meta",
5434
- "meter",
5435
- "nav",
5436
- "noscript",
5437
- "object",
5438
- "ol",
5439
- "optgroup",
5440
- "option",
5441
- "output",
5442
- "p",
5443
- "picture",
5444
- "pre",
5445
- "progress",
5446
- "q",
5447
- "rp",
5448
- "rt",
5449
- "ruby",
5450
- "s",
5451
- "samp",
5452
- "script",
5453
- "section",
5454
- "select",
5455
- "slot",
5456
- "small",
5457
- "source",
5458
- "span",
5459
- "strong",
5460
- "style",
5461
- "sub",
5462
- "summary",
5463
- "sup",
5464
- "table",
5465
- "tbody",
5466
- "td",
5467
- "template",
5468
- "textarea",
5469
- "tfoot",
5470
- "th",
5471
- "thead",
5472
- "time",
5473
- "title",
5474
- "tr",
5475
- "track",
5476
- "u",
5477
- "ul",
5478
- "var",
5479
- "video",
5480
- "wbr",
5481
- "svg",
5482
- "circle",
5483
- "clippath",
5484
- "defs",
5485
- "ellipse",
5486
- "foreignobject",
5487
- "g",
5488
- "image",
5489
- "line",
5490
- "lineargradient",
5491
- "marker",
5492
- "mask",
5493
- "path",
5494
- "pattern",
5495
- "polygon",
5496
- "polyline",
5497
- "radialgradient",
5498
- "rect",
5499
- "stop",
5500
- "symbol",
5501
- "text",
5502
- "tspan",
5503
- "use"
5504
- ]);
5713
+ var EVENT_MODS = new Set(["stop", "capture", "outside"]);
5505
5714
  var VOID_ELEMENTS2 = new Set([
5506
5715
  "area",
5507
5716
  "base",
@@ -5573,7 +5782,7 @@ class Compiler {
5573
5782
  this.macros = macros;
5574
5783
  this.tree = tree;
5575
5784
  }
5576
- locate(offset2) {
5785
+ locate(offset) {
5577
5786
  if (!this.lineStarts) {
5578
5787
  this.lineStarts = [0];
5579
5788
  for (let i = 0;i < this.src.length; i++)
@@ -5584,35 +5793,35 @@ class Compiler {
5584
5793
  let lo = 0, hi = this.lineStarts.length - 1;
5585
5794
  while (lo < hi) {
5586
5795
  const mid = lo + hi + 1 >> 1;
5587
- this.lineStarts[mid] <= offset2 ? lo = mid : hi = mid - 1;
5796
+ this.lineStarts[mid] <= offset ? lo = mid : hi = mid - 1;
5588
5797
  }
5589
- return { line: lo + 1, col: offset2 - this.lineStarts[lo] + 1 };
5798
+ return { line: lo + 1, col: offset - this.lineStarts[lo] + 1 };
5590
5799
  }
5591
- report(code, severity, message, offset2, length = 1, hint) {
5592
- const { line, col } = this.locate(offset2);
5593
- this.diagnostics.push({ code, severity, message, hint, loc: { line, col, offset: offset2, length } });
5800
+ report(code, severity, message, offset, length = 1, hint) {
5801
+ const { line, col } = this.locate(offset);
5802
+ this.diagnostics.push({ code, severity, message, hint, loc: { line, col, offset, length } });
5594
5803
  }
5595
- expr(source2, at) {
5596
- const cached = this.exprIndex.get(source2);
5804
+ expr(source, at) {
5805
+ const cached = this.exprIndex.get(source);
5597
5806
  if (cached !== undefined)
5598
5807
  return cached;
5599
- const { diagnostics } = parseExpression(source2);
5808
+ const { diagnostics } = parseExpression(source);
5600
5809
  for (const d of diagnostics) {
5601
- const offset2 = (at?.offset ?? 0) + d.loc.offset;
5602
- this.report(d.code, "error", d.message, offset2, d.loc.length);
5810
+ const offset = (at?.offset ?? 0) + d.loc.offset;
5811
+ this.report(d.code, "error", d.message, offset, d.loc.length);
5603
5812
  }
5604
5813
  const idx = this.exprs.length;
5605
- this.exprs.push(source2);
5606
- this.exprIndex.set(source2, idx);
5814
+ this.exprs.push(source);
5815
+ this.exprIndex.set(source, idx);
5607
5816
  return idx;
5608
5817
  }
5609
- synth(source2) {
5610
- const cached = this.exprIndex.get(source2);
5818
+ synth(source) {
5819
+ const cached = this.exprIndex.get(source);
5611
5820
  if (cached !== undefined)
5612
5821
  return cached;
5613
5822
  const idx = this.exprs.length;
5614
- this.exprs.push(source2);
5615
- this.exprIndex.set(source2, idx);
5823
+ this.exprs.push(source);
5824
+ this.exprIndex.set(source, idx);
5616
5825
  return idx;
5617
5826
  }
5618
5827
  concat(parts) {
@@ -5621,8 +5830,8 @@ class Compiler {
5621
5830
  for (const d of diagnostics)
5622
5831
  this.report(d.code, "error", d.message, p.loc.offset + d.loc.offset, d.loc.length);
5623
5832
  });
5624
- const source2 = parts.map((p) => typeof p === "string" ? JSON.stringify(p) : `((${p.expr})??"")`).join("+");
5625
- return this.synth(source2);
5833
+ const source = parts.map((p) => typeof p === "string" ? JSON.stringify(p) : `((${p.expr})??"")`).join("+");
5834
+ return this.synth(source);
5626
5835
  }
5627
5836
  compInput(attr) {
5628
5837
  switch (attr.k) {
@@ -5671,8 +5880,8 @@ class Compiler {
5671
5880
  case "comment": {
5672
5881
  if (tree)
5673
5882
  break;
5674
- const text2 = node.value.replace(/--/g, "- -");
5675
- html.push(`<!--${/^-?>/.test(text2) ? " " + text2 : text2}-->`);
5883
+ const text = node.value.replace(/--/g, "- -");
5884
+ html.push(`<!--${/^-?>/.test(text) ? " " + text : text}-->`);
5676
5885
  lastWasText = false;
5677
5886
  index++;
5678
5887
  break;
@@ -5740,19 +5949,19 @@ class Compiler {
5740
5949
  emitElement(node, path, index, html, block, emitSiblings, kids) {
5741
5950
  const p = [...path, index];
5742
5951
  let open = `<${node.tag}`;
5743
- const el = [node.tag], attrs = {}, put = (name2, value2) => {
5744
- Object.prototype.hasOwnProperty.call(attrs, name2) || (attrs[name2] = value2);
5952
+ const el = [node.tag], attrs = {}, put = (name, value) => {
5953
+ Object.prototype.hasOwnProperty.call(attrs, name) || (attrs[name] = value);
5745
5954
  };
5746
5955
  this.tree && kids.push(el);
5747
5956
  const named = node.attrs.filter((a) => ("name" in a));
5748
5957
  const i18n = named.some((a) => a.name === "i18n" && (a.k === "bool" && a.value || a.k === "literal"));
5749
- const translatableAttr = (name2) => i18n && (name2 === "title" || name2 === "placeholder");
5750
- const keyOf = (name2) => {
5751
- const a = named.find((x) => x.name === name2 && x.k === "literal");
5958
+ const translatableAttr = (name) => i18n && (name === "title" || name === "placeholder");
5959
+ const keyOf = (name) => {
5960
+ const a = named.find((x) => x.name === name && x.k === "literal");
5752
5961
  return a && "value" in a && a.value ? String(a.value) : undefined;
5753
5962
  };
5754
5963
  const textKey = keyOf("i18n");
5755
- const attrKey = (name2) => keyOf(`i18n-${name2}`);
5964
+ const attrKey = (name) => keyOf(`i18n-${name}`);
5756
5965
  !i18n && named.some((a) => a.name.startsWith("i18n-")) && this.report("LIPS-C014", "warning", `i18n-* key on <${node.tag}> without the 'i18n' marker — the attribute will not be translated`, node.loc.offset, node.loc.length);
5757
5966
  for (const attr of node.attrs) {
5758
5967
  if (this.tree && "name" in attr && attr.name === "@html") {
@@ -5760,8 +5969,8 @@ class Compiler {
5760
5969
  continue;
5761
5970
  }
5762
5971
  if ("name" in attr && attr.name === "style") {
5763
- const source2 = objectishAttr(attr);
5764
- if (source2 && isObjectLiteral(source2)) {
5972
+ const source = objectishAttr(attr);
5973
+ if (source && isObjectLiteral(source)) {
5765
5974
  this.report("LIPS-C019", "error", `style= on <${node.tag}> takes CSS text, not an object literal`, attr.loc.offset, attr.loc.length, 'Write the declarations as CSS — style="border: 2px solid gray; margin: 3rem" — ' + 'and interpolate values into it where they vary: style="margin: {state.gap}rem". ' + "Styles that need pseudo-classes, media queries or keyframes belong in the " + "component's stylesheet.");
5766
5975
  continue;
5767
5976
  }
@@ -5836,6 +6045,7 @@ class Compiler {
5836
6045
  break;
5837
6046
  }
5838
6047
  case "event":
6048
+ this.modifiers(attr);
5839
6049
  block.binds.push({ t: "event", p, name: attr.name, e: this.synth(attr.source) });
5840
6050
  break;
5841
6051
  case "spread":
@@ -5932,14 +6142,18 @@ class Compiler {
5932
6142
  args,
5933
6143
  block: this.block(node.children, [...scope, ...args])
5934
6144
  };
5935
- if (inAttr && inAttr.k === "expr")
5936
- child.of = this.expr(inAttr.source, inAttr.loc);
6145
+ if (inAttr) {
6146
+ const source = this.valueOf(inAttr);
6147
+ source === undefined ? this.report("LIPS-C004", "error", `<for in=…> takes an expression: in=state.items`, inAttr.loc.offset, inAttr.loc.length) : child.of = this.expr(source, inAttr.loc);
6148
+ }
5937
6149
  if (fromAttr)
5938
6150
  child.from = this.numInput(fromAttr);
5939
6151
  if (toAttr)
5940
6152
  child.to = this.numInput(toAttr);
5941
- if (byAttr && (byAttr.k === "literal" || byAttr.k === "expr"))
5942
- child.by = byAttr.k === "literal" ? { lit: byAttr.value } : { e: this.expr(byAttr.source, byAttr.loc) };
6153
+ if (byAttr) {
6154
+ const source = byAttr.k === "literal" ? undefined : this.valueOf(byAttr);
6155
+ byAttr.k === "literal" ? child.by = { lit: byAttr.value } : source === undefined ? this.report("LIPS-C004", "error", `<for by=…> takes a key path or an expression`, byAttr.loc.offset, byAttr.loc.length) : child.by = { e: this.expr(source, byAttr.loc) };
6156
+ }
5943
6157
  block.blocks.push(child);
5944
6158
  break;
5945
6159
  }
@@ -6051,10 +6265,18 @@ class Compiler {
6051
6265
  numInput(attr) {
6052
6266
  if (attr.k === "literal")
6053
6267
  return { lit: isNumeric(attr.value) ? Number(attr.value) : attr.value };
6054
- if (attr.k === "expr")
6055
- return isNumeric(attr.source) ? { lit: Number(attr.source) } : { e: this.expr(attr.source, attr.loc) };
6268
+ const source = this.valueOf(attr);
6269
+ if (source !== undefined)
6270
+ return isNumeric(source) ? { lit: Number(source) } : { e: this.expr(source, attr.loc) };
6271
+ "name" in attr && this.report("LIPS-C004", "error", `<for ${attr.name}=…> takes a number or an expression`, attr.loc.offset, attr.loc.length);
6056
6272
  return { lit: undefined };
6057
6273
  }
6274
+ valueOf(attr) {
6275
+ if (attr.k === "expr")
6276
+ return attr.source;
6277
+ if (attr.k === "interp" && attr.parts.length === 1 && typeof attr.parts[0] !== "string")
6278
+ return attr.parts[0].expr;
6279
+ }
6058
6280
  macroCall(node, p, scope) {
6059
6281
  const macro = this.macros.get(node.tag);
6060
6282
  if (this.macroStack.includes(macro.name)) {
@@ -6067,7 +6289,10 @@ class Compiler {
6067
6289
  sets.push({ name: attr.name, ci: this.compInput(attr) });
6068
6290
  else if (attr.k === "spread")
6069
6291
  sets.push({ spread: this.expr(attr.source, attr.loc) });
6292
+ else if (attr.k === "event")
6293
+ this.report("LIPS-C023", "error", `on-${attr.name}( … ) on the macro <${node.tag}> wires no listener`, attr.loc.offset, attr.loc.length, "Pass the handler as an argument (fn=self.pick) and wire it in the body");
6070
6294
  }
6295
+ node.children.length && this.report("LIPS-C024", "error", `<${node.tag}> is a macro: what it encloses is not rendered`, node.loc.offset, node.loc.length, "A component takes content: <{input.renderer}/>");
6071
6296
  this.macroStack.push(macro.name);
6072
6297
  const block = this.block(macro.children, [...scope, ...macro.argv]);
6073
6298
  this.macroStack.pop();
@@ -6079,6 +6304,10 @@ class Compiler {
6079
6304
  this.report("LIPS-C020", "error", `${attr.name}="…" on <${tag}> wires no listener`, attr.loc.offset, attr.loc.length, `Handlers use the instruction form: ${attr.name}( … ). ` + `Quoted, it is an ordinary attribute — the handler never runs and the source is emitted into the DOM.`);
6080
6305
  return true;
6081
6306
  }
6307
+ modifiers(attr, comp) {
6308
+ const mods = attr.name.split(".").slice(1), bad = mods.find((m) => !EVENT_MODS.has(m));
6309
+ (bad || comp && mods[0]) && this.report("LIPS-C022", bad ? "error" : "warning", bad ? `Unknown event modifier .${bad}: use .stop, .capture or .outside` : `.${mods[0]} does nothing on a component's event`, attr.loc.offset, attr.loc.length);
6310
+ }
6082
6311
  compLike(node, p, scope, kind) {
6083
6312
  const inputs = {}, spreads = [], events = [];
6084
6313
  let args = [];
@@ -6090,9 +6319,15 @@ class Compiler {
6090
6319
  case "bool":
6091
6320
  case "expr":
6092
6321
  case "interp":
6322
+ if (attr.name === "@format" && attr.k !== "bool") {
6323
+ const { ref, e } = this.formatBind(p, attr);
6324
+ inputs[attr.name] = { lit: { ref, e } };
6325
+ break;
6326
+ }
6093
6327
  inputs[attr.name] = this.compInput(attr);
6094
6328
  break;
6095
6329
  case "event":
6330
+ this.modifiers(attr, kind === "comp");
6096
6331
  events.push({ name: attr.name, e: this.synth(attr.source) });
6097
6332
  break;
6098
6333
  case "spread":
@@ -6129,15 +6364,15 @@ function parseMacros(src, diagnostics, check) {
6129
6364
  });
6130
6365
  continue;
6131
6366
  }
6132
- let name2 = "";
6367
+ let name = "";
6133
6368
  const argv = [];
6134
6369
  for (const attr of node.attrs) {
6135
6370
  if (attr.k === "args")
6136
6371
  argv.push(...attr.names);
6137
6372
  else if (attr.k === "literal" && attr.name === "name")
6138
- name2 = attr.value;
6373
+ name = attr.value;
6139
6374
  }
6140
- if (!name2) {
6375
+ if (!name) {
6141
6376
  diagnostics.push({
6142
6377
  code: "LIPS-C011",
6143
6378
  severity: "error",
@@ -6146,27 +6381,27 @@ function parseMacros(src, diagnostics, check) {
6146
6381
  });
6147
6382
  continue;
6148
6383
  }
6149
- macros.set(name2.toLowerCase(), { name: name2, argv, children: node.children });
6384
+ macros.set(name.toLowerCase(), { name, argv, children: node.children });
6150
6385
  }
6151
6386
  return macros;
6152
6387
  }
6153
- function compileTemplate(src, options2) {
6388
+ function compileTemplate(src, options) {
6154
6389
  const diagnostics = [];
6155
- const macros = parseMacros(options2?.macros || "", diagnostics, options2?.check);
6390
+ const macros = parseMacros(options?.macros || "", diagnostics, options?.check);
6156
6391
  const parsed = parseTemplate(src);
6157
- options2?.check?.(parsed.root.children, diagnostics, src);
6158
- options2?.transform?.(parsed.root.children, diagnostics);
6159
- const compiler = new Compiler(src, macros, options2?.target === "tree");
6392
+ options?.check?.(parsed.root.children, diagnostics, src);
6393
+ options?.transform?.(parsed.root.children, diagnostics);
6394
+ const compiler = new Compiler(src, macros, options?.target === "tree");
6160
6395
  const ir = compiler.compile(parsed.root.children);
6161
6396
  return { ir, diagnostics: [...diagnostics, ...parsed.diagnostics, ...compiler.diagnostics] };
6162
6397
  }
6163
6398
 
6164
6399
  // src/ir/router.ts
6165
- function safeDecode(value2) {
6400
+ function safeDecode(value) {
6166
6401
  try {
6167
- return decodeURIComponent(value2);
6402
+ return decodeURIComponent(value);
6168
6403
  } catch (e) {
6169
- return value2;
6404
+ return value;
6170
6405
  }
6171
6406
  }
6172
6407
  var parseQuery = (str) => Object.fromEntries(new URLSearchParams(str));
@@ -6186,32 +6421,39 @@ var routerTemplate = {
6186
6421
  onInput() {
6187
6422
  this.processor(this.input);
6188
6423
  },
6189
- processor(options2) {
6190
- if (!options2?.routes)
6424
+ processor(options) {
6425
+ if (!options?.routes)
6191
6426
  return;
6192
- if (options2.global)
6427
+ if (options.global)
6193
6428
  this.__global = true;
6194
- this.__routes = options2.routes.map(({ path, template, default: _default }) => {
6429
+ this.__routes = options.routes.map(({ path, template, default: _default }) => {
6195
6430
  if (_default)
6196
6431
  this.__defaultPath = path;
6197
6432
  const pathVars = path.match(/:[^\/]*(\/|$)/gi) || [], pathRegex = path.replaceAll("/", "\\/").replaceAll(/:[^\/]*(\/|$)/gi, "([^\\/]+)(?:\\/|$)");
6198
6433
  return { path, template, default: _default, pathVars, pathRegex: new RegExp(`${pathRegex}$`, "i") };
6199
6434
  });
6200
- if (options2.global) {
6435
+ if (options.global) {
6201
6436
  const cpathname = window.location.pathname;
6202
6437
  this.__defaultPath = this.__defaultPath && cpathname === "/" && cpathname !== this.__defaultPath ? this.__defaultPath : cpathname ? cpathname + window.location.search : this.__routes[0]?.path;
6203
6438
  }
6204
6439
  },
6205
6440
  onAttach() {
6206
6441
  if (this.input?.global) {
6207
- window.navigate = this.navigate.bind(this);
6208
- window.addEventListener("popstate", (e) => e.state && this.navigate(e.state.path, true));
6442
+ window.navigate = this.__navigate = this.navigate.bind(this);
6443
+ this.__popstate = (e) => e.state && this.navigate(e.state.path, true);
6444
+ window.addEventListener("popstate", this.__popstate);
6209
6445
  }
6210
6446
  typeof this.setContext === "function" && this.setContext("navigate", this.navigate.bind(this));
6447
+ this.__initial = true;
6211
6448
  this.__defaultPath && this.navigate(this.__defaultPath);
6449
+ this.__initial = false;
6450
+ },
6451
+ onDestroy() {
6452
+ this.__popstate && window.removeEventListener("popstate", this.__popstate);
6453
+ this.__navigate && window.navigate === this.__navigate && delete window.navigate;
6212
6454
  },
6213
6455
  navigate(path, back) {
6214
- !back && this.__global && history.pushState({ path }, "", path);
6456
+ !back && this.__global && history[this.__initial ? "replaceState" : "pushState"]({ path }, "", path);
6215
6457
  const parts = String(path).split("?");
6216
6458
  path = parts[0];
6217
6459
  const query = parts[1] ? parseQuery(parts[1]) : {};
@@ -6251,16 +6493,22 @@ var routerTemplate = {
6251
6493
  },
6252
6494
  default: `<{state.page} params=state.params query=state.query/>`
6253
6495
  };
6496
+ // src/component.ts
6497
+ function component(definition) {
6498
+ return definition ? definition : (named) => named;
6499
+ }
6254
6500
  // src/lips.ts
6255
6501
  setCompiler(compileTemplate);
6256
6502
  setStyleCompiler(compileStyle);
6257
6503
  setMessageFormat(messageFormat);
6504
+ setNameCheck(taken);
6258
6505
  registerBuiltin("router", routerTemplate);
6259
6506
  var lips_default = IRLips;
6260
6507
  export {
6261
6508
  batch,
6262
6509
  compileStyle,
6263
6510
  compileTemplate,
6511
+ component,
6264
6512
  lips_default as default,
6265
6513
  effect,
6266
6514
  parseSFC,
@@ -6271,4 +6519,4 @@ export {
6271
6519
  untrack
6272
6520
  };
6273
6521
 
6274
- //# debugId=C430E8D49339D07564756E2164756E21
6522
+ //# debugId=FAD62A6241A2D69364756E2164756E21