@rogieking/figui3 11.3.2 → 11.4.0

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 $1=(_,Z)=>()=>(_&&(Z=_(_=0)),Z);var J1={};var f0=$1(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(_,Z,$){if(_.importNode.length!=1||Z.get("ungap-li"))return;var J="extends";try{var Q={};Q[J]="li";var j=HTMLLIElement,q=function(){return Reflect.construct(j,[],q)};if(q.prototype=$.create(j.prototype),Z.define("ungap-li",q,Q),!/is="ungap-li"/.test(new q().outerHTML))throw Q}catch(N){(function(){var K="attributeChangedCallback",G="connectedCallback",X="disconnectedCallback",Y=Element.prototype,U=$.assign,W=$.create,O=$.defineProperties,B=$.getOwnPropertyDescriptor,F=$.setPrototypeOf,H=Z.define,T=Z.get,R=Z.upgrade,I=Z.whenDefined,E=W(null),V=new WeakMap,C={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(M){return typeof M=="string"&&/^HTML(?!Element)/.test(M)}).forEach(function(M){function D(){}var P=self[M];F(D,P),(D.prototype=P.prototype).constructor=D,P={},P[M]={value:D},O(self,P)}),new MutationObserver(i).observe(_,C),S0(Document.prototype,"importNode"),S0(Node.prototype,"cloneNode"),O(Z,{define:{value:function(M,D,P){if(M=M.toLowerCase(),P&&J in P){E[M]=U({},P,{Class:D});var y=P[J]+'[is="'+M+'"]',x=_.querySelectorAll(y);for(var v=0,m=x.length;v<m;v++)Q0(x[v])}else H.apply(Z,arguments)}},get:{value:function(M){return M in E?E[M].Class:T.call(Z,M)}},upgrade:{value:function(M){var D=M0(M);if(D&&!(M instanceof D.Class))C0(M,D);else R.call(Z,M)}},whenDefined:{value:function(M){return M in E?Promise.resolve():I.call(Z,M)}}});var w=_.createElement;O(_,{createElement:{value:function(M,D){var P=w.call(_,M);if(D&&"is"in D)P.setAttribute("is",D.is),Z.upgrade(P);return P}}});var f=B(Y,"attachShadow").value,c=B(Y,"innerHTML");O(Y,{attachShadow:{value:function(){var M=f.apply(this,arguments);return new MutationObserver(i).observe(M,C),M}},innerHTML:{get:c.get,set:function(M){if(c.set.call(this,M),/\bis=("|')?[a-z0-9_-]+\1/i.test(M))G0(this,Q0)}}});function i(M){for(var D=0,P=M.length;D<P;D++){var y=M[D],x=y.addedNodes,v=y.removedNodes;for(var m=0,X0=x.length;m<X0;m++)Q0(x[m]);for(var B0=0,Z1=v.length;B0<Z1;B0++)J0(v[B0])}}function d(M){for(var D=0,P=M.length;D<P;D++){var y=M[D],x=y.attributeName,v=y.oldValue,m=y.target,X0=m.getAttribute(x);if(K in m&&!(v==X0&&X0==null))m[K](x,v,m.getAttribute(x),null)}}function J0(M){if(M.nodeType!==1)return;var D=M0(M);if(D&&M instanceof D.Class&&X in M&&V.get(M)!==X)V.set(M,X),Promise.resolve(M).then(_1);G0(M,J0)}function M0(M){var D=M.getAttribute("is");if(D){if(D=D.toLowerCase(),D in E)return E[D]}return null}function e_(M){M[G]()}function _1(M){M[X]()}function C0(M,D){var P=D.Class,y=P.observedAttributes||[];if(F(M,P.prototype),y.length){new MutationObserver(d).observe(M,{attributes:!0,attributeFilter:y,attributeOldValue:!0});var x=[];for(var v=0,m=y.length;v<m;v++)x.push({attributeName:y[v],oldValue:null,target:M});d(x)}}function Q0(M){if(M.nodeType!==1)return;var D=M0(M);if(D){if(!(M instanceof D.Class))C0(M,D);if(G in M&&M.isConnected&&V.get(M)!==G)V.set(M,G),Promise.resolve(M).then(e_)}G0(M,Q0)}function G0(M,D){for(var P=M.content,y=(P&&P.nodeType==11?P:M).querySelectorAll("[is]"),x=0,v=y.length;x<v;x++)D(y[x])}function S0(M,D){var P=M[D],y={};y[D]={value:function(){var x=P.apply(this,arguments);switch(x.nodeType){case 1:case 11:G0(x,Q0)}return x}},O(M,y)}})()}})(document,customElements,Object)});function Q1(){if(typeof navigator>"u")return!1;let _=navigator.userAgent||"",Z=/\b(iPad|iPhone|iPod)\b/.test(_)||/\bMacintosh\b/.test(_)&&/\bMobile\b/.test(_),$=/\bAppleWebKit\b/.test(_)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(_);return Z||$}function h(_,Z={}){let $=document.createElement("fig-icon");if(_)$.setAttribute("name",_);if(Z.size)$.setAttribute("size",Z.size);if(Z.className)$.className=Z.className;return $}var m0="http://www.w3.org/2000/svg";function p0(_,Z){let $=(J)=>{if(J===null||J===void 0||J===!1)return;if(Array.isArray(J)){J.forEach($);return}_.append(J instanceof Node?J:String(J))};return $(Z),_}function u0(_,Z={}){for(let[$,J]of Object.entries(Z)){if(J===null||J===void 0||J===!1)continue;if($==="className")if(_.namespaceURI===m0)_.setAttribute("class",String(J));else _.className=String(J);else if(J===!0)_.setAttribute($,"");else _.setAttribute($,String(J))}return _}function L(_,Z,$){let J=document.createElement(_);return u0(J,Z),p0(J,$)}function S(_,Z,$){let J=document.createElementNS(m0,_);return u0(J,Z),p0(J,$)}function u(_,Z){requestAnimationFrame(()=>{if(_&&!_.isConnected)return;Z()})}function z(_,Z){return _.hasAttribute(Z)&&_.getAttribute(Z)!=="false"}function t(_,Z,$){let J=Number(Z),Q=Number($),j=Number.isFinite(J)?Math.max(0,Math.min(1,J)):Number.isFinite(Q)?Math.max(0,Math.min(100,Q))/100:1,q=Number.isFinite(Q)?Math.max(0,Math.min(100,Q)):Math.round(j*100);return{color:_,alpha:j,opacity:q}}function W0(_){_.querySelectorAll(':scope > [slot="prepend"], :scope > [slot="append"]').forEach((Z)=>{if(Z.children.length>0){A0(Z);return}let $=Z.textContent.trim();if(!$){A0(Z);return}let J=Z.dataset.figInputSlotFullText||"",Q=J?Array.from(J)[0]?.toUpperCase():"",j=$===Q?J:$,N=Array.from($)[0].toUpperCase();if(Z.textContent!==N)Z.textContent=N;if(j&&j!==N)Z.dataset.figInputSlotFullText=j,Z.setAttribute("aria-label",j),j1(Z);else A0(Z)})}function j1(_){if(_.dataset.figInputSlotTooltipBound==="true")return;_.dataset.figInputSlotTooltipBound="true",_.addEventListener("pointerenter",x0),_.addEventListener("pointerleave",H0),_.addEventListener("focus",x0),_.addEventListener("blur",H0)}function A0(_){H0({currentTarget:_}),delete _.dataset.figInputSlotFullText,_.removeAttribute("aria-label")}function x0(_){let Z=_.currentTarget,$=Z?.dataset?.figInputSlotFullText;if(!Z||!$)return;k.show(Z,$)}function H0(_){let Z=_.currentTarget;if(!Z)return;k.hide(Z)}function U0({owner:_,onStart:Z,onEnd:$,startClass:J="",endClass:Q="",chevronClass:j="",startLabel:q="Scroll back",endLabel:N="Scroll forward"}={}){let K=(G,X)=>{let Y=document.createElement("button");if(Y.type="button",Y.className=["fig-overflow",`fig-overflow-${G}`,G==="start"?J:Q].filter(Boolean).join(" "),Y.dataset.figOverflow=G,_)Y.setAttribute(`data-fig-${_}-nav`,G);return Y.setAttribute("tabindex","-1"),Y.setAttribute("aria-label",G==="start"?q:N),Y.appendChild(h("chevron",{size:"small",className:["fig-overflow-chevron",j].filter(Boolean).join(" ")})),Y.addEventListener("click",(U)=>{U.preventDefault(),U.stopPropagation(),X?.(U)}),Y};return{start:K("start",Z),end:K("end",$)}}var c0=`
1
+ var Q1=(_,Z)=>()=>(_&&(Z=_(_=0)),Z);var j1={};var x0=Q1(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(_,Z,$){if(_.importNode.length!=1||Z.get("ungap-li"))return;var J="extends";try{var Q={};Q[J]="li";var j=HTMLLIElement,q=function(){return Reflect.construct(j,[],q)};if(q.prototype=$.create(j.prototype),Z.define("ungap-li",q,Q),!/is="ungap-li"/.test(new q().outerHTML))throw Q}catch(N){(function(){var G="attributeChangedCallback",K="connectedCallback",X="disconnectedCallback",Y=Element.prototype,U=$.assign,R=$.create,O=$.defineProperties,M=$.getOwnPropertyDescriptor,H=$.setPrototypeOf,A=Z.define,z=Z.get,W=Z.upgrade,I=Z.whenDefined,V=R(null),C=new WeakMap,S={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(B){return typeof B=="string"&&/^HTML(?!Element)/.test(B)}).forEach(function(B){function D(){}var P=self[B];H(D,P),(D.prototype=P.prototype).constructor=D,P={},P[B]={value:D},O(self,P)}),new MutationObserver(r).observe(_,S),f0(Document.prototype,"importNode"),f0(Node.prototype,"cloneNode"),O(Z,{define:{value:function(B,D,P){if(B=B.toLowerCase(),P&&J in P){V[B]=U({},P,{Class:D});var y=P[J]+'[is="'+B+'"]',x=_.querySelectorAll(y);for(var g=0,m=x.length;g<m;g++)Q0(x[g])}else A.apply(Z,arguments)}},get:{value:function(B){return B in V?V[B].Class:z.call(Z,B)}},upgrade:{value:function(B){var D=B0(B);if(D&&!(B instanceof D.Class))E0(B,D);else W.call(Z,B)}},whenDefined:{value:function(B){return B in V?Promise.resolve():I.call(Z,B)}}});var w=_.createElement;O(_,{createElement:{value:function(B,D){var P=w.call(_,B);if(D&&"is"in D)P.setAttribute("is",D.is),Z.upgrade(P);return P}}});var f=M(Y,"attachShadow").value,c=M(Y,"innerHTML");O(Y,{attachShadow:{value:function(){var B=f.apply(this,arguments);return new MutationObserver(r).observe(B,S),B}},innerHTML:{get:c.get,set:function(B){if(c.set.call(this,B),/\bis=("|')?[a-z0-9_-]+\1/i.test(B))X0(this,Q0)}}});function r(B){for(var D=0,P=B.length;D<P;D++){var y=B[D],x=y.addedNodes,g=y.removedNodes;for(var m=0,Y0=x.length;m<Y0;m++)Q0(x[m]);for(var H0=0,J1=g.length;H0<J1;H0++)J0(g[H0])}}function d(B){for(var D=0,P=B.length;D<P;D++){var y=B[D],x=y.attributeName,g=y.oldValue,m=y.target,Y0=m.getAttribute(x);if(G in m&&!(g==Y0&&Y0==null))m[G](x,g,m.getAttribute(x),null)}}function J0(B){if(B.nodeType!==1)return;var D=B0(B);if(D&&B instanceof D.Class&&X in B&&C.get(B)!==X)C.set(B,X),Promise.resolve(B).then($1);X0(B,J0)}function B0(B){var D=B.getAttribute("is");if(D){if(D=D.toLowerCase(),D in V)return V[D]}return null}function Z1(B){B[K]()}function $1(B){B[X]()}function E0(B,D){var P=D.Class,y=P.observedAttributes||[];if(H(B,P.prototype),y.length){new MutationObserver(d).observe(B,{attributes:!0,attributeFilter:y,attributeOldValue:!0});var x=[];for(var g=0,m=y.length;g<m;g++)x.push({attributeName:y[g],oldValue:null,target:B});d(x)}}function Q0(B){if(B.nodeType!==1)return;var D=B0(B);if(D){if(!(B instanceof D.Class))E0(B,D);if(K in B&&B.isConnected&&C.get(B)!==K)C.set(B,K),Promise.resolve(B).then(Z1)}X0(B,Q0)}function X0(B,D){for(var P=B.content,y=(P&&P.nodeType==11?P:B).querySelectorAll("[is]"),x=0,g=y.length;x<g;x++)D(y[x])}function f0(B,D){var P=B[D],y={};y[D]={value:function(){var x=P.apply(this,arguments);switch(x.nodeType){case 1:case 11:X0(x,Q0)}return x}},O(B,y)}})()}})(document,customElements,Object)});function q1(){if(typeof navigator>"u")return!1;let _=navigator.userAgent||"",Z=/\b(iPad|iPhone|iPod)\b/.test(_)||/\bMacintosh\b/.test(_)&&/\bMobile\b/.test(_),$=/\bAppleWebKit\b/.test(_)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(_);return Z||$}function b(_,Z={}){let $=document.createElement("fig-icon");if(_)$.setAttribute("name",_);if(Z.size)$.setAttribute("size",Z.size);if(Z.className)$.className=Z.className;return $}var p0="http://www.w3.org/2000/svg";function u0(_,Z){let $=(J)=>{if(J===null||J===void 0||J===!1)return;if(Array.isArray(J)){J.forEach($);return}_.append(J instanceof Node?J:String(J))};return $(Z),_}function c0(_,Z={}){for(let[$,J]of Object.entries(Z)){if(J===null||J===void 0||J===!1)continue;if($==="className")if(_.namespaceURI===p0)_.setAttribute("class",String(J));else _.className=String(J);else if(J===!0)_.setAttribute($,"");else _.setAttribute($,String(J))}return _}function L(_,Z,$){let J=document.createElement(_);return c0(J,Z),u0(J,$)}function E(_,Z,$){let J=document.createElementNS(p0,_);return c0(J,Z),u0(J,$)}function u(_,Z){requestAnimationFrame(()=>{if(_&&!_.isConnected)return;Z()})}function T(_,Z){return _.hasAttribute(Z)&&_.getAttribute(Z)!=="false"}function a(_,Z,$){let J=Number(Z),Q=Number($),j=Number.isFinite(J)?Math.max(0,Math.min(1,J)):Number.isFinite(Q)?Math.max(0,Math.min(100,Q))/100:1,q=Number.isFinite(Q)?Math.max(0,Math.min(100,Q)):Math.round(j*100);return{color:_,alpha:j,opacity:q}}function U0(_){_.querySelectorAll(':scope > [slot="prepend"], :scope > [slot="append"]').forEach((Z)=>{if(Z.children.length>0){F0(Z);return}let $=Z.textContent.trim();if(!$){F0(Z);return}let J=Z.dataset.figInputSlotFullText||"",Q=J?Array.from(J)[0]?.toUpperCase():"",j=$===Q?J:$,N=Array.from($)[0].toUpperCase();if(Z.textContent!==N)Z.textContent=N;if(j&&j!==N)Z.dataset.figInputSlotFullText=j,Z.setAttribute("aria-label",j),N1(Z);else F0(Z)})}function N1(_){if(_.dataset.figInputSlotTooltipBound==="true")return;_.dataset.figInputSlotTooltipBound="true",_.addEventListener("pointerenter",w0),_.addEventListener("pointerleave",z0),_.addEventListener("focus",w0),_.addEventListener("blur",z0)}function F0(_){z0({currentTarget:_}),delete _.dataset.figInputSlotFullText,_.removeAttribute("aria-label")}function w0(_){let Z=_.currentTarget,$=Z?.dataset?.figInputSlotFullText;if(!Z||!$)return;k.show(Z,$)}function z0(_){let Z=_.currentTarget;if(!Z)return;k.hide(Z)}function W0({owner:_,onStart:Z,onEnd:$,startClass:J="",endClass:Q="",chevronClass:j="",startLabel:q="Scroll back",endLabel:N="Scroll forward"}={}){let G=(K,X)=>{let Y=document.createElement("button");if(Y.type="button",Y.className=["fig-overflow",`fig-overflow-${K}`,K==="start"?J:Q].filter(Boolean).join(" "),Y.dataset.figOverflow=K,_)Y.setAttribute(`data-fig-${_}-nav`,K);return Y.setAttribute("tabindex","-1"),Y.setAttribute("aria-label",K==="start"?q:N),Y.appendChild(b("chevron",{size:"small",className:["fig-overflow-chevron",j].filter(Boolean).join(" ")})),Y.addEventListener("click",(U)=>{U.preventDefault(),U.stopPropagation(),X?.(U)}),Y};return{start:G("start",Z),end:G("end",$)}}var d0=`
2
2
  fig-select-options,
3
3
  .fig-menu-options {
4
4
  --fig-vertical-overflow-size: var(--spacer-4);
@@ -114,7 +114,7 @@ fig-select-options.overflow-start > :is(fig-separator, fig-menu-separator)[stick
114
114
  .fig-menu-options.overflow-start > :is(fig-separator, fig-menu-separator)[sticky]:not([sticky="false"]) {
115
115
  top: var(--fig-vertical-overflow-size, var(--spacer-4)) !important;
116
116
  }
117
- `,d0=`
117
+ `,s0=`
118
118
  fig-icon {
119
119
  contain: size;
120
120
  --size: var(--spacer-4);
@@ -135,7 +135,7 @@ fig-icon {
135
135
  fig-icon[size="small"] {
136
136
  --size: var(--spacer-3);
137
137
  }
138
- `,s0=typeof CSSStyleSheet==="function"&&typeof CSSStyleSheet.prototype.replaceSync==="function"?new CSSStyleSheet:null;s0?.replaceSync(c0);var o0=typeof CSSStyleSheet==="function"&&typeof CSSStyleSheet.prototype.replaceSync==="function"?new CSSStyleSheet:null;o0?.replaceSync(d0);function w0(_,Z,$,J){if(!_||!$)return;if(Z&&"adoptedStyleSheets"in _){if([..._.adoptedStyleSheets].includes(Z))return;_.adoptedStyleSheets=[..._.adoptedStyleSheets,Z];return}let Q=_===document?document.documentElement:_;if(Q.querySelector?.(`style[data-fig-${J}]`))return;let j=document.createElement("style");j.setAttribute(`data-fig-${J}`,""),j.textContent=$,Q.prepend(j)}function i0(_,Z={}){if(w0(_,s0,c0,"vertical-overflow"),Z.icons)w0(_,o0,d0,"shadow-icon")}if(typeof document<"u")i0(document);function R0(_,Z,$="x",J=2){if(!_||!Z)return!1;let Q=$==="x",j=Q?Z.scrollWidth:Z.scrollHeight,q=Q?Z.clientWidth:Z.clientHeight,N=Q?Z.scrollLeft:Z.scrollTop,K=j-q>J,G=!K||N<=J,X=!K||N+q>=j-J;return _.classList.toggle("overflow-start",!G),_.classList.toggle("overflow-end",!X),K}function Z0(_,Z="x",$=1,J="smooth"){if(!_)return;let Q=Z==="x",q=(Q?_.clientWidth:_.clientHeight)*0.8*$;_.scrollBy({[Q?"left":"top"]:q,behavior:J})}function a(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function q1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let _=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class Z extends HTMLButtonElement{}try{return customElements.define(_,Z,{extends:"button"}),document.createElement("button",{is:_})instanceof Z}catch($){return!1}}var l0=Q1()&&!q1(),N1=(l0?Promise.resolve().then(() => (f0(),J1)):Promise.resolve()).then(()=>{}).catch((_)=>{throw _});function z0(_,Z,$){let J=()=>{if(!customElements.get(_))customElements.define(_,Z,$)};if(!l0){J();return}N1.then(J).catch((Q)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${_}".`,Q)})}function A(_,Z){if(!customElements.get(_))customElements.define(_,Z)}function g(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function q0(){if(!document.body)return null;let _="data-figui-overlay-root",Z=document.body.querySelector(`:scope > [${_}]`);if(!Z)Z=document.createElement("div"),Z.setAttribute(_,""),document.body.append(Z);return Z}var K1=1e4;function r0(){return K1++}function p(_,Z,$){if($&&$.trim())_.style.setProperty(Z,$.trim());else _.style.removeProperty(Z)}var o=null,y0=null;function T0(_=1,Z=1){if(!o)o=document.createElement("canvas"),y0=o.getContext("2d");if(o.width!==_)o.width=_;if(o.height!==Z)o.height=Z;return{canvas:o,ctx:y0}}class a0 extends HTMLElement{type;#Z;#_=new WeakMap;#J=["aria-label","aria-labelledby","aria-describedby","aria-haspopup","aria-expanded","aria-controls","title"];#$=this.#Y.bind(this);#Q=this.#G.bind(this);#j=()=>{this.#L(),this.#U()};#K=()=>{if(this.button?.matches(":focus-visible"))this.setAttribute("data-focus-visible","")};#q=()=>{this.removeAttribute("data-focus-visible")};constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){if(this.type=this.getAttribute("type")||"button",!this.button){let _=this.type==="select"||this.type==="upload",Z=_?"span":"button",$=document.createElement("style");$.textContent=`
138
+ `,i0=typeof CSSStyleSheet==="function"&&typeof CSSStyleSheet.prototype.replaceSync==="function"?new CSSStyleSheet:null;i0?.replaceSync(d0);var o0=typeof CSSStyleSheet==="function"&&typeof CSSStyleSheet.prototype.replaceSync==="function"?new CSSStyleSheet:null;o0?.replaceSync(s0);function y0(_,Z,$,J){if(!_||!$)return;if(Z&&"adoptedStyleSheets"in _){if([..._.adoptedStyleSheets].includes(Z))return;_.adoptedStyleSheets=[..._.adoptedStyleSheets,Z];return}let Q=_===document?document.documentElement:_;if(Q.querySelector?.(`style[data-fig-${J}]`))return;let j=document.createElement("style");j.setAttribute(`data-fig-${J}`,""),j.textContent=$,Q.prepend(j)}function r0(_,Z={}){if(y0(_,i0,d0,"vertical-overflow"),Z.icons)y0(_,o0,s0,"shadow-icon")}if(typeof document<"u")r0(document);function L0(_,Z,$="x",J=2){if(!_||!Z)return!1;let Q=$==="x",j=Q?Z.scrollWidth:Z.scrollHeight,q=Q?Z.clientWidth:Z.clientHeight,N=Q?Z.scrollLeft:Z.scrollTop,G=j-q>J,K=!G||N<=J,X=!G||N+q>=j-J;return _.classList.toggle("overflow-start",!K),_.classList.toggle("overflow-end",!X),G}function Z0(_,Z="x",$=1,J="smooth"){if(!_)return;let Q=Z==="x",q=(Q?_.clientWidth:_.clientHeight)*0.8*$;_.scrollBy({[Q?"left":"top"]:q,behavior:J})}function t(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function G1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let _=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class Z extends HTMLButtonElement{}try{return customElements.define(_,Z,{extends:"button"}),document.createElement("button",{is:_})instanceof Z}catch($){return!1}}var l0=q1()&&!G1(),K1=(l0?Promise.resolve().then(() => (x0(),j1)):Promise.resolve()).then(()=>{}).catch((_)=>{throw _});function T0(_,Z,$){let J=()=>{if(!customElements.get(_))customElements.define(_,Z,$)};if(!l0){J();return}K1.then(J).catch((Q)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${_}".`,Q)})}function F(_,Z){if(!customElements.get(_))customElements.define(_,Z)}function v(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function N0(){if(!document.body)return null;let _="data-figui-overlay-root",Z=document.body.querySelector(`:scope > [${_}]`);if(!Z)Z=document.createElement("div"),Z.setAttribute(_,""),document.body.append(Z);return Z}var X1=1e4;function t0(){return X1++}function p(_,Z,$){if($&&$.trim())_.style.setProperty(Z,$.trim());else _.style.removeProperty(Z)}var o=null,h0=null;function k0(_=1,Z=1){if(!o)o=document.createElement("canvas"),h0=o.getContext("2d");if(o.width!==_)o.width=_;if(o.height!==Z)o.height=Z;return{canvas:o,ctx:h0}}class a0 extends HTMLElement{type;#Z;#_=new WeakMap;#J=["aria-label","aria-labelledby","aria-describedby","aria-haspopup","aria-expanded","aria-controls","title"];#$=this.#R.bind(this);#Q=this.#K.bind(this);#j=()=>{this.#O(),this.#W()};#G=()=>{if(this.button?.matches(":focus-visible"))this.setAttribute("data-focus-visible","")};#q=()=>{this.removeAttribute("data-focus-visible")};constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){if(this.type=this.getAttribute("type")||"button",!this.button){let _=this.type==="select"||this.type==="upload",Z=_?"span":"button",$=document.createElement("style");$.textContent=`
139
139
  button, button:hover, button:active, .fig-button-control {
140
140
  padding: var(--fig-button-control-padding, 0 var(--spacer-2));
141
141
  appearance: none;
@@ -169,9 +169,9 @@ fig-icon[size="small"] {
169
169
  :host([type="select"]) .fig-button-control {
170
170
  gap: var(--spacer-1);
171
171
  }
172
- `;let J=document.createElement("slot");J.name="prepend";let Q=document.createElement("slot"),j=document.createElement("slot");j.name="append";let q=L(Z,{className:"fig-button-control",type:_?null:"button"},[J,Q,j]);this.shadowRoot.replaceChildren($,q),this.button=q,this.button.addEventListener("click",this.#Q),this.button.addEventListener("focus",this.#K),this.button.addEventListener("blur",this.#q)}this.shadowRoot.querySelectorAll("slot").forEach((_)=>{_.removeEventListener("slotchange",this.#j),_.addEventListener("slotchange",this.#j)}),this.removeEventListener("keydown",this.#$),this.addEventListener("keydown",this.#$),this.#Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#M(),this.#U()}get type(){return this.getAttribute("type")||"button"}set type(_){this.setAttribute("type",_)}get selected(){return this.#Z}set selected(_){this.setAttribute("selected",_)}#N(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#G(){if(this.#N())return;if(this.type==="toggle")if(this.selected)this.removeAttribute("selected");else this.setAttribute("selected","");if(this.type==="submit"){let _=this.closest("form");if(_)if(typeof _.requestSubmit==="function")_.requestSubmit();else _.submit()}if(this.type==="link"){let _=this.getAttribute("href"),Z=this.getAttribute("target");if(_)if(Z)window.open(_,Z);else window.location.href=_}}#W(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#X(){let _=this.#W();if(_ instanceof HTMLSelectElement)return _;if(_?.tagName==="FIG-DROPDOWN")return _.select||_.querySelector?.("select")||null;return null}#Y(_){if(this.type!=="select")return;if(_.key!=="Enter")return;if(_.altKey||_.ctrlKey||_.metaKey||_.shiftKey)return;let Z=this.#X();if(!Z||Z.disabled||Z.multiple)return;if(typeof Z.showPicker!=="function")return;_.preventDefault();try{Z.showPicker()}catch{}}#R(){if(!this.button)return;if(this.type!=="toggle"){this.removeAttribute("aria-pressed"),this.button.removeAttribute("aria-pressed");return}let _=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.setAttribute("aria-pressed",_?"true":"false"),this.button.setAttribute("aria-pressed",_?"true":"false")}#U(){let Z=Array.from(this.querySelectorAll(':scope > fig-icon[slot="append"][data-generated="select-chevron"]')),$=Z[0];if(Z.slice(1).forEach((j)=>j.remove()),this.type!=="select"){$?.remove();return}if(this.querySelector(':scope > [slot="append"]:not([data-generated])')){$?.remove();return}if($)return;let Q=h("chevron",{size:"small"});Q.setAttribute("slot","append"),Q.setAttribute("data-generated","select-chevron"),this.append(Q)}#B(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#J.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.button.removeAttribute(_);else this.button.setAttribute(_,Z)})}#M(){if(!this.button)return;let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=_,this.button instanceof HTMLButtonElement)this.button.disabled=_,this.button.type="button",this.button.setAttribute("type","button");this.#L(),this.#B(),this.#R()}#L(){let _=this.#W();if(!_)return;if(this.#N()){if(!this.#_.has(_))this.#_.set(_,_.hasAttribute("disabled")&&_.getAttribute("disabled")!=="false");_.setAttribute("disabled","")}else if(this.#_.has(_)){let $=this.#_.get(_);if(this.#_.delete(_),$)_.setAttribute("disabled","");else _.removeAttribute("disabled")}}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","aria-haspopup","aria-expanded","aria-controls","title"]}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"type":{let J=(Q)=>Q==="select"||Q==="upload";if(J(Z||"button")!==J($||"button")){this.button=null,this.connectedCallback();break}this.#M(),this.#U();break}case"disabled":this.#M();break;case"selected":this.#Z=$!==null&&$!=="false",this.#R();break;default:this.#B();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#$),this.shadowRoot?.querySelectorAll("slot").forEach((_)=>{_.removeEventListener("slotchange",this.#j)})}}A("fig-button",a0);class t0 extends HTMLElement{#Z="Menu";#_=null;#J;#$;#Q;get label(){return this.#Z}set label(_){this.#Z=_}#j;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#J=this.#G.bind(this),this.#$=this.#W.bind(this),this.#Q=this.#X.bind(this),this.#j=this.slotChange.bind(this)}#K(){this.select.addEventListener("input",this.#J),this.select.addEventListener("change",this.#$),this.select.addEventListener("keydown",this.#Q)}#q(_){if(!_||!(_ instanceof Element))return!1;return!!_.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.#Y(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#j),this.optionsSlot.addEventListener("slotchange",this.#j),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#Q),this.#K()}slotChange(){let _=this.hasAttribute("value"),Z=this.select.options.length>0&&this.select.selectedIndex>=0,$=_?this.getAttribute("value"):this.type==="dropdown"?this.#_:Z?this.select.value:null;while(this.select.firstChild)this.select.firstChild.remove();if(this.type==="dropdown"){let J=document.createElement("option");J.setAttribute("hidden","true"),J.setAttribute("selected","true"),J.selected=!0,this.select.appendChild(J)}if(this.optionsSlot.assignedNodes().forEach((J)=>{if(J.nodeName==="OPTION"||J.nodeName==="OPTGROUP")this.select.appendChild(J.cloneNode(!0))}),$!==null)this.#R($);if(this.type==="dropdown")this.select.selectedIndex=-1}#G(_){_.stopPropagation();let Z=_.target.selectedOptions?.[0];if(this.#q(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#N();return}let $=_.target.value;if(this.type==="dropdown")this.#_=$;this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}#W(_){_.stopPropagation();let Z=_.target.selectedOptions?.[0];if(this.#q(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#N();return}let $=this.type==="dropdown"?this.#_:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,composed:!0}))}#X(_){if(this.closest('fig-button[type="select"]'))return;if(_.key!=="Enter"||_.defaultPrevented)return;if(_.altKey||_.ctrlKey||_.metaKey||_.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(typeof this.select.showPicker!=="function")return;_.preventDefault();try{this.select.showPicker()}catch{}}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#_;return this.select?.value}set value(_){if(this.type==="dropdown")this.#_=_;this.setAttribute("value",_)}static get observedAttributes(){return["value","type","label","disabled","variant","size"]}#Y(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=_}#R(_){if(this.type==="dropdown")return;if(this.select)this.select.value=_??""}attributeChangedCallback(_,Z,$){if(_==="value")this.#R($);if(_==="type"){if(this.type=$||"select",this.isConnected)this.slotChange()}if(_==="label")this.#Z=$||"Menu",this.select.setAttribute("aria-label",this.#Z);if(_==="disabled")this.#Y()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#j),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#Q)}}A("fig-dropdown",t0);class k extends HTMLElement{static#Z=0;static#_=0;static#J=1000;static#$=null;static#Q=!1;static#j=new Set;#K;#q;#N;#G;#W;#X;#Y;#R;#U;#B;#M;#L;#O=null;#T=null;#I=null;#k=!1;#F;#H=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let _=parseInt(this.getAttribute("delay"));this.delay=!isNaN(_)?_:500,this.#K=this.#b.bind(this),this.#q=this.hidePopupOutsideClick.bind(this),this.#N=this.showDelayedPopup.bind(this),this.#G=this.#x.bind(this),this.#W=()=>{if(!this.#k)this.showDelayedPopup()},this.#X=()=>{this.#k=!1,this.hidePopup()},this.#Y=this.#S.bind(this),this.#R=this.#w.bind(this),this.#U=this.#V.bind(this),this.#B=this.#g.bind(this),this.#L=this.#y.bind(this),this.#M=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(k.#h(),this.setup(),this.#C(),this.setupEventListeners(),this.#O=this.closest("dialog"),this.#O)this.#O.addEventListener("close",this.#M)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#E(),this.#z(),document.removeEventListener("mousedown",this.#K,!0),document.removeEventListener("keydown",this.#L,!0),this.#O)this.#O.removeEventListener("close",this.#M),this.#O=null;if(this.action==="click")document.body.removeEventListener("click",this.#q);if(clearTimeout(this.#F),k.#$===this)k.#$=null}#A(){return this.firstElementChild}#z(){this.#I?.disconnect(),this.#I=null}#C(){if(this.#E(),this.action==="manual")return;let _=this.#A();if(!_){if(!this.#I&&typeof MutationObserver<"u")this.#I=new MutationObserver(()=>{if(this.#A())this.#z(),this.#C()}),this.#I.observe(this,{childList:!0});return}if(this.#T=_,this.action==="hover"){if(!this.isTouchDevice())_.addEventListener("pointerenter",this.#N),_.addEventListener("pointerleave",this.#G);_.addEventListener("touchstart",this.#Y,{passive:!0}),_.addEventListener("touchmove",this.#R,{passive:!0}),_.addEventListener("touchend",this.#U,{passive:!0}),_.addEventListener("touchcancel",this.#B,{passive:!0}),_.addEventListener("focus",this.#W),_.addEventListener("blur",this.#X)}else if(this.action==="click")_.addEventListener("click",this.#N),_.addEventListener("touchstart",this.#N,{passive:!0})}#E(){let _=this.#T;if(!_)return;if(this.action==="hover")_.removeEventListener("pointerenter",this.#N),_.removeEventListener("pointerleave",this.#G),_.removeEventListener("touchstart",this.#Y),_.removeEventListener("touchmove",this.#R),_.removeEventListener("touchend",this.#U),_.removeEventListener("touchcancel",this.#B),_.removeEventListener("focus",this.#W),_.removeEventListener("blur",this.#X);else if(this.action==="click")_.removeEventListener("click",this.#N),_.removeEventListener("touchstart",this.#N);this.#T=null}setup(){this.style.display="contents"}render(){this.destroy();let _=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Z=document.createElement("span");if(this.popup=document.createElement("dialog",{is:"fig-popup"}),this.popup.setAttribute("is","fig-popup"),this.popup.setAttribute("variant","tooltip"),this.popup.setAttribute("data-tooltip-managed",""),this.popup.setAttribute("role","tooltip"),this.popup.setAttribute("closedby","closerequest"),_)this.popup.setAttribute("popover","manual");let $=g();this.popup.setAttribute("id",$);let J=this.getAttribute("theme");if(J)this.popup.setAttribute("theme",J);let Q=this.getAttribute("pointer");if(Q!==null)this.popup.setAttribute("pointer",Q);if(this.popup.append(Z),Z.innerText=this.getAttribute("text")??"",this.firstElementChild){let j=new Set((this.firstElementChild.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));j.add($),this.firstElementChild.setAttribute("aria-describedby",[...j].join(" "))}if(_)(q0()??document.body).append(this.popup);else{let j=this.closest("dialog");if(j&&j.open)j.append(this.popup);else(q0()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.#f(this.popup.id),this.popup.hidePopup?.(),this.popup.remove(),this.popup=null}#f(_){let Z=this.firstElementChild;if(!Z||!_)return;let $=Z.getAttribute("aria-describedby");if(!$)return;let J=$.split(/\s+/).filter((Q)=>Q&&Q!==_).join(" ");if(J)Z.setAttribute("aria-describedby",J);else Z.removeAttribute("aria-describedby")}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#q);document.addEventListener("mousedown",this.#K,!0),document.addEventListener("keydown",this.#L,!0)}get#D(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#P(){let _=Date.now(),Z=k.#J;if(this.action==="hover"&&k.#$)return!0;if(k.#Z&&_-k.#Z<Z)return!0;if(k.#_&&_-k.#_<Z)return!0;return!1}showDelayedPopup(_){if(this.#D)return;if(clearTimeout(this.timeout),_?.type==="pointerenter"){let Z=this.#T;if(Z?.matches?.("fig-select[open]")||Z?.querySelector?.("fig-select[open]"))return}if(this.#P()){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"&&k.#$&&k.#$!==this)k.#$.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")k.#$=this;k.#Z=Date.now()}hidePopup(){if(this.#D)return;clearTimeout(this.timeout),clearTimeout(this.#F);let _=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,k.#$===this)k.#$=null;if(_)k.#_=Date.now()}hidePopupOutsideClick(_){if(this.isOpen&&!this.popup.contains(_.target))this.hidePopup()}#x(_){if(!this.#H)this.hidePopup()}#S(_){if(this.action==="hover")this.#H=!0,clearTimeout(this.#F),this.showDelayedPopup()}#w(_){if(this.action==="hover"&&this.#H)clearTimeout(this.#F),this.#F=setTimeout(()=>{this.#H=!1,this.hidePopup()},150)}#V(_){if(this.action==="hover"&&this.#H)clearTimeout(this.#F),this.#F=setTimeout(()=>{this.#H=!1,this.hidePopup()},300)}#g(_){if(this.action==="hover"&&this.#H)this.#H=!1,clearTimeout(this.#F),this.hidePopup()}#y(_){if(!this.isOpen&&!this.popup||_.key!=="Escape")return;_.preventDefault(),this.hidePopup(),this.firstElementChild?.focus?.()}static get observedAttributes(){return["action","delay","open","pointer","show","text","theme"]}get text(){return this.getAttribute("text")??""}set text(_){this.setAttribute("text",_)}#m(_){if(!this.popup)return;let Z=this.popup.firstElementChild??this.popup.firstChild;if(!Z)return;Z.innerText=_}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){if(_===!1||_==="false"||_===null)this.removeAttribute("open");else this.setAttribute("open","true")}attributeChangedCallback(_,Z,$){if(_==="action"){if(this.#E(),Z==="click")document.body?.removeEventListener("click",this.#q);if(this.action=$||"hover",this.isConnected){if(this.#C(),this.action==="click")document.body?.addEventListener("click",this.#q)}}if(_==="delay"){let J=parseInt($);this.delay=!isNaN(J)?J:500}if(_==="open")if($!==null&&$!=="false")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(_==="show")if($!==null&&$!=="false")this.showPopup();else this.hidePopup();if(_==="text")this.#m($??"");if(_==="pointer"){if(this.popup)if($!==null)this.popup.setAttribute("pointer",$);else this.popup.removeAttribute("pointer")}if(_==="theme"){if(this.popup)if($)this.popup.setAttribute("theme",$);else this.popup.removeAttribute("theme")}}#b(_){if(!this.isOpen)return;let Z=_.target;if(this.popup&&this.popup.contains(Z))return;if(Z.tagName==="SELECT"||Z.hasAttribute("popover")||Z.closest("dialog"))this.hidePopup()}static#h(){if(k.#Q)return;k.#Q=!0;let _=()=>{k.dismissHoverTooltips()},Z=()=>{k.#s()};document.documentElement.addEventListener("mouseleave",_),document.addEventListener("mouseout",($)=>{if($.relatedTarget)return;_()}),document.addEventListener("scroll",Z,{capture:!0,passive:!0}),window.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("resize",Z,{passive:!0});try{let $=window.frameElement;if($)$.addEventListener("mouseleave",_)}catch{}window.addEventListener("message",($)=>{if($?.data?.type!=="figui:dismiss-tooltips")return;if(window.parent!==window&&$.source!==window.parent)return;_()})}static dismissHoverTooltips(){for(let _ of document.querySelectorAll("fig-tooltip")){if(!(_ instanceof k))continue;if(_.action!=="hover")continue;if(_.#D)continue;if(_.#k=!0,setTimeout(()=>{let Z=_.#T;if(Z!==document.activeElement&&!Z?.matches?.(":focus, :focus-within"))_.#k=!1},0),_.isOpen||_.timeout)_.hidePopup()}for(let _ of Array.from(k.#j))k.hide(_)}static#v=new WeakMap;static#s(){for(let _ of document.querySelectorAll("fig-tooltip")){if(!(_ instanceof k))continue;if(_.#D)continue;if(_.isOpen||_.timeout)_.hidePopup()}for(let _ of Array.from(k.#j))k.hide(_)}static show(_,Z,$={}){k.#h(),k.hide(_);let J=$.delay??500,j=Date.now()-k.#Z<k.#J?0:J,q={timeout:null,popup:null};k.#v.set(_,q),k.#j.add(_),q.timeout=setTimeout(()=>{let N=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,K=document.createElement("dialog",{is:"fig-popup"});if(K.setAttribute("is","fig-popup"),K.setAttribute("variant","tooltip"),K.setAttribute("data-tooltip-managed",""),K.setAttribute("role","tooltip"),K.setAttribute("closedby","closerequest"),N)K.setAttribute("popover","manual");let G=document.createElement("span");if(G.innerText=Z,K.append(G),N)(q0()??document.body).append(K);else{let X=_.closest?.("dialog");if(X&&X.open)X.append(K);else(q0()??document.body).append(K)}K.anchor=_,K.open=!0,q.popup=K,k.#Z=Date.now()},j)}static hide(_){let Z=k.#v.get(_);if(!Z)return;if(clearTimeout(Z.timeout),Z.popup)Z.popup.remove(),k.#_=Date.now();k.#v.delete(_),k.#j.delete(_)}}A("fig-tooltip",k);class n0 extends HTMLElement{static observedAttributes=["position","tail","tooltip"];#Z=null;#_=null;#J=null;#$=null;connectedCallback(){this.#Z=this.textContent,this.#$??=new MutationObserver(()=>{this.#Z=this.textContent,this.#j()}),this.#Q(),u(this,()=>{this.#j(),this.#G(),this.#q()})}disconnectedCallback(){this.#$?.disconnect(),this.#G()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#Z===null)return;if(_==="tooltip"){if(this.#G(),this.isConnected)this.#q();return}this.#j()}#Q(){this.#$?.observe(this,{childList:!0,characterData:!0,subtree:!0})}#j(){if(this.#$?.disconnect(),this.#K(),this.isConnected)this.#Q()}#K(){let _=this.getAttribute("position")||"right",Z=this.#Z||"";if(_==="middle"){let $=this.getAttribute("tail"),J;if($){let q=Z.lastIndexOf($);J=q>0?q:Math.ceil(Z.length/2)}else J=Math.ceil(Z.length/2);this.replaceChildren();let Q=document.createElement("span");Q.className="start",Q.textContent=Z.slice(0,J);let j=document.createElement("span");j.className="end",j.textContent=Z.slice(J),this.appendChild(Q),this.appendChild(j)}else this.textContent=Z}#q(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#_=()=>{if(!this.#N())return;k.show(this,this.#Z)},this.#J=()=>{k.hide(this)},this.addEventListener("pointerenter",this.#_),this.addEventListener("pointerleave",this.#J)}#N(){let _=(Z)=>Z.scrollWidth>Z.clientWidth;if(_(this))return!0;return[...this.querySelectorAll(":scope > .start, :scope > .end")].some(_)}#G(){if(this.#_)this.removeEventListener("pointerenter",this.#_);if(this.#J)this.removeEventListener("pointerleave",this.#J);this.#_=null,this.#J=null,k.hide(this)}}A("fig-truncate",n0);function e0(_){if(_.querySelector("fig-header[dialog-header]"))return;let Z=document.createElement("fig-header");Z.setAttribute("dialog-header",""),Z.setAttribute("data-auto","");let $=document.createElement("h3");$.textContent=_.getAttribute("title")||"Dialog";let J=document.createElement("fig-tooltip");J.setAttribute("text","Close");let Q=document.createElement("fig-button");Q.setAttribute("variant","ghost"),Q.setAttribute("icon",""),Q.setAttribute("aria-label","Close dialog"),Q.setAttribute("close-dialog",""),Q.appendChild(h("close")),J.appendChild(Q),Z.appendChild($),Z.appendChild(J),_.prepend(Z)}class __ extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._isDragging=!1,this._dragPending=!1,this._dragStartPos={x:0,y:0},this._dragOffset={x:0,y:0},this._resizeObserver=null,this._mutationObserver=null,this._autoResizeRafId=0,this._offset=16,this._positionInitialized=!1,this._dragThreshold=3,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundClose=this.close.bind(this),this._boundIframeMessage=this._handleIframeMessage.bind(this),this._boundContentMutation=this._scheduleAutoResize.bind(this),this._boundContentResize=this._scheduleAutoResize.bind(this),this._boundRestoreFocus=this._restoreFocus.bind(this),this._boundIframeMouseLeave=this._handleIframeMouseLeave.bind(this),this._iframeDismissMutationObserver=null,this._previousFocus=null}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){if(this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),this.open&&!this.matches?.(":modal"))this._assignStackingOrder();u(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._setupIframeDismissListeners(),this._syncA11y()}),window.addEventListener("message",this._boundIframeMessage)}disconnectedCallback(){this._figInit(),this._removeDragListeners(),this.querySelectorAll("fig-button[close-dialog]").forEach((_)=>{_.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize(),this._teardownIframeDismissListeners(),this.removeEventListener("close",this._boundRestoreFocus)}_captureFocusBeforeOpen(){let _=document.activeElement;this._previousFocus=_ instanceof HTMLElement&&_!==document.body&&!this.contains(_)?_:null}_restoreFocus(){let _=this._previousFocus;if(this._previousFocus=null,!_?.isConnected)return;let Z=document.activeElement;if(Z&&Z!==document.body&&!this.contains(Z))return;requestAnimationFrame(()=>_.focus?.())}_assignStackingOrder(){this.style.zIndex=String(r0()+1)}_clearStackingOrder(){this.style.zIndex=""}show(){return this._captureFocusBeforeOpen(),this._assignStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),k.dismissHoverTooltips(),super.show()}showModal(){return this._captureFocusBeforeOpen(),this._clearStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),k.dismissHoverTooltips(),super.showModal()}close(..._){let Z=super.close(..._);return this._clearStackingOrder(),Z}_handleIframeMouseLeave(_){let Z=_?.currentTarget;if(!(Z instanceof HTMLIFrameElement))return;try{Z.contentWindow?.postMessage({type:"figui:dismiss-tooltips"},"*")}catch{}}_syncIframeDismissListeners(){for(let _ of this.querySelectorAll(":scope > iframe")){if(!(_ instanceof HTMLIFrameElement))continue;if(_.dataset.figuiDismissBound==="true")continue;_.dataset.figuiDismissBound="true",_.addEventListener("mouseleave",this._boundIframeMouseLeave)}}_setupIframeDismissListeners(){if(this._syncIframeDismissListeners(),this._iframeDismissMutationObserver)return;this._iframeDismissMutationObserver=new MutationObserver(()=>{this._syncIframeDismissListeners()}),this._iframeDismissMutationObserver.observe(this,{childList:!0,subtree:!1})}_teardownIframeDismissListeners(){this._iframeDismissMutationObserver?.disconnect(),this._iframeDismissMutationObserver=null;for(let _ of this.querySelectorAll(":scope > iframe"))_.removeEventListener("mouseleave",this._boundIframeMouseLeave),delete _.dataset.figuiDismissBound}_handleIframeMessage(_){if(!this.autoresize)return;let Z=_?.data;if(!Z||Z.type!=="figui:iframe-resize")return;let $=_.source;if(!$)return;let J=Array.from(this.querySelectorAll("iframe")).find((Q)=>Q.contentWindow===$);if(!J)return;this._resizeForIframe(J,Z)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let _ of this.children)try{this._resizeObserver.observe(_)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((_)=>{for(let Z of _)Z.addedNodes?.forEach(($)=>{if($ instanceof Element&&$.parentElement===this)try{this._resizeObserver?.observe($)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(_){let Z=window.getComputedStyle(this),$=parseFloat(Z.paddingTop||"0")+parseFloat(Z.paddingBottom||"0")+parseFloat(Z.borderTopWidth||"0")+parseFloat(Z.borderBottomWidth||"0"),J=0,Q=parseFloat(Z.rowGap||Z.gap||"0")||0,j=0;for(let q of this.children){let N=q.getBoundingClientRect();if(N.height===0)continue;if(j+=1,q===_)continue;let K=window.getComputedStyle(q),G=parseFloat(K.marginTop||"0")+parseFloat(K.marginBottom||"0");J+=N.height+G}if(Q&&j>1)J+=Q*(j-1);return $+J}_resizeForIframe(_,Z){if(typeof Z.height!=="number"||!(Z.height>0))return;let $=this._computeChrome(_);this.style.height=`${Math.ceil(Z.height+$)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){e0(this)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((_)=>{if(!_.hasAttribute("aria-label"))_.setAttribute("aria-label","Close dialog");_.removeEventListener("click",this._boundClose),_.addEventListener("click",this._boundClose)})}_syncA11y(){if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let _=this.querySelector("fig-header[dialog-header] h1, fig-header[dialog-header] h2, fig-header[dialog-header] h3, fig-header[dialog-header] h4, fig-header[dialog-header] h5, fig-header[dialog-header] h6");if(_){let Z=_.getAttribute("id")||g();_.setAttribute("id",Z),this.setAttribute("aria-labelledby",Z)}}}_applyPosition(){let _=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let Z=_.includes("top"),$=_.includes("bottom"),J=_.includes("left"),Q=_.includes("right"),j=_.includes("center")&&!Z&&!$,q=_.includes("center")&&!J&&!Q;if(Z)this.style.top=`${this._offset}px`;else if($)this.style.bottom=`${this._offset}px`;else if(j)this.style.top="0",this.style.bottom="0";if(J)this.style.left=`${this._offset}px`;else if(Q)this.style.right=`${this._offset}px`;else if(q)this.style.left="0",this.style.right="0";if(j&&q)this.style.margin="auto";else if(j)this.style.marginTop="auto",this.style.marginBottom="auto";else if(q)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let _=this.getAttribute("handle"),Z=_?this.querySelector(_):this.querySelector("fig-header, header");if(Z)Z.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}_isInteractiveElement(_){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(j)=>Z.some((q)=>j.matches?.(q))||j.tagName?.startsWith("FIG-")&&!$.includes(j.tagName);if(J(_))return!0;let Q=_.parentElement;while(Q&&Q!==this){if(J(Q))return!0;Q=Q.parentElement}return!1}_handlePointerDown(_){if(!this.drag)return;if(this._isInteractiveElement(_.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(_.target))return}this._dragPending=!0,this._dragStartPos.x=_.clientX,this._dragStartPos.y=_.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=_.clientX-$.left,this._dragOffset.y=_.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}_handlePointerMove(_){if(this._dragPending&&!this._isDragging){let Z=Math.abs(_.clientX-this._dragStartPos.x),$=Math.abs(_.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(_.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${_.clientX-this._dragOffset.x}px`,this.style.top=`${_.clientY-this._dragOffset.y}px`,_.preventDefault()}_handlePointerUp(_){if(this._isDragging){if(this.hasPointerCapture?.(_.pointerId))this.releasePointerCapture(_.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),_.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(_,Z,$){if(this._figInit(),_==="autoresize"&&this.isConnected)this._syncAutoResize();if(_==="drag")if(this.drag=$!==null&&$!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let J=this.querySelector("fig-header, header");if(J)J.style.cursor=""}if(_==="position"&&this._positionInitialized)this._applyPosition();if(_==="modal"){let J=this.modal;if(this.modal=$!==null&&$!=="false",this.open&&J!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(_==="closedby")this.closedby=$||"any";if(_==="title"){let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";this._syncA11y()}if(_==="aria-label"||_==="aria-labelledby")this._syncA11y()}}z0("fig-dialog",__,{extends:"dialog"});class Z_ extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._toastVisible=!1,this._syncingOpen=!1,this._managedRole=null,this._managedLive=null,this._managedIcon=null,this._managedDismiss=null,this._managedDismissSeparator=null,this._boundHandleClose=this.handleClose.bind(this)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.syncIcon(),this.syncDismiss(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast();else{if(this.getAttribute("open")==="false")this._syncingOpen=!0,this.removeAttribute("open"),this._syncingOpen=!1;this._toastVisible=!1}}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((_)=>{if(!_.hasAttribute("aria-label"))_.setAttribute("aria-label","Close notification");_.removeEventListener("click",this._boundHandleClose),_.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto";let _=Number.parseFloat(this.getAttribute("offset")),Z=Number.isFinite(_)?_:this._defaultOffset;this.style.bottom=`${Z}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let _=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger",Z=_?"alert":"status",$=_?"assertive":"polite";if(!this.hasAttribute("role")||this.getAttribute("role")===this._managedRole)this.setAttribute("role",Z),this._managedRole=Z;if(!this.hasAttribute("aria-live")||this.getAttribute("aria-live")===this._managedLive)this.setAttribute("aria-live",$),this._managedLive=$;if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}syncIcon(){let _=this.getAttribute("icon"),Z=this._managedIcon;if(!Z||Z.parentNode!==this)Z=this.querySelector(":scope > fig-icon[data-fig-toast-icon]");if(!_){if(Z)Z.remove();this._managedIcon=null;return}if(!Z)Z=document.createElement("fig-icon"),Z.setAttribute("data-fig-toast-icon",""),Z.setAttribute("aria-hidden","true"),this.prepend(Z);else if(this.firstElementChild!==Z)this.prepend(Z);if(Z.getAttribute("size")!=="medium")Z.setAttribute("size","medium");if(Z.getAttribute("name")!==_)Z.setAttribute("name",_);this._managedIcon=Z}syncDismiss(){let _=z(this,"dismiss"),Z=this._managedDismiss;if(!Z||Z.parentNode!==this)Z=this.querySelector(":scope > fig-button[data-fig-toast-dismiss]");let $=this._managedDismissSeparator;if(!$||$.parentNode!==this)$=this.querySelector(":scope > fig-separator[data-fig-toast-dismiss-separator]");if(!_){if(Z)Z.removeEventListener("click",this._boundHandleClose),Z.remove();if($)$.remove();this._managedDismiss=null,this._managedDismissSeparator=null;return}if(!$)$=document.createElement("fig-separator"),$.setAttribute("data-fig-toast-dismiss-separator",""),$.setAttribute("direction","vertical"),$.setAttribute("aria-orientation","vertical"),$.setAttribute("aria-hidden","true");if(!Z){Z=document.createElement("fig-button"),Z.setAttribute("data-fig-toast-dismiss",""),Z.setAttribute("variant","ghost"),Z.setAttribute("icon",""),Z.setAttribute("close-toast",""),Z.setAttribute("aria-label","Close notification");let J=document.createElement("fig-icon");J.setAttribute("name","close"),J.setAttribute("aria-hidden","true"),Z.append(J)}if($.parentNode!==this||Z.parentNode!==this)this.append($,Z);else if(this.lastElementChild!==Z||Z.previousElementSibling!==$)this.append($,Z);if($.getAttribute("direction")!=="vertical")$.setAttribute("direction","vertical");Z.removeEventListener("click",this._boundHandleClose),Z.addEventListener("click",this._boundHandleClose),this._managedDismiss=Z,this._managedDismissSeparator=$}startAutoClose(){this.clearAutoClose();let _=parseInt(this.getAttribute("duration")??"5000");if(_>0)this._autoCloseTimer=setTimeout(()=>this.hideToast(),_)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}_resolveAutoTheme(){if(this.getAttribute("theme")!=="auto")return;let _=getComputedStyle(document.documentElement).colorScheme||"";this.style.colorScheme=_.includes("dark")?"light":"dark"}showToast(){let _=this._toastVisible;this.syncLiveRegion(),this.syncIcon(),this.syncDismiss(),this._resolveAutoTheme(),this._syncingOpen=!0;try{if(!this.open)this.show()}finally{this._syncingOpen=!1}if(this._toastVisible=!0,this.applyPosition(),this.startAutoClose(),!_)this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){let _=this._toastVisible||this.open;this.clearAutoClose(),this._syncingOpen=!0;try{if(this.open)this.close();else if(this.hasAttribute("open"))this.removeAttribute("open")}finally{this._syncingOpen=!1}if(this._toastVisible=!1,_)this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live","icon","dismiss"]}attributeChangedCallback(_,Z,$){if(this._figInit(),Z===$)return;if(!this.isConnected)return;if(this._syncingOpen)return;if(_==="offset")this.applyPosition();if(_==="open")if($!==null&&$!=="false")this.showToast();else this.hideToast();if(_==="duration"&&this._toastVisible)this.startAutoClose();if(_==="theme")if($==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme");if(_==="theme"||_==="live")this.syncLiveRegion();if(_==="icon")this.syncIcon();if(_==="dismiss")this.syncDismiss()}}z0("fig-toast",Z_,{extends:"dialog"});class $_ extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundContentReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_pendingFullReposition=!1;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;_previousFocus=null;_boundDocumentKeydown;_boundNativeClose;constructor(){super();this._boundReposition=()=>this.queueReposition(),this._boundContentReposition=()=>this.queueReposition({preserveCurrentPosition:!0}),this._boundScroll=(_)=>{let Z=_.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this),this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this),this._boundNativeClose=this.handleNativeClose.bind(this),this._boundAutoClose=()=>{this.open=!1}}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._pendingFullReposition>"u")this._pendingFullReposition=!1;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._previousFocus>"u")this._previousFocus=null;if(typeof this._boundReposition!=="function")this._boundReposition=()=>this.queueReposition();if(typeof this._boundContentReposition!=="function")this._boundContentReposition=()=>this.queueReposition({preserveCurrentPosition:!0});if(typeof this._boundScroll!=="function")this._boundScroll=(_)=>{let Z=_.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this);if(typeof this._boundDocumentKeydown!=="function")this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this);if(typeof this._boundNativeClose!=="function")this._boundNativeClose=this.handleNativeClose.bind(this);if(typeof this._boundAutoClose!=="function")this._boundAutoClose=()=>{this.open=!1}}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin","title"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){if(_===!1||_==="false"||_===null){if(!(this.matches?.(":open")||this.matches?.(":popover-open"))&&!this.hasAttribute("open"))return;if(this.hidePopup(),this.hasAttribute("open"))this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(_){if(_ instanceof Element)this._anchorRef=_;else if(typeof _==="string")this._anchorRef=null,this.setAttribute("anchor",_);else if(_&&typeof _.getBoundingClientRect==="function")this._anchorRef=_;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role",this.getAttribute("variant")==="tooltip"?"tooltip":"dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),this.removeEventListener("close",this._boundNativeClose),this.addEventListener("close",this._boundNativeClose),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.removeEventListener("close",this._boundNativeClose),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(_,Z,$){if(this.ensureInitialized(),Z===$)return;if(_==="open"){if($==="false"){this.open=!1;return}if($===null){this.hidePopup();return}this.showPopup();return}if(_==="drag"){if(this.drag=$!==null&&$!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(_==="title"){this._ensureHeader();let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(r0()+1),this.captureFocusBeforeOpen();let _=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),Z=this.shouldAutoReposition();if(Z)this.style.visibility="hidden";if(_)try{this.showPopover()}catch(J){_=!1}if(!_&&!super.open)try{this.show()}catch(J){}if(Z&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.addEventListener("keydown",this._boundDocumentKeydown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let $=this.resolveAnchor();if($?.classList)$.classList.add("has-popup-open");if(this.getAttribute("variant")!=="tooltip")k.dismissHoverTooltips()}hidePopup(){let _=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),Z=this.resolveAnchor();if(Z?.classList)Z.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch($){}if(this.matches?.(":open"))try{this.close()}catch($){}if(_)this.restoreFocusAfterClose()}shouldRestoreFocus(){return this.getAttribute("variant")!=="tooltip"}captureFocusBeforeOpen(){if(!this.shouldRestoreFocus())return;let _=document.activeElement;this._previousFocus=_ instanceof HTMLElement&&_!==document.body&&!this.contains(_)?_:null}restoreFocusAfterClose(){if(!this.shouldRestoreFocus()){this._previousFocus=null;return}let _=this.resolveAnchor(),Z=this._previousFocus?.isConnected?this._previousFocus:_ instanceof HTMLElement?_:null;if(this._previousFocus=null,!Z?.isConnected)return;let $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Z.focus?.())}get autoresize(){let _=this.getAttribute("autoresize");return _===null||_!=="false"}set autoresize(_){if(_===!1||_==="false"||_===null)this.setAttribute("autoresize","false");else if(_||_==="")this.setAttribute("autoresize",_===!0?"":_);else this.setAttribute("autoresize","false")}handleNativeClose(){if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}setupObservers(){this.teardownObservers();let _=this.resolveAnchor();if(_ instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(_);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundContentReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundContentReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(_){if(!_)return null;let Z=_.getBoundingClientRect();return{x:Z.x,y:Z.y,width:Z.width,height:Z.height}}hasRectChanged(_,Z,$=0.25){if(!_&&!Z)return!1;if(!_||!Z)return!0;return Math.abs(_.x-Z.x)>$||Math.abs(_.y-Z.y)>$||Math.abs(_.width-Z.width)>$||Math.abs(_.height-Z.height)>$}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let _=()=>{if(!this.open){this._anchorTrackRAF=null;return}let Z=this.resolveAnchor(),$=this.readRectSnapshot(Z),J=this.shouldAutoReposition();if(J&&this.hasRectChanged(this._lastAnchorRect,$))this._lastAnchorRect=$,this.queueReposition();else if(!J)this._lastAnchorRect=$;this._anchorTrackRAF=requestAnimationFrame(_)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(_)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}_ensureHeader(){if(!this.hasAttribute("title")||this.getAttribute("variant")==="tooltip")return;e0(this),this.querySelectorAll("fig-button[close-dialog]").forEach((_)=>{_.removeEventListener("click",this._boundAutoClose),_.addEventListener("click",this._boundAutoClose)})}handleOutsidePointerDown(_){if(!this.open||!(this.matches?.(":open")||this.matches?.(":popover-open")))return;let Z=this.getAttribute("closedby");if(Z==="none"||Z==="closerequest")return;let $=_.target;if(!($ instanceof Node))return;let J=typeof _.composedPath==="function"?_.composedPath():[];if(J.includes(this))return;if(this.contains($))return;let Q=this.resolveAnchor();if(Q&&(J.includes(Q)||Q.contains?.($)))return;if(this.isInsideDescendantPopup($))return;this.open=!1}handleDocumentKeydown(_){if(_.key!=="Escape"||_.defaultPrevented)return;if(!this.open)return;if(this.getAttribute("role")==="menu")return;if(this.getAttribute("closedby")==="none")return;let J=Array.from(document.querySelectorAll('dialog[is="fig-popup"][open]')).filter((Q)=>Q.open).map((Q)=>({popup:Q,z:Number.parseInt(getComputedStyle(Q).zIndex||"0",10)||0})).sort((Q,j)=>Q.z-j.z).at(-1)?.popup;if(J&&J!==this)return;_.preventDefault(),this.open=!1}isInsideDescendantPopup(_){let Z=_.closest?.('dialog[is="fig-popup"]');if(!Z||Z===this)return!1;let $=Z,J=new Set;while($&&!J.has($)){J.add($);let Q=$.anchor;if(!(Q instanceof Element))break;if(this.contains(Q))return!0;$=Q.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),document.removeEventListener("pointercancel",this._boundPointerUp)}isInteractiveElement(_){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(j)=>Z.some((q)=>j.matches?.(q))||j.tagName?.startsWith("FIG-")&&!$.includes(j.tagName);if(J(_))return!0;let Q=_.parentElement;while(Q&&Q!==this){if(J(Q))return!0;Q=Q.parentElement}return!1}handlePointerDown(_){if(!this.drag)return;if(this.isInteractiveElement(_.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(_.target))return}this._dragPending=!0,this._dragStartPos.x=_.clientX,this._dragStartPos.y=_.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=_.clientX-$.left,this._dragOffset.y=_.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}handlePointerMove(_){if(this._dragPending&&!this._isDragging){let Z=Math.abs(_.clientX-this._dragStartPos.x),$=Math.abs(_.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(_.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${_.clientX-this._dragOffset.x}px`,this.style.top=`${_.clientY-this._dragOffset.y}px`,_.preventDefault()}handlePointerUp(_){if(this._isDragging){if(this.hasPointerCapture?.(_.pointerId))this.releasePointerCapture(_.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),_.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let _=this.getAttribute("anchor");if(!_)return null;let Z=this.parentElement;try{if(Z?.querySelector){let $=Z.querySelector(_);if($&&!this.contains($))return $}return document.querySelector(_)}catch{return null}}parsePosition(){let Z=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),$=new Set(["top","center","bottom"]),J=new Set(["left","center","right"]),Q="top",j="center",q=null;if(Z.length>=2){if($.has(Z[0]))Q=Z[0];if(J.has(Z[1]))j=Z[1];return{vertical:Q,horizontal:j,shorthand:q}}if(Z.length===1){let N=Z[0];if(N==="top"||N==="bottom")Q=N,q=N;else if(N==="left"||N==="right")j=N,q=N;else if(N==="center")Q="center",j="center"}return{vertical:Q,horizontal:j,shorthand:q}}normalizeOffsetToken(_,Z="0px"){if(!_)return Z;let $=_.trim();if(!$)return Z;if(/^-?\d+(\.\d+)?$/.test($))return`${$}px`;return $}measureLengthPx(_,Z="x"){if(!_)return 0;let $=this.normalizeOffsetToken(_,"0px");if($.endsWith("px")){let j=parseFloat($);return Number.isFinite(j)?j:0}let J=document.createElement("div");if(J.style.position="fixed",J.style.visibility="hidden",J.style.pointerEvents="none",J.style.left="0",J.style.top="0",J.style.margin="0",J.style.padding="0",J.style.border="0",Z==="x")J.style.width=$,J.style.height="0";else J.style.height=$,J.style.width="0";document.body.appendChild(J);let Q=J.getBoundingClientRect();return J.remove(),Z==="x"?Q.width:Q.height}parseOffset(){let Z=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),$=this.normalizeOffsetToken(Z[0],"0px"),J=this.normalizeOffsetToken(Z[1],"0px");return{xToken:$,yToken:J,xPx:this.measureLengthPx($,"x"),yPx:this.measureLengthPx(J,"y")}}parseViewportMargins(){let Z=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((J)=>!Number.isNaN(J)),$=8;if(Z.length===0)return{top:8,right:8,bottom:8,left:8};if(Z.length===1)return{top:Z[0],right:Z[0],bottom:Z[0],left:Z[0]};if(Z.length===2)return{top:Z[0],right:Z[1],bottom:Z[0],left:Z[1]};if(Z.length===3)return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[1]};return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[3]}}getPlacementCandidates(_,Z,$){let J={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if($){let j=$==="left"||$==="right"?["top","bottom"]:["left","right"];return[{v:_,h:Z,s:$},{v:_,h:Z,s:J[$]},{v:_,h:Z,s:j[0]},{v:_,h:Z,s:j[1]}]}if(_==="center")return[{v:"center",h:Z,s:null},{v:"center",h:J[Z],s:null},{v:"top",h:Z,s:null},{v:"bottom",h:Z,s:null},{v:"top",h:J[Z],s:null},{v:"bottom",h:J[Z],s:null}];if(Z==="center")return[{v:_,h:"center",s:null},{v:J[_],h:"center",s:null},{v:_,h:"left",s:null},{v:_,h:"right",s:null},{v:J[_],h:"left",s:null},{v:J[_],h:"right",s:null}];return[{v:_,h:Z,s:null},{v:J[_],h:Z,s:null},{v:_,h:J[Z],s:null},{v:J[_],h:J[Z],s:null}]}computeCoords(_,Z,$,J,Q,j){let q,N;if(j==="left"||j==="right")return N=j==="left"?_.left-Z.width-Q.xPx:_.right+Q.xPx,q=_.top,{top:q,left:N};if(j==="top"||j==="bottom")return q=j==="top"?_.top-Z.height-Q.yPx:_.bottom+Q.yPx,N=_.left,{top:q,left:N};if($==="top")q=_.top-Z.height-Q.yPx;else if($==="bottom")q=_.bottom+Q.yPx;else q=_.top+(_.height-Z.height)/2;if($==="center")if(J==="left")N=_.left-Z.width-Q.xPx;else if(J==="right")N=_.right+Q.xPx;else N=_.left+(_.width-Z.width)/2;else if(J==="left")N=_.left+Q.xPx;else if(J==="right")N=_.right-Z.width-Q.xPx;else N=_.left+(_.width-Z.width)/2;return{top:q,left:N}}oppositeSide(_){return{top:"bottom",bottom:"top",left:"right",right:"left"}[_]||"bottom"}getPlacementSide(_,Z,$){if($==="top")return"top";if($==="bottom")return"bottom";if($==="left")return"left";if($==="right")return"right";if(_!=="center")return _;if(Z!=="center")return Z;return"top"}lengthToPx(_,Z=0){let $=getComputedStyle(this),J=String(_||"").trim(),Q=parseFloat(J);if(!Number.isFinite(Q))return Z;if(J.endsWith("rem"))return Q*parseFloat(getComputedStyle(document.documentElement).fontSize);if(J.endsWith("em"))return Q*parseFloat($.fontSize);return Q}radiusForSide(_){let Z=getComputedStyle(this),$=(J)=>this.lengthToPx(J,0);if(_==="top")return Math.max($(Z.borderTopLeftRadius),$(Z.borderTopRightRadius));if(_==="bottom")return Math.max($(Z.borderBottomLeftRadius),$(Z.borderBottomRightRadius));if(_==="left")return Math.max($(Z.borderTopLeftRadius),$(Z.borderBottomLeftRadius));if(_==="right")return Math.max($(Z.borderTopRightRadius),$(Z.borderBottomRightRadius));return 0}getBeakEdgeInset(_){let Z=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(_)+Z/2)}tracksAnchorBeak(){let _=this.getAttribute("variant");return _==="popover"||_==="tooltip"}getViewportBounds(_){let Z=window.visualViewport,$=Z?.width??window.innerWidth,J=Z?.height??window.innerHeight,Q=Z?.offsetLeft??0,j=Z?.offsetTop??0;return{minLeft:Q+_.left,minTop:j+_.top,maxRight:Q+$-_.right,maxBottom:j+J-_.bottom}}clampToViewport(_,Z,$){let J=this.getViewportBounds($),Q=J.maxRight-Z.width,j=J.maxBottom-Z.height,q=Math.max(J.minLeft,Q),N=Math.max(J.minTop,j);return{left:Math.min(q,Math.max(J.minLeft,_.left)),top:Math.min(N,Math.max(J.minTop,_.top))}}resolveCoordsAtViewport(_,Z,$,J,Q){let{left:j,top:q}=this.clampToViewport($,Z,Q);if(!_||!this.tracksAnchorBeak())return{left:j,top:q};let N=this.oppositeSide(J),K=this.getViewportBounds(Q),G=K.maxRight-Z.width,X=K.minLeft,Y=K.maxBottom-Z.height,U=K.minTop;if(N==="top"||N==="bottom"){let W=this.getBeakEdgeInset(N),O=_.left+_.width/2,B=O-j;if(B<W)j=O-W;else if(B>Z.width-W)j=O-(Z.width-W);j=Math.min(G,Math.max(X,j))}else if(N==="left"||N==="right"){let W=this.getBeakEdgeInset(N),O=_.top+_.height/2,B=O-q;if(B<W)q=O-W;else if(B>Z.height-W)q=O-(Z.height-W);q=Math.min(Y,Math.max(U,q))}return{left:j,top:q}}canPointAtAnchor(_,Z,$,J,Q){if(!_||!this.tracksAnchorBeak())return!0;let j=this.oppositeSide(Q),q=this.getBeakEdgeInset(j);if(j==="top"||j==="bottom"){let K=_.left+_.width/2-$;return K>=q-0.5&&K<=Z.width-q+0.5}let N=_.top+_.height/2-J;return N>=q-0.5&&N<=Z.height-q+0.5}updatePopoverBeak(_,Z,$,J,Q){if(!this.tracksAnchorBeak()||!_){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let j=this.oppositeSide(Q);this.setAttribute("data-beak-side",j);let q=_.left+_.width/2,N=_.top+_.height/2,K=this.getBoundingClientRect(),G=K.width>0&&K.height>0?K:Z,X=G.left,Y=G.top,U=this.getBeakEdgeInset(j),W;if(j==="top"||j==="bottom"){W=q-X;let O=U,B=Math.max(O,G.width-U);W=Math.min(B,Math.max(O,W))}else{W=N-Y;let O=U,B=Math.max(O,G.height-U);W=Math.min(B,Math.max(O,W))}this.style.setProperty("--fig-popup-beak-offset",`${W}px`)}overflowScore(_,Z,$){let J=this.getViewportBounds($),Q=_.left+Z.width,j=_.top+Z.height,q=Math.max(0,J.minLeft-_.left),N=Math.max(0,J.minTop-_.top),K=Math.max(0,Q-J.maxRight),G=Math.max(0,j-J.maxBottom);return q+N+K+G}fits(_,Z,$){return this.overflowScore(_,Z,$)===0}clamp(_,Z,$,J=null,Q="top"){if(J)return this.resolveCoordsAtViewport(J,Z,_,Q,$);return this.clampToViewport(_,Z,$)}primaryAxisOverflowPenalty(_,Z,$,J){let Q=this.getViewportBounds($),j=0;if(J==="top")j=Math.max(0,Q.minTop-_.top);else if(J==="bottom")j=Math.max(0,_.top+Z.height-Q.maxBottom);else if(J==="left")j=Math.max(0,Q.minLeft-_.left);else if(J==="right")j=Math.max(0,_.left+Z.width-Q.maxRight);return j>0?1000+j:0}placementScore(_,Z,$,J,Q){let j=this.resolveCoordsAtViewport(_,Z,$,J,Q),q=this.overflowScore(j,Z,Q);if(q+=this.primaryAxisOverflowPenalty($,Z,Q,J),_&&!this.canPointAtAnchor(_,Z,j.left,j.top,J))q+=1e4;return{score:q,resolved:j}}applyPopupPosition(_,Z,$,J,Q){let j=this.resolveCoordsAtViewport(_,Z,$,J,Q);this.style.left=`${j.left}px`,this.style.top=`${j.top}px`,this.updatePopoverBeak(_,Z,j.left,j.top,J)}currentPlacementSide(){let _=this.getAttribute("data-beak-side");if(_)return this.oppositeSide(_);let{vertical:Z,horizontal:$,shorthand:J}=this.parsePosition();return this.getPlacementSide(Z,$,J)}preservePopupPosition(_,Z,$){let J={left:_.left,top:_.top},Q=this.fits(J,_,$)?J:this.clampToViewport(J,_,$),j=Z?Z.getBoundingClientRect():null,q=this.currentPlacementSide();if(j&&this.tracksAnchorBeak()&&!this.canPointAtAnchor(j,_,Q.left,Q.top,q))return!1;return this.style.left=`${Q.left}px`,this.style.top=`${Q.top}px`,this.updatePopoverBeak(j,_,Q.left,Q.top,q),!0}positionPopup({preserveCurrentPosition:_=!1}={}){if(!this.open)return;let Z=this.getBoundingClientRect(),$=this.resolveAnchor(),J=this.parseViewportMargins();if(_&&this.preservePopupPosition(Z,$,J))return;let Q=this.parseOffset(),{vertical:j,horizontal:q,shorthand:N}=this.parsePosition();if(!$){this.updatePopoverBeak(null,Z,0,0,"top");let W=this.getViewportBounds(J),O={left:W.minLeft+(W.maxRight-W.minLeft-Z.width)/2,top:W.minTop+(W.maxBottom-W.minTop-Z.height)/2},B=this.clampToViewport(O,Z,J);this.style.left=`${B.left}px`,this.style.top=`${B.top}px`;return}let K=$.getBoundingClientRect(),G=this.getPlacementCandidates(j,q,N),X=null,Y="top",U=Number.POSITIVE_INFINITY;for(let{v:W,h:O,s:B}of G){let F=this.computeCoords(K,Z,W,O,Q,B),H=this.getPlacementSide(W,O,B),{score:T,resolved:R}=this.placementScore(K,Z,F,H,J);if(B){let I=this.getViewportBounds(J);if((B==="left"||B==="right"?F.left>=I.minLeft&&F.left+Z.width<=I.maxRight:F.top>=I.minTop&&F.top+Z.height<=I.maxBottom)&&T<1e4){this.applyPopupPosition(K,Z,F,H,J);return}}else if(T===0){this.applyPopupPosition(K,Z,F,H,J);return}if(T<U)U=T,X=R,Y=H}this.applyPopupPosition(K,Z,X||{left:0,top:0},Y,J)}queueReposition({preserveCurrentPosition:_=!1}={}){if(!this.open||!this.isPopupDisplayed()||!this.shouldAutoReposition())return;if(!_)this._pendingFullReposition=!0;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null;let Z=!this._pendingFullReposition;this._pendingFullReposition=!1,this.positionPopup({preserveCurrentPosition:Z})})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}isPopupDisplayed(){return Boolean(this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"))}}z0("fig-popup",$_,{extends:"dialog"});class J_ extends HTMLElement{#Z;#_;constructor(){super();this.content=null,this.#Z=!1,this.#_=this.handleClick.bind(this)}connectedCallback(){if(this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.addEventListener("click",this.#_),u(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let _=this.getAttribute("id")||g(),Z=this.content.getAttribute("id")||g();if(this.setAttribute("id",_),this.content.setAttribute("id",Z),this.setAttribute("aria-controls",Z),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",_),this.#Z)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}}})}get selected(){return this.#Z}set selected(_){this.setAttribute("selected",_?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#_)}handleClick(){if(z(this,"disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(_,Z,$){if(_==="selected"){if(this.#Z=$!==null&&$!=="false",this.setAttribute("aria-selected",this.#Z?"true":"false"),this.setAttribute("tabindex",this.#Z?"0":"-1"),this?.content)this.content.style.display=this.#Z?"block":"none"}if(_==="disabled")if($!==null&&$!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#Z?"0":"-1")}}A("fig-tab",J_);class Q_ extends HTMLElement{#Z;#_;#J=this.#B.bind(this);#$=null;#Q=null;#j=null;#K=null;#q=!1;#N=new WeakSet;constructor(){super();this.#Z=this.handleClick.bind(this),this.#_=this.#F.bind(this)}static get observedAttributes(){return["value","name","disabled","overflow"]}get#G(){return this.getAttribute("overflow")==="fade"?"fade":"buttons"}connectedCallback(){if(this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#_),this.addEventListener("scroll",this.#J),this.#T(),this.#L(),this.#M(),u(this,()=>{let _=this.getAttribute("value");if(_)this.#z(_);if(z(this,"disabled"))this.#W(!0);this.#Y(),this.#B(),this.#R(void 0,"auto")})}#W(_){this.querySelectorAll("fig-tab").forEach(($)=>{if(_){if(!($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false"))this.#N.add($),$.setAttribute("disabled","");$.setAttribute("aria-disabled","true"),$.setAttribute("tabindex","-1")}else if(this.#N.has($))this.#N.delete($),$.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#Y()}#X(){return Array.from(this.querySelectorAll("fig-tab")).filter((_)=>!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false")}#Y(){let _=Array.from(this.querySelectorAll("fig-tab")),Z=_.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false")||this.#X()[0];_.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false";$.setAttribute("tabindex",!J&&$===Z?"0":"-1")})}#R(_=this.selectedTab,Z="smooth"){let $=_||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#X()[0];if(!$)return;requestAnimationFrame(()=>{if(!this.isConnected||!$.isConnected)return;if(!(this.scrollWidth>this.clientWidth))return;let Q=this.getBoundingClientRect(),j=$.getBoundingClientRect(),q=j.left-Q.left+this.scrollLeft+j.width/2;this.scrollTo({left:q-this.clientWidth/2,behavior:Z}),this.#B()})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#_),this.removeEventListener("scroll",this.#J),this.#$?.disconnect(),this.#$=null,this.#Q?.disconnect(),this.#Q=null,this.#O()}#U(){if(this.#q)return;let _=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!_)return;this.#q=!0;try{let Z=Array.from(_.childNodes);_.replaceWith(...Z)}finally{this.#q=!1}}#B(){R0(this,this,"x")}#M(){this.#Q?.disconnect(),this.#Q=new ResizeObserver(()=>this.#B()),this.#Q.observe(this)}#L(){this.#$?.disconnect(),this.#$=new MutationObserver((_)=>{if(this.#q)return;if(!_.some(($)=>[...$.addedNodes,...$.removedNodes].some((J)=>!(J instanceof Element)||!J.matches("[data-fig-tabs-nav]"))))return;this.#U(),this.#T(),this.#Y(),requestAnimationFrame(()=>{this.#B(),this.#R()})}),this.#$.observe(this,{childList:!0,subtree:!1})}#O(){this.#j?.remove(),this.#K?.remove(),this.#j=null,this.#K=null,this.classList.remove("overflow-start","overflow-end")}#T(){let _=this.#G==="fade";if(this.classList.toggle("fig-overflow-fade",_),this.classList.toggle("fig-overflow-fade-horizontal",_),_)this.#O();else this.#I()}#I(){if(this.#j&&this.#K&&this.contains(this.#j)&&this.contains(this.#K)){this.#k();return}this.#j?.remove(),this.#K?.remove();let _=U0({owner:"tabs",onStart:()=>Z0(this,"x",-1),onEnd:()=>Z0(this,"x",1)});this.#j=_.start,this.#K=_.end,this.#k()}#k(){if(this.firstElementChild!==this.#j)this.prepend(this.#j);if(this.lastElementChild!==this.#K)this.append(this.#K)}#F(_){let Z=this.#X();if(!Z.length)return;let $=Z.findIndex((Q)=>z(Q,"selected")),J=$>=0?$:0;switch(_.key){case"ArrowLeft":case"ArrowUp":_.preventDefault(),J=$>0?$-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":_.preventDefault(),J=$<Z.length-1?$+1:0;break;case"Home":_.preventDefault(),J=0;break;case"End":_.preventDefault(),J=Z.length-1;break;default:return}if(J!==$&&Z[J]){this.querySelectorAll("fig-tab").forEach((j)=>j.removeAttribute("selected")),this.selectedTab=Z[J],Z[J].setAttribute("selected","true");let Q=this.#A(Z[J]);if(Q)this.setAttribute("value",Q);else this.removeAttribute("value");Z[J].focus(),this.#Y(),this.#R(Z[J]),this.#H()}}get value(){return this.#A(this.selectedTab)}set value(_){this.setAttribute("value",_)}#H(){let _=this.value;this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#A(_){if(!_)return"";let Z=_.getAttribute("value");if(Z!==null)return Z;return _.textContent?.trim()||""}#z(_){let Z=this.querySelectorAll("fig-tab");for(let $ of Z)if(this.#A($)===_)this.selectedTab=$,$.setAttribute("selected","true");else $.removeAttribute("selected");this.#Y(),this.#R(this.selectedTab)}attributeChangedCallback(_,Z,$){switch(_){case"value":if($!==Z)this.#z($);break;case"disabled":this.#W($!==null&&$!=="false");break;case"overflow":this.#T(),requestAnimationFrame(()=>this.#B());break}}handleClick(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=_.target.closest("fig-tab");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;let $=this.querySelectorAll("fig-tab"),J=Array.from($).find((q)=>z(q,"selected"))||this.selectedTab,Q=this.#A(J);for(let q of $)if(q===Z)this.selectedTab=q,q.setAttribute("selected","true");else q.removeAttribute("selected");let j=this.#A(Z);if(j)this.setAttribute("value",j);else this.removeAttribute("value");if(this.#Y(),this.#R(Z),J!==Z||Q!==this.value)this.#H()}}A("fig-tabs",Q_);class j_ extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group")}}A("fig-toolbelt-group",j_);class q_ extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Z()}get value(){let _=this.getAttribute("value");return _!==null?_:this.textContent?.trim()||""}set value(_){this.setAttribute("value",_??"")}get selected(){return z(this,"selected")}set selected(_){this.toggleAttribute("selected",Boolean(_))}get disabled(){return z(this,"disabled")}set disabled(_){this.toggleAttribute("disabled",Boolean(_))}attributeChangedCallback(){this.#Z()}#Z(){let _=z(this,"selected"),Z=z(this,"disabled");if(this.setAttribute("aria-pressed",_?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled")}}A("fig-toolbelt-item",q_);class N_ extends HTMLElement{#Z=this.#z.bind(this);#_=this.#C.bind(this);#J=this.#f.bind(this);#$=this.#S.bind(this);#Q=null;#j=null;#K=null;#q=null;#N=null;#G=null;#W=null;#X=null;#Y=new WeakSet;#R=!1;constructor(){super();let _=this.attachShadow({mode:"open"}),Z=document.createElement("div");Z.setAttribute("part","frame"),this.#K=document.createElement("slot"),this.#K.name="prepend",this.#K.setAttribute("part","prepend"),this.#K.hidden=!0,this.#K.style.display="none";let $=document.createElement("div");$.setAttribute("part","scroll-region");let J=document.createElement("slot");J.name="start",J.style.display="contents",this.#Q=document.createElement("div"),this.#Q.className="fig-overflow-fade",this.#Q.setAttribute("part","viewport"),this.#j=document.createElement("slot"),this.#j.style.display="contents",this.#Q.append(this.#j);let Q=document.createElement("slot");Q.name="end",Q.style.display="contents",this.#q=document.createElement("slot"),this.#q.name="append",this.#q.setAttribute("part","append"),this.#q.hidden=!0,this.#q.style.display="none",$.append(J,this.#Q,Q),Z.append(this.#K,$,this.#q),_.append(Z);for(let j of[this.#K,this.#j,this.#q])j.addEventListener("slotchange",this.#J)}static get observedAttributes(){return["value","disabled","layout","overflow"]}get#U(){return this.getAttribute("layout")==="vertical"}get#B(){return this.getAttribute("overflow")==="buttons"?"buttons":"scrollbar"}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","toolbar");this.#D(),this.#w(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#_),this.#Q.addEventListener("scroll",this.#$),this.#V(),this.#P(),this.#x(),u(this,()=>{this.#I(),this.#T(z(this,"disabled")),this.#A(),this.#S(),this.#h(void 0,"auto")})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#_),this.#Q.removeEventListener("scroll",this.#$),this.#N?.disconnect(),this.#N=null,this.#G?.disconnect(),this.#G=null,this.#m()}get value(){return this.selectedItem?.value||""}set value(_){if(_===null||_===void 0)this.removeAttribute("value");else this.setAttribute("value",String(_))}get selectedItem(){return this.#M().find((_)=>z(_,"selected"))||null}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="value"&&!this.#R)this.#k($);if(_==="disabled")this.#T($!==null&&$!=="false");if(_==="overflow")this.#V(),requestAnimationFrame(()=>this.#S());if(_==="layout"){if(this.#w(),this.#U)this.#Q.scrollLeft=0;else this.#Q.scrollTop=0;this.#V(),requestAnimationFrame(()=>{this.#S(),this.#h(void 0,"auto")})}}#M(){let _={prepend:[],viewport:[],append:[]};for(let Z of this.querySelectorAll("fig-toolbelt-item")){if(Z.closest("fig-toolbelt")!==this)continue;let $=this.#L(Z);if($)_[$].push(Z)}return[..._.prepend,..._.viewport,..._.append]}#L(_){let Z=_;while(Z.parentElement&&Z.parentElement!==this)Z=Z.parentElement;if(Z.parentElement!==this)return null;let $=Z.getAttribute("slot")||"";if($==="prepend"||$==="append")return $;return $?null:"viewport"}#O(){return this.#M().filter((_)=>!z(_,"disabled"))}#T(_){if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Z of this.#M())if(_){if(!z(Z,"disabled"))this.#Y.add(Z),Z.setAttribute("disabled","")}else if(this.#Y.has(Z))this.#Y.delete(Z),Z.removeAttribute("disabled");this.#A()}#I(){let _=this.getAttribute("value");if(_!==null){this.#k(_);return}let Z=this.#M().filter((J)=>z(J,"selected")),$=Z[0]||null;for(let J of Z.slice(1))J.removeAttribute("selected");if($)this.#H($.value)}#k(_){let Z=_===null?null:this.#M().find(($)=>$.value===_)||null;for(let $ of this.#M())$.toggleAttribute("selected",$===Z);if(this.#A(Z),Z)this.#h(Z)}#F(_,{emit:Z=!1,focus:$=!1}={}){if(!_||z(_,"disabled"))return!1;let J=this.selectedItem,Q=this.value;for(let j of this.#M())j.toggleAttribute("selected",j===_);if(this.#H(_.value),this.#A(_),$)_.focus();if(this.#h(_),Z&&(J!==_||Q!==_.value))this.#E();return!0}#H(_){this.#R=!0,this.setAttribute("value",_),this.#R=!1}#A(_){let Z=this.#M(),$=this.#O(),J=_&&$.includes(_)&&_||$.includes(document.activeElement)&&document.activeElement||$.includes(this.selectedItem)&&this.selectedItem||$[0]||null;for(let Q of Z)Q.setAttribute("tabindex",Q===J?"0":"-1")}#z(_){if(z(this,"disabled"))return;let Z=_.target.closest?.("fig-toolbelt-item");if(!Z||Z.closest("fig-toolbelt")!==this)return;this.#F(Z,{emit:!0})}#C(_){if(z(this,"disabled"))return;let Z=_.target.closest?.("fig-toolbelt-item");if(!Z||Z.closest("fig-toolbelt")!==this)return;if(_.key==="Enter"||_.key===" "){_.preventDefault(),this.#F(Z,{emit:!0});return}let $=this.#O();if(!$.length)return;let J=Math.max(0,$.indexOf(Z)),Q=J;switch(_.key){case"ArrowLeft":if(this.#U)return;Q=J>0?J-1:$.length-1;break;case"ArrowUp":if(!this.#U)return;Q=J>0?J-1:$.length-1;break;case"ArrowRight":if(this.#U)return;Q=J<$.length-1?J+1:0;break;case"ArrowDown":if(!this.#U)return;Q=J<$.length-1?J+1:0;break;case"Home":Q=0;break;case"End":Q=$.length-1;break;default:return}_.preventDefault(),this.#A($[Q]),$[Q].focus(),this.#v($[Q])}#E(){let _=this.value;this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#f(){this.#D(),this.#I(),this.#A(),requestAnimationFrame(()=>{this.#S(),this.#h()})}#D(){for(let _ of[this.#K,this.#q]){let Z=_.assignedElements({flatten:!0}).length===0;if(_.hidden=Z,Z)_.style.setProperty("display","none","important");else _.style.removeProperty("display")}}#P(){this.#N?.disconnect(),this.#N=new MutationObserver((_)=>{if(!_.some(($)=>$.type==="childList"||$.target instanceof Element&&$.target.matches("fig-toolbelt-item")&&$.target.closest("fig-toolbelt")===this))return;this.#V(),this.#I(),this.#T(z(this,"disabled")),this.#A(),requestAnimationFrame(()=>{this.#S(),this.#h()})}),this.#N.observe(this,{childList:!0,attributes:!0,subtree:!0,attributeFilter:["value","selected","disabled"]})}#x(){this.#G?.disconnect(),this.#G=new ResizeObserver(()=>this.#S()),this.#G.observe(this),this.#G.observe(this.#Q)}#S(){if(this.#B==="scrollbar")return;R0(this,this.#Q,this.#U?"y":"x")}#w(){this.setAttribute("aria-orientation",this.#U?"vertical":"horizontal"),this.#Q.classList.add("fig-overflow-fade"),this.#Q.classList.toggle("fig-overflow-fade-horizontal",!this.#U)}#V(){if(this.#B==="scrollbar")this.#m();else this.#g()}#g(){if(this.#W&&this.#X&&this.contains(this.#W)&&this.contains(this.#X)){this.#y();return}this.#W?.remove(),this.#X?.remove();let _=U0({owner:"toolbelt",onStart:()=>this.#b(-1),onEnd:()=>this.#b(1)});this.#W=_.start,this.#X=_.end,this.#W.setAttribute("slot","start"),this.#X.setAttribute("slot","end"),this.#y()}#y(){if(this.firstElementChild!==this.#W)this.prepend(this.#W);if(this.lastElementChild!==this.#X)this.append(this.#X)}#m(){this.#W?.remove(),this.#X?.remove(),this.#W=null,this.#X=null,this.classList.remove("overflow-start","overflow-end")}#b(_){Z0(this.#Q,this.#U?"y":"x",_)}#h(_=this.selectedItem,Z="smooth"){if(_)this.#v(_,Z)}#v(_,Z="smooth"){if(!_||this.#L(_)!=="viewport")return;requestAnimationFrame(()=>{if(!this.isConnected||!_.isConnected)return;let $=this.#U;if(!($?this.#Q.scrollHeight>this.#Q.clientHeight:this.#Q.scrollWidth>this.#Q.clientWidth))return;let Q=this.#Q.getBoundingClientRect(),j=_.getBoundingClientRect();if($){let q=j.top-Q.top+this.#Q.scrollTop+j.height/2;this.#Q.scrollTo({top:q-this.#Q.clientHeight/2,behavior:Z})}else{let q=j.left-Q.left+this.#Q.scrollLeft+j.width/2;this.#Q.scrollTo({left:q-this.#Q.clientWidth/2,behavior:Z})}this.#S()})}}A("fig-toolbelt",N_);class K_ extends HTMLElement{#Z;#_;#J;constructor(){super();this.#J=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#$(),this.addEventListener("click",this.#J)}disconnectedCallback(){this.removeEventListener("click",this.#J)}handleClick(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let _=this.closest("fig-segmented-control");if(_&&_.hasAttribute("disabled")&&_.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#Z}set value(_){this.#Z=_,this.setAttribute("value",_)}get selected(){return this.#_}set selected(_){this.#_=_,this.setAttribute("selected",_)}static get observedAttributes(){return["selected","value","disabled"]}#$(){let _=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",_?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",_?"0":"-1")}attributeChangedCallback(_,Z,$){switch(_){case"value":this.#Z=$;break;case"selected":this.#_=$,this.#$();break;case"disabled":this.#$();break}}}A("fig-segment",K_);class G_ extends HTMLElement{#Z=null;#_=this.handleClick.bind(this);#J=this.#B.bind(this);#$=null;#Q=null;#j=0;#K=!1;#q=!1;#N=new WeakSet;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){if(this.name=this.getAttribute("name")||"segmented-control",!this.hasAttribute("role"))this.setAttribute("role","radiogroup");this.addEventListener("click",this.#_),this.addEventListener("keydown",this.#J),this.#A(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#H(),this.#I(),u(this,()=>{this.#F({enforceFallback:!0}),this.#k(),this.#O({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#_),this.removeEventListener("keydown",this.#J),this.#$?.disconnect(),this.#$=null,this.#Q?.disconnect(),this.#Q=null,this.#j)cancelAnimationFrame(this.#j),this.#j=0;this.#K=!1,this.#q=!1}get selectedSegment(){return this.#Z}set selectedSegment(_){let Z=this.querySelectorAll("fig-segment");for(let $ of Z){let J=$===_,Q=z($,"selected");if(J&&!Q)$.setAttribute("selected","true");else if(!J&&Q)$.removeAttribute("selected")}this.#Z=_ instanceof HTMLElement&&this.contains(_)?_:null,this.#R(),this.#O()}get value(){return this.getAttribute("value")||""}set value(_){if(_===null||_===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(_))}#G(_){this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#W(_){let Z=_.getAttribute("value");if(Z!==null){let $=Z.trim();if($.length>0)return $}return _.textContent?.trim()||""}#X(){let _=this.querySelectorAll("fig-segment");for(let Z of _)if(Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false")return Z;return null}#Y(){return Array.from(this.querySelectorAll("fig-segment")).filter((_)=>!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false")}#R(){let _=Array.from(this.querySelectorAll("fig-segment")),Z=_.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false");_.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false",Q=$===Z;$.setAttribute("aria-checked",Q?"true":"false"),$.setAttribute("tabindex",!J&&Q?"0":"-1")})}#U(_){if(!_)return;let Z=this.selectedSegment,$=this.value;this.selectedSegment=_;let J=this.#W(_);if(J)this.setAttribute("value",J);else this.removeAttribute("value");let Q=this.value;if(Z!==_||$!==Q)this.#G(Q)}#B(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#Y();if(!Z.length)return;let $=Z.findIndex((j)=>z(j,"selected")),J=$>=0?$:0;switch(_.key){case"ArrowLeft":case"ArrowUp":_.preventDefault(),J=J>0?J-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":_.preventDefault(),J=J<Z.length-1?J+1:0;break;case"Home":_.preventDefault(),J=0;break;case"End":_.preventDefault(),J=Z.length-1;break;case" ":case"Enter":{let j=_.target.closest("fig-segment");if(j&&this.contains(j))_.preventDefault(),this.#U(j);return}default:return}let Q=Z[J];this.#U(Q),Q.focus(),requestAnimationFrame(()=>{if(this.contains(Q))Q.focus()})}#M(_){let Z=String(_??"").trim();if(!Z)return!1;let $=this.querySelectorAll("fig-segment");for(let J of $){let Q=this.#W(J);if(!Q)continue;if(Q===Z)return this.selectedSegment=J,!0}return!1}#L(){let _=this.getAttribute("animated");if(_===null)return!1;if(_==="")return!0;return _.trim().toLowerCase()==="true"}#O({forceInstant:_=!1}={}){if(this.#K=this.#K||_,this.#j)return;this.#j=requestAnimationFrame(()=>{this.#j=0;let Z=this.#K;this.#K=!1,this.#T({forceInstant:Z})})}#T({forceInstant:_=!1}={}){let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#L(),J=this.#Z&&this.contains(this.#Z)?this.#Z:this.#X();if(Z||!$){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!$||Z)this.#q=!1;return}if(!J){if(this.#q)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let Q=this.getBoundingClientRect(),j=J.getBoundingClientRect();if(Q.width<=0||j.width<=0){if(this.#q)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let q=Math.max(0,j.left-Q.left);this.style.setProperty("--seg-indicator-x",`${q}px`),this.style.setProperty("--seg-indicator-w",`${j.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#q||_?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#q=!0}#I(){this.#Q?.disconnect(),this.#Q=new ResizeObserver(()=>{this.#O()}),this.#k()}#k(){if(!this.#Q)return;this.#Q.disconnect(),this.#Q.observe(this),this.querySelectorAll("fig-segment").forEach((_)=>{this.#Q?.observe(_)})}#F({enforceFallback:_=!1}={}){if(this.querySelectorAll("fig-segment").length===0){this.#Z=null,this.#O({forceInstant:!0});return}let $=this.getAttribute("value"),J=$?.trim()??"";if($!==null){if(J!==$){this.setAttribute("value",J);return}if(J&&this.#M(J))return}let Q=this.#X();if(Q){this.selectedSegment=Q;return}if(_)this.selectedSegment=this.#Y()[0]||null}#H(){this.#$?.disconnect(),this.#$=new MutationObserver((_)=>{let Z=!1;for(let $ of _){if($.type==="childList"){Z=!0;break}if($.type==="attributes"&&$.target instanceof HTMLElement&&$.target.tagName.toLowerCase()==="fig-segment"&&($.attributeName==="value"||$.attributeName==="selected")){Z=!0;break}if($.type==="characterData"){Z=!0;break}}if(Z)this.#A(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#k(),this.#F({enforceFallback:!0}),this.#R()}),this.#$.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=_.target.closest("fig-segment");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#U(Z)}#A(_){this.setAttribute("aria-disabled",_?"true":"false"),this.querySelectorAll("fig-segment").forEach((Z)=>{if(_){if(!(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false"))this.#N.add(Z),Z.setAttribute("disabled","");Z.setAttribute("aria-disabled","true")}else if(this.#N.has(Z))this.#N.delete(Z),Z.removeAttribute("disabled"),Z.removeAttribute("aria-disabled")}),this.#R()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="disabled"){this.#A($!==null&&$!=="false"),this.#O({forceInstant:!0});return}if(_==="value"){this.#F({enforceFallback:!1});return}if(_==="animated"){if(!this.#L())this.#q=!1;this.#O({forceInstant:!0});return}if(_==="sizing")this.#O({forceInstant:!0})}}A("fig-segmented-control",G_);class X_ extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Z="segments";#_=0;#J=null;#$=[];#Q=null;#j=!1;#K(_){let Z=_?.detail;if(typeof Z==="string")return Z;let $=_?.currentTarget?.value??_?.target?.value??this.getAttribute("value");if($===null||$===void 0)return null;return String($)}#q(){if(this.#$.length===0)return!1;let _=this.querySelector(":scope > fig-segmented-control");if(_){let $=_.querySelectorAll("fig-segment");if($.length!==this.#$.length)return!1;return Array.from($).every((J,Q)=>J.getAttribute("value")===this.#$[Q])}let Z=this.querySelector(":scope > fig-dropdown");if(Z){let $=Z.querySelectorAll("option");return $.length===this.#$.length&&Array.from($).every((J,Q)=>J.textContent?.trim()===this.#$[Q])}return!1}#N(){let _=this.querySelector(":scope > fig-segmented-control");if(_)this.#Q=_,this.#Z="segments";else this.#Q=this.querySelector(":scope > fig-dropdown"),this.#Z="dropdown";this.#R()}connectedCallback(){if(this.#G(),this.#q()){this.#N(),this.#B(),u(this,()=>u(this,()=>this.#O()));return}this.#W(),this.#B(),u(this,()=>u(this,()=>this.#O()))}disconnectedCallback(){this.#J?.disconnect(),this.#J=null}get value(){return this.getAttribute("value")||""}set value(_){if(_===null||_===void 0)this.removeAttribute("value");else this.setAttribute("value",String(_))}get options(){return this.#$.slice()}set options(_){if(Array.isArray(_)){let $=_.some((J)=>String(J).includes(","))?JSON.stringify(_):_.join(",");this.setAttribute("options",$)}else this.setAttribute("options",String(_||""))}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="options"){this.#G(),this.#Y();return}if(_==="value"){this.#R();return}if(_==="disabled"){this.#U("disabled");return}if(_==="full"){this.#U("full");return}if(_==="sizing")this.#U("sizing"),this.#Y()}#G(){let _=this.getAttribute("options")||"";if(_.startsWith("["))try{this.#$=JSON.parse(_);return}catch{}let Z=_.includes(`
172
+ `;let J=document.createElement("slot");J.name="prepend";let Q=document.createElement("slot"),j=document.createElement("slot");j.name="append";let q=L(Z,{className:"fig-button-control",type:_?null:"button"},[J,Q,j]);this.shadowRoot.replaceChildren($,q),this.button=q,this.button.addEventListener("click",this.#Q),this.button.addEventListener("focus",this.#G),this.button.addEventListener("blur",this.#q)}this.shadowRoot.querySelectorAll("slot").forEach((_)=>{_.removeEventListener("slotchange",this.#j),_.addEventListener("slotchange",this.#j)}),this.removeEventListener("keydown",this.#$),this.addEventListener("keydown",this.#$),this.#Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#B(),this.#W()}get type(){return this.getAttribute("type")||"button"}set type(_){this.setAttribute("type",_)}get selected(){return this.#Z}set selected(_){this.setAttribute("selected",_)}#N(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#K(){if(this.#N())return;if(this.type==="toggle")if(this.selected)this.removeAttribute("selected");else this.setAttribute("selected","");if(this.type==="submit"){let _=this.closest("form");if(_)if(typeof _.requestSubmit==="function")_.requestSubmit();else _.submit()}if(this.type==="link"){let _=this.getAttribute("href"),Z=this.getAttribute("target");if(_)if(Z)window.open(_,Z);else window.location.href=_}}#Y(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#X(){let _=this.#Y();if(_ instanceof HTMLSelectElement)return _;if(_?.tagName==="FIG-DROPDOWN")return _.select||_.querySelector?.("select")||null;return null}#R(_){if(this.type!=="select")return;if(_.key!=="Enter")return;if(_.altKey||_.ctrlKey||_.metaKey||_.shiftKey)return;let Z=this.#X();if(!Z||Z.disabled||Z.multiple)return;if(typeof Z.showPicker!=="function")return;_.preventDefault();try{Z.showPicker()}catch{}}#U(){if(!this.button)return;if(this.type!=="toggle"){this.removeAttribute("aria-pressed"),this.button.removeAttribute("aria-pressed");return}let _=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.setAttribute("aria-pressed",_?"true":"false"),this.button.setAttribute("aria-pressed",_?"true":"false")}#W(){let Z=Array.from(this.querySelectorAll(':scope > fig-icon[slot="append"][data-generated="select-chevron"]')),$=Z[0];if(Z.slice(1).forEach((j)=>j.remove()),this.type!=="select"){$?.remove();return}if(this.querySelector(':scope > [slot="append"]:not([data-generated])')){$?.remove();return}if($)return;let Q=b("chevron",{size:"small"});Q.setAttribute("slot","append"),Q.setAttribute("data-generated","select-chevron"),this.append(Q)}#M(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#J.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.button.removeAttribute(_);else this.button.setAttribute(_,Z)})}#B(){if(!this.button)return;let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=_,this.button instanceof HTMLButtonElement)this.button.disabled=_,this.button.type="button",this.button.setAttribute("type","button");this.#O(),this.#M(),this.#U()}#O(){let _=this.#Y();if(!_)return;if(this.#N()){if(!this.#_.has(_))this.#_.set(_,_.hasAttribute("disabled")&&_.getAttribute("disabled")!=="false");_.setAttribute("disabled","")}else if(this.#_.has(_)){let $=this.#_.get(_);if(this.#_.delete(_),$)_.setAttribute("disabled","");else _.removeAttribute("disabled")}}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","aria-haspopup","aria-expanded","aria-controls","title"]}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"type":{let J=(Q)=>Q==="select"||Q==="upload";if(J(Z||"button")!==J($||"button")){this.button=null,this.connectedCallback();break}this.#B(),this.#W();break}case"disabled":this.#B();break;case"selected":this.#Z=$!==null&&$!=="false",this.#U();break;default:this.#M();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#$),this.shadowRoot?.querySelectorAll("slot").forEach((_)=>{_.removeEventListener("slotchange",this.#j)})}}F("fig-button",a0);class n0 extends HTMLElement{#Z="Menu";#_=null;#J;#$;#Q;get label(){return this.#Z}set label(_){this.#Z=_}#j;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#J=this.#K.bind(this),this.#$=this.#Y.bind(this),this.#Q=this.#X.bind(this),this.#j=this.slotChange.bind(this)}#G(){this.select.addEventListener("input",this.#J),this.select.addEventListener("change",this.#$),this.select.addEventListener("keydown",this.#Q)}#q(_){if(!_||!(_ instanceof Element))return!1;return!!_.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.#R(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#j),this.optionsSlot.addEventListener("slotchange",this.#j),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#Q),this.#G()}slotChange(){let _=this.hasAttribute("value"),Z=this.select.options.length>0&&this.select.selectedIndex>=0,$=_?this.getAttribute("value"):this.type==="dropdown"?this.#_:Z?this.select.value:null;while(this.select.firstChild)this.select.firstChild.remove();if(this.type==="dropdown"){let J=document.createElement("option");J.setAttribute("hidden","true"),J.setAttribute("selected","true"),J.selected=!0,this.select.appendChild(J)}if(this.optionsSlot.assignedNodes().forEach((J)=>{if(J.nodeName==="OPTION"||J.nodeName==="OPTGROUP")this.select.appendChild(J.cloneNode(!0))}),$!==null)this.#U($);if(this.type==="dropdown")this.select.selectedIndex=-1}#K(_){_.stopPropagation();let Z=_.target.selectedOptions?.[0];if(this.#q(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#N();return}let $=_.target.value;if(this.type==="dropdown")this.#_=$;this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}#Y(_){_.stopPropagation();let Z=_.target.selectedOptions?.[0];if(this.#q(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#N();return}let $=this.type==="dropdown"?this.#_:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,composed:!0}))}#X(_){if(this.closest('fig-button[type="select"]'))return;if(_.key!=="Enter"||_.defaultPrevented)return;if(_.altKey||_.ctrlKey||_.metaKey||_.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(typeof this.select.showPicker!=="function")return;_.preventDefault();try{this.select.showPicker()}catch{}}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#_;return this.select?.value}set value(_){if(this.type==="dropdown")this.#_=_;this.setAttribute("value",_)}static get observedAttributes(){return["value","type","label","disabled","variant","size"]}#R(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=_}#U(_){if(this.type==="dropdown")return;if(this.select)this.select.value=_??""}attributeChangedCallback(_,Z,$){if(_==="value")this.#U($);if(_==="type"){if(this.type=$||"select",this.isConnected)this.slotChange()}if(_==="label")this.#Z=$||"Menu",this.select.setAttribute("aria-label",this.#Z);if(_==="disabled")this.#R()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#j),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#Q)}}F("fig-dropdown",n0);class k extends HTMLElement{static#Z=0;static#_=0;static#J=1000;static#$=null;static#Q=!1;static#j=new Set;#G;#q;#N;#K;#Y;#X;#R;#U;#W;#M;#B;#O;#L=null;#T=null;#D=null;#k=!1;#F;#A=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let _=parseInt(this.getAttribute("delay"));this.delay=!isNaN(_)?_:500,this.#G=this.#y.bind(this),this.#q=this.hidePopupOutsideClick.bind(this),this.#N=this.showDelayedPopup.bind(this),this.#K=this.#w.bind(this),this.#Y=()=>{if(!this.#k)this.showDelayedPopup()},this.#X=()=>{this.#k=!1,this.hidePopup()},this.#R=this.#E.bind(this),this.#U=this.#x.bind(this),this.#W=this.#C.bind(this),this.#M=this.#v.bind(this),this.#O=this.#h.bind(this),this.#B=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(k.#b(),this.setup(),this.#S(),this.setupEventListeners(),this.#L=this.closest("dialog"),this.#L)this.#L.addEventListener("close",this.#B)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#V(),this.#z(),document.removeEventListener("mousedown",this.#G,!0),document.removeEventListener("keydown",this.#O,!0),this.#L)this.#L.removeEventListener("close",this.#B),this.#L=null;if(this.action==="click")document.body.removeEventListener("click",this.#q);if(clearTimeout(this.#F),k.#$===this)k.#$=null}#H(){return this.firstElementChild}#z(){this.#D?.disconnect(),this.#D=null}#S(){if(this.#V(),this.action==="manual")return;let _=this.#H();if(!_){if(!this.#D&&typeof MutationObserver<"u")this.#D=new MutationObserver(()=>{if(this.#H())this.#z(),this.#S()}),this.#D.observe(this,{childList:!0});return}if(this.#T=_,this.action==="hover"){if(!this.isTouchDevice())_.addEventListener("pointerenter",this.#N),_.addEventListener("pointerleave",this.#K);_.addEventListener("touchstart",this.#R,{passive:!0}),_.addEventListener("touchmove",this.#U,{passive:!0}),_.addEventListener("touchend",this.#W,{passive:!0}),_.addEventListener("touchcancel",this.#M,{passive:!0}),_.addEventListener("focus",this.#Y),_.addEventListener("blur",this.#X)}else if(this.action==="click")_.addEventListener("click",this.#N),_.addEventListener("touchstart",this.#N,{passive:!0})}#V(){let _=this.#T;if(!_)return;if(this.action==="hover")_.removeEventListener("pointerenter",this.#N),_.removeEventListener("pointerleave",this.#K),_.removeEventListener("touchstart",this.#R),_.removeEventListener("touchmove",this.#U),_.removeEventListener("touchend",this.#W),_.removeEventListener("touchcancel",this.#M),_.removeEventListener("focus",this.#Y),_.removeEventListener("blur",this.#X);else if(this.action==="click")_.removeEventListener("click",this.#N),_.removeEventListener("touchstart",this.#N);this.#T=null}setup(){this.style.display="contents"}render(){this.destroy();let _=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Z=document.createElement("span");if(this.popup=document.createElement("dialog",{is:"fig-popup"}),this.popup.setAttribute("is","fig-popup"),this.popup.setAttribute("variant","tooltip"),this.popup.setAttribute("data-tooltip-managed",""),this.popup.setAttribute("role","tooltip"),this.popup.setAttribute("closedby","closerequest"),_)this.popup.setAttribute("popover","manual");let $=v();this.popup.setAttribute("id",$);let J=this.getAttribute("theme");if(J)this.popup.setAttribute("theme",J);let Q=this.getAttribute("pointer");if(Q!==null)this.popup.setAttribute("pointer",Q);if(this.popup.append(Z),Z.innerText=this.getAttribute("text")??"",this.firstElementChild){let j=new Set((this.firstElementChild.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));j.add($),this.firstElementChild.setAttribute("aria-describedby",[...j].join(" "))}if(_)(N0()??document.body).append(this.popup);else{let j=this.closest("dialog");if(j&&j.open)j.append(this.popup);else(N0()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.#f(this.popup.id),this.popup.hidePopup?.(),this.popup.remove(),this.popup=null}#f(_){let Z=this.firstElementChild;if(!Z||!_)return;let $=Z.getAttribute("aria-describedby");if(!$)return;let J=$.split(/\s+/).filter((Q)=>Q&&Q!==_).join(" ");if(J)Z.setAttribute("aria-describedby",J);else Z.removeAttribute("aria-describedby")}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#q);document.addEventListener("mousedown",this.#G,!0),document.addEventListener("keydown",this.#O,!0)}get#I(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#P(){let _=Date.now(),Z=k.#J;if(this.action==="hover"&&k.#$)return!0;if(k.#Z&&_-k.#Z<Z)return!0;if(k.#_&&_-k.#_<Z)return!0;return!1}showDelayedPopup(_){if(this.#I)return;if(clearTimeout(this.timeout),_?.type==="pointerenter"){let Z=this.#T;if(Z?.matches?.("fig-select[open]")||Z?.querySelector?.("fig-select[open]"))return}if(this.#P()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#L&&!this.#L.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&k.#$&&k.#$!==this)k.#$.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")k.#$=this;k.#Z=Date.now()}hidePopup(){if(this.#I)return;clearTimeout(this.timeout),clearTimeout(this.#F);let _=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,k.#$===this)k.#$=null;if(_)k.#_=Date.now()}hidePopupOutsideClick(_){if(this.isOpen&&!this.popup.contains(_.target))this.hidePopup()}#w(_){if(!this.#A)this.hidePopup()}#E(_){if(this.action==="hover")this.#A=!0,clearTimeout(this.#F),this.showDelayedPopup()}#x(_){if(this.action==="hover"&&this.#A)clearTimeout(this.#F),this.#F=setTimeout(()=>{this.#A=!1,this.hidePopup()},150)}#C(_){if(this.action==="hover"&&this.#A)clearTimeout(this.#F),this.#F=setTimeout(()=>{this.#A=!1,this.hidePopup()},300)}#v(_){if(this.action==="hover"&&this.#A)this.#A=!1,clearTimeout(this.#F),this.hidePopup()}#h(_){if(!this.isOpen&&!this.popup||_.key!=="Escape")return;_.preventDefault(),this.hidePopup(),this.firstElementChild?.focus?.()}static get observedAttributes(){return["action","delay","open","pointer","show","text","theme"]}get text(){return this.getAttribute("text")??""}set text(_){this.setAttribute("text",_)}#m(_){if(!this.popup)return;let Z=this.popup.firstElementChild??this.popup.firstChild;if(!Z)return;Z.innerText=_}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){if(_===!1||_==="false"||_===null)this.removeAttribute("open");else this.setAttribute("open","true")}attributeChangedCallback(_,Z,$){if(_==="action"){if(this.#V(),Z==="click")document.body?.removeEventListener("click",this.#q);if(this.action=$||"hover",this.isConnected){if(this.#S(),this.action==="click")document.body?.addEventListener("click",this.#q)}}if(_==="delay"){let J=parseInt($);this.delay=!isNaN(J)?J:500}if(_==="open")if($!==null&&$!=="false")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(_==="show")if($!==null&&$!=="false")this.showPopup();else this.hidePopup();if(_==="text")this.#m($??"");if(_==="pointer"){if(this.popup)if($!==null)this.popup.setAttribute("pointer",$);else this.popup.removeAttribute("pointer")}if(_==="theme"){if(this.popup)if($)this.popup.setAttribute("theme",$);else this.popup.removeAttribute("theme")}}#y(_){if(!this.isOpen)return;let Z=_.target;if(this.popup&&this.popup.contains(Z))return;if(Z.tagName==="SELECT"||Z.hasAttribute("popover")||Z.closest("dialog"))this.hidePopup()}static#b(){if(k.#Q)return;k.#Q=!0;let _=()=>{k.dismissHoverTooltips()},Z=()=>{k.#u()};document.documentElement.addEventListener("mouseleave",_),document.addEventListener("mouseout",($)=>{if($.relatedTarget)return;_()}),document.addEventListener("scroll",Z,{capture:!0,passive:!0}),window.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("resize",Z,{passive:!0});try{let $=window.frameElement;if($)$.addEventListener("mouseleave",_)}catch{}window.addEventListener("message",($)=>{if($?.data?.type!=="figui:dismiss-tooltips")return;if(window.parent!==window&&$.source!==window.parent)return;_()})}static dismissHoverTooltips(){for(let _ of document.querySelectorAll("fig-tooltip")){if(!(_ instanceof k))continue;if(_.action!=="hover")continue;if(_.#I)continue;if(_.#k=!0,setTimeout(()=>{let Z=_.#T;if(Z!==document.activeElement&&!Z?.matches?.(":focus, :focus-within"))_.#k=!1},0),_.isOpen||_.timeout)_.hidePopup()}for(let _ of Array.from(k.#j))k.hide(_)}static#g=new WeakMap;static#u(){for(let _ of document.querySelectorAll("fig-tooltip")){if(!(_ instanceof k))continue;if(_.#I)continue;if(_.isOpen||_.timeout)_.hidePopup()}for(let _ of Array.from(k.#j))k.hide(_)}static show(_,Z,$={}){k.#b(),k.hide(_);let J=$.delay??500,j=Date.now()-k.#Z<k.#J?0:J,q={timeout:null,popup:null};k.#g.set(_,q),k.#j.add(_),q.timeout=setTimeout(()=>{let N=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,G=document.createElement("dialog",{is:"fig-popup"});if(G.setAttribute("is","fig-popup"),G.setAttribute("variant","tooltip"),G.setAttribute("data-tooltip-managed",""),G.setAttribute("role","tooltip"),G.setAttribute("closedby","closerequest"),N)G.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=Z,G.append(K),N)(N0()??document.body).append(G);else{let X=_.closest?.("dialog");if(X&&X.open)X.append(G);else(N0()??document.body).append(G)}G.anchor=_,G.open=!0,q.popup=G,k.#Z=Date.now()},j)}static hide(_){let Z=k.#g.get(_);if(!Z)return;if(clearTimeout(Z.timeout),Z.popup)Z.popup.remove(),k.#_=Date.now();k.#g.delete(_),k.#j.delete(_)}}F("fig-tooltip",k);class e0 extends HTMLElement{static observedAttributes=["position","tail","tooltip"];#Z=null;#_=null;#J=null;#$=null;connectedCallback(){this.#Z=this.textContent,this.#$??=new MutationObserver(()=>{this.#Z=this.textContent,this.#j()}),this.#Q(),u(this,()=>{this.#j(),this.#K(),this.#q()})}disconnectedCallback(){this.#$?.disconnect(),this.#K()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#Z===null)return;if(_==="tooltip"){if(this.#K(),this.isConnected)this.#q();return}this.#j()}#Q(){this.#$?.observe(this,{childList:!0,characterData:!0,subtree:!0})}#j(){if(this.#$?.disconnect(),this.#G(),this.isConnected)this.#Q()}#G(){let _=this.getAttribute("position")||"right",Z=this.#Z||"";if(_==="middle"){let $=this.getAttribute("tail"),J;if($){let q=Z.lastIndexOf($);J=q>0?q:Math.ceil(Z.length/2)}else J=Math.ceil(Z.length/2);this.replaceChildren();let Q=document.createElement("span");Q.className="start",Q.textContent=Z.slice(0,J);let j=document.createElement("span");j.className="end",j.textContent=Z.slice(J),this.appendChild(Q),this.appendChild(j)}else this.textContent=Z}#q(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#_=()=>{if(!this.#N())return;k.show(this,this.#Z)},this.#J=()=>{k.hide(this)},this.addEventListener("pointerenter",this.#_),this.addEventListener("pointerleave",this.#J)}#N(){let _=(Z)=>Z.scrollWidth>Z.clientWidth;if(_(this))return!0;return[...this.querySelectorAll(":scope > .start, :scope > .end")].some(_)}#K(){if(this.#_)this.removeEventListener("pointerenter",this.#_);if(this.#J)this.removeEventListener("pointerleave",this.#J);this.#_=null,this.#J=null,k.hide(this)}}F("fig-truncate",e0);function __(_){if(_.querySelector("fig-header[dialog-header]"))return;let Z=document.createElement("fig-header");Z.setAttribute("dialog-header",""),Z.setAttribute("data-auto","");let $=document.createElement("h3");$.textContent=_.getAttribute("title")||"Dialog";let J=document.createElement("fig-tooltip");J.setAttribute("text","Close");let Q=document.createElement("fig-button");Q.setAttribute("variant","ghost"),Q.setAttribute("icon",""),Q.setAttribute("aria-label","Close dialog"),Q.setAttribute("close-dialog",""),Q.appendChild(b("close")),J.appendChild(Q),Z.appendChild($),Z.appendChild(J),_.prepend(Z)}class Z_ extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._isDragging=!1,this._dragPending=!1,this._dragStartPos={x:0,y:0},this._dragOffset={x:0,y:0},this._resizeObserver=null,this._mutationObserver=null,this._autoResizeRafId=0,this._offset=16,this._positionInitialized=!1,this._dragThreshold=3,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundClose=this.close.bind(this),this._boundIframeMessage=this._handleIframeMessage.bind(this),this._boundContentMutation=this._scheduleAutoResize.bind(this),this._boundContentResize=this._scheduleAutoResize.bind(this),this._boundRestoreFocus=this._restoreFocus.bind(this),this._boundIframeMouseLeave=this._handleIframeMouseLeave.bind(this),this._iframeDismissMutationObserver=null,this._previousFocus=null}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){if(this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),this.open&&!this.matches?.(":modal"))this._assignStackingOrder();u(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._setupIframeDismissListeners(),this._syncA11y()}),window.addEventListener("message",this._boundIframeMessage)}disconnectedCallback(){this._figInit(),this._removeDragListeners(),this.querySelectorAll("fig-button[close-dialog]").forEach((_)=>{_.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize(),this._teardownIframeDismissListeners(),this.removeEventListener("close",this._boundRestoreFocus)}_captureFocusBeforeOpen(){let _=document.activeElement;this._previousFocus=_ instanceof HTMLElement&&_!==document.body&&!this.contains(_)?_:null}_restoreFocus(){let _=this._previousFocus;if(this._previousFocus=null,!_?.isConnected)return;let Z=document.activeElement;if(Z&&Z!==document.body&&!this.contains(Z))return;requestAnimationFrame(()=>_.focus?.())}_assignStackingOrder(){this.style.zIndex=String(t0()+1)}_clearStackingOrder(){this.style.zIndex=""}show(){return this._captureFocusBeforeOpen(),this._assignStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),k.dismissHoverTooltips(),super.show()}showModal(){return this._captureFocusBeforeOpen(),this._clearStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),k.dismissHoverTooltips(),super.showModal()}close(..._){let Z=super.close(..._);return this._clearStackingOrder(),Z}_handleIframeMouseLeave(_){let Z=_?.currentTarget;if(!(Z instanceof HTMLIFrameElement))return;try{Z.contentWindow?.postMessage({type:"figui:dismiss-tooltips"},"*")}catch{}}_syncIframeDismissListeners(){for(let _ of this.querySelectorAll(":scope > iframe")){if(!(_ instanceof HTMLIFrameElement))continue;if(_.dataset.figuiDismissBound==="true")continue;_.dataset.figuiDismissBound="true",_.addEventListener("mouseleave",this._boundIframeMouseLeave)}}_setupIframeDismissListeners(){if(this._syncIframeDismissListeners(),this._iframeDismissMutationObserver)return;this._iframeDismissMutationObserver=new MutationObserver(()=>{this._syncIframeDismissListeners()}),this._iframeDismissMutationObserver.observe(this,{childList:!0,subtree:!1})}_teardownIframeDismissListeners(){this._iframeDismissMutationObserver?.disconnect(),this._iframeDismissMutationObserver=null;for(let _ of this.querySelectorAll(":scope > iframe"))_.removeEventListener("mouseleave",this._boundIframeMouseLeave),delete _.dataset.figuiDismissBound}_handleIframeMessage(_){if(!this.autoresize)return;let Z=_?.data;if(!Z||Z.type!=="figui:iframe-resize")return;let $=_.source;if(!$)return;let J=Array.from(this.querySelectorAll("iframe")).find((Q)=>Q.contentWindow===$);if(!J)return;this._resizeForIframe(J,Z)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let _ of this.children)try{this._resizeObserver.observe(_)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((_)=>{for(let Z of _)Z.addedNodes?.forEach(($)=>{if($ instanceof Element&&$.parentElement===this)try{this._resizeObserver?.observe($)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(_){let Z=window.getComputedStyle(this),$=parseFloat(Z.paddingTop||"0")+parseFloat(Z.paddingBottom||"0")+parseFloat(Z.borderTopWidth||"0")+parseFloat(Z.borderBottomWidth||"0"),J=0,Q=parseFloat(Z.rowGap||Z.gap||"0")||0,j=0;for(let q of this.children){let N=q.getBoundingClientRect();if(N.height===0)continue;if(j+=1,q===_)continue;let G=window.getComputedStyle(q),K=parseFloat(G.marginTop||"0")+parseFloat(G.marginBottom||"0");J+=N.height+K}if(Q&&j>1)J+=Q*(j-1);return $+J}_resizeForIframe(_,Z){if(typeof Z.height!=="number"||!(Z.height>0))return;let $=this._computeChrome(_);this.style.height=`${Math.ceil(Z.height+$)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){__(this)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((_)=>{if(!_.hasAttribute("aria-label"))_.setAttribute("aria-label","Close dialog");_.removeEventListener("click",this._boundClose),_.addEventListener("click",this._boundClose)})}_syncA11y(){if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let _=this.querySelector("fig-header[dialog-header] h1, fig-header[dialog-header] h2, fig-header[dialog-header] h3, fig-header[dialog-header] h4, fig-header[dialog-header] h5, fig-header[dialog-header] h6");if(_){let Z=_.getAttribute("id")||v();_.setAttribute("id",Z),this.setAttribute("aria-labelledby",Z)}}}_applyPosition(){let _=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let Z=_.includes("top"),$=_.includes("bottom"),J=_.includes("left"),Q=_.includes("right"),j=_.includes("center")&&!Z&&!$,q=_.includes("center")&&!J&&!Q;if(Z)this.style.top=`${this._offset}px`;else if($)this.style.bottom=`${this._offset}px`;else if(j)this.style.top="0",this.style.bottom="0";if(J)this.style.left=`${this._offset}px`;else if(Q)this.style.right=`${this._offset}px`;else if(q)this.style.left="0",this.style.right="0";if(j&&q)this.style.margin="auto";else if(j)this.style.marginTop="auto",this.style.marginBottom="auto";else if(q)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let _=this.getAttribute("handle"),Z=_?this.querySelector(_):this.querySelector("fig-header, header");if(Z)Z.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}_isInteractiveElement(_){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(j)=>Z.some((q)=>j.matches?.(q))||j.tagName?.startsWith("FIG-")&&!$.includes(j.tagName);if(J(_))return!0;let Q=_.parentElement;while(Q&&Q!==this){if(J(Q))return!0;Q=Q.parentElement}return!1}_handlePointerDown(_){if(!this.drag)return;if(this._isInteractiveElement(_.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(_.target))return}this._dragPending=!0,this._dragStartPos.x=_.clientX,this._dragStartPos.y=_.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=_.clientX-$.left,this._dragOffset.y=_.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}_handlePointerMove(_){if(this._dragPending&&!this._isDragging){let Z=Math.abs(_.clientX-this._dragStartPos.x),$=Math.abs(_.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(_.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${_.clientX-this._dragOffset.x}px`,this.style.top=`${_.clientY-this._dragOffset.y}px`,_.preventDefault()}_handlePointerUp(_){if(this._isDragging){if(this.hasPointerCapture?.(_.pointerId))this.releasePointerCapture(_.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),_.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(_,Z,$){if(this._figInit(),_==="autoresize"&&this.isConnected)this._syncAutoResize();if(_==="drag")if(this.drag=$!==null&&$!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let J=this.querySelector("fig-header, header");if(J)J.style.cursor=""}if(_==="position"&&this._positionInitialized)this._applyPosition();if(_==="modal"){let J=this.modal;if(this.modal=$!==null&&$!=="false",this.open&&J!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(_==="closedby")this.closedby=$||"any";if(_==="title"){let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";this._syncA11y()}if(_==="aria-label"||_==="aria-labelledby")this._syncA11y()}}T0("fig-dialog",Z_,{extends:"dialog"});class $_ extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._toastVisible=!1,this._syncingOpen=!1,this._managedRole=null,this._managedLive=null,this._managedIcon=null,this._managedDismiss=null,this._managedDismissSeparator=null,this._boundHandleClose=this.handleClose.bind(this)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.syncIcon(),this.syncDismiss(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast();else{if(this.getAttribute("open")==="false")this._syncingOpen=!0,this.removeAttribute("open"),this._syncingOpen=!1;this._toastVisible=!1}}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((_)=>{if(!_.hasAttribute("aria-label"))_.setAttribute("aria-label","Close notification");_.removeEventListener("click",this._boundHandleClose),_.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto";let _=Number.parseFloat(this.getAttribute("offset")),Z=Number.isFinite(_)?_:this._defaultOffset;this.style.bottom=`${Z}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let _=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger",Z=_?"alert":"status",$=_?"assertive":"polite";if(!this.hasAttribute("role")||this.getAttribute("role")===this._managedRole)this.setAttribute("role",Z),this._managedRole=Z;if(!this.hasAttribute("aria-live")||this.getAttribute("aria-live")===this._managedLive)this.setAttribute("aria-live",$),this._managedLive=$;if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}syncIcon(){let _=this.getAttribute("icon"),Z=this._managedIcon;if(!Z||Z.parentNode!==this)Z=this.querySelector(":scope > fig-icon[data-fig-toast-icon]");if(!_){if(Z)Z.remove();this._managedIcon=null;return}if(!Z)Z=document.createElement("fig-icon"),Z.setAttribute("data-fig-toast-icon",""),Z.setAttribute("aria-hidden","true"),this.prepend(Z);else if(this.firstElementChild!==Z)this.prepend(Z);if(Z.getAttribute("size")!=="medium")Z.setAttribute("size","medium");if(Z.getAttribute("name")!==_)Z.setAttribute("name",_);this._managedIcon=Z}syncDismiss(){let _=T(this,"dismiss"),Z=this._managedDismiss;if(!Z||Z.parentNode!==this)Z=this.querySelector(":scope > fig-button[data-fig-toast-dismiss]");let $=this._managedDismissSeparator;if(!$||$.parentNode!==this)$=this.querySelector(":scope > fig-separator[data-fig-toast-dismiss-separator]");if(!_){if(Z)Z.removeEventListener("click",this._boundHandleClose),Z.remove();if($)$.remove();this._managedDismiss=null,this._managedDismissSeparator=null;return}if(!$)$=document.createElement("fig-separator"),$.setAttribute("data-fig-toast-dismiss-separator",""),$.setAttribute("direction","vertical"),$.setAttribute("aria-orientation","vertical"),$.setAttribute("aria-hidden","true");if(!Z){Z=document.createElement("fig-button"),Z.setAttribute("data-fig-toast-dismiss",""),Z.setAttribute("variant","ghost"),Z.setAttribute("icon",""),Z.setAttribute("close-toast",""),Z.setAttribute("aria-label","Close notification");let J=document.createElement("fig-icon");J.setAttribute("name","close"),J.setAttribute("aria-hidden","true"),Z.append(J)}if($.parentNode!==this||Z.parentNode!==this)this.append($,Z);else if(this.lastElementChild!==Z||Z.previousElementSibling!==$)this.append($,Z);if($.getAttribute("direction")!=="vertical")$.setAttribute("direction","vertical");Z.removeEventListener("click",this._boundHandleClose),Z.addEventListener("click",this._boundHandleClose),this._managedDismiss=Z,this._managedDismissSeparator=$}startAutoClose(){this.clearAutoClose();let _=parseInt(this.getAttribute("duration")??"5000");if(_>0)this._autoCloseTimer=setTimeout(()=>this.hideToast(),_)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}_resolveAutoTheme(){if(this.getAttribute("theme")!=="auto")return;let _=getComputedStyle(document.documentElement).colorScheme||"";this.style.colorScheme=_.includes("dark")?"light":"dark"}showToast(){let _=this._toastVisible;this.syncLiveRegion(),this.syncIcon(),this.syncDismiss(),this._resolveAutoTheme(),this._syncingOpen=!0;try{if(!this.open)this.show()}finally{this._syncingOpen=!1}if(this._toastVisible=!0,this.applyPosition(),this.startAutoClose(),!_)this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){let _=this._toastVisible||this.open;this.clearAutoClose(),this._syncingOpen=!0;try{if(this.open)this.close();else if(this.hasAttribute("open"))this.removeAttribute("open")}finally{this._syncingOpen=!1}if(this._toastVisible=!1,_)this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live","icon","dismiss"]}attributeChangedCallback(_,Z,$){if(this._figInit(),Z===$)return;if(!this.isConnected)return;if(this._syncingOpen)return;if(_==="offset")this.applyPosition();if(_==="open")if($!==null&&$!=="false")this.showToast();else this.hideToast();if(_==="duration"&&this._toastVisible)this.startAutoClose();if(_==="theme")if($==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme");if(_==="theme"||_==="live")this.syncLiveRegion();if(_==="icon")this.syncIcon();if(_==="dismiss")this.syncDismiss()}}T0("fig-toast",$_,{extends:"dialog"});class J_ extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundContentReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_pendingFullReposition=!1;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;_previousFocus=null;_boundDocumentKeydown;_boundNativeClose;constructor(){super();this._boundReposition=()=>this.queueReposition(),this._boundContentReposition=()=>this.queueReposition({preserveCurrentPosition:!0}),this._boundScroll=(_)=>{let Z=_.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this),this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this),this._boundNativeClose=this.handleNativeClose.bind(this),this._boundAutoClose=()=>{this.open=!1}}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._pendingFullReposition>"u")this._pendingFullReposition=!1;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._previousFocus>"u")this._previousFocus=null;if(typeof this._boundReposition!=="function")this._boundReposition=()=>this.queueReposition();if(typeof this._boundContentReposition!=="function")this._boundContentReposition=()=>this.queueReposition({preserveCurrentPosition:!0});if(typeof this._boundScroll!=="function")this._boundScroll=(_)=>{let Z=_.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this);if(typeof this._boundDocumentKeydown!=="function")this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this);if(typeof this._boundNativeClose!=="function")this._boundNativeClose=this.handleNativeClose.bind(this);if(typeof this._boundAutoClose!=="function")this._boundAutoClose=()=>{this.open=!1}}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin","title"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){if(_===!1||_==="false"||_===null){if(!(this.matches?.(":open")||this.matches?.(":popover-open"))&&!this.hasAttribute("open"))return;if(this.hidePopup(),this.hasAttribute("open"))this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(_){if(_ instanceof Element)this._anchorRef=_;else if(typeof _==="string")this._anchorRef=null,this.setAttribute("anchor",_);else if(_&&typeof _.getBoundingClientRect==="function")this._anchorRef=_;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role",this.getAttribute("variant")==="tooltip"?"tooltip":"dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),this.removeEventListener("close",this._boundNativeClose),this.addEventListener("close",this._boundNativeClose),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.removeEventListener("close",this._boundNativeClose),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(_,Z,$){if(this.ensureInitialized(),Z===$)return;if(_==="open"){if($==="false"){this.open=!1;return}if($===null){this.hidePopup();return}this.showPopup();return}if(_==="drag"){if(this.drag=$!==null&&$!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(_==="title"){this._ensureHeader();let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(t0()+1),this.captureFocusBeforeOpen();let _=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),Z=this.shouldAutoReposition();if(Z)this.style.visibility="hidden";if(_)try{this.showPopover()}catch(J){_=!1}if(!_&&!super.open)try{this.show()}catch(J){}if(Z&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.addEventListener("keydown",this._boundDocumentKeydown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let $=this.resolveAnchor();if($?.classList)$.classList.add("has-popup-open");if(this.getAttribute("variant")!=="tooltip")k.dismissHoverTooltips()}hidePopup(){let _=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),Z=this.resolveAnchor();if(Z?.classList)Z.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch($){}if(this.matches?.(":open"))try{this.close()}catch($){}if(_)this.restoreFocusAfterClose()}shouldRestoreFocus(){return this.getAttribute("variant")!=="tooltip"}captureFocusBeforeOpen(){if(!this.shouldRestoreFocus())return;let _=document.activeElement;this._previousFocus=_ instanceof HTMLElement&&_!==document.body&&!this.contains(_)?_:null}restoreFocusAfterClose(){if(!this.shouldRestoreFocus()){this._previousFocus=null;return}let _=this.resolveAnchor(),Z=this._previousFocus?.isConnected?this._previousFocus:_ instanceof HTMLElement?_:null;if(this._previousFocus=null,!Z?.isConnected)return;let $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Z.focus?.())}get autoresize(){let _=this.getAttribute("autoresize");return _===null||_!=="false"}set autoresize(_){if(_===!1||_==="false"||_===null)this.setAttribute("autoresize","false");else if(_||_==="")this.setAttribute("autoresize",_===!0?"":_);else this.setAttribute("autoresize","false")}handleNativeClose(){if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}setupObservers(){this.teardownObservers();let _=this.resolveAnchor();if(_ instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(_);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundContentReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundContentReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(_){if(!_)return null;let Z=_.getBoundingClientRect();return{x:Z.x,y:Z.y,width:Z.width,height:Z.height}}hasRectChanged(_,Z,$=0.25){if(!_&&!Z)return!1;if(!_||!Z)return!0;return Math.abs(_.x-Z.x)>$||Math.abs(_.y-Z.y)>$||Math.abs(_.width-Z.width)>$||Math.abs(_.height-Z.height)>$}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let _=()=>{if(!this.open){this._anchorTrackRAF=null;return}let Z=this.resolveAnchor(),$=this.readRectSnapshot(Z),J=this.shouldAutoReposition();if(J&&this.hasRectChanged(this._lastAnchorRect,$))this._lastAnchorRect=$,this.queueReposition();else if(!J)this._lastAnchorRect=$;this._anchorTrackRAF=requestAnimationFrame(_)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(_)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}_ensureHeader(){if(!this.hasAttribute("title")||this.getAttribute("variant")==="tooltip")return;__(this),this.querySelectorAll("fig-button[close-dialog]").forEach((_)=>{_.removeEventListener("click",this._boundAutoClose),_.addEventListener("click",this._boundAutoClose)})}handleOutsidePointerDown(_){if(!this.open||!(this.matches?.(":open")||this.matches?.(":popover-open")))return;let Z=this.getAttribute("closedby");if(Z==="none"||Z==="closerequest")return;let $=_.target;if(!($ instanceof Node))return;let J=typeof _.composedPath==="function"?_.composedPath():[];if(J.includes(this))return;if(this.contains($))return;let Q=this.resolveAnchor();if(Q&&(J.includes(Q)||Q.contains?.($)))return;if(this.isInsideDescendantPopup($))return;this.open=!1}handleDocumentKeydown(_){if(_.key!=="Escape"||_.defaultPrevented)return;if(!this.open)return;if(this.getAttribute("role")==="menu")return;if(this.getAttribute("closedby")==="none")return;let J=Array.from(document.querySelectorAll('dialog[is="fig-popup"][open]')).filter((Q)=>Q.open).map((Q)=>({popup:Q,z:Number.parseInt(getComputedStyle(Q).zIndex||"0",10)||0})).sort((Q,j)=>Q.z-j.z).at(-1)?.popup;if(J&&J!==this)return;_.preventDefault(),this.open=!1}isInsideDescendantPopup(_){let Z=_.closest?.('dialog[is="fig-popup"]');if(!Z||Z===this)return!1;let $=Z,J=new Set;while($&&!J.has($)){J.add($);let Q=$.anchor;if(!(Q instanceof Element))break;if(this.contains(Q))return!0;$=Q.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),document.removeEventListener("pointercancel",this._boundPointerUp)}isInteractiveElement(_){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(j)=>Z.some((q)=>j.matches?.(q))||j.tagName?.startsWith("FIG-")&&!$.includes(j.tagName);if(J(_))return!0;let Q=_.parentElement;while(Q&&Q!==this){if(J(Q))return!0;Q=Q.parentElement}return!1}handlePointerDown(_){if(!this.drag)return;if(this.isInteractiveElement(_.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(_.target))return}this._dragPending=!0,this._dragStartPos.x=_.clientX,this._dragStartPos.y=_.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=_.clientX-$.left,this._dragOffset.y=_.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}handlePointerMove(_){if(this._dragPending&&!this._isDragging){let Z=Math.abs(_.clientX-this._dragStartPos.x),$=Math.abs(_.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(_.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${_.clientX-this._dragOffset.x}px`,this.style.top=`${_.clientY-this._dragOffset.y}px`,_.preventDefault()}handlePointerUp(_){if(this._isDragging){if(this.hasPointerCapture?.(_.pointerId))this.releasePointerCapture(_.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),_.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let _=this.getAttribute("anchor");if(!_)return null;let Z=this.parentElement;try{if(Z?.querySelector){let $=Z.querySelector(_);if($&&!this.contains($))return $}return document.querySelector(_)}catch{return null}}parsePosition(){let Z=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),$=new Set(["top","center","bottom"]),J=new Set(["left","center","right"]),Q="top",j="center",q=null;if(Z.length>=2){if($.has(Z[0]))Q=Z[0];if(J.has(Z[1]))j=Z[1];return{vertical:Q,horizontal:j,shorthand:q}}if(Z.length===1){let N=Z[0];if(N==="top"||N==="bottom")Q=N,q=N;else if(N==="left"||N==="right")j=N,q=N;else if(N==="center")Q="center",j="center"}return{vertical:Q,horizontal:j,shorthand:q}}normalizeOffsetToken(_,Z="0px"){if(!_)return Z;let $=_.trim();if(!$)return Z;if(/^-?\d+(\.\d+)?$/.test($))return`${$}px`;return $}measureLengthPx(_,Z="x"){if(!_)return 0;let $=this.normalizeOffsetToken(_,"0px");if($.endsWith("px")){let j=parseFloat($);return Number.isFinite(j)?j:0}let J=document.createElement("div");if(J.style.position="fixed",J.style.visibility="hidden",J.style.pointerEvents="none",J.style.left="0",J.style.top="0",J.style.margin="0",J.style.padding="0",J.style.border="0",Z==="x")J.style.width=$,J.style.height="0";else J.style.height=$,J.style.width="0";document.body.appendChild(J);let Q=J.getBoundingClientRect();return J.remove(),Z==="x"?Q.width:Q.height}parseOffset(){let Z=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),$=this.normalizeOffsetToken(Z[0],"0px"),J=this.normalizeOffsetToken(Z[1],"0px");return{xToken:$,yToken:J,xPx:this.measureLengthPx($,"x"),yPx:this.measureLengthPx(J,"y")}}parseViewportMargins(){let Z=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((J)=>!Number.isNaN(J)),$=8;if(Z.length===0)return{top:8,right:8,bottom:8,left:8};if(Z.length===1)return{top:Z[0],right:Z[0],bottom:Z[0],left:Z[0]};if(Z.length===2)return{top:Z[0],right:Z[1],bottom:Z[0],left:Z[1]};if(Z.length===3)return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[1]};return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[3]}}getPlacementCandidates(_,Z,$){let J={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if($){let j=$==="left"||$==="right"?["top","bottom"]:["left","right"];return[{v:_,h:Z,s:$},{v:_,h:Z,s:J[$]},{v:_,h:Z,s:j[0]},{v:_,h:Z,s:j[1]}]}if(_==="center")return[{v:"center",h:Z,s:null},{v:"center",h:J[Z],s:null},{v:"top",h:Z,s:null},{v:"bottom",h:Z,s:null},{v:"top",h:J[Z],s:null},{v:"bottom",h:J[Z],s:null}];if(Z==="center")return[{v:_,h:"center",s:null},{v:J[_],h:"center",s:null},{v:_,h:"left",s:null},{v:_,h:"right",s:null},{v:J[_],h:"left",s:null},{v:J[_],h:"right",s:null}];return[{v:_,h:Z,s:null},{v:J[_],h:Z,s:null},{v:_,h:J[Z],s:null},{v:J[_],h:J[Z],s:null}]}computeCoords(_,Z,$,J,Q,j){let q,N;if(j==="left"||j==="right")return N=j==="left"?_.left-Z.width-Q.xPx:_.right+Q.xPx,q=_.top,{top:q,left:N};if(j==="top"||j==="bottom")return q=j==="top"?_.top-Z.height-Q.yPx:_.bottom+Q.yPx,N=_.left,{top:q,left:N};if($==="top")q=_.top-Z.height-Q.yPx;else if($==="bottom")q=_.bottom+Q.yPx;else q=_.top+(_.height-Z.height)/2;if($==="center")if(J==="left")N=_.left-Z.width-Q.xPx;else if(J==="right")N=_.right+Q.xPx;else N=_.left+(_.width-Z.width)/2;else if(J==="left")N=_.left+Q.xPx;else if(J==="right")N=_.right-Z.width-Q.xPx;else N=_.left+(_.width-Z.width)/2;return{top:q,left:N}}oppositeSide(_){return{top:"bottom",bottom:"top",left:"right",right:"left"}[_]||"bottom"}getPlacementSide(_,Z,$){if($==="top")return"top";if($==="bottom")return"bottom";if($==="left")return"left";if($==="right")return"right";if(_!=="center")return _;if(Z!=="center")return Z;return"top"}lengthToPx(_,Z=0){let $=getComputedStyle(this),J=String(_||"").trim(),Q=parseFloat(J);if(!Number.isFinite(Q))return Z;if(J.endsWith("rem"))return Q*parseFloat(getComputedStyle(document.documentElement).fontSize);if(J.endsWith("em"))return Q*parseFloat($.fontSize);return Q}radiusForSide(_){let Z=getComputedStyle(this),$=(J)=>this.lengthToPx(J,0);if(_==="top")return Math.max($(Z.borderTopLeftRadius),$(Z.borderTopRightRadius));if(_==="bottom")return Math.max($(Z.borderBottomLeftRadius),$(Z.borderBottomRightRadius));if(_==="left")return Math.max($(Z.borderTopLeftRadius),$(Z.borderBottomLeftRadius));if(_==="right")return Math.max($(Z.borderTopRightRadius),$(Z.borderBottomRightRadius));return 0}getBeakEdgeInset(_){let Z=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(_)+Z/2)}tracksAnchorBeak(){let _=this.getAttribute("variant");return _==="popover"||_==="tooltip"}getViewportBounds(_){let Z=window.visualViewport,$=Z?.width??window.innerWidth,J=Z?.height??window.innerHeight,Q=Z?.offsetLeft??0,j=Z?.offsetTop??0;return{minLeft:Q+_.left,minTop:j+_.top,maxRight:Q+$-_.right,maxBottom:j+J-_.bottom}}clampToViewport(_,Z,$){let J=this.getViewportBounds($),Q=J.maxRight-Z.width,j=J.maxBottom-Z.height,q=Math.max(J.minLeft,Q),N=Math.max(J.minTop,j);return{left:Math.min(q,Math.max(J.minLeft,_.left)),top:Math.min(N,Math.max(J.minTop,_.top))}}resolveCoordsAtViewport(_,Z,$,J,Q){let{left:j,top:q}=this.clampToViewport($,Z,Q);if(!_||!this.tracksAnchorBeak())return{left:j,top:q};let N=this.oppositeSide(J),G=this.getViewportBounds(Q),K=G.maxRight-Z.width,X=G.minLeft,Y=G.maxBottom-Z.height,U=G.minTop;if(N==="top"||N==="bottom"){let R=this.getBeakEdgeInset(N),O=_.left+_.width/2,M=O-j;if(M<R)j=O-R;else if(M>Z.width-R)j=O-(Z.width-R);j=Math.min(K,Math.max(X,j))}else if(N==="left"||N==="right"){let R=this.getBeakEdgeInset(N),O=_.top+_.height/2,M=O-q;if(M<R)q=O-R;else if(M>Z.height-R)q=O-(Z.height-R);q=Math.min(Y,Math.max(U,q))}return{left:j,top:q}}canPointAtAnchor(_,Z,$,J,Q){if(!_||!this.tracksAnchorBeak())return!0;let j=this.oppositeSide(Q),q=this.getBeakEdgeInset(j);if(j==="top"||j==="bottom"){let G=_.left+_.width/2-$;return G>=q-0.5&&G<=Z.width-q+0.5}let N=_.top+_.height/2-J;return N>=q-0.5&&N<=Z.height-q+0.5}updatePopoverBeak(_,Z,$,J,Q){if(!this.tracksAnchorBeak()||!_){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let j=this.oppositeSide(Q);this.setAttribute("data-beak-side",j);let q=_.left+_.width/2,N=_.top+_.height/2,G=this.getBoundingClientRect(),K=G.width>0&&G.height>0?G:Z,X=K.left,Y=K.top,U=this.getBeakEdgeInset(j),R;if(j==="top"||j==="bottom"){R=q-X;let O=U,M=Math.max(O,K.width-U);R=Math.min(M,Math.max(O,R))}else{R=N-Y;let O=U,M=Math.max(O,K.height-U);R=Math.min(M,Math.max(O,R))}this.style.setProperty("--fig-popup-beak-offset",`${R}px`)}overflowScore(_,Z,$){let J=this.getViewportBounds($),Q=_.left+Z.width,j=_.top+Z.height,q=Math.max(0,J.minLeft-_.left),N=Math.max(0,J.minTop-_.top),G=Math.max(0,Q-J.maxRight),K=Math.max(0,j-J.maxBottom);return q+N+G+K}fits(_,Z,$){return this.overflowScore(_,Z,$)===0}clamp(_,Z,$,J=null,Q="top"){if(J)return this.resolveCoordsAtViewport(J,Z,_,Q,$);return this.clampToViewport(_,Z,$)}primaryAxisOverflowPenalty(_,Z,$,J){let Q=this.getViewportBounds($),j=0;if(J==="top")j=Math.max(0,Q.minTop-_.top);else if(J==="bottom")j=Math.max(0,_.top+Z.height-Q.maxBottom);else if(J==="left")j=Math.max(0,Q.minLeft-_.left);else if(J==="right")j=Math.max(0,_.left+Z.width-Q.maxRight);return j>0?1000+j:0}placementScore(_,Z,$,J,Q){let j=this.resolveCoordsAtViewport(_,Z,$,J,Q),q=this.overflowScore(j,Z,Q);if(q+=this.primaryAxisOverflowPenalty($,Z,Q,J),_&&!this.canPointAtAnchor(_,Z,j.left,j.top,J))q+=1e4;return{score:q,resolved:j}}applyPopupPosition(_,Z,$,J,Q){let j=this.resolveCoordsAtViewport(_,Z,$,J,Q);this.style.left=`${j.left}px`,this.style.top=`${j.top}px`,this.updatePopoverBeak(_,Z,j.left,j.top,J)}currentPlacementSide(){let _=this.getAttribute("data-beak-side");if(_)return this.oppositeSide(_);let{vertical:Z,horizontal:$,shorthand:J}=this.parsePosition();return this.getPlacementSide(Z,$,J)}preservePopupPosition(_,Z,$){let J={left:_.left,top:_.top},Q=this.fits(J,_,$)?J:this.clampToViewport(J,_,$),j=Z?Z.getBoundingClientRect():null,q=this.currentPlacementSide();if(j&&this.tracksAnchorBeak()&&!this.canPointAtAnchor(j,_,Q.left,Q.top,q))return!1;return this.style.left=`${Q.left}px`,this.style.top=`${Q.top}px`,this.updatePopoverBeak(j,_,Q.left,Q.top,q),!0}positionPopup({preserveCurrentPosition:_=!1}={}){if(!this.open)return;let Z=this.getBoundingClientRect(),$=this.resolveAnchor(),J=this.parseViewportMargins();if(_&&this.preservePopupPosition(Z,$,J))return;let Q=this.parseOffset(),{vertical:j,horizontal:q,shorthand:N}=this.parsePosition();if(!$){this.updatePopoverBeak(null,Z,0,0,"top");let R=this.getViewportBounds(J),O={left:R.minLeft+(R.maxRight-R.minLeft-Z.width)/2,top:R.minTop+(R.maxBottom-R.minTop-Z.height)/2},M=this.clampToViewport(O,Z,J);this.style.left=`${M.left}px`,this.style.top=`${M.top}px`;return}let G=$.getBoundingClientRect(),K=this.getPlacementCandidates(j,q,N),X=null,Y="top",U=Number.POSITIVE_INFINITY;for(let{v:R,h:O,s:M}of K){let H=this.computeCoords(G,Z,R,O,Q,M),A=this.getPlacementSide(R,O,M),{score:z,resolved:W}=this.placementScore(G,Z,H,A,J);if(M){let I=this.getViewportBounds(J);if((M==="left"||M==="right"?H.left>=I.minLeft&&H.left+Z.width<=I.maxRight:H.top>=I.minTop&&H.top+Z.height<=I.maxBottom)&&z<1e4){this.applyPopupPosition(G,Z,H,A,J);return}}else if(z===0){this.applyPopupPosition(G,Z,H,A,J);return}if(z<U)U=z,X=W,Y=A}this.applyPopupPosition(G,Z,X||{left:0,top:0},Y,J)}queueReposition({preserveCurrentPosition:_=!1}={}){if(!this.open||!this.isPopupDisplayed()||!this.shouldAutoReposition())return;if(!_)this._pendingFullReposition=!0;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null;let Z=!this._pendingFullReposition;this._pendingFullReposition=!1,this.positionPopup({preserveCurrentPosition:Z})})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}isPopupDisplayed(){return Boolean(this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"))}}T0("fig-popup",J_,{extends:"dialog"});class Q_ extends HTMLElement{#Z;#_;constructor(){super();this.content=null,this.#Z=!1,this.#_=this.handleClick.bind(this)}connectedCallback(){if(this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.addEventListener("click",this.#_),u(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let _=this.getAttribute("id")||v(),Z=this.content.getAttribute("id")||v();if(this.setAttribute("id",_),this.content.setAttribute("id",Z),this.setAttribute("aria-controls",Z),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",_),this.#Z)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}}})}get selected(){return this.#Z}set selected(_){this.setAttribute("selected",_?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#_)}handleClick(){if(T(this,"disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(_,Z,$){if(_==="selected"){if(this.#Z=$!==null&&$!=="false",this.setAttribute("aria-selected",this.#Z?"true":"false"),this.setAttribute("tabindex",this.#Z?"0":"-1"),this?.content)this.content.style.display=this.#Z?"block":"none"}if(_==="disabled")if($!==null&&$!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#Z?"0":"-1")}}F("fig-tab",Q_);class j_ extends HTMLElement{#Z;#_;#J=this.#M.bind(this);#$=null;#Q=null;#j=null;#G=null;#q=!1;#N=new WeakSet;constructor(){super();this.#Z=this.handleClick.bind(this),this.#_=this.#F.bind(this)}static get observedAttributes(){return["value","name","disabled","overflow"]}get#K(){return this.getAttribute("overflow")==="fade"?"fade":"buttons"}connectedCallback(){if(this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#W(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#_),this.addEventListener("scroll",this.#J),this.#T(),this.#O(),this.#B(),u(this,()=>{let _=this.getAttribute("value");if(_)this.#z(_);if(T(this,"disabled"))this.#Y(!0);this.#R(),this.#M(),this.#U(void 0,"auto")})}#Y(_){this.querySelectorAll("fig-tab").forEach(($)=>{if(_){if(!($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false"))this.#N.add($),$.setAttribute("disabled","");$.setAttribute("aria-disabled","true"),$.setAttribute("tabindex","-1")}else if(this.#N.has($))this.#N.delete($),$.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#R()}#X(){return Array.from(this.querySelectorAll("fig-tab")).filter((_)=>!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false")}#R(){let _=Array.from(this.querySelectorAll("fig-tab")),Z=_.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false")||this.#X()[0];_.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false";$.setAttribute("tabindex",!J&&$===Z?"0":"-1")})}#U(_=this.selectedTab,Z="smooth"){let $=_||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#X()[0];if(!$)return;requestAnimationFrame(()=>{if(!this.isConnected||!$.isConnected)return;if(!(this.scrollWidth>this.clientWidth))return;let Q=this.getBoundingClientRect(),j=$.getBoundingClientRect(),q=j.left-Q.left+this.scrollLeft+j.width/2;this.scrollTo({left:q-this.clientWidth/2,behavior:Z}),this.#M()})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#_),this.removeEventListener("scroll",this.#J),this.#$?.disconnect(),this.#$=null,this.#Q?.disconnect(),this.#Q=null,this.#L()}#W(){if(this.#q)return;let _=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!_)return;this.#q=!0;try{let Z=Array.from(_.childNodes);_.replaceWith(...Z)}finally{this.#q=!1}}#M(){L0(this,this,"x")}#B(){this.#Q?.disconnect(),this.#Q=new ResizeObserver(()=>this.#M()),this.#Q.observe(this)}#O(){this.#$?.disconnect(),this.#$=new MutationObserver((_)=>{if(this.#q)return;if(!_.some(($)=>[...$.addedNodes,...$.removedNodes].some((J)=>!(J instanceof Element)||!J.matches("[data-fig-tabs-nav]"))))return;this.#W(),this.#T(),this.#R(),requestAnimationFrame(()=>{this.#M(),this.#U()})}),this.#$.observe(this,{childList:!0,subtree:!1})}#L(){this.#j?.remove(),this.#G?.remove(),this.#j=null,this.#G=null,this.classList.remove("overflow-start","overflow-end")}#T(){let _=this.#K==="fade";if(this.classList.toggle("fig-overflow-fade",_),this.classList.toggle("fig-overflow-fade-horizontal",_),_)this.#L();else this.#D()}#D(){if(this.#j&&this.#G&&this.contains(this.#j)&&this.contains(this.#G)){this.#k();return}this.#j?.remove(),this.#G?.remove();let _=W0({owner:"tabs",onStart:()=>Z0(this,"x",-1),onEnd:()=>Z0(this,"x",1)});this.#j=_.start,this.#G=_.end,this.#k()}#k(){if(this.firstElementChild!==this.#j)this.prepend(this.#j);if(this.lastElementChild!==this.#G)this.append(this.#G)}#F(_){let Z=this.#X();if(!Z.length)return;let $=Z.findIndex((Q)=>T(Q,"selected")),J=$>=0?$:0;switch(_.key){case"ArrowLeft":case"ArrowUp":_.preventDefault(),J=$>0?$-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":_.preventDefault(),J=$<Z.length-1?$+1:0;break;case"Home":_.preventDefault(),J=0;break;case"End":_.preventDefault(),J=Z.length-1;break;default:return}if(J!==$&&Z[J]){this.querySelectorAll("fig-tab").forEach((j)=>j.removeAttribute("selected")),this.selectedTab=Z[J],Z[J].setAttribute("selected","true");let Q=this.#H(Z[J]);if(Q)this.setAttribute("value",Q);else this.removeAttribute("value");Z[J].focus(),this.#R(),this.#U(Z[J]),this.#A()}}get value(){return this.#H(this.selectedTab)}set value(_){this.setAttribute("value",_)}#A(){let _=this.value;this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#H(_){if(!_)return"";let Z=_.getAttribute("value");if(Z!==null)return Z;return _.textContent?.trim()||""}#z(_){let Z=this.querySelectorAll("fig-tab");for(let $ of Z)if(this.#H($)===_)this.selectedTab=$,$.setAttribute("selected","true");else $.removeAttribute("selected");this.#R(),this.#U(this.selectedTab)}attributeChangedCallback(_,Z,$){switch(_){case"value":if($!==Z)this.#z($);break;case"disabled":this.#Y($!==null&&$!=="false");break;case"overflow":this.#T(),requestAnimationFrame(()=>this.#M());break}}handleClick(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=_.target.closest("fig-tab");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;let $=this.querySelectorAll("fig-tab"),J=Array.from($).find((q)=>T(q,"selected"))||this.selectedTab,Q=this.#H(J);for(let q of $)if(q===Z)this.selectedTab=q,q.setAttribute("selected","true");else q.removeAttribute("selected");let j=this.#H(Z);if(j)this.setAttribute("value",j);else this.removeAttribute("value");if(this.#R(),this.#U(Z),J!==Z||Q!==this.value)this.#A()}}F("fig-tabs",j_);class q_ extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group")}}F("fig-toolbelt-group",q_);class N_ extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Z()}get value(){let _=this.getAttribute("value");return _!==null?_:this.textContent?.trim()||""}set value(_){this.setAttribute("value",_??"")}get selected(){return T(this,"selected")}set selected(_){this.toggleAttribute("selected",Boolean(_))}get disabled(){return T(this,"disabled")}set disabled(_){this.toggleAttribute("disabled",Boolean(_))}attributeChangedCallback(){this.#Z()}#Z(){let _=T(this,"selected"),Z=T(this,"disabled");if(this.setAttribute("aria-pressed",_?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled")}}F("fig-toolbelt-item",N_);class G_ extends HTMLElement{#Z=this.#z.bind(this);#_=this.#S.bind(this);#J=this.#f.bind(this);#$=this.#E.bind(this);#Q=null;#j=null;#G=null;#q=null;#N=null;#K=null;#Y=null;#X=null;#R=new WeakSet;#U=!1;constructor(){super();let _=this.attachShadow({mode:"open"}),Z=document.createElement("div");Z.setAttribute("part","frame"),this.#G=document.createElement("slot"),this.#G.name="prepend",this.#G.setAttribute("part","prepend"),this.#G.hidden=!0,this.#G.style.display="none";let $=document.createElement("div");$.setAttribute("part","scroll-region");let J=document.createElement("slot");J.name="start",J.style.display="contents",this.#Q=document.createElement("div"),this.#Q.className="fig-overflow-fade",this.#Q.setAttribute("part","viewport"),this.#j=document.createElement("slot"),this.#j.style.display="contents",this.#Q.append(this.#j);let Q=document.createElement("slot");Q.name="end",Q.style.display="contents",this.#q=document.createElement("slot"),this.#q.name="append",this.#q.setAttribute("part","append"),this.#q.hidden=!0,this.#q.style.display="none",$.append(J,this.#Q,Q),Z.append(this.#G,$,this.#q),_.append(Z);for(let j of[this.#G,this.#j,this.#q])j.addEventListener("slotchange",this.#J)}static get observedAttributes(){return["value","disabled","layout","overflow"]}get#W(){return this.getAttribute("layout")==="vertical"}get#M(){return this.getAttribute("overflow")==="buttons"?"buttons":"scrollbar"}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","toolbar");this.#I(),this.#x(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#_),this.#Q.addEventListener("scroll",this.#$),this.#C(),this.#P(),this.#w(),u(this,()=>{this.#D(),this.#T(T(this,"disabled")),this.#H(),this.#E(),this.#b(void 0,"auto")})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#_),this.#Q.removeEventListener("scroll",this.#$),this.#N?.disconnect(),this.#N=null,this.#K?.disconnect(),this.#K=null,this.#m()}get value(){return this.selectedItem?.value||""}set value(_){if(_===null||_===void 0)this.removeAttribute("value");else this.setAttribute("value",String(_))}get selectedItem(){return this.#B().find((_)=>T(_,"selected"))||null}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="value"&&!this.#U)this.#k($);if(_==="disabled")this.#T($!==null&&$!=="false");if(_==="overflow")this.#C(),requestAnimationFrame(()=>this.#E());if(_==="layout"){if(this.#x(),this.#W)this.#Q.scrollLeft=0;else this.#Q.scrollTop=0;this.#C(),requestAnimationFrame(()=>{this.#E(),this.#b(void 0,"auto")})}}#B(){let _={prepend:[],viewport:[],append:[]};for(let Z of this.querySelectorAll("fig-toolbelt-item")){if(Z.closest("fig-toolbelt")!==this)continue;let $=this.#O(Z);if($)_[$].push(Z)}return[..._.prepend,..._.viewport,..._.append]}#O(_){let Z=_;while(Z.parentElement&&Z.parentElement!==this)Z=Z.parentElement;if(Z.parentElement!==this)return null;let $=Z.getAttribute("slot")||"";if($==="prepend"||$==="append")return $;return $?null:"viewport"}#L(){return this.#B().filter((_)=>!T(_,"disabled"))}#T(_){if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Z of this.#B())if(_){if(!T(Z,"disabled"))this.#R.add(Z),Z.setAttribute("disabled","")}else if(this.#R.has(Z))this.#R.delete(Z),Z.removeAttribute("disabled");this.#H()}#D(){let _=this.getAttribute("value");if(_!==null){this.#k(_);return}let Z=this.#B().filter((J)=>T(J,"selected")),$=Z[0]||null;for(let J of Z.slice(1))J.removeAttribute("selected");if($)this.#A($.value)}#k(_){let Z=_===null?null:this.#B().find(($)=>$.value===_)||null;for(let $ of this.#B())$.toggleAttribute("selected",$===Z);if(this.#H(Z),Z)this.#b(Z)}#F(_,{emit:Z=!1,focus:$=!1}={}){if(!_||T(_,"disabled"))return!1;let J=this.selectedItem,Q=this.value;for(let j of this.#B())j.toggleAttribute("selected",j===_);if(this.#A(_.value),this.#H(_),$)_.focus();if(this.#b(_),Z&&(J!==_||Q!==_.value))this.#V();return!0}#A(_){this.#U=!0,this.setAttribute("value",_),this.#U=!1}#H(_){let Z=this.#B(),$=this.#L(),J=_&&$.includes(_)&&_||$.includes(document.activeElement)&&document.activeElement||$.includes(this.selectedItem)&&this.selectedItem||$[0]||null;for(let Q of Z)Q.setAttribute("tabindex",Q===J?"0":"-1")}#z(_){if(T(this,"disabled"))return;let Z=_.target.closest?.("fig-toolbelt-item");if(!Z||Z.closest("fig-toolbelt")!==this)return;this.#F(Z,{emit:!0})}#S(_){if(T(this,"disabled"))return;let Z=_.target.closest?.("fig-toolbelt-item");if(!Z||Z.closest("fig-toolbelt")!==this)return;if(_.key==="Enter"||_.key===" "){_.preventDefault(),this.#F(Z,{emit:!0});return}let $=this.#L();if(!$.length)return;let J=Math.max(0,$.indexOf(Z)),Q=J;switch(_.key){case"ArrowLeft":if(this.#W)return;Q=J>0?J-1:$.length-1;break;case"ArrowUp":if(!this.#W)return;Q=J>0?J-1:$.length-1;break;case"ArrowRight":if(this.#W)return;Q=J<$.length-1?J+1:0;break;case"ArrowDown":if(!this.#W)return;Q=J<$.length-1?J+1:0;break;case"Home":Q=0;break;case"End":Q=$.length-1;break;default:return}_.preventDefault(),this.#H($[Q]),$[Q].focus(),this.#g($[Q])}#V(){let _=this.value;this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#f(){this.#I(),this.#D(),this.#H(),requestAnimationFrame(()=>{this.#E(),this.#b()})}#I(){for(let _ of[this.#G,this.#q]){let Z=_.assignedElements({flatten:!0}).length===0;if(_.hidden=Z,Z)_.style.setProperty("display","none","important");else _.style.removeProperty("display")}}#P(){this.#N?.disconnect(),this.#N=new MutationObserver((_)=>{if(!_.some(($)=>$.type==="childList"||$.target instanceof Element&&$.target.matches("fig-toolbelt-item")&&$.target.closest("fig-toolbelt")===this))return;this.#C(),this.#D(),this.#T(T(this,"disabled")),this.#H(),requestAnimationFrame(()=>{this.#E(),this.#b()})}),this.#N.observe(this,{childList:!0,attributes:!0,subtree:!0,attributeFilter:["value","selected","disabled"]})}#w(){this.#K?.disconnect(),this.#K=new ResizeObserver(()=>this.#E()),this.#K.observe(this),this.#K.observe(this.#Q)}#E(){if(this.#M==="scrollbar")return;L0(this,this.#Q,this.#W?"y":"x")}#x(){this.setAttribute("aria-orientation",this.#W?"vertical":"horizontal"),this.#Q.classList.add("fig-overflow-fade"),this.#Q.classList.toggle("fig-overflow-fade-horizontal",!this.#W)}#C(){if(this.#M==="scrollbar")this.#m();else this.#v()}#v(){if(this.#Y&&this.#X&&this.contains(this.#Y)&&this.contains(this.#X)){this.#h();return}this.#Y?.remove(),this.#X?.remove();let _=W0({owner:"toolbelt",onStart:()=>this.#y(-1),onEnd:()=>this.#y(1)});this.#Y=_.start,this.#X=_.end,this.#Y.setAttribute("slot","start"),this.#X.setAttribute("slot","end"),this.#h()}#h(){if(this.firstElementChild!==this.#Y)this.prepend(this.#Y);if(this.lastElementChild!==this.#X)this.append(this.#X)}#m(){this.#Y?.remove(),this.#X?.remove(),this.#Y=null,this.#X=null,this.classList.remove("overflow-start","overflow-end")}#y(_){Z0(this.#Q,this.#W?"y":"x",_)}#b(_=this.selectedItem,Z="smooth"){if(_)this.#g(_,Z)}#g(_,Z="smooth"){if(!_||this.#O(_)!=="viewport")return;requestAnimationFrame(()=>{if(!this.isConnected||!_.isConnected)return;let $=this.#W;if(!($?this.#Q.scrollHeight>this.#Q.clientHeight:this.#Q.scrollWidth>this.#Q.clientWidth))return;let Q=this.#Q.getBoundingClientRect(),j=_.getBoundingClientRect();if($){let q=j.top-Q.top+this.#Q.scrollTop+j.height/2;this.#Q.scrollTo({top:q-this.#Q.clientHeight/2,behavior:Z})}else{let q=j.left-Q.left+this.#Q.scrollLeft+j.width/2;this.#Q.scrollTo({left:q-this.#Q.clientWidth/2,behavior:Z})}this.#E()})}}F("fig-toolbelt",G_);class K_ extends HTMLElement{#Z;#_;#J;constructor(){super();this.#J=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#$(),this.addEventListener("click",this.#J)}disconnectedCallback(){this.removeEventListener("click",this.#J)}handleClick(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let _=this.closest("fig-segmented-control");if(_&&_.hasAttribute("disabled")&&_.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#Z}set value(_){this.#Z=_,this.setAttribute("value",_)}get selected(){return this.#_}set selected(_){this.#_=_,this.setAttribute("selected",_)}static get observedAttributes(){return["selected","value","disabled"]}#$(){let _=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",_?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",_?"0":"-1")}attributeChangedCallback(_,Z,$){switch(_){case"value":this.#Z=$;break;case"selected":this.#_=$,this.#$();break;case"disabled":this.#$();break}}}F("fig-segment",K_);class X_ extends HTMLElement{#Z=null;#_=this.handleClick.bind(this);#J=this.#M.bind(this);#$=null;#Q=null;#j=0;#G=!1;#q=!1;#N=new WeakSet;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){if(this.name=this.getAttribute("name")||"segmented-control",!this.hasAttribute("role"))this.setAttribute("role","radiogroup");this.addEventListener("click",this.#_),this.addEventListener("keydown",this.#J),this.#H(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#A(),this.#D(),u(this,()=>{this.#F({enforceFallback:!0}),this.#k(),this.#L({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#_),this.removeEventListener("keydown",this.#J),this.#$?.disconnect(),this.#$=null,this.#Q?.disconnect(),this.#Q=null,this.#j)cancelAnimationFrame(this.#j),this.#j=0;this.#G=!1,this.#q=!1}get selectedSegment(){return this.#Z}set selectedSegment(_){let Z=this.querySelectorAll("fig-segment");for(let $ of Z){let J=$===_,Q=T($,"selected");if(J&&!Q)$.setAttribute("selected","true");else if(!J&&Q)$.removeAttribute("selected")}this.#Z=_ instanceof HTMLElement&&this.contains(_)?_:null,this.#U(),this.#L()}get value(){return this.getAttribute("value")||""}set value(_){if(_===null||_===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(_))}#K(_){this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#Y(_){let Z=_.getAttribute("value");if(Z!==null){let $=Z.trim();if($.length>0)return $}return _.textContent?.trim()||""}#X(){let _=this.querySelectorAll("fig-segment");for(let Z of _)if(Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false")return Z;return null}#R(){return Array.from(this.querySelectorAll("fig-segment")).filter((_)=>!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false")}#U(){let _=Array.from(this.querySelectorAll("fig-segment")),Z=_.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false");_.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false",Q=$===Z;$.setAttribute("aria-checked",Q?"true":"false"),$.setAttribute("tabindex",!J&&Q?"0":"-1")})}#W(_){if(!_)return;let Z=this.selectedSegment,$=this.value;this.selectedSegment=_;let J=this.#Y(_);if(J)this.setAttribute("value",J);else this.removeAttribute("value");let Q=this.value;if(Z!==_||$!==Q)this.#K(Q)}#M(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#R();if(!Z.length)return;let $=Z.findIndex((j)=>T(j,"selected")),J=$>=0?$:0;switch(_.key){case"ArrowLeft":case"ArrowUp":_.preventDefault(),J=J>0?J-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":_.preventDefault(),J=J<Z.length-1?J+1:0;break;case"Home":_.preventDefault(),J=0;break;case"End":_.preventDefault(),J=Z.length-1;break;case" ":case"Enter":{let j=_.target.closest("fig-segment");if(j&&this.contains(j))_.preventDefault(),this.#W(j);return}default:return}let Q=Z[J];this.#W(Q),Q.focus(),requestAnimationFrame(()=>{if(this.contains(Q))Q.focus()})}#B(_){let Z=String(_??"").trim();if(!Z)return!1;let $=this.querySelectorAll("fig-segment");for(let J of $){let Q=this.#Y(J);if(!Q)continue;if(Q===Z)return this.selectedSegment=J,!0}return!1}#O(){let _=this.getAttribute("animated");if(_===null)return!1;if(_==="")return!0;return _.trim().toLowerCase()==="true"}#L({forceInstant:_=!1}={}){if(this.#G=this.#G||_,this.#j)return;this.#j=requestAnimationFrame(()=>{this.#j=0;let Z=this.#G;this.#G=!1,this.#T({forceInstant:Z})})}#T({forceInstant:_=!1}={}){let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#O(),J=this.#Z&&this.contains(this.#Z)?this.#Z:this.#X();if(Z||!$){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!$||Z)this.#q=!1;return}if(!J){if(this.#q)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let Q=this.getBoundingClientRect(),j=J.getBoundingClientRect();if(Q.width<=0||j.width<=0){if(this.#q)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let q=Math.max(0,j.left-Q.left);this.style.setProperty("--seg-indicator-x",`${q}px`),this.style.setProperty("--seg-indicator-w",`${j.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#q||_?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#q=!0}#D(){this.#Q?.disconnect(),this.#Q=new ResizeObserver(()=>{this.#L()}),this.#k()}#k(){if(!this.#Q)return;this.#Q.disconnect(),this.#Q.observe(this),this.querySelectorAll("fig-segment").forEach((_)=>{this.#Q?.observe(_)})}#F({enforceFallback:_=!1}={}){if(this.querySelectorAll("fig-segment").length===0){this.#Z=null,this.#L({forceInstant:!0});return}let $=this.getAttribute("value"),J=$?.trim()??"";if($!==null){if(J!==$){this.setAttribute("value",J);return}if(J&&this.#B(J))return}let Q=this.#X();if(Q){this.selectedSegment=Q;return}if(_)this.selectedSegment=this.#R()[0]||null}#A(){this.#$?.disconnect(),this.#$=new MutationObserver((_)=>{let Z=!1;for(let $ of _){if($.type==="childList"){Z=!0;break}if($.type==="attributes"&&$.target instanceof HTMLElement&&$.target.tagName.toLowerCase()==="fig-segment"&&($.attributeName==="value"||$.attributeName==="selected")){Z=!0;break}if($.type==="characterData"){Z=!0;break}}if(Z)this.#H(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#k(),this.#F({enforceFallback:!0}),this.#U()}),this.#$.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=_.target.closest("fig-segment");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#W(Z)}#H(_){this.setAttribute("aria-disabled",_?"true":"false"),this.querySelectorAll("fig-segment").forEach((Z)=>{if(_){if(!(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false"))this.#N.add(Z),Z.setAttribute("disabled","");Z.setAttribute("aria-disabled","true")}else if(this.#N.has(Z))this.#N.delete(Z),Z.removeAttribute("disabled"),Z.removeAttribute("aria-disabled")}),this.#U()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="disabled"){this.#H($!==null&&$!=="false"),this.#L({forceInstant:!0});return}if(_==="value"){this.#F({enforceFallback:!1});return}if(_==="animated"){if(!this.#O())this.#q=!1;this.#L({forceInstant:!0});return}if(_==="sizing")this.#L({forceInstant:!0})}}F("fig-segmented-control",X_);class Y_ extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Z="segments";#_=0;#J=null;#$=[];#Q=null;#j=!1;#G(_){let Z=_?.detail;if(typeof Z==="string")return Z;let $=_?.currentTarget?.value??_?.target?.value??this.getAttribute("value");if($===null||$===void 0)return null;return String($)}#q(){if(this.#$.length===0)return!1;let _=this.querySelector(":scope > fig-segmented-control");if(_){let $=_.querySelectorAll("fig-segment");if($.length!==this.#$.length)return!1;return Array.from($).every((J,Q)=>J.getAttribute("value")===this.#$[Q])}let Z=this.querySelector(":scope > fig-dropdown");if(Z){let $=Z.querySelectorAll("option");return $.length===this.#$.length&&Array.from($).every((J,Q)=>J.textContent?.trim()===this.#$[Q])}return!1}#N(){let _=this.querySelector(":scope > fig-segmented-control");if(_)this.#Q=_,this.#Z="segments";else this.#Q=this.querySelector(":scope > fig-dropdown"),this.#Z="dropdown";this.#U()}connectedCallback(){if(this.#K(),this.#q()){this.#N(),this.#M(),u(this,()=>u(this,()=>this.#L()));return}this.#Y(),this.#M(),u(this,()=>u(this,()=>this.#L()))}disconnectedCallback(){this.#J?.disconnect(),this.#J=null}get value(){return this.getAttribute("value")||""}set value(_){if(_===null||_===void 0)this.removeAttribute("value");else this.setAttribute("value",String(_))}get options(){return this.#$.slice()}set options(_){if(Array.isArray(_)){let $=_.some((J)=>String(J).includes(","))?JSON.stringify(_):_.join(",");this.setAttribute("options",$)}else this.setAttribute("options",String(_||""))}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="options"){this.#K(),this.#R();return}if(_==="value"){this.#U();return}if(_==="disabled"){this.#W("disabled");return}if(_==="full"){this.#W("full");return}if(_==="sizing")this.#W("sizing"),this.#R()}#K(){let _=this.getAttribute("options")||"";if(_.startsWith("["))try{this.#$=JSON.parse(_);return}catch{}let Z=_.includes(`
173
173
  `)?`
174
- `:",";this.#$=_.split(Z).map(($)=>$.trim()).filter(Boolean)}#W(){if(this.replaceChildren(),this.#$.length===0)return;let _=document.createElement("fig-segmented-control");if(_.setAttribute("sizing",this.getAttribute("sizing")||"equal"),z(this,"disabled"))_.setAttribute("disabled","");if(z(this,"full"))_.setAttribute("full","");let Z=this.getAttribute("value");for(let $ of this.#$){let J=document.createElement("fig-segment");if(J.setAttribute("value",$),J.textContent=$,Z===$)J.setAttribute("selected","true");_.appendChild(J)}if(Z)_.setAttribute("value",Z);_.addEventListener("input",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#K($);if(J===null)return;this.#j=!0,this.setAttribute("value",J),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),_.addEventListener("change",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#K($);if(J===null)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(_),this.#Q=_,this.#Z="segments"}#X(){if(this.replaceChildren(),this.#$.length===0)return;let _=document.createElement("fig-dropdown");if(z(this,"disabled"))_.setAttribute("disabled","");let Z=this.getAttribute("value");for(let $ of this.#$){let J=document.createElement("option");if(J.value=$,J.textContent=$,Z===$)J.selected=!0;_.appendChild(J)}if(Z)_.setAttribute("value",Z);_.addEventListener("input",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#K($);if(!J)return;this.#j=!0,this.setAttribute("value",J),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),_.addEventListener("change",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#K($);if(!J)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(_),this.#Q=_,this.#Z="dropdown"}#Y(){if(this.#Z==="segments")this.#W(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#O())});else this.#X()}#R(){if(!this.#Q||this.#j)return;let _=this.getAttribute("value")||"";this.#Q.value=_}#U(_){if(!this.#Q)return;if(this.hasAttribute(_))this.#Q.setAttribute(_,this.getAttribute(_)||"");else this.#Q.removeAttribute(_)}#B(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#O()}),this.#J.observe(this)}#M(_){let Z=document.createRange();Z.selectNodeContents(_);let $=Z.getBoundingClientRect().width,Q=_.getBoundingClientRect().width,j=getComputedStyle(_),q=parseFloat(j.paddingLeft)||0,N=parseFloat(j.paddingRight)||0,K=Q-q-N;return $>K+0.5}#L(){let _=this.querySelectorAll("fig-segment");for(let Z of _)if(this.#M(Z))return!0;return!1}#O(){if(this.#$.length<=1)return;if(this.#Z==="segments"){let _=this.#Q;if(_&&_.scrollWidth>_.clientWidth+1||this.#L())this.#_=this.clientWidth,this.#X()}else if(this.#_>0&&this.clientWidth>=this.#_)this.#W(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let _=this.#Q;if(_&&_.scrollWidth>_.clientWidth+1||this.#L())this.#X()})})}}A("fig-options",X_);class Y_ extends HTMLElement{#Z=!1;#_=!1;#J=!1;#$="";#Q=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#j={range:{min:0,max:100,step:1},hue:{min:0,max:255,step:1},delta:{min:-100,max:100,step:1},stepper:{min:0,max:100,step:25},opacity:{min:0,max:100,step:0.1,color:"var(--figma-color-icon)"}};#K;#q;#N;#G;#W;#X;#Y;#R=null;#U=null;#B=null;#M=null;constructor(){super();this.initialChildren=null,this.#K=(_)=>{_.stopPropagation(),this.#m()},this.#q=(_)=>{_.stopPropagation(),this.#b()},this.#W=(_)=>{this.#h(_)},this.#N=(_)=>{_.stopPropagation(),this.#F()},this.#G=(_)=>{_.stopPropagation(),this.#v()},this.#X=()=>{this.#Z=!0},this.#Y=()=>{if(this.#Z=!1,this.#_&&this.isConnected)this.#_=!1,this.#k()}}#L(){let _=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.getAttribute("text")!=="false",this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";let Z=this.#j[this.type]||this.#j.range,$=(J,Q)=>{let j=this.getAttribute(J),q=j===null||j.trim()===""?Q:Number(j);return Number.isFinite(q)?q:Q};if(this.min=$("min",Z.min),this.max=$("max",Z.max),this.step=$("step",Z.step),!(this.step>0))this.step=Z.step>0?Z.step:1;this.color=this.getAttribute("color")||Z?.color,this.default=this.#P(),this.value=this.#S(_)}#O(){if(!this.querySelector("[type=range]"))return!1;return this.getAttribute("text")!=="false"===!!this.querySelector("fig-input-number")}#T(){if(this.#L(),this.color)this.style.setProperty("--color",this.color);else this.style.removeProperty("--color");if(this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.input.className=this.type,this.input.min=String(this.min),this.input.max=String(this.max),this.input.step=String(this.step),this.input.value=String(this.value),this.input.disabled=this.disabled,this.text)this.input.setAttribute("tabindex","-1");else this.input.removeAttribute("tabindex");if(this.input.setAttribute("aria-valuemin",String(this.min)),this.input.setAttribute("aria-valuemax",String(this.max)),this.input.setAttribute("aria-valuenow",String(this.value)),this.figInputNumber=this.querySelector("fig-input-number"),this.figInputNumber){if(this.figInputNumber.setAttribute("placeholder",this.placeholder),this.figInputNumber.setAttribute("min",String(this.min)),this.figInputNumber.setAttribute("max",String(this.max)),this.figInputNumber.setAttribute("transform",String(this.transform)),this.figInputNumber.setAttribute("step",String(this.step)),this.figInputNumber.setAttribute("value",String(this.value)),this.units)this.figInputNumber.setAttribute("units",this.units);else this.figInputNumber.removeAttribute("units");if(this.precision!==null)this.figInputNumber.setAttribute("precision",String(this.precision));else this.figInputNumber.removeAttribute("precision");this.figInputNumber.disabled=this.disabled,this.figInputNumber.toggleAttribute("disabled",this.disabled)}}#I(){if(this.#g(),this.input.removeEventListener("input",this.#K),this.input.addEventListener("input",this.#K),this.input.removeEventListener("change",this.#q),this.input.addEventListener("change",this.#q),this.input.removeEventListener("keydown",this.#W),this.input.addEventListener("keydown",this.#W),this.input.removeEventListener("pointerdown",this.#X),this.input.addEventListener("pointerdown",this.#X),this.input.removeEventListener("pointerup",this.#Y),this.input.addEventListener("pointerup",this.#Y),this.input.removeEventListener("pointercancel",this.#Y),this.input.addEventListener("pointercancel",this.#Y),this.style.setProperty("--default",this.#H(this.default)),this.figInputNumber)this.#y(),this.figInputNumber.removeEventListener("input",this.#N),this.figInputNumber.addEventListener("input",this.#N),this.figInputNumber.removeEventListener("change",this.#G),this.figInputNumber.addEventListener("change",this.#G)}#k(){if(this.#L(),this.color)this.style.setProperty("--color",this.color);let _=L("input",{type:"range",tabindex:this.text?"-1":null,disabled:this.disabled,min:this.min,max:this.max,step:this.step,className:this.type,value:this.value,"aria-valuemin":this.min,"aria-valuemax":this.max,"aria-valuenow":this.value}),Z=L("div",{className:"fig-slider-input-container",role:"group"},_);for(let J of this.initialChildren??[])Z.appendChild(J);let $=[Z];if(this.text)$.push(L("fig-input-number",{placeholder:this.placeholder,min:this.min,max:this.max,transform:this.transform,step:this.step,value:this.value,units:this.units||null,precision:this.precision,disabled:this.disabled}));if(this.replaceChildren(...$),this.input=_,this.inputContainer=Z,this.figInputNumber=this.querySelector("fig-input-number"),this.#I(),this.datalist=this.querySelector("datalist"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||g()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("data-generated","slider-stepper"),this.datalist.setAttribute("id",g());let J=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1));for(let Q=0;Q<J;Q++){let j=document.createElement("option");j.setAttribute("value",this.min+Q*this.step),this.datalist.append(j)}this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.type==="delta"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("data-generated","slider-delta"),this.datalist.setAttribute("id",g());let J=document.createElement("option");J.setAttribute("value",this.default),this.datalist.append(J),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.#D())this.#c();this.#a(),this.#V()}connectedCallback(){if(this.initialChildren===null)this.initialChildren=Array.from(this.childNodes);if(this.#O()){this.#T(),this.#I(),this.#V();return}this.#k()}get value(){if(this.#$!=="")return this.#$;let _=this.getAttribute("value");if(_!==null)return String(this.#S(_));return""}set value(_){let Z=_===null||_===void 0?"":String(_),J=this.min!==void 0||this.max!==void 0?String(this.#S(Z)):Z;if(this.#$=J,this.getAttribute("value")!==J)this.#J=!0,this.setAttribute("value",J),this.#J=!1;if(this.input&&this.input.value!==J)this.input.value=J,this.input.setAttribute("aria-valuenow",J);if(this.figInputNumber)this.figInputNumber.setAttribute("value",J);if(this.input)this.#w()}get defaultValue(){return this.#P()}disconnectedCallback(){if(this.#_=!1,this.input)this.input.removeEventListener("input",this.#K),this.input.removeEventListener("change",this.#q),this.input.removeEventListener("keydown",this.#W),this.input.removeEventListener("pointerdown",this.#X),this.input.removeEventListener("pointerup",this.#Y),this.input.removeEventListener("pointercancel",this.#Y);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#N),this.figInputNumber.removeEventListener("change",this.#G)}#F(){if(this.figInputNumber){let _=this.figInputNumber.value,Z=this.#S(_);this.value=Z,this.input.value=String(Z),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#H(_){let{min:Z,max:$}=this.#z(),J=$-Z;if(J===0)return 0;return(Number(_)-Z)/J}#A(_){if(_===null||_===void 0)return null;if(typeof _==="string"&&_.trim()==="")return null;let Z=Number(_);return Number.isFinite(Z)?Z:null}#z(){let _=this.#A(this.min),Z=this.#A(this.max);if(_===null)_=0;if(Z===null)Z=_;if(_>Z)[_,Z]=[Z,_];return{min:_,max:Z}}#C(_){let{min:Z,max:$}=this.#z();return Math.min($,Math.max(Z,_))}#E(_){let{min:Z}=this.#z(),$=this.#A(this.step);if(!($>0))return!0;let J=(_-Z)/$,Q=Math.round(J),j=Number.EPSILON*Math.max(1,Math.abs(J))*16;return Math.abs(J-Q)<=j}#f(){return["range","hue","opacity"].includes(this.type)}#D(){if(!this.hasAttribute("default")||!this.#f())return!1;let{min:_,max:Z}=this.#z(),$=this.#A(this.getAttribute("default"));return $!==null&&$>=_&&$<=Z&&this.#E($)}#P(_=this.getAttribute("default")){let{min:Z,max:$}=this.#z(),J=this.#A(_);if(J!==null&&J>=Z&&J<=$&&(this.type!=="stepper"||this.#E(J)))return J;return this.type==="delta"?Math.min($,Math.max(Z,0)):Z}#x(){if(this.type==="delta"){let Z=this.#A(this.default);if(Z!==null)return this.#C(Z);return this.#C(0)}if(this.type==="range"){let{min:Z,max:$}=this.#z();return this.#C(Z+($-Z)/2)}let{min:_}=this.#z();return _}#S(_){let Z=this.#A(_);if(Z===null)return this.#x();return this.#C(Z)}#w(){let _=this.#H(this.value),Z=this.#H(this.default),$=_<Z?-1:1,J=_===Z?1:0;if(this.#R!==_)this.style.setProperty("--slider-complete",_),this.#R=_;if(this.#U!==Z)this.style.setProperty("--default",Z),this.#U=Z;if(this.#B!==$)this.style.setProperty("--slider-delta-direction",$),this.#B=$;if(this.#M!==J)this.style.setProperty("--unchanged",J),this.#M=J}#V(){let _=this.input.value;if(this.value=_,this.#w(),this.input.setAttribute("aria-valuenow",_),this.figInputNumber)this.figInputNumber.setAttribute("value",_)}#g(){if(!this.input)return;if(this.text){this.input.setAttribute("aria-hidden","true"),["aria-label","aria-labelledby","aria-describedby","aria-valuetext"].forEach((_)=>this.input.removeAttribute(_)),this.#y();return}this.input.removeAttribute("aria-hidden"),this.#Q.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.input.removeAttribute(_);else this.input.setAttribute(_,Z)})}#y(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.figInputNumber.removeAttribute(_);else this.figInputNumber.setAttribute(_,Z)})}#m(){this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#b(){this.#Z=!1,this.#V(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#h(_){if(this.disabled||!_.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(_.key))return;_.preventDefault();let Z=_.key==="ArrowRight"||_.key==="ArrowUp"?1:-1,$=this.#A(this.input.value)??this.#x(),J=this.#A(this.step)??1,Q=this.#S($+J*10*Z);this.value=Q,this.input.value=String(Q),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#v(){if(this.figInputNumber){let _=this.figInputNumber.value,Z=this.#S(_);this.value=Z,this.input.value=String(Z),this.#V(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}#s(_,Z){if(!this.input)return;let $=this.#j[this.type]||this.#j.range,J=Z===null||String(Z).trim()===""?$[_]:Number(Z),Q=Number.isFinite(J)?J:$[_];if(_==="step"&&!(Q>0))Q=$.step>0?$.step:1;if(this[_]===Q&&this.input[_]===String(Q))return;if(this[_]=Q,this.input[_]=String(Q),_==="min")this.input.setAttribute("aria-valuemin",String(Q));else if(_==="max")this.input.setAttribute("aria-valuemax",String(Q));if(this.figInputNumber)this.figInputNumber.setAttribute(_,String(Q));if(!this.hasAttribute("default")&&this.type!=="delta")this.default=this.min;else this.default=this.#P();this.value=this.#S(this.value),this.#w(),this.#r(),this.#a()}#r(){if(this.type!=="stepper"||!this.datalist)return;let _=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1)),Z=document.createDocumentFragment();for(let $=0;$<_;$++){let J=document.createElement("option");J.setAttribute("value",this.min+$*this.step),Z.append(J)}this.datalist.replaceChildren(Z),this.input.setAttribute("list",this.datalist.id),this.#a()}#a(){let _=this.datalist?.getAttribute("data-generated")==="slider-default",Z=this.#D();if(_&&!Z)this.datalist.remove(),this.datalist=null,this.input?.removeAttribute("list");else if(!this.datalist&&Z)this.#c();if(!this.datalist)return;let $=String(this.default);if(_){let j=this.datalist.querySelector("option")??document.createElement("option");j.value=$,this.datalist.replaceChildren(j)}let J=[...this.datalist.querySelectorAll("option")];J.forEach((j)=>j.removeAttribute("default"));let Q=J.find((j)=>j.value===$);if(!Q&&this.type==="delta"&&this.datalist.getAttribute("data-generated")==="slider-delta")Q=document.createElement("option"),Q.value=$,this.datalist.replaceChildren(Q);Q?.setAttribute("default","true")}#c(){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("data-generated","slider-default"),this.datalist.setAttribute("id",g());let _=document.createElement("option");_.value=String(this.default),this.datalist.append(_),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.id)}#o(){if(this.#Z){this.#_=!0;return}this.#_=!1,this.#k()}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"]}focus(){if(this.text&&this.figInputNumber){this.figInputNumber.focus();return}this.input.focus()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="value"&&this.#J)return;if(this.input)switch(_){case"color":this.color=$,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=$!==null&&$!=="false",this.figInputNumber)this.figInputNumber.toggleAttribute("disabled",this.disabled);break;case"value":if(this.#Z)break;this.value=$,this.#V();break;case"transform":if(this.transform=Number($)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=$!==null?Number($):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=$!==null?$:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=this.#P($),this.#w(),this.#a();break;case"min":case"max":case"step":this.#s(_,$);break;case"units":if(this.units=$||"",this.figInputNumber)if(this.units)this.figInputNumber.setAttribute("units",this.units);else this.figInputNumber.removeAttribute("units");break;case"type":case"variant":if(!this.#Z)this[_]=$;this.#o();break;case"text":if(!this.#Z)this.text=$!=="false";this.#o();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#g();break;default:this[_]=this.input[_]=$,this.#V();break}}}A("fig-slider",Y_);class W_ extends HTMLElement{#Z=!1;#_=!1;#J="";#$=!1;#Q;#j;#K;#q;#N;#G;#W;#X;#Y=null;#R=0;#U="";#B="";#M=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#Q=this.#x.bind(this),this.#j=this.#w.bind(this),this.#K=this.#w.bind(this),this.#q=this.#S.bind(this),this.#N=(_)=>{_.stopPropagation(),this.#P(_)},this.#G=(_)=>{_.stopPropagation();let Z=_.target.value;if(this.type==="number")Z=Number(Z)/(this.transform||1);this.value=Z,this.#z(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))},this.#W=()=>{if(!this.disabled)this.focus()},this.#X=this.#O.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")&&this.getAttribute("multiline")!=="false",this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}if(this.input=this.#L(),this.input.readOnly=this.readonly,this.disabled=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.input.disabled=this.disabled,this.#F(),this.#H(),this.#A(),this.#z(),this.#C(),this.#f(),W0(this),this.#T(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#D(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#D(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#D(this.step));this.addEventListener("pointerdown",this.#q)}this.removeEventListener("click",this.#X),this.addEventListener("click",this.#X),this.input.removeEventListener("change",this.#N),this.input.addEventListener("change",this.#N),this.input.removeEventListener("input",this.#G),this.input.addEventListener("input",this.#G)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#N),this.input.removeEventListener("input",this.#G);if(this.removeEventListener("click",this.#X),this.removeEventListener("pointerdown",this.#q),window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#j),window.removeEventListener("blur",this.#K),this.#Y?.disconnect(),this.#Y=null,this.#R)cancelAnimationFrame(this.#R),this.#R=0}focus(){this.input.focus()}#L(){let _=this.multiline,Z=this.querySelector("input,textarea");if(Z){if(_?Z.tagName==="TEXTAREA":Z.tagName==="INPUT")return Z;Z.remove()}let $;if(_)$=document.createElement("textarea"),$.value=this.value;else $=document.createElement("input"),$.type=this.type,$.value=this.type==="number"?this.#D(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"]')),$}#O(_){let Z=_.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;if(this.disabled)return;this.focus()}#T(){this.#Y?.disconnect(),this.#Y=new MutationObserver(()=>this.#I()),this.#Y.observe(this,{childList:!0,characterData:!0,subtree:!0})}#I(){if(this.#R)return;this.#R=requestAnimationFrame(()=>{if(this.#R=0,!this.isConnected)return;this.#k()})}#k(){if(!this.input||!this.contains(this.input))this.input=this.#L(),this.input.readOnly=this.readonly,this.input.addEventListener("change",this.#N),this.input.addEventListener("input",this.#G);this.#F(),this.#H(),this.#A(),this.#z(),this.#C(),this.#f(),W0(this)}#F(){if(!this.input)return;this.#M.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.input.removeAttribute(_);else this.input.setAttribute(_,Z)})}#H(){let _=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){_?.remove();return}if(this.querySelector('[slot="prepend"]:not([data-generated])')){_?.remove();return}if(_){let J=_.querySelector("fig-icon");if(J&&J.getAttribute("name")!=="search")J.setAttribute("name","search");J?.removeAttribute("color");return}let $=h("search");$.setAttribute("slot","prepend"),$.setAttribute("data-generated","search-prefix"),$.addEventListener("click",this.#W),this.prepend($)}#A(){let _=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){_?.remove();return}if(this.querySelector('[slot="append"]:not([data-generated])')){_?.remove();return}if(_){let q=_.querySelector("fig-icon");if(q&&q.getAttribute("name")!=="close")q.setAttribute("name","close");return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","search-clear");let J=document.createElement("fig-tooltip");J.setAttribute("text","Clear search");let Q=document.createElement("fig-button");Q.setAttribute("variant","ghost"),Q.setAttribute("icon",""),Q.setAttribute("aria-label","Clear search");let j=h("close",{size:"small"});j.setAttribute("color","var(--figma-color-icon-secondary)"),Q.append(j),J.append(Q),$.append(J),this.append($),Q.addEventListener("click",(q)=>{if(q.preventDefault(),q.stopPropagation(),this.disabled)return;if(!this.input||this.input.value===""){this.focus();return}this.value="",this.input.value="",this.dispatchEvent(new CustomEvent("input",{detail:"",bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:"",bubbles:!0})),this.#z(),this.focus()})}#z(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#C(){let _=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){_?.remove(),this.#_=!1;return}if(this.querySelector('[slot="append"]:not([data-generated])')){_?.remove();return}if(_){this.#E(_);return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","password-toggle");let J=document.createElement("fig-tooltip"),Q=document.createElement("fig-button");Q.setAttribute("variant","ghost"),Q.setAttribute("icon","");let j=h("visible",{size:"small"});j.setAttribute("color","var(--figma-color-icon-secondary)"),Q.append(j),J.append(Q),$.append(J),this.append($),this.#E($),Q.addEventListener("click",(q)=>{if(q.preventDefault(),q.stopPropagation(),this.disabled)return;if(this.#_=!this.#_,this.input)this.input.type=this.#_?"text":"password";this.#E($),this.focus()})}#E(_){let Z=_.querySelector("fig-tooltip"),$=_.querySelector("fig-button"),J=_.querySelector("fig-icon"),Q=this.#_?"Hide password":"Show password";Z?.setAttribute("text",Q),$?.setAttribute("aria-label",Q),J?.setAttribute("name",this.#_?"visible":"hidden")}#f(){this.querySelectorAll('[data-generated="search-clear"] fig-button, [data-generated="password-toggle"] fig-button').forEach((_)=>{if(this.disabled)_.setAttribute("disabled","");else _.removeAttribute("disabled")})}#D(_){if(_==="")return"";let Z=Number(_)*(this.transform||1);return Z=this.#g(Z),Z}#P(_){_.stopPropagation();let Z=_.target.value,$=Z;if(this.type==="number")Z=Z/(this.transform||1),Z=this.#V(Z,!1),$=Z*(this.transform||1);this.value=Z,this.input.value=$,this.#z(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#x(_){if(this.type!=="number")return;if(_.buttons===0){this.#w();return}let Z=(this.step||1)*_.movementX,$=Number(this.input.value);$=$/(this.transform||1)+Z,$=this.#V($,!1);let J=$*(this.transform||1);$=this.#g($),J=this.#g(J),this.value=$,this.input.value=J,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#S(_){if(this.type!=="number")return;if(_.altKey||_.target.closest("[slot]"))this.#Z=!0,this.#U=this.style.userSelect,this.#B=document.body.style.cursor,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Q),window.addEventListener("pointerup",this.#j),window.addEventListener("pointercancel",this.#j),window.addEventListener("blur",this.#K)}#w(_){if(this.type!=="number")return;let Z=this.#Z;if(this.#Z=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#B,this.style.userSelect=this.#U,window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#j),window.removeEventListener("pointercancel",this.#j),window.removeEventListener("blur",this.#K),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#V(_,Z=!0){let $=_;if(this.type==="number"){if($=Number($),typeof this.min==="number")$=Math.max(Z?this.#D(this.min):this.min,$);if(typeof this.max==="number")$=Math.min(Z?this.#D(this.max):this.max,$);$=this.#g($)}return $}#g(_,Z=2){let $=Math.round(_*100)/100;return Number.isInteger($)?$:$.toFixed(Z)}get value(){return this.#J}set value(_){let Z=_??"";this.#J=Z;let $=String(Z);if(this.getAttribute("value")!==$)this.#$=!0,this.setAttribute("value",$),this.#$=!1;this.#y(Z)}#y(_){if(!this.input||this.#Z)return;let Z=this.type==="number"?String(this.#D(_)):String(_??"");if(this.input.value!==Z)this.input.value=Z;this.#z()}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","multiline","step","min","max","transform","name","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(_,Z,$){if(this.input)switch(_){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false",this.#f();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.#D(this.value);break;case"value":if(this.#Z)break;let J=$;if(this.type==="number")J=this.#V(J,!1);if(this.#J=J??"",!this.#$)this.#y(this.#J);break;case"min":case"max":case"step":if($===null||$==="")this[_]=void 0,this.input.removeAttribute(_);else this[_]=this.input[_]=Number($),this.input.setAttribute(_,$);break;case"name":if(this[_]=this.input[_]=$||"",$)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=$??"",this.input.placeholder=this.placeholder;break;case"type":if(this.type=$||"text",this.input.type=this.type,this.removeEventListener("pointerdown",this.#q),this.type==="number")this.step=this.hasAttribute("step")?Number(this.getAttribute("step")):void 0,this.min=this.hasAttribute("min")?Number(this.getAttribute("min")):void 0,this.max=this.hasAttribute("max")?Number(this.getAttribute("max")):void 0,this.transform=Number(this.getAttribute("transform")||1),this.addEventListener("pointerdown",this.#q);this.#H(),this.#A(),this.#z(),this.#C(),this.#f();break;case"multiline":{let Q=$!==null&&$!=="false";if(Q!==this.multiline){this.multiline=Q;let j=this.input;j.removeEventListener("change",this.#N),j.removeEventListener("input",this.#G),j.remove(),this.input=this.#L(),this.input.readOnly=this.readonly,this.input.disabled=Boolean(this.disabled),this.input.addEventListener("change",this.#N),this.input.addEventListener("input",this.#G),this.#F()}break}case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#F();break;default:this[_]=this.input[_]=$;break}}}A("fig-input-text",W_);class n extends HTMLElement{#Z;#_;#J;#$;#Q;#j;#K;#q;#N;#G;#W;#X;#Y;#R;#U;#B;#M=!1;#L=null;#O=null;#T=0;#I=0;#k=!1;#F;#H;#A=null;#z=0;#C="";#E="";#f=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#D="px";static#P=350;static#x=60;#S(_){return(_||"").split(",").map((Z)=>Z.trim().toLowerCase()).filter(Boolean)}#w(_){let Z=(_||"").trim();if(!Z)return"";return(this.#R??[]).includes(Z.toLowerCase())?"":Z}#V(){this.#X=this.#w(this.#Y)}#g(_){if(_&&!this.#L)this.#L=document.createElement("span"),this.#L.className="fig-steppers",this.#L.append(L("button",{className:"fig-stepper-up",tabindex:"-1","aria-label":"Increase"}),L("button",{className:"fig-stepper-down",tabindex:"-1","aria-label":"Decrease"})),this.#L.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.#m(Z,J),this.input.focus()}),this.append(this.#L);else if(!_&&this.#L)this.#h(),this.#L.remove(),this.#L=null;this.#y()}#y(){if(!this.#L)return;let _=this.#L.querySelector(".fig-stepper-up"),Z=this.#L.querySelector(".fig-stepper-down");if(!_||!Z)return;let $=this.input?this.#d(this.input.value):this.value,J=$!==""&&$!==null&&$!==void 0?Number($)/(this.transform||1):Number(this.value),Q=Number.isFinite(J),j=Boolean(this.disabled),q=Q&&typeof this.min==="number"&&J<=this.min,N=Q&&typeof this.max==="number"&&J>=this.max;_.disabled=j||N,Z.disabled=j||q}#m(_,Z){if(this.#h(),this.#O=_.pointerId,this.#k=this.#v(Z),window.addEventListener("pointerup",this.#F),window.addEventListener("pointercancel",this.#F),window.addEventListener("blur",this.#H),!this.#k)return;this.#T=window.setTimeout(()=>{this.#T=0,this.#I=window.setInterval(()=>{let $=this.#v(Z);if(this.#k||=$,!$)this.#b()},n.#x)},n.#P)}#b(){if(this.#T)clearTimeout(this.#T),this.#T=0;if(this.#I)clearInterval(this.#I),this.#I=0}#h(_=!0){if(this.#b(),window.removeEventListener("pointerup",this.#F),window.removeEventListener("pointercancel",this.#F),window.removeEventListener("blur",this.#H),this.#O=null,_&&this.#k)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}));this.#k=!1}#v(_){if(this.disabled)return!1;let Z=this.step||1,$=this.value,J=this.#d(this.input.value),Q=(J!==""?Number(J)/(this.transform||1):0)+Z*_;if(Q=this.#t(Q,!1),Q===$)return!1;return this.value=Q,this.input.value=this.#u(this.value),this.#y(),this.#p(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),!0}constructor(){super();this.#Z=this.#N0.bind(this),this.#_=this.#j0.bind(this),this.#J=this.#j0.bind(this),this.#$=this.#G0.bind(this),this.#Q=(_)=>{_.stopPropagation(),this.#q0(_)},this.#j=(_)=>{_.stopPropagation(),this.#K0(_)},this.#K=(_)=>{this.#_0(_)},this.#q=(_)=>{this.#Z0(_)},this.#N=(_)=>{this.#n(_)},this.#F=(_)=>{if(this.#O!==null&&_.pointerId!==this.#O)return;this.#h()},this.#H=()=>this.#h(),this.#G=this.focus.bind(this),this.#W=this.#r.bind(this)}connectedCallback(){let _=this.getAttribute("value");this.value=_!==null&&_!==""?Number(_):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#Y=this.getAttribute("units")||"";let Z=this.getAttribute("units-disallow");if(this.#R=this.#S(Z===null?n.#D:Z),this.#V(),this.#U=this.getAttribute("unit-position")||"suffix",this.#B=this.#X0(this.hasAttribute("precision")?this.getAttribute("precision"):null),this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));this.transform=Number(this.getAttribute("transform")||1);let $=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.input=this.#s(),this.#i(),this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.#g($),this.hasAttribute("disabled")){let J=this.getAttribute("disabled");this.disabled=this.input.disabled=J!=="false"}this.#y(),this.#p(),W0(this),this.addEventListener("pointerdown",this.#$),this.removeEventListener("click",this.#W),this.addEventListener("click",this.#W),this.#a(),this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.input.removeEventListener("input",this.#j),this.input.addEventListener("input",this.#j),this.input.removeEventListener("focus",this.#K),this.input.addEventListener("focus",this.#K),this.input.removeEventListener("blur",this.#q),this.input.addEventListener("blur",this.#q),this.input.removeEventListener("keydown",this.#N),this.input.addEventListener("keydown",this.#N)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#Q),this.input.removeEventListener("input",this.#j),this.input.removeEventListener("focus",this.#K),this.input.removeEventListener("blur",this.#q),this.input.removeEventListener("keydown",this.#N);if(this.removeEventListener("click",this.#W),this.removeEventListener("pointerdown",this.#$),window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#_),window.removeEventListener("blur",this.#J),this.#h(!1),this.#A?.disconnect(),this.#A=null,this.#z)cancelAnimationFrame(this.#z),this.#z=0}focus(){this.input.focus()}#s(){let _=this.querySelector("input");if(_)return _;let Z=document.createElement("input");if(Z.type="text",Z.inputMode="decimal",Z.setAttribute("data-generated","input-control"),this.name)Z.name=this.name;return Z.placeholder=this.placeholder,Z.value=this.#u(this.value),this.insertBefore(Z,this.querySelector('[slot="append"]')),Z}#r(_){let Z=_.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;this.focus()}#a(){this.#A?.disconnect(),this.#A=new MutationObserver(()=>this.#c()),this.#A.observe(this,{childList:!0,characterData:!0,subtree:!0})}#c(){if(this.#z)return;this.#z=requestAnimationFrame(()=>{if(this.#z=0,!this.isConnected)return;this.#o()})}#o(){if(!this.input||!this.contains(this.input))this.input=this.#s(),this.input.addEventListener("change",this.#Q),this.input.addEventListener("input",this.#j),this.input.addEventListener("focus",this.#K),this.input.addEventListener("blur",this.#q),this.input.addEventListener("keydown",this.#N);let _=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.#L&&!this.contains(this.#L))this.#L=null;this.#g(_),this.#i(),this.#p(),W0(this)}#i(){if(!this.input)return;this.#f.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.input.removeAttribute(_);else this.input.setAttribute(_,Z)})}#p(){if(!this.input)return;if(this.input.setAttribute("role","spinbutton"),typeof this.min==="number")this.input.setAttribute("aria-valuemin",String(this.min));else this.input.removeAttribute("aria-valuemin");if(typeof this.max==="number")this.input.setAttribute("aria-valuemax",String(this.max));else this.input.removeAttribute("aria-valuemax");let _=this.value===""?null:Number(this.value);if(Number.isFinite(_))this.input.setAttribute("aria-valuenow",String(_)),this.input.setAttribute("aria-valuetext",this.#u(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#d(_){if(!_)return"";if(!this.#X){let J=_.replace(/[^\d.-]/g,""),Q=J.split(".");if(Q.length>2)J=Q[0]+"."+Q.slice(1).join("");return J}let Z=_.replace(this.#X,"").trim();Z=Z.replace(/[^\d.-]/g,"");let $=Z.split(".");if($.length>2)Z=$[0]+"."+$.slice(1).join("");return Z}#u(_){if(_===""||_===null||_===void 0)return"";let Z=Number(_)*(this.transform||1);if(isNaN(Z))return"";if(Z=this.#l(Z),!this.#X)return Z.toString();if(this.#U==="prefix")return this.#X+Z;else return Z+this.#X}#e(_){if(_===""||_===null||_===void 0)return"";let Z=Number(_)*(this.transform||1);return Z=this.#l(Z),Z.toString()}#_0(_){this.#M=!0,setTimeout(()=>{let Z=_.target.value;if(Z&&this.#X)if(this.#U==="prefix")_.target.setSelectionRange(this.#X.length,Z.length);else{let $=Z.indexOf(this.#X);if($>-1)_.target.setSelectionRange(0,$)}},0)}#Z0(_){this.#M=!1;let Z=this.#d(_.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#t($,!1),this.value=$,_.target.value=this.#u(this.value)}else this.value="",_.target.value="";this.#y(),this.#p()}#n(_){if(this.disabled)return;if(_.key!=="ArrowUp"&&_.key!=="ArrowDown")return;_.preventDefault();let Z=this.step||1,$=_.shiftKey?10:1,J=Z*$*(_.key==="ArrowUp"?1:-1),Q=this.#d(this.input.value),j=(Q!==""?Number(Q)/(this.transform||1):0)+J;j=this.#t(j,!1),this.value=j,this.input.value=this.#u(this.value),this.#y(),this.#p(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#K0(_){let Z=this.#d(_.target.value);if(Z!=="")this.value=Number(Z)/(this.transform||1);else this.value="";this.#y(),this.#p(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#q0(_){_.stopPropagation();let Z=this.#d(_.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#t($,!1),this.value=$,_.target.value=this.#u(this.value)}else this.value="",_.target.value="";this.#y(),this.#p(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#N0(_){if(this.disabled)return;if(_.buttons===0){this.#j0();return}let Z=(this.step||1)*_.movementX,$=this.#d(this.input.value),J=Number($)/(this.transform||1)+Z;J=this.#t(J,!1),this.value=J,this.input.value=this.#u(this.value),this.#y(),this.#p(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#G0(_){if(this.disabled)return;if(_.altKey||_.target.closest("[slot]"))this.#M=!0,this.#C=this.style.userSelect,this.#E=document.body.style.cursor,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Z),window.addEventListener("pointerup",this.#_),window.addEventListener("pointercancel",this.#_),window.addEventListener("blur",this.#J)}#j0(_){let Z=this.#M;if(this.#M=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#E,this.style.userSelect=this.#C,window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#_),window.removeEventListener("pointercancel",this.#_),window.removeEventListener("blur",this.#J),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#t(_,Z=!0){let $=Number(_);if(isNaN($))return"";if(typeof this.min==="number")$=Math.max(this.min,$);if(typeof this.max==="number")$=Math.min(this.max,$);return $=this.#W0($),$}#l(_){let Z=this.#B??2,$=this.#W0(_);if(this.#B!==null)return $.toFixed(Z);return Number.isInteger($)?String($):String(parseFloat($.toFixed(Z)))}#W0(_){let Z=this.#B??2,$=Math.pow(10,Z);return Math.round(_*$)/$}#X0(_){if(_===null||_===void 0||_==="")return null;let Z=Number(_);if(!Number.isFinite(Z))return 2;return Math.max(0,Math.min(100,Math.trunc(Z)))}static get observedAttributes(){return["value","placeholder","disabled","step","min","max","transform","name","units","units-disallow","unit-position","steppers","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(_,Z,$){if(this.input)switch(_){case"disabled":if(this.disabled=this.input.disabled=$!==null&&$!=="false",this.disabled)this.#h();this.#y();break;case"units":this.#Y=$||"",this.#V(),this.input.value=this.#u(this.value),this.#p();break;case"units-disallow":this.#R=this.#S($===null?n.#D:$),this.#V(),this.input.value=this.#u(this.value),this.#p();break;case"unit-position":this.#U=$||"suffix",this.input.value=this.#u(this.value),this.#p();break;case"transform":this.transform=Number($)||1,this.input.value=this.#u(this.value),this.#p();break;case"value":if(this.#M)break;let J=$!==null&&$!==""?Number($):"";if(J!=="")J=this.#t(J,!1);this.value=J,this.input.value=this.#u(this.value),this.#y(),this.#p();break;case"min":case"max":case"step":if($===null||$===""){this[_]=void 0,this.#y(),this.#p();break}this[_]=Number($),this.#y(),this.#p();break;case"steppers":{let Q=$!==null&&$!=="false";this.#g(Q);break}case"precision":this.#B=this.#X0($),this.input.value=this.#u(this.value),this.#p();break;case"name":if(this[_]=this.input[_]=$||"",$)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=$??"",this.input.placeholder=this.placeholder;break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#i();break;default:this[_]=this.input[_]=$;break}}}A("fig-input-number",n);class U_ extends HTMLElement{constructor(){super()}connectedCallback(){this.src=this.getAttribute("src"),this.name=this.getAttribute("name"),this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials),this.setSrc(this.src),this.img=this.querySelector("img")}setSrc(_){if(this.src=_,!_){this.querySelector(":scope > img")?.remove(),this.img=null;return}let Z=this.querySelector(":scope > img")||document.createElement("img");if(Z.src=_,Z.alt=this.name||"",!Z.isConnected)this.replaceChildren(Z);this.img=Z}getInitials(_){return _?_.split(" ").map((Z)=>Z[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(_,Z,$){if(this[_]=$,_==="name"){if(this.img)this.img.alt=$||"";this.name=$,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials)}else if(_==="src")this.src=$,this.setSrc(this.src)}}A("fig-avatar",U_);class R_ extends HTMLElement{#Z=!1;#_=null;#J=null;#$=null;#Q=null;#j=null;#K=null;#q=null;constructor(){super();this.#J=this.#X.bind(this),this.#$=this.focus.bind(this),this.#Q=this.#Y.bind(this),this.#j=this.#R.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(!this.isConnected)return;this.#G(),this.#N()})}#N(){if(this.#K||typeof MutationObserver>"u")return;this.#K=new MutationObserver(()=>{this.#G()}),this.#K.observe(this,{childList:!0})}#G(){let _=this.label,Z=this.#_;_?.removeEventListener("click",this.#J),_?.removeEventListener("click",this.#$),_?.removeEventListener("pointerenter",this.#Q),_?.removeEventListener("pointerleave",this.#j),Z?.removeEventListener("click",this.#J),this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((q)=>q.nodeType===Node.ELEMENT_NODE&&q.nodeName.toLowerCase().startsWith("fig-")&&!(q instanceof Element&&q.classList.contains("fig-field-chevron"))),this.#W();let $=this.input?.localName??"",J=this.input?.getAttribute?.("edit"),j=$==="fig-select"||$==="fig-menu"||$==="fig-dropdown"||$==="fig-tooltip"||$==="fig-fill-picker"||$==="fig-input-palette"&&(J==="false"||J==="picker")||this.input instanceof HTMLDialogElement;if(this.#Z=!!(this.input&&("open"in this.input)&&typeof this.input.open!=="function"&&!j),this.#Z&&this.label){if(!this.#_||!this.#_.isConnected)this.#_=h("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#_,this.label);this.#_.addEventListener("click",this.#J),this.label.addEventListener("click",this.#J)}else{if(this.#_)this.#_.removeEventListener("click",this.#J),this.#_.remove(),this.#_=null;if(this.input&&this.label){if(this.input.querySelectorAll("input, select, textarea").length!==1)this.label.addEventListener("click",this.#$)}}if(this.input&&this.label&&!this.#Z)this.#U();if(this.label)this.label.removeEventListener("pointerenter",this.#Q),this.label.addEventListener("pointerenter",this.#Q),this.label.removeEventListener("pointerleave",this.#j),this.label.addEventListener("pointerleave",this.#j)}#W(){if(this.#q?.disconnect(),this.#q=null,this.input?.localName!=="fig-input-palette"||typeof MutationObserver>"u")return;this.#q=new MutationObserver(()=>this.#G()),this.#q.observe(this.input,{attributes:!0,attributeFilter:["edit"]})}disconnectedCallback(){if(this.#K?.disconnect(),this.#K=null,this.#q?.disconnect(),this.#q=null,this.label)k.hide(this.label);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.label&&this.#$)this.label.removeEventListener("click",this.#$);if(this.label&&this.#Q)this.label.removeEventListener("pointerenter",this.#Q);if(this.label&&this.#j)this.label.removeEventListener("pointerleave",this.#j);if(this.#_&&this.#J)this.#_.removeEventListener("click",this.#J)}#X(_){if(_.preventDefault(),_.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;k.show(this.label,this.label.textContent.trim())}#R(){if(this.label)k.hide(this.label)}#U(){if(!this.input||!this.label)return;let _=this.label.getAttribute("id")||g();this.label.setAttribute("id",_);let Z=this.input.querySelectorAll("input, select, textarea");if(Z.length===1){let $=Z[0],J=$.getAttribute("id")||g();if($.setAttribute("id",J),this.label.setAttribute("for",J),this.input.getAttribute("aria-labelledby")===_)this.input.removeAttribute("aria-labelledby");if(!$.hasAttribute("aria-labelledby"))$.setAttribute("aria-labelledby",_);return}if(this.label.removeAttribute("for"),!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-labelledby",_)}attributeChangedCallback(_,Z,$){switch(_){case"label":if(this.label)this.label.textContent=$,this.#U();break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let _=this.input.querySelectorAll("input, select, textarea");if(_.length===1)_[0].focus();else if(this.input.focus(),_.length===0)this.input.click()}}A("fig-field",R_);class L_ extends HTMLElement{rgba;hex;#Z=100;#_;#J;#$;#Q;#j=!1;#K=!1;#q=null;#N=this.#E.bind(this);#G=this.#f.bind(this);#W=this.#D.bind(this);#X=this.#y.bind(this);#Y=this.#x.bind(this);#R=this.#w.bind(this);#U=this.#S.bind(this);#B=this.#m.bind(this);constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(_){if(_===null||_===void 0||_===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(_))}#M(){let _={};for(let{name:Z,value:$}of this.attributes)if(Z.startsWith("picker-")&&Z!=="picker-anchor"&&Z!=="picker-experimental"){let J=Z.slice(7);if(/^on/i.test(J))continue;_[J]=$}if(!_["dialog-position"])_["dialog-position"]="left";return _}#L(){let _=this.#M();return Object.entries(_).map(([Z,$])=>`${Z}="${$}"`).join(" ")}connectedCallback(){if(this.#O()){this.#T();return}this.#F()}disconnectedCallback(){this.#I()}#O(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-swatch")}#T(){if(this.#P(this.getAttribute("value")),this.#_=this.querySelector("fig-swatch"),this.#J=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#Q=this.querySelector("fig-input-number"),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Q)this.#Q.setAttribute("value",String(this.#Z));if(this.#_)this.#_.setAttribute("background",this.hexOpaque),this.#_.setAttribute("alpha",String(this.rgba.a));this.#g(),this.#k()}#I(){if(this.#_)this.#_.removeEventListener("pointerdown",this.#N,{capture:!0}),this.#_.removeEventListener("click",this.#G,{capture:!0}),this.#_.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#W),this.#_.removeEventListener("input",this.#X);this.#$?.removeEventListener("input",this.#Y),this.#$?.removeEventListener("change",this.#R),this.#Q?.removeEventListener("input",this.#U),this.#Q?.removeEventListener("change",this.#R),this.#J?.removeEventListener("input",this.#B),this.#J?.removeEventListener("change",this.#R)}#k(){if(this.#_){this.#_.disabled=z(this,"disabled");let _=this.#_.querySelector('input[type="color"]');if(this.#$||this.hasAttribute("swatch-disabled"))_?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(_?.setAttribute("disabled",""),_)_.style.pointerEvents="none"}this.#_.addEventListener("pointerdown",this.#N,{capture:!0}),this.#_.addEventListener("click",this.#G,{capture:!0}),_?.addEventListener("keydown",this.#W),this.#_.addEventListener("input",this.#X)}if(this.#$)this.#$.addEventListener("input",this.#Y),this.#$.addEventListener("change",this.#R);if(this.#Q)this.#Q.addEventListener("input",this.#U),this.#Q.addEventListener("change",this.#R);if(this.#J)this.#J.addEventListener("input",this.#B),this.#J.addEventListener("change",this.#R)}#F(){this.#P(this.getAttribute("value"));let _=this.getAttribute("alpha")!=="false",Z=this.#s,$=this.getAttribute("text")!=="false",J=L("fig-swatch",{background:this.hexOpaque,alpha:this.rgba.a,disabled:Z});if($){let Q=L("div",{className:"input-combo"},[J,L("fig-input-text",{type:"text",placeholder:"000000",value:this.hexOpaque.slice(1).toUpperCase(),disabled:Z})]);if(_)Q.appendChild(L("fig-tooltip",{text:"Opacity"},L("fig-input-number",{placeholder:"##",min:"0",max:"100",value:this.#Z,units:"%",disabled:Z})));this.replaceChildren(Q)}else this.replaceChildren(J);if(this.#_=J,this.#J=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#Q=this.querySelector("fig-input-number"),this.#g(),this.#$){let Q=this.rgbAlphaToHex(this.rgba,1);if(this.#$.value=Q.slice(1).toUpperCase(),this.#_)this.#_.background=Q}this.#k()}#H(){if(!this.#J)return;for(let[_,Z]of Object.entries(this.#M()))this.#J.setAttribute(_,Z);if(this.#J.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#J.removeAttribute("alpha");else this.#J.setAttribute("alpha","false");if(z(this,"disabled"))this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");this.#J.anchorElement=this,this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}))}#A(){if(!a())return null;if(this.#J?.isConnected)return this.#H(),this.#J;let _=document.createElement("fig-fill-picker");return _.appendChild(L("span",{hidden:!0})),_.addEventListener("input",this.#B),_.addEventListener("change",this.#R),this.appendChild(_),this.#J=_,this.#H(),_}#z(){if(z(this,"disabled")||z(this,"swatch-disabled"))return!1;let _=this.#A();if(!_)return!1;return requestAnimationFrame(()=>_.open?.()),!0}#C(_){_.preventDefault(),_.stopPropagation(),_.stopImmediatePropagation?.()}#E(_){if(!a())return;if(z(this,"disabled")||z(this,"swatch-disabled"))return;if(this.#K=!0,this.#j=!0,this.#q)clearTimeout(this.#q);this.#q=setTimeout(()=>{this.#j=!1,this.#K=!1,this.#q=null},500),this.#C(_)}#f(_){if(!this.#j)return;if(this.#j=!1,this.#q)clearTimeout(this.#q),this.#q=null;if(this.#C(_),this.#K)this.#K=!1,this.#z()}#D(_){if(_.key!=="Enter"&&_.key!==" ")return;if(!a())return;if(!this.#z())return;this.#C(_)}#P(_){let Z=typeof _==="string"&&_.trim()?_.trim():"#D9D9D9",$=this.convertToRGBA(Z);if(!$||!Number.isFinite($.r)||!Number.isFinite($.g)||!Number.isFinite($.b)||!Number.isFinite($.a))Z="#D9D9D9",$={r:217,g:217,b:217,a:1};this.rgba=$,this.value=this.rgbAlphaToHex({r:isNaN(this.rgba.r)?0:this.rgba.r,g:isNaN(this.rgba.g)?0:this.rgba.g,b:isNaN(this.rgba.b)?0:this.rgba.b},this.rgba.a),this.hexWithAlpha=this.value.toUpperCase(),this.hexOpaque=this.hexWithAlpha.slice(0,7),this.#Z=Z.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#x(_){_.stopPropagation();let Z=_.target.value.replace(/#/g,"");if(this.#P("#"+Z),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Q)this.#Q.setAttribute("value",this.#Z);if(this.#_)this.#_.setAttribute("background",this.hexOpaque);this.#b()}#S(_){_.stopPropagation();let Z=Number(_.target.value)||0,J=Math.round(Z/100*255).toString(16).padStart(2,"0");if(this.#P(this.hexOpaque+J),this.#_)this.#_.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));this.#b()}#w(_){_.stopPropagation(),this.#h()}focus(){if(this.#$){this.#$.focus();return}this.#_?.focus()}#V(){return this.getAttribute("aria-label")||"Color"}#g(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#s)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let _=this.getAttribute("aria-describedby"),Z=this.getAttribute("aria-invalid"),$=this.getAttribute("aria-required"),J=this.getAttribute("aria-labelledby"),Q=this.#V();if(this.#$){if(this.#$.setAttribute("aria-label",`${Q} hex color`),_)this.#$.setAttribute("aria-describedby",_);else this.#$.removeAttribute("aria-describedby");if(Z)this.#$.setAttribute("aria-invalid",Z);else this.#$.removeAttribute("aria-invalid");if($)this.#$.setAttribute("aria-required",$);else this.#$.removeAttribute("aria-required")}if(this.#Q){if(this.#Q.setAttribute("aria-label",`${Q} opacity`),_)this.#Q.setAttribute("aria-describedby",_);else this.#Q.removeAttribute("aria-describedby");if(Z)this.#Q.setAttribute("aria-invalid",Z);else this.#Q.removeAttribute("aria-invalid");if($)this.#Q.setAttribute("aria-required",$);else this.#Q.removeAttribute("aria-required")}if(!this.#$){let j=this.#_?.querySelector('input[type="color"]');if(!j)return;if(J)j.setAttribute("aria-labelledby",J),j.removeAttribute("aria-label");else j.setAttribute("aria-label",Q),j.removeAttribute("aria-labelledby");if(_)j.setAttribute("aria-describedby",_);else j.removeAttribute("aria-describedby")}}#y(_){if(_.stopPropagation(),this.#P(_.target.value),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#b()}#m(_){_.stopPropagation();let Z=_.detail;if(Z&&Z.color){let $=Z.color;if(Z.alpha!==void 0){let J=Math.round(Z.alpha*255).toString(16).padStart(2,"0");$=Z.color+J}if(this.#P($),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Q&&Z.alpha!==void 0)this.#Q.setAttribute("value",Math.round(Z.alpha*100));if(this.#_)this.#_.setAttribute("background",this.hexOpaque),this.#_.setAttribute("alpha",this.rgba.a);this.#b()}}#b(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:this.#v()}))}#h(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:this.#v()}))}#v(){return{value:this.value,hex:this.hex,rgba:this.rgba,...t(this.hexOpaque,this.rgba?.a,Math.round((this.rgba?.a??1)*100))}}static get observedAttributes(){return["value","style","mode","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(_){this.setAttribute("mode",_)}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"value":if(this.#P($),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#_)this.#_.setAttribute("background",this.hexOpaque),this.#_.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));if(this.#Q)this.#Q.setAttribute("value",this.#Z);break;case"mode":this.#H();break;case"alpha":case"text":if(this.isConnected)this.#F();break;case"disabled":this.#r();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#g();break}}get#s(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#r(){let _=this.#s;for(let Z of[this.#_,this.#$,this.#Q]){if(!Z)continue;if(_)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}if(this.#g(),this.#J)this.#H()}rgbAlphaToHex({r:_,g:Z,b:$},J=1){_=Math.max(0,Math.min(255,Math.round(_))),Z=Math.max(0,Math.min(255,Math.round(Z))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(1,J));let Q=_.toString(16).padStart(2,"0"),j=Z.toString(16).padStart(2,"0"),q=$.toString(16).padStart(2,"0");if(J===1)return`#${Q}${j}${q}`.toUpperCase();let K=Math.round(J*255).toString(16).padStart(2,"0");return`#${Q}${j}${q}${K}`.toUpperCase()}convertToRGBA(_){if(typeof _!=="string")return null;let Z,$,J,Q=1;if(_.startsWith("#")){let j=_.slice(1);if(j.length===8)Q=parseInt(j.slice(6),16)/255,j=j.slice(0,6);Z=parseInt(j.slice(0,2),16),$=parseInt(j.slice(2,4),16),J=parseInt(j.slice(4,6),16)}else if(_.startsWith("rgba")||_.startsWith("rgb")){let j=_.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(j)Z=parseInt(j[1]),$=parseInt(j[2]),J=parseInt(j[3]),Q=j[4]?parseFloat(j[4]):1}else if(_.startsWith("hsla")||_.startsWith("hsl")){let j=_.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(j){let q=parseInt(j[1])/360,N=parseInt(j[2])/100,K=parseInt(j[3])/100;if(Q=j[4]?parseFloat(j[4]):1,N===0)Z=$=J=K;else{let G=(U,W,O)=>{if(O<0)O+=1;if(O>1)O-=1;if(O<0.16666666666666666)return U+(W-U)*6*O;if(O<0.5)return W;if(O<0.6666666666666666)return U+(W-U)*(0.6666666666666666-O)*6;return U},X=K<0.5?K*(1+N):K+N-K*N,Y=2*K-X;Z=G(Y,X,q+0.3333333333333333),$=G(Y,X,q),J=G(Y,X,q-0.3333333333333333)}Z=Math.round(Z*255),$=Math.round($*255),J=Math.round(J*255)}}else return null;return{r:Z,g:$,b:J,a:Q}}}A("fig-input-color",L_);var G1=["srgb","srgb-linear","display-p3","oklab","oklch","hsl"],X1=["shorter","longer","increasing","decreasing"],O_=new Set(["oklch","hsl"]);function K0(_){let Z={..._??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase();if(!G1.includes($))$="srgb";Z.interpolationSpace=$;let J=String(Z.hueInterpolation??"shorter").toLowerCase();return Z.hueInterpolation=X1.includes(J)?J:"shorter",Z}function M_(_){let Z=K0(_),$={...Z,interpolationSpace:Z.interpolationSpace};if(O_.has(Z.interpolationSpace))$.hueInterpolation=Z.hueInterpolation;else delete $.hueInterpolation;return $}function B_(_){let Z=K0(_);if(Z.interpolationSpace==="srgb")return"";if(O_.has(Z.interpolationSpace))return`in ${Z.interpolationSpace} ${Z.hueInterpolation} hue`;return`in ${Z.interpolationSpace}`}function F0(_){if(!_)return"";return`url("${String(_).replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}")`}function Y1(_){let Z=String(_??"").trim();if(!Z||Z.startsWith("{")||Z.startsWith("#"))return!1;if(Z.startsWith("data:video/"))return!0;try{let $=new URL(Z,"https://fig.local").pathname;return/\.(mp4|webm|mov|m4v|ogv)$/i.test($)}catch{return/\.(mp4|webm|mov|m4v|ogv)(?:[?#]|$)/i.test(Z)}}function $0(_){let Z=_.replace(/^#/,"");return{r:parseInt(Z.substring(0,2),16),g:parseInt(Z.substring(2,4),16),b:parseInt(Z.substring(4,6),16)}}function s(_){let Z=_/255;return Z<=0.04045?Z/12.92:Math.pow((Z+0.055)/1.055,2.4)}function _0(_){let Z=_<=0.0031308?12.92*_:1.055*Math.pow(_,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Z))*255)}function Y0(_,Z,$){let J=s(_),Q=s(Z),j=s($),q=Math.cbrt(0.4122214708*J+0.5363325363*Q+0.0514459929*j),N=Math.cbrt(0.2119034982*J+0.6806995451*Q+0.1073969566*j),K=Math.cbrt(0.0883024619*J+0.2817188376*Q+0.6299787005*j);return{l:0.2104542553*q+0.793617785*N-0.0040720468*K,a:1.9779984951*q-2.428592205*N+0.4505937099*K,b:0.0259040371*q+0.7827717662*N-0.808675766*K}}function b0(_,Z,$){let J=_+0.3963377774*Z+0.2158037573*$,Q=_-0.1055613458*Z-0.0638541728*$,j=_-0.0894841775*Z-1.291485548*$,q=J*J*J,N=Q*Q*Q,K=j*j*j;return{r:_0(4.0767416621*q-3.3077115913*N+0.2309699292*K),g:_0(-1.2684380046*q+2.6097574011*N-0.3413193965*K),b:_0(-0.0041960863*q-0.7034186147*N+1.707614701*K)}}function h0(_,Z,$){return{l:_,c:Math.sqrt(Z*Z+$*$),h:Math.atan2($,Z)*180/Math.PI}}function W1(_,Z,$){let J=$*Math.PI/180;return{l:_,a:Z*Math.cos(J),b:Z*Math.sin(J)}}function v0(_,Z,$,J){let Q=(_%360+360)%360,q=(Z%360+360)%360-Q;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((Q+q*$)%360+360)%360}function U1(_,Z,$,J){let Q=[..._].sort((H,T)=>H.position-T.position),j=Z*100;if(Q.length===0)return"#888888";if(j<=Q[0].position)return Q[0].color;if(j>=Q[Q.length-1].position)return Q[Q.length-1].color;let q=0;while(q<Q.length-1&&Q[q+1].position<j)q++;let N=Q[q],K=Q[q+1],G=K.position-N.position,X=G>0?(j-N.position)/G:0,Y=$0(N.color),U=$0(K.color),W,O,B,F=$||"oklab";if(F==="srgb-linear"){let H=s(Y.r),T=s(Y.g),R=s(Y.b),I=s(U.r),E=s(U.g),V=s(U.b);W=_0(H+(I-H)*X),O=_0(T+(E-T)*X),B=_0(R+(V-R)*X)}else if(F==="oklch"){let H=Y0(Y.r,Y.g,Y.b),T=Y0(U.r,U.g,U.b),R=h0(H.l,H.a,H.b),I=h0(T.l,T.a,T.b),E=R.l+(I.l-R.l)*X,V=R.c+(I.c-R.c)*X,C=v0(R.h,I.h,X,J||"shorter"),w=W1(E,V,C),f=b0(w.l,w.a,w.b);W=f.r,O=f.g,B=f.b}else if(F==="hsl"){let H=g0(Y.r,Y.g,Y.b),T=g0(U.r,U.g,U.b),R=v0(H.h,T.h,X,J||"shorter"),I=H.s+(T.s-H.s)*X,E=H.l+(T.l-H.l)*X,V=R1(R,I,E);W=V[0],O=V[1],B=V[2]}else if(F==="srgb")W=Math.round(Y.r+(U.r-Y.r)*X),O=Math.round(Y.g+(U.g-Y.g)*X),B=Math.round(Y.b+(U.b-Y.b)*X);else{let H=Y0(Y.r,Y.g,Y.b),T=Y0(U.r,U.g,U.b),R=H.l+(T.l-H.l)*X,I=H.a+(T.a-H.a)*X,E=H.b+(T.b-H.b)*X,V=b0(R,I,E);W=V.r,O=V.g,B=V.b}return`#${W.toString(16).padStart(2,"0")}${O.toString(16).padStart(2,"0")}${B.toString(16).padStart(2,"0")}`.toUpperCase()}function g0(_,Z,$){let J=_/255,Q=Z/255,j=$/255,q=Math.max(J,Q,j),N=Math.min(J,Q,j),K=(q+N)/2;if(q===N)return{h:0,s:0,l:K*100};let G=q-N,X=K>0.5?G/(2-q-N):G/(q+N),Y;switch(q){case J:Y=((Q-j)/G+(Q<j?6:0))/6;break;case Q:Y=((j-J)/G+2)/6;break;default:Y=((J-Q)/G+4)/6;break}return{h:Y*360,s:X*100,l:K*100}}function R1(_,Z,$){Z/=100,$/=100;let J=(1-Math.abs(2*$-1))*Z,Q=J*(1-Math.abs(_/60%2-1)),j=$-J/2,q,N,K;if(_<60)q=J,N=Q,K=0;else if(_<120)q=Q,N=J,K=0;else if(_<180)q=0,N=J,K=Q;else if(_<240)q=0,N=Q,K=J;else if(_<300)q=Q,N=0,K=J;else q=J,N=0,K=Q;return[Math.round((q+j)*255),Math.round((N+j)*255),Math.round((K+j)*255)]}class A_ extends HTMLElement{#Z="solid";#_;#J;#$;#Q={color:"#D9D9D9",alpha:1};#j={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",opacity:1,stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#K={url:null,scaleMode:"fill",scale:50,opacity:1};#q={url:null,poster:null,scaleMode:"fill",scale:50,opacity:1,missing:!0};#N={live:!0,snapshot:null,deviceId:null,scaleMode:"fill",scale:50,opacity:1};#G={};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","alpha","webcam-mode","default-video","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#W(),this.#A()}disconnectedCallback(){this.#_=null,this.#J=null,this.#$=null}#W(){let _=this.getAttribute("value");if(!_)return;try{let Z=JSON.parse(_);if(Z.type)this.#Z=Z.type;switch(this.#Z){case"solid":if(Z.color)this.#Q.color=Z.color;if(Z.alpha!==void 0)this.#Q.alpha=Z.alpha;if(Z.opacity!==void 0)this.#Q.alpha=Z.opacity/100;break;case"gradient":if(Z.gradient)this.#j=K0({...this.#j,...Z.gradient}),this.#j.opacity=this.#U(Z.gradient.opacity??Z.opacity??Z.alpha,this.#j.opacity??1);else if(Z.opacity!==void 0||Z.alpha!==void 0)this.#j.opacity=this.#U(Z.opacity??Z.alpha,this.#j.opacity??1);break;case"image":if(Z.image)this.#K={...this.#K,...Z.image};break;case"video":if(Z.video)this.#q={...this.#q,...Z.video},this.#q.missing=!this.#q.url;break;case"webcam":if(Z.webcam&&typeof Z.webcam==="object"){let{stream:$,snapshot:J,...Q}=Z.webcam;if(this.#N={...this.#N,...Q},typeof J==="string"&&J)this.#N.snapshot=J}else if(Z.image?.url){if(this.#N.snapshot=Z.image.url,Z.image.scaleMode)this.#N.scaleMode=Z.image.scaleMode;if(Z.image.scale!=null)this.#N.scale=Z.image.scale}if(Z.opacity!==void 0)this.#N.opacity=Z.opacity;break;default:{let{type:$,...J}=Z;this.#G=J;break}}}catch(Z){if(_.startsWith("#")){if(this.#Z="solid",this.#Q.color=_.slice(0,7),_.length>7){let $=_.slice(7,9);this.#Q.alpha=parseInt($,16)/255}return}if(Y1(_))this.#Z="video",this.#q.url=_.trim(),this.#q.missing=!1}}#X(){let _={},Z=this.getAttribute("mode");if(Z)_.mode=Z;let $=this.getAttribute("alpha");if($)_.alpha=$;for(let{name:j,value:q}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor"&&j!=="picker-experimental"){let N=j.slice(7);if(/^on/i.test(N))continue;_[N]=q}if(!_["dialog-position"])_["dialog-position"]="left";let J=this.getAttribute("webcam-mode");if(J&&!_["webcam-mode"])_["webcam-mode"]=J;let Q=this.getAttribute("default-video");if(Q&&!_["default-video"])_["default-video"]=Q;return _}#Y(){switch(this.#Z){case"solid":return this.#Q.color;case"gradient":{let Z=[...this.#j.stops].sort((Q,j)=>Q.position-j.position).map((Q)=>{let j=(Q.opacity??100)/100;if(j>=1)return`${Q.color} ${Q.position}%`;let{r:q,g:N,b:K}=$0(Q.color);return`rgba(${q}, ${N}, ${K}, ${j}) ${Q.position}%`}).join(", "),$=B_(this.#j),J=$?` ${$}`:"";switch(this.#j.type){case"radial":return`radial-gradient(circle${J}, ${Z})`;case"angular":return`conic-gradient(from ${this.#j.angle}deg${J}, ${Z})`;default:return`linear-gradient(${this.#j.angle}deg${J}, ${Z})`}}case"image":return this.#K.url?F0(this.#K.url):"#D9D9D9";case"video":return this.#q.poster?F0(this.#q.poster):"#D9D9D9";case"webcam":{let _=this.#N.snapshot||this.#_?.value?.webcam?.snapshot;return _?F0(_):""}default:return this.#O()}}#R(){return this.#Y()}#U(_,Z=1){if(_===void 0||_===null||_==="")return Z;let $=Number(_);if(!Number.isFinite($))return Z;if($>1)return Math.max(0,Math.min(1,$/100));return Math.max(0,Math.min(1,$))}#B(){switch(this.#Z){case"solid":return this.#Q.alpha;case"gradient":return this.#j.opacity??1;case"image":return this.#K.opacity??1;case"video":return this.#q.opacity??1;case"webcam":return this.#N.opacity??1;default:return this.#U(this.#G.opacity??this.#G.alpha,1)}}#M(){return this.querySelector(`[slot="mode-${this.#Z}"]`)}#L(){let _=this.#M()?.getAttribute("label");if(_)return _;if(!this.#Z)return"Fill";return this.#Z.charAt(0).toUpperCase()+this.#Z.slice(1)}#O(){return this.#G.swatchBackground||this.#G.background||this.#G.css||this.#M()?.getAttribute("swatch-background")||""}#T(){if(!this.#_)return;for(let _ of[...this.querySelectorAll(":scope > [slot^='mode-']")])this.#_.append(_)}#I(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.setAttribute("aria-disabled",_?"true":"false");for(let Z of[this.#_,this.#J,this.#$]){if(!Z)continue;if(_)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}#k(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#I();let _=this.getAttribute("aria-label")||"Fill",Z=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),Q=(j,q)=>{if(!j)return;if(j.setAttribute("aria-label",q),Z)j.setAttribute("aria-describedby",Z);else j.removeAttribute("aria-describedby");if($)j.setAttribute("aria-invalid",$);else j.removeAttribute("aria-invalid");if(J)j.setAttribute("aria-required",J);else j.removeAttribute("aria-required")};Q(this.#_,`${_} picker`),Q(this.#$,`${_} hex color`),Q(this.#J,`${_} opacity`)}#F(_,Z){if(this.getAttribute("alpha")==="false")return null;return L("fig-tooltip",{text:"Opacity"},L("fig-input-number",{className:"fig-input-fill-opacity",placeholder:"##",min:"0",max:"100",value:_,units:"%",disabled:Z}))}#H(_){let Z=null,$=1;switch(this.#Z){case"solid":return[L("fig-input-text",{type:"text",className:"fig-input-fill-hex",placeholder:"000000",value:this.#Q.color.slice(1).toUpperCase(),disabled:_}),this.#F(Math.round(this.#Q.alpha*100),_)].filter(Boolean);case"gradient":Z=this.#j.type.charAt(0).toUpperCase()+this.#j.type.slice(1),$=this.#j.opacity??1;break;case"image":Z="Image",$=this.#K.opacity??1;break;case"video":Z="Video",$=this.#q.opacity??1;break;case"webcam":Z="Webcam",$=this.#N.opacity??1;break;default:Z=this.#L(),$=this.#U(this.#G.opacity??this.#G.alpha,1);break}return[L("label",{className:"fig-input-fill-label"},Z),this.#F(Math.round($*100),_)].filter(Boolean)}#A(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=JSON.stringify(this.value),$=this.#X(),J=L("fig-swatch",{background:this.#Y(),alpha:this.#B(),disabled:_}),Q=[...this.querySelectorAll("[slot^='mode-']")],j=L("fig-fill-picker",{value:Z,disabled:_,...$},[J,...Q]),q=L("div",{className:"input-combo"},[j,this.#H(_)]);this.replaceChildren(q),this.#z(),queueMicrotask(()=>{this.#T(),this.#D(),this.#C()})}#z(){this.#_=this.querySelector("fig-fill-picker"),this.#J=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let _=this.querySelector(".fig-input-fill-label");if(this.#k(),_&&this.#_)_.addEventListener("click",()=>{let Z=this.#_.querySelector("fig-swatch");if(Z)Z.click()});if(this.#_){let Z=this.getAttribute("picker-anchor");if(!Z||Z==="self")this.#_.anchorElement=this;else{let $=null;try{$=document.querySelector(Z)}catch{}if($)this.#_.anchorElement=$}this.#_.addEventListener("input",($)=>{$.stopPropagation();let J=$.detail;if(!J)return;let Q=J.type,j=Q!==this.#Z;switch(this.#Z=Q,Q){case"solid":this.#Q.color=J.color,this.#Q.alpha=J.alpha;break;case"gradient":if(J.gradient)this.#j=K0({...this.#j,...J.gradient});break;case"image":if(J.image)this.#K=J.image;break;case"video":if(J.video)this.#q={...this.#q,...J.video};break;case"webcam":if(J.webcam){let{stream:q,snapshot:N,...K}=J.webcam;if(this.#N={...this.#N,...K},typeof N==="string"&&N)this.#N.snapshot=N}else if(J.image?.url)this.#N.snapshot=J.image.url;if(!this.#N.snapshot){let q=this.#_?.value?.webcam?.snapshot;if(q)this.#N.snapshot=q}break;default:{let{type:q,colorSpace:N,...K}=J;this.#G=K;break}}if(j)this.#E();else this.#C();this.#D(),this.#x()}),this.#_.addEventListener("change",($)=>{$.stopPropagation(),this.#S()}),this.#_.addEventListener("loaded",($)=>{$.stopPropagation(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,detail:$.detail}))}),this.#_.addEventListener("webcamstream",($)=>{this.dispatchEvent(new CustomEvent("webcamstream",{bubbles:!0,composed:!0,detail:$.detail}))})}if(this.#$)this.#$.addEventListener("input",(Z)=>{Z.stopPropagation();let $="#"+Z.target.value.replace("#","");this.#Q.color=$,this.#f(),this.#x()}),this.#$.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#S()});if(this.#J)this.#J.addEventListener("input",(Z)=>{Z.stopPropagation();let $=parseFloat(Z.target.value),Q=(isNaN($)?100:$)/100;switch(this.#Z){case"solid":this.#Q.alpha=Q;break;case"gradient":this.#j.opacity=Q;break;case"image":this.#K.opacity=Q;break;case"video":this.#q.opacity=Q;break;case"webcam":this.#N.opacity=Q;break;default:this.#G.opacity=Q;break}this.#f(),this.#D(),this.#x()}),this.#J.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#S()})}#C(){switch(this.#Z){case"solid":if(this.#$)this.#$.setAttribute("value",this.#Q.color.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",Math.round(this.#Q.alpha*100));break;case"gradient":{let _=this.querySelector(".fig-input-fill-label");if(_){let Z=this.#j.type.charAt(0).toUpperCase()+this.#j.type.slice(1);_.textContent=Z}if(this.#J)this.#J.setAttribute("value",Math.round((this.#j.opacity??1)*100));break}case"image":if(this.#J)this.#J.setAttribute("value",Math.round((this.#K.opacity??1)*100));break;case"video":if(this.#J)this.#J.setAttribute("value",Math.round((this.#q.opacity??1)*100));break;case"webcam":if(this.#J)this.#J.setAttribute("value",Math.round((this.#N.opacity??1)*100));break;default:{let _=this.querySelector(".fig-input-fill-label");if(_)_.textContent=this.#L();if(this.#J)this.#J.setAttribute("value",Math.round(this.#U(this.#G.opacity??this.#G.alpha,1)*100));break}}}#E(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.querySelector(".input-combo");if(!Z)return;let $=Z.querySelector(".fig-input-fill-label"),J=Z.querySelector(".fig-input-fill-hex"),Q=Z.querySelector(".fig-input-fill-opacity"),j=Z.querySelectorAll("fig-tooltip");$?.remove(),J?.remove(),j.forEach((N)=>N.remove()),Z.append(...this.#H(_)),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.#k(),q&&this.#_)q.addEventListener("click",()=>{let N=this.#_.querySelector("fig-swatch");if(N)N.click()});if(this.#$)this.#$.addEventListener("input",(N)=>{N.stopPropagation();let K="#"+N.target.value.replace("#","");this.#Q.color=K,this.#f(),this.#x()}),this.#$.addEventListener("change",(N)=>{N.stopPropagation(),this.#S()});if(this.#J)this.#J.addEventListener("input",(N)=>{N.stopPropagation();let K=parseFloat(N.target.value),X=(isNaN(K)?100:K)/100;switch(this.#Z){case"solid":this.#Q.alpha=X;break;case"gradient":this.#j.opacity=X;break;case"image":this.#K.opacity=X;break;case"video":this.#q.opacity=X;break;case"webcam":this.#N.opacity=X;break;default:this.#G.opacity=X;break}this.#f(),this.#P(X),this.#x()}),this.#J.addEventListener("change",(N)=>{N.stopPropagation(),this.#S()})}#f(){if(this.#_)this.#_.setAttribute("value",JSON.stringify(this.value));this.#D()}#D(){let _=this.#_?.querySelector("fig-swatch");if(!_)return;let Z=this.#Y();if(this.#Z==="webcam"&&!Z){if((_.getAttribute("background")||"").startsWith("url(")){_.setAttribute("alpha",this.#B());return}}_.setAttribute("background",Z),_.setAttribute("alpha",this.#B())}#P(_){let Z=this.#_?.querySelector("fig-swatch");if(Z)Z.setAttribute("alpha",_)}#x(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#S(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get webcamStream(){return this.#_?.webcamStream??null}releaseWebcam(){this.#_?.releaseWebcam?.()}#w(){let _=this.#q.url??null;return{url:_,poster:this.#q.poster??null,scaleMode:this.#q.scaleMode||"fill",scale:this.#q.scale??50,opacity:this.#q.opacity??1,..._?{}:{missing:!0}}}#V(){return{live:this.#N.live!==!1,snapshot:this.#N.snapshot??this.#_?.value?.webcam?.snapshot??null,deviceId:this.#N.deviceId??null,scaleMode:this.#N.scaleMode||"fill",scale:this.#N.scale??50,opacity:this.#N.opacity??1}}get value(){switch(this.#Z){case"solid":return{type:"solid",colorSpace:"srgb",color:this.#Q.color,alpha:this.#Q.alpha,opacity:Math.round(this.#Q.alpha*100)};case"gradient":return{type:"gradient",colorSpace:"srgb",gradient:M_(this.#j),css:this.#R()};case"image":return{type:"image",colorSpace:"srgb",image:{...this.#K}};case"video":return{type:"video",colorSpace:"srgb",video:this.#w()};case"webcam":return{type:"webcam",colorSpace:"srgb",webcam:this.#V()};default:return{type:this.#Z,...this.#G}}}set value(_){if(typeof _==="string")this.setAttribute("value",_);else this.setAttribute("value",JSON.stringify(_))}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"value":let J=this.#Z;if(this.#W(),this.#_)if(this.#Z!==J)this.#A();else this.#f(),this.#C();break;case"disabled":this.#I();break;case"mode":case"webcam-mode":case"default-video":if(this.#_)if($)this.#_.setAttribute(_,$);else this.#_.removeAttribute(_);break;case"alpha":if(this.isConnected)this.#A();break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#k();break}}}A("fig-input-fill",A_);class F_ extends HTMLElement{#Z=[];#_=[];#J=[];#$=null;#Q=null;#j=null;#K=null;#q=!1;#N=this.#B.bind(this);#G=()=>this.focus();#W=()=>{if(!this.#j)return;if(this.#j.hasAttribute("open")||this.#j.matches?.(":open")||this.#j.matches?.(":popover-open"))return;if(this.open)this.open=!1};static get observedAttributes(){return["value","disabled","min","max","open","fixed","edit"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){let Z=this.open;if(_&&this.#Y!=="false")this.setAttribute("open","");else this.removeAttribute("open");let $=this.open;if(Z!==$)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:$},bubbles:!0}))}get#X(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#Y(){let _=this.getAttribute("edit");if(_==="false")return"false";if(_==="picker")return"picker";return"true"}get#R(){let _=parseInt(this.getAttribute("min"));return isNaN(_)?2:_}get#U(){let _=parseInt(this.getAttribute("max"));return isNaN(_)?8:_}connectedCallback(){if(this.setAttribute("tabindex","-1"),this.removeEventListener("focus",this.#G),this.addEventListener("focus",this.#G),this.removeEventListener("keydown",this.#N),this.addEventListener("keydown",this.#N),this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{if(this.#$=null,!this.isConnected)return;this.#M(),this.#L(),this.#O()})}disconnectedCallback(){if(this.#$)cancelAnimationFrame(this.#$),this.#$=null;this.removeEventListener("keydown",this.#N),this.removeEventListener("focus",this.#G),this.#_=[],this.#J=[],this.#F()}#B(_){if(_.key!=="Enter"&&_.key!==" ")return;if(_.target!==this.querySelector(".palette-colors-inline"))return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Y==="false")return;_.preventDefault(),_.stopPropagation(),this.open=!0}attributeChangedCallback(_,Z,$){if(Z===$||this.#q)return;switch(_){case"value":this.#M(),this.#D(),this.#I();break;case"disabled":this.#P();break;case"min":case"max":case"fixed":this.#L(),this.#I();break;case"open":this.#x(),this.#k();break;case"edit":if(this.#Y==="false"&&this.open)this.open=!1;if(this.#Y!=="picker")this.#F();this.#L(),this.#O();break}}#M(){let _=this.getAttribute("value");if(!_){this.#Z=[];return}let Z=_.trim();try{let $=JSON.parse(Z);if(Array.isArray($)){this.#Z=$.map((J)=>{if(typeof J==="string")return{color:J.slice(0,7),alpha:J.length>7?parseInt(J.slice(7,9),16)/255:1};if(J&&typeof J==="object")return{color:J.color||"#D9D9D9",alpha:J.alpha!==void 0?J.alpha:J.opacity!==void 0?J.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch($){}if(Z.includes(",")){this.#Z=Z.split(",").map(($)=>{let J=$.trim();return{color:J.slice(0,7),alpha:J.length>7?parseInt(J.slice(7,9),16)/255:1}});return}if(Z.startsWith("#")){this.#Z=[{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}];return}this.#Z=[]}get value(){return this.#Z.map((_)=>({..._}))}set value(_){if(typeof _==="string")this.setAttribute("value",_);else this.setAttribute("value",JSON.stringify(_))}#L(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.#Y,$=Z!=="false";this.replaceChildren(),this.#_=[],this.#J=[];let J=document.createElement("div");if(J.className="palette-colors-inline",$){if(J.setAttribute("role","button"),J.setAttribute("tabindex",_?"-1":"+0"),J.setAttribute("aria-expanded",String(this.open)),J.setAttribute("aria-label","Edit palette colors"),Z==="picker")J.setAttribute("aria-haspopup","dialog")}else J.setAttribute("role","img"),J.setAttribute("aria-label","Palette colors");J.addEventListener("blur",()=>{J.style.removeProperty("outline"),J.style.removeProperty("outline-offset")});let Q=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0};if($)J.addEventListener("click",Q);let j=document.createElement("div");if(j.className="palette-colors",this.#Z.forEach((q,N)=>{j.appendChild(this.#H(q,N,_,{inline:!0}))}),J.appendChild(j),this.appendChild(J),this.#x(),Z==="true"){if(!this.#X)this.#C(_,this);let q=document.createElement("div");q.className="palette-colors-expanded",this.#Z.forEach((N,K)=>{if(q.appendChild(this.#H(N,K,_)),!this.#X)q.appendChild(this.#A(K,_))}),this.appendChild(q)}}#O(){if(this.#Y!=="picker"||customElements.get("fig-palette-editor")){this.#k();return}this.#Q??=customElements.whenDefined("fig-palette-editor").then(()=>{if(!this.isConnected||this.#Y!=="picker")return;this.#k()})}#T(){if(this.#j?.isConnected)return this.#j;if(!customElements.get("fig-palette-editor"))return null;let _=document.createElement("dialog",{is:"fig-popup"});_.setAttribute("is","fig-popup"),_.setAttribute("title","Edit palette"),_.setAttribute("position","center left"),_.setAttribute("offset","8 0"),_.setAttribute("viewport-margin","8"),_.setAttribute("popover","manual"),_.className="fig-palette-editor-popup",_.id=g(),_.anchor=this;let Z=document.createElement("fig-palette-editor"),$=L("fig-content",{className:"fig-palette-editor-content"},Z);_.append($);let J=(Q)=>{if(Q.stopPropagation(),!Array.isArray(Q.detail))return;this.#Z=Q.detail.map((j)=>({color:j?.color||"#D9D9D9",alpha:Number.isFinite(Number(j?.alpha))?Math.max(0,Math.min(1,Number(j.alpha))):1})),this.#q=!0,this.setAttribute("value",JSON.stringify(this.#Z)),this.#q=!1,this.#D(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,detail:this.value}))};return Z.addEventListener("input",J),Z.addEventListener("change",J),_.addEventListener("close",this.#W),_.addEventListener("toggle",this.#W),(q0()??document.body).append(_),_.querySelector(":scope > fig-header")?.setAttribute("borderless",""),this.#j=_,this.#K=Z,this.querySelector(".palette-colors-inline")?.setAttribute("aria-controls",_.id),this.#I(),_}#I(){let _=this.#K;if(!_)return;_.setAttribute("value",JSON.stringify(this.#Z)),_.setAttribute("min",String(this.#R)),_.setAttribute("max",String(this.#U)),_.toggleAttribute("fixed",this.#X);let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";_.toggleAttribute("disabled",Z)}#k(){if(!this.isConnected||this.#Y!=="picker")return;if(!customElements.get("fig-palette-editor")){this.#O();return}if(!this.open){if(this.#j)this.#j.open=!1;return}if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.open=!1;return}let Z=this.#T();if(!Z)return;this.#I(),Z.open=!0}#F(){if(!this.#j)return;this.#j.removeEventListener("close",this.#W),this.#j.removeEventListener("toggle",this.#W),this.#j.open=!1,this.#j.remove(),this.querySelector(".palette-colors-inline")?.removeAttribute("aria-controls"),this.#j=null,this.#K=null}#H(_,Z,$,{inline:J=!1}={}){let Q=_.alpha<1?_.color+Math.round(_.alpha*255).toString(16).padStart(2,"0"):_.color,j=document.createElement("fig-input-color");if(j.setAttribute("value",Q),J)j.setAttribute("text","false"),j.setAttribute("alpha","true"),j.setAttribute("swatch-disabled","");else j.setAttribute("text","true"),j.setAttribute("alpha","true"),j.setAttribute("full","");if($)j.setAttribute("disabled","");let q=J?this.#J:this.#_,N=(K)=>{K.stopPropagation();let G=K.currentTarget;this.#Z[Z]={color:G.hexOpaque||this.#Z[Z].color,alpha:G.rgba?G.rgba.a:this.#Z[Z].alpha};let X=q[Z];if(X){let Y=this.#Z[Z],U=Y.alpha<1?Y.color+Math.round(Y.alpha*255).toString(16).padStart(2,"0"):Y.color;X.setAttribute("value",U)}};if(j.addEventListener("input",(K)=>{N(K),this.#w()}),j.addEventListener("change",(K)=>{N(K),this.#V()}),J)this.#_.push(j);else this.#J.push(j);return j}#A(_,Z){let $=document.createElement("fig-button");if($.setAttribute("variant","ghost"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Remove color"),$.className="palette-remove-btn",Z||this.#Z.length<=this.#R)$.setAttribute("disabled","");$.appendChild(h("minus")),$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#z(_)});let J=document.createElement("fig-tooltip");return J.setAttribute("text","Remove color"),J.appendChild($),J}#z(_){if(this.#X)return;if(_<0||_>=this.#Z.length)return;if(this.#Z.length<=this.#R)return;this.#Z.splice(_,1),this.#_=[],this.#J=[],this.#L(),this.#V()}#C(_,Z=this){let $=this.#Z.length>=this.#U,J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Add color"),J.className="palette-add-btn",_||$)J.setAttribute("disabled","");J.appendChild(h("add")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Z.length>=this.#U)return;this.open=!0,this.#E({color:"#D9D9D9",alpha:1})});let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Add color"),Q.appendChild(J),Z.appendChild(Q)}#E(_){if(this.#X)return;this.#Z.push(_);let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#Z.length-1,J=this.#H(_,$,Z,{inline:!0}),Q=this.querySelector(".palette-colors");if(Q)Q.appendChild(J);let j=this.#H(_,$,Z),q=this.querySelector(".palette-colors-expanded");if(q)q.appendChild(j),q.appendChild(this.#A($,Z));if(this.#Z.length>=this.#U){let N=this.querySelector(".palette-add-btn");if(N)N.setAttribute("disabled","")}this.#S(Z),this.#V()}#f(_){let Z=this.#Z[_];if(!Z)return;let $=Z.alpha<1?Z.color+Math.round(Z.alpha*255).toString(16).padStart(2,"0"):Z.color,J=this.#_[_];if(J)J.setAttribute("value",$);let Q=this.#J[_];if(Q)Q.setAttribute("value",$)}#D(){if(this.#_.length!==this.#Z.length){this.#L();return}this.#Z.forEach((_,Z)=>{this.#f(Z)})}#P(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#_,...this.#J].forEach(($)=>{if(_)$.setAttribute("disabled","");else $.removeAttribute("disabled")});let Z=this.querySelector(".palette-add-btn");if(Z)if(_||this.#Z.length>=this.#U)Z.setAttribute("disabled","");else Z.removeAttribute("disabled");if(this.#S(_),this.#x(),this.#I(),_&&this.#Y==="picker"&&this.open)this.open=!1}#x(){let _=this.querySelector(".palette-colors-inline");if(!_)return;let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#Y==="false"){_.removeAttribute("tabindex"),_.removeAttribute("aria-disabled"),_.removeAttribute("aria-expanded"),_.removeAttribute("aria-haspopup");return}if(_.setAttribute("tabindex",Z?"-1":"+0"),_.setAttribute("aria-disabled",String(Z)),_.setAttribute("aria-expanded",String(this.open)),this.#Y==="picker")_.setAttribute("aria-haspopup","dialog");else _.removeAttribute("aria-haspopup")}focus(){if(this.#Y==="false"||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let _=this.querySelector(".palette-colors-inline");if(!_)return;_.style.outline="var(--figma-focus-outline)",_.style.outlineOffset="var(--figma-focus-outline-offset)",_.focus()}#S(_=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let Z=_||this.#Z.length<=this.#R;this.querySelectorAll(".palette-remove-btn").forEach(($)=>{if(Z)$.setAttribute("disabled","");else $.removeAttribute("disabled")})}#w(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#V(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}A("fig-input-palette",F_);class N0 extends HTMLElement{static SHIFT_SNAP=5;#Z;#_;#J=!1;#$=null;#Q=null;#j=null;#K=null;anchorElement=null;#q={type:"linear",angle:90,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode","size"]}get#N(){let _=this.getAttribute("edit");if(_==="false")return"false";if(_==="picker")return"picker";return"true"}get#G(){return this.#N==="true"}get#W(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#X(){if(!this.#_)return null;return this.#_.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#Y(){if(!this.#_)return null;let _=this.#_.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(_)return _;let Z=document.activeElement;if(!(Z instanceof Element)||!this.#_.contains(Z))return null;return Z.closest("fig-handle:not(.fig-input-gradient-ghost)")}#R(_){if(!_||!this.#_)return;this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(Z!==_)Z.deselect()}),_.select(),_.focus()}#U(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#G?"-1":"0")}#B(_){let Z=K0(_);return{...Z,type:["linear","radial","angular"].includes(Z.type)?Z.type:"linear",angle:Number.isFinite(Number(Z.angle))?Number(Z.angle):90,centerX:Number.isFinite(Number(Z.centerX))?Number(Z.centerX):50,centerY:Number.isFinite(Number(Z.centerY))?Number(Z.centerY):50}}connectedCallback(){if(this.#T(),this.#C(),this.#M(),this.removeEventListener("keydown",this.#O),this.addEventListener("keydown",this.#O),this.#G)document.addEventListener("keydown",this.#L)}#M(){if(this.#N!=="picker"||a())return;this.#K??=customElements.whenDefined("fig-fill-picker").then(()=>{if(!this.isConnected||this.#N!=="picker")return;this.#C()})}disconnectedCallback(){if(document.removeEventListener("keydown",this.#L),this.removeEventListener("keydown",this.#O),this.#Q)this.#Q.disconnect(),this.#Q=null;if(this.#j!==null)cancelAnimationFrame(this.#j),this.#j=null;clearTimeout(this.#$),this.removeEventListener("pointerenter",this.#S),this.removeEventListener("pointermove",this.#V),this.removeEventListener("pointerleave",this.#w),this.removeEventListener("click",this.#m),this.removeEventListener("dblclick",this.#y)}#L=(_)=>{let Z=document.activeElement,$=Z instanceof Node&&this.contains(Z),J=this.#_?.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)"),Q=!Z||Z===document.body||Z===document.documentElement;if(!$&&!(J&&Q))return;let j=Z&&(Z.tagName==="INPUT"||Z.tagName==="TEXTAREA"||Z.isContentEditable);if(!this.#_)return;if(_.key==="Tab"&&!j){let X=this.#Y();if(!X)return;_.preventDefault();let Y=[...this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],U=Y.indexOf(X),W=_.shiftKey?(U-1+Y.length)%Y.length:(U+1)%Y.length;X.deselect(),this.#R(Y[W]);return}if((_.key==="ArrowLeft"||_.key==="ArrowRight")&&!j){let X=this.#Y();if(!X)return;let Y=parseInt(X.dataset.stopIndex,10);if(isNaN(Y)||!this.#q.stops[Y])return;_.preventDefault();let U=(_.key==="ArrowRight"?1:-1)*(_.shiftKey?N0.SHIFT_SNAP:1),W=this.#q.stops[Y];W.position=Math.max(0,Math.min(100,W.position+U)),X.setAttribute("value",`${W.position}% 50%`);let O=X.closest("fig-tooltip");if(O)O.text=`${Math.round(W.position)}%`,O.setAttribute("show","true"),O.showPopup(),X.hideColorTip(),clearTimeout(this.#$),this.#$=setTimeout(()=>{O.removeAttribute("show"),X.showColorTip()},600);this.#c(),this.#i(),this.#p();return}if(_.key!=="Delete"&&_.key!=="Backspace")return;if(j)return;if(this.#q.stops.length<=2)return;let q=this.#Y();if(!q)return;let N=parseInt(q.dataset.stopIndex,10);if(isNaN(N)||!this.#q.stops[N])return;_.preventDefault(),this.#q.stops.splice(N,1),this.#v(),this.#c(),this.#i(),this.#p();let K=Math.min(N,this.#q.stops.length-1),G=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[K];this.#R(G)};#O=(_)=>{if(this.#N!=="picker")return;if(_.key!=="Enter"&&_.key!==" ")return;if(_.altKey||_.ctrlKey||_.metaKey)return;if(z(this,"disabled"))return;let Z=this.querySelector("fig-fill-picker");if(!Z||typeof Z.open!=="function")return;_.preventDefault(),Z.open()};#T(){let _=this.getAttribute("value");if(!_)return;try{let Z=JSON.parse(_);if(Z?.type==="gradient"&&Z.gradient){this.#q=this.#B({...this.#q,...Z.gradient});return}if(Z?.gradient)this.#q=this.#B({...this.#q,...Z.gradient})}catch(Z){}}#I(){let _=this.#B(this.#q),$=[..._.stops].sort((j,q)=>j.position-q.position).map((j)=>{let q=(j.opacity??100)/100;if(q>=1)return`${j.color} ${j.position}%`;let{r:N,g:K,b:G}=$0(j.color);return`rgba(${N}, ${K}, ${G}, ${q}) ${j.position}%`}).join(", "),J=B_(_),Q=J?` ${J}`:"";if(this.#N==="picker")switch(_.type){case"radial":return`radial-gradient(circle at ${_.centerX}% ${_.centerY}%${Q}, ${$})`;case"angular":return`conic-gradient(from ${_.angle}deg${Q}, ${$})`;default:return`linear-gradient(${_.angle}deg${Q}, ${$})`}return`linear-gradient(to right${Q}, ${$})`}#k(_){let Z=(_.opacity??100)/100;if(Z>=1)return _.color;let{r:$,g:J,b:Q}=$0(_.color);return`rgba(${$}, ${J}, ${Q}, ${Z})`}#F(){if(!this.#Z)return;let _=this.getAttribute("size");if(_)this.#Z.setAttribute("size",_);else this.#Z.removeAttribute("size")}#H(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";return this.#q.stops.map((Z,$)=>L("fig-tooltip",{action:"manual",text:`${Math.round(Z.position)}%`},L("fig-handle",{drag:!0,"drag-axes":"x","drag-surface":".fig-input-gradient-track",type:"color",tip:this.#W==="tip"?"color":null,color:this.#k(Z),value:`${Z.position}% 50%`,"hit-area":"4","data-stop-index":$,disabled:_})))}#A=null;#z=!1;#C(){this.#Q?.disconnect(),this.#Q=null;let _=z(this,"disabled"),Z=this.#N,$=this.getAttribute("size"),J=L("fig-swatch",{background:this.#I(),size:$||null,disabled:_});if(Z==="picker"&&a()){let q=JSON.stringify(this.value),N=L("fig-fill-picker",{mode:"gradient",value:q,disabled:_},J);this.replaceChildren(N),this.#Z=J,this.#_=null,this.#E(),this.#U();return}let Q=Z==="true"||Z==="picker",j=Q?L("div",{className:"fig-input-gradient-track"},this.#H()):null;if(this.replaceChildren(...j?[J,j]:[J]),this.#Z=J,this.#_=j,Q)this.#D(),this.#o();this.#U()}#E(){let _=this.querySelector("fig-fill-picker");if(!_)return;_.anchorElement=this.anchorElement||this;let Z=($)=>{$.stopPropagation();let J=$.detail;if(!J?.gradient)return;if(this.#q=this.#B({...this.#q,...J.gradient}),this.#N==="picker"&&typeof J.css==="string"&&J.css){this.#Z?.setAttribute("background",J.css),this.#F();return}this.#c()};_.addEventListener("input",($)=>{Z($),this.#i()}),_.addEventListener("change",($)=>{Z($),this.#p()})}#f(_){return U1(this.#q.stops,_,this.#q.interpolationSpace,this.#q.hueInterpolation)}#D(){if(!this.#_||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let _=document.createElement("fig-handle");if(_.classList.add("fig-input-gradient-ghost"),_.setAttribute("type","color"),this.#W==="tip")_.setAttribute("tip","add");_.style.position="absolute",_.style.top="50%",_.style.transform="translate(-50%, -50%)",_.style.pointerEvents="none",_.style.opacity="0",_.style.transition="opacity 0.15s",this.#_.appendChild(_),this.#A=_,this.addEventListener("pointerenter",this.#S),this.addEventListener("pointermove",this.#V),this.addEventListener("pointerleave",this.#w),this.addEventListener("click",this.#m),this.addEventListener("dblclick",this.#y)}#P(){if(!this.#A)return;this.#A.style.opacity="1"}#x(){if(!this.#A)return;this.#A.style.opacity="0"}#S=()=>{if(this.#J)return;this.#P()};#w=()=>{this.#x()};#V=(_)=>{if(this.#J){this.#x();return}if(!this.#A||!this.#_)return;if(_.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#x();return}let Z=this.#_.getBoundingClientRect(),$=Math.max(0,Math.min(1,(_.clientX-Z.left)/Z.width));this.#A.style.left=`${$*100}%`;let J=this.#f($);this.#A.setAttribute("color",J),this.#P()};#g(){let _=this.#q.stops.length;if(_<2)return;for(let Z=0;Z<_;Z++)this.#q.stops[Z].position=Math.round(Z/(_-1)*100);this.#v(),this.#c(),this.#i(),this.#p()}#y=(_)=>{if(!this.#_)return;if(!_.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#g(),this.#_.querySelectorAll("fig-handle[selected]").forEach((Z)=>{Z.removeAttribute("selected")})};#m=(_)=>{if(!this.#_)return;if(this.#J)return;if(this.#z){this.#z=!1;return}if(_.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(_.shiftKey){let q=_.target.closest("fig-handle"),N=parseInt(q?.dataset.stopIndex,10);if(this.#g(),!isNaN(N))this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((K)=>{if(parseInt(K.dataset.stopIndex,10)===N)K.select();else K.deselect()});_.stopPropagation()}return}let Z=this.#_.getBoundingClientRect(),$=Math.max(0,Math.min(1,(_.clientX-Z.left)/Z.width)),J=Math.round($*100),Q=this.#f($);this.#q.stops.push({position:J,color:Q,opacity:100}),this.#q.stops.sort((q,N)=>q.position-N.position);let j=this.#q.stops.findIndex((q)=>q.position===J&&q.color===Q);this.#v(),this.#c(),this.#i(),this.#p(),requestAnimationFrame(()=>{let N=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[j];if(N)this.#R(N)})};#b(){if(this.#j=null,!this.isConnected)return;if(!this.#_)return;let _=this.#q.stops;this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z,$)=>{if($>=_.length)return;Z.removeAttribute("value"),Z.setAttribute("value",`${_[$].position}% 50%`)})}refreshLayout(){this.#b()}#h(){if(this.#j!==null)return;this.#j=requestAnimationFrame(()=>this.#b())}#v(){if(!this.#_)return;let _=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#q.stops;if(_.length!==Z.length){let $=this.#A;if(this.#_.replaceChildren(...this.#H()),$)this.#_.appendChild($);this.#s(),this.#r(),this.#h();return}for(let $=0;$<Z.length;$++){let J=_[$],Q=Z[$];if(J.dataset.stopIndex=$,J.setAttribute("value",`${Q.position}% 50%`),J.setAttribute("color",this.#k(Q)),this.#W==="tip")J.setAttribute("tip","color");else J.removeAttribute("tip");let j=J.closest("fig-tooltip");if(j)j.setAttribute("text",`${Math.round(Q.position)}%`)}this.#s()}#s(){if(!this.#_)return;let _=this.#W==="tip";if(this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(_)Z.setAttribute("tip","color");else Z.removeAttribute("tip")}),this.#A)if(_)this.#A.setAttribute("tip","add");else this.#A.removeAttribute("tip")}#r(){if(!this.#Q||!this.#_)return;this.#Q.disconnect(),this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((_)=>{this.#Q.observe(_,{attributes:!0,attributeFilter:["color"]})})}#a(){if(!this.#_)return;let _=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#q.stops,$=new Set;_.forEach((J)=>{let Q=Math.round(parseFloat(J.getAttribute("value"))||0),j=(J.getAttribute("color")||"").toUpperCase(),q=-1;for(let N=0;N<Z.length;N++){if($.has(N))continue;if(Z[N].position===Q&&Z[N].color.toUpperCase()===j){q=N;break}}if(q===-1){let N=1/0;for(let K=0;K<Z.length;K++){if($.has(K))continue;let G=Math.abs(Z[K].position-Q);if(G<N)N=G,q=K}}if(q!==-1)$.add(q),J.dataset.stopIndex=q})}#c(){if(!this.#Z)return;this.#Z.setAttribute("background",this.#I()),this.#F()}#o(){if(!this.#_)return;this.#_.addEventListener("pointerdown",(_)=>{if(z(this,"disabled"))return;if(_.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(_.button!==0)return;_.preventDefault(),_.stopPropagation();let Z=this.#_.getBoundingClientRect(),$=Math.max(0,Math.min(1,(_.clientX-Z.left)/Z.width)),J=Math.round($*100),Q=this.#f($);this.#q.stops.push({position:J,color:Q,opacity:100}),this.#q.stops.sort((K,G)=>K.position-G.position);let j=this.#q.stops.findIndex((K)=>K.position===J&&K.color===Q);this.#z=!0,this.#v(),this.#c(),this.#i(),this.#x();let N=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[j];if(N)this.#R(N),N.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:_.clientX,clientY:_.clientY,pointerId:_.pointerId,pointerType:_.pointerType,button:_.button,buttons:_.buttons}))}),this.#_.addEventListener("input",(_)=>{let Z=_.target.closest("fig-handle");if(!Z)return;if(_.stopPropagation(),_.detail?.color){let K=parseInt(Z.dataset.stopIndex,10);if(!isNaN(K)&&this.#q.stops[K]){if(this.#q.stops[K].color=_.detail.color,_.detail.opacity!==void 0)this.#q.stops[K].opacity=_.detail.opacity;else if(_.detail.alpha!==void 0)this.#q.stops[K].opacity=Math.round(_.detail.alpha*100);Z.setAttribute("color",this.#k(this.#q.stops[K])),this.#c(),this.#i()}return}if(!this.#J)Z.style.zIndex="5";this.#J=!0;let $=parseInt(Z.dataset.stopIndex,10);if(isNaN($)||!this.#q.stops[$])return;let J=_.detail?.px??0,Q=Math.round(J*100),j=Q,q=this.#_.getBoundingClientRect().width;if(_.detail?.shiftKey)j=Math.round(j/N0.SHIFT_SNAP)*N0.SHIFT_SNAP;else{let K=q>0?5/q*100:0;for(let G=0;G<this.#q.stops.length;G++){if(G===$)continue;if(Math.abs(this.#q.stops[G].position-j)<=K){j=this.#q.stops[G].position;break}}}if(this.#q.stops[$].position=j,j!==Q)Z.style.left=`${j/100*q}px`;let N=Z.closest("fig-tooltip");if(N){if(N.text=`${Math.round(j)}%`,!N.hasAttribute("show"))N.setAttribute("show","true"),Z.hideColorTip()}this.#c(),this.#i()}),this.#_.addEventListener("change",(_)=>{let Z=_.target.closest("fig-handle");if(!Z)return;if(_.stopPropagation(),_.detail?.color){let K=parseInt(Z.dataset.stopIndex,10);if(!isNaN(K)&&this.#q.stops[K]){if(this.#q.stops[K].color=_.detail.color,_.detail.opacity!==void 0)this.#q.stops[K].opacity=_.detail.opacity;Z.setAttribute("color",this.#k(this.#q.stops[K])),this.#c(),this.#p()}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.#q.stops[J])return;let Q=_.detail?.px??0,j=Math.round(Q*100),q=this.#_.getBoundingClientRect().width,N=q>0?5/q*100:0;for(let K=0;K<this.#q.stops.length;K++){if(K===J)continue;if(Math.abs(this.#q.stops[K].position-j)<=N){j=this.#q.stops[K].position;break}}this.#q.stops[J].position=j,Z.style.left=`${j/100*q}px`,this.#q.stops.sort((K,G)=>K.position-G.position),this.#a(),this.#c(),this.#p(),requestAnimationFrame(()=>{this.#J=!1})}),this.#Q=new MutationObserver((_)=>{for(let Z of _){if(Z.attributeName!=="color")continue;let $=Z.target;if($.classList.contains("fig-input-gradient-ghost"))continue;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#q.stops[J])continue;let Q=$.getAttribute("color");if(!Q||!Q.startsWith("#"))continue;if(Q!==this.#q.stops[J].color)this.#q.stops[J].color=Q,this.#c(),this.#i()}}),this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((_)=>{this.#Q.observe(_,{attributes:!0,attributeFilter:["color"]})})}#i(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#p(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:M_(this.#B(this.#q))}}set value(_){let Z=typeof _==="string"?_:JSON.stringify(_);if(this.getAttribute("value")===Z){this.#T(),this.#c(),this.#v();return}this.setAttribute("value",Z)}focus(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#G){let Z=this.#X();if(Z){Z.focus(_);return}}HTMLElement.prototype.focus.call(this,_)}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"value":this.#T(),this.#c(),this.#v();break;case"disabled":this.#d();break;case"edit":if(this.#C(),this.#M(),this.#G)document.addEventListener("keydown",this.#L);else document.removeEventListener("keydown",this.#L);break;case"mode":this.#s();break;case"size":this.#F();break}}#d(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#U(),this.#Z)if(_)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#_)for(let Z of this.#_.querySelectorAll("fig-handle"))if(_)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}A("fig-input-gradient",N0);class L0 extends HTMLElement{#Z=null;#_;#J;#$;#Q=!1;constructor(){super();if(this.input=document.createElement("input"),this.name=this.getAttribute("name")||"",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",g()),this.name)this.input.setAttribute("name",this.name);this.input.setAttribute("type","checkbox"),this.#_=this.handleInput.bind(this),this.#J=this.handleChange.bind(this),this.#$=(_)=>{if(_.target!==this||this.input.disabled)return;this.input.click()}}connectedCallback(){let _=this.querySelector(":scope > input");if(_)this.input=_;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("input",this.#_),this.input.addEventListener("input",this.#_),this.input.removeEventListener("change",this.#J),this.input.addEventListener("change",this.#J),this.removeEventListener("click",this.#$),this.addEventListener("click",this.#$),this.#N();let Z=this.querySelector(":scope > label");if(Z)this.#Z=Z,this.#Q=!1,this.#Z.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#j(),this.#Z.innerText=this.getAttribute("label");if(!this.hasAttribute("label")){let $=Array.from(this.childNodes).filter((J)=>J.nodeType===Node.TEXT_NODE).map((J)=>J.textContent||"").join(" ").trim();if($&&!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-label",$)}this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#j(){if(!this.#Z)this.#Z=document.createElement("label"),this.#Q=!0,this.#Z.setAttribute("for",this.input.id);if(this.#Z&&!this.#Z.parentNode&&this.input.parentNode)this.input.after(this.#Z)}render(){}#K(_){return this.hasAttribute(_)&&this.getAttribute(_)!=="false"}#q(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#N(){let _=this.#K("checked"),Z=this.#K("indeterminate")&&!_,$=this.#K("disabled");this.input.checked=_,this.input.indeterminate=Z,this.input.disabled=$,this.input.value=this.getAttribute("value")||"";let J=this.getAttribute("name")||this.name;if(J)this.input.setAttribute("name",J);else this.input.removeAttribute("name");if(Z)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#q()}focus(){this.input.focus()}get value(){return this.input.value}set value(_){this.input.value=_,this.setAttribute("value",_)}get checked(){return this.input.checked}set checked(_){if(this.input.checked=_,_)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#J),this.removeEventListener("click",this.#$)}attributeChangedCallback(_,Z,$){switch(_){case"label":if($)this.#j(),this.#Z.innerText=$;else if(this.#Z&&this.#Q)this.#Z.remove(),this.#Z=null,this.#Q=!1;break;case"checked":if(this.#K("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#N();break;case"indeterminate":this.#N();break;case"disabled":this.#N();break;case"name":if($)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"value":this.input.value=$||"";break;default:this.input[_]=$,this.input.setAttribute(_,$);break}}handleInput(_){if(_.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#q(),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}handleChange(_){_.stopPropagation(),this.#q(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}A("fig-checkbox",L0);class H_ extends L0{constructor(){super();this.input.setAttribute("type","radio");let _=this.getAttribute("name");if(_)this.input.setAttribute("name",_);else this.input.removeAttribute("name")}}A("fig-radio",H_);class z_ extends L0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}A("fig-switch",z_);class k0 extends HTMLElement{static observedAttributes=["type","options","placeholder","value","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Z=!1;#_=null;#J=null;#$=null;#Q=null;#j=!1;#K=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#q=this.#O.bind(this);#N=this.#T.bind(this);#G=this.#k.bind(this);#W=this.#F.bind(this);get value(){return this.getAttribute("value")||""}set value(_){this.setAttribute("value",_??"")}#X(){return this.getAttribute("type")==="number"?"fig-input-number":"fig-input-text"}#Y(){return L(this.#X(),{placeholder:this.getAttribute("placeholder")||"",value:this.value})}#R(){return this.querySelector(":scope > .input-combo > :is(fig-input-text, fig-input-number)")?.localName===this.#X()}#U(){if(this.#_=this.querySelector(":scope > .input-combo > :is(fig-input-text, fig-input-number)"),this.#$=this.querySelector("fig-button"),this.#J=this.querySelector("fig-select, fig-dropdown"),this.#J?.localName==="fig-select"&&customElements.get("fig-select"))this.#J.menuAnchor=this;if(this.#_)this.#_.setAttribute("value",this.value),this.#_.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#f()}connectedCallback(){if(this.#Q=Array.from(this.children).find((_)=>_.tagName==="FIG-SELECT"||_.tagName==="FIG-DROPDOWN")||null,this.#Z=this.#Q!==null,this.#Q)this.#Q.remove();if(this.#R()){if(this.#U(),!this.#Q)this.#Z=!!this.#J&&!this.#J.hasAttribute("data-fig-split-generated"),this.#Q=this.#Z?this.#J:null;this.#M()}else this.#B(),this.#M();this.#D(z(this,"disabled"))}disconnectedCallback(){this.#L()}#B(){let _=this.#z(),Z=this.#E(),$=this.#Y(),J=this.#Q;if(!J&&customElements.get("fig-select"))J=L("fig-select",{icon:!0,variant:"input",options:_.join(","),label:Z,"aria-label":Z,"data-fig-split-generated":!0});if(!J)J=L("fig-dropdown",{type:"dropdown",label:Z,"data-fig-split-generated":!0},_.map((q)=>L("option",{},q.trim())));let Q=J,j=null;if(J.localName==="fig-dropdown"){if(!J.hasAttribute("type"))J.setAttribute("type","dropdown");j=L("fig-button",{type:"select",variant:"input",icon:!0},L("fig-icon",{name:"chevron",size:"small",slot:"append"})),j.append(J),Q=j}if(!J.hasAttribute("label"))J.setAttribute("label",Z);if(this.replaceChildren(L("div",{className:"input-combo"},[$,Q])),this.#_=$,this.#$=j,this.#J=J,J.localName==="fig-select"&&customElements.get("fig-select"))J.menuAnchor=this;this.#f()}#M(){this.#L(),this.#J?.addEventListener("input",this.#q),this.#J?.addEventListener("change",this.#N),this.#_?.addEventListener("input",this.#G),this.#_?.addEventListener("change",this.#W)}#L(){this.#J?.removeEventListener("input",this.#q),this.#J?.removeEventListener("change",this.#N),this.#_?.removeEventListener("input",this.#G),this.#_?.removeEventListener("change",this.#W)}#O(_){_.stopPropagation(),this.#I(_),this.#H()}#T(_){_.stopPropagation(),this.#I(_),this.#A()}#I(_){let Z=_.target.closest("fig-select, fig-dropdown")?.value??"";if(this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.#_)this.#_.setAttribute("value",Z)}#k(_){_.stopPropagation();let Z=_.target.value??"";this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.#H()}#F(_){_.stopPropagation();let Z=_.target.value??"";this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.#A()}#H(){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}}))}#z(){return(this.getAttribute("options")||"").split(",").map((_)=>_.trim()).filter(Boolean)}#C(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Split input").trim()}#E(){return`${this.#C()} options`}#f(){if(this.#_)this.#K.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.#_.removeAttribute(_);else this.#_.setAttribute(_,Z)});if(this.#J){let _=this.#E();if(!this.#Z){if(this.#J.setAttribute("label",_),this.#J.localName==="fig-select")this.#J.setAttribute("aria-label",_)}else if(!this.#J.hasAttribute("aria-label")&&!this.#J.hasAttribute("label"))this.#J.setAttribute("label",_)}}#D(_){if(this.#_)if(_)this.#_.setAttribute("disabled","");else this.#_.removeAttribute("disabled");if(this.#$)if(_)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#J)if(_)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}focus(){this.#_?.focus()}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"type":{if(!this.#_||this.#_.localName===this.#X())break;let J=this.#_.matches(":focus-within");this.#L();let Q=this.#Y();if(this.#_.replaceWith(Q),this.#_=Q,this.#f(),this.#D(z(this,"disabled")),this.#M(),J)this.focus();break}case"options":if(this.#J&&!this.#Z)if(this.#J.localName==="fig-select")this.#J.setAttribute("options",$||"");else{let J=this.#z();this.#J.replaceChildren(...J.map((Q)=>{let j=document.createElement("option");return j.textContent=Q,j}))}break;case"placeholder":if(this.#_)this.#_.setAttribute("placeholder",$||"");this.#f();break;case"value":if(!this.#j&&this.#_)this.#_.setAttribute("value",$||"");break;case"disabled":this.#D($!==null&&$!=="false");break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#f();break}}}A("fig-split-input",k0);class T_ extends k0{}A("fig-combo-input",T_);class D0 extends HTMLElement{#Z="color";#_=null;#J=!1;constructor(){super();this.#_=this.#G.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#q(),this.#$(),this.#N()}#$(){let _=this.getAttribute("alpha");if(_!==null)this.style.setProperty("--alpha",_);else this.style.removeProperty("--alpha")}#Q(_){if(!_)return"color";let Z=_.toLowerCase();if(Z.includes("gradient"))return"gradient";if(Z.includes("url("))return"image";return"color"}#j(_){if(!_)return"#D9D9D9";if(_.startsWith("#"))return _.slice(0,7);try{let{ctx:Z}=T0(1,1);return Z.fillStyle=_,Z.fillStyle}catch{return"#D9D9D9"}}#K(_){if(!_||!_.includes("var("))return _;let Z=this.style.background;this.style.background=_;let $=getComputedStyle(this),J=$.backgroundImage,Q=$.backgroundColor;if(this.style.background=Z,J&&J!=="none")return J;return Q||_}#q(){let _=this.getAttribute("background");if(this.hasAttribute("background")&&!_?.trim()){if(this.#Z!=="image"||this.input){if(this.#Z="image",this.setAttribute("data-type","image"),this.input)this.input.removeEventListener("input",this.#_);this.replaceChildren(document.createElement("div")),this.input=null,this.#N()}this.style.setProperty("--swatch-background","none");return}let $=_||"#D9D9D9",J=$.includes("var("),Q=J?this.#K($):$,j=this.#Q(Q);if(j!==this.#Z||!this.input){if(this.#Z=j,this.setAttribute("data-type",this.#Z),this.input)this.input.removeEventListener("input",this.#_);if(this.#Z==="color"){let N=this.#j(Q),K=L("input",{type:"color",value:N});if(this.replaceChildren(document.createElement("div"),K),this.input=K,!J)this.input.addEventListener("input",this.#_);this.#N()}else this.replaceChildren(document.createElement("div")),this.input=null,this.#N()}else if(this.#Z==="color"&&this.input){let N=this.#j(Q);if(this.input.value!==N)this.input.value=N}let q=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--swatch-background",q?$:`linear-gradient(${$}, ${$})`)}#N(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",_?"true":"false"),this.input){this.input.disabled=_;let Z=this.getAttribute("aria-labelledby"),$=this.getAttribute("aria-label")||"Color swatch",J=this.getAttribute("aria-describedby");if(Z)this.input.setAttribute("aria-labelledby",Z),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",$),this.input.removeAttribute("aria-labelledby");if(J)this.input.setAttribute("aria-describedby",J);else this.input.removeAttribute("aria-describedby");this.removeAttribute("role"),this.removeAttribute("aria-hidden");return}if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-hidden","true");else this.setAttribute("role","img"),this.removeAttribute("aria-hidden")}#G(_){this.#J=!0,this.setAttribute("background",_.target.value),this.#J=!1}get background(){return this.getAttribute("background")}set background(_){this.setAttribute("background",_)}focus(){if(this.input?.isConnected){this.input.focus();return}HTMLElement.prototype.focus.call(this)}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="background"){if(this.#J){let J=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--swatch-background",J?$:`linear-gradient(${$}, ${$})`);return}this.#q()}else if(_==="alpha")this.#$();else if(_==="disabled"||_==="aria-label"||_==="aria-labelledby"||_==="aria-describedby")this.#N()}get alpha(){return this.getAttribute("alpha")}set alpha(_){if(_===null||_===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",_)}}A("fig-swatch",D0);class k_ extends D0{}A("fig-chit",k_);var D_=["load","error"],I_=["loadstart","progress","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","durationchange","timeupdate","ratechange","resize","volumechange"],L1=[...new Set([...D_,...I_])];class O0 extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#K=null;#q=this.#d.bind(this);#N=this.#_0.bind(this);#G=this.#Z0.bind(this);#W=this.#n.bind(this);#X=this.#e.bind(this);#Y=null;#R=null;#U=null;#B=void 0;#M=null;#L=null;#O=null;#T=null;#I=null;#k=null;#F=null;static get observedAttributes(){return["src","type","alt","upload","loading-indicator","label","aspect-ratio","fit","checkerboard","caption","controls","autoplay","loop","muted","poster","aria-label","aria-labelledby","title"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#Z}set src(_){if(this.#Z=_||"",_===null||_===void 0||_==="")this.removeAttribute("src");else this.setAttribute("src",_)}get file(){return this.#K}#H(){return this.#j||this.#Z||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#H())return null;if(!this.#_)return null;try{if(typeof this.#_.decode==="function")await this.#_.decode();else if(!this.#_.complete)await new Promise((J,Q)=>{this.#_.addEventListener("load",J,{once:!0}),this.#_.addEventListener("error",Q,{once:!0})})}catch{}let _=this.#_.naturalWidth,Z=this.#_.naturalHeight;if(!(_>0)||!(Z>0))return null;let $=document.createElement("canvas");return $.width=_,$.height=Z,$.getContext("2d").drawImage(this.#_,0,0),$.toDataURL()}connectedCallback(){this.#Z=this.getAttribute("src")||"";let _=this.getAttribute("aspect-ratio");if(_)this.style.setProperty("--fig-media-aspect-ratio",_);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let Z=this.getAttribute("fit");if(Z)this.style.setProperty("--fig-media-fit",Z);if(this.querySelectorAll("fig-swatch[data-generated]").forEach((J)=>J.remove()),this.#P(),this.#S(),this.#z(),this.#b(),this.#E(),this.#w(),this.#y(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#i();this.#$=this.querySelector("fig-input-file[data-generated]"),this.#$?.removeEventListener("change",this.#q),this.#$?.addEventListener("change",this.#q)}disconnectedCallback(){if(this.#$?.removeEventListener("change",this.#q),this.#D(),this.#A(),this.#o(),this.#Q)URL.revokeObjectURL(this.#Q),this.#Q=null;this.#j=null}#A(){if(!this.#_)return;if(L1.forEach((_)=>{this.#_.removeEventListener(_,this.#X)}),this.#_.tagName==="VIDEO")this.#_.removeEventListener("play",this.#N),this.#_.removeEventListener("pause",this.#G),this.#_.removeEventListener("ended",this.#W)}#z(){if(this.#A(),!this.#_)return;if((this.#_.tagName==="VIDEO"?I_:D_).forEach((Z)=>{this.#_.addEventListener(Z,this.#X)}),this.#_.tagName!=="VIDEO")return;this.#_.addEventListener("play",this.#N),this.#_.addEventListener("pause",this.#G),this.#_.addEventListener("ended",this.#W)}#C(){return this.mediaKind==="image"&&this.getAttribute("loading-indicator")!=="false"&&this.#J?.hasAttribute("data-generated")&&this.#_?.hasAttribute("data-generated")}#E(){this.#f();let _=this.#H();if(!_||!this.#C()){this.#D();return}if(this.#_?.tagName==="IMG"&&this.#_.complete&&this.#_.currentSrc){this.#D();return}if(this.#U===_)return;this.#D(),this.#U=_,this.#B=this.getAttribute("aria-busy"),this.setAttribute("aria-busy","true"),this.#R=setTimeout(()=>{if(this.#R=null,this.#U!==_||!this.isConnected||!this.#C())return;let Z=document.createElement("fig-spinner");Z.setAttribute("data-generated",""),Z.setAttribute("data-loading-indicator",""),Z.setAttribute("slot","overlay"),Z.setAttribute("size","small"),Z.setAttribute("aria-hidden","true"),this.append(Z),this.#Y=Z},150)}#f(){let _=this.#_?.tagName==="IMG"?this.#_:null,Z=_?.currentSrc||_?.getAttribute("src")||this.#H();this.toggleAttribute("loaded",Boolean(Z&&_?.complete&&_.naturalWidth>0))}#D(){if(this.#R!==null)clearTimeout(this.#R),this.#R=null;if(this.#Y?.remove(),this.#Y=null,this.#U=null,this.#B!==void 0){if(this.#B===null)this.removeAttribute("aria-busy");else this.setAttribute("aria-busy",this.#B);this.#B=void 0}}#P(){if(this.#J?.isConnected)return;let _=this.querySelector(":scope > fig-preview");if(_){this.#J=_;return}let Z=document.createElement("fig-preview");Z.setAttribute("data-generated",""),this.prepend(Z),this.#J=Z}#x(){let _=this.mediaKind==="video"?"video":"img";return this.querySelector(`${_}:not([data-generated])`)}#S(){let _=this.#x();if(_){if(this.#P(),this.#_&&this.#_!==_){if(this.#A(),this.#_.hasAttribute("data-generated"))this.#_.remove()}if(this.#_=_,this.#J&&_.parentElement!==this.#J)this.#J.append(_);this.#z(),this.#w();return}this.#P();let Z=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#_&&this.#_.tagName!==Z){if(this.#A(),this.#_.hasAttribute("data-generated"))this.#_.remove();this.#_=null}if(this.#_)return;if(this.mediaKind==="video"){let $=document.createElement("video");$.setAttribute("data-generated",""),$.className="fig-media-element",$.setAttribute("playsinline",""),$.preload="auto",this.#J.append($),this.#_=$;let J=()=>{if(this.#_?.autoplay)return;try{this.#_.currentTime=0.001}catch{}};this.#_.addEventListener("loadedmetadata",J,{once:!0})}else{let $=document.createElement("img");$.setAttribute("data-generated",""),$.className="fig-media-element",$.loading="lazy",$.decoding="async",$.alt=this.getAttribute("alt")||"",this.#J.append($),this.#_=$}this.#z()}#w(){if(!this.#_)return;if(this.#_.tagName==="IMG"){if(this.hasAttribute("alt")||this.#_.hasAttribute("data-generated"))this.#_.alt=this.getAttribute("alt")||"";return}if(this.#_.tagName!=="VIDEO")return;["aria-label","aria-labelledby","title"].forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.#_.removeAttribute(_);else this.#_.setAttribute(_,Z)})}#V(){return this.querySelector(":scope > figcaption:not([data-generated])")}#g(){return Array.from(this.querySelectorAll(":scope > figcaption[data-generated]"))}#y(){let _=this.#V(),Z=this.#g();if(_){Z.forEach((j)=>j.remove());return}let $=this.getAttribute("caption")||"";if(!$){Z.forEach((j)=>j.remove());return}let J=Z[0]||document.createElement("figcaption");if(Z.slice(1).forEach((j)=>j.remove()),!J.hasAttribute("data-generated"))J.setAttribute("data-generated","");if(J.textContent!==$)J.textContent=$;let Q=this.querySelector(":scope > fig-media-controls");if(Q)Q.before(J);else if(this.#J?.isConnected)this.#J.after(J);else if(!J.isConnected)this.append(J)}#m(_,Z=!1){if(!this.hasAttribute(_))return Z;return this.getAttribute(_)!=="false"}#b(){if(!this.#_)return;if(!this.#_.hasAttribute("data-generated"))return;let _=this.#H();if(this.#_.getAttribute("src")!==_){if(this.removeAttribute("loaded"),_)this.#_.setAttribute("src",_);else if(this.#_.removeAttribute("src"),this.#_.tagName==="VIDEO")this.#_.load()}if(this.#_.tagName==="IMG"){this.#w(),this.#E();return}let Z=this.getAttribute("poster");if(Z)this.#_.setAttribute("poster",Z);else this.#_.removeAttribute("poster");this.#_.controls=!1,this.#_.removeAttribute("controls"),this.#_.autoplay=this.#m("autoplay",!1),this.#_.loop=this.#m("loop",!1),this.#_.muted=this.#m("muted",!1),this.#_.playsInline=!0,this.#w(),this.#s(),this.#v(),this.#E()}get mediaEl(){return this.#_}#h(){if(this.mediaKind!=="video")return!1;return Boolean(this.#H())}#v(){let _=this.#M||this.querySelector(":scope > fig-media-controls");if(!_)return;if(this.mediaKind!=="video")return;if(this.#h()){if(_.hasAttribute("data-fig-empty-disabled"))_.removeAttribute("disabled"),_.removeAttribute("data-fig-empty-disabled");return}_.setAttribute("disabled",""),_.setAttribute("data-fig-empty-disabled",""),_.playing=!1,_.time=0,_.duration=0}#s(){if(this.mediaKind!=="video"){this.#o();return}let _=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(_){if(this.#M!==_)this.#o(),this.#M=_;this.#a(),this.#v();return}if(this.#m("controls",!1))this.#r();else this.#o()}#r(){let _=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Z=_[0];if(_.slice(1).forEach((J)=>J.remove()),Z){this.#M=Z,this.#a(),this.#v();return}let $=document.createElement("fig-media-controls");$.setAttribute("data-generated",""),this.append($),this.#M=$,this.#a(),this.#v()}#a(){if(!this.#M||!this.#_)return;if(this.#L===this.#_&&this.#O===this.#M){this.#v();return}this.#c();let _=this.#M,Z=this.#_;this.#L=Z,this.#O=_;let $=null,J=()=>{if(this.#v(),!this.#h())return;if(_.playing=!Z.paused&&!Z.ended,Number.isFinite(Z.duration))_.duration=Z.duration;if($!==null)if(Math.abs(Z.currentTime-$)<0.25)$=null;else return;_.time=Z.currentTime||0},Q=()=>{if(!this.#h())return;let N=Z.play?.();if(N&&typeof N.catch==="function")N.catch(()=>{})},j=()=>Z.pause?.(),q=(N)=>{if(!this.#h())return;let K=Number(N?.detail?.time);if(!Number.isFinite(K))return;$=K;try{Z.currentTime=K}catch{}};this.#T=J,this.#I=Q,this.#k=j,this.#F=q,Z.addEventListener("play",J),Z.addEventListener("pause",J),Z.addEventListener("ended",J),Z.addEventListener("timeupdate",J),Z.addEventListener("loadedmetadata",J),Z.addEventListener("durationchange",J),Z.addEventListener("seeked",J),_.addEventListener("play",Q),_.addEventListener("pause",j),_.addEventListener("seek",q),J()}#c(){let _=this.#L,Z=this.#O;if(_&&this.#T)_.removeEventListener("play",this.#T),_.removeEventListener("pause",this.#T),_.removeEventListener("ended",this.#T),_.removeEventListener("timeupdate",this.#T),_.removeEventListener("loadedmetadata",this.#T),_.removeEventListener("durationchange",this.#T),_.removeEventListener("seeked",this.#T);if(Z){if(this.#I)Z.removeEventListener("play",this.#I);if(this.#k)Z.removeEventListener("pause",this.#k);if(this.#F)Z.removeEventListener("seek",this.#F)}this.#L=null,this.#O=null,this.#T=null,this.#I=null,this.#k=null,this.#F=null}#o(){this.#c(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((_)=>{_.remove()}),this.#M=null}toggle(){if(!this.#_||this.mediaKind!=="video")return;if(this.#_.paused||this.#_.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#_)return;let _=this.#_.play();if(_&&typeof _.catch==="function")_.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#_)return;this.#_.pause()}#i(){let _=document.createElement("fig-input-file");_.setAttribute("data-generated",""),_.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),_.setAttribute("variant","overlay");let Z=this.getAttribute("label")||"Upload";if(_.setAttribute("label",this.#Z?"Replace":Z),this.#K?.name)_.setAttribute("filename",this.#K.name);else if(this.#Z)_.setAttribute("url",this.#Z);_.addEventListener("change",this.#q),this.#P(),this.#J.append(_),this.#$=_}#p(){if(this.#$)this.#$.removeEventListener("change",this.#q),this.#$.remove(),this.#$=null}#d(_){if(_.target!==this.#$)return;let Z=_.detail?.files?.[0],$=_.detail?.cleared===!0;if(!Z){if(this.#Q)URL.revokeObjectURL(this.#Q),this.#Q=null;if(this.#K=null,this.#j=null,$)this.src="";if(this.#b(),this.#$){let J=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Z?"Replace":J),this.#$.removeAttribute("filename"),this.#Z)this.#$.setAttribute("url",this.#Z);else this.#$.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#Q)URL.revokeObjectURL(this.#Q);if(this.#K=Z,this.#Q=URL.createObjectURL(Z),this.#j=this.#Q,this.#b(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Z,src:this.#Q}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#$)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",Z.name),this.#$.setAttribute("label","Replace")}#u(_){if(!this.#_)return;this.dispatchEvent(new CustomEvent(_,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Z||"",currentTime:this.#_.currentTime,duration:this.#_.duration}}))}#e(_){let Z=this.#_;if(!Z||_.currentTarget!==Z)return;if(Z.tagName==="IMG"&&(_.type==="load"||_.type==="error"))this.toggleAttribute("loaded",_.type==="load"),this.#D();let $={src:this.#H(),media:Z,originalEvent:_};if(Z.tagName==="VIDEO")$.currentTime=Z.currentTime,$.duration=Z.duration,$.readyState=Z.readyState,$.networkState=Z.networkState,$.error=Z.error;if(this.dispatchEvent(new CustomEvent(_.type,{bubbles:!0,cancelable:!1,composed:!0,detail:$})),Z.tagName==="IMG"&&_.type==="load"||Z.tagName==="VIDEO"&&_.type==="loadeddata")this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,composed:!0,detail:{src:$.src,file:this.#K,media:Z}}))}#_0(){this.#u("play")}#Z0(){this.#u("pause")}#n(){this.#u("ended")}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="src"){let J=$||"",Q=J&&(J===this.#j||J===this.#Q);if(this.#Z=J,this.#Q&&!Q)URL.revokeObjectURL(this.#Q),this.#Q=null,this.#j=null,this.#K=null;if(this.#b(),this.#$){let j=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Z?"Replace":j),this.#Z)if(this.#K?.name)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",this.#K.name);else this.#$.setAttribute("url",this.#Z),this.#$.removeAttribute("filename");else this.#$.removeAttribute("url"),this.#$.removeAttribute("filename")}}if(_==="type"){if(this.#S(),this.#b(),this.#$)this.#$.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(_))this.#w();if(_==="upload"){let J=$!==null&&$!=="false";if(J&&!this.#$)this.#i();else if(!J)this.#p()}if(_==="loading-indicator")this.#E();if(_==="aspect-ratio")if($)this.style.setProperty("--fig-media-aspect-ratio",$);else this.style.removeProperty("--fig-media-aspect-ratio");if(_==="fit")if($)this.style.setProperty("--fig-media-fit",$);else this.style.removeProperty("--fig-media-fit");if(_==="label"&&this.#$){let J=this.getAttribute("label")||"Upload";this.#$.setAttribute("label",this.#Z?"Replace":J)}if(["controls","autoplay","loop","muted","poster"].includes(_))this.#b();if(_==="caption")this.#y()}}A("fig-media",O0);class E_ extends O0{get mediaKind(){return"image"}}A("fig-image",E_);class P_ extends O0{get mediaKind(){return"video"}}A("fig-video",P_);class V_ extends HTMLElement{static get observedAttributes(){return["src","alt","label","text","sublabel","selected","disabled","full","size","direction","aspect-ratio","fit","label-line-clamp","label-overflow"]}#Z=null;#_=null;#J=null;#$=null;#Q=!1;#j=new MutationObserver((_)=>{if(!_.some(($)=>[...$.addedNodes,...$.removedNodes].some((J)=>J instanceof Element&&(J.matches("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])")||J.querySelector("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])"))))||!this.isConnected)return;this.#Y(),this.#B()});connectedCallback(){this.#j.observe(this,{childList:!0,subtree:!0}),this.#Y(),this.#B()}disconnectedCallback(){this.#j.disconnect()}attributeChangedCallback(){if(!this.isConnected)return;this.#Y(),this.#B()}#K(){return this.getAttribute("label")??this.getAttribute("text")??""}#q(){return this.getAttribute("sublabel")??""}#N(){return this.getAttribute("label-line-clamp")==="2"?"2":"1"}#G(){return Boolean(this.getAttribute("src"))}#W(){return this.querySelector(":scope > fig-image:not([data-generated]), :scope > fig-media:not([data-generated]), :scope > fig-preview:not([data-generated])")}#X(){this.querySelectorAll(":scope > .fig-card-link").forEach((_)=>{_.querySelectorAll(":scope > .fig-card-media").forEach((Z)=>{while(Z.firstChild)_.insertBefore(Z.firstChild,Z);Z.remove()});while(_.firstChild)this.insertBefore(_.firstChild,_);_.remove()})}#Y(){if(this.#X(),!this.#G()){this.#R();return}let _=this.#W();if(this.#Q=Boolean(_),_)this.querySelectorAll(":scope > [data-generated]:not(fig-footer)").forEach(($)=>$.remove()),this.#_=null;if(!this.#Q){if(this.#_=this.querySelector(":scope > fig-image[data-generated]")||null,!this.#_)this.querySelectorAll(":scope > fig-image, :scope > fig-media, :scope > fig-preview").forEach(($)=>{if($.hasAttribute("data-generated"))$.remove()}),this.#_=document.createElement("fig-image"),this.#_.setAttribute("data-generated",""),this.#_.setAttribute("full",""),this.#_.setAttribute("size","auto"),this.prepend(this.#_)}if(!Boolean(this.#K()||this.#q())){this.querySelector(":scope > fig-footer[data-generated]")?.remove(),this.#Z=null,this.#J=null,this.#$=null;return}if(!this.#Z||!this.#Z.isConnected){if(this.#Z=this.querySelector(":scope > fig-footer[data-generated]"),!this.#Z)this.#Z=document.createElement("fig-footer"),this.#Z.setAttribute("data-generated",""),this.appendChild(this.#Z)}if(!this.#J||!this.#J.isConnected){if(this.#J=this.#Z.querySelector(":scope > .fig-card-label[data-generated]"),!this.#J)this.#J=document.createElement("label"),this.#J.className="fig-card-label",this.#J.setAttribute("data-generated",""),this.#Z.appendChild(this.#J)}if(!this.#$||!this.#$.isConnected){if(this.#$=this.#Z.querySelector(":scope > .fig-card-sublabel[data-generated]"),!this.#$)this.#$=document.createElement("label"),this.#$.className="fig-card-sublabel",this.#$.setAttribute("data-generated",""),this.#J.after(this.#$)}}#R(){if(this.#X(),this.querySelectorAll(":scope > [data-generated]").forEach((Z)=>Z.remove()),this.#_=null,this.#Q=!0,this.#Z=null,this.#J=null,this.#$=null,!this.#K()&&!this.#q())return;this.#Z=document.createElement("fig-footer"),this.#Z.setAttribute("data-generated",""),this.#J=document.createElement("label"),this.#J.className="fig-card-label",this.#J.setAttribute("data-generated",""),this.#Z.appendChild(this.#J);let _=this.#q();if(this.#$=null,_)this.#$=document.createElement("label"),this.#$.className="fig-card-sublabel",this.#$.setAttribute("data-generated",""),this.#Z.appendChild(this.#$);this.appendChild(this.#Z)}#U(){let _=this.getAttribute("label-overflow")==="fade";this.querySelectorAll(":scope > fig-footer > :is(.fig-card-label, .fig-card-sublabel)").forEach((Z)=>{Z.classList.toggle("fig-overflow-fade",_),Z.classList.toggle("fig-overflow-fade-horizontal",_)})}#B(){if(!this.#G()){this.#M();return}let _=z(this,"disabled"),Z=this.#K(),$=this.#q(),J=this.#N();this.style.setProperty("--fig-card-label-line-clamp",J),this.setAttribute("role","group");let Q=[Z,$].filter(Boolean).join(", ");if(Q)this.setAttribute("aria-label",Q);else this.removeAttribute("aria-label");if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#_&&!this.#Q){let j=this.getAttribute("src"),q=this.getAttribute("alt"),N=this.getAttribute("aspect-ratio")||"1/1",K=this.getAttribute("fit")||"contain",G=q!=null?q:"";if(j)this.#_.setAttribute("src",j);else this.#_.removeAttribute("src");this.#_.setAttribute("alt",G),this.#_.setAttribute("aspect-ratio",N),this.#_.setAttribute("fit",K),this.#_.setAttribute("full",""),this.#_.setAttribute("size","auto")}if(this.#J)this.#J.textContent=Z,this.#J.hidden=!Z;if(this.#$)this.#$.textContent=$,this.#$.hidden=!$;if(this.#Z)this.#Z.hidden=!Z&&!$;this.#U()}#M(){let _=z(this,"disabled"),Z=this.#K(),$=this.#q();this.style.setProperty("--fig-card-label-line-clamp",this.#N()),this.setAttribute("role","group");let J=[Z,$].filter(Boolean).join(", ");if(J)this.setAttribute("aria-label",J);else this.removeAttribute("aria-label");if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#J)this.#J.textContent=Z,this.#J.hidden=!Z;if(this.#$)this.#$.textContent=$;this.#U()}}A("fig-card",V_);class C_ extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=!1;#j=!1;static get observedAttributes(){return["playing","duration","time","disabled"]}connectedCallback(){this.#K(),this.#W(),this.#X(),this.#q()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(_){if(_)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let _=Number(this.getAttribute("duration"));return Number.isFinite(_)&&_>=0?_:0}set duration(_){let Z=Number(_);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("duration");return}this.setAttribute("duration",String(Z))}get time(){let _=Number(this.getAttribute("time"));return Number.isFinite(_)&&_>=0?_:0}set time(_){let Z=Number(_);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("time");return}this.setAttribute("time",String(Z))}get disabled(){return z(this,"disabled")}set disabled(_){if(_)this.setAttribute("disabled","");else this.removeAttribute("disabled")}attributeChangedCallback(_){if(!this.#j)return;if(_==="playing")this.#W();if(_==="duration"||_==="time")this.#X();if(_==="disabled")this.#q()}#K(){if(this.#j)return;if(this.#j=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");let _=document.createElement("fig-tooltip");_.setAttribute("text","Play");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Play"),Z.append(h("play")),_.append(Z),Z.addEventListener("click",(j)=>{j.preventDefault(),j.stopPropagation(),this.toggle()});let $=document.createElement("fig-slider");$.setAttribute("text","false"),$.setAttribute("min","0"),$.setAttribute("max",String(this.duration)),$.setAttribute("step","1"),$.setAttribute("value",String(this.time)),$.setAttribute("full",""),$.setAttribute("aria-label","Seek"),$.setAttribute("aria-valuetext",this.#G(this.time,this.duration));let J=document.createElement("span");J.className="fig-media-controls-time",J.textContent=this.#N(this.time);let Q=(j)=>{if(this.disabled){j.preventDefault?.(),j.stopPropagation();return}let q=j.currentTarget,N=Number(q?.value);if(!Number.isFinite(N))return;this.#Q=!0,this.setAttribute("time",String(N)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:N}})),requestAnimationFrame(()=>{this.#Q=!1})};$.addEventListener("input",Q),$.addEventListener("change",Q),this.append(_,$,J),this.#Z=Z,this.#_=_,this.#J=$,this.#$=J,this.#q()}#q(){let _=this.disabled;if(this.setAttribute("aria-disabled",_?"true":"false"),this.#Z)if(_)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#J)if(_)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}#N(_){if(!Number.isFinite(_)||_<0)_=0;let Z=Math.floor(_),$=Math.floor(Z/60),J=Z%60;return`${String($).padStart(2,"0")}:${String(J).padStart(2,"0")}`}#G(_,Z=0){let $=this.#N(_);if(!Number.isFinite(Z)||Z<=0)return $;return`${$} of ${this.#N(Z)}`}#W(){if(!this.#Z)return;let _=this.playing;this.#Z.setAttribute("aria-label",_?"Pause":"Play"),this.#_?.setAttribute("text",_?"Pause":"Play");let Z=this.#Z.querySelector("fig-icon");if(Z)Z.setAttribute("name",_?"pause":"play")}#X(){if(!this.#J)return;let _=this.duration;if(Number(this.#J.getAttribute("max"))!==_)this.#J.setAttribute("max",String(_));let Z=this.time;if(!this.#Q)this.#J.setAttribute("value",String(Z));if(this.#J.setAttribute("aria-valuetext",this.#G(Z,_)),this.#$)this.#$.textContent=this.#N(Z)}toggle(){if(this.disabled)return;let _=!this.playing;this.playing=_,this.dispatchEvent(new CustomEvent(_?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:_}}))}play(){if(this.disabled||this.playing)return;this.toggle()}pause(){if(this.disabled||!this.playing)return;this.toggle()}}A("fig-media-controls",C_);class I0 extends HTMLElement{static#Z=0;static observedAttributes=["url","polarization","progress"];#_=null;#J=null;#$=null;#Q=null;#j=null;#K=null;#q=null;#N=null;#G=[];#W=0;#X=0;connectedCallback(){if(!this.#_)this.#Y();this.#R(),this.#U()}disconnectedCallback(){if(this.#k(),this.#K?.disconnect(),this.#K=null,this.#X)cancelAnimationFrame(this.#X);this.#X=0}attributeChangedCallback(_,Z,$){if(Z===$||!this.#_)return;if(_==="url")this.#U();if(_==="polarization")this.#F();if(_==="progress")this.#I()}#Y(){this.#_=document.createElement("div"),this.#_.className="fig-audio-waveform-surface",this.#_.setAttribute("aria-hidden","true"),this.#J=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.#J.setAttribute("aria-hidden","true"),this.#J.setAttribute("preserveAspectRatio","none");let _=document.createElementNS("http://www.w3.org/2000/svg","defs"),Z=document.createElementNS("http://www.w3.org/2000/svg","clipPath"),$=`fig-audio-waveform-progress-${++I0.#Z}`;Z.id=$,Z.setAttribute("clipPathUnits","userSpaceOnUse"),this.#j=document.createElementNS("http://www.w3.org/2000/svg","rect"),Z.append(this.#j),_.append(Z),this.#$=document.createElementNS("http://www.w3.org/2000/svg","path"),this.#$.classList.add("fig-audio-waveform-path"),this.#Q=document.createElementNS("http://www.w3.org/2000/svg","path"),this.#Q.classList.add("fig-audio-waveform-progress"),this.#Q.setAttribute("clip-path",`url(#${$})`),this.#J.append(_,this.#$,this.#Q),this.#_.appendChild(this.#J),this.replaceChildren(this.#_),this.#R()}#R(){if(this.#K||!this.#J)return;this.#K=new ResizeObserver(()=>this.#F()),this.#K.observe(this.#J)}#U(){let _=this.getAttribute("url");if(!_){this.#L();return}this.#B(async(Z)=>{let $=await fetch(_,{signal:Z});if(!$.ok)throw Error(`Audio request failed: ${$.status}`);return $.arrayBuffer()})}async#B(_){this.#k();let Z=++this.#W,$=new AbortController;this.#q=$,this.setAttribute("data-waveform-state","loading"),this.setAttribute("aria-busy","true"),this.#G=[],this.#F();let J=null;try{let Q=await _($.signal);if(Z!==this.#W||!this.isConnected)return;let j=window.AudioContext||window.webkitAudioContext;if(!j)throw Error("Web Audio is unavailable");J=new j,this.#N=J;let q=await J.decodeAudioData(Q);if(Z!==this.#W||!this.isConnected)return;this.#G=this.#M(q),this.setAttribute("data-waveform-state","ready"),this.#F()}catch(Q){if(Z!==this.#W||Q?.name==="AbortError")return;this.#G=Array(256).fill(0),this.setAttribute("data-waveform-state","unavailable"),this.#F()}finally{if(J)try{await J.close()}catch{}if(this.#N===J)this.#N=null;if(this.#q===$)this.#q=null;if(Z===this.#W)this.removeAttribute("aria-busy")}}#M(_){let $=Array(256).fill(0),J=_.numberOfChannels,Q=_.length,j=Math.max(1,Math.ceil(Q/500000)),q=0;for(let G=0;G<256;G+=1){let X=Math.floor(G/256*Q),Y=Math.max(X+1,Math.floor((G+1)/256*Q)),U=0,W=0;for(let B=0;B<J;B+=1){let F=_.getChannelData(B);for(let H=X;H<Y;H+=j){let T=F[H]||0;if(!Number.isFinite(T))continue;U+=T*T,W+=1}}let O=W>0?Math.sqrt(U/W):0;$[G]=O,q=Math.max(q,O)}if(!Number.isFinite(q)||q<=0)return $.fill(0);let N=Math.min(...$),K=q-N;if(!Number.isFinite(K)||K<=Number.EPSILON)return $.fill(0);return $.map((G)=>{let X=(G-N)/K;return Number.isFinite(X)?X:0})}#L(){this.#k(),this.#G=[],this.removeAttribute("data-waveform-state"),this.removeAttribute("aria-busy"),this.#F()}#O(_){let Z=Number.parseFloat(this.getAttribute("polarization")),$=Number.isFinite(Z)?Math.max(0,Math.min(Z,4)):1.5;return Math.max(0,Math.min(1,0.5+(_-0.5)*$))}#T(){let _=Number.parseFloat(this.getAttribute("progress"));return Number.isFinite(_)?Math.max(0,Math.min(_,1)):0}#I(){if(!this.#J||!this.#j)return;let _=this.#J.viewBox.baseVal,Z=this.#J.getBoundingClientRect(),$=_.width||Math.max(1,Math.round(Z.width)),J=_.height||Math.max(1,Math.round(Z.height));this.#j.setAttribute("x","0"),this.#j.setAttribute("y","0"),this.#j.setAttribute("width",String($*this.#T())),this.#j.setAttribute("height",String(J))}#k(){if(this.#W+=1,this.#q?.abort(),this.#q=null,this.#N){try{this.#N.close()}catch{}this.#N=null}}#F(){if(this.#X)return;this.#X=requestAnimationFrame(()=>{this.#X=0,this.#H()})}#H(){if(!this.#J||!this.#$||!this.#Q||!this.#j)return;let _=this.#J.getBoundingClientRect(),Z=Math.max(1,Math.round(_.width)),$=Math.max(1,Math.round(_.height));if(this.#J.setAttribute("viewBox",`0 0 ${Z} ${$}`),this.#I(),this.#G.length===0){this.#$.setAttribute("d",""),this.#Q.setAttribute("d","");return}let J=Math.min(this.#G.length,Math.max(16,Math.floor(Z/3))),Q=Z/J,j=Number.parseFloat(getComputedStyle(this).getPropertyValue("--fig-audio-waveform-stroke-width")),q=Number.isFinite(j)&&j>0?j:2,N=Math.max(0.5,Math.min(q,Q*0.75)),K=N/2,G=$/2,X=Math.max(2,$-12),Y=[];for(let W=0;W<J;W+=1){let O=Math.min(this.#G.length-1,Math.floor(W/J*this.#G.length)),B=this.#O(this.#G[O]),F=Math.max(N,B*X),H=(W+0.5)*Q,T=G-F/2,R=G+F/2,I=H-K,E=H+K;Y.push(`M ${H} ${T} Q ${E} ${T} ${E} ${T+K} V ${R-K} Q ${E} ${R} ${H} ${R} Q ${I} ${R} ${I} ${R-K} V ${T+K} Q ${I} ${T} ${H} ${T} Z`)}let U=Y.join(" ");this.#$.setAttribute("d",U),this.#Q.setAttribute("d",U)}}A("fig-audio-waveform",I0);var l=[".png",".jpg",".jpeg",".gif",".webp",".svg",".avif"],r=[".mp3",".wav",".aac",".m4a",".ogg",".flac"];class S_ extends HTMLElement{static observedAttributes=["accepts","preview","label","disabled","multiple","variant","url","filename"];#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#K=null;#q=null;#N=null;#G=null;#W=!1;#X=null;#Y=!1;#R=!1;get files(){return this.#j}get#U(){let _=this.getAttribute("filename");if(_)return _;let Z=this.getAttribute("url");if(!Z)return"";try{let J=new URL(Z,location.href).pathname.split("/").pop();return J?decodeURIComponent(J):Z}catch{return Z}}get value(){if(this.#j&&this.#j.length>0){if(this.#j.length===1)return this.#j[0].name;return`${this.#j.length} files`}return this.#U}get#B(){return this.getAttribute("accepts")||""}get#M(){return this.hasAttribute("preview")&&this.getAttribute("preview")!=="false"}#L(_,Z){let $=_.toLowerCase();return Z.some((J)=>$.endsWith(J))}#O(_,Z,$){return this.#L(_.name,Z)||_.type.toLowerCase().startsWith($)}#T(){if(this.#j?.[0]){if(this.#O(this.#j[0],r,"audio/"))return"Upload audio";if(this.#O(this.#j[0],l,"image/"))return"Upload image"}if(this.#L(this.#U,r))return"Upload audio";if(this.#L(this.#U,l))return"Upload image";let _=this.#B.split(",").map((Z)=>Z.trim().toLowerCase()).filter(Boolean).map((Z)=>{if(Z.startsWith("audio/")||r.includes(Z))return"audio";if(Z.startsWith("image/")||l.includes(Z))return"image";return"file"});if(_.length>0&&_.every((Z)=>Z==="audio"))return"Upload audio";if(_.length>0&&_.every((Z)=>Z==="image"))return"Upload image";return"Upload file"}#I(){if(this.#j?.length)return this.#L(this.#j[0].name,l);return!!this.getAttribute("url")&&this.#L(this.#U,l)}#k(){if(this.#j?.length)return this.#O(this.#j[0],r,"audio/");return!!this.getAttribute("url")&&this.#L(this.#U,r)}#F(){if(this.#j&&this.#j.length>0){let _=Array.from(this.#j);if(_.every((Z)=>this.#O(Z,r,"audio/")))return"sound";if(_.every((Z)=>this.#O(Z,l,"image/")))return"image"}if(this.#L(this.#U,r))return"sound";if(this.#L(this.#U,l))return"image";return"upload"}connectedCallback(){this.#v(),this.addEventListener("dragover",this.#C),this.addEventListener("dragleave",this.#E),this.addEventListener("drop",this.#f)}disconnectedCallback(){this.#Z?.removeEventListener("change",this.#A),this.#J?.removeEventListener("click",this.#z),this.#w(),this.#V(),this.removeEventListener("dragover",this.#C),this.removeEventListener("dragleave",this.#E),this.removeEventListener("drop",this.#f)}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#R)return;this.#v()}clear(){if(this.#j=null,this.#Z)this.#Z.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#v(),this.#H({cleared:!0})}#H(_={}){let Z={files:this.#j,..._};this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0}))}#A=()=>{if(this.#Z.files.length>0)this.#j=this.#Z.files,this.removeAttribute("url"),this.#v(),this.#H()};#z=(_)=>{_.stopPropagation(),this.clear()};#C=(_)=>{if(this.#K)return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(_.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#Q)this.#Q.dataset.prevText=this.#Q.textContent,this.#Q.textContent="Drop file"}};#E=()=>{if(this.#K)return;if(this.removeAttribute("dragover"),this.#Q&&this.#Q.dataset.prevText!==void 0)this.#Q.textContent=this.#Q.dataset.prevText,delete this.#Q.dataset.prevText};#f=(_)=>{if(this.#K)return;if(_.preventDefault(),this.removeAttribute("dragover"),this.#Q&&this.#Q.dataset.prevText!==void 0)this.#Q.textContent=this.#Q.dataset.prevText,delete this.#Q.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#B,$=Array.from(_.dataTransfer.files);if(Z){let Q=Z.split(",").map((j)=>j.trim().toLowerCase());$=$.filter((j)=>{let q="."+j.name.split(".").pop().toLowerCase(),N=j.type.toLowerCase();return Q.some((K)=>K===q||K===N||K.endsWith("/*")&&N.startsWith(K.slice(0,-1)))})}if(!this.hasAttribute("multiple")||this.getAttribute("multiple")==="false")$=$.slice(0,1);if($.length===0)return;let J=new DataTransfer;if($.forEach((Q)=>J.items.add(Q)),this.#j=J.files,this.#Z)this.#Z.files=J.files;this.removeAttribute("url"),this.#v(),this.#H()};#D=(_)=>{_.stopPropagation()};#P(){this.#R=!0,this.removeAttribute("url"),this.removeAttribute("filename"),this.#R=!1}#x=(_)=>{if(_.currentTarget!==this.#K)return;_.stopPropagation();let Z=_.detail?.file;if(!Z||this.#j?.[0]===Z)return;let $=new DataTransfer,J=this.#K.querySelector("fig-input-file[data-generated]")?.files;if(J?.length)Array.from(J).forEach((Q)=>$.items.add(Q));else $.items.add(Z);if(this.#j=$.files,this.#P(),!this.#Y)this.#H()};#S=(_)=>{if(_.currentTarget!==this.#K)return;if(_.stopPropagation(),this.#K.file||!this.#j&&!this.#U)return;if(this.#j=null,this.#P(),this.#v(),!this.#Y)this.#H({cleared:!0})};#w(){if(!this.#K)return;this.#K.removeEventListener("loaded",this.#x),this.#K.removeEventListener("change",this.#S),this.#K=null}#V(){if(this.#q?.pause(),this.#X)URL.revokeObjectURL(this.#X),this.#X=null;this.#q=null,this.#N=null,this.#G=null,this.#W=!1}#g(_){this.#W=_,this.#N?.setAttribute("name",_?"pause":"play"),this.#Q?.toggleAttribute("selected",_),this.#Q?.setAttribute("aria-label",_?"Pause audio":"Play audio")}#y(){if(!this.#q||!this.#G)return;let _=this.#q.duration,Z=this.#q.currentTime,$=Number.isFinite(_)&&_>0&&Number.isFinite(Z)?Math.max(0,Math.min(Z/_,1)):0;this.#G.setAttribute("progress",String($))}#m=(_)=>{if(_.preventDefault(),!this.#q||this.#Q?.hasAttribute("disabled"))return;if(this.#W){this.#q.pause();return}let Z=this.#q.play();if(Z&&typeof Z.catch==="function")Z.catch(()=>this.#g(!1))};#b(){let _=document.createElement("audio");if(_.hidden=!0,_.preload="metadata",this.#j?.[0])this.#X=URL.createObjectURL(this.#j[0]),_.src=this.#X;else _.src=this.getAttribute("url")||"";_.addEventListener("play",()=>this.#g(!0)),_.addEventListener("pause",()=>this.#g(!1)),_.addEventListener("ended",()=>{this.#g(!1),this.#G?.setAttribute("progress","0")}),_.addEventListener("timeupdate",()=>this.#y()),_.addEventListener("durationchange",()=>this.#y()),this.#q=_,this.#G=document.createElement("fig-audio-waveform"),this.#G.className="fig-input-file-audio-waveform",this.#G.setAttribute("url",_.src),this.#G.setAttribute("polarization","3"),this.#G.setAttribute("progress","0"),this.#Q?.append(this.#G),this.#Q?.addEventListener("click",this.#m),this.#g(!1),this.append(_)}#h({accepts:_,label:Z,disabled:$,multiple:J}){let Q=document.createElement("fig-image");Q.setAttribute("full",""),Q.setAttribute("checkerboard",""),Q.setAttribute("upload",""),Q.setAttribute("aspect-ratio","4/3"),Q.setAttribute("label",Z);let j=this.getAttribute("url");if(j)Q.setAttribute("src",j);this.#K=Q,Q.addEventListener("loaded",this.#x),Q.addEventListener("change",this.#S),this.appendChild(Q);let q=Q.querySelector("fig-input-file[data-generated]");if(!q)return;if(q.addEventListener("input",this.#D),q.addEventListener("change",this.#D),q.setAttribute("accepts",_),$)q.setAttribute("disabled","");if(J)q.setAttribute("multiple","");if(this.#j?.length){let N=q.querySelector('input[type="file"]');if(N)this.#Y=!0,N.files=this.#j,N.dispatchEvent(new Event("change",{bubbles:!0})),this.#Y=!1}}#v(){let _=this.#B,Z=this.getAttribute("label"),$=Z?.trim()?Z:this.#T(),J=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Q=this.hasAttribute("multiple")&&this.getAttribute("multiple")!=="false",j=this.getAttribute("variant")||"property",q=this.#j&&this.#j.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename"),N=this.#M&&this.#I(),K=this.#M&&this.#k();if(this.#w(),this.#V(),this.replaceChildren(),this.#Z=null,this.#Q=null,this.#J=null,this.#$=null,this.toggleAttribute("data-previewing",N),N){this.#h({accepts:_,label:$,disabled:J,multiple:Q});return}if(q){let G=this.value,X=K?G:_?`Accepts ${_.split(",").map((W)=>W.trim()).join(", ")}`:"";if(this.#Q=document.createElement("fig-button"),this.#Q.setAttribute("variant",j),j==="property")this.#Q.setAttribute("full","");if(this.#Q.className="fig-input-file-filename",J)this.#Q.setAttribute("disabled","");let Y=h(K?"play":this.#F());if(K)this.#N=Y,Y.setAttribute("slot","prepend"),this.#Q.append(Y);else{let W=document.createElement("fig-truncate");W.setAttribute("position","middle"),W.setAttribute("tooltip","");let O=G.lastIndexOf(".");if(O>0)W.setAttribute("tail",G.slice(O));W.textContent=G,Y.setAttribute("slot","prepend"),this.#Q.append(Y,W)}if(!K){if(this.#Q.setAttribute("type","upload"),this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",this.#Z.disabled=J,_)this.#Z.setAttribute("accept",_);if(Q)this.#Z.setAttribute("multiple","");this.#Z.addEventListener("change",this.#A),this.#Q.appendChild(this.#Z)}if(X)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",X),this.#$.appendChild(this.#Q),this.appendChild(this.#$);else this.appendChild(this.#Q);let U=document.createElement("fig-tooltip");if(U.setAttribute("text","Remove"),this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#J.setAttribute("icon","true"),this.#J.setAttribute("aria-label","Remove"),this.#J.className="fig-input-file-clear",J)this.#J.setAttribute("disabled","");if(this.#J.replaceChildren(h("minus")),this.#J.addEventListener("click",this.#z),U.appendChild(this.#J),this.appendChild(U),K)this.#b()}else{let G=_?`Accepts ${_.split(",").map((Y)=>Y.trim()).join(", ")}`:"";if(G)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",G);if(this.#Q=document.createElement("fig-button"),this.#Q.setAttribute("variant",j),j==="property")this.#Q.setAttribute("full","");this.#Q.setAttribute("type","upload"),this.#Q.textContent=$;let X=h("upload");if(X.setAttribute("slot","prepend"),this.#Q.prepend(X),J)this.#Q.setAttribute("disabled","");if(this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",this.#Z.disabled=J,_)this.#Z.setAttribute("accept",_);if(Q)this.#Z.setAttribute("multiple","");if(this.#Z.addEventListener("change",this.#A),this.#Q.appendChild(this.#Z),this.#$)this.#$.appendChild(this.#Q),this.appendChild(this.#$);else this.appendChild(this.#Q)}}}A("fig-input-file",S_);class b extends HTMLElement{#Z={x:0.42,y:0};#_={x:0.58,y:1};#J={stiffness:200,damping:15,mass:1,initialVelocity:0};#$="bezier";#Q=2;#j=null;#K=null;#q=null;#N=null;#G=null;#W=null;#X=null;#Y=null;#R=null;#U=null;#B=null;#M=0.8;#L=200;#O=200;#T=null;#I=null;#k=null;#F=null;#H=5;#A=10;#z=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","mode","precision","aspect-ratio","edit","presets","text"]}connectedCallback(){this.#Q=parseInt(this.getAttribute("precision")||"2"),p(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let _=this.#E();if(_)this.#$=_;let Z=this.getAttribute("value");if(Z)this.#w(Z);this.#f(),this.#U=this.#V(),this.#o(),this.#t()}disconnectedCallback(){if(this.#j=null,this.#F)this.#F.disconnect(),this.#F=null}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="aspect-ratio"){if(p(this,"--aspect-ratio",$),this.#K)this.#l(),this.#$0();return}if(_==="edit"||_==="presets"||_==="text"){if(this.isConnected)this.#o();return}if(_==="mode"){this.#f();let J=this.getAttribute("value");if(J)this.#w(J);if(this.#f(),this.#U=this.#V(),this.isConnected)this.#o();return}if(_==="value"&&$){let J=this.#$;if(this.#w($),this.#U=this.#V(),J!==this.#$&&this.#r())this.#o();else{if(this.#K)this.#$0();this.#U0(),this.#J0()}}if(_==="precision")this.#Q=parseInt($||"2")}get value(){if(this.#$==="spring"){let{stiffness:Z,damping:$,mass:J,initialVelocity:Q=0}=this.#J,j=Q?`, ${Q}`:"";return`spring(${Z}, ${$}, ${J}${j})`}let _=this.#Q;return`${this.#Z.x.toFixed(_)}, ${this.#Z.y.toFixed(_)}, ${this.#_.x.toFixed(_)}, ${this.#_.y.toFixed(_)}`}get cssValue(){if(this.#$==="spring"){let Z=this.#g(),$=20,J=Math.max(1,Math.floor(Z.length/20)),Q=[];for(let j=0;j<Z.length;j+=J)Q.push(Z[j].value.toFixed(3));if(Z.length>0)Q.push(Z[Z.length-1].value.toFixed(3));return`linear(${Q.join(", ")})`}let _=this.#Q;return`cubic-bezier(${this.#Z.x.toFixed(_)}, ${this.#Z.y.toFixed(_)}, ${this.#_.x.toFixed(_)}, ${this.#_.y.toFixed(_)})`}get preset(){return this.#U}set value(_){if(_&&typeof _==="object"){let Z=this.#P(_);if(!Z)throw TypeError("Invalid easing value or mode/type mismatch");let $=Z.type==="spring"?{type:"spring",...Z.spring}:{type:"bezier",x1:Z.bezier[0],y1:Z.bezier[1],x2:Z.bezier[2],y2:Z.bezier[3]};this.setAttribute("value",JSON.stringify($));return}this.setAttribute("value",_)}get spring(){if(this.#$!=="spring")return null;return{...this.#J,initialVelocity:this.#J.initialVelocity??0}}set spring(_){if(!_||typeof _!=="object")throw TypeError("spring must be an object");this.value={..._,type:"spring"}}#E(){let _=this.getAttribute("mode")?.trim().toLowerCase();return _==="bezier"||_==="spring"?_:null}#f(){let _=this.#E();if(_)this.#$=_}#D(_){let Z=this.#E();return!Z||_.type===Z}#P(_){if(!_||typeof _!=="object"||Array.isArray(_))return null;let Z=this.#E(),$=typeof _.type==="string"?_.type.trim().toLowerCase():null;if($&&$!=="bezier"&&$!=="spring")return null;if($&&Z&&$!==Z)return null;let J=$||Z;if(!J)return null;if(J==="spring"){let j={mass:Number(_.mass),stiffness:Number(_.stiffness),damping:Number(_.damping),initialVelocity:_.initialVelocity===void 0?0:Number(_.initialVelocity)};if(!Number.isFinite(j.mass)||j.mass<=0||!Number.isFinite(j.stiffness)||j.stiffness<=0||!Number.isFinite(j.damping)||j.damping<0||!Number.isFinite(j.initialVelocity))return null;return{type:J,spring:j}}let Q=[_.x1,_.y1,_.x2,_.y2].map(Number);if(Q.some((j)=>!Number.isFinite(j))||Q[0]<0||Q[0]>1||Q[2]<0||Q[2]>1)return null;return{type:J,bezier:Q}}#x(_){if(_.type==="spring")this.#$="spring",this.#J={..._.spring};else this.#$="bezier",[this.#Z.x,this.#Z.y,this.#_.x,this.#_.y]=_.bezier}#S(_){let Z=_.match(/^spring\(\s*(.*?)\s*\)$/i);if(!Z)return null;let $=Z[1].split(",").map((Q)=>Number(Q.trim()));if($.length!==3&&$.length!==4||$.some((Q)=>!Number.isFinite(Q)))return null;let J={stiffness:$[0],damping:$[1],mass:$[2],initialVelocity:$[3]??0};if(J.stiffness<=0||J.damping<0||J.mass<=0)return null;return J}#w(_){if(_&&typeof _==="object"){let Q=this.#P(_);if(!Q)return!1;return this.#x(Q),!0}if(typeof _!=="string")return!1;let Z=_.trim();if(Z.startsWith("{"))try{return this.#w(JSON.parse(Z))}catch{return!1}let $=this.#S(Z);if($&&this.#E()!=="bezier")return this.#$="spring",this.#J=$,!0;let J=Z.split(",").map((Q)=>parseFloat(Q.trim()));if(J.length>=4&&J.every((Q)=>!isNaN(Q))&&this.#E()!=="spring")return this.#$="bezier",this.#Z.x=J[0],this.#Z.y=J[1],this.#_.x=J[2],this.#_.y=J[3],!0;return!1}#V(){if(this.#$==="bezier"){for(let Z of b.PRESETS){if(Z.type!=="bezier"||!Z.value)continue;if(Math.abs(this.#Z.x-Z.value[0])<0.001&&Math.abs(this.#Z.y-Z.value[1])<0.001&&Math.abs(this.#_.x-Z.value[2])<0.001&&Math.abs(this.#_.y-Z.value[3])<0.001)return Z.name}return"Custom bezier"}for(let Z of b.PRESETS){if(Z.type!=="spring"||!Z.spring)continue;if(Math.abs(this.#J.stiffness-Z.spring.stiffness)<0.001&&Math.abs(this.#J.damping-Z.spring.damping)<0.001&&Math.abs(this.#J.mass-Z.spring.mass)<0.001&&Math.abs(this.#J.initialVelocity??0)<0.001)return Z.name}return"Custom spring"}#g(){let{stiffness:_,damping:Z,mass:$,initialVelocity:J=0}=this.#J,Q=0.004,j=5,q=[],N=0,K=J;for(let G=0;G<=5;G+=0.004){let X=-_*(N-1)-Z*K;if(K+=X/$*0.004,N+=K*0.004,q.push({t:G,value:N}),G>0.1&&Math.abs(N-1)<0.0005&&Math.abs(K)<0.0005)break}return q}static#y(_,Z=24){let{stiffness:$,damping:J,mass:Q,initialVelocity:j=0}=_,q=0.004,N=5,K=[],G=0,X=j;for(let R=0;R<=5;R+=0.004){let I=-$*(G-1)-J*X;if(X+=I/Q*0.004,G+=X*0.004,K.push({t:R,value:G}),R>0.1&&Math.abs(G-1)<0.001&&Math.abs(X)<0.001)break}let Y=K[K.length-1].t||1,U=1;for(let R of K)if(R.value>U)U=R.value;let W=0;for(let R of K)if(R.value<W)W=R.value;let O=Math.max(U-W,1),B=6,F=Z-B*2,H=Math.max(1,Math.floor(K.length/30)),T="";for(let R=0;R<K.length;R+=H){let I=B+K[R].t/Y*F,E=B+(1-(K[R].value-W)/O)*F;T+=(R===0?"M":"L")+I.toFixed(1)+","+E.toFixed(1)}return b.#v(T,Z,b.#h(Z))}static#m(_,Z,$,J,Q=24){let q=(Q-11)/2,N=48,K=[],G=(R,I,E,V,C)=>{let w=1-C;return w*w*w*R+3*w*w*C*I+3*w*C*C*E+C*C*C*V};for(let R=0;R<=48;R++){let I=R/48;K.push({x:G(0,_,$,1,I),y:G(0,Z,J,1,I)})}let X=1/0,Y=-1/0,U=1/0,W=-1/0;for(let R of K){if(R.x<X)X=R.x;if(R.x>Y)Y=R.x;if(R.y<U)U=R.y;if(R.y>W)W=R.y}let O=Math.max(Y-X,0.000001),B=Math.max(W-U,0.000001),F=(R)=>q+(R-X)/O*11,H=(R)=>q+(1-(R-U)/B)*11,T="";for(let R=0;R<K.length;R++){let I=F(K[R].x),E=H(K[R].y);T+=`${R===0?"M":"L"}${I.toFixed(1)},${E.toFixed(1)}`}return T}static#b(_=24){let $=(_-11)/2,J=3.6666666666666665;return Array.from({length:16},(Q,j)=>({x:$+j%4*3.6666666666666665,y:$+Math.floor(j/4)*3.6666666666666665}))}static#h(_=24){return b.#b(_).map(({x:Z,y:$})=>S("circle",{cx:Z,cy:$,r:0.5,fill:"var(--figma-color-icon-tertiary)"}))}static#v(_,Z=24,$=[]){return S("svg",{width:Z,height:Z,viewBox:`0 0 ${Z} ${Z}`,fill:"none"},[...$,S("path",{d:_,stroke:"currentColor","stroke-width":"1","stroke-linecap":"round",fill:"none"})])}static#s(_,Z,$,J,Q=24){return b.#v(b.#m(_,Z,$,J,Q),Q,b.#h(Q))}static curveIcon(_,Z,$,J,Q=24){let j=b.#m(_,Z,$,J,Q),q=b.#b(Q).map(({x:N,y:K})=>`<circle cx="${N}" cy="${K}" r="0.5" fill="var(--figma-color-icon-tertiary)"></circle>`).join("");return`<svg width="${Q}" height="${Q}" viewBox="0 0 ${Q} ${Q}" fill="none">${q}<path d="${j}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#r(){return this.getAttribute("edit")!=="false"}#a(){return this.getAttribute("presets")!=="false"}#c(){return this.getAttribute("text")!=="false"}#o(){if(this.classList.toggle("spring-mode",this.#$==="spring"),this.classList.toggle("bezier-mode",this.#$!=="spring"),this.#N0(),this.replaceChildren(...this.#K0()),this.#G0(),this.#K)this.#j0(),this.#l(),this.#$0();this.#J0(),this.#b0()}#i(){return["fig-select","fig-select-options","fig-select-option"].every((_)=>{let Z=customElements.get(_);return typeof Z==="function"&&Z.prototype instanceof HTMLElement})}#p(){let _=L("fig-dropdown",{className:"fig-easing-curve-select",label:"Easing preset",value:this.#U,full:!0}),Z=void 0,$=_;for(let J of b.PRESETS){if(!this.#D(J))continue;if(!this.#r()&&!J.value&&!J.spring)continue;if(J.group!==Z){if(Z=J.group,$=Z?L("optgroup",{label:Z}):_,$!==_)_.appendChild($)}$.appendChild(L("option",{value:J.name},J.name))}return _}#d(){if(!this.#i())return this.#p();let _=document.createElement("fig-select-options"),Z=void 0;for(let $ of b.PRESETS){if(!this.#D($))continue;if(!this.#r()&&!$.value&&!$.spring)continue;if($.group!==Z){if($.group)_.appendChild(L("fig-separator",{label:$.group}));Z=$.group}let J;if($.type==="spring"){let Q=$.spring||this.#J;J=b.#y(Q)}else{let Q=$.value||[this.#Z.x,this.#Z.y,this.#_.x,this.#_.y];J=b.#s(...Q)}_.appendChild(L("fig-select-option",{value:$.name,label:$.name},[L("span",{slot:"prepend"},J),L("span",{},$.name)]))}return L("fig-select",{className:"fig-easing-curve-select",label:"Easing preset",value:this.#U,full:!0},_)}#u(_,Z,$){let J=L("fig-handle",{size:"small",type:"minimal","aria-label":$});return S("foreignObject",{className:_,"data-handle":Z,width:"20",height:"20"},L("fig-tooltip",{text:this.#_0(Z)},J))}#e(_){if(!Number.isFinite(_))return"0";return String(Number(_.toFixed(this.#Q)))}#_0(_){if(this.#$==="spring"){if(_==="bounce")return`Bounce ${this.#e(this.#R0())}`;return`Duration ${Math.round(this.#M*100)}%`}let Z=_==="1"?this.#Z:this.#_;return`${_==="1"?"Start":"End"} ${this.#e(Z.x)}, ${this.#e(Z.y)}`}#Z0(){for(let[_,Z]of[[this.#W,this.#$==="spring"?"bounce":"1"],[this.#X,this.#$==="spring"?"duration":"2"]]){let $=_?.querySelector("fig-tooltip");if($)$.text=this.#_0(Z)}}#n(_,Z){let $=_?.querySelector("fig-tooltip");if(!$)return;if(Z)$.setAttribute("show","true");else $.removeAttribute("show")}#K0(){let Z=this.#a()?this.#d():null;if(!this.#r())return Z?[Z]:[];let $=this.#c()?this.#$==="spring"?L("fig-input-number",{className:"fig-easing-curve-value-input",value:this.#R0().toFixed(2),min:"0",max:"1",step:"0.01",precision:"2","aria-label":"Spring bounce",full:!0}):L("fig-input-text",{className:"fig-easing-curve-value-input",value:this.value,full:!0}):null,J=[S("rect",{className:"fig-easing-curve-bounds",x:"0",y:"0",width:200,height:200})];if(this.#$==="spring")J.push(S("line",{className:"fig-easing-curve-target",x1:"0",y1:40,x2:200,y2:40}),S("path",{className:"fig-easing-curve-path"}),this.#u("fig-easing-curve-handle","bounce","Spring bounce handle"),this.#u("fig-easing-curve-handle fig-easing-curve-duration-bar","duration","Spring duration handle"));else J.push(S("line",{className:"fig-easing-curve-boundary","data-boundary":"top",x1:"0",y1:"0",x2:200,y2:"0"}),S("line",{className:"fig-easing-curve-boundary","data-boundary":"bottom",x1:"0",y1:200,x2:200,y2:200}),S("path",{className:"fig-easing-curve-path"}),S("line",{className:"fig-easing-curve-arm","data-arm":"1"}),S("line",{className:"fig-easing-curve-arm","data-arm":"2"}),this.#u("fig-easing-curve-handle","1","First easing control point"),this.#u("fig-easing-curve-handle","2","Second easing control point"));let Q=S("svg",{viewBox:"0 0 200 200",className:"fig-easing-curve-svg"},J);return[...Z?[Z]:[],L("div",{className:"fig-easing-curve-svg-container"},Q),...$?[$]:[]]}#q0(_,Z){let $=getComputedStyle(this).getPropertyValue(_).trim();if(!$)return Z;let J=Number.parseFloat($);return Number.isFinite(J)?J:Z}#N0(){this.#C=this.#q0("--easing-duration-bar-radius",this.#C)}#G0(){this.#K=this.querySelector(".fig-easing-curve-svg"),this.#q=this.querySelector(".fig-easing-curve-path"),this.#N=this.querySelector('[data-arm="1"]'),this.#G=this.querySelector('[data-arm="2"]'),this.#W=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#X=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#Y=this.querySelector(".fig-easing-curve-select"),this.#R=this.querySelector(".fig-easing-curve-value-input"),this.#B=this.querySelector(".fig-easing-curve-target"),this.#T=this.querySelector(".fig-easing-curve-bounds"),this.#I=this.querySelector('[data-boundary="top"]'),this.#k=this.querySelector('[data-boundary="bottom"]')}#j0(){let _=this.#W?.querySelector("fig-handle"),Z=this.#X?.querySelector("fig-handle");if(_){let $=_.offsetWidth||this.#H*2,J=_.offsetHeight||this.#H*2;this.#H=Math.max($,J)/2,this.#W.setAttribute("width",$),this.#W.setAttribute("height",J)}if(Z){let $=Z.offsetWidth||this.#A,J=Z.offsetHeight||this.#z;if(this.#$==="spring")this.#A=$,this.#z=J;this.#X.setAttribute("width",$),this.#X.setAttribute("height",J)}}#t(){if(this.#F||!window.ResizeObserver)return;this.#F=new ResizeObserver(()=>{if(this.#l())this.#$0()}),this.#F.observe(this)}#l(){if(!this.#K)return!1;let _=this.#K.getBoundingClientRect(),Z=Math.max(1,Math.round(_.width||200)),$=Math.max(1,Math.round(_.height||200)),J=Z!==this.#L||$!==this.#O;return this.#L=Z,this.#O=$,this.#K.setAttribute("viewBox",`0 0 ${Z} ${$}`),J}#W0(){let _=Math.min(0,this.#Z.y,this.#_.y),Z=Math.max(1,this.#Z.y,this.#_.y),$=Z-_||1,J=0;return{minVal:_,maxVal:Z,range:$,pad:0,draw:Math.max(1,this.#O-0)}}#X0(_,Z){let{maxVal:$,range:J,pad:Q,draw:j}=this.#W0();return{x:_*this.#L,y:Q+($-Z)/J*j}}#I0(_,Z){let{maxVal:$,range:J,pad:Q,draw:j}=this.#W0();return{x:_/this.#L,y:$-(Z-Q)/j*J}}#A0={minVal:0,maxVal:1.2,totalTime:1};#Y0(_,Z){let J=this.#O-40,{minVal:Q,maxVal:j}=this.#A0,q=j-Q||1;return{x:_*this.#L,y:20+(1-(Z-Q)/q)*J}}#$0(){if(this.#l(),this.#$==="spring")this.#V0();else this.#E0();this.#Z0()}#F0(){this.#N?.classList.toggle("is-active",this.#$==="bezier"&&this.#j===1),this.#G?.classList.toggle("is-active",this.#$==="bezier"&&this.#j===2)}#E0(){if(this.#T)this.#T.setAttribute("x","0"),this.#T.setAttribute("y","0"),this.#T.setAttribute("width",this.#L),this.#T.setAttribute("height",this.#O);let _=this.#X0(0,0),Z=this.#X0(this.#Z.x,this.#Z.y),$=this.#X0(this.#_.x,this.#_.y),J=this.#X0(1,1);for(let[j,q]of[[this.#I,J.y],[this.#k,_.y]]){if(!j)continue;j.setAttribute("x1","0"),j.setAttribute("y1",q),j.setAttribute("x2",this.#L),j.setAttribute("y2",q)}this.#q.setAttribute("d",`M${_.x},${_.y} C${Z.x},${Z.y} ${$.x},${$.y} ${J.x},${J.y}`),this.#N.setAttribute("x1",_.x),this.#N.setAttribute("y1",_.y),this.#N.setAttribute("x2",Z.x),this.#N.setAttribute("y2",Z.y),this.#G.setAttribute("x1",J.x),this.#G.setAttribute("y1",J.y),this.#G.setAttribute("x2",$.x),this.#G.setAttribute("y2",$.y);let Q=this.#H;this.#W.setAttribute("x",Z.x-Q),this.#W.setAttribute("y",Z.y-Q),this.#X.setAttribute("x",$.x-Q),this.#X.setAttribute("y",$.y-Q),this.#P0()}#P0(){if(!this.#K||!this.#W||!this.#X)return;let _=this.#Z.y>=this.#_.y?[this.#W,this.#X]:[this.#X,this.#W];for(let Z of _)this.#K.append(Z)}#V0(){if(this.#T)this.#T.setAttribute("x","0"),this.#T.setAttribute("y","0"),this.#T.setAttribute("width",this.#L),this.#T.setAttribute("height",this.#O);let _=this.#g();if(!_.length)return;let Z=_[_.length-1].t||1,$=0,J=1;for(let B of _){if(B.value<$)$=B.value;if(B.value>J)J=B.value}let Q=Math.max(Math.abs($-1),Math.abs(J-1),0.01),j=0;this.#A0={minVal:1-Q-j,maxVal:1+Q+j,totalTime:Z};let q=Math.max(0.05,Math.min(1,this.#M)),N="";for(let B=0;B<_.length;B++){let F=_[B].t/Z*q,H=this.#Y0(F,_[B].value);N+=(B===0?"M":"L")+H.x.toFixed(1)+","+H.y.toFixed(1)}let K=this.#Y0(q,1),G=this.#Y0(1,1);if(N+=`L${K.x.toFixed(1)},${K.y.toFixed(1)} L${G.x.toFixed(1)},${G.y.toFixed(1)}`,this.#q.setAttribute("d",N),this.#B){let B=this.#Y0(0,1),F=this.#Y0(1,1);this.#B.setAttribute("x1",B.x),this.#B.setAttribute("y1",B.y),this.#B.setAttribute("x2",F.x),this.#B.setAttribute("y2",F.y)}let X=this.#C0(_),Y=X.t/Z*q,U=this.#Y0(Y,X.value),W=this.#H;this.#W.setAttribute("x",U.x-W),this.#W.setAttribute("y",U.y-W);let O=this.#Y0(q,1);this.#X.setAttribute("x",O.x-this.#A/2),this.#X.setAttribute("y",O.y-this.#z/2)}#C0(_){let Z={t:0,value:1},$=!1;for(let J=1;J<_.length-1;J++){let Q=_[J-1],j=_[J],q=_[J+1];if(j.value>=0.99)$=!0;if($&&j.value>Z.value)Z={t:j.t,value:j.value};if($&&j.value>1&&j.value>=Q.value&&j.value>=q.value)return{t:j.t,value:j.value}}return Z}#U0(){if(!this.#Y)return;this.#Y.value=this.#U,this.#x0()}#J0(){if(!this.#R)return;let _=this.#$==="spring"?this.#R0().toFixed(2):this.value;this.#R.setAttribute("value",_)}#R0(){let{stiffness:_,damping:Z,mass:$}=this.#J,J=2*Math.sqrt(_*$);if(!Number.isFinite(J)||J<=0)return 0;return Math.max(0,Math.min(1,1-Z/J))}#L0(_){let Z=Math.max(0,Math.min(1,Number(_))),$=2*Math.sqrt(this.#J.stiffness*this.#J.mass);this.#J.damping=Number(($*(1-Z)).toFixed(4))}#H0(_,Z){let $=Number(_);if(!Number.isFinite($)){if(Z==="change")this.#J0();return}if(this.#L0($),this.#U=this.#V(),this.#$0(),this.#U0(),Z==="change")this.#J0();this.#Q0(Z)}#S0(_){let Z=_.split(",").map(($)=>Number.parseFloat($.trim()));if(Z.length!==4||Z.some(($)=>!Number.isFinite($)))return null;if(Z[0]<0||Z[0]>1||Z[2]<0||Z[2]>1)return null;return Z}#f0(_){return this.#S(_)}#z0(_,Z){let $=this.#E(),J=$==="bezier"?null:this.#f0(_),Q=$==="spring"?null:this.#S0(_);if(!J&&!Q){if(Z==="change")this.#J0();return}let j=this.#$;if(J)this.#$="spring",this.#J=J;else this.#$="bezier",this.#Z.x=Q[0],this.#Z.y=Q[1],this.#_.x=Q[2],this.#_.y=Q[3];if(this.#U=this.#V(),j!==this.#$)this.#o();else if(this.#$0(),this.#U0(),Z==="change")this.#J0();this.#Q0(Z)}#T0(_,Z){if(!this.#Y)return;for(let $ of this.#Y.querySelectorAll("fig-select-option"))if($.value===_){let J=$.querySelector(':scope > [slot="prepend"]');if(J)J.replaceChildren(Z.cloneNode(!0))}}#x0(){if(!this.#Y)return;if(!this.#r())return;let _=b.#s(this.#Z.x,this.#Z.y,this.#_.x,this.#_.y),Z=b.#y(this.#J);this.#T0("Custom bezier",_),this.#T0("Custom spring",Z)}#k0(_){this.#$0(),this.#U=this.#V(),this.#U0(),this.#J0(),this.#Q0(_)}#w0(_,Z){let $=_.shiftKey?0.1:0.01,J=Z===1?this.#Z:this.#_;switch(_.key){case"ArrowLeft":J.x-=$;break;case"ArrowRight":J.x+=$;break;case"ArrowUp":J.y+=$;break;case"ArrowDown":J.y-=$;break;case"Home":J.x=0,J.y=0;break;case"End":J.x=1,J.y=1;break;default:return!1}return J.x=Math.max(0,Math.min(1,Math.round(J.x*100)/100)),J.y=Math.round(J.y*100)/100,this.#k0("input"),this.#Q0("change"),!0}#y0(_,Z){let $=_.shiftKey?10:1;if(Z==="bounce"){let J=$/100;switch(_.key){case"ArrowUp":this.#L0(this.#R0()+J);break;case"ArrowDown":this.#L0(this.#R0()-J);break;case"Home":this.#L0(0);break;case"End":this.#L0(1);break;default:return!1}}else{let J=$*2;switch(_.key){case"ArrowLeft":this.#M=Math.max(0.05,this.#M-J/200),this.#J.stiffness=Math.max(10,Math.round(this.#J.stiffness+J*1.5));break;case"ArrowRight":this.#M=Math.min(1,this.#M+J/200),this.#J.stiffness=Math.max(10,Math.round(this.#J.stiffness-J*1.5));break;case"Home":this.#M=0.05;break;case"End":this.#M=1;break;default:return!1}}return this.#k0("input"),this.#Q0("change"),!0}#O0(_,Z){let $=_?.querySelector("fig-handle");if(!$)return;$.addEventListener("pointerdown",(J)=>{if(J.preventDefault(),J.stopImmediatePropagation(),this.#$==="bezier")this.#M0(J,Number(Z));else this.#B0(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.#y0(J,Z)))return;J.preventDefault(),J.stopImmediatePropagation()},{capture:!0})}#Q0(_){let Z=this.spring;this.dispatchEvent(new CustomEvent(_,{bubbles:!0,detail:{mode:this.#$,value:this.value,cssValue:this.cssValue,preset:this.#U,...Z?{spring:Z}:{}}}))}#b0(){if(this.#K&&this.#$==="bezier"){this.#O0(this.#W,"1"),this.#O0(this.#X,"2"),this.#W.addEventListener("pointerdown",(Z)=>this.#M0(Z,1)),this.#X.addEventListener("pointerdown",(Z)=>this.#M0(Z,2));let _=this.querySelector(".fig-easing-curve-svg-container");if(_)_.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#M0(Z,this.#h0(Z))})}else if(this.#K){this.#O0(this.#W,"bounce"),this.#O0(this.#X,"duration"),this.#W.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#B0(Z,"bounce")}),this.#X.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#B0(Z,"duration")});let _=this.querySelector(".fig-easing-curve-svg-container");if(_)_.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#B0(Z,"duration")})}if(this.#Y)this.#Y.addEventListener("input",(_)=>{_.stopPropagation()}),this.#Y.addEventListener("optionhover",(_)=>{_.stopPropagation()}),this.#Y.addEventListener("change",(_)=>{_.stopPropagation();let Z=_.detail,$=b.PRESETS.find((J)=>J.name===Z);if(!$)return;if($.type==="bezier"){if($.value)this.#Z.x=$.value[0],this.#Z.y=$.value[1],this.#_.x=$.value[2],this.#_.y=$.value[3];if(this.#U=Z,this.#$!=="bezier")this.#$="bezier",this.#o();else if(this.#K)this.#$0(),this.#J0()}else if($.type==="spring"){if($.spring)this.#J={...$.spring,initialVelocity:0};if(this.#U=Z,this.#$!=="spring")this.#$="spring",this.#o();else if(this.#K)this.#$0(),this.#J0()}this.#Q0("input"),this.#Q0("change")});if(this.#R)this.#R.addEventListener("input",(_)=>{_.stopPropagation();let Z=_.detail??_.target?.value;if(this.#$==="spring")this.#H0(Z,"input");else if(typeof Z==="string")this.#z0(Z,"input")}),this.#R.addEventListener("change",(_)=>{_.stopPropagation();let Z=_.detail??_.target?.value;if(this.#$==="spring")this.#H0(Z,"change");else if(typeof Z==="string")this.#z0(Z,"change")})}#D0(_){let Z=this.#K.getScreenCTM();if(!Z)return{x:0,y:0};let $=Z.inverse();return{x:$.a*_.clientX+$.c*_.clientY+$.e,y:$.b*_.clientX+$.d*_.clientY+$.f}}#h0(_){return this.#D0(_).x<=this.#L/2?1:2}#M0(_,Z){_.preventDefault(),this.#j=Z,this.#F0();let $=Z===1?this.#W:this.#X;this.#n($,!0);let J=this.#K.getBoundingClientRect(),Q=_.clientX,j=_.clientY,q=_.target?.closest?.(".fig-easing-curve-handle, fig-handle"),N=Z===1?this.#Z:this.#_,K=this.#D0(_),G=q?{...N}:this.#I0(K.x,K.y),{range:X,draw:Y}=this.#W0(),U=X/Math.max(1,Y/this.#O*Math.max(1,J.height)),W=(B)=>{if(!this.#j)return;let F={x:G.x+(B.clientX-Q)/Math.max(1,J.width),y:B.shiftKey?Z===1?0:1:G.y-(B.clientY-j)*U};if(F.x=Math.round(F.x*100)/100,F.y=Math.round(F.y*100)/100,F.x=Math.max(0,Math.min(1,F.x)),this.#j===1)this.#Z.x=F.x,this.#Z.y=F.y;else this.#_.x=F.x,this.#_.y=F.y;this.#$0(),this.#U=this.#V(),this.#U0(),this.#J0(),this.#Q0("input")},O=()=>{this.#j=null,this.#F0(),this.#n($,!1),document.removeEventListener("pointermove",W),document.removeEventListener("pointerup",O),this.#Q0("change")};document.addEventListener("pointermove",W),document.addEventListener("pointerup",O)}#B0(_,Z){_.preventDefault(),this.#j=Z,this.classList.toggle("spring-bounce-dragging",Z==="bounce");let $=Z==="bounce"?this.#W:this.#X;this.#n($,!0);let J=this.#R0(),Q=this.#J.stiffness,j=this.#M,q=_.clientY,N=_.clientX,K=(X)=>{if(!this.#j)return;if(Z==="bounce"){let Y=X.clientY-q;this.#L0(J-Y/200)}else{let Y=X.clientX-N;this.#M=Math.max(0.05,Math.min(1,j+Y/200)),this.#J.stiffness=Math.max(10,Math.round(Q-Y*1.5))}this.#$0(),this.#U=this.#V(),this.#U0(),this.#J0(),this.#Q0("input")},G=()=>{this.#j=null,this.classList.remove("spring-bounce-dragging"),this.#n($,!1),document.removeEventListener("pointermove",K),document.removeEventListener("pointerup",G),this.#Q0("change")};document.addEventListener("pointermove",K),document.addEventListener("pointerup",G)}}A("fig-easing-curve",b);class e extends HTMLElement{#Z=0;#_=0;#J="deg";#$=null;#Q=null;#j=null;#K=null;#q=null;#N=null;#G=null;#W=null;#X=null;#Y=null;#R=null;#U=!1;#B=!1;#M=(_)=>this.#n(_);#L=(_)=>this.#K0(_);#O=(_)=>this.#q0(_);#T=(_)=>this.#G0(_);#I=(_)=>this.#j0(_);#k=(_)=>this.#t(_);#F=()=>this.#e();static#H(_,Z=12,$=12,J=7,Q=3,j=0){let q=Number(_),N=Number(j),K=Number.isFinite(q)?q:0,G=Number.isFinite(N)?N:0,X=K-G,Y=X<0?"counterclockwise":"clockwise",U=Math.abs(X);if(U<0.001)return{direction:Y,arc:"",arrow:""};let W=(d)=>`${Number(d.x.toFixed(3))} ${Number(d.y.toFixed(3))}`,O=(d)=>{let J0=d*Math.PI/180;return{x:Z+Math.cos(J0)*J,y:$+Math.sin(J0)*J}},B=X>=0?1:-1,F=Y==="clockwise"?1:0,H=[`M ${W(O(G))}`],T=G,R=Math.floor(U/360);for(let d=0;d<R;d++)T+=B*180,H.push(`A ${J} ${J} 0 0 ${F} ${W(O(T))}`),T+=B*180,H.push(`A ${J} ${J} 0 0 ${F} ${W(O(T))}`);let I=U-R*360;if(I>=0.001)T+=B*I,H.push(`A ${J} ${J} 0 ${I>180?1:0} ${F} ${W(O(T))}`);let E=O(K),V=K*Math.PI/180,C=X>=0?{x:-Math.sin(V),y:Math.cos(V)}:{x:Math.sin(V),y:-Math.cos(V)},w={x:-C.y,y:C.x},f=Q/Math.SQRT2,c={x:E.x-C.x*f+w.x*f,y:E.y-C.y*f+w.y*f},i={x:E.x-C.x*f-w.x*f,y:E.y-C.y*f-w.y*f};return{direction:Y,arc:H.join(" "),arrow:`M ${W(c)} L ${W(E)} L ${W(i)}`}}static#A(_=0,Z=0){let $=e.#H(_,50,50,47,4,Z);return S("svg",{class:"fig-angle-reference",x:"3%",y:"3%",width:"94%",height:"94%",viewBox:"3 3 94 94",fill:"none",overflow:"visible","aria-hidden":"true","data-direction":$.direction},S("path",{class:"fig-angle-reference-path",d:[$.arc,$.arrow].filter(Boolean).join(" "),hidden:!$.arc,fill:"none",stroke:"currentColor","stroke-width":"var(--stroke-width)","stroke-linecap":"round","stroke-linejoin":"round"}))}static rotationIcon(_=0,Z=48){let $=Number.isFinite(Number(Z))?Math.max(1,Number(Z)):48,J=e.#H(_),Q=J.arc?`<path d="${J.arc} ${J.arrow}" fill="none" stroke="currentColor" stroke-width="var(--stroke-width, 1)" stroke-linecap="round" stroke-linejoin="round"></path>`:"";return`<svg width="${$}" height="${$}" viewBox="0 0 24 24" fill="none" data-direction="${J.direction}">${Q}</svg>`}static get observedAttributes(){return["value","default","precision","dial","min","max","step","units","rotations","disabled","aria-label","name"]}connectedCallback(){this.#z(),this.#o()}disconnectedCallback(){this.#N0(),this.#p()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#B)return;if(_==="value"){if(this.#U)return;let J=Number($);if(Number.isFinite(J))this.#d(J,{reflect:!1});return}if(_==="units"&&this.isConnected){let J=this.#m(this.#Z),Q=this.#J;this.#J=this.#E($),this.#f(Q,this.#J),this.#_=this.#C(),this.#d(this.#b(J)),this.#o();return}if(this.#z(),!this.isConnected)return;if(["dial","precision","min","max","step","units","rotations","disabled","aria-label","name"].includes(_)){this.#o();return}this.#d(this.#Z)}get value(){return this.#Z}set value(_){let Z=Number(_);if(!Number.isFinite(Z))return;this.#d(Z)}get defaultValue(){return this.#V()}set defaultValue(_){if(_===null||_===void 0||_===""){this.removeAttribute("default");return}let Z=Number(_);if(Number.isFinite(Z))this.setAttribute("default",String(Z))}get adjacent(){return Math.cos(this.#m(this.#Z)*Math.PI/180)}get opposite(){return Math.sin(this.#m(this.#Z)*Math.PI/180)}focus(_){this.#Q?.focus(_)}#z(){this.#J=this.#E(this.getAttribute("units")),this.#_=this.#C();let _=this.getAttribute("value"),Z=_===null||_.trim()===""?this.#V():Number(_);if(Number.isFinite(Z))this.#Z=this.#w(Z)}#C(){if(!this.hasAttribute("precision")){if(this.#J==="turn")return 3;if(this.#J==="rad")return 2;return 0}let _=Number.parseInt(this.getAttribute("precision"),10);return Number.isFinite(_)?Math.max(0,_):0}#E(_){let Z=String(_||"deg").trim().toLowerCase();if(Z==="°")return"°";return["deg","rad","turn","grad"].includes(Z)?Z:"deg"}#f(_,Z){if(_===Z)return;this.#B=!0;for(let $ of["min","max","default","step"]){let J=this.getAttribute($);if(J===null||J.trim()==="")continue;let Q=Number(J);if(!Number.isFinite(Q))continue;let j=this.#y(this.#g(Q,_),Z);this.setAttribute($,String(j))}this.#B=!1}#D(_,Z=!1){if(!this.hasAttribute(_))return Z;return this.getAttribute(_)?.toLowerCase()!=="false"}#P(){return z(this,"disabled")}#x(){let _=Number(this.getAttribute("min"));return this.hasAttribute("min")&&Number.isFinite(_)?_:null}#S(){let _=Number(this.getAttribute("max"));return this.hasAttribute("max")&&Number.isFinite(_)?_:null}#w(_){let Z=Number(_);if(!Number.isFinite(Z))return this.#Z;let $=this.#x(),J=this.#S();if($!==null)Z=Math.max($,Z);if(J!==null)Z=Math.min(J,Z);return Z}#V(_=this.getAttribute("default")){let Z=_===null||String(_).trim()===""?0:Number(_);return this.#w(Number.isFinite(Z)?Z:0)}#g(_,Z){switch(Z){case"rad":return _*180/Math.PI;case"turn":return _*360;case"grad":return _*0.9;default:return _}}#y(_,Z){switch(Z){case"rad":return _*Math.PI/180;case"turn":return _/360;case"grad":return _/0.9;default:return _}}#m(_){return this.#g(_,this.#J)}#b(_){return this.#y(_,this.#J)}#h(){return this.#J==="deg"?"°":this.#J}#v(){let _=this.#m(this.#Z),Z=_/360,$=Math.round(Z),J=Math.abs(Z-$)<0.0000000001?$:Math.trunc(Z),Q=_-J*360;return{rotations:J,remainder:this.#b(Math.abs(Q)<0.0000000001?0:Q)}}#s(){return this.#D("rotations")?this.#v().remainder:this.#Z}#r(){switch(this.#J){case"rad":return 0.01;case"turn":return 0.001;case"grad":return 0.1;default:return 1}}#a(){let _=Number(this.getAttribute("step"));return this.hasAttribute("step")&&Number.isFinite(_)&&_>0?_:this.#r()}#c(){return this.getAttribute("aria-label")||this.getAttribute("name")||"Angle"}#o(){this.#N0(),this.#p();let _=[],Z=this.#D("rotations")?L("span",{slot:"append",className:"fig-angle-rotations"},L("span",{className:"fig-angle-rotation-value"})):null,$=this.#D("dial",!0),J=L("fig-input-number",{className:"fig-angle-input",variant:$?"ghost":void 0,tabular:!0,name:"angle",value:this.#s(),min:this.#x(),max:this.#S(),step:this.#a(),precision:this.#_,units:this.#h(),disabled:this.#P(),"aria-label":this.#c()},Z);if($){let Q=L("fig-tooltip",{text:"Reset"},L("fig-button",{variant:"ghost",icon:"true",className:"fig-angle-reset",disabled:this.#P(),"aria-label":"Reset to default"},h("reset",{size:"small"}))),j=this.#x()??this.#b(0),q=this.#S()??this.#b(360),N=this.#P(),K=Array.from({length:24},(X,Y)=>{let U=Y*15,W=U*Math.PI/180,O=37,B=U%45===0?31:35;return S("line",{class:U%45===0?"fig-angle-tick fig-angle-tick-major":"fig-angle-tick",x1:50+Math.cos(W)*B,y1:50+Math.sin(W)*B,x2:50+Math.cos(W)*37,y2:50+Math.sin(W)*37})}),G=S("svg",{class:"fig-angle-svg",viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid meet",role:"slider",tabindex:N?"-1":"0","aria-label":this.#c(),"aria-valuemin":j,"aria-valuemax":q,"aria-disabled":N?"true":"false"},[S("rect",{class:"fig-angle-hit-area",x:"0",y:"0",width:"100",height:"100",fill:"transparent"}),S("circle",{class:"fig-angle-boundary",cx:"50",cy:"50",r:"47"}),...K,e.#A(this.#m(this.#Z),this.#m(this.#V())),S("line",{class:"fig-angle-indicator-halo",x1:"75",y1:"50",x2:"87",y2:"50"}),S("line",{class:"fig-angle-indicator",x1:"75",y1:"50",x2:"87",y2:"50"})]);_.push(L("div",{className:"fig-angle-surface"},[G,J,Q]))}else _.push(J);this.replaceChildren(..._),this.#$=this.querySelector(".fig-angle-surface"),this.#Q=this.querySelector(".fig-angle-svg"),this.#j=this.querySelector(".fig-angle-indicator"),this.#K=this.querySelector(".fig-angle-indicator-halo"),this.#q=this.querySelector(".fig-angle-reference"),this.#N=this.querySelector(".fig-angle-input"),this.#G=this.querySelector(".fig-angle-rotations"),this.#W=this.querySelector(".fig-angle-reset"),this.#i(),this.#u()}#i(){this.#X=new AbortController;let _=this.#X.signal;this.#Q?.addEventListener("pointerdown",this.#M,{signal:_}),this.#Q?.addEventListener("pointermove",this.#L,{signal:_}),this.#Q?.addEventListener("pointerup",this.#O,{signal:_}),this.#Q?.addEventListener("pointercancel",this.#O,{signal:_}),this.#Q?.addEventListener("lostpointercapture",this.#O,{signal:_}),this.#Q?.addEventListener("keydown",this.#T,{signal:_}),this.#N?.addEventListener("input",this.#I,{signal:_}),this.#N?.addEventListener("change",this.#I,{signal:_}),this.#W?.addEventListener("click",this.#F,{signal:_}),this.addEventListener("change",this.#k,{capture:!0,signal:_})}#p(){this.#X?.abort(),this.#X=null}#d(_,{reflect:Z=!0}={}){let $=this.#w(_);if(this.#Z=$,Z){let J=String($);if(this.getAttribute("value")!==J)this.#U=!0,this.setAttribute("value",J),this.#U=!1}this.#u()}#u(){let _=this.#m(this.#Z),$=`rotate(${(_%360+360)%360} 50 50)`;this.#j?.setAttribute("transform",$),this.#K?.setAttribute("transform",$);let J=this.#m(this.#V()),Q=e.#H(_,50,50,47,4,J);this.#q?.setAttribute("data-direction",Q.direction);let j=this.#q?.querySelector(".fig-angle-reference-path");if(j?.setAttribute("d",[Q.arc,Q.arrow].filter(Boolean).join(" ")),j?.toggleAttribute("hidden",!Q.arc),this.#Q){let q=this.#b(0),N=this.#b(360);this.#Q.setAttribute("aria-valuemin",String(this.#x()??Math.min(q,this.#Z))),this.#Q.setAttribute("aria-valuemax",String(this.#S()??Math.max(N,this.#Z))),this.#Q.setAttribute("aria-valuenow",String(this.#Z)),this.#Q.setAttribute("aria-valuetext",`${this.#Z.toFixed(this.#_)}${this.#h()}`)}if(this.#N){let q=this.#s().toFixed(this.#_);if(this.#N.getAttribute("value")!==q)this.#N.setAttribute("value",q)}if(this.#G){let{rotations:q}=this.#v(),N=this.#G.querySelector(".fig-angle-rotation-value");if(N)N.textContent=q?`×${q}`:"";this.#G.hidden=q===0}if(this.#W)this.#W.hidden=this.#Z===this.#V()}#e(){if(this.#P())return;this.#d(this.#V()),this.#l("input"),this.#l("change")}#_0(_){let Z=this.#$.getBoundingClientRect(),$=Z.left+Z.width/2,J=Z.top+Z.height/2,Q=_.clientX-$,j=_.clientY-J;if(Math.hypot(Q,j)<Math.min(Z.width,Z.height)*0.08)return null;let q=Math.atan2(j,Q)*180/Math.PI;if(q=(q%360+360)%360,_.shiftKey)q=Math.round(q/15)*15;return q}#Z0(_){let Z=this.#_0(_);if(Z===null)return;let $=this.#m(this.#Z),J;if(this.#R===null){let Q=($%360+360)%360;J=Z-Q}else J=Z-this.#R;if(J>180)J-=360;if(J<-180)J+=360;this.#R=Z,this.#d(this.#b($+J)),this.#l("input")}#n(_){if(this.#P()||_.button!==0)return;_.preventDefault(),this.#Q?.focus({preventScroll:!0}),this.#Y=_.pointerId,this.#R=null,this.#$.classList.add("dragging");try{this.#Q.setPointerCapture?.(_.pointerId)}catch{}this.#Z0(_)}#K0(_){if(_.pointerId!==this.#Y)return;if(_.buttons===0){this.#q0(_);return}this.#Z0(_)}#q0(_){if(_.pointerId!==this.#Y)return;let Z=this.#Y;if(this.#Y=null,this.#R=null,this.#$?.classList.remove("dragging"),this.#Q?.hasPointerCapture?.(Z))this.#Q.releasePointerCapture(Z);this.#l("change")}#N0(){this.#Y=null,this.#R=null,this.#$?.classList.remove("dragging")}#G0(_){if(this.#P())return;let Z=this.#Z,$=_.key==="ArrowLeft"||_.key==="ArrowDown"?-1:_.key==="ArrowRight"||_.key==="ArrowUp"?1:0;if($){let J=_.shiftKey?this.#b(15):this.#a();Z+=$*J}else if(_.key==="Home")Z=this.#x()??this.#b(0);else if(_.key==="End")Z=this.#S()??this.#b(360);else return;_.preventDefault(),_.stopPropagation(),this.#d(Z),this.#l("input"),this.#l("change")}#j0(_){if(_.stopPropagation(),this.#P())return;let Z=Number(_.currentTarget.value);if(!Number.isFinite(Z))return;if(this.#D("rotations")){let{rotations:$}=this.#v();this.#d(this.#b($*360+this.#m(Z)))}else this.#d(Z);this.#l(_.type)}#t(_){if(!_.target?.matches?.("input"))return;let Z=String(_.target.value).match(/^(-?\d*\.?\d+)\s*(deg|°|rad|turn|grad)$/i);if(!Z)return;let $=Number(Z[1]),J=this.#E(Z[2]),Q=$;if(J==="rad")Q=$*180/Math.PI;else if(J==="turn")Q=$*360;else if(J==="grad")Q=$*0.9;_.target.value=String(this.#b(Q))}#l(_){let Z=Number(this.value.toFixed(this.#_));this.dispatchEvent(new CustomEvent(_,{bubbles:!0,cancelable:!0,detail:{value:Z,angle:Z,units:this.#J}}))}}A("fig-angle",e);class f_ extends HTMLElement{#Z=0;#_=0;#J=0;#$=1;#Q=!1;#j=!1;#K=null;#q=null;#N=null;#G=null;#W=(_)=>this.#P(_);#X=null;#Y=[];#R={};#U={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#$=parseInt(this.getAttribute("precision")||"1"),p(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),p(this,"--perspective",this.getAttribute("perspective")),p(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#L(this.getAttribute("transform-origin")),this.#I(this.getAttribute("fields"));let _=this.getAttribute("value");if(_)this.#k(_);if(this.querySelector(".fig-3d-rotate-container"))this.#B();else this.#F();this.#T(this.getAttribute("selected")),this.#O()}disconnectedCallback(){this.#Q=!1,this.#M()}#B(){this.#q=this.querySelector(".fig-3d-rotate-container"),this.#K=this.querySelector(".fig-3d-rotate-cube"),this.#H(),this.#z(),this.#f()}#M(){if(this.#X?.abort(),this.#X=null,this.#N)window.removeEventListener("keydown",this.#N),window.removeEventListener("keyup",this.#G),this.#N=null,this.#G=null}#L(_){if(!_||!_.trim()){this.style.removeProperty("--transform-origin");return}let Z=_.trim().split(/\s+/);if(Z.length===2)this.style.setProperty("--transform-origin",`${Z[0]} ${Z[1]} -50cqi`);else this.style.setProperty("--transform-origin",_.trim())}#O(){if(!this.#q)return;this.#q.style.cursor=this.#D?"":"default"}#T(_){if(!this.#K)return;let Z=this.#K.querySelectorAll(".fig-3d-rotate-face"),$=_?_.trim().toLowerCase():"";for(let J of Z)J.classList.toggle("selected",$!==""&&J.classList.contains($))}#I(_){if(!_||!_.trim()){this.#Y=[];return}let Z=["rotateX","rotateY","rotateZ"];this.#Y=_.split(",").map(($)=>$.trim()).filter(($)=>Z.includes($))}attributeChangedCallback(_,Z,$){if(_==="aspect-ratio"){p(this,"--aspect-ratio",$);return}if(_==="perspective"){p(this,"--perspective",$);return}if(_==="perspective-origin"){p(this,"--perspective-origin",$);return}if(_==="transform-origin"){this.#L($);return}if(_==="selected"){this.#T($);return}if(_==="drag"){this.#O();return}if(_==="fields"){if(this.#I($),this.#K)this.#F();return}if(!this.#K)return;if(_==="value"&&$){if(this.#Q)return;this.#k($),this.#z(),this.#A()}if(_==="precision")this.#$=parseInt($||"1")}get value(){let _=this.#$;return`rotateX(${this.#Z.toFixed(_)}deg) rotateY(${this.#_.toFixed(_)}deg) rotateZ(${this.#J.toFixed(_)}deg)`}set value(_){this.setAttribute("value",_)}get rotateX(){return this.#Z}get rotateY(){return this.#_}get rotateZ(){return this.#J}#k(_){let Z=_.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),$=_.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),J=_.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if(Z)this.#Z=parseFloat(Z[1]);if($)this.#_=parseFloat($[1]);if(J)this.#J=parseFloat(J[1])}#F(){let _={rotateX:"X",rotateY:"Y",rotateZ:"Z"},Z={rotateX:this.#Z,rotateY:this.#_,rotateZ:this.#J},$=L("div",{className:"fig-3d-rotate-cube"},["front","back","right","left","top","bottom"].map((j)=>L("div",{className:`fig-3d-rotate-face ${j}`}))),J=L("div",{className:"fig-3d-rotate-container",tabindex:"0"},L("div",{className:"fig-3d-rotate-scene"},$)),Q=this.#Y.map((j)=>L("fig-input-number",{name:j,step:"1",precision:"1",value:Z[j],units:"°"},L("span",{slot:"prepend"},_[j])));this.replaceChildren(J,...Q),this.#q=J,this.#K=$,this.#H(),this.#z(),this.#f()}#H(){this.#R={};for(let _ of this.#Y){let Z=this.querySelector(`fig-input-number[name="${_}"]`);if(!Z)continue;if(this.#R[_]=Z,!this.#U[_])this.#U[_]=(J)=>{J.stopPropagation();let Q=parseFloat(J.target.value);if(isNaN(Q))return;if(_==="rotateX")this.#Z=Q;else if(_==="rotateY")this.#_=Q;else if(_==="rotateZ")this.#J=Q;this.#z(),this.#C(J.type)};let $=this.#U[_];Z.removeEventListener("input",$),Z.removeEventListener("change",$),Z.addEventListener("input",$),Z.addEventListener("change",$)}}#A(){let _={rotateX:this.#Z,rotateY:this.#_,rotateZ:this.#J};for(let Z of this.#Y){let $=this.#R[Z];if($)$.setAttribute("value",_[Z].toFixed(this.#$))}}#z(){if(!this.#K)return;this.#K.style.transform=`rotateX(${this.#Z}deg) rotateY(${this.#_}deg) rotateZ(${this.#J}deg)`}#C(_){this.dispatchEvent(new CustomEvent(_,{bubbles:!0,detail:{value:this.value,rotateX:this.#Z,rotateY:this.#_,rotateZ:this.#J}}))}#E(_){if(!this.#j)return _;return Math.round(_/15)*15}#f(){if(this.#M(),!this.#q)return;this.#X=new AbortController,this.#q.addEventListener("pointerdown",this.#W,{signal:this.#X.signal}),this.#N=(_)=>{if(_.key==="Shift")this.#j=!0},this.#G=(_)=>{if(_.key==="Shift")this.#j=!1},window.addEventListener("keydown",this.#N),window.addEventListener("keyup",this.#G)}get#D(){let _=this.getAttribute("drag");return _===null||_.toLowerCase()!=="false"}#P(_){if(!this.#D)return;_.preventDefault(),this.#Q=!0,this.#q.classList.add("dragging"),this.#q.setPointerCapture(_.pointerId);let{clientX:Z,clientY:$}=_,J=this.#Z,Q=this.#_,j=(N)=>{if(!this.#Q)return;if(N.buttons===0){q();return}let K=N.clientX-Z,G=N.clientY-$;this.#_=this.#E(Q+K*0.5),this.#Z=this.#E(J-G*0.5),this.#z(),this.#A(),this.setAttribute("value",this.value),this.#C("input")},q=()=>{if(!this.#Q)return;this.setAttribute("value",this.value),this.#Q=!1,this.#q.classList.remove("dragging"),this.#q.removeEventListener("pointermove",j),this.#q.removeEventListener("pointerup",q),this.#q.removeEventListener("pointercancel",q),this.#q.removeEventListener("lostpointercapture",q),this.#C("change")};this.#q.addEventListener("pointermove",j),this.#q.addEventListener("pointerup",q),this.#q.addEventListener("pointercancel",q),this.#q.addEventListener("lostpointercapture",q)}}A("fig-3d-rotate",f_);class E0 extends HTMLElement{#Z=50;#_=50;#J=0;#$=null;#Q=[];#j=null;#K=null;#q=null;#N=!1;#G=!1;#W=null;#X=null;#Y=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"]}#R(){this.#$=this.querySelector(".origin-grid"),this.#Q=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#j=this.querySelector("fig-handle"),this.#K=this.querySelector('fig-input-number[name="x"]'),this.#q=this.querySelector('fig-input-number[name="y"]'),this.#z(),this.#C(),this.#F(),this.#v()}connectedCallback(){if(this.#J=parseInt(this.getAttribute("precision")||"0"),p(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#I(this.getAttribute("value")),this.querySelector(".fig-origin-grid-surface"))this.#R();else this.#k();this.#M(),this.#H()}disconnectedCallback(){this.#N=!1,this.#y(),this.#h()}get value(){let _=this.#J;return`${this.#Z.toFixed(_)}% ${this.#_.toFixed(_)}%`}set value(_){this.setAttribute("value",_)}attributeChangedCallback(_,Z,$){if(_==="aspect-ratio"){p(this,"--aspect-ratio",$);return}if(_==="drag"){this.#M();return}if(_==="fields"){this.#k(),this.#M(),this.#H();return}if(_==="precision"){this.#J=parseInt($||"0"),this.#F(),this.#H();return}if(_==="value"){if(this.#G||this.#N)return;this.#I($),this.#z(),this.#C(),this.#F()}}get#U(){let _=this.getAttribute("drag");return _===null||_.toLowerCase()!=="false"}get#B(){let _=this.getAttribute("fields");if(_===null)return!1;return _.toLowerCase()!=="false"}#M(){if(!this.#$)return;this.#$.classList.toggle("drag-disabled",!this.#U)}#L(_){return Math.max(0,Math.min(100,_))}#O(_,Z){let $=(_||"").trim().toLowerCase();if(!$)return Z==="x"?this.#Z:this.#_;let J=Z==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if($ in J)return J[$];let Q=Number.parseFloat($.replace("%",""));if(Number.isFinite(Q))return Q;return Z==="x"?this.#Z:this.#_}#T(_){let Z=_.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if(Z.length<1)return;if(Z.length===1){let $=this.#O(Z[0],"x");this.#Z=$,this.#_=$;return}this.#Z=this.#O(Z[0],"x"),this.#_=this.#O(Z[1],"y")}#I(_){let Z=typeof _==="string"?_.trim():"";if(!Z){this.#Z=50,this.#_=50;return}this.#T(Z)}#k(){let _=Array.from({length:9},(N,K)=>{let G=K%3,X=Math.floor(K/3);return L("span",{className:"origin-grid-cell","data-col":G,"data-row":X},L("span",{className:"origin-grid-dot"}))}),Z=this.#Z.toFixed(this.#J),$=this.#_.toFixed(this.#J),J=document.createElement("fig-handle"),Q=L("div",{className:"origin-grid","aria-label":"Transform origin grid"},[L("div",{className:"origin-grid-cells"},_),J]),q=[L("div",{className:"fig-origin-grid-surface"},Q)];if(this.#B){let N=(K,G)=>L("fig-input-number",{name:K,value:G,step:"1",units:"%"},L("span",{slot:"prepend"},K.toUpperCase()));q.push(L("div",{className:"origin-values"},[N("x",Z),N("y",$)]))}this.replaceChildren(...q),this.#$=Q,this.#Q=_,this.#j=J,this.#K=this.querySelector('fig-input-number[name="x"]'),this.#q=this.querySelector('fig-input-number[name="y"]'),this.#z(),this.#C(),this.#F(),this.#v()}#F(){let _=this.#Z.toFixed(this.#J),Z=this.#_.toFixed(this.#J);if(this.#K)this.#K.setAttribute("value",_);if(this.#q)this.#q.setAttribute("value",Z)}#H(){let _=this.value;if(this.getAttribute("value")===_)return;this.#G=!0,this.setAttribute("value",_),this.#G=!1}#A(_){this.dispatchEvent(new CustomEvent(_,{bubbles:!0,detail:{value:this.value,x:this.#Z,y:this.#_}}))}#z(){if(!this.#j)return;let _=(Z)=>16.6667+this.#L(Z)/100*66.6667;this.#j.style.left=`${_(this.#Z)}%`,this.#j.style.top=`${_(this.#_)}%`}#C(){if(!this.#j)return;let _=this.#Z<0||this.#Z>100,Z=this.#_<0||this.#_>100,$=this.#Z<0,J=this.#Z>100,Q=this.#_<0,j=this.#_>100;this.#j.classList.toggle("beyond-bounds-x",_),this.#j.classList.toggle("beyond-bounds-y",Z),this.#j.classList.toggle("overflow-left",$),this.#j.classList.toggle("overflow-right",J),this.#j.classList.toggle("overflow-up",Q),this.#j.classList.toggle("overflow-down",j)}#E(_,Z){if(!this.#$)return null;let $=this.#$.getBoundingClientRect(),J=(_-$.left)/Math.max($.width,1),Q=(Z-$.top)/Math.max($.height,1);if(J<0||J>1||Q<0||Q>1)return null;let j=Math.max(0,Math.min(2,Math.floor(J*3))),q=Math.max(0,Math.min(2,Math.floor(Q*3)));return this.#Q.find((N)=>Number(N.getAttribute("data-col"))===j&&Number(N.getAttribute("data-row"))===q)}#f(){for(let _ of this.#Q)_.classList.remove("is-hovered")}#D(_){if(this.#f(),_)_.classList.add("is-hovered")}#P(_,Z,$){let J=Number(_),Q=Number(Z);if(!Number.isFinite(J)||!Number.isFinite(Q))return;if(J===this.#Z&&Q===this.#_&&$==="input")return;this.#Z=J,this.#_=Q,this.#z(),this.#C(),this.#F(),this.#H(),this.#A($)}#x(_,Z){if(!this.#$)return{x:this.#Z,y:this.#_};let $=this.#$.getBoundingClientRect(),J=$.width/6,Q=$.height/6,j=Math.max(1,$.width-J*2),q=Math.max(1,$.height-Q*2),N=(_-($.left+J))/j,K=(Z-($.top+Q))/q;return{x:N*100,y:K*100}}#S(_,Z){if(!this.#$)return{x:50,y:50};let $=this.#$.getBoundingClientRect(),J=(_-$.left)/Math.max($.width,1)*3,Q=(Z-$.top)/Math.max($.height,1)*3,j=Math.max(0,Math.min(2,Math.floor(J))),q=Math.max(0,Math.min(2,Math.floor(Q)));return{x:j*50,y:q*50}}#w(_){let $=_,J=1/0;for(let Q of E0.SNAP_POINTS){let j=Math.abs(_-Q);if(j<J)J=j,$=Q}return J<=2.5?$:_}#V(_,Z){if(!Z)return _;return{x:this.#w(_.x),y:this.#w(_.y)}}#g(_){if(!this.#U)return!1;let Z=_.shiftKey?10:1,$=this.#Z,J=this.#_;switch(_.key){case"ArrowLeft":$-=Z;break;case"ArrowRight":$+=Z;break;case"ArrowUp":J-=Z;break;case"ArrowDown":J+=Z;break;case"Home":$=0,J=0;break;case"End":$=100,J=100;break;default:return!1}return this.#P(this.#L($),this.#L(J),"input"),this.#A("change"),!0}#y(){if(!this.#$||!this.#X||!this.#Y)return;this.#$.removeEventListener("pointermove",this.#X),this.#$.removeEventListener("pointerup",this.#Y),this.#$.removeEventListener("pointercancel",this.#Y),this.#$.removeEventListener("lostpointercapture",this.#Y),this.#X=null,this.#Y=null}#m(_){if(!this.#$||!this.#U)return;_.preventDefault(),this.#N=!0,this.#W=_.pointerId;let{clientX:Z,clientY:$}=_,J=3,Q=!1;this.#$.setPointerCapture(_.pointerId),this.#X=(j)=>{if(!this.#N||j.pointerId!==this.#W)return;let q=j.clientX-Z,N=j.clientY-$,K=Math.hypot(q,N);if(!Q&&K<J)return;if(!Q)Q=!0,this.#$.classList.add("is-dragging"),this.#f();let G=this.#V(this.#x(j.clientX,j.clientY),j.shiftKey);this.#P(G.x,G.y,"input")},this.#Y=(j)=>{if(!this.#N||j.pointerId!==this.#W)return;if(this.#N=!1,this.#W=null,this.#$.classList.remove("is-dragging"),this.#f(),this.#y(),!Q){let q=this.#S(Z,$);this.#P(q.x,q.y,"input")}this.#A("change")},this.#$.addEventListener("pointermove",this.#X),this.#$.addEventListener("pointerup",this.#Y),this.#$.addEventListener("pointercancel",this.#Y),this.#$.addEventListener("lostpointercapture",this.#Y)}#b=null;#h(){this.#b?.abort(),this.#b=null}#v(){if(this.#h(),!this.#$||!this.#j)return;this.#b=new AbortController;let{signal:_}=this.#b;this.#$.addEventListener("pointerdown",($)=>{let J=this.#E($.clientX,$.clientY);if(this.#D(J),this.#U){this.#m($);return}let Q=this.#S($.clientX,$.clientY);this.#P(Q.x,Q.y,"input"),this.#A("change")},{signal:_}),this.#$.addEventListener("pointermove",($)=>{if(this.#N)return;let J=this.#E($.clientX,$.clientY);this.#D(J)},{signal:_}),this.#$.addEventListener("pointerleave",()=>{this.#f()},{signal:_}),this.#j.addEventListener("keydown",($)=>{if(!this.#g($))return;$.preventDefault(),$.stopPropagation()},{signal:_});let Z=($,J)=>{if(!$)return;let Q=(j)=>{let q=Number.parseFloat(j.target.value);if(!Number.isFinite(q))return;if(J==="x")this.#P(q,this.#_,"input");else this.#P(this.#Z,q,"input")};$.addEventListener("input",Q,{signal:_}),$.addEventListener("change",Q,{signal:_}),$.addEventListener("focusout",()=>{this.#A("change")},{signal:_})};Z(this.#K,"x"),Z(this.#q,"y")}}A("fig-origin-grid",E0);class x_ extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#K=null;#q=null;#N=!1;#G={x:0.5,y:0.5};#W=!1;constructor(){super();this.position={x:0.5,y:0.5},this.isDragging=!1,this.plane=null,this.cursor=null,this.xInput=null,this.yInput=null,this.coordinates="screen",this.#Z=(_)=>this.#F(_),this.#_=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#J=(_)=>this.#H(_),this.#$=()=>this.#A(),this.#Q=(_)=>this.#O(_),this.#j=(_)=>this.#T(_),this.#K=()=>this.#I(),this.#q=()=>this.#I()}#X(){this.#M(),this.#E(),this.#D(),this.#P(),this.#W=!0}connectedCallback(){u(this,()=>{if(this.precision=this.getAttribute("precision")||3,this.precision=parseInt(this.precision),this.transform=this.getAttribute("transform")||1,this.transform=Number(this.transform),this.coordinates=this.getAttribute("coordinates")||"screen",p(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");if(this.querySelector(".fig-input-joystick-plane")){this.#X();return}this.#U(),this.#M(),this.#E(),this.#D(),this.#P(),this.#W=!0})}#Y(_){return this.coordinates==="math"?1-_:_}disconnectedCallback(){this.#L()}get#R(){let _=this.getAttribute("fields");if(_===null)return!1;return _.toLowerCase()!=="false"}#U(){let _=this.#B(),Z=L("div",{className:"fig-input-joystick-plane-container"}),$=(q,N)=>N?L("label",{className:["fig-joystick-axis-label",q].join(" "),"aria-hidden":"true"},N):null;Z.append(...[$("left",_.left),$("right",_.right),$("top",_.top),$("bottom",_.bottom)].filter(Boolean));let J=L("div",{className:"fig-input-joystick-plane"},[L("div",{className:"fig-input-joystick-guides"}),L("fig-handle",{drag:!0,"drag-surface":".fig-input-joystick-plane","drag-axes":"x,y","drag-snapping":"modifier"})]),Q=L("fig-tooltip",{text:"Reset"},L("fig-button",{variant:"ghost",icon:"true",className:"fig-joystick-reset","aria-label":"Reset to default"},h("reset",{size:"small"})));Z.append(J,Q);let j=[Z];if(this.#R){let q=(N,K)=>L("fig-input-number",{name:N,step:"1",value:K,min:"0",max:"100",units:"%"},L("span",{slot:"prepend"},N.toUpperCase()));j.push(L("div",{className:"joystick-values"},[q("x",(this.position.x*100).toFixed(this.precision)),q("y",(this.position.y*100).toFixed(this.precision))]))}this.replaceChildren(...j)}#B(){let _=(this.getAttribute("axis-labels")||"").trim();if(!_)return{left:"",right:"",top:"",bottom:""};let Z=_.split(/[\s,]+/).filter(Boolean);if(Z.length===1)return{left:"",right:"",top:Z[0],bottom:""};if(Z.length===2){let[$,J]=Z;return{left:$,right:"",top:"",bottom:J}}if(Z.length===4){let[$,J,Q,j]=Z;return{left:$,right:J,top:Q,bottom:j}}return{left:"",right:"",top:"",bottom:""}}#M(){this.plane=this.querySelector(".fig-input-joystick-plane"),this.cursor=this.querySelector("fig-handle"),this.xInput=this.querySelector("fig-input-number[name='x']"),this.yInput=this.querySelector("fig-input-number[name='y']"),this.plane?.addEventListener("pointerdown",this.#Z),this.cursor?.addEventListener("pointerdown",this.#_),this.cursor?.addEventListener("input",this.#J),this.cursor?.addEventListener("change",this.#$);let _=this.querySelector(".fig-joystick-reset");if(_)_.addEventListener("click",()=>this.#x());if(this.#R&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#Q),this.xInput.addEventListener("change",this.#Q),this.xInput.addEventListener("focusout",this.#K),this.yInput.addEventListener("input",this.#j),this.yInput.addEventListener("change",this.#j),this.yInput.addEventListener("focusout",this.#q)}#L(){if(this.plane?.removeEventListener("pointerdown",this.#Z),this.cursor?.removeEventListener("pointerdown",this.#_),this.cursor?.removeEventListener("input",this.#J),this.cursor?.removeEventListener("change",this.#$),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#R&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#Q),this.xInput.removeEventListener("change",this.#Q),this.xInput.removeEventListener("focusout",this.#K),this.yInput.removeEventListener("input",this.#j),this.yInput.removeEventListener("change",this.#j),this.yInput.removeEventListener("focusout",this.#q)}#O(_){let Z=Number.parseFloat(_.target.value);if(!Number.isFinite(Z))return;this.position.x=Math.max(0,Math.min(1,Z/100)),this.#E(),this.#D(),this.#z()}#T(_){let Z=Number.parseFloat(_.target.value);if(!Number.isFinite(Z))return;this.position.y=Math.max(0,Math.min(1,Z/100)),this.#E(),this.#D(),this.#z()}#I(){this.#D(),this.#C()}#k(_,Z,{syncHandle:$=!0}={}){let J=Math.max(0,Math.min(1,_)),Q=Math.max(0,Math.min(1,Z)),j=this.coordinates==="math"?1-Q:Q;if(this.position={x:J,y:j},$)this.#E();this.#f(),this.#D()}#F(_){if(!this.plane||!this.cursor)return;if(_.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let Z=this.plane.getBoundingClientRect(),$=Z.width>0?(_.clientX-Z.left)/Z.width:0.5,J=Z.height>0?(_.clientY-Z.top)/Z.height:0.5;this.cursor.value=`${Math.round($*100)}% ${Math.round(J*100)}%`,this.#k($,J,{syncHandle:!1}),this.#z(),this.#C()}#H(_){let Z=_.detail??{};if(typeof Z.px!=="number"||typeof Z.py!=="number")return;this.#k(Z.px,Z.py,{syncHandle:!1}),this.#z()}#A(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#D(),this.#C()}#z(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#C(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#E(){let _=this.#Y(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${_*100}%`;this.#f()}#f(){if(this.#R&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#D(){let _=this.value;if(this.getAttribute("value")!==_)this.#N=!0,this.setAttribute("value",_),this.#N=!1;this.#P()}#P(){let _=this.#G,Z=Math.round(this.position.x*100)===Math.round(_.x*100)&&Math.round(this.position.y*100)===Math.round(_.y*100);this.toggleAttribute("default",Z),this.style.setProperty("--is-not-default",Z?"0":"1")}#x(){this.position={...this.#G},this.#E(),this.#D(),this.#z(),this.#C()}focus(){this.cursor?.focus()}static get observedAttributes(){return["value","precision","transform","fields","coordinates","aspect-ratio","axis-labels"]}get value(){return`${Math.round(this.position.x*100)}% ${Math.round(this.position.y*100)}%`}set value(_){let Z=_==null?"":String(_).trim();if(!Z)this.position={x:0.5,y:0.5};else{let $=Z.split(/[\s,]+/).filter(Boolean),J=(q)=>{if(!q)return 0.5;let N=q.includes("%"),K=Number.parseFloat(q.replace(/%/g,"").trim());if(!Number.isFinite(K))return 0.5;let G=N||Math.abs(K)>1?K/100:K;return Math.max(0,Math.min(1,G))},Q=J($[0]),j=J($[1]??$[0]);this.position={x:Q,y:j}}if(this.#W)this.#E(),this.#P()}attributeChangedCallback(_,Z,$){if(_==="aspect-ratio"){p(this,"--aspect-ratio",$);return}if(_==="value"){if(this.#N||this.isDragging)return;this.value=$}if(_==="precision")this.precision=parseInt($);if(_==="transform")this.transform=Number($);if(_==="fields"&&$!==Z)this.#L(),this.#U(),this.#M(),this.#E();if(_==="axis-labels"&&$!==Z)this.#L(),this.#U(),this.#M(),this.#E();if(_==="coordinates")this.coordinates=$||"screen",this.#E()}}A("fig-joystick",x_);class P0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let _=this.getAttribute("duration");if(_)this.style.setProperty(this.durationPropertyName,_);this.#Z()}static get observedAttributes(){return["duration","playing","aria-label","aria-labelledby"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(_){if(_)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(_,Z,$){if(_==="duration")this.style.setProperty(this.durationPropertyName,$||"1.5s");if(_==="playing"||_==="aria-label"||_==="aria-labelledby")this.#Z()}#Z(){let _=this.playing;if(this.setAttribute("aria-busy",_?"true":"false"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")){if(!this.hasAttribute("role"))this.setAttribute("role","status");this.removeAttribute("aria-hidden")}else this.removeAttribute("role"),this.setAttribute("aria-hidden","true")}}A("fig-shimmer",P0);class w_ extends P0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}A("fig-skeleton",w_);class y_ extends HTMLElement{static observedAttributes=["name","collapsible","open","compact","chevron"];#Z=null;#_=null;#J=null;#$=null;#Q=null;connectedCallback(){this.#X()}disconnectedCallback(){this.#j()}#j(){if(this.#_?.removeEventListener("click",this.#G),this.#J?.removeEventListener("click",this.#G),this.#J?.removeEventListener("keydown",this.#W),this.#Z)this.#Z.removeEventListener("click",this.#G),this.#Z.removeEventListener("keydown",this.#W)}attributeChangedCallback(_,Z,$){if(Z===$)return;if(!this.isConnected)return;if(_==="open"){this.#K();return}this.#X()}get open(){let _=this.getAttribute("open");return _!==null&&_!=="false"}set open(_){let Z=this.open;if(_)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#K(),Z!==!!_)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!_},bubbles:!0}))}#K(){if(this.hasAttribute("collapsible"))this.#J?.setAttribute("aria-expanded",String(this.open));else this.#J?.removeAttribute("aria-expanded")}#q(){if(!this.#$)return;if(this.#Q===null)this.#$.removeAttribute("compact");else this.#$.setAttribute("compact",this.#Q);this.#$=null,this.#Q=null}#N(){if(!(this.hasAttribute("compact")&&this.getAttribute("compact")!=="false")){this.#q();return}if(this.#$!==this.#Z)this.#q(),this.#$=this.#Z,this.#Q=this.#Z?.getAttribute("compact")??null;this.#Z?.setAttribute("compact","")}#G=(_)=>{_.stopPropagation(),this.open=!this.open};#W=(_)=>{if(_.key!=="Enter"&&_.key!==" ")return;_.preventDefault(),_.stopPropagation(),this.open=!this.open};#X(){this.#j();let _=this.hasAttribute("collapsible"),$=this.getAttribute("name")||(_?"Group":null),J=this.querySelector(":scope > fig-header:not([data-generated])");if(!$&&!_&&!J){if(this.#Z&&this.#Z.dataset.generated)this.#q(),this.#Z.remove(),this.#Z=null,this.#_=null,this.#J=null;return}if(J)this.querySelectorAll(":scope > fig-header[data-generated]").forEach((j)=>j.remove()),this.#Z=J;else if(!this.#Z||!this.#Z.dataset.generated)this.#Z=document.createElement("fig-header"),this.#Z.setAttribute("borderless",""),this.#Z.dataset.generated="true",this.prepend(this.#Z);this.#N();let Q=this.#Z.querySelector("h3");if(!Q)Q=document.createElement("h3"),this.#Z.prepend(Q);if(this.#J=Q,!Q.id)Q.id=g();if(this.#Z.dataset.generated)Q.textContent=$;if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",Q.id);if(_){let j=this.#Z.querySelector(".fig-group-chevron");if(!j)j=h("chevron",{size:"small",className:"fig-group-chevron"});let q=this.getAttribute("chevron")==="end";if(j.setAttribute("size",q?"medium":"small"),q){if(Q.nextSibling!==j)this.#Z.insertBefore(j,Q.nextSibling)}else if(Q.previousSibling!==j)this.#Z.insertBefore(j,Q);if(this.#_=j,this.#Z.removeAttribute("role"),this.#Z.removeAttribute("tabindex"),this.#Z.removeAttribute("aria-expanded"),Q.setAttribute("role","button"),Q.setAttribute("tabindex","0"),Q.setAttribute("aria-expanded",String(this.open)),Q.addEventListener("click",this.#G),Q.addEventListener("keydown",this.#W),j.addEventListener("click",this.#G),!this.hasAttribute("open"))this.setAttribute("open","false"),Q.setAttribute("aria-expanded","false")}else{if(Q.removeAttribute("role"),Q.removeAttribute("tabindex"),Q.removeAttribute("aria-expanded"),this.#Z.removeAttribute("role"),this.#Z.removeAttribute("tabindex"),this.#Z.removeAttribute("aria-expanded"),this.#_)this.#_.remove(),this.#_=null;this.removeAttribute("open")}}}A("fig-group",y_);class b_ extends HTMLElement{}A("fig-header",b_);class h_ extends HTMLElement{}A("fig-footer",h_);class v_ 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")}}A("fig-spinner",v_);class g_ extends HTMLElement{static get observedAttributes(){return["fit","aspect-ratio"]}connectedCallback(){this.#Z(),this.#_()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="fit")this.#Z();if(_==="aspect-ratio")this.#_()}#Z(){let _=this.getAttribute("fit");if(_)this.style.setProperty("--fig-preview-fit",_);else this.style.removeProperty("--fig-preview-fit")}#_(){let _=this.getAttribute("aspect-ratio");if(_)this.style.setProperty("--fig-preview-aspect-ratio",_);else this.style.removeProperty("--fig-preview-aspect-ratio")}}A("fig-preview",g_);var O1={chevron:{medium:"--icon-24-chevron",small:"--icon-16-chevron"},checkmark:{medium:"--icon-24-checkmark",small:"--icon-16-checkmark"},reset:{medium:"--icon-24-reset",small:"--icon-16-reset"},"arrow-left":{medium:"--icon-24-arrow-left",small:"--icon-16-arrow-left"},steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",send:{medium:"--icon-24-send",small:"--icon-16-send"},adjust:{medium:"--icon-24-adjust",small:"--icon-16-adjust"},minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",download:"--icon-24-download",upload:"--icon-24-upload",image:"--icon-24-image",sound:{medium:"--icon-24-sound",small:"--icon-16-sound"},"sound-off":{medium:"--icon-24-sound-off",small:"--icon-16-sound-off"},sun:"--icon-24-sun",moon:"--icon-24-moon",edit:{medium:"--icon-24-edit",small:"--icon-16-edit"},settings:{medium:"--icon-24-settings",small:"--icon-16-settings"},more:{medium:"--icon-24-more",small:"--icon-16-more"},visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"},globe:{medium:"--icon-24-globe",small:"--icon-16-globe"},warning:{medium:"--icon-24-warning",small:"--icon-16-warning"},copy:{medium:"--icon-24-copy",small:"--icon-16-copy"},trash:{medium:"--icon-24-trash",small:"--icon-16-trash"}};function M1(_,Z="medium"){let $=_&&O1[_];if(!$)return"";let J=typeof $==="string"?$:$[Z==="small"?"small":"medium"];return J?`var(${J})`:""}var B1={primary:"--figma-color-icon",secondary:"--figma-color-icon-secondary",tertiary:"--figma-color-icon-tertiary",disabled:"--figma-color-icon-disabled",brand:"--figma-color-icon-brand",component:"--figma-color-icon-component",danger:"--figma-color-icon-danger",success:"--figma-color-icon-success",warning:"--figma-color-icon-warning",selected:"--figma-color-icon-selected",hover:"--figma-color-icon-hover",pressed:"--figma-color-icon-pressed",onbrand:"--figma-color-icon-onbrand",oncomponent:"--figma-color-icon-oncomponent",ondanger:"--figma-color-icon-ondanger",ondisabled:"--figma-color-icon-ondisabled",oninverse:"--figma-color-icon-oninverse",onselected:"--figma-color-icon-onselected",onsuccess:"--figma-color-icon-onsuccess",onwarning:"--figma-color-icon-onwarning"};function A1(_){if(!_)return"";if(_.startsWith("var("))return _;let Z=B1[_.toLowerCase()];return Z?`var(${Z})`:_}class m_ extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#Z()}attributeChangedCallback(_,Z,$){if(Z!==$)this.#Z()}#Z(){let _=this.getAttribute("name"),Z=this.getAttribute("size")||"medium",$=M1(_,Z);if($)this.style.setProperty("--icon",$);else this.style.removeProperty("--icon");if(Z==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let J=A1(this.getAttribute("color"));if(J)this.style.backgroundColor=J,this.style.setProperty("--icon-color",J);else this.style.removeProperty("background-color"),this.style.removeProperty("--icon-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}A("fig-icon",m_);class p_ extends HTMLElement{}A("fig-content",p_);class u_ extends HTMLElement{}A("fig-tab-content",u_);class c_ extends HTMLElement{}A("fig-button-combo",c_);class d_ extends HTMLElement{}A("fig-input-combo",d_);class s_ extends HTMLElement{static get observedAttributes(){return["gap","columns","min-width"]}connectedCallback(){this.#Z()}attributeChangedCallback(){this.#Z()}#Z(){let _=this.getAttribute("gap")?.trim();this.#_("--fig-stack-gap",_&&/^(\d+(-5)?|half)$/.test(_)?`var(--spacer-${_})`:_);let Z=this.getAttribute("columns")?.trim();this.#_("--fig-stack-columns",Z&&/^\d+$/.test(Z)?`repeat(${Z}, minmax(0, 1fr))`:Z),this.#_("--fig-stack-min-width",this.getAttribute("min-width")?.trim())}#_(_,Z){if(Z)this.style.setProperty(_,Z);else this.style.removeProperty(_)}}A("fig-stack",s_);class o_ extends HTMLElement{#Z=null;#_=null;#J=null;#$=this.#L.bind(this);#Q=this.#O.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#j(){return this.getAttribute("control")||"color"}connectedCallback(){this.#G(),this.#U()}disconnectedCallback(){this.#K(),this.removeEventListener("click",this.#W)}#K(){if(this.#Z)this.#Z.removeEventListener("input",this.#$),this.#Z.removeEventListener("change",this.#Q);if(this.#_)this.#_.removeEventListener("input",this.#$),this.#_.removeEventListener("change",this.#Q);if(this.#J)this.#J.disconnect(),this.#J=null}#q(){if(this.#J)this.#J.disconnect(),this.#J=null;if(!this.#_)return;this.#J=new MutationObserver(()=>{if(this.#_?.hasAttribute("selected")&&this.#_.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#J.observe(this.#_,{attributes:!0,attributeFilter:["selected"]})}get#N(){let _=this.getAttribute("alpha");return _===null||_!=="false"}#G(){this.#K();let _=this.#j;if(_==="add"||_==="remove"){let N=_==="add"?"add":"minus",K=this.getAttribute("aria-label")||(_==="add"?"Add color stop":"Remove color stop");this.replaceChildren(L("fig-button",{icon:!0,variant:"ghost","aria-label":K},h(N))),this.#Z=null,this.#_=null,this.addEventListener("click",this.#W),this.#B();return}this.removeEventListener("click",this.#W);let Z=(this.getAttribute("value")||"").trim(),$=this.#R(Z),J=this.#Y(Z),Q=J<1?JSON.stringify({type:"solid",color:$,opacity:Math.round(J*100)}):JSON.stringify({type:"solid",color:$}),j=L("fig-swatch",{background:$,alpha:J<1?J:null}),q=null;if(a())q=L("fig-fill-picker",{mode:"solid",alpha:this.#N?null:"false",value:Q},j),this.replaceChildren(q);else this.replaceChildren(j);if(this.#Z=q,this.#_=j,this.#Z?.addEventListener("input",this.#$),this.#Z?.addEventListener("change",this.#Q),!this.#Z)this.#_?.addEventListener("input",this.#$),this.#_?.addEventListener("change",this.#Q);this.#q(),this.#B()}#W=()=>{let _=this.#j;this.dispatchEvent(new CustomEvent(_,{bubbles:!0,composed:!0}))};#X(_){if(!_)return"#D9D9D9";let Z=_.replace("#","").trim();if(Z.length===3||Z.length===4){let[$,J,Q]=Z;return`#${$}${$}${J}${J}${Q}${Q}`.toUpperCase()}if(Z.length===6||Z.length===8)return`#${Z.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#Y(_){if(!_)return 1;let Z=String(_).trim(),$=Z.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test($)){let Q=$[3];return parseInt(`${Q}${Q}`,16)/255}if(/^[0-9a-f]{8}$/i.test($))return parseInt($.slice(6,8),16)/255;let J=Z.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(J)return parseFloat(J[1]);return 1}#R(_){if(!_)return"#D9D9D9";let Z=String(_).trim();if(Z.startsWith("{"))try{let $=JSON.parse(Z);if($?.color)return this.#R($.color)}catch{}if(Z.startsWith("#"))return this.#X(Z);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Z))return this.#X(Z);try{let{ctx:$}=T0(1,1);$.fillStyle="#000000",$.fillStyle=Z;let J=$.fillStyle;if(J.startsWith("#"))return this.#X(J);let Q=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(Q){let j=(q)=>Math.max(0,Math.min(255,Number(q))).toString(16).padStart(2,"0");return`#${j(Q[1])}${j(Q[2])}${j(Q[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#U(){let _=this.getAttribute("value"),Z=this.#R(_),$=this.#Y(_);if(_!==Z&&$>=1){this.setAttribute("value",Z);return}if(this.#Z){this.#B();let J=$<1?{type:"solid",color:Z,opacity:Math.round($*100)}:{type:"solid",color:Z};if(this.#Z.setAttribute("value",JSON.stringify(J)),this.#N)this.#Z.removeAttribute("alpha");else this.#Z.setAttribute("alpha","false");if(z(this,"disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}if(this.#_){if(this.#B(),this.#_.setAttribute("background",Z),$<1)this.#_.setAttribute("alpha",String($));else this.#_.removeAttribute("alpha");if(z(this,"disabled"))this.#_.setAttribute("disabled","");else this.#_.removeAttribute("disabled")}}#B(){let _=this.#j,Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",Z?"true":"false"),this.setAttribute("aria-pressed",$?"true":"false"),_==="add"||_==="remove"){let N=this.querySelector("fig-button"),K=this.getAttribute("aria-label")||(_==="add"?"Add color stop":"Remove color stop");if(N?.setAttribute("aria-label",K),Z)N?.setAttribute("disabled","");else N?.removeAttribute("disabled");return}let J=this.#Z||this.#_;if(!J)return;let Q=this.getAttribute("aria-label")||"Color stop",j=this.getAttribute("aria-labelledby"),q=this.getAttribute("aria-describedby");if(j)J.setAttribute("aria-labelledby",j),J.removeAttribute("aria-label");else J.setAttribute("aria-label",Q),J.removeAttribute("aria-labelledby");if(q)J.setAttribute("aria-describedby",q);else J.removeAttribute("aria-describedby")}#M(_,Z){let $=this.#R(_?.color),J=this.#R(this.getAttribute("value"));if($!==J)this.setAttribute("value",$);else this.#U();let Q={color:this.value};if(this.#N){if(_?.opacity!==void 0)Q.opacity=_.opacity;else if(_?.alpha!==void 0)Q.opacity=Math.round(_.alpha*100)}Object.assign(Q,t(Q.color,this.#N?_?.alpha:1,Q.opacity)),this.dispatchEvent(new CustomEvent(Z,{bubbles:!0,cancelable:!0,composed:!0,detail:Q}))}#L(_){_.stopPropagation(),this.#M(_.detail||{color:_.target?.value},"input")}#O(_){_.stopPropagation(),this.#M(_.detail||{color:_.target?.value},"change")}attributeChangedCallback(_,Z,$){if(Z===$)return;if(!this.isConnected)return;switch(_){case"control":this.#G();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#U(),this.#B();break}}get value(){return this.#R(this.getAttribute("value"))}set value(_){if(_===null||_===void 0||_===""){this.removeAttribute("value");return}this.setAttribute("value",this.#R(_))}get selected(){return z(this,"selected")}set selected(_){this.toggleAttribute("selected",Boolean(_))}get disabled(){return z(this,"disabled")}set disabled(_){this.toggleAttribute("disabled",Boolean(_))}}A("fig-color-tip",o_);class i_ extends HTMLElement{#Z=null;static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.#_(),z(this,"disabled"))this.setAttribute("aria-disabled","true")}disconnectedCallback(){this.#Z?.disconnect()}#_(){let _=z(this,"selected");this.setAttribute("aria-selected",_?"true":"false");for(let Z of this.children)Z.toggleAttribute("selected",_);if(this.#Z?.disconnect(),_&&this.isConnected)this.#Z??=new MutationObserver(()=>this.#_()),this.#Z.observe(this,{childList:!0})}attributeChangedCallback(_){if(_==="selected")this.#_();if(_==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}A("fig-choice",i_);class l_ extends HTMLElement{#Z=null;#_=this.#T.bind(this);#J=this.#I.bind(this);#$=this.#F.bind(this);#Q=null;#j=null;#K=null;#q=null;#N=null;#G=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop","auto-scroll"]}get#W(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#X(){let _=this.getAttribute("drag");return _===null||_!=="false"}get autoScroll(){let _=this.getAttribute("auto-scroll");return _===null||_!=="false"}set autoScroll(_){if(_===!1||_==="false"||_===null)this.setAttribute("auto-scroll","false");else this.removeAttribute("auto-scroll")}get scrollBehavior(){return this.getAttribute("scroll-behavior")==="auto"?"auto":"smooth"}set scrollBehavior(_){if(_==="auto"||_==="smooth")this.setAttribute("scroll-behavior",_);else this.removeAttribute("scroll-behavior")}get#Y(){return this.getAttribute("choice-element")||"fig-choice"}#R(){let _=this.getAttribute("columns"),Z=_===null?NaN:Number(_);if(Number.isInteger(Z)&&Z>0)this.style.setProperty("--fig-chooser-grid-columns",String(Z));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from(this.querySelectorAll(`:scope > ${this.#Y}`))}get selectedChoice(){return this.#Z}set selectedChoice(_){if(_&&!this.contains(_))return;let Z=this.choices;for(let J of Z){let Q=J===_,j=z(J,"selected");if(Q&&!j)J.setAttribute("selected","");else if(!Q&&j)J.removeAttribute("selected")}this.#Z=_??null;let $=_?.getAttribute("value")??"";if(this.getAttribute("value")!==$)this.setAttribute("value",$);if(this.autoScroll)this.#w(_)}get value(){return this.#Z?.getAttribute("value")??""}set value(_){if(_===null||_===void 0||_===""){this.setAttribute("value","");return}this.setAttribute("value",String(_))}scrollSelectionIntoView(_={}){if(!this.#Z)return;this.#w(this.#Z,_)}connectedCallback(){if(this.setAttribute("role","listbox"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#R(),this.#C(),this.addEventListener("click",this.#_),this.addEventListener("keydown",this.#J),this.addEventListener("scroll",this.#$),this.#E(),this.#A(),this.#g(),this.#H(),this.#M(),u(this,()=>{this.#B(),this.#F(),this.#U()})}#U(){requestAnimationFrame(()=>{if(!this.isConnected||!this.autoScroll)return;if(this.#Z)this.#w(this.#Z)})}disconnectedCallback(){this.removeEventListener("click",this.#_),this.removeEventListener("keydown",this.#J),this.removeEventListener("scroll",this.#$),this.#z(),this.#Q?.disconnect(),this.#Q=null,this.#j?.disconnect(),this.#j=null,this.#f()}attributeChangedCallback(_,Z,$){if(_==="value"&&$!==Z)if($==="")this.selectedChoice=null;else if($==null)this.#B();else this.#L($);if(_==="disabled")this.#M();if(_==="choice-element")requestAnimationFrame(()=>{this.#R(),this.#B()});if(_==="columns")this.#R(),this.#S();if(_==="drag")if(this.#X)this.#A();else this.#z();if(_==="overflow")this.#E(),requestAnimationFrame(()=>this.#F());if(_==="layout"){if(this.#R(),this.#E(),$==="horizontal")this.scrollTop=0;else this.scrollLeft=0;this.#S()}if(_==="auto-scroll"&&this.autoScroll)this.#S()}#B(){let _=this.choices;if(!_.length){this.#Z=null;return}let Z=this.hasAttribute("value"),$=this.getAttribute("value");if(Z&&$===""){this.selectedChoice=null;return}if($&&this.#L($))return;let J=_.find((Q)=>z(Q,"selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=_[0]}#M(){let _=z(this,"disabled");if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Z of this.choices)if(_||z(Z,"disabled"))Z.setAttribute("aria-disabled","true"),Z.setAttribute("tabindex","-1");else Z.removeAttribute("aria-disabled"),Z.setAttribute("tabindex","0")}#L(_){let Z=this.choices;for(let $ of Z)if($.getAttribute("value")===_)return this.selectedChoice=$,!0;return!1}#O(_){let Z=this.#Y,$=_;while($&&$!==this){if($.matches(Z))return $;$=$.parentElement}return null}#T(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#O(_.target);if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.selectedChoice=Z,this.#k()}#I(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!Z.length)return;let $=this.#O(_.target),J=Z.indexOf($),Q=J,j=this.hasAttribute("loop");switch(_.key){case"ArrowDown":case"ArrowRight":if(_.preventDefault(),J<Z.length-1)Q=J+1;else if(j)Q=0;break;case"ArrowUp":case"ArrowLeft":if(_.preventDefault(),J>0)Q=J-1;else if(j)Q=Z.length-1;break;case"Home":_.preventDefault(),Q=0;break;case"End":_.preventDefault(),Q=Z.length-1;break;case"Enter":case" ":if(_.preventDefault(),$&&$!==this.#Z)this.selectedChoice=$,this.#k();return;default:return}if(Q!==J&&Z[Q]){let q=Z[Q];if(q.focus({preventScroll:!0}),this.autoScroll)this.#w(q)}}#k(){let _=this.value;this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#F(){if(this.#W==="scrollbar")return;let _=this.getAttribute("layout")==="horizontal";R0(this,this,_?"x":"y")}#H(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#F(),this.#S()}),this.#j.observe(this)}#A(){if(this.#N?.bound)return;if(!this.#X)return;let _=(q)=>{if(q.button!==0)return;if(q.target.closest("[data-fig-chooser-nav]"))return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#N.active=!0,this.#N.didDrag=!1,this.#N.startX=q.clientX,this.#N.startY=q.clientY,this.#N.scrollLeft=this.scrollLeft,this.#N.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Z=(q)=>{if(!this.#N.active)return;let N=this.getAttribute("layout")==="horizontal",K=q.clientX-this.#N.startX,G=q.clientY-this.#N.startY;if(!this.#N.didDrag&&Math.abs(N?K:G)>3)this.#N.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(q.pointerId);if(!this.#N.didDrag)return;if(N)this.scrollLeft=this.#N.scrollLeft-K;else this.scrollTop=this.#N.scrollTop-G},$=(q)=>{if(!this.#N.active)return;let N=this.#N.didDrag;if(this.#N.active=!1,this.#N.didDrag=!1,this.style.cursor="",this.style.userSelect="",q.pointerId!==void 0)try{this.releasePointerCapture(q.pointerId)}catch{}if(N)q.preventDefault(),q.stopPropagation()},J=(q)=>{if(this.#N?.suppressClick)q.stopPropagation(),q.preventDefault(),this.#N.suppressClick=!1},Q=(q)=>{if(this.#N?.didDrag)this.#N.suppressClick=!0,setTimeout(()=>{if(this.#N)this.#N.suppressClick=!1},0)},j=(q)=>{if(this.#N?.active)q.preventDefault()};this.#N={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:_,onPointerMove:Z,onPointerUp:$,onClick:J,onPointerUpCapture:Q,onDragStart:j},this.addEventListener("pointerdown",_),window.addEventListener("pointermove",Z),window.addEventListener("pointerup",$),this.addEventListener("pointerup",Q,!0),this.addEventListener("click",J,!0),this.addEventListener("dragstart",j)}#z(){if(!this.#N?.bound)return;this.removeEventListener("pointerdown",this.#N.onPointerDown),window.removeEventListener("pointermove",this.#N.onPointerMove),window.removeEventListener("pointerup",this.#N.onPointerUp),this.removeEventListener("pointerup",this.#N.onPointerUpCapture,!0),this.removeEventListener("click",this.#N.onClick,!0),this.removeEventListener("dragstart",this.#N.onDragStart),this.style.cursor="",this.style.userSelect="",this.#N=null}#C(){if(this.#G)return;let _=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!_)return;this.#G=!0;try{let Z=Array.from(_.childNodes);_.replaceWith(...Z)}finally{this.#G=!1}}#E(){let _=this.#W==="scrollbar",Z=this.getAttribute("layout")==="grid";if(_||Z)this.#f(),this.classList.toggle("fig-overflow-fade",_),this.classList.toggle("fig-overflow-fade-horizontal",_&&this.getAttribute("layout")==="horizontal");else this.#D(),this.classList.remove("fig-overflow-fade","fig-overflow-fade-horizontal")}#f(){this.#K?.remove(),this.#q?.remove(),this.#K=null,this.#q=null,this.classList.remove("overflow-start","overflow-end")}#D(){if(this.#K&&this.#q&&this.contains(this.#K)&&this.contains(this.#q)){this.#P();return}this.#K?.remove(),this.#q?.remove(),this.#K=null,this.#q=null;let _=U0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#x(-1),onEnd:()=>this.#x(1)});this.#K=_.start,this.#q=_.end,this.#P()}#P(){if(this.firstElementChild!==this.#K)this.prepend(this.#K);if(this.lastElementChild!==this.#q)this.append(this.#q)}#x(_){let Z=this.getAttribute("layout")==="horizontal";Z0(this,Z?"x":"y",_,"auto")}#S(){if(!this.autoScroll||!this.#Z)return;this.#w(this.#Z)}#w(_,Z={}){if(!_)return;let $=typeof Z==="object"&&Z!==null?Z:{},J=$.behavior==="smooth"||$.behavior==="instant"?$.behavior:"auto",Q=$.block||"center",j=$.inline||"center";requestAnimationFrame(()=>{if(!_.isConnected)return;let q=this.scrollHeight>this.clientHeight,N=this.scrollWidth>this.clientWidth;if(!N&&!q)return;let K=_.getBoundingClientRect(),G=this.getBoundingClientRect(),X={behavior:J},Y=!1;if(q){let U=K.top-G.top+this.scrollTop,W=this.scrollHeight-this.clientHeight;X.top=this.#V(U,K.height,this.clientHeight,this.scrollTop,W,Q),Y=!0}if(N){let U=K.left-G.left+this.scrollLeft,W=this.scrollWidth-this.clientWidth;X.left=this.#V(U,K.width,this.clientWidth,this.scrollLeft,W,j),Y=!0}if(Y)this.scrollTo(X);this.#F()})}#V(_,Z,$,J,Q,j){let q;if(j==="start")q=_;else if(j==="end")q=_+Z-$;else if(j==="nearest"){let N=J,K=J+$,G=_+Z;if(_>=N&&G<=K)q=J;else if(_<N)q=_;else q=G-$}else q=_+Z/2-$/2;return Math.max(0,Math.min(q,Q))}#g(){this.#Q?.disconnect(),this.#Q=new MutationObserver(()=>{if(this.#G)return;this.#C(),this.#R(),this.#E(),this.#M();let _=this.choices;if(this.#Z&&!_.includes(this.#Z))this.#Z=null,this.#B();else if(!this.#Z&&_.length)this.#B();requestAnimationFrame(()=>this.#F())}),this.#Q.observe(this,{childList:!0,subtree:!1})}}A("fig-chooser",l_);class r_ extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","precision","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#Z=!1;#_=!1;#J=null;#$=null;#Q=!1;#j=null;#K=null;#q=null;#N=null;get#G(){let _=(this.getAttribute("tip")||"").trim().toLowerCase();return _==="color"||_==="add"||_==="remove"?_:null}get#W(){return!this.hasAttribute("data-no-color-picker")}get#X(){let _=this.getAttribute("drag");return _!==null&&_!=="false"}get#Y(){let _=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:_.includes("x"),y:_.includes("y")}}get#R(){let _=this.getAttribute("drag-snapping");if(_===null)return"false";let Z=_.trim().toLowerCase();if(Z==="modifier")return"modifier";if(Z===""||Z==="true")return"true";return"false"}#U(_){let Z=this.#R;if(Z==="true")return!0;if(Z==="modifier")return!!_;return!1}#B(_){if(_<0.1)return 0;if(_>0.9)return 1;if(_>0.4&&_<0.6)return 0.5;return _}#M(_,Z){if(Math.abs(_-Z)<0.1){let J=(_+Z)/2;return{x:J,y:J}}if(Math.abs(1-_-Z)<0.1)return{x:_,y:1-_};return{x:_,y:Z}}#L(){let _=this.getAttribute("drag-surface");if(!_||_==="parent")return this.parentElement;return this.closest(_)}get value(){let _=this.#L();if(!_)return"0% 0%";let{px:Z,py:$}=this.#l(_.getBoundingClientRect());return`${(Z*100).toFixed(this.precision)}% ${($*100).toFixed(this.precision)}%`}set value(_){this.setAttribute("value",_??"0% 0%")}get precision(){let _=Number(this.getAttribute("precision")??2);if(!Number.isFinite(_))return 2;return Math.max(0,Math.min(10,Math.trunc(_)))}set precision(_){if(_===null||_===void 0||_==="")this.removeAttribute("precision");else{let Z=Number(_),$=Number.isFinite(Z)?Math.max(0,Math.min(10,Math.trunc(Z))):2;this.setAttribute("precision",String($))}}#O(_){let Z=10**this.precision,$=Math.round(_*Z)/Z;return Object.is($,-0)?0:$}#T(_){let Z=_==null?"":String(_).trim();if(!Z)return{xPct:0,yPct:0};let $=Z.split(/[\s,]+/).filter(Boolean),J=(q)=>{if(!q)return 0;let N=q.includes("px"),K=q.includes("%"),G=parseFloat(q.replace(/[%px]/g,""));if(!Number.isFinite(G))return 0;if(N)return{px:G};if(K||Math.abs(G)>1)return Math.max(0,Math.min(100,G));return Math.max(0,Math.min(100,G*100))},Q=J($[0]),j=J($[1]??$[0]);return{xToken:Q,yToken:j}}#I(_){let Z=this.#L();if(!Z)return;let{xToken:$,yToken:J}=this.#T(_),Q=Z.getBoundingClientRect(),j=(K,G)=>{if(K&&typeof K==="object"&&"px"in K)return Math.max(0,Math.min(G,K.px));return null},q=(K)=>{let G=typeof K==="number"?K:0;return`${this.#O(G)}%`},N=this.#Y;if(this.#k(N),N.x){let K=j($,Q.width);this.style.left=K===null?q($):`${this.#O(K)}px`}if(N.y){let K=j(J,Q.height);this.style.top=K===null?q(J):`${this.#O(K)}px`}}#k(_=this.#Y){this.style.setProperty("--fig-handle-position-translate",`${_.x?"-50%":"0"} ${_.y?"-50%":"0"}`)}#F(){this.#Q=!0,this.setAttribute("value",this.value),this.#Q=!1}get#H(){return this.getAttribute("hit-area-mode")||"handle"}#A(){let _=this.getAttribute("hit-area");if(!_)return null;let Z=_.trim().split(/\s+/),$=0,J=0,Q=!1,j=[];for(let q of Z){if(q==="circle"){Q=!0;continue}let N=parseFloat(q);if(Number.isFinite(N))j.push(N)}if(j.length>=2)$=j[0],J=j[1];else if(j.length===1)$=j[0],J=j[0];else return null;return{vPad:$,hPad:J,circle:Q}}#z(){let _=this.#A();if(!_){if(this.#N)this.#N.remove(),this.#N=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#N){let Z=document.createElement("div");Z.classList.add("fig-handle-hit-area"),Z.addEventListener("pointerdown",($)=>this.#C($)),this.prepend(Z),this.#N=Z}if(this.style.setProperty("--fig-handle-hit-area-size",String(_.hPad*2)),_.circle)this.#N.style.borderRadius="50%";else this.#N.style.borderRadius="inherit"}#C(_){if(z(this,"disabled"))return;if(_.target!==this.#N)return;if(this.#H==="delegate")_.preventDefault(),_.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:_}}));else this.#g(_)}connectedCallback(){this.#w(),this.#S(),this.#z(),this.addEventListener("click",this.#E),this.addEventListener("blur",this.#D),document.addEventListener("pointerdown",this.#f),document.addEventListener("keydown",this.#P);let _=this.getAttribute("value");if(_)this.#I(_);if(this.#G)this.#i()}disconnectedCallback(){if(this.#V(),this.#p(),this.#s(),this.#c(),this.#N)this.#N.remove(),this.#N=null;this.removeEventListener("click",this.#E),this.removeEventListener("blur",this.#D),document.removeEventListener("pointerdown",this.#f),document.removeEventListener("keydown",this.#P)}select(){if(z(this,"disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#E=(_)=>{if(this.#_){this.#_=!1;return}if(this.select(),this.getAttribute("type")==="color"&&this.#W&&!this.#G)this.#v()};#f=(_)=>{if(this.contains(_.target))return;if((this.#j||this.#K)&&_.target.closest?.("dialog, [popover]"))return;this.deselect()};#D=()=>{this.removeAttribute("data-fig-pointer-focus")};#P=(_)=>{if(this.removeAttribute("data-fig-pointer-focus"),_.defaultPrevented)return;if(_.target===this&&this.#X&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(_.key)){if(this.#x(_)){if(_.preventDefault(),!z(this,"selected"))this.select()}return}if(_.key!=="Enter"&&_.key!==" ")return;if(_.target===this&&!z(this,"selected")){if(_.preventDefault(),this.getAttribute("type")==="color"&&this.#W&&!this.#G)this.#v();else this.select();return}if(!z(this,"selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#W)return;if(_.preventDefault(),!this.#G)this.#v()};#x(_){if(z(this,"disabled"))return!1;let Z=this.#L();if(!Z)return!1;let $=Z.getBoundingClientRect();if($.width<=0||$.height<=0)return!1;let J=this.#Y,Q=this.#l($),j=_.shiftKey?0.1:0.01,q=Q.px,N=Q.py;switch(_.key){case"ArrowLeft":if(!J.x)return!1;q-=j;break;case"ArrowRight":if(!J.x)return!1;q+=j;break;case"ArrowUp":if(!J.y)return!1;N-=j;break;case"ArrowDown":if(!J.y)return!1;N+=j;break;case"Home":if(J.x)q=0;if(J.y)N=0;break;case"End":if(J.x)q=1;if(J.y)N=1;break;default:return!1}if(q=Math.max(0,Math.min(1,q)),N=Math.max(0,Math.min(1,N)),this.#k(J),J.x)this.style.left=`${this.#O(q*$.width)}px`;if(J.y)this.style.top=`${this.#O(N*$.height)}px`;this.#F();let K={...this.#l($),shiftKey:_.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:K})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:K})),!0}attributeChangedCallback(_,Z,$){if(_==="color"){if(!$||$==="false"||$==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",$);if(this.#j&&this.#G==="color"&&$)this.#j.setAttribute("value",$);this.#b()}if(_==="drag")this.#S();if(_==="hit-area")this.#z();if(_==="selected")this.#d();if(_==="selected"||_==="disabled"||_==="type"||_==="tip"||_==="aria-label"||_==="aria-labelledby")this.#w();if(_==="value"&&!this.#Q&&!this.#Z)this.#I($);if(_==="precision"&&this.isConnected&&!this.#Z&&this.hasAttribute("value"))this.#I(this.getAttribute("value")),this.#F();if(_==="tip"){if(this.#p(),this.#G)this.#s(),this.#i()}}#S(){if(this.#X&&!this.#J)this.#J=(_)=>this.#g(_),this.addEventListener("pointerdown",this.#J);else if(!this.#X&&this.#J)this.#V()}#w(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex",_?"-1":"0");else if(_)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",_?"true":"false"),this.setAttribute("aria-pressed",Z?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let $=this.#G||this.getAttribute("type")||"handle";this.setAttribute("aria-label",$==="color"?"Color handle":$==="add"?"Add handle":$==="remove"?"Remove handle":"Handle")}}#V(){if(this.#$?.(),this.#$=null,this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#Z=!1,this.#_=!1}#g(_){if(!this.#X||z(this,"disabled"))return;_.preventDefault(),this.setAttribute("data-fig-pointer-focus",""),this.focus(),this.select();let Z=this.#L();if(!Z)return;this.#$?.(),this.#Z=!0;let $=this.#Y,J=null,Q=this.getBoundingClientRect(),j=Q.left+Q.width/2,q=Q.top+Q.height/2,N=_.clientX-j,K=_.clientY-q,G=_.clientX,X=_.clientY,Y=3,U=(F,H,T=!1)=>{let R=Z.getBoundingClientRect();J=R;let I=this.#l(R),E=F-N-R.left,V=H-K-R.top,C=Math.max(0,Math.min(R.width,E)),w=Math.max(0,Math.min(R.height,V)),f=R.width>0?$.x?C/R.width:I.px:0.5,c=R.height>0?$.y?w/R.height:I.py:0.5;if(this.#U(T)){if($.x)f=this.#B(f);if($.y)c=this.#B(c);if($.x&&$.y){let i=this.#M(f,c);f=i.x,c=i.y}}if(this.#k($),$.x)this.style.left=`${this.#O(Math.max(0,Math.min(R.width,f*R.width)))}px`;if($.y)this.style.top=`${this.#O(Math.max(0,Math.min(R.height,c*R.height)))}px`},W=(F)=>{if(!this.#Z)return;if(!this.#_){let H=F.clientX-G,T=F.clientY-X;if(H*H+T*T<Y*Y)return;if(this.#o(),this.classList.add("dragging"),this.style.cursor="grabbing",!z(this,"selected"))this.select()}this.#_=!0,U(F.clientX,F.clientY,F.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#l(J),shiftKey:F.shiftKey}}))},O=(F)=>{if(B(),this.#_){U(F.clientX,F.clientY,F.shiftKey),this.#F(),this.#I(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#l(J)}));let H=(T)=>{T.stopPropagation(),T.preventDefault()};this.addEventListener("click",H,{capture:!0,once:!0})}else this.#F();this.#_=!1},B=()=>{if(window.removeEventListener("pointermove",W),window.removeEventListener("pointerup",O),this.#Z=!1,this.style.cursor="",this.classList.remove("dragging"),this.#$===B)this.#$=null};this.#$=B,window.addEventListener("pointermove",W),window.addEventListener("pointerup",O)}showColorTip(){if(!this.#G)return;if(this.#j){this.#j.style.display="";return}this.#i()}hideColorTip(){if(!this.#j)return;this.#j.style.display="none"}#y(_=this.getAttribute("color")){let Z={color:"#D9D9D9",opacity:100},$=String(_||"").trim();if(!$)return Z;let J=(j)=>{let q=j.replace("#","").trim();if(q.length===3||q.length===4){let[N,K,G,X]=q;return{color:`#${N}${N}${K}${K}${G}${G}`.toUpperCase(),opacity:X?Math.round(parseInt(`${X}${X}`,16)/255*100):100}}if(q.length===6||q.length===8)return{color:`#${q.slice(0,6)}`.toUpperCase(),opacity:q.length===8?Math.round(parseInt(q.slice(6,8),16)/255*100):100};return Z},Q=(j,q,N)=>{let K=(G)=>Math.max(0,Math.min(255,Math.round(Number(G)))).toString(16).padStart(2,"0");return`#${K(j)}${K(q)}${K(N)}`.toUpperCase()};if($.startsWith("#"))return J($);try{let{ctx:j}=T0(1,1);j.fillStyle="#000000",j.fillStyle=$;let q=j.fillStyle;if(q.startsWith("#"))return J(q);let N=q.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(N)return{color:Q(N[1],N[2],N[3]),opacity:N[4]!==void 0?Math.round(parseFloat(N[4])*100):100}}catch{}return Z}#m(){let{color:_,opacity:Z}=this.#y();return JSON.stringify(Z<100?{type:"solid",color:_,opacity:Z}:{type:"solid",color:_})}#b(){if(!this.#K)return;this.#K.setAttribute("value",this.#m())}#h(){if(!a())return null;if(this.#K)return this.#K;let _=document.createElement("fig-fill-picker");_.setAttribute("mode","solid"),_.setAttribute("alpha","true"),_.setAttribute("dialog-offset","8 8"),_.setAttribute("value",this.#m()),_.anchorElement=this;let Z=document.createElement("span");return Z.hidden=!0,_.appendChild(Z),_.addEventListener("input",this.#_0),_.addEventListener("change",this.#Z0),_.addEventListener("close",this.#N0),this.appendChild(_),this.#K=_,_}#v(){if(z(this,"disabled"))return;let _=this.#h();if(!_){this.#a();return}this.setAttribute("selected",""),this.#b(),_.open()}#s(){if(!this.#K)return;this.#K.removeEventListener("input",this.#_0),this.#K.removeEventListener("change",this.#Z0),this.#K.removeEventListener("close",this.#N0),this.#K.close(),this.#K.remove(),this.#K=null,this.removeAttribute("selected")}#r(){if(this.#q)return this.#q;let _=document.createElement("input");return _.type="color",_.tabIndex=-1,_.setAttribute("aria-hidden","true"),_.style.position="fixed",_.style.inlineSize="1px",_.style.blockSize="1px",_.style.opacity="0",_.style.pointerEvents="none",_.addEventListener("input",this.#K0),_.addEventListener("change",this.#q0),this.appendChild(_),this.#q=_,_}#a(){let _=this.#r(),{color:Z}=this.#y();_.value=Z,this.setAttribute("selected",""),_.click()}#c(){if(!this.#q)return;this.#q.removeEventListener("input",this.#K0),this.#q.removeEventListener("change",this.#q0),this.#q.remove(),this.#q=null}#o(){if(this.getAttribute("type")!=="color")return;this.#K?.close()}#i(){let _=this.#G;if(!_)return;if(this.#j)return;let Z=document.createElement("fig-color-tip");if(_==="add"||_==="remove")Z.setAttribute("control",_);else Z.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Z.setAttribute("alpha","true");Z.addEventListener("input",this.#G0),Z.addEventListener("change",this.#j0),Z.addEventListener("add",this.#t),Z.addEventListener("remove",this.#t),this.appendChild(Z),this.#j=Z,this.#d()}#p(){if(!this.#j)return;this.#j.removeEventListener("input",this.#G0),this.#j.removeEventListener("change",this.#j0),this.#j.removeEventListener("add",this.#t),this.#j.removeEventListener("remove",this.#t),this.#j.remove(),this.#j=null}#d(){if(!this.#j||this.#G!=="color")return;let _=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#j.toggleAttribute("selected",_)}#u(_,Z){if(Z===void 0||Z>=100)return _;let{r:$,g:J,b:Q}=$0(_);return`rgba(${$}, ${J}, ${Q}, ${Z/100})`}#e(_){if(!_?.color)return null;let Z=_.opacity!==void 0?_.opacity:_.alpha!==void 0?Math.round(_.alpha*100):void 0;return{color:_.color,opacity:Z,...t(_.color,_.alpha,Z)}}#_0=(_)=>{_.stopPropagation();let Z=this.#e(_.detail);if(!Z)return;this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#Z0=(_)=>{_.stopPropagation();let Z=this.#e(_.detail);if(!Z)return;this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#n(_){let{opacity:Z}=this.#y();return{...Z<100?{color:_,opacity:Z}:{color:_},...t(_,void 0,Z)}}#K0=(_)=>{_.stopPropagation();let Z=this.#n(_.target.value);this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#q0=(_)=>{_.stopPropagation();let Z=this.#n(_.target.value);if(this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z})),this.isConnected)this.focus()};#N0=()=>{if(!this.isConnected)return;this.setAttribute("selected",""),this.focus()};#G0=(_)=>{if(_.stopPropagation(),_.detail?.color){let Z={color:_.detail.color,opacity:_.detail.opacity,...t(_.detail.color,_.detail.alpha,_.detail.opacity)};this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))}};#j0=(_)=>{if(_.stopPropagation(),_.detail?.color){let Z={color:_.detail.color,opacity:_.detail.opacity,...t(_.detail.color,_.detail.alpha,_.detail.opacity)};this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))}};#t=(_)=>{_.stopPropagation(),this.dispatchEvent(new CustomEvent(_.type,{bubbles:!0,composed:!0}))};#l(_){let Z=_||this.#L()?.getBoundingClientRect();if(!Z)return{x:0,y:0,px:0,py:0};let $=this.getBoundingClientRect(),J=this.offsetWidth/2,Q=this.offsetHeight/2,j=$.left-Z.left,q=$.top-Z.top,N=j+J,K=q+Q,G=Z.width>0?N/Z.width:0,X=Z.height>0?K/Z.height:0;return{x:this.#O(j),y:this.#O(q),px:G,py:X}}}A("fig-handle",r_);class a_ extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(_){this.setAttribute("value",_??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Z()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="disabled")this.#Z()}#Z(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}A("fig-menu-item",a_);class V0 extends HTMLElement{#Z=null;#_=null;#J=null;#$=this.#G.bind(this);static get observedAttributes(){return["label","direction","sticky"]}get label(){return this.getAttribute("label")??""}set label(_){if(_==null||_==="")this.removeAttribute("label");else this.setAttribute("label",String(_))}connectedCallback(){this.#Q(),this.#j(),this.#q()}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#N()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#Q(),_==="sticky")this.#q()}#Q(){if(!this.hasAttribute("role"))this.setAttribute("role","separator");if(this.getAttribute("direction")==="vertical")this.setAttribute("aria-orientation","vertical");else if(!this.hasAttribute("aria-orientation"))this.setAttribute("aria-orientation","horizontal");let Z=this.label.trim(),$=Array.from(this.children).filter((q)=>q.localName==="label"),J=$.find((q)=>!q.hasAttribute("data-fig-separator-generated")),Q=$.filter((q)=>q.hasAttribute("data-fig-separator-generated"));if(J)Q.forEach((q)=>q.remove());else if(Z){let q=Q[0]??document.createElement("label");if(Q.slice(1).forEach((N)=>N.remove()),q.setAttribute("data-fig-separator-generated",""),q.textContent!==Z)q.textContent=Z;if(!q.parentElement)this.appendChild(q)}else Q.forEach((q)=>q.remove());let j=J?.textContent?.trim()||Z;if(j)this.setAttribute("aria-label",j);else this.removeAttribute("aria-label")}#j(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>this.#Q()),this.#J.observe(this,{childList:!0,characterData:!0,subtree:!0})}#K(){return this.hasAttribute("sticky")&&this.getAttribute("sticky")!=="false"}#q(){if(this.#N(),!this.isConnected||!this.#K()){this.removeAttribute("stuck");return}let _=F1(this);if(this.#Z=_,_?.addEventListener("scroll",this.#$,{passive:!0}),this.#_=new ResizeObserver(this.#$),this.#_.observe(this),_ instanceof Element)this.#_.observe(_);requestAnimationFrame(this.#$)}#N(){this.#Z?.removeEventListener?.("scroll",this.#$),this.#Z=null,this.#_?.disconnect(),this.#_=null}#G(){if(!this.#K()||!this.#Z){this.removeAttribute("stuck");return}let _=parseFloat(getComputedStyle(this).top)||0,Z=this.#Z,$=Z===document.scrollingElement||Z===document.documentElement?{top:0}:Z.getBoundingClientRect(),J=Z instanceof Element?parseFloat(getComputedStyle(Z).paddingTop)||0:0,Q=$.top+J+_;this.toggleAttribute("stuck",this.getBoundingClientRect().top<=Q+1)}}A("fig-separator",V0);function F1(_){let Z=_.parentElement;while(Z){let $=getComputedStyle(Z),J=$.overflowY||$.overflow;if(J&&J!=="visible"&&J!=="clip")return Z;Z=Z.parentElement}return document.scrollingElement}class t_ extends V0{}A("fig-menu-separator",t_);var H1=new Set(["FIG-MENU-ITEM","FIG-SEPARATOR","FIG-MENU-SEPARATOR"]),j0="trigger";function z1(_){return _?.nodeType===1&&H1.has(_.tagName)}function T1(_,Z){if(!_||!Z)return null;let $=Z;while($.parentElement&&$.parentElement!==_)$=$.parentElement;return $.parentElement===_?$:null}class n_ extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#K=null;#q=null;#N=null;#G=null;#W=!1;#X;#Y;#R;#U;#B;#M;#L=this.#x.bind(this);#O=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open","trigger"]}constructor(){super();this.#X=this.#v.bind(this),this.#Y=this.#s.bind(this),this.#R=this.#a.bind(this),this.#U=this.#c.bind(this),this.#B=this.#o.bind(this),this.#M=this.#x.bind(this),this.#T()}get value(){return this.getAttribute("value")||""}set value(_){this.setAttribute("value",_??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){if(_){if(this.#h())return;this.setAttribute("open","")}else this.removeAttribute("open")}connectedCallback(){if(this.#k(),this.#C(),this.#D(),this.#f(),this.#b(),this.open)this.#p()}disconnectedCallback(){if(this.#E(),this.#P(),document.removeEventListener("keydown",this.#U,!0),this.#K)this.#K.disconnect(),this.#K=null}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="open"){if($===null||$==="false")this.#d();else{if(this.#h()){this.removeAttribute("open");return}this.#p()}return}if(_==="disabled"){this.#b();return}if(this.#Z&&(_==="position"||_==="offset"||_==="closedby"))if($!==null)this.#Z.setAttribute(_,$);else this.#Z.removeAttribute(_)}#T(){if(this.#W)return;this.#W=!0;let _=this.attachShadow({mode:"open"});i0(_,{icons:!0});let Z=document.createElement("style");Z.textContent=`
174
+ `:",";this.#$=_.split(Z).map(($)=>$.trim()).filter(Boolean)}#Y(){if(this.replaceChildren(),this.#$.length===0)return;let _=document.createElement("fig-segmented-control");if(_.setAttribute("sizing",this.getAttribute("sizing")||"equal"),T(this,"disabled"))_.setAttribute("disabled","");if(T(this,"full"))_.setAttribute("full","");let Z=this.getAttribute("value");for(let $ of this.#$){let J=document.createElement("fig-segment");if(J.setAttribute("value",$),J.textContent=$,Z===$)J.setAttribute("selected","true");_.appendChild(J)}if(Z)_.setAttribute("value",Z);_.addEventListener("input",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#G($);if(J===null)return;this.#j=!0,this.setAttribute("value",J),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),_.addEventListener("change",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#G($);if(J===null)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(_),this.#Q=_,this.#Z="segments"}#X(){if(this.replaceChildren(),this.#$.length===0)return;let _=document.createElement("fig-dropdown");if(T(this,"disabled"))_.setAttribute("disabled","");let Z=this.getAttribute("value");for(let $ of this.#$){let J=document.createElement("option");if(J.value=$,J.textContent=$,Z===$)J.selected=!0;_.appendChild(J)}if(Z)_.setAttribute("value",Z);_.addEventListener("input",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#G($);if(!J)return;this.#j=!0,this.setAttribute("value",J),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),_.addEventListener("change",($)=>{if($.stopPropagation(),this.#j)return;let J=this.#G($);if(!J)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(_),this.#Q=_,this.#Z="dropdown"}#R(){if(this.#Z==="segments")this.#Y(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#L())});else this.#X()}#U(){if(!this.#Q||this.#j)return;let _=this.getAttribute("value")||"";this.#Q.value=_}#W(_){if(!this.#Q)return;if(this.hasAttribute(_))this.#Q.setAttribute(_,this.getAttribute(_)||"");else this.#Q.removeAttribute(_)}#M(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#L()}),this.#J.observe(this)}#B(_){let Z=document.createRange();Z.selectNodeContents(_);let $=Z.getBoundingClientRect().width,Q=_.getBoundingClientRect().width,j=getComputedStyle(_),q=parseFloat(j.paddingLeft)||0,N=parseFloat(j.paddingRight)||0,G=Q-q-N;return $>G+0.5}#O(){let _=this.querySelectorAll("fig-segment");for(let Z of _)if(this.#B(Z))return!0;return!1}#L(){if(this.#$.length<=1)return;if(this.#Z==="segments"){let _=this.#Q;if(_&&_.scrollWidth>_.clientWidth+1||this.#O())this.#_=this.clientWidth,this.#X()}else if(this.#_>0&&this.clientWidth>=this.#_)this.#Y(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let _=this.#Q;if(_&&_.scrollWidth>_.clientWidth+1||this.#O())this.#X()})})}}F("fig-options",Y_);class R_ extends HTMLElement{#Z=!1;#_=!1;#J=!1;#$="";#Q=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#j={range:{min:0,max:100,step:1},hue:{min:0,max:255,step:1},delta:{min:-100,max:100,step:1},stepper:{min:0,max:100,step:25},opacity:{min:0,max:100,step:0.1,color:"var(--figma-color-icon)"}};#G;#q;#N;#K;#Y;#X;#R;#U=null;#W=null;#M=null;#B=null;constructor(){super();this.initialChildren=null,this.#G=(_)=>{_.stopPropagation(),this.#m()},this.#q=(_)=>{_.stopPropagation(),this.#y()},this.#Y=(_)=>{this.#b(_)},this.#N=(_)=>{_.stopPropagation(),this.#F()},this.#K=(_)=>{_.stopPropagation(),this.#g()},this.#X=()=>{this.#Z=!0},this.#R=()=>{if(this.#Z=!1,this.#_&&this.isConnected)this.#_=!1,this.#k()}}#O(){let _=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.getAttribute("text")!=="false",this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";let Z=this.#j[this.type]||this.#j.range,$=(J,Q)=>{let j=this.getAttribute(J),q=j===null||j.trim()===""?Q:Number(j);return Number.isFinite(q)?q:Q};if(this.min=$("min",Z.min),this.max=$("max",Z.max),this.step=$("step",Z.step),!(this.step>0))this.step=Z.step>0?Z.step:1;this.color=this.getAttribute("color")||Z?.color,this.default=this.#P(),this.value=this.#E(_)}#L(){if(!this.querySelector("[type=range]"))return!1;return this.getAttribute("text")!=="false"===!!this.querySelector("fig-input-number")}#T(){if(this.#O(),this.color)this.style.setProperty("--color",this.color);else this.style.removeProperty("--color");if(this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.input.className=this.type,this.input.min=String(this.min),this.input.max=String(this.max),this.input.step=String(this.step),this.input.value=String(this.value),this.input.disabled=this.disabled,this.text)this.input.setAttribute("tabindex","-1");else this.input.removeAttribute("tabindex");if(this.input.setAttribute("aria-valuemin",String(this.min)),this.input.setAttribute("aria-valuemax",String(this.max)),this.input.setAttribute("aria-valuenow",String(this.value)),this.figInputNumber=this.querySelector("fig-input-number"),this.figInputNumber){if(this.figInputNumber.setAttribute("placeholder",this.placeholder),this.figInputNumber.setAttribute("min",String(this.min)),this.figInputNumber.setAttribute("max",String(this.max)),this.figInputNumber.setAttribute("transform",String(this.transform)),this.figInputNumber.setAttribute("step",String(this.step)),this.figInputNumber.setAttribute("value",String(this.value)),this.units)this.figInputNumber.setAttribute("units",this.units);else this.figInputNumber.removeAttribute("units");if(this.precision!==null)this.figInputNumber.setAttribute("precision",String(this.precision));else this.figInputNumber.removeAttribute("precision");this.figInputNumber.disabled=this.disabled,this.figInputNumber.toggleAttribute("disabled",this.disabled)}}#D(){if(this.#v(),this.input.removeEventListener("input",this.#G),this.input.addEventListener("input",this.#G),this.input.removeEventListener("change",this.#q),this.input.addEventListener("change",this.#q),this.input.removeEventListener("keydown",this.#Y),this.input.addEventListener("keydown",this.#Y),this.input.removeEventListener("pointerdown",this.#X),this.input.addEventListener("pointerdown",this.#X),this.input.removeEventListener("pointerup",this.#R),this.input.addEventListener("pointerup",this.#R),this.input.removeEventListener("pointercancel",this.#R),this.input.addEventListener("pointercancel",this.#R),this.style.setProperty("--default",this.#A(this.default)),this.figInputNumber)this.#h(),this.figInputNumber.removeEventListener("input",this.#N),this.figInputNumber.addEventListener("input",this.#N),this.figInputNumber.removeEventListener("change",this.#K),this.figInputNumber.addEventListener("change",this.#K)}#k(){if(this.#O(),this.color)this.style.setProperty("--color",this.color);let _=L("input",{type:"range",tabindex:this.text?"-1":null,disabled:this.disabled,min:this.min,max:this.max,step:this.step,className:this.type,value:this.value,"aria-valuemin":this.min,"aria-valuemax":this.max,"aria-valuenow":this.value}),Z=L("div",{className:"fig-slider-input-container",role:"group"},_);for(let J of this.initialChildren??[])Z.appendChild(J);let $=[Z];if(this.text)$.push(L("fig-input-number",{placeholder:this.placeholder,min:this.min,max:this.max,transform:this.transform,step:this.step,value:this.value,units:this.units||null,precision:this.precision,disabled:this.disabled}));if(this.replaceChildren(...$),this.input=_,this.inputContainer=Z,this.figInputNumber=this.querySelector("fig-input-number"),this.#D(),this.datalist=this.querySelector("datalist"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||v()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("data-generated","slider-stepper"),this.datalist.setAttribute("id",v());let J=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1));for(let Q=0;Q<J;Q++){let j=document.createElement("option");j.setAttribute("value",this.min+Q*this.step),this.datalist.append(j)}this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.type==="delta"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("data-generated","slider-delta"),this.datalist.setAttribute("id",v());let J=document.createElement("option");J.setAttribute("value",this.default),this.datalist.append(J),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.#I())this.#d();this.#t(),this.#C()}connectedCallback(){if(this.initialChildren===null)this.initialChildren=Array.from(this.childNodes);if(this.#L()){this.#T(),this.#D(),this.#C();return}this.#k()}get value(){if(this.#$!=="")return this.#$;let _=this.getAttribute("value");if(_!==null)return String(this.#E(_));return""}set value(_){let Z=_===null||_===void 0?"":String(_),J=this.min!==void 0||this.max!==void 0?String(this.#E(Z)):Z;if(this.#$=J,this.getAttribute("value")!==J)this.#J=!0,this.setAttribute("value",J),this.#J=!1;if(this.input&&this.input.value!==J)this.input.value=J,this.input.setAttribute("aria-valuenow",J);if(this.figInputNumber)this.figInputNumber.setAttribute("value",J);if(this.input)this.#x()}get defaultValue(){return this.#P()}disconnectedCallback(){if(this.#_=!1,this.input)this.input.removeEventListener("input",this.#G),this.input.removeEventListener("change",this.#q),this.input.removeEventListener("keydown",this.#Y),this.input.removeEventListener("pointerdown",this.#X),this.input.removeEventListener("pointerup",this.#R),this.input.removeEventListener("pointercancel",this.#R);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#N),this.figInputNumber.removeEventListener("change",this.#K)}#F(){if(this.figInputNumber){let _=this.figInputNumber.value,Z=this.#E(_);this.value=Z,this.input.value=String(Z),this.#C(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#A(_){let{min:Z,max:$}=this.#z(),J=$-Z;if(J===0)return 0;return(Number(_)-Z)/J}#H(_){if(_===null||_===void 0)return null;if(typeof _==="string"&&_.trim()==="")return null;let Z=Number(_);return Number.isFinite(Z)?Z:null}#z(){let _=this.#H(this.min),Z=this.#H(this.max);if(_===null)_=0;if(Z===null)Z=_;if(_>Z)[_,Z]=[Z,_];return{min:_,max:Z}}#S(_){let{min:Z,max:$}=this.#z();return Math.min($,Math.max(Z,_))}#V(_){let{min:Z}=this.#z(),$=this.#H(this.step);if(!($>0))return!0;let J=(_-Z)/$,Q=Math.round(J),j=Number.EPSILON*Math.max(1,Math.abs(J))*16;return Math.abs(J-Q)<=j}#f(){return["range","hue","opacity"].includes(this.type)}#I(){if(!this.hasAttribute("default")||!this.#f())return!1;let{min:_,max:Z}=this.#z(),$=this.#H(this.getAttribute("default"));return $!==null&&$>=_&&$<=Z&&this.#V($)}#P(_=this.getAttribute("default")){let{min:Z,max:$}=this.#z(),J=this.#H(_);if(J!==null&&J>=Z&&J<=$&&(this.type!=="stepper"||this.#V(J)))return J;return this.type==="delta"?Math.min($,Math.max(Z,0)):Z}#w(){if(this.type==="delta"){let Z=this.#H(this.default);if(Z!==null)return this.#S(Z);return this.#S(0)}if(this.type==="range"){let{min:Z,max:$}=this.#z();return this.#S(Z+($-Z)/2)}let{min:_}=this.#z();return _}#E(_){let Z=this.#H(_);if(Z===null)return this.#w();return this.#S(Z)}#x(){let _=this.#A(this.value),Z=this.#A(this.default),$=_<Z?-1:1,J=_===Z?1:0;if(this.#U!==_)this.style.setProperty("--slider-complete",_),this.#U=_;if(this.#W!==Z)this.style.setProperty("--default",Z),this.#W=Z;if(this.#M!==$)this.style.setProperty("--slider-delta-direction",$),this.#M=$;if(this.#B!==J)this.style.setProperty("--unchanged",J),this.#B=J}#C(){let _=this.input.value;if(this.value=_,this.#x(),this.input.setAttribute("aria-valuenow",_),this.figInputNumber)this.figInputNumber.setAttribute("value",_)}#v(){if(!this.input)return;if(this.text){this.input.setAttribute("aria-hidden","true"),["aria-label","aria-labelledby","aria-describedby","aria-valuetext"].forEach((_)=>this.input.removeAttribute(_)),this.#h();return}this.input.removeAttribute("aria-hidden"),this.#Q.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.input.removeAttribute(_);else this.input.setAttribute(_,Z)})}#h(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.figInputNumber.removeAttribute(_);else this.figInputNumber.setAttribute(_,Z)})}#m(){this.#C(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#y(){this.#Z=!1,this.#C(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#b(_){if(this.disabled||!_.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(_.key))return;_.preventDefault();let Z=_.key==="ArrowRight"||_.key==="ArrowUp"?1:-1,$=this.#H(this.input.value)??this.#w(),J=this.#H(this.step)??1,Q=this.#E($+J*10*Z);this.value=Q,this.input.value=String(Q),this.#C(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#g(){if(this.figInputNumber){let _=this.figInputNumber.value,Z=this.#E(_);this.value=Z,this.input.value=String(Z),this.#C(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}#u(_,Z){if(!this.input)return;let $=this.#j[this.type]||this.#j.range,J=Z===null||String(Z).trim()===""?$[_]:Number(Z),Q=Number.isFinite(J)?J:$[_];if(_==="step"&&!(Q>0))Q=$.step>0?$.step:1;if(this[_]===Q&&this.input[_]===String(Q))return;if(this[_]=Q,this.input[_]=String(Q),_==="min")this.input.setAttribute("aria-valuemin",String(Q));else if(_==="max")this.input.setAttribute("aria-valuemax",String(Q));if(this.figInputNumber)this.figInputNumber.setAttribute(_,String(Q));if(!this.hasAttribute("default")&&this.type!=="delta")this.default=this.min;else this.default=this.#P();this.value=this.#E(this.value),this.#x(),this.#l(),this.#t()}#l(){if(this.type!=="stepper"||!this.datalist)return;let _=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1)),Z=document.createDocumentFragment();for(let $=0;$<_;$++){let J=document.createElement("option");J.setAttribute("value",this.min+$*this.step),Z.append(J)}this.datalist.replaceChildren(Z),this.input.setAttribute("list",this.datalist.id),this.#t()}#t(){let _=this.datalist?.getAttribute("data-generated")==="slider-default",Z=this.#I();if(_&&!Z)this.datalist.remove(),this.datalist=null,this.input?.removeAttribute("list");else if(!this.datalist&&Z)this.#d();if(!this.datalist)return;let $=String(this.default);if(_){let j=this.datalist.querySelector("option")??document.createElement("option");j.value=$,this.datalist.replaceChildren(j)}let J=[...this.datalist.querySelectorAll("option")];J.forEach((j)=>j.removeAttribute("default"));let Q=J.find((j)=>j.value===$);if(!Q&&this.type==="delta"&&this.datalist.getAttribute("data-generated")==="slider-delta")Q=document.createElement("option"),Q.value=$,this.datalist.replaceChildren(Q);Q?.setAttribute("default","true")}#d(){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("data-generated","slider-default"),this.datalist.setAttribute("id",v());let _=document.createElement("option");_.value=String(this.default),this.datalist.append(_),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.id)}#i(){if(this.#Z){this.#_=!0;return}this.#_=!1,this.#k()}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"]}focus(){if(this.text&&this.figInputNumber){this.figInputNumber.focus();return}this.input.focus()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="value"&&this.#J)return;if(this.input)switch(_){case"color":this.color=$,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=$!==null&&$!=="false",this.figInputNumber)this.figInputNumber.toggleAttribute("disabled",this.disabled);break;case"value":if(this.#Z)break;this.value=$,this.#C();break;case"transform":if(this.transform=Number($)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=$!==null?Number($):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=$!==null?$:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=this.#P($),this.#x(),this.#t();break;case"min":case"max":case"step":this.#u(_,$);break;case"units":if(this.units=$||"",this.figInputNumber)if(this.units)this.figInputNumber.setAttribute("units",this.units);else this.figInputNumber.removeAttribute("units");break;case"type":case"variant":if(!this.#Z)this[_]=$;this.#i();break;case"text":if(!this.#Z)this.text=$!=="false";this.#i();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#v();break;default:this[_]=this.input[_]=$,this.#C();break}}}F("fig-slider",R_);class U_ extends HTMLElement{#Z=!1;#_=!1;#J="";#$=!1;#Q;#j;#G;#q;#N;#K;#Y;#X;#R=null;#U=0;#W="";#M="";#B=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#Q=this.#w.bind(this),this.#j=this.#x.bind(this),this.#G=this.#x.bind(this),this.#q=this.#E.bind(this),this.#N=(_)=>{_.stopPropagation(),this.#P(_)},this.#K=(_)=>{_.stopPropagation();let Z=_.target.value;if(this.type==="number")Z=Number(Z)/(this.transform||1);this.value=Z,this.#z(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))},this.#Y=()=>{if(!this.disabled)this.focus()},this.#X=this.#L.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")&&this.getAttribute("multiline")!=="false",this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}if(this.input=this.#O(),this.input.readOnly=this.readonly,this.disabled=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.input.disabled=this.disabled,this.#F(),this.#A(),this.#H(),this.#z(),this.#S(),this.#f(),U0(this),this.#T(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#I(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#I(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#I(this.step));this.addEventListener("pointerdown",this.#q)}this.removeEventListener("click",this.#X),this.addEventListener("click",this.#X),this.input.removeEventListener("change",this.#N),this.input.addEventListener("change",this.#N),this.input.removeEventListener("input",this.#K),this.input.addEventListener("input",this.#K)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#N),this.input.removeEventListener("input",this.#K);if(this.removeEventListener("click",this.#X),this.removeEventListener("pointerdown",this.#q),window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#j),window.removeEventListener("blur",this.#G),this.#R?.disconnect(),this.#R=null,this.#U)cancelAnimationFrame(this.#U),this.#U=0}focus(){this.input.focus()}#O(){let _=this.multiline,Z=this.querySelector("input,textarea");if(Z){if(_?Z.tagName==="TEXTAREA":Z.tagName==="INPUT")return Z;Z.remove()}let $;if(_)$=document.createElement("textarea"),$.value=this.value;else $=document.createElement("input"),$.type=this.type,$.value=this.type==="number"?this.#I(this.value):this.value;if($.setAttribute("data-generated","input-control"),this.name)$.name=this.name;return $.placeholder=this.placeholder,this.insertBefore($,this.querySelector('[slot="append"]')),$}#L(_){let Z=_.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;if(this.disabled)return;this.focus()}#T(){this.#R?.disconnect(),this.#R=new MutationObserver(()=>this.#D()),this.#R.observe(this,{childList:!0,characterData:!0,subtree:!0})}#D(){if(this.#U)return;this.#U=requestAnimationFrame(()=>{if(this.#U=0,!this.isConnected)return;this.#k()})}#k(){if(!this.input||!this.contains(this.input))this.input=this.#O(),this.input.readOnly=this.readonly,this.input.addEventListener("change",this.#N),this.input.addEventListener("input",this.#K);this.#F(),this.#A(),this.#H(),this.#z(),this.#S(),this.#f(),U0(this)}#F(){if(!this.input)return;this.#B.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.input.removeAttribute(_);else this.input.setAttribute(_,Z)})}#A(){let _=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){_?.remove();return}if(this.querySelector('[slot="prepend"]:not([data-generated])')){_?.remove();return}if(_){let J=_.querySelector("fig-icon");if(J&&J.getAttribute("name")!=="search")J.setAttribute("name","search");J?.removeAttribute("color");return}let $=b("search");$.setAttribute("slot","prepend"),$.setAttribute("data-generated","search-prefix"),$.addEventListener("click",this.#Y),this.prepend($)}#H(){let _=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){_?.remove();return}if(this.querySelector('[slot="append"]:not([data-generated])')){_?.remove();return}if(_){let q=_.querySelector("fig-icon");if(q&&q.getAttribute("name")!=="close")q.setAttribute("name","close");return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","search-clear");let J=document.createElement("fig-tooltip");J.setAttribute("text","Clear search");let Q=document.createElement("fig-button");Q.setAttribute("variant","ghost"),Q.setAttribute("icon",""),Q.setAttribute("aria-label","Clear search");let j=b("close",{size:"small"});j.setAttribute("color","var(--figma-color-icon-secondary)"),Q.append(j),J.append(Q),$.append(J),this.append($),Q.addEventListener("click",(q)=>{if(q.preventDefault(),q.stopPropagation(),this.disabled)return;if(!this.input||this.input.value===""){this.focus();return}this.value="",this.input.value="",this.dispatchEvent(new CustomEvent("input",{detail:"",bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:"",bubbles:!0})),this.#z(),this.focus()})}#z(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#S(){let _=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){_?.remove(),this.#_=!1;return}if(this.querySelector('[slot="append"]:not([data-generated])')){_?.remove();return}if(_){this.#V(_);return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","password-toggle");let J=document.createElement("fig-tooltip"),Q=document.createElement("fig-button");Q.setAttribute("variant","ghost"),Q.setAttribute("icon","");let j=b("visible",{size:"small"});j.setAttribute("color","var(--figma-color-icon-secondary)"),Q.append(j),J.append(Q),$.append(J),this.append($),this.#V($),Q.addEventListener("click",(q)=>{if(q.preventDefault(),q.stopPropagation(),this.disabled)return;if(this.#_=!this.#_,this.input)this.input.type=this.#_?"text":"password";this.#V($),this.focus()})}#V(_){let Z=_.querySelector("fig-tooltip"),$=_.querySelector("fig-button"),J=_.querySelector("fig-icon"),Q=this.#_?"Hide password":"Show password";Z?.setAttribute("text",Q),$?.setAttribute("aria-label",Q),J?.setAttribute("name",this.#_?"visible":"hidden")}#f(){this.querySelectorAll('[data-generated="search-clear"] fig-button, [data-generated="password-toggle"] fig-button').forEach((_)=>{if(this.disabled)_.setAttribute("disabled","");else _.removeAttribute("disabled")})}#I(_){if(_==="")return"";let Z=Number(_)*(this.transform||1);return Z=this.#v(Z),Z}#P(_){_.stopPropagation();let Z=_.target.value,$=Z;if(this.type==="number")Z=Z/(this.transform||1),Z=this.#C(Z,!1),$=Z*(this.transform||1);this.value=Z,this.input.value=$,this.#z(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#w(_){if(this.type!=="number")return;if(_.buttons===0){this.#x();return}let Z=(this.step||1)*_.movementX,$=Number(this.input.value);$=$/(this.transform||1)+Z,$=this.#C($,!1);let J=$*(this.transform||1);$=this.#v($),J=this.#v(J),this.value=$,this.input.value=J,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#E(_){if(this.type!=="number")return;if(_.altKey||_.target.closest("[slot]"))this.#Z=!0,this.#W=this.style.userSelect,this.#M=document.body.style.cursor,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Q),window.addEventListener("pointerup",this.#j),window.addEventListener("pointercancel",this.#j),window.addEventListener("blur",this.#G)}#x(_){if(this.type!=="number")return;let Z=this.#Z;if(this.#Z=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#M,this.style.userSelect=this.#W,window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#j),window.removeEventListener("pointercancel",this.#j),window.removeEventListener("blur",this.#G),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#C(_,Z=!0){let $=_;if(this.type==="number"){if($=Number($),typeof this.min==="number")$=Math.max(Z?this.#I(this.min):this.min,$);if(typeof this.max==="number")$=Math.min(Z?this.#I(this.max):this.max,$);$=this.#v($)}return $}#v(_,Z=2){let $=Math.round(_*100)/100;return Number.isInteger($)?$:$.toFixed(Z)}get value(){return this.#J}set value(_){let Z=_??"";this.#J=Z;let $=String(Z);if(this.getAttribute("value")!==$)this.#$=!0,this.setAttribute("value",$),this.#$=!1;this.#h(Z)}#h(_){if(!this.input||this.#Z)return;let Z=this.type==="number"?String(this.#I(_)):String(_??"");if(this.input.value!==Z)this.input.value=Z;this.#z()}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","multiline","step","min","max","transform","name","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(_,Z,$){if(this.input)switch(_){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false",this.#f();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.#I(this.value);break;case"value":if(this.#Z)break;let J=$;if(this.type==="number")J=this.#C(J,!1);if(this.#J=J??"",!this.#$)this.#h(this.#J);break;case"min":case"max":case"step":if($===null||$==="")this[_]=void 0,this.input.removeAttribute(_);else this[_]=this.input[_]=Number($),this.input.setAttribute(_,$);break;case"name":if(this[_]=this.input[_]=$||"",$)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=$??"",this.input.placeholder=this.placeholder;break;case"type":if(this.type=$||"text",this.input.type=this.type,this.removeEventListener("pointerdown",this.#q),this.type==="number")this.step=this.hasAttribute("step")?Number(this.getAttribute("step")):void 0,this.min=this.hasAttribute("min")?Number(this.getAttribute("min")):void 0,this.max=this.hasAttribute("max")?Number(this.getAttribute("max")):void 0,this.transform=Number(this.getAttribute("transform")||1),this.addEventListener("pointerdown",this.#q);this.#A(),this.#H(),this.#z(),this.#S(),this.#f();break;case"multiline":{let Q=$!==null&&$!=="false";if(Q!==this.multiline){this.multiline=Q;let j=this.input;j.removeEventListener("change",this.#N),j.removeEventListener("input",this.#K),j.remove(),this.input=this.#O(),this.input.readOnly=this.readonly,this.input.disabled=Boolean(this.disabled),this.input.addEventListener("change",this.#N),this.input.addEventListener("input",this.#K),this.#F()}break}case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#F();break;default:this[_]=this.input[_]=$;break}}}F("fig-input-text",U_);class n extends HTMLElement{#Z;#_;#J;#$;#Q;#j;#G;#q;#N;#K;#Y;#X;#R;#U;#W;#M;#B=!1;#O=null;#L=null;#T=0;#D=0;#k=!1;#F;#A;#H=null;#z=0;#S="";#V="";#f=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#I="px";static#P=350;static#w=60;#E(_){return(_||"").split(",").map((Z)=>Z.trim().toLowerCase()).filter(Boolean)}#x(_){let Z=(_||"").trim();if(!Z)return"";return(this.#U??[]).includes(Z.toLowerCase())?"":Z}#C(){this.#X=this.#x(this.#R)}#v(_){if(_&&!this.#O)this.#O=document.createElement("span"),this.#O.className="fig-steppers",this.#O.append(L("button",{className:"fig-stepper-up",tabindex:"-1","aria-label":"Increase"}),L("button",{className:"fig-stepper-down",tabindex:"-1","aria-label":"Decrease"})),this.#O.addEventListener("pointerdown",(Z)=>{Z.preventDefault(),Z.stopPropagation();let $=Z.target.closest("button");if(!$||this.disabled||$.disabled)return;let J=$.classList.contains("fig-stepper-up")?1:-1;this.#m(Z,J),this.input.focus()}),this.append(this.#O);else if(!_&&this.#O)this.#b(),this.#O.remove(),this.#O=null;this.#h()}#h(){if(!this.#O)return;let _=this.#O.querySelector(".fig-stepper-up"),Z=this.#O.querySelector(".fig-stepper-down");if(!_||!Z)return;let $=this.input?this.#s(this.input.value):this.value,J=$!==""&&$!==null&&$!==void 0?Number($)/(this.transform||1):Number(this.value),Q=Number.isFinite(J),j=Boolean(this.disabled),q=Q&&typeof this.min==="number"&&J<=this.min,N=Q&&typeof this.max==="number"&&J>=this.max;_.disabled=j||N,Z.disabled=j||q}#m(_,Z){if(this.#b(),this.#L=_.pointerId,this.#k=this.#g(Z),window.addEventListener("pointerup",this.#F),window.addEventListener("pointercancel",this.#F),window.addEventListener("blur",this.#A),!this.#k)return;this.#T=window.setTimeout(()=>{this.#T=0,this.#D=window.setInterval(()=>{let $=this.#g(Z);if(this.#k||=$,!$)this.#y()},n.#w)},n.#P)}#y(){if(this.#T)clearTimeout(this.#T),this.#T=0;if(this.#D)clearInterval(this.#D),this.#D=0}#b(_=!0){if(this.#y(),window.removeEventListener("pointerup",this.#F),window.removeEventListener("pointercancel",this.#F),window.removeEventListener("blur",this.#A),this.#L=null,_&&this.#k)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}));this.#k=!1}#g(_){if(this.disabled)return!1;let Z=this.step||1,$=this.value,J=this.#s(this.input.value),Q=(J!==""?Number(J)/(this.transform||1):0)+Z*_;if(Q=this.#a(Q,!1),Q===$)return!1;return this.value=Q,this.input.value=this.#c(this.value),this.#h(),this.#p(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),!0}constructor(){super();this.#Z=this.#N0.bind(this),this.#_=this.#j0.bind(this),this.#J=this.#j0.bind(this),this.#$=this.#K0.bind(this),this.#Q=(_)=>{_.stopPropagation(),this.#q0(_)},this.#j=(_)=>{_.stopPropagation(),this.#G0(_)},this.#G=(_)=>{this.#_0(_)},this.#q=(_)=>{this.#Z0(_)},this.#N=(_)=>{this.#n(_)},this.#F=(_)=>{if(this.#L!==null&&_.pointerId!==this.#L)return;this.#b()},this.#A=()=>this.#b(),this.#K=this.focus.bind(this),this.#Y=this.#l.bind(this)}connectedCallback(){let _=this.getAttribute("value");this.value=_!==null&&_!==""?Number(_):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#R=this.getAttribute("units")||"";let Z=this.getAttribute("units-disallow");if(this.#U=this.#E(Z===null?n.#I:Z),this.#C(),this.#W=this.getAttribute("unit-position")||"suffix",this.#M=this.#X0(this.hasAttribute("precision")?this.getAttribute("precision"):null),this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));this.transform=Number(this.getAttribute("transform")||1);let $=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.input=this.#u(),this.#o(),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.#v($),this.hasAttribute("disabled")){let J=this.getAttribute("disabled");this.disabled=this.input.disabled=J!=="false"}this.#h(),this.#p(),U0(this),this.addEventListener("pointerdown",this.#$),this.removeEventListener("click",this.#Y),this.addEventListener("click",this.#Y),this.#t(),this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.input.removeEventListener("input",this.#j),this.input.addEventListener("input",this.#j),this.input.removeEventListener("focus",this.#G),this.input.addEventListener("focus",this.#G),this.input.removeEventListener("blur",this.#q),this.input.addEventListener("blur",this.#q),this.input.removeEventListener("keydown",this.#N),this.input.addEventListener("keydown",this.#N)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#Q),this.input.removeEventListener("input",this.#j),this.input.removeEventListener("focus",this.#G),this.input.removeEventListener("blur",this.#q),this.input.removeEventListener("keydown",this.#N);if(this.removeEventListener("click",this.#Y),this.removeEventListener("pointerdown",this.#$),window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#_),window.removeEventListener("blur",this.#J),this.#b(!1),this.#H?.disconnect(),this.#H=null,this.#z)cancelAnimationFrame(this.#z),this.#z=0}focus(){this.input.focus()}#u(){let _=this.querySelector("input");if(_)return _;let Z=document.createElement("input");if(Z.type="text",Z.inputMode="decimal",Z.setAttribute("data-generated","input-control"),this.name)Z.name=this.name;return Z.placeholder=this.placeholder,Z.value=this.#c(this.value),this.insertBefore(Z,this.querySelector('[slot="append"]')),Z}#l(_){let Z=_.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;this.focus()}#t(){this.#H?.disconnect(),this.#H=new MutationObserver(()=>this.#d()),this.#H.observe(this,{childList:!0,characterData:!0,subtree:!0})}#d(){if(this.#z)return;this.#z=requestAnimationFrame(()=>{if(this.#z=0,!this.isConnected)return;this.#i()})}#i(){if(!this.input||!this.contains(this.input))this.input=this.#u(),this.input.addEventListener("change",this.#Q),this.input.addEventListener("input",this.#j),this.input.addEventListener("focus",this.#G),this.input.addEventListener("blur",this.#q),this.input.addEventListener("keydown",this.#N);let _=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.#O&&!this.contains(this.#O))this.#O=null;this.#v(_),this.#o(),this.#p(),U0(this)}#o(){if(!this.input)return;this.#f.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.input.removeAttribute(_);else this.input.setAttribute(_,Z)})}#p(){if(!this.input)return;if(this.input.setAttribute("role","spinbutton"),typeof this.min==="number")this.input.setAttribute("aria-valuemin",String(this.min));else this.input.removeAttribute("aria-valuemin");if(typeof this.max==="number")this.input.setAttribute("aria-valuemax",String(this.max));else this.input.removeAttribute("aria-valuemax");let _=this.value===""?null:Number(this.value);if(Number.isFinite(_))this.input.setAttribute("aria-valuenow",String(_)),this.input.setAttribute("aria-valuetext",this.#c(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#s(_){if(!_)return"";if(!this.#X){let J=_.replace(/[^\d.-]/g,""),Q=J.split(".");if(Q.length>2)J=Q[0]+"."+Q.slice(1).join("");return J}let Z=_.replace(this.#X,"").trim();Z=Z.replace(/[^\d.-]/g,"");let $=Z.split(".");if($.length>2)Z=$[0]+"."+$.slice(1).join("");return Z}#c(_){if(_===""||_===null||_===void 0)return"";let Z=Number(_)*(this.transform||1);if(isNaN(Z))return"";if(Z=this.#r(Z),!this.#X)return Z.toString();if(this.#W==="prefix")return this.#X+Z;else return Z+this.#X}#e(_){if(_===""||_===null||_===void 0)return"";let Z=Number(_)*(this.transform||1);return Z=this.#r(Z),Z.toString()}#_0(_){this.#B=!0,setTimeout(()=>{let Z=_.target.value;if(Z&&this.#X)if(this.#W==="prefix")_.target.setSelectionRange(this.#X.length,Z.length);else{let $=Z.indexOf(this.#X);if($>-1)_.target.setSelectionRange(0,$)}},0)}#Z0(_){this.#B=!1;let Z=this.#s(_.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#a($,!1),this.value=$,_.target.value=this.#c(this.value)}else this.value="",_.target.value="";this.#h(),this.#p()}#n(_){if(this.disabled)return;if(_.key!=="ArrowUp"&&_.key!=="ArrowDown")return;_.preventDefault();let Z=this.step||1,$=_.shiftKey?10:1,J=Z*$*(_.key==="ArrowUp"?1:-1),Q=this.#s(this.input.value),j=(Q!==""?Number(Q)/(this.transform||1):0)+J;j=this.#a(j,!1),this.value=j,this.input.value=this.#c(this.value),this.#h(),this.#p(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#G0(_){let Z=this.#s(_.target.value);if(Z!=="")this.value=Number(Z)/(this.transform||1);else this.value="";this.#h(),this.#p(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#q0(_){_.stopPropagation();let Z=this.#s(_.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#a($,!1),this.value=$,_.target.value=this.#c(this.value)}else this.value="",_.target.value="";this.#h(),this.#p(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#N0(_){if(this.disabled)return;if(_.buttons===0){this.#j0();return}let Z=(this.step||1)*_.movementX,$=this.#s(this.input.value),J=Number($)/(this.transform||1)+Z;J=this.#a(J,!1),this.value=J,this.input.value=this.#c(this.value),this.#h(),this.#p(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#K0(_){if(this.disabled)return;if(_.altKey||_.target.closest("[slot]"))this.#B=!0,this.#S=this.style.userSelect,this.#V=document.body.style.cursor,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Z),window.addEventListener("pointerup",this.#_),window.addEventListener("pointercancel",this.#_),window.addEventListener("blur",this.#J)}#j0(_){let Z=this.#B;if(this.#B=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#V,this.style.userSelect=this.#S,window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#_),window.removeEventListener("pointercancel",this.#_),window.removeEventListener("blur",this.#J),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#a(_,Z=!0){let $=Number(_);if(isNaN($))return"";if(typeof this.min==="number")$=Math.max(this.min,$);if(typeof this.max==="number")$=Math.min(this.max,$);return $=this.#R0($),$}#r(_){let Z=this.#M??2,$=this.#R0(_);if(this.#M!==null)return $.toFixed(Z);return Number.isInteger($)?String($):String(parseFloat($.toFixed(Z)))}#R0(_){let Z=this.#M??2,$=Math.pow(10,Z);return Math.round(_*$)/$}#X0(_){if(_===null||_===void 0||_==="")return null;let Z=Number(_);if(!Number.isFinite(Z))return 2;return Math.max(0,Math.min(100,Math.trunc(Z)))}static get observedAttributes(){return["value","placeholder","disabled","step","min","max","transform","name","units","units-disallow","unit-position","steppers","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(_,Z,$){if(this.input)switch(_){case"disabled":if(this.disabled=this.input.disabled=$!==null&&$!=="false",this.disabled)this.#b();this.#h();break;case"units":this.#R=$||"",this.#C(),this.input.value=this.#c(this.value),this.#p();break;case"units-disallow":this.#U=this.#E($===null?n.#I:$),this.#C(),this.input.value=this.#c(this.value),this.#p();break;case"unit-position":this.#W=$||"suffix",this.input.value=this.#c(this.value),this.#p();break;case"transform":this.transform=Number($)||1,this.input.value=this.#c(this.value),this.#p();break;case"value":if(this.#B)break;let J=$!==null&&$!==""?Number($):"";if(J!=="")J=this.#a(J,!1);this.value=J,this.input.value=this.#c(this.value),this.#h(),this.#p();break;case"min":case"max":case"step":if($===null||$===""){this[_]=void 0,this.#h(),this.#p();break}this[_]=Number($),this.#h(),this.#p();break;case"steppers":{let Q=$!==null&&$!=="false";this.#v(Q);break}case"precision":this.#M=this.#X0($),this.input.value=this.#c(this.value),this.#p();break;case"name":if(this[_]=this.input[_]=$||"",$)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=$??"",this.input.placeholder=this.placeholder;break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#o();break;default:this[_]=this.input[_]=$;break}}}F("fig-input-number",n);class W_ extends HTMLElement{constructor(){super()}connectedCallback(){this.src=this.getAttribute("src"),this.name=this.getAttribute("name"),this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials),this.setSrc(this.src),this.img=this.querySelector("img")}setSrc(_){if(this.src=_,!_){this.querySelector(":scope > img")?.remove(),this.img=null;return}let Z=this.querySelector(":scope > img")||document.createElement("img");if(Z.src=_,Z.alt=this.name||"",!Z.isConnected)this.replaceChildren(Z);this.img=Z}getInitials(_){return _?_.split(" ").map((Z)=>Z[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(_,Z,$){if(this[_]=$,_==="name"){if(this.img)this.img.alt=$||"";this.name=$,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials)}else if(_==="src")this.src=$,this.setSrc(this.src)}}F("fig-avatar",W_);class L_ extends HTMLElement{#Z=!1;#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#q=null;constructor(){super();this.#J=this.#X.bind(this),this.#$=this.focus.bind(this),this.#Q=this.#R.bind(this),this.#j=this.#U.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(!this.isConnected)return;this.#K(),this.#N()})}#N(){if(this.#G||typeof MutationObserver>"u")return;this.#G=new MutationObserver(()=>{this.#K()}),this.#G.observe(this,{childList:!0})}#K(){let _=this.label,Z=this.#_;_?.removeEventListener("click",this.#J),_?.removeEventListener("click",this.#$),_?.removeEventListener("pointerenter",this.#Q),_?.removeEventListener("pointerleave",this.#j),Z?.removeEventListener("click",this.#J),this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((q)=>q.nodeType===Node.ELEMENT_NODE&&q.nodeName.toLowerCase().startsWith("fig-")&&!(q instanceof Element&&q.classList.contains("fig-field-chevron"))),this.#Y();let $=this.input?.localName??"",J=this.input?.getAttribute?.("edit"),j=$==="fig-select"||$==="fig-menu"||$==="fig-dropdown"||$==="fig-tooltip"||$==="fig-fill-picker"||$==="fig-input-palette"&&(J==="false"||J==="picker")||this.input instanceof HTMLDialogElement;if(this.#Z=!!(this.input&&("open"in this.input)&&typeof this.input.open!=="function"&&!j),this.#Z&&this.label){if(!this.#_||!this.#_.isConnected)this.#_=b("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#_,this.label);this.#_.addEventListener("click",this.#J),this.label.addEventListener("click",this.#J)}else{if(this.#_)this.#_.removeEventListener("click",this.#J),this.#_.remove(),this.#_=null;if(this.input&&this.label){if(this.input.querySelectorAll("input, select, textarea").length!==1)this.label.addEventListener("click",this.#$)}}if(this.input&&this.label&&!this.#Z)this.#W();if(this.label)this.label.removeEventListener("pointerenter",this.#Q),this.label.addEventListener("pointerenter",this.#Q),this.label.removeEventListener("pointerleave",this.#j),this.label.addEventListener("pointerleave",this.#j)}#Y(){if(this.#q?.disconnect(),this.#q=null,this.input?.localName!=="fig-input-palette"||typeof MutationObserver>"u")return;this.#q=new MutationObserver(()=>this.#K()),this.#q.observe(this.input,{attributes:!0,attributeFilter:["edit"]})}disconnectedCallback(){if(this.#G?.disconnect(),this.#G=null,this.#q?.disconnect(),this.#q=null,this.label)k.hide(this.label);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.label&&this.#$)this.label.removeEventListener("click",this.#$);if(this.label&&this.#Q)this.label.removeEventListener("pointerenter",this.#Q);if(this.label&&this.#j)this.label.removeEventListener("pointerleave",this.#j);if(this.#_&&this.#J)this.#_.removeEventListener("click",this.#J)}#X(_){if(_.preventDefault(),_.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open}#R(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;k.show(this.label,this.label.textContent.trim())}#U(){if(this.label)k.hide(this.label)}#W(){if(!this.input||!this.label)return;let _=this.label.getAttribute("id")||v();this.label.setAttribute("id",_);let Z=this.input.querySelectorAll("input, select, textarea");if(Z.length===1){let $=Z[0],J=$.getAttribute("id")||v();if($.setAttribute("id",J),this.label.setAttribute("for",J),this.input.getAttribute("aria-labelledby")===_)this.input.removeAttribute("aria-labelledby");if(!$.hasAttribute("aria-labelledby"))$.setAttribute("aria-labelledby",_);return}if(this.label.removeAttribute("for"),!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-labelledby",_)}attributeChangedCallback(_,Z,$){switch(_){case"label":if(this.label)this.label.textContent=$,this.#W();break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let _=this.input.querySelectorAll("input, select, textarea");if(_.length===1)_[0].focus();else if(this.input.focus(),_.length===0)this.input.click()}}F("fig-field",L_);class O_ extends HTMLElement{rgba;hex;#Z=100;#_;#J;#$;#Q;#j=!1;#G=!1;#q=null;#N=this.#V.bind(this);#K=this.#f.bind(this);#Y=this.#I.bind(this);#X=this.#h.bind(this);#R=this.#w.bind(this);#U=this.#x.bind(this);#W=this.#E.bind(this);#M=this.#m.bind(this);constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(_){if(_===null||_===void 0||_===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(_))}#B(){let _={};for(let{name:Z,value:$}of this.attributes)if(Z.startsWith("picker-")&&Z!=="picker-anchor"&&Z!=="picker-experimental"){let J=Z.slice(7);if(/^on/i.test(J))continue;_[J]=$}if(!_["dialog-position"])_["dialog-position"]="left";return _}#O(){let _=this.#B();return Object.entries(_).map(([Z,$])=>`${Z}="${$}"`).join(" ")}connectedCallback(){if(this.#L()){this.#T();return}this.#F()}disconnectedCallback(){this.#D()}#L(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-swatch")}#T(){if(this.#P(this.getAttribute("value")),this.#_=this.querySelector("fig-swatch"),this.#J=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#Q=this.querySelector("fig-input-number"),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Q)this.#Q.setAttribute("value",String(this.#Z));if(this.#_)this.#_.setAttribute("background",this.hexOpaque),this.#_.setAttribute("alpha",String(this.rgba.a));this.#v(),this.#k()}#D(){if(this.#_)this.#_.removeEventListener("pointerdown",this.#N,{capture:!0}),this.#_.removeEventListener("click",this.#K,{capture:!0}),this.#_.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#Y),this.#_.removeEventListener("input",this.#X);this.#$?.removeEventListener("input",this.#R),this.#$?.removeEventListener("change",this.#U),this.#Q?.removeEventListener("input",this.#W),this.#Q?.removeEventListener("change",this.#U),this.#J?.removeEventListener("input",this.#M),this.#J?.removeEventListener("change",this.#U)}#k(){if(this.#_){this.#_.disabled=T(this,"disabled");let _=this.#_.querySelector('input[type="color"]');if(this.#$||this.hasAttribute("swatch-disabled"))_?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(_?.setAttribute("disabled",""),_)_.style.pointerEvents="none"}this.#_.addEventListener("pointerdown",this.#N,{capture:!0}),this.#_.addEventListener("click",this.#K,{capture:!0}),_?.addEventListener("keydown",this.#Y),this.#_.addEventListener("input",this.#X)}if(this.#$)this.#$.addEventListener("input",this.#R),this.#$.addEventListener("change",this.#U);if(this.#Q)this.#Q.addEventListener("input",this.#W),this.#Q.addEventListener("change",this.#U);if(this.#J)this.#J.addEventListener("input",this.#M),this.#J.addEventListener("change",this.#U)}#F(){this.#P(this.getAttribute("value"));let _=this.getAttribute("alpha")!=="false",Z=this.#u,$=this.getAttribute("text")!=="false",J=L("fig-swatch",{background:this.hexOpaque,alpha:this.rgba.a,disabled:Z});if($){let Q=L("div",{className:"input-combo"},[J,L("fig-input-text",{type:"text",placeholder:"000000",value:this.hexOpaque.slice(1).toUpperCase(),disabled:Z})]);if(_)Q.appendChild(L("fig-tooltip",{text:"Opacity"},L("fig-input-number",{placeholder:"##",min:"0",max:"100",value:this.#Z,units:"%",disabled:Z})));this.replaceChildren(Q)}else this.replaceChildren(J);if(this.#_=J,this.#J=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#Q=this.querySelector("fig-input-number"),this.#v(),this.#$){let Q=this.rgbAlphaToHex(this.rgba,1);if(this.#$.value=Q.slice(1).toUpperCase(),this.#_)this.#_.background=Q}this.#k()}#A(){if(!this.#J)return;for(let[_,Z]of Object.entries(this.#B()))this.#J.setAttribute(_,Z);if(this.#J.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#J.removeAttribute("alpha");else this.#J.setAttribute("alpha","false");if(T(this,"disabled"))this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");this.#J.anchorElement=this,this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}))}#H(){if(!t())return null;if(this.#J?.isConnected)return this.#A(),this.#J;let _=document.createElement("fig-fill-picker");return _.appendChild(L("span",{hidden:!0})),_.addEventListener("input",this.#M),_.addEventListener("change",this.#U),this.appendChild(_),this.#J=_,this.#A(),_}#z(){if(T(this,"disabled")||T(this,"swatch-disabled"))return!1;let _=this.#H();if(!_)return!1;return requestAnimationFrame(()=>_.open?.()),!0}#S(_){_.preventDefault(),_.stopPropagation(),_.stopImmediatePropagation?.()}#V(_){if(!t())return;if(T(this,"disabled")||T(this,"swatch-disabled"))return;if(this.#G=!0,this.#j=!0,this.#q)clearTimeout(this.#q);this.#q=setTimeout(()=>{this.#j=!1,this.#G=!1,this.#q=null},500),this.#S(_)}#f(_){if(!this.#j)return;if(this.#j=!1,this.#q)clearTimeout(this.#q),this.#q=null;if(this.#S(_),this.#G)this.#G=!1,this.#z()}#I(_){if(_.key!=="Enter"&&_.key!==" ")return;if(!t())return;if(!this.#z())return;this.#S(_)}#P(_){let Z=typeof _==="string"&&_.trim()?_.trim():"#D9D9D9",$=this.convertToRGBA(Z);if(!$||!Number.isFinite($.r)||!Number.isFinite($.g)||!Number.isFinite($.b)||!Number.isFinite($.a))Z="#D9D9D9",$={r:217,g:217,b:217,a:1};this.rgba=$,this.value=this.rgbAlphaToHex({r:isNaN(this.rgba.r)?0:this.rgba.r,g:isNaN(this.rgba.g)?0:this.rgba.g,b:isNaN(this.rgba.b)?0:this.rgba.b},this.rgba.a),this.hexWithAlpha=this.value.toUpperCase(),this.hexOpaque=this.hexWithAlpha.slice(0,7),this.#Z=Z.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#w(_){_.stopPropagation();let Z=_.target.value.replace(/#/g,"");if(this.#P("#"+Z),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Q)this.#Q.setAttribute("value",this.#Z);if(this.#_)this.#_.setAttribute("background",this.hexOpaque);this.#y()}#E(_){_.stopPropagation();let Z=Number(_.target.value)||0,J=Math.round(Z/100*255).toString(16).padStart(2,"0");if(this.#P(this.hexOpaque+J),this.#_)this.#_.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));this.#y()}#x(_){_.stopPropagation(),this.#b()}focus(){if(this.#$){this.#$.focus();return}this.#_?.focus()}#C(){return this.getAttribute("aria-label")||"Color"}#v(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#u)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let _=this.getAttribute("aria-describedby"),Z=this.getAttribute("aria-invalid"),$=this.getAttribute("aria-required"),J=this.getAttribute("aria-labelledby"),Q=this.#C();if(this.#$){if(this.#$.setAttribute("aria-label",`${Q} hex color`),_)this.#$.setAttribute("aria-describedby",_);else this.#$.removeAttribute("aria-describedby");if(Z)this.#$.setAttribute("aria-invalid",Z);else this.#$.removeAttribute("aria-invalid");if($)this.#$.setAttribute("aria-required",$);else this.#$.removeAttribute("aria-required")}if(this.#Q){if(this.#Q.setAttribute("aria-label",`${Q} opacity`),_)this.#Q.setAttribute("aria-describedby",_);else this.#Q.removeAttribute("aria-describedby");if(Z)this.#Q.setAttribute("aria-invalid",Z);else this.#Q.removeAttribute("aria-invalid");if($)this.#Q.setAttribute("aria-required",$);else this.#Q.removeAttribute("aria-required")}if(!this.#$){let j=this.#_?.querySelector('input[type="color"]');if(!j)return;if(J)j.setAttribute("aria-labelledby",J),j.removeAttribute("aria-label");else j.setAttribute("aria-label",Q),j.removeAttribute("aria-labelledby");if(_)j.setAttribute("aria-describedby",_);else j.removeAttribute("aria-describedby")}}#h(_){if(_.stopPropagation(),this.#P(_.target.value),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#y()}#m(_){_.stopPropagation();let Z=_.detail;if(Z&&Z.color){let $=Z.color;if(Z.alpha!==void 0){let J=Math.round(Z.alpha*255).toString(16).padStart(2,"0");$=Z.color+J}if(this.#P($),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Q&&Z.alpha!==void 0)this.#Q.setAttribute("value",Math.round(Z.alpha*100));if(this.#_)this.#_.setAttribute("background",this.hexOpaque),this.#_.setAttribute("alpha",this.rgba.a);this.#y()}}#y(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:this.#g()}))}#b(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:this.#g()}))}#g(){return{value:this.value,hex:this.hex,rgba:this.rgba,...a(this.hexOpaque,this.rgba?.a,Math.round((this.rgba?.a??1)*100))}}static get observedAttributes(){return["value","style","mode","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(_){this.setAttribute("mode",_)}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"value":if(this.#P($),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#_)this.#_.setAttribute("background",this.hexOpaque),this.#_.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));if(this.#Q)this.#Q.setAttribute("value",this.#Z);break;case"mode":this.#A();break;case"alpha":case"text":if(this.isConnected)this.#F();break;case"disabled":this.#l();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#v();break}}get#u(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#l(){let _=this.#u;for(let Z of[this.#_,this.#$,this.#Q]){if(!Z)continue;if(_)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}if(this.#v(),this.#J)this.#A()}rgbAlphaToHex({r:_,g:Z,b:$},J=1){_=Math.max(0,Math.min(255,Math.round(_))),Z=Math.max(0,Math.min(255,Math.round(Z))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(1,J));let Q=_.toString(16).padStart(2,"0"),j=Z.toString(16).padStart(2,"0"),q=$.toString(16).padStart(2,"0");if(J===1)return`#${Q}${j}${q}`.toUpperCase();let G=Math.round(J*255).toString(16).padStart(2,"0");return`#${Q}${j}${q}${G}`.toUpperCase()}convertToRGBA(_){if(typeof _!=="string")return null;let Z,$,J,Q=1;if(_.startsWith("#")){let j=_.slice(1);if(j.length===8)Q=parseInt(j.slice(6),16)/255,j=j.slice(0,6);Z=parseInt(j.slice(0,2),16),$=parseInt(j.slice(2,4),16),J=parseInt(j.slice(4,6),16)}else if(_.startsWith("rgba")||_.startsWith("rgb")){let j=_.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(j)Z=parseInt(j[1]),$=parseInt(j[2]),J=parseInt(j[3]),Q=j[4]?parseFloat(j[4]):1}else if(_.startsWith("hsla")||_.startsWith("hsl")){let j=_.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(j){let q=parseInt(j[1])/360,N=parseInt(j[2])/100,G=parseInt(j[3])/100;if(Q=j[4]?parseFloat(j[4]):1,N===0)Z=$=J=G;else{let K=(U,R,O)=>{if(O<0)O+=1;if(O>1)O-=1;if(O<0.16666666666666666)return U+(R-U)*6*O;if(O<0.5)return R;if(O<0.6666666666666666)return U+(R-U)*(0.6666666666666666-O)*6;return U},X=G<0.5?G*(1+N):G+N-G*N,Y=2*G-X;Z=K(Y,X,q+0.3333333333333333),$=K(Y,X,q),J=K(Y,X,q-0.3333333333333333)}Z=Math.round(Z*255),$=Math.round($*255),J=Math.round(J*255)}}else return null;return{r:Z,g:$,b:J,a:Q}}}F("fig-input-color",O_);var Y1=["srgb","srgb-linear","display-p3","oklab","oklch","hsl"],R1=["shorter","longer","increasing","decreasing"],M_=new Set(["oklch","hsl"]);function K0(_){let Z={..._??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase();if(!Y1.includes($))$="srgb";Z.interpolationSpace=$;let J=String(Z.hueInterpolation??"shorter").toLowerCase();return Z.hueInterpolation=R1.includes(J)?J:"shorter",Z}function B_(_){let Z=K0(_),$={...Z,interpolationSpace:Z.interpolationSpace};if(M_.has(Z.interpolationSpace))$.hueInterpolation=Z.hueInterpolation;else delete $.hueInterpolation;return $}function H_(_){let Z=K0(_);if(Z.interpolationSpace==="srgb")return"";if(M_.has(Z.interpolationSpace))return`in ${Z.interpolationSpace} ${Z.hueInterpolation} hue`;return`in ${Z.interpolationSpace}`}function A0(_){if(!_)return"";return`url("${String(_).replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}")`}function U1(_){let Z=String(_??"").trim();if(!Z||Z.startsWith("{")||Z.startsWith("#"))return!1;if(Z.startsWith("data:video/"))return!0;try{let $=new URL(Z,"https://fig.local").pathname;return/\.(mp4|webm|mov|m4v|ogv)$/i.test($)}catch{return/\.(mp4|webm|mov|m4v|ogv)(?:[?#]|$)/i.test(Z)}}function $0(_){let Z=_.replace(/^#/,"");return{r:parseInt(Z.substring(0,2),16),g:parseInt(Z.substring(2,4),16),b:parseInt(Z.substring(4,6),16)}}function i(_){let Z=_/255;return Z<=0.04045?Z/12.92:Math.pow((Z+0.055)/1.055,2.4)}function _0(_){let Z=_<=0.0031308?12.92*_:1.055*Math.pow(_,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Z))*255)}function R0(_,Z,$){let J=i(_),Q=i(Z),j=i($),q=Math.cbrt(0.4122214708*J+0.5363325363*Q+0.0514459929*j),N=Math.cbrt(0.2119034982*J+0.6806995451*Q+0.1073969566*j),G=Math.cbrt(0.0883024619*J+0.2817188376*Q+0.6299787005*j);return{l:0.2104542553*q+0.793617785*N-0.0040720468*G,a:1.9779984951*q-2.428592205*N+0.4505937099*G,b:0.0259040371*q+0.7827717662*N-0.808675766*G}}function b0(_,Z,$){let J=_+0.3963377774*Z+0.2158037573*$,Q=_-0.1055613458*Z-0.0638541728*$,j=_-0.0894841775*Z-1.291485548*$,q=J*J*J,N=Q*Q*Q,G=j*j*j;return{r:_0(4.0767416621*q-3.3077115913*N+0.2309699292*G),g:_0(-1.2684380046*q+2.6097574011*N-0.3413193965*G),b:_0(-0.0041960863*q-0.7034186147*N+1.707614701*G)}}function g0(_,Z,$){return{l:_,c:Math.sqrt(Z*Z+$*$),h:Math.atan2($,Z)*180/Math.PI}}function W1(_,Z,$){let J=$*Math.PI/180;return{l:_,a:Z*Math.cos(J),b:Z*Math.sin(J)}}function v0(_,Z,$,J){let Q=(_%360+360)%360,q=(Z%360+360)%360-Q;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((Q+q*$)%360+360)%360}function L1(_,Z,$,J){let Q=[..._].sort((A,z)=>A.position-z.position),j=Z*100;if(Q.length===0)return"#888888";if(j<=Q[0].position)return Q[0].color;if(j>=Q[Q.length-1].position)return Q[Q.length-1].color;let q=0;while(q<Q.length-1&&Q[q+1].position<j)q++;let N=Q[q],G=Q[q+1],K=G.position-N.position,X=K>0?(j-N.position)/K:0,Y=$0(N.color),U=$0(G.color),R,O,M,H=$||"oklab";if(H==="srgb-linear"){let A=i(Y.r),z=i(Y.g),W=i(Y.b),I=i(U.r),V=i(U.g),C=i(U.b);R=_0(A+(I-A)*X),O=_0(z+(V-z)*X),M=_0(W+(C-W)*X)}else if(H==="oklch"){let A=R0(Y.r,Y.g,Y.b),z=R0(U.r,U.g,U.b),W=g0(A.l,A.a,A.b),I=g0(z.l,z.a,z.b),V=W.l+(I.l-W.l)*X,C=W.c+(I.c-W.c)*X,S=v0(W.h,I.h,X,J||"shorter"),w=W1(V,C,S),f=b0(w.l,w.a,w.b);R=f.r,O=f.g,M=f.b}else if(H==="hsl"){let A=m0(Y.r,Y.g,Y.b),z=m0(U.r,U.g,U.b),W=v0(A.h,z.h,X,J||"shorter"),I=A.s+(z.s-A.s)*X,V=A.l+(z.l-A.l)*X,C=O1(W,I,V);R=C[0],O=C[1],M=C[2]}else if(H==="srgb")R=Math.round(Y.r+(U.r-Y.r)*X),O=Math.round(Y.g+(U.g-Y.g)*X),M=Math.round(Y.b+(U.b-Y.b)*X);else{let A=R0(Y.r,Y.g,Y.b),z=R0(U.r,U.g,U.b),W=A.l+(z.l-A.l)*X,I=A.a+(z.a-A.a)*X,V=A.b+(z.b-A.b)*X,C=b0(W,I,V);R=C.r,O=C.g,M=C.b}return`#${R.toString(16).padStart(2,"0")}${O.toString(16).padStart(2,"0")}${M.toString(16).padStart(2,"0")}`.toUpperCase()}function m0(_,Z,$){let J=_/255,Q=Z/255,j=$/255,q=Math.max(J,Q,j),N=Math.min(J,Q,j),G=(q+N)/2;if(q===N)return{h:0,s:0,l:G*100};let K=q-N,X=G>0.5?K/(2-q-N):K/(q+N),Y;switch(q){case J:Y=((Q-j)/K+(Q<j?6:0))/6;break;case Q:Y=((j-J)/K+2)/6;break;default:Y=((J-Q)/K+4)/6;break}return{h:Y*360,s:X*100,l:G*100}}function O1(_,Z,$){Z/=100,$/=100;let J=(1-Math.abs(2*$-1))*Z,Q=J*(1-Math.abs(_/60%2-1)),j=$-J/2,q,N,G;if(_<60)q=J,N=Q,G=0;else if(_<120)q=Q,N=J,G=0;else if(_<180)q=0,N=J,G=Q;else if(_<240)q=0,N=Q,G=J;else if(_<300)q=Q,N=0,G=J;else q=J,N=0,G=Q;return[Math.round((q+j)*255),Math.round((N+j)*255),Math.round((G+j)*255)]}class F_ extends HTMLElement{#Z="solid";#_;#J;#$;#Q={color:"#D9D9D9",alpha:1};#j={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",opacity:1,stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#G={url:null,scaleMode:"fill",scale:50,opacity:1};#q={url:null,poster:null,scaleMode:"fill",scale:50,opacity:1,missing:!0};#N={live:!0,snapshot:null,deviceId:null,scaleMode:"fill",scale:50,opacity:1};#K={};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","alpha","webcam-mode","default-video","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#Y(),this.#H()}disconnectedCallback(){this.#_=null,this.#J=null,this.#$=null}#Y(){let _=this.getAttribute("value");if(!_)return;try{let Z=JSON.parse(_);if(Z.type)this.#Z=Z.type;switch(this.#Z){case"solid":if(Z.color)this.#Q.color=Z.color;if(Z.alpha!==void 0)this.#Q.alpha=Z.alpha;if(Z.opacity!==void 0)this.#Q.alpha=Z.opacity/100;break;case"gradient":if(Z.gradient)this.#j=K0({...this.#j,...Z.gradient}),this.#j.opacity=this.#W(Z.gradient.opacity??Z.opacity??Z.alpha,this.#j.opacity??1);else if(Z.opacity!==void 0||Z.alpha!==void 0)this.#j.opacity=this.#W(Z.opacity??Z.alpha,this.#j.opacity??1);break;case"image":if(Z.image)this.#G={...this.#G,...Z.image};break;case"video":if(Z.video)this.#q={...this.#q,...Z.video},this.#q.missing=!this.#q.url;break;case"webcam":if(Z.webcam&&typeof Z.webcam==="object"){let{stream:$,snapshot:J,...Q}=Z.webcam;if(this.#N={...this.#N,...Q},typeof J==="string"&&J)this.#N.snapshot=J}else if(Z.image?.url){if(this.#N.snapshot=Z.image.url,Z.image.scaleMode)this.#N.scaleMode=Z.image.scaleMode;if(Z.image.scale!=null)this.#N.scale=Z.image.scale}if(Z.opacity!==void 0)this.#N.opacity=Z.opacity;break;default:{let{type:$,...J}=Z;this.#K=J;break}}}catch(Z){if(_.startsWith("#")){if(this.#Z="solid",this.#Q.color=_.slice(0,7),_.length>7){let $=_.slice(7,9);this.#Q.alpha=parseInt($,16)/255}return}if(U1(_))this.#Z="video",this.#q.url=_.trim(),this.#q.missing=!1}}#X(){let _={},Z=this.getAttribute("mode");if(Z)_.mode=Z;let $=this.getAttribute("alpha");if($)_.alpha=$;for(let{name:j,value:q}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor"&&j!=="picker-experimental"){let N=j.slice(7);if(/^on/i.test(N))continue;_[N]=q}if(!_["dialog-position"])_["dialog-position"]="left";let J=this.getAttribute("webcam-mode");if(J&&!_["webcam-mode"])_["webcam-mode"]=J;let Q=this.getAttribute("default-video");if(Q&&!_["default-video"])_["default-video"]=Q;return _}#R(){switch(this.#Z){case"solid":return this.#Q.color;case"gradient":{let Z=[...this.#j.stops].sort((Q,j)=>Q.position-j.position).map((Q)=>{let j=(Q.opacity??100)/100;if(j>=1)return`${Q.color} ${Q.position}%`;let{r:q,g:N,b:G}=$0(Q.color);return`rgba(${q}, ${N}, ${G}, ${j}) ${Q.position}%`}).join(", "),$=H_(this.#j),J=$?` ${$}`:"";switch(this.#j.type){case"radial":return`radial-gradient(circle${J}, ${Z})`;case"angular":return`conic-gradient(from ${this.#j.angle}deg${J}, ${Z})`;default:return`linear-gradient(${this.#j.angle}deg${J}, ${Z})`}}case"image":return this.#G.url?A0(this.#G.url):"#D9D9D9";case"video":return this.#q.poster?A0(this.#q.poster):"#D9D9D9";case"webcam":{let _=this.#N.snapshot||this.#_?.value?.webcam?.snapshot;return _?A0(_):""}default:return this.#L()}}#U(){return this.#R()}#W(_,Z=1){if(_===void 0||_===null||_==="")return Z;let $=Number(_);if(!Number.isFinite($))return Z;if($>1)return Math.max(0,Math.min(1,$/100));return Math.max(0,Math.min(1,$))}#M(){switch(this.#Z){case"solid":return this.#Q.alpha;case"gradient":return this.#j.opacity??1;case"image":return this.#G.opacity??1;case"video":return this.#q.opacity??1;case"webcam":return this.#N.opacity??1;default:return this.#W(this.#K.opacity??this.#K.alpha,1)}}#B(){return this.querySelector(`[slot="mode-${this.#Z}"]`)}#O(){let _=this.#B()?.getAttribute("label");if(_)return _;if(!this.#Z)return"Fill";return this.#Z.charAt(0).toUpperCase()+this.#Z.slice(1)}#L(){return this.#K.swatchBackground||this.#K.background||this.#K.css||this.#B()?.getAttribute("swatch-background")||""}#T(){if(!this.#_)return;for(let _ of[...this.querySelectorAll(":scope > [slot^='mode-']")])this.#_.append(_)}#D(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.setAttribute("aria-disabled",_?"true":"false");for(let Z of[this.#_,this.#J,this.#$]){if(!Z)continue;if(_)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}#k(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#D();let _=this.getAttribute("aria-label")||"Fill",Z=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),Q=(j,q)=>{if(!j)return;if(j.setAttribute("aria-label",q),Z)j.setAttribute("aria-describedby",Z);else j.removeAttribute("aria-describedby");if($)j.setAttribute("aria-invalid",$);else j.removeAttribute("aria-invalid");if(J)j.setAttribute("aria-required",J);else j.removeAttribute("aria-required")};Q(this.#_,`${_} picker`),Q(this.#$,`${_} hex color`),Q(this.#J,`${_} opacity`)}#F(_,Z){if(this.getAttribute("alpha")==="false")return null;return L("fig-tooltip",{text:"Opacity"},L("fig-input-number",{className:"fig-input-fill-opacity",placeholder:"##",min:"0",max:"100",value:_,units:"%",disabled:Z}))}#A(_){let Z=null,$=1;switch(this.#Z){case"solid":return[L("fig-input-text",{type:"text",className:"fig-input-fill-hex",placeholder:"000000",value:this.#Q.color.slice(1).toUpperCase(),disabled:_}),this.#F(Math.round(this.#Q.alpha*100),_)].filter(Boolean);case"gradient":Z=this.#j.type.charAt(0).toUpperCase()+this.#j.type.slice(1),$=this.#j.opacity??1;break;case"image":Z="Image",$=this.#G.opacity??1;break;case"video":Z="Video",$=this.#q.opacity??1;break;case"webcam":Z="Webcam",$=this.#N.opacity??1;break;default:Z=this.#O(),$=this.#W(this.#K.opacity??this.#K.alpha,1);break}return[L("label",{className:"fig-input-fill-label"},Z),this.#F(Math.round($*100),_)].filter(Boolean)}#H(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=JSON.stringify(this.value),$=this.#X(),J=L("fig-swatch",{background:this.#R(),alpha:this.#M(),disabled:_}),Q=[...this.querySelectorAll("[slot^='mode-']")],j=L("fig-fill-picker",{value:Z,disabled:_,...$},[J,...Q]),q=L("div",{className:"input-combo"},[j,this.#A(_)]);this.replaceChildren(q),this.#z(),queueMicrotask(()=>{this.#T(),this.#I(),this.#S()})}#z(){this.#_=this.querySelector("fig-fill-picker"),this.#J=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let _=this.querySelector(".fig-input-fill-label");if(this.#k(),_&&this.#_)_.addEventListener("click",()=>{let Z=this.#_.querySelector("fig-swatch");if(Z)Z.click()});if(this.#_){let Z=this.getAttribute("picker-anchor");if(!Z||Z==="self")this.#_.anchorElement=this;else{let $=null;try{$=document.querySelector(Z)}catch{}if($)this.#_.anchorElement=$}this.#_.addEventListener("input",($)=>{$.stopPropagation();let J=$.detail;if(!J)return;let Q=J.type,j=Q!==this.#Z;switch(this.#Z=Q,Q){case"solid":this.#Q.color=J.color,this.#Q.alpha=J.alpha;break;case"gradient":if(J.gradient)this.#j=K0({...this.#j,...J.gradient});break;case"image":if(J.image)this.#G=J.image;break;case"video":if(J.video)this.#q={...this.#q,...J.video};break;case"webcam":if(J.webcam){let{stream:q,snapshot:N,...G}=J.webcam;if(this.#N={...this.#N,...G},typeof N==="string"&&N)this.#N.snapshot=N}else if(J.image?.url)this.#N.snapshot=J.image.url;if(!this.#N.snapshot){let q=this.#_?.value?.webcam?.snapshot;if(q)this.#N.snapshot=q}break;default:{let{type:q,colorSpace:N,...G}=J;this.#K=G;break}}if(j)this.#V();else this.#S();this.#I(),this.#w()}),this.#_.addEventListener("change",($)=>{$.stopPropagation(),this.#E()}),this.#_.addEventListener("loaded",($)=>{$.stopPropagation(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,detail:$.detail}))}),this.#_.addEventListener("webcamstream",($)=>{this.dispatchEvent(new CustomEvent("webcamstream",{bubbles:!0,composed:!0,detail:$.detail}))})}if(this.#$)this.#$.addEventListener("input",(Z)=>{Z.stopPropagation();let $="#"+Z.target.value.replace("#","");this.#Q.color=$,this.#f(),this.#w()}),this.#$.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#E()});if(this.#J)this.#J.addEventListener("input",(Z)=>{Z.stopPropagation();let $=parseFloat(Z.target.value),Q=(isNaN($)?100:$)/100;switch(this.#Z){case"solid":this.#Q.alpha=Q;break;case"gradient":this.#j.opacity=Q;break;case"image":this.#G.opacity=Q;break;case"video":this.#q.opacity=Q;break;case"webcam":this.#N.opacity=Q;break;default:this.#K.opacity=Q;break}this.#f(),this.#I(),this.#w()}),this.#J.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#E()})}#S(){switch(this.#Z){case"solid":if(this.#$)this.#$.setAttribute("value",this.#Q.color.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",Math.round(this.#Q.alpha*100));break;case"gradient":{let _=this.querySelector(".fig-input-fill-label");if(_){let Z=this.#j.type.charAt(0).toUpperCase()+this.#j.type.slice(1);_.textContent=Z}if(this.#J)this.#J.setAttribute("value",Math.round((this.#j.opacity??1)*100));break}case"image":if(this.#J)this.#J.setAttribute("value",Math.round((this.#G.opacity??1)*100));break;case"video":if(this.#J)this.#J.setAttribute("value",Math.round((this.#q.opacity??1)*100));break;case"webcam":if(this.#J)this.#J.setAttribute("value",Math.round((this.#N.opacity??1)*100));break;default:{let _=this.querySelector(".fig-input-fill-label");if(_)_.textContent=this.#O();if(this.#J)this.#J.setAttribute("value",Math.round(this.#W(this.#K.opacity??this.#K.alpha,1)*100));break}}}#V(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.querySelector(".input-combo");if(!Z)return;let $=Z.querySelector(".fig-input-fill-label"),J=Z.querySelector(".fig-input-fill-hex"),Q=Z.querySelector(".fig-input-fill-opacity"),j=Z.querySelectorAll("fig-tooltip");$?.remove(),J?.remove(),j.forEach((N)=>N.remove()),Z.append(...this.#A(_)),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.#k(),q&&this.#_)q.addEventListener("click",()=>{let N=this.#_.querySelector("fig-swatch");if(N)N.click()});if(this.#$)this.#$.addEventListener("input",(N)=>{N.stopPropagation();let G="#"+N.target.value.replace("#","");this.#Q.color=G,this.#f(),this.#w()}),this.#$.addEventListener("change",(N)=>{N.stopPropagation(),this.#E()});if(this.#J)this.#J.addEventListener("input",(N)=>{N.stopPropagation();let G=parseFloat(N.target.value),X=(isNaN(G)?100:G)/100;switch(this.#Z){case"solid":this.#Q.alpha=X;break;case"gradient":this.#j.opacity=X;break;case"image":this.#G.opacity=X;break;case"video":this.#q.opacity=X;break;case"webcam":this.#N.opacity=X;break;default:this.#K.opacity=X;break}this.#f(),this.#P(X),this.#w()}),this.#J.addEventListener("change",(N)=>{N.stopPropagation(),this.#E()})}#f(){if(this.#_)this.#_.setAttribute("value",JSON.stringify(this.value));this.#I()}#I(){let _=this.#_?.querySelector("fig-swatch");if(!_)return;let Z=this.#R();if(this.#Z==="webcam"&&!Z){if((_.getAttribute("background")||"").startsWith("url(")){_.setAttribute("alpha",this.#M());return}}_.setAttribute("background",Z),_.setAttribute("alpha",this.#M())}#P(_){let Z=this.#_?.querySelector("fig-swatch");if(Z)Z.setAttribute("alpha",_)}#w(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#E(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get webcamStream(){return this.#_?.webcamStream??null}releaseWebcam(){this.#_?.releaseWebcam?.()}#x(){let _=this.#q.url??null;return{url:_,poster:this.#q.poster??null,scaleMode:this.#q.scaleMode||"fill",scale:this.#q.scale??50,opacity:this.#q.opacity??1,..._?{}:{missing:!0}}}#C(){return{live:this.#N.live!==!1,snapshot:this.#N.snapshot??this.#_?.value?.webcam?.snapshot??null,deviceId:this.#N.deviceId??null,scaleMode:this.#N.scaleMode||"fill",scale:this.#N.scale??50,opacity:this.#N.opacity??1}}get value(){switch(this.#Z){case"solid":return{type:"solid",colorSpace:"srgb",color:this.#Q.color,alpha:this.#Q.alpha,opacity:Math.round(this.#Q.alpha*100)};case"gradient":return{type:"gradient",colorSpace:"srgb",gradient:B_(this.#j),css:this.#U()};case"image":return{type:"image",colorSpace:"srgb",image:{...this.#G}};case"video":return{type:"video",colorSpace:"srgb",video:this.#x()};case"webcam":return{type:"webcam",colorSpace:"srgb",webcam:this.#C()};default:return{type:this.#Z,...this.#K}}}set value(_){if(typeof _==="string")this.setAttribute("value",_);else this.setAttribute("value",JSON.stringify(_))}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"value":let J=this.#Z;if(this.#Y(),this.#_)if(this.#Z!==J)this.#H();else this.#f(),this.#S();break;case"disabled":this.#D();break;case"mode":case"webcam-mode":case"default-video":if(this.#_)if($)this.#_.setAttribute(_,$);else this.#_.removeAttribute(_);break;case"alpha":if(this.isConnected)this.#H();break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#k();break}}}F("fig-input-fill",F_);class A_ extends HTMLElement{#Z=[];#_=[];#J=[];#$=null;#Q=null;#j=null;#G=null;#q=!1;#N=this.#M.bind(this);#K=()=>this.focus();#Y=()=>{if(!this.#j)return;if(this.#j.hasAttribute("open")||this.#j.matches?.(":open")||this.#j.matches?.(":popover-open"))return;if(this.open)this.open=!1};static get observedAttributes(){return["value","disabled","min","max","open","fixed","edit"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){let Z=this.open;if(_&&this.#R!=="false")this.setAttribute("open","");else this.removeAttribute("open");let $=this.open;if(Z!==$)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:$},bubbles:!0}))}get#X(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#R(){let _=this.getAttribute("edit");if(_==="false")return"false";if(_==="picker")return"picker";return"true"}get#U(){let _=parseInt(this.getAttribute("min"));return isNaN(_)?2:_}get#W(){let _=parseInt(this.getAttribute("max"));return isNaN(_)?8:_}connectedCallback(){if(this.setAttribute("tabindex","-1"),this.removeEventListener("focus",this.#K),this.addEventListener("focus",this.#K),this.removeEventListener("keydown",this.#N),this.addEventListener("keydown",this.#N),this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{if(this.#$=null,!this.isConnected)return;this.#B(),this.#O(),this.#L()})}disconnectedCallback(){if(this.#$)cancelAnimationFrame(this.#$),this.#$=null;this.removeEventListener("keydown",this.#N),this.removeEventListener("focus",this.#K),this.#_=[],this.#J=[],this.#F()}#M(_){if(_.key!=="Enter"&&_.key!==" ")return;if(_.target!==this.querySelector(".palette-colors-inline"))return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#R==="false")return;_.preventDefault(),_.stopPropagation(),this.open=!0}attributeChangedCallback(_,Z,$){if(Z===$||this.#q)return;switch(_){case"value":this.#B(),this.#I(),this.#D();break;case"disabled":this.#P();break;case"min":case"max":case"fixed":this.#O(),this.#D();break;case"open":this.#w(),this.#k();break;case"edit":if(this.#R==="false"&&this.open)this.open=!1;if(this.#R!=="picker")this.#F();this.#O(),this.#L();break}}#B(){let _=this.getAttribute("value");if(!_){this.#Z=[];return}let Z=_.trim();try{let $=JSON.parse(Z);if(Array.isArray($)){this.#Z=$.map((J)=>{if(typeof J==="string")return{color:J.slice(0,7),alpha:J.length>7?parseInt(J.slice(7,9),16)/255:1};if(J&&typeof J==="object")return{color:J.color||"#D9D9D9",alpha:J.alpha!==void 0?J.alpha:J.opacity!==void 0?J.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch($){}if(Z.includes(",")){this.#Z=Z.split(",").map(($)=>{let J=$.trim();return{color:J.slice(0,7),alpha:J.length>7?parseInt(J.slice(7,9),16)/255:1}});return}if(Z.startsWith("#")){this.#Z=[{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}];return}this.#Z=[]}get value(){return this.#Z.map((_)=>({..._}))}set value(_){if(typeof _==="string")this.setAttribute("value",_);else this.setAttribute("value",JSON.stringify(_))}#O(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.#R,$=Z!=="false";this.replaceChildren(),this.#_=[],this.#J=[];let J=document.createElement("div");if(J.className="palette-colors-inline",$){if(J.setAttribute("role","button"),J.setAttribute("tabindex",_?"-1":"+0"),J.setAttribute("aria-expanded",String(this.open)),J.setAttribute("aria-label","Edit palette colors"),Z==="picker")J.setAttribute("aria-haspopup","dialog")}else J.setAttribute("role","img"),J.setAttribute("aria-label","Palette colors");J.addEventListener("blur",()=>{J.style.removeProperty("outline"),J.style.removeProperty("outline-offset")});let Q=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0};if($)J.addEventListener("click",Q);let j=document.createElement("div");if(j.className="palette-colors",this.#Z.forEach((q,N)=>{j.appendChild(this.#A(q,N,_,{inline:!0}))}),J.appendChild(j),this.appendChild(J),this.#w(),Z==="true"){if(!this.#X)this.#S(_,this);let q=document.createElement("div");q.className="palette-colors-expanded",this.#Z.forEach((N,G)=>{if(q.appendChild(this.#A(N,G,_)),!this.#X)q.appendChild(this.#H(G,_))}),this.appendChild(q)}}#L(){if(this.#R!=="picker"||customElements.get("fig-palette-editor")){this.#k();return}this.#Q??=customElements.whenDefined("fig-palette-editor").then(()=>{if(!this.isConnected||this.#R!=="picker")return;this.#k()})}#T(){if(this.#j?.isConnected)return this.#j;if(!customElements.get("fig-palette-editor"))return null;let _=document.createElement("dialog",{is:"fig-popup"});_.setAttribute("is","fig-popup"),_.setAttribute("title","Edit palette"),_.setAttribute("position","center left"),_.setAttribute("offset","8 0"),_.setAttribute("viewport-margin","8"),_.setAttribute("popover","manual"),_.className="fig-palette-editor-popup",_.id=v(),_.anchor=this;let Z=document.createElement("fig-palette-editor"),$=L("fig-content",{className:"fig-palette-editor-content"},Z);_.append($);let J=(Q)=>{if(Q.stopPropagation(),!Array.isArray(Q.detail))return;this.#Z=Q.detail.map((j)=>({color:j?.color||"#D9D9D9",alpha:Number.isFinite(Number(j?.alpha))?Math.max(0,Math.min(1,Number(j.alpha))):1})),this.#q=!0,this.setAttribute("value",JSON.stringify(this.#Z)),this.#q=!1,this.#I(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,detail:this.value}))};return Z.addEventListener("input",J),Z.addEventListener("change",J),_.addEventListener("close",this.#Y),_.addEventListener("toggle",this.#Y),(N0()??document.body).append(_),_.querySelector(":scope > fig-header")?.setAttribute("borderless",""),this.#j=_,this.#G=Z,this.querySelector(".palette-colors-inline")?.setAttribute("aria-controls",_.id),this.#D(),_}#D(){let _=this.#G;if(!_)return;_.setAttribute("value",JSON.stringify(this.#Z)),_.setAttribute("min",String(this.#U)),_.setAttribute("max",String(this.#W)),_.toggleAttribute("fixed",this.#X);let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";_.toggleAttribute("disabled",Z)}#k(){if(!this.isConnected||this.#R!=="picker")return;if(!customElements.get("fig-palette-editor")){this.#L();return}if(!this.open){if(this.#j)this.#j.open=!1;return}if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.open=!1;return}let Z=this.#T();if(!Z)return;this.#D(),Z.open=!0}#F(){if(!this.#j)return;this.#j.removeEventListener("close",this.#Y),this.#j.removeEventListener("toggle",this.#Y),this.#j.open=!1,this.#j.remove(),this.querySelector(".palette-colors-inline")?.removeAttribute("aria-controls"),this.#j=null,this.#G=null}#A(_,Z,$,{inline:J=!1}={}){let Q=_.alpha<1?_.color+Math.round(_.alpha*255).toString(16).padStart(2,"0"):_.color,j=document.createElement("fig-input-color");if(j.setAttribute("value",Q),J)j.setAttribute("text","false"),j.setAttribute("alpha","true"),j.setAttribute("swatch-disabled","");else j.setAttribute("text","true"),j.setAttribute("alpha","true"),j.setAttribute("full","");if($)j.setAttribute("disabled","");let q=J?this.#J:this.#_,N=(G)=>{G.stopPropagation();let K=G.currentTarget;this.#Z[Z]={color:K.hexOpaque||this.#Z[Z].color,alpha:K.rgba?K.rgba.a:this.#Z[Z].alpha};let X=q[Z];if(X){let Y=this.#Z[Z],U=Y.alpha<1?Y.color+Math.round(Y.alpha*255).toString(16).padStart(2,"0"):Y.color;X.setAttribute("value",U)}};if(j.addEventListener("input",(G)=>{N(G),this.#x()}),j.addEventListener("change",(G)=>{N(G),this.#C()}),J)this.#_.push(j);else this.#J.push(j);return j}#H(_,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.#U)$.setAttribute("disabled","");$.appendChild(b("minus")),$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#z(_)});let J=document.createElement("fig-tooltip");return J.setAttribute("text","Remove color"),J.appendChild($),J}#z(_){if(this.#X)return;if(_<0||_>=this.#Z.length)return;if(this.#Z.length<=this.#U)return;this.#Z.splice(_,1),this.#_=[],this.#J=[],this.#O(),this.#C()}#S(_,Z=this){let $=this.#Z.length>=this.#W,J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Add color"),J.className="palette-add-btn",_||$)J.setAttribute("disabled","");J.appendChild(b("add")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Z.length>=this.#W)return;this.open=!0,this.#V({color:"#D9D9D9",alpha:1})});let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Add color"),Q.appendChild(J),Z.appendChild(Q)}#V(_){if(this.#X)return;this.#Z.push(_);let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#Z.length-1,J=this.#A(_,$,Z,{inline:!0}),Q=this.querySelector(".palette-colors");if(Q)Q.appendChild(J);let j=this.#A(_,$,Z),q=this.querySelector(".palette-colors-expanded");if(q)q.appendChild(j),q.appendChild(this.#H($,Z));if(this.#Z.length>=this.#W){let N=this.querySelector(".palette-add-btn");if(N)N.setAttribute("disabled","")}this.#E(Z),this.#C()}#f(_){let Z=this.#Z[_];if(!Z)return;let $=Z.alpha<1?Z.color+Math.round(Z.alpha*255).toString(16).padStart(2,"0"):Z.color,J=this.#_[_];if(J)J.setAttribute("value",$);let Q=this.#J[_];if(Q)Q.setAttribute("value",$)}#I(){if(this.#_.length!==this.#Z.length){this.#O();return}this.#Z.forEach((_,Z)=>{this.#f(Z)})}#P(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#_,...this.#J].forEach(($)=>{if(_)$.setAttribute("disabled","");else $.removeAttribute("disabled")});let Z=this.querySelector(".palette-add-btn");if(Z)if(_||this.#Z.length>=this.#W)Z.setAttribute("disabled","");else Z.removeAttribute("disabled");if(this.#E(_),this.#w(),this.#D(),_&&this.#R==="picker"&&this.open)this.open=!1}#w(){let _=this.querySelector(".palette-colors-inline");if(!_)return;let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#R==="false"){_.removeAttribute("tabindex"),_.removeAttribute("aria-disabled"),_.removeAttribute("aria-expanded"),_.removeAttribute("aria-haspopup");return}if(_.setAttribute("tabindex",Z?"-1":"+0"),_.setAttribute("aria-disabled",String(Z)),_.setAttribute("aria-expanded",String(this.open)),this.#R==="picker")_.setAttribute("aria-haspopup","dialog");else _.removeAttribute("aria-haspopup")}focus(){if(this.#R==="false"||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let _=this.querySelector(".palette-colors-inline");if(!_)return;_.style.outline="var(--figma-focus-outline)",_.style.outlineOffset="var(--figma-focus-outline-offset)",_.focus()}#E(_=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let Z=_||this.#Z.length<=this.#U;this.querySelectorAll(".palette-remove-btn").forEach(($)=>{if(Z)$.setAttribute("disabled","");else $.removeAttribute("disabled")})}#x(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#C(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}F("fig-input-palette",A_);class G0 extends HTMLElement{static SHIFT_SNAP=5;#Z;#_;#J=!1;#$=null;#Q=null;#j=null;#G=null;anchorElement=null;#q={type:"linear",angle:90,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode","size"]}get#N(){let _=this.getAttribute("edit");if(_==="false")return"false";if(_==="picker")return"picker";return"true"}get#K(){return this.#N==="true"}get#Y(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#X(){if(!this.#_)return null;return this.#_.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#R(){if(!this.#_)return null;let _=this.#_.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(_)return _;let Z=document.activeElement;if(!(Z instanceof Element)||!this.#_.contains(Z))return null;return Z.closest("fig-handle:not(.fig-input-gradient-ghost)")}#U(_){if(!_||!this.#_)return;this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(Z!==_)Z.deselect()}),_.select(),_.focus()}#W(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#K?"-1":"0")}#M(_){let Z=K0(_);return{...Z,type:["linear","radial","angular"].includes(Z.type)?Z.type:"linear",angle:Number.isFinite(Number(Z.angle))?Number(Z.angle):90,centerX:Number.isFinite(Number(Z.centerX))?Number(Z.centerX):50,centerY:Number.isFinite(Number(Z.centerY))?Number(Z.centerY):50}}connectedCallback(){if(this.#T(),this.#S(),this.#B(),this.removeEventListener("keydown",this.#L),this.addEventListener("keydown",this.#L),this.#K)document.addEventListener("keydown",this.#O)}#B(){if(this.#N!=="picker"||t())return;this.#G??=customElements.whenDefined("fig-fill-picker").then(()=>{if(!this.isConnected||this.#N!=="picker")return;this.#S()})}disconnectedCallback(){if(document.removeEventListener("keydown",this.#O),this.removeEventListener("keydown",this.#L),this.#Q)this.#Q.disconnect(),this.#Q=null;if(this.#j!==null)cancelAnimationFrame(this.#j),this.#j=null;clearTimeout(this.#$),this.removeEventListener("pointerenter",this.#E),this.removeEventListener("pointermove",this.#C),this.removeEventListener("pointerleave",this.#x),this.removeEventListener("click",this.#m),this.removeEventListener("dblclick",this.#h)}#O=(_)=>{let Z=document.activeElement,$=Z instanceof Node&&this.contains(Z),J=this.#_?.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)"),Q=!Z||Z===document.body||Z===document.documentElement;if(!$&&!(J&&Q))return;let j=Z&&(Z.tagName==="INPUT"||Z.tagName==="TEXTAREA"||Z.isContentEditable);if(!this.#_)return;if(_.key==="Tab"&&!j){let X=this.#R();if(!X)return;_.preventDefault();let Y=[...this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],U=Y.indexOf(X),R=_.shiftKey?(U-1+Y.length)%Y.length:(U+1)%Y.length;X.deselect(),this.#U(Y[R]);return}if((_.key==="ArrowLeft"||_.key==="ArrowRight")&&!j){let X=this.#R();if(!X)return;let Y=parseInt(X.dataset.stopIndex,10);if(isNaN(Y)||!this.#q.stops[Y])return;_.preventDefault();let U=(_.key==="ArrowRight"?1:-1)*(_.shiftKey?G0.SHIFT_SNAP:1),R=this.#q.stops[Y];R.position=Math.max(0,Math.min(100,R.position+U)),X.setAttribute("value",`${R.position}% 50%`);let O=X.closest("fig-tooltip");if(O)O.text=`${Math.round(R.position)}%`,O.setAttribute("show","true"),O.showPopup(),X.hideColorTip(),clearTimeout(this.#$),this.#$=setTimeout(()=>{O.removeAttribute("show"),X.showColorTip()},600);this.#d(),this.#o(),this.#p();return}if(_.key!=="Delete"&&_.key!=="Backspace")return;if(j)return;if(this.#q.stops.length<=2)return;let q=this.#R();if(!q)return;let N=parseInt(q.dataset.stopIndex,10);if(isNaN(N)||!this.#q.stops[N])return;_.preventDefault(),this.#q.stops.splice(N,1),this.#g(),this.#d(),this.#o(),this.#p();let G=Math.min(N,this.#q.stops.length-1),K=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[G];this.#U(K)};#L=(_)=>{if(this.#N!=="picker")return;if(_.key!=="Enter"&&_.key!==" ")return;if(_.altKey||_.ctrlKey||_.metaKey)return;if(T(this,"disabled"))return;let Z=this.querySelector("fig-fill-picker");if(!Z||typeof Z.open!=="function")return;_.preventDefault(),Z.open()};#T(){let _=this.getAttribute("value");if(!_)return;try{let Z=JSON.parse(_);if(Z?.type==="gradient"&&Z.gradient){this.#q=this.#M({...this.#q,...Z.gradient});return}if(Z?.gradient)this.#q=this.#M({...this.#q,...Z.gradient})}catch(Z){}}#D(){let _=this.#M(this.#q),$=[..._.stops].sort((j,q)=>j.position-q.position).map((j)=>{let q=(j.opacity??100)/100;if(q>=1)return`${j.color} ${j.position}%`;let{r:N,g:G,b:K}=$0(j.color);return`rgba(${N}, ${G}, ${K}, ${q}) ${j.position}%`}).join(", "),J=H_(_),Q=J?` ${J}`:"";if(this.#N==="picker")switch(_.type){case"radial":return`radial-gradient(circle at ${_.centerX}% ${_.centerY}%${Q}, ${$})`;case"angular":return`conic-gradient(from ${_.angle}deg${Q}, ${$})`;default:return`linear-gradient(${_.angle}deg${Q}, ${$})`}return`linear-gradient(to right${Q}, ${$})`}#k(_){let Z=(_.opacity??100)/100;if(Z>=1)return _.color;let{r:$,g:J,b:Q}=$0(_.color);return`rgba(${$}, ${J}, ${Q}, ${Z})`}#F(){if(!this.#Z)return;let _=this.getAttribute("size");if(_)this.#Z.setAttribute("size",_);else this.#Z.removeAttribute("size")}#A(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";return this.#q.stops.map((Z,$)=>L("fig-tooltip",{action:"manual",text:`${Math.round(Z.position)}%`},L("fig-handle",{drag:!0,"drag-axes":"x","drag-surface":".fig-input-gradient-track",type:"color",tip:this.#Y==="tip"?"color":null,color:this.#k(Z),value:`${Z.position}% 50%`,"hit-area":"4","data-stop-index":$,disabled:_})))}#H=null;#z=!1;#S(){this.#Q?.disconnect(),this.#Q=null;let _=T(this,"disabled"),Z=this.#N,$=this.getAttribute("size"),J=L("fig-swatch",{background:this.#D(),size:$||null,disabled:_});if(Z==="picker"&&t()){let q=JSON.stringify(this.value),N=L("fig-fill-picker",{mode:"gradient",value:q,disabled:_},J);this.replaceChildren(N),this.#Z=J,this.#_=null,this.#V(),this.#W();return}let Q=Z==="true"||Z==="picker",j=Q?L("div",{className:"fig-input-gradient-track"},this.#A()):null;if(this.replaceChildren(...j?[J,j]:[J]),this.#Z=J,this.#_=j,Q)this.#I(),this.#i();this.#W()}#V(){let _=this.querySelector("fig-fill-picker");if(!_)return;_.anchorElement=this.anchorElement||this;let Z=($)=>{$.stopPropagation();let J=$.detail;if(!J?.gradient)return;if(this.#q=this.#M({...this.#q,...J.gradient}),this.#N==="picker"&&typeof J.css==="string"&&J.css){this.#Z?.setAttribute("background",J.css),this.#F();return}this.#d()};_.addEventListener("input",($)=>{Z($),this.#o()}),_.addEventListener("change",($)=>{Z($),this.#p()})}#f(_){return L1(this.#q.stops,_,this.#q.interpolationSpace,this.#q.hueInterpolation)}#I(){if(!this.#_||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let _=document.createElement("fig-handle");if(_.classList.add("fig-input-gradient-ghost"),_.setAttribute("type","color"),this.#Y==="tip")_.setAttribute("tip","add");_.style.position="absolute",_.style.top="50%",_.style.transform="translate(-50%, -50%)",_.style.pointerEvents="none",_.style.opacity="0",_.style.transition="opacity 0.15s",this.#_.appendChild(_),this.#H=_,this.addEventListener("pointerenter",this.#E),this.addEventListener("pointermove",this.#C),this.addEventListener("pointerleave",this.#x),this.addEventListener("click",this.#m),this.addEventListener("dblclick",this.#h)}#P(){if(!this.#H)return;this.#H.style.opacity="1"}#w(){if(!this.#H)return;this.#H.style.opacity="0"}#E=()=>{if(this.#J)return;this.#P()};#x=()=>{this.#w()};#C=(_)=>{if(this.#J){this.#w();return}if(!this.#H||!this.#_)return;if(_.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#w();return}let Z=this.#_.getBoundingClientRect(),$=Math.max(0,Math.min(1,(_.clientX-Z.left)/Z.width));this.#H.style.left=`${$*100}%`;let J=this.#f($);this.#H.setAttribute("color",J),this.#P()};#v(){let _=this.#q.stops.length;if(_<2)return;for(let Z=0;Z<_;Z++)this.#q.stops[Z].position=Math.round(Z/(_-1)*100);this.#g(),this.#d(),this.#o(),this.#p()}#h=(_)=>{if(!this.#_)return;if(!_.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#v(),this.#_.querySelectorAll("fig-handle[selected]").forEach((Z)=>{Z.removeAttribute("selected")})};#m=(_)=>{if(!this.#_)return;if(this.#J)return;if(this.#z){this.#z=!1;return}if(_.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(_.shiftKey){let q=_.target.closest("fig-handle"),N=parseInt(q?.dataset.stopIndex,10);if(this.#v(),!isNaN(N))this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((G)=>{if(parseInt(G.dataset.stopIndex,10)===N)G.select();else G.deselect()});_.stopPropagation()}return}let Z=this.#_.getBoundingClientRect(),$=Math.max(0,Math.min(1,(_.clientX-Z.left)/Z.width)),J=Math.round($*100),Q=this.#f($);this.#q.stops.push({position:J,color:Q,opacity:100}),this.#q.stops.sort((q,N)=>q.position-N.position);let j=this.#q.stops.findIndex((q)=>q.position===J&&q.color===Q);this.#g(),this.#d(),this.#o(),this.#p(),requestAnimationFrame(()=>{let N=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[j];if(N)this.#U(N)})};#y(){if(this.#j=null,!this.isConnected)return;if(!this.#_)return;let _=this.#q.stops;this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z,$)=>{if($>=_.length)return;Z.removeAttribute("value"),Z.setAttribute("value",`${_[$].position}% 50%`)})}refreshLayout(){this.#y()}#b(){if(this.#j!==null)return;this.#j=requestAnimationFrame(()=>this.#y())}#g(){if(!this.#_)return;let _=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#q.stops;if(_.length!==Z.length){let $=this.#H;if(this.#_.replaceChildren(...this.#A()),$)this.#_.appendChild($);this.#u(),this.#l(),this.#b();return}for(let $=0;$<Z.length;$++){let J=_[$],Q=Z[$];if(J.dataset.stopIndex=$,J.setAttribute("value",`${Q.position}% 50%`),J.setAttribute("color",this.#k(Q)),this.#Y==="tip")J.setAttribute("tip","color");else J.removeAttribute("tip");let j=J.closest("fig-tooltip");if(j)j.setAttribute("text",`${Math.round(Q.position)}%`)}this.#u()}#u(){if(!this.#_)return;let _=this.#Y==="tip";if(this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(_)Z.setAttribute("tip","color");else Z.removeAttribute("tip")}),this.#H)if(_)this.#H.setAttribute("tip","add");else this.#H.removeAttribute("tip")}#l(){if(!this.#Q||!this.#_)return;this.#Q.disconnect(),this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((_)=>{this.#Q.observe(_,{attributes:!0,attributeFilter:["color"]})})}#t(){if(!this.#_)return;let _=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#q.stops,$=new Set;_.forEach((J)=>{let Q=Math.round(parseFloat(J.getAttribute("value"))||0),j=(J.getAttribute("color")||"").toUpperCase(),q=-1;for(let N=0;N<Z.length;N++){if($.has(N))continue;if(Z[N].position===Q&&Z[N].color.toUpperCase()===j){q=N;break}}if(q===-1){let N=1/0;for(let G=0;G<Z.length;G++){if($.has(G))continue;let K=Math.abs(Z[G].position-Q);if(K<N)N=K,q=G}}if(q!==-1)$.add(q),J.dataset.stopIndex=q})}#d(){if(!this.#Z)return;this.#Z.setAttribute("background",this.#D()),this.#F()}#i(){if(!this.#_)return;this.#_.addEventListener("pointerdown",(_)=>{if(T(this,"disabled"))return;if(_.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(_.button!==0)return;_.preventDefault(),_.stopPropagation();let Z=this.#_.getBoundingClientRect(),$=Math.max(0,Math.min(1,(_.clientX-Z.left)/Z.width)),J=Math.round($*100),Q=this.#f($);this.#q.stops.push({position:J,color:Q,opacity:100}),this.#q.stops.sort((G,K)=>G.position-K.position);let j=this.#q.stops.findIndex((G)=>G.position===J&&G.color===Q);this.#z=!0,this.#g(),this.#d(),this.#o(),this.#w();let N=this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[j];if(N)this.#U(N),N.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:_.clientX,clientY:_.clientY,pointerId:_.pointerId,pointerType:_.pointerType,button:_.button,buttons:_.buttons}))}),this.#_.addEventListener("input",(_)=>{let Z=_.target.closest("fig-handle");if(!Z)return;if(_.stopPropagation(),_.detail?.color){let G=parseInt(Z.dataset.stopIndex,10);if(!isNaN(G)&&this.#q.stops[G]){if(this.#q.stops[G].color=_.detail.color,_.detail.opacity!==void 0)this.#q.stops[G].opacity=_.detail.opacity;else if(_.detail.alpha!==void 0)this.#q.stops[G].opacity=Math.round(_.detail.alpha*100);Z.setAttribute("color",this.#k(this.#q.stops[G])),this.#d(),this.#o()}return}if(!this.#J)Z.style.zIndex="5";this.#J=!0;let $=parseInt(Z.dataset.stopIndex,10);if(isNaN($)||!this.#q.stops[$])return;let J=_.detail?.px??0,Q=Math.round(J*100),j=Q,q=this.#_.getBoundingClientRect().width;if(_.detail?.shiftKey)j=Math.round(j/G0.SHIFT_SNAP)*G0.SHIFT_SNAP;else{let G=q>0?5/q*100:0;for(let K=0;K<this.#q.stops.length;K++){if(K===$)continue;if(Math.abs(this.#q.stops[K].position-j)<=G){j=this.#q.stops[K].position;break}}}if(this.#q.stops[$].position=j,j!==Q)Z.style.left=`${j/100*q}px`;let N=Z.closest("fig-tooltip");if(N){if(N.text=`${Math.round(j)}%`,!N.hasAttribute("show"))N.setAttribute("show","true"),Z.hideColorTip()}this.#d(),this.#o()}),this.#_.addEventListener("change",(_)=>{let Z=_.target.closest("fig-handle");if(!Z)return;if(_.stopPropagation(),_.detail?.color){let G=parseInt(Z.dataset.stopIndex,10);if(!isNaN(G)&&this.#q.stops[G]){if(this.#q.stops[G].color=_.detail.color,_.detail.opacity!==void 0)this.#q.stops[G].opacity=_.detail.opacity;Z.setAttribute("color",this.#k(this.#q.stops[G])),this.#d(),this.#p()}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.#q.stops[J])return;let Q=_.detail?.px??0,j=Math.round(Q*100),q=this.#_.getBoundingClientRect().width,N=q>0?5/q*100:0;for(let G=0;G<this.#q.stops.length;G++){if(G===J)continue;if(Math.abs(this.#q.stops[G].position-j)<=N){j=this.#q.stops[G].position;break}}this.#q.stops[J].position=j,Z.style.left=`${j/100*q}px`,this.#q.stops.sort((G,K)=>G.position-K.position),this.#t(),this.#d(),this.#p(),requestAnimationFrame(()=>{this.#J=!1})}),this.#Q=new MutationObserver((_)=>{for(let Z of _){if(Z.attributeName!=="color")continue;let $=Z.target;if($.classList.contains("fig-input-gradient-ghost"))continue;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#q.stops[J])continue;let Q=$.getAttribute("color");if(!Q||!Q.startsWith("#"))continue;if(Q!==this.#q.stops[J].color)this.#q.stops[J].color=Q,this.#d(),this.#o()}}),this.#_.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((_)=>{this.#Q.observe(_,{attributes:!0,attributeFilter:["color"]})})}#o(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#p(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:B_(this.#M(this.#q))}}set value(_){let Z=typeof _==="string"?_:JSON.stringify(_);if(this.getAttribute("value")===Z){this.#T(),this.#d(),this.#g();return}this.setAttribute("value",Z)}focus(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#K){let Z=this.#X();if(Z){Z.focus(_);return}}HTMLElement.prototype.focus.call(this,_)}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"value":this.#T(),this.#d(),this.#g();break;case"disabled":this.#s();break;case"edit":if(this.#S(),this.#B(),this.#K)document.addEventListener("keydown",this.#O);else document.removeEventListener("keydown",this.#O);break;case"mode":this.#u();break;case"size":this.#F();break}}#s(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#W(),this.#Z)if(_)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#_)for(let Z of this.#_.querySelectorAll("fig-handle"))if(_)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}F("fig-input-gradient",G0);class O0 extends HTMLElement{#Z=null;#_;#J;#$;#Q=!1;constructor(){super();if(this.input=document.createElement("input"),this.name=this.getAttribute("name")||"",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",v()),this.name)this.input.setAttribute("name",this.name);this.input.setAttribute("type","checkbox"),this.#_=this.handleInput.bind(this),this.#J=this.handleChange.bind(this),this.#$=(_)=>{if(_.target!==this||this.input.disabled)return;this.input.click()}}connectedCallback(){let _=this.querySelector(":scope > input");if(_)this.input=_;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("input",this.#_),this.input.addEventListener("input",this.#_),this.input.removeEventListener("change",this.#J),this.input.addEventListener("change",this.#J),this.removeEventListener("click",this.#$),this.addEventListener("click",this.#$),this.#N();let Z=this.querySelector(":scope > label");if(Z)this.#Z=Z,this.#Q=!1,this.#Z.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#j(),this.#Z.innerText=this.getAttribute("label");if(!this.hasAttribute("label")){let $=Array.from(this.childNodes).filter((J)=>J.nodeType===Node.TEXT_NODE).map((J)=>J.textContent||"").join(" ").trim();if($&&!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-label",$)}this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#j(){if(!this.#Z)this.#Z=document.createElement("label"),this.#Q=!0,this.#Z.setAttribute("for",this.input.id);if(this.#Z&&!this.#Z.parentNode&&this.input.parentNode)this.input.after(this.#Z)}render(){}#G(_){return this.hasAttribute(_)&&this.getAttribute(_)!=="false"}#q(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#N(){let _=this.#G("checked"),Z=this.#G("indeterminate")&&!_,$=this.#G("disabled");this.input.checked=_,this.input.indeterminate=Z,this.input.disabled=$,this.input.value=this.getAttribute("value")||"";let J=this.getAttribute("name")||this.name;if(J)this.input.setAttribute("name",J);else this.input.removeAttribute("name");if(Z)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#q()}focus(){this.input.focus()}get value(){return this.input.value}set value(_){this.input.value=_,this.setAttribute("value",_)}get checked(){return this.input.checked}set checked(_){if(this.input.checked=_,_)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#J),this.removeEventListener("click",this.#$)}attributeChangedCallback(_,Z,$){switch(_){case"label":if($)this.#j(),this.#Z.innerText=$;else if(this.#Z&&this.#Q)this.#Z.remove(),this.#Z=null,this.#Q=!1;break;case"checked":if(this.#G("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#N();break;case"indeterminate":this.#N();break;case"disabled":this.#N();break;case"name":if($)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"value":this.input.value=$||"";break;default:this.input[_]=$,this.input.setAttribute(_,$);break}}handleInput(_){if(_.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#q(),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}handleChange(_){_.stopPropagation(),this.#q(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}F("fig-checkbox",O0);class z_ extends O0{constructor(){super();this.input.setAttribute("type","radio");let _=this.getAttribute("name");if(_)this.input.setAttribute("name",_);else this.input.removeAttribute("name")}}F("fig-radio",z_);class T_ extends O0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}F("fig-switch",T_);class D0 extends HTMLElement{static observedAttributes=["type","options","placeholder","value","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Z=!1;#_=null;#J=null;#$=null;#Q=null;#j=!1;#G=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#q=this.#L.bind(this);#N=this.#T.bind(this);#K=this.#k.bind(this);#Y=this.#F.bind(this);get value(){return this.getAttribute("value")||""}set value(_){this.setAttribute("value",_??"")}#X(){return this.getAttribute("type")==="number"?"fig-input-number":"fig-input-text"}#R(){return L(this.#X(),{placeholder:this.getAttribute("placeholder")||"",value:this.value})}#U(){return this.querySelector(":scope > .input-combo > :is(fig-input-text, fig-input-number)")?.localName===this.#X()}#W(){if(this.#_=this.querySelector(":scope > .input-combo > :is(fig-input-text, fig-input-number)"),this.#$=this.querySelector("fig-button"),this.#J=this.querySelector("fig-select, fig-dropdown"),this.#J?.localName==="fig-select"&&customElements.get("fig-select"))this.#J.menuAnchor=this;if(this.#_)this.#_.setAttribute("value",this.value),this.#_.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#f()}connectedCallback(){if(this.#Q=Array.from(this.children).find((_)=>_.tagName==="FIG-SELECT"||_.tagName==="FIG-DROPDOWN")||null,this.#Z=this.#Q!==null,this.#Q)this.#Q.remove();if(this.#U()){if(this.#W(),!this.#Q)this.#Z=!!this.#J&&!this.#J.hasAttribute("data-fig-split-generated"),this.#Q=this.#Z?this.#J:null;this.#B()}else this.#M(),this.#B();this.#I(T(this,"disabled"))}disconnectedCallback(){this.#O()}#M(){let _=this.#z(),Z=this.#V(),$=this.#R(),J=this.#Q;if(!J&&customElements.get("fig-select"))J=L("fig-select",{icon:!0,variant:"input",options:_.join(","),label:Z,"aria-label":Z,"data-fig-split-generated":!0});if(!J)J=L("fig-dropdown",{type:"dropdown",label:Z,"data-fig-split-generated":!0},_.map((q)=>L("option",{},q.trim())));let Q=J,j=null;if(J.localName==="fig-dropdown"){if(!J.hasAttribute("type"))J.setAttribute("type","dropdown");j=L("fig-button",{type:"select",variant:"input",icon:!0},L("fig-icon",{name:"chevron",size:"small",slot:"append"})),j.append(J),Q=j}if(!J.hasAttribute("label"))J.setAttribute("label",Z);if(this.replaceChildren(L("div",{className:"input-combo"},[$,Q])),this.#_=$,this.#$=j,this.#J=J,J.localName==="fig-select"&&customElements.get("fig-select"))J.menuAnchor=this;this.#f()}#B(){this.#O(),this.#J?.addEventListener("input",this.#q),this.#J?.addEventListener("change",this.#N),this.#_?.addEventListener("input",this.#K),this.#_?.addEventListener("change",this.#Y)}#O(){this.#J?.removeEventListener("input",this.#q),this.#J?.removeEventListener("change",this.#N),this.#_?.removeEventListener("input",this.#K),this.#_?.removeEventListener("change",this.#Y)}#L(_){_.stopPropagation(),this.#D(_),this.#A()}#T(_){_.stopPropagation(),this.#D(_),this.#H()}#D(_){let Z=_.target.closest("fig-select, fig-dropdown")?.value??"";if(this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.#_)this.#_.setAttribute("value",Z)}#k(_){_.stopPropagation();let Z=_.target.value??"";this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.#A()}#F(_){_.stopPropagation();let Z=_.target.value??"";this.#j=!0,this.setAttribute("value",Z),this.#j=!1,this.#H()}#A(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#H(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#z(){return(this.getAttribute("options")||"").split(",").map((_)=>_.trim()).filter(Boolean)}#S(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Split input").trim()}#V(){return`${this.#S()} options`}#f(){if(this.#_)this.#G.forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.#_.removeAttribute(_);else this.#_.setAttribute(_,Z)});if(this.#J){let _=this.#V();if(!this.#Z){if(this.#J.setAttribute("label",_),this.#J.localName==="fig-select")this.#J.setAttribute("aria-label",_)}else if(!this.#J.hasAttribute("aria-label")&&!this.#J.hasAttribute("label"))this.#J.setAttribute("label",_)}}#I(_){if(this.#_)if(_)this.#_.setAttribute("disabled","");else this.#_.removeAttribute("disabled");if(this.#$)if(_)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#J)if(_)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}focus(){this.#_?.focus()}attributeChangedCallback(_,Z,$){if(Z===$)return;switch(_){case"type":{if(!this.#_||this.#_.localName===this.#X())break;let J=this.#_.matches(":focus-within");this.#O();let Q=this.#R();if(this.#_.replaceWith(Q),this.#_=Q,this.#f(),this.#I(T(this,"disabled")),this.#B(),J)this.focus();break}case"options":if(this.#J&&!this.#Z)if(this.#J.localName==="fig-select")this.#J.setAttribute("options",$||"");else{let J=this.#z();this.#J.replaceChildren(...J.map((Q)=>{let j=document.createElement("option");return j.textContent=Q,j}))}break;case"placeholder":if(this.#_)this.#_.setAttribute("placeholder",$||"");this.#f();break;case"value":if(!this.#j&&this.#_)this.#_.setAttribute("value",$||"");break;case"disabled":this.#I($!==null&&$!=="false");break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#f();break}}}F("fig-split-input",D0);class k_ extends D0{}F("fig-combo-input",k_);class I0 extends HTMLElement{#Z="color";#_=null;#J=!1;constructor(){super();this.#_=this.#K.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#q(),this.#$(),this.#N()}#$(){let _=this.getAttribute("alpha");if(_!==null)this.style.setProperty("--alpha",_);else this.style.removeProperty("--alpha")}#Q(_){if(!_)return"color";let Z=_.toLowerCase();if(Z.includes("gradient"))return"gradient";if(Z.includes("url("))return"image";return"color"}#j(_){if(!_)return"#D9D9D9";if(_.startsWith("#"))return _.slice(0,7);try{let{ctx:Z}=k0(1,1);return Z.fillStyle=_,Z.fillStyle}catch{return"#D9D9D9"}}#G(_){if(!_||!_.includes("var("))return _;let Z=this.style.background;this.style.background=_;let $=getComputedStyle(this),J=$.backgroundImage,Q=$.backgroundColor;if(this.style.background=Z,J&&J!=="none")return J;return Q||_}#q(){let _=this.getAttribute("background");if(this.hasAttribute("background")&&!_?.trim()){if(this.#Z!=="image"||this.input){if(this.#Z="image",this.setAttribute("data-type","image"),this.input)this.input.removeEventListener("input",this.#_);this.replaceChildren(document.createElement("div")),this.input=null,this.#N()}this.style.setProperty("--swatch-background","none");return}let $=_||"#D9D9D9",J=$.includes("var("),Q=J?this.#G($):$,j=this.#Q(Q);if(j!==this.#Z||!this.input){if(this.#Z=j,this.setAttribute("data-type",this.#Z),this.input)this.input.removeEventListener("input",this.#_);if(this.#Z==="color"){let N=this.#j(Q),G=L("input",{type:"color",value:N});if(this.replaceChildren(document.createElement("div"),G),this.input=G,!J)this.input.addEventListener("input",this.#_);this.#N()}else this.replaceChildren(document.createElement("div")),this.input=null,this.#N()}else if(this.#Z==="color"&&this.input){let N=this.#j(Q);if(this.input.value!==N)this.input.value=N}let q=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--swatch-background",q?$:`linear-gradient(${$}, ${$})`)}#N(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",_?"true":"false"),this.input){this.input.disabled=_;let Z=this.getAttribute("aria-labelledby"),$=this.getAttribute("aria-label")||"Color swatch",J=this.getAttribute("aria-describedby");if(Z)this.input.setAttribute("aria-labelledby",Z),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",$),this.input.removeAttribute("aria-labelledby");if(J)this.input.setAttribute("aria-describedby",J);else this.input.removeAttribute("aria-describedby");this.removeAttribute("role"),this.removeAttribute("aria-hidden");return}if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-hidden","true");else this.setAttribute("role","img"),this.removeAttribute("aria-hidden")}#K(_){this.#J=!0,this.setAttribute("background",_.target.value),this.#J=!1}get background(){return this.getAttribute("background")}set background(_){this.setAttribute("background",_)}focus(){if(this.input?.isConnected){this.input.focus();return}HTMLElement.prototype.focus.call(this)}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="background"){if(this.#J){let J=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--swatch-background",J?$:`linear-gradient(${$}, ${$})`);return}this.#q()}else if(_==="alpha")this.#$();else if(_==="disabled"||_==="aria-label"||_==="aria-labelledby"||_==="aria-describedby")this.#N()}get alpha(){return this.getAttribute("alpha")}set alpha(_){if(_===null||_===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",_)}}F("fig-swatch",I0);class D_ extends I0{}F("fig-chit",D_);var I_=["load","error"],V_=["loadstart","progress","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","durationchange","timeupdate","ratechange","resize","volumechange"],M1=[...new Set([...I_,...V_])];class M0 extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#q=this.#s.bind(this);#N=this.#_0.bind(this);#K=this.#Z0.bind(this);#Y=this.#n.bind(this);#X=this.#e.bind(this);#R=null;#U=null;#W=null;#M=void 0;#B=null;#O=null;#L=null;#T=null;#D=null;#k=null;#F=null;static get observedAttributes(){return["src","type","alt","upload","loading-indicator","label","aspect-ratio","fit","checkerboard","caption","controls","autoplay","loop","muted","poster","aria-label","aria-labelledby","title"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#Z}set src(_){if(this.#Z=_||"",_===null||_===void 0||_==="")this.removeAttribute("src");else this.setAttribute("src",_)}get file(){return this.#G}#A(){return this.#j||this.#Z||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#A())return null;if(!this.#_)return null;try{if(typeof this.#_.decode==="function")await this.#_.decode();else if(!this.#_.complete)await new Promise((J,Q)=>{this.#_.addEventListener("load",J,{once:!0}),this.#_.addEventListener("error",Q,{once:!0})})}catch{}let _=this.#_.naturalWidth,Z=this.#_.naturalHeight;if(!(_>0)||!(Z>0))return null;let $=document.createElement("canvas");return $.width=_,$.height=Z,$.getContext("2d").drawImage(this.#_,0,0),$.toDataURL()}connectedCallback(){this.#Z=this.getAttribute("src")||"";let _=this.getAttribute("aspect-ratio");if(_)this.style.setProperty("--fig-media-aspect-ratio",_);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let Z=this.getAttribute("fit");if(Z)this.style.setProperty("--fig-media-fit",Z);if(this.querySelectorAll("fig-swatch[data-generated]").forEach((J)=>J.remove()),this.#P(),this.#E(),this.#z(),this.#y(),this.#V(),this.#x(),this.#h(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#o();this.#$=this.querySelector("fig-input-file[data-generated]"),this.#$?.removeEventListener("change",this.#q),this.#$?.addEventListener("change",this.#q)}disconnectedCallback(){if(this.#$?.removeEventListener("change",this.#q),this.#I(),this.#H(),this.#i(),this.#Q)URL.revokeObjectURL(this.#Q),this.#Q=null;this.#j=null}#H(){if(!this.#_)return;if(M1.forEach((_)=>{this.#_.removeEventListener(_,this.#X)}),this.#_.tagName==="VIDEO")this.#_.removeEventListener("play",this.#N),this.#_.removeEventListener("pause",this.#K),this.#_.removeEventListener("ended",this.#Y)}#z(){if(this.#H(),!this.#_)return;if((this.#_.tagName==="VIDEO"?V_:I_).forEach((Z)=>{this.#_.addEventListener(Z,this.#X)}),this.#_.tagName!=="VIDEO")return;this.#_.addEventListener("play",this.#N),this.#_.addEventListener("pause",this.#K),this.#_.addEventListener("ended",this.#Y)}#S(){return this.mediaKind==="image"&&this.getAttribute("loading-indicator")!=="false"&&this.#J?.hasAttribute("data-generated")&&this.#_?.hasAttribute("data-generated")}#V(){this.#f();let _=this.#A();if(!_||!this.#S()){this.#I();return}if(this.#_?.tagName==="IMG"&&this.#_.complete&&this.#_.currentSrc){this.#I();return}if(this.#W===_)return;this.#I(),this.#W=_,this.#M=this.getAttribute("aria-busy"),this.setAttribute("aria-busy","true"),this.#U=setTimeout(()=>{if(this.#U=null,this.#W!==_||!this.isConnected||!this.#S())return;let Z=document.createElement("fig-spinner");Z.setAttribute("data-generated",""),Z.setAttribute("data-loading-indicator",""),Z.setAttribute("slot","overlay"),Z.setAttribute("size","small"),Z.setAttribute("aria-hidden","true"),this.append(Z),this.#R=Z},150)}#f(){let _=this.#_?.tagName==="IMG"?this.#_:null,Z=_?.currentSrc||_?.getAttribute("src")||this.#A();this.toggleAttribute("loaded",Boolean(Z&&_?.complete&&_.naturalWidth>0))}#I(){if(this.#U!==null)clearTimeout(this.#U),this.#U=null;if(this.#R?.remove(),this.#R=null,this.#W=null,this.#M!==void 0){if(this.#M===null)this.removeAttribute("aria-busy");else this.setAttribute("aria-busy",this.#M);this.#M=void 0}}#P(){if(this.#J?.isConnected)return;let _=this.querySelector(":scope > fig-preview");if(_){this.#J=_;return}let Z=document.createElement("fig-preview");Z.setAttribute("data-generated",""),this.prepend(Z),this.#J=Z}#w(){let _=this.mediaKind==="video"?"video":"img";return this.querySelector(`${_}:not([data-generated])`)}#E(){let _=this.#w();if(_){if(this.#P(),this.#_&&this.#_!==_){if(this.#H(),this.#_.hasAttribute("data-generated"))this.#_.remove()}if(this.#_=_,this.#J&&_.parentElement!==this.#J)this.#J.append(_);this.#z(),this.#x();return}this.#P();let Z=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#_&&this.#_.tagName!==Z){if(this.#H(),this.#_.hasAttribute("data-generated"))this.#_.remove();this.#_=null}if(this.#_)return;if(this.mediaKind==="video"){let $=document.createElement("video");$.setAttribute("data-generated",""),$.className="fig-media-element",$.setAttribute("playsinline",""),$.preload="auto",this.#J.append($),this.#_=$;let J=()=>{if(this.#_?.autoplay)return;try{this.#_.currentTime=0.001}catch{}};this.#_.addEventListener("loadedmetadata",J,{once:!0})}else{let $=document.createElement("img");$.setAttribute("data-generated",""),$.className="fig-media-element",$.loading="lazy",$.decoding="async",$.alt=this.getAttribute("alt")||"",this.#J.append($),this.#_=$}this.#z()}#x(){if(!this.#_)return;if(this.#_.tagName==="IMG"){if(this.hasAttribute("alt")||this.#_.hasAttribute("data-generated"))this.#_.alt=this.getAttribute("alt")||"";return}if(this.#_.tagName!=="VIDEO")return;["aria-label","aria-labelledby","title"].forEach((_)=>{let Z=this.getAttribute(_);if(Z===null)this.#_.removeAttribute(_);else this.#_.setAttribute(_,Z)})}#C(){return this.querySelector(":scope > figcaption:not([data-generated])")}#v(){return Array.from(this.querySelectorAll(":scope > figcaption[data-generated]"))}#h(){let _=this.#C(),Z=this.#v();if(_){Z.forEach((j)=>j.remove());return}let $=this.getAttribute("caption")||"";if(!$){Z.forEach((j)=>j.remove());return}let J=Z[0]||document.createElement("figcaption");if(Z.slice(1).forEach((j)=>j.remove()),!J.hasAttribute("data-generated"))J.setAttribute("data-generated","");if(J.textContent!==$)J.textContent=$;let Q=this.querySelector(":scope > fig-media-controls");if(Q)Q.before(J);else if(this.#J?.isConnected)this.#J.after(J);else if(!J.isConnected)this.append(J)}#m(_,Z=!1){if(!this.hasAttribute(_))return Z;return this.getAttribute(_)!=="false"}#y(){if(!this.#_)return;if(!this.#_.hasAttribute("data-generated"))return;let _=this.#A();if(this.#_.getAttribute("src")!==_){if(this.removeAttribute("loaded"),_)this.#_.setAttribute("src",_);else if(this.#_.removeAttribute("src"),this.#_.tagName==="VIDEO")this.#_.load()}if(this.#_.tagName==="IMG"){this.#x(),this.#V();return}let Z=this.getAttribute("poster");if(Z)this.#_.setAttribute("poster",Z);else this.#_.removeAttribute("poster");this.#_.controls=!1,this.#_.removeAttribute("controls"),this.#_.autoplay=this.#m("autoplay",!1),this.#_.loop=this.#m("loop",!1),this.#_.muted=this.#m("muted",!1),this.#_.playsInline=!0,this.#x(),this.#u(),this.#g(),this.#V()}get mediaEl(){return this.#_}#b(){if(this.mediaKind!=="video")return!1;return Boolean(this.#A())}#g(){let _=this.#B||this.querySelector(":scope > fig-media-controls");if(!_)return;if(this.mediaKind!=="video")return;if(this.#b()){if(_.hasAttribute("data-fig-empty-disabled"))_.removeAttribute("disabled"),_.removeAttribute("data-fig-empty-disabled");return}_.setAttribute("disabled",""),_.setAttribute("data-fig-empty-disabled",""),_.playing=!1,_.time=0,_.duration=0}#u(){if(this.mediaKind!=="video"){this.#i();return}let _=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(_){if(this.#B!==_)this.#i(),this.#B=_;this.#t(),this.#g();return}if(this.#m("controls",!1))this.#l();else this.#i()}#l(){let _=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Z=_[0];if(_.slice(1).forEach((J)=>J.remove()),Z){this.#B=Z,this.#t(),this.#g();return}let $=document.createElement("fig-media-controls");$.setAttribute("data-generated",""),this.append($),this.#B=$,this.#t(),this.#g()}#t(){if(!this.#B||!this.#_)return;if(this.#O===this.#_&&this.#L===this.#B){this.#g();return}this.#d();let _=this.#B,Z=this.#_;this.#O=Z,this.#L=_;let $=null,J=()=>{if(this.#g(),!this.#b())return;if(_.playing=!Z.paused&&!Z.ended,Number.isFinite(Z.duration))_.duration=Z.duration;if($!==null)if(Math.abs(Z.currentTime-$)<0.25)$=null;else return;_.time=Z.currentTime||0},Q=()=>{if(!this.#b())return;let N=Z.play?.();if(N&&typeof N.catch==="function")N.catch(()=>{})},j=()=>Z.pause?.(),q=(N)=>{if(!this.#b())return;let G=Number(N?.detail?.time);if(!Number.isFinite(G))return;$=G;try{Z.currentTime=G}catch{}};this.#T=J,this.#D=Q,this.#k=j,this.#F=q,Z.addEventListener("play",J),Z.addEventListener("pause",J),Z.addEventListener("ended",J),Z.addEventListener("timeupdate",J),Z.addEventListener("loadedmetadata",J),Z.addEventListener("durationchange",J),Z.addEventListener("seeked",J),_.addEventListener("play",Q),_.addEventListener("pause",j),_.addEventListener("seek",q),J()}#d(){let _=this.#O,Z=this.#L;if(_&&this.#T)_.removeEventListener("play",this.#T),_.removeEventListener("pause",this.#T),_.removeEventListener("ended",this.#T),_.removeEventListener("timeupdate",this.#T),_.removeEventListener("loadedmetadata",this.#T),_.removeEventListener("durationchange",this.#T),_.removeEventListener("seeked",this.#T);if(Z){if(this.#D)Z.removeEventListener("play",this.#D);if(this.#k)Z.removeEventListener("pause",this.#k);if(this.#F)Z.removeEventListener("seek",this.#F)}this.#O=null,this.#L=null,this.#T=null,this.#D=null,this.#k=null,this.#F=null}#i(){this.#d(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((_)=>{_.remove()}),this.#B=null}toggle(){if(!this.#_||this.mediaKind!=="video")return;if(this.#_.paused||this.#_.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#_)return;let _=this.#_.play();if(_&&typeof _.catch==="function")_.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#_)return;this.#_.pause()}#o(){let _=document.createElement("fig-input-file");_.setAttribute("data-generated",""),_.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),_.setAttribute("variant","overlay");let Z=this.getAttribute("label")||"Upload";if(_.setAttribute("label",this.#Z?"Replace":Z),this.#G?.name)_.setAttribute("filename",this.#G.name);else if(this.#Z)_.setAttribute("url",this.#Z);_.addEventListener("change",this.#q),this.#P(),this.#J.append(_),this.#$=_}#p(){if(this.#$)this.#$.removeEventListener("change",this.#q),this.#$.remove(),this.#$=null}#s(_){if(_.target!==this.#$)return;let Z=_.detail?.files?.[0],$=_.detail?.cleared===!0;if(!Z){if(this.#Q)URL.revokeObjectURL(this.#Q),this.#Q=null;if(this.#G=null,this.#j=null,$)this.src="";if(this.#y(),this.#$){let J=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Z?"Replace":J),this.#$.removeAttribute("filename"),this.#Z)this.#$.setAttribute("url",this.#Z);else this.#$.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#Q)URL.revokeObjectURL(this.#Q);if(this.#G=Z,this.#Q=URL.createObjectURL(Z),this.#j=this.#Q,this.#y(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Z,src:this.#Q}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#$)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",Z.name),this.#$.setAttribute("label","Replace")}#c(_){if(!this.#_)return;this.dispatchEvent(new CustomEvent(_,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Z||"",currentTime:this.#_.currentTime,duration:this.#_.duration}}))}#e(_){let Z=this.#_;if(!Z||_.currentTarget!==Z)return;if(Z.tagName==="IMG"&&(_.type==="load"||_.type==="error"))this.toggleAttribute("loaded",_.type==="load"),this.#I();let $={src:this.#A(),media:Z,originalEvent:_};if(Z.tagName==="VIDEO")$.currentTime=Z.currentTime,$.duration=Z.duration,$.readyState=Z.readyState,$.networkState=Z.networkState,$.error=Z.error;if(this.dispatchEvent(new CustomEvent(_.type,{bubbles:!0,cancelable:!1,composed:!0,detail:$})),Z.tagName==="IMG"&&_.type==="load"||Z.tagName==="VIDEO"&&_.type==="loadeddata")this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,composed:!0,detail:{src:$.src,file:this.#G,media:Z}}))}#_0(){this.#c("play")}#Z0(){this.#c("pause")}#n(){this.#c("ended")}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="src"){let J=$||"",Q=J&&(J===this.#j||J===this.#Q);if(this.#Z=J,this.#Q&&!Q)URL.revokeObjectURL(this.#Q),this.#Q=null,this.#j=null,this.#G=null;if(this.#y(),this.#$){let j=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Z?"Replace":j),this.#Z)if(this.#G?.name)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",this.#G.name);else this.#$.setAttribute("url",this.#Z),this.#$.removeAttribute("filename");else this.#$.removeAttribute("url"),this.#$.removeAttribute("filename")}}if(_==="type"){if(this.#E(),this.#y(),this.#$)this.#$.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(_))this.#x();if(_==="upload"){let J=$!==null&&$!=="false";if(J&&!this.#$)this.#o();else if(!J)this.#p()}if(_==="loading-indicator")this.#V();if(_==="aspect-ratio")if($)this.style.setProperty("--fig-media-aspect-ratio",$);else this.style.removeProperty("--fig-media-aspect-ratio");if(_==="fit")if($)this.style.setProperty("--fig-media-fit",$);else this.style.removeProperty("--fig-media-fit");if(_==="label"&&this.#$){let J=this.getAttribute("label")||"Upload";this.#$.setAttribute("label",this.#Z?"Replace":J)}if(["controls","autoplay","loop","muted","poster"].includes(_))this.#y();if(_==="caption")this.#h()}}F("fig-media",M0);class P_ extends M0{get mediaKind(){return"image"}}F("fig-image",P_);class C_ extends M0{get mediaKind(){return"video"}}F("fig-video",C_);class S_ extends HTMLElement{static get observedAttributes(){return["src","alt","label","text","sublabel","selected","disabled","full","size","direction","aspect-ratio","fit","label-line-clamp","label-overflow"]}#Z=null;#_=null;#J=null;#$=null;#Q=!1;#j=new MutationObserver((_)=>{if(!_.some(($)=>[...$.addedNodes,...$.removedNodes].some((J)=>J instanceof Element&&(J.matches("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])")||J.querySelector("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])"))))||!this.isConnected)return;this.#R(),this.#M()});connectedCallback(){this.#j.observe(this,{childList:!0,subtree:!0}),this.#R(),this.#M()}disconnectedCallback(){this.#j.disconnect()}attributeChangedCallback(){if(!this.isConnected)return;this.#R(),this.#M()}#G(){return this.getAttribute("label")??this.getAttribute("text")??""}#q(){return this.getAttribute("sublabel")??""}#N(){return this.getAttribute("label-line-clamp")==="2"?"2":"1"}#K(){return Boolean(this.getAttribute("src"))}#Y(){return this.querySelector(":scope > fig-image:not([data-generated]), :scope > fig-media:not([data-generated]), :scope > fig-preview:not([data-generated])")}#X(){this.querySelectorAll(":scope > .fig-card-link").forEach((_)=>{_.querySelectorAll(":scope > .fig-card-media").forEach((Z)=>{while(Z.firstChild)_.insertBefore(Z.firstChild,Z);Z.remove()});while(_.firstChild)this.insertBefore(_.firstChild,_);_.remove()})}#R(){if(this.#X(),!this.#K()){this.#U();return}let _=this.#Y();if(this.#Q=Boolean(_),_)this.querySelectorAll(":scope > [data-generated]:not(fig-footer)").forEach(($)=>$.remove()),this.#_=null;if(!this.#Q){if(this.#_=this.querySelector(":scope > fig-image[data-generated]")||null,!this.#_)this.querySelectorAll(":scope > fig-image, :scope > fig-media, :scope > fig-preview").forEach(($)=>{if($.hasAttribute("data-generated"))$.remove()}),this.#_=document.createElement("fig-image"),this.#_.setAttribute("data-generated",""),this.#_.setAttribute("full",""),this.#_.setAttribute("size","auto"),this.prepend(this.#_)}if(!Boolean(this.#G()||this.#q())){this.querySelector(":scope > fig-footer[data-generated]")?.remove(),this.#Z=null,this.#J=null,this.#$=null;return}if(!this.#Z||!this.#Z.isConnected){if(this.#Z=this.querySelector(":scope > fig-footer[data-generated]"),!this.#Z)this.#Z=document.createElement("fig-footer"),this.#Z.setAttribute("data-generated",""),this.appendChild(this.#Z)}if(!this.#J||!this.#J.isConnected){if(this.#J=this.#Z.querySelector(":scope > .fig-card-label[data-generated]"),!this.#J)this.#J=document.createElement("label"),this.#J.className="fig-card-label",this.#J.setAttribute("data-generated",""),this.#Z.appendChild(this.#J)}if(!this.#$||!this.#$.isConnected){if(this.#$=this.#Z.querySelector(":scope > .fig-card-sublabel[data-generated]"),!this.#$)this.#$=document.createElement("label"),this.#$.className="fig-card-sublabel",this.#$.setAttribute("data-generated",""),this.#J.after(this.#$)}}#U(){if(this.#X(),this.querySelectorAll(":scope > [data-generated]").forEach((Z)=>Z.remove()),this.#_=null,this.#Q=!0,this.#Z=null,this.#J=null,this.#$=null,!this.#G()&&!this.#q())return;this.#Z=document.createElement("fig-footer"),this.#Z.setAttribute("data-generated",""),this.#J=document.createElement("label"),this.#J.className="fig-card-label",this.#J.setAttribute("data-generated",""),this.#Z.appendChild(this.#J);let _=this.#q();if(this.#$=null,_)this.#$=document.createElement("label"),this.#$.className="fig-card-sublabel",this.#$.setAttribute("data-generated",""),this.#Z.appendChild(this.#$);this.appendChild(this.#Z)}#W(){let _=this.getAttribute("label-overflow")==="fade";this.querySelectorAll(":scope > fig-footer > :is(.fig-card-label, .fig-card-sublabel)").forEach((Z)=>{Z.classList.toggle("fig-overflow-fade",_),Z.classList.toggle("fig-overflow-fade-horizontal",_)})}#M(){if(!this.#K()){this.#B();return}let _=T(this,"disabled"),Z=this.#G(),$=this.#q(),J=this.#N();this.style.setProperty("--fig-card-label-line-clamp",J),this.setAttribute("role","group");let Q=[Z,$].filter(Boolean).join(", ");if(Q)this.setAttribute("aria-label",Q);else this.removeAttribute("aria-label");if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#_&&!this.#Q){let j=this.getAttribute("src"),q=this.getAttribute("alt"),N=this.getAttribute("aspect-ratio")||"1/1",G=this.getAttribute("fit")||"contain",K=q!=null?q:"";if(j)this.#_.setAttribute("src",j);else this.#_.removeAttribute("src");this.#_.setAttribute("alt",K),this.#_.setAttribute("aspect-ratio",N),this.#_.setAttribute("fit",G),this.#_.setAttribute("full",""),this.#_.setAttribute("size","auto")}if(this.#J)this.#J.textContent=Z,this.#J.hidden=!Z;if(this.#$)this.#$.textContent=$,this.#$.hidden=!$;if(this.#Z)this.#Z.hidden=!Z&&!$;this.#W()}#B(){let _=T(this,"disabled"),Z=this.#G(),$=this.#q();this.style.setProperty("--fig-card-label-line-clamp",this.#N()),this.setAttribute("role","group");let J=[Z,$].filter(Boolean).join(", ");if(J)this.setAttribute("aria-label",J);else this.removeAttribute("aria-label");if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#J)this.#J.textContent=Z,this.#J.hidden=!Z;if(this.#$)this.#$.textContent=$;this.#W()}}F("fig-card",S_);class E_ extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=!1;#j=!1;static get observedAttributes(){return["playing","duration","time","disabled"]}connectedCallback(){this.#G(),this.#Y(),this.#X(),this.#q()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(_){if(_)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let _=Number(this.getAttribute("duration"));return Number.isFinite(_)&&_>=0?_:0}set duration(_){let Z=Number(_);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("duration");return}this.setAttribute("duration",String(Z))}get time(){let _=Number(this.getAttribute("time"));return Number.isFinite(_)&&_>=0?_:0}set time(_){let Z=Number(_);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("time");return}this.setAttribute("time",String(Z))}get disabled(){return T(this,"disabled")}set disabled(_){if(_)this.setAttribute("disabled","");else this.removeAttribute("disabled")}attributeChangedCallback(_){if(!this.#j)return;if(_==="playing")this.#Y();if(_==="duration"||_==="time")this.#X();if(_==="disabled")this.#q()}#G(){if(this.#j)return;if(this.#j=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");let _=document.createElement("fig-tooltip");_.setAttribute("text","Play");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Play"),Z.append(b("play")),_.append(Z),Z.addEventListener("click",(j)=>{j.preventDefault(),j.stopPropagation(),this.toggle()});let $=document.createElement("fig-slider");$.setAttribute("text","false"),$.setAttribute("min","0"),$.setAttribute("max",String(this.duration)),$.setAttribute("step","1"),$.setAttribute("value",String(this.time)),$.setAttribute("full",""),$.setAttribute("aria-label","Seek"),$.setAttribute("aria-valuetext",this.#K(this.time,this.duration));let J=document.createElement("span");J.className="fig-media-controls-time",J.textContent=this.#N(this.time);let Q=(j)=>{if(this.disabled){j.preventDefault?.(),j.stopPropagation();return}let q=j.currentTarget,N=Number(q?.value);if(!Number.isFinite(N))return;this.#Q=!0,this.setAttribute("time",String(N)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:N}})),requestAnimationFrame(()=>{this.#Q=!1})};$.addEventListener("input",Q),$.addEventListener("change",Q),this.append(_,$,J),this.#Z=Z,this.#_=_,this.#J=$,this.#$=J,this.#q()}#q(){let _=this.disabled;if(this.setAttribute("aria-disabled",_?"true":"false"),this.#Z)if(_)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#J)if(_)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}#N(_){if(!Number.isFinite(_)||_<0)_=0;let Z=Math.floor(_),$=Math.floor(Z/60),J=Z%60;return`${String($).padStart(2,"0")}:${String(J).padStart(2,"0")}`}#K(_,Z=0){let $=this.#N(_);if(!Number.isFinite(Z)||Z<=0)return $;return`${$} of ${this.#N(Z)}`}#Y(){if(!this.#Z)return;let _=this.playing;this.#Z.setAttribute("aria-label",_?"Pause":"Play"),this.#_?.setAttribute("text",_?"Pause":"Play");let Z=this.#Z.querySelector("fig-icon");if(Z)Z.setAttribute("name",_?"pause":"play")}#X(){if(!this.#J)return;let _=this.duration;if(Number(this.#J.getAttribute("max"))!==_)this.#J.setAttribute("max",String(_));let Z=this.time;if(!this.#Q)this.#J.setAttribute("value",String(Z));if(this.#J.setAttribute("aria-valuetext",this.#K(Z,_)),this.#$)this.#$.textContent=this.#N(Z)}toggle(){if(this.disabled)return;let _=!this.playing;this.playing=_,this.dispatchEvent(new CustomEvent(_?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:_}}))}play(){if(this.disabled||this.playing)return;this.toggle()}pause(){if(this.disabled||!this.playing)return;this.toggle()}}F("fig-media-controls",E_);class V0 extends HTMLElement{static#Z=0;static observedAttributes=["url","polarization","progress"];#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#q=null;#N=null;#K=[];#Y=0;#X=0;connectedCallback(){if(!this.#_)this.#R();this.#U(),this.#W()}disconnectedCallback(){if(this.#k(),this.#G?.disconnect(),this.#G=null,this.#X)cancelAnimationFrame(this.#X);this.#X=0}attributeChangedCallback(_,Z,$){if(Z===$||!this.#_)return;if(_==="url")this.#W();if(_==="polarization")this.#F();if(_==="progress")this.#D()}#R(){this.#_=document.createElement("div"),this.#_.className="fig-audio-waveform-surface",this.#_.setAttribute("aria-hidden","true"),this.#J=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.#J.setAttribute("aria-hidden","true"),this.#J.setAttribute("preserveAspectRatio","none");let _=document.createElementNS("http://www.w3.org/2000/svg","defs"),Z=document.createElementNS("http://www.w3.org/2000/svg","clipPath"),$=`fig-audio-waveform-progress-${++V0.#Z}`;Z.id=$,Z.setAttribute("clipPathUnits","userSpaceOnUse"),this.#j=document.createElementNS("http://www.w3.org/2000/svg","rect"),Z.append(this.#j),_.append(Z),this.#$=document.createElementNS("http://www.w3.org/2000/svg","path"),this.#$.classList.add("fig-audio-waveform-path"),this.#Q=document.createElementNS("http://www.w3.org/2000/svg","path"),this.#Q.classList.add("fig-audio-waveform-progress"),this.#Q.setAttribute("clip-path",`url(#${$})`),this.#J.append(_,this.#$,this.#Q),this.#_.appendChild(this.#J),this.replaceChildren(this.#_),this.#U()}#U(){if(this.#G||!this.#J)return;this.#G=new ResizeObserver(()=>this.#F()),this.#G.observe(this.#J)}#W(){let _=this.getAttribute("url");if(!_){this.#O();return}this.#M(async(Z)=>{let $=await fetch(_,{signal:Z});if(!$.ok)throw Error(`Audio request failed: ${$.status}`);return $.arrayBuffer()})}async#M(_){this.#k();let Z=++this.#Y,$=new AbortController;this.#q=$,this.setAttribute("data-waveform-state","loading"),this.setAttribute("aria-busy","true"),this.#K=[],this.#F();let J=null;try{let Q=await _($.signal);if(Z!==this.#Y||!this.isConnected)return;let j=window.AudioContext||window.webkitAudioContext;if(!j)throw Error("Web Audio is unavailable");J=new j,this.#N=J;let q=await J.decodeAudioData(Q);if(Z!==this.#Y||!this.isConnected)return;this.#K=this.#B(q),this.setAttribute("data-waveform-state","ready"),this.#F()}catch(Q){if(Z!==this.#Y||Q?.name==="AbortError")return;this.#K=Array(256).fill(0),this.setAttribute("data-waveform-state","unavailable"),this.#F()}finally{if(J)try{await J.close()}catch{}if(this.#N===J)this.#N=null;if(this.#q===$)this.#q=null;if(Z===this.#Y)this.removeAttribute("aria-busy")}}#B(_){let $=Array(256).fill(0),J=_.numberOfChannels,Q=_.length,j=Math.max(1,Math.ceil(Q/500000)),q=0;for(let K=0;K<256;K+=1){let X=Math.floor(K/256*Q),Y=Math.max(X+1,Math.floor((K+1)/256*Q)),U=0,R=0;for(let M=0;M<J;M+=1){let H=_.getChannelData(M);for(let A=X;A<Y;A+=j){let z=H[A]||0;if(!Number.isFinite(z))continue;U+=z*z,R+=1}}let O=R>0?Math.sqrt(U/R):0;$[K]=O,q=Math.max(q,O)}if(!Number.isFinite(q)||q<=0)return $.fill(0);let N=Math.min(...$),G=q-N;if(!Number.isFinite(G)||G<=Number.EPSILON)return $.fill(0);return $.map((K)=>{let X=(K-N)/G;return Number.isFinite(X)?X:0})}#O(){this.#k(),this.#K=[],this.removeAttribute("data-waveform-state"),this.removeAttribute("aria-busy"),this.#F()}#L(_){let Z=Number.parseFloat(this.getAttribute("polarization")),$=Number.isFinite(Z)?Math.max(0,Math.min(Z,4)):1.5;return Math.max(0,Math.min(1,0.5+(_-0.5)*$))}#T(){let _=Number.parseFloat(this.getAttribute("progress"));return Number.isFinite(_)?Math.max(0,Math.min(_,1)):0}#D(){if(!this.#J||!this.#j)return;let _=this.#J.viewBox.baseVal,Z=this.#J.getBoundingClientRect(),$=_.width||Math.max(1,Math.round(Z.width)),J=_.height||Math.max(1,Math.round(Z.height));this.#j.setAttribute("x","0"),this.#j.setAttribute("y","0"),this.#j.setAttribute("width",String($*this.#T())),this.#j.setAttribute("height",String(J))}#k(){if(this.#Y+=1,this.#q?.abort(),this.#q=null,this.#N){try{this.#N.close()}catch{}this.#N=null}}#F(){if(this.#X)return;this.#X=requestAnimationFrame(()=>{this.#X=0,this.#A()})}#A(){if(!this.#J||!this.#$||!this.#Q||!this.#j)return;let _=this.#J.getBoundingClientRect(),Z=Math.max(1,Math.round(_.width)),$=Math.max(1,Math.round(_.height));if(this.#J.setAttribute("viewBox",`0 0 ${Z} ${$}`),this.#D(),this.#K.length===0){this.#$.setAttribute("d",""),this.#Q.setAttribute("d","");return}let J=Math.min(this.#K.length,Math.max(16,Math.floor(Z/3))),Q=Z/J,j=Number.parseFloat(getComputedStyle(this).getPropertyValue("--fig-audio-waveform-stroke-width")),q=Number.isFinite(j)&&j>0?j:2,N=Math.max(0.5,Math.min(q,Q*0.75)),G=N/2,K=$/2,X=Math.max(2,$-12),Y=[];for(let R=0;R<J;R+=1){let O=Math.min(this.#K.length-1,Math.floor(R/J*this.#K.length)),M=this.#L(this.#K[O]),H=Math.max(N,M*X),A=(R+0.5)*Q,z=K-H/2,W=K+H/2,I=A-G,V=A+G;Y.push(`M ${A} ${z} Q ${V} ${z} ${V} ${z+G} V ${W-G} Q ${V} ${W} ${A} ${W} Q ${I} ${W} ${I} ${W-G} V ${z+G} Q ${I} ${z} ${A} ${z} Z`)}let U=Y.join(" ");this.#$.setAttribute("d",U),this.#Q.setAttribute("d",U)}}F("fig-audio-waveform",V0);class f_ extends HTMLElement{#Z="";#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#q=null;#N=null;#K=null;static get observedAttributes(){return["src","autoplay","controls","muted","loop"]}connectedCallback(){this.#Z=this.getAttribute("src")||"",this.#X(),this.#R(),this.#W(),this.#B(),this.#D()}disconnectedCallback(){this.#F()}get src(){return this.#Z}set src(_){if(_===null||_===void 0||_==="")this.removeAttribute("src");else this.setAttribute("src",String(_))}get audioEl(){return this.#_}#Y(_){return this.hasAttribute(_)&&this.getAttribute(_)!=="false"}#X(){let _=this.querySelector(":scope > audio:not([data-generated])");if(_){this.#_=_;return}let Z=Array.from(this.querySelectorAll(":scope > audio[data-generated]")),$=Z[0]||document.createElement("audio");if(Z.slice(1).forEach((J)=>J.remove()),!$.hasAttribute("data-generated"))$.setAttribute("data-generated",""),$.preload="metadata",this.append($);this.#_=$}#R(){let _=this.querySelector(":scope > fig-audio-waveform:not([data-generated])");if(_)this.querySelectorAll(":scope > fig-audio-waveform[data-generated]").forEach((Z)=>Z.remove()),this.#J=_;else{let Z=Array.from(this.querySelectorAll(":scope > fig-audio-waveform[data-generated]")),$=Z[0]||document.createElement("fig-audio-waveform");if(Z.slice(1).forEach((J)=>J.remove()),!$.hasAttribute("data-generated"))$.setAttribute("data-generated",""),$.setAttribute("full",""),this.prepend($);this.#J=$}this.#U()}#U(){if(!this.#J)return;if(this.#Z)this.#J.setAttribute("url",this.#Z);else this.#J.removeAttribute("url")}#W(){if(!this.#_)return;if(this.#_.getAttribute("src")!==this.#Z)if(this.#Z)this.#_.setAttribute("src",this.#Z);else this.#_.removeAttribute("src"),this.#_.load?.();this.#_.controls=!1,this.#_.removeAttribute("controls"),this.#_.autoplay=this.#Y("autoplay"),this.#_.muted=this.#Y("muted"),this.#_.loop=this.#Y("loop"),this.#U(),this.#L()}#M(){return Boolean(this.#Z)}#B(){let _=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(_){if(this.#$!==_)this.#A(),this.#$=_;this.#k(),this.#L();return}if(this.#Y("controls"))this.#O();else this.#A()}#O(){let _=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Z=_[0]||document.createElement("fig-media-controls");if(_.slice(1).forEach(($)=>$.remove()),!Z.hasAttribute("data-generated"))Z.setAttribute("data-generated",""),this.append(Z);this.#$=Z,this.#k(),this.#L()}#L(){if(!this.#$)return;if(this.#M()){if(this.#$.hasAttribute("data-fig-empty-disabled"))this.#$.removeAttribute("disabled"),this.#$.removeAttribute("data-fig-empty-disabled");return}this.#$.setAttribute("disabled",""),this.#$.setAttribute("data-fig-empty-disabled",""),this.#$.removeAttribute("playing"),this.#$.setAttribute("time","0"),this.#$.setAttribute("duration","0"),this.#T(0,0)}#T(_,Z){if(!this.#J)return;let $=Number.isFinite(_)&&Number.isFinite(Z)&&Z>0?Math.max(0,Math.min(_/Z,1)):0;this.#J.setAttribute("progress",String($))}#D(){let _=this.#_;if(!_)return;let Z=Number.isFinite(_.currentTime)?_.currentTime:0,$=Number.isFinite(_.duration)?_.duration:0;if(this.#$)this.#$.toggleAttribute("playing",!_.paused&&!_.ended),this.#$.setAttribute("time",String(Z)),this.#$.setAttribute("duration",String($));this.#T(Z,$)}#k(){if(!this.#$||!this.#_)return;if(this.#Q===this.#_&&this.#j===this.#$){this.#L(),this.#D();return}this.#F();let _=this.#$,Z=this.#_,$=null,J=()=>{if(this.#L(),!this.#M())return;let N=Number.isFinite(Z.duration)?Z.duration:0,G=Number.isFinite(Z.currentTime)?Z.currentTime:0;if(_.toggleAttribute("playing",!Z.paused&&!Z.ended),_.setAttribute("duration",String(N)),$!==null)if(Math.abs(G-$)<0.25)$=null;else{this.#T(G,N);return}_.setAttribute("time",String(G)),this.#T(G,N)},Q=()=>this.play(),j=()=>this.pause(),q=(N)=>{if(!this.#M())return;let G=Number(N?.detail?.time);if(!Number.isFinite(G))return;$=G;try{Z.currentTime=G}catch{}this.#T(G,Z.duration)};this.#Q=Z,this.#j=_,this.#G=J,this.#q=Q,this.#N=j,this.#K=q,["play","pause","ended","timeupdate","loadedmetadata","durationchange","seeked","emptied"].forEach((N)=>Z.addEventListener(N,J)),_.addEventListener("play",Q),_.addEventListener("pause",j),_.addEventListener("seek",q),J()}#F(){let _=this.#Q,Z=this.#j;if(_&&this.#G)["play","pause","ended","timeupdate","loadedmetadata","durationchange","seeked","emptied"].forEach(($)=>_.removeEventListener($,this.#G));if(Z){if(this.#q)Z.removeEventListener("play",this.#q);if(this.#N)Z.removeEventListener("pause",this.#N);if(this.#K)Z.removeEventListener("seek",this.#K)}this.#Q=null,this.#j=null,this.#G=null,this.#q=null,this.#N=null,this.#K=null}#A(){this.#F(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((_)=>_.remove()),this.#$=null}play(){if(!this.#_||!this.#M())return;let _=this.#_.play?.();if(_&&typeof _.catch==="function")_.catch(()=>{})}pause(){this.#_?.pause?.()}toggle(){if(!this.#_||!this.#M())return;if(this.#_.paused||this.#_.ended)this.play();else this.pause()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="src")this.#Z=$||"";if(!this.isConnected)return;if(_==="controls")this.#B();if(["src","autoplay","muted","loop"].includes(_))this.#W(),this.#D()}}F("fig-audio",f_);var s=[".png",".jpg",".jpeg",".gif",".webp",".svg",".avif"],l=[".mp3",".wav",".aac",".m4a",".ogg",".flac"],j0=[".mp4",".webm",".mov",".m4v",".avi",".mkv",".ogv",".mpeg",".mpg",".3gp"];class x_ extends HTMLElement{static observedAttributes=["accepts","preview","label","disabled","multiple","variant","url","filename"];#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#q=null;#N=null;#K=null;#Y=!1;#X=null;#R=!1;get files(){return this.#j}get#U(){let _=this.getAttribute("filename");if(_)return _;let Z=this.getAttribute("url");if(!Z)return"";try{let J=new URL(Z,location.href).pathname.split("/").pop();return J?decodeURIComponent(J):Z}catch{return Z}}get value(){if(this.#j&&this.#j.length>0){if(this.#j.length===1)return this.#j[0].name;return`${this.#j.length} files`}return this.#U}get#W(){return this.getAttribute("accepts")||""}get#M(){return this.hasAttribute("preview")&&this.getAttribute("preview")!=="false"}get#B(){return this.getAttribute("preview")?.toLowerCase()==="large"}#O(_,Z){let $=_.toLowerCase();return Z.some((J)=>$.endsWith(J))}#L(_,Z,$){return this.#O(_.name,Z)||_.type.toLowerCase().startsWith($)}#T(){if(this.#j?.[0]){if(this.#L(this.#j[0],l,"audio/"))return"Upload audio";if(this.#L(this.#j[0],s,"image/"))return"Upload image"}if(this.#O(this.#U,l))return"Upload audio";if(this.#O(this.#U,s))return"Upload image";let _=this.#W.split(",").map((Z)=>Z.trim().toLowerCase()).filter(Boolean).map((Z)=>{if(Z.startsWith("audio/")||l.includes(Z))return"audio";if(Z.startsWith("image/")||s.includes(Z))return"image";return"file"});if(_.length>0&&_.every((Z)=>Z==="audio"))return"Upload audio";if(_.length>0&&_.every((Z)=>Z==="image"))return"Upload image";return"Upload file"}#D(){if(this.#j?.length)return this.#L(this.#j[0],s,"image/");return!!this.getAttribute("url")&&this.#O(this.#U,s)}#k(){if(this.#j?.length)return this.#L(this.#j[0],l,"audio/");return!!this.getAttribute("url")&&this.#O(this.#U,l)}#F(){let _=this.#j?.[0];if(_){if(this.#L(_,j0,"video/"))return"video";if(this.#L(_,s,"image/"))return"image";return null}if(this.#O(this.#U,j0))return"video";if(this.#O(this.#U,s))return"image";let Z=this.#W.split(",").map(($)=>$.trim().toLowerCase()).filter(Boolean).map(($)=>{if($.startsWith("video/")||j0.includes($))return"video";if($.startsWith("image/")||s.includes($))return"image";return null});if(Z.length>0&&Z.every(($)=>$===Z[0]))return Z[0];return null}#A(){if(this.#j&&this.#j.length>0){let _=Array.from(this.#j);if(this.#M&&_.every((Z)=>this.#L(Z,j0,"video/")))return"video";if(_.every((Z)=>this.#L(Z,l,"audio/")))return"sound";if(_.every((Z)=>this.#L(Z,s,"image/")))return"image"}if(this.#M&&this.#O(this.#U,j0))return"video";if(this.#O(this.#U,l))return"sound";if(this.#O(this.#U,s))return"image";return"upload"}connectedCallback(){this.#u(),this.addEventListener("dragover",this.#f),this.addEventListener("dragleave",this.#I),this.addEventListener("drop",this.#P)}disconnectedCallback(){this.#Z?.removeEventListener("change",this.#S),this.#J?.removeEventListener("click",this.#V),this.#w(),this.#E(),this.removeEventListener("dragover",this.#f),this.removeEventListener("dragleave",this.#I),this.removeEventListener("drop",this.#P)}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#R)return;this.#u()}clear(){if(this.#j=null,this.#Z)this.#Z.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#u(),this.#H({cleared:!0})}#H(_={}){let Z={files:this.#j,..._};this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0}))}#z(){this.#R=!0,this.removeAttribute("url"),this.removeAttribute("filename"),this.#R=!1}#S=()=>{if(this.#Z.files.length>0)this.#j=this.#Z.files,this.#z(),this.#u(),this.#H()};#V=(_)=>{_.stopPropagation(),this.clear()};#f=(_)=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(_.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#Q)this.#Q.dataset.prevText=this.#Q.textContent,this.#Q.textContent="Drop file"}};#I=()=>{if(this.removeAttribute("dragover"),this.#Q&&this.#Q.dataset.prevText!==void 0)this.#Q.textContent=this.#Q.dataset.prevText,delete this.#Q.dataset.prevText};#P=(_)=>{if(_.preventDefault(),this.removeAttribute("dragover"),this.#Q&&this.#Q.dataset.prevText!==void 0)this.#Q.textContent=this.#Q.dataset.prevText,delete this.#Q.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#W,$=Array.from(_.dataTransfer.files);if(Z){let Q=Z.split(",").map((j)=>j.trim().toLowerCase());$=$.filter((j)=>{let q="."+j.name.split(".").pop().toLowerCase(),N=j.type.toLowerCase();return Q.some((G)=>G===q||G===N||G.endsWith("/*")&&N.startsWith(G.slice(0,-1)))})}if(!this.hasAttribute("multiple")||this.getAttribute("multiple")==="false")$=$.slice(0,1);if($.length===0)return;let J=new DataTransfer;if($.forEach((Q)=>J.items.add(Q)),this.#j=J.files,this.#Z)this.#Z.files=J.files;this.#z(),this.#u(),this.#H()};#w(){if(!this.#G)return;URL.revokeObjectURL(this.#G),this.#G=null}#E(){if(this.#q?.pause(),this.#X)URL.revokeObjectURL(this.#X),this.#X=null;this.#q=null,this.#N=null,this.#K=null,this.#Y=!1}#x(_){this.#Y=_,this.#N?.setAttribute("name",_?"pause":"play"),this.#Q?.toggleAttribute("selected",_),this.#Q?.setAttribute("aria-label",_?"Pause audio":"Play audio")}#C(){if(!this.#q||!this.#K)return;let _=this.#q.duration,Z=this.#q.currentTime,$=Number.isFinite(_)&&_>0&&Number.isFinite(Z)?Math.max(0,Math.min(Z/_,1)):0;this.#K.setAttribute("progress",String($))}#v=(_)=>{if(_.preventDefault(),!this.#q||this.#Q?.hasAttribute("disabled"))return;if(this.#Y){this.#q.pause();return}let Z=this.#q.play();if(Z&&typeof Z.catch==="function")Z.catch(()=>this.#x(!1))};#h(){let _=document.createElement("audio");if(_.hidden=!0,_.preload="metadata",this.#j?.[0])this.#X=URL.createObjectURL(this.#j[0]),_.src=this.#X;else _.src=this.getAttribute("url")||"";_.addEventListener("play",()=>this.#x(!0)),_.addEventListener("pause",()=>this.#x(!1)),_.addEventListener("ended",()=>{this.#x(!1),this.#K?.setAttribute("progress","0")}),_.addEventListener("timeupdate",()=>this.#C()),_.addEventListener("durationchange",()=>this.#C()),this.#q=_,this.#K=document.createElement("fig-audio-waveform"),this.#K.className="fig-input-file-audio-waveform",this.#K.setAttribute("url",_.src),this.#K.setAttribute("polarization","3"),this.#K.setAttribute("progress","0"),this.#Q?.append(this.#K),this.#Q?.addEventListener("click",this.#v),this.#x(!1),this.append(_)}#m(){let _=document.createElement("fig-swatch"),Z=this.#j?.[0],$=Z?this.#G=URL.createObjectURL(Z):this.getAttribute("url")||"";return _.setAttribute("background",`url(${JSON.stringify($)})`),_.setAttribute("slot","prepend"),_}#y(_){let Z=document.createElement("fig-icon");Z.setAttribute("slot","prepend");let $=document.createElement("label");return $.textContent=String(_),Z.append($),Z}#b=(_)=>{if(_.target!==_.currentTarget){_.stopPropagation();return}_.stopPropagation();let $=_.currentTarget.file;if($){let J=new DataTransfer;J.items.add($),this.#j=J.files,this.#z(),this.#u(),this.#H();return}this.#j=null,this.#z(),this.#u(),this.#H({cleared:!0})};#g(_,Z){let $=document.createElement(_==="video"?"fig-video":"fig-image");$.setAttribute("upload",""),$.setAttribute("full",""),$.setAttribute("checkerboard","");let J=this.#j?.[0],Q=J?this.#G=URL.createObjectURL(J):this.getAttribute("url")||"";if(Q)$.setAttribute("src",Q);$.addEventListener("change",this.#b),this.append($);let j=$.querySelector(":scope > fig-preview > fig-input-file[data-generated]");if(Z)j?.setAttribute("disabled","");this.setAttribute("data-previewing","large")}#u(){let _=this.#W,Z=this.getAttribute("label"),$=Z?.trim()?Z:this.#T(),J=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Q=this.hasAttribute("multiple")&&this.getAttribute("multiple")!=="false",j=this.getAttribute("variant")||"property",q=this.#j&&this.#j.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename"),N=this.#M&&Q&&(this.#j?.length??0)>1,G=!N&&this.#M&&this.#D(),K=!N&&this.#M&&this.#k();this.#w(),this.#E(),this.replaceChildren(),this.#Z=null,this.#Q=null,this.#J=null,this.#$=null,this.removeAttribute("data-previewing");let X=this.#B&&!N?this.#F():null;if(X){this.#g(X,J);return}if(q){let Y=this.value,U=Q&&this.#j?.length?Array.from(this.#j,(H)=>H.name).join(", "):"",R=U?U:K?Y:_?`Accepts ${_.split(",").map((H)=>H.trim()).join(", ")}`:"";if(this.#Q=document.createElement("fig-button"),this.#Q.setAttribute("variant",j),j==="property")this.#Q.setAttribute("full","");if(this.#Q.className="fig-input-file-filename",J)this.#Q.setAttribute("disabled","");let O=N?this.#y(this.#j.length):G?this.#m():b(K?"play":this.#A());if(K)this.#N=O,O.setAttribute("slot","prepend"),this.#Q.append(O);else{let H=document.createElement("fig-truncate");H.setAttribute("position","middle"),H.setAttribute("tooltip","");let A=N?"Multiple files":Y,z=A.lastIndexOf(".");if(!N&&z>0)H.setAttribute("tail",A.slice(z));H.textContent=A,O.setAttribute("slot","prepend"),this.#Q.append(O,H)}if(!K){if(this.#Q.setAttribute("type","upload"),this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",this.#Z.disabled=J,_)this.#Z.setAttribute("accept",_);if(Q)this.#Z.setAttribute("multiple","");this.#Z.addEventListener("change",this.#S),this.#Q.appendChild(this.#Z)}if(R)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",R),this.#$.appendChild(this.#Q),this.appendChild(this.#$);else this.appendChild(this.#Q);let M=document.createElement("fig-tooltip");if(M.setAttribute("text","Remove"),this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#J.setAttribute("icon","true"),this.#J.setAttribute("aria-label","Remove"),this.#J.className="fig-input-file-clear",J)this.#J.setAttribute("disabled","");if(this.#J.replaceChildren(b("minus")),this.#J.addEventListener("click",this.#V),M.appendChild(this.#J),this.appendChild(M),K)this.#h()}else{let Y=_?`Accepts ${_.split(",").map((R)=>R.trim()).join(", ")}`:"";if(Y)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",Y);if(this.#Q=document.createElement("fig-button"),this.#Q.setAttribute("variant",j),j==="property")this.#Q.setAttribute("full","");this.#Q.setAttribute("type","upload"),this.#Q.textContent=$;let U=b("upload");if(U.setAttribute("slot","prepend"),this.#Q.prepend(U),J)this.#Q.setAttribute("disabled","");if(this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",this.#Z.disabled=J,_)this.#Z.setAttribute("accept",_);if(Q)this.#Z.setAttribute("multiple","");if(this.#Z.addEventListener("change",this.#S),this.#Q.appendChild(this.#Z),this.#$)this.#$.appendChild(this.#Q),this.appendChild(this.#$);else this.appendChild(this.#Q)}}}F("fig-input-file",x_);class h extends HTMLElement{#Z={x:0.42,y:0};#_={x:0.58,y:1};#J={stiffness:200,damping:15,mass:1,initialVelocity:0};#$="bezier";#Q=2;#j=null;#G=null;#q=null;#N=null;#K=null;#Y=null;#X=null;#R=null;#U=null;#W=null;#M=null;#B=0.8;#O=200;#L=200;#T=null;#D=null;#k=null;#F=null;#A=5;#H=10;#z=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","mode","precision","aspect-ratio","edit","presets","text"]}connectedCallback(){this.#Q=parseInt(this.getAttribute("precision")||"2"),p(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let _=this.#V();if(_)this.#$=_;let Z=this.getAttribute("value");if(Z)this.#x(Z);this.#f(),this.#W=this.#C(),this.#i(),this.#a()}disconnectedCallback(){if(this.#j=null,this.#F)this.#F.disconnect(),this.#F=null}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="aspect-ratio"){if(p(this,"--aspect-ratio",$),this.#G)this.#r(),this.#$0();return}if(_==="edit"||_==="presets"||_==="text"){if(this.isConnected)this.#i();return}if(_==="mode"){this.#f();let J=this.getAttribute("value");if(J)this.#x(J);if(this.#f(),this.#W=this.#C(),this.isConnected)this.#i();return}if(_==="value"&&$){let J=this.#$;if(this.#x($),this.#W=this.#C(),J!==this.#$&&this.#l())this.#i();else{if(this.#G)this.#$0();this.#U0(),this.#J0()}}if(_==="precision")this.#Q=parseInt($||"2")}get value(){if(this.#$==="spring"){let{stiffness:Z,damping:$,mass:J,initialVelocity:Q=0}=this.#J,j=Q?`, ${Q}`:"";return`spring(${Z}, ${$}, ${J}${j})`}let _=this.#Q;return`${this.#Z.x.toFixed(_)}, ${this.#Z.y.toFixed(_)}, ${this.#_.x.toFixed(_)}, ${this.#_.y.toFixed(_)}`}get cssValue(){if(this.#$==="spring"){let Z=this.#v(),$=20,J=Math.max(1,Math.floor(Z.length/20)),Q=[];for(let j=0;j<Z.length;j+=J)Q.push(Z[j].value.toFixed(3));if(Z.length>0)Q.push(Z[Z.length-1].value.toFixed(3));return`linear(${Q.join(", ")})`}let _=this.#Q;return`cubic-bezier(${this.#Z.x.toFixed(_)}, ${this.#Z.y.toFixed(_)}, ${this.#_.x.toFixed(_)}, ${this.#_.y.toFixed(_)})`}get preset(){return this.#W}set value(_){if(_&&typeof _==="object"){let Z=this.#P(_);if(!Z)throw TypeError("Invalid easing value or mode/type mismatch");let $=Z.type==="spring"?{type:"spring",...Z.spring}:{type:"bezier",x1:Z.bezier[0],y1:Z.bezier[1],x2:Z.bezier[2],y2:Z.bezier[3]};this.setAttribute("value",JSON.stringify($));return}this.setAttribute("value",_)}get spring(){if(this.#$!=="spring")return null;return{...this.#J,initialVelocity:this.#J.initialVelocity??0}}set spring(_){if(!_||typeof _!=="object")throw TypeError("spring must be an object");this.value={..._,type:"spring"}}#V(){let _=this.getAttribute("mode")?.trim().toLowerCase();return _==="bezier"||_==="spring"?_:null}#f(){let _=this.#V();if(_)this.#$=_}#I(_){let Z=this.#V();return!Z||_.type===Z}#P(_){if(!_||typeof _!=="object"||Array.isArray(_))return null;let Z=this.#V(),$=typeof _.type==="string"?_.type.trim().toLowerCase():null;if($&&$!=="bezier"&&$!=="spring")return null;if($&&Z&&$!==Z)return null;let J=$||Z;if(!J)return null;if(J==="spring"){let j={mass:Number(_.mass),stiffness:Number(_.stiffness),damping:Number(_.damping),initialVelocity:_.initialVelocity===void 0?0:Number(_.initialVelocity)};if(!Number.isFinite(j.mass)||j.mass<=0||!Number.isFinite(j.stiffness)||j.stiffness<=0||!Number.isFinite(j.damping)||j.damping<0||!Number.isFinite(j.initialVelocity))return null;return{type:J,spring:j}}let Q=[_.x1,_.y1,_.x2,_.y2].map(Number);if(Q.some((j)=>!Number.isFinite(j))||Q[0]<0||Q[0]>1||Q[2]<0||Q[2]>1)return null;return{type:J,bezier:Q}}#w(_){if(_.type==="spring")this.#$="spring",this.#J={..._.spring};else this.#$="bezier",[this.#Z.x,this.#Z.y,this.#_.x,this.#_.y]=_.bezier}#E(_){let Z=_.match(/^spring\(\s*(.*?)\s*\)$/i);if(!Z)return null;let $=Z[1].split(",").map((Q)=>Number(Q.trim()));if($.length!==3&&$.length!==4||$.some((Q)=>!Number.isFinite(Q)))return null;let J={stiffness:$[0],damping:$[1],mass:$[2],initialVelocity:$[3]??0};if(J.stiffness<=0||J.damping<0||J.mass<=0)return null;return J}#x(_){if(_&&typeof _==="object"){let Q=this.#P(_);if(!Q)return!1;return this.#w(Q),!0}if(typeof _!=="string")return!1;let Z=_.trim();if(Z.startsWith("{"))try{return this.#x(JSON.parse(Z))}catch{return!1}let $=this.#E(Z);if($&&this.#V()!=="bezier")return this.#$="spring",this.#J=$,!0;let J=Z.split(",").map((Q)=>parseFloat(Q.trim()));if(J.length>=4&&J.every((Q)=>!isNaN(Q))&&this.#V()!=="spring")return this.#$="bezier",this.#Z.x=J[0],this.#Z.y=J[1],this.#_.x=J[2],this.#_.y=J[3],!0;return!1}#C(){if(this.#$==="bezier"){for(let Z of h.PRESETS){if(Z.type!=="bezier"||!Z.value)continue;if(Math.abs(this.#Z.x-Z.value[0])<0.001&&Math.abs(this.#Z.y-Z.value[1])<0.001&&Math.abs(this.#_.x-Z.value[2])<0.001&&Math.abs(this.#_.y-Z.value[3])<0.001)return Z.name}return"Custom bezier"}for(let Z of h.PRESETS){if(Z.type!=="spring"||!Z.spring)continue;if(Math.abs(this.#J.stiffness-Z.spring.stiffness)<0.001&&Math.abs(this.#J.damping-Z.spring.damping)<0.001&&Math.abs(this.#J.mass-Z.spring.mass)<0.001&&Math.abs(this.#J.initialVelocity??0)<0.001)return Z.name}return"Custom spring"}#v(){let{stiffness:_,damping:Z,mass:$,initialVelocity:J=0}=this.#J,Q=0.004,j=5,q=[],N=0,G=J;for(let K=0;K<=5;K+=0.004){let X=-_*(N-1)-Z*G;if(G+=X/$*0.004,N+=G*0.004,q.push({t:K,value:N}),K>0.1&&Math.abs(N-1)<0.0005&&Math.abs(G)<0.0005)break}return q}static#h(_,Z=24){let{stiffness:$,damping:J,mass:Q,initialVelocity:j=0}=_,q=0.004,N=5,G=[],K=0,X=j;for(let W=0;W<=5;W+=0.004){let I=-$*(K-1)-J*X;if(X+=I/Q*0.004,K+=X*0.004,G.push({t:W,value:K}),W>0.1&&Math.abs(K-1)<0.001&&Math.abs(X)<0.001)break}let Y=G[G.length-1].t||1,U=1;for(let W of G)if(W.value>U)U=W.value;let R=0;for(let W of G)if(W.value<R)R=W.value;let O=Math.max(U-R,1),M=6,H=Z-M*2,A=Math.max(1,Math.floor(G.length/30)),z="";for(let W=0;W<G.length;W+=A){let I=M+G[W].t/Y*H,V=M+(1-(G[W].value-R)/O)*H;z+=(W===0?"M":"L")+I.toFixed(1)+","+V.toFixed(1)}return h.#g(z,Z,h.#b(Z))}static#m(_,Z,$,J,Q=24){let q=(Q-11)/2,N=48,G=[],K=(W,I,V,C,S)=>{let w=1-S;return w*w*w*W+3*w*w*S*I+3*w*S*S*V+S*S*S*C};for(let W=0;W<=48;W++){let I=W/48;G.push({x:K(0,_,$,1,I),y:K(0,Z,J,1,I)})}let X=1/0,Y=-1/0,U=1/0,R=-1/0;for(let W of G){if(W.x<X)X=W.x;if(W.x>Y)Y=W.x;if(W.y<U)U=W.y;if(W.y>R)R=W.y}let O=Math.max(Y-X,0.000001),M=Math.max(R-U,0.000001),H=(W)=>q+(W-X)/O*11,A=(W)=>q+(1-(W-U)/M)*11,z="";for(let W=0;W<G.length;W++){let I=H(G[W].x),V=A(G[W].y);z+=`${W===0?"M":"L"}${I.toFixed(1)},${V.toFixed(1)}`}return z}static#y(_=24){let $=(_-11)/2,J=3.6666666666666665;return Array.from({length:16},(Q,j)=>({x:$+j%4*3.6666666666666665,y:$+Math.floor(j/4)*3.6666666666666665}))}static#b(_=24){return h.#y(_).map(({x:Z,y:$})=>E("circle",{cx:Z,cy:$,r:0.5,fill:"var(--figma-color-icon-tertiary)"}))}static#g(_,Z=24,$=[]){return E("svg",{width:Z,height:Z,viewBox:`0 0 ${Z} ${Z}`,fill:"none"},[...$,E("path",{d:_,stroke:"currentColor","stroke-width":"1","stroke-linecap":"round",fill:"none"})])}static#u(_,Z,$,J,Q=24){return h.#g(h.#m(_,Z,$,J,Q),Q,h.#b(Q))}static curveIcon(_,Z,$,J,Q=24){let j=h.#m(_,Z,$,J,Q),q=h.#y(Q).map(({x:N,y:G})=>`<circle cx="${N}" cy="${G}" r="0.5" fill="var(--figma-color-icon-tertiary)"></circle>`).join("");return`<svg width="${Q}" height="${Q}" viewBox="0 0 ${Q} ${Q}" fill="none">${q}<path d="${j}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#l(){return this.getAttribute("edit")!=="false"}#t(){return this.getAttribute("presets")!=="false"}#d(){return this.getAttribute("text")!=="false"}#i(){if(this.classList.toggle("spring-mode",this.#$==="spring"),this.classList.toggle("bezier-mode",this.#$!=="spring"),this.#N0(),this.replaceChildren(...this.#G0()),this.#K0(),this.#G)this.#j0(),this.#r(),this.#$0();this.#J0(),this.#h0()}#o(){return["fig-select","fig-select-options","fig-select-option"].every((_)=>{let Z=customElements.get(_);return typeof Z==="function"&&Z.prototype instanceof HTMLElement})}#p(){let _=L("fig-dropdown",{className:"fig-easing-curve-select",label:"Easing preset",value:this.#W,full:!0}),Z=void 0,$=_;for(let J of h.PRESETS){if(!this.#I(J))continue;if(!this.#l()&&!J.value&&!J.spring)continue;if(J.group!==Z){if(Z=J.group,$=Z?L("optgroup",{label:Z}):_,$!==_)_.appendChild($)}$.appendChild(L("option",{value:J.name},J.name))}return _}#s(){if(!this.#o())return this.#p();let _=document.createElement("fig-select-options"),Z=void 0;for(let $ of h.PRESETS){if(!this.#I($))continue;if(!this.#l()&&!$.value&&!$.spring)continue;if($.group!==Z){if($.group)_.appendChild(L("fig-separator",{label:$.group}));Z=$.group}let J;if($.type==="spring"){let Q=$.spring||this.#J;J=h.#h(Q)}else{let Q=$.value||[this.#Z.x,this.#Z.y,this.#_.x,this.#_.y];J=h.#u(...Q)}_.appendChild(L("fig-select-option",{value:$.name,label:$.name},[L("span",{slot:"prepend"},J),L("span",{},$.name)]))}return L("fig-select",{className:"fig-easing-curve-select",label:"Easing preset",value:this.#W,full:!0},_)}#c(_,Z,$){let J=L("fig-handle",{size:"small",type:"minimal","aria-label":$});return E("foreignObject",{className:_,"data-handle":Z,width:"20",height:"20"},L("fig-tooltip",{text:this.#_0(Z)},J))}#e(_){if(!Number.isFinite(_))return"0";return String(Number(_.toFixed(this.#Q)))}#_0(_){if(this.#$==="spring"){if(_==="bounce")return`Bounce ${this.#e(this.#W0())}`;return`Duration ${Math.round(this.#B*100)}%`}let Z=_==="1"?this.#Z:this.#_;return`${_==="1"?"Start":"End"} ${this.#e(Z.x)}, ${this.#e(Z.y)}`}#Z0(){for(let[_,Z]of[[this.#Y,this.#$==="spring"?"bounce":"1"],[this.#X,this.#$==="spring"?"duration":"2"]]){let $=_?.querySelector("fig-tooltip");if($)$.text=this.#_0(Z)}}#n(_,Z){let $=_?.querySelector("fig-tooltip");if(!$)return;if(Z)$.setAttribute("show","true");else $.removeAttribute("show")}#G0(){let Z=this.#t()?this.#s():null;if(!this.#l())return Z?[Z]:[];let $=this.#d()?this.#$==="spring"?L("fig-input-number",{className:"fig-easing-curve-value-input",value:this.#W0().toFixed(2),min:"0",max:"1",step:"0.01",precision:"2","aria-label":"Spring bounce",full:!0}):L("fig-input-text",{className:"fig-easing-curve-value-input",value:this.value,full:!0}):null,J=[E("rect",{className:"fig-easing-curve-bounds",x:"0",y:"0",width:200,height:200})];if(this.#$==="spring")J.push(E("line",{className:"fig-easing-curve-target",x1:"0",y1:40,x2:200,y2:40}),E("path",{className:"fig-easing-curve-path"}),this.#c("fig-easing-curve-handle","bounce","Spring bounce handle"),this.#c("fig-easing-curve-handle fig-easing-curve-duration-bar","duration","Spring duration handle"));else J.push(E("line",{className:"fig-easing-curve-boundary","data-boundary":"top",x1:"0",y1:"0",x2:200,y2:"0"}),E("line",{className:"fig-easing-curve-boundary","data-boundary":"bottom",x1:"0",y1:200,x2:200,y2:200}),E("path",{className:"fig-easing-curve-path"}),E("line",{className:"fig-easing-curve-arm","data-arm":"1"}),E("line",{className:"fig-easing-curve-arm","data-arm":"2"}),this.#c("fig-easing-curve-handle","1","First easing control point"),this.#c("fig-easing-curve-handle","2","Second easing control point"));let Q=E("svg",{viewBox:"0 0 200 200",className:"fig-easing-curve-svg"},J);return[...Z?[Z]:[],L("div",{className:"fig-easing-curve-svg-container"},Q),...$?[$]:[]]}#q0(_,Z){let $=getComputedStyle(this).getPropertyValue(_).trim();if(!$)return Z;let J=Number.parseFloat($);return Number.isFinite(J)?J:Z}#N0(){this.#S=this.#q0("--easing-duration-bar-radius",this.#S)}#K0(){this.#G=this.querySelector(".fig-easing-curve-svg"),this.#q=this.querySelector(".fig-easing-curve-path"),this.#N=this.querySelector('[data-arm="1"]'),this.#K=this.querySelector('[data-arm="2"]'),this.#Y=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#X=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#R=this.querySelector(".fig-easing-curve-select"),this.#U=this.querySelector(".fig-easing-curve-value-input"),this.#M=this.querySelector(".fig-easing-curve-target"),this.#T=this.querySelector(".fig-easing-curve-bounds"),this.#D=this.querySelector('[data-boundary="top"]'),this.#k=this.querySelector('[data-boundary="bottom"]')}#j0(){let _=this.#Y?.querySelector("fig-handle"),Z=this.#X?.querySelector("fig-handle");if(_){let $=_.offsetWidth||this.#A*2,J=_.offsetHeight||this.#A*2;this.#A=Math.max($,J)/2,this.#Y.setAttribute("width",$),this.#Y.setAttribute("height",J)}if(Z){let $=Z.offsetWidth||this.#H,J=Z.offsetHeight||this.#z;if(this.#$==="spring")this.#H=$,this.#z=J;this.#X.setAttribute("width",$),this.#X.setAttribute("height",J)}}#a(){if(this.#F||!window.ResizeObserver)return;this.#F=new ResizeObserver(()=>{if(this.#r())this.#$0()}),this.#F.observe(this)}#r(){if(!this.#G)return!1;let _=this.#G.getBoundingClientRect(),Z=Math.max(1,Math.round(_.width||200)),$=Math.max(1,Math.round(_.height||200)),J=Z!==this.#O||$!==this.#L;return this.#O=Z,this.#L=$,this.#G.setAttribute("viewBox",`0 0 ${Z} ${$}`),J}#R0(){let _=Math.min(0,this.#Z.y,this.#_.y),Z=Math.max(1,this.#Z.y,this.#_.y),$=Z-_||1,J=0;return{minVal:_,maxVal:Z,range:$,pad:0,draw:Math.max(1,this.#L-0)}}#X0(_,Z){let{maxVal:$,range:J,pad:Q,draw:j}=this.#R0();return{x:_*this.#O,y:Q+($-Z)/J*j}}#I0(_,Z){let{maxVal:$,range:J,pad:Q,draw:j}=this.#R0();return{x:_/this.#O,y:$-(Z-Q)/j*J}}#H0={minVal:0,maxVal:1.2,totalTime:1};#Y0(_,Z){let J=this.#L-40,{minVal:Q,maxVal:j}=this.#H0,q=j-Q||1;return{x:_*this.#O,y:20+(1-(Z-Q)/q)*J}}#$0(){if(this.#r(),this.#$==="spring")this.#C0();else this.#V0();this.#Z0()}#F0(){this.#N?.classList.toggle("is-active",this.#$==="bezier"&&this.#j===1),this.#K?.classList.toggle("is-active",this.#$==="bezier"&&this.#j===2)}#V0(){if(this.#T)this.#T.setAttribute("x","0"),this.#T.setAttribute("y","0"),this.#T.setAttribute("width",this.#O),this.#T.setAttribute("height",this.#L);let _=this.#X0(0,0),Z=this.#X0(this.#Z.x,this.#Z.y),$=this.#X0(this.#_.x,this.#_.y),J=this.#X0(1,1);for(let[j,q]of[[this.#D,J.y],[this.#k,_.y]]){if(!j)continue;j.setAttribute("x1","0"),j.setAttribute("y1",q),j.setAttribute("x2",this.#O),j.setAttribute("y2",q)}this.#q.setAttribute("d",`M${_.x},${_.y} C${Z.x},${Z.y} ${$.x},${$.y} ${J.x},${J.y}`),this.#N.setAttribute("x1",_.x),this.#N.setAttribute("y1",_.y),this.#N.setAttribute("x2",Z.x),this.#N.setAttribute("y2",Z.y),this.#K.setAttribute("x1",J.x),this.#K.setAttribute("y1",J.y),this.#K.setAttribute("x2",$.x),this.#K.setAttribute("y2",$.y);let Q=this.#A;this.#Y.setAttribute("x",Z.x-Q),this.#Y.setAttribute("y",Z.y-Q),this.#X.setAttribute("x",$.x-Q),this.#X.setAttribute("y",$.y-Q),this.#P0()}#P0(){if(!this.#G||!this.#Y||!this.#X)return;let _=this.#Z.y>=this.#_.y?[this.#Y,this.#X]:[this.#X,this.#Y];for(let Z of _)this.#G.append(Z)}#C0(){if(this.#T)this.#T.setAttribute("x","0"),this.#T.setAttribute("y","0"),this.#T.setAttribute("width",this.#O),this.#T.setAttribute("height",this.#L);let _=this.#v();if(!_.length)return;let Z=_[_.length-1].t||1,$=0,J=1;for(let M of _){if(M.value<$)$=M.value;if(M.value>J)J=M.value}let Q=Math.max(Math.abs($-1),Math.abs(J-1),0.01),j=0;this.#H0={minVal:1-Q-j,maxVal:1+Q+j,totalTime:Z};let q=Math.max(0.05,Math.min(1,this.#B)),N="";for(let M=0;M<_.length;M++){let H=_[M].t/Z*q,A=this.#Y0(H,_[M].value);N+=(M===0?"M":"L")+A.x.toFixed(1)+","+A.y.toFixed(1)}let G=this.#Y0(q,1),K=this.#Y0(1,1);if(N+=`L${G.x.toFixed(1)},${G.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#q.setAttribute("d",N),this.#M){let M=this.#Y0(0,1),H=this.#Y0(1,1);this.#M.setAttribute("x1",M.x),this.#M.setAttribute("y1",M.y),this.#M.setAttribute("x2",H.x),this.#M.setAttribute("y2",H.y)}let X=this.#S0(_),Y=X.t/Z*q,U=this.#Y0(Y,X.value),R=this.#A;this.#Y.setAttribute("x",U.x-R),this.#Y.setAttribute("y",U.y-R);let O=this.#Y0(q,1);this.#X.setAttribute("x",O.x-this.#H/2),this.#X.setAttribute("y",O.y-this.#z/2)}#S0(_){let Z={t:0,value:1},$=!1;for(let J=1;J<_.length-1;J++){let Q=_[J-1],j=_[J],q=_[J+1];if(j.value>=0.99)$=!0;if($&&j.value>Z.value)Z={t:j.t,value:j.value};if($&&j.value>1&&j.value>=Q.value&&j.value>=q.value)return{t:j.t,value:j.value}}return Z}#U0(){if(!this.#R)return;this.#R.value=this.#W,this.#x0()}#J0(){if(!this.#U)return;let _=this.#$==="spring"?this.#W0().toFixed(2):this.value;this.#U.setAttribute("value",_)}#W0(){let{stiffness:_,damping:Z,mass:$}=this.#J,J=2*Math.sqrt(_*$);if(!Number.isFinite(J)||J<=0)return 0;return Math.max(0,Math.min(1,1-Z/J))}#L0(_){let Z=Math.max(0,Math.min(1,Number(_))),$=2*Math.sqrt(this.#J.stiffness*this.#J.mass);this.#J.damping=Number(($*(1-Z)).toFixed(4))}#A0(_,Z){let $=Number(_);if(!Number.isFinite($)){if(Z==="change")this.#J0();return}if(this.#L0($),this.#W=this.#C(),this.#$0(),this.#U0(),Z==="change")this.#J0();this.#Q0(Z)}#E0(_){let Z=_.split(",").map(($)=>Number.parseFloat($.trim()));if(Z.length!==4||Z.some(($)=>!Number.isFinite($)))return null;if(Z[0]<0||Z[0]>1||Z[2]<0||Z[2]>1)return null;return Z}#f0(_){return this.#E(_)}#z0(_,Z){let $=this.#V(),J=$==="bezier"?null:this.#f0(_),Q=$==="spring"?null:this.#E0(_);if(!J&&!Q){if(Z==="change")this.#J0();return}let j=this.#$;if(J)this.#$="spring",this.#J=J;else this.#$="bezier",this.#Z.x=Q[0],this.#Z.y=Q[1],this.#_.x=Q[2],this.#_.y=Q[3];if(this.#W=this.#C(),j!==this.#$)this.#i();else if(this.#$0(),this.#U0(),Z==="change")this.#J0();this.#Q0(Z)}#T0(_,Z){if(!this.#R)return;for(let $ of this.#R.querySelectorAll("fig-select-option"))if($.value===_){let J=$.querySelector(':scope > [slot="prepend"]');if(J)J.replaceChildren(Z.cloneNode(!0))}}#x0(){if(!this.#R)return;if(!this.#l())return;let _=h.#u(this.#Z.x,this.#Z.y,this.#_.x,this.#_.y),Z=h.#h(this.#J);this.#T0("Custom bezier",_),this.#T0("Custom spring",Z)}#k0(_){this.#$0(),this.#W=this.#C(),this.#U0(),this.#J0(),this.#Q0(_)}#w0(_,Z){let $=_.shiftKey?0.1:0.01,J=Z===1?this.#Z:this.#_;switch(_.key){case"ArrowLeft":J.x-=$;break;case"ArrowRight":J.x+=$;break;case"ArrowUp":J.y+=$;break;case"ArrowDown":J.y-=$;break;case"Home":J.x=0,J.y=0;break;case"End":J.x=1,J.y=1;break;default:return!1}return J.x=Math.max(0,Math.min(1,Math.round(J.x*100)/100)),J.y=Math.round(J.y*100)/100,this.#k0("input"),this.#Q0("change"),!0}#y0(_,Z){let $=_.shiftKey?10:1;if(Z==="bounce"){let J=$/100;switch(_.key){case"ArrowUp":this.#L0(this.#W0()+J);break;case"ArrowDown":this.#L0(this.#W0()-J);break;case"Home":this.#L0(0);break;case"End":this.#L0(1);break;default:return!1}}else{let J=$*2;switch(_.key){case"ArrowLeft":this.#B=Math.max(0.05,this.#B-J/200),this.#J.stiffness=Math.max(10,Math.round(this.#J.stiffness+J*1.5));break;case"ArrowRight":this.#B=Math.min(1,this.#B+J/200),this.#J.stiffness=Math.max(10,Math.round(this.#J.stiffness-J*1.5));break;case"Home":this.#B=0.05;break;case"End":this.#B=1;break;default:return!1}}return this.#k0("input"),this.#Q0("change"),!0}#O0(_,Z){let $=_?.querySelector("fig-handle");if(!$)return;$.addEventListener("pointerdown",(J)=>{if(J.preventDefault(),J.stopImmediatePropagation(),this.#$==="bezier")this.#M0(J,Number(Z));else this.#B0(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.#y0(J,Z)))return;J.preventDefault(),J.stopImmediatePropagation()},{capture:!0})}#Q0(_){let Z=this.spring;this.dispatchEvent(new CustomEvent(_,{bubbles:!0,detail:{mode:this.#$,value:this.value,cssValue:this.cssValue,preset:this.#W,...Z?{spring:Z}:{}}}))}#h0(){if(this.#G&&this.#$==="bezier"){this.#O0(this.#Y,"1"),this.#O0(this.#X,"2"),this.#Y.addEventListener("pointerdown",(Z)=>this.#M0(Z,1)),this.#X.addEventListener("pointerdown",(Z)=>this.#M0(Z,2));let _=this.querySelector(".fig-easing-curve-svg-container");if(_)_.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#M0(Z,this.#b0(Z))})}else if(this.#G){this.#O0(this.#Y,"bounce"),this.#O0(this.#X,"duration"),this.#Y.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#B0(Z,"bounce")}),this.#X.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#B0(Z,"duration")});let _=this.querySelector(".fig-easing-curve-svg-container");if(_)_.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#B0(Z,"duration")})}if(this.#R)this.#R.addEventListener("input",(_)=>{_.stopPropagation()}),this.#R.addEventListener("optionhover",(_)=>{_.stopPropagation()}),this.#R.addEventListener("change",(_)=>{_.stopPropagation();let Z=_.detail,$=h.PRESETS.find((J)=>J.name===Z);if(!$)return;if($.type==="bezier"){if($.value)this.#Z.x=$.value[0],this.#Z.y=$.value[1],this.#_.x=$.value[2],this.#_.y=$.value[3];if(this.#W=Z,this.#$!=="bezier")this.#$="bezier",this.#i();else if(this.#G)this.#$0(),this.#J0()}else if($.type==="spring"){if($.spring)this.#J={...$.spring,initialVelocity:0};if(this.#W=Z,this.#$!=="spring")this.#$="spring",this.#i();else if(this.#G)this.#$0(),this.#J0()}this.#Q0("input"),this.#Q0("change")});if(this.#U)this.#U.addEventListener("input",(_)=>{_.stopPropagation();let Z=_.detail??_.target?.value;if(this.#$==="spring")this.#A0(Z,"input");else if(typeof Z==="string")this.#z0(Z,"input")}),this.#U.addEventListener("change",(_)=>{_.stopPropagation();let Z=_.detail??_.target?.value;if(this.#$==="spring")this.#A0(Z,"change");else if(typeof Z==="string")this.#z0(Z,"change")})}#D0(_){let Z=this.#G.getScreenCTM();if(!Z)return{x:0,y:0};let $=Z.inverse();return{x:$.a*_.clientX+$.c*_.clientY+$.e,y:$.b*_.clientX+$.d*_.clientY+$.f}}#b0(_){return this.#D0(_).x<=this.#O/2?1:2}#M0(_,Z){_.preventDefault(),this.#j=Z,this.#F0();let $=Z===1?this.#Y:this.#X;this.#n($,!0);let J=this.#G.getBoundingClientRect(),Q=_.clientX,j=_.clientY,q=_.target?.closest?.(".fig-easing-curve-handle, fig-handle"),N=Z===1?this.#Z:this.#_,G=this.#D0(_),K=q?{...N}:this.#I0(G.x,G.y),{range:X,draw:Y}=this.#R0(),U=X/Math.max(1,Y/this.#L*Math.max(1,J.height)),R=(M)=>{if(!this.#j)return;let H={x:K.x+(M.clientX-Q)/Math.max(1,J.width),y:M.shiftKey?Z===1?0:1:K.y-(M.clientY-j)*U};if(H.x=Math.round(H.x*100)/100,H.y=Math.round(H.y*100)/100,H.x=Math.max(0,Math.min(1,H.x)),this.#j===1)this.#Z.x=H.x,this.#Z.y=H.y;else this.#_.x=H.x,this.#_.y=H.y;this.#$0(),this.#W=this.#C(),this.#U0(),this.#J0(),this.#Q0("input")},O=()=>{this.#j=null,this.#F0(),this.#n($,!1),document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",O),this.#Q0("change")};document.addEventListener("pointermove",R),document.addEventListener("pointerup",O)}#B0(_,Z){_.preventDefault(),this.#j=Z,this.classList.toggle("spring-bounce-dragging",Z==="bounce");let $=Z==="bounce"?this.#Y:this.#X;this.#n($,!0);let J=this.#W0(),Q=this.#J.stiffness,j=this.#B,q=_.clientY,N=_.clientX,G=(X)=>{if(!this.#j)return;if(Z==="bounce"){let Y=X.clientY-q;this.#L0(J-Y/200)}else{let Y=X.clientX-N;this.#B=Math.max(0.05,Math.min(1,j+Y/200)),this.#J.stiffness=Math.max(10,Math.round(Q-Y*1.5))}this.#$0(),this.#W=this.#C(),this.#U0(),this.#J0(),this.#Q0("input")},K=()=>{this.#j=null,this.classList.remove("spring-bounce-dragging"),this.#n($,!1),document.removeEventListener("pointermove",G),document.removeEventListener("pointerup",K),this.#Q0("change")};document.addEventListener("pointermove",G),document.addEventListener("pointerup",K)}}F("fig-easing-curve",h);class e extends HTMLElement{#Z=0;#_=0;#J="deg";#$=null;#Q=null;#j=null;#G=null;#q=null;#N=null;#K=null;#Y=null;#X=null;#R=null;#U=null;#W=!1;#M=!1;#B=(_)=>this.#n(_);#O=(_)=>this.#G0(_);#L=(_)=>this.#q0(_);#T=(_)=>this.#K0(_);#D=(_)=>this.#j0(_);#k=(_)=>this.#a(_);#F=()=>this.#e();static#A(_,Z=12,$=12,J=7,Q=3,j=0){let q=Number(_),N=Number(j),G=Number.isFinite(q)?q:0,K=Number.isFinite(N)?N:0,X=G-K,Y=X<0?"counterclockwise":"clockwise",U=Math.abs(X);if(U<0.001)return{direction:Y,arc:"",arrow:""};let R=(d)=>`${Number(d.x.toFixed(3))} ${Number(d.y.toFixed(3))}`,O=(d)=>{let J0=d*Math.PI/180;return{x:Z+Math.cos(J0)*J,y:$+Math.sin(J0)*J}},M=X>=0?1:-1,H=Y==="clockwise"?1:0,A=[`M ${R(O(K))}`],z=K,W=Math.floor(U/360);for(let d=0;d<W;d++)z+=M*180,A.push(`A ${J} ${J} 0 0 ${H} ${R(O(z))}`),z+=M*180,A.push(`A ${J} ${J} 0 0 ${H} ${R(O(z))}`);let I=U-W*360;if(I>=0.001)z+=M*I,A.push(`A ${J} ${J} 0 ${I>180?1:0} ${H} ${R(O(z))}`);let V=O(G),C=G*Math.PI/180,S=X>=0?{x:-Math.sin(C),y:Math.cos(C)}:{x:Math.sin(C),y:-Math.cos(C)},w={x:-S.y,y:S.x},f=Q/Math.SQRT2,c={x:V.x-S.x*f+w.x*f,y:V.y-S.y*f+w.y*f},r={x:V.x-S.x*f-w.x*f,y:V.y-S.y*f-w.y*f};return{direction:Y,arc:A.join(" "),arrow:`M ${R(c)} L ${R(V)} L ${R(r)}`}}static#H(_=0,Z=0){let $=e.#A(_,50,50,47,4,Z);return E("svg",{class:"fig-angle-reference",x:"3%",y:"3%",width:"94%",height:"94%",viewBox:"3 3 94 94",fill:"none",overflow:"visible","aria-hidden":"true","data-direction":$.direction},E("path",{class:"fig-angle-reference-path",d:[$.arc,$.arrow].filter(Boolean).join(" "),hidden:!$.arc,fill:"none",stroke:"currentColor","stroke-width":"var(--stroke-width)","stroke-linecap":"round","stroke-linejoin":"round"}))}static rotationIcon(_=0,Z=48){let $=Number.isFinite(Number(Z))?Math.max(1,Number(Z)):48,J=e.#A(_),Q=J.arc?`<path d="${J.arc} ${J.arrow}" fill="none" stroke="currentColor" stroke-width="var(--stroke-width, 1)" stroke-linecap="round" stroke-linejoin="round"></path>`:"";return`<svg width="${$}" height="${$}" viewBox="0 0 24 24" fill="none" data-direction="${J.direction}">${Q}</svg>`}static get observedAttributes(){return["value","default","precision","dial","min","max","step","units","rotations","disabled","aria-label","name"]}connectedCallback(){this.#z(),this.#i()}disconnectedCallback(){this.#N0(),this.#p()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#M)return;if(_==="value"){if(this.#W)return;let J=Number($);if(Number.isFinite(J))this.#s(J,{reflect:!1});return}if(_==="units"&&this.isConnected){let J=this.#m(this.#Z),Q=this.#J;this.#J=this.#V($),this.#f(Q,this.#J),this.#_=this.#S(),this.#s(this.#y(J)),this.#i();return}if(this.#z(),!this.isConnected)return;if(["dial","precision","min","max","step","units","rotations","disabled","aria-label","name"].includes(_)){this.#i();return}this.#s(this.#Z)}get value(){return this.#Z}set value(_){let Z=Number(_);if(!Number.isFinite(Z))return;this.#s(Z)}get defaultValue(){return this.#C()}set defaultValue(_){if(_===null||_===void 0||_===""){this.removeAttribute("default");return}let Z=Number(_);if(Number.isFinite(Z))this.setAttribute("default",String(Z))}get adjacent(){return Math.cos(this.#m(this.#Z)*Math.PI/180)}get opposite(){return Math.sin(this.#m(this.#Z)*Math.PI/180)}focus(_){this.#Q?.focus(_)}#z(){this.#J=this.#V(this.getAttribute("units")),this.#_=this.#S();let _=this.getAttribute("value"),Z=_===null||_.trim()===""?this.#C():Number(_);if(Number.isFinite(Z))this.#Z=this.#x(Z)}#S(){if(!this.hasAttribute("precision")){if(this.#J==="turn")return 3;if(this.#J==="rad")return 2;return 0}let _=Number.parseInt(this.getAttribute("precision"),10);return Number.isFinite(_)?Math.max(0,_):0}#V(_){let Z=String(_||"deg").trim().toLowerCase();if(Z==="°")return"°";return["deg","rad","turn","grad"].includes(Z)?Z:"deg"}#f(_,Z){if(_===Z)return;this.#M=!0;for(let $ of["min","max","default","step"]){let J=this.getAttribute($);if(J===null||J.trim()==="")continue;let Q=Number(J);if(!Number.isFinite(Q))continue;let j=this.#h(this.#v(Q,_),Z);this.setAttribute($,String(j))}this.#M=!1}#I(_,Z=!1){if(!this.hasAttribute(_))return Z;return this.getAttribute(_)?.toLowerCase()!=="false"}#P(){return T(this,"disabled")}#w(){let _=Number(this.getAttribute("min"));return this.hasAttribute("min")&&Number.isFinite(_)?_:null}#E(){let _=Number(this.getAttribute("max"));return this.hasAttribute("max")&&Number.isFinite(_)?_:null}#x(_){let Z=Number(_);if(!Number.isFinite(Z))return this.#Z;let $=this.#w(),J=this.#E();if($!==null)Z=Math.max($,Z);if(J!==null)Z=Math.min(J,Z);return Z}#C(_=this.getAttribute("default")){let Z=_===null||String(_).trim()===""?0:Number(_);return this.#x(Number.isFinite(Z)?Z:0)}#v(_,Z){switch(Z){case"rad":return _*180/Math.PI;case"turn":return _*360;case"grad":return _*0.9;default:return _}}#h(_,Z){switch(Z){case"rad":return _*Math.PI/180;case"turn":return _/360;case"grad":return _/0.9;default:return _}}#m(_){return this.#v(_,this.#J)}#y(_){return this.#h(_,this.#J)}#b(){return this.#J==="deg"?"°":this.#J}#g(){let _=this.#m(this.#Z),Z=_/360,$=Math.round(Z),J=Math.abs(Z-$)<0.0000000001?$:Math.trunc(Z),Q=_-J*360;return{rotations:J,remainder:this.#y(Math.abs(Q)<0.0000000001?0:Q)}}#u(){return this.#I("rotations")?this.#g().remainder:this.#Z}#l(){switch(this.#J){case"rad":return 0.01;case"turn":return 0.001;case"grad":return 0.1;default:return 1}}#t(){let _=Number(this.getAttribute("step"));return this.hasAttribute("step")&&Number.isFinite(_)&&_>0?_:this.#l()}#d(){return this.getAttribute("aria-label")||this.getAttribute("name")||"Angle"}#i(){this.#N0(),this.#p();let _=[],Z=this.#I("rotations")?L("span",{slot:"append",className:"fig-angle-rotations"},L("span",{className:"fig-angle-rotation-value"})):null,$=this.#I("dial",!0),J=L("fig-input-number",{className:"fig-angle-input",variant:$?"ghost":void 0,tabular:!0,name:"angle",value:this.#u(),min:this.#w(),max:this.#E(),step:this.#t(),precision:this.#_,units:this.#b(),disabled:this.#P(),"aria-label":this.#d()},Z);if($){let Q=L("fig-tooltip",{text:"Reset"},L("fig-button",{variant:"ghost",icon:"true",className:"fig-angle-reset",disabled:this.#P(),"aria-label":"Reset to default"},b("reset",{size:"small"}))),j=this.#w()??this.#y(0),q=this.#E()??this.#y(360),N=this.#P(),G=Array.from({length:24},(X,Y)=>{let U=Y*15,R=U*Math.PI/180,O=37,M=U%45===0?31:35;return E("line",{class:U%45===0?"fig-angle-tick fig-angle-tick-major":"fig-angle-tick",x1:50+Math.cos(R)*M,y1:50+Math.sin(R)*M,x2:50+Math.cos(R)*37,y2:50+Math.sin(R)*37})}),K=E("svg",{class:"fig-angle-svg",viewBox:"0 0 100 100",preserveAspectRatio:"xMidYMid meet",role:"slider",tabindex:N?"-1":"0","aria-label":this.#d(),"aria-valuemin":j,"aria-valuemax":q,"aria-disabled":N?"true":"false"},[E("rect",{class:"fig-angle-hit-area",x:"0",y:"0",width:"100",height:"100",fill:"transparent"}),E("circle",{class:"fig-angle-boundary",cx:"50",cy:"50",r:"47"}),...G,e.#H(this.#m(this.#Z),this.#m(this.#C())),E("line",{class:"fig-angle-indicator-halo",x1:"75",y1:"50",x2:"87",y2:"50"}),E("line",{class:"fig-angle-indicator",x1:"75",y1:"50",x2:"87",y2:"50"})]);_.push(L("div",{className:"fig-angle-surface"},[K,J,Q]))}else _.push(J);this.replaceChildren(..._),this.#$=this.querySelector(".fig-angle-surface"),this.#Q=this.querySelector(".fig-angle-svg"),this.#j=this.querySelector(".fig-angle-indicator"),this.#G=this.querySelector(".fig-angle-indicator-halo"),this.#q=this.querySelector(".fig-angle-reference"),this.#N=this.querySelector(".fig-angle-input"),this.#K=this.querySelector(".fig-angle-rotations"),this.#Y=this.querySelector(".fig-angle-reset"),this.#o(),this.#c()}#o(){this.#X=new AbortController;let _=this.#X.signal;this.#Q?.addEventListener("pointerdown",this.#B,{signal:_}),this.#Q?.addEventListener("pointermove",this.#O,{signal:_}),this.#Q?.addEventListener("pointerup",this.#L,{signal:_}),this.#Q?.addEventListener("pointercancel",this.#L,{signal:_}),this.#Q?.addEventListener("lostpointercapture",this.#L,{signal:_}),this.#Q?.addEventListener("keydown",this.#T,{signal:_}),this.#N?.addEventListener("input",this.#D,{signal:_}),this.#N?.addEventListener("change",this.#D,{signal:_}),this.#Y?.addEventListener("click",this.#F,{signal:_}),this.addEventListener("change",this.#k,{capture:!0,signal:_})}#p(){this.#X?.abort(),this.#X=null}#s(_,{reflect:Z=!0}={}){let $=this.#x(_);if(this.#Z=$,Z){let J=String($);if(this.getAttribute("value")!==J)this.#W=!0,this.setAttribute("value",J),this.#W=!1}this.#c()}#c(){let _=this.#m(this.#Z),$=`rotate(${(_%360+360)%360} 50 50)`;this.#j?.setAttribute("transform",$),this.#G?.setAttribute("transform",$);let J=this.#m(this.#C()),Q=e.#A(_,50,50,47,4,J);this.#q?.setAttribute("data-direction",Q.direction);let j=this.#q?.querySelector(".fig-angle-reference-path");if(j?.setAttribute("d",[Q.arc,Q.arrow].filter(Boolean).join(" ")),j?.toggleAttribute("hidden",!Q.arc),this.#Q){let q=this.#y(0),N=this.#y(360);this.#Q.setAttribute("aria-valuemin",String(this.#w()??Math.min(q,this.#Z))),this.#Q.setAttribute("aria-valuemax",String(this.#E()??Math.max(N,this.#Z))),this.#Q.setAttribute("aria-valuenow",String(this.#Z)),this.#Q.setAttribute("aria-valuetext",`${this.#Z.toFixed(this.#_)}${this.#b()}`)}if(this.#N){let q=this.#u().toFixed(this.#_);if(this.#N.getAttribute("value")!==q)this.#N.setAttribute("value",q)}if(this.#K){let{rotations:q}=this.#g(),N=this.#K.querySelector(".fig-angle-rotation-value");if(N)N.textContent=q?`×${q}`:"";this.#K.hidden=q===0}if(this.#Y)this.#Y.hidden=this.#Z===this.#C()}#e(){if(this.#P())return;this.#s(this.#C()),this.#r("input"),this.#r("change")}#_0(_){let Z=this.#$.getBoundingClientRect(),$=Z.left+Z.width/2,J=Z.top+Z.height/2,Q=_.clientX-$,j=_.clientY-J;if(Math.hypot(Q,j)<Math.min(Z.width,Z.height)*0.08)return null;let q=Math.atan2(j,Q)*180/Math.PI;if(q=(q%360+360)%360,_.shiftKey)q=Math.round(q/15)*15;return q}#Z0(_){let Z=this.#_0(_);if(Z===null)return;let $=this.#m(this.#Z),J;if(this.#U===null){let Q=($%360+360)%360;J=Z-Q}else J=Z-this.#U;if(J>180)J-=360;if(J<-180)J+=360;this.#U=Z,this.#s(this.#y($+J)),this.#r("input")}#n(_){if(this.#P()||_.button!==0)return;_.preventDefault(),this.#Q?.focus({preventScroll:!0}),this.#R=_.pointerId,this.#U=null,this.#$.classList.add("dragging");try{this.#Q.setPointerCapture?.(_.pointerId)}catch{}this.#Z0(_)}#G0(_){if(_.pointerId!==this.#R)return;if(_.buttons===0){this.#q0(_);return}this.#Z0(_)}#q0(_){if(_.pointerId!==this.#R)return;let Z=this.#R;if(this.#R=null,this.#U=null,this.#$?.classList.remove("dragging"),this.#Q?.hasPointerCapture?.(Z))this.#Q.releasePointerCapture(Z);this.#r("change")}#N0(){this.#R=null,this.#U=null,this.#$?.classList.remove("dragging")}#K0(_){if(this.#P())return;let Z=this.#Z,$=_.key==="ArrowLeft"||_.key==="ArrowDown"?-1:_.key==="ArrowRight"||_.key==="ArrowUp"?1:0;if($){let J=_.shiftKey?this.#y(15):this.#t();Z+=$*J}else if(_.key==="Home")Z=this.#w()??this.#y(0);else if(_.key==="End")Z=this.#E()??this.#y(360);else return;_.preventDefault(),_.stopPropagation(),this.#s(Z),this.#r("input"),this.#r("change")}#j0(_){if(_.stopPropagation(),this.#P())return;let Z=Number(_.currentTarget.value);if(!Number.isFinite(Z))return;if(this.#I("rotations")){let{rotations:$}=this.#g();this.#s(this.#y($*360+this.#m(Z)))}else this.#s(Z);this.#r(_.type)}#a(_){if(!_.target?.matches?.("input"))return;let Z=String(_.target.value).match(/^(-?\d*\.?\d+)\s*(deg|°|rad|turn|grad)$/i);if(!Z)return;let $=Number(Z[1]),J=this.#V(Z[2]),Q=$;if(J==="rad")Q=$*180/Math.PI;else if(J==="turn")Q=$*360;else if(J==="grad")Q=$*0.9;_.target.value=String(this.#y(Q))}#r(_){let Z=Number(this.value.toFixed(this.#_));this.dispatchEvent(new CustomEvent(_,{bubbles:!0,cancelable:!0,detail:{value:Z,angle:Z,units:this.#J}}))}}F("fig-angle",e);class w_ extends HTMLElement{#Z=0;#_=0;#J=0;#$=1;#Q=!1;#j=!1;#G=null;#q=null;#N=null;#K=null;#Y=(_)=>this.#P(_);#X=null;#R=[];#U={};#W={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#$=parseInt(this.getAttribute("precision")||"1"),p(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),p(this,"--perspective",this.getAttribute("perspective")),p(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#O(this.getAttribute("transform-origin")),this.#D(this.getAttribute("fields"));let _=this.getAttribute("value");if(_)this.#k(_);if(this.querySelector(".fig-3d-rotate-container"))this.#M();else this.#F();this.#T(this.getAttribute("selected")),this.#L()}disconnectedCallback(){this.#Q=!1,this.#B()}#M(){this.#q=this.querySelector(".fig-3d-rotate-container"),this.#G=this.querySelector(".fig-3d-rotate-cube"),this.#A(),this.#z(),this.#f()}#B(){if(this.#X?.abort(),this.#X=null,this.#N)window.removeEventListener("keydown",this.#N),window.removeEventListener("keyup",this.#K),this.#N=null,this.#K=null}#O(_){if(!_||!_.trim()){this.style.removeProperty("--transform-origin");return}let Z=_.trim().split(/\s+/);if(Z.length===2)this.style.setProperty("--transform-origin",`${Z[0]} ${Z[1]} -50cqi`);else this.style.setProperty("--transform-origin",_.trim())}#L(){if(!this.#q)return;this.#q.style.cursor=this.#I?"":"default"}#T(_){if(!this.#G)return;let Z=this.#G.querySelectorAll(".fig-3d-rotate-face"),$=_?_.trim().toLowerCase():"";for(let J of Z)J.classList.toggle("selected",$!==""&&J.classList.contains($))}#D(_){if(!_||!_.trim()){this.#R=[];return}let Z=["rotateX","rotateY","rotateZ"];this.#R=_.split(",").map(($)=>$.trim()).filter(($)=>Z.includes($))}attributeChangedCallback(_,Z,$){if(_==="aspect-ratio"){p(this,"--aspect-ratio",$);return}if(_==="perspective"){p(this,"--perspective",$);return}if(_==="perspective-origin"){p(this,"--perspective-origin",$);return}if(_==="transform-origin"){this.#O($);return}if(_==="selected"){this.#T($);return}if(_==="drag"){this.#L();return}if(_==="fields"){if(this.#D($),this.#G)this.#F();return}if(!this.#G)return;if(_==="value"&&$){if(this.#Q)return;this.#k($),this.#z(),this.#H()}if(_==="precision")this.#$=parseInt($||"1")}get value(){let _=this.#$;return`rotateX(${this.#Z.toFixed(_)}deg) rotateY(${this.#_.toFixed(_)}deg) rotateZ(${this.#J.toFixed(_)}deg)`}set value(_){this.setAttribute("value",_)}get rotateX(){return this.#Z}get rotateY(){return this.#_}get rotateZ(){return this.#J}#k(_){let Z=_.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),$=_.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),J=_.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if(Z)this.#Z=parseFloat(Z[1]);if($)this.#_=parseFloat($[1]);if(J)this.#J=parseFloat(J[1])}#F(){let _={rotateX:"X",rotateY:"Y",rotateZ:"Z"},Z={rotateX:this.#Z,rotateY:this.#_,rotateZ:this.#J},$=L("div",{className:"fig-3d-rotate-cube"},["front","back","right","left","top","bottom"].map((j)=>L("div",{className:`fig-3d-rotate-face ${j}`}))),J=L("div",{className:"fig-3d-rotate-container",tabindex:"0"},L("div",{className:"fig-3d-rotate-scene"},$)),Q=this.#R.map((j)=>L("fig-input-number",{name:j,step:"1",precision:"1",value:Z[j],units:"°"},L("span",{slot:"prepend"},_[j])));this.replaceChildren(J,...Q),this.#q=J,this.#G=$,this.#A(),this.#z(),this.#f()}#A(){this.#U={};for(let _ of this.#R){let Z=this.querySelector(`fig-input-number[name="${_}"]`);if(!Z)continue;if(this.#U[_]=Z,!this.#W[_])this.#W[_]=(J)=>{J.stopPropagation();let Q=parseFloat(J.target.value);if(isNaN(Q))return;if(_==="rotateX")this.#Z=Q;else if(_==="rotateY")this.#_=Q;else if(_==="rotateZ")this.#J=Q;this.#z(),this.#S(J.type)};let $=this.#W[_];Z.removeEventListener("input",$),Z.removeEventListener("change",$),Z.addEventListener("input",$),Z.addEventListener("change",$)}}#H(){let _={rotateX:this.#Z,rotateY:this.#_,rotateZ:this.#J};for(let Z of this.#R){let $=this.#U[Z];if($)$.setAttribute("value",_[Z].toFixed(this.#$))}}#z(){if(!this.#G)return;this.#G.style.transform=`rotateX(${this.#Z}deg) rotateY(${this.#_}deg) rotateZ(${this.#J}deg)`}#S(_){this.dispatchEvent(new CustomEvent(_,{bubbles:!0,detail:{value:this.value,rotateX:this.#Z,rotateY:this.#_,rotateZ:this.#J}}))}#V(_){if(!this.#j)return _;return Math.round(_/15)*15}#f(){if(this.#B(),!this.#q)return;this.#X=new AbortController,this.#q.addEventListener("pointerdown",this.#Y,{signal:this.#X.signal}),this.#N=(_)=>{if(_.key==="Shift")this.#j=!0},this.#K=(_)=>{if(_.key==="Shift")this.#j=!1},window.addEventListener("keydown",this.#N),window.addEventListener("keyup",this.#K)}get#I(){let _=this.getAttribute("drag");return _===null||_.toLowerCase()!=="false"}#P(_){if(!this.#I)return;_.preventDefault(),this.#Q=!0,this.#q.classList.add("dragging"),this.#q.setPointerCapture(_.pointerId);let{clientX:Z,clientY:$}=_,J=this.#Z,Q=this.#_,j=(N)=>{if(!this.#Q)return;if(N.buttons===0){q();return}let G=N.clientX-Z,K=N.clientY-$;this.#_=this.#V(Q+G*0.5),this.#Z=this.#V(J-K*0.5),this.#z(),this.#H(),this.setAttribute("value",this.value),this.#S("input")},q=()=>{if(!this.#Q)return;this.setAttribute("value",this.value),this.#Q=!1,this.#q.classList.remove("dragging"),this.#q.removeEventListener("pointermove",j),this.#q.removeEventListener("pointerup",q),this.#q.removeEventListener("pointercancel",q),this.#q.removeEventListener("lostpointercapture",q),this.#S("change")};this.#q.addEventListener("pointermove",j),this.#q.addEventListener("pointerup",q),this.#q.addEventListener("pointercancel",q),this.#q.addEventListener("lostpointercapture",q)}}F("fig-3d-rotate",w_);class P0 extends HTMLElement{#Z=50;#_=50;#J=0;#$=null;#Q=[];#j=null;#G=null;#q=null;#N=!1;#K=!1;#Y=null;#X=null;#R=null;static SNAP_POINTS=[0,16.6667,33.3333,50,66.6667,83.3333,100];static get observedAttributes(){return["value","precision","aspect-ratio","drag","fields"]}#U(){this.#$=this.querySelector(".origin-grid"),this.#Q=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#j=this.querySelector("fig-handle"),this.#G=this.querySelector('fig-input-number[name="x"]'),this.#q=this.querySelector('fig-input-number[name="y"]'),this.#z(),this.#S(),this.#F(),this.#g()}connectedCallback(){if(this.#J=parseInt(this.getAttribute("precision")||"0"),p(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#D(this.getAttribute("value")),this.querySelector(".fig-origin-grid-surface"))this.#U();else this.#k();this.#B(),this.#A()}disconnectedCallback(){this.#N=!1,this.#h(),this.#b()}get value(){let _=this.#J;return`${this.#Z.toFixed(_)}% ${this.#_.toFixed(_)}%`}set value(_){this.setAttribute("value",_)}attributeChangedCallback(_,Z,$){if(_==="aspect-ratio"){p(this,"--aspect-ratio",$);return}if(_==="drag"){this.#B();return}if(_==="fields"){this.#k(),this.#B(),this.#A();return}if(_==="precision"){this.#J=parseInt($||"0"),this.#F(),this.#A();return}if(_==="value"){if(this.#K||this.#N)return;this.#D($),this.#z(),this.#S(),this.#F()}}get#W(){let _=this.getAttribute("drag");return _===null||_.toLowerCase()!=="false"}get#M(){let _=this.getAttribute("fields");if(_===null)return!1;return _.toLowerCase()!=="false"}#B(){if(!this.#$)return;this.#$.classList.toggle("drag-disabled",!this.#W)}#O(_){return Math.max(0,Math.min(100,_))}#L(_,Z){let $=(_||"").trim().toLowerCase();if(!$)return Z==="x"?this.#Z:this.#_;let J=Z==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if($ in J)return J[$];let Q=Number.parseFloat($.replace("%",""));if(Number.isFinite(Q))return Q;return Z==="x"?this.#Z:this.#_}#T(_){let Z=_.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if(Z.length<1)return;if(Z.length===1){let $=this.#L(Z[0],"x");this.#Z=$,this.#_=$;return}this.#Z=this.#L(Z[0],"x"),this.#_=this.#L(Z[1],"y")}#D(_){let Z=typeof _==="string"?_.trim():"";if(!Z){this.#Z=50,this.#_=50;return}this.#T(Z)}#k(){let _=Array.from({length:9},(N,G)=>{let K=G%3,X=Math.floor(G/3);return L("span",{className:"origin-grid-cell","data-col":K,"data-row":X},L("span",{className:"origin-grid-dot"}))}),Z=this.#Z.toFixed(this.#J),$=this.#_.toFixed(this.#J),J=document.createElement("fig-handle"),Q=L("div",{className:"origin-grid","aria-label":"Transform origin grid"},[L("div",{className:"origin-grid-cells"},_),J]),q=[L("div",{className:"fig-origin-grid-surface"},Q)];if(this.#M){let N=(G,K)=>L("fig-input-number",{name:G,value:K,step:"1",units:"%"},L("span",{slot:"prepend"},G.toUpperCase()));q.push(L("div",{className:"origin-values"},[N("x",Z),N("y",$)]))}this.replaceChildren(...q),this.#$=Q,this.#Q=_,this.#j=J,this.#G=this.querySelector('fig-input-number[name="x"]'),this.#q=this.querySelector('fig-input-number[name="y"]'),this.#z(),this.#S(),this.#F(),this.#g()}#F(){let _=this.#Z.toFixed(this.#J),Z=this.#_.toFixed(this.#J);if(this.#G)this.#G.setAttribute("value",_);if(this.#q)this.#q.setAttribute("value",Z)}#A(){let _=this.value;if(this.getAttribute("value")===_)return;this.#K=!0,this.setAttribute("value",_),this.#K=!1}#H(_){this.dispatchEvent(new CustomEvent(_,{bubbles:!0,detail:{value:this.value,x:this.#Z,y:this.#_}}))}#z(){if(!this.#j)return;let _=(Z)=>16.6667+this.#O(Z)/100*66.6667;this.#j.style.left=`${_(this.#Z)}%`,this.#j.style.top=`${_(this.#_)}%`}#S(){if(!this.#j)return;let _=this.#Z<0||this.#Z>100,Z=this.#_<0||this.#_>100,$=this.#Z<0,J=this.#Z>100,Q=this.#_<0,j=this.#_>100;this.#j.classList.toggle("beyond-bounds-x",_),this.#j.classList.toggle("beyond-bounds-y",Z),this.#j.classList.toggle("overflow-left",$),this.#j.classList.toggle("overflow-right",J),this.#j.classList.toggle("overflow-up",Q),this.#j.classList.toggle("overflow-down",j)}#V(_,Z){if(!this.#$)return null;let $=this.#$.getBoundingClientRect(),J=(_-$.left)/Math.max($.width,1),Q=(Z-$.top)/Math.max($.height,1);if(J<0||J>1||Q<0||Q>1)return null;let j=Math.max(0,Math.min(2,Math.floor(J*3))),q=Math.max(0,Math.min(2,Math.floor(Q*3)));return this.#Q.find((N)=>Number(N.getAttribute("data-col"))===j&&Number(N.getAttribute("data-row"))===q)}#f(){for(let _ of this.#Q)_.classList.remove("is-hovered")}#I(_){if(this.#f(),_)_.classList.add("is-hovered")}#P(_,Z,$){let J=Number(_),Q=Number(Z);if(!Number.isFinite(J)||!Number.isFinite(Q))return;if(J===this.#Z&&Q===this.#_&&$==="input")return;this.#Z=J,this.#_=Q,this.#z(),this.#S(),this.#F(),this.#A(),this.#H($)}#w(_,Z){if(!this.#$)return{x:this.#Z,y:this.#_};let $=this.#$.getBoundingClientRect(),J=$.width/6,Q=$.height/6,j=Math.max(1,$.width-J*2),q=Math.max(1,$.height-Q*2),N=(_-($.left+J))/j,G=(Z-($.top+Q))/q;return{x:N*100,y:G*100}}#E(_,Z){if(!this.#$)return{x:50,y:50};let $=this.#$.getBoundingClientRect(),J=(_-$.left)/Math.max($.width,1)*3,Q=(Z-$.top)/Math.max($.height,1)*3,j=Math.max(0,Math.min(2,Math.floor(J))),q=Math.max(0,Math.min(2,Math.floor(Q)));return{x:j*50,y:q*50}}#x(_){let $=_,J=1/0;for(let Q of P0.SNAP_POINTS){let j=Math.abs(_-Q);if(j<J)J=j,$=Q}return J<=2.5?$:_}#C(_,Z){if(!Z)return _;return{x:this.#x(_.x),y:this.#x(_.y)}}#v(_){if(!this.#W)return!1;let Z=_.shiftKey?10:1,$=this.#Z,J=this.#_;switch(_.key){case"ArrowLeft":$-=Z;break;case"ArrowRight":$+=Z;break;case"ArrowUp":J-=Z;break;case"ArrowDown":J+=Z;break;case"Home":$=0,J=0;break;case"End":$=100,J=100;break;default:return!1}return this.#P(this.#O($),this.#O(J),"input"),this.#H("change"),!0}#h(){if(!this.#$||!this.#X||!this.#R)return;this.#$.removeEventListener("pointermove",this.#X),this.#$.removeEventListener("pointerup",this.#R),this.#$.removeEventListener("pointercancel",this.#R),this.#$.removeEventListener("lostpointercapture",this.#R),this.#X=null,this.#R=null}#m(_){if(!this.#$||!this.#W)return;_.preventDefault(),this.#N=!0,this.#Y=_.pointerId;let{clientX:Z,clientY:$}=_,J=3,Q=!1;this.#$.setPointerCapture(_.pointerId),this.#X=(j)=>{if(!this.#N||j.pointerId!==this.#Y)return;let q=j.clientX-Z,N=j.clientY-$,G=Math.hypot(q,N);if(!Q&&G<J)return;if(!Q)Q=!0,this.#$.classList.add("is-dragging"),this.#f();let K=this.#C(this.#w(j.clientX,j.clientY),j.shiftKey);this.#P(K.x,K.y,"input")},this.#R=(j)=>{if(!this.#N||j.pointerId!==this.#Y)return;if(this.#N=!1,this.#Y=null,this.#$.classList.remove("is-dragging"),this.#f(),this.#h(),!Q){let q=this.#E(Z,$);this.#P(q.x,q.y,"input")}this.#H("change")},this.#$.addEventListener("pointermove",this.#X),this.#$.addEventListener("pointerup",this.#R),this.#$.addEventListener("pointercancel",this.#R),this.#$.addEventListener("lostpointercapture",this.#R)}#y=null;#b(){this.#y?.abort(),this.#y=null}#g(){if(this.#b(),!this.#$||!this.#j)return;this.#y=new AbortController;let{signal:_}=this.#y;this.#$.addEventListener("pointerdown",($)=>{let J=this.#V($.clientX,$.clientY);if(this.#I(J),this.#W){this.#m($);return}let Q=this.#E($.clientX,$.clientY);this.#P(Q.x,Q.y,"input"),this.#H("change")},{signal:_}),this.#$.addEventListener("pointermove",($)=>{if(this.#N)return;let J=this.#V($.clientX,$.clientY);this.#I(J)},{signal:_}),this.#$.addEventListener("pointerleave",()=>{this.#f()},{signal:_}),this.#j.addEventListener("keydown",($)=>{if(!this.#v($))return;$.preventDefault(),$.stopPropagation()},{signal:_});let Z=($,J)=>{if(!$)return;let Q=(j)=>{let q=Number.parseFloat(j.target.value);if(!Number.isFinite(q))return;if(J==="x")this.#P(q,this.#_,"input");else this.#P(this.#Z,q,"input")};$.addEventListener("input",Q,{signal:_}),$.addEventListener("change",Q,{signal:_}),$.addEventListener("focusout",()=>{this.#H("change")},{signal:_})};Z(this.#G,"x"),Z(this.#q,"y")}}F("fig-origin-grid",P0);class y_ extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#q=null;#N=!1;#K={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=(_)=>this.#F(_),this.#_=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#J=(_)=>this.#A(_),this.#$=()=>this.#H(),this.#Q=(_)=>this.#L(_),this.#j=(_)=>this.#T(_),this.#G=()=>this.#D(),this.#q=()=>this.#D()}#X(){this.#B(),this.#V(),this.#I(),this.#P(),this.#Y=!0}connectedCallback(){u(this,()=>{if(this.precision=this.getAttribute("precision")||3,this.precision=parseInt(this.precision),this.transform=this.getAttribute("transform")||1,this.transform=Number(this.transform),this.coordinates=this.getAttribute("coordinates")||"screen",p(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");if(this.querySelector(".fig-input-joystick-plane")){this.#X();return}this.#W(),this.#B(),this.#V(),this.#I(),this.#P(),this.#Y=!0})}#R(_){return this.coordinates==="math"?1-_:_}disconnectedCallback(){this.#O()}get#U(){let _=this.getAttribute("fields");if(_===null)return!1;return _.toLowerCase()!=="false"}#W(){let _=this.#M(),Z=L("div",{className:"fig-input-joystick-plane-container"}),$=(q,N)=>N?L("label",{className:["fig-joystick-axis-label",q].join(" "),"aria-hidden":"true"},N):null;Z.append(...[$("left",_.left),$("right",_.right),$("top",_.top),$("bottom",_.bottom)].filter(Boolean));let J=L("div",{className:"fig-input-joystick-plane"},[L("div",{className:"fig-input-joystick-guides"}),L("fig-handle",{drag:!0,"drag-surface":".fig-input-joystick-plane","drag-axes":"x,y","drag-snapping":"modifier"})]),Q=L("fig-tooltip",{text:"Reset"},L("fig-button",{variant:"ghost",icon:"true",className:"fig-joystick-reset","aria-label":"Reset to default"},b("reset",{size:"small"})));Z.append(J,Q);let j=[Z];if(this.#U){let q=(N,G)=>L("fig-input-number",{name:N,step:"1",value:G,min:"0",max:"100",units:"%"},L("span",{slot:"prepend"},N.toUpperCase()));j.push(L("div",{className:"joystick-values"},[q("x",(this.position.x*100).toFixed(this.precision)),q("y",(this.position.y*100).toFixed(this.precision))]))}this.replaceChildren(...j)}#M(){let _=(this.getAttribute("axis-labels")||"").trim();if(!_)return{left:"",right:"",top:"",bottom:""};let Z=_.split(/[\s,]+/).filter(Boolean);if(Z.length===1)return{left:"",right:"",top:Z[0],bottom:""};if(Z.length===2){let[$,J]=Z;return{left:$,right:"",top:"",bottom:J}}if(Z.length===4){let[$,J,Q,j]=Z;return{left:$,right:J,top:Q,bottom:j}}return{left:"",right:"",top:"",bottom:""}}#B(){this.plane=this.querySelector(".fig-input-joystick-plane"),this.cursor=this.querySelector("fig-handle"),this.xInput=this.querySelector("fig-input-number[name='x']"),this.yInput=this.querySelector("fig-input-number[name='y']"),this.plane?.addEventListener("pointerdown",this.#Z),this.cursor?.addEventListener("pointerdown",this.#_),this.cursor?.addEventListener("input",this.#J),this.cursor?.addEventListener("change",this.#$);let _=this.querySelector(".fig-joystick-reset");if(_)_.addEventListener("click",()=>this.#w());if(this.#U&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#Q),this.xInput.addEventListener("change",this.#Q),this.xInput.addEventListener("focusout",this.#G),this.yInput.addEventListener("input",this.#j),this.yInput.addEventListener("change",this.#j),this.yInput.addEventListener("focusout",this.#q)}#O(){if(this.plane?.removeEventListener("pointerdown",this.#Z),this.cursor?.removeEventListener("pointerdown",this.#_),this.cursor?.removeEventListener("input",this.#J),this.cursor?.removeEventListener("change",this.#$),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#U&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#Q),this.xInput.removeEventListener("change",this.#Q),this.xInput.removeEventListener("focusout",this.#G),this.yInput.removeEventListener("input",this.#j),this.yInput.removeEventListener("change",this.#j),this.yInput.removeEventListener("focusout",this.#q)}#L(_){let Z=Number.parseFloat(_.target.value);if(!Number.isFinite(Z))return;this.position.x=Math.max(0,Math.min(1,Z/100)),this.#V(),this.#I(),this.#z()}#T(_){let Z=Number.parseFloat(_.target.value);if(!Number.isFinite(Z))return;this.position.y=Math.max(0,Math.min(1,Z/100)),this.#V(),this.#I(),this.#z()}#D(){this.#I(),this.#S()}#k(_,Z,{syncHandle:$=!0}={}){let J=Math.max(0,Math.min(1,_)),Q=Math.max(0,Math.min(1,Z)),j=this.coordinates==="math"?1-Q:Q;if(this.position={x:J,y:j},$)this.#V();this.#f(),this.#I()}#F(_){if(!this.plane||!this.cursor)return;if(_.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let Z=this.plane.getBoundingClientRect(),$=Z.width>0?(_.clientX-Z.left)/Z.width:0.5,J=Z.height>0?(_.clientY-Z.top)/Z.height:0.5;this.cursor.value=`${Math.round($*100)}% ${Math.round(J*100)}%`,this.#k($,J,{syncHandle:!1}),this.#z(),this.#S()}#A(_){let Z=_.detail??{};if(typeof Z.px!=="number"||typeof Z.py!=="number")return;this.#k(Z.px,Z.py,{syncHandle:!1}),this.#z()}#H(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#I(),this.#S()}#z(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#S(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#V(){let _=this.#R(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${_*100}%`;this.#f()}#f(){if(this.#U&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#I(){let _=this.value;if(this.getAttribute("value")!==_)this.#N=!0,this.setAttribute("value",_),this.#N=!1;this.#P()}#P(){let _=this.#K,Z=Math.round(this.position.x*100)===Math.round(_.x*100)&&Math.round(this.position.y*100)===Math.round(_.y*100);this.toggleAttribute("default",Z),this.style.setProperty("--is-not-default",Z?"0":"1")}#w(){this.position={...this.#K},this.#V(),this.#I(),this.#z(),this.#S()}focus(){this.cursor?.focus()}static get observedAttributes(){return["value","precision","transform","fields","coordinates","aspect-ratio","axis-labels"]}get value(){return`${Math.round(this.position.x*100)}% ${Math.round(this.position.y*100)}%`}set value(_){let Z=_==null?"":String(_).trim();if(!Z)this.position={x:0.5,y:0.5};else{let $=Z.split(/[\s,]+/).filter(Boolean),J=(q)=>{if(!q)return 0.5;let N=q.includes("%"),G=Number.parseFloat(q.replace(/%/g,"").trim());if(!Number.isFinite(G))return 0.5;let K=N||Math.abs(G)>1?G/100:G;return Math.max(0,Math.min(1,K))},Q=J($[0]),j=J($[1]??$[0]);this.position={x:Q,y:j}}if(this.#Y)this.#V(),this.#P()}attributeChangedCallback(_,Z,$){if(_==="aspect-ratio"){p(this,"--aspect-ratio",$);return}if(_==="value"){if(this.#N||this.isDragging)return;this.value=$}if(_==="precision")this.precision=parseInt($);if(_==="transform")this.transform=Number($);if(_==="fields"&&$!==Z)this.#O(),this.#W(),this.#B(),this.#V();if(_==="axis-labels"&&$!==Z)this.#O(),this.#W(),this.#B(),this.#V();if(_==="coordinates")this.coordinates=$||"screen",this.#V()}}F("fig-joystick",y_);class C0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let _=this.getAttribute("duration");if(_)this.style.setProperty(this.durationPropertyName,_);this.#Z()}static get observedAttributes(){return["duration","playing","aria-label","aria-labelledby"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(_){if(_)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(_,Z,$){if(_==="duration")this.style.setProperty(this.durationPropertyName,$||"1.5s");if(_==="playing"||_==="aria-label"||_==="aria-labelledby")this.#Z()}#Z(){let _=this.playing;if(this.setAttribute("aria-busy",_?"true":"false"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")){if(!this.hasAttribute("role"))this.setAttribute("role","status");this.removeAttribute("aria-hidden")}else this.removeAttribute("role"),this.setAttribute("aria-hidden","true")}}F("fig-shimmer",C0);class h_ extends C0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}F("fig-skeleton",h_);class b_ extends HTMLElement{static observedAttributes=["name","collapsible","open","compact","chevron"];#Z=null;#_=null;#J=null;#$=null;#Q=null;connectedCallback(){this.#X()}disconnectedCallback(){this.#j()}#j(){if(this.#_?.removeEventListener("click",this.#K),this.#J?.removeEventListener("click",this.#K),this.#J?.removeEventListener("keydown",this.#Y),this.#Z)this.#Z.removeEventListener("click",this.#K),this.#Z.removeEventListener("keydown",this.#Y)}attributeChangedCallback(_,Z,$){if(Z===$)return;if(!this.isConnected)return;if(_==="open"){this.#G();return}this.#X()}get open(){let _=this.getAttribute("open");return _!==null&&_!=="false"}set open(_){let Z=this.open;if(_)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#G(),Z!==!!_)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!_},bubbles:!0}))}#G(){if(this.hasAttribute("collapsible"))this.#J?.setAttribute("aria-expanded",String(this.open));else this.#J?.removeAttribute("aria-expanded")}#q(){if(!this.#$)return;if(this.#Q===null)this.#$.removeAttribute("compact");else this.#$.setAttribute("compact",this.#Q);this.#$=null,this.#Q=null}#N(){if(!(this.hasAttribute("compact")&&this.getAttribute("compact")!=="false")){this.#q();return}if(this.#$!==this.#Z)this.#q(),this.#$=this.#Z,this.#Q=this.#Z?.getAttribute("compact")??null;this.#Z?.setAttribute("compact","")}#K=(_)=>{_.stopPropagation(),this.open=!this.open};#Y=(_)=>{if(_.key!=="Enter"&&_.key!==" ")return;_.preventDefault(),_.stopPropagation(),this.open=!this.open};#X(){this.#j();let _=this.hasAttribute("collapsible"),$=this.getAttribute("name")||(_?"Group":null),J=this.querySelector(":scope > fig-header:not([data-generated])");if(!$&&!_&&!J){if(this.#Z&&this.#Z.dataset.generated)this.#q(),this.#Z.remove(),this.#Z=null,this.#_=null,this.#J=null;return}if(J)this.querySelectorAll(":scope > fig-header[data-generated]").forEach((j)=>j.remove()),this.#Z=J;else if(!this.#Z||!this.#Z.dataset.generated)this.#Z=document.createElement("fig-header"),this.#Z.setAttribute("borderless",""),this.#Z.dataset.generated="true",this.prepend(this.#Z);this.#N();let Q=this.#Z.querySelector("h3");if(!Q)Q=document.createElement("h3"),this.#Z.prepend(Q);if(this.#J=Q,!Q.id)Q.id=v();if(this.#Z.dataset.generated)Q.textContent=$;if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",Q.id);if(_){let j=this.#Z.querySelector(".fig-group-chevron");if(!j)j=b("chevron",{size:"small",className:"fig-group-chevron"});let q=this.getAttribute("chevron")==="end";if(j.setAttribute("size",q?"medium":"small"),q){if(Q.nextSibling!==j)this.#Z.insertBefore(j,Q.nextSibling)}else if(Q.previousSibling!==j)this.#Z.insertBefore(j,Q);if(this.#_=j,this.#Z.removeAttribute("role"),this.#Z.removeAttribute("tabindex"),this.#Z.removeAttribute("aria-expanded"),Q.setAttribute("role","button"),Q.setAttribute("tabindex","0"),Q.setAttribute("aria-expanded",String(this.open)),Q.addEventListener("click",this.#K),Q.addEventListener("keydown",this.#Y),j.addEventListener("click",this.#K),!this.hasAttribute("open"))this.setAttribute("open","false"),Q.setAttribute("aria-expanded","false")}else{if(Q.removeAttribute("role"),Q.removeAttribute("tabindex"),Q.removeAttribute("aria-expanded"),this.#Z.removeAttribute("role"),this.#Z.removeAttribute("tabindex"),this.#Z.removeAttribute("aria-expanded"),this.#_)this.#_.remove(),this.#_=null;this.removeAttribute("open")}}}F("fig-group",b_);class g_ extends HTMLElement{}F("fig-header",g_);class v_ extends HTMLElement{}F("fig-footer",v_);class m_ extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Loading")}}F("fig-spinner",m_);class p_ extends HTMLElement{static get observedAttributes(){return["fit","aspect-ratio"]}connectedCallback(){this.#Z(),this.#_()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="fit")this.#Z();if(_==="aspect-ratio")this.#_()}#Z(){let _=this.getAttribute("fit");if(_)this.style.setProperty("--fig-preview-fit",_);else this.style.removeProperty("--fig-preview-fit")}#_(){let _=this.getAttribute("aspect-ratio");if(_)this.style.setProperty("--fig-preview-aspect-ratio",_);else this.style.removeProperty("--fig-preview-aspect-ratio")}}F("fig-preview",p_);var B1={chevron:{medium:"--icon-24-chevron",small:"--icon-16-chevron"},checkmark:{medium:"--icon-24-checkmark",small:"--icon-16-checkmark"},reset:{medium:"--icon-24-reset",small:"--icon-16-reset"},"arrow-left":{medium:"--icon-24-arrow-left",small:"--icon-16-arrow-left"},steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",send:{medium:"--icon-24-send",small:"--icon-16-send"},adjust:{medium:"--icon-24-adjust",small:"--icon-16-adjust"},minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",download:"--icon-24-download",upload:"--icon-24-upload",image:"--icon-24-image",video:{medium:"--icon-24-video",small:"--icon-16-video"},sound:{medium:"--icon-24-sound",small:"--icon-16-sound"},"sound-off":{medium:"--icon-24-sound-off",small:"--icon-16-sound-off"},sun:"--icon-24-sun",moon:"--icon-24-moon",edit:{medium:"--icon-24-edit",small:"--icon-16-edit"},settings:{medium:"--icon-24-settings",small:"--icon-16-settings"},more:{medium:"--icon-24-more",small:"--icon-16-more"},visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"},globe:{medium:"--icon-24-globe",small:"--icon-16-globe"},warning:{medium:"--icon-24-warning",small:"--icon-16-warning"},copy:{medium:"--icon-24-copy",small:"--icon-16-copy"},trash:{medium:"--icon-24-trash",small:"--icon-16-trash"}};function H1(_,Z="medium"){let $=_&&B1[_];if(!$)return"";let J=typeof $==="string"?$:$[Z==="small"?"small":"medium"];return J?`var(${J})`:""}var F1={primary:"--figma-color-icon",secondary:"--figma-color-icon-secondary",tertiary:"--figma-color-icon-tertiary",disabled:"--figma-color-icon-disabled",brand:"--figma-color-icon-brand",component:"--figma-color-icon-component",danger:"--figma-color-icon-danger",success:"--figma-color-icon-success",warning:"--figma-color-icon-warning",selected:"--figma-color-icon-selected",hover:"--figma-color-icon-hover",pressed:"--figma-color-icon-pressed",onbrand:"--figma-color-icon-onbrand",oncomponent:"--figma-color-icon-oncomponent",ondanger:"--figma-color-icon-ondanger",ondisabled:"--figma-color-icon-ondisabled",oninverse:"--figma-color-icon-oninverse",onselected:"--figma-color-icon-onselected",onsuccess:"--figma-color-icon-onsuccess",onwarning:"--figma-color-icon-onwarning"};function A1(_){if(!_)return"";if(_.startsWith("var("))return _;let Z=F1[_.toLowerCase()];return Z?`var(${Z})`:_}class u_ extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#Z()}attributeChangedCallback(_,Z,$){if(Z!==$)this.#Z()}#Z(){let _=this.getAttribute("name"),Z=this.getAttribute("size")||"medium",$=H1(_,Z);if($)this.style.setProperty("--icon",$);else this.style.removeProperty("--icon");if(Z==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let J=A1(this.getAttribute("color"));if(J)this.style.backgroundColor=J,this.style.setProperty("--icon-color",J);else this.style.removeProperty("background-color"),this.style.removeProperty("--icon-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}F("fig-icon",u_);class c_ extends HTMLElement{}F("fig-content",c_);class d_ extends HTMLElement{}F("fig-tab-content",d_);class s_ extends HTMLElement{}F("fig-button-combo",s_);class i_ extends HTMLElement{}F("fig-input-combo",i_);class o_ extends HTMLElement{static get observedAttributes(){return["gap","columns","min-width"]}connectedCallback(){this.#Z()}attributeChangedCallback(){this.#Z()}#Z(){let _=this.getAttribute("gap")?.trim();this.#_("--fig-stack-gap",_&&/^(\d+(-5)?|half)$/.test(_)?`var(--spacer-${_})`:_);let Z=this.getAttribute("columns")?.trim();this.#_("--fig-stack-columns",Z&&/^\d+$/.test(Z)?`repeat(${Z}, minmax(0, 1fr))`:Z),this.#_("--fig-stack-min-width",this.getAttribute("min-width")?.trim())}#_(_,Z){if(Z)this.style.setProperty(_,Z);else this.style.removeProperty(_)}}F("fig-stack",o_);class r_ extends HTMLElement{#Z=null;#_=null;#J=null;#$=this.#O.bind(this);#Q=this.#L.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#j(){return this.getAttribute("control")||"color"}connectedCallback(){this.#K(),this.#W()}disconnectedCallback(){this.#G(),this.removeEventListener("click",this.#Y)}#G(){if(this.#Z)this.#Z.removeEventListener("input",this.#$),this.#Z.removeEventListener("change",this.#Q);if(this.#_)this.#_.removeEventListener("input",this.#$),this.#_.removeEventListener("change",this.#Q);if(this.#J)this.#J.disconnect(),this.#J=null}#q(){if(this.#J)this.#J.disconnect(),this.#J=null;if(!this.#_)return;this.#J=new MutationObserver(()=>{if(this.#_?.hasAttribute("selected")&&this.#_.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#J.observe(this.#_,{attributes:!0,attributeFilter:["selected"]})}get#N(){let _=this.getAttribute("alpha");return _===null||_!=="false"}#K(){this.#G();let _=this.#j;if(_==="add"||_==="remove"){let N=_==="add"?"add":"minus",G=this.getAttribute("aria-label")||(_==="add"?"Add color stop":"Remove color stop");this.replaceChildren(L("fig-button",{icon:!0,variant:"ghost","aria-label":G},b(N))),this.#Z=null,this.#_=null,this.addEventListener("click",this.#Y),this.#M();return}this.removeEventListener("click",this.#Y);let Z=(this.getAttribute("value")||"").trim(),$=this.#U(Z),J=this.#R(Z),Q=J<1?JSON.stringify({type:"solid",color:$,opacity:Math.round(J*100)}):JSON.stringify({type:"solid",color:$}),j=L("fig-swatch",{background:$,alpha:J<1?J:null}),q=null;if(t())q=L("fig-fill-picker",{mode:"solid",alpha:this.#N?null:"false",value:Q},j),this.replaceChildren(q);else this.replaceChildren(j);if(this.#Z=q,this.#_=j,this.#Z?.addEventListener("input",this.#$),this.#Z?.addEventListener("change",this.#Q),!this.#Z)this.#_?.addEventListener("input",this.#$),this.#_?.addEventListener("change",this.#Q);this.#q(),this.#M()}#Y=()=>{let _=this.#j;this.dispatchEvent(new CustomEvent(_,{bubbles:!0,composed:!0}))};#X(_){if(!_)return"#D9D9D9";let Z=_.replace("#","").trim();if(Z.length===3||Z.length===4){let[$,J,Q]=Z;return`#${$}${$}${J}${J}${Q}${Q}`.toUpperCase()}if(Z.length===6||Z.length===8)return`#${Z.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#R(_){if(!_)return 1;let Z=String(_).trim(),$=Z.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test($)){let Q=$[3];return parseInt(`${Q}${Q}`,16)/255}if(/^[0-9a-f]{8}$/i.test($))return parseInt($.slice(6,8),16)/255;let J=Z.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(J)return parseFloat(J[1]);return 1}#U(_){if(!_)return"#D9D9D9";let Z=String(_).trim();if(Z.startsWith("{"))try{let $=JSON.parse(Z);if($?.color)return this.#U($.color)}catch{}if(Z.startsWith("#"))return this.#X(Z);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Z))return this.#X(Z);try{let{ctx:$}=k0(1,1);$.fillStyle="#000000",$.fillStyle=Z;let J=$.fillStyle;if(J.startsWith("#"))return this.#X(J);let Q=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(Q){let j=(q)=>Math.max(0,Math.min(255,Number(q))).toString(16).padStart(2,"0");return`#${j(Q[1])}${j(Q[2])}${j(Q[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#W(){let _=this.getAttribute("value"),Z=this.#U(_),$=this.#R(_);if(_!==Z&&$>=1){this.setAttribute("value",Z);return}if(this.#Z){this.#M();let J=$<1?{type:"solid",color:Z,opacity:Math.round($*100)}:{type:"solid",color:Z};if(this.#Z.setAttribute("value",JSON.stringify(J)),this.#N)this.#Z.removeAttribute("alpha");else this.#Z.setAttribute("alpha","false");if(T(this,"disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}if(this.#_){if(this.#M(),this.#_.setAttribute("background",Z),$<1)this.#_.setAttribute("alpha",String($));else this.#_.removeAttribute("alpha");if(T(this,"disabled"))this.#_.setAttribute("disabled","");else this.#_.removeAttribute("disabled")}}#M(){let _=this.#j,Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",Z?"true":"false"),this.setAttribute("aria-pressed",$?"true":"false"),_==="add"||_==="remove"){let N=this.querySelector("fig-button"),G=this.getAttribute("aria-label")||(_==="add"?"Add color stop":"Remove color stop");if(N?.setAttribute("aria-label",G),Z)N?.setAttribute("disabled","");else N?.removeAttribute("disabled");return}let J=this.#Z||this.#_;if(!J)return;let Q=this.getAttribute("aria-label")||"Color stop",j=this.getAttribute("aria-labelledby"),q=this.getAttribute("aria-describedby");if(j)J.setAttribute("aria-labelledby",j),J.removeAttribute("aria-label");else J.setAttribute("aria-label",Q),J.removeAttribute("aria-labelledby");if(q)J.setAttribute("aria-describedby",q);else J.removeAttribute("aria-describedby")}#B(_,Z){let $=this.#U(_?.color),J=this.#U(this.getAttribute("value"));if($!==J)this.setAttribute("value",$);else this.#W();let Q={color:this.value};if(this.#N){if(_?.opacity!==void 0)Q.opacity=_.opacity;else if(_?.alpha!==void 0)Q.opacity=Math.round(_.alpha*100)}Object.assign(Q,a(Q.color,this.#N?_?.alpha:1,Q.opacity)),this.dispatchEvent(new CustomEvent(Z,{bubbles:!0,cancelable:!0,composed:!0,detail:Q}))}#O(_){_.stopPropagation(),this.#B(_.detail||{color:_.target?.value},"input")}#L(_){_.stopPropagation(),this.#B(_.detail||{color:_.target?.value},"change")}attributeChangedCallback(_,Z,$){if(Z===$)return;if(!this.isConnected)return;switch(_){case"control":this.#K();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#W(),this.#M();break}}get value(){return this.#U(this.getAttribute("value"))}set value(_){if(_===null||_===void 0||_===""){this.removeAttribute("value");return}this.setAttribute("value",this.#U(_))}get selected(){return T(this,"selected")}set selected(_){this.toggleAttribute("selected",Boolean(_))}get disabled(){return T(this,"disabled")}set disabled(_){this.toggleAttribute("disabled",Boolean(_))}}F("fig-color-tip",r_);class l_ extends HTMLElement{#Z=null;static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.#_(),T(this,"disabled"))this.setAttribute("aria-disabled","true")}disconnectedCallback(){this.#Z?.disconnect()}#_(){let _=T(this,"selected");this.setAttribute("aria-selected",_?"true":"false");for(let Z of this.children)Z.toggleAttribute("selected",_);if(this.#Z?.disconnect(),_&&this.isConnected)this.#Z??=new MutationObserver(()=>this.#_()),this.#Z.observe(this,{childList:!0})}attributeChangedCallback(_){if(_==="selected")this.#_();if(_==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}F("fig-choice",l_);class t_ extends HTMLElement{#Z=null;#_=this.#T.bind(this);#J=this.#D.bind(this);#$=this.#F.bind(this);#Q=null;#j=null;#G=null;#q=null;#N=null;#K=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop","auto-scroll"]}get#Y(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#X(){let _=this.getAttribute("drag");return _===null||_!=="false"}get autoScroll(){let _=this.getAttribute("auto-scroll");return _===null||_!=="false"}set autoScroll(_){if(_===!1||_==="false"||_===null)this.setAttribute("auto-scroll","false");else this.removeAttribute("auto-scroll")}get scrollBehavior(){return this.getAttribute("scroll-behavior")==="auto"?"auto":"smooth"}set scrollBehavior(_){if(_==="auto"||_==="smooth")this.setAttribute("scroll-behavior",_);else this.removeAttribute("scroll-behavior")}get#R(){return this.getAttribute("choice-element")||"fig-choice"}#U(){let _=this.getAttribute("columns"),Z=_===null?NaN:Number(_);if(Number.isInteger(Z)&&Z>0)this.style.setProperty("--fig-chooser-grid-columns",String(Z));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from(this.querySelectorAll(`:scope > ${this.#R}`))}get selectedChoice(){return this.#Z}set selectedChoice(_){if(_&&!this.contains(_))return;let Z=this.choices;for(let J of Z){let Q=J===_,j=T(J,"selected");if(Q&&!j)J.setAttribute("selected","");else if(!Q&&j)J.removeAttribute("selected")}this.#Z=_??null;let $=_?.getAttribute("value")??"";if(this.getAttribute("value")!==$)this.setAttribute("value",$);if(this.autoScroll)this.#x(_)}get value(){return this.#Z?.getAttribute("value")??""}set value(_){if(_===null||_===void 0||_===""){this.setAttribute("value","");return}this.setAttribute("value",String(_))}scrollSelectionIntoView(_={}){if(!this.#Z)return;this.#x(this.#Z,_)}connectedCallback(){if(this.setAttribute("role","listbox"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.#S(),this.addEventListener("click",this.#_),this.addEventListener("keydown",this.#J),this.addEventListener("scroll",this.#$),this.#V(),this.#H(),this.#v(),this.#A(),this.#B(),u(this,()=>{this.#M(),this.#F(),this.#W()})}#W(){requestAnimationFrame(()=>{if(!this.isConnected||!this.autoScroll)return;if(this.#Z)this.#x(this.#Z)})}disconnectedCallback(){this.removeEventListener("click",this.#_),this.removeEventListener("keydown",this.#J),this.removeEventListener("scroll",this.#$),this.#z(),this.#Q?.disconnect(),this.#Q=null,this.#j?.disconnect(),this.#j=null,this.#f()}attributeChangedCallback(_,Z,$){if(_==="value"&&$!==Z)if($==="")this.selectedChoice=null;else if($==null)this.#M();else this.#O($);if(_==="disabled")this.#B();if(_==="choice-element")requestAnimationFrame(()=>{this.#U(),this.#M()});if(_==="columns")this.#U(),this.#E();if(_==="drag")if(this.#X)this.#H();else this.#z();if(_==="overflow")this.#V(),requestAnimationFrame(()=>this.#F());if(_==="layout"){if(this.#U(),this.#V(),$==="horizontal")this.scrollTop=0;else this.scrollLeft=0;this.#E()}if(_==="auto-scroll"&&this.autoScroll)this.#E()}#M(){let _=this.choices;if(!_.length){this.#Z=null;return}let Z=this.hasAttribute("value"),$=this.getAttribute("value");if(Z&&$===""){this.selectedChoice=null;return}if($&&this.#O($))return;let J=_.find((Q)=>T(Q,"selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=_[0]}#B(){let _=T(this,"disabled");if(_)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Z of this.choices)if(_||T(Z,"disabled"))Z.setAttribute("aria-disabled","true"),Z.setAttribute("tabindex","-1");else Z.removeAttribute("aria-disabled"),Z.setAttribute("tabindex","0")}#O(_){let Z=this.choices;for(let $ of Z)if($.getAttribute("value")===_)return this.selectedChoice=$,!0;return!1}#L(_){let Z=this.#R,$=_;while($&&$!==this){if($.matches(Z))return $;$=$.parentElement}return null}#T(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#L(_.target);if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.selectedChoice=Z,this.#k()}#D(_){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!Z.length)return;let $=this.#L(_.target),J=Z.indexOf($),Q=J,j=this.hasAttribute("loop");switch(_.key){case"ArrowDown":case"ArrowRight":if(_.preventDefault(),J<Z.length-1)Q=J+1;else if(j)Q=0;break;case"ArrowUp":case"ArrowLeft":if(_.preventDefault(),J>0)Q=J-1;else if(j)Q=Z.length-1;break;case"Home":_.preventDefault(),Q=0;break;case"End":_.preventDefault(),Q=Z.length-1;break;case"Enter":case" ":if(_.preventDefault(),$&&$!==this.#Z)this.selectedChoice=$,this.#k();return;default:return}if(Q!==J&&Z[Q]){let q=Z[Q];if(q.focus({preventScroll:!0}),this.autoScroll)this.#x(q)}}#k(){let _=this.value;this.dispatchEvent(new CustomEvent("input",{detail:_,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:_,bubbles:!0}))}#F(){if(this.#Y==="scrollbar")return;let _=this.getAttribute("layout")==="horizontal";L0(this,this,_?"x":"y")}#A(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#F(),this.#E()}),this.#j.observe(this)}#H(){if(this.#N?.bound)return;if(!this.#X)return;let _=(q)=>{if(q.button!==0)return;if(q.target.closest("[data-fig-chooser-nav]"))return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#N.active=!0,this.#N.didDrag=!1,this.#N.startX=q.clientX,this.#N.startY=q.clientY,this.#N.scrollLeft=this.scrollLeft,this.#N.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Z=(q)=>{if(!this.#N.active)return;let N=this.getAttribute("layout")==="horizontal",G=q.clientX-this.#N.startX,K=q.clientY-this.#N.startY;if(!this.#N.didDrag&&Math.abs(N?G:K)>3)this.#N.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(q.pointerId);if(!this.#N.didDrag)return;if(N)this.scrollLeft=this.#N.scrollLeft-G;else this.scrollTop=this.#N.scrollTop-K},$=(q)=>{if(!this.#N.active)return;let N=this.#N.didDrag;if(this.#N.active=!1,this.#N.didDrag=!1,this.style.cursor="",this.style.userSelect="",q.pointerId!==void 0)try{this.releasePointerCapture(q.pointerId)}catch{}if(N)q.preventDefault(),q.stopPropagation()},J=(q)=>{if(this.#N?.suppressClick)q.stopPropagation(),q.preventDefault(),this.#N.suppressClick=!1},Q=(q)=>{if(this.#N?.didDrag)this.#N.suppressClick=!0,setTimeout(()=>{if(this.#N)this.#N.suppressClick=!1},0)},j=(q)=>{if(this.#N?.active)q.preventDefault()};this.#N={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:_,onPointerMove:Z,onPointerUp:$,onClick:J,onPointerUpCapture:Q,onDragStart:j},this.addEventListener("pointerdown",_),window.addEventListener("pointermove",Z),window.addEventListener("pointerup",$),this.addEventListener("pointerup",Q,!0),this.addEventListener("click",J,!0),this.addEventListener("dragstart",j)}#z(){if(!this.#N?.bound)return;this.removeEventListener("pointerdown",this.#N.onPointerDown),window.removeEventListener("pointermove",this.#N.onPointerMove),window.removeEventListener("pointerup",this.#N.onPointerUp),this.removeEventListener("pointerup",this.#N.onPointerUpCapture,!0),this.removeEventListener("click",this.#N.onClick,!0),this.removeEventListener("dragstart",this.#N.onDragStart),this.style.cursor="",this.style.userSelect="",this.#N=null}#S(){if(this.#K)return;let _=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!_)return;this.#K=!0;try{let Z=Array.from(_.childNodes);_.replaceWith(...Z)}finally{this.#K=!1}}#V(){let _=this.#Y==="scrollbar",Z=this.getAttribute("layout")==="grid";if(_||Z)this.#f(),this.classList.toggle("fig-overflow-fade",_),this.classList.toggle("fig-overflow-fade-horizontal",_&&this.getAttribute("layout")==="horizontal");else this.#I(),this.classList.remove("fig-overflow-fade","fig-overflow-fade-horizontal")}#f(){this.#G?.remove(),this.#q?.remove(),this.#G=null,this.#q=null,this.classList.remove("overflow-start","overflow-end")}#I(){if(this.#G&&this.#q&&this.contains(this.#G)&&this.contains(this.#q)){this.#P();return}this.#G?.remove(),this.#q?.remove(),this.#G=null,this.#q=null;let _=W0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#w(-1),onEnd:()=>this.#w(1)});this.#G=_.start,this.#q=_.end,this.#P()}#P(){if(this.firstElementChild!==this.#G)this.prepend(this.#G);if(this.lastElementChild!==this.#q)this.append(this.#q)}#w(_){let Z=this.getAttribute("layout")==="horizontal";Z0(this,Z?"x":"y",_,"auto")}#E(){if(!this.autoScroll||!this.#Z)return;this.#x(this.#Z)}#x(_,Z={}){if(!_)return;let $=typeof Z==="object"&&Z!==null?Z:{},J=$.behavior==="smooth"||$.behavior==="instant"?$.behavior:"auto",Q=$.block||"center",j=$.inline||"center";requestAnimationFrame(()=>{if(!_.isConnected)return;let q=this.scrollHeight>this.clientHeight,N=this.scrollWidth>this.clientWidth;if(!N&&!q)return;let G=_.getBoundingClientRect(),K=this.getBoundingClientRect(),X={behavior:J},Y=!1;if(q){let U=G.top-K.top+this.scrollTop,R=this.scrollHeight-this.clientHeight;X.top=this.#C(U,G.height,this.clientHeight,this.scrollTop,R,Q),Y=!0}if(N){let U=G.left-K.left+this.scrollLeft,R=this.scrollWidth-this.clientWidth;X.left=this.#C(U,G.width,this.clientWidth,this.scrollLeft,R,j),Y=!0}if(Y)this.scrollTo(X);this.#F()})}#C(_,Z,$,J,Q,j){let q;if(j==="start")q=_;else if(j==="end")q=_+Z-$;else if(j==="nearest"){let N=J,G=J+$,K=_+Z;if(_>=N&&K<=G)q=J;else if(_<N)q=_;else q=K-$}else q=_+Z/2-$/2;return Math.max(0,Math.min(q,Q))}#v(){this.#Q?.disconnect(),this.#Q=new MutationObserver(()=>{if(this.#K)return;this.#S(),this.#U(),this.#V(),this.#B();let _=this.choices;if(this.#Z&&!_.includes(this.#Z))this.#Z=null,this.#M();else if(!this.#Z&&_.length)this.#M();requestAnimationFrame(()=>this.#F())}),this.#Q.observe(this,{childList:!0,subtree:!1})}}F("fig-chooser",t_);class a_ extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","precision","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#Z=!1;#_=!1;#J=null;#$=null;#Q=!1;#j=null;#G=null;#q=null;#N=null;get#K(){let _=(this.getAttribute("tip")||"").trim().toLowerCase();return _==="color"||_==="add"||_==="remove"?_:null}get#Y(){return!this.hasAttribute("data-no-color-picker")}get#X(){let _=this.getAttribute("drag");return _!==null&&_!=="false"}get#R(){let _=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:_.includes("x"),y:_.includes("y")}}get#U(){let _=this.getAttribute("drag-snapping");if(_===null)return"false";let Z=_.trim().toLowerCase();if(Z==="modifier")return"modifier";if(Z===""||Z==="true")return"true";return"false"}#W(_){let Z=this.#U;if(Z==="true")return!0;if(Z==="modifier")return!!_;return!1}#M(_){if(_<0.1)return 0;if(_>0.9)return 1;if(_>0.4&&_<0.6)return 0.5;return _}#B(_,Z){if(Math.abs(_-Z)<0.1){let J=(_+Z)/2;return{x:J,y:J}}if(Math.abs(1-_-Z)<0.1)return{x:_,y:1-_};return{x:_,y:Z}}#O(){let _=this.getAttribute("drag-surface");if(!_||_==="parent")return this.parentElement;return this.closest(_)}get value(){let _=this.#O();if(!_)return"0% 0%";let{px:Z,py:$}=this.#r(_.getBoundingClientRect());return`${(Z*100).toFixed(this.precision)}% ${($*100).toFixed(this.precision)}%`}set value(_){this.setAttribute("value",_??"0% 0%")}get precision(){let _=Number(this.getAttribute("precision")??2);if(!Number.isFinite(_))return 2;return Math.max(0,Math.min(10,Math.trunc(_)))}set precision(_){if(_===null||_===void 0||_==="")this.removeAttribute("precision");else{let Z=Number(_),$=Number.isFinite(Z)?Math.max(0,Math.min(10,Math.trunc(Z))):2;this.setAttribute("precision",String($))}}#L(_){let Z=10**this.precision,$=Math.round(_*Z)/Z;return Object.is($,-0)?0:$}#T(_){let Z=_==null?"":String(_).trim();if(!Z)return{xPct:0,yPct:0};let $=Z.split(/[\s,]+/).filter(Boolean),J=(q)=>{if(!q)return 0;let N=q.includes("px"),G=q.includes("%"),K=parseFloat(q.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(N)return{px:K};if(G||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},Q=J($[0]),j=J($[1]??$[0]);return{xToken:Q,yToken:j}}#D(_){let Z=this.#O();if(!Z)return;let{xToken:$,yToken:J}=this.#T(_),Q=Z.getBoundingClientRect(),j=(G,K)=>{if(G&&typeof G==="object"&&"px"in G)return Math.max(0,Math.min(K,G.px));return null},q=(G)=>{let K=typeof G==="number"?G:0;return`${this.#L(K)}%`},N=this.#R;if(this.#k(N),N.x){let G=j($,Q.width);this.style.left=G===null?q($):`${this.#L(G)}px`}if(N.y){let G=j(J,Q.height);this.style.top=G===null?q(J):`${this.#L(G)}px`}}#k(_=this.#R){this.style.setProperty("--fig-handle-position-translate",`${_.x?"-50%":"0"} ${_.y?"-50%":"0"}`)}#F(){this.#Q=!0,this.setAttribute("value",this.value),this.#Q=!1}get#A(){return this.getAttribute("hit-area-mode")||"handle"}#H(){let _=this.getAttribute("hit-area");if(!_)return null;let Z=_.trim().split(/\s+/),$=0,J=0,Q=!1,j=[];for(let q of Z){if(q==="circle"){Q=!0;continue}let N=parseFloat(q);if(Number.isFinite(N))j.push(N)}if(j.length>=2)$=j[0],J=j[1];else if(j.length===1)$=j[0],J=j[0];else return null;return{vPad:$,hPad:J,circle:Q}}#z(){let _=this.#H();if(!_){if(this.#N)this.#N.remove(),this.#N=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#N){let Z=document.createElement("div");Z.classList.add("fig-handle-hit-area"),Z.addEventListener("pointerdown",($)=>this.#S($)),this.prepend(Z),this.#N=Z}if(this.style.setProperty("--fig-handle-hit-area-size",String(_.hPad*2)),_.circle)this.#N.style.borderRadius="50%";else this.#N.style.borderRadius="inherit"}#S(_){if(T(this,"disabled"))return;if(_.target!==this.#N)return;if(this.#A==="delegate")_.preventDefault(),_.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:_}}));else this.#v(_)}connectedCallback(){this.#x(),this.#E(),this.#z(),this.addEventListener("click",this.#V),this.addEventListener("blur",this.#I),document.addEventListener("pointerdown",this.#f),document.addEventListener("keydown",this.#P);let _=this.getAttribute("value");if(_)this.#D(_);if(this.#K)this.#o()}disconnectedCallback(){if(this.#C(),this.#p(),this.#u(),this.#d(),this.#N)this.#N.remove(),this.#N=null;this.removeEventListener("click",this.#V),this.removeEventListener("blur",this.#I),document.removeEventListener("pointerdown",this.#f),document.removeEventListener("keydown",this.#P)}select(){if(T(this,"disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#V=(_)=>{if(this.#_){this.#_=!1;return}if(this.select(),this.getAttribute("type")==="color"&&this.#Y&&!this.#K)this.#g()};#f=(_)=>{if(this.contains(_.target))return;if((this.#j||this.#G)&&_.target.closest?.("dialog, [popover]"))return;this.deselect()};#I=()=>{this.removeAttribute("data-fig-pointer-focus")};#P=(_)=>{if(this.removeAttribute("data-fig-pointer-focus"),_.defaultPrevented)return;if(_.target===this&&this.#X&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(_.key)){if(this.#w(_)){if(_.preventDefault(),!T(this,"selected"))this.select()}return}if(_.key!=="Enter"&&_.key!==" ")return;if(_.target===this&&!T(this,"selected")){if(_.preventDefault(),this.getAttribute("type")==="color"&&this.#Y&&!this.#K)this.#g();else this.select();return}if(!T(this,"selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#Y)return;if(_.preventDefault(),!this.#K)this.#g()};#w(_){if(T(this,"disabled"))return!1;let Z=this.#O();if(!Z)return!1;let $=Z.getBoundingClientRect();if($.width<=0||$.height<=0)return!1;let J=this.#R,Q=this.#r($),j=_.shiftKey?0.1:0.01,q=Q.px,N=Q.py;switch(_.key){case"ArrowLeft":if(!J.x)return!1;q-=j;break;case"ArrowRight":if(!J.x)return!1;q+=j;break;case"ArrowUp":if(!J.y)return!1;N-=j;break;case"ArrowDown":if(!J.y)return!1;N+=j;break;case"Home":if(J.x)q=0;if(J.y)N=0;break;case"End":if(J.x)q=1;if(J.y)N=1;break;default:return!1}if(q=Math.max(0,Math.min(1,q)),N=Math.max(0,Math.min(1,N)),this.#k(J),J.x)this.style.left=`${this.#L(q*$.width)}px`;if(J.y)this.style.top=`${this.#L(N*$.height)}px`;this.#F();let G={...this.#r($),shiftKey:_.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:G})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:G})),!0}attributeChangedCallback(_,Z,$){if(_==="color"){if(!$||$==="false"||$==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",$);if(this.#j&&this.#K==="color"&&$)this.#j.setAttribute("value",$);this.#y()}if(_==="drag")this.#E();if(_==="hit-area")this.#z();if(_==="selected")this.#s();if(_==="selected"||_==="disabled"||_==="type"||_==="tip"||_==="aria-label"||_==="aria-labelledby")this.#x();if(_==="value"&&!this.#Q&&!this.#Z)this.#D($);if(_==="precision"&&this.isConnected&&!this.#Z&&this.hasAttribute("value"))this.#D(this.getAttribute("value")),this.#F();if(_==="tip"){if(this.#p(),this.#K)this.#u(),this.#o()}}#E(){if(this.#X&&!this.#J)this.#J=(_)=>this.#v(_),this.addEventListener("pointerdown",this.#J);else if(!this.#X&&this.#J)this.#C()}#x(){let _=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex",_?"-1":"0");else if(_)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",_?"true":"false"),this.setAttribute("aria-pressed",Z?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let $=this.#K||this.getAttribute("type")||"handle";this.setAttribute("aria-label",$==="color"?"Color handle":$==="add"?"Add handle":$==="remove"?"Remove handle":"Handle")}}#C(){if(this.#$?.(),this.#$=null,this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#Z=!1,this.#_=!1}#v(_){if(!this.#X||T(this,"disabled"))return;_.preventDefault(),this.setAttribute("data-fig-pointer-focus",""),this.focus(),this.select();let Z=this.#O();if(!Z)return;this.#$?.(),this.#Z=!0;let $=this.#R,J=null,Q=this.getBoundingClientRect(),j=Q.left+Q.width/2,q=Q.top+Q.height/2,N=_.clientX-j,G=_.clientY-q,K=_.clientX,X=_.clientY,Y=3,U=(H,A,z=!1)=>{let W=Z.getBoundingClientRect();J=W;let I=this.#r(W),V=H-N-W.left,C=A-G-W.top,S=Math.max(0,Math.min(W.width,V)),w=Math.max(0,Math.min(W.height,C)),f=W.width>0?$.x?S/W.width:I.px:0.5,c=W.height>0?$.y?w/W.height:I.py:0.5;if(this.#W(z)){if($.x)f=this.#M(f);if($.y)c=this.#M(c);if($.x&&$.y){let r=this.#B(f,c);f=r.x,c=r.y}}if(this.#k($),$.x)this.style.left=`${this.#L(Math.max(0,Math.min(W.width,f*W.width)))}px`;if($.y)this.style.top=`${this.#L(Math.max(0,Math.min(W.height,c*W.height)))}px`},R=(H)=>{if(!this.#Z)return;if(!this.#_){let A=H.clientX-K,z=H.clientY-X;if(A*A+z*z<Y*Y)return;if(this.#i(),this.classList.add("dragging"),this.style.cursor="grabbing",!T(this,"selected"))this.select()}this.#_=!0,U(H.clientX,H.clientY,H.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#r(J),shiftKey:H.shiftKey}}))},O=(H)=>{if(M(),this.#_){U(H.clientX,H.clientY,H.shiftKey),this.#F(),this.#D(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#r(J)}));let A=(z)=>{z.stopPropagation(),z.preventDefault()};this.addEventListener("click",A,{capture:!0,once:!0})}else this.#F();this.#_=!1},M=()=>{if(window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",O),this.#Z=!1,this.style.cursor="",this.classList.remove("dragging"),this.#$===M)this.#$=null};this.#$=M,window.addEventListener("pointermove",R),window.addEventListener("pointerup",O)}showColorTip(){if(!this.#K)return;if(this.#j){this.#j.style.display="";return}this.#o()}hideColorTip(){if(!this.#j)return;this.#j.style.display="none"}#h(_=this.getAttribute("color")){let Z={color:"#D9D9D9",opacity:100},$=String(_||"").trim();if(!$)return Z;let J=(j)=>{let q=j.replace("#","").trim();if(q.length===3||q.length===4){let[N,G,K,X]=q;return{color:`#${N}${N}${G}${G}${K}${K}`.toUpperCase(),opacity:X?Math.round(parseInt(`${X}${X}`,16)/255*100):100}}if(q.length===6||q.length===8)return{color:`#${q.slice(0,6)}`.toUpperCase(),opacity:q.length===8?Math.round(parseInt(q.slice(6,8),16)/255*100):100};return Z},Q=(j,q,N)=>{let G=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${G(j)}${G(q)}${G(N)}`.toUpperCase()};if($.startsWith("#"))return J($);try{let{ctx:j}=k0(1,1);j.fillStyle="#000000",j.fillStyle=$;let q=j.fillStyle;if(q.startsWith("#"))return J(q);let N=q.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(N)return{color:Q(N[1],N[2],N[3]),opacity:N[4]!==void 0?Math.round(parseFloat(N[4])*100):100}}catch{}return Z}#m(){let{color:_,opacity:Z}=this.#h();return JSON.stringify(Z<100?{type:"solid",color:_,opacity:Z}:{type:"solid",color:_})}#y(){if(!this.#G)return;this.#G.setAttribute("value",this.#m())}#b(){if(!t())return null;if(this.#G)return this.#G;let _=document.createElement("fig-fill-picker");_.setAttribute("mode","solid"),_.setAttribute("alpha","true"),_.setAttribute("dialog-offset","8 8"),_.setAttribute("value",this.#m()),_.anchorElement=this;let Z=document.createElement("span");return Z.hidden=!0,_.appendChild(Z),_.addEventListener("input",this.#_0),_.addEventListener("change",this.#Z0),_.addEventListener("close",this.#N0),this.appendChild(_),this.#G=_,_}#g(){if(T(this,"disabled"))return;let _=this.#b();if(!_){this.#t();return}this.setAttribute("selected",""),this.#y(),_.open()}#u(){if(!this.#G)return;this.#G.removeEventListener("input",this.#_0),this.#G.removeEventListener("change",this.#Z0),this.#G.removeEventListener("close",this.#N0),this.#G.close(),this.#G.remove(),this.#G=null,this.removeAttribute("selected")}#l(){if(this.#q)return this.#q;let _=document.createElement("input");return _.type="color",_.tabIndex=-1,_.setAttribute("aria-hidden","true"),_.style.position="fixed",_.style.inlineSize="1px",_.style.blockSize="1px",_.style.opacity="0",_.style.pointerEvents="none",_.addEventListener("input",this.#G0),_.addEventListener("change",this.#q0),this.appendChild(_),this.#q=_,_}#t(){let _=this.#l(),{color:Z}=this.#h();_.value=Z,this.setAttribute("selected",""),_.click()}#d(){if(!this.#q)return;this.#q.removeEventListener("input",this.#G0),this.#q.removeEventListener("change",this.#q0),this.#q.remove(),this.#q=null}#i(){if(this.getAttribute("type")!=="color")return;this.#G?.close()}#o(){let _=this.#K;if(!_)return;if(this.#j)return;let Z=document.createElement("fig-color-tip");if(_==="add"||_==="remove")Z.setAttribute("control",_);else Z.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Z.setAttribute("alpha","true");Z.addEventListener("input",this.#K0),Z.addEventListener("change",this.#j0),Z.addEventListener("add",this.#a),Z.addEventListener("remove",this.#a),this.appendChild(Z),this.#j=Z,this.#s()}#p(){if(!this.#j)return;this.#j.removeEventListener("input",this.#K0),this.#j.removeEventListener("change",this.#j0),this.#j.removeEventListener("add",this.#a),this.#j.removeEventListener("remove",this.#a),this.#j.remove(),this.#j=null}#s(){if(!this.#j||this.#K!=="color")return;let _=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#j.toggleAttribute("selected",_)}#c(_,Z){if(Z===void 0||Z>=100)return _;let{r:$,g:J,b:Q}=$0(_);return`rgba(${$}, ${J}, ${Q}, ${Z/100})`}#e(_){if(!_?.color)return null;let Z=_.opacity!==void 0?_.opacity:_.alpha!==void 0?Math.round(_.alpha*100):void 0;return{color:_.color,opacity:Z,...a(_.color,_.alpha,Z)}}#_0=(_)=>{_.stopPropagation();let Z=this.#e(_.detail);if(!Z)return;this.setAttribute("color",this.#c(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#Z0=(_)=>{_.stopPropagation();let Z=this.#e(_.detail);if(!Z)return;this.setAttribute("color",this.#c(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#n(_){let{opacity:Z}=this.#h();return{...Z<100?{color:_,opacity:Z}:{color:_},...a(_,void 0,Z)}}#G0=(_)=>{_.stopPropagation();let Z=this.#n(_.target.value);this.setAttribute("color",this.#c(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#q0=(_)=>{_.stopPropagation();let Z=this.#n(_.target.value);if(this.setAttribute("color",this.#c(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z})),this.isConnected)this.focus()};#N0=()=>{if(!this.isConnected)return;this.setAttribute("selected",""),this.focus()};#K0=(_)=>{if(_.stopPropagation(),_.detail?.color){let Z={color:_.detail.color,opacity:_.detail.opacity,...a(_.detail.color,_.detail.alpha,_.detail.opacity)};this.setAttribute("color",this.#c(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))}};#j0=(_)=>{if(_.stopPropagation(),_.detail?.color){let Z={color:_.detail.color,opacity:_.detail.opacity,...a(_.detail.color,_.detail.alpha,_.detail.opacity)};this.setAttribute("color",this.#c(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))}};#a=(_)=>{_.stopPropagation(),this.dispatchEvent(new CustomEvent(_.type,{bubbles:!0,composed:!0}))};#r(_){let Z=_||this.#O()?.getBoundingClientRect();if(!Z)return{x:0,y:0,px:0,py:0};let $=this.getBoundingClientRect(),J=this.offsetWidth/2,Q=this.offsetHeight/2,j=$.left-Z.left,q=$.top-Z.top,N=j+J,G=q+Q,K=Z.width>0?N/Z.width:0,X=Z.height>0?G/Z.height:0;return{x:this.#L(j),y:this.#L(q),px:K,py:X}}}F("fig-handle",a_);class n_ extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(_){this.setAttribute("value",_??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Z()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="disabled")this.#Z()}#Z(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}F("fig-menu-item",n_);class S0 extends HTMLElement{#Z=null;#_=null;#J=null;#$=this.#K.bind(this);static get observedAttributes(){return["label","direction","sticky"]}get label(){return this.getAttribute("label")??""}set label(_){if(_==null||_==="")this.removeAttribute("label");else this.setAttribute("label",String(_))}connectedCallback(){this.#Q(),this.#j(),this.#q()}disconnectedCallback(){this.#J?.disconnect(),this.#J=null,this.#N()}attributeChangedCallback(_,Z,$){if(Z===$)return;if(this.#Q(),_==="sticky")this.#q()}#Q(){if(!this.hasAttribute("role"))this.setAttribute("role","separator");if(this.getAttribute("direction")==="vertical")this.setAttribute("aria-orientation","vertical");else if(!this.hasAttribute("aria-orientation"))this.setAttribute("aria-orientation","horizontal");let Z=this.label.trim(),$=Array.from(this.children).filter((q)=>q.localName==="label"),J=$.find((q)=>!q.hasAttribute("data-fig-separator-generated")),Q=$.filter((q)=>q.hasAttribute("data-fig-separator-generated"));if(J)Q.forEach((q)=>q.remove());else if(Z){let q=Q[0]??document.createElement("label");if(Q.slice(1).forEach((N)=>N.remove()),q.setAttribute("data-fig-separator-generated",""),q.textContent!==Z)q.textContent=Z;if(!q.parentElement)this.appendChild(q)}else Q.forEach((q)=>q.remove());let j=J?.textContent?.trim()||Z;if(j)this.setAttribute("aria-label",j);else this.removeAttribute("aria-label")}#j(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>this.#Q()),this.#J.observe(this,{childList:!0,characterData:!0,subtree:!0})}#G(){return this.hasAttribute("sticky")&&this.getAttribute("sticky")!=="false"}#q(){if(this.#N(),!this.isConnected||!this.#G()){this.removeAttribute("stuck");return}let _=z1(this);if(this.#Z=_,_?.addEventListener("scroll",this.#$,{passive:!0}),this.#_=new ResizeObserver(this.#$),this.#_.observe(this),_ instanceof Element)this.#_.observe(_);requestAnimationFrame(this.#$)}#N(){this.#Z?.removeEventListener?.("scroll",this.#$),this.#Z=null,this.#_?.disconnect(),this.#_=null}#K(){if(!this.#G()||!this.#Z){this.removeAttribute("stuck");return}let _=parseFloat(getComputedStyle(this).top)||0,Z=this.#Z,$=Z===document.scrollingElement||Z===document.documentElement?{top:0}:Z.getBoundingClientRect(),J=Z instanceof Element?parseFloat(getComputedStyle(Z).paddingTop)||0:0,Q=$.top+J+_;this.toggleAttribute("stuck",this.getBoundingClientRect().top<=Q+1)}}F("fig-separator",S0);function z1(_){let Z=_.parentElement;while(Z){let $=getComputedStyle(Z),J=$.overflowY||$.overflow;if(J&&J!=="visible"&&J!=="clip")return Z;Z=Z.parentElement}return document.scrollingElement}class e_ extends S0{}F("fig-menu-separator",e_);var T1=new Set(["FIG-MENU-ITEM","FIG-SEPARATOR","FIG-MENU-SEPARATOR"]),q0="trigger";function k1(_){return _?.nodeType===1&&T1.has(_.tagName)}function D1(_,Z){if(!_||!Z)return null;let $=Z;while($.parentElement&&$.parentElement!==_)$=$.parentElement;return $.parentElement===_?$:null}class _1 extends HTMLElement{#Z=null;#_=null;#J=null;#$=null;#Q=null;#j=null;#G=null;#q=null;#N=null;#K=null;#Y=!1;#X;#R;#U;#W;#M;#B;#O=this.#w.bind(this);#L=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open","trigger"]}constructor(){super();this.#X=this.#g.bind(this),this.#R=this.#u.bind(this),this.#U=this.#t.bind(this),this.#W=this.#d.bind(this),this.#M=this.#i.bind(this),this.#B=this.#w.bind(this),this.#T()}get value(){return this.getAttribute("value")||""}set value(_){this.setAttribute("value",_??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(_){if(_){if(this.#b())return;this.setAttribute("open","")}else this.removeAttribute("open")}connectedCallback(){if(this.#k(),this.#S(),this.#I(),this.#f(),this.#y(),this.open)this.#p()}disconnectedCallback(){if(this.#V(),this.#P(),document.removeEventListener("keydown",this.#W,!0),this.#G)this.#G.disconnect(),this.#G=null}attributeChangedCallback(_,Z,$){if(Z===$)return;if(_==="open"){if($===null||$==="false")this.#s();else{if(this.#b()){this.removeAttribute("open");return}this.#p()}return}if(_==="disabled"){this.#y();return}if(this.#Z&&(_==="position"||_==="offset"||_==="closedby"))if($!==null)this.#Z.setAttribute(_,$);else this.#Z.removeAttribute(_)}#T(){if(this.#Y)return;this.#Y=!0;let _=this.attachShadow({mode:"open"});r0(_,{icons:!0});let Z=document.createElement("style");Z.textContent=`
175
175
  :host {
176
176
  display: contents;
177
177
  }
@@ -197,4 +197,4 @@ fig-icon[size="small"] {
197
197
  .fig-menu-items > ::slotted(fig-menu-separator) {
198
198
  flex-shrink: 0;
199
199
  }
200
- `;let $=document.createElement("slot");$.setAttribute("name",j0);let J=document.createElement("dialog",{is:"fig-popup"});if(J.setAttribute("is","fig-popup"),J.classList.add("fig-menu-popup"),J.setAttribute("part","listbox"),J.setAttribute("theme","menu"),J.setAttribute("role","menu"),J.id=g(),"popover"in HTMLElement.prototype)J.setAttribute("popover","manual");let Q=document.createElement("div");Q.className="fig-menu-options",Q.setAttribute("part","options"),Q.setAttribute("role","presentation");let j=document.createElement("div");j.className="fig-menu-items";let q=document.createElement("slot");j.appendChild(q),Q.appendChild(j),J.appendChild(Q),_.append(Z,$,J),this.#Z=J,this.#_=Q,this.#J=q,this.#I(),J.addEventListener("close",this.#B),q.addEventListener("slotchange",this.#M)}#I(){if(!this.#Z)return;let _=this.getAttribute("position")||"bottom left";this.#Z.setAttribute("position",_);let Z=this.getAttribute("offset");if(Z)this.#Z.setAttribute("offset",Z);else this.#Z.removeAttribute("offset");let $=this.getAttribute("closedby");if($)this.#Z.setAttribute("closedby",$);else this.#Z.removeAttribute("closedby")}#k(){this.#$=this.querySelector("[fig-menu-trigger]")||this.querySelector(`:scope > :not(fig-menu-item):not(fig-separator):not(fig-menu-separator):not([slot="${j0}"])`)||this.querySelector(`[slot="${j0}"]`),this.#F()}#F(){let _=T1(this,this.#$);if(this.#Q=_,!_)return;if(_.getAttribute("slot")!==j0)_.setAttribute("slot",j0)}#H(){return(this.getAttribute("trigger")||"").toLowerCase()==="contextmenu"||this.hasAttribute("contextmenu")}#A(){if(!this.#$||!this.#Z)return;this.#$.addEventListener("click",this.#X),this.#$.addEventListener("contextmenu",this.#Y),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded",this.open?"true":"false"),this.#$.setAttribute("aria-controls",this.#Z.id),this.#Z.anchor=this.#$}#z(){if(!this.#$)return;this.#$.removeEventListener("click",this.#X),this.#$.removeEventListener("contextmenu",this.#Y)}#C(){this.addEventListener("keydown",this.#U),this.addEventListener("click",this.#R),this.#A(),this.#Z?.addEventListener("keydown",this.#U)}#E(){this.removeEventListener("keydown",this.#U),this.removeEventListener("click",this.#R),this.#z(),this.#Z?.removeEventListener("keydown",this.#U)}#f(){if(this.#K)return;this.#K=new MutationObserver((_)=>{let Z=!1;for(let $ of _){for(let J of $.addedNodes){if(J.nodeType!==1)continue;if(z1(J))continue;if(J.parentElement===this)Z=!0}for(let J of $.removedNodes)if(J===this.#$||J===this.#Q)Z=!0}if(Z||!this.#$)this.#z(),this.#k(),this.#A(),this.#b();this.#x()}),this.#K.observe(this,{childList:!0})}#D(){if(!this.#_)return;this.#S(),this.#_.addEventListener("scroll",this.#L,{passive:!0}),this.#q?.disconnect(),this.#q=new ResizeObserver(()=>this.#x()),this.#q.observe(this.#_),requestAnimationFrame(()=>this.#x())}#P(){this.#_?.removeEventListener("scroll",this.#L),this.#q?.disconnect(),this.#q=null,this.#w()}#x(){let _=R0(this.#_,this.#_,"y");return this.classList.toggle("overflow-start",Boolean(this.#_?.classList.contains("overflow-start"))),this.classList.toggle("overflow-end",Boolean(this.#_?.classList.contains("overflow-end"))),_}#S(){if(this.#N&&this.#G&&this.#_?.contains(this.#N)&&this.#_?.contains(this.#G))return;this.#w();let _=U0({owner:"menu",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>Z0(this.#_,"y",-1),onEnd:()=>Z0(this.#_,"y",1)});this.#N=_.start,this.#G=_.end,this.#_.prepend(this.#N),this.#_.append(this.#G)}#w(){this.#N?.remove(),this.#G?.remove(),this.#N=null,this.#G=null,this.#_?.classList.remove("overflow-start","overflow-end"),this.classList.remove("overflow-start","overflow-end")}#V(){return Array.from(this.querySelectorAll(":scope > fig-menu-item")).filter((_)=>!_.hidden&&(!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false"))}#g(){let _=this.#V();if(!_.length){this.#O=-1;return}let Z=document.activeElement,$=_.findIndex((J)=>J===Z||J.contains(Z));this.#O=$>=0?$:-1}#y(_){let Z=this.#V();if(!Z.length)return;let $=(_+Z.length)%Z.length;this.#O=$;let J=Z[$];J.focus(),this.#m(J)}#m(_){let Z=this.#_;if(!Z||!_)return;requestAnimationFrame(()=>{if(!Z.isConnected||!_.isConnected)return;let{scrollHeight:$,clientHeight:J}=Z;if($<=J+1){this.#x();return}let Q=_.getBoundingClientRect(),j=Z.getBoundingClientRect(),q=Q.top-j.top+Z.scrollTop,N=$-J,K=Math.max(0,Math.min(q+Q.height/2-J/2,N));Z.scrollTo({top:K,behavior:"auto"}),this.#x()})}#b(){let _=this.#h();if(_)if(this.open)this.removeAttribute("open");else this.#d();if(!this.#$)return;if(_)this.#$.setAttribute("disabled",""),this.#$.setAttribute("aria-disabled","true"),this.#$.setAttribute("aria-expanded","false");else this.#$.removeAttribute("disabled"),this.#$.removeAttribute("aria-disabled")}#h(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#v(_){if(this.#H())return;if(this.#h())return;_.stopPropagation();let Z=this.#Z?.matches?.(":open")??!1;if(this.open&&!Z)this.removeAttribute("open");if(this.open&&Z)this.open=!1;else{if(this.#Z&&this.#$)this.#Z.anchor=this.#$;this.open=!0}}#s(_){if(!this.#H())return;if(this.#h())return;_.preventDefault(),_.stopPropagation(),this.#r(_.clientX,_.clientY)}#r(_,Z){let $=!1,J=0,Q=()=>{window.clearTimeout(J),window.removeEventListener("pointerup",j,!0),window.removeEventListener("pointercancel",q,!0)},j=()=>{if($)return;$=!0,Q(),requestAnimationFrame(()=>this.showAt(_,Z))},q=()=>{if($)return;$=!0,Q()};window.addEventListener("pointerup",j,{once:!0,capture:!0}),window.addEventListener("pointercancel",q,{once:!0,capture:!0}),J=window.setTimeout(j,180)}#a(_){if(this.#h())return;if(this.#$?.contains(_.target)||this.#Q?.contains(_.target))return;let Z=_.target.closest?.("fig-menu-item");if(!Z||Z.parentElement!==this)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;_.stopPropagation(),this.#i(Z)}#c(_){if(this.#h())return;if(_.currentTarget===document&&_.key!=="Escape")return;if(_.currentTarget===this){let $=typeof _.composedPath==="function"?_.composedPath():[];if(this.#Z&&$.includes(this.#Z))return}if(!this.open||!this.#Z?.matches?.(":open")){if(this.#$?.contains(_.target)&&(_.key==="ArrowDown"||_.key==="Enter"||_.key===" ")){if(_.preventDefault(),this.#Z&&this.#$)this.#Z.anchor=this.#$;this.open=!0,requestAnimationFrame(()=>this.#y(0))}return}let Z=this.#V();if(!Z.length)return;switch(_.key){case"ArrowDown":{_.preventDefault(),this.#g(),this.#y(this.#O+1);break}case"ArrowUp":{_.preventDefault(),this.#g(),this.#y(this.#O-1);break}case"Home":{_.preventDefault(),this.#y(0);break}case"End":{_.preventDefault(),this.#y(Z.length-1);break}case"Escape":{_.preventDefault(),this.open=!1,this.#$?.focus();break}case"Enter":case" ":{this.#g();let $=Z[this.#O];if(!$)return;_.preventDefault(),this.#i($);break}}}#o(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#$)this.#$.setAttribute("aria-expanded","false"),this.#$.focus();this.#O=-1}#i(_){let Z=_.getAttribute("value")||_.textContent.trim();this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("change",{detail:{value:Z,item:_},bubbles:!0})),this.open=!1}showAt(_,Z){if(this.#h())return;if(this.#j={getBoundingClientRect:()=>({width:0,height:0,top:Z,right:_,bottom:Z,left:_,x:_,y:Z})},this.#Z)this.#Z.anchor=this.#j;if(this.open)this.open=!1;requestAnimationFrame(()=>{if(this.#h())return;this.open=!0})}#p(){if(!this.#Z||this.#h()){if(this.hasAttribute("open"))this.removeAttribute("open");return}if(this.#Z.open=!0,document.addEventListener("keydown",this.#U,!0),this.#$)this.#$.setAttribute("aria-expanded","true");this.#O=-1,requestAnimationFrame(()=>{if(this.#x(),!this.#$?.matches?.(":focus-visible"))return;this.#y(0)})}#d(){if(!this.#Z)return;document.removeEventListener("keydown",this.#U,!0),this.#Z.open=!1,this.#$?.setAttribute("aria-expanded","false")}}A("fig-menu",n_);
200
+ `;let $=document.createElement("slot");$.setAttribute("name",q0);let J=document.createElement("dialog",{is:"fig-popup"});if(J.setAttribute("is","fig-popup"),J.classList.add("fig-menu-popup"),J.setAttribute("part","listbox"),J.setAttribute("theme","menu"),J.setAttribute("role","menu"),J.id=v(),"popover"in HTMLElement.prototype)J.setAttribute("popover","manual");let Q=document.createElement("div");Q.className="fig-menu-options",Q.setAttribute("part","options"),Q.setAttribute("role","presentation");let j=document.createElement("div");j.className="fig-menu-items";let q=document.createElement("slot");j.appendChild(q),Q.appendChild(j),J.appendChild(Q),_.append(Z,$,J),this.#Z=J,this.#_=Q,this.#J=q,this.#D(),J.addEventListener("close",this.#M),q.addEventListener("slotchange",this.#B)}#D(){if(!this.#Z)return;let _=this.getAttribute("position")||"bottom left";this.#Z.setAttribute("position",_);let Z=this.getAttribute("offset");if(Z)this.#Z.setAttribute("offset",Z);else this.#Z.removeAttribute("offset");let $=this.getAttribute("closedby");if($)this.#Z.setAttribute("closedby",$);else this.#Z.removeAttribute("closedby")}#k(){this.#$=this.querySelector("[fig-menu-trigger]")||this.querySelector(`:scope > :not(fig-menu-item):not(fig-separator):not(fig-menu-separator):not([slot="${q0}"])`)||this.querySelector(`[slot="${q0}"]`),this.#F()}#F(){let _=D1(this,this.#$);if(this.#Q=_,!_)return;if(_.getAttribute("slot")!==q0)_.setAttribute("slot",q0)}#A(){return(this.getAttribute("trigger")||"").toLowerCase()==="contextmenu"||this.hasAttribute("contextmenu")}#H(){if(!this.#$||!this.#Z)return;this.#$.addEventListener("click",this.#X),this.#$.addEventListener("contextmenu",this.#R),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded",this.open?"true":"false"),this.#$.setAttribute("aria-controls",this.#Z.id),this.#Z.anchor=this.#$}#z(){if(!this.#$)return;this.#$.removeEventListener("click",this.#X),this.#$.removeEventListener("contextmenu",this.#R)}#S(){this.addEventListener("keydown",this.#W),this.addEventListener("click",this.#U),this.#H(),this.#Z?.addEventListener("keydown",this.#W)}#V(){this.removeEventListener("keydown",this.#W),this.removeEventListener("click",this.#U),this.#z(),this.#Z?.removeEventListener("keydown",this.#W)}#f(){if(this.#G)return;this.#G=new MutationObserver((_)=>{let Z=!1;for(let $ of _){for(let J of $.addedNodes){if(J.nodeType!==1)continue;if(k1(J))continue;if(J.parentElement===this)Z=!0}for(let J of $.removedNodes)if(J===this.#$||J===this.#Q)Z=!0}if(Z||!this.#$)this.#z(),this.#k(),this.#H(),this.#y();this.#w()}),this.#G.observe(this,{childList:!0})}#I(){if(!this.#_)return;this.#E(),this.#_.addEventListener("scroll",this.#O,{passive:!0}),this.#q?.disconnect(),this.#q=new ResizeObserver(()=>this.#w()),this.#q.observe(this.#_),requestAnimationFrame(()=>this.#w())}#P(){this.#_?.removeEventListener("scroll",this.#O),this.#q?.disconnect(),this.#q=null,this.#x()}#w(){let _=L0(this.#_,this.#_,"y");return this.classList.toggle("overflow-start",Boolean(this.#_?.classList.contains("overflow-start"))),this.classList.toggle("overflow-end",Boolean(this.#_?.classList.contains("overflow-end"))),_}#E(){if(this.#N&&this.#K&&this.#_?.contains(this.#N)&&this.#_?.contains(this.#K))return;this.#x();let _=W0({owner:"menu",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>Z0(this.#_,"y",-1),onEnd:()=>Z0(this.#_,"y",1)});this.#N=_.start,this.#K=_.end,this.#_.prepend(this.#N),this.#_.append(this.#K)}#x(){this.#N?.remove(),this.#K?.remove(),this.#N=null,this.#K=null,this.#_?.classList.remove("overflow-start","overflow-end"),this.classList.remove("overflow-start","overflow-end")}#C(){return Array.from(this.querySelectorAll(":scope > fig-menu-item")).filter((_)=>!_.hidden&&(!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false"))}#v(){let _=this.#C();if(!_.length){this.#L=-1;return}let Z=document.activeElement,$=_.findIndex((J)=>J===Z||J.contains(Z));this.#L=$>=0?$:-1}#h(_){let Z=this.#C();if(!Z.length)return;let $=(_+Z.length)%Z.length;this.#L=$;let J=Z[$];J.focus(),this.#m(J)}#m(_){let Z=this.#_;if(!Z||!_)return;requestAnimationFrame(()=>{if(!Z.isConnected||!_.isConnected)return;let{scrollHeight:$,clientHeight:J}=Z;if($<=J+1){this.#w();return}let Q=_.getBoundingClientRect(),j=Z.getBoundingClientRect(),q=Q.top-j.top+Z.scrollTop,N=$-J,G=Math.max(0,Math.min(q+Q.height/2-J/2,N));Z.scrollTo({top:G,behavior:"auto"}),this.#w()})}#y(){let _=this.#b();if(_)if(this.open)this.removeAttribute("open");else this.#s();if(!this.#$)return;if(_)this.#$.setAttribute("disabled",""),this.#$.setAttribute("aria-disabled","true"),this.#$.setAttribute("aria-expanded","false");else this.#$.removeAttribute("disabled"),this.#$.removeAttribute("aria-disabled")}#b(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#g(_){if(this.#A())return;if(this.#b())return;_.stopPropagation();let Z=this.#Z?.matches?.(":open")??!1;if(this.open&&!Z)this.removeAttribute("open");if(this.open&&Z)this.open=!1;else{if(this.#Z&&this.#$)this.#Z.anchor=this.#$;this.open=!0}}#u(_){if(!this.#A())return;if(this.#b())return;_.preventDefault(),_.stopPropagation(),this.#l(_.clientX,_.clientY)}#l(_,Z){let $=!1,J=0,Q=()=>{window.clearTimeout(J),window.removeEventListener("pointerup",j,!0),window.removeEventListener("pointercancel",q,!0)},j=()=>{if($)return;$=!0,Q(),requestAnimationFrame(()=>this.showAt(_,Z))},q=()=>{if($)return;$=!0,Q()};window.addEventListener("pointerup",j,{once:!0,capture:!0}),window.addEventListener("pointercancel",q,{once:!0,capture:!0}),J=window.setTimeout(j,180)}#t(_){if(this.#b())return;if(this.#$?.contains(_.target)||this.#Q?.contains(_.target))return;let Z=_.target.closest?.("fig-menu-item");if(!Z||Z.parentElement!==this)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;_.stopPropagation(),this.#o(Z)}#d(_){if(this.#b())return;if(_.currentTarget===document&&_.key!=="Escape")return;if(_.currentTarget===this){let $=typeof _.composedPath==="function"?_.composedPath():[];if(this.#Z&&$.includes(this.#Z))return}if(!this.open||!this.#Z?.matches?.(":open")){if(this.#$?.contains(_.target)&&(_.key==="ArrowDown"||_.key==="Enter"||_.key===" ")){if(_.preventDefault(),this.#Z&&this.#$)this.#Z.anchor=this.#$;this.open=!0,requestAnimationFrame(()=>this.#h(0))}return}let Z=this.#C();if(!Z.length)return;switch(_.key){case"ArrowDown":{_.preventDefault(),this.#v(),this.#h(this.#L+1);break}case"ArrowUp":{_.preventDefault(),this.#v(),this.#h(this.#L-1);break}case"Home":{_.preventDefault(),this.#h(0);break}case"End":{_.preventDefault(),this.#h(Z.length-1);break}case"Escape":{_.preventDefault(),this.open=!1,this.#$?.focus();break}case"Enter":case" ":{this.#v();let $=Z[this.#L];if(!$)return;_.preventDefault(),this.#o($);break}}}#i(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#$)this.#$.setAttribute("aria-expanded","false"),this.#$.focus();this.#L=-1}#o(_){let Z=_.getAttribute("value")||_.textContent.trim();this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("change",{detail:{value:Z,item:_},bubbles:!0})),this.open=!1}showAt(_,Z){if(this.#b())return;if(this.#j={getBoundingClientRect:()=>({width:0,height:0,top:Z,right:_,bottom:Z,left:_,x:_,y:Z})},this.#Z)this.#Z.anchor=this.#j;if(this.open)this.open=!1;requestAnimationFrame(()=>{if(this.#b())return;this.open=!0})}#p(){if(!this.#Z||this.#b()){if(this.hasAttribute("open"))this.removeAttribute("open");return}if(this.#Z.open=!0,document.addEventListener("keydown",this.#W,!0),this.#$)this.#$.setAttribute("aria-expanded","true");this.#L=-1,requestAnimationFrame(()=>{if(this.#w(),!this.#$?.matches?.(":focus-visible"))return;this.#h(0)})}#s(){if(!this.#Z)return;document.removeEventListener("keydown",this.#W,!0),this.#Z.open=!1,this.#$?.setAttribute("aria-expanded","false")}}F("fig-menu",_1);