@treeviz/gedcom-parser 2.1.22 → 2.1.24
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/classes/gedcom.d.ts.map +1 -1
- package/dist/classes/index.js +32 -4
- package/dist/classes/list.d.ts.map +1 -1
- package/dist/cli/index.js +751 -721
- package/dist/constants/constants.d.ts +0 -4
- package/dist/constants/constants.d.ts.map +1 -1
- package/dist/constants/index.js +2 -3
- package/dist/factories/index.js +1 -1
- package/dist/index.js +1213 -1183
- package/dist/kinship-translator/index.js +1 -1
- package/dist/structures/individual.d.ts +2 -0
- package/dist/structures/individual.d.ts.map +1 -1
- package/dist/types/types.d.ts +2 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/utils/family-edit.d.ts +7 -0
- package/dist/utils/family-edit.d.ts.map +1 -1
- package/dist/utils/gedcom7-schema.d.ts.map +1 -1
- package/dist/utils/index.js +42 -11
- package/dist/utils/parser.d.ts +13 -8
- package/dist/utils/parser.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -22,7 +22,6 @@ var LINE_REG = /(?<indent>^[0-9]{1,2}) (?:(@[_a-zA-Z0-9]*@) )?(?<type>_[_A-Z][_a
|
|
|
22
22
|
var ID_REG = /^@[_a-zA-Z0-9]+@/;
|
|
23
23
|
var ID_GETTER_REG = /^(?<at>@)?(?<letter>[A-Z])?/i;
|
|
24
24
|
var ORIG_HEAD_TAG = "_ORIGHEAD";
|
|
25
|
-
var MAX_FILE_SIZE_TO_SYNC = 1024 * 1024 * 20;
|
|
26
25
|
|
|
27
26
|
// src/utils/gedcom-trailer.ts
|
|
28
27
|
var TRAILER_LINE = /^0 TRLR\s*$/i;
|
|
@@ -516,7 +515,7 @@ var List = class _List {
|
|
|
516
515
|
const gedcom = [];
|
|
517
516
|
this.entries().forEach(([_, item]) => {
|
|
518
517
|
const validTag = getValidTag(tag);
|
|
519
|
-
const xref = item.id;
|
|
518
|
+
const xref = validTag === "CONT" || validTag === "CONC" ? void 0 : item.id;
|
|
520
519
|
const payload = item.exportValue?.();
|
|
521
520
|
if (xref) {
|
|
522
521
|
gedcom.push(
|
|
@@ -1318,7 +1317,257 @@ var getCacheManagerFactory = () => {
|
|
|
1318
1317
|
return cacheFactory;
|
|
1319
1318
|
};
|
|
1320
1319
|
|
|
1321
|
-
// src/
|
|
1320
|
+
// src/factories/date-locale-factory.ts
|
|
1321
|
+
var dateLocaleProvider = () => void 0;
|
|
1322
|
+
var getDateLocale = () => {
|
|
1323
|
+
const result = dateLocaleProvider();
|
|
1324
|
+
return result;
|
|
1325
|
+
};
|
|
1326
|
+
|
|
1327
|
+
// src/factories/i18n-factory.ts
|
|
1328
|
+
var i18nProvider = (key) => key;
|
|
1329
|
+
var i18n = {
|
|
1330
|
+
t: (key, options) => i18nProvider(key)
|
|
1331
|
+
};
|
|
1332
|
+
|
|
1333
|
+
// src/kinship-translator/translators.ts
|
|
1334
|
+
var translators_exports = {};
|
|
1335
|
+
__export(translators_exports, {
|
|
1336
|
+
de: () => KinshipTranslatorDe,
|
|
1337
|
+
en: () => KinshipTranslatorEn,
|
|
1338
|
+
es: () => KinshipTranslatorEs,
|
|
1339
|
+
fr: () => KinshipTranslatorFr,
|
|
1340
|
+
hu: () => KinshipTranslatorHU,
|
|
1341
|
+
ja: () => KinshipTranslatorJa,
|
|
1342
|
+
ru: () => KinshipTranslatorRu,
|
|
1343
|
+
zh: () => KinshipTranslatorZh
|
|
1344
|
+
});
|
|
1345
|
+
|
|
1346
|
+
// src/constants/filters.ts
|
|
1347
|
+
var FEMALE = {
|
|
1348
|
+
SEX: "F"
|
|
1349
|
+
};
|
|
1350
|
+
var MALE = {
|
|
1351
|
+
SEX: "M"
|
|
1352
|
+
};
|
|
1353
|
+
var ADOPTED = {
|
|
1354
|
+
PEDI: "adopted" /* ADOPTED */
|
|
1355
|
+
};
|
|
1356
|
+
var BIRTH = {
|
|
1357
|
+
PEDI: "birth" /* BIRTH */
|
|
1358
|
+
};
|
|
1359
|
+
var FOSTER = {
|
|
1360
|
+
PEDI: "foster" /* FOSTER */
|
|
1361
|
+
};
|
|
1362
|
+
var SEALING = {
|
|
1363
|
+
PEDI: "sealing" /* SEALING */
|
|
1364
|
+
};
|
|
1365
|
+
var STEP = {
|
|
1366
|
+
PEDI: "step" /* STEP */
|
|
1367
|
+
};
|
|
1368
|
+
var BIOLOGICAL = {
|
|
1369
|
+
PEDI: "biological" /* BIOLOGICAL */
|
|
1370
|
+
};
|
|
1371
|
+
var FRIEND = {
|
|
1372
|
+
PART: "friend" /* FRIEND */
|
|
1373
|
+
};
|
|
1374
|
+
var PARTNER = {
|
|
1375
|
+
PART: "partner" /* PARTNER */
|
|
1376
|
+
};
|
|
1377
|
+
var SPOUSE = {
|
|
1378
|
+
PART: "spouse" /* SPOUSE */
|
|
1379
|
+
};
|
|
1380
|
+
|
|
1381
|
+
// src/utils/get-family-with.ts
|
|
1382
|
+
var getFamilyWith = (person1, person2, famType = "FAMS") => {
|
|
1383
|
+
return person1?.get(famType)?.toValueList().find((fam) => {
|
|
1384
|
+
const family = fam;
|
|
1385
|
+
return famType === "FAMC" || family?.HUSB?.value === person2 || family?.WIFE?.value === person2;
|
|
1386
|
+
});
|
|
1387
|
+
};
|
|
1388
|
+
|
|
1389
|
+
// src/constants/orders.ts
|
|
1390
|
+
var BIRTH_ASC = {
|
|
1391
|
+
"BIRT.DATE": {
|
|
1392
|
+
direction: "ASC",
|
|
1393
|
+
getter: (value, raw) => {
|
|
1394
|
+
if (isCommonDate(raw) && raw.rawValue) {
|
|
1395
|
+
return raw.rawValue.getTime();
|
|
1396
|
+
}
|
|
1397
|
+
return new Date(value).getTime();
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
};
|
|
1401
|
+
var BIRTH_DESC = {
|
|
1402
|
+
"BIRT.DATE": {
|
|
1403
|
+
direction: "DESC",
|
|
1404
|
+
getter: (value, raw) => {
|
|
1405
|
+
if (isCommonDate(raw) && raw.rawValue) {
|
|
1406
|
+
return raw.rawValue.getTime();
|
|
1407
|
+
}
|
|
1408
|
+
return new Date(value).getTime();
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
};
|
|
1412
|
+
var DEATH_ASC = {
|
|
1413
|
+
"DEAT.DATE": {
|
|
1414
|
+
direction: "ASC",
|
|
1415
|
+
getter: (value, raw) => {
|
|
1416
|
+
if (isCommonDate(raw) && raw.rawValue) {
|
|
1417
|
+
return raw.rawValue.getTime();
|
|
1418
|
+
}
|
|
1419
|
+
return new Date(value).getTime();
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
var DEATH_DESC = {
|
|
1424
|
+
"DEAT.DATE": {
|
|
1425
|
+
direction: "DESC",
|
|
1426
|
+
getter: (value, raw) => {
|
|
1427
|
+
if (isCommonDate(raw) && raw.rawValue) {
|
|
1428
|
+
return raw.rawValue.getTime();
|
|
1429
|
+
}
|
|
1430
|
+
return new Date(value).getTime();
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
};
|
|
1434
|
+
var DATE_ASC = {
|
|
1435
|
+
DATE: {
|
|
1436
|
+
direction: "ASC",
|
|
1437
|
+
getter: (value, raw) => {
|
|
1438
|
+
if (isCommonDate(raw) && raw.rawValue) {
|
|
1439
|
+
return raw.rawValue.getTime();
|
|
1440
|
+
}
|
|
1441
|
+
return new Date(value).getTime();
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
var chars = [
|
|
1446
|
+
"a",
|
|
1447
|
+
"\xE0",
|
|
1448
|
+
"\xE1",
|
|
1449
|
+
"\xE2",
|
|
1450
|
+
"\xE4",
|
|
1451
|
+
"\xE6",
|
|
1452
|
+
"\xE3",
|
|
1453
|
+
"\xE5",
|
|
1454
|
+
"\u0101",
|
|
1455
|
+
"b",
|
|
1456
|
+
"c",
|
|
1457
|
+
"\xE7",
|
|
1458
|
+
"\u0107",
|
|
1459
|
+
"\u010D",
|
|
1460
|
+
"cs",
|
|
1461
|
+
"d",
|
|
1462
|
+
"dz",
|
|
1463
|
+
"dzs",
|
|
1464
|
+
"e",
|
|
1465
|
+
"\xE8",
|
|
1466
|
+
"\xE9",
|
|
1467
|
+
"\xEA",
|
|
1468
|
+
"\xEB",
|
|
1469
|
+
"\u0113",
|
|
1470
|
+
"\u0117",
|
|
1471
|
+
"\u0119",
|
|
1472
|
+
"f",
|
|
1473
|
+
"g",
|
|
1474
|
+
"gy",
|
|
1475
|
+
"h",
|
|
1476
|
+
"i",
|
|
1477
|
+
"\xEE",
|
|
1478
|
+
"\xEF",
|
|
1479
|
+
"\xED",
|
|
1480
|
+
"\u012B",
|
|
1481
|
+
"\u012F",
|
|
1482
|
+
"\xEC",
|
|
1483
|
+
"j",
|
|
1484
|
+
"k",
|
|
1485
|
+
"l",
|
|
1486
|
+
"\u0142",
|
|
1487
|
+
"ly",
|
|
1488
|
+
"m",
|
|
1489
|
+
"n",
|
|
1490
|
+
"\xF1",
|
|
1491
|
+
"\u0144",
|
|
1492
|
+
"ny",
|
|
1493
|
+
"o",
|
|
1494
|
+
"\xF3",
|
|
1495
|
+
"\xF6",
|
|
1496
|
+
"\u0151",
|
|
1497
|
+
"\xF4",
|
|
1498
|
+
"\xF2",
|
|
1499
|
+
"\xF5",
|
|
1500
|
+
"\u0153",
|
|
1501
|
+
"\xF8",
|
|
1502
|
+
"\u014D",
|
|
1503
|
+
"p",
|
|
1504
|
+
"q",
|
|
1505
|
+
"r",
|
|
1506
|
+
"s",
|
|
1507
|
+
"\u015B",
|
|
1508
|
+
"\u0161",
|
|
1509
|
+
"\xDF",
|
|
1510
|
+
"sz",
|
|
1511
|
+
"t",
|
|
1512
|
+
"ty",
|
|
1513
|
+
"u",
|
|
1514
|
+
"\xFA",
|
|
1515
|
+
"\xFC",
|
|
1516
|
+
"\u0171",
|
|
1517
|
+
"\xFB",
|
|
1518
|
+
"\xF9",
|
|
1519
|
+
"\u016B",
|
|
1520
|
+
"v",
|
|
1521
|
+
"w",
|
|
1522
|
+
"x",
|
|
1523
|
+
"y",
|
|
1524
|
+
"z",
|
|
1525
|
+
"zs"
|
|
1526
|
+
];
|
|
1527
|
+
chars.reduce((acc, curr, idx) => {
|
|
1528
|
+
acc[curr] = idx;
|
|
1529
|
+
return acc;
|
|
1530
|
+
}, {});
|
|
1531
|
+
var getBirthAsc = (itemA, _keyA, itemB, _keyB) => {
|
|
1532
|
+
const birthA = itemA?.BIRT?.index(0);
|
|
1533
|
+
const birthB = itemB?.BIRT?.index(0);
|
|
1534
|
+
const valueA = birthA?.DATE?.rawValue;
|
|
1535
|
+
const valueB = birthB?.DATE?.rawValue;
|
|
1536
|
+
if (valueA?.getTime() === valueB?.getTime()) {
|
|
1537
|
+
return 0;
|
|
1538
|
+
}
|
|
1539
|
+
if (!valueA || valueB && valueA > valueB) {
|
|
1540
|
+
return 1;
|
|
1541
|
+
}
|
|
1542
|
+
return -1;
|
|
1543
|
+
};
|
|
1544
|
+
var getMarriageAsc = (person, famType = "FAMS") => (itemA, _keyA, itemB, _keyB) => {
|
|
1545
|
+
if (!person && famType === "FAMS") {
|
|
1546
|
+
return 0;
|
|
1547
|
+
}
|
|
1548
|
+
const familyA = getFamilyWith(itemA, person);
|
|
1549
|
+
const familyB = getFamilyWith(itemB, person);
|
|
1550
|
+
const marriageA = familyA?.MARR?.DATE?.rawValue;
|
|
1551
|
+
const marriageB = familyB?.MARR?.DATE?.rawValue;
|
|
1552
|
+
if (marriageA?.getTime() === marriageB?.getTime()) {
|
|
1553
|
+
return 0;
|
|
1554
|
+
}
|
|
1555
|
+
if (!marriageA || marriageB && marriageA > marriageB) {
|
|
1556
|
+
return 1;
|
|
1557
|
+
}
|
|
1558
|
+
return -1;
|
|
1559
|
+
};
|
|
1560
|
+
var getMarriageAscAndChildBirth = (person) => (itemA, keyA, itemB, keyB) => {
|
|
1561
|
+
const marriageSort = getMarriageAsc(person)(itemA, keyA, itemB, keyB);
|
|
1562
|
+
if (marriageSort !== 0) {
|
|
1563
|
+
return marriageSort;
|
|
1564
|
+
}
|
|
1565
|
+
const familyA = getFamilyWith(itemA, person);
|
|
1566
|
+
const familyB = getFamilyWith(itemB, person);
|
|
1567
|
+
const childA = familyA?.getChildren().orderBy(BIRTH_ASC).index(0);
|
|
1568
|
+
const childB = familyB?.getChildren().orderBy(BIRTH_ASC).index(0);
|
|
1569
|
+
return getBirthAsc(childA, keyA, childB);
|
|
1570
|
+
};
|
|
1322
1571
|
var getGedcomId = (gedcom) => {
|
|
1323
1572
|
if (!gedcom) {
|
|
1324
1573
|
return "unknown";
|
|
@@ -1570,612 +1819,6 @@ var cacheDiscoveredPath = (gedcom, path) => {
|
|
|
1570
1819
|
}
|
|
1571
1820
|
};
|
|
1572
1821
|
|
|
1573
|
-
// src/utils/family-edit.ts
|
|
1574
|
-
var refTypeForTag = (tag) => {
|
|
1575
|
-
if (tag === "FAMS" || tag === "FAMC") return "FAM";
|
|
1576
|
-
return "INDI";
|
|
1577
|
-
};
|
|
1578
|
-
var normalizeSinglePointer = (owner, tag) => {
|
|
1579
|
-
const node = owner.get(tag);
|
|
1580
|
-
if (!node) return;
|
|
1581
|
-
if (node instanceof List && node.length === 1) {
|
|
1582
|
-
const only = node.index(0);
|
|
1583
|
-
if (only) {
|
|
1584
|
-
owner.set(tag, only);
|
|
1585
|
-
return;
|
|
1586
|
-
}
|
|
1587
|
-
const raw = node.values()[0];
|
|
1588
|
-
if (typeof raw === "string") {
|
|
1589
|
-
const gedcom = owner.getGedcom?.();
|
|
1590
|
-
if (gedcom) {
|
|
1591
|
-
owner.set(tag, makePointer(gedcom, owner, raw, refTypeForTag(tag)));
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
};
|
|
1596
|
-
var PEDIGREE_VALUES = [
|
|
1597
|
-
"birth" /* BIRTH */,
|
|
1598
|
-
"adopted" /* ADOPTED */,
|
|
1599
|
-
"foster" /* FOSTER */,
|
|
1600
|
-
"step" /* STEP */,
|
|
1601
|
-
"sealing" /* SEALING */
|
|
1602
|
-
];
|
|
1603
|
-
var toGedcomPedigree = (value) => {
|
|
1604
|
-
const normalized = String(value || "birth" /* BIRTH */).toLowerCase();
|
|
1605
|
-
if (normalized === "biological" /* BIOLOGICAL */ || normalized === "birth" /* BIRTH */) {
|
|
1606
|
-
return "birth" /* BIRTH */;
|
|
1607
|
-
}
|
|
1608
|
-
const match = PEDIGREE_VALUES.find((item) => item === normalized);
|
|
1609
|
-
return match ?? "birth" /* BIRTH */;
|
|
1610
|
-
};
|
|
1611
|
-
var pointerIds = (tag) => {
|
|
1612
|
-
if (!tag) {
|
|
1613
|
-
return [];
|
|
1614
|
-
}
|
|
1615
|
-
if (tag instanceof List) {
|
|
1616
|
-
return tag.values().map((item) => item?.toValue?.()).filter((value2) => !!value2);
|
|
1617
|
-
}
|
|
1618
|
-
const value = tag.toValue?.();
|
|
1619
|
-
return value ? [String(value)] : [];
|
|
1620
|
-
};
|
|
1621
|
-
var firstPointerId = (tag) => pointerIds(tag)[0];
|
|
1622
|
-
var makePointer = (gedcom, parent, value, refType) => {
|
|
1623
|
-
const pointer = createCommon(gedcom, void 0, parent);
|
|
1624
|
-
pointer.value = value;
|
|
1625
|
-
pointer.refType = refType;
|
|
1626
|
-
return pointer;
|
|
1627
|
-
};
|
|
1628
|
-
var nextRecordId = (ids, prefix) => {
|
|
1629
|
-
let max = 0;
|
|
1630
|
-
ids.forEach((id) => {
|
|
1631
|
-
const match = String(id).match(/(\d+)/);
|
|
1632
|
-
const n = match ? Number.parseInt(match[1], 10) : 0;
|
|
1633
|
-
if (n > max) {
|
|
1634
|
-
max = n;
|
|
1635
|
-
}
|
|
1636
|
-
});
|
|
1637
|
-
return `@${prefix}${max + 1}@`;
|
|
1638
|
-
};
|
|
1639
|
-
var familyHasParent = (fam, indiId) => pointerIds(fam.get("HUSB")).includes(indiId) || pointerIds(fam.get("WIFE")).includes(indiId);
|
|
1640
|
-
var familyHasChild = (fam, indiId) => pointerIds(fam.get("CHIL")).includes(indiId);
|
|
1641
|
-
var spouseTagFor = (indi, fam) => {
|
|
1642
|
-
const husbId = firstPointerId(fam.get("HUSB"));
|
|
1643
|
-
const wifeId = firstPointerId(fam.get("WIFE"));
|
|
1644
|
-
if (husbId === indi.id) {
|
|
1645
|
-
return "HUSB";
|
|
1646
|
-
}
|
|
1647
|
-
if (wifeId === indi.id) {
|
|
1648
|
-
return "WIFE";
|
|
1649
|
-
}
|
|
1650
|
-
if (indi.isFemale()) {
|
|
1651
|
-
return wifeId && wifeId !== indi.id ? "HUSB" : "WIFE";
|
|
1652
|
-
}
|
|
1653
|
-
if (indi.isMale()) {
|
|
1654
|
-
return husbId && husbId !== indi.id ? "WIFE" : "HUSB";
|
|
1655
|
-
}
|
|
1656
|
-
return husbId ? "WIFE" : "HUSB";
|
|
1657
|
-
};
|
|
1658
|
-
var canAttachAsSpouse = (fam, indi) => {
|
|
1659
|
-
if (!indi.id) {
|
|
1660
|
-
return false;
|
|
1661
|
-
}
|
|
1662
|
-
if (familyHasParent(fam, indi.id)) {
|
|
1663
|
-
return true;
|
|
1664
|
-
}
|
|
1665
|
-
const tag = spouseTagFor(indi, fam);
|
|
1666
|
-
const occupied = firstPointerId(fam.get(tag));
|
|
1667
|
-
return !occupied || occupied === indi.id;
|
|
1668
|
-
};
|
|
1669
|
-
var pointerByValue = (tag, id) => {
|
|
1670
|
-
if (!tag) {
|
|
1671
|
-
return void 0;
|
|
1672
|
-
}
|
|
1673
|
-
const fromValues = tag.toValueList?.().item(id);
|
|
1674
|
-
if (fromValues) {
|
|
1675
|
-
return fromValues;
|
|
1676
|
-
}
|
|
1677
|
-
return tag.toList()?.values().find((item) => item?.toValue?.() === id);
|
|
1678
|
-
};
|
|
1679
|
-
var setChildPedigree = (fam, child, pedigree, parent) => {
|
|
1680
|
-
if (!fam.id || !child.id) {
|
|
1681
|
-
return;
|
|
1682
|
-
}
|
|
1683
|
-
const pedi = toGedcomPedigree(pedigree);
|
|
1684
|
-
const famc = pointerByValue(child.get("FAMC"), fam.id);
|
|
1685
|
-
if (famc) {
|
|
1686
|
-
famc.set("PEDI", pedi);
|
|
1687
|
-
}
|
|
1688
|
-
const chil = pointerByValue(fam.get("CHIL"), child.id);
|
|
1689
|
-
if (!chil) {
|
|
1690
|
-
return;
|
|
1691
|
-
}
|
|
1692
|
-
const setFather = !parent || parent.isMale() || parent.isUnknownSex();
|
|
1693
|
-
const setMother = !parent || parent.isFemale() || parent.isUnknownSex();
|
|
1694
|
-
if (setFather) {
|
|
1695
|
-
chil.set("_FREL", pedi);
|
|
1696
|
-
}
|
|
1697
|
-
if (setMother) {
|
|
1698
|
-
chil.set("_MREL", pedi);
|
|
1699
|
-
}
|
|
1700
|
-
};
|
|
1701
|
-
var attachSpouseToFamily = (fam, indi) => {
|
|
1702
|
-
const gedcom = fam.getGedcom() ?? indi.getGedcom();
|
|
1703
|
-
if (!indi.id || !fam.id || !gedcom) {
|
|
1704
|
-
return false;
|
|
1705
|
-
}
|
|
1706
|
-
if (!canAttachAsSpouse(fam, indi)) {
|
|
1707
|
-
return false;
|
|
1708
|
-
}
|
|
1709
|
-
const tag = spouseTagFor(indi, fam);
|
|
1710
|
-
if (firstPointerId(fam.get(tag)) !== indi.id) {
|
|
1711
|
-
fam.set(tag, makePointer(gedcom, fam, indi.id, "INDI"));
|
|
1712
|
-
}
|
|
1713
|
-
indi.assign("FAMS", makePointer(gedcom, indi, fam.id, "FAM"), true);
|
|
1714
|
-
normalizeSinglePointer(indi, "FAMS");
|
|
1715
|
-
normalizeSinglePointer(fam, spouseTagFor(indi, fam));
|
|
1716
|
-
resetRelativesCache();
|
|
1717
|
-
return true;
|
|
1718
|
-
};
|
|
1719
|
-
var attachChildToFamily = (fam, child, pedigree, parent) => {
|
|
1720
|
-
const gedcom = fam.getGedcom() ?? child.getGedcom();
|
|
1721
|
-
if (!child.id || !fam.id || !gedcom) {
|
|
1722
|
-
return false;
|
|
1723
|
-
}
|
|
1724
|
-
if (!familyHasChild(fam, child.id)) {
|
|
1725
|
-
fam.assign("CHIL", makePointer(gedcom, fam, child.id, "INDI"), true);
|
|
1726
|
-
}
|
|
1727
|
-
const existingFamc = pointerByValue(child.get("FAMC"), fam.id);
|
|
1728
|
-
if (!existingFamc) {
|
|
1729
|
-
child.assign("FAMC", makePointer(gedcom, child, fam.id, "FAM"), true);
|
|
1730
|
-
}
|
|
1731
|
-
setChildPedigree(fam, child, pedigree, parent);
|
|
1732
|
-
normalizeSinglePointer(child, "FAMC");
|
|
1733
|
-
normalizeSinglePointer(fam, "CHIL");
|
|
1734
|
-
resetRelativesCache();
|
|
1735
|
-
return true;
|
|
1736
|
-
};
|
|
1737
|
-
var removePointerByValue = (owner, tag, targetId) => {
|
|
1738
|
-
const node = owner.get(tag);
|
|
1739
|
-
if (!node) {
|
|
1740
|
-
return false;
|
|
1741
|
-
}
|
|
1742
|
-
if (node instanceof List) {
|
|
1743
|
-
const keysToRemove = [];
|
|
1744
|
-
node.entries().forEach(([key, item]) => {
|
|
1745
|
-
if (item?.toValue?.() === targetId || item?.id === targetId || String(key) === targetId) {
|
|
1746
|
-
keysToRemove.push(key);
|
|
1747
|
-
}
|
|
1748
|
-
});
|
|
1749
|
-
keysToRemove.forEach((key) => {
|
|
1750
|
-
node.removeItem(key);
|
|
1751
|
-
});
|
|
1752
|
-
if (node.length === 0) {
|
|
1753
|
-
owner.remove(tag);
|
|
1754
|
-
}
|
|
1755
|
-
return keysToRemove.length > 0;
|
|
1756
|
-
}
|
|
1757
|
-
if (node.toValue?.() === targetId) {
|
|
1758
|
-
owner.remove(tag);
|
|
1759
|
-
return true;
|
|
1760
|
-
}
|
|
1761
|
-
const asList = node.toList?.();
|
|
1762
|
-
if (asList && asList.length > 0) {
|
|
1763
|
-
const keysToRemove = [];
|
|
1764
|
-
asList.entries().forEach(([key, item]) => {
|
|
1765
|
-
if (item?.toValue?.() === targetId || item?.id === targetId) {
|
|
1766
|
-
keysToRemove.push(key);
|
|
1767
|
-
}
|
|
1768
|
-
});
|
|
1769
|
-
if (keysToRemove.length === asList.length) {
|
|
1770
|
-
owner.remove(tag);
|
|
1771
|
-
return true;
|
|
1772
|
-
}
|
|
1773
|
-
if (keysToRemove.length > 0) {
|
|
1774
|
-
const remaining = asList.values().filter((item) => item?.toValue?.() !== targetId);
|
|
1775
|
-
if (remaining.length === 1 && remaining[0]) {
|
|
1776
|
-
owner.set(tag, remaining[0]);
|
|
1777
|
-
} else {
|
|
1778
|
-
owner.set(tag, new List(remaining));
|
|
1779
|
-
}
|
|
1780
|
-
return true;
|
|
1781
|
-
}
|
|
1782
|
-
}
|
|
1783
|
-
return false;
|
|
1784
|
-
};
|
|
1785
|
-
var familyMemberCount = (fam) => {
|
|
1786
|
-
let count = 0;
|
|
1787
|
-
if (firstPointerId(fam.get("HUSB"))) {
|
|
1788
|
-
count += 1;
|
|
1789
|
-
}
|
|
1790
|
-
if (firstPointerId(fam.get("WIFE"))) {
|
|
1791
|
-
count += 1;
|
|
1792
|
-
}
|
|
1793
|
-
count += pointerIds(fam.get("CHIL")).length;
|
|
1794
|
-
return count;
|
|
1795
|
-
};
|
|
1796
|
-
var isDegenerateFamily = (fam) => familyMemberCount(fam) <= 1;
|
|
1797
|
-
var pruneEmptyFamilies = (gedcom) => {
|
|
1798
|
-
const emptyIds = [];
|
|
1799
|
-
gedcom.fams()?.forEach((fam, id) => {
|
|
1800
|
-
if (fam && isDegenerateFamily(fam) && id) {
|
|
1801
|
-
emptyIds.push(id);
|
|
1802
|
-
}
|
|
1803
|
-
});
|
|
1804
|
-
if (emptyIds.length === 0) {
|
|
1805
|
-
return [];
|
|
1806
|
-
}
|
|
1807
|
-
gedcom.indis()?.forEach((indi) => {
|
|
1808
|
-
if (!indi) {
|
|
1809
|
-
return;
|
|
1810
|
-
}
|
|
1811
|
-
emptyIds.forEach((famId) => {
|
|
1812
|
-
removePointerByValue(indi, "FAMS", famId);
|
|
1813
|
-
removePointerByValue(indi, "FAMC", famId);
|
|
1814
|
-
});
|
|
1815
|
-
});
|
|
1816
|
-
emptyIds.forEach((famId) => {
|
|
1817
|
-
gedcom.fams()?.removeItem(famId);
|
|
1818
|
-
});
|
|
1819
|
-
return emptyIds;
|
|
1820
|
-
};
|
|
1821
|
-
var findSharedSpouseFamily = (parent, coParentId) => {
|
|
1822
|
-
let found;
|
|
1823
|
-
parent.getFamilies("FAMS")?.forEach((fam) => {
|
|
1824
|
-
if (!found && fam && familyHasParent(fam, coParentId)) {
|
|
1825
|
-
found = fam;
|
|
1826
|
-
}
|
|
1827
|
-
});
|
|
1828
|
-
return found;
|
|
1829
|
-
};
|
|
1830
|
-
var findReusableParentChildFamily = (parent, child, options) => {
|
|
1831
|
-
if (!parent.id || !child.id) {
|
|
1832
|
-
return void 0;
|
|
1833
|
-
}
|
|
1834
|
-
const reuseParentFamilies = options?.reuseParentFamilies !== false;
|
|
1835
|
-
const gedcom = parent.getGedcom() ?? child.getGedcom();
|
|
1836
|
-
let reusableFamc;
|
|
1837
|
-
let coupleFam;
|
|
1838
|
-
let already = false;
|
|
1839
|
-
const noteCoupleWith = (coParentId) => {
|
|
1840
|
-
if (!coParentId || coParentId === parent.id || coupleFam || !parent.id) {
|
|
1841
|
-
return;
|
|
1842
|
-
}
|
|
1843
|
-
const shared = findSharedSpouseFamily(parent, coParentId);
|
|
1844
|
-
if (shared) {
|
|
1845
|
-
coupleFam = shared;
|
|
1846
|
-
}
|
|
1847
|
-
};
|
|
1848
|
-
child.getFamilies("FAMC")?.forEach((fam) => {
|
|
1849
|
-
if (!fam) {
|
|
1850
|
-
return;
|
|
1851
|
-
}
|
|
1852
|
-
if (familyHasParent(fam, parent.id) && familyHasChild(fam, child.id)) {
|
|
1853
|
-
already = true;
|
|
1854
|
-
return;
|
|
1855
|
-
}
|
|
1856
|
-
pointerIds(fam.get("HUSB")).forEach(noteCoupleWith);
|
|
1857
|
-
pointerIds(fam.get("WIFE")).forEach(noteCoupleWith);
|
|
1858
|
-
if (!reusableFamc && canAttachAsSpouse(fam, parent)) {
|
|
1859
|
-
reusableFamc = fam;
|
|
1860
|
-
}
|
|
1861
|
-
});
|
|
1862
|
-
if (already) {
|
|
1863
|
-
return "already";
|
|
1864
|
-
}
|
|
1865
|
-
if (coupleFam) {
|
|
1866
|
-
return coupleFam;
|
|
1867
|
-
}
|
|
1868
|
-
if (reusableFamc) {
|
|
1869
|
-
return reusableFamc;
|
|
1870
|
-
}
|
|
1871
|
-
if (options?.targetFamilyId && gedcom) {
|
|
1872
|
-
const target = gedcom.fam(options.targetFamilyId);
|
|
1873
|
-
if (target && (familyHasParent(target, parent.id) || canAttachAsSpouse(target, parent))) {
|
|
1874
|
-
return target;
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1877
|
-
if (!reuseParentFamilies) {
|
|
1878
|
-
return void 0;
|
|
1879
|
-
}
|
|
1880
|
-
const parentFams = [];
|
|
1881
|
-
parent.getFamilies("FAMS")?.forEach((fam) => {
|
|
1882
|
-
if (fam) {
|
|
1883
|
-
parentFams.push(fam);
|
|
1884
|
-
}
|
|
1885
|
-
});
|
|
1886
|
-
if (parentFams.length === 1) {
|
|
1887
|
-
return parentFams[0];
|
|
1888
|
-
}
|
|
1889
|
-
return void 0;
|
|
1890
|
-
};
|
|
1891
|
-
var consolidateChildIntoFamily = (child, keep) => {
|
|
1892
|
-
if (!child.id || !keep.id) {
|
|
1893
|
-
return [];
|
|
1894
|
-
}
|
|
1895
|
-
const keepParentIds = /* @__PURE__ */ new Set([
|
|
1896
|
-
...pointerIds(keep.get("HUSB")),
|
|
1897
|
-
...pointerIds(keep.get("WIFE"))
|
|
1898
|
-
]);
|
|
1899
|
-
const removed = [];
|
|
1900
|
-
child.getFamilies("FAMC")?.forEach((fam) => {
|
|
1901
|
-
if (!fam?.id || fam.id === keep.id) {
|
|
1902
|
-
return;
|
|
1903
|
-
}
|
|
1904
|
-
const famParentIds = [
|
|
1905
|
-
...pointerIds(fam.get("HUSB")),
|
|
1906
|
-
...pointerIds(fam.get("WIFE"))
|
|
1907
|
-
];
|
|
1908
|
-
if (famParentIds.length === 0 || !famParentIds.every((id) => keepParentIds.has(id))) {
|
|
1909
|
-
return;
|
|
1910
|
-
}
|
|
1911
|
-
removePointerByValue(fam, "CHIL", child.id);
|
|
1912
|
-
normalizeSinglePointer(fam, "CHIL");
|
|
1913
|
-
removePointerByValue(child, "FAMC", fam.id);
|
|
1914
|
-
normalizeSinglePointer(child, "FAMC");
|
|
1915
|
-
removed.push(fam.id);
|
|
1916
|
-
});
|
|
1917
|
-
const gedcom = child.getGedcom() ?? keep.getGedcom();
|
|
1918
|
-
if (gedcom && removed.length > 0) {
|
|
1919
|
-
pruneEmptyFamilies(gedcom);
|
|
1920
|
-
}
|
|
1921
|
-
if (removed.length > 0) {
|
|
1922
|
-
resetRelativesCache();
|
|
1923
|
-
}
|
|
1924
|
-
return removed;
|
|
1925
|
-
};
|
|
1926
|
-
|
|
1927
|
-
// src/factories/date-locale-factory.ts
|
|
1928
|
-
var dateLocaleProvider = () => void 0;
|
|
1929
|
-
var getDateLocale = () => {
|
|
1930
|
-
const result = dateLocaleProvider();
|
|
1931
|
-
return result;
|
|
1932
|
-
};
|
|
1933
|
-
|
|
1934
|
-
// src/factories/i18n-factory.ts
|
|
1935
|
-
var i18nProvider = (key) => key;
|
|
1936
|
-
var i18n = {
|
|
1937
|
-
t: (key, options) => i18nProvider(key)
|
|
1938
|
-
};
|
|
1939
|
-
|
|
1940
|
-
// src/kinship-translator/translators.ts
|
|
1941
|
-
var translators_exports = {};
|
|
1942
|
-
__export(translators_exports, {
|
|
1943
|
-
de: () => KinshipTranslatorDe,
|
|
1944
|
-
en: () => KinshipTranslatorEn,
|
|
1945
|
-
es: () => KinshipTranslatorEs,
|
|
1946
|
-
fr: () => KinshipTranslatorFr,
|
|
1947
|
-
hu: () => KinshipTranslatorHU,
|
|
1948
|
-
ja: () => KinshipTranslatorJa,
|
|
1949
|
-
ru: () => KinshipTranslatorRu,
|
|
1950
|
-
zh: () => KinshipTranslatorZh
|
|
1951
|
-
});
|
|
1952
|
-
|
|
1953
|
-
// src/constants/filters.ts
|
|
1954
|
-
var FEMALE = {
|
|
1955
|
-
SEX: "F"
|
|
1956
|
-
};
|
|
1957
|
-
var MALE = {
|
|
1958
|
-
SEX: "M"
|
|
1959
|
-
};
|
|
1960
|
-
var ADOPTED = {
|
|
1961
|
-
PEDI: "adopted" /* ADOPTED */
|
|
1962
|
-
};
|
|
1963
|
-
var BIRTH = {
|
|
1964
|
-
PEDI: "birth" /* BIRTH */
|
|
1965
|
-
};
|
|
1966
|
-
var FOSTER = {
|
|
1967
|
-
PEDI: "foster" /* FOSTER */
|
|
1968
|
-
};
|
|
1969
|
-
var SEALING = {
|
|
1970
|
-
PEDI: "sealing" /* SEALING */
|
|
1971
|
-
};
|
|
1972
|
-
var STEP = {
|
|
1973
|
-
PEDI: "step" /* STEP */
|
|
1974
|
-
};
|
|
1975
|
-
var BIOLOGICAL = {
|
|
1976
|
-
PEDI: "biological" /* BIOLOGICAL */
|
|
1977
|
-
};
|
|
1978
|
-
var FRIEND = {
|
|
1979
|
-
PART: "friend" /* FRIEND */
|
|
1980
|
-
};
|
|
1981
|
-
var PARTNER = {
|
|
1982
|
-
PART: "partner" /* PARTNER */
|
|
1983
|
-
};
|
|
1984
|
-
var SPOUSE = {
|
|
1985
|
-
PART: "spouse" /* SPOUSE */
|
|
1986
|
-
};
|
|
1987
|
-
|
|
1988
|
-
// src/utils/get-family-with.ts
|
|
1989
|
-
var getFamilyWith = (person1, person2, famType = "FAMS") => {
|
|
1990
|
-
return person1?.get(famType)?.toValueList().find((fam) => {
|
|
1991
|
-
const family = fam;
|
|
1992
|
-
return famType === "FAMC" || family?.HUSB?.value === person2 || family?.WIFE?.value === person2;
|
|
1993
|
-
});
|
|
1994
|
-
};
|
|
1995
|
-
|
|
1996
|
-
// src/constants/orders.ts
|
|
1997
|
-
var BIRTH_ASC = {
|
|
1998
|
-
"BIRT.DATE": {
|
|
1999
|
-
direction: "ASC",
|
|
2000
|
-
getter: (value, raw) => {
|
|
2001
|
-
if (isCommonDate(raw) && raw.rawValue) {
|
|
2002
|
-
return raw.rawValue.getTime();
|
|
2003
|
-
}
|
|
2004
|
-
return new Date(value).getTime();
|
|
2005
|
-
}
|
|
2006
|
-
}
|
|
2007
|
-
};
|
|
2008
|
-
var BIRTH_DESC = {
|
|
2009
|
-
"BIRT.DATE": {
|
|
2010
|
-
direction: "DESC",
|
|
2011
|
-
getter: (value, raw) => {
|
|
2012
|
-
if (isCommonDate(raw) && raw.rawValue) {
|
|
2013
|
-
return raw.rawValue.getTime();
|
|
2014
|
-
}
|
|
2015
|
-
return new Date(value).getTime();
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
};
|
|
2019
|
-
var DEATH_ASC = {
|
|
2020
|
-
"DEAT.DATE": {
|
|
2021
|
-
direction: "ASC",
|
|
2022
|
-
getter: (value, raw) => {
|
|
2023
|
-
if (isCommonDate(raw) && raw.rawValue) {
|
|
2024
|
-
return raw.rawValue.getTime();
|
|
2025
|
-
}
|
|
2026
|
-
return new Date(value).getTime();
|
|
2027
|
-
}
|
|
2028
|
-
}
|
|
2029
|
-
};
|
|
2030
|
-
var DEATH_DESC = {
|
|
2031
|
-
"DEAT.DATE": {
|
|
2032
|
-
direction: "DESC",
|
|
2033
|
-
getter: (value, raw) => {
|
|
2034
|
-
if (isCommonDate(raw) && raw.rawValue) {
|
|
2035
|
-
return raw.rawValue.getTime();
|
|
2036
|
-
}
|
|
2037
|
-
return new Date(value).getTime();
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
2040
|
-
};
|
|
2041
|
-
var DATE_ASC = {
|
|
2042
|
-
DATE: {
|
|
2043
|
-
direction: "ASC",
|
|
2044
|
-
getter: (value, raw) => {
|
|
2045
|
-
if (isCommonDate(raw) && raw.rawValue) {
|
|
2046
|
-
return raw.rawValue.getTime();
|
|
2047
|
-
}
|
|
2048
|
-
return new Date(value).getTime();
|
|
2049
|
-
}
|
|
2050
|
-
}
|
|
2051
|
-
};
|
|
2052
|
-
var chars = [
|
|
2053
|
-
"a",
|
|
2054
|
-
"\xE0",
|
|
2055
|
-
"\xE1",
|
|
2056
|
-
"\xE2",
|
|
2057
|
-
"\xE4",
|
|
2058
|
-
"\xE6",
|
|
2059
|
-
"\xE3",
|
|
2060
|
-
"\xE5",
|
|
2061
|
-
"\u0101",
|
|
2062
|
-
"b",
|
|
2063
|
-
"c",
|
|
2064
|
-
"\xE7",
|
|
2065
|
-
"\u0107",
|
|
2066
|
-
"\u010D",
|
|
2067
|
-
"cs",
|
|
2068
|
-
"d",
|
|
2069
|
-
"dz",
|
|
2070
|
-
"dzs",
|
|
2071
|
-
"e",
|
|
2072
|
-
"\xE8",
|
|
2073
|
-
"\xE9",
|
|
2074
|
-
"\xEA",
|
|
2075
|
-
"\xEB",
|
|
2076
|
-
"\u0113",
|
|
2077
|
-
"\u0117",
|
|
2078
|
-
"\u0119",
|
|
2079
|
-
"f",
|
|
2080
|
-
"g",
|
|
2081
|
-
"gy",
|
|
2082
|
-
"h",
|
|
2083
|
-
"i",
|
|
2084
|
-
"\xEE",
|
|
2085
|
-
"\xEF",
|
|
2086
|
-
"\xED",
|
|
2087
|
-
"\u012B",
|
|
2088
|
-
"\u012F",
|
|
2089
|
-
"\xEC",
|
|
2090
|
-
"j",
|
|
2091
|
-
"k",
|
|
2092
|
-
"l",
|
|
2093
|
-
"\u0142",
|
|
2094
|
-
"ly",
|
|
2095
|
-
"m",
|
|
2096
|
-
"n",
|
|
2097
|
-
"\xF1",
|
|
2098
|
-
"\u0144",
|
|
2099
|
-
"ny",
|
|
2100
|
-
"o",
|
|
2101
|
-
"\xF3",
|
|
2102
|
-
"\xF6",
|
|
2103
|
-
"\u0151",
|
|
2104
|
-
"\xF4",
|
|
2105
|
-
"\xF2",
|
|
2106
|
-
"\xF5",
|
|
2107
|
-
"\u0153",
|
|
2108
|
-
"\xF8",
|
|
2109
|
-
"\u014D",
|
|
2110
|
-
"p",
|
|
2111
|
-
"q",
|
|
2112
|
-
"r",
|
|
2113
|
-
"s",
|
|
2114
|
-
"\u015B",
|
|
2115
|
-
"\u0161",
|
|
2116
|
-
"\xDF",
|
|
2117
|
-
"sz",
|
|
2118
|
-
"t",
|
|
2119
|
-
"ty",
|
|
2120
|
-
"u",
|
|
2121
|
-
"\xFA",
|
|
2122
|
-
"\xFC",
|
|
2123
|
-
"\u0171",
|
|
2124
|
-
"\xFB",
|
|
2125
|
-
"\xF9",
|
|
2126
|
-
"\u016B",
|
|
2127
|
-
"v",
|
|
2128
|
-
"w",
|
|
2129
|
-
"x",
|
|
2130
|
-
"y",
|
|
2131
|
-
"z",
|
|
2132
|
-
"zs"
|
|
2133
|
-
];
|
|
2134
|
-
chars.reduce((acc, curr, idx) => {
|
|
2135
|
-
acc[curr] = idx;
|
|
2136
|
-
return acc;
|
|
2137
|
-
}, {});
|
|
2138
|
-
var getBirthAsc = (itemA, _keyA, itemB, _keyB) => {
|
|
2139
|
-
const birthA = itemA?.BIRT?.index(0);
|
|
2140
|
-
const birthB = itemB?.BIRT?.index(0);
|
|
2141
|
-
const valueA = birthA?.DATE?.rawValue;
|
|
2142
|
-
const valueB = birthB?.DATE?.rawValue;
|
|
2143
|
-
if (valueA?.getTime() === valueB?.getTime()) {
|
|
2144
|
-
return 0;
|
|
2145
|
-
}
|
|
2146
|
-
if (!valueA || valueB && valueA > valueB) {
|
|
2147
|
-
return 1;
|
|
2148
|
-
}
|
|
2149
|
-
return -1;
|
|
2150
|
-
};
|
|
2151
|
-
var getMarriageAsc = (person, famType = "FAMS") => (itemA, _keyA, itemB, _keyB) => {
|
|
2152
|
-
if (!person && famType === "FAMS") {
|
|
2153
|
-
return 0;
|
|
2154
|
-
}
|
|
2155
|
-
const familyA = getFamilyWith(itemA, person);
|
|
2156
|
-
const familyB = getFamilyWith(itemB, person);
|
|
2157
|
-
const marriageA = familyA?.MARR?.DATE?.rawValue;
|
|
2158
|
-
const marriageB = familyB?.MARR?.DATE?.rawValue;
|
|
2159
|
-
if (marriageA?.getTime() === marriageB?.getTime()) {
|
|
2160
|
-
return 0;
|
|
2161
|
-
}
|
|
2162
|
-
if (!marriageA || marriageB && marriageA > marriageB) {
|
|
2163
|
-
return 1;
|
|
2164
|
-
}
|
|
2165
|
-
return -1;
|
|
2166
|
-
};
|
|
2167
|
-
var getMarriageAscAndChildBirth = (person) => (itemA, keyA, itemB, keyB) => {
|
|
2168
|
-
const marriageSort = getMarriageAsc(person)(itemA, keyA, itemB, keyB);
|
|
2169
|
-
if (marriageSort !== 0) {
|
|
2170
|
-
return marriageSort;
|
|
2171
|
-
}
|
|
2172
|
-
const familyA = getFamilyWith(itemA, person);
|
|
2173
|
-
const familyB = getFamilyWith(itemB, person);
|
|
2174
|
-
const childA = familyA?.getChildren().orderBy(BIRTH_ASC).index(0);
|
|
2175
|
-
const childB = familyB?.getChildren().orderBy(BIRTH_ASC).index(0);
|
|
2176
|
-
return getBirthAsc(childA, keyA, childB);
|
|
2177
|
-
};
|
|
2178
|
-
|
|
2179
1822
|
// src/utils/get-all-prop.ts
|
|
2180
1823
|
var getAllProp = (indi, prop) => {
|
|
2181
1824
|
return prop && (indi?.get(prop)?.toList().values() ?? []).filter(Boolean) || [];
|
|
@@ -2366,34 +2009,124 @@ var dateFormatter = (indi, showMarriages = false, showDays = false, showPlaces =
|
|
|
2366
2009
|
}) : deathDate}`
|
|
2367
2010
|
);
|
|
2368
2011
|
}
|
|
2369
|
-
deathPlaces.push(deathEventPlace);
|
|
2370
|
-
});
|
|
2371
|
-
const birthString = birthStrings[0] ?? "";
|
|
2372
|
-
const deathString = deathStrings[0] ?? "";
|
|
2373
|
-
const marriageArray = marriages.length ? marriages.filter(Boolean) : [];
|
|
2374
|
-
const datesArray = !birth && !death ? marriageArray : [...birthStrings, ...marriageArray, ...deathStrings];
|
|
2375
|
-
const placesArray = !birth && !death ? marriagePlaces : [...birthPlaces, ...marriagePlaces, ...deathPlaces];
|
|
2376
|
-
const nonNullDatesArray = datesArray.filter(Boolean);
|
|
2377
|
-
const dates = nonNullDatesArray.join(" ").trim();
|
|
2378
|
-
return {
|
|
2379
|
-
inArray: nonNullDatesArray,
|
|
2380
|
-
inOrder: dates,
|
|
2381
|
-
places: placesArray,
|
|
2382
|
-
birth: birthString,
|
|
2383
|
-
marriage: marriageArray,
|
|
2384
|
-
death: deathString,
|
|
2385
|
-
...showPlaces ? {
|
|
2386
|
-
birthPlace,
|
|
2387
|
-
deathPlace,
|
|
2388
|
-
...showMarriages ? { marriages, marriagePlaces } : {}
|
|
2389
|
-
} : {},
|
|
2390
|
-
...showAllEvents ? {
|
|
2391
|
-
births: birthStrings,
|
|
2392
|
-
birthPlaces,
|
|
2393
|
-
deaths: deathStrings,
|
|
2394
|
-
deathPlaces
|
|
2395
|
-
} : {}
|
|
2396
|
-
};
|
|
2012
|
+
deathPlaces.push(deathEventPlace);
|
|
2013
|
+
});
|
|
2014
|
+
const birthString = birthStrings[0] ?? "";
|
|
2015
|
+
const deathString = deathStrings[0] ?? "";
|
|
2016
|
+
const marriageArray = marriages.length ? marriages.filter(Boolean) : [];
|
|
2017
|
+
const datesArray = !birth && !death ? marriageArray : [...birthStrings, ...marriageArray, ...deathStrings];
|
|
2018
|
+
const placesArray = !birth && !death ? marriagePlaces : [...birthPlaces, ...marriagePlaces, ...deathPlaces];
|
|
2019
|
+
const nonNullDatesArray = datesArray.filter(Boolean);
|
|
2020
|
+
const dates = nonNullDatesArray.join(" ").trim();
|
|
2021
|
+
return {
|
|
2022
|
+
inArray: nonNullDatesArray,
|
|
2023
|
+
inOrder: dates,
|
|
2024
|
+
places: placesArray,
|
|
2025
|
+
birth: birthString,
|
|
2026
|
+
marriage: marriageArray,
|
|
2027
|
+
death: deathString,
|
|
2028
|
+
...showPlaces ? {
|
|
2029
|
+
birthPlace,
|
|
2030
|
+
deathPlace,
|
|
2031
|
+
...showMarriages ? { marriages, marriagePlaces } : {}
|
|
2032
|
+
} : {},
|
|
2033
|
+
...showAllEvents ? {
|
|
2034
|
+
births: birthStrings,
|
|
2035
|
+
birthPlaces,
|
|
2036
|
+
deaths: deathStrings,
|
|
2037
|
+
deathPlaces
|
|
2038
|
+
} : {}
|
|
2039
|
+
};
|
|
2040
|
+
};
|
|
2041
|
+
|
|
2042
|
+
// src/utils/fact-edit.ts
|
|
2043
|
+
var SINGLETON_TAGS = /* @__PURE__ */ new Set(["BIRT", "DEAT", "SSN", "SEX", "DSCR"]);
|
|
2044
|
+
var firstRecord = (node) => {
|
|
2045
|
+
if (!node) {
|
|
2046
|
+
return void 0;
|
|
2047
|
+
}
|
|
2048
|
+
if (node instanceof List) {
|
|
2049
|
+
return node.index(0);
|
|
2050
|
+
}
|
|
2051
|
+
return node.index(0) ?? node;
|
|
2052
|
+
};
|
|
2053
|
+
var setDateOn = (gedcom, owner, parent, date) => {
|
|
2054
|
+
const trimmed = date.trim();
|
|
2055
|
+
if (!trimmed) {
|
|
2056
|
+
return;
|
|
2057
|
+
}
|
|
2058
|
+
let dateNode = parent.get("DATE");
|
|
2059
|
+
if (!dateNode || dateNode instanceof List) {
|
|
2060
|
+
dateNode = createCommonDate(gedcom, void 0, owner, parent);
|
|
2061
|
+
dateNode.type = "DATE";
|
|
2062
|
+
parent.set("DATE", dateNode);
|
|
2063
|
+
}
|
|
2064
|
+
dateNode.value = trimmed;
|
|
2065
|
+
};
|
|
2066
|
+
var fillFact = (gedcom, owner, event, input) => {
|
|
2067
|
+
if (input.value?.trim()) {
|
|
2068
|
+
event.value = input.value.trim();
|
|
2069
|
+
}
|
|
2070
|
+
if (input.type?.trim()) {
|
|
2071
|
+
event.set("TYPE", input.type.trim());
|
|
2072
|
+
}
|
|
2073
|
+
if (input.date) {
|
|
2074
|
+
setDateOn(gedcom, owner, event, input.date);
|
|
2075
|
+
}
|
|
2076
|
+
if (input.place?.trim()) {
|
|
2077
|
+
event.set("PLAC", input.place.trim());
|
|
2078
|
+
}
|
|
2079
|
+
if (input.note?.trim()) {
|
|
2080
|
+
event.set("NOTE", input.note.trim());
|
|
2081
|
+
}
|
|
2082
|
+
};
|
|
2083
|
+
var addIndividualFact = (indi, input) => {
|
|
2084
|
+
const gedcom = indi.getGedcom();
|
|
2085
|
+
if (!gedcom) {
|
|
2086
|
+
return void 0;
|
|
2087
|
+
}
|
|
2088
|
+
const tag = input.tag;
|
|
2089
|
+
let event = SINGLETON_TAGS.has(tag) ? firstRecord(indi.get(tag)) : void 0;
|
|
2090
|
+
if (!event) {
|
|
2091
|
+
event = createCommon(gedcom, void 0, indi);
|
|
2092
|
+
event.type = tag;
|
|
2093
|
+
if (SINGLETON_TAGS.has(tag)) {
|
|
2094
|
+
indi.set(tag, event);
|
|
2095
|
+
} else {
|
|
2096
|
+
indi.assign(tag, event);
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
fillFact(gedcom, indi, event, input);
|
|
2100
|
+
return event;
|
|
2101
|
+
};
|
|
2102
|
+
var addFamilyFact = (fam, input) => {
|
|
2103
|
+
const gedcom = fam.getGedcom();
|
|
2104
|
+
if (!gedcom) {
|
|
2105
|
+
return void 0;
|
|
2106
|
+
}
|
|
2107
|
+
const event = createCommon(gedcom, void 0, fam);
|
|
2108
|
+
event.type = input.tag;
|
|
2109
|
+
fam.assign(input.tag, event);
|
|
2110
|
+
fillFact(gedcom, fam, event, input);
|
|
2111
|
+
return event;
|
|
2112
|
+
};
|
|
2113
|
+
var addNonEvent = (owner, input) => {
|
|
2114
|
+
const gedcom = owner.getGedcom();
|
|
2115
|
+
const eventType = input.event?.trim().toUpperCase();
|
|
2116
|
+
if (!gedcom || !eventType) {
|
|
2117
|
+
return void 0;
|
|
2118
|
+
}
|
|
2119
|
+
const no = createCommon(gedcom, void 0, owner);
|
|
2120
|
+
no.type = "NO";
|
|
2121
|
+
no.value = eventType;
|
|
2122
|
+
if (input.date?.trim()) {
|
|
2123
|
+
setDateOn(gedcom, owner, no, input.date);
|
|
2124
|
+
}
|
|
2125
|
+
if (input.note?.trim()) {
|
|
2126
|
+
no.set("NOTE", input.note.trim());
|
|
2127
|
+
}
|
|
2128
|
+
owner.assign("NO", no);
|
|
2129
|
+
return no;
|
|
2397
2130
|
};
|
|
2398
2131
|
|
|
2399
2132
|
// src/utils/get-places.ts
|
|
@@ -8463,107 +8196,396 @@ var CommonDate = class extends Common {
|
|
|
8463
8196
|
);
|
|
8464
8197
|
return super.toGedcomLines(tag, level, options).filter((line) => !internal.test(line));
|
|
8465
8198
|
}
|
|
8466
|
-
inRange(range, trueIfNoYear = false) {
|
|
8467
|
-
return inRange(this.YEAR?.value, range, trueIfNoYear);
|
|
8199
|
+
inRange(range, trueIfNoYear = false) {
|
|
8200
|
+
return inRange(this.YEAR?.value, range, trueIfNoYear);
|
|
8201
|
+
}
|
|
8202
|
+
};
|
|
8203
|
+
var createCommonDate = (gedcom, id, main, parent) => {
|
|
8204
|
+
return createProxy(
|
|
8205
|
+
new CommonDate(gedcom, id, main, parent)
|
|
8206
|
+
);
|
|
8207
|
+
};
|
|
8208
|
+
var isCommonDate = (value) => {
|
|
8209
|
+
return !!value && value !== null && typeof value === "object" && "_date" in value;
|
|
8210
|
+
};
|
|
8211
|
+
|
|
8212
|
+
// src/utils/family-edit.ts
|
|
8213
|
+
var GEDCOM_MONTHS2 = [
|
|
8214
|
+
"JAN",
|
|
8215
|
+
"FEB",
|
|
8216
|
+
"MAR",
|
|
8217
|
+
"APR",
|
|
8218
|
+
"MAY",
|
|
8219
|
+
"JUN",
|
|
8220
|
+
"JUL",
|
|
8221
|
+
"AUG",
|
|
8222
|
+
"SEP",
|
|
8223
|
+
"OCT",
|
|
8224
|
+
"NOV",
|
|
8225
|
+
"DEC"
|
|
8226
|
+
];
|
|
8227
|
+
var CREATED_AT_TAG = "_CREATED_AT";
|
|
8228
|
+
var stampCreatedAt = (gedcom, indi, when = /* @__PURE__ */ new Date()) => {
|
|
8229
|
+
const existing = indi.get(CREATED_AT_TAG);
|
|
8230
|
+
if (isCommonDate(existing) && existing.rawValue instanceof Date && !Number.isNaN(existing.rawValue.getTime())) {
|
|
8231
|
+
return;
|
|
8232
|
+
}
|
|
8233
|
+
const dateNode = createCommonDate(gedcom, void 0, indi, indi);
|
|
8234
|
+
dateNode.type = CREATED_AT_TAG;
|
|
8235
|
+
dateNode.value = `${when.getDate()} ${GEDCOM_MONTHS2[when.getMonth()]} ${when.getFullYear()}`;
|
|
8236
|
+
indi.set(CREATED_AT_TAG, dateNode);
|
|
8237
|
+
};
|
|
8238
|
+
var refTypeForTag = (tag) => {
|
|
8239
|
+
if (tag === "FAMS" || tag === "FAMC") return "FAM";
|
|
8240
|
+
return "INDI";
|
|
8241
|
+
};
|
|
8242
|
+
var normalizeSinglePointer = (owner, tag) => {
|
|
8243
|
+
const node = owner.get(tag);
|
|
8244
|
+
if (!node) return;
|
|
8245
|
+
if (node instanceof List && node.length === 1) {
|
|
8246
|
+
const only = node.index(0);
|
|
8247
|
+
if (only) {
|
|
8248
|
+
owner.set(tag, only);
|
|
8249
|
+
return;
|
|
8250
|
+
}
|
|
8251
|
+
const raw = node.values()[0];
|
|
8252
|
+
if (typeof raw === "string") {
|
|
8253
|
+
const gedcom = owner.getGedcom?.();
|
|
8254
|
+
if (gedcom) {
|
|
8255
|
+
owner.set(tag, makePointer(gedcom, owner, raw, refTypeForTag(tag)));
|
|
8256
|
+
}
|
|
8257
|
+
}
|
|
8258
|
+
}
|
|
8259
|
+
};
|
|
8260
|
+
var PEDIGREE_VALUES = [
|
|
8261
|
+
"birth" /* BIRTH */,
|
|
8262
|
+
"adopted" /* ADOPTED */,
|
|
8263
|
+
"foster" /* FOSTER */,
|
|
8264
|
+
"step" /* STEP */,
|
|
8265
|
+
"sealing" /* SEALING */
|
|
8266
|
+
];
|
|
8267
|
+
var toGedcomPedigree = (value) => {
|
|
8268
|
+
const normalized = String(value || "birth" /* BIRTH */).toLowerCase();
|
|
8269
|
+
if (normalized === "biological" /* BIOLOGICAL */ || normalized === "birth" /* BIRTH */) {
|
|
8270
|
+
return "birth" /* BIRTH */;
|
|
8271
|
+
}
|
|
8272
|
+
const match = PEDIGREE_VALUES.find((item) => item === normalized);
|
|
8273
|
+
return match ?? "birth" /* BIRTH */;
|
|
8274
|
+
};
|
|
8275
|
+
var pointerIds = (tag) => {
|
|
8276
|
+
if (!tag) {
|
|
8277
|
+
return [];
|
|
8278
|
+
}
|
|
8279
|
+
if (tag instanceof List) {
|
|
8280
|
+
return tag.values().map((item) => item?.toValue?.()).filter((value2) => !!value2);
|
|
8281
|
+
}
|
|
8282
|
+
const value = tag.toValue?.();
|
|
8283
|
+
return value ? [String(value)] : [];
|
|
8284
|
+
};
|
|
8285
|
+
var firstPointerId = (tag) => pointerIds(tag)[0];
|
|
8286
|
+
var makePointer = (gedcom, parent, value, refType) => {
|
|
8287
|
+
const pointer = createCommon(gedcom, void 0, parent);
|
|
8288
|
+
pointer.value = value;
|
|
8289
|
+
pointer.refType = refType;
|
|
8290
|
+
return pointer;
|
|
8291
|
+
};
|
|
8292
|
+
var nextRecordId = (ids, prefix) => {
|
|
8293
|
+
let max = 0;
|
|
8294
|
+
ids.forEach((id) => {
|
|
8295
|
+
const match = String(id).match(/(\d+)/);
|
|
8296
|
+
const n = match ? Number.parseInt(match[1], 10) : 0;
|
|
8297
|
+
if (n > max) {
|
|
8298
|
+
max = n;
|
|
8299
|
+
}
|
|
8300
|
+
});
|
|
8301
|
+
return `@${prefix}${max + 1}@`;
|
|
8302
|
+
};
|
|
8303
|
+
var familyHasParent = (fam, indiId) => pointerIds(fam.get("HUSB")).includes(indiId) || pointerIds(fam.get("WIFE")).includes(indiId);
|
|
8304
|
+
var familyHasChild = (fam, indiId) => pointerIds(fam.get("CHIL")).includes(indiId);
|
|
8305
|
+
var spouseTagFor = (indi, fam) => {
|
|
8306
|
+
const husbId = firstPointerId(fam.get("HUSB"));
|
|
8307
|
+
const wifeId = firstPointerId(fam.get("WIFE"));
|
|
8308
|
+
if (husbId === indi.id) {
|
|
8309
|
+
return "HUSB";
|
|
8310
|
+
}
|
|
8311
|
+
if (wifeId === indi.id) {
|
|
8312
|
+
return "WIFE";
|
|
8313
|
+
}
|
|
8314
|
+
if (indi.isFemale()) {
|
|
8315
|
+
return wifeId && wifeId !== indi.id ? "HUSB" : "WIFE";
|
|
8316
|
+
}
|
|
8317
|
+
if (indi.isMale()) {
|
|
8318
|
+
return husbId && husbId !== indi.id ? "WIFE" : "HUSB";
|
|
8319
|
+
}
|
|
8320
|
+
return husbId ? "WIFE" : "HUSB";
|
|
8321
|
+
};
|
|
8322
|
+
var canAttachAsSpouse = (fam, indi) => {
|
|
8323
|
+
if (!indi.id) {
|
|
8324
|
+
return false;
|
|
8325
|
+
}
|
|
8326
|
+
if (familyHasParent(fam, indi.id)) {
|
|
8327
|
+
return true;
|
|
8328
|
+
}
|
|
8329
|
+
const tag = spouseTagFor(indi, fam);
|
|
8330
|
+
const occupied = firstPointerId(fam.get(tag));
|
|
8331
|
+
return !occupied || occupied === indi.id;
|
|
8332
|
+
};
|
|
8333
|
+
var pointerByValue = (tag, id) => {
|
|
8334
|
+
if (!tag) {
|
|
8335
|
+
return void 0;
|
|
8336
|
+
}
|
|
8337
|
+
const fromValues = tag.toValueList?.().item(id);
|
|
8338
|
+
if (fromValues) {
|
|
8339
|
+
return fromValues;
|
|
8340
|
+
}
|
|
8341
|
+
return tag.toList()?.values().find((item) => item?.toValue?.() === id);
|
|
8342
|
+
};
|
|
8343
|
+
var setChildPedigree = (fam, child, pedigree, parent) => {
|
|
8344
|
+
if (!fam.id || !child.id) {
|
|
8345
|
+
return;
|
|
8346
|
+
}
|
|
8347
|
+
const pedi = toGedcomPedigree(pedigree);
|
|
8348
|
+
const famc = pointerByValue(child.get("FAMC"), fam.id);
|
|
8349
|
+
if (famc) {
|
|
8350
|
+
famc.set("PEDI", pedi);
|
|
8351
|
+
}
|
|
8352
|
+
const chil = pointerByValue(fam.get("CHIL"), child.id);
|
|
8353
|
+
if (!chil) {
|
|
8354
|
+
return;
|
|
8355
|
+
}
|
|
8356
|
+
const setFather = !parent || parent.isMale() || parent.isUnknownSex();
|
|
8357
|
+
const setMother = !parent || parent.isFemale() || parent.isUnknownSex();
|
|
8358
|
+
if (setFather) {
|
|
8359
|
+
chil.set("_FREL", pedi);
|
|
8360
|
+
}
|
|
8361
|
+
if (setMother) {
|
|
8362
|
+
chil.set("_MREL", pedi);
|
|
8363
|
+
}
|
|
8364
|
+
};
|
|
8365
|
+
var attachSpouseToFamily = (fam, indi) => {
|
|
8366
|
+
const gedcom = fam.getGedcom() ?? indi.getGedcom();
|
|
8367
|
+
if (!indi.id || !fam.id || !gedcom) {
|
|
8368
|
+
return false;
|
|
8369
|
+
}
|
|
8370
|
+
if (!canAttachAsSpouse(fam, indi)) {
|
|
8371
|
+
return false;
|
|
8372
|
+
}
|
|
8373
|
+
const tag = spouseTagFor(indi, fam);
|
|
8374
|
+
if (firstPointerId(fam.get(tag)) !== indi.id) {
|
|
8375
|
+
fam.set(tag, makePointer(gedcom, fam, indi.id, "INDI"));
|
|
8376
|
+
}
|
|
8377
|
+
indi.assign("FAMS", makePointer(gedcom, indi, fam.id, "FAM"), true);
|
|
8378
|
+
normalizeSinglePointer(indi, "FAMS");
|
|
8379
|
+
normalizeSinglePointer(fam, spouseTagFor(indi, fam));
|
|
8380
|
+
resetRelativesCache();
|
|
8381
|
+
return true;
|
|
8382
|
+
};
|
|
8383
|
+
var attachChildToFamily = (fam, child, pedigree, parent) => {
|
|
8384
|
+
const gedcom = fam.getGedcom() ?? child.getGedcom();
|
|
8385
|
+
if (!child.id || !fam.id || !gedcom) {
|
|
8386
|
+
return false;
|
|
8387
|
+
}
|
|
8388
|
+
if (!familyHasChild(fam, child.id)) {
|
|
8389
|
+
fam.assign("CHIL", makePointer(gedcom, fam, child.id, "INDI"), true);
|
|
8390
|
+
}
|
|
8391
|
+
const existingFamc = pointerByValue(child.get("FAMC"), fam.id);
|
|
8392
|
+
if (!existingFamc) {
|
|
8393
|
+
child.assign("FAMC", makePointer(gedcom, child, fam.id, "FAM"), true);
|
|
8468
8394
|
}
|
|
8395
|
+
setChildPedigree(fam, child, pedigree, parent);
|
|
8396
|
+
normalizeSinglePointer(child, "FAMC");
|
|
8397
|
+
normalizeSinglePointer(fam, "CHIL");
|
|
8398
|
+
resetRelativesCache();
|
|
8399
|
+
return true;
|
|
8469
8400
|
};
|
|
8470
|
-
var
|
|
8471
|
-
|
|
8472
|
-
new CommonDate(gedcom, id, main, parent)
|
|
8473
|
-
);
|
|
8474
|
-
};
|
|
8475
|
-
var isCommonDate = (value) => {
|
|
8476
|
-
return !!value && value !== null && typeof value === "object" && "_date" in value;
|
|
8477
|
-
};
|
|
8478
|
-
|
|
8479
|
-
// src/utils/fact-edit.ts
|
|
8480
|
-
var SINGLETON_TAGS = /* @__PURE__ */ new Set(["BIRT", "DEAT", "SSN", "SEX", "DSCR"]);
|
|
8481
|
-
var firstRecord = (node) => {
|
|
8401
|
+
var removePointerByValue = (owner, tag, targetId) => {
|
|
8402
|
+
const node = owner.get(tag);
|
|
8482
8403
|
if (!node) {
|
|
8483
|
-
return
|
|
8404
|
+
return false;
|
|
8484
8405
|
}
|
|
8485
8406
|
if (node instanceof List) {
|
|
8486
|
-
|
|
8407
|
+
const keysToRemove = [];
|
|
8408
|
+
node.entries().forEach(([key, item]) => {
|
|
8409
|
+
if (item?.toValue?.() === targetId || item?.id === targetId || String(key) === targetId) {
|
|
8410
|
+
keysToRemove.push(key);
|
|
8411
|
+
}
|
|
8412
|
+
});
|
|
8413
|
+
keysToRemove.forEach((key) => {
|
|
8414
|
+
node.removeItem(key);
|
|
8415
|
+
});
|
|
8416
|
+
if (node.length === 0) {
|
|
8417
|
+
owner.remove(tag);
|
|
8418
|
+
}
|
|
8419
|
+
return keysToRemove.length > 0;
|
|
8487
8420
|
}
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
const trimmed = date.trim();
|
|
8492
|
-
if (!trimmed) {
|
|
8493
|
-
return;
|
|
8421
|
+
if (node.toValue?.() === targetId) {
|
|
8422
|
+
owner.remove(tag);
|
|
8423
|
+
return true;
|
|
8494
8424
|
}
|
|
8495
|
-
|
|
8496
|
-
if (
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8425
|
+
const asList = node.toList?.();
|
|
8426
|
+
if (asList && asList.length > 0) {
|
|
8427
|
+
const keysToRemove = [];
|
|
8428
|
+
asList.entries().forEach(([key, item]) => {
|
|
8429
|
+
if (item?.toValue?.() === targetId || item?.id === targetId) {
|
|
8430
|
+
keysToRemove.push(key);
|
|
8431
|
+
}
|
|
8432
|
+
});
|
|
8433
|
+
if (keysToRemove.length === asList.length) {
|
|
8434
|
+
owner.remove(tag);
|
|
8435
|
+
return true;
|
|
8436
|
+
}
|
|
8437
|
+
if (keysToRemove.length > 0) {
|
|
8438
|
+
const remaining = asList.values().filter((item) => item?.toValue?.() !== targetId);
|
|
8439
|
+
if (remaining.length === 1 && remaining[0]) {
|
|
8440
|
+
owner.set(tag, remaining[0]);
|
|
8441
|
+
} else {
|
|
8442
|
+
owner.set(tag, new List(remaining));
|
|
8443
|
+
}
|
|
8444
|
+
return true;
|
|
8445
|
+
}
|
|
8500
8446
|
}
|
|
8501
|
-
|
|
8447
|
+
return false;
|
|
8502
8448
|
};
|
|
8503
|
-
var
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
if (input.type?.trim()) {
|
|
8508
|
-
event.set("TYPE", input.type.trim());
|
|
8509
|
-
}
|
|
8510
|
-
if (input.date) {
|
|
8511
|
-
setDateOn(gedcom, owner, event, input.date);
|
|
8449
|
+
var familyMemberCount = (fam) => {
|
|
8450
|
+
let count = 0;
|
|
8451
|
+
if (firstPointerId(fam.get("HUSB"))) {
|
|
8452
|
+
count += 1;
|
|
8512
8453
|
}
|
|
8513
|
-
if (
|
|
8514
|
-
|
|
8454
|
+
if (firstPointerId(fam.get("WIFE"))) {
|
|
8455
|
+
count += 1;
|
|
8515
8456
|
}
|
|
8516
|
-
|
|
8517
|
-
|
|
8457
|
+
count += pointerIds(fam.get("CHIL")).length;
|
|
8458
|
+
return count;
|
|
8459
|
+
};
|
|
8460
|
+
var isDegenerateFamily = (fam) => familyMemberCount(fam) <= 1;
|
|
8461
|
+
var pruneEmptyFamilies = (gedcom) => {
|
|
8462
|
+
const emptyIds = [];
|
|
8463
|
+
gedcom.fams()?.forEach((fam, id) => {
|
|
8464
|
+
if (fam && isDegenerateFamily(fam) && id) {
|
|
8465
|
+
emptyIds.push(id);
|
|
8466
|
+
}
|
|
8467
|
+
});
|
|
8468
|
+
if (emptyIds.length === 0) {
|
|
8469
|
+
return [];
|
|
8518
8470
|
}
|
|
8471
|
+
gedcom.indis()?.forEach((indi) => {
|
|
8472
|
+
if (!indi) {
|
|
8473
|
+
return;
|
|
8474
|
+
}
|
|
8475
|
+
emptyIds.forEach((famId) => {
|
|
8476
|
+
removePointerByValue(indi, "FAMS", famId);
|
|
8477
|
+
removePointerByValue(indi, "FAMC", famId);
|
|
8478
|
+
});
|
|
8479
|
+
});
|
|
8480
|
+
emptyIds.forEach((famId) => {
|
|
8481
|
+
gedcom.fams()?.removeItem(famId);
|
|
8482
|
+
});
|
|
8483
|
+
return emptyIds;
|
|
8519
8484
|
};
|
|
8520
|
-
var
|
|
8521
|
-
|
|
8522
|
-
|
|
8485
|
+
var findSharedSpouseFamily = (parent, coParentId) => {
|
|
8486
|
+
let found;
|
|
8487
|
+
parent.getFamilies("FAMS")?.forEach((fam) => {
|
|
8488
|
+
if (!found && fam && familyHasParent(fam, coParentId)) {
|
|
8489
|
+
found = fam;
|
|
8490
|
+
}
|
|
8491
|
+
});
|
|
8492
|
+
return found;
|
|
8493
|
+
};
|
|
8494
|
+
var findReusableParentChildFamily = (parent, child, options) => {
|
|
8495
|
+
if (!parent.id || !child.id) {
|
|
8523
8496
|
return void 0;
|
|
8524
8497
|
}
|
|
8525
|
-
const
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8498
|
+
const reuseParentFamilies = options?.reuseParentFamilies !== false;
|
|
8499
|
+
const gedcom = parent.getGedcom() ?? child.getGedcom();
|
|
8500
|
+
let reusableFamc;
|
|
8501
|
+
let coupleFam;
|
|
8502
|
+
let already = false;
|
|
8503
|
+
const noteCoupleWith = (coParentId) => {
|
|
8504
|
+
if (!coParentId || coParentId === parent.id || coupleFam || !parent.id) {
|
|
8505
|
+
return;
|
|
8506
|
+
}
|
|
8507
|
+
const shared = findSharedSpouseFamily(parent, coParentId);
|
|
8508
|
+
if (shared) {
|
|
8509
|
+
coupleFam = shared;
|
|
8510
|
+
}
|
|
8511
|
+
};
|
|
8512
|
+
child.getFamilies("FAMC")?.forEach((fam) => {
|
|
8513
|
+
if (!fam) {
|
|
8514
|
+
return;
|
|
8515
|
+
}
|
|
8516
|
+
if (familyHasParent(fam, parent.id) && familyHasChild(fam, child.id)) {
|
|
8517
|
+
already = true;
|
|
8518
|
+
return;
|
|
8519
|
+
}
|
|
8520
|
+
pointerIds(fam.get("HUSB")).forEach(noteCoupleWith);
|
|
8521
|
+
pointerIds(fam.get("WIFE")).forEach(noteCoupleWith);
|
|
8522
|
+
if (!reusableFamc && canAttachAsSpouse(fam, parent)) {
|
|
8523
|
+
reusableFamc = fam;
|
|
8534
8524
|
}
|
|
8525
|
+
});
|
|
8526
|
+
if (already) {
|
|
8527
|
+
return "already";
|
|
8535
8528
|
}
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
}
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8529
|
+
if (coupleFam) {
|
|
8530
|
+
return coupleFam;
|
|
8531
|
+
}
|
|
8532
|
+
if (reusableFamc) {
|
|
8533
|
+
return reusableFamc;
|
|
8534
|
+
}
|
|
8535
|
+
if (options?.targetFamilyId && gedcom) {
|
|
8536
|
+
const target = gedcom.fam(options.targetFamilyId);
|
|
8537
|
+
if (target && (familyHasParent(target, parent.id) || canAttachAsSpouse(target, parent))) {
|
|
8538
|
+
return target;
|
|
8539
|
+
}
|
|
8540
|
+
}
|
|
8541
|
+
if (!reuseParentFamilies) {
|
|
8542
8542
|
return void 0;
|
|
8543
8543
|
}
|
|
8544
|
-
const
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8544
|
+
const parentFams = [];
|
|
8545
|
+
parent.getFamilies("FAMS")?.forEach((fam) => {
|
|
8546
|
+
if (fam) {
|
|
8547
|
+
parentFams.push(fam);
|
|
8548
|
+
}
|
|
8549
|
+
});
|
|
8550
|
+
if (parentFams.length === 1) {
|
|
8551
|
+
return parentFams[0];
|
|
8552
|
+
}
|
|
8553
|
+
return void 0;
|
|
8549
8554
|
};
|
|
8550
|
-
var
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
if (!gedcom || !eventType) {
|
|
8554
|
-
return void 0;
|
|
8555
|
+
var consolidateChildIntoFamily = (child, keep) => {
|
|
8556
|
+
if (!child.id || !keep.id) {
|
|
8557
|
+
return [];
|
|
8555
8558
|
}
|
|
8556
|
-
const
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8559
|
+
const keepParentIds = /* @__PURE__ */ new Set([
|
|
8560
|
+
...pointerIds(keep.get("HUSB")),
|
|
8561
|
+
...pointerIds(keep.get("WIFE"))
|
|
8562
|
+
]);
|
|
8563
|
+
const removed = [];
|
|
8564
|
+
child.getFamilies("FAMC")?.forEach((fam) => {
|
|
8565
|
+
if (!fam?.id || fam.id === keep.id) {
|
|
8566
|
+
return;
|
|
8567
|
+
}
|
|
8568
|
+
const famParentIds = [
|
|
8569
|
+
...pointerIds(fam.get("HUSB")),
|
|
8570
|
+
...pointerIds(fam.get("WIFE"))
|
|
8571
|
+
];
|
|
8572
|
+
if (famParentIds.length === 0 || !famParentIds.every((id) => keepParentIds.has(id))) {
|
|
8573
|
+
return;
|
|
8574
|
+
}
|
|
8575
|
+
removePointerByValue(fam, "CHIL", child.id);
|
|
8576
|
+
normalizeSinglePointer(fam, "CHIL");
|
|
8577
|
+
removePointerByValue(child, "FAMC", fam.id);
|
|
8578
|
+
normalizeSinglePointer(child, "FAMC");
|
|
8579
|
+
removed.push(fam.id);
|
|
8580
|
+
});
|
|
8581
|
+
const gedcom = child.getGedcom() ?? keep.getGedcom();
|
|
8582
|
+
if (gedcom && removed.length > 0) {
|
|
8583
|
+
pruneEmptyFamilies(gedcom);
|
|
8561
8584
|
}
|
|
8562
|
-
if (
|
|
8563
|
-
|
|
8585
|
+
if (removed.length > 0) {
|
|
8586
|
+
resetRelativesCache();
|
|
8564
8587
|
}
|
|
8565
|
-
|
|
8566
|
-
return no;
|
|
8588
|
+
return removed;
|
|
8567
8589
|
};
|
|
8568
8590
|
|
|
8569
8591
|
// src/classes/fam.ts
|
|
@@ -9001,7 +9023,7 @@ var createGedcomUid = () => {
|
|
|
9001
9023
|
};
|
|
9002
9024
|
|
|
9003
9025
|
// src/utils/gedcom7-metadata.ts
|
|
9004
|
-
var
|
|
9026
|
+
var GEDCOM_MONTHS3 = [
|
|
9005
9027
|
"JAN",
|
|
9006
9028
|
"FEB",
|
|
9007
9029
|
"MAR",
|
|
@@ -9017,7 +9039,7 @@ var GEDCOM_MONTHS2 = [
|
|
|
9017
9039
|
];
|
|
9018
9040
|
var formatGedcom7Timestamp = (date = /* @__PURE__ */ new Date()) => {
|
|
9019
9041
|
const day = String(date.getUTCDate());
|
|
9020
|
-
const month =
|
|
9042
|
+
const month = GEDCOM_MONTHS3[date.getUTCMonth()];
|
|
9021
9043
|
const year = String(date.getUTCFullYear());
|
|
9022
9044
|
const hh = String(date.getUTCHours()).padStart(2, "0");
|
|
9023
9045
|
const mm = String(date.getUTCMinutes()).padStart(2, "0");
|
|
@@ -9095,12 +9117,14 @@ var TREEVIZ_EXTENSION_URIS = {
|
|
|
9095
9117
|
_MTTAG: `${TREEVIZ_EXTENSION_BASE_URI}#_MTTAG`,
|
|
9096
9118
|
_MTCAT: `${TREEVIZ_EXTENSION_BASE_URI}#_MTCAT`,
|
|
9097
9119
|
_CLON: `${TREEVIZ_EXTENSION_BASE_URI}#_CLON`,
|
|
9120
|
+
_CREATED_AT: `${TREEVIZ_EXTENSION_BASE_URI}#_CREATED_AT`,
|
|
9098
9121
|
_MSER: `${TREEVIZ_EXTENSION_BASE_URI}#_MSER`,
|
|
9099
9122
|
_OID: `${TREEVIZ_EXTENSION_BASE_URI}#_OID`,
|
|
9100
9123
|
_LKID: `${TREEVIZ_EXTENSION_BASE_URI}#_LKID`,
|
|
9101
9124
|
_PHOTO_RIN: `${TREEVIZ_EXTENSION_BASE_URI}#_PHOTO_RIN`,
|
|
9102
9125
|
_EXPORTED_FROM_SITE_ID: `${TREEVIZ_EXTENSION_BASE_URI}#_EXPORTED_FROM_SITE_ID`,
|
|
9103
9126
|
_FS_ID: `${TREEVIZ_EXTENSION_BASE_URI}#_FS_ID`,
|
|
9127
|
+
_CON_INDI: `${TREEVIZ_EXTENSION_BASE_URI}#_CON_INDI`,
|
|
9104
9128
|
_FS_LINK: `${TREEVIZ_EXTENSION_BASE_URI}#_FS_LINK`,
|
|
9105
9129
|
_FS_MATCH: `${TREEVIZ_EXTENSION_BASE_URI}#_FS_MATCH`,
|
|
9106
9130
|
_FS_SOUR: `${TREEVIZ_EXTENSION_BASE_URI}#_FS_SOUR`,
|
|
@@ -9234,7 +9258,7 @@ var ensureExtensionSchema = (gedcom, extraTags) => {
|
|
|
9234
9258
|
|
|
9235
9259
|
// package.json
|
|
9236
9260
|
var package_default = {
|
|
9237
|
-
version: "2.1.
|
|
9261
|
+
version: "2.1.24"};
|
|
9238
9262
|
|
|
9239
9263
|
// src/utils/get-product-details.ts
|
|
9240
9264
|
var isDevelopment = () => {
|
|
@@ -10461,6 +10485,7 @@ var mergeGedcoms = (targetGedcom, sourceGedcom, strategy = "id") => {
|
|
|
10461
10485
|
}
|
|
10462
10486
|
} else {
|
|
10463
10487
|
if (clonedIndi.id) {
|
|
10488
|
+
stampCreatedAt(mergedGedcom, clonedIndi);
|
|
10464
10489
|
mergedGedcom.indis()?.item(clonedIndi.id, clonedIndi);
|
|
10465
10490
|
}
|
|
10466
10491
|
}
|
|
@@ -10585,7 +10610,7 @@ var create = (gedcom, type, id, nodes) => {
|
|
|
10585
10610
|
prevNode = createSour(gedcom, void 0, mainNode, curNode);
|
|
10586
10611
|
} else if (type === "OBJE") {
|
|
10587
10612
|
prevNode = createObje(gedcom, void 0, mainNode, curNode);
|
|
10588
|
-
} else if (type === "DATE") {
|
|
10613
|
+
} else if (type === "DATE" || type === "_CREATED_AT") {
|
|
10589
10614
|
prevNode = createCommonDate(gedcom, void 0, mainNode, curNode);
|
|
10590
10615
|
} else if (type === "NOTE" || type === "SNOTE" || type === "_TREEVIZ_LIFE_STORY" || type === "_TREEVIZ_FAMILY_STORY") {
|
|
10591
10616
|
prevNode = createCommonNote(gedcom, void 0, mainNode, curNode);
|
|
@@ -10612,7 +10637,12 @@ var GedcomTree = {
|
|
|
10612
10637
|
},
|
|
10613
10638
|
parseHierarchy: function(content, options) {
|
|
10614
10639
|
content = content.replace(/^\uFEFF+/, "");
|
|
10615
|
-
const {
|
|
10640
|
+
const {
|
|
10641
|
+
settings,
|
|
10642
|
+
filename = "",
|
|
10643
|
+
purgeOversized = false,
|
|
10644
|
+
maxFileSizeToPurge
|
|
10645
|
+
} = options ?? {};
|
|
10616
10646
|
const { linkedPersons = "skip", linkingKey } = settings ?? {};
|
|
10617
10647
|
const gedcom = createGedCom();
|
|
10618
10648
|
gedcom.removeValue();
|
|
@@ -10714,7 +10744,7 @@ var GedcomTree = {
|
|
|
10714
10744
|
return acc;
|
|
10715
10745
|
}, []);
|
|
10716
10746
|
let linesJoined = lines.join("\n");
|
|
10717
|
-
if (!linesJoined.includes("1 _IS_PURGED true") && getRawSize(linesJoined) >
|
|
10747
|
+
if (purgeOversized && typeof maxFileSizeToPurge === "number" && !linesJoined.includes("1 _IS_PURGED true") && getRawSize(linesJoined) > maxFileSizeToPurge) {
|
|
10718
10748
|
linesJoined = linesJoined.replace(
|
|
10719
10749
|
/1\s(NOTE|OBJE|SOUR)([^\n]*\n)([23456789]\s.+\n)*/gm,
|
|
10720
10750
|
""
|