@treeviz/gedcom-parser 1.0.23 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -850,11 +850,30 @@ var Common = class _Common {
850
850
  const sour = get(head, "SOUR.value");
851
851
  return !!sour?.toLowerCase()?.startsWith("myheritage");
852
852
  }
853
+ /**
854
+ * Get the source type as a string (for prefixing tree IDs and names)
855
+ * Returns the detected source type or undefined if unknown
856
+ */
857
+ getSourceType() {
858
+ if (this.isAncestry()) return "Ancestry";
859
+ if (this.isMyHeritage()) return "MyHeritage";
860
+ if (this.isFamilySearch()) return "FamilySearch";
861
+ if (this.isGNO2GED()) return "GNO2GED";
862
+ if (this.isGenoPro()) return "GenoPro";
863
+ if (this.isAhnenblatt()) return "Ahnenblatt";
864
+ if (this.isGeni()) return "Geni";
865
+ return void 0;
866
+ }
853
867
  isFamilySearch() {
854
868
  const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
855
869
  const sourName = get(head, "SOUR.NAME.value");
856
870
  return sourName === "FamilySearch API";
857
871
  }
872
+ isGNO2GED() {
873
+ const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
874
+ const sour = get(head, "SOUR.value");
875
+ return sour === "GNO2GED";
876
+ }
858
877
  getAncestryTreeId() {
859
878
  const path = "HEAD.SOUR._TREE.RIN.value";
860
879
  return get(this, path) || get(this.getGedcom(), path);
@@ -865,11 +884,34 @@ var Common = class _Common {
865
884
  }
866
885
  getTreeId() {
867
886
  if (this?.isAncestry()) {
868
- return this.getAncestryTreeId();
887
+ const id = this.getAncestryTreeId();
888
+ if (id !== void 0) return id;
869
889
  }
870
890
  if (this?.isMyHeritage()) {
871
- return this.getMyHeritageTreeId();
891
+ const id = this.getMyHeritageTreeId();
892
+ if (id !== void 0) return id;
893
+ }
894
+ if (this?.isFamilySearch()) {
895
+ const id = this.getFamilySearchTreeId();
896
+ if (id !== void 0) return id;
872
897
  }
898
+ if (this?.isGNO2GED()) {
899
+ const id = this.getGNO2GEDTreeId();
900
+ if (id !== void 0) return id;
901
+ }
902
+ if (this?.isAhnenblatt()) {
903
+ const id = this.getAhnenblattTreeId();
904
+ if (id !== void 0) return id;
905
+ }
906
+ if (this?.isGeni()) {
907
+ const id = this.getGeniTreeId();
908
+ if (id !== void 0) return id;
909
+ }
910
+ if (this?.isGenoPro()) {
911
+ const id = this.getGenoProTreeId();
912
+ if (id !== void 0) return id;
913
+ }
914
+ return this.getUniversalTreeId();
873
915
  }
874
916
  getAncestryTreeName() {
875
917
  const path = "HEAD.SOUR._TREE.value";
@@ -882,13 +924,146 @@ var Common = class _Common {
882
924
  /Exported by MyHeritage.com from (?<tree>.+) in.+$/
883
925
  )?.groups?.tree;
884
926
  }
927
+ getFamilySearchTreeId() {
928
+ const rin = get(this, "HEAD.SOUR._TREE.RIN.value") || get(this.getGedcom(), "HEAD.SOUR._TREE.RIN.value");
929
+ if (rin) {
930
+ return rin;
931
+ }
932
+ return "familysearch";
933
+ }
934
+ getFamilySearchTreeName() {
935
+ const treeName = get(this, "HEAD.SOUR._TREE.value") || get(this.getGedcom(), "HEAD.SOUR._TREE.value");
936
+ if (treeName) {
937
+ return treeName;
938
+ }
939
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
940
+ return fileName || "FamilySearch Import";
941
+ }
942
+ getAhnenblattTreeId() {
943
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
944
+ if (fileName) {
945
+ const idMatch = fileName.match(/_(\d+)/);
946
+ if (idMatch) {
947
+ return idMatch[1];
948
+ }
949
+ }
950
+ return void 0;
951
+ }
952
+ getAhnenblattTreeName() {
953
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
954
+ return fileName?.replace(/\.ged$/i, "").replace(/_/g, " ");
955
+ }
956
+ getGeniTreeId() {
957
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
958
+ if (fileName) {
959
+ const idMatch = fileName.match(/_(\d+)/);
960
+ if (idMatch) {
961
+ return idMatch[1];
962
+ }
963
+ }
964
+ return void 0;
965
+ }
966
+ getGeniTreeName() {
967
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
968
+ return fileName?.replace(/\.ged$/i, "").replace(/_/g, " ");
969
+ }
970
+ getGenoProTreeId() {
971
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
972
+ if (fileName) {
973
+ const idMatch = fileName.match(/_(\d+)/);
974
+ if (idMatch) {
975
+ return idMatch[1];
976
+ }
977
+ }
978
+ return void 0;
979
+ }
980
+ getGenoProTreeName() {
981
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
982
+ return fileName?.replace(/\.ged$/i, "").replace(/_/g, " ");
983
+ }
984
+ getGNO2GEDTreeId() {
985
+ const rin = get(this, "HEAD._TREE.RIN.value") || get(this.getGedcom(), "HEAD._TREE.RIN.value");
986
+ if (rin) {
987
+ return rin;
988
+ }
989
+ return `gno_${this._gedcom?.refcount || "unknown"}`;
990
+ }
991
+ getGNO2GEDTreeName() {
992
+ const treeName = get(this, "HEAD._TREE.value") || get(this.getGedcom(), "HEAD._TREE.value");
993
+ if (treeName) {
994
+ return treeName;
995
+ }
996
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
997
+ return fileName || "GNO2GED Export";
998
+ }
999
+ /**
1000
+ * Universal tree ID getter for unknown/unrecognized GEDCOM sources
1001
+ * Tries to extract an ID from various common locations
1002
+ */
1003
+ getUniversalTreeId() {
1004
+ const sourceType = this.getSourceType();
1005
+ const prefix = sourceType ? sourceType.toLowerCase() : "tree";
1006
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
1007
+ if (fileName) {
1008
+ const idMatch = fileName.match(/_(\d+)/);
1009
+ if (idMatch) {
1010
+ return `${prefix}_${idMatch[1]}`;
1011
+ }
1012
+ }
1013
+ return `${prefix}_${this._gedcom?.refcount || "unknown"}`;
1014
+ }
1015
+ /**
1016
+ * Universal tree name getter for unknown/unrecognized GEDCOM sources
1017
+ * Tries to extract a name from various common locations
1018
+ */
1019
+ getUniversalTreeName() {
1020
+ const sourceType = this.getSourceType();
1021
+ const prefix = sourceType ? `${sourceType}-` : "";
1022
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
1023
+ if (fileName) {
1024
+ const cleanName = fileName.replace(/\.ged$/i, "").replace(/_/g, " ");
1025
+ return `${prefix}${cleanName}`;
1026
+ }
1027
+ const sourName = get(this, "HEAD.SOUR.NAME.value") || get(this.getGedcom(), "HEAD.SOUR.NAME.value");
1028
+ if (sourName) {
1029
+ return `${prefix}${sourName}`;
1030
+ }
1031
+ const sourValue = get(this, "HEAD.SOUR.value") || get(this.getGedcom(), "HEAD.SOUR.value");
1032
+ if (sourValue) {
1033
+ return `${prefix}${sourValue}`;
1034
+ }
1035
+ return `${prefix}Unknown Tree`;
1036
+ }
885
1037
  getTreeName() {
886
1038
  if (this?.isAncestry()) {
887
- return this.getAncestryTreeName();
1039
+ const name = this.getAncestryTreeName();
1040
+ if (name) return name;
888
1041
  }
889
1042
  if (this?.isMyHeritage()) {
890
- return this.getMyHeritageTreeName();
1043
+ const name = this.getMyHeritageTreeName();
1044
+ if (name) return name;
1045
+ }
1046
+ if (this?.isFamilySearch()) {
1047
+ const name = this.getFamilySearchTreeName();
1048
+ if (name) return name;
1049
+ }
1050
+ if (this?.isGNO2GED()) {
1051
+ const name = this.getGNO2GEDTreeName();
1052
+ if (name) return name;
1053
+ }
1054
+ if (this?.isAhnenblatt()) {
1055
+ const name = this.getAhnenblattTreeName();
1056
+ if (name) return name;
891
1057
  }
1058
+ if (this?.isGeni()) {
1059
+ const name = this.getGeniTreeName();
1060
+ if (name) return name;
1061
+ }
1062
+ if (this?.isGenoPro()) {
1063
+ const name = this.getGenoProTreeName();
1064
+ if (name) return name;
1065
+ }
1066
+ return this.getUniversalTreeName();
892
1067
  }
893
1068
  };
