builder-settings-types 0.0.325 → 0.0.326
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Nt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let vt=(h=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(h|=0));for(;h--;)t+=Nt[e[h]&63];return t};function It(h){let t=0,e=h.parentElement;for(;e;)e.classList.contains("setting-group")&&e!==h&&t++,e=e.parentElement;return t}function Z(h,t){const e=Math.min(Math.max(t,0),5);h.setAttribute("data-nesting-level",e.toString()),e>0?h.style.setProperty("--visual-indent",`${e*2}px`):(h.style.removeProperty("--visual-indent"),h.style.marginLeft="")}function st(h,t=0){h.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach(i=>{const s=i,n=t+1;Z(s,n),st(s,n)})}const Vt={maxLevel:5,spacingMultiplier:1,visualIndentMultiplier:2,enableAutoDetection:!0};class Tt{constructor(t={}){this.observedElements=new Set,this.config={...Vt,...t},this.config.enableAutoDetection&&this.setupAutoDetection()}setupAutoDetection(){this.observer=new MutationObserver(t=>{let e=!1;t.forEach(i=>{i.type==="childList"&&i.addedNodes.forEach(s=>{s instanceof HTMLElement&&(s.classList.contains("setting-group")?[s]:Array.from(s.querySelectorAll(".setting-group"))).length>0&&(e=!0)})}),e&&this.updateAllNesting()}),this.observer.observe(document.body,{childList:!0,subtree:!0})}trackElement(t){this.observedElements.add(t),this.updateElementNesting(t)}untrackElement(t){this.observedElements.delete(t)}updateElementNesting(t){const e=It(t);this.applyNestingWithConfig(t,e)}updateAllNesting(){this.observedElements.forEach(t=>{t.isConnected?this.updateElementNesting(t):this.observedElements.delete(t)})}applyNestingWithConfig(t,e){const i=Math.min(Math.max(e,0),this.config.maxLevel);if(t.setAttribute("data-nesting-level",i.toString()),i>0){const s=i*this.config.visualIndentMultiplier;t.style.setProperty("--visual-indent",`${s}px`)}else t.style.removeProperty("--visual-indent"),t.style.marginLeft=""}recalculateNesting(t=document.body){t.querySelectorAll(".setting-group").forEach(i=>{const s=i;this.updateElementNesting(s),this.trackElement(s)})}getNestingStats(){const t={};return this.observedElements.forEach(e=>{const i=parseInt(e.getAttribute("data-nesting-level")||"0",10);t[i]=(t[i]||0)+1}),t}destroy(){this.observer&&(this.observer.disconnect(),this.observer=void 0),this.observedElements.clear()}}const dt=new Tt;function Y(h){if(h===null||typeof h!="object")return h;if(h instanceof Date)return new Date(h.getTime());if(h instanceof Array)return h.map(t=>Y(t));if(typeof h=="object"){const t={};for(const e in h)Object.prototype.hasOwnProperty.call(h,e)&&(t[e]=Y(h[e]));return t}return h}function Pt(h){switch(h){case"number":return 0;case"text":return"";case"select":return null;case"color":return"#000000";case"date":return new Date().toISOString().split("T")[0];case"button":return"";default:return""}}const M=class M{constructor(t={}){this.props=t,this.dataPropsPath="",this.id=t.id||vt(),this.value=this.props.default,this.desktop=this.props.default,this.title=t.title||"",this.includeGetJson=t.includeGetJson!==void 0?t.includeGetJson:!0}static SetUploadUrl(t){globalThis.DefaultUploadUrl=t,M.DefaultUploadUrl=t}static SetDefaultLanguage(t){globalThis.DefaultLanguage=t,M.DefaultLanguage=t}static CurrentLanguage(t){return t!==void 0&&(M.currentLanguage=t,M.currentLanguageExplicitlySet=!0,M.DefaultLanguage||M.SetDefaultLanguage(t),M.languageChangeCallbacks.forEach(e=>e(t))),M.currentLanguage||M.DefaultLanguage}static HasExplicitCurrentLanguage(){return M.currentLanguageExplicitlySet}static onLanguageChange(t){return M.languageChangeCallbacks.add(t),()=>{M.languageChangeCallbacks.delete(t)}}static SetGlobalVariables(t){M.GlobalVariables={...M.GlobalVariables,...t}}destroy(){throw new Error("Method not implemented.")}setOnChange(t){return this.onChange=t,this}setOnBlur(t){return this.onBlur=t,this}setDataPropsPath(t){this.dataPropsPath=t}getDataPropsPath(){return this.dataPropsPath}setValue(t){this.value=t,this.inputEl&&(this.inputEl.value=String(t)),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}clone(){const t=this.constructor,e=Y(this.props),i=new t(e);return i.value=Y(this.value),i}createInput(t){t={...this.props.inputProps,...t};const e=document.createElement("div");if(e.className=t.wrapperClassName||"",t.title||t.icon){const a=document.createElement("div");if(a.className="icon-container",t.icon){const l=this.createIcon(t.icon,t.iconClassName);a.appendChild(l)}if(t.title){const l=this.createLabel(t.title,t.labelClassName);a.appendChild(l)}e.appendChild(a)}const i=document.createElement("div");i.className=t.wrapperClassName||"";const s=document.createElement("input");this.inputEl=s,s.value=String(t.value||Pt(t.inputType)),s.type=t.inputType,s.placeholder=t.placeholder||"",s.className=t.inputClassName||"",this.dataPropsPath&&s.setAttribute("data-test-id",this.dataPropsPath);const n=a=>{const l=a.target;let r=l.value;switch(t.inputType){case"number":r=Number(l.value);break;case"color":r=l.value;break;case"date":r=l.value;break;case"select":r=l.value;break;case"text":r=l.value;break;case"button":r=l.value;break;default:r=l.value}this.value=r,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},o=a=>{a.target,this.onBlur&&this.onBlur(this.value)};return s.addEventListener("input",n),s.addEventListener("change",n),s.addEventListener("blur",o),t.inputCustomizer&&t.inputCustomizer(s),i.appendChild(s),e.appendChild(i),e}createLabel(t,e){const i=document.createElement("span");return i.textContent=t,i.className="input-label "+(e||""),i}createIcon(t,e){const i=document.createElement("span");return i.className="input-icon "+(e||""),i.innerHTML=t,i}};M.currentLanguageExplicitlySet=!1,M.languageChangeCallbacks=new Set,M.GlobalVariables={primary:"#1B1958",secondary:"#0D0938",tertiary:"#2A1560",accent:"#189541","text-dark":"#00141E","text-light":"#FFFFFF"},M.GlobalVariableGroups=[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}];let w=M;function B(h){return h instanceof w}function k(h){return h instanceof H}function nt(h){return B(h)||k(h)}const rt=(h,t,e)=>{let i=!1,s=0,n=0,o=0,a=0;const l=p=>{if(p.target.closest("button"))return;i=!0,s=p.clientX,n=p.clientY;const d=t.getBoundingClientRect();o=d.left,a=d.top,document.addEventListener("mousemove",r),document.addEventListener("mouseup",c),document.body.style.userSelect="none"},r=p=>{if(!i)return;const d=p.clientX-s,g=p.clientY-n,C=window.innerWidth,m=window.innerHeight,u=t.offsetWidth,v=t.offsetHeight;let f=o+d,y=a+g;f=Math.max(8,Math.min(C-u-8,f)),y=Math.max(8,Math.min(m-v-8,y)),t.style.left=`${f}px`,t.style.top=`${y}px`,e==null||e(f,y)},c=()=>{i=!1,document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",c),document.body.style.userSelect=""};h.addEventListener("mousedown",l)},R=h=>{if(!h)return null;let t=h.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()}`},X=(h,t,e)=>`#${[h,t,e].map(i=>Math.max(0,Math.min(255,i)).toString(16).padStart(2,"0")).join("")}`,O=h=>{const t=h.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)}},W=h=>{const{r:t,g:e,b:i}=O(h),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 c=0;r!==0&&(a===s?c=(n-o)/r%6:a===n?c=(o-s)/r+2:c=(s-n)/r+4),c<0&&(c+=6);const p=a===0?0:r/a,d=a;return{h:c*60,s:p,v:d}},j=(h,t,e)=>{const i=(h%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),X(Math.round((a+o)*255),Math.round((l+o)*255),Math.round((r+o)*255))},ft=(h,t,e)=>{const i=e*(1-t/2),s=i===0||i===1?0:(e-i)/Math.min(i,1-i);return{hue:h,sat:s,lightness:i}},ot=(h,t,e)=>{const i=(1-Math.abs(2*e-1))*t,s=i*(1-Math.abs(h/60%2-1)),n=e-i/2;let o=0,a=0,l=0;return h<60?(o=i,a=s,l=0):h<120?(o=s,a=i,l=0):h<180?(o=0,a=i,l=s):h<240?(o=0,a=s,l=i):h<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)}},at=(h,t)=>{const e=Math.max(0,Math.min(100,t))/100;if(h.startsWith("#")){const{r:s,g:n,b:o}=O(h);return`rgba(${s}, ${n}, ${o}, ${e})`}if(h.startsWith("rgba("))return h.replace(/,\s*[\d.]+\)$/,`, ${e})`);if(h.startsWith("rgb("))return h.replace("rgb(","rgba(").replace(")",`, ${e})`);if(h.startsWith("hsl(")){const s=h.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const{r:n,g:o,b:a}=ot(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}if(h.startsWith("hsla(")){const s=h.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);if(s){const{r:n,g:o,b:a}=ot(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}const i=R(h);if(i){const{r:s,g:n,b:o}=O(i);return`rgba(${s}, ${n}, ${o}, ${e})`}return h},Ot=h=>["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy","maroon","olive","aqua","silver","teal","fuchsia","transparent"].includes(h.toLowerCase()),Ct=h=>[/^#[0-9a-fA-F]{3,8}$/,/^rgba?\s*\([^)]+\)$/,/^hsla?\s*\([^)]+\)$/,/^[a-zA-Z]+$/].some(e=>e.test(h.trim())),Ht=h=>{if(typeof document>"u")return Ct(h)||!!R(h);const t=document.createElement("div");return t.style.color=h,t.style.color!==""},yt=h=>{const t=h.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:X(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:X(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}=ot(parseFloat(i[1]),parseFloat(i[2])/100,parseFloat(i[3])/100),l=i[4]?parseFloat(i[4]):1;return{color:X(n,o,a),position:0,opacity:Math.round(l*100)}}return{color:R(t)||t,position:0,opacity:100}},pt=h=>{const t=[];let e="",i=0;for(let s=0;s<h.length;s++){const n=h[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},ut=(h,t)=>{const e=new RegExp(`${t}\\s*\\(`,"i"),i=h.match(e);if(!i)return null;const s=i.index+i[0].length;let n=1,o=s;for(let a=s;a<h.length&&n>0;a++)h[a]==="("?n++:h[a]===")"&&n--,o=a;return n===0?h.substring(s,o):null},$t=h=>{const t=h.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(h)||/^hsl/i.test(h)||Ot(t)},gt=h=>{const t=[];return h.forEach((e,i)=>{const s=e.trim();if(!s)return;let n="",o=0;const a=s.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);a&&Ct(a[1].trim())?(n=a[1].trim(),o=parseFloat(a[2])):(n=s,o=h.length===1?0:i/(h.length-1)*100);const l=yt(n);l.position=Math.max(0,Math.min(100,Math.round(o))),t.push(l)}),t},D=h=>{const t=h.stops&&h.stops.length?h.stops:[{color:"#000000",position:0,opacity:100}];return{type:h.type&&["linear","radial","solid"].includes(h.type)?h.type:"linear",angle:typeof h.angle=="number"?h.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=h=>{const t=h.replace(/;$/,"").trim();if(Ht(t)){const s=yt(t);return D({type:"solid",angle:0,stops:[s]})}const e=ut(t,"linear-gradient");if(e){const s=pt(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=gt(o);return l.length?D({type:"linear",angle:n,stops:l}):null}const i=ut(t,"radial-gradient");if(i){const s=pt(i),n=s[0]&&!$t(s[0])?s.slice(1):s,o=gt(n);return o.length?D({type:"radial",angle:0,stops:o}):null}return null},I=h=>{if(h.type==="solid"){const e=h.stops[0],i=e.color;if(i.startsWith("var(--"))return i;const s=e.opacity??100,n=i.replace("#",""),o=Math.round(s/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${n}${o}`}const t=h.stops.map(e=>`${at(e.color,e.opacity??100)} ${e.position}%`).join(", ");return h.type==="radial"?`radial-gradient(circle, ${t})`:`linear-gradient(${h.angle}deg, ${t})`},Bt=h=>Math.round(h/100*255).toString(16).toUpperCase().padStart(2,"0"),K=h=>{if(h.type==="solid"){const t=h.stops[0];if(t){const e=t.color;if(e.startsWith("var(--"))return e.replace("var(--","").replace(")","").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");e.toUpperCase();const i=t.opacity??100;if(i===100)return e;{const s=Bt(i);return`${e}${s}`}}return"#000000"}return h.type==="linear"?`Linear ${h.angle}°`:"Radial Gradient"},J=class J{static defaults(){return{solid:[],gradient:[]}}static normalizeList(t){const e=new Set,i=[];return t.forEach(s=>{let n=R(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=[],n=Math.max(e.length,i.length);for(let o=0;o<n;o++)o<e.length&&s.push(e[o]),o<i.length&&s.push(i[o]);return this.normalizeList(s)}return[...this.list(t)]}static addColor(t,e){if(!t)return;let i=R(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()}};J.STORAGE_KEY="settingsLib_recentColors",J.MAX_COLORS=12,J.colors=null;let z=J;const ct=(h,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=(c,p)=>{const d=c.getBoundingClientRect();s.textContent=p,s.style.left=`${d.left+d.width/2}px`,s.style.top=`${d.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 c=z.getColors(t);if(c.length===0){a.style.display="none",l.style.display="block";return}a.style.display="grid",l.style.display="none",c.forEach(p=>{const d=document.createElement("button");d.type="button",d.className="color-picker-recent-swatch";const g=At(p);if(d.title=g,d.setAttribute("aria-label",`Use color: ${g}`),p.includes("gradient(")){d.style.backgroundImage=p,d.style.backgroundColor="transparent";const m=P(p);m&&m.stops&&m.stops.length>0&&(d.style.borderColor=m.stops[0].color)}else d.style.backgroundColor=p,d.style.borderColor=p;d.addEventListener("mouseenter",()=>o(d,g)),d.addEventListener("mouseleave",()=>{n(),d.style.boxShadow=""}),d.addEventListener("mousedown",()=>{d.style.boxShadow="0px 0px 0px 2px var(--grey40)"}),d.addEventListener("mouseup",()=>{setTimeout(()=>{d.style.boxShadow=""},150)}),d.addEventListener("click",()=>{n(),h(p)}),a.appendChild(d)})};return r(),{container:e,refresh:r}},At=h=>{const t=P(h);if(t)return K(t);const e=R(h);if(e){const i=O(e);return`${e} (RGB: ${i.r}, ${i.g}, ${i.b})`}return h},bt=`<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const It="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let vt=(h=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(h|=0));for(;h--;)t+=It[e[h]&63];return t};function Nt(h){let t=0,e=h.parentElement;for(;e;)e.classList.contains("setting-group")&&e!==h&&t++,e=e.parentElement;return t}function Z(h,t){const e=Math.min(Math.max(t,0),5);h.setAttribute("data-nesting-level",e.toString()),e>0?h.style.setProperty("--visual-indent",`${e*2}px`):(h.style.removeProperty("--visual-indent"),h.style.marginLeft="")}function st(h,t=0){h.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach(i=>{const s=i,n=t+1;Z(s,n),st(s,n)})}const Vt={maxLevel:5,spacingMultiplier:1,visualIndentMultiplier:2,enableAutoDetection:!0};class Tt{constructor(t={}){this.observedElements=new Set,this.config={...Vt,...t},this.config.enableAutoDetection&&this.setupAutoDetection()}setupAutoDetection(){this.observer=new MutationObserver(t=>{let e=!1;t.forEach(i=>{i.type==="childList"&&i.addedNodes.forEach(s=>{s instanceof HTMLElement&&(s.classList.contains("setting-group")?[s]:Array.from(s.querySelectorAll(".setting-group"))).length>0&&(e=!0)})}),e&&this.updateAllNesting()}),this.observer.observe(document.body,{childList:!0,subtree:!0})}trackElement(t){this.observedElements.add(t),this.updateElementNesting(t)}untrackElement(t){this.observedElements.delete(t)}updateElementNesting(t){const e=Nt(t);this.applyNestingWithConfig(t,e)}updateAllNesting(){this.observedElements.forEach(t=>{t.isConnected?this.updateElementNesting(t):this.observedElements.delete(t)})}applyNestingWithConfig(t,e){const i=Math.min(Math.max(e,0),this.config.maxLevel);if(t.setAttribute("data-nesting-level",i.toString()),i>0){const s=i*this.config.visualIndentMultiplier;t.style.setProperty("--visual-indent",`${s}px`)}else t.style.removeProperty("--visual-indent"),t.style.marginLeft=""}recalculateNesting(t=document.body){t.querySelectorAll(".setting-group").forEach(i=>{const s=i;this.updateElementNesting(s),this.trackElement(s)})}getNestingStats(){const t={};return this.observedElements.forEach(e=>{const i=parseInt(e.getAttribute("data-nesting-level")||"0",10);t[i]=(t[i]||0)+1}),t}destroy(){this.observer&&(this.observer.disconnect(),this.observer=void 0),this.observedElements.clear()}}const dt=new Tt;function Y(h){if(h===null||typeof h!="object")return h;if(h instanceof Date)return new Date(h.getTime());if(h instanceof Array)return h.map(t=>Y(t));if(typeof h=="object"){const t={};for(const e in h)Object.prototype.hasOwnProperty.call(h,e)&&(t[e]=Y(h[e]));return t}return h}function Pt(h){switch(h){case"number":return 0;case"text":return"";case"select":return null;case"color":return"#000000";case"date":return new Date().toISOString().split("T")[0];case"button":return"";default:return""}}const M=class M{constructor(t={}){this.props=t,this.dataPropsPath="",this.id=t.id||vt(),this.value=this.props.default,this.desktop=this.props.default,this.title=t.title||"",this.includeGetJson=t.includeGetJson!==void 0?t.includeGetJson:!0}static SetUploadUrl(t){globalThis.DefaultUploadUrl=t,M.DefaultUploadUrl=t}static SetDefaultLanguage(t){globalThis.DefaultLanguage=t,M.DefaultLanguage=t}static CurrentLanguage(t){return t!==void 0&&(M.currentLanguage=t,M.currentLanguageExplicitlySet=!0,M.DefaultLanguage||M.SetDefaultLanguage(t),M.languageChangeCallbacks.forEach(e=>e(t))),M.currentLanguage||M.DefaultLanguage}static HasExplicitCurrentLanguage(){return M.currentLanguageExplicitlySet}static onLanguageChange(t){return M.languageChangeCallbacks.add(t),()=>{M.languageChangeCallbacks.delete(t)}}static SetGlobalVariables(t){M.GlobalVariables={...M.GlobalVariables,...t}}destroy(){throw new Error("Method not implemented.")}setOnChange(t){return this.onChange=t,this}setOnBlur(t){return this.onBlur=t,this}setDataPropsPath(t){this.dataPropsPath=t}getDataPropsPath(){return this.dataPropsPath}setValue(t){this.value=t,this.inputEl&&(this.inputEl.value=String(t)),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}clone(){const t=this.constructor,e=Y(this.props),i=new t(e);return i.value=Y(this.value),i}createInput(t){t={...this.props.inputProps,...t};const e=document.createElement("div");if(e.className=t.wrapperClassName||"",t.title||t.icon){const a=document.createElement("div");if(a.className="icon-container",t.icon){const l=this.createIcon(t.icon,t.iconClassName);a.appendChild(l)}if(t.title){const l=this.createLabel(t.title,t.labelClassName);a.appendChild(l)}e.appendChild(a)}const i=document.createElement("div");i.className=t.wrapperClassName||"";const s=document.createElement("input");this.inputEl=s,s.value=String(t.value||Pt(t.inputType)),s.type=t.inputType,s.placeholder=t.placeholder||"",s.className=t.inputClassName||"",this.dataPropsPath&&s.setAttribute("data-test-id",this.dataPropsPath);const n=a=>{const l=a.target;let r=l.value;switch(t.inputType){case"number":r=Number(l.value);break;case"color":r=l.value;break;case"date":r=l.value;break;case"select":r=l.value;break;case"text":r=l.value;break;case"button":r=l.value;break;default:r=l.value}this.value=r,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},o=a=>{a.target,this.onBlur&&this.onBlur(this.value)};return s.addEventListener("input",n),s.addEventListener("change",n),s.addEventListener("blur",o),t.inputCustomizer&&t.inputCustomizer(s),i.appendChild(s),e.appendChild(i),e}createLabel(t,e){const i=document.createElement("span");return i.textContent=t,i.className="input-label "+(e||""),i}createIcon(t,e){const i=document.createElement("span");return i.className="input-icon "+(e||""),i.innerHTML=t,i}};M.currentLanguageExplicitlySet=!1,M.languageChangeCallbacks=new Set,M.GlobalVariables={primary:"#1B1958",secondary:"#0D0938",tertiary:"#2A1560",accent:"#189541","text-dark":"#00141E","text-light":"#FFFFFF"},M.GlobalVariableGroups=[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}];let w=M;function B(h){return h instanceof w}function k(h){return h instanceof H}function nt(h){return B(h)||k(h)}const rt=(h,t,e)=>{let i=!1,s=0,n=0,o=0,a=0;const l=p=>{if(p.target.closest("button"))return;i=!0,s=p.clientX,n=p.clientY;const d=t.getBoundingClientRect();o=d.left,a=d.top,document.addEventListener("mousemove",r),document.addEventListener("mouseup",c),document.body.style.userSelect="none"},r=p=>{if(!i)return;const d=p.clientX-s,g=p.clientY-n,C=window.innerWidth,m=window.innerHeight,u=t.offsetWidth,f=t.offsetHeight;let v=o+d,y=a+g;v=Math.max(8,Math.min(C-u-8,v)),y=Math.max(8,Math.min(m-f-8,y)),t.style.left=`${v}px`,t.style.top=`${y}px`,e==null||e(v,y)},c=()=>{i=!1,document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",c),document.body.style.userSelect=""};h.addEventListener("mousedown",l)},R=h=>{if(!h)return null;let t=h.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()}`},X=(h,t,e)=>`#${[h,t,e].map(i=>Math.max(0,Math.min(255,i)).toString(16).padStart(2,"0")).join("")}`,O=h=>{const t=h.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)}},W=h=>{const{r:t,g:e,b:i}=O(h),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 c=0;r!==0&&(a===s?c=(n-o)/r%6:a===n?c=(o-s)/r+2:c=(s-n)/r+4),c<0&&(c+=6);const p=a===0?0:r/a,d=a;return{h:c*60,s:p,v:d}},j=(h,t,e)=>{const i=(h%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),X(Math.round((a+o)*255),Math.round((l+o)*255),Math.round((r+o)*255))},ft=(h,t,e)=>{const i=e*(1-t/2),s=i===0||i===1?0:(e-i)/Math.min(i,1-i);return{hue:h,sat:s,lightness:i}},ot=(h,t,e)=>{const i=(1-Math.abs(2*e-1))*t,s=i*(1-Math.abs(h/60%2-1)),n=e-i/2;let o=0,a=0,l=0;return h<60?(o=i,a=s,l=0):h<120?(o=s,a=i,l=0):h<180?(o=0,a=i,l=s):h<240?(o=0,a=s,l=i):h<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)}},at=(h,t)=>{const e=Math.max(0,Math.min(100,t))/100;if(h.startsWith("#")){const{r:s,g:n,b:o}=O(h);return`rgba(${s}, ${n}, ${o}, ${e})`}if(h.startsWith("rgba("))return h.replace(/,\s*[\d.]+\)$/,`, ${e})`);if(h.startsWith("rgb("))return h.replace("rgb(","rgba(").replace(")",`, ${e})`);if(h.startsWith("hsl(")){const s=h.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const{r:n,g:o,b:a}=ot(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}if(h.startsWith("hsla(")){const s=h.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);if(s){const{r:n,g:o,b:a}=ot(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}const i=R(h);if(i){const{r:s,g:n,b:o}=O(i);return`rgba(${s}, ${n}, ${o}, ${e})`}return h},Ot=h=>["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy","maroon","olive","aqua","silver","teal","fuchsia","transparent"].includes(h.toLowerCase()),Ct=h=>[/^#[0-9a-fA-F]{3,8}$/,/^rgba?\s*\([^)]+\)$/,/^hsla?\s*\([^)]+\)$/,/^[a-zA-Z]+$/].some(e=>e.test(h.trim())),Ht=h=>{if(typeof document>"u")return Ct(h)||!!R(h);const t=document.createElement("div");return t.style.color=h,t.style.color!==""},yt=h=>{const t=h.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:X(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:X(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}=ot(parseFloat(i[1]),parseFloat(i[2])/100,parseFloat(i[3])/100),l=i[4]?parseFloat(i[4]):1;return{color:X(n,o,a),position:0,opacity:Math.round(l*100)}}return{color:R(t)||t,position:0,opacity:100}},pt=h=>{const t=[];let e="",i=0;for(let s=0;s<h.length;s++){const n=h[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},ut=(h,t)=>{const e=new RegExp(`${t}\\s*\\(`,"i"),i=h.match(e);if(!i)return null;const s=i.index+i[0].length;let n=1,o=s;for(let a=s;a<h.length&&n>0;a++)h[a]==="("?n++:h[a]===")"&&n--,o=a;return n===0?h.substring(s,o):null},$t=h=>{const t=h.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(h)||/^hsl/i.test(h)||Ot(t)},gt=h=>{const t=[];return h.forEach((e,i)=>{const s=e.trim();if(!s)return;let n="",o=0;const a=s.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);a&&Ct(a[1].trim())?(n=a[1].trim(),o=parseFloat(a[2])):(n=s,o=h.length===1?0:i/(h.length-1)*100);const l=yt(n);l.position=Math.max(0,Math.min(100,Math.round(o))),t.push(l)}),t},D=h=>{const t=h.stops&&h.stops.length?h.stops:[{color:"#000000",position:0,opacity:100}];return{type:h.type&&["linear","radial","solid"].includes(h.type)?h.type:"linear",angle:typeof h.angle=="number"?h.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=h=>{const t=h.replace(/;$/,"").trim();if(Ht(t)){const s=yt(t);return D({type:"solid",angle:0,stops:[s]})}const e=ut(t,"linear-gradient");if(e){const s=pt(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=gt(o);return l.length?D({type:"linear",angle:n,stops:l}):null}const i=ut(t,"radial-gradient");if(i){const s=pt(i),n=s[0]&&!$t(s[0])?s.slice(1):s,o=gt(n);return o.length?D({type:"radial",angle:0,stops:o}):null}return null},N=h=>{if(h.type==="solid"){const e=h.stops[0],i=e.color;if(i.startsWith("var(--"))return i;const s=e.opacity??100,n=i.replace("#",""),o=Math.round(s/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${n}${o}`}const t=h.stops.map(e=>`${at(e.color,e.opacity??100)} ${e.position}%`).join(", ");return h.type==="radial"?`radial-gradient(circle, ${t})`:`linear-gradient(${h.angle}deg, ${t})`},Bt=h=>Math.round(h/100*255).toString(16).toUpperCase().padStart(2,"0"),K=h=>{if(h.type==="solid"){const t=h.stops[0];if(t){const e=t.color;if(e.startsWith("var(--"))return e.replace("var(--","").replace(")","").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");e.toUpperCase();const i=t.opacity??100;if(i===100)return e;{const s=Bt(i);return`${e}${s}`}}return"#000000"}return h.type==="linear"?`Linear ${h.angle}°`:"Radial Gradient"},J=class J{static defaults(){return{solid:[],gradient:[]}}static normalizeList(t){const e=new Set,i=[];return t.forEach(s=>{let n=R(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=[],n=Math.max(e.length,i.length);for(let o=0;o<n;o++)o<e.length&&s.push(e[o]),o<i.length&&s.push(i[o]);return this.normalizeList(s)}return[...this.list(t)]}static addColor(t,e){if(!t)return;let i=R(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()}};J.STORAGE_KEY="settingsLib_recentColors",J.MAX_COLORS=12,J.colors=null;let z=J;const ct=(h,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=(c,p)=>{const d=c.getBoundingClientRect();s.textContent=p,s.style.left=`${d.left+d.width/2}px`,s.style.top=`${d.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 c=z.getColors(t);if(c.length===0){a.style.display="none",l.style.display="block";return}a.style.display="grid",l.style.display="none",c.forEach(p=>{const d=document.createElement("button");d.type="button",d.className="color-picker-recent-swatch";const g=At(p);if(d.title=g,d.setAttribute("aria-label",`Use color: ${g}`),p.includes("gradient(")){d.style.backgroundImage=p,d.style.backgroundColor="transparent";const m=P(p);m&&m.stops&&m.stops.length>0&&(d.style.borderColor=m.stops[0].color)}else d.style.backgroundColor=p,d.style.borderColor=p;d.addEventListener("mouseenter",()=>o(d,g)),d.addEventListener("mouseleave",()=>{n(),d.style.boxShadow=""}),d.addEventListener("mousedown",()=>{d.style.boxShadow="0px 0px 0px 2px var(--grey40)"}),d.addEventListener("mouseup",()=>{setTimeout(()=>{d.style.boxShadow=""},150)}),d.addEventListener("click",()=>{n(),h(p)}),a.appendChild(d)})};return r(),{container:e,refresh:r}},At=h=>{const t=P(h);if(t)return K(t);const e=R(h);if(e){const i=O(e);return`${e} (RGB: ${i.r}, ${i.g}, ${i.b})`}return h},bt=`<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
2
|
<path fill-rule="evenodd" clip-rule="evenodd"
|
|
3
3
|
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"
|
|
4
4
|
fill="#919EAB"/>
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
<path d="M20.6106 19.5062C20.6887 19.5843 20.6887 19.711 20.6106 19.7891L19.7896 20.6101C19.7115 20.6882 19.5848 20.6882 19.5067 20.6101L5.98957 7.09298C5.91146 7.01488 5.91146 6.88825 5.98957 6.81014L6.81063 5.98908C6.88873 5.91097 7.01537 5.91097 7.09347 5.98908L20.6106 19.5062Z" fill="#46525C"/>
|
|
23
23
|
<path d="M9.69583 12.2146C9.81298 12.3318 9.81298 12.5217 9.69583 12.6389L7.80151 14.5332C6.72071 15.614 6.6062 17.4365 7.80151 18.6318C8.99473 19.8267 10.8184 19.7123 11.8992 18.6318L13.7935 16.7366C13.9106 16.6194 14.1006 16.6194 14.2178 16.7366L14.816 17.3348C14.9331 17.4519 14.9332 17.6418 14.816 17.759L12.9216 19.6543C11.2241 21.3536 8.47364 21.3518 6.77417 19.6543C5.07483 17.9568 5.0749 15.2064 6.77417 13.5068L8.66848 11.6116C8.78563 11.4944 8.97562 11.4944 9.0928 11.6116L9.69583 12.2146ZM13.5085 6.77441C15.2061 5.07514 17.9565 5.07509 19.656 6.77441C21.3535 8.47388 21.3533 11.2243 19.656 12.9238L17.7607 14.8182C17.6436 14.9354 17.4536 14.9353 17.3365 14.8182L16.7344 14.2161C16.6172 14.0989 16.6172 13.9089 16.7344 13.7918L18.6296 11.8975C19.7101 10.8167 19.8245 8.99503 18.6296 7.7998C17.4363 6.60449 15.6118 6.719 14.531 7.7998L12.6367 9.69412C12.5195 9.81128 12.3296 9.81128 12.2124 9.69412L11.6123 9.09402C11.4952 8.97684 11.4952 8.78685 11.6124 8.6697L13.5085 6.77441Z" fill="#46525C"/>
|
|
24
24
|
</svg>
|
|
25
|
-
`;class mt{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=bt,s.addEventListener("click",()=>this.close(!0)),e.appendChild(i),e.appendChild(s),rt(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 c=document.createElement("div");c.className="color-picker-hue",this.hueSlider=c;const p=document.createElement("div");p.className="color-picker-hue-marker",this.hueMarker=p,c.appendChild(p);const d=document.createElement("div");d.className="color-picker-opacity",this.opacitySlider=d;const g=document.createElement("div");g.className="color-picker-opacity-marker",this.opacityMarker=g,d.appendChild(g),r.appendChild(c),r.appendChild(d),a.appendChild(l),a.appendChild(r);const C=ct(b=>{var x;this.setColor(b),(x=this.onChange)==null||x.call(this,b,this.currentOpacity)},this.recentScope);this.recentSectionRefresh=C.refresh;const m=document.createElement("div");m.className="color-picker-format-section";const u=document.createElement("select");u.className="color-picker-format-select",this.select=u;const v=document.createElement("option");v.value="hex",v.textContent="HEX";const f=document.createElement("option");f.value="rgb",f.textContent="RGB";const y=document.createElement("option");y.value="hsl",y.textContent="HSL",u.appendChild(v),u.appendChild(f),u.appendChild(y);const E=document.createElement("input");E.type="text",E.className="color-picker-color-input",E.value=this.currentColor,this.input=E;const L=document.createElement("div");L.className="color-picker-input-container";const N=document.createElement("button");return N.className="color-picker-copy-inside",N.textContent="Copy",L.appendChild(E),L.appendChild(N),m.appendChild(u),m.appendChild(L),t.appendChild(e),t.appendChild(n),t.appendChild(a),t.appendChild(C.container),t.appendChild(m),t.addEventListener("click",b=>b.stopPropagation()),this.bind(n,c,d,E,u,N,l),t}createBackdrop(){const t=document.createElement("div");return t.className="color-picker-backdrop",t.style.display="none",t.style.pointerEvents="none",t}bind(t,e,i,s,n,o,a){const l=p=>{var f;const d=t.getBoundingClientRect(),g=Math.max(0,Math.min(1,(p.clientX-d.left)/d.width)),C=Math.max(0,Math.min(1,(p.clientY-d.top)/d.height));this.colorMarker.style.left=`${g*100}%`,this.colorMarker.style.top=`${C*100}%`;const u=this.parsePercentage(this.hueMarker.style.left||"0%")*360,v=j(u,g,1-C);this.currentColor=v,this.syncInput(),this.updateOpacityBg(),(f=this.onChange)==null||f.call(this,v,this.currentOpacity)},r=p=>{var f;const d=e.getBoundingClientRect();let g=Math.max(0,Math.min(1,(p.clientX-d.left)/d.width));this.hueMarker.style.left=`${g*100}%`;const C=g*360,m=this.parsePercentage(this.colorMarker.style.left||"0%"),u=this.parsePercentage(this.colorMarker.style.top||"0%"),v=j(C,m,1-u);this.currentColor=v,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${C}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(f=this.onChange)==null||f.call(this,v,this.currentOpacity)},c=p=>{var C;const d=i.getBoundingClientRect(),g=Math.max(0,Math.min(1,(p.clientX-d.left)/d.width));this.opacityMarker.style.left=`${g*100}%`,this.currentOpacity=Math.round(g*100),(C=this.onChange)==null||C.call(this,this.currentColor,this.currentOpacity)};t.addEventListener("mousedown",p=>{p.preventDefault(),l(p);const d=C=>l(C),g=()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",g)}),e.addEventListener("mousedown",p=>{p.preventDefault(),r(p);const d=C=>r(C),g=()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",g)}),i.addEventListener("mousedown",p=>{p.preventDefault(),c(p);const d=C=>c(C),g=()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",g)}),n.addEventListener("change",()=>this.syncInput()),s.addEventListener("input",()=>this.applyFromInput()),s.addEventListener("blur",()=>this.syncInput()),s.addEventListener("keydown",p=>{p.key==="Enter"&&(p.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 p;if(!("EyeDropper"in window)){alert("EyeDropper API is not supported in this browser.");return}try{const d=new window.EyeDropper,{sRGBHex:g}=await d.open();this.setColor(g),(p=this.onChange)==null||p.call(this,g,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}=W(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}=W(this.currentColor);if(t==="hex")this.input.value=this.currentColor;else if(t==="rgb"){const{r:n,g:o,b:a}=O(this.currentColor);this.input.value=`rgb(${n}, ${o}, ${a})`}else{const{hue:n,sat:o,lightness:a}=ft(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=j(n,r,l)}}}e&&this.setColor(e)}updateOpacityBg(){const{r:t,g:e,b:i}=O(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${t}, ${e}, ${i})`)}open(t,e,i){var y;this.currentColor=t,this.currentOpacity=i??100,this.syncInput();const{h:s,s:n,v:o}=W(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}%`,(y=this.recentSectionRefresh)==null||y.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(),c=window.innerWidth,p=window.innerHeight,d=16;let g=r.right+8,C=r.top;const m=c-r.right,u=r.left;m>=a+d?g=r.right+8:u>=a+d?g=r.left-a-8:g=Math.max(d,(c-a)/2);const v=p-r.bottom,f=r.top;v>=l+d?C=r.bottom+8:f>=l+d?C=r.top-l-8:v>f?(C=r.bottom+8,C+l>p-d&&(C=p-l-d)):(C=r.top-l-8,C<d&&(C=d)),this.element.style.left=`${g}px`,this.element.style.top=`${C}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"&&(z.addColor(this.currentColor,this.recentScope),(e=this.recentSectionRefresh)==null||e.call(this)))}getElement(){return this.element}}class Ut{constructor(t){this.isDragging=!1,this.currentColor="#FFFFFF",this.currentColor=this.sanitizeColor(t.initialColor),this.currentOpacity=this.clampOpacity(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}sanitizeColor(t){const e=this.currentColor||"#FFFFFF";return R(t)??e}clampOpacity(t){return Number.isFinite(t)?Math.min(100,Math.max(0,Math.round(t))):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 c=document.createElement("div");c.className="color-picker-opacity-marker",this.opacityMarker=c,r.appendChild(c),o.appendChild(a),o.appendChild(r),s.appendChild(n),s.appendChild(o);const p=ct(E=>{const L=P(E);L&&L.type!=="solid"?this.onColorChange(E,this.currentOpacity):(this.setColor(E),this.onColorChange(this.currentColor,this.currentOpacity))},"all");this.recentSectionRefresh=p.refresh;const d=document.createElement("div");d.className="color-picker-format-section embedded";const g=document.createElement("select");g.className="color-picker-format-select",this.select=g;const C=document.createElement("option");C.value="hex",C.textContent="HEX";const m=document.createElement("option");m.value="rgb",m.textContent="RGB";const u=document.createElement("option");u.value="hsl",u.textContent="HSL",g.appendChild(C),g.appendChild(m),g.appendChild(u);const v=document.createElement("input");v.type="text",v.className="color-picker-color-input",this.input=v;const f=document.createElement("div");f.className="color-picker-input-container";const y=document.createElement("button");return y.className="color-picker-copy-inside",y.textContent="Copy",f.appendChild(v),f.appendChild(y),d.appendChild(g),d.appendChild(f),t.appendChild(e),t.appendChild(s),t.appendChild(d),t.appendChild(p.container),this.bind(e,a,r,v,g,y,n),t}bind(t,e,i,s,n,o,a){const l=d=>{const g=t.getBoundingClientRect(),C=Math.max(0,Math.min(1,(d.clientX-g.left)/g.width)),m=Math.max(0,Math.min(1,(d.clientY-g.top)/g.height));this.colorMarker.style.left=`${C*100}%`,this.colorMarker.style.top=`${m*100}%`;const v=this.parsePercentage(this.hueMarker.style.left||"0%")*360,f=j(v,C,1-m);this.currentColor=f,this.syncInput(),this.updateOpacityBg(),this.queueChange()},r=d=>{const g=e.getBoundingClientRect(),C=Math.max(0,Math.min(1,(d.clientX-g.left)/g.width));this.hueMarker.style.left=`${C*100}%`;const m=C*360,u=this.parsePercentage(this.colorMarker.style.left||"0%"),v=this.parsePercentage(this.colorMarker.style.top||"0%"),f=j(m,u,1-v);this.currentColor=f,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
|
|
26
|
-
linear-gradient(to right, #fff, hsl(${
|
|
25
|
+
`;class mt{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=bt,s.addEventListener("click",()=>this.close(!0)),e.appendChild(i),e.appendChild(s),rt(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 c=document.createElement("div");c.className="color-picker-hue",this.hueSlider=c;const p=document.createElement("div");p.className="color-picker-hue-marker",this.hueMarker=p,c.appendChild(p);const d=document.createElement("div");d.className="color-picker-opacity",this.opacitySlider=d;const g=document.createElement("div");g.className="color-picker-opacity-marker",this.opacityMarker=g,d.appendChild(g),r.appendChild(c),r.appendChild(d),a.appendChild(l),a.appendChild(r);const C=ct(b=>{var x;this.setColor(b),(x=this.onChange)==null||x.call(this,b,this.currentOpacity)},this.recentScope);this.recentSectionRefresh=C.refresh;const m=document.createElement("div");m.className="color-picker-format-section";const u=document.createElement("select");u.className="color-picker-format-select",this.select=u;const f=document.createElement("option");f.value="hex",f.textContent="HEX";const v=document.createElement("option");v.value="rgb",v.textContent="RGB";const y=document.createElement("option");y.value="hsl",y.textContent="HSL",u.appendChild(f),u.appendChild(v),u.appendChild(y);const E=document.createElement("input");E.type="text",E.className="color-picker-color-input",E.value=this.currentColor,this.input=E;const L=document.createElement("div");L.className="color-picker-input-container";const I=document.createElement("button");return I.className="color-picker-copy-inside",I.textContent="Copy",L.appendChild(E),L.appendChild(I),m.appendChild(u),m.appendChild(L),t.appendChild(e),t.appendChild(n),t.appendChild(a),t.appendChild(C.container),t.appendChild(m),t.addEventListener("click",b=>b.stopPropagation()),this.bind(n,c,d,E,u,I,l),t}createBackdrop(){const t=document.createElement("div");return t.className="color-picker-backdrop",t.style.display="none",t.style.pointerEvents="none",t}bind(t,e,i,s,n,o,a){const l=p=>{var v;const d=t.getBoundingClientRect(),g=Math.max(0,Math.min(1,(p.clientX-d.left)/d.width)),C=Math.max(0,Math.min(1,(p.clientY-d.top)/d.height));this.colorMarker.style.left=`${g*100}%`,this.colorMarker.style.top=`${C*100}%`;const u=this.parsePercentage(this.hueMarker.style.left||"0%")*360,f=j(u,g,1-C);this.currentColor=f,this.syncInput(),this.updateOpacityBg(),(v=this.onChange)==null||v.call(this,f,this.currentOpacity)},r=p=>{var v;const d=e.getBoundingClientRect();let g=Math.max(0,Math.min(1,(p.clientX-d.left)/d.width));this.hueMarker.style.left=`${g*100}%`;const C=g*360,m=this.parsePercentage(this.colorMarker.style.left||"0%"),u=this.parsePercentage(this.colorMarker.style.top||"0%"),f=j(C,m,1-u);this.currentColor=f,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${C}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(v=this.onChange)==null||v.call(this,f,this.currentOpacity)},c=p=>{var C;const d=i.getBoundingClientRect(),g=Math.max(0,Math.min(1,(p.clientX-d.left)/d.width));this.opacityMarker.style.left=`${g*100}%`,this.currentOpacity=Math.round(g*100),(C=this.onChange)==null||C.call(this,this.currentColor,this.currentOpacity)};t.addEventListener("mousedown",p=>{p.preventDefault(),l(p);const d=C=>l(C),g=()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",g)}),e.addEventListener("mousedown",p=>{p.preventDefault(),r(p);const d=C=>r(C),g=()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",g)}),i.addEventListener("mousedown",p=>{p.preventDefault(),c(p);const d=C=>c(C),g=()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",g)}),n.addEventListener("change",()=>this.syncInput()),s.addEventListener("input",()=>this.applyFromInput()),s.addEventListener("blur",()=>this.syncInput()),s.addEventListener("keydown",p=>{p.key==="Enter"&&(p.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 p;if(!("EyeDropper"in window)){alert("EyeDropper API is not supported in this browser.");return}try{const d=new window.EyeDropper,{sRGBHex:g}=await d.open();this.setColor(g),(p=this.onChange)==null||p.call(this,g,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}=W(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}=W(this.currentColor);if(t==="hex")this.input.value=this.currentColor;else if(t==="rgb"){const{r:n,g:o,b:a}=O(this.currentColor);this.input.value=`rgb(${n}, ${o}, ${a})`}else{const{hue:n,sat:o,lightness:a}=ft(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=j(n,r,l)}}}e&&this.setColor(e)}updateOpacityBg(){const{r:t,g:e,b:i}=O(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${t}, ${e}, ${i})`)}open(t,e,i){var y;this.currentColor=t,this.currentOpacity=i??100,this.syncInput();const{h:s,s:n,v:o}=W(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}%`,(y=this.recentSectionRefresh)==null||y.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(),c=window.innerWidth,p=window.innerHeight,d=16;let g=r.right+8,C=r.top;const m=c-r.right,u=r.left;m>=a+d?g=r.right+8:u>=a+d?g=r.left-a-8:g=Math.max(d,(c-a)/2);const f=p-r.bottom,v=r.top;f>=l+d?C=r.bottom+8:v>=l+d?C=r.top-l-8:f>v?(C=r.bottom+8,C+l>p-d&&(C=p-l-d)):(C=r.top-l-8,C<d&&(C=d)),this.element.style.left=`${g}px`,this.element.style.top=`${C}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"&&(z.addColor(this.currentColor,this.recentScope),(e=this.recentSectionRefresh)==null||e.call(this)))}getElement(){return this.element}}class Ut{constructor(t){this.isDragging=!1,this.currentColor="#FFFFFF",this.currentColor=this.sanitizeColor(t.initialColor),this.currentOpacity=this.clampOpacity(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}sanitizeColor(t){const e=this.currentColor||"#FFFFFF";return R(t)??e}clampOpacity(t){return Number.isFinite(t)?Math.min(100,Math.max(0,Math.round(t))):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 c=document.createElement("div");c.className="color-picker-opacity-marker",this.opacityMarker=c,r.appendChild(c),o.appendChild(a),o.appendChild(r),s.appendChild(n),s.appendChild(o);const p=ct(E=>{const L=P(E);L&&L.type!=="solid"?this.onColorChange(E,this.currentOpacity):(this.setColor(E),this.onColorChange(this.currentColor,this.currentOpacity))},"all");this.recentSectionRefresh=p.refresh;const d=document.createElement("div");d.className="color-picker-format-section embedded";const g=document.createElement("select");g.className="color-picker-format-select",this.select=g;const C=document.createElement("option");C.value="hex",C.textContent="HEX";const m=document.createElement("option");m.value="rgb",m.textContent="RGB";const u=document.createElement("option");u.value="hsl",u.textContent="HSL",g.appendChild(C),g.appendChild(m),g.appendChild(u);const f=document.createElement("input");f.type="text",f.className="color-picker-color-input",this.input=f;const v=document.createElement("div");v.className="color-picker-input-container";const y=document.createElement("button");return y.className="color-picker-copy-inside",y.textContent="Copy",v.appendChild(f),v.appendChild(y),d.appendChild(g),d.appendChild(v),t.appendChild(e),t.appendChild(s),t.appendChild(d),t.appendChild(p.container),this.bind(e,a,r,f,g,y,n),t}bind(t,e,i,s,n,o,a){const l=(d,g)=>{const C=g||t.getBoundingClientRect(),m=Math.max(0,Math.min(1,(d.clientX-C.left)/C.width)),u=Math.max(0,Math.min(1,(d.clientY-C.top)/C.height));this.colorMarker.style.left=`${m*100}%`,this.colorMarker.style.top=`${u*100}%`;const v=this.parsePercentage(this.hueMarker.style.left||"0%")*360,y=j(v,m,1-u);this.currentColor=y,this.syncInput(),this.updateOpacityBg(),this.queueChange()},r=(d,g)=>{const C=g||e.getBoundingClientRect(),m=Math.max(0,Math.min(1,(d.clientX-C.left)/C.width));this.hueMarker.style.left=`${m*100}%`;const u=m*360,f=this.parsePercentage(this.colorMarker.style.left||"0%"),v=this.parsePercentage(this.colorMarker.style.top||"0%"),y=j(u,f,1-v);this.currentColor=y,this.colorArea.style.background=`linear-gradient(to top, #000, transparent),
|
|
26
|
+
linear-gradient(to right, #fff, hsl(${u}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),this.queueChange()},c=(d,g)=>{const C=g||i.getBoundingClientRect(),m=Math.max(0,Math.min(1,(d.clientX-C.left)/C.width));this.opacityMarker.style.left=`${m*100}%`,this.currentOpacity=this.clampOpacity(m*100),this.queueChange()},p=(d,g,C)=>{d.preventDefault(),this.isDragging=!0,this.cachedRect=C.getBoundingClientRect(),g(d,this.cachedRect);let m=null,u;const f=()=>{this.dragRafId===void 0&&(this.dragRafId=window.requestAnimationFrame(()=>{this.dragRafId=void 0,m&&this.cachedRect&&g(m,this.cachedRect)}))},v=()=>{this.isDragging&&(this.isDragging=!1,this.dragRafId!==void 0&&(cancelAnimationFrame(this.dragRafId),this.dragRafId=void 0),this.cachedRect=void 0,m=null,this.flushChange(),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",v),window.removeEventListener("blur",v),this.applyPendingExternal())};u=y=>{if(!y.buttons){v();return}m=y,f()},document.addEventListener("mousemove",u),document.addEventListener("mouseup",v),window.addEventListener("blur",v)};t.addEventListener("mousedown",d=>{p(d,l,t)}),e.addEventListener("mousedown",d=>{p(d,r,e)}),i.addEventListener("mousedown",d=>{p(d,c,i)}),n.addEventListener("change",()=>{this.syncInput()}),s.addEventListener("input",()=>{this.applyFromInput()}),s.addEventListener("blur",()=>{this.syncInput()}),s.addEventListener("keydown",d=>{d.key==="Enter"&&(d.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 d=new window.EyeDropper,{sRGBHex:g}=await d.open();this.setColor(g),this.onColorChange(this.currentColor,this.currentOpacity)}catch{}})}setColor(t){const e=this.sanitizeColor(t);this.currentColor=e;const{h:i,s,v:n}=W(e),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),
|
|
27
27
|
linear-gradient(to right, #fff, hsl(${o}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg()}syncInput(){const t=this.select.value,{h:e,s:i,v:s}=W(this.currentColor);if(t==="hex")this.input.value=this.currentColor;else if(t==="rgb"){const{r:n,g:o,b:a}=O(this.currentColor);this.input.value=`rgb(${n}, ${o}, ${a})`}else{const{hue:n,sat:o,lightness:a}=ft(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=j(n,r,l)}}}e&&(this.setColor(e),this.onColorChange(this.currentColor,this.currentOpacity))}updateOpacityBg(){const{r:t,g:e,b:i}=O(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 l;const i=this.sanitizeColor(t);this.currentColor=i,this.currentOpacity=this.clampOpacity(e);const{h:s,s:n,v:o}=W(i),a=s>=360?s%360:s;this.hueMarker.style.left=`${a/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),
|
|
28
|
-
linear-gradient(to right, #fff, hsl(${a}, 100%, 50%))`,this.opacityMarker.style.left=`${this.currentOpacity}%`,this.updateOpacityBg(),this.syncInput(),(l=this.recentSectionRefresh)==null||l.call(this)}commitRecentColor(){var t;this.recentScope==="solid"&&(z.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 T=class T extends w{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.changeDebounceTimeout=null,this.solidPicker=null,this.pendingSolidColor=null,this.variant="default",this.globalLayoutMode="list",this.globalSearchQuery="",this.currentMode="custom",this.linkedGlobalVariable=null,this.unlinkButton=null,this.onBackgroundClick=i=>{var d;if(!this.popoverEl||!this.isPopoverOpen)return;const s=i.target,n=this.popoverEl.contains(s),o=(d=this.element)==null?void 0:d.contains(s),a=document.querySelectorAll(".custom-color-picker"),l=Array.from(a).some(g=>g.contains(s)),r=s.closest(".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"),c=s.classList.contains("color-picker-backdrop"),p=s.classList.contains("gradient-popover-backdrop");!n&&!o&&!l&&!r&&!c&&!p&&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.variant=t.variant??"default",this.originalDefault=t.default,this.value=this.defaultValue(),this.setLinkedGlobalVariableFrom(this.originalDefault??this.value)}resolveGlobalVarColor(t){if(t.startsWith("var(--")){const e=t.replace("var(--","").replace(")","");return(w.GlobalVariables||{})[e]||t}return t}setLinkedGlobalVariableFrom(t){var i,s;if(!t){this.linkedGlobalVariable=null;return}const e=typeof t=="string"?t:((s=(i=t.stops)==null?void 0:i[0])==null?void 0:s.color)??null;this.linkedGlobalVariable=e&&e.startsWith("var(--")?e:null}isBoundToGlobal(){return!!this.linkedGlobalVariable}clearGlobalBindingForCustomChange(){var t,e;this.isBoundToGlobal()&&((e=(t=this.value)==null?void 0:t.stops)!=null&&e.length&&(this.value.stops=this.value.stops.map(i=>({...i,color:this.resolveGlobalVarColor(i.color)}))),this.linkedGlobalVariable=null,this.updateUnlinkButtonVisibility())}breakGlobalBinding(){var t;!this.isBoundToGlobal()||!this.value||((t=this.value.stops)!=null&&t.length&&(this.value.stops=this.value.stops.map(e=>({...e,color:this.resolveGlobalVarColor(e.color)}))),this.linkedGlobalVariable=null,this.updateUI(),this.triggerChange(),this.isPopoverOpen&&this.refreshPopoverContent())}defaultValue(){const t=this.originalDefault;if(typeof t=="string"){if(t.startsWith("var(--"))return D({type:"solid",angle:0,stops:[{color:t,position:0,opacity:100}]});const i=P(t);if(i)return D(i)}return D(t&&typeof t=="object"?t:{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]})}setValue(t){let e=null;typeof t=="string"?t.startsWith("var(--")?e=D({type:"solid",angle:0,stops:[{color:t,position:0,opacity:100}]}):e=P(t):t&&typeof t=="object"&&(e=D(t)),e||(e=this.defaultValue()),this.value=e,this.setLinkedGlobalVariableFrom(t??e),this.updateUI(),this.isPopoverOpen&&this.refreshPopoverContent(),this.triggerChange(),this.pendingSolidColor=null,this.updateUnlinkButtonVisibility()}updateUI(){if(this.previewEl&&this.value)if(this.value.type==="solid"){const t=this.value.stops[0],e=t.opacity??100,i=this.resolveGlobalVarColor(t.color);this.previewEl.style.background=at(i,e)}else{const t=this.resolveGradientGlobalVars(this.value);this.previewEl.style.background=I(t)}if(this.inputEl&&this.value&&!this.isEditing)if(this.isBoundToGlobal()&&this.linkedGlobalVariable){const e=this.linkedGlobalVariable.replace("var(--","").replace(")","").split("-").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" ");this.inputEl.value=`Linked: ${e}`}else this.inputEl.value=K(this.value);this.updateUnlinkButtonVisibility()}resolveGradientGlobalVars(t){return{...t,stops:t.stops.map(e=>({...e,color:this.resolveGlobalVarColor(e.color)}))}}updateUnlinkButtonVisibility(){if(!this.unlinkButton)return;const t=this.isBoundToGlobal();t?this.unlinkButton.classList.add("visible"):this.unlinkButton.classList.remove("visible"),this.previewEl&&(t?this.previewEl.classList.add("bound"):this.previewEl.classList.remove("bound"))}cssForTextValue(){return this.value?{background:I(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?I(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?K(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=I(this.value)}),this.inputEl.addEventListener("blur",()=>{this.isEditing=!1,this.value&&(this.inputEl.value=K(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=I(this.value)),this.inputEl.blur())}),e.appendChild(this.previewEl),this.unlinkButton=document.createElement("button"),this.unlinkButton.type="button",this.unlinkButton.className="gradient-unlink-button",this.unlinkButton.innerHTML=zt,this.unlinkButton.title="Break global color binding",this.unlinkButton.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.breakGlobalBinding()}),e.appendChild(this.unlinkButton),e.appendChild(this.inputEl),t.appendChild(e),this.createPopover(),this.element=t,this.updateUnlinkButtonVisibility(),t}createPopover(){if(this.popoverEl)return;this.backdropEl=document.createElement("div"),this.backdropEl.className="gradient-popover-backdrop",this.backdropEl.style.display="none",this.backdropEl.style.pointerEvents="none",this.popoverEl=document.createElement("div"),this.popoverEl.className="gradient-popover",this.popoverEl.style.display="none",this.popoverEl.addEventListener("click",l=>{l.stopPropagation()});const t=document.createElement("div");t.className="gradient-popover-header",t.style.cursor="move";let e=null;if(this.variant!=="global"){e=document.createElement("div"),e.className="color-setting-tabs header-tabs";const l=document.createElement("button");l.className="color-tab active",l.textContent="Custom";const r=document.createElement("button");r.className="color-tab",r.textContent="Global",e.appendChild(l),e.appendChild(r),t.appendChild(e)}else{const l=document.createElement("div");t.appendChild(l)}const i=document.createElement("button");i.type="button",i.className="gradient-popover-close",i.innerHTML=bt,i.addEventListener("click",()=>this.closePopover()),t.appendChild(i),rt(t,this.popoverEl,(l,r)=>{this.popoverPosition={left:l,top:r}});const s=document.createElement("div");s.className="gradient-editor";const n=document.createElement("div");n.className="type-tabs-wrapper";const o=this.createTypeTabs();n.appendChild(o),s.appendChild(n);const a=document.createElement("div");if(a.className="gradient-editor-content",this.updatePopoverContent(a),s.appendChild(a),this.variant!=="global"&&e){const l=e.children[0],r=e.children[1],c=p=>{this.currentMode=p,p==="custom"?(l.classList.add("active"),r.classList.remove("active"),n.style.display="block"):(r.classList.add("active"),l.classList.remove("active"),n.style.display="none"),this.updatePopoverContent(a)};l.addEventListener("click",()=>c("custom")),r.addEventListener("click",()=>c("global")),this.isBoundToGlobal()?(this.currentMode="global",c("global")):(this.currentMode="custom",c("custom"))}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.innerHTML=Ft,e.style.minWidth="32px",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.innerHTML=Rt,i.style.minWidth="32px",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,e=!1){var o;if(!this.value)return;const i=this.isBoundToGlobal(),s=this.linkedGlobalVariable;if(this.value.type=t,t!=="solid"&&(this.pendingSolidColor=null),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===1){const l=this.value.stops[0].color;if(l.startsWith("var(--")){const r=this.resolveGlobalVarColor(l),c=P(r);c&&c.type!=="solid"&&c.stops.length>=2?(this.value.stops=c.stops,this.value.angle=c.angle,this.value.type=c.type):(this.value.stops.push({color:"#786666",position:100,opacity:100}),this.value.angle=90)}else this.value.stops.push({color:"#786666",position:100,opacity:100}),this.value.angle=90}else if(t!=="solid"&&this.value.stops.length>=2)this.value.angle||(this.value.angle=90);else if(t==="solid"&&i&&s){const a=this.value.stops&&this.value.stops[0]?this.value.stops[0].opacity??100:100;this.value.stops=[{color:s,position:0,opacity:a}],this.value.angle=0}if(this.popoverEl){const a=this.popoverEl.querySelectorAll(".gradient-type-tab");a.forEach(c=>c.classList.remove("active"));const l=a[0],r=a[1];t==="solid"?l==null||l.classList.add("active"):r==null||r.classList.add("active")}const n=(o=this.popoverEl)==null?void 0:o.querySelector(".gradient-editor-content");n&&this.updatePopoverContent(n),this.updateUI(),e&&this.triggerChange()}updatePopoverContent(t){if(t.innerHTML="",!!this.value){if(this.variant!=="global"&&this.currentMode==="global"){this.renderGlobalColors(t);return}this.value.type==="solid"?this.renderSolid(t):this.renderGradient(t)}}renderGlobalColors(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=p=>{p.innerHTML="";let d={};try{d=w.GlobalVariables||{}}catch(u){console.warn("Could not access Setting.GlobalVariables",u)}if(!d||Object.keys(d).length===0){const u=document.createElement("div");u.textContent="No global colors defined",u.style.fontSize="12px",u.style.color="#666",u.style.padding="8px",p.appendChild(u);return}const g=w.GlobalVariableGroups||[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}],C=this.globalSearchQuery.toLowerCase();let m;this.globalLayoutMode==="list"?(m=document.createElement("div"),m.className="global-colors-list"):(m=document.createElement("div"),m.className="global-colors-grid"),p.appendChild(m),g.forEach(u=>{const v=Object.entries(d).filter(([f])=>!u.keys.includes(f)&&u.title!=="Global Colors"?!1:u.keys.includes(f)&&f.toLowerCase().includes(C));v.length!==0&&v.forEach(([f,y])=>{if(this.globalLayoutMode==="list"){const E=document.createElement("div");E.className="global-color-row";const L=document.createElement("div");L.className="global-color-circle";const N=this.resolveGlobalVarColor(y);L.style.background=N,(this.linkedGlobalVariable===`var(--${f})`||e.color===`var(--${f})`)&&L.classList.add("selected");const x=document.createElement("span");x.className="global-color-label",x.textContent=f.split("-").map(S=>S.charAt(0).toUpperCase()+S.slice(1)).join(" "),E.appendChild(L),E.appendChild(x),E.addEventListener("click",S=>{S.preventDefault();const G=`var(--${f})`;this.setValue(G),this.pendingSolidColor=G,i(p)}),m.appendChild(E)}else{const E=document.createElement("div");E.className="global-color-circle";const L=this.resolveGlobalVarColor(y);E.style.background=L,E.title=f.split("-").map(b=>b.charAt(0).toUpperCase()+b.slice(1)).join(" "),(this.linkedGlobalVariable===`var(--${f})`||e.color===`var(--${f})`)&&E.classList.add("selected"),E.addEventListener("click",b=>{b.preventDefault();const x=`var(--${f})`;this.setValue(x),this.pendingSolidColor=x,i(p)}),m.appendChild(E)}})})},s=document.createElement("div");s.className="global-controls-row";const n=document.createElement("div");n.className="global-search-container";const o=document.createElement("span");o.className="global-search-icon",o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>';const a=document.createElement("input");a.type="text",a.className="global-search-input",a.placeholder="Search",a.value=this.globalSearchQuery;const l=document.createElement("div");a.addEventListener("input",p=>{this.globalSearchQuery=p.target.value,i(l)}),n.appendChild(o),n.appendChild(a);const r=document.createElement("button");r.className="global-layout-toggle",r.type="button";const c=()=>{r.innerHTML=this.globalLayoutMode==="list"?'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>':'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="8" y1="6" x2="21" y2="6"></line><line x1="8" y1="12" x2="21" y2="12"></line><line x1="8" y1="18" x2="21" y2="18"></line><line x1="3" y1="6" x2="3.01" y2="6"></line><line x1="3" y1="12" x2="3.01" y2="12"></line><line x1="3" y1="18" x2="3.01" y2="18"></line></svg>'};c(),r.addEventListener("click",()=>{this.globalLayoutMode=this.globalLayoutMode==="list"?"grid":"list",c(),i(l)}),s.appendChild(n),s.appendChild(r),t.appendChild(s),t.appendChild(l),i(l)}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 Ut({initialColor:e.color.startsWith("var(--")?this.resolveGlobalVarColor(e.color):e.color,initialOpacity:e.opacity??100,onColorChange:(s,n)=>{if(this.clearGlobalBindingForCustomChange(),this.value){const o=P(s);if(o&&o.type!=="solid"){this.value=o,this.switchType(o.type,!0);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;let e=null;{const c=document.createElement("div");c.className="gradient-subtype-inline";const p=document.createElement("select");p.className="gradient-subtype-select";const d=document.createElement("option");d.value="linear",d.textContent="Linear";const g=document.createElement("option");g.value="radial",g.textContent="Radial",p.appendChild(d),p.appendChild(g),p.value=this.value.type==="radial"?"radial":"linear",e=document.createElement("input"),e.type="text",e.inputMode="numeric",e.className="gradient-degree-input",e.value=`${this.value.angle??90}°`,e.style.width="75px",e.style.textAlign="center",(!this.value.angle||this.value.stops.length<2)&&(this.value.angle=90,e.value="90°");const C=document.createElement("button");C.type="button",C.className="gradient-flip-btn",C.innerHTML=Dt,p.addEventListener("change",()=>{this.clearGlobalBindingForCustomChange(),this.switchType(p.value==="radial"?"radial":"linear",!0),e&&this.updateDegreeVisibility(e)}),e.addEventListener("focus",m=>{const u=m.target;u.value=u.value.replace(/[^0-9-]/g,""),setTimeout(()=>u.select(),0)}),e.addEventListener("input",m=>{this.clearGlobalBindingForCustomChange();const u=parseInt(m.target.value);!Number.isNaN(u)&&this.value&&(this.value.angle=Math.max(0,Math.min(360,u)),this.debouncedPreviewUpdate())}),e.addEventListener("blur",m=>{var f;this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const u=m.target;let v=parseInt(u.value);Number.isNaN(v)&&(v=((f=this.value)==null?void 0:f.angle)??0),v=Math.max(0,Math.min(360,v)),this.value&&(this.value.angle=v),u.value=`${v}°`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),C.addEventListener("click",()=>{this.clearGlobalBindingForCustomChange(),!(!this.value||!this.value.stops)&&(this.value.stops.forEach(m=>{m.position=100-m.position}),this.value.stops.sort((m,u)=>m.position-u.position),this.updateGradientPreview(i),this.createHandles(s,i),this.updateStopsList(l),this.updateUI(),this.triggerChange())}),c.appendChild(p),c.appendChild(e),c.appendChild(C),t.appendChild(c),this.updateDegreeVisibility(e)}const i=document.createElement("div");i.className="gradient-preview",this.updateGradientPreview(i);const s=document.createElement("div");s.className="gradient-handles",i.appendChild(s),t.appendChild(i),this.createHandles(s,i);const n=document.createElement("div");n.className="gradient-stops-header";const o=document.createElement("span");o.textContent="Stops";const a=document.createElement("button");a.type="button",a.className="gradient-add-stop",a.textContent="+",n.appendChild(o),n.appendChild(a);const l=document.createElement("div");l.className="gradient-stops",t.appendChild(n),t.appendChild(l),this.updateStopsList(l);const r=ct(c=>{const p=P(c);p&&(this.clearGlobalBindingForCustomChange(),this.value=p,this.switchType(p.type,!0),this.updateUI(),this.triggerChange())},"all");this.recentGradientRefresh=r.refresh,t.appendChild(r.container),a.addEventListener("click",()=>{var c;this.clearGlobalBindingForCustomChange(),this.addStop(),this.updateStopsList(l),this.updateGradientPreview(i),this.createHandles(s,i),this.updateUI(),((c=document.activeElement)==null?void 0:c.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()})}updateDegreeVisibility(t){var e;t&&(((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"));if(e&&this.value)if(this.value.type==="solid")e.style.background=I(this.value);else{const s=this.value.stops.map(n=>`${at(n.color,n.opacity??100)} ${n.position}%`).join(", ");e.style.background=`linear-gradient(90deg, ${s})`}}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";const a=this.resolveGlobalVarColor(i.color);o.style.backgroundColor=a,n.appendChild(o);const l=new mt((u,v)=>{this.clearGlobalBindingForCustomChange(),this.value&&this.value.stops[s]&&(this.value.stops[s].color=u,v!==void 0&&(this.value.stops[s].opacity=v),o.style.backgroundColor=u,this.updateGradientPreview(),this.updateStopsList(),this.updateUI(),this.triggerChange())},"solid");let r=!1,c=!1,p=0,d=0;const g=u=>{r=!0,c=!1,p=u.clientX,d=this.value.stops[s].position,n.classList.add("selected"),document.addEventListener("mousemove",C),document.addEventListener("mouseup",m),u.preventDefault(),u.stopPropagation()},C=u=>{if(!r||!this.value)return;const v=u.clientX-p;if(Math.abs(v)>3&&(c=!0),c){this.clearGlobalBindingForCustomChange();const f=e.getBoundingClientRect();let y=d+v/f.width*100;y=Math.max(0,Math.min(100,y)),this.value.stops[s].position=Math.round(y),n.style.left=`${y}%`,this.updateGradientPreview()}},m=u=>{var v;if(r)if(r=!1,n.classList.remove("selected"),document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",m),c)this.value&&(this.value.stops.sort((f,y)=>f.position-y.position),this.createHandles(t,e),this.updateStopsList()),this.updateUI(),this.triggerChange();else{u.stopPropagation();const f=(v=this.value)==null?void 0:v.stops[s];f&&setTimeout(()=>{const y=this.resolveGlobalVarColor(f.color);l.open(y,o,f.opacity??100)},0)}};n.addEventListener("mousedown",g),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 L,N;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 c=this.resolveGlobalVarColor(s.color),p=document.createElement("div");p.className="gstop-color-preview",p.style.backgroundColor=c;const d=document.createElement("input");d.type="text",d.className="gstop-color-input",d.value=c.replace("#","").toUpperCase();const g=document.createElement("button");g.type="button",g.className="gstop-color-copy",g.textContent="Copy",r.appendChild(p),r.appendChild(d),r.appendChild(g);const C=document.createElement("button");C.type="button",C.className="gstop-del",C.innerHTML=Gt,C.disabled=(((N=(L=this.value)==null?void 0:L.stops)==null?void 0:N.length)||0)<=2,o.appendChild(a),o.appendChild(r),o.appendChild(C),e.appendChild(o);const m=document.createElement("span");m.className="gstop-opacity-label",m.textContent="Opacity";const u=document.createElement("div");u.className="gstop-opacity-group";const v=document.createElement("input");v.type="range",v.className="gstop-opacity-slider",v.min="0",v.max="100",v.value=String(s.opacity??100);const f=O(c);v.style.setProperty("--slider-color",`rgb(${f.r}, ${f.g}, ${f.b})`);const y=document.createElement("span");y.className="gstop-opacity-value",y.textContent=`${s.opacity??100}%`,u.appendChild(v),u.appendChild(y);const E=new mt((b,x)=>{this.clearGlobalBindingForCustomChange(),d.value=b.replace("#","").toUpperCase(),p.style.backgroundColor=b,this.value.stops[n].color=b,x!==void 0&&(this.value.stops[n].opacity=x,v.value=String(x),y.textContent=`${x}%`);const S=O(b);v.style.setProperty("--slider-color",`rgb(${S.r}, ${S.g}, ${S.b})`),this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()},"solid");d.addEventListener("click",b=>{b.preventDefault(),b.stopPropagation();const x=this.resolveGlobalVarColor(s.color);E.open(x,d,s.opacity??100)}),d.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const b=d.value.trim(),x=b.startsWith("#")?b:`#${b}`;if(/^#[0-9A-Fa-f]{6}$/.test(x)){this.value.stops[n].color=x,p.style.backgroundColor=x;const S=O(x);v.style.setProperty("--slider-color",`rgb(${S.r}, ${S.g}, ${S.b})`),this.debouncedPreviewUpdate()}}),d.addEventListener("blur",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),g.addEventListener("click",async b=>{b.stopPropagation();try{await navigator.clipboard.writeText(`#${d.value}`)}catch{}}),l.addEventListener("focus",b=>{const x=b.target;x.value=x.value.replace("%",""),x.select()}),l.addEventListener("input",b=>{this.clearGlobalBindingForCustomChange();const x=b.target,S=parseInt(x.value.replace(/[^\d]/g,""),10);if(!Number.isNaN(S)){const G=Math.max(0,Math.min(100,S));this.value.stops[n].position=G,x.value=`${G}%`,this.debouncedPreviewUpdate()}}),l.addEventListener("blur",b=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const x=b.target,S=parseInt(x.value.replace(/[^\d]/g,""),10);if(Number.isNaN(S))x.value=`${this.value.stops[n].position}%`;else{const G=Math.max(0,Math.min(100,S));this.value.stops[n].position=G,x.value=`${G}%`}this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateUI(),this.triggerChange()}),C.addEventListener("click",()=>{var b;(this.value.stops.length||0)<=2||(this.clearGlobalBindingForCustomChange(),this.value.stops.splice(n,1),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateGradientPreview(),this.updateUI(),((b=document.activeElement)==null?void 0:b.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange())}),v.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const b=parseInt(v.value,10);this.value.stops[n].opacity=Math.max(0,Math.min(100,b)),y.textContent=`${this.value.stops[n].opacity}%`,this.debouncedPreviewUpdate()}),v.addEventListener("change",()=>{this.clearGlobalBindingForCustomChange(),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,c=t.left,p=e+n;r<p&&c>r+100&&(a=t.left-e-8);const d=s-t.bottom,g=t.top;g>=o+n?l=t.top-o-8:d>=o+n?l=t.bottom+8:g>d?(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 c=s-e.right,p=e.left,d=i+o;c<d&&p>c+100&&(l=e.left-i-8);const g=n-e.bottom,C=e.top;C>=a+o?r=e.top-a-8:g>=a+o?r=e.bottom+8:C>g?(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=I(this.value);z.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():z.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){let e=t.trim();e&&!e.startsWith("#")&&!e.startsWith("var(")&&!e.startsWith("rgb")&&!e.startsWith("hsl")&&!e.includes("gradient")&&/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$|^[0-9A-Fa-f]{8}$/.test(e)&&(e="#"+e,this.inputEl&&(this.inputEl.value=e));const i=P(e);i&&this.setValue(i)}getChangePayload(){var t;if(this.value)return this.isBoundToGlobal()?((t=this.value.stops)==null?void 0:t.some(i=>i.opacity!==void 0&&i.opacity!==100))?this.resolveGradientGlobalVars(this.value):this.linkedGlobalVariable||void 0:this.value}triggerChange(){const t=this.getChangePayload();t!==void 0&&(this.changeDebounceTimeout&&clearTimeout(this.changeDebounceTimeout),this.changeDebounceTimeout=setTimeout(()=>{var e,i;(e=this.onChange)==null||e.call(this,t),(i=this.detectChange)==null||i.call(this,t),this.changeDebounceTimeout=null},T.CHANGE_DEBOUNCE_DELAY))}getElement(){return this.element}getValue(){const t=this.getChangePayload();return t?typeof t=="string"?t:I(t):""}getCSSValue(){const t=this.getChangePayload();return t?typeof t=="string"?t:I(t):""}getCSSForText(){return this.value?this.cssForTextValue():{}}getRawValue(){return this.value}};T.openInstance=null,T.CHANGE_DEBOUNCE_DELAY=150;let U=T;function q(h,t){for(const e in h)if(Object.prototype.hasOwnProperty.call(h,e)){const i=h[e];t(e,i)}}const tt=class tt{constructor(t){this.elementRef=null,this.isHidden=!1,this.custom=!1,this.initialValues={},this.changeTimeout=null,this.isHandlingChange=!1,this.changeHandlers=new Set,this.blurTimeout=null,this.lastChangeTime=0,this.handleBlur=()=>{},this.pendingBlurHandler=null,this.originalDefaultValues={},this.nestingLevel=0,this.dataPropsPath="",this.hide=!1,this.id=t.id||vt(),this.title=t.title,this.settings=t.settings,this.isCollapsed=t.collapsed??!1,this.isMain=t.main??!1,this.custom=t.custom??!1,this.nestingLevel=0,this.includeGetJson=t.includeGetJson??!0,this.addItemCfg=t.addItem,this.deleteItemCfg=t.deleteItem,this.dataProps=t.dataProps,this.dataPropsPath=t.dataProps||"",this.hide=t.hide??!1,Object.assign(this,t.settings),this.initialValues=this.getValues(),this.originalDefaultValues=this.getDefaultValues(),this.propagateNestingLevel(),this.propagateDataPropsPath()}propagateNestingLevel(){const t=this.nestingLevel+1;q(this.settings,(e,i)=>{k(i)&&(i.nestingLevel=t,i.propagateNestingLevel())})}getNestingLevel(){return this.nestingLevel}setNestingLevel(t){this.nestingLevel=t,this.propagateNestingLevel(),this.elementRef&&this.updateNestingStyles()}setTitle(t){if(this.title=t,this.elementRef){const e=this.elementRef.querySelector(".setting-group-title h3");e&&(e.textContent=t)}}getDataPropsPath(){return this.dataPropsPath}setDataPropsPath(t){this.dataPropsPath=t,this.propagateDataPropsPath()}propagateDataPropsPath(){q(this.settings,(t,e)=>{const i=String(t),s=this.dataPropsPath?`${this.dataPropsPath}_${i}`:i;(k(e)||B(e)&&typeof e.setDataPropsPath=="function")&&e.setDataPropsPath(s)})}updateNestingStyles(){this.elementRef&&(Z(this.elementRef,this.nestingLevel),st(this.elementRef,this.nestingLevel))}forceChildUIRefresh(){Object.entries(this.settings).forEach(([t,e])=>{try{if(k(e)){const i=e.getValues();e.setValue(i)}else if(typeof e.setValue=="function"){const i=e.value;i!==void 0&&e.setValue(i)}}catch(i){console.warn(`Error refreshing UI for setting ${t}:`,i)}})}removeSetting(t){var s;const e=this.settings[t];if(!e)return;if(delete this.settings[t],this.elementRef){const n=this.elementRef.querySelector(".setting-group-content");if(n){const o=Array.from(n.querySelectorAll(".setting-group, .setting, [data-setting-id]"));for(const a of o){const l=a.id,r=a.getAttribute("data-setting-id");if(l&&"id"in e&&typeof e.id=="string"&&l.includes(e.id)){a.remove();break}if(r&&"id"in e&&typeof e.id=="string"&&r===e.id){a.remove();break}}}}typeof e.cleanup=="function"&&e.cleanup(),this.updateNestingStyles();const i=this.getValues();this.initialValues=i,(s=this.onChange)==null||s.call(this,i)}updateVisibility(){this.elementRef}updateSettings(t,e){var l;const i=(e==null?void 0:e.preserveValues)??!0,s=new Set(Object.keys(this.settings)),n=Object.keys(t),o={};i&&n.forEach(r=>{const c=this.settings[r];c&&(k(c)?o[r]=c.getValues():B(c)?o[r]=c.value:typeof c.getValues=="function"?o[r]=c.getValues():c.value!==void 0&&(o[r]=c.value))}),s.forEach(r=>{n.includes(r)||this.removeSetting(r)}),n.forEach(r=>{var d;const c=t[r],p=this.settings[r];if(p!==c&&(p&&this.removeSetting(r),this.addSetting(r,c),i&&r in o)){const g=o[r];try{k(c)?c.setValue(g):B(c)?(d=c.setValue)==null||d.call(c,g):c.setValue&&c.setValue(g)}catch(C){console.warn(`Could not preserve value for setting ${r}:`,C)}}}),this.settings=t,this.propagateNestingLevel(),this.propagateDataPropsPath();const a=this.getValues();this.initialValues=a,(l=this.onChange)==null||l.call(this,a)}clone(){const t={};q(this.settings,(s,n)=>{const o=String(s);typeof n.clone=="function"?t[o]=n.clone():(console.warn(`Setting with key '${o}' does not have a clone method. Copying reference.`),t[o]=n)});const e={title:this.title,settings:t,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,includeGetJson:this.includeGetJson,addItem:this.addItemCfg,deleteItem:this.deleteItemCfg,dataProps:this.dataProps,hide:this.hide},i=wt(e);return i.initialValues=this.getValues(),i}resetDefault(){const t=this.originalDefaultValues;this.setValue(t),this.onChange&&this.onChange(this.getValues())}setMobileValues(t){!t||typeof t!="object"||(Object.entries(t).forEach(([e,i])=>{const s=this.settings[e];s&&(k(s)||B(s))&&typeof s.setMobileValue=="function"&&s.setMobileValue(i)}),this.setValue(t),this.onChange&&this.onChange(this.getValues()))}getMobileValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(k(s))e[i]=s.getMobileValues();else{const n=s;e[i]=n.mobileValue!==void 0?n.mobileValue:n.value}}return e}else{const e=this.settings[t];if(!e)return;if(k(e))return e.getMobileValues();const i=e;return i.mobileValue!==void 0?i.mobileValue:i.value}}setOnChange(t){this.onChange=t;const e=()=>{this.isHandlingChange||(this.isHandlingChange=!0,this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=setTimeout(()=>{const i=this.getValues(),s=this.calculateChanges(this.initialValues,i);Object.keys(s).length>0&&(this.lastChangeTime=Date.now(),this.initialValues=i,t(i),this.updateVisibility()),this.isHandlingChange=!1},50))};return this.changeHandlers.clear(),q(this.settings,(i,s)=>{var n;if(k(s))s.setOnChange(()=>{const o=this.getValues();this.initialValues=o,t(o)}),this.changeHandlers.add(()=>t(this.getValues()));else if(B(s)){const o=()=>e();this.changeHandlers.add(o),s.setOnChange(o)}else{const o=()=>e();this.changeHandlers.add(o),(n=s.setOnChange)==null||n.call(s,o)}}),this}cleanup(){this.changeTimeout&&(clearTimeout(this.changeTimeout),this.changeTimeout=null),this.blurTimeout&&(clearTimeout(this.blurTimeout),this.blurTimeout=null),this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.changeHandlers.clear()}setValue(t){if(!t||typeof t!="object")return;Object.entries(t).forEach(([i,s])=>{let n=this.settings[i];if(!n&&this.addItemCfg&&i.startsWith(this.addItemCfg.keyPrefix)){const o=i.slice(this.addItemCfg.keyPrefix.length),a=Number(o);if(Number.isFinite(a)){const l=this.addItemCfg.createItem(a);nt(l)&&(this.addSetting(i,l),n=l)}}n&&(k(n)||B(n))&&typeof n.setValue=="function"&&n.setValue(s)}),setTimeout(()=>{this.forceChildUIRefresh()},0);const e=this.getValues();this.initialValues=e,this.onChange&&this.onChange(e)}wireChild(t){var i;const e=()=>{var n;const s=this.getValues();this.initialValues=s,(n=this.onChange)==null||n.call(this,s),this.updateVisibility()};k(t)?t.setOnChange(()=>e()):B(t)?t.setOnChange(()=>e()):(i=t.setOnChange)==null||i.call(t,()=>e())}addSetting(t,e){var s,n;if(this.settings[t]=e,this.wireChild(e),this.elementRef){const o=this.elementRef.querySelector(".setting-group-content");if(o){k(e)&&typeof e.setNestingLevel=="function"&&e.setNestingLevel(this.nestingLevel+1);const a=e.draw(),l=this.deleteItemCfg??this.addItemCfg;if(l){const p=l.keyPrefix??((s=this.addItemCfg)==null?void 0:s.keyPrefix);p&&t.startsWith(p)&&this.addDeleteButtonToElement(a,t)}const r=o.querySelector(".sg-add-button-bottom");r?o.insertBefore(a,r):o.appendChild(a),dt.trackElement(a),Z(a,this.nestingLevel+1),st(a,this.nestingLevel+1);const c=a.style.display;a.style.display="none",a.offsetHeight,a.style.display=c,this.updateNestingStyles()}}const i=this.getValues();this.initialValues=i,(n=this.onChange)==null||n.call(this,i)}addDeleteButtonToElement(t,e,i){let s=null;try{s=t.querySelector(":scope > .setting-group-title")}catch{s=null}if(!s){const r=Array.from(t.querySelectorAll(".setting-group-title"));for(const c of r)if(c.closest(".setting-group")===t){s=c;break}s||(s=r[0]??null)}if(!s)return;const n=s.querySelector(".actions-section");if(!n)return;const o=document.createElement("button");o.type="button",o.className="sg-delete-button",i?i.deleteItemCfg:this.deleteItemCfg??this.addItemCfg,o.title="Delete",o.style.cssText=`
|
|
28
|
+
linear-gradient(to right, #fff, hsl(${a}, 100%, 50%))`,this.opacityMarker.style.left=`${this.currentOpacity}%`,this.updateOpacityBg(),this.syncInput(),(l=this.recentSectionRefresh)==null||l.call(this)}commitRecentColor(){var t;this.recentScope==="solid"&&(z.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 T=class T extends w{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.changeDebounceTimeout=null,this.solidPicker=null,this.pendingSolidColor=null,this.variant="default",this.globalLayoutMode="list",this.globalSearchQuery="",this.currentMode="custom",this.linkedGlobalVariable=null,this.unlinkButton=null,this.onBackgroundClick=i=>{var d;if(!this.popoverEl||!this.isPopoverOpen)return;const s=i.target,n=this.popoverEl.contains(s),o=(d=this.element)==null?void 0:d.contains(s),a=document.querySelectorAll(".custom-color-picker"),l=Array.from(a).some(g=>g.contains(s)),r=s.closest(".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"),c=s.classList.contains("color-picker-backdrop"),p=s.classList.contains("gradient-popover-backdrop");!n&&!o&&!l&&!r&&!c&&!p&&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.variant=t.variant??"default",this.originalDefault=t.default,this.value=this.defaultValue(),this.setLinkedGlobalVariableFrom(this.originalDefault??this.value)}resolveGlobalVarColor(t){if(t.startsWith("var(--")){const e=t.replace("var(--","").replace(")","");return(w.GlobalVariables||{})[e]||t}return t}setLinkedGlobalVariableFrom(t){var i,s;if(!t){this.linkedGlobalVariable=null;return}const e=typeof t=="string"?t:((s=(i=t.stops)==null?void 0:i[0])==null?void 0:s.color)??null;this.linkedGlobalVariable=e&&e.startsWith("var(--")?e:null}isBoundToGlobal(){return!!this.linkedGlobalVariable}clearGlobalBindingForCustomChange(){var t,e;this.isBoundToGlobal()&&((e=(t=this.value)==null?void 0:t.stops)!=null&&e.length&&(this.value.stops=this.value.stops.map(i=>({...i,color:this.resolveGlobalVarColor(i.color)}))),this.linkedGlobalVariable=null,this.updateUnlinkButtonVisibility())}breakGlobalBinding(){var t;!this.isBoundToGlobal()||!this.value||((t=this.value.stops)!=null&&t.length&&(this.value.stops=this.value.stops.map(e=>({...e,color:this.resolveGlobalVarColor(e.color)}))),this.linkedGlobalVariable=null,this.updateUI(),this.triggerChange(),this.isPopoverOpen&&this.refreshPopoverContent())}defaultValue(){const t=this.originalDefault;if(typeof t=="string"){if(t.startsWith("var(--"))return D({type:"solid",angle:0,stops:[{color:t,position:0,opacity:100}]});const i=P(t);if(i)return D(i)}return D(t&&typeof t=="object"?t:{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]})}setValue(t){let e=null;typeof t=="string"?t.startsWith("var(--")?e=D({type:"solid",angle:0,stops:[{color:t,position:0,opacity:100}]}):e=P(t):t&&typeof t=="object"&&(e=D(t)),e||(e=this.defaultValue()),this.value=e,this.setLinkedGlobalVariableFrom(t??e),this.updateUI(),this.isPopoverOpen&&this.refreshPopoverContent(),this.triggerChange(),this.pendingSolidColor=null,this.updateUnlinkButtonVisibility()}updateUI(){if(this.previewEl&&this.value)if(this.value.type==="solid"){const t=this.value.stops[0],e=t.opacity??100,i=this.resolveGlobalVarColor(t.color);this.previewEl.style.background=at(i,e)}else{const t=this.resolveGradientGlobalVars(this.value);this.previewEl.style.background=N(t)}if(this.inputEl&&this.value&&!this.isEditing)if(this.isBoundToGlobal()&&this.linkedGlobalVariable){const e=this.linkedGlobalVariable.replace("var(--","").replace(")","").split("-").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" ");this.inputEl.value=`Linked: ${e}`}else this.inputEl.value=K(this.value);this.updateUnlinkButtonVisibility()}resolveGradientGlobalVars(t){return{...t,stops:t.stops.map(e=>({...e,color:this.resolveGlobalVarColor(e.color)}))}}updateUnlinkButtonVisibility(){if(!this.unlinkButton)return;const t=this.isBoundToGlobal();t?this.unlinkButton.classList.add("visible"):this.unlinkButton.classList.remove("visible"),this.previewEl&&(t?this.previewEl.classList.add("bound"):this.previewEl.classList.remove("bound"))}cssForTextValue(){return this.value?{background:N(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?N(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?K(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=N(this.value)}),this.inputEl.addEventListener("blur",()=>{this.isEditing=!1,this.value&&(this.inputEl.value=K(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=N(this.value)),this.inputEl.blur())}),e.appendChild(this.previewEl),this.unlinkButton=document.createElement("button"),this.unlinkButton.type="button",this.unlinkButton.className="gradient-unlink-button",this.unlinkButton.innerHTML=zt,this.unlinkButton.title="Break global color binding",this.unlinkButton.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.breakGlobalBinding()}),e.appendChild(this.unlinkButton),e.appendChild(this.inputEl),t.appendChild(e),this.createPopover(),this.element=t,this.updateUnlinkButtonVisibility(),t}createPopover(){if(this.popoverEl)return;this.backdropEl=document.createElement("div"),this.backdropEl.className="gradient-popover-backdrop",this.backdropEl.style.display="none",this.backdropEl.style.pointerEvents="none",this.popoverEl=document.createElement("div"),this.popoverEl.className="gradient-popover",this.popoverEl.style.display="none",this.popoverEl.addEventListener("click",l=>{l.stopPropagation()});const t=document.createElement("div");t.className="gradient-popover-header",t.style.cursor="move";let e=null;if(this.variant!=="global"){e=document.createElement("div"),e.className="color-setting-tabs header-tabs";const l=document.createElement("button");l.className="color-tab active",l.textContent="Custom";const r=document.createElement("button");r.className="color-tab",r.textContent="Global",e.appendChild(l),e.appendChild(r),t.appendChild(e)}else{const l=document.createElement("div");t.appendChild(l)}const i=document.createElement("button");i.type="button",i.className="gradient-popover-close",i.innerHTML=bt,i.addEventListener("click",()=>this.closePopover()),t.appendChild(i),rt(t,this.popoverEl,(l,r)=>{this.popoverPosition={left:l,top:r}});const s=document.createElement("div");s.className="gradient-editor";const n=document.createElement("div");n.className="type-tabs-wrapper";const o=this.createTypeTabs();n.appendChild(o),s.appendChild(n);const a=document.createElement("div");if(a.className="gradient-editor-content",this.updatePopoverContent(a),s.appendChild(a),this.variant!=="global"&&e){const l=e.children[0],r=e.children[1],c=p=>{this.currentMode=p,p==="custom"?(l.classList.add("active"),r.classList.remove("active"),n.style.display="block"):(r.classList.add("active"),l.classList.remove("active"),n.style.display="none"),this.updatePopoverContent(a)};l.addEventListener("click",()=>c("custom")),r.addEventListener("click",()=>c("global")),this.isBoundToGlobal()?(this.currentMode="global",c("global")):(this.currentMode="custom",c("custom"))}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.innerHTML=Ft,e.style.minWidth="32px",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.innerHTML=Rt,i.style.minWidth="32px",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,e=!1){var o;if(!this.value)return;const i=this.isBoundToGlobal(),s=this.linkedGlobalVariable;if(this.value.type=t,t!=="solid"&&(this.pendingSolidColor=null),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===1){const l=this.value.stops[0].color;if(l.startsWith("var(--")){const r=this.resolveGlobalVarColor(l),c=P(r);c&&c.type!=="solid"&&c.stops.length>=2?(this.value.stops=c.stops,this.value.angle=c.angle,this.value.type=c.type):(this.value.stops.push({color:"#786666",position:100,opacity:100}),this.value.angle=90)}else this.value.stops.push({color:"#786666",position:100,opacity:100}),this.value.angle=90}else if(t!=="solid"&&this.value.stops.length>=2)this.value.angle||(this.value.angle=90);else if(t==="solid"&&i&&s){const a=this.value.stops&&this.value.stops[0]?this.value.stops[0].opacity??100:100;this.value.stops=[{color:s,position:0,opacity:a}],this.value.angle=0}if(this.popoverEl){const a=this.popoverEl.querySelectorAll(".gradient-type-tab");a.forEach(c=>c.classList.remove("active"));const l=a[0],r=a[1];t==="solid"?l==null||l.classList.add("active"):r==null||r.classList.add("active")}const n=(o=this.popoverEl)==null?void 0:o.querySelector(".gradient-editor-content");n&&this.updatePopoverContent(n),this.updateUI(),e&&this.triggerChange()}updatePopoverContent(t){if(t.innerHTML="",!!this.value){if(this.variant!=="global"&&this.currentMode==="global"){this.renderGlobalColors(t);return}this.value.type==="solid"?this.renderSolid(t):this.renderGradient(t)}}renderGlobalColors(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=p=>{p.innerHTML="";let d={};try{d=w.GlobalVariables||{}}catch(u){console.warn("Could not access Setting.GlobalVariables",u)}if(!d||Object.keys(d).length===0){const u=document.createElement("div");u.textContent="No global colors defined",u.style.fontSize="12px",u.style.color="#666",u.style.padding="8px",p.appendChild(u);return}const g=w.GlobalVariableGroups||[{title:"Global Colors",keys:["primary","secondary","tertiary","accent"]},{title:"Text Color",keys:["text-dark","text-light"]}],C=this.globalSearchQuery.toLowerCase();let m;this.globalLayoutMode==="list"?(m=document.createElement("div"),m.className="global-colors-list"):(m=document.createElement("div"),m.className="global-colors-grid"),p.appendChild(m),g.forEach(u=>{const f=Object.entries(d).filter(([v])=>!u.keys.includes(v)&&u.title!=="Global Colors"?!1:u.keys.includes(v)&&v.toLowerCase().includes(C));f.length!==0&&f.forEach(([v,y])=>{if(this.globalLayoutMode==="list"){const E=document.createElement("div");E.className="global-color-row";const L=document.createElement("div");L.className="global-color-circle";const I=this.resolveGlobalVarColor(y);L.style.background=I,(this.linkedGlobalVariable===`var(--${v})`||e.color===`var(--${v})`)&&L.classList.add("selected");const x=document.createElement("span");x.className="global-color-label",x.textContent=v.split("-").map(S=>S.charAt(0).toUpperCase()+S.slice(1)).join(" "),E.appendChild(L),E.appendChild(x),E.addEventListener("click",S=>{S.preventDefault();const G=`var(--${v})`;this.setValue(G),this.pendingSolidColor=G,i(p)}),m.appendChild(E)}else{const E=document.createElement("div");E.className="global-color-circle";const L=this.resolveGlobalVarColor(y);E.style.background=L,E.title=v.split("-").map(b=>b.charAt(0).toUpperCase()+b.slice(1)).join(" "),(this.linkedGlobalVariable===`var(--${v})`||e.color===`var(--${v})`)&&E.classList.add("selected"),E.addEventListener("click",b=>{b.preventDefault();const x=`var(--${v})`;this.setValue(x),this.pendingSolidColor=x,i(p)}),m.appendChild(E)}})})},s=document.createElement("div");s.className="global-controls-row";const n=document.createElement("div");n.className="global-search-container";const o=document.createElement("span");o.className="global-search-icon",o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>';const a=document.createElement("input");a.type="text",a.className="global-search-input",a.placeholder="Search",a.value=this.globalSearchQuery;const l=document.createElement("div");a.addEventListener("input",p=>{this.globalSearchQuery=p.target.value,i(l)}),n.appendChild(o),n.appendChild(a);const r=document.createElement("button");r.className="global-layout-toggle",r.type="button";const c=()=>{r.innerHTML=this.globalLayoutMode==="list"?'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>':'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="8" y1="6" x2="21" y2="6"></line><line x1="8" y1="12" x2="21" y2="12"></line><line x1="8" y1="18" x2="21" y2="18"></line><line x1="3" y1="6" x2="3.01" y2="6"></line><line x1="3" y1="12" x2="3.01" y2="12"></line><line x1="3" y1="18" x2="3.01" y2="18"></line></svg>'};c(),r.addEventListener("click",()=>{this.globalLayoutMode=this.globalLayoutMode==="list"?"grid":"list",c(),i(l)}),s.appendChild(n),s.appendChild(r),t.appendChild(s),t.appendChild(l),i(l)}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 Ut({initialColor:e.color.startsWith("var(--")?this.resolveGlobalVarColor(e.color):e.color,initialOpacity:e.opacity??100,onColorChange:(s,n)=>{if(this.clearGlobalBindingForCustomChange(),this.value){const o=P(s);if(o&&o.type!=="solid"){this.value=o,this.switchType(o.type,!0);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;let e=null;{const c=document.createElement("div");c.className="gradient-subtype-inline";const p=document.createElement("select");p.className="gradient-subtype-select";const d=document.createElement("option");d.value="linear",d.textContent="Linear";const g=document.createElement("option");g.value="radial",g.textContent="Radial",p.appendChild(d),p.appendChild(g),p.value=this.value.type==="radial"?"radial":"linear",e=document.createElement("input"),e.type="text",e.inputMode="numeric",e.className="gradient-degree-input",e.value=`${this.value.angle??90}°`,e.style.width="75px",e.style.textAlign="center",(!this.value.angle||this.value.stops.length<2)&&(this.value.angle=90,e.value="90°");const C=document.createElement("button");C.type="button",C.className="gradient-flip-btn",C.innerHTML=Dt,p.addEventListener("change",()=>{this.clearGlobalBindingForCustomChange(),this.switchType(p.value==="radial"?"radial":"linear",!0),e&&this.updateDegreeVisibility(e)}),e.addEventListener("focus",m=>{const u=m.target;u.value=u.value.replace(/[^0-9-]/g,""),setTimeout(()=>u.select(),0)}),e.addEventListener("input",m=>{this.clearGlobalBindingForCustomChange();const u=parseInt(m.target.value);!Number.isNaN(u)&&this.value&&(this.value.angle=Math.max(0,Math.min(360,u)),this.debouncedPreviewUpdate())}),e.addEventListener("blur",m=>{var v;this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const u=m.target;let f=parseInt(u.value);Number.isNaN(f)&&(f=((v=this.value)==null?void 0:v.angle)??0),f=Math.max(0,Math.min(360,f)),this.value&&(this.value.angle=f),u.value=`${f}°`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),C.addEventListener("click",()=>{this.clearGlobalBindingForCustomChange(),!(!this.value||!this.value.stops)&&(this.value.stops.forEach(m=>{m.position=100-m.position}),this.value.stops.sort((m,u)=>m.position-u.position),this.updateGradientPreview(i),this.createHandles(s,i),this.updateStopsList(l),this.updateUI(),this.triggerChange())}),c.appendChild(p),c.appendChild(e),c.appendChild(C),t.appendChild(c),this.updateDegreeVisibility(e)}const i=document.createElement("div");i.className="gradient-preview",this.updateGradientPreview(i);const s=document.createElement("div");s.className="gradient-handles",i.appendChild(s),t.appendChild(i),this.createHandles(s,i);const n=document.createElement("div");n.className="gradient-stops-header";const o=document.createElement("span");o.textContent="Stops";const a=document.createElement("button");a.type="button",a.className="gradient-add-stop",a.textContent="+",n.appendChild(o),n.appendChild(a);const l=document.createElement("div");l.className="gradient-stops",t.appendChild(n),t.appendChild(l),this.updateStopsList(l);const r=ct(c=>{const p=P(c);p&&(this.clearGlobalBindingForCustomChange(),this.value=p,this.switchType(p.type,!0),this.updateUI(),this.triggerChange())},"all");this.recentGradientRefresh=r.refresh,t.appendChild(r.container),a.addEventListener("click",()=>{var c;this.clearGlobalBindingForCustomChange(),this.addStop(),this.updateStopsList(l),this.updateGradientPreview(i),this.createHandles(s,i),this.updateUI(),((c=document.activeElement)==null?void 0:c.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()})}updateDegreeVisibility(t){var e;t&&(((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"));if(e&&this.value)if(this.value.type==="solid")e.style.background=N(this.value);else{const s=this.value.stops.map(n=>`${at(n.color,n.opacity??100)} ${n.position}%`).join(", ");e.style.background=`linear-gradient(90deg, ${s})`}}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";const a=this.resolveGlobalVarColor(i.color);o.style.backgroundColor=a,n.appendChild(o);const l=new mt((u,f)=>{this.clearGlobalBindingForCustomChange(),this.value&&this.value.stops[s]&&(this.value.stops[s].color=u,f!==void 0&&(this.value.stops[s].opacity=f),o.style.backgroundColor=u,this.updateGradientPreview(),this.updateStopsList(),this.updateUI(),this.triggerChange())},"solid");let r=!1,c=!1,p=0,d=0;const g=u=>{r=!0,c=!1,p=u.clientX,d=this.value.stops[s].position,n.classList.add("selected"),document.addEventListener("mousemove",C),document.addEventListener("mouseup",m),u.preventDefault(),u.stopPropagation()},C=u=>{if(!r||!this.value)return;const f=u.clientX-p;if(Math.abs(f)>3&&(c=!0),c){this.clearGlobalBindingForCustomChange();const v=e.getBoundingClientRect();let y=d+f/v.width*100;y=Math.max(0,Math.min(100,y)),this.value.stops[s].position=Math.round(y),n.style.left=`${y}%`,this.updateGradientPreview()}},m=u=>{var f;if(r)if(r=!1,n.classList.remove("selected"),document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",m),c)this.value&&(this.value.stops.sort((v,y)=>v.position-y.position),this.createHandles(t,e),this.updateStopsList()),this.updateUI(),this.triggerChange();else{u.stopPropagation();const v=(f=this.value)==null?void 0:f.stops[s];v&&setTimeout(()=>{const y=this.resolveGlobalVarColor(v.color);l.open(y,o,v.opacity??100)},0)}};n.addEventListener("mousedown",g),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 L,I;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 c=this.resolveGlobalVarColor(s.color),p=document.createElement("div");p.className="gstop-color-preview",p.style.backgroundColor=c;const d=document.createElement("input");d.type="text",d.className="gstop-color-input",d.value=c.replace("#","").toUpperCase();const g=document.createElement("button");g.type="button",g.className="gstop-color-copy",g.textContent="Copy",r.appendChild(p),r.appendChild(d),r.appendChild(g);const C=document.createElement("button");C.type="button",C.className="gstop-del",C.innerHTML=Gt,C.disabled=(((I=(L=this.value)==null?void 0:L.stops)==null?void 0:I.length)||0)<=2,o.appendChild(a),o.appendChild(r),o.appendChild(C),e.appendChild(o);const m=document.createElement("span");m.className="gstop-opacity-label",m.textContent="Opacity";const u=document.createElement("div");u.className="gstop-opacity-group";const f=document.createElement("input");f.type="range",f.className="gstop-opacity-slider",f.min="0",f.max="100",f.value=String(s.opacity??100);const v=O(c);f.style.setProperty("--slider-color",`rgb(${v.r}, ${v.g}, ${v.b})`);const y=document.createElement("span");y.className="gstop-opacity-value",y.textContent=`${s.opacity??100}%`,u.appendChild(f),u.appendChild(y);const E=new mt((b,x)=>{this.clearGlobalBindingForCustomChange(),d.value=b.replace("#","").toUpperCase(),p.style.backgroundColor=b,this.value.stops[n].color=b,x!==void 0&&(this.value.stops[n].opacity=x,f.value=String(x),y.textContent=`${x}%`);const S=O(b);f.style.setProperty("--slider-color",`rgb(${S.r}, ${S.g}, ${S.b})`),this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()},"solid");d.addEventListener("click",b=>{b.preventDefault(),b.stopPropagation();const x=this.resolveGlobalVarColor(s.color);E.open(x,d,s.opacity??100)}),d.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const b=d.value.trim(),x=b.startsWith("#")?b:`#${b}`;if(/^#[0-9A-Fa-f]{6}$/.test(x)){this.value.stops[n].color=x,p.style.backgroundColor=x;const S=O(x);f.style.setProperty("--slider-color",`rgb(${S.r}, ${S.g}, ${S.b})`),this.debouncedPreviewUpdate()}}),d.addEventListener("blur",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),g.addEventListener("click",async b=>{b.stopPropagation();try{await navigator.clipboard.writeText(`#${d.value}`)}catch{}}),l.addEventListener("focus",b=>{const x=b.target;x.value=x.value.replace("%",""),x.select()}),l.addEventListener("input",b=>{this.clearGlobalBindingForCustomChange();const x=b.target,S=parseInt(x.value.replace(/[^\d]/g,""),10);if(!Number.isNaN(S)){const G=Math.max(0,Math.min(100,S));this.value.stops[n].position=G,x.value=`${G}%`,this.debouncedPreviewUpdate()}}),l.addEventListener("blur",b=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const x=b.target,S=parseInt(x.value.replace(/[^\d]/g,""),10);if(Number.isNaN(S))x.value=`${this.value.stops[n].position}%`;else{const G=Math.max(0,Math.min(100,S));this.value.stops[n].position=G,x.value=`${G}%`}this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateUI(),this.triggerChange()}),C.addEventListener("click",()=>{var b;(this.value.stops.length||0)<=2||(this.clearGlobalBindingForCustomChange(),this.value.stops.splice(n,1),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateGradientPreview(),this.updateUI(),((b=document.activeElement)==null?void 0:b.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange())}),f.addEventListener("input",()=>{this.clearGlobalBindingForCustomChange();const b=parseInt(f.value,10);this.value.stops[n].opacity=Math.max(0,Math.min(100,b)),y.textContent=`${this.value.stops[n].opacity}%`,this.debouncedPreviewUpdate()}),f.addEventListener("change",()=>{this.clearGlobalBindingForCustomChange(),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,c=t.left,p=e+n;r<p&&c>r+100&&(a=t.left-e-8);const d=s-t.bottom,g=t.top;g>=o+n?l=t.top-o-8:d>=o+n?l=t.bottom+8:g>d?(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 c=s-e.right,p=e.left,d=i+o;c<d&&p>c+100&&(l=e.left-i-8);const g=n-e.bottom,C=e.top;C>=a+o?r=e.top-a-8:g>=a+o?r=e.bottom+8:C>g?(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=N(this.value);z.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():z.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){let e=t.trim();e&&!e.startsWith("#")&&!e.startsWith("var(")&&!e.startsWith("rgb")&&!e.startsWith("hsl")&&!e.includes("gradient")&&/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$|^[0-9A-Fa-f]{8}$/.test(e)&&(e="#"+e,this.inputEl&&(this.inputEl.value=e));const i=P(e);i&&this.setValue(i)}getChangePayload(){var t;if(this.value)return this.isBoundToGlobal()?((t=this.value.stops)==null?void 0:t.some(i=>i.opacity!==void 0&&i.opacity!==100))?this.resolveGradientGlobalVars(this.value):this.linkedGlobalVariable||void 0:this.value}triggerChange(){const t=this.getChangePayload();t!==void 0&&(this.changeDebounceTimeout&&clearTimeout(this.changeDebounceTimeout),this.changeDebounceTimeout=setTimeout(()=>{var e,i;(e=this.onChange)==null||e.call(this,t),(i=this.detectChange)==null||i.call(this,t),this.changeDebounceTimeout=null},T.CHANGE_DEBOUNCE_DELAY))}getElement(){return this.element}getValue(){const t=this.getChangePayload();return t?typeof t=="string"?t:N(t):""}getCSSValue(){const t=this.getChangePayload();return t?typeof t=="string"?t:N(t):""}getCSSForText(){return this.value?this.cssForTextValue():{}}getRawValue(){return this.value}};T.openInstance=null,T.CHANGE_DEBOUNCE_DELAY=150;let U=T;function q(h,t){for(const e in h)if(Object.prototype.hasOwnProperty.call(h,e)){const i=h[e];t(e,i)}}const tt=class tt{constructor(t){this.elementRef=null,this.isHidden=!1,this.custom=!1,this.initialValues={},this.changeTimeout=null,this.isHandlingChange=!1,this.changeHandlers=new Set,this.blurTimeout=null,this.lastChangeTime=0,this.handleBlur=()=>{},this.pendingBlurHandler=null,this.originalDefaultValues={},this.nestingLevel=0,this.dataPropsPath="",this.hide=!1,this.id=t.id||vt(),this.title=t.title,this.settings=t.settings,this.isCollapsed=t.collapsed??!1,this.isMain=t.main??!1,this.custom=t.custom??!1,this.nestingLevel=0,this.includeGetJson=t.includeGetJson??!0,this.addItemCfg=t.addItem,this.deleteItemCfg=t.deleteItem,this.dataProps=t.dataProps,this.dataPropsPath=t.dataProps||"",this.hide=t.hide??!1,Object.assign(this,t.settings),this.initialValues=this.getValues(),this.originalDefaultValues=this.getDefaultValues(),this.propagateNestingLevel(),this.propagateDataPropsPath()}propagateNestingLevel(){const t=this.nestingLevel+1;q(this.settings,(e,i)=>{k(i)&&(i.nestingLevel=t,i.propagateNestingLevel())})}getNestingLevel(){return this.nestingLevel}setNestingLevel(t){this.nestingLevel=t,this.propagateNestingLevel(),this.elementRef&&this.updateNestingStyles()}setTitle(t){if(this.title=t,this.elementRef){const e=this.elementRef.querySelector(".setting-group-title h3");e&&(e.textContent=t)}}getDataPropsPath(){return this.dataPropsPath}setDataPropsPath(t){this.dataPropsPath=t,this.propagateDataPropsPath()}propagateDataPropsPath(){q(this.settings,(t,e)=>{const i=String(t),s=this.dataPropsPath?`${this.dataPropsPath}_${i}`:i;(k(e)||B(e)&&typeof e.setDataPropsPath=="function")&&e.setDataPropsPath(s)})}updateNestingStyles(){this.elementRef&&(Z(this.elementRef,this.nestingLevel),st(this.elementRef,this.nestingLevel))}forceChildUIRefresh(){Object.entries(this.settings).forEach(([t,e])=>{try{if(k(e)){const i=e.getValues();e.setValue(i)}else if(typeof e.setValue=="function"){const i=e.value;i!==void 0&&e.setValue(i)}}catch(i){console.warn(`Error refreshing UI for setting ${t}:`,i)}})}removeSetting(t){var s;const e=this.settings[t];if(!e)return;if(delete this.settings[t],this.elementRef){const n=this.elementRef.querySelector(".setting-group-content");if(n){const o=Array.from(n.querySelectorAll(".setting-group, .setting, [data-setting-id]"));for(const a of o){const l=a.id,r=a.getAttribute("data-setting-id");if(l&&"id"in e&&typeof e.id=="string"&&l.includes(e.id)){a.remove();break}if(r&&"id"in e&&typeof e.id=="string"&&r===e.id){a.remove();break}}}}typeof e.cleanup=="function"&&e.cleanup(),this.updateNestingStyles();const i=this.getValues();this.initialValues=i,(s=this.onChange)==null||s.call(this,i)}updateVisibility(){this.elementRef}updateSettings(t,e){var l;const i=(e==null?void 0:e.preserveValues)??!0,s=new Set(Object.keys(this.settings)),n=Object.keys(t),o={};i&&n.forEach(r=>{const c=this.settings[r];c&&(k(c)?o[r]=c.getValues():B(c)?o[r]=c.value:typeof c.getValues=="function"?o[r]=c.getValues():c.value!==void 0&&(o[r]=c.value))}),s.forEach(r=>{n.includes(r)||this.removeSetting(r)}),n.forEach(r=>{var d;const c=t[r],p=this.settings[r];if(p!==c&&(p&&this.removeSetting(r),this.addSetting(r,c),i&&r in o)){const g=o[r];try{k(c)?c.setValue(g):B(c)?(d=c.setValue)==null||d.call(c,g):c.setValue&&c.setValue(g)}catch(C){console.warn(`Could not preserve value for setting ${r}:`,C)}}}),this.settings=t,this.propagateNestingLevel(),this.propagateDataPropsPath();const a=this.getValues();this.initialValues=a,(l=this.onChange)==null||l.call(this,a)}clone(){const t={};q(this.settings,(s,n)=>{const o=String(s);typeof n.clone=="function"?t[o]=n.clone():(console.warn(`Setting with key '${o}' does not have a clone method. Copying reference.`),t[o]=n)});const e={title:this.title,settings:t,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,includeGetJson:this.includeGetJson,addItem:this.addItemCfg,deleteItem:this.deleteItemCfg,dataProps:this.dataProps,hide:this.hide},i=wt(e);return i.initialValues=this.getValues(),i}resetDefault(){const t=this.originalDefaultValues;this.setValue(t),this.onChange&&this.onChange(this.getValues())}setMobileValues(t){!t||typeof t!="object"||(Object.entries(t).forEach(([e,i])=>{const s=this.settings[e];s&&(k(s)||B(s))&&typeof s.setMobileValue=="function"&&s.setMobileValue(i)}),this.setValue(t),this.onChange&&this.onChange(this.getValues()))}getMobileValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(k(s))e[i]=s.getMobileValues();else{const n=s;e[i]=n.mobileValue!==void 0?n.mobileValue:n.value}}return e}else{const e=this.settings[t];if(!e)return;if(k(e))return e.getMobileValues();const i=e;return i.mobileValue!==void 0?i.mobileValue:i.value}}setOnChange(t){this.onChange=t;const e=()=>{this.isHandlingChange||(this.isHandlingChange=!0,this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=setTimeout(()=>{const i=this.getValues(),s=this.calculateChanges(this.initialValues,i);Object.keys(s).length>0&&(this.lastChangeTime=Date.now(),this.initialValues=i,t(i),this.updateVisibility()),this.isHandlingChange=!1},50))};return this.changeHandlers.clear(),q(this.settings,(i,s)=>{var n;if(k(s))s.setOnChange(()=>{const o=this.getValues();this.initialValues=o,t(o)}),this.changeHandlers.add(()=>t(this.getValues()));else if(B(s)){const o=()=>e();this.changeHandlers.add(o),s.setOnChange(o)}else{const o=()=>e();this.changeHandlers.add(o),(n=s.setOnChange)==null||n.call(s,o)}}),this}cleanup(){this.changeTimeout&&(clearTimeout(this.changeTimeout),this.changeTimeout=null),this.blurTimeout&&(clearTimeout(this.blurTimeout),this.blurTimeout=null),this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.changeHandlers.clear()}setValue(t){if(!t||typeof t!="object")return;Object.entries(t).forEach(([i,s])=>{let n=this.settings[i];if(!n&&this.addItemCfg&&i.startsWith(this.addItemCfg.keyPrefix)){const o=i.slice(this.addItemCfg.keyPrefix.length),a=Number(o);if(Number.isFinite(a)){const l=this.addItemCfg.createItem(a);nt(l)&&(this.addSetting(i,l),n=l)}}n&&(k(n)||B(n))&&typeof n.setValue=="function"&&n.setValue(s)}),setTimeout(()=>{this.forceChildUIRefresh()},0);const e=this.getValues();this.initialValues=e,this.onChange&&this.onChange(e)}wireChild(t){var i;const e=()=>{var n;const s=this.getValues();this.initialValues=s,(n=this.onChange)==null||n.call(this,s),this.updateVisibility()};k(t)?t.setOnChange(()=>e()):B(t)?t.setOnChange(()=>e()):(i=t.setOnChange)==null||i.call(t,()=>e())}addSetting(t,e){var s,n;if(this.settings[t]=e,this.wireChild(e),this.elementRef){const o=this.elementRef.querySelector(".setting-group-content");if(o){k(e)&&typeof e.setNestingLevel=="function"&&e.setNestingLevel(this.nestingLevel+1);const a=e.draw(),l=this.deleteItemCfg??this.addItemCfg;if(l){const p=l.keyPrefix??((s=this.addItemCfg)==null?void 0:s.keyPrefix);p&&t.startsWith(p)&&this.addDeleteButtonToElement(a,t)}const r=o.querySelector(".sg-add-button-bottom");r?o.insertBefore(a,r):o.appendChild(a),dt.trackElement(a),Z(a,this.nestingLevel+1),st(a,this.nestingLevel+1);const c=a.style.display;a.style.display="none",a.offsetHeight,a.style.display=c,this.updateNestingStyles()}}const i=this.getValues();this.initialValues=i,(n=this.onChange)==null||n.call(this,i)}addDeleteButtonToElement(t,e,i){let s=null;try{s=t.querySelector(":scope > .setting-group-title")}catch{s=null}if(!s){const r=Array.from(t.querySelectorAll(".setting-group-title"));for(const c of r)if(c.closest(".setting-group")===t){s=c;break}s||(s=r[0]??null)}if(!s)return;const n=s.querySelector(".actions-section");if(!n)return;const o=document.createElement("button");o.type="button",o.className="sg-delete-button",i?i.deleteItemCfg:this.deleteItemCfg??this.addItemCfg,o.title="Delete",o.style.cssText=`
|
|
29
29
|
background: none;
|
|
30
30
|
border: none;
|
|
31
31
|
cursor: pointer;
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
font-weight: 500;
|
|
98
98
|
cursor: pointer;
|
|
99
99
|
transition: all 0.2s;
|
|
100
|
-
`,a.addEventListener("mouseenter",()=>{a.style.backgroundColor="#f9fafb",a.style.borderColor="#9ca3af"}),a.addEventListener("mouseleave",()=>{a.style.backgroundColor="white",a.style.borderColor="#d1d5db"}),l.addEventListener("mouseenter",()=>{l.style.backgroundColor="#dc2626"}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="#ef4444"});const r=()=>{e.style.opacity="0",i.style.transform="scale(0.95)",setTimeout(()=>{e.parentNode&&e.parentNode.removeChild(e)},200)};a.addEventListener("click",()=>{r(),t(!1)}),l.addEventListener("click",()=>{r(),t(!0)}),e.addEventListener("click",p=>{p.target===e&&(r(),t(!1))});const c=p=>{p.key==="Escape"&&(r(),t(!1),document.removeEventListener("keydown",c))};document.addEventListener("keydown",c),o.appendChild(a),o.appendChild(l),i.appendChild(s),i.appendChild(n),i.appendChild(o),e.appendChild(i),document.body.appendChild(e),requestAnimationFrame(()=>{e.style.opacity="1",i.style.transform="scale(1)"}),setTimeout(()=>l.focus(),100)})}getNextIndexFromPrefix(t){const e=new Set(Object.keys(this.settings).filter(s=>s.startsWith(t)).map(s=>{const n=Number(s.slice(t.length));return Number.isFinite(n)?n:-1}).filter(s=>s>=0));let i=0;for(;e.has(i);)i+=1;return i}calculateChanges(t,e){const i={};return new Set([...Object.keys(t),...Object.keys(e)]).forEach(n=>{const o=t[n],a=e[n];JSON.stringify(o)!==JSON.stringify(a)&&(i[n]={from:o,to:a})}),i}getValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(k(s))e[i]=s.getValues();else{const n=s;e[i]=n.getValue?n.getValue():n.value}}return e}else{const e=this.settings[t];if(!e)return;if(k(e))return e.getValues();const i=e;return i.getValue?i.getValue():i.value}}getValuesForJson(t){var e;if(t===void 0){if(this.includeGetJson===!1)return null;const i={};for(const s in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,s)){const n=this.settings[s];if(k(n)){const o=n.getValuesForJson();o!==null&&(i[s]=o)}else{const o=n;if(o.includeGetJson!==!1)if(n instanceof U){const a=n.getRawValue();i[s]=a?
|
|
100
|
+
`,a.addEventListener("mouseenter",()=>{a.style.backgroundColor="#f9fafb",a.style.borderColor="#9ca3af"}),a.addEventListener("mouseleave",()=>{a.style.backgroundColor="white",a.style.borderColor="#d1d5db"}),l.addEventListener("mouseenter",()=>{l.style.backgroundColor="#dc2626"}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="#ef4444"});const r=()=>{e.style.opacity="0",i.style.transform="scale(0.95)",setTimeout(()=>{e.parentNode&&e.parentNode.removeChild(e)},200)};a.addEventListener("click",()=>{r(),t(!1)}),l.addEventListener("click",()=>{r(),t(!0)}),e.addEventListener("click",p=>{p.target===e&&(r(),t(!1))});const c=p=>{p.key==="Escape"&&(r(),t(!1),document.removeEventListener("keydown",c))};document.addEventListener("keydown",c),o.appendChild(a),o.appendChild(l),i.appendChild(s),i.appendChild(n),i.appendChild(o),e.appendChild(i),document.body.appendChild(e),requestAnimationFrame(()=>{e.style.opacity="1",i.style.transform="scale(1)"}),setTimeout(()=>l.focus(),100)})}getNextIndexFromPrefix(t){const e=new Set(Object.keys(this.settings).filter(s=>s.startsWith(t)).map(s=>{const n=Number(s.slice(t.length));return Number.isFinite(n)?n:-1}).filter(s=>s>=0));let i=0;for(;e.has(i);)i+=1;return i}calculateChanges(t,e){const i={};return new Set([...Object.keys(t),...Object.keys(e)]).forEach(n=>{const o=t[n],a=e[n];JSON.stringify(o)!==JSON.stringify(a)&&(i[n]={from:o,to:a})}),i}getValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(k(s))e[i]=s.getValues();else{const n=s;e[i]=n.getValue?n.getValue():n.value}}return e}else{const e=this.settings[t];if(!e)return;if(k(e))return e.getValues();const i=e;return i.getValue?i.getValue():i.value}}getValuesForJson(t){var e;if(t===void 0){if(this.includeGetJson===!1)return null;const i={};for(const s in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,s)){const n=this.settings[s];if(k(n)){const o=n.getValuesForJson();o!==null&&(i[s]=o)}else{const o=n;if(o.includeGetJson!==!1)if(n instanceof U){const a=n.getRawValue();i[s]=a?N(a):null}else i[s]=o.value}}return(this.hide===!0||((e=this==null?void 0:this.groupProps)==null?void 0:e.hide)===!0)&&(i.hide=!0),i}else{const i=this.settings[t];if(!i)return;if(k(i))return i.includeGetJson===!1?null:i.getValuesForJson();{const s=i;if(s.includeGetJson===!1)return null;if(i instanceof U){const n=i.getRawValue();return n?N(n):null}return s.value}}}getDefaultValues(t){if(t===void 0){const e={};for(const i in this.settings)if(Object.prototype.hasOwnProperty.call(this.settings,i)){const s=this.settings[i];if(k(s))e[i]=s.getDefaultValues();else{const n=s;e[i]=n.default!==void 0?n.default:n.value}}return e}else{const e=this.settings[t];if(!e)return;if(k(e))return e.getDefaultValues();const i=e;return i.default!==void 0?i.default:i.value}}draw(){const t=document.createElement("div");t.className="setting-group",t.id=`setting-group-${this.id}`,tt.hiddenElements.add(t),this.hide&&(t.style.display="none"),this.isMain&&t.classList.add("main-group"),this.custom&&t.classList.add("custom_class"),Z(t,this.nestingLevel);const e=document.createElement("div");e.className="setting-group-title",this.isCollapsed&&e.classList.add("collapsed-view"),e.setAttribute("role","button"),e.setAttribute("aria-expanded",(!this.isCollapsed).toString()),e.setAttribute("tabindex","0");const i=document.createElement("div");i.className="title-section";const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");n.className="actions-section";const o=document.createElement("span");o.className="setting-group-arrow",o.innerHTML=`
|
|
101
101
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
102
102
|
<path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
103
103
|
</svg>
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
xmlns="http://www.w3.org/2000/svg">
|
|
107
107
|
<path d="M8 3.333v9.334M3.333 8h9.334" stroke="currentColor"
|
|
108
108
|
stroke-width="1.5" stroke-linecap="round"/>
|
|
109
|
-
</svg>`;c.innerHTML=`${p}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel??"Add"}</span>`,c.addEventListener("click",d=>{d.stopPropagation(),d.preventDefault();const g=this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),C=this.addItemCfg.createItem(g);if(nt(C)){const m=`${this.addItemCfg.keyPrefix}${g}`;this.addSetting(m,C)}}),a.appendChild(c)}return e.appendChild(i),e.appendChild(n),t.appendChild(e),t.appendChild(a),this.elementRef=t,dt.trackElement(t),setTimeout(()=>{this.updateNestingStyles()},0),this.pendingBlurHandler&&(this.pendingBlurHandler=null),t}collapse(){if(!this.elementRef||this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!0,t.classList.add("collapsed"),e.classList.add("rotated"),i.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!1,t.classList.remove("collapsed"),e.classList.remove("rotated"),i.setAttribute("aria-expanded","true"))}getJson(){return JSON.stringify(this.getValuesForJson(),null,2)}setJson(t){try{const e=JSON.parse(t);let i=e;const s=Object.keys(this.settings),n=Object.keys(e);if(!s.some(a=>n.includes(a))&&n.length===1){const a=n[0];i=e[a]}this.setValue(i)}catch(e){throw console.error("Invalid JSON provided to setJson:",e),new Error("Invalid JSON format")}}};tt.hiddenElements=new Set;let H=tt;function Wt(h){return new ht(h)}class ht extends H{constructor(t){super(t);const e=Object.keys(this.settings)[0];this.activeTabId=e||""}getActiveTabId(){return this.activeTabId}switchToTab(t){var i;if(!this.settings[t]||this.activeTabId===t)return;this.activeTabId=t,this.updateTabUI();const e=this.getValues();this.initialValues=e,(i=this.onChange)==null||i.call(this,e)}getValues(t){return t!==void 0?super.getValues(t):{...super.getValues(),activeTabId:this.activeTabId}}updateTabUI(){if(!this.tabsContainer||!this.contentContainers)return;this.tabsContainer.querySelectorAll(".tab-button").forEach(e=>{e.getAttribute("data-tab-id")===this.activeTabId?e.classList.add("active"):e.classList.remove("active")}),Object.entries(this.contentContainers).forEach(([e,i])=>{e===this.activeTabId?i.classList.add("active"):i.classList.remove("active")})}draw(){const t=super.draw();t.classList.add("tabs-settings-container");const e=t.querySelector(".setting-group-content");if(!e)return t;e.innerHTML="";const i=document.createElement("div");i.className="tabs-title";const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");n.className="tabs-header",this.tabsContainer=n;const o=document.createElement("div");if(o.className="tab-content",this.contentContainers={},Object.keys(this.settings).forEach((a,l)=>{const r=document.createElement("button");r.className="tab-button",r.type="button",r.setAttribute("data-tab-id",a),r.textContent=a,r.addEventListener("click",()=>this.switchToTab(a)),n.appendChild(r);const c=document.createElement("div");c.className="tab-panel",this.contentContainers[a]=c;const p=this.settings[a];p&&(k(p)&&typeof p.setNestingLevel=="function"&&p.setNestingLevel(this.getNestingLevel()+1),c.appendChild(p.draw())),o.appendChild(c),l===0&&!this.activeTabId&&(this.activeTabId=a)}),e.appendChild(i),e.appendChild(n),e.appendChild(o),!this.activeTabId){const a=Object.keys(this.settings)[0];this.activeTabId=a||""}return this.updateTabUI(),t}}function wt(h){return new H(h)}function jt(h){return h}class xt extends w{constructor(t={}){super(t),this.inputType="text",t.onChange&&this.setOnChange(t.onChange)}draw(){const t=e=>{this.props.maxLength!==void 0&&(e.maxLength=this.props.maxLength),this.props.className&&e.classList.add(this.props.className)};return this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,placeholder:this.props.placeholder,icon:this.props.icon,inputClassName:"string-setting-input "+(this.props.inputClassName||""),wrapperClassName:"string-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:t})}}const qt="<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' stroke-linecap='round' stroke-linejoin='round'/></svg>";class V extends xt{constructor(t){super({...t,icon:t.icon||qt,title:t.title||"Color",default:t.default?V.normalizeColorValue(t.default):"#000000"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.detectChange=t.detectChange}static normalizeColorValue(t){return t.startsWith("var(--")?t:t.startsWith("#")?V.normalizeHexValue(t):t.includes(",")?V.rgbToHexStatic(t):V.normalizeHexValue(t)}static normalizeHexValue(t){return t=t.replace("#",""),t.length===3&&(t=t.split("").map(e=>e+e).join("")),t.length!==6?(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000"):/^[0-9A-Fa-f]{6}$/.test(t)?`#${t.toLowerCase()}`:(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000")}static rgbToHexStatic(t){const e=t.split(",").map(c=>parseInt(c.trim()));if(e.length!==3||e.some(isNaN))return console.warn(`Invalid RGB value "${t}", using default "#000000"`),"#000000";const[i,s,n]=e,o=Math.max(0,Math.min(255,i)),a=Math.max(0,Math.min(255,s)),l=Math.max(0,Math.min(255,n)),r=c=>{const p=c.toString(16);return p.length===1?"0"+p:p};return`#${r(o)}${r(a)}${r(l)}`}setValue(t){if(t===void 0){this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000");return}if(typeof t=="string"){const e=V.normalizeColorValue(t);this.value=e,this.colorInputEl&&(this.colorInputEl.value=e),this.textInputEl&&(this.textInputEl.value=e),this.onChange&&this.onChange(e),this.props.detectChange&&this.props.detectChange(e)}else this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000")}hexToRgb(t){t=t.replace("#","");const e=parseInt(t.substring(0,2),16),i=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return`${e}, ${i}, ${s}`}draw(){const t=document.createElement("div");if(t.className="color-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const m=document.createElement("div");if(m.className="icon-container",this.props.icon){const u=document.createElement("span");u.className="input-icon",u.innerHTML=this.props.icon,m.appendChild(u)}if(this.props.title){const u=document.createElement("span");u.className="input-label",u.textContent=this.props.title,m.appendChild(u)}t.appendChild(m)}const e=document.createElement("div");e.className="color-input-wrapper";const i=document.createElement("div");i.className="color-setting-tabs",i.style.display="flex",i.style.marginBottom="8px",i.style.gap="4px";const s=document.createElement("button");s.className="color-tab active",s.textContent="Solid";const n=document.createElement("button");n.className="color-tab",n.textContent="Global",i.appendChild(s),i.appendChild(n);const o=document.createElement("div");o.className="color-content-solid";const a=document.createElement("div");a.className="color-content-global",a.style.display="none",a.style.display="grid",a.style.gridTemplateColumns="repeat(auto-fill, minmax(30px, 1fr))",a.style.gap="8px";const l=()=>{try{if(console.log("ColorSetting: renderGlobalOptions called"),a.innerHTML="",!w){console.error("ColorSetting: Setting class is undefined");const u=document.createElement("div");u.textContent="Error: System error (Setting undefined)",a.appendChild(u);return}const m=w.GlobalVariables||{};if(console.log("ColorSetting: GlobalVariables:",m),!m||Object.keys(m).length===0){const u=document.createElement("div");u.textContent="No global colors defined",u.style.gridColumn="1 / -1",u.style.fontSize="12px",u.style.color="#666",a.appendChild(u);return}Object.entries(m).forEach(([u,v])=>{const f=document.createElement("button");f.className="global-color-btn",f.title=u,f.style.width="30px",f.style.height="30px",f.style.borderRadius="50%",f.style.border="1px solid #ddd",f.style.backgroundColor=v,f.style.cursor="pointer",this.value===`var(--${u})`&&(f.style.border="2px solid #2196f3"),f.addEventListener("click",y=>{var L,N;y.preventDefault();const E=`var(--${u})`;this.value=E,(L=this.onChange)==null||L.call(this,E),(N=this.detectChange)==null||N.call(this,E),Array.from(a.children).forEach(b=>{b.style.border="1px solid #ddd"}),f.style.border="2px solid #2196f3",p.style.backgroundColor=v}),a.appendChild(f)})}catch(m){console.error("ColorSetting: Error in renderGlobalOptions",m),a.innerHTML="Error loading global options"}};l(),s.addEventListener("click",m=>{m.preventDefault(),s.classList.add("active"),n.classList.remove("active"),o.style.display="flex",a.style.display="none",this.value&&this.value.startsWith("var(--")}),n.addEventListener("click",m=>{m.preventDefault(),n.classList.add("active"),s.classList.remove("active"),o.style.display="none",a.style.display="grid",l()}),this.value&&this.value.startsWith("var(--")?n.click():s.click();const r=m=>{const u=m.value.trim();if(!u)return e.classList.remove("error"),!0;const f=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(u);return f?e.classList.remove("error"):e.classList.add("error"),f},c=document.createElement("input");c.type="color",c.className="color-picker",c.value=this.value&&!this.value.startsWith("var(--")?this.value:"#000000",c.setAttribute("aria-label","Choose color"),c.setAttribute("title","Click to open color picker"),this.getDataPropsPath()&&c.setAttribute("data-test-id",this.getDataPropsPath()),this.colorInputEl=c;const p=document.createElement("div");p.className="color-preview";let d=this.value||"#000000";if(d.startsWith("var(--")){const m=d.replace("var(--","").replace(")","");d=(w.GlobalVariables||{})[m]||"#000000"}p.style.backgroundColor=d;const g=document.createElement("input");g.type="text",g.className="color-text-input",g.value=this.value||"",g.placeholder="#000000",g.setAttribute("pattern","#[0-9A-Fa-f]{6}"),g.setAttribute("title","Enter a hex color value (e.g., #ff0000)"),g.setAttribute("aria-label","Hex color value"),g.setAttribute("maxlength","7"),this.getDataPropsPath()&&g.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.textInputEl=g;const C=m=>{var v,f;let u=m.trim();if(u&&!u.startsWith("#")&&!u.startsWith("var(")&&/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(u)&&(u="#"+u,this.textInputEl&&(this.textInputEl.value=u)),this.textInputEl&&r(this.textInputEl)){const y=V.normalizeColorValue(u);this.value=y,(v=this.onChange)==null||v.call(this,y),(f=this.detectChange)==null||f.call(this,y),this.colorInputEl&&(this.colorInputEl.value=y),p.style.backgroundColor=y}};return this.textInputEl.addEventListener("input",m=>{const u=m.target.value;C(u)}),this.textInputEl.addEventListener("paste",m=>{var v;m.preventDefault();const u=((v=m.clipboardData)==null?void 0:v.getData("text"))||"";this.textInputEl&&(this.textInputEl.value=u.trim(),C(u))}),this.textInputEl.addEventListener("keydown",m=>{var u,v,f;m.key==="Enter"&&(m.preventDefault(),C(((u=this.textInputEl)==null?void 0:u.value)||""),(v=this.textInputEl)==null||v.blur()),m.key==="Escape"&&(this.textInputEl&&this.value&&(this.textInputEl.value=this.value),(f=this.textInputEl)==null||f.blur(),e.classList.remove("error"))}),this.colorInputEl.addEventListener("input",m=>{var f,y;const u=m.target.value,v=V.normalizeColorValue(u);this.value=v,(f=this.onChange)==null||f.call(this,v),(y=this.detectChange)==null||y.call(this,v),this.textInputEl&&(this.textInputEl.value=v),p.style.backgroundColor=v,e.classList.remove("error")}),this.colorInputEl.addEventListener("change",m=>{var f,y;const u=m.target.value,v=V.normalizeColorValue(u);this.value=v,(f=this.onChange)==null||f.call(this,v),(y=this.detectChange)==null||y.call(this,v),this.textInputEl&&(this.textInputEl.value=v),p.style.backgroundColor=v}),o.appendChild(c),o.appendChild(p),o.appendChild(g),e.appendChild(i),e.appendChild(o),e.appendChild(a),t.appendChild(e),this.element=t,t}getElement(){return this.element}getNormalizedValue(){return this.value?V.normalizeColorValue(this.value):"#000000"}isValidHex(){return this.value?/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(this.value):!1}toRgb(){return this.isValidHex()?this.hexToRgb(this.value):"0, 0, 0"}}const Jt=`
|
|
109
|
+
</svg>`;c.innerHTML=`${p}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel??"Add"}</span>`,c.addEventListener("click",d=>{d.stopPropagation(),d.preventDefault();const g=this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),C=this.addItemCfg.createItem(g);if(nt(C)){const m=`${this.addItemCfg.keyPrefix}${g}`;this.addSetting(m,C)}}),a.appendChild(c)}return e.appendChild(i),e.appendChild(n),t.appendChild(e),t.appendChild(a),this.elementRef=t,dt.trackElement(t),setTimeout(()=>{this.updateNestingStyles()},0),this.pendingBlurHandler&&(this.pendingBlurHandler=null),t}collapse(){if(!this.elementRef||this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!0,t.classList.add("collapsed"),e.classList.add("rotated"),i.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!1,t.classList.remove("collapsed"),e.classList.remove("rotated"),i.setAttribute("aria-expanded","true"))}getJson(){return JSON.stringify(this.getValuesForJson(),null,2)}setJson(t){try{const e=JSON.parse(t);let i=e;const s=Object.keys(this.settings),n=Object.keys(e);if(!s.some(a=>n.includes(a))&&n.length===1){const a=n[0];i=e[a]}this.setValue(i)}catch(e){throw console.error("Invalid JSON provided to setJson:",e),new Error("Invalid JSON format")}}};tt.hiddenElements=new Set;let H=tt;function Wt(h){return new ht(h)}class ht extends H{constructor(t){super(t);const e=Object.keys(this.settings)[0];this.activeTabId=e||""}getActiveTabId(){return this.activeTabId}switchToTab(t){var i;if(!this.settings[t]||this.activeTabId===t)return;this.activeTabId=t,this.updateTabUI();const e=this.getValues();this.initialValues=e,(i=this.onChange)==null||i.call(this,e)}getValues(t){return t!==void 0?super.getValues(t):{...super.getValues(),activeTabId:this.activeTabId}}updateTabUI(){if(!this.tabsContainer||!this.contentContainers)return;this.tabsContainer.querySelectorAll(".tab-button").forEach(e=>{e.getAttribute("data-tab-id")===this.activeTabId?e.classList.add("active"):e.classList.remove("active")}),Object.entries(this.contentContainers).forEach(([e,i])=>{e===this.activeTabId?i.classList.add("active"):i.classList.remove("active")})}draw(){const t=super.draw();t.classList.add("tabs-settings-container");const e=t.querySelector(".setting-group-content");if(!e)return t;e.innerHTML="";const i=document.createElement("div");i.className="tabs-title";const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");n.className="tabs-header",this.tabsContainer=n;const o=document.createElement("div");if(o.className="tab-content",this.contentContainers={},Object.keys(this.settings).forEach((a,l)=>{const r=document.createElement("button");r.className="tab-button",r.type="button",r.setAttribute("data-tab-id",a),r.textContent=a,r.addEventListener("click",()=>this.switchToTab(a)),n.appendChild(r);const c=document.createElement("div");c.className="tab-panel",this.contentContainers[a]=c;const p=this.settings[a];p&&(k(p)&&typeof p.setNestingLevel=="function"&&p.setNestingLevel(this.getNestingLevel()+1),c.appendChild(p.draw())),o.appendChild(c),l===0&&!this.activeTabId&&(this.activeTabId=a)}),e.appendChild(i),e.appendChild(n),e.appendChild(o),!this.activeTabId){const a=Object.keys(this.settings)[0];this.activeTabId=a||""}return this.updateTabUI(),t}}function wt(h){return new H(h)}function jt(h){return h}class xt extends w{constructor(t={}){super(t),this.inputType="text",t.onChange&&this.setOnChange(t.onChange)}draw(){const t=e=>{this.props.maxLength!==void 0&&(e.maxLength=this.props.maxLength),this.props.className&&e.classList.add(this.props.className)};return this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,placeholder:this.props.placeholder,icon:this.props.icon,inputClassName:"string-setting-input "+(this.props.inputClassName||""),wrapperClassName:"string-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:t})}}const qt="<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' stroke-linecap='round' stroke-linejoin='round'/></svg>";class V extends xt{constructor(t){super({...t,icon:t.icon||qt,title:t.title||"Color",default:t.default?V.normalizeColorValue(t.default):"#000000"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.detectChange=t.detectChange}static normalizeColorValue(t){return t.startsWith("var(--")?t:t.startsWith("#")?V.normalizeHexValue(t):t.includes(",")?V.rgbToHexStatic(t):V.normalizeHexValue(t)}static normalizeHexValue(t){return t=t.replace("#",""),t.length===3&&(t=t.split("").map(e=>e+e).join("")),t.length!==6?(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000"):/^[0-9A-Fa-f]{6}$/.test(t)?`#${t.toLowerCase()}`:(console.warn(`Invalid hex value "${t}", using default "#000000"`),"#000000")}static rgbToHexStatic(t){const e=t.split(",").map(c=>parseInt(c.trim()));if(e.length!==3||e.some(isNaN))return console.warn(`Invalid RGB value "${t}", using default "#000000"`),"#000000";const[i,s,n]=e,o=Math.max(0,Math.min(255,i)),a=Math.max(0,Math.min(255,s)),l=Math.max(0,Math.min(255,n)),r=c=>{const p=c.toString(16);return p.length===1?"0"+p:p};return`#${r(o)}${r(a)}${r(l)}`}setValue(t){if(t===void 0){this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000");return}if(typeof t=="string"){const e=V.normalizeColorValue(t);this.value=e,this.colorInputEl&&(this.colorInputEl.value=e),this.textInputEl&&(this.textInputEl.value=e),this.onChange&&this.onChange(e),this.props.detectChange&&this.props.detectChange(e)}else this.value="#000000",this.colorInputEl&&(this.colorInputEl.value="#000000"),this.textInputEl&&(this.textInputEl.value="#000000"),this.onChange&&this.onChange("#000000"),this.props.detectChange&&this.props.detectChange("#000000")}hexToRgb(t){t=t.replace("#","");const e=parseInt(t.substring(0,2),16),i=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return`${e}, ${i}, ${s}`}draw(){const t=document.createElement("div");if(t.className="color-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const m=document.createElement("div");if(m.className="icon-container",this.props.icon){const u=document.createElement("span");u.className="input-icon",u.innerHTML=this.props.icon,m.appendChild(u)}if(this.props.title){const u=document.createElement("span");u.className="input-label",u.textContent=this.props.title,m.appendChild(u)}t.appendChild(m)}const e=document.createElement("div");e.className="color-input-wrapper";const i=document.createElement("div");i.className="color-setting-tabs",i.style.display="flex",i.style.marginBottom="8px",i.style.gap="4px";const s=document.createElement("button");s.className="color-tab active",s.textContent="Solid";const n=document.createElement("button");n.className="color-tab",n.textContent="Global",i.appendChild(s),i.appendChild(n);const o=document.createElement("div");o.className="color-content-solid";const a=document.createElement("div");a.className="color-content-global",a.style.display="none",a.style.display="grid",a.style.gridTemplateColumns="repeat(auto-fill, minmax(30px, 1fr))",a.style.gap="8px";const l=()=>{try{if(console.log("ColorSetting: renderGlobalOptions called"),a.innerHTML="",!w){console.error("ColorSetting: Setting class is undefined");const u=document.createElement("div");u.textContent="Error: System error (Setting undefined)",a.appendChild(u);return}const m=w.GlobalVariables||{};if(console.log("ColorSetting: GlobalVariables:",m),!m||Object.keys(m).length===0){const u=document.createElement("div");u.textContent="No global colors defined",u.style.gridColumn="1 / -1",u.style.fontSize="12px",u.style.color="#666",a.appendChild(u);return}Object.entries(m).forEach(([u,f])=>{const v=document.createElement("button");v.className="global-color-btn",v.title=u,v.style.width="30px",v.style.height="30px",v.style.borderRadius="50%",v.style.border="1px solid #ddd",v.style.backgroundColor=f,v.style.cursor="pointer",this.value===`var(--${u})`&&(v.style.border="2px solid #2196f3"),v.addEventListener("click",y=>{var L,I;y.preventDefault();const E=`var(--${u})`;this.value=E,(L=this.onChange)==null||L.call(this,E),(I=this.detectChange)==null||I.call(this,E),Array.from(a.children).forEach(b=>{b.style.border="1px solid #ddd"}),v.style.border="2px solid #2196f3",p.style.backgroundColor=f}),a.appendChild(v)})}catch(m){console.error("ColorSetting: Error in renderGlobalOptions",m),a.innerHTML="Error loading global options"}};l(),s.addEventListener("click",m=>{m.preventDefault(),s.classList.add("active"),n.classList.remove("active"),o.style.display="flex",a.style.display="none",this.value&&this.value.startsWith("var(--")}),n.addEventListener("click",m=>{m.preventDefault(),n.classList.add("active"),s.classList.remove("active"),o.style.display="none",a.style.display="grid",l()}),this.value&&this.value.startsWith("var(--")?n.click():s.click();const r=m=>{const u=m.value.trim();if(!u)return e.classList.remove("error"),!0;const v=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(u);return v?e.classList.remove("error"):e.classList.add("error"),v},c=document.createElement("input");c.type="color",c.className="color-picker",c.value=this.value&&!this.value.startsWith("var(--")?this.value:"#000000",c.setAttribute("aria-label","Choose color"),c.setAttribute("title","Click to open color picker"),this.getDataPropsPath()&&c.setAttribute("data-test-id",this.getDataPropsPath()),this.colorInputEl=c;const p=document.createElement("div");p.className="color-preview";let d=this.value||"#000000";if(d.startsWith("var(--")){const m=d.replace("var(--","").replace(")","");d=(w.GlobalVariables||{})[m]||"#000000"}p.style.backgroundColor=d;const g=document.createElement("input");g.type="text",g.className="color-text-input",g.value=this.value||"",g.placeholder="#000000",g.setAttribute("pattern","#[0-9A-Fa-f]{6}"),g.setAttribute("title","Enter a hex color value (e.g., #ff0000)"),g.setAttribute("aria-label","Hex color value"),g.setAttribute("maxlength","7"),this.getDataPropsPath()&&g.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.textInputEl=g;const C=m=>{var f,v;let u=m.trim();if(u&&!u.startsWith("#")&&!u.startsWith("var(")&&/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(u)&&(u="#"+u,this.textInputEl&&(this.textInputEl.value=u)),this.textInputEl&&r(this.textInputEl)){const y=V.normalizeColorValue(u);this.value=y,(f=this.onChange)==null||f.call(this,y),(v=this.detectChange)==null||v.call(this,y),this.colorInputEl&&(this.colorInputEl.value=y),p.style.backgroundColor=y}};return this.textInputEl.addEventListener("input",m=>{const u=m.target.value;C(u)}),this.textInputEl.addEventListener("paste",m=>{var f;m.preventDefault();const u=((f=m.clipboardData)==null?void 0:f.getData("text"))||"";this.textInputEl&&(this.textInputEl.value=u.trim(),C(u))}),this.textInputEl.addEventListener("keydown",m=>{var u,f,v;m.key==="Enter"&&(m.preventDefault(),C(((u=this.textInputEl)==null?void 0:u.value)||""),(f=this.textInputEl)==null||f.blur()),m.key==="Escape"&&(this.textInputEl&&this.value&&(this.textInputEl.value=this.value),(v=this.textInputEl)==null||v.blur(),e.classList.remove("error"))}),this.colorInputEl.addEventListener("input",m=>{var v,y;const u=m.target.value,f=V.normalizeColorValue(u);this.value=f,(v=this.onChange)==null||v.call(this,f),(y=this.detectChange)==null||y.call(this,f),this.textInputEl&&(this.textInputEl.value=f),p.style.backgroundColor=f,e.classList.remove("error")}),this.colorInputEl.addEventListener("change",m=>{var v,y;const u=m.target.value,f=V.normalizeColorValue(u);this.value=f,(v=this.onChange)==null||v.call(this,f),(y=this.detectChange)==null||y.call(this,f),this.textInputEl&&(this.textInputEl.value=f),p.style.backgroundColor=f}),o.appendChild(c),o.appendChild(p),o.appendChild(g),e.appendChild(i),e.appendChild(o),e.appendChild(a),t.appendChild(e),this.element=t,t}getElement(){return this.element}getNormalizedValue(){return this.value?V.normalizeColorValue(this.value):"#000000"}isValidHex(){return this.value?/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(this.value):!1}toRgb(){return this.isValidHex()?this.hexToRgb(this.value):"0, 0, 0"}}const Jt=`
|
|
110
110
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
111
111
|
<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"/>
|
|
112
112
|
<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"/>
|
|
@@ -226,7 +226,7 @@
|
|
|
226
226
|
${ne}
|
|
227
227
|
<span>Click to upload image</span>
|
|
228
228
|
</div>
|
|
229
|
-
`,i.addEventListener("click",()=>{window.postMessage({type:"OPEN_FILE_MANAGER_MODAL",settingId:this.id},"*")}),e.appendChild(i),t.appendChild(e)}renderImageMapSection(t){const e=document.createElement("div");e.className="image-map-actions";const i=document.createElement("div");i.className="undo-redo-group";const s=document.createElement("button");s.type="button",s.className="undo-btn action-btn",s.innerHTML=le,s.title="Undo (Ctrl+Z)",s.disabled=!this.canUndo(),s.addEventListener("click",()=>this.undo()),i.appendChild(s);const n=document.createElement("button");n.type="button",n.className="redo-btn action-btn",n.innerHTML=re,n.title="Redo (Ctrl+Y)",n.disabled=!this.canRedo(),n.addEventListener("click",()=>this.redo()),i.appendChild(n),e.appendChild(i);const o=document.createElement("button");o.type="button",o.className="replace-btn",o.textContent="Replace Image",o.addEventListener("click",()=>{window.postMessage({type:"OPEN_FILE_MANAGER_MODAL",settingId:this.id},"*")}),e.appendChild(o);const a=document.createElement("button");a.type="button",a.className="clear-all-btn",a.textContent="Clear All Markers",a.addEventListener("click",()=>this.handleClearAllMarkers()),e.appendChild(a),t.appendChild(e);const l=document.createElement("div");l.className="image-map-container";const r=document.createElement("div");r.className="image-map-wrapper",r.addEventListener("mousemove",this.boundHandleMarkerDrag),r.addEventListener("mouseup",this.boundStopDragging),r.addEventListener("mouseleave",this.boundStopDragging),this.imageElement=document.createElement("img"),this.imageElement.className="image-map-image",this.imageElement.src=this.value.imageUrl,this.imageElement.addEventListener("load",()=>this.recordImageNaturalSize()),this.imageElement.addEventListener("click",c=>this.handleImageClick(c)),r.appendChild(this.imageElement),this.cursorTooltip=document.createElement("div"),this.cursorTooltip.className="marker-cursor-tooltip",r.appendChild(this.cursorTooltip),this.imageElement.addEventListener("mouseenter",()=>this.showCursorTooltip()),this.imageElement.addEventListener("mouseleave",()=>this.hideCursorTooltip()),this.imageElement.addEventListener("mousemove",c=>this.updateCursorTooltip(c)),this.value&&this.value.markers&&this.value.markers.forEach(c=>{const p=this.createMarkerElement(c);r.appendChild(p)}),l.appendChild(r),t.appendChild(l)}renderSidebar(t){var c,p;const e=document.createElement("div");e.className="prize-counter";const i=this.props.maxMarkers||10,s=((c=this.value)==null?void 0:c.markers.length)||0,n=s===i;e.textContent=`Prizes ${s}/${i}`,n&&e.classList.add("complete"),t.appendChild(e);const o=document.createElement("div");o.className="prize-list";const a=((p=this.value)==null?void 0:p.markers)||[],l=new Map;a.forEach(d=>l.set(d.index,d));for(let d=1;d<=i;d++){const g=l.get(d),C=!!g,m=(g==null?void 0:g.prizeName)||this.props.prizeMap&&this.props.prizeMap[d-1]||`Prize #${d}`,u=document.createElement("div");u.className=`prize-item ${C?"placed":"missing"}`;const v=document.createElement("div");v.className="prize-index",v.textContent=String(d);const f=document.createElement("div");f.className="prize-label";const y=document.createElement("div");y.className="prize-title",y.textContent=`Prize #${d}`;const E=document.createElement("div");E.className="prize-subtitle",E.textContent=C?m:"Not Placed",f.appendChild(y),f.appendChild(E);const L=document.createElement("div");L.className=`prize-status ${C?"placed":"missing"}`,L.innerHTML=C?ce:he,u.appendChild(v),u.appendChild(f),u.appendChild(L),o.appendChild(u)}t.appendChild(o);const r=document.createElement("button");r.type="button",r.className="sidebar-save-btn",r.textContent="Save",n?r.title="Save and close":(r.disabled=!0,r.title=`Add ${i-s} more prize(s) to save`),r.addEventListener("click",()=>{n&&(this.triggerChange(),this.closePopover(!0))}),t.appendChild(r)}createMarkerElement(t){const e=document.createElement("div");e.className="marker-container",e.style.left=`${t.x}%`,e.style.top=`${t.y}%`,e.setAttribute("data-marker-id",String(t.id));const i=document.createElement("div");i.className="image-map-marker";const s=document.createElement("span");s.className="marker-number",s.textContent=String(t.index),i.appendChild(s);const n=document.createElement("button");n.type="button",n.className="marker-delete-btn",n.innerHTML=ae,n.addEventListener("click",a=>{a.stopPropagation(),this.handleDeleteMarker(t.id)}),i.appendChild(n),e.appendChild(i);const o=document.createElement("div");return o.className="marker-label",t.prizeName?o.textContent=t.prizeName:o.textContent=`Prize ${t.index}`,e.appendChild(o),e.addEventListener("mousedown",a=>{a.stopPropagation(),a.preventDefault(),this.draggingMarkerId=t.id,e.classList.add("dragging")}),e}handleImageUpload(t){const e=this.lastImageNaturalSize;if(!["image/jpeg","image/jpg","image/png","image/gif","image/webp"].includes(t.type)){this.showError("Invalid file type. Please upload a JPEG, PNG, GIF, or WebP image.");return}const s=(this.props.maxFileSizeMB||5)*1024*1024;if(t.size>s){const o=(t.size/1048576).toFixed(1);this.showError(`File size (${o}MB) exceeds ${this.props.maxFileSizeMB}MB limit.`);return}const n=new FileReader;n.onload=o=>{var l;const a=(l=o.target)==null?void 0:l.result;if(typeof a=="string"){const r=new Image;r.onload=()=>{var d;const c={width:r.naturalWidth||0,height:r.naturalHeight||0},p=this.scaleMarkersForNewImage(((d=this.value)==null?void 0:d.markers)||[],e,c);this.value={imageUrl:a,markers:p},this.lastImageNaturalSize=c,this.history=[JSON.parse(JSON.stringify(p))],this.historyIndex=0,this.updateUndoRedoButtons(),this.updateButtonDisplay(),this.refreshPopoverContent(),this.triggerChange()},r.onerror=()=>{this.showError("Failed to read image file.")},r.src=a}},n.onerror=()=>{this.showError("Failed to read image file.")},n.readAsDataURL(t)}handleImageClick(t){if(this.draggingMarkerId!==null||!this.value||!this.imageElement)return;if(this.value.markers.length>=(this.props.maxMarkers||10)){this.showError(`Maximum of ${this.props.maxMarkers||10} markers allowed.`);return}const e=this.imageElement.getBoundingClientRect(),i=(t.clientX-e.left)/e.width*100,s=(t.clientY-e.top)/e.height*100,n=this.value.markers.map(c=>c.index).sort((c,p)=>c-p);let o=1;for(const c of n)if(c===o)o++;else break;let a;this.props.prizeMap&&this.props.prizeMap.length>0&&(a=this.props.prizeMap[o-1]);const l={id:Date.now(),index:o,x:Math.min(100,Math.max(0,i)),y:Math.min(100,Math.max(0,s)),prizeName:a},r=[...this.value.markers,l];this.setMarkers(r),this.saveState(),this.refreshPopoverContent(),this.updateButtonDisplay(),this.triggerChange()}handleMarkerDrag(t){var r;if(this.draggingMarkerId===null||!this.imageElement||!this.value)return;const e=this.imageElement.getBoundingClientRect(),i=(t.clientX-e.left)/e.width*100,s=(t.clientY-e.top)/e.height*100,n=Math.min(100,Math.max(0,i)),o=Math.min(100,Math.max(0,s)),a=this.value.markers.map(c=>c.id===this.draggingMarkerId?{...c,x:n,y:o}:c),l=(r=this.popoverEl)==null?void 0:r.querySelector(`[data-marker-id="${this.draggingMarkerId}"]`);l&&(l.style.left=`${n}%`,l.style.top=`${o}%`),this.setMarkers(a)}stopDragging(){var t;if(this.draggingMarkerId!==null){const e=(t=this.popoverEl)==null?void 0:t.querySelector(`[data-marker-id="${this.draggingMarkerId}"]`);e==null||e.classList.remove("dragging"),this.draggingMarkerId=null,this.saveState(),this.triggerChange()}}handleDeleteMarker(t){if(!this.value||this.value.markers.findIndex(s=>s.id===t)===-1)return;const i=this.value.markers.filter(s=>s.id!==t);this.setMarkers(i),this.saveState(),this.refreshPopoverContent(),this.updateButtonDisplay(),this.triggerChange()}handleClearAllMarkers(){this.value&&(this.setMarkers([]),this.saveState(),this.refreshPopoverContent(),this.updateButtonDisplay(),this.triggerChange())}getNextPrizeInfo(){if(!this.value)return{index:1,name:"Prize 1"};const t=this.value.markers.map(s=>s.index).sort((s,n)=>s-n);let e=1;for(const s of t)if(s===e)e++;else break;let i=`Prize ${e}`;if(this.props.prizeMap&&this.props.prizeMap.length>0){const s=this.props.prizeMap[e-1];s&&(i=s)}return{index:e,name:i}}showCursorTooltip(){if(!this.cursorTooltip||!this.value||this.value.markers.length>=(this.props.maxMarkers||10))return;const t=this.getNextPrizeInfo();this.cursorTooltip.textContent=`Add: ${t.name}`,this.cursorTooltip.classList.add("visible")}hideCursorTooltip(){this.cursorTooltip&&this.cursorTooltip.classList.remove("visible")}updateCursorTooltip(t){if(!this.cursorTooltip||!this.imageElement)return;const e=this.imageElement.getBoundingClientRect(),i=t.clientX-e.left,s=t.clientY-e.top;this.cursorTooltip.style.left=`${i}px`,this.cursorTooltip.style.top=`${s}px`}saveState(){if(this.isUndoRedoOperation||!this.value)return;const t=JSON.parse(JSON.stringify(this.value.markers));if(this.historyIndex>=0&&this.history.length>0){const e=this.history[this.historyIndex];if(JSON.stringify(e)===JSON.stringify(t))return}this.history=this.history.slice(0,this.historyIndex+1),this.history.push(t),this.historyIndex++,this.history.length>50&&(this.history.shift(),this.historyIndex--),this.updateUndoRedoButtons()}canUndo(){return this.historyIndex>0}canRedo(){return this.historyIndex<this.history.length-1}undo(){if(!this.canUndo()||!this.value)return;this.historyIndex--,this.isUndoRedoOperation=!0;const t=JSON.parse(JSON.stringify(this.history[this.historyIndex]));this.setMarkers(t),this.refreshPopoverContent(),this.updateButtonDisplay(),this.triggerChange(),this.isUndoRedoOperation=!1,this.updateUndoRedoButtons()}redo(){if(!this.canRedo()||!this.value)return;this.historyIndex++,this.isUndoRedoOperation=!0;const t=JSON.parse(JSON.stringify(this.history[this.historyIndex]));this.setMarkers(t),this.refreshPopoverContent(),this.updateButtonDisplay(),this.triggerChange(),this.isUndoRedoOperation=!1,this.updateUndoRedoButtons()}updateUndoRedoButtons(){if(!this.popoverEl)return;const t=this.popoverEl.querySelector(".undo-btn"),e=this.popoverEl.querySelector(".redo-btn");t&&(t.disabled=!this.canUndo()),e&&(e.disabled=!this.canRedo())}showError(t){const e=document.createElement("div");if(e.className="image-map-error-toast",e.textContent=t,e.style.cssText=`
|
|
229
|
+
`,i.addEventListener("click",()=>{window.postMessage({type:"OPEN_FILE_MANAGER_MODAL",settingId:this.id},"*")}),e.appendChild(i),t.appendChild(e)}renderImageMapSection(t){const e=document.createElement("div");e.className="image-map-actions";const i=document.createElement("div");i.className="undo-redo-group";const s=document.createElement("button");s.type="button",s.className="undo-btn action-btn",s.innerHTML=le,s.title="Undo (Ctrl+Z)",s.disabled=!this.canUndo(),s.addEventListener("click",()=>this.undo()),i.appendChild(s);const n=document.createElement("button");n.type="button",n.className="redo-btn action-btn",n.innerHTML=re,n.title="Redo (Ctrl+Y)",n.disabled=!this.canRedo(),n.addEventListener("click",()=>this.redo()),i.appendChild(n),e.appendChild(i);const o=document.createElement("button");o.type="button",o.className="replace-btn",o.textContent="Replace Image",o.addEventListener("click",()=>{window.postMessage({type:"OPEN_FILE_MANAGER_MODAL",settingId:this.id},"*")}),e.appendChild(o);const a=document.createElement("button");a.type="button",a.className="clear-all-btn",a.textContent="Clear All Markers",a.addEventListener("click",()=>this.handleClearAllMarkers()),e.appendChild(a),t.appendChild(e);const l=document.createElement("div");l.className="image-map-container";const r=document.createElement("div");r.className="image-map-wrapper",r.addEventListener("mousemove",this.boundHandleMarkerDrag),r.addEventListener("mouseup",this.boundStopDragging),r.addEventListener("mouseleave",this.boundStopDragging),this.imageElement=document.createElement("img"),this.imageElement.className="image-map-image",this.imageElement.src=this.value.imageUrl,this.imageElement.addEventListener("load",()=>this.recordImageNaturalSize()),this.imageElement.addEventListener("click",c=>this.handleImageClick(c)),r.appendChild(this.imageElement),this.cursorTooltip=document.createElement("div"),this.cursorTooltip.className="marker-cursor-tooltip",r.appendChild(this.cursorTooltip),this.imageElement.addEventListener("mouseenter",()=>this.showCursorTooltip()),this.imageElement.addEventListener("mouseleave",()=>this.hideCursorTooltip()),this.imageElement.addEventListener("mousemove",c=>this.updateCursorTooltip(c)),this.value&&this.value.markers&&this.value.markers.forEach(c=>{const p=this.createMarkerElement(c);r.appendChild(p)}),l.appendChild(r),t.appendChild(l)}renderSidebar(t){var c,p;const e=document.createElement("div");e.className="prize-counter";const i=this.props.maxMarkers||10,s=((c=this.value)==null?void 0:c.markers.length)||0,n=s===i;e.textContent=`Prizes ${s}/${i}`,n&&e.classList.add("complete"),t.appendChild(e);const o=document.createElement("div");o.className="prize-list";const a=((p=this.value)==null?void 0:p.markers)||[],l=new Map;a.forEach(d=>l.set(d.index,d));for(let d=1;d<=i;d++){const g=l.get(d),C=!!g,m=(g==null?void 0:g.prizeName)||this.props.prizeMap&&this.props.prizeMap[d-1]||`Prize #${d}`,u=document.createElement("div");u.className=`prize-item ${C?"placed":"missing"}`;const f=document.createElement("div");f.className="prize-index",f.textContent=String(d);const v=document.createElement("div");v.className="prize-label";const y=document.createElement("div");y.className="prize-title",y.textContent=`Prize #${d}`;const E=document.createElement("div");E.className="prize-subtitle",E.textContent=C?m:"Not Placed",v.appendChild(y),v.appendChild(E);const L=document.createElement("div");L.className=`prize-status ${C?"placed":"missing"}`,L.innerHTML=C?ce:he,u.appendChild(f),u.appendChild(v),u.appendChild(L),o.appendChild(u)}t.appendChild(o);const r=document.createElement("button");r.type="button",r.className="sidebar-save-btn",r.textContent="Save",n?r.title="Save and close":(r.disabled=!0,r.title=`Add ${i-s} more prize(s) to save`),r.addEventListener("click",()=>{n&&(this.triggerChange(),this.closePopover(!0))}),t.appendChild(r)}createMarkerElement(t){const e=document.createElement("div");e.className="marker-container",e.style.left=`${t.x}%`,e.style.top=`${t.y}%`,e.setAttribute("data-marker-id",String(t.id));const i=document.createElement("div");i.className="image-map-marker";const s=document.createElement("span");s.className="marker-number",s.textContent=String(t.index),i.appendChild(s);const n=document.createElement("button");n.type="button",n.className="marker-delete-btn",n.innerHTML=ae,n.addEventListener("click",a=>{a.stopPropagation(),this.handleDeleteMarker(t.id)}),i.appendChild(n),e.appendChild(i);const o=document.createElement("div");return o.className="marker-label",t.prizeName?o.textContent=t.prizeName:o.textContent=`Prize ${t.index}`,e.appendChild(o),e.addEventListener("mousedown",a=>{a.stopPropagation(),a.preventDefault(),this.draggingMarkerId=t.id,e.classList.add("dragging")}),e}handleImageUpload(t){const e=this.lastImageNaturalSize;if(!["image/jpeg","image/jpg","image/png","image/gif","image/webp"].includes(t.type)){this.showError("Invalid file type. Please upload a JPEG, PNG, GIF, or WebP image.");return}const s=(this.props.maxFileSizeMB||5)*1024*1024;if(t.size>s){const o=(t.size/1048576).toFixed(1);this.showError(`File size (${o}MB) exceeds ${this.props.maxFileSizeMB}MB limit.`);return}const n=new FileReader;n.onload=o=>{var l;const a=(l=o.target)==null?void 0:l.result;if(typeof a=="string"){const r=new Image;r.onload=()=>{var d;const c={width:r.naturalWidth||0,height:r.naturalHeight||0},p=this.scaleMarkersForNewImage(((d=this.value)==null?void 0:d.markers)||[],e,c);this.value={imageUrl:a,markers:p},this.lastImageNaturalSize=c,this.history=[JSON.parse(JSON.stringify(p))],this.historyIndex=0,this.updateUndoRedoButtons(),this.updateButtonDisplay(),this.refreshPopoverContent(),this.triggerChange()},r.onerror=()=>{this.showError("Failed to read image file.")},r.src=a}},n.onerror=()=>{this.showError("Failed to read image file.")},n.readAsDataURL(t)}handleImageClick(t){if(this.draggingMarkerId!==null||!this.value||!this.imageElement)return;if(this.value.markers.length>=(this.props.maxMarkers||10)){this.showError(`Maximum of ${this.props.maxMarkers||10} markers allowed.`);return}const e=this.imageElement.getBoundingClientRect(),i=(t.clientX-e.left)/e.width*100,s=(t.clientY-e.top)/e.height*100,n=this.value.markers.map(c=>c.index).sort((c,p)=>c-p);let o=1;for(const c of n)if(c===o)o++;else break;let a;this.props.prizeMap&&this.props.prizeMap.length>0&&(a=this.props.prizeMap[o-1]);const l={id:Date.now(),index:o,x:Math.min(100,Math.max(0,i)),y:Math.min(100,Math.max(0,s)),prizeName:a},r=[...this.value.markers,l];this.setMarkers(r),this.saveState(),this.refreshPopoverContent(),this.updateButtonDisplay(),this.triggerChange()}handleMarkerDrag(t){var r;if(this.draggingMarkerId===null||!this.imageElement||!this.value)return;const e=this.imageElement.getBoundingClientRect(),i=(t.clientX-e.left)/e.width*100,s=(t.clientY-e.top)/e.height*100,n=Math.min(100,Math.max(0,i)),o=Math.min(100,Math.max(0,s)),a=this.value.markers.map(c=>c.id===this.draggingMarkerId?{...c,x:n,y:o}:c),l=(r=this.popoverEl)==null?void 0:r.querySelector(`[data-marker-id="${this.draggingMarkerId}"]`);l&&(l.style.left=`${n}%`,l.style.top=`${o}%`),this.setMarkers(a)}stopDragging(){var t;if(this.draggingMarkerId!==null){const e=(t=this.popoverEl)==null?void 0:t.querySelector(`[data-marker-id="${this.draggingMarkerId}"]`);e==null||e.classList.remove("dragging"),this.draggingMarkerId=null,this.saveState(),this.triggerChange()}}handleDeleteMarker(t){if(!this.value||this.value.markers.findIndex(s=>s.id===t)===-1)return;const i=this.value.markers.filter(s=>s.id!==t);this.setMarkers(i),this.saveState(),this.refreshPopoverContent(),this.updateButtonDisplay(),this.triggerChange()}handleClearAllMarkers(){this.value&&(this.setMarkers([]),this.saveState(),this.refreshPopoverContent(),this.updateButtonDisplay(),this.triggerChange())}getNextPrizeInfo(){if(!this.value)return{index:1,name:"Prize 1"};const t=this.value.markers.map(s=>s.index).sort((s,n)=>s-n);let e=1;for(const s of t)if(s===e)e++;else break;let i=`Prize ${e}`;if(this.props.prizeMap&&this.props.prizeMap.length>0){const s=this.props.prizeMap[e-1];s&&(i=s)}return{index:e,name:i}}showCursorTooltip(){if(!this.cursorTooltip||!this.value||this.value.markers.length>=(this.props.maxMarkers||10))return;const t=this.getNextPrizeInfo();this.cursorTooltip.textContent=`Add: ${t.name}`,this.cursorTooltip.classList.add("visible")}hideCursorTooltip(){this.cursorTooltip&&this.cursorTooltip.classList.remove("visible")}updateCursorTooltip(t){if(!this.cursorTooltip||!this.imageElement)return;const e=this.imageElement.getBoundingClientRect(),i=t.clientX-e.left,s=t.clientY-e.top;this.cursorTooltip.style.left=`${i}px`,this.cursorTooltip.style.top=`${s}px`}saveState(){if(this.isUndoRedoOperation||!this.value)return;const t=JSON.parse(JSON.stringify(this.value.markers));if(this.historyIndex>=0&&this.history.length>0){const e=this.history[this.historyIndex];if(JSON.stringify(e)===JSON.stringify(t))return}this.history=this.history.slice(0,this.historyIndex+1),this.history.push(t),this.historyIndex++,this.history.length>50&&(this.history.shift(),this.historyIndex--),this.updateUndoRedoButtons()}canUndo(){return this.historyIndex>0}canRedo(){return this.historyIndex<this.history.length-1}undo(){if(!this.canUndo()||!this.value)return;this.historyIndex--,this.isUndoRedoOperation=!0;const t=JSON.parse(JSON.stringify(this.history[this.historyIndex]));this.setMarkers(t),this.refreshPopoverContent(),this.updateButtonDisplay(),this.triggerChange(),this.isUndoRedoOperation=!1,this.updateUndoRedoButtons()}redo(){if(!this.canRedo()||!this.value)return;this.historyIndex++,this.isUndoRedoOperation=!0;const t=JSON.parse(JSON.stringify(this.history[this.historyIndex]));this.setMarkers(t),this.refreshPopoverContent(),this.updateButtonDisplay(),this.triggerChange(),this.isUndoRedoOperation=!1,this.updateUndoRedoButtons()}updateUndoRedoButtons(){if(!this.popoverEl)return;const t=this.popoverEl.querySelector(".undo-btn"),e=this.popoverEl.querySelector(".redo-btn");t&&(t.disabled=!this.canUndo()),e&&(e.disabled=!this.canRedo())}showError(t){const e=document.createElement("div");if(e.className="image-map-error-toast",e.textContent=t,e.style.cssText=`
|
|
230
230
|
position: fixed;
|
|
231
231
|
top: 20px;
|
|
232
232
|
right: 20px;
|
|
@@ -360,15 +360,15 @@
|
|
|
360
360
|
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="13" viewBox="0 0 14 13" fill="none">
|
|
361
361
|
<path d="M1 2.75C1 2.05109 1 1.70163 1.11418 1.42597C1.26642 1.05843 1.55843 0.766422 1.92597 0.614181C2.20163 0.5 2.55109 0.5 3.25 0.5H10.75C11.4489 0.5 11.7984 0.5 12.074 0.614181C12.4416 0.766422 12.7336 1.05843 12.8858 1.42597C13 1.70163 13 2.05109 13 2.75M4.75 12.5H9.25M7 0.5V12.5" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
362
362
|
</svg>
|
|
363
|
-
`,
|
|
363
|
+
`,Ie=`
|
|
364
364
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
365
365
|
<path d="M3 5.75C3 5.05109 3 4.70163 3.11418 4.42597C3.26642 4.05843 3.55843 3.76642 3.92597 3.61418C4.20163 3.5 4.55109 3.5 5.25 3.5H12.75C13.4489 3.5 13.7984 3.5 14.074 3.61418C14.4416 3.76642 14.7336 4.05843 14.8858 4.42597C15 4.70163 15 5.05109 15 5.75M6 15.5H12M7.6875 3.5V15.5M10.3125 3.5V15.5" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
366
366
|
</svg>
|
|
367
|
-
`,
|
|
367
|
+
`,Ne=`
|
|
368
368
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
369
369
|
<path d="M6 5.75H12M9 5.75V13.25M5.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.75H5.85C4.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.35V12.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.25Z" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
370
370
|
</svg>
|
|
371
|
-
`;class Ve extends H{constructor(t={}){const{showAlign:e=t.showAlign??!0,...i}=t;super({title:i.title||"Typography",collapsed:i.collapsed,settings:(()=>{const s={color:new U({title:"Color",default:i.colorDefault??"#001E1E"}),fontFamily:new Q({title:"Font",icon:Se,default:i.fontFamilyDefault??"Satoshi",options:i.fontFamilyOptions??[{name:"Alt",value:"Croco Sans Black Caps Alt"},{name:"Regular",value:"Croco Sans Caps Regular"},{name:"Caps",value:"Croco Sans Black Caps"},{name:"FaraGo",value:"'FiraGO', sans-serif"}],getOptions:i.fontFamilyGetOptions,getOptionsAsync:i.fontFamilyGetOptionsAsync}),fontWeight:new Q({title:"Weight",icon:
|
|
371
|
+
`;class Ve extends H{constructor(t={}){const{showAlign:e=t.showAlign??!0,...i}=t;super({title:i.title||"Typography",collapsed:i.collapsed,settings:(()=>{const s={color:new U({title:"Color",default:i.colorDefault??"#001E1E"}),fontFamily:new Q({title:"Font",icon:Se,default:i.fontFamilyDefault??"Satoshi",options:i.fontFamilyOptions??[{name:"Alt",value:"Croco Sans Black Caps Alt"},{name:"Regular",value:"Croco Sans Caps Regular"},{name:"Caps",value:"Croco Sans Black Caps"},{name:"FaraGo",value:"'FiraGO', sans-serif"}],getOptions:i.fontFamilyGetOptions,getOptionsAsync:i.fontFamilyGetOptionsAsync}),fontWeight:new Q({title:"Weight",icon:Ie,default:i.fontWeightDefault??"400",options:i.fontWeightOptions??[{name:"Regular",value:"400"},{name:"Medium",value:"500"},{name:"Bold",value:"600"}],getOptions:i.fontWeightGetOptions,getOptionsAsync:i.fontWeightGetOptionsAsync}),fontSize:new $({title:"Size",icon:Ne,default:i.fontSizeDefault??12,suffix:"px",mobile:i.fontSizeMobileDefault})};return e?{...s,align:new kt({title:"Align",default:i.alignDefault??"center"})}:s})()})}getCssCode(){var o;const t=this.settings.color.getValue()??"#000000",e=this.settings.fontFamily.value??"Satoshi",i=this.settings.fontWeight.value??"bold",s=this.settings.fontSize.value??12,n=((o=this.settings.align)==null?void 0:o.value)??"left";return`
|
|
372
372
|
color: ${t};
|
|
373
373
|
font-family: ${e};
|
|
374
374
|
font-weight: ${i};
|
|
@@ -280,9 +280,9 @@ const ot = (h, t, e) => {
|
|
|
280
280
|
o = d.left, a = d.top, document.addEventListener("mousemove", r), document.addEventListener("mouseup", c), document.body.style.userSelect = "none";
|
|
281
281
|
}, r = (p) => {
|
|
282
282
|
if (!i) return;
|
|
283
|
-
const d = p.clientX - s, g = p.clientY - n, C = window.innerWidth, m = window.innerHeight, u = t.offsetWidth,
|
|
284
|
-
let
|
|
285
|
-
|
|
283
|
+
const d = p.clientX - s, g = p.clientY - n, C = window.innerWidth, m = window.innerHeight, u = t.offsetWidth, f = t.offsetHeight;
|
|
284
|
+
let v = o + d, y = a + g;
|
|
285
|
+
v = Math.max(8, Math.min(C - u - 8, v)), y = Math.max(8, Math.min(m - f - 8, y)), t.style.left = `${v}px`, t.style.top = `${y}px`, e == null || e(v, y);
|
|
286
286
|
}, c = () => {
|
|
287
287
|
i = !1, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", c), document.body.style.userSelect = "";
|
|
288
288
|
};
|
|
@@ -390,7 +390,7 @@ const ot = (h, t, e) => {
|
|
|
390
390
|
/^rgba?\s*\([^)]+\)$/,
|
|
391
391
|
/^hsla?\s*\([^)]+\)$/,
|
|
392
392
|
/^[a-zA-Z]+$/
|
|
393
|
-
].some((e) => e.test(h.trim())),
|
|
393
|
+
].some((e) => e.test(h.trim())), It = (h) => {
|
|
394
394
|
if (typeof document > "u")
|
|
395
395
|
return ft(h) || !!F(h);
|
|
396
396
|
const t = document.createElement("div");
|
|
@@ -454,7 +454,7 @@ const ot = (h, t, e) => {
|
|
|
454
454
|
for (let a = s; a < h.length && n > 0; a++)
|
|
455
455
|
h[a] === "(" ? n++ : h[a] === ")" && n--, o = a;
|
|
456
456
|
return n === 0 ? h.substring(s, o) : null;
|
|
457
|
-
},
|
|
457
|
+
}, Nt = (h) => {
|
|
458
458
|
const t = h.split(" ")[0].toLowerCase();
|
|
459
459
|
return [
|
|
460
460
|
"circle",
|
|
@@ -491,7 +491,7 @@ const ot = (h, t, e) => {
|
|
|
491
491
|
};
|
|
492
492
|
}, T = (h) => {
|
|
493
493
|
const t = h.replace(/;$/, "").trim();
|
|
494
|
-
if (
|
|
494
|
+
if (It(t)) {
|
|
495
495
|
const s = Ct(t);
|
|
496
496
|
return A({ type: "solid", angle: 0, stops: [s] });
|
|
497
497
|
}
|
|
@@ -518,7 +518,7 @@ const ot = (h, t, e) => {
|
|
|
518
518
|
}
|
|
519
519
|
const i = dt(t, "radial-gradient");
|
|
520
520
|
if (i) {
|
|
521
|
-
const s = ht(i), n = s[0] && !
|
|
521
|
+
const s = ht(i), n = s[0] && !Nt(s[0]) ? s.slice(1) : s, o = pt(n);
|
|
522
522
|
return o.length ? A({ type: "radial", angle: 0, stops: o }) : null;
|
|
523
523
|
}
|
|
524
524
|
return null;
|
|
@@ -775,18 +775,18 @@ class ut {
|
|
|
775
775
|
m.className = "color-picker-format-section";
|
|
776
776
|
const u = document.createElement("select");
|
|
777
777
|
u.className = "color-picker-format-select", this.select = u;
|
|
778
|
-
const v = document.createElement("option");
|
|
779
|
-
v.value = "hex", v.textContent = "HEX";
|
|
780
778
|
const f = document.createElement("option");
|
|
781
|
-
f.value = "
|
|
779
|
+
f.value = "hex", f.textContent = "HEX";
|
|
780
|
+
const v = document.createElement("option");
|
|
781
|
+
v.value = "rgb", v.textContent = "RGB";
|
|
782
782
|
const y = document.createElement("option");
|
|
783
|
-
y.value = "hsl", y.textContent = "HSL", u.appendChild(
|
|
783
|
+
y.value = "hsl", y.textContent = "HSL", u.appendChild(f), u.appendChild(v), u.appendChild(y);
|
|
784
784
|
const b = document.createElement("input");
|
|
785
785
|
b.type = "text", b.className = "color-picker-color-input", b.value = this.currentColor, this.input = b;
|
|
786
786
|
const L = document.createElement("div");
|
|
787
787
|
L.className = "color-picker-input-container";
|
|
788
|
-
const
|
|
789
|
-
return
|
|
788
|
+
const N = document.createElement("button");
|
|
789
|
+
return N.className = "color-picker-copy-inside", N.textContent = "Copy", L.appendChild(b), L.appendChild(N), m.appendChild(u), m.appendChild(L), t.appendChild(e), t.appendChild(n), t.appendChild(a), t.appendChild(C.container), t.appendChild(m), t.addEventListener("click", (E) => E.stopPropagation()), this.bind(n, c, d, b, u, N, l), t;
|
|
790
790
|
}
|
|
791
791
|
createBackdrop() {
|
|
792
792
|
const t = document.createElement("div");
|
|
@@ -794,18 +794,18 @@ class ut {
|
|
|
794
794
|
}
|
|
795
795
|
bind(t, e, i, s, n, o, a) {
|
|
796
796
|
const l = (p) => {
|
|
797
|
-
var
|
|
797
|
+
var v;
|
|
798
798
|
const d = t.getBoundingClientRect(), g = Math.max(0, Math.min(1, (p.clientX - d.left) / d.width)), C = Math.max(0, Math.min(1, (p.clientY - d.top) / d.height));
|
|
799
799
|
this.colorMarker.style.left = `${g * 100}%`, this.colorMarker.style.top = `${C * 100}%`;
|
|
800
|
-
const u = this.parsePercentage(this.hueMarker.style.left || "0%") * 360,
|
|
801
|
-
this.currentColor =
|
|
800
|
+
const u = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, f = W(u, g, 1 - C);
|
|
801
|
+
this.currentColor = f, this.syncInput(), this.updateOpacityBg(), (v = this.onChange) == null || v.call(this, f, this.currentOpacity);
|
|
802
802
|
}, r = (p) => {
|
|
803
|
-
var
|
|
803
|
+
var v;
|
|
804
804
|
const d = e.getBoundingClientRect();
|
|
805
805
|
let g = Math.max(0, Math.min(1, (p.clientX - d.left) / d.width));
|
|
806
806
|
this.hueMarker.style.left = `${g * 100}%`;
|
|
807
|
-
const C = g * 360, m = this.parsePercentage(this.colorMarker.style.left || "0%"), u = this.parsePercentage(this.colorMarker.style.top || "0%"),
|
|
808
|
-
this.currentColor =
|
|
807
|
+
const C = g * 360, m = this.parsePercentage(this.colorMarker.style.left || "0%"), u = this.parsePercentage(this.colorMarker.style.top || "0%"), f = W(C, m, 1 - u);
|
|
808
|
+
this.currentColor = f, this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${C}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), (v = this.onChange) == null || v.call(this, f, this.currentOpacity);
|
|
809
809
|
}, c = (p) => {
|
|
810
810
|
var C;
|
|
811
811
|
const d = i.getBoundingClientRect(), g = Math.max(0, Math.min(1, (p.clientX - d.left) / d.width));
|
|
@@ -907,8 +907,8 @@ class ut {
|
|
|
907
907
|
let g = r.right + 8, C = r.top;
|
|
908
908
|
const m = c - r.right, u = r.left;
|
|
909
909
|
m >= a + d ? g = r.right + 8 : u >= a + d ? g = r.left - a - 8 : g = Math.max(d, (c - a) / 2);
|
|
910
|
-
const
|
|
911
|
-
|
|
910
|
+
const f = p - r.bottom, v = r.top;
|
|
911
|
+
f >= l + d ? C = r.bottom + 8 : v >= l + d ? C = r.top - l - 8 : f > v ? (C = r.bottom + 8, C + l > p - d && (C = p - l - d)) : (C = r.top - l - 8, C < d && (C = d)), this.element.style.left = `${g}px`, this.element.style.top = `${C}px`;
|
|
912
912
|
}
|
|
913
913
|
close(t) {
|
|
914
914
|
var e;
|
|
@@ -969,48 +969,52 @@ class Bt {
|
|
|
969
969
|
m.value = "rgb", m.textContent = "RGB";
|
|
970
970
|
const u = document.createElement("option");
|
|
971
971
|
u.value = "hsl", u.textContent = "HSL", g.appendChild(C), g.appendChild(m), g.appendChild(u);
|
|
972
|
-
const
|
|
973
|
-
|
|
974
|
-
const
|
|
975
|
-
|
|
972
|
+
const f = document.createElement("input");
|
|
973
|
+
f.type = "text", f.className = "color-picker-color-input", this.input = f;
|
|
974
|
+
const v = document.createElement("div");
|
|
975
|
+
v.className = "color-picker-input-container";
|
|
976
976
|
const y = document.createElement("button");
|
|
977
|
-
return y.className = "color-picker-copy-inside", y.textContent = "Copy",
|
|
977
|
+
return y.className = "color-picker-copy-inside", y.textContent = "Copy", v.appendChild(f), v.appendChild(y), d.appendChild(g), d.appendChild(v), t.appendChild(e), t.appendChild(s), t.appendChild(d), t.appendChild(p.container), this.bind(e, a, r, f, g, y, n), t;
|
|
978
978
|
}
|
|
979
979
|
bind(t, e, i, s, n, o, a) {
|
|
980
|
-
const l = (d) => {
|
|
981
|
-
const
|
|
982
|
-
this.colorMarker.style.left = `${
|
|
983
|
-
const v = this.parsePercentage(this.hueMarker.style.left || "0%") * 360,
|
|
984
|
-
this.currentColor =
|
|
985
|
-
}, r = (d) => {
|
|
986
|
-
const
|
|
987
|
-
this.hueMarker.style.left = `${
|
|
988
|
-
const
|
|
989
|
-
this.currentColor =
|
|
990
|
-
linear-gradient(to right, #fff, hsl(${
|
|
991
|
-
}, c = (d) => {
|
|
992
|
-
const
|
|
993
|
-
this.opacityMarker.style.left = `${
|
|
994
|
-
}, p = (d, g) => {
|
|
995
|
-
d.preventDefault(), this.isDragging = !0, g(d);
|
|
996
|
-
let
|
|
997
|
-
const
|
|
998
|
-
this.
|
|
980
|
+
const l = (d, g) => {
|
|
981
|
+
const C = g || t.getBoundingClientRect(), m = Math.max(0, Math.min(1, (d.clientX - C.left) / C.width)), u = Math.max(0, Math.min(1, (d.clientY - C.top) / C.height));
|
|
982
|
+
this.colorMarker.style.left = `${m * 100}%`, this.colorMarker.style.top = `${u * 100}%`;
|
|
983
|
+
const v = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, y = W(v, m, 1 - u);
|
|
984
|
+
this.currentColor = y, this.syncInput(), this.updateOpacityBg(), this.queueChange();
|
|
985
|
+
}, r = (d, g) => {
|
|
986
|
+
const C = g || e.getBoundingClientRect(), m = Math.max(0, Math.min(1, (d.clientX - C.left) / C.width));
|
|
987
|
+
this.hueMarker.style.left = `${m * 100}%`;
|
|
988
|
+
const u = m * 360, f = this.parsePercentage(this.colorMarker.style.left || "0%"), v = this.parsePercentage(this.colorMarker.style.top || "0%"), y = W(u, f, 1 - v);
|
|
989
|
+
this.currentColor = y, this.colorArea.style.background = `linear-gradient(to top, #000, transparent),
|
|
990
|
+
linear-gradient(to right, #fff, hsl(${u}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), this.queueChange();
|
|
991
|
+
}, c = (d, g) => {
|
|
992
|
+
const C = g || i.getBoundingClientRect(), m = Math.max(0, Math.min(1, (d.clientX - C.left) / C.width));
|
|
993
|
+
this.opacityMarker.style.left = `${m * 100}%`, this.currentOpacity = this.clampOpacity(m * 100), this.queueChange();
|
|
994
|
+
}, p = (d, g, C) => {
|
|
995
|
+
d.preventDefault(), this.isDragging = !0, this.cachedRect = C.getBoundingClientRect(), g(d, this.cachedRect);
|
|
996
|
+
let m = null, u;
|
|
997
|
+
const f = () => {
|
|
998
|
+
this.dragRafId === void 0 && (this.dragRafId = window.requestAnimationFrame(() => {
|
|
999
|
+
this.dragRafId = void 0, m && this.cachedRect && g(m, this.cachedRect);
|
|
1000
|
+
}));
|
|
1001
|
+
}, v = () => {
|
|
1002
|
+
this.isDragging && (this.isDragging = !1, this.dragRafId !== void 0 && (cancelAnimationFrame(this.dragRafId), this.dragRafId = void 0), this.cachedRect = void 0, m = null, this.flushChange(), document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", v), window.removeEventListener("blur", v), this.applyPendingExternal());
|
|
999
1003
|
};
|
|
1000
|
-
|
|
1001
|
-
if (!
|
|
1002
|
-
|
|
1004
|
+
u = (y) => {
|
|
1005
|
+
if (!y.buttons) {
|
|
1006
|
+
v();
|
|
1003
1007
|
return;
|
|
1004
1008
|
}
|
|
1005
|
-
|
|
1006
|
-
}, document.addEventListener("mousemove",
|
|
1009
|
+
m = y, f();
|
|
1010
|
+
}, document.addEventListener("mousemove", u), document.addEventListener("mouseup", v), window.addEventListener("blur", v);
|
|
1007
1011
|
};
|
|
1008
1012
|
t.addEventListener("mousedown", (d) => {
|
|
1009
|
-
p(d, l);
|
|
1013
|
+
p(d, l, t);
|
|
1010
1014
|
}), e.addEventListener("mousedown", (d) => {
|
|
1011
|
-
p(d, r);
|
|
1015
|
+
p(d, r, e);
|
|
1012
1016
|
}), i.addEventListener("mousedown", (d) => {
|
|
1013
|
-
p(d, c);
|
|
1017
|
+
p(d, c, i);
|
|
1014
1018
|
}), n.addEventListener("change", () => {
|
|
1015
1019
|
this.syncInput();
|
|
1016
1020
|
}), s.addEventListener("input", () => {
|
|
@@ -1405,28 +1409,28 @@ const V = class V extends x {
|
|
|
1405
1409
|
], C = this.globalSearchQuery.toLowerCase();
|
|
1406
1410
|
let m;
|
|
1407
1411
|
this.globalLayoutMode === "list" ? (m = document.createElement("div"), m.className = "global-colors-list") : (m = document.createElement("div"), m.className = "global-colors-grid"), p.appendChild(m), g.forEach((u) => {
|
|
1408
|
-
const
|
|
1409
|
-
|
|
1412
|
+
const f = Object.entries(d).filter(([v]) => !u.keys.includes(v) && u.title !== "Global Colors" ? !1 : u.keys.includes(v) && v.toLowerCase().includes(C));
|
|
1413
|
+
f.length !== 0 && f.forEach(([v, y]) => {
|
|
1410
1414
|
if (this.globalLayoutMode === "list") {
|
|
1411
1415
|
const b = document.createElement("div");
|
|
1412
1416
|
b.className = "global-color-row";
|
|
1413
1417
|
const L = document.createElement("div");
|
|
1414
1418
|
L.className = "global-color-circle";
|
|
1415
|
-
const
|
|
1416
|
-
L.style.background =
|
|
1419
|
+
const N = this.resolveGlobalVarColor(y);
|
|
1420
|
+
L.style.background = N, (this.linkedGlobalVariable === `var(--${v})` || e.color === `var(--${v})`) && L.classList.add("selected");
|
|
1417
1421
|
const w = document.createElement("span");
|
|
1418
|
-
w.className = "global-color-label", w.textContent =
|
|
1419
|
-
|
|
1420
|
-
const D = `var(--${
|
|
1422
|
+
w.className = "global-color-label", w.textContent = v.split("-").map((I) => I.charAt(0).toUpperCase() + I.slice(1)).join(" "), b.appendChild(L), b.appendChild(w), b.addEventListener("click", (I) => {
|
|
1423
|
+
I.preventDefault();
|
|
1424
|
+
const D = `var(--${v})`;
|
|
1421
1425
|
this.setValue(D), this.pendingSolidColor = D, i(p);
|
|
1422
1426
|
}), m.appendChild(b);
|
|
1423
1427
|
} else {
|
|
1424
1428
|
const b = document.createElement("div");
|
|
1425
1429
|
b.className = "global-color-circle";
|
|
1426
1430
|
const L = this.resolveGlobalVarColor(y);
|
|
1427
|
-
b.style.background = L, b.title =
|
|
1431
|
+
b.style.background = L, b.title = v.split("-").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" "), (this.linkedGlobalVariable === `var(--${v})` || e.color === `var(--${v})`) && b.classList.add("selected"), b.addEventListener("click", (E) => {
|
|
1428
1432
|
E.preventDefault();
|
|
1429
|
-
const w = `var(--${
|
|
1433
|
+
const w = `var(--${v})`;
|
|
1430
1434
|
this.setValue(w), this.pendingSolidColor = w, i(p);
|
|
1431
1435
|
}), m.appendChild(b);
|
|
1432
1436
|
}
|
|
@@ -1494,11 +1498,11 @@ const V = class V extends x {
|
|
|
1494
1498
|
const u = parseInt(m.target.value);
|
|
1495
1499
|
!Number.isNaN(u) && this.value && (this.value.angle = Math.max(0, Math.min(360, u)), this.debouncedPreviewUpdate());
|
|
1496
1500
|
}), e.addEventListener("blur", (m) => {
|
|
1497
|
-
var
|
|
1501
|
+
var v;
|
|
1498
1502
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null);
|
|
1499
1503
|
const u = m.target;
|
|
1500
|
-
let
|
|
1501
|
-
Number.isNaN(
|
|
1504
|
+
let f = parseInt(u.value);
|
|
1505
|
+
Number.isNaN(f) && (f = ((v = this.value) == null ? void 0 : v.angle) ?? 0), f = Math.max(0, Math.min(360, f)), this.value && (this.value.angle = f), u.value = `${f}°`, this.updateGradientPreview(), this.updateUI(), this.triggerChange();
|
|
1502
1506
|
}), C.addEventListener("click", () => {
|
|
1503
1507
|
this.clearGlobalBindingForCustomChange(), !(!this.value || !this.value.stops) && (this.value.stops.forEach((m) => {
|
|
1504
1508
|
m.position = 100 - m.position;
|
|
@@ -1554,32 +1558,32 @@ const V = class V extends x {
|
|
|
1554
1558
|
o.className = "gstop-chip";
|
|
1555
1559
|
const a = this.resolveGlobalVarColor(i.color);
|
|
1556
1560
|
o.style.backgroundColor = a, n.appendChild(o);
|
|
1557
|
-
const l = new ut((u,
|
|
1558
|
-
this.clearGlobalBindingForCustomChange(), this.value && this.value.stops[s] && (this.value.stops[s].color = u,
|
|
1561
|
+
const l = new ut((u, f) => {
|
|
1562
|
+
this.clearGlobalBindingForCustomChange(), this.value && this.value.stops[s] && (this.value.stops[s].color = u, f !== void 0 && (this.value.stops[s].opacity = f), o.style.backgroundColor = u, this.updateGradientPreview(), this.updateStopsList(), this.updateUI(), this.triggerChange());
|
|
1559
1563
|
}, "solid");
|
|
1560
1564
|
let r = !1, c = !1, p = 0, d = 0;
|
|
1561
1565
|
const g = (u) => {
|
|
1562
1566
|
r = !0, c = !1, p = u.clientX, d = this.value.stops[s].position, n.classList.add("selected"), document.addEventListener("mousemove", C), document.addEventListener("mouseup", m), u.preventDefault(), u.stopPropagation();
|
|
1563
1567
|
}, C = (u) => {
|
|
1564
1568
|
if (!r || !this.value) return;
|
|
1565
|
-
const
|
|
1566
|
-
if (Math.abs(
|
|
1569
|
+
const f = u.clientX - p;
|
|
1570
|
+
if (Math.abs(f) > 3 && (c = !0), c) {
|
|
1567
1571
|
this.clearGlobalBindingForCustomChange();
|
|
1568
|
-
const
|
|
1569
|
-
let y = d +
|
|
1572
|
+
const v = e.getBoundingClientRect();
|
|
1573
|
+
let y = d + f / v.width * 100;
|
|
1570
1574
|
y = Math.max(0, Math.min(100, y)), this.value.stops[s].position = Math.round(y), n.style.left = `${y}%`, this.updateGradientPreview();
|
|
1571
1575
|
}
|
|
1572
1576
|
}, m = (u) => {
|
|
1573
|
-
var
|
|
1577
|
+
var f;
|
|
1574
1578
|
if (r)
|
|
1575
1579
|
if (r = !1, n.classList.remove("selected"), document.removeEventListener("mousemove", C), document.removeEventListener("mouseup", m), c)
|
|
1576
|
-
this.value && (this.value.stops.sort((
|
|
1580
|
+
this.value && (this.value.stops.sort((v, y) => v.position - y.position), this.createHandles(t, e), this.updateStopsList()), this.updateUI(), this.triggerChange();
|
|
1577
1581
|
else {
|
|
1578
1582
|
u.stopPropagation();
|
|
1579
|
-
const
|
|
1580
|
-
|
|
1581
|
-
const y = this.resolveGlobalVarColor(
|
|
1582
|
-
l.open(y, o,
|
|
1583
|
+
const v = (f = this.value) == null ? void 0 : f.stops[s];
|
|
1584
|
+
v && setTimeout(() => {
|
|
1585
|
+
const y = this.resolveGlobalVarColor(v.color);
|
|
1586
|
+
l.open(y, o, v.opacity ?? 100);
|
|
1583
1587
|
}, 0);
|
|
1584
1588
|
}
|
|
1585
1589
|
};
|
|
@@ -1590,7 +1594,7 @@ const V = class V extends x {
|
|
|
1590
1594
|
var i;
|
|
1591
1595
|
const e = t || ((i = this.popoverEl) == null ? void 0 : i.querySelector(".gradient-stops"));
|
|
1592
1596
|
!e || !this.value || this.value.type === "solid" || !this.value.stops || (e.innerHTML = "", this.value.stops.forEach((s, n) => {
|
|
1593
|
-
var L,
|
|
1597
|
+
var L, N;
|
|
1594
1598
|
const o = document.createElement("div");
|
|
1595
1599
|
o.className = "gstop-row";
|
|
1596
1600
|
const a = document.createElement("div");
|
|
@@ -1606,21 +1610,21 @@ const V = class V extends x {
|
|
|
1606
1610
|
const g = document.createElement("button");
|
|
1607
1611
|
g.type = "button", g.className = "gstop-color-copy", g.textContent = "Copy", r.appendChild(p), r.appendChild(d), r.appendChild(g);
|
|
1608
1612
|
const C = document.createElement("button");
|
|
1609
|
-
C.type = "button", C.className = "gstop-del", C.innerHTML = Pt, C.disabled = (((
|
|
1613
|
+
C.type = "button", C.className = "gstop-del", C.innerHTML = Pt, C.disabled = (((N = (L = this.value) == null ? void 0 : L.stops) == null ? void 0 : N.length) || 0) <= 2, o.appendChild(a), o.appendChild(r), o.appendChild(C), e.appendChild(o);
|
|
1610
1614
|
const m = document.createElement("span");
|
|
1611
1615
|
m.className = "gstop-opacity-label", m.textContent = "Opacity";
|
|
1612
1616
|
const u = document.createElement("div");
|
|
1613
1617
|
u.className = "gstop-opacity-group";
|
|
1614
|
-
const
|
|
1615
|
-
|
|
1616
|
-
const
|
|
1617
|
-
|
|
1618
|
+
const f = document.createElement("input");
|
|
1619
|
+
f.type = "range", f.className = "gstop-opacity-slider", f.min = "0", f.max = "100", f.value = String(s.opacity ?? 100);
|
|
1620
|
+
const v = P(c);
|
|
1621
|
+
f.style.setProperty("--slider-color", `rgb(${v.r}, ${v.g}, ${v.b})`);
|
|
1618
1622
|
const y = document.createElement("span");
|
|
1619
|
-
y.className = "gstop-opacity-value", y.textContent = `${s.opacity ?? 100}%`, u.appendChild(
|
|
1623
|
+
y.className = "gstop-opacity-value", y.textContent = `${s.opacity ?? 100}%`, u.appendChild(f), u.appendChild(y);
|
|
1620
1624
|
const b = new ut((E, w) => {
|
|
1621
|
-
this.clearGlobalBindingForCustomChange(), d.value = E.replace("#", "").toUpperCase(), p.style.backgroundColor = E, this.value.stops[n].color = E, w !== void 0 && (this.value.stops[n].opacity = w,
|
|
1622
|
-
const
|
|
1623
|
-
|
|
1625
|
+
this.clearGlobalBindingForCustomChange(), d.value = E.replace("#", "").toUpperCase(), p.style.backgroundColor = E, this.value.stops[n].color = E, w !== void 0 && (this.value.stops[n].opacity = w, f.value = String(w), y.textContent = `${w}%`);
|
|
1626
|
+
const I = P(E);
|
|
1627
|
+
f.style.setProperty("--slider-color", `rgb(${I.r}, ${I.g}, ${I.b})`), this.updateGradientPreview(), this.createHandles(
|
|
1624
1628
|
this.popoverEl.querySelector(".gradient-handles"),
|
|
1625
1629
|
this.popoverEl.querySelector(".gradient-preview")
|
|
1626
1630
|
), this.updateUI(), this.triggerChange();
|
|
@@ -1634,8 +1638,8 @@ const V = class V extends x {
|
|
|
1634
1638
|
const E = d.value.trim(), w = E.startsWith("#") ? E : `#${E}`;
|
|
1635
1639
|
if (/^#[0-9A-Fa-f]{6}$/.test(w)) {
|
|
1636
1640
|
this.value.stops[n].color = w, p.style.backgroundColor = w;
|
|
1637
|
-
const
|
|
1638
|
-
|
|
1641
|
+
const I = P(w);
|
|
1642
|
+
f.style.setProperty("--slider-color", `rgb(${I.r}, ${I.g}, ${I.b})`), this.debouncedPreviewUpdate();
|
|
1639
1643
|
}
|
|
1640
1644
|
}), d.addEventListener("blur", () => {
|
|
1641
1645
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null), this.updateGradientPreview(), this.updateUI(), this.triggerChange();
|
|
@@ -1650,18 +1654,18 @@ const V = class V extends x {
|
|
|
1650
1654
|
w.value = w.value.replace("%", ""), w.select();
|
|
1651
1655
|
}), l.addEventListener("input", (E) => {
|
|
1652
1656
|
this.clearGlobalBindingForCustomChange();
|
|
1653
|
-
const w = E.target,
|
|
1654
|
-
if (!Number.isNaN(
|
|
1655
|
-
const D = Math.max(0, Math.min(100,
|
|
1657
|
+
const w = E.target, I = parseInt(w.value.replace(/[^\d]/g, ""), 10);
|
|
1658
|
+
if (!Number.isNaN(I)) {
|
|
1659
|
+
const D = Math.max(0, Math.min(100, I));
|
|
1656
1660
|
this.value.stops[n].position = D, w.value = `${D}%`, this.debouncedPreviewUpdate();
|
|
1657
1661
|
}
|
|
1658
1662
|
}), l.addEventListener("blur", (E) => {
|
|
1659
1663
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null);
|
|
1660
|
-
const w = E.target,
|
|
1661
|
-
if (Number.isNaN(
|
|
1664
|
+
const w = E.target, I = parseInt(w.value.replace(/[^\d]/g, ""), 10);
|
|
1665
|
+
if (Number.isNaN(I))
|
|
1662
1666
|
w.value = `${this.value.stops[n].position}%`;
|
|
1663
1667
|
else {
|
|
1664
|
-
const D = Math.max(0, Math.min(100,
|
|
1668
|
+
const D = Math.max(0, Math.min(100, I));
|
|
1665
1669
|
this.value.stops[n].position = D, w.value = `${D}%`;
|
|
1666
1670
|
}
|
|
1667
1671
|
this.updateGradientPreview(), this.createHandles(
|
|
@@ -1674,11 +1678,11 @@ const V = class V extends x {
|
|
|
1674
1678
|
this.popoverEl.querySelector(".gradient-handles"),
|
|
1675
1679
|
this.popoverEl.querySelector(".gradient-preview")
|
|
1676
1680
|
), this.updateStopsList(), this.updateGradientPreview(), this.updateUI(), ((E = document.activeElement) == null ? void 0 : E.tagName) !== "INPUT" && this.repositionPopover(), this.triggerChange());
|
|
1677
|
-
}),
|
|
1681
|
+
}), f.addEventListener("input", () => {
|
|
1678
1682
|
this.clearGlobalBindingForCustomChange();
|
|
1679
|
-
const E = parseInt(
|
|
1683
|
+
const E = parseInt(f.value, 10);
|
|
1680
1684
|
this.value.stops[n].opacity = Math.max(0, Math.min(100, E)), y.textContent = `${this.value.stops[n].opacity}%`, this.debouncedPreviewUpdate();
|
|
1681
|
-
}),
|
|
1685
|
+
}), f.addEventListener("change", () => {
|
|
1682
1686
|
this.clearGlobalBindingForCustomChange(), this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null), this.updateGradientPreview(), this.updateUI(), this.triggerChange();
|
|
1683
1687
|
});
|
|
1684
1688
|
}));
|
|
@@ -2603,16 +2607,16 @@ class O extends Gt {
|
|
|
2603
2607
|
u.textContent = "No global colors defined", u.style.gridColumn = "1 / -1", u.style.fontSize = "12px", u.style.color = "#666", a.appendChild(u);
|
|
2604
2608
|
return;
|
|
2605
2609
|
}
|
|
2606
|
-
Object.entries(m).forEach(([u,
|
|
2607
|
-
const
|
|
2608
|
-
|
|
2609
|
-
var L,
|
|
2610
|
+
Object.entries(m).forEach(([u, f]) => {
|
|
2611
|
+
const v = document.createElement("button");
|
|
2612
|
+
v.className = "global-color-btn", v.title = u, v.style.width = "30px", v.style.height = "30px", v.style.borderRadius = "50%", v.style.border = "1px solid #ddd", v.style.backgroundColor = f, v.style.cursor = "pointer", this.value === `var(--${u})` && (v.style.border = "2px solid #2196f3"), v.addEventListener("click", (y) => {
|
|
2613
|
+
var L, N;
|
|
2610
2614
|
y.preventDefault();
|
|
2611
2615
|
const b = `var(--${u})`;
|
|
2612
|
-
this.value = b, (L = this.onChange) == null || L.call(this, b), (
|
|
2616
|
+
this.value = b, (L = this.onChange) == null || L.call(this, b), (N = this.detectChange) == null || N.call(this, b), Array.from(a.children).forEach((E) => {
|
|
2613
2617
|
E.style.border = "1px solid #ddd";
|
|
2614
|
-
}),
|
|
2615
|
-
}), a.appendChild(
|
|
2618
|
+
}), v.style.border = "2px solid #2196f3", p.style.backgroundColor = f;
|
|
2619
|
+
}), a.appendChild(v);
|
|
2616
2620
|
});
|
|
2617
2621
|
} catch (m) {
|
|
2618
2622
|
console.error("ColorSetting: Error in renderGlobalOptions", m), a.innerHTML = "Error loading global options";
|
|
@@ -2627,8 +2631,8 @@ class O extends Gt {
|
|
|
2627
2631
|
const u = m.value.trim();
|
|
2628
2632
|
if (!u)
|
|
2629
2633
|
return e.classList.remove("error"), !0;
|
|
2630
|
-
const
|
|
2631
|
-
return
|
|
2634
|
+
const v = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(u);
|
|
2635
|
+
return v ? e.classList.remove("error") : e.classList.add("error"), v;
|
|
2632
2636
|
}, c = document.createElement("input");
|
|
2633
2637
|
c.type = "color", c.className = "color-picker", c.value = this.value && !this.value.startsWith("var(--") ? this.value : "#000000", c.setAttribute("aria-label", "Choose color"), c.setAttribute("title", "Click to open color picker"), this.getDataPropsPath() && c.setAttribute("data-test-id", this.getDataPropsPath()), this.colorInputEl = c;
|
|
2634
2638
|
const p = document.createElement("div");
|
|
@@ -2642,32 +2646,32 @@ class O extends Gt {
|
|
|
2642
2646
|
const g = document.createElement("input");
|
|
2643
2647
|
g.type = "text", g.className = "color-text-input", g.value = this.value || "", g.placeholder = "#000000", g.setAttribute("pattern", "#[0-9A-Fa-f]{6}"), g.setAttribute("title", "Enter a hex color value (e.g., #ff0000)"), g.setAttribute("aria-label", "Hex color value"), g.setAttribute("maxlength", "7"), this.getDataPropsPath() && g.setAttribute("data-test-id", `${this.getDataPropsPath()}_text`), this.textInputEl = g;
|
|
2644
2648
|
const C = (m) => {
|
|
2645
|
-
var
|
|
2649
|
+
var f, v;
|
|
2646
2650
|
let u = m.trim();
|
|
2647
2651
|
if (u && !u.startsWith("#") && !u.startsWith("var(") && /^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(u) && (u = "#" + u, this.textInputEl && (this.textInputEl.value = u)), this.textInputEl && r(this.textInputEl)) {
|
|
2648
2652
|
const y = O.normalizeColorValue(u);
|
|
2649
|
-
this.value = y, (
|
|
2653
|
+
this.value = y, (f = this.onChange) == null || f.call(this, y), (v = this.detectChange) == null || v.call(this, y), this.colorInputEl && (this.colorInputEl.value = y), p.style.backgroundColor = y;
|
|
2650
2654
|
}
|
|
2651
2655
|
};
|
|
2652
2656
|
return this.textInputEl.addEventListener("input", (m) => {
|
|
2653
2657
|
const u = m.target.value;
|
|
2654
2658
|
C(u);
|
|
2655
2659
|
}), this.textInputEl.addEventListener("paste", (m) => {
|
|
2656
|
-
var
|
|
2660
|
+
var f;
|
|
2657
2661
|
m.preventDefault();
|
|
2658
|
-
const u = ((
|
|
2662
|
+
const u = ((f = m.clipboardData) == null ? void 0 : f.getData("text")) || "";
|
|
2659
2663
|
this.textInputEl && (this.textInputEl.value = u.trim(), C(u));
|
|
2660
2664
|
}), this.textInputEl.addEventListener("keydown", (m) => {
|
|
2661
|
-
var u,
|
|
2662
|
-
m.key === "Enter" && (m.preventDefault(), C(((u = this.textInputEl) == null ? void 0 : u.value) || ""), (
|
|
2665
|
+
var u, f, v;
|
|
2666
|
+
m.key === "Enter" && (m.preventDefault(), C(((u = this.textInputEl) == null ? void 0 : u.value) || ""), (f = this.textInputEl) == null || f.blur()), m.key === "Escape" && (this.textInputEl && this.value && (this.textInputEl.value = this.value), (v = this.textInputEl) == null || v.blur(), e.classList.remove("error"));
|
|
2663
2667
|
}), this.colorInputEl.addEventListener("input", (m) => {
|
|
2664
|
-
var
|
|
2665
|
-
const u = m.target.value,
|
|
2666
|
-
this.value =
|
|
2668
|
+
var v, y;
|
|
2669
|
+
const u = m.target.value, f = O.normalizeColorValue(u);
|
|
2670
|
+
this.value = f, (v = this.onChange) == null || v.call(this, f), (y = this.detectChange) == null || y.call(this, f), this.textInputEl && (this.textInputEl.value = f), p.style.backgroundColor = f, e.classList.remove("error");
|
|
2667
2671
|
}), this.colorInputEl.addEventListener("change", (m) => {
|
|
2668
|
-
var
|
|
2669
|
-
const u = m.target.value,
|
|
2670
|
-
this.value =
|
|
2672
|
+
var v, y;
|
|
2673
|
+
const u = m.target.value, f = O.normalizeColorValue(u);
|
|
2674
|
+
this.value = f, (v = this.onChange) == null || v.call(this, f), (y = this.detectChange) == null || y.call(this, f), this.textInputEl && (this.textInputEl.value = f), p.style.backgroundColor = f;
|
|
2671
2675
|
}), o.appendChild(c), o.appendChild(p), o.appendChild(g), e.appendChild(i), e.appendChild(o), e.appendChild(a), t.appendChild(e), this.element = t, t;
|
|
2672
2676
|
}
|
|
2673
2677
|
getElement() {
|
|
@@ -3672,16 +3676,16 @@ const Kt = `
|
|
|
3672
3676
|
for (let d = 1; d <= i; d++) {
|
|
3673
3677
|
const g = l.get(d), C = !!g, m = (g == null ? void 0 : g.prizeName) || this.props.prizeMap && this.props.prizeMap[d - 1] || `Prize #${d}`, u = document.createElement("div");
|
|
3674
3678
|
u.className = `prize-item ${C ? "placed" : "missing"}`;
|
|
3675
|
-
const v = document.createElement("div");
|
|
3676
|
-
v.className = "prize-index", v.textContent = String(d);
|
|
3677
3679
|
const f = document.createElement("div");
|
|
3678
|
-
f.className = "prize-
|
|
3680
|
+
f.className = "prize-index", f.textContent = String(d);
|
|
3681
|
+
const v = document.createElement("div");
|
|
3682
|
+
v.className = "prize-label";
|
|
3679
3683
|
const y = document.createElement("div");
|
|
3680
3684
|
y.className = "prize-title", y.textContent = `Prize #${d}`;
|
|
3681
3685
|
const b = document.createElement("div");
|
|
3682
|
-
b.className = "prize-subtitle", b.textContent = C ? m : "Not Placed",
|
|
3686
|
+
b.className = "prize-subtitle", b.textContent = C ? m : "Not Placed", v.appendChild(y), v.appendChild(b);
|
|
3683
3687
|
const L = document.createElement("div");
|
|
3684
|
-
L.className = `prize-status ${C ? "placed" : "missing"}`, L.innerHTML = C ? ie : se, u.appendChild(
|
|
3688
|
+
L.className = `prize-status ${C ? "placed" : "missing"}`, L.innerHTML = C ? ie : se, u.appendChild(f), u.appendChild(v), u.appendChild(L), o.appendChild(u);
|
|
3685
3689
|
}
|
|
3686
3690
|
t.appendChild(o);
|
|
3687
3691
|
const r = document.createElement("button");
|
|
@@ -4188,7 +4192,7 @@ class Me extends x {
|
|
|
4188
4192
|
), this.updateButtonText(), this.updateOptionsList(), this.detectChangeCallback && this.detectChangeCallback !== this.props.detectChange && this.detectChangeCallback(t);
|
|
4189
4193
|
}
|
|
4190
4194
|
}
|
|
4191
|
-
class
|
|
4195
|
+
class Ie extends x {
|
|
4192
4196
|
constructor(t) {
|
|
4193
4197
|
var e, i;
|
|
4194
4198
|
super(t), this.inputType = "text", this.value = t.default ?? ((i = (e = t.options) == null ? void 0 : e[0]) == null ? void 0 : i.value) ?? "", this.detectChangeCallback = t.detectChange;
|
|
@@ -4241,7 +4245,7 @@ class Ne extends x {
|
|
|
4241
4245
|
const ce = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
4242
4246
|
<path d="M13.3334 5.99996H2.66675M13.3334 9.99996H2.66675M5.33341 12.6666V3.33329M10.6667 12.6666V3.33329" stroke="#667085" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
|
4243
4247
|
</svg>`;
|
|
4244
|
-
class
|
|
4248
|
+
class Ne extends x {
|
|
4245
4249
|
// Store mobile value
|
|
4246
4250
|
constructor(t = {}) {
|
|
4247
4251
|
t.rowGap = t.rowGap ?? !0, t.columnGap = t.columnGap ?? !0, t.title = t.title ?? "Gap", t.icon = t.icon ?? ce, t.suffix = t.suffix ?? "px", t.minValue = t.minValue ?? 0, super(t), this.inputType = "number", this.inputValues = {}, this.mobileValue = t.mobile, this.value = this.validateValue(t.default ?? 0), t.rowGap && (this.inputValues.row = this.value), t.columnGap && (this.inputValues.column = this.value);
|
|
@@ -4935,7 +4939,7 @@ export {
|
|
|
4935
4939
|
O as ColorSetting,
|
|
4936
4940
|
z as ColorWithOpacitySetting,
|
|
4937
4941
|
ke as DimensionSetting,
|
|
4938
|
-
|
|
4942
|
+
Ne as GapSetting,
|
|
4939
4943
|
j as GradientSetting,
|
|
4940
4944
|
$e as HeaderTypographySettingSet,
|
|
4941
4945
|
ne as HeightSetting,
|
|
@@ -4955,7 +4959,7 @@ export {
|
|
|
4955
4959
|
Gt as StringSetting,
|
|
4956
4960
|
At as TabSettingGroup,
|
|
4957
4961
|
At as TabsSettingGroup,
|
|
4958
|
-
|
|
4962
|
+
Ie as Toggle,
|
|
4959
4963
|
lt as UploadSetting,
|
|
4960
4964
|
ae as WidthSetting,
|
|
4961
4965
|
we as asSettingGroupWithSettings,
|
|
@@ -23,6 +23,8 @@ export declare class EmbeddedColorPicker {
|
|
|
23
23
|
private isDragging;
|
|
24
24
|
private changeRafId?;
|
|
25
25
|
private pendingExternalUpdate?;
|
|
26
|
+
private dragRafId?;
|
|
27
|
+
private cachedRect?;
|
|
26
28
|
constructor(options: EmbeddedColorPickerOptions);
|
|
27
29
|
private parsePercentage;
|
|
28
30
|
private sanitizeColor;
|
package/package.json
CHANGED