builder-settings-types 0.0.244 → 0.0.246

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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let O=(c=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(c|=0));for(;c--;)t+=R[e[c]&63];return t};function F(c){let t=0,e=c.parentElement;for(;e;)e.classList.contains("setting-group")&&e!==c&&t++,e=e.parentElement;return t}function x(c,t){const e=Math.min(Math.max(t,0),5);c.setAttribute("data-nesting-level",e.toString()),e>0?c.style.setProperty("--visual-indent",`${e*2}px`):(c.style.removeProperty("--visual-indent"),c.style.marginLeft="")}function V(c,t=0){c.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach(i=>{const s=i,n=t+1;x(s,n),V(s,n)})}const G={maxLevel:5,spacingMultiplier:1,visualIndentMultiplier:2,enableAutoDetection:!0};class z{constructor(t={}){this.observedElements=new Set,this.config={...G,...t},this.config.enableAutoDetection&&this.setupAutoDetection()}setupAutoDetection(){this.observer=new MutationObserver(t=>{let e=!1;t.forEach(i=>{i.type==="childList"&&i.addedNodes.forEach(s=>{s instanceof HTMLElement&&(s.classList.contains("setting-group")?[s]:Array.from(s.querySelectorAll(".setting-group"))).length>0&&(e=!0)})}),e&&this.updateAllNesting()}),this.observer.observe(document.body,{childList:!0,subtree:!0})}trackElement(t){this.observedElements.add(t),this.updateElementNesting(t)}untrackElement(t){this.observedElements.delete(t)}updateElementNesting(t){const e=F(t);this.applyNestingWithConfig(t,e)}updateAllNesting(){this.observedElements.forEach(t=>{t.isConnected?this.updateElementNesting(t):this.observedElements.delete(t)})}applyNestingWithConfig(t,e){const i=Math.min(Math.max(e,0),this.config.maxLevel);if(t.setAttribute("data-nesting-level",i.toString()),i>0){const s=i*this.config.visualIndentMultiplier;t.style.setProperty("--visual-indent",`${s}px`)}else t.style.removeProperty("--visual-indent"),t.style.marginLeft=""}recalculateNesting(t=document.body){t.querySelectorAll(".setting-group").forEach(i=>{const s=i;this.updateElementNesting(s),this.trackElement(s)})}getNestingStats(){const t={};return this.observedElements.forEach(e=>{const i=parseInt(e.getAttribute("data-nesting-level")||"0",10);t[i]=(t[i]||0)+1}),t}destroy(){this.observer&&(this.observer.disconnect(),this.observer=void 0),this.observedElements.clear()}}const N=new z;function y(c){if(c===null||typeof c!="object")return c;if(c instanceof Date)return new Date(c.getTime());if(c instanceof Array)return c.map(t=>y(t));if(typeof c=="object"){const t={};for(const e in c)Object.prototype.hasOwnProperty.call(c,e)&&(t[e]=y(c[e]));return t}return c}function W(c){switch(c){case"number":return 0;case"text":return"";case"select":return null;case"color":return"#000000";case"date":return new Date().toISOString().split("T")[0];case"button":return"";default:return""}}class g{constructor(t={}){this.props=t,this.dataPropsPath="",this.id=t.id||O(),this.value=this.props.default,this.desktop=this.props.default,this.title=t.title||"",this.includeGetJson=t.includeGetJson!==void 0?t.includeGetJson:!0}static SetUploadUrl(t){globalThis.DefaultUploadUrl=t,g.DefaultUploadUrl=t}destroy(){throw new Error("Method not implemented.")}setOnChange(t){return this.onChange=t,this}setOnBlur(t){return this.onBlur=t,this}setDataPropsPath(t){this.dataPropsPath=t}getDataPropsPath(){return this.dataPropsPath}setValue(t){this.value=t,this.inputEl&&(this.inputEl.value=String(t)),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}clone(){const t=this.constructor,e=y(this.props),i=new t(e);return i.value=y(this.value),i}createInput(t){t={...this.props.inputProps,...t};const e=document.createElement("div");if(e.className=t.wrapperClassName||"",t.title||t.icon){const o=document.createElement("div");if(o.className="icon-container",t.icon){const l=this.createIcon(t.icon,t.iconClassName);o.appendChild(l)}if(t.title){const l=this.createLabel(t.title,t.labelClassName);o.appendChild(l)}e.appendChild(o)}const i=document.createElement("div");i.className=t.wrapperClassName||"";const s=document.createElement("input");this.inputEl=s,s.value=String(t.value||W(t.inputType)),s.type=t.inputType,s.placeholder=t.placeholder||"",s.className=t.inputClassName||"",this.dataPropsPath&&s.setAttribute("data-test-id",this.dataPropsPath);const n=o=>{const l=o.target;let r=l.value;switch(t.inputType){case"number":r=Number(l.value);break;case"color":r=l.value;break;case"date":r=l.value;break;case"select":r=l.value;break;case"text":r=l.value;break;case"button":r=l.value;break;default:r=l.value}this.value=r,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},a=o=>{o.target,this.onBlur&&this.onBlur(this.value)};return s.addEventListener("input",n),s.addEventListener("change",n),s.addEventListener("blur",a),t.inputCustomizer&&t.inputCustomizer(s),i.appendChild(s),e.appendChild(i),e}createLabel(t,e){const i=document.createElement("span");return i.textContent=t,i.className="input-label "+(e||""),i}createIcon(t,e){const i=document.createElement("span");return i.className="input-icon "+(e||""),i.innerHTML=t,i}}function w(c){return c instanceof g}function u(c){return c instanceof v}function _(c){return w(c)||u(c)}function b(c,t){for(const e in c)if(Object.prototype.hasOwnProperty.call(c,e)){const i=c[e];t(e,i)}}const k=class k{constructor(t){this.elementRef=null,this.isHidden=!1,this.custom=!1,this.initialValues={},this.changeTimeout=null,this.isHandlingChange=!1,this.changeHandlers=new Set,this.blurTimeout=null,this.lastChangeTime=0,this.handleBlur=()=>{},this.pendingBlurHandler=null,this.originalDefaultValues={},this.nestingLevel=0,this.dataPropsPath="",this.id=t.id||O(),this.title=t.title,this.settings=t.settings,this.isCollapsed=t.collapsed??!1,this.isMain=t.main??!1,this.custom=t.custom??!1,this.nestingLevel=0,this.includeGetJson=t.includeGetJson??!0,this.addItemCfg=t.addItem,this.deleteItemCfg=t.deleteItem,this.dataProps=t.dataProps,this.dataPropsPath=t.dataProps||"",Object.assign(this,t.settings),this.initialValues=this.getValues(),this.originalDefaultValues=this.getDefaultValues(),this.propagateNestingLevel(),this.propagateDataPropsPath()}propagateNestingLevel(){const t=this.nestingLevel+1;b(this.settings,(e,i)=>{u(i)&&(i.nestingLevel=t,i.propagateNestingLevel())})}getNestingLevel(){return this.nestingLevel}setNestingLevel(t){this.nestingLevel=t,this.propagateNestingLevel(),this.elementRef&&this.updateNestingStyles()}getDataPropsPath(){return this.dataPropsPath}setDataPropsPath(t){this.dataPropsPath=t,this.propagateDataPropsPath()}propagateDataPropsPath(){b(this.settings,(t,e)=>{const i=String(t),s=this.dataPropsPath?`${this.dataPropsPath}_${i}`:i;(u(e)||w(e)&&typeof e.setDataPropsPath=="function")&&e.setDataPropsPath(s)})}updateNestingStyles(){this.elementRef&&(x(this.elementRef,this.nestingLevel),V(this.elementRef,this.nestingLevel))}forceChildUIRefresh(){Object.entries(this.settings).forEach(([t,e])=>{try{if(u(e)){const i=e.getValues();e.setValue(i)}else if(typeof e.setValue=="function"){const i=e.value;i!==void 0&&e.setValue(i)}}catch(i){console.warn(`Error refreshing UI for setting ${t}:`,i)}})}removeSetting(t){var s;const e=this.settings[t];if(!e)return;if(delete this.settings[t],this.elementRef){const n=this.elementRef.querySelector(".setting-group-content");if(n){const a=Array.from(n.querySelectorAll(".setting-group, .setting"));for(const o of a){const l=o.id;if(l&&"id"in e&&typeof e.id=="string"&&l.includes(e.id)){o.remove();break}}}}typeof e.cleanup=="function"&&e.cleanup(),this.updateNestingStyles();const i=this.getValues();this.initialValues=i,(s=this.onChange)==null||s.call(this,i)}updateVisibility(){this.elementRef}clone(){const t={};b(this.settings,(s,n)=>{const a=String(s);typeof n.clone=="function"?t[a]=n.clone():(console.warn(`Setting with key '${a}' does not have a clone method. Copying reference.`),t[a]=n)});const e={title:this.title,settings:t,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,includeGetJson:this.includeGetJson,addItem:this.addItemCfg,deleteItem:this.deleteItemCfg,dataProps:this.dataProps},i=H(e);return i.initialValues=this.getValues(),i}resetDefault(){const t=this.originalDefaultValues;this.setValue(t),this.onChange&&this.onChange(this.getValues())}setMobileValues(t){!t||typeof t!="object"||(Object.entries(t).forEach(([e,i])=>{const s=this.settings[e];s&&(u(s)||w(s))&&typeof s.setMobileValue=="function"&&s.setMobileValue(i)}),this.setValue(t),this.onChange&&this.onChange(this.getValues()))}getMobileValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(u(s))e[i]=s.getMobileValues();else{const n=s;e[i]=n.mobileValue!==void 0?n.mobileValue:n.value}}return e}else{const e=this.settings[t];if(!e)return;if(u(e))return e.getMobileValues();const i=e;return i.mobileValue!==void 0?i.mobileValue:i.value}}setOnChange(t){this.onChange=t;const e=()=>{this.isHandlingChange||(this.isHandlingChange=!0,this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=setTimeout(()=>{const i=this.getValues(),s=this.calculateChanges(this.initialValues,i);Object.keys(s).length>0&&(this.lastChangeTime=Date.now(),this.initialValues=i,t(i),this.updateVisibility()),this.isHandlingChange=!1},50))};return this.changeHandlers.clear(),b(this.settings,(i,s)=>{var n;if(u(s))s.setOnChange(()=>{const a=this.getValues();this.initialValues=a,t(a)}),this.changeHandlers.add(()=>t(this.getValues()));else if(w(s)){const a=()=>e();this.changeHandlers.add(a),s.setOnChange(a)}else{const a=()=>e();this.changeHandlers.add(a),(n=s.setOnChange)==null||n.call(s,a)}}),this}cleanup(){this.changeTimeout&&(clearTimeout(this.changeTimeout),this.changeTimeout=null),this.blurTimeout&&(clearTimeout(this.blurTimeout),this.blurTimeout=null),this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.changeHandlers.clear()}setValue(t){if(!t||typeof t!="object")return;Object.entries(t).forEach(([i,s])=>{let n=this.settings[i];if(!n&&this.addItemCfg&&i.startsWith(this.addItemCfg.keyPrefix)){const a=i.slice(this.addItemCfg.keyPrefix.length),o=Number(a);if(Number.isFinite(o)){const l=this.addItemCfg.createItem(o);this.addSetting(i,l),n=l}}n&&(u(n)||w(n))&&typeof n.setValue=="function"&&n.setValue(s)}),setTimeout(()=>{this.forceChildUIRefresh()},0);const e=this.getValues();this.initialValues=e,this.onChange&&this.onChange(e)}wireChild(t){var i;const e=()=>{var n;const s=this.getValues();this.initialValues=s,(n=this.onChange)==null||n.call(this,s),this.updateVisibility()};u(t)?t.setOnChange(()=>e()):w(t)?t.setOnChange(()=>e()):(i=t.setOnChange)==null||i.call(t,()=>e())}addSetting(t,e){var s,n;if(this.settings[t]=e,this.wireChild(e),this.elementRef){const a=this.elementRef.querySelector(".setting-group-content");if(a){u(e)&&typeof e.setNestingLevel=="function"&&e.setNestingLevel(this.nestingLevel+1);const o=e.draw(),l=this.deleteItemCfg??this.addItemCfg;if(l){const d=l.keyPrefix??((s=this.addItemCfg)==null?void 0:s.keyPrefix);d&&t.startsWith(d)&&this.addDeleteButtonToElement(o,t)}const r=a.querySelector(".sg-add-button-bottom");r?a.insertBefore(o,r):a.appendChild(o),N.trackElement(o),x(o,this.nestingLevel+1),V(o,this.nestingLevel+1);const h=o.style.display;o.style.display="none",o.offsetHeight,o.style.display=h,this.updateNestingStyles()}}const i=this.getValues();this.initialValues=i,(n=this.onChange)==null||n.call(this,i)}addDeleteButtonToElement(t,e,i){let s=null;try{s=t.querySelector(":scope > .setting-group-title")}catch{s=null}if(!s){const r=Array.from(t.querySelectorAll(".setting-group-title"));for(const h of r)if(h.closest(".setting-group")===t){s=h;break}s||(s=r[0]??null)}if(!s)return;const n=s.querySelector(".actions-section");if(!n)return;const a=document.createElement("button");a.type="button",a.className="sg-delete-button",i?i.deleteItemCfg:this.deleteItemCfg??this.addItemCfg,a.title="Delete",a.style.cssText=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let O=(c=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(c|=0));for(;c--;)t+=R[e[c]&63];return t};function F(c){let t=0,e=c.parentElement;for(;e;)e.classList.contains("setting-group")&&e!==c&&t++,e=e.parentElement;return t}function x(c,t){const e=Math.min(Math.max(t,0),5);c.setAttribute("data-nesting-level",e.toString()),e>0?c.style.setProperty("--visual-indent",`${e*2}px`):(c.style.removeProperty("--visual-indent"),c.style.marginLeft="")}function V(c,t=0){c.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach(i=>{const s=i,n=t+1;x(s,n),V(s,n)})}const G={maxLevel:5,spacingMultiplier:1,visualIndentMultiplier:2,enableAutoDetection:!0};class z{constructor(t={}){this.observedElements=new Set,this.config={...G,...t},this.config.enableAutoDetection&&this.setupAutoDetection()}setupAutoDetection(){this.observer=new MutationObserver(t=>{let e=!1;t.forEach(i=>{i.type==="childList"&&i.addedNodes.forEach(s=>{s instanceof HTMLElement&&(s.classList.contains("setting-group")?[s]:Array.from(s.querySelectorAll(".setting-group"))).length>0&&(e=!0)})}),e&&this.updateAllNesting()}),this.observer.observe(document.body,{childList:!0,subtree:!0})}trackElement(t){this.observedElements.add(t),this.updateElementNesting(t)}untrackElement(t){this.observedElements.delete(t)}updateElementNesting(t){const e=F(t);this.applyNestingWithConfig(t,e)}updateAllNesting(){this.observedElements.forEach(t=>{t.isConnected?this.updateElementNesting(t):this.observedElements.delete(t)})}applyNestingWithConfig(t,e){const i=Math.min(Math.max(e,0),this.config.maxLevel);if(t.setAttribute("data-nesting-level",i.toString()),i>0){const s=i*this.config.visualIndentMultiplier;t.style.setProperty("--visual-indent",`${s}px`)}else t.style.removeProperty("--visual-indent"),t.style.marginLeft=""}recalculateNesting(t=document.body){t.querySelectorAll(".setting-group").forEach(i=>{const s=i;this.updateElementNesting(s),this.trackElement(s)})}getNestingStats(){const t={};return this.observedElements.forEach(e=>{const i=parseInt(e.getAttribute("data-nesting-level")||"0",10);t[i]=(t[i]||0)+1}),t}destroy(){this.observer&&(this.observer.disconnect(),this.observer=void 0),this.observedElements.clear()}}const N=new z;function y(c){if(c===null||typeof c!="object")return c;if(c instanceof Date)return new Date(c.getTime());if(c instanceof Array)return c.map(t=>y(t));if(typeof c=="object"){const t={};for(const e in c)Object.prototype.hasOwnProperty.call(c,e)&&(t[e]=y(c[e]));return t}return c}function W(c){switch(c){case"number":return 0;case"text":return"";case"select":return null;case"color":return"#000000";case"date":return new Date().toISOString().split("T")[0];case"button":return"";default:return""}}class g{constructor(t={}){this.props=t,this.dataPropsPath="",this.id=t.id||O(),this.value=this.props.default,this.desktop=this.props.default,this.title=t.title||"",this.includeGetJson=t.includeGetJson!==void 0?t.includeGetJson:!0}static SetUploadUrl(t){globalThis.DefaultUploadUrl=t,g.DefaultUploadUrl=t}destroy(){throw new Error("Method not implemented.")}setOnChange(t){return this.onChange=t,this}setOnBlur(t){return this.onBlur=t,this}setDataPropsPath(t){this.dataPropsPath=t}getDataPropsPath(){return this.dataPropsPath}setValue(t){this.value=t,this.inputEl&&(this.inputEl.value=String(t)),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}clone(){const t=this.constructor,e=y(this.props),i=new t(e);return i.value=y(this.value),i}createInput(t){t={...this.props.inputProps,...t};const e=document.createElement("div");if(e.className=t.wrapperClassName||"",t.title||t.icon){const o=document.createElement("div");if(o.className="icon-container",t.icon){const l=this.createIcon(t.icon,t.iconClassName);o.appendChild(l)}if(t.title){const l=this.createLabel(t.title,t.labelClassName);o.appendChild(l)}e.appendChild(o)}const i=document.createElement("div");i.className=t.wrapperClassName||"";const s=document.createElement("input");this.inputEl=s,s.value=String(t.value||W(t.inputType)),s.type=t.inputType,s.placeholder=t.placeholder||"",s.className=t.inputClassName||"",this.dataPropsPath&&s.setAttribute("data-test-id",this.dataPropsPath);const n=o=>{const l=o.target;let r=l.value;switch(t.inputType){case"number":r=Number(l.value);break;case"color":r=l.value;break;case"date":r=l.value;break;case"select":r=l.value;break;case"text":r=l.value;break;case"button":r=l.value;break;default:r=l.value}this.value=r,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},a=o=>{o.target,this.onBlur&&this.onBlur(this.value)};return s.addEventListener("input",n),s.addEventListener("change",n),s.addEventListener("blur",a),t.inputCustomizer&&t.inputCustomizer(s),i.appendChild(s),e.appendChild(i),e}createLabel(t,e){const i=document.createElement("span");return i.textContent=t,i.className="input-label "+(e||""),i}createIcon(t,e){const i=document.createElement("span");return i.className="input-icon "+(e||""),i.innerHTML=t,i}}function w(c){return c instanceof g}function p(c){return c instanceof v}function _(c){return w(c)||p(c)}function b(c,t){for(const e in c)if(Object.prototype.hasOwnProperty.call(c,e)){const i=c[e];t(e,i)}}const k=class k{constructor(t){this.elementRef=null,this.isHidden=!1,this.custom=!1,this.initialValues={},this.changeTimeout=null,this.isHandlingChange=!1,this.changeHandlers=new Set,this.blurTimeout=null,this.lastChangeTime=0,this.handleBlur=()=>{},this.pendingBlurHandler=null,this.originalDefaultValues={},this.nestingLevel=0,this.dataPropsPath="",this.id=t.id||O(),this.title=t.title,this.settings=t.settings,this.isCollapsed=t.collapsed??!1,this.isMain=t.main??!1,this.custom=t.custom??!1,this.nestingLevel=0,this.includeGetJson=t.includeGetJson??!0,this.addItemCfg=t.addItem,this.deleteItemCfg=t.deleteItem,this.dataProps=t.dataProps,this.dataPropsPath=t.dataProps||"",Object.assign(this,t.settings),this.initialValues=this.getValues(),this.originalDefaultValues=this.getDefaultValues(),this.propagateNestingLevel(),this.propagateDataPropsPath()}propagateNestingLevel(){const t=this.nestingLevel+1;b(this.settings,(e,i)=>{p(i)&&(i.nestingLevel=t,i.propagateNestingLevel())})}getNestingLevel(){return this.nestingLevel}setNestingLevel(t){this.nestingLevel=t,this.propagateNestingLevel(),this.elementRef&&this.updateNestingStyles()}getDataPropsPath(){return this.dataPropsPath}setDataPropsPath(t){this.dataPropsPath=t,this.propagateDataPropsPath()}propagateDataPropsPath(){b(this.settings,(t,e)=>{const i=String(t),s=this.dataPropsPath?`${this.dataPropsPath}_${i}`:i;(p(e)||w(e)&&typeof e.setDataPropsPath=="function")&&e.setDataPropsPath(s)})}updateNestingStyles(){this.elementRef&&(x(this.elementRef,this.nestingLevel),V(this.elementRef,this.nestingLevel))}forceChildUIRefresh(){Object.entries(this.settings).forEach(([t,e])=>{try{if(p(e)){const i=e.getValues();e.setValue(i)}else if(typeof e.setValue=="function"){const i=e.value;i!==void 0&&e.setValue(i)}}catch(i){console.warn(`Error refreshing UI for setting ${t}:`,i)}})}removeSetting(t){var s;const e=this.settings[t];if(!e)return;if(delete this.settings[t],this.elementRef){const n=this.elementRef.querySelector(".setting-group-content");if(n){const a=Array.from(n.querySelectorAll(".setting-group, .setting"));for(const o of a){const l=o.id;if(l&&"id"in e&&typeof e.id=="string"&&l.includes(e.id)){o.remove();break}}}}typeof e.cleanup=="function"&&e.cleanup(),this.updateNestingStyles();const i=this.getValues();this.initialValues=i,(s=this.onChange)==null||s.call(this,i)}updateVisibility(){this.elementRef}clone(){const t={};b(this.settings,(s,n)=>{const a=String(s);typeof n.clone=="function"?t[a]=n.clone():(console.warn(`Setting with key '${a}' does not have a clone method. Copying reference.`),t[a]=n)});const e={title:this.title,settings:t,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,includeGetJson:this.includeGetJson,addItem:this.addItemCfg,deleteItem:this.deleteItemCfg,dataProps:this.dataProps},i=H(e);return i.initialValues=this.getValues(),i}resetDefault(){const t=this.originalDefaultValues;this.setValue(t),this.onChange&&this.onChange(this.getValues())}setMobileValues(t){!t||typeof t!="object"||(Object.entries(t).forEach(([e,i])=>{const s=this.settings[e];s&&(p(s)||w(s))&&typeof s.setMobileValue=="function"&&s.setMobileValue(i)}),this.setValue(t),this.onChange&&this.onChange(this.getValues()))}getMobileValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(p(s))e[i]=s.getMobileValues();else{const n=s;e[i]=n.mobileValue!==void 0?n.mobileValue:n.value}}return e}else{const e=this.settings[t];if(!e)return;if(p(e))return e.getMobileValues();const i=e;return i.mobileValue!==void 0?i.mobileValue:i.value}}setOnChange(t){this.onChange=t;const e=()=>{this.isHandlingChange||(this.isHandlingChange=!0,this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=setTimeout(()=>{const i=this.getValues(),s=this.calculateChanges(this.initialValues,i);Object.keys(s).length>0&&(this.lastChangeTime=Date.now(),this.initialValues=i,t(i),this.updateVisibility()),this.isHandlingChange=!1},50))};return this.changeHandlers.clear(),b(this.settings,(i,s)=>{var n;if(p(s))s.setOnChange(()=>{const a=this.getValues();this.initialValues=a,t(a)}),this.changeHandlers.add(()=>t(this.getValues()));else if(w(s)){const a=()=>e();this.changeHandlers.add(a),s.setOnChange(a)}else{const a=()=>e();this.changeHandlers.add(a),(n=s.setOnChange)==null||n.call(s,a)}}),this}cleanup(){this.changeTimeout&&(clearTimeout(this.changeTimeout),this.changeTimeout=null),this.blurTimeout&&(clearTimeout(this.blurTimeout),this.blurTimeout=null),this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.changeHandlers.clear()}setValue(t){if(!t||typeof t!="object")return;Object.entries(t).forEach(([i,s])=>{let n=this.settings[i];if(!n&&this.addItemCfg&&i.startsWith(this.addItemCfg.keyPrefix)){const a=i.slice(this.addItemCfg.keyPrefix.length),o=Number(a);if(Number.isFinite(o)){const l=this.addItemCfg.createItem(o);this.addSetting(i,l),n=l}}n&&(p(n)||w(n))&&typeof n.setValue=="function"&&n.setValue(s)}),setTimeout(()=>{this.forceChildUIRefresh()},0);const e=this.getValues();this.initialValues=e,this.onChange&&this.onChange(e)}wireChild(t){var i;const e=()=>{var n;const s=this.getValues();this.initialValues=s,(n=this.onChange)==null||n.call(this,s),this.updateVisibility()};p(t)?t.setOnChange(()=>e()):w(t)?t.setOnChange(()=>e()):(i=t.setOnChange)==null||i.call(t,()=>e())}addSetting(t,e){var s,n;if(this.settings[t]=e,this.wireChild(e),this.elementRef){const a=this.elementRef.querySelector(".setting-group-content");if(a){p(e)&&typeof e.setNestingLevel=="function"&&e.setNestingLevel(this.nestingLevel+1);const o=e.draw(),l=this.deleteItemCfg??this.addItemCfg;if(l){const d=l.keyPrefix??((s=this.addItemCfg)==null?void 0:s.keyPrefix);d&&t.startsWith(d)&&this.addDeleteButtonToElement(o,t)}const r=a.querySelector(".sg-add-button-bottom");r?a.insertBefore(o,r):a.appendChild(o),N.trackElement(o),x(o,this.nestingLevel+1),V(o,this.nestingLevel+1);const h=o.style.display;o.style.display="none",o.offsetHeight,o.style.display=h,this.updateNestingStyles()}}const i=this.getValues();this.initialValues=i,(n=this.onChange)==null||n.call(this,i)}addDeleteButtonToElement(t,e,i){let s=null;try{s=t.querySelector(":scope > .setting-group-title")}catch{s=null}if(!s){const r=Array.from(t.querySelectorAll(".setting-group-title"));for(const h of r)if(h.closest(".setting-group")===t){s=h;break}s||(s=r[0]??null)}if(!s)return;const n=s.querySelector(".actions-section");if(!n)return;const a=document.createElement("button");a.type="button",a.className="sg-delete-button",i?i.deleteItemCfg:this.deleteItemCfg??this.addItemCfg,a.title="Delete",a.style.cssText=`
2
2
  background: none;
3
3
  border: none;
4
4
  cursor: pointer;
@@ -70,16 +70,16 @@
70
70
  font-weight: 500;
71
71
  cursor: pointer;
72
72
  transition: all 0.2s;
73
- `,o.addEventListener("mouseenter",()=>{o.style.backgroundColor="#f9fafb",o.style.borderColor="#9ca3af"}),o.addEventListener("mouseleave",()=>{o.style.backgroundColor="white",o.style.borderColor="#d1d5db"}),l.addEventListener("mouseenter",()=>{l.style.backgroundColor="#dc2626"}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="#ef4444"});const r=()=>{e.style.opacity="0",i.style.transform="scale(0.95)",setTimeout(()=>{e.parentNode&&e.parentNode.removeChild(e)},200)};o.addEventListener("click",()=>{r(),t(!1)}),l.addEventListener("click",()=>{r(),t(!0)}),e.addEventListener("click",d=>{d.target===e&&(r(),t(!1))});const h=d=>{d.key==="Escape"&&(r(),t(!1),document.removeEventListener("keydown",h))};document.addEventListener("keydown",h),a.appendChild(o),a.appendChild(l),i.appendChild(s),i.appendChild(n),i.appendChild(a),e.appendChild(i),document.body.appendChild(e),requestAnimationFrame(()=>{e.style.opacity="1",i.style.transform="scale(1)"}),setTimeout(()=>l.focus(),100)})}getNextIndexFromPrefix(t){const e=Object.keys(this.settings).filter(i=>i.startsWith(t)).map(i=>{const s=Number(i.slice(t.length));return Number.isFinite(s)?s:-1}).filter(i=>i>=0);return e.length?Math.max(...e)+1:0}calculateChanges(t,e){const i={};return new Set([...Object.keys(t),...Object.keys(e)]).forEach(n=>{const a=t[n],o=e[n];JSON.stringify(a)!==JSON.stringify(o)&&(i[n]={from:a,to:o})}),i}getValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];u(s)?e[i]=s.getValues():e[i]=s.value}return e}else{const e=this.settings[t];return e?u(e)?e.getValues():e.value:void 0}}getValuesForJson(t){if(t===void 0){if(this.includeGetJson===!1)return null;const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(u(s))e[i]=s.getValuesForJson();else{const n=s;n.includeGetJson===!1?e[i]=null:e[i]=n.value}}return e}else{const e=this.settings[t];if(!e)return;if(u(e))return e.includeGetJson===!1?null:e.getValuesForJson();{const i=e;return i.includeGetJson===!1?null:i.value}}}getDefaultValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(u(s))e[i]=s.getDefaultValues();else{const n=s;e[i]=n.default!==void 0?n.default:n.value}}return e}else{const e=this.settings[t];if(!e)return;if(u(e))return e.getDefaultValues();const i=e;return i.default!==void 0?i.default:i.value}}draw(){const t=document.createElement("div");t.className="setting-group",t.id=`setting-group-${this.id}`,k.hiddenElements.add(t),this.isMain&&t.classList.add("main-group"),this.custom&&t.classList.add("custom_class"),x(t,this.nestingLevel);const e=document.createElement("div");e.className="setting-group-title",this.isCollapsed&&e.classList.add("collapsed-view"),e.setAttribute("role","button"),e.setAttribute("aria-expanded",(!this.isCollapsed).toString()),e.setAttribute("tabindex","0");const i=document.createElement("div");i.className="title-section";const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");n.className="actions-section";const a=document.createElement("span");a.className="setting-group-arrow",a.innerHTML=`
73
+ `,o.addEventListener("mouseenter",()=>{o.style.backgroundColor="#f9fafb",o.style.borderColor="#9ca3af"}),o.addEventListener("mouseleave",()=>{o.style.backgroundColor="white",o.style.borderColor="#d1d5db"}),l.addEventListener("mouseenter",()=>{l.style.backgroundColor="#dc2626"}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="#ef4444"});const r=()=>{e.style.opacity="0",i.style.transform="scale(0.95)",setTimeout(()=>{e.parentNode&&e.parentNode.removeChild(e)},200)};o.addEventListener("click",()=>{r(),t(!1)}),l.addEventListener("click",()=>{r(),t(!0)}),e.addEventListener("click",d=>{d.target===e&&(r(),t(!1))});const h=d=>{d.key==="Escape"&&(r(),t(!1),document.removeEventListener("keydown",h))};document.addEventListener("keydown",h),a.appendChild(o),a.appendChild(l),i.appendChild(s),i.appendChild(n),i.appendChild(a),e.appendChild(i),document.body.appendChild(e),requestAnimationFrame(()=>{e.style.opacity="1",i.style.transform="scale(1)"}),setTimeout(()=>l.focus(),100)})}getNextIndexFromPrefix(t){const e=Object.keys(this.settings).filter(i=>i.startsWith(t)).map(i=>{const s=Number(i.slice(t.length));return Number.isFinite(s)?s:-1}).filter(i=>i>=0);return e.length?Math.max(...e)+1:0}calculateChanges(t,e){const i={};return new Set([...Object.keys(t),...Object.keys(e)]).forEach(n=>{const a=t[n],o=e[n];JSON.stringify(a)!==JSON.stringify(o)&&(i[n]={from:a,to:o})}),i}getValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];p(s)?e[i]=s.getValues():e[i]=s.value}return e}else{const e=this.settings[t];return e?p(e)?e.getValues():e.value:void 0}}getValuesForJson(t){if(t===void 0){if(this.includeGetJson===!1)return null;const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(p(s))e[i]=s.getValuesForJson();else{const n=s;n.includeGetJson===!1?e[i]=null:e[i]=n.value}}return e}else{const e=this.settings[t];if(!e)return;if(p(e))return e.includeGetJson===!1?null:e.getValuesForJson();{const i=e;return i.includeGetJson===!1?null:i.value}}}getDefaultValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(p(s))e[i]=s.getDefaultValues();else{const n=s;e[i]=n.default!==void 0?n.default:n.value}}return e}else{const e=this.settings[t];if(!e)return;if(p(e))return e.getDefaultValues();const i=e;return i.default!==void 0?i.default:i.value}}draw(){const t=document.createElement("div");t.className="setting-group",t.id=`setting-group-${this.id}`,k.hiddenElements.add(t),this.isMain&&t.classList.add("main-group"),this.custom&&t.classList.add("custom_class"),x(t,this.nestingLevel);const e=document.createElement("div");e.className="setting-group-title",this.isCollapsed&&e.classList.add("collapsed-view"),e.setAttribute("role","button"),e.setAttribute("aria-expanded",(!this.isCollapsed).toString()),e.setAttribute("tabindex","0");const i=document.createElement("div");i.className="title-section";const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");n.className="actions-section";const a=document.createElement("span");a.className="setting-group-arrow",a.innerHTML=`
74
74
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
75
75
  <path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
76
76
  </svg>
77
- `,this.isCollapsed&&a.classList.add("rotated"),n.appendChild(a);const o=document.createElement("div");o.className="setting-group-content",this.isCollapsed&&(o.classList.add("collapsed"),e.classList.add("collapsed-view"),a.classList.add("rotated"),t.classList.add("collapsed")),this.isMain&&o.classList.add("main-content");const l=()=>{this.isCollapsed=!this.isCollapsed,o.classList.toggle("collapsed"),e.classList.toggle("collapsed-view"),a.classList.toggle("rotated"),t.classList.toggle("collapsed",this.isCollapsed),e.setAttribute("aria-expanded",(!this.isCollapsed).toString())};if(e.onclick=l,e.onkeydown=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),l())},Object.keys(this.settings).length>0){for(const h in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,h)){const d=this.settings[h];u(d)&&typeof d.setNestingLevel=="function"&&d.setNestingLevel(this.nestingLevel+1);const p=d.draw();u(d)&&d.deleteItemCfg&&this.addDeleteButtonToElement(p,h,d),o.appendChild(p)}}else{const h=document.createElement("div");h.className="setting-group-empty",h.textContent="No settings in this group",o.appendChild(h)}if(this.addItemCfg){const h=document.createElement("button");h.type="button",h.className="sg-add-button-bottom",h.style.marginTop="8px";const d=`
77
+ `,this.isCollapsed&&a.classList.add("rotated"),n.appendChild(a);const o=document.createElement("div");o.className="setting-group-content",this.isCollapsed&&(o.classList.add("collapsed"),e.classList.add("collapsed-view"),a.classList.add("rotated"),t.classList.add("collapsed")),this.isMain&&o.classList.add("main-content");const l=()=>{this.isCollapsed=!this.isCollapsed,o.classList.toggle("collapsed"),e.classList.toggle("collapsed-view"),a.classList.toggle("rotated"),t.classList.toggle("collapsed",this.isCollapsed),e.setAttribute("aria-expanded",(!this.isCollapsed).toString())};if(e.onclick=l,e.onkeydown=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),l())},Object.keys(this.settings).length>0){for(const h in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,h)){const d=this.settings[h];p(d)&&typeof d.setNestingLevel=="function"&&d.setNestingLevel(this.nestingLevel+1);const u=d.draw();p(d)&&d.deleteItemCfg&&this.addDeleteButtonToElement(u,h,d),o.appendChild(u)}}else{const h=document.createElement("div");h.className="setting-group-empty",h.textContent="No settings in this group",o.appendChild(h)}if(this.addItemCfg){const h=document.createElement("button");h.type="button",h.className="sg-add-button-bottom",h.style.marginTop="8px";const d=`
78
78
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none"
79
79
  xmlns="http://www.w3.org/2000/svg">
80
80
  <path d="M8 3.333v9.334M3.333 8h9.334" stroke="currentColor"
81
81
  stroke-width="1.5" stroke-linecap="round"/>
82
- </svg>`;h.innerHTML=`${d}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel??"Add"}</span>`,h.addEventListener("click",p=>{p.stopPropagation(),p.preventDefault();const M=this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),$=this.addItemCfg.createItem(M),D=`${this.addItemCfg.keyPrefix}${M}`;this.addSetting(D,$)}),o.appendChild(h)}return e.appendChild(i),e.appendChild(n),t.appendChild(e),t.appendChild(o),this.elementRef=t,N.trackElement(t),setTimeout(()=>{this.updateNestingStyles()},0),this.pendingBlurHandler&&(this.pendingBlurHandler=null),t}collapse(){if(!this.elementRef||this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!0,t.classList.add("collapsed"),e.classList.add("rotated"),i.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!1,t.classList.remove("collapsed"),e.classList.remove("rotated"),i.setAttribute("aria-expanded","true"))}getJson(){return JSON.stringify(this.getValuesForJson(),null,2)}setJson(t){try{const e=JSON.parse(t);let i=e;const s=Object.keys(this.settings),n=Object.keys(e);if(!s.some(o=>n.includes(o))&&n.length===1){const o=n[0];i=e[o]}this.setValue(i)}catch(e){throw console.error("Invalid JSON provided to setJson:",e),new Error("Invalid JSON format")}}};k.hiddenElements=new Set;let v=k;function j(c){return new I(c)}class I extends v{constructor(t){super(t);const e=Object.keys(this.settings)[0];this.activeTabId=e||""}getActiveTabId(){return this.activeTabId}switchToTab(t){this.settings[t]&&(this.activeTabId=t,this.updateTabUI())}updateTabUI(){if(!this.tabsContainer||!this.contentContainers)return;this.tabsContainer.querySelectorAll(".tab-button").forEach(e=>{e.getAttribute("data-tab-id")===this.activeTabId?e.classList.add("active"):e.classList.remove("active")}),Object.entries(this.contentContainers).forEach(([e,i])=>{e===this.activeTabId?i.classList.add("active"):i.classList.remove("active")})}draw(){const t=super.draw();t.classList.add("tabs-settings-container");const e=t.querySelector(".setting-group-content");if(!e)return t;e.innerHTML="";const i=document.createElement("div");i.className="tabs-title";const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");n.className="tabs-header",this.tabsContainer=n;const a=document.createElement("div");if(a.className="tab-content",this.contentContainers={},Object.keys(this.settings).forEach((o,l)=>{const r=document.createElement("button");r.className="tab-button",r.type="button",r.setAttribute("data-tab-id",o),r.textContent=o,r.addEventListener("click",()=>this.switchToTab(o)),n.appendChild(r);const h=document.createElement("div");h.className="tab-panel",this.contentContainers[o]=h;const d=this.settings[o];d&&(u(d)&&typeof d.setNestingLevel=="function"&&d.setNestingLevel(this.getNestingLevel()+1),h.appendChild(d.draw())),a.appendChild(h),l===0&&!this.activeTabId&&(this.activeTabId=o)}),e.appendChild(i),e.appendChild(n),e.appendChild(a),!this.activeTabId){const o=Object.keys(this.settings)[0];this.activeTabId=o||""}return this.updateTabUI(),t}}function H(c){return new v(c)}function J(c){return c}class T extends g{constructor(t={}){super(t),this.inputType="text",t.onChange&&this.setOnChange(t.onChange)}draw(){const t=e=>{this.props.maxLength!==void 0&&(e.maxLength=this.props.maxLength),this.props.className&&e.classList.add(this.props.className)};return this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,placeholder:this.props.placeholder,icon:this.props.icon,inputClassName:"string-setting-input "+(this.props.inputClassName||""),wrapperClassName:"string-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:t})}}const U="<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' stroke-linecap='round' stroke-linejoin='round'/></svg>";class m extends T{constructor(t){super({...t,icon:t.icon||U,title:t.title||"Color",default:t.default?m.normalizeColorValue(t.default):"#000000"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.detectChange=t.detectChange}static normalizeColorValue(t){return t.startsWith("#")?m.normalizeHexValue(t):t.includes(",")?m.rgbToHexStatic(t):m.normalizeHexValue(t)}static normalizeHexValue(t){return t=t.replace("#",""),t.length===3&&(t=t.split("").map(e=>e+e).join("")),t.length!==6?(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000"):/^[0-9A-Fa-f]{6}$/.test(t)?`#${t.toLowerCase()}`:(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000")}static rgbToHexStatic(t){const e=t.split(",").map(h=>parseInt(h.trim()));if(e.length!==3||e.some(isNaN))return console.warn(`Invalid RGB value "${t}", using default "#000000"`),"#000000";const[i,s,n]=e,a=Math.max(0,Math.min(255,i)),o=Math.max(0,Math.min(255,s)),l=Math.max(0,Math.min(255,n)),r=h=>{const d=h.toString(16);return d.length===1?"0"+d:d};return`#${r(a)}${r(o)}${r(l)}`}setValue(t){if(t===void 0){this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000");return}if(typeof t=="string"){const e=m.normalizeColorValue(t);this.value=e,this.colorInputEl&&(this.colorInputEl.value=e),this.textInputEl&&(this.textInputEl.value=e),this.onChange&&this.onChange(e),this.props.detectChange&&this.props.detectChange(e)}else this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000")}hexToRgb(t){t=t.replace("#","");const e=parseInt(t.substring(0,2),16),i=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return`${e}, ${i}, ${s}`}draw(){const t=document.createElement("div");if(t.className="color-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const l=document.createElement("div");if(l.className="icon-container",this.props.icon){const r=document.createElement("span");r.className="input-icon",r.innerHTML=this.props.icon,l.appendChild(r)}if(this.props.title){const r=document.createElement("span");r.className="input-label",r.textContent=this.props.title,l.appendChild(r)}t.appendChild(l)}const e=document.createElement("div");e.className="color-input-wrapper";const i=l=>{const r=l.value.trim();if(!r)return e.classList.remove("error"),!0;const d=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r);return d?e.classList.remove("error"):e.classList.add("error"),d},s=document.createElement("input");s.type="color",s.className="color-picker",s.value=this.value||"#000000",s.setAttribute("aria-label","Choose color"),s.setAttribute("title","Click to open color picker"),this.getDataPropsPath()&&s.setAttribute("data-test-id",this.getDataPropsPath()),this.colorInputEl=s;const n=document.createElement("div");n.className="color-preview";const a=this.value||"#000000";n.style.backgroundColor=a;const o=document.createElement("input");return o.type="text",o.className="color-text-input",o.value=this.value||"",o.placeholder="#000000",o.setAttribute("pattern","#[0-9A-Fa-f]{6}"),o.setAttribute("title","Enter a hex color value (e.g., #ff0000)"),o.setAttribute("aria-label","Hex color value"),o.setAttribute("maxlength","7"),this.getDataPropsPath()&&o.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.textInputEl=o,this.textInputEl.addEventListener("input",l=>{var h,d;let r=l.target.value.trim();if(this.textInputEl&&i(this.textInputEl)){const p=m.normalizeColorValue(r);this.value=p,(h=this.onChange)==null||h.call(this,p),(d=this.detectChange)==null||d.call(this,p),this.colorInputEl&&(this.colorInputEl.value=p),n.style.backgroundColor=p}}),this.colorInputEl.addEventListener("input",l=>{var d,p;const r=l.target.value,h=m.normalizeColorValue(r);this.value=h,(d=this.onChange)==null||d.call(this,h),(p=this.detectChange)==null||p.call(this,h),this.textInputEl&&(this.textInputEl.value=h),n.style.backgroundColor=h,e.classList.remove("error")}),this.colorInputEl.addEventListener("change",l=>{var d,p;const r=l.target.value,h=m.normalizeColorValue(r);this.value=h,(d=this.onChange)==null||d.call(this,h),(p=this.detectChange)==null||p.call(this,h),this.textInputEl&&(this.textInputEl.value=h),n.style.backgroundColor=h}),e.appendChild(s),e.appendChild(n),e.appendChild(o),t.appendChild(e),this.element=t,t}getElement(){return this.element}getNormalizedValue(){return this.value?m.normalizeColorValue(this.value):"#000000"}isValidHex(){return this.value?/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(this.value):!1}toRgb(){return this.isValidHex()?this.hexToRgb(this.value):"0, 0, 0"}}const q=`
82
+ </svg>`;h.innerHTML=`${d}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel??"Add"}</span>`,h.addEventListener("click",u=>{u.stopPropagation(),u.preventDefault();const M=this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),D=this.addItemCfg.createItem(M),$=`${this.addItemCfg.keyPrefix}${M}`;this.addSetting($,D)}),o.appendChild(h)}return e.appendChild(i),e.appendChild(n),t.appendChild(e),t.appendChild(o),this.elementRef=t,N.trackElement(t),setTimeout(()=>{this.updateNestingStyles()},0),this.pendingBlurHandler&&(this.pendingBlurHandler=null),t}collapse(){if(!this.elementRef||this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!0,t.classList.add("collapsed"),e.classList.add("rotated"),i.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!1,t.classList.remove("collapsed"),e.classList.remove("rotated"),i.setAttribute("aria-expanded","true"))}getJson(){return JSON.stringify(this.getValuesForJson(),null,2)}setJson(t){try{const e=JSON.parse(t);let i=e;const s=Object.keys(this.settings),n=Object.keys(e);if(!s.some(o=>n.includes(o))&&n.length===1){const o=n[0];i=e[o]}this.setValue(i)}catch(e){throw console.error("Invalid JSON provided to setJson:",e),new Error("Invalid JSON format")}}};k.hiddenElements=new Set;let v=k;function j(c){return new I(c)}class I extends v{constructor(t){super(t);const e=Object.keys(this.settings)[0];this.activeTabId=e||""}getActiveTabId(){return this.activeTabId}switchToTab(t){this.settings[t]&&(this.activeTabId=t,this.updateTabUI())}updateTabUI(){if(!this.tabsContainer||!this.contentContainers)return;this.tabsContainer.querySelectorAll(".tab-button").forEach(e=>{e.getAttribute("data-tab-id")===this.activeTabId?e.classList.add("active"):e.classList.remove("active")}),Object.entries(this.contentContainers).forEach(([e,i])=>{e===this.activeTabId?i.classList.add("active"):i.classList.remove("active")})}draw(){const t=super.draw();t.classList.add("tabs-settings-container");const e=t.querySelector(".setting-group-content");if(!e)return t;e.innerHTML="";const i=document.createElement("div");i.className="tabs-title";const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");n.className="tabs-header",this.tabsContainer=n;const a=document.createElement("div");if(a.className="tab-content",this.contentContainers={},Object.keys(this.settings).forEach((o,l)=>{const r=document.createElement("button");r.className="tab-button",r.type="button",r.setAttribute("data-tab-id",o),r.textContent=o,r.addEventListener("click",()=>this.switchToTab(o)),n.appendChild(r);const h=document.createElement("div");h.className="tab-panel",this.contentContainers[o]=h;const d=this.settings[o];d&&(p(d)&&typeof d.setNestingLevel=="function"&&d.setNestingLevel(this.getNestingLevel()+1),h.appendChild(d.draw())),a.appendChild(h),l===0&&!this.activeTabId&&(this.activeTabId=o)}),e.appendChild(i),e.appendChild(n),e.appendChild(a),!this.activeTabId){const o=Object.keys(this.settings)[0];this.activeTabId=o||""}return this.updateTabUI(),t}}function H(c){return new v(c)}function J(c){return c}class T extends g{constructor(t={}){super(t),this.inputType="text",t.onChange&&this.setOnChange(t.onChange)}draw(){const t=e=>{this.props.maxLength!==void 0&&(e.maxLength=this.props.maxLength),this.props.className&&e.classList.add(this.props.className)};return this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,placeholder:this.props.placeholder,icon:this.props.icon,inputClassName:"string-setting-input "+(this.props.inputClassName||""),wrapperClassName:"string-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:t})}}const U="<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' stroke-linecap='round' stroke-linejoin='round'/></svg>";class m extends T{constructor(t){super({...t,icon:t.icon||U,title:t.title||"Color",default:t.default?m.normalizeColorValue(t.default):"#000000"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.detectChange=t.detectChange}static normalizeColorValue(t){return t.startsWith("#")?m.normalizeHexValue(t):t.includes(",")?m.rgbToHexStatic(t):m.normalizeHexValue(t)}static normalizeHexValue(t){return t=t.replace("#",""),t.length===3&&(t=t.split("").map(e=>e+e).join("")),t.length!==6?(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000"):/^[0-9A-Fa-f]{6}$/.test(t)?`#${t.toLowerCase()}`:(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000")}static rgbToHexStatic(t){const e=t.split(",").map(h=>parseInt(h.trim()));if(e.length!==3||e.some(isNaN))return console.warn(`Invalid RGB value "${t}", using default "#000000"`),"#000000";const[i,s,n]=e,a=Math.max(0,Math.min(255,i)),o=Math.max(0,Math.min(255,s)),l=Math.max(0,Math.min(255,n)),r=h=>{const d=h.toString(16);return d.length===1?"0"+d:d};return`#${r(a)}${r(o)}${r(l)}`}setValue(t){if(t===void 0){this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000");return}if(typeof t=="string"){const e=m.normalizeColorValue(t);this.value=e,this.colorInputEl&&(this.colorInputEl.value=e),this.textInputEl&&(this.textInputEl.value=e),this.onChange&&this.onChange(e),this.props.detectChange&&this.props.detectChange(e)}else this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000")}hexToRgb(t){t=t.replace("#","");const e=parseInt(t.substring(0,2),16),i=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return`${e}, ${i}, ${s}`}draw(){const t=document.createElement("div");if(t.className="color-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const l=document.createElement("div");if(l.className="icon-container",this.props.icon){const r=document.createElement("span");r.className="input-icon",r.innerHTML=this.props.icon,l.appendChild(r)}if(this.props.title){const r=document.createElement("span");r.className="input-label",r.textContent=this.props.title,l.appendChild(r)}t.appendChild(l)}const e=document.createElement("div");e.className="color-input-wrapper";const i=l=>{const r=l.value.trim();if(!r)return e.classList.remove("error"),!0;const d=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r);return d?e.classList.remove("error"):e.classList.add("error"),d},s=document.createElement("input");s.type="color",s.className="color-picker",s.value=this.value||"#000000",s.setAttribute("aria-label","Choose color"),s.setAttribute("title","Click to open color picker"),this.getDataPropsPath()&&s.setAttribute("data-test-id",this.getDataPropsPath()),this.colorInputEl=s;const n=document.createElement("div");n.className="color-preview";const a=this.value||"#000000";n.style.backgroundColor=a;const o=document.createElement("input");return o.type="text",o.className="color-text-input",o.value=this.value||"",o.placeholder="#000000",o.setAttribute("pattern","#[0-9A-Fa-f]{6}"),o.setAttribute("title","Enter a hex color value (e.g., #ff0000)"),o.setAttribute("aria-label","Hex color value"),o.setAttribute("maxlength","7"),this.getDataPropsPath()&&o.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.textInputEl=o,this.textInputEl.addEventListener("input",l=>{var h,d;let r=l.target.value.trim();if(this.textInputEl&&i(this.textInputEl)){const u=m.normalizeColorValue(r);this.value=u,(h=this.onChange)==null||h.call(this,u),(d=this.detectChange)==null||d.call(this,u),this.colorInputEl&&(this.colorInputEl.value=u),n.style.backgroundColor=u}}),this.colorInputEl.addEventListener("input",l=>{var d,u;const r=l.target.value,h=m.normalizeColorValue(r);this.value=h,(d=this.onChange)==null||d.call(this,h),(u=this.detectChange)==null||u.call(this,h),this.textInputEl&&(this.textInputEl.value=h),n.style.backgroundColor=h,e.classList.remove("error")}),this.colorInputEl.addEventListener("change",l=>{var d,u;const r=l.target.value,h=m.normalizeColorValue(r);this.value=h,(d=this.onChange)==null||d.call(this,h),(u=this.detectChange)==null||u.call(this,h),this.textInputEl&&(this.textInputEl.value=h),n.style.backgroundColor=h}),e.appendChild(s),e.appendChild(n),e.appendChild(o),t.appendChild(e),this.element=t,t}getElement(){return this.element}getNormalizedValue(){return this.value?m.normalizeColorValue(this.value):"#000000"}isValidHex(){return this.value?/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(this.value):!1}toRgb(){return this.isValidHex()?this.hexToRgb(this.value):"0, 0, 0"}}const q=`
83
83
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
84
84
  <path d="M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
