@treeviz/gedcom-parser 1.0.20 → 1.0.21

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.
@@ -1,2 +1,2 @@
1
- export { ao as Common, az as CommonDate, aQ as CommonName, aS as CommonNote, an as CustomTags, am as Existed, aC as Fam, aj as FamType, aE as Families, aL as FamilySearchMatch, aM as FamilySearchSource, aF as GedCom, ak as GedComType, a3 as GenealogyMember, aa as GenerationIndiType, a9 as GenerationSpouseType, aK as Indi, a5 as IndiGenealogy, ab as IndiGenealogyGenerations, ac as IndiGenealogyResult, a6 as IndiMarker, a4 as IndiTree, a1 as IndiType, aO as Individuals, aP as List, a8 as MemberMain, a7 as MemberSide, ad as NonNullIndiGenealogyResult, aU as Obje, al as ObjeType, aW as Objects, af as Path, ae as PathItem, Z as ProxyOriginal, ai as Queue, ah as QueueItem, ag as ReducedPath, aX as Repo, $ as RepoType, aZ as Repositories, a_ as Sour, _ as SourType, b0 as Sources, b1 as Subm, a0 as SubmType, b3 as Submitters, a2 as TreeMember, aq as createCommon, aA as createCommonDate, aR as createCommonName, aT as createCommonNote, aD as createFam, aG as createGedCom, aN as createIndi, aV as createObje, ap as createProxy, aY as createRepo, a$ as createSour, b2 as createSubm, av as getListTag, aw as getValidKey, at as getValidKeys, au as getValidTag, ay as idGetter, aB as isCommonDate, aH as isGedcomString, ax as isId, ar as isOnlyMainProp, as as isValidKey, aJ as mergeGedcoms, aI as validateGedcomContent } from '../index-DOapi7nN.js';
1
+ export { ao as Common, az as CommonDate, aR as CommonName, aT as CommonNote, an as CustomTags, am as Existed, aC as Fam, aj as FamType, aE as Families, aL as FamilySearchMatch, aM as FamilySearchSource, aF as GedCom, ak as GedComType, a3 as GenealogyMember, aa as GenerationIndiType, a9 as GenerationSpouseType, aK as Indi, a5 as IndiGenealogy, ab as IndiGenealogyGenerations, ac as IndiGenealogyResult, a6 as IndiMarker, a4 as IndiTree, a1 as IndiType, aP as Individuals, aQ as List, a8 as MemberMain, a7 as MemberSide, ad as NonNullIndiGenealogyResult, aV as Obje, al as ObjeType, aX as Objects, af as Path, ae as PathItem, aN as ProfilePicture, Z as ProxyOriginal, ai as Queue, ah as QueueItem, ag as ReducedPath, aY as Repo, $ as RepoType, a_ as Repositories, a$ as Sour, _ as SourType, b1 as Sources, b2 as Subm, a0 as SubmType, b4 as Submitters, a2 as TreeMember, aq as createCommon, aA as createCommonDate, aS as createCommonName, aU as createCommonNote, aD as createFam, aG as createGedCom, aO as createIndi, aW as createObje, ap as createProxy, aZ as createRepo, b0 as createSour, b3 as createSubm, av as getListTag, aw as getValidKey, at as getValidKeys, au as getValidTag, ay as idGetter, aB as isCommonDate, aH as isGedcomString, ax as isId, ar as isOnlyMainProp, as as isValidKey, aJ as mergeGedcoms, aI as validateGedcomContent } from '../index-BPEVN_DY.js';
2
2
  import 'date-fns';
@@ -3158,6 +3158,27 @@ var getPlaces = (common, type = ["ALL" /* All */], maxLevel = 1, level = 0, main
3158
3158
  };
3159
3159
  var implemented = (type, ...args) => {
3160
3160
  };
