@domorium/validator 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -861,10 +861,10 @@ function w() {
861
861
  requireDeclaration: !1
862
862
  };
863
863
  }
864
- function T(e, t) {
864
+ function se(e, t) {
865
865
  return e.aliases.get(v(t)) ?? v(t);
866
866
  }
867
- function E(e, t) {
867
+ function ce(e, t) {
868
868
  return {
869
869
  code: p.UndocumentedTag,
870
870
  message: `Extension tag ${e} is not declared in HEAD.SCHMA`,
@@ -872,19 +872,19 @@ function E(e, t) {
872
872
  level: "warning"
873
873
  };
874
874
  }
875
- var se = /^(_[A-Z0-9_]+)\s+([A-Za-z][A-Za-z0-9+.-]*:\S*)$/;
876
- function ce(e) {
877
- let t = e.trim().match(se);
875
+ var le = /^(_[A-Z0-9_]+)\s+([A-Za-z][A-Za-z0-9+.-]*:\S*)$/;
876
+ function ue(e) {
877
+ let t = e.trim().match(le);
878
878
  return t ? {
879
879
  tag: v(t[1]),
880
880
  uri: t[2]
881
881
  } : null;
882
882
  }
883
- function le(e, t, n) {
883
+ function de(e, t, n) {
884
884
  let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = [], s = e.find((e) => e.tokens.TAG?.value === "HEAD")?.children.find((e) => e.tokens.TAG?.value === "SCHMA");
885
885
  for (let e of s?.children ?? []) {
886
886
  if (e.tokens.TAG?.value !== "TAG") continue;
887
- let t = ce(_(e));
887
+ let t = ue(_(e));
888
888
  if (!t) continue;
889
889
  let s = `${t.tag} ${t.uri}`;
890
890
  if (a.has(s)) {
@@ -912,37 +912,37 @@ function le(e, t, n) {
912
912
  }
913
913
  //#endregion
914
914
  //#region src/validator/calendars.ts
915
- var D = "@#D([A-Z][A-Z ]*)@", ue = RegExp(`^${D}\\s*`, "u"), de = RegExp(`^${D}$`, "u"), fe = RegExp(`${D}|\\S+`, "gu"), O = v("GREGORIAN"), pe = {
915
+ var T = "@#D([A-Z][A-Z ]*)@", fe = RegExp(`^${T}\\s*`, "u"), pe = RegExp(`^${T}$`, "u"), me = RegExp(`${T}|\\S+`, "gu"), E = v("GREGORIAN"), he = {
916
916
  months: null,
917
917
  epochs: null
918
- }, k = /* @__PURE__ */ new WeakMap();
919
- function A(e, t) {
920
- let n = k.get(e);
921
- n || (n = /* @__PURE__ */ new Map(), k.set(e, n));
918
+ }, D = /* @__PURE__ */ new WeakMap();
919
+ function O(e, t) {
920
+ let n = D.get(e);
921
+ n || (n = /* @__PURE__ */ new Map(), D.set(e, n));
922
922
  let r = n.get(t);
923
923
  if (r) return r;
924
924
  let i = e.calendar[t];
925
- if (!i) return pe;
925
+ if (!i) return he;
926
926
  let a = {
927
927
  months: new Set(Object.keys(i.months)),
928
928
  epochs: new Set(i.epochs)
929
929
  };
930
930
  return n.set(t, a), a;
931
931
  }
932
- function j(e, t) {
932
+ function k(e, t) {
933
933
  return e === null ? C(t) : e.has(t) || C(t);
934
934
  }
935
- function me(e) {
935
+ function ge(e) {
936
936
  return `@#D${e}@`;
937
937
  }
938
- function he(e, t) {
939
- let n = de.exec(t)?.[1];
938
+ function A(e, t) {
939
+ let n = pe.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 ge(e) {
945
- let t = ue.exec(e);
944
+ function j(e) {
945
+ let t = fe.exec(e);
946
946
  return t ? {
947
947
  calendar: v(t[1]),
948
948
  rest: e.slice(t[0].length)
@@ -951,18 +951,18 @@ function ge(e) {
951
951
  rest: e
952
952
  };
953
953
  }
954
- function _e(e) {
955
- return e.match(fe) ?? [];
954
+ function M(e) {
955
+ return e.match(me) ?? [];
956
956
  }
957
957
  //#endregion
958
958
  //#region src/validator/epoch.ts
959
- var ve = "(?:[Bb][Cc][Ee]|[Bb]\\.?[Cc]\\.?)", ye = RegExp(`^${ve}$`);
960
- function be(e) {
961
- return e !== void 0 && ye.test(e);
959
+ var N = "(?:[Bb][Cc][Ee]|[Bb]\\.?[Cc]\\.?)", _e = RegExp(`^${N}$`);
960
+ function ve(e) {
961
+ return e !== void 0 && _e.test(e);
962
962
  }
963
963
  //#endregion
964
964
  //#region src/validator/calendarDays.ts
965
- var xe = {
965
+ var P = {
966
966
  JAN: 31,
967
967
  FEB: 29,
968
968
  MAR: 31,
@@ -975,7 +975,7 @@ var xe = {
975
975
  OCT: 31,
976
976
  NOV: 30,
977
977
  DEC: 31
978
- }, Se = /* @__PURE__ */ new Set([O, "JULIAN"]), Ce = /^\d+$/u, we = /* @__PURE__ */ new Set([
978
+ }, ye = /* @__PURE__ */ new Set([E, "JULIAN"]), F = /^\d+$/u, be = /* @__PURE__ */ new Set([
979
979
  "ABT",
980
980
  "AFT",
981
981
  "AND",
@@ -987,32 +987,32 @@ var xe = {
987
987
  "INT",
988
988
  "TO"
989
989
  ]);
990
- function Te(e, t) {
990
+ function xe(e, t) {
991
991
  return e % 4 == 0 ? t === "JULIAN" || e % 100 != 0 || e % 400 == 0 : !1;
992
992
  }
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;
993
+ function Se(e, t, n) {
994
+ let r = P[e];
995
+ return r === void 0 ? null : e !== "FEB" || t === null ? r : xe(t, n) ? 29 : 28;
996
996
  }
997
- function De(e) {
997
+ function Ce(e) {
998
998
  return e.replace(/\([^()]*\)/gu, " ");
999
999
  }
1000
- function Oe(e, t) {
1001
- let n = _e(De(t)), r = [], i = O;
1000
+ function I(e, t) {
1001
+ let n = M(Ce(t)), r = [], i = E;
1002
1002
  for (let t = 0; t < n.length; t += 1) {
1003
1003
  let a = n[t];
1004
- if (we.has(a)) {
1005
- i = O;
1004
+ if (be.has(a)) {
1005
+ i = E;
1006
1006
  continue;
1007
1007
  }
1008
- let o = he(e, a);
1008
+ let o = A(e, a);
1009
1009
  if (o !== null) {
1010
1010
  i = o;
1011
1011
  continue;
1012
1012
  }
1013
1013
  let s = n[t + 1];
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);
1014
+ if (!ye.has(i) || !F.test(a) || s === void 0 || P[s] === void 0) continue;
1015
+ let c = Se(s, F.test(n[t + 2] ?? "") && !ve(n[t + 3]) ? Number(n[t + 2]) : null, i), l = Number(a);
1016
1016
  c !== null && (l < 1 || l > c) && r.push({
1017
1017
  day: l,
1018
1018
  month: s,
@@ -1023,71 +1023,197 @@ function Oe(e, t) {
1023
1023
  }
1024
1024
  //#endregion
1025
1025
  //#region src/validator/date-v7.ts
1026
- var M = /^\d+$/, ke = [
1026
+ var L = /^\d+$/, R = [
1027
1027
  "ABT",
1028
1028
  "CAL",
1029
1029
  "EST"
1030
- ], N = -1;
1031
- function P(e, t, n) {
1032
- let r = t, i = e[r];
1033
- if (i === void 0) return N;
1034
- let a = O;
1035
- (n.calendar[v(i)] || C(i)) && (a = v(i), r += 1);
1036
- let { months: o, epochs: s } = A(n, a);
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;
1038
- }
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);
1044
- }
1045
- function Ae(e, t, n) {
1046
- let r = e[t];
1047
- if (r !== void 0 && ke.includes(r)) return P(e, t + 1, n);
1048
- if (r === "BET") {
1049
- let r = P(e, t + 1, n);
1050
- return r === N || e[r] !== "AND" ? N : P(e, r + 1, n);
1030
+ ], z = -1;
1031
+ function B(e, t, n, r) {
1032
+ let i = t, a = e[i];
1033
+ if (a === void 0) return z;
1034
+ let o = E;
1035
+ (n.calendar[v(a)] || C(a)) && (o = v(a), i += 1);
1036
+ let { months: s, epochs: c } = O(n, o), l = {
1037
+ calendar: o,
1038
+ year: 0
1039
+ };
1040
+ return L.test(e[i] ?? "") && e[i + 1] !== void 0 && k(s, e[i + 1]) && L.test(e[i + 2] ?? "") ? (l.day = Number(e[i]), l.month = e[i + 1], i += 2) : e[i] !== void 0 && k(s, e[i]) && L.test(e[i + 1] ?? "") && (l.month = e[i], i += 1), L.test(e[i] ?? "") ? (l.year = Number(e[i]), i += 1, e[i] !== void 0 && k(c, e[i]) && (l.epoch = e[i], i += 1), r.push(l), i) : z;
1041
+ }
1042
+ function V(e, t, n, r) {
1043
+ if (e[t] === "TO") return B(e, t + 1, n, r);
1044
+ if (e[t] !== "FROM") return z;
1045
+ let i = B(e, t + 1, n, r);
1046
+ return i === z || e[i] !== "TO" ? i : B(e, i + 1, n, r);
1047
+ }
1048
+ function H(e, t, n, r) {
1049
+ let i = e[t];
1050
+ if (i !== void 0 && R.includes(i)) return B(e, t + 1, n, r);
1051
+ if (i === "BET") {
1052
+ let i = B(e, t + 1, n, r);
1053
+ return i === z || e[i] !== "AND" ? z : B(e, i + 1, n, r);
1051
1054
  }
1052
- return r === "AFT" || r === "BEF" ? P(e, t + 1, n) : r === "FROM" || r === "TO" ? F(e, t, n) : P(e, t, n);
1055
+ return i === "AFT" || i === "BEF" ? B(e, t + 1, n, r) : i === "FROM" || i === "TO" ? V(e, t, n, r) : B(e, t, n, r);
1053
1056
  }
1054
- function je(e) {
1057
+ function we(e) {
1055
1058
  return e.trim().split(/\s+/);
1056
1059
  }
1057
- function I(e, t) {
1058
- return je(e).map((e) => T(t, e));
1060
+ function U(e, t) {
1061
+ return we(e).map((e) => se(t, e));
1059
1062
  }
1060
- function L(e, t, n, r) {
1061
- let i = I(e, n);
1062
- return i.length > 0 && r(i, 0, t) === i.length;
1063
+ function W(e, t, n, r) {
1064
+ let i = U(e, n);
1065
+ return i.length > 0 && r(i, 0, t, []) === i.length;
1063
1066
  }
1064
- function Me(e, t, n = w()) {
1065
- return L(e, t, n, Ae);
1067
+ function Te(e, t, n = w()) {
1068
+ return W(e, t, n, H);
1069
+ }
1070
+ var Ee = /* @__PURE__ */ new Set([
1071
+ ...R,
1072
+ "BEF",
1073
+ "AFT",
1074
+ "BET",
1075
+ "FROM",
1076
+ "TO"
1077
+ ]);
1078
+ function De(e, t, n = w()) {
1079
+ let r = U(e, n), i = [];
1080
+ if (H(r, 0, t, i) !== r.length) return null;
1081
+ let a = r[0];
1082
+ return Ee.has(a) ? {
1083
+ modifier: a,
1084
+ dates: i,
1085
+ text: e
1086
+ } : {
1087
+ dates: i,
1088
+ text: e
1089
+ };
1066
1090
  }
1067
- function Ne(e, t, n = w()) {
1068
- return L(e, t, n, F);
1091
+ function Oe(e, t, n = w()) {
1092
+ return W(e, t, n, V);
1069
1093
  }
1070
- function Pe(e, t, n = w()) {
1071
- let r = I(e, n);
1094
+ function ke(e, t, n = w()) {
1095
+ let r = U(e, n);
1072
1096
  if (r.length !== 3) return !1;
1073
- let { months: i } = A(t, O);
1074
- return M.test(r[0]) && j(i, r[1]) && M.test(r[2]);
1097
+ let { months: i } = O(t, E);
1098
+ return L.test(r[0]) && k(i, r[1]) && L.test(r[2]);
1099
+ }
1100
+ //#endregion
1101
+ //#region src/validator/date-551.ts
1102
+ var Ae = "\\d+(?:/\\d{2})?", G = /* @__PURE__ */ new WeakMap();
1103
+ function je(e) {
1104
+ let t = `(?:${e.join("|")})`, n = `(?:(?:(?<day>\\d{1,2})\\s)?(?<month>${t})\\s)?(?<year>\\d+)(?:/(?<dual>\\d{2}))?`;
1105
+ return {
1106
+ dated: RegExp(`^${n}(?:\\s?(?<epoch>${N}))?$`),
1107
+ exact: RegExp(`^\\d{1,2}\\s${t}\\s${Ae}$`)
1108
+ };
1109
+ }
1110
+ function K(e, t) {
1111
+ let n = G.get(e);
1112
+ n || (n = /* @__PURE__ */ new Map(), G.set(e, n));
1113
+ let r = n.get(t);
1114
+ if (r !== void 0) return r;
1115
+ let i = Object.keys(e.calendar[v(t)]?.months ?? {}), a = i.length === 0 ? null : je(i);
1116
+ return n.set(t, a), a;
1117
+ }
1118
+ function Me(e, t) {
1119
+ let { calendar: n, rest: r } = j(t), i = K(e, n ?? E);
1120
+ return i === null ? r.length > 0 : i.dated.test(r);
1121
+ }
1122
+ function Ne(e, t) {
1123
+ let { calendar: n, rest: r } = j(t), i = n ?? E, a = K(e, i)?.dated.exec(r)?.groups;
1124
+ if (!a) return null;
1125
+ let { day: o, month: s, year: c, dual: l, epoch: u } = a, d = {
1126
+ calendar: i.replace(" ", "_"),
1127
+ year: Number(c)
1128
+ };
1129
+ return o !== void 0 && (d.day = Number(o)), s !== void 0 && (d.month = s), l !== void 0 && u === void 0 && Number(l) === (d.year + 1) % 100 && (d.dualYear = d.year + 1), u !== void 0 && (d.epoch = "BCE"), d;
1130
+ }
1131
+ var Pe = /^INT\s(.+)\s\(([^()]*)\)$/, Fe = /^\(([^()]*)\)$/, Ie = /^(ABT|CAL|EST|BEF|AFT)\s(.+)$/, Le = /^BET\s(.+)\sAND\s(.+)$/, Re = /^FROM\s(.+)\sTO\s(.+)$/, ze = /^FROM\s(.+)$/, Be = /^TO\s(.+)$/;
1132
+ function Ve(e) {
1133
+ let t = Re.exec(e);
1134
+ if (t) return {
1135
+ modifier: "FROM",
1136
+ slots: [t[1], t[2]]
1137
+ };
1138
+ let n = ze.exec(e);
1139
+ if (n) return {
1140
+ modifier: "FROM",
1141
+ slots: [n[1]]
1142
+ };
1143
+ let r = Be.exec(e);
1144
+ return r && {
1145
+ modifier: "TO",
1146
+ slots: [r[1]]
1147
+ };
1148
+ }
1149
+ function He(e) {
1150
+ let t = Fe.exec(e);
1151
+ if (t) return {
1152
+ slots: [],
1153
+ phrase: t[1]
1154
+ };
1155
+ let n = Pe.exec(e);
1156
+ if (n) return {
1157
+ modifier: "INT",
1158
+ slots: [n[1]],
1159
+ phrase: n[2]
1160
+ };
1161
+ let r = Le.exec(e);
1162
+ if (r) return {
1163
+ modifier: "BET",
1164
+ slots: [r[1], r[2]]
1165
+ };
1166
+ if (ze.test(e) || Be.test(e)) return Ve(e);
1167
+ let i = Ie.exec(e);
1168
+ return i ? {
1169
+ modifier: i[1],
1170
+ slots: [i[2]]
1171
+ } : { slots: [e] };
1172
+ }
1173
+ function Ue(e, t) {
1174
+ return t !== null && t.slots.every((t) => Me(e, t));
1175
+ }
1176
+ function We(e, t) {
1177
+ return Ue(e, Ve(t));
1178
+ }
1179
+ function Ge(e, t) {
1180
+ return Ue(e, He(t));
1181
+ }
1182
+ function Ke(e, t) {
1183
+ let n = K(e, E);
1184
+ return n === null ? t.length > 0 : n.exact.test(t);
1185
+ }
1186
+ function qe(e, t) {
1187
+ let n = He(t);
1188
+ if (n === null) return null;
1189
+ let r = [];
1190
+ for (let t of n.slots) {
1191
+ let n = Ne(e, t);
1192
+ if (n === null) return null;
1193
+ r.push(n);
1194
+ }
1195
+ return {
1196
+ ...n.modifier === void 0 ? {} : { modifier: n.modifier },
1197
+ dates: r,
1198
+ ...n.phrase === void 0 ? {} : { phrase: n.phrase },
1199
+ text: t
1200
+ };
1075
1201
  }
1076
1202
  //#endregion
1077
1203
  //#region src/validator/rule-node.ts
1078
- var R = "@VOID@", Fe = /* @__PURE__ */ new Set([
1204
+ var q = "@VOID@", Je = /* @__PURE__ */ new Set([
1079
1205
  "http://www.w3.org/2001/XMLSchema#string",
1080
1206
  "https://gedcom.io/terms/v7/type-List#Text",
1081
1207
  "https://gedcom.io/terms/v7/type-Date",
1082
1208
  "https://gedcom.io/terms/v7/type-Date#period",
1083
1209
  "https://gedcom.io/terms/v7/type-Age"
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) {
1210
+ ]), Ye = /* @__PURE__ */ new Set(["https://gedcom.io/terms/v5.5.1/NOTE-XREF_NOTE", "https://gedcom.io/terms/v5.5.1/SOUR-XREF_SOUR"]), Xe = /* @__PURE__ */ new Set(["https://gedcom.io/terms/v5.5.1/enumset-MULTIMEDIA_FORMAT"]), Ze = "https://gedcom.io/terms/v7/", Qe = 10;
1211
+ function $e(e) {
1086
1212
  if (!e?.length) return "";
1087
- let t = e.slice(0, z).join(", "), n = e.length - z;
1213
+ let t = e.slice(0, Qe).join(", "), n = e.length - Qe;
1088
1214
  return n > 0 ? `${t}, … ${n} more` : t;
1089
1215
  }
1090
- function B(e, t, n = p.IncorrectValue) {
1216
+ function J(e, t, n = p.IncorrectValue) {
1091
1217
  return {
1092
1218
  code: _(e).trim() ? n : p.MissingValue,
1093
1219
  message: `Value for ${e.tokens.TAG?.value} ${t}`,
@@ -1095,51 +1221,10 @@ function B(e, t, n = p.IncorrectValue) {
1095
1221
  level: "error"
1096
1222
  };
1097
1223
  }
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));
1100
- }
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}`;
1104
- return {
1105
- dated: RegExp(`^${n}(?:\\s?${ve})?$`),
1106
- exact: RegExp(`^\\d{1,2}\\s${t}\\s${U}$`)
1107
- };
1108
- }
1109
- function G(e, t) {
1110
- let n = W.get(e);
1111
- n || (n = /* @__PURE__ */ new Map(), W.set(e, n));
1112
- let r = n.get(t);
1113
- if (r !== void 0) return r;
1114
- let i = Object.keys(e.calendar[v(t)]?.months ?? {}), a = i.length === 0 ? null : Ze(i);
1115
- return n.set(t, a), a;
1224
+ function et(e, t, n) {
1225
+ return I(e, n).map(({ day: e, month: n, length: r }) => J(t, `names ${e} ${n}, and ${n} has ${r} days`, p.ImpossibleDay));
1116
1226
  }
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]);
1127
- }
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 = {
1227
+ var tt = "(?:[01]?\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?", nt = RegExp(`^${tt}$`), rt = RegExp(`^${tt}Z?$`), it = "(?: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)", at = RegExp(`^(?:[<>]\\s)?${it}$`), ot = RegExp(`^(?:[<>]\\s*)?${it}$`, "i"), st = /^[^/]*(?:\/[^/]*\/[^/]*)?$/, ct = /^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*\/[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*(;\s*[\w-]+=[^;]+)*$/, lt = /^\d+$/, ut = /^[NS]\d+(\.\d+)?$/, dt = /^[EW]\d+(\.\d+)?$/, ft = /* @__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"), pt = {
1143
1228
  "Y|<NULL>": "boolean",
1144
1229
  "http://www.w3.org/2001/XMLSchema#string": "string",
1145
1230
  "https://gedcom.io/terms/v7/type-List#Text": "string",
@@ -1191,94 +1276,94 @@ var ot = {
1191
1276
  "https://gedcom.io/terms/v5.5.1/type-TIME_VALUE": "time",
1192
1277
  "https://gedcom.io/terms/v7/type-Age": "age-v7",
1193
1278
  "https://gedcom.io/terms/v5.5.1/type-AGE_AT_EVENT": "age"
1194
- }, st = {
1279
+ }, mt = {
1195
1280
  latitude: {
1196
- test: (e) => Je.test(e),
1281
+ test: (e) => ut.test(e),
1197
1282
  message: "should be correct latitude (e.g. \"N18.150944\")"
1198
1283
  },
1199
1284
  longitude: {
1200
- test: (e) => Ye.test(e),
1285
+ test: (e) => dt.test(e),
1201
1286
  message: "should be correct longitude (e.g. \"W46.6\")"
1202
1287
  },
1203
1288
  "personal-name": {
1204
- test: (e) => Ge.test(e),
1289
+ test: (e) => st.test(e),
1205
1290
  message: "should be a name, with the surname (if any) wrapped in a single pair of slashes (e.g. \"John /Doe/\")"
1206
1291
  },
1207
1292
  "media-type": {
1208
- test: (e) => Ke.test(e),
1293
+ test: (e) => ct.test(e),
1209
1294
  message: "should be a media type in the form \"type/subtype\" (e.g. \"image/jpeg\")"
1210
1295
  },
1211
1296
  "language-tag": {
1212
- test: (e) => Xe.test(e),
1297
+ test: (e) => ft.test(e),
1213
1298
  message: "should be a valid RFC 5646 language tag (e.g. \"en\", \"en-US\")"
1214
1299
  },
1215
1300
  "tag-def": {
1216
- test: (e) => !!ce(e),
1301
+ test: (e) => !!ue(e),
1217
1302
  message: "should be an extension tag and its URI (e.g. \"_SKYPEID http://xmlns.com/foaf/0.1/skypeID\")"
1218
1303
  },
1219
1304
  nonNegativeInteger: {
1220
- test: (e) => qe.test(e),
1305
+ test: (e) => lt.test(e),
1221
1306
  message: "should be a whole number, zero or greater"
1222
1307
  },
1223
1308
  time: {
1224
- test: (e) => Ve.test(e),
1309
+ test: (e) => nt.test(e),
1225
1310
  message: "should be correct time"
1226
1311
  },
1227
1312
  "time-v7": {
1228
- test: (e) => He.test(e),
1313
+ test: (e) => rt.test(e),
1229
1314
  message: "should be correct time"
1230
1315
  },
1231
1316
  age: {
1232
- test: (e) => We.test(e),
1317
+ test: (e) => ot.test(e),
1233
1318
  message: "should be correct age (e.g. \"35y 11m 8w 21d\", \"< 1y\", \"CHILD\")"
1234
1319
  },
1235
1320
  "age-v7": {
1236
- test: (e) => Ue.test(e),
1321
+ test: (e) => at.test(e),
1237
1322
  message: "should be correct age (e.g. \"35y 11m 8w 21d\", \"< 1y\", \"CHILD\")"
1238
1323
  },
1239
1324
  date: {
1240
- test: (e, t) => it(t, e),
1325
+ test: (e, t) => Ge(t, e),
1241
1326
  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)\")",
1242
1327
  calendarDays: !0
1243
1328
  },
1244
1329
  "date-v7": {
1245
- test: Me,
1330
+ test: Te,
1246
1331
  message: "should be a valid date value (e.g. \"12 JAN 2000\", \"ABT 1950\", \"BET 1900 AND 1910\", \"JULIAN 3 MAR 1721\", \"1000 BCE\")",
1247
1332
  calendarDays: !0
1248
1333
  },
1249
1334
  "date-period": {
1250
- test: (e, t) => rt(t, e),
1335
+ test: (e, t) => We(t, e),
1251
1336
  message: "should be a valid date period (e.g. \"FROM 1900 TO 1910\", \"TO 1920\")",
1252
1337
  calendarDays: !0
1253
1338
  },
1254
1339
  "date-period-v7": {
1255
- test: Ne,
1340
+ test: Oe,
1256
1341
  message: "should be a valid date period (e.g. \"FROM 1900 TO 1910\", \"TO 1920\")",
1257
1342
  calendarDays: !0
1258
1343
  },
1259
1344
  "date-exact": {
1260
- test: (e, t) => at(t, e),
1345
+ test: (e, t) => Ke(t, e),
1261
1346
  message: "should be an exact date in day month year order (e.g. \"1 APR 1911\")",
1262
1347
  calendarDays: !0
1263
1348
  },
1264
1349
  "date-exact-v7": {
1265
- test: Pe,
1350
+ test: ke,
1266
1351
  message: "should be an exact date in day month year order (e.g. \"1 APR 1911\")",
1267
1352
  calendarDays: !0
1268
1353
  }
1269
- }, ct = /* @__PURE__ */ new WeakMap();
1270
- function lt(e, t) {
1271
- let n = ct.get(e);
1354
+ }, ht = /* @__PURE__ */ new WeakMap();
1355
+ function gt(e, t) {
1356
+ let n = ht.get(e);
1272
1357
  if (n) return n;
1273
1358
  let r = /* @__PURE__ */ new Map();
1274
1359
  for (let n of e.values()) for (let e of n) {
1275
1360
  let n = e.tokens.TAG?.value, i = e.tokens.POINTER?.value;
1276
- if (!(!n || !i)) for (let e of /* @__PURE__ */ new Set([n, T(t, n)])) {
1361
+ if (n && i) for (let e of /* @__PURE__ */ new Set([n, se(t, n)])) {
1277
1362
  let t = r.get(e);
1278
1363
  t || (t = /* @__PURE__ */ new Set(), r.set(e, t)), t.add(i);
1279
1364
  }
1280
1365
  }
1281
- return ct.set(e, r), r;
1366
+ return ht.set(e, r), r;
1282
1367
  }
1283
1368
  var Y = class {
1284
1369
  scheme;
@@ -1289,7 +1374,7 @@ var Y = class {
1289
1374
  }
1290
1375
  isPointerTarget(e, t) {
1291
1376
  let { to: n } = this.getFieldType(e);
1292
- return n ? lt(this.pointerMap, this.extensions).get(this.scheme.tag[n])?.has(t) ?? !1 : !1;
1377
+ return n ? gt(this.pointerMap, this.extensions).get(this.scheme.tag[n])?.has(t) ?? !1 : !1;
1293
1378
  }
1294
1379
  getFieldType(e) {
1295
1380
  let t = this.scheme.payload[e];
@@ -1297,25 +1382,25 @@ var Y = class {
1297
1382
  type: "pointer",
1298
1383
  to: t.to
1299
1384
  } : {
1300
- type: ot[t?.type ?? ""] ?? null,
1385
+ type: pt[t?.type ?? ""] ?? null,
1301
1386
  to: void 0
1302
1387
  };
1303
1388
  }
1304
1389
  mayOmitPayload(e) {
1305
- return e.startsWith(Re) && Fe.has(this.scheme.payload[e]?.type ?? "");
1390
+ return e.startsWith(Ze) && Je.has(this.scheme.payload[e]?.type ?? "");
1306
1391
  }
1307
1392
  validateEnumeration(e, t, n) {
1308
1393
  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))));
1309
- for (let e of o) a.push(E(v(e), r));
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;
1394
+ for (let e of o) a.push(ce(v(e), r));
1395
+ let s = this.scheme.payload[t]?.set, c = s !== void 0 && Xe.has(s), l = c ? i?.map((e) => e.toLowerCase()) : i;
1396
+ return e.some((e) => !C(e) && !l?.includes(c ? e.toLowerCase() : e)) && a.push(J(n, `should be in set [${$e(i)}]`, p.ShouldBeSetValue)), a;
1312
1397
  }
1313
1398
  getAvailableValues(e) {
1314
1399
  let t = this.getFieldType(e), n = this.scheme.payload[e];
1315
1400
  if ((t.type === "select" || t.type === "multiselect") && n.set) return Object.keys(this.scheme.set[n.set]);
1316
1401
  if (t.type === "pointer" && t.to) {
1317
1402
  let e = this.scheme.tag[t.to];
1318
- return [...lt(this.pointerMap, this.extensions).get(e) ?? []];
1403
+ return [...gt(this.pointerMap, this.extensions).get(e) ?? []];
1319
1404
  }
1320
1405
  return null;
1321
1406
  }
@@ -1347,14 +1432,11 @@ var Y = class {
1347
1432
  collect(e, t, n) {
1348
1433
  let r = n || this.getNodeType(t), i = this.getFieldType(r), a = _(t).trim(), o = t.tokens.TAG;
1349
1434
  if (!a && this.mayOmitPayload(r) || i.type === null) return;
1350
- let s = st[i.type];
1351
- if (s) {
1352
- !a || !s.test(a, this.scheme, this.extensions) ? e.push(B(t, s.message)) : s.calendarDays && e.push(...Be(this.scheme, t, a));
1353
- return;
1354
- }
1355
- switch (i.type) {
1435
+ let s = mt[i.type];
1436
+ if (s) !a || !s.test(a, this.scheme, this.extensions) ? e.push(J(t, s.message)) : s.calendarDays && e.push(...et(this.scheme, t, a));
1437
+ else switch (i.type) {
1356
1438
  case "boolean":
1357
- a && a !== "Y" ? e.push(B(t, "should be Y or null")) : !a && t.children.length === 0 && e.push({
1439
+ a && a !== "Y" ? e.push(J(t, "should be Y or null")) : !a && t.children.length === 0 && e.push({
1358
1440
  code: p.EmptyEvent,
1359
1441
  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`,
1360
1442
  range: o?.range || t.range,
@@ -1376,13 +1458,13 @@ var Y = class {
1376
1458
  e.push(...this.validateEnumeration(a.split(",").map((e) => e.trim()), r, t));
1377
1459
  break;
1378
1460
  case "pointer": {
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)) {
1461
+ let n = t.tokens.XREF, a = !!n?.value, s = a && (n.value === q || this.isPointerTarget(r, n.value)), c = t.children.length !== 0;
1462
+ if ((!Ye.has(r) || a) && (a && !s || !a && !c)) {
1381
1463
  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@"`;
1382
1464
  e.push({
1383
- code: a && n?.value !== R ? p.UnresolvedXref : p.MissingRef,
1465
+ code: a && n?.value !== q ? p.UnresolvedXref : p.MissingRef,
1384
1466
  message: c,
1385
- data: a && n?.value !== R ? {
1467
+ data: a && n?.value !== q ? {
1386
1468
  xref: n?.value,
1387
1469
  requiredRecordTag: i.to ? this.scheme.tag[i.to] : void 0
1388
1470
  } : void 0,
@@ -1397,24 +1479,24 @@ var Y = class {
1397
1479
  };
1398
1480
  //#endregion
1399
1481
  //#region src/validator/validate.ts
1400
- function ut(e) {
1482
+ function _t(e) {
1401
1483
  let t = e.match(/^\{(?<a>\d+):(?<b>\d+|M)}$/);
1402
1484
  return t?.groups ? {
1403
1485
  min: parseInt(t.groups.a, 10),
1404
1486
  max: t.groups.b === "M" ? Infinity : parseInt(t.groups.b, 10)
1405
1487
  } : null;
1406
1488
  }
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));
1489
+ var vt = /* @__PURE__ */ new WeakMap();
1490
+ function yt(e, t) {
1491
+ let n = vt.get(e);
1492
+ n || (n = /* @__PURE__ */ new Map(), vt.set(e, n));
1411
1493
  let r = n.get(t);
1412
1494
  if (r) return r;
1413
1495
  let i = e.substructure[t];
1414
1496
  if (!i && !(t in e.payload)) return;
1415
1497
  let a = /* @__PURE__ */ new Map();
1416
1498
  for (let [t, { cardinality: n, type: r }] of Object.entries(i ?? {})) {
1417
- let i = ut(n);
1499
+ let i = _t(n);
1418
1500
  i && a.set(v(t), {
1419
1501
  ...i,
1420
1502
  type: r,
@@ -1423,14 +1505,14 @@ function ft(e, t) {
1423
1505
  }
1424
1506
  return n.set(t, a), a;
1425
1507
  }
1426
- function pt(e, t, n) {
1508
+ function bt(e, t, n) {
1427
1509
  let r = e.tags.get(t), i = r ? y(r) : void 0;
1428
1510
  return i && n.payload[i] ? i : void 0;
1429
1511
  }
1430
- function mt(e) {
1512
+ function xt(e) {
1431
1513
  return S(e)?.startsWith("5") ? x : b;
1432
1514
  }
1433
- var ht = class {
1515
+ var St = class {
1434
1516
  pointers;
1435
1517
  extensions;
1436
1518
  fragment;
@@ -1438,14 +1520,14 @@ var ht = class {
1438
1520
  this.pointers = e, this.extensions = t, this.fragment = n;
1439
1521
  }
1440
1522
  setScheme(e) {
1441
- return mt(e);
1523
+ return xt(e);
1442
1524
  }
1443
1525
  validate(e, t = y(""), n, r) {
1444
1526
  let i = [];
1445
1527
  return this.collect(i, e, t, n || this.setScheme(e), r), i;
1446
1528
  }
1447
1529
  collect(e, t, n, r, i) {
1448
- let a = ft(r, n);
1530
+ let a = yt(r, n);
1449
1531
  if (!a) return;
1450
1532
  let o = /* @__PURE__ */ new Map(), s = r.tag[y(n)], c = new Y(r, this.pointers, this.extensions);
1451
1533
  for (let n of t) {
@@ -1466,8 +1548,8 @@ var ht = class {
1466
1548
  if (t === v("CONT") || t === v("CONC")) continue;
1467
1549
  let i = n.tokens.TAG;
1468
1550
  if (C(t)) {
1469
- this.extensions.requireDeclaration && !this.extensions.tags.has(t) && e.push(E(t, i?.range || n.range));
1470
- let a = pt(this.extensions, t, r);
1551
+ this.extensions.requireDeclaration && !this.extensions.tags.has(t) && e.push(ce(t, i?.range || n.range));
1552
+ let a = bt(this.extensions, t, r);
1471
1553
  a && (c.collect(e, n, a), this.collect(e, n.children, a, r, n));
1472
1554
  continue;
1473
1555
  }
@@ -1545,7 +1627,7 @@ var ht = class {
1545
1627
  scheme: x,
1546
1628
  requiresSchmaDeclaration: !1
1547
1629
  }
1548
- ], gt = [...X].sort((e, t) => t.version.length - e.version.length), _t = X.find(({ kind: e }) => e === "supported"), vt = {
1630
+ ], Ct = [...X].sort((e, t) => t.version.length - e.version.length), wt = X.find(({ kind: e }) => e === "supported"), Tt = {
1549
1631
  start: {
1550
1632
  line: 0,
1551
1633
  character: 0
@@ -1555,7 +1637,7 @@ var ht = class {
1555
1637
  character: 0
1556
1638
  }
1557
1639
  };
1558
- function yt(e) {
1640
+ function Et(e) {
1559
1641
  let t = X.find((t) => t.kind === "supported" && t.dialect === e);
1560
1642
  return {
1561
1643
  scheme: t.scheme,
@@ -1563,14 +1645,14 @@ function yt(e) {
1563
1645
  requiresSchmaDeclaration: t.requiresSchmaDeclaration
1564
1646
  };
1565
1647
  }
1566
- function bt(e) {
1648
+ function Dt(e) {
1567
1649
  let t = (t) => e?.children.findIndex((e) => e.tokens.TAG?.value === t) ?? -1, n = t("SYST");
1568
1650
  if (n === -1) return;
1569
1651
  let r = t("GEDC");
1570
1652
  return r === -1 || n < r ? e?.children[n] : void 0;
1571
1653
  }
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);
1654
+ function Ot(e) {
1655
+ 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 ?? Tt, r = Dt(t);
1574
1656
  if (r) return {
1575
1657
  kind: "paf",
1576
1658
  system: r.tokens.VALUE?.value?.trim() ?? "",
@@ -1578,7 +1660,7 @@ function xt(e) {
1578
1660
  };
1579
1661
  let i = S(e);
1580
1662
  if (!i) {
1581
- let { scheme: e, dialect: t, requiresSchmaDeclaration: r } = _t;
1663
+ let { scheme: e, dialect: t, requiresSchmaDeclaration: r } = wt;
1582
1664
  return {
1583
1665
  kind: "undetermined",
1584
1666
  scheme: e,
@@ -1587,7 +1669,7 @@ function xt(e) {
1587
1669
  range: n
1588
1670
  };
1589
1671
  }
1590
- let a = gt.find(({ version: e }) => i.startsWith(e));
1672
+ let a = Ct.find(({ version: e }) => i.startsWith(e));
1591
1673
  return a ? {
1592
1674
  ...a,
1593
1675
  range: n
@@ -1604,7 +1686,7 @@ var Z = {
1604
1686
  months: null,
1605
1687
  epochs: null,
1606
1688
  keywords: []
1607
- }, St = [
1689
+ }, kt = [
1608
1690
  "ABT",
1609
1691
  "CAL",
1610
1692
  "EST",
@@ -1613,16 +1695,16 @@ var Z = {
1613
1695
  "BET",
1614
1696
  "FROM",
1615
1697
  "TO"
1616
- ], Ct = ["FROM", "TO"], wt = {
1698
+ ], At = ["FROM", "TO"], jt = {
1617
1699
  BET: "AND",
1618
1700
  FROM: "TO"
1619
1701
  }, Q = /^\d+$/u;
1620
- function Tt(e) {
1621
- let t = _e(e);
1702
+ function Mt(e) {
1703
+ let t = M(e);
1622
1704
  return /\s$/u.test(e) ? t : t.slice(0, -1);
1623
1705
  }
1624
- function Et(e, t) {
1625
- let n = 0, r = O, i = t[0] === void 0 ? null : he(e, t[0]);
1706
+ function Nt(e, t) {
1707
+ let n = 0, r = E, i = t[0] === void 0 ? null : A(e, t[0]);
1626
1708
  i !== null && (r = i, n = 1);
1627
1709
  let a = t.slice(n);
1628
1710
  if (a.length === 0) return {
@@ -1632,7 +1714,7 @@ function Et(e, t) {
1632
1714
  keywords: [],
1633
1715
  complete: !1
1634
1716
  };
1635
- let { epochs: o } = A(e, r);
1717
+ let { epochs: o } = O(e, r);
1636
1718
  if (a.some((e) => o?.has(e))) return {
1637
1719
  ...Z,
1638
1720
  complete: !0
@@ -1656,20 +1738,20 @@ function Et(e, t) {
1656
1738
  complete: l
1657
1739
  };
1658
1740
  }
1659
- function Dt(e, t, n) {
1660
- let r = Tt(t);
1741
+ function Pt(e, t, n) {
1742
+ let r = Mt(t);
1661
1743
  if (n === "exact") return r.length === 1 ? {
1662
1744
  ...Z,
1663
- months: O
1745
+ months: E
1664
1746
  } : Z;
1665
- let i = n === "period" ? Ct : St;
1747
+ let i = n === "period" ? At : kt;
1666
1748
  if (r.length === 0) return {
1667
1749
  calendars: !0,
1668
- months: O,
1750
+ months: E,
1669
1751
  epochs: null,
1670
1752
  keywords: i
1671
1753
  };
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));
1754
+ let a = i.includes(r[0]) ? r[0] : null, o = a === null ? r : r.slice(1), s = a === null ? void 0 : jt[a], c = s === void 0 ? -1 : o.indexOf(s), l = Nt(e, c === -1 ? o : o.slice(c + 1));
1673
1755
  return {
1674
1756
  calendars: l.calendars,
1675
1757
  months: l.months,
@@ -1679,16 +1761,16 @@ function Dt(e, t, n) {
1679
1761
  }
1680
1762
  //#endregion
1681
1763
  //#region src/completion/completion.ts
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);
1764
+ var Ft = /^(\d+)\s+(?:@[^\s@]+@\s+)?([A-Za-z0-9_]*)$/, It = /^(\d+)\s+(?:@[^\s@]+@\s+)?([A-Za-z0-9_]+)\s+(.*)$/, Lt = /* @__PURE__ */ new WeakMap();
1765
+ function Rt(e) {
1766
+ let t = Lt.get(e);
1685
1767
  if (t) return t;
1686
1768
  let n = [], r = (e) => {
1687
1769
  for (let t of e) n.push(t), r(t.children);
1688
1770
  };
1689
- return r(e), $.set(e, n), n;
1771
+ return r(e), Lt.set(e, n), n;
1690
1772
  }
1691
- function jt(e, t) {
1773
+ function zt(e, t) {
1692
1774
  let n = 0, r = e.length;
1693
1775
  for (; n < r;) {
1694
1776
  let i = n + r >> 1;
@@ -1696,11 +1778,11 @@ function jt(e, t) {
1696
1778
  }
1697
1779
  return n - 1;
1698
1780
  }
1699
- function Mt(e) {
1781
+ function Bt(e) {
1700
1782
  let t = /^\{\d+:(\d+|M)\}$/.exec(e);
1701
1783
  return t ? t[1] === "M" ? Infinity : Number(t[1]) : null;
1702
1784
  }
1703
- function Nt(e, t) {
1785
+ function Vt(e, t) {
1704
1786
  let n = e, r = t;
1705
1787
  for (; n;) {
1706
1788
  if (n.level !== r || !n.tokens.TAG?.value) return !1;
@@ -1708,12 +1790,12 @@ function Nt(e, t) {
1708
1790
  }
1709
1791
  return r === -1;
1710
1792
  }
1711
- function Pt(e, t) {
1793
+ function $(e, t) {
1712
1794
  if (t === 0) return {
1713
1795
  parentType: y(""),
1714
1796
  siblings: e.nodes
1715
1797
  };
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;
1798
+ let n = Rt(e.nodes), r = zt(n, e.position.line), i = r >= 0 && n[r].range.start.line === e.position.line ? n[r] : void 0, a;
1717
1799
  if (i) {
1718
1800
  if (i.level !== t || i.parent?.level !== t - 1) return null;
1719
1801
  a = i.parent;
@@ -1725,18 +1807,18 @@ function Pt(e, t) {
1725
1807
  break;
1726
1808
  }
1727
1809
  }
1728
- if (!a || !Nt(a, t - 1)) return null;
1810
+ if (!a || !Vt(a, t - 1)) return null;
1729
1811
  let o = new Y(e.scheme, e.pointers).getNodeType(a);
1730
1812
  return o ? {
1731
1813
  parentType: o,
1732
1814
  siblings: a.children
1733
1815
  } : null;
1734
1816
  }
1735
- function Ft(e, t) {
1736
- let n = Pt(e, t);
1817
+ function Ht(e, t) {
1818
+ let n = $(e, t);
1737
1819
  if (!n) return [];
1738
1820
  let r = Object.entries(e.scheme.substructure[n.parentType] ?? {}).filter(([t, r]) => {
1739
- let i = Mt(r.cardinality);
1821
+ let i = Bt(r.cardinality);
1740
1822
  return i === null || i === Infinity || n.siblings.filter((n) => n.range.start.line !== e.position.line && n.tokens.TAG?.value === t).length < i;
1741
1823
  }).map(([t, n]) => ({
1742
1824
  label: v(t),
@@ -1749,7 +1831,7 @@ function Ft(e, t) {
1749
1831
  }));
1750
1832
  return [...r, ...i];
1751
1833
  }
1752
- var It = {
1834
+ var Ut = {
1753
1835
  "date-v7": {
1754
1836
  grammar: "value",
1755
1837
  escaped: !1
@@ -1775,8 +1857,8 @@ var It = {
1775
1857
  escaped: !0
1776
1858
  }
1777
1859
  };
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);
1860
+ function Wt(e, { grammar: t, escaped: n }, r) {
1861
+ let i = Pt(e.scheme, r, t), a = (t) => t === null ? void 0 : e.scheme.calendar[v(t)], o = Object.keys(e.scheme.calendar).map((e) => n ? ge(e) : e);
1780
1862
  return [
1781
1863
  ...i.calendars ? o : [],
1782
1864
  ...Object.keys(a(i.months)?.months ?? {}),
@@ -1787,13 +1869,13 @@ function Lt(e, { grammar: t, escaped: n }, r) {
1787
1869
  kind: "enum"
1788
1870
  }));
1789
1871
  }
1790
- function Rt(e, t, n, r) {
1791
- let i = Pt(e, t);
1872
+ function Gt(e, t, n, r) {
1873
+ let i = $(e, t);
1792
1874
  if (!i) return [];
1793
1875
  let a = e.scheme.substructure[i.parentType]?.[v(n.toUpperCase())]?.type;
1794
1876
  if (!a) return [];
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);
1877
+ let o = new Y(e.scheme, e.pointers), s = o.getFieldType(a), c = s.type === null ? void 0 : Ut[s.type];
1878
+ if (c) return Wt(e, c, r);
1797
1879
  if (s.type === "select" || s.type === "multiselect") return [...new Set(o.getAvailableValues(a) ?? [])].filter(Boolean).map((e) => ({
1798
1880
  label: e,
1799
1881
  kind: "enum"
@@ -1807,22 +1889,23 @@ function Rt(e, t, n, r) {
1807
1889
  }
1808
1890
  return [];
1809
1891
  }
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]) : [];
1892
+ function Kt(e) {
1893
+ let t = e.lineText.slice(0, e.position.character), n = Ft.exec(t);
1894
+ if (n) return Ht(e, Number(n[1]));
1895
+ let r = It.exec(t);
1896
+ return r ? Gt(e, Number(r[1]), r[2], r[3]) : [];
1815
1897
  }
1816
1898
  //#endregion
1817
1899
  //#region src/document/gedcomDocument.ts
1818
- function Bt(e) {
1900
+ function qt(e) {
1819
1901
  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`;
1820
1902
  }
1821
- var Vt = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), Ht = class {
1903
+ var Jt = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), Yt = class {
1822
1904
  nodes = [];
1823
1905
  pointers = /* @__PURE__ */ new Map();
1824
1906
  errors = [];
1825
1907
  scheme;
1908
+ validatedAs;
1826
1909
  resolution;
1827
1910
  requiresSchmaDeclaration = !1;
1828
1911
  extensions = w();
@@ -1840,7 +1923,7 @@ var Vt = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), Ht = cl
1840
1923
  let r = t.line ?? 0, o = t.column ?? 0;
1841
1924
  o < (n.get(r) ?? Infinity) && i.add(r), !a.has(r) && (a.add(r), this.errors.push({
1842
1925
  code: p.Lexer,
1843
- message: Bt(e.slice(t.offset, t.offset + t.length)),
1926
+ message: qt(e.slice(t.offset, t.offset + t.length)),
1844
1927
  range: {
1845
1928
  start: {
1846
1929
  line: r,
@@ -1866,9 +1949,9 @@ var Vt = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), Ht = cl
1866
1949
  }
1867
1950
  createDocument(e, t = {}) {
1868
1951
  let { nodes: n, pointers: r } = this.parseGedcom(e);
1869
- this.nodes = n, this.pointers = r, this.scheme = void 0, this.requiresSchmaDeclaration = !1, this.extensions = w(), this.validateLevels(this.errors, n);
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;
1952
+ this.nodes = n, this.pointers = r, this.scheme = void 0, this.validatedAs = void 0, this.requiresSchmaDeclaration = !1, this.extensions = w(), this.validateLevels(this.errors, n);
1953
+ let i = Ot(n);
1954
+ if (this.resolution = i, t.fragment && t.dialect && i.kind === "undetermined") return this.applyScheme(n, Et(t.dialect), t), this;
1872
1955
  if (i.kind === "undetermined") return this.scheme = i.scheme, this.requiresSchmaDeclaration = i.requiresSchmaDeclaration, this.errors.push({
1873
1956
  code: p.UndeterminedVersion,
1874
1957
  message: "No GEDCOM version in HEAD.GEDC.VERS, so the file cannot be checked against a specification",
@@ -1897,11 +1980,11 @@ var Vt = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), Ht = cl
1897
1980
  }), this.applyScheme(n, i, t), this);
1898
1981
  }
1899
1982
  applyScheme(e, t, n) {
1900
- this.scheme = t.scheme, this.requiresSchmaDeclaration = t.requiresSchmaDeclaration;
1901
- let { context: r, errors: i } = le(e, this.requiresSchmaDeclaration, this.scheme);
1983
+ this.scheme = t.scheme, this.validatedAs = t.dialect, this.requiresSchmaDeclaration = t.requiresSchmaDeclaration;
1984
+ let { context: r, errors: i } = de(e, this.requiresSchmaDeclaration, this.scheme);
1902
1985
  this.extensions = r;
1903
1986
  for (let e of i) this.errors.push(e);
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)));
1987
+ new St(this.pointers, r, n.fragment ?? !1).collect(this.errors, this.nodes, y(""), this.scheme), n.fragment && (this.errors = this.errors.filter((e) => !Jt.has(e.code)));
1905
1988
  }
1906
1989
  validateLevels(e, t, n = 0) {
1907
1990
  for (let r of t) r.level !== n && e.push({
@@ -1945,7 +2028,7 @@ var Vt = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), Ht = cl
1945
2028
  return this.resolution && "dialect" in this.resolution ? this.resolution.dialect : void 0;
1946
2029
  }
1947
2030
  getCompletions(e, t) {
1948
- return this.scheme ? zt({
2031
+ return this.scheme ? Kt({
1949
2032
  nodes: this.nodes,
1950
2033
  pointers: this.pointers,
1951
2034
  scheme: this.scheme,
@@ -1955,6 +2038,10 @@ var Vt = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), Ht = cl
1955
2038
  lineText: t
1956
2039
  }) : [];
1957
2040
  }
2041
+ readDate(e) {
2042
+ let t = e.trim();
2043
+ return !this.scheme || !this.validatedAs || I(this.scheme, t).length > 0 ? null : this.validatedAs === "7.0" ? De(t, this.scheme, this.extensions) : qe(this.scheme, t);
2044
+ }
1958
2045
  getErrors() {
1959
2046
  return this.errors;
1960
2047
  }
@@ -1963,4 +2050,4 @@ var Vt = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), Ht = cl
1963
2050
  }
1964
2051
  };
1965
2052
  //#endregion
1966
- export { Ht as GedcomDocument, p as GedcomErrorCode, r as TokenNames };
2053
+ export { Yt as GedcomDocument, p as GedcomErrorCode, r as TokenNames };