85
85
  <path d="M9 17C13.4183 17 17 13.4183 17 9C17 4.58172 13.4183 1 9 1C4.58172 1 1 4.58172 1 9C1 13.4183 4.58172 17 9 17Z" stroke="#667085" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5"/>
@@ -172,21 +172,21 @@
172
172
  <svg xmlns="http://www.w3.org/2000/svg" class="svg-select-api" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down">
173
173
  <polyline points="6 9 12 15 18 9"></polyline>
174
174
  </svg>
175
- `;class ct extends g{constructor(t={}){if(super(t),this.inputType="select",this._options=[],this.isOpen=!1,this.selectedOptionIndex=null,this.optionsListEl=null,this.svgContainer=null,this.buttonEl=null,this.isLoading=!1,this.container=null,this.hasInitializedOptions=!1,this.selectedOptionIndex=null,t.default!==void 0&&(this.value=t.default),this.initializeOptions(t),!t.getOptionsAsync&&this.value!==void 0){const e=this._options.findIndex(i=>JSON.stringify(i.value)===JSON.stringify(this.value));e!==-1&&(this.selectedOptionIndex=e)}t.onChange&&this.setOnChange(t.onChange),t.detectChange&&(this.detectChangeCallback=t.detectChange)}initializeOptions(t){this.hasInitializedOptions&&!t.getOptionsAsync||(this._options=[],t.options&&(this._options=[...t.options]),t.getOptions&&this._options.push(...t.getOptions()),t.getOptionsAsync?this.isLoading=!0:this.hasInitializedOptions=!0)}createOption(t,e){const i=document.createElement("li");i.classList.add("select-api-option"),i.textContent=t.name,i.dataset.index=String(e);const s=document.createElement("input");return s.type="radio",s.classList.add("select-api-radio"),s.name="select-api-radio-group",i.appendChild(s),this.selectedOptionIndex===e&&(s.checked=!0),i}draw(){const t=document.createElement("div");t.classList.add("select-api-container"),this.container=t;const e=document.createElement("div");if(e.classList.add("select-api-button"),this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath()),this.props.title){e.classList.add("has-label");const n=document.createElement("div");n.className="select-label",n.textContent=this.props.title,e.appendChild(n);const a=document.createElement("span");if(a.className="select-value",this.isLoading)a.textContent=this.props.loadingText||"Loading options...";else{const o=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,l=o&&typeof o.name=="string"?o.name:"Select an option";a.textContent=l}e.appendChild(a)}else{const n=document.createElement("span");if(this.isLoading)n.textContent=this.props.loadingText||"Loading options...";else{const a=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,o=a&&typeof a.name=="string"?a.name:"Select an option";n.textContent=o}e.appendChild(n)}e.onclick=()=>{var n,a;this.isLoading||(this.isOpen=!this.isOpen,(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(a=this.svgContainer)==null||a.classList.toggle("open",this.isOpen))},t.appendChild(e),this.buttonEl=e;const i=document.createElement("ul");i.classList.add("select-api-options"),this._options.forEach((n,a)=>{const o=this.createOption(n,a);o.onclick=l=>this.selectApiOption(l,a,e),i.appendChild(o)}),t.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=ht,t.appendChild(s),s.onclick=()=>{var n,a;this.isLoading||(this.isOpen=!this.isOpen,(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(a=this.svgContainer)==null||a.classList.toggle("open",this.isOpen))},this.optionsListEl=i,this.svgContainer=s,this.props.getOptionsAsync&&!this.hasInitializedOptions?(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{const a=new Set(this._options.map(l=>JSON.stringify(l.value))),o=n.filter(l=>!a.has(JSON.stringify(l.value)));if(this._options.push(...o),this.isLoading=!1,this.hasInitializedOptions=!0,this.value!==void 0){const l=this._options.findIndex(r=>JSON.stringify(r.value)===JSON.stringify(this.value));this.selectedOptionIndex=l!==-1?l:null}else this.selectedOptionIndex=null;this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText(this.props.errorText||"Error: Could not load options",!0)})):this.props.getOptionsAsync&&this._options.length<=1&&(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{const a=new Set(this._options.map(l=>JSON.stringify(l.value))),o=n.filter(l=>!a.has(JSON.stringify(l.value)));if(this._options.push(...o),this.isLoading=!1,this.value!==void 0){const l=this._options.findIndex(r=>JSON.stringify(r.value)===JSON.stringify(this.value));this.selectedOptionIndex=l!==-1?l:null}else this.selectedOptionIndex=null;this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText(this.props.errorText||"Error: Could not load options",!0)})),t}getJson(t=!0){return JSON.stringify(t?{}:{value:this.value},null,2)}selectApiOption(t,e,i){var l,r,h,d;const s=t.target,n=s.querySelector(".select-api-radio")||((l=s.closest(".select-api-option"))==null?void 0:l.querySelector(".select-api-radio"));n&&(n.checked=!0),this.selectedOptionIndex=e;const a=this._options[e].value;this.value=a;const o=i.querySelector(".select-value");if(o)o.textContent=this._options[e].name;else{const p=i.firstChild;p&&p.tagName==="SPAN"&&(p.textContent=this._options[e].name)}this.isOpen=!1,(r=this.optionsListEl)==null||r.classList.remove("open"),(h=this.svgContainer)==null||h.classList.remove("open"),(d=this.onChange)==null||d.call(this,a),this.detectChangeCallback&&this.detectChangeCallback(a)}updateOptionsList(){!this.optionsListEl||!this.buttonEl||(this.optionsListEl.innerHTML="",this._options.forEach((t,e)=>{var s;const i=this.createOption(t,e);i.onclick=n=>{this.buttonEl&&this.selectApiOption(n,e,this.buttonEl)},(s=this.optionsListEl)==null||s.appendChild(i)}))}updateButtonText(t,e=!1){if(!this.buttonEl)return;const i=this.buttonEl.querySelector(".select-value")||this.buttonEl.firstChild;if(i)if(e)i.textContent=t||"Error",this.buttonEl.classList.add("error"),this.buttonEl.setAttribute("disabled","true"),this.optionsListEl&&this.optionsListEl.classList.remove("open"),this.svgContainer&&(this.svgContainer.style.display="none");else if(this.isLoading)i.textContent=this.props.loadingText||"Loading options...",this.buttonEl.classList.remove("error"),this.buttonEl.removeAttribute("disabled"),this.svgContainer&&(this.svgContainer.style.display="");else{const s=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,n=s&&typeof s.name=="string"?s.name:"Select an option";i.textContent=t||n,this.buttonEl.classList.remove("error"),this.buttonEl.removeAttribute("disabled"),this.svgContainer&&(this.svgContainer.style.display="")}}setDetectChange(t){this.detectChangeCallback=t}setValue(t){this.value=t,this.selectedOptionIndex=this._options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t)),this.updateButtonText()}}class dt extends g{constructor(t){var e,i;super(t),this.inputType="text",this.value=t.default??((i=(e=t.options)==null?void 0:e[0])==null?void 0:i.value)??"",this.detectChangeCallback=t.detectChange}draw(){var a,o;const t=document.createElement("div");t.className="toggle-setting-container",this.props.icon&&t.classList.add("toggle-with-icon");const e=document.createElement("div");if(e.className="toggle-label",this.props.icon){const l=document.createElement("span");l.className="toggle-icon",l.innerHTML=this.props.icon,e.appendChild(l)}if(this.props.title){const l=document.createElement("span");l.textContent=this.props.title,e.appendChild(l)}t.appendChild(e);const i=document.createElement("label");i.className="toggle-switch";const s=document.createElement("input");s.type="checkbox",s.checked=((o=(a=this.props.options)==null?void 0:a.find(l=>l.value===this.value))==null?void 0:o.status)??!1,this.getDataPropsPath()&&s.setAttribute("data-test-id",this.getDataPropsPath()),s.addEventListener("change",()=>{var r,h;const l=((h=(r=this.props.options)==null?void 0:r.find(d=>d.status===s.checked))==null?void 0:h.value)??"";this.value=l,this.onChange&&this.onChange(this.value),this.detectChangeCallback&&this.detectChangeCallback(this.value)});const n=document.createElement("span");if(n.className="toggle-slider",this.props.activeColor||this.props.inactiveColor){const l=document.createElement("style"),r=this.props.activeColor||"#4CAF50",h=this.props.inactiveColor||"#ccc";l.textContent=`
175
+ `;class ct extends g{constructor(t={}){if(super(t),this.inputType="select",this._options=[],this.isOpen=!1,this.selectedOptionIndex=null,this.optionsListEl=null,this.svgContainer=null,this.buttonEl=null,this.isLoading=!1,this.container=null,this.hasInitializedOptions=!1,this.selectedOptionIndex=null,t.default!==void 0&&(this.value=t.default),this.initializeOptions(t),!t.getOptionsAsync&&this.value!==void 0){const e=this._options.findIndex(i=>JSON.stringify(i.value)===JSON.stringify(this.value));e!==-1&&(this.selectedOptionIndex=e)}t.onChange&&this.setOnChange(t.onChange),t.detectChange&&(this.detectChangeCallback=t.detectChange)}initializeOptions(t){this.hasInitializedOptions&&!t.getOptionsAsync||(this._options=[],t.options&&(this._options=[...t.options]),t.getOptions&&this._options.push(...t.getOptions()),t.getOptionsAsync?this.isLoading=!0:this.hasInitializedOptions=!0)}createOption(t,e){const i=document.createElement("li");i.classList.add("select-api-option"),i.textContent=t.name,i.dataset.index=String(e);const s=document.createElement("input");return s.type="radio",s.classList.add("select-api-radio"),s.name="select-api-radio-group",i.appendChild(s),this.selectedOptionIndex===e&&(s.checked=!0),i}draw(){const t=document.createElement("div");t.classList.add("select-api-container"),this.container=t;const e=document.createElement("div");if(e.classList.add("select-api-button"),this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath()),this.props.title){e.classList.add("has-label");const n=document.createElement("div");n.className="select-label",n.textContent=this.props.title,e.appendChild(n);const a=document.createElement("span");if(a.className="select-value",this.isLoading)a.textContent=this.props.loadingText||"Loading options...";else{const o=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,l=o&&typeof o.name=="string"?o.name:"Select an option";a.textContent=l}e.appendChild(a)}else{const n=document.createElement("span");if(this.isLoading)n.textContent=this.props.loadingText||"Loading options...";else{const a=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,o=a&&typeof a.name=="string"?a.name:"Select an option";n.textContent=o}e.appendChild(n)}e.onclick=()=>{var n,a;this.isLoading||(this.isOpen=!this.isOpen,(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(a=this.svgContainer)==null||a.classList.toggle("open",this.isOpen))},t.appendChild(e),this.buttonEl=e;const i=document.createElement("ul");i.classList.add("select-api-options"),this._options.forEach((n,a)=>{const o=this.createOption(n,a);o.onclick=l=>this.selectApiOption(l,a,e),i.appendChild(o)}),t.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=ht,t.appendChild(s),s.onclick=()=>{var n,a;this.isLoading||(this.isOpen=!this.isOpen,(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(a=this.svgContainer)==null||a.classList.toggle("open",this.isOpen))},this.optionsListEl=i,this.svgContainer=s,this.props.getOptionsAsync&&!this.hasInitializedOptions?(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{const a=new Set(this._options.map(l=>JSON.stringify(l.value))),o=n.filter(l=>!a.has(JSON.stringify(l.value)));if(this._options.push(...o),this.isLoading=!1,this.hasInitializedOptions=!0,this.value!==void 0){const l=this._options.findIndex(r=>JSON.stringify(r.value)===JSON.stringify(this.value));this.selectedOptionIndex=l!==-1?l:null}else this.selectedOptionIndex=null;this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText(this.props.errorText||"Error: Could not load options",!0)})):this.props.getOptionsAsync&&this._options.length<=1&&(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{const a=new Set(this._options.map(l=>JSON.stringify(l.value))),o=n.filter(l=>!a.has(JSON.stringify(l.value)));if(this._options.push(...o),this.isLoading=!1,this.value!==void 0){const l=this._options.findIndex(r=>JSON.stringify(r.value)===JSON.stringify(this.value));this.selectedOptionIndex=l!==-1?l:null}else this.selectedOptionIndex=null;this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText(this.props.errorText||"Error: Could not load options",!0)})),t}getJson(t=!0){return JSON.stringify(t?{}:{value:this.value},null,2)}selectApiOption(t,e,i){var l,r,h,d;const s=t.target,n=s.querySelector(".select-api-radio")||((l=s.closest(".select-api-option"))==null?void 0:l.querySelector(".select-api-radio"));n&&(n.checked=!0),this.selectedOptionIndex=e;const a=this._options[e].value;this.value=a;const o=i.querySelector(".select-value");if(o)o.textContent=this._options[e].name;else{const u=i.firstChild;u&&u.tagName==="SPAN"&&(u.textContent=this._options[e].name)}this.isOpen=!1,(r=this.optionsListEl)==null||r.classList.remove("open"),(h=this.svgContainer)==null||h.classList.remove("open"),(d=this.onChange)==null||d.call(this,a),this.detectChangeCallback&&this.detectChangeCallback(a)}updateOptionsList(){!this.optionsListEl||!this.buttonEl||(this.optionsListEl.innerHTML="",this._options.forEach((t,e)=>{var s;const i=this.createOption(t,e);i.onclick=n=>{this.buttonEl&&this.selectApiOption(n,e,this.buttonEl)},(s=this.optionsListEl)==null||s.appendChild(i)}))}updateButtonText(t,e=!1){if(!this.buttonEl)return;const i=this.buttonEl.querySelector(".select-value")||this.buttonEl.firstChild;if(i)if(e)i.textContent=t||"Error",this.buttonEl.classList.add("error"),this.buttonEl.setAttribute("disabled","true"),this.optionsListEl&&this.optionsListEl.classList.remove("open"),this.svgContainer&&(this.svgContainer.style.display="none");else if(this.isLoading)i.textContent=this.props.loadingText||"Loading options...",this.buttonEl.classList.remove("error"),this.buttonEl.removeAttribute("disabled"),this.svgContainer&&(this.svgContainer.style.display="");else{const s=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,n=s&&typeof s.name=="string"?s.name:"Select an option";i.textContent=t||n,this.buttonEl.classList.remove("error"),this.buttonEl.removeAttribute("disabled"),this.svgContainer&&(this.svgContainer.style.display="")}}setDetectChange(t){this.detectChangeCallback=t}setValue(t){this.value=t,this.selectedOptionIndex=this._options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t)),this.updateButtonText()}}class dt extends g{constructor(t){var e,i;super(t),this.inputType="text",this.value=t.default??((i=(e=t.options)==null?void 0:e[0])==null?void 0:i.value)??"",this.detectChangeCallback=t.detectChange}draw(){var a,o;const t=document.createElement("div");t.className="toggle-setting-container",this.props.icon&&t.classList.add("toggle-with-icon");const e=document.createElement("div");if(e.className="toggle-label",this.props.icon){const l=document.createElement("span");l.className="toggle-icon",l.innerHTML=this.props.icon,e.appendChild(l)}if(this.props.title){const l=document.createElement("span");l.textContent=this.props.title,e.appendChild(l)}t.appendChild(e);const i=document.createElement("label");i.className="toggle-switch";const s=document.createElement("input");s.type="checkbox",s.checked=((o=(a=this.props.options)==null?void 0:a.find(l=>l.value===this.value))==null?void 0:o.status)??!1,this.getDataPropsPath()&&s.setAttribute("data-test-id",this.getDataPropsPath()),s.addEventListener("change",()=>{var r,h;const l=((h=(r=this.props.options)==null?void 0:r.find(d=>d.status===s.checked))==null?void 0:h.value)??"";this.value=l,this.onChange&&this.onChange(this.value),this.detectChangeCallback&&this.detectChangeCallback(this.value)});const n=document.createElement("span");if(n.className="toggle-slider",this.props.activeColor||this.props.inactiveColor){const l=document.createElement("style"),r=this.props.activeColor||"#4CAF50",h=this.props.inactiveColor||"#ccc";l.textContent=`
176
176
  .toggle-switch input:checked + .toggle-slider {
177
177
  background-color: ${r};
178
178
  }
