builder-settings-types 0.0.164 → 0.0.166

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 j="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let B=(c=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(c|=0));for(;c--;)t+=j[e[c]&63];return t};function S(c){if(c===null||typeof c!="object")return c;if(c instanceof Date)return new Date(c.getTime());if(Array.isArray(c)){const i=[];for(let s=0;s<c.length;s++)i[s]=S(c[s]);return i}const t={};for(const i in c)Object.prototype.hasOwnProperty.call(c,i)&&(t[i]=S(c[i]));const e=Object.getPrototypeOf(c);return e!==Object.prototype&&Object.setPrototypeOf(t,e),t}function G(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.id=t.id||B(),this.value=this.props.default,this.desktop=this.props.default,this.title=t.title||""}destroy(){throw new Error("Method not implemented.")}setOnChange(t){return this.onChange=t,this}setOnBlur(t){return this.onBlur=t,this}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=S(this.props),i=new t(e);return i.value=S(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||G(t.inputType)),s.type=t.inputType,s.placeholder=t.placeholder||"",s.className=t.inputClassName||"";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 L(c,t){for(const e in c)if(c.hasOwnProperty(e)){const i=c[e];t(e,i)}}const C=class C{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.lastValues={},this.lastChangeTime=0,this.CHANGE_DEBOUNCE=100,this.handleBlur=()=>{},this.pendingBlurHandler=null,this.id=t.id||B(),this.title=t.title,this.settings=t.settings,this.description=t.description,this.icon=t.icon,this.isCollapsed=t.collapsed??!1,this.isMain=t.main??!1,this.custom=t.custom??!1,this.hideCondition=t.hideCondition,this.onBlur=t.onBlur,Object.assign(this,t.settings),this.initialValues=this.getValues()}static hide(){this.hiddenElements.forEach(t=>{t&&(t.style.display="none")})}static show(){this.hiddenElements.forEach(t=>{t&&(t.style.display="")})}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(),L(this.settings,(i,s)=>{var n;if(s instanceof C)s.setOnChange(a=>{const o=this.getValues();this.initialValues=o,t(o)}),this.changeHandlers.add(()=>t(this.getValues()));else if(s instanceof g){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}setOnBlur(t){return this.onBlur=t,this.pendingBlurHandler=t,this.handleBlur=e=>{(e==null?void 0:e.target)instanceof HTMLElement&&e.target.closest(".setting-group")!==this.elementRef||(this.blurTimeout&&clearTimeout(this.blurTimeout),this.blurTimeout=setTimeout(()=>{t()},100))},this.elementRef&&this.setupBlurHandlers(),this}setupBlurHandlers(){this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.elementRef&&this.elementRef.addEventListener("focusout",this.handleBlur,!0),L(this.settings,(t,e)=>{var i;if(e instanceof C)e.setOnBlur(this.handleBlur);else{const s=(i=this.elementRef)==null?void 0:i.querySelector(`[data-setting-id="${e.id}"]`);s&&s.addEventListener("focusout",this.handleBlur,!0)}})}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()}clone(){const t={};L(this.settings,(s,n)=>{typeof n.clone=="function"?t[s]=n.clone():(console.warn(`Setting with key '${s}' does not have a clone method. Copying reference.`),t[s]=n)});const e={title:this.title,settings:t,description:this.description,icon:this.icon,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,hideCondition:this.hideCondition},i=R(e);return i.initialValues=this.getValues(),i}setValue(t){if(!t||typeof t!="object")return;Object.entries(t).forEach(([i,s])=>{const n=this.settings[i];n&&(n instanceof C||n instanceof g)&&typeof n.setValue=="function"&&n.setValue(s)});const e=this.getValues();this.initialValues=e,this.onChange&&this.onChange(e)}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}hide(){this.elementRef&&(this.elementRef.style.display="none",this.isHidden=!0)}show(){this.elementRef&&(this.elementRef.style.display="",this.isHidden=!1)}getValues(t){if(t===void 0){const e={};for(const i in this.settings)if(this.settings.hasOwnProperty(i)){const s=this.settings[i];s instanceof C?e[i]=s.getValues():e[i]=s.value}return e}else{const e=this.settings[t];return e?e instanceof C?e.getValues():e.value:void 0}}getMobileValues(t){if(t===void 0){const e={};for(const i in this.settings)if(this.settings.hasOwnProperty(i)){const s=this.settings[i];if(s instanceof C)e[i]=s.getMobileValues();else if(typeof s.getMobileValue=="function"){const n=s.getMobileValue();e[i]=n!==void 0?n:s.value}}return e}else{const e=this.settings[t];if(!e)return;if(e instanceof C)return e.getMobileValues();if(typeof e.getMobileValue=="function"){const i=e.getMobileValue();return i!==void 0?i:e.value}return}}setMobileValues(t){if(!(!t||typeof t!="object")&&(Object.entries(t).forEach(([e,i])=>{const s=this.settings[e];s&&(s instanceof C?typeof i=="object"&&i!==null&&s.setMobileValues(i):typeof s.setMobileValue=="function"&&s.setMobileValue(i))}),this.setValue(t),this.onChange)){const e=this.getValues();this.onChange(e)}}draw(){const t=document.createElement("div");t.className="setting-group",t.id=`setting-group-${this.id}`,C.hiddenElements.add(t),this.hideCondition&&this.hideCondition()&&(t.style.display="none"),this.isMain&&t.classList.add("main-group");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");if(i.className="title-section",this.icon){const h=document.createElement("span");h.className="group-icon",h.innerHTML=this.icon,i.appendChild(h)}this.custom&&t.classList.add("custom_class");const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");if(n.className="actions-section",this.description&&this.isCollapsed){const h=document.createElement("span");h.className="info-marker",h.innerHTML=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let B=(c=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(c|=0));for(;c--;)t+=j[e[c]&63];return t};function S(c){if(c===null||typeof c!="object")return c;if(c instanceof Date)return new Date(c.getTime());if(Array.isArray(c)){const i=[];for(let s=0;s<c.length;s++)i[s]=S(c[s]);return i}const t={};for(const i in c)Object.prototype.hasOwnProperty.call(c,i)&&(t[i]=S(c[i]));const e=Object.getPrototypeOf(c);return e!==Object.prototype&&Object.setPrototypeOf(t,e),t}function G(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.id=t.id||B(),this.value=this.props.default,this.desktop=this.props.default,this.title=t.title||""}destroy(){throw new Error("Method not implemented.")}setOnChange(t){return this.onChange=t,this}setOnBlur(t){return this.onBlur=t,this}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=S(this.props),i=new t(e);return i.value=S(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||G(t.inputType)),s.type=t.inputType,s.placeholder=t.placeholder||"",s.className=t.inputClassName||"";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 L(c,t){for(const e in c)if(c.hasOwnProperty(e)){const i=c[e];t(e,i)}}const f=class f{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.lastValues={},this.lastChangeTime=0,this.CHANGE_DEBOUNCE=100,this.handleBlur=()=>{},this.pendingBlurHandler=null,this.originalDefaultValues={},this.id=t.id||B(),this.title=t.title,this.settings=t.settings,this.description=t.description,this.icon=t.icon,this.isCollapsed=t.collapsed??!1,this.isMain=t.main??!1,this.custom=t.custom??!1,this.hideCondition=t.hideCondition,this.onBlur=t.onBlur,Object.assign(this,t.settings),this.initialValues=this.getValues(),this.originalDefaultValues=this.getDefaultValues()}static hide(){this.hiddenElements.forEach(t=>{t&&(t.style.display="none")})}static show(){this.hiddenElements.forEach(t=>{t&&(t.style.display="")})}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(),L(this.settings,(i,s)=>{var n;if(s instanceof f)s.setOnChange(a=>{const o=this.getValues();this.initialValues=o,t(o)}),this.changeHandlers.add(()=>t(this.getValues()));else if(s instanceof g){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}setOnBlur(t){return this.onBlur=t,this.pendingBlurHandler=t,this.handleBlur=e=>{(e==null?void 0:e.target)instanceof HTMLElement&&e.target.closest(".setting-group")!==this.elementRef||(this.blurTimeout&&clearTimeout(this.blurTimeout),this.blurTimeout=setTimeout(()=>{t()},100))},this.elementRef&&this.setupBlurHandlers(),this}setupBlurHandlers(){this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.elementRef&&this.elementRef.addEventListener("focusout",this.handleBlur,!0),L(this.settings,(t,e)=>{var i;if(e instanceof f)e.setOnBlur(this.handleBlur);else{const s=(i=this.elementRef)==null?void 0:i.querySelector(`[data-setting-id="${e.id}"]`);s&&s.addEventListener("focusout",this.handleBlur,!0)}})}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()}clone(){const t={};L(this.settings,(s,n)=>{typeof n.clone=="function"?t[s]=n.clone():(console.warn(`Setting with key '${s}' does not have a clone method. Copying reference.`),t[s]=n)});const e={title:this.title,settings:t,description:this.description,icon:this.icon,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,hideCondition:this.hideCondition},i=R(e);return i.initialValues=this.getValues(),i}setValue(t){if(!t||typeof t!="object")return;Object.entries(t).forEach(([i,s])=>{const n=this.settings[i];n&&(n instanceof f||n instanceof g)&&typeof n.setValue=="function"&&n.setValue(s)});const e=this.getValues();this.initialValues=e,this.onChange&&this.onChange(e)}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}hide(){this.elementRef&&(this.elementRef.style.display="none",this.isHidden=!0)}show(){this.elementRef&&(this.elementRef.style.display="",this.isHidden=!1)}getValues(t){if(t===void 0){const e={};for(const i in this.settings)if(this.settings.hasOwnProperty(i)){const s=this.settings[i];s instanceof f?e[i]=s.getValues():e[i]=s.value}return e}else{const e=this.settings[t];return e?e instanceof f?e.getValues():e.value:void 0}}getDefaultValues(t){if(t===void 0){const e={};for(const i in this.settings)if(this.settings.hasOwnProperty(i)){const s=this.settings[i];s instanceof f?e[i]=s.getDefaultValues():e[i]=s.default!==void 0?s.default:s.value}return e}else{const e=this.settings[t];return e?e instanceof f?e.getDefaultValues():e.default!==void 0?e.default:e.value:void 0}}getMobileValues(t){if(t===void 0){const e={};for(const i in this.settings)if(this.settings.hasOwnProperty(i)){const s=this.settings[i];if(s instanceof f)e[i]=s.getMobileValues();else if(typeof s.getMobileValue=="function"){const n=s.getMobileValue();e[i]=n!==void 0?n:s.value}else e[i]=s.value}return e}else{const e=this.settings[t];if(!e)return;if(e instanceof f)return e.getMobileValues();if(typeof e.getMobileValue=="function"){const i=e.getMobileValue();return i!==void 0?i:e.value}else return e.value}}setMobileValues(t){if(!(!t||typeof t!="object")&&(Object.entries(t).forEach(([e,i])=>{const s=this.settings[e];s&&(s instanceof f?typeof i=="object"&&i!==null&&s.setMobileValues(i):typeof s.setMobileValue=="function"&&s.setMobileValue(i))}),this.setValue(t),this.onChange)){const e=this.getValues();this.onChange(e)}}resetDefault(){const t=this.originalDefaultValues;if(this.setValue(t),this.onChange){const e=this.getValues();this.onChange(e)}}draw(){const t=document.createElement("div");t.className="setting-group",t.id=`setting-group-${this.id}`,f.hiddenElements.add(t),this.hideCondition&&this.hideCondition()&&(t.style.display="none"),this.isMain&&t.classList.add("main-group");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");if(i.className="title-section",this.icon){const h=document.createElement("span");h.className="group-icon",h.innerHTML=this.icon,i.appendChild(h)}this.custom&&t.classList.add("custom_class");const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");if(n.className="actions-section",this.description&&this.isCollapsed){const h=document.createElement("span");h.className="info-marker",h.innerHTML=`
2
2
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
3
3
  <path d="M8 5.33333V8M8 10.6667H8.00667M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8Z"
