@treeviz/gedcom-parser 2.0.8 → 2.0.10

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.
Files changed (37) hide show
  1. package/dist/classes/index.js +627 -159
  2. package/dist/classes/indi.d.ts.map +1 -1
  3. package/dist/cli/index.js +627 -159
  4. package/dist/constants/index.js +626 -158
  5. package/dist/factories/index.js +626 -158
  6. package/dist/index.js +628 -160
  7. package/dist/kinship-translator/index.d.ts +1 -0
  8. package/dist/kinship-translator/index.d.ts.map +1 -1
  9. package/dist/kinship-translator/index.js +627 -159
  10. package/dist/kinship-translator/kinship-translator.basic.d.ts +11 -0
  11. package/dist/kinship-translator/kinship-translator.basic.d.ts.map +1 -1
  12. package/dist/kinship-translator/kinship-translator.d.ts.map +1 -1
  13. package/dist/kinship-translator/kinship-translator.de.d.ts +2 -1
  14. package/dist/kinship-translator/kinship-translator.de.d.ts.map +1 -1
  15. package/dist/kinship-translator/kinship-translator.en.d.ts +2 -1
  16. package/dist/kinship-translator/kinship-translator.en.d.ts.map +1 -1
  17. package/dist/kinship-translator/kinship-translator.es.d.ts +2 -1
  18. package/dist/kinship-translator/kinship-translator.es.d.ts.map +1 -1
  19. package/dist/kinship-translator/kinship-translator.fr.d.ts +2 -1
  20. package/dist/kinship-translator/kinship-translator.fr.d.ts.map +1 -1
  21. package/dist/kinship-translator/kinship-translator.hu.d.ts +8 -1
  22. package/dist/kinship-translator/kinship-translator.hu.d.ts.map +1 -1
  23. package/dist/kinship-translator/kinship-translator.interface.d.ts +1 -0
  24. package/dist/kinship-translator/kinship-translator.interface.d.ts.map +1 -1
  25. package/dist/kinship-translator/kinship-translator.ru.d.ts +18 -0
  26. package/dist/kinship-translator/kinship-translator.ru.d.ts.map +1 -0
  27. package/dist/kinship-translator/patterns.es.d.ts.map +1 -1
  28. package/dist/kinship-translator/patterns.ru.d.ts +2 -0
  29. package/dist/kinship-translator/patterns.ru.d.ts.map +1 -0
  30. package/dist/kinship-translator/translators.d.ts +1 -0
  31. package/dist/kinship-translator/translators.d.ts.map +1 -1
  32. package/dist/kinship-translator/types.d.ts +1 -1
  33. package/dist/kinship-translator/types.d.ts.map +1 -1
  34. package/dist/utils/cache.d.ts +14 -1
  35. package/dist/utils/cache.d.ts.map +1 -1
  36. package/dist/utils/index.js +628 -160
  37. package/package.json +1 -1
@@ -63,7 +63,8 @@ __export(translators_exports, {
63
63
  en: () => KinshipTranslatorEn,
64
64
  es: () => KinshipTranslatorEs,
65
65
  fr: () => KinshipTranslatorFr,
66
- hu: () => KinshipTranslatorHU
66
+ hu: () => KinshipTranslatorHU,
67
+ ru: () => KinshipTranslatorRu
67
68
  });
68
69
 
69
70
  // src/constants/filters.ts
@@ -1898,6 +1899,135 @@ var profilePictureCache = (gedcom, key, value) => {
1898
1899
  const cached = caches.profilePictureCache?.[fullKey];
1899
1900
  return cached;
1900
1901
  };