179
179
  .toggle-switch .toggle-slider {
180
180
  background-color: ${h};
181
181
  }
182
- `,document.head.appendChild(l)}return i.appendChild(s),i.appendChild(n),t.appendChild(i),t}setDetectChange(t){this.detectChangeCallback=t}}const pt=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
182
+ `,document.head.appendChild(l)}return i.appendChild(s),i.appendChild(n),t.appendChild(i),t}setDetectChange(t){this.detectChangeCallback=t}}const ut=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
183
183
  <path d="M13.3334 5.99996H2.66675M13.3334 9.99996H2.66675M5.33341 12.6666V3.33329M10.6667 12.6666V3.33329" stroke="#667085" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
184
- </svg>`;class ut extends g{constructor(t={}){t.rowGap=t.rowGap??!0,t.columnGap=t.columnGap??!0,t.title=t.title??"Gap",t.icon=t.icon??pt,t.suffix=t.suffix??"px",t.minValue=t.minValue??0,super(t),this.inputType="number",this.inputValues={},this.mobileValue=t.mobile,this.value=this.validateValue(t.default??0),t.rowGap&&(this.inputValues.row=this.value),t.columnGap&&(this.inputValues.column=this.value)}draw(){const t=document.createElement("div");t.className=`setting-container ${this.props.className||""}`,t.id=this.id;const e=document.createElement("div");e.className="setting-label-input-wrapper";const i=document.createElement("label");i.className="setting-label",i.setAttribute("for",this.id+"-input");const s=document.createElement("span");if(s.textContent=this.props.title??"Gap",i.appendChild(s),this.props.icon){const o=document.createElement("span");o.className="setting-icon",o.innerHTML=this.props.icon,i.insertBefore(o,s)}const n=document.createElement("div");n.className=`setting-input-wrapper ${this.props.wrapperClassName||""}`,n.classList.add("gap-setting-wrapper");const a=document.createElement("div");return a.className="gap-inputs-container",this.props.rowGap&&a.appendChild(this.createGapInput("row","Row")),this.props.columnGap&&a.appendChild(this.createGapInput("column","Col")),n.appendChild(a),e.appendChild(i),e.appendChild(n),t.appendChild(e),t}createGapInput(t,e){const i=document.createElement("div");i.className="gap-input-wrapper";const s=document.createElement("input");if(s.type="number",s.className=`gap-input gap-${t}-input ${this.props.inputClassName||""}`,s.id=`${this.id}-${t}-input`,s.min=String(this.props.minValue??0),this.props.maxValue!==void 0&&(s.max=String(this.props.maxValue)),s.step=String(this.props.step??1),s.value=String(this.inputValues[t]??this.value),s.title=e,this.getDataPropsPath()&&s.setAttribute("data-test-id",`${this.getDataPropsPath()}_${t}`),s.addEventListener("input",n=>{const a=n.target;let o=parseFloat(a.value);o=this.validateValue(o),String(o)!==a.value&&(a.value=String(o)),this.inputValues[t]=o,this.setValue(o)}),s.addEventListener("blur",n=>{var l,r;const a=n.target;let o=parseFloat(a.value);o=this.validateValue(o),String(o)!==a.value&&(a.value=String(o),this.inputValues[t]=o,this.setValue(o)),(r=(l=this.props).onBlur)==null||r.call(l)}),i.appendChild(s),this.props.suffix&&this.props.suffix!=="none"){const n=document.createElement("span");n.className="gap-suffix",n.textContent=this.props.suffix,i.appendChild(n),s.style.paddingRight="30px"}return i}validateValue(t){(t==null||isNaN(t))&&(t=this.props.default??0);const e=this.props.minValue??Number.MIN_SAFE_INTEGER,i=this.props.maxValue??Number.MAX_SAFE_INTEGER;let s=Number(t);return s<e&&(s=e),s>i&&(s=i),s}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}}const gt=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
184
+ </svg>`;class pt extends g{constructor(t={}){t.rowGap=t.rowGap??!0,t.columnGap=t.columnGap??!0,t.title=t.title??"Gap",t.icon=t.icon??ut,t.suffix=t.suffix??"px",t.minValue=t.minValue??0,super(t),this.inputType="number",this.inputValues={},this.mobileValue=t.mobile,this.value=this.validateValue(t.default??0),t.rowGap&&(this.inputValues.row=this.value),t.columnGap&&(this.inputValues.column=this.value)}draw(){const t=document.createElement("div");t.className=`setting-container ${this.props.className||""}`,t.id=this.id;const e=document.createElement("div");e.className="setting-label-input-wrapper";const i=document.createElement("label");i.className="setting-label",i.setAttribute("for",this.id+"-input");const s=document.createElement("span");if(s.textContent=this.props.title??"Gap",i.appendChild(s),this.props.icon){const o=document.createElement("span");o.className="setting-icon",o.innerHTML=this.props.icon,i.insertBefore(o,s)}const n=document.createElement("div");n.className=`setting-input-wrapper ${this.props.wrapperClassName||""}`,n.classList.add("gap-setting-wrapper");const a=document.createElement("div");return a.className="gap-inputs-container",this.props.rowGap&&a.appendChild(this.createGapInput("row","Row")),this.props.columnGap&&a.appendChild(this.createGapInput("column","Col")),n.appendChild(a),e.appendChild(i),e.appendChild(n),t.appendChild(e),t}createGapInput(t,e){const i=document.createElement("div");i.className="gap-input-wrapper";const s=document.createElement("input");if(s.type="number",s.className=`gap-input gap-${t}-input ${this.props.inputClassName||""}`,s.id=`${this.id}-${t}-input`,s.min=String(this.props.minValue??0),this.props.maxValue!==void 0&&(s.max=String(this.props.maxValue)),s.step=String(this.props.step??1),s.value=String(this.inputValues[t]??this.value),s.title=e,this.getDataPropsPath()&&s.setAttribute("data-test-id",`${this.getDataPropsPath()}_${t}`),s.addEventListener("input",n=>{const a=n.target;let o=parseFloat(a.value);o=this.validateValue(o),String(o)!==a.value&&(a.value=String(o)),this.inputValues[t]=o,this.setValue(o)}),s.addEventListener("blur",n=>{var l,r;const a=n.target;let o=parseFloat(a.value);o=this.validateValue(o),String(o)!==a.value&&(a.value=String(o),this.inputValues[t]=o,this.setValue(o)),(r=(l=this.props).onBlur)==null||r.call(l)}),i.appendChild(s),this.props.suffix&&this.props.suffix!=="none"){const n=document.createElement("span");n.className="gap-suffix",n.textContent=this.props.suffix,i.appendChild(n),s.style.paddingRight="30px"}return i}validateValue(t){(t==null||isNaN(t))&&(t=this.props.default??0);const e=this.props.minValue??Number.MIN_SAFE_INTEGER,i=this.props.maxValue??Number.MAX_SAFE_INTEGER;let s=Number(t);return s<e&&(s=e),s>i&&(s=i),s}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}}const gt=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
185
185
  <path d="M2.25 11.75H15.75M5.85 2.75H12.15C13.4101 2.75 14.0402 2.75 14.5215 2.99524C14.9448 3.21095 15.289 3.55516 15.5048 3.97852C15.75 4.45982 15.75 5.08988 15.75 6.35V12.65C15.75 13.9101 15.75 14.5402 15.5048 15.0215C15.289 15.4448 14.9448 15.789 14.5215 16.0048C14.0402 16.25 13.4101 16.25 12.15 16.25H5.85C4.58988 16.25 3.95982 16.25 3.47852 16.0048C3.05516 15.789 2.71095 15.4448 2.49524 15.0215C2.25 14.5402 2.25 13.9101 2.25 12.65V6.35C2.25 5.08988 2.25 4.45982 2.49524 3.97852C2.71095 3.55516 3.05516 3.21095 3.47852 2.99524C3.95982 2.75 4.58988 2.75 5.85 2.75Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
