polytypo 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/{chunk-47XAYIKV.js → chunk-3XRMEZDM.js} +168 -183
  2. package/dist/{chunk-47XAYIKV.js.map → chunk-3XRMEZDM.js.map} +1 -1
  3. package/dist/{chunk-MMU4UU46.js → chunk-4FZZJB7Y.js} +2 -2
  4. package/dist/{chunk-M2UGLSIB.cjs → chunk-5BVKKURT.cjs} +11 -11
  5. package/dist/{chunk-M2UGLSIB.cjs.map → chunk-5BVKKURT.cjs.map} +1 -1
  6. package/dist/chunk-A4HNRHBV.cjs +19 -0
  7. package/dist/{chunk-DZ72ITYV.cjs.map → chunk-A4HNRHBV.cjs.map} +1 -1
  8. package/dist/{chunk-MOVY7OL2.cjs → chunk-ADRRRKLB.cjs} +168 -183
  9. package/dist/chunk-ADRRRKLB.cjs.map +1 -0
  10. package/dist/{chunk-7IZAODBB.cjs → chunk-CZRTSOOB.cjs} +3 -3
  11. package/dist/{chunk-7IZAODBB.cjs.map → chunk-CZRTSOOB.cjs.map} +1 -1
  12. package/dist/{chunk-UKWVAQMR.js → chunk-EWZWHW3B.js} +3 -3
  13. package/dist/{chunk-7L4ECXDJ.js → chunk-ILWDO7FZ.js} +2 -2
  14. package/dist/chunk-IS7WKMGA.cjs +21 -0
  15. package/dist/{chunk-F3BDCZSG.cjs.map → chunk-IS7WKMGA.cjs.map} +1 -1
  16. package/dist/{chunk-YS3FXB5V.cjs → chunk-RNFW7474.cjs} +14 -14
  17. package/dist/{chunk-YS3FXB5V.cjs.map → chunk-RNFW7474.cjs.map} +1 -1
  18. package/dist/{chunk-HZPDGNOO.js → chunk-X2B4LIW3.js} +3 -3
  19. package/dist/{chunk-E63PQ3N7.js → chunk-ZBLCAVSM.js} +2 -2
  20. package/dist/html.cjs +7 -7
  21. package/dist/html.js +4 -4
  22. package/dist/index.cjs +10 -10
  23. package/dist/index.js +5 -5
  24. package/dist/markdown.cjs +7 -7
  25. package/dist/markdown.js +4 -4
  26. package/dist/text.cjs +6 -6
  27. package/dist/text.js +3 -3
  28. package/package.json +3 -3
  29. package/dist/chunk-DZ72ITYV.cjs +0 -19
  30. package/dist/chunk-F3BDCZSG.cjs +0 -21
  31. package/dist/chunk-MOVY7OL2.cjs.map +0 -1
  32. /package/dist/{chunk-MMU4UU46.js.map → chunk-4FZZJB7Y.js.map} +0 -0
  33. /package/dist/{chunk-UKWVAQMR.js.map → chunk-EWZWHW3B.js.map} +0 -0
  34. /package/dist/{chunk-7L4ECXDJ.js.map → chunk-ILWDO7FZ.js.map} +0 -0
  35. /package/dist/{chunk-HZPDGNOO.js.map → chunk-X2B4LIW3.js.map} +0 -0
  36. /package/dist/{chunk-E63PQ3N7.js.map → chunk-ZBLCAVSM.js.map} +0 -0
@@ -3835,131 +3835,8 @@ function isMarker(value) {
3835
3835
  return value === MARKER || value === LINE_MARKER;
3836
3836
  }
3837
3837
 
