@treeviz/gedcom-parser 1.0.13 → 1.0.15
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/index.d.ts +2 -28
- package/dist/classes/index.js +6713 -21
- package/dist/classes/index.js.map +1 -0
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +7826 -24
- package/dist/cli/index.js.map +1 -0
- package/dist/constants/index.d.ts +49 -4
- package/dist/constants/index.js +5797 -4
- package/dist/constants/index.js.map +1 -0
- package/dist/factories/index.d.ts +202 -13
- package/dist/factories/index.js +5782 -8
- package/dist/factories/index.js.map +1 -0
- package/dist/index-BvW-KWJP.d.ts +1654 -0
- package/dist/index.d.ts +9 -28
- package/dist/index.js +7380 -35
- package/dist/index.js.map +1 -0
- package/dist/interfaces/index.d.ts +2 -12
- package/dist/interfaces/index.js +3 -1
- package/dist/interfaces/index.js.map +1 -0
- package/dist/kinship-translator/index.d.ts +146 -11
- package/dist/kinship-translator/index.js +5727 -9
- package/dist/kinship-translator/index.js.map +1 -0
- package/dist/place-parser-RlXCXZ8F.d.ts +37 -0
- package/dist/structures/index.d.ts +25 -27
- package/dist/structures/index.js +3 -1
- package/dist/structures/index.js.map +1 -0
- package/dist/types/index.d.ts +69 -8
- package/dist/types/index.js +31 -6
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +91 -18
- package/dist/utils/index.js +6953 -17
- package/dist/utils/index.js.map +1 -0
- package/package.json +4 -3
- package/dist/classes/common.d.ts +0 -91
- package/dist/classes/common.d.ts.map +0 -1
- package/dist/classes/common.js +0 -488
- package/dist/classes/date.d.ts +0 -27
- package/dist/classes/date.d.ts.map +0 -1
- package/dist/classes/date.js +0 -178
- package/dist/classes/fam.d.ts +0 -19
- package/dist/classes/fam.d.ts.map +0 -1
- package/dist/classes/fam.js +0 -38
- package/dist/classes/fams.d.ts +0 -16
- package/dist/classes/fams.d.ts.map +0 -1
- package/dist/classes/fams.js +0 -41
- package/dist/classes/gedcom.d.ts +0 -139
- package/dist/classes/gedcom.d.ts.map +0 -1
- package/dist/classes/gedcom.js +0 -910
- package/dist/classes/index.d.ts.map +0 -1
- package/dist/classes/indi.d.ts +0 -323
- package/dist/classes/indi.d.ts.map +0 -1
- package/dist/classes/indi.js +0 -2131
- package/dist/classes/indis.d.ts +0 -55
- package/dist/classes/indis.d.ts.map +0 -1
- package/dist/classes/indis.js +0 -457
- package/dist/classes/list.d.ts +0 -55
- package/dist/classes/list.d.ts.map +0 -1
- package/dist/classes/list.js +0 -440
- package/dist/classes/name.d.ts +0 -20
- package/dist/classes/name.d.ts.map +0 -1
- package/dist/classes/name.js +0 -48
- package/dist/classes/note.d.ts +0 -12
- package/dist/classes/note.d.ts.map +0 -1
- package/dist/classes/note.js +0 -46
- package/dist/classes/obje.d.ts +0 -12
- package/dist/classes/obje.d.ts.map +0 -1
- package/dist/classes/obje.js +0 -81
- package/dist/classes/objes.d.ts +0 -8
- package/dist/classes/objes.d.ts.map +0 -1
- package/dist/classes/objes.js +0 -13
- package/dist/classes/repo.d.ts +0 -11
- package/dist/classes/repo.d.ts.map +0 -1
- package/dist/classes/repo.js +0 -6
- package/dist/classes/repos.d.ts +0 -8
- package/dist/classes/repos.d.ts.map +0 -1
- package/dist/classes/repos.js +0 -13
- package/dist/classes/sour.d.ts +0 -11
- package/dist/classes/sour.d.ts.map +0 -1
- package/dist/classes/sour.js +0 -6
- package/dist/classes/sours.d.ts +0 -8
- package/dist/classes/sours.d.ts.map +0 -1
- package/dist/classes/sours.js +0 -13
- package/dist/classes/subm.d.ts +0 -10
- package/dist/classes/subm.d.ts.map +0 -1
- package/dist/classes/subm.js +0 -6
- package/dist/classes/subms.d.ts +0 -8
- package/dist/classes/subms.d.ts.map +0 -1
- package/dist/classes/subms.js +0 -13
- package/dist/cli/commands/convert.d.ts +0 -3
- package/dist/cli/commands/convert.d.ts.map +0 -1
- package/dist/cli/commands/convert.js +0 -83
- package/dist/cli/commands/extract.d.ts +0 -3
- package/dist/cli/commands/extract.d.ts.map +0 -1
- package/dist/cli/commands/extract.js +0 -85
- package/dist/cli/commands/find.d.ts +0 -3
- package/dist/cli/commands/find.d.ts.map +0 -1
- package/dist/cli/commands/find.js +0 -97
- package/dist/cli/commands/info.d.ts +0 -3
- package/dist/cli/commands/info.d.ts.map +0 -1
- package/dist/cli/commands/info.js +0 -80
- package/dist/cli/commands/merge.d.ts +0 -3
- package/dist/cli/commands/merge.d.ts.map +0 -1
- package/dist/cli/commands/merge.js +0 -61
- package/dist/cli/commands/relatives.d.ts +0 -3
- package/dist/cli/commands/relatives.d.ts.map +0 -1
- package/dist/cli/commands/relatives.js +0 -107
- package/dist/cli/commands/show.d.ts +0 -3
- package/dist/cli/commands/show.d.ts.map +0 -1
- package/dist/cli/commands/show.js +0 -176
- package/dist/cli/commands/stats.d.ts +0 -3
- package/dist/cli/commands/stats.d.ts.map +0 -1
- package/dist/cli/commands/stats.js +0 -59
- package/dist/cli/commands/validate.d.ts +0 -3
- package/dist/cli/commands/validate.d.ts.map +0 -1
- package/dist/cli/commands/validate.js +0 -148
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/utils/formatters.d.ts +0 -69
- package/dist/cli/utils/formatters.d.ts.map +0 -1
- package/dist/cli/utils/formatters.js +0 -125
- package/dist/cli/utils/helpers.d.ts +0 -21
- package/dist/cli/utils/helpers.d.ts.map +0 -1
- package/dist/cli/utils/helpers.js +0 -58
- package/dist/constants/constants.d.ts +0 -14
- package/dist/constants/constants.d.ts.map +0 -1
- package/dist/constants/constants.js +0 -13
- package/dist/constants/filters.d.ts +0 -18
- package/dist/constants/filters.d.ts.map +0 -1
- package/dist/constants/filters.js +0 -44
- package/dist/constants/index.d.ts.map +0 -1
- package/dist/constants/orders.d.ts +0 -17
- package/dist/constants/orders.d.ts.map +0 -1
- package/dist/constants/orders.js +0 -240
- package/dist/factories/cache-factory.d.ts +0 -30
- package/dist/factories/cache-factory.d.ts.map +0 -1
- package/dist/factories/cache-factory.js +0 -43
- package/dist/factories/date-locale-factory.d.ts +0 -30
- package/dist/factories/date-locale-factory.d.ts.map +0 -1
- package/dist/factories/date-locale-factory.js +0 -34
- package/dist/factories/i18n-factory.d.ts +0 -40
- package/dist/factories/i18n-factory.d.ts.map +0 -1
- package/dist/factories/i18n-factory.js +0 -44
- package/dist/factories/index.d.ts.map +0 -1
- package/dist/factories/kinship-factory.d.ts +0 -38
- package/dist/factories/kinship-factory.d.ts.map +0 -1
- package/dist/factories/kinship-factory.js +0 -35
- package/dist/factories/place-parser-provider.d.ts +0 -32
- package/dist/factories/place-parser-provider.d.ts.map +0 -1
- package/dist/factories/place-parser-provider.js +0 -35
- package/dist/factories/place-translator-provider.d.ts +0 -32
- package/dist/factories/place-translator-provider.d.ts.map +0 -1
- package/dist/factories/place-translator-provider.js +0 -35
- package/dist/index.d.ts.map +0 -1
- package/dist/interfaces/common.d.ts +0 -43
- package/dist/interfaces/common.d.ts.map +0 -1
- package/dist/interfaces/common.js +0 -1
- package/dist/interfaces/fam.d.ts +0 -11
- package/dist/interfaces/fam.d.ts.map +0 -1
- package/dist/interfaces/fam.js +0 -1
- package/dist/interfaces/fams.d.ts +0 -9
- package/dist/interfaces/fams.d.ts.map +0 -1
- package/dist/interfaces/fams.js +0 -1
- package/dist/interfaces/gedcom.d.ts +0 -30
- package/dist/interfaces/gedcom.d.ts.map +0 -1
- package/dist/interfaces/gedcom.js +0 -1
- package/dist/interfaces/index.d.ts.map +0 -1
- package/dist/interfaces/indi.d.ts +0 -113
- package/dist/interfaces/indi.d.ts.map +0 -1
- package/dist/interfaces/indi.js +0 -1
- package/dist/interfaces/indis.d.ts +0 -31
- package/dist/interfaces/indis.d.ts.map +0 -1
- package/dist/interfaces/indis.js +0 -1
- package/dist/interfaces/list.d.ts +0 -52
- package/dist/interfaces/list.d.ts.map +0 -1
- package/dist/interfaces/list.js +0 -1
- package/dist/interfaces/obje.d.ts +0 -7
- package/dist/interfaces/obje.d.ts.map +0 -1
- package/dist/interfaces/obje.js +0 -1
- package/dist/interfaces/repo.d.ts +0 -7
- package/dist/interfaces/repo.d.ts.map +0 -1
- package/dist/interfaces/repo.js +0 -1
- package/dist/interfaces/sour.d.ts +0 -7
- package/dist/interfaces/sour.d.ts.map +0 -1
- package/dist/interfaces/sour.js +0 -1
- package/dist/interfaces/subm.d.ts +0 -6
- package/dist/interfaces/subm.d.ts.map +0 -1
- package/dist/interfaces/subm.js +0 -1
- package/dist/kinship-translator/index.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.basic.d.ts +0 -30
- package/dist/kinship-translator/kinship-translator.basic.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.basic.js +0 -74
- package/dist/kinship-translator/kinship-translator.d.ts +0 -26
- package/dist/kinship-translator/kinship-translator.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.de.d.ts +0 -18
- package/dist/kinship-translator/kinship-translator.de.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.de.js +0 -180
- package/dist/kinship-translator/kinship-translator.en.d.ts +0 -18
- package/dist/kinship-translator/kinship-translator.en.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.en.js +0 -182
- package/dist/kinship-translator/kinship-translator.es.d.ts +0 -18
- package/dist/kinship-translator/kinship-translator.es.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.es.js +0 -181
- package/dist/kinship-translator/kinship-translator.fr.d.ts +0 -18
- package/dist/kinship-translator/kinship-translator.fr.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.fr.js +0 -181
- package/dist/kinship-translator/kinship-translator.hu.d.ts +0 -19
- package/dist/kinship-translator/kinship-translator.hu.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.hu.js +0 -226
- package/dist/kinship-translator/kinship-translator.interface.d.ts +0 -19
- package/dist/kinship-translator/kinship-translator.interface.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.interface.js +0 -1
- package/dist/kinship-translator/kinship-translator.js +0 -103
- package/dist/kinship-translator/patterns.de.d.ts +0 -2
- package/dist/kinship-translator/patterns.de.d.ts.map +0 -1
- package/dist/kinship-translator/patterns.de.js +0 -14
- package/dist/kinship-translator/patterns.en.d.ts +0 -2
- package/dist/kinship-translator/patterns.en.d.ts.map +0 -1
- package/dist/kinship-translator/patterns.en.js +0 -14
- package/dist/kinship-translator/patterns.es.d.ts +0 -2
- package/dist/kinship-translator/patterns.es.d.ts.map +0 -1
- package/dist/kinship-translator/patterns.es.js +0 -14
- package/dist/kinship-translator/patterns.fr.d.ts +0 -2
- package/dist/kinship-translator/patterns.fr.d.ts.map +0 -1
- package/dist/kinship-translator/patterns.fr.js +0 -14
- package/dist/kinship-translator/patterns.hu.d.ts +0 -6
- package/dist/kinship-translator/patterns.hu.d.ts.map +0 -1
- package/dist/kinship-translator/patterns.hu.js +0 -97
- package/dist/kinship-translator/translators.d.ts +0 -6
- package/dist/kinship-translator/translators.d.ts.map +0 -1
- package/dist/kinship-translator/translators.js +0 -5
- package/dist/kinship-translator/types.d.ts +0 -9
- package/dist/kinship-translator/types.d.ts.map +0 -1
- package/dist/kinship-translator/types.js +0 -1
- package/dist/structures/address.d.ts +0 -14
- package/dist/structures/address.d.ts.map +0 -1
- package/dist/structures/address.js +0 -1
- package/dist/structures/association.d.ts +0 -13
- package/dist/structures/association.d.ts.map +0 -1
- package/dist/structures/association.js +0 -1
- package/dist/structures/change-date.d.ts +0 -8
- package/dist/structures/change-date.d.ts.map +0 -1
- package/dist/structures/change-date.js +0 -1
- package/dist/structures/creation-date.d.ts +0 -7
- package/dist/structures/creation-date.d.ts.map +0 -1
- package/dist/structures/creation-date.js +0 -1
- package/dist/structures/date.d.ts +0 -9
- package/dist/structures/date.d.ts.map +0 -1
- package/dist/structures/date.js +0 -1
- package/dist/structures/event-detail-structure.d.ts +0 -25
- package/dist/structures/event-detail-structure.d.ts.map +0 -1
- package/dist/structures/event-detail-structure.js +0 -1
- package/dist/structures/family.d.ts +0 -34
- package/dist/structures/family.d.ts.map +0 -1
- package/dist/structures/family.js +0 -1
- package/dist/structures/gedcom.d.ts +0 -59
- package/dist/structures/gedcom.d.ts.map +0 -1
- package/dist/structures/gedcom.js +0 -1
- package/dist/structures/index.d.ts.map +0 -1
- package/dist/structures/individual-event-detail-structure.d.ts +0 -9
- package/dist/structures/individual-event-detail-structure.d.ts.map +0 -1
- package/dist/structures/individual-event-detail-structure.js +0 -1
- package/dist/structures/individual-event-structure.d.ts +0 -83
- package/dist/structures/individual-event-structure.d.ts.map +0 -1
- package/dist/structures/individual-event-structure.js +0 -1
- package/dist/structures/individual.d.ts +0 -40
- package/dist/structures/individual.d.ts.map +0 -1
- package/dist/structures/individual.js +0 -1
- package/dist/structures/lds-ordinance-detail.d.ts +0 -17
- package/dist/structures/lds-ordinance-detail.d.ts.map +0 -1
- package/dist/structures/lds-ordinance-detail.js +0 -1
- package/dist/structures/lds-spouse-sealing.d.ts +0 -7
- package/dist/structures/lds-spouse-sealing.d.ts.map +0 -1
- package/dist/structures/lds-spouse-sealing.js +0 -1
- package/dist/structures/marriage-date.d.ts +0 -11
- package/dist/structures/marriage-date.d.ts.map +0 -1
- package/dist/structures/marriage-date.js +0 -1
- package/dist/structures/multimedia-link.d.ts +0 -16
- package/dist/structures/multimedia-link.d.ts.map +0 -1
- package/dist/structures/multimedia-link.js +0 -1
- package/dist/structures/non-event.d.ts +0 -12
- package/dist/structures/non-event.d.ts.map +0 -1
- package/dist/structures/non-event.js +0 -1
- package/dist/structures/note.d.ts +0 -16
- package/dist/structures/note.d.ts.map +0 -1
- package/dist/structures/note.js +0 -1
- package/dist/structures/personal-name-pieces.d.ts +0 -11
- package/dist/structures/personal-name-pieces.d.ts.map +0 -1
- package/dist/structures/personal-name-pieces.js +0 -1
- package/dist/structures/personal-name.d.ts +0 -16
- package/dist/structures/personal-name.d.ts.map +0 -1
- package/dist/structures/personal-name.js +0 -1
- package/dist/structures/place.d.ts +0 -20
- package/dist/structures/place.d.ts.map +0 -1
- package/dist/structures/place.js +0 -1
- package/dist/structures/repository.d.ts +0 -6
- package/dist/structures/repository.d.ts.map +0 -1
- package/dist/structures/repository.js +0 -1
- package/dist/structures/source-citation.d.ts +0 -27
- package/dist/structures/source-citation.d.ts.map +0 -1
- package/dist/structures/source-citation.js +0 -1
- package/dist/structures/source-repository-citation.d.ts +0 -13
- package/dist/structures/source-repository-citation.d.ts.map +0 -1
- package/dist/structures/source-repository-citation.js +0 -1
- package/dist/structures/source.d.ts +0 -28
- package/dist/structures/source.d.ts.map +0 -1
- package/dist/structures/source.js +0 -1
- package/dist/types/ancestry-media.d.ts +0 -65
- package/dist/types/ancestry-media.d.ts.map +0 -1
- package/dist/types/ancestry-media.js +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/settings.d.ts +0 -12
- package/dist/types/settings.d.ts.map +0 -1
- package/dist/types/settings.js +0 -1
- package/dist/types/types.d.ts +0 -225
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/types.js +0 -26
- package/dist/utils/cache.d.ts +0 -22
- package/dist/utils/cache.d.ts.map +0 -1
- package/dist/utils/cache.js +0 -57
- package/dist/utils/common-creator.d.ts +0 -13
- package/dist/utils/common-creator.d.ts.map +0 -1
- package/dist/utils/common-creator.js +0 -72
- package/dist/utils/date-formatter.d.ts +0 -35
- package/dist/utils/date-formatter.d.ts.map +0 -1
- package/dist/utils/date-formatter.js +0 -207
- package/dist/utils/get-all-prop.d.ts +0 -4
- package/dist/utils/get-all-prop.d.ts.map +0 -1
- package/dist/utils/get-all-prop.js +0 -5
- package/dist/utils/get-family-with.d.ts +0 -5
- package/dist/utils/get-family-with.d.ts.map +0 -1
- package/dist/utils/get-family-with.js +0 -11
- package/dist/utils/get-places.d.ts +0 -21
- package/dist/utils/get-places.d.ts.map +0 -1
- package/dist/utils/get-places.js +0 -77
- package/dist/utils/get-product-details.d.ts +0 -4
- package/dist/utils/get-product-details.d.ts.map +0 -1
- package/dist/utils/get-product-details.js +0 -6
- package/dist/utils/get-raw-size.d.ts +0 -2
- package/dist/utils/get-raw-size.d.ts.map +0 -1
- package/dist/utils/get-raw-size.js +0 -3
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/logger.d.ts +0 -3
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -11
- package/dist/utils/name-formatter.d.ts +0 -10
- package/dist/utils/name-formatter.d.ts.map +0 -1
- package/dist/utils/name-formatter.js +0 -45
- package/dist/utils/nested-group.d.ts +0 -4
- package/dist/utils/nested-group.d.ts.map +0 -1
- package/dist/utils/nested-group.js +0 -34
- package/dist/utils/ordinalize.d.ts +0 -3
- package/dist/utils/ordinalize.d.ts.map +0 -1
- package/dist/utils/ordinalize.js +0 -104
- package/dist/utils/parser.d.ts +0 -17
- package/dist/utils/parser.d.ts.map +0 -1
- package/dist/utils/parser.js +0 -321
- package/dist/utils/place-parser.d.ts +0 -16
- package/dist/utils/place-parser.d.ts.map +0 -1
- package/dist/utils/place-parser.js +0 -46
- package/dist/utils/place-translator.d.ts +0 -6
- package/dist/utils/place-translator.d.ts.map +0 -1
- package/dist/utils/place-translator.js +0 -8
- package/dist/utils/place-types.d.ts +0 -27
- package/dist/utils/place-types.d.ts.map +0 -1
- package/dist/utils/place-types.js +0 -14
- package/dist/utils/range.d.ts +0 -19
- package/dist/utils/range.d.ts.map +0 -1
- package/dist/utils/range.js +0 -265
package/dist/classes/indi.js
DELETED
|
@@ -1,2131 +0,0 @@
|
|
|
1
|
-
import * as Filters from "../constants/filters.js";
|
|
2
|
-
import { BIRTH_ASC, DATE_ASC, getMarriageAscAndChildBirth, } from "../constants/orders.js";
|
|
3
|
-
import { getKinshipTranslatorClass } from "../factories/kinship-factory.js";
|
|
4
|
-
import { RelationType, PartnerType } from "../types/types.js";
|
|
5
|
-
import { pathCache, relativesCache } from "../utils/cache.js";
|
|
6
|
-
import { dateFormatter } from "../utils/date-formatter.js";
|
|
7
|
-
import { PlaceType, getPlaces } from "../utils/get-places.js";
|
|
8
|
-
import { implemented } from "../utils/logger.js";
|
|
9
|
-
import { Common, createCommon, createProxy } from "./common.js";
|
|
10
|
-
import { Families } from "./fams.js";
|
|
11
|
-
import { Individuals } from "./indis.js";
|
|
12
|
-
import { List } from "./list.js";
|
|
13
|
-
import { CommonName, createCommonName } from "./name.js";
|
|
14
|
-
export var Existed;
|
|
15
|
-
(function (Existed) {
|
|
16
|
-
Existed["SPOUSE"] = "spouse";
|
|
17
|
-
Existed["YES"] = "yes";
|
|
18
|
-
})(Existed || (Existed = {}));
|
|
19
|
-
export var CustomTags;
|
|
20
|
-
(function (CustomTags) {
|
|
21
|
-
CustomTags["UnknownGivenname"] = "Unknown givenname";
|
|
22
|
-
CustomTags["UnknownSurname"] = "Unknown surname";
|
|
23
|
-
CustomTags["UnattachedMember"] = "Unattached member";
|
|
24
|
-
CustomTags["IgnoredMember"] = "Ignored member";
|
|
25
|
-
CustomTags["UnknownAncestor"] = "Unknown Ancestor";
|
|
26
|
-
})(CustomTags || (CustomTags = {}));
|
|
27
|
-
const ALLOWED_FACTS = [
|
|
28
|
-
"EVEN",
|
|
29
|
-
"OCCU",
|
|
30
|
-
"OCCUPATIONS",
|
|
31
|
-
"RESI",
|
|
32
|
-
"BAPT",
|
|
33
|
-
"CHRI",
|
|
34
|
-
"CHR",
|
|
35
|
-
"BURI",
|
|
36
|
-
"EDUC",
|
|
37
|
-
"GRAD",
|
|
38
|
-
"DIV",
|
|
39
|
-
"IMMI",
|
|
40
|
-
"RELI",
|
|
41
|
-
"_MILT",
|
|
42
|
-
"_MILTID",
|
|
43
|
-
"FACT",
|
|
44
|
-
"_ORIG",
|
|
45
|
-
];
|
|
46
|
-
const DISALLOWED_CUSTOM_FACTS = ["DNA Test", "Newspaper"];
|
|
47
|
-
const CustomFactRenderers = {
|
|
48
|
-
AKA: (label, fact, indi) => {
|
|
49
|
-
const originalNameObj = indi?.NAME;
|
|
50
|
-
const note = fact.get("NOTE");
|
|
51
|
-
const factName = note?.toValue();
|
|
52
|
-
const name = createCommonName(fact.getGedcom(), undefined, indi);
|
|
53
|
-
const suffix = originalNameObj?.NSFX?.toValue();
|
|
54
|
-
const surname = originalNameObj?.SURN?.toValue();
|
|
55
|
-
const givenname = originalNameObj?.GIVN?.toValue();
|
|
56
|
-
const nameParts = [
|
|
57
|
-
...(givenname
|
|
58
|
-
?.split(" ")
|
|
59
|
-
.map((s) => ({ name: s, givenname: true })) ?? []),
|
|
60
|
-
...(surname?.split(" ").map((s) => ({ name: s, surname: true })) ??
|
|
61
|
-
[]),
|
|
62
|
-
...(suffix?.split(" ").map((s) => ({ name: s, suffix: true })) ??
|
|
63
|
-
[]),
|
|
64
|
-
].filter(Boolean);
|
|
65
|
-
const factParts = factName?.split(" ");
|
|
66
|
-
if (nameParts.length === factParts?.length &&
|
|
67
|
-
!(note instanceof CommonName)) {
|
|
68
|
-
const guessedSuffix = [];
|
|
69
|
-
const guessedSurname = [];
|
|
70
|
-
const guessedGivenname = [];
|
|
71
|
-
factParts.forEach((f, i) => {
|
|
72
|
-
const namePart = nameParts[i];
|
|
73
|
-
if (!f) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (namePart.suffix) {
|
|
77
|
-
guessedSuffix.push(f);
|
|
78
|
-
}
|
|
79
|
-
else if (namePart.givenname) {
|
|
80
|
-
guessedGivenname.push(f);
|
|
81
|
-
}
|
|
82
|
-
else if (namePart.surname) {
|
|
83
|
-
guessedSurname.push(f);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
const allNamePart = [];
|
|
87
|
-
if (guessedGivenname.length) {
|
|
88
|
-
allNamePart.push(guessedGivenname.join(" "));
|
|
89
|
-
}
|
|
90
|
-
if (guessedSurname.length) {
|
|
91
|
-
allNamePart.push(`/${guessedSurname.join(" ")}/`);
|
|
92
|
-
}
|
|
93
|
-
if (guessedSuffix.length) {
|
|
94
|
-
allNamePart.push(guessedSuffix.join(" "));
|
|
95
|
-
}
|
|
96
|
-
name.value = allNamePart.join(" ");
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
name.value = factName;
|
|
100
|
-
}
|
|
101
|
-
fact.set("NOTE", name);
|
|
102
|
-
label.value = "AKA";
|
|
103
|
-
fact.set("_LABEL", label);
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
const relativesOnLevelCache = relativesCache("relativesOnLevelCache");
|
|
107
|
-
const relativesOnDegreeCache = relativesCache("relativesOnDegreeCache");
|
|
108
|
-
export class Indi extends Common {
|
|
109
|
-
toName() {
|
|
110
|
-
return this.get("NAME")?.toValue();
|
|
111
|
-
}
|
|
112
|
-
toNaturalName() {
|
|
113
|
-
return this.get("NAME")?.toValue()?.replaceAll("/", "");
|
|
114
|
-
}
|
|
115
|
-
toList() {
|
|
116
|
-
return new Individuals().concat(
|
|
117
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
-
this.id ? { [this.id]: this } : { ...[this] });
|
|
119
|
-
}
|
|
120
|
-
generateTree(props) {
|
|
121
|
-
const { generations, level, index, showDescendants, offspringSpouses, ancestorSpouses, onlyDescendants, maxLevel, minLevel, drawNonBiologicalAncestors, ancestorSiblings, } = props;
|
|
122
|
-
if (!this.id) {
|
|
123
|
-
throw new Error("Indi must have an id");
|
|
124
|
-
}
|
|
125
|
-
const isMainDescendantLevel = showDescendants && level <= 1;
|
|
126
|
-
const isDescendantLevel = showDescendants && level < 1;
|
|
127
|
-
if (level < 1 && !isDescendantLevel) {
|
|
128
|
-
throw new Error("Arguments 2 must be greater than 0.");
|
|
129
|
-
}
|
|
130
|
-
if ((maxLevel !== undefined && maxLevel < level) ||
|
|
131
|
-
(minLevel !== undefined && minLevel > level)) {
|
|
132
|
-
return this;
|
|
133
|
-
}
|
|
134
|
-
// Only for debug
|
|
135
|
-
// if (level > 3) {
|
|
136
|
-
// return this;
|
|
137
|
-
// }
|
|
138
|
-
const gens = generations ?? {
|
|
139
|
-
existed: {},
|
|
140
|
-
tree: {},
|
|
141
|
-
halves: {},
|
|
142
|
-
lastItems: {},
|
|
143
|
-
};
|
|
144
|
-
const families = this.getFamiliesBiologicalFirst("FAMC");
|
|
145
|
-
const familiesAllMember = families.getParents();
|
|
146
|
-
families.forEach((fam, famKey, famIndex) => {
|
|
147
|
-
if (!this.id) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
const id = fam.id;
|
|
151
|
-
let father = isDescendantLevel
|
|
152
|
-
? undefined
|
|
153
|
-
: fam.getHusband().index(0);
|
|
154
|
-
let mother = isDescendantLevel ? undefined : fam.getWife().index(0);
|
|
155
|
-
const children = isMainDescendantLevel && famIndex > 0
|
|
156
|
-
? this.getChildren()
|
|
157
|
-
: undefined;
|
|
158
|
-
if (father?.id &&
|
|
159
|
-
(gens.existed[father.id] === Existed.YES ||
|
|
160
|
-
(!drawNonBiologicalAncestors &&
|
|
161
|
-
this.getParentType(father.id) !==
|
|
162
|
-
RelationType.BIOLOGICAL))) {
|
|
163
|
-
// console.info(
|
|
164
|
-
// "Father already in tree",
|
|
165
|
-
// father.toName(),
|
|
166
|
-
// father,
|
|
167
|
-
// gens.existed[father.id]
|
|
168
|
-
// );
|
|
169
|
-
father = undefined;
|
|
170
|
-
}
|
|
171
|
-
if (mother?.id &&
|
|
172
|
-
(gens.existed[mother.id] === Existed.YES ||
|
|
173
|
-
(!drawNonBiologicalAncestors &&
|
|
174
|
-
this.getParentType(mother.id) !==
|
|
175
|
-
RelationType.BIOLOGICAL))) {
|
|
176
|
-
// console.info(
|
|
177
|
-
// "Mother already in tree",
|
|
178
|
-
// mother.toName(),
|
|
179
|
-
// mother,
|
|
180
|
-
// gens.existed[mother.id]
|
|
181
|
-
// );
|
|
182
|
-
mother = undefined;
|
|
183
|
-
}
|
|
184
|
-
if (!id &&
|
|
185
|
-
!father &&
|
|
186
|
-
!mother &&
|
|
187
|
-
(!children?.length || famIndex > 0)) {
|
|
188
|
-
return this;
|
|
189
|
-
}
|
|
190
|
-
let fatherSpouses;
|
|
191
|
-
if (father && ancestorSpouses) {
|
|
192
|
-
fatherSpouses = father
|
|
193
|
-
.getCoParents()
|
|
194
|
-
.orderBy(getMarriageAscAndChildBirth(father.id));
|
|
195
|
-
if (drawNonBiologicalAncestors) {
|
|
196
|
-
fatherSpouses = fatherSpouses
|
|
197
|
-
.copy()
|
|
198
|
-
.exclude(familiesAllMember);
|
|
199
|
-
}
|
|
200
|
-
if (mother) {
|
|
201
|
-
fatherSpouses = fatherSpouses.except(mother);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
let motherSpouses;
|
|
205
|
-
if (mother && ancestorSpouses) {
|
|
206
|
-
motherSpouses = mother
|
|
207
|
-
.getCoParents()
|
|
208
|
-
.orderBy(getMarriageAscAndChildBirth(mother.id));
|
|
209
|
-
if (drawNonBiologicalAncestors) {
|
|
210
|
-
motherSpouses = motherSpouses
|
|
211
|
-
.copy()
|
|
212
|
-
.exclude(familiesAllMember);
|
|
213
|
-
}
|
|
214
|
-
if (father) {
|
|
215
|
-
motherSpouses = motherSpouses.except(father);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
let childIndex = 0;
|
|
219
|
-
const amount = Math.pow(2, level - 1);
|
|
220
|
-
const half = Math.floor(amount / 2);
|
|
221
|
-
const closers = {
|
|
222
|
-
id: id || this.id,
|
|
223
|
-
index,
|
|
224
|
-
father: isDescendantLevel
|
|
225
|
-
? this.isMale()
|
|
226
|
-
? this
|
|
227
|
-
: undefined
|
|
228
|
-
: onlyDescendants
|
|
229
|
-
? undefined
|
|
230
|
-
: father?.generateTree({
|
|
231
|
-
generations: gens,
|
|
232
|
-
level: level + 1,
|
|
233
|
-
famIndex: famIndex * 2,
|
|
234
|
-
index: index * 2,
|
|
235
|
-
ancestorSpouses,
|
|
236
|
-
ancestorSiblings,
|
|
237
|
-
maxLevel,
|
|
238
|
-
minLevel,
|
|
239
|
-
drawNonBiologicalAncestors,
|
|
240
|
-
}),
|
|
241
|
-
fatherSpouses: fatherSpouses &&
|
|
242
|
-
(fatherSpouses.values() ?? []),
|
|
243
|
-
mother: isDescendantLevel
|
|
244
|
-
? this.isFemale()
|
|
245
|
-
? this
|
|
246
|
-
: undefined
|
|
247
|
-
: onlyDescendants
|
|
248
|
-
? undefined
|
|
249
|
-
: mother?.generateTree({
|
|
250
|
-
generations: gens,
|
|
251
|
-
level: level + 1,
|
|
252
|
-
famIndex: famIndex * 2,
|
|
253
|
-
index: index * 2 + (famIndex > 0 ? 0 : 1),
|
|
254
|
-
ancestorSpouses,
|
|
255
|
-
ancestorSiblings,
|
|
256
|
-
maxLevel,
|
|
257
|
-
minLevel,
|
|
258
|
-
drawNonBiologicalAncestors,
|
|
259
|
-
}),
|
|
260
|
-
motherSpouses: motherSpouses &&
|
|
261
|
-
(motherSpouses.values() ?? []),
|
|
262
|
-
children: children
|
|
263
|
-
?.map((descendant) => {
|
|
264
|
-
const descendantTree = descendant.generateTree({
|
|
265
|
-
generations: gens,
|
|
266
|
-
level: level === 1 ? -1 : level - 1,
|
|
267
|
-
famIndex: 0,
|
|
268
|
-
index: childIndex++,
|
|
269
|
-
showDescendants: true,
|
|
270
|
-
offspringSpouses,
|
|
271
|
-
maxLevel,
|
|
272
|
-
minLevel,
|
|
273
|
-
});
|
|
274
|
-
if (offspringSpouses) {
|
|
275
|
-
const spousesTrees = descendant
|
|
276
|
-
.getCoParents()
|
|
277
|
-
.orderBy(getMarriageAscAndChildBirth(descendant.id))
|
|
278
|
-
.map((spouse) => {
|
|
279
|
-
return spouse.generateTree({
|
|
280
|
-
generations: gens,
|
|
281
|
-
level: level === 1 ? -1 : level - 1,
|
|
282
|
-
famIndex: 0,
|
|
283
|
-
index: childIndex++,
|
|
284
|
-
showDescendants: true,
|
|
285
|
-
offspringSpouses,
|
|
286
|
-
maxLevel,
|
|
287
|
-
minLevel,
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
return [descendantTree, ...spousesTrees];
|
|
291
|
-
}
|
|
292
|
-
return [descendantTree];
|
|
293
|
-
})
|
|
294
|
-
.flat(),
|
|
295
|
-
};
|
|
296
|
-
if (!gens.tree[level]) {
|
|
297
|
-
gens.tree[level] = [];
|
|
298
|
-
}
|
|
299
|
-
if (level < 0) {
|
|
300
|
-
gens.tree[level].push(closers);
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
if (index >= half && gens.halves[level] === undefined) {
|
|
304
|
-
gens.halves[level] = gens.tree[level].length;
|
|
305
|
-
}
|
|
306
|
-
gens.tree[level].push(closers);
|
|
307
|
-
gens.lastItems[level] = closers;
|
|
308
|
-
}
|
|
309
|
-
if (father?.id) {
|
|
310
|
-
gens.existed[father.id] = Existed.YES;
|
|
311
|
-
}
|
|
312
|
-
if (mother?.id) {
|
|
313
|
-
gens.existed[mother.id] = Existed.YES;
|
|
314
|
-
}
|
|
315
|
-
closers.children?.forEach(({ id }) => {
|
|
316
|
-
if (id) {
|
|
317
|
-
gens.existed[id] = Existed.YES;
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
[
|
|
321
|
-
...(closers.fatherSpouses ?? []),
|
|
322
|
-
...(closers.motherSpouses ?? []),
|
|
323
|
-
]?.forEach(({ id }) => {
|
|
324
|
-
if (id) {
|
|
325
|
-
gens.existed[id] = Existed.SPOUSE;
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
});
|
|
329
|
-
return this;
|
|
330
|
-
}
|
|
331
|
-
getPlaces(type = [PlaceType.All], maxLevel = 1) {
|
|
332
|
-
if (!this._gedcom || !this.id) {
|
|
333
|
-
return [];
|
|
334
|
-
}
|
|
335
|
-
const cacheKey = JSON.stringify(type);
|
|
336
|
-
if (this._places?.[cacheKey]) {
|
|
337
|
-
return this._places[cacheKey];
|
|
338
|
-
}
|
|
339
|
-
let marriages;
|
|
340
|
-
if (type?.includes(PlaceType.Marriage) ||
|
|
341
|
-
type?.includes(PlaceType.All)) {
|
|
342
|
-
const families = this.getFamilies("FAMS");
|
|
343
|
-
// if (families.length === 1) {
|
|
344
|
-
// marriages = families.index(0);
|
|
345
|
-
// } else
|
|
346
|
-
if (families.length >= 1) {
|
|
347
|
-
marriages = new List();
|
|
348
|
-
families.forEach((fam) => {
|
|
349
|
-
if (fam.MARR) {
|
|
350
|
-
const newMarr = createCommon(this._gedcom, undefined, this);
|
|
351
|
-
Object.assign(newMarr, fam.MARR);
|
|
352
|
-
newMarr.id = fam.id;
|
|
353
|
-
marriages.append(newMarr);
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
let usedIndi;
|
|
359
|
-
// let usedMaxLevel = maxLevel;
|
|
360
|
-
if (marriages) {
|
|
361
|
-
usedIndi = createIndi(this._gedcom, this.id);
|
|
362
|
-
Object.assign(usedIndi, this, {
|
|
363
|
-
MARR: marriages,
|
|
364
|
-
});
|
|
365
|
-
// usedMaxLevel = usedMaxLevel === 1 ? 2 : usedMaxLevel;
|
|
366
|
-
}
|
|
367
|
-
const places = getPlaces(usedIndi || this, type, maxLevel);
|
|
368
|
-
return places;
|
|
369
|
-
}
|
|
370
|
-
getTree(props) {
|
|
371
|
-
const { descendants, offspringSpouses, ancestorSpouses, onlyDescendants, maxGen, minGen, drawNonBiologicalAncestors, ancestorSiblings, } = props ?? {};
|
|
372
|
-
const newGenerations = {
|
|
373
|
-
existed: {},
|
|
374
|
-
tree: {},
|
|
375
|
-
halves: {},
|
|
376
|
-
lastItems: {},
|
|
377
|
-
};
|
|
378
|
-
this.generateTree({
|
|
379
|
-
generations: newGenerations,
|
|
380
|
-
level: 1,
|
|
381
|
-
famIndex: 0,
|
|
382
|
-
index: 0,
|
|
383
|
-
showDescendants: descendants,
|
|
384
|
-
offspringSpouses,
|
|
385
|
-
ancestorSpouses,
|
|
386
|
-
onlyDescendants,
|
|
387
|
-
maxLevel: maxGen,
|
|
388
|
-
minLevel: minGen,
|
|
389
|
-
drawNonBiologicalAncestors,
|
|
390
|
-
ancestorSiblings,
|
|
391
|
-
});
|
|
392
|
-
return Object.keys(newGenerations.tree)
|
|
393
|
-
.toSorted((a, b) => Number(a) - Number(b))
|
|
394
|
-
.map((key) => {
|
|
395
|
-
const gen = Number(key);
|
|
396
|
-
return {
|
|
397
|
-
gen,
|
|
398
|
-
indis: newGenerations.tree[gen],
|
|
399
|
-
half: newGenerations.halves[gen],
|
|
400
|
-
};
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
getGenealogy(onlyStraight = false, showDescendants = false) {
|
|
404
|
-
const id = this.get("FAMC")?.toList().index(0)?.toValue();
|
|
405
|
-
if (!id) {
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
const own = this.isMale()
|
|
409
|
-
? {
|
|
410
|
-
father: this,
|
|
411
|
-
mother: !onlyStraight
|
|
412
|
-
? this.getCoParents().index(0)
|
|
413
|
-
: undefined,
|
|
414
|
-
}
|
|
415
|
-
: {
|
|
416
|
-
mother: this,
|
|
417
|
-
father: !onlyStraight
|
|
418
|
-
? this.getCoParents().index(0)
|
|
419
|
-
: undefined,
|
|
420
|
-
};
|
|
421
|
-
const newGenerations = {
|
|
422
|
-
existed: {
|
|
423
|
-
[this.id]: Existed.YES,
|
|
424
|
-
},
|
|
425
|
-
tree: {
|
|
426
|
-
0: [
|
|
427
|
-
{
|
|
428
|
-
id,
|
|
429
|
-
index: 0,
|
|
430
|
-
...own,
|
|
431
|
-
},
|
|
432
|
-
],
|
|
433
|
-
},
|
|
434
|
-
halves: { 0: 0 },
|
|
435
|
-
lastItems: {},
|
|
436
|
-
};
|
|
437
|
-
this.generateTree({
|
|
438
|
-
generations: newGenerations,
|
|
439
|
-
level: 1,
|
|
440
|
-
famIndex: 0,
|
|
441
|
-
index: 0,
|
|
442
|
-
showDescendants,
|
|
443
|
-
});
|
|
444
|
-
const gens = Object.keys(newGenerations.tree).toSorted((a, b) => Number(b) - Number(a));
|
|
445
|
-
const genealogyGenerations = {};
|
|
446
|
-
const genealogyResult = {};
|
|
447
|
-
gens.forEach((genIndex) => {
|
|
448
|
-
const gen = Number(genIndex);
|
|
449
|
-
const generation = newGenerations.tree[gen].flat();
|
|
450
|
-
if (!genealogyGenerations[gen]) {
|
|
451
|
-
genealogyGenerations[gen] = {
|
|
452
|
-
left: [],
|
|
453
|
-
main: { left: [], right: [] },
|
|
454
|
-
right: [],
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
else {
|
|
458
|
-
if (!genealogyGenerations[gen].left) {
|
|
459
|
-
genealogyGenerations[gen].left = [];
|
|
460
|
-
}
|
|
461
|
-
if (!genealogyGenerations[gen].main) {
|
|
462
|
-
genealogyGenerations[gen].main = { left: [], right: [] };
|
|
463
|
-
}
|
|
464
|
-
if (!genealogyGenerations[gen].right) {
|
|
465
|
-
genealogyGenerations[gen].right = [];
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
generation.forEach((pack, index) => {
|
|
469
|
-
const members = { left: [], right: [] };
|
|
470
|
-
["father", "mother"].forEach((type, mIndex) => {
|
|
471
|
-
const key = type;
|
|
472
|
-
const typedPack = pack?.[key];
|
|
473
|
-
const validIndex = index * 2 + mIndex;
|
|
474
|
-
const side = validIndex >= generation.length ? "right" : "left";
|
|
475
|
-
if (typedPack) {
|
|
476
|
-
members[side].push(typedPack);
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
if (!onlyStraight) {
|
|
480
|
-
["father", "mother"].forEach((type, mIndex) => {
|
|
481
|
-
const key = type;
|
|
482
|
-
const typedPack = pack?.[key];
|
|
483
|
-
const validIndex = index * 2 + mIndex;
|
|
484
|
-
const side = validIndex >= generation.length ? "right" : "left";
|
|
485
|
-
const spouse = key === "father" ? pack?.mother : pack?.father;
|
|
486
|
-
const spouses = (typedPack?.getCoParents().values() ?? []).filter((item) => {
|
|
487
|
-
if (item?.id === spouse?.id) {
|
|
488
|
-
return false;
|
|
489
|
-
}
|
|
490
|
-
if (item.id && !newGenerations.existed[item.id]) {
|
|
491
|
-
newGenerations.existed[item.id] = Existed.YES;
|
|
492
|
-
return true;
|
|
493
|
-
}
|
|
494
|
-
return false;
|
|
495
|
-
});
|
|
496
|
-
const rawSiblings = typedPack
|
|
497
|
-
?.getSiblings()
|
|
498
|
-
.orderBy(BIRTH_ASC)
|
|
499
|
-
.values() ?? [];
|
|
500
|
-
const siblings = rawSiblings.reduce((acc, item, index) => {
|
|
501
|
-
if (item.id && !newGenerations.existed[item.id]) {
|
|
502
|
-
newGenerations.existed[item.id] = Existed.YES;
|
|
503
|
-
const siblingSpouses = (item?.getCoParents().values() ?? []).filter((siblingSpouse) => {
|
|
504
|
-
if (siblingSpouse.id &&
|
|
505
|
-
!newGenerations.existed[siblingSpouse.id]) {
|
|
506
|
-
newGenerations.existed[siblingSpouse.id] = Existed.YES;
|
|
507
|
-
return true;
|
|
508
|
-
}
|
|
509
|
-
return false;
|
|
510
|
-
});
|
|
511
|
-
if (siblingSpouses.length) {
|
|
512
|
-
const newValue = item?.isMale()
|
|
513
|
-
? [item, ...siblingSpouses]
|
|
514
|
-
: [...siblingSpouses, item];
|
|
515
|
-
return [
|
|
516
|
-
...acc,
|
|
517
|
-
...(index > 0 &&
|
|
518
|
-
newValue.length > 1 &&
|
|
519
|
-
acc[acc.length - 1] !== undefined
|
|
520
|
-
? [undefined]
|
|
521
|
-
: []),
|
|
522
|
-
...newValue,
|
|
523
|
-
...(index < rawSiblings.length - 1 &&
|
|
524
|
-
newValue.length > 1
|
|
525
|
-
? [undefined]
|
|
526
|
-
: []),
|
|
527
|
-
];
|
|
528
|
-
}
|
|
529
|
-
return [...acc, item];
|
|
530
|
-
}
|
|
531
|
-
return acc;
|
|
532
|
-
}, []);
|
|
533
|
-
const spouseMethod = key === "father" ? "unshift" : "push";
|
|
534
|
-
const siblingMethod = side === "left" ? "unshift" : "push";
|
|
535
|
-
members[side][spouseMethod](...spouses);
|
|
536
|
-
if (siblings.length) {
|
|
537
|
-
if ((key === "father" && pack?.mother) ||
|
|
538
|
-
(key === "mother" && pack?.father)) {
|
|
539
|
-
members[side][siblingMethod](undefined);
|
|
540
|
-
}
|
|
541
|
-
members[side][siblingMethod](...siblings);
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
genealogyGenerations[gen].main.left.push(members.left.length ? members.left : undefined);
|
|
546
|
-
genealogyGenerations[gen].main.right.push(members.right.length ? members.right : undefined);
|
|
547
|
-
});
|
|
548
|
-
});
|
|
549
|
-
gens.forEach((genIndex) => {
|
|
550
|
-
const gen = Number(genIndex);
|
|
551
|
-
const prevGen = gen - 1;
|
|
552
|
-
if (!genealogyGenerations[prevGen]) {
|
|
553
|
-
genealogyGenerations[prevGen] = {
|
|
554
|
-
left: [],
|
|
555
|
-
main: { left: [], right: [] },
|
|
556
|
-
right: [],
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
["left", "right"].forEach((s) => {
|
|
560
|
-
const side = s;
|
|
561
|
-
if (!onlyStraight) {
|
|
562
|
-
genealogyGenerations[gen].main[side].forEach((pack) => {
|
|
563
|
-
if (!pack) {
|
|
564
|
-
return;
|
|
565
|
-
}
|
|
566
|
-
const toRight = side === "right";
|
|
567
|
-
const orderedPack = pack;
|
|
568
|
-
orderedPack.forEach((indi) => {
|
|
569
|
-
if (!indi) {
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
const rawChildren = indi
|
|
573
|
-
?.getChildren()
|
|
574
|
-
.orderBy(BIRTH_ASC)
|
|
575
|
-
.values() ?? [];
|
|
576
|
-
const children = rawChildren.reduce((acc, item, index) => {
|
|
577
|
-
if (item.id &&
|
|
578
|
-
!newGenerations.existed[item.id]) {
|
|
579
|
-
newGenerations.existed[item.id] =
|
|
580
|
-
Existed.YES;
|
|
581
|
-
const childSpouses = (item?.getCoParents().values() ?? []).filter((childSpouse) => {
|
|
582
|
-
if (childSpouse.id &&
|
|
583
|
-
!newGenerations.existed[childSpouse.id]) {
|
|
584
|
-
newGenerations.existed[childSpouse.id] = Existed.YES;
|
|
585
|
-
return true;
|
|
586
|
-
}
|
|
587
|
-
return false;
|
|
588
|
-
});
|
|
589
|
-
if (childSpouses.length) {
|
|
590
|
-
const newValue = item?.isMale()
|
|
591
|
-
? [item, ...childSpouses]
|
|
592
|
-
: [...childSpouses, item];
|
|
593
|
-
return [
|
|
594
|
-
...acc,
|
|
595
|
-
...(index > 0 &&
|
|
596
|
-
newValue.length > 1 &&
|
|
597
|
-
acc[acc.length - 1] !== undefined
|
|
598
|
-
? [undefined]
|
|
599
|
-
: []),
|
|
600
|
-
...newValue,
|
|
601
|
-
...(index <
|
|
602
|
-
rawChildren.length - 1 &&
|
|
603
|
-
newValue.length > 1
|
|
604
|
-
? [undefined]
|
|
605
|
-
: []),
|
|
606
|
-
];
|
|
607
|
-
}
|
|
608
|
-
return [...acc, item];
|
|
609
|
-
}
|
|
610
|
-
return acc;
|
|
611
|
-
}, []);
|
|
612
|
-
const childMethod = "push";
|
|
613
|
-
const members = [];
|
|
614
|
-
if (children.length) {
|
|
615
|
-
members[childMethod](children);
|
|
616
|
-
}
|
|
617
|
-
if (toRight) {
|
|
618
|
-
genealogyGenerations[prevGen].right.push(...members);
|
|
619
|
-
}
|
|
620
|
-
else {
|
|
621
|
-
genealogyGenerations[prevGen].left.push(...members);
|
|
622
|
-
}
|
|
623
|
-
});
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
if (genealogyGenerations[prevGen]) {
|
|
627
|
-
genealogyGenerations[prevGen] = {
|
|
628
|
-
left: [],
|
|
629
|
-
main: {
|
|
630
|
-
left: [
|
|
631
|
-
...(genealogyGenerations[prevGen]?.left ?? []),
|
|
632
|
-
...(genealogyGenerations[prevGen]?.main.left ??
|
|
633
|
-
[]),
|
|
634
|
-
],
|
|
635
|
-
right: [
|
|
636
|
-
...(genealogyGenerations[prevGen]?.main.right ??
|
|
637
|
-
[]),
|
|
638
|
-
...(genealogyGenerations[prevGen]?.right ?? []),
|
|
639
|
-
],
|
|
640
|
-
},
|
|
641
|
-
right: [],
|
|
642
|
-
};
|
|
643
|
-
}
|
|
644
|
-
genealogyResult[gen] = {
|
|
645
|
-
left: [
|
|
646
|
-
...(genealogyGenerations[gen]?.left ?? []),
|
|
647
|
-
...(genealogyGenerations[gen]?.main.left ?? []),
|
|
648
|
-
],
|
|
649
|
-
right: [
|
|
650
|
-
...(genealogyGenerations[gen]?.main.right ?? []),
|
|
651
|
-
...(genealogyGenerations[gen]?.right ?? []),
|
|
652
|
-
],
|
|
653
|
-
};
|
|
654
|
-
});
|
|
655
|
-
});
|
|
656
|
-
const result = [];
|
|
657
|
-
gens.forEach((genIndex) => {
|
|
658
|
-
result.unshift({
|
|
659
|
-
gen: Number(genIndex),
|
|
660
|
-
...genealogyResult[Number(genIndex)],
|
|
661
|
-
});
|
|
662
|
-
});
|
|
663
|
-
return result;
|
|
664
|
-
}
|
|
665
|
-
ancestryLink() {
|
|
666
|
-
const www = this._gedcom?.HEAD?.SOUR?.CORP?.WWW?.value;
|
|
667
|
-
const tree = this.getAncestryTreeId();
|
|
668
|
-
if (this.id) {
|
|
669
|
-
return `https://${www}/family-tree/person/tree/${tree}/person/${this.id.replace(/@|I/g, "")}/facts`;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
async ancestryMedia(namespace) {
|
|
673
|
-
const list = {};
|
|
674
|
-
const objIds = this.get("OBJE")?.toValueList().keys() ?? [];
|
|
675
|
-
const www = this._gedcom?.HEAD?.SOUR?.CORP?.WWW?.value;
|
|
676
|
-
const tree = this.getAncestryTreeId();
|
|
677
|
-
await Promise.all(objIds.map(async (objId) => {
|
|
678
|
-
const key = objId;
|
|
679
|
-
const obje = this._gedcom
|
|
680
|
-
?.obje(key)
|
|
681
|
-
?.standardizeMedia(namespace, true, (ns, iId) => {
|
|
682
|
-
return ns && iId
|
|
683
|
-
? `https://mediasvc.ancestry.com/v2/image/namespaces/${ns}/media/${iId}?client=trees-mediaservice&imageQuality=hq`
|
|
684
|
-
: undefined;
|
|
685
|
-
});
|
|
686
|
-
const media = obje?.RIN?.value;
|
|
687
|
-
const clone = obje?.get("_CLON._OID")?.toValue();
|
|
688
|
-
const mser = obje?.get("_MSER._LKID")?.toValue();
|
|
689
|
-
let url = obje?.get("FILE")?.toValue();
|
|
690
|
-
const title = obje?.get("TITL")?.toValue() ?? "";
|
|
691
|
-
const type = obje?.get("FORM")?.toValue() ??
|
|
692
|
-
"raw";
|
|
693
|
-
const imgId = clone || mser;
|
|
694
|
-
if (!www || !tree || !this.id) {
|
|
695
|
-
return;
|
|
696
|
-
}
|
|
697
|
-
if (!namespace && !url) {
|
|
698
|
-
try {
|
|
699
|
-
const mediaDetailsResponse = await fetch(`https://www.ancestry.com/api/media/viewer/v2/trees/${tree}/media?id=${media}`);
|
|
700
|
-
const mediaDetails = (await mediaDetailsResponse.json());
|
|
701
|
-
if (mediaDetails.url) {
|
|
702
|
-
url = `${mediaDetails.url}&imageQuality=hq`;
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
catch (_e) {
|
|
706
|
-
//
|
|
707
|
-
}
|
|
708
|
-
url =
|
|
709
|
-
url ||
|
|
710
|
-
`https://${www}/mediaui-viewer/tree/${tree}/media/${media}`;
|
|
711
|
-
}
|
|
712
|
-
if (url && imgId) {
|
|
713
|
-
const id = `${tree}-${this.id}-${imgId}`;
|
|
714
|
-
list[id] = {
|
|
715
|
-
key,
|
|
716
|
-
id,
|
|
717
|
-
tree,
|
|
718
|
-
imgId,
|
|
719
|
-
person: this.id,
|
|
720
|
-
title: title,
|
|
721
|
-
url,
|
|
722
|
-
contentType: type,
|
|
723
|
-
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title ||
|
|
724
|
-
key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`,
|
|
725
|
-
};
|
|
726
|
-
}
|
|
727
|
-
}));
|
|
728
|
-
return list;
|
|
729
|
-
}
|
|
730
|
-
myheritageLink(poolId = 0) {
|
|
731
|
-
const www = this._gedcom?.HEAD?.SOUR?.CORP?.value
|
|
732
|
-
?.toLowerCase()
|
|
733
|
-
.replace(/^www\./gi, "");
|
|
734
|
-
const site = this.getMyHeritageTreeId();
|
|
735
|
-
const file = this._gedcom?.HEAD?.get("FILE")?.toValue()?.match(/Exported by MyHeritage.com from .+ in (?<site>.+) on .+$/)
|
|
736
|
-
?.groups?.site;
|
|
737
|
-
const normalizedFile = file
|
|
738
|
-
?.normalize("NFD")
|
|
739
|
-
.replace(/[\u0300-\u036f]/g, "")
|
|
740
|
-
.toLowerCase()
|
|
741
|
-
.replace(/[^a-z0-9]+/g, "-");
|
|
742
|
-
if (normalizedFile && this.id) {
|
|
743
|
-
const id = Number(this.id.replace(/@|I/g, "")) + poolId;
|
|
744
|
-
return `https://www.${www}/site-family-tree-${site}/${normalizedFile}#!profile-${id}-info`;
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
myheritageMedia() {
|
|
748
|
-
const list = {};
|
|
749
|
-
const tree = this.getMyHeritageTreeId();
|
|
750
|
-
if (!tree) {
|
|
751
|
-
return;
|
|
752
|
-
}
|
|
753
|
-
const birthObj = this.get("BIRT.OBJE")?.toList().values();
|
|
754
|
-
const deathObj = this.get("DEAT.OBJE")?.toValueList().values();
|
|
755
|
-
const familiesObj = (this.get("FAMS")?.toValueList().values() ?? [])
|
|
756
|
-
.concat(this.get("FAMC")?.toValueList().values() ?? [])
|
|
757
|
-
.map((fam) => {
|
|
758
|
-
return fam?.get("MARR.OBJE");
|
|
759
|
-
});
|
|
760
|
-
(birthObj ?? [])
|
|
761
|
-
.concat(deathObj ?? [])
|
|
762
|
-
.concat(familiesObj ?? [])
|
|
763
|
-
.forEach((o, index) => {
|
|
764
|
-
if (!o) {
|
|
765
|
-
return;
|
|
766
|
-
}
|
|
767
|
-
const obje = o;
|
|
768
|
-
const key = `@O${index}@`;
|
|
769
|
-
obje.standardizeMedia();
|
|
770
|
-
const url = obje?.get("FILE")?.toValue();
|
|
771
|
-
const title = obje?.get("NOTE")?.toValue() ?? "";
|
|
772
|
-
const type = obje?.get("FORM")?.toValue() ??
|
|
773
|
-
"raw";
|
|
774
|
-
const imgId = obje?.get("_PHOTO_RIN")?.toValue();
|
|
775
|
-
if (url && imgId) {
|
|
776
|
-
const id = `${tree}-${this.id}-${imgId}`;
|
|
777
|
-
list[id] = {
|
|
778
|
-
key,
|
|
779
|
-
id,
|
|
780
|
-
tree,
|
|
781
|
-
imgId,
|
|
782
|
-
person: this.id,
|
|
783
|
-
title: title,
|
|
784
|
-
url,
|
|
785
|
-
contentType: type,
|
|
786
|
-
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title ||
|
|
787
|
-
key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`,
|
|
788
|
-
};
|
|
789
|
-
}
|
|
790
|
-
});
|
|
791
|
-
return list;
|
|
792
|
-
}
|
|
793
|
-
familySearchLink() {
|
|
794
|
-
// Get the _FS_LINK custom tag value and return it as-is
|
|
795
|
-
return this.get("_FS_LINK")?.toValue();
|
|
796
|
-
}
|
|
797
|
-
hasFamilySearchMatches() {
|
|
798
|
-
// Check if this individual has any _FS_MATCH tags
|
|
799
|
-
return this.get("_FS_MATCH") !== undefined;
|
|
800
|
-
}
|
|
801
|
-
getFamilySearchMatches() {
|
|
802
|
-
// Get all _FS_MATCH tags for this individual
|
|
803
|
-
const matchTags = this.get("_FS_MATCH")?.toList();
|
|
804
|
-
if (!matchTags?.length) {
|
|
805
|
-
return [];
|
|
806
|
-
}
|
|
807
|
-
return matchTags.map((matchTag) => {
|
|
808
|
-
const id = matchTag.toValue();
|
|
809
|
-
// Extract all sub-tags using get() method
|
|
810
|
-
const title = matchTag.get("TITL")?.toValue();
|
|
811
|
-
const type = matchTag.get("TYPE")?.toValue();
|
|
812
|
-
const ref = matchTag.get("REF")?.toValue();
|
|
813
|
-
const scoreStr = matchTag.get("SCORE")?.toValue();
|
|
814
|
-
const text = matchTag.get("TEXT")?.toValue();
|
|
815
|
-
const www = matchTag.get("WWW")?.toValue();
|
|
816
|
-
// Extract NOTE tags (there can be multiple)
|
|
817
|
-
const noteTags = matchTag.get("NOTE")?.toList() || [];
|
|
818
|
-
const notes = noteTags
|
|
819
|
-
.map((note) => note.toValue())
|
|
820
|
-
.filter(Boolean);
|
|
821
|
-
return {
|
|
822
|
-
id,
|
|
823
|
-
title,
|
|
824
|
-
type,
|
|
825
|
-
ref,
|
|
826
|
-
score: scoreStr ? parseFloat(scoreStr) : undefined,
|
|
827
|
-
text,
|
|
828
|
-
www,
|
|
829
|
-
notes,
|
|
830
|
-
};
|
|
831
|
-
});
|
|
832
|
-
}
|
|
833
|
-
hasFamilySearchSources() {
|
|
834
|
-
// Check if this individual has any _FS_SOUR tags
|
|
835
|
-
return this.get("_FS_SOUR") !== undefined;
|
|
836
|
-
}
|
|
837
|
-
getFamilySearchSources() {
|
|
838
|
-
// Get all _FS_SOUR tags for this individual
|
|
839
|
-
const sourceTags = this.get("_FS_SOUR")?.toList();
|
|
840
|
-
if (!sourceTags?.length) {
|
|
841
|
-
return [];
|
|
842
|
-
}
|
|
843
|
-
return sourceTags.map((sourceTag) => {
|
|
844
|
-
const id = sourceTag.toValue();
|
|
845
|
-
// Extract all sub-tags using get() method
|
|
846
|
-
const title = sourceTag.get("TITL")?.toValue();
|
|
847
|
-
const text = sourceTag.get("TEXT")?.toValue();
|
|
848
|
-
const www = sourceTag.get("WWW")?.toValue();
|
|
849
|
-
// Extract NOTE tags (there can be multiple)
|
|
850
|
-
const noteTags = sourceTag.get("NOTE")?.toList() || [];
|
|
851
|
-
const notes = noteTags
|
|
852
|
-
.map((note) => note.toValue())
|
|
853
|
-
.filter(Boolean);
|
|
854
|
-
return {
|
|
855
|
-
id,
|
|
856
|
-
title,
|
|
857
|
-
text,
|
|
858
|
-
www,
|
|
859
|
-
notes,
|
|
860
|
-
};
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
|
-
async multimedia(namespace) {
|
|
864
|
-
if (this?.isAncestry()) {
|
|
865
|
-
return await this.ancestryMedia(namespace);
|
|
866
|
-
}
|
|
867
|
-
if (this?.isMyHeritage()) {
|
|
868
|
-
return this.myheritageMedia();
|
|
869
|
-
}
|
|
870
|
-
return undefined;
|
|
871
|
-
}
|
|
872
|
-
link(poolId) {
|
|
873
|
-
if (this?.isAncestry()) {
|
|
874
|
-
return this.ancestryLink();
|
|
875
|
-
}
|
|
876
|
-
if (this?.isMyHeritage()) {
|
|
877
|
-
return this.myheritageLink(poolId);
|
|
878
|
-
}
|
|
879
|
-
if (this?.isFamilySearch()) {
|
|
880
|
-
return this.familySearchLink();
|
|
881
|
-
}
|
|
882
|
-
return undefined;
|
|
883
|
-
}
|
|
884
|
-
toFamilies(list) {
|
|
885
|
-
const families = new Families();
|
|
886
|
-
list?.forEach((fam, famId) => {
|
|
887
|
-
const family = fam?.ref;
|
|
888
|
-
if (family) {
|
|
889
|
-
families.item(famId, family);
|
|
890
|
-
}
|
|
891
|
-
});
|
|
892
|
-
return families;
|
|
893
|
-
}
|
|
894
|
-
getFamilies(type) {
|
|
895
|
-
return this.toFamilies(this.get(type)?.toValueList());
|
|
896
|
-
}
|
|
897
|
-
getFamiliesBiologicalFirst(type) {
|
|
898
|
-
const families = this.toFamilies(this.get(type)?.toValueList());
|
|
899
|
-
return families.orderBy((famB, _famBKey, famA) => {
|
|
900
|
-
const husbA = famA.getHusband().index(0);
|
|
901
|
-
const wifeA = famA.getWife().index(0);
|
|
902
|
-
const husbAType = husbA && this.getParentType(husbA);
|
|
903
|
-
const wifeAType = wifeA && this.getParentType(wifeA);
|
|
904
|
-
const husbB = famB.getHusband().index(0);
|
|
905
|
-
const wifeB = famB.getWife().index(0);
|
|
906
|
-
const husbBType = husbB && this.getParentType(husbB);
|
|
907
|
-
const wifeBType = wifeB && this.getParentType(wifeB);
|
|
908
|
-
if (husbAType === RelationType.BIOLOGICAL &&
|
|
909
|
-
wifeAType === RelationType.BIOLOGICAL) {
|
|
910
|
-
if (husbBType === RelationType.BIOLOGICAL &&
|
|
911
|
-
wifeBType === RelationType.BIOLOGICAL) {
|
|
912
|
-
return 0;
|
|
913
|
-
}
|
|
914
|
-
return 1;
|
|
915
|
-
}
|
|
916
|
-
else if (husbAType === RelationType.BIOLOGICAL) {
|
|
917
|
-
if (husbBType === RelationType.BIOLOGICAL &&
|
|
918
|
-
wifeBType === RelationType.BIOLOGICAL) {
|
|
919
|
-
return -1;
|
|
920
|
-
}
|
|
921
|
-
else if (husbBType === RelationType.BIOLOGICAL) {
|
|
922
|
-
return 0;
|
|
923
|
-
}
|
|
924
|
-
return 1;
|
|
925
|
-
}
|
|
926
|
-
else if (wifeAType === RelationType.BIOLOGICAL) {
|
|
927
|
-
if (husbBType === RelationType.BIOLOGICAL &&
|
|
928
|
-
wifeBType === RelationType.BIOLOGICAL) {
|
|
929
|
-
return -1;
|
|
930
|
-
}
|
|
931
|
-
else if (husbBType === RelationType.BIOLOGICAL) {
|
|
932
|
-
return -1;
|
|
933
|
-
}
|
|
934
|
-
return 0;
|
|
935
|
-
}
|
|
936
|
-
if (husbBType === RelationType.BIOLOGICAL ||
|
|
937
|
-
wifeBType === RelationType.BIOLOGICAL) {
|
|
938
|
-
return -1;
|
|
939
|
-
}
|
|
940
|
-
return 0;
|
|
941
|
-
});
|
|
942
|
-
}
|
|
943
|
-
getBirthDate(showDays = false, shortNote = true, showNote = true) {
|
|
944
|
-
const dates = dateFormatter(this, false, showDays, false, shortNote, showNote);
|
|
945
|
-
return dates.birth || undefined;
|
|
946
|
-
}
|
|
947
|
-
getDeathDate(showDays = false, shortNote = true, showNote = true) {
|
|
948
|
-
const dates = dateFormatter(this, false, showDays, false, shortNote, showNote);
|
|
949
|
-
return dates.death || undefined;
|
|
950
|
-
}
|
|
951
|
-
getBirthPlace() {
|
|
952
|
-
const birthEvent = this.get("BIRT")?.toList().index(0);
|
|
953
|
-
return birthEvent?.PLAC?.value;
|
|
954
|
-
}
|
|
955
|
-
getDeathPlace() {
|
|
956
|
-
const deathEvent = this.get("DEAT")?.toList().index(0);
|
|
957
|
-
return deathEvent?.PLAC?.value;
|
|
958
|
-
}
|
|
959
|
-
isDead() {
|
|
960
|
-
return (this.get("DEAT.DATE")?.toValue() !== undefined ||
|
|
961
|
-
this.get("DEAT.PLAC")?.toValue() !== undefined);
|
|
962
|
-
}
|
|
963
|
-
isEmpty() {
|
|
964
|
-
if (this._isEmpty !== undefined) {
|
|
965
|
-
return this._isEmpty;
|
|
966
|
-
}
|
|
967
|
-
const keysLength = Object.keys(this).filter((key) => {
|
|
968
|
-
return (!key.startsWith("_") &&
|
|
969
|
-
!["gedcom", "isListable", "refType"].includes(key));
|
|
970
|
-
}).length;
|
|
971
|
-
this._isEmpty = !keysLength;
|
|
972
|
-
return this._isEmpty;
|
|
973
|
-
}
|
|
974
|
-
isUnknownAncestor() {
|
|
975
|
-
if (this._isUnknownAncestor !== undefined) {
|
|
976
|
-
return this._isUnknownAncestor;
|
|
977
|
-
}
|
|
978
|
-
this._isUnknownAncestor = !!this.get("_MTTAG")
|
|
979
|
-
?.toList()
|
|
980
|
-
?.values()
|
|
981
|
-
.find((tag) => tag?.get("NAME")?.toValue() === CustomTags.UnknownAncestor);
|
|
982
|
-
return this._isUnknownAncestor;
|
|
983
|
-
}
|
|
984
|
-
isIgnoredMember() {
|
|
985
|
-
if (this._isIgnoredPerson !== undefined) {
|
|
986
|
-
return this._isIgnoredPerson;
|
|
987
|
-
}
|
|
988
|
-
this._isIgnoredPerson = !!this.get("_MTTAG")
|
|
989
|
-
?.toList()
|
|
990
|
-
?.values()
|
|
991
|
-
.find((tag) => tag?.get("NAME")?.toValue() === CustomTags.IgnoredMember);
|
|
992
|
-
return this._isIgnoredPerson;
|
|
993
|
-
}
|
|
994
|
-
isUnattachedMember() {
|
|
995
|
-
if (this._isUnattachedMember !== undefined) {
|
|
996
|
-
return this._isUnattachedMember;
|
|
997
|
-
}
|
|
998
|
-
this._isUnattachedMember = !!this.get("_MTTAG")
|
|
999
|
-
?.toList()
|
|
1000
|
-
?.values()
|
|
1001
|
-
.find((tag) => tag?.get("NAME")?.toValue() === CustomTags.UnattachedMember);
|
|
1002
|
-
return this._isUnattachedMember;
|
|
1003
|
-
}
|
|
1004
|
-
isOrphanFamilyMember() {
|
|
1005
|
-
if (this._isOrphanFamilyMember !== undefined) {
|
|
1006
|
-
return this._isOrphanFamilyMember;
|
|
1007
|
-
}
|
|
1008
|
-
// Check if any of the person's families (FAMC or FAMS) has the _IS_ORPHAN_FAMILY tag
|
|
1009
|
-
const famcFamilies = this.getFamilies("FAMC");
|
|
1010
|
-
const famsFamilies = this.getFamilies("FAMS");
|
|
1011
|
-
this._isOrphanFamilyMember = false;
|
|
1012
|
-
// Check FAMC families
|
|
1013
|
-
famcFamilies.forEach((fam) => {
|
|
1014
|
-
if (fam._IS_ORPHAN_FAMILY?.value === "Y") {
|
|
1015
|
-
this._isOrphanFamilyMember = true;
|
|
1016
|
-
}
|
|
1017
|
-
});
|
|
1018
|
-
// Check FAMS families if not already found
|
|
1019
|
-
if (!this._isOrphanFamilyMember) {
|
|
1020
|
-
famsFamilies.forEach((fam) => {
|
|
1021
|
-
if (fam._IS_ORPHAN_FAMILY?.value === "Y") {
|
|
1022
|
-
this._isOrphanFamilyMember = true;
|
|
1023
|
-
}
|
|
1024
|
-
});
|
|
1025
|
-
}
|
|
1026
|
-
return this._isOrphanFamilyMember;
|
|
1027
|
-
}
|
|
1028
|
-
isUnknownGivenname() {
|
|
1029
|
-
if (this._isUnknownGivenname !== undefined) {
|
|
1030
|
-
return this._isUnknownGivenname;
|
|
1031
|
-
}
|
|
1032
|
-
this._isUnknownGivenname = !!this.get("_MTTAG")
|
|
1033
|
-
?.toList()
|
|
1034
|
-
?.values()
|
|
1035
|
-
.find((tag) => tag?.get("NAME")?.toValue() === CustomTags.UnknownGivenname);
|
|
1036
|
-
return this._isUnknownGivenname;
|
|
1037
|
-
}
|
|
1038
|
-
isUnknownSurname() {
|
|
1039
|
-
if (this._isUnknownSurname !== undefined) {
|
|
1040
|
-
return this._isUnknownSurname;
|
|
1041
|
-
}
|
|
1042
|
-
this._isUnknownSurname = !!this.get("_MTTAG")
|
|
1043
|
-
?.toList()
|
|
1044
|
-
?.values()
|
|
1045
|
-
.find((tag) => tag?.get("NAME")?.toValue() === CustomTags.UnknownSurname);
|
|
1046
|
-
return this._isUnknownSurname;
|
|
1047
|
-
}
|
|
1048
|
-
isNonRelevantMember() {
|
|
1049
|
-
return this.isUnknownAncestor() || this.isUnattachedMember();
|
|
1050
|
-
}
|
|
1051
|
-
isMale() {
|
|
1052
|
-
return this.get("SEX")?.toValue() === "M";
|
|
1053
|
-
}
|
|
1054
|
-
isFemale() {
|
|
1055
|
-
return this.get("SEX")?.toValue() === "F";
|
|
1056
|
-
}
|
|
1057
|
-
isUnknownSex() {
|
|
1058
|
-
return !this.isMale() && !this.isFemale();
|
|
1059
|
-
}
|
|
1060
|
-
getParentType(id) {
|
|
1061
|
-
let indi;
|
|
1062
|
-
if (typeof id === "string" || typeof id === "number") {
|
|
1063
|
-
indi = this._gedcom?.indi(id);
|
|
1064
|
-
}
|
|
1065
|
-
else {
|
|
1066
|
-
indi = id;
|
|
1067
|
-
}
|
|
1068
|
-
if (!indi?.id || !this.id) {
|
|
1069
|
-
return;
|
|
1070
|
-
}
|
|
1071
|
-
const parents = this.getParents();
|
|
1072
|
-
let parent = parents.item(indi.id) ? indi : undefined;
|
|
1073
|
-
let child = this._gedcom?.indi(this.id);
|
|
1074
|
-
if (!parent?.id) {
|
|
1075
|
-
const children = this.getChildren();
|
|
1076
|
-
if (children.item(indi.id)) {
|
|
1077
|
-
parent = this._gedcom?.indi(this.id);
|
|
1078
|
-
child = indi;
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
const familiesOfChildren = child?.get("FAMC")?.toValueList();
|
|
1082
|
-
if (!parent?.id || !child?.id || !familiesOfChildren) {
|
|
1083
|
-
return;
|
|
1084
|
-
}
|
|
1085
|
-
const families = this.toFamilies(familiesOfChildren);
|
|
1086
|
-
let childType = "";
|
|
1087
|
-
families.forEach((family) => {
|
|
1088
|
-
if (childType) {
|
|
1089
|
-
return;
|
|
1090
|
-
}
|
|
1091
|
-
const fatherId = family.get("HUSB")?.toValue();
|
|
1092
|
-
const motherId = family.get("WIFE")?.toValue();
|
|
1093
|
-
const usedRel = parent?.id === fatherId
|
|
1094
|
-
? "_FREL"
|
|
1095
|
-
: parent?.id === motherId
|
|
1096
|
-
? "_MREL"
|
|
1097
|
-
: undefined;
|
|
1098
|
-
if (!usedRel || !child?.id) {
|
|
1099
|
-
return;
|
|
1100
|
-
}
|
|
1101
|
-
const famChild = this.id && family.CHIL?.toValueList().item(child.id);
|
|
1102
|
-
if (!famChild) {
|
|
1103
|
-
const childIndi = this._gedcom?.indi(child.id);
|
|
1104
|
-
const childState = childIndi
|
|
1105
|
-
?.get("FAMC")
|
|
1106
|
-
?.toList()
|
|
1107
|
-
?.filter((item) => item.value === family.id)
|
|
1108
|
-
.index(0);
|
|
1109
|
-
childType =
|
|
1110
|
-
childState?.get("PEDI")?.toValue() ||
|
|
1111
|
-
RelationType.BIOLOGICAL;
|
|
1112
|
-
}
|
|
1113
|
-
else {
|
|
1114
|
-
childType =
|
|
1115
|
-
famChild.get(usedRel)?.toValue() ||
|
|
1116
|
-
RelationType.BIOLOGICAL;
|
|
1117
|
-
}
|
|
1118
|
-
});
|
|
1119
|
-
return (childType || RelationType.BIOLOGICAL).toLowerCase();
|
|
1120
|
-
}
|
|
1121
|
-
hasFacts() {
|
|
1122
|
-
const dates = dateFormatter(this, true);
|
|
1123
|
-
if (dates.inArray.length) {
|
|
1124
|
-
return true;
|
|
1125
|
-
}
|
|
1126
|
-
const facts = this.getFacts(1);
|
|
1127
|
-
return !!facts.length;
|
|
1128
|
-
}
|
|
1129
|
-
getLinks() {
|
|
1130
|
-
return this.get("_WLNK")?.toList();
|
|
1131
|
-
}
|
|
1132
|
-
getAkas(limit) {
|
|
1133
|
-
return this.getFacts(limit, "AKA");
|
|
1134
|
-
}
|
|
1135
|
-
getFacts(limit, filter) {
|
|
1136
|
-
const filters = (Array.isArray(filter) ? filter : [filter]).filter(Boolean);
|
|
1137
|
-
const facts = new List();
|
|
1138
|
-
let id = 0;
|
|
1139
|
-
ALLOWED_FACTS.forEach((fact) => {
|
|
1140
|
-
const isCustom = ["EVEN", "FACT"].includes(fact);
|
|
1141
|
-
if (filters.length && !filters.includes(fact) && !isCustom) {
|
|
1142
|
-
return;
|
|
1143
|
-
}
|
|
1144
|
-
const factCommon = this.get(fact);
|
|
1145
|
-
const factCommons = factCommon?.toList();
|
|
1146
|
-
factCommons?.forEach((common, _, index) => {
|
|
1147
|
-
if (limit !== undefined && index >= limit) {
|
|
1148
|
-
return;
|
|
1149
|
-
}
|
|
1150
|
-
if (!common) {
|
|
1151
|
-
return;
|
|
1152
|
-
}
|
|
1153
|
-
const newCommon = createCommon(this._gedcom, `${id}`, this);
|
|
1154
|
-
Object.assign(newCommon, common, { id: id });
|
|
1155
|
-
const type = (isCustom ? newCommon.get("TYPE")?.toValue() : fact);
|
|
1156
|
-
if (!type || DISALLOWED_CUSTOM_FACTS.includes(type)) {
|
|
1157
|
-
return;
|
|
1158
|
-
}
|
|
1159
|
-
if (filters.length && !filters.includes(type) && isCustom) {
|
|
1160
|
-
return;
|
|
1161
|
-
}
|
|
1162
|
-
const label = createCommon(this._gedcom, undefined, this);
|
|
1163
|
-
const customRenderer = CustomFactRenderers[type];
|
|
1164
|
-
if (customRenderer) {
|
|
1165
|
-
customRenderer(label, newCommon, this);
|
|
1166
|
-
}
|
|
1167
|
-
else {
|
|
1168
|
-
label.value = type;
|
|
1169
|
-
newCommon.set("_LABEL", label);
|
|
1170
|
-
}
|
|
1171
|
-
// common.id = common.id || (`${id}` as IdType);
|
|
1172
|
-
id++;
|
|
1173
|
-
facts.append(newCommon);
|
|
1174
|
-
});
|
|
1175
|
-
});
|
|
1176
|
-
return facts.orderBy(DATE_ASC);
|
|
1177
|
-
}
|
|
1178
|
-
commonAncestor(person, options) {
|
|
1179
|
-
const path = this.path(person, options);
|
|
1180
|
-
let wentUp = false;
|
|
1181
|
-
const wentDown = false;
|
|
1182
|
-
let lastItem;
|
|
1183
|
-
let ancestor;
|
|
1184
|
-
path?.forEach((item) => {
|
|
1185
|
-
if (wentDown) {
|
|
1186
|
-
return;
|
|
1187
|
-
}
|
|
1188
|
-
if (lastItem) {
|
|
1189
|
-
if (item.level > lastItem.level) {
|
|
1190
|
-
wentUp = true;
|
|
1191
|
-
}
|
|
1192
|
-
if (item.level < lastItem.level) {
|
|
1193
|
-
wentUp = true;
|
|
1194
|
-
if (wentUp && !ancestor) {
|
|
1195
|
-
ancestor = lastItem.indi;
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
lastItem = item;
|
|
1200
|
-
});
|
|
1201
|
-
return ancestor;
|
|
1202
|
-
}
|
|
1203
|
-
path(person, options) {
|
|
1204
|
-
const { breakAfterSpouse = true, breakAfterNonBiological } = options ?? {};
|
|
1205
|
-
const usedIndi = typeof person === "string" ? this._gedcom?.indi(person) : person;
|
|
1206
|
-
if (!this.id || !usedIndi?.id) {
|
|
1207
|
-
return;
|
|
1208
|
-
}
|
|
1209
|
-
const cacheKey = `${this.id}|${usedIndi.id}`;
|
|
1210
|
-
const cache = pathCache(cacheKey);
|
|
1211
|
-
if (cache) {
|
|
1212
|
-
return cache;
|
|
1213
|
-
}
|
|
1214
|
-
const visited = new Individuals().append(this);
|
|
1215
|
-
const mainItem = {
|
|
1216
|
-
indi: this,
|
|
1217
|
-
level: 0,
|
|
1218
|
-
levelUp: 0,
|
|
1219
|
-
levelDown: 0,
|
|
1220
|
-
degree: 0,
|
|
1221
|
-
kinship: "self",
|
|
1222
|
-
};
|
|
1223
|
-
const path = [mainItem];
|
|
1224
|
-
if (this.id === usedIndi.id) {
|
|
1225
|
-
return path;
|
|
1226
|
-
}
|
|
1227
|
-
const queue = [
|
|
1228
|
-
{
|
|
1229
|
-
...mainItem,
|
|
1230
|
-
path,
|
|
1231
|
-
},
|
|
1232
|
-
];
|
|
1233
|
-
// Breadth-first search to find the shortest path
|
|
1234
|
-
let helper = 0;
|
|
1235
|
-
while (queue.length > 0) {
|
|
1236
|
-
if (helper++ > 1000000) {
|
|
1237
|
-
break;
|
|
1238
|
-
}
|
|
1239
|
-
const { indi, path, kinship, relation, level, levelUp, levelDown, degree, breakOnNext, breakAfterNext, inLaw, } = queue.shift();
|
|
1240
|
-
if (usedIndi.id === indi.id) {
|
|
1241
|
-
if (breakOnNext) {
|
|
1242
|
-
return undefined;
|
|
1243
|
-
}
|
|
1244
|
-
pathCache(cacheKey, path);
|
|
1245
|
-
return path;
|
|
1246
|
-
}
|
|
1247
|
-
visited.append(indi);
|
|
1248
|
-
const additional = {};
|
|
1249
|
-
if (breakOnNext || breakAfterNext) {
|
|
1250
|
-
additional.breakOnNext = breakOnNext || breakAfterNext;
|
|
1251
|
-
}
|
|
1252
|
-
if (inLaw) {
|
|
1253
|
-
additional.inLaw = inLaw;
|
|
1254
|
-
}
|
|
1255
|
-
if (kinship === "spouse" && breakAfterSpouse) {
|
|
1256
|
-
if (path.length <= 2) {
|
|
1257
|
-
additional.inLaw = true;
|
|
1258
|
-
}
|
|
1259
|
-
else {
|
|
1260
|
-
additional.breakOnNext = true;
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
// Direct relatives: Parents and Children
|
|
1264
|
-
if (kinship !== "child" || !breakAfterSpouse) {
|
|
1265
|
-
indi.getBiologicalFathers()
|
|
1266
|
-
.copy()
|
|
1267
|
-
.merge(indi.getBiologicalMothers())
|
|
1268
|
-
.merge(indi.getFathers().copy().merge(indi.getMothers()))
|
|
1269
|
-
.forEach((relative) => {
|
|
1270
|
-
if (!visited.has(relative)) {
|
|
1271
|
-
const currentRelation = indi.getParentType(relative);
|
|
1272
|
-
if (breakAfterNonBiological &&
|
|
1273
|
-
currentRelation !== RelationType.BIOLOGICAL) {
|
|
1274
|
-
additional.breakAfterNext = true;
|
|
1275
|
-
}
|
|
1276
|
-
const newItem = {
|
|
1277
|
-
indi: relative,
|
|
1278
|
-
kinship: "parent",
|
|
1279
|
-
relation: currentRelation &&
|
|
1280
|
-
currentRelation !== RelationType.BIOLOGICAL
|
|
1281
|
-
? currentRelation
|
|
1282
|
-
: relation,
|
|
1283
|
-
level: level + 1,
|
|
1284
|
-
levelUp: levelUp + 1,
|
|
1285
|
-
levelDown,
|
|
1286
|
-
degree,
|
|
1287
|
-
...additional,
|
|
1288
|
-
};
|
|
1289
|
-
queue.push({
|
|
1290
|
-
...newItem,
|
|
1291
|
-
path: [...path, newItem],
|
|
1292
|
-
});
|
|
1293
|
-
}
|
|
1294
|
-
});
|
|
1295
|
-
}
|
|
1296
|
-
indi.getChildren().forEach((relative) => {
|
|
1297
|
-
if (!visited.has(relative)) {
|
|
1298
|
-
const currentRelation = relative.getParentType(indi);
|
|
1299
|
-
if (breakAfterNonBiological &&
|
|
1300
|
-
currentRelation !== RelationType.BIOLOGICAL) {
|
|
1301
|
-
additional.breakAfterNext = true;
|
|
1302
|
-
}
|
|
1303
|
-
const newItem = {
|
|
1304
|
-
indi: relative,
|
|
1305
|
-
kinship: "child",
|
|
1306
|
-
relation: currentRelation &&
|
|
1307
|
-
currentRelation !== RelationType.BIOLOGICAL
|
|
1308
|
-
? currentRelation
|
|
1309
|
-
: relation,
|
|
1310
|
-
level: level - 1,
|
|
1311
|
-
levelUp,
|
|
1312
|
-
levelDown: levelDown + 1,
|
|
1313
|
-
degree: levelUp
|
|
1314
|
-
? level > 0
|
|
1315
|
-
? levelUp - level + 1
|
|
1316
|
-
: levelDown - Math.abs(level)
|
|
1317
|
-
: 0,
|
|
1318
|
-
...additional,
|
|
1319
|
-
};
|
|
1320
|
-
queue.push({
|
|
1321
|
-
...newItem,
|
|
1322
|
-
path: [...path, newItem],
|
|
1323
|
-
});
|
|
1324
|
-
}
|
|
1325
|
-
});
|
|
1326
|
-
// Spouses
|
|
1327
|
-
indi.getCoParents().forEach((relative) => {
|
|
1328
|
-
if (!visited.has(relative)) {
|
|
1329
|
-
const currentAddition = {};
|
|
1330
|
-
if (relation && relation !== RelationType.BIOLOGICAL) {
|
|
1331
|
-
currentAddition.relation = relation;
|
|
1332
|
-
}
|
|
1333
|
-
if (inLaw) {
|
|
1334
|
-
currentAddition.breakOnNext = true;
|
|
1335
|
-
}
|
|
1336
|
-
const newItem = {
|
|
1337
|
-
indi: relative,
|
|
1338
|
-
kinship: "spouse",
|
|
1339
|
-
level,
|
|
1340
|
-
levelUp,
|
|
1341
|
-
levelDown,
|
|
1342
|
-
degree,
|
|
1343
|
-
...additional,
|
|
1344
|
-
...currentAddition,
|
|
1345
|
-
};
|
|
1346
|
-
queue.push({
|
|
1347
|
-
...newItem,
|
|
1348
|
-
path: [...path, newItem],
|
|
1349
|
-
});
|
|
1350
|
-
}
|
|
1351
|
-
});
|
|
1352
|
-
}
|
|
1353
|
-
return undefined;
|
|
1354
|
-
}
|
|
1355
|
-
kinship(other, showMainPerson, lang = "en", entirePath, displayName = "givenname") {
|
|
1356
|
-
const KinshipTranslatorClass = getKinshipTranslatorClass();
|
|
1357
|
-
const translator = new KinshipTranslatorClass(this, other, lang, entirePath, showMainPerson ? displayName : undefined);
|
|
1358
|
-
return translator.translate(!!showMainPerson);
|
|
1359
|
-
}
|
|
1360
|
-
isRelativeOf(type, indi) {
|
|
1361
|
-
const usedIndi = typeof indi === "string" ? this._gedcom?.indi(indi) : indi;
|
|
1362
|
-
let getter;
|
|
1363
|
-
if (type === "fullsibling") {
|
|
1364
|
-
getter = "getFullSiblings";
|
|
1365
|
-
}
|
|
1366
|
-
if (type === "halfsibling") {
|
|
1367
|
-
getter = "getHalfSiblings";
|
|
1368
|
-
}
|
|
1369
|
-
if (type === "sibling") {
|
|
1370
|
-
getter = "getSiblings";
|
|
1371
|
-
}
|
|
1372
|
-
if (type === "parent") {
|
|
1373
|
-
getter = "getParents";
|
|
1374
|
-
}
|
|
1375
|
-
if (type === "child") {
|
|
1376
|
-
getter = "getChildren";
|
|
1377
|
-
}
|
|
1378
|
-
if (type === "spouse") {
|
|
1379
|
-
getter = "getCoParents";
|
|
1380
|
-
}
|
|
1381
|
-
if (type === "siblingInLaw") {
|
|
1382
|
-
getter = "getSiblingsInLaw";
|
|
1383
|
-
}
|
|
1384
|
-
if (type === "parentInLaw") {
|
|
1385
|
-
getter = "getParentsInLaw";
|
|
1386
|
-
}
|
|
1387
|
-
if (type === "childInLaw") {
|
|
1388
|
-
getter = "getChildrenInLaw";
|
|
1389
|
-
}
|
|
1390
|
-
if (!usedIndi || !getter) {
|
|
1391
|
-
return false;
|
|
1392
|
-
}
|
|
1393
|
-
const relatives = usedIndi[getter]();
|
|
1394
|
-
return Boolean(this.id && relatives.item(this.id)
|
|
1395
|
-
? relatives.index(0)?.id || true
|
|
1396
|
-
: false);
|
|
1397
|
-
}
|
|
1398
|
-
isSiblingOf(indi) {
|
|
1399
|
-
return this.isRelativeOf("sibling", indi);
|
|
1400
|
-
}
|
|
1401
|
-
isFullSiblingOf(indi) {
|
|
1402
|
-
return this.isRelativeOf("fullsibling", indi);
|
|
1403
|
-
}
|
|
1404
|
-
isHalfSiblingOf(indi) {
|
|
1405
|
-
return this.isRelativeOf("halfsibling", indi);
|
|
1406
|
-
}
|
|
1407
|
-
isSpouseOf(indi) {
|
|
1408
|
-
return this.isRelativeOf("spouse", indi);
|
|
1409
|
-
}
|
|
1410
|
-
isParentOf(indi) {
|
|
1411
|
-
return this.isRelativeOf("parent", indi);
|
|
1412
|
-
}
|
|
1413
|
-
isChildOf(indi) {
|
|
1414
|
-
return this.isRelativeOf("child", indi);
|
|
1415
|
-
}
|
|
1416
|
-
isSiblingInLawOf(indi) {
|
|
1417
|
-
return this.isRelativeOf("siblingInLaw", indi);
|
|
1418
|
-
}
|
|
1419
|
-
isParentInLawOf(indi) {
|
|
1420
|
-
return this.isRelativeOf("parentInLaw", indi);
|
|
1421
|
-
}
|
|
1422
|
-
isChildInLawOf(indi) {
|
|
1423
|
-
return this.isRelativeOf("childInLaw", indi);
|
|
1424
|
-
}
|
|
1425
|
-
getRelativesOnDegree(degree = 0) {
|
|
1426
|
-
this.id = this.id || `@I${Math.random()}@`;
|
|
1427
|
-
const cache = relativesOnDegreeCache(this.id, degree);
|
|
1428
|
-
if (cache) {
|
|
1429
|
-
return cache;
|
|
1430
|
-
}
|
|
1431
|
-
let persons = this.getRelativesOnLevel(1)
|
|
1432
|
-
.getRelativesOnDegree(-1)
|
|
1433
|
-
.copy();
|
|
1434
|
-
const excludes = persons;
|
|
1435
|
-
if (!Math.abs(degree)) {
|
|
1436
|
-
return relativesOnDegreeCache(this.id, degree, persons.except(this));
|
|
1437
|
-
}
|
|
1438
|
-
for (let i = 1; i < Math.abs(degree) + 1; i++) {
|
|
1439
|
-
const validDegree = i + 1;
|
|
1440
|
-
excludes.merge(persons);
|
|
1441
|
-
persons = this.getRelativesOnLevel(validDegree)
|
|
1442
|
-
.getRelativesOnDegree(-validDegree)
|
|
1443
|
-
.copy()
|
|
1444
|
-
.exclude(excludes);
|
|
1445
|
-
}
|
|
1446
|
-
return relativesOnDegreeCache(this.id, degree, persons);
|
|
1447
|
-
}
|
|
1448
|
-
getRelativesOnLevel(level = 0, filter) {
|
|
1449
|
-
this.id = this.id || `@I${Math.random()}@`;
|
|
1450
|
-
const cache = relativesOnLevelCache(this.id, level);
|
|
1451
|
-
if (cache) {
|
|
1452
|
-
return cache;
|
|
1453
|
-
}
|
|
1454
|
-
let persons = new Individuals();
|
|
1455
|
-
const config = {
|
|
1456
|
-
isAscendant: level < 0,
|
|
1457
|
-
direction: level < 0 ? -1 : 1,
|
|
1458
|
-
key: level <= 0 ? "FAMS" : "FAMC",
|
|
1459
|
-
};
|
|
1460
|
-
let families = this.get(config.key)?.toValueList();
|
|
1461
|
-
if (!families) {
|
|
1462
|
-
return relativesOnLevelCache(this.id, level, persons);
|
|
1463
|
-
}
|
|
1464
|
-
if (filter) {
|
|
1465
|
-
families = families.filter(filter);
|
|
1466
|
-
}
|
|
1467
|
-
if (config.isAscendant) {
|
|
1468
|
-
persons = this.toFamilies(families).getChildren();
|
|
1469
|
-
}
|
|
1470
|
-
else {
|
|
1471
|
-
persons = this.toFamilies(families).getParents();
|
|
1472
|
-
}
|
|
1473
|
-
if (level >= -1 && level <= 1) {
|
|
1474
|
-
return relativesOnLevelCache(this.id, level, persons.except(this));
|
|
1475
|
-
}
|
|
1476
|
-
for (let i = 1; i < Math.abs(level); i++) {
|
|
1477
|
-
if (config.isAscendant) {
|
|
1478
|
-
persons = persons.getChildren();
|
|
1479
|
-
}
|
|
1480
|
-
else {
|
|
1481
|
-
persons = persons.getParents();
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1484
|
-
return relativesOnLevelCache(this.id, level, persons.except(this));
|
|
1485
|
-
}
|
|
1486
|
-
getAscendants(level = 0, filter) {
|
|
1487
|
-
if (!level) {
|
|
1488
|
-
return new Individuals();
|
|
1489
|
-
}
|
|
1490
|
-
return this.getRelativesOnLevel(level, filter);
|
|
1491
|
-
}
|
|
1492
|
-
getDescendants(level = 0, filter) {
|
|
1493
|
-
if (!level) {
|
|
1494
|
-
return new Individuals();
|
|
1495
|
-
}
|
|
1496
|
-
return this.getRelativesOnLevel(-level, filter);
|
|
1497
|
-
}
|
|
1498
|
-
getAllDescendantsRaw(individuals, containDescendantsInLaw = false) {
|
|
1499
|
-
this.id = this.id || `@I${Math.random()}@`;
|
|
1500
|
-
let ownGeneration = new Individuals();
|
|
1501
|
-
if (individuals) {
|
|
1502
|
-
ownGeneration = individuals;
|
|
1503
|
-
ownGeneration.merge(this.getCoParents());
|
|
1504
|
-
}
|
|
1505
|
-
ownGeneration.append(this);
|
|
1506
|
-
const relatives = new Individuals();
|
|
1507
|
-
relatives.merge(ownGeneration);
|
|
1508
|
-
const generations = {
|
|
1509
|
-
0: ownGeneration,
|
|
1510
|
-
};
|
|
1511
|
-
let currentGen = 0;
|
|
1512
|
-
const maxGenCheck = 100;
|
|
1513
|
-
while (currentGen < maxGenCheck) {
|
|
1514
|
-
const descentants = generations[currentGen]?.getChildren().copy();
|
|
1515
|
-
if (!descentants?.length) {
|
|
1516
|
-
break;
|
|
1517
|
-
}
|
|
1518
|
-
if (containDescendantsInLaw) {
|
|
1519
|
-
descentants?.merge(descentants?.getCoParents());
|
|
1520
|
-
}
|
|
1521
|
-
currentGen++;
|
|
1522
|
-
generations[currentGen] = descentants;
|
|
1523
|
-
relativesOnLevelCache(this.id, -currentGen, descentants);
|
|
1524
|
-
descentants && relatives.merge(descentants);
|
|
1525
|
-
}
|
|
1526
|
-
return { relatives, generations };
|
|
1527
|
-
}
|
|
1528
|
-
getAllDescendants(individuals, containDescendantsInLaw = false) {
|
|
1529
|
-
const raw = this.getAllDescendantsRaw(individuals, containDescendantsInLaw);
|
|
1530
|
-
return raw.relatives;
|
|
1531
|
-
}
|
|
1532
|
-
getAllAscendantsRaw(individuals) {
|
|
1533
|
-
this.id = this.id || `@I${Math.random()}@`;
|
|
1534
|
-
let ownGeneration = new Individuals();
|
|
1535
|
-
if (individuals) {
|
|
1536
|
-
ownGeneration = individuals;
|
|
1537
|
-
}
|
|
1538
|
-
ownGeneration.append(this);
|
|
1539
|
-
const relatives = new Individuals();
|
|
1540
|
-
relatives.merge(ownGeneration);
|
|
1541
|
-
const generations = {
|
|
1542
|
-
0: ownGeneration,
|
|
1543
|
-
};
|
|
1544
|
-
let currentGen = 0;
|
|
1545
|
-
const maxGenCheck = 100;
|
|
1546
|
-
while (currentGen < maxGenCheck) {
|
|
1547
|
-
const parents = generations[currentGen]?.getParents().copy();
|
|
1548
|
-
if (!parents?.length) {
|
|
1549
|
-
break;
|
|
1550
|
-
}
|
|
1551
|
-
currentGen++;
|
|
1552
|
-
generations[currentGen] = parents;
|
|
1553
|
-
relativesOnLevelCache(this.id, currentGen, parents);
|
|
1554
|
-
parents && relatives.merge(parents);
|
|
1555
|
-
}
|
|
1556
|
-
return { relatives, generations };
|
|
1557
|
-
}
|
|
1558
|
-
getAllAscendants(individuals) {
|
|
1559
|
-
const raw = this.getAllAscendantsRaw(individuals);
|
|
1560
|
-
return raw.relatives;
|
|
1561
|
-
}
|
|
1562
|
-
getHalfSiblings() {
|
|
1563
|
-
const siblings = this.getSiblings();
|
|
1564
|
-
const ownParents = this.getBiologicalParents();
|
|
1565
|
-
const halfSiblings = new Individuals();
|
|
1566
|
-
siblings.forEach((sibling) => {
|
|
1567
|
-
const siblingsParents = sibling.getBiologicalParents();
|
|
1568
|
-
const inter = ownParents.intersection(siblingsParents);
|
|
1569
|
-
if (inter.length < ownParents.length) {
|
|
1570
|
-
halfSiblings.append(sibling);
|
|
1571
|
-
}
|
|
1572
|
-
});
|
|
1573
|
-
return halfSiblings;
|
|
1574
|
-
}
|
|
1575
|
-
getFullSiblings() {
|
|
1576
|
-
const siblings = this.getSiblings();
|
|
1577
|
-
const ownParents = this.getBiologicalParents();
|
|
1578
|
-
const fullSiblings = new Individuals();
|
|
1579
|
-
siblings.forEach((sibling) => {
|
|
1580
|
-
const siblingsParents = sibling.getBiologicalParents();
|
|
1581
|
-
const inter = ownParents.intersection(siblingsParents);
|
|
1582
|
-
if (inter.length === ownParents.length) {
|
|
1583
|
-
fullSiblings.append(sibling);
|
|
1584
|
-
}
|
|
1585
|
-
});
|
|
1586
|
-
return fullSiblings;
|
|
1587
|
-
}
|
|
1588
|
-
getSiblings() {
|
|
1589
|
-
implemented("getSiblings");
|
|
1590
|
-
return this.getRelativesOnDegree(0);
|
|
1591
|
-
}
|
|
1592
|
-
getBrothers() {
|
|
1593
|
-
implemented("getBrothers");
|
|
1594
|
-
return this.getSiblings().filter(Filters.MALE);
|
|
1595
|
-
}
|
|
1596
|
-
getSisters() {
|
|
1597
|
-
implemented("getSisters");
|
|
1598
|
-
return this.getSiblings().filter(Filters.MALE);
|
|
1599
|
-
}
|
|
1600
|
-
getChildren(filter) {
|
|
1601
|
-
implemented("getChildren");
|
|
1602
|
-
return this.getDescendants(1, filter);
|
|
1603
|
-
}
|
|
1604
|
-
getChildrenFilteredByPedigree(filter) {
|
|
1605
|
-
const children = new Individuals();
|
|
1606
|
-
const familiesOfChildrens = this.get("FAMS")?.toValueList();
|
|
1607
|
-
if (!familiesOfChildrens || !this.id) {
|
|
1608
|
-
return children;
|
|
1609
|
-
}
|
|
1610
|
-
const families = this.toFamilies(familiesOfChildrens);
|
|
1611
|
-
families.forEach((family) => {
|
|
1612
|
-
const fatherId = family.get("HUSB")?.toValue();
|
|
1613
|
-
const motherId = family.get("WIFE")?.toValue();
|
|
1614
|
-
const usedRel = this.id === fatherId
|
|
1615
|
-
? "_FREL"
|
|
1616
|
-
: this.id === motherId
|
|
1617
|
-
? "_MREL"
|
|
1618
|
-
: undefined;
|
|
1619
|
-
if (!usedRel) {
|
|
1620
|
-
return;
|
|
1621
|
-
}
|
|
1622
|
-
const famChildren = this.id && family.CHIL?.toValueList();
|
|
1623
|
-
famChildren?.forEach((child) => {
|
|
1624
|
-
const childType = child.get(usedRel)?.toValue();
|
|
1625
|
-
if ((!childType && filter.PEDI === RelationType.BIOLOGICAL) ||
|
|
1626
|
-
childType?.toLowerCase() === filter.PEDI.toLowerCase()) {
|
|
1627
|
-
const childId = child?.toValue();
|
|
1628
|
-
const childIndi = childId && this._gedcom?.indi(childId);
|
|
1629
|
-
if (childIndi) {
|
|
1630
|
-
children.append(childIndi);
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
});
|
|
1634
|
-
if (!famChildren?.length) {
|
|
1635
|
-
this.getChildren().forEach((child) => {
|
|
1636
|
-
if (!child) {
|
|
1637
|
-
return;
|
|
1638
|
-
}
|
|
1639
|
-
const childState = child
|
|
1640
|
-
?.get("FAMC")
|
|
1641
|
-
?.toList()
|
|
1642
|
-
?.filter((item) => item.value === family.id)
|
|
1643
|
-
.index(0);
|
|
1644
|
-
const childType = childState?.get("PEDI")?.toValue() ||
|
|
1645
|
-
RelationType.BIOLOGICAL;
|
|
1646
|
-
if ((!childType &&
|
|
1647
|
-
filter.PEDI === RelationType.BIOLOGICAL) ||
|
|
1648
|
-
childType?.toLowerCase() === filter.PEDI.toLowerCase()) {
|
|
1649
|
-
children.append(child);
|
|
1650
|
-
}
|
|
1651
|
-
});
|
|
1652
|
-
}
|
|
1653
|
-
});
|
|
1654
|
-
return children;
|
|
1655
|
-
}
|
|
1656
|
-
getBiologicalChildren() {
|
|
1657
|
-
implemented("getBiologicalChildren");
|
|
1658
|
-
return this.getChildrenFilteredByPedigree(Filters.BIOLOGICAL);
|
|
1659
|
-
}
|
|
1660
|
-
getAdoptedChildren() {
|
|
1661
|
-
implemented("getAdoptedChildren");
|
|
1662
|
-
return this.getChildrenFilteredByPedigree(Filters.ADOPTED);
|
|
1663
|
-
}
|
|
1664
|
-
getBirthChildren() {
|
|
1665
|
-
implemented("getBirthChildren");
|
|
1666
|
-
return this.getChildrenFilteredByPedigree(Filters.BIRTH);
|
|
1667
|
-
}
|
|
1668
|
-
getFosterChildren() {
|
|
1669
|
-
implemented("getFosterChildren");
|
|
1670
|
-
return this.getChildrenFilteredByPedigree(Filters.FOSTER);
|
|
1671
|
-
}
|
|
1672
|
-
getSealingChildren() {
|
|
1673
|
-
implemented("getSealingChildren");
|
|
1674
|
-
return this.getChildrenFilteredByPedigree(Filters.SEALING);
|
|
1675
|
-
}
|
|
1676
|
-
getStepChildren() {
|
|
1677
|
-
implemented("getStepChildren");
|
|
1678
|
-
return this.getChildrenFilteredByPedigree(Filters.STEP);
|
|
1679
|
-
}
|
|
1680
|
-
getSons() {
|
|
1681
|
-
implemented("getSons");
|
|
1682
|
-
return this.getChildren().filter(Filters.MALE);
|
|
1683
|
-
}
|
|
1684
|
-
getBiologicalSons() {
|
|
1685
|
-
implemented("getBiologicalSons");
|
|
1686
|
-
return this.getChildrenFilteredByPedigree(Filters.BIOLOGICAL).filter(Filters.MALE);
|
|
1687
|
-
}
|
|
1688
|
-
getAdoptedSons() {
|
|
1689
|
-
implemented("getAdoptedSons");
|
|
1690
|
-
return this.getAdoptedChildren().filter(Filters.MALE);
|
|
1691
|
-
}
|
|
1692
|
-
getBirthSons() {
|
|
1693
|
-
implemented("getBirthSons");
|
|
1694
|
-
return this.getBirthChildren().filter(Filters.MALE);
|
|
1695
|
-
}
|
|
1696
|
-
getFosterSons() {
|
|
1697
|
-
implemented("getFosterSons");
|
|
1698
|
-
return this.getFosterChildren().filter(Filters.MALE);
|
|
1699
|
-
}
|
|
1700
|
-
getSealingSons() {
|
|
1701
|
-
implemented("getSealingSons");
|
|
1702
|
-
return this.getSealingChildren().filter(Filters.MALE);
|
|
1703
|
-
}
|
|
1704
|
-
getStepSons() {
|
|
1705
|
-
implemented("getStepSons");
|
|
1706
|
-
return this.getStepChildren().filter(Filters.MALE);
|
|
1707
|
-
}
|
|
1708
|
-
getDaughters() {
|
|
1709
|
-
implemented("getDaughters");
|
|
1710
|
-
return this.getChildren().filter(Filters.FEMALE);
|
|
1711
|
-
}
|
|
1712
|
-
getBiologicalDaugthers() {
|
|
1713
|
-
implemented("getBiologicalDaugthers");
|
|
1714
|
-
return this.getChildrenFilteredByPedigree(Filters.BIOLOGICAL).filter(Filters.FEMALE);
|
|
1715
|
-
}
|
|
1716
|
-
getAdoptedDaughters() {
|
|
1717
|
-
implemented("getAdoptedDaughters");
|
|
1718
|
-
return this.getAdoptedChildren().filter(Filters.FEMALE);
|
|
1719
|
-
}
|
|
1720
|
-
getBirthDaughters() {
|
|
1721
|
-
implemented("getBirthDaughters");
|
|
1722
|
-
return this.getBirthChildren().filter(Filters.FEMALE);
|
|
1723
|
-
}
|
|
1724
|
-
getFosterDaughters() {
|
|
1725
|
-
implemented("getFosterDaughters");
|
|
1726
|
-
return this.getFosterChildren().filter(Filters.FEMALE);
|
|
1727
|
-
}
|
|
1728
|
-
getSealingDaughters() {
|
|
1729
|
-
implemented("getSealingDaughters");
|
|
1730
|
-
return this.getSealingChildren().filter(Filters.FEMALE);
|
|
1731
|
-
}
|
|
1732
|
-
getStepDaughters() {
|
|
1733
|
-
implemented("getStepDaughters");
|
|
1734
|
-
return this.getStepChildren().filter(Filters.FEMALE);
|
|
1735
|
-
}
|
|
1736
|
-
getParents(filter) {
|
|
1737
|
-
implemented("getParents");
|
|
1738
|
-
return this.getAscendants(1, filter);
|
|
1739
|
-
}
|
|
1740
|
-
getParentsFilteredByPedigree(filter) {
|
|
1741
|
-
const parents = new Individuals();
|
|
1742
|
-
const familiesOfParents = this.get("FAMC")?.toValueList();
|
|
1743
|
-
if (!familiesOfParents || !this.id) {
|
|
1744
|
-
return parents;
|
|
1745
|
-
}
|
|
1746
|
-
const families = this.toFamilies(familiesOfParents);
|
|
1747
|
-
families.forEach((family) => {
|
|
1748
|
-
const child = this.id && family.CHIL?.toValueList()?.item(this.id);
|
|
1749
|
-
if (!child) {
|
|
1750
|
-
const childState = this?.get("FAMC")
|
|
1751
|
-
?.toList()
|
|
1752
|
-
?.filter((item) => item.value === family.id)
|
|
1753
|
-
.index(0);
|
|
1754
|
-
const parentType = childState?.get("PEDI")?.toValue() ||
|
|
1755
|
-
RelationType.BIOLOGICAL;
|
|
1756
|
-
if ((!parentType && filter.PEDI === RelationType.BIOLOGICAL) ||
|
|
1757
|
-
parentType?.toLowerCase() === filter.PEDI.toLowerCase()) {
|
|
1758
|
-
parents.merge(family.getParents());
|
|
1759
|
-
}
|
|
1760
|
-
return;
|
|
1761
|
-
}
|
|
1762
|
-
const fatherType = child.get("_FREL")?.toValue();
|
|
1763
|
-
const motherType = child.get("_MREL")?.toValue();
|
|
1764
|
-
if ((!fatherType && filter.PEDI === RelationType.BIOLOGICAL) ||
|
|
1765
|
-
fatherType?.toLowerCase() === filter.PEDI.toLowerCase()) {
|
|
1766
|
-
const fatherId = family.get("HUSB")?.toValue();
|
|
1767
|
-
const father = fatherId && this._gedcom?.indi(fatherId);
|
|
1768
|
-
if (father) {
|
|
1769
|
-
parents.append(father);
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
if ((!motherType && filter.PEDI === RelationType.BIOLOGICAL) ||
|
|
1773
|
-
motherType?.toLowerCase() === filter.PEDI.toLowerCase()) {
|
|
1774
|
-
const motherId = family.get("WIFE")?.toValue();
|
|
1775
|
-
const mother = motherId && this._gedcom?.indi(motherId);
|
|
1776
|
-
if (mother) {
|
|
1777
|
-
parents.append(mother);
|
|
1778
|
-
}
|
|
1779
|
-
}
|
|
1780
|
-
});
|
|
1781
|
-
return parents;
|
|
1782
|
-
}
|
|
1783
|
-
getSpousesFilteredByPartner(filter) {
|
|
1784
|
-
const spouses = new Individuals();
|
|
1785
|
-
const familiesOfSpouses = this.get("FAMS")?.toValueList();
|
|
1786
|
-
if (!familiesOfSpouses || !this.id) {
|
|
1787
|
-
return spouses;
|
|
1788
|
-
}
|
|
1789
|
-
const families = this.toFamilies(familiesOfSpouses);
|
|
1790
|
-
families.forEach((family) => {
|
|
1791
|
-
const spouseType = family.get("_SREL")?.toValue();
|
|
1792
|
-
if ((!spouseType && filter.PART === PartnerType.SPOUSE) ||
|
|
1793
|
-
spouseType?.toLowerCase() === filter.PART.toLowerCase()) {
|
|
1794
|
-
const spouse = family.getParents().copy().except(this).index(0);
|
|
1795
|
-
if (spouse) {
|
|
1796
|
-
spouses.append(spouse);
|
|
1797
|
-
}
|
|
1798
|
-
}
|
|
1799
|
-
});
|
|
1800
|
-
return spouses;
|
|
1801
|
-
}
|
|
1802
|
-
getBiologicalParents() {
|
|
1803
|
-
implemented("getBiologicalParents");
|
|
1804
|
-
return this.getParentsFilteredByPedigree(Filters.BIOLOGICAL);
|
|
1805
|
-
}
|
|
1806
|
-
getAdoptedParents() {
|
|
1807
|
-
implemented("getAdoptedParents");
|
|
1808
|
-
return this.getParentsFilteredByPedigree(Filters.ADOPTED);
|
|
1809
|
-
}
|
|
1810
|
-
getBirthParents() {
|
|
1811
|
-
implemented("getBirthParents");
|
|
1812
|
-
return this.getParentsFilteredByPedigree(Filters.BIRTH);
|
|
1813
|
-
}
|
|
1814
|
-
getFosterParents() {
|
|
1815
|
-
implemented("getFosterParents");
|
|
1816
|
-
return this.getParentsFilteredByPedigree(Filters.FOSTER);
|
|
1817
|
-
}
|
|
1818
|
-
getSealingParents() {
|
|
1819
|
-
implemented("getSealingParents");
|
|
1820
|
-
return this.getParentsFilteredByPedigree(Filters.SEALING);
|
|
1821
|
-
}
|
|
1822
|
-
getStepParents() {
|
|
1823
|
-
implemented("getStepParents");
|
|
1824
|
-
return this.getParentsFilteredByPedigree(Filters.STEP);
|
|
1825
|
-
}
|
|
1826
|
-
getFathers() {
|
|
1827
|
-
implemented("getFathers");
|
|
1828
|
-
return this.getParents().filter(Filters.MALE);
|
|
1829
|
-
}
|
|
1830
|
-
getBiologicalFathers() {
|
|
1831
|
-
implemented("getBiologicalFathers");
|
|
1832
|
-
return this.getParentsFilteredByPedigree(Filters.BIOLOGICAL).filter(Filters.MALE);
|
|
1833
|
-
}
|
|
1834
|
-
getAdoptedFathers() {
|
|
1835
|
-
implemented("getAdoptedFathers");
|
|
1836
|
-
return this.getParentsFilteredByPedigree(Filters.ADOPTED).filter(Filters.MALE);
|
|
1837
|
-
}
|
|
1838
|
-
getBirthFathers() {
|
|
1839
|
-
implemented("getBirthFathers");
|
|
1840
|
-
return this.getParentsFilteredByPedigree(Filters.BIRTH).filter(Filters.MALE);
|
|
1841
|
-
}
|
|
1842
|
-
getFosterFathers() {
|
|
1843
|
-
implemented("getFosterFathers");
|
|
1844
|
-
return this.getParentsFilteredByPedigree(Filters.FOSTER).filter(Filters.MALE);
|
|
1845
|
-
}
|
|
1846
|
-
getSealingFathers() {
|
|
1847
|
-
implemented("getSealingFathers");
|
|
1848
|
-
return this.getParentsFilteredByPedigree(Filters.SEALING).filter(Filters.MALE);
|
|
1849
|
-
}
|
|
1850
|
-
getStepFathers() {
|
|
1851
|
-
implemented("getStepFathers");
|
|
1852
|
-
return this.getParentsFilteredByPedigree(Filters.STEP).filter(Filters.MALE);
|
|
1853
|
-
}
|
|
1854
|
-
getMothers() {
|
|
1855
|
-
implemented("getMothers");
|
|
1856
|
-
return this.getParents().filter(Filters.FEMALE);
|
|
1857
|
-
}
|
|
1858
|
-
getBiologicalMothers() {
|
|
1859
|
-
implemented("getBiologicalMothers");
|
|
1860
|
-
return this.getParentsFilteredByPedigree(Filters.BIOLOGICAL).filter(Filters.FEMALE);
|
|
1861
|
-
}
|
|
1862
|
-
getAdoptedMothers() {
|
|
1863
|
-
implemented("getAdoptedMothers");
|
|
1864
|
-
return this.getParentsFilteredByPedigree(Filters.ADOPTED).filter(Filters.FEMALE);
|
|
1865
|
-
}
|
|
1866
|
-
getBirthMothers() {
|
|
1867
|
-
implemented("getBirthMothers");
|
|
1868
|
-
return this.getParentsFilteredByPedigree(Filters.BIRTH).filter(Filters.FEMALE);
|
|
1869
|
-
}
|
|
1870
|
-
getFosterMothers() {
|
|
1871
|
-
implemented("getFosterMothers");
|
|
1872
|
-
return this.getParentsFilteredByPedigree(Filters.FOSTER).filter(Filters.FEMALE);
|
|
1873
|
-
}
|
|
1874
|
-
getSealingMothers() {
|
|
1875
|
-
implemented("getSealingMothers");
|
|
1876
|
-
return this.getParentsFilteredByPedigree(Filters.SEALING).filter(Filters.FEMALE);
|
|
1877
|
-
}
|
|
1878
|
-
getStepMothers() {
|
|
1879
|
-
implemented("getStepMothers");
|
|
1880
|
-
return this.getParentsFilteredByPedigree(Filters.STEP).filter(Filters.FEMALE);
|
|
1881
|
-
}
|
|
1882
|
-
getCoParents() {
|
|
1883
|
-
implemented("getCoParents");
|
|
1884
|
-
return this.getRelativesOnLevel(0);
|
|
1885
|
-
}
|
|
1886
|
-
getSpouses() {
|
|
1887
|
-
implemented("getCertifiedSpouses");
|
|
1888
|
-
return this.getSpousesFilteredByPartner(Filters.SPOUSE);
|
|
1889
|
-
}
|
|
1890
|
-
getPartners() {
|
|
1891
|
-
implemented("getPartners");
|
|
1892
|
-
return this.getSpousesFilteredByPartner(Filters.PARTNER);
|
|
1893
|
-
}
|
|
1894
|
-
getFriends() {
|
|
1895
|
-
implemented("getFriends");
|
|
1896
|
-
return this.getSpousesFilteredByPartner(Filters.FRIEND);
|
|
1897
|
-
}
|
|
1898
|
-
getWives() {
|
|
1899
|
-
implemented("getWives");
|
|
1900
|
-
return this.getCoParents().filter(Filters.FEMALE);
|
|
1901
|
-
}
|
|
1902
|
-
getHusbands() {
|
|
1903
|
-
implemented("getHusbands");
|
|
1904
|
-
return this.getCoParents().filter(Filters.MALE);
|
|
1905
|
-
}
|
|
1906
|
-
getCousins() {
|
|
1907
|
-
implemented("getCousins");
|
|
1908
|
-
return this.getRelativesOnDegree(1);
|
|
1909
|
-
}
|
|
1910
|
-
getGrandParents() {
|
|
1911
|
-
implemented("getGrandParents");
|
|
1912
|
-
return this.getAscendants(2);
|
|
1913
|
-
}
|
|
1914
|
-
getGrandFathers() {
|
|
1915
|
-
implemented("getGrandFathers");
|
|
1916
|
-
return this.getGrandParents().filter(Filters.MALE);
|
|
1917
|
-
}
|
|
1918
|
-
getGrandMothers() {
|
|
1919
|
-
implemented("getGrandMothers");
|
|
1920
|
-
return this.getGrandParents().filter(Filters.FEMALE);
|
|
1921
|
-
}
|
|
1922
|
-
getGrandChildren() {
|
|
1923
|
-
implemented("getGrandChildren");
|
|
1924
|
-
return this.getDescendants(2);
|
|
1925
|
-
}
|
|
1926
|
-
getGrandSons() {
|
|
1927
|
-
implemented("getGrandSons");
|
|
1928
|
-
return this.getGrandChildren().filter(Filters.MALE);
|
|
1929
|
-
}
|
|
1930
|
-
getGrandDaughters() {
|
|
1931
|
-
implemented("getGrandDaughters");
|
|
1932
|
-
return this.getGrandChildren().filter(Filters.FEMALE);
|
|
1933
|
-
}
|
|
1934
|
-
getGreatGrandParents() {
|
|
1935
|
-
implemented("getGreatGrandParents");
|
|
1936
|
-
return this.getAscendants(3);
|
|
1937
|
-
}
|
|
1938
|
-
getGreatGrandFathers() {
|
|
1939
|
-
implemented("getGreatGrandFathers");
|
|
1940
|
-
return this.getGreatGrandParents().filter(Filters.MALE);
|
|
1941
|
-
}
|
|
1942
|
-
getGreatGrandMothers() {
|
|
1943
|
-
implemented("getGreatGrandMothers");
|
|
1944
|
-
return this.getGreatGrandParents().filter(Filters.FEMALE);
|
|
1945
|
-
}
|
|
1946
|
-
getGreatGrandChildren() {
|
|
1947
|
-
implemented("getGreatGrandChildren");
|
|
1948
|
-
return this.getDescendants(3);
|
|
1949
|
-
}
|
|
1950
|
-
getGreatGrandSons() {
|
|
1951
|
-
implemented("getGreatGrandSons");
|
|
1952
|
-
return this.getGreatGrandChildren().filter(Filters.MALE);
|
|
1953
|
-
}
|
|
1954
|
-
getGreatGrandDaughters() {
|
|
1955
|
-
implemented("getGreatGrandDaughters");
|
|
1956
|
-
return this.getGreatGrandChildren().filter(Filters.FEMALE);
|
|
1957
|
-
}
|
|
1958
|
-
getAuncles() {
|
|
1959
|
-
implemented("getAuncles");
|
|
1960
|
-
return this.getParents().getSiblings();
|
|
1961
|
-
}
|
|
1962
|
-
getAunts() {
|
|
1963
|
-
implemented("getAunts");
|
|
1964
|
-
return this.getAuncles().filter(Filters.FEMALE);
|
|
1965
|
-
}
|
|
1966
|
-
getUncles() {
|
|
1967
|
-
implemented("getUncles");
|
|
1968
|
-
return this.getAuncles().filter(Filters.MALE);
|
|
1969
|
-
}
|
|
1970
|
-
getNiblings() {
|
|
1971
|
-
implemented("getNiblings");
|
|
1972
|
-
return this.getSiblings().getChildren();
|
|
1973
|
-
}
|
|
1974
|
-
getNieces() {
|
|
1975
|
-
implemented("getNieces");
|
|
1976
|
-
return this.getNiblings().filter(Filters.FEMALE);
|
|
1977
|
-
}
|
|
1978
|
-
getNephews() {
|
|
1979
|
-
implemented("getNephews");
|
|
1980
|
-
return this.getNiblings().filter(Filters.MALE);
|
|
1981
|
-
}
|
|
1982
|
-
getParentsInLaw() {
|
|
1983
|
-
implemented("getParentsInLaw");
|
|
1984
|
-
return this.getCoParents().getParents();
|
|
1985
|
-
}
|
|
1986
|
-
getFathersInLaw() {
|
|
1987
|
-
implemented("getFathersInLaw");
|
|
1988
|
-
return this.getParentsInLaw().filter(Filters.MALE);
|
|
1989
|
-
}
|
|
1990
|
-
getMothersInLaw() {
|
|
1991
|
-
implemented("getMothersInLaw");
|
|
1992
|
-
return this.getParentsInLaw().filter(Filters.FEMALE);
|
|
1993
|
-
}
|
|
1994
|
-
getSiblingsInLaw() {
|
|
1995
|
-
implemented("getSiblingsInLaw");
|
|
1996
|
-
return this.getCoParents()
|
|
1997
|
-
.copy()
|
|
1998
|
-
.getSiblings()
|
|
1999
|
-
.copy()
|
|
2000
|
-
.merge(this.getSiblings().getCoParents());
|
|
2001
|
-
}
|
|
2002
|
-
getBrothersInLaw() {
|
|
2003
|
-
implemented("getBrothersInLaw");
|
|
2004
|
-
return this.getSiblingsInLaw().filter(Filters.MALE);
|
|
2005
|
-
}
|
|
2006
|
-
getSistersInLaw() {
|
|
2007
|
-
implemented("getSistersInLaw");
|
|
2008
|
-
return this.getSiblingsInLaw().filter(Filters.FEMALE);
|
|
2009
|
-
}
|
|
2010
|
-
getChildrenInLaw() {
|
|
2011
|
-
implemented("getChildrenInLaw");
|
|
2012
|
-
return this.getChildren().getCoParents();
|
|
2013
|
-
}
|
|
2014
|
-
getSonsInLaw() {
|
|
2015
|
-
implemented("getSonsInLaw");
|
|
2016
|
-
return this.getChildrenInLaw().filter(Filters.MALE);
|
|
2017
|
-
}
|
|
2018
|
-
getDaughtersInLaw() {
|
|
2019
|
-
implemented("getDaughtersInLaw");
|
|
2020
|
-
return this.getChildrenInLaw().filter(Filters.FEMALE);
|
|
2021
|
-
}
|
|
2022
|
-
// These are generated automatically
|
|
2023
|
-
get2ndCousins() {
|
|
2024
|
-
return new Individuals();
|
|
2025
|
-
}
|
|
2026
|
-
get2ndGreatGrandParents() {
|
|
2027
|
-
return new Individuals();
|
|
2028
|
-
}
|
|
2029
|
-
get2ndGreatGrandChildren() {
|
|
2030
|
-
return new Individuals();
|
|
2031
|
-
}
|
|
2032
|
-
get3rdCousins() {
|
|
2033
|
-
return new Individuals();
|
|
2034
|
-
}
|
|
2035
|
-
get3rdGreatGrandParents() {
|
|
2036
|
-
return new Individuals();
|
|
2037
|
-
}
|
|
2038
|
-
get3rdGreatGrandChildren() {
|
|
2039
|
-
return new Individuals();
|
|
2040
|
-
}
|
|
2041
|
-
get4thCousins() {
|
|
2042
|
-
return new Individuals();
|
|
2043
|
-
}
|
|
2044
|
-
get4thGreatGrandParents() {
|
|
2045
|
-
return new Individuals();
|
|
2046
|
-
}
|
|
2047
|
-
get4thGreatGrandChildren() {
|
|
2048
|
-
return new Individuals();
|
|
2049
|
-
}
|
|
2050
|
-
get5thCousins() {
|
|
2051
|
-
return new Individuals();
|
|
2052
|
-
}
|
|
2053
|
-
get5thGreatGrandParents() {
|
|
2054
|
-
return new Individuals();
|
|
2055
|
-
}
|
|
2056
|
-
get5thGreatGrandChildren() {
|
|
2057
|
-
return new Individuals();
|
|
2058
|
-
}
|
|
2059
|
-
get6thCousins() {
|
|
2060
|
-
return new Individuals();
|
|
2061
|
-
}
|
|
2062
|
-
get6thGreatGrandParents() {
|
|
2063
|
-
return new Individuals();
|
|
2064
|
-
}
|
|
2065
|
-
get6thGreatGrandChildren() {
|
|
2066
|
-
return new Individuals();
|
|
2067
|
-
}
|
|
2068
|
-
get7thCousins() {
|
|
2069
|
-
return new Individuals();
|
|
2070
|
-
}
|
|
2071
|
-
get7thGreatGrandParents() {
|
|
2072
|
-
return new Individuals();
|
|
2073
|
-
}
|
|
2074
|
-
get7thGreatGrandChildren() {
|
|
2075
|
-
return new Individuals();
|
|
2076
|
-
}
|
|
2077
|
-
get8thCousins() {
|
|
2078
|
-
return new Individuals();
|
|
2079
|
-
}
|
|
2080
|
-
get8thGreatGrandParents() {
|
|
2081
|
-
return new Individuals();
|
|
2082
|
-
}
|
|
2083
|
-
get8thGreatGrandChildren() {
|
|
2084
|
-
return new Individuals();
|
|
2085
|
-
}
|
|
2086
|
-
get9thCousins() {
|
|
2087
|
-
return new Individuals();
|
|
2088
|
-
}
|
|
2089
|
-
get9thGreatGrandParents() {
|
|
2090
|
-
return new Individuals();
|
|
2091
|
-
}
|
|
2092
|
-
get9thGreatGrandChildren() {
|
|
2093
|
-
return new Individuals();
|
|
2094
|
-
}
|
|
2095
|
-
}
|
|
2096
|
-
const generateFunctions = () => {
|
|
2097
|
-
const levels = [2, 3, 4, 5, 6, 7, 8, 9];
|
|
2098
|
-
const types = [
|
|
2099
|
-
["Cousins", 0, "degree"],
|
|
2100
|
-
["GreatGrandParents", 2, "level"],
|
|
2101
|
-
["GreatGrandChildren", -2, "level"],
|
|
2102
|
-
];
|
|
2103
|
-
levels.forEach((level) => {
|
|
2104
|
-
types.forEach(([type, starting, direction]) => {
|
|
2105
|
-
let validLevel;
|
|
2106
|
-
if (level === 2) {
|
|
2107
|
-
validLevel = "2nd";
|
|
2108
|
-
}
|
|
2109
|
-
else if (level === 3) {
|
|
2110
|
-
validLevel = "3rd";
|
|
2111
|
-
}
|
|
2112
|
-
else {
|
|
2113
|
-
validLevel = `${level}th`;
|
|
2114
|
-
}
|
|
2115
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
2116
|
-
Indi.prototype[`get${validLevel}${type}`] = function (filter) {
|
|
2117
|
-
if (direction === "level" && starting < 0) {
|
|
2118
|
-
return this.getRelativesOnLevel(-level + starting, filter);
|
|
2119
|
-
}
|
|
2120
|
-
else if (direction === "level" && starting > 0) {
|
|
2121
|
-
return this.getRelativesOnLevel(level + starting, filter);
|
|
2122
|
-
}
|
|
2123
|
-
return this.getRelativesOnDegree(level + starting);
|
|
2124
|
-
};
|
|
2125
|
-
});
|
|
2126
|
-
});
|
|
2127
|
-
};
|
|
2128
|
-
generateFunctions();
|
|
2129
|
-
export const createIndi = (gedcom, id, main, parent) => {
|
|
2130
|
-
return createProxy(new Indi(gedcom, id, main, parent));
|
|
2131
|
-
};
|