@rohal12/spindle 0.64.24 → 0.64.26

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.
@@ -81,12 +81,23 @@ var NOT_TEXT = /* @__PURE__ */ new Set([
81
81
  "template",
82
82
  "noscript"
83
83
  ]);
84
+ var SVG_NOT_TEXT = /* @__PURE__ */ new Set([
85
+ "title",
86
+ "desc",
87
+ "metadata",
88
+ "defs",
89
+ "symbol",
90
+ "clippath",
91
+ "mask",
92
+ "pattern",
93
+ "marker"
94
+ ]);
84
95
  /**
85
96
  * Whether the element hides its whole subtree, including stylesheet rules.
86
97
  * This needs computed styles but no layout, so it also works headlessly.
87
98
  */
88
99
  function isHidden(el) {
89
- return el.hasAttribute("hidden") || el.getAttribute("aria-hidden") === "true" || /(^|;)\s*display\s*:\s*none\b/i.test(el.getAttribute("style") ?? "") || el.ownerDocument.defaultView?.getComputedStyle(el).display === "none" || NOT_TEXT.has(el.localName.toLowerCase()) || el.parentElement?.tagName === "DETAILS" && !el.parentElement.hasAttribute("open") && el !== Array.from(el.parentElement.children).find((c) => c.tagName === "SUMMARY");
100
+ return el.hasAttribute("hidden") || el.getAttribute("aria-hidden") === "true" || /(^|;)\s*display\s*:\s*none\b/i.test(el.getAttribute("style") ?? "") || el.ownerDocument.defaultView?.getComputedStyle(el).display === "none" || NOT_TEXT.has(el.localName.toLowerCase()) || el.namespaceURI === "http://www.w3.org/2000/svg" && SVG_NOT_TEXT.has(el.localName.toLowerCase()) || el.parentElement?.tagName === "DETAILS" && !el.parentElement.hasAttribute("open") && el !== Array.from(el.parentElement.children).find((c) => c.tagName === "SUMMARY");
90
101
  }