3838
- // src/rules/quote-ambiguity.ts
3839
- var SQ = 39;
3840
- var MIN_ENCLOSED = 1;
3841
- var MAX_ENCLOSED = 3;
3842
- var NARROW = /* @__PURE__ */ new Set([
3843
- 39,
3844
- 8216,
3845
- 8217,
3846
- 8218,
3847
- 8219,
3848
- 8249,
3849
- 8250
3850
- ]);
3851
- var INLINE_SPACE = /* @__PURE__ */ new Set([
3852
- 32,
3853
- 9,
3854
- 160,
3855
- 8239,
3856
- 8199,
3857
- 8201,
3858
- 8202
3859
- ]);
3860
- function at(cp, i) {
3861
- const value = cp[i];
3862
- return value === void 0 ? NONE : value;
3863
- }
3864
- function asciiLower(cp) {
3865
- return cp >= 65 && cp <= 90 ? cp + 32 : cp;
3866
- }
3867
- function isAlnum(cp) {
3868
- const DIGIT_ZERO9 = 48;
3869
- const DIGIT_NINE8 = 57;
3870
- return cp >= DIGIT_ZERO9 && cp <= DIGIT_NINE8 || isLetter(cp);
3871
- }
3872
- function wordEndsAt(arr, end, word) {
3873
- const start = end - word.length;
3874
- if (start < 0) return false;
3875
- for (let k = 0; k < word.length; k += 1) {
3876
- const c = at(arr, start + k);
3877
- const matches = k === 0 ? asciiLower(c) === asciiLower(word[k]) : c === word[k];
3878
- if (!matches) return false;
3879
- }
3880
- const before = start > 0 ? at(arr, start - 1) : NONE;
3881
- return before === NONE || !isAlnum(before);
3882
- }
3883
- function wordStartsAt(arr, start, word) {
3884
- const n = arr.length;
3885
- for (let k = 0; k < word.length; k += 1) {
3886
- const c = at(arr, start + k);
3887
- const matches = k === 0 ? asciiLower(c) === asciiLower(word[k]) : c === word[k];
3888
- if (!matches) return false;
3889
- }
3890
- const after = start + word.length < n ? at(arr, start + word.length) : NONE;
3891
- return after === NONE || !isAlnum(after);
3892
- }
3893
- function computeIdiomMatchedIndices(arr, idioms) {
3894
- const vetoed = /* @__PURE__ */ new Set();
3895
- if (idioms.length === 0) return vetoed;
3896
- const n = arr.length;
3897
- const compiled = idioms.map((idiom) => ({
3898
- left: toCodePoints(idiom.left),
3899
- elided: toCodePoints(idiom.elided),
3900
- right: toCodePoints(idiom.right)
3901
- }));
3902
- for (let i = 0; i < n; i += 1) {
3903
- const g = at(arr, i);
3904
- if (!NARROW.has(g)) continue;
3905
- const lLit = i > 0 ? at(arr, i - 1) : NONE;
3906
- if (lLit === NONE || !INLINE_SPACE.has(lLit)) continue;
3907
- for (const idiom of compiled) {
3908
- const k = idiom.elided.length;
3909
- const j = i + 1 + k;
3910
- if (j >= n) continue;
3911
- let elidedMatches = true;
3912
- for (let w = 0; w < k; w += 1) {
3913
- if (at(arr, i + 1 + w) !== idiom.elided[w]) {
3914
- elidedMatches = false;
3915
- break;
3916
- }
3917
- }
3918
- if (!elidedMatches) continue;
3919
- if (!NARROW.has(at(arr, j))) continue;
3920
- const rLit = j + 1 < n ? at(arr, j + 1) : NONE;
3921
- if (rLit === NONE || !INLINE_SPACE.has(rLit)) continue;
3922
- if (!wordEndsAt(arr, i - 1, idiom.left)) continue;
3923
- if (!wordStartsAt(arr, j + 2, idiom.right)) continue;
3924
- vetoed.add(i);
3925
- vetoed.add(j);
3926
- }
3927
- }
3928
- return vetoed;
3929
- }
3930
- function computeAmbiguousShapeIndices(cp) {
3931
- const ambiguous = /* @__PURE__ */ new Set();
3932
- const n = cp.length;
3933
- for (let i = 0; i < n; i += 1) {
3934
- if (at(cp, i) !== SQ) continue;
3935
- const lLit = i > 0 ? at(cp, i - 1) : NONE;
3936
- if (lLit === NONE || !INLINE_SPACE.has(lLit)) continue;
3937
- let k = 0;
3938
- while (k < MAX_ENCLOSED && isLetter(at(cp, i + 1 + k))) k += 1;
3939
- if (k < MIN_ENCLOSED) continue;
3940
- const j = i + 1 + k;
3941
- if (at(cp, j) !== SQ) continue;
3942
- const rLit = j + 1 < n ? at(cp, j + 1) : NONE;
3943
- if (rLit === NONE || !INLINE_SPACE.has(rLit)) continue;
3944
- ambiguous.add(i);
3945
- ambiguous.add(j);
3946
- }
3947
- return ambiguous;
3948
- }
3949
- function computePreserveIndices(cp, idioms) {
3950
- const ambiguous = computeAmbiguousShapeIndices(cp);
3951
- if (ambiguous.size === 0) return ambiguous;
3952
- const idiomMatched = computeIdiomMatchedIndices(cp, idioms);
3953
- if (idiomMatched.size === 0) return ambiguous;
3954
- const preserve = /* @__PURE__ */ new Set();
3955
- for (const index of ambiguous) {
3956
- if (!idiomMatched.has(index)) preserve.add(index);
3957
- }
3958
- return preserve;
3959
- }
3960
-
3961
3838
  // src/rules/apostrophe.ts
