@domorium/validator 2.0.0 → 2.0.1

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/dist/index.esm.js CHANGED
@@ -935,13 +935,13 @@ function j(e, t) {
935
935
  function me(e) {
936
936
  return `@#D${e}@`;
937
937
  }
938
- function M(e, t) {
938
+ function he(e, t) {
939
939
  let n = de.exec(t)?.[1];
940
940
  if (n !== void 0) return v(n);
941
941
  let r = v(t);
942
942
  return e.calendar[r] ? r : null;
943
943
  }
944
- function he(e) {
944
+ function ge(e) {
945
945
  let t = ue.exec(e);
946
946
  return t ? {
947
947
  calendar: v(t[1]),
@@ -951,18 +951,18 @@ function he(e) {
951
951
  rest: e
952
952
  };
953
953
  }
954
- function N(e) {
954
+ function _e(e) {
955
955
  return e.match(fe) ?? [];
956
956
  }
957
957
  //#endregion
958
958
  //#region src/validator/epoch.ts
959
- var ge = "(?:[Bb][Cc][Ee]|[Bb]\\.?[Cc]\\.?)", _e = RegExp(`^${ge}$`);
960
- function ve(e) {
961
- return e !== void 0 && _e.test(e);
959
+ var ve = "(?:[Bb][Cc][Ee]|[Bb]\\.?[Cc]\\.?)", ye = RegExp(`^${ve}$`);
960
+ function be(e) {
961
+ return e !== void 0 && ye.test(e);
962
962
  }
963
963
  //#endregion
964
964
  //#region src/validator/calendarDays.ts
965
- var ye = {
965
+ var xe = {
966
966
  JAN: 31,
967
967
  FEB: 29,
968
968
  MAR: 31,
@@ -975,28 +975,44 @@ var ye = {
975
975
  OCT: 31,
976
976
  NOV: 30,
977
977
  DEC: 31
978
- }, be = /* @__PURE__ */ new Set([O, "JULIAN"]), xe = /^\d+$/u;
979
- function Se(e, t) {
978
+ }, Se = /* @__PURE__ */ new Set([O, "JULIAN"]), Ce = /^\d+$/u, we = /* @__PURE__ */ new Set([
979
+ "ABT",
980
+ "AFT",
981
+ "AND",
982
+ "BEF",
983
+ "BET",
984
+ "CAL",
985
+ "EST",
986
+ "FROM",
987
+ "INT",
988
+ "TO"
989
+ ]);
990
+ function Te(e, t) {
980
991
  return e % 4 == 0 ? t === "JULIAN" || e % 100 != 0 || e % 400 == 0 : !1;
981
992
  }
982
- function Ce(e, t, n) {
983
- let r = ye[e];
984
- return r === void 0 ? null : e !== "FEB" || t === null ? r : Se(t, n) ? 29 : 28;
993
+ function Ee(e, t, n) {
994
+ let r = xe[e];
995
+ return r === void 0 ? null : e !== "FEB" || t === null ? r : Te(t, n) ? 29 : 28;
985
996
  }
986
- function we(e) {
997
+ function De(e) {
987
998
  return e.replace(/\([^()]*\)/gu, " ");
988
999
  }
989
- function Te(e, t) {
990
- let n = N(we(t)), r = [], i = O;
1000
+ function Oe(e, t) {
1001
+ let n = _e(De(t)), r = [], i = O;
991
1002
  for (let t = 0; t < n.length; t += 1) {
992
- let a = n[t], o = M(e, a);
1003
+ let a = n[t];
1004
+ if (we.has(a)) {
1005
+ i = O;
1006
+ continue;
1007
+ }
1008
+ let o = he(e, a);
993
1009
  if (o !== null) {
994
1010
  i = o;
995
1011
  continue;
996
1012
  }
997
1013
  let s = n[t + 1];
998
- if (!be.has(i) || !xe.test(a) || s === void 0 || ye[s] === void 0) continue;
999
- let c = Ce(s, xe.test(n[t + 2] ?? "") && !ve(n[t + 3]) ? Number(n[t + 2]) : null, i), l = Number(a);
1014
+ if (!Se.has(i) || !Ce.test(a) || s === void 0 || xe[s] === void 0) continue;
1015
+ let c = Ee(s, Ce.test(n[t + 2] ?? "") && !be(n[t + 3]) ? Number(n[t + 2]) : null, i), l = Number(a);
1000
1016
  c !== null && (l < 1 || l > c) && r.push({
1001
1017
  day: l,
1002
1018
  month: s,
@@ -1007,71 +1023,71 @@ function Te(e, t) {
1007
1023
  }
1008
1024
  //#endregion
1009
1025
  //#region src/validator/date-v7.ts
1010
- var P = /^\d+$/, Ee = [
1026
+ var M = /^\d+$/, ke = [
1011
1027
  "ABT",
1012
1028
  "CAL",
1013
1029
  "EST"
1014
- ], F = -1;
1015
- function I(e, t, n) {
1030
+ ], N = -1;
1031
+ function P(e, t, n) {
1016
1032
  let r = t, i = e[r];
1017
- if (i === void 0) return F;
1033
+ if (i === void 0) return N;
1018
1034
  let a = O;
1019
1035
  (n.calendar[v(i)] || C(i)) && (a = v(i), r += 1);
1020
1036
  let { months: o, epochs: s } = A(n, a);
1021
- return P.test(e[r] ?? "") && e[r + 1] !== void 0 && j(o, e[r + 1]) && P.test(e[r + 2] ?? "") ? r += 2 : e[r] !== void 0 && j(o, e[r]) && P.test(e[r + 1] ?? "") && (r += 1), P.test(e[r] ?? "") ? (r += 1, e[r] !== void 0 && j(s, e[r]) && (r += 1), r) : F;
1037
+ return M.test(e[r] ?? "") && e[r + 1] !== void 0 && j(o, e[r + 1]) && M.test(e[r + 2] ?? "") ? r += 2 : e[r] !== void 0 && j(o, e[r]) && M.test(e[r + 1] ?? "") && (r += 1), M.test(e[r] ?? "") ? (r += 1, e[r] !== void 0 && j(s, e[r]) && (r += 1), r) : N;
1022
1038
  }
1023
- function L(e, t, n) {
1024
- if (e[t] === "TO") return I(e, t + 1, n);
1025
- if (e[t] !== "FROM") return F;
1026
- let r = I(e, t + 1, n);
1027
- return r === F || e[r] !== "TO" ? r : I(e, r + 1, n);
1039
+ function F(e, t, n) {
1040
+ if (e[t] === "TO") return P(e, t + 1, n);
1041
+ if (e[t] !== "FROM") return N;
1042
+ let r = P(e, t + 1, n);
1043
+ return r === N || e[r] !== "TO" ? r : P(e, r + 1, n);
1028
1044
  }
1029
- function De(e, t, n) {
1045
+ function Ae(e, t, n) {
1030
1046
  let r = e[t];
1031
- if (r !== void 0 && Ee.includes(r)) return I(e, t + 1, n);
1047
+ if (r !== void 0 && ke.includes(r)) return P(e, t + 1, n);
1032
1048
  if (r === "BET") {
1033
- let r = I(e, t + 1, n);
1034
- return r === F || e[r] !== "AND" ? F : I(e, r + 1, n);
1049
+ let r = P(e, t + 1, n);
1050
+ return r === N || e[r] !== "AND" ? N : P(e, r + 1, n);
1035
1051
  }
1036
- return r === "AFT" || r === "BEF" ? I(e, t + 1, n) : r === "FROM" || r === "TO" ? L(e, t, n) : I(e, t, n);
1052
+ return r === "AFT" || r === "BEF" ? P(e, t + 1, n) : r === "FROM" || r === "TO" ? F(e, t, n) : P(e, t, n);
1037
1053
  }
1038
- function Oe(e) {
1054
+ function je(e) {
1039
1055
  return e.trim().split(/\s+/);
1040
1056
  }
1041
- function R(e, t) {
1042
- return Oe(e).map((e) => T(t, e));
1057
+ function I(e, t) {
1058
+ return je(e).map((e) => T(t, e));
1043
1059
  }
1044
- function z(e, t, n, r) {
1045
- let i = R(e, n);
1060
+ function L(e, t, n, r) {
1061
+ let i = I(e, n);
1046
1062
  return i.length > 0 && r(i, 0, t) === i.length;
1047
1063
  }
1048
- function ke(e, t, n = w()) {
1049
- return z(e, t, n, De);
1064
+ function Me(e, t, n = w()) {
1065
+ return L(e, t, n, Ae);
1050
1066
  }
1051
- function Ae(e, t, n = w()) {
1052
- return z(e, t, n, L);
1067
+ function Ne(e, t, n = w()) {
1068
+ return L(e, t, n, F);
1053
1069
  }
1054
- function je(e, t, n = w()) {
1055
- let r = R(e, n);
1070
+ function Pe(e, t, n = w()) {
1071
+ let r = I(e, n);
1056
1072
  if (r.length !== 3) return !1;
1057
1073
  let { months: i } = A(t, O);
1058
- return P.test(r[0]) && j(i, r[1]) && P.test(r[2]);
1074
+ return M.test(r[0]) && j(i, r[1]) && M.test(r[2]);
1059
1075
  }
1060
1076
  //#endregion
1061
1077
  //#region src/validator/rule-node.ts
1062
- var B = "@VOID@", Me = /* @__PURE__ */ new Set([
1078
+ var R = "@VOID@", Fe = /* @__PURE__ */ new Set([
1063
1079
  "http://www.w3.org/2001/XMLSchema#string",
1064
1080
  "https://gedcom.io/terms/v7/type-List#Text",
1065
1081
  "https://gedcom.io/terms/v7/type-Date",
1066
1082
  "https://gedcom.io/terms/v7/type-Date#period",
1067
1083
  "https://gedcom.io/terms/v7/type-Age"
1068
- ]), Ne = /* @__PURE__ */ new Set(["https://gedcom.io/terms/v5.5.1/NOTE-XREF_NOTE", "https://gedcom.io/terms/v5.5.1/SOUR-XREF_SOUR"]), Pe = /* @__PURE__ */ new Set(["https://gedcom.io/terms/v5.5.1/enumset-MULTIMEDIA_FORMAT"]), Fe = "https://gedcom.io/terms/v7/", V = 10;
1069
- function Ie(e) {
1084
+ ]), Ie = /* @__PURE__ */ new Set(["https://gedcom.io/terms/v5.5.1/NOTE-XREF_NOTE", "https://gedcom.io/terms/v5.5.1/SOUR-XREF_SOUR"]), Le = /* @__PURE__ */ new Set(["https://gedcom.io/terms/v5.5.1/enumset-MULTIMEDIA_FORMAT"]), Re = "https://gedcom.io/terms/v7/", z = 10;
1085
+ function ze(e) {
1070
1086
  if (!e?.length) return "";
1071
- let t = e.slice(0, V).join(", "), n = e.length - V;
1087
+ let t = e.slice(0, z).join(", "), n = e.length - z;
1072
1088
  return n > 0 ? `${t}, … ${n} more` : t;
1073
1089
  }
1074
- function H(e, t, n = p.IncorrectValue) {
1090
+ function B(e, t, n = p.IncorrectValue) {
1075
1091
  return {
1076
1092
  code: _(e).trim() ? n : p.MissingValue,
1077
1093
  message: `Value for ${e.tokens.TAG?.value} ${t}`,
@@ -1079,31 +1095,51 @@ function H(e, t, n = p.IncorrectValue) {
1079
1095
  level: "error"
1080
1096
  };
1081
1097
  }
1082
- function Le(e, t, n) {
1083
- return Te(e, n).map(({ day: e, month: n, length: r }) => H(t, `names ${e} ${n}, and ${n} has ${r} days`, p.ImpossibleDay));
1098
+ function Be(e, t, n) {
1099
+ return Oe(e, n).map(({ day: e, month: n, length: r }) => B(t, `names ${e} ${n}, and ${n} has ${r} days`, p.ImpossibleDay));
1084
1100
  }
1085
- var U = "(?:[01]?\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?", Re = RegExp(`^${U}$`), ze = RegExp(`^${U}Z?$`), W = "(?:CHILD|INFANT|STILLBORN|\\d+y(?:\\s\\d+m)?(?:\\s\\d+w)?(?:\\s\\d+d)?|\\d+m(?:\\s\\d+w)?(?:\\s\\d+d)?|\\d+w(?:\\s\\d+d)?|\\d+d)", Be = RegExp(`^(?:[<>]\\s)?${W}$`), Ve = RegExp(`^(?:[<>]\\s*)?${W}$`, "i"), He = /^[^/]*(?:\/[^/]*\/[^/]*)?$/, Ue = /^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*\/[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*(;\s*[\w-]+=[^;]+)*$/, We = /^\d+$/, Ge = /^[NS]\d+(\.\d+)?$/, Ke = /^[EW]\d+(\.\d+)?$/, qe = /* @__PURE__ */ RegExp("^(?:(?:en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE|art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)|(?:(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4}|[A-Za-z]{5,8})(?:-[A-Za-z]{4})?(?:-(?:[A-Za-z]{2}|[0-9]{3}))?(?:-(?:[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(?:-[0-9A-WY-Za-wy-z](?:-[A-Za-z0-9]{2,8})+)*(?:-x(?:-[A-Za-z0-9]{1,8})+)?)|(?:x(?:-[A-Za-z0-9]{1,8})+))$", "i"), G = "\\d+(?:/\\d{2})?", K = /* @__PURE__ */ new WeakMap();
1086
- function Je(e) {
1087
- let t = `(?:${e.join("|")})`, n = `${`(?:(?:\\d{1,2}\\s)?${t}\\s)?${G}`}(?:\\s?${ge})?`, r = `FROM\\s${n}(?:\\sTO\\s${n})?|TO\\s${n}`;
1101
+ var V = "(?:[01]?\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?", Ve = RegExp(`^${V}$`), He = RegExp(`^${V}Z?$`), H = "(?:CHILD|INFANT|STILLBORN|\\d+y(?:\\s\\d+m)?(?:\\s\\d+w)?(?:\\s\\d+d)?|\\d+m(?:\\s\\d+w)?(?:\\s\\d+d)?|\\d+w(?:\\s\\d+d)?|\\d+d)", Ue = RegExp(`^(?:[<>]\\s)?${H}$`), We = RegExp(`^(?:[<>]\\s*)?${H}$`, "i"), Ge = /^[^/]*(?:\/[^/]*\/[^/]*)?$/, Ke = /^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*\/[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*(;\s*[\w-]+=[^;]+)*$/, qe = /^\d+$/, Je = /^[NS]\d+(\.\d+)?$/, Ye = /^[EW]\d+(\.\d+)?$/, Xe = /* @__PURE__ */ RegExp("^(?:(?:en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE|art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)|(?:(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4}|[A-Za-z]{5,8})(?:-[A-Za-z]{4})?(?:-(?:[A-Za-z]{2}|[0-9]{3}))?(?:-(?:[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(?:-[0-9A-WY-Za-wy-z](?:-[A-Za-z0-9]{2,8})+)*(?:-x(?:-[A-Za-z0-9]{1,8})+)?)|(?:x(?:-[A-Za-z0-9]{1,8})+))$", "i"), U = "\\d+(?:/\\d{2})?", W = /* @__PURE__ */ new WeakMap();
1102
+ function Ze(e) {
1103
+ let t = `(?:${e.join("|")})`, n = `(?:(?:\\d{1,2}\\s)?${t}\\s)?${U}`;
1088
1104
  return {
1089
- value: RegExp(`^(?:(?:ABT|CAL|EST)\\s${n}|(?:BEF|AFT)\\s${n}|BET\\s${n}\\sAND\\s${n}|` + r + `|INT\\s${n}\\s\\([^()]*\\)|${n}|\\([^()]*\\))\$`),
1090
- period: RegExp(`^(?:${r})$`),
1091
- exact: RegExp(`^\\d{1,2}\\s${t}\\s${G}$`)
1105
+ dated: RegExp(`^${n}(?:\\s?${ve})?$`),
1106
+ exact: RegExp(`^\\d{1,2}\\s${t}\\s${U}$`)
1092
1107
  };
1093
1108
  }
1094
- function Ye(e, t) {
1095
- let n = K.get(e);
1096
- n || (n = /* @__PURE__ */ new Map(), K.set(e, n));
1109
+ function G(e, t) {
1110
+ let n = W.get(e);
1111
+ n || (n = /* @__PURE__ */ new Map(), W.set(e, n));
1097
1112
  let r = n.get(t);
1098
1113
  if (r !== void 0) return r;
1099
- let i = Object.keys(e.calendar[v(t)]?.months ?? {}), a = i.length === 0 ? null : Je(i);
1114
+ let i = Object.keys(e.calendar[v(t)]?.months ?? {}), a = i.length === 0 ? null : Ze(i);
1100
1115
  return n.set(t, a), a;
1101
1116
  }
1102
- function q(e, t, n) {
1103
- let { calendar: r, rest: i } = he(t), a = Ye(e, r ?? O);
1104
- return a === null ? !!i : a[n].test(i);
1117
+ function K(e, t) {
1118
+ let { calendar: n, rest: r } = ge(t), i = G(e, n ?? O);
1119
+ return i === null ? r.length > 0 : i.dated.test(r);
1120
+ }
1121
+ var Qe = /^INT\s(.+)\s\([^()]*\)$/, $e = /^\([^()]*\)$/, et = /^(?:ABT|CAL|EST|BEF|AFT)\s(.+)$/, tt = /^BET\s(.+)\sAND\s(.+)$/, nt = /^FROM\s(.+)\sTO\s(.+)$/, q = /^FROM\s(.+)$/, J = /^TO\s(.+)$/;
1122
+ function rt(e, t) {
1123
+ let n = nt.exec(t);
1124
+ if (n) return K(e, n[1]) && K(e, n[2]);
1125
+ let r = q.exec(t) ?? J.exec(t);
1126
+ return r !== null && K(e, r[1]);
1105
1127
  }
1106
- var Xe = {
1128
+ function it(e, t) {
1129
+ if ($e.test(t)) return !0;
1130
+ let n = Qe.exec(t);
1131
+ if (n) return K(e, n[1]);
1132
+ let r = tt.exec(t);
1133
+ if (r) return K(e, r[1]) && K(e, r[2]);
1134
+ if (q.test(t) || J.test(t)) return rt(e, t);
1135
+ let i = et.exec(t);
1136
+ return i ? K(e, i[1]) : K(e, t);
1137
+ }
1138
+ function at(e, t) {
1139
+ let n = G(e, O);
1140
+ return n === null ? t.length > 0 : n.exact.test(t);
1141
+ }
1142
+ var ot = {
1107
1143
  "Y|<NULL>": "boolean",
1108
1144
  "http://www.w3.org/2001/XMLSchema#string": "string",
1109
1145
  "https://gedcom.io/terms/v7/type-List#Text": "string",
@@ -1155,25 +1191,25 @@ var Xe = {
1155
1191
  "https://gedcom.io/terms/v5.5.1/type-TIME_VALUE": "time",
1156
1192
  "https://gedcom.io/terms/v7/type-Age": "age-v7",
1157
1193
  "https://gedcom.io/terms/v5.5.1/type-AGE_AT_EVENT": "age"
1158
- }, Ze = {
1194
+ }, st = {
1159
1195
  latitude: {
1160
- test: (e) => Ge.test(e),
1196
+ test: (e) => Je.test(e),
1161
1197
  message: "should be correct latitude (e.g. \"N18.150944\")"
1162
1198
  },
1163
1199
  longitude: {
1164
- test: (e) => Ke.test(e),
1200
+ test: (e) => Ye.test(e),
1165
1201
  message: "should be correct longitude (e.g. \"W46.6\")"
1166
1202
  },
1167
1203
  "personal-name": {
1168
- test: (e) => He.test(e),
1204
+ test: (e) => Ge.test(e),
1169
1205
  message: "should be a name, with the surname (if any) wrapped in a single pair of slashes (e.g. \"John /Doe/\")"
1170
1206
  },
1171
1207
  "media-type": {
1172
- test: (e) => Ue.test(e),
1208
+ test: (e) => Ke.test(e),
1173
1209
  message: "should be a media type in the form \"type/subtype\" (e.g. \"image/jpeg\")"
1174
1210
  },
1175
1211
  "language-tag": {
1176
- test: (e) => qe.test(e),
1212
+ test: (e) => Xe.test(e),
1177
1213
  message: "should be a valid RFC 5646 language tag (e.g. \"en\", \"en-US\")"
1178
1214
  },
1179
1215
  "tag-def": {
@@ -1181,58 +1217,58 @@ var Xe = {
1181
1217
  message: "should be an extension tag and its URI (e.g. \"_SKYPEID http://xmlns.com/foaf/0.1/skypeID\")"
1182
1218
  },
1183
1219
  nonNegativeInteger: {
1184
- test: (e) => We.test(e),
1220
+ test: (e) => qe.test(e),
1185
1221
  message: "should be a whole number, zero or greater"
1186
1222
  },
1187
1223
  time: {
1188
- test: (e) => Re.test(e),
1224
+ test: (e) => Ve.test(e),
1189
1225
  message: "should be correct time"
1190
1226
  },
1191
1227
  "time-v7": {
1192
- test: (e) => ze.test(e),
1228
+ test: (e) => He.test(e),
1193
1229
  message: "should be correct time"
1194
1230
  },
1195
1231
  age: {
1196
- test: (e) => Ve.test(e),
1232
+ test: (e) => We.test(e),
1197
1233
  message: "should be correct age (e.g. \"35y 11m 8w 21d\", \"< 1y\", \"CHILD\")"
1198
1234
  },
1199
1235
  "age-v7": {
1200
- test: (e) => Be.test(e),
1236
+ test: (e) => Ue.test(e),
1201
1237
  message: "should be correct age (e.g. \"35y 11m 8w 21d\", \"< 1y\", \"CHILD\")"
1202
1238
  },
1203
1239
  date: {
1204
- test: (e, t) => q(t, e, "value"),
1240
+ test: (e, t) => it(t, e),
1205
1241
  message: "should be a valid date value (e.g. \"12 JAN 2000\", \"ABT 1950\", \"BET 1900 AND 1910\", \"FROM 1900 TO 1910\", \"@#DJULIAN@ 3 MAR 1721\", \"(unknown)\")",
1206
1242
  calendarDays: !0
1207
1243
  },
1208
1244
  "date-v7": {
1209
- test: ke,
1245
+ test: Me,
1210
1246
  message: "should be a valid date value (e.g. \"12 JAN 2000\", \"ABT 1950\", \"BET 1900 AND 1910\", \"JULIAN 3 MAR 1721\", \"1000 BCE\")",
1211
1247
  calendarDays: !0
1212
1248
  },
1213
1249
  "date-period": {
1214
- test: (e, t) => q(t, e, "period"),
1250
+ test: (e, t) => rt(t, e),
1215
1251
  message: "should be a valid date period (e.g. \"FROM 1900 TO 1910\", \"TO 1920\")",
1216
1252
  calendarDays: !0
1217
1253
  },
1218
1254
  "date-period-v7": {
1219
- test: Ae,
1255
+ test: Ne,
1220
1256
  message: "should be a valid date period (e.g. \"FROM 1900 TO 1910\", \"TO 1920\")",
1221
1257
  calendarDays: !0
1222
1258
  },
1223
1259
  "date-exact": {
1224
- test: (e, t) => q(t, e, "exact"),
1260
+ test: (e, t) => at(t, e),
1225
1261
  message: "should be an exact date in day month year order (e.g. \"1 APR 1911\")",
1226
1262
  calendarDays: !0
1227
1263
  },
1228
1264
  "date-exact-v7": {
1229
- test: je,
1265
+ test: Pe,
1230
1266
  message: "should be an exact date in day month year order (e.g. \"1 APR 1911\")",
1231
1267
  calendarDays: !0
1232
1268
  }
1233
- }, J = /* @__PURE__ */ new WeakMap();
1234
- function Y(e, t) {
1235
- let n = J.get(e);
1269
+ }, ct = /* @__PURE__ */ new WeakMap();
1270
+ function lt(e, t) {
1271
+ let n = ct.get(e);
1236
1272
  if (n) return n;
1237
1273
  let r = /* @__PURE__ */ new Map();
1238
1274
  for (let n of e.values()) for (let e of n) {
@@ -1242,9 +1278,9 @@ function Y(e, t) {
1242
1278
  t || (t = /* @__PURE__ */ new Set(), r.set(e, t)), t.add(i);
1243
1279
  }
1244
1280
  }
1245
- return J.set(e, r), r;
1281
+ return ct.set(e, r), r;
1246
1282
  }
1247
- var X = class {
1283
+ var Y = class {
1248
1284
  scheme;
1249
1285
  pointerMap;
1250
1286
  extensions;
@@ -1253,7 +1289,7 @@ var X = class {
1253
1289
  }
1254
1290
  isPointerTarget(e, t) {
1255
1291
  let { to: n } = this.getFieldType(e);
1256
- return n ? Y(this.pointerMap, this.extensions).get(this.scheme.tag[n])?.has(t) ?? !1 : !1;
1292
+ return n ? lt(this.pointerMap, this.extensions).get(this.scheme.tag[n])?.has(t) ?? !1 : !1;
1257
1293
  }
1258
1294
  getFieldType(e) {
1259
1295
  let t = this.scheme.payload[e];
@@ -1261,25 +1297,25 @@ var X = class {
1261
1297
  type: "pointer",
1262
1298
  to: t.to
1263
1299
  } : {
1264
- type: Xe[t?.type ?? ""] ?? null,
1300
+ type: ot[t?.type ?? ""] ?? null,
1265
1301
  to: void 0
1266
1302
  };
1267
1303
  }
1268
1304
  mayOmitPayload(e) {
1269
- return e.startsWith(Fe) && Me.has(this.scheme.payload[e]?.type ?? "");
1305
+ return e.startsWith(Re) && Fe.has(this.scheme.payload[e]?.type ?? "");
1270
1306
  }
1271
1307
  validateEnumeration(e, t, n) {
1272
1308
  let r = n.tokens.VALUE?.range || n.range, i = this.getAvailableValues(t), a = [], o = new Set(e.filter((e) => C(e) && this.extensions.requireDeclaration && !this.extensions.tags.has(v(e))));
1273
1309
  for (let e of o) a.push(E(v(e), r));
1274
- let s = this.scheme.payload[t]?.set, c = s !== void 0 && Pe.has(s), l = c ? i?.map((e) => e.toLowerCase()) : i;
1275
- return e.some((e) => !C(e) && !l?.includes(c ? e.toLowerCase() : e)) && a.push(H(n, `should be in set [${Ie(i)}]`, p.ShouldBeSetValue)), a;
1310
+ let s = this.scheme.payload[t]?.set, c = s !== void 0 && Le.has(s), l = c ? i?.map((e) => e.toLowerCase()) : i;
1311
+ return e.some((e) => !C(e) && !l?.includes(c ? e.toLowerCase() : e)) && a.push(B(n, `should be in set [${ze(i)}]`, p.ShouldBeSetValue)), a;
1276
1312
  }
1277
1313
  getAvailableValues(e) {
1278
1314
  let t = this.getFieldType(e), n = this.scheme.payload[e];
1279
1315
  if ((t.type === "select" || t.type === "multiselect") && n.set) return Object.keys(this.scheme.set[n.set]);
1280
1316
  if (t.type === "pointer" && t.to) {
1281
1317
  let e = this.scheme.tag[t.to];
1282
- return [...Y(this.pointerMap, this.extensions).get(e) ?? []];
1318
+ return [...lt(this.pointerMap, this.extensions).get(e) ?? []];
1283
1319
  }
1284
1320
  return null;
1285
1321
  }
@@ -1311,14 +1347,14 @@ var X = class {
1311
1347
  collect(e, t, n) {
1312
1348
  let r = n || this.getNodeType(t), i = this.getFieldType(r), a = _(t).trim(), o = t.tokens.TAG;
1313
1349
  if (!a && this.mayOmitPayload(r) || i.type === null) return;
1314
- let s = Ze[i.type];
1350
+ let s = st[i.type];
1315
1351
  if (s) {
1316
- !a || !s.test(a, this.scheme, this.extensions) ? e.push(H(t, s.message)) : s.calendarDays && e.push(...Le(this.scheme, t, a));
1352
+ !a || !s.test(a, this.scheme, this.extensions) ? e.push(B(t, s.message)) : s.calendarDays && e.push(...Be(this.scheme, t, a));
1317
1353
  return;
1318
1354
  }
1319
1355
  switch (i.type) {
1320
1356
  case "boolean":
1321
- a && a !== "Y" ? e.push(H(t, "should be Y or null")) : !a && t.children.length === 0 && e.push({
1357
+ a && a !== "Y" ? e.push(B(t, "should be Y or null")) : !a && t.children.length === 0 && e.push({
1322
1358
  code: p.EmptyEvent,
1323
1359
  message: `${o?.value} has neither a payload nor substructures, so it asserts nothing and other software may drop it — write "Y" to assert the event happened, or give it a DATE, PLAC or NOTE`,
1324
1360
  range: o?.range || t.range,
@@ -1340,13 +1376,13 @@ var X = class {
1340
1376
  e.push(...this.validateEnumeration(a.split(",").map((e) => e.trim()), r, t));
1341
1377
  break;
1342
1378
  case "pointer": {
1343
- let n = t.tokens.XREF, a = !!n?.value, s = a && (n.value === B || this.isPointerTarget(r, n.value)), c = t.children.length !== 0;
1344
- if (!(Ne.has(r) && !a) && (a && !s || !a && !c)) {
1379
+ let n = t.tokens.XREF, a = !!n?.value, s = a && (n.value === R || this.isPointerTarget(r, n.value)), c = t.children.length !== 0;
1380
+ if (!(Ie.has(r) && !a) && (a && !s || !a && !c)) {
1345
1381
  let r = i.to ? this.scheme.tag[i.to] : void 0, s = r ? `${r} record` : "record", c = a ? `No ${s} carries ${n.value}` : `Value for ${o?.value} should be a pointer to a ${s}, written as "@xref@"`;
1346
1382
  e.push({
1347
- code: a && n?.value !== B ? p.UnresolvedXref : p.MissingRef,
1383
+ code: a && n?.value !== R ? p.UnresolvedXref : p.MissingRef,
1348
1384
  message: c,
1349
- data: a && n?.value !== B ? {
1385
+ data: a && n?.value !== R ? {
1350
1386
  xref: n?.value,
1351
1387
  requiredRecordTag: i.to ? this.scheme.tag[i.to] : void 0
1352
1388
  } : void 0,
@@ -1361,24 +1397,24 @@ var X = class {
1361
1397
  };
1362
1398
  //#endregion
1363
1399
  //#region src/validator/validate.ts
1364
- function Qe(e) {
1400
+ function ut(e) {
1365
1401
  let t = e.match(/^\{(?<a>\d+):(?<b>\d+|M)}$/);
1366
1402
  return t?.groups ? {
1367
1403
  min: parseInt(t.groups.a, 10),
1368
1404
  max: t.groups.b === "M" ? Infinity : parseInt(t.groups.b, 10)
1369
1405
  } : null;
1370
1406
  }
1371
- var $e = /* @__PURE__ */ new WeakMap();
1372
- function et(e, t) {
1373
- let n = $e.get(e);
1374
- n || (n = /* @__PURE__ */ new Map(), $e.set(e, n));
1407
+ var dt = /* @__PURE__ */ new WeakMap();
1408
+ function ft(e, t) {
1409
+ let n = dt.get(e);
1410
+ n || (n = /* @__PURE__ */ new Map(), dt.set(e, n));
1375
1411
  let r = n.get(t);
1376
1412
  if (r) return r;
1377
1413
  let i = e.substructure[t];
1378
1414
  if (!i && !(t in e.payload)) return;
1379
1415
  let a = /* @__PURE__ */ new Map();
1380
1416
  for (let [t, { cardinality: n, type: r }] of Object.entries(i ?? {})) {
1381
- let i = Qe(n);
1417
+ let i = ut(n);
1382
1418
  i && a.set(v(t), {
1383
1419
  ...i,
1384
1420
  type: r,
@@ -1387,14 +1423,14 @@ function et(e, t) {
1387
1423
  }
1388
1424
  return n.set(t, a), a;
1389
1425
  }
1390
- function tt(e, t, n) {
1426
+ function pt(e, t, n) {
1391
1427
  let r = e.tags.get(t), i = r ? y(r) : void 0;
1392
1428
  return i && n.payload[i] ? i : void 0;
1393
1429
  }
1394
- function nt(e) {
1430
+ function mt(e) {
1395
1431
  return S(e)?.startsWith("5") ? x : b;
1396
1432
  }
1397
- var rt = class {
1433
+ var ht = class {
1398
1434
  pointers;
1399
1435
  extensions;
1400
1436
  fragment;
@@ -1402,16 +1438,16 @@ var rt = class {
1402
1438
  this.pointers = e, this.extensions = t, this.fragment = n;
1403
1439
  }
1404
1440
  setScheme(e) {
1405
- return nt(e);
1441
+ return mt(e);
1406
1442
  }
1407
1443
  validate(e, t = y(""), n, r) {
1408
1444
  let i = [];
1409
1445
  return this.collect(i, e, t, n || this.setScheme(e), r), i;
1410
1446
  }
1411
1447
  collect(e, t, n, r, i) {
1412
- let a = et(r, n);
1448
+ let a = ft(r, n);
1413
1449
  if (!a) return;
1414
- let o = /* @__PURE__ */ new Map(), s = r.tag[y(n)], c = new X(r, this.pointers, this.extensions);
1450
+ let o = /* @__PURE__ */ new Map(), s = r.tag[y(n)], c = new Y(r, this.pointers, this.extensions);
1415
1451
  for (let n of t) {
1416
1452
  if (n.tokens.LEVEL === void 0) continue;
1417
1453
  let t = n.tokens.TAG?.value ? v(n.tokens.TAG?.value) : void 0;
@@ -1431,7 +1467,7 @@ var rt = class {
1431
1467
  let i = n.tokens.TAG;
1432
1468
  if (C(t)) {
1433
1469
  this.extensions.requireDeclaration && !this.extensions.tags.has(t) && e.push(E(t, i?.range || n.range));
1434
- let a = tt(this.extensions, t, r);
1470
+ let a = pt(this.extensions, t, r);
1435
1471
  a && (c.collect(e, n, a), this.collect(e, n.children, a, r, n));
1436
1472
  continue;
1437
1473
  }
@@ -1473,7 +1509,7 @@ var rt = class {
1473
1509
  });
1474
1510
  }
1475
1511
  }
1476
- }, Z = [
1512
+ }, X = [
1477
1513
  {
1478
1514
  kind: "supported",
1479
1515
  version: "7.0",
@@ -1509,7 +1545,7 @@ var rt = class {
1509
1545
  scheme: x,
1510
1546
  requiresSchmaDeclaration: !1
1511
1547
  }
1512
- ], it = [...Z].sort((e, t) => t.version.length - e.version.length), at = Z.find(({ kind: e }) => e === "supported"), ot = {
1548
+ ], gt = [...X].sort((e, t) => t.version.length - e.version.length), _t = X.find(({ kind: e }) => e === "supported"), vt = {
1513
1549
  start: {
1514
1550
  line: 0,
1515
1551
  character: 0
@@ -1519,22 +1555,22 @@ var rt = class {
1519
1555
  character: 0
1520
1556
  }
1521
1557
  };
1522
- function st(e) {
1523
- let t = Z.find((t) => t.kind === "supported" && t.dialect === e);
1558
+ function yt(e) {
1559
+ let t = X.find((t) => t.kind === "supported" && t.dialect === e);
1524
1560
  return {
1525
1561
  scheme: t.scheme,
1526
1562
  dialect: t.dialect,
1527
1563
  requiresSchmaDeclaration: t.requiresSchmaDeclaration
1528
1564
  };
1529
1565
  }
1530
- function ct(e) {
1566
+ function bt(e) {
1531
1567
  let t = (t) => e?.children.findIndex((e) => e.tokens.TAG?.value === t) ?? -1, n = t("SYST");
1532
1568
  if (n === -1) return;
1533
1569
  let r = t("GEDC");
1534
1570
  return r === -1 || n < r ? e?.children[n] : void 0;
1535
1571
  }
1536
- function lt(e) {
1537
- let t = e.find((e) => e.tokens.TAG?.value === "HEAD"), n = ((t?.children.find((e) => e.tokens.TAG?.value === "GEDC"))?.children.find((e) => e.tokens.TAG?.value === "VERS"))?.tokens.VALUE?.range ?? t?.range ?? ot, r = ct(t);
1572
+ function xt(e) {
1573
+ let t = e.find((e) => e.tokens.TAG?.value === "HEAD"), n = ((t?.children.find((e) => e.tokens.TAG?.value === "GEDC"))?.children.find((e) => e.tokens.TAG?.value === "VERS"))?.tokens.VALUE?.range ?? t?.range ?? vt, r = bt(t);
1538
1574
  if (r) return {
1539
1575
  kind: "paf",
1540
1576
  system: r.tokens.VALUE?.value?.trim() ?? "",
@@ -1542,7 +1578,7 @@ function lt(e) {
1542
1578
  };
1543
1579
  let i = S(e);
1544
1580
  if (!i) {
1545
- let { scheme: e, dialect: t, requiresSchmaDeclaration: r } = at;
1581
+ let { scheme: e, dialect: t, requiresSchmaDeclaration: r } = _t;
1546
1582
  return {
1547
1583
  kind: "undetermined",
1548
1584
  scheme: e,
@@ -1551,7 +1587,7 @@ function lt(e) {
1551
1587
  range: n
1552
1588
  };
1553
1589
  }
1554
- let a = it.find(({ version: e }) => i.startsWith(e));
1590
+ let a = gt.find(({ version: e }) => i.startsWith(e));
1555
1591
  return a ? {
1556
1592
  ...a,
1557
1593
  range: n
@@ -1563,12 +1599,12 @@ function lt(e) {
1563
1599
  }
1564
1600
  //#endregion
1565
1601
  //#region src/completion/dateSlot.ts
1566
- var Q = {
1602
+ var Z = {
1567
1603
  calendars: !1,
1568
1604
  months: null,
1569
1605
  epochs: null,
1570
1606
  keywords: []
1571
- }, ut = [
1607
+ }, St = [
1572
1608
  "ABT",
1573
1609
  "CAL",
1574
1610
  "EST",
@@ -1577,16 +1613,16 @@ var Q = {
1577
1613
  "BET",
1578
1614
  "FROM",
1579
1615
  "TO"
1580
- ], dt = ["FROM", "TO"], ft = {
1616
+ ], Ct = ["FROM", "TO"], wt = {
1581
1617
  BET: "AND",
1582
1618
  FROM: "TO"
1583
- }, $ = /^\d+$/u;
1584
- function pt(e) {
1585
- let t = N(e);
1619
+ }, Q = /^\d+$/u;
1620
+ function Tt(e) {
1621
+ let t = _e(e);
1586
1622
  return /\s$/u.test(e) ? t : t.slice(0, -1);
1587
1623
  }
1588
- function mt(e, t) {
1589
- let n = 0, r = O, i = t[0] === void 0 ? null : M(e, t[0]);
1624
+ function Et(e, t) {
1625
+ let n = 0, r = O, i = t[0] === void 0 ? null : he(e, t[0]);
1590
1626
  i !== null && (r = i, n = 1);
1591
1627
  let a = t.slice(n);
1592
1628
  if (a.length === 0) return {
@@ -1598,14 +1634,14 @@ function mt(e, t) {
1598
1634
  };
1599
1635
  let { epochs: o } = A(e, r);
1600
1636
  if (a.some((e) => o?.has(e))) return {
1601
- ...Q,
1637
+ ...Z,
1602
1638
  complete: !0
1603
1639
  };
1604
1640
  let s = 0;
1605
- $.test(a[s] ?? "") && !$.test(a[s + 1] ?? "0") && (s += 1);
1606
- let c = a[s] !== void 0 && !$.test(a[s]);
1641
+ Q.test(a[s] ?? "") && !Q.test(a[s + 1] ?? "0") && (s += 1);
1642
+ let c = a[s] !== void 0 && !Q.test(a[s]);
1607
1643
  c && (s += 1);
1608
- let l = $.test(a[s] ?? "");
1644
+ let l = Q.test(a[s] ?? "");
1609
1645
  return c ? {
1610
1646
  calendars: !1,
1611
1647
  months: null,
@@ -1620,20 +1656,20 @@ function mt(e, t) {
1620
1656
  complete: l
1621
1657
  };
1622
1658
  }
1623
- function ht(e, t, n) {
1624
- let r = pt(t);
1659
+ function Dt(e, t, n) {
1660
+ let r = Tt(t);
1625
1661
  if (n === "exact") return r.length === 1 ? {
1626
- ...Q,
1662
+ ...Z,
1627
1663
  months: O
1628
- } : Q;
1629
- let i = n === "period" ? dt : ut;
1664
+ } : Z;
1665
+ let i = n === "period" ? Ct : St;
1630
1666
  if (r.length === 0) return {
1631
1667
  calendars: !0,
1632
1668
  months: O,
1633
1669
  epochs: null,
1634
1670
  keywords: i
1635
1671
  };
1636
- let a = i.includes(r[0]) ? r[0] : null, o = a === null ? r : r.slice(1), s = a === null ? void 0 : ft[a], c = s === void 0 ? -1 : o.indexOf(s), l = mt(e, c === -1 ? o : o.slice(c + 1));
1672
+ let a = i.includes(r[0]) ? r[0] : null, o = a === null ? r : r.slice(1), s = a === null ? void 0 : wt[a], c = s === void 0 ? -1 : o.indexOf(s), l = Et(e, c === -1 ? o : o.slice(c + 1));
1637
1673
  return {
1638
1674
  calendars: l.calendars,
1639
1675
  months: l.months,
@@ -1643,16 +1679,16 @@ function ht(e, t, n) {
1643
1679
  }
1644
1680
  //#endregion
1645
1681
  //#region src/completion/completion.ts
1646
- var gt = /^(\d+)\s+(?:@[^\s@]+@\s+)?([A-Za-z0-9_]*)$/, _t = /^(\d+)\s+(?:@[^\s@]+@\s+)?([A-Za-z0-9_]+)\s+(.*)$/, vt = /* @__PURE__ */ new WeakMap();
1647
- function yt(e) {
1648
- let t = vt.get(e);
1682
+ var Ot = /^(\d+)\s+(?:@[^\s@]+@\s+)?([A-Za-z0-9_]*)$/, kt = /^(\d+)\s+(?:@[^\s@]+@\s+)?([A-Za-z0-9_]+)\s+(.*)$/, $ = /* @__PURE__ */ new WeakMap();
1683
+ function At(e) {
1684
+ let t = $.get(e);
1649
1685
  if (t) return t;
1650
1686
  let n = [], r = (e) => {
1651
1687
  for (let t of e) n.push(t), r(t.children);
1652
1688
  };
1653
- return r(e), vt.set(e, n), n;
1689
+ return r(e), $.set(e, n), n;
1654
1690
  }
1655
- function bt(e, t) {
1691
+ function jt(e, t) {
1656
1692
  let n = 0, r = e.length;
1657
1693
  for (; n < r;) {
1658
1694
  let i = n + r >> 1;
@@ -1660,11 +1696,11 @@ function bt(e, t) {
1660
1696
  }
1661
1697
  return n - 1;
1662
1698
  }
1663
- function xt(e) {
1699
+ function Mt(e) {
1664
1700
  let t = /^\{\d+:(\d+|M)\}$/.exec(e);
1665
1701
  return t ? t[1] === "M" ? Infinity : Number(t[1]) : null;
1666
1702
  }
1667
- function St(e, t) {
1703
+ function Nt(e, t) {
1668
1704
  let n = e, r = t;
1669
1705
  for (; n;) {
1670
1706
  if (n.level !== r || !n.tokens.TAG?.value) return !1;
@@ -1672,12 +1708,12 @@ function St(e, t) {
1672
1708
  }
1673
1709
  return r === -1;
1674
1710
  }
1675
- function Ct(e, t) {
1711
+ function Pt(e, t) {
1676
1712
  if (t === 0) return {
1677
1713
  parentType: y(""),
1678
1714
  siblings: e.nodes
1679
1715
  };
1680
- let n = yt(e.nodes), r = bt(n, e.position.line), i = r >= 0 && n[r].range.start.line === e.position.line ? n[r] : void 0, a;
1716
+ let n = At(e.nodes), r = jt(n, e.position.line), i = r >= 0 && n[r].range.start.line === e.position.line ? n[r] : void 0, a;
1681
1717
  if (i) {
1682
1718
  if (i.level !== t || i.parent?.level !== t - 1) return null;
1683
1719
  a = i.parent;
@@ -1689,18 +1725,18 @@ function Ct(e, t) {
1689
1725
  break;
1690
1726
  }
1691
1727
  }
1692
- if (!a || !St(a, t - 1)) return null;
1693
- let o = new X(e.scheme, e.pointers).getNodeType(a);
1728
+ if (!a || !Nt(a, t - 1)) return null;
1729
+ let o = new Y(e.scheme, e.pointers).getNodeType(a);
1694
1730
  return o ? {
1695
1731
  parentType: o,
1696
1732
  siblings: a.children
1697
1733
  } : null;
1698
1734
  }
1699
- function wt(e, t) {
1700
- let n = Ct(e, t);
1735
+ function Ft(e, t) {
1736
+ let n = Pt(e, t);
1701
1737
  if (!n) return [];
1702
1738
  let r = Object.entries(e.scheme.substructure[n.parentType] ?? {}).filter(([t, r]) => {
1703
- let i = xt(r.cardinality);
1739
+ let i = Mt(r.cardinality);
1704
1740
  return i === null || i === Infinity || n.siblings.filter((n) => n.range.start.line !== e.position.line && n.tokens.TAG?.value === t).length < i;
1705
1741
  }).map(([t, n]) => ({
1706
1742
  label: v(t),
@@ -1713,7 +1749,7 @@ function wt(e, t) {
1713
1749
  }));
1714
1750
  return [...r, ...i];
1715
1751
  }
1716
- var Tt = {
1752
+ var It = {
1717
1753
  "date-v7": {
1718
1754
  grammar: "value",
1719
1755
  escaped: !1
@@ -1739,8 +1775,8 @@ var Tt = {
1739
1775
  escaped: !0
1740
1776
  }
1741
1777
  };
1742
- function Et(e, { grammar: t, escaped: n }, r) {
1743
- let i = ht(e.scheme, r, t), a = (t) => t === null ? void 0 : e.scheme.calendar[v(t)], o = Object.keys(e.scheme.calendar).map((e) => n ? me(e) : e);
1778
+ function Lt(e, { grammar: t, escaped: n }, r) {
1779
+ let i = Dt(e.scheme, r, t), a = (t) => t === null ? void 0 : e.scheme.calendar[v(t)], o = Object.keys(e.scheme.calendar).map((e) => n ? me(e) : e);
1744
1780
  return [
1745
1781
  ...i.calendars ? o : [],
1746
1782
  ...Object.keys(a(i.months)?.months ?? {}),
@@ -1751,13 +1787,13 @@ function Et(e, { grammar: t, escaped: n }, r) {
1751
1787
  kind: "enum"
1752
1788
  }));
1753
1789
  }
1754
- function Dt(e, t, n, r) {
1755
- let i = Ct(e, t);
1790
+ function Rt(e, t, n, r) {
1791
+ let i = Pt(e, t);
1756
1792
  if (!i) return [];
1757
1793
  let a = e.scheme.substructure[i.parentType]?.[v(n.toUpperCase())]?.type;
1758
1794
  if (!a) return [];
1759
- let o = new X(e.scheme, e.pointers), s = o.getFieldType(a), c = s.type === null ? void 0 : Tt[s.type];
1760
- if (c) return Et(e, c, r);
1795
+ let o = new Y(e.scheme, e.pointers), s = o.getFieldType(a), c = s.type === null ? void 0 : It[s.type];
1796
+ if (c) return Lt(e, c, r);
1761
1797
  if (s.type === "select" || s.type === "multiselect") return [...new Set(o.getAvailableValues(a) ?? [])].filter(Boolean).map((e) => ({
1762
1798
  label: e,
1763
1799
  kind: "enum"
@@ -1771,18 +1807,18 @@ function Dt(e, t, n, r) {
1771
1807
  }
1772
1808
  return [];
1773
1809
  }
1774
- function Ot(e) {
1775
- let t = e.lineText.slice(0, e.position.character), n = gt.exec(t);
1776
- if (n) return wt(e, Number(n[1]));
1777
- let r = _t.exec(t);
1778
- return r ? Dt(e, Number(r[1]), r[2], r[3]) : [];
1810
+ function zt(e) {
1811
+ let t = e.lineText.slice(0, e.position.character), n = Ot.exec(t);
1812
+ if (n) return Ft(e, Number(n[1]));
1813
+ let r = kt.exec(t);
1814
+ return r ? Rt(e, Number(r[1]), r[2], r[3]) : [];
1779
1815
  }
1780
1816
  //#endregion
1781
1817
  //#region src/document/gedcomDocument.ts
1782
- function kt(e) {
1818
+ function Bt(e) {
1783
1819
  return e.startsWith("@") ? "An xref holds letters, digits and underscore between two @ marks, so this line cannot be read" : `This line cannot be read from ${JSON.stringify(e)} onward`;
1784
1820
  }
1785
- var At = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), jt = class {
1821
+ var Vt = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), Ht = class {
1786
1822
  nodes = [];
1787
1823
  pointers = /* @__PURE__ */ new Map();
1788
1824
  errors = [];
@@ -1804,7 +1840,7 @@ var At = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), jt = cl
1804
1840
  let r = t.line ?? 0, o = t.column ?? 0;
1805
1841
  o < (n.get(r) ?? Infinity) && i.add(r), !a.has(r) && (a.add(r), this.errors.push({
1806
1842
  code: p.Lexer,
1807
- message: kt(e.slice(t.offset, t.offset + t.length)),
1843
+ message: Bt(e.slice(t.offset, t.offset + t.length)),
1808
1844
  range: {
1809
1845
  start: {
1810
1846
  line: r,
@@ -1831,8 +1867,8 @@ var At = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), jt = cl
1831
1867
  createDocument(e, t = {}) {
1832
1868
  let { nodes: n, pointers: r } = this.parseGedcom(e);
1833
1869
  this.nodes = n, this.pointers = r, this.scheme = void 0, this.requiresSchmaDeclaration = !1, this.extensions = w(), this.validateLevels(this.errors, n);
1834
- let i = lt(n);
1835
- if (this.resolution = i, t.fragment && t.dialect && i.kind === "undetermined") return this.applyScheme(n, st(t.dialect), t), this;
1870
+ let i = xt(n);
1871
+ if (this.resolution = i, t.fragment && t.dialect && i.kind === "undetermined") return this.applyScheme(n, yt(t.dialect), t), this;
1836
1872
  if (i.kind === "undetermined") return this.scheme = i.scheme, this.requiresSchmaDeclaration = i.requiresSchmaDeclaration, this.errors.push({
1837
1873
  code: p.UndeterminedVersion,
1838
1874
  message: "No GEDCOM version in HEAD.GEDC.VERS, so the file cannot be checked against a specification",
@@ -1865,7 +1901,7 @@ var At = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), jt = cl
1865
1901
  let { context: r, errors: i } = le(e, this.requiresSchmaDeclaration, this.scheme);
1866
1902
  this.extensions = r;
1867
1903
  for (let e of i) this.errors.push(e);
1868
- new rt(this.pointers, r, n.fragment ?? !1).collect(this.errors, this.nodes, y(""), this.scheme), n.fragment && (this.errors = this.errors.filter((e) => !At.has(e.code)));
1904
+ new ht(this.pointers, r, n.fragment ?? !1).collect(this.errors, this.nodes, y(""), this.scheme), n.fragment && (this.errors = this.errors.filter((e) => !Vt.has(e.code)));
1869
1905
  }
1870
1906
  validateLevels(e, t, n = 0) {
1871
1907
  for (let r of t) r.level !== n && e.push({
@@ -1886,12 +1922,12 @@ var At = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), jt = cl
1886
1922
  return e ? `Extension tag (${e})` : "Extension tag";
1887
1923
  }
1888
1924
  if (!this.scheme) return;
1889
- let n = new X(this.scheme, this.pointers).getNodeType(e);
1925
+ let n = new Y(this.scheme, this.pointers).getNodeType(e);
1890
1926
  return this.scheme.label[n]?.["en-US"];
1891
1927
  }
1892
1928
  getPointerTargetTag(e) {
1893
1929
  if (!this.scheme) return;
1894
- let t = new X(this.scheme, this.pointers), n = t.getFieldType(t.getNodeType(e));
1930
+ let t = new Y(this.scheme, this.pointers), n = t.getFieldType(t.getNodeType(e));
1895
1931
  return n.type === "pointer" && n.to ? this.scheme.tag[n.to] : void 0;
1896
1932
  }
1897
1933
  isRecordDeclaration(e) {
@@ -1909,7 +1945,7 @@ var At = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), jt = cl
1909
1945
  return this.resolution && "dialect" in this.resolution ? this.resolution.dialect : void 0;
1910
1946
  }
1911
1947
  getCompletions(e, t) {
1912
- return this.scheme ? Ot({
1948
+ return this.scheme ? zt({
1913
1949
  nodes: this.nodes,
1914
1950
  pointers: this.pointers,
1915
1951
  scheme: this.scheme,
@@ -1927,4 +1963,4 @@ var At = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), jt = cl
1927
1963
  }
1928
1964
  };
1929
1965
  //#endregion
1930
- export { jt as GedcomDocument, p as GedcomErrorCode, r as TokenNames };
1966
+ export { Ht as GedcomDocument, p as GedcomErrorCode, r as TokenNames };