1902
+ var isNonBiologicalPath = (path) => path.some(
1903
+ (item) => item.relation && item.relation !== "biological" /* BIOLOGICAL */
1904
+ );
1905
+ var invertHop = (kinship) => {
1906
+ if (kinship === "parent") {
1907
+ return "child";
1908
+ }
1909
+ if (kinship === "child") {
1910
+ return "parent";
1911
+ }
1912
+ return kinship;
1913
+ };
1914
+ var hopRelation = (from, toIndi, kinship, inherited) => {
1915
+ if (kinship === "parent" || kinship === "child") {
1916
+ const parent = kinship === "parent" ? toIndi : from.indi;
1917
+ const child = kinship === "parent" ? from.indi : toIndi;
1918
+ const currentRelation = child.getParentType(parent);
1919
+ if (currentRelation && currentRelation !== "biological" /* BIOLOGICAL */) {
1920
+ return currentRelation;
1921
+ }
1922
+ }
1923
+ if (inherited && inherited !== "biological" /* BIOLOGICAL */) {
1924
+ return inherited;
1925
+ }
1926
+ return void 0;
1927
+ };
1928
+ var rebuildPathFromHops = (hops, skipRelation = false) => {
1929
+ if (hops.length === 0) {
1930
+ return [];
1931
+ }
1932
+ const path = [
1933
+ {
1934
+ indi: hops[0].indi,
1935
+ kinship: "self",
1936
+ level: 0,
1937
+ levelUp: 0,
1938
+ levelDown: 0,
1939
+ degree: 0
1940
+ }
1941
+ ];
1942
+ for (let i = 1; i < hops.length; i++) {
1943
+ const prev = path[i - 1];
1944
+ const { indi, kinship } = hops[i];
1945
+ const relation = skipRelation ? void 0 : hopRelation(prev, indi, kinship, prev.relation);
1946
+ if (kinship === "parent") {
1947
+ path.push({
1948
+ indi,
1949
+ kinship,
1950
+ relation,
1951
+ level: prev.level + 1,
1952
+ levelUp: prev.levelUp + 1,
1953
+ levelDown: prev.levelDown,
1954
+ degree: prev.degree
1955
+ });
1956
+ continue;
1957
+ }
1958
+ if (kinship === "child") {
1959
+ path.push({
1960
+ indi,
1961
+ kinship,
1962
+ relation,
1963
+ level: prev.level - 1,
1964
+ levelUp: prev.levelUp,
1965
+ levelDown: prev.levelDown + 1,
1966
+ degree: prev.levelUp ? prev.level > 0 ? prev.levelUp - prev.level + 1 : prev.levelDown - Math.abs(prev.level) : 0
1967
+ });
1968
+ continue;
1969
+ }
1970
+ path.push({
1971
+ indi,
1972
+ kinship,
1973
+ relation,
1974
+ level: prev.level,
1975
+ levelUp: prev.levelUp,
1976
+ levelDown: prev.levelDown,
1977
+ degree: prev.degree
1978
+ });
1979
+ }
1980
+ return path;
1981
+ };
1982
+ var storePathIfBetter = (gedcom, fromId, toId, path) => {
1983
+ const key = `${fromId}|${toId}`;
1984
+ const existing = pathCache(gedcom, key);
1985
+ if (existing && (!isNonBiologicalPath(existing) || isNonBiologicalPath(path))) {
1986
+ return;
1987
+ }
1988
+ pathCache(gedcom, key, path);
1989
+ };
1990
+ var cacheDiscoveredPath = (gedcom, path) => {
1991
+ const n = path.length;
1992
+ if (n < 2) {
1993
+ return;
1994
+ }
1995
+ for (let i = 0; i < n; i++) {
1996
+ const fromId = path[i].indi.id;
1997
+ if (!fromId) {
1998
+ continue;
1999
+ }
2000
+ for (let j = i + 1; j < n; j++) {
2001
+ const toId = path[j].indi.id;
2002
+ if (!toId) {
2003
+ continue;
2004
+ }
2005
+ const isOriginalPair = i === 0 && j === n - 1;
2006
+ const isDirectHop = j === i + 1;
2007
+ const slice = path.slice(i, j + 1);
2008
+ const sliceMixed = isNonBiologicalPath(slice);
2009
+ if (!isOriginalPair && !isDirectHop && sliceMixed) {
2010
+ continue;
2011
+ }
2012
+ const forward = i === 0 ? slice : rebuildPathFromHops(slice, !sliceMixed);
2013
+ const reverseHops = [
2014
+ {
2015
+ indi: slice[slice.length - 1].indi,
2016
+ kinship: "self"
2017
+ }
2018
+ ];
2019
+ for (let k = slice.length - 2; k >= 0; k--) {
2020
+ reverseHops.push({
2021
+ indi: slice[k].indi,
2022
+ kinship: invertHop(slice[k + 1].kinship)
2023
+ });
2024
+ }
2025
+ const reverse = rebuildPathFromHops(reverseHops, !sliceMixed);
2026
+ storePathIfBetter(gedcom, fromId, toId, forward);
2027
+ storePathIfBetter(gedcom, toId, fromId, reverse);
2028
+ }
2029
+ }
2030
+ };
1901
2031
 
1902
2032
  // src/utils/get-places.ts