3962
- var SQ2 = 39;
3839
+ var SQ = 39;
3963
3840
  var RIGHT_SINGLE = 8217;
3964
3841
  var DIGIT_ZERO = 48;
3965
3842
  var DIGIT_NINE = 57;
@@ -4020,22 +3897,22 @@ var CLOSEISH = /* @__PURE__ */ new Set([
4020
3897
  8211,
4021
3898
  8212
4022
3899
  ]);
4023
- function at2(cp, i) {
3900
+ function at(cp, i) {
4024
3901
  const value = cp[i];
4025
3902
  return value === void 0 ? NONE : value;
4026
3903
  }
4027
3904
  function isDigit(cp) {
4028
3905
  return cp >= DIGIT_ZERO && cp <= DIGIT_NINE;
4029
3906
  }
4030
- function isAlnum2(cp) {
3907
+ function isAlnum(cp) {
4031
3908
  return isDigit(cp) || isLetter(cp);
4032
3909
  }
4033
3910
  function isApostrophe(left, right) {
4034
3911
  if (isDigit(left) && !isLetter(right)) return false;
4035
- if (isAlnum2(left) && isAlnum2(right)) return true;
3912
+ if (isAlnum(left) && isAlnum(right)) return true;
4036
3913
  if (isLetter(left) && (right === NONE || SPACELIKE.has(right) || CLOSEISH.has(right)))
4037
3914
  return true;
4038
- if ((left === NONE || SPACELIKE.has(left) || OPENISH.has(left)) && isAlnum2(right)) return true;
3915
+ if ((left === NONE || SPACELIKE.has(left) || OPENISH.has(left)) && isAlnum(right)) return true;
4039
3916
  return false;
4040
3917
  }
4041
3918
  var apostropheRule = {
@@ -4044,12 +3921,10 @@ var apostropheRule = {
4044
3921
  const cp = ctx.cp;
4045
3922
  const n = cp.length;
4046
3923
  const edits = [];
4047
- const preserve = computePreserveIndices(cp, ctx.locale.quotes.elisionIdioms);
4048
3924
  for (let i = 0; i < n; i += 1) {
4049
- if (at2(cp, i) !== SQ2) continue;
4050
- if (preserve.has(i)) continue;
4051
- const left = i > 0 ? at2(cp, i - 1) : NONE;
4052
- const right = i + 1 < n ? at2(cp, i + 1) : NONE;
3925
+ if (at(cp, i) !== SQ) continue;
3926
+ const left = i > 0 ? at(cp, i - 1) : NONE;
3927
+ const right = i + 1 < n ? at(cp, i + 1) : NONE;
4053
3928
  if (isApostrophe(left, right)) {
4054
3929
  edits.push({ start: i, end: i + 1, replacement: [RIGHT_SINGLE], ruleId: "apostrophe" });
4055
3930
  }
@@ -4284,7 +4159,7 @@ var DOT = 46;
4284
4159
  var ELL = 8230;
4285
4160
  var EXCLAMATION = 33;
4286
4161
  var QUESTION = 63;
4287
- function at3(cp, i) {
4162
+ function at2(cp, i) {
4288
4163
  const value = cp[i];
4289
4164
  return value === void 0 ? NONE : value;
4290
4165
  }
@@ -4297,7 +4172,7 @@ function isTerminal(cp) {
4297
4172
  function isSameRun(cp, s, e, target) {
4298
4173
  if (e - s !== target.length) return false;
4299
4174
  for (let j = 0; j < target.length; j += 1) {
4300
- if (at3(cp, s + j) !== target[j]) return false;
4175
+ if (at2(cp, s + j) !== target[j]) return false;
4301
4176
  }
4302
4177
  return true;
4303
4178
  }
@@ -4310,19 +4185,19 @@ var ellipsisRule = {
4310
4185
  const edits = [];
4311
4186
  let i = 0;
4312
4187
  while (i < n) {
4313
- if (!isDotlike(at3(cp, i))) {
4188
+ if (!isDotlike(at2(cp, i))) {
4314
4189
  i += 1;
4315
4190
  continue;
4316
4191
  }
4317
4192
  const s = i;
4318
4193
  let e = s;
4319
4194
  let q = 0;
4320
- while (e < n && isDotlike(at3(cp, e))) {
4321
- if (at3(cp, e) === ELL) q += 1;
4195
+ while (e < n && isDotlike(at2(cp, e))) {
4196
+ if (at2(cp, e) === ELL) q += 1;
4322
4197
  e += 1;
4323
4198
  }
4324
4199
  const k = e - s;
4325
- const left = at3(cp, s - 1);
4200
+ const left = at2(cp, s - 1);
4326
4201
  const target = runTarget(k, q, left, abbreviated);
4327
4202
  if (target !== null && !isSameRun(cp, s, e, target)) {
4328
4203
  edits.push({ start: s, end: e, replacement: target, ruleId: "ellipsis" });
@@ -4348,7 +4223,7 @@ var HYPHEN_MINUS2 = 45;
4348
4223
  var NON_BREAKING_HYPHEN = 8209;
4349
4224
  var DIGIT_ZERO3 = 48;
4350
4225
  var DIGIT_NINE3 = 57;
4351
- function at4(cp, i) {
4226
+ function at3(cp, i) {
4352
4227
  const value = cp[i];
4353
4228
  return value === void 0 ? NONE : value;
4354
4229
  }
@@ -4399,19 +4274,19 @@ function bind(index) {
4399
4274
  return { start: index, end: index + 1, replacement: [NON_BREAKING_HYPHEN], ruleId: "hyphen" };
4400
4275
  }
4401
4276
  function guardCompound(cp, a, k) {
4402
- const before = at4(cp, a - 1);
4277
+ const before = at3(cp, a - 1);
4403
4278
  if (before !== NONE && isWordish(before)) return false;
4404
- const after = at4(cp, a + k);
4279
+ const after = at3(cp, a + k);
4405
4280
  return after === NONE || !isWordish(after);
4406
4281
  }
4407
4282
  function guardPrefix(cp, a, k) {
4408
- const before = at4(cp, a - 1);
4283
+ const before = at3(cp, a - 1);
4409
4284
  if (before !== NONE && isWordish(before)) return false;
4410
- return isLetter(at4(cp, a + k));
4285
+ return isLetter(at3(cp, a + k));
4411
4286
  }
4412
4287
  function guardSuffix(cp, a, k) {
4413
- if (!isLetter(at4(cp, a - 1))) return false;
4414
- const after = at4(cp, a + k);
4288
+ if (!isLetter(at3(cp, a - 1))) return false;
4289
+ const after = at3(cp, a + k);
4415
4290
  return after === NONE || !isWordish(after);
4416
4291
  }
4417
4292
  function scan2(ctx) {
@@ -4489,14 +4364,14 @@ var BRACE_CLOSE = 125;
4489
4364
  var EN_DASH2 = 8211;
4490
4365
  var EM_DASH2 = 8212;
4491
4366
  var ELLIPSIS = 8230;
4492
- function at5(cp, i) {
4367
+ function at4(cp, i) {
4493
4368
  const value = cp[i];
4494
4369
  return value === void 0 ? NONE : value;
4495
4370
  }
4496
4371
  function isDigit4(cp) {
4497
4372
  return cp >= DIGIT_ZERO4 && cp <= DIGIT_NINE4;
4498
4373
  }
4499
- function isAlnum3(cp) {
4374
+ function isAlnum2(cp) {
4500
4375
  return isDigit4(cp) || isLetter(cp);
4501
4376
  }
4502
4377
  function isBreak2(cp) {
@@ -4646,14 +4521,14 @@ function punctuationSubRule(cp, prep, claims, marks, target, other) {
4646
4521
  if (marks.length === 0) return;
4647
4522
  for (let i = 0; i < cp.length; i += 1) {
4648
4523
  if (!contains(marks, cp[i])) continue;
4649
- const left = at5(cp, i - 1);
4524
+ const left = at4(cp, i - 1);
4650
4525
  if (left !== NONE && isMark(prep, left)) continue;
4651
- const after = at5(cp, i + 1);
4526
+ const after = at4(cp, i + 1);
4652
4527
  if (after !== NONE && !isSpaceLike(after) && !isCloseish(prep, after) && after !== ELLIPSIS && !isMark(prep, after)) {
4653
4528
  continue;
4654
4529
  }
4655
4530
  if (isOpenish(prep, left)) continue;
4656
- if (left !== NONE && isSpaceLike(left) && isOpenish(prep, at5(cp, i - 2))) continue;
4531
+ if (left !== NONE && isSpaceLike(left) && isOpenish(prep, at4(cp, i - 2))) continue;
4657
4532
  if (left === target) continue;
4658
4533
  if (left === SPACE2 || left === other) {
4659
4534
  claimConversion(claims, i - 1, target);
@@ -4670,15 +4545,15 @@ function shortWordsSubRule(cp, prep, claims) {
4670
4545
  const w = longestMatch(prep.shortWords, cp, a, matchFirstCharLenient);
4671
4546
  if (w === void 0) continue;
4672
4547
  const k = w.length;
4673
- const before = at5(cp, a - 1);
4548
+ const before = at4(cp, a - 1);
4674
4549
  if (!(before === NONE || isSpaceLike(before) || isOpenish(prep, before) || isSentenceDash(before))) {
4675
4550
  continue;
4676
4551
  }
4677
- const separator = at5(cp, a + k);
4552
+ const separator = at4(cp, a + k);
4678
4553
  if (separator === NBSP) continue;
4679
4554
  if (separator !== SPACE2) continue;
4680
- const next = at5(cp, a + k + 1);
4681
- if (!isAlnum3(next) && !isOpenish(prep, next)) continue;
4555
+ const next = at4(cp, a + k + 1);
4556
+ if (!isAlnum2(next) && !isOpenish(prep, next)) continue;
4682
4557
  claimConversion(claims, a + k, NBSP);
4683
4558
  }
4684
4559
  }
@@ -4688,8 +4563,8 @@ function abbreviationsSubRule(cp, prep, claims) {
4688
4563
  const w = longestMatch(prep.abbreviations, cp, a, matchSpaceLenient);
4689
4564
  if (w === void 0) continue;
4690
4565
  const k = w.length;
4691
- if (isAlnum3(at5(cp, a - 1))) continue;
4692
- if (isAlnum3(at5(cp, a + k))) continue;
4566
+ if (isAlnum2(at4(cp, a - 1))) continue;
4567
+ if (isAlnum2(at4(cp, a + k))) continue;
4693
4568
  for (let j = 0; j < k; j += 1) {
4694
4569
  if (w[j] !== SPACE2) continue;
4695
4570
  if (cp[a + j] === NBSP) continue;
@@ -4703,14 +4578,14 @@ function unitsSubRule(cp, prep, claims) {
4703
4578
  const w = longestMatch(prep.units, cp, a, matchExact);
4704
4579
  if (w === void 0) continue;
4705
4580
  const k = w.length;
4706
- if (isAlnum3(at5(cp, a + k))) continue;
4707
- const left = at5(cp, a - 1);
4581
+ if (isAlnum2(at4(cp, a + k))) continue;
4582
+ const left = at4(cp, a - 1);
4708
4583
  if (left === NBSP) continue;
4709
4584
  if (left !== SPACE2) continue;
4710
- if (!isDigit4(at5(cp, a - 2))) continue;
4585
+ if (!isDigit4(at4(cp, a - 2))) continue;
4711
4586
  let b = a - 2;
4712
4587
  while (b - 1 >= 0 && isDigit4(cp[b - 1])) b -= 1;
4713
- if (isLetter(at5(cp, b - 1))) continue;
4588
+ if (isLetter(at4(cp, b - 1))) continue;
4714
4589
  claimConversion(claims, a - 1, NBSP);
4715
4590
  }
4716
4591
  }
@@ -4720,31 +4595,31 @@ function symbolsSubRule(cp, prep, claims) {
4720
4595
  const w = longestMatch(prep.symbols, cp, a, matchExact);
4721
4596
  if (w === void 0) continue;
4722
4597
  const k = w.length;
4723
- if (isAlnum3(at5(cp, a - 1))) continue;
4724
- const separator = at5(cp, a + k);
4598
+ if (isAlnum2(at4(cp, a - 1))) continue;
4599
+ const separator = at4(cp, a + k);
4725
4600
  if (separator === NBSP) continue;
4726
4601
  if (separator !== SPACE2) continue;
4727
- if (!isDigit4(at5(cp, a + k + 1))) continue;
4602
+ if (!isDigit4(at4(cp, a + k + 1))) continue;
4728
4603
  claimConversion(claims, a + k, NBSP);
4729
4604
  }
4730
4605
  }
4731
4606
  function isInitialAt(cp, prep, p) {
4732
4607
  if (p < 0) return false;
4733
- if (!isUpper(at5(cp, p))) return false;
4734
- if (at5(cp, p + 1) !== FULL_STOP2) return false;
4735
- const before = at5(cp, p - 1);
4608
+ if (!isUpper(at4(cp, p))) return false;
4609
+ if (at4(cp, p + 1) !== FULL_STOP2) return false;
4610
+ const before = at4(cp, p - 1);
4736
4611
  return before === NONE || isSpaceLike(before) || isOpenish(prep, before);
4737
4612
  }
4738
4613
  function isAbbreviationTail(cp, p) {
4739
- if (!isSpaceLike(at5(cp, p - 1))) return false;
4740
- if (at5(cp, p - 2) !== FULL_STOP2) return false;
4741
- const head = at5(cp, p - 3);
4614
+ if (!isSpaceLike(at4(cp, p - 1))) return false;
4615
+ if (at4(cp, p - 2) !== FULL_STOP2) return false;
4616
+ const head = at4(cp, p - 3);
4742
4617
  return isLetter(head) && !isUpper(head);
4743
4618
  }
4744
4619
  function hasPrecedingInitial(cp, prep, p) {
4745
- const gap = at5(cp, p - 1);
4620
+ const gap = at4(cp, p - 1);
4746
4621
  if (gap !== SPACE2 && gap !== NBSP) return false;
4747
- if (at5(cp, p - 2) !== FULL_STOP2) return false;
4622
+ if (at4(cp, p - 2) !== FULL_STOP2) return false;
4748
4623
  return isInitialAt(cp, prep, p - 3);
4749
4624
  }
4750
4625
  function initialsSubRule(cp, prep, claims) {
@@ -4754,10 +4629,10 @@ function initialsSubRule(cp, prep, claims) {
4754
4629
  const here = cp[q];
4755
4630
  if (here !== SPACE2 && here !== NBSP) continue;
4756
4631
  const leftInitialP = q - 2;
4757
- const c1Shape = at5(cp, q - 1) === FULL_STOP2 && isInitialAt(cp, prep, leftInitialP) && isUpper(at5(cp, q + 1)) && !isAbbreviationTail(cp, leftInitialP);
4632
+ const c1Shape = at4(cp, q - 1) === FULL_STOP2 && isInitialAt(cp, prep, leftInitialP) && isUpper(at4(cp, q + 1)) && !isAbbreviationTail(cp, leftInitialP);
4758
4633
  const c1 = c1Shape && (mode === "single" || isInitialAt(cp, prep, q + 1) || hasPrecedingInitial(cp, prep, leftInitialP));
4759
- const rightSpace = at5(cp, q + 3);
4760
- const c2 = isLetter(at5(cp, q - 1)) && isInitialAt(cp, prep, q + 1) && (rightSpace === SPACE2 || rightSpace === NBSP) && isInitialAt(cp, prep, q + 4);
4634
+ const rightSpace = at4(cp, q + 3);
4635
+ const c2 = isLetter(at4(cp, q - 1)) && isInitialAt(cp, prep, q + 1) && (rightSpace === SPACE2 || rightSpace === NBSP) && isInitialAt(cp, prep, q + 4);
4761
4636
  if (!c1 && !c2) continue;
4762
4637
  if (here === NBSP) continue;
4763
4638
  claimConversion(claims, q, NBSP);
@@ -4768,7 +4643,7 @@ function quotesSubRule(cp, prep, claims) {
4768
4643
  for (let i = 0; i < cp.length; i += 1) {
4769
4644
  const here = cp[i];
4770
4645
  if (here === pair.open) {
4771
- const right = at5(cp, i + 1);
4646
+ const right = at4(cp, i + 1);
4772
4647
  if (right === pair.target) continue;
4773
4648
  if (right === SPACE2 || isNoBreak(right)) {
4774
4649
  claimConversion(claims, i + 1, pair.target);
@@ -4779,7 +4654,7 @@ function quotesSubRule(cp, prep, claims) {
4779
4654
  continue;
4780
4655
  }
4781
4656
  if (here !== pair.close) continue;
4782
- const left = at5(cp, i - 1);
4657
+ const left = at4(cp, i - 1);
4783
4658
  if (left === pair.target) continue;
4784
4659
  if (left === SPACE2 || isNoBreak(left)) {
4785
4660
  claimConversion(claims, i - 1, pair.target);
@@ -4799,14 +4674,14 @@ function forwardBindingSubRule(cp, prep, claims, patterns, wantsDigit) {
4799
4674
  if (!wantsDigit && prep.initialBinding !== "none" && k === 2 && isUpper(w[0]) && w[1] === FULL_STOP2) {
4800
4675
  continue;
4801
4676
  }
4802
- const before = at5(cp, a - 1);
4677
+ const before = at4(cp, a - 1);
4803
4678
  if (!(before === NONE || isSpaceLike(before) || isOpenish(prep, before) || isSentenceDash(before))) {
4804
4679
  continue;
4805
4680
  }
4806
- const separator = at5(cp, a + k);
4681
+ const separator = at4(cp, a + k);
4807
4682
  if (separator === NBSP) continue;
4808
4683
  if (separator !== SPACE2) continue;
4809
- const next = at5(cp, a + k + 1);
4684
+ const next = at4(cp, a + k + 1);
4810
4685
  if (isSpaceLike(next)) continue;
4811
4686
  if (wantsDigit ? !isDigit4(next) : !isLetter(next)) continue;
4812
4687
  claimConversion(claims, a + k, NBSP);
@@ -4838,13 +4713,123 @@ var nbspRule = {
4838
4713
  apply: scan3
4839
4714
  };
4840
4715
 
4716
+ // src/rules/quote-ambiguity.ts
4717
+ var LOWER_N = 110;
4718
+ var UPPER_N = 78;
4719
+ var NARROW = /* @__PURE__ */ new Set([
4720
+ 39,
4721
+ 8216,
4722
+ 8217,
4723
+ 8218,
4724
+ 8219,
4725
+ 8249,
4726
+ 8250
4727
+ ]);
4728
+ var INLINE_SPACE = /* @__PURE__ */ new Set([
4729
+ 32,
4730
+ 9,
4731
+ 160,
4732
+ 8239,
4733
+ 8199,
4734
+ 8201,
4735
+ 8202
4736
+ ]);
4737
+ function at5(cp, i) {
4738
+ const value = cp[i];
4739
+ return value === void 0 ? NONE : value;
4740
+ }
4741
+ function asciiLower(cp) {
4742
+ return cp >= 65 && cp <= 90 ? cp + 32 : cp;
4743
+ }
4744
+ function isAlnum3(cp) {
4745
+ const DIGIT_ZERO9 = 48;
4746
+ const DIGIT_NINE8 = 57;
4747
+ return cp >= DIGIT_ZERO9 && cp <= DIGIT_NINE8 || isLetter(cp);
4748
+ }
4749
+ function wordEndsAt(arr, end, word) {
4750
+ const start = end - word.length;
4751
+ if (start < 0) return false;
4752
+ for (let k = 0; k < word.length; k += 1) {
4753
+ const c = at5(arr, start + k);
4754
+ const matches = k === 0 ? asciiLower(c) === asciiLower(word[k]) : c === word[k];
4755
+ if (!matches) return false;
4756
+ }
4757
+ const before = start > 0 ? at5(arr, start - 1) : NONE;
4758
+ return before === NONE || !isAlnum3(before);
4759
+ }
4760
+ function wordStartsAt(arr, start, word) {
4761
+ const n = arr.length;
4762
+ for (let k = 0; k < word.length; k += 1) {
4763
+ const c = at5(arr, start + k);
4764
+ const matches = k === 0 ? asciiLower(c) === asciiLower(word[k]) : c === word[k];
4765
+ if (!matches) return false;
4766
+ }
4767
+ const after = start + word.length < n ? at5(arr, start + word.length) : NONE;
4768
+ return after === NONE || !isAlnum3(after);
4769
+ }
4770
+ function computeIdiomMatchedIndices(arr, idioms) {
4771
+ const vetoed = /* @__PURE__ */ new Set();
4772
+ if (idioms.length === 0) return vetoed;
4773
+ const n = arr.length;
4774
+ const compiled = idioms.map((idiom) => ({
4775
+ left: toCodePoints(idiom.left),
4776
+ elided: toCodePoints(idiom.elided),
4777
+ right: toCodePoints(idiom.right)
4778
+ }));
4779
+ for (let i = 0; i < n; i += 1) {
4780
+ const g = at5(arr, i);
4781
+ if (!NARROW.has(g)) continue;
4782
+ const lLit = i > 0 ? at5(arr, i - 1) : NONE;
4783
+ if (lLit === NONE || !INLINE_SPACE.has(lLit)) continue;
4784
+ for (const idiom of compiled) {
4785
+ const k = idiom.elided.length;
4786
+ const j = i + 1 + k;
4787
+ if (j >= n) continue;
4788
+ let elidedMatches = true;
4789
+ for (let w = 0; w < k; w += 1) {
4790
+ if (at5(arr, i + 1 + w) !== idiom.elided[w]) {
4791
+ elidedMatches = false;
4792
+ break;
4793
+ }
4794
+ }
4795
+ if (!elidedMatches) continue;
4796
+ if (!NARROW.has(at5(arr, j))) continue;
4797
+ const rLit = j + 1 < n ? at5(arr, j + 1) : NONE;
4798
+ if (rLit === NONE || !INLINE_SPACE.has(rLit)) continue;
4799
+ if (!wordEndsAt(arr, i - 1, idiom.left)) continue;
4800
+ if (!wordStartsAt(arr, j + 2, idiom.right)) continue;
4801
+ vetoed.add(i);
4802
+ vetoed.add(j);
4803
+ }
4804
+ }
4805
+ return vetoed;
4806
+ }
4807
+ function computeAmbiguousShapeIndices(cp) {
4808
+ const ambiguous = /* @__PURE__ */ new Set();
4809
+ const n = cp.length;
4810
+ for (let i = 0; i < n; i += 1) {
4811
+ if (!NARROW.has(at5(cp, i))) continue;
4812
+ const lLit = i > 0 ? at5(cp, i - 1) : NONE;
4813
+ if (lLit === NONE || !INLINE_SPACE.has(lLit)) continue;
4814
+ const enclosed = at5(cp, i + 1);
4815
+ if (enclosed !== LOWER_N && enclosed !== UPPER_N) continue;
4816
+ const j = i + 2;
4817
+ if (!NARROW.has(at5(cp, j))) continue;
4818
+ const rLit = j + 1 < n ? at5(cp, j + 1) : NONE;
4819
+ if (rLit === NONE || !INLINE_SPACE.has(rLit)) continue;
4820
+ ambiguous.add(i);
4821
+ ambiguous.add(j);
4822
+ }
4823
+ return ambiguous;
4824
+ }
4825
+
4841
4826
  // src/rules/quotes.ts
4842
4827
  var DIGIT_ZERO5 = 48;
4843
4828
  var DIGIT_NINE5 = 57;
4844
- var SQ3 = 39;
4829
+ var SQ2 = 39;
4845
4830
  var RIGHT_SINGLE_QUOTE = 8217;
4846
4831
  function v1Identity(cp) {
4847
- return cp === SQ3 ? RIGHT_SINGLE_QUOTE : cp;
4832
+ return cp === SQ2 ? RIGHT_SINGLE_QUOTE : cp;
4848
4833
  }
4849
4834
  var WIDE = /* @__PURE__ */ new Set([
4850
4835
  34,
@@ -5632,4 +5617,4 @@ export {
5632
5617
  planRules,
5633
5618
  runRules
5634
5619
  };
5635
- //# sourceMappingURL=chunk-47XAYIKV.js.map
5620
+ //# sourceMappingURL=chunk-3XRMEZDM.js.map