zois-core 1.1.9 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import l from"./styles.css";import{findModByName as u,registerMod as g}from"./modsApi";import{initVirtualDOM as d,useToastsStore as f,useDialogStore as m}from"./popups";import{version as A}from"../package.json";let c;function C(e){if(!window.ZOISCORE){const t=document.createElement("style");t.innerHTML=l,document.head.append(t),window.ZOISCORE=Object.freeze({loaded:!0,useToastsStore:f,useDialogStore:m}),d()}c={...e},g()}function p(e){return new Promise(t=>setTimeout(t,e))}async function h(e,t=()=>!1){for(;!e();){if(t())return!1;await p(10)}return!0}function y(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function w(e,t){const r=e.split("."),o=t.split(".");for(let n=0;n<Math.max(r.length,o.length);n++){const i=parseInt(r[n]||"0",10),s=parseInt(o[n]||"0",10);if(i>s)return!0;if(i<s)return!1}return!1}function D(e,t){return!e&&!t||!e&&t==="Default"||!t&&e==="Default"||e==="Default"&&Array.isArray(t)&&t.filter(r=>r==="Default").length===t.length||t==="Default"&&Array.isArray(e)&&e.filter(r=>r==="Default").length===e.length?!0:JSON.stringify(e)===JSON.stringify(t)}function T(e){return typeof e=="string"?Math.round(new TextEncoder().encode(e).byteLength/100)/10:Math.round(new TextEncoder().encode(JSON.stringify(e)).byteLength/100)/10}function N(e){if(e)return ChatRoomCharacter.find(t=>t.MemberNumber==e||t.Name.toLowerCase()===e||t.Nickname?.toLowerCase()===e)}function O(e){return CharacterNickname(e)}function S(){if(!u("Themed"))return null;const e=JSON.parse(LZString.decompressFromBase64(Player.ExtensionSettings.Themed??""));return!e?.GlobalModule?.themedEnabled||!e?.GlobalModule?.doVanillaGuiOverhaul?null:e.ColorsModule}function k(e){const t=document.createElement("style");t.innerHTML=e,document.head.append(t)}function P(e){h(()=>typeof window.Player?.MemberNumber=="number").then(()=>setTimeout(e,y(3e3,6e3)))}function a(e){return typeof e!="object"||e===null?e:Array.isArray(e)?e.map(a).sort():Object.keys(e).sort().reduce((t,r)=>(t[r]=a(e[r]),t),{})}export{c as MOD_DATA,D as colorsEqual,O as getNickname,N as getPlayer,y as getRandomNumber,T as getSizeInKbytes,S as getThemedColorsModule,k as injectStyles,w as isVersionNewer,a as normalizeObject,C as registerCore,p as sleep,A as version,h as waitFor,P as waitForStart};
1
+ import l from"./styles.css";import{findModByName as u,registerMod as g}from"./modsApi";import{initVirtualDOM as m,useToastsStore as d,useDialogStore as f}from"./popups";import{version as c}from"../package.json";import{version as B}from"../package.json";let p;function D(e){if(!window.ZOISCORE){const t=document.createElement("style");t.innerHTML=l,document.head.append(t),window.ZOISCORE=Object.freeze({loaded:!0,useToastsStore:d,useDialogStore:f,version:c}),document.addEventListener("click",r=>{const o=r.target.closest("a");if(o&&o.href)try{const n=new URL(o.href);if(n.protocol==="zc:"&&(r.preventDefault(),o.href.startsWith("zc://open"))){const i={subscreen:n.searchParams.get("subscreen")};n.searchParams.get("mod")&&(i.mod=n.searchParams.get("mod")),window.dispatchEvent(new CustomEvent("zoiscore:open",{detail:i}))}}catch{}},!0),m()}p={...e},g()}function h(e){return new Promise(t=>setTimeout(t,e))}async function y(e,t=()=>!1){for(;!e();){if(t())return!1;await h(10)}return!0}function b(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function S(e,t){const r=e.split("."),o=t.split(".");for(let n=0;n<Math.max(r.length,o.length);n++){const i=parseInt(r[n]||"0",10),s=parseInt(o[n]||"0",10);if(i>s)return!0;if(i<s)return!1}return!1}function T(e,t){return!e&&!t||!e&&t==="Default"||!t&&e==="Default"||e==="Default"&&Array.isArray(t)&&t.filter(r=>r==="Default").length===t.length||t==="Default"&&Array.isArray(e)&&e.filter(r=>r==="Default").length===e.length?!0:JSON.stringify(e)===JSON.stringify(t)}function N(e){return typeof e=="string"?Math.round(new TextEncoder().encode(e).byteLength/100)/10:Math.round(new TextEncoder().encode(JSON.stringify(e)).byteLength/100)/10}function O(e){if(e)return ChatRoomCharacter.find(t=>t.MemberNumber==e||t.Name.toLowerCase()===e||t.Nickname?.toLowerCase()===e)}function k(e){return CharacterNickname(e)}function E(){if(!u("Themed"))return null;const e=JSON.parse(LZString.decompressFromBase64(Player.ExtensionSettings.Themed??""));return!e?.GlobalModule?.themedEnabled||!e?.GlobalModule?.doVanillaGuiOverhaul?null:e.ColorsModule}function P(e){const t=document.createElement("style");t.innerHTML=e,document.head.append(t)}function v(e){y(()=>typeof window.Player?.MemberNumber=="number").then(()=>setTimeout(e,b(3e3,6e3)))}function a(e){return typeof e!="object"||e===null?e:Array.isArray(e)?e.map(a).sort():Object.keys(e).sort().reduce((t,r)=>(t[r]=a(e[r]),t),{})}export{p as MOD_DATA,T as colorsEqual,k as getNickname,O as getPlayer,b as getRandomNumber,N as getSizeInKbytes,E as getThemedColorsModule,P as injectStyles,S as isVersionNewer,a as normalizeObject,D as registerCore,h as sleep,B as version,y as waitFor,v as waitForStart};
package/dist/modsApi.js CHANGED
@@ -1 +1 @@
1
- import s from"bondage-club-mod-sdk";import{MOD_DATA as i}from"./index";import{getCurrentSubscreen as a}from"./ui";var d=(n=>(n[n.OBSERVE=0]="OBSERVE",n[n.ADD_BEHAVIOR=1]="ADD_BEHAVIOR",n[n.MODIFY_BEHAVIOR=5]="MODIFY_BEHAVIOR",n[n.OVERRIDE_BEHAVIOR=10]="OVERRIDE_BEHAVIOR",n[n.TOP=100]="TOP",n))(d||{});let o;function T(){o=s.registerMod({name:i.name,fullName:i.fullName,version:i.version,repository:i.repository}),c("GameKeyDown",1,(e,t)=>{const r=a();return CommonKey.IsPressed(e[0],"Escape")&&r?(r.exit(),!1):t(e)})}function c(e,t,r){if(!o)throw new Error("zois-core is not registered");return o.hookFunction(e,t,r)}function h(e,t){if(!o)throw new Error("zois-core is not registered");o.patchFunction(e,t)}function I(e,t,r){if(!o)throw new Error("zois-core is not registered");return o.callOriginal(e,t)}function x(){return s.getModsInfo()}function E(e){return!!s.getModsInfo().find(t=>t.name===e)}export{d as HookPriority,I as callOriginal,E as findModByName,x as getLoadedMods,c as hookFunction,o as modSdk,h as patchFunction,T as registerMod};
1
+ import c from"bondage-club-mod-sdk";import{MOD_DATA as o}from"./index";import{getCurrentSubscreen as u,setSubscreen as d}from"./ui";import{dialogsManager as m}from"./popups";var f=(t=>(t[t.OBSERVE=0]="OBSERVE",t[t.ADD_BEHAVIOR=1]="ADD_BEHAVIOR",t[t.MODIFY_BEHAVIOR=5]="MODIFY_BEHAVIOR",t[t.OVERRIDE_BEHAVIOR=10]="OVERRIDE_BEHAVIOR",t[t.TOP=100]="TOP",t))(f||{});let s;function O(){window.ZOISCORE_MODS??=[],window.ZOISCORE_MODS.push({name:o.name,fullName:o.fullName,key:o.key,version:o.version,deepLinkSubscreens:o.deepLinkSubscreens??[]}),s=c.registerMod({name:o.name,fullName:o.fullName,version:o.version,repository:o.repository}),l("GameKeyDown",1,(e,n)=>{const r=u();if(CommonKey.IsPressed(e[0],"Escape")&&r)return r.exit(),!1;const i=document.querySelector(".zcDialog");return i instanceof HTMLDivElement?(i.focus(),!1):n(e)}),window.addEventListener("zoiscore:open",async e=>{const n=e.detail.subscreen,r=e.detail.mod;if(r&&r!==o.key||u()?.constructor.name===n)return;const a=o.deepLinkSubscreens?.find(t=>t.constructor.name===n);a&&await m.confirm({message:"This deep link wants to redirect you to another subscreen. Confirm the redirecting."})&&d(a)})}function l(e,n,r){if(!s)throw new Error("zois-core is not registered");return s.hookFunction(e,n,r)}function w(e,n){if(!s)throw new Error("zois-core is not registered");s.patchFunction(e,n)}function I(e,n,r){if(!s)throw new Error("zois-core is not registered");return s.callOriginal(e,n)}function y(){return c.getModsInfo()}function x(e){return!!c.getModsInfo().find(n=>n.name===e)}export{f as HookPriority,I as callOriginal,x as findModByName,y as getLoadedMods,l as hookFunction,s as modSdk,w as patchFunction,O as registerMod};
package/dist/popups.js CHANGED
@@ -1 +1 @@
1
- import{getRelativeX as D,getRelativeY as x}from"./ui";import{MOD_DATA as d}from"./index";import{useState as p,useEffect as u,useRef as E}from"react";import k from"react-dom/client";import{create as S}from"zustand";import{CircleAlert as I,CircleCheck as O,CircleX as P,Info as z}from"lucide-react";import{Fragment as f,jsx as i,jsxs as l}from"react/jsx-runtime";const R=({children:s})=>{const[e,o]=p({}),r=window.ZOISCORE.useToastsStore(t=>t.clearToasts);return u(()=>{const t=()=>{o({fontFamily:CommonGetFontName(),bottom:x(5)+"px",left:D(5)+"px"})};return window.addEventListener("resize",t),t(),()=>{window.removeEventListener("resize",t)}},[]),i("div",{className:"zcToastsContainer",style:e,onClick:()=>{document.querySelectorAll(".zcToast").forEach(t=>{t.classList.add("exiting")}),setTimeout(r,300)},children:s})},M=({type:s,theme:e})=>{switch(s){case"info":return i(z,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#addbff",stroke:e?e.iconStrokeColor:"#385073"}});case"success":return i(O,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#c3ffc3",stroke:e?e.iconStrokeColor:"#028f74"}});case"warning":return i(I,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#ffdfaf",stroke:e?e.iconStrokeColor:"#9c7633"}});case"error":return i(P,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#ffb2b2",stroke:e?e.iconStrokeColor:"#7f2828"}});case"spinner":return i("div",{style:{flexShrink:0,width:"1.65em",height:"1.65em",boxSizing:"border-box",border:"2px solid",borderRadius:"100%",borderColor:`transparent ${e?e.iconFillColor:"rgb(154 154 255)"}`,animation:"zcSpin 0.65s linear infinite"}})}},F=({title:s,message:e,type:o,duration:r,theme:t})=>{const[n,a]=p({}),[c,m]=p(!1),h=t?t.backgroundColor:o==="success"?"#3ece7e":o==="warning"?"#debf72":o==="error"?"rgb(212, 46, 107)":"rgb(80, 80, 223)",C=t?t.titleColor:o==="info"||o==="spinner"?"rgb(47, 46, 104)":o==="success"?"#244428":o==="error"?"rgb(113, 2, 2)":"#5e4328",T=t?t.messageColor:o==="info"||o==="spinner"?"#b8b8ff":o==="success"?"#c7f9c7":o==="error"?"rgb(255, 152, 152)":"#ffeec5";return u(()=>{const g=()=>{const w=MainCanvas.canvas.clientWidth,b=MainCanvas.canvas.clientHeight,v=Math.min(w,b)/100;a({position:"relative",width:"100%",fontSize:3*v+"px",padding:1.5*v+"px",background:h})};window.addEventListener("resize",g),g();const y=setTimeout(()=>m(!0),r);return()=>{clearTimeout(y),window.removeEventListener("resize",g)}},[]),l("div",{className:`zcToast ${c&&"exiting"}`,"data-zc-toast-type":o,style:n,children:[l("div",{style:{display:"flex",alignItems:"center",gap:"1vw",position:"relative",zIndex:5},children:[i(M,{type:o,theme:t}),l("div",{children:[s&&e&&l(f,{children:[i("p",{style:{color:C,fontWeight:"bold"},children:s}),i("p",{style:{color:T,fontSize:"70%",fontWeight:"bold",overflowWrap:"anywhere",marginTop:"0.25em"},children:e})]}),(!s&&e||s&&!e)&&i("p",{style:{position:"relative",zIndex:5,color:T,fontWeight:"bold",overflowWrap:"anywhere"},children:s||e})]})]}),o!=="spinner"&&i("div",{className:"zcToast-ProgressBar",style:{animation:`zcToast-progress ${r}ms linear 0s 1 alternate none`,position:"absolute",top:0,left:0,height:"100%",borderRadius:"4px",background:t?t.progressBarColor:o==="info"?"rgb(103, 103, 234)":o==="success"?"#34bc71":o==="warning"?"#d0af5e":"rgb(183, 40, 92)"}})]})};function W({dialog:s}){const e=window.ZOISCORE.useDialogStore(a=>a.clearDialog),[o,r]=p(""),t=E(null),n=a=>{a.key==="Enter"&&(e(),s.promise.resolve(s.type==="prompt"?o:!0))};return u(()=>(document.body.style.pointerEvents="none",s.type==="prompt"&&t.current instanceof HTMLInputElement&&t.current.focus(),document.addEventListener("keypress",n),()=>{document.body.style.pointerEvents="",document.removeEventListener("keypress",n)}),[]),l(f,{children:[l("dialog",{className:"zcDialog","data-zc-dialog-type":s.type,style:{fontFamily:CommonGetFontName()},children:[i("p",{children:s.message}),s.type==="prompt"&&i("input",{ref:t,type:"text",style:{color:"white",marginTop:"1px",width:"90%",background:"rgb(82, 89, 104)",border:"none",borderRadius:"4px",padding:"0.45em"},onChange:a=>r(a.currentTarget.value)}),l("div",{style:{display:"flex",justifyContent:"end",columnGap:"0.75em",width:"100%",padding:"1em"},children:[i("button",{onClick:()=>{e(),s.promise.resolve(!1)},children:"Cancel"}),i("button",{onClick:()=>{e(),s.promise.resolve(s.type==="prompt"?o:!0)},children:"Ok"})]})]}),i("div",{style:{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"20",opacity:"0.5",background:"black"}})]})}class L{generateToastId(){return crypto.randomUUID()}process({title:e,message:o,duration:r,type:t,id:n,theme:a}){const{addToast:c,removeToast:m}=window.ZOISCORE.useToastsStore.getState();c({id:n,title:e,message:o,duration:r,type:t,theme:a}),setTimeout(()=>m(n),r+300)}info({title:e,message:o,duration:r}){const t=this.generateToastId(),n=d.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"info",id:t,theme:n})}success({title:e,message:o,duration:r}){const t=this.generateToastId(),n=d.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"success",id:t,theme:n})}warn({title:e,message:o,duration:r}){const t=this.generateToastId(),n=d.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"warning",id:t,theme:n})}error({title:e,message:o,duration:r}){const t=this.generateToastId(),n=d.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"error",id:t,theme:n})}spinner({title:e,message:o}){const r=this.generateToastId(),t=d.singleToastsTheme;return this.process({title:e,message:o,duration:1e6,type:"spinner",id:r,theme:t}),r}removeSpinner(e){const{removeToast:o}=window.ZOISCORE.useToastsStore.getState();o(e)}}class N{prompt({message:e}){const{setDialog:o}=window.ZOISCORE.useDialogStore.getState();return new Promise((r,t)=>{o({type:"prompt",message:e,promise:{resolve:r,reject:t}})})}confirm({message:e}){const{setDialog:o}=window.ZOISCORE.useDialogStore.getState();return new Promise((r,t)=>{o({type:"confirm",message:e,promise:{resolve:r,reject:t}})})}}function Z(){const s=window.ZOISCORE.useToastsStore(o=>o.toasts),e=window.ZOISCORE.useDialogStore(o=>o.dialog);return l(f,{children:[i(R,{children:s.map(({title:o,message:r,type:t,duration:n,id:a,theme:c})=>i(F,{id:a,title:o,message:r,type:t,duration:n,theme:c},a))}),e&&i(W,{dialog:e})]})}class A extends HTMLElement{disconnectedCallback(){ServerShowBeep("VirtualDOM was removed, chaos is coming...",5e3,{})}}const ee=S(s=>({toasts:[],addToast:e=>s(o=>({toasts:[...o.toasts,e]})),removeToast:e=>s(o=>({toasts:o.toasts.filter(r=>r.id!==e)})),clearToasts:()=>s({toasts:[]})})),oe=S(s=>({dialog:null,setDialog:e=>s({dialog:e}),clearDialog:()=>s({dialog:null})}));function te(){customElements.define("zc-virtual-dom",A);const s=document.createElement("zc-virtual-dom");document.body.append(s),k.createRoot(document.getElementsByTagName("zc-virtual-dom")[0]).render(i(Z,{}))}const se=new L,re=new N;export{re as dialogsManager,te as initVirtualDOM,se as toastsManager,oe as useDialogStore,ee as useToastsStore};
1
+ import{getRelativeX as D,getRelativeY as P}from"./ui";import{MOD_DATA as g}from"./index";import{useState as u,useEffect as f,useRef as k}from"react";import x from"react-dom/client";import{create as w}from"zustand";import{CircleAlert as E,CircleCheck as O,CircleX as I,Info as R}from"lucide-react";import{Fragment as v,jsx as i,jsxs as d}from"react/jsx-runtime";function z({children:t}){const[e,o]=u({}),r=window.ZOISCORE.useToastsStore(s=>s.clearToasts);return f(()=>{const s=()=>{o({fontFamily:CommonGetFontName(),bottom:P(5)+"px",left:D(5)+"px"})};return window.addEventListener("resize",s),s(),()=>{window.removeEventListener("resize",s)}},[]),i("div",{className:"zcToastsContainer",style:e,onClick:()=>{document.querySelectorAll(".zcToast").forEach(s=>{s.classList.add("exiting")}),setTimeout(r,300)},children:t})}const M=({type:t,theme:e})=>{switch(t){case"info":return i(R,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#addbff",stroke:e?e.iconStrokeColor:"#385073"}});case"success":return i(O,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#c3ffc3",stroke:e?e.iconStrokeColor:"#028f74"}});case"warning":return i(E,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#ffdfaf",stroke:e?e.iconStrokeColor:"#9c7633"}});case"error":return i(I,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#ffb2b2",stroke:e?e.iconStrokeColor:"#7f2828"}});case"spinner":return i("div",{style:{flexShrink:0,width:"1.65em",height:"1.65em",boxSizing:"border-box",border:"2px solid",borderRadius:"100%",borderColor:`transparent ${e?e.iconFillColor:"rgb(154 154 255)"}`,animation:"zcSpin 0.65s linear infinite"}})}},F=({title:t,message:e,type:o,duration:r,theme:s})=>{const[n,l]=u({}),[c,m]=u(!1),a=s?s.backgroundColor:o==="success"?"#3ece7e":o==="warning"?"#debf72":o==="error"?"rgb(212, 46, 107)":"rgb(80, 80, 223)",p=s?s.titleColor:o==="info"||o==="spinner"?"rgb(47, 46, 104)":o==="success"?"#244428":o==="error"?"rgb(113, 2, 2)":"#5e4328",y=s?s.messageColor:o==="info"||o==="spinner"?"#b8b8ff":o==="success"?"#c7f9c7":o==="error"?"rgb(255, 152, 152)":"#ffeec5";return f(()=>{const T=()=>{const C=MainCanvas.canvas.clientWidth,b=MainCanvas.canvas.clientHeight,S=Math.min(C,b)/100;l({position:"relative",width:"100%",fontSize:3*S+"px",padding:1.5*S+"px",background:a})};window.addEventListener("resize",T),T();const h=setTimeout(()=>m(!0),r);return()=>{clearTimeout(h),window.removeEventListener("resize",T)}},[]),d("div",{className:`zcToast ${c&&"exiting"}`,"data-zc-toast-type":o,style:n,children:[d("div",{style:{display:"flex",alignItems:"center",gap:"1vw",position:"relative",zIndex:5},children:[i(M,{type:o,theme:s}),d("div",{children:[t&&e&&d(v,{children:[i("p",{style:{color:p,fontWeight:"bold"},children:t}),i("p",{style:{color:y,fontSize:"70%",fontWeight:"bold",overflowWrap:"anywhere",marginTop:"0.25em"},children:e})]}),(!t&&e||t&&!e)&&i("p",{style:{position:"relative",zIndex:5,color:y,fontWeight:"bold",overflowWrap:"anywhere"},children:t||e})]})]}),o!=="spinner"&&i("div",{className:"zcToast-ProgressBar",style:{animation:`zcToast-progress ${r}ms linear 0s 1 alternate none`,position:"absolute",top:0,left:0,height:"100%",borderRadius:"4px",background:s?s.progressBarColor:o==="info"?"rgb(103, 103, 234)":o==="success"?"#34bc71":o==="warning"?"#d0af5e":"rgb(183, 40, 92)"}})]})};function W({dialog:t}){const e=window.ZOISCORE.useDialogStore(a=>a.clearDialog),[o,r]=u(""),[s,n]=u(t.type==="pick"?t.options?.[0]?.value:null),l=k(null),c=()=>{e(),t.type==="prompt"&&t.promise.resolve(o),t.type==="confirm"&&t.promise.resolve(!0),t.type==="pick"&&t.promise.resolve(s)},m=()=>{e(),t.promise.resolve(!1)};return f(()=>(document.body.style.pointerEvents="none",t.type==="prompt"&&l.current instanceof HTMLInputElement&&(console.log("Focus call"),l.current.focus()),()=>{document.body.style.pointerEvents=""}),[]),f(()=>{const a=p=>{(p.key==="Enter"||p.key==="Escape")&&(p.preventDefault(),p.stopPropagation()),p.key==="Enter"&&c(),p.key==="Escape"&&m()};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a)}},[c,m]),d(v,{children:[d("div",{className:"zcDialog","data-zc-dialog-type":t.type,style:{fontFamily:CommonGetFontName()},children:[i("p",{children:t.message}),t.type==="prompt"&&i("input",{ref:l,type:"text",value:o,style:{color:"white",marginTop:"1px",width:"90%",background:"rgb(82, 89, 104)",border:"none",borderRadius:"4px",padding:"0.45em"},onChange:a=>{console.log(a.currentTarget.value),r(a.currentTarget.value)}}),t.type==="pick"&&i("select",{style:{cursor:"pointer",width:"90%",background:"rgb(82, 89, 104)",border:"none",padding:"0.4em",color:"white",borderRadius:"4px"},children:t.options.map(a=>i("option",{onClick:()=>{n(a.value)},children:a.name},a.name))}),d("div",{style:{display:"flex",justifyContent:"end",columnGap:"0.75em",width:"100%",padding:"1em"},children:[i("button",{onClick:m,children:"Cancel"}),i("button",{onClick:c,children:"Ok"})]})]}),i("div",{style:{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"20",opacity:"0.5",background:"black"}})]})}class L{generateToastId(){return crypto.randomUUID()}process({title:e,message:o,duration:r,type:s,id:n,theme:l}){const{addToast:c,removeToast:m}=window.ZOISCORE.useToastsStore.getState();c({id:n,title:e,message:o,duration:r,type:s,theme:l}),setTimeout(()=>m(n),r+300)}info({title:e,message:o,duration:r}){const s=this.generateToastId(),n=g.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"info",id:s,theme:n})}success({title:e,message:o,duration:r}){const s=this.generateToastId(),n=g.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"success",id:s,theme:n})}warn({title:e,message:o,duration:r}){const s=this.generateToastId(),n=g.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"warning",id:s,theme:n})}error({title:e,message:o,duration:r}){const s=this.generateToastId(),n=g.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"error",id:s,theme:n})}spinner({title:e,message:o}){const r=this.generateToastId(),s=g.singleToastsTheme;return this.process({title:e,message:o,duration:1e6,type:"spinner",id:r,theme:s}),r}removeSpinner(e){const{removeToast:o}=window.ZOISCORE.useToastsStore.getState();o(e)}}class Z{prompt({message:e}){const{setDialog:o}=window.ZOISCORE.useDialogStore.getState();return new Promise((r,s)=>{o({type:"prompt",message:e,promise:{resolve:r,reject:s}})})}confirm({message:e}){const{setDialog:o}=window.ZOISCORE.useDialogStore.getState();return new Promise((r,s)=>{o({type:"confirm",message:e,promise:{resolve:r,reject:s}})})}pick({message:e,options:o}){const{setDialog:r}=window.ZOISCORE.useDialogStore.getState();return new Promise((s,n)=>{r({type:"pick",message:e,options:o,promise:{resolve:s,reject:n}})})}}function B(){const t=window.ZOISCORE.useToastsStore(o=>o.toasts),e=window.ZOISCORE.useDialogStore(o=>o.dialog);return d(v,{children:[i(z,{children:t.map(({title:o,message:r,type:s,duration:n,id:l,theme:c})=>i(F,{id:l,title:o,message:r,type:s,duration:n,theme:c},l))}),e&&i(W,{dialog:e})]})}class N extends HTMLElement{disconnectedCallback(){ServerShowBeep("VirtualDOM was removed, chaos is coming...",5e3,{})}}const oe=w(t=>({toasts:[],addToast:e=>t(o=>({toasts:[...o.toasts,e]})),removeToast:e=>t(o=>({toasts:o.toasts.filter(r=>r.id!==e)})),clearToasts:()=>t({toasts:[]})})),te=w(t=>({dialog:null,setDialog:e=>t({dialog:e}),clearDialog:()=>t({dialog:null})}));function se(){customElements.define("zc-virtual-dom",N);const t=document.createElement("zc-virtual-dom");document.body.append(t),x.createRoot(document.getElementsByTagName("zc-virtual-dom")[0]).render(i(B,{}))}const re=new L,ie=new Z;export{ie as dialogsManager,se as initVirtualDOM,re as toastsManager,te as useDialogStore,oe as useToastsStore};
package/dist/styles.css CHANGED
@@ -1 +1 @@
1
- *{margin:0;padding:0;box-sizing:border-box}.zcButton{cursor:pointer;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, black);border-radius:4px}.zcButton:hover{background:var(--tmd-element-hover, #ebf7fe);border-color:var(--tmd-accent-hover, #7dd3fc);color:var(--tmd-accent-hover, #015a8c)}.zcButton .tooltip{position:absolute;color:#000;text-align:center;padding:4px;border-radius:4px;background:#ff8;border:2px solid #e7e787;width:max-content;visibility:hidden;z-index:10}.zcButton .tooltip[position=left]{right:calc(100% + 1vw)}.zcButton .tooltip[position=right]{left:calc(100% + 1vw)}.zcButton:hover .tooltip{visibility:visible}.zcButton[data-zc-style=green]{background:#7cff7c;border-color:#52cc52;color:#000}.zcButton[data-zc-style=green]:hover{background:#5ec55e;color:#000}.zcButton[data-zc-style=inverted]{background:var(--tmd-accent, #303030);border:none;color:var(--tmd-text, white)}.zcButton[data-zc-style=inverted]:hover{background:var(--tmd-accent-hover, #474747)}.zcInput{background:var(--tmd-element, white);color:var(--tmd-text, black);padding:2vw;border:2px solid var(--tmd-accent, black);border-radius:4px}.zcInput::placeholder{color:var(--tmd-text, black)}.zcBackNextButton{display:flex;column-gap:2vw;justify-content:center;align-items:center;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, black);border-radius:4px}.zcBackNextButton-btnDisabled{background:#ffa590;pointer-events:none}.zcTabs{display:flex}.zcTabs button{cursor:pointer;width:100%;color:var(--tmd-text, black);background:none;border:none;border-bottom:2px solid var(--tmd-element, rgb(214, 214, 214));padding:.25em}.zcTabs button[data-opened=true]{font-weight:700;border-bottom:2px solid var(--tmd-accent, rgb(81, 81, 231))!important}.zcTabs button:hover{background:var(--tmd-element, rgb(235, 235, 235));border-bottom:2px solid var(--tmd-element-hover, rgb(149, 149, 149))}.zcCard{border:2px solid var(--tmd-accent, rgb(195, 195, 195));border-radius:.4em;background:var(--tmd-element, white);color:var(--tmd-text, black);padding:.4em 2.5em .4em .4em}.zcCard:hover{border:2px solid var(--tmd-accent-hover, rgb(170, 170, 170))}.zcCard_name{font-size:.5em;color:var(--tmd-text, rgb(100, 100, 100))}.zcCard_value{color:var(--tmd-text, black);margin-top:.4em;font-weight:700}.zcSelect{cursor:pointer;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, rgb(195, 195, 195));border-radius:.4em;padding:.45em;z-index:10}.zcSelect[opened=true]{border-color:var(--tmd-accent-hover, rgb(0, 96, 223))}.zcSelect[opened=false]:hover{border-color:var(--tmd-accent-hover, rgb(170, 170, 170))}.zcSelect>svg{position:absolute;right:.45em;top:50%;transform:translateY(-50%);width:1.5em;height:1.5em;color:var(--tmd-accent, rgb(0, 96, 223))}.zcSelect>div[data-zc-position=bottom]{position:absolute;top:calc(100% + .45em);left:0;width:100%;background:var(--tmd-element, #f6f6f6);border:2px solid var(--tmd-element-hover, rgb(235 235 235));border-radius:.4em}.zcSelect>div[data-zc-position=top]{position:absolute;bottom:calc(100% + .45em);left:0;width:100%;background:var(--tmd-element, #f6f6f6ed);border:2px solid var(--tmd-element-hover, rgb(235 235 235));border-radius:.4em}.zcSelect>div>div{color:var(--tmd-text, black);width:100%;padding:.45em;border-radius:.25em}.zcSelect>div>div>svg{width:1.25em;height:1.25em;color:var(--tmd-accent, rgb(0, 96, 223))}.zcSelect>div>div:hover{background:var(--tmd-element-hover, #ededed)}.zcToastsContainer{display:flex;flex-direction:column;gap:.25vw;cursor:pointer;position:fixed;z-index:30}@keyframes zcToast-progress{0%{width:0}to{width:100%}}@keyframes zcSlideInFromLeft{0%{transform:translate(-100%);opacity:0}to{transform:translate(0);opacity:1}}@keyframes zcSlideOutToLeft{0%{transform:translate(0);opacity:1}to{transform:translate(-100%);opacity:0}}.zcToast{max-width:25vw;animation:zcSlideInFromLeft .3s ease-out forwards;border-radius:4px}.zcToast.exiting{animation:zcSlideOutToLeft .3s ease-out forwards}.zcToast p{color:#fff}.zcDialog{display:flex;flex-direction:column;align-items:center;background:#39404d;margin:auto;position:absolute;inset:0;border:none;border-radius:4px;min-width:200px;max-width:450px;width:90%;z-index:25;pointer-events:all!important;box-shadow:0 0 6px 1px #0000006e}.zcDialog>p{padding:.75em 0;user-select:none;width:90%;color:#fff}.zcDialog>input:focus{outline:2px solid rgb(0,238,255)}.zcDialog>div>button{cursor:pointer;padding:6px 14px;border:none;border-radius:4px;font-weight:700}.zcDialog>div>button:first-child{background:#495263;color:#fff}.zcDialog>div>button:first-child:hover{background:#565e6c}.zcDialog>div>button:last-child{background:#0ef}.zcDialog>div>button:last-child:hover{background:#04cbd9}@keyframes zcSpin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes zcCursorBlink{0%{border-right-color:transparent}to{border-right-color:#2a2a2a}}.zcCursor{border-right:2px solid var(--tmd-text, rgb(42, 42, 42));width:fit-content}.zcDisabled{pointer-events:none;opacity:.6}
1
+ *{margin:0;padding:0;box-sizing:border-box}.zcButton{cursor:pointer;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, black);border-radius:4px}.zcButton:hover{background:var(--tmd-element-hover, #ebf7fe);border-color:var(--tmd-accent-hover, #7dd3fc);color:var(--tmd-accent-hover, #015a8c)}.zcButton .tooltip{position:absolute;color:#000;text-align:center;padding:4px;border-radius:4px;background:#ff8;border:2px solid #e7e787;width:max-content;visibility:hidden;z-index:10}.zcButton .tooltip[position=left]{right:calc(100% + 1vw)}.zcButton .tooltip[position=right]{left:calc(100% + 1vw)}.zcButton:hover .tooltip{visibility:visible}.zcButton[data-zc-style=green]{background:#7cff7c;border-color:#52cc52;color:#000}.zcButton[data-zc-style=green]:hover{background:#5ec55e;color:#000}.zcButton[data-zc-style=inverted]{background:var(--tmd-accent, #303030);border:none;color:var(--tmd-text, white)}.zcButton[data-zc-style=inverted]:hover{background:var(--tmd-accent-hover, #474747)}.zcInput{background:var(--tmd-element, white);color:var(--tmd-text, black);padding:2vw;border:2px solid var(--tmd-accent, black);border-radius:4px}.zcInput::placeholder{color:var(--tmd-text, black)}.zcBackNextButton{display:flex;column-gap:2vw;justify-content:center;align-items:center;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, black);border-radius:4px}.zcBackNextButton-btnDisabled{background:#ffa590;pointer-events:none}.zcTabs{display:flex}.zcTabs button{cursor:pointer;width:100%;color:var(--tmd-text, black);background:none;border:none;border-bottom:2px solid var(--tmd-element, rgb(214, 214, 214));padding:.25em}.zcTabs button[data-opened=true]{font-weight:700;border-bottom:2px solid var(--tmd-accent, rgb(81, 81, 231))!important}.zcTabs button:hover{background:var(--tmd-element, rgb(235, 235, 235));border-bottom:2px solid var(--tmd-element-hover, rgb(149, 149, 149))}.zcCard{border:2px solid var(--tmd-accent, rgb(195, 195, 195));border-radius:.4em;background:var(--tmd-element, white);color:var(--tmd-text, black);padding:.4em 2.5em .4em .4em}.zcCard:hover{border:2px solid var(--tmd-accent-hover, rgb(170, 170, 170))}.zcCard_name{font-size:.5em;color:var(--tmd-text, rgb(100, 100, 100))}.zcCard_value{color:var(--tmd-text, black);margin-top:.4em;font-weight:700}.zcSelect{cursor:pointer;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, rgb(195, 195, 195));border-radius:.4em;padding:.45em;z-index:10}.zcSelect[opened=true]{border-color:var(--tmd-accent-hover, rgb(0, 96, 223))}.zcSelect[opened=false]:hover{border-color:var(--tmd-accent-hover, rgb(170, 170, 170))}.zcSelect>svg{position:absolute;right:.45em;top:50%;transform:translateY(-50%);width:1.5em;height:1.5em;color:var(--tmd-accent, rgb(0, 96, 223))}.zcSelect>div[data-zc-position=bottom]{position:absolute;top:calc(100% + .45em);left:0;width:100%;background:var(--tmd-element, #f6f6f6);border:2px solid var(--tmd-element-hover, rgb(235 235 235));border-radius:.4em}.zcSelect>div[data-zc-position=top]{position:absolute;bottom:calc(100% + .45em);left:0;width:100%;background:var(--tmd-element, #f6f6f6ed);border:2px solid var(--tmd-element-hover, rgb(235 235 235));border-radius:.4em}.zcSelect>div>div{color:var(--tmd-text, black);width:100%;padding:.45em;border-radius:.25em}.zcSelect>div>div>svg{width:1.25em;height:1.25em;color:var(--tmd-accent, rgb(0, 96, 223))}.zcSelect>div>div:hover{background:var(--tmd-element-hover, #ededed)}.zcToastsContainer{display:flex;flex-direction:column;gap:.25vw;cursor:pointer;position:fixed;z-index:30}@keyframes zcToast-progress{0%{width:0}to{width:100%}}@keyframes zcSlideInFromLeft{0%{transform:translate(-100%);opacity:0}to{transform:translate(0);opacity:1}}@keyframes zcSlideOutToLeft{0%{transform:translate(0);opacity:1}to{transform:translate(-100%);opacity:0}}.zcToast{max-width:25vw;animation:zcSlideInFromLeft .3s ease-out forwards;border-radius:4px}.zcToast.exiting{animation:zcSlideOutToLeft .3s ease-out forwards}.zcToast p{color:#fff}.zcDialog{display:flex;flex-direction:column;align-items:center;background:#39404d;margin:auto;position:absolute;inset:0;border:none;border-radius:4px;min-width:200px;max-width:450px;width:90%;height:fit-content;z-index:100;pointer-events:all!important;box-shadow:0 0 6px 1px #0000006e}.zcDialog>p{padding:.75em 0;user-select:none;width:90%;color:#fff}.zcDialog>input:focus{outline:2px solid rgb(0,238,255)}.zcDialog>div>button{cursor:pointer;padding:6px 14px;border:none;border-radius:4px;font-weight:700}.zcDialog>div>button:first-child{background:#495263;color:#fff}.zcDialog>div>button:first-child:hover{background:#565e6c}.zcDialog>div>button:last-child{background:#0ef}.zcDialog>div>button:last-child:hover{background:#04cbd9}@keyframes zcSpin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes zcCursorBlink{0%{border-right-color:transparent}to{border-right-color:#2a2a2a}}.zcCursor{border-right:2px solid var(--tmd-text, rgb(42, 42, 42));width:fit-content}.zcDisabled{pointer-events:none;opacity:.6}
@@ -1,3 +1,4 @@
1
+ import { BaseSubscreen } from "./ui";
1
2
  export interface ModData {
2
3
  name: string;
3
4
  fullName: string;
@@ -15,6 +16,7 @@ export interface ModData {
15
16
  iconFillColor: string;
16
17
  iconStrokeColor: string;
17
18
  };
19
+ deepLinkSubscreens?: BaseSubscreen[];
18
20
  }
19
21
  interface ThemedColorsModule {
20
22
  base: {
@@ -7,14 +7,28 @@ interface ToastProps {
7
7
  duration: number;
8
8
  theme?: ModData["singleToastsTheme"];
9
9
  }
10
- interface DialogProps {
11
- type: "prompt" | "confirm";
10
+ interface BaseDialogProps<T> {
11
+ type: "prompt" | "confirm" | "pick";
12
12
  message: string;
13
13
  promise: {
14
- resolve: (data: any) => void;
15
- reject: (data: any) => void;
14
+ resolve: (data: T) => void;
15
+ reject: (data: T) => void;
16
16
  };
17
17
  }
18
+ interface ConfirmDialogProps extends BaseDialogProps<boolean> {
19
+ type: "confirm";
20
+ }
21
+ interface PromptDialogProps extends BaseDialogProps<string | false> {
22
+ type: "prompt";
23
+ }
24
+ interface PickDialogProps<T> extends BaseDialogProps<T | false> {
25
+ type: "pick";
26
+ options: {
27
+ name: string;
28
+ value: T;
29
+ }[];
30
+ }
31
+ type DialogProps = ConfirmDialogProps | PromptDialogProps | PickDialogProps<unknown>;
18
32
  declare class ToastsManager {
19
33
  private generateToastId;
20
34
  private process;
@@ -26,8 +40,9 @@ declare class ToastsManager {
26
40
  removeSpinner(id: string): void;
27
41
  }
28
42
  declare class DialogsManager {
29
- prompt({ message }: Omit<DialogProps, "type" | "promise">): Promise<string | false>;
30
- confirm({ message }: Omit<DialogProps, "type" | "promise">): Promise<boolean>;
43
+ prompt({ message }: Omit<PromptDialogProps, "type" | "promise">): Promise<string | false>;
44
+ confirm({ message }: Omit<ConfirmDialogProps, "type" | "promise">): Promise<boolean>;
45
+ pick<T>({ message, options }: Omit<PickDialogProps<T>, "type" | "promise">): Promise<T | false>;
31
46
  }
32
47
  export interface ToastsStore {
33
48
  toasts: ToastProps[];
@@ -138,7 +138,10 @@ export interface DynamicClassStyles {
138
138
  before?: Partial<CSSStyleDeclaration>;
139
139
  after?: Partial<CSSStyleDeclaration>;
140
140
  }
141
+ export declare function hexToRgb(hex: string): string;
141
142
  export declare function dataUrlSvgWithColor(dataUrl: string, newColor: string): string;
143
+ export declare function dataUrlSvgReplaceVars(dataUrl: string, vars: Record<string, string>): string;
144
+ export declare function cssVar(name: string, fallback: string): string;
142
145
  export declare function getRelativeHeight(height: number): number;
143
146
  export declare function getRelativeWidth(width: number): number;
144
147
  export declare function getRelativeY(yPos: number, anchorPosition?: 'top' | 'bottom'): number;
package/dist/ui.js CHANGED
@@ -1,11 +1,11 @@
1
- import{Check as N,ChevronDown as I,CircleX as F,createElement as T,Trash2 as W}from"lucide";import{getThemedColorsModule as z,MOD_DATA as C}from"./index";import{StyleModule as H}from"./ui-modules";function q(g,e){return g.replace(/fill="[^"]*"/g,`fill="${e}"`).replace(/stroke="[^"]*"/g,`stroke="${e}"`)}function D(g){return g*(MainCanvas.canvas.clientHeight/1e3)}function P(g){return g*(MainCanvas.canvas.clientWidth/2e3)}function V(g,e="top"){const o=MainCanvas.canvas.clientHeight/1e3;return e==="top"?MainCanvas.canvas.offsetTop+g*o:window.innerHeight-(MainCanvas.canvas.offsetTop+MainCanvas.canvas.clientHeight)+g*o}function R(g,e="left"){const o=MainCanvas.canvas.clientWidth/2e3;return e==="left"?MainCanvas.canvas.offsetLeft+g*o:window.innerWidth-(MainCanvas.canvas.offsetLeft+MainCanvas.canvas.clientWidth)+g*o}function O(g,e,o,l="top-left"){const i=l==="top-left"||l==="top-right"?"top":"bottom",n=l==="top-left"||l==="bottom-left"?"left":"right",t=V(o,i),f=R(e,n);Object.assign(g.style,{position:"fixed",[n]:f+"px",[i]:t+"px"})}function J(g,e,o){Object.assign(g.style,{width:P(e)+"px",height:D(o)+"px"})}function j(g,e){const o=MainCanvas.canvas.clientWidth,l=MainCanvas.canvas.clientHeight,i=Math.min(o,l)/100,n=e*i;Object.assign(g.style,{fontSize:n+"px"})}function L(g,e){g.style.fontFamily=e??"sans-serif"}function G(g,e){const o=MainCanvas.canvas.clientWidth,l=MainCanvas.canvas.clientHeight,i=Math.min(o,l)/100,n=e*i;Object.assign(g.style,{padding:n+"px"})}function X(g){const e=MainCanvas.canvas.clientWidth<=MainCanvas.canvas.clientHeight*2?MainCanvas.canvas.clientWidth/50:MainCanvas.canvas.clientHeight/25;Object.assign(g.style,{fontSize:e+"px"})}const B=[];function _(g){const e=o=>o?JSON.stringify(Object.keys(o).sort().reduce((l,i)=>(l[i]=o[i],l),{})):"null";return`base:${e(g.base)}|hover:${e(g.hover)}|active:${e(g.active)}|before:${e(g.before)}|after:${e(g.after)}`}function Q(g,e){const o=_(e),l=B.find(p=>p.key===o);if(l)return g.classList.add(l.className);let i;do i="dynamic-"+Math.random().toString(36).substring(2,10);while(B.find(p=>p.className===i));B.push({key:o,className:i});const n=(p,m)=>{let d=`${p} {`;for(const[r,c]of Object.entries(m))d+=`${r.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()}: ${c};`;return d+="}",d};let t="";e.base&&(t+=n(`.${i}`,e.base)),e.hover&&(t+=n(`.${i}:hover`,e.hover)),e.active&&(t+=n(`.${i}:active`,e.active)),e.focus&&(t+=n(`.${i}:focus`,e.focus)),e.disabled&&(t+=n(`.${i}:disabled`,e.disabled)),e.before&&(t+=n(`.${i}:before`,e.before)),e.after&&(t+=n(`.${i}:after`,e.after));let f=document.getElementById(`${C.key??""}-dynamic-classes`);f?f.textContent+=t:(f=document.createElement("style"),f.id=`${C.key??""}-dynamic-classes`,f.textContent=t,document.head.appendChild(f)),g.classList.add(i)}function U(){$(w)}function $(g){w=k,k=g,k&&k.load(),w&&w.unload()}function ee(){return k}let k,w=null;class te{htmlElements=[];resizeEventListeners=[];tabHandlers={};addElement(e,{x:o,y:l,width:i,height:n,padding:t,fontSize:f="auto",anchor:p,place:m,modules:d={},modulesMap:r}){L(e,C.fontFamily);const c={anchor:p,x:o,y:l,width:i,height:n,padding:t,fontSize:f,place:m,element:e};Object.keys(d)?.forEach(s=>{d[s].forEach(b=>{const u=b.overrideProperties(c,r[s]);p=u.anchor,o=u.x,l=u.y,i=u.width,n=u.height,t=u.padding,f=u.fontSize,m=u.place,e=u.element})});const a=()=>{typeof o=="number"&&typeof l=="number"&&O(e,o,l,p),f==="auto"?X(e):j(e,f),t&&G(e,t),i&&(e.style.width=P(i)+"px"),n&&(e.style.height=D(n)+"px")};a(),window.addEventListener("resize",a),Object.keys(d)?.forEach(s=>{d[s].forEach(b=>{b.layoutEffect(c,r[s])})}),m&&document.body.append(e),this.resizeEventListeners.push(a),this.htmlElements.push(e),Object.keys(d)?.forEach(s=>{d[s].forEach(b=>{b.effect(c,r[s])})})}get currentSubscreen(){return k}get previousSubscreen(){return w}get name(){return""}run(){this.tabHandlers.run?.()}load(){this.createButton({x:1815,y:75,width:90,height:90,icon:"Icons/Exit.png",modules:{base:[new H({zIndex:"10"})]}}).addEventListener("click",()=>this.exit()),this.name&&(this.createText({text:this.name,x:100,y:60,fontSize:8}).style.cssText+="max-width: 85%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0.1em;"),M[this.constructor.name]&&M[this.name].forEach(e=>e(this))}unload(){this.tabHandlers.unload?.(),this.htmlElements.forEach(e=>{e.remove()}),this.resizeEventListeners.forEach(e=>{removeEventListener("resize",e)})}click(){}exit(){this.tabHandlers.exit?.(),this.setSubscreen(this.previousSubscreen)}update(){}setPreviousSubscreen(){U()}setSubscreen(e){$(e)}createButton({text:e,x:o,y:l,width:i,height:n,fontSize:t="auto",anchor:f="top-left",padding:p,style:m="default",place:d=!0,icon:r,iconAbsolutePosition:c=!0,tooltip:a,onClick:s,isDisabled:b,modules:u}){let h,v;const y=document.createElement("button");if(y.classList.add("zcButton"),y.setAttribute("data-zc-style",m),y.style.display="flex",y.style.alignItems="center",y.style.justifyContent="center",y.style.columnGap="1.25vw",L(y,C.fontFamily),r&&(typeof r=="string"?(h=document.createElement("img"),h.src=r):h=r,h.style.height="80%",h.style.width="auto",e&&c&&(h.style.position="absolute",h.style.left="1vw"),e&&!c&&(y.style.justifyContent=""),y.append(h)),e&&(v=document.createElement("span"),v.textContent=e,y.append(v)),a){const S=document.createElement("span");S.classList.add("tooltip"),S.setAttribute("position",a.position),S.textContent=a.text,y.append(S)}return typeof b=="function"&&b()&&y.classList.add("zcDisabled"),y.addEventListener("click",()=>{if(typeof b=="function"&&b())return y.classList.add("zcDisabled");typeof s=="function"&&s()}),this.addElement(y,{x:o,y:l,width:i,height:n,anchor:f,place:d,fontSize:t,padding:p,modules:u,modulesMap:{base:y,text:v,icon:h}}),y}createText({text:e,color:o,x:l,y:i,width:n,height:t,withBackground:f=!1,withBorder:p=!1,fontSize:m="auto",anchor:d="top-left",padding:r,place:c=!0,modules:a}){const s=document.createElement("p");return s.innerHTML=e,s.style.color=o??"var(--tmd-text, black)",f&&(s.style.background="var(--tmd-element,rgb(239, 239, 239))"),p&&(s.style.border="2px solid var(--tmd-accent, rgb(236, 236, 236))"),L(s,C.fontFamily),this.addElement(s,{x:l,y:i,width:n,height:t,anchor:d,place:c,fontSize:m,padding:r,modules:a,modulesMap:{base:s}}),s}createInput({value:e,placeholder:o,x:l,y:i,width:n,height:t,textArea:f=!1,fontSize:p="auto",anchor:m="top-left",padding:d,place:r=!0,onChange:c,onInput:a,isDisabled:s,modules:b}){const u=document.createElement(f?"textarea":"input");return u.classList.add("zcInput"),o&&(u.placeholder=o),e&&(u.value=e),L(u,C.fontFamily),typeof s=="function"&&s()&&u.classList.add("zcDisabled"),u.addEventListener("change",()=>{if(typeof s=="function"&&s())return u.classList.add("zcDisabled");typeof c=="function"&&c()}),u.addEventListener("input",()=>{if(typeof s=="function"&&s())return u.classList.add("zcDisabled");typeof a=="function"&&a()}),this.addElement(u,{x:l,y:i,width:n,height:t,anchor:m,place:r,fontSize:p,padding:d,modules:b,modulesMap:{base:u}}),u}createCheckbox({text:e,x:o,y:l,isChecked:i,width:n,modules:t,anchor:f="top-left",place:p=!0,isDisabled:m,onChange:d}){const r=document.createElement("div");r.style.display="flex",r.style.alignItems="center",r.style.columnGap="1vw";const c=document.createElement("input");c.type="checkbox",c.checked=i,c.style.borderRadius="min(0.8dvh, 0.3dvw)",c.style.aspectRatio="1/1",c.classList.add("zcCheckbox","checkbox");const a=document.createElement("p");return a.textContent=e,a.style.color="var(--tmd-text, black)",L(a,C.fontFamily),typeof m=="function"&&m()&&r.classList.add("zcDisabled"),r.addEventListener("change",()=>{if(typeof m=="function"&&m())return r.classList.add("zcDisabled");typeof d=="function"&&d()}),r.append(c,a),this.addElement(r,{x:o,y:l,width:n,anchor:f,place:p,modules:t,modulesMap:{base:r,checkbox:c,label:a}}),r}createScrollView({scroll:e,x:o,y:l,width:i,height:n,anchor:t="top-left",modules:f,place:p=!0}){const m=document.createElement("div");return e==="all"&&(m.style.overflow="scroll"),e==="x"&&(m.style.overflowX="scroll"),e==="y"&&(m.style.overflowY="scroll"),this.addElement(m,{x:o,y:l,width:i,height:n,anchor:t,place:p,modules:f,modulesMap:{base:m}}),m}createInputList({x:e,y:o,width:l,height:i,title:n,value:t,modules:f,anchor:p="top-left",place:m=!0,numbersOnly:d=!1,isDisabled:r,onChange:c}){const a=[],s=document.createElement("div");s.style.cssText=`
1
+ import{Check as I,ChevronDown as N,CircleX as V,createElement as T,Trash2 as R}from"lucide";import{getThemedColorsModule as z,MOD_DATA as C}from"./index";import{StyleModule as H}from"./ui-modules";function W(l){l=l.replace("#","");const e=parseInt(l.substring(0,2),16),n=parseInt(l.substring(2,4),16),c=parseInt(l.substring(4,6),16);return`rgb(${e}, ${n}, ${c})`}function J(l,e){return l.replace(/fill="[^"]*"/g,`fill="${e}"`).replace(/stroke="[^"]*"/g,`stroke="${e}"`)}function Q(l,e){for(let[n,c]of Object.entries(e))c.startsWith("#")&&(c=W(c)),l=l.replaceAll(`$${n}`,c);return l}function ee(l,e){return getComputedStyle(document.documentElement).getPropertyValue(l).trim()||e}function D(l){return l*(MainCanvas.canvas.clientHeight/1e3)}function $(l){return l*(MainCanvas.canvas.clientWidth/2e3)}function F(l,e="top"){const n=MainCanvas.canvas.clientHeight/1e3;return e==="top"?MainCanvas.canvas.offsetTop+l*n:window.innerHeight-(MainCanvas.canvas.offsetTop+MainCanvas.canvas.clientHeight)+l*n}function O(l,e="left"){const n=MainCanvas.canvas.clientWidth/2e3;return e==="left"?MainCanvas.canvas.offsetLeft+l*n:window.innerWidth-(MainCanvas.canvas.offsetLeft+MainCanvas.canvas.clientWidth)+l*n}function j(l,e,n,c="top-left"){const i=c==="top-left"||c==="top-right"?"top":"bottom",a=c==="top-left"||c==="bottom-left"?"left":"right",t=F(n,i),m=O(e,a);Object.assign(l.style,{position:"fixed",[a]:m+"px",[i]:t+"px"})}function te(l,e,n){Object.assign(l.style,{width:$(e)+"px",height:D(n)+"px"})}function G(l,e){const n=MainCanvas.canvas.clientWidth,c=MainCanvas.canvas.clientHeight,i=Math.min(n,c)/100,a=e*i;Object.assign(l.style,{fontSize:a+"px"})}function L(l,e){l.style.fontFamily=e??"sans-serif"}function X(l,e){const n=MainCanvas.canvas.clientWidth,c=MainCanvas.canvas.clientHeight,i=Math.min(n,c)/100,a=e*i;Object.assign(l.style,{padding:a+"px"})}function _(l){const e=MainCanvas.canvas.clientWidth<=MainCanvas.canvas.clientHeight*2?MainCanvas.canvas.clientWidth/50:MainCanvas.canvas.clientHeight/25;Object.assign(l.style,{fontSize:e+"px"})}const B=[];function Y(l){const e=n=>n?JSON.stringify(Object.keys(n).sort().reduce((c,i)=>(c[i]=n[i],c),{})):"null";return`base:${e(l.base)}|hover:${e(l.hover)}|active:${e(l.active)}|before:${e(l.before)}|after:${e(l.after)}`}function ne(l,e){const n=Y(e),c=B.find(b=>b.key===n);if(c)return l.classList.add(c.className);let i;do i="dynamic-"+Math.random().toString(36).substring(2,10);while(B.find(b=>b.className===i));B.push({key:n,className:i});const a=(b,p)=>{let u=`${b} {`;for(const[o,d]of Object.entries(p))u+=`${o.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()}: ${d};`;return u+="}",u};let t="";e.base&&(t+=a(`.${i}`,e.base)),e.hover&&(t+=a(`.${i}:hover`,e.hover)),e.active&&(t+=a(`.${i}:active`,e.active)),e.focus&&(t+=a(`.${i}:focus`,e.focus)),e.disabled&&(t+=a(`.${i}:disabled`,e.disabled)),e.before&&(t+=a(`.${i}:before`,e.before)),e.after&&(t+=a(`.${i}:after`,e.after));let m=document.getElementById(`${C.key??""}-dynamic-classes`);m?m.textContent+=t:(m=document.createElement("style"),m.id=`${C.key??""}-dynamic-classes`,m.textContent=t,document.head.appendChild(m)),l.classList.add(i)}function K(){P(w)}function P(l){w=k,k=l,k&&k.load(),w&&w.unload()}function ae(){return k}let k,w=null;class se{htmlElements=[];resizeEventListeners=[];tabHandlers={};addElement(e,{x:n,y:c,width:i,height:a,padding:t,fontSize:m="auto",anchor:b,place:p,modules:u={},modulesMap:o}){L(e,C.fontFamily);const d={anchor:b,x:n,y:c,width:i,height:a,padding:t,fontSize:m,place:p,element:e};Object.keys(u)?.forEach(r=>{u[r].forEach(g=>{const f=g.overrideProperties(d,o[r]);b=f.anchor,n=f.x,c=f.y,i=f.width,a=f.height,t=f.padding,m=f.fontSize,p=f.place,e=f.element})});const s=()=>{typeof n=="number"&&typeof c=="number"&&j(e,n,c,b),m==="auto"?_(e):G(e,m),t&&X(e,t),i&&(e.style.width=$(i)+"px"),a&&(e.style.height=D(a)+"px")};s(),window.addEventListener("resize",s),Object.keys(u)?.forEach(r=>{u[r].forEach(g=>{g.layoutEffect(d,o[r])})}),p&&document.body.append(e),this.resizeEventListeners.push(s),this.htmlElements.push(e),Object.keys(u)?.forEach(r=>{u[r].forEach(g=>{g.effect(d,o[r])})})}get currentSubscreen(){return k}get previousSubscreen(){return w}get name(){return""}run(){this.tabHandlers.run?.()}load(){this.createButton({x:1815,y:75,width:90,height:90,icon:"Icons/Exit.png",modules:{base:[new H({zIndex:"10"})]}}).addEventListener("click",()=>this.exit()),this.name&&(this.createText({text:this.name,x:100,y:60,fontSize:8}).style.cssText+="max-width: 85%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0.1em;"),M[this.constructor.name]&&M[this.name].forEach(e=>e(this))}unload(){this.tabHandlers.unload?.(),this.htmlElements.forEach(e=>{e.remove()}),this.resizeEventListeners.forEach(e=>{removeEventListener("resize",e)})}click(){}exit(){this.tabHandlers.exit?.(),this.setSubscreen(this.previousSubscreen)}update(){}setPreviousSubscreen(){K()}setSubscreen(e){P(e)}createButton({text:e,x:n,y:c,width:i,height:a,fontSize:t="auto",anchor:m="top-left",padding:b,style:p="default",place:u=!0,icon:o,iconAbsolutePosition:d=!0,tooltip:s,onClick:r,isDisabled:g,modules:f}){let h,v;const y=document.createElement("button");if(y.classList.add("zcButton"),y.setAttribute("data-zc-style",p),y.style.display="flex",y.style.alignItems="center",y.style.justifyContent="center",y.style.columnGap="1.25vw",L(y,C.fontFamily),o&&(typeof o=="string"?(h=document.createElement("img"),h.src=o):h=o,h.style.height="80%",h.style.width="auto",e&&d&&(h.style.position="absolute",h.style.left="1vw"),e&&!d&&(y.style.justifyContent=""),y.append(h)),e&&(v=document.createElement("span"),v.textContent=e,y.append(v)),s){const S=document.createElement("span");S.classList.add("tooltip"),S.setAttribute("position",s.position),S.textContent=s.text,y.append(S)}return typeof g=="function"&&g()&&y.classList.add("zcDisabled"),y.addEventListener("click",()=>{if(typeof g=="function"&&g())return y.classList.add("zcDisabled");typeof r=="function"&&r()}),this.addElement(y,{x:n,y:c,width:i,height:a,anchor:m,place:u,fontSize:t,padding:b,modules:f,modulesMap:{base:y,text:v,icon:h}}),y}createText({text:e,color:n,x:c,y:i,width:a,height:t,withBackground:m=!1,withBorder:b=!1,fontSize:p="auto",anchor:u="top-left",padding:o,place:d=!0,modules:s}){const r=document.createElement("p");return r.innerHTML=e,r.style.color=n??"var(--tmd-text, black)",m&&(r.style.background="var(--tmd-element,rgb(239, 239, 239))"),b&&(r.style.border="2px solid var(--tmd-accent, rgb(236, 236, 236))"),L(r,C.fontFamily),this.addElement(r,{x:c,y:i,width:a,height:t,anchor:u,place:d,fontSize:p,padding:o,modules:s,modulesMap:{base:r}}),r}createInput({value:e,placeholder:n,x:c,y:i,width:a,height:t,textArea:m=!1,fontSize:b="auto",anchor:p="top-left",padding:u,place:o=!0,onChange:d,onInput:s,isDisabled:r,modules:g}){const f=document.createElement(m?"textarea":"input");return f.classList.add("zcInput"),n&&(f.placeholder=n),e&&(f.value=e),L(f,C.fontFamily),typeof r=="function"&&r()&&f.classList.add("zcDisabled"),f.addEventListener("change",()=>{if(typeof r=="function"&&r())return f.classList.add("zcDisabled");typeof d=="function"&&d()}),f.addEventListener("input",()=>{if(typeof r=="function"&&r())return f.classList.add("zcDisabled");typeof s=="function"&&s()}),this.addElement(f,{x:c,y:i,width:a,height:t,anchor:p,place:o,fontSize:b,padding:u,modules:g,modulesMap:{base:f}}),f}createCheckbox({text:e,x:n,y:c,isChecked:i,width:a,modules:t,anchor:m="top-left",place:b=!0,isDisabled:p,onChange:u}){const o=document.createElement("div");o.style.display="flex",o.style.alignItems="center",o.style.columnGap="1vw";const d=document.createElement("input");d.type="checkbox",d.checked=i,d.style.borderRadius="min(0.8dvh, 0.3dvw)",d.style.aspectRatio="1/1",d.classList.add("zcCheckbox","checkbox");const s=document.createElement("p");return s.textContent=e,s.style.color="var(--tmd-text, black)",L(s,C.fontFamily),typeof p=="function"&&p()&&o.classList.add("zcDisabled"),o.addEventListener("change",()=>{if(typeof p=="function"&&p())return o.classList.add("zcDisabled");typeof u=="function"&&u()}),o.append(d,s),this.addElement(o,{x:n,y:c,width:a,anchor:m,place:b,modules:t,modulesMap:{base:o,checkbox:d,label:s}}),o}createScrollView({scroll:e,x:n,y:c,width:i,height:a,anchor:t="top-left",modules:m,place:b=!0}){const p=document.createElement("div");return e==="all"&&(p.style.overflow="scroll"),e==="x"&&(p.style.overflowX="scroll"),e==="y"&&(p.style.overflowY="scroll"),this.addElement(p,{x:n,y:c,width:i,height:a,anchor:t,place:b,modules:m,modulesMap:{base:p}}),p}createInputList({x:e,y:n,width:c,height:i,title:a,value:t,modules:m,anchor:b="top-left",place:p=!0,numbersOnly:u=!1,isDisabled:o,onChange:d}){const s=[],r=document.createElement("div");r.style.cssText=`
2
2
  display: flex; flex-direction: column; gap: 1vw; border: 2px solid var(--tmd-accent, black);
3
3
  border-radius: 4px; padding: 0.75vw; background: var(--tmd-element, none);
4
- `,L(s,C.fontFamily);const b=document.createElement("div");b.style.cssText="display: flex; justify-content: center; column-gap: 1vw; width: 100%;";const u=document.createElement("b");u.textContent=n+":",u.style.cssText="width: 100%; font-size: clamp(10px, 2.4vw, 24px); color: var(--tmd-text, black);";const h=document.createElement("div");h.style.cssText=`display: flex; gap: 1vw; flex-wrap: wrap; align-content: flex-start;
5
- overflow-y: scroll;`;const v=document.createElement("input");v.style.cssText="border: none; outline: none; background: none; height: fit-content; flex-grow: 1; padding: 0.8vw; width: 6vw; font-size: clamp(8px, 2vw, 20px);";const y=(x,E)=>{const A=this.createButton({icon:x,place:!1,onClick:E,style:"default",modules:{icon:[new H({width:"70%",height:"70%"})]}});A.style.width="2em",A.style.aspectRatio="1/1",b.append(A)},S=x=>{const E=document.createElement("div");E.style.cssText="cursor: pointer; background: var(--tmd-element-hover, rgb(206, 206, 206)); color: var(--tmd-text, black); height: fit-content; padding: 0.8vw; border-radius: 0.8vw; font-size: clamp(8px, 2vw, 20px);",E.textContent=x,h.insertBefore(E,v),E.addEventListener("click",A=>{E.style.border===""?E.style.border="2px solid red":E.style.border="",A.stopPropagation()}),a.push(x)};return y(T(F),()=>{if(typeof r=="function"&&r())return s.classList.add("zcDisabled");h.innerHTML="",a.splice(0,a.length),h.append(v),t.forEach(x=>S(String(x))),typeof c=="function"&&c(d?a.map(x=>parseInt(x)):a)}),y(T(W),()=>{if(typeof r=="function"&&r())return s.classList.add("zcDisabled");for(const x of[...h.children])x.getAttribute("style").includes("border: 2px solid red;")&&(a.splice(a.indexOf(x.textContent),1),x.remove());typeof c=="function"&&c(d?a.map(x=>parseInt(x)):a)}),typeof r=="function"&&r()&&s.classList.add("zcDisabled"),v.addEventListener("keypress",x=>{if(document.activeElement===v)switch(x.key){case"Enter":if(d&&Number.isNaN(parseInt(v.value))||v.value.trim()==="")return;if(typeof r=="function"&&r())return s.classList.add("zcDisabled");S(v.value),v.value="",typeof c=="function"&&c(d?a.map(E=>parseInt(E)):a);break}}),s.addEventListener("click",x=>{x.currentTarget==s&&v.focus()}),h.append(v),s.append(b,u,h),this.addElement(s,{x:e,y:o,width:l,height:i,anchor:p,place:m,modules:f,modulesMap:{base:s,input:v}}),t.forEach(x=>S(String(x))),s}createImage({x:e,y:o,width:l,src:i,place:n=!0,anchor:t="top-left",modules:f}){const p=document.createElement("img");return p.style.height="auto",p.src=i,this.addElement(p,{x:e,y:o,width:l,height:0,anchor:t,place:n,modules:f,modulesMap:{base:p}}),p}createSvg({x:e,y:o,size:l,dataurl:i,place:n=!0,anchor:t="top-left",fill:f="var(--tmd-accent, black)",stroke:p="var(--tmd-accent-hover, black)",strokeWidth:m="2px",modules:d}){function r(s){const b=s.replace("data:image/svg+xml,",""),u=decodeURIComponent(b),h=document.createElement("div");return h.innerHTML=u,h.firstElementChild}function c(s,{fill:b,stroke:u}){return s.querySelectorAll("*").forEach(v=>{v.getAttribute("fill")!=="none"&&v.setAttribute("fill",b),v.getAttribute("stroke")!=="none"&&v.setAttribute("stroke",u)}),s.getAttribute("fill")!=="none"&&s.setAttribute("fill",b),s.getAttribute("stroke")!=="none"&&s.setAttribute("stroke",u),s}const a=r(i);return c(a,{fill:f,stroke:p}),a.setAttribute("stroke-width",m),this.addElement(a,{x:e,y:o,width:l,height:l,anchor:t,place:n,modules:d,modulesMap:{base:a}}),a}createBackNextButton({x:e,y:o,width:l,height:i,items:n,currentIndex:t,modules:f,isBold:p=!1,anchor:m="top-left",place:d=!0,onChange:r,isDisabled:c}){const a=document.createElement("div");a.classList.add("zcBackNextButton"),L(a,C.fontFamily);const s=()=>{t===0||typeof c=="function"&&c(n[t-1][1])?b.classList.add("zcBackNextButton-btnDisabled"):b.classList.remove("zcBackNextButton-btnDisabled"),t===n.length-1||typeof c=="function"&&c(n[t+1][1])?u.classList.add("zcBackNextButton-btnDisabled"):u.classList.remove("zcBackNextButton-btnDisabled")},b=document.createElement("button");b.style.cssText=`
4
+ `,L(r,C.fontFamily);const g=document.createElement("div");g.style.cssText="display: flex; justify-content: center; column-gap: 1vw; width: 100%;";const f=document.createElement("b");f.textContent=a+":",f.style.cssText="width: 100%; font-size: clamp(10px, 2.4vw, 24px); color: var(--tmd-text, black);";const h=document.createElement("div");h.style.cssText=`display: flex; gap: 1vw; flex-wrap: wrap; align-content: flex-start;
5
+ overflow-y: scroll;`;const v=document.createElement("input");v.style.cssText="border: none; outline: none; background: none; height: fit-content; flex-grow: 1; padding: 0.8vw; width: 6vw; font-size: clamp(8px, 2vw, 20px);";const y=(x,E)=>{const A=this.createButton({icon:x,place:!1,onClick:E,style:"default",modules:{icon:[new H({width:"70%",height:"70%"})]}});A.style.width="2em",A.style.aspectRatio="1/1",g.append(A)},S=x=>{const E=document.createElement("div");E.style.cssText="cursor: pointer; background: var(--tmd-element-hover, rgb(206, 206, 206)); color: var(--tmd-text, black); height: fit-content; padding: 0.8vw; border-radius: 0.8vw; font-size: clamp(8px, 2vw, 20px);",E.textContent=x,h.insertBefore(E,v),E.addEventListener("click",A=>{E.style.border===""?E.style.border="2px solid red":E.style.border="",A.stopPropagation()}),s.push(x)};return y(T(V),()=>{if(typeof o=="function"&&o())return r.classList.add("zcDisabled");h.innerHTML="",s.splice(0,s.length),h.append(v),t.forEach(x=>S(String(x))),typeof d=="function"&&d(u?s.map(x=>parseInt(x)):s)}),y(T(R),()=>{if(typeof o=="function"&&o())return r.classList.add("zcDisabled");for(const x of[...h.children])x.getAttribute("style").includes("border: 2px solid red;")&&(s.splice(s.indexOf(x.textContent),1),x.remove());typeof d=="function"&&d(u?s.map(x=>parseInt(x)):s)}),typeof o=="function"&&o()&&r.classList.add("zcDisabled"),v.addEventListener("keypress",x=>{if(document.activeElement===v)switch(x.key){case"Enter":if(u&&Number.isNaN(parseInt(v.value))||v.value.trim()==="")return;if(typeof o=="function"&&o())return r.classList.add("zcDisabled");S(v.value),v.value="",typeof d=="function"&&d(u?s.map(E=>parseInt(E)):s);break}}),r.addEventListener("click",x=>{x.currentTarget==r&&v.focus()}),h.append(v),r.append(g,f,h),this.addElement(r,{x:e,y:n,width:c,height:i,anchor:b,place:p,modules:m,modulesMap:{base:r,input:v}}),t.forEach(x=>S(String(x))),r}createImage({x:e,y:n,width:c,src:i,place:a=!0,anchor:t="top-left",modules:m}){const b=document.createElement("img");return b.style.height="auto",b.src=i,this.addElement(b,{x:e,y:n,width:c,height:0,anchor:t,place:a,modules:m,modulesMap:{base:b}}),b}createSvg({x:e,y:n,size:c,dataurl:i,place:a=!0,anchor:t="top-left",fill:m="var(--tmd-accent, black)",stroke:b="var(--tmd-accent-hover, black)",strokeWidth:p="2px",modules:u}){function o(r){const g=r.replace("data:image/svg+xml,",""),f=decodeURIComponent(g),h=document.createElement("div");return h.innerHTML=f,h.firstElementChild}function d(r,{fill:g,stroke:f}){return r.querySelectorAll("*").forEach(v=>{v.getAttribute("fill")!=="none"&&v.setAttribute("fill",g),v.getAttribute("stroke")!=="none"&&v.setAttribute("stroke",f)}),r.getAttribute("fill")!=="none"&&r.setAttribute("fill",g),r.getAttribute("stroke")!=="none"&&r.setAttribute("stroke",f),r}const s=o(i);return d(s,{fill:m,stroke:b}),s.setAttribute("stroke-width",p),this.addElement(s,{x:e,y:n,width:c,height:c,anchor:t,place:a,modules:u,modulesMap:{base:s}}),s}createBackNextButton({x:e,y:n,width:c,height:i,items:a,currentIndex:t,modules:m,isBold:b=!1,anchor:p="top-left",place:u=!0,onChange:o,isDisabled:d}){const s=document.createElement("div");s.classList.add("zcBackNextButton"),L(s,C.fontFamily);const r=()=>{t===0||typeof d=="function"&&d(a[t-1][1])?g.classList.add("zcBackNextButton-btnDisabled"):g.classList.remove("zcBackNextButton-btnDisabled"),t===a.length-1||typeof d=="function"&&d(a[t+1][1])?f.classList.add("zcBackNextButton-btnDisabled"):f.classList.remove("zcBackNextButton-btnDisabled")},g=document.createElement("button");g.style.cssText=`
6
6
  position: absolute; left: 1vw; font-size: 3.5vw; aspect-ratio: 1/1;
7
7
  height: 140%; background-image: url("Icons/Prev.png"); background-size: 100%;
8
- `,b.classList.add("zcButton"),b.addEventListener("click",()=>{if(t===0||typeof c=="function"&&c(n[t-1][1]))return b.classList.add("zcDisabled");t--,h.textContent=n[t][0],typeof r=="function"&&r(n[t][1]),s()});const u=document.createElement("button");u.style.cssText=`
8
+ `,g.classList.add("zcButton"),g.addEventListener("click",()=>{if(t===0||typeof d=="function"&&d(a[t-1][1]))return g.classList.add("zcDisabled");t--,h.textContent=a[t][0],typeof o=="function"&&o(a[t][1]),r()});const f=document.createElement("button");f.style.cssText=`
9
9
  position: absolute; right: 1vw; font-size: 3.5vw; aspect-ratio: 1/1;
10
10
  height: 140%; background-image: url("Icons/Next.png"); background-size: 100%;
11
- `,u.classList.add("zcButton"),u.addEventListener("click",()=>{if(t===n.length-1||typeof c=="function"&&c(n[t+1][1]))return u.classList.add("zcDisabled");t++,h.textContent=n[t][0],typeof r=="function"&&r(n[t][1]),s()}),s();const h=document.createElement("p");return p&&(h.style.fontWeight="bold"),h.textContent=n[t][0],a.append(b,h,u),this.addElement(a,{x:e,y:o,width:l,height:i,anchor:m,place:d,modules:f,modulesMap:{base:a,backButton:b,nextButton:u,text:h}}),a}createTabs({x:e,y:o,width:l,tabs:i,anchor:n="top-left",place:t=!0,currentTabName:f,modules:p}){let m=[];const d=document.createElement("div");return d.classList.add("zcTabs"),L(d,C.fontFamily),i.forEach(r=>{const c=()=>{for(const b of d.children)b.removeAttribute("data-opened");for(const b of m)b instanceof Node&&document.body.removeChild(b);m=[],a.setAttribute("data-opened","true");const s=document.body.append.bind(document.body);document.body.append=(...b)=>{m.push(...b),s(...b)},this.tabHandlers.unload?.(),this.tabHandlers.exit?.(),r.load(),this.tabHandlers={run:r.run,load:r.load,unload:r.unload,exit:r.exit},document.body.append=s},a=document.createElement("button");a.textContent=r.name,r.name===f&&c(),a.addEventListener("click",c),d.append(a)}),this.addElement(d,{x:e,y:o,width:l,anchor:n,place:t,modules:p,modulesMap:{base:d}}),d}drawPolylineArrow({points:e,strokeColor:o=z()?.base?.text??"black",lineWidth:l=2,circleRadius:i=5,circleColor:n=z()?.base?.text??"black"}){if(e.length<2)return;const t=MainCanvas.canvas.getContext("2d");t.save(),t.strokeStyle=o,t.lineWidth=l,t.fillStyle=n,t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let f=1;f<e.length;f++)t.lineTo(e[f].x,e[f].y);t.stroke(),t.beginPath(),t.arc(e[0].x,e[0].y,i,0,Math.PI*2),t.fill(),t.beginPath(),t.arc(e[e.length-1].x,e[e.length-1].y,i,0,Math.PI*2),t.fill(),t.restore()}createCard({x:e,y:o,name:l,value:i,icon:n,anchor:t="top-left",place:f=!0,modules:p}){const m=document.createElement("div");m.classList.add("zcCard");const d=document.createElement("p");d.classList.add("zcCard_name"),d.textContent=l;const r=document.createElement("p");return r.classList.add("zcCard_value"),r.textContent=`${i}`,n&&(n.style.cssText+="position: absolute; top: 0.4em; right: 0.4em; width: 1.2em; height: 1.2em;",m.append(n)),m.append(d,r),this.addElement(m,{x:e,y:o,anchor:t,place:f,modules:p,modulesMap:{name:d,value:r,base:m,icon:null}}),m}createSelect({x:e,y:o,width:l,options:i,currentOption:n,anchor:t="top-left",place:f=!0,modules:p,onChange:m,isDisabled:d}){let r=!1,c;const a=document.createElement("div");a.classList.add("zcSelect"),a.setAttribute("opened",!1),a.addEventListener("click",()=>{if(d&&d())return a.classList.add("zcDisabled");r?(r=!1,c.remove()):(r=!0,c=document.createElement("div"),c.setAttribute("data-zc-position",typeof o=="number"&&o>500-a.offsetHeight/2?"top":"bottom"),i.forEach(h=>{const v=document.createElement("div");v.style.cssText="display: flex; align-items: center; column-gap: 0.5em;",h.icon&&(h.icon.style.cssText="color: #bcbcbc;",v.append(h.icon)),v.append(h.text),h.name===n&&v.append(u),v.addEventListener("click",()=>{n=h.name,s.textContent=h.text,c.remove(),m&&m(h.name)}),c.append(v)}),a.append(c))});const s=document.createElement("p");s.textContent=i.find(h=>h.name===n).text;const b=T(I),u=T(N);return u.style.cssText="position: absolute; right: 0.25em;",a.append(s,b),d&&d()&&a.classList.add("zcDisabled"),this.addElement(a,{x:e,y:o,width:l,anchor:t,place:f,modules:p,modulesMap:{base:a}}),a}createContainer({x:e,y:o,width:l,height:i,anchor:n="top-left",place:t=!0,modules:f}){const p=document.createElement("div");return this.addElement(p,{x:e,y:o,width:l,height:i,anchor:n,place:t,modules:f,modulesMap:{base:p}}),p}}const M={};function ne(g,e){M[g]||(M[g]=[]),M[g].push(e)}export{te as BaseSubscreen,Q as addDynamicClass,X as autosetFontSize,q as dataUrlSvgWithColor,ee as getCurrentSubscreen,D as getRelativeHeight,P as getRelativeWidth,R as getRelativeX,V as getRelativeY,ne as hookSubscreen,L as setFontFamily,j as setFontSize,G as setPadding,O as setPosition,U as setPreviousSubscreen,J as setSize,$ as setSubscreen};
11
+ `,f.classList.add("zcButton"),f.addEventListener("click",()=>{if(t===a.length-1||typeof d=="function"&&d(a[t+1][1]))return f.classList.add("zcDisabled");t++,h.textContent=a[t][0],typeof o=="function"&&o(a[t][1]),r()}),r();const h=document.createElement("p");return b&&(h.style.fontWeight="bold"),h.textContent=a[t][0],s.append(g,h,f),this.addElement(s,{x:e,y:n,width:c,height:i,anchor:p,place:u,modules:m,modulesMap:{base:s,backButton:g,nextButton:f,text:h}}),s}createTabs({x:e,y:n,width:c,tabs:i,anchor:a="top-left",place:t=!0,currentTabName:m,modules:b}){let p=[];const u=document.createElement("div");return u.classList.add("zcTabs"),L(u,C.fontFamily),i.forEach(o=>{const d=()=>{for(const g of u.children)g.removeAttribute("data-opened");for(const g of p)g instanceof Node&&document.body.removeChild(g);p=[],s.setAttribute("data-opened","true");const r=document.body.append.bind(document.body);document.body.append=(...g)=>{p.push(...g),r(...g)},this.tabHandlers.unload?.(),this.tabHandlers.exit?.(),o.load(),this.tabHandlers={run:o.run,load:o.load,unload:o.unload,exit:o.exit},document.body.append=r},s=document.createElement("button");s.textContent=o.name,o.name===m&&d(),s.addEventListener("click",d),u.append(s)}),this.addElement(u,{x:e,y:n,width:c,anchor:a,place:t,modules:b,modulesMap:{base:u}}),u}drawPolylineArrow({points:e,strokeColor:n=z()?.base?.text??"black",lineWidth:c=2,circleRadius:i=5,circleColor:a=z()?.base?.text??"black"}){if(e.length<2)return;const t=MainCanvas.canvas.getContext("2d");t.save(),t.strokeStyle=n,t.lineWidth=c,t.fillStyle=a,t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let m=1;m<e.length;m++)t.lineTo(e[m].x,e[m].y);t.stroke(),t.beginPath(),t.arc(e[0].x,e[0].y,i,0,Math.PI*2),t.fill(),t.beginPath(),t.arc(e[e.length-1].x,e[e.length-1].y,i,0,Math.PI*2),t.fill(),t.restore()}createCard({x:e,y:n,name:c,value:i,icon:a,anchor:t="top-left",place:m=!0,modules:b}){const p=document.createElement("div");p.classList.add("zcCard");const u=document.createElement("p");u.classList.add("zcCard_name"),u.textContent=c;const o=document.createElement("p");return o.classList.add("zcCard_value"),o.textContent=`${i}`,a&&(a.style.cssText+="position: absolute; top: 0.4em; right: 0.4em; width: 1.2em; height: 1.2em;",p.append(a)),p.append(u,o),this.addElement(p,{x:e,y:n,anchor:t,place:m,modules:b,modulesMap:{name:u,value:o,base:p,icon:null}}),p}createSelect({x:e,y:n,width:c,options:i,currentOption:a,anchor:t="top-left",place:m=!0,modules:b,onChange:p,isDisabled:u}){let o=!1,d;const s=document.createElement("div");s.classList.add("zcSelect"),s.setAttribute("opened",!1),s.addEventListener("click",()=>{if(u&&u())return s.classList.add("zcDisabled");o?(o=!1,d.remove()):(o=!0,d=document.createElement("div"),d.setAttribute("data-zc-position",typeof n=="number"&&n>500-s.offsetHeight/2?"top":"bottom"),i.forEach(h=>{const v=document.createElement("div");v.style.cssText="display: flex; align-items: center; column-gap: 0.5em;",h.icon&&(h.icon.style.cssText="color: #bcbcbc;",v.append(h.icon)),v.append(h.text),h.name===a&&v.append(f),v.addEventListener("click",()=>{a=h.name,r.textContent=h.text,d.remove(),p&&p(h.name)}),d.append(v)}),s.append(d))});const r=document.createElement("p");r.textContent=i.find(h=>h.name===a).text;const g=T(N),f=T(I);return f.style.cssText="position: absolute; right: 0.25em;",s.append(r,g),u&&u()&&s.classList.add("zcDisabled"),this.addElement(s,{x:e,y:n,width:c,anchor:t,place:m,modules:b,modulesMap:{base:s}}),s}createContainer({x:e,y:n,width:c,height:i,anchor:a="top-left",place:t=!0,modules:m}){const b=document.createElement("div");return this.addElement(b,{x:e,y:n,width:c,height:i,anchor:a,place:t,modules:m,modulesMap:{base:b}}),b}}const M={};function re(l,e){M[l]||(M[l]=[]),M[l].push(e)}export{se as BaseSubscreen,ne as addDynamicClass,_ as autosetFontSize,ee as cssVar,Q as dataUrlSvgReplaceVars,J as dataUrlSvgWithColor,ae as getCurrentSubscreen,D as getRelativeHeight,$ as getRelativeWidth,O as getRelativeX,F as getRelativeY,W as hexToRgb,re as hookSubscreen,L as setFontFamily,G as setFontSize,X as setPadding,j as setPosition,K as setPreviousSubscreen,te as setSize,P as setSubscreen};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zois-core",
3
- "version": "1.1.9",
3
+ "version": "1.2.1",
4
4
  "description": "The core for the my mods, which contains a shared code reused in all my mods",
5
5
  "author": "Zoi",
6
6
  "license": "MIT",