UNPKG

gedcom-ts

Version:

TypeScript GEDCOM toolkit for browser apps: import .ged/.zip, edit typed genealogy data, and export GEDCOM or GEDZIP.

2 lines (1 loc) 13.4 kB
var m=(e,t)=>()=>(e&&(t=e(e=0)),t);var U=m(()=>{});function B(e){let t=e.trim();return!t||t===D?!1:G.test(t)||z.test(t)}function d(e){let t=e.trim();if(!t||t===D)return"on an unknown date";if(G.test(t))return`in ${t}`;let n=z.exec(t);if(n){let o=n[1].toLowerCase(),r=n[2];switch(o){case"bef":return`before ${r}`;case"aft":return`after ${r}`;case"vers":case"circa":case"environ":case"about":case"abt":case"est":case"cal":return`about ${r}`;default:return`in ${r}`}}return`on ${t}`}function S(e,t){let n=e.trim(),o=t.trim();return`${B(n)?`From ${n}`:`From ${n}`} to ${o}`}function y(e){let t=e.trim();return G.test(t)?`was born in ${t}`:B(t)?`was born ${d(t)}`:`was born on ${t}`}var G,z,D,P=m(()=>{G=/^\d{3,4}$/,z=/^(vers|circa|environ|about|ABT|BEF|AFT|EST|CAL|INT|FROM|TO)\s+(\d{3,4})$/i,D="Unknown date"});function pe(e){return e.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()}function he(e){return de.has(pe(e))}function W(e){let t=e.trim();if(!t)return null;let n=t.indexOf(", ");return n>=0?{city:t.slice(0,n).trim(),country:t.slice(n+2).trim(),raw:t}:he(t)?{city:null,country:t,raw:t}:{city:t,country:null,raw:t}}function K(e){let t=e.trim();return/^in\s+/i.test(t)?t:`in ${t}`}function k(e){let t=W(e);return t?t.city&&t.country?`${t.city}, ${K(t.country)}`:t.city?t.city:t.country?K(t.country):t.raw:""}function p(e,t){let n=k(t);if(!n)return"";let o=n.startsWith("in ")?` ${n}`:` in ${n}`;return B(e)?`,${o}`:o}function R(e){let t=k(e);return t?t.startsWith("in ")?` ${t}`:` in ${t}`:""}function N(e,t,n,o){let r=t.trim(),a=o.trim();return r&&r===a?{birth:"",death:p(n,a)}:{birth:p(e,r),death:p(n,a)}}function T(e,t){let n=k(e),o=k(t);if(!n&&!o)return"";if(n&&o&&n===o)return n.startsWith("in ")?`, ${n}`:`, in ${n}`;if(n&&o)return`, from ${n} to ${o}`;let r=n||o;return r.startsWith("in ")?`, ${r}`:`, in ${r}`}function O(e,t){let n=d(e),o=t.trim();return n==="on an unknown date"&&!o?null:o?n==="on an unknown date"?R(o).trim()||null:`${n}${p(e,o)}`:n}function $(e){let t=e?.trim();return!t||t==="on an unknown date"?"":` ${t}`}var de,_=m(()=>{P();de=new Set(["france","germany","deutschland","spain","espana","italy","italia","belgium","switzerland","united kingdom","uk","england","scotland","ireland","portugal","netherlands","holland","luxembourg","austria","poland","russia","canada","united states","usa","morocco","algeria","tunisia"].map(e=>e.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase()))});function $e(e){return e!=null&&ge.includes(e)}function f(e){return $e(e)?e:"en"}var ge,C=m(()=>{ge=["en","fr","de","nl","es","zh","it","pt","pl","ar","he"]});function fe(){let e=globalThis;return e[M]??(e[M]=new Map),e[M]}function b(e){let t=fe().get(e);if(!t)throw new H(e);return t}var M,H,x=m(()=>{C();M="__GEDCOM_TS_BOOKLET_LOCALE_CACHE__";H=class extends Error{constructor(t){super(`Booklet locale "${t}" is not loaded. Call await ensureBookletLocale("${t}") before using sync booklet APIs.`),this.name="BookletLocaleNotLoadedError"}}});function Le(e){return b(e).genderWords}function E(e,t){return Le(f(t))[e]}function V(e,t){if(e<=0)return"";let n=f(t),o=b(n).genderPhrases?.recensedChildren(e);return o||(n==="en"?e===1?"1 child listed":`${e} children listed`:e===1?"1 enfant recens\xE9":`${e} enfants recens\xE9s`)}function Y(e,t){if(e<=0)return"";let n=f(t),o=b(n).genderPhrases?.otherUnions(e);return o||(n==="en"?e===1?"1 other union cited in the tree":`${e} other unions cited in the tree`:e===1?"1 autre union cit\xE9e dans l'arbre":`${e} autres unions cit\xE9es dans l'arbre`)}var X=m(()=>{C();x()});function j(e){let t=f(e);return b(t).messages}var Q=m(()=>{C();x();x()});function w(e,t=6,n){let o=j(n);if(e.length===0)return o.childrenNone;let r=e.map(a=>a.name);return r.length<=t?r.join(", "):`${r.slice(0,t).join(", ")} ${o.childrenMore(r.length-t)}`}var q=m(()=>{C();Q()});function J(e){return e!==be&&e!=="Dates inconnues"}function Z(e){return e.map(t=>t.trim()).filter(Boolean).map(t=>t.endsWith(".")?t:`${t}.`).join(" ")}function u(e){let t=e.map(o=>o.trim()).filter(Boolean);return t.length===0?"":`${t.map(o=>o.endsWith(".")?o.slice(0,-1):o).join(" ; ")}.`}function A(e){return e.trim().split(/\s+/)[0]??e}function i(e,t){return e[Math.abs(t)%e.length]}function L(e,t="and"){return e.length===0?"":e.length===1?e[0]:e.length===2?`${e[0]} ${t} ${e[1]}`:`${e.slice(0,-1).join(", ")} ${t} ${e.at(-1)}`}function I(e,t){if(e.parents.length===0)return null;let n=E(e.sex,g),o=e.parents.map(r=>r.name);return o.length===1?i([`child of ${o[0]}`,`${n.childOf} of ${o[0]}`,`${n.descendant} of ${o[0]}`],t+3):i([`${n.offspring} of ${L(o)}`,`${n.descendant} of ${L(o)}`,`child of ${L(o)}`],t+3)}function Ee(e,t){if(t.marriageLabel)return t.marriageLabel;let n=e.events.find(o=>o.kind===String("MARR"));return n?O(n.date,n.place):null}function ee(e,t,n){let o=E(e.sex,g),r=t.coParent.name,a=[],l=$(Ee(e,t));if(l?a.push(i([`marries ${r}${l}`,`unites with ${r}${l}`,`marriage to ${r}${l}`],n+7)):a.push(i([`${o.linked} to ${r}`,`shares a life with ${r}`,`union recorded with ${r}`],n+7)),t.children.length>0){let s=t.children.map(c=>A(c.name));s.length===1?a.push(i([`including ${s[0]}`,`with child ${s[0]}`,`${o.parentOf} of ${s[0]}`],n+11)):a.push(i([`including children ${L(s)}`,`with descendants ${L(s)}`,`${o.parentOf} of ${L(s)}`],n+11))}return u(a)}function te(e,t){let n=e.events.find(l=>l.kind===String("BIRT")),o=e.events.find(l=>l.kind===String("DEAT")),r=e.name,a=E(e.sex,g);if(n&&o){let l=d(n.date),s=d(o.date),c=N(n.date,n.place,o.date,o.place),h=T(n.place,o.place);return i([`${r}, ${a.born} ${l}${c.birth}, passed away ${s}${c.death}`,`${S(n.date,o.date)}${h}, ${r} marks this lineage`,`${r} ${y(n.date)}${c.birth||p(n.date,n.place)} and passed away ${s}${c.death}`],t)}if(n){let l=d(n.date),s=p(n.date,n.place);return i([`${r}, ${a.born} ${l}${s}`,`Birth of ${r} ${l}${s}`,`${r} ${y(n.date)}${s}`],t)}if(o){let l=d(o.date),s=p(o.date,o.place);return i([`${r}, ${a.died} ${l}${s}`,`Death of ${r} ${l}${s}`,`${r} passed away ${l}${s}`],t+1)}return J(e.datesLabel)?i([`${r}, ${a.present} in the records around ${e.datesLabel}`,`${r} is placed around ${e.datesLabel}`,`${r} (${e.datesLabel})`],t+2):null}function ne(e,t,n){let o=d(e.date),r=p(e.date,e.place),a=E(n,g);switch(e.kind){case"MARR":return i([`marriage celebrated ${o}${r}`,`union recorded ${o}${r}`,`wedding celebrated ${o}${r}`,`united${o}${r}`],t);case"DIV":return`divorce recorded ${o}${r}`;case"BAPM":case"CHR":return i([`baptism ${o}${r}`,`${a.baptized} ${o}${r}`,`baptismal rite ${o}${r}`],t);case"BURI":return i([`burial ${o}${r}`,`funeral ${o}${r}`,`interment ${o}${r}`],t);case"CREM":return`cremation recorded ${o}${r}`;case"OCCU":return`occupation noted (${e.date})${R(e.place)}`;default:return`${e.label.toLowerCase()} ${o}${r}`}}function oe(e,t){let n=[],o=0;for(let r of e.events){if(Ae.has(r.kind))continue;let a=ne(r,t+o,e.sex);a&&n.push(a),o+=1}return n}function re(e){let t=e.entries.length,n=e.subtitle.includes("\u2014")?e.subtitle.split("\u2014").pop()?.trim()??"":"",o=e.title.match(/Generation (\d+)/),r=o?Number(o[1]):0;if(r>0){let a=r===1?[`Starting point of the narrative: ${t} figure${t>1?"s":""} at the root of the tree.`,`Here the lineage begins, with ${t} reference person${t>1?"s":""}.`]:[`In generation ${r}, ${t} ancestor${t>1?"s":""} enter the scene.`,`This generation includes ${t} person${t>1?"s":""}${n?` (${n})`:""}.`,`${t} lives intersect in this generation${n?`, between ${n}`:""}.`];return i(a,r)}return i([`${e.title}: ${t} portrait${t>1?"s":""} to discover.`,`${t} person${t>1?"s":""} for letter ${e.title.replace("Letter ","")}${n?` (${n})`:""}.`],t)}function ae(e,t){let n=e.familyId,o=e.partners[0]?.name??"An ancestor",r=e.partners[1]?.name,a=e.children,l;if(r){let s=i([`${A(o)} and ${A(r)}`,`The couple ${A(o)} \u2013 ${A(r)}`,`${o} and ${r}`],n),c=$(e.marriageLabel),h=i(c?[`unite${c}`,`marry${c}`,`celebrate their union${c}`]:["form a union","are united in the records","appear as spouses"],n+1);if(a.length===0)l=u([`${s} ${h}`,"with no descendants listed in the file"]);else if(a.length===1)l=u([`${s} ${h}`,i([`with child ${a[0].name}`,`gave birth to ${a[0].name}`,`have a child, ${a[0].name}`],n+2)]);else if(t==="summary")l=u([`${s} ${h}`,`${a.length} children: ${w(a,5,g)}`]);else{let v=a.map(F=>{let ce=J(F.datesLabel)?` (${F.datesLabel})`:"";return`${F.name}${ce}`});l=u([`${s} ${h}`,`descendants: ${L(v,"and")}`])}}else l=Z([i([`${A(o)} holds a central place in this lineage`,`${o}, a landmark figure in this chapter`],n),e.marriageLabel?i([`marriage recorded${$(e.marriageLabel)}`,`union noted${$(e.marriageLabel)}`],n+1):"",a.length>0?i([`descendants: ${w(a,5,g)}`,`${V(a.length,g)}: ${w(a,5,g)}`],n+2):""]);return[l]}function se(e){let t=e.indi,n=[],o=te(e,t);if(o)n.push(o);else{let l=E(e.sex,g);n.push(i([`${e.name}, ${l.present} in this branch`,`${e.name} appears in this chapter`],t))}let r=I(e,t);r&&n.push(r),e.unions[0]&&(n.push(ee(e,e.unions[0],t)),e.unions.length>1&&n.push(Y(e.unions.length-1,g)));let a=oe(e,t);return a.length>0&&n.push(u(a.slice(0,2))),e.sosa!=null&&n.length>0&&n.push(`SOSA ${e.sosa}`),n.length<=1&&e.events.length===0&&e.unions.length===0?Z([`${e.name}: few records so far`,"further research may complete this portrait"]):u(n)}function le(e){let t=e.indi,n=[],o=[],r=te(e,t);r&&o.push(r);let a=I(e,t);a&&o.push(a);let l=oe(e,t);if(l.length>0&&o.push(u(l)),o.length>0?n.push(u(o)):n.push(`${e.name} \u2014 portrait still to be completed from the archives.`),e.unions.length>0){let s=e.unions.map((c,h)=>ee(e,c,t+20+h));n.push(i([u(s),`Family side: ${u(s)}`,`On the marital side: ${u(s)}`],t+5))}else{let s=e.events.filter(c=>c.kind===String("MARR"));if(s.length>0){let c=s.map((h,v)=>ne(h,t+30+v,e.sex));n.push(u(c))}}return e.notesPreview&&n.push(i([`Research note: ${e.notesPreview}`,`The archives note: ${e.notesPreview}`,`Worth noting: ${e.notesPreview}`],t+9)),n}var g,be,Ae,ie=m(()=>{U();P();_();X();q();g="en",be="Unknown dates";Ae=new Set([String("BIRT"),String("DEAT"),String("MARR")])});var Re,Ce,De,Se,Pe,Ne,Te,Oe,at,Me=m(()=>{U();P();_();ie();Re={BIRT:"Birth",DEAT:"Death",MARR:"Marriage",DIV:"Divorce",BAPM:"Baptism (BAPM)",CHR:"Baptism",BURI:"Burial",CREM:"Cremation",EVEN:"Event",OCCU:"Occupation"},Ce={unknownDates:"Unknown dates",unknownDate:"Unknown date",chapterUnknownDates:"Unknown dates",generation1Title:"Generation 1 \u2014 reference person",generationTitle:e=>`Generation ${e}`,letterTitle:e=>`Letter ${e}`,chapterSubtitle:(e,t)=>`${e} person(s) \u2014 ${t}`,chapterDateAbout:"about",childrenNone:"no children listed",childrenMore:e=>`(+ ${e} more)`,pagesEstimate:e=>`~${e} pages`,pagesEmpty:"\u2014",adviceDetailed120:"For more than 120 people, Summary mode produces a much more readable document and generates faster.",adviceDetailed50:"Beyond 50 people, Summary mode is still recommended for a first read-through.",adviceSummary25:"Few people: Detailed mode offers a fine one-page sheet per person, ideal for printing.",actTypeLabels:Re,spouseUnknown:"Spouse not recorded",timelineTitle:e=>`Chronological timeline \u2014 ${e}`,timelineUnknownDates:"unknown dates",pdf:{coverSubtitle:"Family history from your GEDCOM file",referencePerson:e=>`Reference person (SOSA 1): ${e}`,personCount:e=>`${e} person(s) in this booklet`,localNote:"Document generated locally in your browser.",tocTitle:"Table of contents",modeSummary:"Summary mode - short narratives",modeDetailed:"Detailed mode - expanded biographies",contentHeading:"Booklet contents",introSummary:"This booklet tells your tree in prose: births, unions, descent and deaths reconstructed from the GEDCOM. Each chapter opens on a generation or a letter, then unfolds lives in short narratives.",introDetailed:"This booklet develops each figure as a narrative biography, in sequence within each chapter. Each new generation starts on a dedicated page.",introSosa:"SOSA numbers are mentioned when numbering is active. Table of contents at the end of the document.",familyHeading:e=>`The ${e} family`,generationLabel:e=>`generation ${e}`,pageFooter:e=>`Page ${e}`},timeline:{legendBirth:"birth",legendDeath:"death",legendMarriage:"marriage",overflow:e=>`+ ${e} more on following pages`,continuation:"(timeline continued)"}},De={F:{born:"born",died:"died",baptized:"baptized",present:"present",linked:"linked",offspring:"child",descendant:"descendant",childOf:"daughter",parentOf:"mother"},M:{born:"born",died:"died",baptized:"baptized",present:"present",linked:"linked",offspring:"child",descendant:"descendant",childOf:"son",parentOf:"father"},U:{born:"born",died:"died",baptized:"baptized",present:"present",linked:"linked",offspring:"child",descendant:"descendant",childOf:"child",parentOf:"parent"},X:{born:"born",died:"died",baptized:"baptized",present:"present",linked:"linked",offspring:"child",descendant:"descendant",childOf:"child",parentOf:"parent"}},Se=void 0,Pe={BOOKLET_UNKNOWN_DATE:D,isYearOnlyDate:B,onDate:d,lifeDateRange:S,seesDayOn:y},Ne={parsePlaceLabel:W,placeCore:k,afterDateLocation:p,atLocation:R,birthDeathLocationPhrases:N,lifeRangeLocation:T,marriageWhenWhere:O,embedMarriageWhenWhere:$},Te={buildChapterIntroNarrative:re,buildFamilyNarrative:ae,buildPersonSummaryNarrative:se,buildPersonDetailedNarratives:le},Oe={messages:Ce,genderWords:De,genderPhrases:Se,dateModule:Pe,placeModule:Ne,narrativeModule:Te},at=Oe});Me();export{at as default};