1903
2033
  var getPlaces = (common, type = ["ALL" /* All */], maxLevel = 1, level = 0, mainKey) => {
@@ -3946,7 +4076,6 @@ var Indi = class extends Common {
3946
4076
  if (cache) {
3947
4077
  return cache;
3948
4078
  }
3949
- const visited = new Individuals().append(this);
3950
4079
  const mainItem = {
3951
4080
  indi: this,
3952
4081
  level: 0,
@@ -3955,129 +4084,155 @@ var Indi = class extends Common {
3955
4084
  degree: 0,
3956
4085
  kinship: "self"
3957
4086
  };
3958
- const path = [mainItem];
4087
+ const mainPath = [mainItem];
3959
4088
  if (this.id === usedIndi.id) {
3960
- return path;
4089
+ return mainPath;
3961
4090
  }
3962
- const queue = [
3963
- {
3964
- ...mainItem,
3965
- path
3966
- }
3967
- ];
3968
- let helper = 0;
3969
- while (queue.length > 0) {
3970
- if (helper++ > 1e6) {
3971
- break;
3972
- }
3973
- const {
3974
- indi,
3975
- path: path2,
3976
- kinship,
3977
- relation,
3978
- level,
3979
- levelUp,
3980
- levelDown,
3981
- degree,
3982
- breakOnNext,
3983
- breakAfterNext,
3984
- inLaw
3985
- } = queue.shift();
3986
- if (usedIndi.id === indi.id) {
3987
- if (breakOnNext) {
3988
- return void 0;
4091
+ const bfs = (biologicalOnly) => {
4092
+ const visited = new Individuals().append(this);
4093
+ const queue = [
4094
+ {
4095
+ ...mainItem,
4096
+ path: mainPath
3989
4097
  }
3990
- pathCache(this._gedcom, cacheKey, path2);
3991
- return path2;
3992
- }
3993
- visited.append(indi);
3994
- const additional = {};
3995
- if (breakOnNext || breakAfterNext) {
3996
- additional.breakOnNext = breakOnNext || breakAfterNext;
3997
- }
3998
- if (inLaw) {
3999
- additional.inLaw = inLaw;
4000
- }
4001
- if (kinship === "spouse" && breakAfterSpouse) {
4002
- if (path2.length <= 2) {
4003
- additional.inLaw = true;
4004
- } else {
4005
- additional.breakOnNext = true;
4098
+ ];
4099
+ let helper = 0;
4100
+ while (queue.length > 0) {
4101
+ if (helper++ > 1e6) {
4102
+ break;
4006
4103
  }
4007
- }
4008
- if (kinship !== "child" || !breakAfterSpouse) {
4009
- indi.getBiologicalFathers().copy().merge(indi.getBiologicalMothers()).merge(indi.getFathers().copy().merge(indi.getMothers())).forEach((relative) => {
4104
+ const {
4105
+ indi,
4106
+ path,
4107
+ kinship,
4108
+ relation,
4109
+ level,
4110
+ levelUp,
4111
+ levelDown,
4112
+ degree,
4113
+ breakOnNext,
4114
+ breakAfterNext,
4115
+ inLaw
4116
+ } = queue.shift();
4117
+ if (usedIndi.id === indi.id) {
4118
+ if (breakOnNext) {
4119
+ return void 0;
4120
+ }
4121
+ return path;
4122
+ }
4123
+ visited.append(indi);
4124
+ const additional = {};
4125
+ if (breakOnNext || breakAfterNext) {
4126
+ additional.breakOnNext = breakOnNext || breakAfterNext;
4127
+ }
4128
+ if (inLaw) {
4129
+ additional.inLaw = inLaw;
4130
+ }
4131
+ if (!biologicalOnly && kinship === "spouse" && breakAfterSpouse) {
4132
+ if (path.length <= 2) {
4133
+ additional.inLaw = true;
4134
+ } else {
4135
+ additional.breakOnNext = true;
4136
+ }
4137
+ }
4138
+ if (kinship !== "child" || !breakAfterSpouse) {
4139
+ indi.getBiologicalFathers().copy().merge(indi.getBiologicalMothers()).merge(indi.getFathers().copy().merge(indi.getMothers())).forEach((relative) => {
4140
+ if (!visited.has(relative)) {
4141
+ const currentRelation = indi.getParentType(relative);
4142
+ const isNonBiological = !!currentRelation && currentRelation !== "biological" /* BIOLOGICAL */;
4143
+ if (biologicalOnly && isNonBiological) {
4144
+ return;
4145
+ }
4146
+ if (!biologicalOnly && breakAfterNonBiological && isNonBiological) {
4147
+ additional.breakAfterNext = true;
4148
+ }
4149
+ const newItem = {
4150
+ indi: relative,
4151
+ kinship: "parent",
4152
+ relation: isNonBiological ? currentRelation : relation,
4153
+ level: level + 1,
4154
+ levelUp: levelUp + 1,
4155
+ levelDown,
4156
+ degree,
4157
+ ...additional
4158
+ };
4159
+ queue.push({
4160
+ ...newItem,
4161
+ path: [...path, newItem]
4162
+ });
4163
+ }
4164
+ });
4165
+ }
4166
+ indi.getChildren().forEach((relative) => {
4010
4167
  if (!visited.has(relative)) {
4011
- const currentRelation = indi.getParentType(relative);
4012
- if (breakAfterNonBiological && currentRelation !== "biological" /* BIOLOGICAL */) {
4168
+ const currentRelation = relative.getParentType(indi);
4169
+ const isNonBiological = !!currentRelation && currentRelation !== "biological" /* BIOLOGICAL */;
4170
+ if (biologicalOnly && isNonBiological) {
4171
+ return;
4172
+ }
4173
+ if (!biologicalOnly && breakAfterNonBiological && isNonBiological) {
4013
4174
  additional.breakAfterNext = true;
4014
4175
  }
4015
4176
  const newItem = {
4016
4177
  indi: relative,
4017
- kinship: "parent",
4018
- relation: currentRelation && currentRelation !== "biological" /* BIOLOGICAL */ ? currentRelation : relation,
4019
- level: level + 1,
4020
- levelUp: levelUp + 1,
4021
- levelDown,
4022
- degree,
4178
+ kinship: "child",
4179
+ relation: isNonBiological ? currentRelation : relation,
4180
+ level: level - 1,
4181
+ levelUp,
4182
+ levelDown: levelDown + 1,
4183
+ degree: levelUp ? level > 0 ? levelUp - level + 1 : levelDown - Math.abs(level) : 0,
4023
4184
  ...additional
4024
4185
  };
4025
4186
  queue.push({
4026
4187
  ...newItem,
4027
- path: [...path2, newItem]
4188
+ path: [...path, newItem]
4028
4189
  });
4029
4190
  }
4030
4191
  });
4031
- }
4032
- indi.getChildren().forEach((relative) => {
4033
- if (!visited.has(relative)) {
4034
- const currentRelation = relative.getParentType(indi);
4035
- if (breakAfterNonBiological && currentRelation !== "biological" /* BIOLOGICAL */) {
4036
- additional.breakAfterNext = true;
4037
- }
4038
- const newItem = {
4039
- indi: relative,
4040
- kinship: "child",
4041
- relation: currentRelation && currentRelation !== "biological" /* BIOLOGICAL */ ? currentRelation : relation,
4042
- level: level - 1,
4043
- levelUp,
4044
- levelDown: levelDown + 1,
4045
- degree: levelUp ? level > 0 ? levelUp - level + 1 : levelDown - Math.abs(level) : 0,
4046
- ...additional
4047
- };
4048
- queue.push({
4049
- ...newItem,
4050
- path: [...path2, newItem]
4051
- });
4192
+ if (biologicalOnly) {
4193
+ continue;
4052
4194
  }
4053
- });
4054
- indi.getCoParents().forEach((relative) => {
4055
- if (!visited.has(relative)) {
4056
- const currentAddition = {};
4057
- if (relation && relation !== "biological" /* BIOLOGICAL */) {
4058
- currentAddition.relation = relation;
4059
- }
4060
- if (inLaw) {
4061
- currentAddition.breakOnNext = true;
4195
+ indi.getCoParents().forEach((relative) => {
4196
+ if (!visited.has(relative)) {
4197
+ const currentAddition = {};
4198
+ if (relation && relation !== "biological" /* BIOLOGICAL */) {
4199
+ currentAddition.relation = relation;
4200
+ }
4201
+ if (inLaw) {
4202
+ currentAddition.breakOnNext = true;
4203
+ }
4204
+ const newItem = {
4205
+ indi: relative,
4206
+ kinship: "spouse",
4207
+ level,
4208
+ levelUp,
4209
+ levelDown,
4210
+ degree,
4211
+ ...additional,
4212
+ ...currentAddition
4213
+ };
4214
+ queue.push({
4215
+ ...newItem,
4216
+ path: [...path, newItem]
4217
+ });
4062
4218
  }
4063
- const newItem = {
4064
- indi: relative,
4065
- kinship: "spouse",
4066
- level,
4067
- levelUp,
4068
- levelDown,
4069
- degree,
4070
- ...additional,
4071
- ...currentAddition
4072
- };
4073
- queue.push({
4074
- ...newItem,
4075
- path: [...path2, newItem]
4076
- });
4077
- }
4078
- });
4219
+ });
4220
+ }
4221
+ return void 0;
4222
+ };
4223
+ const foundPath = bfs(false);
4224
+ const lastItem = foundPath?.[foundPath.length - 1];
4225
+ if (lastItem?.relation && lastItem.relation !== "biological" /* BIOLOGICAL */) {
4226
+ const biologicalPath = bfs(true);
4227
+ if (biologicalPath) {
4228
+ cacheDiscoveredPath(this._gedcom, biologicalPath);
4229
+ return biologicalPath;
4230
+ }
4079
4231
  }
4080
- return void 0;
4232
+ if (foundPath) {
4233
+ cacheDiscoveredPath(this._gedcom, foundPath);
4234
+ }
4235
+ return foundPath;
4081
4236
  }
4082
4237
  kinship(other, showMainPerson, lang = "en", entirePath, displayName = "givenname") {
4083
4238
  const KinshipTranslatorClass2 = getKinshipTranslatorClass();
@@ -5049,6 +5204,44 @@ var KinshipTranslatorBasic = class {
5049
5204
  }
5050
5205
  return this.pathN?.indi;
5051
5206
  }
5207
+ /**
5208
+ * True when the path goes through a common ancestor whose two children
5209
+ * (the person we came from and the person we go to) share fewer than two
5210
+ * biological parents — i.e. they are half-siblings, so every collateral
5211
+ * relative on this path is a half-aunt/half-cousin/... too.
5212
+ *
5213
+ * Direct ancestors/descendants and paths that already use a
5214
+ * step/adopted/foster edge are never half-blood.
5215
+ */
5216
+ get isHalfBlood() {
5217
+ const path = this.path;
5218
+ if (!path || path.length < 3) {
5219
+ return false;
5220
+ }
5221
+ if (path.some(
5222
+ (item) => item.relation && item.relation !== "biological" /* BIOLOGICAL */
5223
+ )) {
5224
+ return false;
5225
+ }
5226
+ let peakIndex = -1;
5227
+ for (let i = 1; i < path.length; i++) {
5228
+ if (path[i].kinship === "parent") {
5229
+ peakIndex = i;
5230
+ }
5231
+ }
5232
+ if (peakIndex <= 0 || peakIndex >= path.length - 1) {
5233
+ return false;
5234
+ }
5235
+ if (path[peakIndex + 1].kinship !== "child") {
5236
+ return false;
5237
+ }
5238
+ const siblingA = path[peakIndex - 1].indi;
5239
+ const siblingB = path[peakIndex + 1].indi;
5240
+ const parentsA = siblingA.getBiologicalParents();
5241
+ const parentsB = siblingB.getBiologicalParents();
5242
+ const inter = parentsA.intersection(parentsB);
5243
+ return inter.length === 1 && (parentsA.length > 1 || parentsB.length > 1);
5244
+ }
5052
5245
  indirect() {
5053
5246
  return "";
5054
5247
  }
@@ -5076,6 +5269,9 @@ var KinshipTranslatorBasic = class {
5076
5269
  relationType(relation) {
5077
5270
  return relation ?? "";
5078
5271
  }
5272
+ halfBlood(relation) {
5273
+ return relation ?? "";
5274
+ }
5079
5275
  of(relation) {
5080
5276
  return relation ?? "";
5081
5277
  }
@@ -5314,14 +5510,34 @@ var KinshipTranslatorHU = class extends KinshipTranslatorBasic {
5314
5510
  return `${prefix.replace(/nagy$/, "")}unoka`;
5315
5511
  }
5316
5512
  sibling() {
5317
- const parents1 = this.person1?.getBiologicalParents();
5318
- const parentsN = this.personN?.getBiologicalParents();
5319
- const inter = parents1?.intersection(parentsN);
5320
- if (!inter || inter.length < 2) {
5321
- return "f\xE9ltestv\xE9r";
5322
- }
5323
5513
  return "testv\xE9r";
5324
5514
  }
5515
+ halfBlood(relation) {
5516
+ if (!relation || !this.isHalfBlood) {
5517
+ return relation ?? "";
5518
+ }
5519
+ const [head, ...rest] = relation.split(" ");
5520
+ if (!head) {
5521
+ return relation;
5522
+ }
5523
+ const prefixed = this.prefixHalf(head);
5524
+ return [prefixed, ...rest].join(" ");
5525
+ }
5526
+ /**
5527
+ * AkH. 139: compounds of more than two members stay closed up to 6
5528
+ * syllables; longer ones are hyphenated at the main boundary. A head
5529
+ * that is already hyphenated also takes a hyphenated half- prefix.
5530
+ */
5531
+ prefixHalf(head) {
5532
+ if (head.includes("-") || !/[aáeéiíoóöőuúüű]/i.test(head)) {
5533
+ return `f\xE9l-${head}`;
5534
+ }
5535
+ const syllables = (head.match(/[aáeéiíoóöőuúüű]/gi) ?? []).length + 1;
5536
+ if (syllables > 6) {
5537
+ return `f\xE9l-${head}`;
5538
+ }
5539
+ return `f\xE9l${head}`;
5540
+ }
5325
5541
  spouse() {
5326
5542
  if (this.personN?.isMale()) {
5327
5543
  return "f\xE9rj";
@@ -5520,20 +5736,22 @@ var KinshipTranslatorEn = class extends KinshipTranslatorBasic {
5520
5736
  return `${prefix}child`;
5521
5737
  }
5522
5738
  sibling() {
5523
- const parents1 = this.person1?.getBiologicalParents();
5524
- const parentsN = this.personN?.getBiologicalParents();
5525
- const inter = parents1?.intersection(parentsN);
5526
- let prefix = "";
5527
- if (!inter || inter.length < 2) {
5528
- prefix = "half-";
5529
- }
5530
5739
  if (this.personN?.isMale()) {
5531
- return `${prefix}brother`;
5740
+ return "brother";
5532
5741
  }
5533
5742
  if (this.personN?.isFemale()) {
5534
- return `${prefix}sister`;
5743
+ return "sister";
5744
+ }
5745
+ return "sibling";
5746
+ }
5747
+ halfBlood(relation) {
5748
+ if (!relation || !this.isHalfBlood) {
5749
+ return relation ?? "";
5750
+ }
5751
+ if (relation.includes(" ")) {
5752
+ return `half ${relation}`;
5535
5753
  }
5536
- return `${prefix}sibling`;
5754
+ return `half-${relation}`;
5537
5755
  }
5538
5756
  spouse() {
5539
5757
  if (this.personN?.isMale()) {
@@ -5715,20 +5933,22 @@ var KinshipTranslatorDe = class extends KinshipTranslatorBasic {
5715
5933
  return `${prefix}kind`;
5716
5934
  }
5717
5935
  sibling() {
5718
- const parents1 = this.person1?.getBiologicalParents();
5719
- const parentsN = this.personN?.getBiologicalParents();
5720
- const inter = parents1?.intersection(parentsN);
5721
- let prefix = "";
5722
- if (!inter || inter.length < 2) {
5723
- prefix = "Halb";
5724
- }
5725
5936
  if (this.personN?.isMale()) {
5726
- return `${prefix}bruder`;
5937
+ return "bruder";
5727
5938
  }
5728
5939
  if (this.personN?.isFemale()) {
5729
- return `${prefix}schwester`;
5940
+ return "schwester";
5941
+ }
5942
+ return "geschwister";
5943
+ }
5944
+ halfBlood(relation) {
5945
+ if (!relation || !this.isHalfBlood) {
5946
+ return relation ?? "";
5947
+ }
5948
+ if (/^[A-ZÄÖÜ]/.test(relation) || /[-\s]/.test(relation)) {
5949
+ return `Halb-${relation}`;
5730
5950
  }
5731
- return `${prefix}geschwister`;
5951
+ return `Halb${relation}`;
5732
5952
  }
5733
5953
  spouse() {
5734
5954
  if (this.personN?.isMale()) {
@@ -5910,20 +6130,19 @@ var KinshipTranslatorFr = class extends KinshipTranslatorBasic {
5910
6130
  return `${prefix}enfant`;
5911
6131
  }
5912
6132
  sibling() {
5913
- const parents1 = this.person1?.getBiologicalParents();
5914
- const parentsN = this.personN?.getBiologicalParents();
5915
- const inter = parents1?.intersection(parentsN);
5916
- let prefix = "";
5917
- if (!inter || inter.length < 2) {
5918
- prefix = "demi-";
5919
- }
5920
6133
  if (this.personN?.isMale()) {
5921
- return `${prefix}fr\xE8re`;
6134
+ return "fr\xE8re";
5922
6135
  }
5923
6136
  if (this.personN?.isFemale()) {
5924
- return `${prefix}s\u0153ur`;
6137
+ return "s\u0153ur";
6138
+ }
6139
+ return "fr\xE8re/s\u0153ur";
6140
+ }
6141
+ halfBlood(relation) {
6142
+ if (!relation || !this.isHalfBlood) {
6143
+ return relation ?? "";
5925
6144
  }
5926
- return `${prefix}fr\xE8re/s\u0153ur`;
6145
+ return `demi-${relation}`;
5927
6146
  }
5928
6147
  spouse() {
5929
6148
  if (this.personN?.isMale()) {
@@ -6020,12 +6239,12 @@ var InLawsEs = {
6020
6239
  "madre del (c\xF3nyuge|esposa|esposo)": "suegra",
6021
6240
  "padre del (c\xF3nyuge|esposa|esposo)": "suegro",
6022
6241
  "padre/madre del (c\xF3nyuge|esposa|esposo)": "suegro/suegra",
6023
- "esposa de (medio )?(hermano/hermana|hermana|hermano)": "cu\xF1ada",
6024
- "esposo de (medio )?(hermano/hermana|hermana|hermano)": "cu\xF1ado",
6025
- "c\xF3nyuge de (medio )?(hermano/hermana|hermana|hermano)": "cu\xF1ado/cu\xF1ada",
6026
- "(medio )?hermana del (c\xF3nyuge|esposa|esposo)": "cu\xF1ada",
6027
- "(medio )?hermano del (c\xF3nyuge|esposa|esposo)": "cu\xF1ado",
6028
- "(medio )?hermano/hermana del (c\xF3nyuge|esposa|esposo)": "cu\xF1ado/cu\xF1ada"
6242
+ "esposa de (medio |media |medio/a )?(hermano/hermana|hermana|hermano)": "cu\xF1ada",
6243
+ "esposo de (medio |media |medio/a )?(hermano/hermana|hermana|hermano)": "cu\xF1ado",
6244
+ "c\xF3nyuge de (medio |media |medio/a )?(hermano/hermana|hermana|hermano)": "cu\xF1ado/cu\xF1ada",
6245
+ "(medio |media |medio/a )?hermana del (c\xF3nyuge|esposa|esposo)": "cu\xF1ada",
6246
+ "(medio |media |medio/a )?hermano del (c\xF3nyuge|esposa|esposo)": "cu\xF1ado",
6247
+ "(medio |media |medio/a )?hermano/hermana del (c\xF3nyuge|esposa|esposo)": "cu\xF1ado/cu\xF1ada"
6029
6248
  };
6030
6249
 
6031
6250
  // src/kinship-translator/kinship-translator.es.ts
@@ -6105,20 +6324,25 @@ var KinshipTranslatorEs = class extends KinshipTranslatorBasic {
6105
6324
  return `${prefix}hijo/hija`;
6106
6325
  }
6107
6326
  sibling() {
6108
- const parents1 = this.person1?.getBiologicalParents();
6109
- const parentsN = this.personN?.getBiologicalParents();
6110
- const inter = parents1?.intersection(parentsN);
6111
- let prefix = "";
6112
- if (!inter || inter.length < 2) {
6113
- prefix = "medio ";
6114
- }
6115
6327
  if (this.personN?.isMale()) {
6116
- return `${prefix}hermano`;
6328
+ return "hermano";
6329
+ }
6330
+ if (this.personN?.isFemale()) {
6331
+ return "hermana";
6332
+ }
6333
+ return "hermano/hermana";
6334
+ }
6335
+ halfBlood(relation) {
6336
+ if (!relation || !this.isHalfBlood) {
6337
+ return relation ?? "";
6117
6338
  }
6118
6339
  if (this.personN?.isFemale()) {
6119
- return `${prefix}hermana`;
6340
+ return `media ${relation}`;
6341
+ }
6342
+ if (this.personN?.isMale()) {
6343
+ return `medio ${relation}`;
6120
6344
  }
6121
- return `${prefix}hermano/hermana`;
6345
+ return `medio/a ${relation}`;
6122
6346
  }
6123
6347
  spouse() {
6124
6348
  if (this.personN?.isMale()) {
@@ -6207,6 +6431,249 @@ var KinshipTranslatorEs = class extends KinshipTranslatorBasic {
6207
6431
  }
6208
6432
  };
6209
6433
 
6434
+ // src/kinship-translator/patterns.ru.ts
6435
+ var InLawsRu = {
6436
+ "\u0441\u0443\u043F\u0440\u0443\u0433(?:\u0430)? (\u0440\u0435\u0431\u0451\u043D\u043A\u0430|\u0434\u043E\u0447\u0435\u0440\u0438|\u0441\u044B\u043D\u0430)": "\u0437\u044F\u0442\u044C/\u043D\u0435\u0432\u0435\u0441\u0442\u043A\u0430",
6437
+ "\u0436\u0435\u043D\u0430 (\u0440\u0435\u0431\u0451\u043D\u043A\u0430|\u0434\u043E\u0447\u0435\u0440\u0438|\u0441\u044B\u043D\u0430)": "\u043D\u0435\u0432\u0435\u0441\u0442\u043A\u0430",
6438
+ "\u043C\u0443\u0436 (\u0440\u0435\u0431\u0451\u043D\u043A\u0430|\u0434\u043E\u0447\u0435\u0440\u0438|\u0441\u044B\u043D\u0430)": "\u0437\u044F\u0442\u044C",
6439
+ "\u043C\u0430\u0442\u044C (\u0441\u0443\u043F\u0440\u0443\u0433\u0430|\u0436\u0435\u043D\u044B|\u043C\u0443\u0436\u0430)": "\u0442\u0451\u0449\u0430",
6440
+ "\u043E\u0442\u0435\u0446 (\u0441\u0443\u043F\u0440\u0443\u0433\u0430|\u0436\u0435\u043D\u044B|\u043C\u0443\u0436\u0430)": "\u0442\u0435\u0441\u0442\u044C",
6441
+ "\u0440\u043E\u0434\u0438\u0442\u0435\u043B\u044C (\u0441\u0443\u043F\u0440\u0443\u0433\u0430|\u0436\u0435\u043D\u044B|\u043C\u0443\u0436\u0430)": "\u0442\u0435\u0441\u0442\u044C/\u0442\u0451\u0449\u0430",
6442
+ "\u0436\u0435\u043D\u0430 (\u0441\u0432\u043E\u0434\u043D(?:\u044B\u0439|\u0430\u044F) )?(\u0431\u0440\u0430\u0442\u0430|\u0441\u0435\u0441\u0442\u0440\u044B|\u0441\u0438\u0431\u043B\u0438\u043D\u0433\u0430)": "\u043D\u0435\u0432\u0435\u0441\u0442\u043A\u0430",
6443
+ "\u043C\u0443\u0436 (\u0441\u0432\u043E\u0434\u043D(?:\u044B\u0439|\u0430\u044F) )?(\u0431\u0440\u0430\u0442\u0430|\u0441\u0435\u0441\u0442\u0440\u044B|\u0441\u0438\u0431\u043B\u0438\u043D\u0433\u0430)": "\u0437\u044F\u0442\u044C",
6444
+ "\u0441\u0443\u043F\u0440\u0443\u0433(?:\u0430)? (\u0441\u0432\u043E\u0434\u043D(?:\u044B\u0439|\u0430\u044F) )?(\u0431\u0440\u0430\u0442\u0430|\u0441\u0435\u0441\u0442\u0440\u044B|\u0441\u0438\u0431\u043B\u0438\u043D\u0433\u0430)": "\u0437\u044F\u0442\u044C/\u043D\u0435\u0432\u0435\u0441\u0442\u043A\u0430",
6445
+ "(\u0441\u0432\u043E\u0434\u043D(?:\u044B\u0439|\u0430\u044F) )?\u0441\u0435\u0441\u0442\u0440\u0430 (\u0441\u0443\u043F\u0440\u0443\u0433\u0430|\u0436\u0435\u043D\u044B|\u043C\u0443\u0436\u0430)": "\u0437\u043E\u043B\u043E\u0432\u043A\u0430",
6446
+ "(\u0441\u0432\u043E\u0434\u043D(?:\u044B\u0439|\u0430\u044F) )?\u0431\u0440\u0430\u0442 (\u0441\u0443\u043F\u0440\u0443\u0433\u0430|\u0436\u0435\u043D\u044B|\u043C\u0443\u0436\u0430)": "\u0448\u0443\u0440\u0438\u043D",
6447
+ "(\u0441\u0432\u043E\u0434\u043D(?:\u044B\u0439|\u0430\u044F) )?\u0441\u0438\u0431\u043B\u0438\u043D\u0433 (\u0441\u0443\u043F\u0440\u0443\u0433\u0430|\u0436\u0435\u043D\u044B|\u043C\u0443\u0436\u0430)": "\u0448\u0443\u0440\u0438\u043D/\u0437\u043E\u043B\u043E\u0432\u043A\u0430"
6448
+ };
6449
+
6450
+ // src/kinship-translator/kinship-translator.ru.ts
6451
+ var GENITIVE = {
6452
+ \u0441\u044B\u043D: "\u0441\u044B\u043D\u0430",
6453
+ \u0434\u043E\u0447\u044C: "\u0434\u043E\u0447\u0435\u0440\u0438",
6454
+ \u0440\u0435\u0431\u0451\u043D\u043E\u043A: "\u0440\u0435\u0431\u0451\u043D\u043A\u0430",
6455
+ \u0431\u0440\u0430\u0442: "\u0431\u0440\u0430\u0442\u0430",
6456
+ \u0441\u0435\u0441\u0442\u0440\u0430: "\u0441\u0435\u0441\u0442\u0440\u044B",
6457
+ \u0441\u0438\u0431\u043B\u0438\u043D\u0433: "\u0441\u0438\u0431\u043B\u0438\u043D\u0433\u0430",
6458
+ \u043E\u0442\u0435\u0446: "\u043E\u0442\u0446\u0430",
6459
+ \u043C\u0430\u0442\u044C: "\u043C\u0430\u0442\u0435\u0440\u0438",
6460
+ \u0440\u043E\u0434\u0438\u0442\u0435\u043B\u044C: "\u0440\u043E\u0434\u0438\u0442\u0435\u043B\u044F",
6461
+ \u043C\u0443\u0436: "\u043C\u0443\u0436\u0430",
6462
+ \u0436\u0435\u043D\u0430: "\u0436\u0435\u043D\u044B",
6463
+ \u0441\u0443\u043F\u0440\u0443\u0433: "\u0441\u0443\u043F\u0440\u0443\u0433\u0430",
6464
+ \u0441\u0443\u043F\u0440\u0443\u0433\u0430: "\u0441\u0443\u043F\u0440\u0443\u0433\u0438"
6465
+ };
6466
+ var toGenitive = (word) => GENITIVE[word] ?? word;
6467
+ var cousinWord = (degree, sex) => {
6468
+ const stem = degree <= 1 ? "\u0434\u0432\u043E\u044E\u0440\u043E\u0434\u043D" : degree === 2 ? "\u0442\u0440\u043E\u044E\u0440\u043E\u0434\u043D" : degree === 3 ? "\u0447\u0435\u0442\u0432\u0435\u0440\u043E\u044E\u0440\u043E\u0434\u043D" : `${degree + 1}-\u044E\u0440\u043E\u0434\u043D`;
6469
+ if (sex === "m") {
6470
+ return `${stem}\u044B\u0439 \u0431\u0440\u0430\u0442`;
6471
+ }
6472
+ if (sex === "f") {
6473
+ return `${stem}\u0430\u044F \u0441\u0435\u0441\u0442\u0440\u0430`;
6474
+ }
6475
+ return `${stem}\u044B\u0439 \u0431\u0440\u0430\u0442/\u0441\u0435\u0441\u0442\u0440\u0430`;
6476
+ };
6477
+ var praRepeat = (count) => count > 0 ? "\u043F\u0440\u0430".repeat(count) : "";
6478
+ var sexOf = (person) => {
6479
+ if (person?.isMale?.()) {
6480
+ return "m";
6481
+ }
6482
+ if (person?.isFemale?.()) {
6483
+ return "f";
6484
+ }
6485
+ return "n";
6486
+ };
6487
+ var KinshipTranslatorRu = class extends KinshipTranslatorBasic {
6488
+ indirect() {
6489
+ let degree = Math.abs(this.pathN?.degree ?? 0);
6490
+ if (degree > 0) {
6491
+ degree = degree - 1;
6492
+ }
6493
+ return cousinWord(degree, sexOf(this.personN));
6494
+ }
6495
+ removal() {
6496
+ const level = this.pathN?.level ?? 0;
6497
+ let degree = Math.abs(this.pathN?.degree ?? 0);
6498
+ if (degree > 0) {
6499
+ degree = degree - 1;
6500
+ }
6501
+ if (!degree) {
6502
+ return level < 0 ? this.nibling() : this.auncle();
6503
+ }
6504
+ const removed = Math.abs(level);
6505
+ return `${cousinWord(degree, sexOf(this.personN))} (${removed}\xD7 \u0447\u0435\u0440\u0435\u0437 \u043F\u043E\u043A\u043E\u043B\u0435\u043D\u0438\u0435)`;
6506
+ }
6507
+ auncle() {
6508
+ const level = Math.abs(this.pathN?.level ?? 0);
6509
+ const pra = praRepeat(Math.max(0, level - 2));
6510
+ const sex = sexOf(this.personN);
6511
+ if (sex === "m") {
6512
+ return `${pra}\u0434\u044F\u0434\u044F`;
6513
+ }
6514
+ if (sex === "f") {
6515
+ return `${pra}\u0442\u0451\u0442\u044F`;
6516
+ }
6517
+ return `${pra}\u0434\u044F\u0434\u044F/\u0442\u0451\u0442\u044F`;
6518
+ }
6519
+ nibling() {
6520
+ const level = Math.abs(this.pathN?.level ?? 0);
6521
+ const pra = praRepeat(Math.max(0, level - 2));
6522
+ const sex = sexOf(this.personN);
6523
+ if (sex === "m") {
6524
+ return `${pra}\u043F\u043B\u0435\u043C\u044F\u043D\u043D\u0438\u043A`;
6525
+ }
6526
+ if (sex === "f") {
6527
+ return `${pra}\u043F\u043B\u0435\u043C\u044F\u043D\u043D\u0438\u0446\u0430`;
6528
+ }
6529
+ return `${pra}\u043F\u043B\u0435\u043C\u044F\u043D\u043D\u0438\u043A/\u043F\u043B\u0435\u043C\u044F\u043D\u043D\u0438\u0446\u0430`;
6530
+ }
6531
+ parent() {
6532
+ const level = Math.abs(this.pathN?.level ?? 0);
6533
+ const sex = sexOf(this.personN);
6534
+ if (level <= 1) {
6535
+ if (sex === "m") {
6536
+ return "\u043E\u0442\u0435\u0446";
6537
+ }
6538
+ if (sex === "f") {
6539
+ return "\u043C\u0430\u0442\u044C";
6540
+ }
6541
+ return "\u0440\u043E\u0434\u0438\u0442\u0435\u043B\u044C";
6542
+ }
6543
+ if (level === 2) {
6544
+ if (sex === "m") {
6545
+ return "\u0434\u0435\u0434";
6546
+ }
6547
+ if (sex === "f") {
6548
+ return "\u0431\u0430\u0431\u0443\u0448\u043A\u0430";
6549
+ }
6550
+ return "\u0434\u0435\u0434/\u0431\u0430\u0431\u0443\u0448\u043A\u0430";
6551
+ }
6552
+ const pra = praRepeat(level - 2);
6553
+ if (sex === "m") {
6554
+ return `${pra}\u0434\u0435\u0434`;
6555
+ }
6556
+ if (sex === "f") {
6557
+ return `${pra}\u0431\u0430\u0431\u0443\u0448\u043A\u0430`;
6558
+ }
6559
+ return `${pra}\u0434\u0435\u0434/\u0431\u0430\u0431\u0443\u0448\u043A\u0430`;
6560
+ }
6561
+ child() {
6562
+ const level = Math.abs(this.pathN?.level ?? 0);
6563
+ const sex = sexOf(this.personN);
6564
+ if (level <= 1) {
6565
+ if (sex === "m") {
6566
+ return "\u0441\u044B\u043D";
6567
+ }
6568
+ if (sex === "f") {
6569
+ return "\u0434\u043E\u0447\u044C";
6570
+ }
6571
+ return "\u0440\u0435\u0431\u0451\u043D\u043E\u043A";
6572
+ }
6573
+ if (level === 2) {
6574
+ if (sex === "m") {
6575
+ return "\u0432\u043D\u0443\u043A";
6576
+ }
6577
+ if (sex === "f") {
6578
+ return "\u0432\u043D\u0443\u0447\u043A\u0430";
6579
+ }
6580
+ return "\u0432\u043D\u0443\u043A/\u0432\u043D\u0443\u0447\u043A\u0430";
6581
+ }
6582
+ const pra = praRepeat(level - 2);
6583
+ if (sex === "m") {
6584
+ return `${pra}\u0432\u043D\u0443\u043A`;
6585
+ }
6586
+ if (sex === "f") {
6587
+ return `${pra}\u0432\u043D\u0443\u0447\u043A\u0430`;
6588
+ }
6589
+ return `${pra}\u0432\u043D\u0443\u043A/\u0432\u043D\u0443\u0447\u043A\u0430`;
6590
+ }
6591
+ sibling() {
6592
+ const sex = sexOf(this.personN);
6593
+ if (sex === "m") {
6594
+ return "\u0431\u0440\u0430\u0442";
6595
+ }
6596
+ if (sex === "f") {
6597
+ return "\u0441\u0435\u0441\u0442\u0440\u0430";
6598
+ }
6599
+ return "\u0441\u0438\u0431\u043B\u0438\u043D\u0433";
6600
+ }
6601
+ halfBlood(relation) {
6602
+ if (!relation || !this.isHalfBlood) {
6603
+ return relation ?? "";
6604
+ }
6605
+ if (/сестра|дочь|мать|тётя|бабушка|жена|племянница|внучка/.test(
6606
+ relation
6607
+ )) {
6608
+ return `\u0441\u0432\u043E\u0434\u043D\u0430\u044F ${relation}`;
6609
+ }
6610
+ return `\u0441\u0432\u043E\u0434\u043D\u044B\u0439 ${relation}`;
6611
+ }
6612
+ spouse() {
6613
+ const sex = sexOf(this.personN);
6614
+ if (sex === "m") {
6615
+ return "\u043C\u0443\u0436";
6616
+ }
6617
+ if (sex === "f") {
6618
+ return "\u0436\u0435\u043D\u0430";
6619
+ }
6620
+ return "\u0441\u0443\u043F\u0440\u0443\u0433";
6621
+ }
6622
+ ofSpouse(relation) {
6623
+ if (!relation) {
6624
+ return "";
6625
+ }
6626
+ const spouse = this.path?.[1].indi;
6627
+ const sex = sexOf(spouse);
6628
+ const spouseType = sex === "m" ? "\u043C\u0443\u0436" : sex === "f" ? "\u0436\u0435\u043D\u0430" : "\u0441\u0443\u043F\u0440\u0443\u0433";
6629
+ return `${relation} ${toGenitive(spouseType)}`;
6630
+ }
6631
+ spouseOf(relation) {
6632
+ if (!relation) {
6633
+ return "";
6634
+ }
6635
+ const spouse = this.path?.[this.path.length - 1].indi;
6636
+ const sex = sexOf(spouse);
6637
+ const spouseType = sex === "m" ? "\u043C\u0443\u0436" : sex === "f" ? "\u0436\u0435\u043D\u0430" : "\u0441\u0443\u043F\u0440\u0443\u0433";
6638
+ return `${spouseType} ${toGenitive(relation)}`;
6639
+ }
6640
+ of(relation) {
6641
+ const formattedName = nameFormatter(this.path?.[0]?.indi, {
6642
+ nameOrder: "first-last"
6643
+ });
6644
+ let name = formattedName.inOrder.filter(Boolean).join(" ");
6645
+ if (this.displayName === "none") {
6646
+ name = "";
6647
+ } else if (this.displayName === "givenname") {
6648
+ name = formattedName.givenname;
6649
+ } else if (this.displayName === "surname") {
6650
+ name = `${formattedName.surname}`;
6651
+ }
6652
+ if (!name || !relation) {
6653
+ return relation ?? "";
6654
+ }
6655
+ return `${name}: ${relation}`;
6656
+ }
6657
+ inLaw(relation) {
6658
+ let inLawRelation = relation;
6659
+ Object.keys(InLawsRu).find((pattern) => {
6660
+ const regex = new RegExp(`^${pattern}$`);
6661
+ if (relation?.match(regex)) {
6662
+ inLawRelation = InLawsRu[pattern];
6663
+ return true;
6664
+ }
6665
+ return false;
6666
+ });
6667
+ return inLawRelation ?? "";
6668
+ }
6669
+ relationType(relation) {
6670
+ if (!relation || !this.pathN?.relation) {
6671
+ return relation ?? "";
6672
+ }
6673
+ return `${this.pathN.relation} ${relation}`;
6674
+ }
6675
+ };
6676
+
6210
6677
  // src/kinship-translator/kinship-translator.ts
6211
6678
  var KinshipTranslator = class {
6212
6679
  constructor(person1, person2, lang = "en", entirePath, displayName = "givenname") {
@@ -6300,6 +6767,7 @@ var KinshipTranslator = class {
6300
6767
  } else if (personN.level !== 0) {
6301
6768
  relation = this.removal();
6302
6769
  }
6770
+ relation = this.translator?.halfBlood(relation);
6303
6771
  relation = this.translator?.relationType(relation);
6304
6772
  if (this.translator?.isOfSpouse) {
6305
6773
  relation = this.translator?.ofSpouse(relation);