zois-core 1.1.3 → 1.1.5

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/messaging.js CHANGED
@@ -1 +1 @@
1
- import{getPlayer as g,MOD_DATA as u}from"./index";import{hookFunction as p,HookPriority as m}from"./modsApi";import{setFontFamily as h}from"./ui";import{validateData as f}from"./validation";class k{sendBeep(n,e){const c={IsSecret:!0,BeepType:"Leash",MemberNumber:e,Message:JSON.stringify({...n})};ServerSend("AccountBeep",c)}sendPacket(n,e,c){const o={Content:u.key,Dictionary:{msg:n},Type:"Hidden"};e&&(o.Dictionary.data=e),c&&(o.Target=c),ServerSend("ChatRoomChat",o)}sendAction(n,e=void 0,c=[]){if(!n||!ServerPlayerIsInChatRoom())return;const o=CharacterPronounDescription(Player)==="She/Her",i=o?"Her":"His",s=o?"Her":"Him",r=o?"Herself":"Himself",t=o?"She":"He";n=n.replaceAll("<Possessive>",i).replaceAll("<possessive>",i.toLocaleLowerCase()).replaceAll("<Intensive>",s).replaceAll("<intensive>",s.toLocaleLowerCase()).replaceAll("<SelfIntensive>",r).replaceAll("<selfIntensive>",r.toLocaleLowerCase()).replaceAll("<Pronoun>",t).replaceAll("<pronoun>",t.toLocaleLowerCase()),ServerSend("ChatRoomChat",{Content:"ZC_CUSTOM_ACTION",Type:"Action",Target:e??void 0,Dictionary:[{Tag:'MISSING TEXT IN "Interface.csv": ZC_CUSTOM_ACTION',Text:n},...c]})}sendRequest({message:n,data:e={},target:c,type:o="packet"}){const i=crypto.randomUUID();return new Promise(s=>{let r;o==="packet"?(C.sendPacket("request",{requestId:i,message:n,data:e},c),r=p("ChatRoomMessage",m.ADD_BEHAVIOR,(t,a)=>{const l=t[0],d=g(l.Sender);if(!d)return a(t);if(l.Content===u.key&&!d.IsPlayer()){const y=l.Dictionary.msg,R=l.Dictionary.data;y==="requestResponse"&&R.requestId===i&&(r(),s({data:R.data,isError:!1}))}return a(t)})):(C.sendBeep({type:`${u.key}_request`,requestId:i,message:n,data:e},c),r=p("ServerAccountBeep",m.ADD_BEHAVIOR,(t,a)=>{const l=t[0];if(l.BeepType!=="Leash")return a(t);let d;try{d=JSON.parse(l.Message)}catch{return a(t)}return d.type===`${u.key}_requestResponse`&&d.requestId===i&&(r(),s({data:d.data,isError:!1})),a(t)})),setTimeout(()=>{r(),s({isError:!0})},6e3)})}sendLocal(n){if(!ServerPlayerIsInChatRoom())return;const e=document.createElement("div");e.setAttribute("class","ChatMessage ChatMessageLocalMessage"),e.setAttribute("data-time",ChatRoomCurrentTime()),e.setAttribute("data-sender",`${Player.MemberNumber}`),h(e,u.fontFamily),e.style.background=u.chatMessageBackground??"#55edc095",e.style.color=u.chatMessageColor??"black",e.style.margin="0.15em 0",typeof n=="string"?e.innerHTML=n:e.appendChild(n),document.querySelector("#TextAreaChatLog").appendChild(e),ElementScrollToEnd("TextAreaChatLog")}sendChat(n){ServerSend("ChatRoomChat",{Type:"Chat",Content:n})}onRequest(n,e,c){let o,i;typeof e=="function"&&e.prototype?.constructor==e?(i=e,o=c):o=e,p("ChatRoomMessage",m.ADD_BEHAVIOR,async(s,r)=>{const t=s[0],a=g(t.Sender);if(!a)return r(s);if(t.Content===u.key&&!a.IsPlayer()){const l=t.Dictionary?.msg,d=t.Dictionary?.data;if(l==="request"&&d.message===n){if(typeof d.requestId!="string"||typeof d.message!="string")return;if(i&&!(await f(d.data,i)).isValid)return r(s);const y=o(d.data,a);y!==void 0&&C.sendPacket("requestResponse",{requestId:d.requestId,message:d.message,data:y},a.MemberNumber)}}return r(s)}),p("ServerAccountBeep",m.ADD_BEHAVIOR,async(s,r)=>{const t=s[0];if(t.BeepType!=="Leash")return r(s);let a;try{a=JSON.parse(t.Message)}catch{return r(s)}if(a.type===`${u.key}_request`&&a.message===n){if(typeof a.requestId!="string")return;if(i&&!(await f(a.data,i)).isValid)return r(s);o(a.data,t.MemberNumber,t.MemberName)!==void 0&&C.sendBeep({type:`${u.key}_requestResponse`,requestId:a.requestId,message:a.message,data:a.data},t.MemberNumber)}return r(s)})}onPacket(n,e,c){p("ChatRoomMessage",m.ADD_BEHAVIOR,async(o,i)=>{let s,r;typeof e=="function"&&e.prototype?.constructor==e?(r=e,s=c):s=e;const t=o[0],a=g(t.Sender);if(!a)return i(o);if(t.Content===u.key&&t.Dictionary.msg===n&&!a.IsPlayer()){if(r&&!(await f(t.Dictionary?.data,r)).isValid)return i(o);s(t.Dictionary.data,a)}return i(o)})}}const C=new k;export{C as messagesManager};
1
+ import{getPlayer as g,MOD_DATA as l}from"./index";import{hookFunction as p,HookPriority as m}from"./modsApi";import{setFontFamily as h}from"./ui";import{validateData as f}from"./validation";class k{sendBeep(a,e){const d={IsSecret:!0,BeepType:"Leash",MemberNumber:e,Message:JSON.stringify({...a})};ServerSend("AccountBeep",d)}sendPacket(a,e,d){const o={Content:l.key,Dictionary:{msg:a},Type:"Hidden"};e&&(o.Dictionary.data=e),d&&(o.Target=d),ServerSend("ChatRoomChat",o)}sendAction(a,e=void 0,d=[]){if(!a||!ServerPlayerIsInChatRoom())return;const o=CharacterPronounDescription(Player)==="She/Her",i=o?"Her":"His",s=o?"Her":"Him",r=o?"Herself":"Himself",t=o?"She":"He";a=a.replaceAll("<Possessive>",i).replaceAll("<possessive>",i.toLocaleLowerCase()).replaceAll("<Intensive>",s).replaceAll("<intensive>",s.toLocaleLowerCase()).replaceAll("<SelfIntensive>",r).replaceAll("<selfIntensive>",r.toLocaleLowerCase()).replaceAll("<Pronoun>",t).replaceAll("<pronoun>",t.toLocaleLowerCase()),ServerSend("ChatRoomChat",{Content:"ZC_CUSTOM_ACTION",Type:"Action",Target:e??void 0,Dictionary:[{Tag:'MISSING TEXT IN "Interface.csv": ZC_CUSTOM_ACTION',Text:a},...d]})}sendRequest({message:a,data:e={},target:d,type:o="packet"}){const i=crypto.randomUUID();return new Promise(s=>{let r;o==="packet"?(C.sendPacket("request",{requestId:i,message:a,data:e},d),r=p("ChatRoomMessage",m.ADD_BEHAVIOR,(t,n)=>{const u=t[0],c=g(u.Sender);if(!c)return n(t);if(u.Content===l.key&&!c.IsPlayer()){const y=u.Dictionary.msg,R=u.Dictionary.data;y==="requestResponse"&&R.requestId===i&&(r(),s({data:R.data,isError:!1}))}return n(t)})):(C.sendBeep({type:`${l.key}_request`,requestId:i,message:a,data:e},d),r=p("ServerAccountBeep",m.ADD_BEHAVIOR,(t,n)=>{const u=t[0];if(u.BeepType!=="Leash")return n(t);let c;try{c=JSON.parse(u.Message)}catch{return n(t)}return c.type===`${l.key}_requestResponse`&&c.requestId===i&&(r(),s({data:c.data,isError:!1})),n(t)})),setTimeout(()=>{r(),s({isError:!0})},6e3)})}sendLocal(a){if(!ServerPlayerIsInChatRoom())return;const e=document.createElement("div");e.setAttribute("class","ChatMessage ChatMessageLocalMessage"),e.setAttribute("data-time",ChatRoomCurrentTime()),e.setAttribute("data-sender",`${Player.MemberNumber}`),h(e,l.fontFamily),e.style.background=l.chatMessageBackground??"#55edc095",e.style.color=l.chatMessageColor??"black",e.style.margin="0.15em 0",typeof a=="string"?e.innerHTML=a:e.appendChild(a),document.querySelector("#TextAreaChatLog").appendChild(e),ElementScrollToEnd("TextAreaChatLog")}sendChat(a){ServerSend("ChatRoomChat",{Type:"Chat",Content:a})}onRequest(a,e,d){let o,i;typeof e=="function"&&e.prototype?.constructor==e?(i=e,o=d):o=e,p("ChatRoomMessage",m.ADD_BEHAVIOR,async(s,r)=>{const t=s[0],n=g(t.Sender);if(!n)return r(s);if(t.Content===l.key&&!n.IsPlayer()){const u=t.Dictionary?.msg,c=t.Dictionary?.data;if(u==="request"&&c.message===a){if(typeof c.requestId!="string"||typeof c.message!="string")return;if(i&&!(await f(c.data,i)).isValid)return r(s);const y=o(c.data,n);y!==void 0&&C.sendPacket("requestResponse",{requestId:c.requestId,message:c.message,data:y},n.MemberNumber)}}return r(s)}),p("ServerAccountBeep",m.ADD_BEHAVIOR,async(s,r)=>{const t=s[0];if(t.BeepType!=="Leash")return r(s);let n;try{n=JSON.parse(t.Message)}catch{return r(s)}if(n.type===`${l.key}_request`&&n.message===a){if(typeof n.requestId!="string")return;if(i&&!(await f(n.data,i)).isValid)return r(s);const u=o(n.data,t.MemberNumber,t.MemberName);u!==void 0&&C.sendBeep({type:`${l.key}_requestResponse`,requestId:n.requestId,message:n.message,data:u},t.MemberNumber)}return r(s)})}onPacket(a,e,d){p("ChatRoomMessage",m.ADD_BEHAVIOR,async(o,i)=>{let s,r;typeof e=="function"&&e.prototype?.constructor==e?(r=e,s=d):s=e;const t=o[0],n=g(t.Sender);if(!n)return i(o);if(t.Content===l.key&&t.Dictionary.msg===a&&!n.IsPlayer()){if(r&&!(await f(t.Dictionary?.data,r)).isValid)return i(o);s(t.Dictionary.data,n)}return i(o)})}}const C=new k;export{C as messagesManager};
@@ -0,0 +1,6 @@
1
+ import { BaseModule, Context, ModuleTarget } from "../modules";
2
+ export declare class AttributesModule extends BaseModule {
3
+ private attributes;
4
+ constructor(attributes: Record<string, string>);
5
+ layoutEffect(context: Context, target: ModuleTarget): void;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { BaseModule, Context, ModuleTarget } from "zois-core/modules";
2
+ export declare class ClickModule extends BaseModule {
3
+ private callback;
4
+ constructor(callback: (target: ModuleTarget) => void);
5
+ layoutEffect(context: Context, target: ModuleTarget): void;
6
+ }
@@ -0,0 +1,7 @@
1
+ import { DynamicClassStyles } from "../ui";
2
+ import { BaseModule, Context, ModuleTarget } from "../modules";
3
+ export declare class DynamicClassModule extends BaseModule {
4
+ private style;
5
+ constructor(style: DynamicClassStyles);
6
+ layoutEffect(context: Context, target: ModuleTarget): void;
7
+ }
@@ -2,3 +2,6 @@ export * from "./centerModule";
2
2
  export * from "./counterUpModule";
3
3
  export * from "./typeModule";
4
4
  export * from "./styleModule";
5
+ export * from "./dynamicClassModule";
6
+ export * from "./attributesModule";
7
+ export * from "./clickModule";
@@ -2,5 +2,6 @@ import { BaseModule, Context, ModuleTarget } from "../modules";
2
2
  export declare class StyleModule extends BaseModule {
3
3
  private style;
4
4
  constructor(style: Partial<CSSStyleDeclaration>);
5
+ private applyStyle;
5
6
  layoutEffect(context: Context, target: ModuleTarget): void;
6
7
  }
@@ -16,7 +16,6 @@ interface CreateButtonArgs extends BaseElementArgs<"base" | "icon" | "text"> {
16
16
  style?: "default" | "green" | "inverted";
17
17
  icon?: string | SVGElement;
18
18
  iconAbsolutePosition?: boolean;
19
- iconWidth?: string;
20
19
  tooltip?: {
21
20
  text: string;
22
21
  position: "left" | "right";
@@ -73,6 +72,13 @@ interface CreateImageArgs extends BaseElementArgs<"base"> {
73
72
  src: string;
74
73
  width: number;
75
74
  }
75
+ interface CreateSvgArgs extends BaseElementArgs<"base"> {
76
+ dataurl: string;
77
+ size: number;
78
+ fill?: string;
79
+ stroke?: string;
80
+ strokeWidth?: string;
81
+ }
76
82
  interface CreateBackNextButtonArgs extends BaseElementArgs<"base" | "backButton" | "nextButton" | "text"> {
77
83
  width: number;
78
84
  height: number;
@@ -123,6 +129,13 @@ interface DrawPolylineArrowArgs {
123
129
  circleRadius?: number;
124
130
  circleColor?: string;
125
131
  }
132
+ export interface DynamicClassStyles {
133
+ base?: Record<string, string>;
134
+ hover?: Record<string, string>;
135
+ active?: Record<string, string>;
136
+ focus?: Record<string, string>;
137
+ disabled?: Record<string, string>;
138
+ }
126
139
  export declare function dataUrlSvgWithColor(dataUrl: string, newColor: string): string;
127
140
  export declare function getRelativeHeight(height: number): number;
128
141
  export declare function getRelativeWidth(width: number): number;
@@ -134,6 +147,7 @@ export declare function setFontSize(element: HTMLElement, targetFontSize: number
134
147
  export declare function setFontFamily(element: HTMLElement, fontFamily?: string): void;
135
148
  export declare function setPadding(element: HTMLElement, targetPadding: number): void;
136
149
  export declare function autosetFontSize(element: HTMLElement): void;
150
+ export declare function addDynamicClass(targetElement: HTMLElement | SVGElement, styles: DynamicClassStyles): void;
137
151
  export declare function setPreviousSubscreen(): void;
138
152
  export declare function setSubscreen(subscreen: BaseSubscreen | null): void;
139
153
  export declare function getCurrentSubscreen(): BaseSubscreen;
@@ -153,13 +167,14 @@ export declare abstract class BaseSubscreen {
153
167
  update?(): void;
154
168
  setPreviousSubscreen(): void;
155
169
  setSubscreen(subscreen: BaseSubscreen | null): void;
156
- createButton({ text, x, y, width, height, fontSize, anchor, padding, style, place, icon, iconAbsolutePosition, iconWidth, tooltip, onClick, isDisabled, modules }: CreateButtonArgs): HTMLButtonElement;
170
+ createButton({ text, x, y, width, height, fontSize, anchor, padding, style, place, icon, iconAbsolutePosition, tooltip, onClick, isDisabled, modules }: CreateButtonArgs): HTMLButtonElement;
157
171
  createText({ text, color, x, y, width, height, withBackground, withBorder, fontSize, anchor, padding, place, modules }: CreateTextArgs): HTMLParagraphElement;
158
172
  createInput({ value, placeholder, x, y, width, height, textArea, fontSize, anchor, padding, place, onChange, onInput, isDisabled, modules }: CreateInputArgs): HTMLInputElement | HTMLTextAreaElement;
159
173
  createCheckbox({ text, x, y, isChecked, width, modules, anchor, place, isDisabled, onChange }: CreateCheckboxArgs): HTMLDivElement;
160
174
  createScrollView({ scroll, x, y, width, height, anchor, modules, place }: CreateScrollViewArgs): HTMLDivElement;
161
175
  createInputList({ x, y, width, height, title, value, modules, anchor, place, numbersOnly, isDisabled, onChange }: CreateInputListArgs): HTMLDivElement;
162
176
  createImage({ x, y, width, src, place, anchor, modules }: CreateImageArgs): HTMLImageElement;
177
+ createSvg({ x, y, size, dataurl, place, anchor, fill, stroke, strokeWidth, modules }: CreateSvgArgs): HTMLElement;
163
178
  createBackNextButton({ x, y, width, height, items, currentIndex, modules, isBold, anchor, place, onChange, isDisabled }: CreateBackNextButtonArgs): HTMLDivElement;
164
179
  createTabs({ x, y, width, tabs, anchor, place, currentTabName, modules }: CreateTabArgs): HTMLDivElement;
165
180
  drawPolylineArrow({ points, strokeColor, lineWidth, circleRadius, circleColor }: DrawPolylineArrowArgs): void;
@@ -0,0 +1 @@
1
+ import{BaseModule as o}from"../modules";class c extends o{constructor(e){super();this.attributes=e}layoutEffect(e,r){for(const t of Object.keys(this.attributes))r.setAttribute(t,this.attributes[t])}}export{c as AttributesModule};
@@ -0,0 +1 @@
1
+ import{BaseModule as o}from"zois-core/modules";class i extends o{constructor(t){super();this.callback=t}layoutEffect(t,e){e.addEventListener("click",()=>this.callback(e))}}export{i as ClickModule};
@@ -0,0 +1 @@
1
+ import{addDynamicClass as s}from"../ui";import{BaseModule as a}from"../modules";class i extends a{constructor(t){super();this.style=t}layoutEffect(t,e){s(e,this.style)}}export{i as DynamicClassModule};
@@ -1 +1 @@
1
- export*from"./centerModule";export*from"./counterUpModule";export*from"./typeModule";export*from"./styleModule";
1
+ export*from"./centerModule";export*from"./counterUpModule";export*from"./typeModule";export*from"./styleModule";export*from"./dynamicClassModule";export*from"./attributesModule";export*from"./clickModule";
@@ -1 +1 @@
1
- import{BaseModule as l}from"../modules";class n extends l{constructor(e){super();this.style=e}layoutEffect(e,o){for(const t of Object.keys(this.style))o.style[t]=this.style[t]}}export{n as StyleModule};
1
+ import{BaseModule as a}from"../modules";class y extends a{constructor(o){super();this.style=o}applyStyle(o,t){for(const e of Object.keys(t))!isNaN(e)||typeof t[e]=="function"||(o.style[e]=t[e])}layoutEffect(o,t){this.applyStyle(t,this.style)}}export{y as StyleModule};
package/dist/ui.js CHANGED
@@ -1,11 +1,11 @@
1
- import{Check as N,ChevronDown as I,CircleX as P,createElement as T,Trash2 as D}from"lucide";import{getThemedColorsModule as z,MOD_DATA as L}from"./index";import{StyleModule as W}from"./ui-modules";function q(b,e){return b.replace(/fill="[^"]*"/g,`fill="${e}"`).replace(/stroke="[^"]*"/g,`stroke="${e}"`)}function S(b){return b*(MainCanvas.canvas.clientHeight/1e3)}function H(b){return b*(MainCanvas.canvas.clientWidth/2e3)}function R(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 V(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 j(b,e,o,d="top-left"){const u=d==="top-left"||d==="top-right"?"top":"bottom",r=d==="top-left"||d==="bottom-left"?"left":"right",t=R(o,u),p=V(e,r);Object.assign(b.style,{position:"fixed",[r]:p+"px",[u]:t+"px"})}function J(b,e,o){Object.assign(b.style,{width:H(e)+"px",height:S(o)+"px"})}function O(b,e){const o=MainCanvas.canvas.clientWidth,d=MainCanvas.canvas.clientHeight,u=Math.min(o,d)/100,r=e*u;Object.assign(b.style,{fontSize:r+"px"})}function k(b,e){b.style.fontFamily=e??"sans-serif"}function G(b,e){const o=MainCanvas.canvas.clientWidth,d=MainCanvas.canvas.clientHeight,u=Math.min(o,d)/100,r=e*u;Object.assign(b.style,{padding:r+"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"})}function Y(){F(M)}function F(b){M=w,w=b,w&&w.load(),M&&M.unload()}function K(){return w}let w,M=null;class Q{htmlElements=[];resizeEventListeners=[];tabHandlers={};addElement(e,{x:o,y:d,width:u,height:r,padding:t,fontSize:p="auto",anchor:g,place:m,modules:l={},modulesMap:n}){k(e,L.fontFamily);const i={anchor:g,x:o,y:d,width:u,height:r,padding:t,fontSize:p,place:m,element:e};Object.keys(l)?.forEach(s=>{l[s].forEach(f=>{const c=f.overrideProperties(i,n[s]);g=c.anchor,o=c.x,d=c.y,u=c.width,r=c.height,t=c.padding,p=c.fontSize,m=c.place,e=c.element})});const a=()=>{typeof o=="number"&&typeof d=="number"&&j(e,o,d,g),p==="auto"?X(e):O(e,p),t&&G(e,t),u&&(e.style.width=H(u)+"px"),r&&(e.style.height=S(r)+"px")};a(),window.addEventListener("resize",a),Object.keys(l)?.forEach(s=>{l[s].forEach(f=>{f.layoutEffect(i,n[s])})}),m&&document.body.append(e),this.resizeEventListeners.push(a),this.htmlElements.push(e),Object.keys(l)?.forEach(s=>{l[s].forEach(f=>{f.effect(i,n[s])})})}get currentSubscreen(){return w}get previousSubscreen(){return M}get name(){return""}run(){this.tabHandlers.run?.()}load(){this.createButton({x:1815,y:75,width:90,height:90,icon:"Icons/Exit.png"}).addEventListener("click",()=>this.exit()),this.name&&(this.createText({text:this.name,x:100,y:60,fontSize:10}).style.cssText+="max-width: 85%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0.1em;"),B[this.constructor.name]&&B[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(){Y()}setSubscreen(e){F(e)}createButton({text:e,x:o,y:d,width:u,height:r,fontSize:t="auto",anchor:p="top-left",padding:g,style:m="default",place:l=!0,icon:n,iconAbsolutePosition:i=!0,iconWidth:a,tooltip:s,onClick:f,isDisabled:c,modules:v}){let h,C;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",k(y,L.fontFamily),n&&(typeof n=="string"?(h=document.createElement("img"),h.src=n):h=n,a?h.style.width=a:h.style.height="80%",e&&i&&(h.style.position="absolute",h.style.left="1vw"),e&&!i&&(y.style.justifyContent=""),y.append(h)),e&&(C=document.createElement("span"),C.textContent=e,n&&!i&&a&&(C.style.width="100%",C.style.marginRight=a),y.append(C)),s){const x=document.createElement("span");x.classList.add("tooltip"),x.setAttribute("position",s.position),x.textContent=s.text,y.append(x)}return typeof c=="function"&&c()&&y.classList.add("zcDisabled"),y.addEventListener("click",()=>{if(typeof c=="function"&&c())return y.classList.add("zcDisabled");typeof f=="function"&&f()}),this.addElement(y,{x:o,y:d,width:u,height:r,anchor:p,place:l,fontSize:t,padding:g,modules:v,modulesMap:{base:y,text:C,icon:h}}),y}createText({text:e,color:o,x:d,y:u,width:r,height:t,withBackground:p=!1,withBorder:g=!1,fontSize:m="auto",anchor:l="top-left",padding:n,place:i=!0,modules:a}){const s=document.createElement("p");return s.innerHTML=e,s.style.color=o??"var(--tmd-text, black)",p&&(s.style.background="var(--tmd-element,rgb(239, 239, 239))"),g&&(s.style.border="2px solid var(--tmd-accent, rgb(236, 236, 236))"),k(s,L.fontFamily),this.addElement(s,{x:d,y:u,width:r,height:t,anchor:l,place:i,fontSize:m,padding:n,modules:a,modulesMap:{base:s}}),s}createInput({value:e,placeholder:o,x:d,y:u,width:r,height:t,textArea:p=!1,fontSize:g="auto",anchor:m="top-left",padding:l,place:n=!0,onChange:i,onInput:a,isDisabled:s,modules:f}){const c=document.createElement(p?"textarea":"input");return c.classList.add("zcInput"),o&&(c.placeholder=o),e&&(c.value=e),k(c,L.fontFamily),typeof s=="function"&&s()&&c.classList.add("zcDisabled"),c.addEventListener("change",()=>{if(typeof s=="function"&&s())return c.classList.add("zcDisabled");typeof i=="function"&&i()}),c.addEventListener("input",()=>{if(typeof s=="function"&&s())return c.classList.add("zcDisabled");typeof a=="function"&&a()}),this.addElement(c,{x:d,y:u,width:r,height:t,anchor:m,place:n,fontSize:g,padding:l,modules:f,modulesMap:{base:c}}),c}createCheckbox({text:e,x:o,y:d,isChecked:u,width:r,modules:t,anchor:p="top-left",place:g=!0,isDisabled:m,onChange:l}){const n=document.createElement("div");n.style.display="flex",n.style.alignItems="center",n.style.columnGap="1vw";const i=document.createElement("input");i.type="checkbox",i.checked=u,i.style.borderRadius="min(0.8dvh, 0.3dvw)",i.style.aspectRatio="1/1",i.classList.add("zcCheckbox","checkbox");const a=document.createElement("p");return a.textContent=e,a.style.color="var(--tmd-text, black)",k(a,L.fontFamily),typeof m=="function"&&m()&&n.classList.add("zcDisabled"),n.addEventListener("change",()=>{if(typeof m=="function"&&m())return n.classList.add("zcDisabled");typeof l=="function"&&l()}),n.append(i,a),this.addElement(n,{x:o,y:d,width:r,anchor:p,place:g,modules:t,modulesMap:{base:n,checkbox:i,label:a}}),n}createScrollView({scroll:e,x:o,y:d,width:u,height:r,anchor:t="top-left",modules:p,place:g=!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:d,width:u,height:r,anchor:t,place:g,modules:p,modulesMap:{base:m}}),m}createInputList({x:e,y:o,width:d,height:u,title:r,value:t,modules:p,anchor:g="top-left",place:m=!0,numbersOnly:l=!1,isDisabled:n,onChange:i}){const a=[],s=document.createElement("div");s.style.cssText=`
1
+ import{Check as I,ChevronDown as $,CircleX as F,createElement as B,Trash2 as P}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 N(g){return g*(MainCanvas.canvas.clientHeight/1e3)}function D(g){return g*(MainCanvas.canvas.clientWidth/2e3)}function W(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 V(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",s=l==="top-left"||l==="bottom-left"?"left":"right",t=W(o,i),f=V(e,s);Object.assign(g.style,{position:"fixed",[s]:f+"px",[i]:t+"px"})}function J(g,e,o){Object.assign(g.style,{width:D(e)+"px",height:N(o)+"px"})}function j(g,e){const o=MainCanvas.canvas.clientWidth,l=MainCanvas.canvas.clientHeight,i=Math.min(o,l)/100,s=e*i;Object.assign(g.style,{fontSize:s+"px"})}function k(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,s=e*i;Object.assign(g.style,{padding:s+"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 S=[];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)}`}function Q(g,e){const o=_(e),l=S.find(h=>h.key===o);if(l)return g.classList.add(l.className);let i;do i="dynamic-"+Math.random().toString(36).substring(2,10);while(S.find(h=>h.className===i));S.push({key:o,className:i});const s=(h,m)=>{let d=`${h} {`;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+=s(`.${i}`,e.base)),e.hover&&(t+=s(`.${i}:hover`,e.hover)),e.active&&(t+=s(`.${i}:active`,e.active)),e.focus&&(t+=s(`.${i}:focus`,e.focus)),e.disabled&&(t+=s(`.${i}:disabled`,e.disabled));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(){R(M)}function R(g){M=A,A=g,A&&A.load(),M&&M.unload()}function ee(){return A}let A,M=null;class te{htmlElements=[];resizeEventListeners=[];tabHandlers={};addElement(e,{x:o,y:l,width:i,height:s,padding:t,fontSize:f="auto",anchor:h,place:m,modules:d={},modulesMap:r}){k(e,C.fontFamily);const c={anchor:h,x:o,y:l,width:i,height:s,padding:t,fontSize:f,place:m,element:e};Object.keys(d)?.forEach(a=>{d[a].forEach(p=>{const u=p.overrideProperties(c,r[a]);h=u.anchor,o=u.x,l=u.y,i=u.width,s=u.height,t=u.padding,f=u.fontSize,m=u.place,e=u.element})});const n=()=>{typeof o=="number"&&typeof l=="number"&&O(e,o,l,h),f==="auto"?X(e):j(e,f),t&&G(e,t),i&&(e.style.width=D(i)+"px"),s&&(e.style.height=N(s)+"px")};n(),window.addEventListener("resize",n),Object.keys(d)?.forEach(a=>{d[a].forEach(p=>{p.layoutEffect(c,r[a])})}),m&&document.body.append(e),this.resizeEventListeners.push(n),this.htmlElements.push(e),Object.keys(d)?.forEach(a=>{d[a].forEach(p=>{p.effect(c,r[a])})})}get currentSubscreen(){return A}get previousSubscreen(){return M}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;"),T[this.constructor.name]&&T[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){R(e)}createButton({text:e,x:o,y:l,width:i,height:s,fontSize:t="auto",anchor:f="top-left",padding:h,style:m="default",place:d=!0,icon:r,iconAbsolutePosition:c=!0,tooltip:n,onClick:a,isDisabled:p,modules:u}){let b,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",k(y,C.fontFamily),r&&(typeof r=="string"?(b=document.createElement("img"),b.src=r):b=r,b.style.height="80%",b.style.width="auto",e&&c&&(b.style.position="absolute",b.style.left="1vw"),e&&!c&&(y.style.justifyContent=""),y.append(b)),e&&(v=document.createElement("span"),v.textContent=e,y.append(v)),n){const L=document.createElement("span");L.classList.add("tooltip"),L.setAttribute("position",n.position),L.textContent=n.text,y.append(L)}return typeof p=="function"&&p()&&y.classList.add("zcDisabled"),y.addEventListener("click",()=>{if(typeof p=="function"&&p())return y.classList.add("zcDisabled");typeof a=="function"&&a()}),this.addElement(y,{x:o,y:l,width:i,height:s,anchor:f,place:d,fontSize:t,padding:h,modules:u,modulesMap:{base:y,text:v,icon:b}}),y}createText({text:e,color:o,x:l,y:i,width:s,height:t,withBackground:f=!1,withBorder:h=!1,fontSize:m="auto",anchor:d="top-left",padding:r,place:c=!0,modules:n}){const a=document.createElement("p");return a.innerHTML=e,a.style.color=o??"var(--tmd-text, black)",f&&(a.style.background="var(--tmd-element,rgb(239, 239, 239))"),h&&(a.style.border="2px solid var(--tmd-accent, rgb(236, 236, 236))"),k(a,C.fontFamily),this.addElement(a,{x:l,y:i,width:s,height:t,anchor:d,place:c,fontSize:m,padding:r,modules:n,modulesMap:{base:a}}),a}createInput({value:e,placeholder:o,x:l,y:i,width:s,height:t,textArea:f=!1,fontSize:h="auto",anchor:m="top-left",padding:d,place:r=!0,onChange:c,onInput:n,isDisabled:a,modules:p}){const u=document.createElement(f?"textarea":"input");return u.classList.add("zcInput"),o&&(u.placeholder=o),e&&(u.value=e),k(u,C.fontFamily),typeof a=="function"&&a()&&u.classList.add("zcDisabled"),u.addEventListener("change",()=>{if(typeof a=="function"&&a())return u.classList.add("zcDisabled");typeof c=="function"&&c()}),u.addEventListener("input",()=>{if(typeof a=="function"&&a())return u.classList.add("zcDisabled");typeof n=="function"&&n()}),this.addElement(u,{x:l,y:i,width:s,height:t,anchor:m,place:r,fontSize:h,padding:d,modules:p,modulesMap:{base:u}}),u}createCheckbox({text:e,x:o,y:l,isChecked:i,width:s,modules:t,anchor:f="top-left",place:h=!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 n=document.createElement("p");return n.textContent=e,n.style.color="var(--tmd-text, black)",k(n,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,n),this.addElement(r,{x:o,y:l,width:s,anchor:f,place:h,modules:t,modulesMap:{base:r,checkbox:c,label:n}}),r}createScrollView({scroll:e,x:o,y:l,width:i,height:s,anchor:t="top-left",modules:f,place:h=!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:s,anchor:t,place:h,modules:f,modulesMap:{base:m}}),m}createInputList({x:e,y:o,width:l,height:i,title:s,value:t,modules:f,anchor:h="top-left",place:m=!0,numbersOnly:d=!1,isDisabled:r,onChange:c}){const n=[],a=document.createElement("div");a.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
- `,k(s,L.fontFamily);const f=document.createElement("div");f.style.cssText="display: flex; justify-content: center; column-gap: 1vw; width: 100%;";const c=document.createElement("b");c.textContent=r+":",c.style.cssText="width: 100%; font-size: clamp(10px, 2.4vw, 24px); color: var(--tmd-text, black);";const v=document.createElement("div");v.style.cssText=`display: flex; gap: 1vw; flex-wrap: wrap; align-content: flex-start;
5
- overflow-y: scroll;`;const h=document.createElement("input");h.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 C=(x,E)=>{const A=this.createButton({icon:x,place:!1,onClick:E,style:"default",modules:{icon:[new W({width:"70%",height:"70%"})]}});A.style.width="2em",A.style.aspectRatio="1/1",f.append(A)},y=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,v.insertBefore(E,h),E.addEventListener("click",A=>{E.style.border===""?E.style.border="2px solid red":E.style.border="",A.stopPropagation()}),a.push(x)};return C(T(P),()=>{if(typeof n=="function"&&n())return s.classList.add("zcDisabled");v.innerHTML="",a.splice(0,a.length),v.append(h),t.forEach(x=>y(String(x))),typeof i=="function"&&i(l?a.map(x=>parseInt(x)):a)}),C(T(D),()=>{if(typeof n=="function"&&n())return s.classList.add("zcDisabled");for(const x of[...v.children])x.getAttribute("style").includes("border: 2px solid red;")&&(a.splice(a.indexOf(x.textContent),1),x.remove());typeof i=="function"&&i(l?a.map(x=>parseInt(x)):a)}),typeof n=="function"&&n()&&s.classList.add("zcDisabled"),h.addEventListener("keypress",x=>{if(document.activeElement===h)switch(x.key){case"Enter":if(l&&Number.isNaN(parseInt(h.value))||h.value.trim()==="")return;if(typeof n=="function"&&n())return s.classList.add("zcDisabled");y(h.value),h.value="",typeof i=="function"&&i(l?a.map(E=>parseInt(E)):a);break}}),s.addEventListener("click",x=>{x.currentTarget==s&&h.focus()}),v.append(h),s.append(f,c,v),this.addElement(s,{x:e,y:o,width:d,height:u,anchor:g,place:m,modules:p,modulesMap:{base:s,input:h}}),t.forEach(x=>y(String(x))),s}createImage({x:e,y:o,width:d,src:u,place:r=!0,anchor:t="top-left",modules:p}){const g=document.createElement("img");return g.style.height="auto",g.src=u,this.addElement(g,{x:e,y:o,width:d,height:0,anchor:t,place:r,modules:p,modulesMap:{base:g}}),g}createBackNextButton({x:e,y:o,width:d,height:u,items:r,currentIndex:t,modules:p,isBold:g=!1,anchor:m="top-left",place:l=!0,onChange:n,isDisabled:i}){const a=document.createElement("div");a.classList.add("zcBackNextButton"),k(a,L.fontFamily);const s=()=>{t===0||typeof i=="function"&&i(r[t-1][1])?f.classList.add("zcBackNextButton-btnDisabled"):f.classList.remove("zcBackNextButton-btnDisabled"),t===r.length-1||typeof i=="function"&&i(r[t+1][1])?c.classList.add("zcBackNextButton-btnDisabled"):c.classList.remove("zcBackNextButton-btnDisabled")},f=document.createElement("button");f.style.cssText=`
4
+ `,k(a,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=s+":",u.style.cssText="width: 100%; font-size: clamp(10px, 2.4vw, 24px); color: var(--tmd-text, black);";const b=document.createElement("div");b.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 w=this.createButton({icon:x,place:!1,onClick:E,style:"default",modules:{icon:[new H({width:"70%",height:"70%"})]}});w.style.width="2em",w.style.aspectRatio="1/1",p.append(w)},L=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,b.insertBefore(E,v),E.addEventListener("click",w=>{E.style.border===""?E.style.border="2px solid red":E.style.border="",w.stopPropagation()}),n.push(x)};return y(B(F),()=>{if(typeof r=="function"&&r())return a.classList.add("zcDisabled");b.innerHTML="",n.splice(0,n.length),b.append(v),t.forEach(x=>L(String(x))),typeof c=="function"&&c(d?n.map(x=>parseInt(x)):n)}),y(B(P),()=>{if(typeof r=="function"&&r())return a.classList.add("zcDisabled");for(const x of[...b.children])x.getAttribute("style").includes("border: 2px solid red;")&&(n.splice(n.indexOf(x.textContent),1),x.remove());typeof c=="function"&&c(d?n.map(x=>parseInt(x)):n)}),typeof r=="function"&&r()&&a.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 a.classList.add("zcDisabled");L(v.value),v.value="",typeof c=="function"&&c(d?n.map(E=>parseInt(E)):n);break}}),a.addEventListener("click",x=>{x.currentTarget==a&&v.focus()}),b.append(v),a.append(p,u,b),this.addElement(a,{x:e,y:o,width:l,height:i,anchor:h,place:m,modules:f,modulesMap:{base:a,input:v}}),t.forEach(x=>L(String(x))),a}createImage({x:e,y:o,width:l,src:i,place:s=!0,anchor:t="top-left",modules:f}){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:s,modules:f,modulesMap:{base:h}}),h}createSvg({x:e,y:o,size:l,dataurl:i,place:s=!0,anchor:t="top-left",fill:f="var(--tmd-accent, black)",stroke:h="var(--tmd-accent-hover, black)",strokeWidth:m="2px",modules:d}){function r(a){const p=a.replace("data:image/svg+xml,",""),u=decodeURIComponent(p),b=document.createElement("div");return b.innerHTML=u,b.firstElementChild}function c(a,{fill:p,stroke:u}){return a.querySelectorAll("*").forEach(v=>{v.getAttribute("fill")!=="none"&&v.setAttribute("fill",p),v.getAttribute("stroke")!=="none"&&v.setAttribute("stroke",u)}),a.getAttribute("fill")!=="none"&&a.setAttribute("fill",p),a.getAttribute("stroke")!=="none"&&a.setAttribute("stroke",u),a}const n=r(i);return c(n,{fill:f,stroke:h}),n.setAttribute("stroke-width",m),this.addElement(n,{x:e,y:o,width:l,height:l,anchor:t,place:s,modules:d,modulesMap:{base:n}}),n}createBackNextButton({x:e,y:o,width:l,height:i,items:s,currentIndex:t,modules:f,isBold:h=!1,anchor:m="top-left",place:d=!0,onChange:r,isDisabled:c}){const n=document.createElement("div");n.classList.add("zcBackNextButton"),k(n,C.fontFamily);const a=()=>{t===0||typeof c=="function"&&c(s[t-1][1])?p.classList.add("zcBackNextButton-btnDisabled"):p.classList.remove("zcBackNextButton-btnDisabled"),t===s.length-1||typeof c=="function"&&c(s[t+1][1])?u.classList.add("zcBackNextButton-btnDisabled"):u.classList.remove("zcBackNextButton-btnDisabled")},p=document.createElement("button");p.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
- `,f.classList.add("zcButton"),f.addEventListener("click",()=>{if(t===0||typeof i=="function"&&i(r[t-1][1]))return f.classList.add("zcDisabled");t--,v.textContent=r[t][0],typeof n=="function"&&n(r[t][1]),s()});const c=document.createElement("button");c.style.cssText=`
8
+ `,p.classList.add("zcButton"),p.addEventListener("click",()=>{if(t===0||typeof c=="function"&&c(s[t-1][1]))return p.classList.add("zcDisabled");t--,b.textContent=s[t][0],typeof r=="function"&&r(s[t][1]),a()});const u=document.createElement("button");u.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
- `,c.classList.add("zcButton"),c.addEventListener("click",()=>{if(t===r.length-1||typeof i=="function"&&i(r[t+1][1]))return c.classList.add("zcDisabled");t++,v.textContent=r[t][0],typeof n=="function"&&n(r[t][1]),s()}),s();const v=document.createElement("p");return g&&(v.style.fontWeight="bold"),v.textContent=r[t][0],a.append(f,v,c),this.addElement(a,{x:e,y:o,width:d,height:u,anchor:m,place:l,modules:p,modulesMap:{base:a,backButton:f,nextButton:c,text:v}}),a}createTabs({x:e,y:o,width:d,tabs:u,anchor:r="top-left",place:t=!0,currentTabName:p,modules:g}){let m=[];const l=document.createElement("div");return l.classList.add("zcTabs"),k(l,L.fontFamily),u.forEach(n=>{const i=()=>{for(const f of l.children)f.removeAttribute("data-opened");for(const f of m)f instanceof Node&&document.body.removeChild(f);m=[],a.setAttribute("data-opened","true");const s=document.body.append.bind(document.body);document.body.append=(...f)=>{m.push(...f),s(...f)},this.tabHandlers.unload?.(),this.tabHandlers.exit?.(),n.load(),this.tabHandlers={run:n.run,load:n.load,unload:n.unload,exit:n.exit},document.body.append=s},a=document.createElement("button");a.textContent=n.name,n.name===p&&i(),a.addEventListener("click",i),l.append(a)}),this.addElement(l,{x:e,y:o,width:d,anchor:r,place:t,modules:g,modulesMap:{base:l}}),l}drawPolylineArrow({points:e,strokeColor:o=z()?.base?.text??"black",lineWidth:d=2,circleRadius:u=5,circleColor:r=z()?.base?.text??"black"}){if(e.length<2)return;const t=MainCanvas.canvas.getContext("2d");t.save(),t.strokeStyle=o,t.lineWidth=d,t.fillStyle=r,t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let p=1;p<e.length;p++)t.lineTo(e[p].x,e[p].y);t.stroke(),t.beginPath(),t.arc(e[0].x,e[0].y,u,0,Math.PI*2),t.fill(),t.beginPath(),t.arc(e[e.length-1].x,e[e.length-1].y,u,0,Math.PI*2),t.fill(),t.restore()}createCard({x:e,y:o,name:d,value:u,icon:r,anchor:t="top-left",place:p=!0,modules:g}){const m=document.createElement("div");m.classList.add("zcCard");const l=document.createElement("p");l.classList.add("zcCard_name"),l.textContent=d;const n=document.createElement("p");return n.classList.add("zcCard_value"),n.textContent=`${u}`,r&&(r.style.cssText+="position: absolute; top: 0.4em; right: 0.4em; width: 1.2em; height: 1.2em;",m.append(r)),m.append(l,n),this.addElement(m,{x:e,y:o,anchor:t,place:p,modules:g,modulesMap:{name:l,value:n,base:m,icon:null}}),m}createSelect({x:e,y:o,width:d,options:u,currentOption:r,anchor:t="top-left",place:p=!0,modules:g,onChange:m,isDisabled:l}){let n=!1,i;const a=document.createElement("div");a.classList.add("zcSelect"),a.setAttribute("opened",!1),a.addEventListener("click",()=>{if(l&&l())return a.classList.add("zcDisabled");n?(n=!1,i.remove()):(n=!0,i=document.createElement("div"),i.setAttribute("data-zc-position",typeof o=="number"&&o>500-a.offsetHeight/2?"top":"bottom"),u.forEach(v=>{const h=document.createElement("div");h.style.cssText="display: flex; align-items: center; column-gap: 0.5em;",v.icon&&(v.icon.style.cssText="color: #bcbcbc;",h.append(v.icon)),h.append(v.text),v.name===r&&h.append(c),h.addEventListener("click",()=>{r=v.name,s.textContent=v.text,i.remove(),m&&m(v.name)}),i.append(h)}),a.append(i))});const s=document.createElement("p");s.textContent=u.find(v=>v.name===r).text;const f=T(I),c=T(N);return c.style.cssText="position: absolute; right: 0.25em;",a.append(s,f),l&&l()&&a.classList.add("zcDisabled"),this.addElement(a,{x:e,y:o,width:d,anchor:t,place:p,modules:g,modulesMap:{base:a}}),a}createContainer({x:e,y:o,anchor:d="top-left",place:u=!0,modules:r}){const t=document.createElement("div");return this.addElement(t,{x:e,y:o,anchor:d,place:u,modules:r,modulesMap:{base:t}}),t}}const B={};function Z(b,e){B[b]||(B[b]=[]),B[b].push(e)}export{Q as BaseSubscreen,X as autosetFontSize,q as dataUrlSvgWithColor,K as getCurrentSubscreen,S as getRelativeHeight,H as getRelativeWidth,V as getRelativeX,R as getRelativeY,Z as hookSubscreen,k as setFontFamily,O as setFontSize,G as setPadding,j as setPosition,Y as setPreviousSubscreen,J as setSize,F as setSubscreen};
11
+ `,u.classList.add("zcButton"),u.addEventListener("click",()=>{if(t===s.length-1||typeof c=="function"&&c(s[t+1][1]))return u.classList.add("zcDisabled");t++,b.textContent=s[t][0],typeof r=="function"&&r(s[t][1]),a()}),a();const b=document.createElement("p");return h&&(b.style.fontWeight="bold"),b.textContent=s[t][0],n.append(p,b,u),this.addElement(n,{x:e,y:o,width:l,height:i,anchor:m,place:d,modules:f,modulesMap:{base:n,backButton:p,nextButton:u,text:b}}),n}createTabs({x:e,y:o,width:l,tabs:i,anchor:s="top-left",place:t=!0,currentTabName:f,modules:h}){let m=[];const d=document.createElement("div");return d.classList.add("zcTabs"),k(d,C.fontFamily),i.forEach(r=>{const c=()=>{for(const p of d.children)p.removeAttribute("data-opened");for(const p of m)p instanceof Node&&document.body.removeChild(p);m=[],n.setAttribute("data-opened","true");const a=document.body.append.bind(document.body);document.body.append=(...p)=>{m.push(...p),a(...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=a},n=document.createElement("button");n.textContent=r.name,r.name===f&&c(),n.addEventListener("click",c),d.append(n)}),this.addElement(d,{x:e,y:o,width:l,anchor:s,place:t,modules:h,modulesMap:{base:d}}),d}drawPolylineArrow({points:e,strokeColor:o=z()?.base?.text??"black",lineWidth:l=2,circleRadius:i=5,circleColor:s=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=s,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:s,anchor:t="top-left",place:f=!0,modules:h}){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}`,s&&(s.style.cssText+="position: absolute; top: 0.4em; right: 0.4em; width: 1.2em; height: 1.2em;",m.append(s)),m.append(d,r),this.addElement(m,{x:e,y:o,anchor:t,place:f,modules:h,modulesMap:{name:d,value:r,base:m,icon:null}}),m}createSelect({x:e,y:o,width:l,options:i,currentOption:s,anchor:t="top-left",place:f=!0,modules:h,onChange:m,isDisabled:d}){let r=!1,c;const n=document.createElement("div");n.classList.add("zcSelect"),n.setAttribute("opened",!1),n.addEventListener("click",()=>{if(d&&d())return n.classList.add("zcDisabled");r?(r=!1,c.remove()):(r=!0,c=document.createElement("div"),c.setAttribute("data-zc-position",typeof o=="number"&&o>500-n.offsetHeight/2?"top":"bottom"),i.forEach(b=>{const v=document.createElement("div");v.style.cssText="display: flex; align-items: center; column-gap: 0.5em;",b.icon&&(b.icon.style.cssText="color: #bcbcbc;",v.append(b.icon)),v.append(b.text),b.name===s&&v.append(u),v.addEventListener("click",()=>{s=b.name,a.textContent=b.text,c.remove(),m&&m(b.name)}),c.append(v)}),n.append(c))});const a=document.createElement("p");a.textContent=i.find(b=>b.name===s).text;const p=B($),u=B(I);return u.style.cssText="position: absolute; right: 0.25em;",n.append(a,p),d&&d()&&n.classList.add("zcDisabled"),this.addElement(n,{x:e,y:o,width:l,anchor:t,place:f,modules:h,modulesMap:{base:n}}),n}createContainer({x:e,y:o,anchor:l="top-left",place:i=!0,modules:s}){const t=document.createElement("div");return this.addElement(t,{x:e,y:o,anchor:l,place:i,modules:s,modulesMap:{base:t}}),t}}const T={};function ne(g,e){T[g]||(T[g]=[]),T[g].push(e)}export{te as BaseSubscreen,Q as addDynamicClass,X as autosetFontSize,q as dataUrlSvgWithColor,ee as getCurrentSubscreen,N as getRelativeHeight,D as getRelativeWidth,V as getRelativeX,W as getRelativeY,ne as hookSubscreen,k as setFontFamily,j as setFontSize,G as setPadding,O as setPosition,U as setPreviousSubscreen,J as setSize,R as setSubscreen};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zois-core",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
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",