186
186
  </svg>`;class mt extends f{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||gt,title:t.title||"Margin Bottom",default:t.default??20,wrapperClassName:"margin-bottom-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}const ft=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
187
187
  <path d="M15.75 7.25H2.25m9.9 9h-6.3c-1.26 0-1.89 0-2.371-.245a2.25 2.25 0 0 1-.984-.983c-.245-.482-.245-1.112-.245-2.372v-6.3c0-1.26 0-1.89.245-2.371a2.25 2.25 0 0 1 .984-.984c.48-.245 1.11-.245 2.371-.245h6.3c1.26 0 1.89 0 2.371.245.424.216.768.56.984.984.245.48.245 1.11.245 2.371v6.3c0 1.26 0 1.89-.245 2.371-.216.424-.56.768-.984.984-.48.245-1.11.245-2.371.245"
188
188
  stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
189
- </svg>`;class vt extends f{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||ft,title:t.title||"Margin Top",default:t.default??20,wrapperClassName:"margin-top-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}class Ct extends g{constructor(t){super(t),this.inputType={},this.container=null,this.value||(this.value={}),t.languages.forEach(e=>{e in(this.value||{})||(this.value||(this.value={}),this.value[e]="")})}createTextareaRow(t,e){const i=document.createElement("div");i.classList.add("simple-multi-language-row");const s=document.createElement("label");s.classList.add("simple-language-label"),s.textContent=t.toUpperCase(),s.setAttribute("for",`textarea-${t}`);const n=document.createElement("textarea");return n.id=`textarea-${t}`,n.classList.add("simple-language-textarea"),n.value=e||"",n.placeholder=this.props.placeholder||`Enter text in ${t.toUpperCase()}...`,n.rows=this.props.rows||3,this.getDataPropsPath()&&n.setAttribute("data-test-id",`${this.getDataPropsPath()}_${t}`),n.addEventListener("input",a=>{const o=a.target;this.updateLanguageValue(t,o.value)}),i.appendChild(s),i.appendChild(n),i}updateLanguageValue(t,e){this.value||(this.value={}),this.value[t]=e,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)}draw(){const t=document.createElement("div");if(t.classList.add("simple-multi-language-wrapper"),this.props.title){const i=document.createElement("div");i.classList.add("simple-multi-language-title"),i.textContent=this.props.title,t.appendChild(i)}const e=document.createElement("div");return e.classList.add("simple-multi-language-content"),this.props.languages.forEach(i=>{var a;const s=((a=this.value)==null?void 0:a[i])||"",n=this.createTextareaRow(i,s);e.appendChild(n)}),t.appendChild(e),this.container=t,t}setValue(t){super.setValue(t),this.container&&this.props.languages.forEach(e=>{var s;const i=(s=this.container)==null?void 0:s.querySelector(`#textarea-${e}`);i&&(i.value=(t==null?void 0:t[e])||"")})}}class wt extends g{constructor(t={}){super(t),this.inputType="select";const e=[{name:"None",value:"none"},{name:"Fade",value:"fade 1.5s ease-in-out infinite"},{name:"Slide",value:"slide 1.5s ease-in-out infinite"},{name:"Zoom",value:"zoom 1.5s ease-in-out infinite"},{name:"Bounce",value:"bounce 1.5s ease-in-out infinite"},{name:"Pulse",value:"pulse 1.5s ease-in-out infinite"}];this.selectSetting=new L({title:this.title||"Animation",options:e,default:this.props.default||"none"}),this.selectSetting.onChange=i=>{var s;this.value=i,(s=this.onChange)==null||s.call(this,i)}}draw(){return this.selectSetting.draw()}destroy(){this.selectSetting.destroy(),super.destroy()}}const bt=`
189
+ </svg>`;class vt extends f{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||ft,title:t.title||"Margin Top",default:t.default??20,wrapperClassName:"margin-top-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}class Ct extends g{constructor(t){super(t),this.inputType={},this.container=null,t.default?this.value={...t.default}:this.value||(this.value={});const e=t.defaultValue||"Test";t.languages.forEach(i=>{var s;i in(this.value||{})||(this.value||(this.value={}),this.value[i]=((s=t.default)==null?void 0:s[i])||e)})}createTextareaRow(t,e){const i=document.createElement("div");i.classList.add("simple-multi-language-row");const s=document.createElement("label");s.classList.add("simple-language-label"),s.textContent=t.toUpperCase(),s.setAttribute("for",`textarea-${t}`);const n=document.createElement("textarea");n.id=`textarea-${t}`,n.classList.add("simple-language-textarea"),n.value=e||"";let a=this.props.placeholder||"Enter text in {language}...";return a.includes("{language}")&&(a=a.replace("{language}",t.toUpperCase())),n.placeholder=a,n.rows=this.props.rows||3,this.getDataPropsPath()&&n.setAttribute("data-test-id",`${this.getDataPropsPath()}_${t}`),n.addEventListener("input",o=>{const l=o.target;this.updateLanguageValue(t,l.value)}),i.appendChild(s),i.appendChild(n),i}updateLanguageValue(t,e){this.value||(this.value={});const i={...this.value,[t]:e};this.setValue(i)}draw(){const t=document.createElement("div");if(t.classList.add("simple-multi-language-wrapper"),this.props.title){const i=document.createElement("div");i.classList.add("simple-multi-language-title"),i.textContent=this.props.title,t.appendChild(i)}const e=document.createElement("div");return e.classList.add("simple-multi-language-content"),this.props.languages.forEach(i=>{var a;const s=((a=this.value)==null?void 0:a[i])||"",n=this.createTextareaRow(i,s);e.appendChild(n)}),t.appendChild(e),this.container=t,t}setValue(t){super.setValue(t),this.container&&this.props.languages.forEach(e=>{var s;const i=(s=this.container)==null?void 0:s.querySelector(`#textarea-${e}`);i&&(i.value=(t==null?void 0:t[e])||"")})}}class wt extends g{constructor(t={}){super(t),this.inputType="select";const e=[{name:"None",value:"none"},{name:"Fade",value:"fade 1.5s ease-in-out infinite"},{name:"Slide",value:"slide 1.5s ease-in-out infinite"},{name:"Zoom",value:"zoom 1.5s ease-in-out infinite"},{name:"Bounce",value:"bounce 1.5s ease-in-out infinite"},{name:"Pulse",value:"pulse 1.5s ease-in-out infinite"}];this.selectSetting=new L({title:this.title||"Animation",options:e,default:this.props.default||"none"}),this.selectSetting.onChange=i=>{var s;this.value=i,(s=this.onChange)==null||s.call(this,i)}}draw(){return this.selectSetting.draw()}destroy(){this.selectSetting.destroy(),super.destroy()}}const bt=`
190
190
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
191
191
  <path d="M5.625 9.5H5.6325M12.375 9.5H12.3825M9 9.5H9.0075M9 12.875H9.0075M9 6.125H9.0075M2.25 6.35L2.25 12.65C2.25 13.9101 2.25 14.5402 2.49524 15.0215C2.71095 15.4448 3.05516 15.789 3.47852 16.0048C3.95982 16.25 4.58988 16.25 5.85 16.25H12.15C13.4101 16.25 14.0402 16.25 14.5215 16.0048C14.9448 15.789 15.289 15.4448 15.5048 15.0215C15.75 14.5402 15.75 13.9101 15.75 12.65V6.35C15.75 5.08988 15.75 4.45982 15.5048 3.97852C15.289 3.55516 14.9448 3.21095 14.5215 2.99524C14.0402 2.75 13.4101 2.75 12.15 2.75L5.85 2.75C4.58988 2.75 3.95982 2.75 3.47852 2.99524C3.05516 3.21095 2.71095 3.55516 2.49524 3.97852C2.25 4.45982 2.25 5.08988 2.25 6.35Z" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
192
192
  </svg>
@@ -236,4 +236,4 @@
236
236
  opacity: ${e/100};
237
237
  `:`
238
238
  background-color: ${i};
239
- `}}exports.AlignSetting=A;exports.AnimationSetting=wt;exports.BackgroundSettingSet=Ht;exports.BorderSettingSet=xt;exports.ButtonSetting=Q;exports.ColorSetting=m;exports.ColorWithOpacitySetting=C;exports.DimensionSetting=Y;exports.GapSetting=ut;exports.HeaderTypographySettingSet=Mt;exports.HeightSetting=at;exports.HtmlSetting=Z;exports.MarginBottomSetting=mt;exports.MarginSettingGroup=St;exports.MarginTopSetting=vt;exports.MultiLanguageSetting=Ct;exports.NumberSetting=f;exports.OpacitySetting=P;exports.SelectApiSettings=ct;exports.SelectSetting=L;exports.Setting=g;exports.SettingGroup=v;exports.StringSetting=T;exports.TabSettingGroup=I;exports.TabsSettingGroup=I;exports.Toggle=dt;exports.UploadSetting=B;exports.WidthSetting=lt;exports.asSettingGroupWithSettings=J;exports.createSettingGroup=H;exports.createTabSettingGroup=j;exports.isSetting=w;exports.isSettingChild=_;exports.isSettingGroup=u;exports.iterateSettings=b;
239
+ `}}exports.AlignSetting=A;exports.AnimationSetting=wt;exports.BackgroundSettingSet=Ht;exports.BorderSettingSet=xt;exports.ButtonSetting=Q;exports.ColorSetting=m;exports.ColorWithOpacitySetting=C;exports.DimensionSetting=Y;exports.GapSetting=pt;exports.HeaderTypographySettingSet=Mt;exports.HeightSetting=at;exports.HtmlSetting=Z;exports.MarginBottomSetting=mt;exports.MarginSettingGroup=St;exports.MarginTopSetting=vt;exports.MultiLanguageSetting=Ct;exports.NumberSetting=f;exports.OpacitySetting=P;exports.SelectApiSettings=ct;exports.SelectSetting=L;exports.Setting=g;exports.SettingGroup=v;exports.StringSetting=T;exports.TabSettingGroup=I;exports.TabsSettingGroup=I;exports.Toggle=dt;exports.UploadSetting=B;exports.WidthSetting=lt;exports.asSettingGroupWithSettings=J;exports.createSettingGroup=H;exports.createTabSettingGroup=j;exports.isSetting=w;exports.isSettingChild=_;exports.isSettingGroup=p;exports.iterateSettings=b;
@@ -233,11 +233,11 @@ class g {
233
233
  function w(c) {
234
234
  return c instanceof g;
235
235
  }
236
- function u(c) {
236
+ function p(c) {
237
237
  return c instanceof v;
238
238
  }
239
239
  function gt(c) {
240
- return w(c) || u(c);
240
+ return w(c) || p(c);
241
241
  }
242
242
  function E(c, t) {
243
243
  for (const e in c)
@@ -254,7 +254,7 @@ const L = class L {
254
254
  propagateNestingLevel() {
255
255
  const t = this.nestingLevel + 1;
256
256
  E(this.settings, (e, i) => {
257
- u(i) && (i.nestingLevel = t, i.propagateNestingLevel());
257
+ p(i) && (i.nestingLevel = t, i.propagateNestingLevel());
258
258
  });
259
259
  }
260
260
  getNestingLevel() {
@@ -272,7 +272,7 @@ const L = class L {
272
272
  propagateDataPropsPath() {
273
273
  E(this.settings, (t, e) => {
274
274
  const i = String(t), s = this.dataPropsPath ? `${this.dataPropsPath}_${i}` : i;
275
- (u(e) || w(e) && typeof e.setDataPropsPath == "function") && e.setDataPropsPath(s);
275
+ (p(e) || w(e) && typeof e.setDataPropsPath == "function") && e.setDataPropsPath(s);
276
276
  });
277
277
  }
278
278
  updateNestingStyles() {
@@ -281,7 +281,7 @@ const L = class L {
281
281
  forceChildUIRefresh() {
282
282
  Object.entries(this.settings).forEach(([t, e]) => {
283
283
  try {
284
- if (u(e)) {
284
+ if (p(e)) {
285
285
  const i = e.getValues();
286
286
  e.setValue(i);
287
287
  } else if (typeof e.setValue == "function") {
@@ -351,7 +351,7 @@ const L = class L {
351
351
  setMobileValues(t) {
352
352
  !t || typeof t != "object" || (Object.entries(t).forEach(([e, i]) => {
353
353
  const s = this.settings[e];
354
- s && (u(s) || w(s)) && typeof s.setMobileValue == "function" && s.setMobileValue(i);
354
+ s && (p(s) || w(s)) && typeof s.setMobileValue == "function" && s.setMobileValue(i);
355
355
  }), this.setValue(t), this.onChange && this.onChange(this.getValues()));
356
356
  }
357
357
  getMobileValues(t) {
@@ -360,7 +360,7 @@ const L = class L {
360
360
  for (const i in this.settings)
361
361
  if (Object.prototype.hasOwnProperty.call(this.settings, i)) {
362
362
  const s = this.settings[i];
363
- if (u(s))
363
+ if (p(s))
364
364
  e[i] = s.getMobileValues();
365
365
  else {
366
366
  const n = s;
@@ -371,7 +371,7 @@ const L = class L {
371
371
  } else {
372
372
  const e = this.settings[t];
373
373
  if (!e) return;
374
- if (u(e)) return e.getMobileValues();
374
+ if (p(e)) return e.getMobileValues();
375
375
  const i = e;
376
376
  return i.mobileValue !== void 0 ? i.mobileValue : i.value;
377
377
  }
@@ -389,7 +389,7 @@ const L = class L {
389
389
  };
390
390
  return this.changeHandlers.clear(), E(this.settings, (i, s) => {
391
391
  var n;
392
- if (u(s))
392
+ if (p(s))
393
393
  s.setOnChange(() => {
394
394
  const a = this.getValues();
395
395
  this.initialValues = a, t(a);
@@ -420,7 +420,7 @@ const L = class L {
420
420
  this.addSetting(i, l), n = l;
421
421
  }
422
422
  }
423
- n && (u(n) || w(n)) && typeof n.setValue == "function" && n.setValue(s);
423
+ n && (p(n) || w(n)) && typeof n.setValue == "function" && n.setValue(s);
424
424
  }), setTimeout(() => {
425
425
  this.forceChildUIRefresh();
426
426
  }, 0);
@@ -434,7 +434,7 @@ const L = class L {
434
434
  const s = this.getValues();
435
435
  this.initialValues = s, (n = this.onChange) == null || n.call(this, s), this.updateVisibility();
436
436
  };
437
- u(t) ? t.setOnChange(() => e()) : w(t) ? t.setOnChange(() => e()) : (i = t.setOnChange) == null || i.call(t, () => e());
437
+ p(t) ? t.setOnChange(() => e()) : w(t) ? t.setOnChange(() => e()) : (i = t.setOnChange) == null || i.call(t, () => e());
438
438
  }
439
439
  addSetting(t, e) {
440
440
  var s, n;
@@ -443,7 +443,7 @@ const L = class L {
443
443
  ".setting-group-content"
444
444
  );
445
445
  if (a) {
446
- u(e) && typeof e.setNestingLevel == "function" && e.setNestingLevel(this.nestingLevel + 1);
446
+ p(e) && typeof e.setNestingLevel == "function" && e.setNestingLevel(this.nestingLevel + 1);
447
447
  const o = e.draw(), l = this.deleteItemCfg ?? this.addItemCfg;
448
448
  if (l) {
449
449
  const d = l.keyPrefix ?? ((s = this.addItemCfg) == null ? void 0 : s.keyPrefix);
@@ -633,12 +633,12 @@ const L = class L {
633
633
  for (const i in this.settings)
634
634
  if (Object.prototype.hasOwnProperty.call(this.settings, i)) {
635
635
  const s = this.settings[i];
636
- u(s) ? e[i] = s.getValues() : e[i] = s.value;
636
+ p(s) ? e[i] = s.getValues() : e[i] = s.value;
637
637
  }
638
638
  return e;
639
639
  } else {
640
640
  const e = this.settings[t];
641
- return e ? u(e) ? e.getValues() : e.value : void 0;
641
+ return e ? p(e) ? e.getValues() : e.value : void 0;
642
642
  }
643
643
  }
644
644
  getValuesForJson(t) {
@@ -648,7 +648,7 @@ const L = class L {
648
648
  for (const i in this.settings)
649
649
  if (Object.prototype.hasOwnProperty.call(this.settings, i)) {
650
650
  const s = this.settings[i];
651
- if (u(s))
651
+ if (p(s))
652
652
  e[i] = s.getValuesForJson();
653
653
  else {
654
654
  const n = s;
@@ -659,7 +659,7 @@ const L = class L {
659
659
  } else {
660
660
  const e = this.settings[t];
661
661
  if (!e) return;
662
- if (u(e))
662
+ if (p(e))
663
663
  return e.includeGetJson === !1 ? null : e.getValuesForJson();
664
664
  {
665
665
  const i = e;
@@ -673,7 +673,7 @@ const L = class L {
673
673
  for (const i in this.settings)
674
674
  if (Object.prototype.hasOwnProperty.call(this.settings, i)) {
675
675
  const s = this.settings[i];
676
- if (u(s))
676
+ if (p(s))
677
677
  e[i] = s.getDefaultValues();
678
678
  else {
679
679
  const n = s;
@@ -684,7 +684,7 @@ const L = class L {
684
684
  } else {
685
685
  const e = this.settings[t];
686
686
  if (!e) return;
687
- if (u(e)) return e.getDefaultValues();
687
+ if (p(e)) return e.getDefaultValues();
688
688
  const i = e;
689
689
  return i.default !== void 0 ? i.default : i.value;
690
690
  }
@@ -723,13 +723,13 @@ const L = class L {
723
723
  for (const h in this.settings)
724
724
  if (Object.prototype.hasOwnProperty.call(this.settings, h)) {
725
725
  const d = this.settings[h];
726
- u(d) && typeof d.setNestingLevel == "function" && d.setNestingLevel(this.nestingLevel + 1);
727
- const p = d.draw();
728
- u(d) && d.deleteItemCfg && this.addDeleteButtonToElement(
729
- p,
726
+ p(d) && typeof d.setNestingLevel == "function" && d.setNestingLevel(this.nestingLevel + 1);
727
+ const u = d.draw();
728
+ p(d) && d.deleteItemCfg && this.addDeleteButtonToElement(
729
+ u,
730
730
  h,
731
731
  d
732
- ), o.appendChild(p);
732
+ ), o.appendChild(u);
733
733
  }
734
734
  } else {
735
735
  const h = document.createElement("div");
@@ -744,8 +744,8 @@ const L = class L {
744
744
  <path d="M8 3.333v9.334M3.333 8h9.334" stroke="currentColor"
745
745
  stroke-width="1.5" stroke-linecap="round"/>
746
746
  </svg>`;
747
- h.innerHTML = `${d}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel ?? "Add"}</span>`, h.addEventListener("click", (p) => {
748
- p.stopPropagation(), p.preventDefault();
747
+ h.innerHTML = `${d}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel ?? "Add"}</span>`, h.addEventListener("click", (u) => {
748
+ u.stopPropagation(), u.preventDefault();
749
749
  const k = this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix), O = this.addItemCfg.createItem(k), H = `${this.addItemCfg.keyPrefix}${k}`;
750
750
  this.addSetting(H, O);
751
751
  }), o.appendChild(h);
@@ -838,7 +838,7 @@ class D extends v {
838
838
  const h = document.createElement("div");
839
839
  h.className = "tab-panel", this.contentContainers[o] = h;
840
840
  const d = this.settings[o];
841
- d && (u(d) && typeof d.setNestingLevel == "function" && d.setNestingLevel(this.getNestingLevel() + 1), h.appendChild(
841
+ d && (p(d) && typeof d.setNestingLevel == "function" && d.setNestingLevel(this.getNestingLevel() + 1), h.appendChild(
842
842
  d.draw()
843
843
  )), a.appendChild(h), l === 0 && !this.activeTabId && (this.activeTabId = o);
844
844
  }), e.appendChild(i), e.appendChild(n), e.appendChild(a), !this.activeTabId) {
@@ -949,17 +949,17 @@ class m extends F {
949
949
  var h, d;
950
950
  let r = l.target.value.trim();
951
951
  if (this.textInputEl && i(this.textInputEl)) {
952
- const p = m.normalizeColorValue(r);
953
- this.value = p, (h = this.onChange) == null || h.call(this, p), (d = this.detectChange) == null || d.call(this, p), this.colorInputEl && (this.colorInputEl.value = p), n.style.backgroundColor = p;
952
+ const u = m.normalizeColorValue(r);
953
+ this.value = u, (h = this.onChange) == null || h.call(this, u), (d = this.detectChange) == null || d.call(this, u), this.colorInputEl && (this.colorInputEl.value = u), n.style.backgroundColor = u;
954
954
  }
955
955
  }), this.colorInputEl.addEventListener("input", (l) => {
956
- var d, p;
956
+ var d, u;
957
957
  const r = l.target.value, h = m.normalizeColorValue(r);
958
- this.value = h, (d = this.onChange) == null || d.call(this, h), (p = this.detectChange) == null || p.call(this, h), this.textInputEl && (this.textInputEl.value = h), n.style.backgroundColor = h, e.classList.remove("error");
958
+ this.value = h, (d = this.onChange) == null || d.call(this, h), (u = this.detectChange) == null || u.call(this, h), this.textInputEl && (this.textInputEl.value = h), n.style.backgroundColor = h, e.classList.remove("error");
959
959
  }), this.colorInputEl.addEventListener("change", (l) => {
960
- var d, p;
960
+ var d, u;
961
961
  const r = l.target.value, h = m.normalizeColorValue(r);
962
- this.value = h, (d = this.onChange) == null || d.call(this, h), (p = this.detectChange) == null || p.call(this, h), this.textInputEl && (this.textInputEl.value = h), n.style.backgroundColor = h;
962
+ this.value = h, (d = this.onChange) == null || d.call(this, h), (u = this.detectChange) == null || u.call(this, h), this.textInputEl && (this.textInputEl.value = h), n.style.backgroundColor = h;
963
963
  }), e.appendChild(s), e.appendChild(n), e.appendChild(o), t.appendChild(e), this.element = t, t;
964
964
  }
965
965
  getElement() {
@@ -1851,8 +1851,8 @@ class xt extends g {
1851
1851
  if (o)
1852
1852
  o.textContent = this._options[e].name;
1853
1853
  else {
1854
- const p = i.firstChild;
1855
- p && p.tagName === "SPAN" && (p.textContent = this._options[e].name);
1854
+ const u = i.firstChild;
1855
+ u && u.tagName === "SPAN" && (u.textContent = this._options[e].name);
1856
1856
  }
1857
1857
  this.isOpen = !1, (r = this.optionsListEl) == null || r.classList.remove("open"), (h = this.svgContainer) == null || h.classList.remove("open"), (d = this.onChange) == null || d.call(this, a), this.detectChangeCallback && this.detectChangeCallback(a);
1858
1858
  }
@@ -2024,8 +2024,11 @@ class Mt extends f {
2024
2024
  }
2025
2025
  class Vt extends g {
2026
2026
  constructor(t) {
2027
- super(t), this.inputType = {}, this.container = null, this.value || (this.value = {}), t.languages.forEach((e) => {
2028
- e in (this.value || {}) || (this.value || (this.value = {}), this.value[e] = "");
2027
+ super(t), this.inputType = {}, this.container = null, t.default ? this.value = { ...t.default } : this.value || (this.value = {});
2028
+ const e = t.defaultValue || "Test";
2029
+ t.languages.forEach((i) => {
2030
+ var s;
2031
+ i in (this.value || {}) || (this.value || (this.value = {}), this.value[i] = ((s = t.default) == null ? void 0 : s[i]) || e);
2029
2032
  });
2030
2033
  }
2031
2034
  createTextareaRow(t, e) {
@@ -2034,16 +2037,23 @@ class Vt extends g {
2034
2037
  const s = document.createElement("label");
2035
2038
  s.classList.add("simple-language-label"), s.textContent = t.toUpperCase(), s.setAttribute("for", `textarea-${t}`);
2036
2039
  const n = document.createElement("textarea");
2037
- return n.id = `textarea-${t}`, n.classList.add("simple-language-textarea"), n.value = e || "", n.placeholder = this.props.placeholder || `Enter text in ${t.toUpperCase()}...`, n.rows = this.props.rows || 3, this.getDataPropsPath() && n.setAttribute(
2040
+ n.id = `textarea-${t}`, n.classList.add("simple-language-textarea"), n.value = e || "";
2041
+ let a = this.props.placeholder || "Enter text in {language}...";
2042
+ return a.includes("{language}") && (a = a.replace(
2043
+ "{language}",
2044
+ t.toUpperCase()
2045
+ )), n.placeholder = a, n.rows = this.props.rows || 3, this.getDataPropsPath() && n.setAttribute(
2038
2046
  "data-test-id",
2039
2047
  `${this.getDataPropsPath()}_${t}`
2040
- ), n.addEventListener("input", (a) => {
2041
- const o = a.target;
2042
- this.updateLanguageValue(t, o.value);
2048
+ ), n.addEventListener("input", (o) => {
2049
+ const l = o.target;
2050
+ this.updateLanguageValue(t, l.value);
2043
2051
  }), i.appendChild(s), i.appendChild(n), i;
2044
2052
  }
2045
2053
  updateLanguageValue(t, e) {
2046
- this.value || (this.value = {}), this.value[t] = e, this.onChange && this.onChange(this.value), this.props.detectChange && this.props.detectChange(this.value);
2054
+ this.value || (this.value = {});
2055
+ const i = { ...this.value, [t]: e };
2056
+ this.setValue(i);
2047
2057
  }
2048
2058
  draw() {
2049
2059
  const t = document.createElement("div");
@@ -2285,13 +2295,13 @@ class Ot extends v {
2285
2295
  }),
2286
2296
  marginBottom: new b({
2287
2297
  title: "Bottom",
2288
- icon: pt,
2298
+ icon: ut,
2289
2299
  suffix: "px",
2290
2300
  default: (t == null ? void 0 : t.marginBottom) ?? 0
2291
2301
  }),
2292
2302
  marginLeft: new b({
2293
2303
  title: "Left",
2294
- icon: ut,
2304
+ icon: pt,
2295
2305
  suffix: "px",
2296
2306
  default: (t == null ? void 0 : t.marginLeft) ?? 0
2297
2307
  })
@@ -2312,9 +2322,9 @@ const ct = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewB
2312
2322
  <path d="M2.25 16.25H2.2575M2.25 9.5H2.2575M2.25 12.875H2.2575M2.25 6.125H2.2575M5.625 16.25H5.6325M5.625 9.5H5.6325M12.375 16.25H12.3825M12.375 9.5H12.3825M9 16.25H9.0075M9 9.5H9.0075M9 12.875H9.0075M9 6.125H9.0075M15.75 16.25H15.7575M15.75 9.5H15.7575M15.75 12.875H15.7575M15.75 6.125H15.7575M15.75 2.75H2.25" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
2313
2323
  </svg>`, dt = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
2314
2324
  <path d="M5.625 2.75H5.6325M5.625 9.5H5.6325M5.625 16.25H5.6325M12.375 2.75H12.3825M12.375 9.5H12.3825M12.375 16.25H12.3825M9 2.75H9.0075M9 9.5H9.0075M9 16.25H9.0075M9 12.875H9.0075M9 6.125H9.0075M2.25 2.75H2.2575M2.25 9.5H2.2575M2.25 16.25H2.2575M2.25 12.875H2.2575M2.25 6.125H2.2575M15.75 16.25V2.75" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
2315
- </svg>`, pt = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
2316
- <path d="M2.25 2.75H2.2575M2.25 9.5H2.2575M2.25 12.875H2.2575M2.25 6.125H2.2575M5.625 2.75H5.6325M5.625 9.5H5.6325M12.375 2.75H12.3825M12.375 9.5H12.3825M9 2.75H9.0075M9 9.5H9.0075M9 12.875H9.0075M9 6.125H9.0075M15.75 2.75H15.7575M15.75 9.5H15.7575M15.75 12.875H15.7575M15.75 6.125H15.7575M15.75 16.25H2.25" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
2317
2325
  </svg>`, ut = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
2326
+ <path d="M2.25 2.75H2.2575M2.25 9.5H2.2575M2.25 12.875H2.2575M2.25 6.125H2.2575M5.625 2.75H5.6325M5.625 9.5H5.6325M12.375 2.75H12.3825M12.375 9.5H12.3825M9 2.75H9.0075M9 9.5H9.0075M9 12.875H9.0075M9 6.125H9.0075M15.75 2.75H15.7575M15.75 9.5H15.7575M15.75 12.875H15.7575M15.75 6.125H15.7575M15.75 16.25H2.25" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
2327
+ </svg>`, pt = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
2318
2328
  <path d="M5.625 2.75H5.6325M5.625 9.5H5.6325M5.625 16.25H5.6325M12.375 2.75H12.3825M12.375 9.5H12.3825M12.375 16.25H12.3825M9 2.75H9.0075M9 9.5H9.0075M9 16.25H9.0075M9 12.875H9.0075M9 6.125H9.0075M15.75 2.75H15.7575M15.75 9.5H15.7575M15.75 16.25H15.7575M15.75 12.875H15.7575M15.75 6.125H15.7575M2.25 16.25V2.75" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
2319
2329
  </svg>`;
2320
2330
  class Ht extends v {
@@ -2390,6 +2400,6 @@ export {
2390
2400
  mt as createTabSettingGroup,
2391
2401
  w as isSetting,
2392
2402
  gt as isSettingChild,
2393
- u as isSettingGroup,
2403
+ p as isSettingGroup,
2394
2404
  E as iterateSettings
2395
2405
  };
@@ -6,6 +6,8 @@ export interface MultiLanguageSettingsProps extends SettingProps<MultiLanguageVa
6
6
  languages: string[];
7
7
  placeholder?: string;
8
8
  rows?: number;
9
+ default?: MultiLanguageValue;
10
+ defaultValue?: string;
9
11
  }
10
12
  export declare class MultiLanguageSetting extends Setting<MultiLanguageValue, MultiLanguageSettingsProps> {
11
13
  inputType: Record<keyof MultiLanguageValue, "text">;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "builder-settings-types",
3
3
  "description": "builder settings",
4
- "version": "0.0.244",
4
+ "version": "0.0.246",
5
5
  "type": "module",
6
6
  "main": "dist/builder-settings-types.cjs.js",
7
7
  "module": "dist/builder-settings-types.es.js",