@domorium/validator 2.0.0 → 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 M(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 he(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 he(e) {
951
951
  rest: e
952
952
  };
953
953
  }
954
- function N(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 ge = "(?:[Bb][Cc][Ee]|[Bb]\\.?[Cc]\\.?)", _e = RegExp(`^${ge}$`);
959
+ var N = "(?:[Bb][Cc][Ee]|[Bb]\\.?[Cc]\\.?)", _e = RegExp(`^${N}$`);
960
960
  function ve(e) {
961
961
  return e !== void 0 && _e.test(e);
962
962
  }
963
963
  //#endregion
964
964
  //#region src/validator/calendarDays.ts
965
- var ye = {
965
+ var P = {
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
+ }, ye = /* @__PURE__ */ new Set([E, "JULIAN"]), F = /^\d+$/u, be = /* @__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 xe(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 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;
985
996
  }
986
- function we(e) {
997
+ function Ce(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 I(e, t) {
1001
+ let n = M(Ce(t)), r = [], i = E;
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 (be.has(a)) {
1005
+ i = E;
1006
+ continue;
1007
+ }
1008
+ let o = A(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 (!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);
1000
1016
  c !== null && (l < 1 || l > c) && r.push({
1001
1017
  day: l,
1002
1018
  month: s,
@@ -1007,71 +1023,197 @@ function Te(e, t) {
1007
1023
  }
1008
1024
  //#endregion
1009
1025
  //#region src/validator/date-v7.ts
1010
- var P = /^\d+$/, Ee = [
1026
+ var L = /^\d+$/, R = [
1011
1027
  "ABT",
1012
1028
  "CAL",
1013
1029
  "EST"
1014
- ], F = -1;
1015
- function I(e, t, n) {
1016
- let r = t, i = e[r];
1017
- if (i === void 0) return F;
1018
- let a = O;
1019
- (n.calendar[v(i)] || C(i)) && (a = v(i), r += 1);
1020
- 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;
1022
- }
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);
1028
- }
1029
- function De(e, t, n) {
1030
- let r = e[t];
1031
- if (r !== void 0 && Ee.includes(r)) return I(e, t + 1, n);
1032
- if (r === "BET") {
1033
- let r = I(e, t + 1, n);
1034
- return r === F || e[r] !== "AND" ? F : I(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);
1035
1054
  }
1036
- return r === "AFT" || r === "BEF" ? I(e, t + 1, n) : r === "FROM" || r === "TO" ? L(e, t, n) : I(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);
1037
1056
  }
1038
- function Oe(e) {
1057
+ function we(e) {
1039
1058
  return e.trim().split(/\s+/);
1040
1059
  }
1041
- function R(e, t) {
1042
- return Oe(e).map((e) => T(t, e));
1060
+ function U(e, t) {
1061
+ return we(e).map((e) => se(t, e));
1043
1062
  }
1044
- function z(e, t, n, r) {
1045
- let i = R(e, n);
1046
- 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;
1047
1066
  }
1048
- function ke(e, t, n = w()) {
1049
- return z(e, t, n, De);
1067
+ function Te(e, t, n = w()) {
1068
+ return W(e, t, n, H);
1050
1069
  }
1051
- function Ae(e, t, n = w()) {
1052
- return z(e, t, n, L);
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
+ };
1053
1090
  }
1054
- function je(e, t, n = w()) {
1055
- let r = R(e, n);
1091
+ function Oe(e, t, n = w()) {
1092
+ return W(e, t, n, V);
1093
+ }
1094
+ function ke(e, t, n = w()) {
1095
+ let r = U(e, n);
1056
1096
  if (r.length !== 3) return !1;
1057
- let { months: i } = A(t, O);
1058
- return P.test(r[0]) && j(i, r[1]) && P.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
+ };
1059
1201
  }
1060
1202
  //#endregion
1061
1203
  //#region src/validator/rule-node.ts
1062
- var B = "@VOID@", Me = /* @__PURE__ */ new Set([
1204
+ var q = "@VOID@", Je = /* @__PURE__ */ new Set([
1063
1205
  "http://www.w3.org/2001/XMLSchema#string",
1064
1206
  "https://gedcom.io/terms/v7/type-List#Text",
1065
1207
  "https://gedcom.io/terms/v7/type-Date",
1066
1208
  "https://gedcom.io/terms/v7/type-Date#period",
1067
1209
  "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) {
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) {
1070
1212
  if (!e?.length) return "";
1071
- let t = e.slice(0, V).join(", "), n = e.length - V;
1213
+ let t = e.slice(0, Qe).join(", "), n = e.length - Qe;
1072
1214
  return n > 0 ? `${t}, … ${n} more` : t;
1073
1215
  }
1074
- function H(e, t, n = p.IncorrectValue) {
1216
+ function J(e, t, n = p.IncorrectValue) {
1075
1217
  return {
1076
1218
  code: _(e).trim() ? n : p.MissingValue,
1077
1219
  message: `Value for ${e.tokens.TAG?.value} ${t}`,
@@ -1079,31 +1221,10 @@ function H(e, t, n = p.IncorrectValue) {
1079
1221
  level: "error"
1080
1222
  };
1081
1223
  }
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));
1084
- }
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}`;
1088
- 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}$`)
1092
- };
1093
- }
1094
- function Ye(e, t) {
1095
- let n = K.get(e);
1096
- n || (n = /* @__PURE__ */ new Map(), K.set(e, n));
1097
- let r = n.get(t);
1098
- if (r !== void 0) return r;
1099
- let i = Object.keys(e.calendar[v(t)]?.months ?? {}), a = i.length === 0 ? null : Je(i);
1100
- return n.set(t, a), a;
1101
- }
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);
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));
1105
1226
  }
