From c364c0c6ecbf27e45d2fdd0b0c9d824f711a4a88 Mon Sep 17 00:00:00 2001 From: Jason Johnston Date: Mon, 4 Sep 2023 22:40:12 -0500 Subject: [PATCH] Forgot to compile io page --- docs/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/index.html b/docs/index.html index 8bb82a5..57e9f7e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -99,7 +99,7 @@ `:`; `)+H+`return __p }`;var ue=Zp(function(){return ge(x,q+"return "+H).apply(n,E)});if(ue.source=H,Gu(ue))throw ue;return ue}function B_(r){return xe(r).toLowerCase()}function $_(r){return xe(r).toUpperCase()}function H_(r,l,o){if(r=xe(r),r&&(o||l===n))return ah(r);if(!r||!(l=Ft(l)))return r;var f=fn(r),p=fn(l),x=uh(f,p),E=ch(f,p)+1;return ar(f,x,E).join("")}function V_(r,l,o){if(r=xe(r),r&&(o||l===n))return r.slice(0,dh(r)+1);if(!r||!(l=Ft(l)))return r;var f=fn(r),p=ch(f,fn(l))+1;return ar(f,0,p).join("")}function G_(r,l,o){if(r=xe(r),r&&(o||l===n))return r.replace(Ga,"");if(!r||!(l=Ft(l)))return r;var f=fn(r),p=uh(f,fn(l));return ar(f,p).join("")}function Q_(r,l){var o=Y,f=ye;if(Te(l)){var p="separator"in l?l.separator:p;o="length"in l?ae(l.length):o,f="omission"in l?Ft(l.omission):f}r=xe(r);var x=r.length;if(dl(r)){var E=fn(r);x=E.length}if(o>=x)return r;var P=o-hl(f);if(P<1)return f;var T=E?ar(E,0,P).join(""):r.slice(0,P);if(p===n)return T+f;if(E&&(P+=T.length-P),Qu(p)){if(r.slice(P).search(p)){var W,B=T;for(p.global||(p=au(p.source,xe(Id.exec(p))+"g")),p.lastIndex=0;W=p.exec(B);)var H=W.index;T=T.slice(0,H===n?P:H)}}else if(r.indexOf(Ft(p),P)!=P){var Q=T.lastIndexOf(p);Q>-1&&(T=T.slice(0,Q))}return T+f}function K_(r){return r=xe(r),r&&l1.test(r)?r.replace(kd,Cx):r}var b_=wl(function(r,l,o){return r+(o?" ":"")+l.toUpperCase()}),Yu=ep("toUpperCase");function Jp(r,l,o){return r=xe(r),l=o?n:l,l===n?gx(r)?jx(r):ax(r):r.match(l)||[]}var Zp=ce(function(r,l){try{return Mt(r,n,l)}catch(o){return Gu(o)?o:new ie(o)}}),Y_=Wn(function(r,l){return bt(l,function(o){o=kn(o),zn(r,o,Hu(r[o],r))}),r});function X_(r){var l=r==null?0:r.length,o=ee();return r=l?Ie(r,function(f){if(typeof f[1]!="function")throw new Yt(c);return[o(f[0]),f[1]]}):[],ce(function(f){for(var p=-1;++pG)return[];var o=ve,f=ct(r,ve);l=ee(l),r-=ve;for(var p=iu(f,l);++o0||l<0)?new de(o):(r<0?o=o.takeRight(-r):r&&(o=o.drop(r)),l!==n&&(l=ae(l),o=l<0?o.dropRight(-l):o.take(l-r)),o)},de.prototype.takeRightWhile=function(r){return this.reverse().takeWhile(r).reverse()},de.prototype.toArray=function(){return this.take(ve)},jn(de.prototype,function(r,l){var o=/^(?:filter|find|map|reject)|While$/.test(l),f=/^(?:head|last)$/.test(l),p=v[f?"take"+(l=="last"?"Right":""):l],x=f||/^find/.test(l);p&&(v.prototype[l]=function(){var E=this.__wrapped__,P=f?[1]:arguments,T=E instanceof de,W=P[0],B=T||se(E),H=function(fe){var pe=p.apply(v,nr([fe],P));return f&&Q?pe[0]:pe};B&&o&&typeof W=="function"&&W.length!=1&&(T=B=!1);var Q=this.__chain__,q=!!this.__actions__.length,te=x&&!Q,ue=T&&!q;if(!x&&B){E=ue?E:new de(this);var ne=r.apply(E,P);return ne.__actions__.push({func:ro,args:[H],thisArg:n}),new Xt(ne,Q)}return te&&ue?r.apply(this,P):(ne=this.thru(H),te?f?ne.value()[0]:ne.value():ne)})}),bt(["pop","push","shift","sort","splice","unshift"],function(r){var l=Ps[r],o=/^(?:push|sort|unshift)$/.test(r)?"tap":"thru",f=/^(?:pop|shift)$/.test(r);v.prototype[r]=function(){var p=arguments;if(f&&!this.__chain__){var x=this.value();return l.apply(se(x)?x:[],p)}return this[o](function(E){return l.apply(se(E)?E:[],p)})}}),jn(de.prototype,function(r,l){var o=v[l];if(o){var f=o.name+"";we.call(gl,f)||(gl[f]=[]),gl[f].push({name:l,func:o})}}),gl[Xs(n,y).name]=[{name:"wrapper",func:n}],de.prototype.clone=Kx,de.prototype.reverse=bx,de.prototype.value=Yx,v.prototype.at=NS,v.prototype.chain=jS,v.prototype.commit=ES,v.prototype.next=kS,v.prototype.plant=PS,v.prototype.reverse=IS,v.prototype.toJSON=v.prototype.valueOf=v.prototype.value=RS,v.prototype.first=v.prototype.head,fi&&(v.prototype[fi]=AS),v},pl=Ex();Fr?((Fr.exports=pl)._=pl,qa._=pl):rt._=pl}).call(ji)})(pa,pa.exports);var ok=pa.exports;const U=_0(ok);var Kg={exports:{}};(function(e,t){function n(){var c=document.querySelector("[data-toggle-theme]"),d=c?c.getAttribute("data-key"):null;(function(h=localStorage.getItem(d||"theme")){localStorage.getItem(d||"theme")&&(document.documentElement.setAttribute("data-theme",h),c&&[...document.querySelectorAll("[data-toggle-theme]")].forEach(m=>{m.classList.add(c.getAttribute("data-act-class"))}))})(),c&&[...document.querySelectorAll("[data-toggle-theme]")].forEach(h=>{h.addEventListener("click",function(){var m=h.getAttribute("data-toggle-theme");if(m){var _=m.split(",");document.documentElement.getAttribute("data-theme")==_[0]?_.length==1?(document.documentElement.removeAttribute("data-theme"),localStorage.removeItem(d||"theme")):(document.documentElement.setAttribute("data-theme",_[1]),localStorage.setItem(d||"theme",_[1])):(document.documentElement.setAttribute("data-theme",_[0]),localStorage.setItem(d||"theme",_[0]))}[...document.querySelectorAll("[data-toggle-theme]")].forEach(k=>{k.classList.toggle(this.getAttribute("data-act-class"))})})})}function i(){var c=document.querySelector("[data-set-theme='']"),d=c?c.getAttribute("data-key"):null;(function(h=localStorage.getItem(d||"theme")){if(h!=null&&h!="")if(localStorage.getItem(d||"theme")&&localStorage.getItem(d||"theme")!=""){document.documentElement.setAttribute("data-theme",h);var m=document.querySelector("[data-set-theme='"+h.toString()+"']");m&&([...document.querySelectorAll("[data-set-theme]")].forEach(_=>{_.classList.remove(_.getAttribute("data-act-class"))}),m.getAttribute("data-act-class")&&m.classList.add(m.getAttribute("data-act-class")))}else{var m=document.querySelector("[data-set-theme='']");m.getAttribute("data-act-class")&&m.classList.add(m.getAttribute("data-act-class"))}})(),[...document.querySelectorAll("[data-set-theme]")].forEach(h=>{h.addEventListener("click",function(){document.documentElement.setAttribute("data-theme",this.getAttribute("data-set-theme")),localStorage.setItem(d||"theme",document.documentElement.getAttribute("data-theme")),[...document.querySelectorAll("[data-set-theme]")].forEach(m=>{m.classList.remove(m.getAttribute("data-act-class"))}),h.getAttribute("data-act-class")&&h.classList.add(h.getAttribute("data-act-class"))})})}function s(){var c=document.querySelector("select[data-choose-theme]"),d=c?c.getAttribute("data-key"):null;(function(h=localStorage.getItem(d||"theme")){if(localStorage.getItem(d||"theme")){document.documentElement.setAttribute("data-theme",h);var m=document.querySelector("select[data-choose-theme] [value='"+h.toString()+"']");m&&[...document.querySelectorAll("select[data-choose-theme] [value='"+h.toString()+"']")].forEach(_=>{_.selected=!0})}})(),c&&[...document.querySelectorAll("select[data-choose-theme]")].forEach(h=>{h.addEventListener("change",function(){document.documentElement.setAttribute("data-theme",this.value),localStorage.setItem(d||"theme",document.documentElement.getAttribute("data-theme")),[...document.querySelectorAll("select[data-choose-theme] [value='"+localStorage.getItem(d||"theme")+"']")].forEach(m=>{m.selected=!0})})})}function a(c=!0){c===!0?document.addEventListener("DOMContentLoaded",function(d){n(),s(),i()}):(n(),s(),i())}e.exports={themeChange:a}})(Kg);var ak=Kg.exports;function tn(e,t){return e+Math.floor(Math.random()*(t+1-e))}const y0={neutral:"btn-neutral",primary:"btn-primary",secondary:"btn-secondary",accent:"btn-accent",info:"btn-info",success:"btn-success",warning:"btn-warning",error:"btn-error",disabled:"btn-disabled",default:"btn-primary"},tt={neutral:"bg-neutral text-neutral-content",primary:"bg-primary text-primary-content",secondary:"bg-secondary text-secondary-content",accent:"bg-accent text-accent-content",info:"bg-info text-info-content",success:"bg-success text-success-content",warning:"bg-warning text-warning-content",error:"bg-error text-error-content",default:"bg-primary text-primary-content"},J={neutral:"border-neutral",primary:"border-primary",secondary:"border-secondary",accent:"border-accent",info:"border-info",success:"border-success",warning:"border-warning",error:"border-error",default:"border-primary"};function X({className:e,as:t,color:n,...i}){let s=`${e||""} btn btn-sm px-2 py-1 rounded-xl font-bold text-center ${y0[n]||y0.default}`,a=t||"button";return u.jsx(a,{className:s,...i})}class ma{static GetVersion(t){return U.has(t,"version")?t.version:0}static Upgrade(t){let n=!1;return U.has(t,"version")||(U.merge(t,{version:0}),n=!0,console.info(`Upgrading ${t.title} to version 0`)),t.version==0&&(U.has(t,"data.miscstats")&&(U.merge(t,{data:{miscstats:{basespeed:[t.data.miscstats.speed[0],t.data.miscstats.speed[2],t.data.miscstats.speed[3],t.data.miscstats.speed[4]]}}}),t.data.miscstats.speed=[0,t.data.miscstats.speed[1],0,0,0]),t.version=1,n=!0,console.info(`Upgrading ${t.title} to version 1`)),n}}nm(ma,"CurrentVersion",1);const qe=T0.createContext(null);function uk(e){let t=I.useRef([]),[n,i]=I.useState([]),[s,a]=I.useState(null);I.useEffect(()=>{if(!U.isNil(localStorage.getItem("PCSGlobalStore"))){let d=JSON.parse(localStorage.getItem("PCSGlobalStore"));d.forEach(h=>{ma.Upgrade(h)&&(h.saved=!1)}),i(d),t.current=d}return U.isNil(s)&&a(setInterval(()=>{U.isEmpty(t.current)&&(U.isNil(localStorage.getItem("PCSGlobalStore"))?localStorage.setItem("PCSGlobalStore",JSON.stringify(t.current)):localStorage.removeItem("PCSGlobalStore"))},10*1e3)),()=>clearInterval(s)},[]),I.useEffect(()=>{U.isEmpty(n)?localStorage.removeItem("PCSGlobalStore"):(localStorage.setItem("PCSGlobalStore",JSON.stringify(n)),t.current=[...n])},[n]);function c(){for(let d=0;d{const i=new Uint8Array(1);return n.getRandomValues(i),i[0]/255};if(typeof(n==null?void 0:n.randomBytes)=="function")return()=>n.randomBytes(1).readUInt8()/255;throw new yn({info:{code:"PRNG_DETECT",...zi}},"Failed to find a reliable PRNG")}function vk(){return yk()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function gk(e,t){let n="";for(;e>0;e--)n=wk(t)+n;return n}function xk(e,t){if(isNaN(e))throw new yn({info:{code:"ENC_TIME_NAN",...zi}},`Time must be a number: ${e}`);if(e>w0)throw new yn({info:{code:"ENC_TIME_SIZE_EXCEED",...zi}},`Cannot encode a time larger than ${w0}: ${e}`);if(e<0)throw new yn({info:{code:"ENC_TIME_NEG",...zi}},`Time must be positive: ${e}`);if(Number.isInteger(e)===!1)throw new yn({info:{code:"ENC_TIME_TYPE",...zi}},`Time must be an integer: ${e}`);let n,i="";for(let s=t;s>0;s--)n=e%Yi,i=bg.charAt(n)+i,e=(e-n)/Yi;return i}function yk(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function wk(e){let t=Math.floor(e()*Yi);return t===Yi&&(t=Yi-1),bg.charAt(t)}function ut(e,t){const n=t||mk(),i=isNaN(e)?Date.now():e;return xk(i,hk)+gk(pk,n)}function Sk({className:e,innerClass:t,outerClass:n,color:i,title:s,children:a}){return u.jsxs("div",{className:`${e||""} ${n||""} card card-compact border border-base-content shadow-md rounded-md`,children:[u.jsx("div",{className:`card-title lg-title rounded-t-md ${tt[i]||tt.default}`,children:s==0?"0":s||"Dialog"}),u.jsx("div",{className:`${t||""} flex flex-col rounded-b-md -mt-1`,children:a})]})}function Re({title:e,id:t,value:n,placeholder:i,color:s,className:a,innerClass:c,outerClass:d,onChange:h}){h||console.warn("In order to get the text, you need to assign something to onChange...");let[m,_]=I.useState(n||""),[k,C]=I.useState(t||ut());I.useEffect(()=>{_(n||"")},[n]);function N(S){let w=S.target.value;_(w),h&&h(w)}return u.jsxs("div",{className:`text-cont ${a||""} ${d||""}`,children:[u.jsx("label",{htmlFor:k,className:`text-label lg-title ${tt[s]||tt.default} ${J[s]||J.default}`,children:e==0?"0":e||"Text"}),u.jsx("input",{type:"text",id:k,name:k,value:m,placeholder:i,className:`text-input ${c} ${J[s]||J.default}`,onChange:N})]})}function sl({id:e,title:t,color:n,className:i,innerClass:s,outerClass:a,children:c,type:d,onClose:h}){const[m,_]=I.useState("");U.isEmpty(e)&&console.warn("You must supply an id property for a Modal component, or else you will not be able to call it via window.id.showModal()"),h||console.warn("In order to get a return value, you must provide an onClose property");function k(){switch(d){case wn.okcancel:return u.jsxs(u.Fragment,{children:[u.jsx(X,{color:"primary",value:"ok",className:"flex-grow",children:"OK"}),u.jsx(X,{color:"error",value:"cancel",className:"flex-grow",children:"Cancel"})]});case wn.yesno:return u.jsxs(u.Fragment,{children:[u.jsx(X,{color:"primary",value:"yes",className:"flex-grow",children:"YES"}),u.jsx(X,{color:"error",value:"no",className:"flex-grow",children:"NO"})]});default:return u.jsx(X,{color:"primary",value:"ok",className:"flex-grow",children:"OK"})}}function C(N){h&&(d==wn.prompt&&N.target.returnValue==="ok"?h(m):h(N.target.returnValue)),_("")}return u.jsx("dialog",{id:e,className:`${i||""} ${a||""} modal`,onClose:N=>C(N),children:u.jsxs("form",{method:"dialog",className:"modal-box border border-black",children:[u.jsxs("div",{className:`flex flex-row p-1 items-center rounded-t-lg border ${tt[n]||tt.default} ${J[n]||J.default}`,children:[u.jsx("div",{className:"lg-title flex-grow",children:t==0?"0":t||"Modal"}),u.jsx(X,{className:`bi-x-lg border ${J[n]||J.default}`,color:"error",value:"close"})]}),u.jsxs("div",{className:`${s||""} rounded-b-lg border border-t-0 p-0.5 ${J[n]||J.default}`,children:[c||u.jsx("p",{children:"Dialog Message"}),d==wn.prompt&&u.jsx("div",{className:"flex mt-3",children:u.jsx(Re,{title:"Value",placeholder:"Enter new value...",outerClass:"flex-grow",value:m,color:"secondary",onChange:N=>_(N)})})]}),u.jsx("div",{className:"modal-action",children:k()})]})})}const wn={ok:0,okcancel:1,yesno:2,prompt:3};function Ck(){let e=I.useContext(qe),[t,n]=I.useState([]);I.useEffect(()=>{e.setFiles([...e.files]),n(new Array(e.files.length).fill(!1))},[]);function i(C){let N=[...t];N[C]=!N[C],n(N)}function s(C){if(!U.isEmpty(C)&&C!=="close"){let N=[...e.files];N.push({_id:ut(),title:C,loaded:!1,saved:!1,data:{},version:ma.CurrentVersion});let S=[...t];S.push(!1),e.setFiles(N),n(S)}}function a(C){let N=C.target.files;for(let S=0;S{let y=w.result,g=null;try{if(g=JSON.parse(y),!U.has(g,"title")||!U.has(g,"data"))throw"Invalid data format";let j=ma.Upgrade(g);U.assign(g,{_id:ut(),loaded:!1,saved:!j}),e.setFiles([...e.files,g]);let M=[...t];M.push(!1),n(M)}catch(j){console.error("DEAL WITH NON-STANDARD FILE LOADS",j)}}),w.readAsText(N[S])}}function c(C){if(!U.isNil(e.files[C])){let N=e.files.map((S,w)=>(S.loaded?S.loaded=!1:S.loaded=C==w,S));e.setFiles(N)}}function d(C){let N={...e.files[C]};U.unset(N,"loaded"),U.unset(N,"saved"),U.unset(N,"_id");let S=document.createElement("a");S.href=`data:application/json;charset=utf8,${encodeURIComponent(JSON.stringify(N,null," "))}`,S.download=`${N.title}.json`,S.style.display="none",document.body.appendChild(S),S.click(),document.body.removeChild(S),e.files[C].saved=!0,e.setFiles([...e.files])}function h(C){let N=[...e.files];N.splice(C,1),e.setFiles(N)}function m(C,N,S){if(U.has(e.files[C].data,S))return u.jsxs("div",{className:"flex flex-row items-center space-x-3 p-1 last:rounded-b-md hover:bg-gradient-to-r hover:from-slate-300 hover:to-white",children:[u.jsx("div",{className:"flex-grow",children:N}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>_(C,S),children:" Clear"})]})}function _(C,N){U.unset(e.files[C].data,N)}function k(){return e.files.length==0?u.jsx("p",{children:"No characters have been loaded or created..."}):e.files.map((C,N)=>u.jsxs("div",{className:"border border-primary rounded-md p-1 space-y-1",children:[u.jsxs("div",{className:"flex flex-row items-center space-x-2",children:[u.jsx("div",{className:"flex-grow",onClick:()=>console.info(e.files[N]),children:C.title}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(X,{color:"primary",className:"bi-eraser",onClick:()=>i(N)}),u.jsx(X,{color:C.loaded?"disabled":"secondary",className:`${C.loaded?"bi-square-fill":"bi-caret-right-fill"} pointer-events-auto`,onClick:()=>c(N)}),u.jsx(X,{color:C.saved?"disabled":"success",className:"bi-save-fill pointer-events-auto",onClick:()=>d(N)}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>h(N)})]})]}),t[N]&&u.jsxs(Sk,{title:"Erase Data",color:"error",children:[m(N,"Character Details","details"),m(N,"Ability Scores","stats"),m(N,"Classes","classes"),m(N,"Health","health"),m(N,"Saving Throws","saves"),m(N,"Offensive Stats","offense"),m(N,"Defensive Stats","defense"),m(N,"Miscellaneous Stats","miscstats"),m(N,"Weapons","weapons"),m(N,"Armor","armors"),m(N,"Skills","skills"),m(N,"Custom Skills","custskills"),m(N,"Experience","exp"),m(N,"Wealth","wealth"),m(N,"Abilities","abilities"),m(N,"Equipment","equipment"),m(N,"Spellbook","spellbook"),m(N,"Notes","notes")]})]},`character-${C._id}`))}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"File Manager"}),u.jsxs("div",{className:"main-container",children:[u.jsx(X,{color:"primary",onClick:()=>window.newchar.showModal(),children:"New Character"}),u.jsxs(X,{as:"label",color:"primary",children:[u.jsx("input",{type:"file",className:"hidden h-0",multiple:!0,accept:".json",onChange:a}),"Load Character"]})]}),u.jsx("h2",{children:"Characters"}),u.jsx("div",{className:"main-container",children:k()}),u.jsxs("div",{className:"msg-container space-y-1",children:[u.jsxs("div",{className:"font-bold",children:[u.jsx(X,{color:"primary",className:"bi-eraser text-xs px-1 py-0.5"})," - Clear Data"]}),u.jsxs("div",{className:"font-bold",children:[u.jsx(X,{color:"disabled",className:"bi-square-fill text-xs px-1 py-0.5"})," - Disable Character  ",u.jsx(X,{color:"secondary",className:"bi-caret-right-fill text-xs px-1 py-0.5"})," - Activate Character"]}),u.jsxs("div",{className:"font-bold",children:[u.jsx(X,{color:"disabled",className:"bi-save-fill text-xs px-1 py-0.5"})," - Character Saved  ",u.jsx(X,{color:"success",className:"bi-save-fill text-xs px-1 py-0.5"})," - Character NOT Saved"]}),u.jsxs("div",{className:"font-bold",children:[u.jsx(X,{color:"error",className:"bi-trash text-xs px-1 py-0.5"})," - Remove Character"]}),u.jsxs("div",{children:["Characters will be stored upon any changes to the list from this page, or periodically every 10 seconds. Upon loading the page again, they should be reloaded. Please note that this store uses localstorage for the characters, so if you move this web application the localstorage will be reset. It is a known flaw with non-server based web applications. To prevent any major losses, make sure you ",u.jsx(X,{color:"green",className:"bi-save-fill text-white text-xs px-1 py-0.5"})," save the characters listed."]})]}),u.jsx(sl,{id:"newchar",title:"Create New Character",type:wn.prompt,onClose:C=>s(C),children:u.jsx("p",{children:"Please enter the name of your new Character:"})})]})}function Ir({title:e,id:t,value:n,items:i,arrow:s,color:a,className:c,innerClass:d,outerClass:h,onChange:m}){if(!Array.isArray(i))throw new Error("The Select component requires the items property to be present, and be of type Array.");m||console.warn("In order to get the index, you need to assign something to onChange...");let[_,k]=I.useState(n||0),[C,N]=I.useState(t||ut());I.useEffect(()=>{k(n||0)},[n]);function S(A){let y=A.target.selectedIndex;k(y),m&&m(y)}function w(){return i.map((A,y)=>u.jsx("option",{value:y,children:A},`${C}${y}`))}return u.jsxs("div",{className:`select-cont ${c||""} ${h||""}`,children:[u.jsx("label",{htmlFor:C,className:`select-label lg-title ${tt[a]||tt.default} ${J[a]||J.default}`,children:e==0?"0":e||"Select"}),u.jsx("select",{id:C,name:C,value:_,className:`select-input ${d||"bg-base-100"} ${J[a]||J.default}`,onChange:S,children:w()}),u.jsx("div",{className:`select-end ${s||"bi-caret-down"}`})]})}function Oe({title:e,titleElements:t,color:n,className:i,innerClass:s,outerClass:a,children:c}){const[d,h]=I.useState(!1),m=d?"bi-caret-down":"bi-caret-right",_=d?"":"rounded-b-md",k=d?"flex":"hidden";function C(N){N.target.tagName!="BUTTON"&&h(!d)}return u.jsxs("div",{className:`${i||""} ${a||""}`,children:[u.jsxs("div",{className:`accordian-top ${_} ${tt[n]||tt.default} ${J[n]||J.default}`,onClick:C,children:[u.jsx("div",{className:`pointer-events-none ${m}`}),u.jsx("div",{className:"pointer-events-none flex-grow lg-title",children:e==0?"0":e||"Accordian"}),u.jsx("div",{className:"pointer-events-none accordian-elements",children:t})]}),u.jsx("div",{className:`${s||""} accordian-bottom ${k} ${J[n]||J.default}`,children:c})]})}function xr({title:e,id:t,value:n,color:i,className:s,innerClass:a,outerClass:c,onChange:d}){d||console.warn("In order to get the list, you need to assign something to onChange...");let[h,m]=I.useState(n||[]);I.useState(t||ut()),I.useEffect(()=>{m(n||[])},[n]);function _(S,w){let A=S.target.value,y=[...h];y[w]=A,m(y),d&&d(y)}function k(){let S=[...h];S.push(""),m(S),d&&d(S)}function C(S){let w=[...h];w.splice(S,1),m(w),d&&d(w)}function N(){return h.length==0?u.jsx("p",{children:"No items in list..."}):h.map((S,w)=>u.jsxs("div",{className:"list-row",children:[u.jsx("input",{type:"text",value:S,className:`list-input ${J[i]||J.default}`,onChange:A=>_(A,w)}),u.jsx(X,{color:"error",className:"bi-trash border border-black",onClick:()=>C(w)})]},`${t}-${w}`))}return u.jsx(Oe,{title:e==0?"0":e||"List",titleElements:[u.jsx("div",{className:"flex items-center",children:h.length},`${t}-size`),u.jsx(X,{color:"success",className:"bi-plus-circle pointer-events-auto border border-black",onClick:k},`${t}-add`)],className:s||"",outerClass:c||"",innerClass:a||"",color:i,children:N()})}const va=["str","dex","con","int","wis","chr"],Yg=e=>Math.floor((e-10)/2),_k=["Fine","Diminutive","Tiny","Small","Medium","Large","Huge","Gargantuan","Colossal"],Nk=["Unaligned","Lawful Good","Neutral Good","Chaotic Good","Lawful Neutral","True Neutral","Chaotic Neutral","Lawful Evil","Neutral Evil","Chaotic Evil","Its Complicated"],jk=[{k:"acro",v:"Acrobatics",s:1,f:1},{k:"appr",v:"Appraise",s:3,f:0},{k:"bluf",v:"Bluff",s:5,f:0},{k:"clim",v:"Climb",s:0,f:1},{k:"dipl",v:"Diplomacy",s:5,f:0},{k:"disd",v:"Disable Device",s:1,f:3},{k:"disg",v:"Disguise",s:5,f:0},{k:"esca",v:"Escape Artist",s:1,f:1},{k:"fly",v:"Fly",s:1,f:1},{k:"hana",v:"Handle Animal",s:5,f:2},{k:"heal",v:"Heal",s:4,f:0},{k:"inti",v:"Intimidation",s:5,f:0},{k:"ling",v:"Linguistics",s:3,f:0},{k:"perc",v:"Perception",s:4,f:0},{k:"ride",v:"Ride",s:1,f:1},{k:"senm",v:"Sense Motive",s:4,f:0},{k:"sleh",v:"Sleight of Hand",s:1,f:3},{k:"spel",v:"Spellcraft",s:3,f:2},{k:"stea",v:"Stealth",s:1,f:1},{k:"surv",v:"Survival",s:4,f:0},{k:"swim",v:"Swim",s:0,f:1},{k:"usmd",v:"Use Magic Device",s:5,f:2}],Ek=[{k:"craf",v:"Craft",s:3,f:0},{k:"know",v:"Knowledge",s:3,f:2},{k:"perf",v:"Perform",s:5,f:0},{k:"prof",v:"Profession",s:4,f:2}],S0=[[0,3e3,7500,14e3,23e3,35e3,53e3,77e3,115e3,16e4,235e3,33e4,475e3,665e3,955e3,135e4,19e5,27e5,385e4,535e4],[0,2e3,5e3,9e3,15e3,23e3,35e3,51e3,75e3,105e3,155e3,22e4,315e3,445e3,635e3,89e4,13e5,18e5,255e4,36e5],[0,1300,3300,6e3,1e4,15e3,23e3,34e3,5e4,71e3,105e3,145e3,21e4,295e3,425e3,6e5,85e4,12e5,17e5,24e5]];function kk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1);function s(c){return U.get(e.files[n].data.details,c)}function a(c,d){let h={};h[c]=d,U.assign(e.files[n].data.details,h),e.files[n].saved=!1}return I.useEffect(()=>{let c=e.getLoadedIndex();if(c==-1){t("/");return}U.has(e.files[c],"data.details")||U.assign(e.files[c].data,{details:{name:"",race:"",size:4,gender:"",height:"",weight:"",hair:"",eyes:"",skin:"",age:"",alignment:"",deity:"",homeland:"",languages:[]}}),i(c)},[]),n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Character Details"}),u.jsxs("div",{className:"main-container",children:[u.jsx(Re,{title:"Name",id:"name",value:s("name"),onChange:c=>a("name",c)}),u.jsx(Re,{title:"Race",id:"race",value:s("race"),onChange:c=>a("race",c)}),u.jsx(Ir,{title:"Size",id:"size",value:s("size"),items:_k,arrow:"bi-aspect-ratio",onChange:c=>a("size",c)}),u.jsx(Re,{title:"Gender",id:"gender",value:s("gender"),onChange:c=>a("gender",c)}),u.jsx(Re,{title:"Height",id:"height",value:s("height"),onChange:c=>a("height",c)}),u.jsx(Re,{title:"Weight",id:"weight",value:s("weight"),onChange:c=>a("weight",c)}),u.jsx(Re,{title:"Hair",id:"hair",value:s("hair"),onChange:c=>a("hair",c)}),u.jsx(Re,{title:"Eyes",id:"eyes",value:s("eyes"),onChange:c=>a("eyes",c)}),u.jsx(Re,{title:"Skin",id:"skin",value:s("skin"),onChange:c=>a("skin",c)}),u.jsx(Re,{title:"Age",id:"age",value:s("age"),onChange:c=>a("age",c)}),u.jsx(Ir,{title:"Alignment",id:"alignment",value:s("alignment"),items:Nk,arrow:"bi-text-indent-left",onChange:c=>a("alignment",c)}),u.jsx(Re,{title:"Deity",id:"deity",value:s("deity"),onChange:c=>a("deity",c)}),u.jsx(Re,{title:"Homeland",id:"homeland",value:s("homeland"),onChange:c=>a("homeland",c)}),u.jsx(xr,{title:"Languages",id:"languages",value:s("languages"),onChange:c=>a("languages",c)})]})]})}function mt({title:e,id:t,value:n,min:i,max:s,color:a,className:c,innerClass:d,outerClass:h,onChange:m}){if(e=e||["Num 1","Num 2","Num 3","Num 4"],n=n||new Array(e.length).fill(0),i=i||new Array(e.length).fill(-5e3),s=s||new Array(e.length).fill(1e7),m||console.warn("In order to get the number array, you need to assign something to onChange..."),!Array.isArray(e)||!Array.isArray(n)||!Array.isArray(i)||!Array.isArray(s))throw new Error("The properties of title, value, min and max must be of type Array");if(e.length!=n.length||e.length!=i.length||e.length!=s.length)throw new Error("The properties of title, value, min, and max must be of the same Array dimension");let[_,k]=I.useState(n),[C,N]=I.useState(t||ut());I.useEffect(()=>{JSON.stringify(new Array(e.length).fill(0))!=JSON.stringify(n.filter(A=>A==0))&&k(n)},[n]);function S(A,y){let g=A.target.value,j=[..._];j[y]=parseInt(g)||0,k(j),m&&m(j)}function w(){let A=[];for(let y=0;yS(g,y)})]},`${C}-section${y}`));return A}return u.jsx("div",{className:`mn-cont ${c||""} ${h||""} ${J[a]||J.default}`,children:w()})}function Ak(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([0,0,0,0]),[c,d]=I.useState([0,0,0,0]),[h,m]=I.useState([0,0,0,0]),[_,k]=I.useState([0,0,0,0]),[C,N]=I.useState([0,0,0,0]),[S,w]=I.useState([0,0,0,0]);function A(O){return U.get(e.files[n].data.stats,O)}function y(O,L){let F={};F[O]=L,U.assign(e.files[n].data.stats,F),e.files[n].saved=!1}I.useEffect(()=>{let O=e.getLoadedIndex();if(O==-1){t("/");return}U.has(e.files[O],"data.stats")||U.assign(e.files[O].data,{stats:{str:[0,0,0,0],dex:[0,0,0,0],con:[0,0,0,0],int:[0,0,0,0],wis:[0,0,0,0],chr:[0,0,0,0]}}),i(O),a(e.files[O].data.stats.str),d(e.files[O].data.stats.dex),m(e.files[O].data.stats.con),k(e.files[O].data.stats.int),N(e.files[O].data.stats.wis),w(e.files[O].data.stats.chr)},[]);let g=O=>Math.floor((O-10)/2);function j(O,L){O=="str"&&a(L),O=="dex"&&d(L),O=="con"&&m(L),O=="int"&&k(L),O=="wis"&&N(L),O=="chr"&&w(L),y(O,L)}function M(O,L){if(n==-1)return u.jsx("p",{children:"Loading..."});let F=U.sum(A(L));return u.jsx(Oe,{title:O,titleElements:u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black bg-base-300 text-base-content rounded-md",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Total"}),u.jsx("p",{className:"text-center m-0 p-0",children:F})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Mod"}),u.jsx("p",{className:"text-center m-0 p-0",children:g(F)})]})]}),children:u.jsx(mt,{title:["Base","Enhance","Misc","Temp"],id:`${L}`,value:A(L),min:[0,0,-100,-100],max:[100,100,100,100],color:"secondary",onChange:$=>j(L,$)})})}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Ability Scores"}),u.jsxs("div",{className:"main-container",children:[M("Strength","str"),M("Dexterity","dex"),M("Constitution","con"),M("Intelligence","int"),M("Wisdom","wis"),M("Charisma","chr")]}),u.jsx("div",{className:"msg-container",children:u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Mods Calculation"}),": ⌊(StatTotal - 10) / 2)⌋"]})})]})}function Ce({title:e,value:t,color:n,className:i,innerClass:s,outerClass:a}){return u.jsxs("div",{className:`text-cont ${i||""} ${a||""}`,children:[u.jsx("div",{className:`text-label lg-title ${tt[n]||tt.default} ${J[n]||J.default}`,children:e==0?"0":e||"Label"}),u.jsx("div",{className:`text-input ${J[n]||J.default} ${s||""}`,children:t||""})]})}function st({title:e,id:t,value:n,min:i,max:s,color:a,className:c,innerClass:d,outerClass:h,onChange:m}){m||console.warn("In order to get the number, you need to assign something to onChange...");let[_,k]=I.useState(n||0),[C,N]=I.useState(t||ut());I.useEffect(()=>{k(n||0)},[n]);function S(w){let A=parseInt(w.target.value)||0;k(A),m&&m(A)}return u.jsxs("div",{className:`text-cont ${c||""} ${h||""}`,children:[u.jsx("label",{htmlFor:C,className:`text-label lg-title ${tt[a]||tt.default} ${J[a]||J.default}`,children:e==0?"0":e||"Number"}),u.jsx("input",{type:"number",id:C,name:C,value:_,min:i==0?0:i||-5e3,max:s==0?0:s||1e7,className:`text-input ${J[a]||J.default} ${d||""}`,onChange:S})]})}function Pk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([]),[c,d]=I.useState(-1);function h(w){e.files[n].data.classes=w,e.files[n].saved=!1}I.useEffect(()=>{let w=e.getLoadedIndex();if(w==-1){t("/");return}U.has(e.files[w],"data.classes")||U.assign(e.files[w].data,{classes:[]}),i(w),a(e.files[w].data.classes)},[]);function m(){let w=[...s];w.push({_id:ut(),name:"Untitled Class",level:1,hd:0,health:0,bab:0,skillnum:0,favclass:[0,0],saves:[0,0,0]}),h(w),a(w)}function _(w){d(w),window.removeclass.showModal()}function k(w){if(w==="ok"){let A=[...s];A.splice(c,1),h(A),a(A),d(-1)}d(-1)}function C(){if(n==-1)return 0;let w=0;return s.forEach((A,y)=>{w+=A.level}),w}function N(w,A,y){let g=[...s];A==0&&(g[w].name=y),A==1&&(g[w].level=y),A==2&&(g[w].hd=y[0],g[w].health=y[1],g[w].bab=y[2],g[w].skillnum=y[3]),A==3&&(g[w].favclass=y),A==4&&(g[w].saves=y),a(g),h(g)}function S(){return n==-1?u.jsx("p",{children:"Loading..."}):s.length==0?u.jsx("p",{children:"No classes have been added yet..."}):s.map((w,A)=>u.jsxs(Oe,{title:w.name,titleElements:u.jsx("div",{children:w.level}),children:[u.jsxs("div",{className:"flex flex-row",children:[u.jsx(Re,{title:"Class Name",id:`class${A+1}name`,value:w.name,className:"flex-grow mr-1",color:"secondary",onChange:y=>N(A,0,y)}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>_(A)})]}),u.jsx(st,{title:"Level",id:`class${A+1}level`,value:w.level,min:1,max:20,color:"secondary",onChange:y=>N(A,1,y)}),u.jsx(mt,{title:["HD","Health","BAB","Skill Num"],id:`class${A+1}bs`,value:[w.hd,w.health,w.bab,w.skillnum],min:[0,0,0,0],max:[100,5e3,20,20],color:"secondary",onChange:y=>N(A,2,y)}),u.jsx(mt,{title:["Fav Class Health","Fav Class Skill"],id:`class${A+1}fc`,value:[w.favclass[0],w.favclass[1]],min:[0,0],max:[20,20],color:"secondary",onChange:y=>N(A,3,y)}),u.jsx(mt,{title:["Fortitude","Reflex","Will"],id:`class${A+1}st`,value:[w.saves[0],w.saves[1],w.saves[2]],min:[0,0,0],max:[20,20,20],color:"secondary",onChange:y=>N(A,4,y)})]},`class-${w._id}`))}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Classes"}),u.jsxs("div",{className:"main-container",children:[u.jsx(X,{color:"primary",onClick:m,children:"Add Class"}),u.jsx(Ce,{title:"Total Class Levels",value:C()})]}),u.jsx("div",{className:"main-container",children:S()}),u.jsxs(sl,{id:"removeclass",title:"Confirm Remove?",color:"warning",type:wn.okcancel,onClose:w=>k(w),children:[u.jsx("p",{children:"Are you sure you wish to remove this class?"}),u.jsx("p",{children:"This action is permanent and can only be reverted by re-loading the character data."})]})]})}function Ik(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([0,0,0,0]);function c(_){U.assign(e.files[n].data.health,_),e.files[n].saved=!1}I.useEffect(()=>{let _=e.getLoadedIndex();if(_==-1){t("/");return}U.has(e.files[_],"data.health")||U.assign(e.files[_].data,{health:[0,0,0,0]}),i(_),a(e.files[_].data.health)},[]);function d(){let _=0,k=0,C=0;if(U.has(e.files[n].data,"stats")){let N=e.files[n].data.stats.con;C=Math.floor((N[0]+N[1]+N[2]+N[3]-10)/2)}return U.has(e.files[n].data,"classes")&&e.files[n].data.classes.forEach(N=>{_+=N.health+N.favclass[0],k+=N.level}),_+=k*C,_<=0&&(_=1),_}function h(){let _=d();return _+=-s[0]+-s[1]+s[2]+s[3],_}function m(_){a(_),c(_)}return n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Health"}),u.jsxs("div",{className:"main-container",children:[u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Ce,{title:"Max Health",value:d(),className:"w-1/2"}),u.jsx(Ce,{title:"Current Health",value:h(),className:"w-1/2"})]}),u.jsx(Oe,{title:"Wounds and Bonuses",children:u.jsx(mt,{title:["Wounds","Non-Lethal","Misc","Temp"],id:"health",value:s,min:[0,0,-1e3,-1e3],max:[5e3,5e3,5e3,5e3],color:"secondary",onChange:m})})]}),u.jsxs("div",{className:"msg-container",children:[u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Note:"})," Wounds and Non-Lethal subtract from the total health, while Misc and Temp add to the total."]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Max Calculation:"})," Total = Sum of Each Class(Health + Favored Class Health)"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Current Calculation:"})," Total = -(Wounds) + -(Non-Lethal) + Misc + Temp"]})]})]})}function Rk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([0,0,0]),[c,d]=I.useState([0,0,0]),[h,m]=I.useState([0,0,0]);function _(y){return U.get(e.files[n].data.saves,y)}function k(y,g){let j={};j[y]=g,U.assign(e.files[n].data.saves,j),e.files[n].saved=!1}I.useEffect(()=>{let y=e.getLoadedIndex();if(y==-1){t("/");return}U.has(e.files[y],"data.saves")||U.assign(e.files[y].data,{saves:{fort:[0,0,0],ref:[0,0,0],will:[0,0,0]}}),i(y),a(e.files[y].data.saves.fort),d(e.files[y].data.saves.ref),m(e.files[y].data.saves.will)},[]);let C=[0,0,0],N=[0,0,0],S=[0,0,0];if(n!=-1){if(U.has(e.files[n].data,"stats")){let y=e.files[n].data.stats.con,g=e.files[n].data.stats.dex,j=e.files[n].data.stats.wis;N[0]=Math.floor((U.sum(y)-10)/2),N[1]=Math.floor((U.sum(g)-10)/2),N[2]=Math.floor((U.sum(j)-10)/2)}U.has(e.files[n].data,"classes")&&e.files[n].data.classes.forEach(y=>{C[0]+=y.saves[0],C[1]+=y.saves[1],C[2]+=y.saves[2]}),S[0]=U.sum(s),S[1]=U.sum(c),S[2]=U.sum(h)}function w(y,g){y=="fort"&&a(g),y=="ref"&&d(g),y=="will"&&m(g),k(y,g)}function A(y,g,j){return n==-1?u.jsx("p",{children:"Loading..."}):u.jsx(Oe,{title:y,titleElements:u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Base"}),u.jsx("p",{className:"text-center m-0 p-0",children:C[j]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Mod"}),u.jsx("p",{className:"text-center m-0 p-0",children:N[j]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Misc"}),u.jsx("p",{className:"text-center m-0 p-0",children:S[j]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black bg-base-300 text-base-content rounded-md",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Total"}),u.jsx("p",{className:"text-center m-0 p-0",children:C[j]+N[j]+S[j]})]})]}),children:u.jsx(mt,{title:["Enhance","Misc","Temp"],id:g,value:_(g),min:[0,-100,-100],max:[100,100,100],color:"secondary",onChange:M=>w(g,M)})})}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Saving Throws"}),u.jsxs("div",{className:"main-container",children:[A("Fortitude","fort",0),A("Reflex","ref",1),A("Will","will",2)]})]})}function Lk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([0,0]),[c,d]=I.useState([0,0]),[h,m]=I.useState([0,0]),[_,k]=I.useState([0,0]),[C,N]=I.useState(0);function S(oe){return U.get(e.files[n].data.offense,oe)}function w(oe,Ne){let Tn={};Tn[oe]=Ne,U.assign(e.files[n].data.offense,Tn),e.files[n].saved=!1}I.useEffect(()=>{let oe=e.getLoadedIndex();if(oe==-1){t("/");return}U.has(e.files[oe],"data.offense")||U.assign(e.files[oe].data,{offense:{melee:[0,0],range:[0,0],cmb:[0,0],cmd:[0,0]}}),i(oe),a(e.files[oe].data.offense.melee),d(e.files[oe].data.offense.range),m(e.files[oe].data.offense.cmb),k(e.files[oe].data.offense.cmd)},[]);let A=[0,0,0,0],y=0,g=0,j=0,M=[0,0],O=0,L=0,F=0,$=[],Z=[],Y=oe=>Math.floor((oe-10)/2);if(n!=-1){if(U.has(e.files[n].data,"details")){let oe=e.files[n].data.details.size-4,Ne=Math.ceil(Math.pow(2,Math.abs(oe))/2);g=oe==0?0:oe>0?-Ne:Ne,j=-g}for(U.has(e.files[n].data,"stats")&&(M=[Y(U.sum(e.files[n].data.stats.str)),Y(U.sum(e.files[n].data.stats.dex))]),U.has(e.files[n].data,"classes")&&e.files[n].data.classes.forEach(oe=>{y+=oe.bab}),A=[U.sum(s),U.sum(c),U.sum(h),U.sum(_)],O=y,L=y+M[0]+g+A[0],F=y+M[1]+g+A[1];O>=0;)$.push(L),Z.push(F),O-=5,L-=5,F-=5}function ye(oe,Ne){oe=="melee"&&a(Ne),oe=="range"&&d(Ne),oe=="cmb"&&m(Ne),oe=="cmd"&&k(Ne),w(oe,Ne)}function Ve(oe,Ne,Tn,Or){if(n==-1)return u.jsx("p",{children:"Loading..."});let Nt=Ne[0]=="c"?j:g,G=Ne=="cmd"?M[0]+M[1]:M[Or],re=(Ne=="cmd"?10:0)+y+G+Nt+A[Tn];return u.jsxs(Oe,{title:`${oe}${Ne=="cmb"?C?" (Dex)":" (Str)":""}`,titleElements:u.jsxs("div",{className:"flex flex-row space-x-1",children:[Ne=="cmd"?u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Base"}),u.jsx("p",{className:"text-center m-0 p-0",children:"10"})]}):"",u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"BAB"}),u.jsx("p",{className:"text-center m-0 p-0",children:y})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Mod"}),u.jsx("p",{className:"text-center m-0 p-0",children:G})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Size"}),u.jsx("p",{className:"text-center m-0 p-0",children:Nt})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Misc"}),u.jsx("p",{className:"text-center m-0 p-0",children:A[Tn]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black bg-base-300 text-base-content rounded-md",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Total"}),u.jsx("p",{className:"text-center m-0 p-0",children:re})]})]}),children:[Ne=="cmb"?u.jsx(Ir,{title:"Modifier",id:"cmbstate",value:C,items:["Strength","Dexterity"],color:"secondary",onChange:N}):"",u.jsx(mt,{title:["Misc","Temp"],id:Ne,value:S(Ne),min:[-100,-100],max:[100,100],color:"secondary",onChange:le=>ye(Ne,le)})]})}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Offensive Stats"}),u.jsxs("div",{className:"main-container",children:[Ve("Melee","melee",0,0),Ve("Ranged","range",1,1),Ve("CMB","cmb",2,C),Ve("CMD","cmd",3,0),u.jsx(Ce,{title:"Melee Attacks",value:$.join(", ")}),u.jsx(Ce,{title:"Ranged Attacks",value:Z.join(", ")})]}),u.jsxs("div",{className:"msg-container",children:[u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Mods Used"}),": Melee (str), Ranged (dex)"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"CMD Calculation"}),": 10 + BAB + Str Mod + Dex Mod + Size + Misc + Temp"]})]})]})}function Tk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([0,0,0,0]);function c(j){U.assign(e.files[n].data.defense,j),e.files[n].saved=!1}I.useEffect(()=>{let j=e.getLoadedIndex();if(j==-1){t("/");return}U.has(e.files[j],"data.defense")||U.assign(e.files[j].data,{defense:[0,0,0,0]}),i(j),a(e.files[j].data.defense)},[]);let d=0,h=-1,m=0,_=0,k=0,C=0,N=0,S=0,w=0,A=0,y=j=>Math.floor((j-10)/2);if(n!=-1){if(U.has(e.files[n].data,"details")){let j=e.files[n].data.details.size-4,M=Math.ceil(Math.pow(2,Math.abs(j))/2);N=j==0?0:j>0?-M:M}U.has(e.files[n].data,"stats")&&(k=y(U.sum(e.files[n].data.stats.dex))),U.has(e.files[n].data,"armors")&&e.files[n].data.armors.forEach(j=>{j.active&&(d+=j.ac,m+=j.penalty,_+=j.spellfail,j.maxdex>=0&&(h<0||h>j.maxdex)&&(h=j.maxdex))}),h>=0?C=k>h?h:k:C=k,S=10+d+C+N+U.sum(s),w=10+C+N+s[0]+s[2]+s[3],A=10+d+N+s[1]+s[2]+s[3]}function g(j){a(j),c(j)}return n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Defensive Stats"}),u.jsxs("div",{className:"main-container",children:[u.jsx(Oe,{title:"Total AC",titleElements:u.jsx("div",{children:S}),children:u.jsxs("div",{className:"flex flex-row space-x-1 justify-evenly",children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Base"}),u.jsx("p",{className:"text-center m-0 p-0",children:"10"})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Armor"}),u.jsx("p",{className:"text-center m-0 p-0",children:d})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Dexterity"}),u.jsx("p",{className:"text-center m-0 p-0",children:C})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Size"}),u.jsx("p",{className:"text-center m-0 p-0",children:N})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Bonuses"}),u.jsx("p",{className:"text-center m-0 p-0",children:U.sum(s)})]})]})}),u.jsx(Oe,{title:"Touch AC",titleElements:u.jsx("div",{children:w}),children:u.jsxs("div",{className:"flex flex-row space-x-1 justify-evenly",children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Base"}),u.jsx("p",{className:"text-center m-0 p-0",children:"10"})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Dexterity"}),u.jsx("p",{className:"text-center m-0 p-0",children:C})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Size"}),u.jsx("p",{className:"text-center m-0 p-0",children:N})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Bonuses (-Natural)"}),u.jsx("p",{className:"text-center m-0 p-0",children:U.sum(s)-s[1]})]})]})}),u.jsx(Oe,{title:"Flat-Foot AC",titleElements:u.jsx("div",{children:A}),children:u.jsxs("div",{className:"flex flex-row space-x-1 justify-evenly",children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Base"}),u.jsx("p",{className:"text-center m-0 p-0",children:"10"})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Armor"}),u.jsx("p",{className:"text-center m-0 p-0",children:d})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Size"}),u.jsx("p",{className:"text-center m-0 p-0",children:N})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Bonuses (-Dodge)"}),u.jsx("p",{className:"text-center m-0 p-0",children:U.sum(s)-s[0]})]})]})}),u.jsx(Oe,{title:"AC Bonuses",children:u.jsx(mt,{title:["Dodge","Natural","Misc","Temp"],id:"bonuses",value:s,min:[0,0,-100,-100],max:[100,100,100,100],color:"secondary",onChange:g})}),u.jsx(Ce,{title:"Armor Check Penalty",value:m}),u.jsx(Ce,{title:"Maximum Dex",value:h!=-1?h:"N/A"}),u.jsx(Ce,{title:"Spell Failure",value:_})]}),u.jsxs("div",{className:"msg-container",children:[u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Armor Number"}),": Total of all protective items (under armor) that are marked as active."]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Dexterity Number"}),": If there is a Max Dex, the Dexterity value will be limited by the Max Dex."]})]})]})}function Mk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([0,0,0,0]),[c,d]=I.useState([0,0,0,0,0]),[h,m]=I.useState(0);function _(A){return U.get(e.files[n].data.miscstats,A)}function k(A,y){let g={};g[A]=y,U.assign(e.files[n].data.miscstats,g),e.files[n].saved=!1}I.useEffect(()=>{let A=e.getLoadedIndex();if(A==-1){t("/");return}U.has(e.files[A],"data.miscstats")||U.assign(e.files[A].data,{miscstats:{basespeed:[0,0,0,0],speed:[0,0,0,0,0],init:0,resist:[0,0,0,0,0],dr:"",sr:""}}),i(A),a(e.files[A].data.miscstats.basespeed),d(e.files[A].data.miscstats.speed),m(e.files[A].data.miscstats.init)},[]);let C=0,N=A=>Math.floor((A-10)/2);n!=-1&&U.has(e.files[n].data,"stats")&&(C=N(U.sum(e.files[n].data.stats.dex)));function S(A,y){A=="basespeed"&&a(y),A=="speed"&&d(y),A=="init"&&m(y),k(A,y)}function w(){return s[0]+c[0]}return n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Miscellaneous Stats"}),u.jsxs("div",{className:"main-container",children:[u.jsxs(Oe,{title:"Speeds",titleElements:u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Walk"}),u.jsx("p",{className:"text-center m-0 p-0",children:w()})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Run x4"}),u.jsx("p",{className:"text-center m-0 p-0",children:w()*4+c[1]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Run x5"}),u.jsx("p",{className:"text-center m-0 p-0",children:w()*5+c[1]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Swim"}),u.jsx("p",{className:"text-center m-0 p-0",children:(s[1]==0?Math.floor(w()/4):s[1])+c[2]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Climb"}),u.jsx("p",{className:"text-center m-0 p-0",children:(s[2]==0?Math.floor(w()/4):s[2])+c[3]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Fly"}),u.jsx("p",{className:"text-center m-0 p-0",children:s[3]+c[4]})]})]}),children:[u.jsx("h2",{children:"Base Speeds"}),u.jsx(mt,{title:["Walk","Swim","Climb","Fly"],id:"speed",value:_("basespeed"),min:[0,0,0,0],max:[1e3,1e3,1e3,1e3],color:"secondary",onChange:A=>S("basespeed",A)}),u.jsx("h2",{children:"Modifiers"}),u.jsx(mt,{title:["Walk","Run","Swim","Climb","Fly"],id:"speed",value:_("speed"),min:[-1e3,-1e3,-1e3,-1e3,-1e3],max:[1e3,1e3,1e3,1e3,1e3],color:"secondary",onChange:A=>S("speed",A)})]}),u.jsx(Oe,{title:"Initiative",titleElements:u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Dexterity"}),u.jsx("p",{className:"text-center m-0 p-0",children:C})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Misc"}),u.jsx("p",{className:"text-center m-0 p-0",children:h})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black bg-base-300 text-base-content rounded-md",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Total"}),u.jsx("p",{className:"text-center m-0 p-0",children:C+_("init")})]})]}),children:u.jsx(st,{title:"Misc",id:"init",value:_("init"),min:0,max:100,color:"secondary",onChange:A=>S("init",A)})}),u.jsxs(Oe,{title:"Resistances",children:[u.jsx(mt,{title:["Acid","Cold","Elec","Fire","Sonic"],id:"resist",value:_("resist"),min:[0,0,0,0,0],max:[1e3,1e3,1e3,1e3,1e3],color:"secondary",onChange:A=>S("resist",A)}),u.jsx(Re,{title:"DR",id:"dr",value:_("dr"),color:"secondary",onChange:A=>S("dr",A)}),u.jsx(Re,{title:"SR",id:"sr",value:_("sr"),color:"secondary",onChange:A=>S("sr",A)})]})]}),u.jsx("div",{className:"msg-container",children:u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Speeds"}),": Base speed is your walk speed. All other values are automatically derived (exception is fly) unless you override the value."]})})]})}function ys({title:e,id:t,value:n,color:i,placeholder:s,className:a,innerClass:c,outerClass:d,onChange:h}){h||console.warn("In order to get the text, you need to assign something to onChange...");let[m,_]=I.useState(n||""),[k,C]=I.useState(t||ut());I.useEffect(()=>{_(n||"")},[n]);function N(S){let w=S.target.value;_(w),h&&h(w)}return u.jsxs("div",{className:`textarea-cont ${a||""} ${d||""}`,children:[u.jsx("label",{htmlFor:k,className:`textarea-label lg-title ${tt[i]||tt.default} ${J[i]||J.default}`,children:e==0?"0":e||"Text Area"}),u.jsx("textarea",{id:k,name:k,value:m,placeholder:s,className:`textarea-box ${c||""} ${J[i]||J.default}`,onChange:N})]})}function Ok(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([]),[c,d]=I.useState(-1);function h(S){e.files[n].data.weapons=S,e.files[n].saved=!1}I.useEffect(()=>{let S=e.getLoadedIndex();if(S==-1){t("/");return}U.has(e.files[S],"data.weapons")||U.assign(e.files[S].data,{weapons:[]}),i(S),a(e.files[S].data.weapons)},[]);function m(){let S=[...s];S.push({_id:ut(),name:"New Weapon",hit:[],dmg:[],critical:"",range:"",type:"",ammo:"",info:""}),h(S),a(S)}function _(S){d(S),window.removeweapon.showModal()}function k(S){if(S==="ok"){let w=[...s];w.splice(c,1),h(w),a(w),d(-1)}}function C(S,w,A){let y=[...s];y[S][w]=A,a(y),h(y)}function N(){return n==-1?u.jsx("p",{children:"Loading..."}):s.length==0?u.jsx("p",{children:"No weapons have been added yet..."}):s.map((S,w)=>u.jsxs(Oe,{title:S.name,children:[u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Re,{title:"Name",id:`wep${w}name`,value:S.name,className:"flex-grow",color:"secondary",onChange:A=>C(w,"name",A)}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>_(w)})]}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(xr,{title:"To Hit",id:`wep${w}hit`,value:S.hit,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"hit",A)}),u.jsx(xr,{title:"Damage",id:`wep${w}dmg`,value:S.dmg,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"dmg",A)})]}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Re,{title:"Crit",id:`wep${w}crit`,value:S.critical,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"critical",A)}),u.jsx(Re,{title:"Rng",id:`wep${w}rng`,value:S.range,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"range",A)})]}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Re,{title:"Type",id:`wep${w}type`,value:S.type,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"type",A)}),u.jsx(Re,{title:"Ammo",id:`wep${w}ammo`,value:S.ammo,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"ammo",A)})]}),u.jsx(ys,{title:"Notes",id:`wep${w}info`,value:S.info,color:"secondary",onChange:A=>C(w,"info",A)})]},`wep-${S._id}`))}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Weapons"}),u.jsx("div",{className:"main-container",children:u.jsx(X,{color:"primary",onClick:m,children:"Add Weapon"})}),u.jsx("div",{className:"main-container",children:N()}),u.jsxs(sl,{id:"removeweapon",title:"Confirm Remove?",type:wn.okcancel,onClose:S=>k(S),children:[u.jsx("p",{children:"Are you sure you wish to remove this weapon?"}),u.jsx("p",{children:"This action is permanent and can only be reverted by re-loading the character data."})]})]})}function Fk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([]),[c,d]=I.useState(-1);function h(S){e.files[n].data.armors=S,e.files[n].saved=!1}I.useEffect(()=>{let S=e.getLoadedIndex();if(S==-1){t("/");return}U.has(e.files[S],"data.armors")||U.assign(e.files[S].data,{armors:[]}),i(S),a(e.files[S].data.armors)},[]);function m(){let S=[...s];S.push({_id:ut(),name:"New Armor",active:!1,ac:0,maxdex:-1,penalty:0,spellfail:0,info:""}),h(S),a(S)}function _(S){d(S),window.removearmor.showModal()}function k(S){if(S==="ok"){let w=[...s];w.splice(c,1),h(w),a(w),d(-1)}}function C(S,w,A){let y=[...s];y[S][w]=A,a(y),h(y)}function N(){return n==-1?u.jsx("p",{children:"Loading..."}):s.length==0?u.jsx("p",{children:"No armors have been added yet..."}):s.map((S,w)=>u.jsxs(Oe,{title:S.name,titleElements:u.jsx(X,{color:S.active?"success":"error",className:`pointer-events-auto ${S.active?"bi-check-square":"bi-square"}`,onClick:()=>C(w,"active",!S.active)}),children:[u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Re,{title:"Name",id:`arm${w}name`,value:S.name,className:"flex-grow",color:"secondary",onChange:A=>C(w,"name",A)}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>_(w)})]}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(st,{title:"AC",id:`arm${w}ac`,value:S.ac,min:0,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"ac",A)}),u.jsx(st,{title:"Max Dex",id:`arm${w}max`,value:S.maxdex,min:-1,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"maxdex",A)})]}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(st,{title:"Penalty",id:`arm${w}pen`,value:S.penalty,min:0,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"penalty",A)}),u.jsx(st,{title:"Spell Fail",id:`arm${w}fail`,value:S.spellfail,min:0,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"spellfail",A)})]}),u.jsx(ys,{title:"Notes",id:`arm${w}info`,value:S.info,color:"secondary",onChange:A=>C(w,"info",A)})]},`arm-${S._id}`))}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Armors"}),u.jsx("div",{className:"main-container",children:u.jsx(X,{color:"primary",onClick:m,children:"Add Armor"})}),u.jsx("div",{className:"main-container",children:N()}),u.jsxs("div",{className:"msg-container",children:[u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Max Dex:"})," If the armor has no max dex penalty, set the value to a negative value."]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Note:"})," Before the armor piece becomes active on the defensive stats page, you must click on the button in the title."]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Inactive:"})," ",u.jsx(X,{color:"error",className:"bi-square"})," ",u.jsx("span",{className:"font-bold",children:"Active:"})," ",u.jsx(X,{color:"success",className:"bi-check-square"})]})]}),u.jsxs(sl,{id:"removearmor",title:"Confirm Remove?",type:wn.okcancel,onClose:S=>k(S),children:[u.jsx("p",{children:"Are you sure you wish to remove this armor?"}),u.jsx("p",{children:"This action is permanent and can only be reverted by re-loading the character data."})]})]})}function Dk({title:e,id:t,value:n,color:i,className:s,onChange:a}){n=n||[0,0,0,0,!1,0,0],a||console.warn("In order to get the Skill Value, you need to assign something to onChange...");let[c,d]=I.useState([n[4],e||"",n[5],n[6]]);I.useState(t||ut());function h(_,k){let C=[...c];C[k]=_,d(C),a&&a(C)}let m=(c[0]&&c[2]>0?3:0)+c[2]+n[3]+c[3];return(n[0]&1)==1&&(m-=n[1]),(n[0]&2)==2&&c[2]<=0&&(m=0),u.jsxs("div",{className:`sr-cont ${s||""}`,children:[u.jsx("div",{className:"col-span-1 sr-center",children:u.jsx("input",{type:"checkbox",checked:c[0],onChange:_=>h(_.target.checked,0)})}),u.jsxs("div",{className:"col-span-3 sr-label",children:[c[1]," ",(n[0]&1)==1?"*":""," ",(n[0]&2)==2?u.jsx(u.Fragment,{children:"†"}):""]}),u.jsx("div",{className:"col-span-2 sr-label text-right",children:va[n[2]]}),u.jsx("div",{className:`col-span-1 sr-input sr-center ${J[i]||J.default}`,children:(n[0]&2)==2&&c[2]<=0?"-":m}),u.jsx("div",{className:`col-span-2 sr-input ${J[i]||J.default}`,children:u.jsx("input",{type:"number",value:c[2],min:0,max:100,onChange:_=>h(parseInt(_.target.value),2)})}),u.jsx("div",{className:`col-span-1 sr-input sr-center ${J[i]||J.default}`,children:n[3]}),u.jsx("div",{className:`col-span-2 sr-input ${J[i]||J.default}`,children:u.jsx("input",{type:"number",value:c[3],min:-100,max:100,onChange:_=>h(parseInt(_.target.value),3)})})]})}function zk({title:e,id:t,value:n,color:i,className:s,onChange:a,onDelete:c}){n=n||[0,0,!1,0,0],a||console.warn("In order to get the Skill Value, you need to assign something to onChange..."),c||console.warn("onDelete must be set or items cannot be removed...");let[d,h]=I.useState([n[2],e||"",n[3],n[4]]);I.useState(t||ut());function m(k,C){let N=[...d];N[C]=k,h(N),a&&a(N)}let _=(d[0]&&d[2]>0?3:0)+d[2]+n[1]+d[3];return(n[0]&2)==2&&d[2]<=0&&(_=0),u.jsxs("div",{className:`sr-cont ${s||""}`,children:[u.jsx("div",{className:"col-span-1 sr-center",children:u.jsx("input",{type:"checkbox",checked:d[0],onChange:k=>m(k.target.checked,0)})}),u.jsx("div",{className:`col-span-4 sr-input ${J[i]||J.default}`,children:u.jsx("input",{type:"text",value:d[1],onChange:k=>m(k.target.value,1)})}),u.jsx("div",{className:`col-span-1 sr-input sr-center ${J[i]||J.default}`,children:(n[0]&2)==2&&d[2]<=0?"-":_}),u.jsx("div",{className:`col-span-2 sr-input ${J[i]||J.default}`,children:u.jsx("input",{type:"number",value:d[2],min:0,max:100,onChange:k=>m(parseInt(k.target.value),2)})}),u.jsx("div",{className:`col-span-1 sr-input sr-center ${J[i]||J.default}`,children:n[1]}),u.jsx("div",{className:`col-span-2 sr-input ${J[i]||J.default}`,children:u.jsx("input",{type:"number",value:d[3],min:-100,max:100,onChange:k=>m(parseInt(k.target.value),3)})}),u.jsx("div",{className:"col-span-1 sr-center",children:u.jsx(X,{color:"error",className:"bi-trash text-xs px-1 py-0.5",onClick:c})})]})}function Uk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([]),[c,d]=I.useState([]);function h(L,F,$){let Z={};Z[L]=$,F?U.assign(e.files[n].data.custskills,Z):U.assign(e.files[n].data.skills,Z),e.files[n].saved=!1}I.useEffect(()=>{let L=e.getLoadedIndex();if(L==-1){t("/");return}U.has(e.files[L],"data.skills")||U.assign(e.files[L].data,{skills:{appr:[!1,0,0],acro:[!1,0,0],bluf:[!1,0,0],clim:[!1,0,0],dipl:[!1,0,0],disd:[!1,0,0],disg:[!1,0,0],esca:[!1,0,0],fly:[!1,0,0],hana:[!1,0,0],heal:[!1,0,0],inti:[!1,0,0],ling:[!1,0,0],perc:[!1,0,0],ride:[!1,0,0],senm:[!1,0,0],sleh:[!1,0,0],spel:[!1,0,0],stea:[!1,0,0],surv:[!1,0,0],swim:[!1,0,0],usmd:[!1,0,0]}}),U.has(e.files[L],"data.custskills")||U.assign(e.files[L].data,{custskills:{craf:[],know:[],perf:[],prof:[]}}),i(L);let F=e.files[L].data.skills,$=e.files[L].data.custskills,Z=[],Y=[];U.forEach(F,(ye,Ve)=>{Z.push([Ve,ye])}),U.forEach($,(ye,Ve)=>{Y.push([Ve,ye])}),a(Z),d(Y)},[]);function m(L){for(let F=0;F{S[$]=Yg(U.sum(U.get(L,va[$])))})}U.has(e.files[n].data,"armors")&&e.files[n].data.armors.forEach(L=>{L.active&&(w+=L.penalty)}),U.has(e.files[n].data,"classes")&&e.files[n].data.classes.forEach(F=>{let $=F.skillnum+S[3];$<1&&($=1),A+=$*F.level+F.favclass[1]}),s.forEach(L=>{y+=L[1][1]}),c.forEach(L=>{L[1].forEach(F=>{y+=F.stats[1]})})}function g(L,F){let $=[...s];$[m(L)][1]=[F[0],F[2],F[3]],a($),h(L,!1,$[m(L)][1])}function j(){return jk.map(L=>{let F=s[m(L.k)][1];return u.jsx(Dk,{title:L.v,id:L.k,value:[L.f,w,L.s,S[L.s],F[0],F[1],F[2]],color:"secondary",onChange:$=>g(L.k,$)},L.k)})}function M(L){return c[_(L.k)][1].map((F,$)=>u.jsx(zk,{title:F.name,id:`${L.k}:${$}`,value:[L.f,S[L.s],F.stats[0],F.stats[1],F.stats[2]],className:"pr-2",color:"secondary",onChange:Z=>N(L.k,$,Z),onDelete:()=>C(L.k,$)},`${L.k}-${F._id}`))}function O(){return Ek.map(L=>u.jsxs("div",{className:"rounded-md border-2 border-primary",children:[u.jsxs("div",{className:"flex flex-row p-1 items-center",children:[u.jsxs("div",{className:"font-bold flex-grow",children:[L.v," ",(L.f&1)==1?"*":""," ",(L.f&2)==2?u.jsx(u.Fragment,{children:"†"}):""," (",va[L.s],")"]}),u.jsx(X,{color:"success",className:"text-xs bi-plus-square",onClick:()=>k(L.k)})]}),u.jsxs("div",{className:"grid grid-cols-12 gap-1 text-xs bg-primary text-primary-content",children:[u.jsx("div",{className:"col-start-6 col-span-1 text-center",children:"TTL"}),u.jsx("div",{className:"col-span-2 text-center",children:"Ranks"}),u.jsx("div",{className:"col-span-1 text-center",children:"Mod"}),u.jsx("div",{className:"col-span-2 text-center",children:"Misc"}),u.jsx("div",{className:"col-span-1",children:" "})]}),M(L)]},L.k))}return n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Skills"}),u.jsxs("div",{className:"main-container",children:[u.jsx(Ce,{title:"Total Ranks",value:A}),u.jsx(Ce,{title:"Used Ranks",value:y})]}),u.jsxs("div",{className:"main-container space-y-0 rounded-md border-2 border-primary",children:[u.jsxs("div",{className:"grid grid-cols-12 gap-1 text-xs bg-primary text-primary-content rounded-t-sm",children:[u.jsx("div",{className:"col-start-7 col-span-1 text-center",children:"TTL"}),u.jsx("div",{className:"col-span-2 text-center",children:"Ranks"}),u.jsx("div",{className:"col-span-1 text-center",children:"Mod"}),u.jsx("div",{className:"col-span-2 text-center",children:"Misc"})]}),j()]}),u.jsx("div",{className:"main-container",children:O()}),u.jsxs("div",{className:"msg-container",children:[u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"*"}),": Armor Check Penalty (subtracts ",w,")"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"†"}),": Cannot Use Untrained"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Total Skills"}),": Sum of((Class Skill # + INT Mod) * Class Level) + FC Skill Total (min 1 per level)"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Used Skills"}),": Sum of(Skill Ranks + Custom Skill Ranks)"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Total Points in Skill"}),": Ranks + Ability Mod + Misc + (If Class and Rank == 3) - (If STR or DEX == Armor Check Penalty)"]})]})]})}function Wk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([0,1]);function c(N){return U.get(e.files[n].data.wealth,N)}function d(N){e.files[n].data.exp=N,e.files[n].saved=!1}function h(N,S){let w={};w[N]=S,U.assign(e.files[n].data.wealth,w),e.files[n].saved=!1}I.useEffect(()=>{let N=e.getLoadedIndex();if(N==-1){t("/");return}U.has(e.files[N],"data.exp")||U.assign(e.files[N].data,{exp:[0,1]}),U.has(e.files[N],"data.wealth")||U.assign(e.files[N].data,{wealth:{plat:[0,0],gold:[0,0],silv:[0,0],copp:[0,0],othe:""}}),i(N),a(e.files[N].data.exp)},[]);let m=0,_=0;do _+=1;while(S0[s[1]][_]<=s[0]);m=S0[s[1]][_];function k(N,S){let w=[...s];w[N]=S,a(w),d(w)}function C(N,S){h(N,S)}return n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Experience and Wealth"}),u.jsx("h2",{className:"mt-2",children:"Experience"}),u.jsxs("div",{className:"main-container",children:[u.jsx(st,{title:"Current XP",id:"xp",value:s[0],min:0,onChange:N=>k(0,N)}),u.jsx(Ce,{title:"Next Level",value:m}),u.jsx(Ir,{title:"Progression",id:"progress",value:s[1],items:["Slow","Medium","Fast"],onChange:N=>k(1,N)}),u.jsx(Ce,{title:"Current Level",value:_})]}),u.jsx("h2",{className:"mt-2",children:"Wealth"}),u.jsxs("div",{className:"main-container",children:[u.jsx(Ce,{title:"Platinum",value:u.jsx(mt,{title:["Carried","Stored"],id:"platinum",value:c("plat"),min:[0,0],max:[99999999,99999999],className:"flex-grow",color:"secondary",onChange:N=>C("plat",N)})}),u.jsx(Ce,{title:"Gold",value:u.jsx(mt,{title:["Carried","Stored"],id:"gold",value:c("gold"),min:[0,0],max:[99999999,99999999],className:"flex-grow",color:"secondary",onChange:N=>C("gold",N)})}),u.jsx(Ce,{title:"Silver",value:u.jsx(mt,{title:["Carried","Stored"],id:"silver",value:c("silv"),min:[0,0],max:[99999999,99999999],className:"flex-grow",color:"secondary",onChange:N=>C("silv",N)})}),u.jsx(Ce,{title:"Copper",value:u.jsx(mt,{title:["Carried","Stored"],id:"copper",value:c("copp"),min:[0,0],max:[99999999,99999999],className:"flex-grow",color:"secondary",onChange:N=>C("copp",N)})}),u.jsx(ys,{title:"Other (in gp)",id:"other",value:c("othe"),onChange:N=>C("othe",N)})]})]})}function Bk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1);function s(c){return U.get(e.files[n].data.abilities,c)}function a(c,d){let h={};h[c]=d,U.assign(e.files[n].data.abilities,h),e.files[n].saved=!1}return I.useEffect(()=>{let c=e.getLoadedIndex();if(c==-1){t("/");return}U.has(e.files[c],"data.abilities")||U.assign(e.files[c].data,{abilities:{feats:[],features:[],racial:[],misc:[]}}),i(c)},[]),n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Feats and Abilities"}),u.jsxs("div",{className:"main-container",children:[u.jsx(xr,{title:"Feats",id:"feats",value:s("feats"),onChange:c=>a("feats",c)}),u.jsx(xr,{title:"Class Features",id:"features",value:s("features"),onChange:c=>a("features",c)}),u.jsx(xr,{title:"Racial",id:"racial",value:s("racial"),onChange:c=>a("racial",c)}),u.jsx(xr,{title:"Miscellaneous",id:"misc",value:s("misc"),onChange:c=>a("misc",c)})]})]})}function $k(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([]),[c,d]=I.useState(-1);function h(w){e.files[n].data.equipment=w,e.files[n].saved=!1}I.useEffect(()=>{let w=e.getLoadedIndex();if(w==-1){t("/");return}U.has(e.files[w],"data.equipment")||U.assign(e.files[w].data,{equipment:[]}),i(w),a(e.files[w].data.equipment)},[]);let m=0;s.forEach(w=>{m+=w.weight*w.num});function _(){let w=[...s];w.push({_id:ut(),name:"New Item",ref:"",num:0,weight:0,info:""}),h(w),a(w)}function k(w){d(w),window.removequip.showModal()}function C(w){if(w==="ok"){let A=[...s];A.splice(c,1),h(A),a(A),d(-1)}}function N(w,A,y){let g=[...s];g[w][A]=y,a(g),h(g)}function S(){return n==-1?u.jsx("p",{children:"Loading..."}):s.length==0?u.jsx("p",{children:"No items have been added yet..."}):s.map((w,A)=>u.jsxs(Oe,{title:w.name,titleElements:u.jsx("div",{children:w.num}),children:[u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Re,{title:"Name",id:`quip${A}name`,value:w.name,className:"flex-grow",color:"secondary",onChange:y=>N(A,"name",y)}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>k(A)})]}),u.jsx(Re,{title:"Ref",id:`quip${A}ref`,value:w.ref,color:"secondary",onChange:y=>N(A,"ref",y)}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(st,{title:"# of",id:`quip${A}num`,value:w.num,min:0,max:5e3,className:"flex-grow w-1/2",color:"secondary",onChange:y=>N(A,"num",y)}),u.jsx(st,{title:"Weight",id:`quip${A}weight`,value:w.weight,min:0,max:1e4,className:"flex-grow w-1/2",color:"secondary",onChange:y=>N(A,"weight",y)})]}),u.jsx(ys,{title:"Notes",id:`quip${A}info`,value:w.info,color:"secondary",onChange:y=>N(A,"info",y)})]},`class-${w._id}`))}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Equipment"}),u.jsxs("div",{className:"main-container",children:[u.jsx(X,{color:"primary",onClick:_,children:"Add Item"}),u.jsx(Ce,{title:"Total Weight",value:m}),S()]}),u.jsxs(sl,{id:"removequip",title:"Confirm Remove?",type:wn.okcancel,onClose:w=>C(w),children:[u.jsx("p",{children:"Are you sure you wish to remove this item?"}),u.jsx("p",{children:"This action is permanent and can only be reverted by re-loading the character data."})]})]})}function Hk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([]),[c,d]=I.useState(-1);function h(g){e.files[n].data.spellbook=g,e.files[n].saved=!1}I.useEffect(()=>{let g=e.getLoadedIndex();if(g==-1){t("/");return}U.has(e.files[g],"data.spellbook")||U.assign(e.files[g].data,{spellbook:[]}),i(g),a(e.files[g].data.spellbook)},[]);let m=[],_=[0,0,0,0,0,0];if(n!=-1&&(U.has(e.files[n],"data.classes")&&e.files[n].data.classes.forEach(g=>{m.push({_id:g._id,name:g.name,level:g.level})}),U.has(e.files[n].data,"stats"))){let g=e.files[n].data.stats;_.forEach((j,M)=>{_[M]=U.sum(U.get(g,va[M]))})}function k(g){for(let j=0;j{let M=k(g.class_id);return u.jsxs(Oe,{title:`${m[M].name}'s Spellbook`,children:[u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Ir,{title:"Class",id:`sb-${g._id}-class`,value:M,items:m.map(O=>O.name),className:"flex-grow",color:"secondary",onChange:O=>w(j,"class_id",m[O]._id)}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>N(j)})]}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Ir,{title:"Stat",id:`sb-${g._id}-score`,value:g.score,items:["Intelligence","Wisdom","Charisma"],className:"w-2/3",color:"secondary",onChange:O=>w(j,"score",O)}),u.jsx(Ce,{title:"CL",value:m[M].level,color:"secondary",className:"w-1/3"})]}),u.jsx(Oe,{title:"Spell Slots",color:"secondary",children:Array(10).fill(0).map((O,L)=>{let F=Yg(_[g.score+3]),$=Math.ceil(F/4)+(F%4==0?1:0)-Math.ceil((L-F%4)/4);L==0&&($=0);let Z=10+L+F,Y=$+g.stats[L][0]+g.stats[L][1];return _[g.score+3]<10+L?u.jsx(Ce,{title:L,value:"Cannot cast spells of this level...",color:"accent"},`${g._id}${L}`):u.jsx(Ce,{title:L,color:"accent",value:u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"DC"}),u.jsx("p",{className:"text-center m-0 p-0",children:Z})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Total"}),u.jsx("p",{className:"text-center m-0 p-0",children:Y})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Mod"}),u.jsx("p",{className:"text-center m-0 p-0",children:L==0?"-":$})]}),u.jsx(mt,{title:["Class","Misc","Known"],id:`ss-${L}`,value:s[j].stats[L],color:"info",onChange:ye=>A(j,L,ye)})]})},`${g._id}${L}`)})}),u.jsxs(Oe,{title:"Distances",color:"secondary",children:[u.jsx(Ce,{title:"Long",value:400+40*m[M].level,color:"accent"}),u.jsx(Ce,{title:"Medium",value:100+10*m[M].level,color:"accent"}),u.jsx(Ce,{title:"Short",value:25+5*Math.ceil(m[M].level/2),color:"accent"})]}),u.jsx(xr,{title:"Spells",id:`sb-${g._id}-book`,value:g.book,color:"secondary",onChange:O=>w(j,"book",O)})]},g._id)})}return n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Spellbook"}),u.jsxs("div",{className:"main-container",children:[u.jsx(X,{color:"primary",onClick:C,children:"Add Spellbook"}),y()]}),u.jsxs("div",{className:"msg-container",children:[u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Save DC"}),": 10 + Spell Level + Ability Mod"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Total Spells"}),": Can cast; Class Spells + Spell Mod Calc + Misc"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Spell Mod Calculation"}),": Mod = Ability Mod, Lv = Spell Level; (⌈Mod / 4⌉ + (((Mod % 4) == 0) ? 1 : 0)) - ⌈(Lv - (Mod % 4)) / 4⌉"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Distances"}),": Cl = Caster Level; Long = 400 + 40 * Cl, Medium = 100 + 10 * Cl, Short = 25 + 5 * ⌈Cl / 2⌉"]})]}),u.jsxs(sl,{id:"removebook",title:"Confirm Remove?",color:"warning",type:wn.okcancel,onClose:g=>S(g),children:[u.jsx("p",{children:"Are you sure you wish to remove this spellbook?"}),u.jsx("p",{children:"This action is permanent and can only be reverted by re-loading the character data."})]})]})}function Vk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([]),[c,d]=I.useState(-1);function h(S){e.files[n].data.notes=S,e.files[n].saved=!1}I.useEffect(()=>{let S=e.getLoadedIndex();if(S==-1){t("/");return}U.has(e.files[S],"data.notes")||U.assign(e.files[S].data,{notes:[]}),i(S),a(e.files[S].data.notes)},[]);function m(){let S=[...s];S.push({_id:ut(),name:"New Note",info:""}),h(S),a(S)}function _(S){d(S),window.removenote.showModal()}function k(S){if(S==="ok"){let w=[...s];w.splice(c,1),h(w),a(w),d(-1)}}function C(S,w,A){let y=[...s];y[S][w]=A,a(y),h(y)}function N(){return n==-1?u.jsx("p",{children:"Loading..."}):s.length==0?u.jsx("p",{children:"No notes have been added yet..."}):s.map((S,w)=>u.jsxs(Oe,{title:S.name,children:[u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Re,{title:"Name",id:`note${w}name`,value:S.name,className:"flex-grow",color:"secondary",onChange:A=>C(w,"name",A)}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>_(w)})]}),u.jsx(ys,{title:"Notes",id:`note${w}info`,value:S.info,color:"secondary",onChange:A=>C(w,"info",A)})]},`note-${S._id}`))}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Notes"}),u.jsx("div",{className:"main-container",children:u.jsx(X,{color:"primary",onClick:m,children:"Add Note"})}),u.jsx("div",{className:"main-container",children:N()}),u.jsxs(sl,{id:"removenote",title:"Confirm Remove?",color:"warning",type:wn.okcancel,onClose:S=>k(S),children:[u.jsx("p",{children:"Are you sure you wish to remove this note?"}),u.jsx("p",{children:"This action is permanent and can only be reverted by re-loading the character data."})]})]})}function Gk(e){let t=ni(),n=s=>t.pathname==`/tools/${s}`;function i(){switch(!0){case n("dice"):return u.jsx(Qk,{});case n("stats"):return u.jsx(Kk,{});default:return u.jsx("p",{children:"Please select a tool from the buttons above..."})}}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Tools"}),u.jsxs("div",{className:"base-size flex flex-row justify-evenly my-2",children:[u.jsx(X,{as:bi,to:"/tools/dice",children:"Dice Roller"}),u.jsx(X,{as:bi,to:"/tools/stats",children:"Stats Roller"})]}),i()]})}function Qk(){let[e,t]=I.useState(1),[n,i]=I.useState(5),[s,a]=I.useState(0),[c,d]=I.useState(0),[h,m]=I.useState(0),[_,k]=I.useState(0),[C,N]=I.useState(0),[S,w]=I.useState(0),[A,y]=I.useState(0),[g,j]=I.useState(0),[M,O]=I.useState(""),L=[4,6,8,10,12,20,100,0];function F(Y,ye){t(Y),i(ye)}function $(){t(1),i(5),a(0),d(0),m(0),k(0),N(0),w(0),y(0),j(0),O("")}function Z(){let Y=0,ye="";for(let Ve=0;Ve0&&(Y*=A),h>0&&(Y+=h),C>0&&(Y-=C),ye+=`Roll (${Ve+1}): ${oe}${A>0?` x ${A}`:""}${h>0?` + ${h}`:""}${C>0?` - ${C}`:""} (${Y}) +caused by: ${yn.fullStack(n)}`:t.stack}static info(t){Pc(t);const n={},i=yn.cause(t);return i&&Object.assign(n,yn.info(i)),t._info&&Object.assign(n,t._info),n}cause(){return yn.cause(this)}toString(){let t=this.name||this.constructor.name||this.constructor.prototype.name;return this.message&&(t=`${t}: ${this.message}`),t}}const bg="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Yi=32,w0=0xffffffffffff,hk=10,pk=16,zi=Object.freeze({source:"ulid"});function mk(e){const t=e||vk(),n=t&&(t.crypto||t.msCrypto)||null;if(typeof(n==null?void 0:n.getRandomValues)=="function")return()=>{const i=new Uint8Array(1);return n.getRandomValues(i),i[0]/255};if(typeof(n==null?void 0:n.randomBytes)=="function")return()=>n.randomBytes(1).readUInt8()/255;throw new yn({info:{code:"PRNG_DETECT",...zi}},"Failed to find a reliable PRNG")}function vk(){return yk()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function gk(e,t){let n="";for(;e>0;e--)n=wk(t)+n;return n}function xk(e,t){if(isNaN(e))throw new yn({info:{code:"ENC_TIME_NAN",...zi}},`Time must be a number: ${e}`);if(e>w0)throw new yn({info:{code:"ENC_TIME_SIZE_EXCEED",...zi}},`Cannot encode a time larger than ${w0}: ${e}`);if(e<0)throw new yn({info:{code:"ENC_TIME_NEG",...zi}},`Time must be positive: ${e}`);if(Number.isInteger(e)===!1)throw new yn({info:{code:"ENC_TIME_TYPE",...zi}},`Time must be an integer: ${e}`);let n,i="";for(let s=t;s>0;s--)n=e%Yi,i=bg.charAt(n)+i,e=(e-n)/Yi;return i}function yk(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function wk(e){let t=Math.floor(e()*Yi);return t===Yi&&(t=Yi-1),bg.charAt(t)}function ut(e,t){const n=t||mk(),i=isNaN(e)?Date.now():e;return xk(i,hk)+gk(pk,n)}function Sk({className:e,innerClass:t,outerClass:n,color:i,title:s,children:a}){return u.jsxs("div",{className:`${e||""} ${n||""} card card-compact border border-base-content shadow-md rounded-md`,children:[u.jsx("div",{className:`card-title lg-title rounded-t-md ${tt[i]||tt.default}`,children:s==0?"0":s||"Dialog"}),u.jsx("div",{className:`${t||""} flex flex-col rounded-b-md -mt-1`,children:a})]})}function Re({title:e,id:t,value:n,placeholder:i,color:s,className:a,innerClass:c,outerClass:d,onChange:h}){h||console.warn("In order to get the text, you need to assign something to onChange...");let[m,_]=I.useState(n==0?"0":n||""),[k,C]=I.useState(t||ut());I.useEffect(()=>{_(n||"")},[n]);function N(S){let w=S.target.value;_(w),h&&h(w)}return u.jsxs("div",{className:`text-cont ${a||""} ${d||""}`,children:[u.jsx("label",{htmlFor:k,className:`text-label lg-title ${tt[s]||tt.default} ${J[s]||J.default}`,children:e==0?"0":e||"Text"}),u.jsx("input",{type:"text",id:k,name:k,value:m,placeholder:i,className:`text-input ${c} ${J[s]||J.default}`,onChange:N})]})}function sl({id:e,title:t,color:n,className:i,innerClass:s,outerClass:a,children:c,type:d,onClose:h}){const[m,_]=I.useState("");U.isEmpty(e)&&console.warn("You must supply an id property for a Modal component, or else you will not be able to call it via window.id.showModal()"),h||console.warn("In order to get a return value, you must provide an onClose property");function k(){switch(d){case wn.okcancel:return u.jsxs(u.Fragment,{children:[u.jsx(X,{color:"primary",value:"ok",className:"flex-grow",children:"OK"}),u.jsx(X,{color:"error",value:"cancel",className:"flex-grow",children:"Cancel"})]});case wn.yesno:return u.jsxs(u.Fragment,{children:[u.jsx(X,{color:"primary",value:"yes",className:"flex-grow",children:"YES"}),u.jsx(X,{color:"error",value:"no",className:"flex-grow",children:"NO"})]});default:return u.jsx(X,{color:"primary",value:"ok",className:"flex-grow",children:"OK"})}}function C(N){h&&(d==wn.prompt&&N.target.returnValue==="ok"?h(m):h(N.target.returnValue)),_("")}return u.jsx("dialog",{id:e,className:`${i||""} ${a||""} modal`,onClose:N=>C(N),children:u.jsxs("form",{method:"dialog",className:"modal-box border border-black",children:[u.jsxs("div",{className:`flex flex-row p-1 items-center rounded-t-lg border ${tt[n]||tt.default} ${J[n]||J.default}`,children:[u.jsx("div",{className:"lg-title flex-grow",children:t==0?"0":t||"Modal"}),u.jsx(X,{className:`bi-x-lg border ${J[n]||J.default}`,color:"error",value:"close"})]}),u.jsxs("div",{className:`${s||""} rounded-b-lg border border-t-0 p-0.5 ${J[n]||J.default}`,children:[c||u.jsx("p",{children:"Dialog Message"}),d==wn.prompt&&u.jsx("div",{className:"flex mt-3",children:u.jsx(Re,{title:"Value",placeholder:"Enter new value...",outerClass:"flex-grow",value:m,color:"secondary",onChange:N=>_(N)})})]}),u.jsx("div",{className:"modal-action",children:k()})]})})}const wn={ok:0,okcancel:1,yesno:2,prompt:3};function Ck(){let e=I.useContext(qe),[t,n]=I.useState([]);I.useEffect(()=>{e.setFiles([...e.files]),n(new Array(e.files.length).fill(!1))},[]);function i(C){let N=[...t];N[C]=!N[C],n(N)}function s(C){if(!U.isEmpty(C)&&C!=="close"){let N=[...e.files];N.push({_id:ut(),title:C,loaded:!1,saved:!1,data:{},version:ma.CurrentVersion});let S=[...t];S.push(!1),e.setFiles(N),n(S)}}function a(C){let N=C.target.files;for(let S=0;S{let y=w.result,g=null;try{if(g=JSON.parse(y),!U.has(g,"title")||!U.has(g,"data"))throw"Invalid data format";let j=ma.Upgrade(g);U.assign(g,{_id:ut(),loaded:!1,saved:!j}),e.setFiles([...e.files,g]);let M=[...t];M.push(!1),n(M)}catch(j){console.error("DEAL WITH NON-STANDARD FILE LOADS",j)}}),w.readAsText(N[S])}}function c(C){if(!U.isNil(e.files[C])){let N=e.files.map((S,w)=>(S.loaded?S.loaded=!1:S.loaded=C==w,S));e.setFiles(N)}}function d(C){let N={...e.files[C]};U.unset(N,"loaded"),U.unset(N,"saved"),U.unset(N,"_id");let S=document.createElement("a");S.href=`data:application/json;charset=utf8,${encodeURIComponent(JSON.stringify(N,null," "))}`,S.download=`${N.title}.json`,S.style.display="none",document.body.appendChild(S),S.click(),document.body.removeChild(S),e.files[C].saved=!0,e.setFiles([...e.files])}function h(C){let N=[...e.files];N.splice(C,1),e.setFiles(N)}function m(C,N,S){if(U.has(e.files[C].data,S))return u.jsxs("div",{className:"flex flex-row items-center space-x-3 p-1 last:rounded-b-md hover:bg-gradient-to-r hover:from-slate-300 hover:to-white",children:[u.jsx("div",{className:"flex-grow",children:N}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>_(C,S),children:" Clear"})]})}function _(C,N){U.unset(e.files[C].data,N)}function k(){return e.files.length==0?u.jsx("p",{children:"No characters have been loaded or created..."}):e.files.map((C,N)=>u.jsxs("div",{className:"border border-primary rounded-md p-1 space-y-1",children:[u.jsxs("div",{className:"flex flex-row items-center space-x-2",children:[u.jsx("div",{className:"flex-grow",onClick:()=>console.info(e.files[N]),children:C.title}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(X,{color:"primary",className:"bi-eraser",onClick:()=>i(N)}),u.jsx(X,{color:C.loaded?"disabled":"secondary",className:`${C.loaded?"bi-square-fill":"bi-caret-right-fill"} pointer-events-auto`,onClick:()=>c(N)}),u.jsx(X,{color:C.saved?"disabled":"success",className:"bi-save-fill pointer-events-auto",onClick:()=>d(N)}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>h(N)})]})]}),t[N]&&u.jsxs(Sk,{title:"Erase Data",color:"error",children:[m(N,"Character Details","details"),m(N,"Ability Scores","stats"),m(N,"Classes","classes"),m(N,"Health","health"),m(N,"Saving Throws","saves"),m(N,"Offensive Stats","offense"),m(N,"Defensive Stats","defense"),m(N,"Miscellaneous Stats","miscstats"),m(N,"Weapons","weapons"),m(N,"Armor","armors"),m(N,"Skills","skills"),m(N,"Custom Skills","custskills"),m(N,"Experience","exp"),m(N,"Wealth","wealth"),m(N,"Abilities","abilities"),m(N,"Equipment","equipment"),m(N,"Spellbook","spellbook"),m(N,"Notes","notes")]})]},`character-${C._id}`))}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"File Manager"}),u.jsxs("div",{className:"main-container",children:[u.jsx(X,{color:"primary",onClick:()=>window.newchar.showModal(),children:"New Character"}),u.jsxs(X,{as:"label",color:"primary",children:[u.jsx("input",{type:"file",className:"hidden h-0",multiple:!0,accept:".json",onChange:a}),"Load Character"]})]}),u.jsx("h2",{children:"Characters"}),u.jsx("div",{className:"main-container",children:k()}),u.jsxs("div",{className:"msg-container space-y-1",children:[u.jsxs("div",{className:"font-bold",children:[u.jsx(X,{color:"primary",className:"bi-eraser text-xs px-1 py-0.5"})," - Clear Data"]}),u.jsxs("div",{className:"font-bold",children:[u.jsx(X,{color:"disabled",className:"bi-square-fill text-xs px-1 py-0.5"})," - Disable Character  ",u.jsx(X,{color:"secondary",className:"bi-caret-right-fill text-xs px-1 py-0.5"})," - Activate Character"]}),u.jsxs("div",{className:"font-bold",children:[u.jsx(X,{color:"disabled",className:"bi-save-fill text-xs px-1 py-0.5"})," - Character Saved  ",u.jsx(X,{color:"success",className:"bi-save-fill text-xs px-1 py-0.5"})," - Character NOT Saved"]}),u.jsxs("div",{className:"font-bold",children:[u.jsx(X,{color:"error",className:"bi-trash text-xs px-1 py-0.5"})," - Remove Character"]}),u.jsxs("div",{children:["Characters will be stored upon any changes to the list from this page, or periodically every 10 seconds. Upon loading the page again, they should be reloaded. Please note that this store uses localstorage for the characters, so if you move this web application the localstorage will be reset. It is a known flaw with non-server based web applications. To prevent any major losses, make sure you ",u.jsx(X,{color:"green",className:"bi-save-fill text-white text-xs px-1 py-0.5"})," save the characters listed."]})]}),u.jsx(sl,{id:"newchar",title:"Create New Character",type:wn.prompt,onClose:C=>s(C),children:u.jsx("p",{children:"Please enter the name of your new Character:"})})]})}function Ir({title:e,id:t,value:n,items:i,arrow:s,color:a,className:c,innerClass:d,outerClass:h,onChange:m}){if(!Array.isArray(i))throw new Error("The Select component requires the items property to be present, and be of type Array.");m||console.warn("In order to get the index, you need to assign something to onChange...");let[_,k]=I.useState(n||0),[C,N]=I.useState(t||ut());I.useEffect(()=>{k(n||0)},[n]);function S(A){let y=A.target.selectedIndex;k(y),m&&m(y)}function w(){return i.map((A,y)=>u.jsx("option",{value:y,children:A},`${C}${y}`))}return u.jsxs("div",{className:`select-cont ${c||""} ${h||""}`,children:[u.jsx("label",{htmlFor:C,className:`select-label lg-title ${tt[a]||tt.default} ${J[a]||J.default}`,children:e==0?"0":e||"Select"}),u.jsx("select",{id:C,name:C,value:_,className:`select-input ${d||"bg-base-100"} ${J[a]||J.default}`,onChange:S,children:w()}),u.jsx("div",{className:`select-end ${s||"bi-caret-down"}`})]})}function Oe({title:e,titleElements:t,color:n,className:i,innerClass:s,outerClass:a,children:c}){const[d,h]=I.useState(!1),m=d?"bi-caret-down":"bi-caret-right",_=d?"":"rounded-b-md",k=d?"flex":"hidden";function C(N){N.target.tagName!="BUTTON"&&h(!d)}return u.jsxs("div",{className:`${i||""} ${a||""}`,children:[u.jsxs("div",{className:`accordian-top ${_} ${tt[n]||tt.default} ${J[n]||J.default}`,onClick:C,children:[u.jsx("div",{className:`pointer-events-none ${m}`}),u.jsx("div",{className:"pointer-events-none flex-grow lg-title",children:e==0?"0":e||"Accordian"}),u.jsx("div",{className:"pointer-events-none accordian-elements",children:t})]}),u.jsx("div",{className:`${s||""} accordian-bottom ${k} ${J[n]||J.default}`,children:c})]})}function xr({title:e,id:t,value:n,color:i,className:s,innerClass:a,outerClass:c,onChange:d}){d||console.warn("In order to get the list, you need to assign something to onChange...");let[h,m]=I.useState(n||[]);I.useState(t||ut()),I.useEffect(()=>{m(n||[])},[n]);function _(S,w){let A=S.target.value,y=[...h];y[w]=A,m(y),d&&d(y)}function k(){let S=[...h];S.push(""),m(S),d&&d(S)}function C(S){let w=[...h];w.splice(S,1),m(w),d&&d(w)}function N(){return h.length==0?u.jsx("p",{children:"No items in list..."}):h.map((S,w)=>u.jsxs("div",{className:"list-row",children:[u.jsx("input",{type:"text",value:S,className:`list-input ${J[i]||J.default}`,onChange:A=>_(A,w)}),u.jsx(X,{color:"error",className:"bi-trash border border-black",onClick:()=>C(w)})]},`${t}-${w}`))}return u.jsx(Oe,{title:e==0?"0":e||"List",titleElements:[u.jsx("div",{className:"flex items-center",children:h.length},`${t}-size`),u.jsx(X,{color:"success",className:"bi-plus-circle pointer-events-auto border border-black",onClick:k},`${t}-add`)],className:s||"",outerClass:c||"",innerClass:a||"",color:i,children:N()})}const va=["str","dex","con","int","wis","chr"],Yg=e=>Math.floor((e-10)/2),_k=["Fine","Diminutive","Tiny","Small","Medium","Large","Huge","Gargantuan","Colossal"],Nk=["Unaligned","Lawful Good","Neutral Good","Chaotic Good","Lawful Neutral","True Neutral","Chaotic Neutral","Lawful Evil","Neutral Evil","Chaotic Evil","Its Complicated"],jk=[{k:"acro",v:"Acrobatics",s:1,f:1},{k:"appr",v:"Appraise",s:3,f:0},{k:"bluf",v:"Bluff",s:5,f:0},{k:"clim",v:"Climb",s:0,f:1},{k:"dipl",v:"Diplomacy",s:5,f:0},{k:"disd",v:"Disable Device",s:1,f:3},{k:"disg",v:"Disguise",s:5,f:0},{k:"esca",v:"Escape Artist",s:1,f:1},{k:"fly",v:"Fly",s:1,f:1},{k:"hana",v:"Handle Animal",s:5,f:2},{k:"heal",v:"Heal",s:4,f:0},{k:"inti",v:"Intimidation",s:5,f:0},{k:"ling",v:"Linguistics",s:3,f:0},{k:"perc",v:"Perception",s:4,f:0},{k:"ride",v:"Ride",s:1,f:1},{k:"senm",v:"Sense Motive",s:4,f:0},{k:"sleh",v:"Sleight of Hand",s:1,f:3},{k:"spel",v:"Spellcraft",s:3,f:2},{k:"stea",v:"Stealth",s:1,f:1},{k:"surv",v:"Survival",s:4,f:0},{k:"swim",v:"Swim",s:0,f:1},{k:"usmd",v:"Use Magic Device",s:5,f:2}],Ek=[{k:"craf",v:"Craft",s:3,f:0},{k:"know",v:"Knowledge",s:3,f:2},{k:"perf",v:"Perform",s:5,f:0},{k:"prof",v:"Profession",s:4,f:2}],S0=[[0,3e3,7500,14e3,23e3,35e3,53e3,77e3,115e3,16e4,235e3,33e4,475e3,665e3,955e3,135e4,19e5,27e5,385e4,535e4],[0,2e3,5e3,9e3,15e3,23e3,35e3,51e3,75e3,105e3,155e3,22e4,315e3,445e3,635e3,89e4,13e5,18e5,255e4,36e5],[0,1300,3300,6e3,1e4,15e3,23e3,34e3,5e4,71e3,105e3,145e3,21e4,295e3,425e3,6e5,85e4,12e5,17e5,24e5]];function kk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1);function s(c){return U.get(e.files[n].data.details,c)}function a(c,d){let h={};h[c]=d,U.assign(e.files[n].data.details,h),e.files[n].saved=!1}return I.useEffect(()=>{let c=e.getLoadedIndex();if(c==-1){t("/");return}U.has(e.files[c],"data.details")||U.assign(e.files[c].data,{details:{name:"",race:"",size:4,gender:"",height:"",weight:"",hair:"",eyes:"",skin:"",age:"",alignment:"",deity:"",homeland:"",languages:[]}}),i(c)},[]),n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Character Details"}),u.jsxs("div",{className:"main-container",children:[u.jsx(Re,{title:"Name",id:"name",value:s("name"),onChange:c=>a("name",c)}),u.jsx(Re,{title:"Race",id:"race",value:s("race"),onChange:c=>a("race",c)}),u.jsx(Ir,{title:"Size",id:"size",value:s("size"),items:_k,arrow:"bi-aspect-ratio",onChange:c=>a("size",c)}),u.jsx(Re,{title:"Gender",id:"gender",value:s("gender"),onChange:c=>a("gender",c)}),u.jsx(Re,{title:"Height",id:"height",value:s("height"),onChange:c=>a("height",c)}),u.jsx(Re,{title:"Weight",id:"weight",value:s("weight"),onChange:c=>a("weight",c)}),u.jsx(Re,{title:"Hair",id:"hair",value:s("hair"),onChange:c=>a("hair",c)}),u.jsx(Re,{title:"Eyes",id:"eyes",value:s("eyes"),onChange:c=>a("eyes",c)}),u.jsx(Re,{title:"Skin",id:"skin",value:s("skin"),onChange:c=>a("skin",c)}),u.jsx(Re,{title:"Age",id:"age",value:s("age"),onChange:c=>a("age",c)}),u.jsx(Ir,{title:"Alignment",id:"alignment",value:s("alignment"),items:Nk,arrow:"bi-text-indent-left",onChange:c=>a("alignment",c)}),u.jsx(Re,{title:"Deity",id:"deity",value:s("deity"),onChange:c=>a("deity",c)}),u.jsx(Re,{title:"Homeland",id:"homeland",value:s("homeland"),onChange:c=>a("homeland",c)}),u.jsx(xr,{title:"Languages",id:"languages",value:s("languages"),onChange:c=>a("languages",c)})]})]})}function mt({title:e,id:t,value:n,min:i,max:s,color:a,className:c,innerClass:d,outerClass:h,onChange:m}){if(e=e||["Num 1","Num 2","Num 3","Num 4"],n=n||new Array(e.length).fill(0),i=i||new Array(e.length).fill(-5e3),s=s||new Array(e.length).fill(1e7),m||console.warn("In order to get the number array, you need to assign something to onChange..."),!Array.isArray(e)||!Array.isArray(n)||!Array.isArray(i)||!Array.isArray(s))throw new Error("The properties of title, value, min and max must be of type Array");if(e.length!=n.length||e.length!=i.length||e.length!=s.length)throw new Error("The properties of title, value, min, and max must be of the same Array dimension");let[_,k]=I.useState(n),[C,N]=I.useState(t||ut());I.useEffect(()=>{JSON.stringify(new Array(e.length).fill(0))!=JSON.stringify(n.filter(A=>A==0))&&k(n)},[n]);function S(A,y){let g=A.target.value,j=[..._];j[y]=parseInt(g)||0,k(j),m&&m(j)}function w(){let A=[];for(let y=0;yS(g,y)})]},`${C}-section${y}`));return A}return u.jsx("div",{className:`mn-cont ${c||""} ${h||""} ${J[a]||J.default}`,children:w()})}function Ak(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([0,0,0,0]),[c,d]=I.useState([0,0,0,0]),[h,m]=I.useState([0,0,0,0]),[_,k]=I.useState([0,0,0,0]),[C,N]=I.useState([0,0,0,0]),[S,w]=I.useState([0,0,0,0]);function A(O){return U.get(e.files[n].data.stats,O)}function y(O,L){let F={};F[O]=L,U.assign(e.files[n].data.stats,F),e.files[n].saved=!1}I.useEffect(()=>{let O=e.getLoadedIndex();if(O==-1){t("/");return}U.has(e.files[O],"data.stats")||U.assign(e.files[O].data,{stats:{str:[0,0,0,0],dex:[0,0,0,0],con:[0,0,0,0],int:[0,0,0,0],wis:[0,0,0,0],chr:[0,0,0,0]}}),i(O),a(e.files[O].data.stats.str),d(e.files[O].data.stats.dex),m(e.files[O].data.stats.con),k(e.files[O].data.stats.int),N(e.files[O].data.stats.wis),w(e.files[O].data.stats.chr)},[]);let g=O=>Math.floor((O-10)/2);function j(O,L){O=="str"&&a(L),O=="dex"&&d(L),O=="con"&&m(L),O=="int"&&k(L),O=="wis"&&N(L),O=="chr"&&w(L),y(O,L)}function M(O,L){if(n==-1)return u.jsx("p",{children:"Loading..."});let F=U.sum(A(L));return u.jsx(Oe,{title:O,titleElements:u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black bg-base-300 text-base-content rounded-md",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Total"}),u.jsx("p",{className:"text-center m-0 p-0",children:F})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Mod"}),u.jsx("p",{className:"text-center m-0 p-0",children:g(F)})]})]}),children:u.jsx(mt,{title:["Base","Enhance","Misc","Temp"],id:`${L}`,value:A(L),min:[0,0,-100,-100],max:[100,100,100,100],color:"secondary",onChange:$=>j(L,$)})})}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Ability Scores"}),u.jsxs("div",{className:"main-container",children:[M("Strength","str"),M("Dexterity","dex"),M("Constitution","con"),M("Intelligence","int"),M("Wisdom","wis"),M("Charisma","chr")]}),u.jsx("div",{className:"msg-container",children:u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Mods Calculation"}),": ⌊(StatTotal - 10) / 2)⌋"]})})]})}function Ce({title:e,value:t,color:n,className:i,innerClass:s,outerClass:a}){return u.jsxs("div",{className:`text-cont ${i||""} ${a||""}`,children:[u.jsx("div",{className:`text-label lg-title ${tt[n]||tt.default} ${J[n]||J.default}`,children:e==0?"0":e||"Label"}),u.jsx("div",{className:`text-input ${J[n]||J.default} ${s||""}`,children:t==0?"0":t||""})]})}function st({title:e,id:t,value:n,min:i,max:s,color:a,className:c,innerClass:d,outerClass:h,onChange:m}){m||console.warn("In order to get the number, you need to assign something to onChange...");let[_,k]=I.useState(n||0),[C,N]=I.useState(t||ut());I.useEffect(()=>{k(n||0)},[n]);function S(w){let A=parseInt(w.target.value)||0;k(A),m&&m(A)}return u.jsxs("div",{className:`text-cont ${c||""} ${h||""}`,children:[u.jsx("label",{htmlFor:C,className:`text-label lg-title ${tt[a]||tt.default} ${J[a]||J.default}`,children:e==0?"0":e||"Number"}),u.jsx("input",{type:"number",id:C,name:C,value:_,min:i==0?0:i||-5e3,max:s==0?0:s||1e7,className:`text-input ${J[a]||J.default} ${d||""}`,onChange:S})]})}function Pk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([]),[c,d]=I.useState(-1);function h(w){e.files[n].data.classes=w,e.files[n].saved=!1}I.useEffect(()=>{let w=e.getLoadedIndex();if(w==-1){t("/");return}U.has(e.files[w],"data.classes")||U.assign(e.files[w].data,{classes:[]}),i(w),a(e.files[w].data.classes)},[]);function m(){let w=[...s];w.push({_id:ut(),name:"Untitled Class",level:1,hd:0,health:0,bab:0,skillnum:0,favclass:[0,0],saves:[0,0,0]}),h(w),a(w)}function _(w){d(w),window.removeclass.showModal()}function k(w){if(w==="ok"){let A=[...s];A.splice(c,1),h(A),a(A),d(-1)}d(-1)}function C(){if(n==-1)return 0;let w=0;return s.forEach((A,y)=>{w+=A.level}),w}function N(w,A,y){let g=[...s];A==0&&(g[w].name=y),A==1&&(g[w].level=y),A==2&&(g[w].hd=y[0],g[w].health=y[1],g[w].bab=y[2],g[w].skillnum=y[3]),A==3&&(g[w].favclass=y),A==4&&(g[w].saves=y),a(g),h(g)}function S(){return n==-1?u.jsx("p",{children:"Loading..."}):s.length==0?u.jsx("p",{children:"No classes have been added yet..."}):s.map((w,A)=>u.jsxs(Oe,{title:w.name,titleElements:u.jsx("div",{children:w.level}),children:[u.jsxs("div",{className:"flex flex-row",children:[u.jsx(Re,{title:"Class Name",id:`class${A+1}name`,value:w.name,className:"flex-grow mr-1",color:"secondary",onChange:y=>N(A,0,y)}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>_(A)})]}),u.jsx(st,{title:"Level",id:`class${A+1}level`,value:w.level,min:1,max:20,color:"secondary",onChange:y=>N(A,1,y)}),u.jsx(mt,{title:["HD","Health","BAB","Skill Num"],id:`class${A+1}bs`,value:[w.hd,w.health,w.bab,w.skillnum],min:[0,0,0,0],max:[100,5e3,20,20],color:"secondary",onChange:y=>N(A,2,y)}),u.jsx(mt,{title:["Fav Class Health","Fav Class Skill"],id:`class${A+1}fc`,value:[w.favclass[0],w.favclass[1]],min:[0,0],max:[20,20],color:"secondary",onChange:y=>N(A,3,y)}),u.jsx(mt,{title:["Fortitude","Reflex","Will"],id:`class${A+1}st`,value:[w.saves[0],w.saves[1],w.saves[2]],min:[0,0,0],max:[20,20,20],color:"secondary",onChange:y=>N(A,4,y)})]},`class-${w._id}`))}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Classes"}),u.jsxs("div",{className:"main-container",children:[u.jsx(X,{color:"primary",onClick:m,children:"Add Class"}),u.jsx(Ce,{title:"Total Class Levels",value:C()})]}),u.jsx("div",{className:"main-container",children:S()}),u.jsxs(sl,{id:"removeclass",title:"Confirm Remove?",color:"warning",type:wn.okcancel,onClose:w=>k(w),children:[u.jsx("p",{children:"Are you sure you wish to remove this class?"}),u.jsx("p",{children:"This action is permanent and can only be reverted by re-loading the character data."})]})]})}function Ik(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([0,0,0,0]);function c(_){U.assign(e.files[n].data.health,_),e.files[n].saved=!1}I.useEffect(()=>{let _=e.getLoadedIndex();if(_==-1){t("/");return}U.has(e.files[_],"data.health")||U.assign(e.files[_].data,{health:[0,0,0,0]}),i(_),a(e.files[_].data.health)},[]);function d(){let _=0,k=0,C=0;if(U.has(e.files[n].data,"stats")){let N=e.files[n].data.stats.con;C=Math.floor((N[0]+N[1]+N[2]+N[3]-10)/2)}return U.has(e.files[n].data,"classes")&&e.files[n].data.classes.forEach(N=>{_+=N.health+N.favclass[0],k+=N.level}),_+=k*C,_<=0&&(_=1),_}function h(){let _=d();return _+=-s[0]+-s[1]+s[2]+s[3],_}function m(_){a(_),c(_)}return n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Health"}),u.jsxs("div",{className:"main-container",children:[u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Ce,{title:"Max Health",value:d(),className:"w-1/2"}),u.jsx(Ce,{title:"Current Health",value:h(),className:"w-1/2"})]}),u.jsx(Oe,{title:"Wounds and Bonuses",children:u.jsx(mt,{title:["Wounds","Non-Lethal","Misc","Temp"],id:"health",value:s,min:[0,0,-1e3,-1e3],max:[5e3,5e3,5e3,5e3],color:"secondary",onChange:m})})]}),u.jsxs("div",{className:"msg-container",children:[u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Note:"})," Wounds and Non-Lethal subtract from the total health, while Misc and Temp add to the total."]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Max Calculation:"})," Total = Sum of Each Class(Health + Favored Class Health)"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Current Calculation:"})," Total = -(Wounds) + -(Non-Lethal) + Misc + Temp"]})]})]})}function Rk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([0,0,0]),[c,d]=I.useState([0,0,0]),[h,m]=I.useState([0,0,0]);function _(y){return U.get(e.files[n].data.saves,y)}function k(y,g){let j={};j[y]=g,U.assign(e.files[n].data.saves,j),e.files[n].saved=!1}I.useEffect(()=>{let y=e.getLoadedIndex();if(y==-1){t("/");return}U.has(e.files[y],"data.saves")||U.assign(e.files[y].data,{saves:{fort:[0,0,0],ref:[0,0,0],will:[0,0,0]}}),i(y),a(e.files[y].data.saves.fort),d(e.files[y].data.saves.ref),m(e.files[y].data.saves.will)},[]);let C=[0,0,0],N=[0,0,0],S=[0,0,0];if(n!=-1){if(U.has(e.files[n].data,"stats")){let y=e.files[n].data.stats.con,g=e.files[n].data.stats.dex,j=e.files[n].data.stats.wis;N[0]=Math.floor((U.sum(y)-10)/2),N[1]=Math.floor((U.sum(g)-10)/2),N[2]=Math.floor((U.sum(j)-10)/2)}U.has(e.files[n].data,"classes")&&e.files[n].data.classes.forEach(y=>{C[0]+=y.saves[0],C[1]+=y.saves[1],C[2]+=y.saves[2]}),S[0]=U.sum(s),S[1]=U.sum(c),S[2]=U.sum(h)}function w(y,g){y=="fort"&&a(g),y=="ref"&&d(g),y=="will"&&m(g),k(y,g)}function A(y,g,j){return n==-1?u.jsx("p",{children:"Loading..."}):u.jsx(Oe,{title:y,titleElements:u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Base"}),u.jsx("p",{className:"text-center m-0 p-0",children:C[j]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Mod"}),u.jsx("p",{className:"text-center m-0 p-0",children:N[j]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Misc"}),u.jsx("p",{className:"text-center m-0 p-0",children:S[j]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black bg-base-300 text-base-content rounded-md",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Total"}),u.jsx("p",{className:"text-center m-0 p-0",children:C[j]+N[j]+S[j]})]})]}),children:u.jsx(mt,{title:["Enhance","Misc","Temp"],id:g,value:_(g),min:[0,-100,-100],max:[100,100,100],color:"secondary",onChange:M=>w(g,M)})})}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Saving Throws"}),u.jsxs("div",{className:"main-container",children:[A("Fortitude","fort",0),A("Reflex","ref",1),A("Will","will",2)]})]})}function Lk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([0,0]),[c,d]=I.useState([0,0]),[h,m]=I.useState([0,0]),[_,k]=I.useState([0,0]),[C,N]=I.useState(0);function S(oe){return U.get(e.files[n].data.offense,oe)}function w(oe,Ne){let Tn={};Tn[oe]=Ne,U.assign(e.files[n].data.offense,Tn),e.files[n].saved=!1}I.useEffect(()=>{let oe=e.getLoadedIndex();if(oe==-1){t("/");return}U.has(e.files[oe],"data.offense")||U.assign(e.files[oe].data,{offense:{melee:[0,0],range:[0,0],cmb:[0,0],cmd:[0,0]}}),i(oe),a(e.files[oe].data.offense.melee),d(e.files[oe].data.offense.range),m(e.files[oe].data.offense.cmb),k(e.files[oe].data.offense.cmd)},[]);let A=[0,0,0,0],y=0,g=0,j=0,M=[0,0],O=0,L=0,F=0,$=[],Z=[],Y=oe=>Math.floor((oe-10)/2);if(n!=-1){if(U.has(e.files[n].data,"details")){let oe=e.files[n].data.details.size-4,Ne=Math.ceil(Math.pow(2,Math.abs(oe))/2);g=oe==0?0:oe>0?-Ne:Ne,j=-g}for(U.has(e.files[n].data,"stats")&&(M=[Y(U.sum(e.files[n].data.stats.str)),Y(U.sum(e.files[n].data.stats.dex))]),U.has(e.files[n].data,"classes")&&e.files[n].data.classes.forEach(oe=>{y+=oe.bab}),A=[U.sum(s),U.sum(c),U.sum(h),U.sum(_)],O=y,L=y+M[0]+g+A[0],F=y+M[1]+g+A[1];O>=0;)$.push(L),Z.push(F),O-=5,L-=5,F-=5}function ye(oe,Ne){oe=="melee"&&a(Ne),oe=="range"&&d(Ne),oe=="cmb"&&m(Ne),oe=="cmd"&&k(Ne),w(oe,Ne)}function Ve(oe,Ne,Tn,Or){if(n==-1)return u.jsx("p",{children:"Loading..."});let Nt=Ne[0]=="c"?j:g,G=Ne=="cmd"?M[0]+M[1]:M[Or],re=(Ne=="cmd"?10:0)+y+G+Nt+A[Tn];return u.jsxs(Oe,{title:`${oe}${Ne=="cmb"?C?" (Dex)":" (Str)":""}`,titleElements:u.jsxs("div",{className:"flex flex-row space-x-1",children:[Ne=="cmd"?u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Base"}),u.jsx("p",{className:"text-center m-0 p-0",children:"10"})]}):"",u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"BAB"}),u.jsx("p",{className:"text-center m-0 p-0",children:y})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Mod"}),u.jsx("p",{className:"text-center m-0 p-0",children:G})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Size"}),u.jsx("p",{className:"text-center m-0 p-0",children:Nt})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Misc"}),u.jsx("p",{className:"text-center m-0 p-0",children:A[Tn]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black bg-base-300 text-base-content rounded-md",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Total"}),u.jsx("p",{className:"text-center m-0 p-0",children:re})]})]}),children:[Ne=="cmb"?u.jsx(Ir,{title:"Modifier",id:"cmbstate",value:C,items:["Strength","Dexterity"],color:"secondary",onChange:N}):"",u.jsx(mt,{title:["Misc","Temp"],id:Ne,value:S(Ne),min:[-100,-100],max:[100,100],color:"secondary",onChange:le=>ye(Ne,le)})]})}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Offensive Stats"}),u.jsxs("div",{className:"main-container",children:[Ve("Melee","melee",0,0),Ve("Ranged","range",1,1),Ve("CMB","cmb",2,C),Ve("CMD","cmd",3,0),u.jsx(Ce,{title:"Melee Attacks",value:$.join(", ")}),u.jsx(Ce,{title:"Ranged Attacks",value:Z.join(", ")})]}),u.jsxs("div",{className:"msg-container",children:[u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Mods Used"}),": Melee (str), Ranged (dex)"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"CMD Calculation"}),": 10 + BAB + Str Mod + Dex Mod + Size + Misc + Temp"]})]})]})}function Tk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([0,0,0,0]);function c(j){U.assign(e.files[n].data.defense,j),e.files[n].saved=!1}I.useEffect(()=>{let j=e.getLoadedIndex();if(j==-1){t("/");return}U.has(e.files[j],"data.defense")||U.assign(e.files[j].data,{defense:[0,0,0,0]}),i(j),a(e.files[j].data.defense)},[]);let d=0,h=-1,m=0,_=0,k=0,C=0,N=0,S=0,w=0,A=0,y=j=>Math.floor((j-10)/2);if(n!=-1){if(U.has(e.files[n].data,"details")){let j=e.files[n].data.details.size-4,M=Math.ceil(Math.pow(2,Math.abs(j))/2);N=j==0?0:j>0?-M:M}U.has(e.files[n].data,"stats")&&(k=y(U.sum(e.files[n].data.stats.dex))),U.has(e.files[n].data,"armors")&&e.files[n].data.armors.forEach(j=>{j.active&&(d+=j.ac,m+=j.penalty,_+=j.spellfail,j.maxdex>=0&&(h<0||h>j.maxdex)&&(h=j.maxdex))}),h>=0?C=k>h?h:k:C=k,S=10+d+C+N+U.sum(s),w=10+C+N+s[0]+s[2]+s[3],A=10+d+N+s[1]+s[2]+s[3]}function g(j){a(j),c(j)}return n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Defensive Stats"}),u.jsxs("div",{className:"main-container",children:[u.jsx(Oe,{title:"Total AC",titleElements:u.jsx("div",{children:S}),children:u.jsxs("div",{className:"flex flex-row space-x-1 justify-evenly",children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Base"}),u.jsx("p",{className:"text-center m-0 p-0",children:"10"})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Armor"}),u.jsx("p",{className:"text-center m-0 p-0",children:d})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Dexterity"}),u.jsx("p",{className:"text-center m-0 p-0",children:C})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Size"}),u.jsx("p",{className:"text-center m-0 p-0",children:N})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Bonuses"}),u.jsx("p",{className:"text-center m-0 p-0",children:U.sum(s)})]})]})}),u.jsx(Oe,{title:"Touch AC",titleElements:u.jsx("div",{children:w}),children:u.jsxs("div",{className:"flex flex-row space-x-1 justify-evenly",children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Base"}),u.jsx("p",{className:"text-center m-0 p-0",children:"10"})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Dexterity"}),u.jsx("p",{className:"text-center m-0 p-0",children:C})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Size"}),u.jsx("p",{className:"text-center m-0 p-0",children:N})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Bonuses (-Natural)"}),u.jsx("p",{className:"text-center m-0 p-0",children:U.sum(s)-s[1]})]})]})}),u.jsx(Oe,{title:"Flat-Foot AC",titleElements:u.jsx("div",{children:A}),children:u.jsxs("div",{className:"flex flex-row space-x-1 justify-evenly",children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Base"}),u.jsx("p",{className:"text-center m-0 p-0",children:"10"})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Armor"}),u.jsx("p",{className:"text-center m-0 p-0",children:d})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Size"}),u.jsx("p",{className:"text-center m-0 p-0",children:N})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Bonuses (-Dodge)"}),u.jsx("p",{className:"text-center m-0 p-0",children:U.sum(s)-s[0]})]})]})}),u.jsx(Oe,{title:"AC Bonuses",children:u.jsx(mt,{title:["Dodge","Natural","Misc","Temp"],id:"bonuses",value:s,min:[0,0,-100,-100],max:[100,100,100,100],color:"secondary",onChange:g})}),u.jsx(Ce,{title:"Armor Check Penalty",value:m}),u.jsx(Ce,{title:"Maximum Dex",value:h!=-1?h:"N/A"}),u.jsx(Ce,{title:"Spell Failure",value:_})]}),u.jsxs("div",{className:"msg-container",children:[u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Armor Number"}),": Total of all protective items (under armor) that are marked as active."]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Dexterity Number"}),": If there is a Max Dex, the Dexterity value will be limited by the Max Dex."]})]})]})}function Mk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([0,0,0,0]),[c,d]=I.useState([0,0,0,0,0]),[h,m]=I.useState(0);function _(A){return U.get(e.files[n].data.miscstats,A)}function k(A,y){let g={};g[A]=y,U.assign(e.files[n].data.miscstats,g),e.files[n].saved=!1}I.useEffect(()=>{let A=e.getLoadedIndex();if(A==-1){t("/");return}U.has(e.files[A],"data.miscstats")||U.assign(e.files[A].data,{miscstats:{basespeed:[0,0,0,0],speed:[0,0,0,0,0],init:0,resist:[0,0,0,0,0],dr:"",sr:""}}),i(A),a(e.files[A].data.miscstats.basespeed),d(e.files[A].data.miscstats.speed),m(e.files[A].data.miscstats.init)},[]);let C=0,N=A=>Math.floor((A-10)/2);n!=-1&&U.has(e.files[n].data,"stats")&&(C=N(U.sum(e.files[n].data.stats.dex)));function S(A,y){A=="basespeed"&&a(y),A=="speed"&&d(y),A=="init"&&m(y),k(A,y)}function w(){return s[0]+c[0]}return n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Miscellaneous Stats"}),u.jsxs("div",{className:"main-container",children:[u.jsxs(Oe,{title:"Speeds",titleElements:u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Walk"}),u.jsx("p",{className:"text-center m-0 p-0",children:w()})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Run x4"}),u.jsx("p",{className:"text-center m-0 p-0",children:w()*4+c[1]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Run x5"}),u.jsx("p",{className:"text-center m-0 p-0",children:w()*5+c[1]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Swim"}),u.jsx("p",{className:"text-center m-0 p-0",children:(s[1]==0?Math.floor(w()/4):s[1])+c[2]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Climb"}),u.jsx("p",{className:"text-center m-0 p-0",children:(s[2]==0?Math.floor(w()/4):s[2])+c[3]})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Fly"}),u.jsx("p",{className:"text-center m-0 p-0",children:s[3]+c[4]})]})]}),children:[u.jsx("h2",{children:"Base Speeds"}),u.jsx(mt,{title:["Walk","Swim","Climb","Fly"],id:"speed",value:_("basespeed"),min:[0,0,0,0],max:[1e3,1e3,1e3,1e3],color:"secondary",onChange:A=>S("basespeed",A)}),u.jsx("h2",{children:"Modifiers"}),u.jsx(mt,{title:["Walk","Run","Swim","Climb","Fly"],id:"speed",value:_("speed"),min:[-1e3,-1e3,-1e3,-1e3,-1e3],max:[1e3,1e3,1e3,1e3,1e3],color:"secondary",onChange:A=>S("speed",A)})]}),u.jsx(Oe,{title:"Initiative",titleElements:u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Dexterity"}),u.jsx("p",{className:"text-center m-0 p-0",children:C})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Misc"}),u.jsx("p",{className:"text-center m-0 p-0",children:h})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black bg-base-300 text-base-content rounded-md",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Total"}),u.jsx("p",{className:"text-center m-0 p-0",children:C+_("init")})]})]}),children:u.jsx(st,{title:"Misc",id:"init",value:_("init"),min:0,max:100,color:"secondary",onChange:A=>S("init",A)})}),u.jsxs(Oe,{title:"Resistances",children:[u.jsx(mt,{title:["Acid","Cold","Elec","Fire","Sonic"],id:"resist",value:_("resist"),min:[0,0,0,0,0],max:[1e3,1e3,1e3,1e3,1e3],color:"secondary",onChange:A=>S("resist",A)}),u.jsx(Re,{title:"DR",id:"dr",value:_("dr"),color:"secondary",onChange:A=>S("dr",A)}),u.jsx(Re,{title:"SR",id:"sr",value:_("sr"),color:"secondary",onChange:A=>S("sr",A)})]})]}),u.jsx("div",{className:"msg-container",children:u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Speeds"}),": Base speed is your walk speed. All other values are automatically derived (exception is fly) unless you override the value."]})})]})}function ys({title:e,id:t,value:n,color:i,placeholder:s,className:a,innerClass:c,outerClass:d,onChange:h}){h||console.warn("In order to get the text, you need to assign something to onChange...");let[m,_]=I.useState(n==0?"0":n||""),[k,C]=I.useState(t||ut());I.useEffect(()=>{_(n||"")},[n]);function N(S){let w=S.target.value;_(w),h&&h(w)}return u.jsxs("div",{className:`textarea-cont ${a||""} ${d||""}`,children:[u.jsx("label",{htmlFor:k,className:`textarea-label lg-title ${tt[i]||tt.default} ${J[i]||J.default}`,children:e==0?"0":e||"Text Area"}),u.jsx("textarea",{id:k,name:k,value:m,placeholder:s,className:`textarea-box ${c||""} ${J[i]||J.default}`,onChange:N})]})}function Ok(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([]),[c,d]=I.useState(-1);function h(S){e.files[n].data.weapons=S,e.files[n].saved=!1}I.useEffect(()=>{let S=e.getLoadedIndex();if(S==-1){t("/");return}U.has(e.files[S],"data.weapons")||U.assign(e.files[S].data,{weapons:[]}),i(S),a(e.files[S].data.weapons)},[]);function m(){let S=[...s];S.push({_id:ut(),name:"New Weapon",hit:[],dmg:[],critical:"",range:"",type:"",ammo:"",info:""}),h(S),a(S)}function _(S){d(S),window.removeweapon.showModal()}function k(S){if(S==="ok"){let w=[...s];w.splice(c,1),h(w),a(w),d(-1)}}function C(S,w,A){let y=[...s];y[S][w]=A,a(y),h(y)}function N(){return n==-1?u.jsx("p",{children:"Loading..."}):s.length==0?u.jsx("p",{children:"No weapons have been added yet..."}):s.map((S,w)=>u.jsxs(Oe,{title:S.name,children:[u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Re,{title:"Name",id:`wep${w}name`,value:S.name,className:"flex-grow",color:"secondary",onChange:A=>C(w,"name",A)}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>_(w)})]}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(xr,{title:"To Hit",id:`wep${w}hit`,value:S.hit,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"hit",A)}),u.jsx(xr,{title:"Damage",id:`wep${w}dmg`,value:S.dmg,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"dmg",A)})]}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Re,{title:"Crit",id:`wep${w}crit`,value:S.critical,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"critical",A)}),u.jsx(Re,{title:"Rng",id:`wep${w}rng`,value:S.range,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"range",A)})]}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Re,{title:"Type",id:`wep${w}type`,value:S.type,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"type",A)}),u.jsx(Re,{title:"Ammo",id:`wep${w}ammo`,value:S.ammo,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"ammo",A)})]}),u.jsx(ys,{title:"Notes",id:`wep${w}info`,value:S.info,color:"secondary",onChange:A=>C(w,"info",A)})]},`wep-${S._id}`))}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Weapons"}),u.jsx("div",{className:"main-container",children:u.jsx(X,{color:"primary",onClick:m,children:"Add Weapon"})}),u.jsx("div",{className:"main-container",children:N()}),u.jsxs(sl,{id:"removeweapon",title:"Confirm Remove?",type:wn.okcancel,onClose:S=>k(S),children:[u.jsx("p",{children:"Are you sure you wish to remove this weapon?"}),u.jsx("p",{children:"This action is permanent and can only be reverted by re-loading the character data."})]})]})}function Fk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([]),[c,d]=I.useState(-1);function h(S){e.files[n].data.armors=S,e.files[n].saved=!1}I.useEffect(()=>{let S=e.getLoadedIndex();if(S==-1){t("/");return}U.has(e.files[S],"data.armors")||U.assign(e.files[S].data,{armors:[]}),i(S),a(e.files[S].data.armors)},[]);function m(){let S=[...s];S.push({_id:ut(),name:"New Armor",active:!1,ac:0,maxdex:-1,penalty:0,spellfail:0,info:""}),h(S),a(S)}function _(S){d(S),window.removearmor.showModal()}function k(S){if(S==="ok"){let w=[...s];w.splice(c,1),h(w),a(w),d(-1)}}function C(S,w,A){let y=[...s];y[S][w]=A,a(y),h(y)}function N(){return n==-1?u.jsx("p",{children:"Loading..."}):s.length==0?u.jsx("p",{children:"No armors have been added yet..."}):s.map((S,w)=>u.jsxs(Oe,{title:S.name,titleElements:u.jsx(X,{color:S.active?"success":"error",className:`pointer-events-auto ${S.active?"bi-check-square":"bi-square"}`,onClick:()=>C(w,"active",!S.active)}),children:[u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Re,{title:"Name",id:`arm${w}name`,value:S.name,className:"flex-grow",color:"secondary",onChange:A=>C(w,"name",A)}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>_(w)})]}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(st,{title:"AC",id:`arm${w}ac`,value:S.ac,min:0,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"ac",A)}),u.jsx(st,{title:"Max Dex",id:`arm${w}max`,value:S.maxdex,min:-1,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"maxdex",A)})]}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(st,{title:"Penalty",id:`arm${w}pen`,value:S.penalty,min:0,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"penalty",A)}),u.jsx(st,{title:"Spell Fail",id:`arm${w}fail`,value:S.spellfail,min:0,className:"flex-grow w-1/2",color:"secondary",onChange:A=>C(w,"spellfail",A)})]}),u.jsx(ys,{title:"Notes",id:`arm${w}info`,value:S.info,color:"secondary",onChange:A=>C(w,"info",A)})]},`arm-${S._id}`))}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Armors"}),u.jsx("div",{className:"main-container",children:u.jsx(X,{color:"primary",onClick:m,children:"Add Armor"})}),u.jsx("div",{className:"main-container",children:N()}),u.jsxs("div",{className:"msg-container",children:[u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Max Dex:"})," If the armor has no max dex penalty, set the value to a negative value."]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Note:"})," Before the armor piece becomes active on the defensive stats page, you must click on the button in the title."]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Inactive:"})," ",u.jsx(X,{color:"error",className:"bi-square"})," ",u.jsx("span",{className:"font-bold",children:"Active:"})," ",u.jsx(X,{color:"success",className:"bi-check-square"})]})]}),u.jsxs(sl,{id:"removearmor",title:"Confirm Remove?",type:wn.okcancel,onClose:S=>k(S),children:[u.jsx("p",{children:"Are you sure you wish to remove this armor?"}),u.jsx("p",{children:"This action is permanent and can only be reverted by re-loading the character data."})]})]})}function Dk({title:e,id:t,value:n,color:i,className:s,onChange:a}){n=n||[0,0,0,0,!1,0,0],a||console.warn("In order to get the Skill Value, you need to assign something to onChange...");let[c,d]=I.useState([n[4],e||"",n[5],n[6]]);I.useState(t||ut());function h(_,k){let C=[...c];C[k]=_,d(C),a&&a(C)}let m=(c[0]&&c[2]>0?3:0)+c[2]+n[3]+c[3];return(n[0]&1)==1&&(m-=n[1]),(n[0]&2)==2&&c[2]<=0&&(m=0),u.jsxs("div",{className:`sr-cont ${s||""}`,children:[u.jsx("div",{className:"col-span-1 sr-center",children:u.jsx("input",{type:"checkbox",checked:c[0],onChange:_=>h(_.target.checked,0)})}),u.jsxs("div",{className:"col-span-3 sr-label",children:[c[1]," ",(n[0]&1)==1?"*":""," ",(n[0]&2)==2?u.jsx(u.Fragment,{children:"†"}):""]}),u.jsx("div",{className:"col-span-2 sr-label text-right",children:va[n[2]]}),u.jsx("div",{className:`col-span-1 sr-input sr-center ${J[i]||J.default}`,children:(n[0]&2)==2&&c[2]<=0?"-":m}),u.jsx("div",{className:`col-span-2 sr-input ${J[i]||J.default}`,children:u.jsx("input",{type:"number",value:c[2],min:0,max:100,onChange:_=>h(parseInt(_.target.value),2)})}),u.jsx("div",{className:`col-span-1 sr-input sr-center ${J[i]||J.default}`,children:n[3]}),u.jsx("div",{className:`col-span-2 sr-input ${J[i]||J.default}`,children:u.jsx("input",{type:"number",value:c[3],min:-100,max:100,onChange:_=>h(parseInt(_.target.value),3)})})]})}function zk({title:e,id:t,value:n,color:i,className:s,onChange:a,onDelete:c}){n=n||[0,0,!1,0,0],a||console.warn("In order to get the Skill Value, you need to assign something to onChange..."),c||console.warn("onDelete must be set or items cannot be removed...");let[d,h]=I.useState([n[2],e||"",n[3],n[4]]);I.useState(t||ut());function m(k,C){let N=[...d];N[C]=k,h(N),a&&a(N)}let _=(d[0]&&d[2]>0?3:0)+d[2]+n[1]+d[3];return(n[0]&2)==2&&d[2]<=0&&(_=0),u.jsxs("div",{className:`sr-cont ${s||""}`,children:[u.jsx("div",{className:"col-span-1 sr-center",children:u.jsx("input",{type:"checkbox",checked:d[0],onChange:k=>m(k.target.checked,0)})}),u.jsx("div",{className:`col-span-4 sr-input ${J[i]||J.default}`,children:u.jsx("input",{type:"text",value:d[1],onChange:k=>m(k.target.value,1)})}),u.jsx("div",{className:`col-span-1 sr-input sr-center ${J[i]||J.default}`,children:(n[0]&2)==2&&d[2]<=0?"-":_}),u.jsx("div",{className:`col-span-2 sr-input ${J[i]||J.default}`,children:u.jsx("input",{type:"number",value:d[2],min:0,max:100,onChange:k=>m(parseInt(k.target.value),2)})}),u.jsx("div",{className:`col-span-1 sr-input sr-center ${J[i]||J.default}`,children:n[1]}),u.jsx("div",{className:`col-span-2 sr-input ${J[i]||J.default}`,children:u.jsx("input",{type:"number",value:d[3],min:-100,max:100,onChange:k=>m(parseInt(k.target.value),3)})}),u.jsx("div",{className:"col-span-1 sr-center",children:u.jsx(X,{color:"error",className:"bi-trash text-xs px-1 py-0.5",onClick:c})})]})}function Uk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([]),[c,d]=I.useState([]);function h(L,F,$){let Z={};Z[L]=$,F?U.assign(e.files[n].data.custskills,Z):U.assign(e.files[n].data.skills,Z),e.files[n].saved=!1}I.useEffect(()=>{let L=e.getLoadedIndex();if(L==-1){t("/");return}U.has(e.files[L],"data.skills")||U.assign(e.files[L].data,{skills:{appr:[!1,0,0],acro:[!1,0,0],bluf:[!1,0,0],clim:[!1,0,0],dipl:[!1,0,0],disd:[!1,0,0],disg:[!1,0,0],esca:[!1,0,0],fly:[!1,0,0],hana:[!1,0,0],heal:[!1,0,0],inti:[!1,0,0],ling:[!1,0,0],perc:[!1,0,0],ride:[!1,0,0],senm:[!1,0,0],sleh:[!1,0,0],spel:[!1,0,0],stea:[!1,0,0],surv:[!1,0,0],swim:[!1,0,0],usmd:[!1,0,0]}}),U.has(e.files[L],"data.custskills")||U.assign(e.files[L].data,{custskills:{craf:[],know:[],perf:[],prof:[]}}),i(L);let F=e.files[L].data.skills,$=e.files[L].data.custskills,Z=[],Y=[];U.forEach(F,(ye,Ve)=>{Z.push([Ve,ye])}),U.forEach($,(ye,Ve)=>{Y.push([Ve,ye])}),a(Z),d(Y)},[]);function m(L){for(let F=0;F{S[$]=Yg(U.sum(U.get(L,va[$])))})}U.has(e.files[n].data,"armors")&&e.files[n].data.armors.forEach(L=>{L.active&&(w+=L.penalty)}),U.has(e.files[n].data,"classes")&&e.files[n].data.classes.forEach(F=>{let $=F.skillnum+S[3];$<1&&($=1),A+=$*F.level+F.favclass[1]}),s.forEach(L=>{y+=L[1][1]}),c.forEach(L=>{L[1].forEach(F=>{y+=F.stats[1]})})}function g(L,F){let $=[...s];$[m(L)][1]=[F[0],F[2],F[3]],a($),h(L,!1,$[m(L)][1])}function j(){return jk.map(L=>{let F=s[m(L.k)][1];return u.jsx(Dk,{title:L.v,id:L.k,value:[L.f,w,L.s,S[L.s],F[0],F[1],F[2]],color:"secondary",onChange:$=>g(L.k,$)},L.k)})}function M(L){return c[_(L.k)][1].map((F,$)=>u.jsx(zk,{title:F.name,id:`${L.k}:${$}`,value:[L.f,S[L.s],F.stats[0],F.stats[1],F.stats[2]],className:"pr-2",color:"secondary",onChange:Z=>N(L.k,$,Z),onDelete:()=>C(L.k,$)},`${L.k}-${F._id}`))}function O(){return Ek.map(L=>u.jsxs("div",{className:"rounded-md border-2 border-primary",children:[u.jsxs("div",{className:"flex flex-row p-1 items-center",children:[u.jsxs("div",{className:"font-bold flex-grow",children:[L.v," ",(L.f&1)==1?"*":""," ",(L.f&2)==2?u.jsx(u.Fragment,{children:"†"}):""," (",va[L.s],")"]}),u.jsx(X,{color:"success",className:"text-xs bi-plus-square",onClick:()=>k(L.k)})]}),u.jsxs("div",{className:"grid grid-cols-12 gap-1 text-xs bg-primary text-primary-content",children:[u.jsx("div",{className:"col-start-6 col-span-1 text-center",children:"TTL"}),u.jsx("div",{className:"col-span-2 text-center",children:"Ranks"}),u.jsx("div",{className:"col-span-1 text-center",children:"Mod"}),u.jsx("div",{className:"col-span-2 text-center",children:"Misc"}),u.jsx("div",{className:"col-span-1",children:" "})]}),M(L)]},L.k))}return n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Skills"}),u.jsxs("div",{className:"main-container",children:[u.jsx(Ce,{title:"Total Ranks",value:A}),u.jsx(Ce,{title:"Used Ranks",value:y})]}),u.jsxs("div",{className:"main-container space-y-0 rounded-md border-2 border-primary",children:[u.jsxs("div",{className:"grid grid-cols-12 gap-1 text-xs bg-primary text-primary-content rounded-t-sm",children:[u.jsx("div",{className:"col-start-7 col-span-1 text-center",children:"TTL"}),u.jsx("div",{className:"col-span-2 text-center",children:"Ranks"}),u.jsx("div",{className:"col-span-1 text-center",children:"Mod"}),u.jsx("div",{className:"col-span-2 text-center",children:"Misc"})]}),j()]}),u.jsx("div",{className:"main-container",children:O()}),u.jsxs("div",{className:"msg-container",children:[u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"*"}),": Armor Check Penalty (subtracts ",w,")"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"†"}),": Cannot Use Untrained"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Total Skills"}),": Sum of((Class Skill # + INT Mod) * Class Level) + FC Skill Total (min 1 per level)"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Used Skills"}),": Sum of(Skill Ranks + Custom Skill Ranks)"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Total Points in Skill"}),": Ranks + Ability Mod + Misc + (If Class and Rank == 3) - (If STR or DEX == Armor Check Penalty)"]})]})]})}function Wk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([0,1]);function c(N){return U.get(e.files[n].data.wealth,N)}function d(N){e.files[n].data.exp=N,e.files[n].saved=!1}function h(N,S){let w={};w[N]=S,U.assign(e.files[n].data.wealth,w),e.files[n].saved=!1}I.useEffect(()=>{let N=e.getLoadedIndex();if(N==-1){t("/");return}U.has(e.files[N],"data.exp")||U.assign(e.files[N].data,{exp:[0,1]}),U.has(e.files[N],"data.wealth")||U.assign(e.files[N].data,{wealth:{plat:[0,0],gold:[0,0],silv:[0,0],copp:[0,0],othe:""}}),i(N),a(e.files[N].data.exp)},[]);let m=0,_=0;do _+=1;while(S0[s[1]][_]<=s[0]);m=S0[s[1]][_];function k(N,S){let w=[...s];w[N]=S,a(w),d(w)}function C(N,S){h(N,S)}return n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Experience and Wealth"}),u.jsx("h2",{className:"mt-2",children:"Experience"}),u.jsxs("div",{className:"main-container",children:[u.jsx(st,{title:"Current XP",id:"xp",value:s[0],min:0,onChange:N=>k(0,N)}),u.jsx(Ce,{title:"Next Level",value:m}),u.jsx(Ir,{title:"Progression",id:"progress",value:s[1],items:["Slow","Medium","Fast"],onChange:N=>k(1,N)}),u.jsx(Ce,{title:"Current Level",value:_})]}),u.jsx("h2",{className:"mt-2",children:"Wealth"}),u.jsxs("div",{className:"main-container",children:[u.jsx(Ce,{title:"Platinum",value:u.jsx(mt,{title:["Carried","Stored"],id:"platinum",value:c("plat"),min:[0,0],max:[99999999,99999999],className:"flex-grow",color:"secondary",onChange:N=>C("plat",N)})}),u.jsx(Ce,{title:"Gold",value:u.jsx(mt,{title:["Carried","Stored"],id:"gold",value:c("gold"),min:[0,0],max:[99999999,99999999],className:"flex-grow",color:"secondary",onChange:N=>C("gold",N)})}),u.jsx(Ce,{title:"Silver",value:u.jsx(mt,{title:["Carried","Stored"],id:"silver",value:c("silv"),min:[0,0],max:[99999999,99999999],className:"flex-grow",color:"secondary",onChange:N=>C("silv",N)})}),u.jsx(Ce,{title:"Copper",value:u.jsx(mt,{title:["Carried","Stored"],id:"copper",value:c("copp"),min:[0,0],max:[99999999,99999999],className:"flex-grow",color:"secondary",onChange:N=>C("copp",N)})}),u.jsx(ys,{title:"Other (in gp)",id:"other",value:c("othe"),onChange:N=>C("othe",N)})]})]})}function Bk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1);function s(c){return U.get(e.files[n].data.abilities,c)}function a(c,d){let h={};h[c]=d,U.assign(e.files[n].data.abilities,h),e.files[n].saved=!1}return I.useEffect(()=>{let c=e.getLoadedIndex();if(c==-1){t("/");return}U.has(e.files[c],"data.abilities")||U.assign(e.files[c].data,{abilities:{feats:[],features:[],racial:[],misc:[]}}),i(c)},[]),n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Feats and Abilities"}),u.jsxs("div",{className:"main-container",children:[u.jsx(xr,{title:"Feats",id:"feats",value:s("feats"),onChange:c=>a("feats",c)}),u.jsx(xr,{title:"Class Features",id:"features",value:s("features"),onChange:c=>a("features",c)}),u.jsx(xr,{title:"Racial",id:"racial",value:s("racial"),onChange:c=>a("racial",c)}),u.jsx(xr,{title:"Miscellaneous",id:"misc",value:s("misc"),onChange:c=>a("misc",c)})]})]})}function $k(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([]),[c,d]=I.useState(-1);function h(w){e.files[n].data.equipment=w,e.files[n].saved=!1}I.useEffect(()=>{let w=e.getLoadedIndex();if(w==-1){t("/");return}U.has(e.files[w],"data.equipment")||U.assign(e.files[w].data,{equipment:[]}),i(w),a(e.files[w].data.equipment)},[]);let m=0;s.forEach(w=>{m+=w.weight*w.num});function _(){let w=[...s];w.push({_id:ut(),name:"New Item",ref:"",num:0,weight:0,info:""}),h(w),a(w)}function k(w){d(w),window.removequip.showModal()}function C(w){if(w==="ok"){let A=[...s];A.splice(c,1),h(A),a(A),d(-1)}}function N(w,A,y){let g=[...s];g[w][A]=y,a(g),h(g)}function S(){return n==-1?u.jsx("p",{children:"Loading..."}):s.length==0?u.jsx("p",{children:"No items have been added yet..."}):s.map((w,A)=>u.jsxs(Oe,{title:w.name,titleElements:u.jsx("div",{children:w.num}),children:[u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Re,{title:"Name",id:`quip${A}name`,value:w.name,className:"flex-grow",color:"secondary",onChange:y=>N(A,"name",y)}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>k(A)})]}),u.jsx(Re,{title:"Ref",id:`quip${A}ref`,value:w.ref,color:"secondary",onChange:y=>N(A,"ref",y)}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(st,{title:"# of",id:`quip${A}num`,value:w.num,min:0,max:5e3,className:"flex-grow w-1/2",color:"secondary",onChange:y=>N(A,"num",y)}),u.jsx(st,{title:"Weight",id:`quip${A}weight`,value:w.weight,min:0,max:1e4,className:"flex-grow w-1/2",color:"secondary",onChange:y=>N(A,"weight",y)})]}),u.jsx(ys,{title:"Notes",id:`quip${A}info`,value:w.info,color:"secondary",onChange:y=>N(A,"info",y)})]},`class-${w._id}`))}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Equipment"}),u.jsxs("div",{className:"main-container",children:[u.jsx(X,{color:"primary",onClick:_,children:"Add Item"}),u.jsx(Ce,{title:"Total Weight",value:m}),S()]}),u.jsxs(sl,{id:"removequip",title:"Confirm Remove?",type:wn.okcancel,onClose:w=>C(w),children:[u.jsx("p",{children:"Are you sure you wish to remove this item?"}),u.jsx("p",{children:"This action is permanent and can only be reverted by re-loading the character data."})]})]})}function Hk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([]),[c,d]=I.useState(-1);function h(g){e.files[n].data.spellbook=g,e.files[n].saved=!1}I.useEffect(()=>{let g=e.getLoadedIndex();if(g==-1){t("/");return}U.has(e.files[g],"data.spellbook")||U.assign(e.files[g].data,{spellbook:[]}),i(g),a(e.files[g].data.spellbook)},[]);let m=[],_=[0,0,0,0,0,0];if(n!=-1&&(U.has(e.files[n],"data.classes")&&e.files[n].data.classes.forEach(g=>{m.push({_id:g._id,name:g.name,level:g.level})}),U.has(e.files[n].data,"stats"))){let g=e.files[n].data.stats;_.forEach((j,M)=>{_[M]=U.sum(U.get(g,va[M]))})}function k(g){for(let j=0;j{let M=k(g.class_id);return u.jsxs(Oe,{title:`${m[M].name}'s Spellbook`,children:[u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Ir,{title:"Class",id:`sb-${g._id}-class`,value:M,items:m.map(O=>O.name),className:"flex-grow",color:"secondary",onChange:O=>w(j,"class_id",m[O]._id)}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>N(j)})]}),u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Ir,{title:"Stat",id:`sb-${g._id}-score`,value:g.score,items:["Intelligence","Wisdom","Charisma"],className:"w-2/3",color:"secondary",onChange:O=>w(j,"score",O)}),u.jsx(Ce,{title:"CL",value:m[M].level,color:"secondary",className:"w-1/3"})]}),u.jsx(Oe,{title:"Spell Slots",color:"secondary",children:Array(10).fill(0).map((O,L)=>{let F=Yg(_[g.score+3]),$=Math.ceil(F/4)+(F%4==0?1:0)-Math.ceil((L-F%4)/4);L==0&&($=0);let Z=10+L+F,Y=$+g.stats[L][0]+g.stats[L][1];return _[g.score+3]<10+L?u.jsx(Ce,{title:L,value:"Cannot cast spells of this level...",color:"accent"},`${g._id}${L}`):u.jsx(Ce,{title:L,color:"accent",value:u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"DC"}),u.jsx("p",{className:"text-center m-0 p-0",children:Z})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Total"}),u.jsx("p",{className:"text-center m-0 p-0",children:Y})]}),u.jsxs("div",{className:"flex flex-col divide-y divide-solid divide-black",children:[u.jsx("p",{className:"text-xs m-0 p-0",children:"Mod"}),u.jsx("p",{className:"text-center m-0 p-0",children:L==0?"-":$})]}),u.jsx(mt,{title:["Class","Misc","Known"],id:`ss-${L}`,value:s[j].stats[L],color:"info",onChange:ye=>A(j,L,ye)})]})},`${g._id}${L}`)})}),u.jsxs(Oe,{title:"Distances",color:"secondary",children:[u.jsx(Ce,{title:"Long",value:400+40*m[M].level,color:"accent"}),u.jsx(Ce,{title:"Medium",value:100+10*m[M].level,color:"accent"}),u.jsx(Ce,{title:"Short",value:25+5*Math.ceil(m[M].level/2),color:"accent"})]}),u.jsx(xr,{title:"Spells",id:`sb-${g._id}-book`,value:g.book,color:"secondary",onChange:O=>w(j,"book",O)})]},g._id)})}return n==-1?u.jsx("p",{children:"Loading..."}):u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Spellbook"}),u.jsxs("div",{className:"main-container",children:[u.jsx(X,{color:"primary",onClick:C,children:"Add Spellbook"}),y()]}),u.jsxs("div",{className:"msg-container",children:[u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Save DC"}),": 10 + Spell Level + Ability Mod"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Total Spells"}),": Can cast; Class Spells + Spell Mod Calc + Misc"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Spell Mod Calculation"}),": Mod = Ability Mod, Lv = Spell Level; (⌈Mod / 4⌉ + (((Mod % 4) == 0) ? 1 : 0)) - ⌈(Lv - (Mod % 4)) / 4⌉"]}),u.jsxs("div",{children:[u.jsx("span",{className:"font-bold",children:"Distances"}),": Cl = Caster Level; Long = 400 + 40 * Cl, Medium = 100 + 10 * Cl, Short = 25 + 5 * ⌈Cl / 2⌉"]})]}),u.jsxs(sl,{id:"removebook",title:"Confirm Remove?",color:"warning",type:wn.okcancel,onClose:g=>S(g),children:[u.jsx("p",{children:"Are you sure you wish to remove this spellbook?"}),u.jsx("p",{children:"This action is permanent and can only be reverted by re-loading the character data."})]})]})}function Vk(){let e=I.useContext(qe),t=nt(),[n,i]=I.useState(-1),[s,a]=I.useState([]),[c,d]=I.useState(-1);function h(S){e.files[n].data.notes=S,e.files[n].saved=!1}I.useEffect(()=>{let S=e.getLoadedIndex();if(S==-1){t("/");return}U.has(e.files[S],"data.notes")||U.assign(e.files[S].data,{notes:[]}),i(S),a(e.files[S].data.notes)},[]);function m(){let S=[...s];S.push({_id:ut(),name:"New Note",info:""}),h(S),a(S)}function _(S){d(S),window.removenote.showModal()}function k(S){if(S==="ok"){let w=[...s];w.splice(c,1),h(w),a(w),d(-1)}}function C(S,w,A){let y=[...s];y[S][w]=A,a(y),h(y)}function N(){return n==-1?u.jsx("p",{children:"Loading..."}):s.length==0?u.jsx("p",{children:"No notes have been added yet..."}):s.map((S,w)=>u.jsxs(Oe,{title:S.name,children:[u.jsxs("div",{className:"flex flex-row space-x-1",children:[u.jsx(Re,{title:"Name",id:`note${w}name`,value:S.name,className:"flex-grow",color:"secondary",onChange:A=>C(w,"name",A)}),u.jsx(X,{color:"error",className:"bi-trash",onClick:()=>_(w)})]}),u.jsx(ys,{title:"Notes",id:`note${w}info`,value:S.info,color:"secondary",onChange:A=>C(w,"info",A)})]},`note-${S._id}`))}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Notes"}),u.jsx("div",{className:"main-container",children:u.jsx(X,{color:"primary",onClick:m,children:"Add Note"})}),u.jsx("div",{className:"main-container",children:N()}),u.jsxs(sl,{id:"removenote",title:"Confirm Remove?",color:"warning",type:wn.okcancel,onClose:S=>k(S),children:[u.jsx("p",{children:"Are you sure you wish to remove this note?"}),u.jsx("p",{children:"This action is permanent and can only be reverted by re-loading the character data."})]})]})}function Gk(e){let t=ni(),n=s=>t.pathname==`/tools/${s}`;function i(){switch(!0){case n("dice"):return u.jsx(Qk,{});case n("stats"):return u.jsx(Kk,{});default:return u.jsx("p",{children:"Please select a tool from the buttons above..."})}}return u.jsxs(u.Fragment,{children:[u.jsx("h1",{children:"Tools"}),u.jsxs("div",{className:"base-size flex flex-row justify-evenly my-2",children:[u.jsx(X,{as:bi,to:"/tools/dice",children:"Dice Roller"}),u.jsx(X,{as:bi,to:"/tools/stats",children:"Stats Roller"})]}),i()]})}function Qk(){let[e,t]=I.useState(1),[n,i]=I.useState(5),[s,a]=I.useState(0),[c,d]=I.useState(0),[h,m]=I.useState(0),[_,k]=I.useState(0),[C,N]=I.useState(0),[S,w]=I.useState(0),[A,y]=I.useState(0),[g,j]=I.useState(0),[M,O]=I.useState(""),L=[4,6,8,10,12,20,100,0];function F(Y,ye){t(Y),i(ye)}function $(){t(1),i(5),a(0),d(0),m(0),k(0),N(0),w(0),y(0),j(0),O("")}function Z(){let Y=0,ye="";for(let Ve=0;Ve0&&(Y*=A),h>0&&(Y+=h),C>0&&(Y-=C),ye+=`Roll (${Ve+1}): ${oe}${A>0?` x ${A}`:""}${h>0?` + ${h}`:""}${C>0?` - ${C}`:""} (${Y}) `}S>0&&(Y*=S,ye+=`Multiply by ${S} (${Y}) `),c>0&&(Y+=c,ye+=`Add ${c} (${Y}) `),_>0&&(Y-=_,ye+=`Subtract ${_} (${Y}) @@ -107,11 +107,11 @@