@rogieking/figui3 6.23.4 → 6.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/fig.js CHANGED
@@ -38,7 +38,7 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
38
38
  `)?`
39
39
  `:",";this.#J=Q.split(Z).map(($)=>$.trim()).filter(Boolean)}#N(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-segmented-control");if(Q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),F(this,"disabled"))Q.setAttribute("disabled","");if(F(this,"full"))Q.setAttribute("full","");let Z=this.getAttribute("value");for(let $ of this.#J){let J=document.createElement("fig-segment");if(J.setAttribute("value",$),J.textContent=$,Z===$)J.setAttribute("selected","true");Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Q="segments"}#K(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-dropdown");if(F(this,"disabled"))Q.setAttribute("disabled","");let Z=this.getAttribute("value");for(let $ of this.#J){let J=document.createElement("option");if(J.value=$,J.textContent=$,Z===$)J.selected=!0;Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Q="dropdown"}#G(){if(this.#Q==="segments")this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#M())});else this.#K()}#U(){if(!this.#j||this.#q)return;let Q=this.getAttribute("value")||"";this.#j.value=Q}#L(Q){if(!this.#j)return;if(this.hasAttribute(Q))this.#j.setAttribute(Q,this.getAttribute(Q)||"");else this.#j.removeAttribute(Q)}#F(){this.#$?.disconnect(),this.#$=new ResizeObserver(()=>{this.#M()}),this.#$.observe(this)}#z(Q){let Z=document.createRange();Z.selectNodeContents(Q);let $=Z.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,q=getComputedStyle(Q),_=parseFloat(q.paddingLeft)||0,X=parseFloat(q.paddingRight)||0,Y=j-_-X;return $>Y+0.5}#B(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(this.#z(Z))return!0;return!1}#M(){if(this.#J.length<=1)return;if(this.#Q==="segments"){let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#B())this.#Z=this.clientWidth,this.#K()}else if(this.#Z>0&&this.clientWidth>=this.#Z)this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#B())this.#K()})})}}z("fig-options",u0);function c1(Q){let Z=Q||"";if(Z.startsWith("["))try{let J=JSON.parse(Z);return Array.isArray(J)?J:[]}catch{}let $=Z.includes(`
40
40
  `)?`
41
- `:",";return Z.split($).map((J)=>J.trim()).filter(Boolean)}function u1(Q){if(Q&&typeof Q==="object")return String(Q.value??Q.label??"");return String(Q??"")}function p1(Q){if(Q&&typeof Q==="object")return String(Q.label??Q.value??"");return String(Q??"")}class p0 extends HTMLElement{static get observedAttributes(){return["value","disabled","selected","label"]}get value(){let Q=this.getAttribute("value");if(Q!==null)return Q;return(this.textContent||"").trim()}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get disabled(){return F(this,"disabled")}set disabled(Q){if(Q)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get selected(){return F(this,"selected")}set selected(Q){if(Q)this.setAttribute("selected","");else this.removeAttribute("selected")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","option");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled")this.#Q()}#Q(){if(this.disabled)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}z("fig-select-option",p0);class d0 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=this.syncOverflow.bind(this);connectedCallback(){if(!this.hasAttribute("slot"))this.setAttribute("slot","panel");this.#j(),this.#q(),this.addEventListener("scroll",this.#J,{passive:!0}),this.#$?.disconnect(),this.#$=new ResizeObserver(()=>this.syncOverflow()),this.#$.observe(this),requestAnimationFrame(()=>this.syncOverflow())}disconnectedCallback(){this.removeEventListener("scroll",this.#J),this.#$?.disconnect(),this.#$=null,this.#_()}syncOverflow(){return a(this,this,"y")}scrollToOption(Q,Z="auto"){S0(this,Q,"y",Z)}#j(){let Q=this.querySelector(":scope > fig-chooser");if(!Q)return;while(Q.firstChild)this.insertBefore(Q.firstChild,Q);Q.remove()}#q(){if(this.#Q&&this.#Z&&this.contains(this.#Q)&&this.contains(this.#Z))return;this.#_();let Q=X0({owner:"select",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>i(this,"y",-1),onEnd:()=>i(this,"y",1)});this.#Q=Q.start,this.#Z=Q.end,this.prepend(this.#Q),this.append(this.#Z)}#_(){this.#Q?.remove(),this.#Z?.remove(),this.#Q=null,this.#Z=null,this.classList.remove("overflow-start","overflow-end")}}z("fig-select-options",d0);class s0 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#_=!1;#Y=-1;#X=!1;#W=!1;#N=null;#K=!1;#G=null;#U=null;#L=!1;#F=this.#Z0.bind(this);#z=this.#j0.bind(this);#B=this.#q0.bind(this);#M=this.#e.bind(this);#D=this.#c.bind(this);static get observedAttributes(){return["value","disabled","label","options","position","offset","closedby","open"]}get value(){return this.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get open(){return F(this,"open")}set open(Q){if(Q)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(!this.#_)this.#f();if(this.#H(),this.#S(),this.#r(),this.#t(),this.#i(),this.#m(),this.open)this.#_0()}disconnectedCallback(){this.#x(),document.removeEventListener("keydown",this.#B,!0),this.#q?.disconnect(),this.#q=null}attributeChangedCallback(Q,Z,$){if(Z===$||!this.#_)return;if(Q==="options"){this.#S(),this.#i();return}if(Q==="value"||Q==="label"){this.#i();return}if(Q==="disabled"){this.#r();return}if(Q==="open"){if($===null||$==="false")this.#G0();else this.#_0();return}if(Q==="position"||Q==="offset"||Q==="closedby")this.#t()}focus(Q){this.#Q?.focus(Q)}blur(){this.#Q?.blur()}#T(Q){return Q?.nodeType===1&&(Q.tagName==="FIG-SELECT-OPTION"||Q.tagName==="FIG-MENU-SEPARATOR"||Q.tagName==="FIG-SELECT-OPTIONS")}#H(){for(let Q of this.querySelectorAll(":scope > fig-select-options"))if(!Q.hasAttribute("slot"))Q.setAttribute("slot","panel")}#O(){let Z=(this.#j?.assignedElements({flatten:!0})??[]).find(($)=>$.tagName==="FIG-SELECT-OPTIONS");if(Z)return Z;return this.querySelector(":scope > fig-select-options")}#R(){return Boolean(this.querySelector(":scope > fig-select-option:not([data-fig-generated]), :scope > fig-select-options > fig-select-option:not([data-fig-generated])"))}#P(){let Q=this.#O();if(Q){if(!Q.hasAttribute("slot"))Q.setAttribute("slot","panel");return Q}return Q=document.createElement("fig-select-options"),Q.setAttribute("slot","panel"),Q.setAttribute("data-fig-generated",""),this.appendChild(Q),Q}#S(){if(this.#R())return;let Q=this.hasAttribute("options"),Z=Q?this.#P():this.#O();if(!Z)return;this.#L=!0;try{for(let j of Z.querySelectorAll(":scope > fig-select-option[data-fig-generated]"))j.remove();if(!Q)return;let $=c1(this.getAttribute("options")),J=Z.querySelector(":scope > .fig-overflow-end");for(let j of $){let q=document.createElement("fig-select-option");if(q.setAttribute("data-fig-generated",""),q.setAttribute("value",u1(j)),q.textContent=p1(j),J)Z.insertBefore(q,J);else Z.appendChild(q)}}finally{this.#L=!1}}#f(){this.#_=!0;let Q=this.attachShadow({mode:"open"});Q.innerHTML=`
41
+ `:",";return Z.split($).map((J)=>J.trim()).filter(Boolean)}function u1(Q){if(Q&&typeof Q==="object")return String(Q.value??Q.label??"");return String(Q??"")}function p1(Q){if(Q&&typeof Q==="object")return String(Q.label??Q.value??"");return String(Q??"")}class p0 extends HTMLElement{static get observedAttributes(){return["value","disabled","selected","label"]}get value(){let Q=this.getAttribute("value");if(Q!==null)return Q;return(this.textContent||"").trim()}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get disabled(){return F(this,"disabled")}set disabled(Q){if(Q)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get selected(){return F(this,"selected")}set selected(Q){if(Q)this.setAttribute("selected","");else this.removeAttribute("selected")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","option");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled")this.#Q()}#Q(){if(this.disabled)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}z("fig-select-option",p0);class d0 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=this.syncOverflow.bind(this);connectedCallback(){if(!this.hasAttribute("slot"))this.setAttribute("slot","panel");this.#j(),this.#q(),this.addEventListener("scroll",this.#J,{passive:!0}),this.#$?.disconnect(),this.#$=new ResizeObserver(()=>this.syncOverflow()),this.#$.observe(this),requestAnimationFrame(()=>this.syncOverflow())}disconnectedCallback(){this.removeEventListener("scroll",this.#J),this.#$?.disconnect(),this.#$=null,this.#_()}syncOverflow(){return a(this,this,"y")}scrollToOption(Q,Z="auto"){S0(this,Q,"y",Z)}#j(){let Q=this.querySelector(":scope > fig-chooser");if(!Q)return;while(Q.firstChild)this.insertBefore(Q.firstChild,Q);Q.remove()}#q(){if(this.#Q&&this.#Z&&this.contains(this.#Q)&&this.contains(this.#Z))return;this.#_();let Q=X0({owner:"select",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>i(this,"y",-1),onEnd:()=>i(this,"y",1)});this.#Q=Q.start,this.#Z=Q.end,this.prepend(this.#Q),this.append(this.#Z)}#_(){this.#Q?.remove(),this.#Z?.remove(),this.#Q=null,this.#Z=null,this.classList.remove("overflow-start","overflow-end")}}z("fig-select-options",d0);class s0 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#_=!1;#Y=-1;#X=!1;#W=!1;#N=null;#K=!1;#G=null;#U=null;#L=!1;#F=this.#Z0.bind(this);#z=this.#j0.bind(this);#B=this.#q0.bind(this);#M=this.#e.bind(this);#D=this.#c.bind(this);static get observedAttributes(){return["value","disabled","label","options","position","offset","closedby","open"]}get value(){return this.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get open(){return F(this,"open")}set open(Q){if(Q)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(!this.#_)this.#f();if(this.#H(),this.#S(),this.#r(),this.#t(),this.#i(),this.#m(),this.open)this.#_0()}disconnectedCallback(){this.#x(),document.removeEventListener("keydown",this.#B,!0),this.#q?.disconnect(),this.#q=null}attributeChangedCallback(Q,Z,$){if(Z===$||!this.#_)return;if(Q==="options"){this.#S(),this.#i();return}if(Q==="value"||Q==="label"){this.#i();return}if(Q==="disabled"){this.#r();return}if(Q==="open"){if($===null||$==="false")this.#G0();else this.#_0();return}if(Q==="position"||Q==="offset"||Q==="closedby")this.#t()}focus(Q){this.#Q?.focus(Q)}blur(){this.#Q?.blur()}#T(Q){return Q?.nodeType===1&&(Q.tagName==="FIG-SELECT-OPTION"||Q.tagName==="FIG-SEPARATOR"||Q.tagName==="FIG-SELECT-OPTIONS")}#H(){for(let Q of this.querySelectorAll(":scope > fig-select-options"))if(!Q.hasAttribute("slot"))Q.setAttribute("slot","panel")}#O(){let Z=(this.#j?.assignedElements({flatten:!0})??[]).find(($)=>$.tagName==="FIG-SELECT-OPTIONS");if(Z)return Z;return this.querySelector(":scope > fig-select-options")}#R(){return Boolean(this.querySelector(":scope > fig-select-option:not([data-fig-generated]), :scope > fig-select-options > fig-select-option:not([data-fig-generated])"))}#P(){let Q=this.#O();if(Q){if(!Q.hasAttribute("slot"))Q.setAttribute("slot","panel");return Q}return Q=document.createElement("fig-select-options"),Q.setAttribute("slot","panel"),Q.setAttribute("data-fig-generated",""),this.appendChild(Q),Q}#S(){if(this.#R())return;let Q=this.hasAttribute("options"),Z=Q?this.#P():this.#O();if(!Z)return;this.#L=!0;try{for(let j of Z.querySelectorAll(":scope > fig-select-option[data-fig-generated]"))j.remove();if(!Q)return;let $=c1(this.getAttribute("options")),J=Z.querySelector(":scope > .fig-overflow-end");for(let j of $){let q=document.createElement("fig-select-option");if(q.setAttribute("data-fig-generated",""),q.setAttribute("value",u1(j)),q.textContent=p1(j),J)Z.insertBefore(q,J);else Z.appendChild(q)}}finally{this.#L=!1}}#f(){this.#_=!0;let Q=this.attachShadow({mode:"open"});Q.innerHTML=`
42
42
  <style>