1106
- var Xe = {
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 = {
1107
1228
  "Y|<NULL>": "boolean",
1108
1229
  "http://www.w3.org/2001/XMLSchema#string": "string",
1109
1230
  "https://gedcom.io/terms/v7/type-List#Text": "string",
@@ -1155,96 +1276,96 @@ var Xe = {
1155
1276
  "https://gedcom.io/terms/v5.5.1/type-TIME_VALUE": "time",
1156
1277
  "https://gedcom.io/terms/v7/type-Age": "age-v7",
1157
1278
  "https://gedcom.io/terms/v5.5.1/type-AGE_AT_EVENT": "age"
1158
- }, Ze = {
1279
+ }, mt = {
1159
1280
  latitude: {
1160
- test: (e) => Ge.test(e),
1281
+ test: (e) => ut.test(e),
1161
1282
  message: "should be correct latitude (e.g. \"N18.150944\")"
1162
1283
  },
1163
1284
  longitude: {
1164
- test: (e) => Ke.test(e),
1285
+ test: (e) => dt.test(e),
1165
1286
  message: "should be correct longitude (e.g. \"W46.6\")"
1166
1287
  },
1167
1288
  "personal-name": {
1168
- test: (e) => He.test(e),
1289
+ test: (e) => st.test(e),
1169
1290
  message: "should be a name, with the surname (if any) wrapped in a single pair of slashes (e.g. \"John /Doe/\")"
1170
1291
  },
1171
1292
  "media-type": {
1172
- test: (e) => Ue.test(e),
1293
+ test: (e) => ct.test(e),
1173
1294
  message: "should be a media type in the form \"type/subtype\" (e.g. \"image/jpeg\")"
1174
1295
  },
1175
1296
  "language-tag": {
1176
- test: (e) => qe.test(e),
1297
+ test: (e) => ft.test(e),
1177
1298
  message: "should be a valid RFC 5646 language tag (e.g. \"en\", \"en-US\")"
1178
1299
  },
1179
1300
  "tag-def": {
1180
- test: (e) => !!ce(e),
1301
+ test: (e) => !!ue(e),
1181
1302
  message: "should be an extension tag and its URI (e.g. \"_SKYPEID http://xmlns.com/foaf/0.1/skypeID\")"
1182
1303
  },
1183
1304
  nonNegativeInteger: {
1184
- test: (e) => We.test(e),
1305
+ test: (e) => lt.test(e),
1185
1306
  message: "should be a whole number, zero or greater"
1186
1307
  },
1187
1308
  time: {
1188
- test: (e) => Re.test(e),
1309
+ test: (e) => nt.test(e),
1189
1310
  message: "should be correct time"
1190
1311
  },
1191
1312
  "time-v7": {
1192
- test: (e) => ze.test(e),
1313
+ test: (e) => rt.test(e),
1193
1314
  message: "should be correct time"
1194
1315
  },
1195
1316
  age: {
1196
- test: (e) => Ve.test(e),
1317
+ test: (e) => ot.test(e),
1197
1318
  message: "should be correct age (e.g. \"35y 11m 8w 21d\", \"< 1y\", \"CHILD\")"
1198
1319
  },
1199
1320
  "age-v7": {
1200
- test: (e) => Be.test(e),
1321
+ test: (e) => at.test(e),
1201
1322
  message: "should be correct age (e.g. \"35y 11m 8w 21d\", \"< 1y\", \"CHILD\")"
1202
1323
  },
1203
1324
  date: {
1204
- test: (e, t) => q(t, e, "value"),
1325
+ test: (e, t) => Ge(t, e),
1205
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)\")",
1206
1327
  calendarDays: !0
1207
1328
  },
1208
1329
  "date-v7": {
1209
- test: ke,
1330
+ test: Te,
1210
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\")",
1211
1332
  calendarDays: !0
1212
1333
  },
1213
1334
  "date-period": {
1214
- test: (e, t) => q(t, e, "period"),
1335
+ test: (e, t) => We(t, e),
1215
1336
  message: "should be a valid date period (e.g. \"FROM 1900 TO 1910\", \"TO 1920\")",
1216
1337
  calendarDays: !0
1217
1338
  },
1218
1339
  "date-period-v7": {
1219
- test: Ae,
1340
+ test: Oe,
1220
1341
  message: "should be a valid date period (e.g. \"FROM 1900 TO 1910\", \"TO 1920\")",
1221
1342
  calendarDays: !0
1222
1343
  },
1223
1344
  "date-exact": {
1224
- test: (e, t) => q(t, e, "exact"),
1345
+ test: (e, t) => Ke(t, e),
1225
1346
  message: "should be an exact date in day month year order (e.g. \"1 APR 1911\")",
1226
1347
  calendarDays: !0
1227
1348
  },
1228
1349
  "date-exact-v7": {
1229
- test: je,
1350
+ test: ke,
1230
1351
  message: "should be an exact date in day month year order (e.g. \"1 APR 1911\")",
1231
1352
  calendarDays: !0
1232
1353
  }
1233
- }, J = /* @__PURE__ */ new WeakMap();
1234
- function Y(e, t) {
1235
- let n = J.get(e);
1354
+ }, ht = /* @__PURE__ */ new WeakMap();
1355
+ function gt(e, t) {
1356
+ let n = ht.get(e);
1236
1357
  if (n) return n;
1237
1358
  let r = /* @__PURE__ */ new Map();
1238
1359
  for (let n of e.values()) for (let e of n) {
1239
1360
  let n = e.tokens.TAG?.value, i = e.tokens.POINTER?.value;
1240
- 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)])) {
1241
1362
  let t = r.get(e);
1242
1363
  t || (t = /* @__PURE__ */ new Set(), r.set(e, t)), t.add(i);
1243
1364
  }