4
4
  stroke="currentColor" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
@@ -12,15 +12,15 @@
12
12
  <path d="M8 5.33333V8M8 10.6667H8.00667M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8Z"
13
13
  stroke="currentColor" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
14
14
  </svg>
15
- `,d.title=this.description,n.insertBefore(d,a)}}else{if(!h){const d=document.createElement("div");d.className="setting-group-description",d.textContent=this.description,o.insertBefore(d,o.firstChild)}u&&u.remove()}};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(this.settings.hasOwnProperty(h)){const u=this.settings[h];o.appendChild(u.draw())}}else{const h=document.createElement("div");h.className="setting-group-empty",h.textContent="No settings in this group",o.appendChild(h)}return e.appendChild(i),e.appendChild(n),t.appendChild(e),t.appendChild(o),this.elementRef=t,this.pendingBlurHandler&&(this.setupBlurHandlers(),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"))}updateVisibility(){this.elementRef&&this.hideCondition&&(this.elementRef.style.display=this.hideCondition()?"none":"")}toggle(){this.isHidden?this.show():this.hide()}getJson(){return JSON.stringify(this.getValues(),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")}}};C.hiddenElements=new Set;let m=C;function R(c){return new m(c)}function _(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 I="<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 V extends T{constructor(t){super({...t,icon:t.icon||I,title:t.title||"Color",default:t.default?V.normalizeRgbValue(t.default):t.default}),this.inputType="color",this.element=null,this.detectChange=t.detectChange}static normalizeRgbValue(t){const e=t.split(",").map(r=>parseInt(r.trim()));if(e.length!==3||e.some(isNaN))return console.warn(`Invalid RGB value "${t}", using default "0, 0, 0"`),"0, 0, 0";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));return`${a}, ${o}, ${l}`}setValue(t){if(t===void 0){super.setValue("");return}if(typeof t=="string"){const e=V.normalizeRgbValue(t);super.setValue(e)}else super.setValue("")}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}`}rgbToHex(t){const e=t.split(",").map(h=>parseInt(h.trim()));if(e.length!==3||e.some(isNaN))return"#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 u=h.toString(16);return u.length===1?"0"+u:u};return`#${r(a)}${r(o)}${r(l)}`}draw(){const t=document.createElement("div");t.className="color-setting-wrapper",this.element=t;const e=document.createElement("div");e.className="icon-container";const i=this.createIcon(this.props.icon||I),s=this.createLabel(this.title||"Color");e.appendChild(i),e.appendChild(s);const n=document.createElement("div");n.className="color-input-wrapper";const a=d=>{const f=d.value.trim();if(!f)return d.style.border="",!0;const p=f.split(",").map(x=>parseInt(x.trim()));if(p.length!==3||p.some(isNaN))return d.style.border="1px solid red",!1;const[v,b,H]=p,E=v>=0&&v<=255&&b>=0&&b<=255&&H>=0&&H<=255;return d.style.border=E?"":"1px solid red",E},o=document.createElement("div");o.className="color-preview",o.style.backgroundColor=this.value?`rgb(${this.value})`:"";const l=this.createInput({value:this.value,inputType:"text",inputClassName:"color-text-input"}),r=l.querySelector("input");r.readOnly=!0;const h=this.createInput({value:this.value?this.rgbToHex(this.value):"#000000",inputType:this.inputType,inputClassName:"color-picker"}),u=h.querySelector("input");return r.oninput=d=>{var p;let f=d.target.value.trim();a(r)&&(this.value=f,(p=this.onChange)==null||p.call(this,f),u.value=this.rgbToHex(f),o.style.backgroundColor=`rgb(${f})`)},u.oninput=d=>{var v,b;const f=d.target.value,p=this.hexToRgb(f);this.value=p,(v=this.onChange)==null||v.call(this,p),(b=this.detectChange)==null||b.call(this,p),r.value=p,o.style.backgroundColor=`rgb(${p})`},u.onchange=d=>{var v,b;const f=d.target.value,p=this.hexToRgb(f);this.value=p,(v=this.onChange)==null||v.call(this,p),(b=this.detectChange)==null||b.call(this,p),r.value=p,o.style.backgroundColor=`rgb(${p})`},n.appendChild(o),n.appendChild(h),n.appendChild(l),t.appendChild(e),t.appendChild(n),this.value&&(r.value=this.value,u.value=this.rgbToHex(this.value),o.style.backgroundColor=`rgb(${this.value})`),t}getElement(){return this.element}getNormalizedValue(){return this.value?V.normalizeRgbValue(this.value):"0, 0, 0"}isValidRgb(){if(!this.value)return!1;const t=this.value.split(",").map(n=>parseInt(n.trim()));if(t.length!==3||t.some(isNaN))return!1;const[e,i,s]=t;return e>=0&&e<=255&&i>=0&&i<=255&&s>=0&&s<=255}}class w extends g{constructor(t){super(t),this.inputType="number",this.inputElement=null,this.mobileValue=t.mobile,this.validateProps(),this.value=this.validateValue(this.value)}draw(){const t=s=>{this.props.minValue!==void 0&&(s.min=String(this.props.minValue)),this.props.maxValue!==void 0&&(s.max=String(this.props.maxValue)),this.props.className&&s.classList.add(this.props.className),s.addEventListener("input",()=>{const n=this.props.minValue??Number.MIN_SAFE_INTEGER,a=this.props.maxValue??Number.MAX_SAFE_INTEGER;let o=Number(s.value);o<n&&(o=n),o>a&&(o=a),String(o)!==s.value&&(s.value=String(o)),this.setValue(o)}),s.addEventListener("blur",()=>{var a,o;const n=this.validateValue(Number(s.value));n!==Number(s.value)&&(s.value=String(n),this.setValue(n)),(o=(a=this.props).onBlur)==null||o.call(a)})},e=this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,icon:this.props.icon,inputClassName:"number-setting-input "+(this.props.inputClassName||""),wrapperClassName:"number-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:t});if(this.inputElement=e.querySelector("input.number-setting-input"),!this.props.suffix||this.props.suffix==="none")return e;e.classList.add("suffix-wrapper"),this.inputElement&&(this.inputElement.style.paddingRight="35px");const i=document.createElement("span");return i.className="suffix-label",i.textContent=this.props.suffix,e.appendChild(i),e}setValue(t){const e=this.validateValue(t);super.setValue(e),this.inputElement&&this.inputElement.value!==String(e)&&(this.inputElement.value=String(e??""))}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)}validateProps(){this.props.minValue!==void 0&&(this.props.default??0)<this.props.minValue&&console.warn(`Default value ${this.props.default} is less than minValue ${this.props.minValue}`),this.props.maxValue!==void 0&&(this.props.default??0)>this.props.maxValue&&console.warn(`Default value ${this.props.default} is greater than maxValue ${this.props.maxValue}`)}}const W=`
15
+ `,d.title=this.description,n.insertBefore(d,a)}}else{if(!h){const d=document.createElement("div");d.className="setting-group-description",d.textContent=this.description,o.insertBefore(d,o.firstChild)}u&&u.remove()}};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(this.settings.hasOwnProperty(h)){const u=this.settings[h];o.appendChild(u.draw())}}else{const h=document.createElement("div");h.className="setting-group-empty",h.textContent="No settings in this group",o.appendChild(h)}return e.appendChild(i),e.appendChild(n),t.appendChild(e),t.appendChild(o),this.elementRef=t,this.pendingBlurHandler&&(this.setupBlurHandlers(),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"))}updateVisibility(){this.elementRef&&this.hideCondition&&(this.elementRef.style.display=this.hideCondition()?"none":"")}toggle(){this.isHidden?this.show():this.hide()}getJson(){return JSON.stringify(this.getValues(),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")}}};f.hiddenElements=new Set;let m=f;function R(c){return new m(c)}function W(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 I="<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 V extends T{constructor(t){super({...t,icon:t.icon||I,title:t.title||"Color",default:t.default?V.normalizeRgbValue(t.default):t.default}),this.inputType="color",this.element=null,this.detectChange=t.detectChange}static normalizeRgbValue(t){const e=t.split(",").map(r=>parseInt(r.trim()));if(e.length!==3||e.some(isNaN))return console.warn(`Invalid RGB value "${t}", using default "0, 0, 0"`),"0, 0, 0";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));return`${a}, ${o}, ${l}`}setValue(t){if(t===void 0){super.setValue("");return}if(typeof t=="string"){const e=V.normalizeRgbValue(t);super.setValue(e)}else super.setValue("")}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}`}rgbToHex(t){const e=t.split(",").map(h=>parseInt(h.trim()));if(e.length!==3||e.some(isNaN))return"#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 u=h.toString(16);return u.length===1?"0"+u:u};return`#${r(a)}${r(o)}${r(l)}`}draw(){const t=document.createElement("div");t.className="color-setting-wrapper",this.element=t;const e=document.createElement("div");e.className="icon-container";const i=this.createIcon(this.props.icon||I),s=this.createLabel(this.title||"Color");e.appendChild(i),e.appendChild(s);const n=document.createElement("div");n.className="color-input-wrapper";const a=d=>{const C=d.value.trim();if(!C)return d.style.border="",!0;const p=C.split(",").map(x=>parseInt(x.trim()));if(p.length!==3||p.some(isNaN))return d.style.border="1px solid red",!1;const[v,b,H]=p,E=v>=0&&v<=255&&b>=0&&b<=255&&H>=0&&H<=255;return d.style.border=E?"":"1px solid red",E},o=document.createElement("div");o.className="color-preview",o.style.backgroundColor=this.value?`rgb(${this.value})`:"";const l=this.createInput({value:this.value,inputType:"text",inputClassName:"color-text-input"}),r=l.querySelector("input");r.readOnly=!0;const h=this.createInput({value:this.value?this.rgbToHex(this.value):"#000000",inputType:this.inputType,inputClassName:"color-picker"}),u=h.querySelector("input");return r.oninput=d=>{var p;let C=d.target.value.trim();a(r)&&(this.value=C,(p=this.onChange)==null||p.call(this,C),u.value=this.rgbToHex(C),o.style.backgroundColor=`rgb(${C})`)},u.oninput=d=>{var v,b;const C=d.target.value,p=this.hexToRgb(C);this.value=p,(v=this.onChange)==null||v.call(this,p),(b=this.detectChange)==null||b.call(this,p),r.value=p,o.style.backgroundColor=`rgb(${p})`},u.onchange=d=>{var v,b;const C=d.target.value,p=this.hexToRgb(C);this.value=p,(v=this.onChange)==null||v.call(this,p),(b=this.detectChange)==null||b.call(this,p),r.value=p,o.style.backgroundColor=`rgb(${p})`},n.appendChild(o),n.appendChild(h),n.appendChild(l),t.appendChild(e),t.appendChild(n),this.value&&(r.value=this.value,u.value=this.rgbToHex(this.value),o.style.backgroundColor=`rgb(${this.value})`),t}getElement(){return this.element}getNormalizedValue(){return this.value?V.normalizeRgbValue(this.value):"0, 0, 0"}isValidRgb(){if(!this.value)return!1;const t=this.value.split(",").map(n=>parseInt(n.trim()));if(t.length!==3||t.some(isNaN))return!1;const[e,i,s]=t;return e>=0&&e<=255&&i>=0&&i<=255&&s>=0&&s<=255}}class w extends g{constructor(t){super(t),this.inputType="number",this.inputElement=null,this.mobileValue=t.mobile,this.validateProps(),this.value=this.validateValue(this.value)}draw(){const t=s=>{this.props.minValue!==void 0&&(s.min=String(this.props.minValue)),this.props.maxValue!==void 0&&(s.max=String(this.props.maxValue)),this.props.className&&s.classList.add(this.props.className),s.addEventListener("input",()=>{const n=this.props.minValue??Number.MIN_SAFE_INTEGER,a=this.props.maxValue??Number.MAX_SAFE_INTEGER;let o=Number(s.value);o<n&&(o=n),o>a&&(o=a),String(o)!==s.value&&(s.value=String(o)),this.setValue(o)}),s.addEventListener("blur",()=>{var a,o;const n=this.validateValue(Number(s.value));n!==Number(s.value)&&(s.value=String(n),this.setValue(n)),(o=(a=this.props).onBlur)==null||o.call(a)})},e=this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,icon:this.props.icon,inputClassName:"number-setting-input "+(this.props.inputClassName||""),wrapperClassName:"number-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:t});if(this.inputElement=e.querySelector("input.number-setting-input"),!this.props.suffix||this.props.suffix==="none")return e;e.classList.add("suffix-wrapper"),this.inputElement&&(this.inputElement.style.paddingRight="35px");const i=document.createElement("span");return i.className="suffix-label",i.textContent=this.props.suffix,e.appendChild(i),e}setValue(t){const e=this.validateValue(t);super.setValue(e),this.inputElement&&this.inputElement.value!==String(e)&&(this.inputElement.value=String(e??""))}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)}validateProps(){this.props.minValue!==void 0&&(this.props.default??0)<this.props.minValue&&console.warn(`Default value ${this.props.default} is less than minValue ${this.props.minValue}`),this.props.maxValue!==void 0&&(this.props.default??0)>this.props.maxValue&&console.warn(`Default value ${this.props.default} is greater than maxValue ${this.props.maxValue}`)}}const _=`
16
16
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
17
17
  <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="1.5" stroke-linecap="round" stroke-linejoin="round"/>
18
18
  <path d="M9 1V17C4.58172 17 1 13.4183 1 9C1 4.58172 4.58172 1 9 1Z" fill="#667085" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
19
- </svg>`;class y extends w{constructor(t={}){const e={title:"Opacity",suffix:"%",minValue:0,maxValue:100,step:1,default:t.default??100,icon:W,...t};super(e),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}}const q=`
19
+ </svg>`;class y extends w{constructor(t={}){const e={title:"Opacity",suffix:"%",minValue:0,maxValue:100,step:1,default:t.default??100,icon:_,...t};super(e),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}}const D=`
20
20
  <svg xmlns="http://www.w3.org/2000/svg" class="svg-select" 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">
21
21
  <polyline points="6 9 12 15 18 9"></polyline>
22
22
  </svg>
23
- `;class N 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.clickOutsideListener=null,t.options&&(this._options=[...t.options]),t.getOptions&&this._options.push(...t.getOptions()),t.getOptionsAsync&&(this.isLoading=!0),this.value!==void 0){const e=this._options.findIndex(i=>i.value===this.value);e>=0&&(this.selectedOptionIndex=e)}}createOption(t,e){const i=document.createElement("li");return i.classList.add("select-option"),i.textContent=t.name,i.dataset.index=String(e),this.selectedOptionIndex===e&&i.classList.add("selected"),i}draw(){const t=document.createElement("div");if(t.classList.add("select-container"),this.container=t,this.props.icon||this.props.title){const n=document.createElement("div");if(n.className="icon-container",this.props.icon){const a=this.createIcon(this.props.icon);n.appendChild(a)}if(this.props.title){const a=this.createLabel(this.props.title);n.appendChild(a)}t.appendChild(n)}else{const n=document.createElement("div");t.appendChild(n)}const e=document.createElement("div");e.classList.add("select-button"),this.isLoading?e.classList.add("loading"):e.textContent=this.selectedOptionIndex!==null?this._options[this.selectedOptionIndex].name:this.props.placeholder||"Select an option",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-options"),this._options.forEach((n,a)=>{const o=this.createOption(n,a);o.onclick=l=>this.selectOption(l,a,e),i.appendChild(o)}),t.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=q,t.appendChild(s),this.optionsListEl=i,this.svgContainer=s,this.props.getOptionsAsync&&(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{this._options.push(...n),this.isLoading=!1,this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText("Failed to load options")})),this.clickOutsideListener&&document.removeEventListener("click",this.clickOutsideListener),this.clickOutsideListener=n=>{var a,o;this.isOpen&&!t.contains(n.target)&&(this.isOpen=!1,(a=this.optionsListEl)==null||a.classList.remove("open"),(o=this.svgContainer)==null||o.classList.remove("open"))},document.addEventListener("click",this.clickOutsideListener),t}selectOption(t,e,i){var n,a,o;const s=this._options[e];s&&(this.value=s.value,(n=this.onChange)==null||n.call(this,this.value),this.selectedOptionIndex=e,this.isOpen=!1,i.textContent=s.name,(a=this.optionsListEl)==null||a.classList.remove("open"),(o=this.svgContainer)==null||o.classList.remove("open"),this.optionsListEl&&this.optionsListEl.querySelectorAll(".select-option").forEach((r,h)=>{h===e?r.classList.add("selected"):r.classList.remove("selected")}))}updateOptionsList(){if(this.optionsListEl){if(this.optionsListEl.innerHTML="",this._options.length===0){const t=document.createElement("li");t.classList.add("select-option","empty-message"),t.textContent="No options available",this.optionsListEl.appendChild(t);return}this._options.forEach((t,e)=>{const i=this.createOption(t,e);i.onclick=s=>{this.buttonEl&&this.selectOption(s,e,this.buttonEl)},this.optionsListEl.appendChild(i)})}}updateButtonText(t){if(!this.buttonEl)return;if(this.isLoading){this.buttonEl.classList.add("loading"),this.buttonEl.textContent=this.props.loadingText||"Loading options...";return}this.buttonEl.classList.remove("loading","error");let e;t?((t.includes("Failed")||t.includes("Error"))&&this.buttonEl.classList.add("error"),e=t):this.selectedOptionIndex!==null&&this._options[this.selectedOptionIndex]?e=this._options[this.selectedOptionIndex].name:e=this.props.placeholder||"Select an option",this.buttonEl.textContent=e}destroy(){this.clickOutsideListener&&(document.removeEventListener("click",this.clickOutsideListener),this.clickOutsideListener=null),super.destroy()}}class A extends g{constructor(t={}){super(t),this.inputType="button",this.value||(this.value="center")}draw(){const t=document.createElement("div");t.className="align-setting-wrapper";const e=document.createElement("label");e.className="align-setting-label",e.textContent=this.title||"Align",t.appendChild(e);const i=document.createElement("div");return i.className="align-options-container",[{name:"left",icon:`
23
+ `;class N 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.clickOutsideListener=null,t.options&&(this._options=[...t.options]),t.getOptions&&this._options.push(...t.getOptions()),t.getOptionsAsync&&(this.isLoading=!0),this.value!==void 0){const e=this._options.findIndex(i=>i.value===this.value);e>=0&&(this.selectedOptionIndex=e)}}createOption(t,e){const i=document.createElement("li");return i.classList.add("select-option"),i.textContent=t.name,i.dataset.index=String(e),this.selectedOptionIndex===e&&i.classList.add("selected"),i}draw(){const t=document.createElement("div");if(t.classList.add("select-container"),this.container=t,this.props.icon||this.props.title){const n=document.createElement("div");if(n.className="icon-container",this.props.icon){const a=this.createIcon(this.props.icon);n.appendChild(a)}if(this.props.title){const a=this.createLabel(this.props.title);n.appendChild(a)}t.appendChild(n)}else{const n=document.createElement("div");t.appendChild(n)}const e=document.createElement("div");e.classList.add("select-button"),this.isLoading?e.classList.add("loading"):e.textContent=this.selectedOptionIndex!==null?this._options[this.selectedOptionIndex].name:this.props.placeholder||"Select an option",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-options"),this._options.forEach((n,a)=>{const o=this.createOption(n,a);o.onclick=l=>this.selectOption(l,a,e),i.appendChild(o)}),t.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=D,t.appendChild(s),this.optionsListEl=i,this.svgContainer=s,this.props.getOptionsAsync&&(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{this._options.push(...n),this.isLoading=!1,this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText("Failed to load options")})),this.clickOutsideListener&&document.removeEventListener("click",this.clickOutsideListener),this.clickOutsideListener=n=>{var a,o;this.isOpen&&!t.contains(n.target)&&(this.isOpen=!1,(a=this.optionsListEl)==null||a.classList.remove("open"),(o=this.svgContainer)==null||o.classList.remove("open"))},document.addEventListener("click",this.clickOutsideListener),t}selectOption(t,e,i){var n,a,o;const s=this._options[e];s&&(this.value=s.value,(n=this.onChange)==null||n.call(this,this.value),this.selectedOptionIndex=e,this.isOpen=!1,i.textContent=s.name,(a=this.optionsListEl)==null||a.classList.remove("open"),(o=this.svgContainer)==null||o.classList.remove("open"),this.optionsListEl&&this.optionsListEl.querySelectorAll(".select-option").forEach((r,h)=>{h===e?r.classList.add("selected"):r.classList.remove("selected")}))}updateOptionsList(){if(this.optionsListEl){if(this.optionsListEl.innerHTML="",this._options.length===0){const t=document.createElement("li");t.classList.add("select-option","empty-message"),t.textContent="No options available",this.optionsListEl.appendChild(t);return}this._options.forEach((t,e)=>{const i=this.createOption(t,e);i.onclick=s=>{this.buttonEl&&this.selectOption(s,e,this.buttonEl)},this.optionsListEl.appendChild(i)})}}updateButtonText(t){if(!this.buttonEl)return;if(this.isLoading){this.buttonEl.classList.add("loading"),this.buttonEl.textContent=this.props.loadingText||"Loading options...";return}this.buttonEl.classList.remove("loading","error");let e;t?((t.includes("Failed")||t.includes("Error"))&&this.buttonEl.classList.add("error"),e=t):this.selectedOptionIndex!==null&&this._options[this.selectedOptionIndex]?e=this._options[this.selectedOptionIndex].name:e=this.props.placeholder||"Select an option",this.buttonEl.textContent=e}destroy(){this.clickOutsideListener&&(document.removeEventListener("click",this.clickOutsideListener),this.clickOutsideListener=null),super.destroy()}}class A extends g{constructor(t={}){super(t),this.inputType="button",this.value||(this.value="center")}draw(){const t=document.createElement("div");t.className="align-setting-wrapper";const e=document.createElement("label");e.className="align-setting-label",e.textContent=this.title||"Align",t.appendChild(e);const i=document.createElement("div");return i.className="align-options-container",[{name:"left",icon:`
24
24
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
25
25
  <path d="M10.5 7.5C11.1989 7.5 11.5484 7.5 11.824 7.38582C12.1916 7.23358 12.4836 6.94157 12.6358 6.57402C12.75 6.29837 12.75 5.94891 12.75 5.25C12.75 4.55109 12.75 4.20163 12.6358 3.92598C12.4836 3.55843 12.1916 3.26642 11.824 3.11418C11.5484 3 11.1989 3 10.5 3L4.5 3C3.80109 3 3.45163 3 3.17598 3.11418C2.80843 3.26642 2.51642 3.55843 2.36418 3.92597C2.25 4.20163 2.25 4.55109 2.25 5.25C2.25 5.94891 2.25 6.29837 2.36418 6.57402C2.51642 6.94157 2.80843 7.23358 3.17598 7.38582C3.45163 7.5 3.80109 7.5 4.5 7.5L10.5 7.5Z"
26
26
  stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
@@ -41,7 +41,7 @@
41
41
  <path d="M13.5 15C14.1989 15 14.5484 15 14.824 14.8858C15.1916 14.7336 15.4836 14.4416 15.6358 14.074C15.75 13.7984 15.75 13.4489 15.75 12.75C15.75 12.0511 15.75 11.7016 15.6358 11.426C15.4836 11.0584 15.1916 10.7664 14.824 10.6142C14.5484 10.5 14.1989 10.5 13.5 10.5H4.5C3.80109 10.5 3.45163 10.5 3.17598 10.6142C2.80843 10.7664 2.51642 11.0584 2.36418 11.426C2.25 11.7016 2.25 12.0511 2.25 12.75C2.25 13.4489 2.25 13.7984 2.36418 14.074C2.51642 14.4416 2.80843 14.7336 3.17597 14.8858C3.45163 15 3.80109 15 4.5 15L13.5 15Z"
42
42
  stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
43
43
  </svg>
44
- `}].forEach(n=>{const a=document.createElement("button");a.className="align-option-button",a.innerHTML=n.icon,this.value===n.name&&a.classList.add("selected"),a.addEventListener("click",()=>{var o;i.querySelectorAll(".align-option-button").forEach(l=>l.classList.remove("selected")),a.classList.add("selected"),this.value=n.name,(o=this.onChange)==null||o.call(this,this.value)}),i.appendChild(a)}),t.appendChild(i),t}}class D extends g{constructor(t){super(t),this.inputType="button"}draw(){const t=document.createElement("button");t.className="button-setting "+(this.props.className||""),t.textContent=this.props.label,t.addEventListener("click",()=>{this.props.onClick&&this.props.onClick()});const e=document.createElement("div");return e.className="button-setting-wrapper "+(this.props.wrapperClassName||""),e.appendChild(t),e}}class z extends g{constructor(t={}){super(t),this.inputType={width:"number",height:"number"},this.aspectRatio=1,this.isUpdating=!1;const e=t.width||0,i=t.height||0;this.value||(this.value={width:e,height:i}),this.minWidth=t.minWidth??0,this.maxWidth=t.maxWidth,this.minHeight=t.minHeight??0,this.maxHeight=t.maxHeight,this.locked=t.locked??!1,this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.widthSetting=new w({title:"Width",default:this.value.width,suffix:"px",minValue:this.minWidth,maxValue:this.maxWidth,icon:F}),this.heightSetting=new w({title:"Height",default:this.value.height,suffix:"px",minValue:this.minHeight,maxValue:this.maxHeight,icon:U}),this.widthSetting.setOnChange(this.handleWidthChange.bind(this)),this.heightSetting.setOnChange(this.handleHeightChange.bind(this))}handleWidthChange(t){if(!this.isUpdating&&!isNaN(t)){this.maxWidth&&t>this.maxWidth&&(t=this.maxWidth),this.isUpdating=!0;try{let e=t,i=this.value.height;this.locked&&this.aspectRatio>0&&(i=Math.round(e/this.aspectRatio),this.maxHeight&&i>this.maxHeight&&(i=this.maxHeight,e=Math.round(i*this.aspectRatio),this.maxWidth&&e>this.maxWidth&&(e=this.maxWidth,i>0&&(this.aspectRatio=e/i)))),this.value={width:e,height:i},this.widthSetting.setValue(e),this.locked&&this.heightSetting.setValue(i),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}handleHeightChange(t){if(!this.isUpdating&&!isNaN(t)){this.maxHeight&&t>this.maxHeight&&(t=this.maxHeight),this.isUpdating=!0;try{let e=t,i=this.value.width;this.locked&&this.aspectRatio>0&&(i=Math.round(e*this.aspectRatio),this.maxWidth&&i>this.maxWidth&&(i=this.maxWidth,e=Math.round(i/this.aspectRatio),this.maxHeight&&e>this.maxHeight&&(e=this.maxHeight,e>0&&(this.aspectRatio=i/e)))),this.value={width:i,height:e},this.locked&&this.widthSetting.setValue(i),this.heightSetting.setValue(e),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}toggleLock(t){if(this.locked=!this.locked,this.locked&&this.value){const{width:i,height:s}=this.value;s>0&&(this.aspectRatio=i/s)}t.innerHTML=this.getLockSVG(this.locked),t.setAttribute("aria-pressed",String(this.locked)),t.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio";const e=t.closest(".dimension-setting-container");e&&(this.locked?e.classList.add("aspect-locked"):e.classList.remove("aspect-locked"))}getLockSVG(t){return t?`
44
+ `}].forEach(n=>{const a=document.createElement("button");a.className="align-option-button",a.innerHTML=n.icon,this.value===n.name&&a.classList.add("selected"),a.addEventListener("click",()=>{var o;i.querySelectorAll(".align-option-button").forEach(l=>l.classList.remove("selected")),a.classList.add("selected"),this.value=n.name,(o=this.onChange)==null||o.call(this,this.value)}),i.appendChild(a)}),t.appendChild(i),t}}class q extends g{constructor(t){super(t),this.inputType="button"}draw(){const t=document.createElement("button");t.className="button-setting "+(this.props.className||""),t.textContent=this.props.label,t.addEventListener("click",()=>{this.props.onClick&&this.props.onClick()});const e=document.createElement("div");return e.className="button-setting-wrapper "+(this.props.wrapperClassName||""),e.appendChild(t),e}}class z extends g{constructor(t={}){super(t),this.inputType={width:"number",height:"number"},this.aspectRatio=1,this.isUpdating=!1;const e=t.width||0,i=t.height||0;this.value||(this.value={width:e,height:i}),this.minWidth=t.minWidth??0,this.maxWidth=t.maxWidth,this.minHeight=t.minHeight??0,this.maxHeight=t.maxHeight,this.locked=t.locked??!1,this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.widthSetting=new w({title:"Width",default:this.value.width,suffix:"px",minValue:this.minWidth,maxValue:this.maxWidth,icon:F}),this.heightSetting=new w({title:"Height",default:this.value.height,suffix:"px",minValue:this.minHeight,maxValue:this.maxHeight,icon:U}),this.widthSetting.setOnChange(this.handleWidthChange.bind(this)),this.heightSetting.setOnChange(this.handleHeightChange.bind(this))}handleWidthChange(t){if(!this.isUpdating&&!isNaN(t)){this.maxWidth&&t>this.maxWidth&&(t=this.maxWidth),this.isUpdating=!0;try{let e=t,i=this.value.height;this.locked&&this.aspectRatio>0&&(i=Math.round(e/this.aspectRatio),this.maxHeight&&i>this.maxHeight&&(i=this.maxHeight,e=Math.round(i*this.aspectRatio),this.maxWidth&&e>this.maxWidth&&(e=this.maxWidth,i>0&&(this.aspectRatio=e/i)))),this.value={width:e,height:i},this.widthSetting.setValue(e),this.locked&&this.heightSetting.setValue(i),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}handleHeightChange(t){if(!this.isUpdating&&!isNaN(t)){this.maxHeight&&t>this.maxHeight&&(t=this.maxHeight),this.isUpdating=!0;try{let e=t,i=this.value.width;this.locked&&this.aspectRatio>0&&(i=Math.round(e*this.aspectRatio),this.maxWidth&&i>this.maxWidth&&(i=this.maxWidth,e=Math.round(i/this.aspectRatio),this.maxHeight&&e>this.maxHeight&&(e=this.maxHeight,e>0&&(this.aspectRatio=i/e)))),this.value={width:i,height:e},this.locked&&this.widthSetting.setValue(i),this.heightSetting.setValue(e),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}toggleLock(t){if(this.locked=!this.locked,this.locked&&this.value){const{width:i,height:s}=this.value;s>0&&(this.aspectRatio=i/s)}t.innerHTML=this.getLockSVG(this.locked),t.setAttribute("aria-pressed",String(this.locked)),t.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio";const e=t.closest(".dimension-setting-container");e&&(this.locked?e.classList.add("aspect-locked"):e.classList.remove("aspect-locked"))}getLockSVG(t){return t?`
45
45
  <svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none">
46
46
  <path d="M2.91663 4.58333V3.33333C2.91663 2.18274 3.84937 1.25 4.99996 1.25C6.00786 1.25 6.84859 1.96573 7.04162 2.91667M3.66663 8.75H6.33329C7.03336 8.75 7.38339 8.75 7.65078 8.61376C7.88598 8.49392 8.07721 8.30269 8.19705 8.06749C8.33329 7.8001 8.33329 7.45007 8.33329 6.75V6.58333C8.33329 5.88327 8.33329 5.53323 8.19705 5.26584C8.07721 5.03064 7.88598 4.83942 7.65078 4.71958C7.38339 4.58333 7.03336 4.58333 6.33329 4.58333H3.66663C2.96656 4.58333 2.61653 4.58333 2.34914 4.71958C2.11394 4.83942 1.92271 5.03064 1.80287 5.26584C1.66663 5.53323 1.66663 5.88327 1.66663 6.58333V6.75C1.66663 7.45007 1.66663 7.8001 1.80287 8.06749C1.92271 8.30269 2.11394 8.49392 2.34914 8.61376C2.61653 8.75 2.96656 8.75 3.66663 8.75Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
47
47
  </svg>`:`
@@ -73,7 +73,7 @@
73
73
  `))}draw(){const t=document.createElement("div");t.className="upload-setting-wrapper",t.setAttribute("data-setting-id",this.id),t.addEventListener("focusout",l=>{var r;l.relatedTarget&&t.contains(l.relatedTarget)||(r=this.onBlur)==null||r.call(this,this.value??"")},!0);const e=!!(this.props.title||this.props.icon);if(e||t.classList.add("no-label"),e){const l=document.createElement("div");if(l.className="icon-title-container",this.props.icon){const r=this.createIcon(this.props.icon);l.appendChild(r)}if(this.props.title){const r=this.createLabel(this.props.title);l.appendChild(r)}t.appendChild(l)}const i=document.createElement("div");i.className="preview-button-container";const s=this.value&&this.value!=="";s||i.classList.add("no-image");const n=document.createElement("div");if(n.className="preview-placeholder",n.innerHTML=P,this.previewWrapper=document.createElement("div"),this.previewWrapper.className="preview-wrapper",this.previewEl=document.createElement("img"),this.previewEl.className="upload-preview",this.props.delete){const l=document.createElement("button");l.className="delete-button",l.type="button",l.title="Delete image",l.innerHTML=J,this.previewWrapper.appendChild(l),l.onclick=r=>{var h;r.stopPropagation(),this.value="",o.value="",this.updatePreviewState(null),(h=this.onChange)==null||h.call(this,"")}}this.previewWrapper.appendChild(this.previewEl);const a=document.createElement("button");a.className="upload-button",a.innerHTML=`
74
74
  <span class="upload-icon">${O}</span>
75
75
  <span class="upload-label">Upload</span>
76
- `;const o=document.createElement("input");return o.type="file",o.accept="image/*",o.style.display="none",i.appendChild(n),i.appendChild(this.previewWrapper),i.appendChild(a),t.appendChild(i),t.appendChild(o),s?this.updatePreviewState(this.value):this.updatePreviewState(null),a.onclick=()=>{o.click()},o.onchange=async()=>{var r,h,u;const l=(r=o.files)==null?void 0:r[0];if(l)try{a.classList.add("loading"),a.disabled=!0;const d=new FormData,f=this.props.formFieldName||"file";d.append(f,l,l.name);const p=this.props.uploadUrl;if(!p)throw new Error("No uploadUrl provided to UploadSetting.");const v=this.props.requestMethod||"POST",b={...this.props.requestHeaders||{}},E=await(await fetch(p,{method:v,body:d,headers:b})).json();console.log("Upload response:",E);let x;if(this.props.parseResponse)x=this.props.parseResponse(E);else if(x=(h=E==null?void 0:E.data)==null?void 0:h.url,!x)throw new Error("No URL found in response. Provide a parseResponse if needed.");console.log("Final URL:",x),this.value=x,this.updatePreviewState(x),(u=this.onChange)==null||u.call(this,x)}catch(d){console.error("Error uploading file:",d)}finally{a.classList.remove("loading"),a.disabled=!1,o.value=""}else o.value=""},t}}class Z extends w{constructor(t={}){const e={title:t.title||"Height",suffix:"px",minValue:t.minValue??0,maxValue:t.maxValue,icon:t.icon||X,...t};super(e),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}}const X=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
76
+ `;const o=document.createElement("input");return o.type="file",o.accept="image/*",o.style.display="none",i.appendChild(n),i.appendChild(this.previewWrapper),i.appendChild(a),t.appendChild(i),t.appendChild(o),s?this.updatePreviewState(this.value):this.updatePreviewState(null),a.onclick=()=>{o.click()},o.onchange=async()=>{var r,h,u;const l=(r=o.files)==null?void 0:r[0];if(l)try{a.classList.add("loading"),a.disabled=!0;const d=new FormData,C=this.props.formFieldName||"file";d.append(C,l,l.name);const p=this.props.uploadUrl;if(!p)throw new Error("No uploadUrl provided to UploadSetting.");const v=this.props.requestMethod||"POST",b={...this.props.requestHeaders||{}},E=await(await fetch(p,{method:v,body:d,headers:b})).json();console.log("Upload response:",E);let x;if(this.props.parseResponse)x=this.props.parseResponse(E);else if(x=(h=E==null?void 0:E.data)==null?void 0:h.url,!x)throw new Error("No URL found in response. Provide a parseResponse if needed.");console.log("Final URL:",x),this.value=x,this.updatePreviewState(x),(u=this.onChange)==null||u.call(this,x)}catch(d){console.error("Error uploading file:",d)}finally{a.classList.remove("loading"),a.disabled=!1,o.value=""}else o.value=""},t}}class Z extends w{constructor(t={}){const e={title:t.title||"Height",suffix:"px",minValue:t.minValue??0,maxValue:t.maxValue,icon:t.icon||X,...t};super(e),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}}const X=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
77
77
  <path d="M9 14L9 5M9 14L6.75 12.5M9 14L11.25 12.5M9 5L6.75 6.5M9 5L11.25 6.5M15.75 2.75H2.25M15.75 16.25H2.25" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