91
102
  /**
92
103
  * Whether `el` is in a closed `<details>`, other than in the summary that
@@ -9537,6 +9548,14 @@ function actionAttributes(action, control) {
9537
9548
  ref: action.ref
9538
9549
  };
9539
9550
  }
9551
+ /** Render a native macro button with its registered action and label. */
9552
+ function renderActionButton(action, control, onClick, label) {
9553
+ return h("button", {
9554
+ type: "button",
9555
+ ...actionAttributes(action, control),
9556
+ onClick
9557
+ }, label);
9558
+ }
9540
9559
  /**
9541
9560
  * While true, controls rendered underneath do not register actions or reserve
9542
9561
  * IDs. Used for display-only content mounted off-screen, so it never shows up
@@ -9953,9 +9972,9 @@ function peg$parse(input, options) {
9953
9972
  const peg$c7 = "[";
9954
9973
  const peg$c8 = "[[";
9955
9974
  const peg$c9 = "]]";
9956
- const peg$c10 = " ";
9975
+ const peg$c10 = "/";
9957
9976
  const peg$c11 = "}";
9958
- const peg$c12 = "/";
9977
+ const peg$c12 = " ";
9959
9978
  const peg$c13 = "@";
9960
9979
  const peg$c14 = ":";
9961
9980
  const peg$c15 = "</";
@@ -9991,38 +10010,38 @@ function peg$parse(input, options) {
9991
10010
  const peg$e11 = peg$literalExpectation("[", false);
9992
10011
  const peg$e12 = peg$literalExpectation("[[", false);
9993
10012
  const peg$e13 = peg$literalExpectation("]]", false);
9994
- const peg$e14 = peg$literalExpectation(" ", false);
9995
- const peg$e15 = peg$classExpectation([".", "#"], false, false, false);
9996
- const peg$e16 = peg$classExpectation([
10013
+ const peg$e14 = peg$literalExpectation("/", false);
10014
+ const peg$e15 = peg$classExpectation([
10015
+ "$",
10016
+ "_",
10017
+ "@",
10018
+ "%",
10019
+ "(",
10020
+ "!"
10021
+ ], false, false, false);
10022
+ const peg$e16 = peg$literalExpectation("}", false);
10023
+ const peg$e17 = peg$literalExpectation(" ", false);
10024
+ const peg$e18 = peg$classExpectation([".", "#"], false, false, false);
10025
+ const peg$e19 = peg$classExpectation([
9997
10026
  ["a", "z"],
9998
10027
  ["A", "Z"],
9999
10028
  ["0", "9"],
10000
10029
  "_",
10001
10030
  "-"
10002
10031
  ], false, false, false);
10003
- const peg$e17 = peg$classExpectation([
10032
+ const peg$e20 = peg$classExpectation([
10004
10033
  "$",
10005
10034
  "_",
10006
10035
  "@",
10007
10036
  "%"
10008
10037
  ], false, false, false);
10009
- const peg$e18 = peg$classExpectation([
10038
+ const peg$e21 = peg$classExpectation([
10010
10039
  ["a", "z"],
10011
10040
  ["A", "Z"],
10012
10041
  ["0", "9"],
10013
10042
  "_",
10014
10043
  "."
10015
10044
  ], false, false, false);
10016
- const peg$e19 = peg$literalExpectation("}", false);
10017
- const peg$e20 = peg$classExpectation([
10018
- "$",
10019
- "_",
10020
- "@",
10021
- "%",
10022
- "(",
10023
- "!"
10024
- ], false, false, false);
10025
- const peg$e21 = peg$literalExpectation("/", false);
10026
10045
  const peg$e22 = peg$classExpectation([["a", "z"], ["A", "Z"]], false, false, false);
10027
10046
  const peg$e23 = peg$classExpectation([
10028
10047
  " ",
@@ -10296,7 +10315,7 @@ function peg$parse(input, options) {
10296
10315
  return !textMode;
10297
10316
  }
10298
10317
  function peg$f34(ss, s, at, inner) {
10299
- const link = lexeme("link", location(), parseLink(inner, at, (separator) => linkSeparatorIndex(inner, at, separator)));
10318
+ const link = lexeme("link", location(), parseLink(inner.value, at, (separator) => linkSeparatorIndex(inner.value, at, separator, inner.spans)));
10300
10319
  link.selectorSpan = selectorSpan(s, ss, at);
10301
10320
  return withSelectors(link, s);
10302
10321
  }
@@ -10306,22 +10325,56 @@ function peg$parse(input, options) {
10306
10325
  function peg$f36() {
10307
10326
  fail("Unclosed link: [[ without ]]", location(), "unclosed-link");
10308
10327
  }
10309
- function peg$f37(parts) {
10328
+ function peg$f37(start) {
10329
+ const close = input.indexOf("]]", start);
10330
+ const nested = input.indexOf("[[", start);
10331
+ linkTextEnd = Math.min(close < 0 ? input.length : close, nested < 0 ? input.length : nested);
10332
+ return true;
10333
+ }
10334
+ function peg$f38(start, part) {
10335
+ return typeof part === "string" ? null : part;
10336
+ }
10337
+ function peg$f39(start, parts, end) {
10338
+ return {
10339
+ value: input.slice(start, end),
10340
+ spans: parts.filter(Boolean)
10341
+ };
10342
+ }
10343
+ function peg$f40(start, end) {
10344
+ return {
10345
+ start,
10346
+ end
10347
+ };
10348
+ }
10349
+ function peg$f41(start, codeStart, nameEnd) {
10350
+ const close = hooks.closeBrace(input, nameEnd, codeStart);
10351
+ return close >= 0 && close < linkTextEnd && skipTo(close);
10352
+ }
10353
+ function peg$f42(start, codeStart, nameEnd) {
10354
+ return skipEnd - offset();
10355
+ }
10356
+ function peg$f43(start, codeStart, nameEnd, end) {
10357
+ return {
10358
+ start,
10359
+ end
10360
+ };
10361
+ }
10362
+ function peg$f44(parts) {
10310
10363
  return selectorsOf(parts);
10311
10364
  }
10312
- function peg$f38() {
10365
+ function peg$f45() {
10313
10366
  return NO_SELECTORS;
10314
10367
  }
10315
- function peg$f39(s, end) {
10368
+ function peg$f46(s, end) {
10316
10369
  return {
10317
10370
  ...s,
10318
10371
  end
10319
10372
  };
10320
10373
  }
10321
- function peg$f40(prefix, name) {
10374
+ function peg$f47(prefix, name) {
10322
10375
  return [prefix, name];
10323
10376
  }
10324
- function peg$f41(ss, s, sigil, nameStart, name) {
10377
+ function peg$f48(ss, s, sigil, nameStart, name) {
10325
10378
  const variable = lexeme("variable", location(), {
10326
10379
  name,
10327
10380
  nameStart,
@@ -10331,7 +10384,7 @@ function peg$parse(input, options) {
10331
10384
  variable.selectorSpan = selectorSpan(s, ss, nameStart - 1);
10332
10385
  return withSelectors(variable, s);
10333
10386
  }
10334
- function peg$f42(ss, s, after, expression) {
10387
+ function peg$f49(ss, s, after, expression) {
10335
10388
  const node = lexeme("expression", location(), {
10336
10389
  expression,
10337
10390
  expressionStart: after,
@@ -10340,33 +10393,33 @@ function peg$parse(input, options) {
10340
10393
  node.selectorSpan = selectorSpan(s, ss, after);
10341
10394
  return withSelectors(node, s);
10342
10395
  }
10343
- function peg$f43() {
10396
+ function peg$f50() {
10344
10397
  fail("Unclosed {" + input.substr(location().end.offset, 1) + "…: no } ends it", location(), "unclosed-expression");
10345
10398
  }
10346
- function peg$f44(start) {
10399
+ function peg$f51(start) {
10347
10400
  const end = hooks.closeBrace(input, start, start);
10348
10401
  return skipTo(end < 0 && completionMode ? input.length : end);
10349
10402
  }
10350
- function peg$f45(start) {
10403
+ function peg$f52(start) {
10351
10404
  return skipEnd - offset();
10352
10405
  }
10353
- function peg$f46(start, code) {
10406
+ function peg$f53(start, code) {
10354
10407
  return code;
10355
10408
  }
10356
- function peg$f47() {
10409
+ function peg$f54() {
10357
10410
  return completionMode;
10358
10411
  }
10359
- function peg$f48(ss, s, start, close, name, nameEnd) {
10412
+ function peg$f55(ss, s, start, close, name, nameEnd) {
10360
10413
  const end = hooks.closeBrace(input, nameEnd, start);
10361
10414
  return skipTo(end < 0 && completionMode ? input.length : end);
10362
10415
  }
10363
- function peg$f49(ss, s, start, close, name, nameEnd) {
10416
+ function peg$f56(ss, s, start, close, name, nameEnd) {
10364
10417
  return skipEnd - offset();
10365
10418
  }
10366
- function peg$f50(ss, s, start, close, name, nameEnd, args) {
10419
+ function peg$f57(ss, s, start, close, name, nameEnd, args) {
10367
10420
  return args;
10368
10421
  }
10369
- function peg$f51(ss, s, start, close, name, nameEnd, tail) {
10422
+ function peg$f58(ss, s, start, close, name, nameEnd, tail) {
10370
10423
  const loc = location();
10371
10424
  const lower = name.toLowerCase();
10372
10425
  const tag = lexeme("macro", loc, {
@@ -10392,19 +10445,19 @@ function peg$parse(input, options) {
10392
10445
  }
10393
10446
  return tag;
10394
10447
  }
10395
- function peg$f52(s) {
10448
+ function peg$f59(s) {
10396
10449
  fail("A closing tag starts with a letter after {/", location(), "invalid-closer");
10397
10450
  }
10398
- function peg$f53(value) {
10451
+ function peg$f60(value) {
10399
10452
  return EMAIL_AUTOLINK.test(value);
10400
10453
  }
10401
- function peg$f54(value) {
10454
+ function peg$f61(value) {
10402
10455
  return lexeme("text", location(), { value });
10403
10456
  }
10404
- function peg$f55(value) {
10457
+ function peg$f62(value) {
10405
10458
  return lexeme("text", location(), { value });
10406
10459
  }
10407
- function peg$f56(tagStart, tag, list, slash) {
10460
+ function peg$f63(tagStart, tag, list, slash) {
10408
10461
  const lower = tag.toLowerCase();
10409
10462
  return lexeme("html", location(), {
10410
10463
  tag,
@@ -10417,7 +10470,7 @@ function peg$parse(input, options) {
10417
10470
  isSelfClose: !!slash || VOID_TAGS.has(lower)
10418
10471
  });
10419
10472
  }
10420
- function peg$f57(tag, bad) {
10473
+ function peg$f64(tag, bad) {
10421
10474
  const c = input.charAt(bad);
10422
10475
  if (!c) fail("Unclosed tag <" + tag + ": no > ends it (write &lt; for a < that starts no tag)", location(), "unclosed-tag");
10423
10476
  const at = {
@@ -10435,7 +10488,7 @@ function peg$parse(input, options) {
10435
10488
  };
10436
10489
  fail("Unexpected " + JSON.stringify(c) + " in the tag <" + tag + ">: expected an attribute, or > to end the tag", at, "unexpected-character");
10437
10490
  }
10438
- function peg$f58(tagStart, tag) {
10491
+ function peg$f65(tagStart, tag) {
10439
10492
  return lexeme("html", location(), {
10440
10493
  tag,
10441
10494
  lower: tag.toLowerCase(),
@@ -10447,14 +10500,14 @@ function peg$parse(input, options) {
10447
10500
  isSelfClose: false
10448
10501
  });
10449
10502
  }
10450
- function peg$f59(nameStart, name) {
10503
+ function peg$f66(nameStart, name) {
10451
10504
  attrCode = hooks.isCodeAttribute(name);
10452
10505
  return true;
10453
10506
  }
10454
- function peg$f60(nameStart, name, v) {
10507
+ function peg$f67(nameStart, name, v) {
10455
10508
  return v;
10456
10509
  }
10457
- function peg$f61(nameStart, name, value) {
10510
+ function peg$f68(nameStart, name, value) {
10458
10511
  const attribute = {
10459
10512
  name,
10460
10513
  value: value ? value.value : "",
@@ -10468,7 +10521,7 @@ function peg$parse(input, options) {
10468
10521
  }
10469
10522
  return attribute;
10470
10523
  }
10471
- function peg$f62(start, value, end) {
10524
+ function peg$f69(start, value, end) {
10472
10525
  return {
10473
10526
  value,
10474
10527
  start,
@@ -10476,7 +10529,7 @@ function peg$parse(input, options) {
10476
10529
  quote: "\""
10477
10530
  };
10478
10531
  }
10479
- function peg$f63(start, value, end) {
10532
+ function peg$f70(start, value, end) {
10480
10533
  return {
10481
10534
  value,
10482
10535
  start,
@@ -10484,36 +10537,36 @@ function peg$parse(input, options) {
10484
10537
  quote: "'"
10485
10538
  };
10486
10539
  }
10487
- function peg$f64(q) {
10540
+ function peg$f71(q) {
10488
10541
  fail("Unclosed attribute value: the " + q + " here has no closing " + q, location(), "unclosed-attribute");
10489
10542
  }
10490
- function peg$f65(start, value, end) {
10543
+ function peg$f72(start, value, end) {
10491
10544
  return {
10492
10545
  value,
10493
10546
  start,
10494
10547
  end
10495
10548
  };
10496
10549
  }
10497
- function peg$f66() {
10550
+ function peg$f73() {
10498
10551
  return !attrCode;
10499
10552
  }
10500
- function peg$f67(bs) {
10553
+ function peg$f74(bs) {
10501
10554
  return bs.length % 2 === 1;
10502
10555
  }
10503
- function peg$f68() {
10556
+ function peg$f75() {
10504
10557
  return !attrCode;
10505
10558
  }
10506
- function peg$f69(start, nameEnd) {
10559
+ function peg$f76(start, nameEnd) {
10507
10560
  const end = hooks.closeBrace(input, nameEnd, start);
10508
10561
  return skipTo(end < 0 && completionMode ? input.length : end);
10509
10562
  }
10510
- function peg$f70(start, nameEnd) {
10563
+ function peg$f77(start, nameEnd) {
10511
10564
  return skipEnd - offset();
10512
10565
  }
10513
- function peg$f71() {
10566
+ function peg$f78() {
10514
10567
  return !attrCode;
10515
10568
  }
10516
- function peg$f72() {
10569
+ function peg$f79() {
10517
10570
  return attrCode;
10518
10571
  }
10519
10572
  let peg$currPos = options.peg$currPos | 0;
@@ -11284,20 +11337,23 @@ function peg$parse(input, options) {
11284
11337
  s4 = peg$parseSelectors();
11285
11338
  if (s4 !== peg$FAILED) {
11286
11339
  s5 = peg$parseHere();
11287
- s6 = peg$currPos;
11288
- s7 = peg$parseLinkText();
11289
- s6 = input.substring(s6, peg$currPos);
11290
- if (input.substr(peg$currPos, 2) === peg$c9) {
11291
- s7 = peg$c9;
11292
- peg$currPos += 2;
11293
- } else {
11294
- s7 = peg$FAILED;
11295
- if (peg$silentFails === 0) peg$fail(peg$e13);
11296
- }
11297
- if (s7 === peg$FAILED) s7 = peg$parseOpenEnd();
11298
- if (s7 !== peg$FAILED) {
11299
- peg$savedPos = s0;
11300
- s0 = peg$f34(s3, s4, s5, s6);
11340
+ s6 = peg$parseLinkText();
11341
+ if (s6 !== peg$FAILED) {
11342
+ if (input.substr(peg$currPos, 2) === peg$c9) {
11343
+ s7 = peg$c9;
11344
+ peg$currPos += 2;
11345
+ } else {
11346
+ s7 = peg$FAILED;
11347
+ if (peg$silentFails === 0) peg$fail(peg$e13);
11348
+ }
11349
+ if (s7 === peg$FAILED) s7 = peg$parseOpenEnd();
11350
+ if (s7 !== peg$FAILED) {
11351
+ peg$savedPos = s0;
11352
+ s0 = peg$f34(s3, s4, s5, s6);
11353
+ } else {
11354
+ peg$currPos = s0;
11355
+ s0 = peg$FAILED;
11356
+ }
11301
11357
  } else {
11302
11358
  peg$currPos = s0;
11303
11359
  s0 = peg$FAILED;
@@ -11343,55 +11399,224 @@ function peg$parse(input, options) {
11343
11399
  return s0;
11344
11400
  }
11345
11401
  function peg$parseLinkText() {
11346
- let s0, s1, s2, s3;
11347
- s0 = [];
11348
- for (;;) {
11349
- s1 = peg$currPos;
11350
- s2 = peg$currPos;
11351
- peg$silentFails++;
11352
- if (input.substr(peg$currPos, 2) === peg$c9) {
11353
- s3 = peg$c9;
11354
- peg$currPos += 2;
11355
- } else {
11356
- s3 = peg$FAILED;
11357
- if (peg$silentFails === 0) peg$fail(peg$e13);
11358
- }
11359
- if (s3 === peg$FAILED) {
11360
- if (input.substr(peg$currPos, 2) === peg$c8) {
11361
- s3 = peg$c8;
11402
+ let s0, s1, s2, s3, s4, s5, s6;
11403
+ s0 = peg$currPos;
11404
+ s1 = peg$parseHere();
11405
+ peg$savedPos = peg$currPos;
11406
+ s2 = peg$f37(s1);
11407
+ if (s2) s2 = void 0;
11408
+ else s2 = peg$FAILED;
11409
+ if (s2 !== peg$FAILED) {
11410
+ s3 = [];
11411
+ for (;;) {
11412
+ s4 = peg$currPos;
11413
+ s5 = peg$currPos;
11414
+ peg$silentFails++;
11415
+ if (input.substr(peg$currPos, 2) === peg$c9) {
11416
+ s6 = peg$c9;
11362
11417
  peg$currPos += 2;
11363
11418
  } else {
11364
- s3 = peg$FAILED;
11365
- if (peg$silentFails === 0) peg$fail(peg$e12);
11419
+ s6 = peg$FAILED;
11420
+ if (peg$silentFails === 0) peg$fail(peg$e13);
11421
+ }
11422
+ if (s6 === peg$FAILED) {
11423
+ if (input.substr(peg$currPos, 2) === peg$c8) {
11424
+ s6 = peg$c8;
11425
+ peg$currPos += 2;
11426
+ } else {
11427
+ s6 = peg$FAILED;
11428
+ if (peg$silentFails === 0) peg$fail(peg$e12);
11429
+ }
11366
11430
  }
11431
+ peg$silentFails--;
11432
+ if (s6 === peg$FAILED) s5 = void 0;
11433
+ else {
11434
+ peg$currPos = s5;
11435
+ s5 = peg$FAILED;
11436
+ }
11437
+ if (s5 !== peg$FAILED) {
11438
+ s6 = peg$parseLinkLabelCode();
11439
+ if (s6 === peg$FAILED) {
11440
+ if (input.length > peg$currPos) {
11441
+ s6 = input.charAt(peg$currPos);
11442
+ peg$currPos++;
11443
+ } else {
11444
+ s6 = peg$FAILED;
11445
+ if (peg$silentFails === 0) peg$fail(peg$e0);
11446
+ }
11447
+ }
11448
+ if (s6 !== peg$FAILED) {
11449
+ peg$savedPos = s4;
11450
+ s4 = peg$f38(s1, s6);
11451
+ } else {
11452
+ peg$currPos = s4;
11453
+ s4 = peg$FAILED;
11454
+ }
11455
+ } else {
11456
+ peg$currPos = s4;
11457
+ s4 = peg$FAILED;
11458
+ }
11459
+ if (s4 === peg$FAILED) break;
11460
+ s3.push(s4);
11367
11461
  }
11368
- peg$silentFails--;
11369
- if (s3 === peg$FAILED) s2 = void 0;
11462
+ s4 = peg$parseHere();
11463
+ peg$savedPos = s0;
11464
+ s0 = peg$f39(s1, s3, s4);
11465
+ } else {
11466
+ peg$currPos = s0;
11467
+ s0 = peg$FAILED;
11468
+ }
11469
+ return s0;
11470
+ }
11471
+ function peg$parseLinkLabelCode() {
11472
+ let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12;
11473
+ s0 = peg$currPos;
11474
+ s1 = peg$parseHere();
11475
+ if (input.charCodeAt(peg$currPos) === 92) {
11476
+ s2 = peg$c4;
11477
+ peg$currPos++;
11478
+ } else {
11479
+ s2 = peg$FAILED;
11480
+ if (peg$silentFails === 0) peg$fail(peg$e6);
11481
+ }
11482
+ if (s2 !== peg$FAILED) {
11483
+ s3 = input.charAt(peg$currPos);
11484
+ if (peg$charCode = s3.charCodeAt(0), peg$charCode === 123 || peg$charCode === 125) peg$currPos++;
11370
11485
  else {
11371
- peg$currPos = s2;
11486
+ s3 = peg$FAILED;
11487
+ if (peg$silentFails === 0) peg$fail(peg$e7);
11488
+ }
11489
+ if (s3 !== peg$FAILED) {
11490
+ s4 = peg$parseHere();
11491
+ peg$savedPos = s0;
11492
+ s0 = peg$f40(s1, s4);
11493
+ } else {
11494
+ peg$currPos = s0;
11495
+ s0 = peg$FAILED;
11496
+ }
11497
+ } else {
11498
+ peg$currPos = s0;
11499
+ s0 = peg$FAILED;
11500
+ }
11501
+ if (s0 === peg$FAILED) {
11502
+ s0 = peg$currPos;
11503
+ s1 = peg$parseHere();
11504
+ if (input.charCodeAt(peg$currPos) === 123) {
11505
+ s2 = peg$c5;
11506
+ peg$currPos++;
11507
+ } else {
11372
11508
  s2 = peg$FAILED;
11509
+ if (peg$silentFails === 0) peg$fail(peg$e8);
11373
11510
  }
11374
11511
  if (s2 !== peg$FAILED) {
11375
- if (input.length > peg$currPos) {
11376
- s3 = input.charAt(peg$currPos);
11377
- peg$currPos++;
11378
- } else {
11379
- s3 = peg$FAILED;
11380
- if (peg$silentFails === 0) peg$fail(peg$e0);
11381
- }
11512
+ s3 = peg$parseSelectors();
11382
11513
  if (s3 !== peg$FAILED) {
11383
- s2 = [s2, s3];
11384
- s1 = s2;
11514
+ s4 = peg$parseHere();
11515
+ s5 = peg$currPos;
11516
+ if (input.charCodeAt(peg$currPos) === 47) {
11517
+ s6 = peg$c10;
11518
+ peg$currPos++;
11519
+ } else {
11520
+ s6 = peg$FAILED;
11521
+ if (peg$silentFails === 0) peg$fail(peg$e14);
11522
+ }
11523
+ if (s6 === peg$FAILED) s6 = null;
11524
+ s7 = peg$parseMacroName();
11525
+ if (s7 !== peg$FAILED) {
11526
+ s6 = [s6, s7];
11527
+ s5 = s6;
11528
+ } else {
11529
+ peg$currPos = s5;
11530
+ s5 = peg$FAILED;
11531
+ }
11532
+ if (s5 === peg$FAILED) {
11533
+ s5 = peg$currPos;
11534
+ peg$silentFails++;
11535
+ s6 = input.charAt(peg$currPos);
11536
+ if (peg$charCode = s6.charCodeAt(0), peg$charCode === 36 || peg$charCode === 95 || peg$charCode === 64 || peg$charCode === 37 || peg$charCode === 40 || peg$charCode === 33) peg$currPos++;
11537
+ else {
11538
+ s6 = peg$FAILED;
11539
+ if (peg$silentFails === 0) peg$fail(peg$e15);
11540
+ }
11541
+ peg$silentFails--;
11542
+ if (s6 !== peg$FAILED) {
11543
+ peg$currPos = s5;
11544
+ s5 = void 0;
11545
+ } else s5 = peg$FAILED;
11546
+ }
11547
+ if (s5 !== peg$FAILED) {
11548
+ s6 = peg$parseHere();
11549
+ peg$savedPos = peg$currPos;
11550
+ s7 = peg$f41(s1, s4, s6);
11551
+ if (s7) s7 = void 0;
11552
+ else s7 = peg$FAILED;
11553
+ if (s7 !== peg$FAILED) {
11554
+ s8 = peg$currPos;
11555
+ s9 = peg$f42(s1, s4, s6);
11556
+ s10 = peg$currPos;
11557
+ s11 = [];
11558
+ if (s11.length >= (s9 | 0)) s12 = peg$FAILED;
11559
+ else if (input.length > peg$currPos) {
11560
+ s12 = input.charAt(peg$currPos);
11561
+ peg$currPos++;
11562
+ } else {
11563
+ s12 = peg$FAILED;
11564
+ if (peg$silentFails === 0) peg$fail(peg$e0);
11565
+ }
11566
+ while (s12 !== peg$FAILED) {
11567
+ s11.push(s12);
11568
+ if (s11.length >= (s9 | 0)) s12 = peg$FAILED;
11569
+ else if (input.length > peg$currPos) {
11570
+ s12 = input.charAt(peg$currPos);
11571
+ peg$currPos++;
11572
+ } else {
11573
+ s12 = peg$FAILED;
11574
+ if (peg$silentFails === 0) peg$fail(peg$e0);
11575
+ }
11576
+ }
11577
+ if (s11.length < (s9 | 0)) {
11578
+ peg$currPos = s10;
11579
+ s10 = peg$FAILED;
11580
+ } else s10 = s11;
11581
+ s9 = s10;
11582
+ if (s9 !== peg$FAILED) s8 = input.substring(s8, peg$currPos);
11583
+ else s8 = s9;
11584
+ if (s8 !== peg$FAILED) {
11585
+ if (input.charCodeAt(peg$currPos) === 125) {
11586
+ s9 = peg$c11;
11587
+ peg$currPos++;
11588
+ } else {
11589
+ s9 = peg$FAILED;
11590
+ if (peg$silentFails === 0) peg$fail(peg$e16);
11591
+ }
11592
+ if (s9 !== peg$FAILED) {
11593
+ s10 = peg$parseHere();
11594
+ peg$savedPos = s0;
11595
+ s0 = peg$f43(s1, s4, s6, s10);
11596
+ } else {
11597
+ peg$currPos = s0;
11598
+ s0 = peg$FAILED;
11599
+ }
11600
+ } else {
11601
+ peg$currPos = s0;
11602
+ s0 = peg$FAILED;
11603
+ }
11604
+ } else {
11605
+ peg$currPos = s0;
11606
+ s0 = peg$FAILED;
11607
+ }
11608
+ } else {
11609
+ peg$currPos = s0;
11610
+ s0 = peg$FAILED;
11611
+ }
11385
11612
  } else {
11386
- peg$currPos = s1;
11387
- s1 = peg$FAILED;
11613
+ peg$currPos = s0;
11614
+ s0 = peg$FAILED;
11388
11615
  }
11389
11616
  } else {
11390
- peg$currPos = s1;
11391
- s1 = peg$FAILED;
11617
+ peg$currPos = s0;
11618
+ s0 = peg$FAILED;
11392
11619
  }
11393
- if (s1 === peg$FAILED) break;
11394
- s0.push(s1);
11395
11620
  }
11396
11621
  return s0;
11397
11622
  }
@@ -11407,15 +11632,15 @@ function peg$parse(input, options) {
11407
11632
  if (s1.length < 1) s1 = peg$FAILED;
11408
11633
  if (s1 !== peg$FAILED) {
11409
11634
  if (input.charCodeAt(peg$currPos) === 32) {
11410
- s2 = peg$c10;
11635
+ s2 = peg$c12;
11411
11636
  peg$currPos++;
11412
11637
  } else {
11413
11638
  s2 = peg$FAILED;
11414
- if (peg$silentFails === 0) peg$fail(peg$e14);
11639
+ if (peg$silentFails === 0) peg$fail(peg$e17);
11415
11640
  }
11416
11641
  if (s2 === peg$FAILED) s2 = null;
11417
11642
  peg$savedPos = s0;
11418
- s0 = peg$f37(s1);
11643
+ s0 = peg$f44(s1);
11419
11644
  } else {
11420
11645
  peg$currPos = s0;
11421
11646
  s0 = peg$FAILED;
@@ -11424,7 +11649,7 @@ function peg$parse(input, options) {
11424
11649
  s0 = peg$currPos;
11425
11650
  s1 = "";
11426
11651
  peg$savedPos = s0;
11427
- s1 = peg$f38();
11652
+ s1 = peg$f45();
11428
11653
  s0 = s1;
11429
11654
  }
11430
11655
  return s0;
@@ -11448,7 +11673,7 @@ function peg$parse(input, options) {
11448
11673
  s3.push(s4);
11449
11674
  }
11450
11675
  peg$savedPos = s0;
11451
- s0 = peg$f39(s1, s2);
11676
+ s0 = peg$f46(s1, s2);
11452
11677
  } else {
11453
11678
  peg$currPos = s0;
11454
11679
  s0 = peg$FAILED;
@@ -11462,7 +11687,7 @@ function peg$parse(input, options) {
11462
11687
  if (peg$charCode = s1.charCodeAt(0), peg$charCode === 46 || peg$charCode === 35) peg$currPos++;
11463
11688
  else {
11464
11689
  s1 = peg$FAILED;
11465
- if (peg$silentFails === 0) peg$fail(peg$e15);
11690
+ if (peg$silentFails === 0) peg$fail(peg$e18);
11466
11691
  }
11467
11692
  if (s1 !== peg$FAILED) {
11468
11693
  s2 = peg$currPos;
@@ -11474,7 +11699,7 @@ function peg$parse(input, options) {
11474
11699
  }
11475
11700
  s2 = input.substring(s2, peg$currPos);
11476
11701
  peg$savedPos = s0;
11477
- s0 = peg$f40(s1, s2);
11702
+ s0 = peg$f47(s1, s2);
11478
11703
  } else {
11479
11704
  peg$currPos = s0;
11480
11705
  s0 = peg$FAILED;
@@ -11487,7 +11712,7 @@ function peg$parse(input, options) {
11487
11712
  if (peg$charCode = s0.charCodeAt(0), peg$charCode >= 97 && peg$charCode <= 122 || peg$charCode >= 65 && peg$charCode <= 90 || peg$charCode >= 48 && peg$charCode <= 57 || peg$charCode === 95 || peg$charCode === 45) peg$currPos++;
11488
11713
  else {
11489
11714
  s0 = peg$FAILED;
11490
- if (peg$silentFails === 0) peg$fail(peg$e16);
11715
+ if (peg$silentFails === 0) peg$fail(peg$e19);
11491
11716
  }
11492
11717
  if (s0 === peg$FAILED) {
11493
11718
  s0 = peg$currPos;
@@ -11503,7 +11728,7 @@ function peg$parse(input, options) {
11503
11728
  if (peg$charCode = s2.charCodeAt(0), peg$charCode === 36 || peg$charCode === 95 || peg$charCode === 64 || peg$charCode === 37) peg$currPos++;
11504
11729
  else {
11505
11730
  s2 = peg$FAILED;
11506
- if (peg$silentFails === 0) peg$fail(peg$e17);
11731
+ if (peg$silentFails === 0) peg$fail(peg$e20);
11507
11732
  }
11508
11733
  if (s2 !== peg$FAILED) {
11509
11734
  s3 = [];
@@ -11512,7 +11737,7 @@ function peg$parse(input, options) {
11512
11737
  if (peg$charCode = s4.charCodeAt(0), peg$charCode >= 97 && peg$charCode <= 122 || peg$charCode >= 65 && peg$charCode <= 90 || peg$charCode >= 48 && peg$charCode <= 57 || peg$charCode === 95 || peg$charCode === 46) peg$currPos++;
11513
11738
  else {
11514
11739
  s4 = peg$FAILED;
11515
- if (peg$silentFails === 0) peg$fail(peg$e18);
11740
+ if (peg$silentFails === 0) peg$fail(peg$e21);
11516
11741
  }
11517
11742
  if (s4 === peg$FAILED) break;
11518
11743
  s3.push(s4);
@@ -11522,7 +11747,7 @@ function peg$parse(input, options) {
11522
11747
  peg$currPos++;
11523
11748
  } else {
11524
11749
  s4 = peg$FAILED;
11525
- if (peg$silentFails === 0) peg$fail(peg$e19);
11750
+ if (peg$silentFails === 0) peg$fail(peg$e16);
11526
11751
  }
11527
11752
  if (s4 !== peg$FAILED) {
11528
11753
  s1 = [
@@ -11565,7 +11790,7 @@ function peg$parse(input, options) {
11565
11790
  if (peg$charCode = s4.charCodeAt(0), peg$charCode === 36 || peg$charCode === 95 || peg$charCode === 64 || peg$charCode === 37) peg$currPos++;
11566
11791
  else {
11567
11792
  s4 = peg$FAILED;
11568
- if (peg$silentFails === 0) peg$fail(peg$e17);
11793
+ if (peg$silentFails === 0) peg$fail(peg$e20);
11569
11794
  }
11570
11795
  if (s4 !== peg$FAILED) {
11571
11796
  s5 = peg$parseHere();
@@ -11576,7 +11801,7 @@ function peg$parse(input, options) {
11576
11801
  if (peg$charCode = s8.charCodeAt(0), peg$charCode >= 97 && peg$charCode <= 122 || peg$charCode >= 65 && peg$charCode <= 90 || peg$charCode >= 48 && peg$charCode <= 57 || peg$charCode === 95 || peg$charCode === 46) peg$currPos++;
11577
11802
  else {
11578
11803
  s8 = peg$FAILED;
11579
- if (peg$silentFails === 0) peg$fail(peg$e18);
11804
+ if (peg$silentFails === 0) peg$fail(peg$e21);
11580
11805
  }
11581
11806
  if (s8 === peg$FAILED) break;
11582
11807
  s7.push(s8);
@@ -11585,7 +11810,7 @@ function peg$parse(input, options) {
11585
11810
  s7 = peg$parseBraceEnd();
11586
11811
  if (s7 !== peg$FAILED) {
11587
11812
  peg$savedPos = s0;
11588
- s0 = peg$f41(s2, s3, s4, s5, s6);
11813
+ s0 = peg$f48(s2, s3, s4, s5, s6);
11589
11814
  } else {
11590
11815
  peg$currPos = s0;
11591
11816
  s0 = peg$FAILED;
@@ -11622,7 +11847,7 @@ function peg$parse(input, options) {
11622
11847
  if (peg$charCode = s6.charCodeAt(0), peg$charCode === 36 || peg$charCode === 95 || peg$charCode === 64 || peg$charCode === 37 || peg$charCode === 40 || peg$charCode === 33) peg$currPos++;
11623
11848
  else {
11624
11849
  s6 = peg$FAILED;
11625
- if (peg$silentFails === 0) peg$fail(peg$e20);
11850
+ if (peg$silentFails === 0) peg$fail(peg$e15);
11626
11851
  }
11627
11852
  peg$silentFails--;
11628
11853
  if (s6 !== peg$FAILED) {
@@ -11635,7 +11860,7 @@ function peg$parse(input, options) {
11635
11860
  s7 = peg$parseBraceEnd();
11636
11861
  if (s7 !== peg$FAILED) {
11637
11862
  peg$savedPos = s0;
11638
- s0 = peg$f42(s2, s3, s4, s6);
11863
+ s0 = peg$f49(s2, s3, s4, s6);
11639
11864
  } else {
11640
11865
  peg$currPos = s0;
11641
11866
  s0 = peg$FAILED;
@@ -11674,7 +11899,7 @@ function peg$parse(input, options) {
11674
11899
  if (peg$charCode = s4.charCodeAt(0), peg$charCode === 36 || peg$charCode === 95 || peg$charCode === 64 || peg$charCode === 37 || peg$charCode === 40 || peg$charCode === 33) peg$currPos++;
11675
11900
  else {
11676
11901
  s4 = peg$FAILED;
11677
- if (peg$silentFails === 0) peg$fail(peg$e20);
11902
+ if (peg$silentFails === 0) peg$fail(peg$e15);
11678
11903
  }
11679
11904
  peg$silentFails--;
11680
11905
  if (s4 !== peg$FAILED) {
@@ -11683,7 +11908,7 @@ function peg$parse(input, options) {
11683
11908
  } else s3 = peg$FAILED;
11684
11909
  if (s3 !== peg$FAILED) {
11685
11910
  peg$savedPos = s0;
11686
- s0 = peg$f43();
11911
+ s0 = peg$f50();
11687
11912
  } else {
11688
11913
  peg$currPos = s0;
11689
11914
  s0 = peg$FAILED;
@@ -11705,12 +11930,12 @@ function peg$parse(input, options) {
11705
11930
  s0 = peg$currPos;
11706
11931
  s1 = peg$parseHere();
11707
11932
  peg$savedPos = peg$currPos;
11708
- s2 = peg$f44(s1);
11933
+ s2 = peg$f51(s1);
11709
11934
  if (s2) s2 = void 0;
11710
11935
  else s2 = peg$FAILED;
11711
11936
  if (s2 !== peg$FAILED) {
11712
11937
  s3 = peg$currPos;
11713
- s4 = peg$f45(s1);
11938
+ s4 = peg$f52(s1);
11714
11939
  s5 = peg$currPos;
11715
11940
  s6 = [];
11716
11941
  if (s6.length >= (s4 | 0)) s7 = peg$FAILED;
@@ -11741,7 +11966,7 @@ function peg$parse(input, options) {
11741
11966
  else s3 = s4;
11742
11967
  if (s3 !== peg$FAILED) {
11743
11968
  peg$savedPos = s0;
11744
- s0 = peg$f46(s1, s3);
11969
+ s0 = peg$f53(s1, s3);
11745
11970
  } else {
11746
11971
  peg$currPos = s0;
11747
11972
  s0 = peg$FAILED;
@@ -11756,7 +11981,7 @@ function peg$parse(input, options) {
11756
11981
  let s0, s1, s2, s3;
11757
11982
  s0 = peg$currPos;
11758
11983
  peg$savedPos = peg$currPos;
11759
- s1 = peg$f47();
11984
+ s1 = peg$f54();
11760
11985
  if (s1) s1 = void 0;
11761
11986
  else s1 = peg$FAILED;
11762
11987
  if (s1 !== peg$FAILED) {
@@ -11795,7 +12020,7 @@ function peg$parse(input, options) {
11795
12020
  peg$currPos++;
11796
12021
  } else {
11797
12022
  s0 = peg$FAILED;
11798
- if (peg$silentFails === 0) peg$fail(peg$e19);
12023
+ if (peg$silentFails === 0) peg$fail(peg$e16);
11799
12024
  }
11800
12025
  if (s0 === peg$FAILED) s0 = peg$parseOpenEnd();
11801
12026
  return s0;
@@ -11816,11 +12041,11 @@ function peg$parse(input, options) {
11816
12041
  if (s3 !== peg$FAILED) {
11817
12042
  s4 = peg$parseHere();
11818
12043
  if (input.charCodeAt(peg$currPos) === 47) {
11819
- s5 = peg$c12;
12044
+ s5 = peg$c10;
11820
12045
  peg$currPos++;
11821
12046
  } else {
11822
12047
  s5 = peg$FAILED;
11823
- if (peg$silentFails === 0) peg$fail(peg$e21);
12048
+ if (peg$silentFails === 0) peg$fail(peg$e14);
11824
12049
  }
11825
12050
  if (s5 === peg$FAILED) s5 = null;
11826
12051
  s6 = peg$parseMacroName();
@@ -11828,12 +12053,12 @@ function peg$parse(input, options) {
11828
12053
  s7 = peg$parseHere();
11829
12054
  s8 = peg$currPos;
11830
12055
  peg$savedPos = peg$currPos;
11831
- s9 = peg$f48(s2, s3, s4, s5, s6, s7);
12056
+ s9 = peg$f55(s2, s3, s4, s5, s6, s7);
11832
12057
  if (s9) s9 = void 0;
11833
12058
  else s9 = peg$FAILED;
11834
12059
  if (s9 !== peg$FAILED) {
11835
12060
  s10 = peg$currPos;
11836
- s11 = peg$f49(s2, s3, s4, s5, s6, s7);
12061
+ s11 = peg$f56(s2, s3, s4, s5, s6, s7);
11837
12062
  s12 = peg$currPos;
11838
12063
  s13 = [];
11839
12064
  if (s13.length >= (s11 | 0)) s14 = peg$FAILED;
@@ -11866,7 +12091,7 @@ function peg$parse(input, options) {
11866
12091
  s11 = peg$parseBraceEnd();
11867
12092
  if (s11 !== peg$FAILED) {
11868
12093
  peg$savedPos = s8;
11869
- s8 = peg$f50(s2, s3, s4, s5, s6, s7, s10);
12094
+ s8 = peg$f57(s2, s3, s4, s5, s6, s7, s10);
11870
12095
  } else {
11871
12096
  peg$currPos = s8;
11872
12097
  s8 = peg$FAILED;
@@ -11881,7 +12106,7 @@ function peg$parse(input, options) {
11881
12106
  }
11882
12107
  if (s8 === peg$FAILED) s8 = null;
11883
12108
  peg$savedPos = s0;
11884
- s0 = peg$f51(s2, s3, s4, s5, s6, s7, s8);
12109
+ s0 = peg$f58(s2, s3, s4, s5, s6, s7, s8);
11885
12110
  } else {
11886
12111
  peg$currPos = s0;
11887
12112
  s0 = peg$FAILED;
@@ -11907,15 +12132,15 @@ function peg$parse(input, options) {
11907
12132
  s2 = peg$parseSelectors();
11908
12133
  if (s2 !== peg$FAILED) {
11909
12134
  if (input.charCodeAt(peg$currPos) === 47) {
11910
- s3 = peg$c12;
12135
+ s3 = peg$c10;
11911
12136
  peg$currPos++;
11912
12137
  } else {
11913
12138
  s3 = peg$FAILED;
11914
- if (peg$silentFails === 0) peg$fail(peg$e21);
12139
+ if (peg$silentFails === 0) peg$fail(peg$e14);
11915
12140
  }
11916
12141
  if (s3 !== peg$FAILED) {
11917
12142
  peg$savedPos = s0;
11918
- s0 = peg$f52(s2);
12143
+ s0 = peg$f59(s2);
11919
12144
  } else {
11920
12145
  peg$currPos = s0;
11921
12146
  s0 = peg$FAILED;
@@ -12050,12 +12275,12 @@ function peg$parse(input, options) {
12050
12275
  else s1 = s2;
12051
12276
  if (s1 !== peg$FAILED) {
12052
12277
  peg$savedPos = peg$currPos;
12053
- s2 = peg$f53(s1);
12278
+ s2 = peg$f60(s1);
12054
12279
  if (s2) s2 = void 0;
12055
12280
  else s2 = peg$FAILED;
12056
12281
  if (s2 !== peg$FAILED) {
12057
12282
  peg$savedPos = s0;
12058
- s0 = peg$f54(s1);
12283
+ s0 = peg$f61(s1);
12059
12284
  } else {
12060
12285
  peg$currPos = s0;
12061
12286
  s0 = peg$FAILED;
@@ -12199,7 +12424,7 @@ function peg$parse(input, options) {
12199
12424
  else s1 = s2;
12200
12425
  if (s1 !== peg$FAILED) {
12201
12426
  peg$savedPos = s0;
12202
- s1 = peg$f55(s1);
12427
+ s1 = peg$f62(s1);
12203
12428
  }
12204
12429
  s0 = s1;
12205
12430
  return s0;
@@ -12226,11 +12451,11 @@ function peg$parse(input, options) {
12226
12451
  }
12227
12452
  s5 = peg$parse_();
12228
12453
  if (input.charCodeAt(peg$currPos) === 47) {
12229
- s6 = peg$c12;
12454
+ s6 = peg$c10;
12230
12455
  peg$currPos++;
12231
12456
  } else {
12232
12457
  s6 = peg$FAILED;
12233
- if (peg$silentFails === 0) peg$fail(peg$e21);
12458
+ if (peg$silentFails === 0) peg$fail(peg$e14);
12234
12459
  }
12235
12460
  if (s6 === peg$FAILED) s6 = null;
12236
12461
  if (input.charCodeAt(peg$currPos) === 62) {
@@ -12243,7 +12468,7 @@ function peg$parse(input, options) {
12243
12468
  if (s7 === peg$FAILED) s7 = peg$parseOpenEnd();
12244
12469
  if (s7 !== peg$FAILED) {
12245
12470
  peg$savedPos = s0;
12246
- s0 = peg$f56(s2, s3, s4, s6);
12471
+ s0 = peg$f63(s2, s3, s4, s6);
12247
12472
  } else {
12248
12473
  peg$currPos = s0;
12249
12474
  s0 = peg$FAILED;
@@ -12308,7 +12533,7 @@ function peg$parse(input, options) {
12308
12533
  s5 = peg$parse_();
12309
12534
  s6 = peg$parseHere();
12310
12535
  peg$savedPos = s0;
12311
- s0 = peg$f57(s2, s6);
12536
+ s0 = peg$f64(s2, s6);
12312
12537
  } else {
12313
12538
  peg$currPos = s0;
12314
12539
  s0 = peg$FAILED;
@@ -12348,7 +12573,7 @@ function peg$parse(input, options) {
12348
12573
  }
12349
12574
  if (s5 !== peg$FAILED) {
12350
12575
  peg$savedPos = s0;
12351
- s0 = peg$f58(s2, s3);
12576
+ s0 = peg$f65(s2, s3);
12352
12577
  } else {
12353
12578
  peg$currPos = s0;
12354
12579
  s0 = peg$FAILED;
@@ -12445,7 +12670,7 @@ function peg$parse(input, options) {
12445
12670
  else s3 = s4;
12446
12671
  if (s3 !== peg$FAILED) {
12447
12672
  peg$savedPos = peg$currPos;
12448
- s4 = peg$f59(s2, s3);
12673
+ s4 = peg$f66(s2, s3);
12449
12674
  if (s4) s4 = void 0;
12450
12675
  else s4 = peg$FAILED;
12451
12676
  if (s4 !== peg$FAILED) {
@@ -12463,7 +12688,7 @@ function peg$parse(input, options) {
12463
12688
  s9 = peg$parseAttrValue();
12464
12689
  if (s9 !== peg$FAILED) {
12465
12690
  peg$savedPos = s5;
12466
- s5 = peg$f60(s2, s3, s9);
12691
+ s5 = peg$f67(s2, s3, s9);
12467
12692
  } else {
12468
12693
  peg$currPos = s5;
12469
12694
  s5 = peg$FAILED;
@@ -12474,7 +12699,7 @@ function peg$parse(input, options) {
12474
12699
  }
12475
12700
  if (s5 === peg$FAILED) s5 = null;
12476
12701
  peg$savedPos = s0;
12477
- s0 = peg$f61(s2, s3, s5);
12702
+ s0 = peg$f68(s2, s3, s5);
12478
12703
  } else {
12479
12704
  peg$currPos = s0;
12480
12705
  s0 = peg$FAILED;
@@ -12524,7 +12749,7 @@ function peg$parse(input, options) {
12524
12749
  if (s5 === peg$FAILED) s5 = peg$parseOpenEnd();
12525
12750
  if (s5 !== peg$FAILED) {
12526
12751
  peg$savedPos = s0;
12527
- s0 = peg$f62(s2, s3, s4);
12752
+ s0 = peg$f69(s2, s3, s4);
12528
12753
  } else {
12529
12754
  peg$currPos = s0;
12530
12755
  s0 = peg$FAILED;
@@ -12571,7 +12796,7 @@ function peg$parse(input, options) {
12571
12796
  if (s5 === peg$FAILED) s5 = peg$parseOpenEnd();
12572
12797
  if (s5 !== peg$FAILED) {
12573
12798
  peg$savedPos = s0;
12574
- s0 = peg$f63(s2, s3, s4);
12799
+ s0 = peg$f70(s2, s3, s4);
12575
12800
  } else {
12576
12801
  peg$currPos = s0;
12577
12802
  s0 = peg$FAILED;
@@ -12590,7 +12815,7 @@ function peg$parse(input, options) {
12590
12815
  }
12591
12816
  if (s1 !== peg$FAILED) {
12592
12817
  peg$savedPos = s0;
12593
- s1 = peg$f64(s1);
12818
+ s1 = peg$f71(s1);
12594
12819
  }
12595
12820
  s0 = s1;
12596
12821
  if (s0 === peg$FAILED) {
@@ -12611,7 +12836,7 @@ function peg$parse(input, options) {
12611
12836
  s2 = input.substring(s2, peg$currPos);
12612
12837
  s3 = peg$parseHere();
12613
12838
  peg$savedPos = s0;
12614
- s0 = peg$f65(s1, s2, s3);
12839
+ s0 = peg$f72(s1, s2, s3);
12615
12840
  }
12616
12841
  }
12617
12842
  }
@@ -12621,7 +12846,7 @@ function peg$parse(input, options) {
12621
12846
  let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13;
12622
12847
  s0 = peg$currPos;
12623
12848
  peg$savedPos = peg$currPos;
12624
- s1 = peg$f66();
12849
+ s1 = peg$f73();
12625
12850
  if (s1) s1 = void 0;
12626
12851
  else s1 = peg$FAILED;
12627
12852
  if (s1 !== peg$FAILED) {
@@ -12644,7 +12869,7 @@ function peg$parse(input, options) {
12644
12869
  if (s2 !== peg$FAILED) {
12645
12870
  s3 = peg$currPos;
12646
12871
  peg$savedPos = peg$currPos;
12647
- s4 = peg$f67(s2);
12872
+ s4 = peg$f74(s2);
12648
12873
  if (s4) s4 = void 0;
12649
12874
  else s4 = peg$FAILED;
12650
12875
  if (s4 !== peg$FAILED) {
@@ -12683,7 +12908,7 @@ function peg$parse(input, options) {
12683
12908
  if (s0 === peg$FAILED) {
12684
12909
  s0 = peg$currPos;
12685
12910
  peg$savedPos = peg$currPos;
12686
- s1 = peg$f68();
12911
+ s1 = peg$f75();
12687
12912
  if (s1) s1 = void 0;
12688
12913
  else s1 = peg$FAILED;
12689
12914
  if (s1 !== peg$FAILED) {
@@ -12699,23 +12924,23 @@ function peg$parse(input, options) {
12699
12924
  if (s3 !== peg$FAILED) {
12700
12925
  s4 = peg$parseHere();
12701
12926
  if (input.charCodeAt(peg$currPos) === 47) {
12702
- s5 = peg$c12;
12927
+ s5 = peg$c10;
12703
12928
  peg$currPos++;
12704
12929
  } else {
12705
12930
  s5 = peg$FAILED;
12706
- if (peg$silentFails === 0) peg$fail(peg$e21);
12931
+ if (peg$silentFails === 0) peg$fail(peg$e14);
12707
12932
  }
12708
12933
  if (s5 === peg$FAILED) s5 = null;
12709
12934
  s6 = peg$parseMacroName();
12710
12935
  if (s6 !== peg$FAILED) {
12711
12936
  s7 = peg$parseHere();
12712
12937
  peg$savedPos = peg$currPos;
12713
- s8 = peg$f69(s4, s7);
12938
+ s8 = peg$f76(s4, s7);
12714
12939
  if (s8) s8 = void 0;
12715
12940
  else s8 = peg$FAILED;
12716
12941
  if (s8 !== peg$FAILED) {
12717
12942
  s9 = peg$currPos;
12718
- s10 = peg$f70(s4, s7);
12943
+ s10 = peg$f77(s4, s7);
12719
12944
  s11 = peg$currPos;
12720
12945
  s12 = [];
12721
12946
  if (s12.length >= (s10 | 0)) s13 = peg$FAILED;
@@ -12791,7 +13016,7 @@ function peg$parse(input, options) {
12791
13016
  if (s0 === peg$FAILED) {
12792
13017
  s0 = peg$currPos;
12793
13018
  peg$savedPos = peg$currPos;
12794
- s1 = peg$f71();
13019
+ s1 = peg$f78();
12795
13020
  if (s1) s1 = void 0;
12796
13021
  else s1 = peg$FAILED;
12797
13022
  if (s1 !== peg$FAILED) {
@@ -12809,11 +13034,11 @@ function peg$parse(input, options) {
12809
13034
  peg$silentFails++;
12810
13035
  s5 = peg$currPos;
12811
13036
  if (input.charCodeAt(peg$currPos) === 47) {
12812
- s6 = peg$c12;
13037
+ s6 = peg$c10;
12813
13038
  peg$currPos++;
12814
13039
  } else {
12815
13040
  s6 = peg$FAILED;
12816
- if (peg$silentFails === 0) peg$fail(peg$e21);
13041
+ if (peg$silentFails === 0) peg$fail(peg$e14);
12817
13042
  }
12818
13043
  if (s6 === peg$FAILED) s6 = null;
12819
13044
  s7 = input.charAt(peg$currPos);
@@ -12876,7 +13101,7 @@ function peg$parse(input, options) {
12876
13101
  if (s0 === peg$FAILED) {
12877
13102
  s0 = peg$currPos;
12878
13103
  peg$savedPos = peg$currPos;
12879
- s1 = peg$f72();
13104
+ s1 = peg$f79();
12880
13105
  if (s1) s1 = void 0;
12881
13106
  else s1 = peg$FAILED;
12882
13107
  if (s1 !== peg$FAILED) {
@@ -12894,7 +13119,7 @@ function peg$parse(input, options) {
12894
13119
  if (peg$charCode = s4.charCodeAt(0), peg$charCode === 36 || peg$charCode === 95 || peg$charCode === 64 || peg$charCode === 37) peg$currPos++;
12895
13120
  else {
12896
13121
  s4 = peg$FAILED;
12897
- if (peg$silentFails === 0) peg$fail(peg$e17);
13122
+ if (peg$silentFails === 0) peg$fail(peg$e20);
12898
13123
  }
12899
13124
  peg$silentFails--;
12900
13125
  if (s4 !== peg$FAILED) {
@@ -12971,22 +13196,17 @@ function peg$parse(input, options) {
12971
13196
  let rawName = "";
12972
13197
  /** The HTML text-only body being read; its own closer ends this context. */