43
43
  :host {
44
44
  display: inline-flex;
@@ -277,7 +277,7 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
277
277
  </svg>
278
278
  ${j}
279
279
  </fig-button>
280
- </div>`,this.#Z=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#Q&&this.#j&&this.#J){if(!this.#j.hasAttribute("type"))this.#j.setAttribute("type","dropdown");if(!this.#j.hasAttribute("label"))this.#j.setAttribute("label",J);this.#J.append(this.#j)}this.#$=this.querySelector("fig-dropdown"),this.#R()}#U(){this.#L(),this.#$?.addEventListener("input",this.#Y),this.#Z?.addEventListener("input",this.#X),this.#Z?.addEventListener("change",this.#W)}#L(){this.#$?.removeEventListener("input",this.#Y),this.#Z?.removeEventListener("input",this.#X),this.#Z?.removeEventListener("change",this.#W)}#F(Q){Q.stopPropagation();let Z=Q.target.closest("fig-dropdown")?.value??"";if(this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#Z)this.#Z.setAttribute("value",Z);this.#M(),this.#D()}#z(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#M()}#B(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#D()}#M(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#D(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#T(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#H(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#O(){return`${this.#H()} options`}#R(){if(this.#Z)this.#_.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.#Z.removeAttribute(Q);else this.#Z.setAttribute(Q,Z)});if(this.#$&&!this.#$.hasAttribute("aria-label"))this.#$.setAttribute("label",this.#O())}#P(Q){if(this.#Z)if(Q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}focus(){this.#Z?.focus()}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"options":if(this.#$&&!this.#Q){let J=this.#T();this.#$.replaceChildren(...J.map((j)=>{let q=document.createElement("option");return q.textContent=j,q}))}break;case"placeholder":if(this.#Z)this.#Z.setAttribute("placeholder",$||"");this.#R();break;case"value":if(!this.#q&&this.#Z)this.#Z.setAttribute("value",$||"");break;case"disabled":this.#P($!==null&&$!=="false");break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#R();break}}}z("fig-combo-input",j1);class q1 extends HTMLElement{#Q="color";#Z=null;#$=!1;constructor(){super();this.#Z=this.#W.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#Y(),this.#J(),this.#X()}#J(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#j(Q){if(!Q)return"color";let Z=Q.toLowerCase();if(Z.includes("gradient"))return"gradient";if(Z.includes("url("))return"image";return"color"}#q(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:Z}=O0(1,1);return Z.fillStyle=Q,Z.fillStyle}catch{return"#D9D9D9"}}#_(Q){if(!Q||!Q.includes("var("))return Q;let Z=this.style.background;this.style.background=Q;let $=getComputedStyle(this),J=$.backgroundImage,j=$.backgroundColor;if(this.style.background=Z,J&&J!=="none")return J;return j||Q}#Y(){let Q=this.getAttribute("background")||"#D9D9D9",Z=Q.includes("var("),$=Z?this.#_(Q):Q,J=this.#j($);if(J!==this.#Q||!this.input){if(this.#Q=J,this.setAttribute("data-type",this.#Q),this.input)this.input.removeEventListener("input",this.#Z);if(this.#Q==="color"){let q=this.#q($);if(this.innerHTML=`<div></div><input type="color" value="${q}" />`,this.input=this.querySelector("input"),!Z)this.input.addEventListener("input",this.#Z);this.#X()}else this.innerHTML="<div></div>",this.input=null,this.#X()}else if(this.#Q==="color"&&this.input){let q=this.#q($);if(this.input.value!==q)this.input.value=q}let j=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Q);this.style.setProperty("--swatch-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#X(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",Q?"true":"false"),this.input){this.input.disabled=Q;let Z=this.getAttribute("aria-labelledby"),$=this.getAttribute("aria-label")||"Color swatch",J=this.getAttribute("aria-describedby");if(Z)this.input.setAttribute("aria-labelledby",Z),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",$),this.input.removeAttribute("aria-labelledby");if(J)this.input.setAttribute("aria-describedby",J);else this.input.removeAttribute("aria-describedby");this.removeAttribute("role"),this.removeAttribute("aria-hidden");return}if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-hidden","true");else this.setAttribute("role","img"),this.removeAttribute("aria-hidden")}#W(Q){this.#$=!0,this.setAttribute("background",Q.target.value),this.#$=!1}get background(){return this.getAttribute("background")}set background(Q){this.setAttribute("background",Q)}focus(){this.input?.focus()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="background"){if(this.#$){let J=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--swatch-background",J?$:`linear-gradient(${$}, ${$})`);return}this.#Y()}else if(Q==="alpha")this.#J();else if(Q==="disabled"||Q==="aria-label"||Q==="aria-labelledby"||Q==="aria-describedby")this.#X()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",Q)}}z("fig-swatch",q1);class K0 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#_=null;#Y=this.#c.bind(this);#X=this.#h.bind(this);#W=this.#d.bind(this);#N=this.#p.bind(this);#K=null;#G=null;#U=null;#L=null;#F=null;#z=null;#B=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","caption","controls","autoplay","loop","muted","poster","aria-label","aria-labelledby","title"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#Q}set src(Q){if(this.#Q=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#_}#M(){return this.#q||this.#Q||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#M())return null;if(!this.#Z)return null;try{if(typeof this.#Z.decode==="function")await this.#Z.decode();else if(!this.#Z.complete)await new Promise((J,j)=>{this.#Z.addEventListener("load",J,{once:!0}),this.#Z.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Z.naturalWidth,Z=this.#Z.naturalHeight;if(!(Q>0)||!(Z>0))return null;let $=document.createElement("canvas");return $.width=Q,$.height=Z,$.getContext("2d").drawImage(this.#Z,0,0),$.toDataURL()}connectedCallback(){this.#Q=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--fig-media-aspect-ratio",Q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let Z=this.getAttribute("fit");if(Z)this.style.setProperty("--fig-media-fit",Z);if(this.querySelectorAll("fig-swatch[data-generated]").forEach((J)=>J.remove()),this.#H(),this.#R(),this.#T(),this.#E(),this.#P(),this.#I(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#g();this.#J=this.querySelector("fig-input-file[data-generated]"),this.#J?.removeEventListener("change",this.#Y),this.#J?.addEventListener("change",this.#Y)}disconnectedCallback(){if(this.#J?.removeEventListener("change",this.#Y),this.#D(),this.#V(),this.#j)URL.revokeObjectURL(this.#j),this.#j=null;this.#q=null}#D(){if(!this.#Z)return;if(this.#Z.tagName==="VIDEO")this.#Z.removeEventListener("play",this.#X),this.#Z.removeEventListener("pause",this.#W),this.#Z.removeEventListener("ended",this.#N)}#T(){if(this.#D(),this.#Z?.tagName!=="VIDEO")return;this.#Z.addEventListener("play",this.#X),this.#Z.addEventListener("pause",this.#W),this.#Z.addEventListener("ended",this.#N)}#H(){if(this.#$?.isConnected)return;let Q=this.querySelector(":scope > fig-preview");if(Q){this.#$=Q;return}let Z=document.createElement("fig-preview");Z.setAttribute("data-generated",""),this.prepend(Z),this.#$=Z}#O(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#R(){let Q=this.#O();if(Q){if(this.#H(),this.#Z&&this.#Z!==Q){if(this.#D(),this.#Z.hasAttribute("data-generated"))this.#Z.remove()}if(this.#Z=Q,this.#$&&Q.parentElement!==this.#$)this.#$.append(Q);this.#P();return}this.#H();let Z=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Z&&this.#Z.tagName!==Z){if(this.#D(),this.#Z.hasAttribute("data-generated"))this.#Z.remove();this.#Z=null}if(this.#Z)return;if(this.mediaKind==="video"){let $=document.createElement("video");$.setAttribute("data-generated",""),$.className="fig-media-element",$.setAttribute("playsinline",""),$.preload="auto",this.#$.append($),this.#Z=$,this.#T();let J=()=>{if(this.#Z?.autoplay)return;try{this.#Z.currentTime=0.001}catch{}};this.#Z.addEventListener("loadedmetadata",J,{once:!0})}else{let $=document.createElement("img");$.setAttribute("data-generated",""),$.className="fig-media-element",$.loading="lazy",$.decoding="async",$.alt=this.getAttribute("alt")||"",this.#$.append($),this.#Z=$}}#P(){if(!this.#Z)return;if(this.#Z.tagName==="IMG"){if(this.hasAttribute("alt")||this.#Z.hasAttribute("data-generated"))this.#Z.alt=this.getAttribute("alt")||"";return}if(this.#Z.tagName!=="VIDEO")return;["aria-label","aria-labelledby","title"].forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.#Z.removeAttribute(Q);else this.#Z.setAttribute(Q,Z)})}#S(){return this.querySelector(":scope > figcaption:not([data-generated])")}#f(){return Array.from(this.querySelectorAll(":scope > figcaption[data-generated]"))}#I(){let Q=this.#S(),Z=this.#f();if(Q){Z.forEach((q)=>q.remove());return}let $=this.getAttribute("caption")||"";if(!$){Z.forEach((q)=>q.remove());return}let J=Z[0]||document.createElement("figcaption");if(Z.slice(1).forEach((q)=>q.remove()),!J.hasAttribute("data-generated"))J.setAttribute("data-generated","");if(J.textContent!==$)J.textContent=$;let j=this.querySelector(":scope > fig-media-controls");if(j)j.before(J);else if(this.#$?.isConnected)this.#$.after(J);else if(!J.isConnected)this.append(J)}#A(Q,Z=!1){if(!this.hasAttribute(Q))return Z;return this.getAttribute(Q)!=="false"}#E(){if(!this.#Z)return;if(!this.#Z.hasAttribute("data-generated"))return;let Q=this.#M();if(this.#Z.getAttribute("src")!==Q){if(Q)this.#Z.setAttribute("src",Q);else if(this.#Z.removeAttribute("src"),this.#Z.tagName==="VIDEO")this.#Z.load()}if(this.#Z.tagName==="IMG"){this.#P();return}let Z=this.getAttribute("poster");if(Z)this.#Z.setAttribute("poster",Z);else this.#Z.removeAttribute("poster");this.#Z.controls=!1,this.#Z.removeAttribute("controls"),this.#Z.autoplay=this.#A("autoplay",!1),this.#Z.loop=this.#A("loop",!1),this.#Z.muted=this.#A("muted",!1),this.#Z.playsInline=!0,this.#P(),this.#y(),this.#k()}get mediaEl(){return this.#Z}#C(){if(this.mediaKind!=="video")return!1;return Boolean(this.#M())}#k(){let Q=this.#K||this.querySelector(":scope > fig-media-controls");if(!Q)return;if(this.mediaKind!=="video")return;if(this.#C()){if(Q.hasAttribute("data-fig-empty-disabled"))Q.removeAttribute("disabled"),Q.removeAttribute("data-fig-empty-disabled");return}Q.setAttribute("disabled",""),Q.setAttribute("data-fig-empty-disabled",""),Q.playing=!1,Q.time=0,Q.duration=0}#y(){if(this.mediaKind!=="video"){this.#V();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#K!==Q)this.#V(),this.#K=Q;this.#b(),this.#k();return}if(this.#A("controls",!1))this.#v();else this.#V()}#v(){let Q=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Z=Q[0];if(Q.slice(1).forEach((J)=>J.remove()),Z){this.#K=Z,this.#b(),this.#k();return}let $=document.createElement("fig-media-controls");$.setAttribute("data-generated",""),this.append($),this.#K=$,this.#b(),this.#k()}#b(){if(!this.#K||!this.#Z)return;if(this.#G===this.#Z&&this.#U===this.#K){this.#k();return}this.#w();let Q=this.#K,Z=this.#Z;this.#G=Z,this.#U=Q;let $=null,J=()=>{if(this.#k(),!this.#C())return;if(Q.playing=!Z.paused&&!Z.ended,Number.isFinite(Z.duration))Q.duration=Z.duration;if($!==null)if(Math.abs(Z.currentTime-$)<0.25)$=null;else return;Q.time=Z.currentTime||0},j=()=>{if(!this.#C())return;let X=Z.play?.();if(X&&typeof X.catch==="function")X.catch(()=>{})},q=()=>Z.pause?.(),_=(X)=>{if(!this.#C())return;let Y=Number(X?.detail?.time);if(!Number.isFinite(Y))return;$=Y;try{Z.currentTime=Y}catch{}};this.#L=J,this.#F=j,this.#z=q,this.#B=_,Z.addEventListener("play",J),Z.addEventListener("pause",J),Z.addEventListener("ended",J),Z.addEventListener("timeupdate",J),Z.addEventListener("loadedmetadata",J),Z.addEventListener("durationchange",J),Z.addEventListener("seeked",J),Q.addEventListener("play",j),Q.addEventListener("pause",q),Q.addEventListener("seek",_),J()}#w(){let Q=this.#G,Z=this.#U;if(Q&&this.#L)Q.removeEventListener("play",this.#L),Q.removeEventListener("pause",this.#L),Q.removeEventListener("ended",this.#L),Q.removeEventListener("timeupdate",this.#L),Q.removeEventListener("loadedmetadata",this.#L),Q.removeEventListener("durationchange",this.#L),Q.removeEventListener("seeked",this.#L);if(Z){if(this.#F)Z.removeEventListener("play",this.#F);if(this.#z)Z.removeEventListener("pause",this.#z);if(this.#B)Z.removeEventListener("seek",this.#B)}this.#G=null,this.#U=null,this.#L=null,this.#F=null,this.#z=null,this.#B=null}#V(){this.#w(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((Q)=>{Q.remove()}),this.#K=null}toggle(){if(!this.#Z||this.mediaKind!=="video")return;if(this.#Z.paused||this.#Z.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Z)return;let Q=this.#Z.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Z)return;this.#Z.pause()}#g(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let Z=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#Q?"Replace":Z),this.#_?.name)Q.setAttribute("filename",this.#_.name);else if(this.#Q)Q.setAttribute("url",this.#Q);Q.addEventListener("change",this.#Y),this.#H(),this.#$.append(Q),this.#J=Q}#x(){if(this.#J)this.#J.removeEventListener("change",this.#Y),this.#J.remove(),this.#J=null}#c(Q){if(Q.target!==this.#J)return;let Z=Q.detail?.files?.[0],$=Q.detail?.cleared===!0;if(!Z){if(this.#j)URL.revokeObjectURL(this.#j),this.#j=null;if(this.#_=null,this.#q=null,$)this.src="";if(this.#E(),this.#J){let J=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#Q?"Replace":J),this.#J.removeAttribute("filename"),this.#Q)this.#J.setAttribute("url",this.#Q);else this.#J.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#j)URL.revokeObjectURL(this.#j);if(this.#_=Z,this.#j=URL.createObjectURL(Z),this.#q=this.#j,this.#E(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Z,src:this.#j}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#J)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",Z.name),this.#J.setAttribute("label","Replace")}#m(Q){if(!this.#Z)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Q||"",currentTime:this.#Z.currentTime,duration:this.#Z.duration}}))}#h(){this.#m("play")}#d(){this.#m("pause")}#p(){this.#m("ended")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="src"){let J=$||"",j=J&&(J===this.#q||J===this.#j);if(this.#Q=J,this.#j&&!j)URL.revokeObjectURL(this.#j),this.#j=null,this.#q=null,this.#_=null;if(this.#E(),this.#J){let q=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#Q?"Replace":q),this.#Q)if(this.#_?.name)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",this.#_.name);else this.#J.setAttribute("url",this.#Q),this.#J.removeAttribute("filename");else this.#J.removeAttribute("url"),this.#J.removeAttribute("filename")}}if(Q==="type"){if(this.#R(),this.#E(),this.#J)this.#J.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(Q))this.#P();if(Q==="upload"){let J=$!==null&&$!=="false";if(J&&!this.#J)this.#g();else if(!J)this.#x()}if(Q==="aspect-ratio")if($)this.style.setProperty("--fig-media-aspect-ratio",$);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if($)this.style.setProperty("--fig-media-fit",$);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#J){let J=this.getAttribute("label")||"Upload";this.#J.setAttribute("label",this.#Q?"Replace":J)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#E();if(Q==="caption")this.#I()}}z("fig-media",K0);class _1 extends K0{get mediaKind(){return"image"}}z("fig-image",_1);class X1 extends K0{get mediaKind(){return"video"}}z("fig-video",X1);class Y1 extends HTMLElement{static get observedAttributes(){return["src","alt","label","text","sublabel","href","target","selected","disabled","full","aspect-ratio","fit","label-line-clamp"]}#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#_=!1;connectedCallback(){this.#G(),this.#U()}attributeChangedCallback(){if(!this.isConnected)return;this.#G(),this.#U()}#Y(){return this.getAttribute("label")??this.getAttribute("text")??""}#X(){return this.getAttribute("sublabel")??""}#W(){let Q=this.getAttribute("href");return Boolean(Q)&&!F(this,"disabled")}#N(){return this.getAttribute("label-line-clamp")==="2"?"2":"1"}#K(){return this.querySelector(":scope > fig-image:not([data-generated]), :scope > fig-media:not([data-generated]), :scope > fig-preview:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-image:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-media:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-preview:not([data-generated])")}#G(){let Q=this.#K();this.#_=Boolean(Q);let $=this.#W()?"a":"div";if(!this.#Q||this.#Q.tagName.toLowerCase()!==$){let J=document.createElement($);if(J.className="fig-card-link",this.#Q){while(this.#Q.firstChild)J.appendChild(this.#Q.firstChild);this.#Q.replaceWith(J)}else this.appendChild(J);this.#Q=J}if(!this.#Z||!this.#Z.isConnected){if(this.#Z=this.#Q.querySelector(":scope > .fig-card-media"),!this.#Z)this.#Z=document.createElement("div"),this.#Z.className="fig-card-media",this.#Q.prepend(this.#Z)}if(Q&&Q.parentElement!==this.#Z)this.#Z.querySelectorAll("[data-generated]").forEach((J)=>J.remove()),this.#Z.appendChild(Q),this.#J=null;if(!this.#_){if(this.#J=this.#Z.querySelector(":scope > fig-image[data-generated]")||null,!this.#J)this.#Z.querySelectorAll(":scope > fig-image, :scope > fig-media, :scope > fig-preview").forEach((J)=>{if(J.hasAttribute("data-generated"))J.remove()}),this.#J=document.createElement("fig-image"),this.#J.setAttribute("data-generated",""),this.#J.setAttribute("full",""),this.#J.setAttribute("size","auto"),this.#Z.appendChild(this.#J)}if(!this.#$||!this.#$.isConnected){if(this.#$=this.#Q.querySelector(":scope > .fig-card-text"),!this.#$)this.#$=document.createElement("div"),this.#$.className="fig-card-text",this.#$.setAttribute("data-generated",""),this.#Q.appendChild(this.#$)}if(!this.#j||!this.#j.isConnected){if(this.#j=this.#$.querySelector(":scope > .fig-card-label[data-generated]"),!this.#j){if(this.#j=this.#Q.querySelector(":scope > .fig-card-label[data-generated]")||null,!this.#j)this.#j=document.createElement("label"),this.#j.className="fig-card-label",this.#j.setAttribute("data-generated","");this.#$.appendChild(this.#j)}}if(!this.#q||!this.#q.isConnected){if(this.#q=this.#$.querySelector(":scope > .fig-card-sublabel[data-generated]"),!this.#q){if(this.#q=this.#Q.querySelector(":scope > .fig-card-sublabel[data-generated]")||null,!this.#q)this.#q=document.createElement("span"),this.#q.className="fig-card-sublabel",this.#q.setAttribute("data-generated","");this.#j.after(this.#q)}}}#U(){if(!this.#Q)return;let Q=F(this,"disabled"),Z=F(this,"selected"),$=this.#Y(),J=this.#X(),j=this.#N();if(this.style.setProperty("--fig-card-label-line-clamp",j),this.#W()){let q=this.getAttribute("href")||"",_=this.getAttribute("target");if(this.#Q.setAttribute("href",q),_)if(this.#Q.setAttribute("target",_),_==="_blank")this.#Q.setAttribute("rel","noopener noreferrer");else this.#Q.removeAttribute("rel");else this.#Q.removeAttribute("target"),this.#Q.removeAttribute("rel");if(Z)this.#Q.setAttribute("aria-current","true");else this.#Q.removeAttribute("aria-current");this.removeAttribute("role"),this.removeAttribute("aria-label")}else{this.#Q.removeAttribute("href"),this.#Q.removeAttribute("target"),this.#Q.removeAttribute("rel"),this.#Q.removeAttribute("aria-current"),this.setAttribute("role","group");let q=[$,J].filter(Boolean).join(", ");if(q)this.setAttribute("aria-label",q);else this.removeAttribute("aria-label")}if(Q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#J&&!this.#_){let q=this.getAttribute("src"),_=this.getAttribute("alt"),X=this.getAttribute("aspect-ratio")||"1/1",Y=this.getAttribute("fit")||"contain",K=_!=null?_:"";if(q)this.#J.setAttribute("src",q);else this.#J.removeAttribute("src");this.#J.setAttribute("alt",K),this.#J.setAttribute("aspect-ratio",X),this.#J.setAttribute("fit",Y),this.#J.setAttribute("full",""),this.#J.setAttribute("size","auto")}if(this.#j)this.#j.textContent=$,this.#j.hidden=!$;if(this.#q)this.#q.textContent=J,this.#q.hidden=!J;if(this.#$)this.#$.hidden=!$&&!J}}z("fig-card",Y1);class K1 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=!1;#q=!1;static get observedAttributes(){return["playing","duration","time","disabled"]}connectedCallback(){this.#_(),this.#N(),this.#K(),this.#Y()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let Q=Number(this.getAttribute("duration"));return Number.isFinite(Q)&&Q>=0?Q:0}set duration(Q){let Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("duration");return}this.setAttribute("duration",String(Z))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("time");return}this.setAttribute("time",String(Z))}get disabled(){return F(this,"disabled")}set disabled(Q){if(Q)this.setAttribute("disabled","");else this.removeAttribute("disabled")}attributeChangedCallback(Q){if(!this.#q)return;if(Q==="playing")this.#N();if(Q==="duration"||Q==="time")this.#K();if(Q==="disabled")this.#Y()}#_(){if(this.#q)return;if(this.#q=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Play");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("size","small"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Play");let $=u("play",{className:"fig-media-controls-play-icon"});Z.append($),Q.append(Z),Z.addEventListener("click",(_)=>{_.preventDefault(),_.stopPropagation(),this.toggle()});let J=document.createElement("fig-slider");J.setAttribute("text","false"),J.setAttribute("min","0"),J.setAttribute("max",String(this.duration)),J.setAttribute("step","1"),J.setAttribute("value",String(this.time)),J.setAttribute("full",""),J.setAttribute("aria-label","Seek"),J.setAttribute("aria-valuetext",this.#W(this.time,this.duration));let j=document.createElement("span");j.className="fig-media-controls-time",j.textContent=this.#X(this.time);let q=(_)=>{if(this.disabled){_.preventDefault?.(),_.stopPropagation();return}let X=_.currentTarget,Y=Number(X?.value);if(!Number.isFinite(Y))return;this.#j=!0,this.setAttribute("time",String(Y)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:Y}})),requestAnimationFrame(()=>{this.#j=!1})};J.addEventListener("input",q),J.addEventListener("change",q),this.append(Q,J,j),this.#Q=Z,this.#Z=Q,this.#$=J,this.#J=j,this.#Y()}#Y(){let Q=this.disabled;if(this.setAttribute("aria-disabled",Q?"true":"false"),this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}#X(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let Z=Math.floor(Q),$=Math.floor(Z/60),J=Z%60;return`${String($).padStart(2,"0")}:${String(J).padStart(2,"0")}`}#W(Q,Z=0){let $=this.#X(Q);if(!Number.isFinite(Z)||Z<=0)return $;return`${$} of ${this.#X(Z)}`}#N(){if(!this.#Q)return;let Q=this.playing;this.#Q.setAttribute("aria-label",Q?"Pause":"Play"),this.#Z?.setAttribute("text",Q?"Pause":"Play");let Z=this.#Q.querySelector(".fig-media-controls-play-icon");if(Z)Z.setAttribute("name",Q?"pause":"play")}#K(){if(!this.#$)return;let Q=this.duration;if(Number(this.#$.getAttribute("max"))!==Q)this.#$.setAttribute("max",String(Q));let Z=this.time;if(!this.#j)this.#$.setAttribute("value",String(Z));if(this.#$.setAttribute("aria-valuetext",this.#W(Z,Q)),this.#J)this.#J.textContent=this.#X(Z)}toggle(){if(this.disabled)return;let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.disabled||this.playing)return;this.toggle()}pause(){if(this.disabled||!this.playing)return;this.toggle()}}z("fig-media-controls",K1);class G1 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;get files(){return this.#q}get#_(){let Q=this.getAttribute("filename");if(Q)return Q;let Z=this.getAttribute("url");if(!Z)return"";try{let J=new URL(Z,location.href).pathname.split("/").pop();return J?decodeURIComponent(J):Z}catch{return Z}}get value(){if(this.#q&&this.#q.length>0){if(this.#q.length===1)return this.#q[0].name;return`${this.#q.length} files`}return this.#_}connectedCallback(){this.#U(),this.addEventListener("dragover",this.#N),this.addEventListener("dragleave",this.#K),this.addEventListener("drop",this.#G)}disconnectedCallback(){this.#Q?.removeEventListener("change",this.#X),this.#$?.removeEventListener("click",this.#W),this.removeEventListener("dragover",this.#N),this.removeEventListener("dragleave",this.#K),this.removeEventListener("drop",this.#G)}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#U()}clear(){if(this.#q=null,this.#Q)this.#Q.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#U(),this.#Y({cleared:!0})}#Y(Q={}){let Z={files:this.#q,...Q};this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0}))}#X=()=>{if(this.#Q.files.length>0)this.#q=this.#Q.files,this.removeAttribute("url"),this.#U(),this.#Y()};#W=(Q)=>{Q.stopPropagation(),this.clear()};#N=(Q)=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#j)this.#j.dataset.prevText=this.#j.textContent,this.#j.textContent="Drop file"}};#K=()=>{if(this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText};#G=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.getAttribute("accepts"),$=Array.from(Q.dataTransfer.files);if(Z){let j=Z.split(",").map((q)=>q.trim().toLowerCase());$=$.filter((q)=>{let _="."+q.name.split(".").pop().toLowerCase(),X=q.type.toLowerCase();return j.some((Y)=>Y===_||Y===X||Y.endsWith("/*")&&X.startsWith(Y.slice(0,-1)))})}if(!this.hasAttribute("multiple")||this.getAttribute("multiple")==="false")$=$.slice(0,1);if($.length===0)return;let J=new DataTransfer;if($.forEach((j)=>J.items.add(j)),this.#q=J.files,this.#Q)this.#Q.files=J.files;this.removeAttribute("url"),this.#U(),this.#Y()};#U(){let Q=this.getAttribute("accepts")||"",Z=this.getAttribute("label")||"Upload",$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.hasAttribute("multiple")&&this.getAttribute("multiple")!=="false",j=this.getAttribute("variant")||"input",q=this.#q&&this.#q.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",q){let _=Q?`Accepts ${Q.split(",").map((N)=>N.trim()).join(", ")}`:"";if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.className="fig-input-file-filename",$)this.#j.setAttribute("disabled","");let X=document.createElement("fig-truncate");X.setAttribute("position","middle"),X.setAttribute("tooltip","");let Y=this.value,K=Y.lastIndexOf(".");if(K>0)X.setAttribute("tail",Y.slice(K));if(X.textContent=Y,this.#j.appendChild(X),this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",this.#Q.disabled=$,Q)this.#Q.setAttribute("accept",Q);if(J)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#X),this.#j.appendChild(this.#Q),_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_),this.#J.appendChild(this.#j),this.appendChild(this.#J);else this.appendChild(this.#j);let G=document.createElement("fig-tooltip");if(G.setAttribute("text","Remove"),this.#$=document.createElement("fig-button"),this.#$.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#$.setAttribute("icon","true"),this.#$.setAttribute("aria-label","Remove"),this.#$.className="fig-input-file-clear",$)this.#$.setAttribute("disabled","");this.#$.replaceChildren(u("minus")),this.#$.addEventListener("click",this.#W),G.appendChild(this.#$),this.appendChild(G)}else{let _=Q?`Accepts ${Q.split(",").map((X)=>X.trim()).join(", ")}`:"";if(_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_);if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.textContent=Z,$)this.#j.setAttribute("disabled","");if(this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",this.#Q.disabled=$,Q)this.#Q.setAttribute("accept",Q);if(J)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#X),this.#j.appendChild(this.#Q),this.#J)this.#J.appendChild(this.#j),this.appendChild(this.#J);else this.appendChild(this.#j)}}}z("fig-input-file",G1);class w extends HTMLElement{#Q={x:0.42,y:0};#Z={x:0.58,y:1};#$={stiffness:200,damping:15,mass:1};#J="bezier";#j=2;#q=null;#_=null;#Y=null;#X=null;#W=null;#N=null;#K=null;#G=null;#U=null;#L=null;#F=null;#z=0.8;#B=200;#M=200;#D=null;#T=null;#H=null;#O=null;#R=5;#P=10;#S=10;#f=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#j=parseInt(this.getAttribute("precision")||"2"),b(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#I(Q);this.#L=this.#A(),this.#y(),this.#m()}disconnectedCallback(){if(this.#q=null,this.#O)this.#O.disconnect(),this.#O=null}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="aspect-ratio"){if(b(this,"--aspect-ratio",$),this.#_)this.#h(),this.#u();return}if(Q==="edit"){if(this.isConnected)this.#y();return}if(Q==="value"&&$){let J=this.#J;if(this.#I($),this.#L=this.#A(),J!==this.#J&&this.#k())this.#y();else{if(this.#_)this.#u();this.#e(),this.#l()}}if(Q==="precision")this.#j=parseInt($||"2")}get value(){if(this.#J==="spring"){let{stiffness:Z,damping:$,mass:J}=this.#$;return`spring(${Z}, ${$}, ${J})`}let Q=this.#j;return`${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}, ${this.#Z.x.toFixed(Q)}, ${this.#Z.y.toFixed(Q)}`}get cssValue(){if(this.#J==="spring"){let Z=this.#E(),$=20,J=Math.max(1,Math.floor(Z.length/20)),j=[];for(let q=0;q<Z.length;q+=J)j.push(Z[q].value.toFixed(3));if(Z.length>0)j.push(Z[Z.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#j;return`cubic-bezier(${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}, ${this.#Z.x.toFixed(Q)}, ${this.#Z.y.toFixed(Q)})`}get preset(){return this.#L}set value(Q){this.setAttribute("value",Q)}#I(Q){let Z=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if(Z)return this.#J="spring",this.#$.stiffness=parseFloat(Z[1]),this.#$.damping=parseFloat(Z[2]),this.#$.mass=parseFloat(Z[3]),!0;let $=Q.split(",").map((J)=>parseFloat(J.trim()));if($.length>=4&&$.every((J)=>!isNaN(J)))return this.#J="bezier",this.#Q.x=$[0],this.#Q.y=$[1],this.#Z.x=$[2],this.#Z.y=$[3],!0;return!1}#A(){if(this.#J==="bezier"){for(let Z of w.PRESETS){if(Z.type!=="bezier"||!Z.value)continue;if(Math.abs(this.#Q.x-Z.value[0])<0.001&&Math.abs(this.#Q.y-Z.value[1])<0.001&&Math.abs(this.#Z.x-Z.value[2])<0.001&&Math.abs(this.#Z.y-Z.value[3])<0.001)return Z.name}return"Custom bezier"}for(let Z of w.PRESETS){if(Z.type!=="spring"||!Z.spring)continue;if(Math.abs(this.#$.stiffness-Z.spring.stiffness)<0.001&&Math.abs(this.#$.damping-Z.spring.damping)<0.001&&Math.abs(this.#$.mass-Z.spring.mass)<0.001)return Z.name}return"Custom spring"}#E(){let{stiffness:Q,damping:Z,mass:$}=this.#$,J=0.004,j=5,q=[],_=0,X=0;for(let Y=0;Y<=5;Y+=0.004){let K=-Q*(_-1)-Z*X;if(X+=K/$*0.004,_+=X*0.004,q.push({t:Y,value:_}),Y>0.1&&Math.abs(_-1)<0.0005&&Math.abs(X)<0.0005)break}return q}static#C(Q,Z=24){let{stiffness:$,damping:J,mass:j}=Q,q=0.004,_=5,X=[],Y=0,K=0;for(let A=0;A<=5;A+=0.004){let M=-$*(Y-1)-J*K;if(K+=M/j*0.004,Y+=K*0.004,X.push({t:A,value:Y}),A>0.1&&Math.abs(Y-1)<0.001&&Math.abs(K)<0.001)break}let G=X[X.length-1].t||1,N=1;for(let A of X)if(A.value>N)N=A.value;let W=0;for(let A of X)if(A.value<W)W=A.value;let O=Math.max(N-W,1),B=6,L=Z-B*2,T=Math.max(1,Math.floor(X.length/30)),R="";for(let A=0;A<X.length;A+=T){let M=B+X[A].t/G*L,E=B+(1-(X[A].value-W)/O)*L;R+=(A===0?"M":"L")+M.toFixed(1)+","+E.toFixed(1)}return`<svg width="${Z}" height="${Z}" viewBox="0 0 ${Z} ${Z}" fill="none"><path d="${R}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,Z,$,J,j=24){let _=(j-12)/2,X=48,Y=[],K=(M,E,k,S,x)=>{let y=1-x;return y*y*y*M+3*y*y*x*E+3*y*x*x*k+x*x*x*S};for(let M=0;M<=48;M++){let E=M/48;Y.push({x:K(0,Q,$,1,E),y:K(0,Z,J,1,E)})}let G=1/0,N=-1/0,W=1/0,O=-1/0;for(let M of Y){if(M.x<G)G=M.x;if(M.x>N)N=M.x;if(M.y<W)W=M.y;if(M.y>O)O=M.y}let B=Math.max(N-G,0.000001),L=Math.max(O-W,0.000001),T=(M)=>_+(M-G)/B*12,R=(M)=>_+(1-(M-W)/L)*12,A="";for(let M=0;M<Y.length;M++){let E=T(Y[M].x),k=R(Y[M].y);A+=`${M===0?"M":"L"}${E.toFixed(1)},${k.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${A}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#k(){return this.getAttribute("edit")!=="false"}#y(){if(this.classList.toggle("spring-mode",this.#J==="spring"),this.classList.toggle("bezier-mode",this.#J!=="spring"),this.#g(),this.innerHTML=this.#w(),this.#x(),this.#_)this.#c(),this.#h(),this.#u();this.#l(),this.#U0()}static#v(Q){return String(Q).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#b(){let Q="",Z=void 0;for(let J of w.PRESETS){if(!this.#k()&&!J.value&&!J.spring)continue;if(J.group!==Z){if(J.group)Q+=`<fig-menu-separator label="${w.#v(J.group)}"></fig-menu-separator>`;Z=J.group}let j;if(J.type==="spring"){let _=J.spring||this.#$;j=w.#C(_)}else{let _=J.value||[this.#Q.x,this.#Q.y,this.#Z.x,this.#Z.y];j=w.curveIcon(..._)}let q=w.#v(J.name);Q+=`<fig-select-option value="${q}" label="${q}"><span slot="prepend">${j}</span><span>${q}</span></fig-select-option>`}return`<fig-select class="fig-easing-curve-select" label="Easing preset" value="${w.#v(this.#L)}" full><fig-select-options>${Q}</fig-select-options></fig-select>`}#w(){let Z=this.#b();if(!this.#k())return Z;let $=`<fig-input-text class="fig-easing-curve-value-input" value="${w.#v(this.value)}" full></fig-input-text>`;if(this.#J==="spring")return`${Z}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
280
+ </div>`,this.#Z=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#Q&&this.#j&&this.#J){if(!this.#j.hasAttribute("type"))this.#j.setAttribute("type","dropdown");if(!this.#j.hasAttribute("label"))this.#j.setAttribute("label",J);this.#J.append(this.#j)}this.#$=this.querySelector("fig-dropdown"),this.#R()}#U(){this.#L(),this.#$?.addEventListener("input",this.#Y),this.#Z?.addEventListener("input",this.#X),this.#Z?.addEventListener("change",this.#W)}#L(){this.#$?.removeEventListener("input",this.#Y),this.#Z?.removeEventListener("input",this.#X),this.#Z?.removeEventListener("change",this.#W)}#F(Q){Q.stopPropagation();let Z=Q.target.closest("fig-dropdown")?.value??"";if(this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#Z)this.#Z.setAttribute("value",Z);this.#M(),this.#D()}#z(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#M()}#B(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#D()}#M(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#D(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#T(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#H(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#O(){return`${this.#H()} options`}#R(){if(this.#Z)this.#_.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.#Z.removeAttribute(Q);else this.#Z.setAttribute(Q,Z)});if(this.#$&&!this.#$.hasAttribute("aria-label"))this.#$.setAttribute("label",this.#O())}#P(Q){if(this.#Z)if(Q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}focus(){this.#Z?.focus()}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"options":if(this.#$&&!this.#Q){let J=this.#T();this.#$.replaceChildren(...J.map((j)=>{let q=document.createElement("option");return q.textContent=j,q}))}break;case"placeholder":if(this.#Z)this.#Z.setAttribute("placeholder",$||"");this.#R();break;case"value":if(!this.#q&&this.#Z)this.#Z.setAttribute("value",$||"");break;case"disabled":this.#P($!==null&&$!=="false");break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#R();break}}}z("fig-combo-input",j1);class q1 extends HTMLElement{#Q="color";#Z=null;#$=!1;constructor(){super();this.#Z=this.#W.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#Y(),this.#J(),this.#X()}#J(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#j(Q){if(!Q)return"color";let Z=Q.toLowerCase();if(Z.includes("gradient"))return"gradient";if(Z.includes("url("))return"image";return"color"}#q(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:Z}=O0(1,1);return Z.fillStyle=Q,Z.fillStyle}catch{return"#D9D9D9"}}#_(Q){if(!Q||!Q.includes("var("))return Q;let Z=this.style.background;this.style.background=Q;let $=getComputedStyle(this),J=$.backgroundImage,j=$.backgroundColor;if(this.style.background=Z,J&&J!=="none")return J;return j||Q}#Y(){let Q=this.getAttribute("background")||"#D9D9D9",Z=Q.includes("var("),$=Z?this.#_(Q):Q,J=this.#j($);if(J!==this.#Q||!this.input){if(this.#Q=J,this.setAttribute("data-type",this.#Q),this.input)this.input.removeEventListener("input",this.#Z);if(this.#Q==="color"){let q=this.#q($);if(this.innerHTML=`<div></div><input type="color" value="${q}" />`,this.input=this.querySelector("input"),!Z)this.input.addEventListener("input",this.#Z);this.#X()}else this.innerHTML="<div></div>",this.input=null,this.#X()}else if(this.#Q==="color"&&this.input){let q=this.#q($);if(this.input.value!==q)this.input.value=q}let j=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Q);this.style.setProperty("--swatch-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#X(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",Q?"true":"false"),this.input){this.input.disabled=Q;let Z=this.getAttribute("aria-labelledby"),$=this.getAttribute("aria-label")||"Color swatch",J=this.getAttribute("aria-describedby");if(Z)this.input.setAttribute("aria-labelledby",Z),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",$),this.input.removeAttribute("aria-labelledby");if(J)this.input.setAttribute("aria-describedby",J);else this.input.removeAttribute("aria-describedby");this.removeAttribute("role"),this.removeAttribute("aria-hidden");return}if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-hidden","true");else this.setAttribute("role","img"),this.removeAttribute("aria-hidden")}#W(Q){this.#$=!0,this.setAttribute("background",Q.target.value),this.#$=!1}get background(){return this.getAttribute("background")}set background(Q){this.setAttribute("background",Q)}focus(){this.input?.focus()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="background"){if(this.#$){let J=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--swatch-background",J?$:`linear-gradient(${$}, ${$})`);return}this.#Y()}else if(Q==="alpha")this.#J();else if(Q==="disabled"||Q==="aria-label"||Q==="aria-labelledby"||Q==="aria-describedby")this.#X()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",Q)}}z("fig-swatch",q1);class K0 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#_=null;#Y=this.#c.bind(this);#X=this.#h.bind(this);#W=this.#d.bind(this);#N=this.#p.bind(this);#K=null;#G=null;#U=null;#L=null;#F=null;#z=null;#B=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","caption","controls","autoplay","loop","muted","poster","aria-label","aria-labelledby","title"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#Q}set src(Q){if(this.#Q=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#_}#M(){return this.#q||this.#Q||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#M())return null;if(!this.#Z)return null;try{if(typeof this.#Z.decode==="function")await this.#Z.decode();else if(!this.#Z.complete)await new Promise((J,j)=>{this.#Z.addEventListener("load",J,{once:!0}),this.#Z.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Z.naturalWidth,Z=this.#Z.naturalHeight;if(!(Q>0)||!(Z>0))return null;let $=document.createElement("canvas");return $.width=Q,$.height=Z,$.getContext("2d").drawImage(this.#Z,0,0),$.toDataURL()}connectedCallback(){this.#Q=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--fig-media-aspect-ratio",Q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let Z=this.getAttribute("fit");if(Z)this.style.setProperty("--fig-media-fit",Z);if(this.querySelectorAll("fig-swatch[data-generated]").forEach((J)=>J.remove()),this.#H(),this.#R(),this.#T(),this.#E(),this.#P(),this.#I(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#g();this.#J=this.querySelector("fig-input-file[data-generated]"),this.#J?.removeEventListener("change",this.#Y),this.#J?.addEventListener("change",this.#Y)}disconnectedCallback(){if(this.#J?.removeEventListener("change",this.#Y),this.#D(),this.#V(),this.#j)URL.revokeObjectURL(this.#j),this.#j=null;this.#q=null}#D(){if(!this.#Z)return;if(this.#Z.tagName==="VIDEO")this.#Z.removeEventListener("play",this.#X),this.#Z.removeEventListener("pause",this.#W),this.#Z.removeEventListener("ended",this.#N)}#T(){if(this.#D(),this.#Z?.tagName!=="VIDEO")return;this.#Z.addEventListener("play",this.#X),this.#Z.addEventListener("pause",this.#W),this.#Z.addEventListener("ended",this.#N)}#H(){if(this.#$?.isConnected)return;let Q=this.querySelector(":scope > fig-preview");if(Q){this.#$=Q;return}let Z=document.createElement("fig-preview");Z.setAttribute("data-generated",""),this.prepend(Z),this.#$=Z}#O(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#R(){let Q=this.#O();if(Q){if(this.#H(),this.#Z&&this.#Z!==Q){if(this.#D(),this.#Z.hasAttribute("data-generated"))this.#Z.remove()}if(this.#Z=Q,this.#$&&Q.parentElement!==this.#$)this.#$.append(Q);this.#P();return}this.#H();let Z=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Z&&this.#Z.tagName!==Z){if(this.#D(),this.#Z.hasAttribute("data-generated"))this.#Z.remove();this.#Z=null}if(this.#Z)return;if(this.mediaKind==="video"){let $=document.createElement("video");$.setAttribute("data-generated",""),$.className="fig-media-element",$.setAttribute("playsinline",""),$.preload="auto",this.#$.append($),this.#Z=$,this.#T();let J=()=>{if(this.#Z?.autoplay)return;try{this.#Z.currentTime=0.001}catch{}};this.#Z.addEventListener("loadedmetadata",J,{once:!0})}else{let $=document.createElement("img");$.setAttribute("data-generated",""),$.className="fig-media-element",$.loading="lazy",$.decoding="async",$.alt=this.getAttribute("alt")||"",this.#$.append($),this.#Z=$}}#P(){if(!this.#Z)return;if(this.#Z.tagName==="IMG"){if(this.hasAttribute("alt")||this.#Z.hasAttribute("data-generated"))this.#Z.alt=this.getAttribute("alt")||"";return}if(this.#Z.tagName!=="VIDEO")return;["aria-label","aria-labelledby","title"].forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.#Z.removeAttribute(Q);else this.#Z.setAttribute(Q,Z)})}#S(){return this.querySelector(":scope > figcaption:not([data-generated])")}#f(){return Array.from(this.querySelectorAll(":scope > figcaption[data-generated]"))}#I(){let Q=this.#S(),Z=this.#f();if(Q){Z.forEach((q)=>q.remove());return}let $=this.getAttribute("caption")||"";if(!$){Z.forEach((q)=>q.remove());return}let J=Z[0]||document.createElement("figcaption");if(Z.slice(1).forEach((q)=>q.remove()),!J.hasAttribute("data-generated"))J.setAttribute("data-generated","");if(J.textContent!==$)J.textContent=$;let j=this.querySelector(":scope > fig-media-controls");if(j)j.before(J);else if(this.#$?.isConnected)this.#$.after(J);else if(!J.isConnected)this.append(J)}#A(Q,Z=!1){if(!this.hasAttribute(Q))return Z;return this.getAttribute(Q)!=="false"}#E(){if(!this.#Z)return;if(!this.#Z.hasAttribute("data-generated"))return;let Q=this.#M();if(this.#Z.getAttribute("src")!==Q){if(Q)this.#Z.setAttribute("src",Q);else if(this.#Z.removeAttribute("src"),this.#Z.tagName==="VIDEO")this.#Z.load()}if(this.#Z.tagName==="IMG"){this.#P();return}let Z=this.getAttribute("poster");if(Z)this.#Z.setAttribute("poster",Z);else this.#Z.removeAttribute("poster");this.#Z.controls=!1,this.#Z.removeAttribute("controls"),this.#Z.autoplay=this.#A("autoplay",!1),this.#Z.loop=this.#A("loop",!1),this.#Z.muted=this.#A("muted",!1),this.#Z.playsInline=!0,this.#P(),this.#y(),this.#k()}get mediaEl(){return this.#Z}#C(){if(this.mediaKind!=="video")return!1;return Boolean(this.#M())}#k(){let Q=this.#K||this.querySelector(":scope > fig-media-controls");if(!Q)return;if(this.mediaKind!=="video")return;if(this.#C()){if(Q.hasAttribute("data-fig-empty-disabled"))Q.removeAttribute("disabled"),Q.removeAttribute("data-fig-empty-disabled");return}Q.setAttribute("disabled",""),Q.setAttribute("data-fig-empty-disabled",""),Q.playing=!1,Q.time=0,Q.duration=0}#y(){if(this.mediaKind!=="video"){this.#V();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#K!==Q)this.#V(),this.#K=Q;this.#b(),this.#k();return}if(this.#A("controls",!1))this.#v();else this.#V()}#v(){let Q=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Z=Q[0];if(Q.slice(1).forEach((J)=>J.remove()),Z){this.#K=Z,this.#b(),this.#k();return}let $=document.createElement("fig-media-controls");$.setAttribute("data-generated",""),this.append($),this.#K=$,this.#b(),this.#k()}#b(){if(!this.#K||!this.#Z)return;if(this.#G===this.#Z&&this.#U===this.#K){this.#k();return}this.#w();let Q=this.#K,Z=this.#Z;this.#G=Z,this.#U=Q;let $=null,J=()=>{if(this.#k(),!this.#C())return;if(Q.playing=!Z.paused&&!Z.ended,Number.isFinite(Z.duration))Q.duration=Z.duration;if($!==null)if(Math.abs(Z.currentTime-$)<0.25)$=null;else return;Q.time=Z.currentTime||0},j=()=>{if(!this.#C())return;let X=Z.play?.();if(X&&typeof X.catch==="function")X.catch(()=>{})},q=()=>Z.pause?.(),_=(X)=>{if(!this.#C())return;let Y=Number(X?.detail?.time);if(!Number.isFinite(Y))return;$=Y;try{Z.currentTime=Y}catch{}};this.#L=J,this.#F=j,this.#z=q,this.#B=_,Z.addEventListener("play",J),Z.addEventListener("pause",J),Z.addEventListener("ended",J),Z.addEventListener("timeupdate",J),Z.addEventListener("loadedmetadata",J),Z.addEventListener("durationchange",J),Z.addEventListener("seeked",J),Q.addEventListener("play",j),Q.addEventListener("pause",q),Q.addEventListener("seek",_),J()}#w(){let Q=this.#G,Z=this.#U;if(Q&&this.#L)Q.removeEventListener("play",this.#L),Q.removeEventListener("pause",this.#L),Q.removeEventListener("ended",this.#L),Q.removeEventListener("timeupdate",this.#L),Q.removeEventListener("loadedmetadata",this.#L),Q.removeEventListener("durationchange",this.#L),Q.removeEventListener("seeked",this.#L);if(Z){if(this.#F)Z.removeEventListener("play",this.#F);if(this.#z)Z.removeEventListener("pause",this.#z);if(this.#B)Z.removeEventListener("seek",this.#B)}this.#G=null,this.#U=null,this.#L=null,this.#F=null,this.#z=null,this.#B=null}#V(){this.#w(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((Q)=>{Q.remove()}),this.#K=null}toggle(){if(!this.#Z||this.mediaKind!=="video")return;if(this.#Z.paused||this.#Z.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Z)return;let Q=this.#Z.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Z)return;this.#Z.pause()}#g(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let Z=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#Q?"Replace":Z),this.#_?.name)Q.setAttribute("filename",this.#_.name);else if(this.#Q)Q.setAttribute("url",this.#Q);Q.addEventListener("change",this.#Y),this.#H(),this.#$.append(Q),this.#J=Q}#x(){if(this.#J)this.#J.removeEventListener("change",this.#Y),this.#J.remove(),this.#J=null}#c(Q){if(Q.target!==this.#J)return;let Z=Q.detail?.files?.[0],$=Q.detail?.cleared===!0;if(!Z){if(this.#j)URL.revokeObjectURL(this.#j),this.#j=null;if(this.#_=null,this.#q=null,$)this.src="";if(this.#E(),this.#J){let J=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#Q?"Replace":J),this.#J.removeAttribute("filename"),this.#Q)this.#J.setAttribute("url",this.#Q);else this.#J.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#j)URL.revokeObjectURL(this.#j);if(this.#_=Z,this.#j=URL.createObjectURL(Z),this.#q=this.#j,this.#E(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Z,src:this.#j}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#J)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",Z.name),this.#J.setAttribute("label","Replace")}#m(Q){if(!this.#Z)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Q||"",currentTime:this.#Z.currentTime,duration:this.#Z.duration}}))}#h(){this.#m("play")}#d(){this.#m("pause")}#p(){this.#m("ended")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="src"){let J=$||"",j=J&&(J===this.#q||J===this.#j);if(this.#Q=J,this.#j&&!j)URL.revokeObjectURL(this.#j),this.#j=null,this.#q=null,this.#_=null;if(this.#E(),this.#J){let q=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#Q?"Replace":q),this.#Q)if(this.#_?.name)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",this.#_.name);else this.#J.setAttribute("url",this.#Q),this.#J.removeAttribute("filename");else this.#J.removeAttribute("url"),this.#J.removeAttribute("filename")}}if(Q==="type"){if(this.#R(),this.#E(),this.#J)this.#J.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(Q))this.#P();if(Q==="upload"){let J=$!==null&&$!=="false";if(J&&!this.#J)this.#g();else if(!J)this.#x()}if(Q==="aspect-ratio")if($)this.style.setProperty("--fig-media-aspect-ratio",$);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if($)this.style.setProperty("--fig-media-fit",$);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#J){let J=this.getAttribute("label")||"Upload";this.#J.setAttribute("label",this.#Q?"Replace":J)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#E();if(Q==="caption")this.#I()}}z("fig-media",K0);class _1 extends K0{get mediaKind(){return"image"}}z("fig-image",_1);class X1 extends K0{get mediaKind(){return"video"}}z("fig-video",X1);class Y1 extends HTMLElement{static get observedAttributes(){return["src","alt","label","text","sublabel","href","target","selected","disabled","full","aspect-ratio","fit","label-line-clamp"]}#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#_=!1;connectedCallback(){this.#G(),this.#U()}attributeChangedCallback(){if(!this.isConnected)return;this.#G(),this.#U()}#Y(){return this.getAttribute("label")??this.getAttribute("text")??""}#X(){return this.getAttribute("sublabel")??""}#W(){let Q=this.getAttribute("href");return Boolean(Q)&&!F(this,"disabled")}#N(){return this.getAttribute("label-line-clamp")==="2"?"2":"1"}#K(){return this.querySelector(":scope > fig-image:not([data-generated]), :scope > fig-media:not([data-generated]), :scope > fig-preview:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-image:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-media:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-preview:not([data-generated])")}#G(){let Q=this.#K();this.#_=Boolean(Q);let $=this.#W()?"a":"div";if(!this.#Q||this.#Q.tagName.toLowerCase()!==$){let J=document.createElement($);if(J.className="fig-card-link",this.#Q){while(this.#Q.firstChild)J.appendChild(this.#Q.firstChild);this.#Q.replaceWith(J)}else this.appendChild(J);this.#Q=J}if(!this.#Z||!this.#Z.isConnected){if(this.#Z=this.#Q.querySelector(":scope > .fig-card-media"),!this.#Z)this.#Z=document.createElement("div"),this.#Z.className="fig-card-media",this.#Q.prepend(this.#Z)}if(Q&&Q.parentElement!==this.#Z)this.#Z.querySelectorAll("[data-generated]").forEach((J)=>J.remove()),this.#Z.appendChild(Q),this.#J=null;if(!this.#_){if(this.#J=this.#Z.querySelector(":scope > fig-image[data-generated]")||null,!this.#J)this.#Z.querySelectorAll(":scope > fig-image, :scope > fig-media, :scope > fig-preview").forEach((J)=>{if(J.hasAttribute("data-generated"))J.remove()}),this.#J=document.createElement("fig-image"),this.#J.setAttribute("data-generated",""),this.#J.setAttribute("full",""),this.#J.setAttribute("size","auto"),this.#Z.appendChild(this.#J)}if(!this.#$||!this.#$.isConnected){if(this.#$=this.#Q.querySelector(":scope > .fig-card-text"),!this.#$)this.#$=document.createElement("div"),this.#$.className="fig-card-text",this.#$.setAttribute("data-generated",""),this.#Q.appendChild(this.#$)}if(!this.#j||!this.#j.isConnected){if(this.#j=this.#$.querySelector(":scope > .fig-card-label[data-generated]"),!this.#j){if(this.#j=this.#Q.querySelector(":scope > .fig-card-label[data-generated]")||null,!this.#j)this.#j=document.createElement("label"),this.#j.className="fig-card-label",this.#j.setAttribute("data-generated","");this.#$.appendChild(this.#j)}}if(!this.#q||!this.#q.isConnected){if(this.#q=this.#$.querySelector(":scope > .fig-card-sublabel[data-generated]"),!this.#q){if(this.#q=this.#Q.querySelector(":scope > .fig-card-sublabel[data-generated]")||null,!this.#q)this.#q=document.createElement("span"),this.#q.className="fig-card-sublabel",this.#q.setAttribute("data-generated","");this.#j.after(this.#q)}}}#U(){if(!this.#Q)return;let Q=F(this,"disabled"),Z=F(this,"selected"),$=this.#Y(),J=this.#X(),j=this.#N();if(this.style.setProperty("--fig-card-label-line-clamp",j),this.#W()){let q=this.getAttribute("href")||"",_=this.getAttribute("target");if(this.#Q.setAttribute("href",q),_)if(this.#Q.setAttribute("target",_),_==="_blank")this.#Q.setAttribute("rel","noopener noreferrer");else this.#Q.removeAttribute("rel");else this.#Q.removeAttribute("target"),this.#Q.removeAttribute("rel");if(Z)this.#Q.setAttribute("aria-current","true");else this.#Q.removeAttribute("aria-current");this.removeAttribute("role"),this.removeAttribute("aria-label")}else{this.#Q.removeAttribute("href"),this.#Q.removeAttribute("target"),this.#Q.removeAttribute("rel"),this.#Q.removeAttribute("aria-current"),this.setAttribute("role","group");let q=[$,J].filter(Boolean).join(", ");if(q)this.setAttribute("aria-label",q);else this.removeAttribute("aria-label")}if(Q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#J&&!this.#_){let q=this.getAttribute("src"),_=this.getAttribute("alt"),X=this.getAttribute("aspect-ratio")||"1/1",Y=this.getAttribute("fit")||"contain",K=_!=null?_:"";if(q)this.#J.setAttribute("src",q);else this.#J.removeAttribute("src");this.#J.setAttribute("alt",K),this.#J.setAttribute("aspect-ratio",X),this.#J.setAttribute("fit",Y),this.#J.setAttribute("full",""),this.#J.setAttribute("size","auto")}if(this.#j)this.#j.textContent=$,this.#j.hidden=!$;if(this.#q)this.#q.textContent=J,this.#q.hidden=!J;if(this.#$)this.#$.hidden=!$&&!J}}z("fig-card",Y1);class K1 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=!1;#q=!1;static get observedAttributes(){return["playing","duration","time","disabled"]}connectedCallback(){this.#_(),this.#N(),this.#K(),this.#Y()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let Q=Number(this.getAttribute("duration"));return Number.isFinite(Q)&&Q>=0?Q:0}set duration(Q){let Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("duration");return}this.setAttribute("duration",String(Z))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("time");return}this.setAttribute("time",String(Z))}get disabled(){return F(this,"disabled")}set disabled(Q){if(Q)this.setAttribute("disabled","");else this.removeAttribute("disabled")}attributeChangedCallback(Q){if(!this.#q)return;if(Q==="playing")this.#N();if(Q==="duration"||Q==="time")this.#K();if(Q==="disabled")this.#Y()}#_(){if(this.#q)return;if(this.#q=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Play");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("size","small"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Play");let $=u("play",{className:"fig-media-controls-play-icon"});Z.append($),Q.append(Z),Z.addEventListener("click",(_)=>{_.preventDefault(),_.stopPropagation(),this.toggle()});let J=document.createElement("fig-slider");J.setAttribute("text","false"),J.setAttribute("min","0"),J.setAttribute("max",String(this.duration)),J.setAttribute("step","1"),J.setAttribute("value",String(this.time)),J.setAttribute("full",""),J.setAttribute("aria-label","Seek"),J.setAttribute("aria-valuetext",this.#W(this.time,this.duration));let j=document.createElement("span");j.className="fig-media-controls-time",j.textContent=this.#X(this.time);let q=(_)=>{if(this.disabled){_.preventDefault?.(),_.stopPropagation();return}let X=_.currentTarget,Y=Number(X?.value);if(!Number.isFinite(Y))return;this.#j=!0,this.setAttribute("time",String(Y)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:Y}})),requestAnimationFrame(()=>{this.#j=!1})};J.addEventListener("input",q),J.addEventListener("change",q),this.append(Q,J,j),this.#Q=Z,this.#Z=Q,this.#$=J,this.#J=j,this.#Y()}#Y(){let Q=this.disabled;if(this.setAttribute("aria-disabled",Q?"true":"false"),this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}#X(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let Z=Math.floor(Q),$=Math.floor(Z/60),J=Z%60;return`${String($).padStart(2,"0")}:${String(J).padStart(2,"0")}`}#W(Q,Z=0){let $=this.#X(Q);if(!Number.isFinite(Z)||Z<=0)return $;return`${$} of ${this.#X(Z)}`}#N(){if(!this.#Q)return;let Q=this.playing;this.#Q.setAttribute("aria-label",Q?"Pause":"Play"),this.#Z?.setAttribute("text",Q?"Pause":"Play");let Z=this.#Q.querySelector(".fig-media-controls-play-icon");if(Z)Z.setAttribute("name",Q?"pause":"play")}#K(){if(!this.#$)return;let Q=this.duration;if(Number(this.#$.getAttribute("max"))!==Q)this.#$.setAttribute("max",String(Q));let Z=this.time;if(!this.#j)this.#$.setAttribute("value",String(Z));if(this.#$.setAttribute("aria-valuetext",this.#W(Z,Q)),this.#J)this.#J.textContent=this.#X(Z)}toggle(){if(this.disabled)return;let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.disabled||this.playing)return;this.toggle()}pause(){if(this.disabled||!this.playing)return;this.toggle()}}z("fig-media-controls",K1);class G1 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;get files(){return this.#q}get#_(){let Q=this.getAttribute("filename");if(Q)return Q;let Z=this.getAttribute("url");if(!Z)return"";try{let J=new URL(Z,location.href).pathname.split("/").pop();return J?decodeURIComponent(J):Z}catch{return Z}}get value(){if(this.#q&&this.#q.length>0){if(this.#q.length===1)return this.#q[0].name;return`${this.#q.length} files`}return this.#_}connectedCallback(){this.#U(),this.addEventListener("dragover",this.#N),this.addEventListener("dragleave",this.#K),this.addEventListener("drop",this.#G)}disconnectedCallback(){this.#Q?.removeEventListener("change",this.#X),this.#$?.removeEventListener("click",this.#W),this.removeEventListener("dragover",this.#N),this.removeEventListener("dragleave",this.#K),this.removeEventListener("drop",this.#G)}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#U()}clear(){if(this.#q=null,this.#Q)this.#Q.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#U(),this.#Y({cleared:!0})}#Y(Q={}){let Z={files:this.#q,...Q};this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0}))}#X=()=>{if(this.#Q.files.length>0)this.#q=this.#Q.files,this.removeAttribute("url"),this.#U(),this.#Y()};#W=(Q)=>{Q.stopPropagation(),this.clear()};#N=(Q)=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#j)this.#j.dataset.prevText=this.#j.textContent,this.#j.textContent="Drop file"}};#K=()=>{if(this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText};#G=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.getAttribute("accepts"),$=Array.from(Q.dataTransfer.files);if(Z){let j=Z.split(",").map((q)=>q.trim().toLowerCase());$=$.filter((q)=>{let _="."+q.name.split(".").pop().toLowerCase(),X=q.type.toLowerCase();return j.some((Y)=>Y===_||Y===X||Y.endsWith("/*")&&X.startsWith(Y.slice(0,-1)))})}if(!this.hasAttribute("multiple")||this.getAttribute("multiple")==="false")$=$.slice(0,1);if($.length===0)return;let J=new DataTransfer;if($.forEach((j)=>J.items.add(j)),this.#q=J.files,this.#Q)this.#Q.files=J.files;this.removeAttribute("url"),this.#U(),this.#Y()};#U(){let Q=this.getAttribute("accepts")||"",Z=this.getAttribute("label")||"Upload",$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.hasAttribute("multiple")&&this.getAttribute("multiple")!=="false",j=this.getAttribute("variant")||"input",q=this.#q&&this.#q.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",q){let _=Q?`Accepts ${Q.split(",").map((N)=>N.trim()).join(", ")}`:"";if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.className="fig-input-file-filename",$)this.#j.setAttribute("disabled","");let X=document.createElement("fig-truncate");X.setAttribute("position","middle"),X.setAttribute("tooltip","");let Y=this.value,K=Y.lastIndexOf(".");if(K>0)X.setAttribute("tail",Y.slice(K));if(X.textContent=Y,this.#j.appendChild(X),this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",this.#Q.disabled=$,Q)this.#Q.setAttribute("accept",Q);if(J)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#X),this.#j.appendChild(this.#Q),_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_),this.#J.appendChild(this.#j),this.appendChild(this.#J);else this.appendChild(this.#j);let G=document.createElement("fig-tooltip");if(G.setAttribute("text","Remove"),this.#$=document.createElement("fig-button"),this.#$.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#$.setAttribute("icon","true"),this.#$.setAttribute("aria-label","Remove"),this.#$.className="fig-input-file-clear",$)this.#$.setAttribute("disabled","");this.#$.replaceChildren(u("minus")),this.#$.addEventListener("click",this.#W),G.appendChild(this.#$),this.appendChild(G)}else{let _=Q?`Accepts ${Q.split(",").map((X)=>X.trim()).join(", ")}`:"";if(_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_);if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.textContent=Z,$)this.#j.setAttribute("disabled","");if(this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",this.#Q.disabled=$,Q)this.#Q.setAttribute("accept",Q);if(J)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#X),this.#j.appendChild(this.#Q),this.#J)this.#J.appendChild(this.#j),this.appendChild(this.#J);else this.appendChild(this.#j)}}}z("fig-input-file",G1);class w extends HTMLElement{#Q={x:0.42,y:0};#Z={x:0.58,y:1};#$={stiffness:200,damping:15,mass:1};#J="bezier";#j=2;#q=null;#_=null;#Y=null;#X=null;#W=null;#N=null;#K=null;#G=null;#U=null;#L=null;#F=null;#z=0.8;#B=200;#M=200;#D=null;#T=null;#H=null;#O=null;#R=5;#P=10;#S=10;#f=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#j=parseInt(this.getAttribute("precision")||"2"),b(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#I(Q);this.#L=this.#A(),this.#y(),this.#m()}disconnectedCallback(){if(this.#q=null,this.#O)this.#O.disconnect(),this.#O=null}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="aspect-ratio"){if(b(this,"--aspect-ratio",$),this.#_)this.#h(),this.#u();return}if(Q==="edit"){if(this.isConnected)this.#y();return}if(Q==="value"&&$){let J=this.#J;if(this.#I($),this.#L=this.#A(),J!==this.#J&&this.#k())this.#y();else{if(this.#_)this.#u();this.#e(),this.#l()}}if(Q==="precision")this.#j=parseInt($||"2")}get value(){if(this.#J==="spring"){let{stiffness:Z,damping:$,mass:J}=this.#$;return`spring(${Z}, ${$}, ${J})`}let Q=this.#j;return`${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}, ${this.#Z.x.toFixed(Q)}, ${this.#Z.y.toFixed(Q)}`}get cssValue(){if(this.#J==="spring"){let Z=this.#E(),$=20,J=Math.max(1,Math.floor(Z.length/20)),j=[];for(let q=0;q<Z.length;q+=J)j.push(Z[q].value.toFixed(3));if(Z.length>0)j.push(Z[Z.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#j;return`cubic-bezier(${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}, ${this.#Z.x.toFixed(Q)}, ${this.#Z.y.toFixed(Q)})`}get preset(){return this.#L}set value(Q){this.setAttribute("value",Q)}#I(Q){let Z=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if(Z)return this.#J="spring",this.#$.stiffness=parseFloat(Z[1]),this.#$.damping=parseFloat(Z[2]),this.#$.mass=parseFloat(Z[3]),!0;let $=Q.split(",").map((J)=>parseFloat(J.trim()));if($.length>=4&&$.every((J)=>!isNaN(J)))return this.#J="bezier",this.#Q.x=$[0],this.#Q.y=$[1],this.#Z.x=$[2],this.#Z.y=$[3],!0;return!1}#A(){if(this.#J==="bezier"){for(let Z of w.PRESETS){if(Z.type!=="bezier"||!Z.value)continue;if(Math.abs(this.#Q.x-Z.value[0])<0.001&&Math.abs(this.#Q.y-Z.value[1])<0.001&&Math.abs(this.#Z.x-Z.value[2])<0.001&&Math.abs(this.#Z.y-Z.value[3])<0.001)return Z.name}return"Custom bezier"}for(let Z of w.PRESETS){if(Z.type!=="spring"||!Z.spring)continue;if(Math.abs(this.#$.stiffness-Z.spring.stiffness)<0.001&&Math.abs(this.#$.damping-Z.spring.damping)<0.001&&Math.abs(this.#$.mass-Z.spring.mass)<0.001)return Z.name}return"Custom spring"}#E(){let{stiffness:Q,damping:Z,mass:$}=this.#$,J=0.004,j=5,q=[],_=0,X=0;for(let Y=0;Y<=5;Y+=0.004){let K=-Q*(_-1)-Z*X;if(X+=K/$*0.004,_+=X*0.004,q.push({t:Y,value:_}),Y>0.1&&Math.abs(_-1)<0.0005&&Math.abs(X)<0.0005)break}return q}static#C(Q,Z=24){let{stiffness:$,damping:J,mass:j}=Q,q=0.004,_=5,X=[],Y=0,K=0;for(let A=0;A<=5;A+=0.004){let M=-$*(Y-1)-J*K;if(K+=M/j*0.004,Y+=K*0.004,X.push({t:A,value:Y}),A>0.1&&Math.abs(Y-1)<0.001&&Math.abs(K)<0.001)break}let G=X[X.length-1].t||1,N=1;for(let A of X)if(A.value>N)N=A.value;let W=0;for(let A of X)if(A.value<W)W=A.value;let O=Math.max(N-W,1),B=6,L=Z-B*2,T=Math.max(1,Math.floor(X.length/30)),R="";for(let A=0;A<X.length;A+=T){let M=B+X[A].t/G*L,E=B+(1-(X[A].value-W)/O)*L;R+=(A===0?"M":"L")+M.toFixed(1)+","+E.toFixed(1)}return`<svg width="${Z}" height="${Z}" viewBox="0 0 ${Z} ${Z}" fill="none"><path d="${R}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,Z,$,J,j=24){let _=(j-12)/2,X=48,Y=[],K=(M,E,k,S,x)=>{let y=1-x;return y*y*y*M+3*y*y*x*E+3*y*x*x*k+x*x*x*S};for(let M=0;M<=48;M++){let E=M/48;Y.push({x:K(0,Q,$,1,E),y:K(0,Z,J,1,E)})}let G=1/0,N=-1/0,W=1/0,O=-1/0;for(let M of Y){if(M.x<G)G=M.x;if(M.x>N)N=M.x;if(M.y<W)W=M.y;if(M.y>O)O=M.y}let B=Math.max(N-G,0.000001),L=Math.max(O-W,0.000001),T=(M)=>_+(M-G)/B*12,R=(M)=>_+(1-(M-W)/L)*12,A="";for(let M=0;M<Y.length;M++){let E=T(Y[M].x),k=R(Y[M].y);A+=`${M===0?"M":"L"}${E.toFixed(1)},${k.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${A}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#k(){return this.getAttribute("edit")!=="false"}#y(){if(this.classList.toggle("spring-mode",this.#J==="spring"),this.classList.toggle("bezier-mode",this.#J!=="spring"),this.#g(),this.innerHTML=this.#w(),this.#x(),this.#_)this.#c(),this.#h(),this.#u();this.#l(),this.#U0()}static#v(Q){return String(Q).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#b(){let Q="",Z=void 0;for(let J of w.PRESETS){if(!this.#k()&&!J.value&&!J.spring)continue;if(J.group!==Z){if(J.group)Q+=`<fig-separator label="${w.#v(J.group)}"></fig-separator>`;Z=J.group}let j;if(J.type==="spring"){let _=J.spring||this.#$;j=w.#C(_)}else{let _=J.value||[this.#Q.x,this.#Q.y,this.#Z.x,this.#Z.y];j=w.curveIcon(..._)}let q=w.#v(J.name);Q+=`<fig-select-option value="${q}" label="${q}"><span slot="prepend">${j}</span><span>${q}</span></fig-select-option>`}return`<fig-select class="fig-easing-curve-select" label="Easing preset" value="${w.#v(this.#L)}" full><fig-select-options>${Q}</fig-select-options></fig-select>`}#w(){let Z=this.#b();if(!this.#k())return Z;let $=`<fig-input-text class="fig-easing-curve-value-input" value="${w.#v(this.value)}" full></fig-input-text>`;if(this.#J==="spring")return`${Z}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
281
281
  <rect class="fig-easing-curve-bounds" x="0" y="0" width="200" height="200"/>
282
282
  <line class="fig-easing-curve-target" x1="0" y1="40" x2="200" y2="40"/>
283
283
  <path class="fig-easing-curve-path"/>
@@ -361,4 +361,4 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
361
361
  <div class="fig-interpolation-swatch-fill" aria-hidden="true"></div>
362
362
  `,this.#X=this.querySelector(".fig-interpolation-swatch-svg"),this.#W=this.querySelector(".fig-interpolation-swatch-fill"),this.#Y=!0}#S(){if(!this.#W)return;let Q=this.#L();if(this.#X)this.#X.style.display=Q?"":"none";let Z=Q?(()=>{let{startDeg:J,sweepDeg:j}=this.#z();return this.#M(J,j)})():this.#D(),$=this.#T(Z);this.#W.style.setProperty("-webkit-mask-image",$),this.#W.style.maskImage=$,this.#W.style.background=this.#R()}}z("fig-interpolation-swatch",C);var l1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:{medium:"--icon-24-reset",small:"--icon-16-reset"},"arrow-left":{medium:"--icon-24-arrow-left",small:"--icon-16-arrow-left"},steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",adjust:{medium:"--icon-24-adjust",small:"--icon-16-adjust"},minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",download:"--icon-24-download",upload:"--icon-24-upload",sun:"--icon-24-sun",moon:"--icon-24-moon",edit:{medium:"--icon-24-edit",small:"--icon-16-edit"},settings:{medium:"--icon-24-settings",small:"--icon-16-settings"},more:{medium:"--icon-24-more",small:"--icon-16-more"},visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function a1(Q,Z="medium"){let $=Q&&l1[Q];if(!$)return"";let J=typeof $==="string"?$:$[Z==="small"?"small":"medium"];return J?`var(${J})`:""}class z1 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#Q()}attributeChangedCallback(Q,Z,$){if(Z!==$)this.#Q()}#Q(){let Q=this.getAttribute("name"),Z=this.getAttribute("size")||"medium",$=a1(Q,Z);if($)this.style.setProperty("--icon",$);else this.style.removeProperty("--icon");if(Z==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let J=this.getAttribute("color");if(J)this.style.backgroundColor=J;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}z("fig-icon",z1);class H1 extends HTMLElement{}z("fig-content",H1);class A1 extends HTMLElement{}z("fig-tab-content",A1);class R1 extends HTMLElement{}z("fig-button-combo",R1);class D1 extends HTMLElement{}z("fig-input-combo",D1);class T1 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=this.#B.bind(this);#j=this.#M.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#q(){return this.getAttribute("control")||"color"}connectedCallback(){this.#W(),this.#L()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#N)}#_(){if(this.#Q)this.#Q.removeEventListener("input",this.#J),this.#Q.removeEventListener("change",this.#j);if(this.#Z)this.#Z.removeEventListener("input",this.#J),this.#Z.removeEventListener("change",this.#j);if(this.#$)this.#$.disconnect(),this.#$=null}#Y(){if(this.#$)this.#$.disconnect(),this.#$=null;if(!this.#Z)return;this.#$=new MutationObserver(()=>{if(this.#Z?.hasAttribute("selected")&&this.#Z.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#$.observe(this.#Z,{attributes:!0,attributeFilter:["selected"]})}get#X(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#W(){let Q=this.#q;if(Q==="add"||Q==="remove"){let X=Q==="add"?"add":"minus",Y=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");this.innerHTML=`<fig-button icon variant="ghost" aria-label="${v(Y)}"><fig-icon name="${X}"></fig-icon></fig-button>`,this.#Q=null,this.#Z=null,this.addEventListener("click",this.#N),this.#F();return}this.removeEventListener("click",this.#N);let Z=(this.getAttribute("value")||"").trim(),$=this.#U(Z),J=this.#G(Z),j=this.#X?"":'alpha="false"',q=J<1?JSON.stringify({type:"solid",color:$,opacity:Math.round(J*100)}):JSON.stringify({type:"solid",color:$}),_=J<1?` alpha="${J}"`:"";if(this.innerHTML=o()?`<fig-fill-picker mode="solid" ${j} value='${q}'>
363
363
  <fig-swatch background="${$}"${_}></fig-swatch>
364
- </fig-fill-picker>`:`<fig-swatch background="${$}"${_}></fig-swatch>`,this.#Q=this.querySelector("fig-fill-picker"),this.#Z=this.querySelector("fig-swatch"),this.#_(),this.#Q?.addEventListener("input",this.#J),this.#Q?.addEventListener("change",this.#j),!this.#Q)this.#Z?.addEventListener("input",this.#J),this.#Z?.addEventListener("change",this.#j);this.#Y(),this.#F()}#N=()=>{let Q=this.#q;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#K(Q){if(!Q)return"#D9D9D9";let Z=Q.replace("#","").trim();if(Z.length===3||Z.length===4){let[$,J,j]=Z;return`#${$}${$}${J}${J}${j}${j}`.toUpperCase()}if(Z.length===6||Z.length===8)return`#${Z.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#G(Q){if(!Q)return 1;let Z=String(Q).trim(),$=Z.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test($)){let j=$[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test($))return parseInt($.slice(6,8),16)/255;let J=Z.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(J)return parseFloat(J[1]);return 1}#U(Q){if(!Q)return"#D9D9D9";let Z=String(Q).trim();if(Z.startsWith("{"))try{let $=JSON.parse(Z);if($?.color)return this.#U($.color)}catch{}if(Z.startsWith("#"))return this.#K(Z);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Z))return this.#K(Z);try{let{ctx:$}=O0(1,1);$.fillStyle="#000000",$.fillStyle=Z;let J=$.fillStyle;if(J.startsWith("#"))return this.#K(J);let j=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let q=(_)=>Math.max(0,Math.min(255,Number(_))).toString(16).padStart(2,"0");return`#${q(j[1])}${q(j[2])}${q(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#L(){let Q=this.getAttribute("value"),Z=this.#U(Q),$=this.#G(Q);if(Q!==Z&&$>=1){this.setAttribute("value",Z);return}if(this.#Q){this.#F();let J=$<1?{type:"solid",color:Z,opacity:Math.round($*100)}:{type:"solid",color:Z};if(this.#Q.setAttribute("value",JSON.stringify(J)),this.#X)this.#Q.removeAttribute("alpha");else this.#Q.setAttribute("alpha","false");if(F(this,"disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}if(this.#Z){if(this.#F(),this.#Z.setAttribute("background",Z),$<1)this.#Z.setAttribute("alpha",String($));else this.#Z.removeAttribute("alpha");if(F(this,"disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}}#F(){let Q=this.#q,Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",Z?"true":"false"),this.setAttribute("aria-pressed",$?"true":"false"),Q==="add"||Q==="remove"){let X=this.querySelector("fig-button"),Y=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");if(X?.setAttribute("aria-label",Y),Z)X?.setAttribute("disabled","");else X?.removeAttribute("disabled");return}let J=this.#Q||this.#Z;if(!J)return;let j=this.getAttribute("aria-label")||"Color stop",q=this.getAttribute("aria-labelledby"),_=this.getAttribute("aria-describedby");if(q)J.setAttribute("aria-labelledby",q),J.removeAttribute("aria-label");else J.setAttribute("aria-label",j),J.removeAttribute("aria-labelledby");if(_)J.setAttribute("aria-describedby",_);else J.removeAttribute("aria-describedby")}#z(Q,Z){let $=this.#U(Q?.color),J=this.#U(this.getAttribute("value"));if($!==J)this.setAttribute("value",$);else this.#L();let j={color:this.value};if(this.#X){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent(Z,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#B(Q){Q.stopPropagation(),this.#z(Q.detail||{color:Q.target?.value},"input")}#M(Q){Q.stopPropagation(),this.#z(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(!this.isConnected)return;switch(Q){case"control":this.#W();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#L(),this.#F();break}}get value(){return this.#U(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#U(Q))}get selected(){return F(this,"selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return F(this,"disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}z("fig-color-tip",T1);class P1 extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",F(this,"selected")?"true":"false"),F(this,"disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",F(this,"selected")?"true":"false");if(Q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}z("fig-choice",P1);class E1 extends HTMLElement{#Q=null;#Z=this.#D.bind(this);#$=this.#T.bind(this);#J=this.#O.bind(this);#j=null;#q=null;#_=null;#Y=null;#X=null;#W=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#N(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#K(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#G(){return this.getAttribute("choice-element")||"fig-choice"}#U(){let Q=this.getAttribute("columns"),Z=Q===null?NaN:Number(Q);if(Number.isInteger(Z)&&Z>0)this.style.setProperty("--fig-chooser-grid-columns",String(Z));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from(this.querySelectorAll(`:scope > ${this.#G}`))}get selectedChoice(){return this.#Q}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let Z=this.choices;for(let J of Z){let j=J===Q,q=F(J,"selected");if(j&&!q)J.setAttribute("selected","");else if(!j&&q)J.removeAttribute("selected")}this.#Q=Q;let $=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==$){if($)this.setAttribute("value",$)}this.#y(Q)}get value(){return this.#Q?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){if(this.setAttribute("role","listbox"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.#f(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#$),this.addEventListener("scroll",this.#J),this.#I(),this.#P(),this.#v(),this.#R(),this.#z(),c(this,()=>{this.#F(),this.#O(),this.#L()})}#L(){let Q=()=>{if(!this.isConnected)return;if(this.#Q)this.#y(this.#Q,"auto")},Z=()=>{let $=this.querySelectorAll("img, video");for(let J of $){if(J.tagName==="IMG"?J.complete:J.readyState>=1)continue;let j=()=>{J.removeEventListener("load",j),J.removeEventListener("loadedmetadata",j),J.removeEventListener("error",j),Q()};J.addEventListener("load",j),J.addEventListener("loadedmetadata",j),J.addEventListener("error",j)}};requestAnimationFrame(()=>{Z(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#$),this.removeEventListener("scroll",this.#J),this.#S(),this.#j?.disconnect(),this.#j=null,this.#q?.disconnect(),this.#q=null,this.#A()}attributeChangedCallback(Q,Z,$){if(Q==="value"&&$!==Z&&$)this.#B($);if(Q==="disabled")this.#z();if(Q==="choice-element")requestAnimationFrame(()=>this.#F());if(Q==="columns")this.#U(),this.#k();if(Q==="drag")if(this.#K)this.#P();else this.#S();if(Q==="overflow")this.#I(),requestAnimationFrame(()=>this.#O());if(Q==="layout"){if(this.#I(),$==="horizontal")this.scrollTop=0;else this.scrollLeft=0;this.#k()}}#F(){let Q=this.choices;if(!Q.length){this.#Q=null;return}let Z=this.getAttribute("value");if(Z&&this.#B(Z))return;let $=Q.find((J)=>F(J,"selected"));if($){this.selectedChoice=$;return}this.selectedChoice=Q[0]}#z(){let Q=F(this,"disabled");if(Q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Z of this.choices)if(Q||F(Z,"disabled"))Z.setAttribute("aria-disabled","true"),Z.setAttribute("tabindex","-1");else Z.removeAttribute("aria-disabled"),Z.setAttribute("tabindex","0")}#B(Q){let Z=this.choices;for(let $ of Z)if($.getAttribute("value")===Q)return this.selectedChoice=$,!0;return!1}#M(Q){let Z=this.#G,$=Q;while($&&$!==this){if($.matches(Z))return $;$=$.parentElement}return null}#D(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#M(Q.target);if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.selectedChoice=Z,this.#H()}#T(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!Z.length)return;let $=Z.indexOf(this.#Q),J=$,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),$<Z.length-1)J=$+1;else if(j)J=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),$>0)J=$-1;else if(j)J=Z.length-1;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#G)){let q=this.#M(document.activeElement);if(q&&q!==this.#Q)this.selectedChoice=q,this.#H()}return;default:return}if(J!==$&&Z[J])this.selectedChoice=Z[J],Z[J].focus(),this.#H()}#H(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#O(){if(this.#N==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal";a(this,this,Q?"x":"y")}#R(){this.#q?.disconnect(),this.#q=new ResizeObserver(()=>{this.#O(),this.#k()}),this.#q.observe(this)}#P(){if(this.#X?.bound)return;if(!this.#K)return;let Q=(q)=>{if(q.button!==0)return;if(q.target.closest("[data-fig-chooser-nav]"))return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#X.active=!0,this.#X.didDrag=!1,this.#X.startX=q.clientX,this.#X.startY=q.clientY,this.#X.scrollLeft=this.scrollLeft,this.#X.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Z=(q)=>{if(!this.#X.active)return;let _=this.getAttribute("layout")==="horizontal",X=q.clientX-this.#X.startX,Y=q.clientY-this.#X.startY;if(!this.#X.didDrag&&Math.abs(_?X:Y)>3)this.#X.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(q.pointerId);if(!this.#X.didDrag)return;if(_)this.scrollLeft=this.#X.scrollLeft-X;else this.scrollTop=this.#X.scrollTop-Y},$=(q)=>{if(!this.#X.active)return;let _=this.#X.didDrag;if(this.#X.active=!1,this.#X.didDrag=!1,this.style.cursor="",this.style.userSelect="",q.pointerId!==void 0)try{this.releasePointerCapture(q.pointerId)}catch{}if(_)q.preventDefault(),q.stopPropagation()},J=(q)=>{if(this.#X?.suppressClick)q.stopPropagation(),q.preventDefault(),this.#X.suppressClick=!1},j=(q)=>{if(this.#X?.didDrag)this.#X.suppressClick=!0,setTimeout(()=>{if(this.#X)this.#X.suppressClick=!1},0)};this.#X={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:Q,onPointerMove:Z,onPointerUp:$,onClick:J,onPointerUpCapture:j},this.addEventListener("pointerdown",Q),window.addEventListener("pointermove",Z),window.addEventListener("pointerup",$),this.addEventListener("pointerup",j,!0),this.addEventListener("click",J,!0)}#S(){if(!this.#X?.bound)return;this.removeEventListener("pointerdown",this.#X.onPointerDown),window.removeEventListener("pointermove",this.#X.onPointerMove),window.removeEventListener("pointerup",this.#X.onPointerUp),this.removeEventListener("pointerup",this.#X.onPointerUpCapture,!0),this.removeEventListener("click",this.#X.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#X=null}#f(){if(this.#W)return;let Q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!Q)return;this.#W=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#W=!1}}#I(){if(this.#N==="scrollbar")this.#A();else this.#E()}#A(){this.#_?.remove(),this.#Y?.remove(),this.#_=null,this.#Y=null,this.classList.remove("overflow-start","overflow-end")}#E(){if(this.#_&&this.#Y&&this.contains(this.#_)&&this.contains(this.#Y))return;this.#_?.remove(),this.#Y?.remove(),this.#_=null,this.#Y=null;let Q=X0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#C(-1),onEnd:()=>this.#C(1)});this.#_=Q.start,this.#Y=Q.end,this.prepend(this.#_),this.append(this.#Y)}#C(Q){let Z=this.getAttribute("layout")==="horizontal";i(this,Z?"x":"y",Q)}#k(){if(!this.#Q)return;this.#y(this.#Q,"auto")}#y(Q,Z="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let $=this.scrollHeight>this.clientHeight,J=this.scrollWidth>this.clientWidth;if(!J&&!$)return;let j=Q.getBoundingClientRect(),q=this.getBoundingClientRect(),_={behavior:Z},X=!1;if($){let Y=j.top-q.top+this.scrollTop,K=this.scrollHeight-this.clientHeight;_.top=Math.max(0,Math.min(Y+j.height/2-this.clientHeight/2,K)),X=!0}if(J){let Y=j.left-q.left+this.scrollLeft,K=this.scrollWidth-this.clientWidth;_.left=Math.max(0,Math.min(Y+j.width/2-this.clientWidth/2,K)),X=!0}if(X)this.scrollTo(_);this.#O()})}#v(){this.#j?.disconnect(),this.#j=new MutationObserver(()=>{if(this.#W)return;this.#f(),this.#I(),this.#z();let Q=this.choices;if(this.#Q&&!Q.includes(this.#Q))this.#Q=null,this.#F();else if(!this.#Q&&Q.length)this.#F();requestAnimationFrame(()=>this.#O())}),this.#j.observe(this,{childList:!0,subtree:!1})}}z("fig-chooser",E1);class C1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#Q=!1;#Z=!1;#$=null;#J=null;#j=!1;#q=null;#_=null;#Y=null;#X=null;get#W(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#N(){return!this.hasAttribute("data-no-color-picker")}get#K(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#G(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#U(){let Q=this.getAttribute("drag-snapping");if(Q===null)return"false";let Z=Q.trim().toLowerCase();if(Z==="modifier")return"modifier";if(Z===""||Z==="true")return"true";return"false"}#L(Q){let Z=this.#U;if(Z==="true")return!0;if(Z==="modifier")return!!Q;return!1}#F(Q){if(Q<0.1)return 0;if(Q>0.9)return 1;if(Q>0.4&&Q<0.6)return 0.5;return Q}#z(Q,Z){if(Math.abs(Q-Z)<0.1){let J=(Q+Z)/2;return{x:J,y:J}}if(Math.abs(1-Q-Z)<0.1)return{x:Q,y:1-Q};return{x:Q,y:Z}}#B(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#B();if(!Q)return"0% 0%";let{px:Z,py:$}=this.#n(Q.getBoundingClientRect());return`${Math.round(Z*100)}% ${Math.round($*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#M(Q){let Z=Q==null?"":String(Q).trim();if(!Z)return{xPct:0,yPct:0};let $=Z.split(/[\s,]+/).filter(Boolean),J=(_)=>{if(!_)return 0;let X=_.includes("px"),Y=_.includes("%"),K=parseFloat(_.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(X)return{px:K};if(Y||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},j=J($[0]),q=J($[1]??$[0]);return{xToken:j,yToken:q}}#D(Q){let Z=this.#B();if(!Z)return;let{xToken:$,yToken:J}=this.#M(Q),j=Z.getBoundingClientRect(),q=(Y,K)=>{if(Y&&typeof Y==="object"&&"px"in Y)return Math.max(0,Math.min(K,Y.px));return null},_=(Y)=>{return`${typeof Y==="number"?Y:0}%`},X=this.#G;if(this.#T(X),X.x){let Y=q($,j.width);this.style.left=Y===null?_($):`${Math.round(Y)}px`}if(X.y){let Y=q(J,j.height);this.style.top=Y===null?_(J):`${Math.round(Y)}px`}}#T(Q=this.#G){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#H(){this.#j=!0,this.setAttribute("value",this.value),this.#j=!1}get#O(){return this.getAttribute("hit-area-mode")||"handle"}#R(){let Q=this.getAttribute("hit-area");if(!Q)return null;let Z=Q.trim().split(/\s+/),$=0,J=0,j=!1,q=[];for(let _ of Z){if(_==="circle"){j=!0;continue}let X=parseFloat(_);if(Number.isFinite(X))q.push(X)}if(q.length>=2)$=q[0],J=q[1];else if(q.length===1)$=q[0],J=q[0];else return null;return{vPad:$,hPad:J,circle:j}}#P(){let Q=this.#R();if(!Q){if(this.#X)this.#X.remove(),this.#X=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#X){let Z=document.createElement("div");Z.classList.add("fig-handle-hit-area"),Z.addEventListener("pointerdown",($)=>this.#S($)),this.prepend(Z),this.#X=Z}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#X.style.borderRadius="50%";else this.#X.style.borderRadius="inherit"}#S(Q){if(F(this,"disabled"))return;if(Q.target!==this.#X)return;if(this.#O==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#v(Q)}connectedCallback(){this.#k(),this.#C(),this.#P(),this.addEventListener("click",this.#f),document.addEventListener("pointerdown",this.#I),document.addEventListener("keydown",this.#A);let Q=this.getAttribute("value");if(Q)this.#D(Q);if(this.#W)this.#s()}disconnectedCallback(){if(this.#y(),this.#t(),this.#c(),this.#d(),this.#X)this.#X.remove(),this.#X=null;this.removeEventListener("click",this.#f),document.removeEventListener("pointerdown",this.#I),document.removeEventListener("keydown",this.#A)}select(){if(F(this,"disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#f=(Q)=>{if(this.#Z){this.#Z=!1;return}if(this.getAttribute("type")==="color"&&this.#N&&!this.#W){this.#x();return}this.select()};#I=(Q)=>{if(this.contains(Q.target))return;if((this.#q||this.#_)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#A=(Q)=>{if(Q.defaultPrevented)return;if(Q.target===this&&this.#K&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Q.key)){if(this.#E(Q)){if(Q.preventDefault(),!F(this,"selected"))this.select()}return}if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target===this&&!F(this,"selected")){if(Q.preventDefault(),this.getAttribute("type")==="color"&&this.#N&&!this.#W)this.#x();else this.select();return}if(!F(this,"selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#N)return;if(Q.preventDefault(),!this.#W)this.#x()};#E(Q){if(F(this,"disabled"))return!1;let Z=this.#B();if(!Z)return!1;let $=Z.getBoundingClientRect();if($.width<=0||$.height<=0)return!1;let J=this.#G,j=this.#n($),q=Q.shiftKey?0.1:0.01,_=j.px,X=j.py;switch(Q.key){case"ArrowLeft":if(!J.x)return!1;_-=q;break;case"ArrowRight":if(!J.x)return!1;_+=q;break;case"ArrowUp":if(!J.y)return!1;X-=q;break;case"ArrowDown":if(!J.y)return!1;X+=q;break;case"Home":if(J.x)_=0;if(J.y)X=0;break;case"End":if(J.x)_=1;if(J.y)X=1;break;default:return!1}if(_=Math.max(0,Math.min(1,_)),X=Math.max(0,Math.min(1,X)),this.#T(J),J.x)this.style.left=`${Math.round(_*$.width)}px`;if(J.y)this.style.top=`${Math.round(X*$.height)}px`;this.#H();let Y={...this.#n($),shiftKey:Q.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Y})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Y})),!0}attributeChangedCallback(Q,Z,$){if(Q==="color"){if(!$||$==="false"||$==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",$);if(this.#q&&this.#W==="color"&&$)this.#q.setAttribute("value",$);this.#V()}if(Q==="drag")this.#C();if(Q==="hit-area")this.#P();if(Q==="selected")this.#r();if(Q==="selected"||Q==="disabled"||Q==="type"||Q==="tip"||Q==="aria-label"||Q==="aria-labelledby")this.#k();if(Q==="value"&&!this.#j&&!this.#Q)this.#D($);if(Q==="tip"){if(this.#t(),this.#W)this.#c(),this.#s()}}#C(){if(this.#K&&!this.#$)this.#$=(Q)=>this.#v(Q),this.addEventListener("pointerdown",this.#$);else if(!this.#K&&this.#$)this.#y()}#k(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex",Q?"-1":"0");else if(Q)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",Q?"true":"false"),this.setAttribute("aria-pressed",Z?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let $=this.#W||this.getAttribute("type")||"handle";this.setAttribute("aria-label",$==="color"?"Color handle":$==="add"?"Add handle":$==="remove"?"Remove handle":"Handle")}}#y(){if(this.#J?.(),this.#J=null,this.#$)this.removeEventListener("pointerdown",this.#$),this.#$=null;this.#Q=!1,this.#Z=!1}#v(Q){if(!this.#K||F(this,"disabled"))return;Q.preventDefault();let Z=this.#B();if(!Z)return;this.#J?.(),this.#Q=!0;let $=this.#G,J=null,j=this.getBoundingClientRect(),q=j.left+j.width/2,_=j.top+j.height/2,X=Q.clientX-q,Y=Q.clientY-_,K=Q.clientX,G=Q.clientY,N=3,W=(T,R,A=!1)=>{let M=Z.getBoundingClientRect();J=M;let E=this.#n(M),k=T-X-M.left,S=R-Y-M.top,x=Math.max(0,Math.min(M.width,k)),y=Math.max(0,Math.min(M.height,S)),m=M.width>0?$.x?x/M.width:E.px:0.5,d=M.height>0?$.y?y/M.height:E.py:0.5;if(this.#L(A)){if($.x)m=this.#F(m);if($.y)d=this.#F(d);if($.x&&$.y){let t=this.#z(m,d);m=t.x,d=t.y}}if(this.#T($),$.x)this.style.left=`${Math.round(Math.max(0,Math.min(M.width,m*M.width)))}px`;if($.y)this.style.top=`${Math.round(Math.max(0,Math.min(M.height,d*M.height)))}px`},O=(T)=>{if(!this.#Q)return;if(!this.#Z){let R=T.clientX-K,A=T.clientY-G;if(R*R+A*A<N*N)return;if(this.#p(),this.classList.add("dragging"),this.style.cursor="grabbing",!F(this,"selected"))this.select()}this.#Z=!0,W(T.clientX,T.clientY,T.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#n(J),shiftKey:T.shiftKey}}))},B=(T)=>{if(L(),this.#Z){W(T.clientX,T.clientY,T.shiftKey),this.#H(),this.#D(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#n(J)}));let R=(A)=>{A.stopPropagation(),A.preventDefault()};this.addEventListener("click",R,{capture:!0,once:!0})}else this.#H();this.#Z=!1},L=()=>{if(window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",B),this.#Q=!1,this.style.cursor="",this.classList.remove("dragging"),this.#J===L)this.#J=null};this.#J=L,window.addEventListener("pointermove",O),window.addEventListener("pointerup",B)}showColorTip(){if(!this.#W)return;if(this.#q){this.#q.style.display="";return}this.#s()}hideColorTip(){if(!this.#q)return;this.#q.style.display="none"}#b(Q=this.getAttribute("color")){let Z={color:"#D9D9D9",opacity:100},$=String(Q||"").trim();if(!$)return Z;let J=(q)=>{let _=q.replace("#","").trim();if(_.length===3||_.length===4){let[X,Y,K,G]=_;return{color:`#${X}${X}${Y}${Y}${K}${K}`.toUpperCase(),opacity:G?Math.round(parseInt(`${G}${G}`,16)/255*100):100}}if(_.length===6||_.length===8)return{color:`#${_.slice(0,6)}`.toUpperCase(),opacity:_.length===8?Math.round(parseInt(_.slice(6,8),16)/255*100):100};return Z},j=(q,_,X)=>{let Y=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${Y(q)}${Y(_)}${Y(X)}`.toUpperCase()};if($.startsWith("#"))return J($);try{let{ctx:q}=O0(1,1);q.fillStyle="#000000",q.fillStyle=$;let _=q.fillStyle;if(_.startsWith("#"))return J(_);let X=_.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(X)return{color:j(X[1],X[2],X[3]),opacity:X[4]!==void 0?Math.round(parseFloat(X[4])*100):100}}catch{}return Z}#w(){let{color:Q,opacity:Z}=this.#b();return JSON.stringify(Z<100?{type:"solid",color:Q,opacity:Z}:{type:"solid",color:Q})}#V(){if(!this.#_)return;this.#_.setAttribute("value",this.#w())}#g(){if(!o())return null;if(this.#_)return this.#_;let Q=document.createElement("fig-fill-picker");Q.setAttribute("mode","solid"),Q.setAttribute("alpha","true"),Q.setAttribute("dialog-offset","8 8"),Q.setAttribute("value",this.#w()),Q.anchorElement=this;let Z=document.createElement("span");return Z.hidden=!0,Q.appendChild(Z),Q.addEventListener("input",this.#i),Q.addEventListener("change",this.#Z0),Q.addEventListener("close",this.#l),this.appendChild(Q),this.#_=Q,Q}#x(){if(F(this,"disabled"))return;let Q=this.#g();if(!Q){this.#h();return}this.setAttribute("selected",""),this.#V(),Q.open()}#c(){if(!this.#_)return;this.#_.removeEventListener("input",this.#i),this.#_.removeEventListener("change",this.#Z0),this.#_.removeEventListener("close",this.#l),this.#_.close(),this.#_.remove(),this.#_=null,this.removeAttribute("selected")}#m(){if(this.#Y)return this.#Y;let Q=document.createElement("input");return Q.type="color",Q.tabIndex=-1,Q.setAttribute("aria-hidden","true"),Q.style.position="fixed",Q.style.inlineSize="1px",Q.style.blockSize="1px",Q.style.opacity="0",Q.style.pointerEvents="none",Q.addEventListener("input",this.#q0),Q.addEventListener("change",this.#e),this.appendChild(Q),this.#Y=Q,Q}#h(){let Q=this.#m(),{color:Z}=this.#b();Q.value=Z,this.setAttribute("selected",""),Q.click()}#d(){if(!this.#Y)return;this.#Y.removeEventListener("input",this.#q0),this.#Y.removeEventListener("change",this.#e),this.#Y.remove(),this.#Y=null}#p(){if(this.getAttribute("type")!=="color")return;this.#_?.close()}#s(){let Q=this.#W;if(!Q)return;if(this.#q)return;let Z=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")Z.setAttribute("control",Q);else Z.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Z.setAttribute("alpha","true");Z.addEventListener("input",this.#J0),Z.addEventListener("change",this.#$0),Z.addEventListener("add",this.#a),Z.addEventListener("remove",this.#a),this.appendChild(Z),this.#q=Z,this.#r()}#t(){if(!this.#q)return;this.#q.removeEventListener("input",this.#J0),this.#q.removeEventListener("change",this.#$0),this.#q.removeEventListener("add",this.#a),this.#q.removeEventListener("remove",this.#a),this.#q.remove(),this.#q=null}#r(){if(!this.#q||this.#W!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#q.toggleAttribute("selected",Q)}#u(Q,Z){if(Z===void 0||Z>=100)return Q;let{r:$,g:J,b:j}=r(Q);return`rgba(${$}, ${J}, ${j}, ${Z/100})`}#o(Q){if(!Q?.color)return null;let Z=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:Z}}#i=(Q)=>{Q.stopPropagation();let Z=this.#o(Q.detail);if(!Z)return;this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#Z0=(Q)=>{Q.stopPropagation();let Z=this.#o(Q.detail);if(!Z)return;this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#j0(Q){let{opacity:Z}=this.#b();return Z<100?{color:Q,opacity:Z}:{color:Q}}#q0=(Q)=>{Q.stopPropagation();let Z=this.#j0(Q.target.value);this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#e=(Q)=>{Q.stopPropagation();let Z=this.#j0(Q.target.value);this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#l=()=>{this.removeAttribute("selected")};#J0=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#u(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#$0=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#u(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#a=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#n(Q){let Z=Q||this.#B()?.getBoundingClientRect();if(!Z)return{x:0,y:0,px:0,py:0};let $=this.getBoundingClientRect(),J=this.offsetWidth/2,j=this.offsetHeight/2,q=$.left-Z.left,_=$.top-Z.top,X=q+J,Y=_+j,K=Z.width>0?X/Z.width:0,G=Z.height>0?Y/Z.height:0;return{x:q,y:_,px:K,py:G}}}z("fig-handle",C1);class k1 extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled")this.#Q()}#Q(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}z("fig-menu-item",k1);class S1 extends HTMLElement{static get observedAttributes(){return["label"]}get label(){return this.getAttribute("label")??""}set label(Q){if(Q==null||Q==="")this.removeAttribute("label");else this.setAttribute("label",String(Q))}connectedCallback(){this.#Q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#Q()}#Q(){if(!this.hasAttribute("role"))this.setAttribute("role","separator");let Q=this.label.trim();if(Q)this.setAttribute("aria-label",Q);else this.removeAttribute("aria-label")}}z("fig-menu-separator",S1);class f1 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#_=null;#Y=null;#X;#W;#N;#K;#G;#U=this.#P.bind(this);#L=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open","trigger"]}constructor(){super();this.#X=this.#y.bind(this),this.#W=this.#v.bind(this),this.#N=this.#w.bind(this),this.#K=this.#V.bind(this),this.#G=this.#g.bind(this)}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q){if(this.#k())return;this.setAttribute("open","")}else this.removeAttribute("open")}connectedCallback(){if(this.#F(),this.#B(),this.#M(),this.#D(),this.#O(),this.#H(),this.#C(),this.open)this.#c()}disconnectedCallback(){if(this.#T(),this.#R(),document.removeEventListener("keydown",this.#K,!0),this.#j)this.#j.disconnect(),this.#j=null;if(this.#Q){this.#Q.removeEventListener("close",this.#G);let Q=Array.from(this.#Z?.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator")??[]);for(let Z of Q)this.insertBefore(Z,this.#Q);this.#Q.remove(),this.#Q=null,this.#Z=null}}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){if($===null||$==="false")this.#m();else{if(this.#k()){this.removeAttribute("open");return}this.#c()}return}if(Q==="disabled"){this.#C();return}if(this.#Q&&(Q==="position"||Q==="offset"||Q==="closedby"))if($!==null)this.#Q.setAttribute(Q,$);else this.#Q.removeAttribute(Q)}#F(){this.#$=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#z(){return(this.getAttribute("trigger")||"").toLowerCase()==="contextmenu"||this.hasAttribute("contextmenu")}#B(){this.#Q=document.createElement("dialog",{is:"fig-popup"}),this.#Q.setAttribute("is","fig-popup"),this.#Q.classList.add("fig-menu-popup"),this.#Q.setAttribute("theme","menu"),this.#Q.setAttribute("role","menu"),this.#Q.setAttribute("id",this.#Q.getAttribute("id")||h());let Q=this.getAttribute("position")||"bottom left";this.#Q.setAttribute("position",Q);let Z=this.getAttribute("offset");if(Z)this.#Q.setAttribute("offset",Z);let $=this.getAttribute("closedby");if($)this.#Q.setAttribute("closedby",$);if(this.#$)this.#Q.anchor=this.#$;this.#Z=document.createElement("div"),this.#Z.className="fig-menu-options",this.#Z.setAttribute("role","presentation"),this.#Q.appendChild(this.#Z),this.#Q.addEventListener("close",this.#G),this.appendChild(this.#Q)}#M(){if(!this.#Z)return;let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let Z of Q)this.#Z.appendChild(Z)}#D(){if(this.addEventListener("keydown",this.#K),this.#$)this.#$.addEventListener("click",this.#X),this.#$.addEventListener("contextmenu",this.#W),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded","false"),this.#$.setAttribute("aria-controls",this.#Q.getAttribute("id"));if(this.#Q)this.#Q.addEventListener("click",this.#N),this.#Q.addEventListener("keydown",this.#K)}#T(){if(this.removeEventListener("keydown",this.#K),this.#$)this.#$.removeEventListener("click",this.#X),this.#$.removeEventListener("contextmenu",this.#W);if(this.#Q)this.#Q.removeEventListener("click",this.#N),this.#Q.removeEventListener("keydown",this.#K)}#H(){this.#j=new MutationObserver((Q)=>{for(let Z of Q)for(let $ of Z.addedNodes){if($.nodeType!==1||$===this.#Q)continue;if(($.tagName==="FIG-MENU-ITEM"||$.tagName==="FIG-MENU-SEPARATOR")&&$.parentElement===this)this.#Z?.appendChild($);else if(!this.#$&&$.parentElement===this){if(this.#F(),this.#$)this.#$.addEventListener("click",this.#X),this.#$.addEventListener("contextmenu",this.#W),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded","false"),this.#$.setAttribute("aria-controls",this.#Q.getAttribute("id")),this.#Q.anchor=this.#$,this.#C()}}this.#P()}),this.#j.observe(this,{childList:!0})}#O(){if(!this.#Z)return;this.#S(),this.#Z.addEventListener("scroll",this.#U,{passive:!0}),this.#q?.disconnect(),this.#q=new ResizeObserver(()=>this.#P()),this.#q.observe(this.#Z),requestAnimationFrame(()=>this.#P())}#R(){this.#Z?.removeEventListener("scroll",this.#U),this.#q?.disconnect(),this.#q=null,this.#f()}#P(){return a(this.#Z,this.#Z,"y")}#S(){if(this.#_&&this.#Y&&this.#Z?.contains(this.#_)&&this.#Z?.contains(this.#Y))return;this.#f();let Q=X0({owner:"menu",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>i(this.#Z,"y",-1),onEnd:()=>i(this.#Z,"y",1)});this.#_=Q.start,this.#Y=Q.end,this.#Z.prepend(this.#_),this.#Z.append(this.#Y)}#f(){this.#_?.remove(),this.#Y?.remove(),this.#_=null,this.#Y=null,this.#Z?.classList.remove("overflow-start","overflow-end")}#I(){if(!this.#Z)return[];return Array.from(this.#Z.querySelectorAll("fig-menu-item")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#A(){let Q=this.#I();if(!Q.length){this.#L=-1;return}let Z=document.activeElement,$=Q.findIndex((J)=>J===Z||J.contains(Z));this.#L=$>=0?$:-1}#E(Q){let Z=this.#I();if(!Z.length)return;let $=(Q+Z.length)%Z.length;this.#L=$;let J=Z[$];J.focus(),S0(this.#Z,J,"y")}#C(){let Q=this.#k();if(Q)if(this.open)this.removeAttribute("open");else this.#m();if(!this.#$)return;if(Q)this.#$.setAttribute("disabled",""),this.#$.setAttribute("aria-disabled","true"),this.#$.setAttribute("aria-expanded","false");else this.#$.removeAttribute("disabled"),this.#$.removeAttribute("aria-disabled")}#k(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#y(Q){if(this.#z())return;if(this.#k())return;Q.stopPropagation();let Z=this.#Q?.matches?.(":open")??!1;if(this.open&&!Z)this.removeAttribute("open");if(this.open&&Z)this.open=!1;else{if(this.#Q&&this.#$)this.#Q.anchor=this.#$;this.open=!0}}#v(Q){if(!this.#z())return;if(this.#k())return;Q.preventDefault(),Q.stopPropagation(),this.#b(Q.clientX,Q.clientY)}#b(Q,Z){let $=!1,J=0,j=()=>{window.clearTimeout(J),window.removeEventListener("pointerup",q,!0),window.removeEventListener("pointercancel",_,!0)},q=()=>{if($)return;$=!0,j(),requestAnimationFrame(()=>this.showAt(Q,Z))},_=()=>{if($)return;$=!0,j()};window.addEventListener("pointerup",q,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),J=window.setTimeout(q,180)}#w(Q){if(this.#k())return;let Z=Q.target.closest("fig-menu-item");if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#x(Z)}#V(Q){if(this.#k())return;if(Q.currentTarget===document&&Q.key!=="Escape")return;if(Q.currentTarget===this&&this.#Q?.contains(Q.target))return;if(!this.open||!this.#Q?.matches?.(":open")){if(this.#$?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" ")){if(Q.preventDefault(),this.#Q&&this.#$)this.#Q.anchor=this.#$;this.open=!0,requestAnimationFrame(()=>this.#E(0))}return}let Z=this.#I();if(!Z.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#A(),this.#E(this.#L+1);break}case"ArrowUp":{Q.preventDefault(),this.#A(),this.#E(this.#L-1);break}case"Home":{Q.preventDefault(),this.#E(0);break}case"End":{Q.preventDefault(),this.#E(Z.length-1);break}case"Escape":{Q.preventDefault(),this.open=!1,this.#$?.focus();break}case"Enter":case" ":{this.#A();let $=Z[this.#L];if(!$)return;Q.preventDefault(),this.#x($);break}}}#g(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#$)this.#$.setAttribute("aria-expanded","false"),this.#$.focus();this.#L=-1}#x(Q){let Z=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("change",{detail:{value:Z,item:Q},bubbles:!0})),this.open=!1}showAt(Q,Z){if(this.#k())return;if(this.#J={getBoundingClientRect:()=>({width:0,height:0,top:Z,right:Q,bottom:Z,left:Q,x:Q,y:Z})},this.#Q)this.#Q.anchor=this.#J;if(this.open)this.open=!1;requestAnimationFrame(()=>{if(this.#k())return;this.open=!0})}#c(){if(!this.#Q||this.#k()){if(this.hasAttribute("open"))this.removeAttribute("open");return}if(this.#Q.open=!0,document.addEventListener("keydown",this.#K,!0),this.#$)this.#$.setAttribute("aria-expanded","true");this.#L=-1,requestAnimationFrame(()=>{if(this.#P(),!this.#$?.matches?.(":focus-visible"))return;this.#E(0)})}#m(){if(!this.#Q)return;document.removeEventListener("keydown",this.#K,!0),this.#Q.open=!1,this.#$?.setAttribute("aria-expanded","false")}}z("fig-menu",f1);
364
+ </fig-fill-picker>`:`<fig-swatch background="${$}"${_}></fig-swatch>`,this.#Q=this.querySelector("fig-fill-picker"),this.#Z=this.querySelector("fig-swatch"),this.#_(),this.#Q?.addEventListener("input",this.#J),this.#Q?.addEventListener("change",this.#j),!this.#Q)this.#Z?.addEventListener("input",this.#J),this.#Z?.addEventListener("change",this.#j);this.#Y(),this.#F()}#N=()=>{let Q=this.#q;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#K(Q){if(!Q)return"#D9D9D9";let Z=Q.replace("#","").trim();if(Z.length===3||Z.length===4){let[$,J,j]=Z;return`#${$}${$}${J}${J}${j}${j}`.toUpperCase()}if(Z.length===6||Z.length===8)return`#${Z.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#G(Q){if(!Q)return 1;let Z=String(Q).trim(),$=Z.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test($)){let j=$[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test($))return parseInt($.slice(6,8),16)/255;let J=Z.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(J)return parseFloat(J[1]);return 1}#U(Q){if(!Q)return"#D9D9D9";let Z=String(Q).trim();if(Z.startsWith("{"))try{let $=JSON.parse(Z);if($?.color)return this.#U($.color)}catch{}if(Z.startsWith("#"))return this.#K(Z);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Z))return this.#K(Z);try{let{ctx:$}=O0(1,1);$.fillStyle="#000000",$.fillStyle=Z;let J=$.fillStyle;if(J.startsWith("#"))return this.#K(J);let j=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let q=(_)=>Math.max(0,Math.min(255,Number(_))).toString(16).padStart(2,"0");return`#${q(j[1])}${q(j[2])}${q(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#L(){let Q=this.getAttribute("value"),Z=this.#U(Q),$=this.#G(Q);if(Q!==Z&&$>=1){this.setAttribute("value",Z);return}if(this.#Q){this.#F();let J=$<1?{type:"solid",color:Z,opacity:Math.round($*100)}:{type:"solid",color:Z};if(this.#Q.setAttribute("value",JSON.stringify(J)),this.#X)this.#Q.removeAttribute("alpha");else this.#Q.setAttribute("alpha","false");if(F(this,"disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}if(this.#Z){if(this.#F(),this.#Z.setAttribute("background",Z),$<1)this.#Z.setAttribute("alpha",String($));else this.#Z.removeAttribute("alpha");if(F(this,"disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}}#F(){let Q=this.#q,Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",Z?"true":"false"),this.setAttribute("aria-pressed",$?"true":"false"),Q==="add"||Q==="remove"){let X=this.querySelector("fig-button"),Y=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");if(X?.setAttribute("aria-label",Y),Z)X?.setAttribute("disabled","");else X?.removeAttribute("disabled");return}let J=this.#Q||this.#Z;if(!J)return;let j=this.getAttribute("aria-label")||"Color stop",q=this.getAttribute("aria-labelledby"),_=this.getAttribute("aria-describedby");if(q)J.setAttribute("aria-labelledby",q),J.removeAttribute("aria-label");else J.setAttribute("aria-label",j),J.removeAttribute("aria-labelledby");if(_)J.setAttribute("aria-describedby",_);else J.removeAttribute("aria-describedby")}#z(Q,Z){let $=this.#U(Q?.color),J=this.#U(this.getAttribute("value"));if($!==J)this.setAttribute("value",$);else this.#L();let j={color:this.value};if(this.#X){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent(Z,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#B(Q){Q.stopPropagation(),this.#z(Q.detail||{color:Q.target?.value},"input")}#M(Q){Q.stopPropagation(),this.#z(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(!this.isConnected)return;switch(Q){case"control":this.#W();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#L(),this.#F();break}}get value(){return this.#U(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#U(Q))}get selected(){return F(this,"selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return F(this,"disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}z("fig-color-tip",T1);class P1 extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",F(this,"selected")?"true":"false"),F(this,"disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",F(this,"selected")?"true":"false");if(Q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}z("fig-choice",P1);class E1 extends HTMLElement{#Q=null;#Z=this.#D.bind(this);#$=this.#T.bind(this);#J=this.#O.bind(this);#j=null;#q=null;#_=null;#Y=null;#X=null;#W=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#N(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#K(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#G(){return this.getAttribute("choice-element")||"fig-choice"}#U(){let Q=this.getAttribute("columns"),Z=Q===null?NaN:Number(Q);if(Number.isInteger(Z)&&Z>0)this.style.setProperty("--fig-chooser-grid-columns",String(Z));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from(this.querySelectorAll(`:scope > ${this.#G}`))}get selectedChoice(){return this.#Q}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let Z=this.choices;for(let J of Z){let j=J===Q,q=F(J,"selected");if(j&&!q)J.setAttribute("selected","");else if(!j&&q)J.removeAttribute("selected")}this.#Q=Q;let $=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==$){if($)this.setAttribute("value",$)}this.#y(Q)}get value(){return this.#Q?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){if(this.setAttribute("role","listbox"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.#f(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#$),this.addEventListener("scroll",this.#J),this.#I(),this.#P(),this.#v(),this.#R(),this.#z(),c(this,()=>{this.#F(),this.#O(),this.#L()})}#L(){let Q=()=>{if(!this.isConnected)return;if(this.#Q)this.#y(this.#Q,"auto")},Z=()=>{let $=this.querySelectorAll("img, video");for(let J of $){if(J.tagName==="IMG"?J.complete:J.readyState>=1)continue;let j=()=>{J.removeEventListener("load",j),J.removeEventListener("loadedmetadata",j),J.removeEventListener("error",j),Q()};J.addEventListener("load",j),J.addEventListener("loadedmetadata",j),J.addEventListener("error",j)}};requestAnimationFrame(()=>{Z(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#$),this.removeEventListener("scroll",this.#J),this.#S(),this.#j?.disconnect(),this.#j=null,this.#q?.disconnect(),this.#q=null,this.#A()}attributeChangedCallback(Q,Z,$){if(Q==="value"&&$!==Z&&$)this.#B($);if(Q==="disabled")this.#z();if(Q==="choice-element")requestAnimationFrame(()=>this.#F());if(Q==="columns")this.#U(),this.#k();if(Q==="drag")if(this.#K)this.#P();else this.#S();if(Q==="overflow")this.#I(),requestAnimationFrame(()=>this.#O());if(Q==="layout"){if(this.#I(),$==="horizontal")this.scrollTop=0;else this.scrollLeft=0;this.#k()}}#F(){let Q=this.choices;if(!Q.length){this.#Q=null;return}let Z=this.getAttribute("value");if(Z&&this.#B(Z))return;let $=Q.find((J)=>F(J,"selected"));if($){this.selectedChoice=$;return}this.selectedChoice=Q[0]}#z(){let Q=F(this,"disabled");if(Q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Z of this.choices)if(Q||F(Z,"disabled"))Z.setAttribute("aria-disabled","true"),Z.setAttribute("tabindex","-1");else Z.removeAttribute("aria-disabled"),Z.setAttribute("tabindex","0")}#B(Q){let Z=this.choices;for(let $ of Z)if($.getAttribute("value")===Q)return this.selectedChoice=$,!0;return!1}#M(Q){let Z=this.#G,$=Q;while($&&$!==this){if($.matches(Z))return $;$=$.parentElement}return null}#D(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#M(Q.target);if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.selectedChoice=Z,this.#H()}#T(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!Z.length)return;let $=Z.indexOf(this.#Q),J=$,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),$<Z.length-1)J=$+1;else if(j)J=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),$>0)J=$-1;else if(j)J=Z.length-1;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#G)){let q=this.#M(document.activeElement);if(q&&q!==this.#Q)this.selectedChoice=q,this.#H()}return;default:return}if(J!==$&&Z[J])this.selectedChoice=Z[J],Z[J].focus(),this.#H()}#H(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#O(){if(this.#N==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal";a(this,this,Q?"x":"y")}#R(){this.#q?.disconnect(),this.#q=new ResizeObserver(()=>{this.#O(),this.#k()}),this.#q.observe(this)}#P(){if(this.#X?.bound)return;if(!this.#K)return;let Q=(q)=>{if(q.button!==0)return;if(q.target.closest("[data-fig-chooser-nav]"))return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#X.active=!0,this.#X.didDrag=!1,this.#X.startX=q.clientX,this.#X.startY=q.clientY,this.#X.scrollLeft=this.scrollLeft,this.#X.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Z=(q)=>{if(!this.#X.active)return;let _=this.getAttribute("layout")==="horizontal",X=q.clientX-this.#X.startX,Y=q.clientY-this.#X.startY;if(!this.#X.didDrag&&Math.abs(_?X:Y)>3)this.#X.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(q.pointerId);if(!this.#X.didDrag)return;if(_)this.scrollLeft=this.#X.scrollLeft-X;else this.scrollTop=this.#X.scrollTop-Y},$=(q)=>{if(!this.#X.active)return;let _=this.#X.didDrag;if(this.#X.active=!1,this.#X.didDrag=!1,this.style.cursor="",this.style.userSelect="",q.pointerId!==void 0)try{this.releasePointerCapture(q.pointerId)}catch{}if(_)q.preventDefault(),q.stopPropagation()},J=(q)=>{if(this.#X?.suppressClick)q.stopPropagation(),q.preventDefault(),this.#X.suppressClick=!1},j=(q)=>{if(this.#X?.didDrag)this.#X.suppressClick=!0,setTimeout(()=>{if(this.#X)this.#X.suppressClick=!1},0)};this.#X={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:Q,onPointerMove:Z,onPointerUp:$,onClick:J,onPointerUpCapture:j},this.addEventListener("pointerdown",Q),window.addEventListener("pointermove",Z),window.addEventListener("pointerup",$),this.addEventListener("pointerup",j,!0),this.addEventListener("click",J,!0)}#S(){if(!this.#X?.bound)return;this.removeEventListener("pointerdown",this.#X.onPointerDown),window.removeEventListener("pointermove",this.#X.onPointerMove),window.removeEventListener("pointerup",this.#X.onPointerUp),this.removeEventListener("pointerup",this.#X.onPointerUpCapture,!0),this.removeEventListener("click",this.#X.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#X=null}#f(){if(this.#W)return;let Q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!Q)return;this.#W=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#W=!1}}#I(){if(this.#N==="scrollbar")this.#A();else this.#E()}#A(){this.#_?.remove(),this.#Y?.remove(),this.#_=null,this.#Y=null,this.classList.remove("overflow-start","overflow-end")}#E(){if(this.#_&&this.#Y&&this.contains(this.#_)&&this.contains(this.#Y))return;this.#_?.remove(),this.#Y?.remove(),this.#_=null,this.#Y=null;let Q=X0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#C(-1),onEnd:()=>this.#C(1)});this.#_=Q.start,this.#Y=Q.end,this.prepend(this.#_),this.append(this.#Y)}#C(Q){let Z=this.getAttribute("layout")==="horizontal";i(this,Z?"x":"y",Q)}#k(){if(!this.#Q)return;this.#y(this.#Q,"auto")}#y(Q,Z="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let $=this.scrollHeight>this.clientHeight,J=this.scrollWidth>this.clientWidth;if(!J&&!$)return;let j=Q.getBoundingClientRect(),q=this.getBoundingClientRect(),_={behavior:Z},X=!1;if($){let Y=j.top-q.top+this.scrollTop,K=this.scrollHeight-this.clientHeight;_.top=Math.max(0,Math.min(Y+j.height/2-this.clientHeight/2,K)),X=!0}if(J){let Y=j.left-q.left+this.scrollLeft,K=this.scrollWidth-this.clientWidth;_.left=Math.max(0,Math.min(Y+j.width/2-this.clientWidth/2,K)),X=!0}if(X)this.scrollTo(_);this.#O()})}#v(){this.#j?.disconnect(),this.#j=new MutationObserver(()=>{if(this.#W)return;this.#f(),this.#I(),this.#z();let Q=this.choices;if(this.#Q&&!Q.includes(this.#Q))this.#Q=null,this.#F();else if(!this.#Q&&Q.length)this.#F();requestAnimationFrame(()=>this.#O())}),this.#j.observe(this,{childList:!0,subtree:!1})}}z("fig-chooser",E1);class C1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#Q=!1;#Z=!1;#$=null;#J=null;#j=!1;#q=null;#_=null;#Y=null;#X=null;get#W(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#N(){return!this.hasAttribute("data-no-color-picker")}get#K(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#G(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#U(){let Q=this.getAttribute("drag-snapping");if(Q===null)return"false";let Z=Q.trim().toLowerCase();if(Z==="modifier")return"modifier";if(Z===""||Z==="true")return"true";return"false"}#L(Q){let Z=this.#U;if(Z==="true")return!0;if(Z==="modifier")return!!Q;return!1}#F(Q){if(Q<0.1)return 0;if(Q>0.9)return 1;if(Q>0.4&&Q<0.6)return 0.5;return Q}#z(Q,Z){if(Math.abs(Q-Z)<0.1){let J=(Q+Z)/2;return{x:J,y:J}}if(Math.abs(1-Q-Z)<0.1)return{x:Q,y:1-Q};return{x:Q,y:Z}}#B(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#B();if(!Q)return"0% 0%";let{px:Z,py:$}=this.#n(Q.getBoundingClientRect());return`${Math.round(Z*100)}% ${Math.round($*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#M(Q){let Z=Q==null?"":String(Q).trim();if(!Z)return{xPct:0,yPct:0};let $=Z.split(/[\s,]+/).filter(Boolean),J=(_)=>{if(!_)return 0;let X=_.includes("px"),Y=_.includes("%"),K=parseFloat(_.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(X)return{px:K};if(Y||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},j=J($[0]),q=J($[1]??$[0]);return{xToken:j,yToken:q}}#D(Q){let Z=this.#B();if(!Z)return;let{xToken:$,yToken:J}=this.#M(Q),j=Z.getBoundingClientRect(),q=(Y,K)=>{if(Y&&typeof Y==="object"&&"px"in Y)return Math.max(0,Math.min(K,Y.px));return null},_=(Y)=>{return`${typeof Y==="number"?Y:0}%`},X=this.#G;if(this.#T(X),X.x){let Y=q($,j.width);this.style.left=Y===null?_($):`${Math.round(Y)}px`}if(X.y){let Y=q(J,j.height);this.style.top=Y===null?_(J):`${Math.round(Y)}px`}}#T(Q=this.#G){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#H(){this.#j=!0,this.setAttribute("value",this.value),this.#j=!1}get#O(){return this.getAttribute("hit-area-mode")||"handle"}#R(){let Q=this.getAttribute("hit-area");if(!Q)return null;let Z=Q.trim().split(/\s+/),$=0,J=0,j=!1,q=[];for(let _ of Z){if(_==="circle"){j=!0;continue}let X=parseFloat(_);if(Number.isFinite(X))q.push(X)}if(q.length>=2)$=q[0],J=q[1];else if(q.length===1)$=q[0],J=q[0];else return null;return{vPad:$,hPad:J,circle:j}}#P(){let Q=this.#R();if(!Q){if(this.#X)this.#X.remove(),this.#X=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#X){let Z=document.createElement("div");Z.classList.add("fig-handle-hit-area"),Z.addEventListener("pointerdown",($)=>this.#S($)),this.prepend(Z),this.#X=Z}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#X.style.borderRadius="50%";else this.#X.style.borderRadius="inherit"}#S(Q){if(F(this,"disabled"))return;if(Q.target!==this.#X)return;if(this.#O==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#v(Q)}connectedCallback(){this.#k(),this.#C(),this.#P(),this.addEventListener("click",this.#f),document.addEventListener("pointerdown",this.#I),document.addEventListener("keydown",this.#A);let Q=this.getAttribute("value");if(Q)this.#D(Q);if(this.#W)this.#s()}disconnectedCallback(){if(this.#y(),this.#t(),this.#c(),this.#d(),this.#X)this.#X.remove(),this.#X=null;this.removeEventListener("click",this.#f),document.removeEventListener("pointerdown",this.#I),document.removeEventListener("keydown",this.#A)}select(){if(F(this,"disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#f=(Q)=>{if(this.#Z){this.#Z=!1;return}if(this.getAttribute("type")==="color"&&this.#N&&!this.#W){this.#x();return}this.select()};#I=(Q)=>{if(this.contains(Q.target))return;if((this.#q||this.#_)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#A=(Q)=>{if(Q.defaultPrevented)return;if(Q.target===this&&this.#K&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Q.key)){if(this.#E(Q)){if(Q.preventDefault(),!F(this,"selected"))this.select()}return}if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target===this&&!F(this,"selected")){if(Q.preventDefault(),this.getAttribute("type")==="color"&&this.#N&&!this.#W)this.#x();else this.select();return}if(!F(this,"selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#N)return;if(Q.preventDefault(),!this.#W)this.#x()};#E(Q){if(F(this,"disabled"))return!1;let Z=this.#B();if(!Z)return!1;let $=Z.getBoundingClientRect();if($.width<=0||$.height<=0)return!1;let J=this.#G,j=this.#n($),q=Q.shiftKey?0.1:0.01,_=j.px,X=j.py;switch(Q.key){case"ArrowLeft":if(!J.x)return!1;_-=q;break;case"ArrowRight":if(!J.x)return!1;_+=q;break;case"ArrowUp":if(!J.y)return!1;X-=q;break;case"ArrowDown":if(!J.y)return!1;X+=q;break;case"Home":if(J.x)_=0;if(J.y)X=0;break;case"End":if(J.x)_=1;if(J.y)X=1;break;default:return!1}if(_=Math.max(0,Math.min(1,_)),X=Math.max(0,Math.min(1,X)),this.#T(J),J.x)this.style.left=`${Math.round(_*$.width)}px`;if(J.y)this.style.top=`${Math.round(X*$.height)}px`;this.#H();let Y={...this.#n($),shiftKey:Q.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Y})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Y})),!0}attributeChangedCallback(Q,Z,$){if(Q==="color"){if(!$||$==="false"||$==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",$);if(this.#q&&this.#W==="color"&&$)this.#q.setAttribute("value",$);this.#V()}if(Q==="drag")this.#C();if(Q==="hit-area")this.#P();if(Q==="selected")this.#r();if(Q==="selected"||Q==="disabled"||Q==="type"||Q==="tip"||Q==="aria-label"||Q==="aria-labelledby")this.#k();if(Q==="value"&&!this.#j&&!this.#Q)this.#D($);if(Q==="tip"){if(this.#t(),this.#W)this.#c(),this.#s()}}#C(){if(this.#K&&!this.#$)this.#$=(Q)=>this.#v(Q),this.addEventListener("pointerdown",this.#$);else if(!this.#K&&this.#$)this.#y()}#k(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex",Q?"-1":"0");else if(Q)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",Q?"true":"false"),this.setAttribute("aria-pressed",Z?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let $=this.#W||this.getAttribute("type")||"handle";this.setAttribute("aria-label",$==="color"?"Color handle":$==="add"?"Add handle":$==="remove"?"Remove handle":"Handle")}}#y(){if(this.#J?.(),this.#J=null,this.#$)this.removeEventListener("pointerdown",this.#$),this.#$=null;this.#Q=!1,this.#Z=!1}#v(Q){if(!this.#K||F(this,"disabled"))return;Q.preventDefault();let Z=this.#B();if(!Z)return;this.#J?.(),this.#Q=!0;let $=this.#G,J=null,j=this.getBoundingClientRect(),q=j.left+j.width/2,_=j.top+j.height/2,X=Q.clientX-q,Y=Q.clientY-_,K=Q.clientX,G=Q.clientY,N=3,W=(T,R,A=!1)=>{let M=Z.getBoundingClientRect();J=M;let E=this.#n(M),k=T-X-M.left,S=R-Y-M.top,x=Math.max(0,Math.min(M.width,k)),y=Math.max(0,Math.min(M.height,S)),m=M.width>0?$.x?x/M.width:E.px:0.5,d=M.height>0?$.y?y/M.height:E.py:0.5;if(this.#L(A)){if($.x)m=this.#F(m);if($.y)d=this.#F(d);if($.x&&$.y){let t=this.#z(m,d);m=t.x,d=t.y}}if(this.#T($),$.x)this.style.left=`${Math.round(Math.max(0,Math.min(M.width,m*M.width)))}px`;if($.y)this.style.top=`${Math.round(Math.max(0,Math.min(M.height,d*M.height)))}px`},O=(T)=>{if(!this.#Q)return;if(!this.#Z){let R=T.clientX-K,A=T.clientY-G;if(R*R+A*A<N*N)return;if(this.#p(),this.classList.add("dragging"),this.style.cursor="grabbing",!F(this,"selected"))this.select()}this.#Z=!0,W(T.clientX,T.clientY,T.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#n(J),shiftKey:T.shiftKey}}))},B=(T)=>{if(L(),this.#Z){W(T.clientX,T.clientY,T.shiftKey),this.#H(),this.#D(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#n(J)}));let R=(A)=>{A.stopPropagation(),A.preventDefault()};this.addEventListener("click",R,{capture:!0,once:!0})}else this.#H();this.#Z=!1},L=()=>{if(window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",B),this.#Q=!1,this.style.cursor="",this.classList.remove("dragging"),this.#J===L)this.#J=null};this.#J=L,window.addEventListener("pointermove",O),window.addEventListener("pointerup",B)}showColorTip(){if(!this.#W)return;if(this.#q){this.#q.style.display="";return}this.#s()}hideColorTip(){if(!this.#q)return;this.#q.style.display="none"}#b(Q=this.getAttribute("color")){let Z={color:"#D9D9D9",opacity:100},$=String(Q||"").trim();if(!$)return Z;let J=(q)=>{let _=q.replace("#","").trim();if(_.length===3||_.length===4){let[X,Y,K,G]=_;return{color:`#${X}${X}${Y}${Y}${K}${K}`.toUpperCase(),opacity:G?Math.round(parseInt(`${G}${G}`,16)/255*100):100}}if(_.length===6||_.length===8)return{color:`#${_.slice(0,6)}`.toUpperCase(),opacity:_.length===8?Math.round(parseInt(_.slice(6,8),16)/255*100):100};return Z},j=(q,_,X)=>{let Y=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${Y(q)}${Y(_)}${Y(X)}`.toUpperCase()};if($.startsWith("#"))return J($);try{let{ctx:q}=O0(1,1);q.fillStyle="#000000",q.fillStyle=$;let _=q.fillStyle;if(_.startsWith("#"))return J(_);let X=_.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(X)return{color:j(X[1],X[2],X[3]),opacity:X[4]!==void 0?Math.round(parseFloat(X[4])*100):100}}catch{}return Z}#w(){let{color:Q,opacity:Z}=this.#b();return JSON.stringify(Z<100?{type:"solid",color:Q,opacity:Z}:{type:"solid",color:Q})}#V(){if(!this.#_)return;this.#_.setAttribute("value",this.#w())}#g(){if(!o())return null;if(this.#_)return this.#_;let Q=document.createElement("fig-fill-picker");Q.setAttribute("mode","solid"),Q.setAttribute("alpha","true"),Q.setAttribute("dialog-offset","8 8"),Q.setAttribute("value",this.#w()),Q.anchorElement=this;let Z=document.createElement("span");return Z.hidden=!0,Q.appendChild(Z),Q.addEventListener("input",this.#i),Q.addEventListener("change",this.#Z0),Q.addEventListener("close",this.#l),this.appendChild(Q),this.#_=Q,Q}#x(){if(F(this,"disabled"))return;let Q=this.#g();if(!Q){this.#h();return}this.setAttribute("selected",""),this.#V(),Q.open()}#c(){if(!this.#_)return;this.#_.removeEventListener("input",this.#i),this.#_.removeEventListener("change",this.#Z0),this.#_.removeEventListener("close",this.#l),this.#_.close(),this.#_.remove(),this.#_=null,this.removeAttribute("selected")}#m(){if(this.#Y)return this.#Y;let Q=document.createElement("input");return Q.type="color",Q.tabIndex=-1,Q.setAttribute("aria-hidden","true"),Q.style.position="fixed",Q.style.inlineSize="1px",Q.style.blockSize="1px",Q.style.opacity="0",Q.style.pointerEvents="none",Q.addEventListener("input",this.#q0),Q.addEventListener("change",this.#e),this.appendChild(Q),this.#Y=Q,Q}#h(){let Q=this.#m(),{color:Z}=this.#b();Q.value=Z,this.setAttribute("selected",""),Q.click()}#d(){if(!this.#Y)return;this.#Y.removeEventListener("input",this.#q0),this.#Y.removeEventListener("change",this.#e),this.#Y.remove(),this.#Y=null}#p(){if(this.getAttribute("type")!=="color")return;this.#_?.close()}#s(){let Q=this.#W;if(!Q)return;if(this.#q)return;let Z=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")Z.setAttribute("control",Q);else Z.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Z.setAttribute("alpha","true");Z.addEventListener("input",this.#J0),Z.addEventListener("change",this.#$0),Z.addEventListener("add",this.#a),Z.addEventListener("remove",this.#a),this.appendChild(Z),this.#q=Z,this.#r()}#t(){if(!this.#q)return;this.#q.removeEventListener("input",this.#J0),this.#q.removeEventListener("change",this.#$0),this.#q.removeEventListener("add",this.#a),this.#q.removeEventListener("remove",this.#a),this.#q.remove(),this.#q=null}#r(){if(!this.#q||this.#W!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#q.toggleAttribute("selected",Q)}#u(Q,Z){if(Z===void 0||Z>=100)return Q;let{r:$,g:J,b:j}=r(Q);return`rgba(${$}, ${J}, ${j}, ${Z/100})`}#o(Q){if(!Q?.color)return null;let Z=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:Z}}#i=(Q)=>{Q.stopPropagation();let Z=this.#o(Q.detail);if(!Z)return;this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#Z0=(Q)=>{Q.stopPropagation();let Z=this.#o(Q.detail);if(!Z)return;this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#j0(Q){let{opacity:Z}=this.#b();return Z<100?{color:Q,opacity:Z}:{color:Q}}#q0=(Q)=>{Q.stopPropagation();let Z=this.#j0(Q.target.value);this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#e=(Q)=>{Q.stopPropagation();let Z=this.#j0(Q.target.value);this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#l=()=>{this.removeAttribute("selected")};#J0=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#u(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#$0=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#u(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#a=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#n(Q){let Z=Q||this.#B()?.getBoundingClientRect();if(!Z)return{x:0,y:0,px:0,py:0};let $=this.getBoundingClientRect(),J=this.offsetWidth/2,j=this.offsetHeight/2,q=$.left-Z.left,_=$.top-Z.top,X=q+J,Y=_+j,K=Z.width>0?X/Z.width:0,G=Z.height>0?Y/Z.height:0;return{x:q,y:_,px:K,py:G}}}z("fig-handle",C1);class k1 extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled")this.#Q()}#Q(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}z("fig-menu-item",k1);class S1 extends HTMLElement{static get observedAttributes(){return["label"]}get label(){return this.getAttribute("label")??""}set label(Q){if(Q==null||Q==="")this.removeAttribute("label");else this.setAttribute("label",String(Q))}connectedCallback(){this.#Q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#Q()}#Q(){if(!this.hasAttribute("role"))this.setAttribute("role","separator");let Q=this.label.trim();if(Q)this.setAttribute("aria-label",Q);else this.removeAttribute("aria-label")}}z("fig-separator",S1);class f1 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#_=null;#Y=null;#X;#W;#N;#K;#G;#U=this.#P.bind(this);#L=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open","trigger"]}constructor(){super();this.#X=this.#y.bind(this),this.#W=this.#v.bind(this),this.#N=this.#w.bind(this),this.#K=this.#V.bind(this),this.#G=this.#g.bind(this)}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q){if(this.#k())return;this.setAttribute("open","")}else this.removeAttribute("open")}connectedCallback(){if(this.#F(),this.#B(),this.#M(),this.#D(),this.#O(),this.#H(),this.#C(),this.open)this.#c()}disconnectedCallback(){if(this.#T(),this.#R(),document.removeEventListener("keydown",this.#K,!0),this.#j)this.#j.disconnect(),this.#j=null;if(this.#Q){this.#Q.removeEventListener("close",this.#G);let Q=Array.from(this.#Z?.querySelectorAll(":scope > fig-menu-item, :scope > fig-separator")??[]);for(let Z of Q)this.insertBefore(Z,this.#Q);this.#Q.remove(),this.#Q=null,this.#Z=null}}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){if($===null||$==="false")this.#m();else{if(this.#k()){this.removeAttribute("open");return}this.#c()}return}if(Q==="disabled"){this.#C();return}if(this.#Q&&(Q==="position"||Q==="offset"||Q==="closedby"))if($!==null)this.#Q.setAttribute(Q,$);else this.#Q.removeAttribute(Q)}#F(){this.#$=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-separator)")}#z(){return(this.getAttribute("trigger")||"").toLowerCase()==="contextmenu"||this.hasAttribute("contextmenu")}#B(){this.#Q=document.createElement("dialog",{is:"fig-popup"}),this.#Q.setAttribute("is","fig-popup"),this.#Q.classList.add("fig-menu-popup"),this.#Q.setAttribute("theme","menu"),this.#Q.setAttribute("role","menu"),this.#Q.setAttribute("id",this.#Q.getAttribute("id")||h());let Q=this.getAttribute("position")||"bottom left";this.#Q.setAttribute("position",Q);let Z=this.getAttribute("offset");if(Z)this.#Q.setAttribute("offset",Z);let $=this.getAttribute("closedby");if($)this.#Q.setAttribute("closedby",$);if(this.#$)this.#Q.anchor=this.#$;this.#Z=document.createElement("div"),this.#Z.className="fig-menu-options",this.#Z.setAttribute("role","presentation"),this.#Q.appendChild(this.#Z),this.#Q.addEventListener("close",this.#G),this.appendChild(this.#Q)}#M(){if(!this.#Z)return;let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-separator"));for(let Z of Q)this.#Z.appendChild(Z)}#D(){if(this.addEventListener("keydown",this.#K),this.#$)this.#$.addEventListener("click",this.#X),this.#$.addEventListener("contextmenu",this.#W),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded","false"),this.#$.setAttribute("aria-controls",this.#Q.getAttribute("id"));if(this.#Q)this.#Q.addEventListener("click",this.#N),this.#Q.addEventListener("keydown",this.#K)}#T(){if(this.removeEventListener("keydown",this.#K),this.#$)this.#$.removeEventListener("click",this.#X),this.#$.removeEventListener("contextmenu",this.#W);if(this.#Q)this.#Q.removeEventListener("click",this.#N),this.#Q.removeEventListener("keydown",this.#K)}#H(){this.#j=new MutationObserver((Q)=>{for(let Z of Q)for(let $ of Z.addedNodes){if($.nodeType!==1||$===this.#Q)continue;if(($.tagName==="FIG-MENU-ITEM"||$.tagName==="FIG-SEPARATOR")&&$.parentElement===this)this.#Z?.appendChild($);else if(!this.#$&&$.parentElement===this){if(this.#F(),this.#$)this.#$.addEventListener("click",this.#X),this.#$.addEventListener("contextmenu",this.#W),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded","false"),this.#$.setAttribute("aria-controls",this.#Q.getAttribute("id")),this.#Q.anchor=this.#$,this.#C()}}this.#P()}),this.#j.observe(this,{childList:!0})}#O(){if(!this.#Z)return;this.#S(),this.#Z.addEventListener("scroll",this.#U,{passive:!0}),this.#q?.disconnect(),this.#q=new ResizeObserver(()=>this.#P()),this.#q.observe(this.#Z),requestAnimationFrame(()=>this.#P())}#R(){this.#Z?.removeEventListener("scroll",this.#U),this.#q?.disconnect(),this.#q=null,this.#f()}#P(){return a(this.#Z,this.#Z,"y")}#S(){if(this.#_&&this.#Y&&this.#Z?.contains(this.#_)&&this.#Z?.contains(this.#Y))return;this.#f();let Q=X0({owner:"menu",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>i(this.#Z,"y",-1),onEnd:()=>i(this.#Z,"y",1)});this.#_=Q.start,this.#Y=Q.end,this.#Z.prepend(this.#_),this.#Z.append(this.#Y)}#f(){this.#_?.remove(),this.#Y?.remove(),this.#_=null,this.#Y=null,this.#Z?.classList.remove("overflow-start","overflow-end")}#I(){if(!this.#Z)return[];return Array.from(this.#Z.querySelectorAll("fig-menu-item")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#A(){let Q=this.#I();if(!Q.length){this.#L=-1;return}let Z=document.activeElement,$=Q.findIndex((J)=>J===Z||J.contains(Z));this.#L=$>=0?$:-1}#E(Q){let Z=this.#I();if(!Z.length)return;let $=(Q+Z.length)%Z.length;this.#L=$;let J=Z[$];J.focus(),S0(this.#Z,J,"y")}#C(){let Q=this.#k();if(Q)if(this.open)this.removeAttribute("open");else this.#m();if(!this.#$)return;if(Q)this.#$.setAttribute("disabled",""),this.#$.setAttribute("aria-disabled","true"),this.#$.setAttribute("aria-expanded","false");else this.#$.removeAttribute("disabled"),this.#$.removeAttribute("aria-disabled")}#k(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#y(Q){if(this.#z())return;if(this.#k())return;Q.stopPropagation();let Z=this.#Q?.matches?.(":open")??!1;if(this.open&&!Z)this.removeAttribute("open");if(this.open&&Z)this.open=!1;else{if(this.#Q&&this.#$)this.#Q.anchor=this.#$;this.open=!0}}#v(Q){if(!this.#z())return;if(this.#k())return;Q.preventDefault(),Q.stopPropagation(),this.#b(Q.clientX,Q.clientY)}#b(Q,Z){let $=!1,J=0,j=()=>{window.clearTimeout(J),window.removeEventListener("pointerup",q,!0),window.removeEventListener("pointercancel",_,!0)},q=()=>{if($)return;$=!0,j(),requestAnimationFrame(()=>this.showAt(Q,Z))},_=()=>{if($)return;$=!0,j()};window.addEventListener("pointerup",q,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),J=window.setTimeout(q,180)}#w(Q){if(this.#k())return;let Z=Q.target.closest("fig-menu-item");if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#x(Z)}#V(Q){if(this.#k())return;if(Q.currentTarget===document&&Q.key!=="Escape")return;if(Q.currentTarget===this&&this.#Q?.contains(Q.target))return;if(!this.open||!this.#Q?.matches?.(":open")){if(this.#$?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" ")){if(Q.preventDefault(),this.#Q&&this.#$)this.#Q.anchor=this.#$;this.open=!0,requestAnimationFrame(()=>this.#E(0))}return}let Z=this.#I();if(!Z.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#A(),this.#E(this.#L+1);break}case"ArrowUp":{Q.preventDefault(),this.#A(),this.#E(this.#L-1);break}case"Home":{Q.preventDefault(),this.#E(0);break}case"End":{Q.preventDefault(),this.#E(Z.length-1);break}case"Escape":{Q.preventDefault(),this.open=!1,this.#$?.focus();break}case"Enter":case" ":{this.#A();let $=Z[this.#L];if(!$)return;Q.preventDefault(),this.#x($);break}}}#g(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#$)this.#$.setAttribute("aria-expanded","false"),this.#$.focus();this.#L=-1}#x(Q){let Z=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("change",{detail:{value:Z,item:Q},bubbles:!0})),this.open=!1}showAt(Q,Z){if(this.#k())return;if(this.#J={getBoundingClientRect:()=>({width:0,height:0,top:Z,right:Q,bottom:Z,left:Q,x:Q,y:Z})},this.#Q)this.#Q.anchor=this.#J;if(this.open)this.open=!1;requestAnimationFrame(()=>{if(this.#k())return;this.open=!0})}#c(){if(!this.#Q||this.#k()){if(this.hasAttribute("open"))this.removeAttribute("open");return}if(this.#Q.open=!0,document.addEventListener("keydown",this.#K,!0),this.#$)this.#$.setAttribute("aria-expanded","true");this.#L=-1,requestAnimationFrame(()=>{if(this.#P(),!this.#$?.matches?.(":focus-visible"))return;this.#E(0)})}#m(){if(!this.#Q)return;document.removeEventListener("keydown",this.#K,!0),this.#Q.open=!1,this.#$?.setAttribute("aria-expanded","false")}}z("fig-menu",f1);
package/fig-editor.js CHANGED
@@ -1521,7 +1521,7 @@ class FigFillPicker extends HTMLElement {
1521
1521
  })
1522
1522
  .join("");
1523
1523
  const separator = group.label || group.separator
1524
- ? `<fig-menu-separator${group.label ? ` label="${figEditorEscapeAttribute(group.label)}"` : ""}></fig-menu-separator>`
1524
+ ? `<fig-separator${group.label ? ` label="${figEditorEscapeAttribute(group.label)}"` : ""}></fig-separator>`
1525
1525
  : "";
1526
1526
  return `${separator}${options}`;
1527
1527
  })
