chrono-phylo-tree 1.1.9 → 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.
- package/dist/App.d.ts +2 -0
- package/dist/chrono-phylo-tree.es.js +1122 -0
- package/dist/chrono-phylo-tree.umd.js +15 -0
- package/dist/classes/Species.d.ts +34 -0
- package/dist/components/HoverDescription.d.ts +14 -0
- package/dist/components/LanguageSelector.d.ts +8 -0
- package/dist/components/Menu.d.ts +14 -0
- package/dist/components/NavBar.d.ts +32 -0
- package/dist/components/PhTree.d.ts +30 -0
- package/dist/index.d.ts +5 -0
- package/dist/logo.png +0 -0
- package/dist/main.d.ts +0 -0
- package/dist/translate.csv +37 -0
- package/dist/utils/between.d.ts +1 -0
- package/dist/utils/example.d.ts +2 -0
- package/dist/utils/hexToRGBA.d.ts +1 -0
- package/dist/utils/scientificNotation.d.ts +1 -0
- package/dist/utils/setFromJson.d.ts +2 -0
- package/dist/utils/translate.d.ts +3 -0
- package/dist/utils/updateSpecies.d.ts +6 -0
- package/dist/vite.svg +1 -0
- package/package.json +13 -3
- package/src/App.css +0 -131
- package/src/App.tsx +0 -149
- package/src/assets/react.svg +0 -1
- package/src/classes/Species.tsx +0 -267
- package/src/components/HoverDescription.tsx +0 -27
- package/src/components/LanguageSelector.tsx +0 -29
- package/src/components/Menu.tsx +0 -348
- package/src/components/NavBar.tsx +0 -234
- package/src/components/PhTree.tsx +0 -362
- package/src/index.css +0 -68
- package/src/index.ts +0 -4
- package/src/main.tsx +0 -10
- package/src/types.d.ts +0 -9
- package/src/utils/between.tsx +0 -3
- package/src/utils/example.tsx +0 -73
- package/src/utils/hexToRGBA.tsx +0 -12
- package/src/utils/scientificNotation.tsx +0 -20
- package/src/utils/setFromJson.tsx +0 -40
- package/src/utils/translate.tsx +0 -68
- package/src/utils/updateSpecies.tsx +0 -129
- package/src/vite-env.d.ts +0 -1
@@ -0,0 +1,15 @@
|
|
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
|
2
|
+
Papa Parse
|
3
|
+
v5.5.2
|
4
|
+
https://github.com/mholt/PapaParse
|
5
|
+
License: MIT
|
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!==`
|
11
|
+
`&&i!=="\r"&&i!==`\r
|
12
|
+
`&&(i=`
|
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&<()),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 {};
|
package/dist/index.d.ts
ADDED
@@ -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/logo.png
ADDED
Binary file
|
package/dist/main.d.ts
ADDED
File without changes
|
@@ -0,0 +1,37 @@
|
|
1
|
+
code;spanish;english;deutsch
|
2
|
+
lan;Español;English;Deutsch
|
3
|
+
ttl;Árbol Cronofilogenético;Chronophylogenetic Tree;Chronophylogenetischer Baum
|
4
|
+
nvlbl00;Escala;Scale;Skala
|
5
|
+
nvlbl01;Presente;Present;Gegenwart
|
6
|
+
nvlbl02;Color;Color;Farbe
|
7
|
+
nvlbl03;Repositorio;Repository;Entwurfsmuster
|
8
|
+
nvlbl04;Importar JSON;Import JSON;Importiere JSON
|
9
|
+
nvbtn00;Crear especie vacía;Create empty species;Erschaffe leere Spezies
|
10
|
+
nvbtn00_0;Eliminar todas las especies;Delete all species;Lösche alle Spezies
|
11
|
+
nvbtn01;Ejemplo;Example;Beispiel
|
12
|
+
nvbtn02;Descargar JSON;Download JSON;JSON Herunterladen
|
13
|
+
nvlbl05;Idioma;Language;Sprache
|
14
|
+
nvlbl06;Escala Cronológica;Chronological Scale;Chronologische Skala
|
15
|
+
nvlbl07;Mostrar Datos;Display Data;Daten Anzeigen
|
16
|
+
nvlbl08;Mostrar Imágenes;Display Images;Bilder Anzeigen
|
17
|
+
splbl00;Nombre;Name;Name
|
18
|
+
splbl01;Aparición;Apparition;Erscheinung
|
19
|
+
splbl02;Duración;Duration;Dauer
|
20
|
+
splbl03;Descripción;Description;Beschreibung
|
21
|
+
splbl04;Imagen;Image;Bild
|
22
|
+
spbtn00;Guardar;Save;Speichern
|
23
|
+
spbtn01;Eliminar;Delete;Löschen
|
24
|
+
spbtn02;Crear descendiente;Create descendant;Erschaffe Nachkomme
|
25
|
+
spbtn03;Crear ancestro;Create ancestor;Erschaffe Vorfahre
|
26
|
+
spbtn04;Quitar Ancestro;Remove Ancestor;Entferne Vorfahr
|
27
|
+
spbtn04_0;Quitar Ancestros;Remove Ancestors;Lösche Nachkomme
|
28
|
+
spbtn05;Cancelar;Cancel;Abbrechen
|
29
|
+
cdbtn00;Crear;Create;Erschaffe
|
30
|
+
cnfrm00;¿Estás seguro de que deseas quitar al ancestro de {0}?;Are you sure you want to remove the {0}'s ancestor?;Willst du wirklich den {0}ten Vorfahre entfernen?
|
31
|
+
cnfrm00_0;¿Estás seguro de que deseas quitar a los ancestros de {0}?;Are you sure you want to remove the {0}'s ancestors?;Willst du wirklich die {0}ten Vorfahren entfernen?
|
32
|
+
cnfrm01;¿Estás seguro de que deseas eliminar la especie {0}?;Are you sure you want to remove the {0} species?;Willst du wirklich die {0}te Spezies entfernen?
|
33
|
+
cnfrm01_0;¿Estás seguro de que deseas eliminar la especie {0} junto a sus descendientes?;Are you sure you want to remove the {0} species along with its descendants?;Willst du wirklich die {0}te Spezies mit allen Nachfahren entfernen?
|
34
|
+
alert01;La duración de {0} debe ser mayor a 0;The duration of {0} must be greater than 0;Die Dauer von {0} muss grösser sein wie 0.
|
35
|
+
alert02;La aparición de {0} debe ser entre la aparición ({1}) y la extinción ({2}) de {3};The apparition of {0} must be between the apparition ({1}) and the extinction ({2}) of {3};Die Erscheinung von {0} muss zwischen der Erscheinung von ({1}) und dem Aussterben von ({2}) von {3}.
|
36
|
+
alert03;La aparición de {0} debe ser anterior o igual a la aparición ({1}) de {2};The apparition of {0} must be before or equal the apparition ({1}) of {2};Die Erscheinung von {0} muss zugleich oder befor dem Erscheinen von ({1}) von {2} sein.
|
37
|
+
alert03_0;La extinción de {0} debe ser posterior o igual a la aparición ({1}) de {2};The extiction of {0} must be after or equal the apparition ({1}) of {2};Das Aussterben von {0} muss nach oder zugleich zu dem Erscheinen von ({1}) von {2} sein.
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const between: (n: number, min: number, max: number) => number;
|
@@ -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/dist/vite.svg
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/package.json
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
{
|
2
2
|
"name": "chrono-phylo-tree",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.11",
|
4
4
|
"description": "A React-based phylogenetic tree visualization library",
|
5
|
-
"
|
5
|
+
"type": "module",
|
6
|
+
"main": "./dist/chrono-phylo-tree.umd.js",
|
7
|
+
"module": "./dist/chrono-phylo-tree.es.js",
|
8
|
+
"types": "./dist/index.d.ts",
|
6
9
|
"files": [
|
7
|
-
"
|
10
|
+
"dist"
|
8
11
|
],
|
12
|
+
"exports": {
|
13
|
+
".": {
|
14
|
+
"import": "./dist/chrono-phylo-tree.es.js",
|
15
|
+
"require": "./dist/chrono-phylo-tree.umd.js"
|
16
|
+
}
|
17
|
+
},
|
9
18
|
"scripts": {
|
10
19
|
"dev": "vite",
|
11
20
|
"build": "tsc -b && vite build",
|
@@ -30,6 +39,7 @@
|
|
30
39
|
"eslint-plugin-react-hooks": "^5.0.0",
|
31
40
|
"eslint-plugin-react-refresh": "^0.4.18",
|
32
41
|
"globals": "^15.14.0",
|
42
|
+
"tsup": "^8.5.0",
|
33
43
|
"typescript": "~5.7.2",
|
34
44
|
"typescript-eslint": "^8.21.0",
|
35
45
|
"vite": "^6.0.11",
|
package/src/App.css
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
@import "tailwindcss";
|
2
|
-
|
3
|
-
@tailwindcss base;
|
4
|
-
@tailwindcss component;
|
5
|
-
@tailwindcss utilities;
|
6
|
-
|
7
|
-
#root {
|
8
|
-
max-width: 1280px;
|
9
|
-
margin: 0 auto;
|
10
|
-
padding: 2rem;
|
11
|
-
text-align: center;
|
12
|
-
}
|
13
|
-
|
14
|
-
.logo {
|
15
|
-
height: 6em;
|
16
|
-
padding: 1.5em;
|
17
|
-
will-change: filter;
|
18
|
-
transition: filter 300ms;
|
19
|
-
}
|
20
|
-
.logo:hover {
|
21
|
-
filter: drop-shadow(0 0 2em #646cffaa);
|
22
|
-
}
|
23
|
-
.logo.react:hover {
|
24
|
-
filter: drop-shadow(0 0 2em #61dafbaa);
|
25
|
-
}
|
26
|
-
|
27
|
-
@keyframes logo-spin {
|
28
|
-
from {
|
29
|
-
transform: rotate(0deg);
|
30
|
-
}
|
31
|
-
to {
|
32
|
-
transform: rotate(360deg);
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
@media (prefers-reduced-motion: no-preference) {
|
37
|
-
a:nth-of-type(2) .logo {
|
38
|
-
animation: logo-spin infinite 20s linear;
|
39
|
-
}
|
40
|
-
}
|
41
|
-
|
42
|
-
.card {
|
43
|
-
padding: 2em;
|
44
|
-
}
|
45
|
-
|
46
|
-
.read-the-docs {
|
47
|
-
color: #888;
|
48
|
-
}
|
49
|
-
|
50
|
-
input:not([type="file"]) {
|
51
|
-
text-rendering: auto;
|
52
|
-
color: fieldtext;
|
53
|
-
letter-spacing: normal;
|
54
|
-
word-spacing: normal;
|
55
|
-
line-height: normal;
|
56
|
-
text-transform: none;
|
57
|
-
text-indent: 0px;
|
58
|
-
text-shadow: none;
|
59
|
-
display: inline-block;
|
60
|
-
text-align: start;
|
61
|
-
appearance: auto;
|
62
|
-
-webkit-rtl-ordering: logical;
|
63
|
-
cursor: text;
|
64
|
-
background-color: field;
|
65
|
-
margin: 0em;
|
66
|
-
padding: 1px 0px;
|
67
|
-
border-width: 2px;
|
68
|
-
border-style: inset;
|
69
|
-
border-color: light-dark(rgb(118, 118, 118), rgb(133, 133, 133));
|
70
|
-
border-image: initial;
|
71
|
-
padding-block: 1px;
|
72
|
-
padding-inline: 2px;
|
73
|
-
}
|
74
|
-
|
75
|
-
input:not([type="image" i], [type="range" i], [type="checkbox" i], [type="radio" i]) {
|
76
|
-
overflow-clip-margin: 0px !important;
|
77
|
-
overflow: clip !important;
|
78
|
-
}
|
79
|
-
|
80
|
-
input[type="text" i],
|
81
|
-
input[type="number" i] {
|
82
|
-
margin-left: 4px;
|
83
|
-
margin-right: 4px;
|
84
|
-
padding-block: 1px;
|
85
|
-
padding-inline: 2px;
|
86
|
-
background-color: field;
|
87
|
-
}
|
88
|
-
|
89
|
-
input[type="range" i] {
|
90
|
-
appearance: auto;
|
91
|
-
cursor: default;
|
92
|
-
color: light-dark(rgb(16, 16, 16), rgb(255, 255, 255));
|
93
|
-
padding: initial;
|
94
|
-
border: initial;
|
95
|
-
margin: 2px;
|
96
|
-
}
|
97
|
-
|
98
|
-
input[type="file"]::file-selector-button{
|
99
|
-
background-color: #6b6b6b;
|
100
|
-
padding-left: 4px;
|
101
|
-
padding-right: 4px;
|
102
|
-
border-radius: 0.25rem;
|
103
|
-
}
|
104
|
-
|
105
|
-
textarea {
|
106
|
-
font-family: monospace;
|
107
|
-
text-rendering: auto;
|
108
|
-
color: fieldtext;
|
109
|
-
letter-spacing: normal;
|
110
|
-
word-spacing: normal;
|
111
|
-
line-height: normal;
|
112
|
-
text-transform: none;
|
113
|
-
text-indent: 0px;
|
114
|
-
text-shadow: none;
|
115
|
-
display: inline-block;
|
116
|
-
text-align: start;
|
117
|
-
appearance: auto;
|
118
|
-
-webkit-rtl-ordering: logical;
|
119
|
-
resize: -internal-textarea-auto;
|
120
|
-
cursor: text;
|
121
|
-
overflow-wrap: break-word;
|
122
|
-
background-color: field;
|
123
|
-
column-count: initial !important;
|
124
|
-
margin: 0em;
|
125
|
-
border-width: 1px;
|
126
|
-
border-style: solid;
|
127
|
-
border-color: light-dark(rgb(118, 118, 118), rgb(133, 133, 133));
|
128
|
-
border-image: initial;
|
129
|
-
padding: 2px;
|
130
|
-
white-space: pre-wrap;
|
131
|
-
}
|
package/src/App.tsx
DELETED
@@ -1,149 +0,0 @@
|
|
1
|
-
import { useEffect, useState } from 'react'
|
2
|
-
import './App.css'
|
3
|
-
import { PhTree } from './components/PhTree'
|
4
|
-
import { Species } from './classes/Species'
|
5
|
-
import { between } from './utils/between';
|
6
|
-
import { codeTextAlt, getLanguageOptions } from './utils/translate';
|
7
|
-
import { Menu } from './components/Menu';
|
8
|
-
import { NavBar } from './components/NavBar';
|
9
|
-
import { scientificNotation } from './utils/scientificNotation';
|
10
|
-
import { hexToRGBA } from './utils/hexToRGBA';
|
11
|
-
import { example } from './utils/example';
|
12
|
-
import { createAncestor, createDescendant, deleteAncestor, deleteSpecies, saveSpecies } from './utils/updateSpecies';
|
13
|
-
import { setFromJson } from './utils/setFromJson';
|
14
|
-
import { HoverDescription } from './components/HoverDescription';
|
15
|
-
|
16
|
-
function App() {
|
17
|
-
const [scale, setScale] = useState(1);
|
18
|
-
const [species, setSpecies] = useState<Species | undefined>(undefined);
|
19
|
-
const [speciesList, setSpeciesList] = useState<Species[]>([]);
|
20
|
-
const [lineColor, setLineColor] = useState("#7F7F7F");
|
21
|
-
const [presentTime, setPresentTime] = useState<number>(1);
|
22
|
-
const [presentTimeBoolean, setPresentTimeBoolean] = useState(true);
|
23
|
-
const [chronoScale, setChronoScale] = useState(true);
|
24
|
-
const [language, setLanguage] = useState("spanish");
|
25
|
-
const [hoverPosition, setHoverPosition] = useState({x: 0, y: 0});
|
26
|
-
const [showHover, setShowHover] = useState(false);
|
27
|
-
const [showImages, setShowImages] = useState(true);
|
28
|
-
const languages = getLanguageOptions();
|
29
|
-
const minScale = 1e-12;
|
30
|
-
const offset = {x: 0, y: -50}
|
31
|
-
|
32
|
-
useEffect(() => {
|
33
|
-
const title = document.getElementById("title");
|
34
|
-
if(title) {
|
35
|
-
codeTextAlt("ttl", language).then((ttl) => title.textContent = ttl);
|
36
|
-
}
|
37
|
-
}, [language]);
|
38
|
-
const showScaleNumber = false;
|
39
|
-
|
40
|
-
const showExample = () => {
|
41
|
-
setSpecies(() =>{
|
42
|
-
if(presentTimeBoolean){
|
43
|
-
setPresentTime(example.absoluteExtinction());
|
44
|
-
}
|
45
|
-
setScale(example.absoluteDuration());
|
46
|
-
return example;
|
47
|
-
});
|
48
|
-
};
|
49
|
-
|
50
|
-
const changePresentTime = (n: number) => {
|
51
|
-
setPresentTime(n);
|
52
|
-
setScale(between(scale, 1, maxScale(n)));
|
53
|
-
};
|
54
|
-
|
55
|
-
const maxScale = (n: number) => species ? Math.min(species.absoluteDuration(), presentTimeBoolean ? n - species.apparition : species.absoluteDuration()) : 1
|
56
|
-
|
57
|
-
const createEmptySpecies = async () => {
|
58
|
-
setSpecies(new Species(await codeTextAlt("nvbtn01", language), 0, 1));
|
59
|
-
setScale(1);
|
60
|
-
setPresentTime(1);
|
61
|
-
};
|
62
|
-
|
63
|
-
const deleteAllSpecies = async () => {
|
64
|
-
if(!species) return;
|
65
|
-
if(!confirm(await codeTextAlt("cnfrm01" + (species.descendants.length > 0 ? "_0" : ""), language, [species.name]))) return;
|
66
|
-
setSpecies(undefined);
|
67
|
-
};
|
68
|
-
|
69
|
-
const handleMouseMove = (x: number, y: number) => {
|
70
|
-
setHoverPosition({
|
71
|
-
x: x,
|
72
|
-
y: y,
|
73
|
-
});
|
74
|
-
};
|
75
|
-
|
76
|
-
//document.addEventListener("mousemove", handleMouseMove);
|
77
|
-
|
78
|
-
return (
|
79
|
-
<>
|
80
|
-
<NavBar
|
81
|
-
species={species}
|
82
|
-
color={hexToRGBA(lineColor, 0.5)}
|
83
|
-
lineColor={lineColor}
|
84
|
-
setLineColor={setLineColor}
|
85
|
-
language={language}
|
86
|
-
languages={languages}
|
87
|
-
setLanguage={setLanguage}
|
88
|
-
minScale={minScale}
|
89
|
-
maxScale={maxScale(presentTime)}
|
90
|
-
scale={scale}
|
91
|
-
setScale={setScale}
|
92
|
-
chronoScale={chronoScale}
|
93
|
-
setChronoScale={setChronoScale}
|
94
|
-
showScaleNumber={showScaleNumber}
|
95
|
-
showHover={showHover}
|
96
|
-
setShowHover={setShowHover}
|
97
|
-
showImages={showImages}
|
98
|
-
setShowImages={setShowImages}
|
99
|
-
presentTime={presentTime}
|
100
|
-
setPresentTime={setPresentTime}
|
101
|
-
setFromJson={setFromJson(setSpecies, setScale, setPresentTime, presentTimeBoolean)}
|
102
|
-
presentTimeBoolean={presentTimeBoolean}
|
103
|
-
setPresentTimeBoolean={setPresentTimeBoolean}
|
104
|
-
changePresentTime={changePresentTime}
|
105
|
-
deleteAllSpecies={deleteAllSpecies}
|
106
|
-
createEmptySpecies={createEmptySpecies}
|
107
|
-
showExample={showExample}
|
108
|
-
/>
|
109
|
-
{species && <div className="h-155 sm:h-65"/>}
|
110
|
-
{species && <PhTree
|
111
|
-
commonAncestor={species}
|
112
|
-
width={window.screen.width * (species?.absoluteDuration() ?? 0) / scale - 64}
|
113
|
-
height={50}
|
114
|
-
stroke={lineColor}
|
115
|
-
format={scientificNotation}
|
116
|
-
chronoScale={chronoScale}
|
117
|
-
showImages={showImages}
|
118
|
-
presentTime={presentTimeBoolean ? presentTime : undefined}
|
119
|
-
padding={1}
|
120
|
-
handleMouseMove={handleMouseMove}
|
121
|
-
>
|
122
|
-
{(sp, showMenu, toggleShowMenu, hoverSpecies) => species &&
|
123
|
-
<>
|
124
|
-
{showMenu && sp && <Menu
|
125
|
-
species={sp}
|
126
|
-
language={language}
|
127
|
-
open={showMenu}
|
128
|
-
onClose={() => toggleShowMenu(sp)}
|
129
|
-
saveSpecies={saveSpecies(setSpecies, language)}
|
130
|
-
createDescendant={createDescendant(setSpecies, language, presentTimeBoolean, setPresentTime, setScale)}
|
131
|
-
createAncestor={createAncestor(setSpecies, language, presentTimeBoolean, setPresentTime, setScale)}
|
132
|
-
deleteAncestor={deleteAncestor(sp, setSpecies, setScale, language)}
|
133
|
-
deleteSpecies={deleteSpecies(sp, setSpecies, language)}
|
134
|
-
/>}
|
135
|
-
{showHover && hoverSpecies && hoverSpecies.description &&
|
136
|
-
<HoverDescription
|
137
|
-
hoverPosition={hoverPosition}
|
138
|
-
hoverSpecies={hoverSpecies}
|
139
|
-
offset={offset}
|
140
|
-
/>
|
141
|
-
}
|
142
|
-
</>
|
143
|
-
}
|
144
|
-
</PhTree>}
|
145
|
-
</>
|
146
|
-
)
|
147
|
-
}
|
148
|
-
|
149
|
-
export default App
|