chrono-phylo-tree 1.1.10 → 1.1.11

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.
@@ -1,45 +1,15 @@
1
- (function(vt,U){typeof exports=="object"&&typeof module<"u"?U(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],U):(vt=typeof globalThis<"u"?globalThis:vt||self,U(vt["chrono-phylo-tree"]={},vt.React))})(this,function(vt,U){"use strict";const Lt=(s,...r)=>s.sort((u,a)=>{for(const d of r){const[f,h]=[u,a].map(b=>d(b));if(f!==h)return f-h}return 0});class xt{constructor(r="",u=0,a=0,d=void 0,f=[],h=void 0,b=void 0){if(this.name="",this.apparition=0,this.duration=0,this.ancestor=void 0,this.descendants=[],this.description=void 0,this.display=!0,this.image=void 0,a<=0)throw new Error("The duration of the species must be greater than 0");this.name=r,this.apparition=u,this.duration=a,this.ancestor=d,this.descendants=f,this.description=h===""?void 0:h,this.image=b===""?void 0:b}onPosition(r=!0){return r&&this.firstAncestor().stepsUntil(this)%2===0}copy(){const r=this.firstAncestor(),u=r.allDescendants(!1).indexOf(this);return xt.fromJSON(r.toJSON()).allDescendants(!1)[u]}unlinkAncestor(){if(!this.ancestor)return;this.ancestor.descendants=this.ancestor.descendants.filter(u=>u!==this);const r=this.ancestor;return this.ancestor=void 0,[r.firstAncestor(),this]}unlinkDescendant(r){if(this.descendants.includes(r))return this.descendants=this.descendants.filter(u=>u!==r),r.ancestor=void 0,[this.firstAncestor(),r]}linkAncestor(r){if(!(this.ancestor===r&&r.descendants.includes(this))){if(r.apparition>this.apparition)throw new Error(`The ancestor's apparition (${r.apparition}) must be before or equal the descendant's apparition (${this.apparition})`);if(r.extinction()<this.apparition)throw new Error(`The ancestor's extinction (${r.extinction()}) must be after or equal the descendant's apparition (${this.apparition})`);this.ancestor!==r&&this.unlinkAncestor(),this.ancestor=r,r.descendants.push(this)}}linkDescendant(r){if(!(r.ancestor===this&&this.descendants.includes(r))){if(r.apparition<this.apparition)throw new Error(`The descendant's apparition (${r.apparition}) must be after or equal the ancestor's apparition (${this.apparition})`);if(r.extinction()>this.extinction())throw new Error(`The descendant's extinction (${r.extinction()}) must be before or equal the ancestor's extinction (${this.extinction()})`);this.descendants.includes(r)||(r.ancestor&&r.unlinkAncestor(),this.descendants.push(r),r.ancestor=this)}}linkDescendants(r){for(const u of r)try{this.linkDescendant(u)}catch(a){console.error(`Error linking descendant ${u.name} to ancestor ${this.name}:`,a)}}addDescendant(r="",u=0,a=0,d=void 0,f=void 0,h=!1){if(u<0||u>this.duration)throw new Error(`The apparition of the descendant must be between the apparition (${this.apparition}) and the extinction (${this.extinction()}) of the ancestor`);const b=h?this.copy():this,j=new xt(r,b.apparition+Math.max(u,0),Math.max(a,0),void 0,[],d,f);return j.linkAncestor(b),h?b:j}removeDescendant(r){this.descendants=this.descendants.filter(u=>u!==r)}addAncestor(r="",u=0,a=0,d=void 0,f=void 0,h=!0,b=!1){if(u<0)throw new Error(`The apparition of the ancestor must be before or equal the apparition (${this.apparition}) of the descendant`);if(a<u)throw new Error(`The extiction of the ancestor must be after or equal the apparition (${this.apparition}) of the descendant`);const j=b?this.copy():this,o=new xt(r,j.apparition-Math.max(u,0),a,void 0,[],d,f);return o.display=h,j.linkAncestor(o),b?j:o}extinction(){return this.apparition+this.duration}absoluteExtinction(){return this.descendants.length>0?Math.max(...this.allDescendants(!1).map(r=>r.extinction())):this.extinction()}absoluteDuration(){return this.absoluteExtinction()-this.apparition}firstAncestor(r=!1){return this.ancestor?this.ancestor.display||r?this.ancestor.firstAncestor():this:this}cousinsExtinction(){return this.firstAncestor().absoluteExtinction()}allDescendants(r=!0){const u=r?Lt(this.descendants,o=>-o.apparition,o=>-o.absoluteExtinction()):this.descendants;if(u.length===0)return[this];const a=u.filter(o=>o.apparition>=this.extinction()),d=u.filter(o=>a.indexOf(o)===-1),h=(this.onPosition(r)?Math.ceil:Math.floor)(a.length/2),b=a.slice(0,h),j=a.slice(h);return b.flatMap(o=>o.allDescendants(r)).concat([this]).concat(j.flatMap(o=>o.allDescendants(r))).concat(d.flatMap(o=>o.allDescendants(r)))}stepsChain(r,u=!1){var a;return this.allDescendants(!1).includes(r)?[this].concat(((a=this.descendants.find(d=>d.allDescendants(!1).includes(r)))==null?void 0:a.stepsChain(r))??[]).filter(d=>d.display||u):[]}stepsUntil(r,u=!1){if(this.allDescendants(!1).includes(r))return this.stepsChain(r,u).length-1}stepsUntilLastDescendant(r=!1){return this.descendants.length===0?0:Math.max(...this.allDescendants(!1).filter(u=>u.descendants.length===0).map(u=>this.stepsUntil(u,r)??0))}toJSON(){return{name:this.name,apparition:this.ancestor?void 0:this.apparition,afterApparition:this.ancestor?this.apparition-this.ancestor.apparition:void 0,description:this.description,duration:this.duration,descendants:this.descendants.length>0?this.descendants.map(r=>r.toJSON()):void 0,image:this.image}}async saveJSON(r=void 0){try{const u=JSON.stringify(this.toJSON(),null,2),a=new Blob([u],{type:"application/json"}),d=URL.createObjectURL(a),f=document.createElement("a");f.href=d,f.download=r??`${this.name}.json`,f.click(),URL.revokeObjectURL(d)}catch(u){console.error("Error saving file:",u)}}static fromJSON(r,u){const a=r.afterApparition??0,d=u?u.apparition:r.apparition??0,f=new xt(r.name??"",d+a,r.duration??0,u,[],r.description,r.image);if(r.descendants)for(const h of r.descendants)f.descendants.push(xt.fromJSON(h,f));return f}}function It(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var jt={exports:{}},wt={};/**
2
- * @license React
3
- * react-jsx-runtime.production.js
4
- *
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var Tt;function Ft(){if(Tt)return wt;Tt=1;var s=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function u(a,d,f){var h=null;if(f!==void 0&&(h=""+f),d.key!==void 0&&(h=""+d.key),"key"in d){f={};for(var b in d)b!=="key"&&(f[b]=d[b])}else f=d;return d=f.ref,{$$typeof:s,type:a,key:h,ref:d!==void 0?d:null,props:f}}return wt.Fragment=r,wt.jsx=u,wt.jsxs=u,wt}var kt={};/**
10
- * @license React
11
- * react-jsx-runtime.development.js
12
- *
13
- * Copyright (c) Meta Platforms, Inc. and affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var Ct;function Ut(){return Ct||(Ct=1,process.env.NODE_ENV!=="production"&&function(){function s(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===G?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case $:return"Fragment";case ot:return"Portal";case e:return"Profiler";case y:return"StrictMode";case g:return"Suspense";case T:return"SuspenseList"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case i:return(t.displayName||"Context")+".Provider";case n:return(t._context.displayName||"Context")+".Consumer";case p:var l=t.render;return t=t.displayName,t||(t=l.displayName||l.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case X:return l=t.displayName||null,l!==null?l:s(t.type)||"Memo";case lt:l=t._payload,t=t._init;try{return s(t(l))}catch{}}return null}function r(t){return""+t}function u(t){try{r(t);var l=!1}catch{l=!0}if(l){l=console;var m=l.error,w=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return m.call(l,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",w),r(t)}}function a(){}function d(){if(q===0){Q=console.log,et=console.info,dt=console.warn,D=console.error,I=console.group,V=console.groupCollapsed,k=console.groupEnd;var t={configurable:!0,enumerable:!0,value:a,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}q++}function f(){if(q--,q===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:E({},t,{value:Q}),info:E({},t,{value:et}),warn:E({},t,{value:dt}),error:E({},t,{value:D}),group:E({},t,{value:I}),groupCollapsed:E({},t,{value:V}),groupEnd:E({},t,{value:k})})}0>q&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}function h(t){if(H===void 0)try{throw Error()}catch(m){var l=m.stack.trim().match(/\n( *(at )?)/);H=l&&l[1]||"",tt=-1<m.stack.indexOf(`
18
- at`)?" (<anonymous>)":-1<m.stack.indexOf("@")?"@unknown:0:0":""}return`
19
- `+H+t+tt}function b(t,l){if(!t||W)return"";var m=Y.get(t);if(m!==void 0)return m;W=!0,m=Error.prepareStackTrace,Error.prepareStackTrace=void 0;var w=null;w=x.H,x.H=null,d();try{var B={DetermineComponentFrameRoot:function(){try{if(l){var mt=function(){throw Error()};if(Object.defineProperty(mt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(mt,[])}catch(yt){var Et=yt}Reflect.construct(t,[],mt)}else{try{mt.call()}catch(yt){Et=yt}t.call(mt.prototype)}}else{try{throw Error()}catch(yt){Et=yt}(mt=t())&&typeof mt.catch=="function"&&mt.catch(function(){})}}catch(yt){if(yt&&Et&&typeof yt.stack=="string")return[yt.stack,Et.stack]}return[null,null]}};B.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var O=Object.getOwnPropertyDescriptor(B.DetermineComponentFrameRoot,"name");O&&O.configurable&&Object.defineProperty(B.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var _=B.DetermineComponentFrameRoot(),it=_[0],bt=_[1];if(it&&bt){var at=it.split(`
20
- `),gt=bt.split(`
21
- `);for(_=O=0;O<at.length&&!at[O].includes("DetermineComponentFrameRoot");)O++;for(;_<gt.length&&!gt[_].includes("DetermineComponentFrameRoot");)_++;if(O===at.length||_===gt.length)for(O=at.length-1,_=gt.length-1;1<=O&&0<=_&&at[O]!==gt[_];)_--;for(;1<=O&&0<=_;O--,_--)if(at[O]!==gt[_]){if(O!==1||_!==1)do if(O--,_--,0>_||at[O]!==gt[_]){var ct=`
22
- `+at[O].replace(" at new "," at ");return t.displayName&&ct.includes("<anonymous>")&&(ct=ct.replace("<anonymous>",t.displayName)),typeof t=="function"&&Y.set(t,ct),ct}while(1<=O&&0<=_);break}}}finally{W=!1,x.H=w,f(),Error.prepareStackTrace=m}return at=(at=t?t.displayName||t.name:"")?h(at):"",typeof t=="function"&&Y.set(t,at),at}function j(t){if(t==null)return"";if(typeof t=="function"){var l=t.prototype;return b(t,!(!l||!l.isReactComponent))}if(typeof t=="string")return h(t);switch(t){case g:return h("Suspense");case T:return h("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case p:return t=b(t.render,!1),t;case X:return j(t.type);case lt:l=t._payload,t=t._init;try{return j(t(l))}catch{}}return""}function o(){var t=x.A;return t===null?null:t.getOwner()}function S(t){if(rt.call(t,"key")){var l=Object.getOwnPropertyDescriptor(t,"key").get;if(l&&l.isReactWarning)return!1}return t.key!==void 0}function A(t,l){function m(){pt||(pt=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",l))}m.isReactWarning=!0,Object.defineProperty(t,"key",{get:m,configurable:!0})}function L(){var t=s(this.type);return R[t]||(R[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function z(t,l,m,w,B,O){return m=O.ref,t={$$typeof:ut,type:t,key:l,props:O,_owner:B},(m!==void 0?m:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:L}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function P(t,l,m,w,B,O){if(typeof t=="string"||typeof t=="function"||t===$||t===e||t===y||t===g||t===T||t===ht||typeof t=="object"&&t!==null&&(t.$$typeof===lt||t.$$typeof===X||t.$$typeof===i||t.$$typeof===n||t.$$typeof===p||t.$$typeof===N||t.getModuleId!==void 0)){var _=l.children;if(_!==void 0)if(w)if(v(_)){for(w=0;w<_.length;w++)J(_[w],t);Object.freeze&&Object.freeze(_)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else J(_,t)}else _="",(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(_+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),t===null?w="null":v(t)?w="array":t!==void 0&&t.$$typeof===ut?(w="<"+(s(t.type)||"Unknown")+" />",_=" Did you accidentally export a JSX literal instead of a component?"):w=typeof t,console.error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",w,_);if(rt.call(l,"key")){_=s(t);var it=Object.keys(l).filter(function(at){return at!=="key"});w=0<it.length?"{key: someKey, "+it.join(": ..., ")+": ...}":"{key: someKey}",K[_+w]||(it=0<it.length?"{"+it.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
23
- let props = %s;
24
- <%s {...props} />
25
- React keys must be passed directly to JSX without using spread:
26
- let props = %s;
27
- <%s key={someKey} {...props} />`,w,_,it,_),K[_+w]=!0)}if(_=null,m!==void 0&&(u(m),_=""+m),S(l)&&(u(l.key),_=""+l.key),"key"in l){m={};for(var bt in l)bt!=="key"&&(m[bt]=l[bt])}else m=l;return _&&A(m,typeof t=="function"?t.displayName||t.name||"Unknown":t),z(t,_,O,B,o(),m)}function J(t,l){if(typeof t=="object"&&t&&t.$$typeof!==M){if(v(t))for(var m=0;m<t.length;m++){var w=t[m];F(w)&&Z(w,l)}else if(F(t))t._store&&(t._store.validated=1);else if(t===null||typeof t!="object"?m=null:(m=C&&t[C]||t["@@iterator"],m=typeof m=="function"?m:null),typeof m=="function"&&m!==t.entries&&(m=m.call(t),m!==t))for(;!(t=m.next()).done;)F(t.value)&&Z(t.value,l)}}function F(t){return typeof t=="object"&&t!==null&&t.$$typeof===ut}function Z(t,l){if(t._store&&!t._store.validated&&t.key==null&&(t._store.validated=1,l=st(l),!_t[l])){_t[l]=!0;var m="";t&&t._owner!=null&&t._owner!==o()&&(m=null,typeof t._owner.tag=="number"?m=s(t._owner.type):typeof t._owner.name=="string"&&(m=t._owner.name),m=" It was passed a child from "+m+".");var w=x.getCurrentStack;x.getCurrentStack=function(){var B=j(t.type);return w&&(B+=w()||""),B},console.error('Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',l,m),x.getCurrentStack=w}}function st(t){var l="",m=o();return m&&(m=s(m.type))&&(l=`
28
-
29
- Check the render method of \``+m+"`."),l||(t=s(t))&&(l=`
30
-
31
- Check the top-level render call using <`+t+">."),l}var nt=U,ut=Symbol.for("react.transitional.element"),ot=Symbol.for("react.portal"),$=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),e=Symbol.for("react.profiler"),n=Symbol.for("react.consumer"),i=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),X=Symbol.for("react.memo"),lt=Symbol.for("react.lazy"),ht=Symbol.for("react.offscreen"),C=Symbol.iterator,G=Symbol.for("react.client.reference"),x=nt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,rt=Object.prototype.hasOwnProperty,E=Object.assign,N=Symbol.for("react.client.reference"),v=Array.isArray,q=0,Q,et,dt,D,I,V,k;a.__reactDisabledLog=!0;var H,tt,W=!1,Y=new(typeof WeakMap=="function"?WeakMap:Map),M=Symbol.for("react.client.reference"),pt,R={},K={},_t={};kt.Fragment=$,kt.jsx=function(t,l,m,w,B){return P(t,l,m,!1,w,B)},kt.jsxs=function(t,l,m,w,B){return P(t,l,m,!0,w,B)}}()),kt}var At;function zt(){return At||(At=1,process.env.NODE_ENV==="production"?jt.exports=Ft():jt.exports=Ut()),jt.exports}var c=zt();const Wt=({speciesList:s,width:r=1e3,height:u=50,padding:a=0,stroke:d="grey",format:f=A=>A.toString(),chronoScale:h=!0,showImages:b=!0,presentTime:j,handleMouseMove:o,children:S})=>{const A=s.map(J=>J.copy()),L=Math.min(...A.map(J=>J.apparition)),z=Math.max(...A.map(J=>J.apparition-L)),P=new xt("",L,z,void 0,[]);return P.display=!1,P.linkDescendants(A),c.jsx(Dt,{commonAncestor:P,width:r,height:u,padding:a,stroke:d,format:f,chronoScale:h,showImages:b,presentTime:j,handleMouseMove:o,children:(J,F,Z,st)=>S==null?void 0:S(J,F,Z,st)})},Dt=({commonAncestor:s,width:r=1e3,height:u=50,padding:a=0,stroke:d="grey",format:f=A=>A.toString(),chronoScale:h=!0,showImages:b=!0,presentTime:j,handleMouseMove:o,children:S})=>{const[A,L]=U.useState(!1),[z,P]=U.useState(void 0),[J,F]=U.useState(void 0),[Z,st]=U.useState(s.allDescendants().reduce((e,n)=>e.set(n,!0),new Map));U.useEffect(()=>{st(s.allDescendants().reduce((e,n)=>e.set(n,!0),new Map))},[s]);const nt=e=>{P(A?void 0:e),L(!A)},ut=e=>{const n=new Map(Z);n.set(e,!Z.get(e)),st(n)},ot=e=>{F(e)},$=j!==void 0&&h,y=e=>b?e.map(n=>n.image?2:1).reduce((n,i)=>n+i):e.length;return c.jsxs(c.Fragment,{children:[c.jsx("svg",{width:r*($?(Math.min(j,s.absoluteExtinction())-s.apparition)/s.absoluteDuration():1),height:u*y($?s.allDescendants().filter(e=>e.apparition<j):s.allDescendants()),onMouseMove:e=>{o==null||o(e.clientX,e.clientY)},children:c.jsx(Nt,{commonAncestor:s,species:s,y:-1,scaleX:r/(h?s.absoluteDuration():Math.max(0,s.stepsUntilLastDescendant())+1),scaleY:u,padding:a,stroke:d,format:f,chronoScale:h,showImages:b,presentTime:j,toggleShowMenu:nt,hoverShowMenu:ot,showDesc:Z,changeShowDesc:ut})}),S==null?void 0:S(z,A,nt,J)]})},Nt=({commonAncestor:s,species:r,y:u,scaleX:a,scaleY:d,padding:f=0,stroke:h="grey",format:b=J=>J.toString(),chronoScale:j=!0,showImages:o=!0,presentTime:S=void 0,toggleShowMenu:A,hoverShowMenu:L,showDesc:z,changeShowDesc:P})=>{const J=S!==void 0&&j,F=s.allDescendants().filter(y=>J?y.apparition<S:!0),Z=F.indexOf(r),st=(j?r.apparition-s.apparition:s.stepsUntil(r)??0)*a,nt=st+(j?Math.min(z.get(r)?r.duration:r.absoluteDuration(),J?S-r.apparition:r.absoluteDuration()):1)*a,ut=o&&Z>0?[...Array(Z).keys()].map(y=>F[y]).map(y=>(y.image?2:1)*d).reduce((y,e)=>y+e):Z*d,ot=r.descendants.filter(y=>J?y.apparition<S:!0),$=ot.length>0?st+(Math.min(...ot.map(y=>y.apparition))-r.apparition)*a:nt;return c.jsxs("g",{children:[u>=0&&c.jsx("line",{x1:st,y1:u,x2:st,y2:ut,stroke:h}),r.display&&c.jsx(Yt,{commonAncestor:s,species:r,height:d,x1:st,x2:nt,x0:$,y:ut,stroke:h,changeShowDesc:()=>P(r),showDesc:z.get(r),padding:f,format:b,chronoScale:j,showImages:o,presentTime:S,toggleShowMenu:A,hoverShowMenu:L}),r.descendants.map((y,e)=>c.jsx("g",{className:z.get(r)&&ot.includes(y)?"block":"hidden",children:c.jsx(Nt,{commonAncestor:s,species:y,y:y.display?ut:-1,scaleX:a,scaleY:d,padding:f,stroke:h,format:b,chronoScale:j,showImages:o,presentTime:S,toggleShowMenu:A,showDesc:z,changeShowDesc:P,hoverShowMenu:L})},F.length+e))]},Z)},Yt=({commonAncestor:s,species:r,height:u,x1:a,x2:d,x0:f,y:h,stroke:b,showDesc:j=!0,changeShowDesc:o=()=>{},padding:S=0,format:A=nt=>nt.toString(),chronoScale:L=!0,showImages:z=!0,presentTime:P,toggleShowMenu:J,hoverShowMenu:F,className:Z,buttonClassName:st})=>{const nt=P!==void 0,ut=s.allDescendants().filter(i=>nt?i.apparition<P:!0),ot=i=>ut.indexOf(i),$=r.ancestor&&ot(r)>ot(r.ancestor)?-3:1,y=r.descendants.filter(i=>nt?i.apparition<P:!0),e=y.filter(i=>i.apparition===r.extinction()).length===0,n=A(Math.min(j?r.extinction():r.absoluteExtinction(),nt?P:r.absoluteExtinction()));return c.jsxs("g",{children:[c.jsx("line",{x1:a,y1:h,x2:d,y2:h,stroke:b}),c.jsx("foreignObject",{x:a+S,y:h+S*$,width:(L?f??d:d)-a-2*S,height:u+(z&&r.image?u:0),children:c.jsxs("div",{className:`flex flex-row justify-between w-full ${Z??""}`,children:[c.jsx("div",{children:L?A(r.apparition):""}),c.jsxs("button",{className:`p-0.625 justify-center flex flex-col items-center ${st??""}`,onClick:()=>J(r),onMouseEnter:()=>F(r),onMouseLeave:()=>F(void 0),children:[r.name,r.image&&z&&c.jsx("img",{src:r.image,alt:r.name,style:{height:u}})]}),y.length>0?c.jsx("button",{onClick:o,className:"h-1",style:{maxWidth:4},children:(e||!j)&&(!f||f===d)?n:""}):c.jsx("div",{children:L?n:""})]})}),L&&f&&f<d&&c.jsx("foreignObject",{x:f+S,y:h+S*$,width:d-f-2*S,height:u,children:c.jsx("div",{className:"flex flex-row justify-end w-full",children:(e||!j)&&L?n:""})})]})},Jt=(s,r,u)=>s<r?r:s>u?u:s;var St={exports:{}};/* @license
1
+ (function(R,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],d):(R=typeof globalThis<"u"?globalThis:R||self,d(R["chrono-phylo-tree"]={},R["react/jsx-runtime"],R.React))})(this,function(R,d,M){"use strict";var Wt=Object.defineProperty;var Kt=(R,d,M)=>d in R?Wt(R,d,{enumerable:!0,configurable:!0,writable:!0,value:M}):R[d]=M;var ft=(R,d,M)=>Kt(R,typeof d!="symbol"?d+"":d,M);const Tt=(r,...n)=>r.sort((o,s)=>{for(const u of n){const[f,c]=[o,s].map(_=>u(_));if(f!==c)return f-c}return 0});class pt{constructor(n="",o=0,s=0,u=void 0,f=[],c=void 0,_=void 0){ft(this,"name","");ft(this,"apparition",0);ft(this,"duration",0);ft(this,"ancestor");ft(this,"descendants",[]);ft(this,"description");ft(this,"display",!0);ft(this,"image");if(s<=0)throw new Error("The duration of the species must be greater than 0");this.name=n,this.apparition=o,this.duration=s,this.ancestor=u,this.descendants=f,this.description=c===""?void 0:c,this.image=_===""?void 0:_}onPosition(n=!0){return n&&this.firstAncestor().stepsUntil(this)%2===0}copy(){const n=this.firstAncestor(),o=n.allDescendants(!1).indexOf(this);return pt.fromJSON(n.toJSON()).allDescendants(!1)[o]}unlinkAncestor(){if(!this.ancestor)return;this.ancestor.descendants=this.ancestor.descendants.filter(o=>o!==this);const n=this.ancestor;return this.ancestor=void 0,[n.firstAncestor(),this]}unlinkDescendant(n){if(this.descendants.includes(n))return this.descendants=this.descendants.filter(o=>o!==n),n.ancestor=void 0,[this.firstAncestor(),n]}linkAncestor(n){if(!(this.ancestor===n&&n.descendants.includes(this))){if(n.apparition>this.apparition)throw new Error(`The ancestor's apparition (${n.apparition}) must be before or equal the descendant's apparition (${this.apparition})`);if(n.extinction()<this.apparition)throw new Error(`The ancestor's extinction (${n.extinction()}) must be after or equal the descendant's apparition (${this.apparition})`);this.ancestor!==n&&this.unlinkAncestor(),this.ancestor=n,n.descendants.push(this)}}linkDescendant(n){if(!(n.ancestor===this&&this.descendants.includes(n))){if(n.apparition<this.apparition)throw new Error(`The descendant's apparition (${n.apparition}) must be after or equal the ancestor's apparition (${this.apparition})`);if(n.extinction()>this.extinction())throw new Error(`The descendant's extinction (${n.extinction()}) must be before or equal the ancestor's extinction (${this.extinction()})`);this.descendants.includes(n)||(n.ancestor&&n.unlinkAncestor(),this.descendants.push(n),n.ancestor=this)}}linkDescendants(n){for(const o of n)try{this.linkDescendant(o)}catch(s){console.error(`Error linking descendant ${o.name} to ancestor ${this.name}:`,s)}}addDescendant(n="",o=0,s=0,u=void 0,f=void 0,c=!1){if(o<0||o>this.duration)throw new Error(`The apparition of the descendant must be between the apparition (${this.apparition}) and the extinction (${this.extinction()}) of the ancestor`);const _=c?this.copy():this,m=new pt(n,_.apparition+Math.max(o,0),Math.max(s,0),void 0,[],u,f);return m.linkAncestor(_),c?_:m}removeDescendant(n){this.descendants=this.descendants.filter(o=>o!==n)}addAncestor(n="",o=0,s=0,u=void 0,f=void 0,c=!0,_=!1){if(o<0)throw new Error(`The apparition of the ancestor must be before or equal the apparition (${this.apparition}) of the descendant`);if(s<o)throw new Error(`The extiction of the ancestor must be after or equal the apparition (${this.apparition}) of the descendant`);const m=_?this.copy():this,a=new pt(n,m.apparition-Math.max(o,0),s,void 0,[],u,f);return a.display=c,m.linkAncestor(a),_?m:a}extinction(){return this.apparition+this.duration}absoluteExtinction(){return this.descendants.length>0?Math.max(...this.allDescendants(!1).map(n=>n.extinction())):this.extinction()}absoluteDuration(){return this.absoluteExtinction()-this.apparition}firstAncestor(n=!1){return this.ancestor?this.ancestor.display||n?this.ancestor.firstAncestor():this:this}cousinsExtinction(){return this.firstAncestor().absoluteExtinction()}allDescendants(n=!0){const o=n?Tt(this.descendants,a=>-a.apparition,a=>-a.absoluteExtinction()):this.descendants;if(o.length===0)return[this];const s=o.filter(a=>a.apparition>=this.extinction()),u=o.filter(a=>s.indexOf(a)===-1),c=(this.onPosition(n)?Math.ceil:Math.floor)(s.length/2),_=s.slice(0,c),m=s.slice(c);return _.flatMap(a=>a.allDescendants(n)).concat([this]).concat(m.flatMap(a=>a.allDescendants(n))).concat(u.flatMap(a=>a.allDescendants(n)))}stepsChain(n,o=!1){var s;return this.allDescendants(!1).includes(n)?[this].concat(((s=this.descendants.find(u=>u.allDescendants(!1).includes(n)))==null?void 0:s.stepsChain(n))??[]).filter(u=>u.display||o):[]}stepsUntil(n,o=!1){if(this.allDescendants(!1).includes(n))return this.stepsChain(n,o).length-1}stepsUntilLastDescendant(n=!1){return this.descendants.length===0?0:Math.max(...this.allDescendants(!1).filter(o=>o.descendants.length===0).map(o=>this.stepsUntil(o,n)??0))}toJSON(){return{name:this.name,apparition:this.ancestor?void 0:this.apparition,afterApparition:this.ancestor?this.apparition-this.ancestor.apparition:void 0,description:this.description,duration:this.duration,descendants:this.descendants.length>0?this.descendants.map(n=>n.toJSON()):void 0,image:this.image}}async saveJSON(n=void 0){try{const o=JSON.stringify(this.toJSON(),null,2),s=new Blob([o],{type:"application/json"}),u=URL.createObjectURL(s),f=document.createElement("a");f.href=u,f.download=n??`${this.name}.json`,f.click(),URL.revokeObjectURL(u)}catch(o){console.error("Error saving file:",o)}}static fromJSON(n,o){const s=n.afterApparition??0,u=o?o.apparition:n.apparition??0,f=new pt(n.name??"",u+s,n.duration??0,o,[],n.description,n.image);if(n.descendants)for(const c of n.descendants)f.descendants.push(pt.fromJSON(c,f));return f}}const Mt=({speciesList:r,width:n=1e3,height:o=50,padding:s=0,stroke:u="grey",format:f=E=>E.toString(),chronoScale:c=!0,showImages:_=!0,presentTime:m,handleMouseMove:a,children:v})=>{const E=r.map(P=>P.copy()),C=Math.min(...E.map(P=>P.apparition)),I=Math.max(...E.map(P=>P.apparition-C)),T=new pt("",C,I,void 0,[]);return T.display=!1,T.linkDescendants(E),d.jsx(Et,{commonAncestor:T,width:n,height:o,padding:s,stroke:u,format:f,chronoScale:c,showImages:_,presentTime:m,handleMouseMove:a,children:(P,F,H,V)=>v==null?void 0:v(P,F,H,V)})},Et=({commonAncestor:r,width:n=1e3,height:o=50,padding:s=0,stroke:u="grey",format:f=E=>E.toString(),chronoScale:c=!0,showImages:_=!0,presentTime:m,handleMouseMove:a,children:v})=>{const[E,C]=M.useState(!1),[I,T]=M.useState(void 0),[P,F]=M.useState(void 0),[H,V]=M.useState(r.allDescendants().reduce((t,e)=>t.set(e,!0),new Map));M.useEffect(()=>{V(r.allDescendants().reduce((t,e)=>t.set(e,!0),new Map))},[r]);const Z=t=>{T(E?void 0:t),C(!E)},rt=t=>{const e=new Map(H);e.set(t,!H.get(t)),V(e)},et=t=>{F(t)},Q=m!==void 0&&c,g=t=>_?t.map(e=>e.image?2:1).reduce((e,i)=>e+i):t.length;return d.jsxs(d.Fragment,{children:[d.jsx("svg",{width:n*(Q?(Math.min(m,r.absoluteExtinction())-r.apparition)/r.absoluteDuration():1),height:o*g(Q?r.allDescendants().filter(t=>t.apparition<m):r.allDescendants()),onMouseMove:t=>{a==null||a(t.clientX,t.clientY)},children:d.jsx(St,{commonAncestor:r,species:r,y:-1,scaleX:n/(c?r.absoluteDuration():Math.max(0,r.stepsUntilLastDescendant())+1),scaleY:o,padding:s,stroke:u,format:f,chronoScale:c,showImages:_,presentTime:m,toggleShowMenu:Z,hoverShowMenu:et,showDesc:H,changeShowDesc:rt})}),v==null?void 0:v(I,E,Z,P)]})},St=({commonAncestor:r,species:n,y:o,scaleX:s,scaleY:u,padding:f=0,stroke:c="grey",format:_=P=>P.toString(),chronoScale:m=!0,showImages:a=!0,presentTime:v=void 0,toggleShowMenu:E,hoverShowMenu:C,showDesc:I,changeShowDesc:T})=>{const P=v!==void 0&&m,F=r.allDescendants().filter(g=>P?g.apparition<v:!0),H=F.indexOf(n),V=(m?n.apparition-r.apparition:r.stepsUntil(n)??0)*s,Z=V+(m?Math.min(I.get(n)?n.duration:n.absoluteDuration(),P?v-n.apparition:n.absoluteDuration()):1)*s,rt=a&&H>0?[...Array(H).keys()].map(g=>F[g]).map(g=>(g.image?2:1)*u).reduce((g,t)=>g+t):H*u,et=n.descendants.filter(g=>P?g.apparition<v:!0),Q=et.length>0?V+(Math.min(...et.map(g=>g.apparition))-n.apparition)*s:Z;return d.jsxs("g",{children:[o>=0&&d.jsx("line",{x1:V,y1:o,x2:V,y2:rt,stroke:c}),n.display&&d.jsx(Lt,{commonAncestor:r,species:n,height:u,x1:V,x2:Z,x0:Q,y:rt,stroke:c,changeShowDesc:()=>T(n),showDesc:I.get(n),padding:f,format:_,chronoScale:m,showImages:a,presentTime:v,toggleShowMenu:E,hoverShowMenu:C}),n.descendants.map((g,t)=>d.jsx("g",{className:I.get(n)&&et.includes(g)?"block":"hidden",children:d.jsx(St,{commonAncestor:r,species:g,y:g.display?rt:-1,scaleX:s,scaleY:u,padding:f,stroke:c,format:_,chronoScale:m,showImages:a,presentTime:v,toggleShowMenu:E,showDesc:I,changeShowDesc:T,hoverShowMenu:C})},F.length+t))]},H)},Lt=({commonAncestor:r,species:n,height:o,x1:s,x2:u,x0:f,y:c,stroke:_,showDesc:m=!0,changeShowDesc:a=()=>{},padding:v=0,format:E=Z=>Z.toString(),chronoScale:C=!0,showImages:I=!0,presentTime:T,toggleShowMenu:P,hoverShowMenu:F,className:H,buttonClassName:V})=>{const Z=T!==void 0,rt=r.allDescendants().filter(i=>Z?i.apparition<T:!0),et=i=>rt.indexOf(i),Q=n.ancestor&&et(n)>et(n.ancestor)?-3:1,g=n.descendants.filter(i=>Z?i.apparition<T:!0),t=g.filter(i=>i.apparition===n.extinction()).length===0,e=E(Math.min(m?n.extinction():n.absoluteExtinction(),Z?T:n.absoluteExtinction()));return d.jsxs("g",{children:[d.jsx("line",{x1:s,y1:c,x2:u,y2:c,stroke:_}),d.jsx("foreignObject",{x:s+v,y:c+v*Q,width:(C?f??u:u)-s-2*v,height:o+(I&&n.image?o:0),children:d.jsxs("div",{className:`flex flex-row justify-between w-full ${H??""}`,children:[d.jsx("div",{children:C?E(n.apparition):""}),d.jsxs("button",{className:`p-0.625 justify-center flex flex-col items-center ${V??""}`,onClick:()=>P(n),onMouseEnter:()=>F(n),onMouseLeave:()=>F(void 0),children:[n.name,n.image&&I&&d.jsx("img",{src:n.image,alt:n.name,style:{height:o}})]}),g.length>0?d.jsx("button",{onClick:a,className:"h-1",style:{maxWidth:4},children:(t||!m)&&(!f||f===u)?e:""}):d.jsx("div",{children:C?e:""})]})}),C&&f&&f<u&&d.jsx("foreignObject",{x:f+v,y:c+v*Q,width:u-f-2*v,height:o,children:d.jsx("div",{className:"flex flex-row justify-end w-full",children:(t||!m)&&C?e:""})})]})},It=(r,n,o)=>r<n?n:r>o?o:r;function Ft(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var mt={exports:{}};/* @license
32
2
  Papa Parse
33
3
  v5.5.2
34
4
  https://github.com/mholt/PapaParse
35
5
  License: MIT
36
- */var Bt=St.exports,Mt;function Ht(){return Mt||(Mt=1,function(s,r){((u,a)=>{s.exports=a()})(Bt,function u(){var a=typeof self<"u"?self:typeof window<"u"?window:a!==void 0?a:{},d,f=!a.document&&!!a.postMessage,h=a.IS_PAPA_WORKER||!1,b={},j=0,o={};function S(e){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},(function(n){var i=ot(n);i.chunkSize=parseInt(i.chunkSize),n.step||n.chunk||(i.chunkSize=null),this._handle=new J(i),(this._handle.streamer=this)._config=i}).call(this,e),this.parseChunk=function(n,i){var p=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<p){let T=this._config.newline;T||(g=this._config.quoteChar||'"',T=this._handle.guessLineEndings(n,g)),n=[...n.split(T).slice(p)].join(T)}this.isFirstChunk&&y(this._config.beforeFirstChunk)&&(g=this._config.beforeFirstChunk(n))!==void 0&&(n=g),this.isFirstChunk=!1,this._halted=!1;var p=this._partialLine+n,g=(this._partialLine="",this._handle.parse(p,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(n=g.meta.cursor,p=(this._finished||(this._partialLine=p.substring(n-this._baseIndex),this._baseIndex=n),g&&g.data&&(this._rowCount+=g.data.length),this._finished||this._config.preview&&this._rowCount>=this._config.preview),h)a.postMessage({results:g,workerId:o.WORKER_ID,finished:p});else if(y(this._config.chunk)&&!i){if(this._config.chunk(g,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=g=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(g.data),this._completeResults.errors=this._completeResults.errors.concat(g.errors),this._completeResults.meta=g.meta),this._completed||!p||!y(this._config.complete)||g&&g.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),p||g&&g.meta.paused||this._nextChunk(),g}this._halted=!0},this._sendError=function(n){y(this._config.error)?this._config.error(n):h&&this._config.error&&a.postMessage({workerId:o.WORKER_ID,error:n,finished:!1})}}function A(e){var n;(e=e||{}).chunkSize||(e.chunkSize=o.RemoteChunkSize),S.call(this,e),this._nextChunk=f?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(i){this._input=i,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(n=new XMLHttpRequest,this._config.withCredentials&&(n.withCredentials=this._config.withCredentials),f||(n.onload=$(this._chunkLoaded,this),n.onerror=$(this._chunkError,this)),n.open(this._config.downloadRequestBody?"POST":"GET",this._input,!f),this._config.downloadRequestHeaders){var i,p=this._config.downloadRequestHeaders;for(i in p)n.setRequestHeader(i,p[i])}var g;this._config.chunkSize&&(g=this._start+this._config.chunkSize-1,n.setRequestHeader("Range","bytes="+this._start+"-"+g));try{n.send(this._config.downloadRequestBody)}catch(T){this._chunkError(T.message)}f&&n.status===0&&this._chunkError()}},this._chunkLoaded=function(){n.readyState===4&&(n.status<200||400<=n.status?this._chunkError():(this._start+=this._config.chunkSize||n.responseText.length,this._finished=!this._config.chunkSize||this._start>=(i=>(i=i.getResponseHeader("Content-Range"))!==null?parseInt(i.substring(i.lastIndexOf("/")+1)):-1)(n),this.parseChunk(n.responseText)))},this._chunkError=function(i){i=n.statusText||i,this._sendError(new Error(i))}}function L(e){(e=e||{}).chunkSize||(e.chunkSize=o.LocalChunkSize),S.call(this,e);var n,i,p=typeof FileReader<"u";this.stream=function(g){this._input=g,i=g.slice||g.webkitSlice||g.mozSlice,p?((n=new FileReader).onload=$(this._chunkLoaded,this),n.onerror=$(this._chunkError,this)):n=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var g=this._input,T=(this._config.chunkSize&&(T=Math.min(this._start+this._config.chunkSize,this._input.size),g=i.call(g,this._start,T)),n.readAsText(g,this._config.encoding));p||this._chunkLoaded({target:{result:T}})},this._chunkLoaded=function(g){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(g.target.result)},this._chunkError=function(){this._sendError(n.error)}}function z(e){var n;S.call(this,e=e||{}),this.stream=function(i){return n=i,this._nextChunk()},this._nextChunk=function(){var i,p;if(!this._finished)return i=this._config.chunkSize,n=i?(p=n.substring(0,i),n.substring(i)):(p=n,""),this._finished=!n,this.parseChunk(p)}}function P(e){S.call(this,e=e||{});var n=[],i=!0,p=!1;this.pause=function(){S.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){S.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(g){this._input=g,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){p&&n.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),n.length?this.parseChunk(n.shift()):i=!0},this._streamData=$(function(g){try{n.push(typeof g=="string"?g:g.toString(this._config.encoding)),i&&(i=!1,this._checkIsFinished(),this.parseChunk(n.shift()))}catch(T){this._streamError(T)}},this),this._streamError=$(function(g){this._streamCleanUp(),this._sendError(g)},this),this._streamEnd=$(function(){this._streamCleanUp(),p=!0,this._streamData("")},this),this._streamCleanUp=$(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function J(e){var n,i,p,g,T=Math.pow(2,53),X=-T,lt=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,ht=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,C=this,G=0,x=0,rt=!1,E=!1,N=[],v={data:[],errors:[],meta:{}};function q(D){return e.skipEmptyLines==="greedy"?D.join("").trim()==="":D.length===1&&D[0].length===0}function Q(){if(v&&p&&(dt("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+o.DefaultDelimiter+"'"),p=!1),e.skipEmptyLines&&(v.data=v.data.filter(function(k){return!q(k)})),et()){let k=function(H,tt){y(e.transformHeader)&&(H=e.transformHeader(H,tt)),N.push(H)};if(v)if(Array.isArray(v.data[0])){for(var D=0;et()&&D<v.data.length;D++)v.data[D].forEach(k);v.data.splice(0,1)}else v.data.forEach(k)}function I(k,H){for(var tt=e.header?{}:[],W=0;W<k.length;W++){var Y=W,M=k[W],M=((pt,R)=>(K=>(e.dynamicTypingFunction&&e.dynamicTyping[K]===void 0&&(e.dynamicTyping[K]=e.dynamicTypingFunction(K)),(e.dynamicTyping[K]||e.dynamicTyping)===!0))(pt)?R==="true"||R==="TRUE"||R!=="false"&&R!=="FALSE"&&((K=>{if(lt.test(K)&&(K=parseFloat(K),X<K&&K<T))return 1})(R)?parseFloat(R):ht.test(R)?new Date(R):R===""?null:R):R)(Y=e.header?W>=N.length?"__parsed_extra":N[W]:Y,M=e.transform?e.transform(M,Y):M);Y==="__parsed_extra"?(tt[Y]=tt[Y]||[],tt[Y].push(M)):tt[Y]=M}return e.header&&(W>N.length?dt("FieldMismatch","TooManyFields","Too many fields: expected "+N.length+" fields but parsed "+W,x+H):W<N.length&&dt("FieldMismatch","TooFewFields","Too few fields: expected "+N.length+" fields but parsed "+W,x+H)),tt}var V;v&&(e.header||e.dynamicTyping||e.transform)&&(V=1,!v.data.length||Array.isArray(v.data[0])?(v.data=v.data.map(I),V=v.data.length):v.data=I(v.data,0),e.header&&v.meta&&(v.meta.fields=N),x+=V)}function et(){return e.header&&N.length===0}function dt(D,I,V,k){D={type:D,code:I,message:V},k!==void 0&&(D.row=k),v.errors.push(D)}y(e.step)&&(g=e.step,e.step=function(D){v=D,et()?Q():(Q(),v.data.length!==0&&(G+=D.data.length,e.preview&&G>e.preview?i.abort():(v.data=v.data[0],g(v,C))))}),this.parse=function(D,I,V){var k=e.quoteChar||'"',k=(e.newline||(e.newline=this.guessLineEndings(D,k)),p=!1,e.delimiter?y(e.delimiter)&&(e.delimiter=e.delimiter(D),v.meta.delimiter=e.delimiter):((k=((H,tt,W,Y,M)=>{var pt,R,K,_t;M=M||[","," ","|",";",o.RECORD_SEP,o.UNIT_SEP];for(var t=0;t<M.length;t++){for(var l,m=M[t],w=0,B=0,O=0,_=(K=void 0,new Z({comments:Y,delimiter:m,newline:tt,preview:10}).parse(H)),it=0;it<_.data.length;it++)W&&q(_.data[it])?O++:(l=_.data[it].length,B+=l,K===void 0?K=l:0<l&&(w+=Math.abs(l-K),K=l));0<_.data.length&&(B/=_.data.length-O),(R===void 0||w<=R)&&(_t===void 0||_t<B)&&1.99<B&&(R=w,pt=m,_t=B)}return{successful:!!(e.delimiter=pt),bestDelimiter:pt}})(D,e.newline,e.skipEmptyLines,e.comments,e.delimitersToGuess)).successful?e.delimiter=k.bestDelimiter:(p=!0,e.delimiter=o.DefaultDelimiter),v.meta.delimiter=e.delimiter),ot(e));return e.preview&&e.header&&k.preview++,n=D,i=new Z(k),v=i.parse(n,I,V),Q(),rt?{meta:{paused:!0}}:v||{meta:{paused:!1}}},this.paused=function(){return rt},this.pause=function(){rt=!0,i.abort(),n=y(e.chunk)?"":n.substring(i.getCharIndex())},this.resume=function(){C.streamer._halted?(rt=!1,C.streamer.parseChunk(n,!0)):setTimeout(C.resume,3)},this.aborted=function(){return E},this.abort=function(){E=!0,i.abort(),v.meta.aborted=!0,y(e.complete)&&e.complete(v),n=""},this.guessLineEndings=function(H,k){H=H.substring(0,1048576);var k=new RegExp(F(k)+"([^]*?)"+F(k),"gm"),V=(H=H.replace(k,"")).split("\r"),k=H.split(`
37
- `),H=1<k.length&&k[0].length<V[0].length;if(V.length===1||H)return`
38
- `;for(var tt=0,W=0;W<V.length;W++)V[W][0]===`
39
- `&&tt++;return tt>=V.length/2?`\r
40
- `:"\r"}}function F(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Z(e){var n=(e=e||{}).delimiter,i=e.newline,p=e.comments,g=e.step,T=e.preview,X=e.fastMode,lt=null,ht=!1,C=e.quoteChar==null?'"':e.quoteChar,G=C;if(e.escapeChar!==void 0&&(G=e.escapeChar),(typeof n!="string"||-1<o.BAD_DELIMITERS.indexOf(n))&&(n=","),p===n)throw new Error("Comment character same as delimiter");p===!0?p="#":(typeof p!="string"||-1<o.BAD_DELIMITERS.indexOf(p))&&(p=!1),i!==`
6
+ */var Nt=mt.exports,Dt;function jt(){return Dt||(Dt=1,function(r,n){((o,s)=>{r.exports=s()})(Nt,function o(){var s=typeof self<"u"?self:typeof window<"u"?window:s!==void 0?s:{},u,f=!s.document&&!!s.postMessage,c=s.IS_PAPA_WORKER||!1,_={},m=0,a={};function v(t){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},(function(e){var i=et(e);i.chunkSize=parseInt(i.chunkSize),e.step||e.chunk||(i.chunkSize=null),this._handle=new P(i),(this._handle.streamer=this)._config=i}).call(this,t),this.parseChunk=function(e,i){var h=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<h){let x=this._config.newline;x||(l=this._config.quoteChar||'"',x=this._handle.guessLineEndings(e,l)),e=[...e.split(x).slice(h)].join(x)}this.isFirstChunk&&g(this._config.beforeFirstChunk)&&(l=this._config.beforeFirstChunk(e))!==void 0&&(e=l),this.isFirstChunk=!1,this._halted=!1;var h=this._partialLine+e,l=(this._partialLine="",this._handle.parse(h,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(e=l.meta.cursor,h=(this._finished||(this._partialLine=h.substring(e-this._baseIndex),this._baseIndex=e),l&&l.data&&(this._rowCount+=l.data.length),this._finished||this._config.preview&&this._rowCount>=this._config.preview),c)s.postMessage({results:l,workerId:a.WORKER_ID,finished:h});else if(g(this._config.chunk)&&!i){if(this._config.chunk(l,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=l=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(l.data),this._completeResults.errors=this._completeResults.errors.concat(l.errors),this._completeResults.meta=l.meta),this._completed||!h||!g(this._config.complete)||l&&l.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),h||l&&l.meta.paused||this._nextChunk(),l}this._halted=!0},this._sendError=function(e){g(this._config.error)?this._config.error(e):c&&this._config.error&&s.postMessage({workerId:a.WORKER_ID,error:e,finished:!1})}}function E(t){var e;(t=t||{}).chunkSize||(t.chunkSize=a.RemoteChunkSize),v.call(this,t),this._nextChunk=f?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(i){this._input=i,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(e=new XMLHttpRequest,this._config.withCredentials&&(e.withCredentials=this._config.withCredentials),f||(e.onload=Q(this._chunkLoaded,this),e.onerror=Q(this._chunkError,this)),e.open(this._config.downloadRequestBody?"POST":"GET",this._input,!f),this._config.downloadRequestHeaders){var i,h=this._config.downloadRequestHeaders;for(i in h)e.setRequestHeader(i,h[i])}var l;this._config.chunkSize&&(l=this._start+this._config.chunkSize-1,e.setRequestHeader("Range","bytes="+this._start+"-"+l));try{e.send(this._config.downloadRequestBody)}catch(x){this._chunkError(x.message)}f&&e.status===0&&this._chunkError()}},this._chunkLoaded=function(){e.readyState===4&&(e.status<200||400<=e.status?this._chunkError():(this._start+=this._config.chunkSize||e.responseText.length,this._finished=!this._config.chunkSize||this._start>=(i=>(i=i.getResponseHeader("Content-Range"))!==null?parseInt(i.substring(i.lastIndexOf("/")+1)):-1)(e),this.parseChunk(e.responseText)))},this._chunkError=function(i){i=e.statusText||i,this._sendError(new Error(i))}}function C(t){(t=t||{}).chunkSize||(t.chunkSize=a.LocalChunkSize),v.call(this,t);var e,i,h=typeof FileReader<"u";this.stream=function(l){this._input=l,i=l.slice||l.webkitSlice||l.mozSlice,h?((e=new FileReader).onload=Q(this._chunkLoaded,this),e.onerror=Q(this._chunkError,this)):e=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var l=this._input,x=(this._config.chunkSize&&(x=Math.min(this._start+this._config.chunkSize,this._input.size),l=i.call(l,this._start,x)),e.readAsText(l,this._config.encoding));h||this._chunkLoaded({target:{result:x}})},this._chunkLoaded=function(l){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(l.target.result)},this._chunkError=function(){this._sendError(e.error)}}function I(t){var e;v.call(this,t=t||{}),this.stream=function(i){return e=i,this._nextChunk()},this._nextChunk=function(){var i,h;if(!this._finished)return i=this._config.chunkSize,e=i?(h=e.substring(0,i),e.substring(i)):(h=e,""),this._finished=!e,this.parseChunk(h)}}function T(t){v.call(this,t=t||{});var e=[],i=!0,h=!1;this.pause=function(){v.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){v.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(l){this._input=l,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){h&&e.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),e.length?this.parseChunk(e.shift()):i=!0},this._streamData=Q(function(l){try{e.push(typeof l=="string"?l:l.toString(this._config.encoding)),i&&(i=!1,this._checkIsFinished(),this.parseChunk(e.shift()))}catch(x){this._streamError(x)}},this),this._streamError=Q(function(l){this._streamCleanUp(),this._sendError(l)},this),this._streamEnd=Q(function(){this._streamCleanUp(),h=!0,this._streamData("")},this),this._streamCleanUp=Q(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function P(t){var e,i,h,l,x=Math.pow(2,53),J=-x,st=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,at=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,S=this,q=0,y=0,Y=!1,w=!1,D=[],p={data:[],errors:[],meta:{}};function W(O){return t.skipEmptyLines==="greedy"?O.join("").trim()==="":O.length===1&&O[0].length===0}function B(){if(p&&h&&(ot("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+a.DefaultDelimiter+"'"),h=!1),t.skipEmptyLines&&(p.data=p.data.filter(function(b){return!W(b)})),G()){let b=function($,K){g(t.transformHeader)&&($=t.transformHeader($,K)),D.push($)};if(p)if(Array.isArray(p.data[0])){for(var O=0;G()&&O<p.data.length;O++)p.data[O].forEach(b);p.data.splice(0,1)}else p.data.forEach(b)}function L(b,$){for(var K=t.header?{}:[],N=0;N<b.length;N++){var j=N,A=b[N],A=((dt,k)=>(U=>(t.dynamicTypingFunction&&t.dynamicTyping[U]===void 0&&(t.dynamicTyping[U]=t.dynamicTypingFunction(U)),(t.dynamicTyping[U]||t.dynamicTyping)===!0))(dt)?k==="true"||k==="TRUE"||k!=="false"&&k!=="FALSE"&&((U=>{if(st.test(U)&&(U=parseFloat(U),J<U&&U<x))return 1})(k)?parseFloat(k):at.test(k)?new Date(k):k===""?null:k):k)(j=t.header?N>=D.length?"__parsed_extra":D[N]:j,A=t.transform?t.transform(A,j):A);j==="__parsed_extra"?(K[j]=K[j]||[],K[j].push(A)):K[j]=A}return t.header&&(N>D.length?ot("FieldMismatch","TooManyFields","Too many fields: expected "+D.length+" fields but parsed "+N,y+$):N<D.length&&ot("FieldMismatch","TooFewFields","Too few fields: expected "+D.length+" fields but parsed "+N,y+$)),K}var z;p&&(t.header||t.dynamicTyping||t.transform)&&(z=1,!p.data.length||Array.isArray(p.data[0])?(p.data=p.data.map(L),z=p.data.length):p.data=L(p.data,0),t.header&&p.meta&&(p.meta.fields=D),y+=z)}function G(){return t.header&&D.length===0}function ot(O,L,z,b){O={type:O,code:L,message:z},b!==void 0&&(O.row=b),p.errors.push(O)}g(t.step)&&(l=t.step,t.step=function(O){p=O,G()?B():(B(),p.data.length!==0&&(q+=O.data.length,t.preview&&q>t.preview?i.abort():(p.data=p.data[0],l(p,S))))}),this.parse=function(O,L,z){var b=t.quoteChar||'"',b=(t.newline||(t.newline=this.guessLineEndings(O,b)),h=!1,t.delimiter?g(t.delimiter)&&(t.delimiter=t.delimiter(O),p.meta.delimiter=t.delimiter):((b=(($,K,N,j,A)=>{var dt,k,U,gt;A=A||[","," ","|",";",a.RECORD_SEP,a.UNIT_SEP];for(var _t=0;_t<A.length;_t++){for(var ht,bt=A[_t],tt=0,lt=0,X=0,it=(U=void 0,new H({comments:j,delimiter:bt,newline:K,preview:10}).parse($)),ct=0;ct<it.data.length;ct++)N&&W(it.data[ct])?X++:(ht=it.data[ct].length,lt+=ht,U===void 0?U=ht:0<ht&&(tt+=Math.abs(ht-U),U=ht));0<it.data.length&&(lt/=it.data.length-X),(k===void 0||tt<=k)&&(gt===void 0||gt<lt)&&1.99<lt&&(k=tt,dt=bt,gt=lt)}return{successful:!!(t.delimiter=dt),bestDelimiter:dt}})(O,t.newline,t.skipEmptyLines,t.comments,t.delimitersToGuess)).successful?t.delimiter=b.bestDelimiter:(h=!0,t.delimiter=a.DefaultDelimiter),p.meta.delimiter=t.delimiter),et(t));return t.preview&&t.header&&b.preview++,e=O,i=new H(b),p=i.parse(e,L,z),B(),Y?{meta:{paused:!0}}:p||{meta:{paused:!1}}},this.paused=function(){return Y},this.pause=function(){Y=!0,i.abort(),e=g(t.chunk)?"":e.substring(i.getCharIndex())},this.resume=function(){S.streamer._halted?(Y=!1,S.streamer.parseChunk(e,!0)):setTimeout(S.resume,3)},this.aborted=function(){return w},this.abort=function(){w=!0,i.abort(),p.meta.aborted=!0,g(t.complete)&&t.complete(p),e=""},this.guessLineEndings=function($,b){$=$.substring(0,1048576);var b=new RegExp(F(b)+"([^]*?)"+F(b),"gm"),z=($=$.replace(b,"")).split("\r"),b=$.split(`
7
+ `),$=1<b.length&&b[0].length<z[0].length;if(z.length===1||$)return`
8
+ `;for(var K=0,N=0;N<z.length;N++)z[N][0]===`
9
+ `&&K++;return K>=z.length/2?`\r
10
+ `:"\r"}}function F(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function H(t){var e=(t=t||{}).delimiter,i=t.newline,h=t.comments,l=t.step,x=t.preview,J=t.fastMode,st=null,at=!1,S=t.quoteChar==null?'"':t.quoteChar,q=S;if(t.escapeChar!==void 0&&(q=t.escapeChar),(typeof e!="string"||-1<a.BAD_DELIMITERS.indexOf(e))&&(e=","),h===e)throw new Error("Comment character same as delimiter");h===!0?h="#":(typeof h!="string"||-1<a.BAD_DELIMITERS.indexOf(h))&&(h=!1),i!==`
41
11
  `&&i!=="\r"&&i!==`\r
42
12
  `&&(i=`
43
- `);var x=0,rt=!1;this.parse=function(E,N,v){if(typeof E!="string")throw new Error("Input must be a string");var q=E.length,Q=n.length,et=i.length,dt=p.length,D=y(g),I=[],V=[],k=[],H=x=0;if(!E)return w();if(X||X!==!1&&E.indexOf(C)===-1){for(var tt=E.split(i),W=0;W<tt.length;W++){if(k=tt[W],x+=k.length,W!==tt.length-1)x+=i.length;else if(v)return w();if(!p||k.substring(0,dt)!==p){if(D){if(I=[],_t(k.split(n)),B(),rt)return w()}else _t(k.split(n));if(T&&T<=W)return I=I.slice(0,T),w(!0)}}return w()}for(var Y=E.indexOf(n,x),M=E.indexOf(i,x),pt=new RegExp(F(G)+F(C),"g"),R=E.indexOf(C,x);;)if(E[x]===C)for(R=x,x++;;){if((R=E.indexOf(C,R+1))===-1)return v||V.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:I.length,index:x}),l();if(R===q-1)return l(E.substring(x,R).replace(pt,C));if(C===G&&E[R+1]===G)R++;else if(C===G||R===0||E[R-1]!==G){Y!==-1&&Y<R+1&&(Y=E.indexOf(n,R+1));var K=t((M=M!==-1&&M<R+1?E.indexOf(i,R+1):M)===-1?Y:Math.min(Y,M));if(E.substr(R+1+K,Q)===n){k.push(E.substring(x,R).replace(pt,C)),E[x=R+1+K+Q]!==C&&(R=E.indexOf(C,x)),Y=E.indexOf(n,x),M=E.indexOf(i,x);break}if(K=t(M),E.substring(R+1+K,R+1+K+et)===i){if(k.push(E.substring(x,R).replace(pt,C)),m(R+1+K+et),Y=E.indexOf(n,x),R=E.indexOf(C,x),D&&(B(),rt))return w();if(T&&I.length>=T)return w(!0);break}V.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:I.length,index:x}),R++}}else if(p&&k.length===0&&E.substring(x,x+dt)===p){if(M===-1)return w();x=M+et,M=E.indexOf(i,x),Y=E.indexOf(n,x)}else if(Y!==-1&&(Y<M||M===-1))k.push(E.substring(x,Y)),x=Y+Q,Y=E.indexOf(n,x);else{if(M===-1)break;if(k.push(E.substring(x,M)),m(M+et),D&&(B(),rt))return w();if(T&&I.length>=T)return w(!0)}return l();function _t(O){I.push(O),H=x}function t(O){var _=0;return _=O!==-1&&(O=E.substring(R+1,O))&&O.trim()===""?O.length:_}function l(O){return v||(O===void 0&&(O=E.substring(x)),k.push(O),x=q,_t(k),D&&B()),w()}function m(O){x=O,_t(k),k=[],M=E.indexOf(i,x)}function w(O){if(e.header&&!N&&I.length&&!ht){var _=I[0],it={},bt=new Set(_);let at=!1;for(let gt=0;gt<_.length;gt++){let ct=_[gt];if(it[ct=y(e.transformHeader)?e.transformHeader(ct,gt):ct]){let mt,Et=it[ct];for(;mt=ct+"_"+Et,Et++,bt.has(mt););bt.add(mt),_[gt]=mt,it[ct]++,at=!0,(lt=lt===null?{}:lt)[mt]=ct}else it[ct]=1,_[gt]=ct;bt.add(ct)}at&&console.warn("Duplicate headers found and renamed."),ht=!0}return{data:I,errors:V,meta:{delimiter:n,linebreak:i,aborted:rt,truncated:!!O,cursor:H+(N||0),renamedHeaders:lt}}}function B(){g(w()),I=[],V=[]}},this.abort=function(){rt=!0},this.getCharIndex=function(){return x}}function st(e){var n=e.data,i=b[n.workerId],p=!1;if(n.error)i.userError(n.error,n.file);else if(n.results&&n.results.data){var g={abort:function(){p=!0,nt(n.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:ut,resume:ut};if(y(i.userStep)){for(var T=0;T<n.results.data.length&&(i.userStep({data:n.results.data[T],errors:n.results.errors,meta:n.results.meta},g),!p);T++);delete n.results}else y(i.userChunk)&&(i.userChunk(n.results,g,n.file),delete n.results)}n.finished&&!p&&nt(n.workerId,n.results)}function nt(e,n){var i=b[e];y(i.userComplete)&&i.userComplete(n),i.terminate(),delete b[e]}function ut(){throw new Error("Not implemented.")}function ot(e){if(typeof e!="object"||e===null)return e;var n,i=Array.isArray(e)?[]:{};for(n in e)i[n]=ot(e[n]);return i}function $(e,n){return function(){e.apply(n,arguments)}}function y(e){return typeof e=="function"}return o.parse=function(e,n){var i=(n=n||{}).dynamicTyping||!1;if(y(i)&&(n.dynamicTypingFunction=i,i={}),n.dynamicTyping=i,n.transform=!!y(n.transform)&&n.transform,!n.worker||!o.WORKERS_SUPPORTED)return i=null,o.NODE_STREAM_INPUT,typeof e=="string"?(e=(p=>p.charCodeAt(0)!==65279?p:p.slice(1))(e),i=new(n.download?A:z)(n)):e.readable===!0&&y(e.read)&&y(e.on)?i=new P(n):(a.File&&e instanceof File||e instanceof Object)&&(i=new L(n)),i.stream(e);(i=(()=>{var p;return!!o.WORKERS_SUPPORTED&&(p=(()=>{var g=a.URL||a.webkitURL||null,T=u.toString();return o.BLOB_URL||(o.BLOB_URL=g.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",T,")();"],{type:"text/javascript"})))})(),(p=new a.Worker(p)).onmessage=st,p.id=j++,b[p.id]=p)})()).userStep=n.step,i.userChunk=n.chunk,i.userComplete=n.complete,i.userError=n.error,n.step=y(n.step),n.chunk=y(n.chunk),n.complete=y(n.complete),n.error=y(n.error),delete n.worker,i.postMessage({input:e,config:n,workerId:i.id})},o.unparse=function(e,n){var i=!1,p=!0,g=",",T=`\r
44
- `,X='"',lt=X+X,ht=!1,C=null,G=!1,x=((()=>{if(typeof n=="object"){if(typeof n.delimiter!="string"||o.BAD_DELIMITERS.filter(function(N){return n.delimiter.indexOf(N)!==-1}).length||(g=n.delimiter),typeof n.quotes!="boolean"&&typeof n.quotes!="function"&&!Array.isArray(n.quotes)||(i=n.quotes),typeof n.skipEmptyLines!="boolean"&&typeof n.skipEmptyLines!="string"||(ht=n.skipEmptyLines),typeof n.newline=="string"&&(T=n.newline),typeof n.quoteChar=="string"&&(X=n.quoteChar),typeof n.header=="boolean"&&(p=n.header),Array.isArray(n.columns)){if(n.columns.length===0)throw new Error("Option columns is empty");C=n.columns}n.escapeChar!==void 0&&(lt=n.escapeChar+X),n.escapeFormulae instanceof RegExp?G=n.escapeFormulae:typeof n.escapeFormulae=="boolean"&&n.escapeFormulae&&(G=/^[=+\-@\t\r].*$/)}})(),new RegExp(F(X),"g"));if(typeof e=="string"&&(e=JSON.parse(e)),Array.isArray(e)){if(!e.length||Array.isArray(e[0]))return rt(null,e,ht);if(typeof e[0]=="object")return rt(C||Object.keys(e[0]),e,ht)}else if(typeof e=="object")return typeof e.data=="string"&&(e.data=JSON.parse(e.data)),Array.isArray(e.data)&&(e.fields||(e.fields=e.meta&&e.meta.fields||C),e.fields||(e.fields=Array.isArray(e.data[0])?e.fields:typeof e.data[0]=="object"?Object.keys(e.data[0]):[]),Array.isArray(e.data[0])||typeof e.data[0]=="object"||(e.data=[e.data])),rt(e.fields||[],e.data||[],ht);throw new Error("Unable to serialize unrecognized input");function rt(N,v,q){var Q="",et=(typeof N=="string"&&(N=JSON.parse(N)),typeof v=="string"&&(v=JSON.parse(v)),Array.isArray(N)&&0<N.length),dt=!Array.isArray(v[0]);if(et&&p){for(var D=0;D<N.length;D++)0<D&&(Q+=g),Q+=E(N[D],D);0<v.length&&(Q+=T)}for(var I=0;I<v.length;I++){var V=(et?N:v[I]).length,k=!1,H=et?Object.keys(v[I]).length===0:v[I].length===0;if(q&&!et&&(k=q==="greedy"?v[I].join("").trim()==="":v[I].length===1&&v[I][0].length===0),q==="greedy"&&et){for(var tt=[],W=0;W<V;W++){var Y=dt?N[W]:W;tt.push(v[I][Y])}k=tt.join("").trim()===""}if(!k){for(var M=0;M<V;M++){0<M&&!H&&(Q+=g);var pt=et&&dt?N[M]:M;Q+=E(v[I][pt],M)}I<v.length-1&&(!q||0<V&&!H)&&(Q+=T)}}return Q}function E(N,v){var q,Q;return N==null?"":N.constructor===Date?JSON.stringify(N).slice(1,25):(Q=!1,G&&typeof N=="string"&&G.test(N)&&(N="'"+N,Q=!0),q=N.toString().replace(x,lt),(Q=Q||i===!0||typeof i=="function"&&i(N,v)||Array.isArray(i)&&i[v]||((et,dt)=>{for(var D=0;D<dt.length;D++)if(-1<et.indexOf(dt[D]))return!0;return!1})(q,o.BAD_DELIMITERS)||-1<q.indexOf(g)||q.charAt(0)===" "||q.charAt(q.length-1)===" ")?X+q+X:q)}},o.RECORD_SEP="",o.UNIT_SEP="",o.BYTE_ORDER_MARK="\uFEFF",o.BAD_DELIMITERS=["\r",`
45
- `,'"',o.BYTE_ORDER_MARK],o.WORKERS_SUPPORTED=!f&&!!a.Worker,o.NODE_STREAM_INPUT=1,o.LocalChunkSize=10485760,o.RemoteChunkSize=5242880,o.DefaultDelimiter=",",o.Parser=Z,o.ParserHandle=J,o.NetworkStreamer=A,o.FileStreamer=L,o.StringStreamer=z,o.ReadableStreamStreamer=P,a.jQuery&&((d=a.jQuery).fn.parse=function(e){var n=e.config||{},i=[];return this.each(function(T){if(!(d(this).prop("tagName").toUpperCase()==="INPUT"&&d(this).attr("type").toLowerCase()==="file"&&a.FileReader)||!this.files||this.files.length===0)return!0;for(var X=0;X<this.files.length;X++)i.push({file:this.files[X],inputElem:this,instanceConfig:d.extend({},n)})}),p(),this;function p(){if(i.length===0)y(e.complete)&&e.complete();else{var T,X,lt,ht,C=i[0];if(y(e.before)){var G=e.before(C.file,C.inputElem);if(typeof G=="object"){if(G.action==="abort")return T="AbortError",X=C.file,lt=C.inputElem,ht=G.reason,void(y(e.error)&&e.error({name:T},X,lt,ht));if(G.action==="skip")return void g();typeof G.config=="object"&&(C.instanceConfig=d.extend(C.instanceConfig,G.config))}else if(G==="skip")return void g()}var x=C.instanceConfig.complete;C.instanceConfig.complete=function(rt){y(x)&&x(rt,C.file,C.inputElem),g()},o.parse(C.file,C.instanceConfig)}}function g(){i.splice(0,1),p()}}),h&&(a.onmessage=function(e){e=e.data,o.WORKER_ID===void 0&&e&&(o.WORKER_ID=e.workerId),typeof e.input=="string"?a.postMessage({workerId:o.WORKER_ID,results:o.parse(e.input,e.config),finished:!0}):(a.File&&e.input instanceof File||e.input instanceof Object)&&(e=o.parse(e.input,e.config))&&a.postMessage({workerId:o.WORKER_ID,results:e,finished:!0})}),(A.prototype=Object.create(S.prototype)).constructor=A,(L.prototype=Object.create(S.prototype)).constructor=L,(z.prototype=Object.create(z.prototype)).constructor=z,(P.prototype=Object.create(S.prototype)).constructor=P,o})}(St)),St.exports}var Kt=Ht();const qt=It(Kt);let Pt=[];const Rt=async s=>{const a=await(await fetch(s)).body.getReader().read(),f=new TextDecoder("utf-8").decode(a.value),{data:h}=qt.parse(f,{header:!0,dynamicTyping:!0,delimiter:";"});return h},Vt=(s="/translate.csv")=>(async(r="/translate.csv")=>{Pt=await Rt(r)})(s),ft=(s,r,u=[],a="/translate.csv")=>{const[d,f]=U.useState([]);U.useEffect(()=>{Rt(a).then(f),Vt(a)},[r]);const h=d.find(b=>b.code===s)??Pt.find(b=>b.code===s);try{const b=h[r];return u.reduce((o,S,A)=>o.replace(`{${A}}`,S),b)}catch{return}},Gt=async(s,r,u=[],a="/translate.csv")=>{const f=(await Rt(a)).find(h=>h.code===s);try{const h=f[r];return u.reduce((b,j,o)=>b.replace(`{${o}}`,j),h)}catch{return""}},Xt=(s="/translate.csv")=>{const[r,u]=U.useState(new Map);return U.useEffect(()=>{(async()=>{const f=(await Rt(s)).find(h=>h.code==="lan");if(f){delete f.code;const h=new Map(Object.entries(f));u(h)}})()},[]),r},Qt=({species:s,language:r,open:u,onClose:a,saveSpecies:d,createDescendant:f,createAncestor:h,deleteAncestor:b,deleteSpecies:j})=>{const[o,S]=U.useState(s.name),[A,L]=U.useState(s.apparition),[z,P]=U.useState(s.duration),[J,F]=U.useState(s.description??""),[Z,st]=U.useState(!1),[nt,ut]=U.useState(!1),[ot,$]=U.useState(s.image??""),y=()=>{st(!Z)},e=()=>{ut(!nt)},n=i=>i.ancestor?i.ancestor.descendants.length===1&&n(i.ancestor):!0;return c.jsx(te,{open:u,onClose:a,children:c.jsx("form",{style:{backgroundColor:"grey"},className:"flex flex-col text-start w-auto fixed p-2.5",children:c.jsxs(Ot,{name:o,setName:S,apparition:A,setApparition:i=>{L(s.ancestor?Jt(i,s.ancestor.apparition,s.ancestor.extinction()):i),P(s.descendants.length>0?Math.max(Math.max(...s.descendants.map(p=>p.apparition))-A,z):z)},minApparition:s.ancestor?s.ancestor.apparition:void 0,maxApparition:s.ancestor?s.ancestor.extinction():void 0,duration:z,setDuration:P,minDuration:s.descendants.length>0?Math.max(...s.descendants.map(i=>i.apparition))-A:void 0,maxDuration:s.descendants.length>0?Math.max(...s.descendants.map(i=>i.apparition))-A:void 0,description:J,setDescription:F,image:ot,setImage:$,language:r,children:[c.jsx("button",{onClick:async()=>{try{await(d==null?void 0:d(s,o,A,z,J,ot)),a==null||a()}catch(i){console.error(i)}},children:ft("spbtn00",r??"")}),c.jsx("button",{type:"button",onClick:j,children:ft("spbtn01",r??"")}),c.jsx("button",{type:"button",onClick:y,children:ft("spbtn02",r??"")}),Z&&c.jsx(Zt,{species:s,language:r,onClose:a,createDescendant:f}),s.ancestor?n(s)&&c.jsx("button",{type:"button",onClick:async()=>{try{await(b==null?void 0:b()),a==null||a()}catch(i){console.error(i)}},children:ft("spbtn04"+(s.ancestor.ancestor?"_0":""),r??"")}):c.jsx("button",{type:"button",onClick:e,children:ft("spbtn03",r??"")}),nt&&c.jsx($t,{species:s,language:r,onClose:a,createAncestor:h}),c.jsx("button",{type:"button",onClick:a,children:ft("spbtn05",r??"")})]})})})},Ot=({name:s,setName:r,apparition:u,setApparition:a,minApparition:d,maxApparition:f,duration:h,setDuration:b,minDuration:j,maxDuration:o,description:S,setDescription:A,language:L,image:z,setImage:P,children:J})=>c.jsxs(c.Fragment,{children:[c.jsx("table",{children:c.jsxs("tbody",{children:[c.jsxs("tr",{children:[c.jsxs("td",{children:[ft("splbl00",L??""),":"]}),c.jsx("td",{children:c.jsx("input",{type:"text",value:s,onChange:F=>r(F.target.value)})})]}),c.jsxs("tr",{children:[c.jsxs("td",{children:[ft("splbl01",L??""),":"]}),c.jsx("td",{children:c.jsx("input",{type:"number",min:d,max:f,value:u,onChange:F=>a(Number(F.target.value))})})]}),c.jsxs("tr",{children:[c.jsxs("td",{children:[ft("splbl02",L??""),":"]}),c.jsx("td",{children:c.jsx("input",{type:"number",min:j,max:o,value:h,onChange:F=>b(Number(F.target.value))})})]}),c.jsxs("tr",{children:[c.jsxs("td",{children:[ft("splbl03",L??""),":"]}),c.jsx("td",{children:c.jsx("textarea",{value:S,onChange:F=>A(F.target.value)})})]}),c.jsxs("tr",{children:[c.jsxs("td",{children:[ft("splbl04",L??""),":"]}),c.jsx("td",{children:c.jsx("input",{type:"text",value:z,onChange:F=>P(F.target.value)})})]}),c.jsx("tr",{children:c.jsx("td",{colSpan:2,children:c.jsx("img",{src:z,style:{height:"100px"}})})})]})}),J]}),Zt=({species:s,language:r,onClose:u,createDescendant:a})=>{const[d,f]=U.useState(""),[h,b]=U.useState(s.duration),[j,o]=U.useState(s.duration),[S,A]=U.useState(""),[L,z]=U.useState("");return c.jsx(c.Fragment,{children:c.jsx(Ot,{name:d,setName:f,apparition:s.apparition+h,setApparition:P=>b(P-s.apparition),minApparition:s.apparition,maxApparition:s.extinction(),duration:j,setDuration:o,description:S,setDescription:A,image:L,setImage:z,language:r,children:c.jsx("button",{type:"button",onClick:async()=>{try{await(a==null?void 0:a(s,d,h,j,S,L)),u==null||u()}catch(P){console.error(P)}},children:ft("cdbtn00",r??"")})})})},$t=({species:s,language:r,onClose:u,createAncestor:a})=>{const[d,f]=U.useState(""),[h,b]=U.useState(s.duration),[j,o]=U.useState(s.duration),[S,A]=U.useState(""),[L,z]=U.useState("");return c.jsx(c.Fragment,{children:c.jsx(Ot,{name:d,setName:f,apparition:s.apparition-h,setApparition:P=>{b(s.apparition-P),o(Math.max(s.apparition-P,j))},maxApparition:s.apparition,duration:j,setDuration:o,minDuration:h,description:S,setDescription:A,image:L,setImage:z,language:r,children:c.jsx("button",{type:"button",onClick:async()=>{try{await(a==null?void 0:a(s,d,h,j,S,L)),u==null||u()}catch(P){console.error(P)}},children:ft("cdbtn00",r??"")})})})},te=({open:s,onClose:r,children:u})=>c.jsx("div",{style:{backgroundColor:s?"rgba(0, 0, 0, 0.2)":"rgba(0, 0, 0, 0)"},className:`flex fixed inset-0 justify-center items-center transition-colors duration-300 ease-in-out ${s?"visible":"hidden"}`,onClick:r,children:c.jsx("div",{onClick:a=>a.stopPropagation(),className:"flex justify-center items-center",children:u})});vt.Menu=Qt,vt.MultiplePhTrees=Wt,vt.PhTree=Dt,vt.Species=xt,vt.codeText=ft,vt.codeTextAlt=Gt,vt.getLanguageOptions=Xt,Object.defineProperty(vt,Symbol.toStringTag,{value:"Module"})});
13
+ `);var y=0,Y=!1;this.parse=function(w,D,p){if(typeof w!="string")throw new Error("Input must be a string");var W=w.length,B=e.length,G=i.length,ot=h.length,O=g(l),L=[],z=[],b=[],$=y=0;if(!w)return tt();if(J||J!==!1&&w.indexOf(S)===-1){for(var K=w.split(i),N=0;N<K.length;N++){if(b=K[N],y+=b.length,N!==K.length-1)y+=i.length;else if(p)return tt();if(!h||b.substring(0,ot)!==h){if(O){if(L=[],gt(b.split(e)),lt(),Y)return tt()}else gt(b.split(e));if(x&&x<=N)return L=L.slice(0,x),tt(!0)}}return tt()}for(var j=w.indexOf(e,y),A=w.indexOf(i,y),dt=new RegExp(F(q)+F(S),"g"),k=w.indexOf(S,y);;)if(w[y]===S)for(k=y,y++;;){if((k=w.indexOf(S,k+1))===-1)return p||z.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:L.length,index:y}),ht();if(k===W-1)return ht(w.substring(y,k).replace(dt,S));if(S===q&&w[k+1]===q)k++;else if(S===q||k===0||w[k-1]!==q){j!==-1&&j<k+1&&(j=w.indexOf(e,k+1));var U=_t((A=A!==-1&&A<k+1?w.indexOf(i,k+1):A)===-1?j:Math.min(j,A));if(w.substr(k+1+U,B)===e){b.push(w.substring(y,k).replace(dt,S)),w[y=k+1+U+B]!==S&&(k=w.indexOf(S,y)),j=w.indexOf(e,y),A=w.indexOf(i,y);break}if(U=_t(A),w.substring(k+1+U,k+1+U+G)===i){if(b.push(w.substring(y,k).replace(dt,S)),bt(k+1+U+G),j=w.indexOf(e,y),k=w.indexOf(S,y),O&&(lt(),Y))return tt();if(x&&L.length>=x)return tt(!0);break}z.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:L.length,index:y}),k++}}else if(h&&b.length===0&&w.substring(y,y+ot)===h){if(A===-1)return tt();y=A+G,A=w.indexOf(i,y),j=w.indexOf(e,y)}else if(j!==-1&&(j<A||A===-1))b.push(w.substring(y,j)),y=j+B,j=w.indexOf(e,y);else{if(A===-1)break;if(b.push(w.substring(y,A)),bt(A+G),O&&(lt(),Y))return tt();if(x&&L.length>=x)return tt(!0)}return ht();function gt(X){L.push(X),$=y}function _t(X){var it=0;return it=X!==-1&&(X=w.substring(k+1,X))&&X.trim()===""?X.length:it}function ht(X){return p||(X===void 0&&(X=w.substring(y)),b.push(X),y=W,gt(b),O&&lt()),tt()}function bt(X){y=X,gt(b),b=[],A=w.indexOf(i,y)}function tt(X){if(t.header&&!D&&L.length&&!at){var it=L[0],ct={},xt=new Set(it);let At=!1;for(let yt=0;yt<it.length;yt++){let ut=it[yt];if(ct[ut=g(t.transformHeader)?t.transformHeader(ut,yt):ut]){let vt,Ct=ct[ut];for(;vt=ut+"_"+Ct,Ct++,xt.has(vt););xt.add(vt),it[yt]=vt,ct[ut]++,At=!0,(st=st===null?{}:st)[vt]=ut}else ct[ut]=1,it[yt]=ut;xt.add(ut)}At&&console.warn("Duplicate headers found and renamed."),at=!0}return{data:L,errors:z,meta:{delimiter:e,linebreak:i,aborted:Y,truncated:!!X,cursor:$+(D||0),renamedHeaders:st}}}function lt(){l(tt()),L=[],z=[]}},this.abort=function(){Y=!0},this.getCharIndex=function(){return y}}function V(t){var e=t.data,i=_[e.workerId],h=!1;if(e.error)i.userError(e.error,e.file);else if(e.results&&e.results.data){var l={abort:function(){h=!0,Z(e.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:rt,resume:rt};if(g(i.userStep)){for(var x=0;x<e.results.data.length&&(i.userStep({data:e.results.data[x],errors:e.results.errors,meta:e.results.meta},l),!h);x++);delete e.results}else g(i.userChunk)&&(i.userChunk(e.results,l,e.file),delete e.results)}e.finished&&!h&&Z(e.workerId,e.results)}function Z(t,e){var i=_[t];g(i.userComplete)&&i.userComplete(e),i.terminate(),delete _[t]}function rt(){throw new Error("Not implemented.")}function et(t){if(typeof t!="object"||t===null)return t;var e,i=Array.isArray(t)?[]:{};for(e in t)i[e]=et(t[e]);return i}function Q(t,e){return function(){t.apply(e,arguments)}}function g(t){return typeof t=="function"}return a.parse=function(t,e){var i=(e=e||{}).dynamicTyping||!1;if(g(i)&&(e.dynamicTypingFunction=i,i={}),e.dynamicTyping=i,e.transform=!!g(e.transform)&&e.transform,!e.worker||!a.WORKERS_SUPPORTED)return i=null,a.NODE_STREAM_INPUT,typeof t=="string"?(t=(h=>h.charCodeAt(0)!==65279?h:h.slice(1))(t),i=new(e.download?E:I)(e)):t.readable===!0&&g(t.read)&&g(t.on)?i=new T(e):(s.File&&t instanceof File||t instanceof Object)&&(i=new C(e)),i.stream(t);(i=(()=>{var h;return!!a.WORKERS_SUPPORTED&&(h=(()=>{var l=s.URL||s.webkitURL||null,x=o.toString();return a.BLOB_URL||(a.BLOB_URL=l.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",x,")();"],{type:"text/javascript"})))})(),(h=new s.Worker(h)).onmessage=V,h.id=m++,_[h.id]=h)})()).userStep=e.step,i.userChunk=e.chunk,i.userComplete=e.complete,i.userError=e.error,e.step=g(e.step),e.chunk=g(e.chunk),e.complete=g(e.complete),e.error=g(e.error),delete e.worker,i.postMessage({input:t,config:e,workerId:i.id})},a.unparse=function(t,e){var i=!1,h=!0,l=",",x=`\r
14
+ `,J='"',st=J+J,at=!1,S=null,q=!1,y=((()=>{if(typeof e=="object"){if(typeof e.delimiter!="string"||a.BAD_DELIMITERS.filter(function(D){return e.delimiter.indexOf(D)!==-1}).length||(l=e.delimiter),typeof e.quotes!="boolean"&&typeof e.quotes!="function"&&!Array.isArray(e.quotes)||(i=e.quotes),typeof e.skipEmptyLines!="boolean"&&typeof e.skipEmptyLines!="string"||(at=e.skipEmptyLines),typeof e.newline=="string"&&(x=e.newline),typeof e.quoteChar=="string"&&(J=e.quoteChar),typeof e.header=="boolean"&&(h=e.header),Array.isArray(e.columns)){if(e.columns.length===0)throw new Error("Option columns is empty");S=e.columns}e.escapeChar!==void 0&&(st=e.escapeChar+J),e.escapeFormulae instanceof RegExp?q=e.escapeFormulae:typeof e.escapeFormulae=="boolean"&&e.escapeFormulae&&(q=/^[=+\-@\t\r].*$/)}})(),new RegExp(F(J),"g"));if(typeof t=="string"&&(t=JSON.parse(t)),Array.isArray(t)){if(!t.length||Array.isArray(t[0]))return Y(null,t,at);if(typeof t[0]=="object")return Y(S||Object.keys(t[0]),t,at)}else if(typeof t=="object")return typeof t.data=="string"&&(t.data=JSON.parse(t.data)),Array.isArray(t.data)&&(t.fields||(t.fields=t.meta&&t.meta.fields||S),t.fields||(t.fields=Array.isArray(t.data[0])?t.fields:typeof t.data[0]=="object"?Object.keys(t.data[0]):[]),Array.isArray(t.data[0])||typeof t.data[0]=="object"||(t.data=[t.data])),Y(t.fields||[],t.data||[],at);throw new Error("Unable to serialize unrecognized input");function Y(D,p,W){var B="",G=(typeof D=="string"&&(D=JSON.parse(D)),typeof p=="string"&&(p=JSON.parse(p)),Array.isArray(D)&&0<D.length),ot=!Array.isArray(p[0]);if(G&&h){for(var O=0;O<D.length;O++)0<O&&(B+=l),B+=w(D[O],O);0<p.length&&(B+=x)}for(var L=0;L<p.length;L++){var z=(G?D:p[L]).length,b=!1,$=G?Object.keys(p[L]).length===0:p[L].length===0;if(W&&!G&&(b=W==="greedy"?p[L].join("").trim()==="":p[L].length===1&&p[L][0].length===0),W==="greedy"&&G){for(var K=[],N=0;N<z;N++){var j=ot?D[N]:N;K.push(p[L][j])}b=K.join("").trim()===""}if(!b){for(var A=0;A<z;A++){0<A&&!$&&(B+=l);var dt=G&&ot?D[A]:A;B+=w(p[L][dt],A)}L<p.length-1&&(!W||0<z&&!$)&&(B+=x)}}return B}function w(D,p){var W,B;return D==null?"":D.constructor===Date?JSON.stringify(D).slice(1,25):(B=!1,q&&typeof D=="string"&&q.test(D)&&(D="'"+D,B=!0),W=D.toString().replace(y,st),(B=B||i===!0||typeof i=="function"&&i(D,p)||Array.isArray(i)&&i[p]||((G,ot)=>{for(var O=0;O<ot.length;O++)if(-1<G.indexOf(ot[O]))return!0;return!1})(W,a.BAD_DELIMITERS)||-1<W.indexOf(l)||W.charAt(0)===" "||W.charAt(W.length-1)===" ")?J+W+J:W)}},a.RECORD_SEP="",a.UNIT_SEP="",a.BYTE_ORDER_MARK="\uFEFF",a.BAD_DELIMITERS=["\r",`
15
+ `,'"',a.BYTE_ORDER_MARK],a.WORKERS_SUPPORTED=!f&&!!s.Worker,a.NODE_STREAM_INPUT=1,a.LocalChunkSize=10485760,a.RemoteChunkSize=5242880,a.DefaultDelimiter=",",a.Parser=H,a.ParserHandle=P,a.NetworkStreamer=E,a.FileStreamer=C,a.StringStreamer=I,a.ReadableStreamStreamer=T,s.jQuery&&((u=s.jQuery).fn.parse=function(t){var e=t.config||{},i=[];return this.each(function(x){if(!(u(this).prop("tagName").toUpperCase()==="INPUT"&&u(this).attr("type").toLowerCase()==="file"&&s.FileReader)||!this.files||this.files.length===0)return!0;for(var J=0;J<this.files.length;J++)i.push({file:this.files[J],inputElem:this,instanceConfig:u.extend({},e)})}),h(),this;function h(){if(i.length===0)g(t.complete)&&t.complete();else{var x,J,st,at,S=i[0];if(g(t.before)){var q=t.before(S.file,S.inputElem);if(typeof q=="object"){if(q.action==="abort")return x="AbortError",J=S.file,st=S.inputElem,at=q.reason,void(g(t.error)&&t.error({name:x},J,st,at));if(q.action==="skip")return void l();typeof q.config=="object"&&(S.instanceConfig=u.extend(S.instanceConfig,q.config))}else if(q==="skip")return void l()}var y=S.instanceConfig.complete;S.instanceConfig.complete=function(Y){g(y)&&y(Y,S.file,S.inputElem),l()},a.parse(S.file,S.instanceConfig)}}function l(){i.splice(0,1),h()}}),c&&(s.onmessage=function(t){t=t.data,a.WORKER_ID===void 0&&t&&(a.WORKER_ID=t.workerId),typeof t.input=="string"?s.postMessage({workerId:a.WORKER_ID,results:a.parse(t.input,t.config),finished:!0}):(s.File&&t.input instanceof File||t.input instanceof Object)&&(t=a.parse(t.input,t.config))&&s.postMessage({workerId:a.WORKER_ID,results:t,finished:!0})}),(E.prototype=Object.create(v.prototype)).constructor=E,(C.prototype=Object.create(v.prototype)).constructor=C,(I.prototype=Object.create(I.prototype)).constructor=I,(T.prototype=Object.create(v.prototype)).constructor=T,a})}(mt)),mt.exports}var Pt=jt();const Ut=Ft(Pt);let Ot=[];const wt=async r=>{const s=await(await fetch(r)).body.getReader().read(),f=new TextDecoder("utf-8").decode(s.value),{data:c}=Ut.parse(f,{header:!0,dynamicTyping:!0,delimiter:";"});return c},qt=(r="/translate.csv")=>(async(n="/translate.csv")=>{Ot=await wt(n)})(r),nt=(r,n,o=[],s="/translate.csv")=>{const[u,f]=M.useState([]);M.useEffect(()=>{wt(s).then(f),qt(s)},[n]);const c=u.find(_=>_.code===r)??Ot.find(_=>_.code===r);try{const _=c[n];return o.reduce((a,v,E)=>a.replace(`{${E}}`,v),_)}catch{return}},zt=async(r,n,o=[],s="/translate.csv")=>{const f=(await wt(s)).find(c=>c.code===r);try{const c=f[n];return o.reduce((_,m,a)=>_.replace(`{${a}}`,m),c)}catch{return""}},$t=(r="/translate.csv")=>{const[n,o]=M.useState(new Map);return M.useEffect(()=>{(async()=>{const f=(await wt(r)).find(c=>c.code==="lan");if(f){delete f.code;const c=new Map(Object.entries(f));o(c)}})()},[]),n},Rt=({species:r,language:n,open:o,onClose:s,saveSpecies:u,createDescendant:f,createAncestor:c,deleteAncestor:_,deleteSpecies:m})=>{const[a,v]=M.useState(r.name),[E,C]=M.useState(r.apparition),[I,T]=M.useState(r.duration),[P,F]=M.useState(r.description??""),[H,V]=M.useState(!1),[Z,rt]=M.useState(!1),[et,Q]=M.useState(r.image??""),g=()=>{V(!H)},t=()=>{rt(!Z)},e=i=>i.ancestor?i.ancestor.descendants.length===1&&e(i.ancestor):!0;return d.jsx(Jt,{open:o,onClose:s,children:d.jsx("form",{style:{backgroundColor:"grey"},className:"flex flex-col text-start w-auto fixed p-2.5",children:d.jsxs(kt,{name:a,setName:v,apparition:E,setApparition:i=>{C(r.ancestor?It(i,r.ancestor.apparition,r.ancestor.extinction()):i),T(r.descendants.length>0?Math.max(Math.max(...r.descendants.map(h=>h.apparition))-E,I):I)},minApparition:r.ancestor?r.ancestor.apparition:void 0,maxApparition:r.ancestor?r.ancestor.extinction():void 0,duration:I,setDuration:T,minDuration:r.descendants.length>0?Math.max(...r.descendants.map(i=>i.apparition))-E:void 0,maxDuration:r.descendants.length>0?Math.max(...r.descendants.map(i=>i.apparition))-E:void 0,description:P,setDescription:F,image:et,setImage:Q,language:n,children:[d.jsx("button",{onClick:async()=>{try{await(u==null?void 0:u(r,a,E,I,P,et)),s==null||s()}catch(i){console.error(i)}},children:nt("spbtn00",n??"")}),d.jsx("button",{type:"button",onClick:m,children:nt("spbtn01",n??"")}),d.jsx("button",{type:"button",onClick:g,children:nt("spbtn02",n??"")}),H&&d.jsx(Bt,{species:r,language:n,onClose:s,createDescendant:f}),r.ancestor?e(r)&&d.jsx("button",{type:"button",onClick:async()=>{try{await(_==null?void 0:_()),s==null||s()}catch(i){console.error(i)}},children:nt("spbtn04"+(r.ancestor.ancestor?"_0":""),n??"")}):d.jsx("button",{type:"button",onClick:t,children:nt("spbtn03",n??"")}),Z&&d.jsx(Ht,{species:r,language:n,onClose:s,createAncestor:c}),d.jsx("button",{type:"button",onClick:s,children:nt("spbtn05",n??"")})]})})})},kt=({name:r,setName:n,apparition:o,setApparition:s,minApparition:u,maxApparition:f,duration:c,setDuration:_,minDuration:m,maxDuration:a,description:v,setDescription:E,language:C,image:I,setImage:T,children:P})=>d.jsxs(d.Fragment,{children:[d.jsx("table",{children:d.jsxs("tbody",{children:[d.jsxs("tr",{children:[d.jsxs("td",{children:[nt("splbl00",C??""),":"]}),d.jsx("td",{children:d.jsx("input",{type:"text",value:r,onChange:F=>n(F.target.value)})})]}),d.jsxs("tr",{children:[d.jsxs("td",{children:[nt("splbl01",C??""),":"]}),d.jsx("td",{children:d.jsx("input",{type:"number",min:u,max:f,value:o,onChange:F=>s(Number(F.target.value))})})]}),d.jsxs("tr",{children:[d.jsxs("td",{children:[nt("splbl02",C??""),":"]}),d.jsx("td",{children:d.jsx("input",{type:"number",min:m,max:a,value:c,onChange:F=>_(Number(F.target.value))})})]}),d.jsxs("tr",{children:[d.jsxs("td",{children:[nt("splbl03",C??""),":"]}),d.jsx("td",{children:d.jsx("textarea",{value:v,onChange:F=>E(F.target.value)})})]}),d.jsxs("tr",{children:[d.jsxs("td",{children:[nt("splbl04",C??""),":"]}),d.jsx("td",{children:d.jsx("input",{type:"text",value:I,onChange:F=>T(F.target.value)})})]}),d.jsx("tr",{children:d.jsx("td",{colSpan:2,children:d.jsx("img",{src:I,style:{height:"100px"}})})})]})}),P]}),Bt=({species:r,language:n,onClose:o,createDescendant:s})=>{const[u,f]=M.useState(""),[c,_]=M.useState(r.duration),[m,a]=M.useState(r.duration),[v,E]=M.useState(""),[C,I]=M.useState("");return d.jsx(d.Fragment,{children:d.jsx(kt,{name:u,setName:f,apparition:r.apparition+c,setApparition:T=>_(T-r.apparition),minApparition:r.apparition,maxApparition:r.extinction(),duration:m,setDuration:a,description:v,setDescription:E,image:C,setImage:I,language:n,children:d.jsx("button",{type:"button",onClick:async()=>{try{await(s==null?void 0:s(r,u,c,m,v,C)),o==null||o()}catch(T){console.error(T)}},children:nt("cdbtn00",n??"")})})})},Ht=({species:r,language:n,onClose:o,createAncestor:s})=>{const[u,f]=M.useState(""),[c,_]=M.useState(r.duration),[m,a]=M.useState(r.duration),[v,E]=M.useState(""),[C,I]=M.useState("");return d.jsx(d.Fragment,{children:d.jsx(kt,{name:u,setName:f,apparition:r.apparition-c,setApparition:T=>{_(r.apparition-T),a(Math.max(r.apparition-T,m))},maxApparition:r.apparition,duration:m,setDuration:a,minDuration:c,description:v,setDescription:E,image:C,setImage:I,language:n,children:d.jsx("button",{type:"button",onClick:async()=>{try{await(s==null?void 0:s(r,u,c,m,v,C)),o==null||o()}catch(T){console.error(T)}},children:nt("cdbtn00",n??"")})})})},Jt=({open:r,onClose:n,children:o})=>d.jsx("div",{style:{backgroundColor:r?"rgba(0, 0, 0, 0.2)":"rgba(0, 0, 0, 0)"},className:`flex fixed inset-0 justify-center items-center transition-colors duration-300 ease-in-out ${r?"visible":"hidden"}`,onClick:n,children:d.jsx("div",{onClick:s=>s.stopPropagation(),className:"flex justify-center items-center",children:o})});R.Menu=Rt,R.MultiplePhTrees=Mt,R.PhTree=Et,R.Species=pt,R.codeText=nt,R.codeTextAlt=zt,R.getLanguageOptions=$t,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,34 @@
1
+ import { SpeciesJSON } from '../types';
2
+ export declare class Species {
3
+ name: string;
4
+ apparition: number;
5
+ duration: number;
6
+ ancestor?: Species;
7
+ descendants: Species[];
8
+ description?: string;
9
+ display: boolean;
10
+ image?: string;
11
+ private onPosition;
12
+ constructor(name?: string, apparition?: number, duration?: number, ancestor?: Species | undefined, descendants?: Species[], description?: string | undefined, image?: string | undefined);
13
+ copy(): Species;
14
+ unlinkAncestor(): [Species, Species] | undefined;
15
+ unlinkDescendant(descendant: Species): [Species, Species] | undefined;
16
+ linkAncestor(ancestor: Species): void;
17
+ linkDescendant(descendant: Species): void;
18
+ linkDescendants(descendants: Species[]): void;
19
+ addDescendant(name?: string, afterApparition?: number, duration?: number, description?: string | undefined, image?: string | undefined, copy?: boolean): Species;
20
+ removeDescendant(desc: Species): void;
21
+ addAncestor(name?: string, previousApparition?: number, duration?: number, description?: string | undefined, image?: string | undefined, display?: boolean, copy?: boolean): Species;
22
+ extinction(): number;
23
+ absoluteExtinction(): number;
24
+ absoluteDuration(): number;
25
+ firstAncestor(includeNotDisplay?: boolean): Species;
26
+ cousinsExtinction(): number;
27
+ allDescendants(sort?: boolean): Species[];
28
+ stepsChain(desc: Species, includeNotDisplay?: boolean): Species[];
29
+ stepsUntil(desc: Species, includeNotDisplay?: boolean): number | undefined;
30
+ stepsUntilLastDescendant(icludeNotDisplay?: boolean): number;
31
+ toJSON(): SpeciesJSON;
32
+ saveJSON(filename?: string | undefined): Promise<void>;
33
+ static fromJSON(json: SpeciesJSON, ancestor?: Species): Species;
34
+ }
@@ -0,0 +1,14 @@
1
+ import { Species } from '../classes/Species';
2
+ export declare const HoverDescription: ({ hoverPosition, hoverSpecies, offset }: HoverDescriptionProps) => import("react/jsx-runtime").JSX.Element;
3
+ interface HoverDescriptionProps {
4
+ hoverPosition: {
5
+ x: number;
6
+ y: number;
7
+ };
8
+ hoverSpecies: Species;
9
+ offset?: {
10
+ x: number;
11
+ y: number;
12
+ };
13
+ }
14
+ export {};
@@ -0,0 +1,8 @@
1
+ export declare const LanguageSelector: ({ className, languages, language, setLanguage }: LanguageSelectorProps) => import("react/jsx-runtime").JSX.Element;
2
+ interface LanguageSelectorProps {
3
+ className?: string;
4
+ languages: Map<string, string>;
5
+ language: string;
6
+ setLanguage: (language: string) => void;
7
+ }
8
+ export {};
@@ -0,0 +1,14 @@
1
+ import { Species } from '../classes/Species';
2
+ interface MenuProps {
3
+ species: Species;
4
+ language?: string;
5
+ open?: boolean;
6
+ onClose?: () => void;
7
+ saveSpecies?: (s: Species, name: string, apparition: number, duration: number, description: string, image: string) => Promise<void>;
8
+ createDescendant?: (s: Species, name: string, afterApparition: number, duration: number, description: string, image: string) => Promise<void>;
9
+ createAncestor?: (s: Species, name: string, previousApparition: number, duration: number, description: string, image: string) => Promise<void>;
10
+ deleteAncestor?: () => Promise<void>;
11
+ deleteSpecies?: () => Promise<void>;
12
+ }
13
+ export declare const Menu: ({ species, language, open, onClose, saveSpecies, createDescendant, createAncestor, deleteAncestor, deleteSpecies }: MenuProps) => import("react/jsx-runtime").JSX.Element;
14
+ export {};
@@ -0,0 +1,32 @@
1
+ import { Species } from '../classes/Species';
2
+ export declare const NavBar: ({ species, color, lineColor, setLineColor, language, languages, setLanguage, minScale, maxScale, scale, setScale, showScaleNumber, chronoScale, setChronoScale, showHover, setShowHover, showImages, setShowImages, presentTime, presentTimeBoolean, setPresentTimeBoolean, changePresentTime, setFromJson, deleteAllSpecies, createEmptySpecies, showExample }: NavBarProps) => import("react/jsx-runtime").JSX.Element;
3
+ interface NavBarProps {
4
+ species?: Species;
5
+ color: string;
6
+ lineColor: string;
7
+ setLineColor: (lineColor: string) => void;
8
+ language: string;
9
+ languages: Map<string, string>;
10
+ setLanguage: (language: string) => void;
11
+ minScale?: number;
12
+ maxScale: number;
13
+ scale: number;
14
+ setScale: (scale: number) => void;
15
+ showScaleNumber: boolean;
16
+ chronoScale: boolean;
17
+ setChronoScale: (chronoScale: boolean) => void;
18
+ showHover: boolean;
19
+ setShowHover: (showHover: boolean) => void;
20
+ showImages: boolean;
21
+ setShowImages: (showImages: boolean) => void;
22
+ presentTime: number;
23
+ setPresentTime: (presentTime: number) => void;
24
+ presentTimeBoolean: boolean;
25
+ setPresentTimeBoolean: (presentTimeBoolean: boolean) => void;
26
+ changePresentTime: (presentTime: number) => void;
27
+ setFromJson: (file: File | undefined) => Promise<void>;
28
+ deleteAllSpecies: () => void;
29
+ createEmptySpecies: () => Promise<void>;
30
+ showExample: () => void;
31
+ }
32
+ export {};
@@ -0,0 +1,30 @@
1
+ import { Species } from '../classes/Species';
2
+ interface MultiplePhTreesProps {
3
+ speciesList: Species[];
4
+ width?: number;
5
+ height?: number;
6
+ padding?: number;
7
+ stroke?: string;
8
+ format?: (n: number) => string;
9
+ chronoScale?: boolean;
10
+ showImages?: boolean;
11
+ presentTime?: number;
12
+ handleMouseMove?: (x: number, y: number) => void;
13
+ children?: (species: Species | undefined, showMenu: boolean, toggleShowMenu: (species: Species) => void, hoverSpecies: Species | undefined) => any;
14
+ }
15
+ export declare const MultiplePhTrees: ({ speciesList, width, height, padding, stroke, format, chronoScale, showImages, presentTime, handleMouseMove, children }: MultiplePhTreesProps) => import("react/jsx-runtime").JSX.Element;
16
+ interface PhTreeProps {
17
+ commonAncestor: Species;
18
+ width?: number;
19
+ height?: number;
20
+ padding?: number;
21
+ stroke?: string;
22
+ format?: (n: number) => string;
23
+ chronoScale?: boolean;
24
+ showImages?: boolean;
25
+ presentTime?: number;
26
+ handleMouseMove?: (x: number, y: number) => void;
27
+ children?: (species: Species | undefined, showMenu: boolean, toggleShowMenu: (species: Species) => void, hoverSpecies: Species | undefined) => any;
28
+ }
29
+ export declare const PhTree: ({ commonAncestor, width, height, padding, stroke, format, chronoScale, showImages, presentTime, handleMouseMove, children }: PhTreeProps) => import("react/jsx-runtime").JSX.Element;
30
+ export {};
@@ -0,0 +1,5 @@
1
+ export { Species } from './classes/Species';
2
+ export { PhTree, MultiplePhTrees } from './components/PhTree';
3
+ export { Menu } from './components/Menu';
4
+ export { codeText, codeTextAlt, getLanguageOptions } from './utils/translate';
5
+ export type { SpeciesJSON } from './types';
package/dist/main.d.ts ADDED
File without changes
@@ -0,0 +1 @@
1
+ export declare const between: (n: number, min: number, max: number) => number;
@@ -0,0 +1,2 @@
1
+ import { Species } from '../classes/Species';
2
+ export declare const example: Species;
@@ -0,0 +1 @@
1
+ export declare const hexToRGBA: (hex: string, a: number) => string;
@@ -0,0 +1 @@
1
+ export declare const scientificNotation: (n: number, decimals?: number) => string;
@@ -0,0 +1,2 @@
1
+ import { Species } from '../classes/Species';
2
+ export declare const setFromJson: (setSpecies: (species: Species | undefined) => void, setScale: (scale: number) => void, setPresentTime: (time: number) => void, presentTimeBoolean: boolean) => (file: File | undefined) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ export declare const codeText: (code: string, language: string, arg?: string[], filePath?: string) => string | undefined;
2
+ export declare const codeTextAlt: (code: string, language: string, arg?: string[], filePath?: string) => Promise<string>;
3
+ export declare const getLanguageOptions: (filePath?: string) => Map<string, string>;
@@ -0,0 +1,6 @@
1
+ import { Species } from '../classes/Species';
2
+ export declare const saveSpecies: (setSpecies: (sp?: Species) => void, language: string) => (s: Species, name: string, apparition: number, duration: number, description: string, image: string) => Promise<void>;
3
+ export declare const createDescendant: (setSpecies: (sp?: Species) => void, language: string, presentTimeBoolean: boolean, setPresentTime: (time: number) => void, setScale: (scale: number) => void) => (s: Species, name: string, afterApparition: number, duration: number, description: string, image: string) => Promise<void>;
4
+ export declare const createAncestor: (setSpecies: (sp?: Species) => void, language: string, presentTimeBoolean: boolean, setPresentTime: (time: number) => void, setScale: (scale: number) => void) => (s: Species, name: string, previousApparition: number, duration: number, description: string, image: string) => Promise<void>;
5
+ export declare const deleteAncestor: (sp: Species, setSpecies: (sp?: Species) => void, setScale: (scale: number) => void, language: string) => () => Promise<void>;
6
+ export declare const deleteSpecies: (sp: Species, setSpecies: (sp?: Species) => void, language: string) => () => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrono-phylo-tree",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "description": "A React-based phylogenetic tree visualization library",
5
5
  "type": "module",
6
6
  "main": "./dist/chrono-phylo-tree.umd.js",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "scripts": {
19
19
  "dev": "vite",
20
- "build": "tsc --emitDeclarationOnly --outDir dist && vite build",
20
+ "build": "tsc -b && vite build",
21
21
  "lint": "eslint .",
22
22
  "preview": "vite preview"
23
23
  },
@@ -42,7 +42,8 @@
42
42
  "tsup": "^8.5.0",
43
43
  "typescript": "~5.7.2",
44
44
  "typescript-eslint": "^8.21.0",
45
- "vite": "^6.0.11"
45
+ "vite": "^6.0.11",
46
+ "vite-plugin-dts": "^4.5.4"
46
47
  },
47
48
  "repository": {
48
49
  "type": "git",