1244
1365
  }
1245
- return J.set(e, r), r;
1366
+ return ht.set(e, r), r;
1246
1367
  }
1247
- var X = class {
1368
+ var Y = class {
1248
1369
  scheme;
1249
1370
  pointerMap;
1250
1371
  extensions;
@@ -1253,7 +1374,7 @@ var X = class {
1253
1374
  }
1254
1375
  isPointerTarget(e, t) {
1255
1376
  let { to: n } = this.getFieldType(e);
1256
- return n ? Y(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;
1257
1378
  }
1258
1379
  getFieldType(e) {
1259
1380
  let t = this.scheme.payload[e];
@@ -1261,25 +1382,25 @@ var X = class {
1261
1382
  type: "pointer",
1262
1383
  to: t.to
1263
1384
  } : {
1264
- type: Xe[t?.type ?? ""] ?? null,
1385
+ type: pt[t?.type ?? ""] ?? null,
1265
1386
  to: void 0
1266
1387
  };
1267
1388
  }
1268
1389
  mayOmitPayload(e) {
1269
- return e.startsWith(Fe) && Me.has(this.scheme.payload[e]?.type ?? "");
1390
+ return e.startsWith(Ze) && Je.has(this.scheme.payload[e]?.type ?? "");
1270
1391
  }
1271
1392
  validateEnumeration(e, t, n) {
1272
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))));
1273
- 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;
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;
1276
1397
  }
