@treeviz/gedcom-parser 2.1.18 → 2.1.23

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.js CHANGED
@@ -967,7 +967,7 @@ var Common = class _Common {
967
967
  return this.sourStartsWith("ahnenblatt");
968
968
  }
969
969
  isGeni() {
970
- return this.sourStartsWith("geni");
970
+ return this.sourStartsWith("geni.com");
971
971
  }
972
972
  isAncestry() {
973
973
  return this.sourStartsWith("ancestry");
@@ -1300,6 +1300,68 @@ var idGetter = (id) => {
1300
1300
  return newId;
1301
1301
  };
1302
1302
 
1303
+ // src/factories/cache-factory.ts
1304
+ var defaultCacheFactory = () => {
1305
+ let cache = null;
1306
+ return {
1307
+ getItem: async () => cache,
1308
+ setItem: async (value) => {
1309
+ cache = value;
1310
+ }
1311
+ };
1312
+ };
1313
+ var cacheFactory = defaultCacheFactory;
1314
+ var setCacheManagerFactory = (factory) => {
1315
+ cacheFactory = factory;
1316
+ };
1317
+ var getCacheManagerFactory = () => {
1318
+ return cacheFactory;
1319
+ };
1320
+ var resetCacheManagerFactory = () => {
1321
+ cacheFactory = defaultCacheFactory;
1322
+ };
1323
+
1324
+ // src/factories/date-locale-factory.ts
1325
+ var dateLocaleProvider = () => void 0;
1326
+ var setDateLocaleProvider = (provider) => {
1327
+ dateLocaleProvider = provider;
1328
+ };
1329
+ var getDateLocale = () => {
1330
+ const result = dateLocaleProvider();
1331
+ return result;
1332
+ };
1333
+ var resetDateLocaleProvider = () => {
1334
+ dateLocaleProvider = () => void 0;
1335
+ };
1336
+
1337
+ // src/factories/i18n-factory.ts
1338
+ var i18nProvider = (key) => key;
1339
+ var setI18nProvider = (provider) => {
1340
+ i18nProvider = provider;
1341
+ };
1342
+ var getI18n = () => {
1343
+ return i18nProvider;
1344
+ };
1345
+ var resetI18nProvider = () => {
1346
+ i18nProvider = (key) => key;
1347
+ };
1348
+ var i18n = {
1349
+ t: (key, options) => i18nProvider(key, options)
1350
+ };
1351
+
1352
+ // src/kinship-translator/translators.ts
1353
+ var translators_exports = {};
1354
+ __export(translators_exports, {
1355
+ de: () => KinshipTranslatorDe,
1356
+ en: () => KinshipTranslatorEn,
1357
+ es: () => KinshipTranslatorEs,
1358
+ fr: () => KinshipTranslatorFr,
1359
+ hu: () => KinshipTranslatorHU,
1360
+ ja: () => KinshipTranslatorJa,
1361
+ ru: () => KinshipTranslatorRu,
1362
+ zh: () => KinshipTranslatorZh
1363
+ });
1364
+
1303
1365
  // src/types/types.ts
1304
1366
  var RelationType = /* @__PURE__ */ ((RelationType2) => {
1305
1367
  RelationType2["BIOLOGICAL"] = "biological";
@@ -1328,996 +1390,92 @@ var Range = /* @__PURE__ */ ((Range2) => {
1328
1390
  return Range2;
1329
1391
  })(Range || {});
1330
1392
 
1331
- // src/factories/cache-factory.ts
1332
- var defaultCacheFactory = () => {
1333
- let cache = null;
1334
- return {
1335
- getItem: async () => cache,
1336
- setItem: async (value) => {
1337
- cache = value;
1338
- }
1339
- };
1393
+ // src/constants/filters.ts
1394
+ var EVERY = {};
1395
+ var FEMALE = {
1396
+ SEX: "F"
1340
1397
  };
1341
- var cacheFactory = defaultCacheFactory;
1342
- var setCacheManagerFactory = (factory) => {
1343
- cacheFactory = factory;
1398
+ var MALE = {
1399
+ SEX: "M"
1344
1400
  };
1345
- var getCacheManagerFactory = () => {
1346
- return cacheFactory;
1401
+ var ADOPTED = {
1402
+ PEDI: "adopted" /* ADOPTED */
1347
1403
  };
1348
- var resetCacheManagerFactory = () => {
1349
- cacheFactory = defaultCacheFactory;
1404
+ var BIRTH = {
1405
+ PEDI: "birth" /* BIRTH */
1350
1406
  };
1351
-
1352
- // src/utils/cache.ts
1353
- var getGedcomId = (gedcom) => {
1354
- if (!gedcom) {
1355
- return "unknown";
1356
- }
1357
- const treeId = gedcom.getTreeId?.() || "";
1358
- const treeName = gedcom.getTreeName?.() || "";
1359
- const sanitizedName = treeName.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
1360
- if (treeId && sanitizedName) {
1361
- return `${treeId}_${sanitizedName}`;
1362
- } else if (treeId) {
1363
- return treeId;
1364
- } else if (sanitizedName) {
1365
- return sanitizedName;
1366
- }
1367
- return `gedcom_${gedcom.refcount}`;
1407
+ var FOSTER = {
1408
+ PEDI: "foster" /* FOSTER */
1368
1409
  };
1369
- var caches = {
1370
- pathCache: {},
1371
- relativesOnDegreeCache: {},
1372
- relativesOnLevelCache: {},
1373
- profilePictureCache: {}
1410
+ var SEALING = {
1411
+ PEDI: "sealing" /* SEALING */
1374
1412
  };
1375
- var cacheDbs;
1376
- var getCacheDbs = () => {
1377
- if (!cacheDbs) {
1378
- const getInstance = getCacheManagerFactory();
1379
- cacheDbs = {
1380
- pathCache: getInstance(
1381
- "ftv",
1382
- "Main",
1383
- "path",
1384
- true
1385
- ),
1386
- relativesOnDegreeCache: getInstance("ftv", "Main", "path", true),
1387
- relativesOnLevelCache: getInstance(
1388
- "ftv",
1389
- "Main",
1390
- "path",
1391
- true
1392
- ),
1393
- profilePictureCache: getInstance(
1394
- "ftv",
1395
- "Main",
1396
- "images",
1397
- false
1398
- )
1399
- };
1400
- }
1401
- return cacheDbs;
1413
+ var STEP = {
1414
+ PEDI: "step" /* STEP */
1402
1415
  };
1403
- var storeCache = {
1404
- // NOTE: pathCache, relativesOnLevelCache, and relativesOnDegreeCache are intentionally
1405
- // kept in memory only. These debounced functions exist to satisfy the type system
1406
- // but are never called.
1407
- pathCache: debounce((value) => {
1408
- if (value) {
1409
- getCacheDbs().pathCache.setItem(value);
1410
- }
1411
- }, 50),
1412
- relativesOnLevelCache: debounce((value) => {
1413
- if (value) {
1414
- getCacheDbs().relativesOnLevelCache.setItem(value);
1415
- }
1416
- }, 50),
1417
- relativesOnDegreeCache: debounce((value) => {
1418
- if (value) {
1419
- getCacheDbs().relativesOnDegreeCache.setItem(value);
1420
- }
1421
- }, 50),
1422
- // Image bytes are stored as one IndexedDB record per photo.
1423
- profilePictureCache: debounce((value) => {
1424
- }, 100)
1416
+ var BIOLOGICAL = {
1417
+ PEDI: "biological" /* BIOLOGICAL */
1425
1418
  };
1426
- var cacheInitialized = false;
1427
- var initializeCache = async () => {
1428
- if (cacheInitialized) {
1429
- return;
1430
- }
1431
- cacheInitialized = true;
1419
+ var FRIEND = {
1420
+ PART: "friend" /* FRIEND */
1432
1421
  };
1433
- var resetRelativesCache = () => {
1434
- caches.relativesOnDegreeCache = {};
1435
- caches.relativesOnLevelCache = {};
1422
+ var OTHER = {
1423
+ PART: "other" /* OTHER */
1436
1424
  };
1437
- var relativesCache = (cacheKey) => (gedcom, key, subKey, value) => {
1438
- const gedcomId = getGedcomId(gedcom);
1439
- const fullKey = `${gedcomId}:${key}`;
1440
- const cache = caches[cacheKey];
1441
- if (!cache) {
1442
- caches[cacheKey] = {};
1443
- }
1444
- if (value) {
1445
- const typedCache2 = caches[cacheKey];
1446
- if (!typedCache2[fullKey]) {
1447
- typedCache2[fullKey] = {};
1425
+ var PARTNER = {
1426
+ PART: "partner" /* PARTNER */
1427
+ };
1428
+ var SINGLE = {
1429
+ PART: "single" /* SINGLE */
1430
+ };
1431
+ var SPOUSE = {
1432
+ PART: "spouse" /* SPOUSE */
1433
+ };
1434
+ var UNKOWN = {
1435
+ PART: "unknown" /* UNKOWN */
1436
+ };
1437
+
1438
+ // src/utils/get-family-with.ts
1439
+ var getFamilyWith = (person1, person2, famType = "FAMS") => {
1440
+ return person1?.get(famType)?.toValueList().find((fam) => {
1441
+ const family = fam;
1442
+ return famType === "FAMC" || family?.HUSB?.value === person2 || family?.WIFE?.value === person2;
1443
+ });
1444
+ };
1445
+
1446
+ // src/constants/orders.ts
1447
+ var DEFAULT = {};
1448
+ var BIRTH_ASC = {
1449
+ "BIRT.DATE": {
1450
+ direction: "ASC",
1451
+ getter: (value, raw) => {
1452
+ if (isCommonDate(raw) && raw.rawValue) {
1453
+ return raw.rawValue.getTime();
1454
+ }
1455
+ return new Date(value).getTime();
1448
1456
  }
1449
- typedCache2[fullKey][subKey] = value;
1450
- return typedCache2[fullKey][subKey];
1451
1457
  }
1452
- const typedCache = caches[cacheKey];
1453
- return typedCache?.[fullKey]?.[subKey];
1454
1458
  };
1455
- var pathCache = (gedcom, key, value) => {
1456
- const gedcomId = getGedcomId(gedcom);
1457
- const fullKey = `${gedcomId}:${key}`;
1458
- if (!caches.pathCache) {
1459
- caches.pathCache = {};
1459
+ var BIRTH_DESC = {
1460
+ "BIRT.DATE": {
1461
+ direction: "DESC",
1462
+ getter: (value, raw) => {
1463
+ if (isCommonDate(raw) && raw.rawValue) {
1464
+ return raw.rawValue.getTime();
1465
+ }
1466
+ return new Date(value).getTime();
1467
+ }
1460
1468
  }
1461
- if (value && caches.pathCache) {
1462
- caches.pathCache[fullKey] = value;
1463
- return caches.pathCache[fullKey];
1464
- }
1465
- return caches.pathCache?.[fullKey];
1466
- };
1467
- var profilePictureCache = (gedcom, key, value) => {
1468
- const gedcomId = getGedcomId(gedcom);
1469
- const fullKey = `${gedcomId}:${key}`;
1470
- if (!caches.profilePictureCache) {
1471
- caches.profilePictureCache = {};
1472
- }
1473
- if (value && caches.profilePictureCache) {
1474
- caches.profilePictureCache[fullKey] = value;
1475
- storeCache.profilePictureCache(caches.profilePictureCache);
1476
- return caches.profilePictureCache[fullKey];
1477
- }
1478
- const cached = caches.profilePictureCache?.[fullKey];
1479
- return cached;
1480
- };
1481
- var isNonBiologicalPath = (path) => path.some(
1482
- (item) => item.relation && item.relation !== "biological" /* BIOLOGICAL */
1483
- );
1484
- var invertHop = (kinship) => {
1485
- if (kinship === "parent") {
1486
- return "child";
1487
- }
1488
- if (kinship === "child") {
1489
- return "parent";
1490
- }
1491
- return kinship;
1492
- };
1493
- var hopRelation = (from, toIndi, kinship, inherited) => {
1494
- if (kinship === "parent" || kinship === "child") {
1495
- const parent = kinship === "parent" ? toIndi : from.indi;
1496
- const child = kinship === "parent" ? from.indi : toIndi;
1497
- const currentRelation = child.getParentType(parent);
1498
- if (currentRelation && currentRelation !== "biological" /* BIOLOGICAL */) {
1499
- return currentRelation;
1500
- }
1501
- }
1502
- if (inherited && inherited !== "biological" /* BIOLOGICAL */) {
1503
- return inherited;
1504
- }
1505
- return void 0;
1506
- };
1507
- var rebuildPathFromHops = (hops, skipRelation = false) => {
1508
- if (hops.length === 0) {
1509
- return [];
1510
- }
1511
- const path = [
1512
- {
1513
- indi: hops[0].indi,
1514
- kinship: "self",
1515
- level: 0,
1516
- levelUp: 0,
1517
- levelDown: 0,
1518
- degree: 0
1519
- }
1520
- ];
1521
- for (let i = 1; i < hops.length; i++) {
1522
- const prev = path[i - 1];
1523
- const { indi, kinship } = hops[i];
1524
- const relation = skipRelation ? void 0 : hopRelation(prev, indi, kinship, prev.relation);
1525
- if (kinship === "parent") {
1526
- path.push({
1527
- indi,
1528
- kinship,
1529
- relation,
1530
- level: prev.level + 1,
1531
- levelUp: prev.levelUp + 1,
1532
- levelDown: prev.levelDown,
1533
- degree: prev.degree
1534
- });
1535
- continue;
1536
- }
1537
- if (kinship === "child") {
1538
- path.push({
1539
- indi,
1540
- kinship,
1541
- relation,
1542
- level: prev.level - 1,
1543
- levelUp: prev.levelUp,
1544
- levelDown: prev.levelDown + 1,
1545
- degree: prev.levelUp ? prev.level > 0 ? prev.levelUp - prev.level + 1 : prev.levelDown - Math.abs(prev.level) : 0
1546
- });
1547
- continue;
1548
- }
1549
- path.push({
1550
- indi,
1551
- kinship,
1552
- relation,
1553
- level: prev.level,
1554
- levelUp: prev.levelUp,
1555
- levelDown: prev.levelDown,
1556
- degree: prev.degree
1557
- });
1558
- }
1559
- return path;
1560
- };
1561
- var storePathIfBetter = (gedcom, fromId, toId, path) => {
1562
- const key = `${fromId}|${toId}`;
1563
- const existing = pathCache(gedcom, key);
1564
- if (existing && (!isNonBiologicalPath(existing) || isNonBiologicalPath(path))) {
1565
- return;
1566
- }
1567
- pathCache(gedcom, key, path);
1568
- };
1569
- var cacheDiscoveredPath = (gedcom, path) => {
1570
- const n = path.length;
1571
- if (n < 2) {
1572
- return;
1573
- }
1574
- for (let i = 0; i < n; i++) {
1575
- const fromId = path[i].indi.id;
1576
- if (!fromId) {
1577
- continue;
1578
- }
1579
- for (let j = i + 1; j < n; j++) {
1580
- const toId = path[j].indi.id;
1581
- if (!toId) {
1582
- continue;
1583
- }
1584
- const isOriginalPair = i === 0 && j === n - 1;
1585
- const isDirectHop = j === i + 1;
1586
- const slice = path.slice(i, j + 1);
1587
- const sliceMixed = isNonBiologicalPath(slice);
1588
- if (!isOriginalPair && !isDirectHop && sliceMixed) {
1589
- continue;
1590
- }
1591
- const forward = i === 0 ? slice : rebuildPathFromHops(slice, !sliceMixed);
1592
- const reverseHops = [
1593
- {
1594
- indi: slice[slice.length - 1].indi,
1595
- kinship: "self"
1596
- }
1597
- ];
1598
- for (let k = slice.length - 2; k >= 0; k--) {
1599
- reverseHops.push({
1600
- indi: slice[k].indi,
1601
- kinship: invertHop(slice[k + 1].kinship)
1602
- });
1603
- }
1604
- const reverse = rebuildPathFromHops(reverseHops, !sliceMixed);
1605
- storePathIfBetter(gedcom, fromId, toId, forward);
1606
- storePathIfBetter(gedcom, toId, fromId, reverse);
1607
- }
1608
- }
1609
- };
1610
-
1611
- // src/utils/family-edit.ts
1612
- var refTypeForTag = (tag) => {
1613
- if (tag === "FAMS" || tag === "FAMC") return "FAM";
1614
- return "INDI";
1615
- };
1616
- var normalizeSinglePointer = (owner, tag) => {
1617
- const node = owner.get(tag);
1618
- if (!node) return;
1619
- if (node instanceof List && node.length === 1) {
1620
- const only = node.index(0);
1621
- if (only) {
1622
- owner.set(tag, only);
1623
- return;
1624
- }
1625
- const raw = node.values()[0];
1626
- if (typeof raw === "string") {
1627
- const gedcom = owner.getGedcom?.();
1628
- if (gedcom) {
1629
- owner.set(tag, makePointer(gedcom, owner, raw, refTypeForTag(tag)));
1630
- }
1631
- }
1632
- }
1633
- };
1634
- var PEDIGREE_VALUES = [
1635
- "birth" /* BIRTH */,
1636
- "adopted" /* ADOPTED */,
1637
- "foster" /* FOSTER */,
1638
- "step" /* STEP */,
1639
- "sealing" /* SEALING */
1640
- ];
1641
- var toGedcomPedigree = (value) => {
1642
- const normalized = String(value || "birth" /* BIRTH */).toLowerCase();
1643
- if (normalized === "biological" /* BIOLOGICAL */ || normalized === "birth" /* BIRTH */) {
1644
- return "birth" /* BIRTH */;
1645
- }
1646
- const match = PEDIGREE_VALUES.find((item) => item === normalized);
1647
- return match ?? "birth" /* BIRTH */;
1648
- };
1649
- var pointerIds = (tag) => {
1650
- if (!tag) {
1651
- return [];
1652
- }
1653
- if (tag instanceof List) {
1654
- return tag.values().map((item) => item?.toValue?.()).filter((value2) => !!value2);
1655
- }
1656
- const value = tag.toValue?.();
1657
- return value ? [String(value)] : [];
1658
- };
1659
- var firstPointerId = (tag) => pointerIds(tag)[0];
1660
- var makePointer = (gedcom, parent, value, refType) => {
1661
- const pointer = createCommon(gedcom, void 0, parent);
1662
- pointer.value = value;
1663
- pointer.refType = refType;
1664
- return pointer;
1665
- };
1666
- var nextRecordId = (ids, prefix) => {
1667
- let max = 0;
1668
- ids.forEach((id) => {
1669
- const match = String(id).match(/(\d+)/);
1670
- const n = match ? Number.parseInt(match[1], 10) : 0;
1671
- if (n > max) {
1672
- max = n;
1673
- }
1674
- });
1675
- return `@${prefix}${max + 1}@`;
1676
- };
1677
- var familyHasParent = (fam, indiId) => pointerIds(fam.get("HUSB")).includes(indiId) || pointerIds(fam.get("WIFE")).includes(indiId);
1678
- var familyHasChild = (fam, indiId) => pointerIds(fam.get("CHIL")).includes(indiId);
1679
- var spouseTagFor = (indi, fam) => {
1680
- const husbId = firstPointerId(fam.get("HUSB"));
1681
- const wifeId = firstPointerId(fam.get("WIFE"));
1682
- if (husbId === indi.id) {
1683
- return "HUSB";
1684
- }
1685
- if (wifeId === indi.id) {
1686
- return "WIFE";
1687
- }
1688
- if (indi.isFemale()) {
1689
- return wifeId && wifeId !== indi.id ? "HUSB" : "WIFE";
1690
- }
1691
- if (indi.isMale()) {
1692
- return husbId && husbId !== indi.id ? "WIFE" : "HUSB";
1693
- }
1694
- return husbId ? "WIFE" : "HUSB";
1695
- };
1696
- var canAttachAsSpouse = (fam, indi) => {
1697
- if (!indi.id) {
1698
- return false;
1699
- }
1700
- if (familyHasParent(fam, indi.id)) {
1701
- return true;
1702
- }
1703
- const tag = spouseTagFor(indi, fam);
1704
- const occupied = firstPointerId(fam.get(tag));
1705
- return !occupied || occupied === indi.id;
1706
- };
1707
- var pointerByValue = (tag, id) => {
1708
- if (!tag) {
1709
- return void 0;
1710
- }
1711
- const fromValues = tag.toValueList?.().item(id);
1712
- if (fromValues) {
1713
- return fromValues;
1714
- }
1715
- return tag.toList()?.values().find((item) => item?.toValue?.() === id);
1716
- };
1717
- var setChildPedigree = (fam, child, pedigree, parent) => {
1718
- if (!fam.id || !child.id) {
1719
- return;
1720
- }
1721
- const pedi = toGedcomPedigree(pedigree);
1722
- const famc = pointerByValue(child.get("FAMC"), fam.id);
1723
- if (famc) {
1724
- famc.set("PEDI", pedi);
1725
- }
1726
- const chil = pointerByValue(fam.get("CHIL"), child.id);
1727
- if (!chil) {
1728
- return;
1729
- }
1730
- const setFather = !parent || parent.isMale() || parent.isUnknownSex();
1731
- const setMother = !parent || parent.isFemale() || parent.isUnknownSex();
1732
- if (setFather) {
1733
- chil.set("_FREL", pedi);
1734
- }
1735
- if (setMother) {
1736
- chil.set("_MREL", pedi);
1737
- }
1738
- };
1739
- var attachSpouseToFamily = (fam, indi) => {
1740
- const gedcom = fam.getGedcom() ?? indi.getGedcom();
1741
- if (!indi.id || !fam.id || !gedcom) {
1742
- return false;
1743
- }
1744
- if (!canAttachAsSpouse(fam, indi)) {
1745
- return false;
1746
- }
1747
- const tag = spouseTagFor(indi, fam);
1748
- if (firstPointerId(fam.get(tag)) !== indi.id) {
1749
- fam.set(tag, makePointer(gedcom, fam, indi.id, "INDI"));
1750
- }
1751
- indi.assign("FAMS", makePointer(gedcom, indi, fam.id, "FAM"), true);
1752
- normalizeSinglePointer(indi, "FAMS");
1753
- normalizeSinglePointer(fam, spouseTagFor(indi, fam));
1754
- resetRelativesCache();
1755
- return true;
1756
- };
1757
- var attachChildToFamily = (fam, child, pedigree, parent) => {
1758
- const gedcom = fam.getGedcom() ?? child.getGedcom();
1759
- if (!child.id || !fam.id || !gedcom) {
1760
- return false;
1761
- }
1762
- if (!familyHasChild(fam, child.id)) {
1763
- fam.assign("CHIL", makePointer(gedcom, fam, child.id, "INDI"), true);
1764
- }
1765
- const existingFamc = pointerByValue(child.get("FAMC"), fam.id);
1766
- if (!existingFamc) {
1767
- child.assign("FAMC", makePointer(gedcom, child, fam.id, "FAM"), true);
1768
- }
1769
- setChildPedigree(fam, child, pedigree, parent);
1770
- normalizeSinglePointer(child, "FAMC");
1771
- normalizeSinglePointer(fam, "CHIL");
1772
- resetRelativesCache();
1773
- return true;
1774
- };
1775
- var removePointerByValue = (owner, tag, targetId) => {
1776
- const node = owner.get(tag);
1777
- if (!node) {
1778
- return false;
1779
- }
1780
- if (node instanceof List) {
1781
- const keysToRemove = [];
1782
- node.entries().forEach(([key, item]) => {
1783
- if (item?.toValue?.() === targetId || item?.id === targetId || String(key) === targetId) {
1784
- keysToRemove.push(key);
1785
- }
1786
- });
1787
- keysToRemove.forEach((key) => {
1788
- node.removeItem(key);
1789
- });
1790
- if (node.length === 0) {
1791
- owner.remove(tag);
1792
- }
1793
- return keysToRemove.length > 0;
1794
- }
1795
- if (node.toValue?.() === targetId) {
1796
- owner.remove(tag);
1797
- return true;
1798
- }
1799
- const asList = node.toList?.();
1800
- if (asList && asList.length > 0) {
1801
- const keysToRemove = [];
1802
- asList.entries().forEach(([key, item]) => {
1803
- if (item?.toValue?.() === targetId || item?.id === targetId) {
1804
- keysToRemove.push(key);
1805
- }
1806
- });
1807
- if (keysToRemove.length === asList.length) {
1808
- owner.remove(tag);
1809
- return true;
1810
- }
1811
- if (keysToRemove.length > 0) {
1812
- const remaining = asList.values().filter((item) => item?.toValue?.() !== targetId);
1813
- if (remaining.length === 1 && remaining[0]) {
1814
- owner.set(tag, remaining[0]);
1815
- } else {
1816
- owner.set(tag, new List(remaining));
1817
- }
1818
- return true;
1819
- }
1820
- }
1821
- return false;
1822
- };
1823
- var familyMemberCount = (fam) => {
1824
- let count = 0;
1825
- if (firstPointerId(fam.get("HUSB"))) {
1826
- count += 1;
1827
- }
1828
- if (firstPointerId(fam.get("WIFE"))) {
1829
- count += 1;
1830
- }
1831
- count += pointerIds(fam.get("CHIL")).length;
1832
- return count;
1833
- };
1834
- var isDegenerateFamily = (fam) => familyMemberCount(fam) <= 1;
1835
- var pruneEmptyFamilies = (gedcom) => {
1836
- const emptyIds = [];
1837
- gedcom.fams()?.forEach((fam, id) => {
1838
- if (fam && isDegenerateFamily(fam) && id) {
1839
- emptyIds.push(id);
1840
- }
1841
- });
1842
- if (emptyIds.length === 0) {
1843
- return [];
1844
- }
1845
- gedcom.indis()?.forEach((indi) => {
1846
- if (!indi) {
1847
- return;
1848
- }
1849
- emptyIds.forEach((famId) => {
1850
- removePointerByValue(indi, "FAMS", famId);
1851
- removePointerByValue(indi, "FAMC", famId);
1852
- });
1853
- });
1854
- emptyIds.forEach((famId) => {
1855
- gedcom.fams()?.removeItem(famId);
1856
- });
1857
- return emptyIds;
1858
- };
1859
- var findDegenerateFamiliesForIndi = (indi) => {
1860
- const found = [];
1861
- const seen = /* @__PURE__ */ new Set();
1862
- ["FAMC", "FAMS"].forEach((pointer) => {
1863
- indi.getFamilies(pointer)?.forEach((fam) => {
1864
- if (!fam?.id || seen.has(fam.id) || !isDegenerateFamily(fam)) {
1865
- return;
1866
- }
1867
- seen.add(fam.id);
1868
- found.push(fam);
1869
- });
1870
- });
1871
- return found;
1872
- };
1873
- var coupleKeyForFam = (fam) => {
1874
- const husb = firstPointerId(fam.get("HUSB"));
1875
- const wife = firstPointerId(fam.get("WIFE"));
1876
- if (!husb || !wife) {
1877
- return void 0;
1878
- }
1879
- return husb < wife ? `${husb}|${wife}` : `${wife}|${husb}`;
1880
- };
1881
- var findDuplicateCoupleFamiliesForIndi = (indi) => {
1882
- const gedcom = indi.getGedcom();
1883
- if (!gedcom) {
1884
- return [];
1885
- }
1886
- const relevantKeys = /* @__PURE__ */ new Set();
1887
- ["FAMC", "FAMS"].forEach((pointer) => {
1888
- indi.getFamilies(pointer)?.forEach((fam) => {
1889
- const key = fam ? coupleKeyForFam(fam) : void 0;
1890
- if (key) {
1891
- relevantKeys.add(key);
1892
- }
1893
- });
1894
- });
1895
- if (relevantKeys.size === 0) {
1896
- return [];
1897
- }
1898
- const byKey = /* @__PURE__ */ new Map();
1899
- gedcom.fams()?.forEach((fam) => {
1900
- if (!fam?.id) {
1901
- return;
1902
- }
1903
- const key = coupleKeyForFam(fam);
1904
- if (!key || !relevantKeys.has(key)) {
1905
- return;
1906
- }
1907
- const list = byKey.get(key) ?? [];
1908
- list.push(fam);
1909
- byKey.set(key, list);
1910
- });
1911
- return [...byKey.entries()].filter(([, families]) => families.length > 1).map(([key, families]) => ({ key, families }));
1912
- };
1913
- var mergeDuplicateCoupleFamilies = (gedcom, families) => {
1914
- const usable = families.filter((fam) => !!fam?.id);
1915
- if (usable.length === 0) {
1916
- return void 0;
1917
- }
1918
- if (usable.length === 1) {
1919
- return usable[0];
1920
- }
1921
- const sorted = [...usable].sort((a, b) => {
1922
- const childDiff = pointerIds(b.get("CHIL")).length - pointerIds(a.get("CHIL")).length;
1923
- if (childDiff !== 0) {
1924
- return childDiff;
1925
- }
1926
- return String(a.id).localeCompare(String(b.id));
1927
- });
1928
- const keep = sorted[0];
1929
- const drops = sorted.slice(1);
1930
- if (!keep?.id) {
1931
- return void 0;
1932
- }
1933
- drops.forEach((drop) => {
1934
- if (!drop?.id || drop.id === keep.id) {
1935
- return;
1936
- }
1937
- pointerIds(drop.get("CHIL")).forEach((childId) => {
1938
- const child = gedcom.indi(childId);
1939
- if (!child) {
1940
- return;
1941
- }
1942
- attachChildToFamily(keep, child);
1943
- removePointerByValue(drop, "CHIL", childId);
1944
- normalizeSinglePointer(drop, "CHIL");
1945
- removePointerByValue(child, "FAMC", drop.id);
1946
- normalizeSinglePointer(child, "FAMC");
1947
- });
1948
- const husbId = firstPointerId(drop.get("HUSB"));
1949
- const wifeId = firstPointerId(drop.get("WIFE"));
1950
- [husbId, wifeId].forEach((parentId) => {
1951
- if (!parentId) {
1952
- return;
1953
- }
1954
- const parent = gedcom.indi(parentId);
1955
- if (parent) {
1956
- removePointerByValue(parent, "FAMS", drop.id);
1957
- normalizeSinglePointer(parent, "FAMS");
1958
- }
1959
- });
1960
- gedcom.fams()?.removeItem(drop.id);
1961
- });
1962
- resetRelativesCache();
1963
- return keep;
1964
- };
1965
- var pruneFamiliesByIds = (gedcom, famIds) => {
1966
- const unique = [...new Set(famIds.filter(Boolean))];
1967
- if (unique.length === 0) {
1968
- return 0;
1969
- }
1970
- gedcom.indis()?.forEach((indi) => {
1971
- if (!indi) {
1972
- return;
1973
- }
1974
- unique.forEach((famId) => {
1975
- removePointerByValue(indi, "FAMS", famId);
1976
- removePointerByValue(indi, "FAMC", famId);
1977
- });
1978
- });
1979
- unique.forEach((famId) => {
1980
- gedcom.fams()?.removeItem(famId);
1981
- });
1982
- return unique.length;
1983
- };
1984
- var findSharedSpouseFamily = (parent, coParentId) => {
1985
- let found;
1986
- parent.getFamilies("FAMS")?.forEach((fam) => {
1987
- if (!found && fam && familyHasParent(fam, coParentId)) {
1988
- found = fam;
1989
- }
1990
- });
1991
- return found;
1992
- };
1993
- var unlinkRelative = (anchor, relative, kind) => {
1994
- if (!anchor.id || !relative.id || anchor.id === relative.id) {
1995
- return false;
1996
- }
1997
- let changed = false;
1998
- if (kind === "spouse") {
1999
- anchor.getFamilies("FAMS")?.forEach((fam) => {
2000
- if (!fam?.id || !familyHasParent(fam, relative.id)) {
2001
- return;
2002
- }
2003
- if (firstPointerId(fam.get("HUSB")) === relative.id) {
2004
- fam.remove("HUSB");
2005
- changed = true;
2006
- }
2007
- if (firstPointerId(fam.get("WIFE")) === relative.id) {
2008
- fam.remove("WIFE");
2009
- changed = true;
2010
- }
2011
- changed = removePointerByValue(relative, "FAMS", fam.id) || changed;
2012
- });
2013
- } else if (kind === "parent") {
2014
- anchor.getFamilies("FAMC")?.forEach((fam) => {
2015
- if (!fam?.id || !familyHasParent(fam, relative.id)) {
2016
- return;
2017
- }
2018
- if (firstPointerId(fam.get("HUSB")) === relative.id) {
2019
- fam.remove("HUSB");
2020
- changed = true;
2021
- }
2022
- if (firstPointerId(fam.get("WIFE")) === relative.id) {
2023
- fam.remove("WIFE");
2024
- changed = true;
2025
- }
2026
- changed = removePointerByValue(relative, "FAMS", fam.id) || changed;
2027
- });
2028
- } else if (kind === "sibling") {
2029
- anchor.getFamilies("FAMC")?.forEach((fam) => {
2030
- if (!fam?.id || !familyHasChild(fam, relative.id)) {
2031
- return;
2032
- }
2033
- changed = removePointerByValue(fam, "CHIL", relative.id) || changed;
2034
- changed = removePointerByValue(relative, "FAMC", fam.id) || changed;
2035
- });
2036
- } else {
2037
- anchor.getFamilies("FAMS")?.forEach((fam) => {
2038
- if (!fam?.id || !familyHasChild(fam, relative.id)) {
2039
- return;
2040
- }
2041
- changed = removePointerByValue(fam, "CHIL", relative.id) || changed;
2042
- changed = removePointerByValue(relative, "FAMC", fam.id) || changed;
2043
- });
2044
- }
2045
- if (changed) {
2046
- const gedcom = anchor.getGedcom() ?? relative.getGedcom();
2047
- if (gedcom) {
2048
- pruneEmptyFamilies(gedcom);
2049
- }
2050
- resetRelativesCache();
2051
- }
2052
- return changed;
2053
- };
2054
- var deleteIndividual = (gedcom, indiId) => {
2055
- const indi = gedcom.indi(indiId);
2056
- if (!indi?.id) {
2057
- return false;
2058
- }
2059
- const famsIds = pointerIds(indi.get("FAMS"));
2060
- const famcIds = pointerIds(indi.get("FAMC"));
2061
- famsIds.forEach((famId) => {
2062
- const fam = gedcom.fam(famId);
2063
- if (!fam) {
2064
- return;
2065
- }
2066
- if (firstPointerId(fam.get("HUSB")) === indiId) {
2067
- fam.remove("HUSB");
2068
- }
2069
- if (firstPointerId(fam.get("WIFE")) === indiId) {
2070
- fam.remove("WIFE");
2071
- }
2072
- });
2073
- famcIds.forEach((famId) => {
2074
- const fam = gedcom.fam(famId);
2075
- if (fam) {
2076
- removePointerByValue(fam, "CHIL", indiId);
2077
- }
2078
- });
2079
- gedcom.fams()?.forEach((fam) => {
2080
- if (fam && familyHasChild(fam, indiId)) {
2081
- removePointerByValue(fam, "CHIL", indiId);
2082
- }
2083
- if (fam && familyHasParent(fam, indiId)) {
2084
- if (firstPointerId(fam.get("HUSB")) === indiId) {
2085
- fam.remove("HUSB");
2086
- }
2087
- if (firstPointerId(fam.get("WIFE")) === indiId) {
2088
- fam.remove("WIFE");
2089
- }
2090
- }
2091
- });
2092
- gedcom.indis()?.removeItem(indiId);
2093
- pruneEmptyFamilies(gedcom);
2094
- resetRelativesCache();
2095
- return true;
2096
- };
2097
- var findReusableParentChildFamily = (parent, child, options) => {
2098
- if (!parent.id || !child.id) {
2099
- return void 0;
2100
- }
2101
- const reuseParentFamilies = options?.reuseParentFamilies !== false;
2102
- const gedcom = parent.getGedcom() ?? child.getGedcom();
2103
- let reusableFamc;
2104
- let coupleFam;
2105
- let already = false;
2106
- const noteCoupleWith = (coParentId) => {
2107
- if (!coParentId || coParentId === parent.id || coupleFam || !parent.id) {
2108
- return;
2109
- }
2110
- const shared = findSharedSpouseFamily(parent, coParentId);
2111
- if (shared) {
2112
- coupleFam = shared;
2113
- }
2114
- };
2115
- child.getFamilies("FAMC")?.forEach((fam) => {
2116
- if (!fam) {
2117
- return;
2118
- }
2119
- if (familyHasParent(fam, parent.id) && familyHasChild(fam, child.id)) {
2120
- already = true;
2121
- return;
2122
- }
2123
- pointerIds(fam.get("HUSB")).forEach(noteCoupleWith);
2124
- pointerIds(fam.get("WIFE")).forEach(noteCoupleWith);
2125
- if (!reusableFamc && canAttachAsSpouse(fam, parent)) {
2126
- reusableFamc = fam;
2127
- }
2128
- });
2129
- if (already) {
2130
- return "already";
2131
- }
2132
- if (coupleFam) {
2133
- return coupleFam;
2134
- }
2135
- if (reusableFamc) {
2136
- return reusableFamc;
2137
- }
2138
- if (options?.targetFamilyId && gedcom) {
2139
- const target = gedcom.fam(options.targetFamilyId);
2140
- if (target && (familyHasParent(target, parent.id) || canAttachAsSpouse(target, parent))) {
2141
- return target;
2142
- }
2143
- }
2144
- if (!reuseParentFamilies) {
2145
- return void 0;
2146
- }
2147
- const parentFams = [];
2148
- parent.getFamilies("FAMS")?.forEach((fam) => {
2149
- if (fam) {
2150
- parentFams.push(fam);
2151
- }
2152
- });
2153
- if (parentFams.length === 1) {
2154
- return parentFams[0];
2155
- }
2156
- return void 0;
2157
- };
2158
- var consolidateChildIntoFamily = (child, keep) => {
2159
- if (!child.id || !keep.id) {
2160
- return [];
2161
- }
2162
- const keepParentIds = /* @__PURE__ */ new Set([
2163
- ...pointerIds(keep.get("HUSB")),
2164
- ...pointerIds(keep.get("WIFE"))
2165
- ]);
2166
- const removed = [];
2167
- child.getFamilies("FAMC")?.forEach((fam) => {
2168
- if (!fam?.id || fam.id === keep.id) {
2169
- return;
2170
- }
2171
- const famParentIds = [
2172
- ...pointerIds(fam.get("HUSB")),
2173
- ...pointerIds(fam.get("WIFE"))
2174
- ];
2175
- if (famParentIds.length === 0 || !famParentIds.every((id) => keepParentIds.has(id))) {
2176
- return;
2177
- }
2178
- removePointerByValue(fam, "CHIL", child.id);
2179
- normalizeSinglePointer(fam, "CHIL");
2180
- removePointerByValue(child, "FAMC", fam.id);
2181
- normalizeSinglePointer(child, "FAMC");
2182
- removed.push(fam.id);
2183
- });
2184
- const gedcom = child.getGedcom() ?? keep.getGedcom();
2185
- if (gedcom && removed.length > 0) {
2186
- pruneEmptyFamilies(gedcom);
2187
- }
2188
- if (removed.length > 0) {
2189
- resetRelativesCache();
2190
- }
2191
- return removed;
2192
- };
2193
-
2194
- // src/factories/date-locale-factory.ts
2195
- var dateLocaleProvider = () => void 0;
2196
- var setDateLocaleProvider = (provider) => {
2197
- dateLocaleProvider = provider;
2198
- };
2199
- var getDateLocale = () => {
2200
- const result = dateLocaleProvider();
2201
- return result;
2202
- };
2203
- var resetDateLocaleProvider = () => {
2204
- dateLocaleProvider = () => void 0;
2205
- };
2206
-
2207
- // src/factories/i18n-factory.ts
2208
- var i18nProvider = (key) => key;
2209
- var setI18nProvider = (provider) => {
2210
- i18nProvider = provider;
2211
- };
2212
- var getI18n = () => {
2213
- return i18nProvider;
2214
- };
2215
- var resetI18nProvider = () => {
2216
- i18nProvider = (key) => key;
2217
- };
2218
- var i18n = {
2219
- t: (key, options) => i18nProvider(key, options)
2220
- };
2221
-
2222
- // src/kinship-translator/translators.ts
2223
- var translators_exports = {};
2224
- __export(translators_exports, {
2225
- de: () => KinshipTranslatorDe,
2226
- en: () => KinshipTranslatorEn,
2227
- es: () => KinshipTranslatorEs,
2228
- fr: () => KinshipTranslatorFr,
2229
- hu: () => KinshipTranslatorHU,
2230
- ja: () => KinshipTranslatorJa,
2231
- ru: () => KinshipTranslatorRu,
2232
- zh: () => KinshipTranslatorZh
2233
- });
2234
-
2235
- // src/constants/filters.ts
2236
- var EVERY = {};
2237
- var FEMALE = {
2238
- SEX: "F"
2239
- };
2240
- var MALE = {
2241
- SEX: "M"
2242
- };
2243
- var ADOPTED = {
2244
- PEDI: "adopted" /* ADOPTED */
2245
- };
2246
- var BIRTH = {
2247
- PEDI: "birth" /* BIRTH */
2248
- };
2249
- var FOSTER = {
2250
- PEDI: "foster" /* FOSTER */
2251
- };
2252
- var SEALING = {
2253
- PEDI: "sealing" /* SEALING */
2254
- };
2255
- var STEP = {
2256
- PEDI: "step" /* STEP */
2257
- };
2258
- var BIOLOGICAL = {
2259
- PEDI: "biological" /* BIOLOGICAL */
2260
- };
2261
- var FRIEND = {
2262
- PART: "friend" /* FRIEND */
2263
- };
2264
- var OTHER = {
2265
- PART: "other" /* OTHER */
2266
- };
2267
- var PARTNER = {
2268
- PART: "partner" /* PARTNER */
2269
- };
2270
- var SINGLE = {
2271
- PART: "single" /* SINGLE */
2272
- };
2273
- var SPOUSE = {
2274
- PART: "spouse" /* SPOUSE */
2275
- };
2276
- var UNKOWN = {
2277
- PART: "unknown" /* UNKOWN */
2278
- };
2279
-
2280
- // src/utils/get-family-with.ts
2281
- var getFamilyWith = (person1, person2, famType = "FAMS") => {
2282
- return person1?.get(famType)?.toValueList().find((fam) => {
2283
- const family = fam;
2284
- return famType === "FAMC" || family?.HUSB?.value === person2 || family?.WIFE?.value === person2;
2285
- });
2286
- };
2287
-
2288
- // src/constants/orders.ts
2289
- var DEFAULT = {};
2290
- var BIRTH_ASC = {
2291
- "BIRT.DATE": {
2292
- direction: "ASC",
2293
- getter: (value, raw) => {
2294
- if (isCommonDate(raw) && raw.rawValue) {
2295
- return raw.rawValue.getTime();
2296
- }
2297
- return new Date(value).getTime();
2298
- }
2299
- }
2300
- };
2301
- var BIRTH_DESC = {
2302
- "BIRT.DATE": {
2303
- direction: "DESC",
2304
- getter: (value, raw) => {
2305
- if (isCommonDate(raw) && raw.rawValue) {
2306
- return raw.rawValue.getTime();
2307
- }
2308
- return new Date(value).getTime();
2309
- }
2310
- }
2311
- };
2312
- var DEATH_ASC = {
2313
- "DEAT.DATE": {
2314
- direction: "ASC",
2315
- getter: (value, raw) => {
2316
- if (isCommonDate(raw) && raw.rawValue) {
2317
- return raw.rawValue.getTime();
2318
- }
2319
- return new Date(value).getTime();
2320
- }
1469
+ };
1470
+ var DEATH_ASC = {
1471
+ "DEAT.DATE": {
1472
+ direction: "ASC",
1473
+ getter: (value, raw) => {
1474
+ if (isCommonDate(raw) && raw.rawValue) {
1475
+ return raw.rawValue.getTime();
1476
+ }
1477
+ return new Date(value).getTime();
1478
+ }
2321
1479
  }
2322
1480
  };
2323
1481
  var DEATH_DESC = {
@@ -2500,28 +1658,285 @@ var getMarriageAsc = (person, famType = "FAMS") => (itemA, _keyA, itemB, _keyB)
2500
1658
  }
2501
1659
  return -1;
2502
1660
  };
2503
- var getMarriageAscAndChildBirth = (person) => (itemA, keyA, itemB, keyB) => {
2504
- const marriageSort = getMarriageAsc(person)(itemA, keyA, itemB, keyB);
2505
- if (marriageSort !== 0) {
2506
- return marriageSort;
1661
+ var getMarriageAscAndChildBirth = (person) => (itemA, keyA, itemB, keyB) => {
1662
+ const marriageSort = getMarriageAsc(person)(itemA, keyA, itemB, keyB);
1663
+ if (marriageSort !== 0) {
1664
+ return marriageSort;
1665
+ }
1666
+ const familyA = getFamilyWith(itemA, person);
1667
+ const familyB = getFamilyWith(itemB, person);
1668
+ const childA = familyA?.getChildren().orderBy(BIRTH_ASC).index(0);
1669
+ const childB = familyB?.getChildren().orderBy(BIRTH_ASC).index(0);
1670
+ return getBirthAsc(childA, keyA, childB);
1671
+ };
1672
+ var getMarriageAscAndBirth = (person) => (itemA, keyA, itemB, keyB) => {
1673
+ const marriageSort = getMarriageAsc(person, "FAMC")(
1674
+ itemA,
1675
+ keyA,
1676
+ itemB,
1677
+ keyB
1678
+ );
1679
+ if (marriageSort !== 0) {
1680
+ return marriageSort;
1681
+ }
1682
+ return getBirthAsc(itemA, keyA, itemB);
1683
+ };
1684
+ var getGedcomId = (gedcom) => {
1685
+ if (!gedcom) {
1686
+ return "unknown";
1687
+ }
1688
+ const treeId = gedcom.getTreeId?.() || "";
1689
+ const treeName = gedcom.getTreeName?.() || "";
1690
+ const sanitizedName = treeName.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
1691
+ if (treeId && sanitizedName) {
1692
+ return `${treeId}_${sanitizedName}`;
1693
+ } else if (treeId) {
1694
+ return treeId;
1695
+ } else if (sanitizedName) {
1696
+ return sanitizedName;
1697
+ }
1698
+ return `gedcom_${gedcom.refcount}`;
1699
+ };
1700
+ var caches = {
1701
+ pathCache: {},
1702
+ relativesOnDegreeCache: {},
1703
+ relativesOnLevelCache: {},
1704
+ profilePictureCache: {}
1705
+ };
1706
+ var cacheDbs;
1707
+ var getCacheDbs = () => {
1708
+ if (!cacheDbs) {
1709
+ const getInstance = getCacheManagerFactory();
1710
+ cacheDbs = {
1711
+ pathCache: getInstance(
1712
+ "ftv",
1713
+ "Main",
1714
+ "path",
1715
+ true
1716
+ ),
1717
+ relativesOnDegreeCache: getInstance("ftv", "Main", "path", true),
1718
+ relativesOnLevelCache: getInstance(
1719
+ "ftv",
1720
+ "Main",
1721
+ "path",
1722
+ true
1723
+ ),
1724
+ profilePictureCache: getInstance(
1725
+ "ftv",
1726
+ "Main",
1727
+ "images",
1728
+ false
1729
+ )
1730
+ };
1731
+ }
1732
+ return cacheDbs;
1733
+ };
1734
+ var storeCache = {
1735
+ // NOTE: pathCache, relativesOnLevelCache, and relativesOnDegreeCache are intentionally
1736
+ // kept in memory only. These debounced functions exist to satisfy the type system
1737
+ // but are never called.
1738
+ pathCache: debounce((value) => {
1739
+ if (value) {
1740
+ getCacheDbs().pathCache.setItem(value);
1741
+ }
1742
+ }, 50),
1743
+ relativesOnLevelCache: debounce((value) => {
1744
+ if (value) {
1745
+ getCacheDbs().relativesOnLevelCache.setItem(value);
1746
+ }
1747
+ }, 50),
1748
+ relativesOnDegreeCache: debounce((value) => {
1749
+ if (value) {
1750
+ getCacheDbs().relativesOnDegreeCache.setItem(value);
1751
+ }
1752
+ }, 50),
1753
+ // Image bytes are stored as one IndexedDB record per photo.
1754
+ profilePictureCache: debounce((value) => {
1755
+ }, 100)
1756
+ };
1757
+ var cacheInitialized = false;
1758
+ var initializeCache = async () => {
1759
+ if (cacheInitialized) {
1760
+ return;
1761
+ }
1762
+ cacheInitialized = true;
1763
+ };
1764
+ var resetRelativesCache = () => {
1765
+ caches.relativesOnDegreeCache = {};
1766
+ caches.relativesOnLevelCache = {};
1767
+ };
1768
+ var relativesCache = (cacheKey) => (gedcom, key, subKey, value) => {
1769
+ const gedcomId = getGedcomId(gedcom);
1770
+ const fullKey = `${gedcomId}:${key}`;
1771
+ const cache = caches[cacheKey];
1772
+ if (!cache) {
1773
+ caches[cacheKey] = {};
1774
+ }
1775
+ if (value) {
1776
+ const typedCache2 = caches[cacheKey];
1777
+ if (!typedCache2[fullKey]) {
1778
+ typedCache2[fullKey] = {};
1779
+ }
1780
+ typedCache2[fullKey][subKey] = value;
1781
+ return typedCache2[fullKey][subKey];
1782
+ }
1783
+ const typedCache = caches[cacheKey];
1784
+ return typedCache?.[fullKey]?.[subKey];
1785
+ };
1786
+ var pathCache = (gedcom, key, value) => {
1787
+ const gedcomId = getGedcomId(gedcom);
1788
+ const fullKey = `${gedcomId}:${key}`;
1789
+ if (!caches.pathCache) {
1790
+ caches.pathCache = {};
1791
+ }
1792
+ if (value && caches.pathCache) {
1793
+ caches.pathCache[fullKey] = value;
1794
+ return caches.pathCache[fullKey];
1795
+ }
1796
+ return caches.pathCache?.[fullKey];
1797
+ };
1798
+ var profilePictureCache = (gedcom, key, value) => {
1799
+ const gedcomId = getGedcomId(gedcom);
1800
+ const fullKey = `${gedcomId}:${key}`;
1801
+ if (!caches.profilePictureCache) {
1802
+ caches.profilePictureCache = {};
1803
+ }
1804
+ if (value && caches.profilePictureCache) {
1805
+ caches.profilePictureCache[fullKey] = value;
1806
+ storeCache.profilePictureCache(caches.profilePictureCache);
1807
+ return caches.profilePictureCache[fullKey];
1808
+ }
1809
+ const cached = caches.profilePictureCache?.[fullKey];
1810
+ return cached;
1811
+ };
1812
+ var isNonBiologicalPath = (path) => path.some(
1813
+ (item) => item.relation && item.relation !== "biological" /* BIOLOGICAL */
1814
+ );
1815
+ var invertHop = (kinship) => {
1816
+ if (kinship === "parent") {
1817
+ return "child";
1818
+ }
1819
+ if (kinship === "child") {
1820
+ return "parent";
1821
+ }
1822
+ return kinship;
1823
+ };
1824
+ var hopRelation = (from, toIndi, kinship, inherited) => {
1825
+ if (kinship === "parent" || kinship === "child") {
1826
+ const parent = kinship === "parent" ? toIndi : from.indi;
1827
+ const child = kinship === "parent" ? from.indi : toIndi;
1828
+ const currentRelation = child.getParentType(parent);
1829
+ if (currentRelation && currentRelation !== "biological" /* BIOLOGICAL */) {
1830
+ return currentRelation;
1831
+ }
1832
+ }
1833
+ if (inherited && inherited !== "biological" /* BIOLOGICAL */) {
1834
+ return inherited;
1835
+ }
1836
+ return void 0;
1837
+ };
1838
+ var rebuildPathFromHops = (hops, skipRelation = false) => {
1839
+ if (hops.length === 0) {
1840
+ return [];
1841
+ }
1842
+ const path = [
1843
+ {
1844
+ indi: hops[0].indi,
1845
+ kinship: "self",
1846
+ level: 0,
1847
+ levelUp: 0,
1848
+ levelDown: 0,
1849
+ degree: 0
1850
+ }
1851
+ ];
1852
+ for (let i = 1; i < hops.length; i++) {
1853
+ const prev = path[i - 1];
1854
+ const { indi, kinship } = hops[i];
1855
+ const relation = skipRelation ? void 0 : hopRelation(prev, indi, kinship, prev.relation);
1856
+ if (kinship === "parent") {
1857
+ path.push({
1858
+ indi,
1859
+ kinship,
1860
+ relation,
1861
+ level: prev.level + 1,
1862
+ levelUp: prev.levelUp + 1,
1863
+ levelDown: prev.levelDown,
1864
+ degree: prev.degree
1865
+ });
1866
+ continue;
1867
+ }
1868
+ if (kinship === "child") {
1869
+ path.push({
1870
+ indi,
1871
+ kinship,
1872
+ relation,
1873
+ level: prev.level - 1,
1874
+ levelUp: prev.levelUp,
1875
+ levelDown: prev.levelDown + 1,
1876
+ degree: prev.levelUp ? prev.level > 0 ? prev.levelUp - prev.level + 1 : prev.levelDown - Math.abs(prev.level) : 0
1877
+ });
1878
+ continue;
1879
+ }
1880
+ path.push({
1881
+ indi,
1882
+ kinship,
1883
+ relation,
1884
+ level: prev.level,
1885
+ levelUp: prev.levelUp,
1886
+ levelDown: prev.levelDown,
1887
+ degree: prev.degree
1888
+ });
1889
+ }
1890
+ return path;
1891
+ };
1892
+ var storePathIfBetter = (gedcom, fromId, toId, path) => {
1893
+ const key = `${fromId}|${toId}`;
1894
+ const existing = pathCache(gedcom, key);
1895
+ if (existing && (!isNonBiologicalPath(existing) || isNonBiologicalPath(path))) {
1896
+ return;
2507
1897
  }
2508
- const familyA = getFamilyWith(itemA, person);
2509
- const familyB = getFamilyWith(itemB, person);
2510
- const childA = familyA?.getChildren().orderBy(BIRTH_ASC).index(0);
2511
- const childB = familyB?.getChildren().orderBy(BIRTH_ASC).index(0);
2512
- return getBirthAsc(childA, keyA, childB);
1898
+ pathCache(gedcom, key, path);
2513
1899
  };
2514
- var getMarriageAscAndBirth = (person) => (itemA, keyA, itemB, keyB) => {
2515
- const marriageSort = getMarriageAsc(person, "FAMC")(
2516
- itemA,
2517
- keyA,
2518
- itemB,
2519
- keyB
2520
- );
2521
- if (marriageSort !== 0) {
2522
- return marriageSort;
1900
+ var cacheDiscoveredPath = (gedcom, path) => {
1901
+ const n = path.length;
1902
+ if (n < 2) {
1903
+ return;
1904
+ }
1905
+ for (let i = 0; i < n; i++) {
1906
+ const fromId = path[i].indi.id;
1907
+ if (!fromId) {
1908
+ continue;
1909
+ }
1910
+ for (let j = i + 1; j < n; j++) {
1911
+ const toId = path[j].indi.id;
1912
+ if (!toId) {
1913
+ continue;
1914
+ }
1915
+ const isOriginalPair = i === 0 && j === n - 1;
1916
+ const isDirectHop = j === i + 1;
1917
+ const slice = path.slice(i, j + 1);
1918
+ const sliceMixed = isNonBiologicalPath(slice);
1919
+ if (!isOriginalPair && !isDirectHop && sliceMixed) {
1920
+ continue;
1921
+ }
1922
+ const forward = i === 0 ? slice : rebuildPathFromHops(slice, !sliceMixed);
1923
+ const reverseHops = [
1924
+ {
1925
+ indi: slice[slice.length - 1].indi,
1926
+ kinship: "self"
1927
+ }
1928
+ ];
1929
+ for (let k = slice.length - 2; k >= 0; k--) {
1930
+ reverseHops.push({
1931
+ indi: slice[k].indi,
1932
+ kinship: invertHop(slice[k + 1].kinship)
1933
+ });
1934
+ }
1935
+ const reverse = rebuildPathFromHops(reverseHops, !sliceMixed);
1936
+ storePathIfBetter(gedcom, fromId, toId, forward);
1937
+ storePathIfBetter(gedcom, toId, fromId, reverse);
1938
+ }
2523
1939
  }
2524
- return getBirthAsc(itemA, keyA, itemB);
2525
1940
  };
2526
1941
 
2527
1942
  // src/utils/get-all-prop.ts
@@ -2757,6 +2172,180 @@ var dateFormatter = (indi, showMarriages = false, showDays = false, showPlaces =
2757
2172
  };
2758
2173
  };
2759
2174
 
2175
+ // src/utils/fact-edit.ts
2176
+ var SINGLETON_TAGS = /* @__PURE__ */ new Set(["BIRT", "DEAT", "SSN", "SEX", "DSCR"]);
2177
+ var firstRecord = (node) => {
2178
+ if (!node) {
2179
+ return void 0;
2180
+ }
2181
+ if (node instanceof List) {
2182
+ return node.index(0);
2183
+ }
2184
+ return node.index(0) ?? node;
2185
+ };
2186
+ var setDateOn = (gedcom, owner, parent, date) => {
2187
+ const trimmed = date.trim();
2188
+ if (!trimmed) {
2189
+ return;
2190
+ }
2191
+ let dateNode = parent.get("DATE");
2192
+ if (!dateNode || dateNode instanceof List) {
2193
+ dateNode = createCommonDate(gedcom, void 0, owner, parent);
2194
+ dateNode.type = "DATE";
2195
+ parent.set("DATE", dateNode);
2196
+ }
2197
+ dateNode.value = trimmed;
2198
+ };
2199
+ var fillFact = (gedcom, owner, event, input) => {
2200
+ if (input.value?.trim()) {
2201
+ event.value = input.value.trim();
2202
+ }
2203
+ if (input.type?.trim()) {
2204
+ event.set("TYPE", input.type.trim());
2205
+ }
2206
+ if (input.date) {
2207
+ setDateOn(gedcom, owner, event, input.date);
2208
+ }
2209
+ if (input.place?.trim()) {
2210
+ event.set("PLAC", input.place.trim());
2211
+ }
2212
+ if (input.note?.trim()) {
2213
+ event.set("NOTE", input.note.trim());
2214
+ }
2215
+ };
2216
+ var updateFactRecord = (owner, event, input) => {
2217
+ const gedcom = owner.getGedcom();
2218
+ if (!gedcom) {
2219
+ return event;
2220
+ }
2221
+ const asOwner = owner;
2222
+ if (input.value !== void 0) {
2223
+ const trimmed = input.value.trim();
2224
+ if (trimmed) {
2225
+ event.value = trimmed;
2226
+ } else {
2227
+ event.removeValue();
2228
+ }
2229
+ }
2230
+ if (input.type !== void 0) {
2231
+ const trimmed = input.type.trim();
2232
+ if (trimmed) {
2233
+ event.set("TYPE", trimmed);
2234
+ } else {
2235
+ event.remove("TYPE");
2236
+ }
2237
+ }
2238
+ if (input.date !== void 0) {
2239
+ const trimmed = input.date.trim();
2240
+ if (trimmed) {
2241
+ setDateOn(gedcom, asOwner, event, trimmed);
2242
+ } else {
2243
+ event.remove("DATE");
2244
+ }
2245
+ }
2246
+ if (input.place !== void 0) {
2247
+ const trimmed = input.place.trim();
2248
+ if (trimmed) {
2249
+ event.set("PLAC", trimmed);
2250
+ } else {
2251
+ event.remove("PLAC");
2252
+ }
2253
+ }
2254
+ if (input.note !== void 0) {
2255
+ const trimmed = input.note.trim();
2256
+ if (trimmed) {
2257
+ event.set("NOTE", trimmed);
2258
+ } else {
2259
+ event.remove("NOTE");
2260
+ }
2261
+ }
2262
+ return event;
2263
+ };
2264
+ var setFamilyMarriage = (fam, input) => {
2265
+ const existing = firstRecord(fam.get("MARR"));
2266
+ if (existing) {
2267
+ return updateFactRecord(fam, existing, {
2268
+ date: input.date,
2269
+ place: input.place
2270
+ });
2271
+ }
2272
+ return addFamilyFact(fam, {
2273
+ tag: "MARR",
2274
+ date: input.date,
2275
+ place: input.place
2276
+ });
2277
+ };
2278
+ var addIndividualFact = (indi, input) => {
2279
+ const gedcom = indi.getGedcom();
2280
+ if (!gedcom) {
2281
+ return void 0;
2282
+ }
2283
+ const tag = input.tag;
2284
+ let event = SINGLETON_TAGS.has(tag) ? firstRecord(indi.get(tag)) : void 0;
2285
+ if (!event) {
2286
+ event = createCommon(gedcom, void 0, indi);
2287
+ event.type = tag;
2288
+ if (SINGLETON_TAGS.has(tag)) {
2289
+ indi.set(tag, event);
2290
+ } else {
2291
+ indi.assign(tag, event);
2292
+ }
2293
+ }
2294
+ fillFact(gedcom, indi, event, input);
2295
+ return event;
2296
+ };
2297
+ var addFamilyFact = (fam, input) => {
2298
+ const gedcom = fam.getGedcom();
2299
+ if (!gedcom) {
2300
+ return void 0;
2301
+ }
2302
+ const event = createCommon(gedcom, void 0, fam);
2303
+ event.type = input.tag;
2304
+ fam.assign(input.tag, event);
2305
+ fillFact(gedcom, fam, event, input);
2306
+ return event;
2307
+ };
2308
+ var setCauseOfDeath = (indi, text) => {
2309
+ const trimmed = text.trim();
2310
+ if (!trimmed) {
2311
+ return void 0;
2312
+ }
2313
+ const death = firstRecord(indi.get("DEAT")) || addIndividualFact(indi, { tag: "DEAT", value: "Y" });
2314
+ if (!death) {
2315
+ return void 0;
2316
+ }
2317
+ death.set("CAUS", trimmed);
2318
+ return death;
2319
+ };
2320
+ var setDeceased = (indi, deceased) => {
2321
+ if (!deceased) {
2322
+ indi.remove("DEAT");
2323
+ return;
2324
+ }
2325
+ if (firstRecord(indi.get("DEAT"))) {
2326
+ return;
2327
+ }
2328
+ addIndividualFact(indi, { tag: "DEAT", value: "Y" });
2329
+ };
2330
+ var addNonEvent = (owner, input) => {
2331
+ const gedcom = owner.getGedcom();
2332
+ const eventType = input.event?.trim().toUpperCase();
2333
+ if (!gedcom || !eventType) {
2334
+ return void 0;
2335
+ }
2336
+ const no = createCommon(gedcom, void 0, owner);
2337
+ no.type = "NO";
2338
+ no.value = eventType;
2339
+ if (input.date?.trim()) {
2340
+ setDateOn(gedcom, owner, no, input.date);
2341
+ }
2342
+ if (input.note?.trim()) {
2343
+ no.set("NOTE", input.note.trim());
2344
+ }
2345
+ owner.assign("NO", no);
2346
+ return no;
2347
+ };
2348
+
2760
2349
  // src/utils/get-places.ts
2761
2350
  var PlaceType = /* @__PURE__ */ ((PlaceType2) => {
2762
2351
  PlaceType2["All"] = "ALL";
@@ -3669,10 +3258,12 @@ var relativesOnLevelCache = relativesCache("relativesOnLevelCache");
3669
3258
  var relativesOnDegreeCache = relativesCache("relativesOnDegreeCache");
3670
3259
  var Indi = class extends Common {
3671
3260
  toName() {
3672
- return this.get("NAME")?.toValue();
3261
+ const name = this.get("NAME");
3262
+ const value = name?.index(0)?.toValue() ?? name?.toValue();
3263
+ return typeof value === "string" ? value : void 0;
3673
3264
  }
3674
3265
  toNaturalName() {
3675
- return this.get("NAME")?.toValue()?.replaceAll("/", "");
3266
+ return this.toName()?.replaceAll("/", "");
3676
3267
  }
3677
3268
  toList() {
3678
3269
  return new Individuals().concat(
@@ -4217,17 +3808,25 @@ var Indi = class extends Common {
4217
3808
  }
4218
3809
  return list;
4219
3810
  }
4220
- myheritageLink(poolId = 0) {
3811
+ myheritageLink(poolId = 0, treeToken) {
4221
3812
  let www = (this.getFromSourceHeads("SOUR.CORP.value") || this._gedcom?.HEAD?.SOUR?.CORP?.value)?.toLowerCase().replace(/^www\./gi, "");
4222
3813
  if (!www || /treeviz/i.test(www)) {
4223
3814
  www = "myheritage.com";
4224
3815
  }
3816
+ if (!this.id) {
3817
+ return;
3818
+ }
3819
+ const id = Number(this.id.replace(/@|I/g, "")) + poolId;
3820
+ if (!Number.isFinite(id)) {
3821
+ return;
3822
+ }
3823
+ const slug = this.toNaturalName()?.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || String(id);
3824
+ if (treeToken) {
3825
+ return `https://www.${www}/profile-${treeToken}-${id}/${slug}`;
3826
+ }
4225
3827
  const site = this.getMyHeritageTreeId();
4226
- const file = (this.getFromSourceHeads("FILE.value") || this._gedcom?.HEAD?.get("FILE")?.toValue())?.match(/Exported by MyHeritage.com from .+ in (?<site>.+) on .+$/)?.groups?.site;
4227
- const normalizedFile = file?.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-");
4228
- if (normalizedFile && this.id) {
4229
- const id = Number(this.id.replace(/@|I/g, "")) + poolId;
4230
- return `https://www.${www}/site-family-tree-${site}/${normalizedFile}#!profile-${id}-info`;
3828
+ if (site) {
3829
+ return `https://www.${www}/person-${id}_${site}_${site}/${slug}`;
4231
3830
  }
4232
3831
  }
4233
3832
  myheritageMedia() {
@@ -4276,6 +3875,14 @@ var Indi = class extends Common {
4276
3875
  });
4277
3876
  return list;
4278
3877
  }
3878
+ geniLink() {
3879
+ if (!this.id) {
3880
+ return;
3881
+ }
3882
+ const id = this.id.replace(/@|I/g, "");
3883
+ const given = this.toNaturalName()?.trim().split(/\s+/)[0] || id;
3884
+ return `https://www.geni.com/people/${given}/${id}`;
3885
+ }
4279
3886
  familySearchLink() {
4280
3887
  const wwwTags = this.get("WWW")?.toList();
4281
3888
  const wwwTag = wwwTags?.find((wwwTag2) => {
@@ -4556,12 +4163,15 @@ var Indi = class extends Common {
4556
4163
  );
4557
4164
  return void 0;
4558
4165
  }
4559
- link(poolId) {
4166
+ link(poolId, treeToken) {
4560
4167
  if (this?.isAncestry()) {
4561
4168
  return this.ancestryLink();
4562
4169
  }
4563
4170
  if (this?.isMyHeritage()) {
4564
- return this.myheritageLink(poolId);
4171
+ return this.myheritageLink(poolId, treeToken);
4172
+ }
4173
+ if (this?.isGeni()) {
4174
+ return this.geniLink();
4565
4175
  }
4566
4176
  if (this?.isFamilySearch()) {
4567
4177
  return this.familySearchLink();
@@ -6321,11 +5931,28 @@ var KinshipTranslatorBasic = class {
6321
5931
  // src/kinship-translator/patterns.hu.ts
6322
5932
  var parentRelationsHu = {
6323
5933
  step: "mostoha",
6324
- foster: "nevelt",
5934
+ foster: { ancestor: "nevel\u0151", other: "nevelt" },
6325
5935
  birth: "v\xE9rszerinti",
6326
5936
  biological: "v\xE9rszerinti",
6327
- adopted: "\xF6r\xF6kbefogadott"
5937
+ adopted: { ancestor: "\xF6r\xF6kbefogad\xF3", other: "\xF6r\xF6kbefogadott" }
5938
+ };
5939
+ var parentRelationPrefix = (relation, ancestor) => {
5940
+ const label = parentRelationsHu[relation];
5941
+ if (!label) {
5942
+ return;
5943
+ }
5944
+ if (typeof label === "string") {
5945
+ return label;
5946
+ }
5947
+ return ancestor ? label.ancestor : label.other;
6328
5948
  };
5949
+ var parentRelationModifiers = [
5950
+ ...new Set(
5951
+ Object.values(parentRelationsHu).flatMap(
5952
+ (label) => typeof label === "string" ? [label] : [label.ancestor, label.other]
5953
+ )
5954
+ )
5955
+ ].join("|");
6329
5956
  var nominativus = {
6330
5957
  apa: { nominativus: "apa", dativus: "apj\xE1nak", possessivus: "apja" },
6331
5958
  anya: { nominativus: "anya", dativus: "anyj\xE1nak", possessivus: "anyja" },
@@ -6403,15 +6030,9 @@ var casesHu = {
6403
6030
  var InLawsHu = {
6404
6031
  "gyermek feles\xE9ge": "meny",
6405
6032
  "gyermek f\xE9rje": "v\u0151",
6406
- [`(f\xE9rj|feles\xE9g) (?<mod1>(${Object.values(parentRelationsHu).join(
6407
- "|"
6408
- )}) )?anyja`]: "any\xF3s",
6409
- [`(f\xE9rj|feles\xE9g) (?<mod1>(${Object.values(parentRelationsHu).join(
6410
- "|"
6411
- )}) )?apja`]: "ap\xF3s",
6412
- [`(f\xE9rj|feles\xE9g) (?<mod1>(${Object.values(parentRelationsHu).join(
6413
- "|"
6414
- )}) )?(f\xE9l)?testv\xE9re`]: (indi) => {
6033
+ [`(f\xE9rj|feles\xE9g) (?<mod1>(${parentRelationModifiers}) )?anyja`]: "any\xF3s",
6034
+ [`(f\xE9rj|feles\xE9g) (?<mod1>(${parentRelationModifiers}) )?apja`]: "ap\xF3s",
6035
+ [`(f\xE9rj|feles\xE9g) (?<mod1>(${parentRelationModifiers}) )?(f\xE9l)?testv\xE9re`]: (indi) => {
6415
6036
  if (indi?.isMale()) {
6416
6037
  return "s\xF3gor";
6417
6038
  }
@@ -6688,7 +6309,12 @@ var KinshipTranslatorHU = class extends KinshipTranslatorBasic {
6688
6309
  if (!relation || !this.pathN?.relation) {
6689
6310
  return relation ?? "";
6690
6311
  }
6691
- return `${parentRelationsHu[this.pathN.relation]} ${relation}`;
6312
+ const isAncestor = (this.pathN.level ?? 0) > 0 && (this.pathN.degree ?? 0) === 0;
6313
+ const prefix = parentRelationPrefix(this.pathN.relation, isAncestor);
6314
+ if (!prefix) {
6315
+ return relation;
6316
+ }
6317
+ return `${prefix} ${relation}`;
6692
6318
  }
6693
6319
  };
6694
6320
 
@@ -6888,6 +6514,10 @@ var KinshipTranslatorEn = class extends KinshipTranslatorBasic {
6888
6514
  if (!relation || !this.pathN?.relation) {
6889
6515
  return relation ?? "";
6890
6516
  }
6517
+ if (this.pathN.relation === "adopted") {
6518
+ const isAncestor = (this.pathN.level ?? 0) > 0 && (this.pathN.degree ?? 0) === 0;
6519
+ return `${isAncestor ? "adoptive" : "adopted"} ${relation}`;
6520
+ }
6891
6521
  return `${this.pathN.relation} ${relation}`;
6892
6522
  }
6893
6523
  };
@@ -8046,6 +7676,39 @@ var lineal = (level, sex, kind) => {
8046
7676
  }
8047
7677
  return `${L - 1}\u4E16\u306E\u5B6B`;
8048
7678
  };
7679
+ var adoptedRelation = (relation) => {
7680
+ if (relation === "\u7236") {
7681
+ return "\u990A\u7236";
7682
+ }
7683
+ if (relation === "\u6BCD") {
7684
+ return "\u990A\u6BCD";
7685
+ }
7686
+ if (relation === "\u89AA") {
7687
+ return "\u990A\u89AA";
7688
+ }
7689
+ if (relation === "\u606F\u5B50" || relation === "\u5B50") {
7690
+ return "\u990A\u5B50";
7691
+ }
7692
+ if (relation === "\u5A18") {
7693
+ return "\u990A\u5973";
7694
+ }
7695
+ return `\u990A${relation}`;
7696
+ };
7697
+ var fosterRelation = (relation) => {
7698
+ if (relation === "\u7236") {
7699
+ return "\u91CC\u7236";
7700
+ }
7701
+ if (relation === "\u6BCD") {
7702
+ return "\u91CC\u6BCD";
7703
+ }
7704
+ if (relation === "\u89AA") {
7705
+ return "\u91CC\u89AA";
7706
+ }
7707
+ if (relation === "\u606F\u5B50" || relation === "\u5A18" || relation === "\u5B50") {
7708
+ return "\u91CC\u5B50";
7709
+ }
7710
+ return `\u91CC${relation}`;
7711
+ };
8049
7712
  var cousinPlain = (degree) => {
8050
7713
  if (degree <= 1) {
8051
7714
  return "\u3044\u3068\u3053";
@@ -8205,10 +7868,10 @@ var KinshipTranslatorJa = class extends KinshipTranslatorBasic {
8205
7868
  return `\u7D99${relation}`;
8206
7869
  }
8207
7870
  if (this.pathN.relation === "adopted") {
8208
- return `\u990A\u5B50\u306E${relation}`;
7871
+ return adoptedRelation(relation);
8209
7872
  }
8210
7873
  if (this.pathN.relation === "foster") {
8211
- return `\u91CC\u89AA\u306E${relation}`;
7874
+ return fosterRelation(relation);
8212
7875
  }
8213
7876
  return relation;
8214
7877
  }
@@ -9051,209 +8714,643 @@ var CommonDate = class extends Common {
9051
8714
  if (!formatted) {
9052
8715
  return formatted;
9053
8716
  }
9054
- const note = this.NOTE?.value?.trim();
9055
- const qualifier = note ? EXPORT_QUALIFIERS[note] : void 0;
9056
- const standardized = qualifier ? formatted.replace(note, qualifier) : formatted;
9057
- const withMonths = standardized.replace(
9058
- GEDCOM_MONTHS,
9059
- (month) => month.toUpperCase()
9060
- );
9061
- if (this._calendar && this._calendar !== "GREGORIAN") {
9062
- return `${this._calendar} ${withMonths}`;
8717
+ const note = this.NOTE?.value?.trim();
8718
+ const qualifier = note ? EXPORT_QUALIFIERS[note] : void 0;
8719
+ const standardized = qualifier ? formatted.replace(note, qualifier) : formatted;
8720
+ const withMonths = standardized.replace(
8721
+ GEDCOM_MONTHS,
8722
+ (month) => month.toUpperCase()
8723
+ );
8724
+ if (this._calendar && this._calendar !== "GREGORIAN") {
8725
+ return `${this._calendar} ${withMonths}`;
8726
+ }
8727
+ return withMonths;
8728
+ }
8729
+ toGedcomLines(tag, level = 0, options) {
8730
+ const internal = new RegExp(
8731
+ `^${level} (DAY|MONTH|YEAR)( |$)|^${level} NOTE (Abt\\.|Bef\\.|Aft\\.)$`
8732
+ );
8733
+ return super.toGedcomLines(tag, level, options).filter((line) => !internal.test(line));
8734
+ }
8735
+ inRange(range, trueIfNoYear = false) {
8736
+ return inRange(this.YEAR?.value, range, trueIfNoYear);
8737
+ }
8738
+ };
8739
+ var createCommonDate = (gedcom, id, main, parent) => {
8740
+ return createProxy(
8741
+ new CommonDate(gedcom, id, main, parent)
8742
+ );
8743
+ };
8744
+ var isCommonDate = (value) => {
8745
+ return !!value && value !== null && typeof value === "object" && "_date" in value;
8746
+ };
8747
+
8748
+ // src/utils/family-edit.ts
8749
+ var GEDCOM_MONTHS2 = [
8750
+ "JAN",
8751
+ "FEB",
8752
+ "MAR",
8753
+ "APR",
8754
+ "MAY",
8755
+ "JUN",
8756
+ "JUL",
8757
+ "AUG",
8758
+ "SEP",
8759
+ "OCT",
8760
+ "NOV",
8761
+ "DEC"
8762
+ ];
8763
+ var CREATED_AT_TAG = "_CREATED_AT";
8764
+ var stampCreatedAt = (gedcom, indi, when = /* @__PURE__ */ new Date()) => {
8765
+ const existing = indi.get(CREATED_AT_TAG);
8766
+ if (isCommonDate(existing) && existing.rawValue instanceof Date && !Number.isNaN(existing.rawValue.getTime())) {
8767
+ return;
8768
+ }
8769
+ const dateNode = createCommonDate(gedcom, void 0, indi, indi);
8770
+ dateNode.type = CREATED_AT_TAG;
8771
+ dateNode.value = `${when.getDate()} ${GEDCOM_MONTHS2[when.getMonth()]} ${when.getFullYear()}`;
8772
+ indi.set(CREATED_AT_TAG, dateNode);
8773
+ };
8774
+ var refTypeForTag = (tag) => {
8775
+ if (tag === "FAMS" || tag === "FAMC") return "FAM";
8776
+ return "INDI";
8777
+ };
8778
+ var normalizeSinglePointer = (owner, tag) => {
8779
+ const node = owner.get(tag);
8780
+ if (!node) return;
8781
+ if (node instanceof List && node.length === 1) {
8782
+ const only = node.index(0);
8783
+ if (only) {
8784
+ owner.set(tag, only);
8785
+ return;
8786
+ }
8787
+ const raw = node.values()[0];
8788
+ if (typeof raw === "string") {
8789
+ const gedcom = owner.getGedcom?.();
8790
+ if (gedcom) {
8791
+ owner.set(tag, makePointer(gedcom, owner, raw, refTypeForTag(tag)));
8792
+ }
8793
+ }
8794
+ }
8795
+ };
8796
+ var PEDIGREE_VALUES = [
8797
+ "birth" /* BIRTH */,
8798
+ "adopted" /* ADOPTED */,
8799
+ "foster" /* FOSTER */,
8800
+ "step" /* STEP */,
8801
+ "sealing" /* SEALING */
8802
+ ];
8803
+ var toGedcomPedigree = (value) => {
8804
+ const normalized = String(value || "birth" /* BIRTH */).toLowerCase();
8805
+ if (normalized === "biological" /* BIOLOGICAL */ || normalized === "birth" /* BIRTH */) {
8806
+ return "birth" /* BIRTH */;
8807
+ }
8808
+ const match = PEDIGREE_VALUES.find((item) => item === normalized);
8809
+ return match ?? "birth" /* BIRTH */;
8810
+ };
8811
+ var pointerIds = (tag) => {
8812
+ if (!tag) {
8813
+ return [];
8814
+ }
8815
+ if (tag instanceof List) {
8816
+ return tag.values().map((item) => item?.toValue?.()).filter((value2) => !!value2);
8817
+ }
8818
+ const value = tag.toValue?.();
8819
+ return value ? [String(value)] : [];
8820
+ };
8821
+ var firstPointerId = (tag) => pointerIds(tag)[0];
8822
+ var makePointer = (gedcom, parent, value, refType) => {
8823
+ const pointer = createCommon(gedcom, void 0, parent);
8824
+ pointer.value = value;
8825
+ pointer.refType = refType;
8826
+ return pointer;
8827
+ };
8828
+ var nextRecordId = (ids, prefix) => {
8829
+ let max = 0;
8830
+ ids.forEach((id) => {
8831
+ const match = String(id).match(/(\d+)/);
8832
+ const n = match ? Number.parseInt(match[1], 10) : 0;
8833
+ if (n > max) {
8834
+ max = n;
8835
+ }
8836
+ });
8837
+ return `@${prefix}${max + 1}@`;
8838
+ };
8839
+ var familyHasParent = (fam, indiId) => pointerIds(fam.get("HUSB")).includes(indiId) || pointerIds(fam.get("WIFE")).includes(indiId);
8840
+ var familyHasChild = (fam, indiId) => pointerIds(fam.get("CHIL")).includes(indiId);
8841
+ var spouseTagFor = (indi, fam) => {
8842
+ const husbId = firstPointerId(fam.get("HUSB"));
8843
+ const wifeId = firstPointerId(fam.get("WIFE"));
8844
+ if (husbId === indi.id) {
8845
+ return "HUSB";
8846
+ }
8847
+ if (wifeId === indi.id) {
8848
+ return "WIFE";
8849
+ }
8850
+ if (indi.isFemale()) {
8851
+ return wifeId && wifeId !== indi.id ? "HUSB" : "WIFE";
8852
+ }
8853
+ if (indi.isMale()) {
8854
+ return husbId && husbId !== indi.id ? "WIFE" : "HUSB";
8855
+ }
8856
+ return husbId ? "WIFE" : "HUSB";
8857
+ };
8858
+ var canAttachAsSpouse = (fam, indi) => {
8859
+ if (!indi.id) {
8860
+ return false;
8861
+ }
8862
+ if (familyHasParent(fam, indi.id)) {
8863
+ return true;
8864
+ }
8865
+ const tag = spouseTagFor(indi, fam);
8866
+ const occupied = firstPointerId(fam.get(tag));
8867
+ return !occupied || occupied === indi.id;
8868
+ };
8869
+ var pointerByValue = (tag, id) => {
8870
+ if (!tag) {
8871
+ return void 0;
8872
+ }
8873
+ const fromValues = tag.toValueList?.().item(id);
8874
+ if (fromValues) {
8875
+ return fromValues;
8876
+ }
8877
+ return tag.toList()?.values().find((item) => item?.toValue?.() === id);
8878
+ };
8879
+ var setChildPedigree = (fam, child, pedigree, parent) => {
8880
+ if (!fam.id || !child.id) {
8881
+ return;
8882
+ }
8883
+ const pedi = toGedcomPedigree(pedigree);
8884
+ const famc = pointerByValue(child.get("FAMC"), fam.id);
8885
+ if (famc) {
8886
+ famc.set("PEDI", pedi);
8887
+ }
8888
+ const chil = pointerByValue(fam.get("CHIL"), child.id);
8889
+ if (!chil) {
8890
+ return;
8891
+ }
8892
+ const setFather = !parent || parent.isMale() || parent.isUnknownSex();
8893
+ const setMother = !parent || parent.isFemale() || parent.isUnknownSex();
8894
+ if (setFather) {
8895
+ chil.set("_FREL", pedi);
8896
+ }
8897
+ if (setMother) {
8898
+ chil.set("_MREL", pedi);
8899
+ }
8900
+ };
8901
+ var attachSpouseToFamily = (fam, indi) => {
8902
+ const gedcom = fam.getGedcom() ?? indi.getGedcom();
8903
+ if (!indi.id || !fam.id || !gedcom) {
8904
+ return false;
8905
+ }
8906
+ if (!canAttachAsSpouse(fam, indi)) {
8907
+ return false;
8908
+ }
8909
+ const tag = spouseTagFor(indi, fam);
8910
+ if (firstPointerId(fam.get(tag)) !== indi.id) {
8911
+ fam.set(tag, makePointer(gedcom, fam, indi.id, "INDI"));
8912
+ }
8913
+ indi.assign("FAMS", makePointer(gedcom, indi, fam.id, "FAM"), true);
8914
+ normalizeSinglePointer(indi, "FAMS");
8915
+ normalizeSinglePointer(fam, spouseTagFor(indi, fam));
8916
+ resetRelativesCache();
8917
+ return true;
8918
+ };
8919
+ var attachChildToFamily = (fam, child, pedigree, parent) => {
8920
+ const gedcom = fam.getGedcom() ?? child.getGedcom();
8921
+ if (!child.id || !fam.id || !gedcom) {
8922
+ return false;
8923
+ }
8924
+ if (!familyHasChild(fam, child.id)) {
8925
+ fam.assign("CHIL", makePointer(gedcom, fam, child.id, "INDI"), true);
8926
+ }
8927
+ const existingFamc = pointerByValue(child.get("FAMC"), fam.id);
8928
+ if (!existingFamc) {
8929
+ child.assign("FAMC", makePointer(gedcom, child, fam.id, "FAM"), true);
8930
+ }
8931
+ setChildPedigree(fam, child, pedigree, parent);
8932
+ normalizeSinglePointer(child, "FAMC");
8933
+ normalizeSinglePointer(fam, "CHIL");
8934
+ resetRelativesCache();
8935
+ return true;
8936
+ };
8937
+ var removePointerByValue = (owner, tag, targetId) => {
8938
+ const node = owner.get(tag);
8939
+ if (!node) {
8940
+ return false;
8941
+ }
8942
+ if (node instanceof List) {
8943
+ const keysToRemove = [];
8944
+ node.entries().forEach(([key, item]) => {
8945
+ if (item?.toValue?.() === targetId || item?.id === targetId || String(key) === targetId) {
8946
+ keysToRemove.push(key);
8947
+ }
8948
+ });
8949
+ keysToRemove.forEach((key) => {
8950
+ node.removeItem(key);
8951
+ });
8952
+ if (node.length === 0) {
8953
+ owner.remove(tag);
8954
+ }
8955
+ return keysToRemove.length > 0;
8956
+ }
8957
+ if (node.toValue?.() === targetId) {
8958
+ owner.remove(tag);
8959
+ return true;
8960
+ }
8961
+ const asList = node.toList?.();
8962
+ if (asList && asList.length > 0) {
8963
+ const keysToRemove = [];
8964
+ asList.entries().forEach(([key, item]) => {
8965
+ if (item?.toValue?.() === targetId || item?.id === targetId) {
8966
+ keysToRemove.push(key);
8967
+ }
8968
+ });
8969
+ if (keysToRemove.length === asList.length) {
8970
+ owner.remove(tag);
8971
+ return true;
8972
+ }
8973
+ if (keysToRemove.length > 0) {
8974
+ const remaining = asList.values().filter((item) => item?.toValue?.() !== targetId);
8975
+ if (remaining.length === 1 && remaining[0]) {
8976
+ owner.set(tag, remaining[0]);
8977
+ } else {
8978
+ owner.set(tag, new List(remaining));
8979
+ }
8980
+ return true;
9063
8981
  }
9064
- return withMonths;
9065
8982
  }
9066
- toGedcomLines(tag, level = 0, options) {
9067
- const internal = new RegExp(
9068
- `^${level} (DAY|MONTH|YEAR)( |$)|^${level} NOTE (Abt\\.|Bef\\.|Aft\\.)$`
9069
- );
9070
- return super.toGedcomLines(tag, level, options).filter((line) => !internal.test(line));
8983
+ return false;
8984
+ };
8985
+ var familyMemberCount = (fam) => {
8986
+ let count = 0;
8987
+ if (firstPointerId(fam.get("HUSB"))) {
8988
+ count += 1;
9071
8989
  }
9072
- inRange(range, trueIfNoYear = false) {
9073
- return inRange(this.YEAR?.value, range, trueIfNoYear);
8990
+ if (firstPointerId(fam.get("WIFE"))) {
8991
+ count += 1;
9074
8992
  }
8993
+ count += pointerIds(fam.get("CHIL")).length;
8994
+ return count;
9075
8995
  };
9076
- var createCommonDate = (gedcom, id, main, parent) => {
9077
- return createProxy(
9078
- new CommonDate(gedcom, id, main, parent)
9079
- );
8996
+ var isDegenerateFamily = (fam) => familyMemberCount(fam) <= 1;
8997
+ var pruneEmptyFamilies = (gedcom) => {
8998
+ const emptyIds = [];
8999
+ gedcom.fams()?.forEach((fam, id) => {
9000
+ if (fam && isDegenerateFamily(fam) && id) {
9001
+ emptyIds.push(id);
9002
+ }
9003
+ });
9004
+ if (emptyIds.length === 0) {
9005
+ return [];
9006
+ }
9007
+ gedcom.indis()?.forEach((indi) => {
9008
+ if (!indi) {
9009
+ return;
9010
+ }
9011
+ emptyIds.forEach((famId) => {
9012
+ removePointerByValue(indi, "FAMS", famId);
9013
+ removePointerByValue(indi, "FAMC", famId);
9014
+ });
9015
+ });
9016
+ emptyIds.forEach((famId) => {
9017
+ gedcom.fams()?.removeItem(famId);
9018
+ });
9019
+ return emptyIds;
9080
9020
  };
9081
- var isCommonDate = (value) => {
9082
- return !!value && value !== null && typeof value === "object" && "_date" in value;
9021
+ var findDegenerateFamiliesForIndi = (indi) => {
9022
+ const found = [];
9023
+ const seen = /* @__PURE__ */ new Set();
9024
+ ["FAMC", "FAMS"].forEach((pointer) => {
9025
+ indi.getFamilies(pointer)?.forEach((fam) => {
9026
+ if (!fam?.id || seen.has(fam.id) || !isDegenerateFamily(fam)) {
9027
+ return;
9028
+ }
9029
+ seen.add(fam.id);
9030
+ found.push(fam);
9031
+ });
9032
+ });
9033
+ return found;
9083
9034
  };
9084
-
9085
- // src/utils/fact-edit.ts
9086
- var SINGLETON_TAGS = /* @__PURE__ */ new Set(["BIRT", "DEAT", "SSN", "SEX", "DSCR"]);
9087
- var firstRecord = (node) => {
9088
- if (!node) {
9035
+ var coupleKeyForFam = (fam) => {
9036
+ const husb = firstPointerId(fam.get("HUSB"));
9037
+ const wife = firstPointerId(fam.get("WIFE"));
9038
+ if (!husb || !wife) {
9089
9039
  return void 0;
9090
9040
  }
9091
- if (node instanceof List) {
9092
- return node.index(0);
9093
- }
9094
- return node.index(0) ?? node;
9041
+ return husb < wife ? `${husb}|${wife}` : `${wife}|${husb}`;
9095
9042
  };
9096
- var setDateOn = (gedcom, owner, parent, date) => {
9097
- const trimmed = date.trim();
9098
- if (!trimmed) {
9099
- return;
9043
+ var findDuplicateCoupleFamiliesForIndi = (indi) => {
9044
+ const gedcom = indi.getGedcom();
9045
+ if (!gedcom) {
9046
+ return [];
9100
9047
  }
9101
- let dateNode = parent.get("DATE");
9102
- if (!dateNode || dateNode instanceof List) {
9103
- dateNode = createCommonDate(gedcom, void 0, owner, parent);
9104
- dateNode.type = "DATE";
9105
- parent.set("DATE", dateNode);
9048
+ const relevantKeys = /* @__PURE__ */ new Set();
9049
+ ["FAMC", "FAMS"].forEach((pointer) => {
9050
+ indi.getFamilies(pointer)?.forEach((fam) => {
9051
+ const key = fam ? coupleKeyForFam(fam) : void 0;
9052
+ if (key) {
9053
+ relevantKeys.add(key);
9054
+ }
9055
+ });
9056
+ });
9057
+ if (relevantKeys.size === 0) {
9058
+ return [];
9106
9059
  }
9107
- dateNode.value = trimmed;
9060
+ const byKey = /* @__PURE__ */ new Map();
9061
+ gedcom.fams()?.forEach((fam) => {
9062
+ if (!fam?.id) {
9063
+ return;
9064
+ }
9065
+ const key = coupleKeyForFam(fam);
9066
+ if (!key || !relevantKeys.has(key)) {
9067
+ return;
9068
+ }
9069
+ const list = byKey.get(key) ?? [];
9070
+ list.push(fam);
9071
+ byKey.set(key, list);
9072
+ });
9073
+ return [...byKey.entries()].filter(([, families]) => families.length > 1).map(([key, families]) => ({ key, families }));
9108
9074
  };
9109
- var fillFact = (gedcom, owner, event, input) => {
9110
- if (input.value?.trim()) {
9111
- event.value = input.value.trim();
9075
+ var mergeDuplicateCoupleFamilies = (gedcom, families) => {
9076
+ const usable = families.filter((fam) => !!fam?.id);
9077
+ if (usable.length === 0) {
9078
+ return void 0;
9112
9079
  }
9113
- if (input.type?.trim()) {
9114
- event.set("TYPE", input.type.trim());
9080
+ if (usable.length === 1) {
9081
+ return usable[0];
9115
9082
  }
9116
- if (input.date) {
9117
- setDateOn(gedcom, owner, event, input.date);
9083
+ const sorted = [...usable].sort((a, b) => {
9084
+ const childDiff = pointerIds(b.get("CHIL")).length - pointerIds(a.get("CHIL")).length;
9085
+ if (childDiff !== 0) {
9086
+ return childDiff;
9087
+ }
9088
+ return String(a.id).localeCompare(String(b.id));
9089
+ });
9090
+ const keep = sorted[0];
9091
+ const drops = sorted.slice(1);
9092
+ if (!keep?.id) {
9093
+ return void 0;
9118
9094
  }
9119
- if (input.place?.trim()) {
9120
- event.set("PLAC", input.place.trim());
9095
+ drops.forEach((drop) => {
9096
+ if (!drop?.id || drop.id === keep.id) {
9097
+ return;
9098
+ }
9099
+ pointerIds(drop.get("CHIL")).forEach((childId) => {
9100
+ const child = gedcom.indi(childId);
9101
+ if (!child) {
9102
+ return;
9103
+ }
9104
+ attachChildToFamily(keep, child);
9105
+ removePointerByValue(drop, "CHIL", childId);
9106
+ normalizeSinglePointer(drop, "CHIL");
9107
+ removePointerByValue(child, "FAMC", drop.id);
9108
+ normalizeSinglePointer(child, "FAMC");
9109
+ });
9110
+ const husbId = firstPointerId(drop.get("HUSB"));
9111
+ const wifeId = firstPointerId(drop.get("WIFE"));
9112
+ [husbId, wifeId].forEach((parentId) => {
9113
+ if (!parentId) {
9114
+ return;
9115
+ }
9116
+ const parent = gedcom.indi(parentId);
9117
+ if (parent) {
9118
+ removePointerByValue(parent, "FAMS", drop.id);
9119
+ normalizeSinglePointer(parent, "FAMS");
9120
+ }
9121
+ });
9122
+ gedcom.fams()?.removeItem(drop.id);
9123
+ });
9124
+ resetRelativesCache();
9125
+ return keep;
9126
+ };
9127
+ var pruneFamiliesByIds = (gedcom, famIds) => {
9128
+ const unique = [...new Set(famIds.filter(Boolean))];
9129
+ if (unique.length === 0) {
9130
+ return 0;
9131
+ }
9132
+ gedcom.indis()?.forEach((indi) => {
9133
+ if (!indi) {
9134
+ return;
9135
+ }
9136
+ unique.forEach((famId) => {
9137
+ removePointerByValue(indi, "FAMS", famId);
9138
+ removePointerByValue(indi, "FAMC", famId);
9139
+ });
9140
+ });
9141
+ unique.forEach((famId) => {
9142
+ gedcom.fams()?.removeItem(famId);
9143
+ });
9144
+ return unique.length;
9145
+ };
9146
+ var findSharedSpouseFamily = (parent, coParentId) => {
9147
+ let found;
9148
+ parent.getFamilies("FAMS")?.forEach((fam) => {
9149
+ if (!found && fam && familyHasParent(fam, coParentId)) {
9150
+ found = fam;
9151
+ }
9152
+ });
9153
+ return found;
9154
+ };
9155
+ var unlinkRelative = (anchor, relative, kind) => {
9156
+ if (!anchor.id || !relative.id || anchor.id === relative.id) {
9157
+ return false;
9158
+ }
9159
+ let changed = false;
9160
+ if (kind === "spouse") {
9161
+ anchor.getFamilies("FAMS")?.forEach((fam) => {
9162
+ if (!fam?.id || !familyHasParent(fam, relative.id)) {
9163
+ return;
9164
+ }
9165
+ if (firstPointerId(fam.get("HUSB")) === relative.id) {
9166
+ fam.remove("HUSB");
9167
+ changed = true;
9168
+ }
9169
+ if (firstPointerId(fam.get("WIFE")) === relative.id) {
9170
+ fam.remove("WIFE");
9171
+ changed = true;
9172
+ }
9173
+ changed = removePointerByValue(relative, "FAMS", fam.id) || changed;
9174
+ });
9175
+ } else if (kind === "parent") {
9176
+ anchor.getFamilies("FAMC")?.forEach((fam) => {
9177
+ if (!fam?.id || !familyHasParent(fam, relative.id)) {
9178
+ return;
9179
+ }
9180
+ if (firstPointerId(fam.get("HUSB")) === relative.id) {
9181
+ fam.remove("HUSB");
9182
+ changed = true;
9183
+ }
9184
+ if (firstPointerId(fam.get("WIFE")) === relative.id) {
9185
+ fam.remove("WIFE");
9186
+ changed = true;
9187
+ }
9188
+ changed = removePointerByValue(relative, "FAMS", fam.id) || changed;
9189
+ });
9190
+ } else if (kind === "sibling") {
9191
+ anchor.getFamilies("FAMC")?.forEach((fam) => {
9192
+ if (!fam?.id || !familyHasChild(fam, relative.id)) {
9193
+ return;
9194
+ }
9195
+ changed = removePointerByValue(fam, "CHIL", relative.id) || changed;
9196
+ changed = removePointerByValue(relative, "FAMC", fam.id) || changed;
9197
+ });
9198
+ } else {
9199
+ anchor.getFamilies("FAMS")?.forEach((fam) => {
9200
+ if (!fam?.id || !familyHasChild(fam, relative.id)) {
9201
+ return;
9202
+ }
9203
+ changed = removePointerByValue(fam, "CHIL", relative.id) || changed;
9204
+ changed = removePointerByValue(relative, "FAMC", fam.id) || changed;
9205
+ });
9121
9206
  }
9122
- if (input.note?.trim()) {
9123
- event.set("NOTE", input.note.trim());
9207
+ if (changed) {
9208
+ const gedcom = anchor.getGedcom() ?? relative.getGedcom();
9209
+ if (gedcom) {
9210
+ pruneEmptyFamilies(gedcom);
9211
+ }
9212
+ resetRelativesCache();
9124
9213
  }
9214
+ return changed;
9125
9215
  };
9126
- var updateFactRecord = (owner, event, input) => {
9127
- const gedcom = owner.getGedcom();
9128
- if (!gedcom) {
9129
- return event;
9216
+ var deleteIndividual = (gedcom, indiId) => {
9217
+ const indi = gedcom.indi(indiId);
9218
+ if (!indi?.id) {
9219
+ return false;
9130
9220
  }
9131
- const asOwner = owner;
9132
- if (input.value !== void 0) {
9133
- const trimmed = input.value.trim();
9134
- if (trimmed) {
9135
- event.value = trimmed;
9136
- } else {
9137
- event.removeValue();
9221
+ const famsIds = pointerIds(indi.get("FAMS"));
9222
+ const famcIds = pointerIds(indi.get("FAMC"));
9223
+ famsIds.forEach((famId) => {
9224
+ const fam = gedcom.fam(famId);
9225
+ if (!fam) {
9226
+ return;
9138
9227
  }
9139
- }
9140
- if (input.type !== void 0) {
9141
- const trimmed = input.type.trim();
9142
- if (trimmed) {
9143
- event.set("TYPE", trimmed);
9144
- } else {
9145
- event.remove("TYPE");
9228
+ if (firstPointerId(fam.get("HUSB")) === indiId) {
9229
+ fam.remove("HUSB");
9146
9230
  }
9147
- }
9148
- if (input.date !== void 0) {
9149
- const trimmed = input.date.trim();
9150
- if (trimmed) {
9151
- setDateOn(gedcom, asOwner, event, trimmed);
9152
- } else {
9153
- event.remove("DATE");
9231
+ if (firstPointerId(fam.get("WIFE")) === indiId) {
9232
+ fam.remove("WIFE");
9154
9233
  }
9155
- }
9156
- if (input.place !== void 0) {
9157
- const trimmed = input.place.trim();
9158
- if (trimmed) {
9159
- event.set("PLAC", trimmed);
9160
- } else {
9161
- event.remove("PLAC");
9234
+ });
9235
+ famcIds.forEach((famId) => {
9236
+ const fam = gedcom.fam(famId);
9237
+ if (fam) {
9238
+ removePointerByValue(fam, "CHIL", indiId);
9162
9239
  }
9163
- }
9164
- if (input.note !== void 0) {
9165
- const trimmed = input.note.trim();
9166
- if (trimmed) {
9167
- event.set("NOTE", trimmed);
9168
- } else {
9169
- event.remove("NOTE");
9240
+ });
9241
+ gedcom.fams()?.forEach((fam) => {
9242
+ if (fam && familyHasChild(fam, indiId)) {
9243
+ removePointerByValue(fam, "CHIL", indiId);
9244
+ }
9245
+ if (fam && familyHasParent(fam, indiId)) {
9246
+ if (firstPointerId(fam.get("HUSB")) === indiId) {
9247
+ fam.remove("HUSB");
9248
+ }
9249
+ if (firstPointerId(fam.get("WIFE")) === indiId) {
9250
+ fam.remove("WIFE");
9251
+ }
9170
9252
  }
9171
- }
9172
- return event;
9173
- };
9174
- var setFamilyMarriage = (fam, input) => {
9175
- const existing = firstRecord(fam.get("MARR"));
9176
- if (existing) {
9177
- return updateFactRecord(fam, existing, {
9178
- date: input.date,
9179
- place: input.place
9180
- });
9181
- }
9182
- return addFamilyFact(fam, {
9183
- tag: "MARR",
9184
- date: input.date,
9185
- place: input.place
9186
9253
  });
9254
+ gedcom.indis()?.removeItem(indiId);
9255
+ pruneEmptyFamilies(gedcom);
9256
+ resetRelativesCache();
9257
+ return true;
9187
9258
  };
9188
- var addIndividualFact = (indi, input) => {
9189
- const gedcom = indi.getGedcom();
9190
- if (!gedcom) {
9259
+ var findReusableParentChildFamily = (parent, child, options) => {
9260
+ if (!parent.id || !child.id) {
9191
9261
  return void 0;
9192
9262
  }
9193
- const tag = input.tag;
9194
- let event = SINGLETON_TAGS.has(tag) ? firstRecord(indi.get(tag)) : void 0;
9195
- if (!event) {
9196
- event = createCommon(gedcom, void 0, indi);
9197
- event.type = tag;
9198
- if (SINGLETON_TAGS.has(tag)) {
9199
- indi.set(tag, event);
9200
- } else {
9201
- indi.assign(tag, event);
9263
+ const reuseParentFamilies = options?.reuseParentFamilies !== false;
9264
+ const gedcom = parent.getGedcom() ?? child.getGedcom();
9265
+ let reusableFamc;
9266
+ let coupleFam;
9267
+ let already = false;
9268
+ const noteCoupleWith = (coParentId) => {
9269
+ if (!coParentId || coParentId === parent.id || coupleFam || !parent.id) {
9270
+ return;
9271
+ }
9272
+ const shared = findSharedSpouseFamily(parent, coParentId);
9273
+ if (shared) {
9274
+ coupleFam = shared;
9275
+ }
9276
+ };
9277
+ child.getFamilies("FAMC")?.forEach((fam) => {
9278
+ if (!fam) {
9279
+ return;
9280
+ }
9281
+ if (familyHasParent(fam, parent.id) && familyHasChild(fam, child.id)) {
9282
+ already = true;
9283
+ return;
9202
9284
  }
9285
+ pointerIds(fam.get("HUSB")).forEach(noteCoupleWith);
9286
+ pointerIds(fam.get("WIFE")).forEach(noteCoupleWith);
9287
+ if (!reusableFamc && canAttachAsSpouse(fam, parent)) {
9288
+ reusableFamc = fam;
9289
+ }
9290
+ });
9291
+ if (already) {
9292
+ return "already";
9203
9293
  }
9204
- fillFact(gedcom, indi, event, input);
9205
- return event;
9206
- };
9207
- var addFamilyFact = (fam, input) => {
9208
- const gedcom = fam.getGedcom();
9209
- if (!gedcom) {
9210
- return void 0;
9294
+ if (coupleFam) {
9295
+ return coupleFam;
9211
9296
  }
9212
- const event = createCommon(gedcom, void 0, fam);
9213
- event.type = input.tag;
9214
- fam.assign(input.tag, event);
9215
- fillFact(gedcom, fam, event, input);
9216
- return event;
9217
- };
9218
- var setCauseOfDeath = (indi, text) => {
9219
- const trimmed = text.trim();
9220
- if (!trimmed) {
9221
- return void 0;
9297
+ if (reusableFamc) {
9298
+ return reusableFamc;
9222
9299
  }
9223
- const death = firstRecord(indi.get("DEAT")) || addIndividualFact(indi, { tag: "DEAT", value: "Y" });
9224
- if (!death) {
9225
- return void 0;
9300
+ if (options?.targetFamilyId && gedcom) {
9301
+ const target = gedcom.fam(options.targetFamilyId);
9302
+ if (target && (familyHasParent(target, parent.id) || canAttachAsSpouse(target, parent))) {
9303
+ return target;
9304
+ }
9226
9305
  }
9227
- death.set("CAUS", trimmed);
9228
- return death;
9229
- };
9230
- var setDeceased = (indi, deceased) => {
9231
- if (!deceased) {
9232
- indi.remove("DEAT");
9233
- return;
9306
+ if (!reuseParentFamilies) {
9307
+ return void 0;
9234
9308
  }
9235
- if (firstRecord(indi.get("DEAT"))) {
9236
- return;
9309
+ const parentFams = [];
9310
+ parent.getFamilies("FAMS")?.forEach((fam) => {
9311
+ if (fam) {
9312
+ parentFams.push(fam);
9313
+ }
9314
+ });
9315
+ if (parentFams.length === 1) {
9316
+ return parentFams[0];
9237
9317
  }
9238
- addIndividualFact(indi, { tag: "DEAT", value: "Y" });
9318
+ return void 0;
9239
9319
  };
9240
- var addNonEvent = (owner, input) => {
9241
- const gedcom = owner.getGedcom();
9242
- const eventType = input.event?.trim().toUpperCase();
9243
- if (!gedcom || !eventType) {
9244
- return void 0;
9320
+ var consolidateChildIntoFamily = (child, keep) => {
9321
+ if (!child.id || !keep.id) {
9322
+ return [];
9245
9323
  }
9246
- const no = createCommon(gedcom, void 0, owner);
9247
- no.type = "NO";
9248
- no.value = eventType;
9249
- if (input.date?.trim()) {
9250
- setDateOn(gedcom, owner, no, input.date);
9324
+ const keepParentIds = /* @__PURE__ */ new Set([
9325
+ ...pointerIds(keep.get("HUSB")),
9326
+ ...pointerIds(keep.get("WIFE"))
9327
+ ]);
9328
+ const removed = [];
9329
+ child.getFamilies("FAMC")?.forEach((fam) => {
9330
+ if (!fam?.id || fam.id === keep.id) {
9331
+ return;
9332
+ }
9333
+ const famParentIds = [
9334
+ ...pointerIds(fam.get("HUSB")),
9335
+ ...pointerIds(fam.get("WIFE"))
9336
+ ];
9337
+ if (famParentIds.length === 0 || !famParentIds.every((id) => keepParentIds.has(id))) {
9338
+ return;
9339
+ }
9340
+ removePointerByValue(fam, "CHIL", child.id);
9341
+ normalizeSinglePointer(fam, "CHIL");
9342
+ removePointerByValue(child, "FAMC", fam.id);
9343
+ normalizeSinglePointer(child, "FAMC");
9344
+ removed.push(fam.id);
9345
+ });
9346
+ const gedcom = child.getGedcom() ?? keep.getGedcom();
9347
+ if (gedcom && removed.length > 0) {
9348
+ pruneEmptyFamilies(gedcom);
9251
9349
  }
9252
- if (input.note?.trim()) {
9253
- no.set("NOTE", input.note.trim());
9350
+ if (removed.length > 0) {
9351
+ resetRelativesCache();
9254
9352
  }
9255
- owner.assign("NO", no);
9256
- return no;
9353
+ return removed;
9257
9354
  };
9258
9355
 
9259
9356
  // src/classes/fam.ts
@@ -9502,7 +9599,8 @@ var extractGedzip = async (data) => {
9502
9599
  if (!preferred) {
9503
9600
  throw new Error("No .ged file found in the archive.");
9504
9601
  }
9505
- const gedcomText = await preferred.async("string");
9602
+ const gedcomBytes = await preferred.async("uint8array");
9603
+ const gedcomText = new TextDecoder("utf-8").decode(gedcomBytes);
9506
9604
  const mediaEntries = [];
9507
9605
  for (const entry of entries) {
9508
9606
  const path = normalizeZipPath(entry.name);
@@ -9827,7 +9925,7 @@ var createGedcomUid = () => {
9827
9925
  };
9828
9926
 
9829
9927
  // src/utils/gedcom7-metadata.ts
9830
- var GEDCOM_MONTHS2 = [
9928
+ var GEDCOM_MONTHS3 = [
9831
9929
  "JAN",
9832
9930
  "FEB",
9833
9931
  "MAR",
@@ -9843,7 +9941,7 @@ var GEDCOM_MONTHS2 = [
9843
9941
  ];
9844
9942
  var formatGedcom7Timestamp = (date = /* @__PURE__ */ new Date()) => {
9845
9943
  const day = String(date.getUTCDate());
9846
- const month = GEDCOM_MONTHS2[date.getUTCMonth()];
9944
+ const month = GEDCOM_MONTHS3[date.getUTCMonth()];
9847
9945
  const year = String(date.getUTCFullYear());
9848
9946
  const hh = String(date.getUTCHours()).padStart(2, "0");
9849
9947
  const mm = String(date.getUTCMinutes()).padStart(2, "0");
@@ -9921,6 +10019,7 @@ var TREEVIZ_EXTENSION_URIS = {
9921
10019
  _MTTAG: `${TREEVIZ_EXTENSION_BASE_URI}#_MTTAG`,
9922
10020
  _MTCAT: `${TREEVIZ_EXTENSION_BASE_URI}#_MTCAT`,
9923
10021
  _CLON: `${TREEVIZ_EXTENSION_BASE_URI}#_CLON`,
10022
+ _CREATED_AT: `${TREEVIZ_EXTENSION_BASE_URI}#_CREATED_AT`,
9924
10023
  _MSER: `${TREEVIZ_EXTENSION_BASE_URI}#_MSER`,
9925
10024
  _OID: `${TREEVIZ_EXTENSION_BASE_URI}#_OID`,
9926
10025
  _LKID: `${TREEVIZ_EXTENSION_BASE_URI}#_LKID`,
@@ -10076,7 +10175,7 @@ var collectExtensionTagsFrom = (node, into = /* @__PURE__ */ new Set()) => {
10076
10175
  // package.json
10077
10176
  var package_default = {
10078
10177
  name: "@treeviz/gedcom-parser",
10079
- version: "2.1.18"};
10178
+ version: "2.1.23"};
10080
10179
 
10081
10180
  // src/utils/get-product-details.ts
10082
10181
  var isDevelopment = () => {
@@ -11339,6 +11438,7 @@ var mergeGedcoms = (targetGedcom, sourceGedcom, strategy = "id") => {
11339
11438
  }
11340
11439
  } else {
11341
11440
  if (clonedIndi.id) {
11441
+ stampCreatedAt(mergedGedcom, clonedIndi);
11342
11442
  mergedGedcom.indis()?.item(clonedIndi.id, clonedIndi);
11343
11443
  }
11344
11444
  }
@@ -11463,7 +11563,7 @@ var create = (gedcom, type, id, nodes) => {
11463
11563
  prevNode = createSour(gedcom, void 0, mainNode, curNode);
11464
11564
  } else if (type === "OBJE") {
11465
11565
  prevNode = createObje(gedcom, void 0, mainNode, curNode);
11466
- } else if (type === "DATE") {
11566
+ } else if (type === "DATE" || type === "_CREATED_AT") {
11467
11567
  prevNode = createCommonDate(gedcom, void 0, mainNode, curNode);
11468
11568
  } else if (type === "NOTE" || type === "SNOTE" || type === "_TREEVIZ_LIFE_STORY" || type === "_TREEVIZ_FAMILY_STORY") {
11469
11569
  prevNode = createCommonNote(gedcom, void 0, mainNode, curNode);
@@ -11489,6 +11589,7 @@ var GedcomTree = {
11489
11589
  return this.parseHierarchy(content, options);
11490
11590
  },
11491
11591
  parseHierarchy: function(content, options) {
11592
+ content = content.replace(/^\uFEFF+/, "");
11492
11593
  const { settings, filename = "" } = options ?? {};
11493
11594
  const { linkedPersons = "skip", linkingKey } = settings ?? {};
11494
11595
  const gedcom = createGedCom();
@@ -11753,4 +11854,4 @@ var createEmptyGedcom = (options) => {
11753
11854
  return gedcom;
11754
11855
  };
11755
11856
 
11756
- export { ACCEPTED_DATE_FORMATS, ACCEPTED_DATE_FORMATS_REGEX, ADOPTED, ANCESTRY_MEDIA_RETRIEVAL_PREFIX, ANCESTRY_TREE_MEDIA_NAMESPACE, APP_BRANDING, BIOLOGICAL, BIRTH, BIRTH_ASC, BIRTH_DESC, Common, CommonDate, CommonName, CommonNote, CustomTags, DATE_ASC, DATE_DESC, DEATH_ASC, DEATH_DESC, DEFAULT, DEFAULT_GEDCOM_EXPORT_VERSION, EVERY, Existed, FEMALE, FOSTER, FRIEND, Fam, Families, GEDCOM7_CALENDARS, GEDCOM7_PEDI_VALUES, GEDCOM7_RESN_VALUES, GEDCOM7_ROLE_VALUES, GEDCOM7_SEX_VALUES, GEDCOM_EXPORT_VERSIONS, GEDZIP_EXTENSION, GEDZIP_GEDCOM_ENTRY, GEDZIP_MIME, GedCom, parser_default as GedcomTree, ID_GETTER_REG, ID_REG, ID_SPLIT_REG, Indi, Individuals, KinshipTranslator, KinshipTranslatorBasic, KinshipTranslatorDe as KinshipTranslatorDE, KinshipTranslatorEn as KinshipTranslatorEN, KinshipTranslatorEs as KinshipTranslatorES, KinshipTranslatorFr as KinshipTranslatorFR, KinshipTranslatorHU, KinshipTranslatorJa as KinshipTranslatorJA, KinshipTranslatorRu as KinshipTranslatorRU, KinshipTranslatorZh as KinshipTranslatorZH, LINE_REG, List, MALE, MAX_FILE_SIZE_TO_SYNC, ORIG_HEAD_TAG, OTHER, Obje, Objects, PARTNER, PEDIGREE_VALUES, PartnerType, PlaceType, REF_LINE_REG, Range, RelationType, Repo, Repositories, SEALING, SINGLE, SPOUSE, STEP, Sour, Sources, Subm, Submitters, TREEVIZ_EXTENSION_BASE_URI, TREEVIZ_EXTENSION_URIS, UNKOWN, addFamilyFact, addIndividualFact, addNonEvent, ancestryMediaFileUrl, applyGedcom7DatePhrases, applyGedcom7Enumerations, applyGedcom7RecordMetadata, attachChildToFamily, attachSpouseToFamily, buildGedzip, buildGedzipBlob, bytesToDataUrl, cacheDiscoveredPath, canAttachAsSpouse, collectExtensionTagsFrom, commonDateFormatter, consolidateChildIntoFamily, coupleKeyForFam, create, createCommon, createCommonDate, createCommonName, createCommonNote, createEmptyGedcom, createFam, createGedCom, createGedcomUid, createIndi, createObje, createProxy, createRepo, createSour, createSubm, dateFormatter, parser_default as default, deleteIndividual, downloadGedzipMedia, ensureExtensionSchema, extractGedzip, extractGedzipGedcom, extractSeparationYears, extractSplitPoints, familyHasChild, familyHasParent, findDegenerateFamiliesForIndi, findDuplicateCoupleFamiliesForIndi, findMatchingRangeForSplitRange, findReusableParentChildFamily, firstPointerId, formatGedcom7Timestamp, fromTuple, generateSplitRanges, getAllProp, getBirthAsc, getCacheManagerFactory, getDateLocale, getExtensionSchema, getFamilyWith, getFileExtension, getI18n, getKinshipTranslatorClass, getListTag, getMarriageAsc, getMarriageAscAndBirth, getMarriageAscAndChildBirth, getName, getNameAsc, getNameAscAndBirth, getNameDesc, getPlaceParserProvider, getPlaceParts, getPlaceTranslatorProvider, getPlaces, getRawSize, getValidKey, getValidKeys, getValidTag, getVersion, hungarianOrdinalize, i18n, idGetter, implemented, inRange, inferMediaForm, initializeCache, isAncestryOriginObje, isCommonDate, isDegenerateFamily, isDevelopment, isGedcom7, isGedcomString, isGedzipContainer, isId, isImageFormat, isIntersectedRange, isObjePointer, isOnlyMainProp, isRangeContained, isRemoteOrEmbeddedMediaUrl, isValidKey, makePointer, marriageDateFormatter, mergeDuplicateCoupleFamilies, mergeGedcoms, mergeMediaLists, mergeMediaListsByObjeKey, nameFormatter, nextRecordId, normalizeGedcomVersion, notImplemented, noteDateFormatter, objeNoteValue, objeXrefKey, ordinalize, parseAncestryNamespaceFromUrl, parseGedcom7CalendarPrefix, parseRangeBounds, pathCache, placeTranslator, pointerIds, profilePictureCache, pruneEmptyFamilies, pruneFamiliesByIds, registerExtensionTag, relativesCache, remountGedzipMediaAsDataUrls, removePointerByValue, resetCacheManagerFactory, resetDateLocaleProvider, resetI18nProvider, resetKinshipTranslatorClass, resetPlaceParserProvider, resetPlaceTranslatorProvider, resetRelativesCache, resolveLocalMediaUrl, resolveMediaContent, resolveObjeForm, resolveObjeMediaId, rewriteGedcomFilePaths, setCacheManagerFactory, setCauseOfDeath, setChildPedigree, setDateLocaleProvider, setDeceased, setFamilyMarriage, setI18nProvider, setKinshipTranslatorClass, setLocalMediaResolver, setMediaContentResolver, setNestedGroup, setPlaceParserProvider, setPlaceTranslatorProvider, splitOverlappingRanges, splitRange, spouseTagFor, toGedcomPedigree, translators_exports as translators, unlinkRelative, updateFactRecord, validateGedcomContent, withGedcom7Calendar };
11857
+ export { ACCEPTED_DATE_FORMATS, ACCEPTED_DATE_FORMATS_REGEX, ADOPTED, ANCESTRY_MEDIA_RETRIEVAL_PREFIX, ANCESTRY_TREE_MEDIA_NAMESPACE, APP_BRANDING, BIOLOGICAL, BIRTH, BIRTH_ASC, BIRTH_DESC, CREATED_AT_TAG, Common, CommonDate, CommonName, CommonNote, CustomTags, DATE_ASC, DATE_DESC, DEATH_ASC, DEATH_DESC, DEFAULT, DEFAULT_GEDCOM_EXPORT_VERSION, EVERY, Existed, FEMALE, FOSTER, FRIEND, Fam, Families, GEDCOM7_CALENDARS, GEDCOM7_PEDI_VALUES, GEDCOM7_RESN_VALUES, GEDCOM7_ROLE_VALUES, GEDCOM7_SEX_VALUES, GEDCOM_EXPORT_VERSIONS, GEDZIP_EXTENSION, GEDZIP_GEDCOM_ENTRY, GEDZIP_MIME, GedCom, parser_default as GedcomTree, ID_GETTER_REG, ID_REG, ID_SPLIT_REG, Indi, Individuals, KinshipTranslator, KinshipTranslatorBasic, KinshipTranslatorDe as KinshipTranslatorDE, KinshipTranslatorEn as KinshipTranslatorEN, KinshipTranslatorEs as KinshipTranslatorES, KinshipTranslatorFr as KinshipTranslatorFR, KinshipTranslatorHU, KinshipTranslatorJa as KinshipTranslatorJA, KinshipTranslatorRu as KinshipTranslatorRU, KinshipTranslatorZh as KinshipTranslatorZH, LINE_REG, List, MALE, MAX_FILE_SIZE_TO_SYNC, ORIG_HEAD_TAG, OTHER, Obje, Objects, PARTNER, PEDIGREE_VALUES, PartnerType, PlaceType, REF_LINE_REG, Range, RelationType, Repo, Repositories, SEALING, SINGLE, SPOUSE, STEP, Sour, Sources, Subm, Submitters, TREEVIZ_EXTENSION_BASE_URI, TREEVIZ_EXTENSION_URIS, UNKOWN, addFamilyFact, addIndividualFact, addNonEvent, ancestryMediaFileUrl, applyGedcom7DatePhrases, applyGedcom7Enumerations, applyGedcom7RecordMetadata, attachChildToFamily, attachSpouseToFamily, buildGedzip, buildGedzipBlob, bytesToDataUrl, cacheDiscoveredPath, canAttachAsSpouse, collectExtensionTagsFrom, commonDateFormatter, consolidateChildIntoFamily, coupleKeyForFam, create, createCommon, createCommonDate, createCommonName, createCommonNote, createEmptyGedcom, createFam, createGedCom, createGedcomUid, createIndi, createObje, createProxy, createRepo, createSour, createSubm, dateFormatter, parser_default as default, deleteIndividual, downloadGedzipMedia, ensureExtensionSchema, extractGedzip, extractGedzipGedcom, extractSeparationYears, extractSplitPoints, familyHasChild, familyHasParent, findDegenerateFamiliesForIndi, findDuplicateCoupleFamiliesForIndi, findMatchingRangeForSplitRange, findReusableParentChildFamily, firstPointerId, formatGedcom7Timestamp, fromTuple, generateSplitRanges, getAllProp, getBirthAsc, getCacheManagerFactory, getDateLocale, getExtensionSchema, getFamilyWith, getFileExtension, getI18n, getKinshipTranslatorClass, getListTag, getMarriageAsc, getMarriageAscAndBirth, getMarriageAscAndChildBirth, getName, getNameAsc, getNameAscAndBirth, getNameDesc, getPlaceParserProvider, getPlaceParts, getPlaceTranslatorProvider, getPlaces, getRawSize, getValidKey, getValidKeys, getValidTag, getVersion, hungarianOrdinalize, i18n, idGetter, implemented, inRange, inferMediaForm, initializeCache, isAncestryOriginObje, isCommonDate, isDegenerateFamily, isDevelopment, isGedcom7, isGedcomString, isGedzipContainer, isId, isImageFormat, isIntersectedRange, isObjePointer, isOnlyMainProp, isRangeContained, isRemoteOrEmbeddedMediaUrl, isValidKey, makePointer, marriageDateFormatter, mergeDuplicateCoupleFamilies, mergeGedcoms, mergeMediaLists, mergeMediaListsByObjeKey, nameFormatter, nextRecordId, normalizeGedcomVersion, notImplemented, noteDateFormatter, objeNoteValue, objeXrefKey, ordinalize, parseAncestryNamespaceFromUrl, parseGedcom7CalendarPrefix, parseRangeBounds, pathCache, placeTranslator, pointerIds, profilePictureCache, pruneEmptyFamilies, pruneFamiliesByIds, registerExtensionTag, relativesCache, remountGedzipMediaAsDataUrls, removePointerByValue, resetCacheManagerFactory, resetDateLocaleProvider, resetI18nProvider, resetKinshipTranslatorClass, resetPlaceParserProvider, resetPlaceTranslatorProvider, resetRelativesCache, resolveLocalMediaUrl, resolveMediaContent, resolveObjeForm, resolveObjeMediaId, rewriteGedcomFilePaths, setCacheManagerFactory, setCauseOfDeath, setChildPedigree, setDateLocaleProvider, setDeceased, setFamilyMarriage, setI18nProvider, setKinshipTranslatorClass, setLocalMediaResolver, setMediaContentResolver, setNestedGroup, setPlaceParserProvider, setPlaceTranslatorProvider, splitOverlappingRanges, splitRange, spouseTagFor, stampCreatedAt, toGedcomPedigree, translators_exports as translators, unlinkRelative, updateFactRecord, validateGedcomContent, withGedcom7Calendar };