@rogieking/figui3 11.6.6 → 11.6.7

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
@@ -135,7 +135,7 @@ fig-icon {
135
135
  fig-icon[size="small"] {
136
136
  --size: var(--spacer-3);
137
137
  }
138
- `,o0=typeof CSSStyleSheet==="function"&&typeof CSSStyleSheet.prototype.replaceSync==="function"?new CSSStyleSheet:null;o0?.replaceSync(s0);var r0=typeof CSSStyleSheet==="function"&&typeof CSSStyleSheet.prototype.replaceSync==="function"?new CSSStyleSheet:null;r0?.replaceSync(i0);function m0(_,Z,$,J){if(!_||!$)return;if(Z&&"adoptedStyleSheets"in _){if([..._.adoptedStyleSheets].includes(Z))return;_.adoptedStyleSheets=[..._.adoptedStyleSheets,Z];return}let Q=_===document?document.documentElement:_;if(Q.querySelector?.(`style[data-fig-${J}]`))return;let j=document.createElement("style");j.setAttribute(`data-fig-${J}`,""),j.textContent=$,Q.prepend(j)}function l0(_,Z={}){if(m0(_,o0,s0,"vertical-overflow"),Z.icons)m0(_,r0,i0,"shadow-icon")}if(typeof document<"u")l0(document);function L0(_,Z,$="x",J=2){if(!_||!Z)return!1;let Q=$==="x",j=Q?Z.scrollWidth:Z.scrollHeight,q=Q?Z.clientWidth:Z.clientHeight,N=Q?Z.scrollLeft:Z.scrollTop,G=j-q>J,K=!G||N<=J,X=!G||N+q>=j-J;return _.classList.toggle("overflow-start",!K),_.classList.toggle("overflow-end",!X),G}function Z0(_,Z="x",$=1,J="smooth"){if(!_)return;let Q=Z==="x",q=(Q?_.clientWidth:_.clientHeight)*0.8*$;_.scrollBy({[Q?"left":"top"]:q,behavior:J})}function q0(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function X1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let _=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class Z extends HTMLButtonElement{}try{return customElements.define(_,Z,{extends:"button"}),document.createElement("button",{is:_})instanceof Z}catch($){return!1}}var a0=G1()&&!X1(),Y1=(a0?Promise.resolve().then(() => (w0(),j1)):Promise.resolve()).then(()=>{}).catch((_)=>{throw _});function k0(_,Z,$){let J=()=>{if(!customElements.get(_))customElements.define(_,Z,$)};if(!a0){J();return}Y1.then(J).catch((Q)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${_}".`,Q)})}function F(_,Z){if(!customElements.get(_))customElements.define(_,Z)}function g(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function l(){if(!document.body)return null;let _="data-figui-overlay-root",Z=document.body.querySelector(`:scope > [${_}]`);if(!Z)Z=document.createElement("div"),Z.setAttribute(_,""),document.body.append(Z);return Z}var R1=1e4;function t0(){return R1++}function p(_,Z,$){if($&&$.trim())_.style.setProperty(Z,$.trim());else _.style.removeProperty(Z)}var i=null,p0=null;function D0(_=1,Z=1){if(!i)i=document.createElement("canvas"),p0=i.getContext("2d");if(i.width!==_)i.width=_;if(i.height!==Z)i.height=Z;return{canvas:i,ctx:p0}}class n0 extends HTMLElement{type;#Z;#_=new WeakMap;#J=["aria-label","aria-labelledby","aria-describedby","aria-haspopup","aria-expanded","aria-controls","title"];#$=this.#R.bind(this);#Q=this.#X.bind(this);#j=()=>{this.#O(),this.#W()};#G=()=>{if(this.button?.matches(":focus-visible"))this.setAttribute("data-focus-visible","")};#N=()=>{this.removeAttribute("data-focus-visible")};constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){if(this.type=this.getAttribute("type")||"button",!this.button){let _=this.type==="select"||this.type==="upload",Z=_?"span":"button",$=document.createElement("style");$.textContent=`
138
+ `,o0=typeof CSSStyleSheet==="function"&&typeof CSSStyleSheet.prototype.replaceSync==="function"?new CSSStyleSheet:null;o0?.replaceSync(s0);var r0=typeof CSSStyleSheet==="function"&&typeof CSSStyleSheet.prototype.replaceSync==="function"?new CSSStyleSheet:null;r0?.replaceSync(i0);function m0(_,Z,$,J){if(!_||!$)return;if(Z&&"adoptedStyleSheets"in _){if([..._.adoptedStyleSheets].includes(Z))return;_.adoptedStyleSheets=[..._.adoptedStyleSheets,Z];return}let Q=_===document?document.documentElement:_;if(Q.querySelector?.(`style[data-fig-${J}]`))return;let j=document.createElement("style");j.setAttribute(`data-fig-${J}`,""),j.textContent=$,Q.prepend(j)}function l0(_,Z={}){if(m0(_,o0,s0,"vertical-overflow"),Z.icons)m0(_,r0,i0,"shadow-icon")}if(typeof document<"u")l0(document);function L0(_,Z,$="x",J=2){if(!_||!Z)return!1;let Q=$==="x",j=Q?Z.scrollWidth:Z.scrollHeight,q=Q?Z.clientWidth:Z.clientHeight,N=Q?Z.scrollLeft:Z.scrollTop,G=j-q>J,K=!G||N<=J,X=!G||N+q>=j-J;return _.classList.toggle("overflow-start",!K),_.classList.toggle("overflow-end",!X),G}function Z0(_,Z="x",$=1,J="smooth"){if(!_)return;let Q=Z==="x",q=(Q?_.clientWidth:_.clientHeight)*0.8*$;_.scrollBy({[Q?"left":"top"]:q,behavior:J})}function q0(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function X1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let _=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class Z extends HTMLButtonElement{}try{return customElements.define(_,Z,{extends:"button"}),document.createElement("button",{is:_})instanceof Z}catch($){return!1}}var a0=G1()&&!X1(),Y1=(a0?Promise.resolve().then(() => (w0(),j1)):Promise.resolve()).then(()=>{}).catch((_)=>{throw _});function k0(_,Z,$){let J=()=>{if(!customElements.get(_))customElements.define(_,Z,$)};if(!a0){J();return}Y1.then(J).catch((Q)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${_}".`,Q)})}function F(_,Z){if(!customElements.get(_))customElements.define(_,Z)}function g(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function l(){if(!document.body)return null;let _="data-figui-overlay-root",Z=document.body.querySelector(`:scope > [${_}]`);if(!Z)Z=document.createElement("div"),Z.setAttribute(_,""),document.body.append(Z);return Z}var R1=1e4;function t0(){return R1++}function p(_,Z,$){if($&&$.trim())_.style.setProperty(Z,$.trim());else _.style.removeProperty(Z)}var i=null,p0=null;function D0(_=1,Z=1){if(!i)i=document.createElement("canvas"),p0=i.getContext("2d");if(i.width!==_)i.width=_;if(i.height!==Z)i.height=Z;return{canvas:i,ctx:p0}}class n0 extends HTMLElement{type;#Z;#_=new WeakMap;#J=["aria-label","aria-labelledby","aria-describedby","aria-haspopup","aria-expanded","aria-controls","title"];#$=this.#R.bind(this);#Q=this.#X.bind(this);#j=()=>{this.#B(),this.#W()};#G=()=>{if(this.button?.matches(":focus-visible"))this.setAttribute("data-focus-visible","")};#q=()=>{this.removeAttribute("data-focus-visible")};constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){if(this.type=this.getAttribute("type")||"button",!this.button){let _=this.type==="select"||this.type==="upload",Z=_?"span":"button",$=document.createElement("style");$.textContent=`
139
139
  button, button:hover, button:active, .fig-button-control {
140
140
  padding: var(--fig-button-control-padding, 0 var(--spacer-2));
141
141
  appearance: none;
@@ -169,9 +169,9 @@ fig-icon[size="small"] {
169
169
  :host([type="select"]) .fig-button-control {
170
170
  gap: var(--spacer-1);
171
171
  }
172
- `;let J=document.createElement("slot");J.name="prepend";let Q=document.createElement("slot"),j=document.createElement("slot");j.name="append";let q=M(Z,{className:"fig-button-control",type:_?null:"button"},[J,Q,j]);this.shadowRoot.replaceChildren($,q),this.button=q,this.button.addEventListener("click",this.#Q),this.button.addEventListener("focus",this.#G),this.button.addEventListener("blur",this.#N)}this.shadowRoot.querySelectorAll("slot").forEach((_)=>{_.removeEventListener("slotchange",this.#j),_.addEventListener("slotchange",this.#j)}),this.removeEventListener("keydown",this.#$),this.addEventListener("keydown",this.#$),this.#Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#M(),this.#W()}get type(){return this.getAttribute("type")||"button"}set type(_){this.setAttribute("type",_)}get selected(){return this.#Z}set selected(_){this.setAttribute("selected",_)}#q(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#X(){if(this.#q())return;if(this.type==="toggle")if(this.selected)this.removeAttribute("selected");else this.setAttribute("selected","");if(this.type==="submit"){let _=this.closest("form");if(_)if(typeof _.requestSubmit==="function")_.requestSubmit();else _.submit()}if(this.type==="link"){let _=this.getAttribute("href"),Z=this.getAttribute("target");if(_)if(Z)window.open(_,Z);else window.location.href=_}}#K(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#Y(){let _=this.#K();if(_ instanceof HTMLSelectElement)return _;if(_?.tagName==="FIG-DROPDOWN")return _.select||_.querySelector?.("select")||null;return null}#R(_){if(this.type!=="select")return;if(_.key!=="Enter")return;if(_.altKey||_.ctrlKey||_.metaKey||_.shiftKey)return;let Z=this.#Y();if(!Z||Z.disabled||Z.multiple)return;if(typeof Z.showPicker!=="function")return;_.preventDefault();try{Z.showPicker()}catch{}}#U(){if(!this.button)return;if(this.type!=="toggle"){this.removeAttribute("aria-pressed"),this.button.removeAttribute("aria-pressed");return}let _=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.setAttribute("aria-pressed",_?"true":"false"),this.button.setAttribute("aria-pressed",_?"true":"false")}#W(){let Z=Array.from(this.querySelectorAll(':scope > fig-icon[slot="append"][data-generated="select-chevron"]')),$=Z[0];if(Z.slice(1).forEach((j)=>j.remove()),this.type!=="select"){$?.remove();return}if(this.querySelector(':scope > [slot="append"]:not([data-generated])')){$?.remove();return}if($)return;let Q=b("chevron",{size:"small"});Q.setAttribute("slot","append"),Q.setAttribute("data-generated","select-chevron"),this.append(Q)}#B(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#J.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.button.removeAttribute(_);else this.button.setAttribute(_,Z)})}#M(){if(!this.button)return;let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=_,this.button instanceof HTMLButtonElement)this.button.disabled=_,this.button.type="button",this.button.setAttribute("type","button");this.#O(),this.#B(),this.#U()}#O(){let _=this.#K();if(!_)return;if(this.#q()){if(!this.#_.has(_))this.#_.set(_,_.hasAttribute("disabled")&&_.getAttribute("disabled")!=="false");_.setAttribute("disabled","")}else if(this.#_.has(_)){let $=this.#_.get(_);if(this.#_.delete(_),$)_.setAttribute("disabled","");else _.removeAttribute("disabled")}}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","aria-haspopup","aria-expanded","aria-controls","title"]}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"type":{let J=(Q)=>Q==="select"||Q==="upload";if(J(Z||"button")!==J($||"button")){this.button=null,this.connectedCallback();break}this.#M(),this.#W();break}case"disabled":this.#M();break;case"selected":this.#Z=$!==null&&$!=="false",this.#U();break;default:this.#B();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#$),this.shadowRoot?.querySelectorAll("slot").forEach((_)=>{_.removeEventListener("slotchange",this.#j)})}}F("fig-button",n0);class e0 extends HTMLElement{#Z="Menu";#_=null;#J;#$;#Q;get label(){return this.#Z}set label(_){this.#Z=_}#j;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#J=this.#X.bind(this),this.#$=this.#K.bind(this),this.#Q=this.#Y.bind(this),this.#j=this.slotChange.bind(this)}#G(){this.select.addEventListener("input",this.#J),this.select.addEventListener("change",this.#$),this.select.addEventListener("keydown",this.#Q)}#N(_){if(!_||!(_ instanceof Element))return!1;return!!_.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#q(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){if(this.type=this.getAttribute("type")||"select",this.#Z=this.getAttribute("label")||this.#Z,this.select.setAttribute("aria-label",this.#Z),this.#R(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#j),this.optionsSlot.addEventListener("slotchange",this.#j),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#Q),this.#G()}slotChange(){let _=this.hasAttribute("value"),Z=this.select.options.length>0&&this.select.selectedIndex>=0,$=_?this.getAttribute("value"):this.type==="dropdown"?this.#_:Z?this.select.value:null;while(this.select.firstChild)this.select.firstChild.remove();if(this.type==="dropdown"){let J=document.createElement("option");J.setAttribute("hidden","true"),J.setAttribute("selected","true"),J.selected=!0,this.select.appendChild(J)}if(this.optionsSlot.assignedNodes().forEach((J)=>{if(J.nodeName==="OPTION"||J.nodeName==="OPTGROUP")this.select.appendChild(J.cloneNode(!0))}),$!==null)this.#U($);if(this.type==="dropdown")this.select.selectedIndex=-1}#X(_){_.stopPropagation();let Z=_.target.selectedOptions?.[0];if(this.#N(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#q();return}let $=_.target.value;if(this.type==="dropdown")this.#_=$;this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}#K(_){_.stopPropagation();let Z=_.target.selectedOptions?.[0];if(this.#N(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#q();return}let $=this.type==="dropdown"?this.#_:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,composed:!0}))}#Y(_){if(this.closest('fig-button[type="select"]'))return;if(_.key!=="Enter"||_.defaultPrevented)return;if(_.altKey||_.ctrlKey||_.metaKey||_.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(typeof this.select.showPicker!=="function")return;_.preventDefault();try{this.select.showPicker()}catch{}}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#_;return this.select?.value}set value(_){if(this.type==="dropdown")this.#_=_;this.setAttribute("value",_)}static get observedAttributes(){return["value","type","label","disabled","variant","size"]}#R(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=_}#U(_){if(this.type==="dropdown")return;if(this.select)this.select.value=_??""}attributeChangedCallback(_,Z,$){if(_==="value")this.#U($);if(_==="type"){if(this.type=$||"select",this.isConnected)this.slotChange()}if(_==="label")this.#Z=$||"Menu",this.select.setAttribute("aria-label",this.#Z);if(_==="disabled")this.#R()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#j),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#Q)}}F("fig-dropdown",e0);class k extends HTMLElement{static#Z=0;static#_=0;static#J=1000;static#$=null;static#Q=!1;static#j=new Set;#G;#N;#q;#X;#K;#Y;#R;#U;#W;#B;#M;#O;#L=null;#A=null;#I=null;#D=!1;#H;#z=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let _=parseInt(this.getAttribute("delay"));this.delay=!isNaN(_)?_:500,this.#G=this.#y.bind(this),this.#N=this.hidePopupOutsideClick.bind(this),this.#q=this.showDelayedPopup.bind(this),this.#X=this.#h.bind(this),this.#K=()=>{if(!this.#D)this.showDelayedPopup()},this.#Y=()=>{this.#D=!1,this.hidePopup()},this.#R=this.#E.bind(this),this.#U=this.#f.bind(this),this.#W=this.#x.bind(this),this.#B=this.#g.bind(this),this.#O=this.#w.bind(this),this.#M=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(k.#b(),this.setup(),this.#S(),this.setupEventListeners(),this.#L=this.closest("dialog"),this.#L)this.#L.addEventListener("close",this.#M)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#P(),this.#T(),document.removeEventListener("mousedown",this.#G,!0),document.removeEventListener("keydown",this.#O,!0),this.#L)this.#L.removeEventListener("close",this.#M),this.#L=null;if(this.action==="click")document.body.removeEventListener("click",this.#N);if(clearTimeout(this.#H),k.#$===this)k.#$=null}#F(){return this.firstElementChild}#T(){this.#I?.disconnect(),this.#I=null}#S(){if(this.#P(),this.action==="manual")return;let _=this.#F();if(!_){if(!this.#I&&typeof MutationObserver<"u")this.#I=new MutationObserver(()=>{if(this.#F())this.#T(),this.#S()}),this.#I.observe(this,{childList:!0});return}if(this.#A=_,this.action==="hover"){if(!this.isTouchDevice())_.addEventListener("pointerenter",this.#q),_.addEventListener("pointerleave",this.#X);_.addEventListener("touchstart",this.#R,{passive:!0}),_.addEventListener("touchmove",this.#U,{passive:!0}),_.addEventListener("touchend",this.#W,{passive:!0}),_.addEventListener("touchcancel",this.#B,{passive:!0}),_.addEventListener("focus",this.#K),_.addEventListener("blur",this.#Y)}else if(this.action==="click")_.addEventListener("click",this.#q),_.addEventListener("touchstart",this.#q,{passive:!0})}#P(){let _=this.#A;if(!_)return;if(this.action==="hover")_.removeEventListener("pointerenter",this.#q),_.removeEventListener("pointerleave",this.#X),_.removeEventListener("touchstart",this.#R),_.removeEventListener("touchmove",this.#U),_.removeEventListener("touchend",this.#W),_.removeEventListener("touchcancel",this.#B),_.removeEventListener("focus",this.#K),_.removeEventListener("blur",this.#Y);else if(this.action==="click")_.removeEventListener("click",this.#q),_.removeEventListener("touchstart",this.#q);this.#A=null}setup(){this.style.display="contents"}render(){this.destroy();let _=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Z=document.createElement("span");if(this.popup=document.createElement("dialog",{is:"fig-popup"}),this.popup.setAttribute("is","fig-popup"),this.popup.setAttribute("variant","tooltip"),this.popup.setAttribute("data-tooltip-managed",""),this.popup.setAttribute("role","tooltip"),this.popup.setAttribute("closedby","closerequest"),_)this.popup.setAttribute("popover","manual");let $=g();this.popup.setAttribute("id",$);let J=this.getAttribute("theme");if(J)this.popup.setAttribute("theme",J);let Q=this.getAttribute("pointer");if(Q!==null)this.popup.setAttribute("pointer",Q);if(this.popup.append(Z),Z.innerText=this.getAttribute("text")??"",this.firstElementChild){let j=new Set((this.firstElementChild.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));j.add($),this.firstElementChild.setAttribute("aria-describedby",[...j].join(" "))}if(_)(l()??document.body).append(this.popup);else{let j=this.closest("dialog");if(j&&j.open)j.append(this.popup);else(l()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.#V(this.popup.id),this.popup.hidePopup?.(),this.popup.remove(),this.popup=null}#V(_){let Z=this.firstElementChild;if(!Z||!_)return;let $=Z.getAttribute("aria-describedby");if(!$)return;let J=$.split(/\s+/).filter((Q)=>Q&&Q!==_).join(" ");if(J)Z.setAttribute("aria-describedby",J);else Z.removeAttribute("aria-describedby")}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#N);document.addEventListener("mousedown",this.#G,!0),document.addEventListener("keydown",this.#O,!0)}get#k(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#C(){let _=Date.now(),Z=k.#J;if(this.action==="hover"&&k.#$)return!0;if(k.#Z&&_-k.#Z<Z)return!0;if(k.#_&&_-k.#_<Z)return!0;return!1}showDelayedPopup(_){if(this.#k)return;if(clearTimeout(this.timeout),_?.type==="pointerenter"){let Z=this.#A;if(Z?.matches?.("fig-select[open]")||Z?.querySelector?.("fig-select[open]"))return}if(this.#C()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#L&&!this.#L.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&k.#$&&k.#$!==this)k.#$.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")k.#$=this;k.#Z=Date.now()}hidePopup(){if(this.#k)return;clearTimeout(this.timeout),clearTimeout(this.#H);let _=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,k.#$===this)k.#$=null;if(_)k.#_=Date.now()}hidePopupOutsideClick(_){if(this.isOpen&&!this.popup.contains(_.target))this.hidePopup()}#h(_){if(!this.#z)this.hidePopup()}#E(_){if(this.action==="hover")this.#z=!0,clearTimeout(this.#H),this.showDelayedPopup()}#f(_){if(this.action==="hover"&&this.#z)clearTimeout(this.#H),this.#H=setTimeout(()=>{this.#z=!1,this.hidePopup()},150)}#x(_){if(this.action==="hover"&&this.#z)clearTimeout(this.#H),this.#H=setTimeout(()=>{this.#z=!1,this.hidePopup()},300)}#g(_){if(this.action==="hover"&&this.#z)this.#z=!1,clearTimeout(this.#H),this.hidePopup()}#w(_){if(!this.isOpen&&!this.popup||_.key!=="Escape")return;_.preventDefault(),this.hidePopup(),this.firstElementChild?.focus?.()}static get observedAttributes(){return["action","delay","open","pointer","show","text","theme"]}get text(){return this.getAttribute("text")??""}set text(_){this.setAttribute("text",_)}#p(_){if(!this.popup)return;let Z=this.popup.firstElementChild??this.popup.firstChild;if(!Z)return;Z.innerText=_}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){if(_===!1||_==="false"||_===null)this.removeAttribute("open");else this.setAttribute("open","true")}attributeChangedCallback(_,Z,$){if(_==="action"){if(this.#P(),Z==="click")document.body?.removeEventListener("click",this.#N);if(this.action=$||"hover",this.isConnected){if(this.#S(),this.action==="click")document.body?.addEventListener("click",this.#N)}}if(_==="delay"){let J=parseInt($);this.delay=!isNaN(J)?J:500}if(_==="open")if($!==null&&$!=="false")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(_==="show")if($!==null&&$!=="false")this.showPopup();else this.hidePopup();if(_==="text")this.#p($??"");if(_==="pointer"){if(this.popup)if($!==null)this.popup.setAttribute("pointer",$);else this.popup.removeAttribute("pointer")}if(_==="theme"){if(this.popup)if($)this.popup.setAttribute("theme",$);else this.popup.removeAttribute("theme")}}#y(_){if(!this.isOpen)return;let Z=_.target;if(this.popup&&this.popup.contains(Z))return;if(Z.tagName==="SELECT"||Z.hasAttribute("popover")||Z.closest("dialog"))this.hidePopup()}static#b(){if(k.#Q)return;k.#Q=!0;let _=()=>{k.dismissHoverTooltips()},Z=()=>{k.#u()};document.documentElement.addEventListener("mouseleave",_),document.addEventListener("mouseout",($)=>{if($.relatedTarget)return;_()}),document.addEventListener("scroll",Z,{capture:!0,passive:!0}),window.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("resize",Z,{passive:!0});try{let $=window.frameElement;if($)$.addEventListener("mouseleave",_)}catch{}window.addEventListener("message",($)=>{if($?.data?.type!=="figui:dismiss-tooltips")return;if(window.parent!==window&&$.source!==window.parent)return;_()})}static dismissHoverTooltips(){for(let _ of document.querySelectorAll("fig-tooltip")){if(!(_ instanceof k))continue;if(_.action!=="hover")continue;if(_.#k)continue;if(_.#D=!0,setTimeout(()=>{let Z=_.#A;if(Z!==document.activeElement&&!Z?.matches?.(":focus, :focus-within"))_.#D=!1},0),_.isOpen||_.timeout)_.hidePopup()}for(let _ of Array.from(k.#j))k.hide(_)}static#v=new WeakMap;static#u(){for(let _ of document.querySelectorAll("fig-tooltip")){if(!(_ instanceof k))continue;if(_.#k)continue;if(_.isOpen||_.timeout)_.hidePopup()}for(let _ of Array.from(k.#j))k.hide(_)}static show(_,Z,$={}){k.#b(),k.hide(_);let J=$.delay??500,j=Date.now()-k.#Z<k.#J?0:J,q={timeout:null,popup:null};k.#v.set(_,q),k.#j.add(_),q.timeout=setTimeout(()=>{let N=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,G=document.createElement("dialog",{is:"fig-popup"});if(G.setAttribute("is","fig-popup"),G.setAttribute("variant","tooltip"),G.setAttribute("data-tooltip-managed",""),G.setAttribute("role","tooltip"),G.setAttribute("closedby","closerequest"),N)G.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=Z,G.append(K),N)(l()??document.body).append(G);else{let X=_.closest?.("dialog");if(X&&X.open)X.append(G);else(l()??document.body).append(G)}G.anchor=_,G.open=!0,q.popup=G,k.#Z=Date.now()},j)}static hide(_){let Z=k.#v.get(_);if(!Z)return;if(clearTimeout(Z.timeout),Z.popup)Z.popup.remove(),k.#_=Date.now();k.#v.delete(_),k.#j.delete(_)}}F("fig-tooltip",k);class __ extends HTMLElement{static observedAttributes=["position","tail","tooltip"];#Z=null;#_=null;#J=null;#$=null;connectedCallback(){this.#Z=this.textContent,this.#$??=new MutationObserver(()=>{this.#Z=this.textContent,this.#j()}),this.#Q(),u(this,()=>{this.#j(),this.#X(),this.#N()})}disconnectedCallback(){this.#$?.disconnect(),this.#X()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#Z===null)return;if(_==="tooltip"){if(this.#X(),this.isConnected)this.#N();return}this.#j()}#Q(){this.#$?.observe(this,{childList:!0,characterData:!0,subtree:!0})}#j(){if(this.#$?.disconnect(),this.#G(),this.isConnected)this.#Q()}#G(){let _=this.getAttribute("position")||"right",Z=this.#Z||"";if(_==="middle"){let $=this.getAttribute("tail"),J;if($){let q=Z.lastIndexOf($);J=q>0?q:Math.ceil(Z.length/2)}else J=Math.ceil(Z.length/2);this.replaceChildren();let Q=document.createElement("span");Q.className="start",Q.textContent=Z.slice(0,J);let j=document.createElement("span");j.className="end",j.textContent=Z.slice(J),this.appendChild(Q),this.appendChild(j)}else this.textContent=Z}#N(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#_=()=>{if(!this.#q())return;k.show(this,this.#Z)},this.#J=()=>{k.hide(this)},this.addEventListener("pointerenter",this.#_),this.addEventListener("pointerleave",this.#J)}#q(){let _=(Z)=>Z.scrollWidth>Z.clientWidth;if(_(this))return!0;return[...this.querySelectorAll(":scope > .start, :scope > .end")].some(_)}#X(){if(this.#_)this.removeEventListener("pointerenter",this.#_);if(this.#J)this.removeEventListener("pointerleave",this.#J);this.#_=null,this.#J=null,k.hide(this)}}F("fig-truncate",__);function Z_(_){if(_.querySelector("fig-header[dialog-header]"))return;let Z=document.createElement("fig-header");Z.setAttribute("dialog-header",""),Z.setAttribute("data-auto","");let $=document.createElement("h3");$.textContent=_.getAttribute("title")||"Dialog";let J=document.createElement("fig-tooltip");J.setAttribute("text","Close");let Q=document.createElement("fig-button");Q.setAttribute("variant","ghost"),Q.setAttribute("icon",""),Q.setAttribute("aria-label","Close dialog"),Q.setAttribute("close-dialog",""),Q.appendChild(b("close")),J.appendChild(Q),Z.appendChild($),Z.appendChild(J),_.prepend(Z)}class $_ extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._isDragging=!1,this._dragPending=!1,this._dragStartPos={x:0,y:0},this._dragOffset={x:0,y:0},this._resizeObserver=null,this._mutationObserver=null,this._autoResizeRafId=0,this._offset=16,this._positionInitialized=!1,this._dragThreshold=3,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundClose=this.close.bind(this),this._boundIframeMessage=this._handleIframeMessage.bind(this),this._boundContentMutation=this._scheduleAutoResize.bind(this),this._boundContentResize=this._scheduleAutoResize.bind(this),this._boundRestoreFocus=this._restoreFocus.bind(this),this._boundIframeMouseLeave=this._handleIframeMouseLeave.bind(this),this._iframeDismissMutationObserver=null,this._previousFocus=null}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){if(this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),this.open&&!this.matches?.(":modal"))this._assignStackingOrder();u(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._setupIframeDismissListeners(),this._syncA11y()}),window.addEventListener("message",this._boundIframeMessage)}disconnectedCallback(){this._figInit(),this._removeDragListeners(),this.querySelectorAll("fig-button[close-dialog]").forEach((_)=>{_.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize(),this._teardownIframeDismissListeners(),this.removeEventListener("close",this._boundRestoreFocus)}_captureFocusBeforeOpen(){let _=document.activeElement;this._previousFocus=_ instanceof HTMLElement&&_!==document.body&&!this.contains(_)?_:null}_restoreFocus(){let _=this._previousFocus;if(this._previousFocus=null,!_?.isConnected)return;let Z=document.activeElement;if(Z&&Z!==document.body&&!this.contains(Z))return;requestAnimationFrame(()=>_.focus?.())}_assignStackingOrder(){this.style.zIndex=String(t0()+1)}_clearStackingOrder(){this.style.zIndex=""}show(){return this._captureFocusBeforeOpen(),this._assignStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),k.dismissHoverTooltips(),super.show()}showModal(){return this._captureFocusBeforeOpen(),this._clearStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),k.dismissHoverTooltips(),super.showModal()}close(..._){let Z=super.close(..._);return this._clearStackingOrder(),Z}_handleIframeMouseLeave(_){let Z=_?.currentTarget;if(!(Z instanceof HTMLIFrameElement))return;try{Z.contentWindow?.postMessage({type:"figui:dismiss-tooltips"},"*")}catch{}}_syncIframeDismissListeners(){for(let _ of this.querySelectorAll(":scope > iframe")){if(!(_ instanceof HTMLIFrameElement))continue;if(_.dataset.figuiDismissBound==="true")continue;_.dataset.figuiDismissBound="true",_.addEventListener("mouseleave",this._boundIframeMouseLeave)}}_setupIframeDismissListeners(){if(this._syncIframeDismissListeners(),this._iframeDismissMutationObserver)return;this._iframeDismissMutationObserver=new MutationObserver(()=>{this._syncIframeDismissListeners()}),this._iframeDismissMutationObserver.observe(this,{childList:!0,subtree:!1})}_teardownIframeDismissListeners(){this._iframeDismissMutationObserver?.disconnect(),this._iframeDismissMutationObserver=null;for(let _ of this.querySelectorAll(":scope > iframe"))_.removeEventListener("mouseleave",this._boundIframeMouseLeave),delete _.dataset.figuiDismissBound}_handleIframeMessage(_){if(!this.autoresize)return;let Z=_?.data;if(!Z||Z.type!=="figui:iframe-resize")return;let $=_.source;if(!$)return;let J=Array.from(this.querySelectorAll("iframe")).find((Q)=>Q.contentWindow===$);if(!J)return;this._resizeForIframe(J,Z)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let _ of this.children)try{this._resizeObserver.observe(_)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((_)=>{for(let Z of _)Z.addedNodes?.forEach(($)=>{if($ instanceof Element&&$.parentElement===this)try{this._resizeObserver?.observe($)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(_){let Z=window.getComputedStyle(this),$=parseFloat(Z.paddingTop||"0")+parseFloat(Z.paddingBottom||"0")+parseFloat(Z.borderTopWidth||"0")+parseFloat(Z.borderBottomWidth||"0"),J=0,Q=parseFloat(Z.rowGap||Z.gap||"0")||0,j=0;for(let q of this.children){let N=q.getBoundingClientRect();if(N.height===0)continue;if(j+=1,q===_)continue;let G=window.getComputedStyle(q),K=parseFloat(G.marginTop||"0")+parseFloat(G.marginBottom||"0");J+=N.height+K}if(Q&&j>1)J+=Q*(j-1);return $+J}_resizeForIframe(_,Z){if(typeof Z.height!=="number"||!(Z.height>0))return;let $=this._computeChrome(_);this.style.height=`${Math.ceil(Z.height+$)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){Z_(this)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((_)=>{if(!_.hasAttribute("aria-label"))_.setAttribute("aria-label","Close dialog");_.removeEventListener("click",this._boundClose),_.addEventListener("click",this._boundClose)})}_syncA11y(){if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let _=this.querySelector("fig-header[dialog-header] h1, fig-header[dialog-header] h2, fig-header[dialog-header] h3, fig-header[dialog-header] h4, fig-header[dialog-header] h5, fig-header[dialog-header] h6");if(_){let Z=_.getAttribute("id")||g();_.setAttribute("id",Z),this.setAttribute("aria-labelledby",Z)}}}_applyPosition(){let _=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let Z=_.includes("top"),$=_.includes("bottom"),J=_.includes("left"),Q=_.includes("right"),j=_.includes("center")&&!Z&&!$,q=_.includes("center")&&!J&&!Q;if(Z)this.style.top=`${this._offset}px`;else if($)this.style.bottom=`${this._offset}px`;else if(j)this.style.top="0",this.style.bottom="0";if(J)this.style.left=`${this._offset}px`;else if(Q)this.style.right=`${this._offset}px`;else if(q)this.style.left="0",this.style.right="0";if(j&&q)this.style.margin="auto";else if(j)this.style.marginTop="auto",this.style.marginBottom="auto";else if(q)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let _=this.getAttribute("handle"),Z=_?this.querySelector(_):this.querySelector("fig-header, header");if(Z)Z.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}_isInteractiveElement(_){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(j)=>Z.some((q)=>j.matches?.(q))||j.tagName?.startsWith("FIG-")&&!$.includes(j.tagName);if(J(_))return!0;let Q=_.parentElement;while(Q&&Q!==this){if(J(Q))return!0;Q=Q.parentElement}return!1}_handlePointerDown(_){if(!this.drag)return;if(this._isInteractiveElement(_.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(_.target))return}this._dragPending=!0,this._dragStartPos.x=_.clientX,this._dragStartPos.y=_.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=_.clientX-$.left,this._dragOffset.y=_.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}_handlePointerMove(_){if(this._dragPending&&!this._isDragging){let Z=Math.abs(_.clientX-this._dragStartPos.x),$=Math.abs(_.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(_.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${_.clientX-this._dragOffset.x}px`,this.style.top=`${_.clientY-this._dragOffset.y}px`,_.preventDefault()}_handlePointerUp(_){if(this._isDragging){if(this.hasPointerCapture?.(_.pointerId))this.releasePointerCapture(_.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),_.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(_,Z,$){if(this._figInit(),_==="autoresize"&&this.isConnected)this._syncAutoResize();if(_==="drag")if(this.drag=$!==null&&$!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let J=this.querySelector("fig-header, header");if(J)J.style.cursor=""}if(_==="position"&&this._positionInitialized)this._applyPosition();if(_==="modal"){let J=this.modal;if(this.modal=$!==null&&$!=="false",this.open&&J!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(_==="closedby")this.closedby=$||"any";if(_==="title"){let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";this._syncA11y()}if(_==="aria-label"||_==="aria-labelledby")this._syncA11y()}}k0("fig-dialog",$_,{extends:"dialog"});class J_ extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._toastVisible=!1,this._syncingOpen=!1,this._managedRole=null,this._managedLive=null,this._managedIcon=null,this._managedDismiss=null,this._managedDismissSeparator=null,this._boundHandleClose=this.handleClose.bind(this)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.syncIcon(),this.syncDismiss(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast();else{if(this.getAttribute("open")==="false")this._syncingOpen=!0,this.removeAttribute("open"),this._syncingOpen=!1;this._toastVisible=!1}}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((_)=>{if(!_.hasAttribute("aria-label"))_.setAttribute("aria-label","Close notification");_.removeEventListener("click",this._boundHandleClose),_.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto";let _=Number.parseFloat(this.getAttribute("offset")),Z=Number.isFinite(_)?_:this._defaultOffset;this.style.bottom=`${Z}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let _=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger",Z=_?"alert":"status",$=_?"assertive":"polite";if(!this.hasAttribute("role")||this.getAttribute("role")===this._managedRole)this.setAttribute("role",Z),this._managedRole=Z;if(!this.hasAttribute("aria-live")||this.getAttribute("aria-live")===this._managedLive)this.setAttribute("aria-live",$),this._managedLive=$;if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}syncIcon(){let _=this.getAttribute("icon"),Z=this._managedIcon;if(!Z||Z.parentNode!==this)Z=this.querySelector(":scope > fig-icon[data-fig-toast-icon]");if(!_){if(Z)Z.remove();this._managedIcon=null;return}if(!Z)Z=document.createElement("fig-icon"),Z.setAttribute("data-fig-toast-icon",""),Z.setAttribute("aria-hidden","true"),this.prepend(Z);else if(this.firstElementChild!==Z)this.prepend(Z);if(Z.getAttribute("size")!=="medium")Z.setAttribute("size","medium");if(Z.getAttribute("name")!==_)Z.setAttribute("name",_);this._managedIcon=Z}syncDismiss(){let _=T(this,"dismiss"),Z=this._managedDismiss;if(!Z||Z.parentNode!==this)Z=this.querySelector(":scope > fig-button[data-fig-toast-dismiss]");let $=this._managedDismissSeparator;if(!$||$.parentNode!==this)$=this.querySelector(":scope > fig-separator[data-fig-toast-dismiss-separator]");if(!_){if(Z)Z.removeEventListener("click",this._boundHandleClose),Z.remove();if($)$.remove();this._managedDismiss=null,this._managedDismissSeparator=null;return}if(!$)$=document.createElement("fig-separator"),$.setAttribute("data-fig-toast-dismiss-separator",""),$.setAttribute("direction","vertical"),$.setAttribute("aria-orientation","vertical"),$.setAttribute("aria-hidden","true");if(!Z){Z=document.createElement("fig-button"),Z.setAttribute("data-fig-toast-dismiss",""),Z.setAttribute("variant","ghost"),Z.setAttribute("icon",""),Z.setAttribute("close-toast",""),Z.setAttribute("aria-label","Close notification");let J=document.createElement("fig-icon");J.setAttribute("name","close"),J.setAttribute("aria-hidden","true"),Z.append(J)}if($.parentNode!==this||Z.parentNode!==this)this.append($,Z);else if(this.lastElementChild!==Z||Z.previousElementSibling!==$)this.append($,Z);if($.getAttribute("direction")!=="vertical")$.setAttribute("direction","vertical");Z.removeEventListener("click",this._boundHandleClose),Z.addEventListener("click",this._boundHandleClose),this._managedDismiss=Z,this._managedDismissSeparator=$}startAutoClose(){this.clearAutoClose();let _=parseInt(this.getAttribute("duration")??"5000");if(_>0)this._autoCloseTimer=setTimeout(()=>this.hideToast(),_)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}_resolveAutoTheme(){if(this.getAttribute("theme")!=="auto")return;let _=getComputedStyle(document.documentElement).colorScheme||"";this.style.colorScheme=_.includes("dark")?"light":"dark"}showToast(){let _=this._toastVisible;this.syncLiveRegion(),this.syncIcon(),this.syncDismiss(),this._resolveAutoTheme(),this._syncingOpen=!0;try{if(!this.open)this.show()}finally{this._syncingOpen=!1}if(this._toastVisible=!0,this.applyPosition(),this.startAutoClose(),!_)this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){let _=this._toastVisible||this.open;this.clearAutoClose(),this._syncingOpen=!0;try{if(this.open)this.close();else if(this.hasAttribute("open"))this.removeAttribute("open")}finally{this._syncingOpen=!1}if(this._toastVisible=!1,_)this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live","icon","dismiss"]}attributeChangedCallback(_,Z,$){if(this._figInit(),Z===$)return;if(!this.isConnected)return;if(this._syncingOpen)return;if(_==="offset")this.applyPosition();if(_==="open")if($!==null&&$!=="false")this.showToast();else this.hideToast();if(_==="duration"&&this._toastVisible)this.startAutoClose();if(_==="theme")if($==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme");if(_==="theme"||_==="live")this.syncLiveRegion();if(_==="icon")this.syncIcon();if(_==="dismiss")this.syncDismiss()}}k0("fig-toast",J_,{extends:"dialog"});class N0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundContentReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_pendingFullReposition=!1;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;_previousFocus=null;_boundDocumentKeydown;_boundDocumentPointerUp;_boundNativeClose;_boundNativeCancel;_suppressNativeCancel=!1;_nativeCancelResetTimer=null;constructor(){super();this._boundReposition=()=>this.queueReposition(),this._boundContentReposition=()=>this.queueReposition({preserveCurrentPosition:!0}),this._boundScroll=(_)=>{let Z=_.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this),this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this),this._boundDocumentPointerUp=this.handleDocumentPointerUp.bind(this),this._boundNativeClose=this.handleNativeClose.bind(this),this._boundNativeCancel=this.handleNativeCancel.bind(this),this._boundAutoClose=()=>{this.open=!1}}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._pendingFullReposition>"u")this._pendingFullReposition=!1;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._previousFocus>"u")this._previousFocus=null;if(typeof this._suppressNativeCancel>"u")this._suppressNativeCancel=!1;if(typeof this._nativeCancelResetTimer>"u")this._nativeCancelResetTimer=null;if(typeof this._boundReposition!=="function")this._boundReposition=()=>this.queueReposition();if(typeof this._boundContentReposition!=="function")this._boundContentReposition=()=>this.queueReposition({preserveCurrentPosition:!0});if(typeof this._boundScroll!=="function")this._boundScroll=(_)=>{let Z=_.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this);if(typeof this._boundDocumentKeydown!=="function")this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this);if(typeof this._boundDocumentPointerUp!=="function")this._boundDocumentPointerUp=this.handleDocumentPointerUp.bind(this);if(typeof this._boundNativeClose!=="function")this._boundNativeClose=this.handleNativeClose.bind(this);if(typeof this._boundNativeCancel!=="function")this._boundNativeCancel=this.handleNativeCancel.bind(this);if(typeof this._boundAutoClose!=="function")this._boundAutoClose=()=>{this.open=!1}}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin","title"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){if(_===!1||_==="false"||_===null){if(!(this.matches?.(":open")||this.matches?.(":popover-open"))&&!this.hasAttribute("open"))return;if(this.hidePopup(),this.hasAttribute("open"))this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(_){if(_ instanceof Element)this._anchorRef=_;else if(typeof _==="string")this._anchorRef=null,this.setAttribute("anchor",_);else if(_&&typeof _.getBoundingClientRect==="function")this._anchorRef=_;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role",this.getAttribute("variant")==="tooltip"?"tooltip":"dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),this.removeEventListener("close",this._boundNativeClose),this.addEventListener("close",this._boundNativeClose),this.removeEventListener("cancel",this._boundNativeCancel),this.addEventListener("cancel",this._boundNativeCancel),requestAnimationFrame(()=>{this.setupDragListeners()}),this.open)this.showPopup();else this.hidePopup()}disconnectedCallback(){if(this.ensureInitialized(),this.teardownObservers(),this.removeDragListeners(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),document.removeEventListener("pointerup",this._boundDocumentPointerUp,!0),document.removeEventListener("pointercancel",this._boundDocumentPointerUp,!0),this.removeEventListener("close",this._boundNativeClose),this.removeEventListener("cancel",this._boundNativeCancel),this._nativeCancelResetTimer!==null)clearTimeout(this._nativeCancelResetTimer),this._nativeCancelResetTimer=null;if(this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(_,Z,$){if(this.ensureInitialized(),Z===$)return;if(_==="open"){if($==="false"){this.open=!1;return}if($===null){this.hidePopup();return}this.showPopup();return}if(_==="drag"){if(this.drag=$!==null&&$!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(_==="title"){this._ensureHeader();let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(t0()+1),this.captureFocusBeforeOpen();let _=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),Z=this.shouldAutoReposition();if(Z)this.style.visibility="hidden";if(_)try{this.showPopover()}catch(J){_=!1}if(!_&&!super.open)try{this.show()}catch(J){}if(Z&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.addEventListener("keydown",this._boundDocumentKeydown,!0),document.addEventListener("pointerup",this._boundDocumentPointerUp,!0),document.addEventListener("pointercancel",this._boundDocumentPointerUp,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let $=this.resolveAnchor();if($?.classList)$.classList.add("has-popup-open");if(this.getAttribute("variant")!=="tooltip")k.dismissHoverTooltips()}hidePopup(){let _=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),Z=this.resolveAnchor();if(Z?.classList)Z.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),document.removeEventListener("pointerup",this._boundDocumentPointerUp,!0),document.removeEventListener("pointercancel",this._boundDocumentPointerUp,!0),this._suppressNativeCancel=!1,this._nativeCancelResetTimer!==null)clearTimeout(this._nativeCancelResetTimer),this._nativeCancelResetTimer=null;if(this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch($){}if(this.matches?.(":open"))try{this.close()}catch($){}if(_)this.restoreFocusAfterClose()}shouldRestoreFocus(){return this.getAttribute("variant")!=="tooltip"}captureFocusBeforeOpen(){if(!this.shouldRestoreFocus())return;let _=document.activeElement;this._previousFocus=_ instanceof HTMLElement&&_!==document.body&&!this.contains(_)?_:null}restoreFocusAfterClose(){if(!this.shouldRestoreFocus()){this._previousFocus=null;return}let _=this.resolveAnchor(),Z=this._previousFocus?.isConnected?this._previousFocus:_ instanceof HTMLElement?_:null;if(this._previousFocus=null,!Z?.isConnected)return;let $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Z.focus?.())}get autoresize(){let _=this.getAttribute("autoresize");return _===null||_!=="false"}set autoresize(_){if(_===!1||_==="false"||_===null)this.setAttribute("autoresize","false");else if(_||_==="")this.setAttribute("autoresize",_===!0?"":_);else this.setAttribute("autoresize","false")}handleNativeClose(){if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}handleNativeCancel(_){if(this._suppressNativeCancel&&this.getAttribute("closedby")==="any")_.preventDefault()}setupObservers(){this.teardownObservers();let _=this.resolveAnchor();if(_ instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(_);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundContentReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundContentReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(_){if(!_)return null;let Z=_.getBoundingClientRect();return{x:Z.x,y:Z.y,width:Z.width,height:Z.height}}hasRectChanged(_,Z,$=0.25){if(!_&&!Z)return!1;if(!_||!Z)return!0;return Math.abs(_.x-Z.x)>$||Math.abs(_.y-Z.y)>$||Math.abs(_.width-Z.width)>$||Math.abs(_.height-Z.height)>$}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let _=()=>{if(!this.open){this._anchorTrackRAF=null;return}let Z=this.resolveAnchor(),$=this.readRectSnapshot(Z),J=this.shouldAutoReposition();if(J&&this.hasRectChanged(this._lastAnchorRect,$))this._lastAnchorRect=$,this.queueReposition();else if(!J)this._lastAnchorRect=$;this._anchorTrackRAF=requestAnimationFrame(_)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(_)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}_ensureHeader(){if(!this.hasAttribute("title")||this.getAttribute("variant")==="tooltip")return;Z_(this),this.querySelectorAll("fig-button[close-dialog]").forEach((_)=>{_.removeEventListener("click",this._boundAutoClose),_.addEventListener("click",this._boundAutoClose)})}handleOutsidePointerDown(_){if(!this.open||!(this.matches?.(":open")||this.matches?.(":popover-open")))return;let Z=this.getAttribute("closedby");if(Z==="none"||Z==="closerequest")return;let $=_.target;if(!($ instanceof Node))return;let J=typeof _.composedPath==="function"?_.composedPath():[];if(J.includes(this)||this.contains($)){this.markOwnedPointerInteraction();return}let Q=this.resolveAnchor();if(Q&&(J.includes(Q)||Q.contains?.($))){this.markOwnedPointerInteraction();return}if(this.isInsideDescendantPopup($,J)){this.markOwnedPointerInteraction();return}this._suppressNativeCancel=!1,this.open=!1}markOwnedPointerInteraction(){if(this._suppressNativeCancel=!0,this._nativeCancelResetTimer!==null)clearTimeout(this._nativeCancelResetTimer),this._nativeCancelResetTimer=null}handleDocumentPointerUp(){if(!this._suppressNativeCancel)return;if(this._nativeCancelResetTimer!==null)clearTimeout(this._nativeCancelResetTimer);this._nativeCancelResetTimer=setTimeout(()=>{this._suppressNativeCancel=!1,this._nativeCancelResetTimer=null},0)}handleDocumentKeydown(_){if(_.key!=="Escape"||_.defaultPrevented)return;if(!this.open)return;if(this.getAttribute("role")==="menu")return;if(this.getAttribute("closedby")==="none")return;let J=Array.from(document.querySelectorAll("dialog[open]")).filter((Q)=>Q instanceof N0&&Q.open).map((Q)=>({popup:Q,z:Number.parseInt(getComputedStyle(Q).zIndex||"0",10)||0})).sort((Q,j)=>Q.z-j.z).at(-1)?.popup;if(J&&J!==this)return;_.preventDefault(),this.open=!1}getContainingPopup(_){let Z=_,$=new Set;while(Z&&!$.has(Z)){if($.add(Z),Z instanceof N0)return Z;Z=Z.parentNode??(Z.getRootNode?.()instanceof ShadowRoot?Z.getRootNode().host:null)}return null}composedContains(_){let Z=_,$=new Set;while(Z&&!$.has(Z)){if(Z===this)return!0;$.add(Z),Z=Z.parentNode??(Z.getRootNode?.()instanceof ShadowRoot?Z.getRootNode().host:null)}return!1}isInsideDescendantPopup(_,Z=[]){let $=Z.find((j)=>j instanceof N0)??this.getContainingPopup(_);if(!$||$===this)return!1;let J=$,Q=new Set;while(J&&!Q.has(J)){Q.add(J);let j=J.anchor;if(!(j instanceof Element))break;if(this.composedContains(j))return!0;J=this.getContainingPopup(j)}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}isInteractiveElement(_){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(j)=>Z.some((q)=>j.matches?.(q))||j.tagName?.startsWith("FIG-")&&!$.includes(j.tagName);if(J(_))return!0;let Q=_.parentElement;while(Q&&Q!==this){if(J(Q))return!0;Q=Q.parentElement}return!1}handlePointerDown(_){if(!this.drag)return;if(this.isInteractiveElement(_.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(_.target))return}this._dragPending=!0,this._dragStartPos.x=_.clientX,this._dragStartPos.y=_.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=_.clientX-$.left,this._dragOffset.y=_.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}handlePointerMove(_){if(this._dragPending&&!this._isDragging){let Z=Math.abs(_.clientX-this._dragStartPos.x),$=Math.abs(_.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(_.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${_.clientX-this._dragOffset.x}px`,this.style.top=`${_.clientY-this._dragOffset.y}px`,_.preventDefault()}handlePointerUp(_){if(this._isDragging){if(this.hasPointerCapture?.(_.pointerId))this.releasePointerCapture(_.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),_.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let _=this.getAttribute("anchor");if(!_)return null;let Z=this.parentElement;try{if(Z?.querySelector){let $=Z.querySelector(_);if($&&!this.contains($))return $}return document.querySelector(_)}catch{return null}}parsePosition(){let Z=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),$=new Set(["top","center","bottom"]),J=new Set(["left","center","right"]),Q="top",j="center",q=null;if(Z.length>=2){if($.has(Z[0]))Q=Z[0];if(J.has(Z[1]))j=Z[1];return{vertical:Q,horizontal:j,shorthand:q}}if(Z.length===1){let N=Z[0];if(N==="top"||N==="bottom")Q=N,q=N;else if(N==="left"||N==="right")j=N,q=N;else if(N==="center")Q="center",j="center"}return{vertical:Q,horizontal:j,shorthand:q}}normalizeOffsetToken(_,Z="0px"){if(!_)return Z;let $=_.trim();if(!$)return Z;if(/^-?\d+(\.\d+)?$/.test($))return`${$}px`;return $}measureLengthPx(_,Z="x"){if(!_)return 0;let $=this.normalizeOffsetToken(_,"0px");if($.endsWith("px")){let j=parseFloat($);return Number.isFinite(j)?j:0}let J=document.createElement("div");if(J.style.position="fixed",J.style.visibility="hidden",J.style.pointerEvents="none",J.style.left="0",J.style.top="0",J.style.margin="0",J.style.padding="0",J.style.border="0",Z==="x")J.style.width=$,J.style.height="0";else J.style.height=$,J.style.width="0";document.body.appendChild(J);let Q=J.getBoundingClientRect();return J.remove(),Z==="x"?Q.width:Q.height}parseOffset(){let Z=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),$=this.normalizeOffsetToken(Z[0],"0px"),J=this.normalizeOffsetToken(Z[1],"0px");return{xToken:$,yToken:J,xPx:this.measureLengthPx($,"x"),yPx:this.measureLengthPx(J,"y")}}parseViewportMargins(){let Z=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((J)=>!Number.isNaN(J)),$=8;if(Z.length===0)return{top:8,right:8,bottom:8,left:8};if(Z.length===1)return{top:Z[0],right:Z[0],bottom:Z[0],left:Z[0]};if(Z.length===2)return{top:Z[0],right:Z[1],bottom:Z[0],left:Z[1]};if(Z.length===3)return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[1]};return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[3]}}getPlacementCandidates(_,Z,$){let J={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if($){let j=$==="left"||$==="right"?["top","bottom"]:["left","right"];return[{v:_,h:Z,s:$},{v:_,h:Z,s:J[$]},{v:_,h:Z,s:j[0]},{v:_,h:Z,s:j[1]}]}if(_==="center")return[{v:"center",h:Z,s:null},{v:"center",h:J[Z],s:null},{v:"top",h:Z,s:null},{v:"bottom",h:Z,s:null},{v:"top",h:J[Z],s:null},{v:"bottom",h:J[Z],s:null}];if(Z==="center")return[{v:_,h:"center",s:null},{v:J[_],h:"center",s:null},{v:_,h:"left",s:null},{v:_,h:"right",s:null},{v:J[_],h:"left",s:null},{v:J[_],h:"right",s:null}];return[{v:_,h:Z,s:null},{v:J[_],h:Z,s:null},{v:_,h:J[Z],s:null},{v:J[_],h:J[Z],s:null}]}computeCoords(_,Z,$,J,Q,j){let q,N;if(j==="left"||j==="right")return N=j==="left"?_.left-Z.width-Q.xPx:_.right+Q.xPx,q=_.top,{top:q,left:N};if(j==="top"||j==="bottom")return q=j==="top"?_.top-Z.height-Q.yPx:_.bottom+Q.yPx,N=_.left,{top:q,left:N};if($==="top")q=_.top-Z.height-Q.yPx;else if($==="bottom")q=_.bottom+Q.yPx;else q=_.top+(_.height-Z.height)/2;if($==="center")if(J==="left")N=_.left-Z.width-Q.xPx;else if(J==="right")N=_.right+Q.xPx;else N=_.left+(_.width-Z.width)/2;else if(J==="left")N=_.left+Q.xPx;else if(J==="right")N=_.right-Z.width-Q.xPx;else N=_.left+(_.width-Z.width)/2;return{top:q,left:N}}oppositeSide(_){return{top:"bottom",bottom:"top",left:"right",right:"left"}[_]||"bottom"}getPlacementSide(_,Z,$){if($==="top")return"top";if($==="bottom")return"bottom";if($==="left")return"left";if($==="right")return"right";if(_!=="center")return _;if(Z!=="center")return Z;return"top"}lengthToPx(_,Z=0){let $=getComputedStyle(this),J=String(_||"").trim(),Q=parseFloat(J);if(!Number.isFinite(Q))return Z;if(J.endsWith("rem"))return Q*parseFloat(getComputedStyle(document.documentElement).fontSize);if(J.endsWith("em"))return Q*parseFloat($.fontSize);return Q}radiusForSide(_){let Z=getComputedStyle(this),$=(J)=>this.lengthToPx(J,0);if(_==="top")return Math.max($(Z.borderTopLeftRadius),$(Z.borderTopRightRadius));if(_==="bottom")return Math.max($(Z.borderBottomLeftRadius),$(Z.borderBottomRightRadius));if(_==="left")return Math.max($(Z.borderTopLeftRadius),$(Z.borderBottomLeftRadius));if(_==="right")return Math.max($(Z.borderTopRightRadius),$(Z.borderBottomRightRadius));return 0}getBeakEdgeInset(_){let Z=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(_)+Z/2)}tracksAnchorBeak(){let _=this.getAttribute("variant");return _==="popover"||_==="tooltip"}getViewportBounds(_){let Z=window.visualViewport,$=Z?.width??window.innerWidth,J=Z?.height??window.innerHeight,Q=Z?.offsetLeft??0,j=Z?.offsetTop??0;return{minLeft:Q+_.left,minTop:j+_.top,maxRight:Q+$-_.right,maxBottom:j+J-_.bottom}}clampToViewport(_,Z,$){let J=this.getViewportBounds($),Q=J.maxRight-Z.width,j=J.maxBottom-Z.height,q=Math.max(J.minLeft,Q),N=Math.max(J.minTop,j);return{left:Math.min(q,Math.max(J.minLeft,_.left)),top:Math.min(N,Math.max(J.minTop,_.top))}}resolveCoordsAtViewport(_,Z,$,J,Q){let{left:j,top:q}=this.clampToViewport($,Z,Q);if(!_||!this.tracksAnchorBeak())return{left:j,top:q};let N=this.oppositeSide(J),G=this.getViewportBounds(Q),K=G.maxRight-Z.width,X=G.minLeft,Y=G.maxBottom-Z.height,W=G.minTop;if(N==="top"||N==="bottom"){let R=this.getBeakEdgeInset(N),L=_.left+_.width/2,O=L-j;if(O<R)j=L-R;else if(O>Z.width-R)j=L-(Z.width-R);j=Math.min(K,Math.max(X,j))}else if(N==="left"||N==="right"){let R=this.getBeakEdgeInset(N),L=_.top+_.height/2,O=L-q;if(O<R)q=L-R;else if(O>Z.height-R)q=L-(Z.height-R);q=Math.min(Y,Math.max(W,q))}return{left:j,top:q}}canPointAtAnchor(_,Z,$,J,Q){if(!_||!this.tracksAnchorBeak())return!0;let j=this.oppositeSide(Q),q=this.getBeakEdgeInset(j);if(j==="top"||j==="bottom"){let G=_.left+_.width/2-$;return G>=q-0.5&&G<=Z.width-q+0.5}let N=_.top+_.height/2-J;return N>=q-0.5&&N<=Z.height-q+0.5}updatePopoverBeak(_,Z,$,J,Q){if(!this.tracksAnchorBeak()||!_){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let j=this.oppositeSide(Q);this.setAttribute("data-beak-side",j);let q=_.left+_.width/2,N=_.top+_.height/2,G=this.getBoundingClientRect(),K=G.width>0&&G.height>0?G:Z,X=K.left,Y=K.top,W=this.getBeakEdgeInset(j),R;if(j==="top"||j==="bottom"){R=q-X;let L=W,O=Math.max(L,K.width-W);R=Math.min(O,Math.max(L,R))}else{R=N-Y;let L=W,O=Math.max(L,K.height-W);R=Math.min(O,Math.max(L,R))}this.style.setProperty("--fig-popup-beak-offset",`${R}px`)}overflowScore(_,Z,$){let J=this.getViewportBounds($),Q=_.left+Z.width,j=_.top+Z.height,q=Math.max(0,J.minLeft-_.left),N=Math.max(0,J.minTop-_.top),G=Math.max(0,Q-J.maxRight),K=Math.max(0,j-J.maxBottom);return q+N+G+K}fits(_,Z,$){return this.overflowScore(_,Z,$)===0}clamp(_,Z,$,J=null,Q="top"){if(J)return this.resolveCoordsAtViewport(J,Z,_,Q,$);return this.clampToViewport(_,Z,$)}primaryAxisOverflowPenalty(_,Z,$,J){let Q=this.getViewportBounds($),j=0;if(J==="top")j=Math.max(0,Q.minTop-_.top);else if(J==="bottom")j=Math.max(0,_.top+Z.height-Q.maxBottom);else if(J==="left")j=Math.max(0,Q.minLeft-_.left);else if(J==="right")j=Math.max(0,_.left+Z.width-Q.maxRight);return j>0?1000+j:0}placementScore(_,Z,$,J,Q){let j=this.resolveCoordsAtViewport(_,Z,$,J,Q),q=this.overflowScore(j,Z,Q);if(q+=this.primaryAxisOverflowPenalty($,Z,Q,J),_&&!this.canPointAtAnchor(_,Z,j.left,j.top,J))q+=1e4;return{score:q,resolved:j}}applyPopupPosition(_,Z,$,J,Q){let j=this.resolveCoordsAtViewport(_,Z,$,J,Q);this.style.left=`${j.left}px`,this.style.top=`${j.top}px`,this.updatePopoverBeak(_,Z,j.left,j.top,J)}currentPlacementSide(){let _=this.getAttribute("data-beak-side");if(_)return this.oppositeSide(_);let{vertical:Z,horizontal:$,shorthand:J}=this.parsePosition();return this.getPlacementSide(Z,$,J)}preservePopupPosition(_,Z,$){let J={left:_.left,top:_.top},Q=this.fits(J,_,$)?J:this.clampToViewport(J,_,$),j=Z?Z.getBoundingClientRect():null,q=this.currentPlacementSide();if(j&&this.tracksAnchorBeak()&&!this.canPointAtAnchor(j,_,Q.left,Q.top,q))return!1;return this.style.left=`${Q.left}px`,this.style.top=`${Q.top}px`,this.updatePopoverBeak(j,_,Q.left,Q.top,q),!0}positionPopup({preserveCurrentPosition:_=!1}={}){if(!this.open)return;let Z=this.getBoundingClientRect(),$=this.resolveAnchor(),J=this.parseViewportMargins();if(_&&this.preservePopupPosition(Z,$,J))return;let Q=this.parseOffset(),{vertical:j,horizontal:q,shorthand:N}=this.parsePosition();if(!$){this.updatePopoverBeak(null,Z,0,0,"top");let R=this.getViewportBounds(J),L={left:R.minLeft+(R.maxRight-R.minLeft-Z.width)/2,top:R.minTop+(R.maxBottom-R.minTop-Z.height)/2},O=this.clampToViewport(L,Z,J);this.style.left=`${O.left}px`,this.style.top=`${O.top}px`;return}let G=$.getBoundingClientRect(),K=this.getPlacementCandidates(j,q,N),X=null,Y="top",W=Number.POSITIVE_INFINITY;for(let{v:R,h:L,s:O}of K){let H=this.computeCoords(G,Z,R,L,Q,O),A=this.getPlacementSide(R,L,O),{score:z,resolved:U}=this.placementScore(G,Z,H,A,J);if(O){let I=this.getViewportBounds(J);if((O==="left"||O==="right"?H.left>=I.minLeft&&H.left+Z.width<=I.maxRight:H.top>=I.minTop&&H.top+Z.height<=I.maxBottom)&&z<1e4){this.applyPopupPosition(G,Z,H,A,J);return}}else if(z===0){this.applyPopupPosition(G,Z,H,A,J);return}if(z<W)W=z,X=U,Y=A}this.applyPopupPosition(G,Z,X||{left:0,top:0},Y,J)}queueReposition({preserveCurrentPosition:_=!1}={}){if(!this.open||!this.isPopupDisplayed()||!this.shouldAutoReposition())return;if(!_)this._pendingFullReposition=!0;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null;let Z=!this._pendingFullReposition;this._pendingFullReposition=!1,this.positionPopup({preserveCurrentPosition:Z})})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}isPopupDisplayed(){return Boolean(this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"))}}k0("fig-popup",N0,{extends:"dialog"});class Q_ extends HTMLElement{#Z;#_;constructor(){super();this.content=null,this.#Z=!1,this.#_=this.handleClick.bind(this)}connectedCallback(){if(this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.addEventListener("click",this.#_),u(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let _=this.getAttribute("id")||g(),Z=this.content.getAttribute("id")||g();if(this.setAttribute("id",_),this.content.setAttribute("id",Z),this.setAttribute("aria-controls",Z),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",_),this.#Z)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}}})}get selected(){return this.#Z}set selected(_){this.setAttribute("selected",_?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#_)}handleClick(){if(T(this,"disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(_,Z,$){if(_==="selected"){if(this.#Z=$!==null&&$!=="false",this.setAttribute("aria-selected",this.#Z?"true":"false"),this.setAttribute("tabindex",this.#Z?"0":"-1"),this?.content)this.content.style.display=this.#Z?"block":"none"}if(_==="disabled")if($!==null&&$!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#Z?"0":"-1")}}F("fig-tab",Q_);class j_ extends HTMLElement{#Z;#_;#J=this.#B.bind(this);#$=null;#Q=null;#j=null;#G=null;#N=!1;#q=new WeakSet;constructor(){super();this.#Z=this.handleClick.bind(this),this.#_=this.#H.bind(this)}static get observedAttributes(){return["value","name","disabled","overflow"]}get#X(){return this.getAttribute("overflow")==="fade"?"fade":"buttons"}connectedCallback(){if(this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#W(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#_),this.addEventListener("scroll",this.#J),this.#A(),this.#O(),this.#M(),u(this,()=>{let _=this.getAttribute("value");if(_)this.#T(_);if(T(this,"disabled"))this.#K(!0);this.#R(),this.#B(),this.#U(void 0,"auto")})}#K(_){this.querySelectorAll("fig-tab").forEach(($)=>{if(_){if(!($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false"))this.#q.add($),$.setAttribute("disabled","");$.setAttribute("aria-disabled","true"),$.setAttribute("tabindex","-1")}else if(this.#q.has($))this.#q.delete($),$.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#R()}#Y(){return Array.from(this.querySelectorAll("fig-tab")).filter((_)=>!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false")}#R(){let _=Array.from(this.querySelectorAll("fig-tab")),Z=_.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false")||this.#Y()[0];_.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false";$.setAttribute("tabindex",!J&&$===Z?"0":"-1")})}#U(_=this.selectedTab,Z="smooth"){let $=_||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#Y()[0];if(!$)return;requestAnimationFrame(()=>{if(!this.isConnected||!$.isConnected)return;if(!(this.scrollWidth>this.clientWidth))return;let Q=this.getBoundingClientRect(),j=$.getBoundingClientRect(),q=j.left-Q.left+this.scrollLeft+j.width/2;this.scrollTo({left:q-this.clientWidth/2,behavior:Z}),this.#B()})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#_),this.removeEventListener("scroll",this.#J),this.#$?.disconnect(),this.#$=null,this.#Q?.disconnect(),this.#Q=null,this.#L()}#W(){if(this.#N)return;let _=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!_)return;this.#N=!0;try{let Z=Array.from(_.childNodes);_.replaceWith(...Z)}finally{this.#N=!1}}#B(){L0(this,this,"x")}#M(){this.#Q?.disconnect(),this.#Q=new ResizeObserver(()=>this.#B()),this.#Q.observe(this)}#O(){this.#$?.disconnect(),this.#$=new MutationObserver((_)=>{if(this.#N)return;if(!_.some(($)=>[...$.addedNodes,...$.removedNodes].some((J)=>!(J instanceof Element)||!J.matches("[data-fig-tabs-nav]"))))return;this.#W(),this.#A(),this.#R(),requestAnimationFrame(()=>{this.#B(),this.#U()})}),this.#$.observe(this,{childList:!0,subtree:!1})}#L(){this.#j?.remove(),this.#G?.remove(),this.#j=null,this.#G=null,this.classList.remove("overflow-start","overflow-end")}#A(){let _=this.#X==="fade";if(this.classList.toggle("fig-overflow-fade",_),this.classList.toggle("fig-overflow-fade-horizontal",_),_)this.#L();else this.#I()}#I(){if(this.#j&&this.#G&&this.contains(this.#j)&&this.contains(this.#G)){this.#D();return}this.#j?.remove(),this.#G?.remove();let _=W0({owner:"tabs",onStart:()=>Z0(this,"x",-1),onEnd:()=>Z0(this,"x",1)});this.#j=_.start,this.#G=_.end,this.#D()}#D(){if(this.firstElementChild!==this.#j)this.prepend(this.#j);if(this.lastElementChild!==this.#G)this.append(this.#G)}#H(_){let Z=this.#Y();if(!Z.length)return;let $=Z.findIndex((Q)=>T(Q,"selected")),J=$>=0?$:0;switch(_.key){case"ArrowLeft":case"ArrowUp":_.preventDefault(),J=$>0?$-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":_.preventDefault(),J=$<Z.length-1?$+1:0;break;case"Home":_.preventDefault(),J=0;break;case"End":_.preventDefault(),J=Z.length-1;break;default:return}if(J!==$&&Z[J]){this.querySelectorAll("fig-tab").forEach((j)=>j.removeAttribute("selected")),this.selectedTab=Z[J],Z[J].setAttribute("selected","true");let Q=this.#F(Z[J]);if(Q)this.setAttribute("value",Q);else this.removeAttribute("value");Z[J].focus(),this.#R(),this.#U(Z[J]),this.#z()}}get value(){return this.#F(this.selectedTab)}set value(_){this.setAttribute("value",_)}#z(){let _=this.value;this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#F(_){if(!_)return"";let Z=_.getAttribute("value");if(Z!==null)return Z;return _.textContent?.trim()||""}#T(_){let Z=this.querySelectorAll("fig-tab");for(let $ of Z)if(this.#F($)===_)this.selectedTab=$,$.setAttribute("selected","true");else $.removeAttribute("selected");this.#R(),this.#U(this.selectedTab)}attributeChangedCallback(_,Z,$){switch(_){case"value":if($!==Z)this.#T($);break;case"disabled":this.#K($!==null&&$!=="false");break;case"overflow":this.#A(),requestAnimationFrame(()=>this.#B());break}}handleClick(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=_.target.closest("fig-tab");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;let $=this.querySelectorAll("fig-tab"),J=Array.from($).find((q)=>T(q,"selected"))||this.selectedTab,Q=this.#F(J);for(let q of $)if(q===Z)this.selectedTab=q,q.setAttribute("selected","true");else q.removeAttribute("selected");let j=this.#F(Z);if(j)this.setAttribute("value",j);else this.removeAttribute("value");if(this.#R(),this.#U(Z),J!==Z||Q!==this.value)this.#z()}}F("fig-tabs",j_);class q_ extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group")}}F("fig-toolbelt-group",q_);class N_ extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Z()}get value(){let _=this.getAttribute("value");return _!==null?_:this.textContent?.trim()||""}set value(_){this.setAttribute("value",_??"")}get selected(){return T(this,"selected")}set selected(_){this.toggleAttribute("selected",Boolean(_))}get disabled(){return T(this,"disabled")}set disabled(_){this.toggleAttribute("disabled",Boolean(_))}attributeChangedCallback(){this.#Z()}#Z(){let _=T(this,"selected"),Z=T(this,"disabled");if(this.setAttribute("aria-pressed",_?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled")}}F("fig-toolbelt-item",N_);class G_ extends HTMLElement{#Z=this.#T.bind(this);#_=this.#S.bind(this);#J=this.#V.bind(this);#$=this.#E.bind(this);#Q=null;#j=null;#G=null;#N=null;#q=null;#X=null;#K=null;#Y=null;#R=new WeakSet;#U=!1;constructor(){super();let _=this.attachShadow({mode:"open"}),Z=document.createElement("div");Z.setAttribute("part","frame"),this.#G=document.createElement("slot"),this.#G.name="prepend",this.#G.setAttribute("part","prepend"),this.#G.hidden=!0,this.#G.style.display="none";let $=document.createElement("div");$.setAttribute("part","scroll-region");let J=document.createElement("slot");J.name="start",J.style.display="contents",this.#Q=document.createElement("div"),this.#Q.className="fig-overflow-fade",this.#Q.setAttribute("part","viewport"),this.#j=document.createElement("slot"),this.#j.style.display="contents",this.#Q.append(this.#j);let Q=document.createElement("slot");Q.name="end",Q.style.display="contents",this.#N=document.createElement("slot"),this.#N.name="append",this.#N.setAttribute("part","append"),this.#N.hidden=!0,this.#N.style.display="none",$.append(J,this.#Q,Q),Z.append(this.#G,$,this.#N),_.append(Z);for(let j of[this.#G,this.#j,this.#N])j.addEventListener("slotchange",this.#J)}static get observedAttributes(){return["value","disabled","layout","overflow"]}get#W(){return this.getAttribute("layout")==="vertical"}get#B(){return this.getAttribute("overflow")==="buttons"?"buttons":"scrollbar"}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","toolbar");this.#k(),this.#f(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#_),this.#Q.addEventListener("scroll",this.#$),this.#x(),this.#C(),this.#h(),u(this,()=>{this.#I(),this.#A(T(this,"disabled")),this.#F(),this.#E(),this.#b(void 0,"auto")})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#_),this.#Q.removeEventListener("scroll",this.#$),this.#q?.disconnect(),this.#q=null,this.#X?.disconnect(),this.#X=null,this.#p()}get value(){return this.selectedItem?.value||""}set value(_){if(_===null||_===void 0)this.removeAttribute("value");else this.setAttribute("value",String(_))}get selectedItem(){return this.#M().find((_)=>T(_,"selected"))||null}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="value"&&!this.#U)this.#D($);if(_==="disabled")this.#A($!==null&&$!=="false");if(_==="overflow")this.#x(),requestAnimationFrame(()=>this.#E());if(_==="layout"){if(this.#f(),this.#W)this.#Q.scrollLeft=0;else this.#Q.scrollTop=0;this.#x(),requestAnimationFrame(()=>{this.#E(),this.#b(void 0,"auto")})}}#M(){let _={prepend:[],viewport:[],append:[]};for(let Z of this.querySelectorAll("fig-toolbelt-item")){if(Z.closest("fig-toolbelt")!==this)continue;let $=this.#O(Z);if($)_[$].push(Z)}return[..._.prepend,..._.viewport,..._.append]}#O(_){let Z=_;while(Z.parentElement&&Z.parentElement!==this)Z=Z.parentElement;if(Z.parentElement!==this)return null;let $=Z.getAttribute("slot")||"";if($==="prepend"||$==="append")return $;return $?null:"viewport"}#L(){return this.#M().filter((_)=>!T(_,"disabled"))}#A(_){if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Z of this.#M())if(_){if(!T(Z,"disabled"))this.#R.add(Z),Z.setAttribute("disabled","")}else if(this.#R.has(Z))this.#R.delete(Z),Z.removeAttribute("disabled");this.#F()}#I(){let _=this.getAttribute("value");if(_!==null){this.#D(_);return}let Z=this.#M().filter((J)=>T(J,"selected")),$=Z[0]||null;for(let J of Z.slice(1))J.removeAttribute("selected");if($)this.#z($.value)}#D(_){let Z=_===null?null:this.#M().find(($)=>$.value===_)||null;for(let $ of this.#M())$.toggleAttribute("selected",$===Z);if(this.#F(Z),Z)this.#b(Z)}#H(_,{emit:Z=!1,focus:$=!1}={}){if(!_||T(_,"disabled"))return!1;let J=this.selectedItem,Q=this.value;for(let j of this.#M())j.toggleAttribute("selected",j===_);if(this.#z(_.value),this.#F(_),$)_.focus();if(this.#b(_),Z&&(J!==_||Q!==_.value))this.#P();return!0}#z(_){this.#U=!0,this.setAttribute("value",_),this.#U=!1}#F(_){let Z=this.#M(),$=this.#L(),J=_&&$.includes(_)&&_||$.includes(document.activeElement)&&document.activeElement||$.includes(this.selectedItem)&&this.selectedItem||$[0]||null;for(let Q of Z)Q.setAttribute("tabindex",Q===J?"0":"-1")}#T(_){if(T(this,"disabled"))return;let Z=_.target.closest?.("fig-toolbelt-item");if(!Z||Z.closest("fig-toolbelt")!==this)return;this.#H(Z,{emit:!0})}#S(_){if(T(this,"disabled"))return;let Z=_.target.closest?.("fig-toolbelt-item");if(!Z||Z.closest("fig-toolbelt")!==this)return;if(_.key==="Enter"||_.key===" "){_.preventDefault(),this.#H(Z,{emit:!0});return}let $=this.#L();if(!$.length)return;let J=Math.max(0,$.indexOf(Z)),Q=J;switch(_.key){case"ArrowLeft":if(this.#W)return;Q=J>0?J-1:$.length-1;break;case"ArrowUp":if(!this.#W)return;Q=J>0?J-1:$.length-1;break;case"ArrowRight":if(this.#W)return;Q=J<$.length-1?J+1:0;break;case"ArrowDown":if(!this.#W)return;Q=J<$.length-1?J+1:0;break;case"Home":Q=0;break;case"End":Q=$.length-1;break;default:return}_.preventDefault(),this.#F($[Q]),$[Q].focus(),this.#v($[Q])}#P(){let _=this.value;this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#V(){this.#k(),this.#I(),this.#F(),requestAnimationFrame(()=>{this.#E(),this.#b()})}#k(){for(let _ of[this.#G,this.#N]){let Z=_.assignedElements({flatten:!0}).length===0;if(_.hidden=Z,Z)_.style.setProperty("display","none","important");else _.style.removeProperty("display")}}#C(){this.#q?.disconnect(),this.#q=new MutationObserver((_)=>{if(!_.some(($)=>$.type==="childList"||$.target instanceof Element&&$.target.matches("fig-toolbelt-item")&&$.target.closest("fig-toolbelt")===this))return;this.#x(),this.#I(),this.#A(T(this,"disabled")),this.#F(),requestAnimationFrame(()=>{this.#E(),this.#b()})}),this.#q.observe(this,{childList:!0,attributes:!0,subtree:!0,attributeFilter:["value","selected","disabled"]})}#h(){this.#X?.disconnect(),this.#X=new ResizeObserver(()=>this.#E()),this.#X.observe(this),this.#X.observe(this.#Q)}#E(){if(this.#B==="scrollbar")return;L0(this,this.#Q,this.#W?"y":"x")}#f(){this.setAttribute("aria-orientation",this.#W?"vertical":"horizontal"),this.#Q.classList.add("fig-overflow-fade"),this.#Q.classList.toggle("fig-overflow-fade-horizontal",!this.#W)}#x(){if(this.#B==="scrollbar")this.#p();else this.#g()}#g(){if(this.#K&&this.#Y&&this.contains(this.#K)&&this.contains(this.#Y)){this.#w();return}this.#K?.remove(),this.#Y?.remove();let _=W0({owner:"toolbelt",onStart:()=>this.#y(-1),onEnd:()=>this.#y(1)});this.#K=_.start,this.#Y=_.end,this.#K.setAttribute("slot","start"),this.#Y.setAttribute("slot","end"),this.#w()}#w(){if(this.firstElementChild!==this.#K)this.prepend(this.#K);if(this.lastElementChild!==this.#Y)this.append(this.#Y)}#p(){this.#K?.remove(),this.#Y?.remove(),this.#K=null,this.#Y=null,this.classList.remove("overflow-start","overflow-end")}#y(_){Z0(this.#Q,this.#W?"y":"x",_)}#b(_=this.selectedItem,Z="smooth"){if(_)this.#v(_,Z)}#v(_,Z="smooth"){if(!_||this.#O(_)!=="viewport")return;requestAnimationFrame(()=>{if(!this.isConnected||!_.isConnected)return;let $=this.#W;if(!($?this.#Q.scrollHeight>this.#Q.clientHeight:this.#Q.scrollWidth>this.#Q.clientWidth))return;let Q=this.#Q.getBoundingClientRect(),j=_.getBoundingClientRect();if($){let q=j.top-Q.top+this.#Q.scrollTop+j.height/2;this.#Q.scrollTo({top:q-this.#Q.clientHeight/2,behavior:Z})}else{let q=j.left-Q.left+this.#Q.scrollLeft+j.width/2;this.#Q.scrollTo({left:q-this.#Q.clientWidth/2,behavior:Z})}this.#E()})}}F("fig-toolbelt",G_);class K_ extends HTMLElement{#Z;#_;#J;constructor(){super();this.#J=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#$(),this.addEventListener("click",this.#J)}disconnectedCallback(){this.removeEventListener("click",this.#J)}handleClick(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let _=this.closest("fig-segmented-control");if(_&&_.hasAttribute("disabled")&&_.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#Z}set value(_){this.#Z=_,this.setAttribute("value",_)}get selected(){return this.#_}set selected(_){this.#_=_,this.setAttribute("selected",_)}static get observedAttributes(){return["selected","value","disabled"]}#$(){let _=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",_?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",_?"0":"-1")}attributeChangedCallback(_,Z,$){switch(_){case"value":this.#Z=$;break;case"selected":this.#_=$,this.#$();break;case"disabled":this.#$();break}}}F("fig-segment",K_);class X_ extends HTMLElement{#Z=null;#_=this.handleClick.bind(this);#J=this.#B.bind(this);#$=null;#Q=null;#j=0;#G=!1;#N=!1;#q=new WeakSet;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){if(this.name=this.getAttribute("name")||"segmented-control",!this.hasAttribute("role"))this.setAttribute("role","radiogroup");this.addEventListener("click",this.#_),this.addEventListener("keydown",this.#J),this.#F(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#z(),this.#I(),u(this,()=>{this.#H({enforceFallback:!0}),this.#D(),this.#L({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#_),this.removeEventListener("keydown",this.#J),this.#$?.disconnect(),this.#$=null,this.#Q?.disconnect(),this.#Q=null,this.#j)cancelAnimationFrame(this.#j),this.#j=0;this.#G=!1,this.#N=!1}get selectedSegment(){return this.#Z}set selectedSegment(_){let Z=this.querySelectorAll("fig-segment");for(let $ of Z){let J=$===_,Q=T($,"selected");if(J&&!Q)$.setAttribute("selected","true");else if(!J&&Q)$.removeAttribute("selected")}this.#Z=_ instanceof HTMLElement&&this.contains(_)?_:null,this.#U(),this.#L()}get value(){return this.getAttribute("value")||""}set value(_){if(_===null||_===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(_))}#X(_){this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#K(_){let Z=_.getAttribute("value");if(Z!==null){let $=Z.trim();if($.length>0)return $}return _.textContent?.trim()||""}#Y(){let _=this.querySelectorAll("fig-segment");for(let Z of _)if(Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false")return Z;return null}#R(){return Array.from(this.querySelectorAll("fig-segment")).filter((_)=>!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false")}#U(){let _=Array.from(this.querySelectorAll("fig-segment")),Z=_.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false");_.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false",Q=$===Z;$.setAttribute("aria-checked",Q?"true":"false"),$.setAttribute("tabindex",!J&&Q?"0":"-1")})}#W(_){if(!_)return;let Z=this.selectedSegment,$=this.value;this.selectedSegment=_;let J=this.#K(_);if(J)this.setAttribute("value",J);else this.removeAttribute("value");let Q=this.value;if(Z!==_||$!==Q)this.#X(Q)}#B(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#R();if(!Z.length)return;let $=Z.findIndex((j)=>T(j,"selected")),J=$>=0?$:0;switch(_.key){case"ArrowLeft":case"ArrowUp":_.preventDefault(),J=J>0?J-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":_.preventDefault(),J=J<Z.length-1?J+1:0;break;case"Home":_.preventDefault(),J=0;break;case"End":_.preventDefault(),J=Z.length-1;break;case" ":case"Enter":{let j=_.target.closest("fig-segment");if(j&&this.contains(j))_.preventDefault(),this.#W(j);return}default:return}let Q=Z[J];this.#W(Q),Q.focus(),requestAnimationFrame(()=>{if(this.contains(Q))Q.focus()})}#M(_){let Z=String(_??"").trim();if(!Z)return!1;let $=this.querySelectorAll("fig-segment");for(let J of $){let Q=this.#K(J);if(!Q)continue;if(Q===Z)return this.selectedSegment=J,!0}return!1}#O(){let _=this.getAttribute("animated");if(_===null)return!1;if(_==="")return!0;return _.trim().toLowerCase()==="true"}#L({forceInstant:_=!1}={}){if(this.#G=this.#G||_,this.#j)return;this.#j=requestAnimationFrame(()=>{this.#j=0;let Z=this.#G;this.#G=!1,this.#A({forceInstant:Z})})}#A({forceInstant:_=!1}={}){let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#O(),J=this.#Z&&this.contains(this.#Z)?this.#Z:this.#Y();if(Z||!$){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!$||Z)this.#N=!1;return}if(!J){if(this.#N)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let Q=this.getBoundingClientRect(),j=J.getBoundingClientRect();if(Q.width<=0||j.width<=0){if(this.#N)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let q=Math.max(0,j.left-Q.left);this.style.setProperty("--seg-indicator-x",`${q}px`),this.style.setProperty("--seg-indicator-w",`${j.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#N||_?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#N=!0}#I(){this.#Q?.disconnect(),this.#Q=new ResizeObserver(()=>{this.#L()}),this.#D()}#D(){if(!this.#Q)return;this.#Q.disconnect(),this.#Q.observe(this),this.querySelectorAll("fig-segment").forEach((_)=>{this.#Q?.observe(_)})}#H({enforceFallback:_=!1}={}){if(this.querySelectorAll("fig-segment").length===0){this.#Z=null,this.#L({forceInstant:!0});return}let $=this.getAttribute("value"),J=$?.trim()??"";if($!==null){if(J!==$){this.setAttribute("value",J);return}if(J&&this.#M(J))return}let Q=this.#Y();if(Q){this.selectedSegment=Q;return}if(_)this.selectedSegment=this.#R()[0]||null}#z(){this.#$?.disconnect(),this.#$=new MutationObserver((_)=>{let Z=!1;for(let $ of _){if($.type==="childList"){Z=!0;break}if($.type==="attributes"&&$.target instanceof HTMLElement&&$.target.tagName.toLowerCase()==="fig-segment"&&($.attributeName==="value"||$.attributeName==="selected")){Z=!0;break}if($.type==="characterData"){Z=!0;break}}if(Z)this.#F(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#D(),this.#H({enforceFallback:!0}),this.#U()}),this.#$.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=_.target.closest("fig-segment");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#W(Z)}#F(_){this.setAttribute("aria-disabled",_?"true":"false"),this.querySelectorAll("fig-segment").forEach((Z)=>{if(_){if(!(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false"))this.#q.add(Z),Z.setAttribute("disabled","");Z.setAttribute("aria-disabled","true")}else if(this.#q.has(Z))this.#q.delete(Z),Z.removeAttribute("disabled"),Z.removeAttribute("aria-disabled")}),this.#U()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="disabled"){this.#F($!==null&&$!=="false"),this.#L({forceInstant:!0});return}if(_==="value"){this.#H({enforceFallback:!1});return}if(_==="animated"){if(!this.#O())this.#N=!1;this.#L({forceInstant:!0});return}if(_==="sizing")this.#L({forceInstant:!0})}}F("fig-segmented-control",X_);class Y_ extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Z="segments";#_=0;#J=null;#$=[];#Q=null;#j=!1;#G(_){let Z=_?.detail;if(typeof Z==="string")return Z;let $=_?.currentTarget?.value??_?.target?.value??this.getAttribute("value");if($===null||$===void 0)return null;return String($)}#N(){if(this.#$.length===0)return!1;let _=this.querySelector(":scope > fig-segmented-control");if(_){let $=_.querySelectorAll("fig-segment");if($.length!==this.#$.length)return!1;return Array.from($).every((J,Q)=>J.getAttribute("value")===this.#$[Q])}let Z=this.querySelector(":scope > fig-dropdown");if(Z){let $=Z.querySelectorAll("option");return $.length===this.#$.length&&Array.from($).every((J,Q)=>J.textContent?.trim()===this.#$[Q])}return!1}#q(){let _=this.querySelector(":scope > fig-segmented-control");if(_)this.#Q=_,this.#Z="segments";else this.#Q=this.querySelector(":scope > fig-dropdown"),this.#Z="dropdown";this.#U()}connectedCallback(){if(this.#X(),this.#N()){this.#q(),this.#B(),u(this,()=>u(this,()=>this.#L()));return}this.#K(),this.#B(),u(this,()=>u(this,()=>this.#L()))}disconnectedCallback(){this.#J?.disconnect(),this.#J=null}get value(){return this.getAttribute("value")||""}set value(_){if(_===null||_===void 0)this.removeAttribute("value");else this.setAttribute("value",String(_))}get options(){return this.#$.slice()}set options(_){if(Array.isArray(_)){let $=_.some((J)=>String(J).includes(","))?JSON.stringify(_):_.join(",");this.setAttribute("options",$)}else this.setAttribute("options",String(_||""))}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="options"){this.#X(),this.#R();return}if(_==="value"){this.#U();return}if(_==="disabled"){this.#W("disabled");return}if(_==="full"){this.#W("full");return}if(_==="sizing")this.#W("sizing"),this.#R()}#X(){let _=this.getAttribute("options")||"";if(_.startsWith("["))try{this.#$=JSON.parse(_);return}catch{}let Z=_.includes(`
172
+ `;let J=document.createElement("slot");J.name="prepend";let Q=document.createElement("slot"),j=document.createElement("slot");j.name="append";let q=M(Z,{className:"fig-button-control",type:_?null:"button"},[J,Q,j]);this.shadowRoot.replaceChildren($,q),this.button=q,this.button.addEventListener("click",this.#Q),this.button.addEventListener("focus",this.#G),this.button.addEventListener("blur",this.#q)}this.shadowRoot.querySelectorAll("slot").forEach((_)=>{_.removeEventListener("slotchange",this.#j),_.addEventListener("slotchange",this.#j)}),this.removeEventListener("keydown",this.#$),this.addEventListener("keydown",this.#$),this.#Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#M(),this.#W()}get type(){return this.getAttribute("type")||"button"}set type(_){this.setAttribute("type",_)}get selected(){return this.#Z}set selected(_){this.setAttribute("selected",_)}#N(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#X(){if(this.#N())return;if(this.type==="toggle")if(this.selected)this.removeAttribute("selected");else this.setAttribute("selected","");if(this.type==="submit"){let _=this.closest("form");if(_)if(typeof _.requestSubmit==="function")_.requestSubmit();else _.submit()}if(this.type==="link"){let _=this.getAttribute("href"),Z=this.getAttribute("target");if(_)if(Z)window.open(_,Z);else window.location.href=_}}#K(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#Y(){let _=this.#K();if(_ instanceof HTMLSelectElement)return _;if(_?.tagName==="FIG-DROPDOWN")return _.select||_.querySelector?.("select")||null;return null}#R(_){if(this.type!=="select")return;if(_.key!=="Enter")return;if(_.altKey||_.ctrlKey||_.metaKey||_.shiftKey)return;let Z=this.#Y();if(!Z||Z.disabled||Z.multiple)return;if(typeof Z.showPicker!=="function")return;_.preventDefault();try{Z.showPicker()}catch{}}#U(){if(!this.button)return;if(this.type!=="toggle"){this.removeAttribute("aria-pressed"),this.button.removeAttribute("aria-pressed");return}let _=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.setAttribute("aria-pressed",_?"true":"false"),this.button.setAttribute("aria-pressed",_?"true":"false")}#W(){let Z=Array.from(this.querySelectorAll(':scope > fig-icon[slot="append"][data-generated="select-chevron"]')),$=Z[0];if(Z.slice(1).forEach((j)=>j.remove()),this.type!=="select"){$?.remove();return}if(this.querySelector(':scope > [slot="append"]:not([data-generated])')){$?.remove();return}if($)return;let Q=b("chevron",{size:"small"});Q.setAttribute("slot","append"),Q.setAttribute("data-generated","select-chevron"),this.append(Q)}#O(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#J.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.button.removeAttribute(_);else this.button.setAttribute(_,Z)})}#M(){if(!this.button)return;let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=_,this.button instanceof HTMLButtonElement)this.button.disabled=_,this.button.type="button",this.button.setAttribute("type","button");this.#B(),this.#O(),this.#U()}#B(){let _=this.#K();if(!_)return;if(this.#N()){if(!this.#_.has(_))this.#_.set(_,_.hasAttribute("disabled")&&_.getAttribute("disabled")!=="false");_.setAttribute("disabled","")}else if(this.#_.has(_)){let $=this.#_.get(_);if(this.#_.delete(_),$)_.setAttribute("disabled","");else _.removeAttribute("disabled")}}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","aria-haspopup","aria-expanded","aria-controls","title"]}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"type":{let J=(Q)=>Q==="select"||Q==="upload";if(J(Z||"button")!==J($||"button")){this.button=null,this.connectedCallback();break}this.#M(),this.#W();break}case"disabled":this.#M();break;case"selected":this.#Z=$!==null&&$!=="false",this.#U();break;default:this.#O();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#$),this.shadowRoot?.querySelectorAll("slot").forEach((_)=>{_.removeEventListener("slotchange",this.#j)})}}F("fig-button",n0);class e0 extends HTMLElement{#Z="Menu";#_=null;#J;#$;#Q;#j;#G;#q=null;#N=!1;#X=!1;#K=!1;#Y=0;get label(){return this.#Z}set label(_){this.#Z=_}#R;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#J=this.#I.bind(this),this.#$=this.#D.bind(this),this.#Q=this.#H.bind(this),this.#j=this.#B.bind(this),this.#G=this.#O.bind(this),this.#R=this.slotChange.bind(this)}#U(){this.select.addEventListener("input",this.#J),this.select.addEventListener("change",this.#$),this.select.addEventListener("keydown",this.#Q),this.select.addEventListener("pointerdown",this.#j),this.select.addEventListener("blur",this.#G)}#W(){let _=this.closest('fig-button[type="select"]');if(this.#K&&this.#q!==_)this.#O();if(!this.#K)this.#X=this.select.hasAttribute("selected")&&this.select.getAttribute("selected")!=="false",this.#K=!0;if(this.select.setAttribute("selected",""),!_)return;if(this.#q!==_)this.#q=_,this.#N=_.hasAttribute("selected")&&_.getAttribute("selected")!=="false";_.setAttribute("selected","")}#O(){if(this.#Y)cancelAnimationFrame(this.#Y),this.#Y=0;if(this.#q&&!this.#N)this.#q.removeAttribute("selected");if(this.#K&&!this.#X)this.select.removeAttribute("selected");this.#q=null,this.#N=!1,this.#X=!1,this.#K=!1}#M(){if(this.#Y)cancelAnimationFrame(this.#Y);let _=0,Z=!1,$=()=>{if(this.#Y=0,!this.isConnected){this.#O();return}let J=!1;try{J=this.select.matches(":open")}catch{return}if(J)Z=!0;if(Z&&!J){this.#O();return}if(_+=1,Z||_<4)this.#Y=requestAnimationFrame($);else this.#O()};this.#Y=requestAnimationFrame($)}#B(_){if(_.button!==0||this.select.disabled)return;this.#W(),this.#M()}#L(_){if(!_||!(_ instanceof Element))return!1;return!!_.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#A(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){if(this.type=this.getAttribute("type")||"select",this.#Z=this.getAttribute("label")||this.#Z,this.select.setAttribute("aria-label",this.#Z),this.#z(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#R),this.optionsSlot.addEventListener("slotchange",this.#R),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#Q),this.#U()}slotChange(){let _=this.hasAttribute("value"),Z=this.select.options.length>0&&this.select.selectedIndex>=0,$=_?this.getAttribute("value"):this.type==="dropdown"?this.#_:Z?this.select.value:null;while(this.select.firstChild)this.select.firstChild.remove();if(this.type==="dropdown"){let J=document.createElement("option");J.setAttribute("hidden","true"),J.setAttribute("selected","true"),J.selected=!0,this.select.appendChild(J)}if(this.optionsSlot.assignedNodes().forEach((J)=>{if(J.nodeName==="OPTION"||J.nodeName==="OPTGROUP")this.select.appendChild(J.cloneNode(!0))}),$!==null)this.#F($);if(this.type==="dropdown")this.select.selectedIndex=-1}#I(_){_.stopPropagation();let Z=_.target.selectedOptions?.[0];if(this.#L(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#A();return}let $=_.target.value;if(this.type==="dropdown")this.#_=$;this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}#D(_){_.stopPropagation();let Z=_.target.selectedOptions?.[0];if(this.#L(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#A();return}this.#O();let $=this.type==="dropdown"?this.#_:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,composed:!0}))}#H(_){if(_.key!=="Enter"||_.defaultPrevented)return;if(_.altKey||_.ctrlKey||_.metaKey||_.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(this.#W(),this.#M(),this.closest('fig-button[type="select"]'))return;if(typeof this.select.showPicker!=="function")return;_.preventDefault();try{this.select.showPicker()}catch{this.#O()}}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#_;return this.select?.value}set value(_){if(this.type==="dropdown")this.#_=_;this.setAttribute("value",_)}static get observedAttributes(){return["value","type","label","disabled","variant","size"]}#z(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=_}#F(_){if(this.type==="dropdown")return;if(this.select)this.select.value=_??""}attributeChangedCallback(_,Z,$){if(_==="value")this.#F($);if(_==="type"){if(this.type=$||"select",this.isConnected)this.slotChange()}if(_==="label")this.#Z=$||"Menu",this.select.setAttribute("aria-label",this.#Z);if(_==="disabled")this.#z()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#R),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#Q),this.select.removeEventListener("pointerdown",this.#j),this.select.removeEventListener("blur",this.#G),this.#O()}}F("fig-dropdown",e0);class k extends HTMLElement{static#Z=0;static#_=0;static#J=1000;static#$=null;static#Q=!1;static#j=new Set;#G;#q;#N;#X;#K;#Y;#R;#U;#W;#O;#M;#B;#L=null;#A=null;#I=null;#D=!1;#H;#z=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let _=parseInt(this.getAttribute("delay"));this.delay=!isNaN(_)?_:500,this.#G=this.#y.bind(this),this.#q=this.hidePopupOutsideClick.bind(this),this.#N=this.showDelayedPopup.bind(this),this.#X=this.#h.bind(this),this.#K=()=>{if(!this.#D)this.showDelayedPopup()},this.#Y=()=>{this.#D=!1,this.hidePopup()},this.#R=this.#E.bind(this),this.#U=this.#f.bind(this),this.#W=this.#x.bind(this),this.#O=this.#g.bind(this),this.#B=this.#w.bind(this),this.#M=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(k.#b(),this.setup(),this.#S(),this.setupEventListeners(),this.#L=this.closest("dialog"),this.#L)this.#L.addEventListener("close",this.#M)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#P(),this.#T(),document.removeEventListener("mousedown",this.#G,!0),document.removeEventListener("keydown",this.#B,!0),this.#L)this.#L.removeEventListener("close",this.#M),this.#L=null;if(this.action==="click")document.body.removeEventListener("click",this.#q);if(clearTimeout(this.#H),k.#$===this)k.#$=null}#F(){return this.firstElementChild}#T(){this.#I?.disconnect(),this.#I=null}#S(){if(this.#P(),this.action==="manual")return;let _=this.#F();if(!_){if(!this.#I&&typeof MutationObserver<"u")this.#I=new MutationObserver(()=>{if(this.#F())this.#T(),this.#S()}),this.#I.observe(this,{childList:!0});return}if(this.#A=_,this.action==="hover"){if(!this.isTouchDevice())_.addEventListener("pointerenter",this.#N),_.addEventListener("pointerleave",this.#X);_.addEventListener("touchstart",this.#R,{passive:!0}),_.addEventListener("touchmove",this.#U,{passive:!0}),_.addEventListener("touchend",this.#W,{passive:!0}),_.addEventListener("touchcancel",this.#O,{passive:!0}),_.addEventListener("focus",this.#K),_.addEventListener("blur",this.#Y)}else if(this.action==="click")_.addEventListener("click",this.#N),_.addEventListener("touchstart",this.#N,{passive:!0})}#P(){let _=this.#A;if(!_)return;if(this.action==="hover")_.removeEventListener("pointerenter",this.#N),_.removeEventListener("pointerleave",this.#X),_.removeEventListener("touchstart",this.#R),_.removeEventListener("touchmove",this.#U),_.removeEventListener("touchend",this.#W),_.removeEventListener("touchcancel",this.#O),_.removeEventListener("focus",this.#K),_.removeEventListener("blur",this.#Y);else if(this.action==="click")_.removeEventListener("click",this.#N),_.removeEventListener("touchstart",this.#N);this.#A=null}setup(){this.style.display="contents"}render(){this.destroy();let _=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Z=document.createElement("span");if(this.popup=document.createElement("dialog",{is:"fig-popup"}),this.popup.setAttribute("is","fig-popup"),this.popup.setAttribute("variant","tooltip"),this.popup.setAttribute("data-tooltip-managed",""),this.popup.setAttribute("role","tooltip"),this.popup.setAttribute("closedby","closerequest"),_)this.popup.setAttribute("popover","manual");let $=g();this.popup.setAttribute("id",$);let J=this.getAttribute("theme");if(J)this.popup.setAttribute("theme",J);let Q=this.getAttribute("pointer");if(Q!==null)this.popup.setAttribute("pointer",Q);if(this.popup.append(Z),Z.innerText=this.getAttribute("text")??"",this.firstElementChild){let j=new Set((this.firstElementChild.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));j.add($),this.firstElementChild.setAttribute("aria-describedby",[...j].join(" "))}if(_)(l()??document.body).append(this.popup);else{let j=this.closest("dialog");if(j&&j.open)j.append(this.popup);else(l()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.#V(this.popup.id),this.popup.hidePopup?.(),this.popup.remove(),this.popup=null}#V(_){let Z=this.firstElementChild;if(!Z||!_)return;let $=Z.getAttribute("aria-describedby");if(!$)return;let J=$.split(/\s+/).filter((Q)=>Q&&Q!==_).join(" ");if(J)Z.setAttribute("aria-describedby",J);else Z.removeAttribute("aria-describedby")}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#q);document.addEventListener("mousedown",this.#G,!0),document.addEventListener("keydown",this.#B,!0)}get#k(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#C(){let _=Date.now(),Z=k.#J;if(this.action==="hover"&&k.#$)return!0;if(k.#Z&&_-k.#Z<Z)return!0;if(k.#_&&_-k.#_<Z)return!0;return!1}showDelayedPopup(_){if(this.#k)return;if(clearTimeout(this.timeout),_?.type==="pointerenter"){let Z=this.#A;if(Z?.matches?.("fig-select[open]")||Z?.querySelector?.("fig-select[open]"))return}if(this.#C()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#L&&!this.#L.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&k.#$&&k.#$!==this)k.#$.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")k.#$=this;k.#Z=Date.now()}hidePopup(){if(this.#k)return;clearTimeout(this.timeout),clearTimeout(this.#H);let _=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,k.#$===this)k.#$=null;if(_)k.#_=Date.now()}hidePopupOutsideClick(_){if(this.isOpen&&!this.popup.contains(_.target))this.hidePopup()}#h(_){if(!this.#z)this.hidePopup()}#E(_){if(this.action==="hover")this.#z=!0,clearTimeout(this.#H),this.showDelayedPopup()}#f(_){if(this.action==="hover"&&this.#z)clearTimeout(this.#H),this.#H=setTimeout(()=>{this.#z=!1,this.hidePopup()},150)}#x(_){if(this.action==="hover"&&this.#z)clearTimeout(this.#H),this.#H=setTimeout(()=>{this.#z=!1,this.hidePopup()},300)}#g(_){if(this.action==="hover"&&this.#z)this.#z=!1,clearTimeout(this.#H),this.hidePopup()}#w(_){if(!this.isOpen&&!this.popup||_.key!=="Escape")return;_.preventDefault(),this.hidePopup(),this.firstElementChild?.focus?.()}static get observedAttributes(){return["action","delay","open","pointer","show","text","theme"]}get text(){return this.getAttribute("text")??""}set text(_){this.setAttribute("text",_)}#p(_){if(!this.popup)return;let Z=this.popup.firstElementChild??this.popup.firstChild;if(!Z)return;Z.innerText=_}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){if(_===!1||_==="false"||_===null)this.removeAttribute("open");else this.setAttribute("open","true")}attributeChangedCallback(_,Z,$){if(_==="action"){if(this.#P(),Z==="click")document.body?.removeEventListener("click",this.#q);if(this.action=$||"hover",this.isConnected){if(this.#S(),this.action==="click")document.body?.addEventListener("click",this.#q)}}if(_==="delay"){let J=parseInt($);this.delay=!isNaN(J)?J:500}if(_==="open")if($!==null&&$!=="false")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(_==="show")if($!==null&&$!=="false")this.showPopup();else this.hidePopup();if(_==="text")this.#p($??"");if(_==="pointer"){if(this.popup)if($!==null)this.popup.setAttribute("pointer",$);else this.popup.removeAttribute("pointer")}if(_==="theme"){if(this.popup)if($)this.popup.setAttribute("theme",$);else this.popup.removeAttribute("theme")}}#y(_){if(!this.isOpen)return;let Z=_.target;if(this.popup&&this.popup.contains(Z))return;if(Z.tagName==="SELECT"||Z.hasAttribute("popover")||Z.closest("dialog"))this.hidePopup()}static#b(){if(k.#Q)return;k.#Q=!0;let _=()=>{k.dismissHoverTooltips()},Z=()=>{k.#u()};document.documentElement.addEventListener("mouseleave",_),document.addEventListener("mouseout",($)=>{if($.relatedTarget)return;_()}),document.addEventListener("scroll",Z,{capture:!0,passive:!0}),window.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("resize",Z,{passive:!0});try{let $=window.frameElement;if($)$.addEventListener("mouseleave",_)}catch{}window.addEventListener("message",($)=>{if($?.data?.type!=="figui:dismiss-tooltips")return;if(window.parent!==window&&$.source!==window.parent)return;_()})}static dismissHoverTooltips(){for(let _ of document.querySelectorAll("fig-tooltip")){if(!(_ instanceof k))continue;if(_.action!=="hover")continue;if(_.#k)continue;if(_.#D=!0,setTimeout(()=>{let Z=_.#A;if(Z!==document.activeElement&&!Z?.matches?.(":focus, :focus-within"))_.#D=!1},0),_.isOpen||_.timeout)_.hidePopup()}for(let _ of Array.from(k.#j))k.hide(_)}static#v=new WeakMap;static#u(){for(let _ of document.querySelectorAll("fig-tooltip")){if(!(_ instanceof k))continue;if(_.#k)continue;if(_.isOpen||_.timeout)_.hidePopup()}for(let _ of Array.from(k.#j))k.hide(_)}static show(_,Z,$={}){k.#b(),k.hide(_);let J=$.delay??500,j=Date.now()-k.#Z<k.#J?0:J,q={timeout:null,popup:null};k.#v.set(_,q),k.#j.add(_),q.timeout=setTimeout(()=>{let N=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,G=document.createElement("dialog",{is:"fig-popup"});if(G.setAttribute("is","fig-popup"),G.setAttribute("variant","tooltip"),G.setAttribute("data-tooltip-managed",""),G.setAttribute("role","tooltip"),G.setAttribute("closedby","closerequest"),N)G.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=Z,G.append(K),N)(l()??document.body).append(G);else{let X=_.closest?.("dialog");if(X&&X.open)X.append(G);else(l()??document.body).append(G)}G.anchor=_,G.open=!0,q.popup=G,k.#Z=Date.now()},j)}static hide(_){let Z=k.#v.get(_);if(!Z)return;if(clearTimeout(Z.timeout),Z.popup)Z.popup.remove(),k.#_=Date.now();k.#v.delete(_),k.#j.delete(_)}}F("fig-tooltip",k);class __ extends HTMLElement{static observedAttributes=["position","tail","tooltip"];#Z=null;#_=null;#J=null;#$=null;connectedCallback(){this.#Z=this.textContent,this.#$??=new MutationObserver(()=>{this.#Z=this.textContent,this.#j()}),this.#Q(),u(this,()=>{this.#j(),this.#X(),this.#q()})}disconnectedCallback(){this.#$?.disconnect(),this.#X()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#Z===null)return;if(_==="tooltip"){if(this.#X(),this.isConnected)this.#q();return}this.#j()}#Q(){this.#$?.observe(this,{childList:!0,characterData:!0,subtree:!0})}#j(){if(this.#$?.disconnect(),this.#G(),this.isConnected)this.#Q()}#G(){let _=this.getAttribute("position")||"right",Z=this.#Z||"";if(_==="middle"){let $=this.getAttribute("tail"),J;if($){let q=Z.lastIndexOf($);J=q>0?q:Math.ceil(Z.length/2)}else J=Math.ceil(Z.length/2);this.replaceChildren();let Q=document.createElement("span");Q.className="start",Q.textContent=Z.slice(0,J);let j=document.createElement("span");j.className="end",j.textContent=Z.slice(J),this.appendChild(Q),this.appendChild(j)}else this.textContent=Z}#q(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#_=()=>{if(!this.#N())return;k.show(this,this.#Z)},this.#J=()=>{k.hide(this)},this.addEventListener("pointerenter",this.#_),this.addEventListener("pointerleave",this.#J)}#N(){let _=(Z)=>Z.scrollWidth>Z.clientWidth;if(_(this))return!0;return[...this.querySelectorAll(":scope > .start, :scope > .end")].some(_)}#X(){if(this.#_)this.removeEventListener("pointerenter",this.#_);if(this.#J)this.removeEventListener("pointerleave",this.#J);this.#_=null,this.#J=null,k.hide(this)}}F("fig-truncate",__);function Z_(_){if(_.querySelector("fig-header[dialog-header]"))return;let Z=document.createElement("fig-header");Z.setAttribute("dialog-header",""),Z.setAttribute("data-auto","");let $=document.createElement("h3");$.textContent=_.getAttribute("title")||"Dialog";let J=document.createElement("fig-tooltip");J.setAttribute("text","Close");let Q=document.createElement("fig-button");Q.setAttribute("variant","ghost"),Q.setAttribute("icon",""),Q.setAttribute("aria-label","Close dialog"),Q.setAttribute("close-dialog",""),Q.appendChild(b("close")),J.appendChild(Q),Z.appendChild($),Z.appendChild(J),_.prepend(Z)}class $_ extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._isDragging=!1,this._dragPending=!1,this._dragStartPos={x:0,y:0},this._dragOffset={x:0,y:0},this._resizeObserver=null,this._mutationObserver=null,this._autoResizeRafId=0,this._offset=16,this._positionInitialized=!1,this._dragThreshold=3,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundClose=this.close.bind(this),this._boundIframeMessage=this._handleIframeMessage.bind(this),this._boundContentMutation=this._scheduleAutoResize.bind(this),this._boundContentResize=this._scheduleAutoResize.bind(this),this._boundRestoreFocus=this._restoreFocus.bind(this),this._boundIframeMouseLeave=this._handleIframeMouseLeave.bind(this),this._iframeDismissMutationObserver=null,this._previousFocus=null}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){if(this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),this.open&&!this.matches?.(":modal"))this._assignStackingOrder();u(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._setupIframeDismissListeners(),this._syncA11y()}),window.addEventListener("message",this._boundIframeMessage)}disconnectedCallback(){this._figInit(),this._removeDragListeners(),this.querySelectorAll("fig-button[close-dialog]").forEach((_)=>{_.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize(),this._teardownIframeDismissListeners(),this.removeEventListener("close",this._boundRestoreFocus)}_captureFocusBeforeOpen(){let _=document.activeElement;this._previousFocus=_ instanceof HTMLElement&&_!==document.body&&!this.contains(_)?_:null}_restoreFocus(){let _=this._previousFocus;if(this._previousFocus=null,!_?.isConnected)return;let Z=document.activeElement;if(Z&&Z!==document.body&&!this.contains(Z))return;requestAnimationFrame(()=>_.focus?.())}_assignStackingOrder(){this.style.zIndex=String(t0()+1)}_clearStackingOrder(){this.style.zIndex=""}show(){return this._captureFocusBeforeOpen(),this._assignStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),k.dismissHoverTooltips(),super.show()}showModal(){return this._captureFocusBeforeOpen(),this._clearStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),k.dismissHoverTooltips(),super.showModal()}close(..._){let Z=super.close(..._);return this._clearStackingOrder(),Z}_handleIframeMouseLeave(_){let Z=_?.currentTarget;if(!(Z instanceof HTMLIFrameElement))return;try{Z.contentWindow?.postMessage({type:"figui:dismiss-tooltips"},"*")}catch{}}_syncIframeDismissListeners(){for(let _ of this.querySelectorAll(":scope > iframe")){if(!(_ instanceof HTMLIFrameElement))continue;if(_.dataset.figuiDismissBound==="true")continue;_.dataset.figuiDismissBound="true",_.addEventListener("mouseleave",this._boundIframeMouseLeave)}}_setupIframeDismissListeners(){if(this._syncIframeDismissListeners(),this._iframeDismissMutationObserver)return;this._iframeDismissMutationObserver=new MutationObserver(()=>{this._syncIframeDismissListeners()}),this._iframeDismissMutationObserver.observe(this,{childList:!0,subtree:!1})}_teardownIframeDismissListeners(){this._iframeDismissMutationObserver?.disconnect(),this._iframeDismissMutationObserver=null;for(let _ of this.querySelectorAll(":scope > iframe"))_.removeEventListener("mouseleave",this._boundIframeMouseLeave),delete _.dataset.figuiDismissBound}_handleIframeMessage(_){if(!this.autoresize)return;let Z=_?.data;if(!Z||Z.type!=="figui:iframe-resize")return;let $=_.source;if(!$)return;let J=Array.from(this.querySelectorAll("iframe")).find((Q)=>Q.contentWindow===$);if(!J)return;this._resizeForIframe(J,Z)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let _ of this.children)try{this._resizeObserver.observe(_)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((_)=>{for(let Z of _)Z.addedNodes?.forEach(($)=>{if($ instanceof Element&&$.parentElement===this)try{this._resizeObserver?.observe($)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(_){let Z=window.getComputedStyle(this),$=parseFloat(Z.paddingTop||"0")+parseFloat(Z.paddingBottom||"0")+parseFloat(Z.borderTopWidth||"0")+parseFloat(Z.borderBottomWidth||"0"),J=0,Q=parseFloat(Z.rowGap||Z.gap||"0")||0,j=0;for(let q of this.children){let N=q.getBoundingClientRect();if(N.height===0)continue;if(j+=1,q===_)continue;let G=window.getComputedStyle(q),K=parseFloat(G.marginTop||"0")+parseFloat(G.marginBottom||"0");J+=N.height+K}if(Q&&j>1)J+=Q*(j-1);return $+J}_resizeForIframe(_,Z){if(typeof Z.height!=="number"||!(Z.height>0))return;let $=this._computeChrome(_);this.style.height=`${Math.ceil(Z.height+$)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){Z_(this)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((_)=>{if(!_.hasAttribute("aria-label"))_.setAttribute("aria-label","Close dialog");_.removeEventListener("click",this._boundClose),_.addEventListener("click",this._boundClose)})}_syncA11y(){if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let _=this.querySelector("fig-header[dialog-header] h1, fig-header[dialog-header] h2, fig-header[dialog-header] h3, fig-header[dialog-header] h4, fig-header[dialog-header] h5, fig-header[dialog-header] h6");if(_){let Z=_.getAttribute("id")||g();_.setAttribute("id",Z),this.setAttribute("aria-labelledby",Z)}}}_applyPosition(){let _=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let Z=_.includes("top"),$=_.includes("bottom"),J=_.includes("left"),Q=_.includes("right"),j=_.includes("center")&&!Z&&!$,q=_.includes("center")&&!J&&!Q;if(Z)this.style.top=`${this._offset}px`;else if($)this.style.bottom=`${this._offset}px`;else if(j)this.style.top="0",this.style.bottom="0";if(J)this.style.left=`${this._offset}px`;else if(Q)this.style.right=`${this._offset}px`;else if(q)this.style.left="0",this.style.right="0";if(j&&q)this.style.margin="auto";else if(j)this.style.marginTop="auto",this.style.marginBottom="auto";else if(q)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let _=this.getAttribute("handle"),Z=_?this.querySelector(_):this.querySelector("fig-header, header");if(Z)Z.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}_isInteractiveElement(_){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(j)=>Z.some((q)=>j.matches?.(q))||j.tagName?.startsWith("FIG-")&&!$.includes(j.tagName);if(J(_))return!0;let Q=_.parentElement;while(Q&&Q!==this){if(J(Q))return!0;Q=Q.parentElement}return!1}_handlePointerDown(_){if(!this.drag)return;if(this._isInteractiveElement(_.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(_.target))return}this._dragPending=!0,this._dragStartPos.x=_.clientX,this._dragStartPos.y=_.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=_.clientX-$.left,this._dragOffset.y=_.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}_handlePointerMove(_){if(this._dragPending&&!this._isDragging){let Z=Math.abs(_.clientX-this._dragStartPos.x),$=Math.abs(_.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(_.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${_.clientX-this._dragOffset.x}px`,this.style.top=`${_.clientY-this._dragOffset.y}px`,_.preventDefault()}_handlePointerUp(_){if(this._isDragging){if(this.hasPointerCapture?.(_.pointerId))this.releasePointerCapture(_.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),_.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(_,Z,$){if(this._figInit(),_==="autoresize"&&this.isConnected)this._syncAutoResize();if(_==="drag")if(this.drag=$!==null&&$!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let J=this.querySelector("fig-header, header");if(J)J.style.cursor=""}if(_==="position"&&this._positionInitialized)this._applyPosition();if(_==="modal"){let J=this.modal;if(this.modal=$!==null&&$!=="false",this.open&&J!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(_==="closedby")this.closedby=$||"any";if(_==="title"){let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";this._syncA11y()}if(_==="aria-label"||_==="aria-labelledby")this._syncA11y()}}k0("fig-dialog",$_,{extends:"dialog"});class J_ extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._toastVisible=!1,this._syncingOpen=!1,this._managedRole=null,this._managedLive=null,this._managedIcon=null,this._managedDismiss=null,this._managedDismissSeparator=null,this._boundHandleClose=this.handleClose.bind(this)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.syncIcon(),this.syncDismiss(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast();else{if(this.getAttribute("open")==="false")this._syncingOpen=!0,this.removeAttribute("open"),this._syncingOpen=!1;this._toastVisible=!1}}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((_)=>{if(!_.hasAttribute("aria-label"))_.setAttribute("aria-label","Close notification");_.removeEventListener("click",this._boundHandleClose),_.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto";let _=Number.parseFloat(this.getAttribute("offset")),Z=Number.isFinite(_)?_:this._defaultOffset;this.style.bottom=`${Z}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let _=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger",Z=_?"alert":"status",$=_?"assertive":"polite";if(!this.hasAttribute("role")||this.getAttribute("role")===this._managedRole)this.setAttribute("role",Z),this._managedRole=Z;if(!this.hasAttribute("aria-live")||this.getAttribute("aria-live")===this._managedLive)this.setAttribute("aria-live",$),this._managedLive=$;if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}syncIcon(){let _=this.getAttribute("icon"),Z=this._managedIcon;if(!Z||Z.parentNode!==this)Z=this.querySelector(":scope > fig-icon[data-fig-toast-icon]");if(!_){if(Z)Z.remove();this._managedIcon=null;return}if(!Z)Z=document.createElement("fig-icon"),Z.setAttribute("data-fig-toast-icon",""),Z.setAttribute("aria-hidden","true"),this.prepend(Z);else if(this.firstElementChild!==Z)this.prepend(Z);if(Z.getAttribute("size")!=="medium")Z.setAttribute("size","medium");if(Z.getAttribute("name")!==_)Z.setAttribute("name",_);this._managedIcon=Z}syncDismiss(){let _=T(this,"dismiss"),Z=this._managedDismiss;if(!Z||Z.parentNode!==this)Z=this.querySelector(":scope > fig-button[data-fig-toast-dismiss]");let $=this._managedDismissSeparator;if(!$||$.parentNode!==this)$=this.querySelector(":scope > fig-separator[data-fig-toast-dismiss-separator]");if(!_){if(Z)Z.removeEventListener("click",this._boundHandleClose),Z.remove();if($)$.remove();this._managedDismiss=null,this._managedDismissSeparator=null;return}if(!$)$=document.createElement("fig-separator"),$.setAttribute("data-fig-toast-dismiss-separator",""),$.setAttribute("direction","vertical"),$.setAttribute("aria-orientation","vertical"),$.setAttribute("aria-hidden","true");if(!Z){Z=document.createElement("fig-button"),Z.setAttribute("data-fig-toast-dismiss",""),Z.setAttribute("variant","ghost"),Z.setAttribute("icon",""),Z.setAttribute("close-toast",""),Z.setAttribute("aria-label","Close notification");let J=document.createElement("fig-icon");J.setAttribute("name","close"),J.setAttribute("aria-hidden","true"),Z.append(J)}if($.parentNode!==this||Z.parentNode!==this)this.append($,Z);else if(this.lastElementChild!==Z||Z.previousElementSibling!==$)this.append($,Z);if($.getAttribute("direction")!=="vertical")$.setAttribute("direction","vertical");Z.removeEventListener("click",this._boundHandleClose),Z.addEventListener("click",this._boundHandleClose),this._managedDismiss=Z,this._managedDismissSeparator=$}startAutoClose(){this.clearAutoClose();let _=parseInt(this.getAttribute("duration")??"5000");if(_>0)this._autoCloseTimer=setTimeout(()=>this.hideToast(),_)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}_resolveAutoTheme(){if(this.getAttribute("theme")!=="auto")return;let _=getComputedStyle(document.documentElement).colorScheme||"";this.style.colorScheme=_.includes("dark")?"light":"dark"}showToast(){let _=this._toastVisible;this.syncLiveRegion(),this.syncIcon(),this.syncDismiss(),this._resolveAutoTheme(),this._syncingOpen=!0;try{if(!this.open)this.show()}finally{this._syncingOpen=!1}if(this._toastVisible=!0,this.applyPosition(),this.startAutoClose(),!_)this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){let _=this._toastVisible||this.open;this.clearAutoClose(),this._syncingOpen=!0;try{if(this.open)this.close();else if(this.hasAttribute("open"))this.removeAttribute("open")}finally{this._syncingOpen=!1}if(this._toastVisible=!1,_)this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live","icon","dismiss"]}attributeChangedCallback(_,Z,$){if(this._figInit(),Z===$)return;if(!this.isConnected)return;if(this._syncingOpen)return;if(_==="offset")this.applyPosition();if(_==="open")if($!==null&&$!=="false")this.showToast();else this.hideToast();if(_==="duration"&&this._toastVisible)this.startAutoClose();if(_==="theme")if($==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme");if(_==="theme"||_==="live")this.syncLiveRegion();if(_==="icon")this.syncIcon();if(_==="dismiss")this.syncDismiss()}}k0("fig-toast",J_,{extends:"dialog"});class N0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundContentReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_pendingFullReposition=!1;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;_previousFocus=null;_boundDocumentKeydown;_boundDocumentPointerUp;_boundNativeClose;_boundNativeCancel;_suppressNativeCancel=!1;_nativeCancelResetTimer=null;constructor(){super();this._boundReposition=()=>this.queueReposition(),this._boundContentReposition=()=>this.queueReposition({preserveCurrentPosition:!0}),this._boundScroll=(_)=>{let Z=_.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this),this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this),this._boundDocumentPointerUp=this.handleDocumentPointerUp.bind(this),this._boundNativeClose=this.handleNativeClose.bind(this),this._boundNativeCancel=this.handleNativeCancel.bind(this),this._boundAutoClose=()=>{this.open=!1}}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._pendingFullReposition>"u")this._pendingFullReposition=!1;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._previousFocus>"u")this._previousFocus=null;if(typeof this._suppressNativeCancel>"u")this._suppressNativeCancel=!1;if(typeof this._nativeCancelResetTimer>"u")this._nativeCancelResetTimer=null;if(typeof this._boundReposition!=="function")this._boundReposition=()=>this.queueReposition();if(typeof this._boundContentReposition!=="function")this._boundContentReposition=()=>this.queueReposition({preserveCurrentPosition:!0});if(typeof this._boundScroll!=="function")this._boundScroll=(_)=>{let Z=_.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this);if(typeof this._boundDocumentKeydown!=="function")this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this);if(typeof this._boundDocumentPointerUp!=="function")this._boundDocumentPointerUp=this.handleDocumentPointerUp.bind(this);if(typeof this._boundNativeClose!=="function")this._boundNativeClose=this.handleNativeClose.bind(this);if(typeof this._boundNativeCancel!=="function")this._boundNativeCancel=this.handleNativeCancel.bind(this);if(typeof this._boundAutoClose!=="function")this._boundAutoClose=()=>{this.open=!1}}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin","title"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){if(_===!1||_==="false"||_===null){if(!(this.matches?.(":open")||this.matches?.(":popover-open"))&&!this.hasAttribute("open"))return;if(this.hidePopup(),this.hasAttribute("open"))this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(_){if(_ instanceof Element)this._anchorRef=_;else if(typeof _==="string")this._anchorRef=null,this.setAttribute("anchor",_);else if(_&&typeof _.getBoundingClientRect==="function")this._anchorRef=_;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role",this.getAttribute("variant")==="tooltip"?"tooltip":"dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),this.removeEventListener("close",this._boundNativeClose),this.addEventListener("close",this._boundNativeClose),this.removeEventListener("cancel",this._boundNativeCancel),this.addEventListener("cancel",this._boundNativeCancel),requestAnimationFrame(()=>{this.setupDragListeners()}),this.open)this.showPopup();else this.hidePopup()}disconnectedCallback(){if(this.ensureInitialized(),this.teardownObservers(),this.removeDragListeners(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),document.removeEventListener("pointerup",this._boundDocumentPointerUp,!0),document.removeEventListener("pointercancel",this._boundDocumentPointerUp,!0),this.removeEventListener("close",this._boundNativeClose),this.removeEventListener("cancel",this._boundNativeCancel),this._nativeCancelResetTimer!==null)clearTimeout(this._nativeCancelResetTimer),this._nativeCancelResetTimer=null;if(this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(_,Z,$){if(this.ensureInitialized(),Z===$)return;if(_==="open"){if($==="false"){this.open=!1;return}if($===null){this.hidePopup();return}this.showPopup();return}if(_==="drag"){if(this.drag=$!==null&&$!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(_==="title"){this._ensureHeader();let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(t0()+1),this.captureFocusBeforeOpen();let _=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),Z=this.shouldAutoReposition();if(Z)this.style.visibility="hidden";if(_)try{this.showPopover()}catch(J){_=!1}if(!_&&!super.open)try{this.show()}catch(J){}if(Z&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.addEventListener("keydown",this._boundDocumentKeydown,!0),document.addEventListener("pointerup",this._boundDocumentPointerUp,!0),document.addEventListener("pointercancel",this._boundDocumentPointerUp,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let $=this.resolveAnchor();if($?.classList)$.classList.add("has-popup-open");if(this.getAttribute("variant")!=="tooltip")k.dismissHoverTooltips()}hidePopup(){let _=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),Z=this.resolveAnchor();if(Z?.classList)Z.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),document.removeEventListener("pointerup",this._boundDocumentPointerUp,!0),document.removeEventListener("pointercancel",this._boundDocumentPointerUp,!0),this._suppressNativeCancel=!1,this._nativeCancelResetTimer!==null)clearTimeout(this._nativeCancelResetTimer),this._nativeCancelResetTimer=null;if(this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch($){}if(this.matches?.(":open"))try{this.close()}catch($){}if(_)this.restoreFocusAfterClose()}shouldRestoreFocus(){return this.getAttribute("variant")!=="tooltip"}captureFocusBeforeOpen(){if(!this.shouldRestoreFocus())return;let _=document.activeElement;this._previousFocus=_ instanceof HTMLElement&&_!==document.body&&!this.contains(_)?_:null}restoreFocusAfterClose(){if(!this.shouldRestoreFocus()){this._previousFocus=null;return}let _=this.resolveAnchor(),Z=this._previousFocus?.isConnected?this._previousFocus:_ instanceof HTMLElement?_:null;if(this._previousFocus=null,!Z?.isConnected)return;let $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Z.focus?.())}get autoresize(){let _=this.getAttribute("autoresize");return _===null||_!=="false"}set autoresize(_){if(_===!1||_==="false"||_===null)this.setAttribute("autoresize","false");else if(_||_==="")this.setAttribute("autoresize",_===!0?"":_);else this.setAttribute("autoresize","false")}handleNativeClose(){if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}handleNativeCancel(_){if(this._suppressNativeCancel&&this.getAttribute("closedby")==="any")_.preventDefault()}setupObservers(){this.teardownObservers();let _=this.resolveAnchor();if(_ instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(_);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundContentReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundContentReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(_){if(!_)return null;let Z=_.getBoundingClientRect();return{x:Z.x,y:Z.y,width:Z.width,height:Z.height}}hasRectChanged(_,Z,$=0.25){if(!_&&!Z)return!1;if(!_||!Z)return!0;return Math.abs(_.x-Z.x)>$||Math.abs(_.y-Z.y)>$||Math.abs(_.width-Z.width)>$||Math.abs(_.height-Z.height)>$}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let _=()=>{if(!this.open){this._anchorTrackRAF=null;return}let Z=this.resolveAnchor(),$=this.readRectSnapshot(Z),J=this.shouldAutoReposition();if(J&&this.hasRectChanged(this._lastAnchorRect,$))this._lastAnchorRect=$,this.queueReposition();else if(!J)this._lastAnchorRect=$;this._anchorTrackRAF=requestAnimationFrame(_)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(_)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}_ensureHeader(){if(!this.hasAttribute("title")||this.getAttribute("variant")==="tooltip")return;Z_(this),this.querySelectorAll("fig-button[close-dialog]").forEach((_)=>{_.removeEventListener("click",this._boundAutoClose),_.addEventListener("click",this._boundAutoClose)})}handleOutsidePointerDown(_){if(!this.open||!(this.matches?.(":open")||this.matches?.(":popover-open")))return;let Z=this.getAttribute("closedby");if(Z==="none"||Z==="closerequest")return;let $=_.target;if(!($ instanceof Node))return;let J=typeof _.composedPath==="function"?_.composedPath():[];if(J.includes(this)||this.contains($)){this.markOwnedPointerInteraction();return}let Q=this.resolveAnchor();if(Q&&(J.includes(Q)||Q.contains?.($))){this.markOwnedPointerInteraction();return}if(this.isInsideDescendantPopup($,J)){this.markOwnedPointerInteraction();return}this._suppressNativeCancel=!1,this.open=!1}markOwnedPointerInteraction(){if(this._suppressNativeCancel=!0,this._nativeCancelResetTimer!==null)clearTimeout(this._nativeCancelResetTimer),this._nativeCancelResetTimer=null}handleDocumentPointerUp(){if(!this._suppressNativeCancel)return;if(this._nativeCancelResetTimer!==null)clearTimeout(this._nativeCancelResetTimer);this._nativeCancelResetTimer=setTimeout(()=>{this._suppressNativeCancel=!1,this._nativeCancelResetTimer=null},0)}handleDocumentKeydown(_){if(_.key!=="Escape"||_.defaultPrevented)return;if(!this.open)return;if(this.getAttribute("role")==="menu")return;if(this.getAttribute("closedby")==="none")return;let J=Array.from(document.querySelectorAll("dialog[open]")).filter((Q)=>Q instanceof N0&&Q.open).map((Q)=>({popup:Q,z:Number.parseInt(getComputedStyle(Q).zIndex||"0",10)||0})).sort((Q,j)=>Q.z-j.z).at(-1)?.popup;if(J&&J!==this)return;_.preventDefault(),this.open=!1}getContainingPopup(_){let Z=_,$=new Set;while(Z&&!$.has(Z)){if($.add(Z),Z instanceof N0)return Z;Z=Z.parentNode??(Z.getRootNode?.()instanceof ShadowRoot?Z.getRootNode().host:null)}return null}composedContains(_){let Z=_,$=new Set;while(Z&&!$.has(Z)){if(Z===this)return!0;$.add(Z),Z=Z.parentNode??(Z.getRootNode?.()instanceof ShadowRoot?Z.getRootNode().host:null)}return!1}isInsideDescendantPopup(_,Z=[]){let $=Z.find((j)=>j instanceof N0)??this.getContainingPopup(_);if(!$||$===this)return!1;let J=$,Q=new Set;while(J&&!Q.has(J)){Q.add(J);let j=J.anchor;if(!(j instanceof Element))break;if(this.composedContains(j))return!0;J=this.getContainingPopup(j)}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}isInteractiveElement(_){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(j)=>Z.some((q)=>j.matches?.(q))||j.tagName?.startsWith("FIG-")&&!$.includes(j.tagName);if(J(_))return!0;let Q=_.parentElement;while(Q&&Q!==this){if(J(Q))return!0;Q=Q.parentElement}return!1}handlePointerDown(_){if(!this.drag)return;if(this.isInteractiveElement(_.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(_.target))return}this._dragPending=!0,this._dragStartPos.x=_.clientX,this._dragStartPos.y=_.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=_.clientX-$.left,this._dragOffset.y=_.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}handlePointerMove(_){if(this._dragPending&&!this._isDragging){let Z=Math.abs(_.clientX-this._dragStartPos.x),$=Math.abs(_.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(_.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${_.clientX-this._dragOffset.x}px`,this.style.top=`${_.clientY-this._dragOffset.y}px`,_.preventDefault()}handlePointerUp(_){if(this._isDragging){if(this.hasPointerCapture?.(_.pointerId))this.releasePointerCapture(_.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),_.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let _=this.getAttribute("anchor");if(!_)return null;let Z=this.parentElement;try{if(Z?.querySelector){let $=Z.querySelector(_);if($&&!this.contains($))return $}return document.querySelector(_)}catch{return null}}parsePosition(){let Z=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),$=new Set(["top","center","bottom"]),J=new Set(["left","center","right"]),Q="top",j="center",q=null;if(Z.length>=2){if($.has(Z[0]))Q=Z[0];if(J.has(Z[1]))j=Z[1];return{vertical:Q,horizontal:j,shorthand:q}}if(Z.length===1){let N=Z[0];if(N==="top"||N==="bottom")Q=N,q=N;else if(N==="left"||N==="right")j=N,q=N;else if(N==="center")Q="center",j="center"}return{vertical:Q,horizontal:j,shorthand:q}}normalizeOffsetToken(_,Z="0px"){if(!_)return Z;let $=_.trim();if(!$)return Z;if(/^-?\d+(\.\d+)?$/.test($))return`${$}px`;return $}measureLengthPx(_,Z="x"){if(!_)return 0;let $=this.normalizeOffsetToken(_,"0px");if($.endsWith("px")){let j=parseFloat($);return Number.isFinite(j)?j:0}let J=document.createElement("div");if(J.style.position="fixed",J.style.visibility="hidden",J.style.pointerEvents="none",J.style.left="0",J.style.top="0",J.style.margin="0",J.style.padding="0",J.style.border="0",Z==="x")J.style.width=$,J.style.height="0";else J.style.height=$,J.style.width="0";document.body.appendChild(J);let Q=J.getBoundingClientRect();return J.remove(),Z==="x"?Q.width:Q.height}parseOffset(){let Z=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),$=this.normalizeOffsetToken(Z[0],"0px"),J=this.normalizeOffsetToken(Z[1],"0px");return{xToken:$,yToken:J,xPx:this.measureLengthPx($,"x"),yPx:this.measureLengthPx(J,"y")}}parseViewportMargins(){let Z=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((J)=>!Number.isNaN(J)),$=8;if(Z.length===0)return{top:8,right:8,bottom:8,left:8};if(Z.length===1)return{top:Z[0],right:Z[0],bottom:Z[0],left:Z[0]};if(Z.length===2)return{top:Z[0],right:Z[1],bottom:Z[0],left:Z[1]};if(Z.length===3)return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[1]};return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[3]}}getPlacementCandidates(_,Z,$){let J={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if($){let j=$==="left"||$==="right"?["top","bottom"]:["left","right"];return[{v:_,h:Z,s:$},{v:_,h:Z,s:J[$]},{v:_,h:Z,s:j[0]},{v:_,h:Z,s:j[1]}]}if(_==="center")return[{v:"center",h:Z,s:null},{v:"center",h:J[Z],s:null},{v:"top",h:Z,s:null},{v:"bottom",h:Z,s:null},{v:"top",h:J[Z],s:null},{v:"bottom",h:J[Z],s:null}];if(Z==="center")return[{v:_,h:"center",s:null},{v:J[_],h:"center",s:null},{v:_,h:"left",s:null},{v:_,h:"right",s:null},{v:J[_],h:"left",s:null},{v:J[_],h:"right",s:null}];return[{v:_,h:Z,s:null},{v:J[_],h:Z,s:null},{v:_,h:J[Z],s:null},{v:J[_],h:J[Z],s:null}]}computeCoords(_,Z,$,J,Q,j){let q,N;if(j==="left"||j==="right")return N=j==="left"?_.left-Z.width-Q.xPx:_.right+Q.xPx,q=_.top,{top:q,left:N};if(j==="top"||j==="bottom")return q=j==="top"?_.top-Z.height-Q.yPx:_.bottom+Q.yPx,N=_.left,{top:q,left:N};if($==="top")q=_.top-Z.height-Q.yPx;else if($==="bottom")q=_.bottom+Q.yPx;else q=_.top+(_.height-Z.height)/2;if($==="center")if(J==="left")N=_.left-Z.width-Q.xPx;else if(J==="right")N=_.right+Q.xPx;else N=_.left+(_.width-Z.width)/2;else if(J==="left")N=_.left+Q.xPx;else if(J==="right")N=_.right-Z.width-Q.xPx;else N=_.left+(_.width-Z.width)/2;return{top:q,left:N}}oppositeSide(_){return{top:"bottom",bottom:"top",left:"right",right:"left"}[_]||"bottom"}getPlacementSide(_,Z,$){if($==="top")return"top";if($==="bottom")return"bottom";if($==="left")return"left";if($==="right")return"right";if(_!=="center")return _;if(Z!=="center")return Z;return"top"}lengthToPx(_,Z=0){let $=getComputedStyle(this),J=String(_||"").trim(),Q=parseFloat(J);if(!Number.isFinite(Q))return Z;if(J.endsWith("rem"))return Q*parseFloat(getComputedStyle(document.documentElement).fontSize);if(J.endsWith("em"))return Q*parseFloat($.fontSize);return Q}radiusForSide(_){let Z=getComputedStyle(this),$=(J)=>this.lengthToPx(J,0);if(_==="top")return Math.max($(Z.borderTopLeftRadius),$(Z.borderTopRightRadius));if(_==="bottom")return Math.max($(Z.borderBottomLeftRadius),$(Z.borderBottomRightRadius));if(_==="left")return Math.max($(Z.borderTopLeftRadius),$(Z.borderBottomLeftRadius));if(_==="right")return Math.max($(Z.borderTopRightRadius),$(Z.borderBottomRightRadius));return 0}getBeakEdgeInset(_){let Z=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(_)+Z/2)}tracksAnchorBeak(){let _=this.getAttribute("variant");return _==="popover"||_==="tooltip"}getViewportBounds(_){let Z=window.visualViewport,$=Z?.width??window.innerWidth,J=Z?.height??window.innerHeight,Q=Z?.offsetLeft??0,j=Z?.offsetTop??0;return{minLeft:Q+_.left,minTop:j+_.top,maxRight:Q+$-_.right,maxBottom:j+J-_.bottom}}clampToViewport(_,Z,$){let J=this.getViewportBounds($),Q=J.maxRight-Z.width,j=J.maxBottom-Z.height,q=Math.max(J.minLeft,Q),N=Math.max(J.minTop,j);return{left:Math.min(q,Math.max(J.minLeft,_.left)),top:Math.min(N,Math.max(J.minTop,_.top))}}resolveCoordsAtViewport(_,Z,$,J,Q){let{left:j,top:q}=this.clampToViewport($,Z,Q);if(!_||!this.tracksAnchorBeak())return{left:j,top:q};let N=this.oppositeSide(J),G=this.getViewportBounds(Q),K=G.maxRight-Z.width,X=G.minLeft,Y=G.maxBottom-Z.height,W=G.minTop;if(N==="top"||N==="bottom"){let R=this.getBeakEdgeInset(N),L=_.left+_.width/2,O=L-j;if(O<R)j=L-R;else if(O>Z.width-R)j=L-(Z.width-R);j=Math.min(K,Math.max(X,j))}else if(N==="left"||N==="right"){let R=this.getBeakEdgeInset(N),L=_.top+_.height/2,O=L-q;if(O<R)q=L-R;else if(O>Z.height-R)q=L-(Z.height-R);q=Math.min(Y,Math.max(W,q))}return{left:j,top:q}}canPointAtAnchor(_,Z,$,J,Q){if(!_||!this.tracksAnchorBeak())return!0;let j=this.oppositeSide(Q),q=this.getBeakEdgeInset(j);if(j==="top"||j==="bottom"){let G=_.left+_.width/2-$;return G>=q-0.5&&G<=Z.width-q+0.5}let N=_.top+_.height/2-J;return N>=q-0.5&&N<=Z.height-q+0.5}updatePopoverBeak(_,Z,$,J,Q){if(!this.tracksAnchorBeak()||!_){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let j=this.oppositeSide(Q);this.setAttribute("data-beak-side",j);let q=_.left+_.width/2,N=_.top+_.height/2,G=this.getBoundingClientRect(),K=G.width>0&&G.height>0?G:Z,X=K.left,Y=K.top,W=this.getBeakEdgeInset(j),R;if(j==="top"||j==="bottom"){R=q-X;let L=W,O=Math.max(L,K.width-W);R=Math.min(O,Math.max(L,R))}else{R=N-Y;let L=W,O=Math.max(L,K.height-W);R=Math.min(O,Math.max(L,R))}this.style.setProperty("--fig-popup-beak-offset",`${R}px`)}overflowScore(_,Z,$){let J=this.getViewportBounds($),Q=_.left+Z.width,j=_.top+Z.height,q=Math.max(0,J.minLeft-_.left),N=Math.max(0,J.minTop-_.top),G=Math.max(0,Q-J.maxRight),K=Math.max(0,j-J.maxBottom);return q+N+G+K}fits(_,Z,$){return this.overflowScore(_,Z,$)===0}clamp(_,Z,$,J=null,Q="top"){if(J)return this.resolveCoordsAtViewport(J,Z,_,Q,$);return this.clampToViewport(_,Z,$)}primaryAxisOverflowPenalty(_,Z,$,J){let Q=this.getViewportBounds($),j=0;if(J==="top")j=Math.max(0,Q.minTop-_.top);else if(J==="bottom")j=Math.max(0,_.top+Z.height-Q.maxBottom);else if(J==="left")j=Math.max(0,Q.minLeft-_.left);else if(J==="right")j=Math.max(0,_.left+Z.width-Q.maxRight);return j>0?1000+j:0}placementScore(_,Z,$,J,Q){let j=this.resolveCoordsAtViewport(_,Z,$,J,Q),q=this.overflowScore(j,Z,Q);if(q+=this.primaryAxisOverflowPenalty($,Z,Q,J),_&&!this.canPointAtAnchor(_,Z,j.left,j.top,J))q+=1e4;return{score:q,resolved:j}}applyPopupPosition(_,Z,$,J,Q){let j=this.resolveCoordsAtViewport(_,Z,$,J,Q);this.style.left=`${j.left}px`,this.style.top=`${j.top}px`,this.updatePopoverBeak(_,Z,j.left,j.top,J)}currentPlacementSide(){let _=this.getAttribute("data-beak-side");if(_)return this.oppositeSide(_);let{vertical:Z,horizontal:$,shorthand:J}=this.parsePosition();return this.getPlacementSide(Z,$,J)}preservePopupPosition(_,Z,$){let J={left:_.left,top:_.top},Q=this.fits(J,_,$)?J:this.clampToViewport(J,_,$),j=Z?Z.getBoundingClientRect():null,q=this.currentPlacementSide();if(j&&this.tracksAnchorBeak()&&!this.canPointAtAnchor(j,_,Q.left,Q.top,q))return!1;return this.style.left=`${Q.left}px`,this.style.top=`${Q.top}px`,this.updatePopoverBeak(j,_,Q.left,Q.top,q),!0}positionPopup({preserveCurrentPosition:_=!1}={}){if(!this.open)return;let Z=this.getBoundingClientRect(),$=this.resolveAnchor(),J=this.parseViewportMargins();if(_&&this.preservePopupPosition(Z,$,J))return;let Q=this.parseOffset(),{vertical:j,horizontal:q,shorthand:N}=this.parsePosition();if(!$){this.updatePopoverBeak(null,Z,0,0,"top");let R=this.getViewportBounds(J),L={left:R.minLeft+(R.maxRight-R.minLeft-Z.width)/2,top:R.minTop+(R.maxBottom-R.minTop-Z.height)/2},O=this.clampToViewport(L,Z,J);this.style.left=`${O.left}px`,this.style.top=`${O.top}px`;return}let G=$.getBoundingClientRect(),K=this.getPlacementCandidates(j,q,N),X=null,Y="top",W=Number.POSITIVE_INFINITY;for(let{v:R,h:L,s:O}of K){let H=this.computeCoords(G,Z,R,L,Q,O),A=this.getPlacementSide(R,L,O),{score:z,resolved:U}=this.placementScore(G,Z,H,A,J);if(O){let I=this.getViewportBounds(J);if((O==="left"||O==="right"?H.left>=I.minLeft&&H.left+Z.width<=I.maxRight:H.top>=I.minTop&&H.top+Z.height<=I.maxBottom)&&z<1e4){this.applyPopupPosition(G,Z,H,A,J);return}}else if(z===0){this.applyPopupPosition(G,Z,H,A,J);return}if(z<W)W=z,X=U,Y=A}this.applyPopupPosition(G,Z,X||{left:0,top:0},Y,J)}queueReposition({preserveCurrentPosition:_=!1}={}){if(!this.open||!this.isPopupDisplayed()||!this.shouldAutoReposition())return;if(!_)this._pendingFullReposition=!0;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null;let Z=!this._pendingFullReposition;this._pendingFullReposition=!1,this.positionPopup({preserveCurrentPosition:Z})})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}isPopupDisplayed(){return Boolean(this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"))}}k0("fig-popup",N0,{extends:"dialog"});class Q_ extends HTMLElement{#Z;#_;constructor(){super();this.content=null,this.#Z=!1,this.#_=this.handleClick.bind(this)}connectedCallback(){if(this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.addEventListener("click",this.#_),u(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let _=this.getAttribute("id")||g(),Z=this.content.getAttribute("id")||g();if(this.setAttribute("id",_),this.content.setAttribute("id",Z),this.setAttribute("aria-controls",Z),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",_),this.#Z)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}}})}get selected(){return this.#Z}set selected(_){this.setAttribute("selected",_?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#_)}handleClick(){if(T(this,"disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(_,Z,$){if(_==="selected"){if(this.#Z=$!==null&&$!=="false",this.setAttribute("aria-selected",this.#Z?"true":"false"),this.setAttribute("tabindex",this.#Z?"0":"-1"),this?.content)this.content.style.display=this.#Z?"block":"none"}if(_==="disabled")if($!==null&&$!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#Z?"0":"-1")}}F("fig-tab",Q_);class j_ extends HTMLElement{#Z;#_;#J=this.#O.bind(this);#$=null;#Q=null;#j=null;#G=null;#q=!1;#N=new WeakSet;constructor(){super();this.#Z=this.handleClick.bind(this),this.#_=this.#H.bind(this)}static get observedAttributes(){return["value","name","disabled","overflow"]}get#X(){return this.getAttribute("overflow")==="fade"?"fade":"buttons"}connectedCallback(){if(this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#W(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#_),this.addEventListener("scroll",this.#J),this.#A(),this.#B(),this.#M(),u(this,()=>{let _=this.getAttribute("value");if(_)this.#T(_);if(T(this,"disabled"))this.#K(!0);this.#R(),this.#O(),this.#U(void 0,"auto")})}#K(_){this.querySelectorAll("fig-tab").forEach(($)=>{if(_){if(!($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false"))this.#N.add($),$.setAttribute("disabled","");$.setAttribute("aria-disabled","true"),$.setAttribute("tabindex","-1")}else if(this.#N.has($))this.#N.delete($),$.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#R()}#Y(){return Array.from(this.querySelectorAll("fig-tab")).filter((_)=>!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false")}#R(){let _=Array.from(this.querySelectorAll("fig-tab")),Z=_.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false")||this.#Y()[0];_.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false";$.setAttribute("tabindex",!J&&$===Z?"0":"-1")})}#U(_=this.selectedTab,Z="smooth"){let $=_||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#Y()[0];if(!$)return;requestAnimationFrame(()=>{if(!this.isConnected||!$.isConnected)return;if(!(this.scrollWidth>this.clientWidth))return;let Q=this.getBoundingClientRect(),j=$.getBoundingClientRect(),q=j.left-Q.left+this.scrollLeft+j.width/2;this.scrollTo({left:q-this.clientWidth/2,behavior:Z}),this.#O()})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#_),this.removeEventListener("scroll",this.#J),this.#$?.disconnect(),this.#$=null,this.#Q?.disconnect(),this.#Q=null,this.#L()}#W(){if(this.#q)return;let _=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!_)return;this.#q=!0;try{let Z=Array.from(_.childNodes);_.replaceWith(...Z)}finally{this.#q=!1}}#O(){L0(this,this,"x")}#M(){this.#Q?.disconnect(),this.#Q=new ResizeObserver(()=>this.#O()),this.#Q.observe(this)}#B(){this.#$?.disconnect(),this.#$=new MutationObserver((_)=>{if(this.#q)return;if(!_.some(($)=>[...$.addedNodes,...$.removedNodes].some((J)=>!(J instanceof Element)||!J.matches("[data-fig-tabs-nav]"))))return;this.#W(),this.#A(),this.#R(),requestAnimationFrame(()=>{this.#O(),this.#U()})}),this.#$.observe(this,{childList:!0,subtree:!1})}#L(){this.#j?.remove(),this.#G?.remove(),this.#j=null,this.#G=null,this.classList.remove("overflow-start","overflow-end")}#A(){let _=this.#X==="fade";if(this.classList.toggle("fig-overflow-fade",_),this.classList.toggle("fig-overflow-fade-horizontal",_),_)this.#L();else this.#I()}#I(){if(this.#j&&this.#G&&this.contains(this.#j)&&this.contains(this.#G)){this.#D();return}this.#j?.remove(),this.#G?.remove();let _=W0({owner:"tabs",onStart:()=>Z0(this,"x",-1),onEnd:()=>Z0(this,"x",1)});this.#j=_.start,this.#G=_.end,this.#D()}#D(){if(this.firstElementChild!==this.#j)this.prepend(this.#j);if(this.lastElementChild!==this.#G)this.append(this.#G)}#H(_){let Z=this.#Y();if(!Z.length)return;let $=Z.findIndex((Q)=>T(Q,"selected")),J=$>=0?$:0;switch(_.key){case"ArrowLeft":case"ArrowUp":_.preventDefault(),J=$>0?$-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":_.preventDefault(),J=$<Z.length-1?$+1:0;break;case"Home":_.preventDefault(),J=0;break;case"End":_.preventDefault(),J=Z.length-1;break;default:return}if(J!==$&&Z[J]){this.querySelectorAll("fig-tab").forEach((j)=>j.removeAttribute("selected")),this.selectedTab=Z[J],Z[J].setAttribute("selected","true");let Q=this.#F(Z[J]);if(Q)this.setAttribute("value",Q);else this.removeAttribute("value");Z[J].focus(),this.#R(),this.#U(Z[J]),this.#z()}}get value(){return this.#F(this.selectedTab)}set value(_){this.setAttribute("value",_)}#z(){let _=this.value;this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#F(_){if(!_)return"";let Z=_.getAttribute("value");if(Z!==null)return Z;return _.textContent?.trim()||""}#T(_){let Z=this.querySelectorAll("fig-tab");for(let $ of Z)if(this.#F($)===_)this.selectedTab=$,$.setAttribute("selected","true");else $.removeAttribute("selected");this.#R(),this.#U(this.selectedTab)}attributeChangedCallback(_,Z,$){switch(_){case"value":if($!==Z)this.#T($);break;case"disabled":this.#K($!==null&&$!=="false");break;case"overflow":this.#A(),requestAnimationFrame(()=>this.#O());break}}handleClick(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=_.target.closest("fig-tab");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;let $=this.querySelectorAll("fig-tab"),J=Array.from($).find((q)=>T(q,"selected"))||this.selectedTab,Q=this.#F(J);for(let q of $)if(q===Z)this.selectedTab=q,q.setAttribute("selected","true");else q.removeAttribute("selected");let j=this.#F(Z);if(j)this.setAttribute("value",j);else this.removeAttribute("value");if(this.#R(),this.#U(Z),J!==Z||Q!==this.value)this.#z()}}F("fig-tabs",j_);class q_ extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group")}}F("fig-toolbelt-group",q_);class N_ extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Z()}get value(){let _=this.getAttribute("value");return _!==null?_:this.textContent?.trim()||""}set value(_){this.setAttribute("value",_??"")}get selected(){return T(this,"selected")}set selected(_){this.toggleAttribute("selected",Boolean(_))}get disabled(){return T(this,"disabled")}set disabled(_){this.toggleAttribute("disabled",Boolean(_))}attributeChangedCallback(){this.#Z()}#Z(){let _=T(this,"selected"),Z=T(this,"disabled");if(this.setAttribute("aria-pressed",_?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled")}}F("fig-toolbelt-item",N_);class G_ extends HTMLElement{#Z=this.#T.bind(this);#_=this.#S.bind(this);#J=this.#V.bind(this);#$=this.#E.bind(this);#Q=null;#j=null;#G=null;#q=null;#N=null;#X=null;#K=null;#Y=null;#R=new WeakSet;#U=!1;constructor(){super();let _=this.attachShadow({mode:"open"}),Z=document.createElement("div");Z.setAttribute("part","frame"),this.#G=document.createElement("slot"),this.#G.name="prepend",this.#G.setAttribute("part","prepend"),this.#G.hidden=!0,this.#G.style.display="none";let $=document.createElement("div");$.setAttribute("part","scroll-region");let J=document.createElement("slot");J.name="start",J.style.display="contents",this.#Q=document.createElement("div"),this.#Q.className="fig-overflow-fade",this.#Q.setAttribute("part","viewport"),this.#j=document.createElement("slot"),this.#j.style.display="contents",this.#Q.append(this.#j);let Q=document.createElement("slot");Q.name="end",Q.style.display="contents",this.#q=document.createElement("slot"),this.#q.name="append",this.#q.setAttribute("part","append"),this.#q.hidden=!0,this.#q.style.display="none",$.append(J,this.#Q,Q),Z.append(this.#G,$,this.#q),_.append(Z);for(let j of[this.#G,this.#j,this.#q])j.addEventListener("slotchange",this.#J)}static get observedAttributes(){return["value","disabled","layout","overflow"]}get#W(){return this.getAttribute("layout")==="vertical"}get#O(){return this.getAttribute("overflow")==="buttons"?"buttons":"scrollbar"}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","toolbar");this.#k(),this.#f(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#_),this.#Q.addEventListener("scroll",this.#$),this.#x(),this.#C(),this.#h(),u(this,()=>{this.#I(),this.#A(T(this,"disabled")),this.#F(),this.#E(),this.#b(void 0,"auto")})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#_),this.#Q.removeEventListener("scroll",this.#$),this.#N?.disconnect(),this.#N=null,this.#X?.disconnect(),this.#X=null,this.#p()}get value(){return this.selectedItem?.value||""}set value(_){if(_===null||_===void 0)this.removeAttribute("value");else this.setAttribute("value",String(_))}get selectedItem(){return this.#M().find((_)=>T(_,"selected"))||null}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="value"&&!this.#U)this.#D($);if(_==="disabled")this.#A($!==null&&$!=="false");if(_==="overflow")this.#x(),requestAnimationFrame(()=>this.#E());if(_==="layout"){if(this.#f(),this.#W)this.#Q.scrollLeft=0;else this.#Q.scrollTop=0;this.#x(),requestAnimationFrame(()=>{this.#E(),this.#b(void 0,"auto")})}}#M(){let _={prepend:[],viewport:[],append:[]};for(let Z of this.querySelectorAll("fig-toolbelt-item")){if(Z.closest("fig-toolbelt")!==this)continue;let $=this.#B(Z);if($)_[$].push(Z)}return[..._.prepend,..._.viewport,..._.append]}#B(_){let Z=_;while(Z.parentElement&&Z.parentElement!==this)Z=Z.parentElement;if(Z.parentElement!==this)return null;let $=Z.getAttribute("slot")||"";if($==="prepend"||$==="append")return $;return $?null:"viewport"}#L(){return this.#M().filter((_)=>!T(_,"disabled"))}#A(_){if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Z of this.#M())if(_){if(!T(Z,"disabled"))this.#R.add(Z),Z.setAttribute("disabled","")}else if(this.#R.has(Z))this.#R.delete(Z),Z.removeAttribute("disabled");this.#F()}#I(){let _=this.getAttribute("value");if(_!==null){this.#D(_);return}let Z=this.#M().filter((J)=>T(J,"selected")),$=Z[0]||null;for(let J of Z.slice(1))J.removeAttribute("selected");if($)this.#z($.value)}#D(_){let Z=_===null?null:this.#M().find(($)=>$.value===_)||null;for(let $ of this.#M())$.toggleAttribute("selected",$===Z);if(this.#F(Z),Z)this.#b(Z)}#H(_,{emit:Z=!1,focus:$=!1}={}){if(!_||T(_,"disabled"))return!1;let J=this.selectedItem,Q=this.value;for(let j of this.#M())j.toggleAttribute("selected",j===_);if(this.#z(_.value),this.#F(_),$)_.focus();if(this.#b(_),Z&&(J!==_||Q!==_.value))this.#P();return!0}#z(_){this.#U=!0,this.setAttribute("value",_),this.#U=!1}#F(_){let Z=this.#M(),$=this.#L(),J=_&&$.includes(_)&&_||$.includes(document.activeElement)&&document.activeElement||$.includes(this.selectedItem)&&this.selectedItem||$[0]||null;for(let Q of Z)Q.setAttribute("tabindex",Q===J?"0":"-1")}#T(_){if(T(this,"disabled"))return;let Z=_.target.closest?.("fig-toolbelt-item");if(!Z||Z.closest("fig-toolbelt")!==this)return;this.#H(Z,{emit:!0})}#S(_){if(T(this,"disabled"))return;let Z=_.target.closest?.("fig-toolbelt-item");if(!Z||Z.closest("fig-toolbelt")!==this)return;if(_.key==="Enter"||_.key===" "){_.preventDefault(),this.#H(Z,{emit:!0});return}let $=this.#L();if(!$.length)return;let J=Math.max(0,$.indexOf(Z)),Q=J;switch(_.key){case"ArrowLeft":if(this.#W)return;Q=J>0?J-1:$.length-1;break;case"ArrowUp":if(!this.#W)return;Q=J>0?J-1:$.length-1;break;case"ArrowRight":if(this.#W)return;Q=J<$.length-1?J+1:0;break;case"ArrowDown":if(!this.#W)return;Q=J<$.length-1?J+1:0;break;case"Home":Q=0;break;case"End":Q=$.length-1;break;default:return}_.preventDefault(),this.#F($[Q]),$[Q].focus(),this.#v($[Q])}#P(){let _=this.value;this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#V(){this.#k(),this.#I(),this.#F(),requestAnimationFrame(()=>{this.#E(),this.#b()})}#k(){for(let _ of[this.#G,this.#q]){let Z=_.assignedElements({flatten:!0}).length===0;if(_.hidden=Z,Z)_.style.setProperty("display","none","important");else _.style.removeProperty("display")}}#C(){this.#N?.disconnect(),this.#N=new MutationObserver((_)=>{if(!_.some(($)=>$.type==="childList"||$.target instanceof Element&&$.target.matches("fig-toolbelt-item")&&$.target.closest("fig-toolbelt")===this))return;this.#x(),this.#I(),this.#A(T(this,"disabled")),this.#F(),requestAnimationFrame(()=>{this.#E(),this.#b()})}),this.#N.observe(this,{childList:!0,attributes:!0,subtree:!0,attributeFilter:["value","selected","disabled"]})}#h(){this.#X?.disconnect(),this.#X=new ResizeObserver(()=>this.#E()),this.#X.observe(this),this.#X.observe(this.#Q)}#E(){if(this.#O==="scrollbar")return;L0(this,this.#Q,this.#W?"y":"x")}#f(){this.setAttribute("aria-orientation",this.#W?"vertical":"horizontal"),this.#Q.classList.add("fig-overflow-fade"),this.#Q.classList.toggle("fig-overflow-fade-horizontal",!this.#W)}#x(){if(this.#O==="scrollbar")this.#p();else this.#g()}#g(){if(this.#K&&this.#Y&&this.contains(this.#K)&&this.contains(this.#Y)){this.#w();return}this.#K?.remove(),this.#Y?.remove();let _=W0({owner:"toolbelt",onStart:()=>this.#y(-1),onEnd:()=>this.#y(1)});this.#K=_.start,this.#Y=_.end,this.#K.setAttribute("slot","start"),this.#Y.setAttribute("slot","end"),this.#w()}#w(){if(this.firstElementChild!==this.#K)this.prepend(this.#K);if(this.lastElementChild!==this.#Y)this.append(this.#Y)}#p(){this.#K?.remove(),this.#Y?.remove(),this.#K=null,this.#Y=null,this.classList.remove("overflow-start","overflow-end")}#y(_){Z0(this.#Q,this.#W?"y":"x",_)}#b(_=this.selectedItem,Z="smooth"){if(_)this.#v(_,Z)}#v(_,Z="smooth"){if(!_||this.#B(_)!=="viewport")return;requestAnimationFrame(()=>{if(!this.isConnected||!_.isConnected)return;let $=this.#W;if(!($?this.#Q.scrollHeight>this.#Q.clientHeight:this.#Q.scrollWidth>this.#Q.clientWidth))return;let Q=this.#Q.getBoundingClientRect(),j=_.getBoundingClientRect();if($){let q=j.top-Q.top+this.#Q.scrollTop+j.height/2;this.#Q.scrollTo({top:q-this.#Q.clientHeight/2,behavior:Z})}else{let q=j.left-Q.left+this.#Q.scrollLeft+j.width/2;this.#Q.scrollTo({left:q-this.#Q.clientWidth/2,behavior:Z})}this.#E()})}}F("fig-toolbelt",G_);class K_ extends HTMLElement{#Z;#_;#J;constructor(){super();this.#J=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#$(),this.addEventListener("click",this.#J)}disconnectedCallback(){this.removeEventListener("click",this.#J)}handleClick(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let _=this.closest("fig-segmented-control");if(_&&_.hasAttribute("disabled")&&_.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#Z}set value(_){this.#Z=_,this.setAttribute("value",_)}get selected(){return this.#_}set selected(_){this.#_=_,this.setAttribute("selected",_)}static get observedAttributes(){return["selected","value","disabled"]}#$(){let _=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",_?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",_?"0":"-1")}attributeChangedCallback(_,Z,$){switch(_){case"value":this.#Z=$;break;case"selected":this.#_=$,this.#$();break;case"disabled":this.#$();break}}}F("fig-segment",K_);class X_ extends HTMLElement{#Z=null;#_=this.handleClick.bind(this);#J=this.#O.bind(this);#$=null;#Q=null;#j=0;#G=!1;#q=!1;#N=new WeakSet;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){if(this.name=this.getAttribute("name")||"segmented-control",!this.hasAttribute("role"))this.setAttribute("role","radiogroup");this.addEventListener("click",this.#_),this.addEventListener("keydown",this.#J),this.#F(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#z(),this.#I(),u(this,()=>{this.#H({enforceFallback:!0}),this.#D(),this.#L({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#_),this.removeEventListener("keydown",this.#J),this.#$?.disconnect(),this.#$=null,this.#Q?.disconnect(),this.#Q=null,this.#j)cancelAnimationFrame(this.#j),this.#j=0;this.#G=!1,this.#q=!1}get selectedSegment(){return this.#Z}set selectedSegment(_){let Z=this.querySelectorAll("fig-segment");for(let $ of Z){let J=$===_,Q=T($,"selected");if(J&&!Q)$.setAttribute("selected","true");else if(!J&&Q)$.removeAttribute("selected")}this.#Z=_ instanceof HTMLElement&&this.contains(_)?_:null,this.#U(),this.#L()}get value(){return this.getAttribute("value")||""}set value(_){if(_===null||_===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(_))}#X(_){this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#K(_){let Z=_.getAttribute("value");if(Z!==null){let $=Z.trim();if($.length>0)return $}return _.textContent?.trim()||""}#Y(){let _=this.querySelectorAll("fig-segment");for(let Z of _)if(Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false")return Z;return null}#R(){return Array.from(this.querySelectorAll("fig-segment")).filter((_)=>!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false")}#U(){let _=Array.from(this.querySelectorAll("fig-segment")),Z=_.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false");_.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false",Q=$===Z;$.setAttribute("aria-checked",Q?"true":"false"),$.setAttribute("tabindex",!J&&Q?"0":"-1")})}#W(_){if(!_)return;let Z=this.selectedSegment,$=this.value;this.selectedSegment=_;let J=this.#K(_);if(J)this.setAttribute("value",J);else this.removeAttribute("value");let Q=this.value;if(Z!==_||$!==Q)this.#X(Q)}#O(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#R();if(!Z.length)return;let $=Z.findIndex((j)=>T(j,"selected")),J=$>=0?$:0;switch(_.key){case"ArrowLeft":case"ArrowUp":_.preventDefault(),J=J>0?J-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":_.preventDefault(),J=J<Z.length-1?J+1:0;break;case"Home":_.preventDefault(),J=0;break;case"End":_.preventDefault(),J=Z.length-1;break;case" ":case"Enter":{let j=_.target.closest("fig-segment");if(j&&this.contains(j))_.preventDefault(),this.#W(j);return}default:return}let Q=Z[J];this.#W(Q),Q.focus(),requestAnimationFrame(()=>{if(this.contains(Q))Q.focus()})}#M(_){let Z=String(_??"").trim();if(!Z)return!1;let $=this.querySelectorAll("fig-segment");for(let J of $){let Q=this.#K(J);if(!Q)continue;if(Q===Z)return this.selectedSegment=J,!0}return!1}#B(){let _=this.getAttribute("animated");if(_===null)return!1;if(_==="")return!0;return _.trim().toLowerCase()==="true"}#L({forceInstant:_=!1}={}){if(this.#G=this.#G||_,this.#j)return;this.#j=requestAnimationFrame(()=>{this.#j=0;let Z=this.#G;this.#G=!1,this.#A({forceInstant:Z})})}#A({forceInstant:_=!1}={}){let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#B(),J=this.#Z&&this.contains(this.#Z)?this.#Z:this.#Y();if(Z||!$){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!$||Z)this.#q=!1;return}if(!J){if(this.#q)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let Q=this.getBoundingClientRect(),j=J.getBoundingClientRect();if(Q.width<=0||j.width<=0){if(this.#q)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let q=Math.max(0,j.left-Q.left);this.style.setProperty("--seg-indicator-x",`${q}px`),this.style.setProperty("--seg-indicator-w",`${j.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#q||_?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#q=!0}#I(){this.#Q?.disconnect(),this.#Q=new ResizeObserver(()=>{this.#L()}),this.#D()}#D(){if(!this.#Q)return;this.#Q.disconnect(),this.#Q.observe(this),this.querySelectorAll("fig-segment").forEach((_)=>{this.#Q?.observe(_)})}#H({enforceFallback:_=!1}={}){if(this.querySelectorAll("fig-segment").length===0){this.#Z=null,this.#L({forceInstant:!0});return}let $=this.getAttribute("value"),J=$?.trim()??"";if($!==null){if(J!==$){this.setAttribute("value",J);return}if(J&&this.#M(J))return}let Q=this.#Y();if(Q){this.selectedSegment=Q;return}if(_)this.selectedSegment=this.#R()[0]||null}#z(){this.#$?.disconnect(),this.#$=new MutationObserver((_)=>{let Z=!1;for(let $ of _){if($.type==="childList"){Z=!0;break}if($.type==="attributes"&&$.target instanceof HTMLElement&&$.target.tagName.toLowerCase()==="fig-segment"&&($.attributeName==="value"||$.attributeName==="selected")){Z=!0;break}if($.type==="characterData"){Z=!0;break}}if(Z)this.#F(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#D(),this.#H({enforceFallback:!0}),this.#U()}),this.#$.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=_.target.closest("fig-segment");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#W(Z)}#F(_){this.setAttribute("aria-disabled",_?"true":"false"),this.querySelectorAll("fig-segment").forEach((Z)=>{if(_){if(!(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false"))this.#N.add(Z),Z.setAttribute("disabled","");Z.setAttribute("aria-disabled","true")}else if(this.#N.has(Z))this.#N.delete(Z),Z.removeAttribute("disabled"),Z.removeAttribute("aria-disabled")}),this.#U()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="disabled"){this.#F($!==null&&$!=="false"),this.#L({forceInstant:!0});return}if(_==="value"){this.#H({enforceFallback:!1});return}if(_==="animated"){if(!this.#B())this.#q=!1;this.#L({forceInstant:!0});return}if(_==="sizing")this.#L({forceInstant:!0})}}F("fig-segmented-control",X_);class Y_ extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Z="segments";#_=0;#J=null;#$=[];#Q=null;#j=!1;#G(_){let Z=_?.detail;if(typeof Z==="string")return Z;let $=_?.currentTarget?.value??_?.target?.value??this.getAttribute("value");if($===null||$===void 0)return null;return String($)}#q(){if(this.#$.length===0)return!1;let _=this.querySelector(":scope > fig-segmented-control");if(_){let $=_.querySelectorAll("fig-segment");if($.length!==this.#$.length)return!1;return Array.from($).every((J,Q)=>J.getAttribute("value")===this.#$[Q])}let Z=this.querySelector(":scope > fig-dropdown");if(Z){let $=Z.querySelectorAll("option");return $.length===this.#$.length&&Array.from($).every((J,Q)=>J.textContent?.trim()===this.#$[Q])}return!1}#N(){let _=this.querySelector(":scope > fig-segmented-control");if(_)this.#Q=_,this.#Z="segments";else this.#Q=this.querySelector(":scope > fig-dropdown"),this.#Z="dropdown";this.#U()}connectedCallback(){if(this.#X(),this.#q()){this.#N(),this.#O(),u(this,()=>u(this,()=>this.#L()));return}this.#K(),this.#O(),u(this,()=>u(this,()=>this.#L()))}disconnectedCallback(){this.#J?.disconnect(),this.#J=null}get value(){return this.getAttribute("value")||""}set value(_){if(_===null||_===void 0)this.removeAttribute("value");else this.setAttribute("value",String(_))}get options(){return this.#$.slice()}set options(_){if(Array.isArray(_)){let $=_.some((J)=>String(J).includes(","))?JSON.stringify(_):_.join(",");this.setAttribute("options",$)}else this.setAttribute("options",String(_||""))}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="options"){this.#X(),this.#R();return}if(_==="value"){this.#U();return}if(_==="disabled"){this.#W("disabled");return}if(_==="full"){this.#W("full");return}if(_==="sizing")this.#W("sizing"),this.#R()}#X(){let _=this.getAttribute("options")||"";if(_.startsWith("["))try{this.#$=JSON.parse(_);return}catch{}let Z=_.includes(`
173
173
  `)?`
174
- `:",";this.#$=_.split(Z).map(($)=>$.trim()).filter(Boolean)}#K(){if(this.replaceChildren(),this.#$.length===0)return;let _=document.createElement("fig-segmented-control");if(_.setAttribute("sizing",this.getAttribute("sizing")||"equal"),T(this,"disabled"))_.setAttribute("disabled","");if(T(this,"full"))_.setAttribute("full","");let Z=this.getAttribute("value");for(let $ of this.#$){let J=document.createElement("fig-segment");if(J.setAttribute("value",$),J.textContent=$,Z===$)J.setAttribute("selected","true");_.appendChild(J)}if(Z)_.setAttribute("value",Z);_.addEventListener("input",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#G($);if(J===null)return;this.#j=!0,this.setAttribute("value",J),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),_.addEventListener("change",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#G($);if(J===null)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(_),this.#Q=_,this.#Z="segments"}#Y(){if(this.replaceChildren(),this.#$.length===0)return;let _=document.createElement("fig-dropdown");if(T(this,"disabled"))_.setAttribute("disabled","");let Z=this.getAttribute("value");for(let $ of this.#$){let J=document.createElement("option");if(J.value=$,J.textContent=$,Z===$)J.selected=!0;_.appendChild(J)}if(Z)_.setAttribute("value",Z);_.addEventListener("input",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#G($);if(!J)return;this.#j=!0,this.setAttribute("value",J),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),_.addEventListener("change",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#G($);if(!J)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(_),this.#Q=_,this.#Z="dropdown"}#R(){if(this.#Z==="segments")this.#K(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#L())});else this.#Y()}#U(){if(!this.#Q||this.#j)return;let _=this.getAttribute("value")||"";this.#Q.value=_}#W(_){if(!this.#Q)return;if(this.hasAttribute(_))this.#Q.setAttribute(_,this.getAttribute(_)||"");else this.#Q.removeAttribute(_)}#B(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#L()}),this.#J.observe(this)}#M(_){let Z=document.createRange();Z.selectNodeContents(_);let $=Z.getBoundingClientRect().width,Q=_.getBoundingClientRect().width,j=getComputedStyle(_),q=parseFloat(j.paddingLeft)||0,N=parseFloat(j.paddingRight)||0,G=Q-q-N;return $>G+0.5}#O(){let _=this.querySelectorAll("fig-segment");for(let Z of _)if(this.#M(Z))return!0;return!1}#L(){if(this.#$.length<=1)return;if(this.#Z==="segments"){let _=this.#Q;if(_&&_.scrollWidth>_.clientWidth+1||this.#O())this.#_=this.clientWidth,this.#Y()}else if(this.#_>0&&this.clientWidth>=this.#_)this.#K(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let _=this.#Q;if(_&&_.scrollWidth>_.clientWidth+1||this.#O())this.#Y()})})}}F("fig-options",Y_);class R_ extends HTMLElement{#Z=!1;#_=!1;#J=!1;#$="";#Q=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#j={range:{min:0,max:100,step:1},hue:{min:0,max:255,step:1},delta:{min:-100,max:100,step:1},stepper:{min:0,max:100,step:25},opacity:{min:0,max:100,step:0.1,color:"var(--figma-color-icon)"}};#G;#N;#q;#X;#K;#Y;#R;#U=null;#W=null;#B=null;#M=null;constructor(){super();this.initialChildren=null,this.#G=(_)=>{_.stopPropagation(),this.#p()},this.#N=(_)=>{_.stopPropagation(),this.#y()},this.#K=(_)=>{this.#b(_)},this.#q=(_)=>{_.stopPropagation(),this.#H()},this.#X=(_)=>{_.stopPropagation(),this.#v()},this.#Y=()=>{this.#Z=!0},this.#R=()=>{if(this.#Z=!1,this.#_&&this.isConnected)this.#_=!1,this.#D()}}#O(){let _=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.getAttribute("text")!=="false",this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";let Z=this.#j[this.type]||this.#j.range,$=(J,Q)=>{let j=this.getAttribute(J),q=j===null||j.trim()===""?Q:Number(j);return Number.isFinite(q)?q:Q};if(this.min=$("min",Z.min),this.max=$("max",Z.max),this.step=$("step",Z.step),!(this.step>0))this.step=Z.step>0?Z.step:1;this.color=this.getAttribute("color")||Z?.color,this.default=this.#C(),this.value=this.#E(_)}#L(){if(!this.querySelector("[type=range]"))return!1;return this.getAttribute("text")!=="false"===!!this.querySelector("fig-input-number")}#A(){if(this.#O(),this.color)this.style.setProperty("--color",this.color);else this.style.removeProperty("--color");if(this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.input.className=this.type,this.input.min=String(this.min),this.input.max=String(this.max),this.input.step=String(this.step),this.input.value=String(this.value),this.input.disabled=this.disabled,this.text)this.input.setAttribute("tabindex","-1");else this.input.removeAttribute("tabindex");if(this.input.setAttribute("aria-valuemin",String(this.min)),this.input.setAttribute("aria-valuemax",String(this.max)),this.input.setAttribute("aria-valuenow",String(this.value)),this.figInputNumber=this.querySelector("fig-input-number"),this.figInputNumber){if(this.figInputNumber.setAttribute("placeholder",this.placeholder),this.figInputNumber.setAttribute("min",String(this.min)),this.figInputNumber.setAttribute("max",String(this.max)),this.figInputNumber.setAttribute("transform",String(this.transform)),this.figInputNumber.setAttribute("step",String(this.step)),this.figInputNumber.setAttribute("value",String(this.value)),this.units)this.figInputNumber.setAttribute("units",this.units);else this.figInputNumber.removeAttribute("units");if(this.precision!==null)this.figInputNumber.setAttribute("precision",String(this.precision));else this.figInputNumber.removeAttribute("precision");this.figInputNumber.disabled=this.disabled,this.figInputNumber.toggleAttribute("disabled",this.disabled)}}#I(){if(this.#g(),this.input.removeEventListener("input",this.#G),this.input.addEventListener("input",this.#G),this.input.removeEventListener("change",this.#N),this.input.addEventListener("change",this.#N),this.input.removeEventListener("keydown",this.#K),this.input.addEventListener("keydown",this.#K),this.input.removeEventListener("pointerdown",this.#Y),this.input.addEventListener("pointerdown",this.#Y),this.input.removeEventListener("pointerup",this.#R),this.input.addEventListener("pointerup",this.#R),this.input.removeEventListener("pointercancel",this.#R),this.input.addEventListener("pointercancel",this.#R),this.style.setProperty("--default",this.#z(this.default)),this.figInputNumber)this.#w(),this.figInputNumber.removeEventListener("input",this.#q),this.figInputNumber.addEventListener("input",this.#q),this.figInputNumber.removeEventListener("change",this.#X),this.figInputNumber.addEventListener("change",this.#X)}#D(){if(this.#O(),this.color)this.style.setProperty("--color",this.color);let _=M("input",{type:"range",tabindex:this.text?"-1":null,disabled:this.disabled,min:this.min,max:this.max,step:this.step,className:this.type,value:this.value,"aria-valuemin":this.min,"aria-valuemax":this.max,"aria-valuenow":this.value}),Z=M("div",{className:"fig-slider-input-container",role:"group"},_);for(let J of this.initialChildren??[])Z.appendChild(J);let $=[Z];if(this.text)$.push(M("fig-input-number",{placeholder:this.placeholder,min:this.min,max:this.max,transform:this.transform,step:this.step,value:this.value,units:this.units||null,precision:this.precision,disabled:this.disabled}));if(this.replaceChildren(...$),this.input=_,this.inputContainer=Z,this.figInputNumber=this.querySelector("fig-input-number"),this.#I(),this.datalist=this.querySelector("datalist"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||g()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("data-generated","slider-stepper"),this.datalist.setAttribute("id",g());let J=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1));for(let Q=0;Q<J;Q++){let j=document.createElement("option");j.setAttribute("value",this.min+Q*this.step),this.datalist.append(j)}this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.type==="delta"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("data-generated","slider-delta"),this.datalist.setAttribute("id",g());let J=document.createElement("option");J.setAttribute("value",this.default),this.datalist.append(J),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.#k())this.#i();this.#o(),this.#x()}connectedCallback(){if(this.initialChildren===null)this.initialChildren=Array.from(this.childNodes);if(this.#L()){this.#A(),this.#I(),this.#x();return}this.#D()}get value(){if(this.#$!=="")return this.#$;let _=this.getAttribute("value");if(_!==null)return String(this.#E(_));return""}set value(_){let Z=_===null||_===void 0?"":String(_),J=this.min!==void 0||this.max!==void 0?String(this.#E(Z)):Z;if(this.#$=J,this.getAttribute("value")!==J)this.#J=!0,this.setAttribute("value",J),this.#J=!1;if(this.input&&this.input.value!==J)this.input.value=J,this.input.setAttribute("aria-valuenow",J);if(this.figInputNumber)this.figInputNumber.setAttribute("value",J);if(this.input)this.#f()}get defaultValue(){return this.#C()}disconnectedCallback(){if(this.#_=!1,this.input)this.input.removeEventListener("input",this.#G),this.input.removeEventListener("change",this.#N),this.input.removeEventListener("keydown",this.#K),this.input.removeEventListener("pointerdown",this.#Y),this.input.removeEventListener("pointerup",this.#R),this.input.removeEventListener("pointercancel",this.#R);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#q),this.figInputNumber.removeEventListener("change",this.#X)}#H(){if(this.figInputNumber){let _=this.figInputNumber.value,Z=this.#E(_);this.value=Z,this.input.value=String(Z),this.#x(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#z(_){let{min:Z,max:$}=this.#T(),J=$-Z;if(J===0)return 0;return(Number(_)-Z)/J}#F(_){if(_===null||_===void 0)return null;if(typeof _==="string"&&_.trim()==="")return null;let Z=Number(_);return Number.isFinite(Z)?Z:null}#T(){let _=this.#F(this.min),Z=this.#F(this.max);if(_===null)_=0;if(Z===null)Z=_;if(_>Z)[_,Z]=[Z,_];return{min:_,max:Z}}#S(_){let{min:Z,max:$}=this.#T();return Math.min($,Math.max(Z,_))}#P(_){let{min:Z}=this.#T(),$=this.#F(this.step);if(!($>0))return!0;let J=(_-Z)/$,Q=Math.round(J),j=Number.EPSILON*Math.max(1,Math.abs(J))*16;return Math.abs(J-Q)<=j}#V(){return["range","hue","opacity"].includes(this.type)}#k(){if(!this.hasAttribute("default")||!this.#V())return!1;let{min:_,max:Z}=this.#T(),$=this.#F(this.getAttribute("default"));return $!==null&&$>=_&&$<=Z&&this.#P($)}#C(_=this.getAttribute("default")){let{min:Z,max:$}=this.#T(),J=this.#F(_);if(J!==null&&J>=Z&&J<=$&&(this.type!=="stepper"||this.#P(J)))return J;return this.type==="delta"?Math.min($,Math.max(Z,0)):Z}#h(){if(this.type==="delta"){let Z=this.#F(this.default);if(Z!==null)return this.#S(Z);return this.#S(0)}if(this.type==="range"){let{min:Z,max:$}=this.#T();return this.#S(Z+($-Z)/2)}let{min:_}=this.#T();return _}#E(_){let Z=this.#F(_);if(Z===null)return this.#h();return this.#S(Z)}#f(){let _=this.#z(this.value),Z=this.#z(this.default),$=_<Z?-1:1,J=_===Z?1:0;if(this.#U!==_)this.style.setProperty("--slider-complete",_),this.#U=_;if(this.#W!==Z)this.style.setProperty("--default",Z),this.#W=Z;if(this.#B!==$)this.style.setProperty("--slider-delta-direction",$),this.#B=$;if(this.#M!==J)this.style.setProperty("--unchanged",J),this.#M=J}#x(){let _=this.input.value;if(this.value=_,this.#f(),this.input.setAttribute("aria-valuenow",_),this.figInputNumber)this.figInputNumber.setAttribute("value",_)}#g(){if(!this.input)return;if(this.text){this.input.setAttribute("aria-hidden","true"),["aria-label","aria-labelledby","aria-describedby","aria-valuetext"].forEach((_)=>this.input.removeAttribute(_)),this.#w();return}this.input.removeAttribute("aria-hidden"),this.#Q.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.input.removeAttribute(_);else this.input.setAttribute(_,Z)})}#w(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.figInputNumber.removeAttribute(_);else this.figInputNumber.setAttribute(_,Z)})}#p(){this.#x(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#y(){this.#Z=!1,this.#x(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#b(_){if(this.disabled||!_.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(_.key))return;_.preventDefault();let Z=_.key==="ArrowRight"||_.key==="ArrowUp"?1:-1,$=this.#F(this.input.value)??this.#h(),J=this.#F(this.step)??1,Q=this.#E($+J*10*Z);this.value=Q,this.input.value=String(Q),this.#x(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#v(){if(this.figInputNumber){let _=this.figInputNumber.value,Z=this.#E(_);this.value=Z,this.input.value=String(Z),this.#x(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}#u(_,Z){if(!this.input)return;let $=this.#j[this.type]||this.#j.range,J=Z===null||String(Z).trim()===""?$[_]:Number(Z),Q=Number.isFinite(J)?J:$[_];if(_==="step"&&!(Q>0))Q=$.step>0?$.step:1;if(this[_]===Q&&this.input[_]===String(Q))return;if(this[_]=Q,this.input[_]=String(Q),_==="min")this.input.setAttribute("aria-valuemin",String(Q));else if(_==="max")this.input.setAttribute("aria-valuemax",String(Q));if(this.figInputNumber)this.figInputNumber.setAttribute(_,String(Q));if(!this.hasAttribute("default")&&this.type!=="delta")this.default=this.min;else this.default=this.#C();this.value=this.#E(this.value),this.#f(),this.#a(),this.#o()}#a(){if(this.type!=="stepper"||!this.datalist)return;let _=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1)),Z=document.createDocumentFragment();for(let $=0;$<_;$++){let J=document.createElement("option");J.setAttribute("value",this.min+$*this.step),Z.append(J)}this.datalist.replaceChildren(Z),this.input.setAttribute("list",this.datalist.id),this.#o()}#o(){let _=this.datalist?.getAttribute("data-generated")==="slider-default",Z=this.#k();if(_&&!Z)this.datalist.remove(),this.datalist=null,this.input?.removeAttribute("list");else if(!this.datalist&&Z)this.#i();if(!this.datalist)return;let $=String(this.default);if(_){let j=this.datalist.querySelector("option")??document.createElement("option");j.value=$,this.datalist.replaceChildren(j)}let J=[...this.datalist.querySelectorAll("option")];J.forEach((j)=>j.removeAttribute("default"));let Q=J.find((j)=>j.value===$);if(!Q&&this.type==="delta"&&this.datalist.getAttribute("data-generated")==="slider-delta")Q=document.createElement("option"),Q.value=$,this.datalist.replaceChildren(Q);Q?.setAttribute("default","true")}#i(){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("data-generated","slider-default"),this.datalist.setAttribute("id",g());let _=document.createElement("option");_.value=String(this.default),this.datalist.append(_),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.id)}#r(){if(this.#Z){this.#_=!0;return}this.#_=!1,this.#D()}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"]}focus(){if(this.text&&this.figInputNumber){this.figInputNumber.focus();return}this.input.focus()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="value"&&this.#J)return;if(this.input)switch(_){case"color":this.color=$,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=$!==null&&$!=="false",this.figInputNumber)this.figInputNumber.toggleAttribute("disabled",this.disabled);break;case"value":if(this.#Z)break;this.value=$,this.#x();break;case"transform":if(this.transform=Number($)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=$!==null?Number($):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=$!==null?$:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=this.#C($),this.#f(),this.#o();break;case"min":case"max":case"step":this.#u(_,$);break;case"units":if(this.units=$||"",this.figInputNumber)if(this.units)this.figInputNumber.setAttribute("units",this.units);else this.figInputNumber.removeAttribute("units");break;case"type":case"variant":if(!this.#Z)this[_]=$;this.#r();break;case"text":if(!this.#Z)this.text=$!=="false";this.#r();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#g();break;default:this[_]=this.input[_]=$,this.#x();break}}}F("fig-slider",R_);class U_ extends HTMLElement{#Z=!1;#_=!1;#J="";#$=!1;#Q;#j;#G;#N;#q;#X;#K;#Y;#R=null;#U=0;#W="";#B="";#M=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#Q=this.#h.bind(this),this.#j=this.#f.bind(this),this.#G=this.#f.bind(this),this.#N=this.#E.bind(this),this.#q=(_)=>{_.stopPropagation(),this.#C(_)},this.#X=(_)=>{_.stopPropagation();let Z=_.target.value;if(this.type==="number")Z=Number(Z)/(this.transform||1);this.value=Z,this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))},this.#K=()=>{if(!this.disabled)this.focus()},this.#Y=this.#L.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")&&this.getAttribute("multiline")!=="false",this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}if(this.input=this.#O(),this.input.readOnly=this.readonly,this.disabled=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.input.disabled=this.disabled,this.#H(),this.#z(),this.#F(),this.#T(),this.#S(),this.#V(),U0(this),this.#A(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#k(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#k(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#k(this.step));this.addEventListener("pointerdown",this.#N)}this.removeEventListener("click",this.#Y),this.addEventListener("click",this.#Y),this.input.removeEventListener("change",this.#q),this.input.addEventListener("change",this.#q),this.input.removeEventListener("input",this.#X),this.input.addEventListener("input",this.#X)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#q),this.input.removeEventListener("input",this.#X);if(this.removeEventListener("click",this.#Y),this.removeEventListener("pointerdown",this.#N),window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#j),window.removeEventListener("blur",this.#G),this.#R?.disconnect(),this.#R=null,this.#U)cancelAnimationFrame(this.#U),this.#U=0}focus(){this.input.focus()}#O(){let _=this.multiline,Z=this.querySelector("input,textarea");if(Z){if(_?Z.tagName==="TEXTAREA":Z.tagName==="INPUT")return Z;Z.remove()}let $;if(_)$=document.createElement("textarea"),$.value=this.value;else $=document.createElement("input"),$.type=this.type,$.value=this.type==="number"?this.#k(this.value):this.value;if($.setAttribute("data-generated","input-control"),this.name)$.name=this.name;return $.placeholder=this.placeholder,this.insertBefore($,this.querySelector('[slot="append"]')),$}#L(_){let Z=_.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;if(this.disabled)return;this.focus()}#A(){this.#R?.disconnect(),this.#R=new MutationObserver(()=>this.#I()),this.#R.observe(this,{childList:!0,characterData:!0,subtree:!0})}#I(){if(this.#U)return;this.#U=requestAnimationFrame(()=>{if(this.#U=0,!this.isConnected)return;this.#D()})}#D(){if(!this.input||!this.contains(this.input))this.input=this.#O(),this.input.readOnly=this.readonly,this.input.addEventListener("change",this.#q),this.input.addEventListener("input",this.#X);this.#H(),this.#z(),this.#F(),this.#T(),this.#S(),this.#V(),U0(this)}#H(){if(!this.input)return;this.#M.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.input.removeAttribute(_);else this.input.setAttribute(_,Z)})}#z(){let _=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){_?.remove();return}if(this.querySelector('[slot="prepend"]:not([data-generated])')){_?.remove();return}if(_){let J=_.querySelector("fig-icon");if(J&&J.getAttribute("name")!=="search")J.setAttribute("name","search");J?.removeAttribute("color");return}let $=b("search");$.setAttribute("slot","prepend"),$.setAttribute("data-generated","search-prefix"),$.addEventListener("click",this.#K),this.prepend($)}#F(){let _=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){_?.remove();return}if(this.querySelector('[slot="append"]:not([data-generated])')){_?.remove();return}if(_){let q=_.querySelector("fig-icon");if(q&&q.getAttribute("name")!=="close")q.setAttribute("name","close");return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","search-clear");let J=document.createElement("fig-tooltip");J.setAttribute("text","Clear search");let Q=document.createElement("fig-button");Q.setAttribute("variant","ghost"),Q.setAttribute("icon",""),Q.setAttribute("aria-label","Clear search");let j=b("close",{size:"small"});j.setAttribute("color","var(--figma-color-icon-secondary)"),Q.append(j),J.append(Q),$.append(J),this.append($),Q.addEventListener("click",(q)=>{if(q.preventDefault(),q.stopPropagation(),this.disabled)return;if(!this.input||this.input.value===""){this.focus();return}this.value="",this.input.value="",this.dispatchEvent(new CustomEvent("input",{detail:"",bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:"",bubbles:!0})),this.#T(),this.focus()})}#T(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#S(){let _=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){_?.remove(),this.#_=!1;return}if(this.querySelector('[slot="append"]:not([data-generated])')){_?.remove();return}if(_){this.#P(_);return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","password-toggle");let J=document.createElement("fig-tooltip"),Q=document.createElement("fig-button");Q.setAttribute("variant","ghost"),Q.setAttribute("icon","");let j=b("visible",{size:"small"});j.setAttribute("color","var(--figma-color-icon-secondary)"),Q.append(j),J.append(Q),$.append(J),this.append($),this.#P($),Q.addEventListener("click",(q)=>{if(q.preventDefault(),q.stopPropagation(),this.disabled)return;if(this.#_=!this.#_,this.input)this.input.type=this.#_?"text":"password";this.#P($),this.focus()})}#P(_){let Z=_.querySelector("fig-tooltip"),$=_.querySelector("fig-button"),J=_.querySelector("fig-icon"),Q=this.#_?"Hide password":"Show password";Z?.setAttribute("text",Q),$?.setAttribute("aria-label",Q),J?.setAttribute("name",this.#_?"visible":"hidden")}#V(){this.querySelectorAll('[data-generated="search-clear"] fig-button, [data-generated="password-toggle"] fig-button').forEach((_)=>{if(this.disabled)_.setAttribute("disabled","");else _.removeAttribute("disabled")})}#k(_){if(_==="")return"";let Z=Number(_)*(this.transform||1);return Z=this.#g(Z),Z}#C(_){_.stopPropagation();let Z=_.target.value,$=Z;if(this.type==="number")Z=Z/(this.transform||1),Z=this.#x(Z,!1),$=Z*(this.transform||1);this.value=Z,this.input.value=$,this.#T(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#h(_){if(this.type!=="number")return;if(_.buttons===0){this.#f();return}let Z=(this.step||1)*_.movementX,$=Number(this.input.value);$=$/(this.transform||1)+Z,$=this.#x($,!1);let J=$*(this.transform||1);$=this.#g($),J=this.#g(J),this.value=$,this.input.value=J,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#E(_){if(this.type!=="number")return;if(_.altKey||_.target.closest("[slot]"))this.#Z=!0,this.#W=this.style.userSelect,this.#B=document.body.style.cursor,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Q),window.addEventListener("pointerup",this.#j),window.addEventListener("pointercancel",this.#j),window.addEventListener("blur",this.#G)}#f(_){if(this.type!=="number")return;let Z=this.#Z;if(this.#Z=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#B,this.style.userSelect=this.#W,window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#j),window.removeEventListener("pointercancel",this.#j),window.removeEventListener("blur",this.#G),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#x(_,Z=!0){let $=_;if(this.type==="number"){if($=Number($),typeof this.min==="number")$=Math.max(Z?this.#k(this.min):this.min,$);if(typeof this.max==="number")$=Math.min(Z?this.#k(this.max):this.max,$);$=this.#g($)}return $}#g(_,Z=2){let $=Math.round(_*100)/100;return Number.isInteger($)?$:$.toFixed(Z)}get value(){return this.#J}set value(_){let Z=_??"";this.#J=Z;let $=String(Z);if(this.getAttribute("value")!==$)this.#$=!0,this.setAttribute("value",$),this.#$=!1;this.#w(Z)}#w(_){if(!this.input||this.#Z)return;let Z=this.type==="number"?String(this.#k(_)):String(_??"");if(this.input.value!==Z)this.input.value=Z;this.#T()}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","multiline","step","min","max","transform","name","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(_,Z,$){if(this.input)switch(_){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false",this.#V();break;case"readonly":this.readonly=$!==null&&$!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number($)||1,this.input.value=this.#k(this.value);break;case"value":if(this.#Z)break;let J=$;if(this.type==="number")J=this.#x(J,!1);if(this.#J=J??"",!this.#$)this.#w(this.#J);break;case"min":case"max":case"step":if($===null||$==="")this[_]=void 0,this.input.removeAttribute(_);else this[_]=this.input[_]=Number($),this.input.setAttribute(_,$);break;case"name":if(this[_]=this.input[_]=$||"",$)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=$??"",this.input.placeholder=this.placeholder;break;case"type":if(this.type=$||"text",this.input.type=this.type,this.removeEventListener("pointerdown",this.#N),this.type==="number")this.step=this.hasAttribute("step")?Number(this.getAttribute("step")):void 0,this.min=this.hasAttribute("min")?Number(this.getAttribute("min")):void 0,this.max=this.hasAttribute("max")?Number(this.getAttribute("max")):void 0,this.transform=Number(this.getAttribute("transform")||1),this.addEventListener("pointerdown",this.#N);this.#z(),this.#F(),this.#T(),this.#S(),this.#V();break;case"multiline":{let Q=$!==null&&$!=="false";if(Q!==this.multiline){this.multiline=Q;let j=this.input;j.removeEventListener("change",this.#q),j.removeEventListener("input",this.#X),j.remove(),this.input=this.#O(),this.input.readOnly=this.readonly,this.input.disabled=Boolean(this.disabled),this.input.addEventListener("change",this.#q),this.input.addEventListener("input",this.#X),this.#H()}break}case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#H();break;default:this[_]=this.input[_]=$;break}}}F("fig-input-text",U_);class n extends HTMLElement{#Z;#_;#J;#$;#Q;#j;#G;#N;#q;#X;#K;#Y;#R;#U;#W;#B;#M=!1;#O=null;#L=null;#A=0;#I=0;#D=!1;#H;#z;#F=null;#T=0;#S="";#P="";#V=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#k="px";static#C=350;static#h=60;#E(_){return(_||"").split(",").map((Z)=>Z.trim().toLowerCase()).filter(Boolean)}#f(_){let Z=(_||"").trim();if(!Z)return"";return(this.#U??[]).includes(Z.toLowerCase())?"":Z}#x(){this.#Y=this.#f(this.#R)}#g(_){if(_&&!this.#O)this.#O=document.createElement("span"),this.#O.className="fig-steppers",this.#O.append(M("button",{className:"fig-stepper-up",tabindex:"-1","aria-label":"Increase"}),M("button",{className:"fig-stepper-down",tabindex:"-1","aria-label":"Decrease"})),this.#O.addEventListener("pointerdown",(Z)=>{Z.preventDefault(),Z.stopPropagation();let $=Z.target.closest("button");if(!$||this.disabled||$.disabled)return;let J=$.classList.contains("fig-stepper-up")?1:-1;this.#p(Z,J),this.input.focus()}),this.append(this.#O);else if(!_&&this.#O)this.#b(),this.#O.remove(),this.#O=null;this.#w()}#w(){if(!this.#O)return;let _=this.#O.querySelector(".fig-stepper-up"),Z=this.#O.querySelector(".fig-stepper-down");if(!_||!Z)return;let $=this.input?this.#c(this.input.value):this.value,J=$!==""&&$!==null&&$!==void 0?Number($)/(this.transform||1):Number(this.value),Q=Number.isFinite(J),j=Boolean(this.disabled),q=Q&&typeof this.min==="number"&&J<=this.min,N=Q&&typeof this.max==="number"&&J>=this.max;_.disabled=j||N,Z.disabled=j||q}#p(_,Z){if(this.#b(),this.#L=_.pointerId,this.#D=this.#v(Z),window.addEventListener("pointerup",this.#H),window.addEventListener("pointercancel",this.#H),window.addEventListener("blur",this.#z),!this.#D)return;this.#A=window.setTimeout(()=>{this.#A=0,this.#I=window.setInterval(()=>{let $=this.#v(Z);if(this.#D||=$,!$)this.#y()},n.#h)},n.#C)}#y(){if(this.#A)clearTimeout(this.#A),this.#A=0;if(this.#I)clearInterval(this.#I),this.#I=0}#b(_=!0){if(this.#y(),window.removeEventListener("pointerup",this.#H),window.removeEventListener("pointercancel",this.#H),window.removeEventListener("blur",this.#z),this.#L=null,_&&this.#D)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}));this.#D=!1}#v(_){if(this.disabled)return!1;let Z=this.step||1,$=this.value,J=this.#c(this.input.value),Q=(J!==""?Number(J)/(this.transform||1):0)+Z*_;if(Q=this.#Z0(Q,!1),Q===$)return!1;return this.value=Q,this.input.value=this.#d(this.value),this.#w(),this.#m(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),!0}constructor(){super();this.#Z=this.#G0.bind(this),this.#_=this.#N0.bind(this),this.#J=this.#N0.bind(this),this.#$=this.#K0.bind(this),this.#Q=(_)=>{_.stopPropagation(),this.#$0(_)},this.#j=(_)=>{_.stopPropagation(),this.#_0(_)},this.#G=(_)=>{this.#s(_)},this.#N=(_)=>{this.#e(_)},this.#q=(_)=>{this.#l(_)},this.#H=(_)=>{if(this.#L!==null&&_.pointerId!==this.#L)return;this.#b()},this.#z=()=>this.#b(),this.#X=this.focus.bind(this),this.#K=this.#a.bind(this)}connectedCallback(){let _=this.getAttribute("value");this.value=_!==null&&_!==""?Number(_):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#R=this.getAttribute("units")||"";let Z=this.getAttribute("units-disallow");if(this.#U=this.#E(Z===null?n.#k:Z),this.#x(),this.#W=this.getAttribute("unit-position")||"suffix",this.#B=this.#X0(this.hasAttribute("precision")?this.getAttribute("precision"):null),this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));this.transform=Number(this.getAttribute("transform")||1);let $=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.input=this.#u(),this.#t(),this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.#g($),this.hasAttribute("disabled")){let J=this.getAttribute("disabled");this.disabled=this.input.disabled=J!=="false"}this.#w(),this.#m(),U0(this),this.addEventListener("pointerdown",this.#$),this.removeEventListener("click",this.#K),this.addEventListener("click",this.#K),this.#o(),this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.input.removeEventListener("input",this.#j),this.input.addEventListener("input",this.#j),this.input.removeEventListener("focus",this.#G),this.input.addEventListener("focus",this.#G),this.input.removeEventListener("blur",this.#N),this.input.addEventListener("blur",this.#N),this.input.removeEventListener("keydown",this.#q),this.input.addEventListener("keydown",this.#q)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#Q),this.input.removeEventListener("input",this.#j),this.input.removeEventListener("focus",this.#G),this.input.removeEventListener("blur",this.#N),this.input.removeEventListener("keydown",this.#q);if(this.removeEventListener("click",this.#K),this.removeEventListener("pointerdown",this.#$),window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#_),window.removeEventListener("blur",this.#J),this.#b(!1),this.#F?.disconnect(),this.#F=null,this.#T)cancelAnimationFrame(this.#T),this.#T=0}focus(){this.input.focus()}#u(){let _=this.querySelector("input");if(_)return _;let Z=document.createElement("input");if(Z.type="text",Z.inputMode="decimal",Z.setAttribute("data-generated","input-control"),this.name)Z.name=this.name;return Z.placeholder=this.placeholder,Z.value=this.#d(this.value),this.insertBefore(Z,this.querySelector('[slot="append"]')),Z}#a(_){let Z=_.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;this.focus()}#o(){this.#F?.disconnect(),this.#F=new MutationObserver(()=>this.#i()),this.#F.observe(this,{childList:!0,characterData:!0,subtree:!0})}#i(){if(this.#T)return;this.#T=requestAnimationFrame(()=>{if(this.#T=0,!this.isConnected)return;this.#r()})}#r(){if(!this.input||!this.contains(this.input))this.input=this.#u(),this.input.addEventListener("change",this.#Q),this.input.addEventListener("input",this.#j),this.input.addEventListener("focus",this.#G),this.input.addEventListener("blur",this.#N),this.input.addEventListener("keydown",this.#q);let _=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.#O&&!this.contains(this.#O))this.#O=null;this.#g(_),this.#t(),this.#m(),U0(this)}#t(){if(!this.input)return;this.#V.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.input.removeAttribute(_);else this.input.setAttribute(_,Z)})}#m(){if(!this.input)return;if(this.input.setAttribute("role","spinbutton"),typeof this.min==="number")this.input.setAttribute("aria-valuemin",String(this.min));else this.input.removeAttribute("aria-valuemin");if(typeof this.max==="number")this.input.setAttribute("aria-valuemax",String(this.max));else this.input.removeAttribute("aria-valuemax");let _=this.value===""?null:Number(this.value);if(Number.isFinite(_))this.input.setAttribute("aria-valuenow",String(_)),this.input.setAttribute("aria-valuetext",this.#d(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#c(_){if(!_)return"";if(!this.#Y){let J=_.replace(/[^\d.-]/g,""),Q=J.split(".");if(Q.length>2)J=Q[0]+"."+Q.slice(1).join("");return J}let Z=_.replace(this.#Y,"").trim();Z=Z.replace(/[^\d.-]/g,"");let $=Z.split(".");if($.length>2)Z=$[0]+"."+$.slice(1).join("");return Z}#d(_){if(_===""||_===null||_===void 0)return"";let Z=Number(_)*(this.transform||1);if(isNaN(Z))return"";if(Z=this.#n(Z),!this.#Y)return Z.toString();if(this.#W==="prefix")return this.#Y+Z;else return Z+this.#Y}#Q0(_){if(_===""||_===null||_===void 0)return"";let Z=Number(_)*(this.transform||1);return Z=this.#n(Z),Z.toString()}#s(_){this.#M=!0,setTimeout(()=>{let Z=_.target.value;if(Z&&this.#Y)if(this.#W==="prefix")_.target.setSelectionRange(this.#Y.length,Z.length);else{let $=Z.indexOf(this.#Y);if($>-1)_.target.setSelectionRange(0,$)}},0)}#e(_){this.#M=!1;let Z=this.#c(_.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#Z0($,!1),this.value=$,_.target.value=this.#d(this.value)}else this.value="",_.target.value="";this.#w(),this.#m()}#l(_){if(this.disabled)return;if(_.key!=="ArrowUp"&&_.key!=="ArrowDown")return;_.preventDefault();let Z=this.step||1,$=_.shiftKey?10:1,J=Z*$*(_.key==="ArrowUp"?1:-1),Q=this.#c(this.input.value),j=(Q!==""?Number(Q)/(this.transform||1):0)+J;j=this.#Z0(j,!1),this.value=j,this.input.value=this.#d(this.value),this.#w(),this.#m(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#_0(_){let Z=this.#c(_.target.value);if(Z!=="")this.value=Number(Z)/(this.transform||1);else this.value="";this.#w(),this.#m(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#$0(_){_.stopPropagation();let Z=this.#c(_.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#Z0($,!1),this.value=$,_.target.value=this.#d(this.value)}else this.value="",_.target.value="";this.#w(),this.#m(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#G0(_){if(this.disabled)return;if(_.buttons===0){this.#N0();return}let Z=(this.step||1)*_.movementX,$=this.#c(this.input.value),J=Number($)/(this.transform||1)+Z;J=this.#Z0(J,!1),this.value=J,this.input.value=this.#d(this.value),this.#w(),this.#m(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#K0(_){if(this.disabled)return;if(_.altKey||_.target.closest("[slot]"))this.#M=!0,this.#S=this.style.userSelect,this.#P=document.body.style.cursor,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Z),window.addEventListener("pointerup",this.#_),window.addEventListener("pointercancel",this.#_),window.addEventListener("blur",this.#J)}#N0(_){let Z=this.#M;if(this.#M=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#P,this.style.userSelect=this.#S,window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#_),window.removeEventListener("pointercancel",this.#_),window.removeEventListener("blur",this.#J),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#Z0(_,Z=!0){let $=Number(_);if(isNaN($))return"";if(typeof this.min==="number")$=Math.max(this.min,$);if(typeof this.max==="number")$=Math.min(this.max,$);return $=this.#L0($),$}#n(_){let Z=this.#B??2,$=this.#L0(_);if(this.#B!==null)return $.toFixed(Z);return Number.isInteger($)?String($):String(parseFloat($.toFixed(Z)))}#L0(_){let Z=this.#B??2,$=Math.pow(10,Z);return Math.round(_*$)/$}#X0(_){if(_===null||_===void 0||_==="")return null;let Z=Number(_);if(!Number.isFinite(Z))return 2;return Math.max(0,Math.min(100,Math.trunc(Z)))}static get observedAttributes(){return["value","placeholder","disabled","step","min","max","transform","name","units","units-disallow","unit-position","steppers","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(_,Z,$){if(this.input)switch(_){case"disabled":if(this.disabled=this.input.disabled=$!==null&&$!=="false",this.disabled)this.#b();this.#w();break;case"units":this.#R=$||"",this.#x(),this.input.value=this.#d(this.value),this.#m();break;case"units-disallow":this.#U=this.#E($===null?n.#k:$),this.#x(),this.input.value=this.#d(this.value),this.#m();break;case"unit-position":this.#W=$||"suffix",this.input.value=this.#d(this.value),this.#m();break;case"transform":this.transform=Number($)||1,this.input.value=this.#d(this.value),this.#m();break;case"value":if(this.#M)break;let J=$!==null&&$!==""?Number($):"";if(J!=="")J=this.#Z0(J,!1);this.value=J,this.input.value=this.#d(this.value),this.#w(),this.#m();break;case"min":case"max":case"step":if($===null||$===""){this[_]=void 0,this.#w(),this.#m();break}this[_]=Number($),this.#w(),this.#m();break;case"steppers":{let Q=$!==null&&$!=="false";this.#g(Q);break}case"precision":this.#B=this.#X0($),this.input.value=this.#d(this.value),this.#m();break;case"name":if(this[_]=this.input[_]=$||"",$)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=$??"",this.input.placeholder=this.placeholder;break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#t();break;default:this[_]=this.input[_]=$;break}}}F("fig-input-number",n);class W_ extends HTMLElement{constructor(){super()}connectedCallback(){this.src=this.getAttribute("src"),this.name=this.getAttribute("name"),this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials),this.setSrc(this.src),this.img=this.querySelector("img")}setSrc(_){if(this.src=_,!_){this.querySelector(":scope > img")?.remove(),this.img=null;return}let Z=this.querySelector(":scope > img")||document.createElement("img");if(Z.src=_,Z.alt=this.name||"",!Z.isConnected)this.replaceChildren(Z);this.img=Z}getInitials(_){return _?_.split(" ").map((Z)=>Z[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(_,Z,$){if(this[_]=$,_==="name"){if(this.img)this.img.alt=$||"";this.name=$,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials)}else if(_==="src")this.src=$,this.setSrc(this.src)}}F("fig-avatar",W_);class L_ extends HTMLElement{#Z=!1;#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#N=null;constructor(){super();this.#J=this.#Y.bind(this),this.#$=this.focus.bind(this),this.#Q=this.#R.bind(this),this.#j=this.#U.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(!this.isConnected)return;this.#X(),this.#q()})}#q(){if(this.#G||typeof MutationObserver>"u")return;this.#G=new MutationObserver(()=>{this.#X()}),this.#G.observe(this,{childList:!0})}#X(){let _=this.label,Z=this.#_;_?.removeEventListener("click",this.#J),_?.removeEventListener("click",this.#$),_?.removeEventListener("pointerenter",this.#Q),_?.removeEventListener("pointerleave",this.#j),Z?.removeEventListener("click",this.#J),this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((q)=>q.nodeType===Node.ELEMENT_NODE&&q.nodeName.toLowerCase().startsWith("fig-")&&!(q instanceof Element&&(q.classList.contains("fig-field-chevron")||["leading","trailing"].includes(q.getAttribute("slot"))))),this.#K();let $=this.input?.localName??"",J=this.input?.getAttribute?.("edit"),j=$==="fig-select"||$==="fig-menu"||$==="fig-dropdown"||$==="fig-tooltip"||$==="fig-fill-picker"||$==="fig-input-palette"&&(J==="false"||J==="picker")||this.input instanceof HTMLDialogElement;if(this.#Z=!!(this.input&&("open"in this.input)&&typeof this.input.open!=="function"&&!j),this.#Z&&this.label){if(!this.#_||!this.#_.isConnected)this.#_=b("chevron",{size:"small",slot:"leading",className:"fig-field-chevron"}),this.insertBefore(this.#_,this.label);this.#_.addEventListener("click",this.#J),this.label.addEventListener("click",this.#J)}else{if(this.#_)this.#_.removeEventListener("click",this.#J),this.#_.remove(),this.#_=null;if(this.input&&this.label){if(this.input.querySelectorAll("input, select, textarea").length!==1)this.label.addEventListener("click",this.#$)}}if(this.input&&this.label&&!this.#Z)this.#W();if(this.label)this.label.removeEventListener("pointerenter",this.#Q),this.label.addEventListener("pointerenter",this.#Q),this.label.removeEventListener("pointerleave",this.#j),this.label.addEventListener("pointerleave",this.#j)}#K(){if(this.#N?.disconnect(),this.#N=null,this.input?.localName!=="fig-input-palette"||typeof MutationObserver>"u")return;this.#N=new MutationObserver(()=>this.#X()),this.#N.observe(this.input,{attributes:!0,attributeFilter:["edit"]})}disconnectedCallback(){if(this.#G?.disconnect(),this.#G=null,this.#N?.disconnect(),this.#N=null,this.label)k.hide(this.label);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.label&&this.#$)this.label.removeEventListener("click",this.#$);if(this.label&&this.#Q)this.label.removeEventListener("pointerenter",this.#Q);if(this.label&&this.#j)this.label.removeEventListener("pointerleave",this.#j);if(this.#_&&this.#J)this.#_.removeEventListener("click",this.#J)}#Y(_){if(_.preventDefault(),_.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open}#R(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;k.show(this.label,this.label.textContent.trim())}#U(){if(this.label)k.hide(this.label)}#W(){if(!this.input||!this.label)return;let _=this.label.getAttribute("id")||g();this.label.setAttribute("id",_);let Z=this.input.querySelectorAll("input, select, textarea");if(Z.length===1){let $=Z[0],J=$.getAttribute("id")||g();if($.setAttribute("id",J),this.label.setAttribute("for",J),this.input.getAttribute("aria-labelledby")===_)this.input.removeAttribute("aria-labelledby");if(!$.hasAttribute("aria-labelledby"))$.setAttribute("aria-labelledby",_);return}if(this.label.removeAttribute("for"),!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-labelledby",_)}attributeChangedCallback(_,Z,$){switch(_){case"label":if(this.label)this.label.textContent=$,this.#W();break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let _=this.input.querySelectorAll("input, select, textarea");if(_.length===1)_[0].focus();else if(this.input.focus(),_.length===0)this.input.click()}}F("fig-field",L_);class O_ extends HTMLElement{rgba;hex;#Z=100;#_;#J;#$;#Q;#j=!1;#G=!1;#N=null;#q=this.#P.bind(this);#X=this.#V.bind(this);#K=this.#k.bind(this);#Y=this.#w.bind(this);#R=this.#h.bind(this);#U=this.#f.bind(this);#W=this.#E.bind(this);#B=this.#p.bind(this);constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(_){if(_===null||_===void 0||_===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(_))}#M(){let _={};for(let{name:Z,value:$}of this.attributes)if(Z.startsWith("picker-")&&Z!=="picker-anchor"&&Z!=="picker-experimental"){let J=Z.slice(7);if(/^on/i.test(J))continue;_[J]=$}if(!_["dialog-position"])_["dialog-position"]="left";return _}#O(){let _=this.#M();return Object.entries(_).map(([Z,$])=>`${Z}="${$}"`).join(" ")}connectedCallback(){if(this.#L()){this.#A();return}this.#H()}disconnectedCallback(){this.#I()}#L(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-swatch")}#A(){if(this.#C(this.getAttribute("value")),this.#_=this.querySelector("fig-swatch"),this.#J=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#Q=this.querySelector("fig-input-number"),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Q)this.#Q.setAttribute("value",String(this.#Z));if(this.#_)this.#_.setAttribute("background",this.hexOpaque),this.#_.setAttribute("alpha",String(this.rgba.a));this.#g(),this.#D()}#I(){if(this.#_)this.#_.removeEventListener("pointerdown",this.#q,{capture:!0}),this.#_.removeEventListener("click",this.#X,{capture:!0}),this.#_.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#K),this.#_.removeEventListener("input",this.#Y);this.#$?.removeEventListener("input",this.#R),this.#$?.removeEventListener("change",this.#U),this.#Q?.removeEventListener("input",this.#W),this.#Q?.removeEventListener("change",this.#U),this.#J?.removeEventListener("input",this.#B),this.#J?.removeEventListener("change",this.#U)}#D(){if(this.#_){this.#_.disabled=T(this,"disabled");let _=this.#_.querySelector('input[type="color"]');if(this.#$||this.hasAttribute("swatch-disabled"))_?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(_?.setAttribute("disabled",""),_)_.style.pointerEvents="none"}this.#_.addEventListener("pointerdown",this.#q,{capture:!0}),this.#_.addEventListener("click",this.#X,{capture:!0}),_?.addEventListener("keydown",this.#K),this.#_.addEventListener("input",this.#Y)}if(this.#$)this.#$.addEventListener("input",this.#R),this.#$.addEventListener("change",this.#U);if(this.#Q)this.#Q.addEventListener("input",this.#W),this.#Q.addEventListener("change",this.#U);if(this.#J)this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#U)}#H(){this.#C(this.getAttribute("value"));let _=this.getAttribute("alpha")!=="false",Z=this.#u,$=this.getAttribute("text")!=="false",J=M("fig-swatch",{background:this.hexOpaque,alpha:this.rgba.a,disabled:Z});if($){let Q=M("div",{className:"input-combo"},[J,M("fig-input-text",{type:"text",placeholder:"000000",value:this.hexOpaque.slice(1).toUpperCase(),disabled:Z})]);if(_)Q.appendChild(M("fig-tooltip",{text:"Opacity"},M("fig-input-number",{placeholder:"##",min:"0",max:"100",value:this.#Z,units:"%",disabled:Z})));this.replaceChildren(Q)}else this.replaceChildren(J);if(this.#_=J,this.#J=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#Q=this.querySelector("fig-input-number"),this.#g(),this.#$){let Q=this.rgbAlphaToHex(this.rgba,1);if(this.#$.value=Q.slice(1).toUpperCase(),this.#_)this.#_.background=Q}this.#D()}#z(){if(!this.#J)return;for(let[_,Z]of Object.entries(this.#M()))this.#J.setAttribute(_,Z);if(this.#J.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#J.removeAttribute("alpha");else this.#J.setAttribute("alpha","false");if(T(this,"disabled"))this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");this.#J.anchorElement=this,this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}))}#F(){if(!q0())return null;if(this.#J?.isConnected)return this.#z(),this.#J;let _=document.createElement("fig-fill-picker");return _.appendChild(M("span",{hidden:!0})),_.addEventListener("input",this.#B),_.addEventListener("change",this.#U),this.appendChild(_),this.#J=_,this.#z(),_}#T(){if(T(this,"disabled")||T(this,"swatch-disabled"))return!1;let _=this.#F();if(!_)return!1;return requestAnimationFrame(()=>_.open?.()),!0}#S(_){_.preventDefault(),_.stopPropagation(),_.stopImmediatePropagation?.()}#P(_){if(!q0())return;if(T(this,"disabled")||T(this,"swatch-disabled"))return;if(this.#G=!0,this.#j=!0,this.#N)clearTimeout(this.#N);this.#N=setTimeout(()=>{this.#j=!1,this.#G=!1,this.#N=null},500),this.#S(_)}#V(_){if(!this.#j)return;if(this.#j=!1,this.#N)clearTimeout(this.#N),this.#N=null;if(this.#S(_),this.#G)this.#G=!1,this.#T()}#k(_){if(_.key!=="Enter"&&_.key!==" ")return;if(!q0())return;if(!this.#T())return;this.#S(_)}#C(_){let Z=typeof _==="string"&&_.trim()?_.trim():"#D9D9D9",$=this.convertToRGBA(Z);if(!$||!Number.isFinite($.r)||!Number.isFinite($.g)||!Number.isFinite($.b)||!Number.isFinite($.a))Z="#D9D9D9",$={r:217,g:217,b:217,a:1};this.rgba=$,this.value=this.rgbAlphaToHex({r:isNaN(this.rgba.r)?0:this.rgba.r,g:isNaN(this.rgba.g)?0:this.rgba.g,b:isNaN(this.rgba.b)?0:this.rgba.b},this.rgba.a),this.hexWithAlpha=this.value.toUpperCase(),this.hexOpaque=this.hexWithAlpha.slice(0,7),this.#Z=Z.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#h(_){_.stopPropagation();let Z=_.target.value.replace(/#/g,"");if(this.#C("#"+Z),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Q)this.#Q.setAttribute("value",this.#Z);if(this.#_)this.#_.setAttribute("background",this.hexOpaque);this.#y()}#E(_){_.stopPropagation();let Z=Number(_.target.value)||0,J=Math.round(Z/100*255).toString(16).padStart(2,"0");if(this.#C(this.hexOpaque+J),this.#_)this.#_.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));this.#y()}#f(_){_.stopPropagation(),this.#b()}focus(){if(this.#$){this.#$.focus();return}this.#_?.focus()}#x(){return this.getAttribute("aria-label")||"Color"}#g(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#u)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let _=this.getAttribute("aria-describedby"),Z=this.getAttribute("aria-invalid"),$=this.getAttribute("aria-required"),J=this.getAttribute("aria-labelledby"),Q=this.#x();if(this.#$){if(this.#$.setAttribute("aria-label",`${Q} hex color`),_)this.#$.setAttribute("aria-describedby",_);else this.#$.removeAttribute("aria-describedby");if(Z)this.#$.setAttribute("aria-invalid",Z);else this.#$.removeAttribute("aria-invalid");if($)this.#$.setAttribute("aria-required",$);else this.#$.removeAttribute("aria-required")}if(this.#Q){if(this.#Q.setAttribute("aria-label",`${Q} opacity`),_)this.#Q.setAttribute("aria-describedby",_);else this.#Q.removeAttribute("aria-describedby");if(Z)this.#Q.setAttribute("aria-invalid",Z);else this.#Q.removeAttribute("aria-invalid");if($)this.#Q.setAttribute("aria-required",$);else this.#Q.removeAttribute("aria-required")}if(!this.#$){let j=this.#_?.querySelector('input[type="color"]');if(!j)return;if(J)j.setAttribute("aria-labelledby",J),j.removeAttribute("aria-label");else j.setAttribute("aria-label",Q),j.removeAttribute("aria-labelledby");if(_)j.setAttribute("aria-describedby",_);else j.removeAttribute("aria-describedby")}}#w(_){if(_.stopPropagation(),this.#C(_.target.value),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#y()}#p(_){_.stopPropagation();let Z=_.detail;if(Z&&Z.color){let $=Z.color;if(Z.alpha!==void 0){let J=Math.round(Z.alpha*255).toString(16).padStart(2,"0");$=Z.color+J}if(this.#C($),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Q&&Z.alpha!==void 0)this.#Q.setAttribute("value",Math.round(Z.alpha*100));if(this.#_)this.#_.setAttribute("background",this.hexOpaque),this.#_.setAttribute("alpha",this.rgba.a);this.#y()}}#y(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:this.#v()}))}#b(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:this.#v()}))}#v(){return{value:this.value,hex:this.hex,rgba:this.rgba,...t(this.hexOpaque,this.rgba?.a,Math.round((this.rgba?.a??1)*100))}}static get observedAttributes(){return["value","style","mode","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(_){this.setAttribute("mode",_)}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"value":if(this.#C($),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#_)this.#_.setAttribute("background",this.hexOpaque),this.#_.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));if(this.#Q)this.#Q.setAttribute("value",this.#Z);break;case"mode":this.#z();break;case"alpha":case"text":if(this.isConnected)this.#H();break;case"disabled":this.#a();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#g();break}}get#u(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#a(){let _=this.#u;for(let Z of[this.#_,this.#$,this.#Q]){if(!Z)continue;if(_)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}if(this.#g(),this.#J)this.#z()}rgbAlphaToHex({r:_,g:Z,b:$},J=1){_=Math.max(0,Math.min(255,Math.round(_))),Z=Math.max(0,Math.min(255,Math.round(Z))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(1,J));let Q=_.toString(16).padStart(2,"0"),j=Z.toString(16).padStart(2,"0"),q=$.toString(16).padStart(2,"0");if(J===1)return`#${Q}${j}${q}`.toUpperCase();let G=Math.round(J*255).toString(16).padStart(2,"0");return`#${Q}${j}${q}${G}`.toUpperCase()}convertToRGBA(_){if(typeof _!=="string")return null;let Z,$,J,Q=1;if(_.startsWith("#")){let j=_.slice(1);if(j.length===8)Q=parseInt(j.slice(6),16)/255,j=j.slice(0,6);Z=parseInt(j.slice(0,2),16),$=parseInt(j.slice(2,4),16),J=parseInt(j.slice(4,6),16)}else if(_.startsWith("rgba")||_.startsWith("rgb")){let j=_.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(j)Z=parseInt(j[1]),$=parseInt(j[2]),J=parseInt(j[3]),Q=j[4]?parseFloat(j[4]):1}else if(_.startsWith("hsla")||_.startsWith("hsl")){let j=_.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(j){let q=parseInt(j[1])/360,N=parseInt(j[2])/100,G=parseInt(j[3])/100;if(Q=j[4]?parseFloat(j[4]):1,N===0)Z=$=J=G;else{let K=(W,R,L)=>{if(L<0)L+=1;if(L>1)L-=1;if(L<0.16666666666666666)return W+(R-W)*6*L;if(L<0.5)return R;if(L<0.6666666666666666)return W+(R-W)*(0.6666666666666666-L)*6;return W},X=G<0.5?G*(1+N):G+N-G*N,Y=2*G-X;Z=K(Y,X,q+0.3333333333333333),$=K(Y,X,q),J=K(Y,X,q-0.3333333333333333)}Z=Math.round(Z*255),$=Math.round($*255),J=Math.round(J*255)}}else return null;return{r:Z,g:$,b:J,a:Q}}}F("fig-input-color",O_);var U1=["srgb","srgb-linear","display-p3","oklab","oklch","hsl"],W1=["shorter","longer","increasing","decreasing"],M_=new Set(["oklch","hsl"]);function K0(_){let Z={..._??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase();if(!U1.includes($))$="srgb";Z.interpolationSpace=$;let J=String(Z.hueInterpolation??"shorter").toLowerCase();return Z.hueInterpolation=W1.includes(J)?J:"shorter",Z}function B_(_){let Z=K0(_),$={...Z,interpolationSpace:Z.interpolationSpace};if(M_.has(Z.interpolationSpace))$.hueInterpolation=Z.hueInterpolation;else delete $.hueInterpolation;return $}function H_(_){let Z=K0(_);if(Z.interpolationSpace==="srgb")return"";if(M_.has(Z.interpolationSpace))return`in ${Z.interpolationSpace} ${Z.hueInterpolation} hue`;return`in ${Z.interpolationSpace}`}function z0(_){if(!_)return"";return`url("${String(_).replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}")`}function L1(_){let Z=String(_??"").trim();if(!Z||Z.startsWith("{")||Z.startsWith("#"))return!1;if(Z.startsWith("data:video/"))return!0;try{let $=new URL(Z,"https://fig.local").pathname;return/\.(mp4|webm|mov|m4v|ogv)$/i.test($)}catch{return/\.(mp4|webm|mov|m4v|ogv)(?:[?#]|$)/i.test(Z)}}function O1(_,Z,$,J){let Q=[..._].sort((A,z)=>A.position-z.position),j=Z*100;if(Q.length===0)return"#888888";if(j<=Q[0].position)return Q[0].color;if(j>=Q[Q.length-1].position)return Q[Q.length-1].color;let q=0;while(q<Q.length-1&&Q[q+1].position<j)q++;let N=Q[q],G=Q[q+1],K=G.position-N.position,X=K>0?(j-N.position)/K:0,Y=_0(N.color),W=_0(G.color),R,L,O,H=$||"oklab";if(H==="srgb-linear"){let A=a(Y.r),z=a(Y.g),U=a(Y.b),I=a(W.r),V=a(W.g),P=a(W.b);R=F0(A+(I-A)*X),L=F0(z+(V-z)*X),O=F0(U+(P-U)*X)}else if(H==="oklch"){let A=R0(Y.r,Y.g,Y.b),z=R0(W.r,W.g,W.b),U=h0(A.l,A.a,A.b),I=h0(z.l,z.a,z.b),V=U.l+(I.l-U.l)*X,P=U.c+(I.c-U.c)*X,S=y0(U.h,I.h,X,J||"shorter"),w=N1(V,P,S),f=b0(w.l,w.a,w.b);R=f.r,L=f.g,O=f.b}else if(H==="hsl"){let A=g0(Y.r,Y.g,Y.b),z=g0(W.r,W.g,W.b),U=y0(A.h,z.h,X,J||"shorter"),I=A.s+(z.s-A.s)*X,V=A.l+(z.l-A.l)*X,P=q1(U,I,V);R=P.r,L=P.g,O=P.b}else if(H==="srgb")R=Math.round(Y.r+(W.r-Y.r)*X),L=Math.round(Y.g+(W.g-Y.g)*X),O=Math.round(Y.b+(W.b-Y.b)*X);else{let A=R0(Y.r,Y.g,Y.b),z=R0(W.r,W.g,W.b),U=A.l+(z.l-A.l)*X,I=A.a+(z.a-A.a)*X,V=A.b+(z.b-A.b)*X,P=b0(U,I,V);R=P.r,L=P.g,O=P.b}return`#${R.toString(16).padStart(2,"0")}${L.toString(16).padStart(2,"0")}${O.toString(16).padStart(2,"0")}`.toUpperCase()}class F_ extends HTMLElement{#Z="solid";#_;#J;#$;#Q={color:"#D9D9D9",alpha:1};#j={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",opacity:1,stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#G={url:null,scaleMode:"fill",scale:50,opacity:1};#N={url:null,poster:null,scaleMode:"fill",scale:50,opacity:1,missing:!0};#q={live:!0,snapshot:null,deviceId:null,scaleMode:"fill",scale:50,opacity:1};#X={};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","alpha","webcam-mode","default-video","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#K(),this.#F()}disconnectedCallback(){this.#_=null,this.#J=null,this.#$=null}#K(){let _=this.getAttribute("value");if(!_)return;try{let Z=JSON.parse(_);if(Z.type)this.#Z=Z.type;switch(this.#Z){case"solid":if(Z.color)this.#Q.color=Z.color;if(Z.alpha!==void 0)this.#Q.alpha=Z.alpha;if(Z.opacity!==void 0)this.#Q.alpha=Z.opacity/100;break;case"gradient":if(Z.gradient)this.#j=K0({...this.#j,...Z.gradient}),this.#j.opacity=this.#W(Z.gradient.opacity??Z.opacity??Z.alpha,this.#j.opacity??1);else if(Z.opacity!==void 0||Z.alpha!==void 0)this.#j.opacity=this.#W(Z.opacity??Z.alpha,this.#j.opacity??1);break;case"image":if(Z.image)this.#G={...this.#G,...Z.image};break;case"video":if(Z.video)this.#N={...this.#N,...Z.video},this.#N.missing=!this.#N.url;break;case"webcam":if(Z.webcam&&typeof Z.webcam==="object"){let{stream:$,snapshot:J,...Q}=Z.webcam;if(this.#q={...this.#q,...Q},typeof J==="string"&&J)this.#q.snapshot=J}else if(Z.image?.url){if(this.#q.snapshot=Z.image.url,Z.image.scaleMode)this.#q.scaleMode=Z.image.scaleMode;if(Z.image.scale!=null)this.#q.scale=Z.image.scale}if(Z.opacity!==void 0)this.#q.opacity=Z.opacity;break;default:{let{type:$,...J}=Z;this.#X=J;break}}}catch(Z){if(_.startsWith("#")){if(this.#Z="solid",this.#Q.color=_.slice(0,7),_.length>7){let $=_.slice(7,9);this.#Q.alpha=parseInt($,16)/255}return}if(L1(_))this.#Z="video",this.#N.url=_.trim(),this.#N.missing=!1}}#Y(){let _={},Z=this.getAttribute("mode");if(Z)_.mode=Z;let $=this.getAttribute("alpha");if($)_.alpha=$;for(let{name:j,value:q}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor"&&j!=="picker-experimental"){let N=j.slice(7);if(/^on/i.test(N))continue;_[N]=q}if(!_["dialog-position"])_["dialog-position"]="left";let J=this.getAttribute("webcam-mode");if(J&&!_["webcam-mode"])_["webcam-mode"]=J;let Q=this.getAttribute("default-video");if(Q&&!_["default-video"])_["default-video"]=Q;return _}#R(){switch(this.#Z){case"solid":return this.#Q.color;case"gradient":{let Z=[...this.#j.stops].sort((Q,j)=>Q.position-j.position).map((Q)=>{let j=(Q.opacity??100)/100;if(j>=1)return`${Q.color} ${Q.position}%`;let{r:q,g:N,b:G}=_0(Q.color);return`rgba(${q}, ${N}, ${G}, ${j}) ${Q.position}%`}).join(", "),$=H_(this.#j),J=$?` ${$}`:"";switch(this.#j.type){case"radial":return`radial-gradient(circle${J}, ${Z})`;case"angular":return`conic-gradient(from ${this.#j.angle}deg${J}, ${Z})`;default:return`linear-gradient(${this.#j.angle}deg${J}, ${Z})`}}case"image":return this.#G.url?z0(this.#G.url):"#D9D9D9";case"video":return this.#N.poster?z0(this.#N.poster):"#D9D9D9";case"webcam":{let _=this.#q.snapshot||this.#_?.value?.webcam?.snapshot;return _?z0(_):""}default:return this.#L()}}#U(){return this.#R()}#W(_,Z=1){if(_===void 0||_===null||_==="")return Z;let $=Number(_);if(!Number.isFinite($))return Z;if($>1)return Math.max(0,Math.min(1,$/100));return Math.max(0,Math.min(1,$))}#B(){switch(this.#Z){case"solid":return this.#Q.alpha;case"gradient":return this.#j.opacity??1;case"image":return this.#G.opacity??1;case"video":return this.#N.opacity??1;case"webcam":return this.#q.opacity??1;default:return this.#W(this.#X.opacity??this.#X.alpha,1)}}#M(){return this.querySelector(`[slot="mode-${this.#Z}"]`)}#O(){let _=this.#M()?.getAttribute("label");if(_)return _;if(!this.#Z)return"Fill";return this.#Z.charAt(0).toUpperCase()+this.#Z.slice(1)}#L(){return this.#X.swatchBackground||this.#X.background||this.#X.css||this.#M()?.getAttribute("swatch-background")||""}#A(){if(!this.#_)return;for(let _ of[...this.querySelectorAll(":scope > [slot^='mode-']")])this.#_.append(_)}#I(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.setAttribute("aria-disabled",_?"true":"false");for(let Z of[this.#_,this.#J,this.#$]){if(!Z)continue;if(_)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}#D(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#I();let _=this.getAttribute("aria-label")||"Fill",Z=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),Q=(j,q)=>{if(!j)return;if(j.setAttribute("aria-label",q),Z)j.setAttribute("aria-describedby",Z);else j.removeAttribute("aria-describedby");if($)j.setAttribute("aria-invalid",$);else j.removeAttribute("aria-invalid");if(J)j.setAttribute("aria-required",J);else j.removeAttribute("aria-required")};Q(this.#_,`${_} picker`),Q(this.#$,`${_} hex color`),Q(this.#J,`${_} opacity`)}#H(_,Z){if(this.getAttribute("alpha")==="false")return null;return M("fig-tooltip",{text:"Opacity"},M("fig-input-number",{className:"fig-input-fill-opacity",placeholder:"##",min:"0",max:"100",value:_,units:"%",disabled:Z}))}#z(_){let Z=null,$=1;switch(this.#Z){case"solid":return[M("fig-input-text",{type:"text",className:"fig-input-fill-hex",placeholder:"000000",value:this.#Q.color.slice(1).toUpperCase(),disabled:_}),this.#H(Math.round(this.#Q.alpha*100),_)].filter(Boolean);case"gradient":Z=this.#j.type.charAt(0).toUpperCase()+this.#j.type.slice(1),$=this.#j.opacity??1;break;case"image":Z="Image",$=this.#G.opacity??1;break;case"video":Z="Video",$=this.#N.opacity??1;break;case"webcam":Z="Webcam",$=this.#q.opacity??1;break;default:Z=this.#O(),$=this.#W(this.#X.opacity??this.#X.alpha,1);break}return[M("label",{className:"fig-input-fill-label"},Z),this.#H(Math.round($*100),_)].filter(Boolean)}#F(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=JSON.stringify(this.value),$=this.#Y(),J=M("fig-swatch",{background:this.#R(),alpha:this.#B(),disabled:_}),Q=[...this.querySelectorAll("[slot^='mode-']")],j=M("fig-fill-picker",{value:Z,disabled:_,...$},[J,...Q]),q=M("div",{className:"input-combo"},[j,this.#z(_)]);this.replaceChildren(q),this.#T(),queueMicrotask(()=>{this.#A(),this.#k(),this.#S()})}#T(){this.#_=this.querySelector("fig-fill-picker"),this.#J=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let _=this.querySelector(".fig-input-fill-label");if(this.#D(),_&&this.#_)_.addEventListener("click",()=>{let Z=this.#_.querySelector("fig-swatch");if(Z)Z.click()});if(this.#_){let Z=this.getAttribute("picker-anchor");if(!Z||Z==="self")this.#_.anchorElement=this;else{let $=null;try{$=document.querySelector(Z)}catch{}if($)this.#_.anchorElement=$}this.#_.addEventListener("input",($)=>{$.stopPropagation();let J=$.detail;if(!J)return;let Q=J.type,j=Q!==this.#Z;switch(this.#Z=Q,Q){case"solid":this.#Q.color=J.color,this.#Q.alpha=J.alpha;break;case"gradient":if(J.gradient)this.#j=K0({...this.#j,...J.gradient});break;case"image":if(J.image)this.#G=J.image;break;case"video":if(J.video)this.#N={...this.#N,...J.video};break;case"webcam":if(J.webcam){let{stream:q,snapshot:N,...G}=J.webcam;if(this.#q={...this.#q,...G},typeof N==="string"&&N)this.#q.snapshot=N}else if(J.image?.url)this.#q.snapshot=J.image.url;if(!this.#q.snapshot){let q=this.#_?.value?.webcam?.snapshot;if(q)this.#q.snapshot=q}break;default:{let{type:q,colorSpace:N,...G}=J;this.#X=G;break}}if(j)this.#P();else this.#S();this.#k(),this.#h()}),this.#_.addEventListener("change",($)=>{$.stopPropagation(),this.#E()}),this.#_.addEventListener("loaded",($)=>{$.stopPropagation(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,detail:$.detail}))}),this.#_.addEventListener("webcamstream",($)=>{this.dispatchEvent(new CustomEvent("webcamstream",{bubbles:!0,composed:!0,detail:$.detail}))})}if(this.#$)this.#$.addEventListener("input",(Z)=>{Z.stopPropagation();let $="#"+Z.target.value.replace("#","");this.#Q.color=$,this.#V(),this.#h()}),this.#$.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#E()});if(this.#J)this.#J.addEventListener("input",(Z)=>{Z.stopPropagation();let $=parseFloat(Z.target.value),Q=(isNaN($)?100:$)/100;switch(this.#Z){case"solid":this.#Q.alpha=Q;break;case"gradient":this.#j.opacity=Q;break;case"image":this.#G.opacity=Q;break;case"video":this.#N.opacity=Q;break;case"webcam":this.#q.opacity=Q;break;default:this.#X.opacity=Q;break}this.#V(),this.#k(),this.#h()}),this.#J.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#E()})}#S(){switch(this.#Z){case"solid":if(this.#$)this.#$.setAttribute("value",this.#Q.color.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",Math.round(this.#Q.alpha*100));break;case"gradient":{let _=this.querySelector(".fig-input-fill-label");if(_){let Z=this.#j.type.charAt(0).toUpperCase()+this.#j.type.slice(1);_.textContent=Z}if(this.#J)this.#J.setAttribute("value",Math.round((this.#j.opacity??1)*100));break}case"image":if(this.#J)this.#J.setAttribute("value",Math.round((this.#G.opacity??1)*100));break;case"video":if(this.#J)this.#J.setAttribute("value",Math.round((this.#N.opacity??1)*100));break;case"webcam":if(this.#J)this.#J.setAttribute("value",Math.round((this.#q.opacity??1)*100));break;default:{let _=this.querySelector(".fig-input-fill-label");if(_)_.textContent=this.#O();if(this.#J)this.#J.setAttribute("value",Math.round(this.#W(this.#X.opacity??this.#X.alpha,1)*100));break}}}#P(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.querySelector(".input-combo");if(!Z)return;let $=Z.querySelector(".fig-input-fill-label"),J=Z.querySelector(".fig-input-fill-hex"),Q=Z.querySelector(".fig-input-fill-opacity"),j=Z.querySelectorAll("fig-tooltip");$?.remove(),J?.remove(),j.forEach((N)=>N.remove()),Z.append(...this.#z(_)),this.#J=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let q=this.querySelector(".fig-input-fill-label");if(this.#D(),q&&this.#_)q.addEventListener("click",()=>{let N=this.#_.querySelector("fig-swatch");if(N)N.click()});if(this.#$)this.#$.addEventListener("input",(N)=>{N.stopPropagation();let G="#"+N.target.value.replace("#","");this.#Q.color=G,this.#V(),this.#h()}),this.#$.addEventListener("change",(N)=>{N.stopPropagation(),this.#E()});if(this.#J)this.#J.addEventListener("input",(N)=>{N.stopPropagation();let G=parseFloat(N.target.value),X=(isNaN(G)?100:G)/100;switch(this.#Z){case"solid":this.#Q.alpha=X;break;case"gradient":this.#j.opacity=X;break;case"image":this.#G.opacity=X;break;case"video":this.#N.opacity=X;break;case"webcam":this.#q.opacity=X;break;default:this.#X.opacity=X;break}this.#V(),this.#C(X),this.#h()}),this.#J.addEventListener("change",(N)=>{N.stopPropagation(),this.#E()})}#V(){if(this.#_)this.#_.setAttribute("value",JSON.stringify(this.value));this.#k()}#k(){let _=this.#_?.querySelector("fig-swatch");if(!_)return;let Z=this.#R();if(this.#Z==="webcam"&&!Z){if((_.getAttribute("background")||"").startsWith("url(")){_.setAttribute("alpha",this.#B());return}}_.setAttribute("background",Z),_.setAttribute("alpha",this.#B())}#C(_){let Z=this.#_?.querySelector("fig-swatch");if(Z)Z.setAttribute("alpha",_)}#h(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#E(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get webcamStream(){return this.#_?.webcamStream??null}releaseWebcam(){this.#_?.releaseWebcam?.()}#f(){let _=this.#N.url??null;return{url:_,poster:this.#N.poster??null,scaleMode:this.#N.scaleMode||"fill",scale:this.#N.scale??50,opacity:this.#N.opacity??1,..._?{}:{missing:!0}}}#x(){return{live:this.#q.live!==!1,snapshot:this.#q.snapshot??this.#_?.value?.webcam?.snapshot??null,deviceId:this.#q.deviceId??null,scaleMode:this.#q.scaleMode||"fill",scale:this.#q.scale??50,opacity:this.#q.opacity??1}}get value(){switch(this.#Z){case"solid":return{type:"solid",colorSpace:"srgb",color:this.#Q.color,alpha:this.#Q.alpha,opacity:Math.round(this.#Q.alpha*100)};case"gradient":return{type:"gradient",colorSpace:"srgb",gradient:B_(this.#j),css:this.#U()};case"image":return{type:"image",colorSpace:"srgb",image:{...this.#G}};case"video":return{type:"video",colorSpace:"srgb",video:this.#f()};case"webcam":return{type:"webcam",colorSpace:"srgb",webcam:this.#x()};default:return{type:this.#Z,...this.#X}}}set value(_){if(typeof _==="string")this.setAttribute("value",_);else this.setAttribute("value",JSON.stringify(_))}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"value":let J=this.#Z;if(this.#K(),this.#_)if(this.#Z!==J)this.#F();else this.#V(),this.#S();break;case"disabled":this.#I();break;case"mode":case"webcam-mode":case"default-video":if(this.#_)if($)this.#_.setAttribute(_,$);else this.#_.removeAttribute(_);break;case"alpha":if(this.isConnected)this.#F();break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#D();break}}}F("fig-input-fill",F_);class A_ extends HTMLElement{#Z=[];#_=[];#J=[];#$=null;#Q=null;#j=null;#G=!1;#N=this.#W.bind(this);#q=()=>this.focus();#X=()=>{if(!this.#j)return;if(this.#j.hasAttribute("open")||this.#j.matches?.(":open")||this.#j.matches?.(":popover-open"))return;if(this.open)this.open=!1};static get observedAttributes(){return["value","disabled","min","max","open","fixed","edit"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){let Z=this.open;if(_&&this.#Y!=="false")this.setAttribute("open","");else this.removeAttribute("open");let $=this.open;if(Z!==$)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:$},bubbles:!0}))}get#K(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#Y(){let _=this.getAttribute("edit");if(_==="false")return"false";if(_==="picker")return"picker";return"true"}get#R(){let _=parseInt(this.getAttribute("min"));return isNaN(_)?2:_}get#U(){let _=parseInt(this.getAttribute("max"));return isNaN(_)?8:_}connectedCallback(){if(this.setAttribute("tabindex","-1"),this.removeEventListener("focus",this.#q),this.addEventListener("focus",this.#q),this.removeEventListener("keydown",this.#N),this.addEventListener("keydown",this.#N),this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{if(this.#$=null,!this.isConnected)return;this.#B(),this.#M(),this.#O()})}disconnectedCallback(){if(this.#$)cancelAnimationFrame(this.#$),this.#$=null;this.removeEventListener("keydown",this.#N),this.removeEventListener("focus",this.#q),this.#_=[],this.#J=[],this.#D()}#W(_){if(_.key!=="Enter"&&_.key!==" ")return;if(_.target!==this.querySelector(".palette-colors-inline"))return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Y==="false")return;_.preventDefault(),_.stopPropagation(),this.open=!0}attributeChangedCallback(_,Z,$){if(Z===$||this.#G)return;switch(_){case"value":this.#B(),this.#V(),this.#A();break;case"disabled":this.#k();break;case"min":case"max":case"fixed":this.#M(),this.#A();break;case"open":this.#C(),this.#I();break;case"edit":if(this.#Y==="false"&&this.open)this.open=!1;if(this.#Y!=="picker")this.#D();this.#M(),this.#O();break}}#B(){let _=this.getAttribute("value");if(!_){this.#Z=[];return}let Z=_.trim();try{let $=JSON.parse(Z);if(Array.isArray($)){this.#Z=$.map((J)=>{if(typeof J==="string")return{color:J.slice(0,7),alpha:J.length>7?parseInt(J.slice(7,9),16)/255:1};if(J&&typeof J==="object")return{color:J.color||"#D9D9D9",alpha:J.alpha!==void 0?J.alpha:J.opacity!==void 0?J.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch($){}if(Z.includes(",")){this.#Z=Z.split(",").map(($)=>{let J=$.trim();return{color:J.slice(0,7),alpha:J.length>7?parseInt(J.slice(7,9),16)/255:1}});return}if(Z.startsWith("#")){this.#Z=[{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}];return}this.#Z=[]}get value(){return this.#Z.map((_)=>({..._}))}set value(_){if(typeof _==="string")this.setAttribute("value",_);else this.setAttribute("value",JSON.stringify(_))}#M(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.#Y,$=Z!=="false";this.replaceChildren(),this.#_=[],this.#J=[];let J=document.createElement("div");if(J.className="palette-colors-inline",$){if(J.setAttribute("role","button"),J.setAttribute("tabindex",_?"-1":"+0"),J.setAttribute("aria-expanded",String(this.open)),J.setAttribute("aria-label","Edit palette colors"),Z==="picker")J.setAttribute("aria-haspopup","dialog")}else J.setAttribute("role","img"),J.setAttribute("aria-label","Palette colors");J.addEventListener("blur",()=>{J.style.removeProperty("outline"),J.style.removeProperty("outline-offset")});let Q=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0};if($)J.addEventListener("click",Q);let j=document.createElement("div");if(j.className="palette-colors",this.#Z.forEach((q,N)=>{j.appendChild(this.#H(q,N,_,{inline:!0}))}),J.appendChild(j),this.appendChild(J),this.#C(),Z==="true"){if(!this.#K)this.#T(_,this);let q=document.createElement("div");q.className="palette-colors-expanded",this.#Z.forEach((N,G)=>{if(q.appendChild(this.#H(N,G,_)),!this.#K)q.appendChild(this.#z(G,_))}),this.appendChild(q)}}#O(){if(this.#Y!=="picker"||customElements.get("fig-popup-palette")){this.#I();return}this.#Q??=customElements.whenDefined("fig-popup-palette").then(()=>{if(!this.isConnected||this.#Y!=="picker")return;this.#I()})}#L(){if(this.#j?.isConnected)return this.#j;if(!customElements.get("fig-popup-palette"))return null;let _=document.createElement("dialog",{is:"fig-popup-palette"});_.setAttribute("is","fig-popup-palette"),_.id=g(),_.anchor=this;let Z=($)=>{if($.stopPropagation(),!Array.isArray($.detail))return;this.#Z=$.detail.map((J)=>({color:J?.color||"#D9D9D9",alpha:Number.isFinite(Number(J?.alpha))?Math.max(0,Math.min(1,Number(J.alpha))):1})),this.#G=!0,this.setAttribute("value",JSON.stringify(this.#Z)),this.#G=!1,this.#V(),this.dispatchEvent(new CustomEvent($.type,{bubbles:!0,detail:this.value}))};return _.addEventListener("input",Z),_.addEventListener("change",Z),_.addEventListener("close",this.#X),_.addEventListener("toggle",this.#X),(l()??document.body).append(_),this.#j=_,this.querySelector(".palette-colors-inline")?.setAttribute("aria-controls",_.id),this.#A(),_}#A(){let _=this.#j;if(!_)return;_.setAttribute("value",JSON.stringify(this.#Z)),_.setAttribute("min",String(this.#R)),_.setAttribute("max",String(this.#U)),_.toggleAttribute("fixed",this.#K);let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";_.toggleAttribute("disabled",Z)}#I(){if(!this.isConnected||this.#Y!=="picker")return;if(!customElements.get("fig-popup-palette")){this.#O();return}if(!this.open){if(this.#j)this.#j.open=!1;return}if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.open=!1;return}let Z=this.#L();if(!Z)return;this.#A(),Z.open=!0}#D(){if(!this.#j)return;this.#j.removeEventListener("close",this.#X),this.#j.removeEventListener("toggle",this.#X),this.#j.open=!1,this.#j.remove(),this.querySelector(".palette-colors-inline")?.removeAttribute("aria-controls"),this.#j=null}#H(_,Z,$,{inline:J=!1}={}){let Q=_.alpha<1?_.color+Math.round(_.alpha*255).toString(16).padStart(2,"0"):_.color,j=document.createElement("fig-input-color");if(j.setAttribute("value",Q),J)j.setAttribute("text","false"),j.setAttribute("alpha","true"),j.setAttribute("swatch-disabled","");else j.setAttribute("text","true"),j.setAttribute("alpha","true"),j.setAttribute("full","");if($)j.setAttribute("disabled","");let q=J?this.#J:this.#_,N=(G)=>{G.stopPropagation();let K=G.currentTarget;this.#Z[Z]={color:K.hexOpaque||this.#Z[Z].color,alpha:K.rgba?K.rgba.a:this.#Z[Z].alpha};let X=q[Z];if(X){let Y=this.#Z[Z],W=Y.alpha<1?Y.color+Math.round(Y.alpha*255).toString(16).padStart(2,"0"):Y.color;X.setAttribute("value",W)}};if(j.addEventListener("input",(G)=>{N(G),this.#E()}),j.addEventListener("change",(G)=>{N(G),this.#f()}),J)this.#_.push(j);else this.#J.push(j);return j}#z(_,Z){let $=document.createElement("fig-button");if($.setAttribute("variant","ghost"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Remove color"),$.className="palette-remove-btn",Z||this.#Z.length<=this.#R)$.setAttribute("disabled","");$.appendChild(b("minus")),$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#F(_)});let J=document.createElement("fig-tooltip");return J.setAttribute("text","Remove color"),J.appendChild($),J}#F(_){if(this.#K)return;if(_<0||_>=this.#Z.length)return;if(this.#Z.length<=this.#R)return;this.#Z.splice(_,1),this.#_=[],this.#J=[],this.#M(),this.#f()}#T(_,Z=this){let $=this.#Z.length>=this.#U,J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Add color"),J.className="palette-add-btn",_||$)J.setAttribute("disabled","");J.appendChild(b("add")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Z.length>=this.#U)return;this.open=!0,this.#S({color:"#D9D9D9",alpha:1})});let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Add color"),Q.appendChild(J),Z.appendChild(Q)}#S(_){if(this.#K)return;this.#Z.push(_);let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#Z.length-1,J=this.#H(_,$,Z,{inline:!0}),Q=this.querySelector(".palette-colors");if(Q)Q.appendChild(J);let j=this.#H(_,$,Z),q=this.querySelector(".palette-colors-expanded");if(q)q.appendChild(j),q.appendChild(this.#z($,Z));if(this.#Z.length>=this.#U){let N=this.querySelector(".palette-add-btn");if(N)N.setAttribute("disabled","")}this.#h(Z),this.#f()}#P(_){let Z=this.#Z[_];if(!Z)return;let $=Z.alpha<1?Z.color+Math.round(Z.alpha*255).toString(16).padStart(2,"0"):Z.color,J=this.#_[_];if(J)J.setAttribute("value",$);let Q=this.#J[_];if(Q)Q.setAttribute("value",$)}#V(){if(this.#_.length!==this.#Z.length){this.#M();return}this.#Z.forEach((_,Z)=>{this.#P(Z)})}#k(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#_,...this.#J].forEach(($)=>{if(_)$.setAttribute("disabled","");else $.removeAttribute("disabled")});let Z=this.querySelector(".palette-add-btn");if(Z)if(_||this.#Z.length>=this.#U)Z.setAttribute("disabled","");else Z.removeAttribute("disabled");if(this.#h(_),this.#C(),this.#A(),_&&this.#Y==="picker"&&this.open)this.open=!1}#C(){let _=this.querySelector(".palette-colors-inline");if(!_)return;let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#Y==="false"){_.removeAttribute("tabindex"),_.removeAttribute("aria-disabled"),_.removeAttribute("aria-expanded"),_.removeAttribute("aria-haspopup");return}if(_.setAttribute("tabindex",Z?"-1":"+0"),_.setAttribute("aria-disabled",String(Z)),_.setAttribute("aria-expanded",String(this.open)),this.#Y==="picker")_.setAttribute("aria-haspopup","dialog");else _.removeAttribute("aria-haspopup")}focus(){if(this.#Y==="false"||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let _=this.querySelector(".palette-colors-inline");if(!_)return;_.style.outline="var(--figma-focus-outline)",_.style.outlineOffset="var(--figma-focus-outline-offset)",_.focus()}#h(_=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let Z=_||this.#Z.length<=this.#R;this.querySelectorAll(".palette-remove-btn").forEach(($)=>{if(Z)$.setAttribute("disabled","");else $.removeAttribute("disabled")})}#E(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#f(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}F("fig-input-palette",A_);class G0 extends HTMLElement{static SHIFT_SNAP=5;#Z;#_;#J=!1;#$=null;#Q=null;#j=null;#G=null;#N=null;#q=!1;anchorElement=null;#X=()=>{if(!this.#N)return;if(this.#N.hasAttribute("open")||this.#N.matches?.(":open")||this.#N.matches?.(":popover-open"))return;this.classList.remove("has-popup-open")};#K={type:"linear",angle:90,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode","size"]}get#Y(){let _=this.getAttribute("edit");if(_==="false")return"false";if(_==="picker")return"picker";return"true"}get#R(){return this.#Y==="true"}get#U(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#W(){if(!this.#_)return null;return this.#_.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#B(){if(!this.#_)return null;let _=this.#_.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(_)return _;let Z=document.activeElement;if(!(Z instanceof Element)||!this.#_.contains(Z))return null;return Z.closest("fig-handle:not(.fig-input-gradient-ghost)")}#M(_){if(!_||!this.#_)return;this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(Z!==_)Z.deselect()}),_.select(),_.focus()}#O(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#R?"-1":"0")}#L(_){let Z=K0(_);return{...Z,type:["linear","radial","angular"].includes(Z.type)?Z.type:"linear",angle:Number.isFinite(Number(Z.angle))?Number(Z.angle):90,centerX:Number.isFinite(Number(Z.centerX))?Number(Z.centerX):50,centerY:Number.isFinite(Number(Z.centerY))?Number(Z.centerY):50}}connectedCallback(){if(this.#z(),this.#C(),this.#A(),this.removeEventListener("click",this.#H),this.addEventListener("click",this.#H),this.removeEventListener("keydown",this.#D),this.addEventListener("keydown",this.#D),this.#R)document.addEventListener("keydown",this.#I)}#A(){if(this.#Y!=="picker"||customElements.get("fig-popup-gradient"))return;this.#G??=customElements.whenDefined("fig-popup-gradient").then(()=>{if(!this.isConnected||this.#Y!=="picker")return;this.#C()})}disconnectedCallback(){if(document.removeEventListener("keydown",this.#I),this.removeEventListener("click",this.#H),this.removeEventListener("keydown",this.#D),this.#x(),this.#Q)this.#Q.disconnect(),this.#Q=null;if(this.#j!==null)cancelAnimationFrame(this.#j),this.#j=null;clearTimeout(this.#$),this.removeEventListener("pointerenter",this.#b),this.removeEventListener("pointermove",this.#u),this.removeEventListener("pointerleave",this.#v),this.removeEventListener("click",this.#i),this.removeEventListener("dblclick",this.#o)}#I=(_)=>{let Z=document.activeElement,$=Z instanceof Node&&this.contains(Z),J=this.#_?.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)"),Q=!Z||Z===document.body||Z===document.documentElement;if(!$&&!(J&&Q))return;let j=Z&&(Z.tagName==="INPUT"||Z.tagName==="TEXTAREA"||Z.isContentEditable);if(!this.#_)return;if(_.key==="Tab"&&!j){let X=this.#B();if(!X)return;_.preventDefault();let Y=[...this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],W=Y.indexOf(X),R=_.shiftKey?(W-1+Y.length)%Y.length:(W+1)%Y.length;X.deselect(),this.#M(Y[R]);return}if((_.key==="ArrowLeft"||_.key==="ArrowRight")&&!j){let X=this.#B();if(!X)return;let Y=parseInt(X.dataset.stopIndex,10);if(isNaN(Y)||!this.#K.stops[Y])return;_.preventDefault();let W=(_.key==="ArrowRight"?1:-1)*(_.shiftKey?G0.SHIFT_SNAP:1),R=this.#K.stops[Y];R.position=Math.max(0,Math.min(100,R.position+W)),X.setAttribute("value",`${R.position}% 50%`);let L=X.closest("fig-tooltip");if(L)L.text=`${Math.round(R.position)}%`,L.setAttribute("show","true"),L.showPopup(),X.hideColorTip(),clearTimeout(this.#$),this.#$=setTimeout(()=>{L.removeAttribute("show"),X.showColorTip()},600);this.#s(),this.#l(),this.#_0();return}if(_.key!=="Delete"&&_.key!=="Backspace")return;if(j)return;if(this.#K.stops.length<=2)return;let q=this.#B();if(!q)return;let N=parseInt(q.dataset.stopIndex,10);if(isNaN(N)||!this.#K.stops[N])return;_.preventDefault(),this.#K.stops.splice(N,1),this.#m(),this.#s(),this.#l(),this.#_0();let G=Math.min(N,this.#K.stops.length-1),K=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[G];this.#M(K)};#D=(_)=>{if(this.#Y!=="picker")return;if(_.key!=="Enter"&&_.key!==" ")return;if(_.altKey||_.ctrlKey||_.metaKey)return;if(T(this,"disabled"))return;_.preventDefault(),this.#f()};#H=()=>{if(this.#Y!=="picker"||T(this,"disabled"))return;this.#f()};#z(){let _=this.getAttribute("value");if(!_)return;try{let Z=JSON.parse(_);if(Z?.type==="gradient"&&Z.gradient){this.#K=this.#L({...this.#K,...Z.gradient});return}if(Z?.gradient)this.#K=this.#L({...this.#K,...Z.gradient})}catch(Z){}}#F(){let _=this.#L(this.#K),$=[..._.stops].sort((j,q)=>j.position-q.position).map((j)=>{let q=(j.opacity??100)/100;if(q>=1)return`${j.color} ${j.position}%`;let{r:N,g:G,b:K}=_0(j.color);return`rgba(${N}, ${G}, ${K}, ${q}) ${j.position}%`}).join(", "),J=H_(_),Q=J?` ${J}`:"";if(this.#Y==="picker")switch(_.type){case"radial":return`radial-gradient(circle at ${_.centerX}% ${_.centerY}%${Q}, ${$})`;case"angular":return`conic-gradient(from ${_.angle}deg${Q}, ${$})`;default:return`linear-gradient(${_.angle}deg${Q}, ${$})`}return`linear-gradient(to right${Q}, ${$})`}#T(_){let Z=(_.opacity??100)/100;if(Z>=1)return _.color;let{r:$,g:J,b:Q}=_0(_.color);return`rgba(${$}, ${J}, ${Q}, ${Z})`}#S(){if(!this.#Z)return;let _=this.getAttribute("size");if(_)this.#Z.setAttribute("size",_);else this.#Z.removeAttribute("size")}#P(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";return this.#K.stops.map((Z,$)=>M("fig-tooltip",{action:"manual",text:`${Math.round(Z.position)}%`},M("fig-handle",{drag:!0,"drag-axes":"x","drag-surface":".fig-input-gradient-track",type:"color",tip:this.#U==="tip"?"color":null,color:this.#T(Z),value:`${Z.position}% 50%`,"hit-area":"4","data-stop-index":$,disabled:_})))}#V=null;#k=!1;#C(){this.#Q?.disconnect(),this.#Q=null;let _=T(this,"disabled"),Z=this.#Y,$=this.getAttribute("size"),J=M("fig-swatch",{background:this.#F(),size:$||null,disabled:_});if(Z==="picker"){this.setAttribute("aria-haspopup","dialog"),this.replaceChildren(J),this.#Z=J,this.#_=null,this.#O();return}this.removeAttribute("aria-haspopup");let Q=Z==="true"||Z==="picker",j=Q?M("div",{className:"fig-input-gradient-track"},this.#P()):null;if(this.replaceChildren(...j?[J,j]:[J]),this.#Z=J,this.#_=j,Q)this.#w(),this.#e();this.#O()}#h(){if(this.#N?.isConnected)return this.#N;if(!customElements.get("fig-popup-gradient"))return null;let _=document.createElement("dialog",{is:"fig-popup-gradient"});_.setAttribute("is","fig-popup-gradient"),_.id=g(),_.anchor=this.anchorElement||this;let Z=($)=>{if($.stopPropagation(),!$.detail?.gradient)return;if(this.#K=this.#L({...this.#K,...$.detail.gradient}),this.#q=!0,this.setAttribute("value",JSON.stringify(this.value)),this.#q=!1,typeof $.detail.css==="string"&&$.detail.css)this.#Z?.setAttribute("background",$.detail.css),this.#S();else this.#s();this.dispatchEvent(new CustomEvent($.type,{bubbles:!0,composed:!0,detail:this.value}))};return _.addEventListener("input",Z),_.addEventListener("change",Z),_.addEventListener("close",this.#X),_.addEventListener("toggle",this.#X),(l()??document.body).append(_),this.#N=_,this.setAttribute("aria-controls",_.id),this.#E(),_}#E(){if(!this.#N)return;this.#N.setAttribute("value",JSON.stringify(this.#K)),this.#N.toggleAttribute("disabled",T(this,"disabled")),this.#N.anchor=this.anchorElement||this}#f(){let _=this.#h();if(!_){this.#A();return}this.#E(),_.open=!0,this.classList.add("has-popup-open")}#x(){if(!this.#N)return;this.#N.removeEventListener("close",this.#X),this.#N.removeEventListener("toggle",this.#X),this.#N.open=!1,this.#N.remove(),this.#N=null,this.removeAttribute("aria-controls"),this.classList.remove("has-popup-open")}#g(_){return O1(this.#K.stops,_,this.#K.interpolationSpace,this.#K.hueInterpolation)}#w(){if(!this.#_||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let _=document.createElement("fig-handle");if(_.classList.add("fig-input-gradient-ghost"),_.setAttribute("type","color"),this.#U==="tip")_.setAttribute("tip","add");_.style.position="absolute",_.style.top="50%",_.style.transform="translate(-50%, -50%)",_.style.pointerEvents="none",_.style.opacity="0",_.style.transition="opacity 0.15s",this.#_.appendChild(_),this.#V=_,this.addEventListener("pointerenter",this.#b),this.addEventListener("pointermove",this.#u),this.addEventListener("pointerleave",this.#v),this.addEventListener("click",this.#i),this.addEventListener("dblclick",this.#o)}#p(){if(!this.#V)return;this.#V.style.opacity="1"}#y(){if(!this.#V)return;this.#V.style.opacity="0"}#b=()=>{if(this.#J)return;this.#p()};#v=()=>{this.#y()};#u=(_)=>{if(this.#J){this.#y();return}if(!this.#V||!this.#_)return;if(_.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#y();return}let Z=this.#_.getBoundingClientRect(),$=Math.max(0,Math.min(1,(_.clientX-Z.left)/Z.width));this.#V.style.left=`${$*100}%`;let J=this.#g($);this.#V.setAttribute("color",J),this.#p()};#a(){let _=this.#K.stops.length;if(_<2)return;for(let Z=0;Z<_;Z++)this.#K.stops[Z].position=Math.round(Z/(_-1)*100);this.#m(),this.#s(),this.#l(),this.#_0()}#o=(_)=>{if(!this.#_)return;if(!_.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#a(),this.#_.querySelectorAll("fig-handle[selected]").forEach((Z)=>{Z.removeAttribute("selected")})};#i=(_)=>{if(!this.#_)return;if(this.#J)return;if(this.#k){this.#k=!1;return}if(_.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(_.shiftKey){let q=_.target.closest("fig-handle"),N=parseInt(q?.dataset.stopIndex,10);if(this.#a(),!isNaN(N))this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((G)=>{if(parseInt(G.dataset.stopIndex,10)===N)G.select();else G.deselect()});_.stopPropagation()}return}let Z=this.#_.getBoundingClientRect(),$=Math.max(0,Math.min(1,(_.clientX-Z.left)/Z.width)),J=Math.round($*100),Q=this.#g($);this.#K.stops.push({position:J,color:Q,opacity:100}),this.#K.stops.sort((q,N)=>q.position-N.position);let j=this.#K.stops.findIndex((q)=>q.position===J&&q.color===Q);this.#m(),this.#s(),this.#l(),this.#_0(),requestAnimationFrame(()=>{let N=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[j];if(N)this.#M(N)})};#r(){if(this.#j=null,!this.isConnected)return;if(!this.#_)return;let _=this.#K.stops;this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z,$)=>{if($>=_.length)return;Z.removeAttribute("value"),Z.setAttribute("value",`${_[$].position}% 50%`)})}refreshLayout(){this.#r()}#t(){if(this.#j!==null)return;this.#j=requestAnimationFrame(()=>this.#r())}#m(){if(!this.#_)return;let _=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#K.stops;if(_.length!==Z.length){let $=this.#V;if(this.#_.replaceChildren(...this.#P()),$)this.#_.appendChild($);this.#c(),this.#d(),this.#t();return}for(let $=0;$<Z.length;$++){let J=_[$],Q=Z[$];if(J.dataset.stopIndex=$,J.setAttribute("value",`${Q.position}% 50%`),J.setAttribute("color",this.#T(Q)),this.#U==="tip")J.setAttribute("tip","color");else J.removeAttribute("tip");let j=J.closest("fig-tooltip");if(j)j.setAttribute("text",`${Math.round(Q.position)}%`)}this.#c()}#c(){if(!this.#_)return;let _=this.#U==="tip";if(this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(_)Z.setAttribute("tip","color");else Z.removeAttribute("tip")}),this.#V)if(_)this.#V.setAttribute("tip","add");else this.#V.removeAttribute("tip")}#d(){if(!this.#Q||!this.#_)return;this.#Q.disconnect(),this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((_)=>{this.#Q.observe(_,{attributes:!0,attributeFilter:["color"]})})}#Q0(){if(!this.#_)return;let _=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#K.stops,$=new Set;_.forEach((J)=>{let Q=Math.round(parseFloat(J.getAttribute("value"))||0),j=(J.getAttribute("color")||"").toUpperCase(),q=-1;for(let N=0;N<Z.length;N++){if($.has(N))continue;if(Z[N].position===Q&&Z[N].color.toUpperCase()===j){q=N;break}}if(q===-1){let N=1/0;for(let G=0;G<Z.length;G++){if($.has(G))continue;let K=Math.abs(Z[G].position-Q);if(K<N)N=K,q=G}}if(q!==-1)$.add(q),J.dataset.stopIndex=q})}#s(){if(!this.#Z)return;this.#Z.setAttribute("background",this.#F()),this.#S()}#e(){if(!this.#_)return;this.#_.addEventListener("pointerdown",(_)=>{if(T(this,"disabled"))return;let Z=_.target.closest("fig-handle:not(.fig-input-gradient-ghost)");if(Z){this.#M(Z);return}if(_.button!==0)return;_.preventDefault(),_.stopPropagation();let $=this.#_.getBoundingClientRect(),J=Math.max(0,Math.min(1,(_.clientX-$.left)/$.width)),Q=Math.round(J*100),j=this.#g(J);this.#K.stops.push({position:Q,color:j,opacity:100}),this.#K.stops.sort((K,X)=>K.position-X.position);let q=this.#K.stops.findIndex((K)=>K.position===Q&&K.color===j);this.#k=!0,this.#m(),this.#s(),this.#l(),this.#y();let G=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(G)this.#M(G),G.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:_.clientX,clientY:_.clientY,pointerId:_.pointerId,pointerType:_.pointerType,button:_.button,buttons:_.buttons}))}),this.#_.addEventListener("input",(_)=>{let Z=_.target.closest("fig-handle");if(!Z)return;if(_.stopPropagation(),_.detail?.color){let G=parseInt(Z.dataset.stopIndex,10);if(!isNaN(G)&&this.#K.stops[G]){if(this.#K.stops[G].color=_.detail.color,_.detail.opacity!==void 0)this.#K.stops[G].opacity=_.detail.opacity;else if(_.detail.alpha!==void 0)this.#K.stops[G].opacity=Math.round(_.detail.alpha*100);Z.setAttribute("color",this.#T(this.#K.stops[G])),this.#s(),this.#l()}return}if(!this.#J)Z.style.zIndex="5";this.#J=!0;let $=parseInt(Z.dataset.stopIndex,10);if(isNaN($)||!this.#K.stops[$])return;let J=_.detail?.px??0,Q=Math.round(J*100),j=Q,q=this.#_.getBoundingClientRect().width;if(_.detail?.shiftKey)j=Math.round(j/G0.SHIFT_SNAP)*G0.SHIFT_SNAP;else{let G=q>0?5/q*100:0;for(let K=0;K<this.#K.stops.length;K++){if(K===$)continue;if(Math.abs(this.#K.stops[K].position-j)<=G){j=this.#K.stops[K].position;break}}}if(this.#K.stops[$].position=j,j!==Q)Z.style.left=`${j/100*q}px`;let N=Z.closest("fig-tooltip");if(N&&this.#U!=="tip"){if(N.text=`${Math.round(j)}%`,!N.hasAttribute("show"))N.setAttribute("show","true"),Z.hideColorTip()}this.#s(),this.#l()}),this.#_.addEventListener("change",(_)=>{let Z=_.target.closest("fig-handle");if(!Z)return;if(_.stopPropagation(),_.detail?.color){let G=parseInt(Z.dataset.stopIndex,10);if(!isNaN(G)&&this.#K.stops[G]){if(this.#K.stops[G].color=_.detail.color,_.detail.opacity!==void 0)this.#K.stops[G].opacity=_.detail.opacity;Z.setAttribute("color",this.#T(this.#K.stops[G])),this.#s(),this.#_0()}return}Z.style.zIndex="";let $=Z.closest("fig-tooltip");if($)$.removeAttribute("show");Z.showColorTip();let J=parseInt(Z.dataset.stopIndex,10);if(isNaN(J)||!this.#K.stops[J])return;let Q=_.detail?.px??0,j=Math.round(Q*100),q=this.#_.getBoundingClientRect().width,N=q>0?5/q*100:0;for(let G=0;G<this.#K.stops.length;G++){if(G===J)continue;if(Math.abs(this.#K.stops[G].position-j)<=N){j=this.#K.stops[G].position;break}}this.#K.stops[J].position=j,Z.style.left=`${j/100*q}px`,this.#K.stops.sort((G,K)=>G.position-K.position),this.#Q0(),this.#s(),this.#_0(),requestAnimationFrame(()=>{this.#J=!1})}),this.#Q=new MutationObserver((_)=>{for(let Z of _){if(Z.attributeName!=="color")continue;let $=Z.target;if($.classList.contains("fig-input-gradient-ghost"))continue;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#K.stops[J])continue;let Q=$.getAttribute("color");if(!Q||!Q.startsWith("#"))continue;if(Q!==this.#K.stops[J].color)this.#K.stops[J].color=Q,this.#s(),this.#l()}}),this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((_)=>{this.#Q.observe(_,{attributes:!0,attributeFilter:["color"]})})}#l(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#_0(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:B_(this.#L(this.#K))}}set value(_){let Z=typeof _==="string"?_:JSON.stringify(_);if(this.getAttribute("value")===Z){this.#z(),this.#s(),this.#m();return}this.setAttribute("value",Z)}focus(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#R){let Z=this.#W();if(Z){Z.focus(_);return}}HTMLElement.prototype.focus.call(this,_)}attributeChangedCallback(_,Z,$){if(Z===$||this.#q)return;switch(_){case"value":this.#z(),this.#s(),this.#m(),this.#E();break;case"disabled":this.#$0(),this.#E();break;case"edit":if(this.#Y!=="picker")this.#x();if(this.#C(),this.#A(),this.#R)document.addEventListener("keydown",this.#I);else document.removeEventListener("keydown",this.#I);break;case"mode":this.#c();break;case"size":this.#S();break}}#$0(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#O(),this.#Z)if(_)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#_)for(let Z of this.#_.querySelectorAll("fig-handle"))if(_)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}F("fig-input-gradient",G0);class O0 extends HTMLElement{#Z=null;#_;#J;#$;#Q=!1;constructor(){super();if(this.input=document.createElement("input"),this.name=this.getAttribute("name")||"",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",g()),this.name)this.input.setAttribute("name",this.name);this.input.setAttribute("type","checkbox"),this.#_=this.handleInput.bind(this),this.#J=this.handleChange.bind(this),this.#$=(_)=>{if(_.target!==this||this.input.disabled)return;this.input.click()}}connectedCallback(){let _=this.querySelector(":scope > input");if(_)this.input=_;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("input",this.#_),this.input.addEventListener("input",this.#_),this.input.removeEventListener("change",this.#J),this.input.addEventListener("change",this.#J),this.removeEventListener("click",this.#$),this.addEventListener("click",this.#$),this.#q();let Z=this.querySelector(":scope > label");if(Z)this.#Z=Z,this.#Q=!1,this.#Z.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#j(),this.#Z.innerText=this.getAttribute("label");if(!this.hasAttribute("label")){let $=Array.from(this.childNodes).filter((J)=>J.nodeType===Node.TEXT_NODE).map((J)=>J.textContent||"").join(" ").trim();if($&&!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-label",$)}this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#j(){if(!this.#Z)this.#Z=document.createElement("label"),this.#Q=!0,this.#Z.setAttribute("for",this.input.id);if(this.#Z&&!this.#Z.parentNode&&this.input.parentNode)this.input.after(this.#Z)}render(){}#G(_){return this.hasAttribute(_)&&this.getAttribute(_)!=="false"}#N(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#q(){let _=this.#G("checked"),Z=this.#G("indeterminate")&&!_,$=this.#G("disabled");this.input.checked=_,this.input.indeterminate=Z,this.input.disabled=$,this.input.value=this.getAttribute("value")||"";let J=this.getAttribute("name")||this.name;if(J)this.input.setAttribute("name",J);else this.input.removeAttribute("name");if(Z)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#N()}focus(){this.input.focus()}get value(){return this.input.value}set value(_){this.input.value=_,this.setAttribute("value",_)}get checked(){return this.input.checked}set checked(_){if(this.input.checked=_,_)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#J),this.removeEventListener("click",this.#$)}attributeChangedCallback(_,Z,$){switch(_){case"label":if($)this.#j(),this.#Z.innerText=$;else if(this.#Z&&this.#Q)this.#Z.remove(),this.#Z=null,this.#Q=!1;break;case"checked":if(this.#G("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#q();break;case"indeterminate":this.#q();break;case"disabled":this.#q();break;case"name":if($)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"value":this.input.value=$||"";break;default:this.input[_]=$,this.input.setAttribute(_,$);break}}handleInput(_){if(_.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#N(),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}handleChange(_){_.stopPropagation(),this.#N(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}F("fig-checkbox",O0);class z_ extends O0{constructor(){super();this.input.setAttribute("type","radio");let _=this.getAttribute("name");if(_)this.input.setAttribute("name",_);else this.input.removeAttribute("name")}}F("fig-radio",z_);class T_ extends O0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}F("fig-switch",T_);class I0 extends HTMLElement{static observedAttributes=["type","options","placeholder","value","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Z=!1;#_=null;#J=null;#$=null;#Q=null;#j=!1;#G=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#N=this.#L.bind(this);#q=this.#A.bind(this);#X=this.#D.bind(this);#K=this.#H.bind(this);get value(){return this.getAttribute("value")||""}set value(_){this.setAttribute("value",_??"")}#Y(){return this.getAttribute("type")==="number"?"fig-input-number":"fig-input-text"}#R(){return M(this.#Y(),{placeholder:this.getAttribute("placeholder")||"",value:this.value})}#U(){return this.querySelector(":scope > .input-combo > :is(fig-input-text, fig-input-number)")?.localName===this.#Y()}#W(){if(this.#_=this.querySelector(":scope > .input-combo > :is(fig-input-text, fig-input-number)"),this.#$=this.querySelector("fig-button"),this.#J=this.querySelector("fig-select, fig-dropdown"),this.#J?.localName==="fig-select"&&customElements.get("fig-select"))this.#J.menuAnchor=this;if(this.#_)this.#_.setAttribute("value",this.value),this.#_.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#V()}connectedCallback(){if(this.#Q=Array.from(this.children).find((_)=>_.tagName==="FIG-SELECT"||_.tagName==="FIG-DROPDOWN")||null,this.#Z=this.#Q!==null,this.#Q)this.#Q.remove();if(this.#U()){if(this.#W(),!this.#Q)this.#Z=!!this.#J&&!this.#J.hasAttribute("data-fig-split-generated"),this.#Q=this.#Z?this.#J:null;this.#M()}else this.#B(),this.#M();this.#k(T(this,"disabled"))}disconnectedCallback(){this.#O()}#B(){let _=this.#T(),Z=this.#P(),$=this.#R(),J=this.#Q;if(!J&&customElements.get("fig-select"))J=M("fig-select",{icon:!0,variant:"input",options:_.join(","),label:Z,"aria-label":Z,"data-fig-split-generated":!0});if(!J)J=M("fig-dropdown",{type:"dropdown",label:Z,"data-fig-split-generated":!0},_.map((q)=>M("option",{},q.trim())));let Q=J,j=null;if(J.localName==="fig-dropdown"){if(!J.hasAttribute("type"))J.setAttribute("type","dropdown");j=M("fig-button",{type:"select",variant:"input",icon:!0},M("fig-icon",{name:"chevron",size:"small",slot:"append"})),j.append(J),Q=j}if(!J.hasAttribute("label"))J.setAttribute("label",Z);if(this.replaceChildren(M("div",{className:"input-combo"},[$,Q])),this.#_=$,this.#$=j,this.#J=J,J.localName==="fig-select"&&customElements.get("fig-select"))J.menuAnchor=this;this.#V()}#M(){this.#O(),this.#J?.addEventListener("input",this.#N),this.#J?.addEventListener("change",this.#q),this.#_?.addEventListener("input",this.#X),this.#_?.addEventListener("change",this.#K)}#O(){this.#J?.removeEventListener("input",this.#N),this.#J?.removeEventListener("change",this.#q),this.#_?.removeEventListener("input",this.#X),this.#_?.removeEventListener("change",this.#K)}#L(_){_.stopPropagation(),this.#I(_),this.#z()}#A(_){_.stopPropagation(),this.#I(_),this.#F()}#I(_){let Z=_.target.closest("fig-select, fig-dropdown")?.value??"";if(this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.#_)this.#_.setAttribute("value",Z)}#D(_){_.stopPropagation();let Z=_.target.value??"";this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.#z()}#H(_){_.stopPropagation();let Z=_.target.value??"";this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.#F()}#z(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#F(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#T(){return(this.getAttribute("options")||"").split(",").map((_)=>_.trim()).filter(Boolean)}#S(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Split input").trim()}#P(){return`${this.#S()} options`}#V(){if(this.#_)this.#G.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.#_.removeAttribute(_);else this.#_.setAttribute(_,Z)});if(this.#J){let _=this.#P();if(!this.#Z){if(this.#J.setAttribute("label",_),this.#J.localName==="fig-select")this.#J.setAttribute("aria-label",_)}else if(!this.#J.hasAttribute("aria-label")&&!this.#J.hasAttribute("label"))this.#J.setAttribute("label",_)}}#k(_){if(this.#_)if(_)this.#_.setAttribute("disabled","");else this.#_.removeAttribute("disabled");if(this.#$)if(_)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#J)if(_)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}focus(){this.#_?.focus()}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"type":{if(!this.#_||this.#_.localName===this.#Y())break;let J=this.#_.matches(":focus-within");this.#O();let Q=this.#R();if(this.#_.replaceWith(Q),this.#_=Q,this.#V(),this.#k(T(this,"disabled")),this.#M(),J)this.focus();break}case"options":if(this.#J&&!this.#Z)if(this.#J.localName==="fig-select")this.#J.setAttribute("options",$||"");else{let J=this.#T();this.#J.replaceChildren(...J.map((Q)=>{let j=document.createElement("option");return j.textContent=Q,j}))}break;case"placeholder":if(this.#_)this.#_.setAttribute("placeholder",$||"");this.#V();break;case"value":if(!this.#j&&this.#_)this.#_.setAttribute("value",$||"");break;case"disabled":this.#k($!==null&&$!=="false");break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#V();break}}}F("fig-split-input",I0);class k_ extends I0{}F("fig-combo-input",k_);class V0 extends HTMLElement{#Z="color";#_=null;#J=!1;constructor(){super();this.#_=this.#X.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#N(),this.#$(),this.#q()}#$(){let _=this.getAttribute("alpha");if(_!==null)this.style.setProperty("--alpha",_);else this.style.removeProperty("--alpha")}#Q(_){if(!_)return"color";let Z=_.toLowerCase();if(Z.includes("gradient"))return"gradient";if(Z.includes("url("))return"image";return"color"}#j(_){if(!_)return"#D9D9D9";if(_.startsWith("#"))return _.slice(0,7);try{let{ctx:Z}=D0(1,1);return Z.fillStyle=_,Z.fillStyle}catch{return"#D9D9D9"}}#G(_){if(!_||!_.includes("var("))return _;let Z=this.style.background;this.style.background=_;let $=getComputedStyle(this),J=$.backgroundImage,Q=$.backgroundColor;if(this.style.background=Z,J&&J!=="none")return J;return Q||_}#N(){let _=this.getAttribute("background");if(this.hasAttribute("background")&&!_?.trim()){if(this.#Z!=="image"||this.input){if(this.#Z="image",this.setAttribute("data-type","image"),this.input)this.input.removeEventListener("input",this.#_);this.replaceChildren(document.createElement("div")),this.input=null,this.#q()}this.style.setProperty("--swatch-background","none");return}let $=_||"#D9D9D9",J=$.includes("var("),Q=J?this.#G($):$,j=this.#Q(Q);if(j!==this.#Z||!this.input){if(this.#Z=j,this.setAttribute("data-type",this.#Z),this.input)this.input.removeEventListener("input",this.#_);if(this.#Z==="color"){let N=this.#j(Q),G=M("input",{type:"color",value:N});if(this.replaceChildren(document.createElement("div"),G),this.input=G,!J)this.input.addEventListener("input",this.#_);this.#q()}else this.replaceChildren(document.createElement("div")),this.input=null,this.#q()}else if(this.#Z==="color"&&this.input){let N=this.#j(Q);if(this.input.value!==N)this.input.value=N}let q=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--swatch-background",q?$:`linear-gradient(${$}, ${$})`)}#q(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",_?"true":"false"),this.input){this.input.disabled=_;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")}#X(_){this.#J=!0,this.setAttribute("background",_.target.value),this.#J=!1}get background(){return this.getAttribute("background")}set background(_){this.setAttribute("background",_)}focus(){if(this.input?.isConnected){this.input.focus();return}HTMLElement.prototype.focus.call(this)}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="background"){if(this.#J){let J=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--swatch-background",J?$:`linear-gradient(${$}, ${$})`);return}this.#N()}else if(_==="alpha")this.#$();else if(_==="disabled"||_==="aria-label"||_==="aria-labelledby"||_==="aria-describedby")this.#q()}get alpha(){return this.getAttribute("alpha")}set alpha(_){if(_===null||_===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",_)}}F("fig-swatch",V0);class D_ extends V0{}F("fig-chit",D_);var I_=["load","error"],V_=["loadstart","progress","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","durationchange","timeupdate","ratechange","resize","volumechange"],M1=[...new Set([...I_,...V_])];class M0 extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#N=this.#c.bind(this);#q=this.#s.bind(this);#X=this.#e.bind(this);#K=this.#l.bind(this);#Y=this.#Q0.bind(this);#R=null;#U=null;#W=null;#B=void 0;#M=null;#O=null;#L=null;#A=null;#I=null;#D=null;#H=null;static get observedAttributes(){return["src","type","alt","upload","loading-indicator","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.#Z}set src(_){if(this.#Z=_||"",_===null||_===void 0||_==="")this.removeAttribute("src");else this.setAttribute("src",_)}get file(){return this.#G}#z(){return this.#j||this.#Z||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#z())return null;if(!this.#_)return null;try{if(typeof this.#_.decode==="function")await this.#_.decode();else if(!this.#_.complete)await new Promise((J,Q)=>{this.#_.addEventListener("load",J,{once:!0}),this.#_.addEventListener("error",Q,{once:!0})})}catch{}let _=this.#_.naturalWidth,Z=this.#_.naturalHeight;if(!(_>0)||!(Z>0))return null;let $=document.createElement("canvas");return $.width=_,$.height=Z,$.getContext("2d").drawImage(this.#_,0,0),$.toDataURL()}connectedCallback(){this.#Z=this.getAttribute("src")||"";let _=this.getAttribute("aspect-ratio");if(_)this.style.setProperty("--fig-media-aspect-ratio",_);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.#C(),this.#E(),this.#T(),this.#y(),this.#P(),this.#f(),this.#w(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#t();this.#$=this.querySelector("fig-input-file[data-generated]"),this.#$?.removeEventListener("change",this.#N),this.#$?.addEventListener("change",this.#N)}disconnectedCallback(){if(this.#$?.removeEventListener("change",this.#N),this.#k(),this.#F(),this.#r(),this.#Q)URL.revokeObjectURL(this.#Q),this.#Q=null;this.#j=null}#F(){if(!this.#_)return;if(M1.forEach((_)=>{this.#_.removeEventListener(_,this.#Y)}),this.#_.tagName==="VIDEO")this.#_.removeEventListener("play",this.#q),this.#_.removeEventListener("pause",this.#X),this.#_.removeEventListener("ended",this.#K)}#T(){if(this.#F(),!this.#_)return;if((this.#_.tagName==="VIDEO"?V_:I_).forEach((Z)=>{this.#_.addEventListener(Z,this.#Y)}),this.#_.tagName!=="VIDEO")return;this.#_.addEventListener("play",this.#q),this.#_.addEventListener("pause",this.#X),this.#_.addEventListener("ended",this.#K)}#S(){return this.mediaKind==="image"&&this.getAttribute("loading-indicator")!=="false"&&this.#J?.hasAttribute("data-generated")&&this.#_?.hasAttribute("data-generated")}#P(){this.#V();let _=this.#z();if(!_||!this.#S()){this.#k();return}if(this.#_?.tagName==="IMG"&&this.#_.complete&&this.#_.currentSrc){this.#k();return}if(this.#W===_)return;this.#k(),this.#W=_,this.#B=this.getAttribute("aria-busy"),this.setAttribute("aria-busy","true"),this.#U=setTimeout(()=>{if(this.#U=null,this.#W!==_||!this.isConnected||!this.#S())return;let Z=document.createElement("fig-spinner");Z.setAttribute("data-generated",""),Z.setAttribute("data-loading-indicator",""),Z.setAttribute("slot","overlay"),Z.setAttribute("size","small"),Z.setAttribute("aria-hidden","true"),this.append(Z),this.#R=Z},150)}#V(){let _=this.#_?.tagName==="IMG"?this.#_:null,Z=_?.currentSrc||_?.getAttribute("src")||this.#z();this.toggleAttribute("loaded",Boolean(Z&&_?.complete&&_.naturalWidth>0))}#k(){if(this.#U!==null)clearTimeout(this.#U),this.#U=null;if(this.#R?.remove(),this.#R=null,this.#W=null,this.#B!==void 0){if(this.#B===null)this.removeAttribute("aria-busy");else this.setAttribute("aria-busy",this.#B);this.#B=void 0}}#C(){if(this.#J?.isConnected)return;let _=this.querySelector(":scope > fig-preview");if(_){this.#J=_;return}let Z=document.createElement("fig-preview");Z.setAttribute("data-generated",""),this.prepend(Z),this.#J=Z}#h(){let _=this.mediaKind==="video"?"video":"img";return this.querySelector(`${_}:not([data-generated])`)}#E(){let _=this.#h();if(_){if(this.#C(),this.#_&&this.#_!==_){if(this.#F(),this.#_.hasAttribute("data-generated"))this.#_.remove()}if(this.#_=_,this.#J&&_.parentElement!==this.#J)this.#J.append(_);this.#T(),this.#f();return}this.#C();let Z=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#_&&this.#_.tagName!==Z){if(this.#F(),this.#_.hasAttribute("data-generated"))this.#_.remove();this.#_=null}if(this.#_)return;if(this.mediaKind==="video"){let $=document.createElement("video");$.setAttribute("data-generated",""),$.className="fig-media-element",$.setAttribute("playsinline",""),$.preload="auto",this.#J.append($),this.#_=$;let J=()=>{if(this.#_?.autoplay)return;try{this.#_.currentTime=0.001}catch{}};this.#_.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.#J.append($),this.#_=$}this.#T()}#f(){if(!this.#_)return;if(this.#_.tagName==="IMG"){if(this.hasAttribute("alt")||this.#_.hasAttribute("data-generated"))this.#_.alt=this.getAttribute("alt")||"";return}if(this.#_.tagName!=="VIDEO")return;["aria-label","aria-labelledby","title"].forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.#_.removeAttribute(_);else this.#_.setAttribute(_,Z)})}#x(){return this.querySelector(":scope > figcaption:not([data-generated])")}#g(){return Array.from(this.querySelectorAll(":scope > figcaption[data-generated]"))}#w(){let _=this.#x(),Z=this.#g();if(_){Z.forEach((j)=>j.remove());return}let $=this.getAttribute("caption")||"";if(!$){Z.forEach((j)=>j.remove());return}let J=Z[0]||document.createElement("figcaption");if(Z.slice(1).forEach((j)=>j.remove()),!J.hasAttribute("data-generated"))J.setAttribute("data-generated","");if(J.textContent!==$)J.textContent=$;let Q=this.querySelector(":scope > fig-media-controls");if(Q)Q.before(J);else if(this.#J?.isConnected)this.#J.after(J);else if(!J.isConnected)this.append(J)}#p(_,Z=!1){if(!this.hasAttribute(_))return Z;return this.getAttribute(_)!=="false"}#y(){if(!this.#_)return;if(!this.#_.hasAttribute("data-generated"))return;let _=this.#z();if(this.#_.getAttribute("src")!==_){if(this.removeAttribute("loaded"),_)this.#_.setAttribute("src",_);else if(this.#_.removeAttribute("src"),this.#_.tagName==="VIDEO")this.#_.load()}if(this.#_.tagName==="IMG"){this.#f(),this.#P();return}let Z=this.getAttribute("poster");if(Z)this.#_.setAttribute("poster",Z);else this.#_.removeAttribute("poster");this.#_.controls=!1,this.#_.removeAttribute("controls"),this.#_.autoplay=this.#p("autoplay",!1),this.#_.loop=this.#p("loop",!1),this.#_.muted=this.#p("muted",!1),this.#_.playsInline=!0,this.#f(),this.#u(),this.#v(),this.#P()}get mediaEl(){return this.#_}#b(){if(this.mediaKind!=="video")return!1;return Boolean(this.#z())}#v(){let _=this.#M||this.querySelector(":scope > fig-media-controls");if(!_)return;if(this.mediaKind!=="video")return;if(this.#b()){if(_.hasAttribute("data-fig-empty-disabled"))_.removeAttribute("disabled"),_.removeAttribute("data-fig-empty-disabled");return}_.setAttribute("disabled",""),_.setAttribute("data-fig-empty-disabled",""),_.playing=!1,_.time=0,_.duration=0}#u(){if(this.mediaKind!=="video"){this.#r();return}let _=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(_){if(this.#M!==_)this.#r(),this.#M=_;this.#o(),this.#v();return}if(this.#p("controls",!1))this.#a();else this.#r()}#a(){let _=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Z=_[0];if(_.slice(1).forEach((J)=>J.remove()),Z){this.#M=Z,this.#o(),this.#v();return}let $=document.createElement("fig-media-controls");$.setAttribute("data-generated",""),this.append($),this.#M=$,this.#o(),this.#v()}#o(){if(!this.#M||!this.#_)return;if(this.#O===this.#_&&this.#L===this.#M){this.#v();return}this.#i();let _=this.#M,Z=this.#_;this.#O=Z,this.#L=_;let $=null,J=()=>{if(this.#v(),!this.#b())return;if(_.playing=!Z.paused&&!Z.ended,Number.isFinite(Z.duration))_.duration=Z.duration;if($!==null)if(Math.abs(Z.currentTime-$)<0.25)$=null;else return;_.time=Z.currentTime||0},Q=()=>{if(!this.#b())return;let N=Z.play?.();if(N&&typeof N.catch==="function")N.catch(()=>{})},j=()=>Z.pause?.(),q=(N)=>{if(!this.#b())return;let G=Number(N?.detail?.time);if(!Number.isFinite(G))return;$=G;try{Z.currentTime=G}catch{}};this.#A=J,this.#I=Q,this.#D=j,this.#H=q,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),_.addEventListener("play",Q),_.addEventListener("pause",j),_.addEventListener("seek",q),J()}#i(){let _=this.#O,Z=this.#L;if(_&&this.#A)_.removeEventListener("play",this.#A),_.removeEventListener("pause",this.#A),_.removeEventListener("ended",this.#A),_.removeEventListener("timeupdate",this.#A),_.removeEventListener("loadedmetadata",this.#A),_.removeEventListener("durationchange",this.#A),_.removeEventListener("seeked",this.#A);if(Z){if(this.#I)Z.removeEventListener("play",this.#I);if(this.#D)Z.removeEventListener("pause",this.#D);if(this.#H)Z.removeEventListener("seek",this.#H)}this.#O=null,this.#L=null,this.#A=null,this.#I=null,this.#D=null,this.#H=null}#r(){this.#i(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((_)=>{_.remove()}),this.#M=null}toggle(){if(!this.#_||this.mediaKind!=="video")return;if(this.#_.paused||this.#_.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#_)return;let _=this.#_.play();if(_&&typeof _.catch==="function")_.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#_)return;this.#_.pause()}#t(){let _=document.createElement("fig-input-file");_.setAttribute("data-generated",""),_.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),_.setAttribute("variant","overlay");let Z=this.getAttribute("label")||"Upload";if(_.setAttribute("label",this.#Z?"Replace":Z),this.#G?.name)_.setAttribute("filename",this.#G.name);else if(this.#Z)_.setAttribute("url",this.#Z);_.addEventListener("change",this.#N),this.#C(),this.#J.append(_),this.#$=_}#m(){if(this.#$)this.#$.removeEventListener("change",this.#N),this.#$.remove(),this.#$=null}#c(_){if(_.target!==this.#$)return;let Z=_.detail?.files?.[0],$=_.detail?.cleared===!0;if(!Z){if(this.#Q)URL.revokeObjectURL(this.#Q),this.#Q=null;if(this.#G=null,this.#j=null,$)this.src="";if(this.#y(),this.#$){let J=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Z?"Replace":J),this.#$.removeAttribute("filename"),this.#Z)this.#$.setAttribute("url",this.#Z);else this.#$.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#Q)URL.revokeObjectURL(this.#Q);if(this.#G=Z,this.#Q=URL.createObjectURL(Z),this.#j=this.#Q,this.#y(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Z,src:this.#Q}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#$)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",Z.name),this.#$.setAttribute("label","Replace")}#d(_){if(!this.#_)return;this.dispatchEvent(new CustomEvent(_,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Z||"",currentTime:this.#_.currentTime,duration:this.#_.duration}}))}#Q0(_){let Z=this.#_;if(!Z||_.currentTarget!==Z)return;if(Z.tagName==="IMG"&&(_.type==="load"||_.type==="error"))this.toggleAttribute("loaded",_.type==="load"),this.#k();let $={src:this.#z(),media:Z,originalEvent:_};if(Z.tagName==="VIDEO")$.currentTime=Z.currentTime,$.duration=Z.duration,$.readyState=Z.readyState,$.networkState=Z.networkState,$.error=Z.error;if(this.dispatchEvent(new CustomEvent(_.type,{bubbles:!0,cancelable:!1,composed:!0,detail:$})),Z.tagName==="IMG"&&_.type==="load"||Z.tagName==="VIDEO"&&_.type==="loadeddata")this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,composed:!0,detail:{src:$.src,file:this.#G,media:Z}}))}#s(){this.#d("play")}#e(){this.#d("pause")}#l(){this.#d("ended")}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="src"){let J=$||"",Q=J&&(J===this.#j||J===this.#Q);if(this.#Z=J,this.#Q&&!Q)URL.revokeObjectURL(this.#Q),this.#Q=null,this.#j=null,this.#G=null;if(this.#y(),this.#$){let j=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Z?"Replace":j),this.#Z)if(this.#G?.name)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",this.#G.name);else this.#$.setAttribute("url",this.#Z),this.#$.removeAttribute("filename");else this.#$.removeAttribute("url"),this.#$.removeAttribute("filename")}}if(_==="type"){if(this.#E(),this.#y(),this.#$)this.#$.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(_))this.#f();if(_==="upload"){let J=$!==null&&$!=="false";if(J&&!this.#$)this.#t();else if(!J)this.#m()}if(_==="loading-indicator")this.#P();if(_==="aspect-ratio")if($)this.style.setProperty("--fig-media-aspect-ratio",$);else this.style.removeProperty("--fig-media-aspect-ratio");if(_==="fit")if($)this.style.setProperty("--fig-media-fit",$);else this.style.removeProperty("--fig-media-fit");if(_==="label"&&this.#$){let J=this.getAttribute("label")||"Upload";this.#$.setAttribute("label",this.#Z?"Replace":J)}if(["controls","autoplay","loop","muted","poster"].includes(_))this.#y();if(_==="caption")this.#w()}}F("fig-media",M0);class C_ extends M0{get mediaKind(){return"image"}}F("fig-image",C_);class P_ extends M0{get mediaKind(){return"video"}}F("fig-video",P_);class S_ extends HTMLElement{static get observedAttributes(){return["src","alt","label","text","sublabel","selected","disabled","full","size","direction","aspect-ratio","fit","label-line-clamp","label-overflow"]}#Z=null;#_=null;#J=null;#$=null;#Q=!1;#j=new MutationObserver((_)=>{if(!_.some(($)=>[...$.addedNodes,...$.removedNodes].some((J)=>J instanceof Element&&(J.matches("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])")||J.querySelector("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])"))))||!this.isConnected)return;this.#R(),this.#B()});connectedCallback(){this.#j.observe(this,{childList:!0,subtree:!0}),this.#R(),this.#B()}disconnectedCallback(){this.#j.disconnect()}attributeChangedCallback(){if(!this.isConnected)return;this.#R(),this.#B()}#G(){return this.getAttribute("label")??this.getAttribute("text")??""}#N(){return this.getAttribute("sublabel")??""}#q(){return this.getAttribute("label-line-clamp")==="2"?"2":"1"}#X(){return Boolean(this.getAttribute("src"))}#K(){return this.querySelector(":scope > fig-image:not([data-generated]), :scope > fig-media:not([data-generated]), :scope > fig-preview:not([data-generated])")}#Y(){this.querySelectorAll(":scope > .fig-card-link").forEach((_)=>{_.querySelectorAll(":scope > .fig-card-media").forEach((Z)=>{while(Z.firstChild)_.insertBefore(Z.firstChild,Z);Z.remove()});while(_.firstChild)this.insertBefore(_.firstChild,_);_.remove()})}#R(){if(this.#Y(),!this.#X()){this.#U();return}let _=this.#K();if(this.#Q=Boolean(_),_)this.querySelectorAll(":scope > [data-generated]:not(fig-footer)").forEach(($)=>$.remove()),this.#_=null;if(!this.#Q){if(this.#_=this.querySelector(":scope > fig-image[data-generated]")||null,!this.#_)this.querySelectorAll(":scope > fig-image, :scope > fig-media, :scope > fig-preview").forEach(($)=>{if($.hasAttribute("data-generated"))$.remove()}),this.#_=document.createElement("fig-image"),this.#_.setAttribute("data-generated",""),this.#_.setAttribute("full",""),this.#_.setAttribute("size","auto"),this.prepend(this.#_)}if(!Boolean(this.#G()||this.#N())){this.querySelector(":scope > fig-footer[data-generated]")?.remove(),this.#Z=null,this.#J=null,this.#$=null;return}if(!this.#Z||!this.#Z.isConnected){if(this.#Z=this.querySelector(":scope > fig-footer[data-generated]"),!this.#Z)this.#Z=document.createElement("fig-footer"),this.#Z.setAttribute("data-generated",""),this.appendChild(this.#Z)}if(!this.#J||!this.#J.isConnected){if(this.#J=this.#Z.querySelector(":scope > .fig-card-label[data-generated]"),!this.#J)this.#J=document.createElement("label"),this.#J.className="fig-card-label",this.#J.setAttribute("data-generated",""),this.#Z.appendChild(this.#J)}if(!this.#$||!this.#$.isConnected){if(this.#$=this.#Z.querySelector(":scope > .fig-card-sublabel[data-generated]"),!this.#$)this.#$=document.createElement("label"),this.#$.className="fig-card-sublabel",this.#$.setAttribute("data-generated",""),this.#J.after(this.#$)}}#U(){if(this.#Y(),this.querySelectorAll(":scope > [data-generated]").forEach((Z)=>Z.remove()),this.#_=null,this.#Q=!0,this.#Z=null,this.#J=null,this.#$=null,!this.#G()&&!this.#N())return;this.#Z=document.createElement("fig-footer"),this.#Z.setAttribute("data-generated",""),this.#J=document.createElement("label"),this.#J.className="fig-card-label",this.#J.setAttribute("data-generated",""),this.#Z.appendChild(this.#J);let _=this.#N();if(this.#$=null,_)this.#$=document.createElement("label"),this.#$.className="fig-card-sublabel",this.#$.setAttribute("data-generated",""),this.#Z.appendChild(this.#$);this.appendChild(this.#Z)}#W(){let _=this.getAttribute("label-overflow")==="fade";this.querySelectorAll(":scope > fig-footer > :is(.fig-card-label, .fig-card-sublabel)").forEach((Z)=>{Z.classList.toggle("fig-overflow-fade",_),Z.classList.toggle("fig-overflow-fade-horizontal",_)})}#B(){if(!this.#X()){this.#M();return}let _=T(this,"disabled"),Z=this.#G(),$=this.#N(),J=this.#q();this.style.setProperty("--fig-card-label-line-clamp",J),this.setAttribute("role","group");let Q=[Z,$].filter(Boolean).join(", ");if(Q)this.setAttribute("aria-label",Q);else this.removeAttribute("aria-label");if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#_&&!this.#Q){let j=this.getAttribute("src"),q=this.getAttribute("alt"),N=this.getAttribute("aspect-ratio")||"1/1",G=this.getAttribute("fit")||"contain",K=q!=null?q:"";if(j)this.#_.setAttribute("src",j);else this.#_.removeAttribute("src");this.#_.setAttribute("alt",K),this.#_.setAttribute("aspect-ratio",N),this.#_.setAttribute("fit",G),this.#_.setAttribute("full",""),this.#_.setAttribute("size","auto")}if(this.#J)this.#J.textContent=Z,this.#J.hidden=!Z;if(this.#$)this.#$.textContent=$,this.#$.hidden=!$;if(this.#Z)this.#Z.hidden=!Z&&!$;this.#W()}#M(){let _=T(this,"disabled"),Z=this.#G(),$=this.#N();this.style.setProperty("--fig-card-label-line-clamp",this.#q()),this.setAttribute("role","group");let J=[Z,$].filter(Boolean).join(", ");if(J)this.setAttribute("aria-label",J);else this.removeAttribute("aria-label");if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#J)this.#J.textContent=Z,this.#J.hidden=!Z;if(this.#$)this.#$.textContent=$;this.#W()}}F("fig-card",S_);class E_ extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=!1;#j=!1;static get observedAttributes(){return["playing","duration","time","disabled"]}connectedCallback(){this.#G(),this.#K(),this.#Y(),this.#N()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(_){if(_)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let _=Number(this.getAttribute("duration"));return Number.isFinite(_)&&_>=0?_:0}set duration(_){let Z=Number(_);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("duration");return}this.setAttribute("duration",String(Z))}get time(){let _=Number(this.getAttribute("time"));return Number.isFinite(_)&&_>=0?_:0}set time(_){let Z=Number(_);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("time");return}this.setAttribute("time",String(Z))}get disabled(){return T(this,"disabled")}set disabled(_){if(_)this.setAttribute("disabled","");else this.removeAttribute("disabled")}attributeChangedCallback(_){if(!this.#j)return;if(_==="playing")this.#K();if(_==="duration"||_==="time")this.#Y();if(_==="disabled")this.#N()}#G(){if(this.#j)return;if(this.#j=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");let _=document.createElement("fig-tooltip");_.setAttribute("text","Play");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Play"),Z.append(b("play")),_.append(Z),Z.addEventListener("click",(j)=>{j.preventDefault(),j.stopPropagation(),this.toggle()});let $=document.createElement("fig-slider");$.setAttribute("text","false"),$.setAttribute("min","0"),$.setAttribute("max",String(this.duration)),$.setAttribute("step","1"),$.setAttribute("value",String(this.time)),$.setAttribute("full",""),$.setAttribute("aria-label","Seek"),$.setAttribute("aria-valuetext",this.#X(this.time,this.duration));let J=document.createElement("span");J.className="fig-media-controls-time",J.textContent=this.#q(this.time);let Q=(j)=>{if(this.disabled){j.preventDefault?.(),j.stopPropagation();return}let q=j.currentTarget,N=Number(q?.value);if(!Number.isFinite(N))return;this.#Q=!0,this.setAttribute("time",String(N)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:N}})),requestAnimationFrame(()=>{this.#Q=!1})};$.addEventListener("input",Q),$.addEventListener("change",Q),this.append(_,$,J),this.#Z=Z,this.#_=_,this.#J=$,this.#$=J,this.#N()}#N(){let _=this.disabled;if(this.setAttribute("aria-disabled",_?"true":"false"),this.#Z)if(_)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#J)if(_)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}#q(_){if(!Number.isFinite(_)||_<0)_=0;let Z=Math.floor(_),$=Math.floor(Z/60),J=Z%60;return`${String($).padStart(2,"0")}:${String(J).padStart(2,"0")}`}#X(_,Z=0){let $=this.#q(_);if(!Number.isFinite(Z)||Z<=0)return $;return`${$} of ${this.#q(Z)}`}#K(){if(!this.#Z)return;let _=this.playing;this.#Z.setAttribute("aria-label",_?"Pause":"Play"),this.#_?.setAttribute("text",_?"Pause":"Play");let Z=this.#Z.querySelector("fig-icon");if(Z)Z.setAttribute("name",_?"pause":"play")}#Y(){if(!this.#J)return;let _=this.duration;if(Number(this.#J.getAttribute("max"))!==_)this.#J.setAttribute("max",String(_));let Z=this.time;if(!this.#Q)this.#J.setAttribute("value",String(Z));if(this.#J.setAttribute("aria-valuetext",this.#X(Z,_)),this.#$)this.#$.textContent=this.#q(Z)}toggle(){if(this.disabled)return;let _=!this.playing;this.playing=_,this.dispatchEvent(new CustomEvent(_?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:_}}))}play(){if(this.disabled||this.playing)return;this.toggle()}pause(){if(this.disabled||!this.playing)return;this.toggle()}}F("fig-media-controls",E_);class C0 extends HTMLElement{static#Z=0;static observedAttributes=["url","polarization","progress"];#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#N=null;#q=null;#X=[];#K=0;#Y=0;connectedCallback(){if(!this.#_)this.#R();this.#U(),this.#W()}disconnectedCallback(){if(this.#D(),this.#G?.disconnect(),this.#G=null,this.#Y)cancelAnimationFrame(this.#Y);this.#Y=0}attributeChangedCallback(_,Z,$){if(Z===$||!this.#_)return;if(_==="url")this.#W();if(_==="polarization")this.#H();if(_==="progress")this.#I()}#R(){this.#_=document.createElement("div"),this.#_.className="fig-audio-waveform-surface",this.#_.setAttribute("aria-hidden","true"),this.#J=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.#J.setAttribute("aria-hidden","true"),this.#J.setAttribute("preserveAspectRatio","none");let _=document.createElementNS("http://www.w3.org/2000/svg","defs"),Z=document.createElementNS("http://www.w3.org/2000/svg","clipPath"),$=`fig-audio-waveform-progress-${++C0.#Z}`;Z.id=$,Z.setAttribute("clipPathUnits","userSpaceOnUse"),this.#j=document.createElementNS("http://www.w3.org/2000/svg","rect"),Z.append(this.#j),_.append(Z),this.#$=document.createElementNS("http://www.w3.org/2000/svg","path"),this.#$.classList.add("fig-audio-waveform-path"),this.#Q=document.createElementNS("http://www.w3.org/2000/svg","path"),this.#Q.classList.add("fig-audio-waveform-progress"),this.#Q.setAttribute("clip-path",`url(#${$})`),this.#J.append(_,this.#$,this.#Q),this.#_.appendChild(this.#J),this.replaceChildren(this.#_),this.#U()}#U(){if(this.#G||!this.#J)return;this.#G=new ResizeObserver(()=>this.#H()),this.#G.observe(this.#J)}#W(){let _=this.getAttribute("url");if(!_){this.#O();return}this.#B(async(Z)=>{let $=await fetch(_,{signal:Z});if(!$.ok)throw Error(`Audio request failed: ${$.status}`);return $.arrayBuffer()})}async#B(_){this.#D();let Z=++this.#K,$=new AbortController;this.#N=$,this.setAttribute("data-waveform-state","loading"),this.setAttribute("aria-busy","true"),this.#X=[],this.#H();let J=null;try{let Q=await _($.signal);if(Z!==this.#K||!this.isConnected)return;let j=window.AudioContext||window.webkitAudioContext;if(!j)throw Error("Web Audio is unavailable");J=new j,this.#q=J;let q=await J.decodeAudioData(Q);if(Z!==this.#K||!this.isConnected)return;this.#X=this.#M(q),this.setAttribute("data-waveform-state","ready"),this.#H()}catch(Q){if(Z!==this.#K||Q?.name==="AbortError")return;this.#X=Array(256).fill(0),this.setAttribute("data-waveform-state","unavailable"),this.#H()}finally{if(J)try{await J.close()}catch{}if(this.#q===J)this.#q=null;if(this.#N===$)this.#N=null;if(Z===this.#K)this.removeAttribute("aria-busy")}}#M(_){let $=Array(256).fill(0),J=_.numberOfChannels,Q=_.length,j=Math.max(1,Math.ceil(Q/500000)),q=0;for(let K=0;K<256;K+=1){let X=Math.floor(K/256*Q),Y=Math.max(X+1,Math.floor((K+1)/256*Q)),W=0,R=0;for(let O=0;O<J;O+=1){let H=_.getChannelData(O);for(let A=X;A<Y;A+=j){let z=H[A]||0;if(!Number.isFinite(z))continue;W+=z*z,R+=1}}let L=R>0?Math.sqrt(W/R):0;$[K]=L,q=Math.max(q,L)}if(!Number.isFinite(q)||q<=0)return $.fill(0);let N=Math.min(...$),G=q-N;if(!Number.isFinite(G)||G<=Number.EPSILON)return $.fill(0);return $.map((K)=>{let X=(K-N)/G;return Number.isFinite(X)?X:0})}#O(){this.#D(),this.#X=[],this.removeAttribute("data-waveform-state"),this.removeAttribute("aria-busy"),this.#H()}#L(_){let Z=Number.parseFloat(this.getAttribute("polarization")),$=Number.isFinite(Z)?Math.max(0,Math.min(Z,4)):1.5;return Math.max(0,Math.min(1,0.5+(_-0.5)*$))}#A(){let _=Number.parseFloat(this.getAttribute("progress"));return Number.isFinite(_)?Math.max(0,Math.min(_,1)):0}#I(){if(!this.#J||!this.#j)return;let _=this.#J.viewBox.baseVal,Z=this.#J.getBoundingClientRect(),$=_.width||Math.max(1,Math.round(Z.width)),J=_.height||Math.max(1,Math.round(Z.height));this.#j.setAttribute("x","0"),this.#j.setAttribute("y","0"),this.#j.setAttribute("width",String($*this.#A())),this.#j.setAttribute("height",String(J))}#D(){if(this.#K+=1,this.#N?.abort(),this.#N=null,this.#q){try{this.#q.close()}catch{}this.#q=null}}#H(){if(this.#Y)return;this.#Y=requestAnimationFrame(()=>{this.#Y=0,this.#z()})}#z(){if(!this.#J||!this.#$||!this.#Q||!this.#j)return;let _=this.#J.getBoundingClientRect(),Z=Math.max(1,Math.round(_.width)),$=Math.max(1,Math.round(_.height));if(this.#J.setAttribute("viewBox",`0 0 ${Z} ${$}`),this.#I(),this.#X.length===0){this.#$.setAttribute("d",""),this.#Q.setAttribute("d","");return}let J=Math.min(this.#X.length,Math.max(16,Math.floor(Z/3))),Q=Z/J,j=Number.parseFloat(getComputedStyle(this).getPropertyValue("--fig-audio-waveform-stroke-width")),q=Number.isFinite(j)&&j>0?j:2,N=Math.max(0.5,Math.min(q,Q*0.75)),G=N/2,K=$/2,X=Math.max(2,$-12),Y=[];for(let R=0;R<J;R+=1){let L=Math.min(this.#X.length-1,Math.floor(R/J*this.#X.length)),O=this.#L(this.#X[L]),H=Math.max(N,O*X),A=(R+0.5)*Q,z=K-H/2,U=K+H/2,I=A-G,V=A+G;Y.push(`M ${A} ${z} Q ${V} ${z} ${V} ${z+G} V ${U-G} Q ${V} ${U} ${A} ${U} Q ${I} ${U} ${I} ${U-G} V ${z+G} Q ${I} ${z} ${A} ${z} Z`)}let W=Y.join(" ");this.#$.setAttribute("d",W),this.#Q.setAttribute("d",W)}}F("fig-audio-waveform",C0);class f_ extends HTMLElement{#Z="";#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#N=null;#q=null;#X=null;static get observedAttributes(){return["src","autoplay","controls","muted","loop"]}connectedCallback(){this.#Z=this.getAttribute("src")||"",this.#Y(),this.#R(),this.#W(),this.#M(),this.#I()}disconnectedCallback(){this.#H()}get src(){return this.#Z}set src(_){if(_===null||_===void 0||_==="")this.removeAttribute("src");else this.setAttribute("src",String(_))}get audioEl(){return this.#_}#K(_){return this.hasAttribute(_)&&this.getAttribute(_)!=="false"}#Y(){let _=this.querySelector(":scope > audio:not([data-generated])");if(_){this.#_=_;return}let Z=Array.from(this.querySelectorAll(":scope > audio[data-generated]")),$=Z[0]||document.createElement("audio");if(Z.slice(1).forEach((J)=>J.remove()),!$.hasAttribute("data-generated"))$.setAttribute("data-generated",""),$.preload="metadata",this.append($);this.#_=$}#R(){let _=this.querySelector(":scope > fig-audio-waveform:not([data-generated])");if(_)this.querySelectorAll(":scope > fig-audio-waveform[data-generated]").forEach((Z)=>Z.remove()),this.#J=_;else{let Z=Array.from(this.querySelectorAll(":scope > fig-audio-waveform[data-generated]")),$=Z[0]||document.createElement("fig-audio-waveform");if(Z.slice(1).forEach((J)=>J.remove()),!$.hasAttribute("data-generated"))$.setAttribute("data-generated",""),$.setAttribute("full",""),this.prepend($);this.#J=$}this.#U()}#U(){if(!this.#J)return;if(this.#Z)this.#J.setAttribute("url",this.#Z);else this.#J.removeAttribute("url")}#W(){if(!this.#_)return;if(this.#_.getAttribute("src")!==this.#Z)if(this.#Z)this.#_.setAttribute("src",this.#Z);else this.#_.removeAttribute("src"),this.#_.load?.();this.#_.controls=!1,this.#_.removeAttribute("controls"),this.#_.autoplay=this.#K("autoplay"),this.#_.muted=this.#K("muted"),this.#_.loop=this.#K("loop"),this.#U(),this.#L()}#B(){return Boolean(this.#Z)}#M(){let _=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(_){if(this.#$!==_)this.#z(),this.#$=_;this.#D(),this.#L();return}if(this.#K("controls"))this.#O();else this.#z()}#O(){let _=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Z=_[0]||document.createElement("fig-media-controls");if(_.slice(1).forEach(($)=>$.remove()),!Z.hasAttribute("data-generated"))Z.setAttribute("data-generated",""),this.append(Z);this.#$=Z,this.#D(),this.#L()}#L(){if(!this.#$)return;if(this.#B()){if(this.#$.hasAttribute("data-fig-empty-disabled"))this.#$.removeAttribute("disabled"),this.#$.removeAttribute("data-fig-empty-disabled");return}this.#$.setAttribute("disabled",""),this.#$.setAttribute("data-fig-empty-disabled",""),this.#$.removeAttribute("playing"),this.#$.setAttribute("time","0"),this.#$.setAttribute("duration","0"),this.#A(0,0)}#A(_,Z){if(!this.#J)return;let $=Number.isFinite(_)&&Number.isFinite(Z)&&Z>0?Math.max(0,Math.min(_/Z,1)):0;this.#J.setAttribute("progress",String($))}#I(){let _=this.#_;if(!_)return;let Z=Number.isFinite(_.currentTime)?_.currentTime:0,$=Number.isFinite(_.duration)?_.duration:0;if(this.#$)this.#$.toggleAttribute("playing",!_.paused&&!_.ended),this.#$.setAttribute("time",String(Z)),this.#$.setAttribute("duration",String($));this.#A(Z,$)}#D(){if(!this.#$||!this.#_)return;if(this.#Q===this.#_&&this.#j===this.#$){this.#L(),this.#I();return}this.#H();let _=this.#$,Z=this.#_,$=null,J=()=>{if(this.#L(),!this.#B())return;let N=Number.isFinite(Z.duration)?Z.duration:0,G=Number.isFinite(Z.currentTime)?Z.currentTime:0;if(_.toggleAttribute("playing",!Z.paused&&!Z.ended),_.setAttribute("duration",String(N)),$!==null)if(Math.abs(G-$)<0.25)$=null;else{this.#A(G,N);return}_.setAttribute("time",String(G)),this.#A(G,N)},Q=()=>this.play(),j=()=>this.pause(),q=(N)=>{if(!this.#B())return;let G=Number(N?.detail?.time);if(!Number.isFinite(G))return;$=G;try{Z.currentTime=G}catch{}this.#A(G,Z.duration)};this.#Q=Z,this.#j=_,this.#G=J,this.#N=Q,this.#q=j,this.#X=q,["play","pause","ended","timeupdate","loadedmetadata","durationchange","seeked","emptied"].forEach((N)=>Z.addEventListener(N,J)),_.addEventListener("play",Q),_.addEventListener("pause",j),_.addEventListener("seek",q),J()}#H(){let _=this.#Q,Z=this.#j;if(_&&this.#G)["play","pause","ended","timeupdate","loadedmetadata","durationchange","seeked","emptied"].forEach(($)=>_.removeEventListener($,this.#G));if(Z){if(this.#N)Z.removeEventListener("play",this.#N);if(this.#q)Z.removeEventListener("pause",this.#q);if(this.#X)Z.removeEventListener("seek",this.#X)}this.#Q=null,this.#j=null,this.#G=null,this.#N=null,this.#q=null,this.#X=null}#z(){this.#H(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((_)=>_.remove()),this.#$=null}play(){if(!this.#_||!this.#B())return;let _=this.#_.play?.();if(_&&typeof _.catch==="function")_.catch(()=>{})}pause(){this.#_?.pause?.()}toggle(){if(!this.#_||!this.#B())return;if(this.#_.paused||this.#_.ended)this.play();else this.pause()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="src")this.#Z=$||"";if(!this.isConnected)return;if(_==="controls")this.#M();if(["src","autoplay","muted","loop"].includes(_))this.#W(),this.#I()}}F("fig-audio",f_);var s=[".png",".jpg",".jpeg",".gif",".webp",".svg",".avif"],r=[".mp3",".wav",".aac",".m4a",".ogg",".flac"],Q0=[".mp4",".webm",".mov",".m4v",".avi",".mkv",".ogv",".mpeg",".mpg",".3gp"];class x_ extends HTMLElement{static observedAttributes=["accepts","preview","label","disabled","multiple","variant","url","filename"];#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#N=null;#q=null;#X=null;#K=!1;#Y=null;#R=!1;get files(){return this.#j}get#U(){let _=this.getAttribute("filename");if(_)return _;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.#j&&this.#j.length>0){if(this.#j.length===1)return this.#j[0].name;return`${this.#j.length} files`}return this.#U}get#W(){return this.getAttribute("accepts")||""}get#B(){return this.hasAttribute("preview")&&this.getAttribute("preview")!=="false"}get#M(){return this.getAttribute("preview")?.toLowerCase()==="large"}#O(_,Z){let $=_.toLowerCase();return Z.some((J)=>$.endsWith(J))}#L(_,Z,$){return this.#O(_.name,Z)||_.type.toLowerCase().startsWith($)}#A(){if(this.#j?.[0]){if(this.#L(this.#j[0],r,"audio/"))return"Upload audio";if(this.#L(this.#j[0],s,"image/"))return"Upload image"}if(this.#O(this.#U,r))return"Upload audio";if(this.#O(this.#U,s))return"Upload image";let _=this.#W.split(",").map((Z)=>Z.trim().toLowerCase()).filter(Boolean).map((Z)=>{if(Z.startsWith("audio/")||r.includes(Z))return"audio";if(Z.startsWith("image/")||s.includes(Z))return"image";return"file"});if(_.length>0&&_.every((Z)=>Z==="audio"))return"Upload audio";if(_.length>0&&_.every((Z)=>Z==="image"))return"Upload image";return"Upload file"}#I(){if(this.#j?.length)return this.#L(this.#j[0],s,"image/");return!!this.getAttribute("url")&&this.#O(this.#U,s)}#D(){if(this.#j?.length)return this.#L(this.#j[0],r,"audio/");return!!this.getAttribute("url")&&this.#O(this.#U,r)}#H(){let _=this.#j?.[0];if(_){if(this.#L(_,Q0,"video/"))return"video";if(this.#L(_,s,"image/"))return"image";return null}if(this.#O(this.#U,Q0))return"video";if(this.#O(this.#U,s))return"image";let Z=this.#W.split(",").map(($)=>$.trim().toLowerCase()).filter(Boolean).map(($)=>{if($.startsWith("video/")||Q0.includes($))return"video";if($.startsWith("image/")||s.includes($))return"image";return null});if(Z.length>0&&Z.every(($)=>$===Z[0]))return Z[0];return null}#z(){if(this.#j&&this.#j.length>0){let _=Array.from(this.#j);if(this.#B&&_.every((Z)=>this.#L(Z,Q0,"video/")))return"video";if(_.every((Z)=>this.#L(Z,r,"audio/")))return"audio";if(_.every((Z)=>this.#L(Z,s,"image/")))return"image"}if(this.#B&&this.#O(this.#U,Q0))return"video";if(this.#O(this.#U,r))return"audio";if(this.#O(this.#U,s))return"image";return"upload"}connectedCallback(){this.#u(),this.addEventListener("dragover",this.#V),this.addEventListener("dragleave",this.#k),this.addEventListener("drop",this.#C)}disconnectedCallback(){this.#Z?.removeEventListener("change",this.#S),this.#J?.removeEventListener("click",this.#P),this.#h(),this.#E(),this.removeEventListener("dragover",this.#V),this.removeEventListener("dragleave",this.#k),this.removeEventListener("drop",this.#C)}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#R)return;this.#u()}clear(){if(this.#j=null,this.#Z)this.#Z.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#u(),this.#F({cleared:!0})}#F(_={}){let Z={files:this.#j,..._};this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0}))}#T(){this.#R=!0,this.removeAttribute("url"),this.removeAttribute("filename"),this.#R=!1}#S=()=>{if(this.#Z.files.length>0)this.#j=this.#Z.files,this.#T(),this.#u(),this.#F()};#P=(_)=>{_.stopPropagation(),this.clear()};#V=(_)=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(_.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#Q)this.#Q.dataset.prevText=this.#Q.textContent,this.#Q.textContent="Drop file"}};#k=()=>{if(this.removeAttribute("dragover"),this.#Q&&this.#Q.dataset.prevText!==void 0)this.#Q.textContent=this.#Q.dataset.prevText,delete this.#Q.dataset.prevText};#C=(_)=>{if(_.preventDefault(),this.removeAttribute("dragover"),this.#Q&&this.#Q.dataset.prevText!==void 0)this.#Q.textContent=this.#Q.dataset.prevText,delete this.#Q.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#W,$=Array.from(_.dataTransfer.files);if(Z){let Q=Z.split(",").map((j)=>j.trim().toLowerCase());$=$.filter((j)=>{let q="."+j.name.split(".").pop().toLowerCase(),N=j.type.toLowerCase();return Q.some((G)=>G===q||G===N||G.endsWith("/*")&&N.startsWith(G.slice(0,-1)))})}if(!this.hasAttribute("multiple")||this.getAttribute("multiple")==="false")$=$.slice(0,1);if($.length===0)return;let J=new DataTransfer;if($.forEach((Q)=>J.items.add(Q)),this.#j=J.files,this.#Z)this.#Z.files=J.files;this.#T(),this.#u(),this.#F()};#h(){if(!this.#G)return;URL.revokeObjectURL(this.#G),this.#G=null}#E(){if(this.#N?.pause(),this.#Y)URL.revokeObjectURL(this.#Y),this.#Y=null;this.#N=null,this.#q=null,this.#X=null,this.#K=!1,this.removeAttribute("data-audio-playing")}#f(_){this.#K=_,this.#q?.setAttribute("name",_?"pause":"play"),this.toggleAttribute("data-audio-playing",_),this.#Q?.toggleAttribute("selected",_),this.#Q?.setAttribute("aria-label",_?"Pause audio":"Play audio")}#x(){if(!this.#N||!this.#X)return;let _=this.#N.duration,Z=this.#N.currentTime,$=Number.isFinite(_)&&_>0&&Number.isFinite(Z)?Math.max(0,Math.min(Z/_,1)):0;this.#X.setAttribute("progress",String($))}#g=(_)=>{if(_.preventDefault(),!this.#N||this.#Q?.hasAttribute("disabled"))return;if(this.#K){this.#N.pause();return}let Z=this.#N.play();if(Z&&typeof Z.catch==="function")Z.catch(()=>this.#f(!1))};#w(){let _=document.createElement("audio");if(_.hidden=!0,_.preload="metadata",this.#j?.[0])this.#Y=URL.createObjectURL(this.#j[0]),_.src=this.#Y;else _.src=this.getAttribute("url")||"";_.addEventListener("play",()=>this.#f(!0)),_.addEventListener("pause",()=>this.#f(!1)),_.addEventListener("ended",()=>{this.#f(!1),this.#X?.setAttribute("progress","0")}),_.addEventListener("timeupdate",()=>this.#x()),_.addEventListener("durationchange",()=>this.#x()),this.#N=_,this.#X=document.createElement("fig-audio-waveform"),this.#X.className="fig-input-file-audio-waveform",this.#X.setAttribute("url",_.src),this.#X.setAttribute("polarization","3"),this.#X.setAttribute("progress","0"),this.#Q?.append(this.#X),this.#Q?.addEventListener("click",this.#g),this.#f(!1),this.append(_)}#p(){let _=document.createElement("fig-swatch"),Z=this.#j?.[0],$=Z?this.#G=URL.createObjectURL(Z):this.getAttribute("url")||"";return _.setAttribute("background",`url(${JSON.stringify($)})`),_.setAttribute("slot","prepend"),_}#y(_){let Z=document.createElement("fig-icon");Z.setAttribute("slot","prepend");let $=document.createElement("label");return $.textContent=String(_),Z.append($),Z}#b=(_)=>{if(_.target!==_.currentTarget){_.stopPropagation();return}_.stopPropagation();let $=_.currentTarget.file;if($){let J=new DataTransfer;J.items.add($),this.#j=J.files,this.#T(),this.#u(),this.#F();return}this.#j=null,this.#T(),this.#u(),this.#F({cleared:!0})};#v(_,Z){let $=document.createElement(_==="video"?"fig-video":"fig-image");$.setAttribute("upload",""),$.setAttribute("full",""),$.setAttribute("checkerboard","");let J=this.#j?.[0],Q=J?this.#G=URL.createObjectURL(J):this.getAttribute("url")||"";if(Q)$.setAttribute("src",Q);$.addEventListener("change",this.#b),this.append($);let j=$.querySelector(":scope > fig-preview > fig-input-file[data-generated]");if(Z)j?.setAttribute("disabled","");this.setAttribute("data-previewing","large")}#u(){let _=this.#W,Z=this.getAttribute("label"),$=Z?.trim()?Z:this.#A(),J=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Q=this.hasAttribute("multiple")&&this.getAttribute("multiple")!=="false",j=this.getAttribute("variant")||"property",q=this.#j&&this.#j.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename"),N=this.#B&&Q&&(this.#j?.length??0)>1,G=!N&&this.#B&&this.#I(),K=!N&&this.#B&&this.#D();this.#h(),this.#E(),this.replaceChildren(),this.#Z=null,this.#Q=null,this.#J=null,this.#$=null,this.removeAttribute("data-previewing");let X=this.#M&&!N?this.#H():null;if(X){this.#v(X,J);return}if(q){let Y=this.value,W=Q&&this.#j?.length?Array.from(this.#j,(U)=>U.name).join(", "):"",R=W?W:K?Y:_?`Accepts ${_.split(",").map((U)=>U.trim()).join(", ")}`:"";if(this.#Q=document.createElement("fig-button"),this.#Q.setAttribute("variant",j),j==="property")this.#Q.setAttribute("full","");if(this.#Q.className="fig-input-file-filename",J)this.#Q.setAttribute("disabled","");let L=N?this.#y(this.#j.length):G?this.#p():b(this.#z()),O=document.createElement("fig-truncate");O.setAttribute("position","middle"),O.setAttribute("tooltip","");let H=N?"Multiple files":Y,A=H.lastIndexOf(".");if(!N&&A>0)O.setAttribute("tail",H.slice(A));if(O.textContent=H,L.setAttribute("slot","prepend"),K)L.classList.add("fig-input-file-audio-icon"),O.classList.add("fig-input-file-audio-label"),this.#q=b("play"),this.#q.classList.add("fig-input-file-audio-control"),this.#q.setAttribute("slot","prepend"),this.#Q.append(L,this.#q,O);else this.#Q.append(L,O);if(!K){if(this.#Q.setAttribute("type","upload"),this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",this.#Z.disabled=J,_)this.#Z.setAttribute("accept",_);if(Q)this.#Z.setAttribute("multiple","");this.#Z.addEventListener("change",this.#S),this.#Q.appendChild(this.#Z)}if(R)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",R),this.#$.appendChild(this.#Q),this.appendChild(this.#$);else this.appendChild(this.#Q);let z=document.createElement("fig-tooltip");if(z.setAttribute("text","Remove"),this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#J.setAttribute("icon","true"),this.#J.setAttribute("aria-label","Remove"),this.#J.className="fig-input-file-clear",J)this.#J.setAttribute("disabled","");if(this.#J.replaceChildren(b("minus")),this.#J.addEventListener("click",this.#P),z.appendChild(this.#J),this.appendChild(z),K)this.#w()}else{let Y=_?`Accepts ${_.split(",").map((R)=>R.trim()).join(", ")}`:"";if(Y)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",Y);if(this.#Q=document.createElement("fig-button"),this.#Q.setAttribute("variant",j),j==="property")this.#Q.setAttribute("full","");this.#Q.setAttribute("type","upload"),this.#Q.textContent=$;let W=b("upload");if(W.setAttribute("slot","prepend"),this.#Q.prepend(W),J)this.#Q.setAttribute("disabled","");if(this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",this.#Z.disabled=J,_)this.#Z.setAttribute("accept",_);if(Q)this.#Z.setAttribute("multiple","");if(this.#Z.addEventListener("change",this.#S),this.#Q.appendChild(this.#Z),this.#$)this.#$.appendChild(this.#Q),this.appendChild(this.#$);else this.appendChild(this.#Q)}}}F("fig-input-file",x_);class h extends HTMLElement{#Z={x:0.42,y:0};#_={x:0.58,y:1};#J={stiffness:200,damping:15,mass:1,initialVelocity:0};#$="bezier";#Q=2;#j=null;#G=null;#N=null;#q=null;#X=null;#K=null;#Y=null;#R=null;#U=null;#W=null;#B=null;#M=0.8;#O=200;#L=200;#A=null;#I=null;#D=null;#H=null;#z=5;#F=10;#T=10;#S=3;#P=null;#V=null;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","mode","precision","aspect-ratio","edit","presets","text"]}connectedCallback(){this.#Q=parseInt(this.getAttribute("precision")||"2"),p(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let _=this.#k();if(_)this.#$=_;let Z=this.getAttribute("value");if(Z)this.#g(Z);this.#C(),this.#W=this.#w(),this.#m(),this.#L0()}disconnectedCallback(){if(this.#j=null,this.#H)this.#H.disconnect(),this.#H=null;this.#P0()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="aspect-ratio"){if(p(this,"--aspect-ratio",$),this.#G)this.#X0(),this.#j0();return}if(_==="edit"||_==="presets"||_==="text"){if(_==="edit"&&$!=="false")this.#P0();if(this.isConnected)this.#m();return}if(_==="mode"){this.#C();let J=this.getAttribute("value");if(J)this.#g(J);if(this.#C(),this.#W=this.#w(),this.isConnected)this.#m();this.#A0();return}if(_==="value"&&$){let J=this.#$;if(this.#g($),this.#W=this.#w(),J!==this.#$&&this.#i())this.#m();else{if(this.#G)this.#j0();this.#R0(),this.#q0()}}if(_==="precision")this.#Q=parseInt($||"2");if(_==="value"||_==="mode"||_==="precision")this.#A0()}get value(){if(this.#$==="spring"){let{stiffness:Z,damping:$,mass:J,initialVelocity:Q=0}=this.#J,j=Q?`, ${Q}`:"";return`spring(${Z}, ${$}, ${J}${j})`}let _=this.#Q;return`${this.#Z.x.toFixed(_)}, ${this.#Z.y.toFixed(_)}, ${this.#_.x.toFixed(_)}, ${this.#_.y.toFixed(_)}`}get cssValue(){if(this.#$==="spring"){let Z=this.#p(),$=20,J=Math.max(1,Math.floor(Z.length/20)),Q=[];for(let j=0;j<Z.length;j+=J)Q.push(Z[j].value.toFixed(3));if(Z.length>0)Q.push(Z[Z.length-1].value.toFixed(3));return`linear(${Q.join(", ")})`}let _=this.#Q;return`cubic-bezier(${this.#Z.x.toFixed(_)}, ${this.#Z.y.toFixed(_)}, ${this.#_.x.toFixed(_)}, ${this.#_.y.toFixed(_)})`}get preset(){return this.#W}set value(_){if(_&&typeof _==="object"){let Z=this.#E(_);if(!Z)throw TypeError("Invalid easing value or mode/type mismatch");let $=Z.type==="spring"?{type:"spring",...Z.spring}:{type:"bezier",x1:Z.bezier[0],y1:Z.bezier[1],x2:Z.bezier[2],y2:Z.bezier[3]};this.setAttribute("value",JSON.stringify($));return}this.setAttribute("value",_)}get spring(){if(this.#$!=="spring")return null;return{...this.#J,initialVelocity:this.#J.initialVelocity??0}}set spring(_){if(!_||typeof _!=="object")throw TypeError("spring must be an object");this.value={..._,type:"spring"}}#k(){let _=this.getAttribute("mode")?.trim().toLowerCase();return _==="bezier"||_==="spring"?_:null}#C(){let _=this.#k();if(_)this.#$=_}#h(_){let Z=this.#k();return!Z||_.type===Z}#E(_){if(!_||typeof _!=="object"||Array.isArray(_))return null;let Z=this.#k(),$=typeof _.type==="string"?_.type.trim().toLowerCase():null;if($&&$!=="bezier"&&$!=="spring")return null;if($&&Z&&$!==Z)return null;let J=$||Z;if(!J)return null;if(J==="spring"){let j={mass:Number(_.mass),stiffness:Number(_.stiffness),damping:Number(_.damping),initialVelocity:_.initialVelocity===void 0?0:Number(_.initialVelocity)};if(!Number.isFinite(j.mass)||j.mass<=0||!Number.isFinite(j.stiffness)||j.stiffness<=0||!Number.isFinite(j.damping)||j.damping<0||!Number.isFinite(j.initialVelocity))return null;return{type:J,spring:j}}let Q=[_.x1,_.y1,_.x2,_.y2].map(Number);if(Q.some((j)=>!Number.isFinite(j))||Q[0]<0||Q[0]>1||Q[2]<0||Q[2]>1)return null;return{type:J,bezier:Q}}#f(_){if(_.type==="spring")this.#$="spring",this.#J={..._.spring};else this.#$="bezier",[this.#Z.x,this.#Z.y,this.#_.x,this.#_.y]=_.bezier}#x(_){let Z=_.match(/^spring\(\s*(.*?)\s*\)$/i);if(!Z)return null;let $=Z[1].split(",").map((Q)=>Number(Q.trim()));if($.length!==3&&$.length!==4||$.some((Q)=>!Number.isFinite(Q)))return null;let J={stiffness:$[0],damping:$[1],mass:$[2],initialVelocity:$[3]??0};if(J.stiffness<=0||J.damping<0||J.mass<=0)return null;return J}#g(_){if(_&&typeof _==="object"){let Q=this.#E(_);if(!Q)return!1;return this.#f(Q),!0}if(typeof _!=="string")return!1;let Z=_.trim();if(Z.startsWith("{"))try{return this.#g(JSON.parse(Z))}catch{return!1}let $=this.#x(Z);if($&&this.#k()!=="bezier")return this.#$="spring",this.#J=$,!0;let J=Z.split(",").map((Q)=>parseFloat(Q.trim()));if(J.length>=4&&J.every((Q)=>!isNaN(Q))&&this.#k()!=="spring")return this.#$="bezier",this.#Z.x=J[0],this.#Z.y=J[1],this.#_.x=J[2],this.#_.y=J[3],!0;return!1}#w(){if(this.#$==="bezier"){for(let Z of h.PRESETS){if(Z.type!=="bezier"||!Z.value)continue;if(Math.abs(this.#Z.x-Z.value[0])<0.001&&Math.abs(this.#Z.y-Z.value[1])<0.001&&Math.abs(this.#_.x-Z.value[2])<0.001&&Math.abs(this.#_.y-Z.value[3])<0.001)return Z.name}return"Custom bezier"}for(let Z of h.PRESETS){if(Z.type!=="spring"||!Z.spring)continue;if(Math.abs(this.#J.stiffness-Z.spring.stiffness)<0.001&&Math.abs(this.#J.damping-Z.spring.damping)<0.001&&Math.abs(this.#J.mass-Z.spring.mass)<0.001&&Math.abs(this.#J.initialVelocity??0)<0.001)return Z.name}return"Custom spring"}#p(){let{stiffness:_,damping:Z,mass:$,initialVelocity:J=0}=this.#J,Q=0.004,j=5,q=[],N=0,G=J;for(let K=0;K<=5;K+=0.004){let X=-_*(N-1)-Z*G;if(G+=X/$*0.004,N+=G*0.004,q.push({t:K,value:N}),K>0.1&&Math.abs(N-1)<0.0005&&Math.abs(G)<0.0005)break}return q}static#y(_,Z=24){let{stiffness:$,damping:J,mass:Q,initialVelocity:j=0}=_,q=0.004,N=5,G=[],K=0,X=j;for(let U=0;U<=5;U+=0.004){let I=-$*(K-1)-J*X;if(X+=I/Q*0.004,K+=X*0.004,G.push({t:U,value:K}),U>0.1&&Math.abs(K-1)<0.001&&Math.abs(X)<0.001)break}let Y=G[G.length-1].t||1,W=1;for(let U of G)if(U.value>W)W=U.value;let R=0;for(let U of G)if(U.value<R)R=U.value;let L=Math.max(W-R,1),O=6,H=Z-O*2,A=Math.max(1,Math.floor(G.length/30)),z="";for(let U=0;U<G.length;U+=A){let I=O+G[U].t/Y*H,V=O+(1-(G[U].value-R)/L)*H;z+=(U===0?"M":"L")+I.toFixed(1)+","+V.toFixed(1)}return h.#a(z,Z,h.#u(Z))}static#b(_,Z,$,J,Q=24){let q=(Q-11)/2,N=48,G=[],K=(U,I,V,P,S)=>{let w=1-S;return w*w*w*U+3*w*w*S*I+3*w*S*S*V+S*S*S*P};for(let U=0;U<=48;U++){let I=U/48;G.push({x:K(0,_,$,1,I),y:K(0,Z,J,1,I)})}let X=1/0,Y=-1/0,W=1/0,R=-1/0;for(let U of G){if(U.x<X)X=U.x;if(U.x>Y)Y=U.x;if(U.y<W)W=U.y;if(U.y>R)R=U.y}let L=Math.max(Y-X,0.000001),O=Math.max(R-W,0.000001),H=(U)=>q+(U-X)/L*11,A=(U)=>q+(1-(U-W)/O)*11,z="";for(let U=0;U<G.length;U++){let I=H(G[U].x),V=A(G[U].y);z+=`${U===0?"M":"L"}${I.toFixed(1)},${V.toFixed(1)}`}return z}static#v(_=24){let $=(_-11)/2,J=3.6666666666666665;return Array.from({length:16},(Q,j)=>({x:$+j%4*3.6666666666666665,y:$+Math.floor(j/4)*3.6666666666666665}))}static#u(_=24){return h.#v(_).map(({x:Z,y:$})=>E("circle",{cx:Z,cy:$,r:0.5,fill:"var(--figma-color-icon-tertiary)"}))}static#a(_,Z=24,$=[]){return E("svg",{width:Z,height:Z,viewBox:`0 0 ${Z} ${Z}`,fill:"none"},[...$,E("path",{d:_,stroke:"currentColor","stroke-width":"1","stroke-linecap":"round",fill:"none"})])}static#o(_,Z,$,J,Q=24){return h.#a(h.#b(_,Z,$,J,Q),Q,h.#u(Q))}static curveIcon(_,Z,$,J,Q=24){let j=h.#b(_,Z,$,J,Q),q=h.#v(Q).map(({x:N,y:G})=>`<circle cx="${N}" cy="${G}" r="0.5" fill="var(--figma-color-icon-tertiary)"></circle>`).join("");return`<svg width="${Q}" height="${Q}" viewBox="0 0 ${Q} ${Q}" fill="none">${q}<path d="${j}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#i(){return this.getAttribute("edit")!=="false"}#r(){return this.getAttribute("presets")!=="false"}#t(){return this.getAttribute("text")!=="false"}#m(){if(this.classList.toggle("spring-mode",this.#$==="spring"),this.classList.toggle("bezier-mode",this.#$!=="spring"),this.#N0(),this.replaceChildren(...this.#G0()),this.#Z0(),this.#G)this.#n(),this.#X0(),this.#j0();this.#q0(),this.#p0()}#c(){return["fig-select","fig-select-options","fig-select-option"].every((_)=>{let Z=customElements.get(_);return typeof Z==="function"&&Z.prototype instanceof HTMLElement})}#d(){let _=M("fig-dropdown",{className:"fig-easing-curve-select",label:"Easing preset",value:this.#W,full:!0}),Z=void 0,$=_;for(let J of h.PRESETS){if(!this.#h(J))continue;if(!this.#i()&&!customElements.get("fig-popup-easing")&&!J.value&&!J.spring)continue;if(J.group!==Z){if(Z=J.group,$=Z?M("optgroup",{label:Z}):_,$!==_)_.appendChild($)}$.appendChild(M("option",{value:J.name},J.name))}return _}#Q0(){if(!this.#c())return this.#d();let _=document.createElement("fig-select-options"),Z=void 0;for(let $ of h.PRESETS){if(!this.#h($))continue;if(!this.#i()&&!customElements.get("fig-popup-easing")&&!$.value&&!$.spring)continue;if($.group!==Z){if($.group)_.appendChild(M("fig-separator",{label:$.group}));Z=$.group}let J;if($.type==="spring"){let Q=$.spring||this.#J;J=h.#y(Q)}else{let Q=$.value||[this.#Z.x,this.#Z.y,this.#_.x,this.#_.y];J=h.#o(...Q)}_.appendChild(M("fig-select-option",{value:$.name,label:$.name},[M("fig-icon",{slot:"prepend"},J),M("span",{},$.name)]))}return M("fig-select",{className:"fig-easing-curve-select",label:"Easing preset",value:this.#W,full:!0},_)}#s(_,Z,$){let J=M("fig-handle",{size:"small",type:"minimal","aria-label":$});return E("foreignObject",{className:_,"data-handle":Z,width:"20",height:"20"},M("fig-tooltip",{text:this.#l(Z)},J))}#e(_){if(!Number.isFinite(_))return"0";return String(Number(_.toFixed(this.#Q)))}#l(_){if(this.#$==="spring"){if(_==="bounce")return`Bounce ${this.#e(this.#U0())}`;return`Duration ${Math.round(this.#M*100)}%`}let Z=_==="1"?this.#Z:this.#_;return`${_==="1"?"Start":"End"} ${this.#e(Z.x)}, ${this.#e(Z.y)}`}#_0(){for(let[_,Z]of[[this.#K,this.#$==="spring"?"bounce":"1"],[this.#Y,this.#$==="spring"?"duration":"2"]]){let $=_?.querySelector("fig-tooltip");if($)$.text=this.#l(Z)}}#$0(_,Z){let $=_?.querySelector("fig-tooltip");if(!$)return;if(Z)$.setAttribute("show","true");else $.removeAttribute("show")}#G0(){let Z=this.#r()?this.#Q0():null;if(!this.#i())return Z?[Z]:[];let $=this.#t()?this.#$==="spring"?M("fig-input-number",{className:"fig-easing-curve-value-input",value:this.#U0().toFixed(2),min:"0",max:"1",step:"0.01",precision:"2","aria-label":"Spring bounce",full:!0}):M("fig-input-text",{className:"fig-easing-curve-value-input",value:this.value,full:!0}):null,J=[E("rect",{className:"fig-easing-curve-bounds",x:"0",y:"0",width:200,height:200})];if(this.#$==="spring")J.push(E("line",{className:"fig-easing-curve-target",x1:"0",y1:40,x2:200,y2:40}),E("path",{className:"fig-easing-curve-path"}),this.#s("fig-easing-curve-handle","bounce","Spring bounce handle"),this.#s("fig-easing-curve-handle fig-easing-curve-duration-bar","duration","Spring duration handle"));else J.push(E("line",{className:"fig-easing-curve-boundary","data-boundary":"top",x1:"0",y1:"0",x2:200,y2:"0"}),E("line",{className:"fig-easing-curve-boundary","data-boundary":"bottom",x1:"0",y1:200,x2:200,y2:200}),E("path",{className:"fig-easing-curve-path"}),E("line",{className:"fig-easing-curve-arm","data-arm":"1"}),E("line",{className:"fig-easing-curve-arm","data-arm":"2"}),this.#s("fig-easing-curve-handle","1","First easing control point"),this.#s("fig-easing-curve-handle","2","Second easing control point"));let Q=E("svg",{viewBox:"0 0 200 200",className:"fig-easing-curve-svg"},J);return[...Z?[Z]:[],M("div",{className:"fig-easing-curve-svg-container"},Q),...$?[$]:[]]}#K0(_,Z){let $=getComputedStyle(this).getPropertyValue(_).trim();if(!$)return Z;let J=Number.parseFloat($);return Number.isFinite(J)?J:Z}#N0(){this.#S=this.#K0("--easing-duration-bar-radius",this.#S)}#Z0(){this.#G=this.querySelector(".fig-easing-curve-svg"),this.#N=this.querySelector(".fig-easing-curve-path"),this.#q=this.querySelector('[data-arm="1"]'),this.#X=this.querySelector('[data-arm="2"]'),this.#K=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#Y=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#R=this.querySelector(".fig-easing-curve-select"),this.#U=this.querySelector(".fig-easing-curve-value-input"),this.#B=this.querySelector(".fig-easing-curve-target"),this.#A=this.querySelector(".fig-easing-curve-bounds"),this.#I=this.querySelector('[data-boundary="top"]'),this.#D=this.querySelector('[data-boundary="bottom"]')}#n(){let _=this.#K?.querySelector("fig-handle"),Z=this.#Y?.querySelector("fig-handle");if(_){let $=_.offsetWidth||this.#z*2,J=_.offsetHeight||this.#z*2;this.#z=Math.max($,J)/2,this.#K.setAttribute("width",$),this.#K.setAttribute("height",J)}if(Z){let $=Z.offsetWidth||this.#F,J=Z.offsetHeight||this.#T;if(this.#$==="spring")this.#F=$,this.#T=J;this.#Y.setAttribute("width",$),this.#Y.setAttribute("height",J)}}#L0(){if(this.#H||!window.ResizeObserver)return;this.#H=new ResizeObserver(()=>{if(this.#X0())this.#j0()}),this.#H.observe(this)}#X0(){if(!this.#G)return!1;let _=this.#G.getBoundingClientRect(),Z=Math.max(1,Math.round(_.width||200)),$=Math.max(1,Math.round(_.height||200)),J=Z!==this.#O||$!==this.#L;return this.#O=Z,this.#L=$,this.#G.setAttribute("viewBox",`0 0 ${Z} ${$}`),J}#F0(){let _=Math.min(0,this.#Z.y,this.#_.y),Z=Math.max(1,this.#Z.y,this.#_.y),$=Z-_||1,J=0;return{minVal:_,maxVal:Z,range:$,pad:0,draw:Math.max(1,this.#L-0)}}#O0(_,Z){let{maxVal:$,range:J,pad:Q,draw:j}=this.#F0();return{x:_*this.#O,y:Q+($-Z)/J*j}}#E0(_,Z){let{maxVal:$,range:J,pad:Q,draw:j}=this.#F0();return{x:_/this.#O,y:$-(Z-Q)/j*J}}#z0={minVal:0,maxVal:1.2,totalTime:1};#Y0(_,Z){let J=this.#L-40,{minVal:Q,maxVal:j}=this.#z0,q=j-Q||1;return{x:_*this.#O,y:20+(1-(Z-Q)/q)*J}}#j0(){if(this.#X0(),this.#$==="spring")this.#w0();else this.#f0();this.#_0()}#T0(){this.#q?.classList.toggle("is-active",this.#$==="bezier"&&this.#j===1),this.#X?.classList.toggle("is-active",this.#$==="bezier"&&this.#j===2)}#f0(){if(this.#A)this.#A.setAttribute("x","0"),this.#A.setAttribute("y","0"),this.#A.setAttribute("width",this.#O),this.#A.setAttribute("height",this.#L);let _=this.#O0(0,0),Z=this.#O0(this.#Z.x,this.#Z.y),$=this.#O0(this.#_.x,this.#_.y),J=this.#O0(1,1);for(let[j,q]of[[this.#I,J.y],[this.#D,_.y]]){if(!j)continue;j.setAttribute("x1","0"),j.setAttribute("y1",q),j.setAttribute("x2",this.#O),j.setAttribute("y2",q)}this.#N.setAttribute("d",`M${_.x},${_.y} C${Z.x},${Z.y} ${$.x},${$.y} ${J.x},${J.y}`),this.#q.setAttribute("x1",_.x),this.#q.setAttribute("y1",_.y),this.#q.setAttribute("x2",Z.x),this.#q.setAttribute("y2",Z.y),this.#X.setAttribute("x1",J.x),this.#X.setAttribute("y1",J.y),this.#X.setAttribute("x2",$.x),this.#X.setAttribute("y2",$.y);let Q=this.#z;this.#K.setAttribute("x",Z.x-Q),this.#K.setAttribute("y",Z.y-Q),this.#Y.setAttribute("x",$.x-Q),this.#Y.setAttribute("y",$.y-Q),this.#x0()}#x0(){if(!this.#G||!this.#K||!this.#Y)return;let _=this.#Z.y>=this.#_.y?[this.#K,this.#Y]:[this.#Y,this.#K];for(let Z of _)this.#G.append(Z)}#w0(){if(this.#A)this.#A.setAttribute("x","0"),this.#A.setAttribute("y","0"),this.#A.setAttribute("width",this.#O),this.#A.setAttribute("height",this.#L);let _=this.#p();if(!_.length)return;let Z=_[_.length-1].t||1,$=0,J=1;for(let O of _){if(O.value<$)$=O.value;if(O.value>J)J=O.value}let Q=Math.max(Math.abs($-1),Math.abs(J-1),0.01),j=0;this.#z0={minVal:1-Q-j,maxVal:1+Q+j,totalTime:Z};let q=Math.max(0.05,Math.min(1,this.#M)),N="";for(let O=0;O<_.length;O++){let H=_[O].t/Z*q,A=this.#Y0(H,_[O].value);N+=(O===0?"M":"L")+A.x.toFixed(1)+","+A.y.toFixed(1)}let G=this.#Y0(q,1),K=this.#Y0(1,1);if(N+=`L${G.x.toFixed(1)},${G.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#N.setAttribute("d",N),this.#B){let O=this.#Y0(0,1),H=this.#Y0(1,1);this.#B.setAttribute("x1",O.x),this.#B.setAttribute("y1",O.y),this.#B.setAttribute("x2",H.x),this.#B.setAttribute("y2",H.y)}let X=this.#y0(_),Y=X.t/Z*q,W=this.#Y0(Y,X.value),R=this.#z;this.#K.setAttribute("x",W.x-R),this.#K.setAttribute("y",W.y-R);let L=this.#Y0(q,1);this.#Y.setAttribute("x",L.x-this.#F/2),this.#Y.setAttribute("y",L.y-this.#T/2)}#y0(_){let Z={t:0,value:1},$=!1;for(let J=1;J<_.length-1;J++){let Q=_[J-1],j=_[J],q=_[J+1];if(j.value>=0.99)$=!0;if($&&j.value>Z.value)Z={t:j.t,value:j.value};if($&&j.value>1&&j.value>=Q.value&&j.value>=q.value)return{t:j.t,value:j.value}}return Z}#R0(){if(!this.#R)return;this.#R.value=this.#W,this.#g0()}#q0(){if(!this.#U)return;let _=this.#$==="spring"?this.#U0().toFixed(2):this.value;this.#U.setAttribute("value",_)}#U0(){let{stiffness:_,damping:Z,mass:$}=this.#J,J=2*Math.sqrt(_*$);if(!Number.isFinite(J)||J<=0)return 0;return Math.max(0,Math.min(1,1-Z/J))}#W0(_){let Z=Math.max(0,Math.min(1,Number(_))),$=2*Math.sqrt(this.#J.stiffness*this.#J.mass);this.#J.damping=Number(($*(1-Z)).toFixed(4))}#k0(_,Z){let $=Number(_);if(!Number.isFinite($)){if(Z==="change")this.#q0();return}if(this.#W0($),this.#W=this.#w(),this.#j0(),this.#R0(),Z==="change")this.#q0();this.#J0(Z)}#h0(_){let Z=_.split(",").map(($)=>Number.parseFloat($.trim()));if(Z.length!==4||Z.some(($)=>!Number.isFinite($)))return null;if(Z[0]<0||Z[0]>1||Z[2]<0||Z[2]>1)return null;return Z}#b0(_){return this.#x(_)}#D0(_,Z){let $=this.#k(),J=$==="bezier"?null:this.#b0(_),Q=$==="spring"?null:this.#h0(_);if(!J&&!Q){if(Z==="change")this.#q0();return}let j=this.#$;if(J)this.#$="spring",this.#J=J;else this.#$="bezier",this.#Z.x=Q[0],this.#Z.y=Q[1],this.#_.x=Q[2],this.#_.y=Q[3];if(this.#W=this.#w(),j!==this.#$)this.#m();else if(this.#j0(),this.#R0(),Z==="change")this.#q0();this.#J0(Z)}#I0(_,Z){if(!this.#R)return;for(let $ of this.#R.querySelectorAll("fig-select-option"))if($.value===_){let J=$.querySelector(':scope > [slot="prepend"]');if(J)J.replaceChildren(Z.cloneNode(!0))}}#g0(){if(!this.#R)return;if(!this.#i()&&!customElements.get("fig-popup-easing"))return;let _=h.#o(this.#Z.x,this.#Z.y,this.#_.x,this.#_.y),Z=h.#y(this.#J);this.#I0("Custom bezier",_),this.#I0("Custom spring",Z)}#V0(_){this.#j0(),this.#W=this.#w(),this.#R0(),this.#q0(),this.#J0(_)}#v0(_,Z){let $=_.shiftKey?0.1:0.01,J=Z===1?this.#Z:this.#_;switch(_.key){case"ArrowLeft":J.x-=$;break;case"ArrowRight":J.x+=$;break;case"ArrowUp":J.y+=$;break;case"ArrowDown":J.y-=$;break;case"Home":J.x=0,J.y=0;break;case"End":J.x=1,J.y=1;break;default:return!1}return J.x=Math.max(0,Math.min(1,Math.round(J.x*100)/100)),J.y=Math.round(J.y*100)/100,this.#V0("input"),this.#J0("change"),!0}#m0(_,Z){let $=_.shiftKey?10:1;if(Z==="bounce"){let J=$/100;switch(_.key){case"ArrowUp":this.#W0(this.#U0()+J);break;case"ArrowDown":this.#W0(this.#U0()-J);break;case"Home":this.#W0(0);break;case"End":this.#W0(1);break;default:return!1}}else{let J=$*2;switch(_.key){case"ArrowLeft":this.#M=Math.max(0.05,this.#M-J/200),this.#J.stiffness=Math.max(10,Math.round(this.#J.stiffness+J*1.5));break;case"ArrowRight":this.#M=Math.min(1,this.#M+J/200),this.#J.stiffness=Math.max(10,Math.round(this.#J.stiffness-J*1.5));break;case"Home":this.#M=0.05;break;case"End":this.#M=1;break;default:return!1}}return this.#V0("input"),this.#J0("change"),!0}#M0(_,Z){let $=_?.querySelector("fig-handle");if(!$)return;$.addEventListener("pointerdown",(J)=>{if(J.preventDefault(),J.stopImmediatePropagation(),this.#$==="bezier")this.#B0(J,Number(Z));else this.#H0(J,Z)},{capture:!0}),$.addEventListener("keydown",(J)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(J.key))return;if(!(this.#$==="bezier"?this.#v0(J,Number(Z)):this.#m0(J,Z)))return;J.preventDefault(),J.stopImmediatePropagation()},{capture:!0})}#J0(_){let Z=this.spring;this.dispatchEvent(new CustomEvent(_,{bubbles:!0,detail:{mode:this.#$,value:this.value,cssValue:this.cssValue,preset:this.#W,...Z?{spring:Z}:{}}}))}#p0(){if(this.#G&&this.#$==="bezier"){this.#M0(this.#K,"1"),this.#M0(this.#Y,"2"),this.#K.addEventListener("pointerdown",(Z)=>this.#B0(Z,1)),this.#Y.addEventListener("pointerdown",(Z)=>this.#B0(Z,2));let _=this.querySelector(".fig-easing-curve-svg-container");if(_)_.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#B0(Z,this.#u0(Z))})}else if(this.#G){this.#M0(this.#K,"bounce"),this.#M0(this.#Y,"duration"),this.#K.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#H0(Z,"bounce")}),this.#Y.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#H0(Z,"duration")});let _=this.querySelector(".fig-easing-curve-svg-container");if(_)_.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#H0(Z,"duration")})}if(this.#R){if(!this.#i()&&this.#R.tagName==="FIG-SELECT"){let _=(Z)=>{if(!customElements.get("fig-popup-easing"))return;Z.preventDefault(),Z.stopImmediatePropagation(),this.#C0()};this.#R.addEventListener("click",_,!0),this.#R.addEventListener("keydown",(Z)=>{if(Z.key==="Enter"||Z.key===" ")_(Z)},!0)}this.#R.addEventListener("input",(_)=>{_.stopPropagation()}),this.#R.addEventListener("optionhover",(_)=>{_.stopPropagation()}),this.#R.addEventListener("change",(_)=>{_.stopPropagation();let Z=_.detail,$=h.PRESETS.find((J)=>J.name===Z);if(!$)return;if($.type==="bezier"){if($.value)this.#Z.x=$.value[0],this.#Z.y=$.value[1],this.#_.x=$.value[2],this.#_.y=$.value[3];if(this.#W=Z,this.#$!=="bezier")this.#$="bezier",this.#m();else if(this.#G)this.#j0(),this.#q0()}else if($.type==="spring"){if($.spring)this.#J={...$.spring,initialVelocity:0};if(this.#W=Z,this.#$!=="spring")this.#$="spring",this.#m();else if(this.#G)this.#j0(),this.#q0()}this.#J0("input"),this.#J0("change")})}if(this.#U)this.#U.addEventListener("input",(_)=>{_.stopPropagation();let Z=_.detail??_.target?.value;if(this.#$==="spring")this.#k0(Z,"input");else if(typeof Z==="string")this.#D0(Z,"input")}),this.#U.addEventListener("change",(_)=>{_.stopPropagation();let Z=_.detail??_.target?.value;if(this.#$==="spring")this.#k0(Z,"change");else if(typeof Z==="string")this.#D0(Z,"change")})}#C0(){if(!customElements.get("fig-popup-easing")){this.#P??=customElements.whenDefined("fig-popup-easing").then(()=>{if(!this.isConnected||this.#i())return;this.#C0()});return}let _=this.#V;if(!_?.isConnected){_=document.createElement("dialog",{is:"fig-popup-easing"}),_.setAttribute("is","fig-popup-easing"),_.id=g(),_.anchor=this.#R;let Z=($)=>{$.stopPropagation(),this.value=_.value,this.#J0($.type)};_.addEventListener("input",Z),_.addEventListener("change",Z),(l()??document.body).append(_),this.#V=_,this.#R?.setAttribute("aria-controls",_.id)}this.#A0(),_.open=!0}#A0(){let _=this.#V;if(!_)return;_.anchor=this.#R,_.setAttribute("value",this.value);for(let Z of["mode","precision"]){let $=this.getAttribute(Z);if($===null)_.removeAttribute(Z);else _.setAttribute(Z,$)}}#P0(){if(!this.#V)return;this.#V.open=!1,this.#V.remove(),this.#R?.removeAttribute("aria-controls"),this.#V=null}#S0(_){let Z=this.#G.getScreenCTM();if(!Z)return{x:0,y:0};let $=Z.inverse();return{x:$.a*_.clientX+$.c*_.clientY+$.e,y:$.b*_.clientX+$.d*_.clientY+$.f}}#u0(_){return this.#S0(_).x<=this.#O/2?1:2}#B0(_,Z){_.preventDefault(),this.#j=Z,this.#T0();let $=Z===1?this.#K:this.#Y;this.#$0($,!0);let J=this.#G.getBoundingClientRect(),Q=_.clientX,j=_.clientY,q=_.target?.closest?.(".fig-easing-curve-handle, fig-handle"),N=Z===1?this.#Z:this.#_,G=this.#S0(_),K=q?{...N}:this.#E0(G.x,G.y),{range:X,draw:Y}=this.#F0(),W=X/Math.max(1,Y/this.#L*Math.max(1,J.height)),R=(O)=>{if(!this.#j)return;let H={x:K.x+(O.clientX-Q)/Math.max(1,J.width),y:O.shiftKey?Z===1?0:1:K.y-(O.clientY-j)*W};if(H.x=Math.round(H.x*100)/100,H.y=Math.round(H.y*100)/100,H.x=Math.max(0,Math.min(1,H.x)),this.#j===1)this.#Z.x=H.x,this.#Z.y=H.y;else this.#_.x=H.x,this.#_.y=H.y;this.#j0(),this.#W=this.#w(),this.#R0(),this.#q0(),this.#J0("input")},L=()=>{this.#j=null,this.#T0(),this.#$0($,!1),document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",L),this.#J0("change")};document.addEventListener("pointermove",R),document.addEventListener("pointerup",L)}#H0(_,Z){_.preventDefault(),this.#j=Z,this.classList.toggle("spring-bounce-dragging",Z==="bounce");let $=Z==="bounce"?this.#K:this.#Y;this.#$0($,!0);let J=this.#U0(),Q=this.#J.stiffness,j=this.#M,q=_.clientY,N=_.clientX,G=(X)=>{if(!this.#j)return;if(Z==="bounce"){let Y=X.clientY-q;this.#W0(J-Y/200)}else{let Y=X.clientX-N;this.#M=Math.max(0.05,Math.min(1,j+Y/200)),this.#J.stiffness=Math.max(10,Math.round(Q-Y*1.5))}this.#j0(),this.#W=this.#w(),this.#R0(),this.#q0(),this.#J0("input")},K=()=>{this.#j=null,this.classList.remove("spring-bounce-dragging"),this.#$0($,!1),document.removeEventListener("pointermove",G),document.removeEventListener("pointerup",K),this.#J0("change")};document.addEventListener("pointermove",G),document.addEventListener("pointerup",K)}}F("fig-easing-curve",h);class e extends HTMLElement{#Z=0;#_=0;#J="deg";#$=null;#Q=null;#j=null;#G=null;#N=null;#q=null;#X=null;#K=null;#Y=null;#R=null;#U=null;#W=!1;#B=!1;#M=(_)=>this.#l(_);#O=(_)=>this.#_0(_);#L=(_)=>this.#$0(_);#A=(_)=>this.#K0(_);#I=(_)=>this.#N0(_);#D=(_)=>this.#Z0(_);#H=()=>this.#Q0();static#z(_,Z=12,$=12,J=7,Q=3,j=0){let q=Number(_),N=Number(j),G=Number.isFinite(q)?q:0,K=Number.isFinite(N)?N:0,X=G-K,Y=X<0?"counterclockwise":"clockwise",W=Math.abs(X);if(W<0.001)return{direction:Y,arc:"",arrow:""};let R=(d)=>`${Number(d.x.toFixed(3))} ${Number(d.y.toFixed(3))}`,L=(d)=>{let $0=d*Math.PI/180;return{x:Z+Math.cos($0)*J,y:$+Math.sin($0)*J}},O=X>=0?1:-1,H=Y==="clockwise"?1:0,A=[`M ${R(L(K))}`],z=K,U=Math.floor(W/360);for(let d=0;d<U;d++)z+=O*180,A.push(`A ${J} ${J} 0 0 ${H} ${R(L(z))}`),z+=O*180,A.push(`A ${J} ${J} 0 0 ${H} ${R(L(z))}`);let I=W-U*360;if(I>=0.001)z+=O*I,A.push(`A ${J} ${J} 0 ${I>180?1:0} ${H} ${R(L(z))}`);let V=L(G),P=G*Math.PI/180,S=X>=0?{x:-Math.sin(P),y:Math.cos(P)}:{x:Math.sin(P),y:-Math.cos(P)},w={x:-S.y,y:S.x},f=Q/Math.SQRT2,c={x:V.x-S.x*f+w.x*f,y:V.y-S.y*f+w.y*f},o={x:V.x-S.x*f-w.x*f,y:V.y-S.y*f-w.y*f};return{direction:Y,arc:A.join(" "),arrow:`M ${R(c)} L ${R(V)} L ${R(o)}`}}static#F(_=0,Z=0){let $=e.#z(_,50,50,47,4,Z);return E("svg",{class:"fig-angle-reference",x:"3%",y:"3%",width:"94%",height:"94%",viewBox:"3 3 94 94",fill:"none",overflow:"visible","aria-hidden":"true","data-direction":$.direction},E("path",{class:"fig-angle-reference-path",d:[$.arc,$.arrow].filter(Boolean).join(" "),hidden:!$.arc,fill:"none",stroke:"currentColor","stroke-width":"var(--stroke-width)","stroke-linecap":"round","stroke-linejoin":"round"}))}static rotationIcon(_=0,Z=48){let $=Number.isFinite(Number(Z))?Math.max(1,Number(Z)):48,J=e.#z(_),Q=J.arc?`<path d="${J.arc} ${J.arrow}" fill="none" stroke="currentColor" stroke-width="var(--stroke-width, 1)" stroke-linecap="round" stroke-linejoin="round"></path>`:"";return`<svg width="${$}" height="${$}" viewBox="0 0 24 24" fill="none" data-direction="${J.direction}">${Q}</svg>`}static get observedAttributes(){return["value","default","precision","dial","min","max","step","units","rotations","disabled","aria-label","name"]}connectedCallback(){this.#T(),this.#r()}disconnectedCallback(){this.#G0(),this.#m()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#B)return;if(_==="value"){if(this.#W)return;let J=Number($);if(Number.isFinite(J))this.#c(J,{reflect:!1});return}if(_==="units"&&this.isConnected){let J=this.#p(this.#Z),Q=this.#J;this.#J=this.#P($),this.#V(Q,this.#J),this.#_=this.#S(),this.#c(this.#y(J)),this.#r();return}if(this.#T(),!this.isConnected)return;if(["dial","precision","min","max","step","units","rotations","disabled","aria-label","name"].includes(_)){this.#r();return}this.#c(this.#Z)}get value(){return this.#Z}set value(_){let Z=Number(_);if(!Number.isFinite(Z))return;this.#c(Z)}get defaultValue(){return this.#x()}set defaultValue(_){if(_===null||_===void 0||_===""){this.removeAttribute("default");return}let Z=Number(_);if(Number.isFinite(Z))this.setAttribute("default",String(Z))}get adjacent(){return Math.cos(this.#p(this.#Z)*Math.PI/180)}get opposite(){return Math.sin(this.#p(this.#Z)*Math.PI/180)}focus(_){this.#Q?.focus(_)}#T(){this.#J=this.#P(this.getAttribute("units")),this.#_=this.#S();let _=this.getAttribute("value"),Z=_===null||_.trim()===""?this.#x():Number(_);if(Number.isFinite(Z))this.#Z=this.#f(Z)}#S(){if(!this.hasAttribute("precision")){if(this.#J==="turn")return 3;if(this.#J==="rad")return 2;return 0}let _=Number.parseInt(this.getAttribute("precision"),10);return Number.isFinite(_)?Math.max(0,_):0}#P(_){let Z=String(_||"deg").trim().toLowerCase();if(Z==="°")return"°";return["deg","rad","turn","grad"].includes(Z)?Z:"deg"}#V(_,Z){if(_===Z)return;this.#B=!0;for(let $ of["min","max","default","step"]){let J=this.getAttribute($);if(J===null||J.trim()==="")continue;let Q=Number(J);if(!Number.isFinite(Q))continue;let j=this.#w(this.#g(Q,_),Z);this.setAttribute($,String(j))}this.#B=!1}#k(_,Z=!1){if(!this.hasAttribute(_))return Z;return this.getAttribute(_)?.toLowerCase()!=="false"}#C(){return T(this,"disabled")}#h(){let _=Number(this.getAttribute("min"));return this.hasAttribute("min")&&Number.isFinite(_)?_:null}#E(){let _=Number(this.getAttribute("max"));return this.hasAttribute("max")&&Number.isFinite(_)?_:null}#f(_){let Z=Number(_);if(!Number.isFinite(Z))return this.#Z;let $=this.#h(),J=this.#E();if($!==null)Z=Math.max($,Z);if(J!==null)Z=Math.min(J,Z);return Z}#x(_=this.getAttribute("default")){let Z=_===null||String(_).trim()===""?0:Number(_);return this.#f(Number.isFinite(Z)?Z:0)}#g(_,Z){switch(Z){case"rad":return _*180/Math.PI;case"turn":return _*360;case"grad":return _*0.9;default:return _}}#w(_,Z){switch(Z){case"rad":return _*Math.PI/180;case"turn":return _/360;case"grad":return _/0.9;default:return _}}#p(_){return this.#g(_,this.#J)}#y(_){return this.#w(_,this.#J)}#b(){return this.#J==="deg"?"°":this.#J}#v(){let _=this.#p(this.#Z),Z=_/360,$=Math.round(Z),J=Math.abs(Z-$)<0.0000000001?$:Math.trunc(Z),Q=_-J*360;return{rotations:J,remainder:this.#y(Math.abs(Q)<0.0000000001?0:Q)}}#u(){return this.#k("rotations")?this.#v().remainder:this.#Z}#a(){switch(this.#J){case"rad":return 0.01;case"turn":return 0.001;case"grad":return 0.1;default:return 1}}#o(){let _=Number(this.getAttribute("step"));return this.hasAttribute("step")&&Number.isFinite(_)&&_>0?_:this.#a()}#i(){return this.getAttribute("aria-label")||this.getAttribute("name")||"Angle"}#r(){this.#G0(),this.#m();let _=[],Z=this.#k("rotations")?M("span",{slot:"append",className:"fig-angle-rotations"},M("span",{className:"fig-angle-rotation-value"})):null,$=this.#k("dial",!0),J=M("fig-input-number",{className:"fig-angle-input",variant:$?"ghost":void 0,tabular:!0,name:"angle",value:this.#u(),min:this.#h(),max:this.#E(),step:this.#o(),precision:this.#_,units:this.#b(),disabled:this.#C(),"aria-label":this.#i()},Z);if($){let Q=M("fig-tooltip",{text:"Reset"},M("fig-button",{variant:"ghost",icon:"true",className:"fig-angle-reset",disabled:this.#C(),"aria-label":"Reset to default"},b("reset",{size:"small"}))),j=this.#h()??this.#y(0),q=this.#E()??this.#y(360),N=this.#C(),G=Array.from({length:24},(X,Y)=>{let W=Y*15,R=W*Math.PI/180,L=37,O=W%45===0?31:35;return E("line",{class:W%45===0?"fig-angle-tick fig-angle-tick-major":"fig-angle-tick",x1:50+Math.cos(R)*O,y1:50+Math.sin(R)*O,x2:50+Math.cos(R)*37,y2:50+Math.sin(R)*37})}),K=E("svg",{class:"fig-angle-svg",viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid meet",role:"slider",tabindex:N?"-1":"0","aria-label":this.#i(),"aria-valuemin":j,"aria-valuemax":q,"aria-disabled":N?"true":"false"},[E("rect",{class:"fig-angle-hit-area",x:"0",y:"0",width:"100",height:"100",fill:"transparent"}),E("circle",{class:"fig-angle-boundary",cx:"50",cy:"50",r:"47"}),...G,e.#F(this.#p(this.#Z),this.#p(this.#x())),E("line",{class:"fig-angle-indicator-halo",x1:"75",y1:"50",x2:"87",y2:"50"}),E("line",{class:"fig-angle-indicator",x1:"75",y1:"50",x2:"87",y2:"50"})]);_.push(M("div",{className:"fig-angle-surface"},[K,J,Q]))}else _.push(J);this.replaceChildren(..._),this.#$=this.querySelector(".fig-angle-surface"),this.#Q=this.querySelector(".fig-angle-svg"),this.#j=this.querySelector(".fig-angle-indicator"),this.#G=this.querySelector(".fig-angle-indicator-halo"),this.#N=this.querySelector(".fig-angle-reference"),this.#q=this.querySelector(".fig-angle-input"),this.#X=this.querySelector(".fig-angle-rotations"),this.#K=this.querySelector(".fig-angle-reset"),this.#t(),this.#d()}#t(){this.#Y=new AbortController;let _=this.#Y.signal;this.#Q?.addEventListener("pointerdown",this.#M,{signal:_}),this.#Q?.addEventListener("pointermove",this.#O,{signal:_}),this.#Q?.addEventListener("pointerup",this.#L,{signal:_}),this.#Q?.addEventListener("pointercancel",this.#L,{signal:_}),this.#Q?.addEventListener("lostpointercapture",this.#L,{signal:_}),this.#Q?.addEventListener("keydown",this.#A,{signal:_}),this.#q?.addEventListener("input",this.#I,{signal:_}),this.#q?.addEventListener("change",this.#I,{signal:_}),this.#K?.addEventListener("click",this.#H,{signal:_}),this.addEventListener("change",this.#D,{capture:!0,signal:_})}#m(){this.#Y?.abort(),this.#Y=null}#c(_,{reflect:Z=!0}={}){let $=this.#f(_);if(this.#Z=$,Z){let J=String($);if(this.getAttribute("value")!==J)this.#W=!0,this.setAttribute("value",J),this.#W=!1}this.#d()}#d(){let _=this.#p(this.#Z),$=`rotate(${(_%360+360)%360} 50 50)`;this.#j?.setAttribute("transform",$),this.#G?.setAttribute("transform",$);let J=this.#p(this.#x()),Q=e.#z(_,50,50,47,4,J);this.#N?.setAttribute("data-direction",Q.direction);let j=this.#N?.querySelector(".fig-angle-reference-path");if(j?.setAttribute("d",[Q.arc,Q.arrow].filter(Boolean).join(" ")),j?.toggleAttribute("hidden",!Q.arc),this.#Q){let q=this.#y(0),N=this.#y(360);this.#Q.setAttribute("aria-valuemin",String(this.#h()??Math.min(q,this.#Z))),this.#Q.setAttribute("aria-valuemax",String(this.#E()??Math.max(N,this.#Z))),this.#Q.setAttribute("aria-valuenow",String(this.#Z)),this.#Q.setAttribute("aria-valuetext",`${this.#Z.toFixed(this.#_)}${this.#b()}`)}if(this.#q){let q=this.#u().toFixed(this.#_);if(this.#q.getAttribute("value")!==q)this.#q.setAttribute("value",q)}if(this.#X){let{rotations:q}=this.#v(),N=this.#X.querySelector(".fig-angle-rotation-value");if(N)N.textContent=q?`×${q}`:"";this.#X.hidden=q===0}if(this.#K)this.#K.hidden=this.#Z===this.#x()}#Q0(){if(this.#C())return;this.#c(this.#x()),this.#n("input"),this.#n("change")}#s(_){let Z=this.#$.getBoundingClientRect(),$=Z.left+Z.width/2,J=Z.top+Z.height/2,Q=_.clientX-$,j=_.clientY-J;if(Math.hypot(Q,j)<Math.min(Z.width,Z.height)*0.08)return null;let q=Math.atan2(j,Q)*180/Math.PI;if(q=(q%360+360)%360,_.shiftKey)q=Math.round(q/15)*15;return q}#e(_){let Z=this.#s(_);if(Z===null)return;let $=this.#p(this.#Z),J;if(this.#U===null){let Q=($%360+360)%360;J=Z-Q}else J=Z-this.#U;if(J>180)J-=360;if(J<-180)J+=360;this.#U=Z,this.#c(this.#y($+J)),this.#n("input")}#l(_){if(this.#C()||_.button!==0)return;_.preventDefault(),this.#Q?.focus({preventScroll:!0}),this.#R=_.pointerId,this.#U=null,this.#$.classList.add("dragging");try{this.#Q.setPointerCapture?.(_.pointerId)}catch{}this.#e(_)}#_0(_){if(_.pointerId!==this.#R)return;if(_.buttons===0){this.#$0(_);return}this.#e(_)}#$0(_){if(_.pointerId!==this.#R)return;let Z=this.#R;if(this.#R=null,this.#U=null,this.#$?.classList.remove("dragging"),this.#Q?.hasPointerCapture?.(Z))this.#Q.releasePointerCapture(Z);this.#n("change")}#G0(){this.#R=null,this.#U=null,this.#$?.classList.remove("dragging")}#K0(_){if(this.#C())return;let Z=this.#Z,$=_.key==="ArrowLeft"||_.key==="ArrowDown"?-1:_.key==="ArrowRight"||_.key==="ArrowUp"?1:0;if($){let J=_.shiftKey?this.#y(15):this.#o();Z+=$*J}else if(_.key==="Home")Z=this.#h()??this.#y(0);else if(_.key==="End")Z=this.#E()??this.#y(360);else return;_.preventDefault(),_.stopPropagation(),this.#c(Z),this.#n("input"),this.#n("change")}#N0(_){if(_.stopPropagation(),this.#C())return;let Z=Number(_.currentTarget.value);if(!Number.isFinite(Z))return;if(this.#k("rotations")){let{rotations:$}=this.#v();this.#c(this.#y($*360+this.#p(Z)))}else this.#c(Z);this.#n(_.type)}#Z0(_){if(!_.target?.matches?.("input"))return;let Z=String(_.target.value).match(/^(-?\d*\.?\d+)\s*(deg|°|rad|turn|grad)$/i);if(!Z)return;let $=Number(Z[1]),J=this.#P(Z[2]),Q=$;if(J==="rad")Q=$*180/Math.PI;else if(J==="turn")Q=$*360;else if(J==="grad")Q=$*0.9;_.target.value=String(this.#y(Q))}#n(_){let Z=Number(this.value.toFixed(this.#_));this.dispatchEvent(new CustomEvent(_,{bubbles:!0,cancelable:!0,detail:{value:Z,angle:Z,units:this.#J}}))}}F("fig-angle",e);class w_ extends HTMLElement{#Z=0;#_=0;#J=0;#$=1;#Q=!1;#j=!1;#G=null;#N=null;#q=null;#X=null;#K=(_)=>this.#C(_);#Y=null;#R=[];#U={};#W={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#$=parseInt(this.getAttribute("precision")||"1"),p(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),p(this,"--perspective",this.getAttribute("perspective")),p(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#O(this.getAttribute("transform-origin")),this.#I(this.getAttribute("fields"));let _=this.getAttribute("value");if(_)this.#D(_);if(this.querySelector(".fig-3d-rotate-container"))this.#B();else this.#H();this.#A(this.getAttribute("selected")),this.#L()}disconnectedCallback(){this.#Q=!1,this.#M()}#B(){this.#N=this.querySelector(".fig-3d-rotate-container"),this.#G=this.querySelector(".fig-3d-rotate-cube"),this.#z(),this.#T(),this.#V()}#M(){if(this.#Y?.abort(),this.#Y=null,this.#q)window.removeEventListener("keydown",this.#q),window.removeEventListener("keyup",this.#X),this.#q=null,this.#X=null}#O(_){if(!_||!_.trim()){this.style.removeProperty("--transform-origin");return}let Z=_.trim().split(/\s+/);if(Z.length===2)this.style.setProperty("--transform-origin",`${Z[0]} ${Z[1]} -50cqi`);else this.style.setProperty("--transform-origin",_.trim())}#L(){if(!this.#N)return;this.#N.style.cursor=this.#k?"":"default"}#A(_){if(!this.#G)return;let Z=this.#G.querySelectorAll(".fig-3d-rotate-face"),$=_?_.trim().toLowerCase():"";for(let J of Z)J.classList.toggle("selected",$!==""&&J.classList.contains($))}#I(_){if(!_||!_.trim()){this.#R=[];return}let Z=["rotateX","rotateY","rotateZ"];this.#R=_.split(",").map(($)=>$.trim()).filter(($)=>Z.includes($))}attributeChangedCallback(_,Z,$){if(_==="aspect-ratio"){p(this,"--aspect-ratio",$);return}if(_==="perspective"){p(this,"--perspective",$);return}if(_==="perspective-origin"){p(this,"--perspective-origin",$);return}if(_==="transform-origin"){this.#O($);return}if(_==="selected"){this.#A($);return}if(_==="drag"){this.#L();return}if(_==="fields"){if(this.#I($),this.#G)this.#H();return}if(!this.#G)return;if(_==="value"&&$){if(this.#Q)return;this.#D($),this.#T(),this.#F()}if(_==="precision")this.#$=parseInt($||"1")}get value(){let _=this.#$;return`rotateX(${this.#Z.toFixed(_)}deg) rotateY(${this.#_.toFixed(_)}deg) rotateZ(${this.#J.toFixed(_)}deg)`}set value(_){this.setAttribute("value",_)}get rotateX(){return this.#Z}get rotateY(){return this.#_}get rotateZ(){return this.#J}#D(_){let Z=_.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),$=_.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),J=_.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if(Z)this.#Z=parseFloat(Z[1]);if($)this.#_=parseFloat($[1]);if(J)this.#J=parseFloat(J[1])}#H(){let _={rotateX:"X",rotateY:"Y",rotateZ:"Z"},Z={rotateX:this.#Z,rotateY:this.#_,rotateZ:this.#J},$=M("div",{className:"fig-3d-rotate-cube"},["front","back","right","left","top","bottom"].map((j)=>M("div",{className:`fig-3d-rotate-face ${j}`}))),J=M("div",{className:"fig-3d-rotate-container",tabindex:"0"},M("div",{className:"fig-3d-rotate-scene"},$)),Q=this.#R.map((j)=>M("fig-input-number",{name:j,step:"1",precision:"1",value:Z[j],units:"°"},M("span",{slot:"prepend"},_[j])));this.replaceChildren(J,...Q),this.#N=J,this.#G=$,this.#z(),this.#T(),this.#V()}#z(){this.#U={};for(let _ of this.#R){let Z=this.querySelector(`fig-input-number[name="${_}"]`);if(!Z)continue;if(this.#U[_]=Z,!this.#W[_])this.#W[_]=(J)=>{J.stopPropagation();let Q=parseFloat(J.target.value);if(isNaN(Q))return;if(_==="rotateX")this.#Z=Q;else if(_==="rotateY")this.#_=Q;else if(_==="rotateZ")this.#J=Q;this.#T(),this.#S(J.type)};let $=this.#W[_];Z.removeEventListener("input",$),Z.removeEventListener("change",$),Z.addEventListener("input",$),Z.addEventListener("change",$)}}#F(){let _={rotateX:this.#Z,rotateY:this.#_,rotateZ:this.#J};for(let Z of this.#R){let $=this.#U[Z];if($)$.setAttribute("value",_[Z].toFixed(this.#$))}}#T(){if(!this.#G)return;this.#G.style.transform=`rotateX(${this.#Z}deg) rotateY(${this.#_}deg) rotateZ(${this.#J}deg)`}#S(_){this.dispatchEvent(new CustomEvent(_,{bubbles:!0,detail:{value:this.value,rotateX:this.#Z,rotateY:this.#_,rotateZ:this.#J}}))}#P(_){if(!this.#j)return _;return Math.round(_/15)*15}#V(){if(this.#M(),!this.#N)return;this.#Y=new AbortController,this.#N.addEventListener("pointerdown",this.#K,{signal:this.#Y.signal}),this.#q=(_)=>{if(_.key==="Shift")this.#j=!0},this.#X=(_)=>{if(_.key==="Shift")this.#j=!1},window.addEventListener("keydown",this.#q),window.addEventListener("keyup",this.#X)}get#k(){let _=this.getAttribute("drag");return _===null||_.toLowerCase()!=="false"}#C(_){if(!this.#k)return;_.preventDefault(),this.#Q=!0,this.#N.classList.add("dragging"),this.#N.setPointerCapture(_.pointerId);let{clientX:Z,clientY:$}=_,J=this.#Z,Q=this.#_,j=(N)=>{if(!this.#Q)return;if(N.buttons===0){q();return}let G=N.clientX-Z,K=N.clientY-$;this.#_=this.#P(Q+G*0.5),this.#Z=this.#P(J-K*0.5),this.#T(),this.#F(),this.setAttribute("value",this.value),this.#S("input")},q=()=>{if(!this.#Q)return;this.setAttribute("value",this.value),this.#Q=!1,this.#N.classList.remove("dragging"),this.#N.removeEventListener("pointermove",j),this.#N.removeEventListener("pointerup",q),this.#N.removeEventListener("pointercancel",q),this.#N.removeEventListener("lostpointercapture",q),this.#S("change")};this.#N.addEventListener("pointermove",j),this.#N.addEventListener("pointerup",q),this.#N.addEventListener("pointercancel",q),this.#N.addEventListener("lostpointercapture",q)}}F("fig-3d-rotate",w_);class P0 extends HTMLElement{#Z=50;#_=50;#J=0;#$=null;#Q=[];#j=null;#G=null;#N=null;#q=!1;#X=!1;#K=null;#Y=null;#R=null;static SNAP_POINTS=[0,16.6667,33.3333,50,66.6667,83.3333,100];static get observedAttributes(){return["value","precision","aspect-ratio","drag","fields"]}#U(){this.#$=this.querySelector(".origin-grid"),this.#Q=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#j=this.querySelector("fig-handle"),this.#G=this.querySelector('fig-input-number[name="x"]'),this.#N=this.querySelector('fig-input-number[name="y"]'),this.#T(),this.#S(),this.#H(),this.#v()}connectedCallback(){if(this.#J=parseInt(this.getAttribute("precision")||"0"),p(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#I(this.getAttribute("value")),this.querySelector(".fig-origin-grid-surface"))this.#U();else this.#D();this.#M(),this.#z()}disconnectedCallback(){this.#q=!1,this.#w(),this.#b()}get value(){let _=this.#J;return`${this.#Z.toFixed(_)}% ${this.#_.toFixed(_)}%`}set value(_){this.setAttribute("value",_)}attributeChangedCallback(_,Z,$){if(_==="aspect-ratio"){p(this,"--aspect-ratio",$);return}if(_==="drag"){this.#M();return}if(_==="fields"){this.#D(),this.#M(),this.#z();return}if(_==="precision"){this.#J=parseInt($||"0"),this.#H(),this.#z();return}if(_==="value"){if(this.#X||this.#q)return;this.#I($),this.#T(),this.#S(),this.#H()}}get#W(){let _=this.getAttribute("drag");return _===null||_.toLowerCase()!=="false"}get#B(){let _=this.getAttribute("fields");if(_===null)return!1;return _.toLowerCase()!=="false"}#M(){if(!this.#$)return;this.#$.classList.toggle("drag-disabled",!this.#W)}#O(_){return Math.max(0,Math.min(100,_))}#L(_,Z){let $=(_||"").trim().toLowerCase();if(!$)return Z==="x"?this.#Z:this.#_;let J=Z==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if($ in J)return J[$];let Q=Number.parseFloat($.replace("%",""));if(Number.isFinite(Q))return Q;return Z==="x"?this.#Z:this.#_}#A(_){let Z=_.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if(Z.length<1)return;if(Z.length===1){let $=this.#L(Z[0],"x");this.#Z=$,this.#_=$;return}this.#Z=this.#L(Z[0],"x"),this.#_=this.#L(Z[1],"y")}#I(_){let Z=typeof _==="string"?_.trim():"";if(!Z){this.#Z=50,this.#_=50;return}this.#A(Z)}#D(){let _=Array.from({length:9},(N,G)=>{let K=G%3,X=Math.floor(G/3);return M("span",{className:"origin-grid-cell","data-col":K,"data-row":X},M("span",{className:"origin-grid-dot"}))}),Z=this.#Z.toFixed(this.#J),$=this.#_.toFixed(this.#J),J=document.createElement("fig-handle"),Q=M("div",{className:"origin-grid","aria-label":"Transform origin grid"},[M("div",{className:"origin-grid-cells"},_),J]),q=[M("div",{className:"fig-origin-grid-surface"},Q)];if(this.#B){let N=(G,K)=>M("fig-input-number",{name:G,value:K,step:"1",units:"%"},M("span",{slot:"prepend"},G.toUpperCase()));q.push(M("div",{className:"origin-values"},[N("x",Z),N("y",$)]))}this.replaceChildren(...q),this.#$=Q,this.#Q=_,this.#j=J,this.#G=this.querySelector('fig-input-number[name="x"]'),this.#N=this.querySelector('fig-input-number[name="y"]'),this.#T(),this.#S(),this.#H(),this.#v()}#H(){let _=this.#Z.toFixed(this.#J),Z=this.#_.toFixed(this.#J);if(this.#G)this.#G.setAttribute("value",_);if(this.#N)this.#N.setAttribute("value",Z)}#z(){let _=this.value;if(this.getAttribute("value")===_)return;this.#X=!0,this.setAttribute("value",_),this.#X=!1}#F(_){this.dispatchEvent(new CustomEvent(_,{bubbles:!0,detail:{value:this.value,x:this.#Z,y:this.#_}}))}#T(){if(!this.#j)return;let _=(Z)=>16.6667+this.#O(Z)/100*66.6667;this.#j.style.left=`${_(this.#Z)}%`,this.#j.style.top=`${_(this.#_)}%`}#S(){if(!this.#j)return;let _=this.#Z<0||this.#Z>100,Z=this.#_<0||this.#_>100,$=this.#Z<0,J=this.#Z>100,Q=this.#_<0,j=this.#_>100;this.#j.classList.toggle("beyond-bounds-x",_),this.#j.classList.toggle("beyond-bounds-y",Z),this.#j.classList.toggle("overflow-left",$),this.#j.classList.toggle("overflow-right",J),this.#j.classList.toggle("overflow-up",Q),this.#j.classList.toggle("overflow-down",j)}#P(_,Z){if(!this.#$)return null;let $=this.#$.getBoundingClientRect(),J=(_-$.left)/Math.max($.width,1),Q=(Z-$.top)/Math.max($.height,1);if(J<0||J>1||Q<0||Q>1)return null;let j=Math.max(0,Math.min(2,Math.floor(J*3))),q=Math.max(0,Math.min(2,Math.floor(Q*3)));return this.#Q.find((N)=>Number(N.getAttribute("data-col"))===j&&Number(N.getAttribute("data-row"))===q)}#V(){for(let _ of this.#Q)_.classList.remove("is-hovered")}#k(_){if(this.#V(),_)_.classList.add("is-hovered")}#C(_,Z,$){let J=Number(_),Q=Number(Z);if(!Number.isFinite(J)||!Number.isFinite(Q))return;if(J===this.#Z&&Q===this.#_&&$==="input")return;this.#Z=J,this.#_=Q,this.#T(),this.#S(),this.#H(),this.#z(),this.#F($)}#h(_,Z){if(!this.#$)return{x:this.#Z,y:this.#_};let $=this.#$.getBoundingClientRect(),J=$.width/6,Q=$.height/6,j=Math.max(1,$.width-J*2),q=Math.max(1,$.height-Q*2),N=(_-($.left+J))/j,G=(Z-($.top+Q))/q;return{x:N*100,y:G*100}}#E(_,Z){if(!this.#$)return{x:50,y:50};let $=this.#$.getBoundingClientRect(),J=(_-$.left)/Math.max($.width,1)*3,Q=(Z-$.top)/Math.max($.height,1)*3,j=Math.max(0,Math.min(2,Math.floor(J))),q=Math.max(0,Math.min(2,Math.floor(Q)));return{x:j*50,y:q*50}}#f(_){let $=_,J=1/0;for(let Q of P0.SNAP_POINTS){let j=Math.abs(_-Q);if(j<J)J=j,$=Q}return J<=2.5?$:_}#x(_,Z){if(!Z)return _;return{x:this.#f(_.x),y:this.#f(_.y)}}#g(_){if(!this.#W)return!1;let Z=_.shiftKey?10:1,$=this.#Z,J=this.#_;switch(_.key){case"ArrowLeft":$-=Z;break;case"ArrowRight":$+=Z;break;case"ArrowUp":J-=Z;break;case"ArrowDown":J+=Z;break;case"Home":$=0,J=0;break;case"End":$=100,J=100;break;default:return!1}return this.#C(this.#O($),this.#O(J),"input"),this.#F("change"),!0}#w(){if(!this.#$||!this.#Y||!this.#R)return;this.#$.removeEventListener("pointermove",this.#Y),this.#$.removeEventListener("pointerup",this.#R),this.#$.removeEventListener("pointercancel",this.#R),this.#$.removeEventListener("lostpointercapture",this.#R),this.#Y=null,this.#R=null}#p(_){if(!this.#$||!this.#W)return;_.preventDefault(),this.#q=!0,this.#K=_.pointerId;let{clientX:Z,clientY:$}=_,J=3,Q=!1;this.#$.setPointerCapture(_.pointerId),this.#Y=(j)=>{if(!this.#q||j.pointerId!==this.#K)return;let q=j.clientX-Z,N=j.clientY-$,G=Math.hypot(q,N);if(!Q&&G<J)return;if(!Q)Q=!0,this.#$.classList.add("is-dragging"),this.#V();let K=this.#x(this.#h(j.clientX,j.clientY),j.shiftKey);this.#C(K.x,K.y,"input")},this.#R=(j)=>{if(!this.#q||j.pointerId!==this.#K)return;if(this.#q=!1,this.#K=null,this.#$.classList.remove("is-dragging"),this.#V(),this.#w(),!Q){let q=this.#E(Z,$);this.#C(q.x,q.y,"input")}this.#F("change")},this.#$.addEventListener("pointermove",this.#Y),this.#$.addEventListener("pointerup",this.#R),this.#$.addEventListener("pointercancel",this.#R),this.#$.addEventListener("lostpointercapture",this.#R)}#y=null;#b(){this.#y?.abort(),this.#y=null}#v(){if(this.#b(),!this.#$||!this.#j)return;this.#y=new AbortController;let{signal:_}=this.#y;this.#$.addEventListener("pointerdown",($)=>{let J=this.#P($.clientX,$.clientY);if(this.#k(J),this.#W){this.#p($);return}let Q=this.#E($.clientX,$.clientY);this.#C(Q.x,Q.y,"input"),this.#F("change")},{signal:_}),this.#$.addEventListener("pointermove",($)=>{if(this.#q)return;let J=this.#P($.clientX,$.clientY);this.#k(J)},{signal:_}),this.#$.addEventListener("pointerleave",()=>{this.#V()},{signal:_}),this.#j.addEventListener("keydown",($)=>{if(!this.#g($))return;$.preventDefault(),$.stopPropagation()},{signal:_});let Z=($,J)=>{if(!$)return;let Q=(j)=>{let q=Number.parseFloat(j.target.value);if(!Number.isFinite(q))return;if(J==="x")this.#C(q,this.#_,"input");else this.#C(this.#Z,q,"input")};$.addEventListener("input",Q,{signal:_}),$.addEventListener("change",Q,{signal:_}),$.addEventListener("focusout",()=>{this.#F("change")},{signal:_})};Z(this.#G,"x"),Z(this.#N,"y")}}F("fig-origin-grid",P0);class y_ extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#N=null;#q=!1;#X={x:0.5,y:0.5};#K=!1;constructor(){super();this.position={x:0.5,y:0.5},this.isDragging=!1,this.plane=null,this.cursor=null,this.xInput=null,this.yInput=null,this.coordinates="screen",this.#Z=(_)=>this.#H(_),this.#_=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#J=(_)=>this.#z(_),this.#$=()=>this.#F(),this.#Q=(_)=>this.#L(_),this.#j=(_)=>this.#A(_),this.#G=()=>this.#I(),this.#N=()=>this.#I()}#Y(){this.#M(),this.#P(),this.#k(),this.#C(),this.#K=!0}connectedCallback(){u(this,()=>{if(this.precision=this.getAttribute("precision")||3,this.precision=parseInt(this.precision),this.transform=this.getAttribute("transform")||1,this.transform=Number(this.transform),this.coordinates=this.getAttribute("coordinates")||"screen",p(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");if(this.querySelector(".fig-input-joystick-plane")){this.#Y();return}this.#W(),this.#M(),this.#P(),this.#k(),this.#C(),this.#K=!0})}#R(_){return this.coordinates==="math"?1-_:_}disconnectedCallback(){this.#O()}get#U(){let _=this.getAttribute("fields");if(_===null)return!1;return _.toLowerCase()!=="false"}#W(){let _=this.#B(),Z=M("div",{className:"fig-input-joystick-plane-container"}),$=(q,N)=>N?M("label",{className:["fig-joystick-axis-label",q].join(" "),"aria-hidden":"true"},N):null;Z.append(...[$("left",_.left),$("right",_.right),$("top",_.top),$("bottom",_.bottom)].filter(Boolean));let J=M("div",{className:"fig-input-joystick-plane"},[M("div",{className:"fig-input-joystick-guides"}),M("fig-handle",{drag:!0,"drag-surface":".fig-input-joystick-plane","drag-axes":"x,y","drag-snapping":"modifier"})]),Q=M("fig-tooltip",{text:"Reset"},M("fig-button",{variant:"ghost",icon:"true",className:"fig-joystick-reset","aria-label":"Reset to default"},b("reset",{size:"small"})));Z.append(J,Q);let j=[Z];if(this.#U){let q=(N,G)=>M("fig-input-number",{name:N,step:"1",value:G,min:"0",max:"100",units:"%"},M("span",{slot:"prepend"},N.toUpperCase()));j.push(M("div",{className:"joystick-values"},[q("x",(this.position.x*100).toFixed(this.precision)),q("y",(this.position.y*100).toFixed(this.precision))]))}this.replaceChildren(...j)}#B(){let _=(this.getAttribute("axis-labels")||"").trim();if(!_)return{left:"",right:"",top:"",bottom:""};let Z=_.split(/[\s,]+/).filter(Boolean);if(Z.length===1)return{left:"",right:"",top:Z[0],bottom:""};if(Z.length===2){let[$,J]=Z;return{left:$,right:"",top:"",bottom:J}}if(Z.length===4){let[$,J,Q,j]=Z;return{left:$,right:J,top:Q,bottom:j}}return{left:"",right:"",top:"",bottom:""}}#M(){this.plane=this.querySelector(".fig-input-joystick-plane"),this.cursor=this.querySelector("fig-handle"),this.xInput=this.querySelector("fig-input-number[name='x']"),this.yInput=this.querySelector("fig-input-number[name='y']"),this.plane?.addEventListener("pointerdown",this.#Z),this.cursor?.addEventListener("pointerdown",this.#_),this.cursor?.addEventListener("input",this.#J),this.cursor?.addEventListener("change",this.#$);let _=this.querySelector(".fig-joystick-reset");if(_)_.addEventListener("click",()=>this.#h());if(this.#U&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#Q),this.xInput.addEventListener("change",this.#Q),this.xInput.addEventListener("focusout",this.#G),this.yInput.addEventListener("input",this.#j),this.yInput.addEventListener("change",this.#j),this.yInput.addEventListener("focusout",this.#N)}#O(){if(this.plane?.removeEventListener("pointerdown",this.#Z),this.cursor?.removeEventListener("pointerdown",this.#_),this.cursor?.removeEventListener("input",this.#J),this.cursor?.removeEventListener("change",this.#$),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#U&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#Q),this.xInput.removeEventListener("change",this.#Q),this.xInput.removeEventListener("focusout",this.#G),this.yInput.removeEventListener("input",this.#j),this.yInput.removeEventListener("change",this.#j),this.yInput.removeEventListener("focusout",this.#N)}#L(_){let Z=Number.parseFloat(_.target.value);if(!Number.isFinite(Z))return;this.position.x=Math.max(0,Math.min(1,Z/100)),this.#P(),this.#k(),this.#T()}#A(_){let Z=Number.parseFloat(_.target.value);if(!Number.isFinite(Z))return;this.position.y=Math.max(0,Math.min(1,Z/100)),this.#P(),this.#k(),this.#T()}#I(){this.#k(),this.#S()}#D(_,Z,{syncHandle:$=!0}={}){let J=Math.max(0,Math.min(1,_)),Q=Math.max(0,Math.min(1,Z)),j=this.coordinates==="math"?1-Q:Q;if(this.position={x:J,y:j},$)this.#P();this.#V(),this.#k()}#H(_){if(!this.plane||!this.cursor)return;if(_.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let Z=this.plane.getBoundingClientRect(),$=Z.width>0?(_.clientX-Z.left)/Z.width:0.5,J=Z.height>0?(_.clientY-Z.top)/Z.height:0.5;this.cursor.value=`${Math.round($*100)}% ${Math.round(J*100)}%`,this.#D($,J,{syncHandle:!1}),this.#T(),this.#S()}#z(_){let Z=_.detail??{};if(typeof Z.px!=="number"||typeof Z.py!=="number")return;this.#D(Z.px,Z.py,{syncHandle:!1}),this.#T()}#F(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#k(),this.#S()}#T(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#S(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#P(){let _=this.#R(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${_*100}%`;this.#V()}#V(){if(this.#U&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#k(){let _=this.value;if(this.getAttribute("value")!==_)this.#q=!0,this.setAttribute("value",_),this.#q=!1;this.#C()}#C(){let _=this.#X,Z=Math.round(this.position.x*100)===Math.round(_.x*100)&&Math.round(this.position.y*100)===Math.round(_.y*100);this.toggleAttribute("default",Z),this.style.setProperty("--is-not-default",Z?"0":"1")}#h(){this.position={...this.#X},this.#P(),this.#k(),this.#T(),this.#S()}focus(){this.cursor?.focus()}static get observedAttributes(){return["value","precision","transform","fields","coordinates","aspect-ratio","axis-labels"]}get value(){return`${Math.round(this.position.x*100)}% ${Math.round(this.position.y*100)}%`}set value(_){let Z=_==null?"":String(_).trim();if(!Z)this.position={x:0.5,y:0.5};else{let $=Z.split(/[\s,]+/).filter(Boolean),J=(q)=>{if(!q)return 0.5;let N=q.includes("%"),G=Number.parseFloat(q.replace(/%/g,"").trim());if(!Number.isFinite(G))return 0.5;let K=N||Math.abs(G)>1?G/100:G;return Math.max(0,Math.min(1,K))},Q=J($[0]),j=J($[1]??$[0]);this.position={x:Q,y:j}}if(this.#K)this.#P(),this.#C()}attributeChangedCallback(_,Z,$){if(_==="aspect-ratio"){p(this,"--aspect-ratio",$);return}if(_==="value"){if(this.#q||this.isDragging)return;this.value=$}if(_==="precision")this.precision=parseInt($);if(_==="transform")this.transform=Number($);if(_==="fields"&&$!==Z)this.#O(),this.#W(),this.#M(),this.#P();if(_==="axis-labels"&&$!==Z)this.#O(),this.#W(),this.#M(),this.#P();if(_==="coordinates")this.coordinates=$||"screen",this.#P()}}F("fig-joystick",y_);class S0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let _=this.getAttribute("duration");if(_)this.style.setProperty(this.durationPropertyName,_);this.#Z()}static get observedAttributes(){return["duration","playing","aria-label","aria-labelledby"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(_){if(_)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(_,Z,$){if(_==="duration")this.style.setProperty(this.durationPropertyName,$||"1.5s");if(_==="playing"||_==="aria-label"||_==="aria-labelledby")this.#Z()}#Z(){let _=this.playing;if(this.setAttribute("aria-busy",_?"true":"false"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")){if(!this.hasAttribute("role"))this.setAttribute("role","status");this.removeAttribute("aria-hidden")}else this.removeAttribute("role"),this.setAttribute("aria-hidden","true")}}F("fig-shimmer",S0);class h_ extends S0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}F("fig-skeleton",h_);class b_ extends HTMLElement{static observedAttributes=["name","collapsible","open","compact","chevron"];#Z=null;#_=null;#J=null;#$=null;#Q=null;connectedCallback(){this.#Y()}disconnectedCallback(){this.#j()}#j(){if(this.#_?.removeEventListener("click",this.#X),this.#J?.removeEventListener("click",this.#X),this.#J?.removeEventListener("keydown",this.#K),this.#Z)this.#Z.removeEventListener("click",this.#X),this.#Z.removeEventListener("keydown",this.#K)}attributeChangedCallback(_,Z,$){if(Z===$)return;if(!this.isConnected)return;if(_==="open"){this.#G();return}this.#Y()}get open(){let _=this.getAttribute("open");return _!==null&&_!=="false"}set open(_){let Z=this.open;if(_)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#G(),Z!==!!_)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!_},bubbles:!0}))}#G(){if(this.hasAttribute("collapsible"))this.#J?.setAttribute("aria-expanded",String(this.open));else this.#J?.removeAttribute("aria-expanded")}#N(){if(!this.#$)return;if(this.#Q===null)this.#$.removeAttribute("compact");else this.#$.setAttribute("compact",this.#Q);this.#$=null,this.#Q=null}#q(){if(!(this.hasAttribute("compact")&&this.getAttribute("compact")!=="false")){this.#N();return}if(this.#$!==this.#Z)this.#N(),this.#$=this.#Z,this.#Q=this.#Z?.getAttribute("compact")??null;this.#Z?.setAttribute("compact","")}#X=(_)=>{_.stopPropagation(),this.open=!this.open};#K=(_)=>{if(_.key!=="Enter"&&_.key!==" ")return;_.preventDefault(),_.stopPropagation(),this.open=!this.open};#Y(){this.#j();let _=this.hasAttribute("collapsible"),$=this.getAttribute("name")||(_?"Group":null),J=this.querySelector(":scope > fig-header:not([data-generated])");if(!$&&!_&&!J){if(this.#Z&&this.#Z.dataset.generated)this.#N(),this.#Z.remove(),this.#Z=null,this.#_=null,this.#J=null;return}if(J)this.querySelectorAll(":scope > fig-header[data-generated]").forEach((j)=>j.remove()),this.#Z=J;else if(!this.#Z||!this.#Z.dataset.generated)this.#Z=document.createElement("fig-header"),this.#Z.setAttribute("borderless",""),this.#Z.dataset.generated="true",this.prepend(this.#Z);this.#q();let Q=this.#Z.querySelector("h3");if(!Q)Q=document.createElement("h3"),this.#Z.prepend(Q);if(this.#J=Q,!Q.id)Q.id=g();if(this.#Z.dataset.generated)Q.textContent=$;if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",Q.id);if(_){let j=this.#Z.querySelector(".fig-group-chevron");if(!j)j=b("chevron",{size:"small",className:"fig-group-chevron"});let q=this.getAttribute("chevron")==="end";if(j.setAttribute("size",q?"medium":"small"),q){if(Q.nextSibling!==j)this.#Z.insertBefore(j,Q.nextSibling)}else if(Q.previousSibling!==j)this.#Z.insertBefore(j,Q);if(this.#_=j,this.#Z.removeAttribute("role"),this.#Z.removeAttribute("tabindex"),this.#Z.removeAttribute("aria-expanded"),Q.setAttribute("role","button"),Q.setAttribute("tabindex","0"),Q.setAttribute("aria-expanded",String(this.open)),Q.addEventListener("click",this.#X),Q.addEventListener("keydown",this.#K),j.addEventListener("click",this.#X),!this.hasAttribute("open"))this.setAttribute("open","false"),Q.setAttribute("aria-expanded","false")}else{if(Q.removeAttribute("role"),Q.removeAttribute("tabindex"),Q.removeAttribute("aria-expanded"),this.#Z.removeAttribute("role"),this.#Z.removeAttribute("tabindex"),this.#Z.removeAttribute("aria-expanded"),this.#_)this.#_.remove(),this.#_=null;this.removeAttribute("open")}}}F("fig-group",b_);class g_ extends HTMLElement{}F("fig-header",g_);class v_ extends HTMLElement{}F("fig-footer",v_);class m_ extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Loading")}}F("fig-spinner",m_);class p_ extends HTMLElement{static get observedAttributes(){return["fit","aspect-ratio"]}connectedCallback(){this.#Z(),this.#_()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="fit")this.#Z();if(_==="aspect-ratio")this.#_()}#Z(){let _=this.getAttribute("fit");if(_)this.style.setProperty("--fig-preview-fit",_);else this.style.removeProperty("--fig-preview-fit")}#_(){let _=this.getAttribute("aspect-ratio");if(_)this.style.setProperty("--fig-preview-aspect-ratio",_);else this.style.removeProperty("--fig-preview-aspect-ratio")}}F("fig-preview",p_);var B1={chevron:{medium:"--icon-24-chevron",small:"--icon-16-chevron"},checkmark:{medium:"--icon-24-checkmark",small:"--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",send:{medium:"--icon-24-send",small:"--icon-16-send"},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",image:"--icon-24-image",video:{medium:"--icon-24-video",small:"--icon-16-video"},audio:"--icon-24-audio",sound:{medium:"--icon-24-sound",small:"--icon-16-sound"},"sound-off":{medium:"--icon-24-sound-off",small:"--icon-16-sound-off"},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"},globe:{medium:"--icon-24-globe",small:"--icon-16-globe"},warning:{medium:"--icon-24-warning",small:"--icon-16-warning"},copy:{medium:"--icon-24-copy",small:"--icon-16-copy"},trash:{medium:"--icon-24-trash",small:"--icon-16-trash"},"drag-handle":"--icon-16-drag-handle"};function H1(_,Z="medium"){let $=_&&B1[_];if(!$)return"";let J=typeof $==="string"?$:$[Z==="small"?"small":"medium"];return J?`var(${J})`:""}var F1={primary:"--figma-color-icon",secondary:"--figma-color-icon-secondary",tertiary:"--figma-color-icon-tertiary",disabled:"--figma-color-icon-disabled",brand:"--figma-color-icon-brand",component:"--figma-color-icon-component",danger:"--figma-color-icon-danger",success:"--figma-color-icon-success",warning:"--figma-color-icon-warning",selected:"--figma-color-icon-selected",hover:"--figma-color-icon-hover",pressed:"--figma-color-icon-pressed",onbrand:"--figma-color-icon-onbrand",oncomponent:"--figma-color-icon-oncomponent",ondanger:"--figma-color-icon-ondanger",ondisabled:"--figma-color-icon-ondisabled",oninverse:"--figma-color-icon-oninverse",onselected:"--figma-color-icon-onselected",onsuccess:"--figma-color-icon-onsuccess",onwarning:"--figma-color-icon-onwarning"};function A1(_){if(!_)return"";if(_.startsWith("var("))return _;let Z=F1[_.toLowerCase()];return Z?`var(${Z})`:_}class u_ extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#Z()}attributeChangedCallback(_,Z,$){if(Z!==$)this.#Z()}#Z(){let _=this.getAttribute("name"),Z=this.getAttribute("size")||"medium",$=H1(_,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=A1(this.getAttribute("color"));if(J)this.style.backgroundColor=J,this.style.setProperty("--icon-color",J);else this.style.removeProperty("background-color"),this.style.removeProperty("--icon-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}F("fig-icon",u_);class c_ extends HTMLElement{}F("fig-content",c_);class d_ extends HTMLElement{}F("fig-tab-content",d_);class s_ extends HTMLElement{}F("fig-button-combo",s_);class i_ extends HTMLElement{}F("fig-input-combo",i_);class o_ extends HTMLElement{static get observedAttributes(){return["gap","columns","min-width"]}connectedCallback(){this.#Z()}attributeChangedCallback(){this.#Z()}#Z(){let _=this.getAttribute("gap")?.trim();this.#_("--fig-stack-gap",_&&/^(\d+(-5)?|half)$/.test(_)?`var(--spacer-${_})`:_);let Z=this.getAttribute("columns")?.trim();this.#_("--fig-stack-columns",Z&&/^\d+$/.test(Z)?`repeat(${Z}, minmax(0, 1fr))`:Z),this.#_("--fig-stack-min-width",this.getAttribute("min-width")?.trim())}#_(_,Z){if(Z)this.style.setProperty(_,Z);else this.style.removeProperty(_)}}F("fig-stack",o_);class r_ extends HTMLElement{#Z=null;#_=null;#J=null;#$=this.#O.bind(this);#Q=this.#L.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#j(){return this.getAttribute("control")||"color"}connectedCallback(){this.#X(),this.#W()}disconnectedCallback(){this.#G(),this.removeEventListener("click",this.#K)}#G(){if(this.#Z)this.#Z.removeEventListener("input",this.#$),this.#Z.removeEventListener("change",this.#Q);if(this.#_)this.#_.removeEventListener("input",this.#$),this.#_.removeEventListener("change",this.#Q);if(this.#J)this.#J.disconnect(),this.#J=null}#N(){if(this.#J)this.#J.disconnect(),this.#J=null;if(!this.#_)return;this.#J=new MutationObserver(()=>{if(this.#_?.hasAttribute("selected")&&this.#_.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#J.observe(this.#_,{attributes:!0,attributeFilter:["selected"]})}get#q(){let _=this.getAttribute("alpha");return _===null||_!=="false"}#X(){this.#G();let _=this.#j;if(_==="add"||_==="remove"){let N=_==="add"?"add":"minus",G=this.getAttribute("aria-label")||(_==="add"?"Add color stop":"Remove color stop");this.replaceChildren(M("fig-button",{icon:!0,variant:"ghost","aria-label":G},b(N))),this.#Z=null,this.#_=null,this.addEventListener("click",this.#K),this.#B();return}this.removeEventListener("click",this.#K);let Z=(this.getAttribute("value")||"").trim(),$=this.#U(Z),J=this.#R(Z),Q=J<1?JSON.stringify({type:"solid",color:$,opacity:Math.round(J*100)}):JSON.stringify({type:"solid",color:$}),j=M("fig-swatch",{background:$,alpha:J<1?J:null}),q=null;if(q0())q=M("fig-fill-picker",{mode:"solid",alpha:this.#q?null:"false",value:Q},j),this.replaceChildren(q);else this.replaceChildren(j);if(this.#Z=q,this.#_=j,this.#Z?.addEventListener("input",this.#$),this.#Z?.addEventListener("change",this.#Q),!this.#Z)this.#_?.addEventListener("input",this.#$),this.#_?.addEventListener("change",this.#Q);this.#N(),this.#B()}#K=()=>{let _=this.#j;this.dispatchEvent(new CustomEvent(_,{bubbles:!0,composed:!0}))};#Y(_){if(!_)return"#D9D9D9";let Z=_.replace("#","").trim();if(Z.length===3||Z.length===4){let[$,J,Q]=Z;return`#${$}${$}${J}${J}${Q}${Q}`.toUpperCase()}if(Z.length===6||Z.length===8)return`#${Z.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#R(_){if(!_)return 1;let Z=String(_).trim(),$=Z.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test($)){let Q=$[3];return parseInt(`${Q}${Q}`,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(_){if(!_)return"#D9D9D9";let Z=String(_).trim();if(Z.startsWith("{"))try{let $=JSON.parse(Z);if($?.color)return this.#U($.color)}catch{}if(Z.startsWith("#"))return this.#Y(Z);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Z))return this.#Y(Z);try{let{ctx:$}=D0(1,1);$.fillStyle="#000000",$.fillStyle=Z;let J=$.fillStyle;if(J.startsWith("#"))return this.#Y(J);let Q=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(Q){let j=(q)=>Math.max(0,Math.min(255,Number(q))).toString(16).padStart(2,"0");return`#${j(Q[1])}${j(Q[2])}${j(Q[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#W(){let _=this.getAttribute("value"),Z=this.#U(_),$=this.#R(_);if(_!==Z&&$>=1){this.setAttribute("value",Z);return}if(this.#Z){this.#B();let J=$<1?{type:"solid",color:Z,opacity:Math.round($*100)}:{type:"solid",color:Z};if(this.#Z.setAttribute("value",JSON.stringify(J)),this.#q)this.#Z.removeAttribute("alpha");else this.#Z.setAttribute("alpha","false");if(T(this,"disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}if(this.#_){if(this.#B(),this.#_.setAttribute("background",Z),$<1)this.#_.setAttribute("alpha",String($));else this.#_.removeAttribute("alpha");if(T(this,"disabled"))this.#_.setAttribute("disabled","");else this.#_.removeAttribute("disabled")}}#B(){let _=this.#j,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"),_==="add"||_==="remove"){let N=this.querySelector("fig-button"),G=this.getAttribute("aria-label")||(_==="add"?"Add color stop":"Remove color stop");if(N?.setAttribute("aria-label",G),Z)N?.setAttribute("disabled","");else N?.removeAttribute("disabled");return}let J=this.#Z||this.#_;if(!J)return;let Q=this.getAttribute("aria-label")||"Color stop",j=this.getAttribute("aria-labelledby"),q=this.getAttribute("aria-describedby");if(j)J.setAttribute("aria-labelledby",j),J.removeAttribute("aria-label");else J.setAttribute("aria-label",Q),J.removeAttribute("aria-labelledby");if(q)J.setAttribute("aria-describedby",q);else J.removeAttribute("aria-describedby")}#M(_,Z){let $=this.#U(_?.color),J=this.#U(this.getAttribute("value"));if($!==J)this.setAttribute("value",$);else this.#W();let Q={color:this.value};if(this.#q){if(_?.opacity!==void 0)Q.opacity=_.opacity;else if(_?.alpha!==void 0)Q.opacity=Math.round(_.alpha*100)}Object.assign(Q,t(Q.color,this.#q?_?.alpha:1,Q.opacity)),this.dispatchEvent(new CustomEvent(Z,{bubbles:!0,cancelable:!0,composed:!0,detail:Q}))}#O(_){_.stopPropagation(),this.#M(_.detail||{color:_.target?.value},"input")}#L(_){_.stopPropagation(),this.#M(_.detail||{color:_.target?.value},"change")}attributeChangedCallback(_,Z,$){if(Z===$)return;if(!this.isConnected)return;switch(_){case"control":this.#X();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#W(),this.#B();break}}get value(){return this.#U(this.getAttribute("value"))}set value(_){if(_===null||_===void 0||_===""){this.removeAttribute("value");return}this.setAttribute("value",this.#U(_))}get selected(){return T(this,"selected")}set selected(_){this.toggleAttribute("selected",Boolean(_))}get disabled(){return T(this,"disabled")}set disabled(_){this.toggleAttribute("disabled",Boolean(_))}}F("fig-color-tip",r_);class l_ extends HTMLElement{#Z=null;static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.#_(),T(this,"disabled"))this.setAttribute("aria-disabled","true")}disconnectedCallback(){this.#Z?.disconnect()}#_(){let _=T(this,"selected");this.setAttribute("aria-selected",_?"true":"false");for(let Z of this.children)Z.toggleAttribute("selected",_);if(this.#Z?.disconnect(),_&&this.isConnected)this.#Z??=new MutationObserver(()=>this.#_()),this.#Z.observe(this,{childList:!0})}attributeChangedCallback(_){if(_==="selected")this.#_();if(_==="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")}}F("fig-choice",l_);class a_ extends HTMLElement{#Z=null;#_=this.#A.bind(this);#J=this.#I.bind(this);#$=this.#H.bind(this);#Q=null;#j=null;#G=null;#N=null;#q=null;#X=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop","auto-scroll"]}get#K(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#Y(){let _=this.getAttribute("drag");return _===null||_!=="false"}get autoScroll(){let _=this.getAttribute("auto-scroll");return _===null||_!=="false"}set autoScroll(_){if(_===!1||_==="false"||_===null)this.setAttribute("auto-scroll","false");else this.removeAttribute("auto-scroll")}get scrollBehavior(){return this.getAttribute("scroll-behavior")==="auto"?"auto":"smooth"}set scrollBehavior(_){if(_==="auto"||_==="smooth")this.setAttribute("scroll-behavior",_);else this.removeAttribute("scroll-behavior")}get#R(){return this.getAttribute("choice-element")||"fig-choice"}#U(){let _=this.getAttribute("columns"),Z=_===null?NaN:Number(_);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.#R}`))}get selectedChoice(){return this.#Z}set selectedChoice(_){if(_&&!this.contains(_))return;let Z=this.choices;for(let J of Z){let Q=J===_,j=T(J,"selected");if(Q&&!j)J.setAttribute("selected","");else if(!Q&&j)J.removeAttribute("selected")}this.#Z=_??null;let $=_?.getAttribute("value")??"";if(this.getAttribute("value")!==$)this.setAttribute("value",$);if(this.autoScroll)this.#f(_)}get value(){return this.#Z?.getAttribute("value")??""}set value(_){if(_===null||_===void 0||_===""){this.setAttribute("value","");return}this.setAttribute("value",String(_))}scrollSelectionIntoView(_={}){if(!this.#Z)return;this.#f(this.#Z,_)}connectedCallback(){if(this.setAttribute("role","listbox"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.#S(),this.addEventListener("click",this.#_),this.addEventListener("keydown",this.#J),this.addEventListener("scroll",this.#$),this.#P(),this.#F(),this.#g(),this.#z(),this.#M(),u(this,()=>{this.#B(),this.#H(),this.#W()})}#W(){requestAnimationFrame(()=>{if(!this.isConnected||!this.autoScroll)return;if(this.#Z)this.#f(this.#Z)})}disconnectedCallback(){this.removeEventListener("click",this.#_),this.removeEventListener("keydown",this.#J),this.removeEventListener("scroll",this.#$),this.#T(),this.#Q?.disconnect(),this.#Q=null,this.#j?.disconnect(),this.#j=null,this.#V()}attributeChangedCallback(_,Z,$){if(_==="value"&&$!==Z)if($==="")this.selectedChoice=null;else if($==null)this.#B();else this.#O($);if(_==="disabled")this.#M();if(_==="choice-element")requestAnimationFrame(()=>{this.#U(),this.#B()});if(_==="columns")this.#U(),this.#E();if(_==="drag")if(this.#Y)this.#F();else this.#T();if(_==="overflow")this.#P(),requestAnimationFrame(()=>this.#H());if(_==="layout"){if(this.#U(),this.#P(),$==="horizontal")this.scrollTop=0;else this.scrollLeft=0;this.#E()}if(_==="auto-scroll"&&this.autoScroll)this.#E()}#B(){let _=this.choices;if(!_.length){this.#Z=null;return}let Z=this.hasAttribute("value"),$=this.getAttribute("value");if(Z&&$===""){this.selectedChoice=null;return}if($&&this.#O($))return;let J=_.find((Q)=>T(Q,"selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=_[0]}#M(){let _=T(this,"disabled");if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Z of this.choices)if(_||T(Z,"disabled"))Z.setAttribute("aria-disabled","true"),Z.setAttribute("tabindex","-1");else Z.removeAttribute("aria-disabled"),Z.setAttribute("tabindex","0")}#O(_){let Z=this.choices;for(let $ of Z)if($.getAttribute("value")===_)return this.selectedChoice=$,!0;return!1}#L(_){let Z=this.#R,$=_;while($&&$!==this){if($.matches(Z))return $;$=$.parentElement}return null}#A(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#L(_.target);if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.selectedChoice=Z,this.#D()}#I(_){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 $=this.#L(_.target),J=Z.indexOf($),Q=J,j=this.hasAttribute("loop");switch(_.key){case"ArrowDown":case"ArrowRight":if(_.preventDefault(),J<Z.length-1)Q=J+1;else if(j)Q=0;break;case"ArrowUp":case"ArrowLeft":if(_.preventDefault(),J>0)Q=J-1;else if(j)Q=Z.length-1;break;case"Home":_.preventDefault(),Q=0;break;case"End":_.preventDefault(),Q=Z.length-1;break;case"Enter":case" ":if(_.preventDefault(),$&&$!==this.#Z)this.selectedChoice=$,this.#D();return;default:return}if(Q!==J&&Z[Q]){let q=Z[Q];if(q.focus({preventScroll:!0}),this.autoScroll)this.#f(q)}}#D(){let _=this.value;this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#H(){if(this.#K==="scrollbar")return;let _=this.getAttribute("layout")==="horizontal";L0(this,this,_?"x":"y")}#z(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#H(),this.#E()}),this.#j.observe(this)}#F(){if(this.#q?.bound)return;if(!this.#Y)return;let _=(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.#q.active=!0,this.#q.didDrag=!1,this.#q.startX=q.clientX,this.#q.startY=q.clientY,this.#q.scrollLeft=this.scrollLeft,this.#q.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Z=(q)=>{if(!this.#q.active)return;let N=this.getAttribute("layout")==="horizontal",G=q.clientX-this.#q.startX,K=q.clientY-this.#q.startY;if(!this.#q.didDrag&&Math.abs(N?G:K)>3)this.#q.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(q.pointerId);if(!this.#q.didDrag)return;if(N)this.scrollLeft=this.#q.scrollLeft-G;else this.scrollTop=this.#q.scrollTop-K},$=(q)=>{if(!this.#q.active)return;let N=this.#q.didDrag;if(this.#q.active=!1,this.#q.didDrag=!1,this.style.cursor="",this.style.userSelect="",q.pointerId!==void 0)try{this.releasePointerCapture(q.pointerId)}catch{}if(N)q.preventDefault(),q.stopPropagation()},J=(q)=>{if(this.#q?.suppressClick)q.stopPropagation(),q.preventDefault(),this.#q.suppressClick=!1},Q=(q)=>{if(this.#q?.didDrag)this.#q.suppressClick=!0,setTimeout(()=>{if(this.#q)this.#q.suppressClick=!1},0)},j=(q)=>{if(this.#q?.active)q.preventDefault()};this.#q={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:_,onPointerMove:Z,onPointerUp:$,onClick:J,onPointerUpCapture:Q,onDragStart:j},this.addEventListener("pointerdown",_),window.addEventListener("pointermove",Z),window.addEventListener("pointerup",$),this.addEventListener("pointerup",Q,!0),this.addEventListener("click",J,!0),this.addEventListener("dragstart",j)}#T(){if(!this.#q?.bound)return;this.removeEventListener("pointerdown",this.#q.onPointerDown),window.removeEventListener("pointermove",this.#q.onPointerMove),window.removeEventListener("pointerup",this.#q.onPointerUp),this.removeEventListener("pointerup",this.#q.onPointerUpCapture,!0),this.removeEventListener("click",this.#q.onClick,!0),this.removeEventListener("dragstart",this.#q.onDragStart),this.style.cursor="",this.style.userSelect="",this.#q=null}#S(){if(this.#X)return;let _=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!_)return;this.#X=!0;try{let Z=Array.from(_.childNodes);_.replaceWith(...Z)}finally{this.#X=!1}}#P(){let _=this.#K==="scrollbar",Z=this.getAttribute("layout")==="grid";if(_||Z)this.#V(),this.classList.toggle("fig-overflow-fade",_),this.classList.toggle("fig-overflow-fade-horizontal",_&&this.getAttribute("layout")==="horizontal");else this.#k(),this.classList.remove("fig-overflow-fade","fig-overflow-fade-horizontal")}#V(){this.#G?.remove(),this.#N?.remove(),this.#G=null,this.#N=null,this.classList.remove("overflow-start","overflow-end")}#k(){if(this.#G&&this.#N&&this.contains(this.#G)&&this.contains(this.#N)){this.#C();return}this.#G?.remove(),this.#N?.remove(),this.#G=null,this.#N=null;let _=W0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#h(-1),onEnd:()=>this.#h(1)});this.#G=_.start,this.#N=_.end,this.#C()}#C(){if(this.firstElementChild!==this.#G)this.prepend(this.#G);if(this.lastElementChild!==this.#N)this.append(this.#N)}#h(_){let Z=this.getAttribute("layout")==="horizontal";Z0(this,Z?"x":"y",_,"auto")}#E(){if(!this.autoScroll||!this.#Z)return;this.#f(this.#Z)}#f(_,Z={}){if(!_)return;let $=typeof Z==="object"&&Z!==null?Z:{},J=$.behavior==="smooth"||$.behavior==="instant"?$.behavior:"auto",Q=$.block||"center",j=$.inline||"center";requestAnimationFrame(()=>{if(!_.isConnected)return;let q=this.scrollHeight>this.clientHeight,N=this.scrollWidth>this.clientWidth;if(!N&&!q)return;let G=_.getBoundingClientRect(),K=this.getBoundingClientRect(),X={behavior:J},Y=!1;if(q){let W=G.top-K.top+this.scrollTop,R=this.scrollHeight-this.clientHeight;X.top=this.#x(W,G.height,this.clientHeight,this.scrollTop,R,Q),Y=!0}if(N){let W=G.left-K.left+this.scrollLeft,R=this.scrollWidth-this.clientWidth;X.left=this.#x(W,G.width,this.clientWidth,this.scrollLeft,R,j),Y=!0}if(Y)this.scrollTo(X);this.#H()})}#x(_,Z,$,J,Q,j){let q;if(j==="start")q=_;else if(j==="end")q=_+Z-$;else if(j==="nearest"){let N=J,G=J+$,K=_+Z;if(_>=N&&K<=G)q=J;else if(_<N)q=_;else q=K-$}else q=_+Z/2-$/2;return Math.max(0,Math.min(q,Q))}#g(){this.#Q?.disconnect(),this.#Q=new MutationObserver(()=>{if(this.#X)return;this.#S(),this.#U(),this.#P(),this.#M();let _=this.choices;if(this.#Z&&!_.includes(this.#Z))this.#Z=null,this.#B();else if(!this.#Z&&_.length)this.#B();requestAnimationFrame(()=>this.#H())}),this.#Q.observe(this,{childList:!0,subtree:!1})}}F("fig-chooser",a_);class t_ extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","precision","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#Z=!1;#_=!1;#J=null;#$=null;#Q=!1;#j=null;#G=null;#N=null;#q=null;get#X(){let _=(this.getAttribute("tip")||"").trim().toLowerCase();return _==="color"||_==="add"||_==="remove"?_:null}get#K(){return!this.hasAttribute("data-no-color-picker")}get#Y(){let _=this.getAttribute("drag");return _!==null&&_!=="false"}get#R(){let _=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:_.includes("x"),y:_.includes("y")}}get#U(){let _=this.getAttribute("drag-snapping");if(_===null)return"false";let Z=_.trim().toLowerCase();if(Z==="modifier")return"modifier";if(Z===""||Z==="true")return"true";return"false"}#W(_){let Z=this.#U;if(Z==="true")return!0;if(Z==="modifier")return!!_;return!1}#B(_){if(_<0.1)return 0;if(_>0.9)return 1;if(_>0.4&&_<0.6)return 0.5;return _}#M(_,Z){if(Math.abs(_-Z)<0.1){let J=(_+Z)/2;return{x:J,y:J}}if(Math.abs(1-_-Z)<0.1)return{x:_,y:1-_};return{x:_,y:Z}}#O(){let _=this.getAttribute("drag-surface");if(!_||_==="parent")return this.parentElement;return this.closest(_)}get value(){let _=this.#O();if(!_)return"0% 0%";let{px:Z,py:$}=this.#n(_.getBoundingClientRect());return`${(Z*100).toFixed(this.precision)}% ${($*100).toFixed(this.precision)}%`}set value(_){this.setAttribute("value",_??"0% 0%")}get precision(){let _=Number(this.getAttribute("precision")??2);if(!Number.isFinite(_))return 2;return Math.max(0,Math.min(10,Math.trunc(_)))}set precision(_){if(_===null||_===void 0||_==="")this.removeAttribute("precision");else{let Z=Number(_),$=Number.isFinite(Z)?Math.max(0,Math.min(10,Math.trunc(Z))):2;this.setAttribute("precision",String($))}}#L(_){let Z=10**this.precision,$=Math.round(_*Z)/Z;return Object.is($,-0)?0:$}#A(_){let Z=_==null?"":String(_).trim();if(!Z)return{xPct:0,yPct:0};let $=Z.split(/[\s,]+/).filter(Boolean),J=(q)=>{if(!q)return 0;let N=q.includes("px"),G=q.includes("%"),K=parseFloat(q.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(N)return{px:K};if(G||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},Q=J($[0]),j=J($[1]??$[0]);return{xToken:Q,yToken:j}}#I(_){let Z=this.#O();if(!Z)return;let{xToken:$,yToken:J}=this.#A(_),Q=Z.getBoundingClientRect(),j=(G,K)=>{if(G&&typeof G==="object"&&"px"in G)return Math.max(0,Math.min(K,G.px));return null},q=(G)=>{let K=typeof G==="number"?G:0;return`${this.#L(K)}%`},N=this.#R;if(this.#D(N),N.x){let G=j($,Q.width);this.style.left=G===null?q($):`${this.#L(G)}px`}if(N.y){let G=j(J,Q.height);this.style.top=G===null?q(J):`${this.#L(G)}px`}}#D(_=this.#R){this.style.setProperty("--fig-handle-position-translate",`${_.x?"-50%":"0"} ${_.y?"-50%":"0"}`)}#H(){this.#Q=!0,this.setAttribute("value",this.value),this.#Q=!1}get#z(){return this.getAttribute("hit-area-mode")||"handle"}#F(){let _=this.getAttribute("hit-area");if(!_)return null;let Z=_.trim().split(/\s+/),$=0,J=0,Q=!1,j=[];for(let q of Z){if(q==="circle"){Q=!0;continue}let N=parseFloat(q);if(Number.isFinite(N))j.push(N)}if(j.length>=2)$=j[0],J=j[1];else if(j.length===1)$=j[0],J=j[0];else return null;return{vPad:$,hPad:J,circle:Q}}#T(){let _=this.#F();if(!_){if(this.#q)this.#q.remove(),this.#q=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#q){let Z=document.createElement("div");Z.classList.add("fig-handle-hit-area"),Z.addEventListener("pointerdown",($)=>this.#S($)),this.prepend(Z),this.#q=Z}if(this.style.setProperty("--fig-handle-hit-area-size",String(_.hPad*2)),_.circle)this.#q.style.borderRadius="50%";else this.#q.style.borderRadius="inherit"}#S(_){if(T(this,"disabled"))return;if(_.target!==this.#q)return;if(this.#z==="delegate")_.preventDefault(),_.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:_}}));else this.#g(_)}connectedCallback(){this.#f(),this.#E(),this.#T(),this.addEventListener("click",this.#P),this.addEventListener("blur",this.#k),document.addEventListener("pointerdown",this.#V),document.addEventListener("keydown",this.#C);let _=this.getAttribute("value");if(_)this.#I(_);if(this.#X)this.#t()}disconnectedCallback(){if(this.#x(),this.#m(),this.#u(),this.#i(),this.#q)this.#q.remove(),this.#q=null;this.removeEventListener("click",this.#P),this.removeEventListener("blur",this.#k),document.removeEventListener("pointerdown",this.#V),document.removeEventListener("keydown",this.#C)}select(){if(T(this,"disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#P=(_)=>{if(this.#_){this.#_=!1;return}if(this.select(),this.getAttribute("type")==="color"&&this.#K&&!this.#X)this.#v()};#V=(_)=>{if(this.contains(_.target))return;if((this.#j||this.#G)&&_.target.closest?.("dialog, [popover]"))return;this.deselect()};#k=()=>{this.removeAttribute("data-fig-pointer-focus")};#C=(_)=>{if(this.removeAttribute("data-fig-pointer-focus"),_.defaultPrevented)return;if(_.target===this&&this.#Y&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(_.key)){if(this.#h(_)){if(_.preventDefault(),!T(this,"selected"))this.select()}return}if(_.key!=="Enter"&&_.key!==" ")return;if(_.target===this&&!T(this,"selected")){if(_.preventDefault(),this.getAttribute("type")==="color"&&this.#K&&!this.#X)this.#v();else this.select();return}if(!T(this,"selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#K)return;if(_.preventDefault(),!this.#X)this.#v()};#h(_){if(T(this,"disabled"))return!1;let Z=this.#O();if(!Z)return!1;let $=Z.getBoundingClientRect();if($.width<=0||$.height<=0)return!1;let J=this.#R,Q=this.#n($),j=_.shiftKey?0.1:0.01,q=Q.px,N=Q.py;switch(_.key){case"ArrowLeft":if(!J.x)return!1;q-=j;break;case"ArrowRight":if(!J.x)return!1;q+=j;break;case"ArrowUp":if(!J.y)return!1;N-=j;break;case"ArrowDown":if(!J.y)return!1;N+=j;break;case"Home":if(J.x)q=0;if(J.y)N=0;break;case"End":if(J.x)q=1;if(J.y)N=1;break;default:return!1}if(q=Math.max(0,Math.min(1,q)),N=Math.max(0,Math.min(1,N)),this.#D(J),J.x)this.style.left=`${this.#L(q*$.width)}px`;if(J.y)this.style.top=`${this.#L(N*$.height)}px`;this.#H();let G={...this.#n($),shiftKey:_.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:G})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:G})),!0}attributeChangedCallback(_,Z,$){if(_==="color"){if(!$||$==="false"||$==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",$);if(this.#j&&this.#X==="color"&&$)this.#j.setAttribute("value",$);this.#y()}if(_==="drag")this.#E();if(_==="hit-area")this.#T();if(_==="selected")this.#c();if(_==="selected"||_==="disabled"||_==="type"||_==="tip"||_==="aria-label"||_==="aria-labelledby")this.#f();if(_==="value"&&!this.#Q&&!this.#Z)this.#I($);if(_==="precision"&&this.isConnected&&!this.#Z&&this.hasAttribute("value"))this.#I(this.getAttribute("value")),this.#H();if(_==="tip"){if(this.#m(),this.#X)this.#u(),this.#t()}}#E(){if(this.#Y&&!this.#J)this.#J=(_)=>this.#g(_),this.addEventListener("pointerdown",this.#J);else if(!this.#Y&&this.#J)this.#x()}#f(){let _=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",_?"-1":"0");else if(_)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",_?"true":"false"),this.setAttribute("aria-pressed",Z?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let $=this.#X||this.getAttribute("type")||"handle";this.setAttribute("aria-label",$==="color"?"Color handle":$==="add"?"Add handle":$==="remove"?"Remove handle":"Handle")}}#x(){if(this.#$?.(),this.#$=null,this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#Z=!1,this.#_=!1}#g(_){if(!this.#Y||T(this,"disabled"))return;_.preventDefault(),this.setAttribute("data-fig-pointer-focus",""),this.focus(),this.select();let Z=this.#O();if(!Z)return;this.#$?.(),this.#Z=!0;let $=this.#R,J=null,Q=this.getBoundingClientRect(),j=Q.left+Q.width/2,q=Q.top+Q.height/2,N=_.clientX-j,G=_.clientY-q,K=_.clientX,X=_.clientY,Y=3,W=(H,A,z=!1)=>{let U=Z.getBoundingClientRect();J=U;let I=this.#n(U),V=H-N-U.left,P=A-G-U.top,S=Math.max(0,Math.min(U.width,V)),w=Math.max(0,Math.min(U.height,P)),f=U.width>0?$.x?S/U.width:I.px:0.5,c=U.height>0?$.y?w/U.height:I.py:0.5;if(this.#W(z)){if($.x)f=this.#B(f);if($.y)c=this.#B(c);if($.x&&$.y){let o=this.#M(f,c);f=o.x,c=o.y}}if(this.#D($),$.x)this.style.left=`${this.#L(Math.max(0,Math.min(U.width,f*U.width)))}px`;if($.y)this.style.top=`${this.#L(Math.max(0,Math.min(U.height,c*U.height)))}px`},R=(H)=>{if(!this.#Z)return;if(!this.#_){let A=H.clientX-K,z=H.clientY-X;if(A*A+z*z<Y*Y)return;if(this.#r(),this.classList.add("dragging"),this.style.cursor="grabbing",!T(this,"selected"))this.select()}this.#_=!0,W(H.clientX,H.clientY,H.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#n(J),shiftKey:H.shiftKey}}))},L=(H)=>{if(O(),this.#_){W(H.clientX,H.clientY,H.shiftKey),this.#H(),this.#I(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#n(J)}));let A=(z)=>{z.stopPropagation(),z.preventDefault()};this.addEventListener("click",A,{capture:!0,once:!0})}else this.#H();this.#_=!1},O=()=>{if(window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",L),this.#Z=!1,this.style.cursor="",this.classList.remove("dragging"),this.#$===O)this.#$=null};this.#$=O,window.addEventListener("pointermove",R),window.addEventListener("pointerup",L)}showColorTip(){if(!this.#X)return;if(this.#j){this.#j.style.display="";return}this.#t()}hideColorTip(){if(!this.#j)return;this.#j.style.display="none"}#w(_=this.getAttribute("color")){let Z={color:"#D9D9D9",opacity:100},$=String(_||"").trim();if(!$)return Z;let J=(j)=>{let q=j.replace("#","").trim();if(q.length===3||q.length===4){let[N,G,K,X]=q;return{color:`#${N}${N}${G}${G}${K}${K}`.toUpperCase(),opacity:X?Math.round(parseInt(`${X}${X}`,16)/255*100):100}}if(q.length===6||q.length===8)return{color:`#${q.slice(0,6)}`.toUpperCase(),opacity:q.length===8?Math.round(parseInt(q.slice(6,8),16)/255*100):100};return Z},Q=(j,q,N)=>{let G=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${G(j)}${G(q)}${G(N)}`.toUpperCase()};if($.startsWith("#"))return J($);try{let{ctx:j}=D0(1,1);j.fillStyle="#000000",j.fillStyle=$;let q=j.fillStyle;if(q.startsWith("#"))return J(q);let N=q.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(N)return{color:Q(N[1],N[2],N[3]),opacity:N[4]!==void 0?Math.round(parseFloat(N[4])*100):100}}catch{}return Z}#p(){let{color:_,opacity:Z}=this.#w();return JSON.stringify(Z<100?{type:"solid",color:_,opacity:Z}:{type:"solid",color:_})}#y(){if(!this.#G)return;this.#G.setAttribute("value",this.#p())}#b(){if(!q0())return null;if(this.#G)return this.#G;let _=document.createElement("fig-fill-picker");_.setAttribute("mode","solid"),_.setAttribute("alpha","true"),_.setAttribute("dialog-offset","8 8"),_.setAttribute("value",this.#p()),_.anchorElement=this;let Z=document.createElement("span");return Z.hidden=!0,_.appendChild(Z),_.addEventListener("input",this.#s),_.addEventListener("change",this.#e),_.addEventListener("close",this.#G0),this.appendChild(_),this.#G=_,_}#v(){if(T(this,"disabled"))return;let _=this.#b();if(!_){this.#o();return}this.setAttribute("selected",""),this.#y(),_.open()}#u(){if(!this.#G)return;this.#G.removeEventListener("input",this.#s),this.#G.removeEventListener("change",this.#e),this.#G.removeEventListener("close",this.#G0),this.#G.close(),this.#G.remove(),this.#G=null,this.removeAttribute("selected")}#a(){if(this.#N)return this.#N;let _=document.createElement("input");return _.type="color",_.tabIndex=-1,_.setAttribute("aria-hidden","true"),_.style.position="fixed",_.style.inlineSize="1px",_.style.blockSize="1px",_.style.opacity="0",_.style.pointerEvents="none",_.addEventListener("input",this.#_0),_.addEventListener("change",this.#$0),this.appendChild(_),this.#N=_,_}#o(){let _=this.#a(),{color:Z}=this.#w();_.value=Z,this.setAttribute("selected",""),_.click()}#i(){if(!this.#N)return;this.#N.removeEventListener("input",this.#_0),this.#N.removeEventListener("change",this.#$0),this.#N.remove(),this.#N=null}#r(){if(this.getAttribute("type")!=="color")return;this.#G?.close()}#t(){let _=this.#X;if(!_)return;if(this.#j)return;let Z=document.createElement("fig-color-tip");if(_==="add"||_==="remove")Z.setAttribute("control",_);else Z.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Z.setAttribute("alpha","true");Z.addEventListener("input",this.#K0),Z.addEventListener("change",this.#N0),Z.addEventListener("add",this.#Z0),Z.addEventListener("remove",this.#Z0),this.appendChild(Z),this.#j=Z,this.#c()}#m(){if(!this.#j)return;this.#j.removeEventListener("input",this.#K0),this.#j.removeEventListener("change",this.#N0),this.#j.removeEventListener("add",this.#Z0),this.#j.removeEventListener("remove",this.#Z0),this.#j.remove(),this.#j=null}#c(){if(!this.#j||this.#X!=="color")return;let _=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#j.toggleAttribute("selected",_)}#d(_,Z){if(Z===void 0||Z>=100)return _;let{r:$,g:J,b:Q}=_0(_);return`rgba(${$}, ${J}, ${Q}, ${Z/100})`}#Q0(_){if(!_?.color)return null;let Z=_.opacity!==void 0?_.opacity:_.alpha!==void 0?Math.round(_.alpha*100):void 0;return{color:_.color,opacity:Z,...t(_.color,_.alpha,Z)}}#s=(_)=>{_.stopPropagation();let Z=this.#Q0(_.detail);if(!Z)return;this.setAttribute("color",this.#d(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#e=(_)=>{_.stopPropagation();let Z=this.#Q0(_.detail);if(!Z)return;this.setAttribute("color",this.#d(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#l(_){let{opacity:Z}=this.#w();return{...Z<100?{color:_,opacity:Z}:{color:_},...t(_,void 0,Z)}}#_0=(_)=>{_.stopPropagation();let Z=this.#l(_.target.value);this.setAttribute("color",this.#d(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#$0=(_)=>{_.stopPropagation();let Z=this.#l(_.target.value);if(this.setAttribute("color",this.#d(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z})),this.isConnected)this.focus()};#G0=()=>{if(!this.isConnected)return;this.setAttribute("selected",""),this.focus()};#K0=(_)=>{if(_.stopPropagation(),_.detail?.color){let Z={color:_.detail.color,opacity:_.detail.opacity,...t(_.detail.color,_.detail.alpha,_.detail.opacity)};this.setAttribute("color",this.#d(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))}};#N0=(_)=>{if(_.stopPropagation(),_.detail?.color){let Z={color:_.detail.color,opacity:_.detail.opacity,...t(_.detail.color,_.detail.alpha,_.detail.opacity)};this.setAttribute("color",this.#d(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))}};#Z0=(_)=>{_.stopPropagation(),this.dispatchEvent(new CustomEvent(_.type,{bubbles:!0,composed:!0}))};#n(_){let Z=_||this.#O()?.getBoundingClientRect();if(!Z)return{x:0,y:0,px:0,py:0};let $=this.getBoundingClientRect(),J=this.offsetWidth/2,Q=this.offsetHeight/2,j=$.left-Z.left,q=$.top-Z.top,N=j+J,G=q+Q,K=Z.width>0?N/Z.width:0,X=Z.height>0?G/Z.height:0;return{x:this.#L(j),y:this.#L(q),px:K,py:X}}}F("fig-handle",t_);class n_ extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(_){this.setAttribute("value",_??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Z()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="disabled")this.#Z()}#Z(){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")}}F("fig-menu-item",n_);class E0 extends HTMLElement{#Z=null;#_=null;#J=null;#$=this.#X.bind(this);static get observedAttributes(){return["label","direction","sticky"]}get label(){return this.getAttribute("label")??""}set label(_){if(_==null||_==="")this.removeAttribute("label");else this.setAttribute("label",String(_))}connectedCallback(){this.#Q(),this.#j(),this.#N()}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#q()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#Q(),_==="sticky")this.#N()}#Q(){if(!this.hasAttribute("role"))this.setAttribute("role","separator");if(this.getAttribute("direction")==="vertical")this.setAttribute("aria-orientation","vertical");else if(!this.hasAttribute("aria-orientation"))this.setAttribute("aria-orientation","horizontal");let Z=this.label.trim(),$=Array.from(this.children).filter((q)=>q.localName==="label"),J=$.find((q)=>!q.hasAttribute("data-fig-separator-generated")),Q=$.filter((q)=>q.hasAttribute("data-fig-separator-generated"));if(J)Q.forEach((q)=>q.remove());else if(Z){let q=Q[0]??document.createElement("label");if(Q.slice(1).forEach((N)=>N.remove()),q.setAttribute("data-fig-separator-generated",""),q.textContent!==Z)q.textContent=Z;if(!q.parentElement)this.appendChild(q)}else Q.forEach((q)=>q.remove());let j=J?.textContent?.trim()||Z;if(j)this.setAttribute("aria-label",j);else this.removeAttribute("aria-label")}#j(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>this.#Q()),this.#J.observe(this,{childList:!0,characterData:!0,subtree:!0})}#G(){return this.hasAttribute("sticky")&&this.getAttribute("sticky")!=="false"}#N(){if(this.#q(),!this.isConnected||!this.#G()){this.removeAttribute("stuck");return}let _=z1(this);if(this.#Z=_,_?.addEventListener("scroll",this.#$,{passive:!0}),this.#_=new ResizeObserver(this.#$),this.#_.observe(this),_ instanceof Element)this.#_.observe(_);requestAnimationFrame(this.#$)}#q(){this.#Z?.removeEventListener?.("scroll",this.#$),this.#Z=null,this.#_?.disconnect(),this.#_=null}#X(){if(!this.#G()||!this.#Z){this.removeAttribute("stuck");return}let _=parseFloat(getComputedStyle(this).top)||0,Z=this.#Z,$=Z===document.scrollingElement||Z===document.documentElement?{top:0}:Z.getBoundingClientRect(),J=Z instanceof Element?parseFloat(getComputedStyle(Z).paddingTop)||0:0,Q=$.top+J+_;this.toggleAttribute("stuck",this.getBoundingClientRect().top<=Q+1)}}F("fig-separator",E0);function z1(_){let Z=_.parentElement;while(Z){let $=getComputedStyle(Z),J=$.overflowY||$.overflow;if(J&&J!=="visible"&&J!=="clip")return Z;Z=Z.parentElement}return document.scrollingElement}class e_ extends E0{}F("fig-menu-separator",e_);var T1=new Set(["FIG-MENU-ITEM","FIG-SEPARATOR","FIG-MENU-SEPARATOR"]),j0="trigger";function k1(_){return _?.nodeType===1&&T1.has(_.tagName)}function D1(_,Z){if(!_||!Z)return null;let $=Z;while($.parentElement&&$.parentElement!==_)$=$.parentElement;return $.parentElement===_?$:null}class _1 extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#N=null;#q=null;#X=null;#K=!1;#Y;#R;#U;#W;#B;#M;#O=this.#h.bind(this);#L=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open","trigger"]}constructor(){super();this.#Y=this.#v.bind(this),this.#R=this.#u.bind(this),this.#U=this.#o.bind(this),this.#W=this.#i.bind(this),this.#B=this.#r.bind(this),this.#M=this.#h.bind(this),this.#A()}get value(){return this.getAttribute("value")||""}set value(_){this.setAttribute("value",_??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){if(_){if(this.#b())return;this.setAttribute("open","")}else this.removeAttribute("open")}connectedCallback(){if(this.#D(),this.#S(),this.#k(),this.#V(),this.#y(),this.open)this.#m()}disconnectedCallback(){if(this.#P(),this.#C(),document.removeEventListener("keydown",this.#W,!0),this.#G)this.#G.disconnect(),this.#G=null}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="open"){if($===null||$==="false")this.#c();else{if(this.#b()){this.removeAttribute("open");return}this.#m()}return}if(_==="disabled"){this.#y();return}if(this.#Z&&(_==="position"||_==="offset"||_==="closedby"))if($!==null)this.#Z.setAttribute(_,$);else this.#Z.removeAttribute(_)}#A(){if(this.#K)return;this.#K=!0;let _=this.attachShadow({mode:"open"});l0(_,{icons:!0});let Z=document.createElement("style");Z.textContent=`
174
+ `:",";this.#$=_.split(Z).map(($)=>$.trim()).filter(Boolean)}#K(){if(this.replaceChildren(),this.#$.length===0)return;let _=document.createElement("fig-segmented-control");if(_.setAttribute("sizing",this.getAttribute("sizing")||"equal"),T(this,"disabled"))_.setAttribute("disabled","");if(T(this,"full"))_.setAttribute("full","");let Z=this.getAttribute("value");for(let $ of this.#$){let J=document.createElement("fig-segment");if(J.setAttribute("value",$),J.textContent=$,Z===$)J.setAttribute("selected","true");_.appendChild(J)}if(Z)_.setAttribute("value",Z);_.addEventListener("input",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#G($);if(J===null)return;this.#j=!0,this.setAttribute("value",J),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),_.addEventListener("change",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#G($);if(J===null)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(_),this.#Q=_,this.#Z="segments"}#Y(){if(this.replaceChildren(),this.#$.length===0)return;let _=document.createElement("fig-dropdown");if(T(this,"disabled"))_.setAttribute("disabled","");let Z=this.getAttribute("value");for(let $ of this.#$){let J=document.createElement("option");if(J.value=$,J.textContent=$,Z===$)J.selected=!0;_.appendChild(J)}if(Z)_.setAttribute("value",Z);_.addEventListener("input",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#G($);if(!J)return;this.#j=!0,this.setAttribute("value",J),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),_.addEventListener("change",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#G($);if(!J)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(_),this.#Q=_,this.#Z="dropdown"}#R(){if(this.#Z==="segments")this.#K(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#L())});else this.#Y()}#U(){if(!this.#Q||this.#j)return;let _=this.getAttribute("value")||"";this.#Q.value=_}#W(_){if(!this.#Q)return;if(this.hasAttribute(_))this.#Q.setAttribute(_,this.getAttribute(_)||"");else this.#Q.removeAttribute(_)}#O(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#L()}),this.#J.observe(this)}#M(_){let Z=document.createRange();Z.selectNodeContents(_);let $=Z.getBoundingClientRect().width,Q=_.getBoundingClientRect().width,j=getComputedStyle(_),q=parseFloat(j.paddingLeft)||0,N=parseFloat(j.paddingRight)||0,G=Q-q-N;return $>G+0.5}#B(){let _=this.querySelectorAll("fig-segment");for(let Z of _)if(this.#M(Z))return!0;return!1}#L(){if(this.#$.length<=1)return;if(this.#Z==="segments"){let _=this.#Q;if(_&&_.scrollWidth>_.clientWidth+1||this.#B())this.#_=this.clientWidth,this.#Y()}else if(this.#_>0&&this.clientWidth>=this.#_)this.#K(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let _=this.#Q;if(_&&_.scrollWidth>_.clientWidth+1||this.#B())this.#Y()})})}}F("fig-options",Y_);class R_ extends HTMLElement{#Z=!1;#_=!1;#J=!1;#$="";#Q=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#j={range:{min:0,max:100,step:1},hue:{min:0,max:255,step:1},delta:{min:-100,max:100,step:1},stepper:{min:0,max:100,step:25},opacity:{min:0,max:100,step:0.1,color:"var(--figma-color-icon)"}};#G;#q;#N;#X;#K;#Y;#R;#U=null;#W=null;#O=null;#M=null;constructor(){super();this.initialChildren=null,this.#G=(_)=>{_.stopPropagation(),this.#p()},this.#q=(_)=>{_.stopPropagation(),this.#y()},this.#K=(_)=>{this.#b(_)},this.#N=(_)=>{_.stopPropagation(),this.#H()},this.#X=(_)=>{_.stopPropagation(),this.#v()},this.#Y=()=>{this.#Z=!0},this.#R=()=>{if(this.#Z=!1,this.#_&&this.isConnected)this.#_=!1,this.#D()}}#B(){let _=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.getAttribute("text")!=="false",this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";let Z=this.#j[this.type]||this.#j.range,$=(J,Q)=>{let j=this.getAttribute(J),q=j===null||j.trim()===""?Q:Number(j);return Number.isFinite(q)?q:Q};if(this.min=$("min",Z.min),this.max=$("max",Z.max),this.step=$("step",Z.step),!(this.step>0))this.step=Z.step>0?Z.step:1;this.color=this.getAttribute("color")||Z?.color,this.default=this.#C(),this.value=this.#E(_)}#L(){if(!this.querySelector("[type=range]"))return!1;return this.getAttribute("text")!=="false"===!!this.querySelector("fig-input-number")}#A(){if(this.#B(),this.color)this.style.setProperty("--color",this.color);else this.style.removeProperty("--color");if(this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.input.className=this.type,this.input.min=String(this.min),this.input.max=String(this.max),this.input.step=String(this.step),this.input.value=String(this.value),this.input.disabled=this.disabled,this.text)this.input.setAttribute("tabindex","-1");else this.input.removeAttribute("tabindex");if(this.input.setAttribute("aria-valuemin",String(this.min)),this.input.setAttribute("aria-valuemax",String(this.max)),this.input.setAttribute("aria-valuenow",String(this.value)),this.figInputNumber=this.querySelector("fig-input-number"),this.figInputNumber){if(this.figInputNumber.setAttribute("placeholder",this.placeholder),this.figInputNumber.setAttribute("min",String(this.min)),this.figInputNumber.setAttribute("max",String(this.max)),this.figInputNumber.setAttribute("transform",String(this.transform)),this.figInputNumber.setAttribute("step",String(this.step)),this.figInputNumber.setAttribute("value",String(this.value)),this.units)this.figInputNumber.setAttribute("units",this.units);else this.figInputNumber.removeAttribute("units");if(this.precision!==null)this.figInputNumber.setAttribute("precision",String(this.precision));else this.figInputNumber.removeAttribute("precision");this.figInputNumber.disabled=this.disabled,this.figInputNumber.toggleAttribute("disabled",this.disabled)}}#I(){if(this.#g(),this.input.removeEventListener("input",this.#G),this.input.addEventListener("input",this.#G),this.input.removeEventListener("change",this.#q),this.input.addEventListener("change",this.#q),this.input.removeEventListener("keydown",this.#K),this.input.addEventListener("keydown",this.#K),this.input.removeEventListener("pointerdown",this.#Y),this.input.addEventListener("pointerdown",this.#Y),this.input.removeEventListener("pointerup",this.#R),this.input.addEventListener("pointerup",this.#R),this.input.removeEventListener("pointercancel",this.#R),this.input.addEventListener("pointercancel",this.#R),this.style.setProperty("--default",this.#z(this.default)),this.figInputNumber)this.#w(),this.figInputNumber.removeEventListener("input",this.#N),this.figInputNumber.addEventListener("input",this.#N),this.figInputNumber.removeEventListener("change",this.#X),this.figInputNumber.addEventListener("change",this.#X)}#D(){if(this.#B(),this.color)this.style.setProperty("--color",this.color);let _=M("input",{type:"range",tabindex:this.text?"-1":null,disabled:this.disabled,min:this.min,max:this.max,step:this.step,className:this.type,value:this.value,"aria-valuemin":this.min,"aria-valuemax":this.max,"aria-valuenow":this.value}),Z=M("div",{className:"fig-slider-input-container",role:"group"},_);for(let J of this.initialChildren??[])Z.appendChild(J);let $=[Z];if(this.text)$.push(M("fig-input-number",{placeholder:this.placeholder,min:this.min,max:this.max,transform:this.transform,step:this.step,value:this.value,units:this.units||null,precision:this.precision,disabled:this.disabled}));if(this.replaceChildren(...$),this.input=_,this.inputContainer=Z,this.figInputNumber=this.querySelector("fig-input-number"),this.#I(),this.datalist=this.querySelector("datalist"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||g()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("data-generated","slider-stepper"),this.datalist.setAttribute("id",g());let J=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1));for(let Q=0;Q<J;Q++){let j=document.createElement("option");j.setAttribute("value",this.min+Q*this.step),this.datalist.append(j)}this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.type==="delta"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("data-generated","slider-delta"),this.datalist.setAttribute("id",g());let J=document.createElement("option");J.setAttribute("value",this.default),this.datalist.append(J),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.#k())this.#i();this.#o(),this.#x()}connectedCallback(){if(this.initialChildren===null)this.initialChildren=Array.from(this.childNodes);if(this.#L()){this.#A(),this.#I(),this.#x();return}this.#D()}get value(){if(this.#$!=="")return this.#$;let _=this.getAttribute("value");if(_!==null)return String(this.#E(_));return""}set value(_){let Z=_===null||_===void 0?"":String(_),J=this.min!==void 0||this.max!==void 0?String(this.#E(Z)):Z;if(this.#$=J,this.getAttribute("value")!==J)this.#J=!0,this.setAttribute("value",J),this.#J=!1;if(this.input&&this.input.value!==J)this.input.value=J,this.input.setAttribute("aria-valuenow",J);if(this.figInputNumber)this.figInputNumber.setAttribute("value",J);if(this.input)this.#f()}get defaultValue(){return this.#C()}disconnectedCallback(){if(this.#_=!1,this.input)this.input.removeEventListener("input",this.#G),this.input.removeEventListener("change",this.#q),this.input.removeEventListener("keydown",this.#K),this.input.removeEventListener("pointerdown",this.#Y),this.input.removeEventListener("pointerup",this.#R),this.input.removeEventListener("pointercancel",this.#R);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#N),this.figInputNumber.removeEventListener("change",this.#X)}#H(){if(this.figInputNumber){let _=this.figInputNumber.value,Z=this.#E(_);this.value=Z,this.input.value=String(Z),this.#x(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#z(_){let{min:Z,max:$}=this.#T(),J=$-Z;if(J===0)return 0;return(Number(_)-Z)/J}#F(_){if(_===null||_===void 0)return null;if(typeof _==="string"&&_.trim()==="")return null;let Z=Number(_);return Number.isFinite(Z)?Z:null}#T(){let _=this.#F(this.min),Z=this.#F(this.max);if(_===null)_=0;if(Z===null)Z=_;if(_>Z)[_,Z]=[Z,_];return{min:_,max:Z}}#S(_){let{min:Z,max:$}=this.#T();return Math.min($,Math.max(Z,_))}#P(_){let{min:Z}=this.#T(),$=this.#F(this.step);if(!($>0))return!0;let J=(_-Z)/$,Q=Math.round(J),j=Number.EPSILON*Math.max(1,Math.abs(J))*16;return Math.abs(J-Q)<=j}#V(){return["range","hue","opacity"].includes(this.type)}#k(){if(!this.hasAttribute("default")||!this.#V())return!1;let{min:_,max:Z}=this.#T(),$=this.#F(this.getAttribute("default"));return $!==null&&$>=_&&$<=Z&&this.#P($)}#C(_=this.getAttribute("default")){let{min:Z,max:$}=this.#T(),J=this.#F(_);if(J!==null&&J>=Z&&J<=$&&(this.type!=="stepper"||this.#P(J)))return J;return this.type==="delta"?Math.min($,Math.max(Z,0)):Z}#h(){if(this.type==="delta"){let Z=this.#F(this.default);if(Z!==null)return this.#S(Z);return this.#S(0)}if(this.type==="range"){let{min:Z,max:$}=this.#T();return this.#S(Z+($-Z)/2)}let{min:_}=this.#T();return _}#E(_){let Z=this.#F(_);if(Z===null)return this.#h();return this.#S(Z)}#f(){let _=this.#z(this.value),Z=this.#z(this.default),$=_<Z?-1:1,J=_===Z?1:0;if(this.#U!==_)this.style.setProperty("--slider-complete",_),this.#U=_;if(this.#W!==Z)this.style.setProperty("--default",Z),this.#W=Z;if(this.#O!==$)this.style.setProperty("--slider-delta-direction",$),this.#O=$;if(this.#M!==J)this.style.setProperty("--unchanged",J),this.#M=J}#x(){let _=this.input.value;if(this.value=_,this.#f(),this.input.setAttribute("aria-valuenow",_),this.figInputNumber)this.figInputNumber.setAttribute("value",_)}#g(){if(!this.input)return;if(this.text){this.input.setAttribute("aria-hidden","true"),["aria-label","aria-labelledby","aria-describedby","aria-valuetext"].forEach((_)=>this.input.removeAttribute(_)),this.#w();return}this.input.removeAttribute("aria-hidden"),this.#Q.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.input.removeAttribute(_);else this.input.setAttribute(_,Z)})}#w(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.figInputNumber.removeAttribute(_);else this.figInputNumber.setAttribute(_,Z)})}#p(){this.#x(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#y(){this.#Z=!1,this.#x(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#b(_){if(this.disabled||!_.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(_.key))return;_.preventDefault();let Z=_.key==="ArrowRight"||_.key==="ArrowUp"?1:-1,$=this.#F(this.input.value)??this.#h(),J=this.#F(this.step)??1,Q=this.#E($+J*10*Z);this.value=Q,this.input.value=String(Q),this.#x(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#v(){if(this.figInputNumber){let _=this.figInputNumber.value,Z=this.#E(_);this.value=Z,this.input.value=String(Z),this.#x(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}#u(_,Z){if(!this.input)return;let $=this.#j[this.type]||this.#j.range,J=Z===null||String(Z).trim()===""?$[_]:Number(Z),Q=Number.isFinite(J)?J:$[_];if(_==="step"&&!(Q>0))Q=$.step>0?$.step:1;if(this[_]===Q&&this.input[_]===String(Q))return;if(this[_]=Q,this.input[_]=String(Q),_==="min")this.input.setAttribute("aria-valuemin",String(Q));else if(_==="max")this.input.setAttribute("aria-valuemax",String(Q));if(this.figInputNumber)this.figInputNumber.setAttribute(_,String(Q));if(!this.hasAttribute("default")&&this.type!=="delta")this.default=this.min;else this.default=this.#C();this.value=this.#E(this.value),this.#f(),this.#a(),this.#o()}#a(){if(this.type!=="stepper"||!this.datalist)return;let _=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1)),Z=document.createDocumentFragment();for(let $=0;$<_;$++){let J=document.createElement("option");J.setAttribute("value",this.min+$*this.step),Z.append(J)}this.datalist.replaceChildren(Z),this.input.setAttribute("list",this.datalist.id),this.#o()}#o(){let _=this.datalist?.getAttribute("data-generated")==="slider-default",Z=this.#k();if(_&&!Z)this.datalist.remove(),this.datalist=null,this.input?.removeAttribute("list");else if(!this.datalist&&Z)this.#i();if(!this.datalist)return;let $=String(this.default);if(_){let j=this.datalist.querySelector("option")??document.createElement("option");j.value=$,this.datalist.replaceChildren(j)}let J=[...this.datalist.querySelectorAll("option")];J.forEach((j)=>j.removeAttribute("default"));let Q=J.find((j)=>j.value===$);if(!Q&&this.type==="delta"&&this.datalist.getAttribute("data-generated")==="slider-delta")Q=document.createElement("option"),Q.value=$,this.datalist.replaceChildren(Q);Q?.setAttribute("default","true")}#i(){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("data-generated","slider-default"),this.datalist.setAttribute("id",g());let _=document.createElement("option");_.value=String(this.default),this.datalist.append(_),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.id)}#r(){if(this.#Z){this.#_=!0;return}this.#_=!1,this.#D()}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"]}focus(){if(this.text&&this.figInputNumber){this.figInputNumber.focus();return}this.input.focus()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="value"&&this.#J)return;if(this.input)switch(_){case"color":this.color=$,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=$!==null&&$!=="false",this.figInputNumber)this.figInputNumber.toggleAttribute("disabled",this.disabled);break;case"value":if(this.#Z)break;this.value=$,this.#x();break;case"transform":if(this.transform=Number($)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=$!==null?Number($):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=$!==null?$:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=this.#C($),this.#f(),this.#o();break;case"min":case"max":case"step":this.#u(_,$);break;case"units":if(this.units=$||"",this.figInputNumber)if(this.units)this.figInputNumber.setAttribute("units",this.units);else this.figInputNumber.removeAttribute("units");break;case"type":case"variant":if(!this.#Z)this[_]=$;this.#r();break;case"text":if(!this.#Z)this.text=$!=="false";this.#r();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#g();break;default:this[_]=this.input[_]=$,this.#x();break}}}F("fig-slider",R_);class U_ extends HTMLElement{#Z=!1;#_=!1;#J="";#$=!1;#Q;#j;#G;#q;#N;#X;#K;#Y;#R=null;#U=0;#W="";#O="";#M=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#Q=this.#h.bind(this),this.#j=this.#f.bind(this),this.#G=this.#f.bind(this),this.#q=this.#E.bind(this),this.#N=(_)=>{_.stopPropagation(),this.#C(_)},this.#X=(_)=>{_.stopPropagation();let Z=_.target.value;if(this.type==="number")Z=Number(Z)/(this.transform||1);this.value=Z,this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))},this.#K=()=>{if(!this.disabled)this.focus()},this.#Y=this.#L.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")&&this.getAttribute("multiline")!=="false",this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}if(this.input=this.#B(),this.input.readOnly=this.readonly,this.disabled=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.input.disabled=this.disabled,this.#H(),this.#z(),this.#F(),this.#T(),this.#S(),this.#V(),U0(this),this.#A(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#k(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#k(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#k(this.step));this.addEventListener("pointerdown",this.#q)}this.removeEventListener("click",this.#Y),this.addEventListener("click",this.#Y),this.input.removeEventListener("change",this.#N),this.input.addEventListener("change",this.#N),this.input.removeEventListener("input",this.#X),this.input.addEventListener("input",this.#X)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#N),this.input.removeEventListener("input",this.#X);if(this.removeEventListener("click",this.#Y),this.removeEventListener("pointerdown",this.#q),window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#j),window.removeEventListener("blur",this.#G),this.#R?.disconnect(),this.#R=null,this.#U)cancelAnimationFrame(this.#U),this.#U=0}focus(){this.input.focus()}#B(){let _=this.multiline,Z=this.querySelector("input,textarea");if(Z){if(_?Z.tagName==="TEXTAREA":Z.tagName==="INPUT")return Z;Z.remove()}let $;if(_)$=document.createElement("textarea"),$.value=this.value;else $=document.createElement("input"),$.type=this.type,$.value=this.type==="number"?this.#k(this.value):this.value;if($.setAttribute("data-generated","input-control"),this.name)$.name=this.name;return $.placeholder=this.placeholder,this.insertBefore($,this.querySelector('[slot="append"]')),$}#L(_){let Z=_.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;if(this.disabled)return;this.focus()}#A(){this.#R?.disconnect(),this.#R=new MutationObserver(()=>this.#I()),this.#R.observe(this,{childList:!0,characterData:!0,subtree:!0})}#I(){if(this.#U)return;this.#U=requestAnimationFrame(()=>{if(this.#U=0,!this.isConnected)return;this.#D()})}#D(){if(!this.input||!this.contains(this.input))this.input=this.#B(),this.input.readOnly=this.readonly,this.input.addEventListener("change",this.#N),this.input.addEventListener("input",this.#X);this.#H(),this.#z(),this.#F(),this.#T(),this.#S(),this.#V(),U0(this)}#H(){if(!this.input)return;this.#M.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.input.removeAttribute(_);else this.input.setAttribute(_,Z)})}#z(){let _=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){_?.remove();return}if(this.querySelector('[slot="prepend"]:not([data-generated])')){_?.remove();return}if(_){let J=_.querySelector("fig-icon");if(J&&J.getAttribute("name")!=="search")J.setAttribute("name","search");J?.removeAttribute("color");return}let $=b("search");$.setAttribute("slot","prepend"),$.setAttribute("data-generated","search-prefix"),$.addEventListener("click",this.#K),this.prepend($)}#F(){let _=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){_?.remove();return}if(this.querySelector('[slot="append"]:not([data-generated])')){_?.remove();return}if(_){let q=_.querySelector("fig-icon");if(q&&q.getAttribute("name")!=="close")q.setAttribute("name","close");return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","search-clear");let J=document.createElement("fig-tooltip");J.setAttribute("text","Clear search");let Q=document.createElement("fig-button");Q.setAttribute("variant","ghost"),Q.setAttribute("icon",""),Q.setAttribute("aria-label","Clear search");let j=b("close",{size:"small"});j.setAttribute("color","var(--figma-color-icon-secondary)"),Q.append(j),J.append(Q),$.append(J),this.append($),Q.addEventListener("click",(q)=>{if(q.preventDefault(),q.stopPropagation(),this.disabled)return;if(!this.input||this.input.value===""){this.focus();return}this.value="",this.input.value="",this.dispatchEvent(new CustomEvent("input",{detail:"",bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:"",bubbles:!0})),this.#T(),this.focus()})}#T(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#S(){let _=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){_?.remove(),this.#_=!1;return}if(this.querySelector('[slot="append"]:not([data-generated])')){_?.remove();return}if(_){this.#P(_);return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","password-toggle");let J=document.createElement("fig-tooltip"),Q=document.createElement("fig-button");Q.setAttribute("variant","ghost"),Q.setAttribute("icon","");let j=b("visible",{size:"small"});j.setAttribute("color","var(--figma-color-icon-secondary)"),Q.append(j),J.append(Q),$.append(J),this.append($),this.#P($),Q.addEventListener("click",(q)=>{if(q.preventDefault(),q.stopPropagation(),this.disabled)return;if(this.#_=!this.#_,this.input)this.input.type=this.#_?"text":"password";this.#P($),this.focus()})}#P(_){let Z=_.querySelector("fig-tooltip"),$=_.querySelector("fig-button"),J=_.querySelector("fig-icon"),Q=this.#_?"Hide password":"Show password";Z?.setAttribute("text",Q),$?.setAttribute("aria-label",Q),J?.setAttribute("name",this.#_?"visible":"hidden")}#V(){this.querySelectorAll('[data-generated="search-clear"] fig-button, [data-generated="password-toggle"] fig-button').forEach((_)=>{if(this.disabled)_.setAttribute("disabled","");else _.removeAttribute("disabled")})}#k(_){if(_==="")return"";let Z=Number(_)*(this.transform||1);return Z=this.#g(Z),Z}#C(_){_.stopPropagation();let Z=_.target.value,$=Z;if(this.type==="number")Z=Z/(this.transform||1),Z=this.#x(Z,!1),$=Z*(this.transform||1);this.value=Z,this.input.value=$,this.#T(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#h(_){if(this.type!=="number")return;if(_.buttons===0){this.#f();return}let Z=(this.step||1)*_.movementX,$=Number(this.input.value);$=$/(this.transform||1)+Z,$=this.#x($,!1);let J=$*(this.transform||1);$=this.#g($),J=this.#g(J),this.value=$,this.input.value=J,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#E(_){if(this.type!=="number")return;if(_.altKey||_.target.closest("[slot]"))this.#Z=!0,this.#W=this.style.userSelect,this.#O=document.body.style.cursor,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Q),window.addEventListener("pointerup",this.#j),window.addEventListener("pointercancel",this.#j),window.addEventListener("blur",this.#G)}#f(_){if(this.type!=="number")return;let Z=this.#Z;if(this.#Z=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#O,this.style.userSelect=this.#W,window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#j),window.removeEventListener("pointercancel",this.#j),window.removeEventListener("blur",this.#G),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#x(_,Z=!0){let $=_;if(this.type==="number"){if($=Number($),typeof this.min==="number")$=Math.max(Z?this.#k(this.min):this.min,$);if(typeof this.max==="number")$=Math.min(Z?this.#k(this.max):this.max,$);$=this.#g($)}return $}#g(_,Z=2){let $=Math.round(_*100)/100;return Number.isInteger($)?$:$.toFixed(Z)}get value(){return this.#J}set value(_){let Z=_??"";this.#J=Z;let $=String(Z);if(this.getAttribute("value")!==$)this.#$=!0,this.setAttribute("value",$),this.#$=!1;this.#w(Z)}#w(_){if(!this.input||this.#Z)return;let Z=this.type==="number"?String(this.#k(_)):String(_??"");if(this.input.value!==Z)this.input.value=Z;this.#T()}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","multiline","step","min","max","transform","name","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(_,Z,$){if(this.input)switch(_){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false",this.#V();break;case"readonly":this.readonly=$!==null&&$!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number($)||1,this.input.value=this.#k(this.value);break;case"value":if(this.#Z)break;let J=$;if(this.type==="number")J=this.#x(J,!1);if(this.#J=J??"",!this.#$)this.#w(this.#J);break;case"min":case"max":case"step":if($===null||$==="")this[_]=void 0,this.input.removeAttribute(_);else this[_]=this.input[_]=Number($),this.input.setAttribute(_,$);break;case"name":if(this[_]=this.input[_]=$||"",$)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=$??"",this.input.placeholder=this.placeholder;break;case"type":if(this.type=$||"text",this.input.type=this.type,this.removeEventListener("pointerdown",this.#q),this.type==="number")this.step=this.hasAttribute("step")?Number(this.getAttribute("step")):void 0,this.min=this.hasAttribute("min")?Number(this.getAttribute("min")):void 0,this.max=this.hasAttribute("max")?Number(this.getAttribute("max")):void 0,this.transform=Number(this.getAttribute("transform")||1),this.addEventListener("pointerdown",this.#q);this.#z(),this.#F(),this.#T(),this.#S(),this.#V();break;case"multiline":{let Q=$!==null&&$!=="false";if(Q!==this.multiline){this.multiline=Q;let j=this.input;j.removeEventListener("change",this.#N),j.removeEventListener("input",this.#X),j.remove(),this.input=this.#B(),this.input.readOnly=this.readonly,this.input.disabled=Boolean(this.disabled),this.input.addEventListener("change",this.#N),this.input.addEventListener("input",this.#X),this.#H()}break}case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#H();break;default:this[_]=this.input[_]=$;break}}}F("fig-input-text",U_);class n extends HTMLElement{#Z;#_;#J;#$;#Q;#j;#G;#q;#N;#X;#K;#Y;#R;#U;#W;#O;#M=!1;#B=null;#L=null;#A=0;#I=0;#D=!1;#H;#z;#F=null;#T=0;#S="";#P="";#V=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#k="px";static#C=350;static#h=60;#E(_){return(_||"").split(",").map((Z)=>Z.trim().toLowerCase()).filter(Boolean)}#f(_){let Z=(_||"").trim();if(!Z)return"";return(this.#U??[]).includes(Z.toLowerCase())?"":Z}#x(){this.#Y=this.#f(this.#R)}#g(_){if(_&&!this.#B)this.#B=document.createElement("span"),this.#B.className="fig-steppers",this.#B.append(M("button",{className:"fig-stepper-up",tabindex:"-1","aria-label":"Increase"}),M("button",{className:"fig-stepper-down",tabindex:"-1","aria-label":"Decrease"})),this.#B.addEventListener("pointerdown",(Z)=>{Z.preventDefault(),Z.stopPropagation();let $=Z.target.closest("button");if(!$||this.disabled||$.disabled)return;let J=$.classList.contains("fig-stepper-up")?1:-1;this.#p(Z,J),this.input.focus()}),this.append(this.#B);else if(!_&&this.#B)this.#b(),this.#B.remove(),this.#B=null;this.#w()}#w(){if(!this.#B)return;let _=this.#B.querySelector(".fig-stepper-up"),Z=this.#B.querySelector(".fig-stepper-down");if(!_||!Z)return;let $=this.input?this.#c(this.input.value):this.value,J=$!==""&&$!==null&&$!==void 0?Number($)/(this.transform||1):Number(this.value),Q=Number.isFinite(J),j=Boolean(this.disabled),q=Q&&typeof this.min==="number"&&J<=this.min,N=Q&&typeof this.max==="number"&&J>=this.max;_.disabled=j||N,Z.disabled=j||q}#p(_,Z){if(this.#b(),this.#L=_.pointerId,this.#D=this.#v(Z),window.addEventListener("pointerup",this.#H),window.addEventListener("pointercancel",this.#H),window.addEventListener("blur",this.#z),!this.#D)return;this.#A=window.setTimeout(()=>{this.#A=0,this.#I=window.setInterval(()=>{let $=this.#v(Z);if(this.#D||=$,!$)this.#y()},n.#h)},n.#C)}#y(){if(this.#A)clearTimeout(this.#A),this.#A=0;if(this.#I)clearInterval(this.#I),this.#I=0}#b(_=!0){if(this.#y(),window.removeEventListener("pointerup",this.#H),window.removeEventListener("pointercancel",this.#H),window.removeEventListener("blur",this.#z),this.#L=null,_&&this.#D)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}));this.#D=!1}#v(_){if(this.disabled)return!1;let Z=this.step||1,$=this.value,J=this.#c(this.input.value),Q=(J!==""?Number(J)/(this.transform||1):0)+Z*_;if(Q=this.#Z0(Q,!1),Q===$)return!1;return this.value=Q,this.input.value=this.#d(this.value),this.#w(),this.#m(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),!0}constructor(){super();this.#Z=this.#G0.bind(this),this.#_=this.#N0.bind(this),this.#J=this.#N0.bind(this),this.#$=this.#K0.bind(this),this.#Q=(_)=>{_.stopPropagation(),this.#$0(_)},this.#j=(_)=>{_.stopPropagation(),this.#_0(_)},this.#G=(_)=>{this.#s(_)},this.#q=(_)=>{this.#e(_)},this.#N=(_)=>{this.#l(_)},this.#H=(_)=>{if(this.#L!==null&&_.pointerId!==this.#L)return;this.#b()},this.#z=()=>this.#b(),this.#X=this.focus.bind(this),this.#K=this.#a.bind(this)}connectedCallback(){let _=this.getAttribute("value");this.value=_!==null&&_!==""?Number(_):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#R=this.getAttribute("units")||"";let Z=this.getAttribute("units-disallow");if(this.#U=this.#E(Z===null?n.#k:Z),this.#x(),this.#W=this.getAttribute("unit-position")||"suffix",this.#O=this.#X0(this.hasAttribute("precision")?this.getAttribute("precision"):null),this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));this.transform=Number(this.getAttribute("transform")||1);let $=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.input=this.#u(),this.#t(),this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.#g($),this.hasAttribute("disabled")){let J=this.getAttribute("disabled");this.disabled=this.input.disabled=J!=="false"}this.#w(),this.#m(),U0(this),this.addEventListener("pointerdown",this.#$),this.removeEventListener("click",this.#K),this.addEventListener("click",this.#K),this.#o(),this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.input.removeEventListener("input",this.#j),this.input.addEventListener("input",this.#j),this.input.removeEventListener("focus",this.#G),this.input.addEventListener("focus",this.#G),this.input.removeEventListener("blur",this.#q),this.input.addEventListener("blur",this.#q),this.input.removeEventListener("keydown",this.#N),this.input.addEventListener("keydown",this.#N)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#Q),this.input.removeEventListener("input",this.#j),this.input.removeEventListener("focus",this.#G),this.input.removeEventListener("blur",this.#q),this.input.removeEventListener("keydown",this.#N);if(this.removeEventListener("click",this.#K),this.removeEventListener("pointerdown",this.#$),window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#_),window.removeEventListener("blur",this.#J),this.#b(!1),this.#F?.disconnect(),this.#F=null,this.#T)cancelAnimationFrame(this.#T),this.#T=0}focus(){this.input.focus()}#u(){let _=this.querySelector("input");if(_)return _;let Z=document.createElement("input");if(Z.type="text",Z.inputMode="decimal",Z.setAttribute("data-generated","input-control"),this.name)Z.name=this.name;return Z.placeholder=this.placeholder,Z.value=this.#d(this.value),this.insertBefore(Z,this.querySelector('[slot="append"]')),Z}#a(_){let Z=_.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;this.focus()}#o(){this.#F?.disconnect(),this.#F=new MutationObserver(()=>this.#i()),this.#F.observe(this,{childList:!0,characterData:!0,subtree:!0})}#i(){if(this.#T)return;this.#T=requestAnimationFrame(()=>{if(this.#T=0,!this.isConnected)return;this.#r()})}#r(){if(!this.input||!this.contains(this.input))this.input=this.#u(),this.input.addEventListener("change",this.#Q),this.input.addEventListener("input",this.#j),this.input.addEventListener("focus",this.#G),this.input.addEventListener("blur",this.#q),this.input.addEventListener("keydown",this.#N);let _=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.#B&&!this.contains(this.#B))this.#B=null;this.#g(_),this.#t(),this.#m(),U0(this)}#t(){if(!this.input)return;this.#V.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.input.removeAttribute(_);else this.input.setAttribute(_,Z)})}#m(){if(!this.input)return;if(this.input.setAttribute("role","spinbutton"),typeof this.min==="number")this.input.setAttribute("aria-valuemin",String(this.min));else this.input.removeAttribute("aria-valuemin");if(typeof this.max==="number")this.input.setAttribute("aria-valuemax",String(this.max));else this.input.removeAttribute("aria-valuemax");let _=this.value===""?null:Number(this.value);if(Number.isFinite(_))this.input.setAttribute("aria-valuenow",String(_)),this.input.setAttribute("aria-valuetext",this.#d(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#c(_){if(!_)return"";if(!this.#Y){let J=_.replace(/[^\d.-]/g,""),Q=J.split(".");if(Q.length>2)J=Q[0]+"."+Q.slice(1).join("");return J}let Z=_.replace(this.#Y,"").trim();Z=Z.replace(/[^\d.-]/g,"");let $=Z.split(".");if($.length>2)Z=$[0]+"."+$.slice(1).join("");return Z}#d(_){if(_===""||_===null||_===void 0)return"";let Z=Number(_)*(this.transform||1);if(isNaN(Z))return"";if(Z=this.#n(Z),!this.#Y)return Z.toString();if(this.#W==="prefix")return this.#Y+Z;else return Z+this.#Y}#Q0(_){if(_===""||_===null||_===void 0)return"";let Z=Number(_)*(this.transform||1);return Z=this.#n(Z),Z.toString()}#s(_){this.#M=!0,setTimeout(()=>{let Z=_.target.value;if(Z&&this.#Y)if(this.#W==="prefix")_.target.setSelectionRange(this.#Y.length,Z.length);else{let $=Z.indexOf(this.#Y);if($>-1)_.target.setSelectionRange(0,$)}},0)}#e(_){this.#M=!1;let Z=this.#c(_.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#Z0($,!1),this.value=$,_.target.value=this.#d(this.value)}else this.value="",_.target.value="";this.#w(),this.#m()}#l(_){if(this.disabled)return;if(_.key!=="ArrowUp"&&_.key!=="ArrowDown")return;_.preventDefault();let Z=this.step||1,$=_.shiftKey?10:1,J=Z*$*(_.key==="ArrowUp"?1:-1),Q=this.#c(this.input.value),j=(Q!==""?Number(Q)/(this.transform||1):0)+J;j=this.#Z0(j,!1),this.value=j,this.input.value=this.#d(this.value),this.#w(),this.#m(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#_0(_){let Z=this.#c(_.target.value);if(Z!=="")this.value=Number(Z)/(this.transform||1);else this.value="";this.#w(),this.#m(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#$0(_){_.stopPropagation();let Z=this.#c(_.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#Z0($,!1),this.value=$,_.target.value=this.#d(this.value)}else this.value="",_.target.value="";this.#w(),this.#m(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#G0(_){if(this.disabled)return;if(_.buttons===0){this.#N0();return}let Z=(this.step||1)*_.movementX,$=this.#c(this.input.value),J=Number($)/(this.transform||1)+Z;J=this.#Z0(J,!1),this.value=J,this.input.value=this.#d(this.value),this.#w(),this.#m(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#K0(_){if(this.disabled)return;if(_.altKey||_.target.closest("[slot]"))this.#M=!0,this.#S=this.style.userSelect,this.#P=document.body.style.cursor,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Z),window.addEventListener("pointerup",this.#_),window.addEventListener("pointercancel",this.#_),window.addEventListener("blur",this.#J)}#N0(_){let Z=this.#M;if(this.#M=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#P,this.style.userSelect=this.#S,window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#_),window.removeEventListener("pointercancel",this.#_),window.removeEventListener("blur",this.#J),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#Z0(_,Z=!0){let $=Number(_);if(isNaN($))return"";if(typeof this.min==="number")$=Math.max(this.min,$);if(typeof this.max==="number")$=Math.min(this.max,$);return $=this.#L0($),$}#n(_){let Z=this.#O??2,$=this.#L0(_);if(this.#O!==null)return $.toFixed(Z);return Number.isInteger($)?String($):String(parseFloat($.toFixed(Z)))}#L0(_){let Z=this.#O??2,$=Math.pow(10,Z);return Math.round(_*$)/$}#X0(_){if(_===null||_===void 0||_==="")return null;let Z=Number(_);if(!Number.isFinite(Z))return 2;return Math.max(0,Math.min(100,Math.trunc(Z)))}static get observedAttributes(){return["value","placeholder","disabled","step","min","max","transform","name","units","units-disallow","unit-position","steppers","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(_,Z,$){if(this.input)switch(_){case"disabled":if(this.disabled=this.input.disabled=$!==null&&$!=="false",this.disabled)this.#b();this.#w();break;case"units":this.#R=$||"",this.#x(),this.input.value=this.#d(this.value),this.#m();break;case"units-disallow":this.#U=this.#E($===null?n.#k:$),this.#x(),this.input.value=this.#d(this.value),this.#m();break;case"unit-position":this.#W=$||"suffix",this.input.value=this.#d(this.value),this.#m();break;case"transform":this.transform=Number($)||1,this.input.value=this.#d(this.value),this.#m();break;case"value":if(this.#M)break;let J=$!==null&&$!==""?Number($):"";if(J!=="")J=this.#Z0(J,!1);this.value=J,this.input.value=this.#d(this.value),this.#w(),this.#m();break;case"min":case"max":case"step":if($===null||$===""){this[_]=void 0,this.#w(),this.#m();break}this[_]=Number($),this.#w(),this.#m();break;case"steppers":{let Q=$!==null&&$!=="false";this.#g(Q);break}case"precision":this.#O=this.#X0($),this.input.value=this.#d(this.value),this.#m();break;case"name":if(this[_]=this.input[_]=$||"",$)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=$??"",this.input.placeholder=this.placeholder;break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#t();break;default:this[_]=this.input[_]=$;break}}}F("fig-input-number",n);class W_ extends HTMLElement{constructor(){super()}connectedCallback(){this.src=this.getAttribute("src"),this.name=this.getAttribute("name"),this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials),this.setSrc(this.src),this.img=this.querySelector("img")}setSrc(_){if(this.src=_,!_){this.querySelector(":scope > img")?.remove(),this.img=null;return}let Z=this.querySelector(":scope > img")||document.createElement("img");if(Z.src=_,Z.alt=this.name||"",!Z.isConnected)this.replaceChildren(Z);this.img=Z}getInitials(_){return _?_.split(" ").map((Z)=>Z[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(_,Z,$){if(this[_]=$,_==="name"){if(this.img)this.img.alt=$||"";this.name=$,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials)}else if(_==="src")this.src=$,this.setSrc(this.src)}}F("fig-avatar",W_);class L_ extends HTMLElement{#Z=!1;#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#q=null;constructor(){super();this.#J=this.#Y.bind(this),this.#$=this.focus.bind(this),this.#Q=this.#R.bind(this),this.#j=this.#U.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(!this.isConnected)return;this.#X(),this.#N()})}#N(){if(this.#G||typeof MutationObserver>"u")return;this.#G=new MutationObserver(()=>{this.#X()}),this.#G.observe(this,{childList:!0})}#X(){let _=this.label,Z=this.#_;_?.removeEventListener("click",this.#J),_?.removeEventListener("click",this.#$),_?.removeEventListener("pointerenter",this.#Q),_?.removeEventListener("pointerleave",this.#j),Z?.removeEventListener("click",this.#J),this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((q)=>q.nodeType===Node.ELEMENT_NODE&&q.nodeName.toLowerCase().startsWith("fig-")&&!(q instanceof Element&&(q.classList.contains("fig-field-chevron")||["leading","trailing"].includes(q.getAttribute("slot"))))),this.#K();let $=this.input?.localName??"",J=this.input?.getAttribute?.("edit"),j=$==="fig-select"||$==="fig-menu"||$==="fig-dropdown"||$==="fig-tooltip"||$==="fig-fill-picker"||$==="fig-input-palette"&&(J==="false"||J==="picker")||this.input instanceof HTMLDialogElement;if(this.#Z=!!(this.input&&("open"in this.input)&&typeof this.input.open!=="function"&&!j),this.#Z&&this.label){if(!this.#_||!this.#_.isConnected)this.#_=b("chevron",{size:"small",slot:"leading",className:"fig-field-chevron"}),this.insertBefore(this.#_,this.label);this.#_.addEventListener("click",this.#J),this.label.addEventListener("click",this.#J)}else{if(this.#_)this.#_.removeEventListener("click",this.#J),this.#_.remove(),this.#_=null;if(this.input&&this.label){if(this.input.querySelectorAll("input, select, textarea").length!==1)this.label.addEventListener("click",this.#$)}}if(this.input&&this.label&&!this.#Z)this.#W();if(this.label)this.label.removeEventListener("pointerenter",this.#Q),this.label.addEventListener("pointerenter",this.#Q),this.label.removeEventListener("pointerleave",this.#j),this.label.addEventListener("pointerleave",this.#j)}#K(){if(this.#q?.disconnect(),this.#q=null,this.input?.localName!=="fig-input-palette"||typeof MutationObserver>"u")return;this.#q=new MutationObserver(()=>this.#X()),this.#q.observe(this.input,{attributes:!0,attributeFilter:["edit"]})}disconnectedCallback(){if(this.#G?.disconnect(),this.#G=null,this.#q?.disconnect(),this.#q=null,this.label)k.hide(this.label);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.label&&this.#$)this.label.removeEventListener("click",this.#$);if(this.label&&this.#Q)this.label.removeEventListener("pointerenter",this.#Q);if(this.label&&this.#j)this.label.removeEventListener("pointerleave",this.#j);if(this.#_&&this.#J)this.#_.removeEventListener("click",this.#J)}#Y(_){if(_.preventDefault(),_.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open}#R(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;k.show(this.label,this.label.textContent.trim())}#U(){if(this.label)k.hide(this.label)}#W(){if(!this.input||!this.label)return;let _=this.label.getAttribute("id")||g();this.label.setAttribute("id",_);let Z=this.input.querySelectorAll("input, select, textarea");if(Z.length===1){let $=Z[0],J=$.getAttribute("id")||g();if($.setAttribute("id",J),this.label.setAttribute("for",J),this.input.getAttribute("aria-labelledby")===_)this.input.removeAttribute("aria-labelledby");if(!$.hasAttribute("aria-labelledby"))$.setAttribute("aria-labelledby",_);return}if(this.label.removeAttribute("for"),!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-labelledby",_)}attributeChangedCallback(_,Z,$){switch(_){case"label":if(this.label)this.label.textContent=$,this.#W();break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let _=this.input.querySelectorAll("input, select, textarea");if(_.length===1)_[0].focus();else if(this.input.focus(),_.length===0)this.input.click()}}F("fig-field",L_);class O_ extends HTMLElement{rgba;hex;#Z=100;#_;#J;#$;#Q;#j=!1;#G=!1;#q=null;#N=this.#P.bind(this);#X=this.#V.bind(this);#K=this.#k.bind(this);#Y=this.#w.bind(this);#R=this.#h.bind(this);#U=this.#f.bind(this);#W=this.#E.bind(this);#O=this.#p.bind(this);constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(_){if(_===null||_===void 0||_===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(_))}#M(){let _={};for(let{name:Z,value:$}of this.attributes)if(Z.startsWith("picker-")&&Z!=="picker-anchor"&&Z!=="picker-experimental"){let J=Z.slice(7);if(/^on/i.test(J))continue;_[J]=$}if(!_["dialog-position"])_["dialog-position"]="left";return _}#B(){let _=this.#M();return Object.entries(_).map(([Z,$])=>`${Z}="${$}"`).join(" ")}connectedCallback(){if(this.#L()){this.#A();return}this.#H()}disconnectedCallback(){this.#I()}#L(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-swatch")}#A(){if(this.#C(this.getAttribute("value")),this.#_=this.querySelector("fig-swatch"),this.#J=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#Q=this.querySelector("fig-input-number"),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Q)this.#Q.setAttribute("value",String(this.#Z));if(this.#_)this.#_.setAttribute("background",this.hexOpaque),this.#_.setAttribute("alpha",String(this.rgba.a));this.#g(),this.#D()}#I(){if(this.#_)this.#_.removeEventListener("pointerdown",this.#N,{capture:!0}),this.#_.removeEventListener("click",this.#X,{capture:!0}),this.#_.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#K),this.#_.removeEventListener("input",this.#Y);this.#$?.removeEventListener("input",this.#R),this.#$?.removeEventListener("change",this.#U),this.#Q?.removeEventListener("input",this.#W),this.#Q?.removeEventListener("change",this.#U),this.#J?.removeEventListener("input",this.#O),this.#J?.removeEventListener("change",this.#U)}#D(){if(this.#_){this.#_.disabled=T(this,"disabled");let _=this.#_.querySelector('input[type="color"]');if(this.#$||this.hasAttribute("swatch-disabled"))_?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(_?.setAttribute("disabled",""),_)_.style.pointerEvents="none"}this.#_.addEventListener("pointerdown",this.#N,{capture:!0}),this.#_.addEventListener("click",this.#X,{capture:!0}),_?.addEventListener("keydown",this.#K),this.#_.addEventListener("input",this.#Y)}if(this.#$)this.#$.addEventListener("input",this.#R),this.#$.addEventListener("change",this.#U);if(this.#Q)this.#Q.addEventListener("input",this.#W),this.#Q.addEventListener("change",this.#U);if(this.#J)this.#J.addEventListener("input",this.#O),this.#J.addEventListener("change",this.#U)}#H(){this.#C(this.getAttribute("value"));let _=this.getAttribute("alpha")!=="false",Z=this.#u,$=this.getAttribute("text")!=="false",J=M("fig-swatch",{background:this.hexOpaque,alpha:this.rgba.a,disabled:Z});if($){let Q=M("div",{className:"input-combo"},[J,M("fig-input-text",{type:"text",placeholder:"000000",value:this.hexOpaque.slice(1).toUpperCase(),disabled:Z})]);if(_)Q.appendChild(M("fig-tooltip",{text:"Opacity"},M("fig-input-number",{placeholder:"##",min:"0",max:"100",value:this.#Z,units:"%",disabled:Z})));this.replaceChildren(Q)}else this.replaceChildren(J);if(this.#_=J,this.#J=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#Q=this.querySelector("fig-input-number"),this.#g(),this.#$){let Q=this.rgbAlphaToHex(this.rgba,1);if(this.#$.value=Q.slice(1).toUpperCase(),this.#_)this.#_.background=Q}this.#D()}#z(){if(!this.#J)return;for(let[_,Z]of Object.entries(this.#M()))this.#J.setAttribute(_,Z);if(this.#J.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#J.removeAttribute("alpha");else this.#J.setAttribute("alpha","false");if(T(this,"disabled"))this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");this.#J.anchorElement=this,this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}))}#F(){if(!q0())return null;if(this.#J?.isConnected)return this.#z(),this.#J;let _=document.createElement("fig-fill-picker");return _.appendChild(M("span",{hidden:!0})),_.addEventListener("input",this.#O),_.addEventListener("change",this.#U),this.appendChild(_),this.#J=_,this.#z(),_}#T(){if(T(this,"disabled")||T(this,"swatch-disabled"))return!1;let _=this.#F();if(!_)return!1;return requestAnimationFrame(()=>_.open?.()),!0}#S(_){_.preventDefault(),_.stopPropagation(),_.stopImmediatePropagation?.()}#P(_){if(!q0())return;if(T(this,"disabled")||T(this,"swatch-disabled"))return;if(this.#G=!0,this.#j=!0,this.#q)clearTimeout(this.#q);this.#q=setTimeout(()=>{this.#j=!1,this.#G=!1,this.#q=null},500),this.#S(_)}#V(_){if(!this.#j)return;if(this.#j=!1,this.#q)clearTimeout(this.#q),this.#q=null;if(this.#S(_),this.#G)this.#G=!1,this.#T()}#k(_){if(_.key!=="Enter"&&_.key!==" ")return;if(!q0())return;if(!this.#T())return;this.#S(_)}#C(_){let Z=typeof _==="string"&&_.trim()?_.trim():"#D9D9D9",$=this.convertToRGBA(Z);if(!$||!Number.isFinite($.r)||!Number.isFinite($.g)||!Number.isFinite($.b)||!Number.isFinite($.a))Z="#D9D9D9",$={r:217,g:217,b:217,a:1};this.rgba=$,this.value=this.rgbAlphaToHex({r:isNaN(this.rgba.r)?0:this.rgba.r,g:isNaN(this.rgba.g)?0:this.rgba.g,b:isNaN(this.rgba.b)?0:this.rgba.b},this.rgba.a),this.hexWithAlpha=this.value.toUpperCase(),this.hexOpaque=this.hexWithAlpha.slice(0,7),this.#Z=Z.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#h(_){_.stopPropagation();let Z=_.target.value.replace(/#/g,"");if(this.#C("#"+Z),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Q)this.#Q.setAttribute("value",this.#Z);if(this.#_)this.#_.setAttribute("background",this.hexOpaque);this.#y()}#E(_){_.stopPropagation();let Z=Number(_.target.value)||0,J=Math.round(Z/100*255).toString(16).padStart(2,"0");if(this.#C(this.hexOpaque+J),this.#_)this.#_.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));this.#y()}#f(_){_.stopPropagation(),this.#b()}focus(){if(this.#$){this.#$.focus();return}this.#_?.focus()}#x(){return this.getAttribute("aria-label")||"Color"}#g(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#u)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let _=this.getAttribute("aria-describedby"),Z=this.getAttribute("aria-invalid"),$=this.getAttribute("aria-required"),J=this.getAttribute("aria-labelledby"),Q=this.#x();if(this.#$){if(this.#$.setAttribute("aria-label",`${Q} hex color`),_)this.#$.setAttribute("aria-describedby",_);else this.#$.removeAttribute("aria-describedby");if(Z)this.#$.setAttribute("aria-invalid",Z);else this.#$.removeAttribute("aria-invalid");if($)this.#$.setAttribute("aria-required",$);else this.#$.removeAttribute("aria-required")}if(this.#Q){if(this.#Q.setAttribute("aria-label",`${Q} opacity`),_)this.#Q.setAttribute("aria-describedby",_);else this.#Q.removeAttribute("aria-describedby");if(Z)this.#Q.setAttribute("aria-invalid",Z);else this.#Q.removeAttribute("aria-invalid");if($)this.#Q.setAttribute("aria-required",$);else this.#Q.removeAttribute("aria-required")}if(!this.#$){let j=this.#_?.querySelector('input[type="color"]');if(!j)return;if(J)j.setAttribute("aria-labelledby",J),j.removeAttribute("aria-label");else j.setAttribute("aria-label",Q),j.removeAttribute("aria-labelledby");if(_)j.setAttribute("aria-describedby",_);else j.removeAttribute("aria-describedby")}}#w(_){if(_.stopPropagation(),this.#C(_.target.value),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#y()}#p(_){_.stopPropagation();let Z=_.detail;if(Z&&Z.color){let $=Z.color;if(Z.alpha!==void 0){let J=Math.round(Z.alpha*255).toString(16).padStart(2,"0");$=Z.color+J}if(this.#C($),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Q&&Z.alpha!==void 0)this.#Q.setAttribute("value",Math.round(Z.alpha*100));if(this.#_)this.#_.setAttribute("background",this.hexOpaque),this.#_.setAttribute("alpha",this.rgba.a);this.#y()}}#y(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:this.#v()}))}#b(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:this.#v()}))}#v(){return{value:this.value,hex:this.hex,rgba:this.rgba,...t(this.hexOpaque,this.rgba?.a,Math.round((this.rgba?.a??1)*100))}}static get observedAttributes(){return["value","style","mode","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(_){this.setAttribute("mode",_)}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"value":if(this.#C($),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#_)this.#_.setAttribute("background",this.hexOpaque),this.#_.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));if(this.#Q)this.#Q.setAttribute("value",this.#Z);break;case"mode":this.#z();break;case"alpha":case"text":if(this.isConnected)this.#H();break;case"disabled":this.#a();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#g();break}}get#u(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#a(){let _=this.#u;for(let Z of[this.#_,this.#$,this.#Q]){if(!Z)continue;if(_)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}if(this.#g(),this.#J)this.#z()}rgbAlphaToHex({r:_,g:Z,b:$},J=1){_=Math.max(0,Math.min(255,Math.round(_))),Z=Math.max(0,Math.min(255,Math.round(Z))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(1,J));let Q=_.toString(16).padStart(2,"0"),j=Z.toString(16).padStart(2,"0"),q=$.toString(16).padStart(2,"0");if(J===1)return`#${Q}${j}${q}`.toUpperCase();let G=Math.round(J*255).toString(16).padStart(2,"0");return`#${Q}${j}${q}${G}`.toUpperCase()}convertToRGBA(_){if(typeof _!=="string")return null;let Z,$,J,Q=1;if(_.startsWith("#")){let j=_.slice(1);if(j.length===8)Q=parseInt(j.slice(6),16)/255,j=j.slice(0,6);Z=parseInt(j.slice(0,2),16),$=parseInt(j.slice(2,4),16),J=parseInt(j.slice(4,6),16)}else if(_.startsWith("rgba")||_.startsWith("rgb")){let j=_.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(j)Z=parseInt(j[1]),$=parseInt(j[2]),J=parseInt(j[3]),Q=j[4]?parseFloat(j[4]):1}else if(_.startsWith("hsla")||_.startsWith("hsl")){let j=_.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(j){let q=parseInt(j[1])/360,N=parseInt(j[2])/100,G=parseInt(j[3])/100;if(Q=j[4]?parseFloat(j[4]):1,N===0)Z=$=J=G;else{let K=(W,R,L)=>{if(L<0)L+=1;if(L>1)L-=1;if(L<0.16666666666666666)return W+(R-W)*6*L;if(L<0.5)return R;if(L<0.6666666666666666)return W+(R-W)*(0.6666666666666666-L)*6;return W},X=G<0.5?G*(1+N):G+N-G*N,Y=2*G-X;Z=K(Y,X,q+0.3333333333333333),$=K(Y,X,q),J=K(Y,X,q-0.3333333333333333)}Z=Math.round(Z*255),$=Math.round($*255),J=Math.round(J*255)}}else return null;return{r:Z,g:$,b:J,a:Q}}}F("fig-input-color",O_);var U1=["srgb","srgb-linear","display-p3","oklab","oklch","hsl"],W1=["shorter","longer","increasing","decreasing"],M_=new Set(["oklch","hsl"]);function K0(_){let Z={..._??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase();if(!U1.includes($))$="srgb";Z.interpolationSpace=$;let J=String(Z.hueInterpolation??"shorter").toLowerCase();return Z.hueInterpolation=W1.includes(J)?J:"shorter",Z}function B_(_){let Z=K0(_),$={...Z,interpolationSpace:Z.interpolationSpace};if(M_.has(Z.interpolationSpace))$.hueInterpolation=Z.hueInterpolation;else delete $.hueInterpolation;return $}function H_(_){let Z=K0(_);if(Z.interpolationSpace==="srgb")return"";if(M_.has(Z.interpolationSpace))return`in ${Z.interpolationSpace} ${Z.hueInterpolation} hue`;return`in ${Z.interpolationSpace}`}function z0(_){if(!_)return"";return`url("${String(_).replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}")`}function L1(_){let Z=String(_??"").trim();if(!Z||Z.startsWith("{")||Z.startsWith("#"))return!1;if(Z.startsWith("data:video/"))return!0;try{let $=new URL(Z,"https://fig.local").pathname;return/\.(mp4|webm|mov|m4v|ogv)$/i.test($)}catch{return/\.(mp4|webm|mov|m4v|ogv)(?:[?#]|$)/i.test(Z)}}function O1(_,Z,$,J){let Q=[..._].sort((A,z)=>A.position-z.position),j=Z*100;if(Q.length===0)return"#888888";if(j<=Q[0].position)return Q[0].color;if(j>=Q[Q.length-1].position)return Q[Q.length-1].color;let q=0;while(q<Q.length-1&&Q[q+1].position<j)q++;let N=Q[q],G=Q[q+1],K=G.position-N.position,X=K>0?(j-N.position)/K:0,Y=_0(N.color),W=_0(G.color),R,L,O,H=$||"oklab";if(H==="srgb-linear"){let A=a(Y.r),z=a(Y.g),U=a(Y.b),I=a(W.r),V=a(W.g),P=a(W.b);R=F0(A+(I-A)*X),L=F0(z+(V-z)*X),O=F0(U+(P-U)*X)}else if(H==="oklch"){let A=R0(Y.r,Y.g,Y.b),z=R0(W.r,W.g,W.b),U=h0(A.l,A.a,A.b),I=h0(z.l,z.a,z.b),V=U.l+(I.l-U.l)*X,P=U.c+(I.c-U.c)*X,S=y0(U.h,I.h,X,J||"shorter"),w=N1(V,P,S),f=b0(w.l,w.a,w.b);R=f.r,L=f.g,O=f.b}else if(H==="hsl"){let A=g0(Y.r,Y.g,Y.b),z=g0(W.r,W.g,W.b),U=y0(A.h,z.h,X,J||"shorter"),I=A.s+(z.s-A.s)*X,V=A.l+(z.l-A.l)*X,P=q1(U,I,V);R=P.r,L=P.g,O=P.b}else if(H==="srgb")R=Math.round(Y.r+(W.r-Y.r)*X),L=Math.round(Y.g+(W.g-Y.g)*X),O=Math.round(Y.b+(W.b-Y.b)*X);else{let A=R0(Y.r,Y.g,Y.b),z=R0(W.r,W.g,W.b),U=A.l+(z.l-A.l)*X,I=A.a+(z.a-A.a)*X,V=A.b+(z.b-A.b)*X,P=b0(U,I,V);R=P.r,L=P.g,O=P.b}return`#${R.toString(16).padStart(2,"0")}${L.toString(16).padStart(2,"0")}${O.toString(16).padStart(2,"0")}`.toUpperCase()}class F_ extends HTMLElement{#Z="solid";#_;#J;#$;#Q={color:"#D9D9D9",alpha:1};#j={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",opacity:1,stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#G={url:null,scaleMode:"fill",scale:50,opacity:1};#q={url:null,poster:null,scaleMode:"fill",scale:50,opacity:1,missing:!0};#N={live:!0,snapshot:null,deviceId:null,scaleMode:"fill",scale:50,opacity:1};#X={};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","alpha","webcam-mode","default-video","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#K(),this.#F()}disconnectedCallback(){this.#_=null,this.#J=null,this.#$=null}#K(){let _=this.getAttribute("value");if(!_)return;try{let Z=JSON.parse(_);if(Z.type)this.#Z=Z.type;switch(this.#Z){case"solid":if(Z.color)this.#Q.color=Z.color;if(Z.alpha!==void 0)this.#Q.alpha=Z.alpha;if(Z.opacity!==void 0)this.#Q.alpha=Z.opacity/100;break;case"gradient":if(Z.gradient)this.#j=K0({...this.#j,...Z.gradient}),this.#j.opacity=this.#W(Z.gradient.opacity??Z.opacity??Z.alpha,this.#j.opacity??1);else if(Z.opacity!==void 0||Z.alpha!==void 0)this.#j.opacity=this.#W(Z.opacity??Z.alpha,this.#j.opacity??1);break;case"image":if(Z.image)this.#G={...this.#G,...Z.image};break;case"video":if(Z.video)this.#q={...this.#q,...Z.video},this.#q.missing=!this.#q.url;break;case"webcam":if(Z.webcam&&typeof Z.webcam==="object"){let{stream:$,snapshot:J,...Q}=Z.webcam;if(this.#N={...this.#N,...Q},typeof J==="string"&&J)this.#N.snapshot=J}else if(Z.image?.url){if(this.#N.snapshot=Z.image.url,Z.image.scaleMode)this.#N.scaleMode=Z.image.scaleMode;if(Z.image.scale!=null)this.#N.scale=Z.image.scale}if(Z.opacity!==void 0)this.#N.opacity=Z.opacity;break;default:{let{type:$,...J}=Z;this.#X=J;break}}}catch(Z){if(_.startsWith("#")){if(this.#Z="solid",this.#Q.color=_.slice(0,7),_.length>7){let $=_.slice(7,9);this.#Q.alpha=parseInt($,16)/255}return}if(L1(_))this.#Z="video",this.#q.url=_.trim(),this.#q.missing=!1}}#Y(){let _={},Z=this.getAttribute("mode");if(Z)_.mode=Z;let $=this.getAttribute("alpha");if($)_.alpha=$;for(let{name:j,value:q}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor"&&j!=="picker-experimental"){let N=j.slice(7);if(/^on/i.test(N))continue;_[N]=q}if(!_["dialog-position"])_["dialog-position"]="left";let J=this.getAttribute("webcam-mode");if(J&&!_["webcam-mode"])_["webcam-mode"]=J;let Q=this.getAttribute("default-video");if(Q&&!_["default-video"])_["default-video"]=Q;return _}#R(){switch(this.#Z){case"solid":return this.#Q.color;case"gradient":{let Z=[...this.#j.stops].sort((Q,j)=>Q.position-j.position).map((Q)=>{let j=(Q.opacity??100)/100;if(j>=1)return`${Q.color} ${Q.position}%`;let{r:q,g:N,b:G}=_0(Q.color);return`rgba(${q}, ${N}, ${G}, ${j}) ${Q.position}%`}).join(", "),$=H_(this.#j),J=$?` ${$}`:"";switch(this.#j.type){case"radial":return`radial-gradient(circle${J}, ${Z})`;case"angular":return`conic-gradient(from ${this.#j.angle}deg${J}, ${Z})`;default:return`linear-gradient(${this.#j.angle}deg${J}, ${Z})`}}case"image":return this.#G.url?z0(this.#G.url):"#D9D9D9";case"video":return this.#q.poster?z0(this.#q.poster):"#D9D9D9";case"webcam":{let _=this.#N.snapshot||this.#_?.value?.webcam?.snapshot;return _?z0(_):""}default:return this.#L()}}#U(){return this.#R()}#W(_,Z=1){if(_===void 0||_===null||_==="")return Z;let $=Number(_);if(!Number.isFinite($))return Z;if($>1)return Math.max(0,Math.min(1,$/100));return Math.max(0,Math.min(1,$))}#O(){switch(this.#Z){case"solid":return this.#Q.alpha;case"gradient":return this.#j.opacity??1;case"image":return this.#G.opacity??1;case"video":return this.#q.opacity??1;case"webcam":return this.#N.opacity??1;default:return this.#W(this.#X.opacity??this.#X.alpha,1)}}#M(){return this.querySelector(`[slot="mode-${this.#Z}"]`)}#B(){let _=this.#M()?.getAttribute("label");if(_)return _;if(!this.#Z)return"Fill";return this.#Z.charAt(0).toUpperCase()+this.#Z.slice(1)}#L(){return this.#X.swatchBackground||this.#X.background||this.#X.css||this.#M()?.getAttribute("swatch-background")||""}#A(){if(!this.#_)return;for(let _ of[...this.querySelectorAll(":scope > [slot^='mode-']")])this.#_.append(_)}#I(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.setAttribute("aria-disabled",_?"true":"false");for(let Z of[this.#_,this.#J,this.#$]){if(!Z)continue;if(_)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}#D(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#I();let _=this.getAttribute("aria-label")||"Fill",Z=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),Q=(j,q)=>{if(!j)return;if(j.setAttribute("aria-label",q),Z)j.setAttribute("aria-describedby",Z);else j.removeAttribute("aria-describedby");if($)j.setAttribute("aria-invalid",$);else j.removeAttribute("aria-invalid");if(J)j.setAttribute("aria-required",J);else j.removeAttribute("aria-required")};Q(this.#_,`${_} picker`),Q(this.#$,`${_} hex color`),Q(this.#J,`${_} opacity`)}#H(_,Z){if(this.getAttribute("alpha")==="false")return null;return M("fig-tooltip",{text:"Opacity"},M("fig-input-number",{className:"fig-input-fill-opacity",placeholder:"##",min:"0",max:"100",value:_,units:"%",disabled:Z}))}#z(_){let Z=null,$=1;switch(this.#Z){case"solid":return[M("fig-input-text",{type:"text",className:"fig-input-fill-hex",placeholder:"000000",value:this.#Q.color.slice(1).toUpperCase(),disabled:_}),this.#H(Math.round(this.#Q.alpha*100),_)].filter(Boolean);case"gradient":Z=this.#j.type.charAt(0).toUpperCase()+this.#j.type.slice(1),$=this.#j.opacity??1;break;case"image":Z="Image",$=this.#G.opacity??1;break;case"video":Z="Video",$=this.#q.opacity??1;break;case"webcam":Z="Webcam",$=this.#N.opacity??1;break;default:Z=this.#B(),$=this.#W(this.#X.opacity??this.#X.alpha,1);break}return[M("label",{className:"fig-input-fill-label"},Z),this.#H(Math.round($*100),_)].filter(Boolean)}#F(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=JSON.stringify(this.value),$=this.#Y(),J=M("fig-swatch",{background:this.#R(),alpha:this.#O(),disabled:_}),Q=[...this.querySelectorAll("[slot^='mode-']")],j=M("fig-fill-picker",{value:Z,disabled:_,...$},[J,...Q]),q=M("div",{className:"input-combo"},[j,this.#z(_)]);this.replaceChildren(q),this.#T(),queueMicrotask(()=>{this.#A(),this.#k(),this.#S()})}#T(){this.#_=this.querySelector("fig-fill-picker"),this.#J=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let _=this.querySelector(".fig-input-fill-label");if(this.#D(),_&&this.#_)_.addEventListener("click",()=>{let Z=this.#_.querySelector("fig-swatch");if(Z)Z.click()});if(this.#_){let Z=this.getAttribute("picker-anchor");if(!Z||Z==="self")this.#_.anchorElement=this;else{let $=null;try{$=document.querySelector(Z)}catch{}if($)this.#_.anchorElement=$}this.#_.addEventListener("input",($)=>{$.stopPropagation();let J=$.detail;if(!J)return;let Q=J.type,j=Q!==this.#Z;switch(this.#Z=Q,Q){case"solid":this.#Q.color=J.color,this.#Q.alpha=J.alpha;break;case"gradient":if(J.gradient)this.#j=K0({...this.#j,...J.gradient});break;case"image":if(J.image)this.#G=J.image;break;case"video":if(J.video)this.#q={...this.#q,...J.video};break;case"webcam":if(J.webcam){let{stream:q,snapshot:N,...G}=J.webcam;if(this.#N={...this.#N,...G},typeof N==="string"&&N)this.#N.snapshot=N}else if(J.image?.url)this.#N.snapshot=J.image.url;if(!this.#N.snapshot){let q=this.#_?.value?.webcam?.snapshot;if(q)this.#N.snapshot=q}break;default:{let{type:q,colorSpace:N,...G}=J;this.#X=G;break}}if(j)this.#P();else this.#S();this.#k(),this.#h()}),this.#_.addEventListener("change",($)=>{$.stopPropagation(),this.#E()}),this.#_.addEventListener("loaded",($)=>{$.stopPropagation(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,detail:$.detail}))}),this.#_.addEventListener("webcamstream",($)=>{this.dispatchEvent(new CustomEvent("webcamstream",{bubbles:!0,composed:!0,detail:$.detail}))})}if(this.#$)this.#$.addEventListener("input",(Z)=>{Z.stopPropagation();let $="#"+Z.target.value.replace("#","");this.#Q.color=$,this.#V(),this.#h()}),this.#$.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#E()});if(this.#J)this.#J.addEventListener("input",(Z)=>{Z.stopPropagation();let $=parseFloat(Z.target.value),Q=(isNaN($)?100:$)/100;switch(this.#Z){case"solid":this.#Q.alpha=Q;break;case"gradient":this.#j.opacity=Q;break;case"image":this.#G.opacity=Q;break;case"video":this.#q.opacity=Q;break;case"webcam":this.#N.opacity=Q;break;default:this.#X.opacity=Q;break}this.#V(),this.#k(),this.#h()}),this.#J.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#E()})}#S(){switch(this.#Z){case"solid":if(this.#$)this.#$.setAttribute("value",this.#Q.color.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",Math.round(this.#Q.alpha*100));break;case"gradient":{let _=this.querySelector(".fig-input-fill-label");if(_){let Z=this.#j.type.charAt(0).toUpperCase()+this.#j.type.slice(1);_.textContent=Z}if(this.#J)this.#J.setAttribute("value",Math.round((this.#j.opacity??1)*100));break}case"image":if(this.#J)this.#J.setAttribute("value",Math.round((this.#G.opacity??1)*100));break;case"video":if(this.#J)this.#J.setAttribute("value",Math.round((this.#q.opacity??1)*100));break;case"webcam":if(this.#J)this.#J.setAttribute("value",Math.round((this.#N.opacity??1)*100));break;default:{let _=this.querySelector(".fig-input-fill-label");if(_)_.textContent=this.#B();if(this.#J)this.#J.setAttribute("value",Math.round(this.#W(this.#X.opacity??this.#X.alpha,1)*100));break}}}#P(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.querySelector(".input-combo");if(!Z)return;let $=Z.querySelector(".fig-input-fill-label"),J=Z.querySelector(".fig-input-fill-hex"),Q=Z.querySelector(".fig-input-fill-opacity"),j=Z.querySelectorAll("fig-tooltip");$?.remove(),J?.remove(),j.forEach((N)=>N.remove()),Z.append(...this.#z(_)),this.#J=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let q=this.querySelector(".fig-input-fill-label");if(this.#D(),q&&this.#_)q.addEventListener("click",()=>{let N=this.#_.querySelector("fig-swatch");if(N)N.click()});if(this.#$)this.#$.addEventListener("input",(N)=>{N.stopPropagation();let G="#"+N.target.value.replace("#","");this.#Q.color=G,this.#V(),this.#h()}),this.#$.addEventListener("change",(N)=>{N.stopPropagation(),this.#E()});if(this.#J)this.#J.addEventListener("input",(N)=>{N.stopPropagation();let G=parseFloat(N.target.value),X=(isNaN(G)?100:G)/100;switch(this.#Z){case"solid":this.#Q.alpha=X;break;case"gradient":this.#j.opacity=X;break;case"image":this.#G.opacity=X;break;case"video":this.#q.opacity=X;break;case"webcam":this.#N.opacity=X;break;default:this.#X.opacity=X;break}this.#V(),this.#C(X),this.#h()}),this.#J.addEventListener("change",(N)=>{N.stopPropagation(),this.#E()})}#V(){if(this.#_)this.#_.setAttribute("value",JSON.stringify(this.value));this.#k()}#k(){let _=this.#_?.querySelector("fig-swatch");if(!_)return;let Z=this.#R();if(this.#Z==="webcam"&&!Z){if((_.getAttribute("background")||"").startsWith("url(")){_.setAttribute("alpha",this.#O());return}}_.setAttribute("background",Z),_.setAttribute("alpha",this.#O())}#C(_){let Z=this.#_?.querySelector("fig-swatch");if(Z)Z.setAttribute("alpha",_)}#h(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#E(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get webcamStream(){return this.#_?.webcamStream??null}releaseWebcam(){this.#_?.releaseWebcam?.()}#f(){let _=this.#q.url??null;return{url:_,poster:this.#q.poster??null,scaleMode:this.#q.scaleMode||"fill",scale:this.#q.scale??50,opacity:this.#q.opacity??1,..._?{}:{missing:!0}}}#x(){return{live:this.#N.live!==!1,snapshot:this.#N.snapshot??this.#_?.value?.webcam?.snapshot??null,deviceId:this.#N.deviceId??null,scaleMode:this.#N.scaleMode||"fill",scale:this.#N.scale??50,opacity:this.#N.opacity??1}}get value(){switch(this.#Z){case"solid":return{type:"solid",colorSpace:"srgb",color:this.#Q.color,alpha:this.#Q.alpha,opacity:Math.round(this.#Q.alpha*100)};case"gradient":return{type:"gradient",colorSpace:"srgb",gradient:B_(this.#j),css:this.#U()};case"image":return{type:"image",colorSpace:"srgb",image:{...this.#G}};case"video":return{type:"video",colorSpace:"srgb",video:this.#f()};case"webcam":return{type:"webcam",colorSpace:"srgb",webcam:this.#x()};default:return{type:this.#Z,...this.#X}}}set value(_){if(typeof _==="string")this.setAttribute("value",_);else this.setAttribute("value",JSON.stringify(_))}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"value":let J=this.#Z;if(this.#K(),this.#_)if(this.#Z!==J)this.#F();else this.#V(),this.#S();break;case"disabled":this.#I();break;case"mode":case"webcam-mode":case"default-video":if(this.#_)if($)this.#_.setAttribute(_,$);else this.#_.removeAttribute(_);break;case"alpha":if(this.isConnected)this.#F();break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#D();break}}}F("fig-input-fill",F_);class A_ extends HTMLElement{#Z=[];#_=[];#J=[];#$=null;#Q=null;#j=null;#G=!1;#q=this.#W.bind(this);#N=()=>this.focus();#X=()=>{if(!this.#j)return;if(this.#j.hasAttribute("open")||this.#j.matches?.(":open")||this.#j.matches?.(":popover-open"))return;if(this.open)this.open=!1};static get observedAttributes(){return["value","disabled","min","max","open","fixed","edit"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){let Z=this.open;if(_&&this.#Y!=="false")this.setAttribute("open","");else this.removeAttribute("open");let $=this.open;if(Z!==$)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:$},bubbles:!0}))}get#K(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#Y(){let _=this.getAttribute("edit");if(_==="false")return"false";if(_==="picker")return"picker";return"true"}get#R(){let _=parseInt(this.getAttribute("min"));return isNaN(_)?2:_}get#U(){let _=parseInt(this.getAttribute("max"));return isNaN(_)?8:_}connectedCallback(){if(this.setAttribute("tabindex","-1"),this.removeEventListener("focus",this.#N),this.addEventListener("focus",this.#N),this.removeEventListener("keydown",this.#q),this.addEventListener("keydown",this.#q),this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{if(this.#$=null,!this.isConnected)return;this.#O(),this.#M(),this.#B()})}disconnectedCallback(){if(this.#$)cancelAnimationFrame(this.#$),this.#$=null;this.removeEventListener("keydown",this.#q),this.removeEventListener("focus",this.#N),this.#_=[],this.#J=[],this.#D()}#W(_){if(_.key!=="Enter"&&_.key!==" ")return;if(_.target!==this.querySelector(".palette-colors-inline"))return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Y==="false")return;_.preventDefault(),_.stopPropagation(),this.open=!0}attributeChangedCallback(_,Z,$){if(Z===$||this.#G)return;switch(_){case"value":this.#O(),this.#V(),this.#A();break;case"disabled":this.#k();break;case"min":case"max":case"fixed":this.#M(),this.#A();break;case"open":this.#C(),this.#I();break;case"edit":if(this.#Y==="false"&&this.open)this.open=!1;if(this.#Y!=="picker")this.#D();this.#M(),this.#B();break}}#O(){let _=this.getAttribute("value");if(!_){this.#Z=[];return}let Z=_.trim();try{let $=JSON.parse(Z);if(Array.isArray($)){this.#Z=$.map((J)=>{if(typeof J==="string")return{color:J.slice(0,7),alpha:J.length>7?parseInt(J.slice(7,9),16)/255:1};if(J&&typeof J==="object")return{color:J.color||"#D9D9D9",alpha:J.alpha!==void 0?J.alpha:J.opacity!==void 0?J.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch($){}if(Z.includes(",")){this.#Z=Z.split(",").map(($)=>{let J=$.trim();return{color:J.slice(0,7),alpha:J.length>7?parseInt(J.slice(7,9),16)/255:1}});return}if(Z.startsWith("#")){this.#Z=[{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}];return}this.#Z=[]}get value(){return this.#Z.map((_)=>({..._}))}set value(_){if(typeof _==="string")this.setAttribute("value",_);else this.setAttribute("value",JSON.stringify(_))}#M(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.#Y,$=Z!=="false";this.replaceChildren(),this.#_=[],this.#J=[];let J=document.createElement("div");if(J.className="palette-colors-inline",$){if(J.setAttribute("role","button"),J.setAttribute("tabindex",_?"-1":"+0"),J.setAttribute("aria-expanded",String(this.open)),J.setAttribute("aria-label","Edit palette colors"),Z==="picker")J.setAttribute("aria-haspopup","dialog")}else J.setAttribute("role","img"),J.setAttribute("aria-label","Palette colors");J.addEventListener("blur",()=>{J.style.removeProperty("outline"),J.style.removeProperty("outline-offset")});let Q=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0};if($)J.addEventListener("click",Q);let j=document.createElement("div");if(j.className="palette-colors",this.#Z.forEach((q,N)=>{j.appendChild(this.#H(q,N,_,{inline:!0}))}),J.appendChild(j),this.appendChild(J),this.#C(),Z==="true"){if(!this.#K)this.#T(_,this);let q=document.createElement("div");q.className="palette-colors-expanded",this.#Z.forEach((N,G)=>{if(q.appendChild(this.#H(N,G,_)),!this.#K)q.appendChild(this.#z(G,_))}),this.appendChild(q)}}#B(){if(this.#Y!=="picker"||customElements.get("fig-popup-palette")){this.#I();return}this.#Q??=customElements.whenDefined("fig-popup-palette").then(()=>{if(!this.isConnected||this.#Y!=="picker")return;this.#I()})}#L(){if(this.#j?.isConnected)return this.#j;if(!customElements.get("fig-popup-palette"))return null;let _=document.createElement("dialog",{is:"fig-popup-palette"});_.setAttribute("is","fig-popup-palette"),_.id=g(),_.anchor=this;let Z=($)=>{if($.stopPropagation(),!Array.isArray($.detail))return;this.#Z=$.detail.map((J)=>({color:J?.color||"#D9D9D9",alpha:Number.isFinite(Number(J?.alpha))?Math.max(0,Math.min(1,Number(J.alpha))):1})),this.#G=!0,this.setAttribute("value",JSON.stringify(this.#Z)),this.#G=!1,this.#V(),this.dispatchEvent(new CustomEvent($.type,{bubbles:!0,detail:this.value}))};return _.addEventListener("input",Z),_.addEventListener("change",Z),_.addEventListener("close",this.#X),_.addEventListener("toggle",this.#X),(l()??document.body).append(_),this.#j=_,this.querySelector(".palette-colors-inline")?.setAttribute("aria-controls",_.id),this.#A(),_}#A(){let _=this.#j;if(!_)return;_.setAttribute("value",JSON.stringify(this.#Z)),_.setAttribute("min",String(this.#R)),_.setAttribute("max",String(this.#U)),_.toggleAttribute("fixed",this.#K);let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";_.toggleAttribute("disabled",Z)}#I(){if(!this.isConnected||this.#Y!=="picker")return;if(!customElements.get("fig-popup-palette")){this.#B();return}if(!this.open){if(this.#j)this.#j.open=!1;return}if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.open=!1;return}let Z=this.#L();if(!Z)return;this.#A(),Z.open=!0}#D(){if(!this.#j)return;this.#j.removeEventListener("close",this.#X),this.#j.removeEventListener("toggle",this.#X),this.#j.open=!1,this.#j.remove(),this.querySelector(".palette-colors-inline")?.removeAttribute("aria-controls"),this.#j=null}#H(_,Z,$,{inline:J=!1}={}){let Q=_.alpha<1?_.color+Math.round(_.alpha*255).toString(16).padStart(2,"0"):_.color,j=document.createElement("fig-input-color");if(j.setAttribute("value",Q),J)j.setAttribute("text","false"),j.setAttribute("alpha","true"),j.setAttribute("swatch-disabled","");else j.setAttribute("text","true"),j.setAttribute("alpha","true"),j.setAttribute("full","");if($)j.setAttribute("disabled","");let q=J?this.#J:this.#_,N=(G)=>{G.stopPropagation();let K=G.currentTarget;this.#Z[Z]={color:K.hexOpaque||this.#Z[Z].color,alpha:K.rgba?K.rgba.a:this.#Z[Z].alpha};let X=q[Z];if(X){let Y=this.#Z[Z],W=Y.alpha<1?Y.color+Math.round(Y.alpha*255).toString(16).padStart(2,"0"):Y.color;X.setAttribute("value",W)}};if(j.addEventListener("input",(G)=>{N(G),this.#E()}),j.addEventListener("change",(G)=>{N(G),this.#f()}),J)this.#_.push(j);else this.#J.push(j);return j}#z(_,Z){let $=document.createElement("fig-button");if($.setAttribute("variant","ghost"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Remove color"),$.className="palette-remove-btn",Z||this.#Z.length<=this.#R)$.setAttribute("disabled","");$.appendChild(b("minus")),$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#F(_)});let J=document.createElement("fig-tooltip");return J.setAttribute("text","Remove color"),J.appendChild($),J}#F(_){if(this.#K)return;if(_<0||_>=this.#Z.length)return;if(this.#Z.length<=this.#R)return;this.#Z.splice(_,1),this.#_=[],this.#J=[],this.#M(),this.#f()}#T(_,Z=this){let $=this.#Z.length>=this.#U,J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Add color"),J.className="palette-add-btn",_||$)J.setAttribute("disabled","");J.appendChild(b("add")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Z.length>=this.#U)return;this.open=!0,this.#S({color:"#D9D9D9",alpha:1})});let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Add color"),Q.appendChild(J),Z.appendChild(Q)}#S(_){if(this.#K)return;this.#Z.push(_);let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#Z.length-1,J=this.#H(_,$,Z,{inline:!0}),Q=this.querySelector(".palette-colors");if(Q)Q.appendChild(J);let j=this.#H(_,$,Z),q=this.querySelector(".palette-colors-expanded");if(q)q.appendChild(j),q.appendChild(this.#z($,Z));if(this.#Z.length>=this.#U){let N=this.querySelector(".palette-add-btn");if(N)N.setAttribute("disabled","")}this.#h(Z),this.#f()}#P(_){let Z=this.#Z[_];if(!Z)return;let $=Z.alpha<1?Z.color+Math.round(Z.alpha*255).toString(16).padStart(2,"0"):Z.color,J=this.#_[_];if(J)J.setAttribute("value",$);let Q=this.#J[_];if(Q)Q.setAttribute("value",$)}#V(){if(this.#_.length!==this.#Z.length){this.#M();return}this.#Z.forEach((_,Z)=>{this.#P(Z)})}#k(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#_,...this.#J].forEach(($)=>{if(_)$.setAttribute("disabled","");else $.removeAttribute("disabled")});let Z=this.querySelector(".palette-add-btn");if(Z)if(_||this.#Z.length>=this.#U)Z.setAttribute("disabled","");else Z.removeAttribute("disabled");if(this.#h(_),this.#C(),this.#A(),_&&this.#Y==="picker"&&this.open)this.open=!1}#C(){let _=this.querySelector(".palette-colors-inline");if(!_)return;let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#Y==="false"){_.removeAttribute("tabindex"),_.removeAttribute("aria-disabled"),_.removeAttribute("aria-expanded"),_.removeAttribute("aria-haspopup");return}if(_.setAttribute("tabindex",Z?"-1":"+0"),_.setAttribute("aria-disabled",String(Z)),_.setAttribute("aria-expanded",String(this.open)),this.#Y==="picker")_.setAttribute("aria-haspopup","dialog");else _.removeAttribute("aria-haspopup")}focus(){if(this.#Y==="false"||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let _=this.querySelector(".palette-colors-inline");if(!_)return;_.style.outline="var(--figma-focus-outline)",_.style.outlineOffset="var(--figma-focus-outline-offset)",_.focus()}#h(_=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let Z=_||this.#Z.length<=this.#R;this.querySelectorAll(".palette-remove-btn").forEach(($)=>{if(Z)$.setAttribute("disabled","");else $.removeAttribute("disabled")})}#E(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#f(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}F("fig-input-palette",A_);class G0 extends HTMLElement{static SHIFT_SNAP=5;#Z;#_;#J=!1;#$=null;#Q=null;#j=null;#G=null;#q=null;#N=!1;anchorElement=null;#X=()=>{if(!this.#q)return;if(this.#q.hasAttribute("open")||this.#q.matches?.(":open")||this.#q.matches?.(":popover-open"))return;this.classList.remove("has-popup-open")};#K={type:"linear",angle:90,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode","size"]}get#Y(){let _=this.getAttribute("edit");if(_==="false")return"false";if(_==="picker")return"picker";return"true"}get#R(){return this.#Y==="true"}get#U(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#W(){if(!this.#_)return null;return this.#_.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#O(){if(!this.#_)return null;let _=this.#_.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(_)return _;let Z=document.activeElement;if(!(Z instanceof Element)||!this.#_.contains(Z))return null;return Z.closest("fig-handle:not(.fig-input-gradient-ghost)")}#M(_){if(!_||!this.#_)return;this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(Z!==_)Z.deselect()}),_.select(),_.focus()}#B(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#R?"-1":"0")}#L(_){let Z=K0(_);return{...Z,type:["linear","radial","angular"].includes(Z.type)?Z.type:"linear",angle:Number.isFinite(Number(Z.angle))?Number(Z.angle):90,centerX:Number.isFinite(Number(Z.centerX))?Number(Z.centerX):50,centerY:Number.isFinite(Number(Z.centerY))?Number(Z.centerY):50}}connectedCallback(){if(this.#z(),this.#C(),this.#A(),this.removeEventListener("click",this.#H),this.addEventListener("click",this.#H),this.removeEventListener("keydown",this.#D),this.addEventListener("keydown",this.#D),this.#R)document.addEventListener("keydown",this.#I)}#A(){if(this.#Y!=="picker"||customElements.get("fig-popup-gradient"))return;this.#G??=customElements.whenDefined("fig-popup-gradient").then(()=>{if(!this.isConnected||this.#Y!=="picker")return;this.#C()})}disconnectedCallback(){if(document.removeEventListener("keydown",this.#I),this.removeEventListener("click",this.#H),this.removeEventListener("keydown",this.#D),this.#x(),this.#Q)this.#Q.disconnect(),this.#Q=null;if(this.#j!==null)cancelAnimationFrame(this.#j),this.#j=null;clearTimeout(this.#$),this.removeEventListener("pointerenter",this.#b),this.removeEventListener("pointermove",this.#u),this.removeEventListener("pointerleave",this.#v),this.removeEventListener("click",this.#i),this.removeEventListener("dblclick",this.#o)}#I=(_)=>{let Z=document.activeElement,$=Z instanceof Node&&this.contains(Z),J=this.#_?.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)"),Q=!Z||Z===document.body||Z===document.documentElement;if(!$&&!(J&&Q))return;let j=Z&&(Z.tagName==="INPUT"||Z.tagName==="TEXTAREA"||Z.isContentEditable);if(!this.#_)return;if(_.key==="Tab"&&!j){let X=this.#O();if(!X)return;_.preventDefault();let Y=[...this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],W=Y.indexOf(X),R=_.shiftKey?(W-1+Y.length)%Y.length:(W+1)%Y.length;X.deselect(),this.#M(Y[R]);return}if((_.key==="ArrowLeft"||_.key==="ArrowRight")&&!j){let X=this.#O();if(!X)return;let Y=parseInt(X.dataset.stopIndex,10);if(isNaN(Y)||!this.#K.stops[Y])return;_.preventDefault();let W=(_.key==="ArrowRight"?1:-1)*(_.shiftKey?G0.SHIFT_SNAP:1),R=this.#K.stops[Y];R.position=Math.max(0,Math.min(100,R.position+W)),X.setAttribute("value",`${R.position}% 50%`);let L=X.closest("fig-tooltip");if(L)L.text=`${Math.round(R.position)}%`,L.setAttribute("show","true"),L.showPopup(),X.hideColorTip(),clearTimeout(this.#$),this.#$=setTimeout(()=>{L.removeAttribute("show"),X.showColorTip()},600);this.#s(),this.#l(),this.#_0();return}if(_.key!=="Delete"&&_.key!=="Backspace")return;if(j)return;if(this.#K.stops.length<=2)return;let q=this.#O();if(!q)return;let N=parseInt(q.dataset.stopIndex,10);if(isNaN(N)||!this.#K.stops[N])return;_.preventDefault(),this.#K.stops.splice(N,1),this.#m(),this.#s(),this.#l(),this.#_0();let G=Math.min(N,this.#K.stops.length-1),K=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[G];this.#M(K)};#D=(_)=>{if(this.#Y!=="picker")return;if(_.key!=="Enter"&&_.key!==" ")return;if(_.altKey||_.ctrlKey||_.metaKey)return;if(T(this,"disabled"))return;_.preventDefault(),this.#f()};#H=()=>{if(this.#Y!=="picker"||T(this,"disabled"))return;this.#f()};#z(){let _=this.getAttribute("value");if(!_)return;try{let Z=JSON.parse(_);if(Z?.type==="gradient"&&Z.gradient){this.#K=this.#L({...this.#K,...Z.gradient});return}if(Z?.gradient)this.#K=this.#L({...this.#K,...Z.gradient})}catch(Z){}}#F(){let _=this.#L(this.#K),$=[..._.stops].sort((j,q)=>j.position-q.position).map((j)=>{let q=(j.opacity??100)/100;if(q>=1)return`${j.color} ${j.position}%`;let{r:N,g:G,b:K}=_0(j.color);return`rgba(${N}, ${G}, ${K}, ${q}) ${j.position}%`}).join(", "),J=H_(_),Q=J?` ${J}`:"";if(this.#Y==="picker")switch(_.type){case"radial":return`radial-gradient(circle at ${_.centerX}% ${_.centerY}%${Q}, ${$})`;case"angular":return`conic-gradient(from ${_.angle}deg${Q}, ${$})`;default:return`linear-gradient(${_.angle}deg${Q}, ${$})`}return`linear-gradient(to right${Q}, ${$})`}#T(_){let Z=(_.opacity??100)/100;if(Z>=1)return _.color;let{r:$,g:J,b:Q}=_0(_.color);return`rgba(${$}, ${J}, ${Q}, ${Z})`}#S(){if(!this.#Z)return;let _=this.getAttribute("size");if(_)this.#Z.setAttribute("size",_);else this.#Z.removeAttribute("size")}#P(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";return this.#K.stops.map((Z,$)=>M("fig-tooltip",{action:"manual",text:`${Math.round(Z.position)}%`},M("fig-handle",{drag:!0,"drag-axes":"x","drag-surface":".fig-input-gradient-track",type:"color",tip:this.#U==="tip"?"color":null,color:this.#T(Z),value:`${Z.position}% 50%`,"hit-area":"4","data-stop-index":$,disabled:_})))}#V=null;#k=!1;#C(){this.#Q?.disconnect(),this.#Q=null;let _=T(this,"disabled"),Z=this.#Y,$=this.getAttribute("size"),J=M("fig-swatch",{background:this.#F(),size:$||null,disabled:_});if(Z==="picker"){this.setAttribute("aria-haspopup","dialog"),this.replaceChildren(J),this.#Z=J,this.#_=null,this.#B();return}this.removeAttribute("aria-haspopup");let Q=Z==="true"||Z==="picker",j=Q?M("div",{className:"fig-input-gradient-track"},this.#P()):null;if(this.replaceChildren(...j?[J,j]:[J]),this.#Z=J,this.#_=j,Q)this.#w(),this.#e();this.#B()}#h(){if(this.#q?.isConnected)return this.#q;if(!customElements.get("fig-popup-gradient"))return null;let _=document.createElement("dialog",{is:"fig-popup-gradient"});_.setAttribute("is","fig-popup-gradient"),_.id=g(),_.anchor=this.anchorElement||this;let Z=($)=>{if($.stopPropagation(),!$.detail?.gradient)return;if(this.#K=this.#L({...this.#K,...$.detail.gradient}),this.#N=!0,this.setAttribute("value",JSON.stringify(this.value)),this.#N=!1,typeof $.detail.css==="string"&&$.detail.css)this.#Z?.setAttribute("background",$.detail.css),this.#S();else this.#s();this.dispatchEvent(new CustomEvent($.type,{bubbles:!0,composed:!0,detail:this.value}))};return _.addEventListener("input",Z),_.addEventListener("change",Z),_.addEventListener("close",this.#X),_.addEventListener("toggle",this.#X),(l()??document.body).append(_),this.#q=_,this.setAttribute("aria-controls",_.id),this.#E(),_}#E(){if(!this.#q)return;this.#q.setAttribute("value",JSON.stringify(this.#K)),this.#q.toggleAttribute("disabled",T(this,"disabled")),this.#q.anchor=this.anchorElement||this}#f(){let _=this.#h();if(!_){this.#A();return}this.#E(),_.open=!0,this.classList.add("has-popup-open")}#x(){if(!this.#q)return;this.#q.removeEventListener("close",this.#X),this.#q.removeEventListener("toggle",this.#X),this.#q.open=!1,this.#q.remove(),this.#q=null,this.removeAttribute("aria-controls"),this.classList.remove("has-popup-open")}#g(_){return O1(this.#K.stops,_,this.#K.interpolationSpace,this.#K.hueInterpolation)}#w(){if(!this.#_||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let _=document.createElement("fig-handle");if(_.classList.add("fig-input-gradient-ghost"),_.setAttribute("type","color"),this.#U==="tip")_.setAttribute("tip","add");_.style.position="absolute",_.style.top="50%",_.style.transform="translate(-50%, -50%)",_.style.pointerEvents="none",_.style.opacity="0",_.style.transition="opacity 0.15s",this.#_.appendChild(_),this.#V=_,this.addEventListener("pointerenter",this.#b),this.addEventListener("pointermove",this.#u),this.addEventListener("pointerleave",this.#v),this.addEventListener("click",this.#i),this.addEventListener("dblclick",this.#o)}#p(){if(!this.#V)return;this.#V.style.opacity="1"}#y(){if(!this.#V)return;this.#V.style.opacity="0"}#b=()=>{if(this.#J)return;this.#p()};#v=()=>{this.#y()};#u=(_)=>{if(this.#J){this.#y();return}if(!this.#V||!this.#_)return;if(_.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#y();return}let Z=this.#_.getBoundingClientRect(),$=Math.max(0,Math.min(1,(_.clientX-Z.left)/Z.width));this.#V.style.left=`${$*100}%`;let J=this.#g($);this.#V.setAttribute("color",J),this.#p()};#a(){let _=this.#K.stops.length;if(_<2)return;for(let Z=0;Z<_;Z++)this.#K.stops[Z].position=Math.round(Z/(_-1)*100);this.#m(),this.#s(),this.#l(),this.#_0()}#o=(_)=>{if(!this.#_)return;if(!_.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#a(),this.#_.querySelectorAll("fig-handle[selected]").forEach((Z)=>{Z.removeAttribute("selected")})};#i=(_)=>{if(!this.#_)return;if(this.#J)return;if(this.#k){this.#k=!1;return}if(_.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(_.shiftKey){let q=_.target.closest("fig-handle"),N=parseInt(q?.dataset.stopIndex,10);if(this.#a(),!isNaN(N))this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((G)=>{if(parseInt(G.dataset.stopIndex,10)===N)G.select();else G.deselect()});_.stopPropagation()}return}let Z=this.#_.getBoundingClientRect(),$=Math.max(0,Math.min(1,(_.clientX-Z.left)/Z.width)),J=Math.round($*100),Q=this.#g($);this.#K.stops.push({position:J,color:Q,opacity:100}),this.#K.stops.sort((q,N)=>q.position-N.position);let j=this.#K.stops.findIndex((q)=>q.position===J&&q.color===Q);this.#m(),this.#s(),this.#l(),this.#_0(),requestAnimationFrame(()=>{let N=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[j];if(N)this.#M(N)})};#r(){if(this.#j=null,!this.isConnected)return;if(!this.#_)return;let _=this.#K.stops;this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z,$)=>{if($>=_.length)return;Z.removeAttribute("value"),Z.setAttribute("value",`${_[$].position}% 50%`)})}refreshLayout(){this.#r()}#t(){if(this.#j!==null)return;this.#j=requestAnimationFrame(()=>this.#r())}#m(){if(!this.#_)return;let _=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#K.stops;if(_.length!==Z.length){let $=this.#V;if(this.#_.replaceChildren(...this.#P()),$)this.#_.appendChild($);this.#c(),this.#d(),this.#t();return}for(let $=0;$<Z.length;$++){let J=_[$],Q=Z[$];if(J.dataset.stopIndex=$,J.setAttribute("value",`${Q.position}% 50%`),J.setAttribute("color",this.#T(Q)),this.#U==="tip")J.setAttribute("tip","color");else J.removeAttribute("tip");let j=J.closest("fig-tooltip");if(j)j.setAttribute("text",`${Math.round(Q.position)}%`)}this.#c()}#c(){if(!this.#_)return;let _=this.#U==="tip";if(this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(_)Z.setAttribute("tip","color");else Z.removeAttribute("tip")}),this.#V)if(_)this.#V.setAttribute("tip","add");else this.#V.removeAttribute("tip")}#d(){if(!this.#Q||!this.#_)return;this.#Q.disconnect(),this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((_)=>{this.#Q.observe(_,{attributes:!0,attributeFilter:["color"]})})}#Q0(){if(!this.#_)return;let _=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#K.stops,$=new Set;_.forEach((J)=>{let Q=Math.round(parseFloat(J.getAttribute("value"))||0),j=(J.getAttribute("color")||"").toUpperCase(),q=-1;for(let N=0;N<Z.length;N++){if($.has(N))continue;if(Z[N].position===Q&&Z[N].color.toUpperCase()===j){q=N;break}}if(q===-1){let N=1/0;for(let G=0;G<Z.length;G++){if($.has(G))continue;let K=Math.abs(Z[G].position-Q);if(K<N)N=K,q=G}}if(q!==-1)$.add(q),J.dataset.stopIndex=q})}#s(){if(!this.#Z)return;this.#Z.setAttribute("background",this.#F()),this.#S()}#e(){if(!this.#_)return;this.#_.addEventListener("pointerdown",(_)=>{if(T(this,"disabled"))return;let Z=_.target.closest("fig-handle:not(.fig-input-gradient-ghost)");if(Z){this.#M(Z);return}if(_.button!==0)return;_.preventDefault(),_.stopPropagation();let $=this.#_.getBoundingClientRect(),J=Math.max(0,Math.min(1,(_.clientX-$.left)/$.width)),Q=Math.round(J*100),j=this.#g(J);this.#K.stops.push({position:Q,color:j,opacity:100}),this.#K.stops.sort((K,X)=>K.position-X.position);let q=this.#K.stops.findIndex((K)=>K.position===Q&&K.color===j);this.#k=!0,this.#m(),this.#s(),this.#l(),this.#y();let G=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(G)this.#M(G),G.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:_.clientX,clientY:_.clientY,pointerId:_.pointerId,pointerType:_.pointerType,button:_.button,buttons:_.buttons}))}),this.#_.addEventListener("input",(_)=>{let Z=_.target.closest("fig-handle");if(!Z)return;if(_.stopPropagation(),_.detail?.color){let G=parseInt(Z.dataset.stopIndex,10);if(!isNaN(G)&&this.#K.stops[G]){if(this.#K.stops[G].color=_.detail.color,_.detail.opacity!==void 0)this.#K.stops[G].opacity=_.detail.opacity;else if(_.detail.alpha!==void 0)this.#K.stops[G].opacity=Math.round(_.detail.alpha*100);Z.setAttribute("color",this.#T(this.#K.stops[G])),this.#s(),this.#l()}return}if(!this.#J)Z.style.zIndex="5";this.#J=!0;let $=parseInt(Z.dataset.stopIndex,10);if(isNaN($)||!this.#K.stops[$])return;let J=_.detail?.px??0,Q=Math.round(J*100),j=Q,q=this.#_.getBoundingClientRect().width;if(_.detail?.shiftKey)j=Math.round(j/G0.SHIFT_SNAP)*G0.SHIFT_SNAP;else{let G=q>0?5/q*100:0;for(let K=0;K<this.#K.stops.length;K++){if(K===$)continue;if(Math.abs(this.#K.stops[K].position-j)<=G){j=this.#K.stops[K].position;break}}}if(this.#K.stops[$].position=j,j!==Q)Z.style.left=`${j/100*q}px`;let N=Z.closest("fig-tooltip");if(N&&this.#U!=="tip"){if(N.text=`${Math.round(j)}%`,!N.hasAttribute("show"))N.setAttribute("show","true"),Z.hideColorTip()}this.#s(),this.#l()}),this.#_.addEventListener("change",(_)=>{let Z=_.target.closest("fig-handle");if(!Z)return;if(_.stopPropagation(),_.detail?.color){let G=parseInt(Z.dataset.stopIndex,10);if(!isNaN(G)&&this.#K.stops[G]){if(this.#K.stops[G].color=_.detail.color,_.detail.opacity!==void 0)this.#K.stops[G].opacity=_.detail.opacity;Z.setAttribute("color",this.#T(this.#K.stops[G])),this.#s(),this.#_0()}return}Z.style.zIndex="";let $=Z.closest("fig-tooltip");if($)$.removeAttribute("show");Z.showColorTip();let J=parseInt(Z.dataset.stopIndex,10);if(isNaN(J)||!this.#K.stops[J])return;let Q=_.detail?.px??0,j=Math.round(Q*100),q=this.#_.getBoundingClientRect().width,N=q>0?5/q*100:0;for(let G=0;G<this.#K.stops.length;G++){if(G===J)continue;if(Math.abs(this.#K.stops[G].position-j)<=N){j=this.#K.stops[G].position;break}}this.#K.stops[J].position=j,Z.style.left=`${j/100*q}px`,this.#K.stops.sort((G,K)=>G.position-K.position),this.#Q0(),this.#s(),this.#_0(),requestAnimationFrame(()=>{this.#J=!1})}),this.#Q=new MutationObserver((_)=>{for(let Z of _){if(Z.attributeName!=="color")continue;let $=Z.target;if($.classList.contains("fig-input-gradient-ghost"))continue;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#K.stops[J])continue;let Q=$.getAttribute("color");if(!Q||!Q.startsWith("#"))continue;if(Q!==this.#K.stops[J].color)this.#K.stops[J].color=Q,this.#s(),this.#l()}}),this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((_)=>{this.#Q.observe(_,{attributes:!0,attributeFilter:["color"]})})}#l(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#_0(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:B_(this.#L(this.#K))}}set value(_){let Z=typeof _==="string"?_:JSON.stringify(_);if(this.getAttribute("value")===Z){this.#z(),this.#s(),this.#m();return}this.setAttribute("value",Z)}focus(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#R){let Z=this.#W();if(Z){Z.focus(_);return}}HTMLElement.prototype.focus.call(this,_)}attributeChangedCallback(_,Z,$){if(Z===$||this.#N)return;switch(_){case"value":this.#z(),this.#s(),this.#m(),this.#E();break;case"disabled":this.#$0(),this.#E();break;case"edit":if(this.#Y!=="picker")this.#x();if(this.#C(),this.#A(),this.#R)document.addEventListener("keydown",this.#I);else document.removeEventListener("keydown",this.#I);break;case"mode":this.#c();break;case"size":this.#S();break}}#$0(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#B(),this.#Z)if(_)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#_)for(let Z of this.#_.querySelectorAll("fig-handle"))if(_)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}F("fig-input-gradient",G0);class O0 extends HTMLElement{#Z=null;#_;#J;#$;#Q=!1;constructor(){super();if(this.input=document.createElement("input"),this.name=this.getAttribute("name")||"",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",g()),this.name)this.input.setAttribute("name",this.name);this.input.setAttribute("type","checkbox"),this.#_=this.handleInput.bind(this),this.#J=this.handleChange.bind(this),this.#$=(_)=>{if(_.target!==this||this.input.disabled)return;this.input.click()}}connectedCallback(){let _=this.querySelector(":scope > input");if(_)this.input=_;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("input",this.#_),this.input.addEventListener("input",this.#_),this.input.removeEventListener("change",this.#J),this.input.addEventListener("change",this.#J),this.removeEventListener("click",this.#$),this.addEventListener("click",this.#$),this.#N();let Z=this.querySelector(":scope > label");if(Z)this.#Z=Z,this.#Q=!1,this.#Z.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#j(),this.#Z.innerText=this.getAttribute("label");if(!this.hasAttribute("label")){let $=Array.from(this.childNodes).filter((J)=>J.nodeType===Node.TEXT_NODE).map((J)=>J.textContent||"").join(" ").trim();if($&&!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-label",$)}this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#j(){if(!this.#Z)this.#Z=document.createElement("label"),this.#Q=!0,this.#Z.setAttribute("for",this.input.id);if(this.#Z&&!this.#Z.parentNode&&this.input.parentNode)this.input.after(this.#Z)}render(){}#G(_){return this.hasAttribute(_)&&this.getAttribute(_)!=="false"}#q(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#N(){let _=this.#G("checked"),Z=this.#G("indeterminate")&&!_,$=this.#G("disabled");this.input.checked=_,this.input.indeterminate=Z,this.input.disabled=$,this.input.value=this.getAttribute("value")||"";let J=this.getAttribute("name")||this.name;if(J)this.input.setAttribute("name",J);else this.input.removeAttribute("name");if(Z)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#q()}focus(){this.input.focus()}get value(){return this.input.value}set value(_){this.input.value=_,this.setAttribute("value",_)}get checked(){return this.input.checked}set checked(_){if(this.input.checked=_,_)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#J),this.removeEventListener("click",this.#$)}attributeChangedCallback(_,Z,$){switch(_){case"label":if($)this.#j(),this.#Z.innerText=$;else if(this.#Z&&this.#Q)this.#Z.remove(),this.#Z=null,this.#Q=!1;break;case"checked":if(this.#G("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#N();break;case"indeterminate":this.#N();break;case"disabled":this.#N();break;case"name":if($)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"value":this.input.value=$||"";break;default:this.input[_]=$,this.input.setAttribute(_,$);break}}handleInput(_){if(_.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#q(),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}handleChange(_){_.stopPropagation(),this.#q(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}F("fig-checkbox",O0);class z_ extends O0{constructor(){super();this.input.setAttribute("type","radio");let _=this.getAttribute("name");if(_)this.input.setAttribute("name",_);else this.input.removeAttribute("name")}}F("fig-radio",z_);class T_ extends O0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}F("fig-switch",T_);class I0 extends HTMLElement{static observedAttributes=["type","options","placeholder","value","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Z=!1;#_=null;#J=null;#$=null;#Q=null;#j=!1;#G=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#q=this.#L.bind(this);#N=this.#A.bind(this);#X=this.#D.bind(this);#K=this.#H.bind(this);get value(){return this.getAttribute("value")||""}set value(_){this.setAttribute("value",_??"")}#Y(){return this.getAttribute("type")==="number"?"fig-input-number":"fig-input-text"}#R(){return M(this.#Y(),{placeholder:this.getAttribute("placeholder")||"",value:this.value})}#U(){return this.querySelector(":scope > .input-combo > :is(fig-input-text, fig-input-number)")?.localName===this.#Y()}#W(){if(this.#_=this.querySelector(":scope > .input-combo > :is(fig-input-text, fig-input-number)"),this.#$=this.querySelector("fig-button"),this.#J=this.querySelector("fig-select, fig-dropdown"),this.#J?.localName==="fig-select"&&customElements.get("fig-select"))this.#J.menuAnchor=this;if(this.#_)this.#_.setAttribute("value",this.value),this.#_.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#V()}connectedCallback(){if(this.#Q=Array.from(this.children).find((_)=>_.tagName==="FIG-SELECT"||_.tagName==="FIG-DROPDOWN")||null,this.#Z=this.#Q!==null,this.#Q)this.#Q.remove();if(this.#U()){if(this.#W(),!this.#Q)this.#Z=!!this.#J&&!this.#J.hasAttribute("data-fig-split-generated"),this.#Q=this.#Z?this.#J:null;this.#M()}else this.#O(),this.#M();this.#k(T(this,"disabled"))}disconnectedCallback(){this.#B()}#O(){let _=this.#T(),Z=this.#P(),$=this.#R(),J=this.#Q;if(!J&&customElements.get("fig-select"))J=M("fig-select",{icon:!0,variant:"input",options:_.join(","),label:Z,"aria-label":Z,"data-fig-split-generated":!0});if(!J)J=M("fig-dropdown",{type:"dropdown",label:Z,"data-fig-split-generated":!0},_.map((q)=>M("option",{},q.trim())));let Q=J,j=null;if(J.localName==="fig-dropdown"){if(!J.hasAttribute("type"))J.setAttribute("type","dropdown");j=M("fig-button",{type:"select",variant:"input",icon:!0},M("fig-icon",{name:"chevron",size:"small",slot:"append"})),j.append(J),Q=j}if(!J.hasAttribute("label"))J.setAttribute("label",Z);if(this.replaceChildren(M("div",{className:"input-combo"},[$,Q])),this.#_=$,this.#$=j,this.#J=J,J.localName==="fig-select"&&customElements.get("fig-select"))J.menuAnchor=this;this.#V()}#M(){this.#B(),this.#J?.addEventListener("input",this.#q),this.#J?.addEventListener("change",this.#N),this.#_?.addEventListener("input",this.#X),this.#_?.addEventListener("change",this.#K)}#B(){this.#J?.removeEventListener("input",this.#q),this.#J?.removeEventListener("change",this.#N),this.#_?.removeEventListener("input",this.#X),this.#_?.removeEventListener("change",this.#K)}#L(_){_.stopPropagation(),this.#I(_),this.#z()}#A(_){_.stopPropagation(),this.#I(_),this.#F()}#I(_){let Z=_.target.closest("fig-select, fig-dropdown")?.value??"";if(this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.#_)this.#_.setAttribute("value",Z)}#D(_){_.stopPropagation();let Z=_.target.value??"";this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.#z()}#H(_){_.stopPropagation();let Z=_.target.value??"";this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.#F()}#z(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#F(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#T(){return(this.getAttribute("options")||"").split(",").map((_)=>_.trim()).filter(Boolean)}#S(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Split input").trim()}#P(){return`${this.#S()} options`}#V(){if(this.#_)this.#G.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.#_.removeAttribute(_);else this.#_.setAttribute(_,Z)});if(this.#J){let _=this.#P();if(!this.#Z){if(this.#J.setAttribute("label",_),this.#J.localName==="fig-select")this.#J.setAttribute("aria-label",_)}else if(!this.#J.hasAttribute("aria-label")&&!this.#J.hasAttribute("label"))this.#J.setAttribute("label",_)}}#k(_){if(this.#_)if(_)this.#_.setAttribute("disabled","");else this.#_.removeAttribute("disabled");if(this.#$)if(_)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#J)if(_)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}focus(){this.#_?.focus()}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"type":{if(!this.#_||this.#_.localName===this.#Y())break;let J=this.#_.matches(":focus-within");this.#B();let Q=this.#R();if(this.#_.replaceWith(Q),this.#_=Q,this.#V(),this.#k(T(this,"disabled")),this.#M(),J)this.focus();break}case"options":if(this.#J&&!this.#Z)if(this.#J.localName==="fig-select")this.#J.setAttribute("options",$||"");else{let J=this.#T();this.#J.replaceChildren(...J.map((Q)=>{let j=document.createElement("option");return j.textContent=Q,j}))}break;case"placeholder":if(this.#_)this.#_.setAttribute("placeholder",$||"");this.#V();break;case"value":if(!this.#j&&this.#_)this.#_.setAttribute("value",$||"");break;case"disabled":this.#k($!==null&&$!=="false");break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#V();break}}}F("fig-split-input",I0);class k_ extends I0{}F("fig-combo-input",k_);class V0 extends HTMLElement{#Z="color";#_=null;#J=!1;constructor(){super();this.#_=this.#X.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#q(),this.#$(),this.#N()}#$(){let _=this.getAttribute("alpha");if(_!==null)this.style.setProperty("--alpha",_);else this.style.removeProperty("--alpha")}#Q(_){if(!_)return"color";let Z=_.toLowerCase();if(Z.includes("gradient"))return"gradient";if(Z.includes("url("))return"image";return"color"}#j(_){if(!_)return"#D9D9D9";if(_.startsWith("#"))return _.slice(0,7);try{let{ctx:Z}=D0(1,1);return Z.fillStyle=_,Z.fillStyle}catch{return"#D9D9D9"}}#G(_){if(!_||!_.includes("var("))return _;let Z=this.style.background;this.style.background=_;let $=getComputedStyle(this),J=$.backgroundImage,Q=$.backgroundColor;if(this.style.background=Z,J&&J!=="none")return J;return Q||_}#q(){let _=this.getAttribute("background");if(this.hasAttribute("background")&&!_?.trim()){if(this.#Z!=="image"||this.input){if(this.#Z="image",this.setAttribute("data-type","image"),this.input)this.input.removeEventListener("input",this.#_);this.replaceChildren(document.createElement("div")),this.input=null,this.#N()}this.style.setProperty("--swatch-background","none");return}let $=_||"#D9D9D9",J=$.includes("var("),Q=J?this.#G($):$,j=this.#Q(Q);if(j!==this.#Z||!this.input){if(this.#Z=j,this.setAttribute("data-type",this.#Z),this.input)this.input.removeEventListener("input",this.#_);if(this.#Z==="color"){let N=this.#j(Q),G=M("input",{type:"color",value:N});if(this.replaceChildren(document.createElement("div"),G),this.input=G,!J)this.input.addEventListener("input",this.#_);this.#N()}else this.replaceChildren(document.createElement("div")),this.input=null,this.#N()}else if(this.#Z==="color"&&this.input){let N=this.#j(Q);if(this.input.value!==N)this.input.value=N}let q=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--swatch-background",q?$:`linear-gradient(${$}, ${$})`)}#N(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",_?"true":"false"),this.input){this.input.disabled=_;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")}#X(_){this.#J=!0,this.setAttribute("background",_.target.value),this.#J=!1}get background(){return this.getAttribute("background")}set background(_){this.setAttribute("background",_)}focus(){if(this.input?.isConnected){this.input.focus();return}HTMLElement.prototype.focus.call(this)}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="background"){if(this.#J){let J=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--swatch-background",J?$:`linear-gradient(${$}, ${$})`);return}this.#q()}else if(_==="alpha")this.#$();else if(_==="disabled"||_==="aria-label"||_==="aria-labelledby"||_==="aria-describedby")this.#N()}get alpha(){return this.getAttribute("alpha")}set alpha(_){if(_===null||_===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",_)}}F("fig-swatch",V0);class D_ extends V0{}F("fig-chit",D_);var I_=["load","error"],V_=["loadstart","progress","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","durationchange","timeupdate","ratechange","resize","volumechange"],M1=[...new Set([...I_,...V_])];class M0 extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#q=this.#c.bind(this);#N=this.#s.bind(this);#X=this.#e.bind(this);#K=this.#l.bind(this);#Y=this.#Q0.bind(this);#R=null;#U=null;#W=null;#O=void 0;#M=null;#B=null;#L=null;#A=null;#I=null;#D=null;#H=null;static get observedAttributes(){return["src","type","alt","upload","loading-indicator","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.#Z}set src(_){if(this.#Z=_||"",_===null||_===void 0||_==="")this.removeAttribute("src");else this.setAttribute("src",_)}get file(){return this.#G}#z(){return this.#j||this.#Z||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#z())return null;if(!this.#_)return null;try{if(typeof this.#_.decode==="function")await this.#_.decode();else if(!this.#_.complete)await new Promise((J,Q)=>{this.#_.addEventListener("load",J,{once:!0}),this.#_.addEventListener("error",Q,{once:!0})})}catch{}let _=this.#_.naturalWidth,Z=this.#_.naturalHeight;if(!(_>0)||!(Z>0))return null;let $=document.createElement("canvas");return $.width=_,$.height=Z,$.getContext("2d").drawImage(this.#_,0,0),$.toDataURL()}connectedCallback(){this.#Z=this.getAttribute("src")||"";let _=this.getAttribute("aspect-ratio");if(_)this.style.setProperty("--fig-media-aspect-ratio",_);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.#C(),this.#E(),this.#T(),this.#y(),this.#P(),this.#f(),this.#w(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#t();this.#$=this.querySelector("fig-input-file[data-generated]"),this.#$?.removeEventListener("change",this.#q),this.#$?.addEventListener("change",this.#q)}disconnectedCallback(){if(this.#$?.removeEventListener("change",this.#q),this.#k(),this.#F(),this.#r(),this.#Q)URL.revokeObjectURL(this.#Q),this.#Q=null;this.#j=null}#F(){if(!this.#_)return;if(M1.forEach((_)=>{this.#_.removeEventListener(_,this.#Y)}),this.#_.tagName==="VIDEO")this.#_.removeEventListener("play",this.#N),this.#_.removeEventListener("pause",this.#X),this.#_.removeEventListener("ended",this.#K)}#T(){if(this.#F(),!this.#_)return;if((this.#_.tagName==="VIDEO"?V_:I_).forEach((Z)=>{this.#_.addEventListener(Z,this.#Y)}),this.#_.tagName!=="VIDEO")return;this.#_.addEventListener("play",this.#N),this.#_.addEventListener("pause",this.#X),this.#_.addEventListener("ended",this.#K)}#S(){return this.mediaKind==="image"&&this.getAttribute("loading-indicator")!=="false"&&this.#J?.hasAttribute("data-generated")&&this.#_?.hasAttribute("data-generated")}#P(){this.#V();let _=this.#z();if(!_||!this.#S()){this.#k();return}if(this.#_?.tagName==="IMG"&&this.#_.complete&&this.#_.currentSrc){this.#k();return}if(this.#W===_)return;this.#k(),this.#W=_,this.#O=this.getAttribute("aria-busy"),this.setAttribute("aria-busy","true"),this.#U=setTimeout(()=>{if(this.#U=null,this.#W!==_||!this.isConnected||!this.#S())return;let Z=document.createElement("fig-spinner");Z.setAttribute("data-generated",""),Z.setAttribute("data-loading-indicator",""),Z.setAttribute("slot","overlay"),Z.setAttribute("size","small"),Z.setAttribute("aria-hidden","true"),this.append(Z),this.#R=Z},150)}#V(){let _=this.#_?.tagName==="IMG"?this.#_:null,Z=_?.currentSrc||_?.getAttribute("src")||this.#z();this.toggleAttribute("loaded",Boolean(Z&&_?.complete&&_.naturalWidth>0))}#k(){if(this.#U!==null)clearTimeout(this.#U),this.#U=null;if(this.#R?.remove(),this.#R=null,this.#W=null,this.#O!==void 0){if(this.#O===null)this.removeAttribute("aria-busy");else this.setAttribute("aria-busy",this.#O);this.#O=void 0}}#C(){if(this.#J?.isConnected)return;let _=this.querySelector(":scope > fig-preview");if(_){this.#J=_;return}let Z=document.createElement("fig-preview");Z.setAttribute("data-generated",""),this.prepend(Z),this.#J=Z}#h(){let _=this.mediaKind==="video"?"video":"img";return this.querySelector(`${_}:not([data-generated])`)}#E(){let _=this.#h();if(_){if(this.#C(),this.#_&&this.#_!==_){if(this.#F(),this.#_.hasAttribute("data-generated"))this.#_.remove()}if(this.#_=_,this.#J&&_.parentElement!==this.#J)this.#J.append(_);this.#T(),this.#f();return}this.#C();let Z=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#_&&this.#_.tagName!==Z){if(this.#F(),this.#_.hasAttribute("data-generated"))this.#_.remove();this.#_=null}if(this.#_)return;if(this.mediaKind==="video"){let $=document.createElement("video");$.setAttribute("data-generated",""),$.className="fig-media-element",$.setAttribute("playsinline",""),$.preload="auto",this.#J.append($),this.#_=$;let J=()=>{if(this.#_?.autoplay)return;try{this.#_.currentTime=0.001}catch{}};this.#_.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.#J.append($),this.#_=$}this.#T()}#f(){if(!this.#_)return;if(this.#_.tagName==="IMG"){if(this.hasAttribute("alt")||this.#_.hasAttribute("data-generated"))this.#_.alt=this.getAttribute("alt")||"";return}if(this.#_.tagName!=="VIDEO")return;["aria-label","aria-labelledby","title"].forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.#_.removeAttribute(_);else this.#_.setAttribute(_,Z)})}#x(){return this.querySelector(":scope > figcaption:not([data-generated])")}#g(){return Array.from(this.querySelectorAll(":scope > figcaption[data-generated]"))}#w(){let _=this.#x(),Z=this.#g();if(_){Z.forEach((j)=>j.remove());return}let $=this.getAttribute("caption")||"";if(!$){Z.forEach((j)=>j.remove());return}let J=Z[0]||document.createElement("figcaption");if(Z.slice(1).forEach((j)=>j.remove()),!J.hasAttribute("data-generated"))J.setAttribute("data-generated","");if(J.textContent!==$)J.textContent=$;let Q=this.querySelector(":scope > fig-media-controls");if(Q)Q.before(J);else if(this.#J?.isConnected)this.#J.after(J);else if(!J.isConnected)this.append(J)}#p(_,Z=!1){if(!this.hasAttribute(_))return Z;return this.getAttribute(_)!=="false"}#y(){if(!this.#_)return;if(!this.#_.hasAttribute("data-generated"))return;let _=this.#z();if(this.#_.getAttribute("src")!==_){if(this.removeAttribute("loaded"),_)this.#_.setAttribute("src",_);else if(this.#_.removeAttribute("src"),this.#_.tagName==="VIDEO")this.#_.load()}if(this.#_.tagName==="IMG"){this.#f(),this.#P();return}let Z=this.getAttribute("poster");if(Z)this.#_.setAttribute("poster",Z);else this.#_.removeAttribute("poster");this.#_.controls=!1,this.#_.removeAttribute("controls"),this.#_.autoplay=this.#p("autoplay",!1),this.#_.loop=this.#p("loop",!1),this.#_.muted=this.#p("muted",!1),this.#_.playsInline=!0,this.#f(),this.#u(),this.#v(),this.#P()}get mediaEl(){return this.#_}#b(){if(this.mediaKind!=="video")return!1;return Boolean(this.#z())}#v(){let _=this.#M||this.querySelector(":scope > fig-media-controls");if(!_)return;if(this.mediaKind!=="video")return;if(this.#b()){if(_.hasAttribute("data-fig-empty-disabled"))_.removeAttribute("disabled"),_.removeAttribute("data-fig-empty-disabled");return}_.setAttribute("disabled",""),_.setAttribute("data-fig-empty-disabled",""),_.playing=!1,_.time=0,_.duration=0}#u(){if(this.mediaKind!=="video"){this.#r();return}let _=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(_){if(this.#M!==_)this.#r(),this.#M=_;this.#o(),this.#v();return}if(this.#p("controls",!1))this.#a();else this.#r()}#a(){let _=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Z=_[0];if(_.slice(1).forEach((J)=>J.remove()),Z){this.#M=Z,this.#o(),this.#v();return}let $=document.createElement("fig-media-controls");$.setAttribute("data-generated",""),this.append($),this.#M=$,this.#o(),this.#v()}#o(){if(!this.#M||!this.#_)return;if(this.#B===this.#_&&this.#L===this.#M){this.#v();return}this.#i();let _=this.#M,Z=this.#_;this.#B=Z,this.#L=_;let $=null,J=()=>{if(this.#v(),!this.#b())return;if(_.playing=!Z.paused&&!Z.ended,Number.isFinite(Z.duration))_.duration=Z.duration;if($!==null)if(Math.abs(Z.currentTime-$)<0.25)$=null;else return;_.time=Z.currentTime||0},Q=()=>{if(!this.#b())return;let N=Z.play?.();if(N&&typeof N.catch==="function")N.catch(()=>{})},j=()=>Z.pause?.(),q=(N)=>{if(!this.#b())return;let G=Number(N?.detail?.time);if(!Number.isFinite(G))return;$=G;try{Z.currentTime=G}catch{}};this.#A=J,this.#I=Q,this.#D=j,this.#H=q,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),_.addEventListener("play",Q),_.addEventListener("pause",j),_.addEventListener("seek",q),J()}#i(){let _=this.#B,Z=this.#L;if(_&&this.#A)_.removeEventListener("play",this.#A),_.removeEventListener("pause",this.#A),_.removeEventListener("ended",this.#A),_.removeEventListener("timeupdate",this.#A),_.removeEventListener("loadedmetadata",this.#A),_.removeEventListener("durationchange",this.#A),_.removeEventListener("seeked",this.#A);if(Z){if(this.#I)Z.removeEventListener("play",this.#I);if(this.#D)Z.removeEventListener("pause",this.#D);if(this.#H)Z.removeEventListener("seek",this.#H)}this.#B=null,this.#L=null,this.#A=null,this.#I=null,this.#D=null,this.#H=null}#r(){this.#i(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((_)=>{_.remove()}),this.#M=null}toggle(){if(!this.#_||this.mediaKind!=="video")return;if(this.#_.paused||this.#_.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#_)return;let _=this.#_.play();if(_&&typeof _.catch==="function")_.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#_)return;this.#_.pause()}#t(){let _=document.createElement("fig-input-file");_.setAttribute("data-generated",""),_.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),_.setAttribute("variant","overlay");let Z=this.getAttribute("label")||"Upload";if(_.setAttribute("label",this.#Z?"Replace":Z),this.#G?.name)_.setAttribute("filename",this.#G.name);else if(this.#Z)_.setAttribute("url",this.#Z);_.addEventListener("change",this.#q),this.#C(),this.#J.append(_),this.#$=_}#m(){if(this.#$)this.#$.removeEventListener("change",this.#q),this.#$.remove(),this.#$=null}#c(_){if(_.target!==this.#$)return;let Z=_.detail?.files?.[0],$=_.detail?.cleared===!0;if(!Z){if(this.#Q)URL.revokeObjectURL(this.#Q),this.#Q=null;if(this.#G=null,this.#j=null,$)this.src="";if(this.#y(),this.#$){let J=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Z?"Replace":J),this.#$.removeAttribute("filename"),this.#Z)this.#$.setAttribute("url",this.#Z);else this.#$.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#Q)URL.revokeObjectURL(this.#Q);if(this.#G=Z,this.#Q=URL.createObjectURL(Z),this.#j=this.#Q,this.#y(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Z,src:this.#Q}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#$)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",Z.name),this.#$.setAttribute("label","Replace")}#d(_){if(!this.#_)return;this.dispatchEvent(new CustomEvent(_,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Z||"",currentTime:this.#_.currentTime,duration:this.#_.duration}}))}#Q0(_){let Z=this.#_;if(!Z||_.currentTarget!==Z)return;if(Z.tagName==="IMG"&&(_.type==="load"||_.type==="error"))this.toggleAttribute("loaded",_.type==="load"),this.#k();let $={src:this.#z(),media:Z,originalEvent:_};if(Z.tagName==="VIDEO")$.currentTime=Z.currentTime,$.duration=Z.duration,$.readyState=Z.readyState,$.networkState=Z.networkState,$.error=Z.error;if(this.dispatchEvent(new CustomEvent(_.type,{bubbles:!0,cancelable:!1,composed:!0,detail:$})),Z.tagName==="IMG"&&_.type==="load"||Z.tagName==="VIDEO"&&_.type==="loadeddata")this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,composed:!0,detail:{src:$.src,file:this.#G,media:Z}}))}#s(){this.#d("play")}#e(){this.#d("pause")}#l(){this.#d("ended")}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="src"){let J=$||"",Q=J&&(J===this.#j||J===this.#Q);if(this.#Z=J,this.#Q&&!Q)URL.revokeObjectURL(this.#Q),this.#Q=null,this.#j=null,this.#G=null;if(this.#y(),this.#$){let j=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Z?"Replace":j),this.#Z)if(this.#G?.name)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",this.#G.name);else this.#$.setAttribute("url",this.#Z),this.#$.removeAttribute("filename");else this.#$.removeAttribute("url"),this.#$.removeAttribute("filename")}}if(_==="type"){if(this.#E(),this.#y(),this.#$)this.#$.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(_))this.#f();if(_==="upload"){let J=$!==null&&$!=="false";if(J&&!this.#$)this.#t();else if(!J)this.#m()}if(_==="loading-indicator")this.#P();if(_==="aspect-ratio")if($)this.style.setProperty("--fig-media-aspect-ratio",$);else this.style.removeProperty("--fig-media-aspect-ratio");if(_==="fit")if($)this.style.setProperty("--fig-media-fit",$);else this.style.removeProperty("--fig-media-fit");if(_==="label"&&this.#$){let J=this.getAttribute("label")||"Upload";this.#$.setAttribute("label",this.#Z?"Replace":J)}if(["controls","autoplay","loop","muted","poster"].includes(_))this.#y();if(_==="caption")this.#w()}}F("fig-media",M0);class C_ extends M0{get mediaKind(){return"image"}}F("fig-image",C_);class P_ extends M0{get mediaKind(){return"video"}}F("fig-video",P_);class S_ extends HTMLElement{static get observedAttributes(){return["src","alt","label","text","sublabel","selected","disabled","full","size","direction","aspect-ratio","fit","label-line-clamp","label-overflow"]}#Z=null;#_=null;#J=null;#$=null;#Q=!1;#j=new MutationObserver((_)=>{if(!_.some(($)=>[...$.addedNodes,...$.removedNodes].some((J)=>J instanceof Element&&(J.matches("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])")||J.querySelector("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])"))))||!this.isConnected)return;this.#R(),this.#O()});connectedCallback(){this.#j.observe(this,{childList:!0,subtree:!0}),this.#R(),this.#O()}disconnectedCallback(){this.#j.disconnect()}attributeChangedCallback(){if(!this.isConnected)return;this.#R(),this.#O()}#G(){return this.getAttribute("label")??this.getAttribute("text")??""}#q(){return this.getAttribute("sublabel")??""}#N(){return this.getAttribute("label-line-clamp")==="2"?"2":"1"}#X(){return Boolean(this.getAttribute("src"))}#K(){return this.querySelector(":scope > fig-image:not([data-generated]), :scope > fig-media:not([data-generated]), :scope > fig-preview:not([data-generated])")}#Y(){this.querySelectorAll(":scope > .fig-card-link").forEach((_)=>{_.querySelectorAll(":scope > .fig-card-media").forEach((Z)=>{while(Z.firstChild)_.insertBefore(Z.firstChild,Z);Z.remove()});while(_.firstChild)this.insertBefore(_.firstChild,_);_.remove()})}#R(){if(this.#Y(),!this.#X()){this.#U();return}let _=this.#K();if(this.#Q=Boolean(_),_)this.querySelectorAll(":scope > [data-generated]:not(fig-footer)").forEach(($)=>$.remove()),this.#_=null;if(!this.#Q){if(this.#_=this.querySelector(":scope > fig-image[data-generated]")||null,!this.#_)this.querySelectorAll(":scope > fig-image, :scope > fig-media, :scope > fig-preview").forEach(($)=>{if($.hasAttribute("data-generated"))$.remove()}),this.#_=document.createElement("fig-image"),this.#_.setAttribute("data-generated",""),this.#_.setAttribute("full",""),this.#_.setAttribute("size","auto"),this.prepend(this.#_)}if(!Boolean(this.#G()||this.#q())){this.querySelector(":scope > fig-footer[data-generated]")?.remove(),this.#Z=null,this.#J=null,this.#$=null;return}if(!this.#Z||!this.#Z.isConnected){if(this.#Z=this.querySelector(":scope > fig-footer[data-generated]"),!this.#Z)this.#Z=document.createElement("fig-footer"),this.#Z.setAttribute("data-generated",""),this.appendChild(this.#Z)}if(!this.#J||!this.#J.isConnected){if(this.#J=this.#Z.querySelector(":scope > .fig-card-label[data-generated]"),!this.#J)this.#J=document.createElement("label"),this.#J.className="fig-card-label",this.#J.setAttribute("data-generated",""),this.#Z.appendChild(this.#J)}if(!this.#$||!this.#$.isConnected){if(this.#$=this.#Z.querySelector(":scope > .fig-card-sublabel[data-generated]"),!this.#$)this.#$=document.createElement("label"),this.#$.className="fig-card-sublabel",this.#$.setAttribute("data-generated",""),this.#J.after(this.#$)}}#U(){if(this.#Y(),this.querySelectorAll(":scope > [data-generated]").forEach((Z)=>Z.remove()),this.#_=null,this.#Q=!0,this.#Z=null,this.#J=null,this.#$=null,!this.#G()&&!this.#q())return;this.#Z=document.createElement("fig-footer"),this.#Z.setAttribute("data-generated",""),this.#J=document.createElement("label"),this.#J.className="fig-card-label",this.#J.setAttribute("data-generated",""),this.#Z.appendChild(this.#J);let _=this.#q();if(this.#$=null,_)this.#$=document.createElement("label"),this.#$.className="fig-card-sublabel",this.#$.setAttribute("data-generated",""),this.#Z.appendChild(this.#$);this.appendChild(this.#Z)}#W(){let _=this.getAttribute("label-overflow")==="fade";this.querySelectorAll(":scope > fig-footer > :is(.fig-card-label, .fig-card-sublabel)").forEach((Z)=>{Z.classList.toggle("fig-overflow-fade",_),Z.classList.toggle("fig-overflow-fade-horizontal",_)})}#O(){if(!this.#X()){this.#M();return}let _=T(this,"disabled"),Z=this.#G(),$=this.#q(),J=this.#N();this.style.setProperty("--fig-card-label-line-clamp",J),this.setAttribute("role","group");let Q=[Z,$].filter(Boolean).join(", ");if(Q)this.setAttribute("aria-label",Q);else this.removeAttribute("aria-label");if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#_&&!this.#Q){let j=this.getAttribute("src"),q=this.getAttribute("alt"),N=this.getAttribute("aspect-ratio")||"1/1",G=this.getAttribute("fit")||"contain",K=q!=null?q:"";if(j)this.#_.setAttribute("src",j);else this.#_.removeAttribute("src");this.#_.setAttribute("alt",K),this.#_.setAttribute("aspect-ratio",N),this.#_.setAttribute("fit",G),this.#_.setAttribute("full",""),this.#_.setAttribute("size","auto")}if(this.#J)this.#J.textContent=Z,this.#J.hidden=!Z;if(this.#$)this.#$.textContent=$,this.#$.hidden=!$;if(this.#Z)this.#Z.hidden=!Z&&!$;this.#W()}#M(){let _=T(this,"disabled"),Z=this.#G(),$=this.#q();this.style.setProperty("--fig-card-label-line-clamp",this.#N()),this.setAttribute("role","group");let J=[Z,$].filter(Boolean).join(", ");if(J)this.setAttribute("aria-label",J);else this.removeAttribute("aria-label");if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#J)this.#J.textContent=Z,this.#J.hidden=!Z;if(this.#$)this.#$.textContent=$;this.#W()}}F("fig-card",S_);class E_ extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=!1;#j=!1;static get observedAttributes(){return["playing","duration","time","disabled"]}connectedCallback(){this.#G(),this.#K(),this.#Y(),this.#q()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(_){if(_)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let _=Number(this.getAttribute("duration"));return Number.isFinite(_)&&_>=0?_:0}set duration(_){let Z=Number(_);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("duration");return}this.setAttribute("duration",String(Z))}get time(){let _=Number(this.getAttribute("time"));return Number.isFinite(_)&&_>=0?_:0}set time(_){let Z=Number(_);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("time");return}this.setAttribute("time",String(Z))}get disabled(){return T(this,"disabled")}set disabled(_){if(_)this.setAttribute("disabled","");else this.removeAttribute("disabled")}attributeChangedCallback(_){if(!this.#j)return;if(_==="playing")this.#K();if(_==="duration"||_==="time")this.#Y();if(_==="disabled")this.#q()}#G(){if(this.#j)return;if(this.#j=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");let _=document.createElement("fig-tooltip");_.setAttribute("text","Play");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Play"),Z.append(b("play")),_.append(Z),Z.addEventListener("click",(j)=>{j.preventDefault(),j.stopPropagation(),this.toggle()});let $=document.createElement("fig-slider");$.setAttribute("text","false"),$.setAttribute("min","0"),$.setAttribute("max",String(this.duration)),$.setAttribute("step","1"),$.setAttribute("value",String(this.time)),$.setAttribute("full",""),$.setAttribute("aria-label","Seek"),$.setAttribute("aria-valuetext",this.#X(this.time,this.duration));let J=document.createElement("span");J.className="fig-media-controls-time",J.textContent=this.#N(this.time);let Q=(j)=>{if(this.disabled){j.preventDefault?.(),j.stopPropagation();return}let q=j.currentTarget,N=Number(q?.value);if(!Number.isFinite(N))return;this.#Q=!0,this.setAttribute("time",String(N)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:N}})),requestAnimationFrame(()=>{this.#Q=!1})};$.addEventListener("input",Q),$.addEventListener("change",Q),this.append(_,$,J),this.#Z=Z,this.#_=_,this.#J=$,this.#$=J,this.#q()}#q(){let _=this.disabled;if(this.setAttribute("aria-disabled",_?"true":"false"),this.#Z)if(_)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#J)if(_)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}#N(_){if(!Number.isFinite(_)||_<0)_=0;let Z=Math.floor(_),$=Math.floor(Z/60),J=Z%60;return`${String($).padStart(2,"0")}:${String(J).padStart(2,"0")}`}#X(_,Z=0){let $=this.#N(_);if(!Number.isFinite(Z)||Z<=0)return $;return`${$} of ${this.#N(Z)}`}#K(){if(!this.#Z)return;let _=this.playing;this.#Z.setAttribute("aria-label",_?"Pause":"Play"),this.#_?.setAttribute("text",_?"Pause":"Play");let Z=this.#Z.querySelector("fig-icon");if(Z)Z.setAttribute("name",_?"pause":"play")}#Y(){if(!this.#J)return;let _=this.duration;if(Number(this.#J.getAttribute("max"))!==_)this.#J.setAttribute("max",String(_));let Z=this.time;if(!this.#Q)this.#J.setAttribute("value",String(Z));if(this.#J.setAttribute("aria-valuetext",this.#X(Z,_)),this.#$)this.#$.textContent=this.#N(Z)}toggle(){if(this.disabled)return;let _=!this.playing;this.playing=_,this.dispatchEvent(new CustomEvent(_?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:_}}))}play(){if(this.disabled||this.playing)return;this.toggle()}pause(){if(this.disabled||!this.playing)return;this.toggle()}}F("fig-media-controls",E_);class C0 extends HTMLElement{static#Z=0;static observedAttributes=["url","polarization","progress"];#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#q=null;#N=null;#X=[];#K=0;#Y=0;connectedCallback(){if(!this.#_)this.#R();this.#U(),this.#W()}disconnectedCallback(){if(this.#D(),this.#G?.disconnect(),this.#G=null,this.#Y)cancelAnimationFrame(this.#Y);this.#Y=0}attributeChangedCallback(_,Z,$){if(Z===$||!this.#_)return;if(_==="url")this.#W();if(_==="polarization")this.#H();if(_==="progress")this.#I()}#R(){this.#_=document.createElement("div"),this.#_.className="fig-audio-waveform-surface",this.#_.setAttribute("aria-hidden","true"),this.#J=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.#J.setAttribute("aria-hidden","true"),this.#J.setAttribute("preserveAspectRatio","none");let _=document.createElementNS("http://www.w3.org/2000/svg","defs"),Z=document.createElementNS("http://www.w3.org/2000/svg","clipPath"),$=`fig-audio-waveform-progress-${++C0.#Z}`;Z.id=$,Z.setAttribute("clipPathUnits","userSpaceOnUse"),this.#j=document.createElementNS("http://www.w3.org/2000/svg","rect"),Z.append(this.#j),_.append(Z),this.#$=document.createElementNS("http://www.w3.org/2000/svg","path"),this.#$.classList.add("fig-audio-waveform-path"),this.#Q=document.createElementNS("http://www.w3.org/2000/svg","path"),this.#Q.classList.add("fig-audio-waveform-progress"),this.#Q.setAttribute("clip-path",`url(#${$})`),this.#J.append(_,this.#$,this.#Q),this.#_.appendChild(this.#J),this.replaceChildren(this.#_),this.#U()}#U(){if(this.#G||!this.#J)return;this.#G=new ResizeObserver(()=>this.#H()),this.#G.observe(this.#J)}#W(){let _=this.getAttribute("url");if(!_){this.#B();return}this.#O(async(Z)=>{let $=await fetch(_,{signal:Z});if(!$.ok)throw Error(`Audio request failed: ${$.status}`);return $.arrayBuffer()})}async#O(_){this.#D();let Z=++this.#K,$=new AbortController;this.#q=$,this.setAttribute("data-waveform-state","loading"),this.setAttribute("aria-busy","true"),this.#X=[],this.#H();let J=null;try{let Q=await _($.signal);if(Z!==this.#K||!this.isConnected)return;let j=window.AudioContext||window.webkitAudioContext;if(!j)throw Error("Web Audio is unavailable");J=new j,this.#N=J;let q=await J.decodeAudioData(Q);if(Z!==this.#K||!this.isConnected)return;this.#X=this.#M(q),this.setAttribute("data-waveform-state","ready"),this.#H()}catch(Q){if(Z!==this.#K||Q?.name==="AbortError")return;this.#X=Array(256).fill(0),this.setAttribute("data-waveform-state","unavailable"),this.#H()}finally{if(J)try{await J.close()}catch{}if(this.#N===J)this.#N=null;if(this.#q===$)this.#q=null;if(Z===this.#K)this.removeAttribute("aria-busy")}}#M(_){let $=Array(256).fill(0),J=_.numberOfChannels,Q=_.length,j=Math.max(1,Math.ceil(Q/500000)),q=0;for(let K=0;K<256;K+=1){let X=Math.floor(K/256*Q),Y=Math.max(X+1,Math.floor((K+1)/256*Q)),W=0,R=0;for(let O=0;O<J;O+=1){let H=_.getChannelData(O);for(let A=X;A<Y;A+=j){let z=H[A]||0;if(!Number.isFinite(z))continue;W+=z*z,R+=1}}let L=R>0?Math.sqrt(W/R):0;$[K]=L,q=Math.max(q,L)}if(!Number.isFinite(q)||q<=0)return $.fill(0);let N=Math.min(...$),G=q-N;if(!Number.isFinite(G)||G<=Number.EPSILON)return $.fill(0);return $.map((K)=>{let X=(K-N)/G;return Number.isFinite(X)?X:0})}#B(){this.#D(),this.#X=[],this.removeAttribute("data-waveform-state"),this.removeAttribute("aria-busy"),this.#H()}#L(_){let Z=Number.parseFloat(this.getAttribute("polarization")),$=Number.isFinite(Z)?Math.max(0,Math.min(Z,4)):1.5;return Math.max(0,Math.min(1,0.5+(_-0.5)*$))}#A(){let _=Number.parseFloat(this.getAttribute("progress"));return Number.isFinite(_)?Math.max(0,Math.min(_,1)):0}#I(){if(!this.#J||!this.#j)return;let _=this.#J.viewBox.baseVal,Z=this.#J.getBoundingClientRect(),$=_.width||Math.max(1,Math.round(Z.width)),J=_.height||Math.max(1,Math.round(Z.height));this.#j.setAttribute("x","0"),this.#j.setAttribute("y","0"),this.#j.setAttribute("width",String($*this.#A())),this.#j.setAttribute("height",String(J))}#D(){if(this.#K+=1,this.#q?.abort(),this.#q=null,this.#N){try{this.#N.close()}catch{}this.#N=null}}#H(){if(this.#Y)return;this.#Y=requestAnimationFrame(()=>{this.#Y=0,this.#z()})}#z(){if(!this.#J||!this.#$||!this.#Q||!this.#j)return;let _=this.#J.getBoundingClientRect(),Z=Math.max(1,Math.round(_.width)),$=Math.max(1,Math.round(_.height));if(this.#J.setAttribute("viewBox",`0 0 ${Z} ${$}`),this.#I(),this.#X.length===0){this.#$.setAttribute("d",""),this.#Q.setAttribute("d","");return}let J=Math.min(this.#X.length,Math.max(16,Math.floor(Z/3))),Q=Z/J,j=Number.parseFloat(getComputedStyle(this).getPropertyValue("--fig-audio-waveform-stroke-width")),q=Number.isFinite(j)&&j>0?j:2,N=Math.max(0.5,Math.min(q,Q*0.75)),G=N/2,K=$/2,X=Math.max(2,$-12),Y=[];for(let R=0;R<J;R+=1){let L=Math.min(this.#X.length-1,Math.floor(R/J*this.#X.length)),O=this.#L(this.#X[L]),H=Math.max(N,O*X),A=(R+0.5)*Q,z=K-H/2,U=K+H/2,I=A-G,V=A+G;Y.push(`M ${A} ${z} Q ${V} ${z} ${V} ${z+G} V ${U-G} Q ${V} ${U} ${A} ${U} Q ${I} ${U} ${I} ${U-G} V ${z+G} Q ${I} ${z} ${A} ${z} Z`)}let W=Y.join(" ");this.#$.setAttribute("d",W),this.#Q.setAttribute("d",W)}}F("fig-audio-waveform",C0);class f_ extends HTMLElement{#Z="";#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#q=null;#N=null;#X=null;static get observedAttributes(){return["src","autoplay","controls","muted","loop"]}connectedCallback(){this.#Z=this.getAttribute("src")||"",this.#Y(),this.#R(),this.#W(),this.#M(),this.#I()}disconnectedCallback(){this.#H()}get src(){return this.#Z}set src(_){if(_===null||_===void 0||_==="")this.removeAttribute("src");else this.setAttribute("src",String(_))}get audioEl(){return this.#_}#K(_){return this.hasAttribute(_)&&this.getAttribute(_)!=="false"}#Y(){let _=this.querySelector(":scope > audio:not([data-generated])");if(_){this.#_=_;return}let Z=Array.from(this.querySelectorAll(":scope > audio[data-generated]")),$=Z[0]||document.createElement("audio");if(Z.slice(1).forEach((J)=>J.remove()),!$.hasAttribute("data-generated"))$.setAttribute("data-generated",""),$.preload="metadata",this.append($);this.#_=$}#R(){let _=this.querySelector(":scope > fig-audio-waveform:not([data-generated])");if(_)this.querySelectorAll(":scope > fig-audio-waveform[data-generated]").forEach((Z)=>Z.remove()),this.#J=_;else{let Z=Array.from(this.querySelectorAll(":scope > fig-audio-waveform[data-generated]")),$=Z[0]||document.createElement("fig-audio-waveform");if(Z.slice(1).forEach((J)=>J.remove()),!$.hasAttribute("data-generated"))$.setAttribute("data-generated",""),$.setAttribute("full",""),this.prepend($);this.#J=$}this.#U()}#U(){if(!this.#J)return;if(this.#Z)this.#J.setAttribute("url",this.#Z);else this.#J.removeAttribute("url")}#W(){if(!this.#_)return;if(this.#_.getAttribute("src")!==this.#Z)if(this.#Z)this.#_.setAttribute("src",this.#Z);else this.#_.removeAttribute("src"),this.#_.load?.();this.#_.controls=!1,this.#_.removeAttribute("controls"),this.#_.autoplay=this.#K("autoplay"),this.#_.muted=this.#K("muted"),this.#_.loop=this.#K("loop"),this.#U(),this.#L()}#O(){return Boolean(this.#Z)}#M(){let _=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(_){if(this.#$!==_)this.#z(),this.#$=_;this.#D(),this.#L();return}if(this.#K("controls"))this.#B();else this.#z()}#B(){let _=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Z=_[0]||document.createElement("fig-media-controls");if(_.slice(1).forEach(($)=>$.remove()),!Z.hasAttribute("data-generated"))Z.setAttribute("data-generated",""),this.append(Z);this.#$=Z,this.#D(),this.#L()}#L(){if(!this.#$)return;if(this.#O()){if(this.#$.hasAttribute("data-fig-empty-disabled"))this.#$.removeAttribute("disabled"),this.#$.removeAttribute("data-fig-empty-disabled");return}this.#$.setAttribute("disabled",""),this.#$.setAttribute("data-fig-empty-disabled",""),this.#$.removeAttribute("playing"),this.#$.setAttribute("time","0"),this.#$.setAttribute("duration","0"),this.#A(0,0)}#A(_,Z){if(!this.#J)return;let $=Number.isFinite(_)&&Number.isFinite(Z)&&Z>0?Math.max(0,Math.min(_/Z,1)):0;this.#J.setAttribute("progress",String($))}#I(){let _=this.#_;if(!_)return;let Z=Number.isFinite(_.currentTime)?_.currentTime:0,$=Number.isFinite(_.duration)?_.duration:0;if(this.#$)this.#$.toggleAttribute("playing",!_.paused&&!_.ended),this.#$.setAttribute("time",String(Z)),this.#$.setAttribute("duration",String($));this.#A(Z,$)}#D(){if(!this.#$||!this.#_)return;if(this.#Q===this.#_&&this.#j===this.#$){this.#L(),this.#I();return}this.#H();let _=this.#$,Z=this.#_,$=null,J=()=>{if(this.#L(),!this.#O())return;let N=Number.isFinite(Z.duration)?Z.duration:0,G=Number.isFinite(Z.currentTime)?Z.currentTime:0;if(_.toggleAttribute("playing",!Z.paused&&!Z.ended),_.setAttribute("duration",String(N)),$!==null)if(Math.abs(G-$)<0.25)$=null;else{this.#A(G,N);return}_.setAttribute("time",String(G)),this.#A(G,N)},Q=()=>this.play(),j=()=>this.pause(),q=(N)=>{if(!this.#O())return;let G=Number(N?.detail?.time);if(!Number.isFinite(G))return;$=G;try{Z.currentTime=G}catch{}this.#A(G,Z.duration)};this.#Q=Z,this.#j=_,this.#G=J,this.#q=Q,this.#N=j,this.#X=q,["play","pause","ended","timeupdate","loadedmetadata","durationchange","seeked","emptied"].forEach((N)=>Z.addEventListener(N,J)),_.addEventListener("play",Q),_.addEventListener("pause",j),_.addEventListener("seek",q),J()}#H(){let _=this.#Q,Z=this.#j;if(_&&this.#G)["play","pause","ended","timeupdate","loadedmetadata","durationchange","seeked","emptied"].forEach(($)=>_.removeEventListener($,this.#G));if(Z){if(this.#q)Z.removeEventListener("play",this.#q);if(this.#N)Z.removeEventListener("pause",this.#N);if(this.#X)Z.removeEventListener("seek",this.#X)}this.#Q=null,this.#j=null,this.#G=null,this.#q=null,this.#N=null,this.#X=null}#z(){this.#H(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((_)=>_.remove()),this.#$=null}play(){if(!this.#_||!this.#O())return;let _=this.#_.play?.();if(_&&typeof _.catch==="function")_.catch(()=>{})}pause(){this.#_?.pause?.()}toggle(){if(!this.#_||!this.#O())return;if(this.#_.paused||this.#_.ended)this.play();else this.pause()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="src")this.#Z=$||"";if(!this.isConnected)return;if(_==="controls")this.#M();if(["src","autoplay","muted","loop"].includes(_))this.#W(),this.#I()}}F("fig-audio",f_);var s=[".png",".jpg",".jpeg",".gif",".webp",".svg",".avif"],r=[".mp3",".wav",".aac",".m4a",".ogg",".flac"],Q0=[".mp4",".webm",".mov",".m4v",".avi",".mkv",".ogv",".mpeg",".mpg",".3gp"];class x_ extends HTMLElement{static observedAttributes=["accepts","preview","label","disabled","multiple","variant","url","filename"];#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#q=null;#N=null;#X=null;#K=!1;#Y=null;#R=!1;get files(){return this.#j}get#U(){let _=this.getAttribute("filename");if(_)return _;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.#j&&this.#j.length>0){if(this.#j.length===1)return this.#j[0].name;return`${this.#j.length} files`}return this.#U}get#W(){return this.getAttribute("accepts")||""}get#O(){return this.hasAttribute("preview")&&this.getAttribute("preview")!=="false"}get#M(){return this.getAttribute("preview")?.toLowerCase()==="large"}#B(_,Z){let $=_.toLowerCase();return Z.some((J)=>$.endsWith(J))}#L(_,Z,$){return this.#B(_.name,Z)||_.type.toLowerCase().startsWith($)}#A(){if(this.#j?.[0]){if(this.#L(this.#j[0],r,"audio/"))return"Upload audio";if(this.#L(this.#j[0],s,"image/"))return"Upload image"}if(this.#B(this.#U,r))return"Upload audio";if(this.#B(this.#U,s))return"Upload image";let _=this.#W.split(",").map((Z)=>Z.trim().toLowerCase()).filter(Boolean).map((Z)=>{if(Z.startsWith("audio/")||r.includes(Z))return"audio";if(Z.startsWith("image/")||s.includes(Z))return"image";return"file"});if(_.length>0&&_.every((Z)=>Z==="audio"))return"Upload audio";if(_.length>0&&_.every((Z)=>Z==="image"))return"Upload image";return"Upload file"}#I(){if(this.#j?.length)return this.#L(this.#j[0],s,"image/");return!!this.getAttribute("url")&&this.#B(this.#U,s)}#D(){if(this.#j?.length)return this.#L(this.#j[0],r,"audio/");return!!this.getAttribute("url")&&this.#B(this.#U,r)}#H(){let _=this.#j?.[0];if(_){if(this.#L(_,Q0,"video/"))return"video";if(this.#L(_,s,"image/"))return"image";return null}if(this.#B(this.#U,Q0))return"video";if(this.#B(this.#U,s))return"image";let Z=this.#W.split(",").map(($)=>$.trim().toLowerCase()).filter(Boolean).map(($)=>{if($.startsWith("video/")||Q0.includes($))return"video";if($.startsWith("image/")||s.includes($))return"image";return null});if(Z.length>0&&Z.every(($)=>$===Z[0]))return Z[0];return null}#z(){if(this.#j&&this.#j.length>0){let _=Array.from(this.#j);if(this.#O&&_.every((Z)=>this.#L(Z,Q0,"video/")))return"video";if(_.every((Z)=>this.#L(Z,r,"audio/")))return"audio";if(_.every((Z)=>this.#L(Z,s,"image/")))return"image"}if(this.#O&&this.#B(this.#U,Q0))return"video";if(this.#B(this.#U,r))return"audio";if(this.#B(this.#U,s))return"image";return"upload"}connectedCallback(){this.#u(),this.addEventListener("dragover",this.#V),this.addEventListener("dragleave",this.#k),this.addEventListener("drop",this.#C)}disconnectedCallback(){this.#Z?.removeEventListener("change",this.#S),this.#J?.removeEventListener("click",this.#P),this.#h(),this.#E(),this.removeEventListener("dragover",this.#V),this.removeEventListener("dragleave",this.#k),this.removeEventListener("drop",this.#C)}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#R)return;this.#u()}clear(){if(this.#j=null,this.#Z)this.#Z.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#u(),this.#F({cleared:!0})}#F(_={}){let Z={files:this.#j,..._};this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0}))}#T(){this.#R=!0,this.removeAttribute("url"),this.removeAttribute("filename"),this.#R=!1}#S=()=>{if(this.#Z.files.length>0)this.#j=this.#Z.files,this.#T(),this.#u(),this.#F()};#P=(_)=>{_.stopPropagation(),this.clear()};#V=(_)=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(_.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#Q)this.#Q.dataset.prevText=this.#Q.textContent,this.#Q.textContent="Drop file"}};#k=()=>{if(this.removeAttribute("dragover"),this.#Q&&this.#Q.dataset.prevText!==void 0)this.#Q.textContent=this.#Q.dataset.prevText,delete this.#Q.dataset.prevText};#C=(_)=>{if(_.preventDefault(),this.removeAttribute("dragover"),this.#Q&&this.#Q.dataset.prevText!==void 0)this.#Q.textContent=this.#Q.dataset.prevText,delete this.#Q.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#W,$=Array.from(_.dataTransfer.files);if(Z){let Q=Z.split(",").map((j)=>j.trim().toLowerCase());$=$.filter((j)=>{let q="."+j.name.split(".").pop().toLowerCase(),N=j.type.toLowerCase();return Q.some((G)=>G===q||G===N||G.endsWith("/*")&&N.startsWith(G.slice(0,-1)))})}if(!this.hasAttribute("multiple")||this.getAttribute("multiple")==="false")$=$.slice(0,1);if($.length===0)return;let J=new DataTransfer;if($.forEach((Q)=>J.items.add(Q)),this.#j=J.files,this.#Z)this.#Z.files=J.files;this.#T(),this.#u(),this.#F()};#h(){if(!this.#G)return;URL.revokeObjectURL(this.#G),this.#G=null}#E(){if(this.#q?.pause(),this.#Y)URL.revokeObjectURL(this.#Y),this.#Y=null;this.#q=null,this.#N=null,this.#X=null,this.#K=!1,this.removeAttribute("data-audio-playing")}#f(_){this.#K=_,this.#N?.setAttribute("name",_?"pause":"play"),this.toggleAttribute("data-audio-playing",_),this.#Q?.toggleAttribute("selected",_),this.#Q?.setAttribute("aria-label",_?"Pause audio":"Play audio")}#x(){if(!this.#q||!this.#X)return;let _=this.#q.duration,Z=this.#q.currentTime,$=Number.isFinite(_)&&_>0&&Number.isFinite(Z)?Math.max(0,Math.min(Z/_,1)):0;this.#X.setAttribute("progress",String($))}#g=(_)=>{if(_.preventDefault(),!this.#q||this.#Q?.hasAttribute("disabled"))return;if(this.#K){this.#q.pause();return}let Z=this.#q.play();if(Z&&typeof Z.catch==="function")Z.catch(()=>this.#f(!1))};#w(){let _=document.createElement("audio");if(_.hidden=!0,_.preload="metadata",this.#j?.[0])this.#Y=URL.createObjectURL(this.#j[0]),_.src=this.#Y;else _.src=this.getAttribute("url")||"";_.addEventListener("play",()=>this.#f(!0)),_.addEventListener("pause",()=>this.#f(!1)),_.addEventListener("ended",()=>{this.#f(!1),this.#X?.setAttribute("progress","0")}),_.addEventListener("timeupdate",()=>this.#x()),_.addEventListener("durationchange",()=>this.#x()),this.#q=_,this.#X=document.createElement("fig-audio-waveform"),this.#X.className="fig-input-file-audio-waveform",this.#X.setAttribute("url",_.src),this.#X.setAttribute("polarization","3"),this.#X.setAttribute("progress","0"),this.#Q?.append(this.#X),this.#Q?.addEventListener("click",this.#g),this.#f(!1),this.append(_)}#p(){let _=document.createElement("fig-swatch"),Z=this.#j?.[0],$=Z?this.#G=URL.createObjectURL(Z):this.getAttribute("url")||"";return _.setAttribute("background",`url(${JSON.stringify($)})`),_.setAttribute("slot","prepend"),_}#y(_){let Z=document.createElement("fig-icon");Z.setAttribute("slot","prepend");let $=document.createElement("label");return $.textContent=String(_),Z.append($),Z}#b=(_)=>{if(_.target!==_.currentTarget){_.stopPropagation();return}_.stopPropagation();let $=_.currentTarget.file;if($){let J=new DataTransfer;J.items.add($),this.#j=J.files,this.#T(),this.#u(),this.#F();return}this.#j=null,this.#T(),this.#u(),this.#F({cleared:!0})};#v(_,Z){let $=document.createElement(_==="video"?"fig-video":"fig-image");$.setAttribute("upload",""),$.setAttribute("full",""),$.setAttribute("checkerboard","");let J=this.#j?.[0],Q=J?this.#G=URL.createObjectURL(J):this.getAttribute("url")||"";if(Q)$.setAttribute("src",Q);$.addEventListener("change",this.#b),this.append($);let j=$.querySelector(":scope > fig-preview > fig-input-file[data-generated]");if(Z)j?.setAttribute("disabled","");this.setAttribute("data-previewing","large")}#u(){let _=this.#W,Z=this.getAttribute("label"),$=Z?.trim()?Z:this.#A(),J=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Q=this.hasAttribute("multiple")&&this.getAttribute("multiple")!=="false",j=this.getAttribute("variant")||"property",q=this.#j&&this.#j.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename"),N=this.#O&&Q&&(this.#j?.length??0)>1,G=!N&&this.#O&&this.#I(),K=!N&&this.#O&&this.#D();this.#h(),this.#E(),this.replaceChildren(),this.#Z=null,this.#Q=null,this.#J=null,this.#$=null,this.removeAttribute("data-previewing");let X=this.#M&&!N?this.#H():null;if(X){this.#v(X,J);return}if(q){let Y=this.value,W=Q&&this.#j?.length?Array.from(this.#j,(U)=>U.name).join(", "):"",R=W?W:K?Y:_?`Accepts ${_.split(",").map((U)=>U.trim()).join(", ")}`:"";if(this.#Q=document.createElement("fig-button"),this.#Q.setAttribute("variant",j),j==="property")this.#Q.setAttribute("full","");if(this.#Q.className="fig-input-file-filename",J)this.#Q.setAttribute("disabled","");let L=N?this.#y(this.#j.length):G?this.#p():b(this.#z()),O=document.createElement("fig-truncate");O.setAttribute("position","middle"),O.setAttribute("tooltip","");let H=N?"Multiple files":Y,A=H.lastIndexOf(".");if(!N&&A>0)O.setAttribute("tail",H.slice(A));if(O.textContent=H,L.setAttribute("slot","prepend"),K)L.classList.add("fig-input-file-audio-icon"),O.classList.add("fig-input-file-audio-label"),this.#N=b("play"),this.#N.classList.add("fig-input-file-audio-control"),this.#N.setAttribute("slot","prepend"),this.#Q.append(L,this.#N,O);else this.#Q.append(L,O);if(!K){if(this.#Q.setAttribute("type","upload"),this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",this.#Z.disabled=J,_)this.#Z.setAttribute("accept",_);if(Q)this.#Z.setAttribute("multiple","");this.#Z.addEventListener("change",this.#S),this.#Q.appendChild(this.#Z)}if(R)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",R),this.#$.appendChild(this.#Q),this.appendChild(this.#$);else this.appendChild(this.#Q);let z=document.createElement("fig-tooltip");if(z.setAttribute("text","Remove"),this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#J.setAttribute("icon","true"),this.#J.setAttribute("aria-label","Remove"),this.#J.className="fig-input-file-clear",J)this.#J.setAttribute("disabled","");if(this.#J.replaceChildren(b("minus")),this.#J.addEventListener("click",this.#P),z.appendChild(this.#J),this.appendChild(z),K)this.#w()}else{let Y=_?`Accepts ${_.split(",").map((R)=>R.trim()).join(", ")}`:"";if(Y)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",Y);if(this.#Q=document.createElement("fig-button"),this.#Q.setAttribute("variant",j),j==="property")this.#Q.setAttribute("full","");this.#Q.setAttribute("type","upload"),this.#Q.textContent=$;let W=b("upload");if(W.setAttribute("slot","prepend"),this.#Q.prepend(W),J)this.#Q.setAttribute("disabled","");if(this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",this.#Z.disabled=J,_)this.#Z.setAttribute("accept",_);if(Q)this.#Z.setAttribute("multiple","");if(this.#Z.addEventListener("change",this.#S),this.#Q.appendChild(this.#Z),this.#$)this.#$.appendChild(this.#Q),this.appendChild(this.#$);else this.appendChild(this.#Q)}}}F("fig-input-file",x_);class h extends HTMLElement{#Z={x:0.42,y:0};#_={x:0.58,y:1};#J={stiffness:200,damping:15,mass:1,initialVelocity:0};#$="bezier";#Q=2;#j=null;#G=null;#q=null;#N=null;#X=null;#K=null;#Y=null;#R=null;#U=null;#W=null;#O=null;#M=0.8;#B=200;#L=200;#A=null;#I=null;#D=null;#H=null;#z=5;#F=10;#T=10;#S=3;#P=null;#V=null;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","mode","precision","aspect-ratio","edit","presets","text"]}connectedCallback(){this.#Q=parseInt(this.getAttribute("precision")||"2"),p(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let _=this.#k();if(_)this.#$=_;let Z=this.getAttribute("value");if(Z)this.#g(Z);this.#C(),this.#W=this.#w(),this.#m(),this.#L0()}disconnectedCallback(){if(this.#j=null,this.#H)this.#H.disconnect(),this.#H=null;this.#P0()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="aspect-ratio"){if(p(this,"--aspect-ratio",$),this.#G)this.#X0(),this.#j0();return}if(_==="edit"||_==="presets"||_==="text"){if(_==="edit"&&$!=="false")this.#P0();if(this.isConnected)this.#m();return}if(_==="mode"){this.#C();let J=this.getAttribute("value");if(J)this.#g(J);if(this.#C(),this.#W=this.#w(),this.isConnected)this.#m();this.#A0();return}if(_==="value"&&$){let J=this.#$;if(this.#g($),this.#W=this.#w(),J!==this.#$&&this.#i())this.#m();else{if(this.#G)this.#j0();this.#R0(),this.#q0()}}if(_==="precision")this.#Q=parseInt($||"2");if(_==="value"||_==="mode"||_==="precision")this.#A0()}get value(){if(this.#$==="spring"){let{stiffness:Z,damping:$,mass:J,initialVelocity:Q=0}=this.#J,j=Q?`, ${Q}`:"";return`spring(${Z}, ${$}, ${J}${j})`}let _=this.#Q;return`${this.#Z.x.toFixed(_)}, ${this.#Z.y.toFixed(_)}, ${this.#_.x.toFixed(_)}, ${this.#_.y.toFixed(_)}`}get cssValue(){if(this.#$==="spring"){let Z=this.#p(),$=20,J=Math.max(1,Math.floor(Z.length/20)),Q=[];for(let j=0;j<Z.length;j+=J)Q.push(Z[j].value.toFixed(3));if(Z.length>0)Q.push(Z[Z.length-1].value.toFixed(3));return`linear(${Q.join(", ")})`}let _=this.#Q;return`cubic-bezier(${this.#Z.x.toFixed(_)}, ${this.#Z.y.toFixed(_)}, ${this.#_.x.toFixed(_)}, ${this.#_.y.toFixed(_)})`}get preset(){return this.#W}set value(_){if(_&&typeof _==="object"){let Z=this.#E(_);if(!Z)throw TypeError("Invalid easing value or mode/type mismatch");let $=Z.type==="spring"?{type:"spring",...Z.spring}:{type:"bezier",x1:Z.bezier[0],y1:Z.bezier[1],x2:Z.bezier[2],y2:Z.bezier[3]};this.setAttribute("value",JSON.stringify($));return}this.setAttribute("value",_)}get spring(){if(this.#$!=="spring")return null;return{...this.#J,initialVelocity:this.#J.initialVelocity??0}}set spring(_){if(!_||typeof _!=="object")throw TypeError("spring must be an object");this.value={..._,type:"spring"}}#k(){let _=this.getAttribute("mode")?.trim().toLowerCase();return _==="bezier"||_==="spring"?_:null}#C(){let _=this.#k();if(_)this.#$=_}#h(_){let Z=this.#k();return!Z||_.type===Z}#E(_){if(!_||typeof _!=="object"||Array.isArray(_))return null;let Z=this.#k(),$=typeof _.type==="string"?_.type.trim().toLowerCase():null;if($&&$!=="bezier"&&$!=="spring")return null;if($&&Z&&$!==Z)return null;let J=$||Z;if(!J)return null;if(J==="spring"){let j={mass:Number(_.mass),stiffness:Number(_.stiffness),damping:Number(_.damping),initialVelocity:_.initialVelocity===void 0?0:Number(_.initialVelocity)};if(!Number.isFinite(j.mass)||j.mass<=0||!Number.isFinite(j.stiffness)||j.stiffness<=0||!Number.isFinite(j.damping)||j.damping<0||!Number.isFinite(j.initialVelocity))return null;return{type:J,spring:j}}let Q=[_.x1,_.y1,_.x2,_.y2].map(Number);if(Q.some((j)=>!Number.isFinite(j))||Q[0]<0||Q[0]>1||Q[2]<0||Q[2]>1)return null;return{type:J,bezier:Q}}#f(_){if(_.type==="spring")this.#$="spring",this.#J={..._.spring};else this.#$="bezier",[this.#Z.x,this.#Z.y,this.#_.x,this.#_.y]=_.bezier}#x(_){let Z=_.match(/^spring\(\s*(.*?)\s*\)$/i);if(!Z)return null;let $=Z[1].split(",").map((Q)=>Number(Q.trim()));if($.length!==3&&$.length!==4||$.some((Q)=>!Number.isFinite(Q)))return null;let J={stiffness:$[0],damping:$[1],mass:$[2],initialVelocity:$[3]??0};if(J.stiffness<=0||J.damping<0||J.mass<=0)return null;return J}#g(_){if(_&&typeof _==="object"){let Q=this.#E(_);if(!Q)return!1;return this.#f(Q),!0}if(typeof _!=="string")return!1;let Z=_.trim();if(Z.startsWith("{"))try{return this.#g(JSON.parse(Z))}catch{return!1}let $=this.#x(Z);if($&&this.#k()!=="bezier")return this.#$="spring",this.#J=$,!0;let J=Z.split(",").map((Q)=>parseFloat(Q.trim()));if(J.length>=4&&J.every((Q)=>!isNaN(Q))&&this.#k()!=="spring")return this.#$="bezier",this.#Z.x=J[0],this.#Z.y=J[1],this.#_.x=J[2],this.#_.y=J[3],!0;return!1}#w(){if(this.#$==="bezier"){for(let Z of h.PRESETS){if(Z.type!=="bezier"||!Z.value)continue;if(Math.abs(this.#Z.x-Z.value[0])<0.001&&Math.abs(this.#Z.y-Z.value[1])<0.001&&Math.abs(this.#_.x-Z.value[2])<0.001&&Math.abs(this.#_.y-Z.value[3])<0.001)return Z.name}return"Custom bezier"}for(let Z of h.PRESETS){if(Z.type!=="spring"||!Z.spring)continue;if(Math.abs(this.#J.stiffness-Z.spring.stiffness)<0.001&&Math.abs(this.#J.damping-Z.spring.damping)<0.001&&Math.abs(this.#J.mass-Z.spring.mass)<0.001&&Math.abs(this.#J.initialVelocity??0)<0.001)return Z.name}return"Custom spring"}#p(){let{stiffness:_,damping:Z,mass:$,initialVelocity:J=0}=this.#J,Q=0.004,j=5,q=[],N=0,G=J;for(let K=0;K<=5;K+=0.004){let X=-_*(N-1)-Z*G;if(G+=X/$*0.004,N+=G*0.004,q.push({t:K,value:N}),K>0.1&&Math.abs(N-1)<0.0005&&Math.abs(G)<0.0005)break}return q}static#y(_,Z=24){let{stiffness:$,damping:J,mass:Q,initialVelocity:j=0}=_,q=0.004,N=5,G=[],K=0,X=j;for(let U=0;U<=5;U+=0.004){let I=-$*(K-1)-J*X;if(X+=I/Q*0.004,K+=X*0.004,G.push({t:U,value:K}),U>0.1&&Math.abs(K-1)<0.001&&Math.abs(X)<0.001)break}let Y=G[G.length-1].t||1,W=1;for(let U of G)if(U.value>W)W=U.value;let R=0;for(let U of G)if(U.value<R)R=U.value;let L=Math.max(W-R,1),O=6,H=Z-O*2,A=Math.max(1,Math.floor(G.length/30)),z="";for(let U=0;U<G.length;U+=A){let I=O+G[U].t/Y*H,V=O+(1-(G[U].value-R)/L)*H;z+=(U===0?"M":"L")+I.toFixed(1)+","+V.toFixed(1)}return h.#a(z,Z,h.#u(Z))}static#b(_,Z,$,J,Q=24){let q=(Q-11)/2,N=48,G=[],K=(U,I,V,P,S)=>{let w=1-S;return w*w*w*U+3*w*w*S*I+3*w*S*S*V+S*S*S*P};for(let U=0;U<=48;U++){let I=U/48;G.push({x:K(0,_,$,1,I),y:K(0,Z,J,1,I)})}let X=1/0,Y=-1/0,W=1/0,R=-1/0;for(let U of G){if(U.x<X)X=U.x;if(U.x>Y)Y=U.x;if(U.y<W)W=U.y;if(U.y>R)R=U.y}let L=Math.max(Y-X,0.000001),O=Math.max(R-W,0.000001),H=(U)=>q+(U-X)/L*11,A=(U)=>q+(1-(U-W)/O)*11,z="";for(let U=0;U<G.length;U++){let I=H(G[U].x),V=A(G[U].y);z+=`${U===0?"M":"L"}${I.toFixed(1)},${V.toFixed(1)}`}return z}static#v(_=24){let $=(_-11)/2,J=3.6666666666666665;return Array.from({length:16},(Q,j)=>({x:$+j%4*3.6666666666666665,y:$+Math.floor(j/4)*3.6666666666666665}))}static#u(_=24){return h.#v(_).map(({x:Z,y:$})=>E("circle",{cx:Z,cy:$,r:0.5,fill:"var(--figma-color-icon-tertiary)"}))}static#a(_,Z=24,$=[]){return E("svg",{width:Z,height:Z,viewBox:`0 0 ${Z} ${Z}`,fill:"none"},[...$,E("path",{d:_,stroke:"currentColor","stroke-width":"1","stroke-linecap":"round",fill:"none"})])}static#o(_,Z,$,J,Q=24){return h.#a(h.#b(_,Z,$,J,Q),Q,h.#u(Q))}static curveIcon(_,Z,$,J,Q=24){let j=h.#b(_,Z,$,J,Q),q=h.#v(Q).map(({x:N,y:G})=>`<circle cx="${N}" cy="${G}" r="0.5" fill="var(--figma-color-icon-tertiary)"></circle>`).join("");return`<svg width="${Q}" height="${Q}" viewBox="0 0 ${Q} ${Q}" fill="none">${q}<path d="${j}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#i(){return this.getAttribute("edit")!=="false"}#r(){return this.getAttribute("presets")!=="false"}#t(){return this.getAttribute("text")!=="false"}#m(){if(this.classList.toggle("spring-mode",this.#$==="spring"),this.classList.toggle("bezier-mode",this.#$!=="spring"),this.#N0(),this.replaceChildren(...this.#G0()),this.#Z0(),this.#G)this.#n(),this.#X0(),this.#j0();this.#q0(),this.#p0()}#c(){return["fig-select","fig-select-options","fig-select-option"].every((_)=>{let Z=customElements.get(_);return typeof Z==="function"&&Z.prototype instanceof HTMLElement})}#d(){let _=M("fig-dropdown",{className:"fig-easing-curve-select",label:"Easing preset",value:this.#W,full:!0}),Z=void 0,$=_;for(let J of h.PRESETS){if(!this.#h(J))continue;if(!this.#i()&&!customElements.get("fig-popup-easing")&&!J.value&&!J.spring)continue;if(J.group!==Z){if(Z=J.group,$=Z?M("optgroup",{label:Z}):_,$!==_)_.appendChild($)}$.appendChild(M("option",{value:J.name},J.name))}return _}#Q0(){if(!this.#c())return this.#d();let _=document.createElement("fig-select-options"),Z=void 0;for(let $ of h.PRESETS){if(!this.#h($))continue;if(!this.#i()&&!customElements.get("fig-popup-easing")&&!$.value&&!$.spring)continue;if($.group!==Z){if($.group)_.appendChild(M("fig-separator",{label:$.group}));Z=$.group}let J;if($.type==="spring"){let Q=$.spring||this.#J;J=h.#y(Q)}else{let Q=$.value||[this.#Z.x,this.#Z.y,this.#_.x,this.#_.y];J=h.#o(...Q)}_.appendChild(M("fig-select-option",{value:$.name,label:$.name},[M("fig-icon",{slot:"prepend"},J),M("span",{},$.name)]))}return M("fig-select",{className:"fig-easing-curve-select",label:"Easing preset",value:this.#W,full:!0},_)}#s(_,Z,$){let J=M("fig-handle",{size:"small",type:"minimal","aria-label":$});return E("foreignObject",{className:_,"data-handle":Z,width:"20",height:"20"},M("fig-tooltip",{text:this.#l(Z)},J))}#e(_){if(!Number.isFinite(_))return"0";return String(Number(_.toFixed(this.#Q)))}#l(_){if(this.#$==="spring"){if(_==="bounce")return`Bounce ${this.#e(this.#U0())}`;return`Duration ${Math.round(this.#M*100)}%`}let Z=_==="1"?this.#Z:this.#_;return`${_==="1"?"Start":"End"} ${this.#e(Z.x)}, ${this.#e(Z.y)}`}#_0(){for(let[_,Z]of[[this.#K,this.#$==="spring"?"bounce":"1"],[this.#Y,this.#$==="spring"?"duration":"2"]]){let $=_?.querySelector("fig-tooltip");if($)$.text=this.#l(Z)}}#$0(_,Z){let $=_?.querySelector("fig-tooltip");if(!$)return;if(Z)$.setAttribute("show","true");else $.removeAttribute("show")}#G0(){let Z=this.#r()?this.#Q0():null;if(!this.#i())return Z?[Z]:[];let $=this.#t()?this.#$==="spring"?M("fig-input-number",{className:"fig-easing-curve-value-input",value:this.#U0().toFixed(2),min:"0",max:"1",step:"0.01",precision:"2","aria-label":"Spring bounce",full:!0}):M("fig-input-text",{className:"fig-easing-curve-value-input",value:this.value,full:!0}):null,J=[E("rect",{className:"fig-easing-curve-bounds",x:"0",y:"0",width:200,height:200})];if(this.#$==="spring")J.push(E("line",{className:"fig-easing-curve-target",x1:"0",y1:40,x2:200,y2:40}),E("path",{className:"fig-easing-curve-path"}),this.#s("fig-easing-curve-handle","bounce","Spring bounce handle"),this.#s("fig-easing-curve-handle fig-easing-curve-duration-bar","duration","Spring duration handle"));else J.push(E("line",{className:"fig-easing-curve-boundary","data-boundary":"top",x1:"0",y1:"0",x2:200,y2:"0"}),E("line",{className:"fig-easing-curve-boundary","data-boundary":"bottom",x1:"0",y1:200,x2:200,y2:200}),E("path",{className:"fig-easing-curve-path"}),E("line",{className:"fig-easing-curve-arm","data-arm":"1"}),E("line",{className:"fig-easing-curve-arm","data-arm":"2"}),this.#s("fig-easing-curve-handle","1","First easing control point"),this.#s("fig-easing-curve-handle","2","Second easing control point"));let Q=E("svg",{viewBox:"0 0 200 200",className:"fig-easing-curve-svg"},J);return[...Z?[Z]:[],M("div",{className:"fig-easing-curve-svg-container"},Q),...$?[$]:[]]}#K0(_,Z){let $=getComputedStyle(this).getPropertyValue(_).trim();if(!$)return Z;let J=Number.parseFloat($);return Number.isFinite(J)?J:Z}#N0(){this.#S=this.#K0("--easing-duration-bar-radius",this.#S)}#Z0(){this.#G=this.querySelector(".fig-easing-curve-svg"),this.#q=this.querySelector(".fig-easing-curve-path"),this.#N=this.querySelector('[data-arm="1"]'),this.#X=this.querySelector('[data-arm="2"]'),this.#K=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#Y=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#R=this.querySelector(".fig-easing-curve-select"),this.#U=this.querySelector(".fig-easing-curve-value-input"),this.#O=this.querySelector(".fig-easing-curve-target"),this.#A=this.querySelector(".fig-easing-curve-bounds"),this.#I=this.querySelector('[data-boundary="top"]'),this.#D=this.querySelector('[data-boundary="bottom"]')}#n(){let _=this.#K?.querySelector("fig-handle"),Z=this.#Y?.querySelector("fig-handle");if(_){let $=_.offsetWidth||this.#z*2,J=_.offsetHeight||this.#z*2;this.#z=Math.max($,J)/2,this.#K.setAttribute("width",$),this.#K.setAttribute("height",J)}if(Z){let $=Z.offsetWidth||this.#F,J=Z.offsetHeight||this.#T;if(this.#$==="spring")this.#F=$,this.#T=J;this.#Y.setAttribute("width",$),this.#Y.setAttribute("height",J)}}#L0(){if(this.#H||!window.ResizeObserver)return;this.#H=new ResizeObserver(()=>{if(this.#X0())this.#j0()}),this.#H.observe(this)}#X0(){if(!this.#G)return!1;let _=this.#G.getBoundingClientRect(),Z=Math.max(1,Math.round(_.width||200)),$=Math.max(1,Math.round(_.height||200)),J=Z!==this.#B||$!==this.#L;return this.#B=Z,this.#L=$,this.#G.setAttribute("viewBox",`0 0 ${Z} ${$}`),J}#F0(){let _=Math.min(0,this.#Z.y,this.#_.y),Z=Math.max(1,this.#Z.y,this.#_.y),$=Z-_||1,J=0;return{minVal:_,maxVal:Z,range:$,pad:0,draw:Math.max(1,this.#L-0)}}#O0(_,Z){let{maxVal:$,range:J,pad:Q,draw:j}=this.#F0();return{x:_*this.#B,y:Q+($-Z)/J*j}}#E0(_,Z){let{maxVal:$,range:J,pad:Q,draw:j}=this.#F0();return{x:_/this.#B,y:$-(Z-Q)/j*J}}#z0={minVal:0,maxVal:1.2,totalTime:1};#Y0(_,Z){let J=this.#L-40,{minVal:Q,maxVal:j}=this.#z0,q=j-Q||1;return{x:_*this.#B,y:20+(1-(Z-Q)/q)*J}}#j0(){if(this.#X0(),this.#$==="spring")this.#w0();else this.#f0();this.#_0()}#T0(){this.#N?.classList.toggle("is-active",this.#$==="bezier"&&this.#j===1),this.#X?.classList.toggle("is-active",this.#$==="bezier"&&this.#j===2)}#f0(){if(this.#A)this.#A.setAttribute("x","0"),this.#A.setAttribute("y","0"),this.#A.setAttribute("width",this.#B),this.#A.setAttribute("height",this.#L);let _=this.#O0(0,0),Z=this.#O0(this.#Z.x,this.#Z.y),$=this.#O0(this.#_.x,this.#_.y),J=this.#O0(1,1);for(let[j,q]of[[this.#I,J.y],[this.#D,_.y]]){if(!j)continue;j.setAttribute("x1","0"),j.setAttribute("y1",q),j.setAttribute("x2",this.#B),j.setAttribute("y2",q)}this.#q.setAttribute("d",`M${_.x},${_.y} C${Z.x},${Z.y} ${$.x},${$.y} ${J.x},${J.y}`),this.#N.setAttribute("x1",_.x),this.#N.setAttribute("y1",_.y),this.#N.setAttribute("x2",Z.x),this.#N.setAttribute("y2",Z.y),this.#X.setAttribute("x1",J.x),this.#X.setAttribute("y1",J.y),this.#X.setAttribute("x2",$.x),this.#X.setAttribute("y2",$.y);let Q=this.#z;this.#K.setAttribute("x",Z.x-Q),this.#K.setAttribute("y",Z.y-Q),this.#Y.setAttribute("x",$.x-Q),this.#Y.setAttribute("y",$.y-Q),this.#x0()}#x0(){if(!this.#G||!this.#K||!this.#Y)return;let _=this.#Z.y>=this.#_.y?[this.#K,this.#Y]:[this.#Y,this.#K];for(let Z of _)this.#G.append(Z)}#w0(){if(this.#A)this.#A.setAttribute("x","0"),this.#A.setAttribute("y","0"),this.#A.setAttribute("width",this.#B),this.#A.setAttribute("height",this.#L);let _=this.#p();if(!_.length)return;let Z=_[_.length-1].t||1,$=0,J=1;for(let O of _){if(O.value<$)$=O.value;if(O.value>J)J=O.value}let Q=Math.max(Math.abs($-1),Math.abs(J-1),0.01),j=0;this.#z0={minVal:1-Q-j,maxVal:1+Q+j,totalTime:Z};let q=Math.max(0.05,Math.min(1,this.#M)),N="";for(let O=0;O<_.length;O++){let H=_[O].t/Z*q,A=this.#Y0(H,_[O].value);N+=(O===0?"M":"L")+A.x.toFixed(1)+","+A.y.toFixed(1)}let G=this.#Y0(q,1),K=this.#Y0(1,1);if(N+=`L${G.x.toFixed(1)},${G.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#q.setAttribute("d",N),this.#O){let O=this.#Y0(0,1),H=this.#Y0(1,1);this.#O.setAttribute("x1",O.x),this.#O.setAttribute("y1",O.y),this.#O.setAttribute("x2",H.x),this.#O.setAttribute("y2",H.y)}let X=this.#y0(_),Y=X.t/Z*q,W=this.#Y0(Y,X.value),R=this.#z;this.#K.setAttribute("x",W.x-R),this.#K.setAttribute("y",W.y-R);let L=this.#Y0(q,1);this.#Y.setAttribute("x",L.x-this.#F/2),this.#Y.setAttribute("y",L.y-this.#T/2)}#y0(_){let Z={t:0,value:1},$=!1;for(let J=1;J<_.length-1;J++){let Q=_[J-1],j=_[J],q=_[J+1];if(j.value>=0.99)$=!0;if($&&j.value>Z.value)Z={t:j.t,value:j.value};if($&&j.value>1&&j.value>=Q.value&&j.value>=q.value)return{t:j.t,value:j.value}}return Z}#R0(){if(!this.#R)return;this.#R.value=this.#W,this.#g0()}#q0(){if(!this.#U)return;let _=this.#$==="spring"?this.#U0().toFixed(2):this.value;this.#U.setAttribute("value",_)}#U0(){let{stiffness:_,damping:Z,mass:$}=this.#J,J=2*Math.sqrt(_*$);if(!Number.isFinite(J)||J<=0)return 0;return Math.max(0,Math.min(1,1-Z/J))}#W0(_){let Z=Math.max(0,Math.min(1,Number(_))),$=2*Math.sqrt(this.#J.stiffness*this.#J.mass);this.#J.damping=Number(($*(1-Z)).toFixed(4))}#k0(_,Z){let $=Number(_);if(!Number.isFinite($)){if(Z==="change")this.#q0();return}if(this.#W0($),this.#W=this.#w(),this.#j0(),this.#R0(),Z==="change")this.#q0();this.#J0(Z)}#h0(_){let Z=_.split(",").map(($)=>Number.parseFloat($.trim()));if(Z.length!==4||Z.some(($)=>!Number.isFinite($)))return null;if(Z[0]<0||Z[0]>1||Z[2]<0||Z[2]>1)return null;return Z}#b0(_){return this.#x(_)}#D0(_,Z){let $=this.#k(),J=$==="bezier"?null:this.#b0(_),Q=$==="spring"?null:this.#h0(_);if(!J&&!Q){if(Z==="change")this.#q0();return}let j=this.#$;if(J)this.#$="spring",this.#J=J;else this.#$="bezier",this.#Z.x=Q[0],this.#Z.y=Q[1],this.#_.x=Q[2],this.#_.y=Q[3];if(this.#W=this.#w(),j!==this.#$)this.#m();else if(this.#j0(),this.#R0(),Z==="change")this.#q0();this.#J0(Z)}#I0(_,Z){if(!this.#R)return;for(let $ of this.#R.querySelectorAll("fig-select-option"))if($.value===_){let J=$.querySelector(':scope > [slot="prepend"]');if(J)J.replaceChildren(Z.cloneNode(!0))}}#g0(){if(!this.#R)return;if(!this.#i()&&!customElements.get("fig-popup-easing"))return;let _=h.#o(this.#Z.x,this.#Z.y,this.#_.x,this.#_.y),Z=h.#y(this.#J);this.#I0("Custom bezier",_),this.#I0("Custom spring",Z)}#V0(_){this.#j0(),this.#W=this.#w(),this.#R0(),this.#q0(),this.#J0(_)}#v0(_,Z){let $=_.shiftKey?0.1:0.01,J=Z===1?this.#Z:this.#_;switch(_.key){case"ArrowLeft":J.x-=$;break;case"ArrowRight":J.x+=$;break;case"ArrowUp":J.y+=$;break;case"ArrowDown":J.y-=$;break;case"Home":J.x=0,J.y=0;break;case"End":J.x=1,J.y=1;break;default:return!1}return J.x=Math.max(0,Math.min(1,Math.round(J.x*100)/100)),J.y=Math.round(J.y*100)/100,this.#V0("input"),this.#J0("change"),!0}#m0(_,Z){let $=_.shiftKey?10:1;if(Z==="bounce"){let J=$/100;switch(_.key){case"ArrowUp":this.#W0(this.#U0()+J);break;case"ArrowDown":this.#W0(this.#U0()-J);break;case"Home":this.#W0(0);break;case"End":this.#W0(1);break;default:return!1}}else{let J=$*2;switch(_.key){case"ArrowLeft":this.#M=Math.max(0.05,this.#M-J/200),this.#J.stiffness=Math.max(10,Math.round(this.#J.stiffness+J*1.5));break;case"ArrowRight":this.#M=Math.min(1,this.#M+J/200),this.#J.stiffness=Math.max(10,Math.round(this.#J.stiffness-J*1.5));break;case"Home":this.#M=0.05;break;case"End":this.#M=1;break;default:return!1}}return this.#V0("input"),this.#J0("change"),!0}#M0(_,Z){let $=_?.querySelector("fig-handle");if(!$)return;$.addEventListener("pointerdown",(J)=>{if(J.preventDefault(),J.stopImmediatePropagation(),this.#$==="bezier")this.#B0(J,Number(Z));else this.#H0(J,Z)},{capture:!0}),$.addEventListener("keydown",(J)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(J.key))return;if(!(this.#$==="bezier"?this.#v0(J,Number(Z)):this.#m0(J,Z)))return;J.preventDefault(),J.stopImmediatePropagation()},{capture:!0})}#J0(_){let Z=this.spring;this.dispatchEvent(new CustomEvent(_,{bubbles:!0,detail:{mode:this.#$,value:this.value,cssValue:this.cssValue,preset:this.#W,...Z?{spring:Z}:{}}}))}#p0(){if(this.#G&&this.#$==="bezier"){this.#M0(this.#K,"1"),this.#M0(this.#Y,"2"),this.#K.addEventListener("pointerdown",(Z)=>this.#B0(Z,1)),this.#Y.addEventListener("pointerdown",(Z)=>this.#B0(Z,2));let _=this.querySelector(".fig-easing-curve-svg-container");if(_)_.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#B0(Z,this.#u0(Z))})}else if(this.#G){this.#M0(this.#K,"bounce"),this.#M0(this.#Y,"duration"),this.#K.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#H0(Z,"bounce")}),this.#Y.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#H0(Z,"duration")});let _=this.querySelector(".fig-easing-curve-svg-container");if(_)_.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#H0(Z,"duration")})}if(this.#R){if(!this.#i()&&this.#R.tagName==="FIG-SELECT"){let _=(Z)=>{if(!customElements.get("fig-popup-easing"))return;Z.preventDefault(),Z.stopImmediatePropagation(),this.#C0()};this.#R.addEventListener("click",_,!0),this.#R.addEventListener("keydown",(Z)=>{if(Z.key==="Enter"||Z.key===" ")_(Z)},!0)}this.#R.addEventListener("input",(_)=>{_.stopPropagation()}),this.#R.addEventListener("optionhover",(_)=>{_.stopPropagation()}),this.#R.addEventListener("change",(_)=>{_.stopPropagation();let Z=_.detail,$=h.PRESETS.find((J)=>J.name===Z);if(!$)return;if($.type==="bezier"){if($.value)this.#Z.x=$.value[0],this.#Z.y=$.value[1],this.#_.x=$.value[2],this.#_.y=$.value[3];if(this.#W=Z,this.#$!=="bezier")this.#$="bezier",this.#m();else if(this.#G)this.#j0(),this.#q0()}else if($.type==="spring"){if($.spring)this.#J={...$.spring,initialVelocity:0};if(this.#W=Z,this.#$!=="spring")this.#$="spring",this.#m();else if(this.#G)this.#j0(),this.#q0()}this.#J0("input"),this.#J0("change")})}if(this.#U)this.#U.addEventListener("input",(_)=>{_.stopPropagation();let Z=_.detail??_.target?.value;if(this.#$==="spring")this.#k0(Z,"input");else if(typeof Z==="string")this.#D0(Z,"input")}),this.#U.addEventListener("change",(_)=>{_.stopPropagation();let Z=_.detail??_.target?.value;if(this.#$==="spring")this.#k0(Z,"change");else if(typeof Z==="string")this.#D0(Z,"change")})}#C0(){if(!customElements.get("fig-popup-easing")){this.#P??=customElements.whenDefined("fig-popup-easing").then(()=>{if(!this.isConnected||this.#i())return;this.#C0()});return}let _=this.#V;if(!_?.isConnected){_=document.createElement("dialog",{is:"fig-popup-easing"}),_.setAttribute("is","fig-popup-easing"),_.id=g(),_.anchor=this.#R;let Z=($)=>{$.stopPropagation(),this.value=_.value,this.#J0($.type)};_.addEventListener("input",Z),_.addEventListener("change",Z),(l()??document.body).append(_),this.#V=_,this.#R?.setAttribute("aria-controls",_.id)}this.#A0(),_.open=!0}#A0(){let _=this.#V;if(!_)return;_.anchor=this.#R,_.setAttribute("value",this.value);for(let Z of["mode","precision"]){let $=this.getAttribute(Z);if($===null)_.removeAttribute(Z);else _.setAttribute(Z,$)}}#P0(){if(!this.#V)return;this.#V.open=!1,this.#V.remove(),this.#R?.removeAttribute("aria-controls"),this.#V=null}#S0(_){let Z=this.#G.getScreenCTM();if(!Z)return{x:0,y:0};let $=Z.inverse();return{x:$.a*_.clientX+$.c*_.clientY+$.e,y:$.b*_.clientX+$.d*_.clientY+$.f}}#u0(_){return this.#S0(_).x<=this.#B/2?1:2}#B0(_,Z){_.preventDefault(),this.#j=Z,this.#T0();let $=Z===1?this.#K:this.#Y;this.#$0($,!0);let J=this.#G.getBoundingClientRect(),Q=_.clientX,j=_.clientY,q=_.target?.closest?.(".fig-easing-curve-handle, fig-handle"),N=Z===1?this.#Z:this.#_,G=this.#S0(_),K=q?{...N}:this.#E0(G.x,G.y),{range:X,draw:Y}=this.#F0(),W=X/Math.max(1,Y/this.#L*Math.max(1,J.height)),R=(O)=>{if(!this.#j)return;let H={x:K.x+(O.clientX-Q)/Math.max(1,J.width),y:O.shiftKey?Z===1?0:1:K.y-(O.clientY-j)*W};if(H.x=Math.round(H.x*100)/100,H.y=Math.round(H.y*100)/100,H.x=Math.max(0,Math.min(1,H.x)),this.#j===1)this.#Z.x=H.x,this.#Z.y=H.y;else this.#_.x=H.x,this.#_.y=H.y;this.#j0(),this.#W=this.#w(),this.#R0(),this.#q0(),this.#J0("input")},L=()=>{this.#j=null,this.#T0(),this.#$0($,!1),document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",L),this.#J0("change")};document.addEventListener("pointermove",R),document.addEventListener("pointerup",L)}#H0(_,Z){_.preventDefault(),this.#j=Z,this.classList.toggle("spring-bounce-dragging",Z==="bounce");let $=Z==="bounce"?this.#K:this.#Y;this.#$0($,!0);let J=this.#U0(),Q=this.#J.stiffness,j=this.#M,q=_.clientY,N=_.clientX,G=(X)=>{if(!this.#j)return;if(Z==="bounce"){let Y=X.clientY-q;this.#W0(J-Y/200)}else{let Y=X.clientX-N;this.#M=Math.max(0.05,Math.min(1,j+Y/200)),this.#J.stiffness=Math.max(10,Math.round(Q-Y*1.5))}this.#j0(),this.#W=this.#w(),this.#R0(),this.#q0(),this.#J0("input")},K=()=>{this.#j=null,this.classList.remove("spring-bounce-dragging"),this.#$0($,!1),document.removeEventListener("pointermove",G),document.removeEventListener("pointerup",K),this.#J0("change")};document.addEventListener("pointermove",G),document.addEventListener("pointerup",K)}}F("fig-easing-curve",h);class e extends HTMLElement{#Z=0;#_=0;#J="deg";#$=null;#Q=null;#j=null;#G=null;#q=null;#N=null;#X=null;#K=null;#Y=null;#R=null;#U=null;#W=!1;#O=!1;#M=(_)=>this.#l(_);#B=(_)=>this.#_0(_);#L=(_)=>this.#$0(_);#A=(_)=>this.#K0(_);#I=(_)=>this.#N0(_);#D=(_)=>this.#Z0(_);#H=()=>this.#Q0();static#z(_,Z=12,$=12,J=7,Q=3,j=0){let q=Number(_),N=Number(j),G=Number.isFinite(q)?q:0,K=Number.isFinite(N)?N:0,X=G-K,Y=X<0?"counterclockwise":"clockwise",W=Math.abs(X);if(W<0.001)return{direction:Y,arc:"",arrow:""};let R=(d)=>`${Number(d.x.toFixed(3))} ${Number(d.y.toFixed(3))}`,L=(d)=>{let $0=d*Math.PI/180;return{x:Z+Math.cos($0)*J,y:$+Math.sin($0)*J}},O=X>=0?1:-1,H=Y==="clockwise"?1:0,A=[`M ${R(L(K))}`],z=K,U=Math.floor(W/360);for(let d=0;d<U;d++)z+=O*180,A.push(`A ${J} ${J} 0 0 ${H} ${R(L(z))}`),z+=O*180,A.push(`A ${J} ${J} 0 0 ${H} ${R(L(z))}`);let I=W-U*360;if(I>=0.001)z+=O*I,A.push(`A ${J} ${J} 0 ${I>180?1:0} ${H} ${R(L(z))}`);let V=L(G),P=G*Math.PI/180,S=X>=0?{x:-Math.sin(P),y:Math.cos(P)}:{x:Math.sin(P),y:-Math.cos(P)},w={x:-S.y,y:S.x},f=Q/Math.SQRT2,c={x:V.x-S.x*f+w.x*f,y:V.y-S.y*f+w.y*f},o={x:V.x-S.x*f-w.x*f,y:V.y-S.y*f-w.y*f};return{direction:Y,arc:A.join(" "),arrow:`M ${R(c)} L ${R(V)} L ${R(o)}`}}static#F(_=0,Z=0){let $=e.#z(_,50,50,47,4,Z);return E("svg",{class:"fig-angle-reference",x:"3%",y:"3%",width:"94%",height:"94%",viewBox:"3 3 94 94",fill:"none",overflow:"visible","aria-hidden":"true","data-direction":$.direction},E("path",{class:"fig-angle-reference-path",d:[$.arc,$.arrow].filter(Boolean).join(" "),hidden:!$.arc,fill:"none",stroke:"currentColor","stroke-width":"var(--stroke-width)","stroke-linecap":"round","stroke-linejoin":"round"}))}static rotationIcon(_=0,Z=48){let $=Number.isFinite(Number(Z))?Math.max(1,Number(Z)):48,J=e.#z(_),Q=J.arc?`<path d="${J.arc} ${J.arrow}" fill="none" stroke="currentColor" stroke-width="var(--stroke-width, 1)" stroke-linecap="round" stroke-linejoin="round"></path>`:"";return`<svg width="${$}" height="${$}" viewBox="0 0 24 24" fill="none" data-direction="${J.direction}">${Q}</svg>`}static get observedAttributes(){return["value","default","precision","dial","min","max","step","units","rotations","disabled","aria-label","name"]}connectedCallback(){this.#T(),this.#r()}disconnectedCallback(){this.#G0(),this.#m()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#O)return;if(_==="value"){if(this.#W)return;let J=Number($);if(Number.isFinite(J))this.#c(J,{reflect:!1});return}if(_==="units"&&this.isConnected){let J=this.#p(this.#Z),Q=this.#J;this.#J=this.#P($),this.#V(Q,this.#J),this.#_=this.#S(),this.#c(this.#y(J)),this.#r();return}if(this.#T(),!this.isConnected)return;if(["dial","precision","min","max","step","units","rotations","disabled","aria-label","name"].includes(_)){this.#r();return}this.#c(this.#Z)}get value(){return this.#Z}set value(_){let Z=Number(_);if(!Number.isFinite(Z))return;this.#c(Z)}get defaultValue(){return this.#x()}set defaultValue(_){if(_===null||_===void 0||_===""){this.removeAttribute("default");return}let Z=Number(_);if(Number.isFinite(Z))this.setAttribute("default",String(Z))}get adjacent(){return Math.cos(this.#p(this.#Z)*Math.PI/180)}get opposite(){return Math.sin(this.#p(this.#Z)*Math.PI/180)}focus(_){this.#Q?.focus(_)}#T(){this.#J=this.#P(this.getAttribute("units")),this.#_=this.#S();let _=this.getAttribute("value"),Z=_===null||_.trim()===""?this.#x():Number(_);if(Number.isFinite(Z))this.#Z=this.#f(Z)}#S(){if(!this.hasAttribute("precision")){if(this.#J==="turn")return 3;if(this.#J==="rad")return 2;return 0}let _=Number.parseInt(this.getAttribute("precision"),10);return Number.isFinite(_)?Math.max(0,_):0}#P(_){let Z=String(_||"deg").trim().toLowerCase();if(Z==="°")return"°";return["deg","rad","turn","grad"].includes(Z)?Z:"deg"}#V(_,Z){if(_===Z)return;this.#O=!0;for(let $ of["min","max","default","step"]){let J=this.getAttribute($);if(J===null||J.trim()==="")continue;let Q=Number(J);if(!Number.isFinite(Q))continue;let j=this.#w(this.#g(Q,_),Z);this.setAttribute($,String(j))}this.#O=!1}#k(_,Z=!1){if(!this.hasAttribute(_))return Z;return this.getAttribute(_)?.toLowerCase()!=="false"}#C(){return T(this,"disabled")}#h(){let _=Number(this.getAttribute("min"));return this.hasAttribute("min")&&Number.isFinite(_)?_:null}#E(){let _=Number(this.getAttribute("max"));return this.hasAttribute("max")&&Number.isFinite(_)?_:null}#f(_){let Z=Number(_);if(!Number.isFinite(Z))return this.#Z;let $=this.#h(),J=this.#E();if($!==null)Z=Math.max($,Z);if(J!==null)Z=Math.min(J,Z);return Z}#x(_=this.getAttribute("default")){let Z=_===null||String(_).trim()===""?0:Number(_);return this.#f(Number.isFinite(Z)?Z:0)}#g(_,Z){switch(Z){case"rad":return _*180/Math.PI;case"turn":return _*360;case"grad":return _*0.9;default:return _}}#w(_,Z){switch(Z){case"rad":return _*Math.PI/180;case"turn":return _/360;case"grad":return _/0.9;default:return _}}#p(_){return this.#g(_,this.#J)}#y(_){return this.#w(_,this.#J)}#b(){return this.#J==="deg"?"°":this.#J}#v(){let _=this.#p(this.#Z),Z=_/360,$=Math.round(Z),J=Math.abs(Z-$)<0.0000000001?$:Math.trunc(Z),Q=_-J*360;return{rotations:J,remainder:this.#y(Math.abs(Q)<0.0000000001?0:Q)}}#u(){return this.#k("rotations")?this.#v().remainder:this.#Z}#a(){switch(this.#J){case"rad":return 0.01;case"turn":return 0.001;case"grad":return 0.1;default:return 1}}#o(){let _=Number(this.getAttribute("step"));return this.hasAttribute("step")&&Number.isFinite(_)&&_>0?_:this.#a()}#i(){return this.getAttribute("aria-label")||this.getAttribute("name")||"Angle"}#r(){this.#G0(),this.#m();let _=[],Z=this.#k("rotations")?M("span",{slot:"append",className:"fig-angle-rotations"},M("span",{className:"fig-angle-rotation-value"})):null,$=this.#k("dial",!0),J=M("fig-input-number",{className:"fig-angle-input",variant:$?"ghost":void 0,tabular:!0,name:"angle",value:this.#u(),min:this.#h(),max:this.#E(),step:this.#o(),precision:this.#_,units:this.#b(),disabled:this.#C(),"aria-label":this.#i()},Z);if($){let Q=M("fig-tooltip",{text:"Reset"},M("fig-button",{variant:"ghost",icon:"true",className:"fig-angle-reset",disabled:this.#C(),"aria-label":"Reset to default"},b("reset",{size:"small"}))),j=this.#h()??this.#y(0),q=this.#E()??this.#y(360),N=this.#C(),G=Array.from({length:24},(X,Y)=>{let W=Y*15,R=W*Math.PI/180,L=37,O=W%45===0?31:35;return E("line",{class:W%45===0?"fig-angle-tick fig-angle-tick-major":"fig-angle-tick",x1:50+Math.cos(R)*O,y1:50+Math.sin(R)*O,x2:50+Math.cos(R)*37,y2:50+Math.sin(R)*37})}),K=E("svg",{class:"fig-angle-svg",viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid meet",role:"slider",tabindex:N?"-1":"0","aria-label":this.#i(),"aria-valuemin":j,"aria-valuemax":q,"aria-disabled":N?"true":"false"},[E("rect",{class:"fig-angle-hit-area",x:"0",y:"0",width:"100",height:"100",fill:"transparent"}),E("circle",{class:"fig-angle-boundary",cx:"50",cy:"50",r:"47"}),...G,e.#F(this.#p(this.#Z),this.#p(this.#x())),E("line",{class:"fig-angle-indicator-halo",x1:"75",y1:"50",x2:"87",y2:"50"}),E("line",{class:"fig-angle-indicator",x1:"75",y1:"50",x2:"87",y2:"50"})]);_.push(M("div",{className:"fig-angle-surface"},[K,J,Q]))}else _.push(J);this.replaceChildren(..._),this.#$=this.querySelector(".fig-angle-surface"),this.#Q=this.querySelector(".fig-angle-svg"),this.#j=this.querySelector(".fig-angle-indicator"),this.#G=this.querySelector(".fig-angle-indicator-halo"),this.#q=this.querySelector(".fig-angle-reference"),this.#N=this.querySelector(".fig-angle-input"),this.#X=this.querySelector(".fig-angle-rotations"),this.#K=this.querySelector(".fig-angle-reset"),this.#t(),this.#d()}#t(){this.#Y=new AbortController;let _=this.#Y.signal;this.#Q?.addEventListener("pointerdown",this.#M,{signal:_}),this.#Q?.addEventListener("pointermove",this.#B,{signal:_}),this.#Q?.addEventListener("pointerup",this.#L,{signal:_}),this.#Q?.addEventListener("pointercancel",this.#L,{signal:_}),this.#Q?.addEventListener("lostpointercapture",this.#L,{signal:_}),this.#Q?.addEventListener("keydown",this.#A,{signal:_}),this.#N?.addEventListener("input",this.#I,{signal:_}),this.#N?.addEventListener("change",this.#I,{signal:_}),this.#K?.addEventListener("click",this.#H,{signal:_}),this.addEventListener("change",this.#D,{capture:!0,signal:_})}#m(){this.#Y?.abort(),this.#Y=null}#c(_,{reflect:Z=!0}={}){let $=this.#f(_);if(this.#Z=$,Z){let J=String($);if(this.getAttribute("value")!==J)this.#W=!0,this.setAttribute("value",J),this.#W=!1}this.#d()}#d(){let _=this.#p(this.#Z),$=`rotate(${(_%360+360)%360} 50 50)`;this.#j?.setAttribute("transform",$),this.#G?.setAttribute("transform",$);let J=this.#p(this.#x()),Q=e.#z(_,50,50,47,4,J);this.#q?.setAttribute("data-direction",Q.direction);let j=this.#q?.querySelector(".fig-angle-reference-path");if(j?.setAttribute("d",[Q.arc,Q.arrow].filter(Boolean).join(" ")),j?.toggleAttribute("hidden",!Q.arc),this.#Q){let q=this.#y(0),N=this.#y(360);this.#Q.setAttribute("aria-valuemin",String(this.#h()??Math.min(q,this.#Z))),this.#Q.setAttribute("aria-valuemax",String(this.#E()??Math.max(N,this.#Z))),this.#Q.setAttribute("aria-valuenow",String(this.#Z)),this.#Q.setAttribute("aria-valuetext",`${this.#Z.toFixed(this.#_)}${this.#b()}`)}if(this.#N){let q=this.#u().toFixed(this.#_);if(this.#N.getAttribute("value")!==q)this.#N.setAttribute("value",q)}if(this.#X){let{rotations:q}=this.#v(),N=this.#X.querySelector(".fig-angle-rotation-value");if(N)N.textContent=q?`×${q}`:"";this.#X.hidden=q===0}if(this.#K)this.#K.hidden=this.#Z===this.#x()}#Q0(){if(this.#C())return;this.#c(this.#x()),this.#n("input"),this.#n("change")}#s(_){let Z=this.#$.getBoundingClientRect(),$=Z.left+Z.width/2,J=Z.top+Z.height/2,Q=_.clientX-$,j=_.clientY-J;if(Math.hypot(Q,j)<Math.min(Z.width,Z.height)*0.08)return null;let q=Math.atan2(j,Q)*180/Math.PI;if(q=(q%360+360)%360,_.shiftKey)q=Math.round(q/15)*15;return q}#e(_){let Z=this.#s(_);if(Z===null)return;let $=this.#p(this.#Z),J;if(this.#U===null){let Q=($%360+360)%360;J=Z-Q}else J=Z-this.#U;if(J>180)J-=360;if(J<-180)J+=360;this.#U=Z,this.#c(this.#y($+J)),this.#n("input")}#l(_){if(this.#C()||_.button!==0)return;_.preventDefault(),this.#Q?.focus({preventScroll:!0}),this.#R=_.pointerId,this.#U=null,this.#$.classList.add("dragging");try{this.#Q.setPointerCapture?.(_.pointerId)}catch{}this.#e(_)}#_0(_){if(_.pointerId!==this.#R)return;if(_.buttons===0){this.#$0(_);return}this.#e(_)}#$0(_){if(_.pointerId!==this.#R)return;let Z=this.#R;if(this.#R=null,this.#U=null,this.#$?.classList.remove("dragging"),this.#Q?.hasPointerCapture?.(Z))this.#Q.releasePointerCapture(Z);this.#n("change")}#G0(){this.#R=null,this.#U=null,this.#$?.classList.remove("dragging")}#K0(_){if(this.#C())return;let Z=this.#Z,$=_.key==="ArrowLeft"||_.key==="ArrowDown"?-1:_.key==="ArrowRight"||_.key==="ArrowUp"?1:0;if($){let J=_.shiftKey?this.#y(15):this.#o();Z+=$*J}else if(_.key==="Home")Z=this.#h()??this.#y(0);else if(_.key==="End")Z=this.#E()??this.#y(360);else return;_.preventDefault(),_.stopPropagation(),this.#c(Z),this.#n("input"),this.#n("change")}#N0(_){if(_.stopPropagation(),this.#C())return;let Z=Number(_.currentTarget.value);if(!Number.isFinite(Z))return;if(this.#k("rotations")){let{rotations:$}=this.#v();this.#c(this.#y($*360+this.#p(Z)))}else this.#c(Z);this.#n(_.type)}#Z0(_){if(!_.target?.matches?.("input"))return;let Z=String(_.target.value).match(/^(-?\d*\.?\d+)\s*(deg|°|rad|turn|grad)$/i);if(!Z)return;let $=Number(Z[1]),J=this.#P(Z[2]),Q=$;if(J==="rad")Q=$*180/Math.PI;else if(J==="turn")Q=$*360;else if(J==="grad")Q=$*0.9;_.target.value=String(this.#y(Q))}#n(_){let Z=Number(this.value.toFixed(this.#_));this.dispatchEvent(new CustomEvent(_,{bubbles:!0,cancelable:!0,detail:{value:Z,angle:Z,units:this.#J}}))}}F("fig-angle",e);class w_ extends HTMLElement{#Z=0;#_=0;#J=0;#$=1;#Q=!1;#j=!1;#G=null;#q=null;#N=null;#X=null;#K=(_)=>this.#C(_);#Y=null;#R=[];#U={};#W={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#$=parseInt(this.getAttribute("precision")||"1"),p(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),p(this,"--perspective",this.getAttribute("perspective")),p(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#B(this.getAttribute("transform-origin")),this.#I(this.getAttribute("fields"));let _=this.getAttribute("value");if(_)this.#D(_);if(this.querySelector(".fig-3d-rotate-container"))this.#O();else this.#H();this.#A(this.getAttribute("selected")),this.#L()}disconnectedCallback(){this.#Q=!1,this.#M()}#O(){this.#q=this.querySelector(".fig-3d-rotate-container"),this.#G=this.querySelector(".fig-3d-rotate-cube"),this.#z(),this.#T(),this.#V()}#M(){if(this.#Y?.abort(),this.#Y=null,this.#N)window.removeEventListener("keydown",this.#N),window.removeEventListener("keyup",this.#X),this.#N=null,this.#X=null}#B(_){if(!_||!_.trim()){this.style.removeProperty("--transform-origin");return}let Z=_.trim().split(/\s+/);if(Z.length===2)this.style.setProperty("--transform-origin",`${Z[0]} ${Z[1]} -50cqi`);else this.style.setProperty("--transform-origin",_.trim())}#L(){if(!this.#q)return;this.#q.style.cursor=this.#k?"":"default"}#A(_){if(!this.#G)return;let Z=this.#G.querySelectorAll(".fig-3d-rotate-face"),$=_?_.trim().toLowerCase():"";for(let J of Z)J.classList.toggle("selected",$!==""&&J.classList.contains($))}#I(_){if(!_||!_.trim()){this.#R=[];return}let Z=["rotateX","rotateY","rotateZ"];this.#R=_.split(",").map(($)=>$.trim()).filter(($)=>Z.includes($))}attributeChangedCallback(_,Z,$){if(_==="aspect-ratio"){p(this,"--aspect-ratio",$);return}if(_==="perspective"){p(this,"--perspective",$);return}if(_==="perspective-origin"){p(this,"--perspective-origin",$);return}if(_==="transform-origin"){this.#B($);return}if(_==="selected"){this.#A($);return}if(_==="drag"){this.#L();return}if(_==="fields"){if(this.#I($),this.#G)this.#H();return}if(!this.#G)return;if(_==="value"&&$){if(this.#Q)return;this.#D($),this.#T(),this.#F()}if(_==="precision")this.#$=parseInt($||"1")}get value(){let _=this.#$;return`rotateX(${this.#Z.toFixed(_)}deg) rotateY(${this.#_.toFixed(_)}deg) rotateZ(${this.#J.toFixed(_)}deg)`}set value(_){this.setAttribute("value",_)}get rotateX(){return this.#Z}get rotateY(){return this.#_}get rotateZ(){return this.#J}#D(_){let Z=_.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),$=_.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),J=_.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if(Z)this.#Z=parseFloat(Z[1]);if($)this.#_=parseFloat($[1]);if(J)this.#J=parseFloat(J[1])}#H(){let _={rotateX:"X",rotateY:"Y",rotateZ:"Z"},Z={rotateX:this.#Z,rotateY:this.#_,rotateZ:this.#J},$=M("div",{className:"fig-3d-rotate-cube"},["front","back","right","left","top","bottom"].map((j)=>M("div",{className:`fig-3d-rotate-face ${j}`}))),J=M("div",{className:"fig-3d-rotate-container",tabindex:"0"},M("div",{className:"fig-3d-rotate-scene"},$)),Q=this.#R.map((j)=>M("fig-input-number",{name:j,step:"1",precision:"1",value:Z[j],units:"°"},M("span",{slot:"prepend"},_[j])));this.replaceChildren(J,...Q),this.#q=J,this.#G=$,this.#z(),this.#T(),this.#V()}#z(){this.#U={};for(let _ of this.#R){let Z=this.querySelector(`fig-input-number[name="${_}"]`);if(!Z)continue;if(this.#U[_]=Z,!this.#W[_])this.#W[_]=(J)=>{J.stopPropagation();let Q=parseFloat(J.target.value);if(isNaN(Q))return;if(_==="rotateX")this.#Z=Q;else if(_==="rotateY")this.#_=Q;else if(_==="rotateZ")this.#J=Q;this.#T(),this.#S(J.type)};let $=this.#W[_];Z.removeEventListener("input",$),Z.removeEventListener("change",$),Z.addEventListener("input",$),Z.addEventListener("change",$)}}#F(){let _={rotateX:this.#Z,rotateY:this.#_,rotateZ:this.#J};for(let Z of this.#R){let $=this.#U[Z];if($)$.setAttribute("value",_[Z].toFixed(this.#$))}}#T(){if(!this.#G)return;this.#G.style.transform=`rotateX(${this.#Z}deg) rotateY(${this.#_}deg) rotateZ(${this.#J}deg)`}#S(_){this.dispatchEvent(new CustomEvent(_,{bubbles:!0,detail:{value:this.value,rotateX:this.#Z,rotateY:this.#_,rotateZ:this.#J}}))}#P(_){if(!this.#j)return _;return Math.round(_/15)*15}#V(){if(this.#M(),!this.#q)return;this.#Y=new AbortController,this.#q.addEventListener("pointerdown",this.#K,{signal:this.#Y.signal}),this.#N=(_)=>{if(_.key==="Shift")this.#j=!0},this.#X=(_)=>{if(_.key==="Shift")this.#j=!1},window.addEventListener("keydown",this.#N),window.addEventListener("keyup",this.#X)}get#k(){let _=this.getAttribute("drag");return _===null||_.toLowerCase()!=="false"}#C(_){if(!this.#k)return;_.preventDefault(),this.#Q=!0,this.#q.classList.add("dragging"),this.#q.setPointerCapture(_.pointerId);let{clientX:Z,clientY:$}=_,J=this.#Z,Q=this.#_,j=(N)=>{if(!this.#Q)return;if(N.buttons===0){q();return}let G=N.clientX-Z,K=N.clientY-$;this.#_=this.#P(Q+G*0.5),this.#Z=this.#P(J-K*0.5),this.#T(),this.#F(),this.setAttribute("value",this.value),this.#S("input")},q=()=>{if(!this.#Q)return;this.setAttribute("value",this.value),this.#Q=!1,this.#q.classList.remove("dragging"),this.#q.removeEventListener("pointermove",j),this.#q.removeEventListener("pointerup",q),this.#q.removeEventListener("pointercancel",q),this.#q.removeEventListener("lostpointercapture",q),this.#S("change")};this.#q.addEventListener("pointermove",j),this.#q.addEventListener("pointerup",q),this.#q.addEventListener("pointercancel",q),this.#q.addEventListener("lostpointercapture",q)}}F("fig-3d-rotate",w_);class P0 extends HTMLElement{#Z=50;#_=50;#J=0;#$=null;#Q=[];#j=null;#G=null;#q=null;#N=!1;#X=!1;#K=null;#Y=null;#R=null;static SNAP_POINTS=[0,16.6667,33.3333,50,66.6667,83.3333,100];static get observedAttributes(){return["value","precision","aspect-ratio","drag","fields"]}#U(){this.#$=this.querySelector(".origin-grid"),this.#Q=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#j=this.querySelector("fig-handle"),this.#G=this.querySelector('fig-input-number[name="x"]'),this.#q=this.querySelector('fig-input-number[name="y"]'),this.#T(),this.#S(),this.#H(),this.#v()}connectedCallback(){if(this.#J=parseInt(this.getAttribute("precision")||"0"),p(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#I(this.getAttribute("value")),this.querySelector(".fig-origin-grid-surface"))this.#U();else this.#D();this.#M(),this.#z()}disconnectedCallback(){this.#N=!1,this.#w(),this.#b()}get value(){let _=this.#J;return`${this.#Z.toFixed(_)}% ${this.#_.toFixed(_)}%`}set value(_){this.setAttribute("value",_)}attributeChangedCallback(_,Z,$){if(_==="aspect-ratio"){p(this,"--aspect-ratio",$);return}if(_==="drag"){this.#M();return}if(_==="fields"){this.#D(),this.#M(),this.#z();return}if(_==="precision"){this.#J=parseInt($||"0"),this.#H(),this.#z();return}if(_==="value"){if(this.#X||this.#N)return;this.#I($),this.#T(),this.#S(),this.#H()}}get#W(){let _=this.getAttribute("drag");return _===null||_.toLowerCase()!=="false"}get#O(){let _=this.getAttribute("fields");if(_===null)return!1;return _.toLowerCase()!=="false"}#M(){if(!this.#$)return;this.#$.classList.toggle("drag-disabled",!this.#W)}#B(_){return Math.max(0,Math.min(100,_))}#L(_,Z){let $=(_||"").trim().toLowerCase();if(!$)return Z==="x"?this.#Z:this.#_;let J=Z==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if($ in J)return J[$];let Q=Number.parseFloat($.replace("%",""));if(Number.isFinite(Q))return Q;return Z==="x"?this.#Z:this.#_}#A(_){let Z=_.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if(Z.length<1)return;if(Z.length===1){let $=this.#L(Z[0],"x");this.#Z=$,this.#_=$;return}this.#Z=this.#L(Z[0],"x"),this.#_=this.#L(Z[1],"y")}#I(_){let Z=typeof _==="string"?_.trim():"";if(!Z){this.#Z=50,this.#_=50;return}this.#A(Z)}#D(){let _=Array.from({length:9},(N,G)=>{let K=G%3,X=Math.floor(G/3);return M("span",{className:"origin-grid-cell","data-col":K,"data-row":X},M("span",{className:"origin-grid-dot"}))}),Z=this.#Z.toFixed(this.#J),$=this.#_.toFixed(this.#J),J=document.createElement("fig-handle"),Q=M("div",{className:"origin-grid","aria-label":"Transform origin grid"},[M("div",{className:"origin-grid-cells"},_),J]),q=[M("div",{className:"fig-origin-grid-surface"},Q)];if(this.#O){let N=(G,K)=>M("fig-input-number",{name:G,value:K,step:"1",units:"%"},M("span",{slot:"prepend"},G.toUpperCase()));q.push(M("div",{className:"origin-values"},[N("x",Z),N("y",$)]))}this.replaceChildren(...q),this.#$=Q,this.#Q=_,this.#j=J,this.#G=this.querySelector('fig-input-number[name="x"]'),this.#q=this.querySelector('fig-input-number[name="y"]'),this.#T(),this.#S(),this.#H(),this.#v()}#H(){let _=this.#Z.toFixed(this.#J),Z=this.#_.toFixed(this.#J);if(this.#G)this.#G.setAttribute("value",_);if(this.#q)this.#q.setAttribute("value",Z)}#z(){let _=this.value;if(this.getAttribute("value")===_)return;this.#X=!0,this.setAttribute("value",_),this.#X=!1}#F(_){this.dispatchEvent(new CustomEvent(_,{bubbles:!0,detail:{value:this.value,x:this.#Z,y:this.#_}}))}#T(){if(!this.#j)return;let _=(Z)=>16.6667+this.#B(Z)/100*66.6667;this.#j.style.left=`${_(this.#Z)}%`,this.#j.style.top=`${_(this.#_)}%`}#S(){if(!this.#j)return;let _=this.#Z<0||this.#Z>100,Z=this.#_<0||this.#_>100,$=this.#Z<0,J=this.#Z>100,Q=this.#_<0,j=this.#_>100;this.#j.classList.toggle("beyond-bounds-x",_),this.#j.classList.toggle("beyond-bounds-y",Z),this.#j.classList.toggle("overflow-left",$),this.#j.classList.toggle("overflow-right",J),this.#j.classList.toggle("overflow-up",Q),this.#j.classList.toggle("overflow-down",j)}#P(_,Z){if(!this.#$)return null;let $=this.#$.getBoundingClientRect(),J=(_-$.left)/Math.max($.width,1),Q=(Z-$.top)/Math.max($.height,1);if(J<0||J>1||Q<0||Q>1)return null;let j=Math.max(0,Math.min(2,Math.floor(J*3))),q=Math.max(0,Math.min(2,Math.floor(Q*3)));return this.#Q.find((N)=>Number(N.getAttribute("data-col"))===j&&Number(N.getAttribute("data-row"))===q)}#V(){for(let _ of this.#Q)_.classList.remove("is-hovered")}#k(_){if(this.#V(),_)_.classList.add("is-hovered")}#C(_,Z,$){let J=Number(_),Q=Number(Z);if(!Number.isFinite(J)||!Number.isFinite(Q))return;if(J===this.#Z&&Q===this.#_&&$==="input")return;this.#Z=J,this.#_=Q,this.#T(),this.#S(),this.#H(),this.#z(),this.#F($)}#h(_,Z){if(!this.#$)return{x:this.#Z,y:this.#_};let $=this.#$.getBoundingClientRect(),J=$.width/6,Q=$.height/6,j=Math.max(1,$.width-J*2),q=Math.max(1,$.height-Q*2),N=(_-($.left+J))/j,G=(Z-($.top+Q))/q;return{x:N*100,y:G*100}}#E(_,Z){if(!this.#$)return{x:50,y:50};let $=this.#$.getBoundingClientRect(),J=(_-$.left)/Math.max($.width,1)*3,Q=(Z-$.top)/Math.max($.height,1)*3,j=Math.max(0,Math.min(2,Math.floor(J))),q=Math.max(0,Math.min(2,Math.floor(Q)));return{x:j*50,y:q*50}}#f(_){let $=_,J=1/0;for(let Q of P0.SNAP_POINTS){let j=Math.abs(_-Q);if(j<J)J=j,$=Q}return J<=2.5?$:_}#x(_,Z){if(!Z)return _;return{x:this.#f(_.x),y:this.#f(_.y)}}#g(_){if(!this.#W)return!1;let Z=_.shiftKey?10:1,$=this.#Z,J=this.#_;switch(_.key){case"ArrowLeft":$-=Z;break;case"ArrowRight":$+=Z;break;case"ArrowUp":J-=Z;break;case"ArrowDown":J+=Z;break;case"Home":$=0,J=0;break;case"End":$=100,J=100;break;default:return!1}return this.#C(this.#B($),this.#B(J),"input"),this.#F("change"),!0}#w(){if(!this.#$||!this.#Y||!this.#R)return;this.#$.removeEventListener("pointermove",this.#Y),this.#$.removeEventListener("pointerup",this.#R),this.#$.removeEventListener("pointercancel",this.#R),this.#$.removeEventListener("lostpointercapture",this.#R),this.#Y=null,this.#R=null}#p(_){if(!this.#$||!this.#W)return;_.preventDefault(),this.#N=!0,this.#K=_.pointerId;let{clientX:Z,clientY:$}=_,J=3,Q=!1;this.#$.setPointerCapture(_.pointerId),this.#Y=(j)=>{if(!this.#N||j.pointerId!==this.#K)return;let q=j.clientX-Z,N=j.clientY-$,G=Math.hypot(q,N);if(!Q&&G<J)return;if(!Q)Q=!0,this.#$.classList.add("is-dragging"),this.#V();let K=this.#x(this.#h(j.clientX,j.clientY),j.shiftKey);this.#C(K.x,K.y,"input")},this.#R=(j)=>{if(!this.#N||j.pointerId!==this.#K)return;if(this.#N=!1,this.#K=null,this.#$.classList.remove("is-dragging"),this.#V(),this.#w(),!Q){let q=this.#E(Z,$);this.#C(q.x,q.y,"input")}this.#F("change")},this.#$.addEventListener("pointermove",this.#Y),this.#$.addEventListener("pointerup",this.#R),this.#$.addEventListener("pointercancel",this.#R),this.#$.addEventListener("lostpointercapture",this.#R)}#y=null;#b(){this.#y?.abort(),this.#y=null}#v(){if(this.#b(),!this.#$||!this.#j)return;this.#y=new AbortController;let{signal:_}=this.#y;this.#$.addEventListener("pointerdown",($)=>{let J=this.#P($.clientX,$.clientY);if(this.#k(J),this.#W){this.#p($);return}let Q=this.#E($.clientX,$.clientY);this.#C(Q.x,Q.y,"input"),this.#F("change")},{signal:_}),this.#$.addEventListener("pointermove",($)=>{if(this.#N)return;let J=this.#P($.clientX,$.clientY);this.#k(J)},{signal:_}),this.#$.addEventListener("pointerleave",()=>{this.#V()},{signal:_}),this.#j.addEventListener("keydown",($)=>{if(!this.#g($))return;$.preventDefault(),$.stopPropagation()},{signal:_});let Z=($,J)=>{if(!$)return;let Q=(j)=>{let q=Number.parseFloat(j.target.value);if(!Number.isFinite(q))return;if(J==="x")this.#C(q,this.#_,"input");else this.#C(this.#Z,q,"input")};$.addEventListener("input",Q,{signal:_}),$.addEventListener("change",Q,{signal:_}),$.addEventListener("focusout",()=>{this.#F("change")},{signal:_})};Z(this.#G,"x"),Z(this.#q,"y")}}F("fig-origin-grid",P0);class y_ extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#q=null;#N=!1;#X={x:0.5,y:0.5};#K=!1;constructor(){super();this.position={x:0.5,y:0.5},this.isDragging=!1,this.plane=null,this.cursor=null,this.xInput=null,this.yInput=null,this.coordinates="screen",this.#Z=(_)=>this.#H(_),this.#_=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#J=(_)=>this.#z(_),this.#$=()=>this.#F(),this.#Q=(_)=>this.#L(_),this.#j=(_)=>this.#A(_),this.#G=()=>this.#I(),this.#q=()=>this.#I()}#Y(){this.#M(),this.#P(),this.#k(),this.#C(),this.#K=!0}connectedCallback(){u(this,()=>{if(this.precision=this.getAttribute("precision")||3,this.precision=parseInt(this.precision),this.transform=this.getAttribute("transform")||1,this.transform=Number(this.transform),this.coordinates=this.getAttribute("coordinates")||"screen",p(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");if(this.querySelector(".fig-input-joystick-plane")){this.#Y();return}this.#W(),this.#M(),this.#P(),this.#k(),this.#C(),this.#K=!0})}#R(_){return this.coordinates==="math"?1-_:_}disconnectedCallback(){this.#B()}get#U(){let _=this.getAttribute("fields");if(_===null)return!1;return _.toLowerCase()!=="false"}#W(){let _=this.#O(),Z=M("div",{className:"fig-input-joystick-plane-container"}),$=(q,N)=>N?M("label",{className:["fig-joystick-axis-label",q].join(" "),"aria-hidden":"true"},N):null;Z.append(...[$("left",_.left),$("right",_.right),$("top",_.top),$("bottom",_.bottom)].filter(Boolean));let J=M("div",{className:"fig-input-joystick-plane"},[M("div",{className:"fig-input-joystick-guides"}),M("fig-handle",{drag:!0,"drag-surface":".fig-input-joystick-plane","drag-axes":"x,y","drag-snapping":"modifier"})]),Q=M("fig-tooltip",{text:"Reset"},M("fig-button",{variant:"ghost",icon:"true",className:"fig-joystick-reset","aria-label":"Reset to default"},b("reset",{size:"small"})));Z.append(J,Q);let j=[Z];if(this.#U){let q=(N,G)=>M("fig-input-number",{name:N,step:"1",value:G,min:"0",max:"100",units:"%"},M("span",{slot:"prepend"},N.toUpperCase()));j.push(M("div",{className:"joystick-values"},[q("x",(this.position.x*100).toFixed(this.precision)),q("y",(this.position.y*100).toFixed(this.precision))]))}this.replaceChildren(...j)}#O(){let _=(this.getAttribute("axis-labels")||"").trim();if(!_)return{left:"",right:"",top:"",bottom:""};let Z=_.split(/[\s,]+/).filter(Boolean);if(Z.length===1)return{left:"",right:"",top:Z[0],bottom:""};if(Z.length===2){let[$,J]=Z;return{left:$,right:"",top:"",bottom:J}}if(Z.length===4){let[$,J,Q,j]=Z;return{left:$,right:J,top:Q,bottom:j}}return{left:"",right:"",top:"",bottom:""}}#M(){this.plane=this.querySelector(".fig-input-joystick-plane"),this.cursor=this.querySelector("fig-handle"),this.xInput=this.querySelector("fig-input-number[name='x']"),this.yInput=this.querySelector("fig-input-number[name='y']"),this.plane?.addEventListener("pointerdown",this.#Z),this.cursor?.addEventListener("pointerdown",this.#_),this.cursor?.addEventListener("input",this.#J),this.cursor?.addEventListener("change",this.#$);let _=this.querySelector(".fig-joystick-reset");if(_)_.addEventListener("click",()=>this.#h());if(this.#U&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#Q),this.xInput.addEventListener("change",this.#Q),this.xInput.addEventListener("focusout",this.#G),this.yInput.addEventListener("input",this.#j),this.yInput.addEventListener("change",this.#j),this.yInput.addEventListener("focusout",this.#q)}#B(){if(this.plane?.removeEventListener("pointerdown",this.#Z),this.cursor?.removeEventListener("pointerdown",this.#_),this.cursor?.removeEventListener("input",this.#J),this.cursor?.removeEventListener("change",this.#$),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#U&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#Q),this.xInput.removeEventListener("change",this.#Q),this.xInput.removeEventListener("focusout",this.#G),this.yInput.removeEventListener("input",this.#j),this.yInput.removeEventListener("change",this.#j),this.yInput.removeEventListener("focusout",this.#q)}#L(_){let Z=Number.parseFloat(_.target.value);if(!Number.isFinite(Z))return;this.position.x=Math.max(0,Math.min(1,Z/100)),this.#P(),this.#k(),this.#T()}#A(_){let Z=Number.parseFloat(_.target.value);if(!Number.isFinite(Z))return;this.position.y=Math.max(0,Math.min(1,Z/100)),this.#P(),this.#k(),this.#T()}#I(){this.#k(),this.#S()}#D(_,Z,{syncHandle:$=!0}={}){let J=Math.max(0,Math.min(1,_)),Q=Math.max(0,Math.min(1,Z)),j=this.coordinates==="math"?1-Q:Q;if(this.position={x:J,y:j},$)this.#P();this.#V(),this.#k()}#H(_){if(!this.plane||!this.cursor)return;if(_.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let Z=this.plane.getBoundingClientRect(),$=Z.width>0?(_.clientX-Z.left)/Z.width:0.5,J=Z.height>0?(_.clientY-Z.top)/Z.height:0.5;this.cursor.value=`${Math.round($*100)}% ${Math.round(J*100)}%`,this.#D($,J,{syncHandle:!1}),this.#T(),this.#S()}#z(_){let Z=_.detail??{};if(typeof Z.px!=="number"||typeof Z.py!=="number")return;this.#D(Z.px,Z.py,{syncHandle:!1}),this.#T()}#F(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#k(),this.#S()}#T(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#S(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#P(){let _=this.#R(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${_*100}%`;this.#V()}#V(){if(this.#U&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#k(){let _=this.value;if(this.getAttribute("value")!==_)this.#N=!0,this.setAttribute("value",_),this.#N=!1;this.#C()}#C(){let _=this.#X,Z=Math.round(this.position.x*100)===Math.round(_.x*100)&&Math.round(this.position.y*100)===Math.round(_.y*100);this.toggleAttribute("default",Z),this.style.setProperty("--is-not-default",Z?"0":"1")}#h(){this.position={...this.#X},this.#P(),this.#k(),this.#T(),this.#S()}focus(){this.cursor?.focus()}static get observedAttributes(){return["value","precision","transform","fields","coordinates","aspect-ratio","axis-labels"]}get value(){return`${Math.round(this.position.x*100)}% ${Math.round(this.position.y*100)}%`}set value(_){let Z=_==null?"":String(_).trim();if(!Z)this.position={x:0.5,y:0.5};else{let $=Z.split(/[\s,]+/).filter(Boolean),J=(q)=>{if(!q)return 0.5;let N=q.includes("%"),G=Number.parseFloat(q.replace(/%/g,"").trim());if(!Number.isFinite(G))return 0.5;let K=N||Math.abs(G)>1?G/100:G;return Math.max(0,Math.min(1,K))},Q=J($[0]),j=J($[1]??$[0]);this.position={x:Q,y:j}}if(this.#K)this.#P(),this.#C()}attributeChangedCallback(_,Z,$){if(_==="aspect-ratio"){p(this,"--aspect-ratio",$);return}if(_==="value"){if(this.#N||this.isDragging)return;this.value=$}if(_==="precision")this.precision=parseInt($);if(_==="transform")this.transform=Number($);if(_==="fields"&&$!==Z)this.#B(),this.#W(),this.#M(),this.#P();if(_==="axis-labels"&&$!==Z)this.#B(),this.#W(),this.#M(),this.#P();if(_==="coordinates")this.coordinates=$||"screen",this.#P()}}F("fig-joystick",y_);class S0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let _=this.getAttribute("duration");if(_)this.style.setProperty(this.durationPropertyName,_);this.#Z()}static get observedAttributes(){return["duration","playing","aria-label","aria-labelledby"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(_){if(_)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(_,Z,$){if(_==="duration")this.style.setProperty(this.durationPropertyName,$||"1.5s");if(_==="playing"||_==="aria-label"||_==="aria-labelledby")this.#Z()}#Z(){let _=this.playing;if(this.setAttribute("aria-busy",_?"true":"false"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")){if(!this.hasAttribute("role"))this.setAttribute("role","status");this.removeAttribute("aria-hidden")}else this.removeAttribute("role"),this.setAttribute("aria-hidden","true")}}F("fig-shimmer",S0);class h_ extends S0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}F("fig-skeleton",h_);class b_ extends HTMLElement{static observedAttributes=["name","collapsible","open","compact","chevron"];#Z=null;#_=null;#J=null;#$=null;#Q=null;connectedCallback(){this.#Y()}disconnectedCallback(){this.#j()}#j(){if(this.#_?.removeEventListener("click",this.#X),this.#J?.removeEventListener("click",this.#X),this.#J?.removeEventListener("keydown",this.#K),this.#Z)this.#Z.removeEventListener("click",this.#X),this.#Z.removeEventListener("keydown",this.#K)}attributeChangedCallback(_,Z,$){if(Z===$)return;if(!this.isConnected)return;if(_==="open"){this.#G();return}this.#Y()}get open(){let _=this.getAttribute("open");return _!==null&&_!=="false"}set open(_){let Z=this.open;if(_)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#G(),Z!==!!_)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!_},bubbles:!0}))}#G(){if(this.hasAttribute("collapsible"))this.#J?.setAttribute("aria-expanded",String(this.open));else this.#J?.removeAttribute("aria-expanded")}#q(){if(!this.#$)return;if(this.#Q===null)this.#$.removeAttribute("compact");else this.#$.setAttribute("compact",this.#Q);this.#$=null,this.#Q=null}#N(){if(!(this.hasAttribute("compact")&&this.getAttribute("compact")!=="false")){this.#q();return}if(this.#$!==this.#Z)this.#q(),this.#$=this.#Z,this.#Q=this.#Z?.getAttribute("compact")??null;this.#Z?.setAttribute("compact","")}#X=(_)=>{_.stopPropagation(),this.open=!this.open};#K=(_)=>{if(_.key!=="Enter"&&_.key!==" ")return;_.preventDefault(),_.stopPropagation(),this.open=!this.open};#Y(){this.#j();let _=this.hasAttribute("collapsible"),$=this.getAttribute("name")||(_?"Group":null),J=this.querySelector(":scope > fig-header:not([data-generated])");if(!$&&!_&&!J){if(this.#Z&&this.#Z.dataset.generated)this.#q(),this.#Z.remove(),this.#Z=null,this.#_=null,this.#J=null;return}if(J)this.querySelectorAll(":scope > fig-header[data-generated]").forEach((j)=>j.remove()),this.#Z=J;else if(!this.#Z||!this.#Z.dataset.generated)this.#Z=document.createElement("fig-header"),this.#Z.setAttribute("borderless",""),this.#Z.dataset.generated="true",this.prepend(this.#Z);this.#N();let Q=this.#Z.querySelector("h3");if(!Q)Q=document.createElement("h3"),this.#Z.prepend(Q);if(this.#J=Q,!Q.id)Q.id=g();if(this.#Z.dataset.generated)Q.textContent=$;if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",Q.id);if(_){let j=this.#Z.querySelector(".fig-group-chevron");if(!j)j=b("chevron",{size:"small",className:"fig-group-chevron"});let q=this.getAttribute("chevron")==="end";if(j.setAttribute("size",q?"medium":"small"),q){if(Q.nextSibling!==j)this.#Z.insertBefore(j,Q.nextSibling)}else if(Q.previousSibling!==j)this.#Z.insertBefore(j,Q);if(this.#_=j,this.#Z.removeAttribute("role"),this.#Z.removeAttribute("tabindex"),this.#Z.removeAttribute("aria-expanded"),Q.setAttribute("role","button"),Q.setAttribute("tabindex","0"),Q.setAttribute("aria-expanded",String(this.open)),Q.addEventListener("click",this.#X),Q.addEventListener("keydown",this.#K),j.addEventListener("click",this.#X),!this.hasAttribute("open"))this.setAttribute("open","false"),Q.setAttribute("aria-expanded","false")}else{if(Q.removeAttribute("role"),Q.removeAttribute("tabindex"),Q.removeAttribute("aria-expanded"),this.#Z.removeAttribute("role"),this.#Z.removeAttribute("tabindex"),this.#Z.removeAttribute("aria-expanded"),this.#_)this.#_.remove(),this.#_=null;this.removeAttribute("open")}}}F("fig-group",b_);class g_ extends HTMLElement{}F("fig-header",g_);class v_ extends HTMLElement{}F("fig-footer",v_);class m_ extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Loading")}}F("fig-spinner",m_);class p_ extends HTMLElement{static get observedAttributes(){return["fit","aspect-ratio"]}connectedCallback(){this.#Z(),this.#_()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="fit")this.#Z();if(_==="aspect-ratio")this.#_()}#Z(){let _=this.getAttribute("fit");if(_)this.style.setProperty("--fig-preview-fit",_);else this.style.removeProperty("--fig-preview-fit")}#_(){let _=this.getAttribute("aspect-ratio");if(_)this.style.setProperty("--fig-preview-aspect-ratio",_);else this.style.removeProperty("--fig-preview-aspect-ratio")}}F("fig-preview",p_);var B1={chevron:{medium:"--icon-24-chevron",small:"--icon-16-chevron"},checkmark:{medium:"--icon-24-checkmark",small:"--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",send:{medium:"--icon-24-send",small:"--icon-16-send"},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",image:"--icon-24-image",video:{medium:"--icon-24-video",small:"--icon-16-video"},audio:"--icon-24-audio",sound:{medium:"--icon-24-sound",small:"--icon-16-sound"},"sound-off":{medium:"--icon-24-sound-off",small:"--icon-16-sound-off"},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"},globe:{medium:"--icon-24-globe",small:"--icon-16-globe"},warning:{medium:"--icon-24-warning",small:"--icon-16-warning"},copy:{medium:"--icon-24-copy",small:"--icon-16-copy"},trash:{medium:"--icon-24-trash",small:"--icon-16-trash"},"drag-handle":"--icon-16-drag-handle"};function H1(_,Z="medium"){let $=_&&B1[_];if(!$)return"";let J=typeof $==="string"?$:$[Z==="small"?"small":"medium"];return J?`var(${J})`:""}var F1={primary:"--figma-color-icon",secondary:"--figma-color-icon-secondary",tertiary:"--figma-color-icon-tertiary",disabled:"--figma-color-icon-disabled",brand:"--figma-color-icon-brand",component:"--figma-color-icon-component",danger:"--figma-color-icon-danger",success:"--figma-color-icon-success",warning:"--figma-color-icon-warning",selected:"--figma-color-icon-selected",hover:"--figma-color-icon-hover",pressed:"--figma-color-icon-pressed",onbrand:"--figma-color-icon-onbrand",oncomponent:"--figma-color-icon-oncomponent",ondanger:"--figma-color-icon-ondanger",ondisabled:"--figma-color-icon-ondisabled",oninverse:"--figma-color-icon-oninverse",onselected:"--figma-color-icon-onselected",onsuccess:"--figma-color-icon-onsuccess",onwarning:"--figma-color-icon-onwarning"};function A1(_){if(!_)return"";if(_.startsWith("var("))return _;let Z=F1[_.toLowerCase()];return Z?`var(${Z})`:_}class u_ extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#Z()}attributeChangedCallback(_,Z,$){if(Z!==$)this.#Z()}#Z(){let _=this.getAttribute("name"),Z=this.getAttribute("size")||"medium",$=H1(_,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=A1(this.getAttribute("color"));if(J)this.style.backgroundColor=J,this.style.setProperty("--icon-color",J);else this.style.removeProperty("background-color"),this.style.removeProperty("--icon-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}F("fig-icon",u_);class c_ extends HTMLElement{}F("fig-content",c_);class d_ extends HTMLElement{}F("fig-tab-content",d_);class s_ extends HTMLElement{}F("fig-button-combo",s_);class i_ extends HTMLElement{}F("fig-input-combo",i_);class o_ extends HTMLElement{static get observedAttributes(){return["gap","columns","min-width"]}connectedCallback(){this.#Z()}attributeChangedCallback(){this.#Z()}#Z(){let _=this.getAttribute("gap")?.trim();this.#_("--fig-stack-gap",_&&/^(\d+(-5)?|half)$/.test(_)?`var(--spacer-${_})`:_);let Z=this.getAttribute("columns")?.trim();this.#_("--fig-stack-columns",Z&&/^\d+$/.test(Z)?`repeat(${Z}, minmax(0, 1fr))`:Z),this.#_("--fig-stack-min-width",this.getAttribute("min-width")?.trim())}#_(_,Z){if(Z)this.style.setProperty(_,Z);else this.style.removeProperty(_)}}F("fig-stack",o_);class r_ extends HTMLElement{#Z=null;#_=null;#J=null;#$=this.#B.bind(this);#Q=this.#L.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#j(){return this.getAttribute("control")||"color"}connectedCallback(){this.#X(),this.#W()}disconnectedCallback(){this.#G(),this.removeEventListener("click",this.#K)}#G(){if(this.#Z)this.#Z.removeEventListener("input",this.#$),this.#Z.removeEventListener("change",this.#Q);if(this.#_)this.#_.removeEventListener("input",this.#$),this.#_.removeEventListener("change",this.#Q);if(this.#J)this.#J.disconnect(),this.#J=null}#q(){if(this.#J)this.#J.disconnect(),this.#J=null;if(!this.#_)return;this.#J=new MutationObserver(()=>{if(this.#_?.hasAttribute("selected")&&this.#_.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#J.observe(this.#_,{attributes:!0,attributeFilter:["selected"]})}get#N(){let _=this.getAttribute("alpha");return _===null||_!=="false"}#X(){this.#G();let _=this.#j;if(_==="add"||_==="remove"){let N=_==="add"?"add":"minus",G=this.getAttribute("aria-label")||(_==="add"?"Add color stop":"Remove color stop");this.replaceChildren(M("fig-button",{icon:!0,variant:"ghost","aria-label":G},b(N))),this.#Z=null,this.#_=null,this.addEventListener("click",this.#K),this.#O();return}this.removeEventListener("click",this.#K);let Z=(this.getAttribute("value")||"").trim(),$=this.#U(Z),J=this.#R(Z),Q=J<1?JSON.stringify({type:"solid",color:$,opacity:Math.round(J*100)}):JSON.stringify({type:"solid",color:$}),j=M("fig-swatch",{background:$,alpha:J<1?J:null}),q=null;if(q0())q=M("fig-fill-picker",{mode:"solid",alpha:this.#N?null:"false",value:Q},j),this.replaceChildren(q);else this.replaceChildren(j);if(this.#Z=q,this.#_=j,this.#Z?.addEventListener("input",this.#$),this.#Z?.addEventListener("change",this.#Q),!this.#Z)this.#_?.addEventListener("input",this.#$),this.#_?.addEventListener("change",this.#Q);this.#q(),this.#O()}#K=()=>{let _=this.#j;this.dispatchEvent(new CustomEvent(_,{bubbles:!0,composed:!0}))};#Y(_){if(!_)return"#D9D9D9";let Z=_.replace("#","").trim();if(Z.length===3||Z.length===4){let[$,J,Q]=Z;return`#${$}${$}${J}${J}${Q}${Q}`.toUpperCase()}if(Z.length===6||Z.length===8)return`#${Z.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#R(_){if(!_)return 1;let Z=String(_).trim(),$=Z.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test($)){let Q=$[3];return parseInt(`${Q}${Q}`,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(_){if(!_)return"#D9D9D9";let Z=String(_).trim();if(Z.startsWith("{"))try{let $=JSON.parse(Z);if($?.color)return this.#U($.color)}catch{}if(Z.startsWith("#"))return this.#Y(Z);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Z))return this.#Y(Z);try{let{ctx:$}=D0(1,1);$.fillStyle="#000000",$.fillStyle=Z;let J=$.fillStyle;if(J.startsWith("#"))return this.#Y(J);let Q=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(Q){let j=(q)=>Math.max(0,Math.min(255,Number(q))).toString(16).padStart(2,"0");return`#${j(Q[1])}${j(Q[2])}${j(Q[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#W(){let _=this.getAttribute("value"),Z=this.#U(_),$=this.#R(_);if(_!==Z&&$>=1){this.setAttribute("value",Z);return}if(this.#Z){this.#O();let J=$<1?{type:"solid",color:Z,opacity:Math.round($*100)}:{type:"solid",color:Z};if(this.#Z.setAttribute("value",JSON.stringify(J)),this.#N)this.#Z.removeAttribute("alpha");else this.#Z.setAttribute("alpha","false");if(T(this,"disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}if(this.#_){if(this.#O(),this.#_.setAttribute("background",Z),$<1)this.#_.setAttribute("alpha",String($));else this.#_.removeAttribute("alpha");if(T(this,"disabled"))this.#_.setAttribute("disabled","");else this.#_.removeAttribute("disabled")}}#O(){let _=this.#j,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"),_==="add"||_==="remove"){let N=this.querySelector("fig-button"),G=this.getAttribute("aria-label")||(_==="add"?"Add color stop":"Remove color stop");if(N?.setAttribute("aria-label",G),Z)N?.setAttribute("disabled","");else N?.removeAttribute("disabled");return}let J=this.#Z||this.#_;if(!J)return;let Q=this.getAttribute("aria-label")||"Color stop",j=this.getAttribute("aria-labelledby"),q=this.getAttribute("aria-describedby");if(j)J.setAttribute("aria-labelledby",j),J.removeAttribute("aria-label");else J.setAttribute("aria-label",Q),J.removeAttribute("aria-labelledby");if(q)J.setAttribute("aria-describedby",q);else J.removeAttribute("aria-describedby")}#M(_,Z){let $=this.#U(_?.color),J=this.#U(this.getAttribute("value"));if($!==J)this.setAttribute("value",$);else this.#W();let Q={color:this.value};if(this.#N){if(_?.opacity!==void 0)Q.opacity=_.opacity;else if(_?.alpha!==void 0)Q.opacity=Math.round(_.alpha*100)}Object.assign(Q,t(Q.color,this.#N?_?.alpha:1,Q.opacity)),this.dispatchEvent(new CustomEvent(Z,{bubbles:!0,cancelable:!0,composed:!0,detail:Q}))}#B(_){_.stopPropagation(),this.#M(_.detail||{color:_.target?.value},"input")}#L(_){_.stopPropagation(),this.#M(_.detail||{color:_.target?.value},"change")}attributeChangedCallback(_,Z,$){if(Z===$)return;if(!this.isConnected)return;switch(_){case"control":this.#X();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#W(),this.#O();break}}get value(){return this.#U(this.getAttribute("value"))}set value(_){if(_===null||_===void 0||_===""){this.removeAttribute("value");return}this.setAttribute("value",this.#U(_))}get selected(){return T(this,"selected")}set selected(_){this.toggleAttribute("selected",Boolean(_))}get disabled(){return T(this,"disabled")}set disabled(_){this.toggleAttribute("disabled",Boolean(_))}}F("fig-color-tip",r_);class l_ extends HTMLElement{#Z=null;static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.#_(),T(this,"disabled"))this.setAttribute("aria-disabled","true")}disconnectedCallback(){this.#Z?.disconnect()}#_(){let _=T(this,"selected");this.setAttribute("aria-selected",_?"true":"false");for(let Z of this.children)Z.toggleAttribute("selected",_);if(this.#Z?.disconnect(),_&&this.isConnected)this.#Z??=new MutationObserver(()=>this.#_()),this.#Z.observe(this,{childList:!0})}attributeChangedCallback(_){if(_==="selected")this.#_();if(_==="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")}}F("fig-choice",l_);class a_ extends HTMLElement{#Z=null;#_=this.#A.bind(this);#J=this.#I.bind(this);#$=this.#H.bind(this);#Q=null;#j=null;#G=null;#q=null;#N=null;#X=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop","auto-scroll"]}get#K(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#Y(){let _=this.getAttribute("drag");return _===null||_!=="false"}get autoScroll(){let _=this.getAttribute("auto-scroll");return _===null||_!=="false"}set autoScroll(_){if(_===!1||_==="false"||_===null)this.setAttribute("auto-scroll","false");else this.removeAttribute("auto-scroll")}get scrollBehavior(){return this.getAttribute("scroll-behavior")==="auto"?"auto":"smooth"}set scrollBehavior(_){if(_==="auto"||_==="smooth")this.setAttribute("scroll-behavior",_);else this.removeAttribute("scroll-behavior")}get#R(){return this.getAttribute("choice-element")||"fig-choice"}#U(){let _=this.getAttribute("columns"),Z=_===null?NaN:Number(_);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.#R}`))}get selectedChoice(){return this.#Z}set selectedChoice(_){if(_&&!this.contains(_))return;let Z=this.choices;for(let J of Z){let Q=J===_,j=T(J,"selected");if(Q&&!j)J.setAttribute("selected","");else if(!Q&&j)J.removeAttribute("selected")}this.#Z=_??null;let $=_?.getAttribute("value")??"";if(this.getAttribute("value")!==$)this.setAttribute("value",$);if(this.autoScroll)this.#f(_)}get value(){return this.#Z?.getAttribute("value")??""}set value(_){if(_===null||_===void 0||_===""){this.setAttribute("value","");return}this.setAttribute("value",String(_))}scrollSelectionIntoView(_={}){if(!this.#Z)return;this.#f(this.#Z,_)}connectedCallback(){if(this.setAttribute("role","listbox"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.#S(),this.addEventListener("click",this.#_),this.addEventListener("keydown",this.#J),this.addEventListener("scroll",this.#$),this.#P(),this.#F(),this.#g(),this.#z(),this.#M(),u(this,()=>{this.#O(),this.#H(),this.#W()})}#W(){requestAnimationFrame(()=>{if(!this.isConnected||!this.autoScroll)return;if(this.#Z)this.#f(this.#Z)})}disconnectedCallback(){this.removeEventListener("click",this.#_),this.removeEventListener("keydown",this.#J),this.removeEventListener("scroll",this.#$),this.#T(),this.#Q?.disconnect(),this.#Q=null,this.#j?.disconnect(),this.#j=null,this.#V()}attributeChangedCallback(_,Z,$){if(_==="value"&&$!==Z)if($==="")this.selectedChoice=null;else if($==null)this.#O();else this.#B($);if(_==="disabled")this.#M();if(_==="choice-element")requestAnimationFrame(()=>{this.#U(),this.#O()});if(_==="columns")this.#U(),this.#E();if(_==="drag")if(this.#Y)this.#F();else this.#T();if(_==="overflow")this.#P(),requestAnimationFrame(()=>this.#H());if(_==="layout"){if(this.#U(),this.#P(),$==="horizontal")this.scrollTop=0;else this.scrollLeft=0;this.#E()}if(_==="auto-scroll"&&this.autoScroll)this.#E()}#O(){let _=this.choices;if(!_.length){this.#Z=null;return}let Z=this.hasAttribute("value"),$=this.getAttribute("value");if(Z&&$===""){this.selectedChoice=null;return}if($&&this.#B($))return;let J=_.find((Q)=>T(Q,"selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=_[0]}#M(){let _=T(this,"disabled");if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Z of this.choices)if(_||T(Z,"disabled"))Z.setAttribute("aria-disabled","true"),Z.setAttribute("tabindex","-1");else Z.removeAttribute("aria-disabled"),Z.setAttribute("tabindex","0")}#B(_){let Z=this.choices;for(let $ of Z)if($.getAttribute("value")===_)return this.selectedChoice=$,!0;return!1}#L(_){let Z=this.#R,$=_;while($&&$!==this){if($.matches(Z))return $;$=$.parentElement}return null}#A(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#L(_.target);if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.selectedChoice=Z,this.#D()}#I(_){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 $=this.#L(_.target),J=Z.indexOf($),Q=J,j=this.hasAttribute("loop");switch(_.key){case"ArrowDown":case"ArrowRight":if(_.preventDefault(),J<Z.length-1)Q=J+1;else if(j)Q=0;break;case"ArrowUp":case"ArrowLeft":if(_.preventDefault(),J>0)Q=J-1;else if(j)Q=Z.length-1;break;case"Home":_.preventDefault(),Q=0;break;case"End":_.preventDefault(),Q=Z.length-1;break;case"Enter":case" ":if(_.preventDefault(),$&&$!==this.#Z)this.selectedChoice=$,this.#D();return;default:return}if(Q!==J&&Z[Q]){let q=Z[Q];if(q.focus({preventScroll:!0}),this.autoScroll)this.#f(q)}}#D(){let _=this.value;this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#H(){if(this.#K==="scrollbar")return;let _=this.getAttribute("layout")==="horizontal";L0(this,this,_?"x":"y")}#z(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#H(),this.#E()}),this.#j.observe(this)}#F(){if(this.#N?.bound)return;if(!this.#Y)return;let _=(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.#N.active=!0,this.#N.didDrag=!1,this.#N.startX=q.clientX,this.#N.startY=q.clientY,this.#N.scrollLeft=this.scrollLeft,this.#N.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Z=(q)=>{if(!this.#N.active)return;let N=this.getAttribute("layout")==="horizontal",G=q.clientX-this.#N.startX,K=q.clientY-this.#N.startY;if(!this.#N.didDrag&&Math.abs(N?G:K)>3)this.#N.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(q.pointerId);if(!this.#N.didDrag)return;if(N)this.scrollLeft=this.#N.scrollLeft-G;else this.scrollTop=this.#N.scrollTop-K},$=(q)=>{if(!this.#N.active)return;let N=this.#N.didDrag;if(this.#N.active=!1,this.#N.didDrag=!1,this.style.cursor="",this.style.userSelect="",q.pointerId!==void 0)try{this.releasePointerCapture(q.pointerId)}catch{}if(N)q.preventDefault(),q.stopPropagation()},J=(q)=>{if(this.#N?.suppressClick)q.stopPropagation(),q.preventDefault(),this.#N.suppressClick=!1},Q=(q)=>{if(this.#N?.didDrag)this.#N.suppressClick=!0,setTimeout(()=>{if(this.#N)this.#N.suppressClick=!1},0)},j=(q)=>{if(this.#N?.active)q.preventDefault()};this.#N={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:_,onPointerMove:Z,onPointerUp:$,onClick:J,onPointerUpCapture:Q,onDragStart:j},this.addEventListener("pointerdown",_),window.addEventListener("pointermove",Z),window.addEventListener("pointerup",$),this.addEventListener("pointerup",Q,!0),this.addEventListener("click",J,!0),this.addEventListener("dragstart",j)}#T(){if(!this.#N?.bound)return;this.removeEventListener("pointerdown",this.#N.onPointerDown),window.removeEventListener("pointermove",this.#N.onPointerMove),window.removeEventListener("pointerup",this.#N.onPointerUp),this.removeEventListener("pointerup",this.#N.onPointerUpCapture,!0),this.removeEventListener("click",this.#N.onClick,!0),this.removeEventListener("dragstart",this.#N.onDragStart),this.style.cursor="",this.style.userSelect="",this.#N=null}#S(){if(this.#X)return;let _=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!_)return;this.#X=!0;try{let Z=Array.from(_.childNodes);_.replaceWith(...Z)}finally{this.#X=!1}}#P(){let _=this.#K==="scrollbar",Z=this.getAttribute("layout")==="grid";if(_||Z)this.#V(),this.classList.toggle("fig-overflow-fade",_),this.classList.toggle("fig-overflow-fade-horizontal",_&&this.getAttribute("layout")==="horizontal");else this.#k(),this.classList.remove("fig-overflow-fade","fig-overflow-fade-horizontal")}#V(){this.#G?.remove(),this.#q?.remove(),this.#G=null,this.#q=null,this.classList.remove("overflow-start","overflow-end")}#k(){if(this.#G&&this.#q&&this.contains(this.#G)&&this.contains(this.#q)){this.#C();return}this.#G?.remove(),this.#q?.remove(),this.#G=null,this.#q=null;let _=W0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#h(-1),onEnd:()=>this.#h(1)});this.#G=_.start,this.#q=_.end,this.#C()}#C(){if(this.firstElementChild!==this.#G)this.prepend(this.#G);if(this.lastElementChild!==this.#q)this.append(this.#q)}#h(_){let Z=this.getAttribute("layout")==="horizontal";Z0(this,Z?"x":"y",_,"auto")}#E(){if(!this.autoScroll||!this.#Z)return;this.#f(this.#Z)}#f(_,Z={}){if(!_)return;let $=typeof Z==="object"&&Z!==null?Z:{},J=$.behavior==="smooth"||$.behavior==="instant"?$.behavior:"auto",Q=$.block||"center",j=$.inline||"center";requestAnimationFrame(()=>{if(!_.isConnected)return;let q=this.scrollHeight>this.clientHeight,N=this.scrollWidth>this.clientWidth;if(!N&&!q)return;let G=_.getBoundingClientRect(),K=this.getBoundingClientRect(),X={behavior:J},Y=!1;if(q){let W=G.top-K.top+this.scrollTop,R=this.scrollHeight-this.clientHeight;X.top=this.#x(W,G.height,this.clientHeight,this.scrollTop,R,Q),Y=!0}if(N){let W=G.left-K.left+this.scrollLeft,R=this.scrollWidth-this.clientWidth;X.left=this.#x(W,G.width,this.clientWidth,this.scrollLeft,R,j),Y=!0}if(Y)this.scrollTo(X);this.#H()})}#x(_,Z,$,J,Q,j){let q;if(j==="start")q=_;else if(j==="end")q=_+Z-$;else if(j==="nearest"){let N=J,G=J+$,K=_+Z;if(_>=N&&K<=G)q=J;else if(_<N)q=_;else q=K-$}else q=_+Z/2-$/2;return Math.max(0,Math.min(q,Q))}#g(){this.#Q?.disconnect(),this.#Q=new MutationObserver(()=>{if(this.#X)return;this.#S(),this.#U(),this.#P(),this.#M();let _=this.choices;if(this.#Z&&!_.includes(this.#Z))this.#Z=null,this.#O();else if(!this.#Z&&_.length)this.#O();requestAnimationFrame(()=>this.#H())}),this.#Q.observe(this,{childList:!0,subtree:!1})}}F("fig-chooser",a_);class t_ extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","precision","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#Z=!1;#_=!1;#J=null;#$=null;#Q=!1;#j=null;#G=null;#q=null;#N=null;get#X(){let _=(this.getAttribute("tip")||"").trim().toLowerCase();return _==="color"||_==="add"||_==="remove"?_:null}get#K(){return!this.hasAttribute("data-no-color-picker")}get#Y(){let _=this.getAttribute("drag");return _!==null&&_!=="false"}get#R(){let _=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:_.includes("x"),y:_.includes("y")}}get#U(){let _=this.getAttribute("drag-snapping");if(_===null)return"false";let Z=_.trim().toLowerCase();if(Z==="modifier")return"modifier";if(Z===""||Z==="true")return"true";return"false"}#W(_){let Z=this.#U;if(Z==="true")return!0;if(Z==="modifier")return!!_;return!1}#O(_){if(_<0.1)return 0;if(_>0.9)return 1;if(_>0.4&&_<0.6)return 0.5;return _}#M(_,Z){if(Math.abs(_-Z)<0.1){let J=(_+Z)/2;return{x:J,y:J}}if(Math.abs(1-_-Z)<0.1)return{x:_,y:1-_};return{x:_,y:Z}}#B(){let _=this.getAttribute("drag-surface");if(!_||_==="parent")return this.parentElement;return this.closest(_)}get value(){let _=this.#B();if(!_)return"0% 0%";let{px:Z,py:$}=this.#n(_.getBoundingClientRect());return`${(Z*100).toFixed(this.precision)}% ${($*100).toFixed(this.precision)}%`}set value(_){this.setAttribute("value",_??"0% 0%")}get precision(){let _=Number(this.getAttribute("precision")??2);if(!Number.isFinite(_))return 2;return Math.max(0,Math.min(10,Math.trunc(_)))}set precision(_){if(_===null||_===void 0||_==="")this.removeAttribute("precision");else{let Z=Number(_),$=Number.isFinite(Z)?Math.max(0,Math.min(10,Math.trunc(Z))):2;this.setAttribute("precision",String($))}}#L(_){let Z=10**this.precision,$=Math.round(_*Z)/Z;return Object.is($,-0)?0:$}#A(_){let Z=_==null?"":String(_).trim();if(!Z)return{xPct:0,yPct:0};let $=Z.split(/[\s,]+/).filter(Boolean),J=(q)=>{if(!q)return 0;let N=q.includes("px"),G=q.includes("%"),K=parseFloat(q.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(N)return{px:K};if(G||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},Q=J($[0]),j=J($[1]??$[0]);return{xToken:Q,yToken:j}}#I(_){let Z=this.#B();if(!Z)return;let{xToken:$,yToken:J}=this.#A(_),Q=Z.getBoundingClientRect(),j=(G,K)=>{if(G&&typeof G==="object"&&"px"in G)return Math.max(0,Math.min(K,G.px));return null},q=(G)=>{let K=typeof G==="number"?G:0;return`${this.#L(K)}%`},N=this.#R;if(this.#D(N),N.x){let G=j($,Q.width);this.style.left=G===null?q($):`${this.#L(G)}px`}if(N.y){let G=j(J,Q.height);this.style.top=G===null?q(J):`${this.#L(G)}px`}}#D(_=this.#R){this.style.setProperty("--fig-handle-position-translate",`${_.x?"-50%":"0"} ${_.y?"-50%":"0"}`)}#H(){this.#Q=!0,this.setAttribute("value",this.value),this.#Q=!1}get#z(){return this.getAttribute("hit-area-mode")||"handle"}#F(){let _=this.getAttribute("hit-area");if(!_)return null;let Z=_.trim().split(/\s+/),$=0,J=0,Q=!1,j=[];for(let q of Z){if(q==="circle"){Q=!0;continue}let N=parseFloat(q);if(Number.isFinite(N))j.push(N)}if(j.length>=2)$=j[0],J=j[1];else if(j.length===1)$=j[0],J=j[0];else return null;return{vPad:$,hPad:J,circle:Q}}#T(){let _=this.#F();if(!_){if(this.#N)this.#N.remove(),this.#N=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#N){let Z=document.createElement("div");Z.classList.add("fig-handle-hit-area"),Z.addEventListener("pointerdown",($)=>this.#S($)),this.prepend(Z),this.#N=Z}if(this.style.setProperty("--fig-handle-hit-area-size",String(_.hPad*2)),_.circle)this.#N.style.borderRadius="50%";else this.#N.style.borderRadius="inherit"}#S(_){if(T(this,"disabled"))return;if(_.target!==this.#N)return;if(this.#z==="delegate")_.preventDefault(),_.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:_}}));else this.#g(_)}connectedCallback(){this.#f(),this.#E(),this.#T(),this.addEventListener("click",this.#P),this.addEventListener("blur",this.#k),document.addEventListener("pointerdown",this.#V),document.addEventListener("keydown",this.#C);let _=this.getAttribute("value");if(_)this.#I(_);if(this.#X)this.#t()}disconnectedCallback(){if(this.#x(),this.#m(),this.#u(),this.#i(),this.#N)this.#N.remove(),this.#N=null;this.removeEventListener("click",this.#P),this.removeEventListener("blur",this.#k),document.removeEventListener("pointerdown",this.#V),document.removeEventListener("keydown",this.#C)}select(){if(T(this,"disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#P=(_)=>{if(this.#_){this.#_=!1;return}if(this.select(),this.getAttribute("type")==="color"&&this.#K&&!this.#X)this.#v()};#V=(_)=>{if(this.contains(_.target))return;if((this.#j||this.#G)&&_.target.closest?.("dialog, [popover]"))return;this.deselect()};#k=()=>{this.removeAttribute("data-fig-pointer-focus")};#C=(_)=>{if(this.removeAttribute("data-fig-pointer-focus"),_.defaultPrevented)return;if(_.target===this&&this.#Y&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(_.key)){if(this.#h(_)){if(_.preventDefault(),!T(this,"selected"))this.select()}return}if(_.key!=="Enter"&&_.key!==" ")return;if(_.target===this&&!T(this,"selected")){if(_.preventDefault(),this.getAttribute("type")==="color"&&this.#K&&!this.#X)this.#v();else this.select();return}if(!T(this,"selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#K)return;if(_.preventDefault(),!this.#X)this.#v()};#h(_){if(T(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.#R,Q=this.#n($),j=_.shiftKey?0.1:0.01,q=Q.px,N=Q.py;switch(_.key){case"ArrowLeft":if(!J.x)return!1;q-=j;break;case"ArrowRight":if(!J.x)return!1;q+=j;break;case"ArrowUp":if(!J.y)return!1;N-=j;break;case"ArrowDown":if(!J.y)return!1;N+=j;break;case"Home":if(J.x)q=0;if(J.y)N=0;break;case"End":if(J.x)q=1;if(J.y)N=1;break;default:return!1}if(q=Math.max(0,Math.min(1,q)),N=Math.max(0,Math.min(1,N)),this.#D(J),J.x)this.style.left=`${this.#L(q*$.width)}px`;if(J.y)this.style.top=`${this.#L(N*$.height)}px`;this.#H();let G={...this.#n($),shiftKey:_.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:G})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:G})),!0}attributeChangedCallback(_,Z,$){if(_==="color"){if(!$||$==="false"||$==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",$);if(this.#j&&this.#X==="color"&&$)this.#j.setAttribute("value",$);this.#y()}if(_==="drag")this.#E();if(_==="hit-area")this.#T();if(_==="selected")this.#c();if(_==="selected"||_==="disabled"||_==="type"||_==="tip"||_==="aria-label"||_==="aria-labelledby")this.#f();if(_==="value"&&!this.#Q&&!this.#Z)this.#I($);if(_==="precision"&&this.isConnected&&!this.#Z&&this.hasAttribute("value"))this.#I(this.getAttribute("value")),this.#H();if(_==="tip"){if(this.#m(),this.#X)this.#u(),this.#t()}}#E(){if(this.#Y&&!this.#J)this.#J=(_)=>this.#g(_),this.addEventListener("pointerdown",this.#J);else if(!this.#Y&&this.#J)this.#x()}#f(){let _=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",_?"-1":"0");else if(_)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",_?"true":"false"),this.setAttribute("aria-pressed",Z?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let $=this.#X||this.getAttribute("type")||"handle";this.setAttribute("aria-label",$==="color"?"Color handle":$==="add"?"Add handle":$==="remove"?"Remove handle":"Handle")}}#x(){if(this.#$?.(),this.#$=null,this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#Z=!1,this.#_=!1}#g(_){if(!this.#Y||T(this,"disabled"))return;_.preventDefault(),this.setAttribute("data-fig-pointer-focus",""),this.focus(),this.select();let Z=this.#B();if(!Z)return;this.#$?.(),this.#Z=!0;let $=this.#R,J=null,Q=this.getBoundingClientRect(),j=Q.left+Q.width/2,q=Q.top+Q.height/2,N=_.clientX-j,G=_.clientY-q,K=_.clientX,X=_.clientY,Y=3,W=(H,A,z=!1)=>{let U=Z.getBoundingClientRect();J=U;let I=this.#n(U),V=H-N-U.left,P=A-G-U.top,S=Math.max(0,Math.min(U.width,V)),w=Math.max(0,Math.min(U.height,P)),f=U.width>0?$.x?S/U.width:I.px:0.5,c=U.height>0?$.y?w/U.height:I.py:0.5;if(this.#W(z)){if($.x)f=this.#O(f);if($.y)c=this.#O(c);if($.x&&$.y){let o=this.#M(f,c);f=o.x,c=o.y}}if(this.#D($),$.x)this.style.left=`${this.#L(Math.max(0,Math.min(U.width,f*U.width)))}px`;if($.y)this.style.top=`${this.#L(Math.max(0,Math.min(U.height,c*U.height)))}px`},R=(H)=>{if(!this.#Z)return;if(!this.#_){let A=H.clientX-K,z=H.clientY-X;if(A*A+z*z<Y*Y)return;if(this.#r(),this.classList.add("dragging"),this.style.cursor="grabbing",!T(this,"selected"))this.select()}this.#_=!0,W(H.clientX,H.clientY,H.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#n(J),shiftKey:H.shiftKey}}))},L=(H)=>{if(O(),this.#_){W(H.clientX,H.clientY,H.shiftKey),this.#H(),this.#I(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#n(J)}));let A=(z)=>{z.stopPropagation(),z.preventDefault()};this.addEventListener("click",A,{capture:!0,once:!0})}else this.#H();this.#_=!1},O=()=>{if(window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",L),this.#Z=!1,this.style.cursor="",this.classList.remove("dragging"),this.#$===O)this.#$=null};this.#$=O,window.addEventListener("pointermove",R),window.addEventListener("pointerup",L)}showColorTip(){if(!this.#X)return;if(this.#j){this.#j.style.display="";return}this.#t()}hideColorTip(){if(!this.#j)return;this.#j.style.display="none"}#w(_=this.getAttribute("color")){let Z={color:"#D9D9D9",opacity:100},$=String(_||"").trim();if(!$)return Z;let J=(j)=>{let q=j.replace("#","").trim();if(q.length===3||q.length===4){let[N,G,K,X]=q;return{color:`#${N}${N}${G}${G}${K}${K}`.toUpperCase(),opacity:X?Math.round(parseInt(`${X}${X}`,16)/255*100):100}}if(q.length===6||q.length===8)return{color:`#${q.slice(0,6)}`.toUpperCase(),opacity:q.length===8?Math.round(parseInt(q.slice(6,8),16)/255*100):100};return Z},Q=(j,q,N)=>{let G=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${G(j)}${G(q)}${G(N)}`.toUpperCase()};if($.startsWith("#"))return J($);try{let{ctx:j}=D0(1,1);j.fillStyle="#000000",j.fillStyle=$;let q=j.fillStyle;if(q.startsWith("#"))return J(q);let N=q.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(N)return{color:Q(N[1],N[2],N[3]),opacity:N[4]!==void 0?Math.round(parseFloat(N[4])*100):100}}catch{}return Z}#p(){let{color:_,opacity:Z}=this.#w();return JSON.stringify(Z<100?{type:"solid",color:_,opacity:Z}:{type:"solid",color:_})}#y(){if(!this.#G)return;this.#G.setAttribute("value",this.#p())}#b(){if(!q0())return null;if(this.#G)return this.#G;let _=document.createElement("fig-fill-picker");_.setAttribute("mode","solid"),_.setAttribute("alpha","true"),_.setAttribute("dialog-offset","8 8"),_.setAttribute("value",this.#p()),_.anchorElement=this;let Z=document.createElement("span");return Z.hidden=!0,_.appendChild(Z),_.addEventListener("input",this.#s),_.addEventListener("change",this.#e),_.addEventListener("close",this.#G0),this.appendChild(_),this.#G=_,_}#v(){if(T(this,"disabled"))return;let _=this.#b();if(!_){this.#o();return}this.setAttribute("selected",""),this.#y(),_.open()}#u(){if(!this.#G)return;this.#G.removeEventListener("input",this.#s),this.#G.removeEventListener("change",this.#e),this.#G.removeEventListener("close",this.#G0),this.#G.close(),this.#G.remove(),this.#G=null,this.removeAttribute("selected")}#a(){if(this.#q)return this.#q;let _=document.createElement("input");return _.type="color",_.tabIndex=-1,_.setAttribute("aria-hidden","true"),_.style.position="fixed",_.style.inlineSize="1px",_.style.blockSize="1px",_.style.opacity="0",_.style.pointerEvents="none",_.addEventListener("input",this.#_0),_.addEventListener("change",this.#$0),this.appendChild(_),this.#q=_,_}#o(){let _=this.#a(),{color:Z}=this.#w();_.value=Z,this.setAttribute("selected",""),_.click()}#i(){if(!this.#q)return;this.#q.removeEventListener("input",this.#_0),this.#q.removeEventListener("change",this.#$0),this.#q.remove(),this.#q=null}#r(){if(this.getAttribute("type")!=="color")return;this.#G?.close()}#t(){let _=this.#X;if(!_)return;if(this.#j)return;let Z=document.createElement("fig-color-tip");if(_==="add"||_==="remove")Z.setAttribute("control",_);else Z.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Z.setAttribute("alpha","true");Z.addEventListener("input",this.#K0),Z.addEventListener("change",this.#N0),Z.addEventListener("add",this.#Z0),Z.addEventListener("remove",this.#Z0),this.appendChild(Z),this.#j=Z,this.#c()}#m(){if(!this.#j)return;this.#j.removeEventListener("input",this.#K0),this.#j.removeEventListener("change",this.#N0),this.#j.removeEventListener("add",this.#Z0),this.#j.removeEventListener("remove",this.#Z0),this.#j.remove(),this.#j=null}#c(){if(!this.#j||this.#X!=="color")return;let _=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#j.toggleAttribute("selected",_)}#d(_,Z){if(Z===void 0||Z>=100)return _;let{r:$,g:J,b:Q}=_0(_);return`rgba(${$}, ${J}, ${Q}, ${Z/100})`}#Q0(_){if(!_?.color)return null;let Z=_.opacity!==void 0?_.opacity:_.alpha!==void 0?Math.round(_.alpha*100):void 0;return{color:_.color,opacity:Z,...t(_.color,_.alpha,Z)}}#s=(_)=>{_.stopPropagation();let Z=this.#Q0(_.detail);if(!Z)return;this.setAttribute("color",this.#d(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#e=(_)=>{_.stopPropagation();let Z=this.#Q0(_.detail);if(!Z)return;this.setAttribute("color",this.#d(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#l(_){let{opacity:Z}=this.#w();return{...Z<100?{color:_,opacity:Z}:{color:_},...t(_,void 0,Z)}}#_0=(_)=>{_.stopPropagation();let Z=this.#l(_.target.value);this.setAttribute("color",this.#d(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#$0=(_)=>{_.stopPropagation();let Z=this.#l(_.target.value);if(this.setAttribute("color",this.#d(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z})),this.isConnected)this.focus()};#G0=()=>{if(!this.isConnected)return;this.setAttribute("selected",""),this.focus()};#K0=(_)=>{if(_.stopPropagation(),_.detail?.color){let Z={color:_.detail.color,opacity:_.detail.opacity,...t(_.detail.color,_.detail.alpha,_.detail.opacity)};this.setAttribute("color",this.#d(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))}};#N0=(_)=>{if(_.stopPropagation(),_.detail?.color){let Z={color:_.detail.color,opacity:_.detail.opacity,...t(_.detail.color,_.detail.alpha,_.detail.opacity)};this.setAttribute("color",this.#d(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))}};#Z0=(_)=>{_.stopPropagation(),this.dispatchEvent(new CustomEvent(_.type,{bubbles:!0,composed:!0}))};#n(_){let Z=_||this.#B()?.getBoundingClientRect();if(!Z)return{x:0,y:0,px:0,py:0};let $=this.getBoundingClientRect(),J=this.offsetWidth/2,Q=this.offsetHeight/2,j=$.left-Z.left,q=$.top-Z.top,N=j+J,G=q+Q,K=Z.width>0?N/Z.width:0,X=Z.height>0?G/Z.height:0;return{x:this.#L(j),y:this.#L(q),px:K,py:X}}}F("fig-handle",t_);class n_ extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(_){this.setAttribute("value",_??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Z()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="disabled")this.#Z()}#Z(){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")}}F("fig-menu-item",n_);class E0 extends HTMLElement{#Z=null;#_=null;#J=null;#$=this.#X.bind(this);static get observedAttributes(){return["label","direction","sticky"]}get label(){return this.getAttribute("label")??""}set label(_){if(_==null||_==="")this.removeAttribute("label");else this.setAttribute("label",String(_))}connectedCallback(){this.#Q(),this.#j(),this.#q()}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#N()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#Q(),_==="sticky")this.#q()}#Q(){if(!this.hasAttribute("role"))this.setAttribute("role","separator");if(this.getAttribute("direction")==="vertical")this.setAttribute("aria-orientation","vertical");else if(!this.hasAttribute("aria-orientation"))this.setAttribute("aria-orientation","horizontal");let Z=this.label.trim(),$=Array.from(this.children).filter((q)=>q.localName==="label"),J=$.find((q)=>!q.hasAttribute("data-fig-separator-generated")),Q=$.filter((q)=>q.hasAttribute("data-fig-separator-generated"));if(J)Q.forEach((q)=>q.remove());else if(Z){let q=Q[0]??document.createElement("label");if(Q.slice(1).forEach((N)=>N.remove()),q.setAttribute("data-fig-separator-generated",""),q.textContent!==Z)q.textContent=Z;if(!q.parentElement)this.appendChild(q)}else Q.forEach((q)=>q.remove());let j=J?.textContent?.trim()||Z;if(j)this.setAttribute("aria-label",j);else this.removeAttribute("aria-label")}#j(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>this.#Q()),this.#J.observe(this,{childList:!0,characterData:!0,subtree:!0})}#G(){return this.hasAttribute("sticky")&&this.getAttribute("sticky")!=="false"}#q(){if(this.#N(),!this.isConnected||!this.#G()){this.removeAttribute("stuck");return}let _=z1(this);if(this.#Z=_,_?.addEventListener("scroll",this.#$,{passive:!0}),this.#_=new ResizeObserver(this.#$),this.#_.observe(this),_ instanceof Element)this.#_.observe(_);requestAnimationFrame(this.#$)}#N(){this.#Z?.removeEventListener?.("scroll",this.#$),this.#Z=null,this.#_?.disconnect(),this.#_=null}#X(){if(!this.#G()||!this.#Z){this.removeAttribute("stuck");return}let _=parseFloat(getComputedStyle(this).top)||0,Z=this.#Z,$=Z===document.scrollingElement||Z===document.documentElement?{top:0}:Z.getBoundingClientRect(),J=Z instanceof Element?parseFloat(getComputedStyle(Z).paddingTop)||0:0,Q=$.top+J+_;this.toggleAttribute("stuck",this.getBoundingClientRect().top<=Q+1)}}F("fig-separator",E0);function z1(_){let Z=_.parentElement;while(Z){let $=getComputedStyle(Z),J=$.overflowY||$.overflow;if(J&&J!=="visible"&&J!=="clip")return Z;Z=Z.parentElement}return document.scrollingElement}class e_ extends E0{}F("fig-menu-separator",e_);var T1=new Set(["FIG-MENU-ITEM","FIG-SEPARATOR","FIG-MENU-SEPARATOR"]),j0="trigger";function k1(_){return _?.nodeType===1&&T1.has(_.tagName)}function D1(_,Z){if(!_||!Z)return null;let $=Z;while($.parentElement&&$.parentElement!==_)$=$.parentElement;return $.parentElement===_?$:null}class _1 extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#q=null;#N=null;#X=null;#K=!1;#Y;#R;#U;#W;#O;#M;#B=this.#h.bind(this);#L=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open","trigger"]}constructor(){super();this.#Y=this.#v.bind(this),this.#R=this.#u.bind(this),this.#U=this.#o.bind(this),this.#W=this.#i.bind(this),this.#O=this.#r.bind(this),this.#M=this.#h.bind(this),this.#A()}get value(){return this.getAttribute("value")||""}set value(_){this.setAttribute("value",_??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){if(_){if(this.#b())return;this.setAttribute("open","")}else this.removeAttribute("open")}connectedCallback(){if(this.#D(),this.#S(),this.#k(),this.#V(),this.#y(),this.open)this.#m()}disconnectedCallback(){if(this.#P(),this.#C(),document.removeEventListener("keydown",this.#W,!0),this.#G)this.#G.disconnect(),this.#G=null}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="open"){if($===null||$==="false")this.#c();else{if(this.#b()){this.removeAttribute("open");return}this.#m()}return}if(_==="disabled"){this.#y();return}if(this.#Z&&(_==="position"||_==="offset"||_==="closedby"))if($!==null)this.#Z.setAttribute(_,$);else this.#Z.removeAttribute(_)}#A(){if(this.#K)return;this.#K=!0;let _=this.attachShadow({mode:"open"});l0(_,{icons:!0});let Z=document.createElement("style");Z.textContent=`
175
175
  :host {
176
176
  display: contents;
177
177
  }
@@ -197,4 +197,4 @@ fig-icon[size="small"] {
197
197
  .fig-menu-items > ::slotted(fig-menu-separator) {
198
198
  flex-shrink: 0;
199
199
  }
200
- `;let $=document.createElement("slot");$.setAttribute("name",j0);let J=document.createElement("dialog",{is:"fig-popup"});if(J.setAttribute("is","fig-popup"),J.classList.add("fig-menu-popup"),J.setAttribute("part","listbox"),J.setAttribute("theme","menu"),J.setAttribute("role","menu"),J.id=g(),"popover"in HTMLElement.prototype)J.setAttribute("popover","manual");let Q=document.createElement("div");Q.className="fig-menu-options",Q.setAttribute("part","options"),Q.setAttribute("role","presentation");let j=document.createElement("div");j.className="fig-menu-items";let q=document.createElement("slot");j.appendChild(q),Q.appendChild(j),J.appendChild(Q),_.append(Z,$,J),this.#Z=J,this.#_=Q,this.#J=q,this.#I(),J.addEventListener("close",this.#B),q.addEventListener("slotchange",this.#M)}#I(){if(!this.#Z)return;let _=this.getAttribute("position")||"bottom left";this.#Z.setAttribute("position",_);let Z=this.getAttribute("offset");if(Z)this.#Z.setAttribute("offset",Z);else this.#Z.removeAttribute("offset");let $=this.getAttribute("closedby");if($)this.#Z.setAttribute("closedby",$);else this.#Z.removeAttribute("closedby")}#D(){this.#$=this.querySelector("[fig-menu-trigger]")||this.querySelector(`:scope > :not(fig-menu-item):not(fig-separator):not(fig-menu-separator):not([slot="${j0}"])`)||this.querySelector(`[slot="${j0}"]`),this.#H()}#H(){let _=D1(this,this.#$);if(this.#Q=_,!_)return;if(_.getAttribute("slot")!==j0)_.setAttribute("slot",j0)}#z(){return(this.getAttribute("trigger")||"").toLowerCase()==="contextmenu"||this.hasAttribute("contextmenu")}#F(){if(!this.#$||!this.#Z)return;this.#$.addEventListener("click",this.#Y),this.#$.addEventListener("contextmenu",this.#R),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded",this.open?"true":"false"),this.#$.setAttribute("aria-controls",this.#Z.id),this.#Z.anchor=this.#$}#T(){if(!this.#$)return;this.#$.removeEventListener("click",this.#Y),this.#$.removeEventListener("contextmenu",this.#R)}#S(){this.addEventListener("keydown",this.#W),this.addEventListener("click",this.#U),this.#F(),this.#Z?.addEventListener("keydown",this.#W)}#P(){this.removeEventListener("keydown",this.#W),this.removeEventListener("click",this.#U),this.#T(),this.#Z?.removeEventListener("keydown",this.#W)}#V(){if(this.#G)return;this.#G=new MutationObserver((_)=>{let Z=!1;for(let $ of _){for(let J of $.addedNodes){if(J.nodeType!==1)continue;if(k1(J))continue;if(J.parentElement===this)Z=!0}for(let J of $.removedNodes)if(J===this.#$||J===this.#Q)Z=!0}if(Z||!this.#$)this.#T(),this.#D(),this.#F(),this.#y();this.#h()}),this.#G.observe(this,{childList:!0})}#k(){if(!this.#_)return;this.#E(),this.#_.addEventListener("scroll",this.#O,{passive:!0}),this.#N?.disconnect(),this.#N=new ResizeObserver(()=>this.#h()),this.#N.observe(this.#_),requestAnimationFrame(()=>this.#h())}#C(){this.#_?.removeEventListener("scroll",this.#O),this.#N?.disconnect(),this.#N=null,this.#f()}#h(){let _=L0(this.#_,this.#_,"y");return this.classList.toggle("overflow-start",Boolean(this.#_?.classList.contains("overflow-start"))),this.classList.toggle("overflow-end",Boolean(this.#_?.classList.contains("overflow-end"))),_}#E(){if(this.#q&&this.#X&&this.#_?.contains(this.#q)&&this.#_?.contains(this.#X))return;this.#f();let _=W0({owner:"menu",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>Z0(this.#_,"y",-1),onEnd:()=>Z0(this.#_,"y",1)});this.#q=_.start,this.#X=_.end,this.#_.prepend(this.#q),this.#_.append(this.#X)}#f(){this.#q?.remove(),this.#X?.remove(),this.#q=null,this.#X=null,this.#_?.classList.remove("overflow-start","overflow-end"),this.classList.remove("overflow-start","overflow-end")}#x(){return Array.from(this.querySelectorAll(":scope > fig-menu-item")).filter((_)=>!_.hidden&&(!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false"))}#g(){let _=this.#x();if(!_.length){this.#L=-1;return}let Z=document.activeElement,$=_.findIndex((J)=>J===Z||J.contains(Z));this.#L=$>=0?$:-1}#w(_){let Z=this.#x();if(!Z.length)return;let $=(_+Z.length)%Z.length;this.#L=$;let J=Z[$];J.focus(),this.#p(J)}#p(_){let Z=this.#_;if(!Z||!_)return;requestAnimationFrame(()=>{if(!Z.isConnected||!_.isConnected)return;let{scrollHeight:$,clientHeight:J}=Z;if($<=J+1){this.#h();return}let Q=_.getBoundingClientRect(),j=Z.getBoundingClientRect(),q=Q.top-j.top+Z.scrollTop,N=$-J,G=Math.max(0,Math.min(q+Q.height/2-J/2,N));Z.scrollTo({top:G,behavior:"auto"}),this.#h()})}#y(){let _=this.#b();if(_)if(this.open)this.removeAttribute("open");else this.#c();if(!this.#$)return;if(_)this.#$.setAttribute("disabled",""),this.#$.setAttribute("aria-disabled","true"),this.#$.setAttribute("aria-expanded","false");else this.#$.removeAttribute("disabled"),this.#$.removeAttribute("aria-disabled")}#b(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#v(_){if(this.#z())return;if(this.#b())return;_.stopPropagation();let Z=this.#Z?.matches?.(":open")??!1;if(this.open&&!Z)this.removeAttribute("open");if(this.open&&Z)this.open=!1;else{if(this.#Z&&this.#$)this.#Z.anchor=this.#$;this.open=!0}}#u(_){if(!this.#z())return;if(this.#b())return;_.preventDefault(),_.stopPropagation(),this.#a(_.clientX,_.clientY)}#a(_,Z){let $=!1,J=0,Q=()=>{window.clearTimeout(J),window.removeEventListener("pointerup",j,!0),window.removeEventListener("pointercancel",q,!0)},j=()=>{if($)return;$=!0,Q(),requestAnimationFrame(()=>this.showAt(_,Z))},q=()=>{if($)return;$=!0,Q()};window.addEventListener("pointerup",j,{once:!0,capture:!0}),window.addEventListener("pointercancel",q,{once:!0,capture:!0}),J=window.setTimeout(j,180)}#o(_){if(this.#b())return;if(this.#$?.contains(_.target)||this.#Q?.contains(_.target))return;let Z=_.target.closest?.("fig-menu-item");if(!Z||Z.parentElement!==this)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;_.stopPropagation(),this.#t(Z)}#i(_){if(this.#b())return;if(_.currentTarget===document&&_.key!=="Escape")return;if(_.currentTarget===this){let $=typeof _.composedPath==="function"?_.composedPath():[];if(this.#Z&&$.includes(this.#Z))return}if(!this.open||!this.#Z?.matches?.(":open")){if(this.#$?.contains(_.target)&&(_.key==="ArrowDown"||_.key==="Enter"||_.key===" ")){if(_.preventDefault(),this.#Z&&this.#$)this.#Z.anchor=this.#$;this.open=!0,requestAnimationFrame(()=>this.#w(0))}return}let Z=this.#x();if(!Z.length)return;switch(_.key){case"ArrowDown":{_.preventDefault(),this.#g(),this.#w(this.#L+1);break}case"ArrowUp":{_.preventDefault(),this.#g(),this.#w(this.#L-1);break}case"Home":{_.preventDefault(),this.#w(0);break}case"End":{_.preventDefault(),this.#w(Z.length-1);break}case"Escape":{_.preventDefault(),this.open=!1,this.#$?.focus();break}case"Enter":case" ":{this.#g();let $=Z[this.#L];if(!$)return;_.preventDefault(),this.#t($);break}}}#r(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#$)this.#$.setAttribute("aria-expanded","false"),this.#$.focus();this.#L=-1}#t(_){let Z=_.getAttribute("value")||_.textContent.trim();this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("change",{detail:{value:Z,item:_},bubbles:!0})),this.open=!1}showAt(_,Z){if(this.#b())return;if(this.#j={getBoundingClientRect:()=>({width:0,height:0,top:Z,right:_,bottom:Z,left:_,x:_,y:Z})},this.#Z)this.#Z.anchor=this.#j;if(this.open)this.open=!1;requestAnimationFrame(()=>{if(this.#b())return;this.open=!0})}#m(){if(!this.#Z||this.#b()){if(this.hasAttribute("open"))this.removeAttribute("open");return}if(this.#Z.open=!0,document.addEventListener("keydown",this.#W,!0),this.#$)this.#$.setAttribute("aria-expanded","true");this.#L=-1,requestAnimationFrame(()=>{if(this.#h(),!this.#$?.matches?.(":focus-visible"))return;this.#w(0)})}#c(){if(!this.#Z)return;document.removeEventListener("keydown",this.#W,!0),this.#Z.open=!1,this.#$?.setAttribute("aria-expanded","false")}}F("fig-menu",_1);
200
+ `;let $=document.createElement("slot");$.setAttribute("name",j0);let J=document.createElement("dialog",{is:"fig-popup"});if(J.setAttribute("is","fig-popup"),J.classList.add("fig-menu-popup"),J.setAttribute("part","listbox"),J.setAttribute("theme","menu"),J.setAttribute("role","menu"),J.id=g(),"popover"in HTMLElement.prototype)J.setAttribute("popover","manual");let Q=document.createElement("div");Q.className="fig-menu-options",Q.setAttribute("part","options"),Q.setAttribute("role","presentation");let j=document.createElement("div");j.className="fig-menu-items";let q=document.createElement("slot");j.appendChild(q),Q.appendChild(j),J.appendChild(Q),_.append(Z,$,J),this.#Z=J,this.#_=Q,this.#J=q,this.#I(),J.addEventListener("close",this.#O),q.addEventListener("slotchange",this.#M)}#I(){if(!this.#Z)return;let _=this.getAttribute("position")||"bottom left";this.#Z.setAttribute("position",_);let Z=this.getAttribute("offset");if(Z)this.#Z.setAttribute("offset",Z);else this.#Z.removeAttribute("offset");let $=this.getAttribute("closedby");if($)this.#Z.setAttribute("closedby",$);else this.#Z.removeAttribute("closedby")}#D(){this.#$=this.querySelector("[fig-menu-trigger]")||this.querySelector(`:scope > :not(fig-menu-item):not(fig-separator):not(fig-menu-separator):not([slot="${j0}"])`)||this.querySelector(`[slot="${j0}"]`),this.#H()}#H(){let _=D1(this,this.#$);if(this.#Q=_,!_)return;if(_.getAttribute("slot")!==j0)_.setAttribute("slot",j0)}#z(){return(this.getAttribute("trigger")||"").toLowerCase()==="contextmenu"||this.hasAttribute("contextmenu")}#F(){if(!this.#$||!this.#Z)return;this.#$.addEventListener("click",this.#Y),this.#$.addEventListener("contextmenu",this.#R),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded",this.open?"true":"false"),this.#$.setAttribute("aria-controls",this.#Z.id),this.#Z.anchor=this.#$}#T(){if(!this.#$)return;this.#$.removeEventListener("click",this.#Y),this.#$.removeEventListener("contextmenu",this.#R)}#S(){this.addEventListener("keydown",this.#W),this.addEventListener("click",this.#U),this.#F(),this.#Z?.addEventListener("keydown",this.#W)}#P(){this.removeEventListener("keydown",this.#W),this.removeEventListener("click",this.#U),this.#T(),this.#Z?.removeEventListener("keydown",this.#W)}#V(){if(this.#G)return;this.#G=new MutationObserver((_)=>{let Z=!1;for(let $ of _){for(let J of $.addedNodes){if(J.nodeType!==1)continue;if(k1(J))continue;if(J.parentElement===this)Z=!0}for(let J of $.removedNodes)if(J===this.#$||J===this.#Q)Z=!0}if(Z||!this.#$)this.#T(),this.#D(),this.#F(),this.#y();this.#h()}),this.#G.observe(this,{childList:!0})}#k(){if(!this.#_)return;this.#E(),this.#_.addEventListener("scroll",this.#B,{passive:!0}),this.#q?.disconnect(),this.#q=new ResizeObserver(()=>this.#h()),this.#q.observe(this.#_),requestAnimationFrame(()=>this.#h())}#C(){this.#_?.removeEventListener("scroll",this.#B),this.#q?.disconnect(),this.#q=null,this.#f()}#h(){let _=L0(this.#_,this.#_,"y");return this.classList.toggle("overflow-start",Boolean(this.#_?.classList.contains("overflow-start"))),this.classList.toggle("overflow-end",Boolean(this.#_?.classList.contains("overflow-end"))),_}#E(){if(this.#N&&this.#X&&this.#_?.contains(this.#N)&&this.#_?.contains(this.#X))return;this.#f();let _=W0({owner:"menu",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>Z0(this.#_,"y",-1),onEnd:()=>Z0(this.#_,"y",1)});this.#N=_.start,this.#X=_.end,this.#_.prepend(this.#N),this.#_.append(this.#X)}#f(){this.#N?.remove(),this.#X?.remove(),this.#N=null,this.#X=null,this.#_?.classList.remove("overflow-start","overflow-end"),this.classList.remove("overflow-start","overflow-end")}#x(){return Array.from(this.querySelectorAll(":scope > fig-menu-item")).filter((_)=>!_.hidden&&(!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false"))}#g(){let _=this.#x();if(!_.length){this.#L=-1;return}let Z=document.activeElement,$=_.findIndex((J)=>J===Z||J.contains(Z));this.#L=$>=0?$:-1}#w(_){let Z=this.#x();if(!Z.length)return;let $=(_+Z.length)%Z.length;this.#L=$;let J=Z[$];J.focus(),this.#p(J)}#p(_){let Z=this.#_;if(!Z||!_)return;requestAnimationFrame(()=>{if(!Z.isConnected||!_.isConnected)return;let{scrollHeight:$,clientHeight:J}=Z;if($<=J+1){this.#h();return}let Q=_.getBoundingClientRect(),j=Z.getBoundingClientRect(),q=Q.top-j.top+Z.scrollTop,N=$-J,G=Math.max(0,Math.min(q+Q.height/2-J/2,N));Z.scrollTo({top:G,behavior:"auto"}),this.#h()})}#y(){let _=this.#b();if(_)if(this.open)this.removeAttribute("open");else this.#c();if(!this.#$)return;if(_)this.#$.setAttribute("disabled",""),this.#$.setAttribute("aria-disabled","true"),this.#$.setAttribute("aria-expanded","false");else this.#$.removeAttribute("disabled"),this.#$.removeAttribute("aria-disabled")}#b(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#v(_){if(this.#z())return;if(this.#b())return;_.stopPropagation();let Z=this.#Z?.matches?.(":open")??!1;if(this.open&&!Z)this.removeAttribute("open");if(this.open&&Z)this.open=!1;else{if(this.#Z&&this.#$)this.#Z.anchor=this.#$;this.open=!0}}#u(_){if(!this.#z())return;if(this.#b())return;_.preventDefault(),_.stopPropagation(),this.#a(_.clientX,_.clientY)}#a(_,Z){let $=!1,J=0,Q=()=>{window.clearTimeout(J),window.removeEventListener("pointerup",j,!0),window.removeEventListener("pointercancel",q,!0)},j=()=>{if($)return;$=!0,Q(),requestAnimationFrame(()=>this.showAt(_,Z))},q=()=>{if($)return;$=!0,Q()};window.addEventListener("pointerup",j,{once:!0,capture:!0}),window.addEventListener("pointercancel",q,{once:!0,capture:!0}),J=window.setTimeout(j,180)}#o(_){if(this.#b())return;if(this.#$?.contains(_.target)||this.#Q?.contains(_.target))return;let Z=_.target.closest?.("fig-menu-item");if(!Z||Z.parentElement!==this)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;_.stopPropagation(),this.#t(Z)}#i(_){if(this.#b())return;if(_.currentTarget===document&&_.key!=="Escape")return;if(_.currentTarget===this){let $=typeof _.composedPath==="function"?_.composedPath():[];if(this.#Z&&$.includes(this.#Z))return}if(!this.open||!this.#Z?.matches?.(":open")){if(this.#$?.contains(_.target)&&(_.key==="ArrowDown"||_.key==="Enter"||_.key===" ")){if(_.preventDefault(),this.#Z&&this.#$)this.#Z.anchor=this.#$;this.open=!0,requestAnimationFrame(()=>this.#w(0))}return}let Z=this.#x();if(!Z.length)return;switch(_.key){case"ArrowDown":{_.preventDefault(),this.#g(),this.#w(this.#L+1);break}case"ArrowUp":{_.preventDefault(),this.#g(),this.#w(this.#L-1);break}case"Home":{_.preventDefault(),this.#w(0);break}case"End":{_.preventDefault(),this.#w(Z.length-1);break}case"Escape":{_.preventDefault(),this.open=!1,this.#$?.focus();break}case"Enter":case" ":{this.#g();let $=Z[this.#L];if(!$)return;_.preventDefault(),this.#t($);break}}}#r(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#$)this.#$.setAttribute("aria-expanded","false"),this.#$.focus();this.#L=-1}#t(_){let Z=_.getAttribute("value")||_.textContent.trim();this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("change",{detail:{value:Z,item:_},bubbles:!0})),this.open=!1}showAt(_,Z){if(this.#b())return;if(this.#j={getBoundingClientRect:()=>({width:0,height:0,top:Z,right:_,bottom:Z,left:_,x:_,y:Z})},this.#Z)this.#Z.anchor=this.#j;if(this.open)this.open=!1;requestAnimationFrame(()=>{if(this.#b())return;this.open=!0})}#m(){if(!this.#Z||this.#b()){if(this.hasAttribute("open"))this.removeAttribute("open");return}if(this.#Z.open=!0,document.addEventListener("keydown",this.#W,!0),this.#$)this.#$.setAttribute("aria-expanded","true");this.#L=-1,requestAnimationFrame(()=>{if(this.#h(),!this.#$?.matches?.(":focus-visible"))return;this.#w(0)})}#c(){if(!this.#Z)return;document.removeEventListener("keydown",this.#W,!0),this.#Z.open=!1,this.#$?.setAttribute("aria-expanded","false")}}F("fig-menu",_1);