@forevka/wordcanvas 0.2.0 → 0.3.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.
- package/README.md +4 -2
- package/dist-lib/assets/{engine-DZ0JqUhP.js → engine-BVd9_fny.js} +1126 -1125
- package/dist-lib/assets/{worker-DL4Rxrg-.js → worker-C35TK5Ee.js} +1 -1
- package/dist-lib/builder.js +1 -1
- package/dist-lib/{editorApp-Dl_Glngl.js → editorApp-DYckquXo.js} +5464 -5158
- package/dist-lib/{types-C2taeCu4.js → types-5-egHV_r.js} +5 -5
- package/dist-lib/wordcanvas.js +65 -2
- package/package.json +1 -1
- package/dist-lib/wordcanvas-CgZ_uuf9.js +0 -373
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as fe, m as
|
|
2
|
-
const
|
|
1
|
+
import { c as fe, m as tt, f as ye } from "./worker-C35TK5Ee.js";
|
|
2
|
+
const An = [
|
|
3
3
|
"BN",
|
|
4
4
|
"BN",
|
|
5
5
|
"BN",
|
|
@@ -256,7 +256,7 @@ const mn = [
|
|
|
256
256
|
"L",
|
|
257
257
|
"L",
|
|
258
258
|
"L"
|
|
259
|
-
],
|
|
259
|
+
], mt = [
|
|
260
260
|
[697, 698, "ON"],
|
|
261
261
|
[706, 719, "ON"],
|
|
262
262
|
[722, 735, "ON"],
|
|
@@ -972,145 +972,145 @@ const mn = [
|
|
|
972
972
|
[1048574, 1048575, "BN"],
|
|
973
973
|
[1114110, 1114111, "BN"]
|
|
974
974
|
];
|
|
975
|
-
function
|
|
975
|
+
function En(e) {
|
|
976
976
|
if (e <= 255)
|
|
977
|
-
return
|
|
978
|
-
let t = 0, n =
|
|
977
|
+
return An[e];
|
|
978
|
+
let t = 0, n = mt.length - 1;
|
|
979
979
|
for (; t <= n; ) {
|
|
980
|
-
const i = t + n >> 1,
|
|
981
|
-
if (e <
|
|
980
|
+
const i = t + n >> 1, r = mt[i];
|
|
981
|
+
if (e < r[0]) {
|
|
982
982
|
n = i - 1;
|
|
983
983
|
continue;
|
|
984
984
|
}
|
|
985
|
-
if (e >
|
|
985
|
+
if (e > r[1]) {
|
|
986
986
|
t = i + 1;
|
|
987
987
|
continue;
|
|
988
988
|
}
|
|
989
|
-
return
|
|
989
|
+
return r[2];
|
|
990
990
|
}
|
|
991
991
|
return "L";
|
|
992
992
|
}
|
|
993
|
-
function
|
|
993
|
+
function Bn(e) {
|
|
994
994
|
const t = e.length;
|
|
995
995
|
if (t === 0)
|
|
996
996
|
return null;
|
|
997
997
|
const n = new Array(t);
|
|
998
998
|
let i = !1;
|
|
999
|
-
for (let
|
|
1000
|
-
const c = e.charCodeAt(
|
|
1001
|
-
let a = c,
|
|
1002
|
-
if (c >= 55296 && c <= 56319 &&
|
|
1003
|
-
const S = e.charCodeAt(
|
|
1004
|
-
S >= 56320 && S <= 57343 && (a = (c - 55296 << 10) + (S - 56320) + 65536,
|
|
1005
|
-
}
|
|
1006
|
-
const d =
|
|
999
|
+
for (let x = 0; x < t; ) {
|
|
1000
|
+
const c = e.charCodeAt(x);
|
|
1001
|
+
let a = c, f = 1;
|
|
1002
|
+
if (c >= 55296 && c <= 56319 && x + 1 < t) {
|
|
1003
|
+
const S = e.charCodeAt(x + 1);
|
|
1004
|
+
S >= 56320 && S <= 57343 && (a = (c - 55296 << 10) + (S - 56320) + 65536, f = 2);
|
|
1005
|
+
}
|
|
1006
|
+
const d = En(a);
|
|
1007
1007
|
(d === "R" || d === "AL" || d === "AN") && (i = !0);
|
|
1008
|
-
for (let S = 0; S <
|
|
1009
|
-
n[
|
|
1010
|
-
|
|
1008
|
+
for (let S = 0; S < f; S++)
|
|
1009
|
+
n[x + S] = d;
|
|
1010
|
+
x += f;
|
|
1011
1011
|
}
|
|
1012
1012
|
if (!i)
|
|
1013
1013
|
return null;
|
|
1014
|
-
let
|
|
1015
|
-
for (let
|
|
1016
|
-
const c = n[
|
|
1014
|
+
let r = 0;
|
|
1015
|
+
for (let x = 0; x < t; x++) {
|
|
1016
|
+
const c = n[x];
|
|
1017
1017
|
if (c === "L") {
|
|
1018
|
-
|
|
1018
|
+
r = 0;
|
|
1019
1019
|
break;
|
|
1020
1020
|
}
|
|
1021
1021
|
if (c === "R" || c === "AL") {
|
|
1022
|
-
|
|
1022
|
+
r = 1;
|
|
1023
1023
|
break;
|
|
1024
1024
|
}
|
|
1025
1025
|
}
|
|
1026
1026
|
const s = new Int8Array(t);
|
|
1027
|
-
for (let
|
|
1028
|
-
s[
|
|
1029
|
-
const l =
|
|
1030
|
-
let o =
|
|
1031
|
-
for (let
|
|
1032
|
-
n[
|
|
1033
|
-
o =
|
|
1034
|
-
for (let
|
|
1035
|
-
const c = n[
|
|
1036
|
-
c === "EN" ? n[
|
|
1037
|
-
}
|
|
1038
|
-
for (let
|
|
1039
|
-
n[
|
|
1040
|
-
for (let
|
|
1041
|
-
n[
|
|
1042
|
-
for (let
|
|
1043
|
-
if (n[
|
|
1027
|
+
for (let x = 0; x < t; x++)
|
|
1028
|
+
s[x] = r;
|
|
1029
|
+
const l = r & 1 ? "R" : "L", u = l;
|
|
1030
|
+
let o = u;
|
|
1031
|
+
for (let x = 0; x < t; x++)
|
|
1032
|
+
n[x] === "NSM" ? n[x] = o : o = n[x];
|
|
1033
|
+
o = u;
|
|
1034
|
+
for (let x = 0; x < t; x++) {
|
|
1035
|
+
const c = n[x];
|
|
1036
|
+
c === "EN" ? n[x] = o === "AL" ? "AN" : "EN" : (c === "R" || c === "L" || c === "AL") && (o = c);
|
|
1037
|
+
}
|
|
1038
|
+
for (let x = 0; x < t; x++)
|
|
1039
|
+
n[x] === "AL" && (n[x] = "R");
|
|
1040
|
+
for (let x = 1; x < t - 1; x++)
|
|
1041
|
+
n[x] === "ES" && n[x - 1] === "EN" && n[x + 1] === "EN" && (n[x] = "EN"), n[x] === "CS" && (n[x - 1] === "EN" || n[x - 1] === "AN") && n[x + 1] === n[x - 1] && (n[x] = n[x - 1]);
|
|
1042
|
+
for (let x = 0; x < t; x++) {
|
|
1043
|
+
if (n[x] !== "EN")
|
|
1044
1044
|
continue;
|
|
1045
1045
|
let c;
|
|
1046
|
-
for (c =
|
|
1046
|
+
for (c = x - 1; c >= 0 && n[c] === "ET"; c--)
|
|
1047
1047
|
n[c] = "EN";
|
|
1048
|
-
for (c =
|
|
1048
|
+
for (c = x + 1; c < t && n[c] === "ET"; c++)
|
|
1049
1049
|
n[c] = "EN";
|
|
1050
1050
|
}
|
|
1051
|
-
for (let
|
|
1052
|
-
const c = n[
|
|
1053
|
-
(c === "WS" || c === "ES" || c === "ET" || c === "CS") && (n[
|
|
1051
|
+
for (let x = 0; x < t; x++) {
|
|
1052
|
+
const c = n[x];
|
|
1053
|
+
(c === "WS" || c === "ES" || c === "ET" || c === "CS") && (n[x] = "ON");
|
|
1054
1054
|
}
|
|
1055
|
-
o =
|
|
1056
|
-
for (let
|
|
1057
|
-
const c = n[
|
|
1058
|
-
c === "EN" ? n[
|
|
1055
|
+
o = u;
|
|
1056
|
+
for (let x = 0; x < t; x++) {
|
|
1057
|
+
const c = n[x];
|
|
1058
|
+
c === "EN" ? n[x] = o === "L" ? "L" : "EN" : (c === "R" || c === "L") && (o = c);
|
|
1059
1059
|
}
|
|
1060
|
-
for (let
|
|
1061
|
-
if (n[
|
|
1060
|
+
for (let x = 0; x < t; x++) {
|
|
1061
|
+
if (n[x] !== "ON")
|
|
1062
1062
|
continue;
|
|
1063
|
-
let c =
|
|
1063
|
+
let c = x + 1;
|
|
1064
1064
|
for (; c < t && n[c] === "ON"; )
|
|
1065
1065
|
c++;
|
|
1066
|
-
const a =
|
|
1067
|
-
if (d === (
|
|
1068
|
-
for (let
|
|
1069
|
-
n[
|
|
1070
|
-
|
|
1071
|
-
}
|
|
1072
|
-
for (let
|
|
1073
|
-
n[
|
|
1074
|
-
for (let
|
|
1075
|
-
const c = n[
|
|
1076
|
-
(s[
|
|
1066
|
+
const a = x > 0 ? n[x - 1] : u, f = c < t ? n[c] : u, d = a !== "L" ? "R" : "L";
|
|
1067
|
+
if (d === (f !== "L" ? "R" : "L"))
|
|
1068
|
+
for (let A = x; A < c; A++)
|
|
1069
|
+
n[A] = d;
|
|
1070
|
+
x = c - 1;
|
|
1071
|
+
}
|
|
1072
|
+
for (let x = 0; x < t; x++)
|
|
1073
|
+
n[x] === "ON" && (n[x] = l);
|
|
1074
|
+
for (let x = 0; x < t; x++) {
|
|
1075
|
+
const c = n[x];
|
|
1076
|
+
(s[x] & 1) === 0 ? c === "R" ? s[x]++ : (c === "AN" || c === "EN") && (s[x] += 2) : (c === "L" || c === "AN" || c === "EN") && s[x]++;
|
|
1077
1077
|
}
|
|
1078
1078
|
return s;
|
|
1079
1079
|
}
|
|
1080
|
-
function
|
|
1081
|
-
const n =
|
|
1080
|
+
function Mn(e, t) {
|
|
1081
|
+
const n = Bn(e);
|
|
1082
1082
|
if (n === null)
|
|
1083
1083
|
return null;
|
|
1084
1084
|
const i = new Int8Array(t.length);
|
|
1085
|
-
for (let
|
|
1086
|
-
i[
|
|
1085
|
+
for (let r = 0; r < t.length; r++)
|
|
1086
|
+
i[r] = n[t[r]];
|
|
1087
1087
|
return i;
|
|
1088
1088
|
}
|
|
1089
|
-
const
|
|
1090
|
-
function
|
|
1089
|
+
const Cn = /[ \t\n\r\f]+/g, kn = /[\t\n\r\f]| {2,}|^ | $/;
|
|
1090
|
+
function Dn(e) {
|
|
1091
1091
|
const t = e ?? "normal";
|
|
1092
1092
|
return t === "pre-wrap" ? { mode: t, preserveOrdinarySpaces: !0, preserveHardBreaks: !0 } : { mode: t, preserveOrdinarySpaces: !1, preserveHardBreaks: !1 };
|
|
1093
1093
|
}
|
|
1094
|
-
function
|
|
1095
|
-
if (!
|
|
1094
|
+
function Ln(e) {
|
|
1095
|
+
if (!kn.test(e))
|
|
1096
1096
|
return e;
|
|
1097
|
-
let t = e.replace(
|
|
1097
|
+
let t = e.replace(Cn, " ");
|
|
1098
1098
|
return t.charCodeAt(0) === 32 && (t = t.slice(1)), t.length > 0 && t.charCodeAt(t.length - 1) === 32 && (t = t.slice(0, -1)), t;
|
|
1099
1099
|
}
|
|
1100
|
-
function
|
|
1100
|
+
function On(e) {
|
|
1101
1101
|
return /[\r\f]/.test(e) ? e.replace(/\r\n/g, `
|
|
1102
1102
|
`).replace(/[\r\f]/g, `
|
|
1103
1103
|
`) : e;
|
|
1104
1104
|
}
|
|
1105
|
-
let
|
|
1106
|
-
function
|
|
1107
|
-
return
|
|
1108
|
-
}
|
|
1109
|
-
const In = /\p{Script=Arabic}/u, ge = /\p{M}/u, tt = /\p{Nd}/u;
|
|
1110
|
-
function mt(e) {
|
|
1111
|
-
return In.test(e);
|
|
1105
|
+
let je = null, bn;
|
|
1106
|
+
function In() {
|
|
1107
|
+
return je === null && (je = new Intl.Segmenter(bn, { granularity: "word" })), je;
|
|
1112
1108
|
}
|
|
1109
|
+
const yn = /\p{Script=Arabic}/u, Ne = /\p{M}/u, nt = /\p{Nd}/u;
|
|
1113
1110
|
function At(e) {
|
|
1111
|
+
return yn.test(e);
|
|
1112
|
+
}
|
|
1113
|
+
function Et(e) {
|
|
1114
1114
|
return e >= 19968 && e <= 40959 || e >= 13312 && e <= 19903 || e >= 131072 && e <= 173791 || e >= 173824 && e <= 177983 || e >= 177984 && e <= 178207 || e >= 178208 && e <= 183983 || e >= 183984 && e <= 191471 || e >= 191472 && e <= 192093 || e >= 194560 && e <= 195103 || e >= 196608 && e <= 201551 || e >= 201552 && e <= 205743 || e >= 205744 && e <= 210041 || e >= 63744 && e <= 64255 || e >= 12288 && e <= 12351 || e >= 12352 && e <= 12447 || e >= 12448 && e <= 12543 || e >= 12592 && e <= 12687 || e >= 44032 && e <= 55215 || e >= 65280 && e <= 65519;
|
|
1115
1115
|
}
|
|
1116
1116
|
function oe(e) {
|
|
@@ -1120,46 +1120,46 @@ function oe(e) {
|
|
|
1120
1120
|
if (n >= 55296 && n <= 56319 && t + 1 < e.length) {
|
|
1121
1121
|
const i = e.charCodeAt(t + 1);
|
|
1122
1122
|
if (i >= 56320 && i <= 57343) {
|
|
1123
|
-
const
|
|
1124
|
-
if (
|
|
1123
|
+
const r = (n - 55296 << 10) + (i - 56320) + 65536;
|
|
1124
|
+
if (Et(r))
|
|
1125
1125
|
return !0;
|
|
1126
1126
|
t++;
|
|
1127
1127
|
continue;
|
|
1128
1128
|
}
|
|
1129
1129
|
}
|
|
1130
|
-
if (
|
|
1130
|
+
if (Et(n))
|
|
1131
1131
|
return !0;
|
|
1132
1132
|
}
|
|
1133
1133
|
}
|
|
1134
1134
|
return !1;
|
|
1135
1135
|
}
|
|
1136
|
-
function
|
|
1137
|
-
const t =
|
|
1138
|
-
return t !== null && (
|
|
1136
|
+
function wn(e) {
|
|
1137
|
+
const t = Le(e);
|
|
1138
|
+
return t !== null && (st.has(t) || ge.has(t));
|
|
1139
1139
|
}
|
|
1140
|
-
const
|
|
1140
|
+
const Pn = /* @__PURE__ */ new Set([
|
|
1141
1141
|
" ",
|
|
1142
1142
|
" ",
|
|
1143
1143
|
"",
|
|
1144
1144
|
"\uFEFF"
|
|
1145
|
-
]),
|
|
1145
|
+
]), Wn = /* @__PURE__ */ new Set([
|
|
1146
1146
|
"-",
|
|
1147
1147
|
"‐",
|
|
1148
1148
|
"–",
|
|
1149
1149
|
"—"
|
|
1150
1150
|
]);
|
|
1151
|
-
function Wn(e) {
|
|
1152
|
-
const t = De(e);
|
|
1153
|
-
return t !== null && wn.has(t);
|
|
1154
|
-
}
|
|
1155
1151
|
function vn(e) {
|
|
1156
|
-
const t =
|
|
1152
|
+
const t = Le(e);
|
|
1157
1153
|
return t !== null && Pn.has(t);
|
|
1158
1154
|
}
|
|
1155
|
+
function Rn(e) {
|
|
1156
|
+
const t = Le(e);
|
|
1157
|
+
return t !== null && Wn.has(t);
|
|
1158
|
+
}
|
|
1159
1159
|
function Kt(e, t) {
|
|
1160
|
-
return
|
|
1160
|
+
return vn(e) ? !1 : t ? !(wn(e) || Rn(e)) : !0;
|
|
1161
1161
|
}
|
|
1162
|
-
const
|
|
1162
|
+
const st = /* @__PURE__ */ new Set([
|
|
1163
1163
|
",",
|
|
1164
1164
|
".",
|
|
1165
1165
|
"!",
|
|
@@ -1186,7 +1186,7 @@ const nt = /* @__PURE__ */ new Set([
|
|
|
1186
1186
|
"ゞ",
|
|
1187
1187
|
"ヽ",
|
|
1188
1188
|
"ヾ"
|
|
1189
|
-
]),
|
|
1189
|
+
]), ve = /* @__PURE__ */ new Set([
|
|
1190
1190
|
'"',
|
|
1191
1191
|
"(",
|
|
1192
1192
|
"[",
|
|
@@ -1210,10 +1210,10 @@ const nt = /* @__PURE__ */ new Set([
|
|
|
1210
1210
|
"〖",
|
|
1211
1211
|
"〘",
|
|
1212
1212
|
"〚"
|
|
1213
|
-
]),
|
|
1213
|
+
]), it = /* @__PURE__ */ new Set([
|
|
1214
1214
|
"'",
|
|
1215
1215
|
"’"
|
|
1216
|
-
]),
|
|
1216
|
+
]), ge = /* @__PURE__ */ new Set([
|
|
1217
1217
|
".",
|
|
1218
1218
|
",",
|
|
1219
1219
|
"!",
|
|
@@ -1240,14 +1240,14 @@ const nt = /* @__PURE__ */ new Set([
|
|
|
1240
1240
|
"»",
|
|
1241
1241
|
"›",
|
|
1242
1242
|
"…"
|
|
1243
|
-
]),
|
|
1243
|
+
]), Tn = /* @__PURE__ */ new Set([
|
|
1244
1244
|
":",
|
|
1245
1245
|
".",
|
|
1246
1246
|
"،",
|
|
1247
1247
|
"؛"
|
|
1248
|
-
]), Tn = /* @__PURE__ */ new Set([
|
|
1249
|
-
"၏"
|
|
1250
1248
|
]), Gn = /* @__PURE__ */ new Set([
|
|
1249
|
+
"၏"
|
|
1250
|
+
]), Hn = /* @__PURE__ */ new Set([
|
|
1251
1251
|
"”",
|
|
1252
1252
|
"’",
|
|
1253
1253
|
"»",
|
|
@@ -1260,39 +1260,39 @@ const nt = /* @__PURE__ */ new Set([
|
|
|
1260
1260
|
"〕",
|
|
1261
1261
|
")"
|
|
1262
1262
|
]);
|
|
1263
|
-
function
|
|
1264
|
-
if (
|
|
1263
|
+
function _n(e) {
|
|
1264
|
+
if (rt(e))
|
|
1265
1265
|
return !0;
|
|
1266
1266
|
let t = !1;
|
|
1267
1267
|
for (const n of e) {
|
|
1268
|
-
if (
|
|
1268
|
+
if (ge.has(n) || Te(n)) {
|
|
1269
1269
|
t = !0;
|
|
1270
1270
|
continue;
|
|
1271
1271
|
}
|
|
1272
|
-
if (!(t &&
|
|
1272
|
+
if (!(t && Ne.test(n)))
|
|
1273
1273
|
return !1;
|
|
1274
1274
|
}
|
|
1275
1275
|
return t;
|
|
1276
1276
|
}
|
|
1277
|
-
function
|
|
1277
|
+
function zn(e) {
|
|
1278
1278
|
for (const t of e)
|
|
1279
|
-
if (!
|
|
1279
|
+
if (!st.has(t) && !ge.has(t))
|
|
1280
1280
|
return !1;
|
|
1281
1281
|
return e.length > 0;
|
|
1282
1282
|
}
|
|
1283
|
-
function
|
|
1284
|
-
if (
|
|
1283
|
+
function jn(e) {
|
|
1284
|
+
if (rt(e))
|
|
1285
1285
|
return !0;
|
|
1286
1286
|
for (const t of e)
|
|
1287
|
-
if (!
|
|
1287
|
+
if (!ve.has(t) && !it.has(t) && !Ne.test(t) && !Te(t))
|
|
1288
1288
|
return !1;
|
|
1289
1289
|
return e.length > 0;
|
|
1290
1290
|
}
|
|
1291
|
-
function
|
|
1291
|
+
function rt(e) {
|
|
1292
1292
|
let t = !1;
|
|
1293
1293
|
for (const n of e)
|
|
1294
|
-
if (!(n === "\\" ||
|
|
1295
|
-
if (
|
|
1294
|
+
if (!(n === "\\" || Ne.test(n))) {
|
|
1295
|
+
if (ve.has(n) || ge.has(n) || it.has(n)) {
|
|
1296
1296
|
t = !0;
|
|
1297
1297
|
continue;
|
|
1298
1298
|
}
|
|
@@ -1300,41 +1300,41 @@ function it(e) {
|
|
|
1300
1300
|
}
|
|
1301
1301
|
return t;
|
|
1302
1302
|
}
|
|
1303
|
-
function
|
|
1303
|
+
function Re(e, t) {
|
|
1304
1304
|
const n = t - 1;
|
|
1305
1305
|
if (n <= 0)
|
|
1306
1306
|
return Math.max(n, 0);
|
|
1307
1307
|
const i = e.charCodeAt(n);
|
|
1308
1308
|
if (i < 56320 || i > 57343)
|
|
1309
1309
|
return n;
|
|
1310
|
-
const
|
|
1311
|
-
if (
|
|
1310
|
+
const r = n - 1;
|
|
1311
|
+
if (r < 0)
|
|
1312
1312
|
return n;
|
|
1313
|
-
const s = e.charCodeAt(
|
|
1314
|
-
return s >= 55296 && s <= 56319 ?
|
|
1313
|
+
const s = e.charCodeAt(r);
|
|
1314
|
+
return s >= 55296 && s <= 56319 ? r : n;
|
|
1315
1315
|
}
|
|
1316
|
-
function
|
|
1316
|
+
function Le(e) {
|
|
1317
1317
|
if (e.length === 0)
|
|
1318
1318
|
return null;
|
|
1319
|
-
const t =
|
|
1319
|
+
const t = Re(e, e.length);
|
|
1320
1320
|
return e.slice(t);
|
|
1321
1321
|
}
|
|
1322
1322
|
function Kn(e) {
|
|
1323
1323
|
for (const t of e)
|
|
1324
|
-
if (!
|
|
1324
|
+
if (!Ne.test(t))
|
|
1325
1325
|
return t;
|
|
1326
1326
|
return null;
|
|
1327
1327
|
}
|
|
1328
|
-
function
|
|
1328
|
+
function Un(e) {
|
|
1329
1329
|
for (let t = e.length; t > 0; ) {
|
|
1330
|
-
const n =
|
|
1331
|
-
if (!
|
|
1330
|
+
const n = Re(e, t), i = e.slice(n, t);
|
|
1331
|
+
if (!Ne.test(i))
|
|
1332
1332
|
return i;
|
|
1333
1333
|
t = n;
|
|
1334
1334
|
}
|
|
1335
1335
|
return null;
|
|
1336
1336
|
}
|
|
1337
|
-
const
|
|
1337
|
+
const Jn = [
|
|
1338
1338
|
36,
|
|
1339
1339
|
37,
|
|
1340
1340
|
43,
|
|
@@ -1402,34 +1402,34 @@ const Un = [
|
|
|
1402
1402
|
126128,
|
|
1403
1403
|
126128
|
|
1404
1404
|
];
|
|
1405
|
-
function
|
|
1405
|
+
function Qn(e, t) {
|
|
1406
1406
|
for (let n = 0; n < t.length; n += 2)
|
|
1407
1407
|
if (e >= t[n] && e <= t[n + 1])
|
|
1408
1408
|
return !0;
|
|
1409
1409
|
return !1;
|
|
1410
1410
|
}
|
|
1411
|
-
function
|
|
1411
|
+
function Te(e) {
|
|
1412
1412
|
const t = e.codePointAt(0);
|
|
1413
|
-
return t !== void 0 &&
|
|
1414
|
-
}
|
|
1415
|
-
function Qn(e) {
|
|
1416
|
-
const t = jn(e);
|
|
1417
|
-
return t !== null && Re(t);
|
|
1413
|
+
return t !== void 0 && Qn(t, Jn);
|
|
1418
1414
|
}
|
|
1419
1415
|
function $n(e) {
|
|
1420
|
-
const t =
|
|
1421
|
-
return t !== null &&
|
|
1416
|
+
const t = Un(e);
|
|
1417
|
+
return t !== null && Te(t);
|
|
1422
1418
|
}
|
|
1423
1419
|
function Yn(e) {
|
|
1420
|
+
const t = Kn(e);
|
|
1421
|
+
return t !== null && nt.test(t);
|
|
1422
|
+
}
|
|
1423
|
+
function Xn(e) {
|
|
1424
1424
|
const t = Array.from(e);
|
|
1425
1425
|
let n = t.length;
|
|
1426
1426
|
for (; n > 0; ) {
|
|
1427
1427
|
const i = t[n - 1];
|
|
1428
|
-
if (
|
|
1428
|
+
if (Ne.test(i)) {
|
|
1429
1429
|
n--;
|
|
1430
1430
|
continue;
|
|
1431
1431
|
}
|
|
1432
|
-
if (
|
|
1432
|
+
if (ve.has(i) || it.has(i)) {
|
|
1433
1433
|
n--;
|
|
1434
1434
|
continue;
|
|
1435
1435
|
}
|
|
@@ -1440,45 +1440,45 @@ function Yn(e) {
|
|
|
1440
1440
|
tail: t.slice(n).join("")
|
|
1441
1441
|
};
|
|
1442
1442
|
}
|
|
1443
|
-
function
|
|
1443
|
+
function qn(e, t, n) {
|
|
1444
1444
|
return n === "text" && !t && e.length === 1 && e !== "-" && e !== "—" ? e : null;
|
|
1445
1445
|
}
|
|
1446
|
-
function
|
|
1447
|
-
const
|
|
1448
|
-
if (
|
|
1446
|
+
function Bt(e, t, n, i) {
|
|
1447
|
+
const r = t[i], s = e[i];
|
|
1448
|
+
if (r == null)
|
|
1449
1449
|
return s;
|
|
1450
1450
|
const l = n[i];
|
|
1451
1451
|
if (s.length === l)
|
|
1452
1452
|
return s;
|
|
1453
|
-
const
|
|
1454
|
-
return e[i] =
|
|
1455
|
-
}
|
|
1456
|
-
function Bt(e, t) {
|
|
1457
|
-
return e && t !== null && Rn.has(t);
|
|
1453
|
+
const u = r.repeat(l);
|
|
1454
|
+
return e[i] = u, u;
|
|
1458
1455
|
}
|
|
1459
|
-
function
|
|
1460
|
-
|
|
1461
|
-
return t !== null && Tn.has(t);
|
|
1456
|
+
function Mt(e, t) {
|
|
1457
|
+
return e && t !== null && Tn.has(t);
|
|
1462
1458
|
}
|
|
1463
1459
|
function Vn(e) {
|
|
1460
|
+
const t = Le(e);
|
|
1461
|
+
return t !== null && Gn.has(t);
|
|
1462
|
+
}
|
|
1463
|
+
function Zn(e) {
|
|
1464
1464
|
if (e.length < 2 || e[0] !== " ")
|
|
1465
1465
|
return null;
|
|
1466
1466
|
const t = e.slice(1);
|
|
1467
1467
|
return /^\p{M}+$/u.test(t) ? { space: " ", marks: t } : null;
|
|
1468
1468
|
}
|
|
1469
|
-
function
|
|
1469
|
+
function Ye(e) {
|
|
1470
1470
|
let t = e.length;
|
|
1471
1471
|
for (; t > 0; ) {
|
|
1472
|
-
const n =
|
|
1473
|
-
if (
|
|
1472
|
+
const n = Re(e, t), i = e.slice(n, t);
|
|
1473
|
+
if (Hn.has(i))
|
|
1474
1474
|
return !0;
|
|
1475
|
-
if (!
|
|
1475
|
+
if (!ge.has(i))
|
|
1476
1476
|
return !1;
|
|
1477
1477
|
t = n;
|
|
1478
1478
|
}
|
|
1479
1479
|
return !1;
|
|
1480
1480
|
}
|
|
1481
|
-
function
|
|
1481
|
+
function e0(e, t) {
|
|
1482
1482
|
if (t.preserveOrdinarySpaces || t.preserveHardBreaks) {
|
|
1483
1483
|
if (e === " ")
|
|
1484
1484
|
return "preserved-space";
|
|
@@ -1490,104 +1490,104 @@ function Zn(e, t) {
|
|
|
1490
1490
|
}
|
|
1491
1491
|
return e === " " ? "space" : e === " " || e === " " || e === "" || e === "\uFEFF" ? "glue" : e === "" ? "zero-width-break" : e === "" ? "soft-hyphen" : "text";
|
|
1492
1492
|
}
|
|
1493
|
-
const
|
|
1494
|
-
function
|
|
1493
|
+
const t0 = /[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;
|
|
1494
|
+
function re(e) {
|
|
1495
1495
|
return e.length === 1 ? e[0] : e.join("");
|
|
1496
1496
|
}
|
|
1497
|
-
function
|
|
1497
|
+
function n0(e, t) {
|
|
1498
1498
|
const n = [];
|
|
1499
1499
|
for (let i = e.length - 1; i >= 0; i--)
|
|
1500
1500
|
n.push(e[i]);
|
|
1501
|
-
return n.push(t),
|
|
1501
|
+
return n.push(t), re(n);
|
|
1502
1502
|
}
|
|
1503
|
-
function
|
|
1504
|
-
if (!
|
|
1503
|
+
function s0(e, t, n, i) {
|
|
1504
|
+
if (!t0.test(e))
|
|
1505
1505
|
return [{ text: e, isWordLike: t, kind: "text", start: n }];
|
|
1506
|
-
const
|
|
1507
|
-
let s = null, l = [],
|
|
1506
|
+
const r = [];
|
|
1507
|
+
let s = null, l = [], u = n, o = !1, x = 0;
|
|
1508
1508
|
for (const c of e) {
|
|
1509
|
-
const a =
|
|
1510
|
-
if (s !== null && a === s &&
|
|
1511
|
-
l.push(c),
|
|
1509
|
+
const a = e0(c, i), f = a === "text" && t;
|
|
1510
|
+
if (s !== null && a === s && f === o) {
|
|
1511
|
+
l.push(c), x += c.length;
|
|
1512
1512
|
continue;
|
|
1513
1513
|
}
|
|
1514
|
-
s !== null &&
|
|
1515
|
-
text:
|
|
1514
|
+
s !== null && r.push({
|
|
1515
|
+
text: re(l),
|
|
1516
1516
|
isWordLike: o,
|
|
1517
1517
|
kind: s,
|
|
1518
|
-
start:
|
|
1519
|
-
}), s = a, l = [c],
|
|
1518
|
+
start: u
|
|
1519
|
+
}), s = a, l = [c], u = n + x, o = f, x += c.length;
|
|
1520
1520
|
}
|
|
1521
|
-
return s !== null &&
|
|
1522
|
-
text:
|
|
1521
|
+
return s !== null && r.push({
|
|
1522
|
+
text: re(l),
|
|
1523
1523
|
isWordLike: o,
|
|
1524
1524
|
kind: s,
|
|
1525
|
-
start:
|
|
1526
|
-
}),
|
|
1525
|
+
start: u
|
|
1526
|
+
}), r;
|
|
1527
1527
|
}
|
|
1528
|
-
function
|
|
1528
|
+
function Xe(e) {
|
|
1529
1529
|
return e === "space" || e === "preserved-space" || e === "zero-width-break" || e === "hard-break";
|
|
1530
1530
|
}
|
|
1531
|
-
const
|
|
1532
|
-
function
|
|
1531
|
+
const i0 = /^[A-Za-z][A-Za-z0-9+.-]*:$/;
|
|
1532
|
+
function r0(e, t) {
|
|
1533
1533
|
const n = e.texts[t];
|
|
1534
|
-
return n.startsWith("www.") ? !0 :
|
|
1534
|
+
return n.startsWith("www.") ? !0 : i0.test(n) && t + 1 < e.len && e.kinds[t + 1] === "text" && e.texts[t + 1] === "//";
|
|
1535
1535
|
}
|
|
1536
1536
|
function x0(e) {
|
|
1537
1537
|
return e.includes("?") && (e.includes("://") || e.startsWith("www."));
|
|
1538
1538
|
}
|
|
1539
|
-
function
|
|
1540
|
-
const t = e.texts.slice(), n = e.isWordLike.slice(), i = e.kinds.slice(),
|
|
1539
|
+
function o0(e) {
|
|
1540
|
+
const t = e.texts.slice(), n = e.isWordLike.slice(), i = e.kinds.slice(), r = e.starts.slice();
|
|
1541
1541
|
for (let l = 0; l < e.len; l++) {
|
|
1542
|
-
if (i[l] !== "text" || !
|
|
1542
|
+
if (i[l] !== "text" || !r0(e, l))
|
|
1543
1543
|
continue;
|
|
1544
|
-
const
|
|
1544
|
+
const u = [t[l]];
|
|
1545
1545
|
let o = l + 1;
|
|
1546
|
-
for (; o < e.len && !
|
|
1547
|
-
|
|
1548
|
-
const
|
|
1549
|
-
if (i[o] = "text", t[o] = "", o++,
|
|
1546
|
+
for (; o < e.len && !Xe(i[o]); ) {
|
|
1547
|
+
u.push(t[o]), n[l] = !0;
|
|
1548
|
+
const x = t[o].includes("?");
|
|
1549
|
+
if (i[o] = "text", t[o] = "", o++, x)
|
|
1550
1550
|
break;
|
|
1551
1551
|
}
|
|
1552
|
-
t[l] =
|
|
1552
|
+
t[l] = re(u);
|
|
1553
1553
|
}
|
|
1554
1554
|
let s = 0;
|
|
1555
1555
|
for (let l = 0; l < t.length; l++) {
|
|
1556
|
-
const
|
|
1557
|
-
|
|
1556
|
+
const u = t[l];
|
|
1557
|
+
u.length !== 0 && (s !== l && (t[s] = u, n[s] = n[l], i[s] = i[l], r[s] = r[l]), s++);
|
|
1558
1558
|
}
|
|
1559
|
-
return t.length = s, n.length = s, i.length = s,
|
|
1559
|
+
return t.length = s, n.length = s, i.length = s, r.length = s, {
|
|
1560
1560
|
len: s,
|
|
1561
1561
|
texts: t,
|
|
1562
1562
|
isWordLike: n,
|
|
1563
1563
|
kinds: i,
|
|
1564
|
-
starts:
|
|
1564
|
+
starts: r
|
|
1565
1565
|
};
|
|
1566
1566
|
}
|
|
1567
|
-
function
|
|
1568
|
-
const t = [], n = [], i = [],
|
|
1567
|
+
function l0(e) {
|
|
1568
|
+
const t = [], n = [], i = [], r = [];
|
|
1569
1569
|
for (let s = 0; s < e.len; s++) {
|
|
1570
1570
|
const l = e.texts[s];
|
|
1571
|
-
if (t.push(l), n.push(e.isWordLike[s]), i.push(e.kinds[s]),
|
|
1571
|
+
if (t.push(l), n.push(e.isWordLike[s]), i.push(e.kinds[s]), r.push(e.starts[s]), !x0(l))
|
|
1572
1572
|
continue;
|
|
1573
|
-
const
|
|
1574
|
-
if (
|
|
1573
|
+
const u = s + 1;
|
|
1574
|
+
if (u >= e.len || Xe(e.kinds[u]))
|
|
1575
1575
|
continue;
|
|
1576
|
-
const o = [],
|
|
1577
|
-
let c =
|
|
1578
|
-
for (; c < e.len && !
|
|
1576
|
+
const o = [], x = e.starts[u];
|
|
1577
|
+
let c = u;
|
|
1578
|
+
for (; c < e.len && !Xe(e.kinds[c]); )
|
|
1579
1579
|
o.push(e.texts[c]), c++;
|
|
1580
|
-
o.length > 0 && (t.push(
|
|
1580
|
+
o.length > 0 && (t.push(re(o)), n.push(!0), i.push("text"), r.push(x), s = c - 1);
|
|
1581
1581
|
}
|
|
1582
1582
|
return {
|
|
1583
1583
|
len: t.length,
|
|
1584
1584
|
texts: t,
|
|
1585
1585
|
isWordLike: n,
|
|
1586
1586
|
kinds: i,
|
|
1587
|
-
starts:
|
|
1587
|
+
starts: r
|
|
1588
1588
|
};
|
|
1589
1589
|
}
|
|
1590
|
-
const
|
|
1590
|
+
const c0 = /* @__PURE__ */ new Set([
|
|
1591
1591
|
":",
|
|
1592
1592
|
"-",
|
|
1593
1593
|
"/",
|
|
@@ -1597,128 +1597,128 @@ const l0 = /* @__PURE__ */ new Set([
|
|
|
1597
1597
|
"+",
|
|
1598
1598
|
"–",
|
|
1599
1599
|
"—"
|
|
1600
|
-
]),
|
|
1601
|
-
function
|
|
1600
|
+
]), a0 = /* @__PURE__ */ new Set([".", ",", ":", ";"]);
|
|
1601
|
+
function Ct(e) {
|
|
1602
1602
|
for (let t = e.length; t > 0; ) {
|
|
1603
|
-
const n =
|
|
1604
|
-
if (
|
|
1603
|
+
const n = Re(e, t), i = e.slice(n, t);
|
|
1604
|
+
if (Ne.test(i)) {
|
|
1605
1605
|
t = n;
|
|
1606
1606
|
continue;
|
|
1607
1607
|
}
|
|
1608
|
-
return
|
|
1608
|
+
return a0.has(i) || Te(i);
|
|
1609
1609
|
}
|
|
1610
1610
|
return !1;
|
|
1611
1611
|
}
|
|
1612
|
-
function
|
|
1612
|
+
function u0(e, t) {
|
|
1613
1613
|
return t && !oe(e);
|
|
1614
1614
|
}
|
|
1615
|
-
function
|
|
1615
|
+
function Ut(e) {
|
|
1616
1616
|
for (const t of e)
|
|
1617
|
-
if (
|
|
1617
|
+
if (nt.test(t))
|
|
1618
1618
|
return !0;
|
|
1619
1619
|
return !1;
|
|
1620
1620
|
}
|
|
1621
|
-
function
|
|
1621
|
+
function we(e) {
|
|
1622
1622
|
if (e.length === 0)
|
|
1623
1623
|
return !1;
|
|
1624
1624
|
for (const t of e)
|
|
1625
|
-
if (!(
|
|
1625
|
+
if (!(nt.test(t) || c0.has(t)))
|
|
1626
1626
|
return !1;
|
|
1627
1627
|
return !0;
|
|
1628
1628
|
}
|
|
1629
|
-
function
|
|
1630
|
-
const t = [], n = [], i = [],
|
|
1629
|
+
function f0(e) {
|
|
1630
|
+
const t = [], n = [], i = [], r = [];
|
|
1631
1631
|
for (let s = 0; s < e.len; s++) {
|
|
1632
|
-
const l = e.texts[s],
|
|
1633
|
-
if (
|
|
1632
|
+
const l = e.texts[s], u = e.kinds[s];
|
|
1633
|
+
if (u === "text" && we(l) && Ut(l)) {
|
|
1634
1634
|
const o = [l];
|
|
1635
|
-
let
|
|
1636
|
-
for (;
|
|
1637
|
-
o.push(e.texts[
|
|
1638
|
-
t.push(
|
|
1635
|
+
let x = s + 1;
|
|
1636
|
+
for (; x < e.len && e.kinds[x] === "text" && we(e.texts[x]); )
|
|
1637
|
+
o.push(e.texts[x]), x++;
|
|
1638
|
+
t.push(re(o)), n.push(!0), i.push("text"), r.push(e.starts[s]), s = x - 1;
|
|
1639
1639
|
continue;
|
|
1640
1640
|
}
|
|
1641
|
-
t.push(l), n.push(e.isWordLike[s]), i.push(
|
|
1641
|
+
t.push(l), n.push(e.isWordLike[s]), i.push(u), r.push(e.starts[s]);
|
|
1642
1642
|
}
|
|
1643
1643
|
return {
|
|
1644
1644
|
len: t.length,
|
|
1645
1645
|
texts: t,
|
|
1646
1646
|
isWordLike: n,
|
|
1647
1647
|
kinds: i,
|
|
1648
|
-
starts:
|
|
1648
|
+
starts: r
|
|
1649
1649
|
};
|
|
1650
1650
|
}
|
|
1651
|
-
function
|
|
1652
|
-
const t = [], n = [], i = [],
|
|
1651
|
+
function h0(e) {
|
|
1652
|
+
const t = [], n = [], i = [], r = [];
|
|
1653
1653
|
for (let s = 0; s < e.len; s++) {
|
|
1654
|
-
const l = e.texts[s],
|
|
1655
|
-
if (
|
|
1656
|
-
const
|
|
1654
|
+
const l = e.texts[s], u = e.kinds[s], o = e.isWordLike[s];
|
|
1655
|
+
if (u === "text" && Ct(l) && (o || $n(l)) && !oe(l)) {
|
|
1656
|
+
const x = [l];
|
|
1657
1657
|
let c = !0, a = s + 1;
|
|
1658
|
-
for (; c && a < e.len && e.kinds[a] === "text" &&
|
|
1659
|
-
const
|
|
1660
|
-
|
|
1658
|
+
for (; c && a < e.len && e.kinds[a] === "text" && u0(e.texts[a], e.isWordLike[a]); ) {
|
|
1659
|
+
const f = e.texts[a];
|
|
1660
|
+
x.push(f), c = Ct(f), a++;
|
|
1661
1661
|
}
|
|
1662
|
-
t.push(
|
|
1662
|
+
t.push(re(x)), n.push(!0), i.push("text"), r.push(e.starts[s]), s = a - 1;
|
|
1663
1663
|
continue;
|
|
1664
1664
|
}
|
|
1665
|
-
t.push(l), n.push(o), i.push(
|
|
1665
|
+
t.push(l), n.push(o), i.push(u), r.push(e.starts[s]);
|
|
1666
1666
|
}
|
|
1667
1667
|
return {
|
|
1668
1668
|
len: t.length,
|
|
1669
1669
|
texts: t,
|
|
1670
1670
|
isWordLike: n,
|
|
1671
1671
|
kinds: i,
|
|
1672
|
-
starts:
|
|
1672
|
+
starts: r
|
|
1673
1673
|
};
|
|
1674
1674
|
}
|
|
1675
|
-
function
|
|
1676
|
-
const t = [], n = [], i = [],
|
|
1675
|
+
function d0(e) {
|
|
1676
|
+
const t = [], n = [], i = [], r = [];
|
|
1677
1677
|
for (let s = 0; s < e.len; s++) {
|
|
1678
1678
|
const l = e.texts[s];
|
|
1679
1679
|
if (e.kinds[s] === "text" && l.includes("-")) {
|
|
1680
|
-
const
|
|
1681
|
-
let o =
|
|
1682
|
-
for (let
|
|
1683
|
-
const c =
|
|
1680
|
+
const u = l.split("-");
|
|
1681
|
+
let o = u.length > 1;
|
|
1682
|
+
for (let x = 0; x < u.length; x++) {
|
|
1683
|
+
const c = u[x];
|
|
1684
1684
|
if (!o)
|
|
1685
1685
|
break;
|
|
1686
|
-
(c.length === 0 || !
|
|
1686
|
+
(c.length === 0 || !Ut(c) || !we(c)) && (o = !1);
|
|
1687
1687
|
}
|
|
1688
1688
|
if (o) {
|
|
1689
|
-
let
|
|
1690
|
-
for (let c = 0; c <
|
|
1691
|
-
const a =
|
|
1692
|
-
t.push(
|
|
1689
|
+
let x = 0;
|
|
1690
|
+
for (let c = 0; c < u.length; c++) {
|
|
1691
|
+
const a = u[c], f = c < u.length - 1 ? `${a}-` : a;
|
|
1692
|
+
t.push(f), n.push(!0), i.push("text"), r.push(e.starts[s] + x), x += f.length;
|
|
1693
1693
|
}
|
|
1694
1694
|
continue;
|
|
1695
1695
|
}
|
|
1696
1696
|
}
|
|
1697
|
-
t.push(l), n.push(e.isWordLike[s]), i.push(e.kinds[s]),
|
|
1697
|
+
t.push(l), n.push(e.isWordLike[s]), i.push(e.kinds[s]), r.push(e.starts[s]);
|
|
1698
1698
|
}
|
|
1699
1699
|
return {
|
|
1700
1700
|
len: t.length,
|
|
1701
1701
|
texts: t,
|
|
1702
1702
|
isWordLike: n,
|
|
1703
1703
|
kinds: i,
|
|
1704
|
-
starts:
|
|
1704
|
+
starts: r
|
|
1705
1705
|
};
|
|
1706
1706
|
}
|
|
1707
|
-
function
|
|
1708
|
-
const t = [], n = [], i = [],
|
|
1707
|
+
function F0(e) {
|
|
1708
|
+
const t = [], n = [], i = [], r = [];
|
|
1709
1709
|
let s = 0;
|
|
1710
1710
|
for (; s < e.len; ) {
|
|
1711
1711
|
const l = [e.texts[s]];
|
|
1712
|
-
let
|
|
1712
|
+
let u = e.isWordLike[s], o = e.kinds[s], x = e.starts[s];
|
|
1713
1713
|
if (o === "glue") {
|
|
1714
|
-
const c = [l[0]], a =
|
|
1714
|
+
const c = [l[0]], a = x;
|
|
1715
1715
|
for (s++; s < e.len && e.kinds[s] === "glue"; )
|
|
1716
1716
|
c.push(e.texts[s]), s++;
|
|
1717
|
-
const
|
|
1717
|
+
const f = re(c);
|
|
1718
1718
|
if (s < e.len && e.kinds[s] === "text")
|
|
1719
|
-
l[0] =
|
|
1719
|
+
l[0] = f, l.push(e.texts[s]), u = e.isWordLike[s], o = "text", x = a, s++;
|
|
1720
1720
|
else {
|
|
1721
|
-
t.push(
|
|
1721
|
+
t.push(f), n.push(!1), i.push("glue"), r.push(a);
|
|
1722
1722
|
continue;
|
|
1723
1723
|
}
|
|
1724
1724
|
} else
|
|
@@ -1728,99 +1728,99 @@ function d0(e) {
|
|
|
1728
1728
|
const c = [];
|
|
1729
1729
|
for (; s < e.len && e.kinds[s] === "glue"; )
|
|
1730
1730
|
c.push(e.texts[s]), s++;
|
|
1731
|
-
const a =
|
|
1731
|
+
const a = re(c);
|
|
1732
1732
|
if (s < e.len && e.kinds[s] === "text") {
|
|
1733
|
-
l.push(a, e.texts[s]),
|
|
1733
|
+
l.push(a, e.texts[s]), u = u || e.isWordLike[s], s++;
|
|
1734
1734
|
continue;
|
|
1735
1735
|
}
|
|
1736
1736
|
l.push(a);
|
|
1737
1737
|
}
|
|
1738
|
-
t.push(
|
|
1738
|
+
t.push(re(l)), n.push(u), i.push(o), r.push(x);
|
|
1739
1739
|
}
|
|
1740
1740
|
return {
|
|
1741
1741
|
len: t.length,
|
|
1742
1742
|
texts: t,
|
|
1743
1743
|
isWordLike: n,
|
|
1744
1744
|
kinds: i,
|
|
1745
|
-
starts:
|
|
1745
|
+
starts: r
|
|
1746
1746
|
};
|
|
1747
1747
|
}
|
|
1748
|
-
function
|
|
1749
|
-
const t = e.texts.slice(), n = e.isWordLike.slice(), i = e.kinds.slice(),
|
|
1748
|
+
function g0(e) {
|
|
1749
|
+
const t = e.texts.slice(), n = e.isWordLike.slice(), i = e.kinds.slice(), r = e.starts.slice();
|
|
1750
1750
|
for (let s = 0; s < t.length - 1; s++) {
|
|
1751
1751
|
if (i[s] !== "text" || i[s + 1] !== "text" || !oe(t[s]) || !oe(t[s + 1]))
|
|
1752
1752
|
continue;
|
|
1753
|
-
const l =
|
|
1754
|
-
l !== null && (t[s] = l.head, t[s + 1] = l.tail + t[s + 1],
|
|
1753
|
+
const l = Xn(t[s]);
|
|
1754
|
+
l !== null && (t[s] = l.head, t[s + 1] = l.tail + t[s + 1], r[s + 1] = r[s] + l.head.length);
|
|
1755
1755
|
}
|
|
1756
1756
|
return {
|
|
1757
1757
|
len: t.length,
|
|
1758
1758
|
texts: t,
|
|
1759
1759
|
isWordLike: n,
|
|
1760
1760
|
kinds: i,
|
|
1761
|
-
starts:
|
|
1761
|
+
starts: r
|
|
1762
1762
|
};
|
|
1763
1763
|
}
|
|
1764
|
-
function
|
|
1765
|
-
const i =
|
|
1766
|
-
let
|
|
1767
|
-
const s = [], l = [],
|
|
1764
|
+
function N0(e, t, n) {
|
|
1765
|
+
const i = In();
|
|
1766
|
+
let r = 0;
|
|
1767
|
+
const s = [], l = [], u = [], o = [], x = [], c = [], a = [], f = [], d = [], S = [], A = [], m = [];
|
|
1768
1768
|
for (const N of i.segment(e))
|
|
1769
|
-
for (const D of
|
|
1769
|
+
for (const D of s0(N.segment, N.isWordLike ?? !1, N.index, n)) {
|
|
1770
1770
|
let y = function() {
|
|
1771
|
-
c[
|
|
1772
|
-
|
|
1773
|
-
], c[
|
|
1771
|
+
c[p] !== null && (l[p] = [
|
|
1772
|
+
Bt(s, c, a, p)
|
|
1773
|
+
], c[p] = null), l[p].push(D.text), u[p] = u[p] || D.isWordLike, f[p] = f[p] || P, d[p] = d[p] || W, S[p] = z, A[p] = C, m[p] = Mt(d[p], H);
|
|
1774
1774
|
};
|
|
1775
|
-
const E = D.kind === "text", T =
|
|
1776
|
-
t.carryCJKAfterClosingQuote && E &&
|
|
1775
|
+
const E = D.kind === "text", T = qn(D.text, D.isWordLike, D.kind), P = oe(D.text), W = At(D.text), H = Le(D.text), z = Ye(D.text), C = Vn(D.text), p = r - 1;
|
|
1776
|
+
t.carryCJKAfterClosingQuote && E && r > 0 && o[p] === "text" && P && f[p] && S[p] || E && r > 0 && o[p] === "text" && zn(D.text) && f[p] || E && r > 0 && o[p] === "text" && A[p] ? y() : E && r > 0 && o[p] === "text" && D.isWordLike && W && m[p] ? (y(), u[p] = !0) : T !== null && r > 0 && o[p] === "text" && c[p] === T ? a[p] = (a[p] ?? 1) + 1 : E && !D.isWordLike && r > 0 && o[p] === "text" && !f[p] && (_n(D.text) || D.text === "-" && u[p]) ? y() : (s[r] = D.text, l[r] = [D.text], u[r] = D.isWordLike, o[r] = D.kind, x[r] = D.start, c[r] = T, a[r] = T === null ? 0 : 1, f[r] = P, d[r] = W, S[r] = z, A[r] = C, m[r] = Mt(W, H), r++);
|
|
1777
1777
|
}
|
|
1778
|
-
for (let N = 0; N <
|
|
1778
|
+
for (let N = 0; N < r; N++) {
|
|
1779
1779
|
if (c[N] !== null) {
|
|
1780
|
-
s[N] =
|
|
1780
|
+
s[N] = Bt(s, c, a, N);
|
|
1781
1781
|
continue;
|
|
1782
1782
|
}
|
|
1783
|
-
s[N] =
|
|
1783
|
+
s[N] = re(l[N]);
|
|
1784
1784
|
}
|
|
1785
|
-
for (let N = 1; N <
|
|
1786
|
-
o[N] === "text" && !
|
|
1787
|
-
const M = Array.from({ length:
|
|
1785
|
+
for (let N = 1; N < r; N++)
|
|
1786
|
+
o[N] === "text" && !u[N] && rt(s[N]) && o[N - 1] === "text" && !f[N - 1] && (s[N - 1] += s[N], u[N - 1] = u[N - 1] || u[N], s[N] = "");
|
|
1787
|
+
const M = Array.from({ length: r }, () => null);
|
|
1788
1788
|
let v = -1;
|
|
1789
|
-
for (let N =
|
|
1789
|
+
for (let N = r - 1; N >= 0; N--) {
|
|
1790
1790
|
const D = s[N];
|
|
1791
1791
|
if (D.length !== 0) {
|
|
1792
|
-
if (o[N] === "text" && !
|
|
1792
|
+
if (o[N] === "text" && !u[N] && v >= 0 && o[v] === "text" && (jn(D) || D === "-" && Yn(s[v]))) {
|
|
1793
1793
|
const E = M[v] ?? [];
|
|
1794
|
-
E.push(D), M[v] = E,
|
|
1794
|
+
E.push(D), M[v] = E, x[v] = x[N], s[N] = "";
|
|
1795
1795
|
continue;
|
|
1796
1796
|
}
|
|
1797
1797
|
v = N;
|
|
1798
1798
|
}
|
|
1799
1799
|
}
|
|
1800
|
-
for (let N = 0; N <
|
|
1800
|
+
for (let N = 0; N < r; N++) {
|
|
1801
1801
|
const D = M[N];
|
|
1802
|
-
D != null && (s[N] =
|
|
1802
|
+
D != null && (s[N] = n0(D, s[N]));
|
|
1803
1803
|
}
|
|
1804
1804
|
let L = 0;
|
|
1805
|
-
for (let N = 0; N <
|
|
1805
|
+
for (let N = 0; N < r; N++) {
|
|
1806
1806
|
const D = s[N];
|
|
1807
|
-
D.length !== 0 && (L !== N && (s[L] = D,
|
|
1807
|
+
D.length !== 0 && (L !== N && (s[L] = D, u[L] = u[N], o[L] = o[N], x[L] = x[N]), L++);
|
|
1808
1808
|
}
|
|
1809
|
-
s.length = L,
|
|
1810
|
-
const w =
|
|
1809
|
+
s.length = L, u.length = L, o.length = L, x.length = L;
|
|
1810
|
+
const w = F0({
|
|
1811
1811
|
len: L,
|
|
1812
1812
|
texts: s,
|
|
1813
|
-
isWordLike:
|
|
1813
|
+
isWordLike: u,
|
|
1814
1814
|
kinds: o,
|
|
1815
|
-
starts:
|
|
1816
|
-
}), R =
|
|
1815
|
+
starts: x
|
|
1816
|
+
}), R = g0(h0(d0(f0(l0(o0(w))))));
|
|
1817
1817
|
for (let N = 0; N < R.len - 1; N++) {
|
|
1818
|
-
const D =
|
|
1819
|
-
D !== null && (R.kinds[N] !== "space" && R.kinds[N] !== "preserved-space" || R.kinds[N + 1] !== "text" || !
|
|
1818
|
+
const D = Zn(R.texts[N]);
|
|
1819
|
+
D !== null && (R.kinds[N] !== "space" && R.kinds[N] !== "preserved-space" || R.kinds[N + 1] !== "text" || !At(R.texts[N + 1]) || (R.texts[N] = D.space, R.isWordLike[N] = !1, R.kinds[N] = R.kinds[N] === "preserved-space" ? "preserved-space" : "space", R.texts[N + 1] = D.marks + R.texts[N + 1], R.starts[N + 1] = R.starts[N] + D.space.length));
|
|
1820
1820
|
}
|
|
1821
1821
|
return R;
|
|
1822
1822
|
}
|
|
1823
|
-
function
|
|
1823
|
+
function S0(e, t) {
|
|
1824
1824
|
if (e.len === 0)
|
|
1825
1825
|
return [];
|
|
1826
1826
|
if (!t.preserveHardBreaks)
|
|
@@ -1831,61 +1831,61 @@ function N0(e, t) {
|
|
|
1831
1831
|
}];
|
|
1832
1832
|
const n = [];
|
|
1833
1833
|
let i = 0;
|
|
1834
|
-
for (let
|
|
1835
|
-
e.kinds[
|
|
1834
|
+
for (let r = 0; r < e.len; r++)
|
|
1835
|
+
e.kinds[r] === "hard-break" && (n.push({
|
|
1836
1836
|
startSegmentIndex: i,
|
|
1837
|
-
endSegmentIndex:
|
|
1838
|
-
consumedEndSegmentIndex:
|
|
1839
|
-
}), i =
|
|
1837
|
+
endSegmentIndex: r,
|
|
1838
|
+
consumedEndSegmentIndex: r + 1
|
|
1839
|
+
}), i = r + 1);
|
|
1840
1840
|
return i < e.len && n.push({
|
|
1841
1841
|
startSegmentIndex: i,
|
|
1842
1842
|
endSegmentIndex: e.len,
|
|
1843
1843
|
consumedEndSegmentIndex: e.len
|
|
1844
1844
|
}), n;
|
|
1845
1845
|
}
|
|
1846
|
-
function
|
|
1846
|
+
function p0(e, t, n) {
|
|
1847
1847
|
if (t.len <= 1)
|
|
1848
1848
|
return t;
|
|
1849
|
-
const i = [],
|
|
1850
|
-
let
|
|
1851
|
-
function
|
|
1852
|
-
i.push(t.texts[
|
|
1849
|
+
const i = [], r = [], s = [], l = [];
|
|
1850
|
+
let u = -1, o = !1;
|
|
1851
|
+
function x(f) {
|
|
1852
|
+
i.push(t.texts[f]), r.push(t.isWordLike[f]), s.push("text"), l.push(t.starts[f]);
|
|
1853
1853
|
}
|
|
1854
|
-
function c(
|
|
1854
|
+
function c(f, d) {
|
|
1855
1855
|
let S = !1;
|
|
1856
|
-
for (let M =
|
|
1856
|
+
for (let M = f; M < d; M++)
|
|
1857
1857
|
S = S || t.isWordLike[M];
|
|
1858
|
-
const
|
|
1859
|
-
i.push(e.slice(
|
|
1858
|
+
const A = t.starts[f], m = d < t.len ? t.starts[d] : e.length;
|
|
1859
|
+
i.push(e.slice(A, m)), r.push(S), s.push("text"), l.push(A);
|
|
1860
1860
|
}
|
|
1861
|
-
function a(
|
|
1862
|
-
if (!(
|
|
1861
|
+
function a(f) {
|
|
1862
|
+
if (!(u < 0)) {
|
|
1863
1863
|
if (o)
|
|
1864
|
-
|
|
1864
|
+
u + 1 === f ? x(u) : c(u, f);
|
|
1865
1865
|
else
|
|
1866
|
-
for (let d =
|
|
1867
|
-
|
|
1868
|
-
|
|
1866
|
+
for (let d = u; d < f; d++)
|
|
1867
|
+
x(d);
|
|
1868
|
+
u = -1, o = !1;
|
|
1869
1869
|
}
|
|
1870
1870
|
}
|
|
1871
|
-
for (let
|
|
1872
|
-
const d = t.texts[
|
|
1871
|
+
for (let f = 0; f < t.len; f++) {
|
|
1872
|
+
const d = t.texts[f], S = t.kinds[f];
|
|
1873
1873
|
if (S === "text") {
|
|
1874
|
-
|
|
1874
|
+
u >= 0 && !Kt(t.texts[f - 1], n) && a(f), u < 0 && (u = f), o = o || oe(d);
|
|
1875
1875
|
continue;
|
|
1876
1876
|
}
|
|
1877
|
-
a(
|
|
1877
|
+
a(f), i.push(d), r.push(t.isWordLike[f]), s.push(S), l.push(t.starts[f]);
|
|
1878
1878
|
}
|
|
1879
1879
|
return a(t.len), {
|
|
1880
1880
|
len: i.length,
|
|
1881
1881
|
texts: i,
|
|
1882
|
-
isWordLike:
|
|
1882
|
+
isWordLike: r,
|
|
1883
1883
|
kinds: s,
|
|
1884
1884
|
starts: l
|
|
1885
1885
|
};
|
|
1886
1886
|
}
|
|
1887
|
-
function
|
|
1888
|
-
const
|
|
1887
|
+
function m0(e, t, n = "normal", i = "normal") {
|
|
1888
|
+
const r = Dn(n), s = r.mode === "pre-wrap" ? On(e) : Ln(e);
|
|
1889
1889
|
if (s.length === 0)
|
|
1890
1890
|
return {
|
|
1891
1891
|
normalized: s,
|
|
@@ -1896,19 +1896,19 @@ function p0(e, t, n = "normal", i = "normal") {
|
|
|
1896
1896
|
kinds: [],
|
|
1897
1897
|
starts: []
|
|
1898
1898
|
};
|
|
1899
|
-
const l =
|
|
1899
|
+
const l = N0(s, t, r), u = i === "keep-all" ? p0(s, l, t.breakKeepAllAfterPunctuation) : l;
|
|
1900
1900
|
return {
|
|
1901
1901
|
normalized: s,
|
|
1902
|
-
chunks:
|
|
1903
|
-
...
|
|
1902
|
+
chunks: S0(u, r),
|
|
1903
|
+
...u
|
|
1904
1904
|
};
|
|
1905
1905
|
}
|
|
1906
1906
|
let Ae = null;
|
|
1907
|
-
const
|
|
1907
|
+
const kt = /* @__PURE__ */ new Map();
|
|
1908
1908
|
let Ee = null;
|
|
1909
|
-
const
|
|
1909
|
+
const A0 = 96, E0 = /\p{Emoji_Presentation}/u, B0 = /[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;
|
|
1910
1910
|
let Ke = null;
|
|
1911
|
-
const
|
|
1911
|
+
const Dt = /* @__PURE__ */ new Map();
|
|
1912
1912
|
function xt() {
|
|
1913
1913
|
if (Ae !== null)
|
|
1914
1914
|
return Ae;
|
|
@@ -1918,9 +1918,9 @@ function xt() {
|
|
|
1918
1918
|
return Ae = document.createElement("canvas").getContext("2d"), Ae;
|
|
1919
1919
|
throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.");
|
|
1920
1920
|
}
|
|
1921
|
-
function
|
|
1922
|
-
let t =
|
|
1923
|
-
return t || (t = /* @__PURE__ */ new Map(),
|
|
1921
|
+
function M0(e) {
|
|
1922
|
+
let t = kt.get(e);
|
|
1923
|
+
return t || (t = /* @__PURE__ */ new Map(), kt.set(e, t)), t;
|
|
1924
1924
|
}
|
|
1925
1925
|
function ue(e, t) {
|
|
1926
1926
|
let n = t.get(e);
|
|
@@ -1949,146 +1949,146 @@ function Be() {
|
|
|
1949
1949
|
preferEarlySoftHyphenBreak: n
|
|
1950
1950
|
}, Ee;
|
|
1951
1951
|
}
|
|
1952
|
-
function
|
|
1952
|
+
function C0(e) {
|
|
1953
1953
|
const t = e.match(/(\d+(?:\.\d+)?)\s*px/);
|
|
1954
1954
|
return t ? parseFloat(t[1]) : 16;
|
|
1955
1955
|
}
|
|
1956
|
-
function
|
|
1956
|
+
function Jt() {
|
|
1957
1957
|
return Ke === null && (Ke = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Ke;
|
|
1958
1958
|
}
|
|
1959
|
-
function C0(e) {
|
|
1960
|
-
return A0.test(e) || e.includes("️");
|
|
1961
|
-
}
|
|
1962
1959
|
function k0(e) {
|
|
1963
|
-
return E0.test(e);
|
|
1960
|
+
return E0.test(e) || e.includes("️");
|
|
1964
1961
|
}
|
|
1965
|
-
function D0(e
|
|
1966
|
-
|
|
1962
|
+
function D0(e) {
|
|
1963
|
+
return B0.test(e);
|
|
1964
|
+
}
|
|
1965
|
+
function L0(e, t) {
|
|
1966
|
+
let n = Dt.get(e);
|
|
1967
1967
|
if (n !== void 0)
|
|
1968
1968
|
return n;
|
|
1969
1969
|
const i = xt();
|
|
1970
1970
|
i.font = e;
|
|
1971
|
-
const
|
|
1972
|
-
if (n = 0,
|
|
1971
|
+
const r = i.measureText("😀").width;
|
|
1972
|
+
if (n = 0, r > t + 0.5 && typeof document < "u" && document.body !== null) {
|
|
1973
1973
|
const s = document.createElement("span");
|
|
1974
1974
|
s.style.font = e, s.style.display = "inline-block", s.style.visibility = "hidden", s.style.position = "absolute", s.textContent = "😀", document.body.appendChild(s);
|
|
1975
1975
|
const l = s.getBoundingClientRect().width;
|
|
1976
|
-
document.body.removeChild(s),
|
|
1976
|
+
document.body.removeChild(s), r - l > 0.5 && (n = r - l);
|
|
1977
1977
|
}
|
|
1978
|
-
return
|
|
1978
|
+
return Dt.set(e, n), n;
|
|
1979
1979
|
}
|
|
1980
|
-
function
|
|
1980
|
+
function O0(e) {
|
|
1981
1981
|
let t = 0;
|
|
1982
|
-
const n =
|
|
1982
|
+
const n = Jt();
|
|
1983
1983
|
for (const i of n.segment(e))
|
|
1984
|
-
|
|
1984
|
+
k0(i.segment) && t++;
|
|
1985
1985
|
return t;
|
|
1986
1986
|
}
|
|
1987
|
-
function
|
|
1988
|
-
return t.emojiCount === void 0 && (t.emojiCount =
|
|
1987
|
+
function b0(e, t) {
|
|
1988
|
+
return t.emojiCount === void 0 && (t.emojiCount = O0(e)), t.emojiCount;
|
|
1989
1989
|
}
|
|
1990
|
-
function
|
|
1991
|
-
return n === 0 ? t.width : t.width -
|
|
1990
|
+
function Fe(e, t, n) {
|
|
1991
|
+
return n === 0 ? t.width : t.width - b0(e, t) * n;
|
|
1992
1992
|
}
|
|
1993
|
-
function
|
|
1994
|
-
if (t.breakableFitAdvances !== void 0 && t.breakableFitMode ===
|
|
1993
|
+
function I0(e, t, n, i, r) {
|
|
1994
|
+
if (t.breakableFitAdvances !== void 0 && t.breakableFitMode === r)
|
|
1995
1995
|
return t.breakableFitAdvances;
|
|
1996
|
-
t.breakableFitMode =
|
|
1997
|
-
const s =
|
|
1996
|
+
t.breakableFitMode = r;
|
|
1997
|
+
const s = Jt(), l = [];
|
|
1998
1998
|
for (const c of s.segment(e))
|
|
1999
1999
|
l.push(c.segment);
|
|
2000
2000
|
if (l.length <= 1)
|
|
2001
2001
|
return t.breakableFitAdvances = null, t.breakableFitAdvances;
|
|
2002
|
-
if (
|
|
2002
|
+
if (r === "sum-graphemes") {
|
|
2003
2003
|
const c = [];
|
|
2004
2004
|
for (const a of l) {
|
|
2005
|
-
const
|
|
2006
|
-
c.push(
|
|
2005
|
+
const f = ue(a, n);
|
|
2006
|
+
c.push(Fe(a, f, i));
|
|
2007
2007
|
}
|
|
2008
2008
|
return t.breakableFitAdvances = c, t.breakableFitAdvances;
|
|
2009
2009
|
}
|
|
2010
|
-
if (
|
|
2010
|
+
if (r === "pair-context" || l.length > A0) {
|
|
2011
2011
|
const c = [];
|
|
2012
|
-
let a = null,
|
|
2012
|
+
let a = null, f = 0;
|
|
2013
2013
|
for (const d of l) {
|
|
2014
|
-
const S = ue(d, n),
|
|
2014
|
+
const S = ue(d, n), A = Fe(d, S, i);
|
|
2015
2015
|
if (a === null)
|
|
2016
|
-
c.push(
|
|
2016
|
+
c.push(A);
|
|
2017
2017
|
else {
|
|
2018
|
-
const
|
|
2019
|
-
c.push(
|
|
2018
|
+
const m = a + d, M = ue(m, n);
|
|
2019
|
+
c.push(Fe(m, M, i) - f);
|
|
2020
2020
|
}
|
|
2021
|
-
a = d,
|
|
2021
|
+
a = d, f = A;
|
|
2022
2022
|
}
|
|
2023
2023
|
return t.breakableFitAdvances = c, t.breakableFitAdvances;
|
|
2024
2024
|
}
|
|
2025
|
-
const
|
|
2026
|
-
let o = "",
|
|
2025
|
+
const u = [];
|
|
2026
|
+
let o = "", x = 0;
|
|
2027
2027
|
for (const c of l) {
|
|
2028
2028
|
o += c;
|
|
2029
|
-
const a = ue(o, n),
|
|
2030
|
-
|
|
2029
|
+
const a = ue(o, n), f = Fe(o, a, i);
|
|
2030
|
+
u.push(f - x), x = f;
|
|
2031
2031
|
}
|
|
2032
|
-
return t.breakableFitAdvances =
|
|
2032
|
+
return t.breakableFitAdvances = u, t.breakableFitAdvances;
|
|
2033
2033
|
}
|
|
2034
|
-
function
|
|
2034
|
+
function y0(e, t) {
|
|
2035
2035
|
const n = xt();
|
|
2036
2036
|
n.font = e;
|
|
2037
|
-
const i =
|
|
2038
|
-
return { cache: i, fontSize:
|
|
2037
|
+
const i = M0(e), r = C0(e), s = t ? L0(e, r) : 0;
|
|
2038
|
+
return { cache: i, fontSize: r, emojiCorrection: s };
|
|
2039
2039
|
}
|
|
2040
|
-
function
|
|
2040
|
+
function w0(e) {
|
|
2041
2041
|
return e === "space" || e === "zero-width-break" || e === "soft-hyphen";
|
|
2042
2042
|
}
|
|
2043
|
-
function
|
|
2043
|
+
function Ge(e) {
|
|
2044
2044
|
return e === "space" || e === "preserved-space" || e === "tab" || e === "zero-width-break" || e === "soft-hyphen";
|
|
2045
2045
|
}
|
|
2046
|
-
function
|
|
2046
|
+
function ot(e, t, n = e.widths.length) {
|
|
2047
2047
|
for (; t < n; ) {
|
|
2048
2048
|
const i = e.kinds[t];
|
|
2049
|
-
if (!
|
|
2049
|
+
if (!w0(i))
|
|
2050
2050
|
break;
|
|
2051
2051
|
t++;
|
|
2052
2052
|
}
|
|
2053
2053
|
return t;
|
|
2054
2054
|
}
|
|
2055
|
-
function
|
|
2055
|
+
function Qt(e, t) {
|
|
2056
2056
|
if (t <= 0)
|
|
2057
2057
|
return 0;
|
|
2058
2058
|
const n = e % t;
|
|
2059
2059
|
return Math.abs(n) <= 1e-6 ? t : t - n;
|
|
2060
2060
|
}
|
|
2061
|
-
function
|
|
2061
|
+
function $t(e, t, n) {
|
|
2062
2062
|
return e.letterSpacing !== 0 && t && e.spacingGraphemeCounts[n] > 0 ? e.letterSpacing : 0;
|
|
2063
2063
|
}
|
|
2064
|
-
function
|
|
2064
|
+
function lt(e, t) {
|
|
2065
2065
|
return t === 0 ? 0 : e + t;
|
|
2066
2066
|
}
|
|
2067
|
-
function
|
|
2067
|
+
function P0(e, t) {
|
|
2068
2068
|
return e.letterSpacing !== 0 && e.spacingGraphemeCounts[t] > 0 ? e.letterSpacing : 0;
|
|
2069
2069
|
}
|
|
2070
|
-
function
|
|
2071
|
-
const s = t === "tab" ?
|
|
2072
|
-
return
|
|
2070
|
+
function Yt(e, t, n, i, r) {
|
|
2071
|
+
const s = t === "tab" ? r + P0(e, n) : e.lineEndFitAdvances[n];
|
|
2072
|
+
return lt(i, s);
|
|
2073
2073
|
}
|
|
2074
|
-
function
|
|
2075
|
-
const
|
|
2076
|
-
return
|
|
2074
|
+
function Pe(e, t, n, i) {
|
|
2075
|
+
const r = t === "tab" ? 0 : e.lineEndFitAdvances[n];
|
|
2076
|
+
return lt(i, r);
|
|
2077
2077
|
}
|
|
2078
|
-
function
|
|
2079
|
-
const s = t === "tab" ?
|
|
2080
|
-
return
|
|
2078
|
+
function We(e, t, n, i, r) {
|
|
2079
|
+
const s = t === "tab" ? r : e.lineEndPaintAdvances[n];
|
|
2080
|
+
return lt(i, s);
|
|
2081
2081
|
}
|
|
2082
|
-
function
|
|
2082
|
+
function Xt(e, t, n) {
|
|
2083
2083
|
return e.letterSpacing !== 0 && t ? n + e.letterSpacing : n;
|
|
2084
2084
|
}
|
|
2085
|
-
function
|
|
2085
|
+
function qt(e, t) {
|
|
2086
2086
|
return e.letterSpacing === 0 ? t : t + e.letterSpacing;
|
|
2087
2087
|
}
|
|
2088
|
-
function
|
|
2088
|
+
function W0(e, t, n, i, r) {
|
|
2089
2089
|
if (e.letterSpacing === 0)
|
|
2090
2090
|
return 0;
|
|
2091
|
-
if (
|
|
2091
|
+
if (r > 0)
|
|
2092
2092
|
return e.spacingGraphemeCounts[i] > 0 ? e.letterSpacing : 0;
|
|
2093
2093
|
for (let s = i - 1; s >= t; s--) {
|
|
2094
2094
|
const l = e.kinds[s];
|
|
@@ -2103,68 +2103,68 @@ function P0(e, t, n, i, x) {
|
|
|
2103
2103
|
}
|
|
2104
2104
|
return 0;
|
|
2105
2105
|
}
|
|
2106
|
-
function
|
|
2107
|
-
return t +
|
|
2106
|
+
function Vt(e, t, n, i, r, s) {
|
|
2107
|
+
return t + W0(e, n, i, r, s);
|
|
2108
2108
|
}
|
|
2109
|
-
function
|
|
2109
|
+
function v0(e, t) {
|
|
2110
2110
|
let n = 0, i = e.chunks.length;
|
|
2111
2111
|
for (; n < i; ) {
|
|
2112
|
-
const
|
|
2113
|
-
t < e.chunks[
|
|
2112
|
+
const r = Math.floor((n + i) / 2);
|
|
2113
|
+
t < e.chunks[r].consumedEndSegmentIndex ? i = r : n = r + 1;
|
|
2114
2114
|
}
|
|
2115
2115
|
return n < e.chunks.length ? n : -1;
|
|
2116
2116
|
}
|
|
2117
|
-
function
|
|
2117
|
+
function R0(e, t, n) {
|
|
2118
2118
|
let i = n.segmentIndex;
|
|
2119
2119
|
if (n.graphemeIndex > 0)
|
|
2120
2120
|
return t;
|
|
2121
|
-
const
|
|
2122
|
-
return
|
|
2121
|
+
const r = e.chunks[t];
|
|
2122
|
+
return r.startSegmentIndex === r.endSegmentIndex && i === r.startSegmentIndex || (i < r.startSegmentIndex && (i = r.startSegmentIndex), i = ot(e, i, r.endSegmentIndex), i < r.endSegmentIndex) ? (n.segmentIndex = i, n.graphemeIndex = 0, t) : r.consumedEndSegmentIndex >= e.widths.length ? -1 : (n.segmentIndex = r.consumedEndSegmentIndex, n.graphemeIndex = 0, t + 1);
|
|
2123
2123
|
}
|
|
2124
|
-
function
|
|
2124
|
+
function T0(e, t) {
|
|
2125
2125
|
if (t.segmentIndex >= e.widths.length)
|
|
2126
2126
|
return -1;
|
|
2127
|
-
const n =
|
|
2128
|
-
return n < 0 ? -1 :
|
|
2127
|
+
const n = v0(e, t.segmentIndex);
|
|
2128
|
+
return n < 0 ? -1 : R0(e, n, t);
|
|
2129
2129
|
}
|
|
2130
|
-
function
|
|
2131
|
-
const { widths: i, kinds:
|
|
2130
|
+
function G0(e, t, n) {
|
|
2131
|
+
const { widths: i, kinds: r, breakableFitAdvances: s } = e;
|
|
2132
2132
|
if (i.length === 0)
|
|
2133
2133
|
return 0;
|
|
2134
|
-
const
|
|
2135
|
-
let
|
|
2134
|
+
const u = Be().lineFitEpsilon, o = t + u;
|
|
2135
|
+
let x = 0, c = 0, a = !1, f = 0, d = 0, S = 0, A = 0, m = -1, M = 0;
|
|
2136
2136
|
function v() {
|
|
2137
|
-
|
|
2137
|
+
m = -1, M = 0;
|
|
2138
2138
|
}
|
|
2139
|
-
function L(T = S, P =
|
|
2140
|
-
|
|
2139
|
+
function L(T = S, P = A, W = c) {
|
|
2140
|
+
x++, n?.(W, f, d, T, P), c = 0, a = !1, v();
|
|
2141
2141
|
}
|
|
2142
2142
|
function w(T, P) {
|
|
2143
|
-
a = !0,
|
|
2143
|
+
a = !0, f = T, d = 0, S = T + 1, A = 0, c = P;
|
|
2144
2144
|
}
|
|
2145
2145
|
function R(T, P, W) {
|
|
2146
|
-
a = !0,
|
|
2146
|
+
a = !0, f = T, d = P, S = T, A = P + 1, c = W;
|
|
2147
2147
|
}
|
|
2148
2148
|
function N(T, P) {
|
|
2149
2149
|
if (!a) {
|
|
2150
2150
|
w(T, P);
|
|
2151
2151
|
return;
|
|
2152
2152
|
}
|
|
2153
|
-
c += P, S = T + 1,
|
|
2153
|
+
c += P, S = T + 1, A = 0;
|
|
2154
2154
|
}
|
|
2155
2155
|
function D(T, P) {
|
|
2156
2156
|
const W = s[T];
|
|
2157
2157
|
for (let H = P; H < W.length; H++) {
|
|
2158
2158
|
const z = W[H];
|
|
2159
|
-
a ? c + z > o ? (L(), R(T, H, z)) : (c += z, S = T,
|
|
2159
|
+
a ? c + z > o ? (L(), R(T, H, z)) : (c += z, S = T, A = H + 1) : R(T, H, z);
|
|
2160
2160
|
}
|
|
2161
|
-
a && S === T &&
|
|
2161
|
+
a && S === T && A === W.length && (S = T + 1, A = 0);
|
|
2162
2162
|
}
|
|
2163
2163
|
let E = 0;
|
|
2164
|
-
for (; E < i.length && !(!a && (E =
|
|
2165
|
-
const T = i[E], P =
|
|
2164
|
+
for (; E < i.length && !(!a && (E = ot(e, E), E >= i.length)); ) {
|
|
2165
|
+
const T = i[E], P = r[E], W = Ge(P);
|
|
2166
2166
|
if (!a) {
|
|
2167
|
-
T > o && s[E] !== null ? D(E, 0) : w(E, T), W && (
|
|
2167
|
+
T > o && s[E] !== null ? D(E, 0) : w(E, T), W && (m = E + 1, M = c - T), E++;
|
|
2168
2168
|
continue;
|
|
2169
2169
|
}
|
|
2170
2170
|
if (c + T > o) {
|
|
@@ -2172,12 +2172,12 @@ function T0(e, t, n) {
|
|
|
2172
2172
|
N(E, T), L(E + 1, 0, c - T), E++;
|
|
2173
2173
|
continue;
|
|
2174
2174
|
}
|
|
2175
|
-
if (
|
|
2176
|
-
if (S >
|
|
2175
|
+
if (m >= 0) {
|
|
2176
|
+
if (S > m || S === m && A > 0) {
|
|
2177
2177
|
L();
|
|
2178
2178
|
continue;
|
|
2179
2179
|
}
|
|
2180
|
-
L(
|
|
2180
|
+
L(m, 0, M);
|
|
2181
2181
|
continue;
|
|
2182
2182
|
}
|
|
2183
2183
|
if (T > o && s[E] !== null) {
|
|
@@ -2187,82 +2187,82 @@ function T0(e, t, n) {
|
|
|
2187
2187
|
L();
|
|
2188
2188
|
continue;
|
|
2189
2189
|
}
|
|
2190
|
-
N(E, T), W && (
|
|
2190
|
+
N(E, T), W && (m = E + 1, M = c - T), E++;
|
|
2191
2191
|
}
|
|
2192
|
-
return a && L(),
|
|
2192
|
+
return a && L(), x;
|
|
2193
2193
|
}
|
|
2194
|
-
function
|
|
2194
|
+
function H0(e, t, n) {
|
|
2195
2195
|
if (e.simpleLineWalkFastPath)
|
|
2196
|
-
return
|
|
2197
|
-
const { widths: i, kinds:
|
|
2198
|
-
if (i.length === 0 ||
|
|
2196
|
+
return G0(e, t, n);
|
|
2197
|
+
const { widths: i, kinds: r, breakableFitAdvances: s, discretionaryHyphenWidth: l, chunks: u } = e;
|
|
2198
|
+
if (i.length === 0 || u.length === 0)
|
|
2199
2199
|
return 0;
|
|
2200
|
-
const o = Be(),
|
|
2201
|
-
let a = 0,
|
|
2200
|
+
const o = Be(), x = o.lineFitEpsilon, c = t + x;
|
|
2201
|
+
let a = 0, f = 0, d = !1, S = 0, A = 0, m = 0, M = 0, v = -1, L = 0, w = 0, R = null;
|
|
2202
2202
|
function N() {
|
|
2203
2203
|
v = -1, L = 0, w = 0, R = null;
|
|
2204
2204
|
}
|
|
2205
2205
|
function D() {
|
|
2206
|
-
return R === "soft-hyphen" && v ===
|
|
2206
|
+
return R === "soft-hyphen" && v === m && M === 0 ? w : f;
|
|
2207
2207
|
}
|
|
2208
|
-
function E(
|
|
2209
|
-
a++, n !== void 0 && n(
|
|
2208
|
+
function E(p = m, y = M, k) {
|
|
2209
|
+
a++, n !== void 0 && n(Vt(e, k ?? D(), S, A, p, y), S, A, p, y), f = 0, d = !1, N();
|
|
2210
2210
|
}
|
|
2211
|
-
function T(
|
|
2212
|
-
d = !0, S =
|
|
2211
|
+
function T(p, y) {
|
|
2212
|
+
d = !0, S = p, A = 0, m = p + 1, M = 0, f = y;
|
|
2213
2213
|
}
|
|
2214
|
-
function P(
|
|
2215
|
-
d = !0, S =
|
|
2214
|
+
function P(p, y, k) {
|
|
2215
|
+
d = !0, S = p, A = y, m = p, M = y + 1, f = k;
|
|
2216
2216
|
}
|
|
2217
|
-
function W(
|
|
2217
|
+
function W(p, y) {
|
|
2218
2218
|
if (!d) {
|
|
2219
|
-
T(
|
|
2219
|
+
T(p, y);
|
|
2220
2220
|
return;
|
|
2221
2221
|
}
|
|
2222
|
-
|
|
2222
|
+
f += y, m = p + 1, M = 0;
|
|
2223
2223
|
}
|
|
2224
|
-
function H(
|
|
2224
|
+
function H(p, y, k, O, U, J) {
|
|
2225
2225
|
if (!y)
|
|
2226
2226
|
return;
|
|
2227
|
-
const
|
|
2228
|
-
v = k + 1, L =
|
|
2227
|
+
const Y = Pe(e, p, k, U), te = We(e, p, k, U, O);
|
|
2228
|
+
v = k + 1, L = f - J + Y, w = f - J + te, R = p;
|
|
2229
2229
|
}
|
|
2230
|
-
function z(
|
|
2231
|
-
const k = s[
|
|
2232
|
-
for (let
|
|
2233
|
-
const U = k[
|
|
2230
|
+
function z(p, y) {
|
|
2231
|
+
const k = s[p];
|
|
2232
|
+
for (let O = y; O < k.length; O++) {
|
|
2233
|
+
const U = k[O];
|
|
2234
2234
|
if (!d)
|
|
2235
|
-
P(
|
|
2235
|
+
P(p, O, U);
|
|
2236
2236
|
else {
|
|
2237
|
-
const J =
|
|
2238
|
-
|
|
2237
|
+
const J = Xt(e, !0, U), Y = f + J;
|
|
2238
|
+
qt(e, Y) > c ? (E(), P(p, O, U)) : (f = Y, m = p, M = O + 1);
|
|
2239
2239
|
}
|
|
2240
2240
|
}
|
|
2241
|
-
d &&
|
|
2241
|
+
d && m === p && M === k.length && (m = p + 1, M = 0);
|
|
2242
2242
|
}
|
|
2243
|
-
function C(
|
|
2244
|
-
a++, n?.(0,
|
|
2243
|
+
function C(p) {
|
|
2244
|
+
a++, n?.(0, p.startSegmentIndex, 0, p.consumedEndSegmentIndex, 0), N();
|
|
2245
2245
|
}
|
|
2246
|
-
for (let
|
|
2247
|
-
const y =
|
|
2246
|
+
for (let p = 0; p < u.length; p++) {
|
|
2247
|
+
const y = u[p];
|
|
2248
2248
|
if (y.startSegmentIndex === y.endSegmentIndex) {
|
|
2249
2249
|
C(y);
|
|
2250
2250
|
continue;
|
|
2251
2251
|
}
|
|
2252
|
-
d = !1,
|
|
2252
|
+
d = !1, f = 0, S = y.startSegmentIndex, A = 0, m = y.startSegmentIndex, M = 0, N();
|
|
2253
2253
|
let k = y.startSegmentIndex;
|
|
2254
|
-
for (; k < y.endSegmentIndex && !(!d && (k =
|
|
2255
|
-
const
|
|
2256
|
-
if (
|
|
2257
|
-
d && (
|
|
2254
|
+
for (; k < y.endSegmentIndex && !(!d && (k = ot(e, k, y.endSegmentIndex), k >= y.endSegmentIndex)); ) {
|
|
2255
|
+
const O = r[k], U = Ge(O), J = $t(e, d, k), Y = O === "tab" ? Qt(f + J, e.tabStopAdvance) : i[k], te = J + Y, ne = Yt(e, O, k, J, Y);
|
|
2256
|
+
if (O === "soft-hyphen") {
|
|
2257
|
+
d && (m = k + 1, M = 0, v = k + 1, L = f + l, w = f + l, R = O), k++;
|
|
2258
2258
|
continue;
|
|
2259
2259
|
}
|
|
2260
2260
|
if (!d) {
|
|
2261
|
-
ne > c && s[k] !== null ? z(k, 0) : T(k,
|
|
2261
|
+
ne > c && s[k] !== null ? z(k, 0) : T(k, Y), H(O, U, k, Y, J, te), k++;
|
|
2262
2262
|
continue;
|
|
2263
2263
|
}
|
|
2264
|
-
if (
|
|
2265
|
-
const Z =
|
|
2264
|
+
if (f + ne > c) {
|
|
2265
|
+
const Z = f + Pe(e, O, k, J), le = f + We(e, O, k, J, Y);
|
|
2266
2266
|
if (R === "soft-hyphen" && o.preferEarlySoftHyphenBreak && L <= c) {
|
|
2267
2267
|
E(v, 0, w);
|
|
2268
2268
|
continue;
|
|
@@ -2272,12 +2272,12 @@ function G0(e, t, n) {
|
|
|
2272
2272
|
continue;
|
|
2273
2273
|
}
|
|
2274
2274
|
if (v >= 0 && L <= c) {
|
|
2275
|
-
if (
|
|
2275
|
+
if (m > v || m === v && M > 0) {
|
|
2276
2276
|
E();
|
|
2277
2277
|
continue;
|
|
2278
2278
|
}
|
|
2279
|
-
const
|
|
2280
|
-
E(
|
|
2279
|
+
const xe = v;
|
|
2280
|
+
E(xe, 0, w), k = xe;
|
|
2281
2281
|
continue;
|
|
2282
2282
|
}
|
|
2283
2283
|
if (ne > c && s[k] !== null) {
|
|
@@ -2287,87 +2287,87 @@ function G0(e, t, n) {
|
|
|
2287
2287
|
E();
|
|
2288
2288
|
continue;
|
|
2289
2289
|
}
|
|
2290
|
-
W(k, te), H(
|
|
2290
|
+
W(k, te), H(O, U, k, Y, J, te), k++;
|
|
2291
2291
|
}
|
|
2292
2292
|
if (d) {
|
|
2293
|
-
const
|
|
2294
|
-
E(y.consumedEndSegmentIndex, 0,
|
|
2293
|
+
const O = v === y.consumedEndSegmentIndex ? w : f;
|
|
2294
|
+
E(y.consumedEndSegmentIndex, 0, O);
|
|
2295
2295
|
}
|
|
2296
2296
|
}
|
|
2297
2297
|
return a;
|
|
2298
2298
|
}
|
|
2299
|
-
function
|
|
2300
|
-
const
|
|
2301
|
-
if (
|
|
2302
|
-
return t.segmentIndex =
|
|
2303
|
-
const { widths: s, kinds: l, breakableFitAdvances:
|
|
2304
|
-
let S = 0,
|
|
2299
|
+
function _0(e, t, n, i) {
|
|
2300
|
+
const r = e.chunks[n];
|
|
2301
|
+
if (r.startSegmentIndex === r.endSegmentIndex)
|
|
2302
|
+
return t.segmentIndex = r.consumedEndSegmentIndex, t.graphemeIndex = 0, 0;
|
|
2303
|
+
const { widths: s, kinds: l, breakableFitAdvances: u, discretionaryHyphenWidth: o } = e, x = Be(), c = x.lineFitEpsilon, a = i + c, f = t.segmentIndex, d = t.graphemeIndex;
|
|
2304
|
+
let S = 0, A = !1, m = t.segmentIndex, M = t.graphemeIndex, v = -1, L = 0, w = 0, R = null;
|
|
2305
2305
|
function N() {
|
|
2306
|
-
return R === "soft-hyphen" && v ===
|
|
2306
|
+
return R === "soft-hyphen" && v === m && M === 0 ? w : S;
|
|
2307
2307
|
}
|
|
2308
|
-
function D(C =
|
|
2309
|
-
return
|
|
2308
|
+
function D(C = m, p = M, y = N()) {
|
|
2309
|
+
return A ? (t.segmentIndex = C, t.graphemeIndex = p, Vt(e, y, f, d, C, p)) : null;
|
|
2310
2310
|
}
|
|
2311
|
-
function E(C,
|
|
2312
|
-
|
|
2311
|
+
function E(C, p) {
|
|
2312
|
+
A = !0, m = C + 1, M = 0, S = p;
|
|
2313
2313
|
}
|
|
2314
|
-
function T(C,
|
|
2315
|
-
|
|
2314
|
+
function T(C, p, y) {
|
|
2315
|
+
A = !0, m = C, M = p + 1, S = y;
|
|
2316
2316
|
}
|
|
2317
|
-
function P(C,
|
|
2318
|
-
if (!
|
|
2319
|
-
E(C,
|
|
2317
|
+
function P(C, p) {
|
|
2318
|
+
if (!A) {
|
|
2319
|
+
E(C, p);
|
|
2320
2320
|
return;
|
|
2321
2321
|
}
|
|
2322
|
-
S +=
|
|
2322
|
+
S += p, m = C + 1, M = 0;
|
|
2323
2323
|
}
|
|
2324
|
-
function W(C,
|
|
2325
|
-
if (!
|
|
2324
|
+
function W(C, p, y, k, O, U) {
|
|
2325
|
+
if (!p)
|
|
2326
2326
|
return;
|
|
2327
|
-
const J =
|
|
2328
|
-
v = y + 1, L = S - U + J, w = S - U +
|
|
2329
|
-
}
|
|
2330
|
-
function H(C,
|
|
2331
|
-
const y =
|
|
2332
|
-
for (let k =
|
|
2333
|
-
const
|
|
2334
|
-
if (!
|
|
2335
|
-
T(C, k,
|
|
2327
|
+
const J = Pe(e, C, y, O), Y = We(e, C, y, O, k);
|
|
2328
|
+
v = y + 1, L = S - U + J, w = S - U + Y, R = C;
|
|
2329
|
+
}
|
|
2330
|
+
function H(C, p) {
|
|
2331
|
+
const y = u[C];
|
|
2332
|
+
for (let k = p; k < y.length; k++) {
|
|
2333
|
+
const O = y[k];
|
|
2334
|
+
if (!A)
|
|
2335
|
+
T(C, k, O);
|
|
2336
2336
|
else {
|
|
2337
|
-
const U =
|
|
2338
|
-
if (
|
|
2337
|
+
const U = Xt(e, !0, O), J = S + U;
|
|
2338
|
+
if (qt(e, J) > a)
|
|
2339
2339
|
return D();
|
|
2340
|
-
S = J,
|
|
2340
|
+
S = J, m = C, M = k + 1;
|
|
2341
2341
|
}
|
|
2342
2342
|
}
|
|
2343
|
-
return
|
|
2343
|
+
return A && m === C && M === y.length && (m = C + 1, M = 0), null;
|
|
2344
2344
|
}
|
|
2345
2345
|
function z() {
|
|
2346
2346
|
return R !== "soft-hyphen" || v < 0 ? null : L <= a ? D(v, 0, w) : null;
|
|
2347
2347
|
}
|
|
2348
|
-
for (let C = t.segmentIndex; C <
|
|
2349
|
-
const
|
|
2350
|
-
if (
|
|
2351
|
-
|
|
2348
|
+
for (let C = t.segmentIndex; C < r.endSegmentIndex; C++) {
|
|
2349
|
+
const p = l[C], y = Ge(p), k = C === t.segmentIndex ? t.graphemeIndex : 0, O = $t(e, A, C), U = p === "tab" ? Qt(S + O, e.tabStopAdvance) : s[C], J = O + U, Y = Yt(e, p, C, O, U);
|
|
2350
|
+
if (p === "soft-hyphen" && k === 0) {
|
|
2351
|
+
A && (m = C + 1, M = 0, v = C + 1, L = S + o, w = S + o, R = p);
|
|
2352
2352
|
continue;
|
|
2353
2353
|
}
|
|
2354
|
-
if (!
|
|
2354
|
+
if (!A) {
|
|
2355
2355
|
if (k > 0) {
|
|
2356
2356
|
const ne = H(C, k);
|
|
2357
2357
|
if (ne !== null)
|
|
2358
2358
|
return ne;
|
|
2359
|
-
} else if (
|
|
2359
|
+
} else if (Y > a && u[C] !== null) {
|
|
2360
2360
|
const ne = H(C, 0);
|
|
2361
2361
|
if (ne !== null)
|
|
2362
2362
|
return ne;
|
|
2363
2363
|
} else
|
|
2364
2364
|
E(C, U);
|
|
2365
|
-
W(
|
|
2365
|
+
W(p, y, C, U, O, J);
|
|
2366
2366
|
continue;
|
|
2367
2367
|
}
|
|
2368
|
-
if (S +
|
|
2369
|
-
const ne = S +
|
|
2370
|
-
if (R === "soft-hyphen" &&
|
|
2368
|
+
if (S + Y > a) {
|
|
2369
|
+
const ne = S + Pe(e, p, C, O), he = S + We(e, p, C, O, U);
|
|
2370
|
+
if (R === "soft-hyphen" && x.preferEarlySoftHyphenBreak && L <= a)
|
|
2371
2371
|
return D(v, 0, w);
|
|
2372
2372
|
const Z = z();
|
|
2373
2373
|
if (Z !== null)
|
|
@@ -2375,103 +2375,103 @@ function H0(e, t, n, i) {
|
|
|
2375
2375
|
if (y && ne <= a)
|
|
2376
2376
|
return P(C, J), D(C + 1, 0, he);
|
|
2377
2377
|
if (v >= 0 && L <= a)
|
|
2378
|
-
return
|
|
2379
|
-
if (
|
|
2378
|
+
return m > v || m === v && M > 0 ? D() : D(v, 0, w);
|
|
2379
|
+
if (Y > a && u[C] !== null) {
|
|
2380
2380
|
const le = D();
|
|
2381
2381
|
if (le !== null)
|
|
2382
2382
|
return le;
|
|
2383
|
-
const
|
|
2384
|
-
if (
|
|
2385
|
-
return
|
|
2383
|
+
const xe = H(C, 0);
|
|
2384
|
+
if (xe !== null)
|
|
2385
|
+
return xe;
|
|
2386
2386
|
}
|
|
2387
2387
|
return D();
|
|
2388
2388
|
}
|
|
2389
|
-
P(C, J), W(
|
|
2389
|
+
P(C, J), W(p, y, C, U, O, J);
|
|
2390
2390
|
}
|
|
2391
|
-
return v ===
|
|
2391
|
+
return v === r.consumedEndSegmentIndex && M === 0 ? D(r.consumedEndSegmentIndex, 0, w) : D(r.consumedEndSegmentIndex, 0, S);
|
|
2392
2392
|
}
|
|
2393
|
-
function
|
|
2394
|
-
const { widths: i, kinds:
|
|
2395
|
-
let
|
|
2396
|
-
for (let
|
|
2397
|
-
const
|
|
2393
|
+
function z0(e, t, n) {
|
|
2394
|
+
const { widths: i, kinds: r, breakableFitAdvances: s } = e, u = Be().lineFitEpsilon, o = n + u;
|
|
2395
|
+
let x = 0, c = !1, a = t.segmentIndex, f = t.graphemeIndex, d = -1, S = 0;
|
|
2396
|
+
for (let A = t.segmentIndex; A < i.length; A++) {
|
|
2397
|
+
const m = r[A], M = Ge(m), v = A === t.segmentIndex ? t.graphemeIndex : 0, L = s[A], w = i[A];
|
|
2398
2398
|
if (!c) {
|
|
2399
2399
|
if (v > 0 || w > o && L !== null) {
|
|
2400
2400
|
const R = L, N = R[v];
|
|
2401
|
-
c = !0,
|
|
2401
|
+
c = !0, x = N, a = A, f = v + 1;
|
|
2402
2402
|
for (let D = v + 1; D < R.length; D++) {
|
|
2403
2403
|
const E = R[D];
|
|
2404
|
-
if (
|
|
2405
|
-
return t.segmentIndex = a, t.graphemeIndex =
|
|
2406
|
-
|
|
2404
|
+
if (x + E > o)
|
|
2405
|
+
return t.segmentIndex = a, t.graphemeIndex = f, x;
|
|
2406
|
+
x += E, a = A, f = D + 1;
|
|
2407
2407
|
}
|
|
2408
|
-
a ===
|
|
2408
|
+
a === A && f === R.length && (a = A + 1, f = 0);
|
|
2409
2409
|
} else
|
|
2410
|
-
c = !0,
|
|
2411
|
-
M && (d =
|
|
2410
|
+
c = !0, x = w, a = A + 1, f = 0;
|
|
2411
|
+
M && (d = A + 1, S = x - w);
|
|
2412
2412
|
continue;
|
|
2413
2413
|
}
|
|
2414
|
-
if (
|
|
2415
|
-
return M ? (t.segmentIndex =
|
|
2416
|
-
|
|
2414
|
+
if (x + w > o)
|
|
2415
|
+
return M ? (t.segmentIndex = A + 1, t.graphemeIndex = 0, x) : d >= 0 ? a > d || a === d && f > 0 ? (t.segmentIndex = a, t.graphemeIndex = f, x) : (t.segmentIndex = d, t.graphemeIndex = 0, S) : (t.segmentIndex = a, t.graphemeIndex = f, x);
|
|
2416
|
+
x += w, a = A + 1, f = 0, M && (d = A + 1, S = x - w);
|
|
2417
2417
|
}
|
|
2418
|
-
return c ? (t.segmentIndex = a, t.graphemeIndex =
|
|
2418
|
+
return c ? (t.segmentIndex = a, t.graphemeIndex = f, x) : null;
|
|
2419
2419
|
}
|
|
2420
|
-
function
|
|
2421
|
-
return e.simpleLineWalkFastPath ?
|
|
2420
|
+
function j0(e, t, n, i) {
|
|
2421
|
+
return e.simpleLineWalkFastPath ? z0(e, t, i) : _0(e, t, n, i);
|
|
2422
2422
|
}
|
|
2423
|
-
function
|
|
2424
|
-
const i =
|
|
2425
|
-
return i < 0 ? null :
|
|
2423
|
+
function qe(e, t, n) {
|
|
2424
|
+
const i = T0(e, t);
|
|
2425
|
+
return i < 0 ? null : j0(e, t, i, n);
|
|
2426
2426
|
}
|
|
2427
|
-
let
|
|
2427
|
+
let Ue = null, Lt = /* @__PURE__ */ new WeakMap();
|
|
2428
2428
|
function K0() {
|
|
2429
|
-
return
|
|
2429
|
+
return Ue === null && (Ue = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Ue;
|
|
2430
2430
|
}
|
|
2431
|
-
function
|
|
2431
|
+
function Ot(e, t, n) {
|
|
2432
2432
|
let i = n.get(e);
|
|
2433
2433
|
if (i !== void 0)
|
|
2434
2434
|
return i;
|
|
2435
2435
|
i = [];
|
|
2436
|
-
const
|
|
2437
|
-
for (const s of
|
|
2436
|
+
const r = K0();
|
|
2437
|
+
for (const s of r.segment(t[e]))
|
|
2438
2438
|
i.push(s.segment);
|
|
2439
2439
|
return n.set(e, i), i;
|
|
2440
2440
|
}
|
|
2441
|
-
function
|
|
2441
|
+
function U0(e, t, n) {
|
|
2442
2442
|
return n > t && e[n - 1] === "soft-hyphen";
|
|
2443
2443
|
}
|
|
2444
|
-
function
|
|
2445
|
-
for (let
|
|
2446
|
-
e += t[
|
|
2444
|
+
function bt(e, t, n, i) {
|
|
2445
|
+
for (let r = n; r < i; r++)
|
|
2446
|
+
e += t[r];
|
|
2447
2447
|
return e;
|
|
2448
2448
|
}
|
|
2449
|
-
function
|
|
2450
|
-
let t =
|
|
2451
|
-
return t !== void 0 || (t = /* @__PURE__ */ new Map(),
|
|
2449
|
+
function J0(e) {
|
|
2450
|
+
let t = Lt.get(e);
|
|
2451
|
+
return t !== void 0 || (t = /* @__PURE__ */ new Map(), Lt.set(e, t)), t;
|
|
2452
2452
|
}
|
|
2453
|
-
function
|
|
2453
|
+
function Q0(e, t, n, i, r, s) {
|
|
2454
2454
|
let l = "";
|
|
2455
|
-
const
|
|
2456
|
-
for (let o = n; o <
|
|
2455
|
+
const u = U0(e.kinds, n, r);
|
|
2456
|
+
for (let o = n; o < r; o++)
|
|
2457
2457
|
if (!(e.kinds[o] === "soft-hyphen" || e.kinds[o] === "hard-break"))
|
|
2458
2458
|
if (o === n && i > 0) {
|
|
2459
|
-
const
|
|
2460
|
-
l =
|
|
2459
|
+
const x = Ot(o, e.segments, t);
|
|
2460
|
+
l = bt(l, x, i, x.length);
|
|
2461
2461
|
} else
|
|
2462
2462
|
l += e.segments[o];
|
|
2463
2463
|
if (s > 0) {
|
|
2464
|
-
|
|
2465
|
-
const o =
|
|
2466
|
-
l =
|
|
2467
|
-
} else
|
|
2464
|
+
u && (l += "-");
|
|
2465
|
+
const o = Ot(r, e.segments, t);
|
|
2466
|
+
l = bt(l, o, n === r ? i : 0, s);
|
|
2467
|
+
} else u && (l += "-");
|
|
2468
2468
|
return l;
|
|
2469
2469
|
}
|
|
2470
|
-
let
|
|
2471
|
-
function
|
|
2472
|
-
return
|
|
2470
|
+
let Je = null;
|
|
2471
|
+
function Zt() {
|
|
2472
|
+
return Je === null && (Je = new Intl.Segmenter(void 0, { granularity: "grapheme" })), Je;
|
|
2473
2473
|
}
|
|
2474
|
-
function
|
|
2474
|
+
function $0(e) {
|
|
2475
2475
|
return {
|
|
2476
2476
|
widths: [],
|
|
2477
2477
|
lineEndFitAdvances: [],
|
|
@@ -2488,106 +2488,106 @@ function Q0(e) {
|
|
|
2488
2488
|
segments: []
|
|
2489
2489
|
};
|
|
2490
2490
|
}
|
|
2491
|
-
function
|
|
2491
|
+
function Y0(e, t) {
|
|
2492
2492
|
const n = [];
|
|
2493
|
-
let i = [],
|
|
2493
|
+
let i = [], r = 0, s = !1, l = !1, u = !1;
|
|
2494
2494
|
function o() {
|
|
2495
2495
|
i.length !== 0 && (n.push({
|
|
2496
2496
|
text: i.length === 1 ? i[0] : i.join(""),
|
|
2497
|
-
start:
|
|
2498
|
-
}), i = [], s = !1, l = !1,
|
|
2497
|
+
start: r
|
|
2498
|
+
}), i = [], s = !1, l = !1, u = !1);
|
|
2499
2499
|
}
|
|
2500
|
-
function
|
|
2501
|
-
i = [a],
|
|
2500
|
+
function x(a, f, d) {
|
|
2501
|
+
i = [a], r = f, s = d, l = Ye(a), u = ve.has(a);
|
|
2502
2502
|
}
|
|
2503
|
-
function c(a,
|
|
2504
|
-
i.push(a), s = s ||
|
|
2505
|
-
const d =
|
|
2506
|
-
a.length === 1 &&
|
|
2503
|
+
function c(a, f) {
|
|
2504
|
+
i.push(a), s = s || f;
|
|
2505
|
+
const d = Ye(a);
|
|
2506
|
+
a.length === 1 && ge.has(a) ? l = l || d : l = d, u = !1;
|
|
2507
2507
|
}
|
|
2508
|
-
for (const a of
|
|
2509
|
-
const
|
|
2508
|
+
for (const a of Zt().segment(e)) {
|
|
2509
|
+
const f = a.segment, d = oe(f);
|
|
2510
2510
|
if (i.length === 0) {
|
|
2511
|
-
|
|
2511
|
+
x(f, a.index, d);
|
|
2512
2512
|
continue;
|
|
2513
2513
|
}
|
|
2514
|
-
if (
|
|
2515
|
-
c(
|
|
2514
|
+
if (u || st.has(f) || ge.has(f) || t.carryCJKAfterClosingQuote && d && l) {
|
|
2515
|
+
c(f, d);
|
|
2516
2516
|
continue;
|
|
2517
2517
|
}
|
|
2518
2518
|
if (!s && !d) {
|
|
2519
|
-
c(
|
|
2519
|
+
c(f, d);
|
|
2520
2520
|
continue;
|
|
2521
2521
|
}
|
|
2522
|
-
o(),
|
|
2522
|
+
o(), x(f, a.index, d);
|
|
2523
2523
|
}
|
|
2524
2524
|
return o(), n;
|
|
2525
2525
|
}
|
|
2526
|
-
function
|
|
2526
|
+
function X0(e, t, n) {
|
|
2527
2527
|
if (t.length <= 1)
|
|
2528
2528
|
return t;
|
|
2529
2529
|
const i = [];
|
|
2530
|
-
let
|
|
2531
|
-
function l(o,
|
|
2532
|
-
const c = t[o].start, a =
|
|
2530
|
+
let r = -1, s = !1;
|
|
2531
|
+
function l(o, x) {
|
|
2532
|
+
const c = t[o].start, a = x < t.length ? t[x].start : e.length;
|
|
2533
2533
|
i.push({
|
|
2534
2534
|
text: e.slice(c, a),
|
|
2535
2535
|
start: c
|
|
2536
2536
|
});
|
|
2537
2537
|
}
|
|
2538
|
-
function
|
|
2539
|
-
if (!(
|
|
2538
|
+
function u(o) {
|
|
2539
|
+
if (!(r < 0)) {
|
|
2540
2540
|
if (s)
|
|
2541
|
-
|
|
2541
|
+
r + 1 === o ? i.push(t[r]) : l(r, o);
|
|
2542
2542
|
else
|
|
2543
|
-
for (let
|
|
2544
|
-
i.push(t[
|
|
2545
|
-
|
|
2543
|
+
for (let x = r; x < o; x++)
|
|
2544
|
+
i.push(t[x]);
|
|
2545
|
+
r = -1, s = !1;
|
|
2546
2546
|
}
|
|
2547
2547
|
}
|
|
2548
2548
|
for (let o = 0; o < t.length; o++) {
|
|
2549
|
-
const
|
|
2550
|
-
|
|
2549
|
+
const x = t[o];
|
|
2550
|
+
r >= 0 && !Kt(t[o - 1].text, n) && u(o), r < 0 && (r = o), s = s || oe(x.text);
|
|
2551
2551
|
}
|
|
2552
|
-
return
|
|
2552
|
+
return u(t.length), i;
|
|
2553
2553
|
}
|
|
2554
|
-
function
|
|
2554
|
+
function It(e, t) {
|
|
2555
2555
|
if (t === "zero-width-break" || t === "soft-hyphen" || t === "hard-break")
|
|
2556
2556
|
return 0;
|
|
2557
2557
|
if (t === "tab")
|
|
2558
2558
|
return 1;
|
|
2559
2559
|
let n = 0;
|
|
2560
|
-
const i =
|
|
2561
|
-
for (const
|
|
2560
|
+
const i = Zt();
|
|
2561
|
+
for (const r of i.segment(e))
|
|
2562
2562
|
n++;
|
|
2563
2563
|
return n;
|
|
2564
2564
|
}
|
|
2565
|
-
function
|
|
2565
|
+
function q0(e, t, n) {
|
|
2566
2566
|
return t > 1 ? e + (t - 1) * n : e;
|
|
2567
2567
|
}
|
|
2568
|
-
function
|
|
2569
|
-
const s = Be(), { cache: l, emojiCorrection:
|
|
2568
|
+
function V0(e, t, n, i, r) {
|
|
2569
|
+
const s = Be(), { cache: l, emojiCorrection: u } = y0(t, D0(e.normalized)), o = Fe("-", ue("-", l), u) + (r === 0 ? 0 : r * 2), c = Fe(" ", ue(" ", l), u) * 8, a = r !== 0;
|
|
2570
2570
|
if (e.len === 0)
|
|
2571
|
-
return
|
|
2572
|
-
const
|
|
2573
|
-
let
|
|
2571
|
+
return $0();
|
|
2572
|
+
const f = [], d = [], S = [], A = [];
|
|
2573
|
+
let m = e.chunks.length <= 1 && !a;
|
|
2574
2574
|
const M = n ? [] : null, v = [], L = [], w = n ? [] : null, R = Array.from({ length: e.len });
|
|
2575
|
-
function N(P, W, H, z, C,
|
|
2576
|
-
C !== "text" && C !== "space" && C !== "zero-width-break" && (
|
|
2575
|
+
function N(P, W, H, z, C, p, y, k) {
|
|
2576
|
+
C !== "text" && C !== "space" && C !== "zero-width-break" && (m = !1), f.push(W), d.push(H), S.push(z), A.push(C), M?.push(p), v.push(y), a && L.push(k), w !== null && w.push(P);
|
|
2577
2577
|
}
|
|
2578
2578
|
function D(P, W, H, z, C) {
|
|
2579
|
-
const
|
|
2579
|
+
const p = ue(P, l), y = a ? It(P, W) : 0, k = q0(Fe(P, p, u), y, r), O = W === "space" || W === "preserved-space" || W === "zero-width-break" ? 0 : k, U = O === 0 ? 0 : O + (y > 0 ? r : 0), J = W === "space" || W === "zero-width-break" ? 0 : k;
|
|
2580
2580
|
if (C && z && P.length > 1) {
|
|
2581
|
-
let
|
|
2582
|
-
|
|
2583
|
-
const te =
|
|
2581
|
+
let Y = "sum-graphemes";
|
|
2582
|
+
r !== 0 ? Y = "segment-prefixes" : we(P) ? Y = "pair-context" : s.preferPrefixWidthsForBreakableRuns && (Y = "segment-prefixes");
|
|
2583
|
+
const te = I0(P, p, l, u, Y);
|
|
2584
2584
|
N(P, k, U, J, W, H, te, y);
|
|
2585
2585
|
return;
|
|
2586
2586
|
}
|
|
2587
2587
|
N(P, k, U, J, W, H, null, y);
|
|
2588
2588
|
}
|
|
2589
2589
|
for (let P = 0; P < e.len; P++) {
|
|
2590
|
-
R[P] =
|
|
2590
|
+
R[P] = f.length;
|
|
2591
2591
|
const W = e.texts[P], H = e.isWordLike[P], z = e.kinds[P], C = e.starts[P];
|
|
2592
2592
|
if (z === "soft-hyphen") {
|
|
2593
2593
|
N(W, 0, o, o, z, C, null, 0);
|
|
@@ -2598,119 +2598,119 @@ function q0(e, t, n, i, x) {
|
|
|
2598
2598
|
continue;
|
|
2599
2599
|
}
|
|
2600
2600
|
if (z === "tab") {
|
|
2601
|
-
N(W, 0, 0, 0, z, C, null, a ?
|
|
2601
|
+
N(W, 0, 0, 0, z, C, null, a ? It(W, z) : 0);
|
|
2602
2602
|
continue;
|
|
2603
2603
|
}
|
|
2604
|
-
const
|
|
2605
|
-
if (z === "text" &&
|
|
2606
|
-
const y =
|
|
2607
|
-
for (let
|
|
2608
|
-
const U = k[
|
|
2604
|
+
const p = ue(W, l);
|
|
2605
|
+
if (z === "text" && p.containsCJK) {
|
|
2606
|
+
const y = Y0(W, s), k = i === "keep-all" ? X0(W, y, s.breakKeepAllAfterPunctuation) : y;
|
|
2607
|
+
for (let O = 0; O < k.length; O++) {
|
|
2608
|
+
const U = k[O];
|
|
2609
2609
|
D(U.text, "text", C + U.start, H, i === "keep-all" || !oe(U.text));
|
|
2610
2610
|
}
|
|
2611
2611
|
continue;
|
|
2612
2612
|
}
|
|
2613
2613
|
D(W, z, C, H, !0);
|
|
2614
2614
|
}
|
|
2615
|
-
const E =
|
|
2615
|
+
const E = Z0(e.chunks, R, f.length), T = M === null ? null : Mn(e.normalized, M);
|
|
2616
2616
|
return w !== null ? {
|
|
2617
|
-
widths:
|
|
2617
|
+
widths: f,
|
|
2618
2618
|
lineEndFitAdvances: d,
|
|
2619
2619
|
lineEndPaintAdvances: S,
|
|
2620
|
-
kinds:
|
|
2621
|
-
simpleLineWalkFastPath:
|
|
2620
|
+
kinds: A,
|
|
2621
|
+
simpleLineWalkFastPath: m,
|
|
2622
2622
|
segLevels: T,
|
|
2623
2623
|
breakableFitAdvances: v,
|
|
2624
|
-
letterSpacing:
|
|
2624
|
+
letterSpacing: r,
|
|
2625
2625
|
spacingGraphemeCounts: L,
|
|
2626
2626
|
discretionaryHyphenWidth: o,
|
|
2627
2627
|
tabStopAdvance: c,
|
|
2628
2628
|
chunks: E,
|
|
2629
2629
|
segments: w
|
|
2630
2630
|
} : {
|
|
2631
|
-
widths:
|
|
2631
|
+
widths: f,
|
|
2632
2632
|
lineEndFitAdvances: d,
|
|
2633
2633
|
lineEndPaintAdvances: S,
|
|
2634
|
-
kinds:
|
|
2635
|
-
simpleLineWalkFastPath:
|
|
2634
|
+
kinds: A,
|
|
2635
|
+
simpleLineWalkFastPath: m,
|
|
2636
2636
|
segLevels: T,
|
|
2637
2637
|
breakableFitAdvances: v,
|
|
2638
|
-
letterSpacing:
|
|
2638
|
+
letterSpacing: r,
|
|
2639
2639
|
spacingGraphemeCounts: L,
|
|
2640
2640
|
discretionaryHyphenWidth: o,
|
|
2641
2641
|
tabStopAdvance: c,
|
|
2642
2642
|
chunks: E
|
|
2643
2643
|
};
|
|
2644
2644
|
}
|
|
2645
|
-
function
|
|
2645
|
+
function Z0(e, t, n) {
|
|
2646
2646
|
const i = [];
|
|
2647
|
-
for (let
|
|
2648
|
-
const s = e[
|
|
2647
|
+
for (let r = 0; r < e.length; r++) {
|
|
2648
|
+
const s = e[r], l = s.startSegmentIndex < t.length ? t[s.startSegmentIndex] : n, u = s.endSegmentIndex < t.length ? t[s.endSegmentIndex] : n, o = s.consumedEndSegmentIndex < t.length ? t[s.consumedEndSegmentIndex] : n;
|
|
2649
2649
|
i.push({
|
|
2650
2650
|
startSegmentIndex: l,
|
|
2651
|
-
endSegmentIndex:
|
|
2651
|
+
endSegmentIndex: u,
|
|
2652
2652
|
consumedEndSegmentIndex: o
|
|
2653
2653
|
});
|
|
2654
2654
|
}
|
|
2655
2655
|
return i;
|
|
2656
2656
|
}
|
|
2657
|
-
function
|
|
2658
|
-
const
|
|
2659
|
-
return
|
|
2657
|
+
function es(e, t, n, i) {
|
|
2658
|
+
const r = i?.wordBreak ?? "normal", s = i?.letterSpacing ?? 0, l = m0(e, Be(), i?.whiteSpace, r);
|
|
2659
|
+
return V0(l, t, n, r, s);
|
|
2660
2660
|
}
|
|
2661
|
-
function
|
|
2662
|
-
return
|
|
2661
|
+
function Ve(e, t, n) {
|
|
2662
|
+
return es(e, t, !0, n);
|
|
2663
2663
|
}
|
|
2664
|
-
function
|
|
2664
|
+
function yt(e) {
|
|
2665
2665
|
let t = 0;
|
|
2666
|
-
return
|
|
2666
|
+
return H0(e, Number.POSITIVE_INFINITY, (n) => {
|
|
2667
2667
|
n > t && (t = n);
|
|
2668
2668
|
}), t;
|
|
2669
2669
|
}
|
|
2670
|
-
const
|
|
2670
|
+
const ts = /[ \t\n\f\r]+/, wt = /^[ \t\n\f\r]+/, Pt = /[ \t\n\f\r]+$/, Wt = { segmentIndex: 0, graphemeIndex: 0 }, ns = {
|
|
2671
2671
|
itemIndex: 0,
|
|
2672
2672
|
segmentIndex: 0,
|
|
2673
2673
|
graphemeIndex: 0
|
|
2674
2674
|
};
|
|
2675
|
-
function
|
|
2675
|
+
function Qe(e) {
|
|
2676
2676
|
return {
|
|
2677
2677
|
segmentIndex: e.segmentIndex,
|
|
2678
2678
|
graphemeIndex: e.graphemeIndex
|
|
2679
2679
|
};
|
|
2680
2680
|
}
|
|
2681
|
-
function
|
|
2681
|
+
function vt(e) {
|
|
2682
2682
|
return e.segmentIndex === 0 && e.graphemeIndex === 0;
|
|
2683
2683
|
}
|
|
2684
|
-
function
|
|
2685
|
-
const i = `${e}\0${t}`,
|
|
2686
|
-
if (
|
|
2687
|
-
return
|
|
2688
|
-
const s = t === 0 ? void 0 : { letterSpacing: t }, l =
|
|
2684
|
+
function be(e, t, n) {
|
|
2685
|
+
const i = `${e}\0${t}`, r = n.get(i);
|
|
2686
|
+
if (r !== void 0)
|
|
2687
|
+
return r;
|
|
2688
|
+
const s = t === 0 ? void 0 : { letterSpacing: t }, l = yt(Ve("A A", e, s)), u = yt(Ve("AA", e, s)), o = Math.max(0, l - u);
|
|
2689
2689
|
return n.set(i, o), o;
|
|
2690
2690
|
}
|
|
2691
|
-
function
|
|
2692
|
-
const t = { segmentIndex: 0, graphemeIndex: 0 }, n =
|
|
2691
|
+
function ss(e) {
|
|
2692
|
+
const t = { segmentIndex: 0, graphemeIndex: 0 }, n = qe(e, t, Number.POSITIVE_INFINITY);
|
|
2693
2693
|
return n === null ? null : {
|
|
2694
2694
|
endGraphemeIndex: t.graphemeIndex,
|
|
2695
2695
|
endSegmentIndex: t.segmentIndex,
|
|
2696
2696
|
width: n
|
|
2697
2697
|
};
|
|
2698
2698
|
}
|
|
2699
|
-
function
|
|
2699
|
+
function is(e, t) {
|
|
2700
2700
|
return e === 0 && t > 0;
|
|
2701
2701
|
}
|
|
2702
|
-
function
|
|
2702
|
+
function en(e) {
|
|
2703
2703
|
const t = [], n = Array.from({ length: e.length }), i = /* @__PURE__ */ new Map();
|
|
2704
|
-
let
|
|
2704
|
+
let r = 0;
|
|
2705
2705
|
for (let s = 0; s < e.length; s++) {
|
|
2706
|
-
const l = e[s],
|
|
2706
|
+
const l = e[s], u = l.letterSpacing ?? 0, o = wt.test(l.text), x = Pt.test(l.text), c = l.text.replace(wt, "").replace(Pt, "");
|
|
2707
2707
|
if (c.length === 0) {
|
|
2708
|
-
|
|
2708
|
+
ts.test(l.text) && r === 0 && (r = be(l.font, u, i));
|
|
2709
2709
|
continue;
|
|
2710
2710
|
}
|
|
2711
|
-
const a =
|
|
2711
|
+
const a = r > 0 ? r : o ? be(l.font, u, i) : 0, f = Ve(c, l.font, u === 0 ? void 0 : { letterSpacing: u }), d = ss(f);
|
|
2712
2712
|
if (d === null) {
|
|
2713
|
-
|
|
2713
|
+
r = x ? be(l.font, u, i) : 0;
|
|
2714
2714
|
continue;
|
|
2715
2715
|
}
|
|
2716
2716
|
const S = {
|
|
@@ -2720,97 +2720,97 @@ function Zt(e) {
|
|
|
2720
2720
|
extraWidth: l.extraWidth ?? 0,
|
|
2721
2721
|
gapBefore: a,
|
|
2722
2722
|
naturalWidth: d.width,
|
|
2723
|
-
prepared:
|
|
2723
|
+
prepared: f,
|
|
2724
2724
|
sourceItemIndex: s
|
|
2725
2725
|
};
|
|
2726
|
-
t.push(S), n[s] = S,
|
|
2726
|
+
t.push(S), n[s] = S, r = x ? be(l.font, u, i) : 0;
|
|
2727
2727
|
}
|
|
2728
2728
|
return {
|
|
2729
2729
|
items: t,
|
|
2730
2730
|
itemsBySourceItemIndex: n
|
|
2731
2731
|
};
|
|
2732
2732
|
}
|
|
2733
|
-
function
|
|
2733
|
+
function rs(e, t, n, i) {
|
|
2734
2734
|
if (e.items.length === 0 || n.itemIndex >= e.items.length)
|
|
2735
2735
|
return null;
|
|
2736
|
-
const
|
|
2737
|
-
let s = 0, l =
|
|
2738
|
-
e: for (;
|
|
2739
|
-
const o = e.items[
|
|
2740
|
-
if (!
|
|
2741
|
-
|
|
2736
|
+
const r = Math.max(1, t);
|
|
2737
|
+
let s = 0, l = r, u = n.itemIndex;
|
|
2738
|
+
e: for (; u < e.items.length; ) {
|
|
2739
|
+
const o = e.items[u];
|
|
2740
|
+
if (!vt(n) && n.segmentIndex === o.endSegmentIndex && n.graphemeIndex === o.endGraphemeIndex) {
|
|
2741
|
+
u++, n.segmentIndex = 0, n.graphemeIndex = 0;
|
|
2742
2742
|
continue;
|
|
2743
2743
|
}
|
|
2744
|
-
const
|
|
2744
|
+
const x = s === 0 ? 0 : o.gapBefore, c = vt(n);
|
|
2745
2745
|
if (o.break === "never") {
|
|
2746
2746
|
if (!c) {
|
|
2747
|
-
|
|
2747
|
+
u++, n.segmentIndex = 0, n.graphemeIndex = 0;
|
|
2748
2748
|
continue;
|
|
2749
2749
|
}
|
|
2750
|
-
const M = o.naturalWidth + o.extraWidth, v =
|
|
2750
|
+
const M = o.naturalWidth + o.extraWidth, v = x + M;
|
|
2751
2751
|
if (s > 0 && v > l)
|
|
2752
2752
|
break e;
|
|
2753
|
-
i?.(o,
|
|
2753
|
+
i?.(o, x, M, Qe(Wt), {
|
|
2754
2754
|
segmentIndex: o.endSegmentIndex,
|
|
2755
2755
|
graphemeIndex: o.endGraphemeIndex
|
|
2756
|
-
}), s += v, l = Math.max(0,
|
|
2756
|
+
}), s += v, l = Math.max(0, r - s), u++, n.segmentIndex = 0, n.graphemeIndex = 0;
|
|
2757
2757
|
continue;
|
|
2758
2758
|
}
|
|
2759
|
-
const a =
|
|
2759
|
+
const a = x + o.extraWidth;
|
|
2760
2760
|
if (s > 0 && a >= l)
|
|
2761
2761
|
break e;
|
|
2762
2762
|
if (c) {
|
|
2763
2763
|
const M = a + o.naturalWidth;
|
|
2764
2764
|
if (M <= l) {
|
|
2765
|
-
i?.(o,
|
|
2765
|
+
i?.(o, x, o.naturalWidth + o.extraWidth, Qe(Wt), {
|
|
2766
2766
|
segmentIndex: o.endSegmentIndex,
|
|
2767
2767
|
graphemeIndex: o.endGraphemeIndex
|
|
2768
|
-
}), s += M, l = Math.max(0,
|
|
2768
|
+
}), s += M, l = Math.max(0, r - s), u++, n.segmentIndex = 0, n.graphemeIndex = 0;
|
|
2769
2769
|
continue;
|
|
2770
2770
|
}
|
|
2771
2771
|
}
|
|
2772
|
-
const
|
|
2772
|
+
const f = Math.max(1, l - a), d = {
|
|
2773
2773
|
segmentIndex: n.segmentIndex,
|
|
2774
2774
|
graphemeIndex: n.graphemeIndex
|
|
2775
|
-
}, S =
|
|
2775
|
+
}, S = qe(o.prepared, d, f);
|
|
2776
2776
|
if (S === null) {
|
|
2777
|
-
|
|
2777
|
+
u++, n.segmentIndex = 0, n.graphemeIndex = 0;
|
|
2778
2778
|
continue;
|
|
2779
2779
|
}
|
|
2780
2780
|
if (n.segmentIndex === d.segmentIndex && n.graphemeIndex === d.graphemeIndex) {
|
|
2781
|
-
|
|
2781
|
+
u++, n.segmentIndex = 0, n.graphemeIndex = 0;
|
|
2782
2782
|
continue;
|
|
2783
2783
|
}
|
|
2784
|
-
const
|
|
2785
|
-
if (s > 0 && c &&
|
|
2784
|
+
const A = S + o.extraWidth, m = x + A;
|
|
2785
|
+
if (s > 0 && c && m > l)
|
|
2786
2786
|
break e;
|
|
2787
|
-
if (s > 0 && c &&
|
|
2787
|
+
if (s > 0 && c && x > 0 && is(d.segmentIndex, d.graphemeIndex)) {
|
|
2788
2788
|
const M = { segmentIndex: 0, graphemeIndex: 0 };
|
|
2789
|
-
if (
|
|
2789
|
+
if (qe(o.prepared, M, Math.max(1, r - o.extraWidth)) !== null && (M.segmentIndex > d.segmentIndex || M.segmentIndex === d.segmentIndex && M.graphemeIndex > d.graphemeIndex))
|
|
2790
2790
|
break e;
|
|
2791
2791
|
}
|
|
2792
|
-
if (i?.(o,
|
|
2792
|
+
if (i?.(o, x, A, Qe(n), {
|
|
2793
2793
|
segmentIndex: d.segmentIndex,
|
|
2794
2794
|
graphemeIndex: d.graphemeIndex
|
|
2795
|
-
}), s +=
|
|
2796
|
-
|
|
2795
|
+
}), s += m, l = Math.max(0, r - s), d.segmentIndex === o.endSegmentIndex && d.graphemeIndex === o.endGraphemeIndex) {
|
|
2796
|
+
u++, n.segmentIndex = 0, n.graphemeIndex = 0;
|
|
2797
2797
|
continue;
|
|
2798
2798
|
}
|
|
2799
2799
|
n.segmentIndex = d.segmentIndex, n.graphemeIndex = d.graphemeIndex;
|
|
2800
2800
|
break;
|
|
2801
2801
|
}
|
|
2802
|
-
return s === 0 ? null : (n.itemIndex =
|
|
2802
|
+
return s === 0 ? null : (n.itemIndex = u, s);
|
|
2803
2803
|
}
|
|
2804
|
-
function xs(e, t, n =
|
|
2805
|
-
const i = e,
|
|
2804
|
+
function xs(e, t, n = ns) {
|
|
2805
|
+
const i = e, r = {
|
|
2806
2806
|
itemIndex: n.itemIndex,
|
|
2807
2807
|
segmentIndex: n.segmentIndex,
|
|
2808
2808
|
graphemeIndex: n.graphemeIndex
|
|
2809
|
-
}, s = [], l =
|
|
2809
|
+
}, s = [], l = rs(i, t, r, (u, o, x, c, a) => {
|
|
2810
2810
|
s.push({
|
|
2811
|
-
itemIndex:
|
|
2811
|
+
itemIndex: u.sourceItemIndex,
|
|
2812
2812
|
gapBefore: o,
|
|
2813
|
-
occupiedWidth:
|
|
2813
|
+
occupiedWidth: x,
|
|
2814
2814
|
start: c,
|
|
2815
2815
|
end: a
|
|
2816
2816
|
});
|
|
@@ -2818,21 +2818,21 @@ function xs(e, t, n = ts) {
|
|
|
2818
2818
|
return l === null ? null : {
|
|
2819
2819
|
fragments: s,
|
|
2820
2820
|
width: l,
|
|
2821
|
-
end:
|
|
2821
|
+
end: r
|
|
2822
2822
|
};
|
|
2823
2823
|
}
|
|
2824
|
-
function rs(e, t) {
|
|
2825
|
-
return J0(e.prepared, U0(e.prepared), t.start.segmentIndex, t.start.graphemeIndex, t.end.segmentIndex, t.end.graphemeIndex);
|
|
2826
|
-
}
|
|
2827
2824
|
function os(e, t) {
|
|
2825
|
+
return Q0(e.prepared, J0(e.prepared), t.start.segmentIndex, t.start.graphemeIndex, t.end.segmentIndex, t.end.graphemeIndex);
|
|
2826
|
+
}
|
|
2827
|
+
function ls(e, t) {
|
|
2828
2828
|
const n = e, i = [];
|
|
2829
|
-
for (let
|
|
2830
|
-
const s = t.fragments[
|
|
2829
|
+
for (let r = 0; r < t.fragments.length; r++) {
|
|
2830
|
+
const s = t.fragments[r], l = n.itemsBySourceItemIndex[s.itemIndex];
|
|
2831
2831
|
if (l === void 0)
|
|
2832
2832
|
throw new Error("Missing rich-text inline item for fragment");
|
|
2833
2833
|
i.push({
|
|
2834
2834
|
itemIndex: s.itemIndex,
|
|
2835
|
-
text:
|
|
2835
|
+
text: os(l, s),
|
|
2836
2836
|
gapBefore: s.gapBefore,
|
|
2837
2837
|
occupiedWidth: s.occupiedWidth,
|
|
2838
2838
|
start: s.start,
|
|
@@ -2845,7 +2845,7 @@ function os(e, t) {
|
|
|
2845
2845
|
end: t.end
|
|
2846
2846
|
};
|
|
2847
2847
|
}
|
|
2848
|
-
const
|
|
2848
|
+
const cs = (e) => e.runs.some((t) => t.text.length > 0) && e.runs.every((t) => t.text.length === 0 || t.style.hidden === !0), as = [
|
|
2849
2849
|
[1e3, "m"],
|
|
2850
2850
|
[900, "cm"],
|
|
2851
2851
|
[500, "d"],
|
|
@@ -2860,96 +2860,96 @@ const ls = (e) => e.runs.some((t) => t.text.length > 0) && e.runs.every((t) => t
|
|
|
2860
2860
|
[4, "iv"],
|
|
2861
2861
|
[1, "i"]
|
|
2862
2862
|
];
|
|
2863
|
-
function
|
|
2863
|
+
function Rt(e) {
|
|
2864
2864
|
let t = "", n = Math.max(1, e);
|
|
2865
|
-
for (const [i,
|
|
2865
|
+
for (const [i, r] of as)
|
|
2866
2866
|
for (; n >= i; )
|
|
2867
|
-
t +=
|
|
2867
|
+
t += r, n -= i;
|
|
2868
2868
|
return t;
|
|
2869
2869
|
}
|
|
2870
|
-
function
|
|
2870
|
+
function Tt(e) {
|
|
2871
2871
|
let t = "", n = Math.max(1, e);
|
|
2872
2872
|
for (; n > 0; )
|
|
2873
2873
|
n -= 1, t = String.fromCharCode(97 + n % 26) + t, n = Math.floor(n / 26);
|
|
2874
2874
|
return t;
|
|
2875
2875
|
}
|
|
2876
|
-
function
|
|
2876
|
+
function ke(e, t) {
|
|
2877
2877
|
switch (t) {
|
|
2878
2878
|
case "decimal":
|
|
2879
2879
|
return String(e);
|
|
2880
2880
|
case "lowerLetter":
|
|
2881
|
-
return
|
|
2881
|
+
return Tt(e);
|
|
2882
2882
|
case "upperLetter":
|
|
2883
|
-
return
|
|
2883
|
+
return Tt(e).toUpperCase();
|
|
2884
2884
|
case "lowerRoman":
|
|
2885
|
-
return
|
|
2885
|
+
return Rt(e);
|
|
2886
2886
|
case "upperRoman":
|
|
2887
|
-
return
|
|
2887
|
+
return Rt(e).toUpperCase();
|
|
2888
2888
|
case "bullet":
|
|
2889
2889
|
return "";
|
|
2890
2890
|
}
|
|
2891
2891
|
}
|
|
2892
|
-
function
|
|
2892
|
+
function us(e, t, n) {
|
|
2893
2893
|
const i = e.levels[Math.min(t, e.levels.length - 1)];
|
|
2894
|
-
return i ? i.format === "bullet" ? i.bulletChar ?? "•" : i.text.replace(/%(\d)/g, (
|
|
2895
|
-
const l = Number(s) - 1,
|
|
2896
|
-
return
|
|
2894
|
+
return i ? i.format === "bullet" ? i.bulletChar ?? "•" : i.text.replace(/%(\d)/g, (r, s) => {
|
|
2895
|
+
const l = Number(s) - 1, u = e.levels[Math.min(l, e.levels.length - 1)], o = n[l] ?? u?.start ?? 1;
|
|
2896
|
+
return ke(o, u?.format ?? "decimal");
|
|
2897
2897
|
}) : "";
|
|
2898
2898
|
}
|
|
2899
|
-
function
|
|
2899
|
+
function fs(e) {
|
|
2900
2900
|
let t = 1;
|
|
2901
2901
|
const n = [];
|
|
2902
2902
|
for (const i of e.rows) {
|
|
2903
|
-
let
|
|
2903
|
+
let r = 0;
|
|
2904
2904
|
for (const s of i.cells) {
|
|
2905
|
-
for (; (n[
|
|
2906
|
-
const l = Math.max(1, s.colSpan ?? 1),
|
|
2907
|
-
if (
|
|
2908
|
-
|
|
2905
|
+
for (; (n[r] ?? 0) > 0; ) r++;
|
|
2906
|
+
const l = Math.max(1, s.colSpan ?? 1), u = Math.max(1, s.rowSpan ?? 1);
|
|
2907
|
+
if (u > 1) for (let o = 0; o < l; o++) n[r + o] = u;
|
|
2908
|
+
r += l;
|
|
2909
2909
|
}
|
|
2910
|
-
t = Math.max(t,
|
|
2910
|
+
t = Math.max(t, r);
|
|
2911
2911
|
for (let s = 0; s < n.length; s++) n[s] > 0 && n[s]--;
|
|
2912
2912
|
}
|
|
2913
2913
|
return t;
|
|
2914
2914
|
}
|
|
2915
|
-
function
|
|
2916
|
-
const t =
|
|
2915
|
+
function hs(e) {
|
|
2916
|
+
const t = fs(e);
|
|
2917
2917
|
return e.colFractions && e.colFractions.length === t ? e.colFractions : Array.from({ length: t }, () => 1 / t);
|
|
2918
2918
|
}
|
|
2919
|
-
function
|
|
2919
|
+
function ds(e) {
|
|
2920
2920
|
const t = [];
|
|
2921
|
-
let n = [], i = 0,
|
|
2921
|
+
let n = [], i = 0, r = 0;
|
|
2922
2922
|
for (const s of e) {
|
|
2923
2923
|
let l = 0;
|
|
2924
2924
|
for (; ; ) {
|
|
2925
2925
|
const o = s.text.indexOf("\v", l);
|
|
2926
2926
|
if (o < 0) break;
|
|
2927
|
-
const
|
|
2928
|
-
|
|
2927
|
+
const x = s.text.slice(l, o);
|
|
2928
|
+
x.length > 0 && n.push({ text: x, style: s.style }), r += o - l, t.push({ runs: n, startOffset: i }), r += 1, i = r, n = [], l = o + 1;
|
|
2929
2929
|
}
|
|
2930
|
-
const
|
|
2931
|
-
|
|
2930
|
+
const u = s.text.slice(l);
|
|
2931
|
+
u.length > 0 && n.push({ text: u, style: s.style }), r += u.length;
|
|
2932
2932
|
}
|
|
2933
2933
|
return t.push({ runs: n, startOffset: i }), t;
|
|
2934
2934
|
}
|
|
2935
|
-
function
|
|
2935
|
+
function tn(e) {
|
|
2936
2936
|
return e.map((t) => {
|
|
2937
2937
|
const n = { text: t.style.hidden ? "" : t.text, font: fe(t.style) };
|
|
2938
2938
|
return !t.style.hidden && t.style.letterSpacingPx !== void 0 && (n.letterSpacing = t.style.letterSpacingPx), n;
|
|
2939
2939
|
});
|
|
2940
2940
|
}
|
|
2941
|
-
function
|
|
2942
|
-
return
|
|
2941
|
+
function Fs(e) {
|
|
2942
|
+
return en(tn(e));
|
|
2943
2943
|
}
|
|
2944
|
-
class
|
|
2944
|
+
class Ze {
|
|
2945
2945
|
map = /* @__PURE__ */ new Map();
|
|
2946
2946
|
get(t) {
|
|
2947
2947
|
const n = this.map.get(t.id);
|
|
2948
2948
|
if (n && n.revision === t.revision) return n.segments;
|
|
2949
|
-
const i =
|
|
2950
|
-
prepared:
|
|
2951
|
-
runs:
|
|
2952
|
-
startOffset:
|
|
2949
|
+
const i = ds(t.runs).map((r) => ({
|
|
2950
|
+
prepared: en(tn(r.runs)),
|
|
2951
|
+
runs: r.runs,
|
|
2952
|
+
startOffset: r.startOffset
|
|
2953
2953
|
}));
|
|
2954
2954
|
return this.map.set(t.id, { revision: t.revision, segments: i }), i;
|
|
2955
2955
|
}
|
|
@@ -2957,191 +2957,200 @@ class Ve {
|
|
|
2957
2957
|
this.map.delete(t);
|
|
2958
2958
|
}
|
|
2959
2959
|
}
|
|
2960
|
-
const
|
|
2961
|
-
function
|
|
2962
|
-
const e = new
|
|
2960
|
+
const $e = 48;
|
|
2961
|
+
function ys() {
|
|
2962
|
+
const e = new Ze(), t = /* @__PURE__ */ new Map(), n = (i, r) => {
|
|
2963
2963
|
const s = t.get(i.id);
|
|
2964
|
-
if (s && s.revision === i.revision && s.width ===
|
|
2965
|
-
const l =
|
|
2966
|
-
return t.set(i.id, { revision: i.revision, width:
|
|
2964
|
+
if (s && s.revision === i.revision && s.width === r) return s.lines;
|
|
2965
|
+
const l = xn(i, r, e);
|
|
2966
|
+
return t.set(i.id, { revision: i.revision, width: r, lines: l }), l;
|
|
2967
2967
|
};
|
|
2968
2968
|
return {
|
|
2969
|
-
layout(i,
|
|
2970
|
-
return
|
|
2969
|
+
layout(i, r, s) {
|
|
2970
|
+
return ks(i, n, (l) => e.get(l), s?.rawBand ?? null);
|
|
2971
2971
|
},
|
|
2972
2972
|
evict(i) {
|
|
2973
2973
|
e.evict(i), t.delete(i);
|
|
2974
2974
|
}
|
|
2975
2975
|
};
|
|
2976
2976
|
}
|
|
2977
|
-
function
|
|
2977
|
+
function gs(e) {
|
|
2978
2978
|
let t = 0;
|
|
2979
2979
|
for (let n = 0; n < e.length; n++) e.charCodeAt(n) === 32 && t++;
|
|
2980
2980
|
return t;
|
|
2981
2981
|
}
|
|
2982
|
-
const
|
|
2982
|
+
const Ns = (e) => e === " " || e === " " || e === `
|
|
2983
2983
|
` || e === "\r";
|
|
2984
|
-
function
|
|
2984
|
+
function Ss(e, t, n) {
|
|
2985
2985
|
const i = e.indexOf(n, t);
|
|
2986
2986
|
if (i >= 0) return { start: i, end: i + n.length };
|
|
2987
|
-
const
|
|
2988
|
-
let s = t, l = 0,
|
|
2987
|
+
const r = [];
|
|
2988
|
+
let s = t, l = 0, u = -1;
|
|
2989
2989
|
for (; l < n.length && s < e.length; ) {
|
|
2990
2990
|
if (e[s] === n[l]) {
|
|
2991
|
-
|
|
2991
|
+
u < 0 && (u = s), r.push(s - u), s++, l++;
|
|
2992
2992
|
continue;
|
|
2993
2993
|
}
|
|
2994
|
-
if (
|
|
2994
|
+
if (Ns(e[s])) {
|
|
2995
2995
|
s++;
|
|
2996
2996
|
continue;
|
|
2997
2997
|
}
|
|
2998
|
-
|
|
2998
|
+
u = -1;
|
|
2999
2999
|
break;
|
|
3000
3000
|
}
|
|
3001
|
-
return
|
|
3001
|
+
return u >= 0 && l === n.length ? (r.push(s - u), s - u === n.length ? { start: u, end: s } : { start: u, end: s, map: r }) : { start: t, end: t + n.length };
|
|
3002
3002
|
}
|
|
3003
|
-
function
|
|
3003
|
+
function ct(e, t) {
|
|
3004
3004
|
const n = [];
|
|
3005
3005
|
let i = t;
|
|
3006
|
-
for (const
|
|
3007
|
-
n.push(i), i +=
|
|
3006
|
+
for (const r of e)
|
|
3007
|
+
n.push(i), i += r.text.length;
|
|
3008
3008
|
return n;
|
|
3009
3009
|
}
|
|
3010
|
-
function
|
|
3011
|
-
return
|
|
3010
|
+
function ps(e) {
|
|
3011
|
+
return cs(e) && !e.style.sectionBreak && !e.style.pageBreakBefore;
|
|
3012
3012
|
}
|
|
3013
|
-
function
|
|
3014
|
-
const t = e.runs[0]?.style, n = t?.fontSizePx ?? 16, i = t ?
|
|
3015
|
-
return { height: s, ascent: (s -
|
|
3013
|
+
function nn(e) {
|
|
3014
|
+
const t = e.runs[0]?.style, n = t?.fontSizePx ?? 16, i = t ? ye(fe(t)) : { ascent: n * 0.8, descent: n * 0.2 }, r = i.ascent + i.descent, s = Math.max(r, e.style.lineHeight * n);
|
|
3015
|
+
return { height: s, ascent: (s - r) / 2 + i.ascent };
|
|
3016
3016
|
}
|
|
3017
|
-
function
|
|
3017
|
+
function at(e, t, n, i, r, s) {
|
|
3018
3018
|
const l = xs(t.prepared, n, i);
|
|
3019
3019
|
if (l === null) return null;
|
|
3020
|
-
const
|
|
3021
|
-
let
|
|
3022
|
-
for (const
|
|
3023
|
-
|
|
3024
|
-
const M = t.runs[
|
|
3025
|
-
if (c = Math.max(c, v.ascent), a = Math.max(a, v.descent),
|
|
3026
|
-
const L =
|
|
3027
|
-
s[
|
|
3020
|
+
const u = ls(t.prepared, l), o = [];
|
|
3021
|
+
let x = 0, c = 0, a = 0, f = 0;
|
|
3022
|
+
for (const m of u.fragments) {
|
|
3023
|
+
x += m.gapBefore;
|
|
3024
|
+
const M = t.runs[m.itemIndex], v = ye(fe(M.style));
|
|
3025
|
+
if (c = Math.max(c, v.ascent), a = Math.max(a, v.descent), f = Math.max(f, M.style.fontSizePx), m.text.length > 0) {
|
|
3026
|
+
const L = Ss(M.text, s[m.itemIndex], m.text);
|
|
3027
|
+
s[m.itemIndex] = L.end;
|
|
3028
3028
|
const w = {
|
|
3029
3029
|
blockId: e.id,
|
|
3030
|
-
startOffset:
|
|
3031
|
-
endOffset:
|
|
3032
|
-
text:
|
|
3030
|
+
startOffset: r[m.itemIndex] + L.start,
|
|
3031
|
+
endOffset: r[m.itemIndex] + L.end,
|
|
3032
|
+
text: m.text,
|
|
3033
3033
|
style: M.style,
|
|
3034
|
-
x
|
|
3035
|
-
width:
|
|
3034
|
+
x,
|
|
3035
|
+
width: m.occupiedWidth
|
|
3036
3036
|
};
|
|
3037
|
-
L.map && (w.offsetMap = L.map), o.push({ frag: w, hadGap:
|
|
3037
|
+
L.map && (w.offsetMap = L.map), o.push({ frag: w, hadGap: m.gapBefore > 0, spaces: gs(m.text) });
|
|
3038
3038
|
}
|
|
3039
|
-
|
|
3039
|
+
x += m.occupiedWidth;
|
|
3040
3040
|
}
|
|
3041
|
-
if (
|
|
3042
|
-
const
|
|
3043
|
-
if (
|
|
3044
|
-
const M =
|
|
3045
|
-
c = M.ascent, a = M.descent,
|
|
3041
|
+
if (f === 0) {
|
|
3042
|
+
const m = e.runs[0]?.style;
|
|
3043
|
+
if (m) {
|
|
3044
|
+
const M = ye(fe(m));
|
|
3045
|
+
c = M.ascent, a = M.descent, f = m.fontSizePx;
|
|
3046
3046
|
}
|
|
3047
3047
|
}
|
|
3048
|
-
const d = c + a, S = Math.max(d, e.style.lineHeight *
|
|
3049
|
-
return { frags: o, width:
|
|
3048
|
+
const d = c + a, S = Math.max(d, e.style.lineHeight * f), A = (S - d) / 2;
|
|
3049
|
+
return { frags: o, width: u.width, height: S, ascent: A + c, end: u.end };
|
|
3050
3050
|
}
|
|
3051
|
-
function
|
|
3052
|
-
for (const
|
|
3053
|
-
let i = (Math.floor(e /
|
|
3054
|
-
return i <= e && (i = e +
|
|
3051
|
+
function ms(e, t, n) {
|
|
3052
|
+
for (const r of t) if (r.posPx > e + 0.5) return r;
|
|
3053
|
+
let i = (Math.floor(e / $e) + 1) * $e;
|
|
3054
|
+
return i <= e && (i = e + $e), { posPx: Math.min(i, Math.max(e + 1, n)), align: "left", leader: "none" };
|
|
3055
3055
|
}
|
|
3056
|
-
function
|
|
3057
|
-
const t = e.map((
|
|
3056
|
+
function As(e) {
|
|
3057
|
+
const t = e.map((r) => r.text).join(""), n = fe(e[0]?.style ?? sn);
|
|
3058
3058
|
let i = t.indexOf(".");
|
|
3059
|
-
return i < 0 && (i = t.indexOf(",")),
|
|
3059
|
+
return i < 0 && (i = t.indexOf(",")), tt(i < 0 ? t : t.slice(0, i + 1), n);
|
|
3060
3060
|
}
|
|
3061
|
-
const
|
|
3062
|
-
function
|
|
3061
|
+
const sn = { fontFamily: "Georgia, serif", fontSizePx: 16 };
|
|
3062
|
+
function Es(e, t, n, i, r) {
|
|
3063
3063
|
const s = [];
|
|
3064
|
-
let l = [],
|
|
3064
|
+
let l = [], u = n, o = n;
|
|
3065
3065
|
for (const L of t) {
|
|
3066
3066
|
let w = 0;
|
|
3067
3067
|
for (; ; ) {
|
|
3068
3068
|
const N = L.text.indexOf(" ", w);
|
|
3069
3069
|
if (N < 0) break;
|
|
3070
3070
|
const D = L.text.slice(w, N);
|
|
3071
|
-
D.length > 0 && l.push({ text: D, style: L.style }), o += N - w, s.push({ runs: l, start:
|
|
3071
|
+
D.length > 0 && l.push({ text: D, style: L.style }), o += N - w, s.push({ runs: l, start: u }), o += 1, u = o, l = [], w = N + 1;
|
|
3072
3072
|
}
|
|
3073
3073
|
const R = L.text.slice(w);
|
|
3074
3074
|
R.length > 0 && l.push({ text: R, style: L.style }), o += R.length;
|
|
3075
3075
|
}
|
|
3076
|
-
s.push({ runs: l, start:
|
|
3077
|
-
const
|
|
3078
|
-
let
|
|
3076
|
+
s.push({ runs: l, start: u });
|
|
3077
|
+
const x = (e.style.tabStops ?? []).slice().sort((L, w) => L.posPx - w.posPx), c = t.find((L) => L.text.length > 0)?.style ?? e.runs[0]?.style, a = [];
|
|
3078
|
+
let f = [], d = [], S = r, A = 0, m = 0, M = !1;
|
|
3079
3079
|
const v = (L) => {
|
|
3080
|
-
if (
|
|
3081
|
-
const w =
|
|
3082
|
-
|
|
3080
|
+
if (A === 0 && c) {
|
|
3081
|
+
const w = ye(fe(c));
|
|
3082
|
+
A = Math.max(w.ascent + w.descent, e.style.lineHeight * c.fontSizePx), m = (A - (w.ascent + w.descent)) / 2 + w.ascent;
|
|
3083
3083
|
}
|
|
3084
3084
|
a.push({
|
|
3085
|
-
frags:
|
|
3085
|
+
frags: f,
|
|
3086
3086
|
width: S,
|
|
3087
3087
|
indent: 0,
|
|
3088
3088
|
// fragment x is already absolute (tab/indent baked in)
|
|
3089
3089
|
lineMaxWidth: i,
|
|
3090
|
-
height:
|
|
3091
|
-
ascent:
|
|
3090
|
+
height: A,
|
|
3091
|
+
ascent: m,
|
|
3092
3092
|
// A tab-positioned line stays ragged (its manual x must not be re-justified);
|
|
3093
3093
|
// pure wrapped continuation lines justify normally when the paragraph does.
|
|
3094
3094
|
lastOfSegment: L || M,
|
|
3095
3095
|
...d.length > 0 ? { leaders: d } : {}
|
|
3096
|
-
}),
|
|
3096
|
+
}), f = [], d = [], S = 0, A = 0, m = 0, M = !1;
|
|
3097
3097
|
};
|
|
3098
3098
|
return s.forEach((L, w) => {
|
|
3099
3099
|
if (w > 0) {
|
|
3100
|
-
const P =
|
|
3100
|
+
const P = ms(S, x, i), W = P.align ?? "left", H = tt(L.runs.map((p) => p.text).join(""), fe(L.runs[0]?.style ?? c ?? sn)), z = S + H <= i;
|
|
3101
3101
|
let C = P.posPx;
|
|
3102
|
-
z && W === "right" ? C = P.posPx - H : z && W === "center" ? C = P.posPx - H / 2 : z && W === "decimal" && (C = P.posPx -
|
|
3102
|
+
z && W === "right" ? C = P.posPx - H : z && W === "center" ? C = P.posPx - H / 2 : z && W === "decimal" && (C = P.posPx - As(L.runs)), C < S && (C = S), (P.leader ?? "none") !== "none" && C > S + 1 && c && d.push({ x1: S, x2: C, kind: P.leader ?? "none", color: c.color, fontSizePx: c.fontSizePx }), S = C, M = !0;
|
|
3103
3103
|
}
|
|
3104
3104
|
if (L.runs.length === 0) return;
|
|
3105
|
-
const R = { prepared:
|
|
3105
|
+
const R = { prepared: Fs(L.runs), runs: L.runs, startOffset: L.start }, N = ct(L.runs, L.start), D = L.runs.map(() => 0);
|
|
3106
3106
|
let E, T = !0;
|
|
3107
3107
|
for (; ; ) {
|
|
3108
|
-
const P = Math.max(24, i - (T ? S : 0)), W =
|
|
3108
|
+
const P = Math.max(24, i - (T ? S : 0)), W = at(e, R, P, E, N, D);
|
|
3109
3109
|
if (W === null) break;
|
|
3110
3110
|
T || v(!1);
|
|
3111
3111
|
const H = T ? S : 0;
|
|
3112
3112
|
for (const z of W.frags)
|
|
3113
|
-
z.frag.x += H,
|
|
3114
|
-
S = H + W.width,
|
|
3113
|
+
z.frag.x += H, f.push(z);
|
|
3114
|
+
S = H + W.width, A = Math.max(A, W.height), m = Math.max(m, W.ascent), E = W.end, T = !1;
|
|
3115
3115
|
}
|
|
3116
3116
|
}), v(!0), a;
|
|
3117
3117
|
}
|
|
3118
|
-
function
|
|
3119
|
-
|
|
3118
|
+
function rn(e, t) {
|
|
3119
|
+
if (t <= 0) return;
|
|
3120
|
+
const n = e.reduce((s, l) => s + l.spaces + (l.hadGap ? 1 : 0), 0);
|
|
3121
|
+
if (n <= 0) return;
|
|
3122
|
+
const i = t / n;
|
|
3123
|
+
let r = 0;
|
|
3124
|
+
for (const s of e)
|
|
3125
|
+
s.hadGap && (r += i), s.frag.x += r, s.spaces > 0 && (s.frag.wordSpacingPx = i, s.frag.width += s.spaces * i, r += s.spaces * i);
|
|
3126
|
+
}
|
|
3127
|
+
function xn(e, t, n) {
|
|
3128
|
+
const i = n.get(e), r = [], s = [];
|
|
3120
3129
|
let l = !0;
|
|
3121
3130
|
for (const o of i) {
|
|
3122
3131
|
if (o.runs.some((d) => d.text.includes(" "))) {
|
|
3123
|
-
s.push(...
|
|
3132
|
+
s.push(...Es(e, o.runs, o.startOffset, t, l ? e.style.indentFirstLinePx : 0)), l = !1;
|
|
3124
3133
|
continue;
|
|
3125
3134
|
}
|
|
3126
|
-
const
|
|
3127
|
-
let a,
|
|
3135
|
+
const x = ct(o.runs, o.startOffset), c = o.runs.map(() => 0);
|
|
3136
|
+
let a, f = !1;
|
|
3128
3137
|
for (; ; ) {
|
|
3129
|
-
const d = l ? e.style.indentFirstLinePx : 0, S = t - d,
|
|
3130
|
-
if (
|
|
3138
|
+
const d = l ? e.style.indentFirstLinePx : 0, S = t - d, A = at(e, o, S, a, x, c);
|
|
3139
|
+
if (A === null) break;
|
|
3131
3140
|
s.push({
|
|
3132
|
-
frags:
|
|
3133
|
-
width:
|
|
3141
|
+
frags: A.frags,
|
|
3142
|
+
width: A.width,
|
|
3134
3143
|
indent: d,
|
|
3135
3144
|
lineMaxWidth: S,
|
|
3136
|
-
height:
|
|
3137
|
-
ascent:
|
|
3145
|
+
height: A.height,
|
|
3146
|
+
ascent: A.ascent,
|
|
3138
3147
|
lastOfSegment: !1
|
|
3139
|
-
}), a =
|
|
3148
|
+
}), a = A.end, l = !1, f = !0;
|
|
3140
3149
|
}
|
|
3141
|
-
if (
|
|
3150
|
+
if (f)
|
|
3142
3151
|
s[s.length - 1].lastOfSegment = !0;
|
|
3143
3152
|
else {
|
|
3144
|
-
const d =
|
|
3153
|
+
const d = nn(e);
|
|
3145
3154
|
s.push({
|
|
3146
3155
|
frags: [],
|
|
3147
3156
|
width: 0,
|
|
@@ -3154,98 +3163,88 @@ function sn(e, t, n) {
|
|
|
3154
3163
|
}), l = !1;
|
|
3155
3164
|
}
|
|
3156
3165
|
}
|
|
3157
|
-
let
|
|
3166
|
+
let u = 0;
|
|
3158
3167
|
for (const o of s) {
|
|
3159
|
-
const
|
|
3168
|
+
const x = o.lineMaxWidth - o.width;
|
|
3160
3169
|
let c = o.indent;
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
if (u > 0) {
|
|
3166
|
-
const d = r / u;
|
|
3167
|
-
let S = 0;
|
|
3168
|
-
for (const p of o.frags)
|
|
3169
|
-
p.hadGap && (S += d), p.frag.x += S, p.spaces > 0 && (p.frag.wordSpacingPx = d, p.frag.width += p.spaces * d, S += p.spaces * d);
|
|
3170
|
-
}
|
|
3171
|
-
}
|
|
3172
|
-
for (const u of o.frags) u.frag.x += c;
|
|
3173
|
-
const a = { y: f, height: o.height, ascent: o.ascent, fragments: o.frags.map((u) => u.frag) };
|
|
3174
|
-
o.emptyOffset !== void 0 && (a.emptyOffset = o.emptyOffset), o.leaders && o.leaders.length > 0 && (a.leaders = o.leaders.map((u) => ({ ...u, x1: u.x1 + c, x2: u.x2 + c }))), x.push(a), f += o.height;
|
|
3170
|
+
e.style.align === "center" ? c += x / 2 : e.style.align === "right" ? c += x : e.style.align === "justify" && !o.lastOfSegment && rn(o.frags, x);
|
|
3171
|
+
for (const f of o.frags) f.frag.x += c;
|
|
3172
|
+
const a = { y: u, height: o.height, ascent: o.ascent, fragments: o.frags.map((f) => f.frag) };
|
|
3173
|
+
o.emptyOffset !== void 0 && (a.emptyOffset = o.emptyOffset), o.leaders && o.leaders.length > 0 && (a.leaders = o.leaders.map((f) => ({ ...f, x1: f.x1 + c, x2: f.x2 + c }))), r.push(a), u += o.height;
|
|
3175
3174
|
}
|
|
3176
|
-
return
|
|
3175
|
+
return r;
|
|
3177
3176
|
}
|
|
3178
|
-
const
|
|
3179
|
-
function
|
|
3177
|
+
const Gt = 2, Ht = 2, Bs = 48, on = ["header", "footer", "headerFirst", "headerEven", "footerFirst", "footerEven"];
|
|
3178
|
+
function Ms(e, t) {
|
|
3180
3179
|
const n = {
|
|
3181
3180
|
pageWidthPx: t.pageWidthPx ?? e.pageWidthPx,
|
|
3182
3181
|
pageHeightPx: t.pageHeightPx ?? e.pageHeightPx,
|
|
3183
3182
|
marginPx: t.marginPx ?? e.marginPx
|
|
3184
3183
|
}, i = t.columns === void 0 ? e.columns : t.columns ?? void 0;
|
|
3185
3184
|
i && (n.columns = i), t.pageNumberStart !== void 0 && (n.pageNumberStart = t.pageNumberStart);
|
|
3186
|
-
const
|
|
3187
|
-
|
|
3185
|
+
const r = t.headerDistancePx ?? e.headerDistancePx;
|
|
3186
|
+
r !== void 0 && (n.headerDistancePx = r);
|
|
3188
3187
|
const s = t.footerDistancePx ?? e.footerDistancePx;
|
|
3189
3188
|
s !== void 0 && (n.footerDistancePx = s);
|
|
3190
|
-
for (const l of
|
|
3191
|
-
const
|
|
3192
|
-
|
|
3189
|
+
for (const l of on) {
|
|
3190
|
+
const u = t[l] ?? e[l];
|
|
3191
|
+
u && (n[l] = u);
|
|
3193
3192
|
}
|
|
3194
3193
|
return n;
|
|
3195
3194
|
}
|
|
3196
|
-
function
|
|
3195
|
+
function _t(e, t) {
|
|
3197
3196
|
return e.headerDistancePx !== void 0 ? e.headerDistancePx : Math.max(8, (e.marginPx.top - t) / 2);
|
|
3198
3197
|
}
|
|
3199
|
-
function
|
|
3198
|
+
function zt(e, t) {
|
|
3200
3199
|
return e.footerDistancePx !== void 0 ? e.pageHeightPx - e.footerDistancePx - t : e.pageHeightPx - Math.max(8, (e.marginPx.bottom - t) / 2) - t;
|
|
3201
3200
|
}
|
|
3202
|
-
function
|
|
3201
|
+
function Cs(e) {
|
|
3203
3202
|
const t = [];
|
|
3204
3203
|
for (let n = 0; n < e.blocks.length; n++) {
|
|
3205
3204
|
const i = e.blocks[n];
|
|
3206
|
-
i.kind === "paragraph" && i.style.sectionBreak && t.push({ props:
|
|
3205
|
+
i.kind === "paragraph" && i.style.sectionBreak && t.push({ props: Ms(e.section, i.style.sectionBreak.props), endBlock: n });
|
|
3207
3206
|
}
|
|
3208
3207
|
return t.push({ props: e.section, endBlock: e.blocks.length - 1 }), t;
|
|
3209
3208
|
}
|
|
3210
|
-
function
|
|
3209
|
+
function ks(e, t, n, i) {
|
|
3211
3210
|
const s = /* @__PURE__ */ new Map();
|
|
3212
3211
|
let l = null;
|
|
3213
|
-
const
|
|
3212
|
+
const u = (h) => {
|
|
3214
3213
|
const F = s.get(h);
|
|
3215
3214
|
if (F) return F;
|
|
3216
3215
|
let g = h.marginPx.top, B = h.pageHeightPx - h.marginPx.bottom;
|
|
3217
|
-
const I = [h.header, h.headerFirst, h.headerEven].filter((_) => !!_),
|
|
3218
|
-
if (I.length > 0 ||
|
|
3219
|
-
l ??= new
|
|
3220
|
-
const _ = h.pageWidthPx - h.marginPx.left - h.marginPx.right,
|
|
3221
|
-
const
|
|
3222
|
-
for (const
|
|
3223
|
-
if (
|
|
3216
|
+
const I = [h.header, h.headerFirst, h.headerEven].filter((_) => !!_), b = [h.footer, h.footerFirst, h.footerEven].filter((_) => !!_);
|
|
3217
|
+
if (I.length > 0 || b.length > 0) {
|
|
3218
|
+
l ??= new Ze();
|
|
3219
|
+
const _ = h.pageWidthPx - h.marginPx.left - h.marginPx.right, j = h.marginPx.left, X = (V) => Ie(V, _, j, 999, 999, l, !1).height, K = (V) => {
|
|
3220
|
+
const ee = Ie(V, _, j, 999, 999, l, !1);
|
|
3221
|
+
for (const $ of ee.placed)
|
|
3222
|
+
if (!!$.table || !!$.image || $.lines.some((Me) => Me.fragments.some((ae) => ae.text.trim().length > 0))) return ee.height - $.y;
|
|
3224
3223
|
return 0;
|
|
3225
|
-
}, Q = I.reduce((
|
|
3224
|
+
}, Q = I.reduce((V, ee) => Math.max(V, X(ee)), 0);
|
|
3226
3225
|
if (Q > 0) {
|
|
3227
|
-
const
|
|
3228
|
-
g = Math.max(g,
|
|
3226
|
+
const V = _t(h, Q);
|
|
3227
|
+
g = Math.max(g, V + Q + 6);
|
|
3229
3228
|
}
|
|
3230
|
-
const
|
|
3231
|
-
if (
|
|
3229
|
+
const q = b.reduce((V, ee) => Math.max(V, X(ee)), 0);
|
|
3230
|
+
if (q > 0)
|
|
3232
3231
|
if (h.footerDistancePx !== void 0) {
|
|
3233
|
-
const
|
|
3234
|
-
B = Math.min(B,
|
|
3232
|
+
const V = h.pageHeightPx - h.footerDistancePx, ee = b.reduce(($, me) => Math.max($, K(me)), 0);
|
|
3233
|
+
B = Math.min(B, V - ee);
|
|
3235
3234
|
} else
|
|
3236
|
-
B = Math.min(B,
|
|
3235
|
+
B = Math.min(B, zt(h, q) - 6);
|
|
3237
3236
|
B = Math.max(B, g + 24);
|
|
3238
3237
|
}
|
|
3239
3238
|
const G = { top: g, bottom: B };
|
|
3240
3239
|
return s.set(h, G), G;
|
|
3241
|
-
}, o =
|
|
3242
|
-
let
|
|
3240
|
+
}, o = Cs(e);
|
|
3241
|
+
let x = o[0].props, c = 0, a = 0, f = 0, d = 0, S = 1, A = 0, m = 0;
|
|
3243
3242
|
const M = (h) => {
|
|
3244
|
-
|
|
3245
|
-
const F =
|
|
3246
|
-
c =
|
|
3243
|
+
x = h;
|
|
3244
|
+
const F = u(x);
|
|
3245
|
+
c = x.marginPx.left, a = F.top, f = F.bottom, d = x.pageWidthPx - x.marginPx.left - x.marginPx.right, S = Math.max(1, x.columns?.count ?? 1), A = x.columns?.gapPx ?? 24, m = S > 1 ? (d - (S - 1) * A) / S : d;
|
|
3247
3246
|
};
|
|
3248
|
-
M(
|
|
3247
|
+
M(x);
|
|
3249
3248
|
const v = e.lists ?? {}, L = (h) => {
|
|
3250
3249
|
const F = h.style.list;
|
|
3251
3250
|
if (!F) return null;
|
|
@@ -3256,11 +3255,11 @@ function Cs(e, t, n, i) {
|
|
|
3256
3255
|
if (!F || !g) return;
|
|
3257
3256
|
const B = v[F.listId], I = D.get(F.listId) ?? [];
|
|
3258
3257
|
I[F.level] = (I[F.level] ?? g.start - 1) + 1, I.length = F.level + 1, D.set(F.listId, I);
|
|
3259
|
-
const
|
|
3260
|
-
if (
|
|
3258
|
+
const b = us(B, F.level, I);
|
|
3259
|
+
if (b.length === 0) return;
|
|
3261
3260
|
const G = h.runs[0]?.style;
|
|
3262
3261
|
G && E.set(h.id, {
|
|
3263
|
-
text:
|
|
3262
|
+
text: b,
|
|
3264
3263
|
style: { ...G, ...g.markerStyle ?? {} },
|
|
3265
3264
|
hangingPx: g.hangingPx
|
|
3266
3265
|
});
|
|
@@ -3276,197 +3275,197 @@ function Cs(e, t, n, i) {
|
|
|
3276
3275
|
for (; h > o[z].endBlock; ) M(o[++z].props);
|
|
3277
3276
|
const F = e.blocks[h];
|
|
3278
3277
|
if (F.kind === "paragraph") {
|
|
3279
|
-
if (
|
|
3280
|
-
const g = F.style.tocEntry ?
|
|
3278
|
+
if (ps(F)) continue;
|
|
3279
|
+
const g = F.style.tocEntry ? Bs : 0;
|
|
3281
3280
|
H.push({
|
|
3282
3281
|
kind: "para",
|
|
3283
3282
|
block: F,
|
|
3284
|
-
lines: t(F,
|
|
3283
|
+
lines: t(F, m - w(F) - R(F) - g)
|
|
3285
3284
|
});
|
|
3286
3285
|
} else if (F.kind === "image")
|
|
3287
3286
|
H.push({ kind: "image", block: F, height: F.heightPx });
|
|
3288
3287
|
else {
|
|
3289
|
-
const g =
|
|
3288
|
+
const g = ut(F, m, t, W);
|
|
3290
3289
|
H.push({ kind: "table", block: F, ...g });
|
|
3291
3290
|
}
|
|
3292
3291
|
}
|
|
3293
3292
|
z = 0, M(o[0].props);
|
|
3294
|
-
const C = [],
|
|
3293
|
+
const C = [], p = () => (C.push(x), {
|
|
3295
3294
|
index: C.length - 1,
|
|
3296
3295
|
number: C.length,
|
|
3297
3296
|
// provisional; the post-pass sets the real value
|
|
3298
3297
|
blocks: [],
|
|
3299
|
-
widthPx:
|
|
3300
|
-
heightPx:
|
|
3301
|
-
marginPx:
|
|
3298
|
+
widthPx: x.pageWidthPx,
|
|
3299
|
+
heightPx: x.pageHeightPx,
|
|
3300
|
+
marginPx: x.marginPx,
|
|
3302
3301
|
contentTopPx: a,
|
|
3303
|
-
contentBottomPx:
|
|
3304
|
-
}), y = [
|
|
3305
|
-
let k = y[0],
|
|
3306
|
-
const U = /* @__PURE__ */ new Map(), J = 14,
|
|
3302
|
+
contentBottomPx: f
|
|
3303
|
+
}), y = [p()];
|
|
3304
|
+
let k = y[0], O = a;
|
|
3305
|
+
const U = /* @__PURE__ */ new Map(), J = 14, Y = 18, te = e.footnotes ?? {}, ne = Object.keys(te).length > 0;
|
|
3307
3306
|
let he = 0;
|
|
3308
|
-
const Z = () =>
|
|
3307
|
+
const Z = () => f - he, le = /* @__PURE__ */ new Set(), xe = [[]], He = [0], dt = /* @__PURE__ */ new Map(), Ft = (h) => {
|
|
3309
3308
|
const F = te[h];
|
|
3310
3309
|
if (!F || F.length === 0) return null;
|
|
3311
|
-
const g = Math.max(40, d -
|
|
3310
|
+
const g = Math.max(40, d - Y);
|
|
3312
3311
|
let B = 0;
|
|
3313
|
-
return { paras: F.map((
|
|
3314
|
-
const G = t(
|
|
3315
|
-
return B +=
|
|
3312
|
+
return { paras: F.map((b) => {
|
|
3313
|
+
const G = t(b, g);
|
|
3314
|
+
return B += b.style.spaceBeforePx + pe(G) + b.style.spaceAfterPx, { p: b, lines: G };
|
|
3316
3315
|
}), height: B };
|
|
3317
|
-
},
|
|
3316
|
+
}, cn = (h, F, g) => {
|
|
3318
3317
|
const B = [];
|
|
3319
3318
|
for (let I = F; I < F + g; I++)
|
|
3320
|
-
for (const
|
|
3321
|
-
const G =
|
|
3322
|
-
G && te[G] && !le.has(G) && !B.some(([_]) => _ === G) && B.push([G,
|
|
3319
|
+
for (const b of h[I].fragments) {
|
|
3320
|
+
const G = b.style.footnoteRef;
|
|
3321
|
+
G && te[G] && !le.has(G) && !B.some(([_]) => _ === G) && B.push([G, b.text]);
|
|
3323
3322
|
}
|
|
3324
3323
|
return B;
|
|
3325
3324
|
};
|
|
3326
|
-
let
|
|
3327
|
-
const ce = () => c +
|
|
3328
|
-
|
|
3325
|
+
let Se = 0, Oe = 0;
|
|
3326
|
+
const ce = () => c + Se * (m + A), se = () => k.blocks.length > Oe, _e = () => {
|
|
3327
|
+
Se = 0, Oe = 0, k = p(), y.push(k), xe.push([]), He.push(0), he = 0, O = a, de = [];
|
|
3329
3328
|
}, ie = () => {
|
|
3330
|
-
|
|
3331
|
-
},
|
|
3332
|
-
k.blocks.length === 0 ? (k.widthPx =
|
|
3333
|
-
},
|
|
3329
|
+
Se + 1 < S ? (Se++, Oe = k.blocks.length, O = a, de = []) : _e();
|
|
3330
|
+
}, an = () => {
|
|
3331
|
+
k.blocks.length === 0 ? (k.widthPx = x.pageWidthPx, k.heightPx = x.pageHeightPx, k.marginPx = x.marginPx, k.contentTopPx = a, k.contentBottomPx = f, C[k.index] = x, Se = 0, Oe = 0, O = a, de = []) : _e();
|
|
3332
|
+
}, un = (h, F, g, B) => {
|
|
3334
3333
|
const I = {
|
|
3335
3334
|
blockId: h.id,
|
|
3336
3335
|
x: ce() + w(h),
|
|
3337
|
-
y:
|
|
3336
|
+
y: O,
|
|
3338
3337
|
firstLineIndex: g,
|
|
3339
3338
|
lines: []
|
|
3340
|
-
},
|
|
3341
|
-
|
|
3339
|
+
}, b = g === 0 ? E.get(h.id) : void 0;
|
|
3340
|
+
b && (I.marker = { text: b.text, style: b.style, x: I.x - b.hangingPx }), h.style.tocEntry && U.set(h.id, { chunk: I, rightEdge: ce() + m, para: h }), k.blocks.push(I);
|
|
3342
3341
|
for (let G = g; G < g + B; G++) {
|
|
3343
3342
|
const _ = F[G];
|
|
3344
|
-
I.lines.push({ ..._, y:
|
|
3343
|
+
I.lines.push({ ..._, y: O - I.y }), O += _.height;
|
|
3345
3344
|
}
|
|
3346
|
-
},
|
|
3347
|
-
let g = 0, B =
|
|
3345
|
+
}, fn = (h, F) => {
|
|
3346
|
+
let g = 0, B = O;
|
|
3348
3347
|
for (; F + g < h.length && B + h[F + g].height <= Z(); )
|
|
3349
3348
|
B += h[F + g].height, g++;
|
|
3350
3349
|
return g;
|
|
3351
|
-
},
|
|
3352
|
-
let F =
|
|
3350
|
+
}, gt = (h) => {
|
|
3351
|
+
let F = xe[k.index].length === 0 ? J : 0;
|
|
3353
3352
|
const g = [];
|
|
3354
3353
|
for (const [B, I] of h) {
|
|
3355
|
-
const
|
|
3356
|
-
|
|
3354
|
+
const b = Ft(B);
|
|
3355
|
+
b && (F += b.height, g.push([B, I, b]));
|
|
3357
3356
|
}
|
|
3358
3357
|
return { H: F, measures: g };
|
|
3359
|
-
},
|
|
3358
|
+
}, Nt = (h, F) => {
|
|
3360
3359
|
for (const [g, B] of h)
|
|
3361
|
-
le.add(g),
|
|
3362
|
-
he += F,
|
|
3363
|
-
},
|
|
3360
|
+
le.add(g), xe[k.index].push(g), dt.set(g, B);
|
|
3361
|
+
he += F, He[k.index] = he;
|
|
3362
|
+
}, hn = (h) => {
|
|
3364
3363
|
const F = [], g = (B) => {
|
|
3365
3364
|
for (const I of B)
|
|
3366
3365
|
if (I.kind === "paragraph") {
|
|
3367
|
-
let
|
|
3366
|
+
let b = 0;
|
|
3368
3367
|
for (const G of I.runs) {
|
|
3369
3368
|
const _ = G.style.footnoteRef;
|
|
3370
|
-
_ && te[_] && !le.has(_) && !F.some(([
|
|
3369
|
+
_ && te[_] && !le.has(_) && !F.some(([j]) => j === _) && F.push([_, G.text]), b += G.text.length;
|
|
3371
3370
|
}
|
|
3372
3371
|
} else if (I.kind === "table")
|
|
3373
|
-
for (const
|
|
3372
|
+
for (const b of I.rows) for (const G of b.cells) g(G.blocks);
|
|
3374
3373
|
};
|
|
3375
3374
|
for (const B of h) for (const I of B.cells) g(I.blocks);
|
|
3376
3375
|
return F;
|
|
3377
|
-
},
|
|
3376
|
+
}, dn = (h, F, g) => {
|
|
3378
3377
|
for (; ; ) {
|
|
3379
3378
|
if (g <= 0) return g;
|
|
3380
|
-
const B =
|
|
3379
|
+
const B = cn(h, F, g);
|
|
3381
3380
|
if (B.length === 0) return g;
|
|
3382
|
-
const { H: I, measures:
|
|
3383
|
-
if (
|
|
3381
|
+
const { H: I, measures: b } = gt(B);
|
|
3382
|
+
if (b.length === 0) return g;
|
|
3384
3383
|
let G = 0;
|
|
3385
|
-
for (let
|
|
3386
|
-
if (
|
|
3387
|
-
return
|
|
3384
|
+
for (let j = F; j < F + g; j++) G += h[j].height;
|
|
3385
|
+
if (O + G + I <= Z() || g === 1 && !se())
|
|
3386
|
+
return Nt(b, I), g;
|
|
3388
3387
|
g--;
|
|
3389
3388
|
}
|
|
3390
|
-
},
|
|
3389
|
+
}, Fn = (h, F) => {
|
|
3391
3390
|
if (h.style.keepLinesTogether === !0 && se()) {
|
|
3392
|
-
const B =
|
|
3393
|
-
|
|
3391
|
+
const B = pe(F);
|
|
3392
|
+
O + B > Z() && B <= f - a && ie();
|
|
3394
3393
|
}
|
|
3395
3394
|
let g = 0;
|
|
3396
3395
|
for (; g < F.length; ) {
|
|
3397
|
-
const B = F.length - g, I =
|
|
3398
|
-
let
|
|
3399
|
-
if (I >= B ?
|
|
3396
|
+
const B = F.length - g, I = fn(F, g);
|
|
3397
|
+
let b;
|
|
3398
|
+
if (I >= B ? b = B : (b = I, B - b === 1 && (b -= Ht - 1), g === 0 && b > 0 && b < Gt && (b = 0), b <= 0 && (b = se() ? 0 : Math.max(1, I))), b > 0 && ne && (b = dn(F, g, b)), b > 0 && (un(h, F, g, b), g += b), g >= F.length) return;
|
|
3400
3399
|
ie();
|
|
3401
3400
|
}
|
|
3402
|
-
},
|
|
3401
|
+
}, pe = (h) => {
|
|
3403
3402
|
let F = 0;
|
|
3404
3403
|
for (const g of h) F += g.height;
|
|
3405
3404
|
return F;
|
|
3406
3405
|
};
|
|
3407
|
-
let
|
|
3408
|
-
const
|
|
3409
|
-
let F = ce(), g = ce() +
|
|
3410
|
-
for (const B of
|
|
3411
|
-
h >= B.bottom || (B.side === "left" ? F = Math.max(F, B.right +
|
|
3406
|
+
let de = [];
|
|
3407
|
+
const St = 10, gn = (h) => {
|
|
3408
|
+
let F = ce(), g = ce() + m;
|
|
3409
|
+
for (const B of de)
|
|
3410
|
+
h >= B.bottom || (B.side === "left" ? F = Math.max(F, B.right + St) : g = Math.min(g, B.left - St));
|
|
3412
3411
|
return { x0: F, width: Math.max(40, g - F) };
|
|
3413
|
-
},
|
|
3414
|
-
|
|
3415
|
-
const F = h.wrap === "square" && h.align !== "center", g =
|
|
3412
|
+
}, Nn = (h) => de.some((F) => F.bottom > h), Sn = (h) => {
|
|
3413
|
+
O + h.heightPx > Z() && se() && ie();
|
|
3414
|
+
const F = h.wrap === "square" && h.align !== "center", g = m - h.widthPx, B = ce() + (h.align === "center" ? g / 2 : h.align === "right" ? g : 0);
|
|
3416
3415
|
k.blocks.push({
|
|
3417
3416
|
blockId: h.id,
|
|
3418
3417
|
x: B,
|
|
3419
|
-
y:
|
|
3418
|
+
y: O,
|
|
3420
3419
|
firstLineIndex: 0,
|
|
3421
3420
|
lines: [],
|
|
3422
3421
|
image: { src: h.src, width: h.widthPx, height: h.heightPx }
|
|
3423
|
-
}), F ?
|
|
3424
|
-
},
|
|
3422
|
+
}), F ? de.push({ left: B, right: B + h.widthPx, bottom: O + h.heightPx, side: h.align === "right" ? "right" : "left" }) : O += h.heightPx;
|
|
3423
|
+
}, pn = (h) => {
|
|
3425
3424
|
const F = n(h);
|
|
3426
3425
|
let g = !0, B = 0, I = null;
|
|
3427
|
-
const
|
|
3426
|
+
const b = (G, _, j, X) => {
|
|
3428
3427
|
if (I === null) {
|
|
3429
|
-
I = { blockId: h.id, x: ce() + w(h), y:
|
|
3428
|
+
I = { blockId: h.id, x: ce() + w(h), y: O, firstLineIndex: B, lines: [] };
|
|
3430
3429
|
const Q = B === 0 ? E.get(h.id) : void 0;
|
|
3431
3430
|
Q && (I.marker = { text: Q.text, style: Q.style, x: I.x - Q.hangingPx }), k.blocks.push(I);
|
|
3432
3431
|
}
|
|
3433
|
-
const
|
|
3434
|
-
|
|
3432
|
+
const K = { y: O - I.y, height: _, ascent: j, fragments: G.map((Q) => Q.frag) };
|
|
3433
|
+
X !== void 0 && (K.emptyOffset = X), I.lines.push(K), O += _, B++;
|
|
3435
3434
|
};
|
|
3436
3435
|
for (const G of F) {
|
|
3437
|
-
const _ =
|
|
3438
|
-
let
|
|
3436
|
+
const _ = ct(G.runs, G.startOffset), j = G.runs.map(() => 0);
|
|
3437
|
+
let X, K = !1, Q = null;
|
|
3439
3438
|
for (; ; ) {
|
|
3440
|
-
const
|
|
3439
|
+
const q = j.slice(), V = gn(O), ee = g ? h.style.indentFirstLinePx : 0, $ = at(
|
|
3441
3440
|
h,
|
|
3442
3441
|
G,
|
|
3443
|
-
Math.max(24, V.width - w(h) -
|
|
3444
|
-
|
|
3442
|
+
Math.max(24, V.width - w(h) - ee - R(h)),
|
|
3443
|
+
X,
|
|
3445
3444
|
_,
|
|
3446
|
-
|
|
3445
|
+
j
|
|
3447
3446
|
);
|
|
3448
|
-
if (
|
|
3449
|
-
if (
|
|
3450
|
-
for (let ae = 0; ae <
|
|
3447
|
+
if ($ === null) break;
|
|
3448
|
+
if (O + $.height > Z() && se()) {
|
|
3449
|
+
for (let ae = 0; ae < j.length; ae++) j[ae] = q[ae];
|
|
3451
3450
|
ie(), I = null;
|
|
3452
3451
|
continue;
|
|
3453
3452
|
}
|
|
3454
|
-
const
|
|
3455
|
-
let
|
|
3456
|
-
h.style.align === "center" ?
|
|
3457
|
-
for (const ae of
|
|
3458
|
-
|
|
3453
|
+
const me = V.width - ee - R(h) - $.width;
|
|
3454
|
+
let Me = V.x0 - ce() + ee;
|
|
3455
|
+
h.style.align === "center" ? Me += me / 2 : h.style.align === "right" && (Me += me);
|
|
3456
|
+
for (const ae of $.frags) ae.frag.x += Me;
|
|
3457
|
+
h.style.align === "justify" && (Q && rn(Q.frags, Q.slack), Q = { frags: $.frags, slack: me }), b($.frags, $.height, $.ascent), X = $.end, g = !1, K = !0;
|
|
3459
3458
|
}
|
|
3460
|
-
if (!
|
|
3461
|
-
const
|
|
3462
|
-
|
|
3459
|
+
if (!K) {
|
|
3460
|
+
const q = nn(h);
|
|
3461
|
+
O + q.height > Z() && se() && (ie(), I = null), b([], q.height, q.ascent, G.startOffset), g = !1;
|
|
3463
3462
|
}
|
|
3464
3463
|
}
|
|
3465
|
-
},
|
|
3466
|
-
h.block.rows.some((B) => B.cells.some((I) => (I.rowSpan ?? 1) > 1)) && se() &&
|
|
3464
|
+
}, mn = (h) => {
|
|
3465
|
+
h.block.rows.some((B) => B.cells.some((I) => (I.rowSpan ?? 1) > 1)) && se() && O + h.height > Z() && h.height <= f - a && ie();
|
|
3467
3466
|
let g = 0;
|
|
3468
3467
|
for (; g < h.rows.length; ) {
|
|
3469
|
-
let B = 0, I =
|
|
3468
|
+
let B = 0, I = O;
|
|
3470
3469
|
for (; g + B < h.rows.length && I + h.rows[g + B].height <= Z(); )
|
|
3471
3470
|
I += h.rows[g + B].height, B++;
|
|
3472
3471
|
if (B === 0) {
|
|
@@ -3476,16 +3475,16 @@ function Cs(e, t, n, i) {
|
|
|
3476
3475
|
}
|
|
3477
3476
|
B = 1;
|
|
3478
3477
|
}
|
|
3479
|
-
let
|
|
3478
|
+
let b = [], G = 0;
|
|
3480
3479
|
for (; ; ) {
|
|
3481
|
-
const
|
|
3482
|
-
if (K.length === 0) break;
|
|
3483
|
-
const { H: Y, measures: j } = Ft(K);
|
|
3480
|
+
const j = hn(h.block.rows.slice(g, g + B));
|
|
3484
3481
|
if (j.length === 0) break;
|
|
3482
|
+
const { H: X, measures: K } = gt(j);
|
|
3483
|
+
if (K.length === 0) break;
|
|
3485
3484
|
let Q = 0;
|
|
3486
|
-
for (let
|
|
3487
|
-
if (
|
|
3488
|
-
|
|
3485
|
+
for (let q = g; q < g + B; q++) Q += h.rows[q].height;
|
|
3486
|
+
if (O + Q + X <= Z() || B === 1 && !se()) {
|
|
3487
|
+
b = K, G = X;
|
|
3489
3488
|
break;
|
|
3490
3489
|
}
|
|
3491
3490
|
if (B--, B === 0) break;
|
|
@@ -3494,143 +3493,145 @@ function Cs(e, t, n, i) {
|
|
|
3494
3493
|
ie();
|
|
3495
3494
|
continue;
|
|
3496
3495
|
}
|
|
3497
|
-
|
|
3496
|
+
b.length > 0 && Nt(b, G);
|
|
3498
3497
|
const _ = h.rows.slice(g, g + B);
|
|
3499
|
-
k.blocks.push(
|
|
3498
|
+
k.blocks.push(ht(h.block, _, h.colWidths, ce(), O, m, g, W)), O += _.reduce((j, X) => j + X.height, 0), g += B, g < h.rows.length && ie();
|
|
3500
3499
|
}
|
|
3501
3500
|
};
|
|
3502
3501
|
for (let h = 0; h < H.length; h++) {
|
|
3503
3502
|
if (h > o[z].endBlock) {
|
|
3504
3503
|
for (; h > o[z].endBlock; ) M(o[++z].props);
|
|
3505
|
-
|
|
3504
|
+
an();
|
|
3506
3505
|
}
|
|
3507
3506
|
const F = H[h], g = (_) => _?.kind === "table" || _?.kind === "image", B = g(H[h - 1]), I = g(H[h + 1]);
|
|
3508
3507
|
if (F.kind === "image") {
|
|
3509
|
-
B || (
|
|
3508
|
+
B || (O += Ce), Sn(F.block), !I && (F.block.wrap !== "square" || F.block.align === "center") && (O += Ce);
|
|
3510
3509
|
continue;
|
|
3511
3510
|
}
|
|
3512
3511
|
if (F.kind === "table") {
|
|
3513
|
-
B || (
|
|
3512
|
+
B || (O += Ce);
|
|
3513
|
+
for (const _ of de) _.bottom > O && (O = _.bottom);
|
|
3514
|
+
mn(F), I || (O += Ce);
|
|
3514
3515
|
continue;
|
|
3515
3516
|
}
|
|
3516
|
-
const { block:
|
|
3517
|
-
if (
|
|
3518
|
-
|
|
3517
|
+
const { block: b, lines: G } = F;
|
|
3518
|
+
if (b.style.pageBreakBefore === !0 && (k.blocks.length > 0 || Se > 0) ? _e() : b.style.columnBreakBefore === !0 && se() && ie(), O += b.style.spaceBeforePx, O >= Z() && se() && ie(), Nn(O)) {
|
|
3519
|
+
pn(b), O += b.style.spaceAfterPx;
|
|
3519
3520
|
continue;
|
|
3520
3521
|
}
|
|
3521
|
-
if (
|
|
3522
|
-
let _ =
|
|
3523
|
-
for (let
|
|
3524
|
-
const
|
|
3525
|
-
if (
|
|
3526
|
-
if (
|
|
3527
|
-
const
|
|
3528
|
-
_ +
|
|
3522
|
+
if (b.style.keepWithNext === !0 && H[h + 1] !== void 0 && se()) {
|
|
3523
|
+
let _ = O + pe(G) + b.style.spaceAfterPx, j = _ <= Z();
|
|
3524
|
+
for (let X = h + 1; j; X++) {
|
|
3525
|
+
const K = H[X];
|
|
3526
|
+
if (K === void 0) break;
|
|
3527
|
+
if (K.kind !== "para") {
|
|
3528
|
+
const $ = K.kind === "table" ? K.rows[0]?.height ?? K.height : K.height;
|
|
3529
|
+
_ + Ce + $ > Z() && (j = !1);
|
|
3529
3530
|
break;
|
|
3530
3531
|
}
|
|
3531
|
-
_ +=
|
|
3532
|
-
const Q =
|
|
3533
|
-
if (Q ||
|
|
3534
|
-
const
|
|
3535
|
-
if (_ +
|
|
3536
|
-
|
|
3532
|
+
_ += K.block.style.spaceBeforePx;
|
|
3533
|
+
const Q = K.block.style.keepWithNext === !0 && H[X + 1] !== void 0;
|
|
3534
|
+
if (Q || K.block.style.keepLinesTogether === !0) {
|
|
3535
|
+
const $ = pe(K.lines);
|
|
3536
|
+
if (_ + $ > Z()) {
|
|
3537
|
+
j = !1;
|
|
3537
3538
|
break;
|
|
3538
3539
|
}
|
|
3539
|
-
if (_ +=
|
|
3540
|
+
if (_ += $ + K.block.style.spaceAfterPx, !Q) break;
|
|
3540
3541
|
continue;
|
|
3541
3542
|
}
|
|
3542
|
-
if (H[
|
|
3543
|
-
const
|
|
3544
|
-
if (_ +
|
|
3545
|
-
|
|
3543
|
+
if (H[X + 1] !== void 0 && K.block.runs.every(($) => $.text.trim().length === 0)) {
|
|
3544
|
+
const $ = pe(K.lines);
|
|
3545
|
+
if (_ + $ > Z()) {
|
|
3546
|
+
j = !1;
|
|
3546
3547
|
break;
|
|
3547
3548
|
}
|
|
3548
|
-
_ +=
|
|
3549
|
+
_ += $ + K.block.style.spaceAfterPx;
|
|
3549
3550
|
continue;
|
|
3550
3551
|
}
|
|
3551
|
-
let
|
|
3552
|
-
for (;
|
|
3553
|
-
|
|
3554
|
-
let
|
|
3555
|
-
|
|
3552
|
+
let q = 0, V = _;
|
|
3553
|
+
for (; q < K.lines.length && V + K.lines[q].height <= Z(); )
|
|
3554
|
+
V += K.lines[q].height, q++;
|
|
3555
|
+
let ee = q;
|
|
3556
|
+
q < K.lines.length && (K.lines.length - ee === 1 && (ee -= Ht - 1), ee < Gt && (ee = 0)), ee <= 0 && (j = !1);
|
|
3556
3557
|
break;
|
|
3557
3558
|
}
|
|
3558
|
-
|
|
3559
|
+
j || ie();
|
|
3559
3560
|
}
|
|
3560
|
-
|
|
3561
|
+
Fn(b, G), O += b.style.spaceAfterPx;
|
|
3561
3562
|
}
|
|
3562
3563
|
for (const h of y) {
|
|
3563
|
-
const F =
|
|
3564
|
+
const F = xe[h.index];
|
|
3564
3565
|
if (!F || F.length === 0) continue;
|
|
3565
3566
|
const g = C[h.index];
|
|
3566
3567
|
M(g);
|
|
3567
|
-
let B =
|
|
3568
|
+
let B = f - He[h.index];
|
|
3568
3569
|
h.footnoteRuleY = B + 4, B += J;
|
|
3569
3570
|
const I = g.marginPx.left;
|
|
3570
|
-
for (const
|
|
3571
|
-
const G =
|
|
3571
|
+
for (const b of F) {
|
|
3572
|
+
const G = Ft(b);
|
|
3572
3573
|
if (!G) continue;
|
|
3573
3574
|
let _ = !0;
|
|
3574
|
-
for (const
|
|
3575
|
-
B +=
|
|
3576
|
-
const
|
|
3577
|
-
blockId:
|
|
3578
|
-
x: I +
|
|
3575
|
+
for (const j of G.paras) {
|
|
3576
|
+
B += j.p.style.spaceBeforePx;
|
|
3577
|
+
const X = {
|
|
3578
|
+
blockId: j.p.id,
|
|
3579
|
+
x: I + Y,
|
|
3579
3580
|
y: B,
|
|
3580
3581
|
firstLineIndex: 0,
|
|
3581
|
-
lines:
|
|
3582
|
+
lines: j.lines
|
|
3582
3583
|
};
|
|
3583
|
-
_ &&
|
|
3584
|
+
_ && j.p.runs[0] && (X.marker = { text: `${dt.get(b) ?? "•"}.`, style: j.p.runs[0].style, x: I }, _ = !1), h.blocks.push(X), B += pe(j.lines) + j.p.style.spaceAfterPx;
|
|
3584
3585
|
}
|
|
3585
3586
|
}
|
|
3586
3587
|
}
|
|
3587
|
-
const
|
|
3588
|
+
const ze = [];
|
|
3588
3589
|
{
|
|
3589
3590
|
let h = 0;
|
|
3590
3591
|
for (let F = 0; F < y.length; F++) {
|
|
3591
3592
|
const g = C[F];
|
|
3592
|
-
(F === 0 || C[F - 1] !== g) && g.pageNumberStart !== void 0 ? h = g.pageNumberStart : h++,
|
|
3593
|
+
(F === 0 || C[F - 1] !== g) && g.pageNumberStart !== void 0 ? h = g.pageNumberStart : h++, ze.push(h), y[F].number = h;
|
|
3593
3594
|
}
|
|
3594
3595
|
}
|
|
3595
3596
|
if (U.size > 0) {
|
|
3596
3597
|
const h = /* @__PURE__ */ new Map(), F = (g, B) => {
|
|
3597
3598
|
for (const I of g)
|
|
3598
|
-
if (h.has(I.blockId) || h.set(I.blockId, B), I.table) for (const
|
|
3599
|
+
if (h.has(I.blockId) || h.set(I.blockId, B), I.table) for (const b of I.table.rows) for (const G of b.cells) F(G.blocks, B);
|
|
3599
3600
|
};
|
|
3600
|
-
for (const g of y) F(g.blocks,
|
|
3601
|
+
for (const g of y) F(g.blocks, ze[g.index]);
|
|
3601
3602
|
for (const g of U.values()) {
|
|
3602
3603
|
const B = g.para.style.tocEntry.targetId, I = h.get(B);
|
|
3603
3604
|
if (I === void 0) continue;
|
|
3604
|
-
const
|
|
3605
|
-
if (!
|
|
3605
|
+
const b = g.para.runs[0]?.style;
|
|
3606
|
+
if (!b || g.chunk.lines.length === 0) continue;
|
|
3606
3607
|
const G = String(I);
|
|
3607
3608
|
g.chunk.toc = {
|
|
3608
3609
|
numText: G,
|
|
3609
|
-
numX: g.rightEdge -
|
|
3610
|
+
numX: g.rightEdge - tt(G, fe(b)),
|
|
3610
3611
|
lineIndex: g.chunk.lines.length - 1,
|
|
3611
|
-
style:
|
|
3612
|
+
style: b
|
|
3612
3613
|
};
|
|
3613
3614
|
}
|
|
3614
3615
|
}
|
|
3615
|
-
const
|
|
3616
|
-
const I = F === "header" ? h.headerFirst : h.footerFirst,
|
|
3616
|
+
const pt = (h, F, g, B) => {
|
|
3617
|
+
const I = F === "header" ? h.headerFirst : h.footerFirst, b = F === "header" ? h.headerEven : h.footerEven;
|
|
3617
3618
|
if (g && I) return { blocks: I, source: F === "header" ? "headerFirst" : "footerFirst" };
|
|
3618
|
-
if (B &&
|
|
3619
|
+
if (B && b) return { blocks: b, source: F === "header" ? "headerEven" : "footerEven" };
|
|
3619
3620
|
const G = h[F];
|
|
3620
3621
|
return G ? { blocks: G, source: F } : null;
|
|
3621
3622
|
};
|
|
3622
|
-
if (C.some((h) =>
|
|
3623
|
-
const h = new
|
|
3623
|
+
if (C.some((h) => on.some((F) => h[F]))) {
|
|
3624
|
+
const h = new Ze();
|
|
3624
3625
|
for (const F of y) {
|
|
3625
|
-
const g = C[F.index], B = g.pageWidthPx - g.marginPx.left - g.marginPx.right, I = g.marginPx.left,
|
|
3626
|
-
if (
|
|
3627
|
-
const
|
|
3628
|
-
F.header = Q.placed.map((
|
|
3626
|
+
const g = C[F.index], B = g.pageWidthPx - g.marginPx.left - g.marginPx.right, I = g.marginPx.left, b = F.index === 0 || C[F.index - 1] !== g, G = ze[F.index], _ = G % 2 === 0, j = pt(g, "header", b, _);
|
|
3627
|
+
if (j) {
|
|
3628
|
+
const K = i === "header", Q = Ie(j.blocks, B, I, G, y.length, h, K), q = _t(g, Q.height);
|
|
3629
|
+
F.header = Q.placed.map((V) => et(V, q)), F.headerSource = j.source;
|
|
3629
3630
|
}
|
|
3630
|
-
const
|
|
3631
|
-
if (
|
|
3632
|
-
const
|
|
3633
|
-
F.footer = Q.placed.map((
|
|
3631
|
+
const X = pt(g, "footer", b, _);
|
|
3632
|
+
if (X) {
|
|
3633
|
+
const K = i === "footer", Q = Ie(X.blocks, B, I, G, y.length, h, K), q = zt(g, Q.height);
|
|
3634
|
+
F.footer = Q.placed.map((V) => et(V, q)), F.footerSource = X.source;
|
|
3634
3635
|
}
|
|
3635
3636
|
}
|
|
3636
3637
|
}
|
|
@@ -3641,67 +3642,67 @@ function Cs(e, t, n, i) {
|
|
|
3641
3642
|
marginPx: e.section.marginPx
|
|
3642
3643
|
};
|
|
3643
3644
|
}
|
|
3644
|
-
function
|
|
3645
|
+
function Ds(e, t) {
|
|
3645
3646
|
switch (t) {
|
|
3646
3647
|
case "roman":
|
|
3647
|
-
return
|
|
3648
|
+
return ke(e, "lowerRoman");
|
|
3648
3649
|
case "Roman":
|
|
3649
|
-
return
|
|
3650
|
+
return ke(e, "upperRoman");
|
|
3650
3651
|
case "alpha":
|
|
3651
|
-
return
|
|
3652
|
+
return ke(e, "lowerLetter");
|
|
3652
3653
|
case "Alpha":
|
|
3653
|
-
return
|
|
3654
|
+
return ke(e, "upperLetter");
|
|
3654
3655
|
default:
|
|
3655
3656
|
return String(e);
|
|
3656
3657
|
}
|
|
3657
3658
|
}
|
|
3658
|
-
function Ds(e, t, n) {
|
|
3659
|
-
return e.replace(/\{page(?::(roman|Roman|alpha|Alpha))?\}/g, (i, x) => ks(t, x)).replace(/\{pages\}/g, String(n)).replace(/\{date\}/g, () => (/* @__PURE__ */ new Date()).toLocaleDateString()).replace(/\{time\}/g, () => (/* @__PURE__ */ new Date()).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }));
|
|
3660
|
-
}
|
|
3661
3659
|
function Ls(e, t, n) {
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3660
|
+
return e.replace(/\{page(?::(roman|Roman|alpha|Alpha))?\}/g, (i, r) => Ds(t, r)).replace(/\{pages\}/g, String(n)).replace(/\{date\}/g, () => (/* @__PURE__ */ new Date()).toLocaleDateString()).replace(/\{time\}/g, () => (/* @__PURE__ */ new Date()).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }));
|
|
3661
|
+
}
|
|
3662
|
+
function Os(e, t, n) {
|
|
3663
|
+
const i = (r) => r.runs.some((s) => s.text.includes("{")) ? {
|
|
3664
|
+
...r,
|
|
3665
|
+
id: `${r.id}@p${t}`,
|
|
3665
3666
|
// per-page identity keeps the band prepare-cache honest
|
|
3666
|
-
runs:
|
|
3667
|
-
} :
|
|
3667
|
+
runs: r.runs.map((s) => ({ ...s, text: Ls(s.text, t, n) }))
|
|
3668
|
+
} : r;
|
|
3668
3669
|
return e.kind === "paragraph" ? i(e) : e.kind === "table" ? {
|
|
3669
3670
|
...e,
|
|
3670
|
-
rows: e.rows.map((
|
|
3671
|
-
cells:
|
|
3671
|
+
rows: e.rows.map((r) => ({
|
|
3672
|
+
cells: r.cells.map((s) => ({
|
|
3672
3673
|
...s,
|
|
3673
3674
|
blocks: s.blocks.map((l) => l.kind === "paragraph" ? i(l) : l)
|
|
3674
3675
|
}))
|
|
3675
3676
|
}))
|
|
3676
3677
|
} : e;
|
|
3677
3678
|
}
|
|
3678
|
-
function
|
|
3679
|
-
const
|
|
3680
|
-
let
|
|
3679
|
+
function Ie(e, t, n, i, r, s, l) {
|
|
3680
|
+
const u = (c, a) => xn(c, a, s), o = [];
|
|
3681
|
+
let x = 0;
|
|
3681
3682
|
for (const c of e) {
|
|
3682
|
-
const a = l ? c :
|
|
3683
|
+
const a = l ? c : Os(c, i, r);
|
|
3683
3684
|
if (a.kind === "paragraph") {
|
|
3684
|
-
|
|
3685
|
-
const
|
|
3686
|
-
o.push({ blockId: a.id, x: n + a.style.indentLeftPx, y:
|
|
3685
|
+
x += a.style.spaceBeforePx;
|
|
3686
|
+
const f = u(a, t);
|
|
3687
|
+
o.push({ blockId: a.id, x: n + a.style.indentLeftPx, y: x, firstLineIndex: 0, lines: f }), x += ft(f) + a.style.spaceAfterPx;
|
|
3687
3688
|
} else if (a.kind === "image") {
|
|
3688
|
-
const
|
|
3689
|
+
const f = t - a.widthPx, d = n + (a.align === "center" ? f / 2 : a.align === "right" ? f : 0);
|
|
3689
3690
|
o.push({
|
|
3690
3691
|
blockId: a.id,
|
|
3691
3692
|
x: d,
|
|
3692
|
-
y:
|
|
3693
|
+
y: x,
|
|
3693
3694
|
firstLineIndex: 0,
|
|
3694
3695
|
lines: [],
|
|
3695
3696
|
image: { src: a.src, width: a.widthPx, height: a.heightPx }
|
|
3696
|
-
}),
|
|
3697
|
+
}), x += a.heightPx;
|
|
3697
3698
|
} else {
|
|
3698
|
-
const
|
|
3699
|
-
o.push(
|
|
3699
|
+
const f = ut(a, t, u, jt);
|
|
3700
|
+
o.push(ht(a, f.rows, f.colWidths, n, x, t, 0, jt)), x += f.height;
|
|
3700
3701
|
}
|
|
3701
3702
|
}
|
|
3702
|
-
return { placed: o, height:
|
|
3703
|
+
return { placed: o, height: x };
|
|
3703
3704
|
}
|
|
3704
|
-
function
|
|
3705
|
+
function et(e, t) {
|
|
3705
3706
|
const n = { ...e, y: e.y + t };
|
|
3706
3707
|
return e.table && (n.table = {
|
|
3707
3708
|
...e.table,
|
|
@@ -3709,85 +3710,85 @@ function Ze(e, t) {
|
|
|
3709
3710
|
rows: e.table.rows.map((i) => ({
|
|
3710
3711
|
...i,
|
|
3711
3712
|
y: i.y + t,
|
|
3712
|
-
cells: i.cells.map((
|
|
3713
|
-
...
|
|
3714
|
-
y:
|
|
3715
|
-
blocks:
|
|
3713
|
+
cells: i.cells.map((r) => ({
|
|
3714
|
+
...r,
|
|
3715
|
+
y: r.y + t,
|
|
3716
|
+
blocks: r.blocks.map((s) => et(s, t))
|
|
3716
3717
|
}))
|
|
3717
3718
|
}))
|
|
3718
3719
|
}), n;
|
|
3719
3720
|
}
|
|
3720
|
-
const
|
|
3721
|
-
function
|
|
3722
|
-
const s =
|
|
3721
|
+
const Ce = 12, bs = { top: 0, right: 7.2, bottom: 0, left: 7.2 }, ln = (e) => e.margin ?? bs, De = 4, jt = { indentOf: () => 0, markers: /* @__PURE__ */ new Map() };
|
|
3722
|
+
function ut(e, t, n, i) {
|
|
3723
|
+
const s = hs(e).map((c) => c * t), l = s.length, u = new Array(l).fill(0), o = e.rows.map((c) => {
|
|
3723
3724
|
let a = 0;
|
|
3724
|
-
const
|
|
3725
|
-
for (; a < l &&
|
|
3726
|
-
const S = Math.max(1, d.colSpan ?? 1),
|
|
3725
|
+
const f = c.cells.map((d) => {
|
|
3726
|
+
for (; a < l && u[a] > 0; ) a++;
|
|
3727
|
+
const S = Math.max(1, d.colSpan ?? 1), A = Math.max(1, d.rowSpan ?? 1), m = a;
|
|
3727
3728
|
let M = 0;
|
|
3728
3729
|
for (let N = 0; N < S; N++) M += s[a + N] ?? s[l - 1] ?? 40;
|
|
3729
|
-
if (
|
|
3730
|
+
if (A > 1) for (let N = 0; N < S && a + N < l; N++) u[a + N] = A;
|
|
3730
3731
|
a += S;
|
|
3731
|
-
const v =
|
|
3732
|
+
const v = ln(d), L = Math.max(8, M - v.left - v.right);
|
|
3732
3733
|
let w = 0;
|
|
3733
3734
|
const R = d.blocks.map((N) => {
|
|
3734
3735
|
if (N.kind === "paragraph") {
|
|
3735
3736
|
const E = n(N, Math.max(8, L - i.indentOf(N)));
|
|
3736
|
-
return w += N.style.spaceBeforePx +
|
|
3737
|
+
return w += N.style.spaceBeforePx + ft(E) + N.style.spaceAfterPx, { kind: "para", block: N, lines: E };
|
|
3737
3738
|
}
|
|
3738
3739
|
if (N.kind === "image") {
|
|
3739
3740
|
const E = Math.min(1, L / Math.max(1, N.widthPx)), T = N.widthPx * E, P = N.heightPx * E;
|
|
3740
|
-
return w += P +
|
|
3741
|
+
return w += P + De, { kind: "image", block: N, width: T, height: P };
|
|
3741
3742
|
}
|
|
3742
|
-
const D =
|
|
3743
|
-
return w += D.height +
|
|
3743
|
+
const D = ut(N, L, n, i);
|
|
3744
|
+
return w += D.height + De, { kind: "table", block: N, ...D };
|
|
3744
3745
|
});
|
|
3745
|
-
return { cell: d, items: R, height: w + v.top + v.bottom, width: M, colStart:
|
|
3746
|
+
return { cell: d, items: R, height: w + v.top + v.bottom, width: M, colStart: m, rowSpan: A };
|
|
3746
3747
|
});
|
|
3747
|
-
for (let d = 0; d < l; d++)
|
|
3748
|
-
return { cells:
|
|
3749
|
-
}),
|
|
3748
|
+
for (let d = 0; d < l; d++) u[d] > 0 && u[d]--;
|
|
3749
|
+
return { cells: f, height: 0 };
|
|
3750
|
+
}), x = o.map((c) => Math.max(0, ...c.cells.filter((a) => a.rowSpan === 1).map((a) => a.height)));
|
|
3750
3751
|
return o.forEach((c, a) => {
|
|
3751
|
-
for (const
|
|
3752
|
-
if (
|
|
3753
|
-
const d = Math.min(o.length - 1, a +
|
|
3752
|
+
for (const f of c.cells) {
|
|
3753
|
+
if (f.rowSpan <= 1) continue;
|
|
3754
|
+
const d = Math.min(o.length - 1, a + f.rowSpan - 1);
|
|
3754
3755
|
let S = 0;
|
|
3755
|
-
for (let
|
|
3756
|
-
|
|
3756
|
+
for (let A = a; A <= d; A++) S += x[A];
|
|
3757
|
+
f.height > S && (x[d] += f.height - S);
|
|
3757
3758
|
}
|
|
3758
|
-
}), o.forEach((c, a) => c.height =
|
|
3759
|
+
}), o.forEach((c, a) => c.height = x[a]), { rows: o, colWidths: s, height: x.reduce((c, a) => c + a, 0) };
|
|
3759
3760
|
}
|
|
3760
|
-
function
|
|
3761
|
+
function ft(e) {
|
|
3761
3762
|
let t = 0;
|
|
3762
3763
|
for (const n of e) t += n.height;
|
|
3763
3764
|
return t;
|
|
3764
3765
|
}
|
|
3765
|
-
function
|
|
3766
|
+
function ht(e, t, n, i, r, s, l, u) {
|
|
3766
3767
|
const o = [0];
|
|
3767
|
-
for (const
|
|
3768
|
-
const
|
|
3769
|
-
for (const
|
|
3768
|
+
for (const f of n) o.push(o[o.length - 1] + f);
|
|
3769
|
+
const x = [r];
|
|
3770
|
+
for (const f of t) x.push(x[x.length - 1] + f.height);
|
|
3770
3771
|
const c = [];
|
|
3771
|
-
for (let
|
|
3772
|
-
const d = t[
|
|
3773
|
-
for (const
|
|
3774
|
-
const M = i + (o[
|
|
3772
|
+
for (let f = 0; f < t.length; f++) {
|
|
3773
|
+
const d = t[f], S = x[f], A = [];
|
|
3774
|
+
for (const m of d.cells) {
|
|
3775
|
+
const M = i + (o[m.colStart] ?? o[o.length - 1]), v = Math.min(t.length - 1, f + m.rowSpan - 1), L = x[v + 1] - S, w = [], R = ln(m.cell), N = m.width - R.left - R.right;
|
|
3775
3776
|
let D = S + R.top;
|
|
3776
|
-
for (const E of
|
|
3777
|
+
for (const E of m.items)
|
|
3777
3778
|
if (E.kind === "para") {
|
|
3778
3779
|
D += E.block.style.spaceBeforePx;
|
|
3779
|
-
const T = M + R.left + E.block.style.indentLeftPx +
|
|
3780
|
+
const T = M + R.left + E.block.style.indentLeftPx + u.indentOf(E.block), P = {
|
|
3780
3781
|
blockId: E.block.id,
|
|
3781
3782
|
x: T,
|
|
3782
3783
|
y: D,
|
|
3783
3784
|
firstLineIndex: 0,
|
|
3784
3785
|
lines: E.lines
|
|
3785
3786
|
// line.y is already block-relative; coords stay consistent
|
|
3786
|
-
}, W =
|
|
3787
|
-
W && (P.marker = { text: W.text, style: W.style, x: Math.max(M + 1, T - W.hangingPx) }), w.push(P), D +=
|
|
3787
|
+
}, W = u.markers.get(E.block.id);
|
|
3788
|
+
W && (P.marker = { text: W.text, style: W.style, x: Math.max(M + 1, T - W.hangingPx) }), w.push(P), D += ft(E.lines) + E.block.style.spaceAfterPx;
|
|
3788
3789
|
} else if (E.kind === "image") {
|
|
3789
3790
|
const T = L - R.top - R.bottom;
|
|
3790
|
-
if (
|
|
3791
|
+
if (m.items.length === 1 && T > E.height + 8) {
|
|
3791
3792
|
const P = Math.max(N / E.block.widthPx, T / E.block.heightPx), W = E.block.widthPx * P, H = E.block.heightPx * P, z = M + R.left, C = S + R.top;
|
|
3792
3793
|
w.push({
|
|
3793
3794
|
blockId: E.block.id,
|
|
@@ -3796,7 +3797,7 @@ function ft(e, t, n, i, x, s, l, f) {
|
|
|
3796
3797
|
firstLineIndex: 0,
|
|
3797
3798
|
lines: [],
|
|
3798
3799
|
image: { src: E.block.src, width: W, height: H, clip: { x: z, y: C, width: N, height: T } }
|
|
3799
|
-
}), D += E.height +
|
|
3800
|
+
}), D += E.height + De;
|
|
3800
3801
|
} else {
|
|
3801
3802
|
const P = N - E.width, W = M + R.left + (E.block.align === "center" ? P / 2 : E.block.align === "right" ? P : 0);
|
|
3802
3803
|
w.push({
|
|
@@ -3806,35 +3807,35 @@ function ft(e, t, n, i, x, s, l, f) {
|
|
|
3806
3807
|
firstLineIndex: 0,
|
|
3807
3808
|
lines: [],
|
|
3808
3809
|
image: { src: E.block.src, width: E.width, height: E.height }
|
|
3809
|
-
}), D += E.height +
|
|
3810
|
+
}), D += E.height + De;
|
|
3810
3811
|
}
|
|
3811
3812
|
} else
|
|
3812
|
-
w.push(
|
|
3813
|
-
|
|
3813
|
+
w.push(ht(E.block, E.rows, E.colWidths, M + R.left, D, N, 0, u)), D += E.height + De;
|
|
3814
|
+
A.push({
|
|
3814
3815
|
x: M,
|
|
3815
3816
|
y: S,
|
|
3816
|
-
width:
|
|
3817
|
+
width: m.width,
|
|
3817
3818
|
height: L,
|
|
3818
3819
|
blocks: w,
|
|
3819
|
-
...
|
|
3820
|
-
...
|
|
3820
|
+
...m.cell.shading !== void 0 ? { shading: m.cell.shading } : {},
|
|
3821
|
+
...m.cell.borders !== void 0 ? { borders: m.cell.borders } : {}
|
|
3821
3822
|
});
|
|
3822
3823
|
}
|
|
3823
|
-
c.push({ y: S, height: d.height, cells:
|
|
3824
|
+
c.push({ y: S, height: d.height, cells: A });
|
|
3824
3825
|
}
|
|
3825
|
-
const a = t.reduce((
|
|
3826
|
+
const a = t.reduce((f, d) => f + d.height, 0);
|
|
3826
3827
|
return {
|
|
3827
3828
|
blockId: e.id,
|
|
3828
3829
|
x: i,
|
|
3829
|
-
y:
|
|
3830
|
+
y: r,
|
|
3830
3831
|
firstLineIndex: l,
|
|
3831
3832
|
// for tables this is the chunk's first ROW index
|
|
3832
3833
|
lines: [],
|
|
3833
|
-
table: { x: i, y:
|
|
3834
|
+
table: { x: i, y: r, width: s, height: a, rows: c, colWidths: n }
|
|
3834
3835
|
};
|
|
3835
3836
|
}
|
|
3836
3837
|
export {
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3838
|
+
ys as createLayoutEngine,
|
|
3839
|
+
Ms as effectiveSection,
|
|
3840
|
+
Cs as resolveSections
|
|
3840
3841
|
};
|