3161
+
3162
+ // src/utils/media-utils.ts
3163
+ var getFileExtension = (filename) => {
3164
+ const match = filename.match(/\.([^.]+)$/);
3165
+ return match ? match[1] : "";
3166
+ };
3167
+ var isImageFormat = (format2) => {
3168
+ if (!format2) return false;
3169
+ const imageFormats = [
3170
+ "jpg",
3171
+ "jpeg",
3172
+ "png",
3173
+ "gif",
3174
+ "bmp",
3175
+ "webp",
3176
+ "svg",
3177
+ "tiff",
3178
+ "tif"
3179
+ ];
3180
+ return imageFormats.includes(format2.toLowerCase());
3181
+ };
3161
3182
  var uniqueItemsCache = /* @__PURE__ */ new WeakMap();
3162
3183
  var setNestedGroup = (obj, key, value, uniqueCounting = true) => {
3163
3184
  const parts = Array.isArray(key) ? key : key.split(/,\s*/);
@@ -4340,54 +4361,62 @@ var Indi = class extends Common {
4340
4361
  }
4341
4362
  async ancestryMedia(namespace) {
4342
4363
  const list = {};
4343
- const objIds = this.get("OBJE")?.toValueList().keys() ?? [];
4364
+ const objeList = this.get("OBJE")?.toList();
4344
4365
  const www = this._gedcom?.HEAD?.SOUR?.CORP?.WWW?.value;
4345
4366
  const tree = this.getAncestryTreeId();
4346
- await Promise.all(
4347
- objIds.map(async (objId) => {
4348
- const key = objId;
4349
- const obje = this._gedcom?.obje(key)?.standardizeMedia(namespace, true, (ns, iId) => {
4350
- return ns && iId ? `https://mediasvc.ancestry.com/v2/image/namespaces/${ns}/media/${iId}?client=trees-mediaservice&imageQuality=hq` : void 0;
4351
- });
4352
- const media = obje?.RIN?.value;
4353
- const clone = obje?.get("_CLON._OID")?.toValue();
4354
- const mser = obje?.get("_MSER._LKID")?.toValue();
4355
- let url = obje?.get("FILE")?.toValue();
4356
- const title = obje?.get("TITL")?.toValue() ?? "";
4357
- const type = obje?.get("FORM")?.toValue() ?? "raw";
4358
- const imgId = clone || mser;
4359
- if (!www || !tree || !this.id) {
4360
- return;
4361
- }
4362
- if (!namespace && !url) {
4363
- try {
4364
- const mediaDetailsResponse = await fetch(
4365
- `https://www.ancestry.com/api/media/viewer/v2/trees/${tree}/media?id=${media}`
4366
- );
4367
- const mediaDetails = await mediaDetailsResponse.json();
4368
- if (mediaDetails.url) {
4369
- url = `${mediaDetails.url}&imageQuality=hq`;
4367
+ if (objeList) {
4368
+ await Promise.all(
4369
+ objeList.map(async (objeRef) => {
4370
+ const key = objeRef?.id;
4371
+ const obje = objeRef?.standardizeMedia(
4372
+ namespace,
4373
+ true,
4374
+ (ns, iId) => {
4375
+ return ns && iId ? `https://mediasvc.ancestry.com/v2/image/namespaces/${ns}/media/${iId}?client=trees-mediaservice&imageQuality=hq` : void 0;
4370
4376
  }
4371
- } catch (_e) {
4377
+ );
4378
+ const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
4379
+ const media = obje?.RIN?.value;
4380
+ const clone = obje?.get("_CLON._OID")?.toValue();
4381
+ const mser = obje?.get("_MSER._LKID")?.toValue();
4382
+ let url = obje?.get("FILE")?.toValue();
4383
+ const title = obje?.get("TITL")?.toValue() ?? "";
4384
+ const type = obje?.get("FORM")?.toValue() ?? "raw";
4385
+ const imgId = clone || mser;
4386
+ if (!www || !tree || !this.id) {
4387
+ return;
4372
4388
  }
4373
- url = url || `https://${www}/mediaui-viewer/tree/${tree}/media/${media}`;
4374
- }
4375
- if (url && imgId) {
4376
- const id = `${tree}-${this.id}-${imgId}`;
4377
- list[id] = {
4378
- key,
4379
- id,
4380
- tree,
4381
- imgId,
4382
- person: this.id,
4383
- title,
4384
- url,
4385
- contentType: type,
4386
- downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
4387
- };
4388
- }
4389
- })
4390
- );
4389
+ if (!namespace && !url) {
4390
+ try {
4391
+ const mediaDetailsResponse = await fetch(
4392
+ `https://www.ancestry.com/api/media/viewer/v2/trees/${tree}/media?id=${media}`
4393
+ );
4394
+ const mediaDetails = await mediaDetailsResponse.json();
4395
+ if (mediaDetails.url) {
4396
+ url = `${mediaDetails.url}&imageQuality=hq`;
4397
+ }
4398
+ } catch (_e) {
4399
+ }
4400
+ url = url || `https://${www}/mediaui-viewer/tree/${tree}/media/${media}`;
4401
+ }
4402
+ if (url && imgId) {
4403
+ const id = `${tree}-${this.id}-${imgId}`;
4404
+ list[id] = {
4405
+ key,
4406
+ isPrimary,
4407
+ id,
4408
+ tree,
4409
+ imgId,
4410
+ person: this.id,
4411
+ title,
4412
+ url,
4413
+ contentType: type,
4414
+ downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
4415
+ };
4416
+ }
4417
+ })
4418
+ );
4419
+ }
4391
4420
  return list;
4392
4421
  }
4393
4422
  myheritageLink(poolId = 0) {
@@ -4425,6 +4454,7 @@ var Indi = class extends Common {
4425
4454
  if (url && imgId) {
4426
4455
  const id = `${tree}-${this.id}-${imgId}`;
4427
4456
  list[id] = {
4457
+ isPrimary: false,
4428
4458
  key,
4429
4459
  id,
4430
4460
  tree,
@@ -4534,6 +4564,36 @@ var Indi = class extends Common {
4534
4564
  }
4535
4565
  return void 0;
4536
4566
  }
4567
+ async getProfilePicture(namespace) {
4568
+ const mediaList = await this.multimedia(namespace);
4569
+ if (!mediaList) {
4570
+ return void 0;
4571
+ }
4572
+ const mediaArray = Object.values(mediaList);
4573
+ const primaryMedia = mediaArray.find(
4574
+ (media) => media.isPrimary && isImageFormat(media.contentType || getFileExtension(media.url))
4575
+ );
4576
+ if (primaryMedia) {
4577
+ return {
4578
+ file: primaryMedia.url,
4579
+ form: primaryMedia.contentType,
4580
+ title: primaryMedia.title,
4581
+ isPrimary: true
4582
+ };
4583
+ }
4584
+ const secondaryMedia = mediaArray.find(
4585
+ (media) => isImageFormat(media.contentType || getFileExtension(media.url))
4586
+ );
4587
+ if (secondaryMedia) {
4588
+ return {
4589
+ file: secondaryMedia.url,
4590
+ form: secondaryMedia.contentType,
4591
+ title: secondaryMedia.title,
4592
+ isPrimary: false
4593
+ };
4594
+ }
4595
+ return void 0;
4596
+ }
4537
4597
  link(poolId) {
4538
4598
  if (this?.isAncestry()) {
4539
4599
  return this.ancestryLink();
@@ -5823,7 +5883,7 @@ var createIndi = (gedcom, id, main, parent) => {
5823
5883
 
5824
5884
  // package.json
5825
5885
  var package_default = {
5826
- version: "1.0.20"};
5886
+ version: "1.0.21"};
5827
5887
 
5828
5888
  // src/utils/get-product-details.ts
5829
5889
  var getVersion = () => package_default.version;
package/dist/cli/index.js CHANGED
@@ -1287,6 +1287,27 @@ var getPlaces = (common, type = ["ALL" /* All */], maxLevel = 1, level = 0, main
1287
1287
  var implemented = (type, ...args) => {
1288
1288
  };
1289
1289
 
1290
+ // src/utils/media-utils.ts
1291
+ var getFileExtension = (filename) => {
1292
+ const match = filename.match(/\.([^.]+)$/);
1293
+ return match ? match[1] : "";
1294
+ };
1295
+ var isImageFormat = (format2) => {
1296
+ if (!format2) return false;
1297
+ const imageFormats = [
1298
+ "jpg",
1299
+ "jpeg",
1300
+ "png",
1301
+ "gif",
1302
+ "bmp",
1303
+ "webp",
1304
+ "svg",
1305
+ "tiff",
1306
+ "tif"
1307
+ ];
1308
+ return imageFormats.includes(format2.toLowerCase());
1309
+ };
1310
+
1290
1311
  // src/classes/name.ts
1291
1312
  var CommonName = class extends Common {
1292
1313
  constructor(gedcom, id, main, parent) {
@@ -1906,54 +1927,62 @@ var Indi = class extends Common {
1906
1927
  }
1907
1928
  async ancestryMedia(namespace) {
1908
1929
  const list = {};
1909
- const objIds = this.get("OBJE")?.toValueList().keys() ?? [];
1930
+ const objeList = this.get("OBJE")?.toList();
1910
1931
  const www = this._gedcom?.HEAD?.SOUR?.CORP?.WWW?.value;
1911
1932
  const tree = this.getAncestryTreeId();
1912
- await Promise.all(
1913
- objIds.map(async (objId) => {
1914
- const key = objId;
1915
- const obje = this._gedcom?.obje(key)?.standardizeMedia(namespace, true, (ns, iId) => {
1916
- return ns && iId ? `https://mediasvc.ancestry.com/v2/image/namespaces/${ns}/media/${iId}?client=trees-mediaservice&imageQuality=hq` : void 0;
1917
- });
1918
- const media = obje?.RIN?.value;
1919
- const clone = obje?.get("_CLON._OID")?.toValue();
1920
- const mser = obje?.get("_MSER._LKID")?.toValue();
1921
- let url = obje?.get("FILE")?.toValue();
1922
- const title = obje?.get("TITL")?.toValue() ?? "";
1923
- const type = obje?.get("FORM")?.toValue() ?? "raw";
1924
- const imgId = clone || mser;
1925
- if (!www || !tree || !this.id) {
1926
- return;
1927
- }
1928
- if (!namespace && !url) {
1929
- try {
1930
- const mediaDetailsResponse = await fetch(
1931
- `https://www.ancestry.com/api/media/viewer/v2/trees/${tree}/media?id=${media}`
1932
- );
1933
- const mediaDetails = await mediaDetailsResponse.json();
1934
- if (mediaDetails.url) {
1935
- url = `${mediaDetails.url}&imageQuality=hq`;
1933
+ if (objeList) {
1934
+ await Promise.all(
1935
+ objeList.map(async (objeRef) => {
1936
+ const key = objeRef?.id;
1937
+ const obje = objeRef?.standardizeMedia(
1938
+ namespace,
1939
+ true,
1940
+ (ns, iId) => {
1941
+ return ns && iId ? `https://mediasvc.ancestry.com/v2/image/namespaces/${ns}/media/${iId}?client=trees-mediaservice&imageQuality=hq` : void 0;
1936
1942
  }
1937
- } catch (_e) {
1943
+ );
1944
+ const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
1945
+ const media = obje?.RIN?.value;
1946
+ const clone = obje?.get("_CLON._OID")?.toValue();
1947
+ const mser = obje?.get("_MSER._LKID")?.toValue();
1948
+ let url = obje?.get("FILE")?.toValue();
1949
+ const title = obje?.get("TITL")?.toValue() ?? "";
1950
+ const type = obje?.get("FORM")?.toValue() ?? "raw";
1951
+ const imgId = clone || mser;
1952
+ if (!www || !tree || !this.id) {
1953
+ return;
1938
1954
  }
1939
- url = url || `https://${www}/mediaui-viewer/tree/${tree}/media/${media}`;
1940
- }
1941
- if (url && imgId) {
1942
- const id = `${tree}-${this.id}-${imgId}`;
1943
- list[id] = {
1944
- key,
1945
- id,
1946
- tree,
1947
- imgId,
1948
- person: this.id,
1949
- title,
1950
- url,
1951
- contentType: type,
1952
- downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
1953
- };
1954
- }
1955
- })
1956
- );
1955
+ if (!namespace && !url) {
1956
+ try {
1957
+ const mediaDetailsResponse = await fetch(
1958
+ `https://www.ancestry.com/api/media/viewer/v2/trees/${tree}/media?id=${media}`
1959
+ );
1960
+ const mediaDetails = await mediaDetailsResponse.json();
1961
+ if (mediaDetails.url) {
1962
+ url = `${mediaDetails.url}&imageQuality=hq`;
1963
+ }
1964
+ } catch (_e) {
1965
+ }
1966
+ url = url || `https://${www}/mediaui-viewer/tree/${tree}/media/${media}`;
1967
+ }
1968
+ if (url && imgId) {
1969
+ const id = `${tree}-${this.id}-${imgId}`;
1970
+ list[id] = {
1971
+ key,
1972
+ isPrimary,
1973
+ id,
1974
+ tree,
1975
+ imgId,
1976
+ person: this.id,
1977
+ title,
1978
+ url,
1979
+ contentType: type,
1980
+ downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
1981
+ };
1982
+ }
1983
+ })
1984
+ );
1985
+ }
1957
1986
  return list;
1958
1987
  }
1959
1988
  myheritageLink(poolId = 0) {
@@ -1991,6 +2020,7 @@ var Indi = class extends Common {
1991
2020
  if (url && imgId) {
1992
2021
  const id = `${tree}-${this.id}-${imgId}`;
1993
2022
  list[id] = {
2023
+ isPrimary: false,
1994
2024
  key,
1995
2025
  id,
1996
2026
  tree,
@@ -2100,6 +2130,36 @@ var Indi = class extends Common {
2100
2130
  }
2101
2131
  return void 0;
2102
2132
  }
2133
+ async getProfilePicture(namespace) {
2134
+ const mediaList = await this.multimedia(namespace);
2135
+ if (!mediaList) {
2136
+ return void 0;
2137
+ }
2138
+ const mediaArray = Object.values(mediaList);
2139
+ const primaryMedia = mediaArray.find(
2140
+ (media) => media.isPrimary && isImageFormat(media.contentType || getFileExtension(media.url))
2141
+ );
2142
+ if (primaryMedia) {
2143
+ return {
2144
+ file: primaryMedia.url,
2145
+ form: primaryMedia.contentType,
2146
+ title: primaryMedia.title,
2147
+ isPrimary: true
2148
+ };
2149
+ }
2150
+ const secondaryMedia = mediaArray.find(
2151
+ (media) => isImageFormat(media.contentType || getFileExtension(media.url))
2152
+ );
2153
+ if (secondaryMedia) {
2154
+ return {
2155
+ file: secondaryMedia.url,
2156
+ form: secondaryMedia.contentType,
2157
+ title: secondaryMedia.title,
2158
+ isPrimary: false
2159
+ };
2160
+ }
2161
+ return void 0;
2162
+ }
2103
2163
  link(poolId) {
2104
2164
  if (this?.isAncestry()) {
2105
2165
  return this.ancestryLink();
@@ -5816,7 +5876,7 @@ var Families = class _Families extends List {
5816
5876
 
5817
5877
  // package.json
5818
5878
  var package_default = {
5819
- version: "1.0.20"};
5879
+ version: "1.0.21"};
5820
5880
 
5821
5881
  // src/utils/get-product-details.ts
5822
5882
  var isDevelopment = () => {
@@ -1,4 +1,4 @@
1
- import { x as Filter, y as RequiredFilter, W as RelationType, X as PartnerType, A as Order, K as NameOrder, B as OrderIterator, a1 as IndiType, n as IndiKey } from '../index-DOapi7nN.js';
1
+ import { x as Filter, y as RequiredFilter, W as RelationType, X as PartnerType, A as Order, K as NameOrder, B as OrderIterator, a1 as IndiType, n as IndiKey } from '../index-BPEVN_DY.js';
2
2
  import 'date-fns';
3
3
 
4
4
  /**
@@ -1291,6 +1291,27 @@ var getPlaces = (common, type = ["ALL" /* All */], maxLevel = 1, level = 0, main
1291
1291
  };
1292
1292
  var implemented = (type, ...args) => {
1293
1293
  };
1294
+
1295
+ // src/utils/media-utils.ts
1296
+ var getFileExtension = (filename) => {
1297
+ const match = filename.match(/\.([^.]+)$/);
1298
+ return match ? match[1] : "";
1299
+ };
1300
+ var isImageFormat = (format2) => {
1301
+ if (!format2) return false;
1302
+ const imageFormats = [
1303
+ "jpg",
1304
+ "jpeg",
1305
+ "png",
1306
+ "gif",
1307
+ "bmp",
1308
+ "webp",
1309
+ "svg",
1310
+ "tiff",
1311
+ "tif"
1312
+ ];
1313
+ return imageFormats.includes(format2.toLowerCase());
1314
+ };
1294
1315
  var uniqueItemsCache = /* @__PURE__ */ new WeakMap();
1295
1316
  var setNestedGroup = (obj, key, value, uniqueCounting = true) => {
1296
1317
  const parts = Array.isArray(key) ? key : key.split(/,\s*/);
@@ -2501,54 +2522,62 @@ var Indi = class extends Common {
2501
2522
  }
2502
2523
  async ancestryMedia(namespace) {
2503
2524
  const list = {};
2504
- const objIds = this.get("OBJE")?.toValueList().keys() ?? [];
2525
+ const objeList = this.get("OBJE")?.toList();
2505
2526
  const www = this._gedcom?.HEAD?.SOUR?.CORP?.WWW?.value;
2506
2527
  const tree = this.getAncestryTreeId();
2507
- await Promise.all(
2508
- objIds.map(async (objId) => {
2509
- const key = objId;
2510
- const obje = this._gedcom?.obje(key)?.standardizeMedia(namespace, true, (ns, iId) => {
2511
- return ns && iId ? `https://mediasvc.ancestry.com/v2/image/namespaces/${ns}/media/${iId}?client=trees-mediaservice&imageQuality=hq` : void 0;
2512
- });
2513
- const media = obje?.RIN?.value;
2514
- const clone = obje?.get("_CLON._OID")?.toValue();
2515
- const mser = obje?.get("_MSER._LKID")?.toValue();
2516
- let url = obje?.get("FILE")?.toValue();
2517
- const title = obje?.get("TITL")?.toValue() ?? "";
2518
- const type = obje?.get("FORM")?.toValue() ?? "raw";
2519
- const imgId = clone || mser;
2520
- if (!www || !tree || !this.id) {
2521
- return;
2522
- }
2523
- if (!namespace && !url) {
2524
- try {
2525
- const mediaDetailsResponse = await fetch(
2526
- `https://www.ancestry.com/api/media/viewer/v2/trees/${tree}/media?id=${media}`
2527
- );
2528
- const mediaDetails = await mediaDetailsResponse.json();
2529
- if (mediaDetails.url) {
2530
- url = `${mediaDetails.url}&imageQuality=hq`;
2528
+ if (objeList) {
2529
+ await Promise.all(
2530
+ objeList.map(async (objeRef) => {
2531
+ const key = objeRef?.id;
2532
+ const obje = objeRef?.standardizeMedia(
2533
+ namespace,
2534
+ true,
2535
+ (ns, iId) => {
2536
+ return ns && iId ? `https://mediasvc.ancestry.com/v2/image/namespaces/${ns}/media/${iId}?client=trees-mediaservice&imageQuality=hq` : void 0;
2531
2537
  }
2532
- } catch (_e) {
2538
+ );
2539
+ const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
2540
+ const media = obje?.RIN?.value;
2541
+ const clone = obje?.get("_CLON._OID")?.toValue();
2542
+ const mser = obje?.get("_MSER._LKID")?.toValue();
2543
+ let url = obje?.get("FILE")?.toValue();
2544
+ const title = obje?.get("TITL")?.toValue() ?? "";
2545
+ const type = obje?.get("FORM")?.toValue() ?? "raw";
2546
+ const imgId = clone || mser;
2547
+ if (!www || !tree || !this.id) {
2548
+ return;
2533
2549
  }
2534
- url = url || `https://${www}/mediaui-viewer/tree/${tree}/media/${media}`;
2535
- }
2536
- if (url && imgId) {
2537
- const id = `${tree}-${this.id}-${imgId}`;
2538
- list[id] = {
2539
- key,
2540
- id,
2541
- tree,
2542
- imgId,
2543
- person: this.id,
2544
- title,
2545
- url,
2546
- contentType: type,
2547
- downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
2548
- };
2549
- }
2550
- })
2551
- );
2550
+ if (!namespace && !url) {
2551
+ try {
2552
+ const mediaDetailsResponse = await fetch(
2553
+ `https://www.ancestry.com/api/media/viewer/v2/trees/${tree}/media?id=${media}`
2554
+ );
2555
+ const mediaDetails = await mediaDetailsResponse.json();
2556
+ if (mediaDetails.url) {
2557
+ url = `${mediaDetails.url}&imageQuality=hq`;
2558
+ }
2559
+ } catch (_e) {
2560
+ }
2561
+ url = url || `https://${www}/mediaui-viewer/tree/${tree}/media/${media}`;
2562
+ }
2563
+ if (url && imgId) {
2564
+ const id = `${tree}-${this.id}-${imgId}`;
2565
+ list[id] = {
2566
+ key,
2567
+ isPrimary,
2568
+ id,
2569
+ tree,
2570
+ imgId,
2571
+ person: this.id,
2572
+ title,
2573
+ url,
2574
+ contentType: type,
2575
+ downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
2576
+ };
2577
+ }
2578
+ })
2579
+ );
2580
+ }
2552
2581
  return list;
2553
2582
  }
2554
2583
  myheritageLink(poolId = 0) {
@@ -2586,6 +2615,7 @@ var Indi = class extends Common {
2586
2615
  if (url && imgId) {
2587
2616
  const id = `${tree}-${this.id}-${imgId}`;
2588
2617
  list[id] = {
2618
+ isPrimary: false,
2589
2619
  key,
2590
2620
  id,
2591
2621
  tree,
@@ -2695,6 +2725,36 @@ var Indi = class extends Common {
2695
2725
  }
2696
2726
  return void 0;
2697
2727
  }
2728
+ async getProfilePicture(namespace) {
2729
+ const mediaList = await this.multimedia(namespace);
2730
+ if (!mediaList) {
2731
+ return void 0;
2732
+ }
2733
+ const mediaArray = Object.values(mediaList);
2734
+ const primaryMedia = mediaArray.find(
2735
+ (media) => media.isPrimary && isImageFormat(media.contentType || getFileExtension(media.url))
2736
+ );
2737
+ if (primaryMedia) {
2738
+ return {
2739
+ file: primaryMedia.url,
2740
+ form: primaryMedia.contentType,
2741
+ title: primaryMedia.title,
2742
+ isPrimary: true
2743
+ };
2744
+ }
2745
+ const secondaryMedia = mediaArray.find(
2746
+ (media) => isImageFormat(media.contentType || getFileExtension(media.url))
2747
+ );
2748
+ if (secondaryMedia) {
2749
+ return {
2750
+ file: secondaryMedia.url,
2751
+ form: secondaryMedia.contentType,
2752
+ title: secondaryMedia.title,
2753
+ isPrimary: false
2754
+ };
2755
+ }
2756
+ return void 0;
2757
+ }
2698
2758
  link(poolId) {
2699
2759
  if (this?.isAncestry()) {
2700
2760
  return this.ancestryLink();
@@ -1,6 +1,6 @@
1
- import { I as ICacheManager, P as PlaceParts } from '../place-parser-CIplmmDd.js';
1
+ import { I as ICacheManager, P as PlaceParts } from '../place-parser-CM0TJFj8.js';
2
2
  import { Locale } from 'date-fns';
3
- import { a1 as IndiType, n as IndiKey, L as Language } from '../index-DOapi7nN.js';
3
+ import { a1 as IndiType, n as IndiKey, L as Language } from '../index-BPEVN_DY.js';
4
4
 
5
5
  /**
6
6
  * Factory function type for creating cache manager instances.