builder-settings-types 0.0.295 → 0.0.296
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.
|
@@ -84,15 +84,15 @@
|
|
|
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"/>
|
|
86
86
|
<path d="M9 1V17C4.58172 17 1 13.4183 1 9C1 4.58172 4.58172 1 9 1Z" fill="#667085" stroke="#667085" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5"/>
|
|
87
|
-
</svg>`;class $ extends b{constructor(t={}){super({...t,icon:t.icon||It,title:t.title||"Color & Opacity",default:t.default||"#000000FF"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.opacityInputEl=null,this.colorPreviewEl=null,this.detectChange=t.detectChange,this.value&&(this.value=$.normalizeHexWithOpacity(this.value))}static normalizeHexWithOpacity(t){return t=t.replace("#",""),t.length===3&&(t=t.split("").map(e=>e+e).join("")),t.length===6&&(t=t+"FF"),t.length===8&&/^[0-9A-Fa-f]{8}$/.test(t)?`#${t.toUpperCase()}`:(console.warn(`Invalid hex value "${t}", using default "#000000FF"`),"#000000FF")}getRgbColor(){return this.value?this.value.substring(0,7):"#000000"}getOpacityPercent(){if(!this.value)return 100;const t=this.value.substring(7,9),e=parseInt(t,16)/255;return Math.round(e*100)}static combineColorOpacity(t,e){const i=t.replace("#","").substring(0,6),n=Math.round(e/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${i}${n}`}setValue(t){t===void 0||t===""?this.value="#000000FF":this.value=$.normalizeHexWithOpacity(t),this.updateInputElements(),this.updateColorPreview(),this.onChange&&this.onChange(this.value),this.detectChange&&this.detectChange(this.value)}updateInputElements(){this.value&&(this.colorInputEl&&(this.colorInputEl.value=this.getRgbColor()),this.textInputEl&&(this.textInputEl.value=this.value),this.opacityInputEl&&(this.opacityInputEl.value=this.getOpacityPercent().toString()))}updateColorPreview(){if(!this.colorPreviewEl||!this.value)return;const t=this.getRgbColor(),e=this.getOpacityPercent()/100,i=t.replace("#",""),s=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);this.colorPreviewEl.style.backgroundColor=`rgba(${s}, ${n}, ${o}, ${e})`}handleColorChange(t){const e=this.getOpacityPercent(),i=$.combineColorOpacity(t,e);this.setValue(i)}handleTextInput(t){const e=/^#[0-9A-Fa-f]{8}$/.test(t.trim()),i=/^#[0-9A-Fa-f]{6}$/.test(t.trim());return e||i?(this.setValue(t),!0):!1}handleOpacityChange(t){const e=this.getRgbColor(),i=Math.max(0,Math.min(100,t)),s=$.combineColorOpacity(e,i);this.setValue(s)}draw(){const t=document.createElement("div");if(t.className="color-with-opacity-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const o=document.createElement("div");if(o.className="icon-container",this.props.icon){const a=document.createElement("span");a.className="input-icon",a.innerHTML=this.props.icon,o.appendChild(a)}if(this.props.title){const a=document.createElement("span");a.className="input-label",a.textContent=this.props.title,o.appendChild(a)}t.appendChild(o)}const e=document.createElement("div");e.className="color-with-opacity-input-wrapper",this.colorInputEl=document.createElement("input"),this.colorInputEl.type="color",this.colorInputEl.className="color-with-opacity-picker",this.getDataPropsPath()&&this.colorInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_color`),this.colorPreviewEl=document.createElement("div"),this.colorPreviewEl.className="color-with-opacity-preview",this.textInputEl=document.createElement("input"),this.textInputEl.type="text",this.textInputEl.className="color-with-opacity-text-input",this.textInputEl.placeholder="#000000FF",this.getDataPropsPath()&&this.textInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.updateInputElements(),this.updateColorPreview(),this.colorInputEl.addEventListener("input",o=>{const a=o.target;this.handleColorChange(a.value),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview()}),this.textInputEl.addEventListener("input",o=>{const a=o.target;this.handleTextInput(a.value)?(this.colorInputEl&&(this.colorInputEl.value=this.getRgbColor()),this.updateColorPreview(),e.classList.remove("error")):a.value.trim()===""?e.classList.remove("error"):e.classList.add("error")}),this.textInputEl.addEventListener("blur",o=>{const a=o.target;a.value.trim()===""&&(a.value=this.value||"#000000FF",e.classList.remove("error"))}),this.colorPreviewEl.addEventListener("click",()=>{var o;(o=this.colorInputEl)==null||o.click()}),e.appendChild(this.colorInputEl),e.appendChild(this.colorPreviewEl),e.appendChild(this.textInputEl);const i=document.createElement("div");i.className="color-with-opacity-opacity-wrapper",this.opacityInputEl=document.createElement("input"),this.opacityInputEl.type="number",this.opacityInputEl.className="color-with-opacity-opacity-input",this.opacityInputEl.value=this.getOpacityPercent().toString(),this.opacityInputEl.min="0",this.opacityInputEl.max="100",this.opacityInputEl.step="1",this.opacityInputEl.placeholder="100",this.getDataPropsPath()&&this.opacityInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_opacity`);const s=document.createElement("span");s.className="color-with-opacity-opacity-suffix",s.textContent="%",this.opacityInputEl.addEventListener("input",o=>{const a=o.target,l=parseFloat(a.value);isNaN(l)||(this.handleOpacityChange(l),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview())}),this.opacityInputEl.addEventListener("blur",o=>{const a=o.target;let l=parseFloat(a.value);isNaN(l)&&(l=this.getOpacityPercent()),l=Math.max(0,Math.min(100,l)),a.value=l.toString(),this.handleOpacityChange(l),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview()}),i.appendChild(this.opacityInputEl),i.appendChild(s);const n=document.createElement("div");return n.className="color-with-opacity-controls-wrapper",n.appendChild(e),n.appendChild(i),t.appendChild(n),this.element=t,this.updateInputElements(),this.updateColorPreview(),t}getElement(){return this.element}getValue(){return this.value}getRgbaValue(){if(!this.value)return"rgba(0, 0, 0, 1)";const t=this.getRgbColor(),e=this.getOpacityPercent()/100,i=t.replace("#",""),s=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);return`rgba(${s}, ${n}, ${o}, ${e})`}getColorAndOpacity(){return{color:this.getRgbColor(),opacity:this.getOpacityPercent()}}}class Vt extends b{constructor(t={}){super(t),this.inputType="text",t.onChange&&this.setOnChange(t.onChange)}setValue(t){this.value=t,this.textareaEl&&(this.textareaEl.value=t),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}draw(){const t=document.createElement("div");if(t.className="html-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const n=document.createElement("div");if(n.className="icon-container",this.props.icon){const o=this.createIcon(this.props.icon);n.appendChild(o)}if(this.props.title){const o=this.createLabel(this.props.title);n.appendChild(o)}t.appendChild(n)}const e=document.createElement("textarea");this.textareaEl=e,e.value=this.value||"",e.placeholder=this.props.placeholder||"Paste your HTML here...",e.className="html-setting-textarea "+(this.props.textareaClassName||""),e.rows=this.props.rows||6,this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath()),this.props.maxLength!==void 0&&(e.maxLength=this.props.maxLength),this.props.className&&e.classList.add(this.props.className);const i=n=>{const a=n.target.value;this.value=a,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},s=n=>{this.onBlur&&this.value!==void 0&&this.onBlur(this.value)};return e.addEventListener("input",i),e.addEventListener("change",i),e.addEventListener("blur",s),t.appendChild(e),t}}class N extends b{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=document.createElement("div");if(t.className="number-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const s=document.createElement("div");if(s.className="icon-container",this.props.icon){const n=document.createElement("span");n.className="input-icon",n.innerHTML=this.props.icon,s.appendChild(n)}if(this.props.title){const n=document.createElement("span");n.className="input-label",n.textContent=this.props.title,s.appendChild(n)}t.appendChild(s)}const e=document.createElement("div");e.className="number-setting-input-container";const i=document.createElement("input");if(i.type="number",i.className="number-setting-input "+(this.props.inputClassName||""),i.value=String(this.value??""),i.placeholder=this.props.placeholder||"",this.getDataPropsPath()&&i.setAttribute("data-test-id",this.getDataPropsPath()),this.props.minValue!==void 0&&(i.min=String(this.props.minValue)),this.props.maxValue!==void 0&&(i.max=String(this.props.maxValue)),this.props.step!==void 0&&(i.step=String(this.props.step)),i.addEventListener("input",()=>{const s=this.props.minValue??Number.MIN_SAFE_INTEGER,n=this.props.maxValue??Number.MAX_SAFE_INTEGER;let o=Number(i.value);o<s&&(o=s),o>n&&(o=n),String(o)!==i.value&&(i.value=String(o)),this.setValue(o)}),i.addEventListener("blur",()=>{var n,o;const s=this.validateValue(Number(i.value));s!==Number(i.value)&&(i.value=String(s),this.setValue(s)),(o=(n=this.props).onBlur)==null||o.call(n)}),e.appendChild(i),this.props.suffix&&this.props.suffix!=="none"){const s=document.createElement("span");s.className="suffix-label",s.textContent=this.props.suffix,e.appendChild(s)}return t.appendChild(e),this.inputElement=i,t}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 Tt=`
|
|
87
|
+
</svg>`;class $ extends b{constructor(t={}){super({...t,icon:t.icon||It,title:t.title||"Color & Opacity",default:t.default||"#000000FF"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.opacityInputEl=null,this.colorPreviewEl=null,this.detectChange=t.detectChange,this.value&&(this.value=$.normalizeHexWithOpacity(this.value))}static normalizeHexWithOpacity(t){return t=t.replace("#",""),t.length===3&&(t=t.split("").map(e=>e+e).join("")),t.length===6&&(t=t+"FF"),t.length===8&&/^[0-9A-Fa-f]{8}$/.test(t)?`#${t.toUpperCase()}`:(console.warn(`Invalid hex value "${t}", using default "#000000FF"`),"#000000FF")}getRgbColor(){return this.value?this.value.substring(0,7):"#000000"}getOpacityPercent(){if(!this.value)return 100;const t=this.value.substring(7,9),e=parseInt(t,16)/255;return Math.round(e*100)}static combineColorOpacity(t,e){const i=t.replace("#","").substring(0,6),n=Math.round(e/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${i}${n}`}setValue(t){t===void 0||t===""?this.value="#000000FF":this.value=$.normalizeHexWithOpacity(t),this.updateInputElements(),this.updateColorPreview(),this.onChange&&this.onChange(this.value),this.detectChange&&this.detectChange(this.value)}updateInputElements(){this.value&&(this.colorInputEl&&(this.colorInputEl.value=this.getRgbColor()),this.textInputEl&&(this.textInputEl.value=this.value),this.opacityInputEl&&(this.opacityInputEl.value=this.getOpacityPercent().toString()))}updateColorPreview(){if(!this.colorPreviewEl||!this.value)return;const t=this.getRgbColor(),e=this.getOpacityPercent()/100,i=t.replace("#",""),s=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);this.colorPreviewEl.style.backgroundColor=`rgba(${s}, ${n}, ${o}, ${e})`}handleColorChange(t){const e=this.getOpacityPercent(),i=$.combineColorOpacity(t,e);this.setValue(i)}handleTextInput(t){const e=/^#[0-9A-Fa-f]{8}$/.test(t.trim()),i=/^#[0-9A-Fa-f]{6}$/.test(t.trim());return e||i?(this.setValue(t),!0):!1}handleOpacityChange(t){const e=this.getRgbColor(),i=Math.max(0,Math.min(100,t)),s=$.combineColorOpacity(e,i);this.setValue(s)}draw(){const t=document.createElement("div");if(t.className="color-with-opacity-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const o=document.createElement("div");if(o.className="icon-container",this.props.icon){const a=document.createElement("span");a.className="input-icon",a.innerHTML=this.props.icon,o.appendChild(a)}if(this.props.title){const a=document.createElement("span");a.className="input-label",a.textContent=this.props.title,o.appendChild(a)}t.appendChild(o)}const e=document.createElement("div");e.className="color-with-opacity-input-wrapper",this.colorInputEl=document.createElement("input"),this.colorInputEl.type="color",this.colorInputEl.className="color-with-opacity-picker",this.getDataPropsPath()&&this.colorInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_color`),this.colorPreviewEl=document.createElement("div"),this.colorPreviewEl.className="color-with-opacity-preview",this.textInputEl=document.createElement("input"),this.textInputEl.type="text",this.textInputEl.className="color-with-opacity-text-input",this.textInputEl.placeholder="#000000FF",this.getDataPropsPath()&&this.textInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.updateInputElements(),this.updateColorPreview(),this.colorInputEl.addEventListener("input",o=>{const a=o.target;this.handleColorChange(a.value),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview()}),this.textInputEl.addEventListener("input",o=>{const a=o.target;this.handleTextInput(a.value)?(this.colorInputEl&&(this.colorInputEl.value=this.getRgbColor()),this.updateColorPreview(),e.classList.remove("error")):a.value.trim()===""?e.classList.remove("error"):e.classList.add("error")}),this.textInputEl.addEventListener("blur",o=>{const a=o.target;a.value.trim()===""&&(a.value=this.value||"#000000FF",e.classList.remove("error"))}),this.colorPreviewEl.addEventListener("click",()=>{var o;(o=this.colorInputEl)==null||o.click()}),e.appendChild(this.colorInputEl),e.appendChild(this.colorPreviewEl),e.appendChild(this.textInputEl);const i=document.createElement("div");i.className="color-with-opacity-opacity-wrapper",this.opacityInputEl=document.createElement("input"),this.opacityInputEl.type="number",this.opacityInputEl.className="color-with-opacity-opacity-input",this.opacityInputEl.value=this.getOpacityPercent().toString(),this.opacityInputEl.min="0",this.opacityInputEl.max="100",this.opacityInputEl.step="1",this.opacityInputEl.placeholder="100",this.getDataPropsPath()&&this.opacityInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_opacity`);const s=document.createElement("span");s.className="color-with-opacity-opacity-suffix",s.textContent="%",this.opacityInputEl.addEventListener("input",o=>{const a=o.target,l=parseFloat(a.value);isNaN(l)||(this.handleOpacityChange(l),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview())}),this.opacityInputEl.addEventListener("blur",o=>{const a=o.target;let l=parseFloat(a.value);isNaN(l)&&(l=this.getOpacityPercent()),l=Math.max(0,Math.min(100,l)),a.value=l.toString(),this.handleOpacityChange(l),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview()}),i.appendChild(this.opacityInputEl),i.appendChild(s);const n=document.createElement("div");return n.className="color-with-opacity-controls-wrapper",n.appendChild(e),n.appendChild(i),t.appendChild(n),this.element=t,this.updateInputElements(),this.updateColorPreview(),t}getElement(){return this.element}getValue(){return this.value}getRgbaValue(){if(!this.value)return"rgba(0, 0, 0, 1)";const t=this.getRgbColor(),e=this.getOpacityPercent()/100,i=t.replace("#",""),s=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);return`rgba(${s}, ${n}, ${o}, ${e})`}getColorAndOpacity(){return{color:this.getRgbColor(),opacity:this.getOpacityPercent()}}}class Vt extends b{constructor(t={}){super(t),this.inputType="text",t.onChange&&this.setOnChange(t.onChange)}setValue(t){this.value=t,this.textareaEl&&(this.textareaEl.value=t),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}draw(){const t=document.createElement("div");if(t.className="html-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const n=document.createElement("div");if(n.className="icon-container",this.props.icon){const o=this.createIcon(this.props.icon);n.appendChild(o)}if(this.props.title){const o=this.createLabel(this.props.title);n.appendChild(o)}t.appendChild(n)}const e=document.createElement("textarea");this.textareaEl=e,e.value=this.value||"",e.placeholder=this.props.placeholder||"Paste your HTML here...",e.className="html-setting-textarea "+(this.props.textareaClassName||""),e.rows=this.props.rows||6,this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath()),this.props.maxLength!==void 0&&(e.maxLength=this.props.maxLength),this.props.className&&e.classList.add(this.props.className);const i=n=>{const a=n.target.value;this.value=a,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},s=n=>{this.onBlur&&this.value!==void 0&&this.onBlur(this.value)};return e.addEventListener("input",i),e.addEventListener("change",i),e.addEventListener("blur",s),t.appendChild(e),t}}class N extends b{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=document.createElement("div");if(t.className="number-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const s=document.createElement("div");if(s.className="icon-container",this.props.icon){const n=document.createElement("span");n.className="input-icon",n.innerHTML=this.props.icon,s.appendChild(n)}if(this.props.title){const n=document.createElement("span");n.className="input-label",n.textContent=this.props.title,s.appendChild(n)}t.appendChild(s)}const e=document.createElement("div");e.className="number-setting-input-container";const i=document.createElement("input");if(i.type="number",i.className="number-setting-input "+(this.props.inputClassName||""),i.value=String(this.value??""),i.placeholder=this.props.placeholder||"",this.getDataPropsPath()&&i.setAttribute("data-test-id",this.getDataPropsPath()),this.props.minValue!==void 0&&(i.min=String(this.props.minValue)),this.props.maxValue!==void 0&&(i.max=String(this.props.maxValue)),this.props.step!==void 0&&(i.step=String(this.props.step)),i.addEventListener("input",()=>{const s=this.props.minValue??Number.MIN_SAFE_INTEGER,n=this.props.maxValue??Number.MAX_SAFE_INTEGER;let o=Number(i.value);o<s&&(o=s),o>n&&(o=n),String(o)!==i.value&&(i.value=String(o)),this.setValue(o)}),i.addEventListener("blur",()=>{var n,o;const s=this.validateValue(Number(i.value));s!==Number(i.value)&&(i.value=String(s),this.setValue(s)),(o=(n=this.props).onBlur)==null||o.call(n)}),e.appendChild(i),this.props.suffix&&this.props.suffix!=="none"){const s=document.createElement("span");s.className="suffix-label",s.textContent=this.props.suffix,e.appendChild(s)}return t.appendChild(e),this.inputElement=i,t}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 Pt=`
|
|
88
88
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
89
89
|
<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"/>
|
|
90
90
|
<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"/>
|
|
91
|
-
</svg>`;class dt extends N{constructor(t={}){const e={title:"Opacity",suffix:"%",minValue:0,maxValue:100,step:1,default:t.default??100,icon:
|
|
91
|
+
</svg>`;class dt extends N{constructor(t={}){const e={title:"Opacity",suffix:"%",minValue:0,maxValue:100,step:1,default:t.default??100,icon:Pt,...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 Tt=`
|
|
92
92
|
<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">
|
|
93
93
|
<polyline points="6 9 12 15 18 9"></polyline>
|
|
94
94
|
</svg>
|
|
95
|
-
`;class Z extends b{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,this.resizeListener=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)}}setValue(t){super.setValue(t);const e=this._options.findIndex(i=>i.value===t);e>=0?this.selectedOptionIndex=e:this.selectedOptionIndex=null,this.updateButtonText()}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 o=this.createIcon(this.props.icon);n.appendChild(o)}if(this.props.title){const o=this.createLabel(this.props.title);n.appendChild(o)}t.appendChild(n)}else{const n=document.createElement("div");t.appendChild(n)}const e=document.createElement("div");e.classList.add("select-button"),this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath()),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,o;this.isLoading||(this.isOpen=!this.isOpen,this.isOpen?this.checkDropdownPosition():this.cleanupDropdownPosition(),(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(o=this.svgContainer)==null||o.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,o)=>{const a=this.createOption(n,o);a.onclick=l=>this.selectOption(l,o,e),i.appendChild(a)}),document.body.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=
|
|
95
|
+
`;class Z extends b{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,this.resizeListener=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)}}setValue(t){super.setValue(t);const e=this._options.findIndex(i=>i.value===t);e>=0?this.selectedOptionIndex=e:this.selectedOptionIndex=null,this.updateButtonText()}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 o=this.createIcon(this.props.icon);n.appendChild(o)}if(this.props.title){const o=this.createLabel(this.props.title);n.appendChild(o)}t.appendChild(n)}else{const n=document.createElement("div");t.appendChild(n)}const e=document.createElement("div");e.classList.add("select-button"),this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath()),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,o;this.isLoading||(this.isOpen=!this.isOpen,this.isOpen?this.checkDropdownPosition():this.cleanupDropdownPosition(),(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(o=this.svgContainer)==null||o.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,o)=>{const a=this.createOption(n,o);a.onclick=l=>this.selectOption(l,o,e),i.appendChild(a)}),document.body.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=Tt,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 o,a;this.isOpen&&!t.contains(n.target)&&(this.isOpen=!1,(o=this.optionsListEl)==null||o.classList.remove("open"),(a=this.svgContainer)==null||a.classList.remove("open"),this.cleanupDropdownPosition())},document.addEventListener("click",this.clickOutsideListener),this.resizeListener&&window.removeEventListener("resize",this.resizeListener),this.resizeListener=()=>{this.isOpen&&this.checkDropdownPosition()},window.addEventListener("resize",this.resizeListener),t}checkDropdownPosition(){if(!this.optionsListEl||!this.buttonEl||!this.container)return;const t=this.buttonEl.getBoundingClientRect();this.optionsListEl.classList.remove("dropdown-up"),this.optionsListEl.style.position="fixed",this.optionsListEl.style.top=`${t.bottom+2}px`,this.optionsListEl.style.bottom="auto",this.optionsListEl.style.left=`${t.left}px`,this.optionsListEl.style.right="auto",this.optionsListEl.style.width=`${t.width}px`;const e=Math.min(this._options.length*40+12,280);if(window.innerHeight-t.bottom<e){const s=Math.max(10,window.innerHeight-e-10);this.optionsListEl.style.top=`${s}px`}}selectOption(t,e,i){var n,o;const s=this._options[e];s&&(this.setValue(s.value),this.selectedOptionIndex=e,this.isOpen=!1,i.textContent=s.name,(n=this.optionsListEl)==null||n.classList.remove("open"),(o=this.svgContainer)==null||o.classList.remove("open"),this.cleanupDropdownPosition(),this.optionsListEl&&this.optionsListEl.querySelectorAll(".select-option").forEach((l,r)=>{r===e?l.classList.add("selected"):l.classList.remove("selected")}))}cleanupDropdownPosition(){this.optionsListEl&&(this.optionsListEl.style.position="",this.optionsListEl.style.top="",this.optionsListEl.style.bottom="",this.optionsListEl.style.left="",this.optionsListEl.style.right="",this.optionsListEl.style.width="")}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),this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null),this.cleanupDropdownPosition(),this.optionsListEl&&this.optionsListEl.parentNode&&this.optionsListEl.parentNode.removeChild(this.optionsListEl),super.destroy()}}class ut extends b{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:`
|
|
96
96
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
|
|
97
97
|
<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"
|
|
98
98
|
stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
</svg>`;class Zt extends N{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||Xt,title:t.title||"Margin Bottom",default:t.default??20,wrapperClassName:"margin-bottom-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}const Kt=`<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 Yt extends N{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||Kt,title:t.title||"Margin Top",default:t.default??20,wrapperClassName:"margin-top-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}class Qt extends b{constructor(t){super(t),this.inputType={},this.container=null,this.defaultLanguage="",this.uploadSettings=new Map,t.default?this.value={...t.default}:this.value||(this.value={}),this.defaultLanguage=t.languages.includes(b.DefaultLanguage)?b.DefaultLanguage:t.languages[0];const e=t.defaultValue||`Enter text in ${this.capitalizeFirstLetter(this.defaultLanguage)}`;t.languages.forEach(i=>{var s,n;i in(this.value||{})||(this.value||(this.value={}),i===this.defaultLanguage&&e?this.value[i]=((s=t.default)==null?void 0:s[i])||e:this.value[i]=((n=t.default)==null?void 0:n[i])||"")})}capitalizeFirstLetter(t){return String(t).charAt(0).toUpperCase()+String(t).slice(1)}measureTextWidth(t,e){this.textMeasureCanvas||(this.textMeasureCanvas=document.createElement("canvas"));const i=this.textMeasureCanvas.getContext("2d");if(!i)return t.length*10;const s=`${e.fontStyle} ${e.fontWeight} ${e.fontSize} ${e.fontFamily}`.trim();return i.font=s,i.measureText(t).width}adaptPlaceholderToSingleLine(t,e){const i=window.getComputedStyle(t),s=parseFloat(i.paddingLeft)||0,n=parseFloat(i.paddingRight)||0,o=parseFloat(i.borderLeftWidth)||0,a=parseFloat(i.borderRightWidth)||0,l=Math.max(0,t.clientWidth-s-n-o-a);if(l<=0){t.placeholder=e;return}if(this.measureTextWidth(e,i)<=l){t.placeholder=e;return}const d="...";let h=0,p=e.length,u=0;for(;h<=p;){const f=Math.floor((h+p)/2),m=e.slice(0,f).trimEnd()+d;this.measureTextWidth(m,i)<=l?(u=f,h=f+1):p=f-1}const g=e.slice(0,u).trimEnd()+d;t.placeholder=g}autosizeTextarea(t,e=3){t.style.height="auto";const i=window.getComputedStyle(t),s=parseFloat(i.lineHeight)||20,n=parseFloat(i.paddingTop)+parseFloat(i.paddingBottom),o=parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth),a=s*e+n+o,l=Math.min(t.scrollHeight||44,a);t.style.height=`${l}px`,t.scrollHeight>a?t.style.overflowY="auto":t.style.overflowY="hidden"}createTextareaRow(t,e){const i=document.createElement("div");i.classList.add("simple-multi-language-row");const s=document.createElement("label");if(s.classList.add("simple-language-label"),s.textContent=t.toUpperCase(),s.setAttribute("for",`textarea-${t}`),i.appendChild(s),this.props.multiImg){const n=new st({defaultUrl:e||"",title:"",id:`${this.id}_upload_${t}`});n.setOnChange(a=>{this.updateLanguageValue(t,a),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(a)}),this.uploadSettings.set(t,n);const o=n.draw();o.classList.add("simple-language-upload"),i.appendChild(o)}else{const n=document.createElement("textarea");n.id=`textarea-${t}`,n.classList.add("simple-language-textarea"),n.value=e||"",n.rows=1,n.style.overflowY="hidden";let o=this.props.placeholder||"Enter text in {language}...";o.includes("{language}")&&(o=o.replace("{language}",t.toUpperCase())),n.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(n,o),this.getDataPropsPath()&&n.setAttribute("data-test-id",`${this.getDataPropsPath()}_${t}`),n.addEventListener("input",l=>{const r=l.target;this.updateLanguageValue(t,r.value),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(r.value),this.autosizeTextarea(r,3);const d=n.getAttribute("data-full-placeholder")||"";d&&this.adaptPlaceholderToSingleLine(n,d)}),i.appendChild(n),(l=>(typeof queueMicrotask=="function"?queueMicrotask:r=>setTimeout(r,0))(l))(()=>{this.autosizeTextarea(n,3);const l=n.getAttribute("data-full-placeholder")||"";l&&this.adaptPlaceholderToSingleLine(n,l)})}return i}updateLanguageValue(t,e){this.value||(this.value={});const i={...this.value,[t]:e};this.setValue(i)}updateOtherLanguagePlaceholders(t){this.container&&this.props.languages.forEach(e=>{var s,n;if(e===this.defaultLanguage)return;const i=(s=this.container)==null?void 0:s.querySelector(`#textarea-${e}`);if(i&&(!i.value||i.value.trim()==="")){const o=t||((n=this.props.placeholder)==null?void 0:n.replace("{language}",e.toUpperCase()))||`Enter text in ${e.toUpperCase()}...`;i.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(i,o)}})}draw(){const t=document.createElement("div");if(t.classList.add("simple-multi-language-wrapper"),this.props.title){const s=document.createElement("div");s.classList.add("simple-multi-language-title"),s.textContent=this.props.title,t.appendChild(s)}const e=document.createElement("div");e.classList.add("simple-multi-language-content"),this.props.languages.forEach(s=>{var a;const n=((a=this.value)==null?void 0:a[s])||"",o=this.createTextareaRow(s,n);e.appendChild(o)}),t.appendChild(e),this.container=t;const i=()=>{if(!this.container)return;this.container.querySelectorAll(".simple-language-textarea").forEach(n=>{const o=n.getAttribute("data-full-placeholder")||"";o&&this.adaptPlaceholderToSingleLine(n,o)})};return window.addEventListener("resize",i),t}setValue(t){super.setValue(t),this.container&&this.props.languages.forEach(e=>{var i;if(this.props.multiImg){const s=this.uploadSettings.get(e);s&&s.setValue((t==null?void 0:t[e])||"")}else{const s=(i=this.container)==null?void 0:i.querySelector(`#textarea-${e}`);if(s){s.value=(t==null?void 0:t[e])||"",this.autosizeTextarea(s,3);const n=s.getAttribute("data-full-placeholder")||"";n&&this.adaptPlaceholderToSingleLine(s,n)}}})}}class te extends b{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 Z({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 gt=(c,t,e)=>{let i=!1,s=0,n=0,o=0,a=0;const l=h=>{if(h.target.closest("button"))return;i=!0,s=h.clientX,n=h.clientY;const p=t.getBoundingClientRect();o=p.left,a=p.top,document.addEventListener("mousemove",r),document.addEventListener("mouseup",d),document.body.style.userSelect="none"},r=h=>{if(!i)return;const p=h.clientX-s,u=h.clientY-n,g=window.innerWidth,f=window.innerHeight,m=t.offsetWidth,v=t.offsetHeight;let C=o+p,x=a+u;C=Math.max(8,Math.min(g-m-8,C)),x=Math.max(8,Math.min(f-v-8,x)),t.style.left=`${C}px`,t.style.top=`${x}px`,e==null||e(C,x)},d=()=>{i=!1,document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",d),document.body.style.userSelect=""};c.addEventListener("mousedown",l)},F=c=>{if(!c)return null;let t=c.trim();return!t.startsWith("#")||(t=t.slice(1),t.length===3&&(t=t.split("").map(e=>e+e).join("")),!/^[0-9a-fA-F]{6}$/.test(t))?null:`#${t.toUpperCase()}`},q=(c,t,e)=>`#${[c,t,e].map(i=>Math.max(0,Math.min(255,i)).toString(16).padStart(2,"0")).join("")}`,S=c=>{const t=c.replace("#",""),e=t.length===3?t.split("").map(i=>i+i).join(""):t;return{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16)}},D=c=>{const{r:t,g:e,b:i}=S(c),s=t/255,n=e/255,o=i/255,a=Math.max(s,n,o),l=Math.min(s,n,o),r=a-l;let d=0;r!==0&&(a===s?d=(n-o)/r%6:a===n?d=(o-s)/r+2:d=(s-n)/r+4),d<0&&(d+=6);const h=a===0?0:r/a,p=a;return{h:d*60,s:h,v:p}},R=(c,t,e)=>{const i=(c%360+360)%360,s=e*t,n=s*(1-Math.abs(i/60%2-1)),o=e-s;let a=0,l=0,r=0;return i<60?(a=s,l=n,r=0):i<120?(a=n,l=s,r=0):i<180?(a=0,l=s,r=n):i<240?(a=0,l=n,r=s):i<300?(a=n,l=0,r=s):(a=s,l=0,r=n),q(Math.round((a+o)*255),Math.round((l+o)*255),Math.round((r+o)*255))},mt=(c,t,e)=>{const i=e*(1-t/2),s=i===0||i===1?0:(e-i)/Math.min(i,1-i);return{hue:c,sat:s,lightness:i}},et=(c,t,e)=>{const i=(1-Math.abs(2*e-1))*t,s=i*(1-Math.abs(c/60%2-1)),n=e-i/2;let o=0,a=0,l=0;return c<60?(o=i,a=s,l=0):c<120?(o=s,a=i,l=0):c<180?(o=0,a=i,l=s):c<240?(o=0,a=s,l=i):c<300?(o=s,a=0,l=i):(o=i,a=0,l=s),{r:Math.round((o+n)*255),g:Math.round((a+n)*255),b:Math.round((l+n)*255)}},ft=(c,t)=>{const e=Math.max(0,Math.min(100,t))/100;if(c.startsWith("#")){const{r:s,g:n,b:o}=S(c);return`rgba(${s}, ${n}, ${o}, ${e})`}if(c.startsWith("rgba("))return c.replace(/,\s*[\d.]+\)$/,`, ${e})`);if(c.startsWith("rgb("))return c.replace("rgb(","rgba(").replace(")",`, ${e})`);if(c.startsWith("hsl(")){const s=c.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const{r:n,g:o,b:a}=et(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}if(c.startsWith("hsla(")){const s=c.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);if(s){const{r:n,g:o,b:a}=et(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}const i=F(c);if(i){const{r:s,g:n,b:o}=S(i);return`rgba(${s}, ${n}, ${o}, ${e})`}return c},ee=c=>["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy","maroon","olive","aqua","silver","teal","fuchsia","transparent"].includes(c.toLowerCase()),vt=c=>[/^#[0-9a-fA-F]{3,8}$/,/^rgba?\s*\([^)]+\)$/,/^hsla?\s*\([^)]+\)$/,/^[a-zA-Z]+$/].some(e=>e.test(c.trim())),ie=c=>{if(typeof document>"u")return vt(c)||!!F(c);const t=document.createElement("div");return t.style.color=c,t.style.color!==""},Ct=c=>{const t=c.trim();if(/^#[0-9A-Fa-f]{8}$/.test(t)){const n=t.slice(1),o=parseInt(n.slice(0,2),16),a=parseInt(n.slice(2,4),16),l=parseInt(n.slice(4,6),16),r=parseInt(n.slice(6,8),16);return{color:q(o,a,l),position:0,opacity:Math.round(r/255*100)}}const e=t.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(e){const n=parseInt(e[1]),o=parseInt(e[2]),a=parseInt(e[3]),l=e[4]?parseFloat(e[4]):1;return{color:q(n,o,a),position:0,opacity:Math.round(l*100)}}const i=t.match(/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)/);if(i){const{r:n,g:o,b:a}=et(parseFloat(i[1]),parseFloat(i[2])/100,parseFloat(i[3])/100),l=i[4]?parseFloat(i[4]):1;return{color:q(n,o,a),position:0,opacity:Math.round(l*100)}}return{color:F(t)||t,position:0,opacity:100}},at=c=>{const t=[];let e="",i=0;for(let s=0;s<c.length;s++){const n=c[s];if(n==="(")i++;else if(n===")")i--;else if(n===","&&i===0){t.push(e.trim()),e="";continue}e+=n}return e.trim()&&t.push(e.trim()),t},lt=(c,t)=>{const e=new RegExp(`${t}\\s*\\(`,"i"),i=c.match(e);if(!i)return null;const s=i.index+i[0].length;let n=1,o=s;for(let a=s;a<c.length&&n>0;a++)c[a]==="("?n++:c[a]===")"&&n--,o=a;return n===0?c.substring(s,o):null},se=c=>{const t=c.split(" ")[0].toLowerCase();return["circle","ellipse","closest-side","closest-corner","farthest-side","farthest-corner","at","contain","cover"].includes(t)?!1:/^#[0-9a-f]{3,8}$/i.test(t)||/^rgb/i.test(c)||/^hsl/i.test(c)||ee(t)},rt=c=>{const t=[];return c.forEach((e,i)=>{const s=e.trim();if(!s)return;let n="",o=0;const a=s.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);a&&vt(a[1].trim())?(n=a[1].trim(),o=parseFloat(a[2])):(n=s,o=c.length===1?0:i/(c.length-1)*100);const l=Ct(n);l.position=Math.max(0,Math.min(100,Math.round(o))),t.push(l)}),t},A=c=>{const t=c.stops&&c.stops.length?c.stops:[{color:"#000000",position:0,opacity:100}];return{type:c.type&&["linear","radial","solid"].includes(c.type)?c.type:"linear",angle:typeof c.angle=="number"?c.angle:90,stops:t.map((e,i)=>({color:e.color||"#000000",position:typeof e.position=="number"?e.position:t.length===1?0:Math.round(i/(t.length-1)*100),opacity:e.opacity===void 0||Number.isNaN(e.opacity)?100:e.opacity}))}},P=c=>{const t=c.replace(/;$/,"").trim();if(ie(t)){const s=Ct(t);return A({type:"solid",angle:0,stops:[s]})}const e=lt(t,"linear-gradient");if(e){const s=at(e);let n=90,o=s;const a=s[0];if(a.includes("deg")){const r=a.match(/(-?\d+(?:\.\d+)?)deg/);r&&(n=parseFloat(r[1]),o=s.slice(1))}else a.includes("to ")&&(n={"to right":90,"to left":270,"to bottom":180,"to top":0,"to bottom right":135,"to bottom left":225,"to top right":45,"to top left":315}[a]??90,o=s.slice(1));const l=rt(o);return l.length?A({type:"linear",angle:n,stops:l}):null}const i=lt(t,"radial-gradient");if(i){const s=at(i),n=s[0]&&!se(s[0])?s.slice(1):s,o=rt(n);return o.length?A({type:"radial",angle:0,stops:o}):null}return null},V=c=>{if(c.type==="solid"){const e=c.stops[0],i=e.opacity??100,s=e.color.replace("#",""),n=Math.round(i/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${s}${n}`}const t=c.stops.map(e=>`${ft(e.color,e.opacity??100)} ${e.position}%`).join(", ");return c.type==="radial"?`radial-gradient(circle, ${t})`:`linear-gradient(${c.angle}deg, ${t})`},ne=c=>Math.round(c/100*255).toString(16).toUpperCase().padStart(2,"0"),J=c=>{if(c.type==="solid"){const t=c.stops[0];if(t){const e=t.color.toUpperCase(),i=t.opacity??100;if(i===100)return e;{const s=ne(i);return`${e}${s}`}}return"#000000"}return c.type==="linear"?`Linear ${c.angle}°`:"Radial Gradient"},z=class z{static defaults(){return{solid:[],gradient:[]}}static normalizeList(t){const e=new Set,i=[];return t.forEach(s=>{let n=F(s);n||P(s)&&(n=s),n&&(e.has(n)||(e.add(n),i.push(n)))}),i.slice(0,this.MAX_COLORS)}static ensureLoaded(){var t;if(!this.colors&&(this.colors=this.defaults(),!(typeof window>"u")))try{const e=(t=window.sessionStorage)==null?void 0:t.getItem(this.STORAGE_KEY);if(!e)return;const i=JSON.parse(e);if(Array.isArray(i))this.colors.solid=this.normalizeList(i);else if(i&&typeof i=="object"){const s=i;s.solid&&(this.colors.solid=this.normalizeList(s.solid)),s.gradient&&(this.colors.gradient=this.normalizeList(s.gradient))}}catch{this.colors=this.defaults()}}static persist(){var t;if(!(typeof window>"u"))try{(t=window.sessionStorage)==null||t.setItem(this.STORAGE_KEY,JSON.stringify(this.colors||this.defaults()))}catch{}}static list(t){return this.ensureLoaded(),this.colors||(this.colors=this.defaults()),this.colors[t]}static getColors(t){if(t==="all"){const e=this.list("solid"),i=this.list("gradient"),s=[...e,...i];return this.normalizeList(s)}return[...this.list(t)]}static addColor(t,e){if(!t)return;let i=F(t),s="solid";if(i)s="solid";else{const l=P(t);l&&(i=t,s=l.type==="solid"?"solid":"gradient")}if(!i)return;const n=e==="all"?s:e,o=this.list(n),a=o.indexOf(i);a!==-1&&o.splice(a,1),o.unshift(i),o.length>this.MAX_COLORS&&(o.length=this.MAX_COLORS),this.persist()}};z.STORAGE_KEY="settingsLib_recentColors",z.MAX_COLORS=12,z.colors=null;let B=z;const nt=(c,t)=>{const e=document.createElement("div");e.className="color-picker-recent-section";const i=document.createElement("div");i.className="color-picker-recent-title",i.textContent="Recently Used";const s=document.createElement("div");s.className="color-picker-tooltip",s.style.display="none",e.appendChild(s);const n=()=>{s.style.display="none"},o=(d,h)=>{const p=d.getBoundingClientRect();s.textContent=h,s.style.left=`${p.left+p.width/2}px`,s.style.top=`${p.bottom+8}px`,s.style.display="block"},a=document.createElement("div");a.className="color-picker-recent-grid";const l=document.createElement("div");l.className="color-picker-recent-placeholder",l.textContent="No recent colors yet",e.appendChild(i),e.appendChild(a),e.appendChild(l);const r=()=>{n(),a.innerHTML="";const d=B.getColors(t);if(d.length===0){a.style.display="none",l.style.display="block";return}a.style.display="grid",l.style.display="none",d.forEach(h=>{const p=document.createElement("button");p.type="button",p.className="color-picker-recent-swatch";const u=oe(h);p.title=u,p.setAttribute("aria-label",`Use color: ${u}`),p.style.background=h,p.style.borderColor=h,p.addEventListener("mouseenter",()=>o(p,u)),p.addEventListener("mouseleave",()=>{n(),p.style.boxShadow=""}),p.addEventListener("mousedown",()=>{p.style.boxShadow="0px 0px 0px 2px var(--grey40)"}),p.addEventListener("mouseup",()=>{setTimeout(()=>{p.style.boxShadow=""},150)}),p.addEventListener("click",()=>{n(),c(h)}),a.appendChild(p)})};return r(),{container:e,refresh:r}},oe=c=>{const t=P(c);if(t)return J(t);const e=F(c);if(e){const i=S(e);return`${e} (RGB: ${i.r}, ${i.g}, ${i.b})`}return c},yt=`<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
189
|
+
</svg>`;class Yt extends N{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||Kt,title:t.title||"Margin Top",default:t.default??20,wrapperClassName:"margin-top-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}class Qt extends b{constructor(t){super(t),this.inputType={},this.container=null,this.defaultLanguage="",this.uploadSettings=new Map,t.default?this.value={...t.default}:this.value||(this.value={}),this.defaultLanguage=t.languages.includes(b.DefaultLanguage)?b.DefaultLanguage:t.languages[0];const e=t.defaultValue||`Enter text in ${this.capitalizeFirstLetter(this.defaultLanguage)}`;t.languages.forEach(i=>{var s,n;i in(this.value||{})||(this.value||(this.value={}),i===this.defaultLanguage&&e?this.value[i]=((s=t.default)==null?void 0:s[i])||e:this.value[i]=((n=t.default)==null?void 0:n[i])||"")})}capitalizeFirstLetter(t){return String(t).charAt(0).toUpperCase()+String(t).slice(1)}measureTextWidth(t,e){this.textMeasureCanvas||(this.textMeasureCanvas=document.createElement("canvas"));const i=this.textMeasureCanvas.getContext("2d");if(!i)return t.length*10;const s=`${e.fontStyle} ${e.fontWeight} ${e.fontSize} ${e.fontFamily}`.trim();return i.font=s,i.measureText(t).width}adaptPlaceholderToSingleLine(t,e){const i=window.getComputedStyle(t),s=parseFloat(i.paddingLeft)||0,n=parseFloat(i.paddingRight)||0,o=parseFloat(i.borderLeftWidth)||0,a=parseFloat(i.borderRightWidth)||0,l=Math.max(0,t.clientWidth-s-n-o-a);if(l<=0){t.placeholder=e;return}if(this.measureTextWidth(e,i)<=l){t.placeholder=e;return}const d="...";let h=0,p=e.length,u=0;for(;h<=p;){const f=Math.floor((h+p)/2),m=e.slice(0,f).trimEnd()+d;this.measureTextWidth(m,i)<=l?(u=f,h=f+1):p=f-1}const g=e.slice(0,u).trimEnd()+d;t.placeholder=g}autosizeTextarea(t,e=3){t.style.height="auto";const i=window.getComputedStyle(t),s=parseFloat(i.lineHeight)||20,n=parseFloat(i.paddingTop)+parseFloat(i.paddingBottom),o=parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth),a=s*e+n+o,l=Math.min(t.scrollHeight||44,a);t.style.height=`${l}px`,t.scrollHeight>a?t.style.overflowY="auto":t.style.overflowY="hidden"}createTextareaRow(t,e){const i=document.createElement("div");i.classList.add("simple-multi-language-row");const s=document.createElement("label");if(s.classList.add("simple-language-label"),s.textContent=t.toUpperCase(),s.setAttribute("for",`textarea-${t}`),i.appendChild(s),this.props.multiImg){const n=new st({defaultUrl:e||"",title:"",id:`${this.id}_upload_${t}`});n.setOnChange(a=>{this.updateLanguageValue(t,a),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(a)}),this.uploadSettings.set(t,n);const o=n.draw();o.classList.add("simple-language-upload"),i.appendChild(o)}else{const n=document.createElement("textarea");n.id=`textarea-${t}`,n.classList.add("simple-language-textarea"),n.value=e||"",n.rows=1,n.style.overflowY="hidden";let o=this.props.placeholder||"Enter text in {language}...";o.includes("{language}")&&(o=o.replace("{language}",t.toUpperCase())),n.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(n,o),this.getDataPropsPath()&&n.setAttribute("data-test-id",`${this.getDataPropsPath()}_${t}`),n.addEventListener("input",l=>{const r=l.target;this.updateLanguageValue(t,r.value),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(r.value),this.autosizeTextarea(r,3);const d=n.getAttribute("data-full-placeholder")||"";d&&this.adaptPlaceholderToSingleLine(n,d)}),i.appendChild(n),(l=>(typeof queueMicrotask=="function"?queueMicrotask:r=>setTimeout(r,0))(l))(()=>{this.autosizeTextarea(n,3);const l=n.getAttribute("data-full-placeholder")||"";l&&this.adaptPlaceholderToSingleLine(n,l)})}return i}updateLanguageValue(t,e){this.value||(this.value={});const i={...this.value,[t]:e};this.setValue(i)}updateOtherLanguagePlaceholders(t){this.container&&this.props.languages.forEach(e=>{var s,n;if(e===this.defaultLanguage)return;const i=(s=this.container)==null?void 0:s.querySelector(`#textarea-${e}`);if(i&&(!i.value||i.value.trim()==="")){const o=t||((n=this.props.placeholder)==null?void 0:n.replace("{language}",e.toUpperCase()))||`Enter text in ${e.toUpperCase()}...`;i.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(i,o)}})}draw(){const t=document.createElement("div");if(t.classList.add("simple-multi-language-wrapper"),this.props.title){const s=document.createElement("div");s.classList.add("simple-multi-language-title"),s.textContent=this.props.title,t.appendChild(s)}const e=document.createElement("div");e.classList.add("simple-multi-language-content"),this.props.languages.forEach(s=>{var a;const n=((a=this.value)==null?void 0:a[s])||"",o=this.createTextareaRow(s,n);e.appendChild(o)}),t.appendChild(e),this.container=t;const i=()=>{if(!this.container)return;this.container.querySelectorAll(".simple-language-textarea").forEach(n=>{const o=n.getAttribute("data-full-placeholder")||"";o&&this.adaptPlaceholderToSingleLine(n,o)})};return window.addEventListener("resize",i),t}setValue(t){super.setValue(t),this.container&&this.props.languages.forEach(e=>{var i;if(this.props.multiImg){const s=this.uploadSettings.get(e);s&&s.setValue((t==null?void 0:t[e])||"")}else{const s=(i=this.container)==null?void 0:i.querySelector(`#textarea-${e}`);if(s){s.value=(t==null?void 0:t[e])||"",this.autosizeTextarea(s,3);const n=s.getAttribute("data-full-placeholder")||"";n&&this.adaptPlaceholderToSingleLine(s,n)}}})}}class te extends b{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 Z({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 gt=(c,t,e)=>{let i=!1,s=0,n=0,o=0,a=0;const l=h=>{if(h.target.closest("button"))return;i=!0,s=h.clientX,n=h.clientY;const p=t.getBoundingClientRect();o=p.left,a=p.top,document.addEventListener("mousemove",r),document.addEventListener("mouseup",d),document.body.style.userSelect="none"},r=h=>{if(!i)return;const p=h.clientX-s,u=h.clientY-n,g=window.innerWidth,f=window.innerHeight,m=t.offsetWidth,v=t.offsetHeight;let C=o+p,x=a+u;C=Math.max(8,Math.min(g-m-8,C)),x=Math.max(8,Math.min(f-v-8,x)),t.style.left=`${C}px`,t.style.top=`${x}px`,e==null||e(C,x)},d=()=>{i=!1,document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",d),document.body.style.userSelect=""};c.addEventListener("mousedown",l)},F=c=>{if(!c)return null;let t=c.trim();return!t.startsWith("#")||(t=t.slice(1),t.length===3&&(t=t.split("").map(e=>e+e).join("")),!/^[0-9a-fA-F]{6}$/.test(t))?null:`#${t.toUpperCase()}`},q=(c,t,e)=>`#${[c,t,e].map(i=>Math.max(0,Math.min(255,i)).toString(16).padStart(2,"0")).join("")}`,S=c=>{const t=c.replace("#",""),e=t.length===3?t.split("").map(i=>i+i).join(""):t;return{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16)}},D=c=>{const{r:t,g:e,b:i}=S(c),s=t/255,n=e/255,o=i/255,a=Math.max(s,n,o),l=Math.min(s,n,o),r=a-l;let d=0;r!==0&&(a===s?d=(n-o)/r%6:a===n?d=(o-s)/r+2:d=(s-n)/r+4),d<0&&(d+=6);const h=a===0?0:r/a,p=a;return{h:d*60,s:h,v:p}},R=(c,t,e)=>{const i=(c%360+360)%360,s=e*t,n=s*(1-Math.abs(i/60%2-1)),o=e-s;let a=0,l=0,r=0;return i<60?(a=s,l=n,r=0):i<120?(a=n,l=s,r=0):i<180?(a=0,l=s,r=n):i<240?(a=0,l=n,r=s):i<300?(a=n,l=0,r=s):(a=s,l=0,r=n),q(Math.round((a+o)*255),Math.round((l+o)*255),Math.round((r+o)*255))},mt=(c,t,e)=>{const i=e*(1-t/2),s=i===0||i===1?0:(e-i)/Math.min(i,1-i);return{hue:c,sat:s,lightness:i}},et=(c,t,e)=>{const i=(1-Math.abs(2*e-1))*t,s=i*(1-Math.abs(c/60%2-1)),n=e-i/2;let o=0,a=0,l=0;return c<60?(o=i,a=s,l=0):c<120?(o=s,a=i,l=0):c<180?(o=0,a=i,l=s):c<240?(o=0,a=s,l=i):c<300?(o=s,a=0,l=i):(o=i,a=0,l=s),{r:Math.round((o+n)*255),g:Math.round((a+n)*255),b:Math.round((l+n)*255)}},ft=(c,t)=>{const e=Math.max(0,Math.min(100,t))/100;if(c.startsWith("#")){const{r:s,g:n,b:o}=S(c);return`rgba(${s}, ${n}, ${o}, ${e})`}if(c.startsWith("rgba("))return c.replace(/,\s*[\d.]+\)$/,`, ${e})`);if(c.startsWith("rgb("))return c.replace("rgb(","rgba(").replace(")",`, ${e})`);if(c.startsWith("hsl(")){const s=c.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const{r:n,g:o,b:a}=et(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}if(c.startsWith("hsla(")){const s=c.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);if(s){const{r:n,g:o,b:a}=et(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}const i=F(c);if(i){const{r:s,g:n,b:o}=S(i);return`rgba(${s}, ${n}, ${o}, ${e})`}return c},ee=c=>["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy","maroon","olive","aqua","silver","teal","fuchsia","transparent"].includes(c.toLowerCase()),vt=c=>[/^#[0-9a-fA-F]{3,8}$/,/^rgba?\s*\([^)]+\)$/,/^hsla?\s*\([^)]+\)$/,/^[a-zA-Z]+$/].some(e=>e.test(c.trim())),ie=c=>{if(typeof document>"u")return vt(c)||!!F(c);const t=document.createElement("div");return t.style.color=c,t.style.color!==""},Ct=c=>{const t=c.trim();if(/^#[0-9A-Fa-f]{8}$/.test(t)){const n=t.slice(1),o=parseInt(n.slice(0,2),16),a=parseInt(n.slice(2,4),16),l=parseInt(n.slice(4,6),16),r=parseInt(n.slice(6,8),16);return{color:q(o,a,l),position:0,opacity:Math.round(r/255*100)}}const e=t.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(e){const n=parseInt(e[1]),o=parseInt(e[2]),a=parseInt(e[3]),l=e[4]?parseFloat(e[4]):1;return{color:q(n,o,a),position:0,opacity:Math.round(l*100)}}const i=t.match(/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)/);if(i){const{r:n,g:o,b:a}=et(parseFloat(i[1]),parseFloat(i[2])/100,parseFloat(i[3])/100),l=i[4]?parseFloat(i[4]):1;return{color:q(n,o,a),position:0,opacity:Math.round(l*100)}}return{color:F(t)||t,position:0,opacity:100}},at=c=>{const t=[];let e="",i=0;for(let s=0;s<c.length;s++){const n=c[s];if(n==="(")i++;else if(n===")")i--;else if(n===","&&i===0){t.push(e.trim()),e="";continue}e+=n}return e.trim()&&t.push(e.trim()),t},lt=(c,t)=>{const e=new RegExp(`${t}\\s*\\(`,"i"),i=c.match(e);if(!i)return null;const s=i.index+i[0].length;let n=1,o=s;for(let a=s;a<c.length&&n>0;a++)c[a]==="("?n++:c[a]===")"&&n--,o=a;return n===0?c.substring(s,o):null},se=c=>{const t=c.split(" ")[0].toLowerCase();return["circle","ellipse","closest-side","closest-corner","farthest-side","farthest-corner","at","contain","cover"].includes(t)?!1:/^#[0-9a-f]{3,8}$/i.test(t)||/^rgb/i.test(c)||/^hsl/i.test(c)||ee(t)},rt=c=>{const t=[];return c.forEach((e,i)=>{const s=e.trim();if(!s)return;let n="",o=0;const a=s.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);a&&vt(a[1].trim())?(n=a[1].trim(),o=parseFloat(a[2])):(n=s,o=c.length===1?0:i/(c.length-1)*100);const l=Ct(n);l.position=Math.max(0,Math.min(100,Math.round(o))),t.push(l)}),t},A=c=>{const t=c.stops&&c.stops.length?c.stops:[{color:"#000000",position:0,opacity:100}];return{type:c.type&&["linear","radial","solid"].includes(c.type)?c.type:"linear",angle:typeof c.angle=="number"?c.angle:90,stops:t.map((e,i)=>({color:e.color||"#000000",position:typeof e.position=="number"?e.position:t.length===1?0:Math.round(i/(t.length-1)*100),opacity:e.opacity===void 0||Number.isNaN(e.opacity)?100:e.opacity}))}},T=c=>{const t=c.replace(/;$/,"").trim();if(ie(t)){const s=Ct(t);return A({type:"solid",angle:0,stops:[s]})}const e=lt(t,"linear-gradient");if(e){const s=at(e);let n=90,o=s;const a=s[0];if(a.includes("deg")){const r=a.match(/(-?\d+(?:\.\d+)?)deg/);r&&(n=parseFloat(r[1]),o=s.slice(1))}else a.includes("to ")&&(n={"to right":90,"to left":270,"to bottom":180,"to top":0,"to bottom right":135,"to bottom left":225,"to top right":45,"to top left":315}[a]??90,o=s.slice(1));const l=rt(o);return l.length?A({type:"linear",angle:n,stops:l}):null}const i=lt(t,"radial-gradient");if(i){const s=at(i),n=s[0]&&!se(s[0])?s.slice(1):s,o=rt(n);return o.length?A({type:"radial",angle:0,stops:o}):null}return null},V=c=>{if(c.type==="solid"){const e=c.stops[0],i=e.opacity??100,s=e.color.replace("#",""),n=Math.round(i/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${s}${n}`}const t=c.stops.map(e=>`${ft(e.color,e.opacity??100)} ${e.position}%`).join(", ");return c.type==="radial"?`radial-gradient(circle, ${t})`:`linear-gradient(${c.angle}deg, ${t})`},ne=c=>Math.round(c/100*255).toString(16).toUpperCase().padStart(2,"0"),J=c=>{if(c.type==="solid"){const t=c.stops[0];if(t){const e=t.color.toUpperCase(),i=t.opacity??100;if(i===100)return e;{const s=ne(i);return`${e}${s}`}}return"#000000"}return c.type==="linear"?`Linear ${c.angle}°`:"Radial Gradient"},z=class z{static defaults(){return{solid:[],gradient:[]}}static normalizeList(t){const e=new Set,i=[];return t.forEach(s=>{let n=F(s);n||T(s)&&(n=s),n&&(e.has(n)||(e.add(n),i.push(n)))}),i.slice(0,this.MAX_COLORS)}static ensureLoaded(){var t;if(!this.colors&&(this.colors=this.defaults(),!(typeof window>"u")))try{const e=(t=window.sessionStorage)==null?void 0:t.getItem(this.STORAGE_KEY);if(!e)return;const i=JSON.parse(e);if(Array.isArray(i))this.colors.solid=this.normalizeList(i);else if(i&&typeof i=="object"){const s=i;s.solid&&(this.colors.solid=this.normalizeList(s.solid)),s.gradient&&(this.colors.gradient=this.normalizeList(s.gradient))}}catch{this.colors=this.defaults()}}static persist(){var t;if(!(typeof window>"u"))try{(t=window.sessionStorage)==null||t.setItem(this.STORAGE_KEY,JSON.stringify(this.colors||this.defaults()))}catch{}}static list(t){return this.ensureLoaded(),this.colors||(this.colors=this.defaults()),this.colors[t]}static getColors(t){if(t==="all"){const e=this.list("solid"),i=this.list("gradient"),s=[...e,...i];return this.normalizeList(s)}return[...this.list(t)]}static addColor(t,e){if(!t)return;let i=F(t),s="solid";if(i)s="solid";else{const l=T(t);l&&(i=t,s=l.type==="solid"?"solid":"gradient")}if(!i)return;const n=e==="all"?s:e,o=this.list(n),a=o.indexOf(i);a!==-1&&o.splice(a,1),o.unshift(i),o.length>this.MAX_COLORS&&(o.length=this.MAX_COLORS),this.persist()}};z.STORAGE_KEY="settingsLib_recentColors",z.MAX_COLORS=12,z.colors=null;let B=z;const nt=(c,t)=>{const e=document.createElement("div");e.className="color-picker-recent-section";const i=document.createElement("div");i.className="color-picker-recent-title",i.textContent="Recently Used";const s=document.createElement("div");s.className="color-picker-tooltip",s.style.display="none",e.appendChild(s);const n=()=>{s.style.display="none"},o=(d,h)=>{const p=d.getBoundingClientRect();s.textContent=h,s.style.left=`${p.left+p.width/2}px`,s.style.top=`${p.bottom+8}px`,s.style.display="block"},a=document.createElement("div");a.className="color-picker-recent-grid";const l=document.createElement("div");l.className="color-picker-recent-placeholder",l.textContent="No recent colors yet",e.appendChild(i),e.appendChild(a),e.appendChild(l);const r=()=>{n(),a.innerHTML="";const d=B.getColors(t);if(d.length===0){a.style.display="none",l.style.display="block";return}a.style.display="grid",l.style.display="none",d.forEach(h=>{const p=document.createElement("button");p.type="button",p.className="color-picker-recent-swatch";const u=oe(h);p.title=u,p.setAttribute("aria-label",`Use color: ${u}`),p.style.background=h,p.style.borderColor=h,p.addEventListener("mouseenter",()=>o(p,u)),p.addEventListener("mouseleave",()=>{n(),p.style.boxShadow=""}),p.addEventListener("mousedown",()=>{p.style.boxShadow="0px 0px 0px 2px var(--grey40)"}),p.addEventListener("mouseup",()=>{setTimeout(()=>{p.style.boxShadow=""},150)}),p.addEventListener("click",()=>{n(),c(h)}),a.appendChild(p)})};return r(),{container:e,refresh:r}},oe=c=>{const t=T(c);if(t)return J(t);const e=F(c);if(e){const i=S(e);return`${e} (RGB: ${i.r}, ${i.g}, ${i.b})`}return c},yt=`<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
190
190
|
<path fill-rule="evenodd" clip-rule="evenodd"
|
|
191
191
|
d="M6.12347 4.96653L1.41158 0.254304C1.25449 0.102568 1.04409 0.0186071 0.825694 0.0205049C0.607302 0.0224037 0.398393 0.110007 0.24396 0.26445C0.0895282 0.418893 0.0019303 0.627818 3.24698e-05 0.846225C-0.00186536 1.06463 0.0820894 1.27505 0.233815 1.43215L4.9457 6.14438L0.233814 10.8566C0.0820886 11.0137 -0.00186625 11.2241 3.15434e-05 11.4425C0.00192934 11.6609 0.0895272 11.8699 0.243959 12.0243C0.398392 12.1787 0.607301 12.2663 0.825693 12.2682C1.04408 12.2701 1.25449 12.1862 1.41158 12.0344L6.12347 7.32222L10.8354 12.0344C10.9932 12.1824 11.2023 12.2632 11.4186 12.2597C11.6349 12.2562 11.8414 12.1687 11.9943 12.0156C12.1472 11.8626 12.2346 11.6561 12.2379 11.4398C12.2413 11.2234 12.1604 11.0143 12.0123 10.8566L7.30123 6.14438L12.0131 1.43215C12.0927 1.35531 12.1561 1.2634 12.1998 1.16177C12.2434 1.06014 12.2664 0.950833 12.2674 0.84023C12.2683 0.729626 12.2473 0.61994 12.2054 0.517568C12.1635 0.415196 12.1017 0.322191 12.0234 0.243979C11.9452 0.165768 11.8522 0.103916 11.7499 0.0620327C11.6475 0.0201492 11.5378 -0.000927989 11.4272 3.33052e-05C11.3166 0.000993646 11.2073 0.0239743 11.1057 0.0676297C11.0041 0.111286 10.9122 0.174745 10.8354 0.254305L6.12347 4.96653Z"
|
|
192
192
|
fill="#919EAB"/>
|
|
@@ -196,10 +196,10 @@
|
|
|
196
196
|
<path d="M14.1333 12.4667H0.8M0.8 12.4667L4.13333 9.13332M0.8 12.4667L4.13333 15.8M0.8 4.13332H14.1333M14.1333 4.13332L10.8 0.799988M14.1333 4.13332L10.8 7.46665" stroke="#919EAB" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
197
197
|
</svg>`,le=`<svg width="14" height="2" viewBox="0 0 14 2" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
198
198
|
<path d="M0.8 0.800003H12.4667" stroke="#919EAB" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
199
|
-
</svg>`;class re{constructor(t,e="gradient"){this.isOpen=!1,this.currentColor="#FF0000",this.currentOpacity=100,this.outsideClick=i=>{if(!this.isOpen)return;const s=i.target;if(this.element.contains(s))return;if(this.backdrop.contains(s)){i.preventDefault(),i.stopPropagation(),this.close(!0);return}const n=document.querySelectorAll(".gstop-color-input, .gstop-color-preview, .gradient-mini-preview");if(Array.from(n).some(l=>l.contains(s)))return;const a=document.querySelector(".gradient-popover");a&&a.contains(s)||(i.preventDefault(),i.stopPropagation(),this.close(!0))},this.keyDown=i=>{if(this.isOpen){if(i.key==="Escape")i.preventDefault(),this.close(!0);else if(i.key==="Enter"){const s=i.target;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"))return;i.preventDefault(),this.close(!0)}}},this.onChange=t,this.recentScope=e,this.element=this.build(),this.backdrop=this.createBackdrop()}parsePercentage(t){const e=parseFloat(t);return isNaN(e)?0:e/100}build(){const t=document.createElement("div");t.className="custom-color-picker",t.style.display="none";const e=document.createElement("div");e.className="color-picker-header",e.style.cursor="move";const i=document.createElement("span");i.textContent="Color";const s=document.createElement("button");s.className="color-picker-close",s.innerHTML=yt,s.addEventListener("click",()=>this.close(!0)),e.appendChild(i),e.appendChild(s),gt(e,t);const n=document.createElement("div");n.className="color-picker-area",this.colorArea=n;const o=document.createElement("div");o.className="color-picker-marker",this.colorMarker=o,n.appendChild(o);const a=document.createElement("div");a.className="color-picker-sliders-container";const l=document.createElement("button");l.className="color-picker-eyedropper",l.type="button",l.innerHTML=Et;const r=document.createElement("div");r.className="color-picker-sliders-group";const d=document.createElement("div");d.className="color-picker-hue",this.hueSlider=d;const h=document.createElement("div");h.className="color-picker-hue-marker",this.hueMarker=h,d.appendChild(h);const p=document.createElement("div");p.className="color-picker-opacity",this.opacitySlider=p;const u=document.createElement("div");u.className="color-picker-opacity-marker",this.opacityMarker=u,p.appendChild(u),r.appendChild(d),r.appendChild(p),a.appendChild(l),a.appendChild(r);const g=nt(E=>{var L;this.setColor(E),(L=this.onChange)==null||L.call(this,E,this.currentOpacity)},this.recentScope);this.recentSectionRefresh=g.refresh;const f=document.createElement("div");f.className="color-picker-format-section";const m=document.createElement("select");m.className="color-picker-format-select",this.select=m;const v=document.createElement("option");v.value="hex",v.textContent="HEX";const C=document.createElement("option");C.value="rgb",C.textContent="RGB";const x=document.createElement("option");x.value="hsl",x.textContent="HSL",m.appendChild(v),m.appendChild(C),m.appendChild(x);const k=document.createElement("input");k.type="text",k.className="color-picker-color-input",k.value=this.currentColor,this.input=k;const O=document.createElement("div");O.className="color-picker-input-container";const y=document.createElement("button");return y.className="color-picker-copy-inside",y.textContent="Copy",O.appendChild(k),O.appendChild(y),f.appendChild(m),f.appendChild(O),t.appendChild(e),t.appendChild(n),t.appendChild(a),t.appendChild(g.container),t.appendChild(f),t.addEventListener("click",E=>E.stopPropagation()),this.bind(n,d,p,k,m,y,l),t}createBackdrop(){const t=document.createElement("div");return t.className="color-picker-backdrop",t.style.display="none",t.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.close(!0)}),t}bind(t,e,i,s,n,o,a){const l=h=>{var C;const p=t.getBoundingClientRect(),u=Math.max(0,Math.min(1,(h.clientX-p.left)/p.width)),g=Math.max(0,Math.min(1,(h.clientY-p.top)/p.height));this.colorMarker.style.left=`${u*100}%`,this.colorMarker.style.top=`${g*100}%`;const m=this.parsePercentage(this.hueMarker.style.left||"0%")*360,v=R(m,u,1-g);this.currentColor=v,this.syncInput(),this.updateOpacityBg(),(C=this.onChange)==null||C.call(this,v,this.currentOpacity)},r=h=>{var C;const p=e.getBoundingClientRect();let u=Math.max(0,Math.min(1,(h.clientX-p.left)/p.width));this.hueMarker.style.left=`${u*100}%`;const g=u*360,f=this.parsePercentage(this.colorMarker.style.left||"0%"),m=this.parsePercentage(this.colorMarker.style.top||"0%"),v=R(g,f,1-m);this.currentColor=v,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${g}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(C=this.onChange)==null||C.call(this,v,this.currentOpacity)},d=h=>{var g;const p=i.getBoundingClientRect(),u=Math.max(0,Math.min(1,(h.clientX-p.left)/p.width));this.opacityMarker.style.left=`${u*100}%`,this.currentOpacity=Math.round(u*100),(g=this.onChange)==null||g.call(this,this.currentColor,this.currentOpacity)};t.addEventListener("mousedown",h=>{h.preventDefault(),l(h);const p=g=>l(g),u=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)}),e.addEventListener("mousedown",h=>{h.preventDefault(),r(h);const p=g=>r(g),u=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)}),i.addEventListener("mousedown",h=>{h.preventDefault(),d(h);const p=g=>d(g),u=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)}),n.addEventListener("change",()=>this.syncInput()),s.addEventListener("input",()=>this.applyFromInput()),s.addEventListener("blur",()=>this.syncInput()),s.addEventListener("keydown",h=>{h.key==="Enter"&&(h.preventDefault(),this.syncInput(),s.blur())}),o.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(s.value)}catch{s.select(),document.execCommand("copy")}}),a.addEventListener("click",async()=>{var h;if(!("EyeDropper"in window)){alert("EyeDropper API is not supported in this browser.");return}try{const p=new window.EyeDropper,{sRGBHex:u}=await p.open();this.setColor(u),(h=this.onChange)==null||h.call(this,u,this.currentOpacity)}catch{}}),document.addEventListener("keydown",this.keyDown,!0),setTimeout(()=>document.addEventListener("click",this.outsideClick,!0),0)}setColor(t){var o;this.currentColor=t;const{h:e,s:i,v:s}=D(t),n=e>=360?e%360:e;this.hueMarker.style.left=`${n/360*100}%`,this.colorMarker.style.left=`${i*100}%`,this.colorMarker.style.top=`${(1-s)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${n}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(o=this.onChange)==null||o.call(this,t,this.currentOpacity)}syncInput(){const t=this.select.value,{h:e,s:i,v:s}=D(this.currentColor);if(t==="hex")this.input.value=this.currentColor;else if(t==="rgb"){const{r:n,g:o,b:a}=S(this.currentColor);this.input.value=`rgb(${n}, ${o}, ${a})`}else{const{hue:n,sat:o,lightness:a}=mt(e,i,s);this.input.value=`hsl(${Math.round(n)}, ${Math.round(o*100)}%, ${Math.round(a*100)}%)`}}applyFromInput(){const t=this.input.value.trim();let e="";if(/^#[0-9A-Fa-f]{6}$/.test(t))e=t;else{const i=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(i){const s=parseInt(i[1]),n=parseInt(i[2]),o=parseInt(i[3]);s<=255&&n<=255&&o<=255&&(e=`#${[s,n,o].map(a=>a.toString(16).padStart(2,"0")).join("")}`)}else{const s=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const n=parseInt(s[1]),o=parseInt(s[2])/100,a=parseInt(s[3])/100,l=a+o*Math.min(a,1-a),r=l===0?0:2*(1-a/l);e=R(n,r,l)}}}e&&this.setColor(e)}updateOpacityBg(){const{r:t,g:e,b:i}=S(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${t}, ${e}, ${i})`)}open(t,e,i){var x;this.currentColor=t,this.currentOpacity=i??100,this.syncInput();const{h:s,s:n,v:o}=D(t);this.hueMarker.style.left=`${s/360*100}%`,this.colorMarker.style.left=`${n*100}%`,this.colorMarker.style.top=`${(1-o)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${s}, 100%, 50%))`,this.updateOpacityBg(),this.opacityMarker.style.left=`${this.currentOpacity}%`,(x=this.recentSectionRefresh)==null||x.call(this),this.isOpen=!0,this.backdrop.style.display="block",this.backdrop.parentElement||document.body.appendChild(this.backdrop),this.element.style.display="block",this.element.style.position="fixed",this.element.style.zIndex="10002",this.element.style.left="-9999px",this.element.style.top="0px",this.element.parentElement||document.body.appendChild(this.element);const a=this.element.offsetWidth,l=this.element.offsetHeight,r=e.getBoundingClientRect(),d=window.innerWidth,h=window.innerHeight,p=16;let u=r.right+8,g=r.top;const f=d-r.right,m=r.left;f>=a+p?u=r.right+8:m>=a+p?u=r.left-a-8:u=Math.max(p,(d-a)/2);const v=h-r.bottom,C=r.top;v>=l+p?g=r.bottom+8:C>=l+p?g=r.top-l-8:v>C?(g=r.bottom+8,g+l>h-p&&(g=h-l-p)):(g=r.top-l-8,g<p&&(g=p)),this.element.style.left=`${u}px`,this.element.style.top=`${g}px`}close(t){var e;this.isOpen&&(this.isOpen=!1,this.backdrop.style.display="none",this.element.style.display="none",document.removeEventListener("click",this.outsideClick,!0),document.removeEventListener("keydown",this.keyDown,!0),t&&this.onChange&&this.recentScope==="solid"&&(B.addColor(this.currentColor,this.recentScope),(e=this.recentSectionRefresh)==null||e.call(this)))}getElement(){return this.element}}class ce{constructor(t){this.currentColor=t.initialColor,this.currentOpacity=t.initialOpacity,this.onColorChange=t.onColorChange,this.recentScope=t.scope??"solid",this.element=this.build(),this.initFromColor(this.currentColor,this.currentOpacity)}parsePercentage(t){const e=parseFloat(t);return isNaN(e)?0:e/100}build(){const t=document.createElement("div");t.className="embedded-color-picker";const e=document.createElement("div");e.className="color-picker-area embedded",this.colorArea=e;const i=document.createElement("div");i.className="color-picker-marker",this.colorMarker=i,e.appendChild(i);const s=document.createElement("div");s.className="color-picker-sliders-container embedded";const n=document.createElement("button");n.className="color-picker-eyedropper",n.type="button",n.innerHTML=Et;const o=document.createElement("div");o.className="color-picker-sliders-group";const a=document.createElement("div");a.className="color-picker-hue embedded",this.hueSlider=a;const l=document.createElement("div");l.className="color-picker-hue-marker",this.hueMarker=l,a.appendChild(l);const r=document.createElement("div");r.className="color-picker-opacity embedded",this.opacitySlider=r;const d=document.createElement("div");d.className="color-picker-opacity-marker",this.opacityMarker=d,r.appendChild(d),o.appendChild(a),o.appendChild(r),s.appendChild(n),s.appendChild(o);const h=nt(k=>{this.setColor(k),this.onColorChange(this.currentColor,this.currentOpacity)},this.recentScope);this.recentSectionRefresh=h.refresh;const p=document.createElement("div");p.className="color-picker-format-section embedded";const u=document.createElement("select");u.className="color-picker-format-select",this.select=u;const g=document.createElement("option");g.value="hex",g.textContent="HEX";const f=document.createElement("option");f.value="rgb",f.textContent="RGB";const m=document.createElement("option");m.value="hsl",m.textContent="HSL",u.appendChild(g),u.appendChild(f),u.appendChild(m);const v=document.createElement("input");v.type="text",v.className="color-picker-color-input",this.input=v;const C=document.createElement("div");C.className="color-picker-input-container";const x=document.createElement("button");return x.className="color-picker-copy-inside",x.textContent="Copy",C.appendChild(v),C.appendChild(x),p.appendChild(u),p.appendChild(C),t.appendChild(e),t.appendChild(s),t.appendChild(h.container),t.appendChild(p),this.bind(e,a,r,v,u,x,n),t}bind(t,e,i,s,n,o,a){const l=h=>{const p=t.getBoundingClientRect(),u=Math.max(0,Math.min(1,(h.clientX-p.left)/p.width)),g=Math.max(0,Math.min(1,(h.clientY-p.top)/p.height));this.colorMarker.style.left=`${u*100}%`,this.colorMarker.style.top=`${g*100}%`;const m=this.parsePercentage(this.hueMarker.style.left||"0%")*360,v=R(m,u,1-g);this.currentColor=v,this.syncInput(),this.updateOpacityBg(),this.onColorChange(this.currentColor,this.currentOpacity)},r=h=>{const p=e.getBoundingClientRect(),u=Math.max(0,Math.min(1,(h.clientX-p.left)/p.width));this.hueMarker.style.left=`${u*100}%`;const g=u*360,f=this.parsePercentage(this.colorMarker.style.left||"0%"),m=this.parsePercentage(this.colorMarker.style.top||"0%"),v=R(g,f,1-m);this.currentColor=v,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
|
|
200
|
-
linear-gradient(to right, #fff, hsl(${g}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),this.
|
|
201
|
-
linear-gradient(to right, #fff, hsl(${n}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg()}syncInput(){const t=this.select.value,{h:e,s:i,v:s}=D(this.currentColor);if(t==="hex")this.input.value=this.currentColor;else if(t==="rgb"){const{r:n,g:o,b:a}=S(this.currentColor);this.input.value=`rgb(${n}, ${o}, ${a})`}else{const{hue:n,sat:o,lightness:a}=mt(e,i,s);this.input.value=`hsl(${Math.round(n)}, ${Math.round(o*100)}%, ${Math.round(a*100)}%)`}}applyFromInput(){const t=this.input.value.trim();let e="";if(/^#[0-9A-Fa-f]{6}$/.test(t))e=t;else{const i=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(i){const s=parseInt(i[1],10),n=parseInt(i[2],10),o=parseInt(i[3],10);s<=255&&n<=255&&o<=255&&(e="#"+[s,n,o].map(a=>a.toString(16).padStart(2,"0")).join(""))}else{const s=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const n=parseInt(s[1],10),o=parseInt(s[2],10)/100,a=parseInt(s[3],10)/100,l=a+o*Math.min(a,1-a),r=l===0?0:2*(1-a/l);e=R(n,r,l)}}}e&&(this.setColor(e),this.onColorChange(this.currentColor,this.currentOpacity))}updateOpacityBg(){const{r:t,g:e,b:i}=S(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${t}, ${e}, ${i})`)}initFromColor(t,e){var a;this.currentColor=t,this.currentOpacity=e;const{h:i,s,v:n}=D(t),o=i>=360?i%360:i;this.hueMarker.style.left=`${o/360*100}%`,this.colorMarker.style.left=`${s*100}%`,this.colorMarker.style.top=`${(1-n)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
|
|
202
|
-
linear-gradient(to right, #fff, hsl(${o}, 100%, 50%))`,this.opacityMarker.style.left=`${e}%`,this.updateOpacityBg(),this.syncInput(),(a=this.recentSectionRefresh)==null||a.call(this)}commitRecentColor(){var t;this.recentScope==="solid"&&(B.addColor(this.currentColor,this.recentScope),(t=this.recentSectionRefresh)==null||t.call(this))}getElement(){return this.element}updateColor(t,e){this.initFromColor(t,e)}}const T=class T extends b{constructor(t={}){const e=typeof t.default=="string"?void 0:t.default;super({...t,title:t.title||"Color",default:e}),this.inputType={type:"text",angle:"number",stops:"text"},this.element=null,this.previewEl=null,this.inputEl=void 0,this.popoverEl=null,this.backdropEl=null,this.isPopoverOpen=!1,this.isEditing=!1,this.popoverPosition=null,this.previewUpdateTimeout=null,this.solidPicker=null,this.pendingSolidColor=null,this.onBackgroundClick=i=>{var p;if(!this.popoverEl||!this.isPopoverOpen)return;const s=i.target,n=this.popoverEl.contains(s),o=(p=this.element)==null?void 0:p.contains(s),a=document.querySelectorAll(".custom-color-picker"),l=Array.from(a).some(u=>u.contains(s)),r=s.closest(".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"),d=s.classList.contains("color-picker-backdrop"),h=s.classList.contains("gradient-popover-backdrop");!n&&!o&&!l&&!r&&!d&&!h&&this.closePopover()},this.handlePopoverKeydown=i=>{if(this.isPopoverOpen){if(i.key==="Escape"){i.preventDefault(),this.closePopover();return}if(i.key==="Enter"){const s=i.target;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"))return;i.preventDefault(),this.closePopover()}}},this.detectChange=t.detectChange,this.originalDefault=t.default,this.value=this.defaultValue()}defaultValue(){const t=this.originalDefault;if(typeof t=="string"){const i=P(t);if(i)return A(i)}return A(t&&typeof t=="object"?t:{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]})}setValue(t){var i,s;let e=null;typeof t=="string"?e=P(t):t&&typeof t=="object"&&(e=A(t)),e||(e=this.defaultValue()),this.value=e,this.updateUI(),this.isPopoverOpen&&this.refreshPopoverContent(),(i=this.onChange)==null||i.call(this,this.value),(s=this.detectChange)==null||s.call(this,this.value),this.pendingSolidColor=null}updateUI(){if(this.previewEl&&this.value)if(this.value.type==="solid"){const t=this.value.stops[0],e=t.opacity??100;this.previewEl.style.background=ft(t.color,e)}else this.previewEl.style.background=V(this.value);this.inputEl&&this.value&&!this.isEditing&&(this.inputEl.value=J(this.value))}cssForTextValue(){return this.value?{background:V(this.value),"-webkit-background-clip":"text","background-clip":"text",color:"transparent","-webkit-text-fill-color":"transparent"}:{}}draw(){const t=document.createElement("div");if(t.className="gradient-setting-wrapper",this.props.title){const i=document.createElement("div");i.className="icon-container";const s=document.createElement("span");s.className="input-label",s.textContent=this.props.title,i.appendChild(s),t.appendChild(i)}const e=document.createElement("div");return e.className="gradient-input-wrapper",this.previewEl=document.createElement("div"),this.previewEl.className="gradient-mini-preview",this.previewEl.style.background=this.value?V(this.value):"linear-gradient(90deg, #a84b4b 0%, #786666 100%)",this.previewEl.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.openPopover()}),this.inputEl=document.createElement("input"),this.inputEl.type="text",this.inputEl.className="gradient-text-input",this.inputEl.placeholder="Enter gradient CSS or paste color...",this.inputEl.value=this.value?J(this.value):"",this.inputEl.readOnly=!1,this.inputEl.addEventListener("focus",()=>{if(this.isEditing=!0,this.value)if(this.value.type==="solid"){const i=this.value.stops[0];if(i){const s=i.color.toUpperCase(),n=i.opacity??100;if(n===100)this.inputEl.value=s;else{const a=Math.round(n/100*255).toString(16).toUpperCase().padStart(2,"0");this.inputEl.value=`${s}${a}`}}}else this.inputEl.value=V(this.value)}),this.inputEl.addEventListener("blur",()=>{this.isEditing=!1,this.value&&(this.inputEl.value=J(this.value))}),this.inputEl.addEventListener("paste",i=>this.handlePaste(i)),this.inputEl.addEventListener("input",i=>this.handleTextInput(i)),this.inputEl.addEventListener("keydown",i=>{i.key==="Enter"&&(this.handleTextInput(i),this.inputEl.blur()),i.key==="Escape"&&(this.value&&(this.inputEl.value=V(this.value)),this.inputEl.blur())}),e.appendChild(this.previewEl),e.appendChild(this.inputEl),t.appendChild(e),this.createPopover(),this.element=t,t}createPopover(){if(this.popoverEl)return;this.backdropEl=document.createElement("div"),this.backdropEl.className="gradient-popover-backdrop",this.backdropEl.style.display="none",this.backdropEl.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.closePopover()}),this.popoverEl=document.createElement("div"),this.popoverEl.className="gradient-popover",this.popoverEl.style.display="none",this.popoverEl.addEventListener("click",a=>{a.stopPropagation()});const t=document.createElement("div");t.className="gradient-popover-header",t.style.cursor="move";const e=document.createElement("span");e.textContent="Fill";const i=document.createElement("button");i.type="button",i.className="gradient-popover-close",i.innerHTML=yt,i.addEventListener("click",()=>this.closePopover()),t.appendChild(e),t.appendChild(i),gt(t,this.popoverEl,(a,l)=>{this.popoverPosition={left:a,top:l}});const s=document.createElement("div");s.className="gradient-editor";const n=this.createTypeTabs();s.appendChild(n);const o=document.createElement("div");o.className="gradient-editor-content",this.updatePopoverContent(o),s.appendChild(o),this.popoverEl.appendChild(t),this.popoverEl.appendChild(s),document.body.appendChild(this.backdropEl),document.body.appendChild(this.popoverEl)}createTypeTabs(){var s,n;const t=document.createElement("div");t.className="gradient-type-tabs";const e=document.createElement("button");e.type="button",e.className=`gradient-type-tab ${((s=this.value)==null?void 0:s.type)==="solid"?"active":""}`,e.textContent="Solid",e.addEventListener("click",()=>this.switchType("solid"));const i=document.createElement("button");return i.type="button",i.className=`gradient-type-tab ${((n=this.value)==null?void 0:n.type)!=="solid"?"active":""}`,i.textContent="Gradient",i.addEventListener("click",()=>{var a,l;const o=((a=this.value)==null?void 0:a.type)==="solid"?"linear":((l=this.value)==null?void 0:l.type)||"linear";this.switchType(o)}),t.appendChild(e),t.appendChild(i),t}switchType(t){var i;if(!this.value)return;if(this.value.type=t,t!=="solid"&&(!this.value.stops||this.value.stops.length===0)&&(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]),t!=="solid"&&this.value.stops.length<2&&(this.value.angle=90),this.popoverEl){const s=this.popoverEl.querySelectorAll(".gradient-type-tab");s.forEach(a=>a.classList.remove("active"));const n=s[0],o=s[1];t==="solid"?n==null||n.classList.add("active"):o==null||o.classList.add("active")}const e=(i=this.popoverEl)==null?void 0:i.querySelector(".gradient-editor-content");e&&this.updatePopoverContent(e),this.updateUI(),this.triggerChange()}updatePopoverContent(t){t.innerHTML="",this.value&&(this.value.type==="solid"?this.renderSolid(t):this.renderGradient(t))}renderSolid(t){(!this.value||!this.value.stops||!this.value.stops.length)&&(this.value||(this.value=this.defaultValue()),this.value.stops=[{color:"#000000",position:0,opacity:100}]);const e=this.value.stops[0],i=new ce({initialColor:e.color,initialOpacity:e.opacity??100,onColorChange:(s,n)=>{if(this.value){const o=P(s);if(o&&o.type!=="solid"){this.value=o,this.switchType(o.type);return}this.value.stops[0].color=s,this.value.stops[0].opacity=n,this.updateUI(),this.triggerChange(),this.pendingSolidColor=s}}});this.solidPicker=i,t.appendChild(i.getElement())}renderGradient(t){this.solidPicker=null;const e=document.createElement("div");e.className="gradient-subtype-inline";const i=document.createElement("select");i.className="gradient-subtype-select";const s=document.createElement("option");s.value="linear",s.textContent="Linear";const n=document.createElement("option");n.value="radial",n.textContent="Radial",i.appendChild(s),i.appendChild(n),i.value=this.value.type==="radial"?"radial":"linear";const o=document.createElement("input");o.type="text",o.inputMode="numeric",o.className="gradient-degree-input",o.value=`${this.value.angle??90}°`,o.style.width="75px",o.style.textAlign="center",(!this.value.angle||this.value.stops.length<2)&&(this.value.angle=90,o.value="90°");const a=document.createElement("button");a.type="button",a.className="gradient-flip-btn",a.innerHTML=ae,i.addEventListener("change",()=>{this.switchType(i.value==="radial"?"radial":"linear"),this.updateDegreeVisibility(o)}),o.addEventListener("focus",f=>{const m=f.target;m.value=m.value.replace(/[^0-9-]/g,""),setTimeout(()=>m.select(),0)}),o.addEventListener("input",f=>{const m=parseInt(f.target.value);!Number.isNaN(m)&&this.value&&(this.value.angle=Math.max(0,Math.min(360,m)),this.debouncedPreviewUpdate())}),o.addEventListener("blur",f=>{var C;this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const m=f.target;let v=parseInt(m.value);Number.isNaN(v)&&(v=((C=this.value)==null?void 0:C.angle)??0),v=Math.max(0,Math.min(360,v)),this.value&&(this.value.angle=v),m.value=`${v}°`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),a.addEventListener("click",()=>{!this.value||!this.value.stops||(this.value.stops.forEach(f=>{f.position=100-f.position}),this.value.stops.sort((f,m)=>f.position-m.position),this.updateGradientPreview(l),this.createHandles(r,l),this.updateStopsList(u),this.updateUI(),this.triggerChange())}),e.appendChild(i),e.appendChild(o),e.appendChild(a),t.appendChild(e),this.updateDegreeVisibility(o);const l=document.createElement("div");l.className="gradient-preview",this.updateGradientPreview(l);const r=document.createElement("div");r.className="gradient-handles",l.appendChild(r),t.appendChild(l),this.createHandles(r,l);const d=document.createElement("div");d.className="gradient-stops-header";const h=document.createElement("span");h.textContent="Stops";const p=document.createElement("button");p.type="button",p.className="gradient-add-stop",p.textContent="+",d.appendChild(h),d.appendChild(p);const u=document.createElement("div");u.className="gradient-stops",t.appendChild(d),t.appendChild(u),this.updateStopsList(u);const g=nt(f=>{const m=P(f);m&&(this.value=m,this.switchType(m.type),this.updateUI(),this.triggerChange())},"all");this.recentGradientRefresh=g.refresh,t.appendChild(g.container),p.addEventListener("click",()=>{var f;this.addStop(),this.updateStopsList(u),this.updateGradientPreview(l),this.createHandles(r,l),this.updateUI(),((f=document.activeElement)==null?void 0:f.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()})}updateDegreeVisibility(t){var e;((e=this.value)==null?void 0:e.type)==="radial"?(t.disabled=!0,t.style.opacity="0.5"):(t.disabled=!1,t.style.opacity="1")}updateGradientPreview(t){var i;const e=t||((i=this.popoverEl)==null?void 0:i.querySelector(".gradient-preview"));e&&this.value&&(e.style.background=V(this.value))}debouncedPreviewUpdate(t){this.previewUpdateTimeout&&clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=window.setTimeout(()=>{this.updateGradientPreview(t),this.previewUpdateTimeout=null},16)}createHandles(t,e){t.innerHTML="",!(!this.value||this.value.type==="solid"||!this.value.stops)&&this.value.stops.forEach((i,s)=>{const n=document.createElement("div");n.className="gstop-handle",n.style.left=`${Math.max(0,Math.min(100,i.position))}%`,n.style.top="0%";const o=document.createElement("div");o.className="gstop-chip",o.style.backgroundColor=i.color,n.appendChild(o);let a=!1,l=0,r=0;const d=u=>{a=!0,l=u.clientX,r=this.value.stops[s].position,n.classList.add("selected"),document.addEventListener("mousemove",h),document.addEventListener("mouseup",p),u.preventDefault(),u.stopPropagation()},h=u=>{if(!a||!this.value)return;const g=e.getBoundingClientRect(),f=u.clientX-l;let m=r+f/g.width*100;m=Math.max(0,Math.min(100,m)),this.value.stops[s].position=Math.round(m),n.style.left=`${m}%`,this.updateGradientPreview()},p=()=>{a&&(a=!1,n.classList.remove("selected"),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p),this.value&&(this.value.stops.sort((u,g)=>u.position-g.position),this.createHandles(t,e),this.updateStopsList()),this.updateUI(),this.triggerChange())};n.addEventListener("mousedown",d),t.appendChild(n)})}updateStopsList(t){var i;const e=t||((i=this.popoverEl)==null?void 0:i.querySelector(".gradient-stops"));!e||!this.value||this.value.type==="solid"||!this.value.stops||(e.innerHTML="",this.value.stops.forEach((s,n)=>{var k,O;const o=document.createElement("div");o.className="gstop-row";const a=document.createElement("div");a.className="gstop-position-group";const l=document.createElement("input");l.type="text",l.className="gstop-position-input",l.value=`${s.position}%`,l.style.width="60px",a.appendChild(l);const r=document.createElement("div");r.className="gstop-color-container";const d=document.createElement("div");d.className="gstop-color-preview",d.style.backgroundColor=s.color;const h=document.createElement("input");h.type="text",h.className="gstop-color-input",h.value=s.color.replace("#","").toUpperCase();const p=document.createElement("button");p.type="button",p.className="gstop-color-copy",p.textContent="Copy",r.appendChild(d),r.appendChild(h),r.appendChild(p);const u=document.createElement("button");u.type="button",u.className="gstop-del",u.innerHTML=le,u.disabled=(((O=(k=this.value)==null?void 0:k.stops)==null?void 0:O.length)||0)<=2,o.appendChild(a),o.appendChild(r),o.appendChild(u),e.appendChild(o);const g=document.createElement("span");g.className="gstop-opacity-label",g.textContent="Opacity";const f=document.createElement("div");f.className="gstop-opacity-group";const m=document.createElement("input");m.type="range",m.className="gstop-opacity-slider",m.min="0",m.max="100",m.value=String(s.opacity??100);const v=S(s.color);m.style.setProperty("--slider-color",`rgb(${v.r}, ${v.g}, ${v.b})`);const C=document.createElement("span");C.className="gstop-opacity-value",C.textContent=`${s.opacity??100}%`,f.appendChild(m),f.appendChild(C);const x=new re((y,E)=>{h.value=y.replace("#","").toUpperCase(),d.style.backgroundColor=y,this.value.stops[n].color=y,E!==void 0&&(this.value.stops[n].opacity=E,m.value=String(E),C.textContent=`${E}%`);const L=S(y);m.style.setProperty("--slider-color",`rgb(${L.r}, ${L.g}, ${L.b})`),this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()},"solid");h.addEventListener("click",y=>{y.preventDefault(),y.stopPropagation(),x.open(s.color,h,s.opacity??100)}),h.addEventListener("input",()=>{const y=h.value.trim(),E=y.startsWith("#")?y:`#${y}`;if(/^#[0-9A-Fa-f]{6}$/.test(E)){this.value.stops[n].color=E,d.style.backgroundColor=E;const L=S(E);m.style.setProperty("--slider-color",`rgb(${L.r}, ${L.g}, ${L.b})`),this.debouncedPreviewUpdate()}}),h.addEventListener("blur",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),p.addEventListener("click",async y=>{y.stopPropagation();try{await navigator.clipboard.writeText(`#${h.value}`)}catch{}}),l.addEventListener("focus",y=>{const E=y.target;E.value=E.value.replace("%",""),E.select()}),l.addEventListener("input",y=>{const E=y.target,L=parseInt(E.value.replace(/[^\d]/g,""),10);if(!Number.isNaN(L)){const G=Math.max(0,Math.min(100,L));this.value.stops[n].position=G,E.value=`${G}%`,this.debouncedPreviewUpdate()}}),l.addEventListener("blur",y=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const E=y.target,L=parseInt(E.value.replace(/[^\d]/g,""),10);if(Number.isNaN(L))E.value=`${this.value.stops[n].position}%`;else{const G=Math.max(0,Math.min(100,L));this.value.stops[n].position=G,E.value=`${G}%`}this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateUI(),this.triggerChange()}),u.addEventListener("click",()=>{var y;(this.value.stops.length||0)<=2||(this.value.stops.splice(n,1),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateGradientPreview(),this.updateUI(),((y=document.activeElement)==null?void 0:y.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange())}),m.addEventListener("input",()=>{const y=parseInt(m.value,10);this.value.stops[n].opacity=Math.max(0,Math.min(100,y)),C.textContent=`${this.value.stops[n].opacity}%`,this.debouncedPreviewUpdate()}),m.addEventListener("change",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()})}))}addStop(){if(!this.value||this.value.type==="solid"||!this.value.stops)return;const t=this.value.stops.map(o=>o.position).sort((o,a)=>o-a);let e=50,i=0;for(let o=0;o<t.length-1;o++){const a=t[o+1]-t[o];a>i&&(i=a,e=t[o]+a/2)}const s=this.value.stops.reduce((o,a)=>Math.abs(a.position-e)<Math.abs(o.position-e)?a:o),n={position:Math.round(e),color:s.color,opacity:s.opacity??100};this.value.stops.push(n),this.value.stops.sort((o,a)=>o.position-a.position)}openPopover(){if(this.popoverEl&&(T.openInstance&&T.openInstance!==this&&T.openInstance.closePopover(),!this.isPopoverOpen)){if(this.isPopoverOpen=!0,T.openInstance=this,this.backdropEl&&(this.backdropEl.style.display="block",this.backdropEl.parentElement||document.body.appendChild(this.backdropEl)),this.popoverEl.style.display="flex",this.refreshPopoverContent(),this.element){const t=this.element.getBoundingClientRect(),e=306,i=window.innerWidth,s=window.innerHeight,n=16;this.popoverEl.style.position="fixed",this.popoverEl.style.zIndex="10000",this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const o=this.popoverEl.offsetHeight;let a=t.right+8,l=t.top;const r=i-t.right,d=t.left,h=e+n;r<h&&d>r+100&&(a=t.left-e-8);const p=s-t.bottom,u=t.top;u>=o+n?l=t.top-o-8:p>=o+n?l=t.bottom+8:u>p?(l=t.top-o-8,l<n&&(l=n)):(l=t.bottom+8,l+o>s-n&&(l=s-o-n)),this.popoverEl.style.left=`${a}px`,this.popoverEl.style.top=`${l}px`,this.popoverPosition={left:a,top:l}}setTimeout(()=>document.addEventListener("click",this.onBackgroundClick,!0),200),document.addEventListener("keydown",this.handlePopoverKeydown,!0)}}repositionPopover(){var t;if(!(!this.popoverEl||!this.isPopoverOpen||!this.element)&&((t=document.activeElement)==null?void 0:t.tagName)!=="INPUT"){if(this.popoverPosition){this.popoverEl.style.left=`${this.popoverPosition.left}px`,this.popoverEl.style.top=`${this.popoverPosition.top}px`;return}requestAnimationFrame(()=>{if(!this.popoverEl||!this.element)return;const e=this.element.getBoundingClientRect(),i=306,s=window.innerWidth,n=window.innerHeight,o=16;this.popoverEl.style.left,this.popoverEl.style.top,this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const a=this.popoverEl.offsetHeight;let l=e.right+8,r=e.top;const d=s-e.right,h=e.left,p=i+o;d<p&&h>d+100&&(l=e.left-i-8);const u=n-e.bottom,g=e.top;g>=a+o?r=e.top-a-8:u>=a+o?r=e.bottom+8:g>u?(r=e.top-a-8,r<o&&(r=o)):(r=e.bottom+8,r+a>n-o&&(r=n-a-o)),this.popoverEl.style.left=`${l}px`,this.popoverEl.style.top=`${r}px`})}}refreshPopoverContent(){var n,o;if(!this.popoverEl)return;const t=this.popoverEl.querySelectorAll(".gradient-type-tab");t.forEach(a=>a.classList.remove("active"));const e=t[0],i=t[1];((n=this.value)==null?void 0:n.type)==="solid"?e.classList.add("active"):(i.classList.add("active"),(o=this.recentGradientRefresh)==null||o.call(this)),this.popoverEl.offsetHeight;const s=this.popoverEl.querySelector(".gradient-editor-content");s&&this.updatePopoverContent(s)}closePopover(){var t;if(!(!this.popoverEl||!this.isPopoverOpen)){if(this.isPopoverOpen=!1,this.popoverPosition=null,this.backdropEl&&(this.backdropEl.style.display="none"),this.popoverEl.style.display="none",document.removeEventListener("click",this.onBackgroundClick,!0),document.removeEventListener("keydown",this.handlePopoverKeydown,!0),this.commitPendingSolidColor(),this.value&&this.value.type!=="solid"){const e=V(this.value);B.addColor(e,"gradient"),(t=this.recentGradientRefresh)==null||t.call(this)}this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),T.openInstance===this&&(T.openInstance=null)}}commitPendingSolidColor(){this.pendingSolidColor&&(this.solidPicker?this.solidPicker.commitRecentColor():B.addColor(this.pendingSolidColor,"solid"),this.pendingSolidColor=null)}handlePaste(t){var i;t.preventDefault();const e=((i=t.clipboardData)==null?void 0:i.getData("text"))||"";this.parseAndSet(e)}handleTextInput(t){const e=t.target;this.parseAndSet(e.value)}parseAndSet(t){const e=P(t.trim());e&&this.setValue(e)}triggerChange(){var t,e;this.value&&((t=this.onChange)==null||t.call(this,this.value),(e=this.detectChange)==null||e.call(this,this.value))}getElement(){return this.element}getValue(){return this.value?V(this.value):""}getCSSValue(){return this.value?V(this.value):""}getCSSForText(){return this.value?this.cssForTextValue():{}}getRawValue(){return this.value}};T.openInstance=null;let W=T;const he=`
|
|
199
|
+
</svg>`;class re{constructor(t,e="gradient"){this.isOpen=!1,this.currentColor="#FF0000",this.currentOpacity=100,this.outsideClick=i=>{if(!this.isOpen)return;const s=i.target;if(this.element.contains(s))return;if(this.backdrop.contains(s)){i.preventDefault(),i.stopPropagation(),this.close(!0);return}const n=document.querySelectorAll(".gstop-color-input, .gstop-color-preview, .gradient-mini-preview");if(Array.from(n).some(l=>l.contains(s)))return;const a=document.querySelector(".gradient-popover");a&&a.contains(s)||(i.preventDefault(),i.stopPropagation(),this.close(!0))},this.keyDown=i=>{if(this.isOpen){if(i.key==="Escape")i.preventDefault(),this.close(!0);else if(i.key==="Enter"){const s=i.target;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"))return;i.preventDefault(),this.close(!0)}}},this.onChange=t,this.recentScope=e,this.element=this.build(),this.backdrop=this.createBackdrop()}parsePercentage(t){const e=parseFloat(t);return isNaN(e)?0:e/100}build(){const t=document.createElement("div");t.className="custom-color-picker",t.style.display="none";const e=document.createElement("div");e.className="color-picker-header",e.style.cursor="move";const i=document.createElement("span");i.textContent="Color";const s=document.createElement("button");s.className="color-picker-close",s.innerHTML=yt,s.addEventListener("click",()=>this.close(!0)),e.appendChild(i),e.appendChild(s),gt(e,t);const n=document.createElement("div");n.className="color-picker-area",this.colorArea=n;const o=document.createElement("div");o.className="color-picker-marker",this.colorMarker=o,n.appendChild(o);const a=document.createElement("div");a.className="color-picker-sliders-container";const l=document.createElement("button");l.className="color-picker-eyedropper",l.type="button",l.innerHTML=Et;const r=document.createElement("div");r.className="color-picker-sliders-group";const d=document.createElement("div");d.className="color-picker-hue",this.hueSlider=d;const h=document.createElement("div");h.className="color-picker-hue-marker",this.hueMarker=h,d.appendChild(h);const p=document.createElement("div");p.className="color-picker-opacity",this.opacitySlider=p;const u=document.createElement("div");u.className="color-picker-opacity-marker",this.opacityMarker=u,p.appendChild(u),r.appendChild(d),r.appendChild(p),a.appendChild(l),a.appendChild(r);const g=nt(E=>{var L;this.setColor(E),(L=this.onChange)==null||L.call(this,E,this.currentOpacity)},this.recentScope);this.recentSectionRefresh=g.refresh;const f=document.createElement("div");f.className="color-picker-format-section";const m=document.createElement("select");m.className="color-picker-format-select",this.select=m;const v=document.createElement("option");v.value="hex",v.textContent="HEX";const C=document.createElement("option");C.value="rgb",C.textContent="RGB";const x=document.createElement("option");x.value="hsl",x.textContent="HSL",m.appendChild(v),m.appendChild(C),m.appendChild(x);const k=document.createElement("input");k.type="text",k.className="color-picker-color-input",k.value=this.currentColor,this.input=k;const O=document.createElement("div");O.className="color-picker-input-container";const y=document.createElement("button");return y.className="color-picker-copy-inside",y.textContent="Copy",O.appendChild(k),O.appendChild(y),f.appendChild(m),f.appendChild(O),t.appendChild(e),t.appendChild(n),t.appendChild(a),t.appendChild(g.container),t.appendChild(f),t.addEventListener("click",E=>E.stopPropagation()),this.bind(n,d,p,k,m,y,l),t}createBackdrop(){const t=document.createElement("div");return t.className="color-picker-backdrop",t.style.display="none",t.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.close(!0)}),t}bind(t,e,i,s,n,o,a){const l=h=>{var C;const p=t.getBoundingClientRect(),u=Math.max(0,Math.min(1,(h.clientX-p.left)/p.width)),g=Math.max(0,Math.min(1,(h.clientY-p.top)/p.height));this.colorMarker.style.left=`${u*100}%`,this.colorMarker.style.top=`${g*100}%`;const m=this.parsePercentage(this.hueMarker.style.left||"0%")*360,v=R(m,u,1-g);this.currentColor=v,this.syncInput(),this.updateOpacityBg(),(C=this.onChange)==null||C.call(this,v,this.currentOpacity)},r=h=>{var C;const p=e.getBoundingClientRect();let u=Math.max(0,Math.min(1,(h.clientX-p.left)/p.width));this.hueMarker.style.left=`${u*100}%`;const g=u*360,f=this.parsePercentage(this.colorMarker.style.left||"0%"),m=this.parsePercentage(this.colorMarker.style.top||"0%"),v=R(g,f,1-m);this.currentColor=v,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${g}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(C=this.onChange)==null||C.call(this,v,this.currentOpacity)},d=h=>{var g;const p=i.getBoundingClientRect(),u=Math.max(0,Math.min(1,(h.clientX-p.left)/p.width));this.opacityMarker.style.left=`${u*100}%`,this.currentOpacity=Math.round(u*100),(g=this.onChange)==null||g.call(this,this.currentColor,this.currentOpacity)};t.addEventListener("mousedown",h=>{h.preventDefault(),l(h);const p=g=>l(g),u=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)}),e.addEventListener("mousedown",h=>{h.preventDefault(),r(h);const p=g=>r(g),u=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)}),i.addEventListener("mousedown",h=>{h.preventDefault(),d(h);const p=g=>d(g),u=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)}),n.addEventListener("change",()=>this.syncInput()),s.addEventListener("input",()=>this.applyFromInput()),s.addEventListener("blur",()=>this.syncInput()),s.addEventListener("keydown",h=>{h.key==="Enter"&&(h.preventDefault(),this.syncInput(),s.blur())}),o.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(s.value)}catch{s.select(),document.execCommand("copy")}}),a.addEventListener("click",async()=>{var h;if(!("EyeDropper"in window)){alert("EyeDropper API is not supported in this browser.");return}try{const p=new window.EyeDropper,{sRGBHex:u}=await p.open();this.setColor(u),(h=this.onChange)==null||h.call(this,u,this.currentOpacity)}catch{}}),document.addEventListener("keydown",this.keyDown,!0),setTimeout(()=>document.addEventListener("click",this.outsideClick,!0),0)}setColor(t){var o;this.currentColor=t;const{h:e,s:i,v:s}=D(t),n=e>=360?e%360:e;this.hueMarker.style.left=`${n/360*100}%`,this.colorMarker.style.left=`${i*100}%`,this.colorMarker.style.top=`${(1-s)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${n}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(o=this.onChange)==null||o.call(this,t,this.currentOpacity)}syncInput(){const t=this.select.value,{h:e,s:i,v:s}=D(this.currentColor);if(t==="hex")this.input.value=this.currentColor;else if(t==="rgb"){const{r:n,g:o,b:a}=S(this.currentColor);this.input.value=`rgb(${n}, ${o}, ${a})`}else{const{hue:n,sat:o,lightness:a}=mt(e,i,s);this.input.value=`hsl(${Math.round(n)}, ${Math.round(o*100)}%, ${Math.round(a*100)}%)`}}applyFromInput(){const t=this.input.value.trim();let e="";if(/^#[0-9A-Fa-f]{6}$/.test(t))e=t;else{const i=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(i){const s=parseInt(i[1]),n=parseInt(i[2]),o=parseInt(i[3]);s<=255&&n<=255&&o<=255&&(e=`#${[s,n,o].map(a=>a.toString(16).padStart(2,"0")).join("")}`)}else{const s=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const n=parseInt(s[1]),o=parseInt(s[2])/100,a=parseInt(s[3])/100,l=a+o*Math.min(a,1-a),r=l===0?0:2*(1-a/l);e=R(n,r,l)}}}e&&this.setColor(e)}updateOpacityBg(){const{r:t,g:e,b:i}=S(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${t}, ${e}, ${i})`)}open(t,e,i){var x;this.currentColor=t,this.currentOpacity=i??100,this.syncInput();const{h:s,s:n,v:o}=D(t);this.hueMarker.style.left=`${s/360*100}%`,this.colorMarker.style.left=`${n*100}%`,this.colorMarker.style.top=`${(1-o)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${s}, 100%, 50%))`,this.updateOpacityBg(),this.opacityMarker.style.left=`${this.currentOpacity}%`,(x=this.recentSectionRefresh)==null||x.call(this),this.isOpen=!0,this.backdrop.style.display="block",this.backdrop.parentElement||document.body.appendChild(this.backdrop),this.element.style.display="block",this.element.style.position="fixed",this.element.style.zIndex="10002",this.element.style.left="-9999px",this.element.style.top="0px",this.element.parentElement||document.body.appendChild(this.element);const a=this.element.offsetWidth,l=this.element.offsetHeight,r=e.getBoundingClientRect(),d=window.innerWidth,h=window.innerHeight,p=16;let u=r.right+8,g=r.top;const f=d-r.right,m=r.left;f>=a+p?u=r.right+8:m>=a+p?u=r.left-a-8:u=Math.max(p,(d-a)/2);const v=h-r.bottom,C=r.top;v>=l+p?g=r.bottom+8:C>=l+p?g=r.top-l-8:v>C?(g=r.bottom+8,g+l>h-p&&(g=h-l-p)):(g=r.top-l-8,g<p&&(g=p)),this.element.style.left=`${u}px`,this.element.style.top=`${g}px`}close(t){var e;this.isOpen&&(this.isOpen=!1,this.backdrop.style.display="none",this.element.style.display="none",document.removeEventListener("click",this.outsideClick,!0),document.removeEventListener("keydown",this.keyDown,!0),t&&this.onChange&&this.recentScope==="solid"&&(B.addColor(this.currentColor,this.recentScope),(e=this.recentSectionRefresh)==null||e.call(this)))}getElement(){return this.element}}class ce{constructor(t){this.isDragging=!1,this.currentColor=t.initialColor,this.currentOpacity=t.initialOpacity,this.onColorChange=t.onColorChange,this.recentScope=t.scope??"solid",this.element=this.build(),this.initFromColor(this.currentColor,this.currentOpacity)}parsePercentage(t){const e=parseFloat(t);return isNaN(e)?0:e/100}build(){const t=document.createElement("div");t.className="embedded-color-picker";const e=document.createElement("div");e.className="color-picker-area embedded",this.colorArea=e;const i=document.createElement("div");i.className="color-picker-marker",this.colorMarker=i,e.appendChild(i);const s=document.createElement("div");s.className="color-picker-sliders-container embedded";const n=document.createElement("button");n.className="color-picker-eyedropper",n.type="button",n.innerHTML=Et;const o=document.createElement("div");o.className="color-picker-sliders-group";const a=document.createElement("div");a.className="color-picker-hue embedded",this.hueSlider=a;const l=document.createElement("div");l.className="color-picker-hue-marker",this.hueMarker=l,a.appendChild(l);const r=document.createElement("div");r.className="color-picker-opacity embedded",this.opacitySlider=r;const d=document.createElement("div");d.className="color-picker-opacity-marker",this.opacityMarker=d,r.appendChild(d),o.appendChild(a),o.appendChild(r),s.appendChild(n),s.appendChild(o);const h=nt(k=>{this.setColor(k),this.onColorChange(this.currentColor,this.currentOpacity)},this.recentScope);this.recentSectionRefresh=h.refresh;const p=document.createElement("div");p.className="color-picker-format-section embedded";const u=document.createElement("select");u.className="color-picker-format-select",this.select=u;const g=document.createElement("option");g.value="hex",g.textContent="HEX";const f=document.createElement("option");f.value="rgb",f.textContent="RGB";const m=document.createElement("option");m.value="hsl",m.textContent="HSL",u.appendChild(g),u.appendChild(f),u.appendChild(m);const v=document.createElement("input");v.type="text",v.className="color-picker-color-input",this.input=v;const C=document.createElement("div");C.className="color-picker-input-container";const x=document.createElement("button");return x.className="color-picker-copy-inside",x.textContent="Copy",C.appendChild(v),C.appendChild(x),p.appendChild(u),p.appendChild(C),t.appendChild(e),t.appendChild(s),t.appendChild(p),t.appendChild(h.container),this.bind(e,a,r,v,u,x,n),t}bind(t,e,i,s,n,o,a){const l=h=>{const p=t.getBoundingClientRect(),u=Math.max(0,Math.min(1,(h.clientX-p.left)/p.width)),g=Math.max(0,Math.min(1,(h.clientY-p.top)/p.height));this.colorMarker.style.left=`${u*100}%`,this.colorMarker.style.top=`${g*100}%`;const m=this.parsePercentage(this.hueMarker.style.left||"0%")*360,v=R(m,u,1-g);this.currentColor=v,this.syncInput(),this.updateOpacityBg(),this.queueChange()},r=h=>{const p=e.getBoundingClientRect(),u=Math.max(0,Math.min(1,(h.clientX-p.left)/p.width));this.hueMarker.style.left=`${u*100}%`;const g=u*360,f=this.parsePercentage(this.colorMarker.style.left||"0%"),m=this.parsePercentage(this.colorMarker.style.top||"0%"),v=R(g,f,1-m);this.currentColor=v,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
|
|
200
|
+
linear-gradient(to right, #fff, hsl(${g}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),this.queueChange()},d=h=>{const p=i.getBoundingClientRect(),u=Math.max(0,Math.min(1,(h.clientX-p.left)/p.width));this.opacityMarker.style.left=`${u*100}%`,this.currentOpacity=Math.round(u*100),this.queueChange()};t.addEventListener("mousedown",h=>{h.preventDefault(),this.isDragging=!0,l(h);const p=g=>l(g),u=()=>{this.isDragging=!1,this.flushChange(),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u),this.applyPendingExternal()};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)}),e.addEventListener("mousedown",h=>{h.preventDefault(),this.isDragging=!0,r(h);const p=g=>r(g),u=()=>{this.isDragging=!1,this.flushChange(),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u),this.applyPendingExternal()};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)}),i.addEventListener("mousedown",h=>{h.preventDefault(),this.isDragging=!0,d(h);const p=g=>d(g),u=()=>{this.isDragging=!1,this.flushChange(),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",u),this.applyPendingExternal()};document.addEventListener("mousemove",p),document.addEventListener("mouseup",u)}),n.addEventListener("change",()=>{this.syncInput()}),s.addEventListener("input",()=>{this.applyFromInput()}),s.addEventListener("blur",()=>{this.syncInput()}),s.addEventListener("keydown",h=>{h.key==="Enter"&&(h.preventDefault(),this.syncInput(),s.blur())}),o.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(s.value)}catch{s.select(),document.execCommand("copy")}}),a.addEventListener("click",async()=>{if(!("EyeDropper"in window)){alert("EyeDropper API is not supported in this browser.");return}try{const h=new window.EyeDropper,{sRGBHex:p}=await h.open();this.setColor(p),this.onColorChange(this.currentColor,this.currentOpacity)}catch{}})}setColor(t){this.currentColor=t;const{h:e,s:i,v:s}=D(t),n=e>=360?e%360:e;this.hueMarker.style.left=`${n/360*100}%`,this.colorMarker.style.left=`${i*100}%`,this.colorMarker.style.top=`${(1-s)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
|
|
201
|
+
linear-gradient(to right, #fff, hsl(${n}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg()}syncInput(){const t=this.select.value,{h:e,s:i,v:s}=D(this.currentColor);if(t==="hex")this.input.value=this.currentColor;else if(t==="rgb"){const{r:n,g:o,b:a}=S(this.currentColor);this.input.value=`rgb(${n}, ${o}, ${a})`}else{const{hue:n,sat:o,lightness:a}=mt(e,i,s);this.input.value=`hsl(${Math.round(n)}, ${Math.round(o*100)}%, ${Math.round(a*100)}%)`}}applyFromInput(){const t=this.input.value.trim();let e="";if(/^#[0-9A-Fa-f]{6}$/.test(t))e=t;else{const i=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(i){const s=parseInt(i[1],10),n=parseInt(i[2],10),o=parseInt(i[3],10);s<=255&&n<=255&&o<=255&&(e="#"+[s,n,o].map(a=>a.toString(16).padStart(2,"0")).join(""))}else{const s=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const n=parseInt(s[1],10),o=parseInt(s[2],10)/100,a=parseInt(s[3],10)/100,l=a+o*Math.min(a,1-a),r=l===0?0:2*(1-a/l);e=R(n,r,l)}}}e&&(this.setColor(e),this.onColorChange(this.currentColor,this.currentOpacity))}updateOpacityBg(){const{r:t,g:e,b:i}=S(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${t}, ${e}, ${i})`)}queueChange(){this.changeRafId===void 0&&(this.changeRafId=window.requestAnimationFrame(()=>{this.changeRafId=void 0,this.onColorChange(this.currentColor,this.currentOpacity)}))}flushChange(){this.changeRafId!==void 0&&(cancelAnimationFrame(this.changeRafId),this.changeRafId=void 0),this.onColorChange(this.currentColor,this.currentOpacity)}applyPendingExternal(){if(!this.pendingExternalUpdate)return;const{color:t,opacity:e}=this.pendingExternalUpdate;this.pendingExternalUpdate=void 0,this.initFromColor(t,e)}initFromColor(t,e){var a;this.currentColor=t,this.currentOpacity=e;const{h:i,s,v:n}=D(t),o=i>=360?i%360:i;this.hueMarker.style.left=`${o/360*100}%`,this.colorMarker.style.left=`${s*100}%`,this.colorMarker.style.top=`${(1-n)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
|
|
202
|
+
linear-gradient(to right, #fff, hsl(${o}, 100%, 50%))`,this.opacityMarker.style.left=`${e}%`,this.updateOpacityBg(),this.syncInput(),(a=this.recentSectionRefresh)==null||a.call(this)}commitRecentColor(){var t;this.recentScope==="solid"&&(B.addColor(this.currentColor,this.recentScope),(t=this.recentSectionRefresh)==null||t.call(this))}getElement(){return this.element}updateColor(t,e){if(this.isDragging){this.pendingExternalUpdate={color:t,opacity:e};return}this.initFromColor(t,e)}}const P=class P extends b{constructor(t={}){const e=typeof t.default=="string"?void 0:t.default;super({...t,title:t.title||"Color",default:e}),this.inputType={type:"text",angle:"number",stops:"text"},this.element=null,this.previewEl=null,this.inputEl=void 0,this.popoverEl=null,this.backdropEl=null,this.isPopoverOpen=!1,this.isEditing=!1,this.popoverPosition=null,this.previewUpdateTimeout=null,this.solidPicker=null,this.pendingSolidColor=null,this.onBackgroundClick=i=>{var p;if(!this.popoverEl||!this.isPopoverOpen)return;const s=i.target,n=this.popoverEl.contains(s),o=(p=this.element)==null?void 0:p.contains(s),a=document.querySelectorAll(".custom-color-picker"),l=Array.from(a).some(u=>u.contains(s)),r=s.closest(".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"),d=s.classList.contains("color-picker-backdrop"),h=s.classList.contains("gradient-popover-backdrop");!n&&!o&&!l&&!r&&!d&&!h&&this.closePopover()},this.handlePopoverKeydown=i=>{if(this.isPopoverOpen){if(i.key==="Escape"){i.preventDefault(),this.closePopover();return}if(i.key==="Enter"){const s=i.target;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"))return;i.preventDefault(),this.closePopover()}}},this.detectChange=t.detectChange,this.originalDefault=t.default,this.value=this.defaultValue()}defaultValue(){const t=this.originalDefault;if(typeof t=="string"){const i=T(t);if(i)return A(i)}return A(t&&typeof t=="object"?t:{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]})}setValue(t){var i,s;let e=null;typeof t=="string"?e=T(t):t&&typeof t=="object"&&(e=A(t)),e||(e=this.defaultValue()),this.value=e,this.updateUI(),this.isPopoverOpen&&this.refreshPopoverContent(),(i=this.onChange)==null||i.call(this,this.value),(s=this.detectChange)==null||s.call(this,this.value),this.pendingSolidColor=null}updateUI(){if(this.previewEl&&this.value)if(this.value.type==="solid"){const t=this.value.stops[0],e=t.opacity??100;this.previewEl.style.background=ft(t.color,e)}else this.previewEl.style.background=V(this.value);this.inputEl&&this.value&&!this.isEditing&&(this.inputEl.value=J(this.value))}cssForTextValue(){return this.value?{background:V(this.value),"-webkit-background-clip":"text","background-clip":"text",color:"transparent","-webkit-text-fill-color":"transparent"}:{}}draw(){const t=document.createElement("div");if(t.className="gradient-setting-wrapper",this.props.title){const i=document.createElement("div");i.className="icon-container";const s=document.createElement("span");s.className="input-label",s.textContent=this.props.title,i.appendChild(s),t.appendChild(i)}const e=document.createElement("div");return e.className="gradient-input-wrapper",this.previewEl=document.createElement("div"),this.previewEl.className="gradient-mini-preview",this.previewEl.style.background=this.value?V(this.value):"linear-gradient(90deg, #a84b4b 0%, #786666 100%)",this.previewEl.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.openPopover()}),this.inputEl=document.createElement("input"),this.inputEl.type="text",this.inputEl.className="gradient-text-input",this.inputEl.placeholder="Enter gradient CSS or paste color...",this.inputEl.value=this.value?J(this.value):"",this.inputEl.readOnly=!1,this.inputEl.addEventListener("focus",()=>{if(this.isEditing=!0,this.value)if(this.value.type==="solid"){const i=this.value.stops[0];if(i){const s=i.color.toUpperCase(),n=i.opacity??100;if(n===100)this.inputEl.value=s;else{const a=Math.round(n/100*255).toString(16).toUpperCase().padStart(2,"0");this.inputEl.value=`${s}${a}`}}}else this.inputEl.value=V(this.value)}),this.inputEl.addEventListener("blur",()=>{this.isEditing=!1,this.value&&(this.inputEl.value=J(this.value))}),this.inputEl.addEventListener("paste",i=>this.handlePaste(i)),this.inputEl.addEventListener("input",i=>this.handleTextInput(i)),this.inputEl.addEventListener("keydown",i=>{i.key==="Enter"&&(this.handleTextInput(i),this.inputEl.blur()),i.key==="Escape"&&(this.value&&(this.inputEl.value=V(this.value)),this.inputEl.blur())}),e.appendChild(this.previewEl),e.appendChild(this.inputEl),t.appendChild(e),this.createPopover(),this.element=t,t}createPopover(){if(this.popoverEl)return;this.backdropEl=document.createElement("div"),this.backdropEl.className="gradient-popover-backdrop",this.backdropEl.style.display="none",this.backdropEl.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.closePopover()}),this.popoverEl=document.createElement("div"),this.popoverEl.className="gradient-popover",this.popoverEl.style.display="none",this.popoverEl.addEventListener("click",a=>{a.stopPropagation()});const t=document.createElement("div");t.className="gradient-popover-header",t.style.cursor="move";const e=document.createElement("span");e.textContent="Fill";const i=document.createElement("button");i.type="button",i.className="gradient-popover-close",i.innerHTML=yt,i.addEventListener("click",()=>this.closePopover()),t.appendChild(e),t.appendChild(i),gt(t,this.popoverEl,(a,l)=>{this.popoverPosition={left:a,top:l}});const s=document.createElement("div");s.className="gradient-editor";const n=this.createTypeTabs();s.appendChild(n);const o=document.createElement("div");o.className="gradient-editor-content",this.updatePopoverContent(o),s.appendChild(o),this.popoverEl.appendChild(t),this.popoverEl.appendChild(s),document.body.appendChild(this.backdropEl),document.body.appendChild(this.popoverEl)}createTypeTabs(){var s,n;const t=document.createElement("div");t.className="gradient-type-tabs";const e=document.createElement("button");e.type="button",e.className=`gradient-type-tab ${((s=this.value)==null?void 0:s.type)==="solid"?"active":""}`,e.textContent="Solid",e.addEventListener("click",()=>this.switchType("solid"));const i=document.createElement("button");return i.type="button",i.className=`gradient-type-tab ${((n=this.value)==null?void 0:n.type)!=="solid"?"active":""}`,i.textContent="Gradient",i.addEventListener("click",()=>{var a,l;const o=((a=this.value)==null?void 0:a.type)==="solid"?"linear":((l=this.value)==null?void 0:l.type)||"linear";this.switchType(o)}),t.appendChild(e),t.appendChild(i),t}switchType(t){var i;if(!this.value)return;if(this.value.type=t,t!=="solid"&&(!this.value.stops||this.value.stops.length===0)&&(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]),t!=="solid"&&this.value.stops.length<2&&(this.value.angle=90),this.popoverEl){const s=this.popoverEl.querySelectorAll(".gradient-type-tab");s.forEach(a=>a.classList.remove("active"));const n=s[0],o=s[1];t==="solid"?n==null||n.classList.add("active"):o==null||o.classList.add("active")}const e=(i=this.popoverEl)==null?void 0:i.querySelector(".gradient-editor-content");e&&this.updatePopoverContent(e),this.updateUI(),this.triggerChange()}updatePopoverContent(t){t.innerHTML="",this.value&&(this.value.type==="solid"?this.renderSolid(t):this.renderGradient(t))}renderSolid(t){(!this.value||!this.value.stops||!this.value.stops.length)&&(this.value||(this.value=this.defaultValue()),this.value.stops=[{color:"#000000",position:0,opacity:100}]);const e=this.value.stops[0],i=new ce({initialColor:e.color,initialOpacity:e.opacity??100,onColorChange:(s,n)=>{if(this.value){const o=T(s);if(o&&o.type!=="solid"){this.value=o,this.switchType(o.type);return}this.value.stops[0].color=s,this.value.stops[0].opacity=n,this.updateUI(),this.triggerChange(),this.pendingSolidColor=s}}});this.solidPicker=i,t.appendChild(i.getElement())}renderGradient(t){this.solidPicker=null;const e=document.createElement("div");e.className="gradient-subtype-inline";const i=document.createElement("select");i.className="gradient-subtype-select";const s=document.createElement("option");s.value="linear",s.textContent="Linear";const n=document.createElement("option");n.value="radial",n.textContent="Radial",i.appendChild(s),i.appendChild(n),i.value=this.value.type==="radial"?"radial":"linear";const o=document.createElement("input");o.type="text",o.inputMode="numeric",o.className="gradient-degree-input",o.value=`${this.value.angle??90}°`,o.style.width="75px",o.style.textAlign="center",(!this.value.angle||this.value.stops.length<2)&&(this.value.angle=90,o.value="90°");const a=document.createElement("button");a.type="button",a.className="gradient-flip-btn",a.innerHTML=ae,i.addEventListener("change",()=>{this.switchType(i.value==="radial"?"radial":"linear"),this.updateDegreeVisibility(o)}),o.addEventListener("focus",f=>{const m=f.target;m.value=m.value.replace(/[^0-9-]/g,""),setTimeout(()=>m.select(),0)}),o.addEventListener("input",f=>{const m=parseInt(f.target.value);!Number.isNaN(m)&&this.value&&(this.value.angle=Math.max(0,Math.min(360,m)),this.debouncedPreviewUpdate())}),o.addEventListener("blur",f=>{var C;this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const m=f.target;let v=parseInt(m.value);Number.isNaN(v)&&(v=((C=this.value)==null?void 0:C.angle)??0),v=Math.max(0,Math.min(360,v)),this.value&&(this.value.angle=v),m.value=`${v}°`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),a.addEventListener("click",()=>{!this.value||!this.value.stops||(this.value.stops.forEach(f=>{f.position=100-f.position}),this.value.stops.sort((f,m)=>f.position-m.position),this.updateGradientPreview(l),this.createHandles(r,l),this.updateStopsList(u),this.updateUI(),this.triggerChange())}),e.appendChild(i),e.appendChild(o),e.appendChild(a),t.appendChild(e),this.updateDegreeVisibility(o);const l=document.createElement("div");l.className="gradient-preview",this.updateGradientPreview(l);const r=document.createElement("div");r.className="gradient-handles",l.appendChild(r),t.appendChild(l),this.createHandles(r,l);const d=document.createElement("div");d.className="gradient-stops-header";const h=document.createElement("span");h.textContent="Stops";const p=document.createElement("button");p.type="button",p.className="gradient-add-stop",p.textContent="+",d.appendChild(h),d.appendChild(p);const u=document.createElement("div");u.className="gradient-stops",t.appendChild(d),t.appendChild(u),this.updateStopsList(u);const g=nt(f=>{const m=T(f);m&&(this.value=m,this.switchType(m.type),this.updateUI(),this.triggerChange())},"all");this.recentGradientRefresh=g.refresh,t.appendChild(g.container),p.addEventListener("click",()=>{var f;this.addStop(),this.updateStopsList(u),this.updateGradientPreview(l),this.createHandles(r,l),this.updateUI(),((f=document.activeElement)==null?void 0:f.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()})}updateDegreeVisibility(t){var e;((e=this.value)==null?void 0:e.type)==="radial"?(t.disabled=!0,t.style.opacity="0.5"):(t.disabled=!1,t.style.opacity="1")}updateGradientPreview(t){var i;const e=t||((i=this.popoverEl)==null?void 0:i.querySelector(".gradient-preview"));e&&this.value&&(e.style.background=V(this.value))}debouncedPreviewUpdate(t){this.previewUpdateTimeout&&clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=window.setTimeout(()=>{this.updateGradientPreview(t),this.previewUpdateTimeout=null},16)}createHandles(t,e){t.innerHTML="",!(!this.value||this.value.type==="solid"||!this.value.stops)&&this.value.stops.forEach((i,s)=>{const n=document.createElement("div");n.className="gstop-handle",n.style.left=`${Math.max(0,Math.min(100,i.position))}%`,n.style.top="0%";const o=document.createElement("div");o.className="gstop-chip",o.style.backgroundColor=i.color,n.appendChild(o);let a=!1,l=0,r=0;const d=u=>{a=!0,l=u.clientX,r=this.value.stops[s].position,n.classList.add("selected"),document.addEventListener("mousemove",h),document.addEventListener("mouseup",p),u.preventDefault(),u.stopPropagation()},h=u=>{if(!a||!this.value)return;const g=e.getBoundingClientRect(),f=u.clientX-l;let m=r+f/g.width*100;m=Math.max(0,Math.min(100,m)),this.value.stops[s].position=Math.round(m),n.style.left=`${m}%`,this.updateGradientPreview()},p=()=>{a&&(a=!1,n.classList.remove("selected"),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p),this.value&&(this.value.stops.sort((u,g)=>u.position-g.position),this.createHandles(t,e),this.updateStopsList()),this.updateUI(),this.triggerChange())};n.addEventListener("mousedown",d),t.appendChild(n)})}updateStopsList(t){var i;const e=t||((i=this.popoverEl)==null?void 0:i.querySelector(".gradient-stops"));!e||!this.value||this.value.type==="solid"||!this.value.stops||(e.innerHTML="",this.value.stops.forEach((s,n)=>{var k,O;const o=document.createElement("div");o.className="gstop-row";const a=document.createElement("div");a.className="gstop-position-group";const l=document.createElement("input");l.type="text",l.className="gstop-position-input",l.value=`${s.position}%`,l.style.width="60px",a.appendChild(l);const r=document.createElement("div");r.className="gstop-color-container";const d=document.createElement("div");d.className="gstop-color-preview",d.style.backgroundColor=s.color;const h=document.createElement("input");h.type="text",h.className="gstop-color-input",h.value=s.color.replace("#","").toUpperCase();const p=document.createElement("button");p.type="button",p.className="gstop-color-copy",p.textContent="Copy",r.appendChild(d),r.appendChild(h),r.appendChild(p);const u=document.createElement("button");u.type="button",u.className="gstop-del",u.innerHTML=le,u.disabled=(((O=(k=this.value)==null?void 0:k.stops)==null?void 0:O.length)||0)<=2,o.appendChild(a),o.appendChild(r),o.appendChild(u),e.appendChild(o);const g=document.createElement("span");g.className="gstop-opacity-label",g.textContent="Opacity";const f=document.createElement("div");f.className="gstop-opacity-group";const m=document.createElement("input");m.type="range",m.className="gstop-opacity-slider",m.min="0",m.max="100",m.value=String(s.opacity??100);const v=S(s.color);m.style.setProperty("--slider-color",`rgb(${v.r}, ${v.g}, ${v.b})`);const C=document.createElement("span");C.className="gstop-opacity-value",C.textContent=`${s.opacity??100}%`,f.appendChild(m),f.appendChild(C);const x=new re((y,E)=>{h.value=y.replace("#","").toUpperCase(),d.style.backgroundColor=y,this.value.stops[n].color=y,E!==void 0&&(this.value.stops[n].opacity=E,m.value=String(E),C.textContent=`${E}%`);const L=S(y);m.style.setProperty("--slider-color",`rgb(${L.r}, ${L.g}, ${L.b})`),this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()},"solid");h.addEventListener("click",y=>{y.preventDefault(),y.stopPropagation(),x.open(s.color,h,s.opacity??100)}),h.addEventListener("input",()=>{const y=h.value.trim(),E=y.startsWith("#")?y:`#${y}`;if(/^#[0-9A-Fa-f]{6}$/.test(E)){this.value.stops[n].color=E,d.style.backgroundColor=E;const L=S(E);m.style.setProperty("--slider-color",`rgb(${L.r}, ${L.g}, ${L.b})`),this.debouncedPreviewUpdate()}}),h.addEventListener("blur",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),p.addEventListener("click",async y=>{y.stopPropagation();try{await navigator.clipboard.writeText(`#${h.value}`)}catch{}}),l.addEventListener("focus",y=>{const E=y.target;E.value=E.value.replace("%",""),E.select()}),l.addEventListener("input",y=>{const E=y.target,L=parseInt(E.value.replace(/[^\d]/g,""),10);if(!Number.isNaN(L)){const G=Math.max(0,Math.min(100,L));this.value.stops[n].position=G,E.value=`${G}%`,this.debouncedPreviewUpdate()}}),l.addEventListener("blur",y=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const E=y.target,L=parseInt(E.value.replace(/[^\d]/g,""),10);if(Number.isNaN(L))E.value=`${this.value.stops[n].position}%`;else{const G=Math.max(0,Math.min(100,L));this.value.stops[n].position=G,E.value=`${G}%`}this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateUI(),this.triggerChange()}),u.addEventListener("click",()=>{var y;(this.value.stops.length||0)<=2||(this.value.stops.splice(n,1),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateGradientPreview(),this.updateUI(),((y=document.activeElement)==null?void 0:y.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange())}),m.addEventListener("input",()=>{const y=parseInt(m.value,10);this.value.stops[n].opacity=Math.max(0,Math.min(100,y)),C.textContent=`${this.value.stops[n].opacity}%`,this.debouncedPreviewUpdate()}),m.addEventListener("change",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()})}))}addStop(){if(!this.value||this.value.type==="solid"||!this.value.stops)return;const t=this.value.stops.map(o=>o.position).sort((o,a)=>o-a);let e=50,i=0;for(let o=0;o<t.length-1;o++){const a=t[o+1]-t[o];a>i&&(i=a,e=t[o]+a/2)}const s=this.value.stops.reduce((o,a)=>Math.abs(a.position-e)<Math.abs(o.position-e)?a:o),n={position:Math.round(e),color:s.color,opacity:s.opacity??100};this.value.stops.push(n),this.value.stops.sort((o,a)=>o.position-a.position)}openPopover(){if(this.popoverEl&&(P.openInstance&&P.openInstance!==this&&P.openInstance.closePopover(),!this.isPopoverOpen)){if(this.isPopoverOpen=!0,P.openInstance=this,this.backdropEl&&(this.backdropEl.style.display="block",this.backdropEl.parentElement||document.body.appendChild(this.backdropEl)),this.popoverEl.style.display="flex",this.refreshPopoverContent(),this.element){const t=this.element.getBoundingClientRect(),e=306,i=window.innerWidth,s=window.innerHeight,n=16;this.popoverEl.style.position="fixed",this.popoverEl.style.zIndex="10000",this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const o=this.popoverEl.offsetHeight;let a=t.right+8,l=t.top;const r=i-t.right,d=t.left,h=e+n;r<h&&d>r+100&&(a=t.left-e-8);const p=s-t.bottom,u=t.top;u>=o+n?l=t.top-o-8:p>=o+n?l=t.bottom+8:u>p?(l=t.top-o-8,l<n&&(l=n)):(l=t.bottom+8,l+o>s-n&&(l=s-o-n)),this.popoverEl.style.left=`${a}px`,this.popoverEl.style.top=`${l}px`,this.popoverPosition={left:a,top:l}}setTimeout(()=>document.addEventListener("click",this.onBackgroundClick,!0),200),document.addEventListener("keydown",this.handlePopoverKeydown,!0)}}repositionPopover(){var t;if(!(!this.popoverEl||!this.isPopoverOpen||!this.element)&&((t=document.activeElement)==null?void 0:t.tagName)!=="INPUT"){if(this.popoverPosition){this.popoverEl.style.left=`${this.popoverPosition.left}px`,this.popoverEl.style.top=`${this.popoverPosition.top}px`;return}requestAnimationFrame(()=>{if(!this.popoverEl||!this.element)return;const e=this.element.getBoundingClientRect(),i=306,s=window.innerWidth,n=window.innerHeight,o=16;this.popoverEl.style.left,this.popoverEl.style.top,this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const a=this.popoverEl.offsetHeight;let l=e.right+8,r=e.top;const d=s-e.right,h=e.left,p=i+o;d<p&&h>d+100&&(l=e.left-i-8);const u=n-e.bottom,g=e.top;g>=a+o?r=e.top-a-8:u>=a+o?r=e.bottom+8:g>u?(r=e.top-a-8,r<o&&(r=o)):(r=e.bottom+8,r+a>n-o&&(r=n-a-o)),this.popoverEl.style.left=`${l}px`,this.popoverEl.style.top=`${r}px`})}}refreshPopoverContent(){var n,o;if(!this.popoverEl)return;const t=this.popoverEl.querySelectorAll(".gradient-type-tab");t.forEach(a=>a.classList.remove("active"));const e=t[0],i=t[1];((n=this.value)==null?void 0:n.type)==="solid"?e.classList.add("active"):(i.classList.add("active"),(o=this.recentGradientRefresh)==null||o.call(this)),this.popoverEl.offsetHeight;const s=this.popoverEl.querySelector(".gradient-editor-content");s&&this.updatePopoverContent(s)}closePopover(){var t;if(!(!this.popoverEl||!this.isPopoverOpen)){if(this.isPopoverOpen=!1,this.popoverPosition=null,this.backdropEl&&(this.backdropEl.style.display="none"),this.popoverEl.style.display="none",document.removeEventListener("click",this.onBackgroundClick,!0),document.removeEventListener("keydown",this.handlePopoverKeydown,!0),this.commitPendingSolidColor(),this.value&&this.value.type!=="solid"){const e=V(this.value);B.addColor(e,"gradient"),(t=this.recentGradientRefresh)==null||t.call(this)}this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),P.openInstance===this&&(P.openInstance=null)}}commitPendingSolidColor(){this.pendingSolidColor&&(this.solidPicker?this.solidPicker.commitRecentColor():B.addColor(this.pendingSolidColor,"solid"),this.pendingSolidColor=null)}handlePaste(t){var i;t.preventDefault();const e=((i=t.clipboardData)==null?void 0:i.getData("text"))||"";this.parseAndSet(e)}handleTextInput(t){const e=t.target;this.parseAndSet(e.value)}parseAndSet(t){const e=T(t.trim());e&&this.setValue(e)}triggerChange(){var t,e;this.value&&((t=this.onChange)==null||t.call(this,this.value),(e=this.detectChange)==null||e.call(this,this.value))}getElement(){return this.element}getValue(){return this.value?V(this.value):""}getCSSValue(){return this.value?V(this.value):""}getCSSForText(){return this.value?this.cssForTextValue():{}}getRawValue(){return this.value}};P.openInstance=null;let W=P;const he=`
|
|
203
203
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
204
204
|
<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"/>
|
|
205
205
|
</svg>
|
|
@@ -242,7 +242,7 @@ function w(c) {
|
|
|
242
242
|
function st(c) {
|
|
243
243
|
return A(c) || w(c);
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function z(c, t) {
|
|
246
246
|
for (const e in c)
|
|
247
247
|
if (Object.prototype.hasOwnProperty.call(c, e)) {
|
|
248
248
|
const i = c[e];
|
|
@@ -256,7 +256,7 @@ const Z = class Z {
|
|
|
256
256
|
}
|
|
257
257
|
propagateNestingLevel() {
|
|
258
258
|
const t = this.nestingLevel + 1;
|
|
259
|
-
|
|
259
|
+
z(this.settings, (e, i) => {
|
|
260
260
|
w(i) && (i.nestingLevel = t, i.propagateNestingLevel());
|
|
261
261
|
});
|
|
262
262
|
}
|
|
@@ -273,7 +273,7 @@ const Z = class Z {
|
|
|
273
273
|
this.dataPropsPath = t, this.propagateDataPropsPath();
|
|
274
274
|
}
|
|
275
275
|
propagateDataPropsPath() {
|
|
276
|
-
|
|
276
|
+
z(this.settings, (t, e) => {
|
|
277
277
|
const i = String(t), s = this.dataPropsPath ? `${this.dataPropsPath}_${i}` : i;
|
|
278
278
|
(w(e) || A(e) && typeof e.setDataPropsPath == "function") && e.setDataPropsPath(s);
|
|
279
279
|
});
|
|
@@ -328,7 +328,7 @@ const Z = class Z {
|
|
|
328
328
|
}
|
|
329
329
|
clone() {
|
|
330
330
|
const t = {};
|
|
331
|
-
|
|
331
|
+
z(this.settings, (s, n) => {
|
|
332
332
|
const o = String(s);
|
|
333
333
|
typeof n.clone == "function" ? t[o] = n.clone() : (console.warn(
|
|
334
334
|
`Setting with key '${o}' does not have a clone method. Copying reference.`
|
|
@@ -391,7 +391,7 @@ const Z = class Z {
|
|
|
391
391
|
Object.keys(s).length > 0 && (this.lastChangeTime = Date.now(), this.initialValues = i, t(i), this.updateVisibility()), this.isHandlingChange = !1;
|
|
392
392
|
}, 50));
|
|
393
393
|
};
|
|
394
|
-
return this.changeHandlers.clear(),
|
|
394
|
+
return this.changeHandlers.clear(), z(this.settings, (i, s) => {
|
|
395
395
|
var n;
|
|
396
396
|
if (w(s))
|
|
397
397
|
s.setOnChange(() => {
|
|
@@ -2334,7 +2334,7 @@ const ct = (c, t, e) => {
|
|
|
2334
2334
|
/^rgba?\s*\([^)]+\)$/,
|
|
2335
2335
|
/^hsla?\s*\([^)]+\)$/,
|
|
2336
2336
|
/^[a-zA-Z]+$/
|
|
2337
|
-
].some((e) => e.test(c.trim())),
|
|
2337
|
+
].some((e) => e.test(c.trim())), Ut = (c) => {
|
|
2338
2338
|
if (typeof document > "u")
|
|
2339
2339
|
return dt(c) || !!F(c);
|
|
2340
2340
|
const t = document.createElement("div");
|
|
@@ -2398,7 +2398,7 @@ const ct = (c, t, e) => {
|
|
|
2398
2398
|
for (let a = s; a < c.length && n > 0; a++)
|
|
2399
2399
|
c[a] === "(" ? n++ : c[a] === ")" && n--, o = a;
|
|
2400
2400
|
return n === 0 ? c.substring(s, o) : null;
|
|
2401
|
-
},
|
|
2401
|
+
}, zt = (c) => {
|
|
2402
2402
|
const t = c.split(" ")[0].toLowerCase();
|
|
2403
2403
|
return [
|
|
2404
2404
|
"circle",
|
|
@@ -2435,7 +2435,7 @@ const ct = (c, t, e) => {
|
|
|
2435
2435
|
};
|
|
2436
2436
|
}, T = (c) => {
|
|
2437
2437
|
const t = c.replace(/;$/, "").trim();
|
|
2438
|
-
if (
|
|
2438
|
+
if (Ut(t)) {
|
|
2439
2439
|
const s = ut(t);
|
|
2440
2440
|
return H({ type: "solid", angle: 0, stops: [s] });
|
|
2441
2441
|
}
|
|
@@ -2462,7 +2462,7 @@ const ct = (c, t, e) => {
|
|
|
2462
2462
|
}
|
|
2463
2463
|
const i = ot(t, "radial-gradient");
|
|
2464
2464
|
if (i) {
|
|
2465
|
-
const s = nt(i), n = s[0] && !
|
|
2465
|
+
const s = nt(i), n = s[0] && !zt(s[0]) ? s.slice(1) : s, o = at(n);
|
|
2466
2466
|
return o.length ? H({ type: "radial", angle: 0, stops: o }) : null;
|
|
2467
2467
|
}
|
|
2468
2468
|
return null;
|
|
@@ -2490,7 +2490,7 @@ const ct = (c, t, e) => {
|
|
|
2490
2490
|
return "#000000";
|
|
2491
2491
|
}
|
|
2492
2492
|
return c.type === "linear" ? `Linear ${c.angle}°` : "Radial Gradient";
|
|
2493
|
-
},
|
|
2493
|
+
}, U = class U {
|
|
2494
2494
|
static defaults() {
|
|
2495
2495
|
return {
|
|
2496
2496
|
solid: [],
|
|
@@ -2556,8 +2556,8 @@ const ct = (c, t, e) => {
|
|
|
2556
2556
|
a !== -1 && o.splice(a, 1), o.unshift(i), o.length > this.MAX_COLORS && (o.length = this.MAX_COLORS), this.persist();
|
|
2557
2557
|
}
|
|
2558
2558
|
};
|
|
2559
|
-
|
|
2560
|
-
let $ =
|
|
2559
|
+
U.STORAGE_KEY = "settingsLib_recentColors", U.MAX_COLORS = 12, U.colors = null;
|
|
2560
|
+
let $ = U;
|
|
2561
2561
|
const et = (c, t) => {
|
|
2562
2562
|
const e = document.createElement("div");
|
|
2563
2563
|
e.className = "color-picker-recent-section";
|
|
@@ -2837,7 +2837,7 @@ class Jt {
|
|
|
2837
2837
|
}
|
|
2838
2838
|
class Xt {
|
|
2839
2839
|
constructor(t) {
|
|
2840
|
-
this.currentColor = t.initialColor, this.currentOpacity = t.initialOpacity, this.onColorChange = t.onColorChange, this.recentScope = t.scope ?? "solid", this.element = this.build(), this.initFromColor(this.currentColor, this.currentOpacity);
|
|
2840
|
+
this.isDragging = !1, this.currentColor = t.initialColor, this.currentOpacity = t.initialOpacity, this.onColorChange = t.onColorChange, this.recentScope = t.scope ?? "solid", this.element = this.build(), this.initFromColor(this.currentColor, this.currentOpacity);
|
|
2841
2841
|
}
|
|
2842
2842
|
parsePercentage(t) {
|
|
2843
2843
|
const e = parseFloat(t);
|
|
@@ -2883,40 +2883,40 @@ class Xt {
|
|
|
2883
2883
|
const C = document.createElement("div");
|
|
2884
2884
|
C.className = "color-picker-input-container";
|
|
2885
2885
|
const x = document.createElement("button");
|
|
2886
|
-
return x.className = "color-picker-copy-inside", x.textContent = "Copy", C.appendChild(v), C.appendChild(x), p.appendChild(u), p.appendChild(C), t.appendChild(e), t.appendChild(s), t.appendChild(
|
|
2886
|
+
return x.className = "color-picker-copy-inside", x.textContent = "Copy", C.appendChild(v), C.appendChild(x), p.appendChild(u), p.appendChild(C), t.appendChild(e), t.appendChild(s), t.appendChild(p), t.appendChild(h.container), this.bind(e, a, r, v, u, x, n), t;
|
|
2887
2887
|
}
|
|
2888
2888
|
bind(t, e, i, s, n, o, a) {
|
|
2889
2889
|
const l = (h) => {
|
|
2890
2890
|
const p = t.getBoundingClientRect(), u = Math.max(0, Math.min(1, (h.clientX - p.left) / p.width)), g = Math.max(0, Math.min(1, (h.clientY - p.top) / p.height));
|
|
2891
2891
|
this.colorMarker.style.left = `${u * 100}%`, this.colorMarker.style.top = `${g * 100}%`;
|
|
2892
2892
|
const m = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, v = R(m, u, 1 - g);
|
|
2893
|
-
this.currentColor = v, this.syncInput(), this.updateOpacityBg(), this.
|
|
2893
|
+
this.currentColor = v, this.syncInput(), this.updateOpacityBg(), this.queueChange();
|
|
2894
2894
|
}, r = (h) => {
|
|
2895
2895
|
const p = e.getBoundingClientRect(), u = Math.max(0, Math.min(1, (h.clientX - p.left) / p.width));
|
|
2896
2896
|
this.hueMarker.style.left = `${u * 100}%`;
|
|
2897
2897
|
const g = u * 360, f = this.parsePercentage(this.colorMarker.style.left || "0%"), m = this.parsePercentage(this.colorMarker.style.top || "0%"), v = R(g, f, 1 - m);
|
|
2898
2898
|
this.currentColor = v, this.colorArea.style.background = `linear-gradient(to top, #000, transparent),
|
|
2899
|
-
linear-gradient(to right, #fff, hsl(${g}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), this.
|
|
2899
|
+
linear-gradient(to right, #fff, hsl(${g}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), this.queueChange();
|
|
2900
2900
|
}, d = (h) => {
|
|
2901
2901
|
const p = i.getBoundingClientRect(), u = Math.max(0, Math.min(1, (h.clientX - p.left) / p.width));
|
|
2902
|
-
this.opacityMarker.style.left = `${u * 100}%`, this.currentOpacity = Math.round(u * 100), this.
|
|
2902
|
+
this.opacityMarker.style.left = `${u * 100}%`, this.currentOpacity = Math.round(u * 100), this.queueChange();
|
|
2903
2903
|
};
|
|
2904
2904
|
t.addEventListener("mousedown", (h) => {
|
|
2905
|
-
h.preventDefault(), l(h);
|
|
2905
|
+
h.preventDefault(), this.isDragging = !0, l(h);
|
|
2906
2906
|
const p = (g) => l(g), u = () => {
|
|
2907
|
-
document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", u);
|
|
2907
|
+
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", u), this.applyPendingExternal();
|
|
2908
2908
|
};
|
|
2909
2909
|
document.addEventListener("mousemove", p), document.addEventListener("mouseup", u);
|
|
2910
2910
|
}), e.addEventListener("mousedown", (h) => {
|
|
2911
|
-
h.preventDefault(), r(h);
|
|
2911
|
+
h.preventDefault(), this.isDragging = !0, r(h);
|
|
2912
2912
|
const p = (g) => r(g), u = () => {
|
|
2913
|
-
document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", u);
|
|
2913
|
+
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", u), this.applyPendingExternal();
|
|
2914
2914
|
};
|
|
2915
2915
|
document.addEventListener("mousemove", p), document.addEventListener("mouseup", u);
|
|
2916
2916
|
}), i.addEventListener("mousedown", (h) => {
|
|
2917
|
-
h.preventDefault(), d(h);
|
|
2917
|
+
h.preventDefault(), this.isDragging = !0, d(h);
|
|
2918
2918
|
const p = (g) => d(g), u = () => {
|
|
2919
|
-
document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", u);
|
|
2919
|
+
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", u), this.applyPendingExternal();
|
|
2920
2920
|
};
|
|
2921
2921
|
document.addEventListener("mousemove", p), document.addEventListener("mouseup", u);
|
|
2922
2922
|
}), n.addEventListener("change", () => {
|
|
@@ -2992,6 +2992,19 @@ class Xt {
|
|
|
2992
2992
|
`rgb(${t}, ${e}, ${i})`
|
|
2993
2993
|
);
|
|
2994
2994
|
}
|
|
2995
|
+
queueChange() {
|
|
2996
|
+
this.changeRafId === void 0 && (this.changeRafId = window.requestAnimationFrame(() => {
|
|
2997
|
+
this.changeRafId = void 0, this.onColorChange(this.currentColor, this.currentOpacity);
|
|
2998
|
+
}));
|
|
2999
|
+
}
|
|
3000
|
+
flushChange() {
|
|
3001
|
+
this.changeRafId !== void 0 && (cancelAnimationFrame(this.changeRafId), this.changeRafId = void 0), this.onColorChange(this.currentColor, this.currentOpacity);
|
|
3002
|
+
}
|
|
3003
|
+
applyPendingExternal() {
|
|
3004
|
+
if (!this.pendingExternalUpdate) return;
|
|
3005
|
+
const { color: t, opacity: e } = this.pendingExternalUpdate;
|
|
3006
|
+
this.pendingExternalUpdate = void 0, this.initFromColor(t, e);
|
|
3007
|
+
}
|
|
2995
3008
|
initFromColor(t, e) {
|
|
2996
3009
|
var a;
|
|
2997
3010
|
this.currentColor = t, this.currentOpacity = e;
|
|
@@ -3006,8 +3019,11 @@ class Xt {
|
|
|
3006
3019
|
getElement() {
|
|
3007
3020
|
return this.element;
|
|
3008
3021
|
}
|
|
3009
|
-
/** For external updates, e.g. when gradient stop changes from outside */
|
|
3010
3022
|
updateColor(t, e) {
|
|
3023
|
+
if (this.isDragging) {
|
|
3024
|
+
this.pendingExternalUpdate = { color: t, opacity: e };
|
|
3025
|
+
return;
|
|
3026
|
+
}
|
|
3011
3027
|
this.initFromColor(t, e);
|
|
3012
3028
|
}
|
|
3013
3029
|
}
|
|
@@ -3811,5 +3827,5 @@ export {
|
|
|
3811
3827
|
A as isSetting,
|
|
3812
3828
|
st as isSettingChild,
|
|
3813
3829
|
w as isSettingGroup,
|
|
3814
|
-
|
|
3830
|
+
z as iterateSettings
|
|
3815
3831
|
};
|
|
@@ -20,6 +20,9 @@ export declare class EmbeddedColorPicker {
|
|
|
20
20
|
private onColorChange;
|
|
21
21
|
private recentScope;
|
|
22
22
|
private recentSectionRefresh?;
|
|
23
|
+
private isDragging;
|
|
24
|
+
private changeRafId?;
|
|
25
|
+
private pendingExternalUpdate?;
|
|
23
26
|
constructor(options: EmbeddedColorPickerOptions);
|
|
24
27
|
private parsePercentage;
|
|
25
28
|
private build;
|
|
@@ -28,9 +31,11 @@ export declare class EmbeddedColorPicker {
|
|
|
28
31
|
private syncInput;
|
|
29
32
|
private applyFromInput;
|
|
30
33
|
private updateOpacityBg;
|
|
34
|
+
private queueChange;
|
|
35
|
+
private flushChange;
|
|
36
|
+
private applyPendingExternal;
|
|
31
37
|
private initFromColor;
|
|
32
38
|
commitRecentColor(): void;
|
|
33
39
|
getElement(): HTMLElement;
|
|
34
|
-
/** For external updates, e.g. when gradient stop changes from outside */
|
|
35
40
|
updateColor(color: string, opacity: number): void;
|
|
36
41
|
}
|
package/package.json
CHANGED