78
78
  </svg>`;class K extends w{constructor(t={}){super({title:t.title||"Width",suffix:"px",minValue:t.minValue??0,maxValue:t.maxValue,icon:t.icon||Q,...t}),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}}const Q=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
79
79
  <path d="M4.5 9.5H13.5M4.5 9.5L6 7.25M4.5 9.5L6 11.75M13.5 9.5L12 7.25M13.5 9.5L12 11.75M15.75 16.25V2.75M2.25 16.25V2.75" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
@@ -166,4 +166,4 @@
166
166
  </svg>
167
167
  </span>
168
168
  <span class="add-label">Add Tab</span>
169
- `,i.onclick=()=>{this.addTab(),this.rerender()},e.appendChild(i),t.appendChild(e),t}rerender(){if(!this._el)return;const t=this._el.querySelector(".setting-group-content");t&&(t.innerHTML="",Object.keys(this.settings).forEach(e=>{const i=this.settings[e];t.appendChild(i.draw())}))}}function xt(c){return c instanceof m}function Et(c){return c instanceof g}exports.AlignSetting=A;exports.BackgroundSettingSet=vt;exports.BorderSettingSet=rt;exports.ButtonSetting=D;exports.ColorSetting=V;exports.DimensionSetting=z;exports.GapSetting=st;exports.HeaderTypographySettingSet=ut;exports.HeightSetting=Z;exports.MarginBottomSetting=at;exports.MarginSettingGroup=pt;exports.NumberSetting=w;exports.OpacitySetting=y;exports.SelectApiSettings=tt;exports.SelectSetting=N;exports.Setting=g;exports.SettingGroup=m;exports.StringSetting=T;exports.TabsContainerGroup=wt;exports.TabsSettings=k;exports.Toggle=et;exports.UploadSetting=$;exports.WidthSetting=K;exports.asSettingGroupWithSettings=_;exports.createSettingGroup=R;exports.isSetting=Et;exports.isSettingGroup=xt;exports.iterateSettings=L;
169
+ `,i.onclick=()=>{this.addTab(),this.rerender()},e.appendChild(i),t.appendChild(e),t}rerender(){if(!this._el)return;const t=this._el.querySelector(".setting-group-content");t&&(t.innerHTML="",Object.keys(this.settings).forEach(e=>{const i=this.settings[e];t.appendChild(i.draw())}))}}function xt(c){return c instanceof m}function Et(c){return c instanceof g}exports.AlignSetting=A;exports.BackgroundSettingSet=vt;exports.BorderSettingSet=rt;exports.ButtonSetting=q;exports.ColorSetting=V;exports.DimensionSetting=z;exports.GapSetting=st;exports.HeaderTypographySettingSet=ut;exports.HeightSetting=Z;exports.MarginBottomSetting=at;exports.MarginSettingGroup=pt;exports.NumberSetting=w;exports.OpacitySetting=y;exports.SelectApiSettings=tt;exports.SelectSetting=N;exports.Setting=g;exports.SettingGroup=m;exports.StringSetting=T;exports.TabsContainerGroup=wt;exports.TabsSettings=k;exports.Toggle=et;exports.UploadSetting=$;exports.WidthSetting=K;exports.asSettingGroupWithSettings=W;exports.createSettingGroup=R;exports.isSetting=Et;exports.isSettingGroup=xt;exports.iterateSettings=L;
@@ -5,7 +5,7 @@ let B = (c = 21) => {
5
5
  t += R[e[c] & 63];
6
6
  return t;
7
7
  };
8
- function y(c) {
8
+ function M(c) {
9
9
  if (c === null || typeof c != "object")
10
10
  return c;
11
11
  if (c instanceof Date)
@@ -13,12 +13,12 @@ function y(c) {
13
13
  if (Array.isArray(c)) {
14
14
  const i = [];
15
15
  for (let s = 0; s < c.length; s++)
16
- i[s] = y(c[s]);
16
+ i[s] = M(c[s]);
17
17
  return i;
18
18
  }
19
19
  const t = {};
20
20
  for (const i in c)
21
- Object.prototype.hasOwnProperty.call(c, i) && (t[i] = y(c[i]));
21
+ Object.prototype.hasOwnProperty.call(c, i) && (t[i] = M(c[i]));
22
22
  const e = Object.getPrototypeOf(c);
23
23
  return e !== Object.prototype && Object.setPrototypeOf(t, e), t;
24
24
  }
@@ -58,8 +58,8 @@ class g {
58
58
  }
59
59
  // Basic clone method
60
60
  clone() {
61
- const t = this.constructor, e = y(this.props), i = new t(e);
62
- return i.value = y(this.value), i;
61
+ const t = this.constructor, e = M(this.props), i = new t(e);
62
+ return i.value = M(this.value), i;
63
63
  }
64
64
  createInput(t) {
65
65
  t = { ...this.props.inputProps, ...t };
@@ -127,10 +127,10 @@ function S(c, t) {
127
127
  t(e, i);
128
128
  }
129
129
  }
130
- const C = class C {
130
+ const f = class f {
131
131
  constructor(t) {
132
132
  this.elementRef = null, this.isHidden = !1, this.custom = !1, this.initialValues = {}, this.changeTimeout = null, this.isHandlingChange = !1, this.changeHandlers = /* @__PURE__ */ new Set(), this.blurTimeout = null, this.lastValues = {}, this.lastChangeTime = 0, this.CHANGE_DEBOUNCE = 100, this.handleBlur = () => {
133
- }, this.pendingBlurHandler = null, this.id = t.id || B(), this.title = t.title, this.settings = t.settings, this.description = t.description, this.icon = t.icon, this.isCollapsed = t.collapsed ?? !1, this.isMain = t.main ?? !1, this.custom = t.custom ?? !1, this.hideCondition = t.hideCondition, this.onBlur = t.onBlur, Object.assign(this, t.settings), this.initialValues = this.getValues();
133
+ }, this.pendingBlurHandler = null, this.originalDefaultValues = {}, this.id = t.id || B(), this.title = t.title, this.settings = t.settings, this.description = t.description, this.icon = t.icon, this.isCollapsed = t.collapsed ?? !1, this.isMain = t.main ?? !1, this.custom = t.custom ?? !1, this.hideCondition = t.hideCondition, this.onBlur = t.onBlur, Object.assign(this, t.settings), this.initialValues = this.getValues(), this.originalDefaultValues = this.getDefaultValues();
134
134
  }
135
135
  static hide() {
136
136
  this.hiddenElements.forEach((t) => {
@@ -155,7 +155,7 @@ const C = class C {
155
155
  };
156
156
  return this.changeHandlers.clear(), S(this.settings, (i, s) => {
157
157
  var n;
158
- if (s instanceof C)
158
+ if (s instanceof f)
159
159
  s.setOnChange((a) => {
160
160
  const o = this.getValues();
161
161
  this.initialValues = o, t(o);
@@ -190,7 +190,7 @@ const C = class C {
190
190
  !0
191
191
  ), S(this.settings, (t, e) => {
192
192
  var i;
193
- if (e instanceof C)
193
+ if (e instanceof f)
194
194
  e.setOnBlur(this.handleBlur);
195
195
  else {
196
196
  const s = (i = this.elementRef) == null ? void 0 : i.querySelector(
@@ -233,7 +233,7 @@ const C = class C {
233
233
  if (!t || typeof t != "object") return;
234
234
  Object.entries(t).forEach(([i, s]) => {
235
235
  const n = this.settings[i];
236
- n && (n instanceof C || n instanceof g) && typeof n.setValue == "function" && n.setValue(s);
236
+ n && (n instanceof f || n instanceof g) && typeof n.setValue == "function" && n.setValue(s);
237
237
  });
238
238
  const e = this.getValues();
239
239
  this.initialValues = e, this.onChange && this.onChange(e);
@@ -263,12 +263,26 @@ const C = class C {
263
263
  for (const i in this.settings)
264
264
  if (this.settings.hasOwnProperty(i)) {
265
265
  const s = this.settings[i];
266
- s instanceof C ? e[i] = s.getValues() : e[i] = s.value;
266
+ s instanceof f ? e[i] = s.getValues() : e[i] = s.value;
267
267
  }
268
268
  return e;
269
269
  } else {
270
270
  const e = this.settings[t];
271
- return e ? e instanceof C ? e.getValues() : e.value : void 0;
271
+ return e ? e instanceof f ? e.getValues() : e.value : void 0;
272
+ }
273
+ }
274
+ getDefaultValues(t) {
275
+ if (t === void 0) {
276
+ const e = {};
277
+ for (const i in this.settings)
278
+ if (this.settings.hasOwnProperty(i)) {
279
+ const s = this.settings[i];
280
+ s instanceof f ? e[i] = s.getDefaultValues() : e[i] = s.default !== void 0 ? s.default : s.value;
281
+ }
282
+ return e;
283
+ } else {
284
+ const e = this.settings[t];
285
+ return e ? e instanceof f ? e.getDefaultValues() : e.default !== void 0 ? e.default : e.value : void 0;
272
286
  }
273
287
  }
274
288
  getMobileValues(t) {
@@ -277,38 +291,46 @@ const C = class C {
277
291
  for (const i in this.settings)
278
292
  if (this.settings.hasOwnProperty(i)) {
279
293
  const s = this.settings[i];
280
- if (s instanceof C)
294
+ if (s instanceof f)
281
295
  e[i] = s.getMobileValues();
282
296
  else if (typeof s.getMobileValue == "function") {
283
297
  const n = s.getMobileValue();
284
298
  e[i] = n !== void 0 ? n : s.value;
285
- }
299
+ } else
300
+ e[i] = s.value;
286
301
  }
287
302
  return e;
288
303
  } else {
289
304
  const e = this.settings[t];
290
305
  if (!e) return;
291
- if (e instanceof C)
306
+ if (e instanceof f)
292
307
  return e.getMobileValues();
293
308
  if (typeof e.getMobileValue == "function") {
294
309
  const i = e.getMobileValue();
295
310
  return i !== void 0 ? i : e.value;
296
- }
297
- return;
311
+ } else
312
+ return e.value;
298
313
  }
299
314
  }
300
315
  setMobileValues(t) {
301
316
  if (!(!t || typeof t != "object") && (Object.entries(t).forEach(([e, i]) => {
302
317
  const s = this.settings[e];
303
- s && (s instanceof C ? typeof i == "object" && i !== null && s.setMobileValues(i) : typeof s.setMobileValue == "function" && s.setMobileValue(i));
318
+ s && (s instanceof f ? typeof i == "object" && i !== null && s.setMobileValues(i) : typeof s.setMobileValue == "function" && s.setMobileValue(i));
304
319
  }), this.setValue(t), this.onChange)) {
305
320
  const e = this.getValues();
306
321
  this.onChange(e);
307
322
  }
308
323
  }
324
+ resetDefault() {
325
+ const t = this.originalDefaultValues;
326
+ if (this.setValue(t), this.onChange) {
327
+ const e = this.getValues();
328
+ this.onChange(e);
329
+ }
330
+ }
309
331
  draw() {
310
332
  const t = document.createElement("div");
311
- t.className = "setting-group", t.id = `setting-group-${this.id}`, C.hiddenElements.add(t), this.hideCondition && this.hideCondition() && (t.style.display = "none"), this.isMain && t.classList.add("main-group");
333
+ t.className = "setting-group", t.id = `setting-group-${this.id}`, f.hiddenElements.add(t), this.hideCondition && this.hideCondition() && (t.style.display = "none"), this.isMain && t.classList.add("main-group");
312
334
  const e = document.createElement("div");
313
335
  e.className = "setting-group-title", this.isCollapsed && e.classList.add("collapsed-view"), e.setAttribute("role", "button"), e.setAttribute(
314
336
  "aria-expanded",
@@ -431,8 +453,8 @@ const C = class C {
431
453
  }
432
454
  }
433
455
  };
434
- C.hiddenElements = /* @__PURE__ */ new Set();
435
- let m = C;
456
+ f.hiddenElements = /* @__PURE__ */ new Set();
457
+ let m = f;
436
458
  function $(c) {
437
459
  return new m(c);
438
460
  }
@@ -513,10 +535,10 @@ class V extends O {
513
535
  const n = document.createElement("div");
514
536
  n.className = "color-input-wrapper";
515
537
  const a = (d) => {
516
- const f = d.value.trim();
517
- if (!f)
538
+ const C = d.value.trim();
539
+ if (!C)
518
540
  return d.style.border = "", !0;
519
- const p = f.split(",").map((w) => parseInt(w.trim()));
541
+ const p = C.split(",").map((w) => parseInt(w.trim()));
520
542
  if (p.length !== 3 || p.some(isNaN))
521
543
  return d.style.border = "1px solid red", !1;
522
544
  const [v, b, T] = p, E = v >= 0 && v <= 255 && b >= 0 && b <= 255 && T >= 0 && T <= 255;
@@ -540,15 +562,15 @@ class V extends O {
540
562
  );
541
563
  return r.oninput = (d) => {
542
564
  var p;
543
- let f = d.target.value.trim();
544
- a(r) && (this.value = f, (p = this.onChange) == null || p.call(this, f), u.value = this.rgbToHex(f), o.style.backgroundColor = `rgb(${f})`);
565
+ let C = d.target.value.trim();
566
+ a(r) && (this.value = C, (p = this.onChange) == null || p.call(this, C), u.value = this.rgbToHex(C), o.style.backgroundColor = `rgb(${C})`);
545
567
  }, u.oninput = (d) => {
546
568
  var v, b;
547
- const f = d.target.value, p = this.hexToRgb(f);
569
+ const C = d.target.value, p = this.hexToRgb(C);
548
570
  this.value = p, (v = this.onChange) == null || v.call(this, p), (b = this.detectChange) == null || b.call(this, p), r.value = p, o.style.backgroundColor = `rgb(${p})`;
549
571
  }, u.onchange = (d) => {
550
572
  var v, b;
551
- const f = d.target.value, p = this.hexToRgb(f);
573
+ const C = d.target.value, p = this.hexToRgb(C);
552
574
  this.value = p, (v = this.onChange) == null || v.call(this, p), (b = this.detectChange) == null || b.call(this, p), r.value = p, o.style.backgroundColor = `rgb(${p})`;
553
575
  }, n.appendChild(o), n.appendChild(h), n.appendChild(l), t.appendChild(e), t.appendChild(n), this.value && (r.value = this.value, u.value = this.rgbToHex(this.value), o.style.backgroundColor = `rgb(${this.value})`), t;
554
576
  }
@@ -823,7 +845,7 @@ class ht extends g {
823
845
  suffix: "px",
824
846
  minValue: this.minHeight,
825
847
  maxValue: this.maxHeight,
826
- icon: q
848
+ icon: D
827
849
  }), this.widthSetting.setOnChange(this.handleWidthChange.bind(this)), this.heightSetting.setOnChange(this.handleHeightChange.bind(this));
828
850
  }
829
851
  handleWidthChange(t) {
@@ -917,13 +939,13 @@ class ht extends g {
917
939
  }
918
940
  const G = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
919
941
  <path d="M4.5 9.5H13.5M4.5 9.5L6 7.25M4.5 9.5L6 11.75M13.5 9.5L12 7.25M13.5 9.5L12 11.75M15.75 16.25V2.75M2.25 16.25V2.75" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
920
- </svg>`, q = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
942
+ </svg>`, D = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
921
943
  <path d="M9 14L9 5M9 14L6.75 12.5M9 14L11.25 12.5M9 5L6.75 6.5M9 5L11.25 6.5M15.75 2.75H2.25M15.75 16.25H2.25" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
922
944
  </svg>`, H = `
923
945
  <svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
924
946
  <path d="M5 10.5L7.5 8M7.5 8L10 10.5M7.5 8V13.625M12.5 10.9643C13.2634 10.3338 13.75 9.37996 13.75 8.3125C13.75 6.41402 12.211 4.875 10.3125 4.875C10.1759 4.875 10.0482 4.80375 9.97882 4.68609C9.16379 3.30302 7.65902 2.375 5.9375 2.375C3.34867 2.375 1.25 4.47367 1.25 7.0625C1.25 8.35381 1.77215 9.52317 2.61684 10.371" stroke="#475467" stroke-linecap="round" stroke-linejoin="round"/>
925
947
  </svg>
926
- `, D = `
948
+ `, q = `
927
949
  <svg width="91" height="71" viewBox="0 0 91 71" fill="none" xmlns="http://www.w3.org/2000/svg">
928
950
  <rect width="91" height="71" rx="4" fill="#F2F4F7"/>
929
951
  <path d="M37 31.5L39.5 29M39.5 29L42 31.5M39.5 29V34.625M44.5 31.9643C45.2634 31.3338 45.75 30.38 45.75 29.3125C45.75 27.414 44.211 25.875 42.3125 25.875C42.1759 25.875 42.0482 25.8037 41.9788 25.6861C41.1638 24.303 39.659 23.375 37.9375 23.375C35.3487 23.375 33.25 25.4737 33.25 28.0625C33.25 29.3538 33.7721 30.5232 34.6168 31.371" stroke="#475467" stroke-linecap="round" stroke-linejoin="round"/>
@@ -978,7 +1000,7 @@ class F extends g {
978
1000
  const s = this.value && this.value !== "";
979
1001
  s || i.classList.add("no-image");
980
1002
  const n = document.createElement("div");
981
- if (n.className = "preview-placeholder", n.innerHTML = D, this.previewWrapper = document.createElement("div"), this.previewWrapper.className = "preview-wrapper", this.previewEl = document.createElement("img"), this.previewEl.className = "upload-preview", this.props.delete) {
1003
+ if (n.className = "preview-placeholder", n.innerHTML = q, this.previewWrapper = document.createElement("div"), this.previewWrapper.className = "preview-wrapper", this.previewEl = document.createElement("img"), this.previewEl.className = "upload-preview", this.props.delete) {
982
1004
  const l = document.createElement("button");
983
1005
  l.className = "delete-button", l.type = "button", l.title = "Delete image", l.innerHTML = z, this.previewWrapper.appendChild(l), l.onclick = (r) => {
984
1006
  var h;
@@ -1000,8 +1022,8 @@ class F extends g {
1000
1022
  if (l)
1001
1023
  try {
1002
1024
  a.classList.add("loading"), a.disabled = !0;
1003
- const d = new FormData(), f = this.props.formFieldName || "file";
1004
- d.append(f, l, l.name);
1025
+ const d = new FormData(), C = this.props.formFieldName || "file";
1026
+ d.append(C, l, l.name);
1005
1027
  const p = this.props.uploadUrl;
1006
1028
  if (!p)
1007
1029
  throw new Error("No uploadUrl provided to UploadSetting.");
@@ -1705,7 +1727,7 @@ class Ct extends m {
1705
1727
  `;