894
1069
  var createProxy = (target) => {
@@ -3030,66 +3205,125 @@ var getMarriageAscAndChildBirth = (person) => (itemA, keyA, itemB, keyB) => {
3030
3205
  const childB = familyB?.getChildren().orderBy(BIRTH_ASC).index(0);
3031
3206
  return getBirthAsc(childA, keyA, childB);
3032
3207
  };
3208
+ var getGedcomId = (gedcom) => {
3209
+ if (!gedcom) {
3210
+ return "unknown";
3211
+ }
3212
+ const treeId = gedcom.getTreeId?.() || "";
3213
+ const treeName = gedcom.getTreeName?.() || "";
3214
+ const sanitizedName = treeName.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
3215
+ if (treeId && sanitizedName) {
3216
+ return `${treeId}_${sanitizedName}`;
3217
+ } else if (treeId) {
3218
+ return treeId;
3219
+ } else if (sanitizedName) {
3220
+ return sanitizedName;
3221
+ }
3222
+ return `gedcom_${gedcom.refcount}`;
3223
+ };
3033
3224
  var caches = {
3034
3225
  pathCache: {},
3035
3226
  relativesOnDegreeCache: {},
3036
- relativesOnLevelCache: {}
3227
+ relativesOnLevelCache: {},
3228
+ profilePictureCache: {}
3037
3229
  };
3038
- var getInstance = getCacheManagerFactory();
3039
- var cacheDbs = {
3040
- pathCache: getInstance("ftv", "Main", "path", true),
3041
- relativesOnDegreeCache: getInstance(
3042
- "ftv",
3043
- "Main",
3044
- "path",
3045
- true
3046
- ),
3047
- relativesOnLevelCache: getInstance(
3048
- "ftv",
3049
- "Main",
3050
- "path",
3051
- true
3052
- )
3230
+ var cacheDbs;
3231
+ var getCacheDbs = () => {
3232
+ if (!cacheDbs) {
3233
+ const getInstance = getCacheManagerFactory();
3234
+ cacheDbs = {
3235
+ pathCache: getInstance(
3236
+ "ftv",
3237
+ "Main",
3238
+ "path",
3239
+ true
3240
+ ),
3241
+ relativesOnDegreeCache: getInstance("ftv", "Main", "path", true),
3242
+ relativesOnLevelCache: getInstance(
3243
+ "ftv",
3244
+ "Main",
3245
+ "path",
3246
+ true
3247
+ ),
3248
+ profilePictureCache: getInstance(
3249
+ "ftv",
3250
+ "Main",
3251
+ "images",
3252
+ false
3253
+ )
3254
+ };
3255
+ }
3256
+ return cacheDbs;
3053
3257
  };
3054
- ({
3258
+ var storeCache = {
3259
+ // NOTE: pathCache, relativesOnLevelCache, and relativesOnDegreeCache are intentionally
3260
+ // kept in memory only. These debounced functions exist to satisfy the type system
3261
+ // but are never called.
3055
3262
  pathCache: debounce((value) => {
3056
3263
  if (value) {
3057
- cacheDbs.pathCache.setItem(value);
3264
+ getCacheDbs().pathCache.setItem(value);
3058
3265
  }
3059
3266
  }, 50),
3060
3267
  relativesOnLevelCache: debounce((value) => {
3061
3268
  if (value) {
3062
- cacheDbs.relativesOnLevelCache.setItem(value);
3269
+ getCacheDbs().relativesOnLevelCache.setItem(value);
3063
3270
  }
3064
3271
  }, 50),
3065
3272
  relativesOnDegreeCache: debounce((value) => {
3066
3273
  if (value) {
3067
- cacheDbs.relativesOnDegreeCache.setItem(value);
3274
+ getCacheDbs().relativesOnDegreeCache.setItem(value);
3068
3275
  }
3069
- }, 50)
3070
- });
3071
- var relativesCache = (cacheKey) => (key, subKey, value) => {
3072
- if (!caches[cacheKey]) {
3276
+ }, 50),
3277
+ // profilePictureCache IS persisted to IndexedDB
3278
+ profilePictureCache: debounce((value) => {
3279
+ if (value) {
3280
+ getCacheDbs().profilePictureCache.setItem(value);
3281
+ }
3282
+ }, 100)
3283
+ };
3284
+ var relativesCache = (cacheKey) => (gedcom, key, subKey, value) => {
3285
+ const gedcomId = getGedcomId(gedcom);
3286
+ const fullKey = `${gedcomId}:${key}`;
3287
+ const cache = caches[cacheKey];
3288
+ if (!cache) {
3073
3289
  caches[cacheKey] = {};
3074
3290
  }
3075
- if (value && caches[cacheKey]) {
3076
- if (!caches[cacheKey][key]) {
3077
- caches[cacheKey][key] = {};
3291
+ if (value) {
3292
+ const typedCache2 = caches[cacheKey];
3293
+ if (!typedCache2[fullKey]) {
3294
+ typedCache2[fullKey] = {};
3078
3295
  }
3079
- caches[cacheKey][key][subKey] = value;
3080
- return caches[cacheKey][key][subKey];
3296
+ typedCache2[fullKey][subKey] = value;
3297
+ return typedCache2[fullKey][subKey];
3081
3298
  }
3082
- return caches[cacheKey]?.[key]?.[subKey];
3299
+ const typedCache = caches[cacheKey];
3300
+ return typedCache?.[fullKey]?.[subKey];
3083
3301
  };
3084
- var pathCache = (key, value) => {
3302
+ var pathCache = (gedcom, key, value) => {
3303
+ const gedcomId = getGedcomId(gedcom);
3304
+ const fullKey = `${gedcomId}:${key}`;
3085
3305
  if (!caches.pathCache) {
3086
3306
  caches.pathCache = {};
3087
3307
  }
3088
3308
  if (value && caches.pathCache) {
3089
- caches.pathCache[key] = value;
3090
- return caches.pathCache[key];
3309
+ caches.pathCache[fullKey] = value;
3310
+ return caches.pathCache[fullKey];
3091
3311
  }
3092
- return caches.pathCache?.[key];
3312
+ return caches.pathCache?.[fullKey];
3313
+ };
3314
+ var profilePictureCache = (gedcom, key, value) => {
3315
+ const gedcomId = getGedcomId(gedcom);
3316
+ const fullKey = `${gedcomId}:${key}`;
3317
+ if (!caches.profilePictureCache) {
3318
+ caches.profilePictureCache = {};
3319
+ }
3320
+ if (value && caches.profilePictureCache) {
3321
+ caches.profilePictureCache[fullKey] = value;
3322
+ storeCache.profilePictureCache(caches.profilePictureCache);
3323
+ return caches.profilePictureCache[fullKey];
3324
+ }
3325
+ const cached = caches.profilePictureCache?.[fullKey];
3326
+ return cached;
3093
3327
  };
3094
3328
 
3095
3329
  // src/utils/get-places.ts
@@ -4361,7 +4595,7 @@ var Indi = class extends Common {
4361
4595
  }
4362
4596
  async ancestryMedia(namespace) {
4363
4597
  const list = {};
4364
- const objeList = this.get("OBJE")?.toList();
4598
+ const objeList = this.get("OBJE")?.toList().copy();
4365
4599
  const www = this._gedcom?.HEAD?.SOUR?.CORP?.WWW?.value;
4366
4600
  const tree = this.getAncestryTreeId();
4367
4601
  if (objeList) {
@@ -4411,7 +4645,7 @@ var Indi = class extends Common {
4411
4645
  title,
4412
4646
  url,
4413
4647
  contentType: type,
4414
- downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
4648
+ downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
4415
4649
  };
4416
4650
  }
4417
4651
  })
@@ -4435,11 +4669,12 @@ var Indi = class extends Common {
4435
4669
  if (!tree) {
4436
4670
  return;
4437
4671
  }
4438
- const objeList = this.get("OBJE")?.toList();
4439
- const birthObj = this.get("BIRT.OBJE")?.toList();
4440
- const deathObj = this.get("DEAT.OBJE")?.toList();
4672
+ const objeList = this.get("OBJE")?.toList().copy();
4673
+ const birthObj = this.get("BIRT.OBJE")?.toList().copy();
4674
+ const deathObj = this.get("DEAT.OBJE")?.toList().copy();
4675
+ objeList?.merge(birthObj).merge(deathObj);
4441
4676
  (this.get("FAMS")?.toValueList().values() ?? []).concat(this.get("FAMC")?.toValueList().values() ?? []).forEach((fam) => {
4442
- objeList?.merge(birthObj).merge(deathObj).merge(fam?.get("MARR.OBJE"));
4677
+ objeList?.merge(fam?.get("MARR.OBJE"));
4443
4678
  });
4444
4679
  objeList?.forEach((o, index) => {
4445
4680
  if (!o) {
@@ -4465,7 +4700,7 @@ var Indi = class extends Common {
4465
4700
  title,
4466
4701
  url,
4467
4702
  contentType: type,
4468
- downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
4703
+ downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
4469
4704
  };
4470
4705
  }
4471
4706
  });
@@ -4557,6 +4792,85 @@ var Indi = class extends Common {
4557
4792
  };
4558
4793
  });
4559
4794
  }
4795
+ geniMedia() {
4796
+ const list = {};
4797
+ const objeList = this.get("OBJE")?.toList().copy();
4798
+ const sourList = this.get("SOUR")?.toList().copy();
4799
+ sourList?.forEach((sour) => {
4800
+ const sourObje = sour?.get("OBJE")?.toList();
4801
+ objeList?.merge(sourObje);
4802
+ });
4803
+ const rfn = this.get("RFN")?.toValue();
4804
+ const geniId = rfn?.replace(/^geni:/, "") || "unknown";
4805
+ objeList?.forEach((obje, index) => {
4806
+ if (!obje) {
4807
+ return;
4808
+ }
4809
+ const key = `@O${index}@`;
4810
+ const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
4811
+ const url = obje?.get("FILE")?.toValue();
4812
+ const title = obje?.get("TITL")?.toValue() ?? "";
4813
+ const type = obje?.get("FORM")?.toValue() ?? "raw";
4814
+ if (url) {
4815
+ const urlMatch = url.match(/\/([^/]+)\?hash=/);
4816
+ const imgId = urlMatch?.[1] || `img-${index}-${Date.now().toString(36)}`;
4817
+ const id = `geni-${geniId}-${imgId}`;
4818
+ list[id] = {
4819
+ isPrimary,
4820
+ key,
4821
+ id,
4822
+ tree: geniId,
4823
+ imgId,
4824
+ person: this.id,
4825
+ title,
4826
+ url,
4827
+ contentType: type,
4828
+ downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
4829
+ };
4830
+ }
4831
+ });
4832
+ return list;
4833
+ }
4834
+ universalMedia() {
4835
+ const list = {};
4836
+ if (!this.id) {
4837
+ return list;
4838
+ }
4839
+ const objeList = this.get("OBJE")?.toList().copy();
4840
+ if (!objeList || objeList.length === 0) {
4841
+ return list;
4842
+ }
4843
+ const rfn = this.get("RFN")?.toValue();
4844
+ const treeId = this.getUniversalTreeId() || rfn || "universal";
4845
+ objeList.forEach((obje, index) => {
4846
+ if (!obje) {
4847
+ return;
4848
+ }
4849
+ const key = `@O${index}@`;
4850
+ obje.standardizeMedia();
4851
+ const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
4852
+ const url = obje?.get("FILE")?.toValue();
4853
+ const title = obje?.get("TITL")?.toValue() ?? "";
4854
+ const type = obje?.get("FORM")?.toValue() ?? "raw";
4855
+ if (url) {
4856
+ const imgId = `media-${index}-${url.split("/").pop()?.split("?")[0]?.substring(0, 20) || Date.now().toString(36)}`;
4857
+ const id = `${treeId}-${this.id}-${imgId}`;
4858
+ list[id] = {
4859
+ isPrimary,
4860
+ key,
4861
+ id,
4862
+ tree: treeId,
4863
+ imgId,
4864
+ person: this.id,
4865
+ title,
4866
+ url,
4867
+ contentType: type,
4868
+ downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
4869
+ };
4870
+ }
4871
+ });
4872
+ return list;
4873
+ }
4560
4874
  async multimedia(namespace) {
4561
4875
  if (this?.isAncestry()) {
4562
4876
  return await this.ancestryMedia(namespace);
@@ -4564,11 +4878,30 @@ var Indi = class extends Common {
4564
4878
  if (this?.isMyHeritage()) {
4565
4879
  return this.myheritageMedia();
4566
4880
  }
4567
- return void 0;
4881
+ if (this?.isGeni()) {
4882
+ return this.geniMedia();
4883
+ }
4884
+ return this.universalMedia();
4568
4885
  }
4569
4886
  async getProfilePicture(namespace, onlyPrimary = true) {
4887
+ if (!this.id) {
4888
+ return void 0;
4889
+ }
4890
+ const cacheKey = this.id;
4891
+ const cached = profilePictureCache(
4892
+ this._gedcom,
4893
+ cacheKey
4894
+ );
4895
+ if (cached !== void 0) {
4896
+ return cached;
4897
+ }
4570
4898
  const mediaList = await this.multimedia(namespace);
4571
4899
  if (!mediaList) {
4900
+ profilePictureCache(
4901
+ this._gedcom,
4902
+ cacheKey,
4903
+ void 0
4904
+ );
4572
4905
  return void 0;
4573
4906
  }
4574
4907
  const mediaArray = Object.values(mediaList);
@@ -4576,27 +4909,41 @@ var Indi = class extends Common {
4576
4909
  (media) => media.isPrimary && isImageFormat(media.contentType || getFileExtension(media.url))
4577
4910
  );
4578
4911
  if (primaryMedia) {
4579
- return {
4912
+ const result = {
4580
4913
  file: primaryMedia.url,
4581
4914
  form: primaryMedia.contentType,
4582
4915
  title: primaryMedia.title,
4583
4916
  isPrimary: true
4584
4917
  };
4585
- }
4586
- if (!onlyPrimary) {
4918
+ profilePictureCache(this._gedcom, cacheKey, result);
4919
+ return result;
4920
+ }
4921
+ if (onlyPrimary) {
4922
+ profilePictureCache(
4923
+ this._gedcom,
4924
+ cacheKey,
4925
+ void 0
4926
+ );
4587
4927
  return void 0;
4588
4928
  }
4589
4929
  const secondaryMedia = mediaArray.find(
4590
4930
  (media) => isImageFormat(media.contentType || getFileExtension(media.url))
4591
4931
  );
4592
4932
  if (secondaryMedia) {
4593
- return {
4933
+ const result = {
4594
4934
  file: secondaryMedia.url,
4595
4935
  form: secondaryMedia.contentType,
4596
4936
  title: secondaryMedia.title,
4597
4937
  isPrimary: false
4598
4938
  };
4939
+ profilePictureCache(this._gedcom, cacheKey, result);
4940
+ return result;
4599
4941
  }
4942
+ profilePictureCache(
4943
+ this._gedcom,
4944
+ cacheKey,
4945
+ void 0
4946
+ );
4600
4947
  return void 0;
4601
4948
  }
4602
4949
  link(poolId) {
@@ -4964,7 +5311,7 @@ var Indi = class extends Common {
4964
5311
  return;
4965
5312
  }
4966
5313
  const cacheKey = `${this.id}|${usedIndi.id}`;
4967
- const cache = pathCache(cacheKey);
5314
+ const cache = pathCache(this._gedcom, cacheKey);
4968
5315
  if (cache) {
4969
5316
  return cache;
4970
5317
  }
@@ -5009,7 +5356,7 @@ var Indi = class extends Common {
5009
5356
  if (breakOnNext) {
5010
5357
  return void 0;
5011
5358
  }
5012
- pathCache(cacheKey, path2);
5359
+ pathCache(this._gedcom, cacheKey, path2);
5013
5360
  return path2;
5014
5361
  }
5015
5362
  visited.append(indi);
@@ -5179,7 +5526,7 @@ var Indi = class extends Common {
5179
5526
  }
5180
5527
  getRelativesOnDegree(degree = 0) {
5181
5528
  this.id = this.id || `@I${Math.random()}@`;
5182
- const cache = relativesOnDegreeCache(this.id, degree);
5529
+ const cache = relativesOnDegreeCache(this._gedcom, this.id, degree);
5183
5530
  if (cache) {
5184
5531
  return cache;
5185
5532
  }
@@ -5187,6 +5534,7 @@ var Indi = class extends Common {
5187
5534
  const excludes = persons;
5188
5535
  if (!Math.abs(degree)) {
5189
5536
  return relativesOnDegreeCache(
5537
+ this._gedcom,
5190
5538
  this.id,
5191
5539
  degree,
5192
5540
  persons.except(this)
@@ -5197,11 +5545,11 @@ var Indi = class extends Common {
5197
5545
  excludes.merge(persons);
5198
5546
  persons = this.getRelativesOnLevel(validDegree).getRelativesOnDegree(-validDegree).copy().exclude(excludes);
5199
5547
  }
5200
- return relativesOnDegreeCache(this.id, degree, persons);
5548
+ return relativesOnDegreeCache(this._gedcom, this.id, degree, persons);
5201
5549
  }
5202
5550
  getRelativesOnLevel(level = 0, filter) {
5203
5551
  this.id = this.id || `@I${Math.random()}@`;
5204
- const cache = relativesOnLevelCache(this.id, level);
5552
+ const cache = relativesOnLevelCache(this._gedcom, this.id, level);
5205
5553
  if (cache) {
5206
5554
  return cache;
5207
5555
  }
@@ -5212,7 +5560,7 @@ var Indi = class extends Common {
5212
5560
  };
5213
5561
  let families = this.get(config.key)?.toValueList();
5214
5562
  if (!families) {
5215
- return relativesOnLevelCache(this.id, level, persons);
5563
+ return relativesOnLevelCache(this._gedcom, this.id, level, persons);
5216
5564
  }
5217
5565
  if (filter) {
5218
5566
  families = families.filter(filter);
@@ -5223,7 +5571,12 @@ var Indi = class extends Common {
5223
5571
  persons = this.toFamilies(families).getParents();
5224
5572
  }
5225
5573
  if (level >= -1 && level <= 1) {
5226
- return relativesOnLevelCache(this.id, level, persons.except(this));
5574
+ return relativesOnLevelCache(
5575
+ this._gedcom,
5576
+ this.id,
5577
+ level,
5578
+ persons.except(this)
5579
+ );
5227
5580
  }
5228
5581
  for (let i = 1; i < Math.abs(level); i++) {
5229
5582
  if (config.isAscendant) {
@@ -5232,7 +5585,12 @@ var Indi = class extends Common {
5232
5585
  persons = persons.getParents();
5233
5586
  }
5234
5587
  }
5235
- return relativesOnLevelCache(this.id, level, persons.except(this));
5588
+ return relativesOnLevelCache(
5589
+ this._gedcom,
5590
+ this.id,
5591
+ level,
5592
+ persons.except(this)
5593
+ );
5236
5594
  }
5237
5595
  getAscendants(level = 0, filter) {
5238
5596
  if (!level) {
@@ -5271,7 +5629,12 @@ var Indi = class extends Common {
5271
5629
  }
5272
5630
  currentGen++;
5273
5631
  generations[currentGen] = descentants;
5274
- relativesOnLevelCache(this.id, -currentGen, descentants);
5632
+ relativesOnLevelCache(
5633
+ this._gedcom,
5634
+ this.id,
5635
+ -currentGen,
5636
+ descentants
5637
+ );
5275
5638
  descentants && relatives.merge(descentants);
5276
5639
  }
5277
5640
  return { relatives, generations };
@@ -5304,7 +5667,7 @@ var Indi = class extends Common {
5304
5667
  }
5305
5668
  currentGen++;
5306
5669
  generations[currentGen] = parents;
5307
- relativesOnLevelCache(this.id, currentGen, parents);
5670
+ relativesOnLevelCache(this._gedcom, this.id, currentGen, parents);
5308
5671
  parents && relatives.merge(parents);
5309
5672
  }
5310
5673
  return { relatives, generations };
@@ -5888,7 +6251,7 @@ var createIndi = (gedcom, id, main, parent) => {
5888
6251
 
5889
6252
  // package.json
5890
6253
  var package_default = {
5891
- version: "1.0.23"};
6254
+ version: "2.0.1"};
5892
6255
 
5893
6256
  // src/utils/get-product-details.ts
5894
6257
  var getVersion = () => package_default.version;