1277
1398
  getAvailableValues(e) {
1278
1399
  let t = this.getFieldType(e), n = this.scheme.payload[e];
1279
1400
  if ((t.type === "select" || t.type === "multiselect") && n.set) return Object.keys(this.scheme.set[n.set]);
1280
1401
  if (t.type === "pointer" && t.to) {
1281
1402
  let e = this.scheme.tag[t.to];
1282
- return [...Y(this.pointerMap, this.extensions).get(e) ?? []];
1403
+ return [...gt(this.pointerMap, this.extensions).get(e) ?? []];
1283
1404
  }
1284
1405
  return null;
1285
1406
  }
@@ -1311,14 +1432,11 @@ var X = class {
1311
1432
  collect(e, t, n) {
1312
1433
  let r = n || this.getNodeType(t), i = this.getFieldType(r), a = _(t).trim(), o = t.tokens.TAG;
1313
1434
  if (!a && this.mayOmitPayload(r) || i.type === null) return;
1314
- let s = Ze[i.type];
1315
- 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));
1317
- return;
1318
- }
1319
- 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) {
1320
1438
  case "boolean":
1321
- a && a !== "Y" ? e.push(H(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({
1322
1440
  code: p.EmptyEvent,
1323
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`,
1324
1442
  range: o?.range || t.range,
@@ -1340,13 +1458,13 @@ var X = class {
1340
1458
  e.push(...this.validateEnumeration(a.split(",").map((e) => e.trim()), r, t));
1341
1459
  break;
1342
1460
  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)) {
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)) {
1345
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@"`;
1346
1464
  e.push({
1347
- code: a && n?.value !== B ? p.UnresolvedXref : p.MissingRef,
1465
+ code: a && n?.value !== q ? p.UnresolvedXref : p.MissingRef,
1348
1466
  message: c,
1349
- data: a && n?.value !== B ? {
1467
+ data: a && n?.value !== q ? {
1350
1468
  xref: n?.value,
1351
1469
  requiredRecordTag: i.to ? this.scheme.tag[i.to] : void 0
1352
1470
  } : void 0,
@@ -1361,24 +1479,24 @@ var X = class {
1361
1479
  };
1362
1480
  //#endregion
1363
1481
  //#region src/validator/validate.ts
1364
- function Qe(e) {
1482
+ function _t(e) {
1365
1483
  let t = e.match(/^\{(?<a>\d+):(?<b>\d+|M)}$/);
1366
1484
  return t?.groups ? {
1367
1485
  min: parseInt(t.groups.a, 10),
1368
1486
  max: t.groups.b === "M" ? Infinity : parseInt(t.groups.b, 10)
1369
1487
  } : null;
1370
1488
  }
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));
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));
1375
1493
  let r = n.get(t);
1376
1494
  if (r) return r;
1377
1495
  let i = e.substructure[t];
1378
1496
  if (!i && !(t in e.payload)) return;
1379
1497
  let a = /* @__PURE__ */ new Map();
1380
1498
  for (let [t, { cardinality: n, type: r }] of Object.entries(i ?? {})) {
1381
- let i = Qe(n);
1499
+ let i = _t(n);
1382
1500
  i && a.set(v(t), {
1383
1501
  ...i,
1384
1502
  type: r,
@@ -1387,14 +1505,14 @@ function et(e, t) {
1387
1505
  }
1388
1506
  return n.set(t, a), a;
1389
1507
  }
1390
- function tt(e, t, n) {
1508
+ function bt(e, t, n) {
1391
1509
  let r = e.tags.get(t), i = r ? y(r) : void 0;
1392
1510
  return i && n.payload[i] ? i : void 0;
1393
1511
  }
1394
- function nt(e) {
1512
+ function xt(e) {
1395
1513
  return S(e)?.startsWith("5") ? x : b;
1396
1514
  }
1397
- var rt = class {
1515
+ var St = class {
1398
1516
  pointers;
1399
1517
  extensions;
1400
1518
  fragment;
@@ -1402,16 +1520,16 @@ var rt = class {
1402
1520
  this.pointers = e, this.extensions = t, this.fragment = n;
1403
1521
  }
1404
1522
  setScheme(e) {
1405
- return nt(e);
1523
+ return xt(e);
1406
1524
  }
1407
1525
  validate(e, t = y(""), n, r) {
1408
1526
  let i = [];
1409
1527
  return this.collect(i, e, t, n || this.setScheme(e), r), i;
1410
1528
  }
1411
1529
  collect(e, t, n, r, i) {
1412
- let a = et(r, n);
1530
+ let a = yt(r, n);
1413
1531
  if (!a) return;
1414
- let o = /* @__PURE__ */ new Map(), s = r.tag[y(n)], c = new X(r, this.pointers, this.extensions);
1532
+ let o = /* @__PURE__ */ new Map(), s = r.tag[y(n)], c = new Y(r, this.pointers, this.extensions);
1415
1533
  for (let n of t) {
1416
1534
  if (n.tokens.LEVEL === void 0) continue;
1417
1535
  let t = n.tokens.TAG?.value ? v(n.tokens.TAG?.value) : void 0;
@@ -1430,8 +1548,8 @@ var rt = class {
1430
1548
  if (t === v("CONT") || t === v("CONC")) continue;
1431
1549
  let i = n.tokens.TAG;
1432
1550
  if (C(t)) {
1433
- this.extensions.requireDeclaration && !this.extensions.tags.has(t) && e.push(E(t, i?.range || n.range));
1434
- let a = tt(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);
1435
1553
  a && (c.collect(e, n, a), this.collect(e, n.children, a, r, n));
1436
1554
  continue;
1437
1555
  }
@@ -1473,7 +1591,7 @@ var rt = class {
1473
1591
  });
1474
1592
  }
1475
1593
  }
1476
- }, Z = [
1594
+ }, X = [
1477
1595
  {
1478
1596
  kind: "supported",
1479
1597
  version: "7.0",
@@ -1509,7 +1627,7 @@ var rt = class {
1509
1627
  scheme: x,
1510
1628
  requiresSchmaDeclaration: !1
1511
1629
  }
1512
- ], it = [...Z].sort((e, t) => t.version.length - e.version.length), at = Z.find(({ kind: e }) => e === "supported"), ot = {
1630
+ ], Ct = [...X].sort((e, t) => t.version.length - e.version.length), wt = X.find(({ kind: e }) => e === "supported"), Tt = {
1513
1631
  start: {
1514
1632
  line: 0,
1515
1633
  character: 0
@@ -1519,22 +1637,22 @@ var rt = class {
1519
1637
  character: 0
1520
1638
  }
1521
1639
  };
1522
- function st(e) {
1523
- let t = Z.find((t) => t.kind === "supported" && t.dialect === e);
1640
+ function Et(e) {
1641
+ let t = X.find((t) => t.kind === "supported" && t.dialect === e);
1524
1642
  return {
1525
1643
  scheme: t.scheme,
1526
1644
  dialect: t.dialect,
1527
1645
  requiresSchmaDeclaration: t.requiresSchmaDeclaration
1528
1646
  };
1529
1647
  }
1530
- function ct(e) {
1648
+ function Dt(e) {
1531
1649
  let t = (t) => e?.children.findIndex((e) => e.tokens.TAG?.value === t) ?? -1, n = t("SYST");
1532
1650
  if (n === -1) return;
1533
1651
  let r = t("GEDC");
1534
1652
  return r === -1 || n < r ? e?.children[n] : void 0;
1535
1653
  }
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);
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);
1538
1656
  if (r) return {
1539
1657
  kind: "paf",
1540
1658
  system: r.tokens.VALUE?.value?.trim() ?? "",
@@ -1542,7 +1660,7 @@ function lt(e) {
1542
1660
  };
1543
1661
  let i = S(e);
1544
1662
  if (!i) {
1545
- let { scheme: e, dialect: t, requiresSchmaDeclaration: r } = at;
1663
+ let { scheme: e, dialect: t, requiresSchmaDeclaration: r } = wt;
1546
1664
  return {
1547
1665
  kind: "undetermined",
1548
1666
  scheme: e,
@@ -1551,7 +1669,7 @@ function lt(e) {
1551
1669
  range: n
1552
1670
  };
1553
1671
  }
1554
- let a = it.find(({ version: e }) => i.startsWith(e));
1672
+ let a = Ct.find(({ version: e }) => i.startsWith(e));
1555
1673
  return a ? {
1556
1674
  ...a,
1557
1675
  range: n
@@ -1563,12 +1681,12 @@ function lt(e) {
1563
1681
  }
1564
1682
  //#endregion
1565
1683
  //#region src/completion/dateSlot.ts
1566
- var Q = {
1684
+ var Z = {
1567
1685
  calendars: !1,
1568
1686
  months: null,
1569
1687
  epochs: null,
1570
1688
  keywords: []
1571
- }, ut = [
1689
+ }, kt = [
1572
1690
  "ABT",
1573
1691
  "CAL",
1574
1692
  "EST",
@@ -1577,16 +1695,16 @@ var Q = {
1577
1695
  "BET",
1578
1696
  "FROM",
1579
1697
  "TO"
1580
- ], dt = ["FROM", "TO"], ft = {
1698
+ ], At = ["FROM", "TO"], jt = {
1581
1699
  BET: "AND",
1582
1700
  FROM: "TO"
1583
- }, $ = /^\d+$/u;
1584
- function pt(e) {
1585
- let t = N(e);
1701
+ }, Q = /^\d+$/u;
1702
+ function Mt(e) {
1703
+ let t = M(e);
1586
1704
  return /\s$/u.test(e) ? t : t.slice(0, -1);
1587
1705
  }
1588
- function mt(e, t) {
1589
- let n = 0, r = O, i = t[0] === void 0 ? null : M(e, t[0]);
1706
+ function Nt(e, t) {
1707
+ let n = 0, r = E, i = t[0] === void 0 ? null : A(e, t[0]);
1590
1708
  i !== null && (r = i, n = 1);
1591
1709
  let a = t.slice(n);
1592
1710
  if (a.length === 0) return {
@@ -1596,16 +1714,16 @@ function mt(e, t) {
1596
1714
  keywords: [],
1597
1715
  complete: !1
1598
1716
  };
1599
- let { epochs: o } = A(e, r);
1717
+ let { epochs: o } = O(e, r);
1600
1718
  if (a.some((e) => o?.has(e))) return {
1601
- ...Q,
1719
+ ...Z,
1602
1720
  complete: !0
1603
1721
  };
1604
1722
  let s = 0;
1605
- $.test(a[s] ?? "") && !$.test(a[s + 1] ?? "0") && (s += 1);
1606
- let c = a[s] !== void 0 && !$.test(a[s]);
1723
+ Q.test(a[s] ?? "") && !Q.test(a[s + 1] ?? "0") && (s += 1);
1724
+ let c = a[s] !== void 0 && !Q.test(a[s]);
1607
1725
  c && (s += 1);
1608
- let l = $.test(a[s] ?? "");
1726
+ let l = Q.test(a[s] ?? "");
1609
1727
  return c ? {
1610
1728
  calendars: !1,
1611
1729
  months: null,
@@ -1620,20 +1738,20 @@ function mt(e, t) {
1620
1738
  complete: l
1621
1739
  };
1622
1740
  }
1623
- function ht(e, t, n) {
1624
- let r = pt(t);
1741
+ function Pt(e, t, n) {
1742
+ let r = Mt(t);
1625
1743
  if (n === "exact") return r.length === 1 ? {
1626
- ...Q,
1627
- months: O
1628
- } : Q;
1629
- let i = n === "period" ? dt : ut;
1744
+ ...Z,
1745
+ months: E
1746
+ } : Z;
1747
+ let i = n === "period" ? At : kt;
1630
1748
  if (r.length === 0) return {
1631
1749
  calendars: !0,
1632
- months: O,
1750
+ months: E,
1633
1751
  epochs: null,
1634
1752
  keywords: i
1635
1753
  };
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));
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));
1637
1755
  return {
1638
1756
  calendars: l.calendars,
1639
1757
  months: l.months,
@@ -1643,16 +1761,16 @@ function ht(e, t, n) {
1643
1761
  }
1644
1762
  //#endregion
1645
1763
  //#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);
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);
1649
1767
  if (t) return t;
1650
1768
  let n = [], r = (e) => {
1651
1769
  for (let t of e) n.push(t), r(t.children);
1652
1770
  };
1653
- return r(e), vt.set(e, n), n;
1771
+ return r(e), Lt.set(e, n), n;
1654
1772
  }
1655
- function bt(e, t) {
1773
+ function zt(e, t) {
1656
1774
  let n = 0, r = e.length;
1657
1775
  for (; n < r;) {
1658
1776
  let i = n + r >> 1;
@@ -1660,11 +1778,11 @@ function bt(e, t) {
1660
1778
  }
1661
1779
  return n - 1;
1662
1780
  }
1663
- function xt(e) {
1781
+ function Bt(e) {
1664
1782
  let t = /^\{\d+:(\d+|M)\}$/.exec(e);
1665
1783
  return t ? t[1] === "M" ? Infinity : Number(t[1]) : null;
1666
1784
  }
1667
- function St(e, t) {
1785
+ function Vt(e, t) {
1668
1786
  let n = e, r = t;
1669
1787
  for (; n;) {
1670
1788
  if (n.level !== r || !n.tokens.TAG?.value) return !1;
@@ -1672,12 +1790,12 @@ function St(e, t) {
1672
1790
  }
1673
1791
  return r === -1;
1674
1792
  }
1675
- function Ct(e, t) {
1793
+ function $(e, t) {
1676
1794
  if (t === 0) return {
1677
1795
  parentType: y(""),
1678
1796
  siblings: e.nodes
1679
1797
  };
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;
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;
1681
1799
  if (i) {
1682
1800
  if (i.level !== t || i.parent?.level !== t - 1) return null;
1683
1801
  a = i.parent;
@@ -1689,18 +1807,18 @@ function Ct(e, t) {
1689
1807
  break;
1690
1808
  }
1691
1809
  }
1692
- if (!a || !St(a, t - 1)) return null;
1693
- let o = new X(e.scheme, e.pointers).getNodeType(a);
1810
+ if (!a || !Vt(a, t - 1)) return null;
1811
+ let o = new Y(e.scheme, e.pointers).getNodeType(a);
1694
1812
  return o ? {
1695
1813
  parentType: o,
1696
1814
  siblings: a.children
1697
1815
  } : null;
1698
1816
  }
1699
- function wt(e, t) {
1700
- let n = Ct(e, t);
1817
+ function Ht(e, t) {
1818
+ let n = $(e, t);
1701
1819
  if (!n) return [];
1702
1820
  let r = Object.entries(e.scheme.substructure[n.parentType] ?? {}).filter(([t, r]) => {
1703
- let i = xt(r.cardinality);
1821
+ let i = Bt(r.cardinality);
1704
1822
  return i === null || i === Infinity || n.siblings.filter((n) => n.range.start.line !== e.position.line && n.tokens.TAG?.value === t).length < i;
1705
1823
  }).map(([t, n]) => ({
1706
1824
  label: v(t),
@@ -1713,7 +1831,7 @@ function wt(e, t) {
1713
1831
  }));
1714
1832
  return [...r, ...i];
1715
1833
  }
1716
- var Tt = {
1834
+ var Ut = {
1717
1835
  "date-v7": {
1718
1836
  grammar: "value",
1719
1837
  escaped: !1
@@ -1739,8 +1857,8 @@ var Tt = {
1739
1857
  escaped: !0
1740
1858
  }
1741
1859
  };
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);
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);
1744
1862
  return [
1745
1863
  ...i.calendars ? o : [],
1746
1864
  ...Object.keys(a(i.months)?.months ?? {}),
@@ -1751,13 +1869,13 @@ function Et(e, { grammar: t, escaped: n }, r) {
1751
1869
  kind: "enum"
1752
1870
  }));
1753
1871
  }
1754
- function Dt(e, t, n, r) {
1755
- let i = Ct(e, t);
1872
+ function Gt(e, t, n, r) {
1873
+ let i = $(e, t);
1756
1874
  if (!i) return [];
1757
1875
  let a = e.scheme.substructure[i.parentType]?.[v(n.toUpperCase())]?.type;
1758
1876
  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);
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);
1761
1879
  if (s.type === "select" || s.type === "multiselect") return [...new Set(o.getAvailableValues(a) ?? [])].filter(Boolean).map((e) => ({
1762
1880
  label: e,
1763
1881
  kind: "enum"
@@ -1771,22 +1889,23 @@ function Dt(e, t, n, r) {
1771
1889
  }
1772
1890
  return [];
1773
1891
  }
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]) : [];
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]) : [];
1779
1897
  }
1780
1898
  //#endregion
1781
1899
  //#region src/document/gedcomDocument.ts
1782
- function kt(e) {
1900
+ function qt(e) {
1783
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`;
1784
1902
  }
1785
- var At = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), jt = class {
1903
+ var Jt = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), Yt = class {
1786
1904
  nodes = [];
1787
1905
  pointers = /* @__PURE__ */ new Map();
1788
1906
  errors = [];
1789
1907
  scheme;
1908
+ validatedAs;
1790
1909
  resolution;
1791
1910
  requiresSchmaDeclaration = !1;
1792
1911
  extensions = w();
@@ -1804,7 +1923,7 @@ var At = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), jt = cl
1804
1923
  let r = t.line ?? 0, o = t.column ?? 0;
1805
1924
  o < (n.get(r) ?? Infinity) && i.add(r), !a.has(r) && (a.add(r), this.errors.push({
1806
1925
  code: p.Lexer,
1807
- message: kt(e.slice(t.offset, t.offset + t.length)),
1926
+ message: qt(e.slice(t.offset, t.offset + t.length)),
1808
1927
  range: {
1809
1928
  start: {
1810
1929
  line: r,
@@ -1830,9 +1949,9 @@ var At = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), jt = cl
1830
1949
  }
1831
1950
  createDocument(e, t = {}) {
1832
1951
  let { nodes: n, pointers: r } = this.parseGedcom(e);
1833
- 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;
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;
1836
1955
  if (i.kind === "undetermined") return this.scheme = i.scheme, this.requiresSchmaDeclaration = i.requiresSchmaDeclaration, this.errors.push({
1837
1956
  code: p.UndeterminedVersion,
1838
1957
  message: "No GEDCOM version in HEAD.GEDC.VERS, so the file cannot be checked against a specification",
@@ -1861,11 +1980,11 @@ var At = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), jt = cl
1861
1980
  }), this.applyScheme(n, i, t), this);
1862
1981
  }
1863
1982
  applyScheme(e, t, n) {
1864
- this.scheme = t.scheme, this.requiresSchmaDeclaration = t.requiresSchmaDeclaration;
1865
- 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);
1866
1985
  this.extensions = r;
1867
1986
  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)));
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)));
1869
1988
  }
1870
1989
  validateLevels(e, t, n = 0) {
1871
1990
  for (let r of t) r.level !== n && e.push({
@@ -1886,12 +2005,12 @@ var At = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), jt = cl
1886
2005
  return e ? `Extension tag (${e})` : "Extension tag";
1887
2006
  }
1888
2007
  if (!this.scheme) return;
1889
- let n = new X(this.scheme, this.pointers).getNodeType(e);
2008
+ let n = new Y(this.scheme, this.pointers).getNodeType(e);
1890
2009
  return this.scheme.label[n]?.["en-US"];
1891
2010
  }
1892
2011
  getPointerTargetTag(e) {
1893
2012
  if (!this.scheme) return;
1894
- let t = new X(this.scheme, this.pointers), n = t.getFieldType(t.getNodeType(e));
2013
+ let t = new Y(this.scheme, this.pointers), n = t.getFieldType(t.getNodeType(e));
1895
2014
  return n.type === "pointer" && n.to ? this.scheme.tag[n.to] : void 0;
1896
2015
  }
1897
2016
  isRecordDeclaration(e) {
@@ -1909,7 +2028,7 @@ var At = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), jt = cl
1909
2028
  return this.resolution && "dialect" in this.resolution ? this.resolution.dialect : void 0;
1910
2029
  }
1911
2030
  getCompletions(e, t) {
1912
- return this.scheme ? Ot({
2031
+ return this.scheme ? Kt({
1913
2032
  nodes: this.nodes,
1914
2033
  pointers: this.pointers,
1915
2034
  scheme: this.scheme,
@@ -1919,6 +2038,10 @@ var At = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), jt = cl
1919
2038
  lineText: t
1920
2039
  }) : [];
1921
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
+ }
1922
2045
  getErrors() {
1923
2046
  return this.errors;
1924
2047
  }
@@ -1927,4 +2050,4 @@ var At = /* @__PURE__ */ new Set([p.UnresolvedXref, p.UndocumentedTag]), jt = cl
1927
2050
  }
1928
2051
  };
1929
2052
  //#endregion
1930
- export { jt as GedcomDocument, p as GedcomErrorCode, r as TokenNames };
2053
+ export { Yt as GedcomDocument, p as GedcomErrorCode, r as TokenNames };