1706
1728
  }
1707
1729
  }
1708
- class M extends g {
1730
+ class y extends g {
1709
1731
  constructor(t) {
1710
1732
  super({
1711
1733
  ...t,
@@ -1758,25 +1780,25 @@ class vt extends m {
1758
1780
  collapsed: t == null ? void 0 : t.collapsed,
1759
1781
  hideCondition: t == null ? void 0 : t.hideCondition,
1760
1782
  settings: {
1761
- marginTop: new M({
1783
+ marginTop: new y({
1762
1784
  title: "Top",
1763
1785
  icon: it,
1764
1786
  suffix: "px",
1765
1787
  default: (t == null ? void 0 : t.marginTop) ?? "auto"
1766
1788
  }),
1767
- marginRight: new M({
1789
+ marginRight: new y({
1768
1790
  title: "Right",
1769
1791
  icon: st,
1770
1792
  suffix: "px",
1771
1793
  default: (t == null ? void 0 : t.marginRight) ?? 0
1772
1794
  }),
1773
- marginBottom: new M({
1795
+ marginBottom: new y({
1774
1796
  title: "Bottom",
1775
1797
  icon: nt,
1776
1798
  suffix: "px",
1777
1799
  default: (t == null ? void 0 : t.marginBottom) ?? 0
1778
1800
  }),
1779
- marginLeft: new M({
1801
+ marginLeft: new y({
1780
1802
  title: "Left",
1781
1803
  icon: at,
1782
1804
  suffix: "px",
package/dist/index.d.ts CHANGED
@@ -474,6 +474,7 @@ export declare class SettingGroup<T extends Record<string, Setting<any, any> | S
474
474
  private readonly CHANGE_DEBOUNCE;
475
475
  private handleBlur;
476
476
  private pendingBlurHandler;
477
+ private originalDefaultValues;
477
478
  constructor(groupProps: SettingGroupProps<T>);
478
479
  static hide(): void;
479
480
  static show(): void;
@@ -487,8 +488,10 @@ export declare class SettingGroup<T extends Record<string, Setting<any, any> | S
487
488
  hide(): void;
488
489
  show(): void;
489
490
  getValues<K extends keyof T>(childKey?: K): any;
491
+ getDefaultValues<K extends keyof T>(childKey?: K): any;
490
492
  getMobileValues<K extends keyof T>(childKey?: K): any;
491
493
  setMobileValues(values: Record<string, any>): void;
494
+ resetDefault(): void;
492
495
  draw(): HTMLElement;
493
496
  collapse(): void;
494
497
  expand(): void;
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.164",
4
+ "version": "0.0.166",
5
5
  "type": "module",
6
6
  "main": "dist/builder-settings-types.cjs.js",
7
7
  "module": "dist/builder-settings-types.es.js",