@rohal12/spindle 0.59.25 → 0.59.27

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.
@@ -39,7 +39,7 @@ function create() {
39
39
  */
40
40
  function randomUUID() {
41
41
  if (typeof crypto.randomUUID === "function") return crypto.randomUUID();
42
- const bytes = crypto.getRandomValues(new Uint8Array(16));
42
+ const bytes = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16));
43
43
  bytes[6] = bytes[6] & 15 | 64;
44
44
  bytes[8] = bytes[8] & 63 | 128;
45
45
  const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
@@ -89,7 +89,7 @@ var grammar_shared_default = {
89
89
  var LB = String.fromCharCode(123);
90
90
  var RB = String.fromCharCode(125);
91
91
  var { SIGIL_SCOPES, withSelectors } = grammar_shared_default;
92
- var VOID_TAGS = new Set([
92
+ var VOID_TAGS = /* @__PURE__ */ new Set([
93
93
  "area",
94
94
  "base",
95
95
  "br",
@@ -751,7 +751,7 @@ function peg$parse(input, options) {
751
751
  return withSelectors(node, s);
752
752
  }
753
753
  function peg$f35() {
754
- fail("Unclosed " + LB + input.substr(location().end.offset, 1) + "…: no } ends it", location(), "unclosed-expression");
754
+ fail("Unclosed {" + input.substr(location().end.offset, 1) + "…: no } ends it", location(), "unclosed-expression");
755
755
  }
756
756
  function peg$f36(start) {
757
757
  return skipTo(hooks.closeBrace(input, start, start));
@@ -783,13 +783,13 @@ function peg$parse(input, options) {
783
783
  tag.nameStart = nameEnd - name.length;
784
784
  tag.nameEnd = nameEnd;
785
785
  tag.selectorSpan = selectorSpan(s, ss, start);
786
- if (tail === null) fail("Unclosed " + LB + (close ? "/" : "") + name + "…: no } ends the macro", loc, "unclosed-macro");
786
+ if (tail === null) fail("Unclosed {" + (close ? "/" : "") + name + "…: no } ends the macro", loc, "unclosed-macro");
787
787
  tag.rawArgs = tail.trim();
788
788
  tag.argsStart = tag.rawArgs ? nameEnd + tail.length - tail.trimStart().length : nameEnd;
789
789
  tag.argsEnd = tag.argsStart + tag.rawArgs.length;
790
790
  if (close) {
791
791
  if (s !== NO_SELECTORS) fail("A closing tag takes no selectors: " + label(tag), loc, "closer-with-selectors");
792
- if (tag.rawArgs) fail("A closing tag takes no arguments: " + LB + "/" + name + " " + tag.rawArgs + RB, loc, "closer-with-arguments");
792
+ if (tag.rawArgs) fail("A closing tag takes no arguments: {/" + name + " " + tag.rawArgs + RB, loc, "closer-with-arguments");
793
793
  tag.kind = "close";
794
794
  } else {
795
795
  withSelectors(tag, s);
@@ -798,7 +798,7 @@ function peg$parse(input, options) {
798
798
  return tag;
799
799
  }
800
800
  function peg$f43(s) {
801
- fail("A closing tag starts with a letter after " + LB + "/", location(), "invalid-closer");
801
+ fail("A closing tag starts with a letter after {/", location(), "invalid-closer");
802
802
  }
803
803
  function peg$f44(value) {
804
804
  return EMAIL_AUTOLINK.test(value);
@@ -1677,12 +1677,14 @@ function peg$parse(input, options) {
1677
1677
  s3 = peg$FAILED;
1678
1678
  if (peg$silentFails === 0) peg$fail(peg$e13);
1679
1679
  }
1680
- if (s3 === peg$FAILED) if (input.substr(peg$currPos, 2) === peg$c8) {
1681
- s3 = peg$c8;
1682
- peg$currPos += 2;
1683
- } else {
1684
- s3 = peg$FAILED;
1685
- if (peg$silentFails === 0) peg$fail(peg$e12);
1680
+ if (s3 === peg$FAILED) {
1681
+ if (input.substr(peg$currPos, 2) === peg$c8) {
1682
+ s3 = peg$c8;
1683
+ peg$currPos += 2;
1684
+ } else {
1685
+ s3 = peg$FAILED;
1686
+ if (peg$silentFails === 0) peg$fail(peg$e12);
1687
+ }
1686
1688
  }
1687
1689
  peg$silentFails--;
1688
1690
  if (s3 === peg$FAILED) s2 = void 0;
@@ -1721,12 +1723,14 @@ function peg$parse(input, options) {
1721
1723
  s3 = peg$FAILED;
1722
1724
  if (peg$silentFails === 0) peg$fail(peg$e13);
1723
1725
  }
1724
- if (s3 === peg$FAILED) if (input.substr(peg$currPos, 2) === peg$c8) {
1725
- s3 = peg$c8;
1726
- peg$currPos += 2;
1727
- } else {
1728
- s3 = peg$FAILED;
1729
- if (peg$silentFails === 0) peg$fail(peg$e12);
1726
+ if (s3 === peg$FAILED) {
1727
+ if (input.substr(peg$currPos, 2) === peg$c8) {
1728
+ s3 = peg$c8;
1729
+ peg$currPos += 2;
1730
+ } else {
1731
+ s3 = peg$FAILED;
1732
+ if (peg$silentFails === 0) peg$fail(peg$e12);
1733
+ }
1730
1734
  }
1731
1735
  peg$silentFails--;
1732
1736
  if (s3 === peg$FAILED) s2 = void 0;
@@ -3409,7 +3413,7 @@ var BLOCK_MACROS = new NameSet([
3409
3413
  "nobr"
3410
3414
  ]);
3411
3415
  /** Macros whose body is JavaScript source, kept verbatim. */
3412
- var RAW_BODY_MACROS = new Set(["do"]);
3416
+ var RAW_BODY_MACROS = /* @__PURE__ */ new Set(["do"]);
3413
3417
  /** Whether a macro's body is JavaScript, kept verbatim (`{do}`). */
3414
3418
  function isRawMacro(name) {
3415
3419
  return RAW_BODY_MACROS.has(name);
@@ -3423,7 +3427,7 @@ function registerBlockMacro(name) {
3423
3427
  BLOCK_MACROS.add(name);
3424
3428
  }
3425
3429
  /** Macros whose branches render as one: the node holds one per branch. */
3426
- var BRANCHING = new Set([
3430
+ var BRANCHING = /* @__PURE__ */ new Set([
3427
3431
  "if",
3428
3432
  "switch",
3429
3433
  "timed"
@@ -4728,7 +4732,8 @@ function binop(name, prec) {
4728
4732
  binop: prec
4729
4733
  });
4730
4734
  }
4731
- var beforeExpr = { beforeExpr: true }, startsExpr = { startsExpr: true };
4735
+ var beforeExpr = { beforeExpr: true };
4736
+ var startsExpr = { startsExpr: true };
4732
4737
  var keywords = {};
4733
4738
  function kw(name, options) {
4734
4739
  if (options === void 0) options = {};
@@ -4983,11 +4988,27 @@ function pushComment(options, array) {
4983
4988
  array.push(comment);
4984
4989
  };
4985
4990
  }
4986
- var SCOPE_TOP = 1, SCOPE_FUNCTION = 2, SCOPE_ASYNC = 4, SCOPE_GENERATOR = 8, SCOPE_ARROW = 16, SCOPE_SIMPLE_CATCH = 32, SCOPE_SUPER = 64, SCOPE_DIRECT_SUPER = 128, SCOPE_CLASS_STATIC_BLOCK = 256, SCOPE_CLASS_FIELD_INIT = 512, SCOPE_SWITCH = 1024, SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK;
4991
+ var SCOPE_TOP = 1;
4992
+ var SCOPE_FUNCTION = 2;
4993
+ var SCOPE_ASYNC = 4;
4994
+ var SCOPE_GENERATOR = 8;
4995
+ var SCOPE_ARROW = 16;
4996
+ var SCOPE_SIMPLE_CATCH = 32;
4997
+ var SCOPE_SUPER = 64;
4998
+ var SCOPE_DIRECT_SUPER = 128;
4999
+ var SCOPE_CLASS_STATIC_BLOCK = 256;
5000
+ var SCOPE_CLASS_FIELD_INIT = 512;
5001
+ var SCOPE_SWITCH = 1024;
5002
+ var SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK;
4987
5003
  function functionFlags(async, generator) {
4988
5004
  return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0);
4989
5005
  }
4990
- var BIND_NONE = 0, BIND_VAR = 1, BIND_LEXICAL = 2, BIND_FUNCTION = 3, BIND_SIMPLE_CATCH = 4, BIND_OUTSIDE = 5;
5006
+ var BIND_NONE = 0;
5007
+ var BIND_VAR = 1;
5008
+ var BIND_LEXICAL = 2;
5009
+ var BIND_FUNCTION = 3;
5010
+ var BIND_SIMPLE_CATCH = 4;
5011
+ var BIND_OUTSIDE = 5;
4991
5012
  var Parser = function Parser(options, input, startPos) {
4992
5013
  this.options = options = getOptions(options);
4993
5014
  this.sourceFile = options.sourceFile;
@@ -5242,7 +5263,8 @@ pp$8.parseTopLevel = function(node) {
5242
5263
  node.sourceType = this.options.sourceType === "commonjs" ? "script" : this.options.sourceType;
5243
5264
  return this.finishNode(node, "Program");
5244
5265
  };
5245
- var loopLabel = { kind: "loop" }, switchLabel = { kind: "switch" };
5266
+ var loopLabel = { kind: "loop" };
5267
+ var switchLabel = { kind: "switch" };
5246
5268
  pp$8.isLet = function(context) {
5247
5269
  if (this.options.ecmaVersion < 6 || !this.isContextual("let")) return false;
5248
5270
  skipWhiteSpace.lastIndex = this.pos;
@@ -5671,7 +5693,9 @@ pp$8.parseVarId = function(decl, kind) {
5671
5693
  decl.id = kind === "using" || kind === "await using" ? this.parseIdent() : this.parseBindingAtom();
5672
5694
  this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
5673
5695
  };
5674
- var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;
5696
+ var FUNC_STATEMENT = 1;
5697
+ var FUNC_HANGING_STATEMENT = 2;
5698
+ var FUNC_NULLABLE_ID = 4;
5675
5699
  pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, forInit) {
5676
5700
  this.initFunction(node);
5677
5701
  if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
@@ -5746,13 +5770,17 @@ pp$8.parseClassElement = function(constructorAllowsSuper) {
5746
5770
  else keyName = "static";
5747
5771
  }
5748
5772
  node.static = isStatic;
5749
- if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) if ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon()) isAsync = true;
5750
- else keyName = "async";
5773
+ if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) {
5774
+ if ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon()) isAsync = true;
5775
+ else keyName = "async";
5776
+ }
5751
5777
  if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types$1.star)) isGenerator = true;
5752
5778
  if (!keyName && !isAsync && !isGenerator) {
5753
5779
  var lastValue = this.value;
5754
- if (this.eatContextual("get") || this.eatContextual("set")) if (this.isClassElementNameStart()) kind = lastValue;
5755
- else keyName = lastValue;
5780
+ if (this.eatContextual("get") || this.eatContextual("set")) {
5781
+ if (this.isClassElementNameStart()) kind = lastValue;
5782
+ else keyName = lastValue;
5783
+ }
5756
5784
  }
5757
5785
  if (keyName) {
5758
5786
  node.computed = false;
@@ -5845,8 +5873,10 @@ pp$8.exitClassBody = function() {
5845
5873
  var parent = len === 0 ? null : this.privateNameStack[len - 1];
5846
5874
  for (var i = 0; i < used.length; ++i) {
5847
5875
  var id = used[i];
5848
- if (!hasOwn$1(declared, id.name)) if (parent) parent.used.push(id);
5849
- else this.raiseRecoverable(id.start, "Private field '#" + id.name + "' must be declared in an enclosing class");
5876
+ if (!hasOwn$1(declared, id.name)) {
5877
+ if (parent) parent.used.push(id);
5878
+ else this.raiseRecoverable(id.start, "Private field '#" + id.name + "' must be declared in an enclosing class");
5879
+ }
5850
5880
  }
5851
5881
  };
5852
5882
  function isPrivateNameConflicted(privateNameMap, element) {
@@ -5868,10 +5898,12 @@ function checkKeyName(node, name) {
5868
5898
  return !computed && (key.type === "Identifier" && key.name === name || key.type === "Literal" && key.value === name);
5869
5899
  }
5870
5900
  pp$8.parseExportAllDeclaration = function(node, exports$1) {
5871
- if (this.options.ecmaVersion >= 11) if (this.eatContextual("as")) {
5872
- node.exported = this.parseModuleExportName();
5873
- this.checkExport(exports$1, node.exported, this.lastTokStart);
5874
- } else node.exported = null;
5901
+ if (this.options.ecmaVersion >= 11) {
5902
+ if (this.eatContextual("as")) {
5903
+ node.exported = this.parseModuleExportName();
5904
+ this.checkExport(exports$1, node.exported, this.lastTokStart);
5905
+ } else node.exported = null;
5906
+ }
5875
5907
  this.expectContextual("from");
5876
5908
  if (this.type !== types$1.string) this.unexpected();
5877
5909
  node.source = this.parseExprAtom();
@@ -6389,9 +6421,11 @@ pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) {
6389
6421
  var kind = prop.kind;
6390
6422
  if (this.options.ecmaVersion >= 6) {
6391
6423
  if (name === "__proto__" && kind === "init") {
6392
- if (propHash.proto) if (refDestructuringErrors) {
6393
- if (refDestructuringErrors.doubleProto < 0) refDestructuringErrors.doubleProto = key.start;
6394
- } else this.raiseRecoverable(key.start, "Redefinition of __proto__ property");
6424
+ if (propHash.proto) {
6425
+ if (refDestructuringErrors) {
6426
+ if (refDestructuringErrors.doubleProto < 0) refDestructuringErrors.doubleProto = key.start;
6427
+ } else this.raiseRecoverable(key.start, "Redefinition of __proto__ property");
6428
+ }
6395
6429
  propHash.proto = true;
6396
6430
  }
6397
6431
  return;
@@ -6425,8 +6459,10 @@ pp$5.parseExpression = function(forInit, refDestructuringErrors) {
6425
6459
  });
6426
6460
  };
6427
6461
  pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {
6428
- if (this.isContextual("yield")) if (this.inGenerator) return this.parseYield(forInit);
6429
- else this.exprAllowed = false;
6462
+ if (this.isContextual("yield")) {
6463
+ if (this.inGenerator) return this.parseYield(forInit);
6464
+ else this.exprAllowed = false;
6465
+ }
6430
6466
  var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldDoubleProto = -1;
6431
6467
  if (refDestructuringErrors) {
6432
6468
  oldParenAssign = refDestructuringErrors.parenthesizedAssign;
@@ -6545,9 +6581,10 @@ pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forIni
6545
6581
  expr = this.finishNode(node$1, "UpdateExpression");
6546
6582
  }
6547
6583
  }
6548
- if (!incDec && !(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.starstar)) if (sawUnary) this.unexpected(this.lastTokStart);
6549
- else return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false, false, forInit), "**", false);
6550
- else return expr;
6584
+ if (!incDec && !(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.starstar)) {
6585
+ if (sawUnary) this.unexpected(this.lastTokStart);
6586
+ else return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false, false, forInit), "**", false);
6587
+ } else return expr;
6551
6588
  };
6552
6589
  function isLocalVariableAccess(node) {
6553
6590
  return node.type === "Identifier" || node.type === "ParenthesizedExpression" && isLocalVariableAccess(node.expression);
@@ -6745,17 +6782,18 @@ pp$5.parseExprImport = function(forNew) {
6745
6782
  pp$5.parseDynamicImport = function(node) {
6746
6783
  this.next();
6747
6784
  node.source = this.parseMaybeAssign();
6748
- if (this.options.ecmaVersion >= 16) if (!this.eat(types$1.parenR)) {
6749
- this.expect(types$1.comma);
6750
- if (!this.afterTrailingComma(types$1.parenR)) {
6751
- node.options = this.parseMaybeAssign();
6752
- if (!this.eat(types$1.parenR)) {
6753
- this.expect(types$1.comma);
6754
- if (!this.afterTrailingComma(types$1.parenR)) this.unexpected();
6755
- }
6785
+ if (this.options.ecmaVersion >= 16) {
6786
+ if (!this.eat(types$1.parenR)) {
6787
+ this.expect(types$1.comma);
6788
+ if (!this.afterTrailingComma(types$1.parenR)) {
6789
+ node.options = this.parseMaybeAssign();
6790
+ if (!this.eat(types$1.parenR)) {
6791
+ this.expect(types$1.comma);
6792
+ if (!this.afterTrailingComma(types$1.parenR)) this.unexpected();
6793
+ }
6794
+ } else node.options = null;
6756
6795
  } else node.options = null;
6757
- } else node.options = null;
6758
- else if (!this.eat(types$1.parenR)) {
6796
+ } else if (!this.eat(types$1.parenR)) {
6759
6797
  var errorPos = this.start;
6760
6798
  if (this.eat(types$1.comma) && this.eat(types$1.parenR)) this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
6761
6799
  else this.unexpected(errorPos);
@@ -6989,12 +7027,14 @@ pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP
6989
7027
  } else this.unexpected();
6990
7028
  };
6991
7029
  pp$5.parsePropertyName = function(prop) {
6992
- if (this.options.ecmaVersion >= 6) if (this.eat(types$1.bracketL)) {
6993
- prop.computed = true;
6994
- prop.key = this.parseMaybeAssign();
6995
- this.expect(types$1.bracketR);
6996
- return prop.key;
6997
- } else prop.computed = false;
7030
+ if (this.options.ecmaVersion >= 6) {
7031
+ if (this.eat(types$1.bracketL)) {
7032
+ prop.computed = true;
7033
+ prop.key = this.parseMaybeAssign();
7034
+ this.expect(types$1.bracketR);
7035
+ return prop.key;
7036
+ } else prop.computed = false;
7037
+ }
6998
7038
  return prop.key = this.type === types$1.num || this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never");
6999
7039
  };
7000
7040
  pp$5.initFunction = function(node) {
@@ -7129,8 +7169,10 @@ pp$5.parsePrivateIdent = function() {
7129
7169
  else this.unexpected();
7130
7170
  this.next();
7131
7171
  this.finishNode(node, "PrivateIdentifier");
7132
- if (this.options.checkPrivateFields) if (this.privateNameStack.length === 0) this.raise(node.start, "Private field '#" + node.name + "' must be declared in an enclosing class");
7133
- else this.privateNameStack[this.privateNameStack.length - 1].used.push(node);
7172
+ if (this.options.checkPrivateFields) {
7173
+ if (this.privateNameStack.length === 0) this.raise(node.start, "Private field '#" + node.name + "' must be declared in an enclosing class");
7174
+ else this.privateNameStack[this.privateNameStack.length - 1].used.push(node);
7175
+ }
7134
7176
  return node;
7135
7177
  };
7136
7178
  pp$5.parseYield = function(forInit) {
@@ -7266,23 +7308,21 @@ var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic";
7266
7308
  var ecma11BinaryProperties = ecma10BinaryProperties;
7267
7309
  var ecma12BinaryProperties = ecma11BinaryProperties + " EBase EComp EMod EPres ExtPict";
7268
7310
  var ecma13BinaryProperties = ecma12BinaryProperties;
7269
- var ecma14BinaryProperties = ecma13BinaryProperties;
7270
7311
  var unicodeBinaryProperties = {
7271
7312
  9: ecma9BinaryProperties,
7272
7313
  10: ecma10BinaryProperties,
7273
7314
  11: ecma11BinaryProperties,
7274
7315
  12: ecma12BinaryProperties,
7275
7316
  13: ecma13BinaryProperties,
7276
- 14: ecma14BinaryProperties
7317
+ 14: ecma13BinaryProperties
7277
7318
  };
7278
- var ecma14BinaryPropertiesOfStrings = "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji";
7279
7319
  var unicodeBinaryPropertiesOfStrings = {
7280
7320
  9: "",
7281
7321
  10: "",
7282
7322
  11: "",
7283
7323
  12: "",
7284
7324
  13: "",
7285
- 14: ecma14BinaryPropertiesOfStrings
7325
+ 14: "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji"
7286
7326
  };
7287
7327
  var unicodeGeneralCategoryValues = "Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu";
7288
7328
  var ecma9ScriptValues = "Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb";
@@ -7290,14 +7330,13 @@ var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Han
7290
7330
  var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
7291
7331
  var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi";
7292
7332
  var ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith";
7293
- var ecma14ScriptValues = ecma13ScriptValues + " " + scriptValuesAddedInUnicode;
7294
7333
  var unicodeScriptValues = {
7295
7334
  9: ecma9ScriptValues,
7296
7335
  10: ecma10ScriptValues,
7297
7336
  11: ecma11ScriptValues,
7298
7337
  12: ecma12ScriptValues,
7299
7338
  13: ecma13ScriptValues,
7300
- 14: ecma14ScriptValues
7339
+ 14: ecma13ScriptValues + " " + scriptValuesAddedInUnicode
7301
7340
  };
7302
7341
  var data = {};
7303
7342
  function buildUnicodeData(ecmaVersion) {
@@ -7668,9 +7707,11 @@ pp$1.regexp_groupSpecifier = function(state) {
7668
7707
  if (!this.regexp_eatGroupName(state)) state.raise("Invalid group");
7669
7708
  var trackDisjunction = this.options.ecmaVersion >= 16;
7670
7709
  var known = state.groupNames[state.lastStringValue];
7671
- if (known) if (trackDisjunction) {
7672
- for (var i = 0, list = known; i < list.length; i += 1) if (!list[i].separatedFrom(state.branchID)) state.raise("Duplicate capture group name");
7673
- } else state.raise("Duplicate capture group name");
7710
+ if (known) {
7711
+ if (trackDisjunction) {
7712
+ for (var i = 0, list = known; i < list.length; i += 1) if (!list[i].separatedFrom(state.branchID)) state.raise("Duplicate capture group name");
7713
+ } else state.raise("Duplicate capture group name");
7714
+ }
7674
7715
  if (trackDisjunction) (known || (state.groupNames[state.lastStringValue] = [])).push(state.branchID);
7675
7716
  else state.groupNames[state.lastStringValue] = true;
7676
7717
  }
@@ -8684,12 +8725,14 @@ pp.readTmplToken = function() {
8684
8725
  if (this.pos >= this.input.length) this.raise(this.start, "Unterminated template");
8685
8726
  var ch = this.input.charCodeAt(this.pos);
8686
8727
  if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) {
8687
- if (this.pos === this.start && (this.type === types$1.template || this.type === types$1.invalidTemplate)) if (ch === 36) {
8688
- this.pos += 2;
8689
- return this.finishToken(types$1.dollarBraceL);
8690
- } else {
8691
- ++this.pos;
8692
- return this.finishToken(types$1.backQuote);
8728
+ if (this.pos === this.start && (this.type === types$1.template || this.type === types$1.invalidTemplate)) {
8729
+ if (ch === 36) {
8730
+ this.pos += 2;
8731
+ return this.finishToken(types$1.dollarBraceL);
8732
+ } else {
8733
+ ++this.pos;
8734
+ return this.finishToken(types$1.backQuote);
8735
+ }
8693
8736
  }
8694
8737
  out += this.input.slice(chunkStart, this.pos);
8695
8738
  return this.finishToken(types$1.template, out);
@@ -8706,9 +8749,7 @@ pp.readTmplToken = function() {
8706
8749
  case 10:
8707
8750
  out += "\n";
8708
8751
  break;
8709
- default:
8710
- out += String.fromCharCode(ch);
8711
- break;
8752
+ default: out += String.fromCharCode(ch);
8712
8753
  }
8713
8754
  if (this.options.locations) {
8714
8755
  ++this.curLine;
@@ -8731,7 +8772,6 @@ pp.readInvalidTemplateToken = function() {
8731
8772
  case "\u2029":
8732
8773
  ++this.curLine;
8733
8774
  this.lineStart = this.pos + 1;
8734
- break;
8735
8775
  }
8736
8776
  this.raise(this.start, "Unterminated template");
8737
8777
  };
@@ -8839,6 +8879,9 @@ Parser.acorn = {
8839
8879
  lineBreakG,
8840
8880
  nonASCIIwhitespace
8841
8881
  };
8882
+ function parse$1(input, options) {
8883
+ return Parser.parse(input, options);
8884
+ }
8842
8885
  //#endregion
8843
8886
  //#region src/js-lexer.ts
8844
8887
  /**
@@ -8890,7 +8933,7 @@ function notABody(src, pos) {
8890
8933
  return NOT_A_BODY_RE.test(src);
8891
8934
  }
8892
8935
  /** Tokens that may end an operand, and so a statement before a line break. */
8893
- var OPERAND_ENDS = new Set([
8936
+ var OPERAND_ENDS = /* @__PURE__ */ new Set([
8894
8937
  types$1.name,
8895
8938
  types$1.num,
8896
8939
  types$1.string,
@@ -9016,13 +9059,13 @@ function transientAssignment(p, end) {
9016
9059
  return false;
9017
9060
  }
9018
9061
  }
9019
- var OPENERS = new Set([
9062
+ var OPENERS = /* @__PURE__ */ new Set([
9020
9063
  types$1.parenL,
9021
9064
  types$1.bracketL,
9022
9065
  types$1.braceL,
9023
9066
  types$1.dollarBraceL
9024
9067
  ]);
9025
- var CLOSERS = new Set([
9068
+ var CLOSERS = /* @__PURE__ */ new Set([
9026
9069
  types$1.parenR,
9027
9070
  types$1.bracketR,
9028
9071
  types$1.braceR
@@ -9319,7 +9362,7 @@ var WORD_RE$1 = /[\p{ID_Continue}$.]*/uy;
9319
9362
  /** The flags after a regex literal, whatever they are. */
9320
9363
  var FLAGS_RE = /[\p{ID_Continue}$]*/uy;
9321
9364
  /** Words a string may follow with no space between (`of'x'`, `get"y"`). */
9322
- var WORDS_BEFORE_STRING = new Set([
9365
+ var WORDS_BEFORE_STRING = /* @__PURE__ */ new Set([
9323
9366
  "of",
9324
9367
  "get",
9325
9368
  "set",
@@ -10058,7 +10101,7 @@ function withEntry(ns, key, value) {
10058
10101
  var EMPTY_NAMESPACE = Object.freeze(createNamespace());
10059
10102
  /** The names whose own entries differ between `a` and `b`, `a`'s first. */
10060
10103
  function changedNames(a, b) {
10061
- return [...new Set([...Object.keys(a), ...Object.keys(b)])].filter((name) => ownValue(a, name) !== ownValue(b, name));
10104
+ return [.../* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)])].filter((name) => ownValue(a, name) !== ownValue(b, name));
10062
10105
  }
10063
10106
  var isCount = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
10064
10107
  /** The count of `name` in `counts`: its own entry, or 0. */
@@ -10657,7 +10700,7 @@ var OPTION_PARAMETERS = [{
10657
10700
  required: true
10658
10701
  }];
10659
10702
  /** The parameters of the built-in sub-macros that take arguments. */
10660
- var SUB_MACRO_PARAMETERS = new Map([["option", OPTION_PARAMETERS]]);
10703
+ var SUB_MACRO_PARAMETERS = /* @__PURE__ */ new Map([["option", OPTION_PARAMETERS]]);
10661
10704
  /** The parameters of the built-in sub-macro `name`, if it takes any. */
10662
10705
  function subMacroParameters(name) {
10663
10706
  return SUB_MACRO_PARAMETERS.get(name.toLowerCase());
@@ -10713,13 +10756,13 @@ function extentOf(piece) {
10713
10756
  return piece.kind === "code" ? piece.code.length : piece.kind === "text" ? piece.text.length : piece.length;
10714
10757
  }
10715
10758
  /** Macros whose whole argument text is one expression: branch conditions. */
10716
- var CONDITION_MACROS = new Set([
10759
+ var CONDITION_MACROS = /* @__PURE__ */ new Set([
10717
10760
  "if",
10718
10761
  "elseif",
10719
10762
  "case"
10720
10763
  ]);
10721
10764
  /** Block macros whose body is the name of a passage. */
10722
- var PASSAGE_BODIES = new Set(["dialog"]);
10765
+ var PASSAGE_BODIES = /* @__PURE__ */ new Set(["dialog"]);
10723
10766
  /**
10724
10767
  * `params` with each `string` and `text` parameter (options too) saying
10725
10768
  * what it holds: what it declares, else `holds`.
@@ -11233,9 +11276,11 @@ function textContainsChildren(text, parametersOf) {
11233
11276
  * Whether a tag renders a `{@children}` in an attribute value or a macro
11234
11277
  * argument that holds markup (`<span title="{@children}">`,
11235
11278
  * `{button "{@children}"}`). Literal arguments and code are not markup.
11279
+ * `src` is the text a flat token's offsets index into (its attribute values
11280
+ * are read from it); a token made from an AST has none.
11236
11281
  */
11237
- function tokenTextContainsChildren(token, parametersOf = registeredParameters) {
11238
- for (const piece of codeAndText("", [token], parametersOf)) if (piece.kind === "text" && textContainsChildren(piece.text, parametersOf)) return true;
11282
+ function tokenTextContainsChildren(token, parametersOf = registeredParameters, src = "") {
11283
+ for (const piece of codeAndText(src, [token], parametersOf)) if (piece.kind === "text" && textContainsChildren(piece.text, parametersOf)) return true;
11239
11284
  return false;
11240
11285
  }
11241
11286
  /**
@@ -11295,13 +11340,14 @@ var WIDGET_PARAMETERS = [{
11295
11340
  }];
11296
11341
  /**
11297
11342
  * The widget a {widget} definition's arguments declare: its name and its
11298
- * parameters, the words after it that start with `@` (docs/widgets.md).
11299
- * Other words, such as `$name`, are not parameters.
11343
+ * parameters, the words after it that start with `@` (docs/widgets.md),
11344
+ * separated by spaces or commas (`@a, @b`). Other words, such as `$name`, are
11345
+ * not parameters.
11300
11346
  */
11301
11347
  function widgetDef({ name = "", parameters = "" }) {
11302
11348
  return {
11303
11349
  name,
11304
- params: parameters.split(/\s+/).filter((word) => word.startsWith("@"))
11350
+ params: parameters.split(/[\s,]+/).filter((word) => word.startsWith("@"))
11305
11351
  };
11306
11352
  }
11307
11353
  /** Read the arguments of a {widget} definition (see widgetDef). */
@@ -11333,18 +11379,19 @@ function widgetDefinitions(passages, parametersOf = registeredParameters) {
11333
11379
  if (passage.name !== "StoryInit" && !passage.tags?.includes("widget")) continue;
11334
11380
  const open = [];
11335
11381
  const done = [];
11336
- for (const token of tokenizeMarkupTolerant(passage.content).tokens) if (token.type === "macro" && token.name.toLowerCase() === "widget") if (!token.isClose) open.push({
11337
- token,
11338
- isBlock: false
11339
- });
11340
- else {
11341
- const def = open.pop();
11342
- if (def) done.push({
11343
- ...def,
11344
- closeStart: token.start
11382
+ for (const token of tokenizeMarkupTolerant(passage.content).tokens) if (token.type === "macro" && token.name.toLowerCase() === "widget") {
11383
+ if (!token.isClose) open.push({
11384
+ token,
11385
+ isBlock: false
11345
11386
  });
11346
- }
11347
- else if (open.length > 0 && (token.type === "variable" && token.scope === "local" && token.name === "children" || tokenTextContainsChildren(token, parametersOf))) open[open.length - 1].isBlock = true;
11387
+ else {
11388
+ const def = open.pop();
11389
+ if (def) done.push({
11390
+ ...def,
11391
+ closeStart: token.start
11392
+ });
11393
+ }
11394
+ } else if (open.length > 0 && (token.type === "variable" && token.scope === "local" && token.name === "children" || tokenTextContainsChildren(token, parametersOf, passage.content))) open[open.length - 1].isBlock = true;
11348
11395
  done.push(...open);
11349
11396
  const defs = [];
11350
11397
  for (const { token, isBlock, closeStart } of done) try {
@@ -11426,7 +11473,7 @@ var OutgoingContext = createContext(null);
11426
11473
  * while the fields don't change, as the store's snapshot must.
11427
11474
  */
11428
11475
  function useStoryFields(...keys) {
11429
- const prev = useRef();
11476
+ const prev = useRef(void 0);
11430
11477
  const freeze = useContext(FrozenStateContext);
11431
11478
  return useStoryStore((s) => {
11432
11479
  if (prev.current && freeze?.(s)) return prev.current;
@@ -12385,7 +12432,7 @@ function unclosedHtml(text) {
12385
12432
  }
12386
12433
  }
12387
12434
  }
12388
- const construct = {
12435
+ return { text: { 60: {
12389
12436
  name: "unclosedHtml",
12390
12437
  resolveTo: joinData,
12391
12438
  tokenize(effects, ok, nok) {
@@ -12398,8 +12445,7 @@ function unclosedHtml(text) {
12398
12445
  return ok;
12399
12446
  };
12400
12447
  }
12401
- };
12402
- return { text: { 60: construct } };
12448
+ } } };
12403
12449
  }
12404
12450
  //#endregion
12405
12451
  //#region src/utils/source-location.ts
@@ -12442,7 +12488,7 @@ function logMacroError(label, error, location = currentSourceLocation()) {
12442
12488
  * from then on; otherwise the macro renders nothing.
12443
12489
  */
12444
12490
  function useRunOnce(macro, rawArgs, effect) {
12445
- const failure = useRef();
12491
+ const failure = useRef(void 0);
12446
12492
  if (failure.current === void 0) {
12447
12493
  failure.current = null;
12448
12494
  const location = currentSourceLocation();
@@ -12516,7 +12562,7 @@ var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
12516
12562
  * paragraphs between them would pull the children out of the structure (#423).
12517
12563
  * Text between the children, when it is only whitespace, is dropped.
12518
12564
  */
12519
- var STRUCTURAL_ELEMENTS = new Set([
12565
+ var STRUCTURAL_ELEMENTS = /* @__PURE__ */ new Set([
12520
12566
  "table",
12521
12567
  "thead",
12522
12568
  "tbody",
@@ -12532,7 +12578,7 @@ var STRUCTURAL_ELEMENTS = new Set([
12532
12578
  "datalist"
12533
12579
  ]);
12534
12580
  /** Elements whose content is literal text, not markdown. */
12535
- var PREFORMATTED_ELEMENTS = new Set([
12581
+ var PREFORMATTED_ELEMENTS = /* @__PURE__ */ new Set([
12536
12582
  "pre",
12537
12583
  "textarea",
12538
12584
  "style"
@@ -12658,7 +12704,8 @@ function htmlToPreact(html, ph, unwrapParagraphs = false) {
12658
12704
  if (unwrapParagraphs) {
12659
12705
  for (const child of Array.from(content.childNodes)) if (child.nodeType === Node.ELEMENT_NODE && child.nodeName === "P") child.replaceWith(...Array.from(child.childNodes));
12660
12706
  }
12661
- return /* @__PURE__ */ jsx(Fragment$1, { children: Array.from(content.childNodes).map((child, i) => convertDomNode(child, i, ph)) });
12707
+ const children = Array.from(content.childNodes).map((child, i) => convertDomNode(child, i, ph));
12708
+ return /* @__PURE__ */ jsx(Fragment$1, { children });
12662
12709
  }
12663
12710
  function convertDomNode(node, key, ph) {
12664
12711
  if (node.nodeType === Node.TEXT_NODE) {
@@ -12716,7 +12763,7 @@ function convertDomNode(node, key, ph) {
12716
12763
  * (lists, headings, paragraphs) is invalid in them: inline elements, and
12717
12764
  * block elements such as headings and buttons that only take inline children.
12718
12765
  */
12719
- var INLINE_ELEMENTS = new Set([
12766
+ var INLINE_ELEMENTS = /* @__PURE__ */ new Set([
12720
12767
  "a",
12721
12768
  "abbr",
12722
12769
  "b",
@@ -12769,7 +12816,7 @@ var INLINE_ELEMENTS = new Set([
12769
12816
  * as `=""` are passed as `true`, since '' is falsy (#177); one that only
12770
12817
  * resolves to '' through an interpolation stays ''.
12771
12818
  */
12772
- var LIVE_PROPERTIES = new Set([
12819
+ var LIVE_PROPERTIES = /* @__PURE__ */ new Set([
12773
12820
  "value",
12774
12821
  "checked",
12775
12822
  "selected",
@@ -12781,7 +12828,7 @@ var LIVE_PROPERTIES = new Set([
12781
12828
  * (`disabled="{$locked ? 'disabled' : ''}"`) is left out, so a variable can
12782
12829
  * switch it off.
12783
12830
  */
12784
- var BOOLEAN_ATTRIBUTES = new Set([
12831
+ var BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
12785
12832
  "allowfullscreen",
12786
12833
  "async",
12787
12834
  "autofocus",
@@ -12809,8 +12856,8 @@ var BOOLEAN_ATTRIBUTES = new Set([
12809
12856
  "selected"
12810
12857
  ]);
12811
12858
  /** Names set directly on SVG elements (see splitAttributes). */
12812
- var SVG_DIRECT = new Set([
12813
- ...new Set([
12859
+ var SVG_DIRECT = /* @__PURE__ */ new Set([
12860
+ .../* @__PURE__ */ new Set([
12814
12861
  "key",
12815
12862
  "ref",
12816
12863
  "children",
@@ -12876,6 +12923,7 @@ function splitAttributes(attributes, svg) {
12876
12923
  */
12877
12924
  function useDirectAttributes(direct) {
12878
12925
  const elementRef = useRef(null);
12926
+ const directKey = JSON.stringify(direct);
12879
12927
  useLayoutEffect(() => {
12880
12928
  const el = elementRef.current;
12881
12929
  if (!el || direct.length === 0) return;
@@ -12883,7 +12931,7 @@ function useDirectAttributes(direct) {
12883
12931
  return () => {
12884
12932
  for (const [name] of direct) el.removeAttribute(name);
12885
12933
  };
12886
- }, [JSON.stringify(direct)]);
12934
+ }, [directKey]);
12887
12935
  return direct.length > 0 ? elementRef : void 0;
12888
12936
  }
12889
12937
  var decodedText = /* @__PURE__ */ new Map();
@@ -12988,29 +13036,31 @@ function HtmlNodeRenderer({ node }) {
12988
13036
  const isInline = INLINE_ELEMENTS.has(tag);
12989
13037
  let children = void 0;
12990
13038
  let structural = false;
12991
- if (node.children.length > 0) if (tag === "style") children = node.children.map((n) => n.type === "text" ? n.value : renderSingleNode(n));
12992
- else if (inRaw || isRawRoot) children = renderInlineNodes(node.children);
12993
- else {
12994
- const summaryAt = tag === "details" ? leadingSummaryIndex(node.children) : -1;
12995
- const body = (nodes) => renderNodes(nodes, {
12996
- nobr,
12997
- locals,
12998
- inline: isInline
12999
- });
13000
- structural = STRUCTURAL_ELEMENTS.has(tag) && node.children.every((n) => n.type !== "text" || isBlankText(n));
13001
- children = structural ? node.children.filter((n) => n.type !== "text").map((n) => renderSingleNode(n)) : summaryAt === -1 ? body(node.children) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
13002
- body(node.children.slice(0, summaryAt)),
13003
- renderSingleNode(node.children[summaryAt]),
13004
- body(node.children.slice(summaryAt + 1))
13005
- ] });
13006
- if (isInline !== parentInline) children = /* @__PURE__ */ jsx(InlineContext.Provider, {
13007
- value: isInline,
13008
- children
13009
- });
13010
- if (structural !== parentStructural) children = /* @__PURE__ */ jsx(StructuralContext.Provider, {
13011
- value: structural,
13012
- children
13013
- });
13039
+ if (node.children.length > 0) {
13040
+ if (tag === "style") children = node.children.map((n) => n.type === "text" ? n.value : renderSingleNode(n));
13041
+ else if (inRaw || isRawRoot) children = renderInlineNodes(node.children);
13042
+ else {
13043
+ const summaryAt = tag === "details" ? leadingSummaryIndex(node.children) : -1;
13044
+ const body = (nodes) => renderNodes(nodes, {
13045
+ nobr,
13046
+ locals,
13047
+ inline: isInline
13048
+ });
13049
+ structural = STRUCTURAL_ELEMENTS.has(tag) && node.children.every((n) => n.type !== "text" || isBlankText(n));
13050
+ children = structural ? node.children.filter((n) => n.type !== "text").map((n) => renderSingleNode(n)) : summaryAt === -1 ? body(node.children) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
13051
+ body(node.children.slice(0, summaryAt)),
13052
+ renderSingleNode(node.children[summaryAt]),
13053
+ body(node.children.slice(summaryAt + 1))
13054
+ ] });
13055
+ if (isInline !== parentInline) children = /* @__PURE__ */ jsx(InlineContext.Provider, {
13056
+ value: isInline,
13057
+ children
13058
+ });
13059
+ if (structural !== parentStructural) children = /* @__PURE__ */ jsx(StructuralContext.Provider, {
13060
+ value: structural,
13061
+ children
13062
+ });
13063
+ }
13014
13064
  }
13015
13065
  if (inSvg && tag === "foreignobject" && children) children = /* @__PURE__ */ jsx(SvgContext.Provider, {
13016
13066
  value: false,
@@ -13576,120 +13626,121 @@ function unflatten(parsed, revivers, options) {
13576
13626
  if (index >= values.length) invalid$1();
13577
13627
  const value = values[index];
13578
13628
  if (!value || typeof value !== "object") hydrated[index] = ops.fromPrimitive(value);
13579
- else if (Array.isArray(value)) if (typeof value[0] === "string") {
13580
- const type = value[0];
13581
- const reviver = revivers && Object.hasOwn(revivers, type) ? revivers[type] : void 0;
13582
- if (reviver) {
13583
- let i = value[1];
13584
- if (typeof i !== "number") i = values.push(value[1]) - 1;
13585
- if (Object.hasOwn(hydrated, i)) return hydrated[index] = reviver(hydrated[i]);
13586
- hydrating ??= /* @__PURE__ */ new Set();
13587
- if (hydrating.has(i)) throw new Error("Invalid circular reference");
13588
- hydrating.add(i);
13589
- hydrated[index] = reviver(hydrate(i));
13590
- hydrating.delete(i);
13591
- return hydrated[index];
13592
- }
13593
- switch (type) {
13594
- case "Date":
13595
- hydrated[index] = ops.fromISOString(value[1]);
13596
- break;
13597
- case "Set":
13598
- const set = ops.createSet();
13599
- hydrated[index] = set;
13600
- for (let i = 1; i < value.length; i += 1) ops.addValue(set, hydrate(value[i]));
13601
- break;
13602
- case "Map":
13603
- const map = ops.createMap();
13604
- hydrated[index] = map;
13605
- for (let i = 1; i < value.length; i += 2) ops.addEntry(map, hydrate(value[i]), hydrate(value[i + 1]));
13606
- break;
13607
- case "RegExp":
13608
- hydrated[index] = ops.fromRegExpInfo(value[1], value[2]);
13609
- break;
13610
- case "Object": {
13611
- const wrapped_index = value[1];
13612
- if (!(wrapped_index === -3 || wrapped_index === -4 || wrapped_index === -5 || wrapped_index === -6)) {
13613
- const wrapped = get_raw(wrapped_index);
13614
- const is_bigint = Array.isArray(wrapped) && wrapped[0] === "BigInt";
13615
- if ((wrapped === void 0 || typeof wrapped === "object") && !is_bigint) invalid$1();
13616
- }
13617
- hydrated[index] = ops.box(hydrate(wrapped_index));
13618
- break;
13629
+ else if (Array.isArray(value)) {
13630
+ if (typeof value[0] === "string") {
13631
+ const type = value[0];
13632
+ const reviver = revivers && Object.hasOwn(revivers, type) ? revivers[type] : void 0;
13633
+ if (reviver) {
13634
+ let i = value[1];
13635
+ if (typeof i !== "number") i = values.push(value[1]) - 1;
13636
+ if (Object.hasOwn(hydrated, i)) return hydrated[index] = reviver(hydrated[i]);
13637
+ hydrating ??= /* @__PURE__ */ new Set();
13638
+ if (hydrating.has(i)) throw new Error("Invalid circular reference");
13639
+ hydrating.add(i);
13640
+ hydrated[index] = reviver(hydrate(i));
13641
+ hydrating.delete(i);
13642
+ return hydrated[index];
13619
13643
  }
13620
- case "BigInt":
13621
- hydrated[index] = ops.fromPrimitive(BigInt(value[1]));
13622
- break;
13623
- case "null":
13624
- const obj = ops.createNullPrototypeObject();
13625
- hydrated[index] = obj;
13626
- for (let i = 1; i < value.length; i += 2) {
13627
- const key = value[i];
13628
- if (typeof key !== "string") throw new Error("Cannot parse an object with a non-string key");
13629
- if (key === "__proto__") throw new Error("Cannot parse an object with a `__proto__` property");
13630
- ops.set(obj, key, hydrate(value[i + 1]));
13644
+ switch (type) {
13645
+ case "Date":
13646
+ hydrated[index] = ops.fromISOString(value[1]);
13647
+ break;
13648
+ case "Set":
13649
+ const set = ops.createSet();
13650
+ hydrated[index] = set;
13651
+ for (let i = 1; i < value.length; i += 1) ops.addValue(set, hydrate(value[i]));
13652
+ break;
13653
+ case "Map":
13654
+ const map = ops.createMap();
13655
+ hydrated[index] = map;
13656
+ for (let i = 1; i < value.length; i += 2) ops.addEntry(map, hydrate(value[i]), hydrate(value[i + 1]));
13657
+ break;
13658
+ case "RegExp":
13659
+ hydrated[index] = ops.fromRegExpInfo(value[1], value[2]);
13660
+ break;
13661
+ case "Object": {
13662
+ const wrapped_index = value[1];
13663
+ if (!(wrapped_index === -3 || wrapped_index === -4 || wrapped_index === -5 || wrapped_index === -6)) {
13664
+ const wrapped = get_raw(wrapped_index);
13665
+ const is_bigint = Array.isArray(wrapped) && wrapped[0] === "BigInt";
13666
+ if ((wrapped === void 0 || typeof wrapped === "object") && !is_bigint) invalid$1();
13667
+ }
13668
+ hydrated[index] = ops.box(hydrate(wrapped_index));
13669
+ break;
13631
13670
  }
13632
- break;
13633
- case "Int8Array":
13634
- case "Uint8Array":
13635
- case "Uint8ClampedArray":
13636
- case "Int16Array":
13637
- case "Uint16Array":
13638
- case "Float16Array":
13639
- case "Int32Array":
13640
- case "Uint32Array":
13641
- case "Float32Array":
13642
- case "Float64Array":
13643
- case "BigInt64Array":
13644
- case "BigUint64Array":
13645
- case "DataView": {
13646
- const buffer_index = value[1];
13647
- const raw = get_raw(buffer_index);
13648
- if (!Array.isArray(raw) || raw[0] !== "ArrayBuffer") invalid$1();
13649
- const buffer = hydrate(buffer_index);
13650
- hydrated[index] = ops.fromViewInfo(type, buffer, value[2], value[3]);
13651
- break;
13671
+ case "BigInt":
13672
+ hydrated[index] = ops.fromPrimitive(BigInt(value[1]));
13673
+ break;
13674
+ case "null":
13675
+ const obj = ops.createNullPrototypeObject();
13676
+ hydrated[index] = obj;
13677
+ for (let i = 1; i < value.length; i += 2) {
13678
+ const key = value[i];
13679
+ if (typeof key !== "string") throw new Error("Cannot parse an object with a non-string key");
13680
+ if (key === "__proto__") throw new Error("Cannot parse an object with a `__proto__` property");
13681
+ ops.set(obj, key, hydrate(value[i + 1]));
13682
+ }
13683
+ break;
13684
+ case "Int8Array":
13685
+ case "Uint8Array":
13686
+ case "Uint8ClampedArray":
13687
+ case "Int16Array":
13688
+ case "Uint16Array":
13689
+ case "Float16Array":
13690
+ case "Int32Array":
13691
+ case "Uint32Array":
13692
+ case "Float32Array":
13693
+ case "Float64Array":
13694
+ case "BigInt64Array":
13695
+ case "BigUint64Array":
13696
+ case "DataView": {
13697
+ const buffer_index = value[1];
13698
+ const raw = get_raw(buffer_index);
13699
+ if (!Array.isArray(raw) || raw[0] !== "ArrayBuffer") invalid$1();
13700
+ const buffer = hydrate(buffer_index);
13701
+ hydrated[index] = ops.fromViewInfo(type, buffer, value[2], value[3]);
13702
+ break;
13703
+ }
13704
+ case "ArrayBuffer": {
13705
+ const base64 = value[1];
13706
+ if (typeof base64 !== "string") throw new Error("Invalid ArrayBuffer encoding");
13707
+ hydrated[index] = ops.fromArrayBuffer(decode64(base64));
13708
+ break;
13709
+ }
13710
+ case "URL":
13711
+ case "URLSearchParams":
13712
+ case "Temporal.Duration":
13713
+ case "Temporal.Instant":
13714
+ case "Temporal.PlainDate":
13715
+ case "Temporal.PlainTime":
13716
+ case "Temporal.PlainDateTime":
13717
+ case "Temporal.PlainMonthDay":
13718
+ case "Temporal.PlainYearMonth":
13719
+ case "Temporal.ZonedDateTime":
13720
+ hydrated[index] = ops.fromStringValue(type, value[1]);
13721
+ break;
13722
+ default: throw new Error(`Unknown type ${type}`);
13652
13723
  }
13653
- case "ArrayBuffer": {
13654
- const base64 = value[1];
13655
- if (typeof base64 !== "string") throw new Error("Invalid ArrayBuffer encoding");
13656
- hydrated[index] = ops.fromArrayBuffer(decode64(base64));
13657
- break;
13724
+ } else if (value[0] === -7) {
13725
+ const len = value[1];
13726
+ if (!is_valid_array_len(len)) invalid$1();
13727
+ const array = ops.createSparseArray(len);
13728
+ hydrated[index] = array;
13729
+ for (let i = 2; i < value.length; i += 2) {
13730
+ const idx = value[i];
13731
+ if (!is_valid_array_index(idx) || idx >= len) invalid$1();
13732
+ ops.set(array, idx, hydrate(value[i + 1]));
13733
+ }
13734
+ } else {
13735
+ const array = ops.createArray(value.length);
13736
+ hydrated[index] = array;
13737
+ for (let i = 0; i < value.length; i += 1) {
13738
+ const n = value[i];
13739
+ if (n === -2) continue;
13740
+ ops.set(array, i, hydrate(n));
13658
13741
  }
13659
- case "URL":
13660
- case "URLSearchParams":
13661
- case "Temporal.Duration":
13662
- case "Temporal.Instant":
13663
- case "Temporal.PlainDate":
13664
- case "Temporal.PlainTime":
13665
- case "Temporal.PlainDateTime":
13666
- case "Temporal.PlainMonthDay":
13667
- case "Temporal.PlainYearMonth":
13668
- case "Temporal.ZonedDateTime":
13669
- hydrated[index] = ops.fromStringValue(type, value[1]);
13670
- break;
13671
- default: throw new Error(`Unknown type ${type}`);
13672
- }
13673
- } else if (value[0] === -7) {
13674
- const len = value[1];
13675
- if (!is_valid_array_len(len)) invalid$1();
13676
- const array = ops.createSparseArray(len);
13677
- hydrated[index] = array;
13678
- for (let i = 2; i < value.length; i += 2) {
13679
- const idx = value[i];
13680
- if (!is_valid_array_index(idx) || idx >= len) invalid$1();
13681
- ops.set(array, idx, hydrate(value[i + 1]));
13682
13742
  }
13683
13743
  } else {
13684
- const array = ops.createArray(value.length);
13685
- hydrated[index] = array;
13686
- for (let i = 0; i < value.length; i += 1) {
13687
- const n = value[i];
13688
- if (n === -2) continue;
13689
- ops.set(array, i, hydrate(n));
13690
- }
13691
- }
13692
- else {
13693
13744
  const object = ops.createObject();
13694
13745
  hydrated[index] = object;
13695
13746
  for (const key of Object.keys(value)) {
@@ -14527,7 +14578,7 @@ function decodeQuietly(encoded) {
14527
14578
  */
14528
14579
  function checkSaveExport(value) {
14529
14580
  if (!isRecord(value)) throw new Error(INVALID_FILE);
14530
- if (!hasOwn(value, "formatVersion")) throw value.version === 1 ? new IncompatibleSaveError() : new Error(INVALID_FILE);
14581
+ if (!hasOwn(value, "formatVersion")) throw value.version === 1 ? new IncompatibleSaveError() : /* @__PURE__ */ new Error(INVALID_FILE);
14531
14582
  checkFormatVersion(value.formatVersion);
14532
14583
  if (typeof value.ifid !== "string") throw new Error(INVALID_FILE);
14533
14584
  const save = value.save;
@@ -15169,7 +15220,7 @@ function loosePairs() {
15169
15220
  const pairs = assumed.get(a);
15170
15221
  if (pairs?.has(b)) return true;
15171
15222
  if (pairs) pairs.add(b);
15172
- else assumed.set(a, new Set([b]));
15223
+ else assumed.set(a, /* @__PURE__ */ new Set([b]));
15173
15224
  };
15174
15225
  }
15175
15226
  /**
@@ -15302,7 +15353,7 @@ function equalKeys(a, b, assumed, keysOf = Object.keys) {
15302
15353
  return true;
15303
15354
  }
15304
15355
  /** Built-in prototypes (see builtinLike), whose instances hold no extra keys. */
15305
- var BUILTIN_PROTOS = new Set([
15356
+ var BUILTIN_PROTOS = /* @__PURE__ */ new Set([
15306
15357
  Array.prototype,
15307
15358
  Map.prototype,
15308
15359
  Set.prototype,
@@ -15762,7 +15813,7 @@ function applyChange(target, change) {
15762
15813
  }
15763
15814
  //#endregion
15764
15815
  //#region src/event-emitter.ts
15765
- var VALID_EVENTS = new Set([
15816
+ var VALID_EVENTS = /* @__PURE__ */ new Set([
15766
15817
  "storyinit",
15767
15818
  "beforerestart",
15768
15819
  "actionsChanged",
@@ -16312,7 +16363,6 @@ function quickSave$1(ifid, playthroughId, payload, slot, custom) {
16312
16363
  return record;
16313
16364
  });
16314
16365
  }
16315
- queued(hasQuickSaveNow);
16316
16366
  async function hasQuickSaveNow(ifid, slot) {
16317
16367
  return await slotRecord(ifid, slot) !== void 0;
16318
16368
  }
@@ -16797,7 +16847,7 @@ function changeTo(ns, path) {
16797
16847
  * replaces exactly what it replaced in program order.
16798
16848
  */
16799
16849
  function writtenPaths(before, after, patches) {
16800
- if (patches.some((p) => p.path.length === 1)) return [...new Set([...Object.keys(before), ...Object.keys(after)])].filter((root) => !hasOwn(before, root) || before[root] !== after[root]).map((root) => changeTo(after, [root]));
16850
+ if (patches.some((p) => p.path.length === 1)) return [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])].filter((root) => !hasOwn(before, root) || before[root] !== after[root]).map((root) => changeTo(after, [root]));
16801
16851
  const seen = /* @__PURE__ */ new Set();
16802
16852
  const changes = [];
16803
16853
  for (const patch of patches) {
@@ -17379,7 +17429,7 @@ function isDialogShowing() {
17379
17429
  //#region src/store.ts
17380
17430
  enablePatches();
17381
17431
  enableMapSet();
17382
- var SPECIAL_PASSAGES = new Set([
17432
+ var SPECIAL_PASSAGES = /* @__PURE__ */ new Set([
17383
17433
  "StoryInit",
17384
17434
  "StoryInterface",
17385
17435
  "StoryVariables",
@@ -17510,12 +17560,14 @@ function persistSession(get) {
17510
17560
  const { storyData, currentPassage, variables, history, historyIndex, visitCounts, renderCounts } = get();
17511
17561
  if (!storyData) return void 0;
17512
17562
  if (sessionMoments.length > history.length) sessionMoments.length = history.length;
17513
- if (sessionMoments.length < history.length) if (history.length - sessionMoments.length === 1) {
17514
- const i = history.length - 1;
17515
- sessionMoments[i] = savedMoment(history[i], variables);
17516
- } else forEachRecorded(history.length, (vars, i) => {
17517
- if (i >= sessionMoments.length) sessionMoments[i] = savedMoment(history[i], vars);
17518
- });
17563
+ if (sessionMoments.length < history.length) {
17564
+ if (history.length - sessionMoments.length === 1) {
17565
+ const i = history.length - 1;
17566
+ sessionMoments[i] = savedMoment(history[i], variables);
17567
+ } else forEachRecorded(history.length, (vars, i) => {
17568
+ if (i >= sessionMoments.length) sessionMoments[i] = savedMoment(history[i], vars);
17569
+ });
17570
+ }
17519
17571
  return saveSession(storyData.ifid, {
17520
17572
  passage: currentPassage,
17521
17573
  variables,
@@ -17933,9 +17985,10 @@ function writeKey(holder, key, value, change) {
17933
17985
  const deleted = change?.deleted ?? false;
17934
17986
  if (Array.isArray(holder)) {
17935
17987
  const index = Number(key);
17936
- if (deleted) if (change && "hole" in change) delete holder[index];
17937
- else holder.length = Math.min(holder.length, index);
17938
- else if (change && "appended" in change) {
17988
+ if (deleted) {
17989
+ if (change && "hole" in change) delete holder[index];
17990
+ else holder.length = Math.min(holder.length, index);
17991
+ } else if (change && "appended" in change) {
17939
17992
  holder.length += change.gap ?? 0;
17940
17993
  holder.push(value);
17941
17994
  } else if (key === "length" && change) holder.length += value;
@@ -18504,7 +18557,8 @@ function StoryInterface() {
18504
18557
  const nobr = overridePassage?.tags.includes("nobr") ?? false;
18505
18558
  const rendered = useMemo(() => {
18506
18559
  try {
18507
- return /* @__PURE__ */ jsx(Fragment$1, { children: renderInlineNodes(parseMarkup(markup)) });
18560
+ const ast = parseMarkup(markup);
18561
+ return /* @__PURE__ */ jsx(Fragment$1, { children: renderInlineNodes(ast) });
18508
18562
  } catch (err) {
18509
18563
  return /* @__PURE__ */ jsxs("span", {
18510
18564
  class: "error",
@@ -18613,7 +18667,7 @@ var openModals = [];
18613
18667
  * - returns focus to the previously focused element on close.
18614
18668
  */
18615
18669
  /** The input types made of several segments, each a native Tab stop. */
18616
- var SEGMENTED_INPUTS = new Set([
18670
+ var SEGMENTED_INPUTS = /* @__PURE__ */ new Set([
18617
18671
  "date",
18618
18672
  "time",
18619
18673
  "datetime-local",
@@ -19011,7 +19065,7 @@ function App() {
19011
19065
  //#region src/parser.ts
19012
19066
  var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
19013
19067
  /** HTML elements written without content or end tag, as innerHTML does. */
19014
- var VOID_ELEMENTS = new Set([
19068
+ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
19015
19069
  "area",
19016
19070
  "base",
19017
19071
  "basefont",
@@ -19127,7 +19181,7 @@ function parseStoryData() {
19127
19181
  const tags = (el.getAttribute("tags") || "").split(/\s+/).filter((t) => t.length > 0);
19128
19182
  const content = passageMarkup(el);
19129
19183
  const metadata = {};
19130
- const skipAttrs = new Set([
19184
+ const skipAttrs = /* @__PURE__ */ new Set([
19131
19185
  "pid",
19132
19186
  "name",
19133
19187
  "tags"
@@ -19906,14 +19960,14 @@ function installStoryAPI() {
19906
19960
  * Passages that hold no markup: declarations, and the JavaScript function
19907
19961
  * body of SaveTitle.
19908
19962
  */
19909
- var NOT_MARKUP = new Set([
19963
+ var NOT_MARKUP = /* @__PURE__ */ new Set([
19910
19964
  "StoryVariables",
19911
19965
  "StoryTransients",
19912
19966
  "SaveTitle"
19913
19967
  ]);
19914
19968
  var NOT_MARKUP_TAGS = ["script", "stylesheet"];
19915
19969
  /** Branch macros, which their parent macro renders. */
19916
- var BRANCH_MACROS = new Set([
19970
+ var BRANCH_MACROS = /* @__PURE__ */ new Set([
19917
19971
  "elseif",
19918
19972
  "else",
19919
19973
  "case",
@@ -19995,19 +20049,30 @@ function validateMarkup(passages, options) {
19995
20049
  const parsed = [];
19996
20050
  const widgets = /* @__PURE__ */ new Set();
19997
20051
  const passageNames = /* @__PURE__ */ new Set();
20052
+ const addWidgets = (tokens) => {
20053
+ for (const token of tokens) {
20054
+ if (token.type !== "macro" || token.isClose) continue;
20055
+ if (token.name.toLowerCase() !== "widget") continue;
20056
+ const name = widgetName(token.rawArgs);
20057
+ if (name) widgets.add(name);
20058
+ }
20059
+ };
19998
20060
  for (const passage of passages) {
19999
20061
  passageNames.add(passage.name);
20000
20062
  if (NOT_MARKUP.has(passage.name)) continue;
20001
20063
  if (passage.tags?.some((tag) => NOT_MARKUP_TAGS.includes(tag))) continue;
20002
20064
  const reported = !options.only || options.only(passage);
20065
+ if (options.tolerant) {
20066
+ const { tokens, errors } = analyzeMarkup(passage.content, { hooks });
20067
+ addWidgets(tokens);
20068
+ if (!reported) continue;
20069
+ for (const err of errors) reportError(passage, err, "");
20070
+ parsed.push([passage, tokens]);
20071
+ continue;
20072
+ }
20003
20073
  try {
20004
20074
  const tokens = tokenizeMarkup(passage.content);
20005
- for (const token of tokens) {
20006
- if (token.type !== "macro" || token.isClose) continue;
20007
- if (token.name.toLowerCase() !== "widget") continue;
20008
- const name = widgetName(token.rawArgs);
20009
- if (name) widgets.add(name);
20010
- }
20075
+ addWidgets(tokens);
20011
20076
  if (!reported) continue;
20012
20077
  parseMarkup(passage.content, { hooks });
20013
20078
  parsed.push([passage, tokens]);
@@ -20097,7 +20162,13 @@ function validateMarkup(passages, options) {
20097
20162
  */
20098
20163
  var NUMBER_RE = /(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:\d[\d_]*\.?[\d_]*|\.\d[\d_]*)(?:[eE][+-]?\d+)?)(n?)/y;
20099
20164
  var IDENT_RE = /[A-Za-z_$][\w$]*/y;
20165
+ var KEY_RE = /[\w$]+/y;
20100
20166
  var ARROW_RE = /(?:async\s+)?(?:\((?:[^()]|\([^()]*\))*\)|[A-Za-z_$][\w$]*)\s*=>/y;
20167
+ var ARRAY_INDEX_RE = /^(?:0|[1-9]\d{0,8})$/;
20168
+ var UNSUPPORTED_UNDEFINED = {
20169
+ unsupported: "undefined",
20170
+ value: "undefined"
20171
+ };
20101
20172
  /** Read `src`, one literal and nothing else. */
20102
20173
  function staticLiteral(src) {
20103
20174
  const reader = new Reader(src);
@@ -20105,6 +20176,27 @@ function staticLiteral(src) {
20105
20176
  reader.space();
20106
20177
  return reader.i === src.length ? value : void 0;
20107
20178
  }
20179
+ /**
20180
+ * The keys of an object in the order `Object.entries` lists them (array
20181
+ * indices first, ascending, then the others as they were added): the order
20182
+ * the runtime meets the members in.
20183
+ */
20184
+ function entryOrder(keys) {
20185
+ const all = [...keys];
20186
+ return [...all.filter((key) => ARRAY_INDEX_RE.test(key)).sort((a, b) => Number(a) - Number(b)), ...all.filter((key) => !ARRAY_INDEX_RE.test(key))];
20187
+ }
20188
+ /** `String(value)` of a BigInt literal's digits, or `undefined` if they are no BigInt. */
20189
+ function bigintValue(digits) {
20190
+ try {
20191
+ return BigInt(digits.replace(/_/g, "")).toString();
20192
+ } catch {
20193
+ return;
20194
+ }
20195
+ }
20196
+ /**
20197
+ * The cursor over a JavaScript text that the literal reader moves: the
20198
+ * helpers that skip what is not read are shared (see macro-discovery.ts).
20199
+ */
20108
20200
  var Reader = class {
20109
20201
  constructor(src) {
20110
20202
  this.src = src;
@@ -20146,6 +20238,15 @@ var Reader = class {
20146
20238
  closed
20147
20239
  };
20148
20240
  }
20241
+ /**
20242
+ * Skip the string literal at the cursor and read its value, or `undefined`
20243
+ * if it is not closed or not well-formed.
20244
+ */
20245
+ stringValue() {
20246
+ const at = this.i;
20247
+ const { closed } = this.string();
20248
+ return closed ? stringLiteralValue(this.src.slice(at, this.i)) ?? void 0 : void 0;
20249
+ }
20149
20250
  /** A template literal: a string, but for `${}`. */
20150
20251
  template() {
20151
20252
  const { src } = this;
@@ -20162,7 +20263,8 @@ var Reader = class {
20162
20263
  number() {
20163
20264
  const { src } = this;
20164
20265
  let i = this.i;
20165
- if (src.charAt(i) === "+" || src.charAt(i) === "-") {
20266
+ const sign = src.charAt(i);
20267
+ if (sign === "+" || sign === "-") {
20166
20268
  i++;
20167
20269
  while (/\s/.test(src.charAt(i))) i++;
20168
20270
  }
@@ -20170,7 +20272,13 @@ var Reader = class {
20170
20272
  const match = NUMBER_RE.exec(src);
20171
20273
  if (match) {
20172
20274
  this.i = NUMBER_RE.lastIndex;
20173
- return match[1] ? { unsupported: "bigint" } : { shape: { type: "number" } };
20275
+ if (!match[1]) return { shape: { type: "number" } };
20276
+ if (sign === "+") return { throws: "Cannot convert a BigInt value to a number" };
20277
+ const digits = bigintValue(match[0].slice(0, -1));
20278
+ return digits === void 0 ? void 0 : {
20279
+ unsupported: "bigint",
20280
+ value: sign === "-" && digits !== "0" ? `-${digits}` : digits
20281
+ };
20174
20282
  }
20175
20283
  IDENT_RE.lastIndex = i;
20176
20284
  if (IDENT_RE.exec(src)?.[0] === "Infinity") {
@@ -20181,8 +20289,9 @@ var Reader = class {
20181
20289
  /** A keyword, a function, or a name (which is not static). */
20182
20290
  word() {
20183
20291
  const { src } = this;
20184
- ARROW_RE.lastIndex = this.i;
20185
- if (ARROW_RE.test(src)) return this.function();
20292
+ const start = this.i;
20293
+ const arrow = this.arrow();
20294
+ if (arrow !== void 0) return arrow ? this.functionFrom(start) : void 0;
20186
20295
  IDENT_RE.lastIndex = this.i;
20187
20296
  const word = IDENT_RE.exec(src)?.[0];
20188
20297
  if (word === void 0) return void 0;
@@ -20200,72 +20309,152 @@ var Reader = class {
20200
20309
  return { shape: { type: "number" } };
20201
20310
  case "undefined":
20202
20311
  this.i = end;
20203
- return { unsupported: "undefined" };
20312
+ return UNSUPPORTED_UNDEFINED;
20313
+ case "void": {
20314
+ this.i = end;
20315
+ const operand = this.value();
20316
+ return operand && !("throws" in operand) ? UNSUPPORTED_UNDEFINED : operand;
20317
+ }
20204
20318
  case "function":
20205
20319
  case "class":
20206
- case "async": return this.function();
20320
+ case "async": return this.skipDeclaration(word) ? this.functionFrom(start) : void 0;
20207
20321
  }
20208
20322
  }
20209
- /** A function (or class): the rest is its body, which is not read. */
20210
- function() {
20211
- return this.unsupported({ unsupported: "function" });
20323
+ /** The function (or class) that was skipped since `start`. */
20324
+ functionFrom(start) {
20325
+ return {
20326
+ unsupported: "function",
20327
+ value: this.src.slice(start, this.i).trimEnd()
20328
+ };
20212
20329
  }
20213
- /** `value`, which makes the whole literal unsupported: the rest is not read. */
20214
- unsupported(value) {
20215
- this.i = this.src.length;
20216
- return value;
20330
+ /**
20331
+ * Skip the parameters of an arrow function and its body, which ends at a
20332
+ * `,` or `}` outside brackets, or at the end of the text. `undefined` if the
20333
+ * text at the cursor is no arrow function, false if it cannot be skipped.
20334
+ */
20335
+ arrow() {
20336
+ const { src } = this;
20337
+ ARROW_RE.lastIndex = this.i;
20338
+ if (!ARROW_RE.test(src)) return void 0;
20339
+ this.i = ARROW_RE.lastIndex;
20340
+ this.space();
20341
+ if (src.charAt(this.i) === "{") return this.skipBalanced();
20342
+ while (this.i < src.length && !",}".includes(src.charAt(this.i))) if (!this.skipOne()) break;
20343
+ return true;
20344
+ }
20345
+ /**
20346
+ * Skip a `function`, `async function` or `class` (its keyword `word` is at
20347
+ * the cursor), up to the end of its body.
20348
+ */
20349
+ skipDeclaration(word) {
20350
+ const { src } = this;
20351
+ this.i += word.length;
20352
+ this.space();
20353
+ if (word === "async") {
20354
+ IDENT_RE.lastIndex = this.i;
20355
+ if (IDENT_RE.exec(src)?.[0] !== "function") return false;
20356
+ return this.skipDeclaration("function");
20357
+ }
20358
+ if (word === "function") {
20359
+ if (src.charAt(this.i) === "*") this.i++;
20360
+ this.space();
20361
+ IDENT_RE.lastIndex = this.i;
20362
+ if (IDENT_RE.test(src)) this.i = IDENT_RE.lastIndex;
20363
+ this.space();
20364
+ if (src.charAt(this.i) !== "(" || !this.skipBalanced()) return false;
20365
+ this.space();
20366
+ } else while (this.i < src.length && src.charAt(this.i) !== "{") if (!this.skipOne()) return false;
20367
+ return src.charAt(this.i) === "{" && this.skipBalanced();
20217
20368
  }
20218
20369
  /** An object literal: the members that are static. */
20219
20370
  object() {
20220
20371
  const { src } = this;
20221
- const fields = /* @__PURE__ */ new Map();
20372
+ const members = /* @__PURE__ */ new Map();
20373
+ let thrown;
20222
20374
  this.i++;
20223
20375
  for (;;) {
20224
20376
  this.space();
20225
20377
  const c = src.charAt(this.i);
20226
20378
  if (c === "}") {
20227
20379
  this.i++;
20228
- return { shape: {
20229
- type: "object",
20230
- fields
20231
- } };
20380
+ return thrown === void 0 ? this.objectOf(members) : { throws: thrown };
20232
20381
  }
20233
20382
  if (c === ",") {
20234
20383
  this.i++;
20235
20384
  continue;
20236
20385
  }
20237
20386
  if (this.i >= src.length) return void 0;
20387
+ const start = this.i;
20238
20388
  const key = this.key();
20389
+ if (key === "__proto__") return void 0;
20239
20390
  this.space();
20240
- if (key !== void 0 && src.charAt(this.i) === ":") {
20391
+ const next = src.charAt(this.i);
20392
+ if (key !== void 0 && next === ":") {
20241
20393
  this.i++;
20242
20394
  const at = this.i;
20243
20395
  const value = this.value();
20244
20396
  this.space();
20245
- if (value && "unsupported" in value) return this.unsupported(value);
20246
- if (value && ",}".includes(src.charAt(this.i))) {
20247
- fields.set(key, value.shape);
20397
+ if (value && this.atMemberEnd()) {
20398
+ if ("throws" in value) thrown ??= value.throws;
20399
+ else members.set(key, "shape" in value ? value.shape : value);
20248
20400
  continue;
20249
20401
  }
20402
+ members.set(key, null);
20250
20403
  this.i = at;
20251
- } else if (key !== void 0 && src.charAt(this.i) === "(") return this.unsupported({ unsupported: "function" });
20404
+ } else if (key !== void 0 && next === "(") {
20405
+ if (!this.skipBalanced()) return void 0;
20406
+ this.space();
20407
+ if (src.charAt(this.i) === "{" && this.skipBalanced()) {
20408
+ members.set(key, {
20409
+ unsupported: "function",
20410
+ value: src.slice(start, this.i)
20411
+ });
20412
+ continue;
20413
+ }
20414
+ return;
20415
+ } else if (key !== void 0 && (next === "," || next === "}")) {
20416
+ members.set(key, null);
20417
+ continue;
20418
+ } else members.clear();
20252
20419
  if (!this.skipMember()) return void 0;
20253
20420
  }
20254
20421
  }
20422
+ /** Whether a member ends at the cursor. */
20423
+ atMemberEnd() {
20424
+ return this.i < this.src.length && ",}".includes(this.src.charAt(this.i));
20425
+ }
20426
+ /**
20427
+ * The object literal with these members: a value no variable can hold
20428
+ * anywhere in it (the first the runtime meets) is what it reads as.
20429
+ */
20430
+ objectOf(members) {
20431
+ const fields = /* @__PURE__ */ new Map();
20432
+ for (const key of entryOrder(members.keys())) {
20433
+ const member = members.get(key);
20434
+ if (!member) continue;
20435
+ if ("unsupported" in member) return member;
20436
+ fields.set(key, member);
20437
+ }
20438
+ return { shape: {
20439
+ type: "object",
20440
+ fields
20441
+ } };
20442
+ }
20255
20443
  /** The key of a member (a name, a string or a number), if it has one. */
20256
20444
  key() {
20257
20445
  const { src } = this;
20258
20446
  const c = src.charAt(this.i);
20259
- if (c === "\"" || c === "'") {
20260
- const { body, closed } = this.string();
20261
- return closed ? body : void 0;
20262
- }
20263
- const word = /[\w$]+/y;
20264
- word.lastIndex = this.i;
20265
- const found = word.exec(src)?.[0];
20447
+ if (c === "\"" || c === "'") return this.stringValue();
20448
+ KEY_RE.lastIndex = this.i;
20449
+ const found = KEY_RE.exec(src)?.[0];
20266
20450
  if (found === void 0) return void 0;
20267
- this.i = word.lastIndex;
20268
- return found;
20451
+ this.i = KEY_RE.lastIndex;
20452
+ if (!/^\d/.test(found)) return found;
20453
+ const digits = found.replace(/_/g, "");
20454
+ if (/^0\d/.test(digits)) return void 0;
20455
+ if (digits.endsWith("n") && !/^0[xX]/.test(digits)) return bigintValue(digits.slice(0, -1));
20456
+ const value = Number(digits);
20457
+ return Number.isNaN(value) ? void 0 : String(value);
20269
20458
  }
20270
20459
  /** Skip to the `,` or `}` that ends a member, balancing what is inside. */
20271
20460
  skipMember() {
@@ -20352,7 +20541,7 @@ function declarationRegex(sigil) {
20352
20541
  var VAR_PATH_RE = /([$%])(\w+(?:\.\w+)*)/y;
20353
20542
  /** Quoted first argument of an input macro naming a story variable. */
20354
20543
  var QUOTED_VAR_ARG_RE = /^["']\$(\w+(?:\.\w+)*)["']?$/;
20355
- var VALID_VAR_TYPES = new Set([
20544
+ var VALID_VAR_TYPES = /* @__PURE__ */ new Set([
20356
20545
  "number",
20357
20546
  "string",
20358
20547
  "boolean"
@@ -20399,6 +20588,27 @@ function shapeSchema(shape) {
20399
20588
  };
20400
20589
  }
20401
20590
  /**
20591
+ * What is wrong with the syntax of an initializer, as it is evaluated
20592
+ * (`return (expr)` in a function body), or `undefined`. `pos` is where, as an
20593
+ * index into `expr` (it may be past its end, for an unexpected end).
20594
+ */
20595
+ function initializerSyntaxError(expr) {
20596
+ const prefix = "return (";
20597
+ try {
20598
+ parse$1(prefix + expr + ")", {
20599
+ ecmaVersion: "latest",
20600
+ allowReturnOutsideFunction: true
20601
+ });
20602
+ } catch (err) {
20603
+ if (!(err instanceof SyntaxError)) throw err;
20604
+ const { pos } = err;
20605
+ return {
20606
+ message: err.message.replace(/ \(\d+:\d+\)$/, ""),
20607
+ pos: Math.max(0, pos - 8)
20608
+ };
20609
+ }
20610
+ }
20611
+ /**
20402
20612
  * Read the declarations of a StoryVariables (`$name = value`) or
20403
20613
  * StoryTransients (`%name = value`) passage, without evaluating them and
20404
20614
  * without throwing: every valid declaration, and every invalid line as an
@@ -20406,9 +20616,10 @@ function shapeSchema(shape) {
20406
20616
  *
20407
20617
  * A declaration is a line of the form `$name = expression`; blank lines are
20408
20618
  * skipped. A line that is not, and a name that cannot be a variable, are
20409
- * errors. So is an initializer that no variable can hold (a function,
20410
- * `undefined`), when it is a literal; whether any other initializer can only
20411
- * be known by running it. A name declared again is an error too, but both
20619
+ * errors. So is an initializer with a syntax error, and one that no variable
20620
+ * can hold (a function, `undefined`) when it is a literal, or one that throws
20621
+ * when it is a literal (`+1n`); whether any other initializer can only be
20622
+ * known by running it. A name declared again is an error too, but both
20412
20623
  * declarations are returned (the later wins when evaluated).
20413
20624
  */
20414
20625
  function parseDeclarations(content, sigil = "$") {
@@ -20451,10 +20662,19 @@ function parseDeclarations(content, sigil = "$") {
20451
20662
  };
20452
20663
  if (seen.has(name)) error("duplicate-declaration", nameStart, nameEnd, `Duplicate declaration of ${sigil}${name}`);
20453
20664
  seen.add(name);
20454
- const literal = staticLiteral(expr);
20455
- if (literal && "shape" in literal) declaration.schema = shapeSchema(literal.shape);
20456
- else if (literal) error("unsupported-value", declaration.valueStart, valueEnd, `Unsupported type "${literal.unsupported}" for value ${expr}. ${UNSUPPORTED_TYPE}`);
20457
20665
  declarations.push(declaration);
20666
+ const failed = `Failed to evaluate "${sigil}${name} = ${expr}"`;
20667
+ const syntax = initializerSyntaxError(expr);
20668
+ if (syntax) {
20669
+ const at = Math.min(syntax.pos, expr.length - 1);
20670
+ error("syntax", declaration.valueStart + at, declaration.valueStart + at + 1, `${failed}: ${syntax.message}`);
20671
+ continue;
20672
+ }
20673
+ const literal = staticLiteral(expr);
20674
+ if (!literal) continue;
20675
+ if ("shape" in literal) declaration.schema = shapeSchema(literal.shape);
20676
+ else if ("throws" in literal) error("unsupported-value", declaration.valueStart, valueEnd, `${failed}: ${literal.throws}`);
20677
+ else error("unsupported-value", declaration.valueStart, valueEnd, `Unsupported type "${literal.unsupported}" for value ${literal.value}. ${UNSUPPORTED_TYPE}`);
20458
20678
  }
20459
20679
  return {
20460
20680
  declarations,
@@ -20631,6 +20851,7 @@ function scanCodeLeniently(code, at, emit, goal) {
20631
20851
  function scanArgs(token, params, at, emit, options) {
20632
20852
  if (!token.rawArgs) return;
20633
20853
  if (params) {
20854
+ if (options.all && !options.storeVarMacros.has(token.name.toLowerCase())) scanVariableParameters(token, params, at, emit);
20634
20855
  const pieces = [...argPieces(token.rawArgs, token.argsStart, params, token.name, "")];
20635
20856
  if (!pieces.some((piece) => piece.kind === "argument-error")) {
20636
20857
  for (const piece of pieces) {
@@ -20646,11 +20867,41 @@ function scanArgs(token, params, at, emit, options) {
20646
20867
  }
20647
20868
  scanCode(token.rawArgs, (i) => at(token.argsStart + i), emit);
20648
20869
  }
20870
+ /**
20871
+ * Report the variables the `variable` parameters of a macro name
20872
+ * (`{unset $x}`, `{computed $x = …}`), when they are `$` or `%` variables.
20873
+ * Arguments that do not parse hold none.
20874
+ */
20875
+ function scanVariableParameters(token, params, at, emit) {
20876
+ const spans = /* @__PURE__ */ new Map();
20877
+ try {
20878
+ parseMacroArgs(token.rawArgs, params, spans);
20879
+ } catch (err) {
20880
+ if (err instanceof MacroArgumentError) return;
20881
+ throw err;
20882
+ }
20883
+ for (const param of params) {
20884
+ const span = spans.get(param);
20885
+ if (param.type !== "variable" || !span) continue;
20886
+ const ref = referenceAt(token.rawArgs.slice(span[0], span[1]), 0, (i) => at(token.argsStart + span[0] + i));
20887
+ if (ref) emit(ref);
20888
+ }
20889
+ }
20890
+ /** Report the references in the selectors of a token, which are interpolated. */
20891
+ function scanSelectors(content, token, at, emit, options) {
20892
+ if (!("selectorsStart" in token) || token.selectorsStart === void 0 || token.selectorsEnd === void 0) return;
20893
+ const from = token.selectorsStart;
20894
+ scanInterpolations(content.slice(from, token.selectorsEnd), (i) => at(from + i), emit, {
20895
+ ...options,
20896
+ storeVarMacros: NO_STORE_VAR_MACROS
20897
+ });
20898
+ }
20649
20899
  /** Report the `$var` references in the tokens of `content`. */
20650
20900
  function collectTokenRefs(content, tokens, at, emit, options) {
20651
20901
  const { storeVarMacros, parametersOf } = options;
20652
20902
  for (let t = 0; t < tokens.length; t++) {
20653
20903
  const token = tokens[t];
20904
+ if (options.all && token.type !== "macro" && token.type !== "html" && token.type !== "text") scanSelectors(content, token, at, emit, options);
20654
20905
  if (token.type === "variable") {
20655
20906
  if ((token.scope === "variable" || token.scope === "transient") && token.name) {
20656
20907
  const [name, ...path] = token.name.split(".");
@@ -20674,13 +20925,7 @@ function collectTokenRefs(content, tokens, at, emit, options) {
20674
20925
  }
20675
20926
  else if (token.type === "macro" && !token.isClose) {
20676
20927
  scanArgs(token, parametersOf(token.name), at, emit, options);
20677
- if (token.selectorsStart !== void 0 && token.selectorsEnd !== void 0) {
20678
- const from = token.selectorsStart;
20679
- scanInterpolations(content.slice(from, token.selectorsEnd), (i) => at(from + i), emit, {
20680
- ...options,
20681
- storeVarMacros: NO_STORE_VAR_MACROS
20682
- });
20683
- }
20928
+ scanSelectors(content, token, at, emit, options);
20684
20929
  if (storeVarMacros.has(token.name.toLowerCase())) {
20685
20930
  const lead = token.rawArgs.length - token.rawArgs.trimStart().length;
20686
20931
  const first = token.rawArgs.trim().split(/\s+/)[0] ?? "";
@@ -20808,7 +21053,7 @@ function renderSpecialPassage(passage) {
20808
21053
  return null;
20809
21054
  }
20810
21055
  }
20811
- var CODE_PASSAGES = new Set([
21056
+ var CODE_PASSAGES = /* @__PURE__ */ new Set([
20812
21057
  "PassageReady",
20813
21058
  "PassageHeader",
20814
21059
  "PassageFooter",
@@ -20885,7 +21130,7 @@ function Passage({ passage, dataTransition, navigationId }) {
20885
21130
  }
20886
21131
  //#endregion
20887
21132
  //#region src/transition.ts
20888
- var TRANSITION_TYPES = new Set([
21133
+ var TRANSITION_TYPES = /* @__PURE__ */ new Set([
20889
21134
  "none",
20890
21135
  "fade",
20891
21136
  "fade-through",
@@ -21107,19 +21352,21 @@ defineMacro({
21107
21352
  setDisplayedPassage(currentPassage);
21108
21353
  }, incomingDelay);
21109
21354
  const cleanupDelay = incomingDelay + config.duration;
21110
- timeoutsRef.current = [t1, setTimeout(() => {
21355
+ const t2 = setTimeout(() => {
21111
21356
  cleanupSnapshots(containerEl);
21112
21357
  if (scrollAfterCleanup.current) scrollToPassageStart(containerEl);
21113
21358
  scrollAfterCleanup.current = false;
21114
- }, cleanupDelay)];
21359
+ }, cleanupDelay);
21360
+ timeoutsRef.current = [t1, t2];
21115
21361
  return;
21116
21362
  }
21117
21363
  containerEl.classList.add("passage-container--crossfading");
21118
21364
  containerEl.appendChild(snapshot);
21119
21365
  setDisplayedPassage(currentPassage);
21120
- timeoutsRef.current = [setTimeout(() => {
21366
+ const t1 = setTimeout(() => {
21121
21367
  cleanupSnapshots(containerEl);
21122
- }, config.duration)];
21368
+ }, config.duration);
21369
+ timeoutsRef.current = [t1];
21123
21370
  }, [navigationId]);
21124
21371
  const shownId = displayedPassage && !renderDeferred ? displayed.id : null;
21125
21372
  const lastShownId = useRef(shownId);
@@ -21557,18 +21804,19 @@ function loopArgs(rawArgs, args) {
21557
21804
  };
21558
21805
  }
21559
21806
  function ForIteration({ parentValues, itemVar, itemValue, indexVar, indexValue, children }) {
21807
+ const ownKeys = useMemo(() => ({
21808
+ [itemVar]: itemValue,
21809
+ ...indexVar ? { [indexVar]: indexValue } : void 0
21810
+ }), [
21811
+ itemVar,
21812
+ itemValue,
21813
+ indexVar,
21814
+ indexValue
21815
+ ]);
21560
21816
  return /* @__PURE__ */ jsx(LocalsScope, {
21561
21817
  body: children,
21562
21818
  parentValues,
21563
- ownKeys: useMemo(() => ({
21564
- [itemVar]: itemValue,
21565
- ...indexVar ? { [indexVar]: indexValue } : void 0
21566
- }), [
21567
- itemVar,
21568
- itemValue,
21569
- indexVar,
21570
- indexValue
21571
- ])
21819
+ ownKeys
21572
21820
  });
21573
21821
  }
21574
21822
  defineMacro({
@@ -22094,7 +22342,10 @@ defineMacro({
22094
22342
  const visibleCharsRef = useRef(0);
22095
22343
  visibleCharsRef.current = visibleChars;
22096
22344
  useEffect(() => {
22097
- if (containerRef.current) setMeasured((containerRef.current.textContent || "").length);
22345
+ if (containerRef.current) {
22346
+ const text = containerRef.current.textContent || "";
22347
+ setMeasured(text.length);
22348
+ }
22098
22349
  });
22099
22350
  useEffect(() => {
22100
22351
  if (totalChars === 0) return;
@@ -22403,8 +22654,8 @@ function SaveManagerContent() {
22403
22654
  }
22404
22655
  }, [renamingId]);
22405
22656
  const mounted = useRef(true);
22406
- const statusTimer = useRef();
22407
- const closeTimer = useRef();
22657
+ const statusTimer = useRef(void 0);
22658
+ const closeTimer = useRef(void 0);
22408
22659
  const showStatus = (text, type = "success") => {
22409
22660
  if (!mounted.current) return;
22410
22661
  clearTimeout(statusTimer.current);