12973
13198
  let htmlTextTag = "";
13199
+ /** First bracket boundary of the current (non-nesting) link label. */
13200
+ let linkTextEnd = -1;
12974
13201
  /**
12975
13202
  * The index in `inner` (at `at` in the input) of the first `separator` that
12976
13203
  * is not inside a {…} of the label: its code (`{if $a || $b}`, a string with
12977
13204
  * a pipe) belongs to the label, not to the link's syntax.
12978
13205
  */
12979
- function linkSeparatorIndex(inner, at, separator) {
12980
- for (let i = 0; i < inner.length; i++) {
12981
- const c = inner.charAt(i);
12982
- if (c === "\\" && /[{}]/.test(inner.charAt(i + 1))) i++;
12983
- else if (c === LB) {
12984
- const head = /^(?:[.#][\w-]*)* ?(\/?[a-zA-Z][\w-]*|(?=[$_@%(!]))/.exec(inner.slice(i + 1));
12985
- if (!head) continue;
12986
- const close = hooks.closeBrace(input, at + i + 1 + head[0].length, at + i + 1);
12987
- if (close !== -1 && close < at + inner.length) i = close - at;
12988
- } else if (inner.startsWith(separator, i)) return i;
12989
- }
13206
+ function linkSeparatorIndex(inner, at, separator, spans) {
13207
+ let span = 0;
13208
+ for (let i = 0; i < inner.length; i++) if (span < spans.length && i === spans[span].start - at) i = spans[span++].end - at - 1;
13209
+ else if (inner.startsWith(separator, i)) return i;
12990
13210
  return -1;
12991
13211
  }
12992
13212
  /**
@@ -21869,25 +22089,29 @@ function formatValue(value) {
21869
22089
  }
21870
22090
  }
21871
22091
  }
21872
- /** What a control with an action shows: its type, variable and value. */
22092
+ function selectedLabels(el) {
22093
+ const labels = Array.from(el.options).filter((option) => option.selected).map((option) => option.getAttribute("label") || (option.textContent ?? "").trim().replace(/\s+/g, " "));
22094
+ return el.multiple ? labels : labels[0] ?? "";
22095
+ }
22096
+ /** What a control shows: its type, optional action variable and live value. */
21873
22097
  function controlMarker(el) {
21874
22098
  const own = el;
21875
22099
  const action = getAction(el.getAttribute("data-action") ?? "");
21876
- const type = action?.type ?? el.getAttribute("type") ?? el.localName;
22100
+ const type = action?.type ?? el.getAttribute("type")?.toLowerCase() ?? el.localName;
21877
22101
  const isCheckbox = type === "checkbox";
21878
- const value = action?.value !== void 0 ? action.value : isCheckbox ? !!own.checked : own.value ?? "";
22102
+ const value = action?.value !== void 0 ? action.value : isCheckbox ? !!own.checked : el.localName === "select" && !el.hasAttribute("data-action") ? selectedLabels(el) : own.value ?? "";
21879
22103
  const shown = isCheckbox ? value ? "checked" : "unchecked" : formatValue(value);
21880
22104
  const variable = action?.variable;
21881
22105
  const name = variable && !variable.startsWith("$") ? `$${variable}` : variable;
21882
- if (type === "radiobutton" && own.value !== void 0) {
21883
- const state = action?.value === own.value ? "selected" : "unselected";
22106
+ if ((type === "radiobutton" || type === "radio") && own.value !== void 0) {
22107
+ const state = (action?.value !== void 0 ? action.value === own.value : !!own.checked) ? "selected" : "unselected";
21884
22108
  return `[${type}${name ? ` ${name}` : ""} = ${formatValue(own.value)}: ${state}]`;
21885
22109
  }
21886
22110
  return `[${type}${name ? ` ${name}` : ""}: ${shown}]`;
21887
22111
  }
21888
22112
  /**
21889
22113
  * The text a reader sees in the element, as lines: blocks and `<br>` break
21890
- * lines, hidden elements are left out, and a control with a `data-action`
22114
+ * lines, hidden elements are left out, and a native or action-associated control
21891
22115
  * becomes a marker such as `[textbox $name: "Alice"]`. Elements inside `el`
21892
22116
  * that match `skip` are left out with their content. `visibilityRoot` bounds
21893
22117
  * ancestor checks when reading StoryContext inside its hidden host.
@@ -21912,7 +22136,8 @@ function observableText(el, skip, visibilityRoot) {
21912
22136
  if (node.nodeType !== 1) return;
21913
22137
  const child = node;
21914
22138
  if (isHidden(child) || skip && child !== el && child.matches(skip)) return;
21915
- if (child.hasAttribute("data-action") && (child.matches("input, textarea, select") || getAction(child.getAttribute("data-action"))?.type === "cycle")) {
22139
+ if (child.matches("input, textarea, select") || child.hasAttribute("data-action") && getAction(child.getAttribute("data-action"))?.type === "cycle") {
22140
+ if (child.matches("input[type=\"hidden\" i]")) return;
21916
22141
  if (!isRendered(child, visibilityRoot)) return;
21917
22142
  out += controlMarker(child);
21918
22143
  return;
@@ -24015,6 +24240,16 @@ function snapshotUrls(value, ids, base) {
24015
24240
  * definitions would replace that inheritance (and resolve currentColor).
24016
24241
  */
24017
24242
  var snapshotSvgRules = /* @__PURE__ */ new WeakSet();
24243
+ /** Keep only snapshot aliases, retaining their media/layer/nesting context. */
24244
+ function snapshotRuleText(rules) {
24245
+ const text = [];
24246
+ for (const rule of rules) if (snapshotSvgRules.has(rule)) text.push(rule.cssText);
24247
+ else if ("cssRules" in rule && !(rule instanceof CSSKeyframesRule)) {
24248
+ const body = snapshotRuleText(rule.cssRules);
24249
+ if (body) text.push(`${rule.cssText.slice(0, rule.cssText.indexOf("{"))}{${body}}`);
24250
+ }
24251
+ return text.join("\n");
24252
+ }
24018
24253
  /** A detached style element has no sheet yet. Carry its CSSOM, including
24019
24254
  * script-inserted rules and imported styles, into the passive tree.
24020
24255
  */
@@ -24143,11 +24378,15 @@ var snapshotPseudoId = 0;
24143
24378
  * as ordinary native elements, without an `is` option (even if the original
24144
24379
  * has since removed its `is` attribute).
24145
24380
  */
24146
- function cloneSnapshotTree(source, ids, pseudoRules = [], svgMarker = String(++snapshotPseudoId), cleanups = []) {
24381
+ function cloneSnapshotTree(source, ids, pseudoRules = [], svgMarker = String(++snapshotPseudoId), cleanups = [], svgState = {
24382
+ opaqueRoots: /* @__PURE__ */ new Set(),
24383
+ copies: []
24384
+ }) {
24147
24385
  const html = source.namespaceURI === "http://www.w3.org/1999/xhtml";
24148
24386
  const svg = source.namespaceURI === "http://www.w3.org/2000/svg";
24149
24387
  const custom = html && source.localName.includes("-");
24150
- const clone = document.createElementNS(source.namespaceURI, custom ? "span" : source.localName);
24388
+ const linkedSheet = html && source.localName === "link" && source.relList.contains("stylesheet");
24389
+ const clone = document.createElementNS(source.namespaceURI, linkedSheet ? "style" : custom ? "span" : source.localName);
24151
24390
  for (const attr of [...source.attributes]) {
24152
24391
  if (attr.name === "id" || attr.name === "data-action" || attr.name === "is" || attr.name.toLowerCase().startsWith("on")) continue;
24153
24392
  const value = svg && attr.localName === "href" ? snapshotFragment(attr.value, ids) : svg || attr.localName === "style" ? snapshotUrls(attr.value, ids) : attr.value;
@@ -24159,6 +24398,13 @@ function cloneSnapshotTree(source, ids, pseudoRules = [], svgMarker = String(++s
24159
24398
  if (source.id) clone.setAttribute("data-spindle-snapshot-original-id", source.id);
24160
24399
  if (custom) clone.setAttribute("data-spindle-snapshot-tag", source.localName);
24161
24400
  if (svg) clone.setAttribute("data-spindle-snapshot-svg", svgMarker);
24401
+ if (svg) svgState.copies.push({
24402
+ source,
24403
+ clone,
24404
+ ids
24405
+ });
24406
+ if (html && source.matches("button, fieldset, input, object, output, select, textarea")) clone.setAttribute("form", "");
24407
+ if (html && (source.localName === "details" || source.localName === "input" && source.type === "radio")) clone.removeAttribute("name");
24162
24408
  const computed = getComputedStyle(source);
24163
24409
  if (!svg) copyComputedStyle(computed, clone.style, ids);
24164
24410
  let pseudoId;
@@ -24179,21 +24425,21 @@ function cloneSnapshotTree(source, ids, pseudoRules = [], svgMarker = String(++s
24179
24425
  const from = source instanceof HTMLTemplateElement ? source.content : source;
24180
24426
  const to = clone instanceof HTMLTemplateElement ? clone.content : clone;
24181
24427
  const copyChildren = (from, to, rules = pseudoRules, localIds = ids) => {
24182
- for (const node of from.childNodes) to.appendChild(node instanceof Element ? cloneSnapshotTree(node, localIds, rules, svgMarker, cleanups) : node.cloneNode(false));
24428
+ for (const node of from.childNodes) to.appendChild(node instanceof Element ? cloneSnapshotTree(node, localIds, rules, svgMarker, cleanups, svgState) : node.cloneNode(false));
24183
24429
  };
24184
24430
  copyChildren(from, to, pseudoRules, source instanceof HTMLTemplateElement ? snapshotIds(from) : ids);
24185
- if (source instanceof HTMLStyleElement && source.sheet) {
24431
+ if (source.localName === "style" || linkedSheet) {
24432
+ const sourceSheet = source.sheet;
24433
+ clone.textContent = "";
24186
24434
  const root = source.getRootNode();
24187
- if (root.querySelector("svg")) {
24188
- let opaque = false;
24189
- const copy = copySnapshotSheet(source.sheet, ids, () => {
24190
- opaque = true;
24435
+ if (sourceSheet && root.querySelector("svg")) {
24436
+ const copy = copySnapshotSheet(sourceSheet, ids, () => {
24437
+ svgState.opaqueRoots.add(root);
24191
24438
  });
24192
- const sheet = opaque ? source.sheet : copy;
24193
- const dispose = installSnapshotSvgStyles(root, ids, svgMarker, [sheet]);
24194
- clone.textContent = snapshotUrls([...sheet.cssRules].map((rule) => rule.cssText).join("\n"), ids, source.sheet.href ?? document.baseURI);
24439
+ const dispose = installSnapshotSvgStyles(root, ids, svgMarker, [copy]);
24440
+ clone.textContent = snapshotRuleText(copy.cssRules);
24195
24441
  dispose();
24196
- if (source.sheet.disabled) clone.setAttribute("media", "not all");
24442
+ if (sourceSheet.disabled) clone.setAttribute("media", "not all");
24197
24443
  }
24198
24444
  }
24199
24445
  if (source.shadowRoot) {
@@ -24252,7 +24498,12 @@ function createSnapshot(passageEl, transitionType) {
24252
24498
  const cleanups = [];
24253
24499
  const ids = snapshotIds(passageEl);
24254
24500
  const svgMarker = String(++snapshotPseudoId);
24255
- const clone = cloneSnapshotTree(passageEl, ids, pseudoRules, svgMarker, cleanups);
24501
+ const svgState = {
24502
+ opaqueRoots: /* @__PURE__ */ new Set(),
24503
+ copies: []
24504
+ };
24505
+ const clone = cloneSnapshotTree(passageEl, ids, pseudoRules, svgMarker, cleanups, svgState);
24506
+ for (const { source, clone: copy, ids: localIds } of svgState.copies) if (svgState.opaqueRoots.has(source.getRootNode()) && !source.closest("defs, symbol, clipPath, mask, pattern, marker")) copyComputedStyle(getComputedStyle(source), copy.style, localIds);
24256
24507
  clone.style.removeProperty("animation");
24257
24508
  clone.style.removeProperty("grid-area");
24258
24509
  for (const name of ["opacity", "transform"]) clone.style.setProperty(name, clone.style.getPropertyValue(name));
@@ -25103,19 +25354,13 @@ defineMacro({
25103
25354
  const label = ctx.resolve?.(ctx.args.label ?? "") ?? rawArgs;
25104
25355
  const runBody = useDetachedBody();
25105
25356
  const handleClick = () => runBody(children);
25106
- const action = useControlAction({
25357
+ return renderActionButton(useControlAction({
25107
25358
  type: "button",
25108
25359
  key: rawArgs,
25109
25360
  authorId: ctx.id,
25110
25361
  label,
25111
25362
  perform: handleClick
25112
- });
25113
- return /* @__PURE__ */ jsx("button", {
25114
- type: "button",
25115
- ...actionAttributes(action, ctx),
25116
- onClick: handleClick,
25117
- children: label
25118
- });
25363
+ }), ctx, handleClick, label);
25119
25364
  }
25120
25365
  });
25121
25366
  // src/components/macros/MacroLink.tsx
@@ -25572,12 +25817,7 @@ defineMacro({
25572
25817
  target: passageName,
25573
25818
  perform: openDialog
25574
25819
  });
25575
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
25576
- type: "button",
25577
- ...actionAttributes(action, ctx),
25578
- onClick: openDialog,
25579
- children: label
25580
- }), open && /* @__PURE__ */ jsx(PassageDialog, {
25820
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [renderActionButton(action, ctx, openDialog, label), open && /* @__PURE__ */ jsx(PassageDialog, {
25581
25821
  passageName,
25582
25822
  onClose: () => setOpen(false),
25583
25823
  showCloseButton: !noclose
@@ -26378,27 +26618,22 @@ defineMacro({
26378
26618
  parameters: [VARIABLE_PARAMETER],
26379
26619
  render({ children = [] }, ctx) {
26380
26620
  const options = ctx.extractOptions(children);
26621
+ const label = ctx.value == null ? "Choose an option" : String(ctx.value);
26381
26622
  const handleClick = () => {
26382
26623
  if (options.length === 0) return;
26383
26624
  const current = ctx.getValue();
26384
- const nextIndex = (options.indexOf(String(current)) + 1) % options.length;
26625
+ const nextIndex = ((current == null ? -1 : options.indexOf(String(current))) + 1) % options.length;
26385
26626
  ctx.setValue(options[nextIndex]);
26386
26627
  };
26387
- const action = useVariableAction(ctx, {
26628
+ return renderActionButton(useVariableAction(ctx, {
26388
26629
  type: "cycle",
26389
- label: ctx.value == null ? options[0] || "" : String(ctx.value),
26630
+ label,
26390
26631
  options,
26391
26632
  perform: (v) => {
26392
26633
  if (v !== void 0) ctx.setValue(v);
26393
26634
  else handleClick();
26394
26635
  }
26395
- });
26396
- return /* @__PURE__ */ jsx("button", {
26397
- type: "button",
26398
- ...actionAttributes(action, ctx),
26399
- onClick: handleClick,
26400
- children: ctx.value == null ? options[0] || "" : String(ctx.value)
26401
- });
26636
+ }), ctx, handleClick, label);
26402
26637
  }
26403
26638
  });
26404
26639
  // src/components/macros/Span.tsx