@rogieking/figui3 6.8.6 → 6.8.8

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
@@ -1,4 +1,4 @@
1
- var A1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var F1={};var L0=A1(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(Q,Z,$){if(Q.importNode.length!=1||Z.get("ungap-li"))return;var J="extends";try{var j={};j[J]="li";var _=HTMLLIElement,q=function(){return Reflect.construct(_,[],q)};if(q.prototype=$.create(_.prototype),Z.define("ungap-li",q,j),!/is="ungap-li"/.test(new q().outerHTML))throw j}catch(G){(function(){var X="attributeChangedCallback",K="connectedCallback",N="disconnectedCallback",B=Element.prototype,L=$.assign,A=$.create,U=$.defineProperties,W=$.getOwnPropertyDescriptor,R=$.setPrototypeOf,z=Z.define,M=Z.get,O=Z.upgrade,T=Z.whenDefined,C=A(null),k=new WeakMap,I={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(Y){return typeof Y=="string"&&/^HTML(?!Element)/.test(Y)}).forEach(function(Y){function F(){}var D=self[Y];R(F,D),(F.prototype=D.prototype).constructor=F,D={},D[Y]={value:F},U(self,D)}),new MutationObserver(K0).observe(Q,I),U0(Document.prototype,"importNode"),U0(Node.prototype,"cloneNode"),U(Z,{define:{value:function(Y,F,D){if(Y=Y.toLowerCase(),D&&J in D){C[Y]=L({},D,{Class:F});var E=D[J]+'[is="'+Y+'"]',P=Q.querySelectorAll(E);for(var f=0,x=P.length;f<x;f++)s(P[f])}else z.apply(Z,arguments)}},get:{value:function(Y){return Y in C?C[Y].Class:M.call(Z,Y)}},upgrade:{value:function(Y){var F=Z0(Y);if(F&&!(Y instanceof F.Class))W0(Y,F);else O.call(Z,Y)}},whenDefined:{value:function(Y){return Y in C?Promise.resolve():T.call(Z,Y)}}});var S=Q.createElement;U(Q,{createElement:{value:function(Y,F){var D=S.call(Q,Y);if(F&&"is"in F)D.setAttribute("is",F.is),Z.upgrade(D);return D}}});var w=W(B,"attachShadow").value,d=W(B,"innerHTML");U(B,{attachShadow:{value:function(){var Y=w.apply(this,arguments);return new MutationObserver(K0).observe(Y,I),Y}},innerHTML:{get:d.get,set:function(Y){if(d.set.call(this,Y),/\bis=("|')?[a-z0-9_-]+\1/i.test(Y))o(this,s)}}});function K0(Y){for(var F=0,D=Y.length;F<D;F++){var E=Y[F],P=E.addedNodes,f=E.removedNodes;for(var x=0,l=P.length;x<l;x++)s(P[x]);for(var $0=0,O1=f.length;$0<O1;$0++)N0(f[$0])}}function Y0(Y){for(var F=0,D=Y.length;F<D;F++){var E=Y[F],P=E.attributeName,f=E.oldValue,x=E.target,l=x.getAttribute(P);if(X in x&&!(f==l&&l==null))x[X](P,f,x.getAttribute(P),null)}}function N0(Y){if(Y.nodeType!==1)return;var F=Z0(Y);if(F&&Y instanceof F.Class&&N in Y&&k.get(Y)!==N)k.set(Y,N),Promise.resolve(Y).then(M1);o(Y,N0)}function Z0(Y){var F=Y.getAttribute("is");if(F){if(F=F.toLowerCase(),F in C)return C[F]}return null}function B1(Y){Y[K]()}function M1(Y){Y[N]()}function W0(Y,F){var D=F.Class,E=D.observedAttributes||[];if(R(Y,D.prototype),E.length){new MutationObserver(Y0).observe(Y,{attributes:!0,attributeFilter:E,attributeOldValue:!0});var P=[];for(var f=0,x=E.length;f<x;f++)P.push({attributeName:E[f],oldValue:null,target:Y});Y0(P)}}function s(Y){if(Y.nodeType!==1)return;var F=Z0(Y);if(F){if(!(Y instanceof F.Class))W0(Y,F);if(K in Y&&Y.isConnected&&k.get(Y)!==K)k.set(Y,K),Promise.resolve(Y).then(B1)}o(Y,s)}function o(Y,F){for(var D=Y.content,E=(D&&D.nodeType==11?D:Y).querySelectorAll("[is]"),P=0,f=E.length;P<f;P++)F(E[P])}function U0(Y,F){var D=Y[F],E={};E[F]={value:function(){var P=D.apply(this,arguments);switch(P.nodeType){case 1:case 11:o(P,s)}return P}},U(Y,E)}})()}})(document,customElements,Object)});function z1(){if(typeof navigator>"u")return!1;let Q=navigator.userAgent||"",Z=/\b(iPad|iPhone|iPod)\b/.test(Q)||/\bMacintosh\b/.test(Q)&&/\bMobile\b/.test(Q),$=/\bAppleWebKit\b/.test(Q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(Q);return Z||$}function v(Q,Z={}){let $=document.createElement("fig-icon");if(Q)$.setAttribute("name",Q);if(Z.size)$.setAttribute("size",Z.size);if(Z.className)$.className=Z.className;return $}function b(Q,Z){requestAnimationFrame(()=>{if(Q&&!Q.isConnected)return;Z()})}function A0({owner:Q,onStart:Z,onEnd:$,startClass:J="",endClass:j="",chevronClass:_=""}={}){let q=(G,X)=>{let K=document.createElement("button");if(K.className=["fig-overflow",`fig-overflow-${G}`,G==="start"?J:j].filter(Boolean).join(" "),K.dataset.figOverflow=G,Q)K.setAttribute(`data-fig-${Q}-nav`,G);return K.setAttribute("tabindex","-1"),K.setAttribute("aria-label",G==="start"?"Scroll back":"Scroll forward"),K.appendChild(v("chevron",{size:"small",className:["fig-overflow-chevron",_].filter(Boolean).join(" ")})),K.addEventListener("click",(N)=>{N.preventDefault(),N.stopPropagation(),X?.(N)}),K};return{start:q("start",Z),end:q("end",$)}}function F0(Q,Z,$="x",J=2){if(!Q||!Z)return!1;let j=$==="x",_=j?Z.scrollWidth:Z.scrollHeight,q=j?Z.clientWidth:Z.clientHeight,G=j?Z.scrollLeft:Z.scrollTop,X=_-q>J,K=!X||G<=J,N=!X||G+q>=_-J;return Q.classList.toggle("overflow-start",!K),Q.classList.toggle("overflow-end",!N),X}function J0(Q,Z="x",$=1){if(!Q)return;let J=Z==="x",_=(J?Q.clientWidth:Q.clientHeight)*0.8*$;Q.scrollBy({[J?"left":"top"]:_,behavior:"smooth"})}function u(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function H1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let Q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class Z extends HTMLButtonElement{}try{return customElements.define(Q,Z,{extends:"button"}),document.createElement("button",{is:Q})instanceof Z}catch($){return!1}}var z0=z1()&&!H1(),D1=(z0?Promise.resolve().then(() => (L0(),F1)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q});function j0(Q,Z,$){let J=()=>{if(!customElements.get(Q))customElements.define(Q,Z,$)};if(!z0){J();return}D1.then(J).catch((j)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${Q}".`,j)})}function y(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function a(){if(!document.body)return null;let Q="data-figui-overlay-root",Z=document.body.querySelector(`:scope > [${Q}]`);if(!Z)Z=document.createElement("div"),Z.setAttribute(Q,""),document.body.append(Z);return Z}var R1=1e4;function T1(){return R1++}function V(Q,Z,$){if($&&$.trim())Q.style.setProperty(Z,$.trim());else Q.style.removeProperty(Z)}var m=null,B0=null;function _0(Q=1,Z=1){if(!m)m=document.createElement("canvas"),B0=m.getContext("2d");if(m.width!==Q)m.width=Q;if(m.height!==Z)m.height=Z;return{canvas:m,ctx:B0}}class H0 extends HTMLElement{type;#Z;#Q=["aria-label","aria-labelledby","aria-describedby","title"];#J=this.#Y.bind(this);#$=this.#G.bind(this);#j=()=>{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 Q=this.type==="select"||this.type==="upload",Z=Q?"span":"button",$=Q?"":` type="${this.type}"`;this.shadowRoot.innerHTML=`
1
+ var D1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var R1={};var O0=D1(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(Q,Z,$){if(Q.importNode.length!=1||Z.get("ungap-li"))return;var J="extends";try{var j={};j[J]="li";var _=HTMLLIElement,q=function(){return Reflect.construct(_,[],q)};if(q.prototype=$.create(_.prototype),Z.define("ungap-li",q,j),!/is="ungap-li"/.test(new q().outerHTML))throw j}catch(G){(function(){var X="attributeChangedCallback",K="connectedCallback",N="disconnectedCallback",M=Element.prototype,L=$.assign,z=$.create,U=$.defineProperties,W=$.getOwnPropertyDescriptor,R=$.setPrototypeOf,H=Z.define,B=Z.get,O=Z.upgrade,T=Z.whenDefined,C=z(null),k=new WeakMap,I={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(Y){return typeof Y=="string"&&/^HTML(?!Element)/.test(Y)}).forEach(function(Y){function A(){}var D=self[Y];R(A,D),(A.prototype=D.prototype).constructor=A,D={},D[Y]={value:A},U(self,D)}),new MutationObserver(W0).observe(Q,I),M0(Document.prototype,"importNode"),M0(Node.prototype,"cloneNode"),U(Z,{define:{value:function(Y,A,D){if(Y=Y.toLowerCase(),D&&J in D){C[Y]=L({},D,{Class:A});var E=D[J]+'[is="'+Y+'"]',P=Q.querySelectorAll(E);for(var f=0,x=P.length;f<x;f++)s(P[f])}else H.apply(Z,arguments)}},get:{value:function(Y){return Y in C?C[Y].Class:B.call(Z,Y)}},upgrade:{value:function(Y){var A=$0(Y);if(A&&!(Y instanceof A.Class))B0(Y,A);else O.call(Z,Y)}},whenDefined:{value:function(Y){return Y in C?Promise.resolve():T.call(Z,Y)}}});var S=Q.createElement;U(Q,{createElement:{value:function(Y,A){var D=S.call(Q,Y);if(A&&"is"in A)D.setAttribute("is",A.is),Z.upgrade(D);return D}}});var w=W(M,"attachShadow").value,d=W(M,"innerHTML");U(M,{attachShadow:{value:function(){var Y=w.apply(this,arguments);return new MutationObserver(W0).observe(Y,I),Y}},innerHTML:{get:d.get,set:function(Y){if(d.set.call(this,Y),/\bis=("|')?[a-z0-9_-]+\1/i.test(Y))o(this,s)}}});function W0(Y){for(var A=0,D=Y.length;A<D;A++){var E=Y[A],P=E.addedNodes,f=E.removedNodes;for(var x=0,l=P.length;x<l;x++)s(P[x]);for(var J0=0,H1=f.length;J0<H1;J0++)L0(f[J0])}}function U0(Y){for(var A=0,D=Y.length;A<D;A++){var E=Y[A],P=E.attributeName,f=E.oldValue,x=E.target,l=x.getAttribute(P);if(X in x&&!(f==l&&l==null))x[X](P,f,x.getAttribute(P),null)}}function L0(Y){if(Y.nodeType!==1)return;var A=$0(Y);if(A&&Y instanceof A.Class&&N in Y&&k.get(Y)!==N)k.set(Y,N),Promise.resolve(Y).then(A1);o(Y,L0)}function $0(Y){var A=Y.getAttribute("is");if(A){if(A=A.toLowerCase(),A in C)return C[A]}return null}function z1(Y){Y[K]()}function A1(Y){Y[N]()}function B0(Y,A){var D=A.Class,E=D.observedAttributes||[];if(R(Y,D.prototype),E.length){new MutationObserver(U0).observe(Y,{attributes:!0,attributeFilter:E,attributeOldValue:!0});var P=[];for(var f=0,x=E.length;f<x;f++)P.push({attributeName:E[f],oldValue:null,target:Y});U0(P)}}function s(Y){if(Y.nodeType!==1)return;var A=$0(Y);if(A){if(!(Y instanceof A.Class))B0(Y,A);if(K in Y&&Y.isConnected&&k.get(Y)!==K)k.set(Y,K),Promise.resolve(Y).then(z1)}o(Y,s)}function o(Y,A){for(var D=Y.content,E=(D&&D.nodeType==11?D:Y).querySelectorAll("[is]"),P=0,f=E.length;P<f;P++)A(E[P])}function M0(Y,A){var D=Y[A],E={};E[A]={value:function(){var P=D.apply(this,arguments);switch(P.nodeType){case 1:case 11:o(P,s)}return P}},U(Y,E)}})()}})(document,customElements,Object)});function T1(){if(typeof navigator>"u")return!1;let Q=navigator.userAgent||"",Z=/\b(iPad|iPhone|iPod)\b/.test(Q)||/\bMacintosh\b/.test(Q)&&/\bMobile\b/.test(Q),$=/\bAppleWebKit\b/.test(Q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(Q);return Z||$}function v(Q,Z={}){let $=document.createElement("fig-icon");if(Q)$.setAttribute("name",Q);if(Z.size)$.setAttribute("size",Z.size);if(Z.className)$.className=Z.className;return $}function b(Q,Z){requestAnimationFrame(()=>{if(Q&&!Q.isConnected)return;Z()})}function n(Q){Q.querySelectorAll(':scope > [slot="prepend"], :scope > [slot="append"]').forEach((Z)=>{if(Z.children.length>0){j0(Z);return}let $=Z.textContent.trim();if(!$){j0(Z);return}let J=Z.dataset.figInputSlotFullText||"",j=J?Array.from(J)[0]?.toUpperCase():"",_=$===j?J:$,G=Array.from($)[0].toUpperCase();if(Z.textContent!==G)Z.textContent=G;if(_&&_!==G)Z.dataset.figInputSlotFullText=_,Z.setAttribute("aria-label",_),P1(Z);else j0(Z)})}function P1(Q){if(Q.dataset.figInputSlotTooltipBound==="true")return;Q.dataset.figInputSlotTooltipBound="true",Q.addEventListener("pointerenter",F0),Q.addEventListener("pointerleave",_0),Q.addEventListener("focus",F0),Q.addEventListener("blur",_0)}function j0(Q){_0({currentTarget:Q}),delete Q.dataset.figInputSlotFullText,Q.removeAttribute("aria-label")}function F0(Q){let Z=Q.currentTarget,$=Z?.dataset?.figInputSlotFullText;if(!Z||!$)return;F.show(Z,$)}function _0(Q){let Z=Q.currentTarget;if(!Z)return;F.hide(Z)}function D0({owner:Q,onStart:Z,onEnd:$,startClass:J="",endClass:j="",chevronClass:_=""}={}){let q=(G,X)=>{let K=document.createElement("button");if(K.className=["fig-overflow",`fig-overflow-${G}`,G==="start"?J:j].filter(Boolean).join(" "),K.dataset.figOverflow=G,Q)K.setAttribute(`data-fig-${Q}-nav`,G);return K.setAttribute("tabindex","-1"),K.setAttribute("aria-label",G==="start"?"Scroll back":"Scroll forward"),K.appendChild(v("chevron",{size:"small",className:["fig-overflow-chevron",_].filter(Boolean).join(" ")})),K.addEventListener("click",(N)=>{N.preventDefault(),N.stopPropagation(),X?.(N)}),K};return{start:q("start",Z),end:q("end",$)}}function R0(Q,Z,$="x",J=2){if(!Q||!Z)return!1;let j=$==="x",_=j?Z.scrollWidth:Z.scrollHeight,q=j?Z.clientWidth:Z.clientHeight,G=j?Z.scrollLeft:Z.scrollTop,X=_-q>J,K=!X||G<=J,N=!X||G+q>=_-J;return Q.classList.toggle("overflow-start",!K),Q.classList.toggle("overflow-end",!N),X}function q0(Q,Z="x",$=1){if(!Q)return;let J=Z==="x",_=(J?Q.clientWidth:Q.clientHeight)*0.8*$;Q.scrollBy({[J?"left":"top"]:_,behavior:"smooth"})}function u(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function E1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let Q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class Z extends HTMLButtonElement{}try{return customElements.define(Q,Z,{extends:"button"}),document.createElement("button",{is:Q})instanceof Z}catch($){return!1}}var T0=T1()&&!E1(),C1=(T0?Promise.resolve().then(() => (O0(),R1)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q});function G0(Q,Z,$){let J=()=>{if(!customElements.get(Q))customElements.define(Q,Z,$)};if(!T0){J();return}C1.then(J).catch((j)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${Q}".`,j)})}function y(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function a(){if(!document.body)return null;let Q="data-figui-overlay-root",Z=document.body.querySelector(`:scope > [${Q}]`);if(!Z)Z=document.createElement("div"),Z.setAttribute(Q,""),document.body.append(Z);return Z}var S1=1e4;function k1(){return S1++}function V(Q,Z,$){if($&&$.trim())Q.style.setProperty(Z,$.trim());else Q.style.removeProperty(Z)}var m=null,z0=null;function X0(Q=1,Z=1){if(!m)m=document.createElement("canvas"),z0=m.getContext("2d");if(m.width!==Q)m.width=Q;if(m.height!==Z)m.height=Z;return{canvas:m,ctx:z0}}class P0 extends HTMLElement{type;#Z;#Q=["aria-label","aria-labelledby","aria-describedby","title"];#J=this.#Y.bind(this);#$=this.#G.bind(this);#j=()=>{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 Q=this.type==="select"||this.type==="upload",Z=Q?"span":"button",$=Q?"":` type="${this.type}"`;this.shadowRoot.innerHTML=`
2
2
  <style>
3
3
  button, button:hover, button:active, .fig-button-control {
4
4
  padding: 0 var(--spacer-2);
@@ -34,9 +34,9 @@ var A1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var F1={};var L0=A1(()=>{/*! Vendored from @
34
34
  <${Z} class="fig-button-control"${$}>
35
35
  <slot></slot>
36
36
  </${Z}>
37
- `,this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.button.addEventListener("click",this.#$),this.button.addEventListener("focus",this.#j),this.button.addEventListener("blur",this.#q),this.addEventListener("keydown",this.#J)}this.#Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#N()}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#Z}set selected(Q){this.setAttribute("selected",Q)}#_(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#G(){if(this.#_())return;if(this.type==="toggle")this.toggleAttribute("selected",!this.hasAttribute("selected"));if(this.type==="submit"){let Q=this.closest("form");if(Q)Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),Z=this.getAttribute("target");if(Q)if(Z)window.open(Q,Z);else window.location.href=Q}}#X(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#W(){let Q=this.#X();if(Q instanceof HTMLSelectElement)return Q;if(Q?.tagName==="FIG-DROPDOWN")return Q.select||Q.querySelector?.("select")||null;return null}#Y(Q){if(this.type!=="select")return;if(Q.key!=="Enter")return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;let Z=this.#W();if(!Z||Z.disabled||Z.multiple)return;if(typeof Z.showPicker!=="function")return;Q.preventDefault();try{Z.showPicker()}catch{}}#K(){if(!this.button)return;if(this.type!=="toggle"){this.removeAttribute("aria-pressed"),this.button.removeAttribute("aria-pressed");return}let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.setAttribute("aria-pressed",Q?"true":"false"),this.button.setAttribute("aria-pressed",Q?"true":"false")}#U(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#Q.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.button.removeAttribute(Q);else this.button.setAttribute(Q,Z)})}#N(){if(!this.button)return;let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=Q,this.button instanceof HTMLButtonElement)this.button.disabled=Q,this.button.type=this.type,this.button.setAttribute("type",this.type);this.#U(),this.#K()}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"type":{let J=(j)=>j==="select"||j==="upload";if(J(Z||"button")!==J($||"button")){this.button=null,this.connectedCallback();break}this.#N();break}case"disabled":this.#N();break;case"selected":this.#Z=$!==null&&$!=="false",this.#K();break;default:this.#U();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#J)}}customElements.define("fig-button",H0);class D0 extends HTMLElement{#Z="Menu";#Q=null;#J;#$;#j;#q=!1;#_=null;get label(){return this.#Z}set label(Q){this.#Z=Q}#G;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#J=this.#L.bind(this),this.#$=this.#O.bind(this),this.#j=this.#B.bind(this),this.#G=this.slotChange.bind(this)}#X(){if(typeof CSS>"u"||typeof CSS.supports!=="function")return!1;try{return CSS.supports("appearance: base-select")&&CSS.supports("selector(::picker(select))")}catch{return!1}}#W(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#X()){this.#q=!1;return}let $=document.createElement("button");$.setAttribute("type","button"),$.setAttribute("aria-hidden","true");let J=document.createElement("selectedcontent");$.appendChild(J),this.select.appendChild($),this.#q=!0,this.#_=J}#Y(){if(!this.#_)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#_.textContent="";return}this.#_.innerHTML=Q.innerHTML}#K(){this.select.addEventListener("input",this.#J),this.select.addEventListener("change",this.#$),this.select.addEventListener("keydown",this.#j)}#U(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#N(){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.#M(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#G),this.optionsSlot.addEventListener("slotchange",this.#G),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#j),this.#K()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.#W(),this.type==="dropdown"){let Q=document.createElement("option");Q.setAttribute("hidden","true"),Q.setAttribute("selected","true"),Q.selected=!0,this.select.appendChild(Q)}if(this.optionsSlot.assignedNodes().forEach((Q)=>{if(Q.nodeName==="OPTION"||Q.nodeName==="OPTGROUP")this.select.appendChild(Q.cloneNode(!0))}),this.#z(this.value),this.#Y(),this.type==="dropdown")this.select.selectedIndex=-1}#L(Q){let Z=Q.target.selectedOptions?.[0];if(this.#U(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#N();return}let $=Q.target.value;if(this.type==="dropdown")this.#Q=$;this.setAttribute("value",$),this.#Y(),this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}#O(Q){let Z=Q.target.selectedOptions?.[0];if(this.#U(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#N();return}let $=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#Y(),this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,composed:!0}))}#B(Q){if(this.closest('fig-button[type="select"]'))return;if(Q.key!=="Enter"||Q.defaultPrevented)return;if(this.#q&&this.select.matches(":open"))return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(typeof this.select.showPicker!=="function")return;Q.preventDefault();try{this.select.showPicker()}catch{}}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#Q;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#Q=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","experimental","label","disabled"]}#M(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=Q}#z(Q){if(this.type==="dropdown")return;if(this.select)this.select.querySelectorAll("option").forEach((Z,$)=>{if(Z.value===this.getAttribute("value"))this.select.selectedIndex=$});this.#Y()}attributeChangedCallback(Q,Z,$){if(Q==="value")this.#z($);if(Q==="type")this.type=$;if(Q==="experimental")this.slotChange();if(Q==="label")this.#Z=$,this.select.setAttribute("aria-label",this.#Z);if(Q==="disabled")this.#M()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#G),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#j)}}customElements.define("fig-dropdown",D0);class H extends HTMLElement{static#Z=0;static#Q=0;static#J=1000;static#$=null;static#j=!1;#q;#_;#G;#X;#W;#Y;#K;#U;#N;#L;#O=null;#B=null;#M=null;#z;#A=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#q=this.#V.bind(this),this.#_=this.hidePopupOutsideClick.bind(this),this.#G=this.showDelayedPopup.bind(this),this.#X=this.#f.bind(this),this.#W=this.#T.bind(this),this.#Y=this.#C.bind(this),this.#K=this.#E.bind(this),this.#U=this.#P.bind(this),this.#L=this.#I.bind(this),this.#N=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(H.#y(),this.setup(),this.#R(),this.setupEventListeners(),this.#O=this.closest("dialog"),this.#O)this.#O.addEventListener("close",this.#N)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#F(),this.#H(),document.removeEventListener("mousedown",this.#q,!0),document.removeEventListener("keydown",this.#L,!0),this.#O)this.#O.removeEventListener("close",this.#N),this.#O=null;if(this.action==="click")document.body.removeEventListener("click",this.#_);if(clearTimeout(this.#z),H.#$===this)H.#$=null}#D(){return this.firstElementChild}#H(){this.#M?.disconnect(),this.#M=null}#R(){if(this.#F(),this.action==="manual")return;let Q=this.#D();if(!Q){if(!this.#M&&typeof MutationObserver<"u")this.#M=new MutationObserver(()=>{if(this.#D())this.#H(),this.#R()}),this.#M.observe(this,{childList:!0});return}if(this.#B=Q,this.action==="hover"){if(!this.isTouchDevice())Q.addEventListener("pointerenter",this.#G),Q.addEventListener("pointerleave",this.#X);Q.addEventListener("touchstart",this.#W,{passive:!0}),Q.addEventListener("touchmove",this.#Y,{passive:!0}),Q.addEventListener("touchend",this.#K,{passive:!0}),Q.addEventListener("touchcancel",this.#U,{passive:!0})}else if(this.action==="click")Q.addEventListener("click",this.#G),Q.addEventListener("touchstart",this.#G,{passive:!0})}#F(){let Q=this.#B;if(!Q)return;if(this.action==="hover")Q.removeEventListener("pointerenter",this.#G),Q.removeEventListener("pointerleave",this.#X),Q.removeEventListener("touchstart",this.#W),Q.removeEventListener("touchmove",this.#Y),Q.removeEventListener("touchend",this.#K),Q.removeEventListener("touchcancel",this.#U);else if(this.action==="click")Q.removeEventListener("click",this.#G),Q.removeEventListener("touchstart",this.#G);this.#B=null}setup(){this.style.display="contents"}render(){this.destroy();let Q=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"),Q)this.popup.setAttribute("popover","manual");let $=y();this.popup.setAttribute("id",$);let J=this.getAttribute("theme");if(J)this.popup.setAttribute("theme",J);let j=this.getAttribute("pointer");if(j!==null)this.popup.setAttribute("pointer",j);if(this.popup.append(Z),Z.innerText=this.getAttribute("text")??"",this.firstElementChild)this.firstElementChild.setAttribute("aria-describedby",$);if(Q)(a()??document.body).append(this.popup);else{let _=this.closest("dialog");if(_&&_.open)_.append(this.popup);else(a()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.popup.hidePopup?.(),this.popup.remove(),this.popup=null;if(this.action==="click")document.body.removeEventListener("click",this.#_)}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#_);document.addEventListener("mousedown",this.#q,!0),document.addEventListener("keydown",this.#L,!0)}get#S(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#k(){let Q=Date.now(),Z=H.#J;if(this.action==="hover"&&H.#$)return!0;if(H.#Z&&Q-H.#Z<Z)return!0;if(H.#Q&&Q-H.#Q<Z)return!0;return!1}showDelayedPopup(){if(this.#S)return;if(clearTimeout(this.timeout),this.#k()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#O&&!this.#O.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&H.#$&&H.#$!==this)H.#$.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")H.#$=this;H.#Z=Date.now()}hidePopup(){if(this.#S)return;clearTimeout(this.timeout),clearTimeout(this.#z);let Q=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,H.#$===this)H.#$=null;if(Q)H.#Q=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#f(Q){if(!this.#A)this.hidePopup()}#T(Q){if(this.action==="hover")this.#A=!0,clearTimeout(this.#z),this.showDelayedPopup()}#C(Q){if(this.action==="hover"&&this.#A)clearTimeout(this.#z),this.#z=setTimeout(()=>{this.#A=!1,this.hidePopup()},150)}#E(Q){if(this.action==="hover"&&this.#A)clearTimeout(this.#z),this.#z=setTimeout(()=>{this.#A=!1,this.hidePopup()},300)}#P(Q){if(this.action==="hover"&&this.#A)this.#A=!1,clearTimeout(this.#z),this.hidePopup()}#I(Q){if(!this.isOpen&&!this.popup||Q.key!=="Escape")return;Q.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(Q){this.setAttribute("text",Q)}#g(Q){if(!this.popup)return;let Z=this.popup.firstElementChild??this.popup.firstChild;if(!Z)return;Z.innerText=Q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")==="true"}set open(Q){this.setAttribute("open",Q)}attributeChangedCallback(Q,Z,$){if(Q==="action")this.action=$;if(Q==="delay"){let J=parseInt($);this.delay=!isNaN(J)?J:500}if(Q==="open")if($==="true")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(Q==="show")if($!==null&&$!=="false")this.showPopup();else this.hidePopup();if(Q==="text")this.#g($??"");if(Q==="pointer"){if(this.popup)if($!==null)this.popup.setAttribute("pointer",$);else this.popup.removeAttribute("pointer")}if(Q==="theme"){if(this.popup)if($)this.popup.setAttribute("theme",$);else this.popup.removeAttribute("theme")}}#V(Q){if(!this.isOpen)return;let Z=Q.target;if(this.popup&&this.popup.contains(Z))return;if(Z.tagName==="SELECT"||Z.hasAttribute("popover")||Z.closest("dialog"))this.hidePopup()}static#y(){if(H.#j)return;H.#j=!0;let Q=()=>{H.#w()};document.documentElement.addEventListener("mouseleave",Q),document.addEventListener("mouseout",(Z)=>{if(Z.relatedTarget)return;Q()});try{let Z=window.frameElement;if(Z)Z.addEventListener("mouseleave",Q)}catch{}window.addEventListener("message",(Z)=>{if(Z?.data?.type!=="figui:dismiss-tooltips")return;if(window.parent!==window&&Z.source!==window.parent)return;Q()})}static#w(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof H))continue;if(Q.action!=="hover")continue;if(Q.hasAttribute("show")&&Q.getAttribute("show")!=="false")continue;if(Q.isOpen||Q.timeout)Q.hidePopup()}}static#v=new WeakMap;static show(Q,Z,$={}){H.hide(Q);let J=$.delay??500,_=Date.now()-H.#Z<H.#J?0:J,q={timeout:null,popup:null};H.#v.set(Q,q),q.timeout=setTimeout(()=>{let G=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,X=document.createElement("dialog",{is:"fig-popup"});if(X.setAttribute("is","fig-popup"),X.setAttribute("variant","tooltip"),X.setAttribute("data-tooltip-managed",""),X.setAttribute("role","tooltip"),X.setAttribute("closedby","closerequest"),G)X.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=Z,X.append(K),G)(a()??document.body).append(X);else{let N=Q.closest?.("dialog");if(N&&N.open)N.append(X);else(a()??document.body).append(X)}X.anchor=Q,X.open=!0,q.popup=X,H.#Z=Date.now()},_)}static hide(Q){let Z=H.#v.get(Q);if(!Z)return;if(clearTimeout(Z.timeout),Z.popup)Z.popup.remove();H.#v.delete(Q)}}customElements.define("fig-tooltip",H);class R0 extends HTMLElement{static observedAttributes=["position","tail"];#Z=null;#Q=null;#J=null;connectedCallback(){this.#Z=this.textContent,b(this,()=>{this.#$(),this.#j()})}disconnectedCallback(){this.#q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(this.#Z===null)return;this.#$()}#$(){let Q=this.getAttribute("position")||"right",Z=this.#Z||"";if(Q==="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.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=Z.slice(0,J);let _=document.createElement("span");_.className="end",_.textContent=Z.slice(J),this.appendChild(j),this.appendChild(_)}else this.textContent=Z}#j(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;H.show(this,this.#Z)},this.#J=()=>{H.hide(this)},this.addEventListener("pointerenter",this.#Q),this.addEventListener("pointerleave",this.#J)}#q(){if(this.#Q)this.removeEventListener("pointerenter",this.#Q);if(this.#J)this.removeEventListener("pointerleave",this.#J);H.hide(this)}}customElements.define("fig-truncate",R0);class T0 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(){this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),b(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((Q)=>{Q.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize(),this._teardownIframeDismissListeners(),this.removeEventListener("close",this._boundRestoreFocus)}_captureFocusBeforeOpen(){let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}_restoreFocus(){let Q=this._previousFocus;if(this._previousFocus=null,!Q?.isConnected)return;let Z=document.activeElement;if(Z&&Z!==document.body&&!this.contains(Z))return;requestAnimationFrame(()=>Q.focus?.())}show(){return this._captureFocusBeforeOpen(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),super.show()}showModal(){return this._captureFocusBeforeOpen(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),super.showModal()}_handleIframeMouseLeave(Q){let Z=Q?.currentTarget;if(!(Z instanceof HTMLIFrameElement))return;try{Z.contentWindow?.postMessage({type:"figui:dismiss-tooltips"},"*")}catch{}}_syncIframeDismissListeners(){for(let Q of this.querySelectorAll(":scope > iframe")){if(!(Q instanceof HTMLIFrameElement))continue;if(Q.dataset.figuiDismissBound==="true")continue;Q.dataset.figuiDismissBound="true",Q.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 Q of this.querySelectorAll(":scope > iframe"))Q.removeEventListener("mouseleave",this._boundIframeMouseLeave),delete Q.dataset.figuiDismissBound}_handleIframeMessage(Q){if(!this.autoresize)return;let Z=Q?.data;if(!Z||Z.type!=="figui:iframe-resize")return;let $=Q.source;if(!$)return;let J=Array.from(this.querySelectorAll("iframe")).find((j)=>j.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 Q of this.children)try{this._resizeObserver.observe(Q)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((Q)=>{for(let Z of Q)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(Q){let Z=window.getComputedStyle(this),$=parseFloat(Z.paddingTop||"0")+parseFloat(Z.paddingBottom||"0")+parseFloat(Z.borderTopWidth||"0")+parseFloat(Z.borderBottomWidth||"0"),J=0,j=parseFloat(Z.rowGap||Z.gap||"0")||0,_=0;for(let q of this.children){let G=q.getBoundingClientRect();if(G.height===0)continue;if(_+=1,q===Q)continue;let X=window.getComputedStyle(q),K=parseFloat(X.marginTop||"0")+parseFloat(X.marginBottom||"0");J+=G.height+K}if(j&&_>1)J+=j*(_-1);return $+J}_resizeForIframe(Q,Z){if(typeof Z.height!=="number"||!(Z.height>0))return;let $=this._computeChrome(Q);this.style.height=`${Math.ceil(Z.height+$)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){if(this.querySelector("fig-header[dialog-header]"))return;let Q=document.createElement("fig-header");Q.setAttribute("dialog-header",""),Q.setAttribute("data-auto","");let Z=document.createElement("h3");Z.textContent=this.getAttribute("title")||"Dialog";let $=document.createElement("fig-tooltip");$.setAttribute("text","Close");let J=document.createElement("fig-button");J.setAttribute("variant","ghost"),J.setAttribute("icon",""),J.setAttribute("aria-label","Close dialog"),J.setAttribute("close-dialog",""),J.appendChild(v("close")),$.appendChild(J),Q.appendChild(Z),Q.appendChild($),this.prepend(Q)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close dialog");Q.removeEventListener("click",this._boundClose),Q.addEventListener("click",this._boundClose)})}_syncA11y(){if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let Q=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(Q){let Z=Q.getAttribute("id")||y();Q.setAttribute("id",Z),this.setAttribute("aria-labelledby",Z)}}}_applyPosition(){let Q=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=Q.includes("top"),$=Q.includes("bottom"),J=Q.includes("left"),j=Q.includes("right"),_=Q.includes("center")&&!Z&&!$,q=Q.includes("center")&&!J&&!j;if(Z)this.style.top=`${this._offset}px`;else if($)this.style.bottom=`${this._offset}px`;else if(_)this.style.top="0",this.style.bottom="0";if(J)this.style.left=`${this._offset}px`;else if(j)this.style.right=`${this._offset}px`;else if(q)this.style.left="0",this.style.right="0";if(_&&q)this.style.margin="auto";else if(_)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 Q=this.getAttribute("handle"),Z=Q?this.querySelector(Q):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)}_isInteractiveElement(Q){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=(_)=>Z.some((q)=>_.matches?.(q))||_.tagName?.startsWith("FIG-")&&!$.includes(_.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.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=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}_handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Q==="autoresize"&&this.isConnected)this._syncAutoResize();if(Q==="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(Q==="position"&&this._positionInitialized)this._applyPosition();if(Q==="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(Q==="closedby")this.closedby=$||"any";if(Q==="title"){let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";this._syncA11y()}if(Q==="aria-label"||Q==="aria-labelledby")this._syncA11y()}}j0("fig-dialog",T0,{extends:"dialog"});class P0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._boundHandleClose=this.handleClose.bind(this)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast()}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close notification");Q.removeEventListener("click",this._boundHandleClose),Q.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto",this.style.bottom=`${parseInt(this.getAttribute("offset")??this._defaultOffset)}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let Q=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger";if(!this.hasAttribute("role"))this.setAttribute("role",Q?"alert":"status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live",Q?"assertive":"polite");if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}startAutoClose(){this.clearAutoClose();let Q=parseInt(this.getAttribute("duration")??"5000");if(Q>0)this._autoCloseTimer=setTimeout(()=>this.hideToast(),Q)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}showToast(){if(this.syncLiveRegion(),!this.open)this.show();this.applyPosition(),this.startAutoClose(),this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){if(this.clearAutoClose(),this.open)this.close();this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Z===$)return;if(!this.isConnected)return;if(Q==="offset")this.applyPosition();if(Q==="open")if($!==null&&$!=="false")this.showToast();else this.hideToast();if(Q==="theme"||Q==="live")this.syncLiveRegion()}}j0("fig-toast",P0,{extends:"dialog"});class E0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_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;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{let Z=Q.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)}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._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._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{let Z=Q.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)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!this.open)return;this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else if(Q&&typeof Q.getBoundingClientRect==="function")this._anchorRef=Q;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.addEventListener("close",()=>{if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}),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),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(Q,Z,$){if(this.ensureInitialized(),Z===$)return;if(Q==="open"){if($===null||$==="false"){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=$!==null&&$!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();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(T1()+1),this.captureFocusBeforeOpen();let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),Z=this.shouldAutoReposition();if(Z)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(J){}if(!Q&&!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),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let $=this.resolveAnchor();if($?.classList)$.classList.add("has-popup-open")}hidePopup(){let Q=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),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch($){}if(this.matches?.(":open"))try{this.close()}catch($){}if(Q)this.restoreFocusAfterClose()}shouldRestoreFocus(){return this.getAttribute("variant")!=="tooltip"}captureFocusBeforeOpen(){if(!this.shouldRestoreFocus())return;let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}restoreFocusAfterClose(){if(!this.shouldRestoreFocus()){this._previousFocus=null;return}let Q=this.resolveAnchor(),Z=this._previousFocus?.isConnected?this._previousFocus:Q instanceof HTMLElement?Q:null;if(this._previousFocus=null,!Z?.isConnected)return;let $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Z.focus?.())}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.removeAttribute("autoresize")}setupObservers(){this.teardownObservers();let Q=this.resolveAnchor();if(Q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(Q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),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(Q){if(!Q)return null;let Z=Q.getBoundingClientRect();return{x:Z.x,y:Z.y,width:Z.width,height:Z.height}}hasRectChanged(Q,Z,$=0.25){if(!Q&&!Z)return!1;if(!Q||!Z)return!0;return Math.abs(Q.x-Z.x)>$||Math.abs(Q.y-Z.y)>$||Math.abs(Q.width-Z.width)>$||Math.abs(Q.height-Z.height)>$}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{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(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!super.open)return;let Z=this.getAttribute("closedby");if(Z==="none"||Z==="closerequest")return;let $=Q.target;if(!($ instanceof Node))return;if(this.contains($))return;let J=this.resolveAnchor();if(J?.contains&&J.contains($))return;if(this.isInsideDescendantPopup($))return;this.open=!1}handleDocumentKeydown(Q){if(Q.key!=="Escape"||Q.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[is="fig-popup"][open]')).filter((j)=>j.open).map((j)=>({popup:j,z:Number.parseInt(getComputedStyle(j).zIndex||"0",10)||0})).sort((j,_)=>j.z-_.z).at(-1)?.popup;if(J&&J!==this)return;Q.preventDefault(),this.open=!1}isInsideDescendantPopup(Q){let Z=Q.closest?.('dialog[is="fig-popup"]');if(!Z||Z===this)return!1;let $=Z,J=new Set;while($&&!J.has($)){J.add($);let j=$.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;$=j.closest?.('dialog[is="fig-popup"]')}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)}isInteractiveElement(Q){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=(_)=>Z.some((q)=>_.matches?.(q))||_.tagName?.startsWith("FIG-")&&!$.includes(_.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.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=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let Z=this.parentElement;if(Z?.querySelector){let $=Z.querySelector(Q);if($&&!this.contains($))return $}return document.querySelector(Q)}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"]),j="top",_="center",q=null;if(Z.length>=2){if($.has(Z[0]))j=Z[0];if(J.has(Z[1]))_=Z[1];return{vertical:j,horizontal:_,shorthand:q}}if(Z.length===1){let G=Z[0];if(G==="top"||G==="bottom")j=G,q=G;else if(G==="left"||G==="right")_=G,q=G;else if(G==="center")j="center",_="center"}return{vertical:j,horizontal:_,shorthand:q}}normalizeOffsetToken(Q,Z="0px"){if(!Q)return Z;let $=Q.trim();if(!$)return Z;if(/^-?\d+(\.\d+)?$/.test($))return`${$}px`;return $}measureLengthPx(Q,Z="x"){if(!Q)return 0;let $=this.normalizeOffsetToken(Q,"0px");if($.endsWith("px")){let _=parseFloat($);return Number.isFinite(_)?_: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 j=J.getBoundingClientRect();return J.remove(),Z==="x"?j.width:j.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(Q,Z,$){let J={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if($){let _=$==="left"||$==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:Z,s:$},{v:Q,h:Z,s:J[$]},{v:Q,h:Z,s:_[0]},{v:Q,h:Z,s:_[1]}]}if(Q==="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:Q,h:"center",s:null},{v:J[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:J[Q],h:"left",s:null},{v:J[Q],h:"right",s:null}];return[{v:Q,h:Z,s:null},{v:J[Q],h:Z,s:null},{v:Q,h:J[Z],s:null},{v:J[Q],h:J[Z],s:null}]}computeCoords(Q,Z,$,J,j,_){let q,G;if(_==="left"||_==="right")return G=_==="left"?Q.left-Z.width-j.xPx:Q.right+j.xPx,q=Q.top,{top:q,left:G};if(_==="top"||_==="bottom")return q=_==="top"?Q.top-Z.height-j.yPx:Q.bottom+j.yPx,G=Q.left,{top:q,left:G};if($==="top")q=Q.top-Z.height-j.yPx;else if($==="bottom")q=Q.bottom+j.yPx;else q=Q.top+(Q.height-Z.height)/2;if($==="center")if(J==="left")G=Q.left-Z.width-j.xPx;else if(J==="right")G=Q.right+j.xPx;else G=Q.left+(Q.width-Z.width)/2;else if(J==="left")G=Q.left+j.xPx;else if(J==="right")G=Q.right-Z.width-j.xPx;else G=Q.left+(Q.width-Z.width)/2;return{top:q,left:G}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,Z,$){if($==="top")return"top";if($==="bottom")return"bottom";if($==="left")return"left";if($==="right")return"right";if(Q!=="center")return Q;if(Z!=="center")return Z;return"top"}lengthToPx(Q,Z=0){let $=getComputedStyle(this),J=String(Q||"").trim(),j=parseFloat(J);if(!Number.isFinite(j))return Z;if(J.endsWith("rem"))return j*parseFloat(getComputedStyle(document.documentElement).fontSize);if(J.endsWith("em"))return j*parseFloat($.fontSize);return j}radiusForSide(Q){let Z=getComputedStyle(this),$=(J)=>this.lengthToPx(J,0);if(Q==="top")return Math.max($(Z.borderTopLeftRadius),$(Z.borderTopRightRadius));if(Q==="bottom")return Math.max($(Z.borderBottomLeftRadius),$(Z.borderBottomRightRadius));if(Q==="left")return Math.max($(Z.borderTopLeftRadius),$(Z.borderBottomLeftRadius));if(Q==="right")return Math.max($(Z.borderTopRightRadius),$(Z.borderBottomRightRadius));return 0}getBeakEdgeInset(Q){let Z=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(Q)+Z/2)}tracksAnchorBeak(){let Q=this.getAttribute("variant");return Q==="popover"||Q==="tooltip"}getViewportBounds(Q){let Z=window.visualViewport,$=Z?.width??window.innerWidth,J=Z?.height??window.innerHeight,j=Z?.offsetLeft??0,_=Z?.offsetTop??0;return{minLeft:j+Q.left,minTop:_+Q.top,maxRight:j+$-Q.right,maxBottom:_+J-Q.bottom}}clampToViewport(Q,Z,$){let J=this.getViewportBounds($),j=J.maxRight-Z.width,_=J.maxBottom-Z.height;return{left:Math.min(j,Math.max(J.minLeft,Q.left)),top:Math.min(_,Math.max(J.minTop,Q.top))}}resolveCoordsAtViewport(Q,Z,$,J,j){let{left:_,top:q}=this.clampToViewport($,Z,j);if(!Q||!this.tracksAnchorBeak())return{left:_,top:q};let G=this.oppositeSide(J),X=this.getViewportBounds(j),K=X.maxRight-Z.width,N=X.minLeft,B=X.maxBottom-Z.height,L=X.minTop;if(G==="top"||G==="bottom"){let A=this.getBeakEdgeInset(G),U=Q.left+Q.width/2,W=U-_;if(W<A)_=U-A;else if(W>Z.width-A)_=U-(Z.width-A);_=Math.min(K,Math.max(N,_))}else if(G==="left"||G==="right"){let A=this.getBeakEdgeInset(G),U=Q.top+Q.height/2,W=U-q;if(W<A)q=U-A;else if(W>Z.height-A)q=U-(Z.height-A);q=Math.min(B,Math.max(L,q))}return{left:_,top:q}}canPointAtAnchor(Q,Z,$,J,j){if(!Q||!this.tracksAnchorBeak())return!0;let _=this.oppositeSide(j),q=this.getBeakEdgeInset(_);if(_==="top"||_==="bottom"){let X=Q.left+Q.width/2-$;return X>=q-0.5&&X<=Z.width-q+0.5}let G=Q.top+Q.height/2-J;return G>=q-0.5&&G<=Z.height-q+0.5}updatePopoverBeak(Q,Z,$,J,j){if(!this.tracksAnchorBeak()||!Q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let _=this.oppositeSide(j);this.setAttribute("data-beak-side",_);let q=Q.left+Q.width/2,G=Q.top+Q.height/2,X=this.getBoundingClientRect(),K=X.width>0&&X.height>0?X:Z,N=K.left,B=K.top,L=this.getBeakEdgeInset(_),A;if(_==="top"||_==="bottom"){A=q-N;let U=L,W=Math.max(U,K.width-L);A=Math.min(W,Math.max(U,A))}else{A=G-B;let U=L,W=Math.max(U,K.height-L);A=Math.min(W,Math.max(U,A))}this.style.setProperty("--fig-popup-beak-offset",`${A}px`)}overflowScore(Q,Z,$){let J=this.getViewportBounds($),j=Q.left+Z.width,_=Q.top+Z.height,q=Math.max(0,J.minLeft-Q.left),G=Math.max(0,J.minTop-Q.top),X=Math.max(0,j-J.maxRight),K=Math.max(0,_-J.maxBottom);return q+G+X+K}fits(Q,Z,$){return this.overflowScore(Q,Z,$)===0}clamp(Q,Z,$,J=null,j="top"){if(J)return this.resolveCoordsAtViewport(J,Z,Q,j,$);return this.clampToViewport(Q,Z,$)}primaryAxisOverflowPenalty(Q,Z,$,J){let j=this.getViewportBounds($),_=0;if(J==="top")_=Math.max(0,j.minTop-Q.top);else if(J==="bottom")_=Math.max(0,Q.top+Z.height-j.maxBottom);else if(J==="left")_=Math.max(0,j.minLeft-Q.left);else if(J==="right")_=Math.max(0,Q.left+Z.width-j.maxRight);return _>0?1000+_:0}placementScore(Q,Z,$,J,j){let _=this.resolveCoordsAtViewport(Q,Z,$,J,j),q=this.overflowScore(_,Z,j);if(q+=this.primaryAxisOverflowPenalty($,Z,j,J),Q&&!this.canPointAtAnchor(Q,Z,_.left,_.top,J))q+=1e4;return{score:q,resolved:_}}applyPopupPosition(Q,Z,$,J,j){let _=this.resolveCoordsAtViewport(Q,Z,$,J,j);this.style.left=`${_.left}px`,this.style.top=`${_.top}px`,this.updatePopoverBeak(Q,Z,_.left,_.top,J)}positionPopup(){if(!this.open)return;let Q=this.getBoundingClientRect(),Z=this.parseOffset(),{vertical:$,horizontal:J,shorthand:j}=this.parsePosition(),_=this.resolveAnchor(),q=this.parseViewportMargins();if(!_){this.updatePopoverBeak(null,Q,0,0,"top");let L=this.getViewportBounds(q),A={left:L.minLeft+(L.maxRight-L.minLeft-Q.width)/2,top:L.minTop+(L.maxBottom-L.minTop-Q.height)/2},U=this.clampToViewport(A,Q,q);this.style.left=`${U.left}px`,this.style.top=`${U.top}px`;return}let G=_.getBoundingClientRect(),X=this.getPlacementCandidates($,J,j),K=null,N="top",B=Number.POSITIVE_INFINITY;for(let{v:L,h:A,s:U}of X){let W=this.computeCoords(G,Q,L,A,Z,U),R=this.getPlacementSide(L,A,U),{score:z,resolved:M}=this.placementScore(G,Q,W,R,q);if(U){let O=this.getViewportBounds(q);if((U==="left"||U==="right"?W.left>=O.minLeft&&W.left+Q.width<=O.maxRight:W.top>=O.minTop&&W.top+Q.height<=O.maxBottom)&&z<1e4){this.applyPopupPosition(G,Q,W,R,q);return}}else if(z===0){this.applyPopupPosition(G,Q,W,R,q);return}if(z<B)B=z,K=M,N=R}this.applyPopupPosition(G,Q,K||{left:0,top:0},N,q)}queueReposition(){if(!this.open||!this.isPopupDisplayed()||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}isPopupDisplayed(){return Boolean(this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"))}}j0("fig-popup",E0,{extends:"dialog"});class C0 extends HTMLElement{#Z;#Q;constructor(){super();this.content=null,this.#Z=!1,this.#Q=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.#Q),b(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let Q=this.getAttribute("id")||y(),Z=this.content.getAttribute("id")||y();if(this.setAttribute("id",Q),this.content.setAttribute("id",Z),this.setAttribute("aria-controls",Z),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",Q),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(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(this.hasAttribute("disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(Q,Z,$){if(Q==="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(Q==="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")}}customElements.define("fig-tab",C0);class S0 extends HTMLElement{#Z;#Q;#J=this.#N.bind(this);#$=null;#j=null;#q=null;#_=null;#G=!1;constructor(){super();this.#Z=this.handleClick.bind(this),this.#Q=this.#z.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){if(this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#Q),this.addEventListener("scroll",this.#J),this.#M(),this.#O(),this.#L(),b(this,()=>{let Q=this.getAttribute("value");if(Q)this.#H(Q);if(this.hasAttribute("disabled"))this.#X(!0);this.#Y(),this.#N(),this.#K(void 0,"auto")})}#X(Q){this.querySelectorAll("fig-tab").forEach(($)=>{if(Q)$.setAttribute("disabled",""),$.setAttribute("aria-disabled","true"),$.setAttribute("tabindex","-1");else $.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#Y()}#W(){return Array.from(this.querySelectorAll("fig-tab")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#Y(){let Q=Array.from(this.querySelectorAll("fig-tab")),Z=Q.find(($)=>$.hasAttribute("selected"))||this.#W()[0];Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false";$.setAttribute("tabindex",!J&&$===Z?"0":"-1")})}#K(Q=this.selectedTab,Z="smooth"){let $=Q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#W()[0];if(!$)return;requestAnimationFrame(()=>{if(!this.isConnected||!$.isConnected)return;if(!(this.scrollWidth>this.clientWidth))return;let j=this.getBoundingClientRect(),_=$.getBoundingClientRect(),q=_.left-j.left+this.scrollLeft+_.width/2;this.scrollTo({left:q-this.clientWidth/2,behavior:Z}),this.#N()})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#Q),this.removeEventListener("scroll",this.#J),this.#$?.disconnect(),this.#$=null,this.#j?.disconnect(),this.#j=null,this.#B()}#U(){if(this.#G)return;let Q=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!Q)return;this.#G=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#G=!1}}#N(){F0(this,this,"x")}#L(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>this.#N()),this.#j.observe(this)}#O(){this.#$?.disconnect(),this.#$=new MutationObserver(()=>{if(this.#G)return;this.#U(),this.#M(),this.#Y(),requestAnimationFrame(()=>{this.#N(),this.#K()})}),this.#$.observe(this,{childList:!0,subtree:!1})}#B(){this.#q?.remove(),this.#_?.remove(),this.#q=null,this.#_=null,this.classList.remove("overflow-start","overflow-end")}#M(){if(this.#q&&this.#_&&this.contains(this.#q)&&this.contains(this.#_))return;this.#q?.remove(),this.#_?.remove();let Q=A0({owner:"tabs",onStart:()=>J0(this,"x",-1),onEnd:()=>J0(this,"x",1)});this.#q=Q.start,this.#_=Q.end,this.prepend(this.#q),this.append(this.#_)}#z(Q){let Z=this.#W();if(!Z.length)return;let $=Z.findIndex((j)=>j.hasAttribute("selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=$>0?$-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=$<Z.length-1?$+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;default:return}if(J!==$&&Z[J]){this.querySelectorAll("fig-tab").forEach((_)=>_.removeAttribute("selected")),this.selectedTab=Z[J],Z[J].setAttribute("selected","true");let j=this.#D(Z[J]);if(j)this.setAttribute("value",j);else this.removeAttribute("value");Z[J].focus(),this.#Y(),this.#K(Z[J]),this.#A()}}get value(){return this.#D(this.selectedTab)}set value(Q){this.setAttribute("value",Q)}#A(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#D(Q){if(!Q)return"";let Z=Q.getAttribute("value");if(Z!==null)return Z;return Q.textContent?.trim()||""}#H(Q){let Z=this.querySelectorAll("fig-tab");for(let $ of Z)if(this.#D($)===Q)this.selectedTab=$,$.setAttribute("selected","true");else $.removeAttribute("selected");this.#Y(),this.#K(this.selectedTab)}attributeChangedCallback(Q,Z,$){switch(Q){case"value":if($!==Z)this.#H($);break;case"disabled":this.#X($!==null&&$!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled"))return;let Z=Q.target.closest("fig-tab");if(!Z||!this.contains(Z))return;let $=this.selectedTab,J=this.value,j=this.querySelectorAll("fig-tab");for(let q of j)if(q===Z)this.selectedTab=q,q.setAttribute("selected","true");else q.removeAttribute("selected");let _=this.#D(Z);if(_)this.setAttribute("value",_);else this.removeAttribute("value");if(this.#Y(),this.#K(Z),$!==Z||J!==this.value)this.#A()}}customElements.define("fig-tabs",S0);class k0 extends HTMLElement{#Z;#Q;#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(){let Q=this.closest("fig-segmented-control");if(Q&&Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#Z}set value(Q){this.#Z=Q,this.setAttribute("value",Q)}get selected(){return this.#Q}set selected(Q){this.#Q=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value","disabled"]}#$(){let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",Q?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",Q?"0":"-1")}attributeChangedCallback(Q,Z,$){switch(Q){case"value":this.#Z=$;break;case"selected":this.#Q=$,this.#$();break;case"disabled":this.#$();break}}}customElements.define("fig-segment",k0);class f0 extends HTMLElement{#Z=null;#Q=this.handleClick.bind(this);#J=this.#L.bind(this);#$=null;#j=null;#q=0;#_=!1;#G=!1;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.#Q),this.addEventListener("keydown",this.#J),this.#F(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#R(),this.#A(),b(this,()=>{this.#H({enforceFallback:!0}),this.#D(),this.#M({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#J),this.#$?.disconnect(),this.#$=null,this.#j?.disconnect(),this.#j=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#_=!1,this.#G=!1}get selectedSegment(){return this.#Z}set selectedSegment(Q){let Z=this.querySelectorAll("fig-segment");for(let $ of Z){let J=$===Q,j=$.hasAttribute("selected");if(J&&!j)$.setAttribute("selected","true");else if(!J&&j)$.removeAttribute("selected")}this.#Z=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#U(),this.#M()}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(Q))}#X(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#W(Q){let Z=Q.getAttribute("value");if(Z!==null){let $=Z.trim();if($.length>0)return $}return Q.textContent?.trim()||""}#Y(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(Z.hasAttribute("selected"))return Z;return null}#K(){return Array.from(this.querySelectorAll("fig-segment")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#U(){let Q=Array.from(this.querySelectorAll("fig-segment")),Z=Q.find(($)=>$.hasAttribute("selected"));Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false",j=$===Z;$.setAttribute("aria-checked",j?"true":"false"),$.setAttribute("tabindex",!J&&j?"0":"-1")})}#N(Q){if(!Q)return;let Z=this.selectedSegment,$=this.value;this.selectedSegment=Q;let J=this.#W(Q);if(J)this.setAttribute("value",J);else this.removeAttribute("value");let j=this.value;if(Z!==Q||$!==j)this.#X(j)}#L(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#K();if(!Z.length)return;let $=Z.findIndex((_)=>_.hasAttribute("selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=J>0?J-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=J<Z.length-1?J+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case" ":case"Enter":{let _=Q.target.closest("fig-segment");if(_&&this.contains(_))Q.preventDefault(),this.#N(_);return}default:return}let j=Z[J];this.#N(j),j.focus(),requestAnimationFrame(()=>{if(this.contains(j))j.focus()})}#O(Q){let Z=String(Q??"").trim();if(!Z)return!1;let $=this.querySelectorAll("fig-segment");for(let J of $){let j=this.#W(J);if(!j)continue;if(j===Z)return this.selectedSegment=J,!0}return!1}#B(){let Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#M({forceInstant:Q=!1}={}){if(this.#_=this.#_||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let Z=this.#_;this.#_=!1,this.#z({forceInstant:Z})})}#z({forceInstant:Q=!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.#G=!1;return}if(!J){if(this.#G)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let j=this.getBoundingClientRect(),_=J.getBoundingClientRect();if(j.width<=0||_.width<=0){if(this.#G)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,_.left-j.left);this.style.setProperty("--seg-indicator-x",`${q}px`),this.style.setProperty("--seg-indicator-w",`${_.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#G||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#G=!0}#A(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#M()}),this.#D()}#D(){if(!this.#j)return;this.#j.disconnect(),this.#j.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#j?.observe(Q)})}#H({enforceFallback:Q=!1}={}){let Z=this.querySelectorAll("fig-segment");if(Z.length===0){this.#Z=null,this.#M({forceInstant:!0});return}let $=this.getAttribute("value"),J=$?.trim()??"";if($!==null){if(J!==$){this.setAttribute("value",J);return}if(J&&this.#O(J))return}let j=this.#Y();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=Z[0]}#R(){this.#$?.disconnect(),this.#$=new MutationObserver((Q)=>{let Z=!1;for(let $ of Q){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(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=Q.target.closest("fig-segment");if(!Z||!this.contains(Z))return;this.#N(Z)}#F(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach((Z)=>{if(Q)Z.setAttribute("disabled",""),Z.setAttribute("aria-disabled","true");else Z.removeAttribute("disabled"),Z.removeAttribute("aria-disabled")}),this.#U()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled"){this.#F($!==null&&$!=="false"),this.#M({forceInstant:!0});return}if(Q==="value"){this.#H({enforceFallback:!1});return}if(Q==="animated"){if(!this.#B())this.#G=!1;this.#M({forceInstant:!0});return}if(Q==="sizing")this.#M({forceInstant:!0})}}customElements.define("fig-segmented-control",f0);class I0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Z="segments";#Q=0;#J=null;#$=[];#j=null;#q=!1;#_(Q){let Z=Q?.detail;if(typeof Z==="string")return Z;let $=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if($===null||$===void 0)return null;return String($)}#G(){if(this.#$.length===0)return!1;let Q=this.querySelector(":scope > fig-segmented-control");if(Q){let $=Q.querySelectorAll("fig-segment");if($.length!==this.#$.length)return!1;return Array.from($).every((J,j)=>J.getAttribute("value")===this.#$[j])}let Z=this.querySelector(":scope > fig-dropdown");if(Z){let $=Z.querySelectorAll("option");return $.length===this.#$.length&&Array.from($).every((J,j)=>J.textContent?.trim()===this.#$[j])}return!1}#X(){let Q=this.querySelector(":scope > fig-segmented-control");if(Q)this.#j=Q,this.#Z="segments";else this.#j=this.querySelector(":scope > fig-dropdown"),this.#Z="dropdown";this.#N()}connectedCallback(){if(this.#W(),this.#G()){this.#X(),this.#O(),b(this,()=>b(this,()=>this.#z()));return}this.#Y(),this.#O(),b(this,()=>b(this,()=>this.#z()))}disconnectedCallback(){this.#J?.disconnect(),this.#J=null}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get options(){return this.#$.slice()}set options(Q){if(Array.isArray(Q)){let $=Q.some((J)=>String(J).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",$)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="options"){this.#W(),this.#U();return}if(Q==="value"){this.#N();return}if(Q==="disabled"){this.#L("disabled");return}if(Q==="full"){this.#L("full");return}if(Q==="sizing")this.#L("sizing"),this.#U()}#W(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#$=JSON.parse(Q);return}catch{}let Z=Q.includes(`
37
+ `,this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.button.addEventListener("click",this.#$),this.button.addEventListener("focus",this.#j),this.button.addEventListener("blur",this.#q),this.addEventListener("keydown",this.#J)}this.#Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#N()}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#Z}set selected(Q){this.setAttribute("selected",Q)}#_(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#G(){if(this.#_())return;if(this.type==="toggle")this.toggleAttribute("selected",!this.hasAttribute("selected"));if(this.type==="submit"){let Q=this.closest("form");if(Q)Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),Z=this.getAttribute("target");if(Q)if(Z)window.open(Q,Z);else window.location.href=Q}}#X(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#W(){let Q=this.#X();if(Q instanceof HTMLSelectElement)return Q;if(Q?.tagName==="FIG-DROPDOWN")return Q.select||Q.querySelector?.("select")||null;return null}#Y(Q){if(this.type!=="select")return;if(Q.key!=="Enter")return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;let Z=this.#W();if(!Z||Z.disabled||Z.multiple)return;if(typeof Z.showPicker!=="function")return;Q.preventDefault();try{Z.showPicker()}catch{}}#K(){if(!this.button)return;if(this.type!=="toggle"){this.removeAttribute("aria-pressed"),this.button.removeAttribute("aria-pressed");return}let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.setAttribute("aria-pressed",Q?"true":"false"),this.button.setAttribute("aria-pressed",Q?"true":"false")}#U(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#Q.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.button.removeAttribute(Q);else this.button.setAttribute(Q,Z)})}#N(){if(!this.button)return;let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=Q,this.button instanceof HTMLButtonElement)this.button.disabled=Q,this.button.type=this.type,this.button.setAttribute("type",this.type);this.#U(),this.#K()}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"type":{let J=(j)=>j==="select"||j==="upload";if(J(Z||"button")!==J($||"button")){this.button=null,this.connectedCallback();break}this.#N();break}case"disabled":this.#N();break;case"selected":this.#Z=$!==null&&$!=="false",this.#K();break;default:this.#U();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#J)}}customElements.define("fig-button",P0);class E0 extends HTMLElement{#Z="Menu";#Q=null;#J;#$;#j;#q=!1;#_=null;get label(){return this.#Z}set label(Q){this.#Z=Q}#G;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#J=this.#L.bind(this),this.#$=this.#H.bind(this),this.#j=this.#B.bind(this),this.#G=this.slotChange.bind(this)}#X(){if(typeof CSS>"u"||typeof CSS.supports!=="function")return!1;try{return CSS.supports("appearance: base-select")&&CSS.supports("selector(::picker(select))")}catch{return!1}}#W(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#X()){this.#q=!1;return}let $=document.createElement("button");$.setAttribute("type","button"),$.setAttribute("aria-hidden","true");let J=document.createElement("selectedcontent");$.appendChild(J),this.select.appendChild($),this.#q=!0,this.#_=J}#Y(){if(!this.#_)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#_.textContent="";return}this.#_.innerHTML=Q.innerHTML}#K(){this.select.addEventListener("input",this.#J),this.select.addEventListener("change",this.#$),this.select.addEventListener("keydown",this.#j)}#U(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#N(){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.#M(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#G),this.optionsSlot.addEventListener("slotchange",this.#G),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#j),this.#K()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.#W(),this.type==="dropdown"){let Q=document.createElement("option");Q.setAttribute("hidden","true"),Q.setAttribute("selected","true"),Q.selected=!0,this.select.appendChild(Q)}if(this.optionsSlot.assignedNodes().forEach((Q)=>{if(Q.nodeName==="OPTION"||Q.nodeName==="OPTGROUP")this.select.appendChild(Q.cloneNode(!0))}),this.#F(this.value),this.#Y(),this.type==="dropdown")this.select.selectedIndex=-1}#L(Q){let Z=Q.target.selectedOptions?.[0];if(this.#U(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#N();return}let $=Q.target.value;if(this.type==="dropdown")this.#Q=$;this.setAttribute("value",$),this.#Y(),this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}#H(Q){let Z=Q.target.selectedOptions?.[0];if(this.#U(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#N();return}let $=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#Y(),this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,composed:!0}))}#B(Q){if(this.closest('fig-button[type="select"]'))return;if(Q.key!=="Enter"||Q.defaultPrevented)return;if(this.#q&&this.select.matches(":open"))return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(typeof this.select.showPicker!=="function")return;Q.preventDefault();try{this.select.showPicker()}catch{}}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#Q;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#Q=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","experimental","label","disabled"]}#M(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=Q}#F(Q){if(this.type==="dropdown")return;if(this.select)this.select.querySelectorAll("option").forEach((Z,$)=>{if(Z.value===this.getAttribute("value"))this.select.selectedIndex=$});this.#Y()}attributeChangedCallback(Q,Z,$){if(Q==="value")this.#F($);if(Q==="type")this.type=$;if(Q==="experimental")this.slotChange();if(Q==="label")this.#Z=$,this.select.setAttribute("aria-label",this.#Z);if(Q==="disabled")this.#M()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#G),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#j)}}customElements.define("fig-dropdown",E0);class F extends HTMLElement{static#Z=0;static#Q=0;static#J=1000;static#$=null;static#j=!1;static#q=new Set;#_;#G;#X;#W;#Y;#K;#U;#N;#L;#H;#B=null;#M=null;#F=null;#O;#A=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#_=this.#V.bind(this),this.#G=this.hidePopupOutsideClick.bind(this),this.#X=this.showDelayedPopup.bind(this),this.#W=this.#S.bind(this),this.#Y=this.#k.bind(this),this.#K=this.#T.bind(this),this.#U=this.#x.bind(this),this.#N=this.#g.bind(this),this.#H=this.#w.bind(this),this.#L=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(F.#y(),this.setup(),this.#D(),this.setupEventListeners(),this.#B=this.closest("dialog"),this.#B)this.#B.addEventListener("close",this.#L)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#E(),this.#P(),document.removeEventListener("mousedown",this.#_,!0),document.removeEventListener("keydown",this.#H,!0),this.#B)this.#B.removeEventListener("close",this.#L),this.#B=null;if(this.action==="click")document.body.removeEventListener("click",this.#G);if(clearTimeout(this.#O),F.#$===this)F.#$=null}#z(){return this.firstElementChild}#P(){this.#F?.disconnect(),this.#F=null}#D(){if(this.#E(),this.action==="manual")return;let Q=this.#z();if(!Q){if(!this.#F&&typeof MutationObserver<"u")this.#F=new MutationObserver(()=>{if(this.#z())this.#P(),this.#D()}),this.#F.observe(this,{childList:!0});return}if(this.#M=Q,this.action==="hover"){if(!this.isTouchDevice())Q.addEventListener("pointerenter",this.#X),Q.addEventListener("pointerleave",this.#W);Q.addEventListener("touchstart",this.#Y,{passive:!0}),Q.addEventListener("touchmove",this.#K,{passive:!0}),Q.addEventListener("touchend",this.#U,{passive:!0}),Q.addEventListener("touchcancel",this.#N,{passive:!0})}else if(this.action==="click")Q.addEventListener("click",this.#X),Q.addEventListener("touchstart",this.#X,{passive:!0})}#E(){let Q=this.#M;if(!Q)return;if(this.action==="hover")Q.removeEventListener("pointerenter",this.#X),Q.removeEventListener("pointerleave",this.#W),Q.removeEventListener("touchstart",this.#Y),Q.removeEventListener("touchmove",this.#K),Q.removeEventListener("touchend",this.#U),Q.removeEventListener("touchcancel",this.#N);else if(this.action==="click")Q.removeEventListener("click",this.#X),Q.removeEventListener("touchstart",this.#X);this.#M=null}setup(){this.style.display="contents"}render(){this.destroy();let Q=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"),Q)this.popup.setAttribute("popover","manual");let $=y();this.popup.setAttribute("id",$);let J=this.getAttribute("theme");if(J)this.popup.setAttribute("theme",J);let j=this.getAttribute("pointer");if(j!==null)this.popup.setAttribute("pointer",j);if(this.popup.append(Z),Z.innerText=this.getAttribute("text")??"",this.firstElementChild)this.firstElementChild.setAttribute("aria-describedby",$);if(Q)(a()??document.body).append(this.popup);else{let _=this.closest("dialog");if(_&&_.open)_.append(this.popup);else(a()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.#C(this.popup.id),this.popup.hidePopup?.(),this.popup.remove(),this.popup=null;if(this.action==="click")document.body.removeEventListener("click",this.#G)}#C(Q){let Z=this.firstElementChild;if(!Z||!Q)return;let $=Z.getAttribute("aria-describedby");if(!$)return;let J=$.split(/\s+/).filter((j)=>j&&j!==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.#G);document.addEventListener("mousedown",this.#_,!0),document.addEventListener("keydown",this.#H,!0)}get#R(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#f(){let Q=Date.now(),Z=F.#J;if(this.action==="hover"&&F.#$)return!0;if(F.#Z&&Q-F.#Z<Z)return!0;if(F.#Q&&Q-F.#Q<Z)return!0;return!1}showDelayedPopup(){if(this.#R)return;if(clearTimeout(this.timeout),this.#f()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#B&&!this.#B.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&F.#$&&F.#$!==this)F.#$.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")F.#$=this;F.#Z=Date.now()}hidePopup(){if(this.#R)return;clearTimeout(this.timeout),clearTimeout(this.#O);let Q=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,F.#$===this)F.#$=null;if(Q)F.#Q=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#S(Q){if(!this.#A)this.hidePopup()}#k(Q){if(this.action==="hover")this.#A=!0,clearTimeout(this.#O),this.showDelayedPopup()}#T(Q){if(this.action==="hover"&&this.#A)clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#A=!1,this.hidePopup()},150)}#x(Q){if(this.action==="hover"&&this.#A)clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#A=!1,this.hidePopup()},300)}#g(Q){if(this.action==="hover"&&this.#A)this.#A=!1,clearTimeout(this.#O),this.hidePopup()}#w(Q){if(!this.isOpen&&!this.popup||Q.key!=="Escape")return;Q.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(Q){this.setAttribute("text",Q)}#I(Q){if(!this.popup)return;let Z=this.popup.firstElementChild??this.popup.firstChild;if(!Z)return;Z.innerText=Q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")==="true"}set open(Q){this.setAttribute("open",Q)}attributeChangedCallback(Q,Z,$){if(Q==="action")this.action=$;if(Q==="delay"){let J=parseInt($);this.delay=!isNaN(J)?J:500}if(Q==="open")if($==="true")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(Q==="show")if($!==null&&$!=="false")this.showPopup();else this.hidePopup();if(Q==="text")this.#I($??"");if(Q==="pointer"){if(this.popup)if($!==null)this.popup.setAttribute("pointer",$);else this.popup.removeAttribute("pointer")}if(Q==="theme"){if(this.popup)if($)this.popup.setAttribute("theme",$);else this.popup.removeAttribute("theme")}}#V(Q){if(!this.isOpen)return;let Z=Q.target;if(this.popup&&this.popup.contains(Z))return;if(Z.tagName==="SELECT"||Z.hasAttribute("popover")||Z.closest("dialog"))this.hidePopup()}static#y(){if(F.#j)return;F.#j=!0;let Q=()=>{F.#h()},Z=()=>{F.#b()};document.documentElement.addEventListener("mouseleave",Q),document.addEventListener("mouseout",($)=>{if($.relatedTarget)return;Q()}),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",Q)}catch{}window.addEventListener("message",($)=>{if($?.data?.type!=="figui:dismiss-tooltips")return;if(window.parent!==window&&$.source!==window.parent)return;Q()})}static#h(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof F))continue;if(Q.action!=="hover")continue;if(Q.#R)continue;if(Q.isOpen||Q.timeout)Q.hidePopup()}}static#v=new WeakMap;static#b(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof F))continue;if(Q.#R)continue;if(Q.isOpen||Q.timeout)Q.hidePopup()}for(let Q of Array.from(F.#q))F.hide(Q)}static show(Q,Z,$={}){F.#y(),F.hide(Q);let J=$.delay??500,_=Date.now()-F.#Z<F.#J?0:J,q={timeout:null,popup:null};F.#v.set(Q,q),F.#q.add(Q),q.timeout=setTimeout(()=>{let G=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,X=document.createElement("dialog",{is:"fig-popup"});if(X.setAttribute("is","fig-popup"),X.setAttribute("variant","tooltip"),X.setAttribute("data-tooltip-managed",""),X.setAttribute("role","tooltip"),X.setAttribute("closedby","closerequest"),G)X.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=Z,X.append(K),G)(a()??document.body).append(X);else{let N=Q.closest?.("dialog");if(N&&N.open)N.append(X);else(a()??document.body).append(X)}X.anchor=Q,X.open=!0,q.popup=X,F.#Z=Date.now()},_)}static hide(Q){let Z=F.#v.get(Q);if(!Z)return;if(clearTimeout(Z.timeout),Z.popup)Z.popup.remove(),F.#Q=Date.now();F.#v.delete(Q),F.#q.delete(Q)}}customElements.define("fig-tooltip",F);class C0 extends HTMLElement{static observedAttributes=["position","tail"];#Z=null;#Q=null;#J=null;connectedCallback(){this.#Z=this.textContent,b(this,()=>{this.#$(),this.#j()})}disconnectedCallback(){this.#q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(this.#Z===null)return;this.#$()}#$(){let Q=this.getAttribute("position")||"right",Z=this.#Z||"";if(Q==="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.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=Z.slice(0,J);let _=document.createElement("span");_.className="end",_.textContent=Z.slice(J),this.appendChild(j),this.appendChild(_)}else this.textContent=Z}#j(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;F.show(this,this.#Z)},this.#J=()=>{F.hide(this)},this.addEventListener("pointerenter",this.#Q),this.addEventListener("pointerleave",this.#J)}#q(){if(this.#Q)this.removeEventListener("pointerenter",this.#Q);if(this.#J)this.removeEventListener("pointerleave",this.#J);F.hide(this)}}customElements.define("fig-truncate",C0);class S0 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(){this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),b(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((Q)=>{Q.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize(),this._teardownIframeDismissListeners(),this.removeEventListener("close",this._boundRestoreFocus)}_captureFocusBeforeOpen(){let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}_restoreFocus(){let Q=this._previousFocus;if(this._previousFocus=null,!Q?.isConnected)return;let Z=document.activeElement;if(Z&&Z!==document.body&&!this.contains(Z))return;requestAnimationFrame(()=>Q.focus?.())}show(){return this._captureFocusBeforeOpen(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),super.show()}showModal(){return this._captureFocusBeforeOpen(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),super.showModal()}_handleIframeMouseLeave(Q){let Z=Q?.currentTarget;if(!(Z instanceof HTMLIFrameElement))return;try{Z.contentWindow?.postMessage({type:"figui:dismiss-tooltips"},"*")}catch{}}_syncIframeDismissListeners(){for(let Q of this.querySelectorAll(":scope > iframe")){if(!(Q instanceof HTMLIFrameElement))continue;if(Q.dataset.figuiDismissBound==="true")continue;Q.dataset.figuiDismissBound="true",Q.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 Q of this.querySelectorAll(":scope > iframe"))Q.removeEventListener("mouseleave",this._boundIframeMouseLeave),delete Q.dataset.figuiDismissBound}_handleIframeMessage(Q){if(!this.autoresize)return;let Z=Q?.data;if(!Z||Z.type!=="figui:iframe-resize")return;let $=Q.source;if(!$)return;let J=Array.from(this.querySelectorAll("iframe")).find((j)=>j.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 Q of this.children)try{this._resizeObserver.observe(Q)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((Q)=>{for(let Z of Q)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(Q){let Z=window.getComputedStyle(this),$=parseFloat(Z.paddingTop||"0")+parseFloat(Z.paddingBottom||"0")+parseFloat(Z.borderTopWidth||"0")+parseFloat(Z.borderBottomWidth||"0"),J=0,j=parseFloat(Z.rowGap||Z.gap||"0")||0,_=0;for(let q of this.children){let G=q.getBoundingClientRect();if(G.height===0)continue;if(_+=1,q===Q)continue;let X=window.getComputedStyle(q),K=parseFloat(X.marginTop||"0")+parseFloat(X.marginBottom||"0");J+=G.height+K}if(j&&_>1)J+=j*(_-1);return $+J}_resizeForIframe(Q,Z){if(typeof Z.height!=="number"||!(Z.height>0))return;let $=this._computeChrome(Q);this.style.height=`${Math.ceil(Z.height+$)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){if(this.querySelector("fig-header[dialog-header]"))return;let Q=document.createElement("fig-header");Q.setAttribute("dialog-header",""),Q.setAttribute("data-auto","");let Z=document.createElement("h3");Z.textContent=this.getAttribute("title")||"Dialog";let $=document.createElement("fig-tooltip");$.setAttribute("text","Close");let J=document.createElement("fig-button");J.setAttribute("variant","ghost"),J.setAttribute("icon",""),J.setAttribute("aria-label","Close dialog"),J.setAttribute("close-dialog",""),J.appendChild(v("close")),$.appendChild(J),Q.appendChild(Z),Q.appendChild($),this.prepend(Q)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close dialog");Q.removeEventListener("click",this._boundClose),Q.addEventListener("click",this._boundClose)})}_syncA11y(){if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let Q=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(Q){let Z=Q.getAttribute("id")||y();Q.setAttribute("id",Z),this.setAttribute("aria-labelledby",Z)}}}_applyPosition(){let Q=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=Q.includes("top"),$=Q.includes("bottom"),J=Q.includes("left"),j=Q.includes("right"),_=Q.includes("center")&&!Z&&!$,q=Q.includes("center")&&!J&&!j;if(Z)this.style.top=`${this._offset}px`;else if($)this.style.bottom=`${this._offset}px`;else if(_)this.style.top="0",this.style.bottom="0";if(J)this.style.left=`${this._offset}px`;else if(j)this.style.right=`${this._offset}px`;else if(q)this.style.left="0",this.style.right="0";if(_&&q)this.style.margin="auto";else if(_)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 Q=this.getAttribute("handle"),Z=Q?this.querySelector(Q):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)}_isInteractiveElement(Q){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=(_)=>Z.some((q)=>_.matches?.(q))||_.tagName?.startsWith("FIG-")&&!$.includes(_.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.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=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}_handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Q==="autoresize"&&this.isConnected)this._syncAutoResize();if(Q==="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(Q==="position"&&this._positionInitialized)this._applyPosition();if(Q==="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(Q==="closedby")this.closedby=$||"any";if(Q==="title"){let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";this._syncA11y()}if(Q==="aria-label"||Q==="aria-labelledby")this._syncA11y()}}G0("fig-dialog",S0,{extends:"dialog"});class k0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._boundHandleClose=this.handleClose.bind(this)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast()}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close notification");Q.removeEventListener("click",this._boundHandleClose),Q.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto",this.style.bottom=`${parseInt(this.getAttribute("offset")??this._defaultOffset)}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let Q=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger";if(!this.hasAttribute("role"))this.setAttribute("role",Q?"alert":"status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live",Q?"assertive":"polite");if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}startAutoClose(){this.clearAutoClose();let Q=parseInt(this.getAttribute("duration")??"5000");if(Q>0)this._autoCloseTimer=setTimeout(()=>this.hideToast(),Q)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}showToast(){if(this.syncLiveRegion(),!this.open)this.show();this.applyPosition(),this.startAutoClose(),this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){if(this.clearAutoClose(),this.open)this.close();this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Z===$)return;if(!this.isConnected)return;if(Q==="offset")this.applyPosition();if(Q==="open")if($!==null&&$!=="false")this.showToast();else this.hideToast();if(Q==="theme"||Q==="live")this.syncLiveRegion()}}G0("fig-toast",k0,{extends:"dialog"});class f0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_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;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{let Z=Q.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)}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._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._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{let Z=Q.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)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!this.open)return;this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else if(Q&&typeof Q.getBoundingClientRect==="function")this._anchorRef=Q;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.addEventListener("close",()=>{if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}),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),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(Q,Z,$){if(this.ensureInitialized(),Z===$)return;if(Q==="open"){if($===null||$==="false"){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=$!==null&&$!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();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(k1()+1),this.captureFocusBeforeOpen();let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),Z=this.shouldAutoReposition();if(Z)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(J){}if(!Q&&!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),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let $=this.resolveAnchor();if($?.classList)$.classList.add("has-popup-open")}hidePopup(){let Q=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),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch($){}if(this.matches?.(":open"))try{this.close()}catch($){}if(Q)this.restoreFocusAfterClose()}shouldRestoreFocus(){return this.getAttribute("variant")!=="tooltip"}captureFocusBeforeOpen(){if(!this.shouldRestoreFocus())return;let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}restoreFocusAfterClose(){if(!this.shouldRestoreFocus()){this._previousFocus=null;return}let Q=this.resolveAnchor(),Z=this._previousFocus?.isConnected?this._previousFocus:Q instanceof HTMLElement?Q:null;if(this._previousFocus=null,!Z?.isConnected)return;let $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Z.focus?.())}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.removeAttribute("autoresize")}setupObservers(){this.teardownObservers();let Q=this.resolveAnchor();if(Q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(Q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),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(Q){if(!Q)return null;let Z=Q.getBoundingClientRect();return{x:Z.x,y:Z.y,width:Z.width,height:Z.height}}hasRectChanged(Q,Z,$=0.25){if(!Q&&!Z)return!1;if(!Q||!Z)return!0;return Math.abs(Q.x-Z.x)>$||Math.abs(Q.y-Z.y)>$||Math.abs(Q.width-Z.width)>$||Math.abs(Q.height-Z.height)>$}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{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(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!super.open)return;let Z=this.getAttribute("closedby");if(Z==="none"||Z==="closerequest")return;let $=Q.target;if(!($ instanceof Node))return;if(this.contains($))return;let J=this.resolveAnchor();if(J?.contains&&J.contains($))return;if(this.isInsideDescendantPopup($))return;this.open=!1}handleDocumentKeydown(Q){if(Q.key!=="Escape"||Q.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[is="fig-popup"][open]')).filter((j)=>j.open).map((j)=>({popup:j,z:Number.parseInt(getComputedStyle(j).zIndex||"0",10)||0})).sort((j,_)=>j.z-_.z).at(-1)?.popup;if(J&&J!==this)return;Q.preventDefault(),this.open=!1}isInsideDescendantPopup(Q){let Z=Q.closest?.('dialog[is="fig-popup"]');if(!Z||Z===this)return!1;let $=Z,J=new Set;while($&&!J.has($)){J.add($);let j=$.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;$=j.closest?.('dialog[is="fig-popup"]')}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)}isInteractiveElement(Q){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=(_)=>Z.some((q)=>_.matches?.(q))||_.tagName?.startsWith("FIG-")&&!$.includes(_.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.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=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let Z=this.parentElement;if(Z?.querySelector){let $=Z.querySelector(Q);if($&&!this.contains($))return $}return document.querySelector(Q)}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"]),j="top",_="center",q=null;if(Z.length>=2){if($.has(Z[0]))j=Z[0];if(J.has(Z[1]))_=Z[1];return{vertical:j,horizontal:_,shorthand:q}}if(Z.length===1){let G=Z[0];if(G==="top"||G==="bottom")j=G,q=G;else if(G==="left"||G==="right")_=G,q=G;else if(G==="center")j="center",_="center"}return{vertical:j,horizontal:_,shorthand:q}}normalizeOffsetToken(Q,Z="0px"){if(!Q)return Z;let $=Q.trim();if(!$)return Z;if(/^-?\d+(\.\d+)?$/.test($))return`${$}px`;return $}measureLengthPx(Q,Z="x"){if(!Q)return 0;let $=this.normalizeOffsetToken(Q,"0px");if($.endsWith("px")){let _=parseFloat($);return Number.isFinite(_)?_: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 j=J.getBoundingClientRect();return J.remove(),Z==="x"?j.width:j.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(Q,Z,$){let J={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if($){let _=$==="left"||$==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:Z,s:$},{v:Q,h:Z,s:J[$]},{v:Q,h:Z,s:_[0]},{v:Q,h:Z,s:_[1]}]}if(Q==="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:Q,h:"center",s:null},{v:J[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:J[Q],h:"left",s:null},{v:J[Q],h:"right",s:null}];return[{v:Q,h:Z,s:null},{v:J[Q],h:Z,s:null},{v:Q,h:J[Z],s:null},{v:J[Q],h:J[Z],s:null}]}computeCoords(Q,Z,$,J,j,_){let q,G;if(_==="left"||_==="right")return G=_==="left"?Q.left-Z.width-j.xPx:Q.right+j.xPx,q=Q.top,{top:q,left:G};if(_==="top"||_==="bottom")return q=_==="top"?Q.top-Z.height-j.yPx:Q.bottom+j.yPx,G=Q.left,{top:q,left:G};if($==="top")q=Q.top-Z.height-j.yPx;else if($==="bottom")q=Q.bottom+j.yPx;else q=Q.top+(Q.height-Z.height)/2;if($==="center")if(J==="left")G=Q.left-Z.width-j.xPx;else if(J==="right")G=Q.right+j.xPx;else G=Q.left+(Q.width-Z.width)/2;else if(J==="left")G=Q.left+j.xPx;else if(J==="right")G=Q.right-Z.width-j.xPx;else G=Q.left+(Q.width-Z.width)/2;return{top:q,left:G}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,Z,$){if($==="top")return"top";if($==="bottom")return"bottom";if($==="left")return"left";if($==="right")return"right";if(Q!=="center")return Q;if(Z!=="center")return Z;return"top"}lengthToPx(Q,Z=0){let $=getComputedStyle(this),J=String(Q||"").trim(),j=parseFloat(J);if(!Number.isFinite(j))return Z;if(J.endsWith("rem"))return j*parseFloat(getComputedStyle(document.documentElement).fontSize);if(J.endsWith("em"))return j*parseFloat($.fontSize);return j}radiusForSide(Q){let Z=getComputedStyle(this),$=(J)=>this.lengthToPx(J,0);if(Q==="top")return Math.max($(Z.borderTopLeftRadius),$(Z.borderTopRightRadius));if(Q==="bottom")return Math.max($(Z.borderBottomLeftRadius),$(Z.borderBottomRightRadius));if(Q==="left")return Math.max($(Z.borderTopLeftRadius),$(Z.borderBottomLeftRadius));if(Q==="right")return Math.max($(Z.borderTopRightRadius),$(Z.borderBottomRightRadius));return 0}getBeakEdgeInset(Q){let Z=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(Q)+Z/2)}tracksAnchorBeak(){let Q=this.getAttribute("variant");return Q==="popover"||Q==="tooltip"}getViewportBounds(Q){let Z=window.visualViewport,$=Z?.width??window.innerWidth,J=Z?.height??window.innerHeight,j=Z?.offsetLeft??0,_=Z?.offsetTop??0;return{minLeft:j+Q.left,minTop:_+Q.top,maxRight:j+$-Q.right,maxBottom:_+J-Q.bottom}}clampToViewport(Q,Z,$){let J=this.getViewportBounds($),j=J.maxRight-Z.width,_=J.maxBottom-Z.height;return{left:Math.min(j,Math.max(J.minLeft,Q.left)),top:Math.min(_,Math.max(J.minTop,Q.top))}}resolveCoordsAtViewport(Q,Z,$,J,j){let{left:_,top:q}=this.clampToViewport($,Z,j);if(!Q||!this.tracksAnchorBeak())return{left:_,top:q};let G=this.oppositeSide(J),X=this.getViewportBounds(j),K=X.maxRight-Z.width,N=X.minLeft,M=X.maxBottom-Z.height,L=X.minTop;if(G==="top"||G==="bottom"){let z=this.getBeakEdgeInset(G),U=Q.left+Q.width/2,W=U-_;if(W<z)_=U-z;else if(W>Z.width-z)_=U-(Z.width-z);_=Math.min(K,Math.max(N,_))}else if(G==="left"||G==="right"){let z=this.getBeakEdgeInset(G),U=Q.top+Q.height/2,W=U-q;if(W<z)q=U-z;else if(W>Z.height-z)q=U-(Z.height-z);q=Math.min(M,Math.max(L,q))}return{left:_,top:q}}canPointAtAnchor(Q,Z,$,J,j){if(!Q||!this.tracksAnchorBeak())return!0;let _=this.oppositeSide(j),q=this.getBeakEdgeInset(_);if(_==="top"||_==="bottom"){let X=Q.left+Q.width/2-$;return X>=q-0.5&&X<=Z.width-q+0.5}let G=Q.top+Q.height/2-J;return G>=q-0.5&&G<=Z.height-q+0.5}updatePopoverBeak(Q,Z,$,J,j){if(!this.tracksAnchorBeak()||!Q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let _=this.oppositeSide(j);this.setAttribute("data-beak-side",_);let q=Q.left+Q.width/2,G=Q.top+Q.height/2,X=this.getBoundingClientRect(),K=X.width>0&&X.height>0?X:Z,N=K.left,M=K.top,L=this.getBeakEdgeInset(_),z;if(_==="top"||_==="bottom"){z=q-N;let U=L,W=Math.max(U,K.width-L);z=Math.min(W,Math.max(U,z))}else{z=G-M;let U=L,W=Math.max(U,K.height-L);z=Math.min(W,Math.max(U,z))}this.style.setProperty("--fig-popup-beak-offset",`${z}px`)}overflowScore(Q,Z,$){let J=this.getViewportBounds($),j=Q.left+Z.width,_=Q.top+Z.height,q=Math.max(0,J.minLeft-Q.left),G=Math.max(0,J.minTop-Q.top),X=Math.max(0,j-J.maxRight),K=Math.max(0,_-J.maxBottom);return q+G+X+K}fits(Q,Z,$){return this.overflowScore(Q,Z,$)===0}clamp(Q,Z,$,J=null,j="top"){if(J)return this.resolveCoordsAtViewport(J,Z,Q,j,$);return this.clampToViewport(Q,Z,$)}primaryAxisOverflowPenalty(Q,Z,$,J){let j=this.getViewportBounds($),_=0;if(J==="top")_=Math.max(0,j.minTop-Q.top);else if(J==="bottom")_=Math.max(0,Q.top+Z.height-j.maxBottom);else if(J==="left")_=Math.max(0,j.minLeft-Q.left);else if(J==="right")_=Math.max(0,Q.left+Z.width-j.maxRight);return _>0?1000+_:0}placementScore(Q,Z,$,J,j){let _=this.resolveCoordsAtViewport(Q,Z,$,J,j),q=this.overflowScore(_,Z,j);if(q+=this.primaryAxisOverflowPenalty($,Z,j,J),Q&&!this.canPointAtAnchor(Q,Z,_.left,_.top,J))q+=1e4;return{score:q,resolved:_}}applyPopupPosition(Q,Z,$,J,j){let _=this.resolveCoordsAtViewport(Q,Z,$,J,j);this.style.left=`${_.left}px`,this.style.top=`${_.top}px`,this.updatePopoverBeak(Q,Z,_.left,_.top,J)}positionPopup(){if(!this.open)return;let Q=this.getBoundingClientRect(),Z=this.parseOffset(),{vertical:$,horizontal:J,shorthand:j}=this.parsePosition(),_=this.resolveAnchor(),q=this.parseViewportMargins();if(!_){this.updatePopoverBeak(null,Q,0,0,"top");let L=this.getViewportBounds(q),z={left:L.minLeft+(L.maxRight-L.minLeft-Q.width)/2,top:L.minTop+(L.maxBottom-L.minTop-Q.height)/2},U=this.clampToViewport(z,Q,q);this.style.left=`${U.left}px`,this.style.top=`${U.top}px`;return}let G=_.getBoundingClientRect(),X=this.getPlacementCandidates($,J,j),K=null,N="top",M=Number.POSITIVE_INFINITY;for(let{v:L,h:z,s:U}of X){let W=this.computeCoords(G,Q,L,z,Z,U),R=this.getPlacementSide(L,z,U),{score:H,resolved:B}=this.placementScore(G,Q,W,R,q);if(U){let O=this.getViewportBounds(q);if((U==="left"||U==="right"?W.left>=O.minLeft&&W.left+Q.width<=O.maxRight:W.top>=O.minTop&&W.top+Q.height<=O.maxBottom)&&H<1e4){this.applyPopupPosition(G,Q,W,R,q);return}}else if(H===0){this.applyPopupPosition(G,Q,W,R,q);return}if(H<M)M=H,K=B,N=R}this.applyPopupPosition(G,Q,K||{left:0,top:0},N,q)}queueReposition(){if(!this.open||!this.isPopupDisplayed()||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}isPopupDisplayed(){return Boolean(this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"))}}G0("fig-popup",f0,{extends:"dialog"});class I0 extends HTMLElement{#Z;#Q;constructor(){super();this.content=null,this.#Z=!1,this.#Q=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.#Q),b(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let Q=this.getAttribute("id")||y(),Z=this.content.getAttribute("id")||y();if(this.setAttribute("id",Q),this.content.setAttribute("id",Z),this.setAttribute("aria-controls",Z),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",Q),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(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(this.hasAttribute("disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(Q,Z,$){if(Q==="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(Q==="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")}}customElements.define("fig-tab",I0);class x0 extends HTMLElement{#Z;#Q;#J=this.#N.bind(this);#$=null;#j=null;#q=null;#_=null;#G=!1;constructor(){super();this.#Z=this.handleClick.bind(this),this.#Q=this.#F.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){if(this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#Q),this.addEventListener("scroll",this.#J),this.#M(),this.#H(),this.#L(),b(this,()=>{let Q=this.getAttribute("value");if(Q)this.#z(Q);if(this.hasAttribute("disabled"))this.#X(!0);this.#Y(),this.#N(),this.#K(void 0,"auto")})}#X(Q){this.querySelectorAll("fig-tab").forEach(($)=>{if(Q)$.setAttribute("disabled",""),$.setAttribute("aria-disabled","true"),$.setAttribute("tabindex","-1");else $.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#Y()}#W(){return Array.from(this.querySelectorAll("fig-tab")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#Y(){let Q=Array.from(this.querySelectorAll("fig-tab")),Z=Q.find(($)=>$.hasAttribute("selected"))||this.#W()[0];Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false";$.setAttribute("tabindex",!J&&$===Z?"0":"-1")})}#K(Q=this.selectedTab,Z="smooth"){let $=Q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#W()[0];if(!$)return;requestAnimationFrame(()=>{if(!this.isConnected||!$.isConnected)return;if(!(this.scrollWidth>this.clientWidth))return;let j=this.getBoundingClientRect(),_=$.getBoundingClientRect(),q=_.left-j.left+this.scrollLeft+_.width/2;this.scrollTo({left:q-this.clientWidth/2,behavior:Z}),this.#N()})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#Q),this.removeEventListener("scroll",this.#J),this.#$?.disconnect(),this.#$=null,this.#j?.disconnect(),this.#j=null,this.#B()}#U(){if(this.#G)return;let Q=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!Q)return;this.#G=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#G=!1}}#N(){R0(this,this,"x")}#L(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>this.#N()),this.#j.observe(this)}#H(){this.#$?.disconnect(),this.#$=new MutationObserver(()=>{if(this.#G)return;this.#U(),this.#M(),this.#Y(),requestAnimationFrame(()=>{this.#N(),this.#K()})}),this.#$.observe(this,{childList:!0,subtree:!1})}#B(){this.#q?.remove(),this.#_?.remove(),this.#q=null,this.#_=null,this.classList.remove("overflow-start","overflow-end")}#M(){if(this.#q&&this.#_&&this.contains(this.#q)&&this.contains(this.#_))return;this.#q?.remove(),this.#_?.remove();let Q=D0({owner:"tabs",onStart:()=>q0(this,"x",-1),onEnd:()=>q0(this,"x",1)});this.#q=Q.start,this.#_=Q.end,this.prepend(this.#q),this.append(this.#_)}#F(Q){let Z=this.#W();if(!Z.length)return;let $=Z.findIndex((j)=>j.hasAttribute("selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=$>0?$-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=$<Z.length-1?$+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;default:return}if(J!==$&&Z[J]){this.querySelectorAll("fig-tab").forEach((_)=>_.removeAttribute("selected")),this.selectedTab=Z[J],Z[J].setAttribute("selected","true");let j=this.#A(Z[J]);if(j)this.setAttribute("value",j);else this.removeAttribute("value");Z[J].focus(),this.#Y(),this.#K(Z[J]),this.#O()}}get value(){return this.#A(this.selectedTab)}set value(Q){this.setAttribute("value",Q)}#O(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#A(Q){if(!Q)return"";let Z=Q.getAttribute("value");if(Z!==null)return Z;return Q.textContent?.trim()||""}#z(Q){let Z=this.querySelectorAll("fig-tab");for(let $ of Z)if(this.#A($)===Q)this.selectedTab=$,$.setAttribute("selected","true");else $.removeAttribute("selected");this.#Y(),this.#K(this.selectedTab)}attributeChangedCallback(Q,Z,$){switch(Q){case"value":if($!==Z)this.#z($);break;case"disabled":this.#X($!==null&&$!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled"))return;let Z=Q.target.closest("fig-tab");if(!Z||!this.contains(Z))return;let $=this.selectedTab,J=this.value,j=this.querySelectorAll("fig-tab");for(let q of j)if(q===Z)this.selectedTab=q,q.setAttribute("selected","true");else q.removeAttribute("selected");let _=this.#A(Z);if(_)this.setAttribute("value",_);else this.removeAttribute("value");if(this.#Y(),this.#K(Z),$!==Z||J!==this.value)this.#O()}}customElements.define("fig-tabs",x0);class V0 extends HTMLElement{#Z;#Q;#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(){let Q=this.closest("fig-segmented-control");if(Q&&Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#Z}set value(Q){this.#Z=Q,this.setAttribute("value",Q)}get selected(){return this.#Q}set selected(Q){this.#Q=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value","disabled"]}#$(){let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",Q?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",Q?"0":"-1")}attributeChangedCallback(Q,Z,$){switch(Q){case"value":this.#Z=$;break;case"selected":this.#Q=$,this.#$();break;case"disabled":this.#$();break}}}customElements.define("fig-segment",V0);class y0 extends HTMLElement{#Z=null;#Q=this.handleClick.bind(this);#J=this.#L.bind(this);#$=null;#j=null;#q=0;#_=!1;#G=!1;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.#Q),this.addEventListener("keydown",this.#J),this.#D(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#P(),this.#O(),b(this,()=>{this.#z({enforceFallback:!0}),this.#A(),this.#M({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#J),this.#$?.disconnect(),this.#$=null,this.#j?.disconnect(),this.#j=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#_=!1,this.#G=!1}get selectedSegment(){return this.#Z}set selectedSegment(Q){let Z=this.querySelectorAll("fig-segment");for(let $ of Z){let J=$===Q,j=$.hasAttribute("selected");if(J&&!j)$.setAttribute("selected","true");else if(!J&&j)$.removeAttribute("selected")}this.#Z=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#U(),this.#M()}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(Q))}#X(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#W(Q){let Z=Q.getAttribute("value");if(Z!==null){let $=Z.trim();if($.length>0)return $}return Q.textContent?.trim()||""}#Y(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(Z.hasAttribute("selected"))return Z;return null}#K(){return Array.from(this.querySelectorAll("fig-segment")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#U(){let Q=Array.from(this.querySelectorAll("fig-segment")),Z=Q.find(($)=>$.hasAttribute("selected"));Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false",j=$===Z;$.setAttribute("aria-checked",j?"true":"false"),$.setAttribute("tabindex",!J&&j?"0":"-1")})}#N(Q){if(!Q)return;let Z=this.selectedSegment,$=this.value;this.selectedSegment=Q;let J=this.#W(Q);if(J)this.setAttribute("value",J);else this.removeAttribute("value");let j=this.value;if(Z!==Q||$!==j)this.#X(j)}#L(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#K();if(!Z.length)return;let $=Z.findIndex((_)=>_.hasAttribute("selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=J>0?J-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=J<Z.length-1?J+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case" ":case"Enter":{let _=Q.target.closest("fig-segment");if(_&&this.contains(_))Q.preventDefault(),this.#N(_);return}default:return}let j=Z[J];this.#N(j),j.focus(),requestAnimationFrame(()=>{if(this.contains(j))j.focus()})}#H(Q){let Z=String(Q??"").trim();if(!Z)return!1;let $=this.querySelectorAll("fig-segment");for(let J of $){let j=this.#W(J);if(!j)continue;if(j===Z)return this.selectedSegment=J,!0}return!1}#B(){let Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#M({forceInstant:Q=!1}={}){if(this.#_=this.#_||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let Z=this.#_;this.#_=!1,this.#F({forceInstant:Z})})}#F({forceInstant:Q=!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.#G=!1;return}if(!J){if(this.#G)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let j=this.getBoundingClientRect(),_=J.getBoundingClientRect();if(j.width<=0||_.width<=0){if(this.#G)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,_.left-j.left);this.style.setProperty("--seg-indicator-x",`${q}px`),this.style.setProperty("--seg-indicator-w",`${_.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#G||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#G=!0}#O(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#M()}),this.#A()}#A(){if(!this.#j)return;this.#j.disconnect(),this.#j.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#j?.observe(Q)})}#z({enforceFallback:Q=!1}={}){let Z=this.querySelectorAll("fig-segment");if(Z.length===0){this.#Z=null,this.#M({forceInstant:!0});return}let $=this.getAttribute("value"),J=$?.trim()??"";if($!==null){if(J!==$){this.setAttribute("value",J);return}if(J&&this.#H(J))return}let j=this.#Y();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=Z[0]}#P(){this.#$?.disconnect(),this.#$=new MutationObserver((Q)=>{let Z=!1;for(let $ of Q){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.#D(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#A(),this.#z({enforceFallback:!0}),this.#U()}),this.#$.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=Q.target.closest("fig-segment");if(!Z||!this.contains(Z))return;this.#N(Z)}#D(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach((Z)=>{if(Q)Z.setAttribute("disabled",""),Z.setAttribute("aria-disabled","true");else Z.removeAttribute("disabled"),Z.removeAttribute("aria-disabled")}),this.#U()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled"){this.#D($!==null&&$!=="false"),this.#M({forceInstant:!0});return}if(Q==="value"){this.#z({enforceFallback:!1});return}if(Q==="animated"){if(!this.#B())this.#G=!1;this.#M({forceInstant:!0});return}if(Q==="sizing")this.#M({forceInstant:!0})}}customElements.define("fig-segmented-control",y0);class w0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Z="segments";#Q=0;#J=null;#$=[];#j=null;#q=!1;#_(Q){let Z=Q?.detail;if(typeof Z==="string")return Z;let $=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if($===null||$===void 0)return null;return String($)}#G(){if(this.#$.length===0)return!1;let Q=this.querySelector(":scope > fig-segmented-control");if(Q){let $=Q.querySelectorAll("fig-segment");if($.length!==this.#$.length)return!1;return Array.from($).every((J,j)=>J.getAttribute("value")===this.#$[j])}let Z=this.querySelector(":scope > fig-dropdown");if(Z){let $=Z.querySelectorAll("option");return $.length===this.#$.length&&Array.from($).every((J,j)=>J.textContent?.trim()===this.#$[j])}return!1}#X(){let Q=this.querySelector(":scope > fig-segmented-control");if(Q)this.#j=Q,this.#Z="segments";else this.#j=this.querySelector(":scope > fig-dropdown"),this.#Z="dropdown";this.#N()}connectedCallback(){if(this.#W(),this.#G()){this.#X(),this.#H(),b(this,()=>b(this,()=>this.#F()));return}this.#Y(),this.#H(),b(this,()=>b(this,()=>this.#F()))}disconnectedCallback(){this.#J?.disconnect(),this.#J=null}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get options(){return this.#$.slice()}set options(Q){if(Array.isArray(Q)){let $=Q.some((J)=>String(J).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",$)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="options"){this.#W(),this.#U();return}if(Q==="value"){this.#N();return}if(Q==="disabled"){this.#L("disabled");return}if(Q==="full"){this.#L("full");return}if(Q==="sizing")this.#L("sizing"),this.#U()}#W(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#$=JSON.parse(Q);return}catch{}let Z=Q.includes(`
38
38
  `)?`
39
- `:",";this.#$=Q.split(Z).map(($)=>$.trim()).filter(Boolean)}#Y(){if(this.innerHTML="",this.#$.length===0)return;let Q=document.createElement("fig-segmented-control");if(Q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),this.hasAttribute("disabled"))Q.setAttribute("disabled","");if(this.hasAttribute("full"))Q.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");Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Z="segments"}#K(){if(this.innerHTML="",this.#$.length===0)return;let Q=document.createElement("fig-dropdown");if(this.hasAttribute("disabled"))Q.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;Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Z="dropdown"}#U(){if(this.#Z==="segments")this.#Y(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#z())});else this.#K()}#N(){if(!this.#j||this.#q)return;let Q=this.getAttribute("value")||"";this.#j.value=Q}#L(Q){if(!this.#j)return;if(this.hasAttribute(Q))this.#j.setAttribute(Q,this.getAttribute(Q)||"");else this.#j.removeAttribute(Q)}#O(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#z()}),this.#J.observe(this)}#B(Q){let Z=document.createRange();Z.selectNodeContents(Q);let $=Z.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,_=getComputedStyle(Q),q=parseFloat(_.paddingLeft)||0,G=parseFloat(_.paddingRight)||0,X=j-q-G;return $>X+0.5}#M(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(this.#B(Z))return!0;return!1}#z(){if(this.#$.length<=1)return;if(this.#Z==="segments"){let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#M())this.#Q=this.clientWidth,this.#K()}else if(this.#Q>0&&this.clientWidth>=this.#Q)this.#Y(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#M())this.#K()})})}}customElements.define("fig-options",I0);class x0 extends HTMLElement{#Z=!1;#Q=!1;#J=!1;#$="";#j=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#q={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:"#FF0000"}};#_;#G;#X;#W;#Y;#K;#U;#N=null;#L=null;#O=null;constructor(){super();this.initialInnerHTML=this.innerHTML,this.#_=(Q)=>{Q.stopPropagation(),this.#g()},this.#G=(Q)=>{Q.stopPropagation(),this.#V()},this.#Y=(Q)=>{this.#y(Q)},this.#X=(Q)=>{Q.stopPropagation(),this.#H()},this.#W=(Q)=>{Q.stopPropagation(),this.#w()},this.#K=()=>{this.#Z=!0},this.#U=()=>{this.#Z=!1}}#B(){let Q=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.getAttribute("disabled")?!0:!1,this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";let Z=this.#q[this.type];this.min=Number(this.getAttribute("min")||Z.min),this.max=Number(this.getAttribute("max")||Z.max),this.step=Number(this.getAttribute("step")||Z.step),this.color=this.getAttribute("color")||Z?.color,this.default=this.hasAttribute("default")?this.getAttribute("default"):this.type==="delta"?0:this.min,this.#Q=this.type!=="range"&&(Q===null||typeof Q==="string"&&Q.trim()===""),this.value=this.#T(Q)}#M(){if(!this.querySelector("[type=range]"))return!1;return this.getAttribute("text")!=="false"===!!this.querySelector("fig-input-number")}#z(){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",this.#Q?"":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)}}#A(){if(this.#P(),this.input.removeEventListener("input",this.#_),this.input.addEventListener("input",this.#_),this.input.removeEventListener("change",this.#G),this.input.addEventListener("change",this.#G),this.input.removeEventListener("keydown",this.#Y),this.input.addEventListener("keydown",this.#Y),this.input.removeEventListener("pointerdown",this.#K),this.input.addEventListener("pointerdown",this.#K),this.input.removeEventListener("pointerup",this.#U),this.input.addEventListener("pointerup",this.#U),this.default)this.style.setProperty("--default",this.#R(this.default));if(this.figInputNumber)this.#I(),this.figInputNumber.removeEventListener("input",this.#X),this.figInputNumber.addEventListener("input",this.#X),this.figInputNumber.removeEventListener("change",this.#W),this.figInputNumber.addEventListener("change",this.#W)}#D(){if(this.#B(),this.color)this.style.setProperty("--color",this.color);let Q="",Z=`<div class="fig-slider-input-container" role="group">
39
+ `:",";this.#$=Q.split(Z).map(($)=>$.trim()).filter(Boolean)}#Y(){if(this.innerHTML="",this.#$.length===0)return;let Q=document.createElement("fig-segmented-control");if(Q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),this.hasAttribute("disabled"))Q.setAttribute("disabled","");if(this.hasAttribute("full"))Q.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");Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Z="segments"}#K(){if(this.innerHTML="",this.#$.length===0)return;let Q=document.createElement("fig-dropdown");if(this.hasAttribute("disabled"))Q.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;Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Z="dropdown"}#U(){if(this.#Z==="segments")this.#Y(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#F())});else this.#K()}#N(){if(!this.#j||this.#q)return;let Q=this.getAttribute("value")||"";this.#j.value=Q}#L(Q){if(!this.#j)return;if(this.hasAttribute(Q))this.#j.setAttribute(Q,this.getAttribute(Q)||"");else this.#j.removeAttribute(Q)}#H(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#F()}),this.#J.observe(this)}#B(Q){let Z=document.createRange();Z.selectNodeContents(Q);let $=Z.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,_=getComputedStyle(Q),q=parseFloat(_.paddingLeft)||0,G=parseFloat(_.paddingRight)||0,X=j-q-G;return $>X+0.5}#M(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(this.#B(Z))return!0;return!1}#F(){if(this.#$.length<=1)return;if(this.#Z==="segments"){let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#M())this.#Q=this.clientWidth,this.#K()}else if(this.#Q>0&&this.clientWidth>=this.#Q)this.#Y(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#M())this.#K()})})}}customElements.define("fig-options",w0);class g0 extends HTMLElement{#Z=!1;#Q=!1;#J=!1;#$="";#j=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#q={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:"#FF0000"}};#_;#G;#X;#W;#Y;#K;#U;#N=null;#L=null;#H=null;constructor(){super();this.initialInnerHTML=this.innerHTML,this.#_=(Q)=>{Q.stopPropagation(),this.#g()},this.#G=(Q)=>{Q.stopPropagation(),this.#w()},this.#Y=(Q)=>{this.#I(Q)},this.#X=(Q)=>{Q.stopPropagation(),this.#z()},this.#W=(Q)=>{Q.stopPropagation(),this.#V()},this.#K=()=>{this.#Z=!0},this.#U=()=>{this.#Z=!1}}#B(){let Q=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.getAttribute("disabled")?!0:!1,this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";let Z=this.#q[this.type];this.min=Number(this.getAttribute("min")||Z.min),this.max=Number(this.getAttribute("max")||Z.max),this.step=Number(this.getAttribute("step")||Z.step),this.color=this.getAttribute("color")||Z?.color,this.default=this.hasAttribute("default")?this.getAttribute("default"):this.type==="delta"?0:this.min,this.#Q=this.type!=="range"&&(Q===null||typeof Q==="string"&&Q.trim()===""),this.value=this.#f(Q)}#M(){if(!this.querySelector("[type=range]"))return!1;return this.getAttribute("text")!=="false"===!!this.querySelector("fig-input-number")}#F(){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",this.#Q?"":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)}}#O(){if(this.#T(),this.input.removeEventListener("input",this.#_),this.input.addEventListener("input",this.#_),this.input.removeEventListener("change",this.#G),this.input.addEventListener("change",this.#G),this.input.removeEventListener("keydown",this.#Y),this.input.addEventListener("keydown",this.#Y),this.input.removeEventListener("pointerdown",this.#K),this.input.addEventListener("pointerdown",this.#K),this.input.removeEventListener("pointerup",this.#U),this.input.addEventListener("pointerup",this.#U),this.default)this.style.setProperty("--default",this.#P(this.default));if(this.figInputNumber)this.#x(),this.figInputNumber.removeEventListener("input",this.#X),this.figInputNumber.addEventListener("input",this.#X),this.figInputNumber.removeEventListener("change",this.#W),this.figInputNumber.addEventListener("change",this.#W)}#A(){if(this.#B(),this.color)this.style.setProperty("--color",this.color);let Q="",Z=`<div class="fig-slider-input-container" role="group">
40
40
  <input
41
41
  type="range"
42
42
  ${this.text?'tabindex="-1"':""}
@@ -60,17 +60,7 @@ var A1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var F1={};var L0=A1(()=>{/*! Vendored from @
60
60
  value="${this.#Q?"":this.value}"
61
61
  ${this.units?`units="${this.units}"`:""}
62
62
  ${this.precision!==null?`precision="${this.precision}"`:""}>
63
- </fig-input-number>`;else Q=Z;if(this.innerHTML=Q,this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.figInputNumber=this.querySelector("fig-input-number"),this.#A(),this.datalist=this.querySelector("datalist"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||y()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",y());let $=(this.max-this.min)/this.step+1;for(let J=0;J<$;J++){let j=document.createElement("option");j.setAttribute("value",this.min+J*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("id",y());let $=document.createElement("option");$.setAttribute("value",this.default),this.datalist.append($),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let $=this.datalist.querySelector(`option[value='${this.default}']`);if($)$.setAttribute("default","true")}this.#E()}connectedCallback(){if(this.#M()){this.#z(),this.#A(),this.#E();return}this.#D()}get value(){if(this.#$!=="")return this.#$;let Q=this.getAttribute("value");if(Q!==null)return String(this.#T(Q));return""}set value(Q){let Z=Q===null||Q===void 0?"":String(Q),J=this.min!==void 0||this.max!==void 0?String(this.#T(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",this.#Q?"":J);if(this.input)this.#C()}disconnectedCallback(){if(this.input)this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#G),this.input.removeEventListener("keydown",this.#Y),this.input.removeEventListener("pointerdown",this.#K),this.input.removeEventListener("pointerup",this.#U);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#X),this.figInputNumber.removeEventListener("change",this.#W)}#H(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let Z=this.#T(Q);this.value=Z,this.input.value=String(Z),this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#R(Q){let{min:Z,max:$}=this.#S(),J=$-Z;if(J===0)return 0;return(Number(Q)-Z)/J}#F(Q){if(Q===null||Q===void 0)return null;if(typeof Q==="string"&&Q.trim()==="")return null;let Z=Number(Q);return Number.isFinite(Z)?Z:null}#S(){let Q=this.#F(this.min),Z=this.#F(this.max);if(Q===null)Q=0;if(Z===null)Z=Q;if(Q>Z)[Q,Z]=[Z,Q];return{min:Q,max:Z}}#k(Q){let{min:Z,max:$}=this.#S();return Math.min($,Math.max(Z,Q))}#f(){if(this.type==="delta"){let Z=this.#F(this.default);if(Z!==null)return this.#k(Z);return this.#k(0)}if(this.type==="range"){let{min:Z,max:$}=this.#S();return this.#k(Z+($-Z)/2)}let{min:Q}=this.#S();return Q}#T(Q){let Z=this.#F(Q);if(Z===null)return this.#f();return this.#k(Z)}#C(){let Q=this.#R(this.value),Z=this.#R(this.default),$=Q===Z?1:0;if(this.#N!==Q)this.style.setProperty("--slider-complete",Q),this.#N=Q;if(this.#L!==Z)this.style.setProperty("--default",Z),this.#L=Z;if(this.#O!==$)this.style.setProperty("--unchanged",$),this.#O=$}#E(){let Q=this.input.value;if(this.value=Q,this.#C(),this.input.setAttribute("aria-valuenow",Q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Q)}#P(){if(!this.input)return;if(this.text){this.input.setAttribute("aria-hidden","true"),["aria-label","aria-labelledby","aria-describedby","aria-valuetext"].forEach((Q)=>this.input.removeAttribute(Q)),this.#I();return}this.input.removeAttribute("aria-hidden"),this.#j.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#I(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.figInputNumber.removeAttribute(Q);else this.figInputNumber.setAttribute(Q,Z)})}#g(){this.#Q=!1,this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#V(){this.#Z=!1,this.#Q=!1,this.#E(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#y(Q){if(this.disabled||!Q.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Q.key))return;Q.preventDefault(),this.#Q=!1;let Z=Q.key==="ArrowRight"||Q.key==="ArrowUp"?1:-1,$=this.#F(this.input.value)??this.#f(),J=this.#F(this.step)??1,j=this.#T($+J*10*Z);this.value=j,this.input.value=String(j),this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#w(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let Z=this.#T(Q);this.value=Z,this.input.value=String(Z),this.#E(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}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(Q,Z,$){if(Q==="value"&&this.#J)return;if(this.input)switch(Q){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.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#Z)break;if(this.#Q=$===null||typeof $==="string"&&$.trim()==="",this.value=this.#T($),this.input.value=String(this.value),this.#E(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":this.value);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=$!==null?$:this.type==="delta"?0:this.min,this.#C();break;case"min":case"max":case"step":case"type":case"variant":case"units":this[Q]=$,this.#D();break;case"text":this.text=$!=="false",this.#D();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#P();break;default:this[Q]=this.input[Q]=$,this.#E();break}}}customElements.define("fig-slider",x0);class V0 extends HTMLElement{#Z=!1;#Q=!1;#J;#$;#j;#q;#_;#G;#X;#W=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#J=this.#A.bind(this),this.#$=this.#H.bind(this),this.#j=this.#H.bind(this),this.#q=this.#D.bind(this),this.#_=(Q)=>{Q.stopPropagation(),this.#z(Q)},this.#G=()=>{this.#L()},this.#X=this.focus.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")||!1,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.#Y(),this.input.readOnly=this.readonly,this.#K(),this.#U(),this.#N(),this.#L(),this.#O(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#M(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#M(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#M(this.step));this.addEventListener("pointerdown",this.#q)}this.input.removeEventListener("change",this.#_),this.input.addEventListener("change",this.#_),this.input.removeEventListener("input",this.#G),this.input.addEventListener("input",this.#G)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#_),this.input.removeEventListener("input",this.#G);this.removeEventListener("pointerdown",this.#q),window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#$),window.removeEventListener("blur",this.#j)}focus(){this.input.focus()}#Y(){let Q=this.multiline,Z=this.querySelector("input,textarea");if(Z){if(Q?Z.tagName==="TEXTAREA":Z.tagName==="INPUT")return Z}let $=`<input
64
- type="${this.type}"
65
- ${this.name?`name="${this.name}"`:""}
66
- placeholder="${this.placeholder}"
67
- value="${this.type==="number"?this.#M(this.value):this.value}" />`;if(Q)$=`<textarea
68
- placeholder="${this.placeholder}">${this.value}</textarea>`;let J=this.querySelector("[slot=append]"),j=this.querySelector("[slot=prepend]");if(this.innerHTML=$,j)j.removeEventListener("click",this.#X),j.addEventListener("click",this.#X),this.prepend(j);if(J)J.removeEventListener("click",this.#X),J.addEventListener("click",this.#X),this.append(J);return this.querySelector("input,textarea")}#K(){if(!this.input)return;this.#W.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#U(){let Q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){Q?.remove();return}let Z=this.querySelector('[slot="prepend"]');if(Z&&Z!==Q)return;if(Q){let J=Q.querySelector("fig-icon");if(J&&J.getAttribute("name")!=="search")J.setAttribute("name","search");return}let $=v("search");$.setAttribute("slot","prepend"),$.setAttribute("data-generated","search-prefix"),$.setAttribute("color","var(--figma-color-icon)"),$.addEventListener("click",this.#X),this.prepend($)}#N(){let Q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){Q?.remove();return}let Z=this.querySelector('[slot="append"]');if(Z&&Z!==Q)return;if(Q){let q=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 j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon",""),j.setAttribute("aria-label","Clear search");let _=v("close",{size:"small"});_.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(_),J.append(j),$.append(J),this.append($),j.addEventListener("click",(q)=>{if(q.preventDefault(),q.stopPropagation(),!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.#L(),this.focus()})}#L(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#O(){let Q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){Q?.remove(),this.#Q=!1;return}let Z=this.querySelector('[slot="append"]');if(Z&&Z!==Q)return;if(Q){this.#B(Q);return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","password-toggle");let J=document.createElement("fig-tooltip"),j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon","");let _=v("visible",{size:"small"});_.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(_),J.append(j),$.append(J),this.append($),this.#B($),j.addEventListener("click",(q)=>{if(q.preventDefault(),q.stopPropagation(),this.#Q=!this.#Q,this.input)this.input.type=this.#Q?"text":"password";this.#B($),this.focus()})}#B(Q){let Z=Q.querySelector("fig-tooltip"),$=Q.querySelector("fig-button"),J=Q.querySelector("fig-icon"),j=this.#Q?"Hide password":"Show password";Z?.setAttribute("text",j),$?.setAttribute("aria-label",j),J?.setAttribute("name",this.#Q?"visible":"hidden")}#M(Q){if(Q==="")return"";let Z=Number(Q)*(this.transform||1);return Z=this.#F(Z),Z}#z(Q){Q.stopPropagation();let Z=Q.target.value,$=Z;if(this.type==="number")Z=Z/(this.transform||1),Z=this.#R(Z,!1),$=Z*(this.transform||1);this.value=Z,this.input.value=$,this.#L(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#A(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#H();return}let Z=(this.step||1)*Q.movementX,$=Number(this.input.value);$=$/(this.transform||1)+Z,$=this.#R($,!1);let J=$*(this.transform||1);$=this.#F($),J=this.#F(J),this.value=$,this.input.value=J,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#D(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#Z=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#J),window.addEventListener("pointerup",this.#$),window.addEventListener("blur",this.#j)}#H(Q){if(this.type!=="number")return;this.#Z=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#$),window.removeEventListener("blur",this.#j)}#R(Q,Z=!0){let $=Q;if(this.type==="number"){if($=Number($),typeof this.min==="number")$=Math.max(Z?this.#M(this.min):this.min,$);if(typeof this.max==="number")$=Math.min(Z?this.#M(this.max):this.max,$);$=this.#F($)}return $}#F(Q,Z=2){let $=Math.round(Q*100)/100;return Number.isInteger($)?$:$.toFixed(Z)}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","step","min","max","transform","name","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(Q,Z,$){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false";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.#M(this.value);break;case"value":if(this.#Z)break;let J=$;if(this.type==="number")J=this.#R(J,!1),this.value=J,this.input.value=this.#M(J);else this.value=J,this.input.value=J;this.#L();break;case"min":case"max":case"step":if(this[Q]=this.input[Q]=Number($),this.input)this.input.setAttribute(Q,$);break;case"name":this[Q]=this.input[Q]=$,this.input.setAttribute("name",$);break;case"placeholder":this.placeholder=$??"",this.input.placeholder=this.placeholder;break;case"type":this.type=$||"text",this.input.type=this.type,this.#U(),this.#N(),this.#L(),this.#O();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#K();break;default:this[Q]=this.input[Q]=$;break}}}customElements.define("fig-input-text",V0);class n extends HTMLElement{#Z;#Q;#J;#$;#j;#q;#_;#G;#X;#W;#Y;#K;#U;#N;#L;#O=!1;#B=null;#M=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#z="px";#A(Q){return(Q||"").split(",").map((Z)=>Z.trim().toLowerCase()).filter(Boolean)}#D(Q){let Z=(Q||"").trim();if(!Z)return"";return(this.#U??[]).includes(Z.toLowerCase())?"":Z}#H(){this.#Y=this.#D(this.#K)}#R(Q){if(Q&&!this.#B)this.#B=document.createElement("span"),this.#B.className="fig-steppers",this.#B.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',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.#S(J),this.input.focus()}),this.append(this.#B);else if(!Q&&this.#B)this.#B.remove(),this.#B=null;this.#F()}#F(){if(!this.#B)return;let Q=this.#B.querySelector(".fig-stepper-up"),Z=this.#B.querySelector(".fig-stepper-down");if(!Q||!Z)return;let $=this.input?this.#C(this.input.value):this.value,J=$!==""&&$!==null&&$!==void 0?Number($)/(this.transform||1):Number(this.value),j=Number.isFinite(J),_=Boolean(this.disabled),q=j&&typeof this.min==="number"&&J<=this.min,G=j&&typeof this.max==="number"&&J>=this.max;Q.disabled=_||G,Z.disabled=_||q}#S(Q){let Z=this.step||1,$=this.#C(this.input.value),J=($!==""?Number($)/(this.transform||1):0)+Z*Q;J=this.#x(J,!1),this.value=J,this.input.value=this.#E(this.value),this.#F(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#Z=this.#v.bind(this),this.#Q=this.#b.bind(this),this.#J=this.#b.bind(this),this.#$=this.#h.bind(this),this.#j=(Q)=>{Q.stopPropagation(),this.#w(Q)},this.#q=(Q)=>{Q.stopPropagation(),this.#y(Q)},this.#_=(Q)=>{this.#I(Q)},this.#G=(Q)=>{this.#g(Q)},this.#X=(Q)=>{this.#V(Q)},this.#W=this.focus.bind(this)}connectedCallback(){let Q=this.getAttribute("value");this.value=Q!==null&&Q!==""?Number(Q):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#K=this.getAttribute("units")||"";let Z=this.getAttribute("units-disallow");if(this.#U=this.#A(Z===null?n.#z:Z),this.#H(),this.#N=this.getAttribute("unit-position")||"suffix",this.#L=this.hasAttribute("precision")?Number(this.getAttribute("precision")):2,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.#k(),this.#f(),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.#R($),this.hasAttribute("disabled")){let J=this.getAttribute("disabled");this.disabled=this.input.disabled=J!=="false"}this.#F(),this.#T(),this.addEventListener("pointerdown",this.#$),this.input.removeEventListener("change",this.#j),this.input.addEventListener("change",this.#j),this.input.removeEventListener("input",this.#q),this.input.addEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.addEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#G),this.input.addEventListener("blur",this.#G),this.input.removeEventListener("keydown",this.#X),this.input.addEventListener("keydown",this.#X)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#j),this.input.removeEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#G),this.input.removeEventListener("keydown",this.#X);this.removeEventListener("pointerdown",this.#$),window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J)}focus(){this.input.focus()}#k(){let Q=this.querySelector("input");if(Q)return Q;let Z=`<input
69
- type="text"
70
- inputmode="decimal"
71
- ${this.name?`name="${this.name}"`:""}
72
- placeholder="${this.placeholder}"
73
- value="${this.#E(this.value)}" />`,$=this.querySelector("[slot=append]"),J=this.querySelector("[slot=prepend]");if(this.innerHTML=Z,J)J.removeEventListener("click",this.#W),J.addEventListener("click",this.#W),this.prepend(J);if($)$.removeEventListener("click",this.#W),$.addEventListener("click",this.#W),this.append($);return this.querySelector("input")}#f(){if(!this.input)return;this.#M.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#T(){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 Q=this.value===""?null:Number(this.value);if(Number.isFinite(Q))this.input.setAttribute("aria-valuenow",String(Q)),this.input.setAttribute("aria-valuetext",this.#E(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#C(Q){if(!Q)return"";if(!this.#Y){let J=Q.replace(/[^\d.-]/g,""),j=J.split(".");if(j.length>2)J=j[0]+"."+j.slice(1).join("");return J}let Z=Q.replace(this.#Y,"").trim();Z=Z.replace(/[^\d.-]/g,"");let $=Z.split(".");if($.length>2)Z=$[0]+"."+$.slice(1).join("");return Z}#E(Q){if(Q===""||Q===null||Q===void 0)return"";let Z=Number(Q)*(this.transform||1);if(isNaN(Z))return"";if(Z=this.#m(Z),!this.#Y)return Z.toString();if(this.#N==="prefix")return this.#Y+Z;else return Z+this.#Y}#P(Q){if(Q===""||Q===null||Q===void 0)return"";let Z=Number(Q)*(this.transform||1);return Z=this.#m(Z),Z.toString()}#I(Q){this.#O=!0,setTimeout(()=>{let Z=Q.target.value;if(Z&&this.#Y)if(this.#N==="prefix")Q.target.setSelectionRange(this.#Y.length,Z.length);else{let $=Z.indexOf(this.#Y);if($>-1)Q.target.setSelectionRange(0,$)}},0)}#g(Q){this.#O=!1;let Z=this.#C(Q.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#x($,!1),this.value=$,Q.target.value=this.#E(this.value)}else this.value="",Q.target.value="";this.#F(),this.#T(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#V(Q){if(this.disabled)return;if(Q.key!=="ArrowUp"&&Q.key!=="ArrowDown")return;Q.preventDefault();let Z=this.step||1,$=Q.shiftKey?10:1,J=Z*$*(Q.key==="ArrowUp"?1:-1),j=this.#C(this.input.value),_=(j!==""?Number(j)/(this.transform||1):0)+J;_=this.#x(_,!1),this.value=_,this.input.value=this.#E(this.value),this.#F(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#y(Q){let Z=this.#C(Q.target.value);if(Z!=="")this.value=Number(Z)/(this.transform||1);else this.value="";this.#F(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#w(Q){Q.stopPropagation();let Z=this.#C(Q.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#x($,!1),this.value=$,Q.target.value=this.#E(this.value)}else this.value="",Q.target.value="";this.#F(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#v(Q){if(this.disabled)return;if(Q.buttons===0){this.#b();return}let Z=(this.step||1)*Q.movementX,$=this.#C(this.input.value),J=Number($)/(this.transform||1)+Z;J=this.#x(J,!1),this.value=J,this.input.value=this.#E(this.value),this.#F(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#h(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#O=!0,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.#Q),window.addEventListener("blur",this.#J)}#b(Q){this.#O=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J)}#x(Q,Z=!0){let $=Number(Q);if(isNaN($))return"";if(typeof this.min==="number")$=Math.max(this.min,$);if(typeof this.max==="number")$=Math.min(this.max,$);return $=this.#m($),$}#m(Q){let Z=this.#L??2,$=Math.pow(10,Z),J=Math.round(Q*$)/$;return Number.isInteger(J)?J:parseFloat(J.toFixed(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(Q,Z,$){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false",this.#F();break;case"units":this.#K=$||"",this.#H(),this.input.value=this.#E(this.value),this.#T();break;case"units-disallow":this.#U=this.#A($===null?n.#z:$),this.#H(),this.input.value=this.#E(this.value),this.#T();break;case"unit-position":this.#N=$||"suffix",this.input.value=this.#E(this.value),this.#T();break;case"transform":this.transform=Number($)||1,this.input.value=this.#E(this.value),this.#T();break;case"value":if(this.#O)break;let J=$!==null&&$!==""?Number($):"";if(J!=="")J=this.#x(J,!1);this.value=J,this.input.value=this.#E(this.value),this.#F(),this.#T();break;case"min":case"max":case"step":if($===null||$===""){this[Q]=void 0,this.#F(),this.#T();break}this[Q]=Number($),this.#F(),this.#T();break;case"steppers":{let j=$!==null&&$!=="false";this.#R(j);break}case"precision":this.#L=$!==null?Number($):2,this.input.value=this.#E(this.value),this.#T();break;case"name":this[Q]=this.input[Q]=$,this.input.setAttribute("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.#f();break;default:this[Q]=this.input[Q]=$;break}}}customElements.define("fig-input-number",n);class y0 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(Q){if(this.src=Q,Q)this.innerHTML=`<img src="${this.src}" ${this.name?`alt="${this.name}"`:""} />`}getInitials(Q){return Q?Q.split(" ").map((Z)=>Z[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(Q,Z,$){if(this[Q]=$,Q==="name")this.img?.setAttribute("alt",$),this.name=$,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials);else if(Q==="src")this.src=$,this.setSrc(this.src)}}customElements.define("fig-avatar",y0);class w0 extends HTMLElement{#Z=!1;#Q=null;#J=null;#$=null;#j=null;#q=null;#_=null;constructor(){super();this.#J=this.#W.bind(this),this.#$=this.focus.bind(this),this.#j=this.#Y.bind(this),this.#q=this.#K.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(!this.isConnected)return;this.#X(),this.#G()})}#G(){if(this.#_||typeof MutationObserver>"u")return;this.#_=new MutationObserver(()=>{this.#X()}),this.#_.observe(this,{childList:!0})}#X(){let Q=this.label,Z=this.#Q;if(Q?.removeEventListener("click",this.#J),Q?.removeEventListener("click",this.#$),Q?.removeEventListener("pointerenter",this.#j),Q?.removeEventListener("pointerleave",this.#q),Z?.removeEventListener("click",this.#J),this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find(($)=>$.nodeType===Node.ELEMENT_NODE&&$.nodeName.toLowerCase().startsWith("fig-")&&!($ instanceof Element&&$.classList.contains("fig-field-chevron"))),this.#Z=!!(this.input&&("open"in this.input)),this.#Z&&this.label){if(!this.#Q||!this.#Q.isConnected)this.#Q=v("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#Q,this.label);this.#Q.addEventListener("click",this.#J),this.label.addEventListener("click",this.#J)}else if(this.input&&this.label)this.label.addEventListener("click",this.#$);if(this.input&&this.label&&!this.#Z)this.#U();if(this.label)this.label.removeEventListener("pointerenter",this.#j),this.label.addEventListener("pointerenter",this.#j),this.label.removeEventListener("pointerleave",this.#q),this.label.addEventListener("pointerleave",this.#q)}disconnectedCallback(){if(this.#_?.disconnect(),this.#_=null,this.label)H.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.#j)this.label.removeEventListener("pointerenter",this.#j);if(this.label&&this.#q)this.label.removeEventListener("pointerleave",this.#q);if(this.#Q&&this.#J)this.#Q.removeEventListener("click",this.#J)}#W(Q){if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open}#Y(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;H.show(this.label,this.label.textContent.trim())}#K(){if(this.label)H.hide(this.label)}#U(){if(!this.input||!this.label)return;let Q=this.label.getAttribute("id")||y();this.label.setAttribute("id",Q);let Z=this.input.querySelectorAll("input, select, textarea");if(Z.length===1){let $=Z[0],J=$.getAttribute("id")||y();if($.setAttribute("id",J),this.label.setAttribute("for",J),this.input.getAttribute("aria-labelledby")===Q)this.input.removeAttribute("aria-labelledby");if(!$.hasAttribute("aria-labelledby"))$.setAttribute("aria-labelledby",Q);return}if(this.label.removeAttribute("for"),!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-labelledby",Q)}attributeChangedCallback(Q,Z,$){switch(Q){case"label":if(this.label)this.label.textContent=$,this.#U();break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let Q=this.input.querySelectorAll("input, select, textarea");if(Q.length===1)Q[0].focus(),Q[0].click();else if(this.input.focus(),Q.length===0)this.input.click()}}customElements.define("fig-field",w0);class g0 extends HTMLElement{rgba;hex;#Z=100;#Q;#J;#$;#j;#q=!1;#_=!1;#G=null;#X=this.#T.bind(this);#W=this.#C.bind(this);#Y=this.#E.bind(this);#K=this.#v.bind(this);#U=this.#I.bind(this);#N=this.#V.bind(this);#L=this.#g.bind(this);#O=this.#h.bind(this);constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0||Q===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(Q))}#B(){let Q={},Z=this.getAttribute("experimental");if(Z)Q.experimental=Z;for(let{name:$,value:J}of this.attributes)if($.startsWith("picker-")&&$!=="picker-anchor")Q[$.slice(7)]=J;if(!Q["dialog-position"])Q["dialog-position"]="left";return Q}#M(){let Q=this.#B();return Object.entries(Q).map(([Z,$])=>`${Z}="${$}"`).join(" ")}connectedCallback(){if(this.#z()){this.#A();return}this.#R()}disconnectedCallback(){this.#D()}#z(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-chit")}#A(){if(this.#P(this.getAttribute("value")),this.#Q=this.querySelector("fig-chit"),this.#J=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#j=this.querySelector("fig-input-number"),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j)this.#j.setAttribute("value",String(this.#Z));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",String(this.rgba.a));this.#w(),this.#H()}#D(){if(this.#Q)this.#Q.removeEventListener("pointerdown",this.#X,{capture:!0}),this.#Q.removeEventListener("click",this.#W,{capture:!0}),this.#Q.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#Y),this.#Q.removeEventListener("input",this.#K);this.#$?.removeEventListener("input",this.#U),this.#$?.removeEventListener("change",this.#N),this.#j?.removeEventListener("input",this.#L),this.#j?.removeEventListener("change",this.#N),this.#J?.removeEventListener("input",this.#O),this.#J?.removeEventListener("change",this.#N)}#H(){if(this.#Q){this.#Q.disabled=this.hasAttribute("disabled");let Q=this.#Q.querySelector('input[type="color"]');if(this.#$||this.hasAttribute("swatch-disabled"))Q?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(Q?.setAttribute("disabled",""),Q)Q.style.pointerEvents="none"}this.#Q.addEventListener("pointerdown",this.#X,{capture:!0}),this.#Q.addEventListener("click",this.#W,{capture:!0}),Q?.addEventListener("keydown",this.#Y),this.#Q.addEventListener("input",this.#K)}if(this.#$)this.#$.addEventListener("input",this.#U),this.#$.addEventListener("change",this.#N);if(this.#j)this.#j.addEventListener("input",this.#L),this.#j.addEventListener("change",this.#N);if(this.#J)this.#J.addEventListener("input",this.#O),this.#J.addEventListener("change",this.#N)}#R(){this.#P(this.getAttribute("value"));let Q=this.getAttribute("alpha")!=="false",$=this.#m?" disabled":"",J="";if(this.getAttribute("text")!=="false"){let _=`<fig-input-text
63
+ </fig-input-number>`;else Q=Z;if(this.innerHTML=Q,this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.figInputNumber=this.querySelector("fig-input-number"),this.#O(),this.datalist=this.querySelector("datalist"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||y()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",y());let $=(this.max-this.min)/this.step+1;for(let J=0;J<$;J++){let j=document.createElement("option");j.setAttribute("value",this.min+J*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("id",y());let $=document.createElement("option");$.setAttribute("value",this.default),this.datalist.append($),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let $=this.datalist.querySelector(`option[value='${this.default}']`);if($)$.setAttribute("default","true")}this.#k()}connectedCallback(){if(this.#M()){this.#F(),this.#O(),this.#k();return}this.#A()}get value(){if(this.#$!=="")return this.#$;let Q=this.getAttribute("value");if(Q!==null)return String(this.#f(Q));return""}set value(Q){let Z=Q===null||Q===void 0?"":String(Q),J=this.min!==void 0||this.max!==void 0?String(this.#f(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",this.#Q?"":J);if(this.input)this.#S()}disconnectedCallback(){if(this.input)this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#G),this.input.removeEventListener("keydown",this.#Y),this.input.removeEventListener("pointerdown",this.#K),this.input.removeEventListener("pointerup",this.#U);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#X),this.figInputNumber.removeEventListener("change",this.#W)}#z(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let Z=this.#f(Q);this.value=Z,this.input.value=String(Z),this.#k(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#P(Q){let{min:Z,max:$}=this.#E(),J=$-Z;if(J===0)return 0;return(Number(Q)-Z)/J}#D(Q){if(Q===null||Q===void 0)return null;if(typeof Q==="string"&&Q.trim()==="")return null;let Z=Number(Q);return Number.isFinite(Z)?Z:null}#E(){let Q=this.#D(this.min),Z=this.#D(this.max);if(Q===null)Q=0;if(Z===null)Z=Q;if(Q>Z)[Q,Z]=[Z,Q];return{min:Q,max:Z}}#C(Q){let{min:Z,max:$}=this.#E();return Math.min($,Math.max(Z,Q))}#R(){if(this.type==="delta"){let Z=this.#D(this.default);if(Z!==null)return this.#C(Z);return this.#C(0)}if(this.type==="range"){let{min:Z,max:$}=this.#E();return this.#C(Z+($-Z)/2)}let{min:Q}=this.#E();return Q}#f(Q){let Z=this.#D(Q);if(Z===null)return this.#R();return this.#C(Z)}#S(){let Q=this.#P(this.value),Z=this.#P(this.default),$=Q===Z?1:0;if(this.#N!==Q)this.style.setProperty("--slider-complete",Q),this.#N=Q;if(this.#L!==Z)this.style.setProperty("--default",Z),this.#L=Z;if(this.#H!==$)this.style.setProperty("--unchanged",$),this.#H=$}#k(){let Q=this.input.value;if(this.value=Q,this.#S(),this.input.setAttribute("aria-valuenow",Q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Q)}#T(){if(!this.input)return;if(this.text){this.input.setAttribute("aria-hidden","true"),["aria-label","aria-labelledby","aria-describedby","aria-valuetext"].forEach((Q)=>this.input.removeAttribute(Q)),this.#x();return}this.input.removeAttribute("aria-hidden"),this.#j.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#x(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.figInputNumber.removeAttribute(Q);else this.figInputNumber.setAttribute(Q,Z)})}#g(){this.#Q=!1,this.#k(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#w(){this.#Z=!1,this.#Q=!1,this.#k(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#I(Q){if(this.disabled||!Q.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Q.key))return;Q.preventDefault(),this.#Q=!1;let Z=Q.key==="ArrowRight"||Q.key==="ArrowUp"?1:-1,$=this.#D(this.input.value)??this.#R(),J=this.#D(this.step)??1,j=this.#f($+J*10*Z);this.value=j,this.input.value=String(j),this.#k(),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 Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let Z=this.#f(Q);this.value=Z,this.input.value=String(Z),this.#k(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}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(Q,Z,$){if(Q==="value"&&this.#J)return;if(this.input)switch(Q){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.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#Z)break;if(this.#Q=$===null||typeof $==="string"&&$.trim()==="",this.value=this.#f($),this.input.value=String(this.value),this.#k(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":this.value);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=$!==null?$:this.type==="delta"?0:this.min,this.#S();break;case"min":case"max":case"step":case"type":case"variant":case"units":this[Q]=$,this.#A();break;case"text":this.text=$!=="false",this.#A();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#T();break;default:this[Q]=this.input[Q]=$,this.#k();break}}}customElements.define("fig-slider",g0);class b0 extends HTMLElement{#Z=!1;#Q=!1;#J;#$;#j;#q;#_;#G;#X;#W;#Y=null;#K=0;#U=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#J=this.#R.bind(this),this.#$=this.#S.bind(this),this.#j=this.#S.bind(this),this.#q=this.#f.bind(this),this.#_=(Q)=>{Q.stopPropagation(),this.#C(Q)},this.#G=()=>{this.#z()},this.#X=this.focus.bind(this),this.#W=this.#L.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")||!1,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.#N(),this.input.readOnly=this.readonly,this.#F(),this.#O(),this.#A(),this.#z(),this.#P(),n(this),this.#H(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#E(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#E(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#E(this.step));this.addEventListener("pointerdown",this.#q)}this.removeEventListener("click",this.#W),this.addEventListener("click",this.#W),this.input.removeEventListener("change",this.#_),this.input.addEventListener("change",this.#_),this.input.removeEventListener("input",this.#G),this.input.addEventListener("input",this.#G)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#_),this.input.removeEventListener("input",this.#G);if(this.removeEventListener("click",this.#W),this.removeEventListener("pointerdown",this.#q),window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#$),window.removeEventListener("blur",this.#j),this.#Y?.disconnect(),this.#Y=null,this.#K)cancelAnimationFrame(this.#K),this.#K=0}focus(){this.input.focus()}#N(){let Q=this.multiline,Z=this.querySelector("input,textarea");if(Z){if(Q?Z.tagName==="TEXTAREA":Z.tagName==="INPUT")return Z;Z.remove()}let $;if(Q)$=document.createElement("textarea"),$.value=this.value;else $=document.createElement("input"),$.type=this.type,$.value=this.type==="number"?this.#E(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(Q){let Z=Q.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;this.focus()}#H(){this.#Y?.disconnect(),this.#Y=new MutationObserver(()=>this.#B()),this.#Y.observe(this,{childList:!0,characterData:!0,subtree:!0})}#B(){if(this.#K)return;this.#K=requestAnimationFrame(()=>{if(this.#K=0,!this.isConnected)return;this.#M()})}#M(){if(!this.input||!this.contains(this.input))this.input=this.#N(),this.input.readOnly=this.readonly,this.input.addEventListener("change",this.#_),this.input.addEventListener("input",this.#G);this.#F(),this.#O(),this.#A(),this.#z(),this.#P(),n(this)}#F(){if(!this.input)return;this.#U.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#O(){let Q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){Q?.remove();return}if(this.querySelector('[slot="prepend"]:not([data-generated])')){Q?.remove();return}if(Q){let J=Q.querySelector("fig-icon");if(J&&J.getAttribute("name")!=="search")J.setAttribute("name","search");return}let $=v("search");$.setAttribute("slot","prepend"),$.setAttribute("data-generated","search-prefix"),$.setAttribute("color","var(--figma-color-icon)"),$.addEventListener("click",this.#X),this.prepend($)}#A(){let Q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){Q?.remove();return}if(this.querySelector('[slot="append"]:not([data-generated])')){Q?.remove();return}if(Q){let q=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 j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon",""),j.setAttribute("aria-label","Clear search");let _=v("close",{size:"small"});_.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(_),J.append(j),$.append(J),this.append($),j.addEventListener("click",(q)=>{if(q.preventDefault(),q.stopPropagation(),!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.#z(),this.focus()})}#z(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#P(){let Q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){Q?.remove(),this.#Q=!1;return}if(this.querySelector('[slot="append"]:not([data-generated])')){Q?.remove();return}if(Q){this.#D(Q);return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","password-toggle");let J=document.createElement("fig-tooltip"),j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon","");let _=v("visible",{size:"small"});_.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(_),J.append(j),$.append(J),this.append($),this.#D($),j.addEventListener("click",(q)=>{if(q.preventDefault(),q.stopPropagation(),this.#Q=!this.#Q,this.input)this.input.type=this.#Q?"text":"password";this.#D($),this.focus()})}#D(Q){let Z=Q.querySelector("fig-tooltip"),$=Q.querySelector("fig-button"),J=Q.querySelector("fig-icon"),j=this.#Q?"Hide password":"Show password";Z?.setAttribute("text",j),$?.setAttribute("aria-label",j),J?.setAttribute("name",this.#Q?"visible":"hidden")}#E(Q){if(Q==="")return"";let Z=Number(Q)*(this.transform||1);return Z=this.#T(Z),Z}#C(Q){Q.stopPropagation();let Z=Q.target.value,$=Z;if(this.type==="number")Z=Z/(this.transform||1),Z=this.#k(Z,!1),$=Z*(this.transform||1);this.value=Z,this.input.value=$,this.#z(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#R(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#S();return}let Z=(this.step||1)*Q.movementX,$=Number(this.input.value);$=$/(this.transform||1)+Z,$=this.#k($,!1);let J=$*(this.transform||1);$=this.#T($),J=this.#T(J),this.value=$,this.input.value=J,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#f(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#Z=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#J),window.addEventListener("pointerup",this.#$),window.addEventListener("blur",this.#j)}#S(Q){if(this.type!=="number")return;this.#Z=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#$),window.removeEventListener("blur",this.#j)}#k(Q,Z=!0){let $=Q;if(this.type==="number"){if($=Number($),typeof this.min==="number")$=Math.max(Z?this.#E(this.min):this.min,$);if(typeof this.max==="number")$=Math.min(Z?this.#E(this.max):this.max,$);$=this.#T($)}return $}#T(Q,Z=2){let $=Math.round(Q*100)/100;return Number.isInteger($)?$:$.toFixed(Z)}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","step","min","max","transform","name","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(Q,Z,$){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false";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.#E(this.value);break;case"value":if(this.#Z)break;let J=$;if(this.type==="number")J=this.#k(J,!1),this.value=J,this.input.value=this.#E(J);else this.value=J,this.input.value=J;this.#z();break;case"min":case"max":case"step":if(this[Q]=this.input[Q]=Number($),this.input)this.input.setAttribute(Q,$);break;case"name":this[Q]=this.input[Q]=$,this.input.setAttribute("name",$);break;case"placeholder":this.placeholder=$??"",this.input.placeholder=this.placeholder;break;case"type":this.type=$||"text",this.input.type=this.type,this.#O(),this.#A(),this.#z(),this.#P();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#F();break;default:this[Q]=this.input[Q]=$;break}}}customElements.define("fig-input-text",b0);class e extends HTMLElement{#Z;#Q;#J;#$;#j;#q;#_;#G;#X;#W;#Y;#K;#U;#N;#L;#H;#B=!1;#M=null;#F=null;#O=0;#A=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#z="px";#P(Q){return(Q||"").split(",").map((Z)=>Z.trim().toLowerCase()).filter(Boolean)}#D(Q){let Z=(Q||"").trim();if(!Z)return"";return(this.#N??[]).includes(Z.toLowerCase())?"":Z}#E(){this.#K=this.#D(this.#U)}#C(Q){if(Q&&!this.#M)this.#M=document.createElement("span"),this.#M.className="fig-steppers",this.#M.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#M.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.#f(J),this.input.focus()}),this.append(this.#M);else if(!Q&&this.#M)this.#M.remove(),this.#M=null;this.#R()}#R(){if(!this.#M)return;let Q=this.#M.querySelector(".fig-stepper-up"),Z=this.#M.querySelector(".fig-stepper-down");if(!Q||!Z)return;let $=this.input?this.#V(this.input.value):this.value,J=$!==""&&$!==null&&$!==void 0?Number($)/(this.transform||1):Number(this.value),j=Number.isFinite(J),_=Boolean(this.disabled),q=j&&typeof this.min==="number"&&J<=this.min,G=j&&typeof this.max==="number"&&J>=this.max;Q.disabled=_||G,Z.disabled=_||q}#f(Q){let Z=this.step||1,$=this.#V(this.input.value),J=($!==""?Number($)/(this.transform||1):0)+Z*Q;J=this.#u(J,!1),this.value=J,this.input.value=this.#y(this.value),this.#R(),this.#I(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#Z=this.#i.bind(this),this.#Q=this.#t.bind(this),this.#J=this.#t.bind(this),this.#$=this.#l.bind(this),this.#j=(Q)=>{Q.stopPropagation(),this.#d(Q)},this.#q=(Q)=>{Q.stopPropagation(),this.#m(Q)},this.#_=(Q)=>{this.#v(Q)},this.#G=(Q)=>{this.#b(Q)},this.#X=(Q)=>{this.#p(Q)},this.#W=this.focus.bind(this),this.#Y=this.#k.bind(this)}connectedCallback(){let Q=this.getAttribute("value");this.value=Q!==null&&Q!==""?Number(Q):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#U=this.getAttribute("units")||"";let Z=this.getAttribute("units-disallow");if(this.#N=this.#P(Z===null?e.#z:Z),this.#E(),this.#L=this.getAttribute("unit-position")||"suffix",this.#H=this.hasAttribute("precision")?Number(this.getAttribute("precision")):2,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.#S(),this.#w(),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.#C($),this.hasAttribute("disabled")){let J=this.getAttribute("disabled");this.disabled=this.input.disabled=J!=="false"}this.#R(),this.#I(),n(this),this.addEventListener("pointerdown",this.#$),this.removeEventListener("click",this.#Y),this.addEventListener("click",this.#Y),this.#T(),this.input.removeEventListener("change",this.#j),this.input.addEventListener("change",this.#j),this.input.removeEventListener("input",this.#q),this.input.addEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.addEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#G),this.input.addEventListener("blur",this.#G),this.input.removeEventListener("keydown",this.#X),this.input.addEventListener("keydown",this.#X)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#j),this.input.removeEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#G),this.input.removeEventListener("keydown",this.#X);if(this.removeEventListener("click",this.#Y),this.removeEventListener("pointerdown",this.#$),window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J),this.#F?.disconnect(),this.#F=null,this.#O)cancelAnimationFrame(this.#O),this.#O=0}focus(){this.input.focus()}#S(){let Q=this.querySelector("input");if(Q)return Q;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.#y(this.value),this.insertBefore(Z,this.querySelector('[slot="append"]')),Z}#k(Q){let Z=Q.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;this.focus()}#T(){this.#F?.disconnect(),this.#F=new MutationObserver(()=>this.#x()),this.#F.observe(this,{childList:!0,characterData:!0,subtree:!0})}#x(){if(this.#O)return;this.#O=requestAnimationFrame(()=>{if(this.#O=0,!this.isConnected)return;this.#g()})}#g(){if(!this.input||!this.contains(this.input))this.input=this.#S(),this.input.addEventListener("change",this.#j),this.input.addEventListener("input",this.#q),this.input.addEventListener("focus",this.#_),this.input.addEventListener("blur",this.#G),this.input.addEventListener("keydown",this.#X);let Q=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.#M&&!this.contains(this.#M))this.#M=null;this.#C(Q),this.#w(),this.#I(),n(this)}#w(){if(!this.input)return;this.#A.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#I(){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 Q=this.value===""?null:Number(this.value);if(Number.isFinite(Q))this.input.setAttribute("aria-valuenow",String(Q)),this.input.setAttribute("aria-valuetext",this.#y(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#V(Q){if(!Q)return"";if(!this.#K){let J=Q.replace(/[^\d.-]/g,""),j=J.split(".");if(j.length>2)J=j[0]+"."+j.slice(1).join("");return J}let Z=Q.replace(this.#K,"").trim();Z=Z.replace(/[^\d.-]/g,"");let $=Z.split(".");if($.length>2)Z=$[0]+"."+$.slice(1).join("");return Z}#y(Q){if(Q===""||Q===null||Q===void 0)return"";let Z=Number(Q)*(this.transform||1);if(isNaN(Z))return"";if(Z=this.#c(Z),!this.#K)return Z.toString();if(this.#L==="prefix")return this.#K+Z;else return Z+this.#K}#h(Q){if(Q===""||Q===null||Q===void 0)return"";let Z=Number(Q)*(this.transform||1);return Z=this.#c(Z),Z.toString()}#v(Q){this.#B=!0,setTimeout(()=>{let Z=Q.target.value;if(Z&&this.#K)if(this.#L==="prefix")Q.target.setSelectionRange(this.#K.length,Z.length);else{let $=Z.indexOf(this.#K);if($>-1)Q.target.setSelectionRange(0,$)}},0)}#b(Q){this.#B=!1;let Z=this.#V(Q.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#u($,!1),this.value=$,Q.target.value=this.#y(this.value)}else this.value="",Q.target.value="";this.#R(),this.#I(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#p(Q){if(this.disabled)return;if(Q.key!=="ArrowUp"&&Q.key!=="ArrowDown")return;Q.preventDefault();let Z=this.step||1,$=Q.shiftKey?10:1,J=Z*$*(Q.key==="ArrowUp"?1:-1),j=this.#V(this.input.value),_=(j!==""?Number(j)/(this.transform||1):0)+J;_=this.#u(_,!1),this.value=_,this.input.value=this.#y(this.value),this.#R(),this.#I(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#m(Q){let Z=this.#V(Q.target.value);if(Z!=="")this.value=Number(Z)/(this.transform||1);else this.value="";this.#R(),this.#I(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#d(Q){Q.stopPropagation();let Z=this.#V(Q.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#u($,!1),this.value=$,Q.target.value=this.#y(this.value)}else this.value="",Q.target.value="";this.#R(),this.#I(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#i(Q){if(this.disabled)return;if(Q.buttons===0){this.#t();return}let Z=(this.step||1)*Q.movementX,$=this.#V(this.input.value),J=Number($)/(this.transform||1)+Z;J=this.#u(J,!1),this.value=J,this.input.value=this.#y(this.value),this.#R(),this.#I(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#l(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#B=!0,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.#Q),window.addEventListener("blur",this.#J)}#t(Q){this.#B=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J)}#u(Q,Z=!0){let $=Number(Q);if(isNaN($))return"";if(typeof this.min==="number")$=Math.max(this.min,$);if(typeof this.max==="number")$=Math.min(this.max,$);return $=this.#c($),$}#c(Q){let Z=this.#H??2,$=Math.pow(10,Z),J=Math.round(Q*$)/$;return Number.isInteger(J)?J:parseFloat(J.toFixed(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(Q,Z,$){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false",this.#R();break;case"units":this.#U=$||"",this.#E(),this.input.value=this.#y(this.value),this.#I();break;case"units-disallow":this.#N=this.#P($===null?e.#z:$),this.#E(),this.input.value=this.#y(this.value),this.#I();break;case"unit-position":this.#L=$||"suffix",this.input.value=this.#y(this.value),this.#I();break;case"transform":this.transform=Number($)||1,this.input.value=this.#y(this.value),this.#I();break;case"value":if(this.#B)break;let J=$!==null&&$!==""?Number($):"";if(J!=="")J=this.#u(J,!1);this.value=J,this.input.value=this.#y(this.value),this.#R(),this.#I();break;case"min":case"max":case"step":if($===null||$===""){this[Q]=void 0,this.#R(),this.#I();break}this[Q]=Number($),this.#R(),this.#I();break;case"steppers":{let j=$!==null&&$!=="false";this.#C(j);break}case"precision":this.#H=$!==null?Number($):2,this.input.value=this.#y(this.value),this.#I();break;case"name":this[Q]=this.input[Q]=$,this.input.setAttribute("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.#w();break;default:this[Q]=this.input[Q]=$;break}}}customElements.define("fig-input-number",e);class v0 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(Q){if(this.src=Q,Q)this.innerHTML=`<img src="${this.src}" ${this.name?`alt="${this.name}"`:""} />`}getInitials(Q){return Q?Q.split(" ").map((Z)=>Z[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(Q,Z,$){if(this[Q]=$,Q==="name")this.img?.setAttribute("alt",$),this.name=$,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials);else if(Q==="src")this.src=$,this.setSrc(this.src)}}customElements.define("fig-avatar",v0);class h0 extends HTMLElement{#Z=!1;#Q=null;#J=null;#$=null;#j=null;#q=null;#_=null;constructor(){super();this.#J=this.#W.bind(this),this.#$=this.focus.bind(this),this.#j=this.#Y.bind(this),this.#q=this.#K.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(!this.isConnected)return;this.#X(),this.#G()})}#G(){if(this.#_||typeof MutationObserver>"u")return;this.#_=new MutationObserver(()=>{this.#X()}),this.#_.observe(this,{childList:!0})}#X(){let Q=this.label,Z=this.#Q;if(Q?.removeEventListener("click",this.#J),Q?.removeEventListener("click",this.#$),Q?.removeEventListener("pointerenter",this.#j),Q?.removeEventListener("pointerleave",this.#q),Z?.removeEventListener("click",this.#J),this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find(($)=>$.nodeType===Node.ELEMENT_NODE&&$.nodeName.toLowerCase().startsWith("fig-")&&!($ instanceof Element&&$.classList.contains("fig-field-chevron"))),this.#Z=!!(this.input&&("open"in this.input)),this.#Z&&this.label){if(!this.#Q||!this.#Q.isConnected)this.#Q=v("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#Q,this.label);this.#Q.addEventListener("click",this.#J),this.label.addEventListener("click",this.#J)}else if(this.input&&this.label)this.label.addEventListener("click",this.#$);if(this.input&&this.label&&!this.#Z)this.#U();if(this.label)this.label.removeEventListener("pointerenter",this.#j),this.label.addEventListener("pointerenter",this.#j),this.label.removeEventListener("pointerleave",this.#q),this.label.addEventListener("pointerleave",this.#q)}disconnectedCallback(){if(this.#_?.disconnect(),this.#_=null,this.label)F.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.#j)this.label.removeEventListener("pointerenter",this.#j);if(this.label&&this.#q)this.label.removeEventListener("pointerleave",this.#q);if(this.#Q&&this.#J)this.#Q.removeEventListener("click",this.#J)}#W(Q){if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open}#Y(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;F.show(this.label,this.label.textContent.trim())}#K(){if(this.label)F.hide(this.label)}#U(){if(!this.input||!this.label)return;let Q=this.label.getAttribute("id")||y();this.label.setAttribute("id",Q);let Z=this.input.querySelectorAll("input, select, textarea");if(Z.length===1){let $=Z[0],J=$.getAttribute("id")||y();if($.setAttribute("id",J),this.label.setAttribute("for",J),this.input.getAttribute("aria-labelledby")===Q)this.input.removeAttribute("aria-labelledby");if(!$.hasAttribute("aria-labelledby"))$.setAttribute("aria-labelledby",Q);return}if(this.label.removeAttribute("for"),!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-labelledby",Q)}attributeChangedCallback(Q,Z,$){switch(Q){case"label":if(this.label)this.label.textContent=$,this.#U();break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let Q=this.input.querySelectorAll("input, select, textarea");if(Q.length===1)Q[0].focus(),Q[0].click();else if(this.input.focus(),Q.length===0)this.input.click()}}customElements.define("fig-field",h0);class m0 extends HTMLElement{rgba;hex;#Z=100;#Q;#J;#$;#j;#q=!1;#_=!1;#G=null;#X=this.#f.bind(this);#W=this.#S.bind(this);#Y=this.#k.bind(this);#K=this.#y.bind(this);#U=this.#x.bind(this);#N=this.#w.bind(this);#L=this.#g.bind(this);#H=this.#h.bind(this);constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0||Q===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(Q))}#B(){let Q={},Z=this.getAttribute("experimental");if(Z)Q.experimental=Z;for(let{name:$,value:J}of this.attributes)if($.startsWith("picker-")&&$!=="picker-anchor")Q[$.slice(7)]=J;if(!Q["dialog-position"])Q["dialog-position"]="left";return Q}#M(){let Q=this.#B();return Object.entries(Q).map(([Z,$])=>`${Z}="${$}"`).join(" ")}connectedCallback(){if(this.#F()){this.#O();return}this.#P()}disconnectedCallback(){this.#A()}#F(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-chit")}#O(){if(this.#T(this.getAttribute("value")),this.#Q=this.querySelector("fig-chit"),this.#J=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#j=this.querySelector("fig-input-number"),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j)this.#j.setAttribute("value",String(this.#Z));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",String(this.rgba.a));this.#V(),this.#z()}#A(){if(this.#Q)this.#Q.removeEventListener("pointerdown",this.#X,{capture:!0}),this.#Q.removeEventListener("click",this.#W,{capture:!0}),this.#Q.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#Y),this.#Q.removeEventListener("input",this.#K);this.#$?.removeEventListener("input",this.#U),this.#$?.removeEventListener("change",this.#N),this.#j?.removeEventListener("input",this.#L),this.#j?.removeEventListener("change",this.#N),this.#J?.removeEventListener("input",this.#H),this.#J?.removeEventListener("change",this.#N)}#z(){if(this.#Q){this.#Q.disabled=this.hasAttribute("disabled");let Q=this.#Q.querySelector('input[type="color"]');if(this.#$||this.hasAttribute("swatch-disabled"))Q?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(Q?.setAttribute("disabled",""),Q)Q.style.pointerEvents="none"}this.#Q.addEventListener("pointerdown",this.#X,{capture:!0}),this.#Q.addEventListener("click",this.#W,{capture:!0}),Q?.addEventListener("keydown",this.#Y),this.#Q.addEventListener("input",this.#K)}if(this.#$)this.#$.addEventListener("input",this.#U),this.#$.addEventListener("change",this.#N);if(this.#j)this.#j.addEventListener("input",this.#L),this.#j.addEventListener("change",this.#N);if(this.#J)this.#J.addEventListener("input",this.#H),this.#J.addEventListener("change",this.#N)}#P(){this.#T(this.getAttribute("value"));let Q=this.getAttribute("alpha")!=="false",$=this.#p?" disabled":"",J="";if(this.getAttribute("text")!=="false"){let _=`<fig-input-text
74
64
  type="text"
75
65
  placeholder="000000"
76
66
  value="${this.hexOpaque.slice(1).toUpperCase()}"${$}>
@@ -85,7 +75,7 @@ var A1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var F1={};var L0=A1(()=>{/*! Vendored from @
85
75
  </fig-tooltip>`;let q="";q=`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${$}></fig-chit>`,J=`<div class="input-combo">
86
76
  ${q}
87
77
  ${_}
88
- </div>`}else J=`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${$}></fig-chit>`;if(this.innerHTML=J,this.#Q=this.querySelector("fig-chit"),this.#J=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#j=this.querySelector("fig-input-number"),this.#w(),this.#$){let _=this.rgbAlphaToHex(this.rgba,1);if(this.#$.value=_.slice(1).toUpperCase(),this.#Q)this.#Q.background=_}this.#H()}#F(){if(!this.#J)return;for(let[Q,Z]of Object.entries(this.#B()))this.#J.setAttribute(Q,Z);if(this.#J.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#J.removeAttribute("alpha");else this.#J.setAttribute("alpha","false");if(this.hasAttribute("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}))}#S(){if(!u())return null;if(this.#J?.isConnected)return this.#F(),this.#J;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#h.bind(this)),Q.addEventListener("change",this.#V.bind(this)),this.appendChild(Q),this.#J=Q,this.#F(),Q}#k(){if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return!1;let Q=this.#S();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#f(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#T(Q){if(!u())return;if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return;if(this.#_=!0,this.#q=!0,this.#G)clearTimeout(this.#G);this.#G=setTimeout(()=>{this.#q=!1,this.#_=!1,this.#G=null},500),this.#f(Q)}#C(Q){if(!this.#q)return;if(this.#q=!1,this.#G)clearTimeout(this.#G),this.#G=null;if(this.#f(Q),this.#_)this.#_=!1,this.#k()}#E(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!u())return;if(!this.#k())return;this.#f(Q)}#P(Q){let Z=Q||"#D9D9D9";this.rgba=this.convertToRGBA(Z),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)}#I(Q){Q.stopPropagation();let Z=Q.target.value.replace("#","");if(this.#P("#"+Z),this.#j)this.#j.setAttribute("value",this.#Z);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#b()}#g(Q){Q.stopPropagation();let Z=Number(Q.target.value)||0,J=Math.round(Z/100*255).toString(16).padStart(2,"0");if(this.#P(this.hexOpaque+J),this.#Q)this.#Q.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));this.#b()}#V(Q){Q.stopPropagation(),this.#x()}focus(){if(this.#$){this.#$.focus();return}this.#Q?.focus()}#y(){return this.getAttribute("aria-label")||"Color"}#w(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#m)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let Q=this.getAttribute("aria-describedby"),Z=this.getAttribute("aria-invalid"),$=this.getAttribute("aria-required"),J=this.getAttribute("aria-labelledby"),j=this.#y();if(this.#$){if(this.#$.setAttribute("aria-label",`${j} hex color`),Q)this.#$.setAttribute("aria-describedby",Q);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.#j){if(this.#j.setAttribute("aria-label",`${j} opacity`),Q)this.#j.setAttribute("aria-describedby",Q);else this.#j.removeAttribute("aria-describedby");if(Z)this.#j.setAttribute("aria-invalid",Z);else this.#j.removeAttribute("aria-invalid");if($)this.#j.setAttribute("aria-required",$);else this.#j.removeAttribute("aria-required")}if(!this.#$){let _=this.#Q?.querySelector('input[type="color"]');if(!_)return;if(J)_.setAttribute("aria-labelledby",J),_.removeAttribute("aria-label");else _.setAttribute("aria-label",j),_.removeAttribute("aria-labelledby");if(Q)_.setAttribute("aria-describedby",Q);else _.removeAttribute("aria-describedby")}}#v(Q){if(Q.stopPropagation(),this.#P(Q.target.value),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#b()}#h(Q){Q.stopPropagation();let Z=Q.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.#P($),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j&&Z.alpha!==void 0)this.#j.setAttribute("value",Math.round(Z.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#b()}}#b(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#x(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}static get observedAttributes(){return["value","style","mode","experimental","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(Q){this.setAttribute("mode",Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":if(this.#P($),this.#$)this.#$.setAttribute("value",this.value);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));if(this.#j)this.#j.setAttribute("value",this.#Z);break;case"mode":this.#F();break;case"alpha":case"text":if(this.isConnected)this.#R();break;case"disabled":this.#u();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#w();break}}get#m(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#u(){let Q=this.#m;for(let Z of[this.#Q,this.#$,this.#j]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}if(this.#w(),this.#J)this.#F()}rgbAlphaToHex({r:Q,g:Z,b:$},J=1){Q=Math.max(0,Math.min(255,Math.round(Q))),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 j=Q.toString(16).padStart(2,"0"),_=Z.toString(16).padStart(2,"0"),q=$.toString(16).padStart(2,"0");if(J===1)return`#${j}${_}${q}`.toUpperCase();let X=Math.round(J*255).toString(16).padStart(2,"0");return`#${j}${_}${q}${X}`.toUpperCase()}convertToRGBA(Q){let Z,$,J,j=1;if(Q.startsWith("#")){let _=Q.slice(1);if(_.length===8)j=parseInt(_.slice(6),16)/255,_=_.slice(0,6);Z=parseInt(_.slice(0,2),16),$=parseInt(_.slice(2,4),16),J=parseInt(_.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let _=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(_)Z=parseInt(_[1]),$=parseInt(_[2]),J=parseInt(_[3]),j=_[4]?parseFloat(_[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let _=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(_){let q=parseInt(_[1])/360,G=parseInt(_[2])/100,X=parseInt(_[3])/100;if(j=_[4]?parseFloat(_[4]):1,G===0)Z=$=J=X;else{let K=(L,A,U)=>{if(U<0)U+=1;if(U>1)U-=1;if(U<0.16666666666666666)return L+(A-L)*6*U;if(U<0.5)return A;if(U<0.6666666666666666)return L+(A-L)*(0.6666666666666666-U)*6;return L},N=X<0.5?X*(1+G):X+G-X*G,B=2*X-N;Z=K(B,N,q+0.3333333333333333),$=K(B,N,q),J=K(B,N,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:j}}}customElements.define("fig-input-color",g0);var P1=["srgb","srgb-linear","display-p3","oklab","oklch"],E1=["shorter","longer","increasing","decreasing"];function r(Q){let Z={...Q??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase();if(!P1.includes($))$="srgb";Z.interpolationSpace=$;let J=String(Z.hueInterpolation??"shorter").toLowerCase();return Z.hueInterpolation=E1.includes(J)?J:"shorter",Z}function b0(Q){let Z=r(Q),$={...Z,interpolationSpace:Z.interpolationSpace};if(Z.interpolationSpace==="oklch")$.hueInterpolation=Z.hueInterpolation;else delete $.hueInterpolation;return $}function v0(Q){let Z=r(Q);if(Z.interpolationSpace==="srgb")return"";if(Z.interpolationSpace==="oklch")return`in oklch ${Z.hueInterpolation} hue`;return`in ${Z.interpolationSpace}`}function c(Q){let Z=Q.replace(/^#/,"");return{r:parseInt(Z.substring(0,2),16),g:parseInt(Z.substring(2,4),16),b:parseInt(Z.substring(4,6),16)}}function h(Q){let Z=Q/255;return Z<=0.04045?Z/12.92:Math.pow((Z+0.055)/1.055,2.4)}function p(Q){let Z=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Z))*255)}function t(Q,Z,$){let J=h(Q),j=h(Z),_=h($),q=Math.cbrt(0.4122214708*J+0.5363325363*j+0.0514459929*_),G=Math.cbrt(0.2119034982*J+0.6806995451*j+0.1073969566*_),X=Math.cbrt(0.0883024619*J+0.2817188376*j+0.6299787005*_);return{l:0.2104542553*q+0.793617785*G-0.0040720468*X,a:1.9779984951*q-2.428592205*G+0.4505937099*X,b:0.0259040371*q+0.7827717662*G-0.808675766*X}}function M0(Q,Z,$){let J=Q+0.3963377774*Z+0.2158037573*$,j=Q-0.1055613458*Z-0.0638541728*$,_=Q-0.0894841775*Z-1.291485548*$,q=J*J*J,G=j*j*j,X=_*_*_;return{r:p(4.0767416621*q-3.3077115913*G+0.2309699292*X),g:p(-1.2684380046*q+2.6097574011*G-0.3413193965*X),b:p(-0.0041960863*q-0.7034186147*G+1.707614701*X)}}function O0(Q,Z,$){return{l:Q,c:Math.sqrt(Z*Z+$*$),h:Math.atan2($,Z)*180/Math.PI}}function C1(Q,Z,$){let J=$*Math.PI/180;return{l:Q,a:Z*Math.cos(J),b:Z*Math.sin(J)}}function S1(Q,Z,$,J){let j=(Q%360+360)%360,q=(Z%360+360)%360-j;switch(J){case"longer":if(q>0&&q<180)q-=360;else if(q<0&&q>-180)q+=360;else if(q===0)q=0;break;case"increasing":if(q<0)q+=360;break;case"decreasing":if(q>0)q-=360;break;default:if(q>180)q-=360;else if(q<-180)q+=360;break}return((j+q*$)%360+360)%360}function k1(Q,Z,$,J){let j=[...Q].sort((z,M)=>z.position-M.position),_=Z*100;if(j.length===0)return"#888888";if(_<=j[0].position)return j[0].color;if(_>=j[j.length-1].position)return j[j.length-1].color;let q=0;while(q<j.length-1&&j[q+1].position<_)q++;let G=j[q],X=j[q+1],K=X.position-G.position,N=K>0?(_-G.position)/K:0,B=c(G.color),L=c(X.color),A,U,W,R=$||"oklab";if(R==="srgb-linear"){let z=h(B.r),M=h(B.g),O=h(B.b),T=h(L.r),C=h(L.g),k=h(L.b);A=p(z+(T-z)*N),U=p(M+(C-M)*N),W=p(O+(k-O)*N)}else if(R==="oklch"){let z=t(B.r,B.g,B.b),M=t(L.r,L.g,L.b),O=O0(z.l,z.a,z.b),T=O0(M.l,M.a,M.b),C=O.l+(T.l-O.l)*N,k=O.c+(T.c-O.c)*N,I=S1(O.h,T.h,N,J||"shorter"),S=C1(C,k,I),w=M0(S.l,S.a,S.b);A=w.r,U=w.g,W=w.b}else{let z=t(B.r,B.g,B.b),M=t(L.r,L.g,L.b),O=z.l+(M.l-z.l)*N,T=z.a+(M.a-z.a)*N,C=z.b+(M.b-z.b)*N,k=M0(O,T,C);A=k.r,U=k.g,W=k.b}return`#${A.toString(16).padStart(2,"0")}${U.toString(16).padStart(2,"0")}${W.toString(16).padStart(2,"0")}`.toUpperCase()}class h0 extends HTMLElement{#Z="solid";#Q;#J;#$;#j={color:"#D9D9D9",alpha:1};#q={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#_={url:null,scaleMode:"fill",scale:50,opacity:1};#G={url:null,scaleMode:"fill",opacity:1};#X={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","experimental","alpha","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#W(),this.#O()}disconnectedCallback(){this.#Q=null,this.#J=null,this.#$=null}#W(){let Q=this.getAttribute("value");if(!Q)return;try{let Z=JSON.parse(Q);if(Z.type)this.#Z=Z.type;switch(this.#Z){case"solid":if(Z.color)this.#j.color=Z.color;if(Z.alpha!==void 0)this.#j.alpha=Z.alpha;if(Z.opacity!==void 0)this.#j.alpha=Z.opacity/100;break;case"gradient":if(Z.gradient)this.#q=r({...this.#q,...Z.gradient});break;case"image":if(Z.image)this.#_={...this.#_,...Z.image};break;case"video":if(Z.video)this.#G={...this.#G,...Z.video};break;case"webcam":if(Z.webcam)this.#X={...this.#X,...Z.webcam};if(Z.opacity!==void 0)this.#X.opacity=Z.opacity;break}}catch(Z){if(Q.startsWith("#")){if(this.#Z="solid",this.#j.color=Q.slice(0,7),Q.length>7){let $=Q.slice(7,9);this.#j.alpha=parseInt($,16)/255}}}}#Y(){let Q={},Z=this.getAttribute("mode");if(Z)Q.mode=Z;let $=this.getAttribute("experimental");if($)Q.experimental=$;let J=this.getAttribute("alpha");if(J)Q.alpha=J;for(let{name:j,value:_}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor")Q[j.slice(7)]=_;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([j,_])=>`${j}="${_}"`).join(" ")}#K(){switch(this.#Z){case"solid":return this.#j.color;case"gradient":{let Z=[...this.#q.stops].sort(($,J)=>$.position-J.position).map(($)=>{let J=($.opacity??100)/100;if(J>=1)return`${$.color} ${$.position}%`;let{r:j,g:_,b:q}=c($.color);return`rgba(${j}, ${_}, ${q}, ${J}) ${$.position}%`}).join(", ");return`linear-gradient(${this.#q.angle}deg ${v0(this.#q)}, ${Z})`}case"image":return this.#_.url?`url(${this.#_.url})`:"#D9D9D9";default:return"#D9D9D9"}}#U(){switch(this.#Z){case"solid":return this.#j.alpha;case"image":return this.#_.opacity??1;case"video":return this.#G.opacity??1;case"webcam":return this.#X.opacity??1;default:return 1}}#N(){let Q=this.hasAttribute("disabled");this.setAttribute("aria-disabled",Q?"true":"false");for(let Z of[this.#Q,this.#J,this.#$]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}#L(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#N();let Q=this.getAttribute("aria-label")||"Fill",Z=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),j=(_,q)=>{if(!_)return;if(_.setAttribute("aria-label",q),Z)_.setAttribute("aria-describedby",Z);else _.removeAttribute("aria-describedby");if($)_.setAttribute("aria-invalid",$);else _.removeAttribute("aria-invalid");if(J)_.setAttribute("aria-required",J);else _.removeAttribute("aria-required")};j(this.#Q,`${Q} picker`),j(this.#$,`${Q} hex color`),j(this.#J,`${Q} opacity`)}#O(){let Q=this.hasAttribute("disabled"),Z=JSON.stringify(this.value),$=this.getAttribute("alpha")!=="false",J=(q)=>$?`<fig-tooltip text="Opacity">
78
+ </div>`}else J=`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${$}></fig-chit>`;if(this.innerHTML=J,this.#Q=this.querySelector("fig-chit"),this.#J=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#j=this.querySelector("fig-input-number"),this.#V(),this.#$){let _=this.rgbAlphaToHex(this.rgba,1);if(this.#$.value=_.slice(1).toUpperCase(),this.#Q)this.#Q.background=_}this.#z()}#D(){if(!this.#J)return;for(let[Q,Z]of Object.entries(this.#B()))this.#J.setAttribute(Q,Z);if(this.#J.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#J.removeAttribute("alpha");else this.#J.setAttribute("alpha","false");if(this.hasAttribute("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}))}#E(){if(!u())return null;if(this.#J?.isConnected)return this.#D(),this.#J;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#h.bind(this)),Q.addEventListener("change",this.#w.bind(this)),this.appendChild(Q),this.#J=Q,this.#D(),Q}#C(){if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return!1;let Q=this.#E();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#R(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#f(Q){if(!u())return;if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return;if(this.#_=!0,this.#q=!0,this.#G)clearTimeout(this.#G);this.#G=setTimeout(()=>{this.#q=!1,this.#_=!1,this.#G=null},500),this.#R(Q)}#S(Q){if(!this.#q)return;if(this.#q=!1,this.#G)clearTimeout(this.#G),this.#G=null;if(this.#R(Q),this.#_)this.#_=!1,this.#C()}#k(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!u())return;if(!this.#C())return;this.#R(Q)}#T(Q){let Z=Q||"#D9D9D9";this.rgba=this.convertToRGBA(Z),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)}#x(Q){Q.stopPropagation();let Z=Q.target.value.replace("#","");if(this.#T("#"+Z),this.#j)this.#j.setAttribute("value",this.#Z);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#v()}#g(Q){Q.stopPropagation();let Z=Number(Q.target.value)||0,J=Math.round(Z/100*255).toString(16).padStart(2,"0");if(this.#T(this.hexOpaque+J),this.#Q)this.#Q.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));this.#v()}#w(Q){Q.stopPropagation(),this.#b()}focus(){if(this.#$){this.#$.focus();return}this.#Q?.focus()}#I(){return this.getAttribute("aria-label")||"Color"}#V(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#p)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let Q=this.getAttribute("aria-describedby"),Z=this.getAttribute("aria-invalid"),$=this.getAttribute("aria-required"),J=this.getAttribute("aria-labelledby"),j=this.#I();if(this.#$){if(this.#$.setAttribute("aria-label",`${j} hex color`),Q)this.#$.setAttribute("aria-describedby",Q);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.#j){if(this.#j.setAttribute("aria-label",`${j} opacity`),Q)this.#j.setAttribute("aria-describedby",Q);else this.#j.removeAttribute("aria-describedby");if(Z)this.#j.setAttribute("aria-invalid",Z);else this.#j.removeAttribute("aria-invalid");if($)this.#j.setAttribute("aria-required",$);else this.#j.removeAttribute("aria-required")}if(!this.#$){let _=this.#Q?.querySelector('input[type="color"]');if(!_)return;if(J)_.setAttribute("aria-labelledby",J),_.removeAttribute("aria-label");else _.setAttribute("aria-label",j),_.removeAttribute("aria-labelledby");if(Q)_.setAttribute("aria-describedby",Q);else _.removeAttribute("aria-describedby")}}#y(Q){if(Q.stopPropagation(),this.#T(Q.target.value),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#v()}#h(Q){Q.stopPropagation();let Z=Q.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.#T($),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j&&Z.alpha!==void 0)this.#j.setAttribute("value",Math.round(Z.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#v()}}#v(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#b(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}static get observedAttributes(){return["value","style","mode","experimental","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(Q){this.setAttribute("mode",Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":if(this.#T($),this.#$)this.#$.setAttribute("value",this.value);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));if(this.#j)this.#j.setAttribute("value",this.#Z);break;case"mode":this.#D();break;case"alpha":case"text":if(this.isConnected)this.#P();break;case"disabled":this.#m();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#V();break}}get#p(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#m(){let Q=this.#p;for(let Z of[this.#Q,this.#$,this.#j]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}if(this.#V(),this.#J)this.#D()}rgbAlphaToHex({r:Q,g:Z,b:$},J=1){Q=Math.max(0,Math.min(255,Math.round(Q))),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 j=Q.toString(16).padStart(2,"0"),_=Z.toString(16).padStart(2,"0"),q=$.toString(16).padStart(2,"0");if(J===1)return`#${j}${_}${q}`.toUpperCase();let X=Math.round(J*255).toString(16).padStart(2,"0");return`#${j}${_}${q}${X}`.toUpperCase()}convertToRGBA(Q){let Z,$,J,j=1;if(Q.startsWith("#")){let _=Q.slice(1);if(_.length===8)j=parseInt(_.slice(6),16)/255,_=_.slice(0,6);Z=parseInt(_.slice(0,2),16),$=parseInt(_.slice(2,4),16),J=parseInt(_.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let _=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(_)Z=parseInt(_[1]),$=parseInt(_[2]),J=parseInt(_[3]),j=_[4]?parseFloat(_[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let _=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(_){let q=parseInt(_[1])/360,G=parseInt(_[2])/100,X=parseInt(_[3])/100;if(j=_[4]?parseFloat(_[4]):1,G===0)Z=$=J=X;else{let K=(L,z,U)=>{if(U<0)U+=1;if(U>1)U-=1;if(U<0.16666666666666666)return L+(z-L)*6*U;if(U<0.5)return z;if(U<0.6666666666666666)return L+(z-L)*(0.6666666666666666-U)*6;return L},N=X<0.5?X*(1+G):X+G-X*G,M=2*X-N;Z=K(M,N,q+0.3333333333333333),$=K(M,N,q),J=K(M,N,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:j}}}customElements.define("fig-input-color",m0);var f1=["srgb","srgb-linear","display-p3","oklab","oklch"],I1=["shorter","longer","increasing","decreasing"];function r(Q){let Z={...Q??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase();if(!f1.includes($))$="srgb";Z.interpolationSpace=$;let J=String(Z.hueInterpolation??"shorter").toLowerCase();return Z.hueInterpolation=I1.includes(J)?J:"shorter",Z}function u0(Q){let Z=r(Q),$={...Z,interpolationSpace:Z.interpolationSpace};if(Z.interpolationSpace==="oklch")$.hueInterpolation=Z.hueInterpolation;else delete $.hueInterpolation;return $}function p0(Q){let Z=r(Q);if(Z.interpolationSpace==="srgb")return"";if(Z.interpolationSpace==="oklch")return`in oklch ${Z.hueInterpolation} hue`;return`in ${Z.interpolationSpace}`}function c(Q){let Z=Q.replace(/^#/,"");return{r:parseInt(Z.substring(0,2),16),g:parseInt(Z.substring(2,4),16),b:parseInt(Z.substring(4,6),16)}}function h(Q){let Z=Q/255;return Z<=0.04045?Z/12.92:Math.pow((Z+0.055)/1.055,2.4)}function p(Q){let Z=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Z))*255)}function t(Q,Z,$){let J=h(Q),j=h(Z),_=h($),q=Math.cbrt(0.4122214708*J+0.5363325363*j+0.0514459929*_),G=Math.cbrt(0.2119034982*J+0.6806995451*j+0.1073969566*_),X=Math.cbrt(0.0883024619*J+0.2817188376*j+0.6299787005*_);return{l:0.2104542553*q+0.793617785*G-0.0040720468*X,a:1.9779984951*q-2.428592205*G+0.4505937099*X,b:0.0259040371*q+0.7827717662*G-0.808675766*X}}function A0(Q,Z,$){let J=Q+0.3963377774*Z+0.2158037573*$,j=Q-0.1055613458*Z-0.0638541728*$,_=Q-0.0894841775*Z-1.291485548*$,q=J*J*J,G=j*j*j,X=_*_*_;return{r:p(4.0767416621*q-3.3077115913*G+0.2309699292*X),g:p(-1.2684380046*q+2.6097574011*G-0.3413193965*X),b:p(-0.0041960863*q-0.7034186147*G+1.707614701*X)}}function H0(Q,Z,$){return{l:Q,c:Math.sqrt(Z*Z+$*$),h:Math.atan2($,Z)*180/Math.PI}}function x1(Q,Z,$){let J=$*Math.PI/180;return{l:Q,a:Z*Math.cos(J),b:Z*Math.sin(J)}}function V1(Q,Z,$,J){let j=(Q%360+360)%360,q=(Z%360+360)%360-j;switch(J){case"longer":if(q>0&&q<180)q-=360;else if(q<0&&q>-180)q+=360;else if(q===0)q=0;break;case"increasing":if(q<0)q+=360;break;case"decreasing":if(q>0)q-=360;break;default:if(q>180)q-=360;else if(q<-180)q+=360;break}return((j+q*$)%360+360)%360}function y1(Q,Z,$,J){let j=[...Q].sort((H,B)=>H.position-B.position),_=Z*100;if(j.length===0)return"#888888";if(_<=j[0].position)return j[0].color;if(_>=j[j.length-1].position)return j[j.length-1].color;let q=0;while(q<j.length-1&&j[q+1].position<_)q++;let G=j[q],X=j[q+1],K=X.position-G.position,N=K>0?(_-G.position)/K:0,M=c(G.color),L=c(X.color),z,U,W,R=$||"oklab";if(R==="srgb-linear"){let H=h(M.r),B=h(M.g),O=h(M.b),T=h(L.r),C=h(L.g),k=h(L.b);z=p(H+(T-H)*N),U=p(B+(C-B)*N),W=p(O+(k-O)*N)}else if(R==="oklch"){let H=t(M.r,M.g,M.b),B=t(L.r,L.g,L.b),O=H0(H.l,H.a,H.b),T=H0(B.l,B.a,B.b),C=O.l+(T.l-O.l)*N,k=O.c+(T.c-O.c)*N,I=V1(O.h,T.h,N,J||"shorter"),S=x1(C,k,I),w=A0(S.l,S.a,S.b);z=w.r,U=w.g,W=w.b}else{let H=t(M.r,M.g,M.b),B=t(L.r,L.g,L.b),O=H.l+(B.l-H.l)*N,T=H.a+(B.a-H.a)*N,C=H.b+(B.b-H.b)*N,k=A0(O,T,C);z=k.r,U=k.g,W=k.b}return`#${z.toString(16).padStart(2,"0")}${U.toString(16).padStart(2,"0")}${W.toString(16).padStart(2,"0")}`.toUpperCase()}class c0 extends HTMLElement{#Z="solid";#Q;#J;#$;#j={color:"#D9D9D9",alpha:1};#q={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#_={url:null,scaleMode:"fill",scale:50,opacity:1};#G={url:null,scaleMode:"fill",opacity:1};#X={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","experimental","alpha","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#W(),this.#H()}disconnectedCallback(){this.#Q=null,this.#J=null,this.#$=null}#W(){let Q=this.getAttribute("value");if(!Q)return;try{let Z=JSON.parse(Q);if(Z.type)this.#Z=Z.type;switch(this.#Z){case"solid":if(Z.color)this.#j.color=Z.color;if(Z.alpha!==void 0)this.#j.alpha=Z.alpha;if(Z.opacity!==void 0)this.#j.alpha=Z.opacity/100;break;case"gradient":if(Z.gradient)this.#q=r({...this.#q,...Z.gradient});break;case"image":if(Z.image)this.#_={...this.#_,...Z.image};break;case"video":if(Z.video)this.#G={...this.#G,...Z.video};break;case"webcam":if(Z.webcam)this.#X={...this.#X,...Z.webcam};if(Z.opacity!==void 0)this.#X.opacity=Z.opacity;break}}catch(Z){if(Q.startsWith("#")){if(this.#Z="solid",this.#j.color=Q.slice(0,7),Q.length>7){let $=Q.slice(7,9);this.#j.alpha=parseInt($,16)/255}}}}#Y(){let Q={},Z=this.getAttribute("mode");if(Z)Q.mode=Z;let $=this.getAttribute("experimental");if($)Q.experimental=$;let J=this.getAttribute("alpha");if(J)Q.alpha=J;for(let{name:j,value:_}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor")Q[j.slice(7)]=_;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([j,_])=>`${j}="${_}"`).join(" ")}#K(){switch(this.#Z){case"solid":return this.#j.color;case"gradient":{let Z=[...this.#q.stops].sort(($,J)=>$.position-J.position).map(($)=>{let J=($.opacity??100)/100;if(J>=1)return`${$.color} ${$.position}%`;let{r:j,g:_,b:q}=c($.color);return`rgba(${j}, ${_}, ${q}, ${J}) ${$.position}%`}).join(", ");return`linear-gradient(${this.#q.angle}deg ${p0(this.#q)}, ${Z})`}case"image":return this.#_.url?`url(${this.#_.url})`:"#D9D9D9";default:return"#D9D9D9"}}#U(){switch(this.#Z){case"solid":return this.#j.alpha;case"image":return this.#_.opacity??1;case"video":return this.#G.opacity??1;case"webcam":return this.#X.opacity??1;default:return 1}}#N(){let Q=this.hasAttribute("disabled");this.setAttribute("aria-disabled",Q?"true":"false");for(let Z of[this.#Q,this.#J,this.#$]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}#L(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#N();let Q=this.getAttribute("aria-label")||"Fill",Z=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),j=(_,q)=>{if(!_)return;if(_.setAttribute("aria-label",q),Z)_.setAttribute("aria-describedby",Z);else _.removeAttribute("aria-describedby");if($)_.setAttribute("aria-invalid",$);else _.removeAttribute("aria-invalid");if(J)_.setAttribute("aria-required",J);else _.removeAttribute("aria-required")};j(this.#Q,`${Q} picker`),j(this.#$,`${Q} hex color`),j(this.#J,`${Q} opacity`)}#H(){let Q=this.hasAttribute("disabled"),Z=JSON.stringify(this.value),$=this.getAttribute("alpha")!=="false",J=(q)=>$?`<fig-tooltip text="Opacity">
89
79
  <fig-input-number
90
80
  class="fig-input-fill-opacity"
91
81
  placeholder="##"
@@ -117,7 +107,7 @@ var A1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var F1={};var L0=A1(()=>{/*! Vendored from @
117
107
  <fig-chit background="${this.#K()}" alpha="${this.#U()}"${Q?" disabled":""}></fig-chit>
118
108
  </fig-fill-picker>
119
109
  ${j}
120
- </div>`,this.#B()}#B(){this.#Q=this.querySelector("fig-fill-picker"),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.#L(),Q&&this.#Q)Q.addEventListener("click",()=>{let Z=this.#Q.querySelector("fig-chit");if(Z)Z.click()});if(this.#Q){let Z=this.getAttribute("picker-anchor");if(!Z||Z==="self")this.#Q.anchorElement=this;else{let $=document.querySelector(Z);if($)this.#Q.anchorElement=$}this.#Q.addEventListener("input",($)=>{$.stopPropagation();let J=$.detail;if(!J)return;let j=J.type,_=j!==this.#Z;switch(this.#Z=j,j){case"solid":this.#j.color=J.color,this.#j.alpha=J.alpha;break;case"gradient":if(J.gradient)this.#q=r({...this.#q,...J.gradient});break;case"image":if(J.image)this.#_=J.image;break;case"video":if(J.video)this.#G=J.video;break}if(_)this.#z();else this.#M();this.#H()}),this.#Q.addEventListener("change",($)=>{$.stopPropagation(),this.#R()})}if(this.#$)this.#$.addEventListener("input",(Z)=>{Z.stopPropagation();let $="#"+Z.target.value.replace("#","");this.#j.color=$,this.#A(),this.#H()}),this.#$.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#R()});if(this.#J)this.#J.addEventListener("input",(Z)=>{Z.stopPropagation();let $=parseFloat(Z.target.value),j=(isNaN($)?100:$)/100;switch(this.#Z){case"solid":this.#j.alpha=j;break;case"gradient":break;case"image":this.#_.opacity=j;break;case"video":this.#G.opacity=j;break;case"webcam":this.#X.opacity=j;break}this.#A(),this.#D(j),this.#H()}),this.#J.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#R()})}#M(){switch(this.#Z){case"solid":if(this.#$)this.#$.setAttribute("value",this.#j.color.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",Math.round(this.#j.alpha*100));break;case"gradient":{let Q=this.querySelector(".fig-input-fill-label");if(Q){let Z=this.#q.type.charAt(0).toUpperCase()+this.#q.type.slice(1);Q.textContent=Z}break}case"image":if(this.#J)this.#J.setAttribute("value",Math.round((this.#_.opacity??1)*100));break;case"video":if(this.#J)this.#J.setAttribute("value",Math.round((this.#G.opacity??1)*100));break;case"webcam":if(this.#J)this.#J.setAttribute("value",Math.round((this.#X.opacity??1)*100));break}}#z(){let Q=this.hasAttribute("disabled"),Z=this.querySelector(".input-combo");if(!Z)return;let $=Z.querySelector(".fig-input-fill-label"),J=Z.querySelector(".fig-input-fill-hex"),j=Z.querySelector(".fig-input-fill-opacity"),_=Z.querySelectorAll("fig-tooltip");$?.remove(),J?.remove(),_.forEach((X)=>X.remove());let q="";switch(this.#Z){case"solid":q=`
110
+ </div>`,this.#B()}#B(){this.#Q=this.querySelector("fig-fill-picker"),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.#L(),Q&&this.#Q)Q.addEventListener("click",()=>{let Z=this.#Q.querySelector("fig-chit");if(Z)Z.click()});if(this.#Q){let Z=this.getAttribute("picker-anchor");if(!Z||Z==="self")this.#Q.anchorElement=this;else{let $=document.querySelector(Z);if($)this.#Q.anchorElement=$}this.#Q.addEventListener("input",($)=>{$.stopPropagation();let J=$.detail;if(!J)return;let j=J.type,_=j!==this.#Z;switch(this.#Z=j,j){case"solid":this.#j.color=J.color,this.#j.alpha=J.alpha;break;case"gradient":if(J.gradient)this.#q=r({...this.#q,...J.gradient});break;case"image":if(J.image)this.#_=J.image;break;case"video":if(J.video)this.#G=J.video;break}if(_)this.#F();else this.#M();this.#z()}),this.#Q.addEventListener("change",($)=>{$.stopPropagation(),this.#P()})}if(this.#$)this.#$.addEventListener("input",(Z)=>{Z.stopPropagation();let $="#"+Z.target.value.replace("#","");this.#j.color=$,this.#O(),this.#z()}),this.#$.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#P()});if(this.#J)this.#J.addEventListener("input",(Z)=>{Z.stopPropagation();let $=parseFloat(Z.target.value),j=(isNaN($)?100:$)/100;switch(this.#Z){case"solid":this.#j.alpha=j;break;case"gradient":break;case"image":this.#_.opacity=j;break;case"video":this.#G.opacity=j;break;case"webcam":this.#X.opacity=j;break}this.#O(),this.#A(j),this.#z()}),this.#J.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#P()})}#M(){switch(this.#Z){case"solid":if(this.#$)this.#$.setAttribute("value",this.#j.color.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",Math.round(this.#j.alpha*100));break;case"gradient":{let Q=this.querySelector(".fig-input-fill-label");if(Q){let Z=this.#q.type.charAt(0).toUpperCase()+this.#q.type.slice(1);Q.textContent=Z}break}case"image":if(this.#J)this.#J.setAttribute("value",Math.round((this.#_.opacity??1)*100));break;case"video":if(this.#J)this.#J.setAttribute("value",Math.round((this.#G.opacity??1)*100));break;case"webcam":if(this.#J)this.#J.setAttribute("value",Math.round((this.#X.opacity??1)*100));break}}#F(){let Q=this.hasAttribute("disabled"),Z=this.querySelector(".input-combo");if(!Z)return;let $=Z.querySelector(".fig-input-fill-label"),J=Z.querySelector(".fig-input-fill-hex"),j=Z.querySelector(".fig-input-fill-opacity"),_=Z.querySelectorAll("fig-tooltip");$?.remove(),J?.remove(),_.forEach((X)=>X.remove());let q="";switch(this.#Z){case"solid":q=`
121
111
  <fig-input-text
122
112
  type="text"
123
113
  class="fig-input-fill-hex"
@@ -183,12 +173,12 @@ var A1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var F1={};var L0=A1(()=>{/*! Vendored from @
183
173
  units="%"
184
174
  ${Q?"disabled":""}>
185
175
  </fig-input-number>
186
- </fig-tooltip>`;break}Z.insertAdjacentHTML("beforeend",q),this.#J=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let G=this.querySelector(".fig-input-fill-label");if(this.#L(),G&&this.#Q)G.addEventListener("click",()=>{let X=this.#Q.querySelector("fig-chit");if(X)X.click()});if(this.#$)this.#$.addEventListener("input",(X)=>{X.stopPropagation();let K="#"+X.target.value.replace("#","");this.#j.color=K,this.#A(),this.#H()}),this.#$.addEventListener("change",(X)=>{X.stopPropagation(),this.#R()});if(this.#J)this.#J.addEventListener("input",(X)=>{X.stopPropagation();let K=parseFloat(X.target.value),B=(isNaN(K)?100:K)/100;switch(this.#Z){case"solid":this.#j.alpha=B;break;case"gradient":break;case"image":this.#_.opacity=B;break;case"video":this.#G.opacity=B;break;case"webcam":this.#X.opacity=B;break}this.#A(),this.#D(B),this.#H()}),this.#J.addEventListener("change",(X)=>{X.stopPropagation(),this.#R()})}#A(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#D(Q){if(this.#Q){let Z=this.#Q.querySelector("fig-chit");if(Z)Z.setAttribute("alpha",Q)}}#H(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#Z){case"solid":return{type:"solid",color:this.#j.color,alpha:this.#j.alpha,opacity:Math.round(this.#j.alpha*100)};case"gradient":return{type:"gradient",gradient:b0(this.#q)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#G}};case"webcam":return{type:"webcam",webcam:{...this.#X}};default:return{type:this.#Z}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":let J=this.#Z;if(this.#W(),this.#Q)if(this.#Z!==J)this.#O();else this.#A(),this.#M();break;case"disabled":this.#N();break;case"mode":case"experimental":if(this.#Q)if($)this.#Q.setAttribute(Q,$);else this.#Q.removeAttribute(Q);break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#L();break}}}customElements.define("fig-input-fill",h0);class m0 extends HTMLElement{#Z=[];#Q=[];#J=[];#$=null;#j=this.#X.bind(this);static get observedAttributes(){return["value","disabled","min","max","open","fixed"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){let Z=this.open;if(Q)this.setAttribute("open","");else this.removeAttribute("open");if(Z!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}get#q(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#_(){let Q=parseInt(this.getAttribute("min"));return isNaN(Q)?2:Q}get#G(){let Q=parseInt(this.getAttribute("max"));return isNaN(Q)?8:Q}connectedCallback(){if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.removeEventListener("keydown",this.#j),this.addEventListener("keydown",this.#j),this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{if(this.#$=null,!this.isConnected)return;this.#W(),this.#Y()})}disconnectedCallback(){if(this.#$)cancelAnimationFrame(this.#$),this.#$=null;this.removeEventListener("keydown",this.#j),this.#Q=[],this.#J=[]}#X(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target!==this&&!Q.target?.closest?.(".palette-colors-inline"))return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.preventDefault(),Q.stopPropagation(),this.open=!0,this.querySelector(".palette-colors-inline")?.setAttribute("aria-expanded","true")}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":this.#W(),this.#M();break;case"disabled":this.#z();break;case"min":case"max":case"fixed":this.#Y();break;case"open":break}}#W(){let Q=this.getAttribute("value");if(!Q){this.#Z=[];return}let Z=Q.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((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#Y(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#J=[];let Z=document.createElement("div");Z.className="palette-colors-inline",Z.setAttribute("role","button"),Z.setAttribute("aria-expanded",String(this.open)),Z.setAttribute("aria-label","Edit palette colors");let $=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0,Z.setAttribute("aria-expanded","true")};Z.addEventListener("click",$),Z.addEventListener("keydown",(_)=>{if(_.key!=="Enter"&&_.key!==" ")return;_.preventDefault(),_.stopPropagation(),$()});let J=document.createElement("div");if(J.className="palette-colors",this.#Z.forEach((_,q)=>{J.appendChild(this.#K(_,q,Q,{inline:!0}))}),Z.appendChild(J),this.appendChild(Z),!this.#q)this.#L(Q,this);let j=document.createElement("div");j.className="palette-colors-expanded",this.#Z.forEach((_,q)=>{if(j.appendChild(this.#K(_,q,Q)),!this.#q)j.appendChild(this.#U(q,Q))}),this.appendChild(j)}#K(Q,Z,$,{inline:J=!1}={}){let j=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,_=document.createElement("fig-input-color");if(_.setAttribute("value",j),J)_.setAttribute("text","false"),_.setAttribute("alpha","true"),_.setAttribute("swatch-disabled","");else _.setAttribute("text","true"),_.setAttribute("alpha","true"),_.setAttribute("full","");if($)_.setAttribute("disabled","");let q=J?this.#J:this.#Q,G=(X)=>{X.stopPropagation();let K=X.currentTarget;this.#Z[Z]={color:K.hexOpaque||this.#Z[Z].color,alpha:K.rgba?K.rgba.a:this.#Z[Z].alpha};let N=q[Z];if(N){let B=this.#Z[Z],L=B.alpha<1?B.color+Math.round(B.alpha*255).toString(16).padStart(2,"0"):B.color;N.setAttribute("value",L)}};if(_.addEventListener("input",(X)=>{G(X),this.#D()}),_.addEventListener("change",(X)=>{G(X),this.#H()}),J)this.#Q.push(_);else this.#J.push(_);return _}#U(Q,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.#_)$.setAttribute("disabled","");$.appendChild(v("minus")),$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#N(Q)});let J=document.createElement("fig-tooltip");return J.setAttribute("text","Remove color"),J.appendChild($),J}#N(Q){if(this.#q)return;if(Q<0||Q>=this.#Z.length)return;if(this.#Z.length<=this.#_)return;this.#Z.splice(Q,1),this.#Q=[],this.#J=[],this.#Y(),this.#H()}#L(Q,Z=this){let $=this.#Z.length>=this.#G,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",Q||$)J.setAttribute("disabled","");J.appendChild(v("add")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Z.length>=this.#G)return;this.open=!0,this.#O({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(J),Z.appendChild(j)}#O(Q){if(this.#q)return;this.#Z.push(Q);let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#Z.length-1,J=this.#K(Q,$,Z,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(J);let _=this.#K(Q,$,Z),q=this.querySelector(".palette-colors-expanded");if(q)q.appendChild(_),q.appendChild(this.#U($,Z));if(this.#Z.length>=this.#G){let G=this.querySelector(".palette-add-btn");if(G)G.setAttribute("disabled","")}this.#A(Z),this.#H()}#B(Q){let Z=this.#Z[Q];if(!Z)return;let $=Z.alpha<1?Z.color+Math.round(Z.alpha*255).toString(16).padStart(2,"0"):Z.color,J=this.#Q[Q];if(J)J.setAttribute("value",$);let j=this.#J[Q];if(j)j.setAttribute("value",$)}#M(){if(this.#Q.length!==this.#Z.length){this.#Y();return}this.#Z.forEach((Q,Z)=>{this.#B(Z)})}#z(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#J].forEach(($)=>{if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")});let Z=this.querySelector(".palette-add-btn");if(Z)if(Q||this.#Z.length>=this.#G)Z.setAttribute("disabled","");else Z.removeAttribute("disabled");this.#A(Q)}#A(Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let Z=Q||this.#Z.length<=this.#_;this.querySelectorAll(".palette-remove-btn").forEach(($)=>{if(Z)$.setAttribute("disabled","");else $.removeAttribute("disabled")})}#D(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#H(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}customElements.define("fig-input-palette",m0);class i extends HTMLElement{static SHIFT_SNAP=5;#Z;#Q;#J=!1;#$=null;#j=null;#q=null;#_={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"]}get#G(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#X(){return this.#G==="true"}get#W(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#Y(){if(!this.#Q)return null;return this.#Q.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#K(){if(this.hasAttribute("disabled")){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#X?"-1":"0")}#U(Q){return{...r(Q),type:"linear",angle:90}}connectedCallback(){if(this.#O(),this.#H(),this.removeEventListener("keydown",this.#L),this.addEventListener("keydown",this.#L),this.#X)document.addEventListener("keydown",this.#N)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#N),this.removeEventListener("keydown",this.#L),this.#j)this.#j.disconnect(),this.#j=null;if(this.#q!==null)cancelAnimationFrame(this.#q),this.#q=null;clearTimeout(this.#$),this.removeEventListener("pointerenter",this.#T),this.removeEventListener("pointermove",this.#E),this.removeEventListener("pointerleave",this.#C),this.removeEventListener("click",this.#g),this.removeEventListener("dblclick",this.#I)}#N=(Q)=>{let Z=document.activeElement,$=Z&&(Z.tagName==="INPUT"||Z.tagName==="TEXTAREA"||Z.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!$){let _=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!_)return;Q.preventDefault();let q=[...this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],G=q.indexOf(_),X=Q.shiftKey?(G-1+q.length)%q.length:(G+1)%q.length;_.deselect(),q[X].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!$){let _=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!_)return;let q=parseInt(_.dataset.stopIndex,10);if(isNaN(q)||!this.#_.stops[q])return;Q.preventDefault();let G=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?i.SHIFT_SNAP:1),X=this.#_.stops[q];X.position=Math.max(0,Math.min(100,X.position+G)),_.setAttribute("value",`${X.position}% 50%`);let K=_.closest("fig-tooltip");if(K)K.text=`${Math.round(X.position)}%`,K.setAttribute("show","true"),K.showPopup(),_.hideColorTip(),clearTimeout(this.#$),this.#$=setTimeout(()=>{K.removeAttribute("show"),_.showColorTip()},600);this.#x(),this.#u(),this.#d();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if($)return;if(this.#_.stops.length<=2)return;let J=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!J)return;let j=parseInt(J.dataset.stopIndex,10);if(isNaN(j)||!this.#_.stops[j])return;Q.preventDefault(),J.removeAttribute("selected"),this.#_.stops.splice(j,1),this.#w(),this.#x(),this.#u(),this.#d()};#L=(Q)=>{if(this.#G!=="picker")return;if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.altKey||Q.ctrlKey||Q.metaKey)return;if(this.hasAttribute("disabled"))return;let Z=this.querySelector("fig-fill-picker");if(!Z||typeof Z.open!=="function")return;Q.preventDefault(),Z.open()};#O(){let Q=this.getAttribute("value");if(!Q)return;try{let Z=JSON.parse(Q);if(Z?.type==="gradient"&&Z.gradient){this.#_=this.#U({...this.#_,...Z.gradient});return}if(Z?.gradient)this.#_=this.#U({...this.#_,...Z.gradient})}catch(Z){}}#B(){let Q=this.#U(this.#_),$=[...Q.stops].sort((_,q)=>_.position-q.position).map((_)=>{let q=(_.opacity??100)/100;if(q>=1)return`${_.color} ${_.position}%`;let{r:G,g:X,b:K}=c(_.color);return`rgba(${G}, ${X}, ${K}, ${q}) ${_.position}%`}).join(", "),J=v0(Q),j=J?` ${J}`:"";return`linear-gradient(${Q.angle}deg${j}, ${$})`}#M(Q){let Z=(Q.opacity??100)/100;if(Z>=1)return Q.color;let{r:$,g:J,b:j}=c(Q.color);return`rgba(${$}, ${J}, ${j}, ${Z})`}#z(){let Q=this.hasAttribute("disabled"),Z=this.#W==="tip"?' tip="color"':"";return this.#_.stops.map(($,J)=>`<fig-tooltip action="manual" text="${Math.round($.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${Z} color="${this.#M($)}" value="${$.position}% 50%" hit-area="4" data-stop-index="${J}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#A=null;#D=!1;#H(){let Q=this.hasAttribute("disabled"),Z=this.#G;if(Z==="picker"&&u()){let $=this.getAttribute("experimental"),J=$?` experimental="${$}"`:"",j=JSON.stringify(this.value);this.innerHTML=`
176
+ </fig-tooltip>`;break}Z.insertAdjacentHTML("beforeend",q),this.#J=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let G=this.querySelector(".fig-input-fill-label");if(this.#L(),G&&this.#Q)G.addEventListener("click",()=>{let X=this.#Q.querySelector("fig-chit");if(X)X.click()});if(this.#$)this.#$.addEventListener("input",(X)=>{X.stopPropagation();let K="#"+X.target.value.replace("#","");this.#j.color=K,this.#O(),this.#z()}),this.#$.addEventListener("change",(X)=>{X.stopPropagation(),this.#P()});if(this.#J)this.#J.addEventListener("input",(X)=>{X.stopPropagation();let K=parseFloat(X.target.value),M=(isNaN(K)?100:K)/100;switch(this.#Z){case"solid":this.#j.alpha=M;break;case"gradient":break;case"image":this.#_.opacity=M;break;case"video":this.#G.opacity=M;break;case"webcam":this.#X.opacity=M;break}this.#O(),this.#A(M),this.#z()}),this.#J.addEventListener("change",(X)=>{X.stopPropagation(),this.#P()})}#O(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#A(Q){if(this.#Q){let Z=this.#Q.querySelector("fig-chit");if(Z)Z.setAttribute("alpha",Q)}}#z(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#P(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#Z){case"solid":return{type:"solid",color:this.#j.color,alpha:this.#j.alpha,opacity:Math.round(this.#j.alpha*100)};case"gradient":return{type:"gradient",gradient:u0(this.#q)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#G}};case"webcam":return{type:"webcam",webcam:{...this.#X}};default:return{type:this.#Z}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":let J=this.#Z;if(this.#W(),this.#Q)if(this.#Z!==J)this.#H();else this.#O(),this.#M();break;case"disabled":this.#N();break;case"mode":case"experimental":if(this.#Q)if($)this.#Q.setAttribute(Q,$);else this.#Q.removeAttribute(Q);break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#L();break}}}customElements.define("fig-input-fill",c0);class d0 extends HTMLElement{#Z=[];#Q=[];#J=[];#$=null;#j=this.#X.bind(this);static get observedAttributes(){return["value","disabled","min","max","open","fixed"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){let Z=this.open;if(Q)this.setAttribute("open","");else this.removeAttribute("open");if(Z!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}get#q(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#_(){let Q=parseInt(this.getAttribute("min"));return isNaN(Q)?2:Q}get#G(){let Q=parseInt(this.getAttribute("max"));return isNaN(Q)?8:Q}connectedCallback(){if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.removeEventListener("keydown",this.#j),this.addEventListener("keydown",this.#j),this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{if(this.#$=null,!this.isConnected)return;this.#W(),this.#Y()})}disconnectedCallback(){if(this.#$)cancelAnimationFrame(this.#$),this.#$=null;this.removeEventListener("keydown",this.#j),this.#Q=[],this.#J=[]}#X(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target!==this&&!Q.target?.closest?.(".palette-colors-inline"))return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.preventDefault(),Q.stopPropagation(),this.open=!0,this.querySelector(".palette-colors-inline")?.setAttribute("aria-expanded","true")}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":this.#W(),this.#M();break;case"disabled":this.#F();break;case"min":case"max":case"fixed":this.#Y();break;case"open":break}}#W(){let Q=this.getAttribute("value");if(!Q){this.#Z=[];return}let Z=Q.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((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#Y(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#J=[];let Z=document.createElement("div");Z.className="palette-colors-inline",Z.setAttribute("role","button"),Z.setAttribute("aria-expanded",String(this.open)),Z.setAttribute("aria-label","Edit palette colors");let $=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0,Z.setAttribute("aria-expanded","true")};Z.addEventListener("click",$),Z.addEventListener("keydown",(_)=>{if(_.key!=="Enter"&&_.key!==" ")return;_.preventDefault(),_.stopPropagation(),$()});let J=document.createElement("div");if(J.className="palette-colors",this.#Z.forEach((_,q)=>{J.appendChild(this.#K(_,q,Q,{inline:!0}))}),Z.appendChild(J),this.appendChild(Z),!this.#q)this.#L(Q,this);let j=document.createElement("div");j.className="palette-colors-expanded",this.#Z.forEach((_,q)=>{if(j.appendChild(this.#K(_,q,Q)),!this.#q)j.appendChild(this.#U(q,Q))}),this.appendChild(j)}#K(Q,Z,$,{inline:J=!1}={}){let j=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,_=document.createElement("fig-input-color");if(_.setAttribute("value",j),J)_.setAttribute("text","false"),_.setAttribute("alpha","true"),_.setAttribute("swatch-disabled","");else _.setAttribute("text","true"),_.setAttribute("alpha","true"),_.setAttribute("full","");if($)_.setAttribute("disabled","");let q=J?this.#J:this.#Q,G=(X)=>{X.stopPropagation();let K=X.currentTarget;this.#Z[Z]={color:K.hexOpaque||this.#Z[Z].color,alpha:K.rgba?K.rgba.a:this.#Z[Z].alpha};let N=q[Z];if(N){let M=this.#Z[Z],L=M.alpha<1?M.color+Math.round(M.alpha*255).toString(16).padStart(2,"0"):M.color;N.setAttribute("value",L)}};if(_.addEventListener("input",(X)=>{G(X),this.#A()}),_.addEventListener("change",(X)=>{G(X),this.#z()}),J)this.#Q.push(_);else this.#J.push(_);return _}#U(Q,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.#_)$.setAttribute("disabled","");$.appendChild(v("minus")),$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#N(Q)});let J=document.createElement("fig-tooltip");return J.setAttribute("text","Remove color"),J.appendChild($),J}#N(Q){if(this.#q)return;if(Q<0||Q>=this.#Z.length)return;if(this.#Z.length<=this.#_)return;this.#Z.splice(Q,1),this.#Q=[],this.#J=[],this.#Y(),this.#z()}#L(Q,Z=this){let $=this.#Z.length>=this.#G,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",Q||$)J.setAttribute("disabled","");J.appendChild(v("add")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Z.length>=this.#G)return;this.open=!0,this.#H({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(J),Z.appendChild(j)}#H(Q){if(this.#q)return;this.#Z.push(Q);let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#Z.length-1,J=this.#K(Q,$,Z,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(J);let _=this.#K(Q,$,Z),q=this.querySelector(".palette-colors-expanded");if(q)q.appendChild(_),q.appendChild(this.#U($,Z));if(this.#Z.length>=this.#G){let G=this.querySelector(".palette-add-btn");if(G)G.setAttribute("disabled","")}this.#O(Z),this.#z()}#B(Q){let Z=this.#Z[Q];if(!Z)return;let $=Z.alpha<1?Z.color+Math.round(Z.alpha*255).toString(16).padStart(2,"0"):Z.color,J=this.#Q[Q];if(J)J.setAttribute("value",$);let j=this.#J[Q];if(j)j.setAttribute("value",$)}#M(){if(this.#Q.length!==this.#Z.length){this.#Y();return}this.#Z.forEach((Q,Z)=>{this.#B(Z)})}#F(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#J].forEach(($)=>{if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")});let Z=this.querySelector(".palette-add-btn");if(Z)if(Q||this.#Z.length>=this.#G)Z.setAttribute("disabled","");else Z.removeAttribute("disabled");this.#O(Q)}#O(Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let Z=Q||this.#Z.length<=this.#_;this.querySelectorAll(".palette-remove-btn").forEach(($)=>{if(Z)$.setAttribute("disabled","");else $.removeAttribute("disabled")})}#A(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#z(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}customElements.define("fig-input-palette",d0);class i extends HTMLElement{static SHIFT_SNAP=5;#Z;#Q;#J=!1;#$=null;#j=null;#q=null;#_={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"]}get#G(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#X(){return this.#G==="true"}get#W(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#Y(){if(!this.#Q)return null;return this.#Q.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#K(){if(this.hasAttribute("disabled")){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#X?"-1":"0")}#U(Q){return{...r(Q),type:"linear",angle:90}}connectedCallback(){if(this.#H(),this.#z(),this.removeEventListener("keydown",this.#L),this.addEventListener("keydown",this.#L),this.#X)document.addEventListener("keydown",this.#N)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#N),this.removeEventListener("keydown",this.#L),this.#j)this.#j.disconnect(),this.#j=null;if(this.#q!==null)cancelAnimationFrame(this.#q),this.#q=null;clearTimeout(this.#$),this.removeEventListener("pointerenter",this.#f),this.removeEventListener("pointermove",this.#k),this.removeEventListener("pointerleave",this.#S),this.removeEventListener("click",this.#g),this.removeEventListener("dblclick",this.#x)}#N=(Q)=>{let Z=document.activeElement,$=Z&&(Z.tagName==="INPUT"||Z.tagName==="TEXTAREA"||Z.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!$){let _=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!_)return;Q.preventDefault();let q=[...this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],G=q.indexOf(_),X=Q.shiftKey?(G-1+q.length)%q.length:(G+1)%q.length;_.deselect(),q[X].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!$){let _=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!_)return;let q=parseInt(_.dataset.stopIndex,10);if(isNaN(q)||!this.#_.stops[q])return;Q.preventDefault();let G=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?i.SHIFT_SNAP:1),X=this.#_.stops[q];X.position=Math.max(0,Math.min(100,X.position+G)),_.setAttribute("value",`${X.position}% 50%`);let K=_.closest("fig-tooltip");if(K)K.text=`${Math.round(X.position)}%`,K.setAttribute("show","true"),K.showPopup(),_.hideColorTip(),clearTimeout(this.#$),this.#$=setTimeout(()=>{K.removeAttribute("show"),_.showColorTip()},600);this.#b(),this.#m(),this.#d();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if($)return;if(this.#_.stops.length<=2)return;let J=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!J)return;let j=parseInt(J.dataset.stopIndex,10);if(isNaN(j)||!this.#_.stops[j])return;Q.preventDefault(),J.removeAttribute("selected"),this.#_.stops.splice(j,1),this.#V(),this.#b(),this.#m(),this.#d()};#L=(Q)=>{if(this.#G!=="picker")return;if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.altKey||Q.ctrlKey||Q.metaKey)return;if(this.hasAttribute("disabled"))return;let Z=this.querySelector("fig-fill-picker");if(!Z||typeof Z.open!=="function")return;Q.preventDefault(),Z.open()};#H(){let Q=this.getAttribute("value");if(!Q)return;try{let Z=JSON.parse(Q);if(Z?.type==="gradient"&&Z.gradient){this.#_=this.#U({...this.#_,...Z.gradient});return}if(Z?.gradient)this.#_=this.#U({...this.#_,...Z.gradient})}catch(Z){}}#B(){let Q=this.#U(this.#_),$=[...Q.stops].sort((_,q)=>_.position-q.position).map((_)=>{let q=(_.opacity??100)/100;if(q>=1)return`${_.color} ${_.position}%`;let{r:G,g:X,b:K}=c(_.color);return`rgba(${G}, ${X}, ${K}, ${q}) ${_.position}%`}).join(", "),J=p0(Q),j=J?` ${J}`:"";return`linear-gradient(${Q.angle}deg${j}, ${$})`}#M(Q){let Z=(Q.opacity??100)/100;if(Z>=1)return Q.color;let{r:$,g:J,b:j}=c(Q.color);return`rgba(${$}, ${J}, ${j}, ${Z})`}#F(){let Q=this.hasAttribute("disabled"),Z=this.#W==="tip"?' tip="color"':"";return this.#_.stops.map(($,J)=>`<fig-tooltip action="manual" text="${Math.round($.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${Z} color="${this.#M($)}" value="${$.position}% 50%" hit-area="4" data-stop-index="${J}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#O=null;#A=!1;#z(){let Q=this.hasAttribute("disabled"),Z=this.#G;if(Z==="picker"&&u()){let $=this.getAttribute("experimental"),J=$?` experimental="${$}"`:"",j=JSON.stringify(this.value);this.innerHTML=`
187
177
  <fig-fill-picker mode="gradient"${J} value='${j}'${Q?" disabled":""}>
188
178
  <fig-chit background="${this.#B()}"${Q?" disabled":""}></fig-chit>
189
- </fig-fill-picker>`,this.#Z=this.querySelector("fig-chit"),this.#Q=null,this.#R(),this.#K();return}if(this.innerHTML=`
179
+ </fig-fill-picker>`,this.#Z=this.querySelector("fig-chit"),this.#Q=null,this.#P(),this.#K();return}if(this.innerHTML=`
190
180
  <fig-chit background="${this.#B()}"${Q?" disabled":""}></fig-chit>
191
- ${Z==="true"||Z==="picker"?`<div class="fig-input-gradient-track">${this.#z()}</div>`:""}`,this.#Z=this.querySelector("fig-chit"),this.#Q=this.querySelector(".fig-input-gradient-track"),Z==="true"||Z==="picker")this.#S(),this.#m();this.#K()}#R(){let Q=this.querySelector("fig-fill-picker");if(!Q)return;Q.anchorElement=this;let Z=($)=>{$.stopPropagation();let J=$.detail;if(!J?.gradient)return;this.#_=this.#U({...this.#_,...J.gradient}),this.#x()};Q.addEventListener("input",($)=>{Z($),this.#u()}),Q.addEventListener("change",($)=>{Z($),this.#d()})}#F(Q){return k1(this.#_.stops,Q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#S(){if(!this.#Q||this.hasAttribute("disabled"))return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#W==="tip")Q.setAttribute("tip","add");Q.style.position="absolute",Q.style.top="50%",Q.style.transform="translate(-50%, -50%)",Q.style.pointerEvents="none",Q.style.opacity="0",Q.style.transition="opacity 0.15s",this.#Q.appendChild(Q),this.#A=Q,this.addEventListener("pointerenter",this.#T),this.addEventListener("pointermove",this.#E),this.addEventListener("pointerleave",this.#C),this.addEventListener("click",this.#g),this.addEventListener("dblclick",this.#I)}#k(){if(!this.#A)return;this.#A.style.opacity="1"}#f(){if(!this.#A)return;this.#A.style.opacity="0"}#T=()=>{if(this.#J)return;this.#k()};#C=()=>{this.#f()};#E=(Q)=>{if(this.#J){this.#f();return}if(!this.#A||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#f();return}let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width));this.#A.style.left=`${$*100}%`;let J=this.#F($);this.#A.setAttribute("color",J),this.#k()};#P(){let Q=this.#_.stops.length;if(Q<2)return;for(let Z=0;Z<Q;Z++)this.#_.stops[Z].position=Math.round(Z/(Q-1)*100);this.#w(),this.#x(),this.#u(),this.#d()}#I=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#P(),this.#Q.querySelectorAll("fig-handle[selected]").forEach((Z)=>{Z.removeAttribute("selected")})};#g=(Q)=>{if(!this.#Q)return;if(this.#J)return;if(this.#D){this.#D=!1;return}if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(Q.shiftKey){let q=Q.target.closest("fig-handle"),G=parseInt(q?.dataset.stopIndex,10);if(this.#P(),!isNaN(G))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(parseInt(X.dataset.stopIndex,10)===G)X.select();else X.deselect()});Q.stopPropagation()}return}let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#F($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((q,G)=>q.position-G.position);let _=this.#_.stops.findIndex((q)=>q.position===J&&q.color===j);this.#w(),this.#x(),this.#u(),this.#d(),requestAnimationFrame(()=>{let G=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[_];if(G)G.click()})};#V(){if(this.#q=null,!this.isConnected)return;if(!this.#Q)return;let Q=this.#_.stops;this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z,$)=>{if($>=Q.length)return;Z.removeAttribute("value"),Z.setAttribute("value",`${Q[$].position}% 50%`)})}refreshLayout(){this.#V()}#y(){if(this.#q!==null)return;this.#q=requestAnimationFrame(()=>this.#V())}#w(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops;if(Q.length!==Z.length){let $=this.#A;if(this.#Q.innerHTML=this.#z(),$)this.#Q.appendChild($);this.#v(),this.#h(),this.#y();return}for(let $=0;$<Z.length;$++){let J=Q[$],j=Z[$];if(J.dataset.stopIndex=$,J.setAttribute("value",`${j.position}% 50%`),J.setAttribute("color",this.#M(j)),this.#W==="tip")J.setAttribute("tip","color");else J.removeAttribute("tip");let _=J.closest("fig-tooltip");if(_)_.setAttribute("text",`${Math.round(j.position)}%`)}this.#v()}#v(){if(!this.#Q)return;let Q=this.#W==="tip";if(this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(Q)Z.setAttribute("tip","color");else Z.removeAttribute("tip")}),this.#A)if(Q)this.#A.setAttribute("tip","add");else this.#A.removeAttribute("tip")}#h(){if(!this.#j||!this.#Q)return;this.#j.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#b(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops,$=new Set;Q.forEach((J)=>{let j=Math.round(parseFloat(J.getAttribute("value"))||0),_=(J.getAttribute("color")||"").toUpperCase(),q=-1;for(let G=0;G<Z.length;G++){if($.has(G))continue;if(Z[G].position===j&&Z[G].color.toUpperCase()===_){q=G;break}}if(q===-1){let G=1/0;for(let X=0;X<Z.length;X++){if($.has(X))continue;let K=Math.abs(Z[X].position-j);if(K<G)G=K,q=X}}if(q!==-1)$.add(q),J.dataset.stopIndex=q})}#x(){if(!this.#Z)return;this.#Z.setAttribute("background",this.#B())}#m(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(this.hasAttribute("disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#F($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((X,K)=>X.position-K.position);let _=this.#_.stops.findIndex((X)=>X.position===J&&X.color===j);this.#D=!0,this.#w(),this.#x(),this.#u(),this.#f();let G=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[_];if(G)this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(X!==G)X.deselect()}),G.select(),G.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:Q.clientX,clientY:Q.clientY,pointerId:Q.pointerId,pointerType:Q.pointerType,button:Q.button,buttons:Q.buttons}))}),this.#Q.addEventListener("input",(Q)=>{let Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt(Z.dataset.stopIndex,10);if(!isNaN(X)&&this.#_.stops[X]){if(this.#_.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[X].opacity=Q.detail.opacity;Z.setAttribute("color",this.#M(this.#_.stops[X])),this.#x(),this.#u()}return}if(!this.#J)Z.style.zIndex="5";this.#J=!0;let $=parseInt(Z.dataset.stopIndex,10);if(isNaN($)||!this.#_.stops[$])return;let J=Q.detail?.px??0,j=Math.round(J*100),_=j,q=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)_=Math.round(_/i.SHIFT_SNAP)*i.SHIFT_SNAP;else{let X=q>0?5/q*100:0;for(let K=0;K<this.#_.stops.length;K++){if(K===$)continue;if(Math.abs(this.#_.stops[K].position-_)<=X){_=this.#_.stops[K].position;break}}}if(this.#_.stops[$].position=_,_!==j)Z.style.left=`${_/100*q}px`;let G=Z.closest("fig-tooltip");if(G){if(G.text=`${Math.round(_)}%`,!G.hasAttribute("show"))G.setAttribute("show","true"),Z.hideColorTip()}this.#x(),this.#u()}),this.#Q.addEventListener("change",(Q)=>{let Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt(Z.dataset.stopIndex,10);if(!isNaN(X)&&this.#_.stops[X]){if(this.#_.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[X].opacity=Q.detail.opacity;Z.setAttribute("color",this.#M(this.#_.stops[X])),this.#x(),this.#d()}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.#_.stops[J])return;let j=Q.detail?.px??0,_=Math.round(j*100),q=this.#Q.getBoundingClientRect().width,G=q>0?5/q*100:0;for(let X=0;X<this.#_.stops.length;X++){if(X===J)continue;if(Math.abs(this.#_.stops[X].position-_)<=G){_=this.#_.stops[X].position;break}}this.#_.stops[J].position=_,Z.style.left=`${_/100*q}px`,this.#_.stops.sort((X,K)=>X.position-K.position),this.#b(),this.#x(),this.#d(),requestAnimationFrame(()=>{this.#J=!1})}),this.#j=new MutationObserver((Q)=>{for(let Z of Q){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.#_.stops[J])continue;let j=$.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#_.stops[J].color)this.#_.stops[J].color=j,this.#x(),this.#u()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#u(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#d(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:b0(this.#U(this.#_))}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}focus(Q){if(this.hasAttribute("disabled"))return;if(this.#X){let Z=this.#Y();if(Z){Z.focus(Q);return}}HTMLElement.prototype.focus.call(this,Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":this.#O(),this.#x(),this.#w();break;case"disabled":this.#s();break;case"edit":if(this.#H(),this.#X)document.addEventListener("keydown",this.#N);else document.removeEventListener("keydown",this.#N);break;case"mode":this.#v();break}}#s(){let Q=this.hasAttribute("disabled");if(this.#K(),this.#Z)if(Q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#Q)for(let Z of this.#Q.querySelectorAll("fig-handle"))if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}customElements.define("fig-input-gradient",i);class e extends HTMLElement{#Z=null;#Q;constructor(){super();this.input=document.createElement("input"),this.name=this.getAttribute("name")||"checkbox",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",y()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","checkbox"),this.#Q=this.handleInput.bind(this)}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.#q();let Z=this.querySelector(":scope > label");if(Z)this.#Z=Z,this.#Z.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#J(),this.#Z.innerText=this.getAttribute("label");this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#J(){if(!this.#Z)this.#Z=document.createElement("label"),this.#Z.setAttribute("for",this.input.id);if(this.#Z&&!this.#Z.parentNode&&this.input.parentNode)this.input.after(this.#Z)}render(){}#$(Q){return this.hasAttribute(Q)&&this.getAttribute(Q)!=="false"}#j(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#q(){let Q=this.#$("checked"),Z=this.#$("indeterminate")&&!Q,$=this.#$("disabled");if(this.input.checked=Q,this.input.indeterminate=Z,this.input.disabled=$,this.input.value=this.getAttribute("value")||"",this.input.setAttribute("name",this.getAttribute("name")||this.name),Z)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#j()}focus(){this.input.focus()}get value(){return this.input.value}set value(Q){this.input.value=Q,this.setAttribute("value",Q)}get checked(){return this.input.checked}set checked(Q){if(this.input.checked=Q,Q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("change",this.#Q),this.input.remove()}attributeChangedCallback(Q,Z,$){switch(Q){case"label":if($)this.#J(),this.#Z.innerText=$;else if(this.#Z)this.#Z.remove(),this.#Z=null;break;case"checked":if(this.#$("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#q();break;case"indeterminate":this.#q();break;case"disabled":this.#q();break;case"name":this.input.setAttribute("name",$||this.name);break;case"value":this.input.value=$||"";break;default:this.input[Q]=$,this.input.setAttribute(Q,$);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#j(),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}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}customElements.define("fig-checkbox",e);class u0 extends e{constructor(){super();this.input.setAttribute("type","radio"),this.input.setAttribute("name",this.getAttribute("name")||"radio")}}customElements.define("fig-radio",u0);class p0 extends e{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}customElements.define("fig-switch",p0);class c0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Z=!1;#Q=null;#J=null;#$=null;#j=null;#q=!1;#_=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#G=this.#O.bind(this);#X=this.#B.bind(this);#W=this.#M.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}#Y(){return!!this.querySelector(":scope > .input-combo")}#K(){if(this.#Q=this.querySelector("fig-input-text"),this.#$=this.querySelector("fig-button"),this.#J=this.querySelector("fig-dropdown"),this.#Q)this.#Q.setAttribute("value",this.value),this.#Q.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#F()}connectedCallback(){if(this.#j=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#Z=this.#j!==null,this.#j)this.#j.remove();if(this.#Y())this.#K(),this.#N();else this.#U(),this.#N();if(this.hasAttribute("disabled"))this.#S(!0)}disconnectedCallback(){this.#L()}#U(){let Q=this.#D(),Z=this.getAttribute("placeholder")||"",$=this.value,J=this.getAttribute("experimental"),j=J?` experimental="${J}"`:"",_=this.#R(),q=this.#Z?"":`<fig-dropdown type="dropdown" label="${_}"${j}>${Q.map((G)=>`<option>${G.trim()}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
181
+ ${Z==="true"||Z==="picker"?`<div class="fig-input-gradient-track">${this.#F()}</div>`:""}`,this.#Z=this.querySelector("fig-chit"),this.#Q=this.querySelector(".fig-input-gradient-track"),Z==="true"||Z==="picker")this.#E(),this.#p();this.#K()}#P(){let Q=this.querySelector("fig-fill-picker");if(!Q)return;Q.anchorElement=this;let Z=($)=>{$.stopPropagation();let J=$.detail;if(!J?.gradient)return;this.#_=this.#U({...this.#_,...J.gradient}),this.#b()};Q.addEventListener("input",($)=>{Z($),this.#m()}),Q.addEventListener("change",($)=>{Z($),this.#d()})}#D(Q){return y1(this.#_.stops,Q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#E(){if(!this.#Q||this.hasAttribute("disabled"))return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#W==="tip")Q.setAttribute("tip","add");Q.style.position="absolute",Q.style.top="50%",Q.style.transform="translate(-50%, -50%)",Q.style.pointerEvents="none",Q.style.opacity="0",Q.style.transition="opacity 0.15s",this.#Q.appendChild(Q),this.#O=Q,this.addEventListener("pointerenter",this.#f),this.addEventListener("pointermove",this.#k),this.addEventListener("pointerleave",this.#S),this.addEventListener("click",this.#g),this.addEventListener("dblclick",this.#x)}#C(){if(!this.#O)return;this.#O.style.opacity="1"}#R(){if(!this.#O)return;this.#O.style.opacity="0"}#f=()=>{if(this.#J)return;this.#C()};#S=()=>{this.#R()};#k=(Q)=>{if(this.#J){this.#R();return}if(!this.#O||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#R();return}let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width));this.#O.style.left=`${$*100}%`;let J=this.#D($);this.#O.setAttribute("color",J),this.#C()};#T(){let Q=this.#_.stops.length;if(Q<2)return;for(let Z=0;Z<Q;Z++)this.#_.stops[Z].position=Math.round(Z/(Q-1)*100);this.#V(),this.#b(),this.#m(),this.#d()}#x=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#T(),this.#Q.querySelectorAll("fig-handle[selected]").forEach((Z)=>{Z.removeAttribute("selected")})};#g=(Q)=>{if(!this.#Q)return;if(this.#J)return;if(this.#A){this.#A=!1;return}if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(Q.shiftKey){let q=Q.target.closest("fig-handle"),G=parseInt(q?.dataset.stopIndex,10);if(this.#T(),!isNaN(G))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(parseInt(X.dataset.stopIndex,10)===G)X.select();else X.deselect()});Q.stopPropagation()}return}let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#D($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((q,G)=>q.position-G.position);let _=this.#_.stops.findIndex((q)=>q.position===J&&q.color===j);this.#V(),this.#b(),this.#m(),this.#d(),requestAnimationFrame(()=>{let G=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[_];if(G)G.click()})};#w(){if(this.#q=null,!this.isConnected)return;if(!this.#Q)return;let Q=this.#_.stops;this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z,$)=>{if($>=Q.length)return;Z.removeAttribute("value"),Z.setAttribute("value",`${Q[$].position}% 50%`)})}refreshLayout(){this.#w()}#I(){if(this.#q!==null)return;this.#q=requestAnimationFrame(()=>this.#w())}#V(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops;if(Q.length!==Z.length){let $=this.#O;if(this.#Q.innerHTML=this.#F(),$)this.#Q.appendChild($);this.#y(),this.#h(),this.#I();return}for(let $=0;$<Z.length;$++){let J=Q[$],j=Z[$];if(J.dataset.stopIndex=$,J.setAttribute("value",`${j.position}% 50%`),J.setAttribute("color",this.#M(j)),this.#W==="tip")J.setAttribute("tip","color");else J.removeAttribute("tip");let _=J.closest("fig-tooltip");if(_)_.setAttribute("text",`${Math.round(j.position)}%`)}this.#y()}#y(){if(!this.#Q)return;let Q=this.#W==="tip";if(this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(Q)Z.setAttribute("tip","color");else Z.removeAttribute("tip")}),this.#O)if(Q)this.#O.setAttribute("tip","add");else this.#O.removeAttribute("tip")}#h(){if(!this.#j||!this.#Q)return;this.#j.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#v(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops,$=new Set;Q.forEach((J)=>{let j=Math.round(parseFloat(J.getAttribute("value"))||0),_=(J.getAttribute("color")||"").toUpperCase(),q=-1;for(let G=0;G<Z.length;G++){if($.has(G))continue;if(Z[G].position===j&&Z[G].color.toUpperCase()===_){q=G;break}}if(q===-1){let G=1/0;for(let X=0;X<Z.length;X++){if($.has(X))continue;let K=Math.abs(Z[X].position-j);if(K<G)G=K,q=X}}if(q!==-1)$.add(q),J.dataset.stopIndex=q})}#b(){if(!this.#Z)return;this.#Z.setAttribute("background",this.#B())}#p(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(this.hasAttribute("disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#D($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((X,K)=>X.position-K.position);let _=this.#_.stops.findIndex((X)=>X.position===J&&X.color===j);this.#A=!0,this.#V(),this.#b(),this.#m(),this.#R();let G=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[_];if(G)this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(X!==G)X.deselect()}),G.select(),G.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:Q.clientX,clientY:Q.clientY,pointerId:Q.pointerId,pointerType:Q.pointerType,button:Q.button,buttons:Q.buttons}))}),this.#Q.addEventListener("input",(Q)=>{let Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt(Z.dataset.stopIndex,10);if(!isNaN(X)&&this.#_.stops[X]){if(this.#_.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[X].opacity=Q.detail.opacity;Z.setAttribute("color",this.#M(this.#_.stops[X])),this.#b(),this.#m()}return}if(!this.#J)Z.style.zIndex="5";this.#J=!0;let $=parseInt(Z.dataset.stopIndex,10);if(isNaN($)||!this.#_.stops[$])return;let J=Q.detail?.px??0,j=Math.round(J*100),_=j,q=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)_=Math.round(_/i.SHIFT_SNAP)*i.SHIFT_SNAP;else{let X=q>0?5/q*100:0;for(let K=0;K<this.#_.stops.length;K++){if(K===$)continue;if(Math.abs(this.#_.stops[K].position-_)<=X){_=this.#_.stops[K].position;break}}}if(this.#_.stops[$].position=_,_!==j)Z.style.left=`${_/100*q}px`;let G=Z.closest("fig-tooltip");if(G){if(G.text=`${Math.round(_)}%`,!G.hasAttribute("show"))G.setAttribute("show","true"),Z.hideColorTip()}this.#b(),this.#m()}),this.#Q.addEventListener("change",(Q)=>{let Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let X=parseInt(Z.dataset.stopIndex,10);if(!isNaN(X)&&this.#_.stops[X]){if(this.#_.stops[X].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[X].opacity=Q.detail.opacity;Z.setAttribute("color",this.#M(this.#_.stops[X])),this.#b(),this.#d()}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.#_.stops[J])return;let j=Q.detail?.px??0,_=Math.round(j*100),q=this.#Q.getBoundingClientRect().width,G=q>0?5/q*100:0;for(let X=0;X<this.#_.stops.length;X++){if(X===J)continue;if(Math.abs(this.#_.stops[X].position-_)<=G){_=this.#_.stops[X].position;break}}this.#_.stops[J].position=_,Z.style.left=`${_/100*q}px`,this.#_.stops.sort((X,K)=>X.position-K.position),this.#v(),this.#b(),this.#d(),requestAnimationFrame(()=>{this.#J=!1})}),this.#j=new MutationObserver((Q)=>{for(let Z of Q){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.#_.stops[J])continue;let j=$.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#_.stops[J].color)this.#_.stops[J].color=j,this.#b(),this.#m()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#m(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#d(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:u0(this.#U(this.#_))}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}focus(Q){if(this.hasAttribute("disabled"))return;if(this.#X){let Z=this.#Y();if(Z){Z.focus(Q);return}}HTMLElement.prototype.focus.call(this,Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":this.#H(),this.#b(),this.#V();break;case"disabled":this.#i();break;case"edit":if(this.#z(),this.#X)document.addEventListener("keydown",this.#N);else document.removeEventListener("keydown",this.#N);break;case"mode":this.#y();break}}#i(){let Q=this.hasAttribute("disabled");if(this.#K(),this.#Z)if(Q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#Q)for(let Z of this.#Q.querySelectorAll("fig-handle"))if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}customElements.define("fig-input-gradient",i);class Q0 extends HTMLElement{#Z=null;#Q;constructor(){super();this.input=document.createElement("input"),this.name=this.getAttribute("name")||"checkbox",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",y()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","checkbox"),this.#Q=this.handleInput.bind(this)}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.#q();let Z=this.querySelector(":scope > label");if(Z)this.#Z=Z,this.#Z.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#J(),this.#Z.innerText=this.getAttribute("label");this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#J(){if(!this.#Z)this.#Z=document.createElement("label"),this.#Z.setAttribute("for",this.input.id);if(this.#Z&&!this.#Z.parentNode&&this.input.parentNode)this.input.after(this.#Z)}render(){}#$(Q){return this.hasAttribute(Q)&&this.getAttribute(Q)!=="false"}#j(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#q(){let Q=this.#$("checked"),Z=this.#$("indeterminate")&&!Q,$=this.#$("disabled");if(this.input.checked=Q,this.input.indeterminate=Z,this.input.disabled=$,this.input.value=this.getAttribute("value")||"",this.input.setAttribute("name",this.getAttribute("name")||this.name),Z)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#j()}focus(){this.input.focus()}get value(){return this.input.value}set value(Q){this.input.value=Q,this.setAttribute("value",Q)}get checked(){return this.input.checked}set checked(Q){if(this.input.checked=Q,Q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("change",this.#Q),this.input.remove()}attributeChangedCallback(Q,Z,$){switch(Q){case"label":if($)this.#J(),this.#Z.innerText=$;else if(this.#Z)this.#Z.remove(),this.#Z=null;break;case"checked":if(this.#$("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#q();break;case"indeterminate":this.#q();break;case"disabled":this.#q();break;case"name":this.input.setAttribute("name",$||this.name);break;case"value":this.input.value=$||"";break;default:this.input[Q]=$,this.input.setAttribute(Q,$);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#j(),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}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}customElements.define("fig-checkbox",Q0);class s0 extends Q0{constructor(){super();this.input.setAttribute("type","radio"),this.input.setAttribute("name",this.getAttribute("name")||"radio")}}customElements.define("fig-radio",s0);class i0 extends Q0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}customElements.define("fig-switch",i0);class r0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Z=!1;#Q=null;#J=null;#$=null;#j=null;#q=!1;#_=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#G=this.#H.bind(this);#X=this.#B.bind(this);#W=this.#M.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}#Y(){return!!this.querySelector(":scope > .input-combo")}#K(){if(this.#Q=this.querySelector("fig-input-text"),this.#$=this.querySelector("fig-button"),this.#J=this.querySelector("fig-dropdown"),this.#Q)this.#Q.setAttribute("value",this.value),this.#Q.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#D()}connectedCallback(){if(this.#j=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#Z=this.#j!==null,this.#j)this.#j.remove();if(this.#Y())this.#K(),this.#N();else this.#U(),this.#N();if(this.hasAttribute("disabled"))this.#E(!0)}disconnectedCallback(){this.#L()}#U(){let Q=this.#A(),Z=this.getAttribute("placeholder")||"",$=this.value,J=this.getAttribute("experimental"),j=J?` experimental="${J}"`:"",_=this.#P(),q=this.#Z?"":`<fig-dropdown type="dropdown" label="${_}"${j}>${Q.map((G)=>`<option>${G.trim()}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
192
182
  <fig-input-text placeholder="${Z}" value="${$}"></fig-input-text>
193
183
  <fig-button type="select" variant="input" icon>
194
184
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -196,7 +186,7 @@ var A1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var F1={};var L0=A1(()=>{/*! Vendored from @
196
186
  </svg>
197
187
  ${q}
198
188
  </fig-button>
199
- </div>`,this.#Q=this.querySelector("fig-input-text"),this.#$=this.querySelector("fig-button"),this.#Z&&this.#j&&this.#$){if(!this.#j.hasAttribute("type"))this.#j.setAttribute("type","dropdown");if(!this.#j.hasAttribute("label"))this.#j.setAttribute("label",_);if(J)this.#j.setAttribute("experimental",J);this.#$.append(this.#j)}this.#J=this.querySelector("fig-dropdown"),this.#F()}#N(){this.#L(),this.#J?.addEventListener("input",this.#G),this.#Q?.addEventListener("input",this.#X),this.#Q?.addEventListener("change",this.#W)}#L(){this.#J?.removeEventListener("input",this.#G),this.#Q?.removeEventListener("input",this.#X),this.#Q?.removeEventListener("change",this.#W)}#O(Q){Q.stopPropagation();let Z=Q.target.closest("fig-dropdown")?.value??"";if(this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#Q)this.#Q.setAttribute("value",Z);this.#z(),this.#A()}#B(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#z()}#M(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#A()}#z(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#A(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#D(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#H(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#R(){return`${this.#H()} options`}#F(){if(this.#Q)this.#_.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,Z)});if(this.#J&&!this.#J.hasAttribute("aria-label"))this.#J.setAttribute("label",this.#R())}#S(Q){if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}focus(){this.#Q?.focus()}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"options":if(this.#J&&!this.#Z){let J=this.#D();this.#J.innerHTML=J.map((j)=>`<option>${j}</option>`).join("")}break;case"placeholder":if(this.#Q)this.#Q.setAttribute("placeholder",$||"");this.#F();break;case"value":if(!this.#q&&this.#Q)this.#Q.setAttribute("value",$||"");break;case"disabled":this.#S($!==null&&$!=="false");break;case"experimental":if(this.#J){if($)this.#J.setAttribute("experimental",$);else if(!this.#Z)this.#J.removeAttribute("experimental")}break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#F();break}}}customElements.define("fig-combo-input",c0);class q0 extends HTMLElement{#Z="color";#Q=null;#J=!1;constructor(){super();this.#Q=this.#W.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#G(),this.#$(),this.#X()}#$(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#j(Q){if(!Q)return"color";let Z=Q.toLowerCase();if(Z.includes("gradient"))return"gradient";if(Z.includes("url("))return"image";return"color"}#q(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:Z}=_0(1,1);return Z.fillStyle=Q,Z.fillStyle}catch{return"#D9D9D9"}}#_(Q){if(!Q||!Q.includes("var("))return Q;let Z=this.style.background;this.style.background=Q;let $=getComputedStyle(this),J=$.backgroundImage,j=$.backgroundColor;if(this.style.background=Z,J&&J!=="none")return J;return j||Q}#G(){let Q=this.getAttribute("background")||"#D9D9D9",Z=Q.includes("var("),$=Z?this.#_(Q):Q,J=this.#j($);if(J!==this.#Z||!this.input){if(this.#Z=J,this.setAttribute("data-type",this.#Z),this.input)this.input.removeEventListener("input",this.#Q);if(this.#Z==="color"){let _=this.#q($);if(this.innerHTML=`<div></div><input type="color" value="${_}" />`,this.input=this.querySelector("input"),!Z)this.input.addEventListener("input",this.#Q);this.#X()}else this.innerHTML="<div></div>",this.input=null,this.#X()}else if(this.#Z==="color"&&this.input){let _=this.#q($);if(this.input.value!==_)this.input.value=_}let j=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Q);this.style.setProperty("--chit-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#X(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",Q?"true":"false"),this.input){this.input.disabled=Q;let Z=this.getAttribute("aria-labelledby"),$=this.getAttribute("aria-label")||"Color swatch",J=this.getAttribute("aria-describedby");if(Z)this.input.setAttribute("aria-labelledby",Z),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",$),this.input.removeAttribute("aria-labelledby");if(J)this.input.setAttribute("aria-describedby",J);else this.input.removeAttribute("aria-describedby");this.removeAttribute("role"),this.removeAttribute("aria-hidden");return}if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-hidden","true");else this.setAttribute("role","img"),this.removeAttribute("aria-hidden")}#W(Q){this.#J=!0,this.setAttribute("background",Q.target.value),this.#J=!1}get background(){return this.getAttribute("background")}set background(Q){this.setAttribute("background",Q)}focus(){this.input?.focus()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="background"){if(this.#J){let J=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--chit-background",J?$:`linear-gradient(${$}, ${$})`);return}this.#G()}else if(Q==="alpha")this.#$();else if(Q==="disabled"||Q==="aria-label"||Q==="aria-labelledby"||Q==="aria-describedby")this.#X()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",Q)}}customElements.define("fig-chit",q0);class d0 extends q0{}customElements.define("fig-swatch",d0);class Q0 extends HTMLElement{#Z=null;#Q=null;#J=null;#$=null;#j=null;#q=null;#_=null;#G=this.#V.bind(this);#X=this.#w.bind(this);#W=this.#v.bind(this);#Y=this.#h.bind(this);#K=null;#U=null;#N=null;#L=null;#O=null;#B=null;#M=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","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(Q){if(this.#Z=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#_}#z(){return this.#q||this.#Z||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#z())return null;if(!this.#Q)return null;try{if(typeof this.#Q.decode==="function")await this.#Q.decode();else if(!this.#Q.complete)await new Promise((J,j)=>{this.#Q.addEventListener("load",J,{once:!0}),this.#Q.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Q.naturalWidth,Z=this.#Q.naturalHeight;if(!(Q>0)||!(Z>0))return null;let $=document.createElement("canvas");return $.width=Q,$.height=Z,$.getContext("2d").drawImage(this.#Q,0,0),$.toDataURL()}connectedCallback(){this.#Z=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--fig-media-aspect-ratio",Q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let Z=this.getAttribute("fit");if(Z)this.style.setProperty("--fig-media-fit",Z);if(this.querySelectorAll("fig-chit[data-generated]").forEach((J)=>J.remove()),this.#D(),this.#R(),this.#k(),this.#F(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#I()}disconnectedCallback(){if(this.#$?.removeEventListener("change",this.#G),this.#A(),this.#P(),this.#j)URL.revokeObjectURL(this.#j),this.#j=null;this.#q=null}#A(){if(!this.#Q)return;if(this.#Q.tagName==="VIDEO")this.#Q.removeEventListener("play",this.#X),this.#Q.removeEventListener("pause",this.#W),this.#Q.removeEventListener("ended",this.#Y)}#D(){if(this.#J?.isConnected)return;let Q=this.querySelector(":scope > fig-preview");if(Q){this.#J=Q;return}let Z=document.createElement("fig-preview");Z.setAttribute("data-generated",""),this.prepend(Z),this.#J=Z}#H(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#R(){let Q=this.#H();if(Q){if(this.#D(),this.#Q&&this.#Q!==Q){if(this.#A(),this.#Q.hasAttribute("data-generated"))this.#Q.remove()}if(this.#Q=Q,this.#J&&Q.parentElement!==this.#J)this.#J.append(Q);this.#F();return}this.#D();let Z=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Q&&this.#Q.tagName!==Z){if(this.#A(),this.#Q.hasAttribute("data-generated"))this.#Q.remove();this.#Q=null}if(this.#Q)return;if(this.mediaKind==="video"){let $=document.createElement("video");$.setAttribute("data-generated",""),$.className="fig-media-element",$.setAttribute("playsinline",""),$.preload="auto",this.#J.append($),this.#Q=$,this.#Q.addEventListener("play",this.#X),this.#Q.addEventListener("pause",this.#W),this.#Q.addEventListener("ended",this.#Y);let J=()=>{if(this.#Q?.autoplay)return;try{this.#Q.currentTime=0.001}catch{}};this.#Q.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.#Q=$}}#F(){if(!this.#Q)return;if(this.#Q.tagName==="IMG"){if(this.hasAttribute("alt")||this.#Q.hasAttribute("data-generated"))this.#Q.alt=this.getAttribute("alt")||"";return}if(this.#Q.tagName!=="VIDEO")return;["aria-label","aria-labelledby","title"].forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,Z)})}#S(Q,Z=!1){if(!this.hasAttribute(Q))return Z;return this.getAttribute(Q)!=="false"}#k(){if(!this.#Q)return;if(!this.#Q.hasAttribute("data-generated"))return;let Q=this.#z();if(this.#Q.getAttribute("src")!==Q){if(Q)this.#Q.setAttribute("src",Q);else if(this.#Q.removeAttribute("src"),this.#Q.tagName==="VIDEO")this.#Q.load()}if(this.#Q.tagName==="IMG"){this.#F();return}let Z=this.getAttribute("poster");if(Z)this.#Q.setAttribute("poster",Z);else this.#Q.removeAttribute("poster");this.#Q.controls=!1,this.#Q.removeAttribute("controls"),this.#Q.autoplay=this.#S("autoplay",!1),this.#Q.loop=this.#S("loop",!1),this.#Q.muted=this.#S("muted",!1),this.#Q.playsInline=!0,this.#F(),this.#f()}get mediaEl(){return this.#Q}#f(){if(this.mediaKind!=="video"){this.#P();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#K!==Q)this.#P(),this.#K=Q;this.#C();return}if(this.#S("controls",!1))this.#T();else this.#P()}#T(){if(this.#K&&this.#K.isConnected){this.#C();return}let Q=document.createElement("fig-media-controls");Q.setAttribute("data-generated",""),this.append(Q),this.#K=Q,this.#C()}#C(){if(!this.#K||!this.#Q)return;if(this.#U===this.#Q&&this.#N===this.#K)return;this.#E();let Q=this.#K,Z=this.#Q;this.#U=Z,this.#N=Q;let $=null,J=()=>{if(Q.playing=!Z.paused&&!Z.ended,Number.isFinite(Z.duration))Q.duration=Z.duration;if($!==null)if(Math.abs(Z.currentTime-$)<0.25)$=null;else return;Q.time=Z.currentTime||0},j=()=>{let G=Z.play?.();if(G&&typeof G.catch==="function")G.catch(()=>{})},_=()=>Z.pause?.(),q=(G)=>{let X=Number(G?.detail?.time);if(!Number.isFinite(X))return;$=X;try{Z.currentTime=X}catch{}};this.#L=J,this.#O=j,this.#B=_,this.#M=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),Q.addEventListener("play",j),Q.addEventListener("pause",_),Q.addEventListener("seek",q),J()}#E(){let Q=this.#U,Z=this.#N;if(Q&&this.#L)Q.removeEventListener("play",this.#L),Q.removeEventListener("pause",this.#L),Q.removeEventListener("ended",this.#L),Q.removeEventListener("timeupdate",this.#L),Q.removeEventListener("loadedmetadata",this.#L),Q.removeEventListener("durationchange",this.#L),Q.removeEventListener("seeked",this.#L);if(Z){if(this.#O)Z.removeEventListener("play",this.#O);if(this.#B)Z.removeEventListener("pause",this.#B);if(this.#M)Z.removeEventListener("seek",this.#M)}this.#U=null,this.#N=null,this.#L=null,this.#O=null,this.#B=null,this.#M=null}#P(){if(this.#E(),!this.#K)return;if(this.#K.hasAttribute("data-generated"))this.#K.remove();this.#K=null}toggle(){if(!this.#Q||this.mediaKind!=="video")return;if(this.#Q.paused||this.#Q.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Q)return;let Q=this.#Q.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Q)return;this.#Q.pause()}#I(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let Z=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#Z?"Replace":Z),this.#_?.name)Q.setAttribute("filename",this.#_.name);else if(this.#Z)Q.setAttribute("url",this.#Z);Q.addEventListener("change",this.#G),this.#D(),this.#J.append(Q),this.#$=Q}#g(){if(this.#$)this.#$.removeEventListener("change",this.#G),this.#$.remove(),this.#$=null}#V(Q){if(Q.target!==this.#$)return;let Z=Q.detail?.files?.[0],$=Q.detail?.cleared===!0;if(!Z){if(this.#j)URL.revokeObjectURL(this.#j),this.#j=null;if(this.#_=null,this.#q=null,$)this.src="";if(this.#k(),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.#j)URL.revokeObjectURL(this.#j);if(this.#_=Z,this.#j=URL.createObjectURL(Z),this.#q=this.#j,this.#k(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Z,src:this.#j}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#$)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",Z.name),this.#$.setAttribute("label","Replace")}#y(Q){if(!this.#Q)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Z||"",currentTime:this.#Q.currentTime,duration:this.#Q.duration}}))}#w(){this.#y("play")}#v(){this.#y("pause")}#h(){this.#y("ended")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="src"){let J=$||"",j=J&&(J===this.#q||J===this.#j);if(this.#Z=J,this.#j&&!j)URL.revokeObjectURL(this.#j),this.#j=null,this.#q=null,this.#_=null;if(this.#k(),this.#$){let _=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Z?"Replace":_),this.#Z)if(this.#_?.name)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",this.#_.name);else this.#$.setAttribute("url",this.#Z),this.#$.removeAttribute("filename");else this.#$.removeAttribute("url"),this.#$.removeAttribute("filename")}}if(Q==="type"){if(this.#R(),this.#k(),this.#$)this.#$.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(Q))this.#F();if(Q==="upload"){let J=$!==null&&$!=="false";if(J&&!this.#$)this.#I();else if(!J)this.#g()}if(Q==="aspect-ratio")if($)this.style.setProperty("--fig-media-aspect-ratio",$);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if($)this.style.setProperty("--fig-media-fit",$);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#$){let J=this.getAttribute("label")||"Upload";this.#$.setAttribute("label",this.#Z?"Replace":J)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#k()}}customElements.define("fig-media",Q0);class s0 extends Q0{get mediaKind(){return"image"}}customElements.define("fig-image",s0);class i0 extends Q0{get mediaKind(){return"video"}}customElements.define("fig-video",i0);class r0 extends HTMLElement{#Z=null;#Q=null;#J=null;#$=null;#j=!1;#q=!1;static get observedAttributes(){return["playing","duration","time"]}connectedCallback(){this.#_(),this.#W(),this.#Y()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let Q=Number(this.getAttribute("duration"));return Number.isFinite(Q)&&Q>=0?Q:0}set duration(Q){let Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("duration");return}this.setAttribute("duration",String(Z))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("time");return}this.setAttribute("time",String(Z))}attributeChangedCallback(Q){if(!this.#q)return;if(Q==="playing")this.#W();if(Q==="duration"||Q==="time")this.#Y()}#_(){if(this.#q)return;if(this.#q=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Play");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("size","small"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Play");let $=v("play",{className:"fig-media-controls-play-icon"});Z.append($),Q.append(Z),Z.addEventListener("click",(q)=>{q.preventDefault(),q.stopPropagation(),this.toggle()});let J=document.createElement("fig-slider");J.setAttribute("text","false"),J.setAttribute("min","0"),J.setAttribute("max",String(this.duration)),J.setAttribute("step","1"),J.setAttribute("value",String(this.time)),J.setAttribute("full",""),J.setAttribute("aria-label","Seek"),J.setAttribute("aria-valuetext",this.#X(this.time,this.duration));let j=document.createElement("span");j.className="fig-media-controls-time",j.textContent=this.#G(this.time);let _=(q)=>{let G=q.currentTarget,X=Number(G?.value);if(!Number.isFinite(X))return;this.#j=!0,this.setAttribute("time",String(X)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:X}})),requestAnimationFrame(()=>{this.#j=!1})};J.addEventListener("input",_),J.addEventListener("change",_),this.append(Q,J,j),this.#Z=Z,this.#Q=Q,this.#J=J,this.#$=j}#G(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let Z=Math.floor(Q),$=Math.floor(Z/60),J=Z%60;return`${String($).padStart(2,"0")}:${String(J).padStart(2,"0")}`}#X(Q,Z=0){let $=this.#G(Q);if(!Number.isFinite(Z)||Z<=0)return $;return`${$} of ${this.#G(Z)}`}#W(){if(!this.#Z)return;let Q=this.playing;this.#Z.setAttribute("aria-label",Q?"Pause":"Play"),this.#Q?.setAttribute("text",Q?"Pause":"Play");let Z=this.#Z.querySelector(".fig-media-controls-play-icon");if(Z)Z.setAttribute("name",Q?"pause":"play")}#Y(){if(!this.#J)return;let Q=this.duration;if(Number(this.#J.getAttribute("max"))!==Q)this.#J.setAttribute("max",String(Q));let Z=this.time;if(!this.#j)this.#J.setAttribute("value",String(Z));if(this.#J.setAttribute("aria-valuetext",this.#X(Z,Q)),this.#$)this.#$.textContent=this.#G(Z)}toggle(){let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.playing)return;this.toggle()}pause(){if(!this.playing)return;this.toggle()}}customElements.define("fig-media-controls",r0);class o0 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#Z=null;#Q=null;#J=null;#$=null;#j=null;#q=null;get files(){return this.#q}get#_(){let Q=this.getAttribute("filename");if(Q)return Q;let Z=this.getAttribute("url");if(!Z)return"";try{let J=new URL(Z,location.href).pathname.split("/").pop();return J?decodeURIComponent(J):Z}catch{return Z}}get value(){if(this.#q&&this.#q.length>0){if(this.#q.length===1)return this.#q[0].name;return`${this.#q.length} files`}return this.#_}connectedCallback(){this.#N(),this.addEventListener("dragover",this.#Y),this.addEventListener("dragleave",this.#K),this.addEventListener("drop",this.#U)}disconnectedCallback(){this.#Z?.removeEventListener("change",this.#X),this.#J?.removeEventListener("click",this.#W),this.removeEventListener("dragover",this.#Y),this.removeEventListener("dragleave",this.#K),this.removeEventListener("drop",this.#U)}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#N()}clear(){if(this.#q=null,this.#Z)this.#Z.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#N(),this.#G({cleared:!0})}#G(Q={}){let Z={files:this.#q,...Q};this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0}))}#X=()=>{if(this.#Z.files.length>0)this.#q=this.#Z.files,this.removeAttribute("url"),this.#N(),this.#G()};#W=(Q)=>{Q.stopPropagation(),this.clear()};#Y=(Q)=>{if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#j)this.#j.dataset.prevText=this.#j.textContent,this.#j.textContent="Drop file"}};#K=()=>{if(this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText};#U=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.getAttribute("accepts"),$=Array.from(Q.dataTransfer.files);if(Z){let j=Z.split(",").map((_)=>_.trim().toLowerCase());$=$.filter((_)=>{let q="."+_.name.split(".").pop().toLowerCase(),G=_.type.toLowerCase();return j.some((X)=>X===q||X===G||X.endsWith("/*")&&G.startsWith(X.slice(0,-1)))})}if(!this.hasAttribute("multiple"))$=$.slice(0,1);if($.length===0)return;let J=new DataTransfer;if($.forEach((j)=>J.items.add(j)),this.#q=J.files,this.#Z)this.#Z.files=J.files;this.removeAttribute("url"),this.#N(),this.#G()};#N(){let Q=this.getAttribute("accepts")||"",Z=this.getAttribute("label")||"Upload",$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.hasAttribute("multiple"),j=this.getAttribute("variant")||"input",_=this.#q&&this.#q.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",_){let q=Q?`Accepts ${Q.split(",").map((B)=>B.trim()).join(", ")}`:"";if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.className="fig-input-file-filename",$)this.#j.setAttribute("disabled","");let G=document.createElement("fig-truncate");G.setAttribute("position","middle"),G.setAttribute("tooltip","");let X=this.value,K=X.lastIndexOf(".");if(K>0)G.setAttribute("tail",X.slice(K));if(G.textContent=X,this.#j.appendChild(G),this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",Q)this.#Z.setAttribute("accept",Q);if(J)this.#Z.setAttribute("multiple","");if(this.#Z.addEventListener("change",this.#X),this.#j.appendChild(this.#Z),q)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",q),this.#$.appendChild(this.#j),this.appendChild(this.#$);else this.appendChild(this.#j);let N=document.createElement("fig-tooltip");if(N.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",$)this.#J.setAttribute("disabled","");this.#J.replaceChildren(v("minus")),this.#J.addEventListener("click",this.#W),N.appendChild(this.#J),this.appendChild(N)}else{let q=Q?`Accepts ${Q.split(",").map((G)=>G.trim()).join(", ")}`:"";if(q)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",q);if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.textContent=Z,$)this.#j.setAttribute("disabled","");if(this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",Q)this.#Z.setAttribute("accept",Q);if(J)this.#Z.setAttribute("multiple","");if(this.#Z.addEventListener("change",this.#X),this.#j.appendChild(this.#Z),this.#$)this.#$.appendChild(this.#j),this.appendChild(this.#$);else this.appendChild(this.#j)}}}customElements.define("fig-input-file",o0);class g extends HTMLElement{#Z={x:0.42,y:0};#Q={x:0.58,y:1};#J={stiffness:200,damping:15,mass:1};#$="bezier";#j=2;#q=null;#_=null;#G=null;#X=null;#W=null;#Y=null;#K=null;#U=null;#N=null;#L=null;#O=null;#B=null;#M=null;#z=0.8;#A=200;#D=200;#H=null;#R=null;#F=null;#S=5;#k=2;#f=10;#T=10;#C=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#j=parseInt(this.getAttribute("precision")||"2"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#E(Q);this.#B=this.#P(),this.#y(),this.#d()}disconnectedCallback(){if(this.#q=null,this.#F)this.#F.disconnect(),this.#F=null}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="aspect-ratio"){if(V(this,"--aspect-ratio",$),this.#_)this.#s(),this.#p();return}if(Q==="edit"){if(this.isConnected)this.#y();return}if(Q==="value"&&$){let J=this.#$;if(this.#E($),this.#B=this.#P(),J!==this.#$&&this.#V())this.#y();else{if(this.#_)this.#p();this.#a(),this.#c()}}if(Q==="precision")this.#j=parseInt($||"2")}get value(){if(this.#$==="spring"){let{stiffness:Z,damping:$,mass:J}=this.#J;return`spring(${Z}, ${$}, ${J})`}let Q=this.#j;return`${this.#Z.x.toFixed(Q)}, ${this.#Z.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}`}get cssValue(){if(this.#$==="spring"){let Z=this.#I(),$=20,J=Math.max(1,Math.floor(Z.length/20)),j=[];for(let _=0;_<Z.length;_+=J)j.push(Z[_].value.toFixed(3));if(Z.length>0)j.push(Z[Z.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#j;return`cubic-bezier(${this.#Z.x.toFixed(Q)}, ${this.#Z.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)})`}get preset(){return this.#B}set value(Q){this.setAttribute("value",Q)}#E(Q){let Z=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if(Z)return this.#$="spring",this.#J.stiffness=parseFloat(Z[1]),this.#J.damping=parseFloat(Z[2]),this.#J.mass=parseFloat(Z[3]),!0;let $=Q.split(",").map((J)=>parseFloat(J.trim()));if($.length>=4&&$.every((J)=>!isNaN(J)))return this.#$="bezier",this.#Z.x=$[0],this.#Z.y=$[1],this.#Q.x=$[2],this.#Q.y=$[3],!0;return!1}#P(){if(this.#$==="bezier"){for(let Z of g.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.#Q.x-Z.value[2])<0.001&&Math.abs(this.#Q.y-Z.value[3])<0.001)return Z.name}return"Custom bezier"}for(let Z of g.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)return Z.name}return"Custom spring"}#I(){let{stiffness:Q,damping:Z,mass:$}=this.#J,J=0.004,j=5,_=[],q=0,G=0;for(let X=0;X<=5;X+=0.004){let K=-Q*(q-1)-Z*G;if(G+=K/$*0.004,q+=G*0.004,_.push({t:X,value:q}),X>0.1&&Math.abs(q-1)<0.0005&&Math.abs(G)<0.0005)break}return _}static#g(Q,Z=24){let{stiffness:$,damping:J,mass:j}=Q,_=0.004,q=5,G=[],X=0,K=0;for(let M=0;M<=5;M+=0.004){let O=-$*(X-1)-J*K;if(K+=O/j*0.004,X+=K*0.004,G.push({t:M,value:X}),M>0.1&&Math.abs(X-1)<0.001&&Math.abs(K)<0.001)break}let N=G[G.length-1].t||1,B=1;for(let M of G)if(M.value>B)B=M.value;let L=0;for(let M of G)if(M.value<L)L=M.value;let A=Math.max(B-L,1),U=6,W=Z-U*2,R=Math.max(1,Math.floor(G.length/30)),z="";for(let M=0;M<G.length;M+=R){let O=U+G[M].t/N*W,T=U+(1-(G[M].value-L)/A)*W;z+=(M===0?"M":"L")+O.toFixed(1)+","+T.toFixed(1)}return`<svg width="${Z}" height="${Z}" viewBox="0 0 ${Z} ${Z}" fill="none"><path d="${z}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,Z,$,J,j=24){let q=(j-12)/2,G=48,X=[],K=(O,T,C,k,I)=>{let S=1-I;return S*S*S*O+3*S*S*I*T+3*S*I*I*C+I*I*I*k};for(let O=0;O<=48;O++){let T=O/48;X.push({x:K(0,Q,$,1,T),y:K(0,Z,J,1,T)})}let N=1/0,B=-1/0,L=1/0,A=-1/0;for(let O of X){if(O.x<N)N=O.x;if(O.x>B)B=O.x;if(O.y<L)L=O.y;if(O.y>A)A=O.y}let U=Math.max(B-N,0.000001),W=Math.max(A-L,0.000001),R=(O)=>q+(O-N)/U*12,z=(O)=>q+(1-(O-L)/W)*12,M="";for(let O=0;O<X.length;O++){let T=R(X[O].x),C=z(X[O].y);M+=`${O===0?"M":"L"}${T.toFixed(1)},${C.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${M}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#V(){return this.getAttribute("edit")!=="false"}#y(){if(this.classList.toggle("spring-mode",this.#$==="spring"),this.classList.toggle("bezier-mode",this.#$!=="spring"),this.#x(),this.innerHTML=this.#h(),this.#m(),this.#_)this.#u(),this.#s(),this.#p();this.#c(),this.#L0()}static#w(Q){return String(Q).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#v(){let Q="",Z=void 0;for(let $ of g.PRESETS){if(!this.#V()&&!$.value&&!$.spring)continue;if($.group!==Z){if(Z!==void 0)Q+="</optgroup>";if($.group)Q+=`<optgroup label="${$.group}">`;Z=$.group}let J;if($.type==="spring"){let _=$.spring||this.#J;J=g.#g(_)}else{let _=$.value||[this.#Z.x,this.#Z.y,this.#Q.x,this.#Q.y];J=g.curveIcon(..._)}let j=$.name===this.#B?" selected":"";Q+=`<option value="${$.name}"${j}>${J} ${$.name}</option>`}if(Z)Q+="</optgroup>";return`<fig-dropdown class="fig-easing-curve-dropdown" full experimental="modern">${Q}</fig-dropdown>`}#h(){let Z=this.#v();if(!this.#V())return Z;let $=`<fig-input-text class="fig-easing-curve-value-input" value="${g.#w(this.value)}" full></fig-input-text>`;if(this.#$==="spring")return`${Z}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
189
+ </div>`,this.#Q=this.querySelector("fig-input-text"),this.#$=this.querySelector("fig-button"),this.#Z&&this.#j&&this.#$){if(!this.#j.hasAttribute("type"))this.#j.setAttribute("type","dropdown");if(!this.#j.hasAttribute("label"))this.#j.setAttribute("label",_);if(J)this.#j.setAttribute("experimental",J);this.#$.append(this.#j)}this.#J=this.querySelector("fig-dropdown"),this.#D()}#N(){this.#L(),this.#J?.addEventListener("input",this.#G),this.#Q?.addEventListener("input",this.#X),this.#Q?.addEventListener("change",this.#W)}#L(){this.#J?.removeEventListener("input",this.#G),this.#Q?.removeEventListener("input",this.#X),this.#Q?.removeEventListener("change",this.#W)}#H(Q){Q.stopPropagation();let Z=Q.target.closest("fig-dropdown")?.value??"";if(this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#Q)this.#Q.setAttribute("value",Z);this.#F(),this.#O()}#B(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#F()}#M(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#O()}#F(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#O(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#A(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#z(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#P(){return`${this.#z()} options`}#D(){if(this.#Q)this.#_.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,Z)});if(this.#J&&!this.#J.hasAttribute("aria-label"))this.#J.setAttribute("label",this.#P())}#E(Q){if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}focus(){this.#Q?.focus()}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"options":if(this.#J&&!this.#Z){let J=this.#A();this.#J.innerHTML=J.map((j)=>`<option>${j}</option>`).join("")}break;case"placeholder":if(this.#Q)this.#Q.setAttribute("placeholder",$||"");this.#D();break;case"value":if(!this.#q&&this.#Q)this.#Q.setAttribute("value",$||"");break;case"disabled":this.#E($!==null&&$!=="false");break;case"experimental":if(this.#J){if($)this.#J.setAttribute("experimental",$);else if(!this.#Z)this.#J.removeAttribute("experimental")}break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#D();break}}}customElements.define("fig-combo-input",r0);class K0 extends HTMLElement{#Z="color";#Q=null;#J=!1;constructor(){super();this.#Q=this.#W.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#G(),this.#$(),this.#X()}#$(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#j(Q){if(!Q)return"color";let Z=Q.toLowerCase();if(Z.includes("gradient"))return"gradient";if(Z.includes("url("))return"image";return"color"}#q(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:Z}=X0(1,1);return Z.fillStyle=Q,Z.fillStyle}catch{return"#D9D9D9"}}#_(Q){if(!Q||!Q.includes("var("))return Q;let Z=this.style.background;this.style.background=Q;let $=getComputedStyle(this),J=$.backgroundImage,j=$.backgroundColor;if(this.style.background=Z,J&&J!=="none")return J;return j||Q}#G(){let Q=this.getAttribute("background")||"#D9D9D9",Z=Q.includes("var("),$=Z?this.#_(Q):Q,J=this.#j($);if(J!==this.#Z||!this.input){if(this.#Z=J,this.setAttribute("data-type",this.#Z),this.input)this.input.removeEventListener("input",this.#Q);if(this.#Z==="color"){let _=this.#q($);if(this.innerHTML=`<div></div><input type="color" value="${_}" />`,this.input=this.querySelector("input"),!Z)this.input.addEventListener("input",this.#Q);this.#X()}else this.innerHTML="<div></div>",this.input=null,this.#X()}else if(this.#Z==="color"&&this.input){let _=this.#q($);if(this.input.value!==_)this.input.value=_}let j=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Q);this.style.setProperty("--chit-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#X(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",Q?"true":"false"),this.input){this.input.disabled=Q;let Z=this.getAttribute("aria-labelledby"),$=this.getAttribute("aria-label")||"Color swatch",J=this.getAttribute("aria-describedby");if(Z)this.input.setAttribute("aria-labelledby",Z),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",$),this.input.removeAttribute("aria-labelledby");if(J)this.input.setAttribute("aria-describedby",J);else this.input.removeAttribute("aria-describedby");this.removeAttribute("role"),this.removeAttribute("aria-hidden");return}if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-hidden","true");else this.setAttribute("role","img"),this.removeAttribute("aria-hidden")}#W(Q){this.#J=!0,this.setAttribute("background",Q.target.value),this.#J=!1}get background(){return this.getAttribute("background")}set background(Q){this.setAttribute("background",Q)}focus(){this.input?.focus()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="background"){if(this.#J){let J=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--chit-background",J?$:`linear-gradient(${$}, ${$})`);return}this.#G()}else if(Q==="alpha")this.#$();else if(Q==="disabled"||Q==="aria-label"||Q==="aria-labelledby"||Q==="aria-describedby")this.#X()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",Q)}}customElements.define("fig-chit",K0);class o0 extends K0{}customElements.define("fig-swatch",o0);class Z0 extends HTMLElement{#Z=null;#Q=null;#J=null;#$=null;#j=null;#q=null;#_=null;#G=this.#w.bind(this);#X=this.#V.bind(this);#W=this.#y.bind(this);#Y=this.#h.bind(this);#K=null;#U=null;#N=null;#L=null;#H=null;#B=null;#M=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","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(Q){if(this.#Z=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#_}#F(){return this.#q||this.#Z||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#F())return null;if(!this.#Q)return null;try{if(typeof this.#Q.decode==="function")await this.#Q.decode();else if(!this.#Q.complete)await new Promise((J,j)=>{this.#Q.addEventListener("load",J,{once:!0}),this.#Q.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Q.naturalWidth,Z=this.#Q.naturalHeight;if(!(Q>0)||!(Z>0))return null;let $=document.createElement("canvas");return $.width=Q,$.height=Z,$.getContext("2d").drawImage(this.#Q,0,0),$.toDataURL()}connectedCallback(){this.#Z=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--fig-media-aspect-ratio",Q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let Z=this.getAttribute("fit");if(Z)this.style.setProperty("--fig-media-fit",Z);if(this.querySelectorAll("fig-chit[data-generated]").forEach((J)=>J.remove()),this.#A(),this.#P(),this.#C(),this.#D(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#x()}disconnectedCallback(){if(this.#$?.removeEventListener("change",this.#G),this.#O(),this.#T(),this.#j)URL.revokeObjectURL(this.#j),this.#j=null;this.#q=null}#O(){if(!this.#Q)return;if(this.#Q.tagName==="VIDEO")this.#Q.removeEventListener("play",this.#X),this.#Q.removeEventListener("pause",this.#W),this.#Q.removeEventListener("ended",this.#Y)}#A(){if(this.#J?.isConnected)return;let Q=this.querySelector(":scope > fig-preview");if(Q){this.#J=Q;return}let Z=document.createElement("fig-preview");Z.setAttribute("data-generated",""),this.prepend(Z),this.#J=Z}#z(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#P(){let Q=this.#z();if(Q){if(this.#A(),this.#Q&&this.#Q!==Q){if(this.#O(),this.#Q.hasAttribute("data-generated"))this.#Q.remove()}if(this.#Q=Q,this.#J&&Q.parentElement!==this.#J)this.#J.append(Q);this.#D();return}this.#A();let Z=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Q&&this.#Q.tagName!==Z){if(this.#O(),this.#Q.hasAttribute("data-generated"))this.#Q.remove();this.#Q=null}if(this.#Q)return;if(this.mediaKind==="video"){let $=document.createElement("video");$.setAttribute("data-generated",""),$.className="fig-media-element",$.setAttribute("playsinline",""),$.preload="auto",this.#J.append($),this.#Q=$,this.#Q.addEventListener("play",this.#X),this.#Q.addEventListener("pause",this.#W),this.#Q.addEventListener("ended",this.#Y);let J=()=>{if(this.#Q?.autoplay)return;try{this.#Q.currentTime=0.001}catch{}};this.#Q.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.#Q=$}}#D(){if(!this.#Q)return;if(this.#Q.tagName==="IMG"){if(this.hasAttribute("alt")||this.#Q.hasAttribute("data-generated"))this.#Q.alt=this.getAttribute("alt")||"";return}if(this.#Q.tagName!=="VIDEO")return;["aria-label","aria-labelledby","title"].forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,Z)})}#E(Q,Z=!1){if(!this.hasAttribute(Q))return Z;return this.getAttribute(Q)!=="false"}#C(){if(!this.#Q)return;if(!this.#Q.hasAttribute("data-generated"))return;let Q=this.#F();if(this.#Q.getAttribute("src")!==Q){if(Q)this.#Q.setAttribute("src",Q);else if(this.#Q.removeAttribute("src"),this.#Q.tagName==="VIDEO")this.#Q.load()}if(this.#Q.tagName==="IMG"){this.#D();return}let Z=this.getAttribute("poster");if(Z)this.#Q.setAttribute("poster",Z);else this.#Q.removeAttribute("poster");this.#Q.controls=!1,this.#Q.removeAttribute("controls"),this.#Q.autoplay=this.#E("autoplay",!1),this.#Q.loop=this.#E("loop",!1),this.#Q.muted=this.#E("muted",!1),this.#Q.playsInline=!0,this.#D(),this.#R()}get mediaEl(){return this.#Q}#R(){if(this.mediaKind!=="video"){this.#T();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#K!==Q)this.#T(),this.#K=Q;this.#S();return}if(this.#E("controls",!1))this.#f();else this.#T()}#f(){if(this.#K&&this.#K.isConnected){this.#S();return}let Q=document.createElement("fig-media-controls");Q.setAttribute("data-generated",""),this.append(Q),this.#K=Q,this.#S()}#S(){if(!this.#K||!this.#Q)return;if(this.#U===this.#Q&&this.#N===this.#K)return;this.#k();let Q=this.#K,Z=this.#Q;this.#U=Z,this.#N=Q;let $=null,J=()=>{if(Q.playing=!Z.paused&&!Z.ended,Number.isFinite(Z.duration))Q.duration=Z.duration;if($!==null)if(Math.abs(Z.currentTime-$)<0.25)$=null;else return;Q.time=Z.currentTime||0},j=()=>{let G=Z.play?.();if(G&&typeof G.catch==="function")G.catch(()=>{})},_=()=>Z.pause?.(),q=(G)=>{let X=Number(G?.detail?.time);if(!Number.isFinite(X))return;$=X;try{Z.currentTime=X}catch{}};this.#L=J,this.#H=j,this.#B=_,this.#M=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),Q.addEventListener("play",j),Q.addEventListener("pause",_),Q.addEventListener("seek",q),J()}#k(){let Q=this.#U,Z=this.#N;if(Q&&this.#L)Q.removeEventListener("play",this.#L),Q.removeEventListener("pause",this.#L),Q.removeEventListener("ended",this.#L),Q.removeEventListener("timeupdate",this.#L),Q.removeEventListener("loadedmetadata",this.#L),Q.removeEventListener("durationchange",this.#L),Q.removeEventListener("seeked",this.#L);if(Z){if(this.#H)Z.removeEventListener("play",this.#H);if(this.#B)Z.removeEventListener("pause",this.#B);if(this.#M)Z.removeEventListener("seek",this.#M)}this.#U=null,this.#N=null,this.#L=null,this.#H=null,this.#B=null,this.#M=null}#T(){if(this.#k(),!this.#K)return;if(this.#K.hasAttribute("data-generated"))this.#K.remove();this.#K=null}toggle(){if(!this.#Q||this.mediaKind!=="video")return;if(this.#Q.paused||this.#Q.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Q)return;let Q=this.#Q.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Q)return;this.#Q.pause()}#x(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let Z=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#Z?"Replace":Z),this.#_?.name)Q.setAttribute("filename",this.#_.name);else if(this.#Z)Q.setAttribute("url",this.#Z);Q.addEventListener("change",this.#G),this.#A(),this.#J.append(Q),this.#$=Q}#g(){if(this.#$)this.#$.removeEventListener("change",this.#G),this.#$.remove(),this.#$=null}#w(Q){if(Q.target!==this.#$)return;let Z=Q.detail?.files?.[0],$=Q.detail?.cleared===!0;if(!Z){if(this.#j)URL.revokeObjectURL(this.#j),this.#j=null;if(this.#_=null,this.#q=null,$)this.src="";if(this.#C(),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.#j)URL.revokeObjectURL(this.#j);if(this.#_=Z,this.#j=URL.createObjectURL(Z),this.#q=this.#j,this.#C(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Z,src:this.#j}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#$)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",Z.name),this.#$.setAttribute("label","Replace")}#I(Q){if(!this.#Q)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Z||"",currentTime:this.#Q.currentTime,duration:this.#Q.duration}}))}#V(){this.#I("play")}#y(){this.#I("pause")}#h(){this.#I("ended")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="src"){let J=$||"",j=J&&(J===this.#q||J===this.#j);if(this.#Z=J,this.#j&&!j)URL.revokeObjectURL(this.#j),this.#j=null,this.#q=null,this.#_=null;if(this.#C(),this.#$){let _=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Z?"Replace":_),this.#Z)if(this.#_?.name)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",this.#_.name);else this.#$.setAttribute("url",this.#Z),this.#$.removeAttribute("filename");else this.#$.removeAttribute("url"),this.#$.removeAttribute("filename")}}if(Q==="type"){if(this.#P(),this.#C(),this.#$)this.#$.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(Q))this.#D();if(Q==="upload"){let J=$!==null&&$!=="false";if(J&&!this.#$)this.#x();else if(!J)this.#g()}if(Q==="aspect-ratio")if($)this.style.setProperty("--fig-media-aspect-ratio",$);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if($)this.style.setProperty("--fig-media-fit",$);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#$){let J=this.getAttribute("label")||"Upload";this.#$.setAttribute("label",this.#Z?"Replace":J)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#C()}}customElements.define("fig-media",Z0);class l0 extends Z0{get mediaKind(){return"image"}}customElements.define("fig-image",l0);class a0 extends Z0{get mediaKind(){return"video"}}customElements.define("fig-video",a0);class t0 extends HTMLElement{#Z=null;#Q=null;#J=null;#$=null;#j=!1;#q=!1;static get observedAttributes(){return["playing","duration","time"]}connectedCallback(){this.#_(),this.#W(),this.#Y()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let Q=Number(this.getAttribute("duration"));return Number.isFinite(Q)&&Q>=0?Q:0}set duration(Q){let Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("duration");return}this.setAttribute("duration",String(Z))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("time");return}this.setAttribute("time",String(Z))}attributeChangedCallback(Q){if(!this.#q)return;if(Q==="playing")this.#W();if(Q==="duration"||Q==="time")this.#Y()}#_(){if(this.#q)return;if(this.#q=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Play");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("size","small"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Play");let $=v("play",{className:"fig-media-controls-play-icon"});Z.append($),Q.append(Z),Z.addEventListener("click",(q)=>{q.preventDefault(),q.stopPropagation(),this.toggle()});let J=document.createElement("fig-slider");J.setAttribute("text","false"),J.setAttribute("min","0"),J.setAttribute("max",String(this.duration)),J.setAttribute("step","1"),J.setAttribute("value",String(this.time)),J.setAttribute("full",""),J.setAttribute("aria-label","Seek"),J.setAttribute("aria-valuetext",this.#X(this.time,this.duration));let j=document.createElement("span");j.className="fig-media-controls-time",j.textContent=this.#G(this.time);let _=(q)=>{let G=q.currentTarget,X=Number(G?.value);if(!Number.isFinite(X))return;this.#j=!0,this.setAttribute("time",String(X)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:X}})),requestAnimationFrame(()=>{this.#j=!1})};J.addEventListener("input",_),J.addEventListener("change",_),this.append(Q,J,j),this.#Z=Z,this.#Q=Q,this.#J=J,this.#$=j}#G(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let Z=Math.floor(Q),$=Math.floor(Z/60),J=Z%60;return`${String($).padStart(2,"0")}:${String(J).padStart(2,"0")}`}#X(Q,Z=0){let $=this.#G(Q);if(!Number.isFinite(Z)||Z<=0)return $;return`${$} of ${this.#G(Z)}`}#W(){if(!this.#Z)return;let Q=this.playing;this.#Z.setAttribute("aria-label",Q?"Pause":"Play"),this.#Q?.setAttribute("text",Q?"Pause":"Play");let Z=this.#Z.querySelector(".fig-media-controls-play-icon");if(Z)Z.setAttribute("name",Q?"pause":"play")}#Y(){if(!this.#J)return;let Q=this.duration;if(Number(this.#J.getAttribute("max"))!==Q)this.#J.setAttribute("max",String(Q));let Z=this.time;if(!this.#j)this.#J.setAttribute("value",String(Z));if(this.#J.setAttribute("aria-valuetext",this.#X(Z,Q)),this.#$)this.#$.textContent=this.#G(Z)}toggle(){let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.playing)return;this.toggle()}pause(){if(!this.playing)return;this.toggle()}}customElements.define("fig-media-controls",t0);class n0 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#Z=null;#Q=null;#J=null;#$=null;#j=null;#q=null;get files(){return this.#q}get#_(){let Q=this.getAttribute("filename");if(Q)return Q;let Z=this.getAttribute("url");if(!Z)return"";try{let J=new URL(Z,location.href).pathname.split("/").pop();return J?decodeURIComponent(J):Z}catch{return Z}}get value(){if(this.#q&&this.#q.length>0){if(this.#q.length===1)return this.#q[0].name;return`${this.#q.length} files`}return this.#_}connectedCallback(){this.#N(),this.addEventListener("dragover",this.#Y),this.addEventListener("dragleave",this.#K),this.addEventListener("drop",this.#U)}disconnectedCallback(){this.#Z?.removeEventListener("change",this.#X),this.#J?.removeEventListener("click",this.#W),this.removeEventListener("dragover",this.#Y),this.removeEventListener("dragleave",this.#K),this.removeEventListener("drop",this.#U)}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#N()}clear(){if(this.#q=null,this.#Z)this.#Z.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#N(),this.#G({cleared:!0})}#G(Q={}){let Z={files:this.#q,...Q};this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0}))}#X=()=>{if(this.#Z.files.length>0)this.#q=this.#Z.files,this.removeAttribute("url"),this.#N(),this.#G()};#W=(Q)=>{Q.stopPropagation(),this.clear()};#Y=(Q)=>{if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#j)this.#j.dataset.prevText=this.#j.textContent,this.#j.textContent="Drop file"}};#K=()=>{if(this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText};#U=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.getAttribute("accepts"),$=Array.from(Q.dataTransfer.files);if(Z){let j=Z.split(",").map((_)=>_.trim().toLowerCase());$=$.filter((_)=>{let q="."+_.name.split(".").pop().toLowerCase(),G=_.type.toLowerCase();return j.some((X)=>X===q||X===G||X.endsWith("/*")&&G.startsWith(X.slice(0,-1)))})}if(!this.hasAttribute("multiple"))$=$.slice(0,1);if($.length===0)return;let J=new DataTransfer;if($.forEach((j)=>J.items.add(j)),this.#q=J.files,this.#Z)this.#Z.files=J.files;this.removeAttribute("url"),this.#N(),this.#G()};#N(){let Q=this.getAttribute("accepts")||"",Z=this.getAttribute("label")||"Upload",$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.hasAttribute("multiple"),j=this.getAttribute("variant")||"input",_=this.#q&&this.#q.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",_){let q=Q?`Accepts ${Q.split(",").map((M)=>M.trim()).join(", ")}`:"";if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.className="fig-input-file-filename",$)this.#j.setAttribute("disabled","");let G=document.createElement("fig-truncate");G.setAttribute("position","middle"),G.setAttribute("tooltip","");let X=this.value,K=X.lastIndexOf(".");if(K>0)G.setAttribute("tail",X.slice(K));if(G.textContent=X,this.#j.appendChild(G),this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",Q)this.#Z.setAttribute("accept",Q);if(J)this.#Z.setAttribute("multiple","");if(this.#Z.addEventListener("change",this.#X),this.#j.appendChild(this.#Z),q)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",q),this.#$.appendChild(this.#j),this.appendChild(this.#$);else this.appendChild(this.#j);let N=document.createElement("fig-tooltip");if(N.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",$)this.#J.setAttribute("disabled","");this.#J.replaceChildren(v("minus")),this.#J.addEventListener("click",this.#W),N.appendChild(this.#J),this.appendChild(N)}else{let q=Q?`Accepts ${Q.split(",").map((G)=>G.trim()).join(", ")}`:"";if(q)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",q);if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.textContent=Z,$)this.#j.setAttribute("disabled","");if(this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",Q)this.#Z.setAttribute("accept",Q);if(J)this.#Z.setAttribute("multiple","");if(this.#Z.addEventListener("change",this.#X),this.#j.appendChild(this.#Z),this.#$)this.#$.appendChild(this.#j),this.appendChild(this.#$);else this.appendChild(this.#j)}}}customElements.define("fig-input-file",n0);class g extends HTMLElement{#Z={x:0.42,y:0};#Q={x:0.58,y:1};#J={stiffness:200,damping:15,mass:1};#$="bezier";#j=2;#q=null;#_=null;#G=null;#X=null;#W=null;#Y=null;#K=null;#U=null;#N=null;#L=null;#H=null;#B=null;#M=null;#F=0.8;#O=200;#A=200;#z=null;#P=null;#D=null;#E=5;#C=2;#R=10;#f=10;#S=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#j=parseInt(this.getAttribute("precision")||"2"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#k(Q);this.#B=this.#T(),this.#I(),this.#d()}disconnectedCallback(){if(this.#q=null,this.#D)this.#D.disconnect(),this.#D=null}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="aspect-ratio"){if(V(this,"--aspect-ratio",$),this.#_)this.#i(),this.#s();return}if(Q==="edit"){if(this.isConnected)this.#I();return}if(Q==="value"&&$){let J=this.#$;if(this.#k($),this.#B=this.#T(),J!==this.#$&&this.#w())this.#I();else{if(this.#_)this.#s();this.#n(),this.#r()}}if(Q==="precision")this.#j=parseInt($||"2")}get value(){if(this.#$==="spring"){let{stiffness:Z,damping:$,mass:J}=this.#J;return`spring(${Z}, ${$}, ${J})`}let Q=this.#j;return`${this.#Z.x.toFixed(Q)}, ${this.#Z.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}`}get cssValue(){if(this.#$==="spring"){let Z=this.#x(),$=20,J=Math.max(1,Math.floor(Z.length/20)),j=[];for(let _=0;_<Z.length;_+=J)j.push(Z[_].value.toFixed(3));if(Z.length>0)j.push(Z[Z.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#j;return`cubic-bezier(${this.#Z.x.toFixed(Q)}, ${this.#Z.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)})`}get preset(){return this.#B}set value(Q){this.setAttribute("value",Q)}#k(Q){let Z=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if(Z)return this.#$="spring",this.#J.stiffness=parseFloat(Z[1]),this.#J.damping=parseFloat(Z[2]),this.#J.mass=parseFloat(Z[3]),!0;let $=Q.split(",").map((J)=>parseFloat(J.trim()));if($.length>=4&&$.every((J)=>!isNaN(J)))return this.#$="bezier",this.#Z.x=$[0],this.#Z.y=$[1],this.#Q.x=$[2],this.#Q.y=$[3],!0;return!1}#T(){if(this.#$==="bezier"){for(let Z of g.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.#Q.x-Z.value[2])<0.001&&Math.abs(this.#Q.y-Z.value[3])<0.001)return Z.name}return"Custom bezier"}for(let Z of g.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)return Z.name}return"Custom spring"}#x(){let{stiffness:Q,damping:Z,mass:$}=this.#J,J=0.004,j=5,_=[],q=0,G=0;for(let X=0;X<=5;X+=0.004){let K=-Q*(q-1)-Z*G;if(G+=K/$*0.004,q+=G*0.004,_.push({t:X,value:q}),X>0.1&&Math.abs(q-1)<0.0005&&Math.abs(G)<0.0005)break}return _}static#g(Q,Z=24){let{stiffness:$,damping:J,mass:j}=Q,_=0.004,q=5,G=[],X=0,K=0;for(let B=0;B<=5;B+=0.004){let O=-$*(X-1)-J*K;if(K+=O/j*0.004,X+=K*0.004,G.push({t:B,value:X}),B>0.1&&Math.abs(X-1)<0.001&&Math.abs(K)<0.001)break}let N=G[G.length-1].t||1,M=1;for(let B of G)if(B.value>M)M=B.value;let L=0;for(let B of G)if(B.value<L)L=B.value;let z=Math.max(M-L,1),U=6,W=Z-U*2,R=Math.max(1,Math.floor(G.length/30)),H="";for(let B=0;B<G.length;B+=R){let O=U+G[B].t/N*W,T=U+(1-(G[B].value-L)/z)*W;H+=(B===0?"M":"L")+O.toFixed(1)+","+T.toFixed(1)}return`<svg width="${Z}" height="${Z}" viewBox="0 0 ${Z} ${Z}" fill="none"><path d="${H}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,Z,$,J,j=24){let q=(j-12)/2,G=48,X=[],K=(O,T,C,k,I)=>{let S=1-I;return S*S*S*O+3*S*S*I*T+3*S*I*I*C+I*I*I*k};for(let O=0;O<=48;O++){let T=O/48;X.push({x:K(0,Q,$,1,T),y:K(0,Z,J,1,T)})}let N=1/0,M=-1/0,L=1/0,z=-1/0;for(let O of X){if(O.x<N)N=O.x;if(O.x>M)M=O.x;if(O.y<L)L=O.y;if(O.y>z)z=O.y}let U=Math.max(M-N,0.000001),W=Math.max(z-L,0.000001),R=(O)=>q+(O-N)/U*12,H=(O)=>q+(1-(O-L)/W)*12,B="";for(let O=0;O<X.length;O++){let T=R(X[O].x),C=H(X[O].y);B+=`${O===0?"M":"L"}${T.toFixed(1)},${C.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${B}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#w(){return this.getAttribute("edit")!=="false"}#I(){if(this.classList.toggle("spring-mode",this.#$==="spring"),this.classList.toggle("bezier-mode",this.#$!=="spring"),this.#b(),this.innerHTML=this.#h(),this.#p(),this.#_)this.#m(),this.#i(),this.#s();this.#r(),this.#L0()}static#V(Q){return String(Q).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#y(){let Q="",Z=void 0;for(let $ of g.PRESETS){if(!this.#w()&&!$.value&&!$.spring)continue;if($.group!==Z){if(Z!==void 0)Q+="</optgroup>";if($.group)Q+=`<optgroup label="${$.group}">`;Z=$.group}let J;if($.type==="spring"){let _=$.spring||this.#J;J=g.#g(_)}else{let _=$.value||[this.#Z.x,this.#Z.y,this.#Q.x,this.#Q.y];J=g.curveIcon(..._)}let j=$.name===this.#B?" selected":"";Q+=`<option value="${$.name}"${j}>${J} ${$.name}</option>`}if(Z)Q+="</optgroup>";return`<fig-dropdown class="fig-easing-curve-dropdown" full experimental="modern">${Q}</fig-dropdown>`}#h(){let Z=this.#y();if(!this.#w())return Z;let $=`<fig-input-text class="fig-easing-curve-value-input" value="${g.#V(this.value)}" full></fig-input-text>`;if(this.#$==="spring")return`${Z}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
200
190
  <rect class="fig-easing-curve-bounds" x="0" y="0" width="200" height="200"/>
201
191
  <line class="fig-easing-curve-target" x1="0" y1="40" x2="200" y2="40"/>
202
192
  <line class="fig-easing-curve-diagonal" x1="0" y1="180" x2="0" y2="180"/>
@@ -209,11 +199,11 @@ var A1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var F1={};var L0=A1(()=>{/*! Vendored from @
209
199
  <line class="fig-easing-curve-arm" data-arm="1"/>
210
200
  <line class="fig-easing-curve-arm" data-arm="2"/>
211
201
  <path class="fig-easing-curve-path"/>
212
- <circle class="fig-easing-curve-endpoint" data-endpoint="start" r="${this.#k}"/>
213
- <circle class="fig-easing-curve-endpoint" data-endpoint="end" r="${this.#k}"/>
202
+ <circle class="fig-easing-curve-endpoint" data-endpoint="start" r="${this.#C}"/>
203
+ <circle class="fig-easing-curve-endpoint" data-endpoint="end" r="${this.#C}"/>
214
204
  <foreignObject class="fig-easing-curve-handle" data-handle="1" width="20" height="20"><fig-handle size="small" drag aria-label="First easing control point"></fig-handle></foreignObject>
215
205
  <foreignObject class="fig-easing-curve-handle" data-handle="2" width="20" height="20"><fig-handle size="small" drag aria-label="Second easing control point"></fig-handle></foreignObject>
216
- </svg></div>${$}`}#b(Q,Z){let $=getComputedStyle(this).getPropertyValue(Q).trim();if(!$)return Z;let J=Number.parseFloat($);return Number.isFinite(J)?J:Z}#x(){this.#k=this.#b("--easing-bezier-endpoint-radius",this.#k),this.#C=this.#b("--easing-duration-bar-radius",this.#C)}#m(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#G=this.querySelector(".fig-easing-curve-path"),this.#X=this.querySelector('[data-arm="1"]'),this.#W=this.querySelector('[data-arm="2"]'),this.#Y=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#K=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#U=this.querySelector('[data-endpoint="start"]'),this.#N=this.querySelector('[data-endpoint="end"]'),this.#L=this.querySelector(".fig-easing-curve-dropdown"),this.#O=this.querySelector(".fig-easing-curve-value-input"),this.#M=this.querySelector(".fig-easing-curve-target"),this.#H=this.querySelector(".fig-easing-curve-bounds"),this.#R=this.querySelector(".fig-easing-curve-diagonal")}#u(){let Q=this.#Y?.querySelector("fig-handle"),Z=this.#K?.querySelector("fig-handle");if(Q){let $=Q.offsetWidth||this.#S*2,J=Q.offsetHeight||this.#S*2;this.#S=Math.max($,J)/2,this.#Y.setAttribute("width",$),this.#Y.setAttribute("height",J)}if(Z){let $=Z.offsetWidth||this.#f,J=Z.offsetHeight||this.#T;if(this.#$==="spring")this.#f=$,this.#T=J;this.#K.setAttribute("width",$),this.#K.setAttribute("height",J)}}#d(){if(this.#F||!window.ResizeObserver)return;this.#F=new ResizeObserver(()=>{if(this.#s())this.#p()}),this.#F.observe(this)}#s(){if(!this.#_)return!1;let Q=this.#_.getBoundingClientRect(),Z=Math.max(1,Math.round(Q.width||200)),$=Math.max(1,Math.round(Q.height||200)),J=Z!==this.#A||$!==this.#D;return this.#A=Z,this.#D=$,this.#_.setAttribute("viewBox",`0 0 ${Z} ${$}`),J}#t(Q,Z){return{x:Q*this.#A,y:(1-Z)*this.#D}}#Q0(Q,Z){return{x:Q/this.#A,y:1-Z/this.#D}}#o={minVal:0,maxVal:1.2,totalTime:1};#i(Q,Z){let J=this.#D-40,{minVal:j,maxVal:_}=this.#o,q=_-j||1;return{x:Q*this.#A,y:20+(1-(Z-j)/q)*J}}#p(){if(this.#s(),this.#$==="spring")this.#J0();else this.#Z0()}#e(){this.#X?.classList.toggle("is-active",this.#$==="bezier"&&this.#q===1),this.#W?.classList.toggle("is-active",this.#$==="bezier"&&this.#q===2)}#Z0(){if(this.#H)this.#H.setAttribute("x","0"),this.#H.setAttribute("y","0"),this.#H.setAttribute("width",this.#A),this.#H.setAttribute("height",this.#D);if(this.#R)this.#R.setAttribute("x1","0"),this.#R.setAttribute("y1",this.#D),this.#R.setAttribute("x2",this.#A),this.#R.setAttribute("y2","0");let Q=this.#t(0,0),Z=this.#t(this.#Z.x,this.#Z.y),$=this.#t(this.#Q.x,this.#Q.y),J=this.#t(1,1);this.#G.setAttribute("d",`M${Q.x},${Q.y} C${Z.x},${Z.y} ${$.x},${$.y} ${J.x},${J.y}`),this.#X.setAttribute("x1",Q.x),this.#X.setAttribute("y1",Q.y),this.#X.setAttribute("x2",Z.x),this.#X.setAttribute("y2",Z.y),this.#W.setAttribute("x1",J.x),this.#W.setAttribute("y1",J.y),this.#W.setAttribute("x2",$.x),this.#W.setAttribute("y2",$.y);let j=this.#S;if(this.#Y.setAttribute("x",Z.x-j),this.#Y.setAttribute("y",Z.y-j),this.#K.setAttribute("x",$.x-j),this.#K.setAttribute("y",$.y-j),this.#U)this.#U.setAttribute("cx",Q.x),this.#U.setAttribute("cy",Q.y);if(this.#N)this.#N.setAttribute("cx",J.x),this.#N.setAttribute("cy",J.y);this.#$0()}#$0(){if(!this.#_||!this.#Y||!this.#K)return;let Q=this.#Z.y>=this.#Q.y?[this.#Y,this.#K]:[this.#K,this.#Y];for(let Z of Q)this.#_.append(Z)}#J0(){if(this.#H)this.#H.setAttribute("x","0"),this.#H.setAttribute("y","0"),this.#H.setAttribute("width",this.#A),this.#H.setAttribute("height",this.#D);let Q=this.#I();if(!Q.length)return;let Z=Q[Q.length-1].t||1,$=0,J=1;for(let W of Q){if(W.value<$)$=W.value;if(W.value>J)J=W.value}let j=Math.max(Math.abs($-1),Math.abs(J-1),0.01),_=0;this.#o={minVal:1-j-_,maxVal:1+j+_,totalTime:Z};let q=Math.max(0.05,Math.min(0.95,this.#z)),G="";for(let W=0;W<Q.length;W++){let R=Q[W].t/Z*q,z=this.#i(R,Q[W].value);G+=(W===0?"M":"L")+z.x.toFixed(1)+","+z.y.toFixed(1)}let X=this.#i(q,1),K=this.#i(1,1);if(G+=`L${X.x.toFixed(1)},${X.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#G.setAttribute("d",G),this.#M){let W=this.#i(0,1),R=this.#i(1,1);this.#M.setAttribute("x1",W.x),this.#M.setAttribute("y1",W.y),this.#M.setAttribute("x2",R.x),this.#M.setAttribute("y2",R.y)}let N=this.#j0(Q),B=N.t/Z*q,L=this.#i(B,N.value),A=this.#S;this.#Y.setAttribute("x",L.x-A),this.#Y.setAttribute("y",L.y-A);let U=this.#i(q,1);this.#K.setAttribute("x",U.x-this.#f/2),this.#K.setAttribute("y",U.y-this.#T/2)}#j0(Q){let Z={t:0,value:1},$=!1;for(let J of Q){if(J.value>=0.99)$=!0;if($&&J.value>Z.value)Z={t:J.t,value:J.value}}return Z}#a(){if(!this.#L)return;this.#L.value=this.#B,this.#N0()}#c(){if(!this.#O)return;this.#O.setAttribute("value",this.value)}#n(Q){let Z=Q.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}#l(Q,Z){let $=this.#n(Q);if(!$){if(Z==="change")this.#c();return}let J=this.#$;if(this.#$="bezier",this.#Z.x=$[0],this.#Z.y=$[1],this.#Q.x=$[2],this.#Q.y=$[3],this.#B=this.#P(),J!==this.#$)this.#y();else if(this.#p(),this.#a(),Z==="change")this.#c();this.#r(Z)}#_0(Q,Z,$){if(!Q)return;for(let J of Q.querySelectorAll("option"))if(J.value===Z)J.innerHTML=`${$} ${Z}`}#N0(){if(!this.#L)return;if(!this.#V())return;let Q=g.curveIcon(this.#Z.x,this.#Z.y,this.#Q.x,this.#Q.y),Z=g.#g(this.#J);this.#_0(this.#L,"Custom bezier",Q),this.#_0(this.#L,"Custom spring",Z),this.#_0(this.#L.select,"Custom bezier",Q),this.#_0(this.#L.select,"Custom spring",Z)}#K0(Q){this.#p(),this.#B=this.#P(),this.#a(),this.#c(),this.#r(Q)}#W0(Q,Z){let $=Q.shiftKey?0.1:0.01,J=Z===1?this.#Z:this.#Q;switch(Q.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.#K0("input"),this.#r("change"),!0}#U0(Q,Z){let $=Q.shiftKey?10:1;if(Z==="bounce")switch(Q.key){case"ArrowUp":this.#J.damping=Math.max(1,Math.round(this.#J.damping-$));break;case"ArrowDown":this.#J.damping=Math.max(1,Math.round(this.#J.damping+$));break;case"Home":this.#J.damping=1;break;case"End":this.#J.damping=50;break;default:return!1}else{let J=$*2;switch(Q.key){case"ArrowLeft":this.#z=Math.max(0.05,this.#z-J/200),this.#J.stiffness=Math.max(10,Math.round(this.#J.stiffness+J*1.5));break;case"ArrowRight":this.#z=Math.min(0.95,this.#z+J/200),this.#J.stiffness=Math.max(10,Math.round(this.#J.stiffness-J*1.5));break;case"Home":this.#z=0.05;break;case"End":this.#z=0.95;break;default:return!1}}return this.#K0("input"),this.#r("change"),!0}#q0(Q,Z){let $=Q?.querySelector("fig-handle");if(!$)return;$.addEventListener("pointerdown",(J)=>{if(J.preventDefault(),J.stopImmediatePropagation(),this.#$==="bezier")this.#G0(J,Number(Z));else this.#X0(J,Z)},{capture:!0}),$.addEventListener("keydown",(J)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(J.key))return;if(!(this.#$==="bezier"?this.#W0(J,Number(Z)):this.#U0(J,Z)))return;J.preventDefault(),J.stopImmediatePropagation()},{capture:!0})}#r(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#$,value:this.value,cssValue:this.cssValue,preset:this.#B}}))}#L0(){if(this.#_&&this.#$==="bezier"){this.#q0(this.#Y,"1"),this.#q0(this.#K,"2"),this.#Y.addEventListener("pointerdown",(Z)=>this.#G0(Z,1)),this.#K.addEventListener("pointerdown",(Z)=>this.#G0(Z,2));let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#G0(Z,this.#B0(Z))})}else if(this.#_){this.#q0(this.#Y,"bounce"),this.#q0(this.#K,"duration"),this.#Y.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#X0(Z,"bounce")}),this.#K.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#X0(Z,"duration")});let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#X0(Z,"duration")})}if(this.#L)this.#L.addEventListener("change",(Q)=>{let Z=Q.detail,$=g.PRESETS.find((J)=>J.name===Z);if(!$)return;if($.type==="bezier"){if($.value)this.#Z.x=$.value[0],this.#Z.y=$.value[1],this.#Q.x=$.value[2],this.#Q.y=$.value[3];if(this.#B=Z,this.#$!=="bezier")this.#$="bezier",this.#y();else if(this.#_)this.#p(),this.#c()}else if($.type==="spring"){if($.spring)this.#J={...$.spring};if(this.#B=Z,this.#$!=="spring")this.#$="spring",this.#y();else if(this.#_)this.#p(),this.#c()}this.#r("input"),this.#r("change")});if(this.#O)this.#O.addEventListener("input",(Q)=>{Q.stopPropagation();let Z=Q.detail??Q.target?.value;if(typeof Z!=="string")return;this.#l(Z,"input")}),this.#O.addEventListener("change",(Q)=>{Q.stopPropagation();let Z=Q.detail??Q.target?.value;if(typeof Z!=="string")return;this.#l(Z,"change")})}#Y0(Q){let Z=this.#_.getScreenCTM();if(!Z)return{x:0,y:0};let $=Z.inverse();return{x:$.a*Q.clientX+$.c*Q.clientY+$.e,y:$.b*Q.clientX+$.d*Q.clientY+$.f}}#B0(Q){return this.#Y0(Q).x<=this.#A/2?1:2}#G0(Q,Z){Q.preventDefault(),this.#q=Z,this.#e();let $=(j)=>{if(!this.#q)return;let _=this.#Y0(j),q=this.#Q0(_.x,_.y);if(q.x=Math.round(q.x*100)/100,q.y=Math.round(q.y*100)/100,q.x=Math.max(0,Math.min(1,q.x)),this.#q===1)this.#Z.x=q.x,this.#Z.y=q.y;else this.#Q.x=q.x,this.#Q.y=q.y;this.#p(),this.#B=this.#P(),this.#a(),this.#c(),this.#r("input")},J=()=>{this.#q=null,this.#e(),document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",J),this.#r("change")};document.addEventListener("pointermove",$),document.addEventListener("pointerup",J)}#X0(Q,Z){Q.preventDefault(),this.#q=Z;let $=this.#J.damping,J=this.#J.stiffness,j=this.#z,_=Q.clientY,q=Q.clientX,G=(K)=>{if(!this.#q)return;if(Z==="bounce"){let N=K.clientY-_;this.#J.damping=Math.max(1,Math.round($+N*0.15))}else{let N=K.clientX-q;this.#z=Math.max(0.05,Math.min(0.95,j+N/200)),this.#J.stiffness=Math.max(10,Math.round(J-N*1.5))}this.#p(),this.#B=this.#P(),this.#a(),this.#c(),this.#r("input")},X=()=>{this.#q=null,document.removeEventListener("pointermove",G),document.removeEventListener("pointerup",X),this.#r("change")};document.addEventListener("pointermove",G),document.addEventListener("pointerup",X)}}customElements.define("fig-easing-curve",g);class l0 extends HTMLElement{#Z=0;#Q=0;#J=0;#$=1;#j=!1;#q=!1;#_=null;#G=null;#X=null;#W=null;#Y=(Q)=>this.#P(Q);#K=null;#U=[];#N={};#L={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#$=parseInt(this.getAttribute("precision")||"1"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),V(this,"--perspective",this.getAttribute("perspective")),V(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#M(this.getAttribute("transform-origin")),this.#D(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#H(Q);if(this.querySelector(".fig-3d-rotate-container"))this.#O();else this.#R();this.#A(this.getAttribute("selected")),this.#z()}disconnectedCallback(){this.#j=!1,this.#B()}#O(){this.#G=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#F(),this.#k(),this.#C()}#B(){if(this.#K?.abort(),this.#K=null,this.#X)window.removeEventListener("keydown",this.#X),window.removeEventListener("keyup",this.#W),this.#X=null,this.#W=null}#M(Q){if(!Q||!Q.trim()){this.style.removeProperty("--transform-origin");return}let Z=Q.trim().split(/\s+/);if(Z.length===2)this.style.setProperty("--transform-origin",`${Z[0]} ${Z[1]} -50cqi`);else this.style.setProperty("--transform-origin",Q.trim())}#z(){if(!this.#G)return;this.#G.style.cursor=this.#E?"":"default"}#A(Q){if(!this.#_)return;let Z=this.#_.querySelectorAll(".fig-3d-rotate-face"),$=Q?Q.trim().toLowerCase():"";for(let J of Z)J.classList.toggle("selected",$!==""&&J.classList.contains($))}#D(Q){if(!Q||!Q.trim()){this.#U=[];return}let Z=["rotateX","rotateY","rotateZ"];this.#U=Q.split(",").map(($)=>$.trim()).filter(($)=>Z.includes($))}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",$);return}if(Q==="perspective"){V(this,"--perspective",$);return}if(Q==="perspective-origin"){V(this,"--perspective-origin",$);return}if(Q==="transform-origin"){this.#M($);return}if(Q==="selected"){this.#A($);return}if(Q==="drag"){this.#z();return}if(Q==="fields"){if(this.#D($),this.#_)this.#R();return}if(!this.#_)return;if(Q==="value"&&$){if(this.#j)return;this.#H($),this.#k(),this.#S()}if(Q==="precision")this.#$=parseInt($||"1")}get value(){let Q=this.#$;return`rotateX(${this.#Z.toFixed(Q)}deg) rotateY(${this.#Q.toFixed(Q)}deg) rotateZ(${this.#J.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#Z}get rotateY(){return this.#Q}get rotateZ(){return this.#J}#H(Q){let Z=Q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),$=Q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),J=Q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if(Z)this.#Z=parseFloat(Z[1]);if($)this.#Q=parseFloat($[1]);if(J)this.#J=parseFloat(J[1])}#R(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},Z={rotateX:this.#Z,rotateY:this.#Q,rotateZ:this.#J},$=this.#U.map((J)=>`<fig-input-number
206
+ </svg></div>${$}`}#v(Q,Z){let $=getComputedStyle(this).getPropertyValue(Q).trim();if(!$)return Z;let J=Number.parseFloat($);return Number.isFinite(J)?J:Z}#b(){this.#C=this.#v("--easing-bezier-endpoint-radius",this.#C),this.#S=this.#v("--easing-duration-bar-radius",this.#S)}#p(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#G=this.querySelector(".fig-easing-curve-path"),this.#X=this.querySelector('[data-arm="1"]'),this.#W=this.querySelector('[data-arm="2"]'),this.#Y=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#K=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#U=this.querySelector('[data-endpoint="start"]'),this.#N=this.querySelector('[data-endpoint="end"]'),this.#L=this.querySelector(".fig-easing-curve-dropdown"),this.#H=this.querySelector(".fig-easing-curve-value-input"),this.#M=this.querySelector(".fig-easing-curve-target"),this.#z=this.querySelector(".fig-easing-curve-bounds"),this.#P=this.querySelector(".fig-easing-curve-diagonal")}#m(){let Q=this.#Y?.querySelector("fig-handle"),Z=this.#K?.querySelector("fig-handle");if(Q){let $=Q.offsetWidth||this.#E*2,J=Q.offsetHeight||this.#E*2;this.#E=Math.max($,J)/2,this.#Y.setAttribute("width",$),this.#Y.setAttribute("height",J)}if(Z){let $=Z.offsetWidth||this.#R,J=Z.offsetHeight||this.#f;if(this.#$==="spring")this.#R=$,this.#f=J;this.#K.setAttribute("width",$),this.#K.setAttribute("height",J)}}#d(){if(this.#D||!window.ResizeObserver)return;this.#D=new ResizeObserver(()=>{if(this.#i())this.#s()}),this.#D.observe(this)}#i(){if(!this.#_)return!1;let Q=this.#_.getBoundingClientRect(),Z=Math.max(1,Math.round(Q.width||200)),$=Math.max(1,Math.round(Q.height||200)),J=Z!==this.#O||$!==this.#A;return this.#O=Z,this.#A=$,this.#_.setAttribute("viewBox",`0 0 ${Z} ${$}`),J}#l(Q,Z){return{x:Q*this.#O,y:(1-Z)*this.#A}}#t(Q,Z){return{x:Q/this.#O,y:1-Z/this.#A}}#u={minVal:0,maxVal:1.2,totalTime:1};#c(Q,Z){let J=this.#A-40,{minVal:j,maxVal:_}=this.#u,q=_-j||1;return{x:Q*this.#O,y:20+(1-(Z-j)/q)*J}}#s(){if(this.#i(),this.#$==="spring")this.#J0();else this.#Z0()}#Q0(){this.#X?.classList.toggle("is-active",this.#$==="bezier"&&this.#q===1),this.#W?.classList.toggle("is-active",this.#$==="bezier"&&this.#q===2)}#Z0(){if(this.#z)this.#z.setAttribute("x","0"),this.#z.setAttribute("y","0"),this.#z.setAttribute("width",this.#O),this.#z.setAttribute("height",this.#A);if(this.#P)this.#P.setAttribute("x1","0"),this.#P.setAttribute("y1",this.#A),this.#P.setAttribute("x2",this.#O),this.#P.setAttribute("y2","0");let Q=this.#l(0,0),Z=this.#l(this.#Z.x,this.#Z.y),$=this.#l(this.#Q.x,this.#Q.y),J=this.#l(1,1);this.#G.setAttribute("d",`M${Q.x},${Q.y} C${Z.x},${Z.y} ${$.x},${$.y} ${J.x},${J.y}`),this.#X.setAttribute("x1",Q.x),this.#X.setAttribute("y1",Q.y),this.#X.setAttribute("x2",Z.x),this.#X.setAttribute("y2",Z.y),this.#W.setAttribute("x1",J.x),this.#W.setAttribute("y1",J.y),this.#W.setAttribute("x2",$.x),this.#W.setAttribute("y2",$.y);let j=this.#E;if(this.#Y.setAttribute("x",Z.x-j),this.#Y.setAttribute("y",Z.y-j),this.#K.setAttribute("x",$.x-j),this.#K.setAttribute("y",$.y-j),this.#U)this.#U.setAttribute("cx",Q.x),this.#U.setAttribute("cy",Q.y);if(this.#N)this.#N.setAttribute("cx",J.x),this.#N.setAttribute("cy",J.y);this.#$0()}#$0(){if(!this.#_||!this.#Y||!this.#K)return;let Q=this.#Z.y>=this.#Q.y?[this.#Y,this.#K]:[this.#K,this.#Y];for(let Z of Q)this.#_.append(Z)}#J0(){if(this.#z)this.#z.setAttribute("x","0"),this.#z.setAttribute("y","0"),this.#z.setAttribute("width",this.#O),this.#z.setAttribute("height",this.#A);let Q=this.#x();if(!Q.length)return;let Z=Q[Q.length-1].t||1,$=0,J=1;for(let W of Q){if(W.value<$)$=W.value;if(W.value>J)J=W.value}let j=Math.max(Math.abs($-1),Math.abs(J-1),0.01),_=0;this.#u={minVal:1-j-_,maxVal:1+j+_,totalTime:Z};let q=Math.max(0.05,Math.min(0.95,this.#F)),G="";for(let W=0;W<Q.length;W++){let R=Q[W].t/Z*q,H=this.#c(R,Q[W].value);G+=(W===0?"M":"L")+H.x.toFixed(1)+","+H.y.toFixed(1)}let X=this.#c(q,1),K=this.#c(1,1);if(G+=`L${X.x.toFixed(1)},${X.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#G.setAttribute("d",G),this.#M){let W=this.#c(0,1),R=this.#c(1,1);this.#M.setAttribute("x1",W.x),this.#M.setAttribute("y1",W.y),this.#M.setAttribute("x2",R.x),this.#M.setAttribute("y2",R.y)}let N=this.#j0(Q),M=N.t/Z*q,L=this.#c(M,N.value),z=this.#E;this.#Y.setAttribute("x",L.x-z),this.#Y.setAttribute("y",L.y-z);let U=this.#c(q,1);this.#K.setAttribute("x",U.x-this.#R/2),this.#K.setAttribute("y",U.y-this.#f/2)}#j0(Q){let Z={t:0,value:1},$=!1;for(let J of Q){if(J.value>=0.99)$=!0;if($&&J.value>Z.value)Z={t:J.t,value:J.value}}return Z}#n(){if(!this.#L)return;this.#L.value=this.#B,this.#N0()}#r(){if(!this.#H)return;this.#H.setAttribute("value",this.value)}#e(Q){let Z=Q.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}#a(Q,Z){let $=this.#e(Q);if(!$){if(Z==="change")this.#r();return}let J=this.#$;if(this.#$="bezier",this.#Z.x=$[0],this.#Z.y=$[1],this.#Q.x=$[2],this.#Q.y=$[3],this.#B=this.#T(),J!==this.#$)this.#I();else if(this.#s(),this.#n(),Z==="change")this.#r();this.#o(Z)}#_0(Q,Z,$){if(!Q)return;for(let J of Q.querySelectorAll("option"))if(J.value===Z)J.innerHTML=`${$} ${Z}`}#N0(){if(!this.#L)return;if(!this.#w())return;let Q=g.curveIcon(this.#Z.x,this.#Z.y,this.#Q.x,this.#Q.y),Z=g.#g(this.#J);this.#_0(this.#L,"Custom bezier",Q),this.#_0(this.#L,"Custom spring",Z),this.#_0(this.#L.select,"Custom bezier",Q),this.#_0(this.#L.select,"Custom spring",Z)}#K0(Q){this.#s(),this.#B=this.#T(),this.#n(),this.#r(),this.#o(Q)}#W0(Q,Z){let $=Q.shiftKey?0.1:0.01,J=Z===1?this.#Z:this.#Q;switch(Q.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.#K0("input"),this.#o("change"),!0}#U0(Q,Z){let $=Q.shiftKey?10:1;if(Z==="bounce")switch(Q.key){case"ArrowUp":this.#J.damping=Math.max(1,Math.round(this.#J.damping-$));break;case"ArrowDown":this.#J.damping=Math.max(1,Math.round(this.#J.damping+$));break;case"Home":this.#J.damping=1;break;case"End":this.#J.damping=50;break;default:return!1}else{let J=$*2;switch(Q.key){case"ArrowLeft":this.#F=Math.max(0.05,this.#F-J/200),this.#J.stiffness=Math.max(10,Math.round(this.#J.stiffness+J*1.5));break;case"ArrowRight":this.#F=Math.min(0.95,this.#F+J/200),this.#J.stiffness=Math.max(10,Math.round(this.#J.stiffness-J*1.5));break;case"Home":this.#F=0.05;break;case"End":this.#F=0.95;break;default:return!1}}return this.#K0("input"),this.#o("change"),!0}#q0(Q,Z){let $=Q?.querySelector("fig-handle");if(!$)return;$.addEventListener("pointerdown",(J)=>{if(J.preventDefault(),J.stopImmediatePropagation(),this.#$==="bezier")this.#G0(J,Number(Z));else this.#X0(J,Z)},{capture:!0}),$.addEventListener("keydown",(J)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(J.key))return;if(!(this.#$==="bezier"?this.#W0(J,Number(Z)):this.#U0(J,Z)))return;J.preventDefault(),J.stopImmediatePropagation()},{capture:!0})}#o(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#$,value:this.value,cssValue:this.cssValue,preset:this.#B}}))}#L0(){if(this.#_&&this.#$==="bezier"){this.#q0(this.#Y,"1"),this.#q0(this.#K,"2"),this.#Y.addEventListener("pointerdown",(Z)=>this.#G0(Z,1)),this.#K.addEventListener("pointerdown",(Z)=>this.#G0(Z,2));let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#G0(Z,this.#B0(Z))})}else if(this.#_){this.#q0(this.#Y,"bounce"),this.#q0(this.#K,"duration"),this.#Y.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#X0(Z,"bounce")}),this.#K.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#X0(Z,"duration")});let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#X0(Z,"duration")})}if(this.#L)this.#L.addEventListener("change",(Q)=>{let Z=Q.detail,$=g.PRESETS.find((J)=>J.name===Z);if(!$)return;if($.type==="bezier"){if($.value)this.#Z.x=$.value[0],this.#Z.y=$.value[1],this.#Q.x=$.value[2],this.#Q.y=$.value[3];if(this.#B=Z,this.#$!=="bezier")this.#$="bezier",this.#I();else if(this.#_)this.#s(),this.#r()}else if($.type==="spring"){if($.spring)this.#J={...$.spring};if(this.#B=Z,this.#$!=="spring")this.#$="spring",this.#I();else if(this.#_)this.#s(),this.#r()}this.#o("input"),this.#o("change")});if(this.#H)this.#H.addEventListener("input",(Q)=>{Q.stopPropagation();let Z=Q.detail??Q.target?.value;if(typeof Z!=="string")return;this.#a(Z,"input")}),this.#H.addEventListener("change",(Q)=>{Q.stopPropagation();let Z=Q.detail??Q.target?.value;if(typeof Z!=="string")return;this.#a(Z,"change")})}#Y0(Q){let Z=this.#_.getScreenCTM();if(!Z)return{x:0,y:0};let $=Z.inverse();return{x:$.a*Q.clientX+$.c*Q.clientY+$.e,y:$.b*Q.clientX+$.d*Q.clientY+$.f}}#B0(Q){return this.#Y0(Q).x<=this.#O/2?1:2}#G0(Q,Z){Q.preventDefault(),this.#q=Z,this.#Q0();let $=(j)=>{if(!this.#q)return;let _=this.#Y0(j),q=this.#t(_.x,_.y);if(q.x=Math.round(q.x*100)/100,q.y=Math.round(q.y*100)/100,q.x=Math.max(0,Math.min(1,q.x)),this.#q===1)this.#Z.x=q.x,this.#Z.y=q.y;else this.#Q.x=q.x,this.#Q.y=q.y;this.#s(),this.#B=this.#T(),this.#n(),this.#r(),this.#o("input")},J=()=>{this.#q=null,this.#Q0(),document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",J),this.#o("change")};document.addEventListener("pointermove",$),document.addEventListener("pointerup",J)}#X0(Q,Z){Q.preventDefault(),this.#q=Z;let $=this.#J.damping,J=this.#J.stiffness,j=this.#F,_=Q.clientY,q=Q.clientX,G=(K)=>{if(!this.#q)return;if(Z==="bounce"){let N=K.clientY-_;this.#J.damping=Math.max(1,Math.round($+N*0.15))}else{let N=K.clientX-q;this.#F=Math.max(0.05,Math.min(0.95,j+N/200)),this.#J.stiffness=Math.max(10,Math.round(J-N*1.5))}this.#s(),this.#B=this.#T(),this.#n(),this.#r(),this.#o("input")},X=()=>{this.#q=null,document.removeEventListener("pointermove",G),document.removeEventListener("pointerup",X),this.#o("change")};document.addEventListener("pointermove",G),document.addEventListener("pointerup",X)}}customElements.define("fig-easing-curve",g);class e0 extends HTMLElement{#Z=0;#Q=0;#J=0;#$=1;#j=!1;#q=!1;#_=null;#G=null;#X=null;#W=null;#Y=(Q)=>this.#T(Q);#K=null;#U=[];#N={};#L={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#$=parseInt(this.getAttribute("precision")||"1"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),V(this,"--perspective",this.getAttribute("perspective")),V(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#M(this.getAttribute("transform-origin")),this.#A(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#z(Q);if(this.querySelector(".fig-3d-rotate-container"))this.#H();else this.#P();this.#O(this.getAttribute("selected")),this.#F()}disconnectedCallback(){this.#j=!1,this.#B()}#H(){this.#G=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#D(),this.#C(),this.#S()}#B(){if(this.#K?.abort(),this.#K=null,this.#X)window.removeEventListener("keydown",this.#X),window.removeEventListener("keyup",this.#W),this.#X=null,this.#W=null}#M(Q){if(!Q||!Q.trim()){this.style.removeProperty("--transform-origin");return}let Z=Q.trim().split(/\s+/);if(Z.length===2)this.style.setProperty("--transform-origin",`${Z[0]} ${Z[1]} -50cqi`);else this.style.setProperty("--transform-origin",Q.trim())}#F(){if(!this.#G)return;this.#G.style.cursor=this.#k?"":"default"}#O(Q){if(!this.#_)return;let Z=this.#_.querySelectorAll(".fig-3d-rotate-face"),$=Q?Q.trim().toLowerCase():"";for(let J of Z)J.classList.toggle("selected",$!==""&&J.classList.contains($))}#A(Q){if(!Q||!Q.trim()){this.#U=[];return}let Z=["rotateX","rotateY","rotateZ"];this.#U=Q.split(",").map(($)=>$.trim()).filter(($)=>Z.includes($))}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",$);return}if(Q==="perspective"){V(this,"--perspective",$);return}if(Q==="perspective-origin"){V(this,"--perspective-origin",$);return}if(Q==="transform-origin"){this.#M($);return}if(Q==="selected"){this.#O($);return}if(Q==="drag"){this.#F();return}if(Q==="fields"){if(this.#A($),this.#_)this.#P();return}if(!this.#_)return;if(Q==="value"&&$){if(this.#j)return;this.#z($),this.#C(),this.#E()}if(Q==="precision")this.#$=parseInt($||"1")}get value(){let Q=this.#$;return`rotateX(${this.#Z.toFixed(Q)}deg) rotateY(${this.#Q.toFixed(Q)}deg) rotateZ(${this.#J.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#Z}get rotateY(){return this.#Q}get rotateZ(){return this.#J}#z(Q){let Z=Q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),$=Q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),J=Q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if(Z)this.#Z=parseFloat(Z[1]);if($)this.#Q=parseFloat($[1]);if(J)this.#J=parseFloat(J[1])}#P(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},Z={rotateX:this.#Z,rotateY:this.#Q,rotateZ:this.#J},$=this.#U.map((J)=>`<fig-input-number
217
207
  name="${J}"
218
208
  step="1"
219
209
  precision="1"
@@ -231,9 +221,9 @@ var A1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var F1={};var L0=A1(()=>{/*! Vendored from @
231
221
  <div class="fig-3d-rotate-face bottom"></div>
232
222
  </div>
233
223
  </div>
234
- </div>${$}`,this.#G=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#F(),this.#k(),this.#C()}#F(){this.#N={};for(let Q of this.#U){let Z=this.querySelector(`fig-input-number[name="${Q}"]`);if(!Z)continue;if(this.#N[Q]=Z,!this.#L[Q])this.#L[Q]=(J)=>{J.stopPropagation();let j=parseFloat(J.target.value);if(isNaN(j))return;if(Q==="rotateX")this.#Z=j;else if(Q==="rotateY")this.#Q=j;else if(Q==="rotateZ")this.#J=j;this.#k(),this.#f(J.type)};let $=this.#L[Q];Z.removeEventListener("input",$),Z.removeEventListener("change",$),Z.addEventListener("input",$),Z.addEventListener("change",$)}}#S(){let Q={rotateX:this.#Z,rotateY:this.#Q,rotateZ:this.#J};for(let Z of this.#U){let $=this.#N[Z];if($)$.setAttribute("value",Q[Z].toFixed(this.#$))}}#k(){if(!this.#_)return;this.#_.style.transform=`rotateX(${this.#Z}deg) rotateY(${this.#Q}deg) rotateZ(${this.#J}deg)`}#f(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#Z,rotateY:this.#Q,rotateZ:this.#J}}))}#T(Q){if(!this.#q)return Q;return Math.round(Q/15)*15}#C(){if(this.#B(),!this.#G)return;this.#K=new AbortController,this.#G.addEventListener("pointerdown",this.#Y,{signal:this.#K.signal}),this.#X=(Q)=>{if(Q.key==="Shift")this.#q=!0},this.#W=(Q)=>{if(Q.key==="Shift")this.#q=!1},window.addEventListener("keydown",this.#X),window.addEventListener("keyup",this.#W)}get#E(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#P(Q){if(!this.#E)return;Q.preventDefault(),this.#j=!0,this.#G.classList.add("dragging"),this.#G.setPointerCapture(Q.pointerId);let{clientX:Z,clientY:$}=Q,J=this.#Z,j=this.#Q,_=(G)=>{if(!this.#j)return;if(G.buttons===0){q();return}let X=G.clientX-Z,K=G.clientY-$;this.#Q=this.#T(j+X*0.5),this.#Z=this.#T(J-K*0.5),this.#k(),this.#S(),this.setAttribute("value",this.value),this.#f("input")},q=()=>{if(!this.#j)return;this.setAttribute("value",this.value),this.#j=!1,this.#G.classList.remove("dragging"),this.#G.removeEventListener("pointermove",_),this.#G.removeEventListener("pointerup",q),this.#G.removeEventListener("pointercancel",q),this.#G.removeEventListener("lostpointercapture",q),this.#f("change")};this.#G.addEventListener("pointermove",_),this.#G.addEventListener("pointerup",q),this.#G.addEventListener("pointercancel",q),this.#G.addEventListener("lostpointercapture",q)}}customElements.define("fig-3d-rotate",l0);class G0 extends HTMLElement{#Z=50;#Q=50;#J=0;#$=null;#j=[];#q=null;#_=null;#G=null;#X=!1;#W=!1;#Y=null;#K=null;#U=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"]}#N(){this.#$=this.querySelector(".origin-grid"),this.#j=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#G=this.querySelector('fig-input-number[name="y"]'),this.#k(),this.#f(),this.#R(),this.#m()}connectedCallback(){if(this.#J=parseInt(this.getAttribute("precision")||"0"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#D(this.getAttribute("value")),this.querySelector(".fig-origin-grid-surface"))this.#N();else this.#H();this.#B(),this.#F()}disconnectedCallback(){this.#X=!1,this.#v(),this.#x()}get value(){let Q=this.#J;return`${this.#Z.toFixed(Q)}% ${this.#Q.toFixed(Q)}%`}set value(Q){this.setAttribute("value",Q)}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",$);return}if(Q==="drag"){this.#B();return}if(Q==="fields"){this.#H(),this.#B(),this.#F();return}if(Q==="precision"){this.#J=parseInt($||"0"),this.#R(),this.#F();return}if(Q==="value"){if(this.#W||this.#X)return;this.#D($),this.#k(),this.#f(),this.#R()}}get#L(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}get#O(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#B(){if(!this.#$)return;this.#$.classList.toggle("drag-disabled",!this.#L)}#M(Q){return Math.max(0,Math.min(100,Q))}#z(Q,Z){let $=(Q||"").trim().toLowerCase();if(!$)return Z==="x"?this.#Z:this.#Q;let J=Z==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if($ in J)return J[$];let j=Number.parseFloat($.replace("%",""));if(Number.isFinite(j))return j;return Z==="x"?this.#Z:this.#Q}#A(Q){let Z=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if(Z.length<1)return;if(Z.length===1){let $=this.#z(Z[0],"x");this.#Z=$,this.#Q=$;return}this.#Z=this.#z(Z[0],"x"),this.#Q=this.#z(Z[1],"y")}#D(Q){let Z=typeof Q==="string"?Q.trim():"";if(!Z){this.#Z=50,this.#Q=50;return}this.#A(Z)}#H(){let Q=Array.from({length:9},(j,_)=>{let q=_%3,G=Math.floor(_/3);return`<span class="origin-grid-cell" data-col="${q}" data-row="${G}">
224
+ </div>${$}`,this.#G=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#D(),this.#C(),this.#S()}#D(){this.#N={};for(let Q of this.#U){let Z=this.querySelector(`fig-input-number[name="${Q}"]`);if(!Z)continue;if(this.#N[Q]=Z,!this.#L[Q])this.#L[Q]=(J)=>{J.stopPropagation();let j=parseFloat(J.target.value);if(isNaN(j))return;if(Q==="rotateX")this.#Z=j;else if(Q==="rotateY")this.#Q=j;else if(Q==="rotateZ")this.#J=j;this.#C(),this.#R(J.type)};let $=this.#L[Q];Z.removeEventListener("input",$),Z.removeEventListener("change",$),Z.addEventListener("input",$),Z.addEventListener("change",$)}}#E(){let Q={rotateX:this.#Z,rotateY:this.#Q,rotateZ:this.#J};for(let Z of this.#U){let $=this.#N[Z];if($)$.setAttribute("value",Q[Z].toFixed(this.#$))}}#C(){if(!this.#_)return;this.#_.style.transform=`rotateX(${this.#Z}deg) rotateY(${this.#Q}deg) rotateZ(${this.#J}deg)`}#R(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#Z,rotateY:this.#Q,rotateZ:this.#J}}))}#f(Q){if(!this.#q)return Q;return Math.round(Q/15)*15}#S(){if(this.#B(),!this.#G)return;this.#K=new AbortController,this.#G.addEventListener("pointerdown",this.#Y,{signal:this.#K.signal}),this.#X=(Q)=>{if(Q.key==="Shift")this.#q=!0},this.#W=(Q)=>{if(Q.key==="Shift")this.#q=!1},window.addEventListener("keydown",this.#X),window.addEventListener("keyup",this.#W)}get#k(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#T(Q){if(!this.#k)return;Q.preventDefault(),this.#j=!0,this.#G.classList.add("dragging"),this.#G.setPointerCapture(Q.pointerId);let{clientX:Z,clientY:$}=Q,J=this.#Z,j=this.#Q,_=(G)=>{if(!this.#j)return;if(G.buttons===0){q();return}let X=G.clientX-Z,K=G.clientY-$;this.#Q=this.#f(j+X*0.5),this.#Z=this.#f(J-K*0.5),this.#C(),this.#E(),this.setAttribute("value",this.value),this.#R("input")},q=()=>{if(!this.#j)return;this.setAttribute("value",this.value),this.#j=!1,this.#G.classList.remove("dragging"),this.#G.removeEventListener("pointermove",_),this.#G.removeEventListener("pointerup",q),this.#G.removeEventListener("pointercancel",q),this.#G.removeEventListener("lostpointercapture",q),this.#R("change")};this.#G.addEventListener("pointermove",_),this.#G.addEventListener("pointerup",q),this.#G.addEventListener("pointercancel",q),this.#G.addEventListener("lostpointercapture",q)}}customElements.define("fig-3d-rotate",e0);class Y0 extends HTMLElement{#Z=50;#Q=50;#J=0;#$=null;#j=[];#q=null;#_=null;#G=null;#X=!1;#W=!1;#Y=null;#K=null;#U=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"]}#N(){this.#$=this.querySelector(".origin-grid"),this.#j=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#G=this.querySelector('fig-input-number[name="y"]'),this.#C(),this.#R(),this.#P(),this.#p()}connectedCallback(){if(this.#J=parseInt(this.getAttribute("precision")||"0"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#A(this.getAttribute("value")),this.querySelector(".fig-origin-grid-surface"))this.#N();else this.#z();this.#B(),this.#D()}disconnectedCallback(){this.#X=!1,this.#y(),this.#b()}get value(){let Q=this.#J;return`${this.#Z.toFixed(Q)}% ${this.#Q.toFixed(Q)}%`}set value(Q){this.setAttribute("value",Q)}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",$);return}if(Q==="drag"){this.#B();return}if(Q==="fields"){this.#z(),this.#B(),this.#D();return}if(Q==="precision"){this.#J=parseInt($||"0"),this.#P(),this.#D();return}if(Q==="value"){if(this.#W||this.#X)return;this.#A($),this.#C(),this.#R(),this.#P()}}get#L(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}get#H(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#B(){if(!this.#$)return;this.#$.classList.toggle("drag-disabled",!this.#L)}#M(Q){return Math.max(0,Math.min(100,Q))}#F(Q,Z){let $=(Q||"").trim().toLowerCase();if(!$)return Z==="x"?this.#Z:this.#Q;let J=Z==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if($ in J)return J[$];let j=Number.parseFloat($.replace("%",""));if(Number.isFinite(j))return j;return Z==="x"?this.#Z:this.#Q}#O(Q){let Z=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if(Z.length<1)return;if(Z.length===1){let $=this.#F(Z[0],"x");this.#Z=$,this.#Q=$;return}this.#Z=this.#F(Z[0],"x"),this.#Q=this.#F(Z[1],"y")}#A(Q){let Z=typeof Q==="string"?Q.trim():"";if(!Z){this.#Z=50,this.#Q=50;return}this.#O(Z)}#z(){let Q=Array.from({length:9},(j,_)=>{let q=_%3,G=Math.floor(_/3);return`<span class="origin-grid-cell" data-col="${q}" data-row="${G}">
235
225
  <span class="origin-grid-dot"></span>
236
- </span>`}).join(""),Z=this.#Z.toFixed(this.#J),$=this.#Q.toFixed(this.#J),J=this.#O?`<div class="origin-values">
226
+ </span>`}).join(""),Z=this.#Z.toFixed(this.#J),$=this.#Q.toFixed(this.#J),J=this.#H?`<div class="origin-values">
237
227
  <fig-input-number name="x" value="${Z}" step="1" units="%"><span slot="prepend">X</span></fig-input-number>
238
228
  <fig-input-number name="y" value="${$}" step="1" units="%"><span slot="prepend">Y</span></fig-input-number>
239
229
  </div>`:"";this.innerHTML=`<div class="fig-origin-grid-surface">
@@ -242,7 +232,7 @@ var A1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var F1={};var L0=A1(()=>{/*! Vendored from @
242
232
  <fig-handle></fig-handle>
243
233
  </div>
244
234
  </div>
245
- ${J}`,this.#$=this.querySelector(".origin-grid"),this.#j=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#G=this.querySelector('fig-input-number[name="y"]'),this.#k(),this.#f(),this.#R(),this.#m()}#R(){let Q=this.#Z.toFixed(this.#J),Z=this.#Q.toFixed(this.#J);if(this.#_)this.#_.setAttribute("value",Q);if(this.#G)this.#G.setAttribute("value",Z)}#F(){let Q=this.value;if(this.getAttribute("value")===Q)return;this.#W=!0,this.setAttribute("value",Q),this.#W=!1}#S(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#Z,y:this.#Q}}))}#k(){if(!this.#q)return;let Q=(Z)=>16.6667+this.#M(Z)/100*66.6667;this.#q.style.left=`${Q(this.#Z)}%`,this.#q.style.top=`${Q(this.#Q)}%`}#f(){if(!this.#q)return;let Q=this.#Z<0||this.#Z>100,Z=this.#Q<0||this.#Q>100,$=this.#Z<0,J=this.#Z>100,j=this.#Q<0,_=this.#Q>100;this.#q.classList.toggle("beyond-bounds-x",Q),this.#q.classList.toggle("beyond-bounds-y",Z),this.#q.classList.toggle("overflow-left",$),this.#q.classList.toggle("overflow-right",J),this.#q.classList.toggle("overflow-up",j),this.#q.classList.toggle("overflow-down",_)}#T(Q,Z){if(!this.#$)return null;let $=this.#$.getBoundingClientRect(),J=(Q-$.left)/Math.max($.width,1),j=(Z-$.top)/Math.max($.height,1);if(J<0||J>1||j<0||j>1)return null;let _=Math.max(0,Math.min(2,Math.floor(J*3))),q=Math.max(0,Math.min(2,Math.floor(j*3)));return this.#j.find((G)=>Number(G.getAttribute("data-col"))===_&&Number(G.getAttribute("data-row"))===q)}#C(){for(let Q of this.#j)Q.classList.remove("is-hovered")}#E(Q){if(this.#C(),Q)Q.classList.add("is-hovered")}#P(Q,Z,$){let J=Number(Q),j=Number(Z);if(!Number.isFinite(J)||!Number.isFinite(j))return;if(J===this.#Z&&j===this.#Q&&$==="input")return;this.#Z=J,this.#Q=j,this.#k(),this.#f(),this.#R(),this.#F(),this.#S($)}#I(Q,Z){if(!this.#$)return{x:this.#Z,y:this.#Q};let $=this.#$.getBoundingClientRect(),J=$.width/6,j=$.height/6,_=Math.max(1,$.width-J*2),q=Math.max(1,$.height-j*2),G=(Q-($.left+J))/_,X=(Z-($.top+j))/q;return{x:G*100,y:X*100}}#g(Q,Z){if(!this.#$)return{x:50,y:50};let $=this.#$.getBoundingClientRect(),J=(Q-$.left)/Math.max($.width,1)*3,j=(Z-$.top)/Math.max($.height,1)*3,_=Math.max(0,Math.min(2,Math.floor(J))),q=Math.max(0,Math.min(2,Math.floor(j)));return{x:_*50,y:q*50}}#V(Q){let $=Q,J=1/0;for(let j of G0.SNAP_POINTS){let _=Math.abs(Q-j);if(_<J)J=_,$=j}return J<=2.5?$:Q}#y(Q,Z){if(!Z)return Q;return{x:this.#V(Q.x),y:this.#V(Q.y)}}#w(Q){if(!this.#L)return!1;let Z=Q.shiftKey?10:1,$=this.#Z,J=this.#Q;switch(Q.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.#P(this.#M($),this.#M(J),"input"),this.#S("change"),!0}#v(){if(!this.#$||!this.#K||!this.#U)return;this.#$.removeEventListener("pointermove",this.#K),this.#$.removeEventListener("pointerup",this.#U),this.#$.removeEventListener("pointercancel",this.#U),this.#$.removeEventListener("lostpointercapture",this.#U),this.#K=null,this.#U=null}#h(Q){if(!this.#$||!this.#L)return;Q.preventDefault(),this.#X=!0,this.#Y=Q.pointerId;let{clientX:Z,clientY:$}=Q,J=3,j=!1;this.#$.setPointerCapture(Q.pointerId),this.#K=(_)=>{if(!this.#X||_.pointerId!==this.#Y)return;let q=_.clientX-Z,G=_.clientY-$,X=Math.hypot(q,G);if(!j&&X<J)return;if(!j)j=!0,this.#$.classList.add("is-dragging"),this.#C();let K=this.#y(this.#I(_.clientX,_.clientY),_.shiftKey);this.#P(K.x,K.y,"input")},this.#U=(_)=>{if(!this.#X||_.pointerId!==this.#Y)return;if(this.#X=!1,this.#Y=null,this.#$.classList.remove("is-dragging"),this.#C(),this.#v(),!j){let q=this.#g(Z,$);this.#P(q.x,q.y,"input")}this.#S("change")},this.#$.addEventListener("pointermove",this.#K),this.#$.addEventListener("pointerup",this.#U),this.#$.addEventListener("pointercancel",this.#U),this.#$.addEventListener("lostpointercapture",this.#U)}#b=null;#x(){this.#b?.abort(),this.#b=null}#m(){if(this.#x(),!this.#$||!this.#q)return;this.#b=new AbortController;let{signal:Q}=this.#b;this.#$.addEventListener("pointerdown",($)=>{let J=this.#T($.clientX,$.clientY);if(this.#E(J),this.#L){this.#h($);return}let j=this.#g($.clientX,$.clientY);this.#P(j.x,j.y,"input"),this.#S("change")},{signal:Q}),this.#$.addEventListener("pointermove",($)=>{if(this.#X)return;let J=this.#T($.clientX,$.clientY);this.#E(J)},{signal:Q}),this.#$.addEventListener("pointerleave",()=>{this.#C()},{signal:Q}),this.#q.addEventListener("keydown",($)=>{if(!this.#w($))return;$.preventDefault(),$.stopPropagation()},{signal:Q});let Z=($,J)=>{if(!$)return;let j=(_)=>{let q=Number.parseFloat(_.target.value);if(!Number.isFinite(q))return;if(J==="x")this.#P(q,this.#Q,"input");else this.#P(this.#Z,q,"input")};$.addEventListener("input",j,{signal:Q}),$.addEventListener("change",j,{signal:Q}),$.addEventListener("focusout",()=>{this.#S("change")},{signal:Q})};Z(this.#_,"x"),Z(this.#G,"y")}}customElements.define("fig-origin-grid",G0);class a0 extends HTMLElement{#Z=null;#Q=null;#J=null;#$=null;#j=null;#q=null;#_=null;#G=null;#X=!1;#W={x:0.5,y:0.5};#Y=!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=(Q)=>this.#F(Q),this.#Q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#J=(Q)=>this.#S(Q),this.#$=()=>this.#k(),this.#j=(Q)=>this.#A(Q),this.#q=(Q)=>this.#D(Q),this.#_=()=>this.#H(),this.#G=()=>this.#H()}#K(){this.#M(),this.#C(),this.#P(),this.#I(),this.#Y=!0}connectedCallback(){b(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",V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");if(this.querySelector(".fig-input-joystick-plane")){this.#K();return}this.#L(),this.#M(),this.#C(),this.#P(),this.#I(),this.#Y=!0})}#U(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#z()}get#N(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#L(){this.innerHTML=this.#B()}#O(){let Q=(this.getAttribute("axis-labels")||"").trim();if(!Q)return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1};let Z=Q.split(/[\s,]+/).filter(Boolean);if(Z.length===1)return{left:"",right:"",top:Z[0],bottom:"",leftNoRotate:!1};if(Z.length===2){let[$,J]=Z;return{left:$,right:"",top:"",bottom:J,leftNoRotate:!0}}if(Z.length===4){let[$,J,j,_]=Z;return{left:$,right:J,top:j,bottom:_,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#B(){let Q=this.#O();return`
235
+ ${J}`,this.#$=this.querySelector(".origin-grid"),this.#j=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#G=this.querySelector('fig-input-number[name="y"]'),this.#C(),this.#R(),this.#P(),this.#p()}#P(){let Q=this.#Z.toFixed(this.#J),Z=this.#Q.toFixed(this.#J);if(this.#_)this.#_.setAttribute("value",Q);if(this.#G)this.#G.setAttribute("value",Z)}#D(){let Q=this.value;if(this.getAttribute("value")===Q)return;this.#W=!0,this.setAttribute("value",Q),this.#W=!1}#E(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#Z,y:this.#Q}}))}#C(){if(!this.#q)return;let Q=(Z)=>16.6667+this.#M(Z)/100*66.6667;this.#q.style.left=`${Q(this.#Z)}%`,this.#q.style.top=`${Q(this.#Q)}%`}#R(){if(!this.#q)return;let Q=this.#Z<0||this.#Z>100,Z=this.#Q<0||this.#Q>100,$=this.#Z<0,J=this.#Z>100,j=this.#Q<0,_=this.#Q>100;this.#q.classList.toggle("beyond-bounds-x",Q),this.#q.classList.toggle("beyond-bounds-y",Z),this.#q.classList.toggle("overflow-left",$),this.#q.classList.toggle("overflow-right",J),this.#q.classList.toggle("overflow-up",j),this.#q.classList.toggle("overflow-down",_)}#f(Q,Z){if(!this.#$)return null;let $=this.#$.getBoundingClientRect(),J=(Q-$.left)/Math.max($.width,1),j=(Z-$.top)/Math.max($.height,1);if(J<0||J>1||j<0||j>1)return null;let _=Math.max(0,Math.min(2,Math.floor(J*3))),q=Math.max(0,Math.min(2,Math.floor(j*3)));return this.#j.find((G)=>Number(G.getAttribute("data-col"))===_&&Number(G.getAttribute("data-row"))===q)}#S(){for(let Q of this.#j)Q.classList.remove("is-hovered")}#k(Q){if(this.#S(),Q)Q.classList.add("is-hovered")}#T(Q,Z,$){let J=Number(Q),j=Number(Z);if(!Number.isFinite(J)||!Number.isFinite(j))return;if(J===this.#Z&&j===this.#Q&&$==="input")return;this.#Z=J,this.#Q=j,this.#C(),this.#R(),this.#P(),this.#D(),this.#E($)}#x(Q,Z){if(!this.#$)return{x:this.#Z,y:this.#Q};let $=this.#$.getBoundingClientRect(),J=$.width/6,j=$.height/6,_=Math.max(1,$.width-J*2),q=Math.max(1,$.height-j*2),G=(Q-($.left+J))/_,X=(Z-($.top+j))/q;return{x:G*100,y:X*100}}#g(Q,Z){if(!this.#$)return{x:50,y:50};let $=this.#$.getBoundingClientRect(),J=(Q-$.left)/Math.max($.width,1)*3,j=(Z-$.top)/Math.max($.height,1)*3,_=Math.max(0,Math.min(2,Math.floor(J))),q=Math.max(0,Math.min(2,Math.floor(j)));return{x:_*50,y:q*50}}#w(Q){let $=Q,J=1/0;for(let j of Y0.SNAP_POINTS){let _=Math.abs(Q-j);if(_<J)J=_,$=j}return J<=2.5?$:Q}#I(Q,Z){if(!Z)return Q;return{x:this.#w(Q.x),y:this.#w(Q.y)}}#V(Q){if(!this.#L)return!1;let Z=Q.shiftKey?10:1,$=this.#Z,J=this.#Q;switch(Q.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.#T(this.#M($),this.#M(J),"input"),this.#E("change"),!0}#y(){if(!this.#$||!this.#K||!this.#U)return;this.#$.removeEventListener("pointermove",this.#K),this.#$.removeEventListener("pointerup",this.#U),this.#$.removeEventListener("pointercancel",this.#U),this.#$.removeEventListener("lostpointercapture",this.#U),this.#K=null,this.#U=null}#h(Q){if(!this.#$||!this.#L)return;Q.preventDefault(),this.#X=!0,this.#Y=Q.pointerId;let{clientX:Z,clientY:$}=Q,J=3,j=!1;this.#$.setPointerCapture(Q.pointerId),this.#K=(_)=>{if(!this.#X||_.pointerId!==this.#Y)return;let q=_.clientX-Z,G=_.clientY-$,X=Math.hypot(q,G);if(!j&&X<J)return;if(!j)j=!0,this.#$.classList.add("is-dragging"),this.#S();let K=this.#I(this.#x(_.clientX,_.clientY),_.shiftKey);this.#T(K.x,K.y,"input")},this.#U=(_)=>{if(!this.#X||_.pointerId!==this.#Y)return;if(this.#X=!1,this.#Y=null,this.#$.classList.remove("is-dragging"),this.#S(),this.#y(),!j){let q=this.#g(Z,$);this.#T(q.x,q.y,"input")}this.#E("change")},this.#$.addEventListener("pointermove",this.#K),this.#$.addEventListener("pointerup",this.#U),this.#$.addEventListener("pointercancel",this.#U),this.#$.addEventListener("lostpointercapture",this.#U)}#v=null;#b(){this.#v?.abort(),this.#v=null}#p(){if(this.#b(),!this.#$||!this.#q)return;this.#v=new AbortController;let{signal:Q}=this.#v;this.#$.addEventListener("pointerdown",($)=>{let J=this.#f($.clientX,$.clientY);if(this.#k(J),this.#L){this.#h($);return}let j=this.#g($.clientX,$.clientY);this.#T(j.x,j.y,"input"),this.#E("change")},{signal:Q}),this.#$.addEventListener("pointermove",($)=>{if(this.#X)return;let J=this.#f($.clientX,$.clientY);this.#k(J)},{signal:Q}),this.#$.addEventListener("pointerleave",()=>{this.#S()},{signal:Q}),this.#q.addEventListener("keydown",($)=>{if(!this.#V($))return;$.preventDefault(),$.stopPropagation()},{signal:Q});let Z=($,J)=>{if(!$)return;let j=(_)=>{let q=Number.parseFloat(_.target.value);if(!Number.isFinite(q))return;if(J==="x")this.#T(q,this.#Q,"input");else this.#T(this.#Z,q,"input")};$.addEventListener("input",j,{signal:Q}),$.addEventListener("change",j,{signal:Q}),$.addEventListener("focusout",()=>{this.#E("change")},{signal:Q})};Z(this.#_,"x"),Z(this.#G,"y")}}customElements.define("fig-origin-grid",Y0);class Q1 extends HTMLElement{#Z=null;#Q=null;#J=null;#$=null;#j=null;#q=null;#_=null;#G=null;#X=!1;#W={x:0.5,y:0.5};#Y=!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=(Q)=>this.#D(Q),this.#Q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#J=(Q)=>this.#E(Q),this.#$=()=>this.#C(),this.#j=(Q)=>this.#O(Q),this.#q=(Q)=>this.#A(Q),this.#_=()=>this.#z(),this.#G=()=>this.#z()}#K(){this.#M(),this.#S(),this.#T(),this.#x(),this.#Y=!0}connectedCallback(){b(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",V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");if(this.querySelector(".fig-input-joystick-plane")){this.#K();return}this.#L(),this.#M(),this.#S(),this.#T(),this.#x(),this.#Y=!0})}#U(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#F()}get#N(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#L(){this.innerHTML=this.#B()}#H(){let Q=(this.getAttribute("axis-labels")||"").trim();if(!Q)return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1};let Z=Q.split(/[\s,]+/).filter(Boolean);if(Z.length===1)return{left:"",right:"",top:Z[0],bottom:"",leftNoRotate:!1};if(Z.length===2){let[$,J]=Z;return{left:$,right:"",top:"",bottom:J,leftNoRotate:!0}}if(Z.length===4){let[$,J,j,_]=Z;return{left:$,right:J,top:j,bottom:_,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#B(){let Q=this.#H();return`
246
236
  <div class="fig-input-joystick-plane-container">
247
237
  ${[Q.left?`<label class="fig-joystick-axis-label left${Q.leftNoRotate?" no-rotate":""}" aria-hidden="true">${Q.left}</label>`:"",Q.right?`<label class="fig-joystick-axis-label right" aria-hidden="true">${Q.right}</label>`:"",Q.top?`<label class="fig-joystick-axis-label top" aria-hidden="true">${Q.top}</label>`:"",Q.bottom?`<label class="fig-joystick-axis-label bottom" aria-hidden="true">${Q.bottom}</label>`:""].join("")}
248
238
  <div class="fig-input-joystick-plane">
@@ -275,6 +265,6 @@ var A1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var F1={};var L0=A1(()=>{/*! Vendored from @
275
265
  <span slot="prepend">Y</span>
276
266
  </fig-input-number>
277
267
  </div>`:""}
278
- `}#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.#Q),this.cursor?.addEventListener("input",this.#J),this.cursor?.addEventListener("change",this.#$);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#g());if(this.#N&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#j),this.xInput.addEventListener("change",this.#j),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#q),this.yInput.addEventListener("change",this.#q),this.yInput.addEventListener("focusout",this.#G)}#z(){if(this.plane?.removeEventListener("pointerdown",this.#Z),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#J),this.cursor?.removeEventListener("change",this.#$),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#N&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#j),this.xInput.removeEventListener("change",this.#j),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#q),this.yInput.removeEventListener("change",this.#q),this.yInput.removeEventListener("focusout",this.#G)}#A(Q){let Z=Number.parseFloat(Q.target.value);if(!Number.isFinite(Z))return;this.position.x=Math.max(0,Math.min(1,Z/100)),this.#C(),this.#P(),this.#f()}#D(Q){let Z=Number.parseFloat(Q.target.value);if(!Number.isFinite(Z))return;this.position.y=Math.max(0,Math.min(1,Z/100)),this.#C(),this.#P(),this.#f()}#H(){this.#P(),this.#T()}#R(Q,Z,{syncHandle:$=!0}={}){let J=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,Z)),_=this.coordinates==="math"?1-j:j;if(this.position={x:J,y:_},$)this.#C();this.#E(),this.#P()}#F(Q){if(!this.plane||!this.cursor)return;if(Q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let Z=this.plane.getBoundingClientRect(),$=Z.width>0?(Q.clientX-Z.left)/Z.width:0.5,J=Z.height>0?(Q.clientY-Z.top)/Z.height:0.5;this.cursor.value=`${Math.round($*100)}% ${Math.round(J*100)}%`,this.#R($,J,{syncHandle:!1}),this.#f(),this.#T()}#S(Q){let Z=Q.detail??{};if(typeof Z.px!=="number"||typeof Z.py!=="number")return;this.#R(Z.px,Z.py,{syncHandle:!1}),this.#f()}#k(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#P(),this.#T()}#f(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#T(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#C(){let Q=this.#U(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;this.#E()}#E(){if(this.#N&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#P(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#X=!0,this.setAttribute("value",Q),this.#X=!1;this.#I()}#I(){let Q=this.#W,Z=Math.round(this.position.x*100)===Math.round(Q.x*100)&&Math.round(this.position.y*100)===Math.round(Q.y*100);this.toggleAttribute("default",Z),this.style.setProperty("--is-not-default",Z?"0":"1")}#g(){this.position={...this.#W},this.#C(),this.#P(),this.#f(),this.#T()}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(Q){let Z=Q==null?"":String(Q).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 G=q.includes("%"),X=Number.parseFloat(q.replace(/%/g,"").trim());if(!Number.isFinite(X))return 0.5;let K=G||Math.abs(X)>1?X/100:X;return Math.max(0,Math.min(1,K))},j=J($[0]),_=J($[1]??$[0]);this.position={x:j,y:_}}if(this.#Y)this.#C(),this.#I()}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",$);return}if(Q==="value"){if(this.#X||this.isDragging)return;this.value=$}if(Q==="precision")this.precision=parseInt($);if(Q==="transform")this.transform=Number($);if(Q==="fields"&&$!==Z)this.#z(),this.#L(),this.#M(),this.#C();if(Q==="axis-labels"&&$!==Z)this.#z(),this.#L(),this.#M(),this.#C();if(Q==="coordinates")this.coordinates=$||"screen",this.#C()}}customElements.define("fig-joystick",a0);class X0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let Q=this.getAttribute("duration");if(Q)this.style.setProperty(this.durationPropertyName,Q);this.#Z()}static get observedAttributes(){return["duration","playing","aria-label","aria-labelledby"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(Q,Z,$){if(Q==="duration")this.style.setProperty(this.durationPropertyName,$||"1.5s");if(Q==="playing"||Q==="aria-label"||Q==="aria-labelledby")this.#Z()}#Z(){let Q=this.playing;if(this.setAttribute("aria-busy",Q?"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")}}customElements.define("fig-shimmer",X0);class t0 extends X0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}customElements.define("fig-skeleton",t0);class n0 extends HTMLElement{static observedAttributes=["name","collapsible","open"];#Z=null;#Q=null;connectedCallback(){this.#j()}disconnectedCallback(){if(this.#Q)this.#Q.removeEventListener("click",this.#J);if(this.#Z)this.#Z.removeEventListener("click",this.#J),this.#Z.removeEventListener("keydown",this.#$),this.#Z.querySelector("h3")?.removeEventListener("click",this.#J)}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){this.#Z?.setAttribute("aria-expanded",String(this.open));return}this.#j()}get open(){let Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){let Z=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#Z?.setAttribute("aria-expanded",String(!!Q)),Z!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}#J=(Q)=>{Q.stopPropagation(),this.open=!this.open};#$=(Q)=>{if(Q.key!=="Enter"&&Q.key!==" ")return;Q.preventDefault(),Q.stopPropagation(),this.open=!this.open};#j(){let Q=this.hasAttribute("collapsible"),$=this.getAttribute("name")||(Q?"Group":null),J=this.querySelector(":scope > fig-header");if(!$&&!Q&&!J){if(this.#Z&&this.#Z.dataset.generated)this.#Z.remove(),this.#Z=null,this.#Q=null;return}if(J)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);let j=this.#Z.querySelector("h3");if(!j)j=document.createElement("h3"),this.#Z.prepend(j);if(!j.id)j.id=y();if(this.#Z.dataset.generated)j.textContent=$;if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",j.id);if(Q){if(!j.querySelector(".fig-group-chevron")){let _=v("chevron",{size:"small",className:"fig-group-chevron"});j.prepend(_)}if(this.#Q=j.querySelector(".fig-group-chevron"),j.removeEventListener("click",this.#J),this.#Z.removeEventListener("click",this.#J),this.#Z.addEventListener("click",this.#J),this.#Z.setAttribute("role","button"),this.#Z.setAttribute("tabindex","0"),this.#Z.setAttribute("aria-expanded",String(this.open)),this.#Z.removeEventListener("keydown",this.#$),this.#Z.addEventListener("keydown",this.#$),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Z.setAttribute("aria-expanded","false")}else{if(j.removeEventListener("click",this.#J),this.#Z.removeEventListener("click",this.#J),this.#Z.removeAttribute("role"),this.#Z.removeAttribute("tabindex"),this.#Z.removeAttribute("aria-expanded"),this.#Z.removeEventListener("keydown",this.#$),this.#Q)this.#Q.remove(),this.#Q=null;this.removeAttribute("open")}}}customElements.define("fig-group",n0);class e0 extends HTMLElement{}customElements.define("fig-header",e0);class Q1 extends HTMLElement{}customElements.define("fig-footer",Q1);class Z1 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")}}customElements.define("fig-spinner",Z1);class $1 extends HTMLElement{static get observedAttributes(){return["fit"]}connectedCallback(){this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="fit")this.#Z()}#Z(){let Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-preview-fit",Q);else this.style.removeProperty("--fig-preview-fit")}}customElements.define("fig-preview",$1);var f1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:"--icon-16-reset","arrow-left":"--icon-16-arrow-left",steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",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",visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function I1(Q,Z="medium"){let $=Q&&f1[Q];if(!$)return"";let J=typeof $==="string"?$:$[Z==="small"?"small":"medium"];return J?`var(${J})`:""}class J1 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#Z()}attributeChangedCallback(Q,Z,$){if(Z!==$)this.#Z()}#Z(){let Q=this.getAttribute("name"),Z=this.getAttribute("size")||"medium",$=I1(Q,Z);if($)this.style.setProperty("--icon",$);else this.style.removeProperty("--icon");if(Z==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let J=this.getAttribute("color");if(J)this.style.backgroundColor=J;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}customElements.define("fig-icon",J1);class j1 extends HTMLElement{}customElements.define("fig-content",j1);class _1 extends HTMLElement{}customElements.define("fig-tab-content",_1);class q1 extends HTMLElement{}customElements.define("fig-button-combo",q1);class G1 extends HTMLElement{}customElements.define("fig-input-combo",G1);class X1 extends HTMLElement{#Z=null;#Q=null;#J=null;#$=this.#M.bind(this);#j=this.#z.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#q(){return this.getAttribute("control")||"color"}connectedCallback(){this.#W(),this.#L()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#Y)}#_(){if(this.#Z)this.#Z.removeEventListener("input",this.#$),this.#Z.removeEventListener("change",this.#j);if(this.#Q)this.#Q.removeEventListener("input",this.#$),this.#Q.removeEventListener("change",this.#j);if(this.#J)this.#J.disconnect(),this.#J=null}#G(){if(this.#J)this.#J.disconnect(),this.#J=null;if(!this.#Q)return;this.#J=new MutationObserver(()=>{if(this.#Q?.hasAttribute("selected")&&this.#Q.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#J.observe(this.#Q,{attributes:!0,attributeFilter:["selected"]})}get#X(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#W(){let Q=this.#q;if(Q==="add"||Q==="remove"){let G=Q==="add"?"add":"minus",X=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");this.innerHTML=`<fig-button icon variant="ghost" aria-label="${X}"><fig-icon name="${G}"></fig-icon></fig-button>`,this.#Z=null,this.#Q=null,this.addEventListener("click",this.#Y),this.#O();return}this.removeEventListener("click",this.#Y);let Z=(this.getAttribute("value")||"").trim(),$=this.#N(Z),J=this.#U(Z),j=this.#X?"":'alpha="false"',_=J<1?JSON.stringify({type:"solid",color:$,opacity:Math.round(J*100)}):JSON.stringify({type:"solid",color:$}),q=J<1?` alpha="${J}"`:"";if(this.innerHTML=u()?`<fig-fill-picker mode="solid" ${j} value='${_}'>
268
+ `}#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.#Q),this.cursor?.addEventListener("input",this.#J),this.cursor?.addEventListener("change",this.#$);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#g());if(this.#N&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#j),this.xInput.addEventListener("change",this.#j),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#q),this.yInput.addEventListener("change",this.#q),this.yInput.addEventListener("focusout",this.#G)}#F(){if(this.plane?.removeEventListener("pointerdown",this.#Z),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#J),this.cursor?.removeEventListener("change",this.#$),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#N&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#j),this.xInput.removeEventListener("change",this.#j),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#q),this.yInput.removeEventListener("change",this.#q),this.yInput.removeEventListener("focusout",this.#G)}#O(Q){let Z=Number.parseFloat(Q.target.value);if(!Number.isFinite(Z))return;this.position.x=Math.max(0,Math.min(1,Z/100)),this.#S(),this.#T(),this.#R()}#A(Q){let Z=Number.parseFloat(Q.target.value);if(!Number.isFinite(Z))return;this.position.y=Math.max(0,Math.min(1,Z/100)),this.#S(),this.#T(),this.#R()}#z(){this.#T(),this.#f()}#P(Q,Z,{syncHandle:$=!0}={}){let J=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,Z)),_=this.coordinates==="math"?1-j:j;if(this.position={x:J,y:_},$)this.#S();this.#k(),this.#T()}#D(Q){if(!this.plane||!this.cursor)return;if(Q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let Z=this.plane.getBoundingClientRect(),$=Z.width>0?(Q.clientX-Z.left)/Z.width:0.5,J=Z.height>0?(Q.clientY-Z.top)/Z.height:0.5;this.cursor.value=`${Math.round($*100)}% ${Math.round(J*100)}%`,this.#P($,J,{syncHandle:!1}),this.#R(),this.#f()}#E(Q){let Z=Q.detail??{};if(typeof Z.px!=="number"||typeof Z.py!=="number")return;this.#P(Z.px,Z.py,{syncHandle:!1}),this.#R()}#C(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#T(),this.#f()}#R(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#f(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#S(){let Q=this.#U(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;this.#k()}#k(){if(this.#N&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#T(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#X=!0,this.setAttribute("value",Q),this.#X=!1;this.#x()}#x(){let Q=this.#W,Z=Math.round(this.position.x*100)===Math.round(Q.x*100)&&Math.round(this.position.y*100)===Math.round(Q.y*100);this.toggleAttribute("default",Z),this.style.setProperty("--is-not-default",Z?"0":"1")}#g(){this.position={...this.#W},this.#S(),this.#T(),this.#R(),this.#f()}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(Q){let Z=Q==null?"":String(Q).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 G=q.includes("%"),X=Number.parseFloat(q.replace(/%/g,"").trim());if(!Number.isFinite(X))return 0.5;let K=G||Math.abs(X)>1?X/100:X;return Math.max(0,Math.min(1,K))},j=J($[0]),_=J($[1]??$[0]);this.position={x:j,y:_}}if(this.#Y)this.#S(),this.#x()}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",$);return}if(Q==="value"){if(this.#X||this.isDragging)return;this.value=$}if(Q==="precision")this.precision=parseInt($);if(Q==="transform")this.transform=Number($);if(Q==="fields"&&$!==Z)this.#F(),this.#L(),this.#M(),this.#S();if(Q==="axis-labels"&&$!==Z)this.#F(),this.#L(),this.#M(),this.#S();if(Q==="coordinates")this.coordinates=$||"screen",this.#S()}}customElements.define("fig-joystick",Q1);class N0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let Q=this.getAttribute("duration");if(Q)this.style.setProperty(this.durationPropertyName,Q);this.#Z()}static get observedAttributes(){return["duration","playing","aria-label","aria-labelledby"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(Q,Z,$){if(Q==="duration")this.style.setProperty(this.durationPropertyName,$||"1.5s");if(Q==="playing"||Q==="aria-label"||Q==="aria-labelledby")this.#Z()}#Z(){let Q=this.playing;if(this.setAttribute("aria-busy",Q?"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")}}customElements.define("fig-shimmer",N0);class Z1 extends N0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}customElements.define("fig-skeleton",Z1);class $1 extends HTMLElement{static observedAttributes=["name","collapsible","open"];#Z=null;#Q=null;connectedCallback(){this.#j()}disconnectedCallback(){if(this.#Q)this.#Q.removeEventListener("click",this.#J);if(this.#Z)this.#Z.removeEventListener("click",this.#J),this.#Z.removeEventListener("keydown",this.#$),this.#Z.querySelector("h3")?.removeEventListener("click",this.#J)}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){this.#Z?.setAttribute("aria-expanded",String(this.open));return}this.#j()}get open(){let Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){let Z=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#Z?.setAttribute("aria-expanded",String(!!Q)),Z!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}#J=(Q)=>{Q.stopPropagation(),this.open=!this.open};#$=(Q)=>{if(Q.key!=="Enter"&&Q.key!==" ")return;Q.preventDefault(),Q.stopPropagation(),this.open=!this.open};#j(){let Q=this.hasAttribute("collapsible"),$=this.getAttribute("name")||(Q?"Group":null),J=this.querySelector(":scope > fig-header");if(!$&&!Q&&!J){if(this.#Z&&this.#Z.dataset.generated)this.#Z.remove(),this.#Z=null,this.#Q=null;return}if(J)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);let j=this.#Z.querySelector("h3");if(!j)j=document.createElement("h3"),this.#Z.prepend(j);if(!j.id)j.id=y();if(this.#Z.dataset.generated)j.textContent=$;if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",j.id);if(Q){if(!j.querySelector(".fig-group-chevron")){let _=v("chevron",{size:"small",className:"fig-group-chevron"});j.prepend(_)}if(this.#Q=j.querySelector(".fig-group-chevron"),j.removeEventListener("click",this.#J),this.#Z.removeEventListener("click",this.#J),this.#Z.addEventListener("click",this.#J),this.#Z.setAttribute("role","button"),this.#Z.setAttribute("tabindex","0"),this.#Z.setAttribute("aria-expanded",String(this.open)),this.#Z.removeEventListener("keydown",this.#$),this.#Z.addEventListener("keydown",this.#$),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Z.setAttribute("aria-expanded","false")}else{if(j.removeEventListener("click",this.#J),this.#Z.removeEventListener("click",this.#J),this.#Z.removeAttribute("role"),this.#Z.removeAttribute("tabindex"),this.#Z.removeAttribute("aria-expanded"),this.#Z.removeEventListener("keydown",this.#$),this.#Q)this.#Q.remove(),this.#Q=null;this.removeAttribute("open")}}}customElements.define("fig-group",$1);class J1 extends HTMLElement{}customElements.define("fig-header",J1);class j1 extends HTMLElement{}customElements.define("fig-footer",j1);class _1 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")}}customElements.define("fig-spinner",_1);class q1 extends HTMLElement{static get observedAttributes(){return["fit"]}connectedCallback(){this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="fit")this.#Z()}#Z(){let Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-preview-fit",Q);else this.style.removeProperty("--fig-preview-fit")}}customElements.define("fig-preview",q1);var w1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:"--icon-16-reset","arrow-left":"--icon-16-arrow-left",steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",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",visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function g1(Q,Z="medium"){let $=Q&&w1[Q];if(!$)return"";let J=typeof $==="string"?$:$[Z==="small"?"small":"medium"];return J?`var(${J})`:""}class G1 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#Z()}attributeChangedCallback(Q,Z,$){if(Z!==$)this.#Z()}#Z(){let Q=this.getAttribute("name"),Z=this.getAttribute("size")||"medium",$=g1(Q,Z);if($)this.style.setProperty("--icon",$);else this.style.removeProperty("--icon");if(Z==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let J=this.getAttribute("color");if(J)this.style.backgroundColor=J;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}customElements.define("fig-icon",G1);class X1 extends HTMLElement{}customElements.define("fig-content",X1);class K1 extends HTMLElement{}customElements.define("fig-tab-content",K1);class Y1 extends HTMLElement{}customElements.define("fig-button-combo",Y1);class N1 extends HTMLElement{}customElements.define("fig-input-combo",N1);class W1 extends HTMLElement{#Z=null;#Q=null;#J=null;#$=this.#M.bind(this);#j=this.#F.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#q(){return this.getAttribute("control")||"color"}connectedCallback(){this.#W(),this.#L()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#Y)}#_(){if(this.#Z)this.#Z.removeEventListener("input",this.#$),this.#Z.removeEventListener("change",this.#j);if(this.#Q)this.#Q.removeEventListener("input",this.#$),this.#Q.removeEventListener("change",this.#j);if(this.#J)this.#J.disconnect(),this.#J=null}#G(){if(this.#J)this.#J.disconnect(),this.#J=null;if(!this.#Q)return;this.#J=new MutationObserver(()=>{if(this.#Q?.hasAttribute("selected")&&this.#Q.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#J.observe(this.#Q,{attributes:!0,attributeFilter:["selected"]})}get#X(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#W(){let Q=this.#q;if(Q==="add"||Q==="remove"){let G=Q==="add"?"add":"minus",X=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");this.innerHTML=`<fig-button icon variant="ghost" aria-label="${X}"><fig-icon name="${G}"></fig-icon></fig-button>`,this.#Z=null,this.#Q=null,this.addEventListener("click",this.#Y),this.#H();return}this.removeEventListener("click",this.#Y);let Z=(this.getAttribute("value")||"").trim(),$=this.#N(Z),J=this.#U(Z),j=this.#X?"":'alpha="false"',_=J<1?JSON.stringify({type:"solid",color:$,opacity:Math.round(J*100)}):JSON.stringify({type:"solid",color:$}),q=J<1?` alpha="${J}"`:"";if(this.innerHTML=u()?`<fig-fill-picker mode="solid" ${j} value='${_}'>
279
269
  <fig-chit background="${$}"${q}></fig-chit>
280
- </fig-fill-picker>`:`<fig-chit background="${$}"${q}></fig-chit>`,this.#Z=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-chit"),this.#_(),this.#Z?.addEventListener("input",this.#$),this.#Z?.addEventListener("change",this.#j),!this.#Z)this.#Q?.addEventListener("input",this.#$),this.#Q?.addEventListener("change",this.#j);this.#G(),this.#O()}#Y=()=>{let Q=this.#q;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#K(Q){if(!Q)return"#D9D9D9";let Z=Q.replace("#","").trim();if(Z.length===3||Z.length===4){let[$,J,j]=Z;return`#${$}${$}${J}${J}${j}${j}`.toUpperCase()}if(Z.length===6||Z.length===8)return`#${Z.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#U(Q){if(!Q)return 1;let Z=String(Q).trim(),$=Z.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test($)){let j=$[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test($))return parseInt($.slice(6,8),16)/255;let J=Z.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(J)return parseFloat(J[1]);return 1}#N(Q){if(!Q)return"#D9D9D9";let Z=String(Q).trim();if(Z.startsWith("{"))try{let $=JSON.parse(Z);if($?.color)return this.#N($.color)}catch{}if(Z.startsWith("#"))return this.#K(Z);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Z))return this.#K(Z);try{let{ctx:$}=_0(1,1);$.fillStyle="#000000",$.fillStyle=Z;let J=$.fillStyle;if(J.startsWith("#"))return this.#K(J);let j=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let _=(q)=>Math.max(0,Math.min(255,Number(q))).toString(16).padStart(2,"0");return`#${_(j[1])}${_(j[2])}${_(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#L(){let Q=this.getAttribute("value"),Z=this.#N(Q),$=this.#U(Q);if(Q!==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.#X)this.#Z.removeAttribute("alpha");else this.#Z.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}if(this.#Q){if(this.#O(),this.#Q.setAttribute("background",Z),$<1)this.#Q.setAttribute("alpha",String($));else this.#Q.removeAttribute("alpha");if(this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}}#O(){let Q=this.#q,Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",Z?"true":"false"),this.setAttribute("aria-pressed",$?"true":"false"),Q==="add"||Q==="remove"){let G=this.querySelector("fig-button"),X=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");if(G?.setAttribute("aria-label",X),Z)G?.setAttribute("disabled","");else G?.removeAttribute("disabled");return}let J=this.#Z||this.#Q;if(!J)return;let j=this.getAttribute("aria-label")||"Color stop",_=this.getAttribute("aria-labelledby"),q=this.getAttribute("aria-describedby");if(_)J.setAttribute("aria-labelledby",_),J.removeAttribute("aria-label");else J.setAttribute("aria-label",j),J.removeAttribute("aria-labelledby");if(q)J.setAttribute("aria-describedby",q);else J.removeAttribute("aria-describedby")}#B(Q,Z){let $=this.#N(Q?.color),J=this.#N(this.getAttribute("value"));if($!==J)this.setAttribute("value",$);else this.#L();let j={color:this.value};if(this.#X){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent(Z,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#M(Q){Q.stopPropagation(),this.#B(Q.detail||{color:Q.target?.value},"input")}#z(Q){Q.stopPropagation(),this.#B(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(!this.isConnected)return;switch(Q){case"control":this.#W();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#L(),this.#O();break}}get value(){return this.#N(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#N(Q))}get selected(){return this.hasAttribute("selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return this.hasAttribute("disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}customElements.define("fig-color-tip",X1);class K1 extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false"),this.hasAttribute("disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false");if(Q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}customElements.define("fig-choice",K1);class Y1 extends HTMLElement{#Z=null;#Q=this.#z.bind(this);#J=this.#A.bind(this);#$=this.#H.bind(this);#j=null;#q=null;#_=null;#G=null;#X=null;#W=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#Y(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#K(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#U(){return this.getAttribute("choice-element")||"fig-choice"}#N(){let Q=this.getAttribute("columns"),Z=Q===null?NaN:Number(Q);if(Number.isInteger(Z)&&Z>0)this.style.setProperty("--fig-chooser-grid-columns",String(Z));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from(this.querySelectorAll(`:scope > ${this.#U}`))}get selectedChoice(){return this.#Z}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let Z=this.choices;for(let J of Z){let j=J===Q,_=J.hasAttribute("selected");if(j&&!_)J.setAttribute("selected","");else if(!j&&_)J.removeAttribute("selected")}this.#Z=Q;let $=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==$){if($)this.setAttribute("value",$)}this.#P(Q)}get value(){return this.#Z?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){if(this.setAttribute("role","listbox"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#N(),this.#k(),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#J),this.addEventListener("scroll",this.#$),this.#f(),this.#F(),this.#I(),this.#R(),b(this,()=>{this.#O(),this.#H(),this.#L()})}#L(){let Q=()=>{if(!this.isConnected)return;if(this.#Z)this.#P(this.#Z,"auto")},Z=()=>{let $=this.querySelectorAll("img, video");for(let J of $){if(J.tagName==="IMG"?J.complete:J.readyState>=1)continue;let j=()=>{J.removeEventListener("load",j),J.removeEventListener("loadedmetadata",j),J.removeEventListener("error",j),Q()};J.addEventListener("load",j),J.addEventListener("loadedmetadata",j),J.addEventListener("error",j)}};requestAnimationFrame(()=>{Z(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#J),this.removeEventListener("scroll",this.#$),this.#S(),this.#j?.disconnect(),this.#j=null,this.#q?.disconnect(),this.#q=null,this.#T()}attributeChangedCallback(Q,Z,$){if(Q==="value"&&$!==Z&&$)this.#B($);if(Q==="disabled"){let J=$!==null&&$!=="false",j=this.choices;for(let _ of j)if(J)_.setAttribute("aria-disabled","true"),_.setAttribute("tabindex","-1");else _.removeAttribute("aria-disabled"),_.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#O());if(Q==="columns")this.#N();if(Q==="drag")if(this.#K)this.#F();else this.#S();if(Q==="overflow")this.#f();if(Q==="layout")this.#f(),requestAnimationFrame(()=>this.#H())}#O(){let Q=this.choices;if(!Q.length){this.#Z=null;return}let Z=this.getAttribute("value");if(Z&&this.#B(Z))return;let $=Q.find((J)=>J.hasAttribute("selected"));if($){this.selectedChoice=$;return}this.selectedChoice=Q[0]}#B(Q){let Z=this.choices;for(let $ of Z)if($.getAttribute("value")===Q)return this.selectedChoice=$,!0;return!1}#M(Q){let Z=this.#U,$=Q;while($&&$!==this){if($.matches(Z))return $;$=$.parentElement}return null}#z(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#M(Q.target);if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.selectedChoice=Z,this.#D()}#A(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.choices.filter((_)=>!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false");if(!Z.length)return;let $=Z.indexOf(this.#Z),J=$,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),$<Z.length-1)J=$+1;else if(j)J=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),$>0)J=$-1;else if(j)J=Z.length-1;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#U)){let _=this.#M(document.activeElement);if(_&&_!==this.#Z)this.selectedChoice=_,this.#D()}return;default:return}if(J!==$&&Z[J])this.selectedChoice=Z[J],Z[J].focus(),this.#D()}#D(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#H(){if(this.#Y==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal";F0(this,this,Q?"x":"y")}#R(){this.#q?.disconnect(),this.#q=new ResizeObserver(()=>{this.#H()}),this.#q.observe(this)}#F(){if(this.#X?.bound)return;if(!this.#K)return;let Q=(_)=>{if(_.button!==0)return;if(_.target.closest("[data-fig-chooser-nav]"))return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#X.active=!0,this.#X.didDrag=!1,this.#X.startX=_.clientX,this.#X.startY=_.clientY,this.#X.scrollLeft=this.scrollLeft,this.#X.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Z=(_)=>{if(!this.#X.active)return;let q=this.getAttribute("layout")==="horizontal",G=_.clientX-this.#X.startX,X=_.clientY-this.#X.startY;if(!this.#X.didDrag&&Math.abs(q?G:X)>3)this.#X.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(_.pointerId);if(!this.#X.didDrag)return;if(q)this.scrollLeft=this.#X.scrollLeft-G;else this.scrollTop=this.#X.scrollTop-X},$=(_)=>{if(!this.#X.active)return;let q=this.#X.didDrag;if(this.#X.active=!1,this.#X.didDrag=!1,this.style.cursor="",this.style.userSelect="",_.pointerId!==void 0)try{this.releasePointerCapture(_.pointerId)}catch{}if(q)_.preventDefault(),_.stopPropagation()},J=(_)=>{if(this.#X?.suppressClick)_.stopPropagation(),_.preventDefault(),this.#X.suppressClick=!1},j=(_)=>{if(this.#X?.didDrag)this.#X.suppressClick=!0,setTimeout(()=>{if(this.#X)this.#X.suppressClick=!1},0)};this.#X={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:Q,onPointerMove:Z,onPointerUp:$,onClick:J,onPointerUpCapture:j},this.addEventListener("pointerdown",Q),window.addEventListener("pointermove",Z),window.addEventListener("pointerup",$),this.addEventListener("pointerup",j,!0),this.addEventListener("click",J,!0)}#S(){if(!this.#X?.bound)return;this.removeEventListener("pointerdown",this.#X.onPointerDown),window.removeEventListener("pointermove",this.#X.onPointerMove),window.removeEventListener("pointerup",this.#X.onPointerUp),this.removeEventListener("pointerup",this.#X.onPointerUpCapture,!0),this.removeEventListener("click",this.#X.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#X=null}#k(){if(this.#W)return;let Q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!Q)return;this.#W=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#W=!1}}#f(){if(this.#Y==="scrollbar")this.#T();else this.#C()}#T(){this.#_?.remove(),this.#G?.remove(),this.#_=null,this.#G=null,this.classList.remove("overflow-start","overflow-end")}#C(){if(this.#_&&this.#G&&this.contains(this.#_)&&this.contains(this.#G))return;this.#_?.remove(),this.#G?.remove(),this.#_=null,this.#G=null;let Q=A0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#E(-1),onEnd:()=>this.#E(1)});this.#_=Q.start,this.#G=Q.end,this.prepend(this.#_),this.append(this.#G)}#E(Q){let Z=this.getAttribute("layout")==="horizontal";J0(this,Z?"x":"y",Q)}#P(Q,Z="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let $=this.scrollHeight>this.clientHeight,J=this.scrollWidth>this.clientWidth;if(!J&&!$)return;let j=Q.getBoundingClientRect(),_=this.getBoundingClientRect(),q={behavior:Z},G=!1,X=2;if($){let K=j.top>=_.top-1&&j.bottom<=_.bottom+1,N=j.top>=_.top-1,B=j.bottom<=_.bottom+1,L=this.scrollTop<=X;if(!K&&(!N||!B&&!L||j.top>=_.bottom-1)){let U=j.top-_.top+this.scrollTop,W=this.scrollHeight-this.clientHeight;q.top=Math.max(0,Math.min(U+j.height/2-this.clientHeight/2,W)),G=!0}}if(J){let K=j.left>=_.left-1&&j.right<=_.right+1,N=j.left>=_.left-1,B=j.right<=_.right+1,L=this.scrollLeft<=X;if(!K&&(!N||!B&&!L||j.left>=_.right-1)){let U=j.left-_.left+this.scrollLeft,W=this.scrollWidth-this.clientWidth;q.left=Math.max(0,Math.min(U+j.width/2-this.clientWidth/2,W)),G=!0}}if(G)this.scrollTo(q);this.#H()})}#I(){this.#j?.disconnect(),this.#j=new MutationObserver(()=>{if(this.#W)return;this.#k(),this.#f();let Q=this.choices;if(this.#Z&&!Q.includes(this.#Z))this.#Z=null,this.#O();else if(!this.#Z&&Q.length)this.#O();requestAnimationFrame(()=>this.#H())}),this.#j.observe(this,{childList:!0,subtree:!1})}}customElements.define("fig-chooser",Y1);class N1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#Z=!1;#Q=!1;#J=null;#$=!1;#j=null;#q=null;#_=null;#G=null;get#X(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#W(){return!this.hasAttribute("data-no-color-picker")}get#Y(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#K(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#U(){let Q=this.getAttribute("drag-snapping");if(Q===null)return"false";let Z=Q.trim().toLowerCase();if(Z==="modifier")return"modifier";if(Z===""||Z==="true")return"true";return"false"}#N(Q){let Z=this.#U;if(Z==="true")return!0;if(Z==="modifier")return!!Q;return!1}#L(Q){if(Q<0.1)return 0;if(Q>0.9)return 1;if(Q>0.4&&Q<0.6)return 0.5;return Q}#O(Q,Z){if(Math.abs(Q-Z)<0.1){let J=(Q+Z)/2;return{x:J,y:J}}if(Math.abs(1-Q-Z)<0.1)return{x:Q,y:1-Q};return{x:Q,y:Z}}#B(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#B();if(!Q)return"0% 0%";let{px:Z,py:$}=this.#l(Q.getBoundingClientRect());return`${Math.round(Z*100)}% ${Math.round($*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#M(Q){let Z=Q==null?"":String(Q).trim();if(!Z)return{xPct:0,yPct:0};let $=Z.split(/[\s,]+/).filter(Boolean),J=(q)=>{if(!q)return 0;let G=q.includes("px"),X=q.includes("%"),K=parseFloat(q.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(G)return{px:K};if(X||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},j=J($[0]),_=J($[1]??$[0]);return{xToken:j,yToken:_}}#z(Q){let Z=this.#B();if(!Z)return;let{xToken:$,yToken:J}=this.#M(Q),j=Z.getBoundingClientRect(),_=(X,K)=>{if(X&&typeof X==="object"&&"px"in X)return Math.max(0,Math.min(K,X.px));return null},q=(X)=>{return`${typeof X==="number"?X:0}%`},G=this.#K;if(this.#A(G),G.x){let X=_($,j.width);this.style.left=X===null?q($):`${Math.round(X)}px`}if(G.y){let X=_(J,j.height);this.style.top=X===null?q(J):`${Math.round(X)}px`}}#A(Q=this.#K){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#D(){this.#$=!0,this.setAttribute("value",this.value),this.#$=!1}get#H(){return this.getAttribute("hit-area-mode")||"handle"}#R(){let Q=this.getAttribute("hit-area");if(!Q)return null;let Z=Q.trim().split(/\s+/),$=0,J=0,j=!1,_=[];for(let q of Z){if(q==="circle"){j=!0;continue}let G=parseFloat(q);if(Number.isFinite(G))_.push(G)}if(_.length>=2)$=_[0],J=_[1];else if(_.length===1)$=_[0],J=_[0];else return null;return{vPad:$,hPad:J,circle:j}}#F(){let Q=this.#R();if(!Q){if(this.#G)this.#G.remove(),this.#G=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#G){let Z=document.createElement("div");Z.classList.add("fig-handle-hit-area"),Z.addEventListener("pointerdown",($)=>this.#S($)),this.prepend(Z),this.#G=Z}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#G.style.borderRadius="50%";else this.#G.style.borderRadius="inherit"}#S(Q){if(this.hasAttribute("disabled"))return;if(Q.target!==this.#G)return;if(this.#H==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#g(Q)}connectedCallback(){this.#P(),this.#E(),this.#F(),this.addEventListener("click",this.#k),document.addEventListener("pointerdown",this.#f),document.addEventListener("keydown",this.#T);let Q=this.getAttribute("value");if(Q)this.#z(Q);if(this.#X)this.#s()}disconnectedCallback(){if(this.#I(),this.#t(),this.#b(),this.#u(),this.#G)this.#G.remove(),this.#G=null;this.removeEventListener("click",this.#k),document.removeEventListener("pointerdown",this.#f),document.removeEventListener("keydown",this.#T)}select(){if(this.hasAttribute("disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#k=(Q)=>{if(this.#Q){this.#Q=!1;return}if(this.getAttribute("type")==="color"&&this.#W&&!this.#X){this.#h();return}this.select()};#f=(Q)=>{if(this.contains(Q.target))return;if((this.#j||this.#q)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#T=(Q)=>{if(Q.defaultPrevented)return;if(Q.target===this&&this.#Y&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Q.key)){if(this.#C(Q)){if(Q.preventDefault(),!this.hasAttribute("selected"))this.select()}return}if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target===this&&!this.hasAttribute("selected")){if(Q.preventDefault(),this.getAttribute("type")==="color"&&this.#W&&!this.#X)this.#h();else this.select();return}if(!this.hasAttribute("selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#W)return;if(Q.preventDefault(),!this.#X)this.#h()};#C(Q){if(this.hasAttribute("disabled"))return!1;let Z=this.#B();if(!Z)return!1;let $=Z.getBoundingClientRect();if($.width<=0||$.height<=0)return!1;let J=this.#K,j=this.#l($),_=Q.shiftKey?0.1:0.01,q=j.px,G=j.py;switch(Q.key){case"ArrowLeft":if(!J.x)return!1;q-=_;break;case"ArrowRight":if(!J.x)return!1;q+=_;break;case"ArrowUp":if(!J.y)return!1;G-=_;break;case"ArrowDown":if(!J.y)return!1;G+=_;break;case"Home":if(J.x)q=0;if(J.y)G=0;break;case"End":if(J.x)q=1;if(J.y)G=1;break;default:return!1}if(q=Math.max(0,Math.min(1,q)),G=Math.max(0,Math.min(1,G)),this.#A(J),J.x)this.style.left=`${Math.round(q*$.width)}px`;if(J.y)this.style.top=`${Math.round(G*$.height)}px`;this.#D();let X={...this.#l($),shiftKey:Q.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:X})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:X})),!0}attributeChangedCallback(Q,Z,$){if(Q==="color"){if(!$||$==="false"||$==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",$);if(this.#j&&this.#X==="color"&&$)this.#j.setAttribute("value",$);this.#w()}if(Q==="drag")this.#E();if(Q==="hit-area")this.#F();if(Q==="selected")this.#Q0();if(Q==="selected"||Q==="disabled"||Q==="type"||Q==="tip"||Q==="aria-label"||Q==="aria-labelledby")this.#P();if(Q==="value"&&!this.#$&&!this.#Z)this.#z($);if(Q==="tip"){if(this.#t(),this.#X)this.#b(),this.#s()}}#E(){if(this.#Y&&!this.#J)this.#J=(Q)=>this.#g(Q),this.addEventListener("pointerdown",this.#J);else if(!this.#Y&&this.#J)this.#I()}#P(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex",Q?"-1":"0");else if(Q)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",Q?"true":"false"),this.setAttribute("aria-pressed",Z?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let $=this.#X||this.getAttribute("type")||"handle";this.setAttribute("aria-label",$==="color"?"Color handle":$==="add"?"Add handle":$==="remove"?"Remove handle":"Handle")}}#I(){if(this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#Z=!1}#g(Q){if(!this.#Y||this.hasAttribute("disabled"))return;Q.preventDefault();let Z=this.#B();if(!Z)return;this.#Z=!0;let $=this.#K,J=null,j=this.getBoundingClientRect(),_=j.left+j.width/2,q=j.top+j.height/2,G=Q.clientX-_,X=Q.clientY-q,K=Q.clientX,N=Q.clientY,B=3,L=(W,R,z=!1)=>{let M=Z.getBoundingClientRect();J=M;let O=this.#l(M),T=W-G-M.left,C=R-X-M.top,k=Math.max(0,Math.min(M.width,T)),I=Math.max(0,Math.min(M.height,C)),S=M.width>0?$.x?k/M.width:O.px:0.5,w=M.height>0?$.y?I/M.height:O.py:0.5;if(this.#N(z)){if($.x)S=this.#L(S);if($.y)w=this.#L(w);if($.x&&$.y){let d=this.#O(S,w);S=d.x,w=d.y}}if(this.#A($),$.x)this.style.left=`${Math.round(Math.max(0,Math.min(M.width,S*M.width)))}px`;if($.y)this.style.top=`${Math.round(Math.max(0,Math.min(M.height,w*M.height)))}px`},A=(W)=>{if(!this.#Z)return;if(!this.#Q){let R=W.clientX-K,z=W.clientY-N;if(R*R+z*z<B*B)return;if(this.#d(),this.classList.add("dragging"),this.style.cursor="grabbing",!this.hasAttribute("selected"))this.select()}this.#Q=!0,L(W.clientX,W.clientY,W.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#l(J),shiftKey:W.shiftKey}}))},U=(W)=>{if(this.#Z=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",U),this.#Q){L(W.clientX,W.clientY,W.shiftKey),this.#D(),this.#z(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#l(J)}));let R=(z)=>{z.stopPropagation(),z.preventDefault()};this.addEventListener("click",R,{capture:!0,once:!0})}else this.#D();this.#Q=!1};window.addEventListener("pointermove",A),window.addEventListener("pointerup",U)}showColorTip(){if(!this.#X)return;if(this.#j){this.#j.style.display="";return}this.#s()}hideColorTip(){if(!this.#j)return;this.#j.style.display="none"}#V(Q=this.getAttribute("color")){let Z={color:"#D9D9D9",opacity:100},$=String(Q||"").trim();if(!$)return Z;let J=(_)=>{let q=_.replace("#","").trim();if(q.length===3||q.length===4){let[G,X,K,N]=q;return{color:`#${G}${G}${X}${X}${K}${K}`.toUpperCase(),opacity:N?Math.round(parseInt(`${N}${N}`,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},j=(_,q,G)=>{let X=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${X(_)}${X(q)}${X(G)}`.toUpperCase()};if($.startsWith("#"))return J($);try{let{ctx:_}=_0(1,1);_.fillStyle="#000000",_.fillStyle=$;let q=_.fillStyle;if(q.startsWith("#"))return J(q);let G=q.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(G)return{color:j(G[1],G[2],G[3]),opacity:G[4]!==void 0?Math.round(parseFloat(G[4])*100):100}}catch{}return Z}#y(){let{color:Q,opacity:Z}=this.#V();return JSON.stringify(Z<100?{type:"solid",color:Q,opacity:Z}:{type:"solid",color:Q})}#w(){if(!this.#q)return;this.#q.setAttribute("value",this.#y())}#v(){if(!u())return null;if(this.#q)return this.#q;let Q=document.createElement("fig-fill-picker");Q.setAttribute("mode","solid"),Q.setAttribute("alpha","true"),Q.setAttribute("dialog-offset","8 8"),Q.setAttribute("value",this.#y()),Q.anchorElement=this;let Z=document.createElement("span");return Z.hidden=!0,Q.appendChild(Z),Q.addEventListener("input",this.#p),Q.addEventListener("change",this.#e),Q.addEventListener("close",this.#j0),this.appendChild(Q),this.#q=Q,Q}#h(){if(this.hasAttribute("disabled"))return;let Q=this.#v();if(!Q){this.#m();return}this.setAttribute("selected",""),this.#w(),Q.open()}#b(){if(!this.#q)return;this.#q.removeEventListener("input",this.#p),this.#q.removeEventListener("change",this.#e),this.#q.removeEventListener("close",this.#j0),this.#q.close(),this.#q.remove(),this.#q=null,this.removeAttribute("selected")}#x(){if(this.#_)return this.#_;let Q=document.createElement("input");return Q.type="color",Q.tabIndex=-1,Q.setAttribute("aria-hidden","true"),Q.style.position="fixed",Q.style.inlineSize="1px",Q.style.blockSize="1px",Q.style.opacity="0",Q.style.pointerEvents="none",Q.addEventListener("input",this.#$0),Q.addEventListener("change",this.#J0),this.appendChild(Q),this.#_=Q,Q}#m(){let Q=this.#x(),{color:Z}=this.#V();Q.value=Z,this.setAttribute("selected",""),Q.click()}#u(){if(!this.#_)return;this.#_.removeEventListener("input",this.#$0),this.#_.removeEventListener("change",this.#J0),this.#_.remove(),this.#_=null}#d(){if(this.getAttribute("type")!=="color")return;this.#q?.close()}#s(){let Q=this.#X;if(!Q)return;if(this.#j)return;let Z=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")Z.setAttribute("control",Q);else Z.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Z.setAttribute("alpha","true");Z.addEventListener("input",this.#a),Z.addEventListener("change",this.#c),Z.addEventListener("add",this.#n),Z.addEventListener("remove",this.#n),this.appendChild(Z),this.#j=Z,this.#Q0()}#t(){if(!this.#j)return;this.#j.removeEventListener("input",this.#a),this.#j.removeEventListener("change",this.#c),this.#j.removeEventListener("add",this.#n),this.#j.removeEventListener("remove",this.#n),this.#j.remove(),this.#j=null}#Q0(){if(!this.#j||this.#X!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#j.toggleAttribute("selected",Q)}#o(Q,Z){if(Z===void 0||Z>=100)return Q;let{r:$,g:J,b:j}=c(Q);return`rgba(${$}, ${J}, ${j}, ${Z/100})`}#i(Q){if(!Q?.color)return null;let Z=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:Z}}#p=(Q)=>{Q.stopPropagation();let Z=this.#i(Q.detail);if(!Z)return;this.setAttribute("color",this.#o(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#e=(Q)=>{Q.stopPropagation();let Z=this.#i(Q.detail);if(!Z)return;this.setAttribute("color",this.#o(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#Z0(Q){let{opacity:Z}=this.#V();return Z<100?{color:Q,opacity:Z}:{color:Q}}#$0=(Q)=>{Q.stopPropagation();let Z=this.#Z0(Q.target.value);this.setAttribute("color",this.#o(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#J0=(Q)=>{Q.stopPropagation();let Z=this.#Z0(Q.target.value);this.setAttribute("color",this.#o(Z.color,Z.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#j0=()=>{this.removeAttribute("selected")};#a=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#o(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#c=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#o(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#n=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#l(Q){let Z=Q||this.#B()?.getBoundingClientRect();if(!Z)return{x:0,y:0,px:0,py:0};let $=this.getBoundingClientRect(),J=this.offsetWidth/2,j=this.offsetHeight/2,_=$.left-Z.left,q=$.top-Z.top,G=_+J,X=q+j,K=Z.width>0?G/Z.width:0,N=Z.height>0?X/Z.height:0;return{x:_,y:q,px:K,py:N}}}customElements.define("fig-handle",N1);class W1 extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="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")}}customElements.define("fig-menu-item",W1);class U1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","separator")}}customElements.define("fig-menu-separator",U1);class L1 extends HTMLElement{#Z=null;#Q=null;#J=null;#$;#j;#q;#_;#G=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open"]}constructor(){super();this.#$=this.#z.bind(this),this.#j=this.#A.bind(this),this.#q=this.#D.bind(this),this.#_=this.#H.bind(this)}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(this.#X(),this.#W(),this.#Y(),this.#K(),this.#N(),this.#M(),this.open)this.#F()}disconnectedCallback(){if(this.#U(),document.removeEventListener("keydown",this.#q,!0),this.#J)this.#J.disconnect(),this.#J=null;if(this.#Z)this.#Z.removeEventListener("close",this.#_),this.#Z.remove(),this.#Z=null}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){if($===null||$==="false")this.#S();else this.#F();return}if(Q==="disabled"){if(this.#Q)if($!==null&&$!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");return}if(this.#Z&&(Q==="position"||Q==="offset"||Q==="closedby"))if($!==null)this.#Z.setAttribute(Q,$);else this.#Z.removeAttribute(Q)}#X(){this.#Q=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#W(){this.#Z=document.createElement("dialog",{is:"fig-popup"}),this.#Z.setAttribute("is","fig-popup"),this.#Z.setAttribute("theme","menu"),this.#Z.setAttribute("role","menu"),this.#Z.setAttribute("id",this.#Z.getAttribute("id")||y());let Q=this.getAttribute("position")||"bottom left";this.#Z.setAttribute("position",Q);let Z=this.getAttribute("offset");if(Z)this.#Z.setAttribute("offset",Z);let $=this.getAttribute("closedby");if($)this.#Z.setAttribute("closedby",$);if(this.#Q)this.#Z.anchor=this.#Q;this.#Z.addEventListener("close",this.#_),this.appendChild(this.#Z)}#Y(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let Z of Q)this.#Z.appendChild(Z)}#K(){if(this.addEventListener("keydown",this.#q),this.#Q)this.#Q.addEventListener("click",this.#$),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#Z.getAttribute("id"));if(this.#Z)this.#Z.addEventListener("click",this.#j),this.#Z.addEventListener("keydown",this.#q)}#U(){if(this.removeEventListener("keydown",this.#q),this.#Q)this.#Q.removeEventListener("click",this.#$);if(this.#Z)this.#Z.removeEventListener("click",this.#j),this.#Z.removeEventListener("keydown",this.#q)}#N(){this.#J=new MutationObserver((Q)=>{for(let Z of Q)for(let $ of Z.addedNodes){if($.nodeType!==1||$===this.#Z)continue;if(($.tagName==="FIG-MENU-ITEM"||$.tagName==="FIG-MENU-SEPARATOR")&&$.parentElement===this)this.#Z.appendChild($);else if(!this.#Q&&$.parentElement===this){if(this.#X(),this.#Q)this.#Q.addEventListener("click",this.#$),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#Z.getAttribute("id")),this.#Z.anchor=this.#Q,this.#M()}}}),this.#J.observe(this,{childList:!0})}#L(){if(!this.#Z)return[];return Array.from(this.#Z.querySelectorAll("fig-menu-item")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#O(){let Q=this.#L();if(!Q.length){this.#G=-1;return}let Z=document.activeElement,$=Q.findIndex((J)=>J===Z||J.contains(Z));this.#G=$>=0?$:-1}#B(Q){let Z=this.#L();if(!Z.length)return;let $=(Q+Z.length)%Z.length;this.#G=$,Z[$].focus()}#M(){if(!this.#Q)return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.#Q.setAttribute("disabled",""),this.#Q.setAttribute("aria-disabled","true"),this.#Q.setAttribute("aria-expanded","false");else this.#Q.removeAttribute("disabled"),this.#Q.removeAttribute("aria-disabled")}#z(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.stopPropagation();let Z=this.#Z?.matches?.(":open")??!1;if(this.open&&!Z)this.removeAttribute("open");if(this.open&&Z)this.open=!1;else this.open=!0}#A(Q){let Z=Q.target.closest("fig-menu-item");if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#R(Z)}#D(Q){if(Q.currentTarget===document&&Q.key!=="Escape")return;if(Q.currentTarget===this&&this.#Z?.contains(Q.target))return;if(!this.open||!this.#Z?.matches?.(":open")){if(this.#Q?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" "))Q.preventDefault(),this.open=!0,requestAnimationFrame(()=>this.#B(0));return}let Z=this.#L();if(!Z.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#O(),this.#B(this.#G+1);break}case"ArrowUp":{Q.preventDefault(),this.#O(),this.#B(this.#G-1);break}case"Home":{Q.preventDefault(),this.#B(0);break}case"End":{Q.preventDefault(),this.#B(Z.length-1);break}case"Escape":{Q.preventDefault(),this.open=!1,this.#Q?.focus();break}case"Enter":case" ":{this.#O();let $=Z[this.#G];if(!$)return;Q.preventDefault(),this.#R($);break}}}#H(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#Q)this.#Q.setAttribute("aria-expanded","false"),this.#Q.focus();this.#G=-1}#R(Q){let Z=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("change",{detail:{value:Z,item:Q},bubbles:!0})),this.open=!1}#F(){if(!this.#Z)return;if(this.#Z.open=!0,document.addEventListener("keydown",this.#q,!0),this.#Q)this.#Q.setAttribute("aria-expanded","true");this.#G=-1,requestAnimationFrame(()=>{if(!this.#Q?.matches?.(":focus-visible"))return;this.#B(0)})}#S(){if(!this.#Z)return;document.removeEventListener("keydown",this.#q,!0),this.#Z.open=!1,this.#Q?.setAttribute("aria-expanded","false")}}customElements.define("fig-menu",L1);
270
+ </fig-fill-picker>`:`<fig-chit background="${$}"${q}></fig-chit>`,this.#Z=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-chit"),this.#_(),this.#Z?.addEventListener("input",this.#$),this.#Z?.addEventListener("change",this.#j),!this.#Z)this.#Q?.addEventListener("input",this.#$),this.#Q?.addEventListener("change",this.#j);this.#G(),this.#H()}#Y=()=>{let Q=this.#q;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#K(Q){if(!Q)return"#D9D9D9";let Z=Q.replace("#","").trim();if(Z.length===3||Z.length===4){let[$,J,j]=Z;return`#${$}${$}${J}${J}${j}${j}`.toUpperCase()}if(Z.length===6||Z.length===8)return`#${Z.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#U(Q){if(!Q)return 1;let Z=String(Q).trim(),$=Z.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test($)){let j=$[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test($))return parseInt($.slice(6,8),16)/255;let J=Z.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(J)return parseFloat(J[1]);return 1}#N(Q){if(!Q)return"#D9D9D9";let Z=String(Q).trim();if(Z.startsWith("{"))try{let $=JSON.parse(Z);if($?.color)return this.#N($.color)}catch{}if(Z.startsWith("#"))return this.#K(Z);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Z))return this.#K(Z);try{let{ctx:$}=X0(1,1);$.fillStyle="#000000",$.fillStyle=Z;let J=$.fillStyle;if(J.startsWith("#"))return this.#K(J);let j=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let _=(q)=>Math.max(0,Math.min(255,Number(q))).toString(16).padStart(2,"0");return`#${_(j[1])}${_(j[2])}${_(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#L(){let Q=this.getAttribute("value"),Z=this.#N(Q),$=this.#U(Q);if(Q!==Z&&$>=1){this.setAttribute("value",Z);return}if(this.#Z){this.#H();let J=$<1?{type:"solid",color:Z,opacity:Math.round($*100)}:{type:"solid",color:Z};if(this.#Z.setAttribute("value",JSON.stringify(J)),this.#X)this.#Z.removeAttribute("alpha");else this.#Z.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}if(this.#Q){if(this.#H(),this.#Q.setAttribute("background",Z),$<1)this.#Q.setAttribute("alpha",String($));else this.#Q.removeAttribute("alpha");if(this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}}#H(){let Q=this.#q,Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",Z?"true":"false"),this.setAttribute("aria-pressed",$?"true":"false"),Q==="add"||Q==="remove"){let G=this.querySelector("fig-button"),X=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");if(G?.setAttribute("aria-label",X),Z)G?.setAttribute("disabled","");else G?.removeAttribute("disabled");return}let J=this.#Z||this.#Q;if(!J)return;let j=this.getAttribute("aria-label")||"Color stop",_=this.getAttribute("aria-labelledby"),q=this.getAttribute("aria-describedby");if(_)J.setAttribute("aria-labelledby",_),J.removeAttribute("aria-label");else J.setAttribute("aria-label",j),J.removeAttribute("aria-labelledby");if(q)J.setAttribute("aria-describedby",q);else J.removeAttribute("aria-describedby")}#B(Q,Z){let $=this.#N(Q?.color),J=this.#N(this.getAttribute("value"));if($!==J)this.setAttribute("value",$);else this.#L();let j={color:this.value};if(this.#X){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent(Z,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#M(Q){Q.stopPropagation(),this.#B(Q.detail||{color:Q.target?.value},"input")}#F(Q){Q.stopPropagation(),this.#B(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(!this.isConnected)return;switch(Q){case"control":this.#W();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#L(),this.#H();break}}get value(){return this.#N(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#N(Q))}get selected(){return this.hasAttribute("selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return this.hasAttribute("disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}customElements.define("fig-color-tip",W1);class U1 extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false"),this.hasAttribute("disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false");if(Q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}customElements.define("fig-choice",U1);class L1 extends HTMLElement{#Z=null;#Q=this.#F.bind(this);#J=this.#O.bind(this);#$=this.#z.bind(this);#j=null;#q=null;#_=null;#G=null;#X=null;#W=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#Y(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#K(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#U(){return this.getAttribute("choice-element")||"fig-choice"}#N(){let Q=this.getAttribute("columns"),Z=Q===null?NaN:Number(Q);if(Number.isInteger(Z)&&Z>0)this.style.setProperty("--fig-chooser-grid-columns",String(Z));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from(this.querySelectorAll(`:scope > ${this.#U}`))}get selectedChoice(){return this.#Z}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let Z=this.choices;for(let J of Z){let j=J===Q,_=J.hasAttribute("selected");if(j&&!_)J.setAttribute("selected","");else if(!j&&_)J.removeAttribute("selected")}this.#Z=Q;let $=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==$){if($)this.setAttribute("value",$)}this.#x(Q)}get value(){return this.#Z?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){if(this.setAttribute("role","listbox"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#N(),this.#C(),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#J),this.addEventListener("scroll",this.#$),this.#R(),this.#D(),this.#g(),this.#P(),b(this,()=>{this.#H(),this.#z(),this.#L()})}#L(){let Q=()=>{if(!this.isConnected)return;if(this.#Z)this.#x(this.#Z,"auto")},Z=()=>{let $=this.querySelectorAll("img, video");for(let J of $){if(J.tagName==="IMG"?J.complete:J.readyState>=1)continue;let j=()=>{J.removeEventListener("load",j),J.removeEventListener("loadedmetadata",j),J.removeEventListener("error",j),Q()};J.addEventListener("load",j),J.addEventListener("loadedmetadata",j),J.addEventListener("error",j)}};requestAnimationFrame(()=>{Z(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#J),this.removeEventListener("scroll",this.#$),this.#E(),this.#j?.disconnect(),this.#j=null,this.#q?.disconnect(),this.#q=null,this.#f()}attributeChangedCallback(Q,Z,$){if(Q==="value"&&$!==Z&&$)this.#B($);if(Q==="disabled"){let J=$!==null&&$!=="false",j=this.choices;for(let _ of j)if(J)_.setAttribute("aria-disabled","true"),_.setAttribute("tabindex","-1");else _.removeAttribute("aria-disabled"),_.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#H());if(Q==="columns")this.#N(),this.#T();if(Q==="drag")if(this.#K)this.#D();else this.#E();if(Q==="overflow")this.#R(),requestAnimationFrame(()=>this.#z());if(Q==="layout"){if(this.#R(),$==="horizontal")this.scrollTop=0;else this.scrollLeft=0;this.#T()}}#H(){let Q=this.choices;if(!Q.length){this.#Z=null;return}let Z=this.getAttribute("value");if(Z&&this.#B(Z))return;let $=Q.find((J)=>J.hasAttribute("selected"));if($){this.selectedChoice=$;return}this.selectedChoice=Q[0]}#B(Q){let Z=this.choices;for(let $ of Z)if($.getAttribute("value")===Q)return this.selectedChoice=$,!0;return!1}#M(Q){let Z=this.#U,$=Q;while($&&$!==this){if($.matches(Z))return $;$=$.parentElement}return null}#F(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#M(Q.target);if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.selectedChoice=Z,this.#A()}#O(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.choices.filter((_)=>!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false");if(!Z.length)return;let $=Z.indexOf(this.#Z),J=$,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),$<Z.length-1)J=$+1;else if(j)J=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),$>0)J=$-1;else if(j)J=Z.length-1;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#U)){let _=this.#M(document.activeElement);if(_&&_!==this.#Z)this.selectedChoice=_,this.#A()}return;default:return}if(J!==$&&Z[J])this.selectedChoice=Z[J],Z[J].focus(),this.#A()}#A(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#z(){if(this.#Y==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal";R0(this,this,Q?"x":"y")}#P(){this.#q?.disconnect(),this.#q=new ResizeObserver(()=>{this.#z(),this.#T()}),this.#q.observe(this)}#D(){if(this.#X?.bound)return;if(!this.#K)return;let Q=(_)=>{if(_.button!==0)return;if(_.target.closest("[data-fig-chooser-nav]"))return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#X.active=!0,this.#X.didDrag=!1,this.#X.startX=_.clientX,this.#X.startY=_.clientY,this.#X.scrollLeft=this.scrollLeft,this.#X.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Z=(_)=>{if(!this.#X.active)return;let q=this.getAttribute("layout")==="horizontal",G=_.clientX-this.#X.startX,X=_.clientY-this.#X.startY;if(!this.#X.didDrag&&Math.abs(q?G:X)>3)this.#X.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(_.pointerId);if(!this.#X.didDrag)return;if(q)this.scrollLeft=this.#X.scrollLeft-G;else this.scrollTop=this.#X.scrollTop-X},$=(_)=>{if(!this.#X.active)return;let q=this.#X.didDrag;if(this.#X.active=!1,this.#X.didDrag=!1,this.style.cursor="",this.style.userSelect="",_.pointerId!==void 0)try{this.releasePointerCapture(_.pointerId)}catch{}if(q)_.preventDefault(),_.stopPropagation()},J=(_)=>{if(this.#X?.suppressClick)_.stopPropagation(),_.preventDefault(),this.#X.suppressClick=!1},j=(_)=>{if(this.#X?.didDrag)this.#X.suppressClick=!0,setTimeout(()=>{if(this.#X)this.#X.suppressClick=!1},0)};this.#X={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:Q,onPointerMove:Z,onPointerUp:$,onClick:J,onPointerUpCapture:j},this.addEventListener("pointerdown",Q),window.addEventListener("pointermove",Z),window.addEventListener("pointerup",$),this.addEventListener("pointerup",j,!0),this.addEventListener("click",J,!0)}#E(){if(!this.#X?.bound)return;this.removeEventListener("pointerdown",this.#X.onPointerDown),window.removeEventListener("pointermove",this.#X.onPointerMove),window.removeEventListener("pointerup",this.#X.onPointerUp),this.removeEventListener("pointerup",this.#X.onPointerUpCapture,!0),this.removeEventListener("click",this.#X.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#X=null}#C(){if(this.#W)return;let Q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!Q)return;this.#W=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#W=!1}}#R(){if(this.#Y==="scrollbar")this.#f();else this.#S()}#f(){this.#_?.remove(),this.#G?.remove(),this.#_=null,this.#G=null,this.classList.remove("overflow-start","overflow-end")}#S(){if(this.#_&&this.#G&&this.contains(this.#_)&&this.contains(this.#G))return;this.#_?.remove(),this.#G?.remove(),this.#_=null,this.#G=null;let Q=D0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#k(-1),onEnd:()=>this.#k(1)});this.#_=Q.start,this.#G=Q.end,this.prepend(this.#_),this.append(this.#G)}#k(Q){let Z=this.getAttribute("layout")==="horizontal";q0(this,Z?"x":"y",Q)}#T(){if(!this.#Z)return;this.#x(this.#Z,"auto")}#x(Q,Z="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let $=this.scrollHeight>this.clientHeight,J=this.scrollWidth>this.clientWidth;if(!J&&!$)return;let j=Q.getBoundingClientRect(),_=this.getBoundingClientRect(),q={behavior:Z},G=!1;if($){let X=j.top-_.top+this.scrollTop,K=this.scrollHeight-this.clientHeight;q.top=Math.max(0,Math.min(X+j.height/2-this.clientHeight/2,K)),G=!0}if(J){let X=j.left-_.left+this.scrollLeft,K=this.scrollWidth-this.clientWidth;q.left=Math.max(0,Math.min(X+j.width/2-this.clientWidth/2,K)),G=!0}if(G)this.scrollTo(q);this.#z()})}#g(){this.#j?.disconnect(),this.#j=new MutationObserver(()=>{if(this.#W)return;this.#C(),this.#R();let Q=this.choices;if(this.#Z&&!Q.includes(this.#Z))this.#Z=null,this.#H();else if(!this.#Z&&Q.length)this.#H();requestAnimationFrame(()=>this.#z())}),this.#j.observe(this,{childList:!0,subtree:!1})}}customElements.define("fig-chooser",L1);class B1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#Z=!1;#Q=!1;#J=null;#$=!1;#j=null;#q=null;#_=null;#G=null;get#X(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#W(){return!this.hasAttribute("data-no-color-picker")}get#Y(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#K(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#U(){let Q=this.getAttribute("drag-snapping");if(Q===null)return"false";let Z=Q.trim().toLowerCase();if(Z==="modifier")return"modifier";if(Z===""||Z==="true")return"true";return"false"}#N(Q){let Z=this.#U;if(Z==="true")return!0;if(Z==="modifier")return!!Q;return!1}#L(Q){if(Q<0.1)return 0;if(Q>0.9)return 1;if(Q>0.4&&Q<0.6)return 0.5;return Q}#H(Q,Z){if(Math.abs(Q-Z)<0.1){let J=(Q+Z)/2;return{x:J,y:J}}if(Math.abs(1-Q-Z)<0.1)return{x:Q,y:1-Q};return{x:Q,y:Z}}#B(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#B();if(!Q)return"0% 0%";let{px:Z,py:$}=this.#a(Q.getBoundingClientRect());return`${Math.round(Z*100)}% ${Math.round($*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#M(Q){let Z=Q==null?"":String(Q).trim();if(!Z)return{xPct:0,yPct:0};let $=Z.split(/[\s,]+/).filter(Boolean),J=(q)=>{if(!q)return 0;let G=q.includes("px"),X=q.includes("%"),K=parseFloat(q.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(G)return{px:K};if(X||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},j=J($[0]),_=J($[1]??$[0]);return{xToken:j,yToken:_}}#F(Q){let Z=this.#B();if(!Z)return;let{xToken:$,yToken:J}=this.#M(Q),j=Z.getBoundingClientRect(),_=(X,K)=>{if(X&&typeof X==="object"&&"px"in X)return Math.max(0,Math.min(K,X.px));return null},q=(X)=>{return`${typeof X==="number"?X:0}%`},G=this.#K;if(this.#O(G),G.x){let X=_($,j.width);this.style.left=X===null?q($):`${Math.round(X)}px`}if(G.y){let X=_(J,j.height);this.style.top=X===null?q(J):`${Math.round(X)}px`}}#O(Q=this.#K){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#A(){this.#$=!0,this.setAttribute("value",this.value),this.#$=!1}get#z(){return this.getAttribute("hit-area-mode")||"handle"}#P(){let Q=this.getAttribute("hit-area");if(!Q)return null;let Z=Q.trim().split(/\s+/),$=0,J=0,j=!1,_=[];for(let q of Z){if(q==="circle"){j=!0;continue}let G=parseFloat(q);if(Number.isFinite(G))_.push(G)}if(_.length>=2)$=_[0],J=_[1];else if(_.length===1)$=_[0],J=_[0];else return null;return{vPad:$,hPad:J,circle:j}}#D(){let Q=this.#P();if(!Q){if(this.#G)this.#G.remove(),this.#G=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#G){let Z=document.createElement("div");Z.classList.add("fig-handle-hit-area"),Z.addEventListener("pointerdown",($)=>this.#E($)),this.prepend(Z),this.#G=Z}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#G.style.borderRadius="50%";else this.#G.style.borderRadius="inherit"}#E(Q){if(this.hasAttribute("disabled"))return;if(Q.target!==this.#G)return;if(this.#z==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#g(Q)}connectedCallback(){this.#T(),this.#k(),this.#D(),this.addEventListener("click",this.#C),document.addEventListener("pointerdown",this.#R),document.addEventListener("keydown",this.#f);let Q=this.getAttribute("value");if(Q)this.#F(Q);if(this.#X)this.#i()}disconnectedCallback(){if(this.#x(),this.#l(),this.#v(),this.#m(),this.#G)this.#G.remove(),this.#G=null;this.removeEventListener("click",this.#C),document.removeEventListener("pointerdown",this.#R),document.removeEventListener("keydown",this.#f)}select(){if(this.hasAttribute("disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#C=(Q)=>{if(this.#Q){this.#Q=!1;return}if(this.getAttribute("type")==="color"&&this.#W&&!this.#X){this.#h();return}this.select()};#R=(Q)=>{if(this.contains(Q.target))return;if((this.#j||this.#q)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#f=(Q)=>{if(Q.defaultPrevented)return;if(Q.target===this&&this.#Y&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Q.key)){if(this.#S(Q)){if(Q.preventDefault(),!this.hasAttribute("selected"))this.select()}return}if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target===this&&!this.hasAttribute("selected")){if(Q.preventDefault(),this.getAttribute("type")==="color"&&this.#W&&!this.#X)this.#h();else this.select();return}if(!this.hasAttribute("selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#W)return;if(Q.preventDefault(),!this.#X)this.#h()};#S(Q){if(this.hasAttribute("disabled"))return!1;let Z=this.#B();if(!Z)return!1;let $=Z.getBoundingClientRect();if($.width<=0||$.height<=0)return!1;let J=this.#K,j=this.#a($),_=Q.shiftKey?0.1:0.01,q=j.px,G=j.py;switch(Q.key){case"ArrowLeft":if(!J.x)return!1;q-=_;break;case"ArrowRight":if(!J.x)return!1;q+=_;break;case"ArrowUp":if(!J.y)return!1;G-=_;break;case"ArrowDown":if(!J.y)return!1;G+=_;break;case"Home":if(J.x)q=0;if(J.y)G=0;break;case"End":if(J.x)q=1;if(J.y)G=1;break;default:return!1}if(q=Math.max(0,Math.min(1,q)),G=Math.max(0,Math.min(1,G)),this.#O(J),J.x)this.style.left=`${Math.round(q*$.width)}px`;if(J.y)this.style.top=`${Math.round(G*$.height)}px`;this.#A();let X={...this.#a($),shiftKey:Q.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:X})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:X})),!0}attributeChangedCallback(Q,Z,$){if(Q==="color"){if(!$||$==="false"||$==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",$);if(this.#j&&this.#X==="color"&&$)this.#j.setAttribute("value",$);this.#V()}if(Q==="drag")this.#k();if(Q==="hit-area")this.#D();if(Q==="selected")this.#t();if(Q==="selected"||Q==="disabled"||Q==="type"||Q==="tip"||Q==="aria-label"||Q==="aria-labelledby")this.#T();if(Q==="value"&&!this.#$&&!this.#Z)this.#F($);if(Q==="tip"){if(this.#l(),this.#X)this.#v(),this.#i()}}#k(){if(this.#Y&&!this.#J)this.#J=(Q)=>this.#g(Q),this.addEventListener("pointerdown",this.#J);else if(!this.#Y&&this.#J)this.#x()}#T(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex",Q?"-1":"0");else if(Q)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",Q?"true":"false"),this.setAttribute("aria-pressed",Z?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let $=this.#X||this.getAttribute("type")||"handle";this.setAttribute("aria-label",$==="color"?"Color handle":$==="add"?"Add handle":$==="remove"?"Remove handle":"Handle")}}#x(){if(this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#Z=!1}#g(Q){if(!this.#Y||this.hasAttribute("disabled"))return;Q.preventDefault();let Z=this.#B();if(!Z)return;this.#Z=!0;let $=this.#K,J=null,j=this.getBoundingClientRect(),_=j.left+j.width/2,q=j.top+j.height/2,G=Q.clientX-_,X=Q.clientY-q,K=Q.clientX,N=Q.clientY,M=3,L=(W,R,H=!1)=>{let B=Z.getBoundingClientRect();J=B;let O=this.#a(B),T=W-G-B.left,C=R-X-B.top,k=Math.max(0,Math.min(B.width,T)),I=Math.max(0,Math.min(B.height,C)),S=B.width>0?$.x?k/B.width:O.px:0.5,w=B.height>0?$.y?I/B.height:O.py:0.5;if(this.#N(H)){if($.x)S=this.#L(S);if($.y)w=this.#L(w);if($.x&&$.y){let d=this.#H(S,w);S=d.x,w=d.y}}if(this.#O($),$.x)this.style.left=`${Math.round(Math.max(0,Math.min(B.width,S*B.width)))}px`;if($.y)this.style.top=`${Math.round(Math.max(0,Math.min(B.height,w*B.height)))}px`},z=(W)=>{if(!this.#Z)return;if(!this.#Q){let R=W.clientX-K,H=W.clientY-N;if(R*R+H*H<M*M)return;if(this.#d(),this.classList.add("dragging"),this.style.cursor="grabbing",!this.hasAttribute("selected"))this.select()}this.#Q=!0,L(W.clientX,W.clientY,W.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#a(J),shiftKey:W.shiftKey}}))},U=(W)=>{if(this.#Z=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",z),window.removeEventListener("pointerup",U),this.#Q){L(W.clientX,W.clientY,W.shiftKey),this.#A(),this.#F(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#a(J)}));let R=(H)=>{H.stopPropagation(),H.preventDefault()};this.addEventListener("click",R,{capture:!0,once:!0})}else this.#A();this.#Q=!1};window.addEventListener("pointermove",z),window.addEventListener("pointerup",U)}showColorTip(){if(!this.#X)return;if(this.#j){this.#j.style.display="";return}this.#i()}hideColorTip(){if(!this.#j)return;this.#j.style.display="none"}#w(Q=this.getAttribute("color")){let Z={color:"#D9D9D9",opacity:100},$=String(Q||"").trim();if(!$)return Z;let J=(_)=>{let q=_.replace("#","").trim();if(q.length===3||q.length===4){let[G,X,K,N]=q;return{color:`#${G}${G}${X}${X}${K}${K}`.toUpperCase(),opacity:N?Math.round(parseInt(`${N}${N}`,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},j=(_,q,G)=>{let X=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${X(_)}${X(q)}${X(G)}`.toUpperCase()};if($.startsWith("#"))return J($);try{let{ctx:_}=X0(1,1);_.fillStyle="#000000",_.fillStyle=$;let q=_.fillStyle;if(q.startsWith("#"))return J(q);let G=q.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(G)return{color:j(G[1],G[2],G[3]),opacity:G[4]!==void 0?Math.round(parseFloat(G[4])*100):100}}catch{}return Z}#I(){let{color:Q,opacity:Z}=this.#w();return JSON.stringify(Z<100?{type:"solid",color:Q,opacity:Z}:{type:"solid",color:Q})}#V(){if(!this.#q)return;this.#q.setAttribute("value",this.#I())}#y(){if(!u())return null;if(this.#q)return this.#q;let Q=document.createElement("fig-fill-picker");Q.setAttribute("mode","solid"),Q.setAttribute("alpha","true"),Q.setAttribute("dialog-offset","8 8"),Q.setAttribute("value",this.#I()),Q.anchorElement=this;let Z=document.createElement("span");return Z.hidden=!0,Q.appendChild(Z),Q.addEventListener("input",this.#s),Q.addEventListener("change",this.#Q0),Q.addEventListener("close",this.#j0),this.appendChild(Q),this.#q=Q,Q}#h(){if(this.hasAttribute("disabled"))return;let Q=this.#y();if(!Q){this.#p();return}this.setAttribute("selected",""),this.#V(),Q.open()}#v(){if(!this.#q)return;this.#q.removeEventListener("input",this.#s),this.#q.removeEventListener("change",this.#Q0),this.#q.removeEventListener("close",this.#j0),this.#q.close(),this.#q.remove(),this.#q=null,this.removeAttribute("selected")}#b(){if(this.#_)return this.#_;let Q=document.createElement("input");return Q.type="color",Q.tabIndex=-1,Q.setAttribute("aria-hidden","true"),Q.style.position="fixed",Q.style.inlineSize="1px",Q.style.blockSize="1px",Q.style.opacity="0",Q.style.pointerEvents="none",Q.addEventListener("input",this.#$0),Q.addEventListener("change",this.#J0),this.appendChild(Q),this.#_=Q,Q}#p(){let Q=this.#b(),{color:Z}=this.#w();Q.value=Z,this.setAttribute("selected",""),Q.click()}#m(){if(!this.#_)return;this.#_.removeEventListener("input",this.#$0),this.#_.removeEventListener("change",this.#J0),this.#_.remove(),this.#_=null}#d(){if(this.getAttribute("type")!=="color")return;this.#q?.close()}#i(){let Q=this.#X;if(!Q)return;if(this.#j)return;let Z=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")Z.setAttribute("control",Q);else Z.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Z.setAttribute("alpha","true");Z.addEventListener("input",this.#n),Z.addEventListener("change",this.#r),Z.addEventListener("add",this.#e),Z.addEventListener("remove",this.#e),this.appendChild(Z),this.#j=Z,this.#t()}#l(){if(!this.#j)return;this.#j.removeEventListener("input",this.#n),this.#j.removeEventListener("change",this.#r),this.#j.removeEventListener("add",this.#e),this.#j.removeEventListener("remove",this.#e),this.#j.remove(),this.#j=null}#t(){if(!this.#j||this.#X!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#j.toggleAttribute("selected",Q)}#u(Q,Z){if(Z===void 0||Z>=100)return Q;let{r:$,g:J,b:j}=c(Q);return`rgba(${$}, ${J}, ${j}, ${Z/100})`}#c(Q){if(!Q?.color)return null;let Z=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:Z}}#s=(Q)=>{Q.stopPropagation();let Z=this.#c(Q.detail);if(!Z)return;this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#Q0=(Q)=>{Q.stopPropagation();let Z=this.#c(Q.detail);if(!Z)return;this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#Z0(Q){let{opacity:Z}=this.#w();return Z<100?{color:Q,opacity:Z}:{color:Q}}#$0=(Q)=>{Q.stopPropagation();let Z=this.#Z0(Q.target.value);this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#J0=(Q)=>{Q.stopPropagation();let Z=this.#Z0(Q.target.value);this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#j0=()=>{this.removeAttribute("selected")};#n=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#u(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#r=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#u(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#e=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#a(Q){let Z=Q||this.#B()?.getBoundingClientRect();if(!Z)return{x:0,y:0,px:0,py:0};let $=this.getBoundingClientRect(),J=this.offsetWidth/2,j=this.offsetHeight/2,_=$.left-Z.left,q=$.top-Z.top,G=_+J,X=q+j,K=Z.width>0?G/Z.width:0,N=Z.height>0?X/Z.height:0;return{x:_,y:q,px:K,py:N}}}customElements.define("fig-handle",B1);class M1 extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="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")}}customElements.define("fig-menu-item",M1);class O1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","separator")}}customElements.define("fig-menu-separator",O1);class F1 extends HTMLElement{#Z=null;#Q=null;#J=null;#$;#j;#q;#_;#G=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open"]}constructor(){super();this.#$=this.#F.bind(this),this.#j=this.#O.bind(this),this.#q=this.#A.bind(this),this.#_=this.#z.bind(this)}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(this.#X(),this.#W(),this.#Y(),this.#K(),this.#N(),this.#M(),this.open)this.#D()}disconnectedCallback(){if(this.#U(),document.removeEventListener("keydown",this.#q,!0),this.#J)this.#J.disconnect(),this.#J=null;if(this.#Z)this.#Z.removeEventListener("close",this.#_),this.#Z.remove(),this.#Z=null}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){if($===null||$==="false")this.#E();else this.#D();return}if(Q==="disabled"){if(this.#Q)if($!==null&&$!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");return}if(this.#Z&&(Q==="position"||Q==="offset"||Q==="closedby"))if($!==null)this.#Z.setAttribute(Q,$);else this.#Z.removeAttribute(Q)}#X(){this.#Q=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#W(){this.#Z=document.createElement("dialog",{is:"fig-popup"}),this.#Z.setAttribute("is","fig-popup"),this.#Z.setAttribute("theme","menu"),this.#Z.setAttribute("role","menu"),this.#Z.setAttribute("id",this.#Z.getAttribute("id")||y());let Q=this.getAttribute("position")||"bottom left";this.#Z.setAttribute("position",Q);let Z=this.getAttribute("offset");if(Z)this.#Z.setAttribute("offset",Z);let $=this.getAttribute("closedby");if($)this.#Z.setAttribute("closedby",$);if(this.#Q)this.#Z.anchor=this.#Q;this.#Z.addEventListener("close",this.#_),this.appendChild(this.#Z)}#Y(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let Z of Q)this.#Z.appendChild(Z)}#K(){if(this.addEventListener("keydown",this.#q),this.#Q)this.#Q.addEventListener("click",this.#$),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#Z.getAttribute("id"));if(this.#Z)this.#Z.addEventListener("click",this.#j),this.#Z.addEventListener("keydown",this.#q)}#U(){if(this.removeEventListener("keydown",this.#q),this.#Q)this.#Q.removeEventListener("click",this.#$);if(this.#Z)this.#Z.removeEventListener("click",this.#j),this.#Z.removeEventListener("keydown",this.#q)}#N(){this.#J=new MutationObserver((Q)=>{for(let Z of Q)for(let $ of Z.addedNodes){if($.nodeType!==1||$===this.#Z)continue;if(($.tagName==="FIG-MENU-ITEM"||$.tagName==="FIG-MENU-SEPARATOR")&&$.parentElement===this)this.#Z.appendChild($);else if(!this.#Q&&$.parentElement===this){if(this.#X(),this.#Q)this.#Q.addEventListener("click",this.#$),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#Z.getAttribute("id")),this.#Z.anchor=this.#Q,this.#M()}}}),this.#J.observe(this,{childList:!0})}#L(){if(!this.#Z)return[];return Array.from(this.#Z.querySelectorAll("fig-menu-item")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#H(){let Q=this.#L();if(!Q.length){this.#G=-1;return}let Z=document.activeElement,$=Q.findIndex((J)=>J===Z||J.contains(Z));this.#G=$>=0?$:-1}#B(Q){let Z=this.#L();if(!Z.length)return;let $=(Q+Z.length)%Z.length;this.#G=$,Z[$].focus()}#M(){if(!this.#Q)return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.#Q.setAttribute("disabled",""),this.#Q.setAttribute("aria-disabled","true"),this.#Q.setAttribute("aria-expanded","false");else this.#Q.removeAttribute("disabled"),this.#Q.removeAttribute("aria-disabled")}#F(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.stopPropagation();let Z=this.#Z?.matches?.(":open")??!1;if(this.open&&!Z)this.removeAttribute("open");if(this.open&&Z)this.open=!1;else this.open=!0}#O(Q){let Z=Q.target.closest("fig-menu-item");if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#P(Z)}#A(Q){if(Q.currentTarget===document&&Q.key!=="Escape")return;if(Q.currentTarget===this&&this.#Z?.contains(Q.target))return;if(!this.open||!this.#Z?.matches?.(":open")){if(this.#Q?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" "))Q.preventDefault(),this.open=!0,requestAnimationFrame(()=>this.#B(0));return}let Z=this.#L();if(!Z.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#H(),this.#B(this.#G+1);break}case"ArrowUp":{Q.preventDefault(),this.#H(),this.#B(this.#G-1);break}case"Home":{Q.preventDefault(),this.#B(0);break}case"End":{Q.preventDefault(),this.#B(Z.length-1);break}case"Escape":{Q.preventDefault(),this.open=!1,this.#Q?.focus();break}case"Enter":case" ":{this.#H();let $=Z[this.#G];if(!$)return;Q.preventDefault(),this.#P($);break}}}#z(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#Q)this.#Q.setAttribute("aria-expanded","false"),this.#Q.focus();this.#G=-1}#P(Q){let Z=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("change",{detail:{value:Z,item:Q},bubbles:!0})),this.open=!1}#D(){if(!this.#Z)return;if(this.#Z.open=!0,document.addEventListener("keydown",this.#q,!0),this.#Q)this.#Q.setAttribute("aria-expanded","true");this.#G=-1,requestAnimationFrame(()=>{if(!this.#Q?.matches?.(":focus-visible"))return;this.#B(0)})}#E(){if(!this.#Z)return;document.removeEventListener("keydown",this.#q,!0),this.#Z.open=!1,this.#Q?.setAttribute("aria-expanded","false")}}customElements.define("fig-menu",F1);