package/fig-lab.css CHANGED
@@ -8,6 +8,95 @@
8
8
  * <link rel="stylesheet" href="fig-lab.css">
9
9
  */
10
10
 
11
+ fig-ai-prompt {
12
+ --fig-ai-prompt-margin-inline: var(--spacer-2);
13
+
14
+ display: flex;
15
+ flex-direction: column;
16
+ box-sizing: border-box;
17
+ width: calc(
18
+ 100% - var(--fig-ai-prompt-margin-inline) -
19
+ var(--fig-ai-prompt-margin-inline)
20
+ );
21
+ min-height: 8rem;
22
+ margin-inline: var(--fig-ai-prompt-margin-inline);
23
+ border: 1px solid var(--figma-color-border);
24
+ border-radius: var(--radius-large);
25
+ background: var(--figma-color-bg);
26
+ color: var(--figma-color-text);
27
+
28
+ &:focus-within {
29
+ outline: var(--figma-focus-outline);
30
+ outline-offset: var(--figma-focus-outline-offset);
31
+ }
32
+
33
+ & > fig-input-text {
34
+ flex: 1 1 auto;
35
+ width: 100%;
36
+ min-width: 0;
37
+ border-radius: 0;
38
+ background: transparent;
39
+ box-shadow: none;
40
+ font-size: var(--body-large-fontSize);
41
+
42
+ &:hover,
43
+ &:has(textarea:focus) {
44
+ outline: 0;
45
+ box-shadow: none;
46
+ }
47
+
48
+ & > textarea {
49
+ box-sizing: border-box;
50
+ width: 100%;
51
+ height: 100%;
52
+ min-height: var(--spacer-6);
53
+ padding: var(--spacer-3);
54
+ resize: none;
55
+ font-size: inherit;
56
+ }
57
+ }
58
+
59
+ & > fig-footer {
60
+ border: none;
61
+ box-shadow: none;
62
+ }
63
+ }
64
+
65
+ fig-chat-message {
66
+ display: block;
67
+ box-sizing: border-box;
68
+ width: 100%;
69
+ max-width: 100%;
70
+ color: var(--figma-color-text);
71
+ font-size: var(--body-large-fontSize);
72
+ line-height: calc(var(--line-height) + var(--spacer-1));
73
+ overflow-wrap: anywhere;
74
+ white-space: pre-wrap;
75
+
76
+ &[from="user"] {
77
+ width: auto;
78
+ margin-inline-start: var(--spacer-4);
79
+ padding: var(--spacer-2) var(--spacer-2-5);
80
+ border-radius: var(--radius-large);
81
+ background: var(--figma-color-bg-secondary);
82
+ }
83
+
84
+ &[from="user"]:has(> fig-avatar) {
85
+ position: relative;
86
+ margin-inline-end: calc(var(--spacer-4) + var(--spacer-2));
87
+
88
+ & > fig-avatar {
89
+ position: absolute;
90
+ right: calc(-1 * (var(--spacer-4) + var(--spacer-2)));
91
+ bottom: 0;
92
+ }
93
+ }
94
+
95
+ & + fig-chat-message {
96
+ margin-top: var(--spacer-3);
97
+ }
98
+ }
99
+
11
100
  propskit-group {
12
101
  display: block;
13
102
  width: 100%;