zois-core 1.1.8 → 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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Zoi
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Zoi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,2 +1,2 @@
1
- ## The core for the my mods, which contains a shared code reused in all my mods
1
+ ## The core for the my mods, which contains a shared code reused in all my mods
2
2
  ![Typing SVG](https://readme-typing-svg.herokuapp.com/?lines=Shush+from+here)
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{getRelativeWidth as C,getRelativeX as y,getRelativeY as x}from"./ui";import{MOD_DATA as p}from"./index";import{useState as g,useEffect as f}from"react";import D from"react-dom/client";import{create as T}from"zustand";import{CircleAlert as k,CircleCheck as z,CircleX as O,Info as E}from"lucide-react";import{Fragment as w,jsx as a,jsxs as d}from"react/jsx-runtime";function I({children:o}){const[e,t]=g({}),r=window.ZOISCORE.useToastsStore(s=>s.clearToasts);return f(()=>{const s=()=>{t({fontFamily:CommonGetFontName(),bottom:x(5)+"px",left:y(5)+"px"})};return window.addEventListener("resize",s),s(),()=>{window.removeEventListener("resize",s)}},[]),a("div",{className:"zcToastsContainer",style:e,onClick:()=>{document.querySelectorAll(".zcToast").forEach(s=>{s.classList.add("exiting")}),setTimeout(r,300)},children:o})}const P=({type:o,theme:e})=>{switch(o){case"info":return a(E,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#addbff",stroke:e?e.iconStrokeColor:"#385073"}});case"success":return a(z,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#c3ffc3",stroke:e?e.iconStrokeColor:"#028f74"}});case"warning":return a(k,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#ffdfaf",stroke:e?e.iconStrokeColor:"#9c7633"}});case"error":return a(O,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#ffb2b2",stroke:e?e.iconStrokeColor:"#7f2828"}});case"spinner":return a("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"}})}};function R({title:o,message:e,type:t,duration:r,id:s,theme:i}){const[n,c]=g({}),[l,m]=g(!1);return f(()=>{const u=()=>{const h=MainCanvas.canvas.clientWidth,b=MainCanvas.canvas.clientHeight,v=Math.min(h,b)/100;c({position:"relative",width:"100%",borderRadius:"0.1em",fontSize:3*v+"px",padding:1.5*v+"px",background:i?i.backgroundColor:t==="success"?"#3ece7e":t==="warning"?"#debf72":t==="error"?"rgb(212, 46, 107)":"rgb(80, 80, 223)"})};window.addEventListener("resize",u),u();const S=setTimeout(()=>m(!0),r);return()=>{clearTimeout(S),window.removeEventListener("resize",u)}},[]),d("div",{className:`zcToast ${l&&"exiting"}`,"data-zc-toast-type":t,style:n,children:[d("div",{style:{display:"flex",alignItems:"center",gap:"1vw",position:"relative",zIndex:5},children:[a(P,{type:t,theme:i}),d("div",{children:[o&&e&&d(w,{children:[a("p",{style:{color:i?i.titleColor:"white"},children:o}),a("p",{style:{color:i?i.messageColor:t==="info"||t==="spinner"?"#b8b8ff":t==="success"?"#c7f9c7":t==="error"?"#f8bcbc":"#ffeec5",fontSize:"70%",overflowWrap:"anywhere",marginTop:"0.25em"},children:e})]}),(!o&&e||o&&!e)&&a("p",{style:{position:"relative",zIndex:5},children:o||e})]})]}),t!=="spinner"&&a("div",{className:"zcToast-ProgressBar",style:{animation:`zcToast-progress ${r}ms linear 0s 1 alternate none`,position:"absolute",top:0,left:0,height:"100%",background:i?i.progressBarColor:t==="info"?"rgb(103, 103, 234)":t==="success"?"#34bc71":t==="warning"?"#d0af5e":"rgb(183, 40, 92)"}})]})}function M({dialog:o}){const e=window.ZOISCORE.useDialogStore(n=>n.clearDialog),[t,r]=g({}),[s,i]=g([]);return f(()=>{const n=()=>{const c=MainCanvas.canvas.clientWidth,l=MainCanvas.canvas.clientHeight,m=Math.min(c,l)/100;r({width:C(o.width),position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"rgba(36, 36, 36, 0.96)",zIndex:20,fontFamily:CommonGetFontName(),border:"none",padding:2*m})};return window.addEventListener("resize",n),n(),()=>{window.removeEventListener("resize",n)}},[]),d("dialog",{open:Object.keys(t).length>0,"data-zc-dialog-type":o.type,style:t,children:[o.title&&a("p",{style:{position:"absolute",top:0,left:0,fontWeight:"bold",color:"white",fontSize:"clamp(6px, 2vw, 24px)",padding:"0.25em",background:"#2d2d2d",width:"100%"},children:o.title}),a("p",{style:{padding:"1em",marginTop:"2vw",fontSize:"clamp(6px, 2vw, 24px)",color:"white"},children:o.body}),a("div",{style:{display:"flex",flexDirection:o.buttons.direction,justifyContent:"center",gap:"0.5vw"},children:o.buttons?.list?.map((n,c)=>a("button",{className:"zcDialogBtn","data-zc-picked":s.includes(c),style:{width:"100%",position:"relative"},onClick:()=>{o.type==="choice_one"?(e(),o.promise.resolve(n.value)):s.includes(c)?i(s.filter(l=>l!==c)):i([...s,c])},children:n.text}))}),o.type==="choice_multiple"&&a("button",{style:{cursor:"pointer",color:"white",background:"#4d4d4d",border:"none",marginTop:"1vw",fontSize:"clamp(8px,2.5vw,28px)",padding:"0.2em",borderRadius:"4px"},onClick:()=>{e(),o.promise.resolve(o.buttons.list.filter((n,c)=>s.includes(c)).map(n=>n.value))},children:"Confirm"})]})}class F{generateToastId(){return crypto.randomUUID()}process({title:e,message:t,duration:r,type:s,id:i,theme:n}){const{addToast:c,removeToast:l}=window.ZOISCORE.useToastsStore.getState();c({id:i,title:e,message:t,duration:r,type:s,theme:n}),setTimeout(()=>l(i),r+300)}info({title:e,message:t,duration:r}){const s=this.generateToastId(),i=p.singleToastsTheme;this.process({title:e,message:t,duration:r,type:"info",id:s,theme:i})}success({title:e,message:t,duration:r}){const s=this.generateToastId(),i=p.singleToastsTheme;this.process({title:e,message:t,duration:r,type:"success",id:s,theme:i})}warn({title:e,message:t,duration:r}){const s=this.generateToastId(),i=p.singleToastsTheme;this.process({title:e,message:t,duration:r,type:"warning",id:s,theme:i})}error({title:e,message:t,duration:r}){const s=this.generateToastId(),i=p.singleToastsTheme;this.process({title:e,message:t,duration:r,type:"error",id:s,theme:i})}spinner({title:e,message:t}){const r=this.generateToastId(),s=p.singleToastsTheme;return this.process({title:e,message:t,duration:1e6,type:"spinner",id:r,theme:s}),r}removeSpinner(e){const{removeToast:t}=window.ZOISCORE.useToastsStore.getState();t(e)}}class N{showDialog({type:e,title:t,body:r,buttons:s,width:i}){const{setDialog:n}=window.ZOISCORE.useDialogStore.getState();return new Promise((c,l)=>{n({width:i,type:e,title:t,body:r,buttons:s,promise:{resolve:c,reject:l}})})}}function L(){const o=window.ZOISCORE.useToastsStore(t=>t.toasts),e=window.ZOISCORE.useDialogStore(t=>t.dialog);return d(w,{children:[a(I,{children:o.map(({title:t,message:r,type:s,duration:i,id:n,theme:c})=>a(R,{id:n,title:t,message:r,type:s,duration:i,theme:c},n))}),e&&a(M,{dialog:e})]})}class W extends HTMLElement{disconnectedCallback(){ServerShowBeep("VirtualDOM was removed, chaos is coming...",5e3,{})}}const q=T(o=>({toasts:[],addToast:e=>o(t=>({toasts:[...t.toasts,e]})),removeToast:e=>o(t=>({toasts:t.toasts.filter(r=>r.id!==e)})),clearToasts:()=>o({toasts:[]})})),Y=T(o=>({dialog:null,setDialog:e=>o({dialog:e}),clearDialog:()=>o({dialog:null})}));function K(){customElements.define("zc-virtual-dom",W);const o=document.createElement("zc-virtual-dom");document.body.append(o),D.createRoot(document.getElementsByTagName("zc-virtual-dom")[0]).render(a(L,{}))}const Q=new F,ee=new N;export{ee as dialogsManager,K as initVirtualDOM,Q as toastsManager,Y as useDialogStore,q 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;min-height:100%;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}.zcToast.exiting{animation:zcSlideOutToLeft .3s ease-out forwards}.zcToast p{color:#fff}dialog[data-zc-dialog-type=choice_multiple] .zcDialogBtn:before{content:"";position:absolute;left:1vw;top:50%;transform:translateY(-50%);border:2px solid white;width:.5em;aspect-ratio:1/1;border-radius:50%}dialog[data-zc-dialog-type=choice_multiple] .zcDialogBtn[data-zc-picked=true]:before{background:#fff}.zcDialogBtn{cursor:pointer;background:#ffffff17;border:none;font-size:clamp(6px,2vw,24px);color:#fff;padding:.2em;border-radius:.5em}.zcDialogBtn:hover{background:#ffffff24}@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,23 +7,28 @@ interface ToastProps {
7
7
  duration: number;
8
8
  theme?: ModData["singleToastsTheme"];
9
9
  }
10
- interface DialogProps {
11
- width: number;
12
- type: "choice_one" | "choice_multiple";
13
- title?: string;
14
- body: string;
15
- buttons: {
16
- direction: "row" | "column";
17
- list: {
18
- text: string;
19
- value?: unknown;
20
- }[];
21
- };
10
+ interface BaseDialogProps<T> {
11
+ type: "prompt" | "confirm" | "pick";
12
+ message: string;
22
13
  promise: {
23
- resolve: (data: any) => void;
24
- reject: (data: any) => void;
14
+ resolve: (data: T) => void;
15
+ reject: (data: T) => void;
25
16
  };
26
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>;
27
32
  declare class ToastsManager {
28
33
  private generateToastId;
29
34
  private process;
@@ -35,7 +40,9 @@ declare class ToastsManager {
35
40
  removeSpinner(id: string): void;
36
41
  }
37
42
  declare class DialogsManager {
38
- showDialog({ type, title, body, buttons, width }: Omit<DialogProps, "promise">): Promise<unknown>;
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>;
39
46
  }
40
47
  export interface ToastsStore {
41
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;
@@ -182,7 +185,7 @@ export declare abstract class BaseSubscreen {
182
185
  drawPolylineArrow({ points, strokeColor, lineWidth, circleRadius, circleColor }: DrawPolylineArrowArgs): void;
183
186
  createCard({ x, y, name, value, icon, anchor, place, modules }: CreateCardArgs): HTMLDivElement;
184
187
  createSelect({ x, y, width, options, currentOption, anchor, place, modules, onChange, isDisabled }: CreateSelectArgs): HTMLDivElement;
185
- createContainer({ x, y, anchor, place, modules }: CreateContainerArgs): HTMLDivElement;
188
+ createContainer({ x, y, width, height, anchor, place, modules }: CreateContainerArgs): HTMLDivElement;
186
189
  }
187
190
  export declare function hookSubscreen(subscreenName: string, hook: (subscreen: BaseSubscreen) => void): void;
188
191
  export {};
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(b,e){return b.replace(/fill="[^"]*"/g,`fill="${e}"`).replace(/stroke="[^"]*"/g,`stroke="${e}"`)}function D(b){return b*(MainCanvas.canvas.clientHeight/1e3)}function P(b){return b*(MainCanvas.canvas.clientWidth/2e3)}function V(b,e="top"){const o=MainCanvas.canvas.clientHeight/1e3;return e==="top"?MainCanvas.canvas.offsetTop+b*o:window.innerHeight-(MainCanvas.canvas.offsetTop+MainCanvas.canvas.clientHeight)+b*o}function R(b,e="left"){const o=MainCanvas.canvas.clientWidth/2e3;return e==="left"?MainCanvas.canvas.offsetLeft+b*o:window.innerWidth-(MainCanvas.canvas.offsetLeft+MainCanvas.canvas.clientWidth)+b*o}function O(b,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),m=R(e,n);Object.assign(b.style,{position:"fixed",[n]:m+"px",[i]:t+"px"})}function J(b,e,o){Object.assign(b.style,{width:P(e)+"px",height:D(o)+"px"})}function j(b,e){const o=MainCanvas.canvas.clientWidth,l=MainCanvas.canvas.clientHeight,i=Math.min(o,l)/100,n=e*i;Object.assign(b.style,{fontSize:n+"px"})}function L(b,e){b.style.fontFamily=e??"sans-serif"}function G(b,e){const o=MainCanvas.canvas.clientWidth,l=MainCanvas.canvas.clientHeight,i=Math.min(o,l)/100,n=e*i;Object.assign(b.style,{padding:n+"px"})}function X(b){const e=MainCanvas.canvas.clientWidth<=MainCanvas.canvas.clientHeight*2?MainCanvas.canvas.clientWidth/50:MainCanvas.canvas.clientHeight/25;Object.assign(b.style,{fontSize:e+"px"})}const B=[];function _(b){const e=o=>o?JSON.stringify(Object.keys(o).sort().reduce((l,i)=>(l[i]=o[i],l),{})):"null";return`base:${e(b.base)}|hover:${e(b.hover)}|active:${e(b.active)}|before:${e(b.before)}|after:${e(b.after)}`}function Q(b,e){const o=_(e),l=B.find(h=>h.key===o);if(l)return b.classList.add(l.className);let i;do i="dynamic-"+Math.random().toString(36).substring(2,10);while(B.find(h=>h.className===i));B.push({key:o,className:i});const n=(h,f)=>{let d=`${h} {`;for(const[r,c]of Object.entries(f))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 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)),b.classList.add(i)}function U(){$(w)}function $(b){w=k,k=b,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:m="auto",anchor:h,place:f,modules:d={},modulesMap:r}){L(e,C.fontFamily);const c={anchor:h,x:o,y:l,width:i,height:n,padding:t,fontSize:m,place:f,element:e};Object.keys(d)?.forEach(s=>{d[s].forEach(p=>{const u=p.overrideProperties(c,r[s]);h=u.anchor,o=u.x,l=u.y,i=u.width,n=u.height,t=u.padding,m=u.fontSize,f=u.place,e=u.element})});const a=()=>{typeof o=="number"&&typeof l=="number"&&O(e,o,l,h),m==="auto"?X(e):j(e,m),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(p=>{p.layoutEffect(c,r[s])})}),f&&document.body.append(e),this.resizeEventListeners.push(a),this.htmlElements.push(e),Object.keys(d)?.forEach(s=>{d[s].forEach(p=>{p.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:m="top-left",padding:h,style:f="default",place:d=!0,icon:r,iconAbsolutePosition:c=!0,tooltip:a,onClick:s,isDisabled:p,modules:u}){let g,v;const y=document.createElement("button");if(y.classList.add("zcButton"),y.setAttribute("data-zc-style",f),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"?(g=document.createElement("img"),g.src=r):g=r,g.style.height="80%",g.style.width="auto",e&&c&&(g.style.position="absolute",g.style.left="1vw"),e&&!c&&(y.style.justifyContent=""),y.append(g)),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 p=="function"&&p()&&y.classList.add("zcDisabled"),y.addEventListener("click",()=>{if(typeof p=="function"&&p())return y.classList.add("zcDisabled");typeof s=="function"&&s()}),this.addElement(y,{x:o,y:l,width:i,height:n,anchor:m,place:d,fontSize:t,padding:h,modules:u,modulesMap:{base:y,text:v,icon:g}}),y}createText({text:e,color:o,x:l,y:i,width:n,height:t,withBackground:m=!1,withBorder:h=!1,fontSize:f="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)",m&&(s.style.background="var(--tmd-element,rgb(239, 239, 239))"),h&&(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:f,padding:r,modules:a,modulesMap:{base:s}}),s}createInput({value:e,placeholder:o,x:l,y:i,width:n,height:t,textArea:m=!1,fontSize:h="auto",anchor:f="top-left",padding:d,place:r=!0,onChange:c,onInput:a,isDisabled:s,modules:p}){const u=document.createElement(m?"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:f,place:r,fontSize:h,padding:d,modules:p,modulesMap:{base:u}}),u}createCheckbox({text:e,x:o,y:l,isChecked:i,width:n,modules:t,anchor:m="top-left",place:h=!0,isDisabled:f,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 f=="function"&&f()&&r.classList.add("zcDisabled"),r.addEventListener("change",()=>{if(typeof f=="function"&&f())return r.classList.add("zcDisabled");typeof d=="function"&&d()}),r.append(c,a),this.addElement(r,{x:o,y:l,width:n,anchor:m,place:h,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:m,place:h=!0}){const f=document.createElement("div");return e==="all"&&(f.style.overflow="scroll"),e==="x"&&(f.style.overflowX="scroll"),e==="y"&&(f.style.overflowY="scroll"),this.addElement(f,{x:o,y:l,width:i,height:n,anchor:t,place:h,modules:m,modulesMap:{base:f}}),f}createInputList({x:e,y:o,width:l,height:i,title:n,value:t,modules:m,anchor:h="top-left",place:f=!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 p=document.createElement("div");p.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 g=document.createElement("div");g.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",p.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,g.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");g.innerHTML="",a.splice(0,a.length),g.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[...g.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()}),g.append(v),s.append(p,u,g),this.addElement(s,{x:e,y:o,width:l,height:i,anchor:h,place:f,modules:m,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:m}){const h=document.createElement("img");return h.style.height="auto",h.src=i,this.addElement(h,{x:e,y:o,width:l,height:0,anchor:t,place:n,modules:m,modulesMap:{base:h}}),h}createSvg({x:e,y:o,size:l,dataurl:i,place:n=!0,anchor:t="top-left",fill:m="var(--tmd-accent, black)",stroke:h="var(--tmd-accent-hover, black)",strokeWidth:f="2px",modules:d}){function r(s){const p=s.replace("data:image/svg+xml,",""),u=decodeURIComponent(p),g=document.createElement("div");return g.innerHTML=u,g.firstElementChild}function c(s,{fill:p,stroke:u}){return s.querySelectorAll("*").forEach(v=>{v.getAttribute("fill")!=="none"&&v.setAttribute("fill",p),v.getAttribute("stroke")!=="none"&&v.setAttribute("stroke",u)}),s.getAttribute("fill")!=="none"&&s.setAttribute("fill",p),s.getAttribute("stroke")!=="none"&&s.setAttribute("stroke",u),s}const a=r(i);return c(a,{fill:m,stroke:h}),a.setAttribute("stroke-width",f),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:m,isBold:h=!1,anchor:f="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])?p.classList.add("zcBackNextButton-btnDisabled"):p.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")},p=document.createElement("button");p.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
- `,p.classList.add("zcButton"),p.addEventListener("click",()=>{if(t===0||typeof c=="function"&&c(n[t-1][1]))return p.classList.add("zcDisabled");t--,g.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++,g.textContent=n[t][0],typeof r=="function"&&r(n[t][1]),s()}),s();const g=document.createElement("p");return h&&(g.style.fontWeight="bold"),g.textContent=n[t][0],a.append(p,g,u),this.addElement(a,{x:e,y:o,width:l,height:i,anchor:f,place:d,modules:m,modulesMap:{base:a,backButton:p,nextButton:u,text:g}}),a}createTabs({x:e,y:o,width:l,tabs:i,anchor:n="top-left",place:t=!0,currentTabName:m,modules:h}){let f=[];const d=document.createElement("div");return d.classList.add("zcTabs"),L(d,C.fontFamily),i.forEach(r=>{const c=()=>{for(const p of d.children)p.removeAttribute("data-opened");for(const p of f)p instanceof Node&&document.body.removeChild(p);f=[],a.setAttribute("data-opened","true");const s=document.body.append.bind(document.body);document.body.append=(...p)=>{f.push(...p),s(...p)},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===m&&c(),a.addEventListener("click",c),d.append(a)}),this.addElement(d,{x:e,y:o,width:l,anchor:n,place:t,modules:h,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 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:o,name:l,value:i,icon:n,anchor:t="top-left",place:m=!0,modules:h}){const f=document.createElement("div");f.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;",f.append(n)),f.append(d,r),this.addElement(f,{x:e,y:o,anchor:t,place:m,modules:h,modulesMap:{name:d,value:r,base:f,icon:null}}),f}createSelect({x:e,y:o,width:l,options:i,currentOption:n,anchor:t="top-left",place:m=!0,modules:h,onChange:f,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(g=>{const v=document.createElement("div");v.style.cssText="display: flex; align-items: center; column-gap: 0.5em;",g.icon&&(g.icon.style.cssText="color: #bcbcbc;",v.append(g.icon)),v.append(g.text),g.name===n&&v.append(u),v.addEventListener("click",()=>{n=g.name,s.textContent=g.text,c.remove(),f&&f(g.name)}),c.append(v)}),a.append(c))});const s=document.createElement("p");s.textContent=i.find(g=>g.name===n).text;const p=T(I),u=T(N);return u.style.cssText="position: absolute; right: 0.25em;",a.append(s,p),d&&d()&&a.classList.add("zcDisabled"),this.addElement(a,{x:e,y:o,width:l,anchor:t,place:m,modules:h,modulesMap:{base:a}}),a}createContainer({x:e,y:o,anchor:l="top-left",place:i=!0,modules:n}){const t=document.createElement("div");return this.addElement(t,{x:e,y:o,anchor:l,place:i,modules:n,modulesMap:{base:t}}),t}}const M={};function ne(b,e){M[b]||(M[b]=[]),M[b].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.8",
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",