@rogieking/figui3 6.23.2 → 6.23.4

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 y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(Q,Z,$){if(Q.importNode.length!=1||Z.get("ungap-li"))return;var J="extends";try{var j={};j[J]="li";var q=HTMLLIElement,_=function(){return Reflect.construct(q,[],_)};if(_.prototype=$.create(q.prototype),Z.define("ungap-li",_,j),!/is="ungap-li"/.test(new _().outerHTML))throw j}catch(X){(function(){var Y="attributeChangedCallback",K="connectedCallback",G="disconnectedCallback",N=Element.prototype,W=$.assign,O=$.create,B=$.defineProperties,L=$.getOwnPropertyDescriptor,T=$.setPrototypeOf,R=Z.define,A=Z.get,M=Z.upgrade,E=Z.whenDefined,k=O(null),S=new WeakMap,x={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(U){return typeof U=="string"&&/^HTML(?!Element)/.test(U)}).forEach(function(U){function D(){}var P=self[U];T(D,P),(D.prototype=P.prototype).constructor=D,P={},P[U]={value:D},B(self,P)}),new MutationObserver(t).observe(Q,x),D0(Document.prototype,"importNode"),D0(Node.prototype,"cloneNode"),B(Z,{define:{value:function(U,D,P){if(U=U.toLowerCase(),P&&J in P){k[U]=W({},P,{Class:D});var I=P[J]+'[is="'+U+'"]',f=Q.querySelectorAll(I);for(var V=0,h=f.length;V<h;V++)n(f[V])}else R.apply(Z,arguments)}},get:{value:function(U){return U in k?k[U].Class:A.call(Z,U)}},upgrade:{value:function(U){var D=G0(U);if(D&&!(U instanceof D.Class))R0(U,D);else M.call(Z,U)}},whenDefined:{value:function(U){return U in k?Promise.resolve():E.call(Z,U)}}});var y=Q.createElement;B(Q,{createElement:{value:function(U,D){var P=y.call(Q,U);if(D&&"is"in D)P.setAttribute("is",D.is),Z.upgrade(P);return P}}});var m=L(N,"attachShadow").value,d=L(N,"innerHTML");B(N,{attachShadow:{value:function(){var U=m.apply(this,arguments);return new MutationObserver(t).observe(U,x),U}},innerHTML:{get:d.get,set:function(U){if(d.set.call(this,U),/\bis=("|')?[a-z0-9_-]+\1/i.test(U))$0(this,n)}}});function t(U){for(var D=0,P=U.length;D<P;D++){var I=U[D],f=I.addedNodes,V=I.removedNodes;for(var h=0,J0=f.length;h<J0;h++)n(f[h]);for(var N0=0,x1=V.length;N0<x1;N0++)A0(V[N0])}}function H0(U){for(var D=0,P=U.length;D<P;D++){var I=U[D],f=I.attributeName,V=I.oldValue,h=I.target,J0=h.getAttribute(f);if(Y in h&&!(V==J0&&J0==null))h[Y](f,V,h.getAttribute(f),null)}}function A0(U){if(U.nodeType!==1)return;var D=G0(U);if(D&&U instanceof D.Class&&G in U&&S.get(U)!==G)S.set(U,G),Promise.resolve(U).then(V1);$0(U,A0)}function G0(U){var D=U.getAttribute("is");if(D){if(D=D.toLowerCase(),D in k)return k[D]}return null}function I1(U){U[K]()}function V1(U){U[G]()}function R0(U,D){var P=D.Class,I=P.observedAttributes||[];if(T(U,P.prototype),I.length){new MutationObserver(H0).observe(U,{attributes:!0,attributeFilter:I,attributeOldValue:!0});var f=[];for(var V=0,h=I.length;V<h;V++)f.push({attributeName:I[V],oldValue:null,target:U});H0(f)}}function n(U){if(U.nodeType!==1)return;var D=G0(U);if(D){if(!(U instanceof D.Class))R0(U,D);if(K in U&&U.isConnected&&S.get(U)!==K)S.set(U,K),Promise.resolve(U).then(I1)}$0(U,n)}function $0(U,D){for(var P=U.content,I=(P&&P.nodeType==11?P:U).querySelectorAll("[is]"),f=0,V=I.length;f<V;f++)D(I[f])}function D0(U,D){var P=U[D],I={};I[D]={value:function(){var f=P.apply(this,arguments);switch(f.nodeType){case 1:case 11:$0(f,n)}return f}},B(U,I)}})()}})(document,customElements,Object)});function v1(){if(typeof navigator>"u")return!1;let Q=navigator.userAgent||"",Z=/\b(iPad|iPhone|iPod)\b/.test(Q)||/\bMacintosh\b/.test(Q)&&/\bMobile\b/.test(Q),$=/\bAppleWebKit\b/.test(Q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(Q);return Z||$}function u(Q,Z={}){let $=document.createElement("fig-icon");if(Q)$.setAttribute("name",Q);if(Z.size)$.setAttribute("size",Z.size);if(Z.className)$.className=Z.className;return $}function c(Q,Z){requestAnimationFrame(()=>{if(Q&&!Q.isConnected)return;Z()})}function F(Q,Z){return Q.hasAttribute(Z)&&Q.getAttribute(Z)!=="false"}function q0(Q){Q.querySelectorAll(':scope > [slot="prepend"], :scope > [slot="append"]').forEach((Z)=>{if(Z.children.length>0){W0(Z);return}let $=Z.textContent.trim();if(!$){W0(Z);return}let J=Z.dataset.figInputSlotFullText||"",j=J?Array.from(J)[0]?.toUpperCase():"",q=$===j?J:$,X=Array.from($)[0].toUpperCase();if(Z.textContent!==X)Z.textContent=X;if(q&&q!==X)Z.dataset.figInputSlotFullText=q,Z.setAttribute("aria-label",q),g1(Z);else W0(Z)})}function g1(Q){if(Q.dataset.figInputSlotTooltipBound==="true")return;Q.dataset.figInputSlotTooltipBound="true",Q.addEventListener("pointerenter",P0),Q.addEventListener("pointerleave",U0),Q.addEventListener("focus",P0),Q.addEventListener("blur",U0)}function W0(Q){U0({currentTarget:Q}),delete Q.dataset.figInputSlotFullText,Q.removeAttribute("aria-label")}function P0(Q){let Z=Q.currentTarget,$=Z?.dataset?.figInputSlotFullText;if(!Z||!$)return;H.show(Z,$)}function U0(Q){let Z=Q.currentTarget;if(!Z)return;H.hide(Z)}function X0({owner:Q,onStart:Z,onEnd:$,startClass:J="",endClass:j="",chevronClass:q="",startLabel:_="Scroll back",endLabel:X="Scroll forward"}={}){let Y=(K,G)=>{let N=document.createElement("button");if(N.type="button",N.className=["fig-overflow",`fig-overflow-${K}`,K==="start"?J:j].filter(Boolean).join(" "),N.dataset.figOverflow=K,Q)N.setAttribute(`data-fig-${Q}-nav`,K);return N.setAttribute("tabindex","-1"),N.setAttribute("aria-label",K==="start"?_:X),N.appendChild(u("chevron",{size:"small",className:["fig-overflow-chevron",q].filter(Boolean).join(" ")})),N.addEventListener("click",(W)=>{W.preventDefault(),W.stopPropagation(),G?.(W)}),N};return{start:Y("start",Z),end:Y("end",$)}}function a(Q,Z,$="x",J=2){if(!Q||!Z)return!1;let j=$==="x",q=j?Z.scrollWidth:Z.scrollHeight,_=j?Z.clientWidth:Z.clientHeight,X=j?Z.scrollLeft:Z.scrollTop,Y=q-_>J,K=!Y||X<=J,G=!Y||X+_>=q-J;return Q.classList.toggle("overflow-start",!K),Q.classList.toggle("overflow-end",!G),Y}function i(Q,Z="x",$=1){if(!Q)return;let J=Z==="x",q=(J?Q.clientWidth:Q.clientHeight)*0.8*$;Q.scrollBy({[J?"left":"top"]:q,behavior:"smooth"})}function S0(Q,Z,$="y",J="auto"){if(!Q||!Z||!Q.contains(Z))return;requestAnimationFrame(()=>{if(!Q.isConnected||!Z.isConnected)return;let j=$==="x",q=j?Q.scrollWidth:Q.scrollHeight,_=j?Q.clientWidth:Q.clientHeight;if(q<=_+1){a(Q,Q,$);return}let X=Z.getBoundingClientRect(),Y=Q.getBoundingClientRect(),K=j?Q.scrollLeft:Q.scrollTop,G=(j?X.left-Y.left:X.top-Y.top)+K,N=j?X.width:X.height,W=q-_,O=Math.max(0,Math.min(G+N/2-_/2,W));Q.scrollTo({[j?"left":"top"]:O,behavior:J}),a(Q,Q,$)})}function o(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function h1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let Q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class Z extends HTMLButtonElement{}try{return customElements.define(Q,Z,{extends:"button"}),document.createElement("button",{is:Q})instanceof Z}catch($){return!1}}var f0=v1()&&!h1(),b1=(f0?Promise.resolve().then(() => (T0(),w1)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q});function M0(Q,Z,$){let J=()=>{if(!customElements.get(Q))customElements.define(Q,Z,$)};if(!f0){J();return}b1.then(J).catch((j)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${Q}".`,j)})}function z(Q,Z){if(!customElements.get(Q))customElements.define(Q,Z)}function g(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function j0(){if(!document.body)return null;let Q="data-figui-overlay-root",Z=document.body.querySelector(`:scope > [${Q}]`);if(!Z)Z=document.createElement("div"),Z.setAttribute(Q,""),document.body.append(Z);return Z}var m1=1e4;function I0(){return m1++}function b(Q,Z,$){if($&&$.trim())Q.style.setProperty(Z,$.trim());else Q.style.removeProperty(Z)}function v(Q){return String(Q??"").replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var s=null,E0=null;function O0(Q=1,Z=1){if(!s)s=document.createElement("canvas"),E0=s.getContext("2d");if(s.width!==Q)s.width=Q;if(s.height!==Z)s.height=Z;return{canvas:s,ctx:E0}}class V0 extends HTMLElement{type;#Z;#Q=new WeakMap;#$=["aria-label","aria-labelledby","aria-describedby","title"];#J=this.#G.bind(this);#j=this.#W.bind(this);#q=()=>this.#z();#_=()=>{if(this.button?.matches(":focus-visible"))this.setAttribute("data-focus-visible","")};#Y=()=>{this.removeAttribute("data-focus-visible")};constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){if(this.type=this.getAttribute("type")||"button",!this.button){let Z=this.type==="select"||this.type==="upload",$=Z?"span":"button",J=Z?"":' type="button"';this.shadowRoot.innerHTML=`
1
+ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(Q,Z,$){if(Q.importNode.length!=1||Z.get("ungap-li"))return;var J="extends";try{var j={};j[J]="li";var q=HTMLLIElement,_=function(){return Reflect.construct(q,[],_)};if(_.prototype=$.create(q.prototype),Z.define("ungap-li",_,j),!/is="ungap-li"/.test(new _().outerHTML))throw j}catch(X){(function(){var Y="attributeChangedCallback",K="connectedCallback",G="disconnectedCallback",N=Element.prototype,W=$.assign,O=$.create,B=$.defineProperties,L=$.getOwnPropertyDescriptor,T=$.setPrototypeOf,R=Z.define,A=Z.get,M=Z.upgrade,E=Z.whenDefined,k=O(null),S=new WeakMap,x={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(U){return typeof U=="string"&&/^HTML(?!Element)/.test(U)}).forEach(function(U){function D(){}var P=self[U];T(D,P),(D.prototype=P.prototype).constructor=D,P={},P[U]={value:D},B(self,P)}),new MutationObserver(t).observe(Q,x),D0(Document.prototype,"importNode"),D0(Node.prototype,"cloneNode"),B(Z,{define:{value:function(U,D,P){if(U=U.toLowerCase(),P&&J in P){k[U]=W({},P,{Class:D});var I=P[J]+'[is="'+U+'"]',f=Q.querySelectorAll(I);for(var V=0,g=f.length;V<g;V++)n(f[V])}else R.apply(Z,arguments)}},get:{value:function(U){return U in k?k[U].Class:A.call(Z,U)}},upgrade:{value:function(U){var D=G0(U);if(D&&!(U instanceof D.Class))R0(U,D);else M.call(Z,U)}},whenDefined:{value:function(U){return U in k?Promise.resolve():E.call(Z,U)}}});var y=Q.createElement;B(Q,{createElement:{value:function(U,D){var P=y.call(Q,U);if(D&&"is"in D)P.setAttribute("is",D.is),Z.upgrade(P);return P}}});var m=L(N,"attachShadow").value,d=L(N,"innerHTML");B(N,{attachShadow:{value:function(){var U=m.apply(this,arguments);return new MutationObserver(t).observe(U,x),U}},innerHTML:{get:d.get,set:function(U){if(d.set.call(this,U),/\bis=("|')?[a-z0-9_-]+\1/i.test(U))$0(this,n)}}});function t(U){for(var D=0,P=U.length;D<P;D++){var I=U[D],f=I.addedNodes,V=I.removedNodes;for(var g=0,J0=f.length;g<J0;g++)n(f[g]);for(var N0=0,x1=V.length;N0<x1;N0++)A0(V[N0])}}function H0(U){for(var D=0,P=U.length;D<P;D++){var I=U[D],f=I.attributeName,V=I.oldValue,g=I.target,J0=g.getAttribute(f);if(Y in g&&!(V==J0&&J0==null))g[Y](f,V,g.getAttribute(f),null)}}function A0(U){if(U.nodeType!==1)return;var D=G0(U);if(D&&U instanceof D.Class&&G in U&&S.get(U)!==G)S.set(U,G),Promise.resolve(U).then(V1);$0(U,A0)}function G0(U){var D=U.getAttribute("is");if(D){if(D=D.toLowerCase(),D in k)return k[D]}return null}function I1(U){U[K]()}function V1(U){U[G]()}function R0(U,D){var P=D.Class,I=P.observedAttributes||[];if(T(U,P.prototype),I.length){new MutationObserver(H0).observe(U,{attributes:!0,attributeFilter:I,attributeOldValue:!0});var f=[];for(var V=0,g=I.length;V<g;V++)f.push({attributeName:I[V],oldValue:null,target:U});H0(f)}}function n(U){if(U.nodeType!==1)return;var D=G0(U);if(D){if(!(U instanceof D.Class))R0(U,D);if(K in U&&U.isConnected&&S.get(U)!==K)S.set(U,K),Promise.resolve(U).then(I1)}$0(U,n)}function $0(U,D){for(var P=U.content,I=(P&&P.nodeType==11?P:U).querySelectorAll("[is]"),f=0,V=I.length;f<V;f++)D(I[f])}function D0(U,D){var P=U[D],I={};I[D]={value:function(){var f=P.apply(this,arguments);switch(f.nodeType){case 1:case 11:$0(f,n)}return f}},B(U,I)}})()}})(document,customElements,Object)});function v1(){if(typeof navigator>"u")return!1;let Q=navigator.userAgent||"",Z=/\b(iPad|iPhone|iPod)\b/.test(Q)||/\bMacintosh\b/.test(Q)&&/\bMobile\b/.test(Q),$=/\bAppleWebKit\b/.test(Q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(Q);return Z||$}function u(Q,Z={}){let $=document.createElement("fig-icon");if(Q)$.setAttribute("name",Q);if(Z.size)$.setAttribute("size",Z.size);if(Z.className)$.className=Z.className;return $}function c(Q,Z){requestAnimationFrame(()=>{if(Q&&!Q.isConnected)return;Z()})}function F(Q,Z){return Q.hasAttribute(Z)&&Q.getAttribute(Z)!=="false"}function q0(Q){Q.querySelectorAll(':scope > [slot="prepend"], :scope > [slot="append"]').forEach((Z)=>{if(Z.children.length>0){W0(Z);return}let $=Z.textContent.trim();if(!$){W0(Z);return}let J=Z.dataset.figInputSlotFullText||"",j=J?Array.from(J)[0]?.toUpperCase():"",q=$===j?J:$,X=Array.from($)[0].toUpperCase();if(Z.textContent!==X)Z.textContent=X;if(q&&q!==X)Z.dataset.figInputSlotFullText=q,Z.setAttribute("aria-label",q),h1(Z);else W0(Z)})}function h1(Q){if(Q.dataset.figInputSlotTooltipBound==="true")return;Q.dataset.figInputSlotTooltipBound="true",Q.addEventListener("pointerenter",P0),Q.addEventListener("pointerleave",U0),Q.addEventListener("focus",P0),Q.addEventListener("blur",U0)}function W0(Q){U0({currentTarget:Q}),delete Q.dataset.figInputSlotFullText,Q.removeAttribute("aria-label")}function P0(Q){let Z=Q.currentTarget,$=Z?.dataset?.figInputSlotFullText;if(!Z||!$)return;H.show(Z,$)}function U0(Q){let Z=Q.currentTarget;if(!Z)return;H.hide(Z)}function X0({owner:Q,onStart:Z,onEnd:$,startClass:J="",endClass:j="",chevronClass:q="",startLabel:_="Scroll back",endLabel:X="Scroll forward"}={}){let Y=(K,G)=>{let N=document.createElement("button");if(N.type="button",N.className=["fig-overflow",`fig-overflow-${K}`,K==="start"?J:j].filter(Boolean).join(" "),N.dataset.figOverflow=K,Q)N.setAttribute(`data-fig-${Q}-nav`,K);return N.setAttribute("tabindex","-1"),N.setAttribute("aria-label",K==="start"?_:X),N.appendChild(u("chevron",{size:"small",className:["fig-overflow-chevron",q].filter(Boolean).join(" ")})),N.addEventListener("click",(W)=>{W.preventDefault(),W.stopPropagation(),G?.(W)}),N};return{start:Y("start",Z),end:Y("end",$)}}function a(Q,Z,$="x",J=2){if(!Q||!Z)return!1;let j=$==="x",q=j?Z.scrollWidth:Z.scrollHeight,_=j?Z.clientWidth:Z.clientHeight,X=j?Z.scrollLeft:Z.scrollTop,Y=q-_>J,K=!Y||X<=J,G=!Y||X+_>=q-J;return Q.classList.toggle("overflow-start",!K),Q.classList.toggle("overflow-end",!G),Y}function i(Q,Z="x",$=1){if(!Q)return;let J=Z==="x",q=(J?Q.clientWidth:Q.clientHeight)*0.8*$;Q.scrollBy({[J?"left":"top"]:q,behavior:"smooth"})}function S0(Q,Z,$="y",J="auto"){if(!Q||!Z||!Q.contains(Z))return;requestAnimationFrame(()=>{if(!Q.isConnected||!Z.isConnected)return;let j=$==="x",q=j?Q.scrollWidth:Q.scrollHeight,_=j?Q.clientWidth:Q.clientHeight;if(q<=_+1){a(Q,Q,$);return}let X=Z.getBoundingClientRect(),Y=Q.getBoundingClientRect(),K=j?Q.scrollLeft:Q.scrollTop,G=(j?X.left-Y.left:X.top-Y.top)+K,N=j?X.width:X.height,W=q-_,O=Math.max(0,Math.min(G+N/2-_/2,W));Q.scrollTo({[j?"left":"top"]:O,behavior:J}),a(Q,Q,$)})}function o(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function g1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let Q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class Z extends HTMLButtonElement{}try{return customElements.define(Q,Z,{extends:"button"}),document.createElement("button",{is:Q})instanceof Z}catch($){return!1}}var f0=v1()&&!g1(),b1=(f0?Promise.resolve().then(() => (T0(),w1)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q});function M0(Q,Z,$){let J=()=>{if(!customElements.get(Q))customElements.define(Q,Z,$)};if(!f0){J();return}b1.then(J).catch((j)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${Q}".`,j)})}function z(Q,Z){if(!customElements.get(Q))customElements.define(Q,Z)}function h(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function j0(){if(!document.body)return null;let Q="data-figui-overlay-root",Z=document.body.querySelector(`:scope > [${Q}]`);if(!Z)Z=document.createElement("div"),Z.setAttribute(Q,""),document.body.append(Z);return Z}var m1=1e4;function I0(){return m1++}function b(Q,Z,$){if($&&$.trim())Q.style.setProperty(Z,$.trim());else Q.style.removeProperty(Z)}function v(Q){return String(Q??"").replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var s=null,E0=null;function O0(Q=1,Z=1){if(!s)s=document.createElement("canvas"),E0=s.getContext("2d");if(s.width!==Q)s.width=Q;if(s.height!==Z)s.height=Z;return{canvas:s,ctx:E0}}class V0 extends HTMLElement{type;#Q;#Z=new WeakMap;#$=["aria-label","aria-labelledby","aria-describedby","title"];#J=this.#G.bind(this);#j=this.#W.bind(this);#q=()=>this.#z();#_=()=>{if(this.button?.matches(":focus-visible"))this.setAttribute("data-focus-visible","")};#Y=()=>{this.removeAttribute("data-focus-visible")};constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){if(this.type=this.getAttribute("type")||"button",!this.button){let Z=this.type==="select"||this.type==="upload",$=Z?"span":"button",J=Z?"":' type="button"';this.shadowRoot.innerHTML=`
2
2
  <style>
3
3
  button, button:hover, button:active, .fig-button-control {
4
4
  padding: 0 var(--spacer-2);
@@ -34,11 +34,11 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
34
34
  <${$} class="fig-button-control"${J}>
35
35
  <slot></slot>
36
36
  </${$}>
37
- `,this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.button.addEventListener("click",this.#j),this.button.addEventListener("focus",this.#_),this.button.addEventListener("blur",this.#Y)}let Q=this.shadowRoot.querySelector("slot");Q?.removeEventListener("slotchange",this.#q),Q?.addEventListener("slotchange",this.#q),this.removeEventListener("keydown",this.#J),this.addEventListener("keydown",this.#J),this.#Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#F()}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#Z}set selected(Q){this.setAttribute("selected",Q)}#X(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#W(){if(this.#X())return;if(this.type==="toggle")if(this.selected)this.removeAttribute("selected");else this.setAttribute("selected","");if(this.type==="submit"){let Q=this.closest("form");if(Q)if(typeof Q.requestSubmit==="function")Q.requestSubmit();else Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),Z=this.getAttribute("target");if(Q)if(Z)window.open(Q,Z);else window.location.href=Q}}#N(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#K(){let Q=this.#N();if(Q instanceof HTMLSelectElement)return Q;if(Q?.tagName==="FIG-DROPDOWN")return Q.select||Q.querySelector?.("select")||null;return null}#G(Q){if(this.type!=="select")return;if(Q.key!=="Enter")return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;let Z=this.#K();if(!Z||Z.disabled||Z.multiple)return;if(typeof Z.showPicker!=="function")return;Q.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 Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.setAttribute("aria-pressed",Q?"true":"false"),this.button.setAttribute("aria-pressed",Q?"true":"false")}#L(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#$.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.button.removeAttribute(Q);else this.button.setAttribute(Q,Z)})}#F(){if(!this.button)return;let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=Q,this.button instanceof HTMLButtonElement)this.button.disabled=Q,this.button.type="button",this.button.setAttribute("type","button");this.#z(),this.#L(),this.#U()}#z(){let Q=this.#N();if(!Q)return;if(this.#X()){if(!this.#Q.has(Q))this.#Q.set(Q,Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false");Q.setAttribute("disabled","")}else if(this.#Q.has(Q)){let $=this.#Q.get(Q);if(this.#Q.delete(Q),$)Q.setAttribute("disabled","");else Q.removeAttribute("disabled")}}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"type":{let J=(j)=>j==="select"||j==="upload";if(J(Z||"button")!==J($||"button")){this.button=null,this.connectedCallback();break}this.#F();break}case"disabled":this.#F();break;case"selected":this.#Z=$!==null&&$!=="false",this.#U();break;default:this.#L();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#J),this.shadowRoot?.querySelector("slot")?.removeEventListener("slotchange",this.#q)}}z("fig-button",V0);class x0 extends HTMLElement{#Z="Menu";#Q=null;#$;#J;#j;get label(){return this.#Z}set label(Q){this.#Z=Q}#q;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#$=this.#W.bind(this),this.#J=this.#N.bind(this),this.#j=this.#K.bind(this),this.#q=this.slotChange.bind(this)}#_(){this.select.addEventListener("input",this.#$),this.select.addEventListener("change",this.#J),this.select.addEventListener("keydown",this.#j)}#Y(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#X(){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.#G(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#q),this.optionsSlot.addEventListener("slotchange",this.#q),this.select.removeEventListener("input",this.#$),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#j),this.#_()}slotChange(){let Q=this.hasAttribute("value"),Z=this.select.options.length>0&&this.select.selectedIndex>=0,$=Q?this.getAttribute("value"):this.type==="dropdown"?this.#Q: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}#W(Q){Q.stopPropagation();let Z=Q.target.selectedOptions?.[0];if(this.#Y(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#X();return}let $=Q.target.value;if(this.type==="dropdown")this.#Q=$;this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}#N(Q){Q.stopPropagation();let Z=Q.target.selectedOptions?.[0];if(this.#Y(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#X();return}let $=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,composed:!0}))}#K(Q){if(this.closest('fig-button[type="select"]'))return;if(Q.key!=="Enter"||Q.defaultPrevented)return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(typeof this.select.showPicker!=="function")return;Q.preventDefault();try{this.select.showPicker()}catch{}}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#Q;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#Q=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","label","disabled"]}#G(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=Q}#U(Q){if(this.type==="dropdown")return;if(this.select)this.select.value=Q??""}attributeChangedCallback(Q,Z,$){if(Q==="value")this.#U($);if(Q==="type"){if(this.type=$||"select",this.isConnected)this.slotChange()}if(Q==="label")this.#Z=$||"Menu",this.select.setAttribute("aria-label",this.#Z);if(Q==="disabled")this.#G()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#q),this.select.removeEventListener("input",this.#$),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#j)}}z("fig-dropdown",x0);class H extends HTMLElement{static#Z=0;static#Q=0;static#$=1000;static#J=null;static#j=!1;static#q=new Set;#_;#Y;#X;#W;#N;#K;#G;#U;#L;#F;#z;#B;#M=null;#D=null;#E=null;#H=!1;#O;#R=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#_=this.#x.bind(this),this.#Y=this.hidePopupOutsideClick.bind(this),this.#X=this.showDelayedPopup.bind(this),this.#W=this.#f.bind(this),this.#N=()=>{if(!this.#H)this.showDelayedPopup()},this.#K=()=>{this.#H=!1,this.hidePopup()},this.#G=this.#y.bind(this),this.#U=this.#g.bind(this),this.#L=this.#h.bind(this),this.#F=this.#w.bind(this),this.#B=this.#V.bind(this),this.#z=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(H.#u(),this.setup(),this.#S(),this.setupEventListeners(),this.#M=this.closest("dialog"),this.#M)this.#M.addEventListener("close",this.#z)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#I(),this.#C(),document.removeEventListener("mousedown",this.#_,!0),document.removeEventListener("keydown",this.#B,!0),this.#M)this.#M.removeEventListener("close",this.#z),this.#M=null;if(this.action==="click")document.body.removeEventListener("click",this.#Y);if(clearTimeout(this.#O),H.#J===this)H.#J=null}#P(){return this.firstElementChild}#C(){this.#E?.disconnect(),this.#E=null}#S(){if(this.#I(),this.action==="manual")return;let Q=this.#P();if(!Q){if(!this.#E&&typeof MutationObserver<"u")this.#E=new MutationObserver(()=>{if(this.#P())this.#C(),this.#S()}),this.#E.observe(this,{childList:!0});return}if(this.#D=Q,this.action==="hover"){if(!this.isTouchDevice())Q.addEventListener("pointerenter",this.#X),Q.addEventListener("pointerleave",this.#W);Q.addEventListener("touchstart",this.#G,{passive:!0}),Q.addEventListener("touchmove",this.#U,{passive:!0}),Q.addEventListener("touchend",this.#L,{passive:!0}),Q.addEventListener("touchcancel",this.#F,{passive:!0}),Q.addEventListener("focus",this.#N),Q.addEventListener("blur",this.#K)}else if(this.action==="click")Q.addEventListener("click",this.#X),Q.addEventListener("touchstart",this.#X,{passive:!0})}#I(){let Q=this.#D;if(!Q)return;if(this.action==="hover")Q.removeEventListener("pointerenter",this.#X),Q.removeEventListener("pointerleave",this.#W),Q.removeEventListener("touchstart",this.#G),Q.removeEventListener("touchmove",this.#U),Q.removeEventListener("touchend",this.#L),Q.removeEventListener("touchcancel",this.#F),Q.removeEventListener("focus",this.#N),Q.removeEventListener("blur",this.#K);else if(this.action==="click")Q.removeEventListener("click",this.#X),Q.removeEventListener("touchstart",this.#X);this.#D=null}setup(){this.style.display="contents"}render(){this.destroy();let Q=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Z=document.createElement("span");if(this.popup=document.createElement("dialog",{is:"fig-popup"}),this.popup.setAttribute("is","fig-popup"),this.popup.setAttribute("variant","tooltip"),this.popup.setAttribute("data-tooltip-managed",""),this.popup.setAttribute("role","tooltip"),this.popup.setAttribute("closedby","closerequest"),Q)this.popup.setAttribute("popover","manual");let $=g();this.popup.setAttribute("id",$);let J=this.getAttribute("theme");if(J)this.popup.setAttribute("theme",J);let j=this.getAttribute("pointer");if(j!==null)this.popup.setAttribute("pointer",j);if(this.popup.append(Z),Z.innerText=this.getAttribute("text")??"",this.firstElementChild){let q=new Set((this.firstElementChild.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));q.add($),this.firstElementChild.setAttribute("aria-describedby",[...q].join(" "))}if(Q)(j0()??document.body).append(this.popup);else{let q=this.closest("dialog");if(q&&q.open)q.append(this.popup);else(j0()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.#A(this.popup.id),this.popup.hidePopup?.(),this.popup.remove(),this.popup=null}#A(Q){let Z=this.firstElementChild;if(!Z||!Q)return;let $=Z.getAttribute("aria-describedby");if(!$)return;let J=$.split(/\s+/).filter((j)=>j&&j!==Q).join(" ");if(J)Z.setAttribute("aria-describedby",J);else Z.removeAttribute("aria-describedby")}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#Y);document.addEventListener("mousedown",this.#_,!0),document.addEventListener("keydown",this.#B,!0)}get#k(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#T(){let Q=Date.now(),Z=H.#$;if(this.action==="hover"&&H.#J)return!0;if(H.#Z&&Q-H.#Z<Z)return!0;if(H.#Q&&Q-H.#Q<Z)return!0;return!1}showDelayedPopup(){if(this.#k)return;if(clearTimeout(this.timeout),this.#T()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#M&&!this.#M.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&H.#J&&H.#J!==this)H.#J.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")H.#J=this;H.#Z=Date.now()}hidePopup(){if(this.#k)return;clearTimeout(this.timeout),clearTimeout(this.#O);let Q=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,H.#J===this)H.#J=null;if(Q)H.#Q=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#f(Q){if(!this.#R)this.hidePopup()}#y(Q){if(this.action==="hover")this.#R=!0,clearTimeout(this.#O),this.showDelayedPopup()}#g(Q){if(this.action==="hover"&&this.#R)clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#R=!1,this.hidePopup()},150)}#h(Q){if(this.action==="hover"&&this.#R)clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#R=!1,this.hidePopup()},300)}#w(Q){if(this.action==="hover"&&this.#R)this.#R=!1,clearTimeout(this.#O),this.hidePopup()}#V(Q){if(!this.isOpen&&!this.popup||Q.key!=="Escape")return;Q.preventDefault(),this.hidePopup(),this.firstElementChild?.focus?.()}static get observedAttributes(){return["action","delay","open","pointer","show","text","theme"]}get text(){return this.getAttribute("text")??""}set text(Q){this.setAttribute("text",Q)}#b(Q){if(!this.popup)return;let Z=this.popup.firstElementChild??this.popup.firstChild;if(!Z)return;Z.innerText=Q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null)this.removeAttribute("open");else this.setAttribute("open","true")}attributeChangedCallback(Q,Z,$){if(Q==="action"){if(this.#I(),Z==="click")document.body?.removeEventListener("click",this.#Y);if(this.action=$||"hover",this.isConnected){if(this.#S(),this.action==="click")document.body?.addEventListener("click",this.#Y)}}if(Q==="delay"){let J=parseInt($);this.delay=!isNaN(J)?J:500}if(Q==="open")if($!==null&&$!=="false")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(Q==="show")if($!==null&&$!=="false")this.showPopup();else this.hidePopup();if(Q==="text")this.#b($??"");if(Q==="pointer"){if(this.popup)if($!==null)this.popup.setAttribute("pointer",$);else this.popup.removeAttribute("pointer")}if(Q==="theme"){if(this.popup)if($)this.popup.setAttribute("theme",$);else this.popup.removeAttribute("theme")}}#x(Q){if(!this.isOpen)return;let Z=Q.target;if(this.popup&&this.popup.contains(Z))return;if(Z.tagName==="SELECT"||Z.hasAttribute("popover")||Z.closest("dialog"))this.hidePopup()}static#u(){if(H.#j)return;H.#j=!0;let Q=()=>{H.dismissHoverTooltips()},Z=()=>{H.#v()};document.documentElement.addEventListener("mouseleave",Q),document.addEventListener("mouseout",($)=>{if($.relatedTarget)return;Q()}),document.addEventListener("scroll",Z,{capture:!0,passive:!0}),window.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("resize",Z,{passive:!0});try{let $=window.frameElement;if($)$.addEventListener("mouseleave",Q)}catch{}window.addEventListener("message",($)=>{if($?.data?.type!=="figui:dismiss-tooltips")return;if(window.parent!==window&&$.source!==window.parent)return;Q()})}static dismissHoverTooltips(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof H))continue;if(Q.action!=="hover")continue;if(Q.#k)continue;if(Q.#H=!0,setTimeout(()=>{let Z=Q.#D;if(Z!==document.activeElement&&!Z?.matches?.(":focus, :focus-within"))Q.#H=!1},0),Q.isOpen||Q.timeout)Q.hidePopup()}for(let Q of Array.from(H.#q))H.hide(Q)}static#m=new WeakMap;static#v(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof H))continue;if(Q.#k)continue;if(Q.isOpen||Q.timeout)Q.hidePopup()}for(let Q of Array.from(H.#q))H.hide(Q)}static show(Q,Z,$={}){H.#u(),H.hide(Q);let J=$.delay??500,q=Date.now()-H.#Z<H.#$?0:J,_={timeout:null,popup:null};H.#m.set(Q,_),H.#q.add(Q),_.timeout=setTimeout(()=>{let X=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Y=document.createElement("dialog",{is:"fig-popup"});if(Y.setAttribute("is","fig-popup"),Y.setAttribute("variant","tooltip"),Y.setAttribute("data-tooltip-managed",""),Y.setAttribute("role","tooltip"),Y.setAttribute("closedby","closerequest"),X)Y.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=Z,Y.append(K),X)(j0()??document.body).append(Y);else{let G=Q.closest?.("dialog");if(G&&G.open)G.append(Y);else(j0()??document.body).append(Y)}Y.anchor=Q,Y.open=!0,_.popup=Y,H.#Z=Date.now()},q)}static hide(Q){let Z=H.#m.get(Q);if(!Z)return;if(clearTimeout(Z.timeout),Z.popup)Z.popup.remove(),H.#Q=Date.now();H.#m.delete(Q),H.#q.delete(Q)}}z("fig-tooltip",H);class y0 extends HTMLElement{static observedAttributes=["position","tail"];#Z=null;#Q=null;#$=null;connectedCallback(){this.#Z=this.textContent,c(this,()=>{this.#J(),this.#j()})}disconnectedCallback(){this.#q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(this.#Z===null)return;this.#J()}#J(){let Q=this.getAttribute("position")||"right",Z=this.#Z||"";if(Q==="middle"){let $=this.getAttribute("tail"),J;if($){let _=Z.lastIndexOf($);J=_>0?_:Math.ceil(Z.length/2)}else J=Math.ceil(Z.length/2);this.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=Z.slice(0,J);let q=document.createElement("span");q.className="end",q.textContent=Z.slice(J),this.appendChild(j),this.appendChild(q)}else this.textContent=Z}#j(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;H.show(this,this.#Z)},this.#$=()=>{H.hide(this)},this.addEventListener("pointerenter",this.#Q),this.addEventListener("pointerleave",this.#$)}#q(){if(this.#Q)this.removeEventListener("pointerenter",this.#Q);if(this.#$)this.removeEventListener("pointerleave",this.#$);H.hide(this)}}z("fig-truncate",y0);class w0 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();c(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._setupIframeDismissListeners(),this._syncA11y()}),window.addEventListener("message",this._boundIframeMessage)}disconnectedCallback(){this._figInit(),this._removeDragListeners(),this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize(),this._teardownIframeDismissListeners(),this.removeEventListener("close",this._boundRestoreFocus)}_captureFocusBeforeOpen(){let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}_restoreFocus(){let Q=this._previousFocus;if(this._previousFocus=null,!Q?.isConnected)return;let Z=document.activeElement;if(Z&&Z!==document.body&&!this.contains(Z))return;requestAnimationFrame(()=>Q.focus?.())}_assignStackingOrder(){this.style.zIndex=String(I0()+1)}_clearStackingOrder(){this.style.zIndex=""}show(){return this._captureFocusBeforeOpen(),this._assignStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),H.dismissHoverTooltips(),super.show()}showModal(){return this._captureFocusBeforeOpen(),this._clearStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),H.dismissHoverTooltips(),super.showModal()}close(...Q){let Z=super.close(...Q);return this._clearStackingOrder(),Z}_handleIframeMouseLeave(Q){let Z=Q?.currentTarget;if(!(Z instanceof HTMLIFrameElement))return;try{Z.contentWindow?.postMessage({type:"figui:dismiss-tooltips"},"*")}catch{}}_syncIframeDismissListeners(){for(let Q of this.querySelectorAll(":scope > iframe")){if(!(Q instanceof HTMLIFrameElement))continue;if(Q.dataset.figuiDismissBound==="true")continue;Q.dataset.figuiDismissBound="true",Q.addEventListener("mouseleave",this._boundIframeMouseLeave)}}_setupIframeDismissListeners(){if(this._syncIframeDismissListeners(),this._iframeDismissMutationObserver)return;this._iframeDismissMutationObserver=new MutationObserver(()=>{this._syncIframeDismissListeners()}),this._iframeDismissMutationObserver.observe(this,{childList:!0,subtree:!1})}_teardownIframeDismissListeners(){this._iframeDismissMutationObserver?.disconnect(),this._iframeDismissMutationObserver=null;for(let Q of this.querySelectorAll(":scope > iframe"))Q.removeEventListener("mouseleave",this._boundIframeMouseLeave),delete Q.dataset.figuiDismissBound}_handleIframeMessage(Q){if(!this.autoresize)return;let Z=Q?.data;if(!Z||Z.type!=="figui:iframe-resize")return;let $=Q.source;if(!$)return;let J=Array.from(this.querySelectorAll("iframe")).find((j)=>j.contentWindow===$);if(!J)return;this._resizeForIframe(J,Z)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let Q of this.children)try{this._resizeObserver.observe(Q)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((Q)=>{for(let Z of Q)Z.addedNodes?.forEach(($)=>{if($ instanceof Element&&$.parentElement===this)try{this._resizeObserver?.observe($)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(Q){let Z=window.getComputedStyle(this),$=parseFloat(Z.paddingTop||"0")+parseFloat(Z.paddingBottom||"0")+parseFloat(Z.borderTopWidth||"0")+parseFloat(Z.borderBottomWidth||"0"),J=0,j=parseFloat(Z.rowGap||Z.gap||"0")||0,q=0;for(let _ of this.children){let X=_.getBoundingClientRect();if(X.height===0)continue;if(q+=1,_===Q)continue;let Y=window.getComputedStyle(_),K=parseFloat(Y.marginTop||"0")+parseFloat(Y.marginBottom||"0");J+=X.height+K}if(j&&q>1)J+=j*(q-1);return $+J}_resizeForIframe(Q,Z){if(typeof Z.height!=="number"||!(Z.height>0))return;let $=this._computeChrome(Q);this.style.height=`${Math.ceil(Z.height+$)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){if(this.querySelector("fig-header[dialog-header]"))return;let Q=document.createElement("fig-header");Q.setAttribute("dialog-header",""),Q.setAttribute("data-auto","");let Z=document.createElement("h3");Z.textContent=this.getAttribute("title")||"Dialog";let $=document.createElement("fig-tooltip");$.setAttribute("text","Close");let J=document.createElement("fig-button");J.setAttribute("variant","ghost"),J.setAttribute("icon",""),J.setAttribute("aria-label","Close dialog"),J.setAttribute("close-dialog",""),J.appendChild(u("close")),$.appendChild(J),Q.appendChild(Z),Q.appendChild($),this.prepend(Q)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close dialog");Q.removeEventListener("click",this._boundClose),Q.addEventListener("click",this._boundClose)})}_syncA11y(){if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let Q=this.querySelector("fig-header[dialog-header] h1, fig-header[dialog-header] h2, fig-header[dialog-header] h3, fig-header[dialog-header] h4, fig-header[dialog-header] h5, fig-header[dialog-header] h6");if(Q){let Z=Q.getAttribute("id")||g();Q.setAttribute("id",Z),this.setAttribute("aria-labelledby",Z)}}}_applyPosition(){let Q=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let Z=Q.includes("top"),$=Q.includes("bottom"),J=Q.includes("left"),j=Q.includes("right"),q=Q.includes("center")&&!Z&&!$,_=Q.includes("center")&&!J&&!j;if(Z)this.style.top=`${this._offset}px`;else if($)this.style.bottom=`${this._offset}px`;else if(q)this.style.top="0",this.style.bottom="0";if(J)this.style.left=`${this._offset}px`;else if(j)this.style.right=`${this._offset}px`;else if(_)this.style.left="0",this.style.right="0";if(q&&_)this.style.margin="auto";else if(q)this.style.marginTop="auto",this.style.marginBottom="auto";else if(_)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let Q=this.getAttribute("handle"),Z=Q?this.querySelector(Q):this.querySelector("fig-header, header");if(Z)Z.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}_isInteractiveElement(Q){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(q)=>Z.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!$.includes(q.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}_handlePointerUp(Q){if(this._isDragging){if(this.hasPointerCapture?.(Q.pointerId))this.releasePointerCapture(Q.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),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Q==="autoresize"&&this.isConnected)this._syncAutoResize();if(Q==="drag")if(this.drag=$!==null&&$!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let J=this.querySelector("fig-header, header");if(J)J.style.cursor=""}if(Q==="position"&&this._positionInitialized)this._applyPosition();if(Q==="modal"){let J=this.modal;if(this.modal=$!==null&&$!=="false",this.open&&J!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(Q==="closedby")this.closedby=$||"any";if(Q==="title"){let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";this._syncA11y()}if(Q==="aria-label"||Q==="aria-labelledby")this._syncA11y()}}M0("fig-dialog",w0,{extends:"dialog"});class v0 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._boundHandleClose=this.handleClose.bind(this)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast();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((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close notification");Q.removeEventListener("click",this._boundHandleClose),Q.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto";let Q=Number.parseFloat(this.getAttribute("offset")),Z=Number.isFinite(Q)?Q:this._defaultOffset;this.style.bottom=`${Z}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let Q=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger",Z=Q?"alert":"status",$=Q?"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")}startAutoClose(){this.clearAutoClose();let Q=parseInt(this.getAttribute("duration")??"5000");if(Q>0)this._autoCloseTimer=setTimeout(()=>this.hideToast(),Q)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}_resolveAutoTheme(){if(this.getAttribute("theme")!=="auto")return;let Q=getComputedStyle(document.documentElement).colorScheme||"";this.style.colorScheme=Q.includes("dark")?"light":"dark"}showToast(){let Q=this._toastVisible;this.syncLiveRegion(),this._resolveAutoTheme(),this._syncingOpen=!0;try{if(!this.open)this.show()}finally{this._syncingOpen=!1}if(this._toastVisible=!0,this.applyPosition(),this.startAutoClose(),!Q)this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){let Q=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,Q)this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Z===$)return;if(!this.isConnected)return;if(this._syncingOpen)return;if(Q==="offset")this.applyPosition();if(Q==="open")if($!==null&&$!=="false")this.showToast();else this.hideToast();if(Q==="duration"&&this._toastVisible)this.startAutoClose();if(Q==="theme")if($==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme");if(Q==="theme"||Q==="live")this.syncLiveRegion()}}M0("fig-toast",v0,{extends:"dialog"});class g0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;_previousFocus=null;_boundDocumentKeydown;_boundNativeClose;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{let Z=Q.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this),this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this),this._boundNativeClose=this.handleNativeClose.bind(this)}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._previousFocus>"u")this._previousFocus=null;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{let Z=Q.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this);if(typeof this._boundDocumentKeydown!=="function")this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this);if(typeof this._boundNativeClose!=="function")this._boundNativeClose=this.handleNativeClose.bind(this)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!(this.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(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else if(Q&&typeof Q.getBoundingClientRect==="function")this._anchorRef=Q;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role",this.getAttribute("variant")==="tooltip"?"tooltip":"dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this.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(Q,Z,$){if(this.ensureInitialized(),Z===$)return;if(Q==="open"){if($==="false"){this.open=!1;return}if($===null){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=$!==null&&$!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(I0()+1),this.captureFocusBeforeOpen();let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),Z=this.shouldAutoReposition();if(Z)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(J){Q=!1}if(!Q&&!super.open)try{this.show()}catch(J){}if(Z&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.addEventListener("keydown",this._boundDocumentKeydown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let $=this.resolveAnchor();if($?.classList)$.classList.add("has-popup-open");if(this.getAttribute("variant")!=="tooltip")H.dismissHoverTooltips()}hidePopup(){let Q=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),Z=this.resolveAnchor();if(Z?.classList)Z.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch($){}if(this.matches?.(":open"))try{this.close()}catch($){}if(Q)this.restoreFocusAfterClose()}shouldRestoreFocus(){return this.getAttribute("variant")!=="tooltip"}captureFocusBeforeOpen(){if(!this.shouldRestoreFocus())return;let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}restoreFocusAfterClose(){if(!this.shouldRestoreFocus()){this._previousFocus=null;return}let Q=this.resolveAnchor(),Z=this._previousFocus?.isConnected?this._previousFocus:Q instanceof HTMLElement?Q:null;if(this._previousFocus=null,!Z?.isConnected)return;let $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Z.focus?.())}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q===!1||Q==="false"||Q===null)this.setAttribute("autoresize","false");else if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.setAttribute("autoresize","false")}handleNativeClose(){if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}setupObservers(){this.teardownObservers();let Q=this.resolveAnchor();if(Q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(Q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(Q){if(!Q)return null;let Z=Q.getBoundingClientRect();return{x:Z.x,y:Z.y,width:Z.width,height:Z.height}}hasRectChanged(Q,Z,$=0.25){if(!Q&&!Z)return!1;if(!Q||!Z)return!0;return Math.abs(Q.x-Z.x)>$||Math.abs(Q.y-Z.y)>$||Math.abs(Q.width-Z.width)>$||Math.abs(Q.height-Z.height)>$}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let Z=this.resolveAnchor(),$=this.readRectSnapshot(Z),J=this.shouldAutoReposition();if(J&&this.hasRectChanged(this._lastAnchorRect,$))this._lastAnchorRect=$,this.queueReposition();else if(!J)this._lastAnchorRect=$;this._anchorTrackRAF=requestAnimationFrame(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!(this.matches?.(":open")||this.matches?.(":popover-open")))return;let Z=this.getAttribute("closedby");if(Z==="none"||Z==="closerequest")return;let $=Q.target;if(!($ instanceof Node))return;let J=typeof Q.composedPath==="function"?Q.composedPath():[];if(J.includes(this))return;if(this.contains($))return;let j=this.resolveAnchor();if(j&&(J.includes(j)||j.contains?.($)))return;if(this.isInsideDescendantPopup($))return;this.open=!1}handleDocumentKeydown(Q){if(Q.key!=="Escape"||Q.defaultPrevented)return;if(!this.open)return;if(this.getAttribute("role")==="menu")return;if(this.getAttribute("closedby")==="none")return;let J=Array.from(document.querySelectorAll('dialog[is="fig-popup"][open]')).filter((j)=>j.open).map((j)=>({popup:j,z:Number.parseInt(getComputedStyle(j).zIndex||"0",10)||0})).sort((j,q)=>j.z-q.z).at(-1)?.popup;if(J&&J!==this)return;Q.preventDefault(),this.open=!1}isInsideDescendantPopup(Q){let Z=Q.closest?.('dialog[is="fig-popup"]');if(!Z||Z===this)return!1;let $=Z,J=new Set;while($&&!J.has($)){J.add($);let j=$.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;$=j.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}isInteractiveElement(Q){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(q)=>Z.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!$.includes(q.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging){if(this.hasPointerCapture?.(Q.pointerId))this.releasePointerCapture(Q.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),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let Z=this.parentElement;try{if(Z?.querySelector){let $=Z.querySelector(Q);if($&&!this.contains($))return $}return document.querySelector(Q)}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"]),j="top",q="center",_=null;if(Z.length>=2){if($.has(Z[0]))j=Z[0];if(J.has(Z[1]))q=Z[1];return{vertical:j,horizontal:q,shorthand:_}}if(Z.length===1){let X=Z[0];if(X==="top"||X==="bottom")j=X,_=X;else if(X==="left"||X==="right")q=X,_=X;else if(X==="center")j="center",q="center"}return{vertical:j,horizontal:q,shorthand:_}}normalizeOffsetToken(Q,Z="0px"){if(!Q)return Z;let $=Q.trim();if(!$)return Z;if(/^-?\d+(\.\d+)?$/.test($))return`${$}px`;return $}measureLengthPx(Q,Z="x"){if(!Q)return 0;let $=this.normalizeOffsetToken(Q,"0px");if($.endsWith("px")){let q=parseFloat($);return Number.isFinite(q)?q:0}let J=document.createElement("div");if(J.style.position="fixed",J.style.visibility="hidden",J.style.pointerEvents="none",J.style.left="0",J.style.top="0",J.style.margin="0",J.style.padding="0",J.style.border="0",Z==="x")J.style.width=$,J.style.height="0";else J.style.height=$,J.style.width="0";document.body.appendChild(J);let j=J.getBoundingClientRect();return J.remove(),Z==="x"?j.width:j.height}parseOffset(){let Z=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),$=this.normalizeOffsetToken(Z[0],"0px"),J=this.normalizeOffsetToken(Z[1],"0px");return{xToken:$,yToken:J,xPx:this.measureLengthPx($,"x"),yPx:this.measureLengthPx(J,"y")}}parseViewportMargins(){let Z=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((J)=>!Number.isNaN(J)),$=8;if(Z.length===0)return{top:8,right:8,bottom:8,left:8};if(Z.length===1)return{top:Z[0],right:Z[0],bottom:Z[0],left:Z[0]};if(Z.length===2)return{top:Z[0],right:Z[1],bottom:Z[0],left:Z[1]};if(Z.length===3)return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[1]};return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[3]}}getPlacementCandidates(Q,Z,$){let J={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if($){let q=$==="left"||$==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:Z,s:$},{v:Q,h:Z,s:J[$]},{v:Q,h:Z,s:q[0]},{v:Q,h:Z,s:q[1]}]}if(Q==="center")return[{v:"center",h:Z,s:null},{v:"center",h:J[Z],s:null},{v:"top",h:Z,s:null},{v:"bottom",h:Z,s:null},{v:"top",h:J[Z],s:null},{v:"bottom",h:J[Z],s:null}];if(Z==="center")return[{v:Q,h:"center",s:null},{v:J[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:J[Q],h:"left",s:null},{v:J[Q],h:"right",s:null}];return[{v:Q,h:Z,s:null},{v:J[Q],h:Z,s:null},{v:Q,h:J[Z],s:null},{v:J[Q],h:J[Z],s:null}]}computeCoords(Q,Z,$,J,j,q){let _,X;if(q==="left"||q==="right")return X=q==="left"?Q.left-Z.width-j.xPx:Q.right+j.xPx,_=Q.top,{top:_,left:X};if(q==="top"||q==="bottom")return _=q==="top"?Q.top-Z.height-j.yPx:Q.bottom+j.yPx,X=Q.left,{top:_,left:X};if($==="top")_=Q.top-Z.height-j.yPx;else if($==="bottom")_=Q.bottom+j.yPx;else _=Q.top+(Q.height-Z.height)/2;if($==="center")if(J==="left")X=Q.left-Z.width-j.xPx;else if(J==="right")X=Q.right+j.xPx;else X=Q.left+(Q.width-Z.width)/2;else if(J==="left")X=Q.left+j.xPx;else if(J==="right")X=Q.right-Z.width-j.xPx;else X=Q.left+(Q.width-Z.width)/2;return{top:_,left:X}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,Z,$){if($==="top")return"top";if($==="bottom")return"bottom";if($==="left")return"left";if($==="right")return"right";if(Q!=="center")return Q;if(Z!=="center")return Z;return"top"}lengthToPx(Q,Z=0){let $=getComputedStyle(this),J=String(Q||"").trim(),j=parseFloat(J);if(!Number.isFinite(j))return Z;if(J.endsWith("rem"))return j*parseFloat(getComputedStyle(document.documentElement).fontSize);if(J.endsWith("em"))return j*parseFloat($.fontSize);return j}radiusForSide(Q){let Z=getComputedStyle(this),$=(J)=>this.lengthToPx(J,0);if(Q==="top")return Math.max($(Z.borderTopLeftRadius),$(Z.borderTopRightRadius));if(Q==="bottom")return Math.max($(Z.borderBottomLeftRadius),$(Z.borderBottomRightRadius));if(Q==="left")return Math.max($(Z.borderTopLeftRadius),$(Z.borderBottomLeftRadius));if(Q==="right")return Math.max($(Z.borderTopRightRadius),$(Z.borderBottomRightRadius));return 0}getBeakEdgeInset(Q){let Z=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(Q)+Z/2)}tracksAnchorBeak(){let Q=this.getAttribute("variant");return Q==="popover"||Q==="tooltip"}getViewportBounds(Q){let Z=window.visualViewport,$=Z?.width??window.innerWidth,J=Z?.height??window.innerHeight,j=Z?.offsetLeft??0,q=Z?.offsetTop??0;return{minLeft:j+Q.left,minTop:q+Q.top,maxRight:j+$-Q.right,maxBottom:q+J-Q.bottom}}clampToViewport(Q,Z,$){let J=this.getViewportBounds($),j=J.maxRight-Z.width,q=J.maxBottom-Z.height;return{left:Math.min(j,Math.max(J.minLeft,Q.left)),top:Math.min(q,Math.max(J.minTop,Q.top))}}resolveCoordsAtViewport(Q,Z,$,J,j){let{left:q,top:_}=this.clampToViewport($,Z,j);if(!Q||!this.tracksAnchorBeak())return{left:q,top:_};let X=this.oppositeSide(J),Y=this.getViewportBounds(j),K=Y.maxRight-Z.width,G=Y.minLeft,N=Y.maxBottom-Z.height,W=Y.minTop;if(X==="top"||X==="bottom"){let O=this.getBeakEdgeInset(X),B=Q.left+Q.width/2,L=B-q;if(L<O)q=B-O;else if(L>Z.width-O)q=B-(Z.width-O);q=Math.min(K,Math.max(G,q))}else if(X==="left"||X==="right"){let O=this.getBeakEdgeInset(X),B=Q.top+Q.height/2,L=B-_;if(L<O)_=B-O;else if(L>Z.height-O)_=B-(Z.height-O);_=Math.min(N,Math.max(W,_))}return{left:q,top:_}}canPointAtAnchor(Q,Z,$,J,j){if(!Q||!this.tracksAnchorBeak())return!0;let q=this.oppositeSide(j),_=this.getBeakEdgeInset(q);if(q==="top"||q==="bottom"){let Y=Q.left+Q.width/2-$;return Y>=_-0.5&&Y<=Z.width-_+0.5}let X=Q.top+Q.height/2-J;return X>=_-0.5&&X<=Z.height-_+0.5}updatePopoverBeak(Q,Z,$,J,j){if(!this.tracksAnchorBeak()||!Q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let q=this.oppositeSide(j);this.setAttribute("data-beak-side",q);let _=Q.left+Q.width/2,X=Q.top+Q.height/2,Y=this.getBoundingClientRect(),K=Y.width>0&&Y.height>0?Y:Z,G=K.left,N=K.top,W=this.getBeakEdgeInset(q),O;if(q==="top"||q==="bottom"){O=_-G;let B=W,L=Math.max(B,K.width-W);O=Math.min(L,Math.max(B,O))}else{O=X-N;let B=W,L=Math.max(B,K.height-W);O=Math.min(L,Math.max(B,O))}this.style.setProperty("--fig-popup-beak-offset",`${O}px`)}overflowScore(Q,Z,$){let J=this.getViewportBounds($),j=Q.left+Z.width,q=Q.top+Z.height,_=Math.max(0,J.minLeft-Q.left),X=Math.max(0,J.minTop-Q.top),Y=Math.max(0,j-J.maxRight),K=Math.max(0,q-J.maxBottom);return _+X+Y+K}fits(Q,Z,$){return this.overflowScore(Q,Z,$)===0}clamp(Q,Z,$,J=null,j="top"){if(J)return this.resolveCoordsAtViewport(J,Z,Q,j,$);return this.clampToViewport(Q,Z,$)}primaryAxisOverflowPenalty(Q,Z,$,J){let j=this.getViewportBounds($),q=0;if(J==="top")q=Math.max(0,j.minTop-Q.top);else if(J==="bottom")q=Math.max(0,Q.top+Z.height-j.maxBottom);else if(J==="left")q=Math.max(0,j.minLeft-Q.left);else if(J==="right")q=Math.max(0,Q.left+Z.width-j.maxRight);return q>0?1000+q:0}placementScore(Q,Z,$,J,j){let q=this.resolveCoordsAtViewport(Q,Z,$,J,j),_=this.overflowScore(q,Z,j);if(_+=this.primaryAxisOverflowPenalty($,Z,j,J),Q&&!this.canPointAtAnchor(Q,Z,q.left,q.top,J))_+=1e4;return{score:_,resolved:q}}applyPopupPosition(Q,Z,$,J,j){let q=this.resolveCoordsAtViewport(Q,Z,$,J,j);this.style.left=`${q.left}px`,this.style.top=`${q.top}px`,this.updatePopoverBeak(Q,Z,q.left,q.top,J)}positionPopup(){if(!this.open)return;let Q=this.getBoundingClientRect(),Z=this.parseOffset(),{vertical:$,horizontal:J,shorthand:j}=this.parsePosition(),q=this.resolveAnchor(),_=this.parseViewportMargins();if(!q){this.updatePopoverBeak(null,Q,0,0,"top");let W=this.getViewportBounds(_),O={left:W.minLeft+(W.maxRight-W.minLeft-Q.width)/2,top:W.minTop+(W.maxBottom-W.minTop-Q.height)/2},B=this.clampToViewport(O,Q,_);this.style.left=`${B.left}px`,this.style.top=`${B.top}px`;return}let X=q.getBoundingClientRect(),Y=this.getPlacementCandidates($,J,j),K=null,G="top",N=Number.POSITIVE_INFINITY;for(let{v:W,h:O,s:B}of Y){let L=this.computeCoords(X,Q,W,O,Z,B),T=this.getPlacementSide(W,O,B),{score:R,resolved:A}=this.placementScore(X,Q,L,T,_);if(B){let M=this.getViewportBounds(_);if((B==="left"||B==="right"?L.left>=M.minLeft&&L.left+Q.width<=M.maxRight:L.top>=M.minTop&&L.top+Q.height<=M.maxBottom)&&R<1e4){this.applyPopupPosition(X,Q,L,T,_);return}}else if(R===0){this.applyPopupPosition(X,Q,L,T,_);return}if(R<N)N=R,K=A,G=T}this.applyPopupPosition(X,Q,K||{left:0,top:0},G,_)}queueReposition(){if(!this.open||!this.isPopupDisplayed()||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}isPopupDisplayed(){return Boolean(this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"))}}M0("fig-popup",g0,{extends:"dialog"});class h0 extends HTMLElement{#Z;#Q;constructor(){super();this.content=null,this.#Z=!1,this.#Q=this.handleClick.bind(this)}connectedCallback(){if(this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.addEventListener("click",this.#Q),c(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let Q=this.getAttribute("id")||g(),Z=this.content.getAttribute("id")||g();if(this.setAttribute("id",Q),this.content.setAttribute("id",Z),this.setAttribute("aria-controls",Z),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",Q),this.#Z)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}}})}get selected(){return this.#Z}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(F(this,"disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(Q,Z,$){if(Q==="selected"){if(this.#Z=$!==null&&$!=="false",this.setAttribute("aria-selected",this.#Z?"true":"false"),this.setAttribute("tabindex",this.#Z?"0":"-1"),this?.content)this.content.style.display=this.#Z?"block":"none"}if(Q==="disabled")if($!==null&&$!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#Z?"0":"-1")}}z("fig-tab",h0);class b0 extends HTMLElement{#Z;#Q;#$=this.#L.bind(this);#J=null;#j=null;#q=null;#_=null;#Y=!1;#X=new WeakSet;constructor(){super();this.#Z=this.handleClick.bind(this),this.#Q=this.#D.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){if(this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#Q),this.addEventListener("scroll",this.#$),this.#M(),this.#z(),this.#F(),c(this,()=>{let Q=this.getAttribute("value");if(Q)this.#O(Q);if(F(this,"disabled"))this.#W(!0);this.#K(),this.#L(),this.#G(void 0,"auto")})}#W(Q){this.querySelectorAll("fig-tab").forEach(($)=>{if(Q){if(!($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false"))this.#X.add($),$.setAttribute("disabled","");$.setAttribute("aria-disabled","true"),$.setAttribute("tabindex","-1")}else if(this.#X.has($))this.#X.delete($),$.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#K()}#N(){return Array.from(this.querySelectorAll("fig-tab")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#K(){let Q=Array.from(this.querySelectorAll("fig-tab")),Z=Q.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false")||this.#N()[0];Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false";$.setAttribute("tabindex",!J&&$===Z?"0":"-1")})}#G(Q=this.selectedTab,Z="smooth"){let $=Q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#N()[0];if(!$)return;requestAnimationFrame(()=>{if(!this.isConnected||!$.isConnected)return;if(!(this.scrollWidth>this.clientWidth))return;let j=this.getBoundingClientRect(),q=$.getBoundingClientRect(),_=q.left-j.left+this.scrollLeft+q.width/2;this.scrollTo({left:_-this.clientWidth/2,behavior:Z}),this.#L()})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#Q),this.removeEventListener("scroll",this.#$),this.#J?.disconnect(),this.#J=null,this.#j?.disconnect(),this.#j=null,this.#B()}#U(){if(this.#Y)return;let Q=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!Q)return;this.#Y=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#Y=!1}}#L(){a(this,this,"x")}#F(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>this.#L()),this.#j.observe(this)}#z(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>{if(this.#Y)return;this.#U(),this.#M(),this.#K(),requestAnimationFrame(()=>{this.#L(),this.#G()})}),this.#J.observe(this,{childList:!0,subtree:!1})}#B(){this.#q?.remove(),this.#_?.remove(),this.#q=null,this.#_=null,this.classList.remove("overflow-start","overflow-end")}#M(){if(this.#q&&this.#_&&this.contains(this.#q)&&this.contains(this.#_))return;this.#q?.remove(),this.#_?.remove();let Q=X0({owner:"tabs",onStart:()=>i(this,"x",-1),onEnd:()=>i(this,"x",1)});this.#q=Q.start,this.#_=Q.end,this.prepend(this.#q),this.append(this.#_)}#D(Q){let Z=this.#N();if(!Z.length)return;let $=Z.findIndex((j)=>F(j,"selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=$>0?$-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=$<Z.length-1?$+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;default:return}if(J!==$&&Z[J]){this.querySelectorAll("fig-tab").forEach((q)=>q.removeAttribute("selected")),this.selectedTab=Z[J],Z[J].setAttribute("selected","true");let j=this.#H(Z[J]);if(j)this.setAttribute("value",j);else this.removeAttribute("value");Z[J].focus(),this.#K(),this.#G(Z[J]),this.#E()}}get value(){return this.#H(this.selectedTab)}set value(Q){this.setAttribute("value",Q)}#E(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#H(Q){if(!Q)return"";let Z=Q.getAttribute("value");if(Z!==null)return Z;return Q.textContent?.trim()||""}#O(Q){let Z=this.querySelectorAll("fig-tab");for(let $ of Z)if(this.#H($)===Q)this.selectedTab=$,$.setAttribute("selected","true");else $.removeAttribute("selected");this.#K(),this.#G(this.selectedTab)}attributeChangedCallback(Q,Z,$){switch(Q){case"value":if($!==Z)this.#O($);break;case"disabled":this.#W($!==null&&$!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=Q.target.closest("fig-tab");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;let $=this.selectedTab,J=this.value,j=this.querySelectorAll("fig-tab");for(let _ of j)if(_===Z)this.selectedTab=_,_.setAttribute("selected","true");else _.removeAttribute("selected");let q=this.#H(Z);if(q)this.setAttribute("value",q);else this.removeAttribute("value");if(this.#K(),this.#G(Z),$!==Z||J!==this.value)this.#E()}}z("fig-tabs",b0);class m0 extends HTMLElement{#Z;#Q;#$;constructor(){super();this.#$=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#J(),this.addEventListener("click",this.#$)}disconnectedCallback(){this.removeEventListener("click",this.#$)}handleClick(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.closest("fig-segmented-control");if(Q&&Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#Z}set value(Q){this.#Z=Q,this.setAttribute("value",Q)}get selected(){return this.#Q}set selected(Q){this.#Q=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value","disabled"]}#J(){let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",Q?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",Q?"0":"-1")}attributeChangedCallback(Q,Z,$){switch(Q){case"value":this.#Z=$;break;case"selected":this.#Q=$,this.#J();break;case"disabled":this.#J();break}}}z("fig-segment",m0);class c0 extends HTMLElement{#Z=null;#Q=this.handleClick.bind(this);#$=this.#F.bind(this);#J=null;#j=null;#q=0;#_=!1;#Y=!1;#X=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.#Q),this.addEventListener("keydown",this.#$),this.#P(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#R(),this.#E(),c(this,()=>{this.#O({enforceFallback:!0}),this.#H(),this.#M({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#$),this.#J?.disconnect(),this.#J=null,this.#j?.disconnect(),this.#j=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#_=!1,this.#Y=!1}get selectedSegment(){return this.#Z}set selectedSegment(Q){let Z=this.querySelectorAll("fig-segment");for(let $ of Z){let J=$===Q,j=F($,"selected");if(J&&!j)$.setAttribute("selected","true");else if(!J&&j)$.removeAttribute("selected")}this.#Z=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#U(),this.#M()}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(Q))}#W(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#N(Q){let Z=Q.getAttribute("value");if(Z!==null){let $=Z.trim();if($.length>0)return $}return Q.textContent?.trim()||""}#K(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false")return Z;return null}#G(){return Array.from(this.querySelectorAll("fig-segment")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#U(){let Q=Array.from(this.querySelectorAll("fig-segment")),Z=Q.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false");Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false",j=$===Z;$.setAttribute("aria-checked",j?"true":"false"),$.setAttribute("tabindex",!J&&j?"0":"-1")})}#L(Q){if(!Q)return;let Z=this.selectedSegment,$=this.value;this.selectedSegment=Q;let J=this.#N(Q);if(J)this.setAttribute("value",J);else this.removeAttribute("value");let j=this.value;if(Z!==Q||$!==j)this.#W(j)}#F(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#G();if(!Z.length)return;let $=Z.findIndex((q)=>F(q,"selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=J>0?J-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=J<Z.length-1?J+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case" ":case"Enter":{let q=Q.target.closest("fig-segment");if(q&&this.contains(q))Q.preventDefault(),this.#L(q);return}default:return}let j=Z[J];this.#L(j),j.focus(),requestAnimationFrame(()=>{if(this.contains(j))j.focus()})}#z(Q){let Z=String(Q??"").trim();if(!Z)return!1;let $=this.querySelectorAll("fig-segment");for(let J of $){let j=this.#N(J);if(!j)continue;if(j===Z)return this.selectedSegment=J,!0}return!1}#B(){let Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#M({forceInstant:Q=!1}={}){if(this.#_=this.#_||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let Z=this.#_;this.#_=!1,this.#D({forceInstant:Z})})}#D({forceInstant:Q=!1}={}){let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#B(),J=this.#Z&&this.contains(this.#Z)?this.#Z:this.#K();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.#Y=!1;return}if(!J){if(this.#Y)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let j=this.getBoundingClientRect(),q=J.getBoundingClientRect();if(j.width<=0||q.width<=0){if(this.#Y)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let _=Math.max(0,q.left-j.left);this.style.setProperty("--seg-indicator-x",`${_}px`),this.style.setProperty("--seg-indicator-w",`${q.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#Y||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#Y=!0}#E(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#M()}),this.#H()}#H(){if(!this.#j)return;this.#j.disconnect(),this.#j.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#j?.observe(Q)})}#O({enforceFallback:Q=!1}={}){if(this.querySelectorAll("fig-segment").length===0){this.#Z=null,this.#M({forceInstant:!0});return}let $=this.getAttribute("value"),J=$?.trim()??"";if($!==null){if(J!==$){this.setAttribute("value",J);return}if(J&&this.#z(J))return}let j=this.#K();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=this.#G()[0]||null}#R(){this.#J?.disconnect(),this.#J=new MutationObserver((Q)=>{let Z=!1;for(let $ of Q){if($.type==="childList"){Z=!0;break}if($.type==="attributes"&&$.target instanceof HTMLElement&&$.target.tagName.toLowerCase()==="fig-segment"&&($.attributeName==="value"||$.attributeName==="selected")){Z=!0;break}if($.type==="characterData"){Z=!0;break}}if(Z)this.#P(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#H(),this.#O({enforceFallback:!0}),this.#U()}),this.#J.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=Q.target.closest("fig-segment");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#L(Z)}#P(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach((Z)=>{if(Q){if(!(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false"))this.#X.add(Z),Z.setAttribute("disabled","");Z.setAttribute("aria-disabled","true")}else if(this.#X.has(Z))this.#X.delete(Z),Z.removeAttribute("disabled"),Z.removeAttribute("aria-disabled")}),this.#U()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled"){this.#P($!==null&&$!=="false"),this.#M({forceInstant:!0});return}if(Q==="value"){this.#O({enforceFallback:!1});return}if(Q==="animated"){if(!this.#B())this.#Y=!1;this.#M({forceInstant:!0});return}if(Q==="sizing")this.#M({forceInstant:!0})}}z("fig-segmented-control",c0);class u0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Z="segments";#Q=0;#$=null;#J=[];#j=null;#q=!1;#_(Q){let Z=Q?.detail;if(typeof Z==="string")return Z;let $=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if($===null||$===void 0)return null;return String($)}#Y(){if(this.#J.length===0)return!1;let Q=this.querySelector(":scope > fig-segmented-control");if(Q){let $=Q.querySelectorAll("fig-segment");if($.length!==this.#J.length)return!1;return Array.from($).every((J,j)=>J.getAttribute("value")===this.#J[j])}let Z=this.querySelector(":scope > fig-dropdown");if(Z){let $=Z.querySelectorAll("option");return $.length===this.#J.length&&Array.from($).every((J,j)=>J.textContent?.trim()===this.#J[j])}return!1}#X(){let Q=this.querySelector(":scope > fig-segmented-control");if(Q)this.#j=Q,this.#Z="segments";else this.#j=this.querySelector(":scope > fig-dropdown"),this.#Z="dropdown";this.#U()}connectedCallback(){if(this.#W(),this.#Y()){this.#X(),this.#F(),c(this,()=>c(this,()=>this.#M()));return}this.#N(),this.#F(),c(this,()=>c(this,()=>this.#M()))}disconnectedCallback(){this.#$?.disconnect(),this.#$=null}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get options(){return this.#J.slice()}set options(Q){if(Array.isArray(Q)){let $=Q.some((J)=>String(J).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",$)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="options"){this.#W(),this.#G();return}if(Q==="value"){this.#U();return}if(Q==="disabled"){this.#L("disabled");return}if(Q==="full"){this.#L("full");return}if(Q==="sizing")this.#L("sizing"),this.#G()}#W(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#J=JSON.parse(Q);return}catch{}let Z=Q.includes(`
37
+ `,this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.button.addEventListener("click",this.#j),this.button.addEventListener("focus",this.#_),this.button.addEventListener("blur",this.#Y)}let Q=this.shadowRoot.querySelector("slot");Q?.removeEventListener("slotchange",this.#q),Q?.addEventListener("slotchange",this.#q),this.removeEventListener("keydown",this.#J),this.addEventListener("keydown",this.#J),this.#Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#F()}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#Q}set selected(Q){this.setAttribute("selected",Q)}#X(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#W(){if(this.#X())return;if(this.type==="toggle")if(this.selected)this.removeAttribute("selected");else this.setAttribute("selected","");if(this.type==="submit"){let Q=this.closest("form");if(Q)if(typeof Q.requestSubmit==="function")Q.requestSubmit();else Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),Z=this.getAttribute("target");if(Q)if(Z)window.open(Q,Z);else window.location.href=Q}}#N(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#K(){let Q=this.#N();if(Q instanceof HTMLSelectElement)return Q;if(Q?.tagName==="FIG-DROPDOWN")return Q.select||Q.querySelector?.("select")||null;return null}#G(Q){if(this.type!=="select")return;if(Q.key!=="Enter")return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;let Z=this.#K();if(!Z||Z.disabled||Z.multiple)return;if(typeof Z.showPicker!=="function")return;Q.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 Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.setAttribute("aria-pressed",Q?"true":"false"),this.button.setAttribute("aria-pressed",Q?"true":"false")}#L(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#$.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.button.removeAttribute(Q);else this.button.setAttribute(Q,Z)})}#F(){if(!this.button)return;let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=Q,this.button instanceof HTMLButtonElement)this.button.disabled=Q,this.button.type="button",this.button.setAttribute("type","button");this.#z(),this.#L(),this.#U()}#z(){let Q=this.#N();if(!Q)return;if(this.#X()){if(!this.#Z.has(Q))this.#Z.set(Q,Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false");Q.setAttribute("disabled","")}else if(this.#Z.has(Q)){let $=this.#Z.get(Q);if(this.#Z.delete(Q),$)Q.setAttribute("disabled","");else Q.removeAttribute("disabled")}}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"type":{let J=(j)=>j==="select"||j==="upload";if(J(Z||"button")!==J($||"button")){this.button=null,this.connectedCallback();break}this.#F();break}case"disabled":this.#F();break;case"selected":this.#Q=$!==null&&$!=="false",this.#U();break;default:this.#L();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#J),this.shadowRoot?.querySelector("slot")?.removeEventListener("slotchange",this.#q)}}z("fig-button",V0);class x0 extends HTMLElement{#Q="Menu";#Z=null;#$;#J;#j;get label(){return this.#Q}set label(Q){this.#Q=Q}#q;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#$=this.#W.bind(this),this.#J=this.#N.bind(this),this.#j=this.#K.bind(this),this.#q=this.slotChange.bind(this)}#_(){this.select.addEventListener("input",this.#$),this.select.addEventListener("change",this.#J),this.select.addEventListener("keydown",this.#j)}#Y(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#X(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){if(this.type=this.getAttribute("type")||"select",this.#Q=this.getAttribute("label")||this.#Q,this.select.setAttribute("aria-label",this.#Q),this.#G(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#q),this.optionsSlot.addEventListener("slotchange",this.#q),this.select.removeEventListener("input",this.#$),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#j),this.#_()}slotChange(){let Q=this.hasAttribute("value"),Z=this.select.options.length>0&&this.select.selectedIndex>=0,$=Q?this.getAttribute("value"):this.type==="dropdown"?this.#Z: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}#W(Q){Q.stopPropagation();let Z=Q.target.selectedOptions?.[0];if(this.#Y(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#X();return}let $=Q.target.value;if(this.type==="dropdown")this.#Z=$;this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}#N(Q){Q.stopPropagation();let Z=Q.target.selectedOptions?.[0];if(this.#Y(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#X();return}let $=this.type==="dropdown"?this.#Z:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,composed:!0}))}#K(Q){if(this.closest('fig-button[type="select"]'))return;if(Q.key!=="Enter"||Q.defaultPrevented)return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(typeof this.select.showPicker!=="function")return;Q.preventDefault();try{this.select.showPicker()}catch{}}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#Z;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#Z=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","label","disabled"]}#G(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=Q}#U(Q){if(this.type==="dropdown")return;if(this.select)this.select.value=Q??""}attributeChangedCallback(Q,Z,$){if(Q==="value")this.#U($);if(Q==="type"){if(this.type=$||"select",this.isConnected)this.slotChange()}if(Q==="label")this.#Q=$||"Menu",this.select.setAttribute("aria-label",this.#Q);if(Q==="disabled")this.#G()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#q),this.select.removeEventListener("input",this.#$),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#j)}}z("fig-dropdown",x0);class H extends HTMLElement{static#Q=0;static#Z=0;static#$=1000;static#J=null;static#j=!1;static#q=new Set;#_;#Y;#X;#W;#N;#K;#G;#U;#L;#F;#z;#B;#M=null;#D=null;#T=null;#H=!1;#O;#R=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#_=this.#x.bind(this),this.#Y=this.hidePopupOutsideClick.bind(this),this.#X=this.showDelayedPopup.bind(this),this.#W=this.#k.bind(this),this.#N=()=>{if(!this.#H)this.showDelayedPopup()},this.#K=()=>{this.#H=!1,this.hidePopup()},this.#G=this.#y.bind(this),this.#U=this.#v.bind(this),this.#L=this.#b.bind(this),this.#F=this.#w.bind(this),this.#B=this.#V.bind(this),this.#z=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(H.#c(),this.setup(),this.#f(),this.setupEventListeners(),this.#M=this.closest("dialog"),this.#M)this.#M.addEventListener("close",this.#z)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#I(),this.#S(),document.removeEventListener("mousedown",this.#_,!0),document.removeEventListener("keydown",this.#B,!0),this.#M)this.#M.removeEventListener("close",this.#z),this.#M=null;if(this.action==="click")document.body.removeEventListener("click",this.#Y);if(clearTimeout(this.#O),H.#J===this)H.#J=null}#P(){return this.firstElementChild}#S(){this.#T?.disconnect(),this.#T=null}#f(){if(this.#I(),this.action==="manual")return;let Q=this.#P();if(!Q){if(!this.#T&&typeof MutationObserver<"u")this.#T=new MutationObserver(()=>{if(this.#P())this.#S(),this.#f()}),this.#T.observe(this,{childList:!0});return}if(this.#D=Q,this.action==="hover"){if(!this.isTouchDevice())Q.addEventListener("pointerenter",this.#X),Q.addEventListener("pointerleave",this.#W);Q.addEventListener("touchstart",this.#G,{passive:!0}),Q.addEventListener("touchmove",this.#U,{passive:!0}),Q.addEventListener("touchend",this.#L,{passive:!0}),Q.addEventListener("touchcancel",this.#F,{passive:!0}),Q.addEventListener("focus",this.#N),Q.addEventListener("blur",this.#K)}else if(this.action==="click")Q.addEventListener("click",this.#X),Q.addEventListener("touchstart",this.#X,{passive:!0})}#I(){let Q=this.#D;if(!Q)return;if(this.action==="hover")Q.removeEventListener("pointerenter",this.#X),Q.removeEventListener("pointerleave",this.#W),Q.removeEventListener("touchstart",this.#G),Q.removeEventListener("touchmove",this.#U),Q.removeEventListener("touchend",this.#L),Q.removeEventListener("touchcancel",this.#F),Q.removeEventListener("focus",this.#N),Q.removeEventListener("blur",this.#K);else if(this.action==="click")Q.removeEventListener("click",this.#X),Q.removeEventListener("touchstart",this.#X);this.#D=null}setup(){this.style.display="contents"}render(){this.destroy();let Q=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Z=document.createElement("span");if(this.popup=document.createElement("dialog",{is:"fig-popup"}),this.popup.setAttribute("is","fig-popup"),this.popup.setAttribute("variant","tooltip"),this.popup.setAttribute("data-tooltip-managed",""),this.popup.setAttribute("role","tooltip"),this.popup.setAttribute("closedby","closerequest"),Q)this.popup.setAttribute("popover","manual");let $=h();this.popup.setAttribute("id",$);let J=this.getAttribute("theme");if(J)this.popup.setAttribute("theme",J);let j=this.getAttribute("pointer");if(j!==null)this.popup.setAttribute("pointer",j);if(this.popup.append(Z),Z.innerText=this.getAttribute("text")??"",this.firstElementChild){let q=new Set((this.firstElementChild.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));q.add($),this.firstElementChild.setAttribute("aria-describedby",[...q].join(" "))}if(Q)(j0()??document.body).append(this.popup);else{let q=this.closest("dialog");if(q&&q.open)q.append(this.popup);else(j0()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.#A(this.popup.id),this.popup.hidePopup?.(),this.popup.remove(),this.popup=null}#A(Q){let Z=this.firstElementChild;if(!Z||!Q)return;let $=Z.getAttribute("aria-describedby");if(!$)return;let J=$.split(/\s+/).filter((j)=>j&&j!==Q).join(" ");if(J)Z.setAttribute("aria-describedby",J);else Z.removeAttribute("aria-describedby")}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#Y);document.addEventListener("mousedown",this.#_,!0),document.addEventListener("keydown",this.#B,!0)}get#E(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#C(){let Q=Date.now(),Z=H.#$;if(this.action==="hover"&&H.#J)return!0;if(H.#Q&&Q-H.#Q<Z)return!0;if(H.#Z&&Q-H.#Z<Z)return!0;return!1}showDelayedPopup(){if(this.#E)return;if(clearTimeout(this.timeout),this.#C()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#M&&!this.#M.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&H.#J&&H.#J!==this)H.#J.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")H.#J=this;H.#Q=Date.now()}hidePopup(){if(this.#E)return;clearTimeout(this.timeout),clearTimeout(this.#O);let Q=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,H.#J===this)H.#J=null;if(Q)H.#Z=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#k(Q){if(!this.#R)this.hidePopup()}#y(Q){if(this.action==="hover")this.#R=!0,clearTimeout(this.#O),this.showDelayedPopup()}#v(Q){if(this.action==="hover"&&this.#R)clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#R=!1,this.hidePopup()},150)}#b(Q){if(this.action==="hover"&&this.#R)clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#R=!1,this.hidePopup()},300)}#w(Q){if(this.action==="hover"&&this.#R)this.#R=!1,clearTimeout(this.#O),this.hidePopup()}#V(Q){if(!this.isOpen&&!this.popup||Q.key!=="Escape")return;Q.preventDefault(),this.hidePopup(),this.firstElementChild?.focus?.()}static get observedAttributes(){return["action","delay","open","pointer","show","text","theme"]}get text(){return this.getAttribute("text")??""}set text(Q){this.setAttribute("text",Q)}#g(Q){if(!this.popup)return;let Z=this.popup.firstElementChild??this.popup.firstChild;if(!Z)return;Z.innerText=Q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null)this.removeAttribute("open");else this.setAttribute("open","true")}attributeChangedCallback(Q,Z,$){if(Q==="action"){if(this.#I(),Z==="click")document.body?.removeEventListener("click",this.#Y);if(this.action=$||"hover",this.isConnected){if(this.#f(),this.action==="click")document.body?.addEventListener("click",this.#Y)}}if(Q==="delay"){let J=parseInt($);this.delay=!isNaN(J)?J:500}if(Q==="open")if($!==null&&$!=="false")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(Q==="show")if($!==null&&$!=="false")this.showPopup();else this.hidePopup();if(Q==="text")this.#g($??"");if(Q==="pointer"){if(this.popup)if($!==null)this.popup.setAttribute("pointer",$);else this.popup.removeAttribute("pointer")}if(Q==="theme"){if(this.popup)if($)this.popup.setAttribute("theme",$);else this.popup.removeAttribute("theme")}}#x(Q){if(!this.isOpen)return;let Z=Q.target;if(this.popup&&this.popup.contains(Z))return;if(Z.tagName==="SELECT"||Z.hasAttribute("popover")||Z.closest("dialog"))this.hidePopup()}static#c(){if(H.#j)return;H.#j=!0;let Q=()=>{H.dismissHoverTooltips()},Z=()=>{H.#h()};document.documentElement.addEventListener("mouseleave",Q),document.addEventListener("mouseout",($)=>{if($.relatedTarget)return;Q()}),document.addEventListener("scroll",Z,{capture:!0,passive:!0}),window.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("resize",Z,{passive:!0});try{let $=window.frameElement;if($)$.addEventListener("mouseleave",Q)}catch{}window.addEventListener("message",($)=>{if($?.data?.type!=="figui:dismiss-tooltips")return;if(window.parent!==window&&$.source!==window.parent)return;Q()})}static dismissHoverTooltips(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof H))continue;if(Q.action!=="hover")continue;if(Q.#E)continue;if(Q.#H=!0,setTimeout(()=>{let Z=Q.#D;if(Z!==document.activeElement&&!Z?.matches?.(":focus, :focus-within"))Q.#H=!1},0),Q.isOpen||Q.timeout)Q.hidePopup()}for(let Q of Array.from(H.#q))H.hide(Q)}static#m=new WeakMap;static#h(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof H))continue;if(Q.#E)continue;if(Q.isOpen||Q.timeout)Q.hidePopup()}for(let Q of Array.from(H.#q))H.hide(Q)}static show(Q,Z,$={}){H.#c(),H.hide(Q);let J=$.delay??500,q=Date.now()-H.#Q<H.#$?0:J,_={timeout:null,popup:null};H.#m.set(Q,_),H.#q.add(Q),_.timeout=setTimeout(()=>{let X=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Y=document.createElement("dialog",{is:"fig-popup"});if(Y.setAttribute("is","fig-popup"),Y.setAttribute("variant","tooltip"),Y.setAttribute("data-tooltip-managed",""),Y.setAttribute("role","tooltip"),Y.setAttribute("closedby","closerequest"),X)Y.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=Z,Y.append(K),X)(j0()??document.body).append(Y);else{let G=Q.closest?.("dialog");if(G&&G.open)G.append(Y);else(j0()??document.body).append(Y)}Y.anchor=Q,Y.open=!0,_.popup=Y,H.#Q=Date.now()},q)}static hide(Q){let Z=H.#m.get(Q);if(!Z)return;if(clearTimeout(Z.timeout),Z.popup)Z.popup.remove(),H.#Z=Date.now();H.#m.delete(Q),H.#q.delete(Q)}}z("fig-tooltip",H);class y0 extends HTMLElement{static observedAttributes=["position","tail"];#Q=null;#Z=null;#$=null;connectedCallback(){this.#Q=this.textContent,c(this,()=>{this.#J(),this.#j()})}disconnectedCallback(){this.#q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(this.#Q===null)return;this.#J()}#J(){let Q=this.getAttribute("position")||"right",Z=this.#Q||"";if(Q==="middle"){let $=this.getAttribute("tail"),J;if($){let _=Z.lastIndexOf($);J=_>0?_:Math.ceil(Z.length/2)}else J=Math.ceil(Z.length/2);this.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=Z.slice(0,J);let q=document.createElement("span");q.className="end",q.textContent=Z.slice(J),this.appendChild(j),this.appendChild(q)}else this.textContent=Z}#j(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Z=()=>{if(this.scrollWidth<=this.clientWidth)return;H.show(this,this.#Q)},this.#$=()=>{H.hide(this)},this.addEventListener("pointerenter",this.#Z),this.addEventListener("pointerleave",this.#$)}#q(){if(this.#Z)this.removeEventListener("pointerenter",this.#Z);if(this.#$)this.removeEventListener("pointerleave",this.#$);H.hide(this)}}z("fig-truncate",y0);class w0 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();c(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._setupIframeDismissListeners(),this._syncA11y()}),window.addEventListener("message",this._boundIframeMessage)}disconnectedCallback(){this._figInit(),this._removeDragListeners(),this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize(),this._teardownIframeDismissListeners(),this.removeEventListener("close",this._boundRestoreFocus)}_captureFocusBeforeOpen(){let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}_restoreFocus(){let Q=this._previousFocus;if(this._previousFocus=null,!Q?.isConnected)return;let Z=document.activeElement;if(Z&&Z!==document.body&&!this.contains(Z))return;requestAnimationFrame(()=>Q.focus?.())}_assignStackingOrder(){this.style.zIndex=String(I0()+1)}_clearStackingOrder(){this.style.zIndex=""}show(){return this._captureFocusBeforeOpen(),this._assignStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),H.dismissHoverTooltips(),super.show()}showModal(){return this._captureFocusBeforeOpen(),this._clearStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),H.dismissHoverTooltips(),super.showModal()}close(...Q){let Z=super.close(...Q);return this._clearStackingOrder(),Z}_handleIframeMouseLeave(Q){let Z=Q?.currentTarget;if(!(Z instanceof HTMLIFrameElement))return;try{Z.contentWindow?.postMessage({type:"figui:dismiss-tooltips"},"*")}catch{}}_syncIframeDismissListeners(){for(let Q of this.querySelectorAll(":scope > iframe")){if(!(Q instanceof HTMLIFrameElement))continue;if(Q.dataset.figuiDismissBound==="true")continue;Q.dataset.figuiDismissBound="true",Q.addEventListener("mouseleave",this._boundIframeMouseLeave)}}_setupIframeDismissListeners(){if(this._syncIframeDismissListeners(),this._iframeDismissMutationObserver)return;this._iframeDismissMutationObserver=new MutationObserver(()=>{this._syncIframeDismissListeners()}),this._iframeDismissMutationObserver.observe(this,{childList:!0,subtree:!1})}_teardownIframeDismissListeners(){this._iframeDismissMutationObserver?.disconnect(),this._iframeDismissMutationObserver=null;for(let Q of this.querySelectorAll(":scope > iframe"))Q.removeEventListener("mouseleave",this._boundIframeMouseLeave),delete Q.dataset.figuiDismissBound}_handleIframeMessage(Q){if(!this.autoresize)return;let Z=Q?.data;if(!Z||Z.type!=="figui:iframe-resize")return;let $=Q.source;if(!$)return;let J=Array.from(this.querySelectorAll("iframe")).find((j)=>j.contentWindow===$);if(!J)return;this._resizeForIframe(J,Z)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let Q of this.children)try{this._resizeObserver.observe(Q)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((Q)=>{for(let Z of Q)Z.addedNodes?.forEach(($)=>{if($ instanceof Element&&$.parentElement===this)try{this._resizeObserver?.observe($)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(Q){let Z=window.getComputedStyle(this),$=parseFloat(Z.paddingTop||"0")+parseFloat(Z.paddingBottom||"0")+parseFloat(Z.borderTopWidth||"0")+parseFloat(Z.borderBottomWidth||"0"),J=0,j=parseFloat(Z.rowGap||Z.gap||"0")||0,q=0;for(let _ of this.children){let X=_.getBoundingClientRect();if(X.height===0)continue;if(q+=1,_===Q)continue;let Y=window.getComputedStyle(_),K=parseFloat(Y.marginTop||"0")+parseFloat(Y.marginBottom||"0");J+=X.height+K}if(j&&q>1)J+=j*(q-1);return $+J}_resizeForIframe(Q,Z){if(typeof Z.height!=="number"||!(Z.height>0))return;let $=this._computeChrome(Q);this.style.height=`${Math.ceil(Z.height+$)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){if(this.querySelector("fig-header[dialog-header]"))return;let Q=document.createElement("fig-header");Q.setAttribute("dialog-header",""),Q.setAttribute("data-auto","");let Z=document.createElement("h3");Z.textContent=this.getAttribute("title")||"Dialog";let $=document.createElement("fig-tooltip");$.setAttribute("text","Close");let J=document.createElement("fig-button");J.setAttribute("variant","ghost"),J.setAttribute("icon",""),J.setAttribute("aria-label","Close dialog"),J.setAttribute("close-dialog",""),J.appendChild(u("close")),$.appendChild(J),Q.appendChild(Z),Q.appendChild($),this.prepend(Q)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close dialog");Q.removeEventListener("click",this._boundClose),Q.addEventListener("click",this._boundClose)})}_syncA11y(){if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let Q=this.querySelector("fig-header[dialog-header] h1, fig-header[dialog-header] h2, fig-header[dialog-header] h3, fig-header[dialog-header] h4, fig-header[dialog-header] h5, fig-header[dialog-header] h6");if(Q){let Z=Q.getAttribute("id")||h();Q.setAttribute("id",Z),this.setAttribute("aria-labelledby",Z)}}}_applyPosition(){let Q=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let Z=Q.includes("top"),$=Q.includes("bottom"),J=Q.includes("left"),j=Q.includes("right"),q=Q.includes("center")&&!Z&&!$,_=Q.includes("center")&&!J&&!j;if(Z)this.style.top=`${this._offset}px`;else if($)this.style.bottom=`${this._offset}px`;else if(q)this.style.top="0",this.style.bottom="0";if(J)this.style.left=`${this._offset}px`;else if(j)this.style.right=`${this._offset}px`;else if(_)this.style.left="0",this.style.right="0";if(q&&_)this.style.margin="auto";else if(q)this.style.marginTop="auto",this.style.marginBottom="auto";else if(_)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let Q=this.getAttribute("handle"),Z=Q?this.querySelector(Q):this.querySelector("fig-header, header");if(Z)Z.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}_isInteractiveElement(Q){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(q)=>Z.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!$.includes(q.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}_handlePointerUp(Q){if(this._isDragging){if(this.hasPointerCapture?.(Q.pointerId))this.releasePointerCapture(Q.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),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Q==="autoresize"&&this.isConnected)this._syncAutoResize();if(Q==="drag")if(this.drag=$!==null&&$!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let J=this.querySelector("fig-header, header");if(J)J.style.cursor=""}if(Q==="position"&&this._positionInitialized)this._applyPosition();if(Q==="modal"){let J=this.modal;if(this.modal=$!==null&&$!=="false",this.open&&J!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(Q==="closedby")this.closedby=$||"any";if(Q==="title"){let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";this._syncA11y()}if(Q==="aria-label"||Q==="aria-labelledby")this._syncA11y()}}M0("fig-dialog",w0,{extends:"dialog"});class v0 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._boundHandleClose=this.handleClose.bind(this)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast();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((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close notification");Q.removeEventListener("click",this._boundHandleClose),Q.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto";let Q=Number.parseFloat(this.getAttribute("offset")),Z=Number.isFinite(Q)?Q:this._defaultOffset;this.style.bottom=`${Z}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let Q=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger",Z=Q?"alert":"status",$=Q?"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")}startAutoClose(){this.clearAutoClose();let Q=parseInt(this.getAttribute("duration")??"5000");if(Q>0)this._autoCloseTimer=setTimeout(()=>this.hideToast(),Q)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}_resolveAutoTheme(){if(this.getAttribute("theme")!=="auto")return;let Q=getComputedStyle(document.documentElement).colorScheme||"";this.style.colorScheme=Q.includes("dark")?"light":"dark"}showToast(){let Q=this._toastVisible;this.syncLiveRegion(),this._resolveAutoTheme(),this._syncingOpen=!0;try{if(!this.open)this.show()}finally{this._syncingOpen=!1}if(this._toastVisible=!0,this.applyPosition(),this.startAutoClose(),!Q)this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){let Q=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,Q)this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Z===$)return;if(!this.isConnected)return;if(this._syncingOpen)return;if(Q==="offset")this.applyPosition();if(Q==="open")if($!==null&&$!=="false")this.showToast();else this.hideToast();if(Q==="duration"&&this._toastVisible)this.startAutoClose();if(Q==="theme")if($==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme");if(Q==="theme"||Q==="live")this.syncLiveRegion()}}M0("fig-toast",v0,{extends:"dialog"});class h0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;_previousFocus=null;_boundDocumentKeydown;_boundNativeClose;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{let Z=Q.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this),this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this),this._boundNativeClose=this.handleNativeClose.bind(this)}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._previousFocus>"u")this._previousFocus=null;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{let Z=Q.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this);if(typeof this._boundDocumentKeydown!=="function")this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this);if(typeof this._boundNativeClose!=="function")this._boundNativeClose=this.handleNativeClose.bind(this)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!(this.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(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else if(Q&&typeof Q.getBoundingClientRect==="function")this._anchorRef=Q;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role",this.getAttribute("variant")==="tooltip"?"tooltip":"dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this.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(Q,Z,$){if(this.ensureInitialized(),Z===$)return;if(Q==="open"){if($==="false"){this.open=!1;return}if($===null){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=$!==null&&$!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(I0()+1),this.captureFocusBeforeOpen();let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),Z=this.shouldAutoReposition();if(Z)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(J){Q=!1}if(!Q&&!super.open)try{this.show()}catch(J){}if(Z&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.addEventListener("keydown",this._boundDocumentKeydown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let $=this.resolveAnchor();if($?.classList)$.classList.add("has-popup-open");if(this.getAttribute("variant")!=="tooltip")H.dismissHoverTooltips()}hidePopup(){let Q=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),Z=this.resolveAnchor();if(Z?.classList)Z.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch($){}if(this.matches?.(":open"))try{this.close()}catch($){}if(Q)this.restoreFocusAfterClose()}shouldRestoreFocus(){return this.getAttribute("variant")!=="tooltip"}captureFocusBeforeOpen(){if(!this.shouldRestoreFocus())return;let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}restoreFocusAfterClose(){if(!this.shouldRestoreFocus()){this._previousFocus=null;return}let Q=this.resolveAnchor(),Z=this._previousFocus?.isConnected?this._previousFocus:Q instanceof HTMLElement?Q:null;if(this._previousFocus=null,!Z?.isConnected)return;let $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Z.focus?.())}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q===!1||Q==="false"||Q===null)this.setAttribute("autoresize","false");else if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.setAttribute("autoresize","false")}handleNativeClose(){if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}setupObservers(){this.teardownObservers();let Q=this.resolveAnchor();if(Q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(Q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(Q){if(!Q)return null;let Z=Q.getBoundingClientRect();return{x:Z.x,y:Z.y,width:Z.width,height:Z.height}}hasRectChanged(Q,Z,$=0.25){if(!Q&&!Z)return!1;if(!Q||!Z)return!0;return Math.abs(Q.x-Z.x)>$||Math.abs(Q.y-Z.y)>$||Math.abs(Q.width-Z.width)>$||Math.abs(Q.height-Z.height)>$}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let Z=this.resolveAnchor(),$=this.readRectSnapshot(Z),J=this.shouldAutoReposition();if(J&&this.hasRectChanged(this._lastAnchorRect,$))this._lastAnchorRect=$,this.queueReposition();else if(!J)this._lastAnchorRect=$;this._anchorTrackRAF=requestAnimationFrame(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!(this.matches?.(":open")||this.matches?.(":popover-open")))return;let Z=this.getAttribute("closedby");if(Z==="none"||Z==="closerequest")return;let $=Q.target;if(!($ instanceof Node))return;let J=typeof Q.composedPath==="function"?Q.composedPath():[];if(J.includes(this))return;if(this.contains($))return;let j=this.resolveAnchor();if(j&&(J.includes(j)||j.contains?.($)))return;if(this.isInsideDescendantPopup($))return;this.open=!1}handleDocumentKeydown(Q){if(Q.key!=="Escape"||Q.defaultPrevented)return;if(!this.open)return;if(this.getAttribute("role")==="menu")return;if(this.getAttribute("closedby")==="none")return;let J=Array.from(document.querySelectorAll('dialog[is="fig-popup"][open]')).filter((j)=>j.open).map((j)=>({popup:j,z:Number.parseInt(getComputedStyle(j).zIndex||"0",10)||0})).sort((j,q)=>j.z-q.z).at(-1)?.popup;if(J&&J!==this)return;Q.preventDefault(),this.open=!1}isInsideDescendantPopup(Q){let Z=Q.closest?.('dialog[is="fig-popup"]');if(!Z||Z===this)return!1;let $=Z,J=new Set;while($&&!J.has($)){J.add($);let j=$.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;$=j.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}isInteractiveElement(Q){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(q)=>Z.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!$.includes(q.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging){if(this.hasPointerCapture?.(Q.pointerId))this.releasePointerCapture(Q.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),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let Z=this.parentElement;try{if(Z?.querySelector){let $=Z.querySelector(Q);if($&&!this.contains($))return $}return document.querySelector(Q)}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"]),j="top",q="center",_=null;if(Z.length>=2){if($.has(Z[0]))j=Z[0];if(J.has(Z[1]))q=Z[1];return{vertical:j,horizontal:q,shorthand:_}}if(Z.length===1){let X=Z[0];if(X==="top"||X==="bottom")j=X,_=X;else if(X==="left"||X==="right")q=X,_=X;else if(X==="center")j="center",q="center"}return{vertical:j,horizontal:q,shorthand:_}}normalizeOffsetToken(Q,Z="0px"){if(!Q)return Z;let $=Q.trim();if(!$)return Z;if(/^-?\d+(\.\d+)?$/.test($))return`${$}px`;return $}measureLengthPx(Q,Z="x"){if(!Q)return 0;let $=this.normalizeOffsetToken(Q,"0px");if($.endsWith("px")){let q=parseFloat($);return Number.isFinite(q)?q:0}let J=document.createElement("div");if(J.style.position="fixed",J.style.visibility="hidden",J.style.pointerEvents="none",J.style.left="0",J.style.top="0",J.style.margin="0",J.style.padding="0",J.style.border="0",Z==="x")J.style.width=$,J.style.height="0";else J.style.height=$,J.style.width="0";document.body.appendChild(J);let j=J.getBoundingClientRect();return J.remove(),Z==="x"?j.width:j.height}parseOffset(){let Z=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),$=this.normalizeOffsetToken(Z[0],"0px"),J=this.normalizeOffsetToken(Z[1],"0px");return{xToken:$,yToken:J,xPx:this.measureLengthPx($,"x"),yPx:this.measureLengthPx(J,"y")}}parseViewportMargins(){let Z=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((J)=>!Number.isNaN(J)),$=8;if(Z.length===0)return{top:8,right:8,bottom:8,left:8};if(Z.length===1)return{top:Z[0],right:Z[0],bottom:Z[0],left:Z[0]};if(Z.length===2)return{top:Z[0],right:Z[1],bottom:Z[0],left:Z[1]};if(Z.length===3)return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[1]};return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[3]}}getPlacementCandidates(Q,Z,$){let J={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if($){let q=$==="left"||$==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:Z,s:$},{v:Q,h:Z,s:J[$]},{v:Q,h:Z,s:q[0]},{v:Q,h:Z,s:q[1]}]}if(Q==="center")return[{v:"center",h:Z,s:null},{v:"center",h:J[Z],s:null},{v:"top",h:Z,s:null},{v:"bottom",h:Z,s:null},{v:"top",h:J[Z],s:null},{v:"bottom",h:J[Z],s:null}];if(Z==="center")return[{v:Q,h:"center",s:null},{v:J[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:J[Q],h:"left",s:null},{v:J[Q],h:"right",s:null}];return[{v:Q,h:Z,s:null},{v:J[Q],h:Z,s:null},{v:Q,h:J[Z],s:null},{v:J[Q],h:J[Z],s:null}]}computeCoords(Q,Z,$,J,j,q){let _,X;if(q==="left"||q==="right")return X=q==="left"?Q.left-Z.width-j.xPx:Q.right+j.xPx,_=Q.top,{top:_,left:X};if(q==="top"||q==="bottom")return _=q==="top"?Q.top-Z.height-j.yPx:Q.bottom+j.yPx,X=Q.left,{top:_,left:X};if($==="top")_=Q.top-Z.height-j.yPx;else if($==="bottom")_=Q.bottom+j.yPx;else _=Q.top+(Q.height-Z.height)/2;if($==="center")if(J==="left")X=Q.left-Z.width-j.xPx;else if(J==="right")X=Q.right+j.xPx;else X=Q.left+(Q.width-Z.width)/2;else if(J==="left")X=Q.left+j.xPx;else if(J==="right")X=Q.right-Z.width-j.xPx;else X=Q.left+(Q.width-Z.width)/2;return{top:_,left:X}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,Z,$){if($==="top")return"top";if($==="bottom")return"bottom";if($==="left")return"left";if($==="right")return"right";if(Q!=="center")return Q;if(Z!=="center")return Z;return"top"}lengthToPx(Q,Z=0){let $=getComputedStyle(this),J=String(Q||"").trim(),j=parseFloat(J);if(!Number.isFinite(j))return Z;if(J.endsWith("rem"))return j*parseFloat(getComputedStyle(document.documentElement).fontSize);if(J.endsWith("em"))return j*parseFloat($.fontSize);return j}radiusForSide(Q){let Z=getComputedStyle(this),$=(J)=>this.lengthToPx(J,0);if(Q==="top")return Math.max($(Z.borderTopLeftRadius),$(Z.borderTopRightRadius));if(Q==="bottom")return Math.max($(Z.borderBottomLeftRadius),$(Z.borderBottomRightRadius));if(Q==="left")return Math.max($(Z.borderTopLeftRadius),$(Z.borderBottomLeftRadius));if(Q==="right")return Math.max($(Z.borderTopRightRadius),$(Z.borderBottomRightRadius));return 0}getBeakEdgeInset(Q){let Z=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(Q)+Z/2)}tracksAnchorBeak(){let Q=this.getAttribute("variant");return Q==="popover"||Q==="tooltip"}getViewportBounds(Q){let Z=window.visualViewport,$=Z?.width??window.innerWidth,J=Z?.height??window.innerHeight,j=Z?.offsetLeft??0,q=Z?.offsetTop??0;return{minLeft:j+Q.left,minTop:q+Q.top,maxRight:j+$-Q.right,maxBottom:q+J-Q.bottom}}clampToViewport(Q,Z,$){let J=this.getViewportBounds($),j=J.maxRight-Z.width,q=J.maxBottom-Z.height;return{left:Math.min(j,Math.max(J.minLeft,Q.left)),top:Math.min(q,Math.max(J.minTop,Q.top))}}resolveCoordsAtViewport(Q,Z,$,J,j){let{left:q,top:_}=this.clampToViewport($,Z,j);if(!Q||!this.tracksAnchorBeak())return{left:q,top:_};let X=this.oppositeSide(J),Y=this.getViewportBounds(j),K=Y.maxRight-Z.width,G=Y.minLeft,N=Y.maxBottom-Z.height,W=Y.minTop;if(X==="top"||X==="bottom"){let O=this.getBeakEdgeInset(X),B=Q.left+Q.width/2,L=B-q;if(L<O)q=B-O;else if(L>Z.width-O)q=B-(Z.width-O);q=Math.min(K,Math.max(G,q))}else if(X==="left"||X==="right"){let O=this.getBeakEdgeInset(X),B=Q.top+Q.height/2,L=B-_;if(L<O)_=B-O;else if(L>Z.height-O)_=B-(Z.height-O);_=Math.min(N,Math.max(W,_))}return{left:q,top:_}}canPointAtAnchor(Q,Z,$,J,j){if(!Q||!this.tracksAnchorBeak())return!0;let q=this.oppositeSide(j),_=this.getBeakEdgeInset(q);if(q==="top"||q==="bottom"){let Y=Q.left+Q.width/2-$;return Y>=_-0.5&&Y<=Z.width-_+0.5}let X=Q.top+Q.height/2-J;return X>=_-0.5&&X<=Z.height-_+0.5}updatePopoverBeak(Q,Z,$,J,j){if(!this.tracksAnchorBeak()||!Q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let q=this.oppositeSide(j);this.setAttribute("data-beak-side",q);let _=Q.left+Q.width/2,X=Q.top+Q.height/2,Y=this.getBoundingClientRect(),K=Y.width>0&&Y.height>0?Y:Z,G=K.left,N=K.top,W=this.getBeakEdgeInset(q),O;if(q==="top"||q==="bottom"){O=_-G;let B=W,L=Math.max(B,K.width-W);O=Math.min(L,Math.max(B,O))}else{O=X-N;let B=W,L=Math.max(B,K.height-W);O=Math.min(L,Math.max(B,O))}this.style.setProperty("--fig-popup-beak-offset",`${O}px`)}overflowScore(Q,Z,$){let J=this.getViewportBounds($),j=Q.left+Z.width,q=Q.top+Z.height,_=Math.max(0,J.minLeft-Q.left),X=Math.max(0,J.minTop-Q.top),Y=Math.max(0,j-J.maxRight),K=Math.max(0,q-J.maxBottom);return _+X+Y+K}fits(Q,Z,$){return this.overflowScore(Q,Z,$)===0}clamp(Q,Z,$,J=null,j="top"){if(J)return this.resolveCoordsAtViewport(J,Z,Q,j,$);return this.clampToViewport(Q,Z,$)}primaryAxisOverflowPenalty(Q,Z,$,J){let j=this.getViewportBounds($),q=0;if(J==="top")q=Math.max(0,j.minTop-Q.top);else if(J==="bottom")q=Math.max(0,Q.top+Z.height-j.maxBottom);else if(J==="left")q=Math.max(0,j.minLeft-Q.left);else if(J==="right")q=Math.max(0,Q.left+Z.width-j.maxRight);return q>0?1000+q:0}placementScore(Q,Z,$,J,j){let q=this.resolveCoordsAtViewport(Q,Z,$,J,j),_=this.overflowScore(q,Z,j);if(_+=this.primaryAxisOverflowPenalty($,Z,j,J),Q&&!this.canPointAtAnchor(Q,Z,q.left,q.top,J))_+=1e4;return{score:_,resolved:q}}applyPopupPosition(Q,Z,$,J,j){let q=this.resolveCoordsAtViewport(Q,Z,$,J,j);this.style.left=`${q.left}px`,this.style.top=`${q.top}px`,this.updatePopoverBeak(Q,Z,q.left,q.top,J)}positionPopup(){if(!this.open)return;let Q=this.getBoundingClientRect(),Z=this.parseOffset(),{vertical:$,horizontal:J,shorthand:j}=this.parsePosition(),q=this.resolveAnchor(),_=this.parseViewportMargins();if(!q){this.updatePopoverBeak(null,Q,0,0,"top");let W=this.getViewportBounds(_),O={left:W.minLeft+(W.maxRight-W.minLeft-Q.width)/2,top:W.minTop+(W.maxBottom-W.minTop-Q.height)/2},B=this.clampToViewport(O,Q,_);this.style.left=`${B.left}px`,this.style.top=`${B.top}px`;return}let X=q.getBoundingClientRect(),Y=this.getPlacementCandidates($,J,j),K=null,G="top",N=Number.POSITIVE_INFINITY;for(let{v:W,h:O,s:B}of Y){let L=this.computeCoords(X,Q,W,O,Z,B),T=this.getPlacementSide(W,O,B),{score:R,resolved:A}=this.placementScore(X,Q,L,T,_);if(B){let M=this.getViewportBounds(_);if((B==="left"||B==="right"?L.left>=M.minLeft&&L.left+Q.width<=M.maxRight:L.top>=M.minTop&&L.top+Q.height<=M.maxBottom)&&R<1e4){this.applyPopupPosition(X,Q,L,T,_);return}}else if(R===0){this.applyPopupPosition(X,Q,L,T,_);return}if(R<N)N=R,K=A,G=T}this.applyPopupPosition(X,Q,K||{left:0,top:0},G,_)}queueReposition(){if(!this.open||!this.isPopupDisplayed()||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}isPopupDisplayed(){return Boolean(this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"))}}M0("fig-popup",h0,{extends:"dialog"});class g0 extends HTMLElement{#Q;#Z;constructor(){super();this.content=null,this.#Q=!1,this.#Z=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.#Z),c(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let Q=this.getAttribute("id")||h(),Z=this.content.getAttribute("id")||h();if(this.setAttribute("id",Q),this.content.setAttribute("id",Z),this.setAttribute("aria-controls",Z),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",Q),this.#Q)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.#Q}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Z)}handleClick(){if(F(this,"disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(Q,Z,$){if(Q==="selected"){if(this.#Q=$!==null&&$!=="false",this.setAttribute("aria-selected",this.#Q?"true":"false"),this.setAttribute("tabindex",this.#Q?"0":"-1"),this?.content)this.content.style.display=this.#Q?"block":"none"}if(Q==="disabled")if($!==null&&$!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#Q?"0":"-1")}}z("fig-tab",g0);class b0 extends HTMLElement{#Q;#Z;#$=this.#L.bind(this);#J=null;#j=null;#q=null;#_=null;#Y=!1;#X=new WeakSet;constructor(){super();this.#Q=this.handleClick.bind(this),this.#Z=this.#D.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){if(this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#Z),this.addEventListener("scroll",this.#$),this.#M(),this.#z(),this.#F(),c(this,()=>{let Q=this.getAttribute("value");if(Q)this.#O(Q);if(F(this,"disabled"))this.#W(!0);this.#K(),this.#L(),this.#G(void 0,"auto")})}#W(Q){this.querySelectorAll("fig-tab").forEach(($)=>{if(Q){if(!($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false"))this.#X.add($),$.setAttribute("disabled","");$.setAttribute("aria-disabled","true"),$.setAttribute("tabindex","-1")}else if(this.#X.has($))this.#X.delete($),$.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#K()}#N(){return Array.from(this.querySelectorAll("fig-tab")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#K(){let Q=Array.from(this.querySelectorAll("fig-tab")),Z=Q.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false")||this.#N()[0];Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false";$.setAttribute("tabindex",!J&&$===Z?"0":"-1")})}#G(Q=this.selectedTab,Z="smooth"){let $=Q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#N()[0];if(!$)return;requestAnimationFrame(()=>{if(!this.isConnected||!$.isConnected)return;if(!(this.scrollWidth>this.clientWidth))return;let j=this.getBoundingClientRect(),q=$.getBoundingClientRect(),_=q.left-j.left+this.scrollLeft+q.width/2;this.scrollTo({left:_-this.clientWidth/2,behavior:Z}),this.#L()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#Z),this.removeEventListener("scroll",this.#$),this.#J?.disconnect(),this.#J=null,this.#j?.disconnect(),this.#j=null,this.#B()}#U(){if(this.#Y)return;let Q=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!Q)return;this.#Y=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#Y=!1}}#L(){a(this,this,"x")}#F(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>this.#L()),this.#j.observe(this)}#z(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>{if(this.#Y)return;this.#U(),this.#M(),this.#K(),requestAnimationFrame(()=>{this.#L(),this.#G()})}),this.#J.observe(this,{childList:!0,subtree:!1})}#B(){this.#q?.remove(),this.#_?.remove(),this.#q=null,this.#_=null,this.classList.remove("overflow-start","overflow-end")}#M(){if(this.#q&&this.#_&&this.contains(this.#q)&&this.contains(this.#_))return;this.#q?.remove(),this.#_?.remove();let Q=X0({owner:"tabs",onStart:()=>i(this,"x",-1),onEnd:()=>i(this,"x",1)});this.#q=Q.start,this.#_=Q.end,this.prepend(this.#q),this.append(this.#_)}#D(Q){let Z=this.#N();if(!Z.length)return;let $=Z.findIndex((j)=>F(j,"selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=$>0?$-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=$<Z.length-1?$+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;default:return}if(J!==$&&Z[J]){this.querySelectorAll("fig-tab").forEach((q)=>q.removeAttribute("selected")),this.selectedTab=Z[J],Z[J].setAttribute("selected","true");let j=this.#H(Z[J]);if(j)this.setAttribute("value",j);else this.removeAttribute("value");Z[J].focus(),this.#K(),this.#G(Z[J]),this.#T()}}get value(){return this.#H(this.selectedTab)}set value(Q){this.setAttribute("value",Q)}#T(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#H(Q){if(!Q)return"";let Z=Q.getAttribute("value");if(Z!==null)return Z;return Q.textContent?.trim()||""}#O(Q){let Z=this.querySelectorAll("fig-tab");for(let $ of Z)if(this.#H($)===Q)this.selectedTab=$,$.setAttribute("selected","true");else $.removeAttribute("selected");this.#K(),this.#G(this.selectedTab)}attributeChangedCallback(Q,Z,$){switch(Q){case"value":if($!==Z)this.#O($);break;case"disabled":this.#W($!==null&&$!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=Q.target.closest("fig-tab");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;let $=this.selectedTab,J=this.value,j=this.querySelectorAll("fig-tab");for(let _ of j)if(_===Z)this.selectedTab=_,_.setAttribute("selected","true");else _.removeAttribute("selected");let q=this.#H(Z);if(q)this.setAttribute("value",q);else this.removeAttribute("value");if(this.#K(),this.#G(Z),$!==Z||J!==this.value)this.#T()}}z("fig-tabs",b0);class m0 extends HTMLElement{#Q;#Z;#$;constructor(){super();this.#$=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#J(),this.addEventListener("click",this.#$)}disconnectedCallback(){this.removeEventListener("click",this.#$)}handleClick(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.closest("fig-segmented-control");if(Q&&Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#Q}set value(Q){this.#Q=Q,this.setAttribute("value",Q)}get selected(){return this.#Z}set selected(Q){this.#Z=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value","disabled"]}#J(){let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",Q?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",Q?"0":"-1")}attributeChangedCallback(Q,Z,$){switch(Q){case"value":this.#Q=$;break;case"selected":this.#Z=$,this.#J();break;case"disabled":this.#J();break}}}z("fig-segment",m0);class c0 extends HTMLElement{#Q=null;#Z=this.handleClick.bind(this);#$=this.#F.bind(this);#J=null;#j=null;#q=0;#_=!1;#Y=!1;#X=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.#Z),this.addEventListener("keydown",this.#$),this.#P(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#R(),this.#T(),c(this,()=>{this.#O({enforceFallback:!0}),this.#H(),this.#M({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#$),this.#J?.disconnect(),this.#J=null,this.#j?.disconnect(),this.#j=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#_=!1,this.#Y=!1}get selectedSegment(){return this.#Q}set selectedSegment(Q){let Z=this.querySelectorAll("fig-segment");for(let $ of Z){let J=$===Q,j=F($,"selected");if(J&&!j)$.setAttribute("selected","true");else if(!J&&j)$.removeAttribute("selected")}this.#Q=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#U(),this.#M()}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(Q))}#W(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#N(Q){let Z=Q.getAttribute("value");if(Z!==null){let $=Z.trim();if($.length>0)return $}return Q.textContent?.trim()||""}#K(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false")return Z;return null}#G(){return Array.from(this.querySelectorAll("fig-segment")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#U(){let Q=Array.from(this.querySelectorAll("fig-segment")),Z=Q.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false");Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false",j=$===Z;$.setAttribute("aria-checked",j?"true":"false"),$.setAttribute("tabindex",!J&&j?"0":"-1")})}#L(Q){if(!Q)return;let Z=this.selectedSegment,$=this.value;this.selectedSegment=Q;let J=this.#N(Q);if(J)this.setAttribute("value",J);else this.removeAttribute("value");let j=this.value;if(Z!==Q||$!==j)this.#W(j)}#F(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#G();if(!Z.length)return;let $=Z.findIndex((q)=>F(q,"selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=J>0?J-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=J<Z.length-1?J+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case" ":case"Enter":{let q=Q.target.closest("fig-segment");if(q&&this.contains(q))Q.preventDefault(),this.#L(q);return}default:return}let j=Z[J];this.#L(j),j.focus(),requestAnimationFrame(()=>{if(this.contains(j))j.focus()})}#z(Q){let Z=String(Q??"").trim();if(!Z)return!1;let $=this.querySelectorAll("fig-segment");for(let J of $){let j=this.#N(J);if(!j)continue;if(j===Z)return this.selectedSegment=J,!0}return!1}#B(){let Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#M({forceInstant:Q=!1}={}){if(this.#_=this.#_||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let Z=this.#_;this.#_=!1,this.#D({forceInstant:Z})})}#D({forceInstant:Q=!1}={}){let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#B(),J=this.#Q&&this.contains(this.#Q)?this.#Q:this.#K();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.#Y=!1;return}if(!J){if(this.#Y)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let j=this.getBoundingClientRect(),q=J.getBoundingClientRect();if(j.width<=0||q.width<=0){if(this.#Y)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let _=Math.max(0,q.left-j.left);this.style.setProperty("--seg-indicator-x",`${_}px`),this.style.setProperty("--seg-indicator-w",`${q.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#Y||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#Y=!0}#T(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#M()}),this.#H()}#H(){if(!this.#j)return;this.#j.disconnect(),this.#j.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#j?.observe(Q)})}#O({enforceFallback:Q=!1}={}){if(this.querySelectorAll("fig-segment").length===0){this.#Q=null,this.#M({forceInstant:!0});return}let $=this.getAttribute("value"),J=$?.trim()??"";if($!==null){if(J!==$){this.setAttribute("value",J);return}if(J&&this.#z(J))return}let j=this.#K();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=this.#G()[0]||null}#R(){this.#J?.disconnect(),this.#J=new MutationObserver((Q)=>{let Z=!1;for(let $ of Q){if($.type==="childList"){Z=!0;break}if($.type==="attributes"&&$.target instanceof HTMLElement&&$.target.tagName.toLowerCase()==="fig-segment"&&($.attributeName==="value"||$.attributeName==="selected")){Z=!0;break}if($.type==="characterData"){Z=!0;break}}if(Z)this.#P(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#H(),this.#O({enforceFallback:!0}),this.#U()}),this.#J.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=Q.target.closest("fig-segment");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#L(Z)}#P(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach((Z)=>{if(Q){if(!(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false"))this.#X.add(Z),Z.setAttribute("disabled","");Z.setAttribute("aria-disabled","true")}else if(this.#X.has(Z))this.#X.delete(Z),Z.removeAttribute("disabled"),Z.removeAttribute("aria-disabled")}),this.#U()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled"){this.#P($!==null&&$!=="false"),this.#M({forceInstant:!0});return}if(Q==="value"){this.#O({enforceFallback:!1});return}if(Q==="animated"){if(!this.#B())this.#Y=!1;this.#M({forceInstant:!0});return}if(Q==="sizing")this.#M({forceInstant:!0})}}z("fig-segmented-control",c0);class u0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Q="segments";#Z=0;#$=null;#J=[];#j=null;#q=!1;#_(Q){let Z=Q?.detail;if(typeof Z==="string")return Z;let $=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if($===null||$===void 0)return null;return String($)}#Y(){if(this.#J.length===0)return!1;let Q=this.querySelector(":scope > fig-segmented-control");if(Q){let $=Q.querySelectorAll("fig-segment");if($.length!==this.#J.length)return!1;return Array.from($).every((J,j)=>J.getAttribute("value")===this.#J[j])}let Z=this.querySelector(":scope > fig-dropdown");if(Z){let $=Z.querySelectorAll("option");return $.length===this.#J.length&&Array.from($).every((J,j)=>J.textContent?.trim()===this.#J[j])}return!1}#X(){let Q=this.querySelector(":scope > fig-segmented-control");if(Q)this.#j=Q,this.#Q="segments";else this.#j=this.querySelector(":scope > fig-dropdown"),this.#Q="dropdown";this.#U()}connectedCallback(){if(this.#W(),this.#Y()){this.#X(),this.#F(),c(this,()=>c(this,()=>this.#M()));return}this.#N(),this.#F(),c(this,()=>c(this,()=>this.#M()))}disconnectedCallback(){this.#$?.disconnect(),this.#$=null}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get options(){return this.#J.slice()}set options(Q){if(Array.isArray(Q)){let $=Q.some((J)=>String(J).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",$)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="options"){this.#W(),this.#G();return}if(Q==="value"){this.#U();return}if(Q==="disabled"){this.#L("disabled");return}if(Q==="full"){this.#L("full");return}if(Q==="sizing")this.#L("sizing"),this.#G()}#W(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#J=JSON.parse(Q);return}catch{}let Z=Q.includes(`
38
38
  `)?`
39
- `:",";this.#J=Q.split(Z).map(($)=>$.trim()).filter(Boolean)}#N(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-segmented-control");if(Q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),F(this,"disabled"))Q.setAttribute("disabled","");if(F(this,"full"))Q.setAttribute("full","");let Z=this.getAttribute("value");for(let $ of this.#J){let J=document.createElement("fig-segment");if(J.setAttribute("value",$),J.textContent=$,Z===$)J.setAttribute("selected","true");Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Z="segments"}#K(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-dropdown");if(F(this,"disabled"))Q.setAttribute("disabled","");let Z=this.getAttribute("value");for(let $ of this.#J){let J=document.createElement("option");if(J.value=$,J.textContent=$,Z===$)J.selected=!0;Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Z="dropdown"}#G(){if(this.#Z==="segments")this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#M())});else this.#K()}#U(){if(!this.#j||this.#q)return;let Q=this.getAttribute("value")||"";this.#j.value=Q}#L(Q){if(!this.#j)return;if(this.hasAttribute(Q))this.#j.setAttribute(Q,this.getAttribute(Q)||"");else this.#j.removeAttribute(Q)}#F(){this.#$?.disconnect(),this.#$=new ResizeObserver(()=>{this.#M()}),this.#$.observe(this)}#z(Q){let Z=document.createRange();Z.selectNodeContents(Q);let $=Z.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,q=getComputedStyle(Q),_=parseFloat(q.paddingLeft)||0,X=parseFloat(q.paddingRight)||0,Y=j-_-X;return $>Y+0.5}#B(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(this.#z(Z))return!0;return!1}#M(){if(this.#J.length<=1)return;if(this.#Z==="segments"){let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#B())this.#Q=this.clientWidth,this.#K()}else if(this.#Q>0&&this.clientWidth>=this.#Q)this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#B())this.#K()})})}}z("fig-options",u0);function c1(Q){let Z=Q||"";if(Z.startsWith("["))try{let J=JSON.parse(Z);return Array.isArray(J)?J:[]}catch{}let $=Z.includes(`
39
+ `:",";this.#J=Q.split(Z).map(($)=>$.trim()).filter(Boolean)}#N(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-segmented-control");if(Q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),F(this,"disabled"))Q.setAttribute("disabled","");if(F(this,"full"))Q.setAttribute("full","");let Z=this.getAttribute("value");for(let $ of this.#J){let J=document.createElement("fig-segment");if(J.setAttribute("value",$),J.textContent=$,Z===$)J.setAttribute("selected","true");Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Q="segments"}#K(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-dropdown");if(F(this,"disabled"))Q.setAttribute("disabled","");let Z=this.getAttribute("value");for(let $ of this.#J){let J=document.createElement("option");if(J.value=$,J.textContent=$,Z===$)J.selected=!0;Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Q="dropdown"}#G(){if(this.#Q==="segments")this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#M())});else this.#K()}#U(){if(!this.#j||this.#q)return;let Q=this.getAttribute("value")||"";this.#j.value=Q}#L(Q){if(!this.#j)return;if(this.hasAttribute(Q))this.#j.setAttribute(Q,this.getAttribute(Q)||"");else this.#j.removeAttribute(Q)}#F(){this.#$?.disconnect(),this.#$=new ResizeObserver(()=>{this.#M()}),this.#$.observe(this)}#z(Q){let Z=document.createRange();Z.selectNodeContents(Q);let $=Z.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,q=getComputedStyle(Q),_=parseFloat(q.paddingLeft)||0,X=parseFloat(q.paddingRight)||0,Y=j-_-X;return $>Y+0.5}#B(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(this.#z(Z))return!0;return!1}#M(){if(this.#J.length<=1)return;if(this.#Q==="segments"){let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#B())this.#Z=this.clientWidth,this.#K()}else if(this.#Z>0&&this.clientWidth>=this.#Z)this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#B())this.#K()})})}}z("fig-options",u0);function c1(Q){let Z=Q||"";if(Z.startsWith("["))try{let J=JSON.parse(Z);return Array.isArray(J)?J:[]}catch{}let $=Z.includes(`
40
40
  `)?`
41
- `:",";return Z.split($).map((J)=>J.trim()).filter(Boolean)}function u1(Q){if(Q&&typeof Q==="object")return String(Q.value??Q.label??"");return String(Q??"")}function p1(Q){if(Q&&typeof Q==="object")return String(Q.label??Q.value??"");return String(Q??"")}class p0 extends HTMLElement{static get observedAttributes(){return["value","disabled","selected","label"]}get value(){let Q=this.getAttribute("value");if(Q!==null)return Q;return(this.textContent||"").trim()}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get disabled(){return F(this,"disabled")}set disabled(Q){if(Q)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get selected(){return F(this,"selected")}set selected(Q){if(Q)this.setAttribute("selected","");else this.removeAttribute("selected")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","option");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled")this.#Z()}#Z(){if(this.disabled)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}z("fig-select-option",p0);class d0 extends HTMLElement{#Z=null;#Q=null;#$=null;#J=this.syncOverflow.bind(this);connectedCallback(){if(!this.hasAttribute("slot"))this.setAttribute("slot","panel");this.#j(),this.#q(),this.addEventListener("scroll",this.#J,{passive:!0}),this.#$?.disconnect(),this.#$=new ResizeObserver(()=>this.syncOverflow()),this.#$.observe(this),requestAnimationFrame(()=>this.syncOverflow())}disconnectedCallback(){this.removeEventListener("scroll",this.#J),this.#$?.disconnect(),this.#$=null,this.#_()}syncOverflow(){return a(this,this,"y")}scrollToOption(Q,Z="auto"){S0(this,Q,"y",Z)}#j(){let Q=this.querySelector(":scope > fig-chooser");if(!Q)return;while(Q.firstChild)this.insertBefore(Q.firstChild,Q);Q.remove()}#q(){if(this.#Z&&this.#Q&&this.contains(this.#Z)&&this.contains(this.#Q))return;this.#_();let Q=X0({owner:"select",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>i(this,"y",-1),onEnd:()=>i(this,"y",1)});this.#Z=Q.start,this.#Q=Q.end,this.prepend(this.#Z),this.append(this.#Q)}#_(){this.#Z?.remove(),this.#Q?.remove(),this.#Z=null,this.#Q=null,this.classList.remove("overflow-start","overflow-end")}}z("fig-select-options",d0);class s0 extends HTMLElement{#Z=null;#Q=null;#$=null;#J=null;#j=null;#q=null;#_=!1;#Y=-1;#X=!1;#W=!1;#N=null;#K=!1;#G=null;#U=null;#L=!1;#F=this.#Z0.bind(this);#z=this.#j0.bind(this);#B=this.#q0.bind(this);#M=this.#e.bind(this);#D=this.#u.bind(this);static get observedAttributes(){return["value","disabled","label","options","position","offset","closedby","open"]}get value(){return this.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get open(){return F(this,"open")}set open(Q){if(Q)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(!this.#_)this.#S();if(this.#H(),this.#C(),this.#r(),this.#t(),this.#i(),this.#m(),this.open)this.#_0()}disconnectedCallback(){this.#x(),document.removeEventListener("keydown",this.#B,!0),this.#q?.disconnect(),this.#q=null}attributeChangedCallback(Q,Z,$){if(Z===$||!this.#_)return;if(Q==="options"){this.#C(),this.#i();return}if(Q==="value"||Q==="label"){this.#i();return}if(Q==="disabled"){this.#r();return}if(Q==="open"){if($===null||$==="false")this.#G0();else this.#_0();return}if(Q==="position"||Q==="offset"||Q==="closedby")this.#t()}focus(Q){this.#Z?.focus(Q)}blur(){this.#Z?.blur()}#E(Q){return Q?.nodeType===1&&(Q.tagName==="FIG-SELECT-OPTION"||Q.tagName==="FIG-MENU-SEPARATOR"||Q.tagName==="FIG-SELECT-OPTIONS")}#H(){for(let Q of this.querySelectorAll(":scope > fig-select-options"))if(!Q.hasAttribute("slot"))Q.setAttribute("slot","panel")}#O(){let Z=(this.#j?.assignedElements({flatten:!0})??[]).find(($)=>$.tagName==="FIG-SELECT-OPTIONS");if(Z)return Z;return this.querySelector(":scope > fig-select-options")}#R(){return Boolean(this.querySelector(":scope > fig-select-option:not([data-fig-generated]), :scope > fig-select-options > fig-select-option:not([data-fig-generated])"))}#P(){let Q=this.#O();if(Q){if(!Q.hasAttribute("slot"))Q.setAttribute("slot","panel");return Q}return Q=document.createElement("fig-select-options"),Q.setAttribute("slot","panel"),Q.setAttribute("data-fig-generated",""),this.appendChild(Q),Q}#C(){if(this.#R())return;let Q=this.hasAttribute("options"),Z=Q?this.#P():this.#O();if(!Z)return;this.#L=!0;try{for(let j of Z.querySelectorAll(":scope > fig-select-option[data-fig-generated]"))j.remove();if(!Q)return;let $=c1(this.getAttribute("options")),J=Z.querySelector(":scope > .fig-overflow-end");for(let j of $){let q=document.createElement("fig-select-option");if(q.setAttribute("data-fig-generated",""),q.setAttribute("value",u1(j)),q.textContent=p1(j),J)Z.insertBefore(q,J);else Z.appendChild(q)}}finally{this.#L=!1}}#S(){this.#_=!0;let Q=this.attachShadow({mode:"open"});Q.innerHTML=`
41
+ `:",";return Z.split($).map((J)=>J.trim()).filter(Boolean)}function u1(Q){if(Q&&typeof Q==="object")return String(Q.value??Q.label??"");return String(Q??"")}function p1(Q){if(Q&&typeof Q==="object")return String(Q.label??Q.value??"");return String(Q??"")}class p0 extends HTMLElement{static get observedAttributes(){return["value","disabled","selected","label"]}get value(){let Q=this.getAttribute("value");if(Q!==null)return Q;return(this.textContent||"").trim()}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get disabled(){return F(this,"disabled")}set disabled(Q){if(Q)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get selected(){return F(this,"selected")}set selected(Q){if(Q)this.setAttribute("selected","");else this.removeAttribute("selected")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","option");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled")this.#Q()}#Q(){if(this.disabled)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}z("fig-select-option",p0);class d0 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=this.syncOverflow.bind(this);connectedCallback(){if(!this.hasAttribute("slot"))this.setAttribute("slot","panel");this.#j(),this.#q(),this.addEventListener("scroll",this.#J,{passive:!0}),this.#$?.disconnect(),this.#$=new ResizeObserver(()=>this.syncOverflow()),this.#$.observe(this),requestAnimationFrame(()=>this.syncOverflow())}disconnectedCallback(){this.removeEventListener("scroll",this.#J),this.#$?.disconnect(),this.#$=null,this.#_()}syncOverflow(){return a(this,this,"y")}scrollToOption(Q,Z="auto"){S0(this,Q,"y",Z)}#j(){let Q=this.querySelector(":scope > fig-chooser");if(!Q)return;while(Q.firstChild)this.insertBefore(Q.firstChild,Q);Q.remove()}#q(){if(this.#Q&&this.#Z&&this.contains(this.#Q)&&this.contains(this.#Z))return;this.#_();let Q=X0({owner:"select",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>i(this,"y",-1),onEnd:()=>i(this,"y",1)});this.#Q=Q.start,this.#Z=Q.end,this.prepend(this.#Q),this.append(this.#Z)}#_(){this.#Q?.remove(),this.#Z?.remove(),this.#Q=null,this.#Z=null,this.classList.remove("overflow-start","overflow-end")}}z("fig-select-options",d0);class s0 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#_=!1;#Y=-1;#X=!1;#W=!1;#N=null;#K=!1;#G=null;#U=null;#L=!1;#F=this.#Z0.bind(this);#z=this.#j0.bind(this);#B=this.#q0.bind(this);#M=this.#e.bind(this);#D=this.#c.bind(this);static get observedAttributes(){return["value","disabled","label","options","position","offset","closedby","open"]}get value(){return this.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get open(){return F(this,"open")}set open(Q){if(Q)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(!this.#_)this.#f();if(this.#H(),this.#S(),this.#r(),this.#t(),this.#i(),this.#m(),this.open)this.#_0()}disconnectedCallback(){this.#x(),document.removeEventListener("keydown",this.#B,!0),this.#q?.disconnect(),this.#q=null}attributeChangedCallback(Q,Z,$){if(Z===$||!this.#_)return;if(Q==="options"){this.#S(),this.#i();return}if(Q==="value"||Q==="label"){this.#i();return}if(Q==="disabled"){this.#r();return}if(Q==="open"){if($===null||$==="false")this.#G0();else this.#_0();return}if(Q==="position"||Q==="offset"||Q==="closedby")this.#t()}focus(Q){this.#Q?.focus(Q)}blur(){this.#Q?.blur()}#T(Q){return Q?.nodeType===1&&(Q.tagName==="FIG-SELECT-OPTION"||Q.tagName==="FIG-MENU-SEPARATOR"||Q.tagName==="FIG-SELECT-OPTIONS")}#H(){for(let Q of this.querySelectorAll(":scope > fig-select-options"))if(!Q.hasAttribute("slot"))Q.setAttribute("slot","panel")}#O(){let Z=(this.#j?.assignedElements({flatten:!0})??[]).find(($)=>$.tagName==="FIG-SELECT-OPTIONS");if(Z)return Z;return this.querySelector(":scope > fig-select-options")}#R(){return Boolean(this.querySelector(":scope > fig-select-option:not([data-fig-generated]), :scope > fig-select-options > fig-select-option:not([data-fig-generated])"))}#P(){let Q=this.#O();if(Q){if(!Q.hasAttribute("slot"))Q.setAttribute("slot","panel");return Q}return Q=document.createElement("fig-select-options"),Q.setAttribute("slot","panel"),Q.setAttribute("data-fig-generated",""),this.appendChild(Q),Q}#S(){if(this.#R())return;let Q=this.hasAttribute("options"),Z=Q?this.#P():this.#O();if(!Z)return;this.#L=!0;try{for(let j of Z.querySelectorAll(":scope > fig-select-option[data-fig-generated]"))j.remove();if(!Q)return;let $=c1(this.getAttribute("options")),J=Z.querySelector(":scope > .fig-overflow-end");for(let j of $){let q=document.createElement("fig-select-option");if(q.setAttribute("data-fig-generated",""),q.setAttribute("value",u1(j)),q.textContent=p1(j),J)Z.insertBefore(q,J);else Z.appendChild(q)}}finally{this.#L=!1}}#f(){this.#_=!0;let Q=this.attachShadow({mode:"open"});Q.innerHTML=`
42
42
  <style>
43
43
  :host {
44
44
  display: inline-flex;
@@ -127,7 +127,7 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
127
127
  max-height: inherit;
128
128
  }
129
129
  </style>
130
- `;let Z=document.createElement("fig-button");Z.className="fig-select-trigger",Z.setAttribute("part","trigger"),Z.setAttribute("variant","ghost"),Z.setAttribute("aria-haspopup","listbox"),Z.setAttribute("aria-expanded","false");let $=document.createElement("span");$.className="fig-select-prepend",$.setAttribute("part","prepend"),$.setAttribute("aria-hidden","true");let J=document.createElement("span");J.className="fig-select-label",J.setAttribute("part","label"),Z.append($,J);let j=document.createElement("dialog",{is:"fig-popup"});if(j.setAttribute("is","fig-popup"),j.setAttribute("part","listbox"),j.setAttribute("theme","menu"),j.setAttribute("role","listbox"),"popover"in HTMLElement.prototype)j.setAttribute("popover","manual");j.id=g(),Z.setAttribute("aria-controls",j.id);let q=document.createElement("slot");if(q.setAttribute("name","panel"),j.appendChild(q),Q.append(Z,j),this.#Z=Z,this.#$=$,this.#J=J,this.#Q=j,this.#j=q,j.anchor=Z,this.#H(),this.#b(),this.#I(),!this.hasAttribute("value")){let _=this.#v().find((X)=>F(X,"selected"));if(_)this.setAttribute("value",_.value)}}#I(){if(!this.#Q||this.#W)return;if(typeof this.#Q.positionPopup!=="function")return;this.#N=this.#Q.positionPopup.bind(this.#Q),this.#Q.positionPopup=()=>{if(!this.open){this.#N?.();return}this.#V()},this.#W=!0}#A(Q){if(!Q)return null;let Z=document.createRange();Z.selectNodeContents(Q);let $=[...Z.getClientRects()].filter((J)=>J.width>0&&J.height>0);if($.length)return $[0];return Q.getBoundingClientRect()}#k(){if(typeof this.#Q?.parseViewportMargins==="function")return this.#Q.parseViewportMargins();return{top:8,right:8,bottom:8,left:8}}#T(){let Q=this.#J?.getBoundingClientRect();if(!Q)return null;return{x:Q.x,y:Q.y,width:Q.width,height:Q.height}}#f(){let Q=window.visualViewport;return{width:Q?.width??window.innerWidth,height:Q?.height??window.innerHeight,offsetLeft:Q?.offsetLeft??0,offsetTop:Q?.offsetTop??0}}#y(Q,Z,$=0.25){if(!Q&&!Z)return!1;if(!Q||!Z)return!0;return Math.abs(Q.x-Z.x)>$||Math.abs(Q.y-Z.y)>$||Math.abs(Q.width-Z.width)>$||Math.abs(Q.height-Z.height)>$}#g(Q,Z,$=0.25){if(!Q&&!Z)return!1;if(!Q||!Z)return!0;return Math.abs(Q.width-Z.width)>$||Math.abs(Q.height-Z.height)>$||Math.abs(Q.offsetLeft-Z.offsetLeft)>$||Math.abs(Q.offsetTop-Z.offsetTop)>$}#h(){if(!this.#K)return!1;let Q=this.#y(this.#G,this.#T()),Z=this.#g(this.#U,this.#f());return!Q&&!Z}#w(){this.#G=this.#T(),this.#U=this.#f()}#V(){if(this.#h())return;let Q=this.#Q,Z=this.#J;if(!Q||!Z){this.#N?.();return}let $=this.#v(),J=$.find((L)=>this.#d(L)===this.value)||$[0];if(!J){this.#N?.();return}this.#N?.();let j=Q.getBoundingClientRect(),q=Z.getBoundingClientRect(),_=this.#A(J);if(!j.width||!j.height||!q.width||!_)return;let X=_.left-j.left,Y=_.top-j.top,G=F(this,"full")?this.getBoundingClientRect().left:q.left-X,N=q.top-Y,W=this.#k();if(typeof Q.clampToViewport==="function")({left:G,top:N}=Q.clampToViewport({left:G,top:N},j,W));else{let{left:L,top:T}=W,R=window.innerWidth-j.width-W.right,A=window.innerHeight-j.height-W.bottom;G=Math.min(Math.max(G,L),Math.max(L,R)),N=Math.min(Math.max(N,T),Math.max(T,A))}Q.style.setProperty("right","auto","important"),Q.style.setProperty("bottom","auto","important"),Q.style.setProperty("left",`${Math.round(G)}px`,"important"),Q.style.setProperty("top",`${Math.round(N)}px`,"important");let O=this.#O(),B=this.#A(J);if(B&&O&&O.scrollHeight>O.clientHeight+1){let L=B.top-q.top;if(Math.abs(L)>0.5)O.scrollTop+=L;O.syncOverflow?.()}if(this.#K||this.open)this.#w()}#b(){this.#Z?.addEventListener("click",this.#F),this.#Z?.addEventListener("keydown",this.#B),this.addEventListener("click",this.#z),this.#Q?.addEventListener("keydown",this.#B),this.#Q?.addEventListener("close",this.#M),this.#j?.addEventListener("slotchange",this.#D)}#x(){this.#Z?.removeEventListener("click",this.#F),this.#Z?.removeEventListener("keydown",this.#B),this.removeEventListener("click",this.#z),this.#Q?.removeEventListener("keydown",this.#B),this.#Q?.removeEventListener("close",this.#M),this.#j?.removeEventListener("slotchange",this.#D)}#u(){this.#H(),this.#i()}#m(){if(this.#q)return;this.#q=new MutationObserver((Q)=>{if(this.#X||this.#L)return;let Z=!1;for(let $ of Q){if($.type==="childList"){if([...$.addedNodes].some((J)=>this.#E(J))||[...$.removedNodes].some((J)=>this.#E(J))||$.target?.closest?.("fig-select-option"))Z=!0}if($.type==="attributes"&&$.target?.tagName==="FIG-SELECT-OPTION"&&($.attributeName==="value"||$.attributeName==="disabled"||$.attributeName==="label"))Z=!0;if($.type==="characterData"&&$.target?.parentElement?.tagName==="FIG-SELECT-OPTION")Z=!0}if(Z)this.#i()}),this.#q.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","disabled","selected","label"]})}#v({enabledOnly:Q=!1}={}){let Z=this.#O(),$=Z?Array.from(Z.querySelectorAll(":scope > fig-select-option")):[];if(!Q)return $;return $.filter((J)=>!F(J,"disabled"))}#d(Q){if(!Q)return"";if(typeof Q.value==="string")return Q.value;let Z=Q.getAttribute?.("value");if(Z!=null)return Z;return(Q.textContent||"").trim()}#p(Q){if(!Q)return"";let Z=Q.getAttribute?.("label");if(Z!=null&&Z!=="")return Z.trim();let $=[];for(let J of Q.childNodes){if(J.nodeType===Node.TEXT_NODE){let _=J.textContent?.trim();if(_)$.push(_);continue}if(!(J instanceof Element))continue;let j=J.getAttribute("slot");if(j==="prepend"||j==="append")continue;let q=J.textContent?.trim();if(q)$.push(q)}if($.length)return $.join(" ").trim();return(Q.textContent||"").trim()}#s(Q){if(!this.#$)return;let Z=Q?.querySelector?.(':scope > [slot="prepend"]');this.#$.replaceChildren(...Array.from(Z?.childNodes??[],($)=>$.cloneNode(!0)))}#t(){if(!this.#Q)return;this.#Q.setAttribute("position",this.getAttribute("position")||"bottom left");let Q=this.getAttribute("offset");if(Q)this.#Q.setAttribute("offset",Q);else this.#Q.removeAttribute("offset");let Z=this.getAttribute("closedby");if(Z)this.#Q.setAttribute("closedby",Z);else this.#Q.removeAttribute("closedby")}#r(){let Q=F(this,"disabled");if(this.#Z)if(Q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(Q&&this.open)this.open=!1}#c(Q){if(!Q.length)return null;let Z=Q.find(($)=>F($,"selected"));if(Z&&!F(Z,"disabled"))return Z;return Q.find(($)=>!F($,"disabled"))||Q[0]||null}#o(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0,composed:!0}))}#i(){if(this.#X)return;this.#X=!0;try{let Q=this.#v(),Z=this.hasAttribute("value"),$=Z?this.getAttribute("value"):null,J=Z?Q.find((X)=>this.#d(X)===$):null,j=!1;if(!J){if(Z){if(!Q.length){if(this.#J)this.#J.textContent=$||this.getAttribute("label")||"";return}if(J=this.#c(Q),J){let X=this.#d(J);if($!==X)this.setAttribute("value",X),j=!0}else this.removeAttribute("value"),j=!0}else if(J=Q.find((X)=>F(X,"selected")),J)this.setAttribute("value",this.#d(J)),j=!0}for(let X of Q){let Y=X===J;if(X.setAttribute("aria-selected",Y?"true":"false"),Y)X.setAttribute("selected","");else X.removeAttribute("selected")}let q=J&&this.#p(J)||this.getAttribute("label")||"";if(this.#J)this.#J.textContent=q;this.#s(J);let _=this.getAttribute("label")||"Select";if(this.#Z?.setAttribute("aria-label",_),this.#O()?.syncOverflow?.(),j)this.#o(this.getAttribute("value")??"")}finally{this.#X=!1}}#Z0(Q){if(F(this,"disabled"))return;Q.preventDefault(),Q.stopPropagation();let Z=!this.open;if(Z&&this.#Q&&this.#Z)this.#Q.anchor=this.#Z;this.open=Z}#j0(Q){let $=(typeof Q.composedPath==="function"?Q.composedPath():[]).find((J)=>J?.tagName==="FIG-SELECT-OPTION");if(!$||!this.contains($))return;if(F($,"disabled"))return;this.#l($)}#q0(Q){if(Q.currentTarget===document&&Q.key!=="Escape")return;if(!(this.open&&(this.#Q?.matches?.(":open")??!1))){if(this.#Z?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" ")){if(Q.preventDefault(),this.#Q&&this.#Z)this.#Q.anchor=this.#Z;this.open=!0,requestAnimationFrame(()=>{let j=this.#v({enabledOnly:!0}).findIndex((q)=>this.#d(q)===this.value);this.#a(j>=0?j:0)})}return}let $=this.#v({enabledOnly:!0});if(!$.length)return;switch(Q.key){case"ArrowDown":Q.preventDefault(),this.#$0(),this.#a(this.#Y+1);break;case"ArrowUp":Q.preventDefault(),this.#$0(),this.#a(this.#Y-1);break;case"Home":Q.preventDefault(),this.#a(0);break;case"End":Q.preventDefault(),this.#a($.length-1);break;case"Escape":Q.preventDefault(),this.open=!1,this.#Z?.focus();break;case"Enter":case" ":{this.#$0();let J=$[this.#Y];if(!J)return;Q.preventDefault(),this.#l(J);break}}}#e(){if(this.hasAttribute("open"))this.removeAttribute("open");this.#Z?.setAttribute("aria-expanded","false"),this.#Z?.focus(),this.#Y=-1}#l(Q){let Z=this.#d(Q);this.setAttribute("value",Z),this.#i(),this.#o(Z),this.open=!1}#J0(){return this.#v({enabledOnly:!0})}#$0(){let Q=this.#J0();if(!Q.length){this.#Y=-1;return}let Z=Q.find((J)=>J===document.activeElement),$=Z?Q.indexOf(Z):-1;this.#Y=$>=0?$:this.#Y}#a(Q){let Z=this.#J0();if(!Z.length)return;let $=(Q%Z.length+Z.length)%Z.length;this.#Y=$,Z[$]?.focus()}#n(){if(!this.#Q||!this.#Z)return;let Q=Math.ceil(this.getBoundingClientRect().width),Z=Math.ceil(this.#Z.getBoundingClientRect().width),$=Math.max(Q,Z,96);this.#Q.style.setProperty("width","max-content","important"),this.#Q.style.setProperty("min-width",`${$}px`,"important"),this.#Q.style.setProperty("max-width","min(20rem, calc(100vw - 1rem))","important")}#_0(){if(!this.#Q||F(this,"disabled"))return;if(this.#Z)this.#Q.anchor=this.#Z;this.#I(),this.#K=!1,this.#G=null,this.#U=null,this.#i(),this.#n(),this.#Q.open=!0,document.addEventListener("keydown",this.#B,!0),this.#Z?.setAttribute("aria-expanded","true"),this.#Y=-1,requestAnimationFrame(()=>{this.#n(),this.#V();let Q=this.#O(),$=this.#J0().findIndex((J)=>this.#d(J)===this.value);if($>=0)this.#a($);else if(this.#Z?.hasAttribute("data-focus-visible")||this.#Z?.matches?.(":focus-visible"))this.#a(0);Q?.syncOverflow?.(),this.#K=!0,this.#w()})}#G0(){if(!this.#Q)return;this.#K=!1,this.#G=null,this.#U=null,document.removeEventListener("keydown",this.#B,!0),this.#Q.open=!1,this.#Z?.setAttribute("aria-expanded","false")}}z("fig-select",s0);class i0 extends HTMLElement{#Z=!1;#Q=!1;#$=!1;#J="";#j=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#q={range:{min:0,max:100,step:1},hue:{min:0,max:255,step:1},delta:{min:-100,max:100,step:1},stepper:{min:0,max:100,step:25},opacity:{min:0,max:100,step:0.1,color:"#FF0000"}};#_;#Y;#X;#W;#N;#K;#G;#U=null;#L=null;#F=null;#z=null;constructor(){super();this.initialInnerHTML=null,this.#_=(Q)=>{Q.stopPropagation(),this.#g()},this.#Y=(Q)=>{Q.stopPropagation(),this.#h()},this.#N=(Q)=>{this.#w(Q)},this.#X=(Q)=>{Q.stopPropagation(),this.#O()},this.#W=(Q)=>{Q.stopPropagation(),this.#V()},this.#K=()=>{this.#Z=!0},this.#G=()=>{this.#Z=!1}}#B(){let Q=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.getAttribute("text")!=="false",this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.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.#q[this.type]||this.#q.range,$=(J,j)=>{let q=this.getAttribute(J),_=q===null||q.trim()===""?j:Number(q);return Number.isFinite(_)?_:j};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.hasAttribute("default")?this.getAttribute("default"):this.type==="delta"?0:this.min,this.#Q=this.type!=="range"&&(Q===null||typeof Q==="string"&&Q.trim()===""),this.value=this.#A(Q)}#M(){if(!this.querySelector("[type=range]"))return!1;return this.getAttribute("text")!=="false"===!!this.querySelector("fig-input-number")}#D(){if(this.#B(),this.color)this.style.setProperty("--color",this.color);else this.style.removeProperty("--color");if(this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.input.className=this.type,this.input.min=String(this.min),this.input.max=String(this.max),this.input.step=String(this.step),this.input.value=String(this.value),this.input.disabled=this.disabled,this.text)this.input.setAttribute("tabindex","-1");else this.input.removeAttribute("tabindex");if(this.input.setAttribute("aria-valuemin",String(this.min)),this.input.setAttribute("aria-valuemax",String(this.max)),this.input.setAttribute("aria-valuenow",String(this.value)),this.figInputNumber=this.querySelector("fig-input-number"),this.figInputNumber){if(this.figInputNumber.setAttribute("placeholder",this.placeholder),this.figInputNumber.setAttribute("min",String(this.min)),this.figInputNumber.setAttribute("max",String(this.max)),this.figInputNumber.setAttribute("transform",String(this.transform)),this.figInputNumber.setAttribute("step",String(this.step)),this.figInputNumber.setAttribute("value",this.#Q?"":String(this.value)),this.units)this.figInputNumber.setAttribute("units",this.units);else this.figInputNumber.removeAttribute("units");if(this.precision!==null)this.figInputNumber.setAttribute("precision",String(this.precision));else this.figInputNumber.removeAttribute("precision");this.figInputNumber.disabled=this.disabled,this.figInputNumber.toggleAttribute("disabled",this.disabled)}}#E(){if(this.#f(),this.input.removeEventListener("input",this.#_),this.input.addEventListener("input",this.#_),this.input.removeEventListener("change",this.#Y),this.input.addEventListener("change",this.#Y),this.input.removeEventListener("keydown",this.#N),this.input.addEventListener("keydown",this.#N),this.input.removeEventListener("pointerdown",this.#K),this.input.addEventListener("pointerdown",this.#K),this.input.removeEventListener("pointerup",this.#G),this.input.addEventListener("pointerup",this.#G),this.input.removeEventListener("pointercancel",this.#G),this.input.addEventListener("pointercancel",this.#G),this.default)this.style.setProperty("--default",this.#R(this.default));if(this.figInputNumber)this.#y(),this.figInputNumber.removeEventListener("input",this.#X),this.figInputNumber.addEventListener("input",this.#X),this.figInputNumber.removeEventListener("change",this.#W),this.figInputNumber.addEventListener("change",this.#W)}#H(){if(this.#B(),this.color)this.style.setProperty("--color",this.color);let Q="",Z=`<div class="fig-slider-input-container" role="group">
130
+ `;let Z=document.createElement("fig-button");Z.className="fig-select-trigger",Z.setAttribute("part","trigger"),Z.setAttribute("variant","ghost"),Z.setAttribute("aria-haspopup","listbox"),Z.setAttribute("aria-expanded","false");let $=document.createElement("span");$.className="fig-select-prepend",$.setAttribute("part","prepend"),$.setAttribute("aria-hidden","true");let J=document.createElement("span");J.className="fig-select-label",J.setAttribute("part","label"),Z.append($,J);let j=document.createElement("dialog",{is:"fig-popup"});if(j.setAttribute("is","fig-popup"),j.setAttribute("part","listbox"),j.setAttribute("theme","menu"),j.setAttribute("role","listbox"),"popover"in HTMLElement.prototype)j.setAttribute("popover","manual");j.id=h(),Z.setAttribute("aria-controls",j.id);let q=document.createElement("slot");if(q.setAttribute("name","panel"),j.appendChild(q),Q.append(Z,j),this.#Q=Z,this.#$=$,this.#J=J,this.#Z=j,this.#j=q,j.anchor=Z,this.#H(),this.#g(),this.#I(),!this.hasAttribute("value")){let _=this.#h().find((X)=>F(X,"selected"));if(_)this.setAttribute("value",_.value)}}#I(){if(!this.#Z||this.#W)return;if(typeof this.#Z.positionPopup!=="function")return;this.#N=this.#Z.positionPopup.bind(this.#Z),this.#Z.positionPopup=()=>{if(!this.open){this.#N?.();return}this.#V()},this.#W=!0}#A(Q){if(!Q)return null;let Z=document.createRange();Z.selectNodeContents(Q);let $=[...Z.getClientRects()].filter((J)=>J.width>0&&J.height>0);if($.length)return $[0];return Q.getBoundingClientRect()}#E(){if(typeof this.#Z?.parseViewportMargins==="function")return this.#Z.parseViewportMargins();return{top:8,right:8,bottom:8,left:8}}#C(){let Q=this.#J?.getBoundingClientRect();if(!Q)return null;return{x:Q.x,y:Q.y,width:Q.width,height:Q.height}}#k(){let Q=window.visualViewport;return{width:Q?.width??window.innerWidth,height:Q?.height??window.innerHeight,offsetLeft:Q?.offsetLeft??0,offsetTop:Q?.offsetTop??0}}#y(Q,Z,$=0.25){if(!Q&&!Z)return!1;if(!Q||!Z)return!0;return Math.abs(Q.x-Z.x)>$||Math.abs(Q.y-Z.y)>$||Math.abs(Q.width-Z.width)>$||Math.abs(Q.height-Z.height)>$}#v(Q,Z,$=0.25){if(!Q&&!Z)return!1;if(!Q||!Z)return!0;return Math.abs(Q.width-Z.width)>$||Math.abs(Q.height-Z.height)>$||Math.abs(Q.offsetLeft-Z.offsetLeft)>$||Math.abs(Q.offsetTop-Z.offsetTop)>$}#b(){if(!this.#K)return!1;let Q=this.#y(this.#G,this.#C()),Z=this.#v(this.#U,this.#k());return!Q&&!Z}#w(){this.#G=this.#C(),this.#U=this.#k()}#V(){if(this.#b())return;let Q=this.#Z,Z=this.#J;if(!Q||!Z){this.#N?.();return}let $=this.#h(),J=$.find((L)=>this.#d(L)===this.value)||$[0];if(!J){this.#N?.();return}this.#N?.();let j=Q.getBoundingClientRect(),q=Z.getBoundingClientRect(),_=this.#A(J);if(!j.width||!j.height||!q.width||!_)return;let X=_.left-j.left,Y=_.top-j.top,G=F(this,"full")?this.getBoundingClientRect().left:q.left-X,N=q.top-Y,W=this.#E();if(typeof Q.clampToViewport==="function")({left:G,top:N}=Q.clampToViewport({left:G,top:N},j,W));else{let{left:L,top:T}=W,R=window.innerWidth-j.width-W.right,A=window.innerHeight-j.height-W.bottom;G=Math.min(Math.max(G,L),Math.max(L,R)),N=Math.min(Math.max(N,T),Math.max(T,A))}Q.style.setProperty("right","auto","important"),Q.style.setProperty("bottom","auto","important"),Q.style.setProperty("left",`${Math.round(G)}px`,"important"),Q.style.setProperty("top",`${Math.round(N)}px`,"important");let O=this.#O(),B=this.#A(J);if(B&&O&&O.scrollHeight>O.clientHeight+1){let L=B.top-q.top;if(Math.abs(L)>0.5)O.scrollTop+=L;O.syncOverflow?.()}if(this.#K||this.open)this.#w()}#g(){this.#Q?.addEventListener("click",this.#F),this.#Q?.addEventListener("keydown",this.#B),this.addEventListener("click",this.#z),this.#Z?.addEventListener("keydown",this.#B),this.#Z?.addEventListener("close",this.#M),this.#j?.addEventListener("slotchange",this.#D)}#x(){this.#Q?.removeEventListener("click",this.#F),this.#Q?.removeEventListener("keydown",this.#B),this.removeEventListener("click",this.#z),this.#Z?.removeEventListener("keydown",this.#B),this.#Z?.removeEventListener("close",this.#M),this.#j?.removeEventListener("slotchange",this.#D)}#c(){this.#H(),this.#i()}#m(){if(this.#q)return;this.#q=new MutationObserver((Q)=>{if(this.#X||this.#L)return;let Z=!1;for(let $ of Q){if($.type==="childList"){if([...$.addedNodes].some((J)=>this.#T(J))||[...$.removedNodes].some((J)=>this.#T(J))||$.target?.closest?.("fig-select-option"))Z=!0}if($.type==="attributes"&&$.target?.tagName==="FIG-SELECT-OPTION"&&($.attributeName==="value"||$.attributeName==="disabled"||$.attributeName==="label"))Z=!0;if($.type==="characterData"&&$.target?.parentElement?.tagName==="FIG-SELECT-OPTION")Z=!0}if(Z)this.#i()}),this.#q.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","disabled","selected","label"]})}#h({enabledOnly:Q=!1}={}){let Z=this.#O(),$=Z?Array.from(Z.querySelectorAll(":scope > fig-select-option")):[];if(!Q)return $;return $.filter((J)=>!F(J,"disabled"))}#d(Q){if(!Q)return"";if(typeof Q.value==="string")return Q.value;let Z=Q.getAttribute?.("value");if(Z!=null)return Z;return(Q.textContent||"").trim()}#p(Q){if(!Q)return"";let Z=Q.getAttribute?.("label");if(Z!=null&&Z!=="")return Z.trim();let $=[];for(let J of Q.childNodes){if(J.nodeType===Node.TEXT_NODE){let _=J.textContent?.trim();if(_)$.push(_);continue}if(!(J instanceof Element))continue;let j=J.getAttribute("slot");if(j==="prepend"||j==="append")continue;let q=J.textContent?.trim();if(q)$.push(q)}if($.length)return $.join(" ").trim();return(Q.textContent||"").trim()}#s(Q){if(!this.#$)return;let Z=Q?.querySelector?.(':scope > [slot="prepend"]');this.#$.replaceChildren(...Array.from(Z?.childNodes??[],($)=>$.cloneNode(!0)))}#t(){if(!this.#Z)return;this.#Z.setAttribute("position",this.getAttribute("position")||"bottom left");let Q=this.getAttribute("offset");if(Q)this.#Z.setAttribute("offset",Q);else this.#Z.removeAttribute("offset");let Z=this.getAttribute("closedby");if(Z)this.#Z.setAttribute("closedby",Z);else this.#Z.removeAttribute("closedby")}#r(){let Q=F(this,"disabled");if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(Q&&this.open)this.open=!1}#u(Q){if(!Q.length)return null;let Z=Q.find(($)=>F($,"selected"));if(Z&&!F(Z,"disabled"))return Z;return Q.find(($)=>!F($,"disabled"))||Q[0]||null}#o(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0,composed:!0}))}#i(){if(this.#X)return;this.#X=!0;try{let Q=this.#h(),Z=this.hasAttribute("value"),$=Z?this.getAttribute("value"):null,J=Z?Q.find((X)=>this.#d(X)===$):null,j=!1;if(!J){if(Z){if(!Q.length){if(this.#J)this.#J.textContent=$||this.getAttribute("label")||"";return}if(J=this.#u(Q),J){let X=this.#d(J);if($!==X)this.setAttribute("value",X),j=!0}else this.removeAttribute("value"),j=!0}else if(J=Q.find((X)=>F(X,"selected")),J)this.setAttribute("value",this.#d(J)),j=!0}for(let X of Q){let Y=X===J;if(X.setAttribute("aria-selected",Y?"true":"false"),Y)X.setAttribute("selected","");else X.removeAttribute("selected")}let q=J&&this.#p(J)||this.getAttribute("label")||"";if(this.#J)this.#J.textContent=q;this.#s(J);let _=this.getAttribute("label")||"Select";if(this.#Q?.setAttribute("aria-label",_),this.#O()?.syncOverflow?.(),j)this.#o(this.getAttribute("value")??"")}finally{this.#X=!1}}#Z0(Q){if(F(this,"disabled"))return;Q.preventDefault(),Q.stopPropagation();let Z=!this.open;if(Z&&this.#Z&&this.#Q)this.#Z.anchor=this.#Q;this.open=Z}#j0(Q){let $=(typeof Q.composedPath==="function"?Q.composedPath():[]).find((J)=>J?.tagName==="FIG-SELECT-OPTION");if(!$||!this.contains($))return;if(F($,"disabled"))return;this.#l($)}#q0(Q){if(Q.currentTarget===document&&Q.key!=="Escape")return;if(!(this.open&&(this.#Z?.matches?.(":open")??!1))){if(this.#Q?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" ")){if(Q.preventDefault(),this.#Z&&this.#Q)this.#Z.anchor=this.#Q;this.open=!0,requestAnimationFrame(()=>{let j=this.#h({enabledOnly:!0}).findIndex((q)=>this.#d(q)===this.value);this.#a(j>=0?j:0)})}return}let $=this.#h({enabledOnly:!0});if(!$.length)return;switch(Q.key){case"ArrowDown":Q.preventDefault(),this.#$0(),this.#a(this.#Y+1);break;case"ArrowUp":Q.preventDefault(),this.#$0(),this.#a(this.#Y-1);break;case"Home":Q.preventDefault(),this.#a(0);break;case"End":Q.preventDefault(),this.#a($.length-1);break;case"Escape":Q.preventDefault(),this.open=!1,this.#Q?.focus();break;case"Enter":case" ":{this.#$0();let J=$[this.#Y];if(!J)return;Q.preventDefault(),this.#l(J);break}}}#e(){if(this.hasAttribute("open"))this.removeAttribute("open");this.#Q?.setAttribute("aria-expanded","false"),this.#Q?.focus(),this.#Y=-1}#l(Q){let Z=this.#d(Q);this.setAttribute("value",Z),this.#i(),this.#o(Z),this.open=!1}#J0(){return this.#h({enabledOnly:!0})}#$0(){let Q=this.#J0();if(!Q.length){this.#Y=-1;return}let Z=Q.find((J)=>J===document.activeElement),$=Z?Q.indexOf(Z):-1;this.#Y=$>=0?$:this.#Y}#a(Q){let Z=this.#J0();if(!Z.length)return;let $=(Q%Z.length+Z.length)%Z.length;this.#Y=$,Z[$]?.focus()}#n(){if(!this.#Z||!this.#Q)return;let Q=Math.ceil(this.getBoundingClientRect().width),Z=Math.ceil(this.#Q.getBoundingClientRect().width),$=Math.max(Q,Z,96);this.#Z.style.setProperty("width","max-content","important"),this.#Z.style.setProperty("min-width",`${$}px`,"important"),this.#Z.style.setProperty("max-width","min(20rem, calc(100vw - 1rem))","important")}#_0(){if(!this.#Z||F(this,"disabled"))return;if(this.#Q)this.#Z.anchor=this.#Q;this.#I(),this.#K=!1,this.#G=null,this.#U=null,this.#i(),this.#n(),this.#Z.open=!0,document.addEventListener("keydown",this.#B,!0),this.#Q?.setAttribute("aria-expanded","true"),this.#Y=-1,requestAnimationFrame(()=>{this.#n(),this.#V();let Q=this.#O(),$=this.#J0().findIndex((J)=>this.#d(J)===this.value);if($>=0)this.#a($);else if(this.#Q?.hasAttribute("data-focus-visible")||this.#Q?.matches?.(":focus-visible"))this.#a(0);Q?.syncOverflow?.(),this.#K=!0,this.#w()})}#G0(){if(!this.#Z)return;this.#K=!1,this.#G=null,this.#U=null,document.removeEventListener("keydown",this.#B,!0),this.#Z.open=!1,this.#Q?.setAttribute("aria-expanded","false")}}z("fig-select",s0);class i0 extends HTMLElement{#Q=!1;#Z=!1;#$=!1;#J=!1;#j="";#q=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#_={range:{min:0,max:100,step:1},hue:{min:0,max:255,step:1},delta:{min:-100,max:100,step:1},stepper:{min:0,max:100,step:25},opacity:{min:0,max:100,step:0.1,color:"#FF0000"}};#Y;#X;#W;#N;#K;#G;#U;#L=null;#F=null;#z=null;#B=null;constructor(){super();this.initialInnerHTML=null,this.#Y=(Q)=>{Q.stopPropagation(),this.#b()},this.#X=(Q)=>{Q.stopPropagation(),this.#w()},this.#K=(Q)=>{this.#V(Q)},this.#W=(Q)=>{Q.stopPropagation(),this.#R()},this.#N=(Q)=>{Q.stopPropagation(),this.#g()},this.#G=()=>{this.#Q=!0},this.#U=()=>{if(this.#Q=!1,this.#Z&&this.isConnected)this.#Z=!1,this.#O()}}#M(){let Q=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.getAttribute("text")!=="false",this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.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.#_[this.type]||this.#_.range,$=(J,j)=>{let q=this.getAttribute(J),_=q===null||q.trim()===""?j:Number(q);return Number.isFinite(_)?_:j};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.hasAttribute("default")?this.getAttribute("default"):this.type==="delta"?0:this.min,this.#$=this.type!=="range"&&(Q===null||typeof Q==="string"&&Q.trim()===""),this.value=this.#E(Q)}#D(){if(!this.querySelector("[type=range]"))return!1;return this.getAttribute("text")!=="false"===!!this.querySelector("fig-input-number")}#T(){if(this.#M(),this.color)this.style.setProperty("--color",this.color);else this.style.removeProperty("--color");if(this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.input.className=this.type,this.input.min=String(this.min),this.input.max=String(this.max),this.input.step=String(this.step),this.input.value=String(this.value),this.input.disabled=this.disabled,this.text)this.input.setAttribute("tabindex","-1");else this.input.removeAttribute("tabindex");if(this.input.setAttribute("aria-valuemin",String(this.min)),this.input.setAttribute("aria-valuemax",String(this.max)),this.input.setAttribute("aria-valuenow",String(this.value)),this.figInputNumber=this.querySelector("fig-input-number"),this.figInputNumber){if(this.figInputNumber.setAttribute("placeholder",this.placeholder),this.figInputNumber.setAttribute("min",String(this.min)),this.figInputNumber.setAttribute("max",String(this.max)),this.figInputNumber.setAttribute("transform",String(this.transform)),this.figInputNumber.setAttribute("step",String(this.step)),this.figInputNumber.setAttribute("value",this.#$?"":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)}}#H(){if(this.#y(),this.input.removeEventListener("input",this.#Y),this.input.addEventListener("input",this.#Y),this.input.removeEventListener("change",this.#X),this.input.addEventListener("change",this.#X),this.input.removeEventListener("keydown",this.#K),this.input.addEventListener("keydown",this.#K),this.input.removeEventListener("pointerdown",this.#G),this.input.addEventListener("pointerdown",this.#G),this.input.removeEventListener("pointerup",this.#U),this.input.addEventListener("pointerup",this.#U),this.input.removeEventListener("pointercancel",this.#U),this.input.addEventListener("pointercancel",this.#U),this.default)this.style.setProperty("--default",this.#P(this.default));if(this.figInputNumber)this.#v(),this.figInputNumber.removeEventListener("input",this.#W),this.figInputNumber.addEventListener("input",this.#W),this.figInputNumber.removeEventListener("change",this.#N),this.figInputNumber.addEventListener("change",this.#N)}#O(){if(this.#M(),this.color)this.style.setProperty("--color",this.color);let Q="",Z=`<div class="fig-slider-input-container" role="group">
131
131
  <input
132
132
  type="range"
133
133
  ${this.text?'tabindex="-1"':""}
@@ -148,10 +148,10 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
148
148
  max="${this.max}"
149
149
  transform="${this.transform}"
150
150
  step="${this.step}"
151
- value="${this.#Q?"":this.value}"
151
+ value="${this.#$?"":this.value}"
152
152
  ${this.units?`units="${v(this.units)}"`:""}
153
153
  ${this.precision!==null?`precision="${this.precision}"`:""}>
154
- </fig-input-number>`;else Q=Z;if(this.innerHTML=Q,this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.figInputNumber=this.querySelector("fig-input-number"),this.#E(),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("id",g());let $=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1));for(let J=0;J<$;J++){let j=document.createElement("option");j.setAttribute("value",this.min+J*this.step),this.datalist.append(j)}this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.type==="delta"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",g());let $=document.createElement("option");$.setAttribute("value",this.default),this.datalist.append($),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let $=this.datalist.querySelector(`option[value='${this.default}']`);if($)$.setAttribute("default","true")}this.#T()}connectedCallback(){if(this.initialInnerHTML===null)this.initialInnerHTML=this.innerHTML;if(this.#M()){this.#D(),this.#E(),this.#T();return}this.#H()}get value(){if(this.#J!=="")return this.#J;let Q=this.getAttribute("value");if(Q!==null)return String(this.#A(Q));return""}set value(Q){let Z=Q===null||Q===void 0?"":String(Q),J=this.min!==void 0||this.max!==void 0?String(this.#A(Z)):Z;if(this.#J=J,this.getAttribute("value")!==J)this.#$=!0,this.setAttribute("value",J),this.#$=!1;if(this.input&&this.input.value!==J)this.input.value=J,this.input.setAttribute("aria-valuenow",J);if(this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":J);if(this.input)this.#k()}disconnectedCallback(){if(this.input)this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#Y),this.input.removeEventListener("keydown",this.#N),this.input.removeEventListener("pointerdown",this.#K),this.input.removeEventListener("pointerup",this.#G),this.input.removeEventListener("pointercancel",this.#G);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#X),this.figInputNumber.removeEventListener("change",this.#W)}#O(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let Z=this.#A(Q);this.value=Z,this.input.value=String(Z),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#R(Q){let{min:Z,max:$}=this.#C(),J=$-Z;if(J===0)return 0;return(Number(Q)-Z)/J}#P(Q){if(Q===null||Q===void 0)return null;if(typeof Q==="string"&&Q.trim()==="")return null;let Z=Number(Q);return Number.isFinite(Z)?Z:null}#C(){let Q=this.#P(this.min),Z=this.#P(this.max);if(Q===null)Q=0;if(Z===null)Z=Q;if(Q>Z)[Q,Z]=[Z,Q];return{min:Q,max:Z}}#S(Q){let{min:Z,max:$}=this.#C();return Math.min($,Math.max(Z,Q))}#I(){if(this.type==="delta"){let Z=this.#P(this.default);if(Z!==null)return this.#S(Z);return this.#S(0)}if(this.type==="range"){let{min:Z,max:$}=this.#C();return this.#S(Z+($-Z)/2)}let{min:Q}=this.#C();return Q}#A(Q){let Z=this.#P(Q);if(Z===null)return this.#I();return this.#S(Z)}#k(){let Q=this.#R(this.value),Z=this.#R(this.default),$=Q<Z?-1:1,J=Q===Z?1:0;if(this.#U!==Q)this.style.setProperty("--slider-complete",Q),this.#U=Q;if(this.#L!==Z)this.style.setProperty("--default",Z),this.#L=Z;if(this.#F!==$)this.style.setProperty("--slider-delta-direction",$),this.#F=$;if(this.#z!==J)this.style.setProperty("--unchanged",J),this.#z=J}#T(){let Q=this.input.value;if(this.value=Q,this.#k(),this.input.setAttribute("aria-valuenow",Q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Q)}#f(){if(!this.input)return;if(this.text){this.input.setAttribute("aria-hidden","true"),["aria-label","aria-labelledby","aria-describedby","aria-valuetext"].forEach((Q)=>this.input.removeAttribute(Q)),this.#y();return}this.input.removeAttribute("aria-hidden"),this.#j.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#y(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.figInputNumber.removeAttribute(Q);else this.figInputNumber.setAttribute(Q,Z)})}#g(){this.#Q=!1,this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#h(){this.#Z=!1,this.#Q=!1,this.#T(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#w(Q){if(this.disabled||!Q.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Q.key))return;Q.preventDefault(),this.#Q=!1;let Z=Q.key==="ArrowRight"||Q.key==="ArrowUp"?1:-1,$=this.#P(this.input.value)??this.#I(),J=this.#P(this.step)??1,j=this.#A($+J*10*Z);this.value=j,this.input.value=String(j),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#V(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let Z=this.#A(Q);this.value=Z,this.input.value=String(Z),this.#T(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"]}focus(){if(this.text&&this.figInputNumber){this.figInputNumber.focus();return}this.input.focus()}attributeChangedCallback(Q,Z,$){if(Q==="value"&&this.#$)return;if(this.input)switch(Q){case"color":this.color=$,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=$!==null&&$!=="false",this.figInputNumber)this.figInputNumber.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#Z)break;if(this.#Q=$===null||typeof $==="string"&&$.trim()==="",this.value=this.#A($),this.input.value=String(this.value),this.#T(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":this.value);break;case"transform":if(this.transform=Number($)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=$!==null?Number($):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=$!==null?$:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=$!==null?$:this.type==="delta"?0:this.min,this.#k();break;case"min":case"max":case"step":case"type":case"variant":case"units":this[Q]=$,this.#H();break;case"text":this.text=$!=="false",this.#H();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#f();break;default:this[Q]=this.input[Q]=$,this.#T();break}}}z("fig-slider",i0);class r0 extends HTMLElement{#Z=!1;#Q=!1;#$="";#J=!1;#j;#q;#_;#Y;#X;#W;#N;#K;#G=null;#U=0;#L="";#F="";#z=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#j=this.#f.bind(this),this.#q=this.#g.bind(this),this.#_=this.#g.bind(this),this.#Y=this.#y.bind(this),this.#X=(Q)=>{Q.stopPropagation(),this.#T(Q)},this.#W=(Q)=>{Q.stopPropagation();let Z=Q.target.value;if(this.type==="number")Z=Number(Z)/(this.transform||1);this.value=Z,this.#C(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))},this.#N=()=>{if(!this.disabled)this.focus()},this.#K=this.#M.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")&&this.getAttribute("multiline")!=="false",this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}if(this.input=this.#B(),this.input.readOnly=this.readonly,this.disabled=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.input.disabled=this.disabled,this.#O(),this.#R(),this.#P(),this.#C(),this.#S(),this.#A(),q0(this),this.#D(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#k(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#k(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#k(this.step));this.addEventListener("pointerdown",this.#Y)}this.removeEventListener("click",this.#K),this.addEventListener("click",this.#K),this.input.removeEventListener("change",this.#X),this.input.addEventListener("change",this.#X),this.input.removeEventListener("input",this.#W),this.input.addEventListener("input",this.#W)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#X),this.input.removeEventListener("input",this.#W);if(this.removeEventListener("click",this.#K),this.removeEventListener("pointerdown",this.#Y),window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#q),window.removeEventListener("blur",this.#_),this.#G?.disconnect(),this.#G=null,this.#U)cancelAnimationFrame(this.#U),this.#U=0}focus(){this.input.focus()}#B(){let Q=this.multiline,Z=this.querySelector("input,textarea");if(Z){if(Q?Z.tagName==="TEXTAREA":Z.tagName==="INPUT")return Z;Z.remove()}let $;if(Q)$=document.createElement("textarea"),$.value=this.value;else $=document.createElement("input"),$.type=this.type,$.value=this.type==="number"?this.#k(this.value):this.value;if($.setAttribute("data-generated","input-control"),this.name)$.name=this.name;return $.placeholder=this.placeholder,this.insertBefore($,this.querySelector('[slot="append"]')),$}#M(Q){let Z=Q.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;if(this.disabled)return;this.focus()}#D(){this.#G?.disconnect(),this.#G=new MutationObserver(()=>this.#E()),this.#G.observe(this,{childList:!0,characterData:!0,subtree:!0})}#E(){if(this.#U)return;this.#U=requestAnimationFrame(()=>{if(this.#U=0,!this.isConnected)return;this.#H()})}#H(){if(!this.input||!this.contains(this.input))this.input=this.#B(),this.input.readOnly=this.readonly,this.input.addEventListener("change",this.#X),this.input.addEventListener("input",this.#W);this.#O(),this.#R(),this.#P(),this.#C(),this.#S(),this.#A(),q0(this)}#O(){if(!this.input)return;this.#z.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#R(){let Q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){Q?.remove();return}if(this.querySelector('[slot="prepend"]:not([data-generated])')){Q?.remove();return}if(Q){let J=Q.querySelector("fig-icon");if(J&&J.getAttribute("name")!=="search")J.setAttribute("name","search");return}let $=u("search");$.setAttribute("slot","prepend"),$.setAttribute("data-generated","search-prefix"),$.setAttribute("color","var(--figma-color-icon)"),$.addEventListener("click",this.#N),this.prepend($)}#P(){let Q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){Q?.remove();return}if(this.querySelector('[slot="append"]:not([data-generated])')){Q?.remove();return}if(Q){let _=Q.querySelector("fig-icon");if(_&&_.getAttribute("name")!=="close")_.setAttribute("name","close");return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","search-clear");let J=document.createElement("fig-tooltip");J.setAttribute("text","Clear search");let j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon",""),j.setAttribute("aria-label","Clear search");let q=u("close",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),J.append(j),$.append(J),this.append($),j.addEventListener("click",(_)=>{if(_.preventDefault(),_.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.#C(),this.focus()})}#C(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#S(){let Q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){Q?.remove(),this.#Q=!1;return}if(this.querySelector('[slot="append"]:not([data-generated])')){Q?.remove();return}if(Q){this.#I(Q);return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","password-toggle");let J=document.createElement("fig-tooltip"),j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon","");let q=u("visible",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),J.append(j),$.append(J),this.append($),this.#I($),j.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),this.disabled)return;if(this.#Q=!this.#Q,this.input)this.input.type=this.#Q?"text":"password";this.#I($),this.focus()})}#I(Q){let Z=Q.querySelector("fig-tooltip"),$=Q.querySelector("fig-button"),J=Q.querySelector("fig-icon"),j=this.#Q?"Hide password":"Show password";Z?.setAttribute("text",j),$?.setAttribute("aria-label",j),J?.setAttribute("name",this.#Q?"visible":"hidden")}#A(){this.querySelectorAll('[data-generated="search-clear"] fig-button, [data-generated="password-toggle"] fig-button').forEach((Q)=>{if(this.disabled)Q.setAttribute("disabled","");else Q.removeAttribute("disabled")})}#k(Q){if(Q==="")return"";let Z=Number(Q)*(this.transform||1);return Z=this.#w(Z),Z}#T(Q){Q.stopPropagation();let Z=Q.target.value,$=Z;if(this.type==="number")Z=Z/(this.transform||1),Z=this.#h(Z,!1),$=Z*(this.transform||1);this.value=Z,this.input.value=$,this.#C(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#f(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#g();return}let Z=(this.step||1)*Q.movementX,$=Number(this.input.value);$=$/(this.transform||1)+Z,$=this.#h($,!1);let J=$*(this.transform||1);$=this.#w($),J=this.#w(J),this.value=$,this.input.value=J,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#y(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#Z=!0,this.#L=this.style.userSelect,this.#F=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.#j),window.addEventListener("pointerup",this.#q),window.addEventListener("pointercancel",this.#q),window.addEventListener("blur",this.#_)}#g(Q){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.#F,this.style.userSelect=this.#L,window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#q),window.removeEventListener("pointercancel",this.#q),window.removeEventListener("blur",this.#_),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#h(Q,Z=!0){let $=Q;if(this.type==="number"){if($=Number($),typeof this.min==="number")$=Math.max(Z?this.#k(this.min):this.min,$);if(typeof this.max==="number")$=Math.min(Z?this.#k(this.max):this.max,$);$=this.#w($)}return $}#w(Q,Z=2){let $=Math.round(Q*100)/100;return Number.isInteger($)?$:$.toFixed(Z)}get value(){return this.#$}set value(Q){let Z=Q??"";this.#$=Z;let $=String(Z);if(this.getAttribute("value")!==$)this.#J=!0,this.setAttribute("value",$),this.#J=!1;this.#V(Z)}#V(Q){if(!this.input||this.#Z)return;let Z=this.type==="number"?String(this.#k(Q)):String(Q??"");if(this.input.value!==Z)this.input.value=Z;this.#C()}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(Q,Z,$){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false",this.#A();break;case"readonly":this.readonly=$!==null&&$!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number($)||1,this.input.value=this.#k(this.value);break;case"value":if(this.#Z)break;let J=$;if(this.type==="number")J=this.#h(J,!1);if(this.#$=J??"",!this.#J)this.#V(this.#$);break;case"min":case"max":case"step":if($===null||$==="")this[Q]=void 0,this.input.removeAttribute(Q);else this[Q]=this.input[Q]=Number($),this.input.setAttribute(Q,$);break;case"name":if(this[Q]=this.input[Q]=$||"",$)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.#Y),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.#Y);this.#R(),this.#P(),this.#C(),this.#S(),this.#A();break;case"multiline":{let j=$!==null&&$!=="false";if(j!==this.multiline){this.multiline=j;let q=this.input;q.removeEventListener("change",this.#X),q.removeEventListener("input",this.#W),q.remove(),this.input=this.#B(),this.input.readOnly=this.readonly,this.input.disabled=Boolean(this.disabled),this.input.addEventListener("change",this.#X),this.input.addEventListener("input",this.#W),this.#O()}break}case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#O();break;default:this[Q]=this.input[Q]=$;break}}}z("fig-input-text",r0);class _0 extends HTMLElement{#Z;#Q;#$;#J;#j;#q;#_;#Y;#X;#W;#N;#K;#G;#U;#L;#F;#z=!1;#B=null;#M=null;#D=0;#E="";#H="";#O=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#R="px";#P(Q){return(Q||"").split(",").map((Z)=>Z.trim().toLowerCase()).filter(Boolean)}#C(Q){let Z=(Q||"").trim();if(!Z)return"";return(this.#U??[]).includes(Z.toLowerCase())?"":Z}#S(){this.#K=this.#C(this.#G)}#I(Q){if(Q&&!this.#B)this.#B=document.createElement("span"),this.#B.className="fig-steppers",this.#B.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#B.addEventListener("pointerdown",(Z)=>{Z.preventDefault(),Z.stopPropagation();let $=Z.target.closest("button");if(!$||this.disabled||$.disabled)return;let J=$.classList.contains("fig-stepper-up")?1:-1;this.#k(J),this.input.focus()}),this.append(this.#B);else if(!Q&&this.#B)this.#B.remove(),this.#B=null;this.#A()}#A(){if(!this.#B)return;let Q=this.#B.querySelector(".fig-stepper-up"),Z=this.#B.querySelector(".fig-stepper-down");if(!Q||!Z)return;let $=this.input?this.#b(this.input.value):this.value,J=$!==""&&$!==null&&$!==void 0?Number($)/(this.transform||1):Number(this.value),j=Number.isFinite(J),q=Boolean(this.disabled),_=j&&typeof this.min==="number"&&J<=this.min,X=j&&typeof this.max==="number"&&J>=this.max;Q.disabled=q||X,Z.disabled=q||_}#k(Q){let Z=this.step||1,$=this.#b(this.input.value),J=($!==""?Number($)/(this.transform||1):0)+Z*Q;J=this.#o(J,!1),this.value=J,this.input.value=this.#x(this.value),this.#A(),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#Z=this.#t.bind(this),this.#Q=this.#c.bind(this),this.#$=this.#c.bind(this),this.#J=this.#r.bind(this),this.#j=(Q)=>{Q.stopPropagation(),this.#s(Q)},this.#q=(Q)=>{Q.stopPropagation(),this.#p(Q)},this.#_=(Q)=>{this.#m(Q)},this.#Y=(Q)=>{this.#v(Q)},this.#X=(Q)=>{this.#d(Q)},this.#W=this.focus.bind(this),this.#N=this.#f.bind(this)}connectedCallback(){let Q=this.getAttribute("value");this.value=Q!==null&&Q!==""?Number(Q):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#G=this.getAttribute("units")||"";let Z=this.getAttribute("units-disallow");if(this.#U=this.#P(Z===null?_0.#R:Z),this.#S(),this.#L=this.getAttribute("unit-position")||"suffix",this.#F=this.#Z0(this.hasAttribute("precision")?this.getAttribute("precision"):2),this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));this.transform=Number(this.getAttribute("transform")||1);let $=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.input=this.#T(),this.#w(),this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.#I($),this.hasAttribute("disabled")){let J=this.getAttribute("disabled");this.disabled=this.input.disabled=J!=="false"}this.#A(),this.#V(),q0(this),this.addEventListener("pointerdown",this.#J),this.removeEventListener("click",this.#N),this.addEventListener("click",this.#N),this.#y(),this.input.removeEventListener("change",this.#j),this.input.addEventListener("change",this.#j),this.input.removeEventListener("input",this.#q),this.input.addEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.addEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#Y),this.input.addEventListener("blur",this.#Y),this.input.removeEventListener("keydown",this.#X),this.input.addEventListener("keydown",this.#X)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#j),this.input.removeEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#Y),this.input.removeEventListener("keydown",this.#X);if(this.removeEventListener("click",this.#N),this.removeEventListener("pointerdown",this.#J),window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#$),this.#M?.disconnect(),this.#M=null,this.#D)cancelAnimationFrame(this.#D),this.#D=0}focus(){this.input.focus()}#T(){let Q=this.querySelector("input");if(Q)return Q;let Z=document.createElement("input");if(Z.type="text",Z.inputMode="decimal",Z.setAttribute("data-generated","input-control"),this.name)Z.name=this.name;return Z.placeholder=this.placeholder,Z.value=this.#x(this.value),this.insertBefore(Z,this.querySelector('[slot="append"]')),Z}#f(Q){let Z=Q.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;this.focus()}#y(){this.#M?.disconnect(),this.#M=new MutationObserver(()=>this.#g()),this.#M.observe(this,{childList:!0,characterData:!0,subtree:!0})}#g(){if(this.#D)return;this.#D=requestAnimationFrame(()=>{if(this.#D=0,!this.isConnected)return;this.#h()})}#h(){if(!this.input||!this.contains(this.input))this.input=this.#T(),this.input.addEventListener("change",this.#j),this.input.addEventListener("input",this.#q),this.input.addEventListener("focus",this.#_),this.input.addEventListener("blur",this.#Y),this.input.addEventListener("keydown",this.#X);let Q=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.#B&&!this.contains(this.#B))this.#B=null;this.#I(Q),this.#w(),this.#V(),q0(this)}#w(){if(!this.input)return;this.#O.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#V(){if(!this.input)return;if(this.input.setAttribute("role","spinbutton"),typeof this.min==="number")this.input.setAttribute("aria-valuemin",String(this.min));else this.input.removeAttribute("aria-valuemin");if(typeof this.max==="number")this.input.setAttribute("aria-valuemax",String(this.max));else this.input.removeAttribute("aria-valuemax");let Q=this.value===""?null:Number(this.value);if(Number.isFinite(Q))this.input.setAttribute("aria-valuenow",String(Q)),this.input.setAttribute("aria-valuetext",this.#x(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#b(Q){if(!Q)return"";if(!this.#K){let J=Q.replace(/[^\d.-]/g,""),j=J.split(".");if(j.length>2)J=j[0]+"."+j.slice(1).join("");return J}let Z=Q.replace(this.#K,"").trim();Z=Z.replace(/[^\d.-]/g,"");let $=Z.split(".");if($.length>2)Z=$[0]+"."+$.slice(1).join("");return Z}#x(Q){if(Q===""||Q===null||Q===void 0)return"";let Z=Number(Q)*(this.transform||1);if(isNaN(Z))return"";if(Z=this.#i(Z),!this.#K)return Z.toString();if(this.#L==="prefix")return this.#K+Z;else return Z+this.#K}#u(Q){if(Q===""||Q===null||Q===void 0)return"";let Z=Number(Q)*(this.transform||1);return Z=this.#i(Z),Z.toString()}#m(Q){this.#z=!0,setTimeout(()=>{let Z=Q.target.value;if(Z&&this.#K)if(this.#L==="prefix")Q.target.setSelectionRange(this.#K.length,Z.length);else{let $=Z.indexOf(this.#K);if($>-1)Q.target.setSelectionRange(0,$)}},0)}#v(Q){this.#z=!1;let Z=this.#b(Q.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#o($,!1),this.value=$,Q.target.value=this.#x(this.value)}else this.value="",Q.target.value="";this.#A(),this.#V()}#d(Q){if(this.disabled)return;if(Q.key!=="ArrowUp"&&Q.key!=="ArrowDown")return;Q.preventDefault();let Z=this.step||1,$=Q.shiftKey?10:1,J=Z*$*(Q.key==="ArrowUp"?1:-1),j=this.#b(this.input.value),q=(j!==""?Number(j)/(this.transform||1):0)+J;q=this.#o(q,!1),this.value=q,this.input.value=this.#x(this.value),this.#A(),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#p(Q){let Z=this.#b(Q.target.value);if(Z!=="")this.value=Number(Z)/(this.transform||1);else this.value="";this.#A(),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#s(Q){Q.stopPropagation();let Z=this.#b(Q.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#o($,!1),this.value=$,Q.target.value=this.#x(this.value)}else this.value="",Q.target.value="";this.#A(),this.#V(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#t(Q){if(this.disabled)return;if(Q.buttons===0){this.#c();return}let Z=(this.step||1)*Q.movementX,$=this.#b(this.input.value),J=Number($)/(this.transform||1)+Z;J=this.#o(J,!1),this.value=J,this.input.value=this.#x(this.value),this.#A(),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#r(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#z=!0,this.#E=this.style.userSelect,this.#H=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.#Q),window.addEventListener("pointercancel",this.#Q),window.addEventListener("blur",this.#$)}#c(Q){let Z=this.#z;if(this.#z=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#H,this.style.userSelect=this.#E,window.removeEventListener("pointermove",this.#Z),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("pointercancel",this.#Q),window.removeEventListener("blur",this.#$),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#o(Q,Z=!0){let $=Number(Q);if(isNaN($))return"";if(typeof this.min==="number")$=Math.max(this.min,$);if(typeof this.max==="number")$=Math.min(this.max,$);return $=this.#i($),$}#i(Q){let Z=this.#F??2,$=Math.pow(10,Z),J=Math.round(Q*$)/$;return Number.isInteger(J)?J:parseFloat(J.toFixed(Z))}#Z0(Q){let Z=Number(Q);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(Q,Z,$){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false",this.#A();break;case"units":this.#G=$||"",this.#S(),this.input.value=this.#x(this.value),this.#V();break;case"units-disallow":this.#U=this.#P($===null?_0.#R:$),this.#S(),this.input.value=this.#x(this.value),this.#V();break;case"unit-position":this.#L=$||"suffix",this.input.value=this.#x(this.value),this.#V();break;case"transform":this.transform=Number($)||1,this.input.value=this.#x(this.value),this.#V();break;case"value":if(this.#z)break;let J=$!==null&&$!==""?Number($):"";if(J!=="")J=this.#o(J,!1);this.value=J,this.input.value=this.#x(this.value),this.#A(),this.#V();break;case"min":case"max":case"step":if($===null||$===""){this[Q]=void 0,this.#A(),this.#V();break}this[Q]=Number($),this.#A(),this.#V();break;case"steppers":{let j=$!==null&&$!=="false";this.#I(j);break}case"precision":this.#F=this.#Z0($!==null?$:2),this.input.value=this.#x(this.value),this.#V();break;case"name":if(this[Q]=this.input[Q]=$||"",$)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.#w();break;default:this[Q]=this.input[Q]=$;break}}}z("fig-input-number",_0);class o0 extends HTMLElement{constructor(){super()}connectedCallback(){this.src=this.getAttribute("src"),this.name=this.getAttribute("name"),this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials),this.setSrc(this.src),this.img=this.querySelector("img")}setSrc(Q){if(this.src=Q,!Q){this.querySelector(":scope > img")?.remove(),this.img=null;return}let Z=this.querySelector(":scope > img")||document.createElement("img");if(Z.src=Q,Z.alt=this.name||"",!Z.isConnected)this.replaceChildren(Z);this.img=Z}getInitials(Q){return Q?Q.split(" ").map((Z)=>Z[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(Q,Z,$){if(this[Q]=$,Q==="name"){if(this.img)this.img.alt=$||"";this.name=$,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials)}else if(Q==="src")this.src=$,this.setSrc(this.src)}}z("fig-avatar",o0);class l0 extends HTMLElement{#Z=!1;#Q=null;#$=null;#J=null;#j=null;#q=null;#_=null;constructor(){super();this.#$=this.#W.bind(this),this.#J=this.focus.bind(this),this.#j=this.#N.bind(this),this.#q=this.#K.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(!this.isConnected)return;this.#X(),this.#Y()})}#Y(){if(this.#_||typeof MutationObserver>"u")return;this.#_=new MutationObserver(()=>{this.#X()}),this.#_.observe(this,{childList:!0})}#X(){let Q=this.label,Z=this.#Q;Q?.removeEventListener("click",this.#$),Q?.removeEventListener("click",this.#J),Q?.removeEventListener("pointerenter",this.#j),Q?.removeEventListener("pointerleave",this.#q),Z?.removeEventListener("click",this.#$),this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.nodeName.toLowerCase().startsWith("fig-")&&!(j instanceof Element&&j.classList.contains("fig-field-chevron")));let $=this.input?.localName??"",J=$==="fig-select"||$==="fig-menu"||$==="fig-dropdown"||$==="fig-tooltip"||this.input instanceof HTMLDialogElement;if(this.#Z=!!(this.input&&("open"in this.input)&&!J),this.#Z&&this.label){if(!this.#Q||!this.#Q.isConnected)this.#Q=u("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#Q,this.label);this.#Q.addEventListener("click",this.#$),this.label.addEventListener("click",this.#$)}else{if(this.#Q)this.#Q.removeEventListener("click",this.#$),this.#Q.remove(),this.#Q=null;if(this.input&&this.label){if(this.input.querySelectorAll("input, select, textarea").length!==1)this.label.addEventListener("click",this.#J)}}if(this.input&&this.label&&!this.#Z)this.#G();if(this.label)this.label.removeEventListener("pointerenter",this.#j),this.label.addEventListener("pointerenter",this.#j),this.label.removeEventListener("pointerleave",this.#q),this.label.addEventListener("pointerleave",this.#q)}disconnectedCallback(){if(this.#_?.disconnect(),this.#_=null,this.label)H.hide(this.label);if(this.label&&this.#$)this.label.removeEventListener("click",this.#$);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.label&&this.#j)this.label.removeEventListener("pointerenter",this.#j);if(this.label&&this.#q)this.label.removeEventListener("pointerleave",this.#q);if(this.#Q&&this.#$)this.#Q.removeEventListener("click",this.#$)}#W(Q){if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open}#N(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;H.show(this.label,this.label.textContent.trim())}#K(){if(this.label)H.hide(this.label)}#G(){if(!this.input||!this.label)return;let Q=this.label.getAttribute("id")||g();this.label.setAttribute("id",Q);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")===Q)this.input.removeAttribute("aria-labelledby");if(!$.hasAttribute("aria-labelledby"))$.setAttribute("aria-labelledby",Q);return}if(this.label.removeAttribute("for"),!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-labelledby",Q)}attributeChangedCallback(Q,Z,$){switch(Q){case"label":if(this.label)this.label.textContent=$,this.#G();break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let Q=this.input.querySelectorAll("input, select, textarea");if(Q.length===1)Q[0].focus();else if(this.input.focus(),Q.length===0)this.input.click()}}z("fig-field",l0);class a0 extends HTMLElement{rgba;hex;#Z=100;#Q;#$;#J;#j;#q=!1;#_=!1;#Y=null;#X=this.#I.bind(this);#W=this.#A.bind(this);#N=this.#k.bind(this);#K=this.#V.bind(this);#G=this.#f.bind(this);#U=this.#g.bind(this);#L=this.#y.bind(this);#F=this.#b.bind(this);constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0||Q===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(Q))}#z(){let Q={};for(let{name:Z,value:$}of this.attributes)if(Z.startsWith("picker-")&&Z!=="picker-anchor"&&Z!=="picker-experimental")Q[Z.slice(7)]=$;if(!Q["dialog-position"])Q["dialog-position"]="left";return Q}#B(){let Q=this.#z();return Object.entries(Q).map(([Z,$])=>`${Z}="${$}"`).join(" ")}connectedCallback(){if(this.#M()){this.#D();return}this.#O()}disconnectedCallback(){this.#E()}#M(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-swatch")}#D(){if(this.#T(this.getAttribute("value")),this.#Q=this.querySelector("fig-swatch"),this.#$=this.querySelector("fig-fill-picker"),this.#J=this.querySelector("fig-input-text:not([type=number])"),this.#j=this.querySelector("fig-input-number"),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j)this.#j.setAttribute("value",String(this.#Z));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",String(this.rgba.a));this.#w(),this.#H()}#E(){if(this.#Q)this.#Q.removeEventListener("pointerdown",this.#X,{capture:!0}),this.#Q.removeEventListener("click",this.#W,{capture:!0}),this.#Q.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#N),this.#Q.removeEventListener("input",this.#K);this.#J?.removeEventListener("input",this.#G),this.#J?.removeEventListener("change",this.#U),this.#j?.removeEventListener("input",this.#L),this.#j?.removeEventListener("change",this.#U),this.#$?.removeEventListener("input",this.#F),this.#$?.removeEventListener("change",this.#U)}#H(){if(this.#Q){this.#Q.disabled=F(this,"disabled");let Q=this.#Q.querySelector('input[type="color"]');if(this.#J||this.hasAttribute("swatch-disabled"))Q?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(Q?.setAttribute("disabled",""),Q)Q.style.pointerEvents="none"}this.#Q.addEventListener("pointerdown",this.#X,{capture:!0}),this.#Q.addEventListener("click",this.#W,{capture:!0}),Q?.addEventListener("keydown",this.#N),this.#Q.addEventListener("input",this.#K)}if(this.#J)this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#U);if(this.#j)this.#j.addEventListener("input",this.#L),this.#j.addEventListener("change",this.#U);if(this.#$)this.#$.addEventListener("input",this.#F),this.#$.addEventListener("change",this.#U)}#O(){this.#T(this.getAttribute("value"));let Q=this.getAttribute("alpha")!=="false",$=this.#m?" disabled":"",J="";if(this.getAttribute("text")!=="false"){let q=`<fig-input-text
154
+ </fig-input-number>`;else Q=Z;if(this.innerHTML=Q,this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.figInputNumber=this.querySelector("fig-input-number"),this.#H(),this.datalist=this.querySelector("datalist"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||h()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",h());let $=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1));for(let J=0;J<$;J++){let j=document.createElement("option");j.setAttribute("value",this.min+J*this.step),this.datalist.append(j)}this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.type==="delta"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",h());let $=document.createElement("option");$.setAttribute("value",this.default),this.datalist.append($),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let $=this.datalist.querySelector(`option[value='${this.default}']`);if($)$.setAttribute("default","true")}this.#k()}connectedCallback(){if(this.initialInnerHTML===null)this.initialInnerHTML=this.innerHTML;if(this.#D()){this.#T(),this.#H(),this.#k();return}this.#O()}get value(){if(this.#j!=="")return this.#j;let Q=this.getAttribute("value");if(Q!==null)return String(this.#E(Q));return""}set value(Q){let Z=Q===null||Q===void 0?"":String(Q),J=this.min!==void 0||this.max!==void 0?String(this.#E(Z)):Z;if(this.#j=J,this.getAttribute("value")!==J)this.#J=!0,this.setAttribute("value",J),this.#J=!1;if(this.input&&this.input.value!==J)this.input.value=J,this.input.setAttribute("aria-valuenow",J);if(this.figInputNumber)this.figInputNumber.setAttribute("value",this.#$?"":J);if(this.input)this.#C()}disconnectedCallback(){if(this.#Z=!1,this.input)this.input.removeEventListener("input",this.#Y),this.input.removeEventListener("change",this.#X),this.input.removeEventListener("keydown",this.#K),this.input.removeEventListener("pointerdown",this.#G),this.input.removeEventListener("pointerup",this.#U),this.input.removeEventListener("pointercancel",this.#U);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#W),this.figInputNumber.removeEventListener("change",this.#N)}#R(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#$=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let Z=this.#E(Q);this.value=Z,this.input.value=String(Z),this.#k(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#P(Q){let{min:Z,max:$}=this.#f(),J=$-Z;if(J===0)return 0;return(Number(Q)-Z)/J}#S(Q){if(Q===null||Q===void 0)return null;if(typeof Q==="string"&&Q.trim()==="")return null;let Z=Number(Q);return Number.isFinite(Z)?Z:null}#f(){let Q=this.#S(this.min),Z=this.#S(this.max);if(Q===null)Q=0;if(Z===null)Z=Q;if(Q>Z)[Q,Z]=[Z,Q];return{min:Q,max:Z}}#I(Q){let{min:Z,max:$}=this.#f();return Math.min($,Math.max(Z,Q))}#A(){if(this.type==="delta"){let Z=this.#S(this.default);if(Z!==null)return this.#I(Z);return this.#I(0)}if(this.type==="range"){let{min:Z,max:$}=this.#f();return this.#I(Z+($-Z)/2)}let{min:Q}=this.#f();return Q}#E(Q){let Z=this.#S(Q);if(Z===null)return this.#A();return this.#I(Z)}#C(){let Q=this.#P(this.value),Z=this.#P(this.default),$=Q<Z?-1:1,J=Q===Z?1:0;if(this.#L!==Q)this.style.setProperty("--slider-complete",Q),this.#L=Q;if(this.#F!==Z)this.style.setProperty("--default",Z),this.#F=Z;if(this.#z!==$)this.style.setProperty("--slider-delta-direction",$),this.#z=$;if(this.#B!==J)this.style.setProperty("--unchanged",J),this.#B=J}#k(){let Q=this.input.value;if(this.value=Q,this.#C(),this.input.setAttribute("aria-valuenow",Q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#$?"":Q)}#y(){if(!this.input)return;if(this.text){this.input.setAttribute("aria-hidden","true"),["aria-label","aria-labelledby","aria-describedby","aria-valuetext"].forEach((Q)=>this.input.removeAttribute(Q)),this.#v();return}this.input.removeAttribute("aria-hidden"),this.#q.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#v(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.figInputNumber.removeAttribute(Q);else this.figInputNumber.setAttribute(Q,Z)})}#b(){this.#$=!1,this.#k(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#w(){this.#Q=!1,this.#$=!1,this.#k(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#V(Q){if(this.disabled||!Q.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Q.key))return;Q.preventDefault(),this.#$=!1;let Z=Q.key==="ArrowRight"||Q.key==="ArrowUp"?1:-1,$=this.#S(this.input.value)??this.#A(),J=this.#S(this.step)??1,j=this.#E($+J*10*Z);this.value=j,this.input.value=String(j),this.#k(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#g(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#$=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let Z=this.#E(Q);this.value=Z,this.input.value=String(Z),this.#k(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}#x(Q,Z){if(!this.input)return;let $=this.#_[this.type]||this.#_.range,J=Z===null||String(Z).trim()===""?$[Q]:Number(Z),j=Number.isFinite(J)?J:$[Q];if(Q==="step"&&!(j>0))j=$.step>0?$.step:1;if(this[Q]===j&&this.input[Q]===String(j))return;if(this[Q]=j,this.input[Q]=String(j),Q==="min")this.input.setAttribute("aria-valuemin",String(j));else if(Q==="max")this.input.setAttribute("aria-valuemax",String(j));if(this.figInputNumber)this.figInputNumber.setAttribute(Q,String(j));if(!this.hasAttribute("default")&&this.type!=="delta")this.default=this.min;this.value=this.#E(this.value),this.#C(),this.#c()}#c(){if(this.type!=="stepper"||!this.datalist)return;let Q=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1)),Z=document.createDocumentFragment();for(let $=0;$<Q;$++){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)}#m(){if(this.#Q){this.#Z=!0;return}this.#Z=!1,this.#O()}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"]}focus(){if(this.text&&this.figInputNumber){this.figInputNumber.focus();return}this.input.focus()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="value"&&this.#J)return;if(this.input)switch(Q){case"color":this.color=$,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=$!==null&&$!=="false",this.figInputNumber)this.figInputNumber.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#Q)break;if(this.#$=$===null||typeof $==="string"&&$.trim()==="",this.value=this.#E($),this.input.value=String(this.value),this.#k(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#$?"":this.value);break;case"transform":if(this.transform=Number($)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=$!==null?Number($):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=$!==null?$:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=$!==null?$:this.type==="delta"?0:this.min,this.#C();break;case"min":case"max":case"step":this.#x(Q,$);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.#Q)this[Q]=$;this.#m();break;case"text":if(!this.#Q)this.text=$!=="false";this.#m();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#y();break;default:this[Q]=this.input[Q]=$,this.#k();break}}}z("fig-slider",i0);class r0 extends HTMLElement{#Q=!1;#Z=!1;#$="";#J=!1;#j;#q;#_;#Y;#X;#W;#N;#K;#G=null;#U=0;#L="";#F="";#z=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#j=this.#k.bind(this),this.#q=this.#v.bind(this),this.#_=this.#v.bind(this),this.#Y=this.#y.bind(this),this.#X=(Q)=>{Q.stopPropagation(),this.#C(Q)},this.#W=(Q)=>{Q.stopPropagation();let Z=Q.target.value;if(this.type==="number")Z=Number(Z)/(this.transform||1);this.value=Z,this.#S(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))},this.#N=()=>{if(!this.disabled)this.focus()},this.#K=this.#M.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")&&this.getAttribute("multiline")!=="false",this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}if(this.input=this.#B(),this.input.readOnly=this.readonly,this.disabled=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.input.disabled=this.disabled,this.#O(),this.#R(),this.#P(),this.#S(),this.#f(),this.#A(),q0(this),this.#D(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#E(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#E(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#E(this.step));this.addEventListener("pointerdown",this.#Y)}this.removeEventListener("click",this.#K),this.addEventListener("click",this.#K),this.input.removeEventListener("change",this.#X),this.input.addEventListener("change",this.#X),this.input.removeEventListener("input",this.#W),this.input.addEventListener("input",this.#W)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#X),this.input.removeEventListener("input",this.#W);if(this.removeEventListener("click",this.#K),this.removeEventListener("pointerdown",this.#Y),window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#q),window.removeEventListener("blur",this.#_),this.#G?.disconnect(),this.#G=null,this.#U)cancelAnimationFrame(this.#U),this.#U=0}focus(){this.input.focus()}#B(){let Q=this.multiline,Z=this.querySelector("input,textarea");if(Z){if(Q?Z.tagName==="TEXTAREA":Z.tagName==="INPUT")return Z;Z.remove()}let $;if(Q)$=document.createElement("textarea"),$.value=this.value;else $=document.createElement("input"),$.type=this.type,$.value=this.type==="number"?this.#E(this.value):this.value;if($.setAttribute("data-generated","input-control"),this.name)$.name=this.name;return $.placeholder=this.placeholder,this.insertBefore($,this.querySelector('[slot="append"]')),$}#M(Q){let Z=Q.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;if(this.disabled)return;this.focus()}#D(){this.#G?.disconnect(),this.#G=new MutationObserver(()=>this.#T()),this.#G.observe(this,{childList:!0,characterData:!0,subtree:!0})}#T(){if(this.#U)return;this.#U=requestAnimationFrame(()=>{if(this.#U=0,!this.isConnected)return;this.#H()})}#H(){if(!this.input||!this.contains(this.input))this.input=this.#B(),this.input.readOnly=this.readonly,this.input.addEventListener("change",this.#X),this.input.addEventListener("input",this.#W);this.#O(),this.#R(),this.#P(),this.#S(),this.#f(),this.#A(),q0(this)}#O(){if(!this.input)return;this.#z.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#R(){let Q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){Q?.remove();return}if(this.querySelector('[slot="prepend"]:not([data-generated])')){Q?.remove();return}if(Q){let J=Q.querySelector("fig-icon");if(J&&J.getAttribute("name")!=="search")J.setAttribute("name","search");return}let $=u("search");$.setAttribute("slot","prepend"),$.setAttribute("data-generated","search-prefix"),$.setAttribute("color","var(--figma-color-icon)"),$.addEventListener("click",this.#N),this.prepend($)}#P(){let Q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){Q?.remove();return}if(this.querySelector('[slot="append"]:not([data-generated])')){Q?.remove();return}if(Q){let _=Q.querySelector("fig-icon");if(_&&_.getAttribute("name")!=="close")_.setAttribute("name","close");return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","search-clear");let J=document.createElement("fig-tooltip");J.setAttribute("text","Clear search");let j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon",""),j.setAttribute("aria-label","Clear search");let q=u("close",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),J.append(j),$.append(J),this.append($),j.addEventListener("click",(_)=>{if(_.preventDefault(),_.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.#S(),this.focus()})}#S(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#f(){let Q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){Q?.remove(),this.#Z=!1;return}if(this.querySelector('[slot="append"]:not([data-generated])')){Q?.remove();return}if(Q){this.#I(Q);return}let $=document.createElement("span");$.setAttribute("slot","append"),$.setAttribute("data-generated","password-toggle");let J=document.createElement("fig-tooltip"),j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon","");let q=u("visible",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),J.append(j),$.append(J),this.append($),this.#I($),j.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),this.disabled)return;if(this.#Z=!this.#Z,this.input)this.input.type=this.#Z?"text":"password";this.#I($),this.focus()})}#I(Q){let Z=Q.querySelector("fig-tooltip"),$=Q.querySelector("fig-button"),J=Q.querySelector("fig-icon"),j=this.#Z?"Hide password":"Show password";Z?.setAttribute("text",j),$?.setAttribute("aria-label",j),J?.setAttribute("name",this.#Z?"visible":"hidden")}#A(){this.querySelectorAll('[data-generated="search-clear"] fig-button, [data-generated="password-toggle"] fig-button').forEach((Q)=>{if(this.disabled)Q.setAttribute("disabled","");else Q.removeAttribute("disabled")})}#E(Q){if(Q==="")return"";let Z=Number(Q)*(this.transform||1);return Z=this.#w(Z),Z}#C(Q){Q.stopPropagation();let Z=Q.target.value,$=Z;if(this.type==="number")Z=Z/(this.transform||1),Z=this.#b(Z,!1),$=Z*(this.transform||1);this.value=Z,this.input.value=$,this.#S(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#k(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#v();return}let Z=(this.step||1)*Q.movementX,$=Number(this.input.value);$=$/(this.transform||1)+Z,$=this.#b($,!1);let J=$*(this.transform||1);$=this.#w($),J=this.#w(J),this.value=$,this.input.value=J,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#y(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#Q=!0,this.#L=this.style.userSelect,this.#F=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.#j),window.addEventListener("pointerup",this.#q),window.addEventListener("pointercancel",this.#q),window.addEventListener("blur",this.#_)}#v(Q){if(this.type!=="number")return;let Z=this.#Q;if(this.#Q=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#F,this.style.userSelect=this.#L,window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#q),window.removeEventListener("pointercancel",this.#q),window.removeEventListener("blur",this.#_),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#b(Q,Z=!0){let $=Q;if(this.type==="number"){if($=Number($),typeof this.min==="number")$=Math.max(Z?this.#E(this.min):this.min,$);if(typeof this.max==="number")$=Math.min(Z?this.#E(this.max):this.max,$);$=this.#w($)}return $}#w(Q,Z=2){let $=Math.round(Q*100)/100;return Number.isInteger($)?$:$.toFixed(Z)}get value(){return this.#$}set value(Q){let Z=Q??"";this.#$=Z;let $=String(Z);if(this.getAttribute("value")!==$)this.#J=!0,this.setAttribute("value",$),this.#J=!1;this.#V(Z)}#V(Q){if(!this.input||this.#Q)return;let Z=this.type==="number"?String(this.#E(Q)):String(Q??"");if(this.input.value!==Z)this.input.value=Z;this.#S()}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(Q,Z,$){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false",this.#A();break;case"readonly":this.readonly=$!==null&&$!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number($)||1,this.input.value=this.#E(this.value);break;case"value":if(this.#Q)break;let J=$;if(this.type==="number")J=this.#b(J,!1);if(this.#$=J??"",!this.#J)this.#V(this.#$);break;case"min":case"max":case"step":if($===null||$==="")this[Q]=void 0,this.input.removeAttribute(Q);else this[Q]=this.input[Q]=Number($),this.input.setAttribute(Q,$);break;case"name":if(this[Q]=this.input[Q]=$||"",$)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.#Y),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.#Y);this.#R(),this.#P(),this.#S(),this.#f(),this.#A();break;case"multiline":{let j=$!==null&&$!=="false";if(j!==this.multiline){this.multiline=j;let q=this.input;q.removeEventListener("change",this.#X),q.removeEventListener("input",this.#W),q.remove(),this.input=this.#B(),this.input.readOnly=this.readonly,this.input.disabled=Boolean(this.disabled),this.input.addEventListener("change",this.#X),this.input.addEventListener("input",this.#W),this.#O()}break}case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#O();break;default:this[Q]=this.input[Q]=$;break}}}z("fig-input-text",r0);class _0 extends HTMLElement{#Q;#Z;#$;#J;#j;#q;#_;#Y;#X;#W;#N;#K;#G;#U;#L;#F;#z=!1;#B=null;#M=null;#D=0;#T="";#H="";#O=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#R="px";#P(Q){return(Q||"").split(",").map((Z)=>Z.trim().toLowerCase()).filter(Boolean)}#S(Q){let Z=(Q||"").trim();if(!Z)return"";return(this.#U??[]).includes(Z.toLowerCase())?"":Z}#f(){this.#K=this.#S(this.#G)}#I(Q){if(Q&&!this.#B)this.#B=document.createElement("span"),this.#B.className="fig-steppers",this.#B.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#B.addEventListener("pointerdown",(Z)=>{Z.preventDefault(),Z.stopPropagation();let $=Z.target.closest("button");if(!$||this.disabled||$.disabled)return;let J=$.classList.contains("fig-stepper-up")?1:-1;this.#E(J),this.input.focus()}),this.append(this.#B);else if(!Q&&this.#B)this.#B.remove(),this.#B=null;this.#A()}#A(){if(!this.#B)return;let Q=this.#B.querySelector(".fig-stepper-up"),Z=this.#B.querySelector(".fig-stepper-down");if(!Q||!Z)return;let $=this.input?this.#g(this.input.value):this.value,J=$!==""&&$!==null&&$!==void 0?Number($)/(this.transform||1):Number(this.value),j=Number.isFinite(J),q=Boolean(this.disabled),_=j&&typeof this.min==="number"&&J<=this.min,X=j&&typeof this.max==="number"&&J>=this.max;Q.disabled=q||X,Z.disabled=q||_}#E(Q){let Z=this.step||1,$=this.#g(this.input.value),J=($!==""?Number($)/(this.transform||1):0)+Z*Q;J=this.#o(J,!1),this.value=J,this.input.value=this.#x(this.value),this.#A(),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#Q=this.#t.bind(this),this.#Z=this.#u.bind(this),this.#$=this.#u.bind(this),this.#J=this.#r.bind(this),this.#j=(Q)=>{Q.stopPropagation(),this.#s(Q)},this.#q=(Q)=>{Q.stopPropagation(),this.#p(Q)},this.#_=(Q)=>{this.#m(Q)},this.#Y=(Q)=>{this.#h(Q)},this.#X=(Q)=>{this.#d(Q)},this.#W=this.focus.bind(this),this.#N=this.#k.bind(this)}connectedCallback(){let Q=this.getAttribute("value");this.value=Q!==null&&Q!==""?Number(Q):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#G=this.getAttribute("units")||"";let Z=this.getAttribute("units-disallow");if(this.#U=this.#P(Z===null?_0.#R:Z),this.#f(),this.#L=this.getAttribute("unit-position")||"suffix",this.#F=this.#Z0(this.hasAttribute("precision")?this.getAttribute("precision"):2),this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));this.transform=Number(this.getAttribute("transform")||1);let $=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.input=this.#C(),this.#w(),this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.#I($),this.hasAttribute("disabled")){let J=this.getAttribute("disabled");this.disabled=this.input.disabled=J!=="false"}this.#A(),this.#V(),q0(this),this.addEventListener("pointerdown",this.#J),this.removeEventListener("click",this.#N),this.addEventListener("click",this.#N),this.#y(),this.input.removeEventListener("change",this.#j),this.input.addEventListener("change",this.#j),this.input.removeEventListener("input",this.#q),this.input.addEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.addEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#Y),this.input.addEventListener("blur",this.#Y),this.input.removeEventListener("keydown",this.#X),this.input.addEventListener("keydown",this.#X)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#j),this.input.removeEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#Y),this.input.removeEventListener("keydown",this.#X);if(this.removeEventListener("click",this.#N),this.removeEventListener("pointerdown",this.#J),window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#Z),window.removeEventListener("blur",this.#$),this.#M?.disconnect(),this.#M=null,this.#D)cancelAnimationFrame(this.#D),this.#D=0}focus(){this.input.focus()}#C(){let Q=this.querySelector("input");if(Q)return Q;let Z=document.createElement("input");if(Z.type="text",Z.inputMode="decimal",Z.setAttribute("data-generated","input-control"),this.name)Z.name=this.name;return Z.placeholder=this.placeholder,Z.value=this.#x(this.value),this.insertBefore(Z,this.querySelector('[slot="append"]')),Z}#k(Q){let Z=Q.target?.closest?.("[slot]");if(!Z||Z.parentElement!==this)return;this.focus()}#y(){this.#M?.disconnect(),this.#M=new MutationObserver(()=>this.#v()),this.#M.observe(this,{childList:!0,characterData:!0,subtree:!0})}#v(){if(this.#D)return;this.#D=requestAnimationFrame(()=>{if(this.#D=0,!this.isConnected)return;this.#b()})}#b(){if(!this.input||!this.contains(this.input))this.input=this.#C(),this.input.addEventListener("change",this.#j),this.input.addEventListener("input",this.#q),this.input.addEventListener("focus",this.#_),this.input.addEventListener("blur",this.#Y),this.input.addEventListener("keydown",this.#X);let Q=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.#B&&!this.contains(this.#B))this.#B=null;this.#I(Q),this.#w(),this.#V(),q0(this)}#w(){if(!this.input)return;this.#O.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,Z)})}#V(){if(!this.input)return;if(this.input.setAttribute("role","spinbutton"),typeof this.min==="number")this.input.setAttribute("aria-valuemin",String(this.min));else this.input.removeAttribute("aria-valuemin");if(typeof this.max==="number")this.input.setAttribute("aria-valuemax",String(this.max));else this.input.removeAttribute("aria-valuemax");let Q=this.value===""?null:Number(this.value);if(Number.isFinite(Q))this.input.setAttribute("aria-valuenow",String(Q)),this.input.setAttribute("aria-valuetext",this.#x(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#g(Q){if(!Q)return"";if(!this.#K){let J=Q.replace(/[^\d.-]/g,""),j=J.split(".");if(j.length>2)J=j[0]+"."+j.slice(1).join("");return J}let Z=Q.replace(this.#K,"").trim();Z=Z.replace(/[^\d.-]/g,"");let $=Z.split(".");if($.length>2)Z=$[0]+"."+$.slice(1).join("");return Z}#x(Q){if(Q===""||Q===null||Q===void 0)return"";let Z=Number(Q)*(this.transform||1);if(isNaN(Z))return"";if(Z=this.#i(Z),!this.#K)return Z.toString();if(this.#L==="prefix")return this.#K+Z;else return Z+this.#K}#c(Q){if(Q===""||Q===null||Q===void 0)return"";let Z=Number(Q)*(this.transform||1);return Z=this.#i(Z),Z.toString()}#m(Q){this.#z=!0,setTimeout(()=>{let Z=Q.target.value;if(Z&&this.#K)if(this.#L==="prefix")Q.target.setSelectionRange(this.#K.length,Z.length);else{let $=Z.indexOf(this.#K);if($>-1)Q.target.setSelectionRange(0,$)}},0)}#h(Q){this.#z=!1;let Z=this.#g(Q.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#o($,!1),this.value=$,Q.target.value=this.#x(this.value)}else this.value="",Q.target.value="";this.#A(),this.#V()}#d(Q){if(this.disabled)return;if(Q.key!=="ArrowUp"&&Q.key!=="ArrowDown")return;Q.preventDefault();let Z=this.step||1,$=Q.shiftKey?10:1,J=Z*$*(Q.key==="ArrowUp"?1:-1),j=this.#g(this.input.value),q=(j!==""?Number(j)/(this.transform||1):0)+J;q=this.#o(q,!1),this.value=q,this.input.value=this.#x(this.value),this.#A(),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#p(Q){let Z=this.#g(Q.target.value);if(Z!=="")this.value=Number(Z)/(this.transform||1);else this.value="";this.#A(),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#s(Q){Q.stopPropagation();let Z=this.#g(Q.target.value);if(Z!==""){let $=Number(Z)/(this.transform||1);$=this.#o($,!1),this.value=$,Q.target.value=this.#x(this.value)}else this.value="",Q.target.value="";this.#A(),this.#V(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#t(Q){if(this.disabled)return;if(Q.buttons===0){this.#u();return}let Z=(this.step||1)*Q.movementX,$=this.#g(this.input.value),J=Number($)/(this.transform||1)+Z;J=this.#o(J,!1),this.value=J,this.input.value=this.#x(this.value),this.#A(),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#r(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#z=!0,this.#T=this.style.userSelect,this.#H=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.#Z),window.addEventListener("pointercancel",this.#Z),window.addEventListener("blur",this.#$)}#u(Q){let Z=this.#z;if(this.#z=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#H,this.style.userSelect=this.#T,window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#Z),window.removeEventListener("pointercancel",this.#Z),window.removeEventListener("blur",this.#$),Z)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#o(Q,Z=!0){let $=Number(Q);if(isNaN($))return"";if(typeof this.min==="number")$=Math.max(this.min,$);if(typeof this.max==="number")$=Math.min(this.max,$);return $=this.#i($),$}#i(Q){let Z=this.#F??2,$=Math.pow(10,Z),J=Math.round(Q*$)/$;return Number.isInteger(J)?J:parseFloat(J.toFixed(Z))}#Z0(Q){let Z=Number(Q);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(Q,Z,$){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=$!==null&&$!=="false",this.#A();break;case"units":this.#G=$||"",this.#f(),this.input.value=this.#x(this.value),this.#V();break;case"units-disallow":this.#U=this.#P($===null?_0.#R:$),this.#f(),this.input.value=this.#x(this.value),this.#V();break;case"unit-position":this.#L=$||"suffix",this.input.value=this.#x(this.value),this.#V();break;case"transform":this.transform=Number($)||1,this.input.value=this.#x(this.value),this.#V();break;case"value":if(this.#z)break;let J=$!==null&&$!==""?Number($):"";if(J!=="")J=this.#o(J,!1);this.value=J,this.input.value=this.#x(this.value),this.#A(),this.#V();break;case"min":case"max":case"step":if($===null||$===""){this[Q]=void 0,this.#A(),this.#V();break}this[Q]=Number($),this.#A(),this.#V();break;case"steppers":{let j=$!==null&&$!=="false";this.#I(j);break}case"precision":this.#F=this.#Z0($!==null?$:2),this.input.value=this.#x(this.value),this.#V();break;case"name":if(this[Q]=this.input[Q]=$||"",$)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.#w();break;default:this[Q]=this.input[Q]=$;break}}}z("fig-input-number",_0);class o0 extends HTMLElement{constructor(){super()}connectedCallback(){this.src=this.getAttribute("src"),this.name=this.getAttribute("name"),this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials),this.setSrc(this.src),this.img=this.querySelector("img")}setSrc(Q){if(this.src=Q,!Q){this.querySelector(":scope > img")?.remove(),this.img=null;return}let Z=this.querySelector(":scope > img")||document.createElement("img");if(Z.src=Q,Z.alt=this.name||"",!Z.isConnected)this.replaceChildren(Z);this.img=Z}getInitials(Q){return Q?Q.split(" ").map((Z)=>Z[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(Q,Z,$){if(this[Q]=$,Q==="name"){if(this.img)this.img.alt=$||"";this.name=$,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials)}else if(Q==="src")this.src=$,this.setSrc(this.src)}}z("fig-avatar",o0);class l0 extends HTMLElement{#Q=!1;#Z=null;#$=null;#J=null;#j=null;#q=null;#_=null;constructor(){super();this.#$=this.#W.bind(this),this.#J=this.focus.bind(this),this.#j=this.#N.bind(this),this.#q=this.#K.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(!this.isConnected)return;this.#X(),this.#Y()})}#Y(){if(this.#_||typeof MutationObserver>"u")return;this.#_=new MutationObserver(()=>{this.#X()}),this.#_.observe(this,{childList:!0})}#X(){let Q=this.label,Z=this.#Z;Q?.removeEventListener("click",this.#$),Q?.removeEventListener("click",this.#J),Q?.removeEventListener("pointerenter",this.#j),Q?.removeEventListener("pointerleave",this.#q),Z?.removeEventListener("click",this.#$),this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((j)=>j.nodeType===Node.ELEMENT_NODE&&j.nodeName.toLowerCase().startsWith("fig-")&&!(j instanceof Element&&j.classList.contains("fig-field-chevron")));let $=this.input?.localName??"",J=$==="fig-select"||$==="fig-menu"||$==="fig-dropdown"||$==="fig-tooltip"||this.input instanceof HTMLDialogElement;if(this.#Q=!!(this.input&&("open"in this.input)&&!J),this.#Q&&this.label){if(!this.#Z||!this.#Z.isConnected)this.#Z=u("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#Z,this.label);this.#Z.addEventListener("click",this.#$),this.label.addEventListener("click",this.#$)}else{if(this.#Z)this.#Z.removeEventListener("click",this.#$),this.#Z.remove(),this.#Z=null;if(this.input&&this.label){if(this.input.querySelectorAll("input, select, textarea").length!==1)this.label.addEventListener("click",this.#J)}}if(this.input&&this.label&&!this.#Q)this.#G();if(this.label)this.label.removeEventListener("pointerenter",this.#j),this.label.addEventListener("pointerenter",this.#j),this.label.removeEventListener("pointerleave",this.#q),this.label.addEventListener("pointerleave",this.#q)}disconnectedCallback(){if(this.#_?.disconnect(),this.#_=null,this.label)H.hide(this.label);if(this.label&&this.#$)this.label.removeEventListener("click",this.#$);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.label&&this.#j)this.label.removeEventListener("pointerenter",this.#j);if(this.label&&this.#q)this.label.removeEventListener("pointerleave",this.#q);if(this.#Z&&this.#$)this.#Z.removeEventListener("click",this.#$)}#W(Q){if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open}#N(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;H.show(this.label,this.label.textContent.trim())}#K(){if(this.label)H.hide(this.label)}#G(){if(!this.input||!this.label)return;let Q=this.label.getAttribute("id")||h();this.label.setAttribute("id",Q);let Z=this.input.querySelectorAll("input, select, textarea");if(Z.length===1){let $=Z[0],J=$.getAttribute("id")||h();if($.setAttribute("id",J),this.label.setAttribute("for",J),this.input.getAttribute("aria-labelledby")===Q)this.input.removeAttribute("aria-labelledby");if(!$.hasAttribute("aria-labelledby"))$.setAttribute("aria-labelledby",Q);return}if(this.label.removeAttribute("for"),!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-labelledby",Q)}attributeChangedCallback(Q,Z,$){switch(Q){case"label":if(this.label)this.label.textContent=$,this.#G();break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let Q=this.input.querySelectorAll("input, select, textarea");if(Q.length===1)Q[0].focus();else if(this.input.focus(),Q.length===0)this.input.click()}}z("fig-field",l0);class a0 extends HTMLElement{rgba;hex;#Q=100;#Z;#$;#J;#j;#q=!1;#_=!1;#Y=null;#X=this.#I.bind(this);#W=this.#A.bind(this);#N=this.#E.bind(this);#K=this.#V.bind(this);#G=this.#k.bind(this);#U=this.#v.bind(this);#L=this.#y.bind(this);#F=this.#g.bind(this);constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0||Q===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(Q))}#z(){let Q={};for(let{name:Z,value:$}of this.attributes)if(Z.startsWith("picker-")&&Z!=="picker-anchor"&&Z!=="picker-experimental")Q[Z.slice(7)]=$;if(!Q["dialog-position"])Q["dialog-position"]="left";return Q}#B(){let Q=this.#z();return Object.entries(Q).map(([Z,$])=>`${Z}="${$}"`).join(" ")}connectedCallback(){if(this.#M()){this.#D();return}this.#O()}disconnectedCallback(){this.#T()}#M(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-swatch")}#D(){if(this.#C(this.getAttribute("value")),this.#Z=this.querySelector("fig-swatch"),this.#$=this.querySelector("fig-fill-picker"),this.#J=this.querySelector("fig-input-text:not([type=number])"),this.#j=this.querySelector("fig-input-number"),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j)this.#j.setAttribute("value",String(this.#Q));if(this.#Z)this.#Z.setAttribute("background",this.hexOpaque),this.#Z.setAttribute("alpha",String(this.rgba.a));this.#w(),this.#H()}#T(){if(this.#Z)this.#Z.removeEventListener("pointerdown",this.#X,{capture:!0}),this.#Z.removeEventListener("click",this.#W,{capture:!0}),this.#Z.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#N),this.#Z.removeEventListener("input",this.#K);this.#J?.removeEventListener("input",this.#G),this.#J?.removeEventListener("change",this.#U),this.#j?.removeEventListener("input",this.#L),this.#j?.removeEventListener("change",this.#U),this.#$?.removeEventListener("input",this.#F),this.#$?.removeEventListener("change",this.#U)}#H(){if(this.#Z){this.#Z.disabled=F(this,"disabled");let Q=this.#Z.querySelector('input[type="color"]');if(this.#J||this.hasAttribute("swatch-disabled"))Q?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(Q?.setAttribute("disabled",""),Q)Q.style.pointerEvents="none"}this.#Z.addEventListener("pointerdown",this.#X,{capture:!0}),this.#Z.addEventListener("click",this.#W,{capture:!0}),Q?.addEventListener("keydown",this.#N),this.#Z.addEventListener("input",this.#K)}if(this.#J)this.#J.addEventListener("input",this.#G),this.#J.addEventListener("change",this.#U);if(this.#j)this.#j.addEventListener("input",this.#L),this.#j.addEventListener("change",this.#U);if(this.#$)this.#$.addEventListener("input",this.#F),this.#$.addEventListener("change",this.#U)}#O(){this.#C(this.getAttribute("value"));let Q=this.getAttribute("alpha")!=="false",$=this.#m?" disabled":"",J="";if(this.getAttribute("text")!=="false"){let q=`<fig-input-text
155
155
  type="text"
156
156
  placeholder="000000"
157
157
  value="${this.hexOpaque.slice(1).toUpperCase()}"${$}>
@@ -160,13 +160,13 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
160
160
  placeholder="##"
161
161
  min="0"
162
162
  max="100"
163
- value="${this.#Z}"
163
+ value="${this.#Q}"
164
164
  units="%"${$}>
165
165
  </fig-input-number>
166
166
  </fig-tooltip>`;let _="";_=`<fig-swatch background="${this.hexOpaque}" alpha="${this.rgba.a}"${$}></fig-swatch>`,J=`<div class="input-combo">
167
167
  ${_}
168
168
  ${q}
169
- </div>`}else J=`<fig-swatch background="${this.hexOpaque}" alpha="${this.rgba.a}"${$}></fig-swatch>`;if(this.innerHTML=J,this.#Q=this.querySelector("fig-swatch"),this.#$=this.querySelector("fig-fill-picker"),this.#J=this.querySelector("fig-input-text:not([type=number])"),this.#j=this.querySelector("fig-input-number"),this.#w(),this.#J){let q=this.rgbAlphaToHex(this.rgba,1);if(this.#J.value=q.slice(1).toUpperCase(),this.#Q)this.#Q.background=q}this.#H()}#R(){if(!this.#$)return;for(let[Q,Z]of Object.entries(this.#z()))this.#$.setAttribute(Q,Z);if(this.#$.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#$.removeAttribute("alpha");else this.#$.setAttribute("alpha","false");if(F(this,"disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");this.#$.anchorElement=this,this.#$.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}))}#P(){if(!o())return null;if(this.#$?.isConnected)return this.#R(),this.#$;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#F),Q.addEventListener("change",this.#U),this.appendChild(Q),this.#$=Q,this.#R(),Q}#C(){if(F(this,"disabled")||F(this,"swatch-disabled"))return!1;let Q=this.#P();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#S(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#I(Q){if(!o())return;if(F(this,"disabled")||F(this,"swatch-disabled"))return;if(this.#_=!0,this.#q=!0,this.#Y)clearTimeout(this.#Y);this.#Y=setTimeout(()=>{this.#q=!1,this.#_=!1,this.#Y=null},500),this.#S(Q)}#A(Q){if(!this.#q)return;if(this.#q=!1,this.#Y)clearTimeout(this.#Y),this.#Y=null;if(this.#S(Q),this.#_)this.#_=!1,this.#C()}#k(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!o())return;if(!this.#C())return;this.#S(Q)}#T(Q){let Z=typeof Q==="string"&&Q.trim()?Q.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)}#f(Q){Q.stopPropagation();let Z=Q.target.value.replace(/#/g,"");if(this.#T("#"+Z),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j)this.#j.setAttribute("value",this.#Z);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#x()}#y(Q){Q.stopPropagation();let Z=Number(Q.target.value)||0,J=Math.round(Z/100*255).toString(16).padStart(2,"0");if(this.#T(this.hexOpaque+J),this.#Q)this.#Q.setAttribute("alpha",this.rgba.a);if(this.#$)this.#$.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));this.#x()}#g(Q){Q.stopPropagation(),this.#u()}focus(){if(this.#J){this.#J.focus();return}this.#Q?.focus()}#h(){return this.getAttribute("aria-label")||"Color"}#w(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#m)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let Q=this.getAttribute("aria-describedby"),Z=this.getAttribute("aria-invalid"),$=this.getAttribute("aria-required"),J=this.getAttribute("aria-labelledby"),j=this.#h();if(this.#J){if(this.#J.setAttribute("aria-label",`${j} hex color`),Q)this.#J.setAttribute("aria-describedby",Q);else this.#J.removeAttribute("aria-describedby");if(Z)this.#J.setAttribute("aria-invalid",Z);else this.#J.removeAttribute("aria-invalid");if($)this.#J.setAttribute("aria-required",$);else this.#J.removeAttribute("aria-required")}if(this.#j){if(this.#j.setAttribute("aria-label",`${j} opacity`),Q)this.#j.setAttribute("aria-describedby",Q);else this.#j.removeAttribute("aria-describedby");if(Z)this.#j.setAttribute("aria-invalid",Z);else this.#j.removeAttribute("aria-invalid");if($)this.#j.setAttribute("aria-required",$);else this.#j.removeAttribute("aria-required")}if(!this.#J){let q=this.#Q?.querySelector('input[type="color"]');if(!q)return;if(J)q.setAttribute("aria-labelledby",J),q.removeAttribute("aria-label");else q.setAttribute("aria-label",j),q.removeAttribute("aria-labelledby");if(Q)q.setAttribute("aria-describedby",Q);else q.removeAttribute("aria-describedby")}}#V(Q){if(Q.stopPropagation(),this.#T(Q.target.value),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#x()}#b(Q){Q.stopPropagation();let Z=Q.detail;if(Z&&Z.color){let $=Z.color;if(Z.alpha!==void 0){let J=Math.round(Z.alpha*255).toString(16).padStart(2,"0");$=Z.color+J}if(this.#T($),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j&&Z.alpha!==void 0)this.#j.setAttribute("value",Math.round(Z.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#x()}}#x(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#u(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}static get observedAttributes(){return["value","style","mode","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(Q){this.setAttribute("mode",Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":if(this.#T($),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);if(this.#$)this.#$.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));if(this.#j)this.#j.setAttribute("value",this.#Z);break;case"mode":this.#R();break;case"alpha":case"text":if(this.isConnected)this.#O();break;case"disabled":this.#v();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#w();break}}get#m(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#v(){let Q=this.#m;for(let Z of[this.#Q,this.#J,this.#j]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}if(this.#w(),this.#$)this.#R()}rgbAlphaToHex({r:Q,g:Z,b:$},J=1){Q=Math.max(0,Math.min(255,Math.round(Q))),Z=Math.max(0,Math.min(255,Math.round(Z))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(1,J));let j=Q.toString(16).padStart(2,"0"),q=Z.toString(16).padStart(2,"0"),_=$.toString(16).padStart(2,"0");if(J===1)return`#${j}${q}${_}`.toUpperCase();let Y=Math.round(J*255).toString(16).padStart(2,"0");return`#${j}${q}${_}${Y}`.toUpperCase()}convertToRGBA(Q){if(typeof Q!=="string")return null;let Z,$,J,j=1;if(Q.startsWith("#")){let q=Q.slice(1);if(q.length===8)j=parseInt(q.slice(6),16)/255,q=q.slice(0,6);Z=parseInt(q.slice(0,2),16),$=parseInt(q.slice(2,4),16),J=parseInt(q.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let q=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q)Z=parseInt(q[1]),$=parseInt(q[2]),J=parseInt(q[3]),j=q[4]?parseFloat(q[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let q=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q){let _=parseInt(q[1])/360,X=parseInt(q[2])/100,Y=parseInt(q[3])/100;if(j=q[4]?parseFloat(q[4]):1,X===0)Z=$=J=Y;else{let K=(W,O,B)=>{if(B<0)B+=1;if(B>1)B-=1;if(B<0.16666666666666666)return W+(O-W)*6*B;if(B<0.5)return O;if(B<0.6666666666666666)return W+(O-W)*(0.6666666666666666-B)*6;return W},G=Y<0.5?Y*(1+X):Y+X-Y*X,N=2*Y-G;Z=K(N,G,_+0.3333333333333333),$=K(N,G,_),J=K(N,G,_-0.3333333333333333)}Z=Math.round(Z*255),$=Math.round($*255),J=Math.round(J*255)}}else return null;return{r:Z,g:$,b:J,a:j}}}z("fig-input-color",a0);var d1=["srgb","srgb-linear","display-p3","oklab","oklch","hsl"],s1=["shorter","longer","increasing","decreasing"],t0=new Set(["oklch","hsl"]);function Z0(Q){let Z={...Q??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase();if(!d1.includes($))$="srgb";Z.interpolationSpace=$;let J=String(Z.hueInterpolation??"shorter").toLowerCase();return Z.hueInterpolation=s1.includes(J)?J:"shorter",Z}function n0(Q){let Z=Z0(Q),$={...Z,interpolationSpace:Z.interpolationSpace};if(t0.has(Z.interpolationSpace))$.hueInterpolation=Z.hueInterpolation;else delete $.hueInterpolation;return $}function e0(Q){let Z=Z0(Q);if(Z.interpolationSpace==="srgb")return"";if(t0.has(Z.interpolationSpace))return`in ${Z.interpolationSpace} ${Z.hueInterpolation} hue`;return`in ${Z.interpolationSpace}`}function r(Q){let Z=Q.replace(/^#/,"");return{r:parseInt(Z.substring(0,2),16),g:parseInt(Z.substring(2,4),16),b:parseInt(Z.substring(4,6),16)}}function p(Q){let Z=Q/255;return Z<=0.04045?Z/12.92:Math.pow((Z+0.055)/1.055,2.4)}function l(Q){let Z=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Z))*255)}function e(Q,Z,$){let J=p(Q),j=p(Z),q=p($),_=Math.cbrt(0.4122214708*J+0.5363325363*j+0.0514459929*q),X=Math.cbrt(0.2119034982*J+0.6806995451*j+0.1073969566*q),Y=Math.cbrt(0.0883024619*J+0.2817188376*j+0.6299787005*q);return{l:0.2104542553*_+0.793617785*X-0.0040720468*Y,a:1.9779984951*_-2.428592205*X+0.4505937099*Y,b:0.0259040371*_+0.7827717662*X-0.808675766*Y}}function C0(Q,Z,$){let J=Q+0.3963377774*Z+0.2158037573*$,j=Q-0.1055613458*Z-0.0638541728*$,q=Q-0.0894841775*Z-1.291485548*$,_=J*J*J,X=j*j*j,Y=q*q*q;return{r:l(4.0767416621*_-3.3077115913*X+0.2309699292*Y),g:l(-1.2684380046*_+2.6097574011*X-0.3413193965*Y),b:l(-0.0041960863*_-0.7034186147*X+1.707614701*Y)}}function L0(Q,Z,$){return{l:Q,c:Math.sqrt(Z*Z+$*$),h:Math.atan2($,Z)*180/Math.PI}}function i1(Q,Z,$){let J=$*Math.PI/180;return{l:Q,a:Z*Math.cos(J),b:Z*Math.sin(J)}}function k0(Q,Z,$,J){let j=(Q%360+360)%360,_=(Z%360+360)%360-j;switch(J){case"longer":if(_>0&&_<180)_-=360;else if(_<0&&_>-180)_+=360;else if(_===0)_=0;break;case"increasing":if(_<0)_+=360;break;case"decreasing":if(_>0)_-=360;break;default:if(_>180)_-=360;else if(_<-180)_+=360;break}return((j+_*$)%360+360)%360}function r1(Q,Z,$,J){let j=[...Q].sort((R,A)=>R.position-A.position),q=Z*100;if(j.length===0)return"#888888";if(q<=j[0].position)return j[0].color;if(q>=j[j.length-1].position)return j[j.length-1].color;let _=0;while(_<j.length-1&&j[_+1].position<q)_++;let X=j[_],Y=j[_+1],K=Y.position-X.position,G=K>0?(q-X.position)/K:0,N=r(X.color),W=r(Y.color),O,B,L,T=$||"oklab";if(T==="srgb-linear"){let R=p(N.r),A=p(N.g),M=p(N.b),E=p(W.r),k=p(W.g),S=p(W.b);O=l(R+(E-R)*G),B=l(A+(k-A)*G),L=l(M+(S-M)*G)}else if(T==="oklch"){let R=e(N.r,N.g,N.b),A=e(W.r,W.g,W.b),M=L0(R.l,R.a,R.b),E=L0(A.l,A.a,A.b),k=M.l+(E.l-M.l)*G,S=M.c+(E.c-M.c)*G,x=k0(M.h,E.h,G,J||"shorter"),y=i1(k,S,x),m=C0(y.l,y.a,y.b);O=m.r,B=m.g,L=m.b}else if(T==="hsl"){let R=B0(N.r,N.g,N.b),A=B0(W.r,W.g,W.b),M=k0(R.h,A.h,G,J||"shorter"),E=R.s+(A.s-R.s)*G,k=R.l+(A.l-R.l)*G,S=o1(M,E,k);O=S[0],B=S[1],L=S[2]}else if(T==="srgb")O=Math.round(N.r+(W.r-N.r)*G),B=Math.round(N.g+(W.g-N.g)*G),L=Math.round(N.b+(W.b-N.b)*G);else{let R=e(N.r,N.g,N.b),A=e(W.r,W.g,W.b),M=R.l+(A.l-R.l)*G,E=R.a+(A.a-R.a)*G,k=R.b+(A.b-R.b)*G,S=C0(M,E,k);O=S.r,B=S.g,L=S.b}return`#${O.toString(16).padStart(2,"0")}${B.toString(16).padStart(2,"0")}${L.toString(16).padStart(2,"0")}`.toUpperCase()}function B0(Q,Z,$){let J=Q/255,j=Z/255,q=$/255,_=Math.max(J,j,q),X=Math.min(J,j,q),Y=(_+X)/2;if(_===X)return{h:0,s:0,l:Y*100};let K=_-X,G=Y>0.5?K/(2-_-X):K/(_+X),N;switch(_){case J:N=((j-q)/K+(j<q?6:0))/6;break;case j:N=((q-J)/K+2)/6;break;default:N=((J-j)/K+4)/6;break}return{h:N*360,s:G*100,l:Y*100}}function o1(Q,Z,$){Z/=100,$/=100;let J=(1-Math.abs(2*$-1))*Z,j=J*(1-Math.abs(Q/60%2-1)),q=$-J/2,_,X,Y;if(Q<60)_=J,X=j,Y=0;else if(Q<120)_=j,X=J,Y=0;else if(Q<180)_=0,X=J,Y=j;else if(Q<240)_=0,X=j,Y=J;else if(Q<300)_=j,X=0,Y=J;else _=J,X=0,Y=j;return[Math.round((_+q)*255),Math.round((X+q)*255),Math.round((Y+q)*255)]}class Q1 extends HTMLElement{#Z="solid";#Q;#$;#J;#j={color:"#D9D9D9",alpha:1};#q={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",opacity:1,stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#_={url:null,scaleMode:"fill",scale:50,opacity:1};#Y={url:null,scaleMode:"fill",opacity:1};#X={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","alpha","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#W(),this.#z()}disconnectedCallback(){this.#Q=null,this.#$=null,this.#J=null}#W(){let Q=this.getAttribute("value");if(!Q)return;try{let Z=JSON.parse(Q);if(Z.type)this.#Z=Z.type;switch(this.#Z){case"solid":if(Z.color)this.#j.color=Z.color;if(Z.alpha!==void 0)this.#j.alpha=Z.alpha;if(Z.opacity!==void 0)this.#j.alpha=Z.opacity/100;break;case"gradient":if(Z.gradient)this.#q=Z0({...this.#q,...Z.gradient}),this.#q.opacity=this.#G(Z.gradient.opacity??Z.opacity??Z.alpha,this.#q.opacity??1);else if(Z.opacity!==void 0||Z.alpha!==void 0)this.#q.opacity=this.#G(Z.opacity??Z.alpha,this.#q.opacity??1);break;case"image":if(Z.image)this.#_={...this.#_,...Z.image};break;case"video":if(Z.video)this.#Y={...this.#Y,...Z.video};break;case"webcam":if(Z.webcam)this.#X={...this.#X,...Z.webcam};if(Z.opacity!==void 0)this.#X.opacity=Z.opacity;break}}catch(Z){if(Q.startsWith("#")){if(this.#Z="solid",this.#j.color=Q.slice(0,7),Q.length>7){let $=Q.slice(7,9);this.#j.alpha=parseInt($,16)/255}}}}#N(){let Q={},Z=this.getAttribute("mode");if(Z)Q.mode=Z;let $=this.getAttribute("alpha");if($)Q.alpha=$;for(let{name:J,value:j}of this.attributes)if(J.startsWith("picker-")&&J!=="picker-anchor"&&J!=="picker-experimental")Q[J.slice(7)]=j;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([J,j])=>`${J}="${v(j)}"`).join(" ")}#K(){switch(this.#Z){case"solid":return this.#j.color;case"gradient":{let Z=[...this.#q.stops].sort((J,j)=>J.position-j.position).map((J)=>{let j=(J.opacity??100)/100;if(j>=1)return`${J.color} ${J.position}%`;let{r:q,g:_,b:X}=r(J.color);return`rgba(${q}, ${_}, ${X}, ${j}) ${J.position}%`}).join(", "),$=e0(this.#q);return`linear-gradient(${this.#q.angle}deg${$?` ${$}`:""}, ${Z})`}case"image":return this.#_.url?`url(${this.#_.url})`:"#D9D9D9";default:return"#D9D9D9"}}#G(Q,Z=1){if(Q===void 0||Q===null||Q==="")return Z;let $=Number(Q);if(!Number.isFinite($))return Z;if($>1)return Math.max(0,Math.min(1,$/100));return Math.max(0,Math.min(1,$))}#U(){switch(this.#Z){case"solid":return this.#j.alpha;case"gradient":return this.#q.opacity??1;case"image":return this.#_.opacity??1;case"video":return this.#Y.opacity??1;case"webcam":return this.#X.opacity??1;default:return 1}}#L(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.setAttribute("aria-disabled",Q?"true":"false");for(let Z of[this.#Q,this.#$,this.#J]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}#F(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#L();let Q=this.getAttribute("aria-label")||"Fill",Z=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),j=(q,_)=>{if(!q)return;if(q.setAttribute("aria-label",_),Z)q.setAttribute("aria-describedby",Z);else q.removeAttribute("aria-describedby");if($)q.setAttribute("aria-invalid",$);else q.removeAttribute("aria-invalid");if(J)q.setAttribute("aria-required",J);else q.removeAttribute("aria-required")};j(this.#Q,`${Q} picker`),j(this.#J,`${Q} hex color`),j(this.#$,`${Q} opacity`)}#z(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=JSON.stringify(this.value),$=this.getAttribute("alpha")!=="false",J=(_)=>$?`<fig-tooltip text="Opacity">
169
+ </div>`}else J=`<fig-swatch background="${this.hexOpaque}" alpha="${this.rgba.a}"${$}></fig-swatch>`;if(this.innerHTML=J,this.#Z=this.querySelector("fig-swatch"),this.#$=this.querySelector("fig-fill-picker"),this.#J=this.querySelector("fig-input-text:not([type=number])"),this.#j=this.querySelector("fig-input-number"),this.#w(),this.#J){let q=this.rgbAlphaToHex(this.rgba,1);if(this.#J.value=q.slice(1).toUpperCase(),this.#Z)this.#Z.background=q}this.#H()}#R(){if(!this.#$)return;for(let[Q,Z]of Object.entries(this.#z()))this.#$.setAttribute(Q,Z);if(this.#$.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#$.removeAttribute("alpha");else this.#$.setAttribute("alpha","false");if(F(this,"disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");this.#$.anchorElement=this,this.#$.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Q}))}#P(){if(!o())return null;if(this.#$?.isConnected)return this.#R(),this.#$;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#F),Q.addEventListener("change",this.#U),this.appendChild(Q),this.#$=Q,this.#R(),Q}#S(){if(F(this,"disabled")||F(this,"swatch-disabled"))return!1;let Q=this.#P();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#f(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#I(Q){if(!o())return;if(F(this,"disabled")||F(this,"swatch-disabled"))return;if(this.#_=!0,this.#q=!0,this.#Y)clearTimeout(this.#Y);this.#Y=setTimeout(()=>{this.#q=!1,this.#_=!1,this.#Y=null},500),this.#f(Q)}#A(Q){if(!this.#q)return;if(this.#q=!1,this.#Y)clearTimeout(this.#Y),this.#Y=null;if(this.#f(Q),this.#_)this.#_=!1,this.#S()}#E(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!o())return;if(!this.#S())return;this.#f(Q)}#C(Q){let Z=typeof Q==="string"&&Q.trim()?Q.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.#Q=Z.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#k(Q){Q.stopPropagation();let Z=Q.target.value.replace(/#/g,"");if(this.#C("#"+Z),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j)this.#j.setAttribute("value",this.#Q);if(this.#Z)this.#Z.setAttribute("background",this.hexOpaque);this.#x()}#y(Q){Q.stopPropagation();let Z=Number(Q.target.value)||0,J=Math.round(Z/100*255).toString(16).padStart(2,"0");if(this.#C(this.hexOpaque+J),this.#Z)this.#Z.setAttribute("alpha",this.rgba.a);if(this.#$)this.#$.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Q}));this.#x()}#v(Q){Q.stopPropagation(),this.#c()}focus(){if(this.#J){this.#J.focus();return}this.#Z?.focus()}#b(){return this.getAttribute("aria-label")||"Color"}#w(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#m)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let Q=this.getAttribute("aria-describedby"),Z=this.getAttribute("aria-invalid"),$=this.getAttribute("aria-required"),J=this.getAttribute("aria-labelledby"),j=this.#b();if(this.#J){if(this.#J.setAttribute("aria-label",`${j} hex color`),Q)this.#J.setAttribute("aria-describedby",Q);else this.#J.removeAttribute("aria-describedby");if(Z)this.#J.setAttribute("aria-invalid",Z);else this.#J.removeAttribute("aria-invalid");if($)this.#J.setAttribute("aria-required",$);else this.#J.removeAttribute("aria-required")}if(this.#j){if(this.#j.setAttribute("aria-label",`${j} opacity`),Q)this.#j.setAttribute("aria-describedby",Q);else this.#j.removeAttribute("aria-describedby");if(Z)this.#j.setAttribute("aria-invalid",Z);else this.#j.removeAttribute("aria-invalid");if($)this.#j.setAttribute("aria-required",$);else this.#j.removeAttribute("aria-required")}if(!this.#J){let q=this.#Z?.querySelector('input[type="color"]');if(!q)return;if(J)q.setAttribute("aria-labelledby",J),q.removeAttribute("aria-label");else q.setAttribute("aria-label",j),q.removeAttribute("aria-labelledby");if(Q)q.setAttribute("aria-describedby",Q);else q.removeAttribute("aria-describedby")}}#V(Q){if(Q.stopPropagation(),this.#C(Q.target.value),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#x()}#g(Q){Q.stopPropagation();let Z=Q.detail;if(Z&&Z.color){let $=Z.color;if(Z.alpha!==void 0){let J=Math.round(Z.alpha*255).toString(16).padStart(2,"0");$=Z.color+J}if(this.#C($),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j&&Z.alpha!==void 0)this.#j.setAttribute("value",Math.round(Z.alpha*100));if(this.#Z)this.#Z.setAttribute("background",this.hexOpaque),this.#Z.setAttribute("alpha",this.rgba.a);this.#x()}}#x(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#c(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}static get observedAttributes(){return["value","style","mode","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(Q){this.setAttribute("mode",Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":if(this.#C($),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Z)this.#Z.setAttribute("background",this.hexOpaque),this.#Z.setAttribute("alpha",this.rgba.a);if(this.#$)this.#$.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Q}));if(this.#j)this.#j.setAttribute("value",this.#Q);break;case"mode":this.#R();break;case"alpha":case"text":if(this.isConnected)this.#O();break;case"disabled":this.#h();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#w();break}}get#m(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#h(){let Q=this.#m;for(let Z of[this.#Z,this.#J,this.#j]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}if(this.#w(),this.#$)this.#R()}rgbAlphaToHex({r:Q,g:Z,b:$},J=1){Q=Math.max(0,Math.min(255,Math.round(Q))),Z=Math.max(0,Math.min(255,Math.round(Z))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(1,J));let j=Q.toString(16).padStart(2,"0"),q=Z.toString(16).padStart(2,"0"),_=$.toString(16).padStart(2,"0");if(J===1)return`#${j}${q}${_}`.toUpperCase();let Y=Math.round(J*255).toString(16).padStart(2,"0");return`#${j}${q}${_}${Y}`.toUpperCase()}convertToRGBA(Q){if(typeof Q!=="string")return null;let Z,$,J,j=1;if(Q.startsWith("#")){let q=Q.slice(1);if(q.length===8)j=parseInt(q.slice(6),16)/255,q=q.slice(0,6);Z=parseInt(q.slice(0,2),16),$=parseInt(q.slice(2,4),16),J=parseInt(q.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let q=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q)Z=parseInt(q[1]),$=parseInt(q[2]),J=parseInt(q[3]),j=q[4]?parseFloat(q[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let q=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q){let _=parseInt(q[1])/360,X=parseInt(q[2])/100,Y=parseInt(q[3])/100;if(j=q[4]?parseFloat(q[4]):1,X===0)Z=$=J=Y;else{let K=(W,O,B)=>{if(B<0)B+=1;if(B>1)B-=1;if(B<0.16666666666666666)return W+(O-W)*6*B;if(B<0.5)return O;if(B<0.6666666666666666)return W+(O-W)*(0.6666666666666666-B)*6;return W},G=Y<0.5?Y*(1+X):Y+X-Y*X,N=2*Y-G;Z=K(N,G,_+0.3333333333333333),$=K(N,G,_),J=K(N,G,_-0.3333333333333333)}Z=Math.round(Z*255),$=Math.round($*255),J=Math.round(J*255)}}else return null;return{r:Z,g:$,b:J,a:j}}}z("fig-input-color",a0);var d1=["srgb","srgb-linear","display-p3","oklab","oklch","hsl"],s1=["shorter","longer","increasing","decreasing"],t0=new Set(["oklch","hsl"]);function Z0(Q){let Z={...Q??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase();if(!d1.includes($))$="srgb";Z.interpolationSpace=$;let J=String(Z.hueInterpolation??"shorter").toLowerCase();return Z.hueInterpolation=s1.includes(J)?J:"shorter",Z}function n0(Q){let Z=Z0(Q),$={...Z,interpolationSpace:Z.interpolationSpace};if(t0.has(Z.interpolationSpace))$.hueInterpolation=Z.hueInterpolation;else delete $.hueInterpolation;return $}function e0(Q){let Z=Z0(Q);if(Z.interpolationSpace==="srgb")return"";if(t0.has(Z.interpolationSpace))return`in ${Z.interpolationSpace} ${Z.hueInterpolation} hue`;return`in ${Z.interpolationSpace}`}function r(Q){let Z=Q.replace(/^#/,"");return{r:parseInt(Z.substring(0,2),16),g:parseInt(Z.substring(2,4),16),b:parseInt(Z.substring(4,6),16)}}function p(Q){let Z=Q/255;return Z<=0.04045?Z/12.92:Math.pow((Z+0.055)/1.055,2.4)}function l(Q){let Z=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Z))*255)}function e(Q,Z,$){let J=p(Q),j=p(Z),q=p($),_=Math.cbrt(0.4122214708*J+0.5363325363*j+0.0514459929*q),X=Math.cbrt(0.2119034982*J+0.6806995451*j+0.1073969566*q),Y=Math.cbrt(0.0883024619*J+0.2817188376*j+0.6299787005*q);return{l:0.2104542553*_+0.793617785*X-0.0040720468*Y,a:1.9779984951*_-2.428592205*X+0.4505937099*Y,b:0.0259040371*_+0.7827717662*X-0.808675766*Y}}function C0(Q,Z,$){let J=Q+0.3963377774*Z+0.2158037573*$,j=Q-0.1055613458*Z-0.0638541728*$,q=Q-0.0894841775*Z-1.291485548*$,_=J*J*J,X=j*j*j,Y=q*q*q;return{r:l(4.0767416621*_-3.3077115913*X+0.2309699292*Y),g:l(-1.2684380046*_+2.6097574011*X-0.3413193965*Y),b:l(-0.0041960863*_-0.7034186147*X+1.707614701*Y)}}function L0(Q,Z,$){return{l:Q,c:Math.sqrt(Z*Z+$*$),h:Math.atan2($,Z)*180/Math.PI}}function i1(Q,Z,$){let J=$*Math.PI/180;return{l:Q,a:Z*Math.cos(J),b:Z*Math.sin(J)}}function k0(Q,Z,$,J){let j=(Q%360+360)%360,_=(Z%360+360)%360-j;switch(J){case"longer":if(_>0&&_<180)_-=360;else if(_<0&&_>-180)_+=360;else if(_===0)_=0;break;case"increasing":if(_<0)_+=360;break;case"decreasing":if(_>0)_-=360;break;default:if(_>180)_-=360;else if(_<-180)_+=360;break}return((j+_*$)%360+360)%360}function r1(Q,Z,$,J){let j=[...Q].sort((R,A)=>R.position-A.position),q=Z*100;if(j.length===0)return"#888888";if(q<=j[0].position)return j[0].color;if(q>=j[j.length-1].position)return j[j.length-1].color;let _=0;while(_<j.length-1&&j[_+1].position<q)_++;let X=j[_],Y=j[_+1],K=Y.position-X.position,G=K>0?(q-X.position)/K:0,N=r(X.color),W=r(Y.color),O,B,L,T=$||"oklab";if(T==="srgb-linear"){let R=p(N.r),A=p(N.g),M=p(N.b),E=p(W.r),k=p(W.g),S=p(W.b);O=l(R+(E-R)*G),B=l(A+(k-A)*G),L=l(M+(S-M)*G)}else if(T==="oklch"){let R=e(N.r,N.g,N.b),A=e(W.r,W.g,W.b),M=L0(R.l,R.a,R.b),E=L0(A.l,A.a,A.b),k=M.l+(E.l-M.l)*G,S=M.c+(E.c-M.c)*G,x=k0(M.h,E.h,G,J||"shorter"),y=i1(k,S,x),m=C0(y.l,y.a,y.b);O=m.r,B=m.g,L=m.b}else if(T==="hsl"){let R=B0(N.r,N.g,N.b),A=B0(W.r,W.g,W.b),M=k0(R.h,A.h,G,J||"shorter"),E=R.s+(A.s-R.s)*G,k=R.l+(A.l-R.l)*G,S=o1(M,E,k);O=S[0],B=S[1],L=S[2]}else if(T==="srgb")O=Math.round(N.r+(W.r-N.r)*G),B=Math.round(N.g+(W.g-N.g)*G),L=Math.round(N.b+(W.b-N.b)*G);else{let R=e(N.r,N.g,N.b),A=e(W.r,W.g,W.b),M=R.l+(A.l-R.l)*G,E=R.a+(A.a-R.a)*G,k=R.b+(A.b-R.b)*G,S=C0(M,E,k);O=S.r,B=S.g,L=S.b}return`#${O.toString(16).padStart(2,"0")}${B.toString(16).padStart(2,"0")}${L.toString(16).padStart(2,"0")}`.toUpperCase()}function B0(Q,Z,$){let J=Q/255,j=Z/255,q=$/255,_=Math.max(J,j,q),X=Math.min(J,j,q),Y=(_+X)/2;if(_===X)return{h:0,s:0,l:Y*100};let K=_-X,G=Y>0.5?K/(2-_-X):K/(_+X),N;switch(_){case J:N=((j-q)/K+(j<q?6:0))/6;break;case j:N=((q-J)/K+2)/6;break;default:N=((J-j)/K+4)/6;break}return{h:N*360,s:G*100,l:Y*100}}function o1(Q,Z,$){Z/=100,$/=100;let J=(1-Math.abs(2*$-1))*Z,j=J*(1-Math.abs(Q/60%2-1)),q=$-J/2,_,X,Y;if(Q<60)_=J,X=j,Y=0;else if(Q<120)_=j,X=J,Y=0;else if(Q<180)_=0,X=J,Y=j;else if(Q<240)_=0,X=j,Y=J;else if(Q<300)_=j,X=0,Y=J;else _=J,X=0,Y=j;return[Math.round((_+q)*255),Math.round((X+q)*255),Math.round((Y+q)*255)]}class Q1 extends HTMLElement{#Q="solid";#Z;#$;#J;#j={color:"#D9D9D9",alpha:1};#q={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",opacity:1,stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#_={url:null,scaleMode:"fill",scale:50,opacity:1};#Y={url:null,scaleMode:"fill",opacity:1};#X={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","alpha","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#W(),this.#z()}disconnectedCallback(){this.#Z=null,this.#$=null,this.#J=null}#W(){let Q=this.getAttribute("value");if(!Q)return;try{let Z=JSON.parse(Q);if(Z.type)this.#Q=Z.type;switch(this.#Q){case"solid":if(Z.color)this.#j.color=Z.color;if(Z.alpha!==void 0)this.#j.alpha=Z.alpha;if(Z.opacity!==void 0)this.#j.alpha=Z.opacity/100;break;case"gradient":if(Z.gradient)this.#q=Z0({...this.#q,...Z.gradient}),this.#q.opacity=this.#G(Z.gradient.opacity??Z.opacity??Z.alpha,this.#q.opacity??1);else if(Z.opacity!==void 0||Z.alpha!==void 0)this.#q.opacity=this.#G(Z.opacity??Z.alpha,this.#q.opacity??1);break;case"image":if(Z.image)this.#_={...this.#_,...Z.image};break;case"video":if(Z.video)this.#Y={...this.#Y,...Z.video};break;case"webcam":if(Z.webcam)this.#X={...this.#X,...Z.webcam};if(Z.opacity!==void 0)this.#X.opacity=Z.opacity;break}}catch(Z){if(Q.startsWith("#")){if(this.#Q="solid",this.#j.color=Q.slice(0,7),Q.length>7){let $=Q.slice(7,9);this.#j.alpha=parseInt($,16)/255}}}}#N(){let Q={},Z=this.getAttribute("mode");if(Z)Q.mode=Z;let $=this.getAttribute("alpha");if($)Q.alpha=$;for(let{name:J,value:j}of this.attributes)if(J.startsWith("picker-")&&J!=="picker-anchor"&&J!=="picker-experimental")Q[J.slice(7)]=j;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([J,j])=>`${J}="${v(j)}"`).join(" ")}#K(){switch(this.#Q){case"solid":return this.#j.color;case"gradient":{let Z=[...this.#q.stops].sort((J,j)=>J.position-j.position).map((J)=>{let j=(J.opacity??100)/100;if(j>=1)return`${J.color} ${J.position}%`;let{r:q,g:_,b:X}=r(J.color);return`rgba(${q}, ${_}, ${X}, ${j}) ${J.position}%`}).join(", "),$=e0(this.#q);return`linear-gradient(${this.#q.angle}deg${$?` ${$}`:""}, ${Z})`}case"image":return this.#_.url?`url(${this.#_.url})`:"#D9D9D9";default:return"#D9D9D9"}}#G(Q,Z=1){if(Q===void 0||Q===null||Q==="")return Z;let $=Number(Q);if(!Number.isFinite($))return Z;if($>1)return Math.max(0,Math.min(1,$/100));return Math.max(0,Math.min(1,$))}#U(){switch(this.#Q){case"solid":return this.#j.alpha;case"gradient":return this.#q.opacity??1;case"image":return this.#_.opacity??1;case"video":return this.#Y.opacity??1;case"webcam":return this.#X.opacity??1;default:return 1}}#L(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.setAttribute("aria-disabled",Q?"true":"false");for(let Z of[this.#Z,this.#$,this.#J]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}#F(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#L();let Q=this.getAttribute("aria-label")||"Fill",Z=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),j=(q,_)=>{if(!q)return;if(q.setAttribute("aria-label",_),Z)q.setAttribute("aria-describedby",Z);else q.removeAttribute("aria-describedby");if($)q.setAttribute("aria-invalid",$);else q.removeAttribute("aria-invalid");if(J)q.setAttribute("aria-required",J);else q.removeAttribute("aria-required")};j(this.#Z,`${Q} picker`),j(this.#J,`${Q} hex color`),j(this.#$,`${Q} opacity`)}#z(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=JSON.stringify(this.value),$=this.getAttribute("alpha")!=="false",J=(_)=>$?`<fig-tooltip text="Opacity">
170
170
  <fig-input-number
171
171
  class="fig-input-fill-opacity"
172
172
  placeholder="##"
@@ -176,7 +176,7 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
176
176
  units="%"
177
177
  ${Q?"disabled":""}>
178
178
  </fig-input-number>
179
- </fig-tooltip>`:"",j="";switch(this.#Z){case"solid":j=`
179
+ </fig-tooltip>`:"",j="";switch(this.#Q){case"solid":j=`
180
180
  <fig-input-text
181
181
  type="text"
182
182
  class="fig-input-fill-hex"
@@ -198,7 +198,7 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
198
198
  <fig-swatch background="${v(this.#K())}" alpha="${this.#U()}"${Q?" disabled":""}></fig-swatch>
199
199
  </fig-fill-picker>
200
200
  ${j}
201
- </div>`,this.#B()}#B(){this.#Q=this.querySelector("fig-fill-picker"),this.#$=this.querySelector(".fig-input-fill-opacity"),this.#J=this.querySelector(".fig-input-fill-hex");let Q=this.querySelector(".fig-input-fill-label");if(this.#F(),Q&&this.#Q)Q.addEventListener("click",()=>{let Z=this.#Q.querySelector("fig-swatch");if(Z)Z.click()});if(this.#Q){let Z=this.getAttribute("picker-anchor");if(!Z||Z==="self")this.#Q.anchorElement=this;else{let $=null;try{$=document.querySelector(Z)}catch{}if($)this.#Q.anchorElement=$}this.#Q.addEventListener("input",($)=>{$.stopPropagation();let J=$.detail;if(!J)return;let j=J.type,q=j!==this.#Z;switch(this.#Z=j,j){case"solid":this.#j.color=J.color,this.#j.alpha=J.alpha;break;case"gradient":if(J.gradient)this.#q=Z0({...this.#q,...J.gradient});break;case"image":if(J.image)this.#_=J.image;break;case"video":if(J.video)this.#Y=J.video;break}if(q)this.#D();else this.#M();this.#O()}),this.#Q.addEventListener("change",($)=>{$.stopPropagation(),this.#R()})}if(this.#J)this.#J.addEventListener("input",(Z)=>{Z.stopPropagation();let $="#"+Z.target.value.replace("#","");this.#j.color=$,this.#E(),this.#O()}),this.#J.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#R()});if(this.#$)this.#$.addEventListener("input",(Z)=>{Z.stopPropagation();let $=parseFloat(Z.target.value),j=(isNaN($)?100:$)/100;switch(this.#Z){case"solid":this.#j.alpha=j;break;case"gradient":this.#q.opacity=j;break;case"image":this.#_.opacity=j;break;case"video":this.#Y.opacity=j;break;case"webcam":this.#X.opacity=j;break}this.#E(),this.#H(j),this.#O()}),this.#$.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#R()})}#M(){switch(this.#Z){case"solid":if(this.#J)this.#J.setAttribute("value",this.#j.color.slice(1).toUpperCase());if(this.#$)this.#$.setAttribute("value",Math.round(this.#j.alpha*100));break;case"gradient":{let Q=this.querySelector(".fig-input-fill-label");if(Q){let Z=this.#q.type.charAt(0).toUpperCase()+this.#q.type.slice(1);Q.textContent=Z}if(this.#$)this.#$.setAttribute("value",Math.round((this.#q.opacity??1)*100));break}case"image":if(this.#$)this.#$.setAttribute("value",Math.round((this.#_.opacity??1)*100));break;case"video":if(this.#$)this.#$.setAttribute("value",Math.round((this.#Y.opacity??1)*100));break;case"webcam":if(this.#$)this.#$.setAttribute("value",Math.round((this.#X.opacity??1)*100));break}}#D(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.getAttribute("alpha")!=="false",$=this.querySelector(".input-combo");if(!$)return;let J=$.querySelector(".fig-input-fill-label"),j=$.querySelector(".fig-input-fill-hex"),q=$.querySelector(".fig-input-fill-opacity"),_=$.querySelectorAll("fig-tooltip");J?.remove(),j?.remove(),_.forEach((K)=>K.remove());let X="";switch(this.#Z){case"solid":X=`
201
+ </div>`,this.#B()}#B(){this.#Z=this.querySelector("fig-fill-picker"),this.#$=this.querySelector(".fig-input-fill-opacity"),this.#J=this.querySelector(".fig-input-fill-hex");let Q=this.querySelector(".fig-input-fill-label");if(this.#F(),Q&&this.#Z)Q.addEventListener("click",()=>{let Z=this.#Z.querySelector("fig-swatch");if(Z)Z.click()});if(this.#Z){let Z=this.getAttribute("picker-anchor");if(!Z||Z==="self")this.#Z.anchorElement=this;else{let $=null;try{$=document.querySelector(Z)}catch{}if($)this.#Z.anchorElement=$}this.#Z.addEventListener("input",($)=>{$.stopPropagation();let J=$.detail;if(!J)return;let j=J.type,q=j!==this.#Q;switch(this.#Q=j,j){case"solid":this.#j.color=J.color,this.#j.alpha=J.alpha;break;case"gradient":if(J.gradient)this.#q=Z0({...this.#q,...J.gradient});break;case"image":if(J.image)this.#_=J.image;break;case"video":if(J.video)this.#Y=J.video;break}if(q)this.#D();else this.#M();this.#O()}),this.#Z.addEventListener("change",($)=>{$.stopPropagation(),this.#R()})}if(this.#J)this.#J.addEventListener("input",(Z)=>{Z.stopPropagation();let $="#"+Z.target.value.replace("#","");this.#j.color=$,this.#T(),this.#O()}),this.#J.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#R()});if(this.#$)this.#$.addEventListener("input",(Z)=>{Z.stopPropagation();let $=parseFloat(Z.target.value),j=(isNaN($)?100:$)/100;switch(this.#Q){case"solid":this.#j.alpha=j;break;case"gradient":this.#q.opacity=j;break;case"image":this.#_.opacity=j;break;case"video":this.#Y.opacity=j;break;case"webcam":this.#X.opacity=j;break}this.#T(),this.#H(j),this.#O()}),this.#$.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#R()})}#M(){switch(this.#Q){case"solid":if(this.#J)this.#J.setAttribute("value",this.#j.color.slice(1).toUpperCase());if(this.#$)this.#$.setAttribute("value",Math.round(this.#j.alpha*100));break;case"gradient":{let Q=this.querySelector(".fig-input-fill-label");if(Q){let Z=this.#q.type.charAt(0).toUpperCase()+this.#q.type.slice(1);Q.textContent=Z}if(this.#$)this.#$.setAttribute("value",Math.round((this.#q.opacity??1)*100));break}case"image":if(this.#$)this.#$.setAttribute("value",Math.round((this.#_.opacity??1)*100));break;case"video":if(this.#$)this.#$.setAttribute("value",Math.round((this.#Y.opacity??1)*100));break;case"webcam":if(this.#$)this.#$.setAttribute("value",Math.round((this.#X.opacity??1)*100));break}}#D(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.getAttribute("alpha")!=="false",$=this.querySelector(".input-combo");if(!$)return;let J=$.querySelector(".fig-input-fill-label"),j=$.querySelector(".fig-input-fill-hex"),q=$.querySelector(".fig-input-fill-opacity"),_=$.querySelectorAll("fig-tooltip");J?.remove(),j?.remove(),_.forEach((K)=>K.remove());let X="";switch(this.#Q){case"solid":X=`
202
202
  <fig-input-text
203
203
  type="text"
204
204
  class="fig-input-fill-hex"
@@ -264,12 +264,12 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
264
264
  units="%"
265
265
  ${Q?"disabled":""}>
266
266
  </fig-input-number>
267
- </fig-tooltip>`:""}`;break}$.insertAdjacentHTML("beforeend",X),this.#$=this.querySelector(".fig-input-fill-opacity"),this.#J=this.querySelector(".fig-input-fill-hex");let Y=this.querySelector(".fig-input-fill-label");if(this.#F(),Y&&this.#Q)Y.addEventListener("click",()=>{let K=this.#Q.querySelector("fig-swatch");if(K)K.click()});if(this.#J)this.#J.addEventListener("input",(K)=>{K.stopPropagation();let G="#"+K.target.value.replace("#","");this.#j.color=G,this.#E(),this.#O()}),this.#J.addEventListener("change",(K)=>{K.stopPropagation(),this.#R()});if(this.#$)this.#$.addEventListener("input",(K)=>{K.stopPropagation();let G=parseFloat(K.target.value),W=(isNaN(G)?100:G)/100;switch(this.#Z){case"solid":this.#j.alpha=W;break;case"gradient":this.#q.opacity=W;break;case"image":this.#_.opacity=W;break;case"video":this.#Y.opacity=W;break;case"webcam":this.#X.opacity=W;break}this.#E(),this.#H(W),this.#O()}),this.#$.addEventListener("change",(K)=>{K.stopPropagation(),this.#R()})}#E(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#H(Q){if(this.#Q){let Z=this.#Q.querySelector("fig-swatch");if(Z)Z.setAttribute("alpha",Q)}}#O(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#Z){case"solid":return{type:"solid",color:this.#j.color,alpha:this.#j.alpha,opacity:Math.round(this.#j.alpha*100)};case"gradient":return{type:"gradient",gradient:n0(this.#q)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#Y}};case"webcam":return{type:"webcam",webcam:{...this.#X}};default:return{type:this.#Z}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":let J=this.#Z;if(this.#W(),this.#Q)if(this.#Z!==J)this.#z();else this.#E(),this.#M();break;case"disabled":this.#L();break;case"mode":if(this.#Q)if($)this.#Q.setAttribute(Q,$);else this.#Q.removeAttribute(Q);break;case"alpha":if(this.isConnected)this.#z();break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#F();break}}}z("fig-input-fill",Q1);class Z1 extends HTMLElement{#Z=[];#Q=[];#$=[];#J=null;#j=this.#W.bind(this);#q=()=>this.focus();static get observedAttributes(){return["value","disabled","min","max","open","fixed"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){let Z=this.open;if(Q)this.setAttribute("open","");else this.removeAttribute("open");if(Z!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}get#_(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#Y(){let Q=parseInt(this.getAttribute("min"));return isNaN(Q)?2:Q}get#X(){let Q=parseInt(this.getAttribute("max"));return isNaN(Q)?8:Q}connectedCallback(){if(this.setAttribute("tabindex","-1"),this.removeEventListener("focus",this.#q),this.addEventListener("focus",this.#q),this.removeEventListener("keydown",this.#j),this.addEventListener("keydown",this.#j),this.#J)cancelAnimationFrame(this.#J);this.#J=requestAnimationFrame(()=>{if(this.#J=null,!this.isConnected)return;this.#N(),this.#K()})}disconnectedCallback(){if(this.#J)cancelAnimationFrame(this.#J),this.#J=null;this.removeEventListener("keydown",this.#j),this.removeEventListener("focus",this.#q),this.#Q=[],this.#$=[]}#W(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target!==this.querySelector(".palette-colors-inline"))return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.preventDefault(),Q.stopPropagation(),this.open=!0,this.querySelector(".palette-colors-inline")?.setAttribute("aria-expanded","true")}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":this.#N(),this.#M();break;case"disabled":this.#D();break;case"min":case"max":case"fixed":this.#K();break;case"open":this.#E();break}}#N(){let Q=this.getAttribute("value");if(!Q){this.#Z=[];return}let Z=Q.trim();try{let $=JSON.parse(Z);if(Array.isArray($)){this.#Z=$.map((J)=>{if(typeof J==="string")return{color:J.slice(0,7),alpha:J.length>7?parseInt(J.slice(7,9),16)/255:1};if(J&&typeof J==="object")return{color:J.color||"#D9D9D9",alpha:J.alpha!==void 0?J.alpha:J.opacity!==void 0?J.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch($){}if(Z.includes(",")){this.#Z=Z.split(",").map(($)=>{let J=$.trim();return{color:J.slice(0,7),alpha:J.length>7?parseInt(J.slice(7,9),16)/255:1}});return}if(Z.startsWith("#")){this.#Z=[{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}];return}this.#Z=[]}get value(){return this.#Z.map((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#K(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#$=[];let Z=document.createElement("div");Z.className="palette-colors-inline",Z.setAttribute("role","button"),Z.setAttribute("tabindex",Q?"-1":"+0"),Z.setAttribute("aria-expanded",String(this.open)),Z.setAttribute("aria-label","Edit palette colors"),Z.addEventListener("blur",()=>{Z.style.removeProperty("outline"),Z.style.removeProperty("outline-offset")});let $=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0,Z.setAttribute("aria-expanded","true")};Z.addEventListener("click",$);let J=document.createElement("div");if(J.className="palette-colors",this.#Z.forEach((q,_)=>{J.appendChild(this.#G(q,_,Q,{inline:!0}))}),Z.appendChild(J),this.appendChild(Z),this.#E(),!this.#_)this.#F(Q,this);let j=document.createElement("div");j.className="palette-colors-expanded",this.#Z.forEach((q,_)=>{if(j.appendChild(this.#G(q,_,Q)),!this.#_)j.appendChild(this.#U(_,Q))}),this.appendChild(j)}#G(Q,Z,$,{inline:J=!1}={}){let j=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,q=document.createElement("fig-input-color");if(q.setAttribute("value",j),J)q.setAttribute("text","false"),q.setAttribute("alpha","true"),q.setAttribute("swatch-disabled","");else q.setAttribute("text","true"),q.setAttribute("alpha","true"),q.setAttribute("full","");if($)q.setAttribute("disabled","");let _=J?this.#$:this.#Q,X=(Y)=>{Y.stopPropagation();let K=Y.currentTarget;this.#Z[Z]={color:K.hexOpaque||this.#Z[Z].color,alpha:K.rgba?K.rgba.a:this.#Z[Z].alpha};let G=_[Z];if(G){let N=this.#Z[Z],W=N.alpha<1?N.color+Math.round(N.alpha*255).toString(16).padStart(2,"0"):N.color;G.setAttribute("value",W)}};if(q.addEventListener("input",(Y)=>{X(Y),this.#O()}),q.addEventListener("change",(Y)=>{X(Y),this.#R()}),J)this.#Q.push(q);else this.#$.push(q);return q}#U(Q,Z){let $=document.createElement("fig-button");if($.setAttribute("variant","ghost"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Remove color"),$.className="palette-remove-btn",Z||this.#Z.length<=this.#Y)$.setAttribute("disabled","");$.appendChild(u("minus")),$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#L(Q)});let J=document.createElement("fig-tooltip");return J.setAttribute("text","Remove color"),J.appendChild($),J}#L(Q){if(this.#_)return;if(Q<0||Q>=this.#Z.length)return;if(this.#Z.length<=this.#Y)return;this.#Z.splice(Q,1),this.#Q=[],this.#$=[],this.#K(),this.#R()}#F(Q,Z=this){let $=this.#Z.length>=this.#X,J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Add color"),J.className="palette-add-btn",Q||$)J.setAttribute("disabled","");J.appendChild(u("add")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Z.length>=this.#X)return;this.open=!0,this.#z({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(J),Z.appendChild(j)}#z(Q){if(this.#_)return;this.#Z.push(Q);let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#Z.length-1,J=this.#G(Q,$,Z,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(J);let q=this.#G(Q,$,Z),_=this.querySelector(".palette-colors-expanded");if(_)_.appendChild(q),_.appendChild(this.#U($,Z));if(this.#Z.length>=this.#X){let X=this.querySelector(".palette-add-btn");if(X)X.setAttribute("disabled","")}this.#H(Z),this.#R()}#B(Q){let Z=this.#Z[Q];if(!Z)return;let $=Z.alpha<1?Z.color+Math.round(Z.alpha*255).toString(16).padStart(2,"0"):Z.color,J=this.#Q[Q];if(J)J.setAttribute("value",$);let j=this.#$[Q];if(j)j.setAttribute("value",$)}#M(){if(this.#Q.length!==this.#Z.length){this.#K();return}this.#Z.forEach((Q,Z)=>{this.#B(Z)})}#D(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#$].forEach(($)=>{if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")});let Z=this.querySelector(".palette-add-btn");if(Z)if(Q||this.#Z.length>=this.#X)Z.setAttribute("disabled","");else Z.removeAttribute("disabled");this.#H(Q),this.#E()}#E(){let Q=this.querySelector(".palette-colors-inline");if(!Q)return;let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";Q.setAttribute("tabindex",Z?"-1":"+0"),Q.setAttribute("aria-disabled",String(Z)),Q.setAttribute("aria-expanded",String(this.open))}focus(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.querySelector(".palette-colors-inline");if(!Q)return;Q.style.outline="var(--figma-focus-outline)",Q.style.outlineOffset="var(--figma-focus-outline-offset)",Q.focus()}#H(Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let Z=Q||this.#Z.length<=this.#Y;this.querySelectorAll(".palette-remove-btn").forEach(($)=>{if(Z)$.setAttribute("disabled","");else $.removeAttribute("disabled")})}#O(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}z("fig-input-palette",Z1);class Q0 extends HTMLElement{static SHIFT_SNAP=5;#Z;#Q;#$=!1;#J=null;#j=null;#q=null;#_={type:"linear",angle:90,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode","size"]}get#Y(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#X(){return this.#Y==="true"}get#W(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#N(){if(!this.#Q)return null;return this.#Q.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#K(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#X?"-1":"0")}#G(Q){let Z=Z0(Q);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.#F(),this.#R(),this.removeEventListener("keydown",this.#L),this.addEventListener("keydown",this.#L),this.#X)document.addEventListener("keydown",this.#U)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#U),this.removeEventListener("keydown",this.#L),this.#j)this.#j.disconnect(),this.#j=null;if(this.#q!==null)cancelAnimationFrame(this.#q),this.#q=null;clearTimeout(this.#J),this.removeEventListener("pointerenter",this.#k),this.removeEventListener("pointermove",this.#f),this.removeEventListener("pointerleave",this.#T),this.removeEventListener("click",this.#h),this.removeEventListener("dblclick",this.#g)}#U=(Q)=>{let Z=document.activeElement;if(!(Z instanceof Node)||!this.contains(Z))return;let $=Z&&(Z.tagName==="INPUT"||Z.tagName==="TEXTAREA"||Z.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!$){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;Q.preventDefault();let _=[...this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],X=_.indexOf(q),Y=Q.shiftKey?(X-1+_.length)%_.length:(X+1)%_.length;q.deselect(),_[Y].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!$){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;let _=parseInt(q.dataset.stopIndex,10);if(isNaN(_)||!this.#_.stops[_])return;Q.preventDefault();let X=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?Q0.SHIFT_SNAP:1),Y=this.#_.stops[_];Y.position=Math.max(0,Math.min(100,Y.position+X)),q.setAttribute("value",`${Y.position}% 50%`);let K=q.closest("fig-tooltip");if(K)K.text=`${Math.round(Y.position)}%`,K.setAttribute("show","true"),K.showPopup(),q.hideColorTip(),clearTimeout(this.#J),this.#J=setTimeout(()=>{K.removeAttribute("show"),q.showColorTip()},600);this.#v(),this.#p(),this.#s();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if($)return;if(this.#_.stops.length<=2)return;let J=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!J)return;let j=parseInt(J.dataset.stopIndex,10);if(isNaN(j)||!this.#_.stops[j])return;Q.preventDefault(),J.removeAttribute("selected"),this.#_.stops.splice(j,1),this.#b(),this.#v(),this.#p(),this.#s()};#L=(Q)=>{if(this.#Y!=="picker")return;if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.altKey||Q.ctrlKey||Q.metaKey)return;if(F(this,"disabled"))return;let Z=this.querySelector("fig-fill-picker");if(!Z||typeof Z.open!=="function")return;Q.preventDefault(),Z.open()};#F(){let Q=this.getAttribute("value");if(!Q)return;try{let Z=JSON.parse(Q);if(Z?.type==="gradient"&&Z.gradient){this.#_=this.#G({...this.#_,...Z.gradient});return}if(Z?.gradient)this.#_=this.#G({...this.#_,...Z.gradient})}catch(Z){}}#z(){let Q=this.#G(this.#_),$=[...Q.stops].sort((q,_)=>q.position-_.position).map((q)=>{let _=(q.opacity??100)/100;if(_>=1)return`${q.color} ${q.position}%`;let{r:X,g:Y,b:K}=r(q.color);return`rgba(${X}, ${Y}, ${K}, ${_}) ${q.position}%`}).join(", "),J=e0(Q),j=J?` ${J}`:"";if(this.#Y==="true")return`linear-gradient(to right${j}, ${$})`;if(Q.type==="radial")return`radial-gradient(circle at ${Q.centerX}% ${Q.centerY}%${j}, ${$})`;if(Q.type==="angular")return`conic-gradient(from ${Q.angle}deg${j}, ${$})`;return`linear-gradient(${Q.angle}deg${j}, ${$})`}#B(Q){let Z=(Q.opacity??100)/100;if(Z>=1)return Q.color;let{r:$,g:J,b:j}=r(Q.color);return`rgba(${$}, ${J}, ${j}, ${Z})`}#M(){let Q=this.getAttribute("size");return Q?` size="${Q}"`:""}#D(){if(!this.#Z)return;let Q=this.getAttribute("size");if(Q)this.#Z.setAttribute("size",Q);else this.#Z.removeAttribute("size")}#E(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.#W==="tip"?' tip="color"':"";return this.#_.stops.map(($,J)=>`<fig-tooltip action="manual" text="${Math.round($.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${Z} color="${this.#B($)}" value="${$.position}% 50%" hit-area="4" data-stop-index="${J}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#H=null;#O=!1;#R(){this.#j?.disconnect(),this.#j=null;let Q=F(this,"disabled"),Z=this.#Y;if(Z==="picker"&&o()){let $=JSON.stringify(this.value);this.innerHTML=`
267
+ </fig-tooltip>`:""}`;break}$.insertAdjacentHTML("beforeend",X),this.#$=this.querySelector(".fig-input-fill-opacity"),this.#J=this.querySelector(".fig-input-fill-hex");let Y=this.querySelector(".fig-input-fill-label");if(this.#F(),Y&&this.#Z)Y.addEventListener("click",()=>{let K=this.#Z.querySelector("fig-swatch");if(K)K.click()});if(this.#J)this.#J.addEventListener("input",(K)=>{K.stopPropagation();let G="#"+K.target.value.replace("#","");this.#j.color=G,this.#T(),this.#O()}),this.#J.addEventListener("change",(K)=>{K.stopPropagation(),this.#R()});if(this.#$)this.#$.addEventListener("input",(K)=>{K.stopPropagation();let G=parseFloat(K.target.value),W=(isNaN(G)?100:G)/100;switch(this.#Q){case"solid":this.#j.alpha=W;break;case"gradient":this.#q.opacity=W;break;case"image":this.#_.opacity=W;break;case"video":this.#Y.opacity=W;break;case"webcam":this.#X.opacity=W;break}this.#T(),this.#H(W),this.#O()}),this.#$.addEventListener("change",(K)=>{K.stopPropagation(),this.#R()})}#T(){if(this.#Z)this.#Z.setAttribute("value",JSON.stringify(this.value))}#H(Q){if(this.#Z){let Z=this.#Z.querySelector("fig-swatch");if(Z)Z.setAttribute("alpha",Q)}}#O(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#Q){case"solid":return{type:"solid",color:this.#j.color,alpha:this.#j.alpha,opacity:Math.round(this.#j.alpha*100)};case"gradient":return{type:"gradient",gradient:n0(this.#q)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#Y}};case"webcam":return{type:"webcam",webcam:{...this.#X}};default:return{type:this.#Q}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":let J=this.#Q;if(this.#W(),this.#Z)if(this.#Q!==J)this.#z();else this.#T(),this.#M();break;case"disabled":this.#L();break;case"mode":if(this.#Z)if($)this.#Z.setAttribute(Q,$);else this.#Z.removeAttribute(Q);break;case"alpha":if(this.isConnected)this.#z();break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#F();break}}}z("fig-input-fill",Q1);class Z1 extends HTMLElement{#Q=[];#Z=[];#$=[];#J=null;#j=this.#W.bind(this);#q=()=>this.focus();static get observedAttributes(){return["value","disabled","min","max","open","fixed"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){let Z=this.open;if(Q)this.setAttribute("open","");else this.removeAttribute("open");if(Z!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}get#_(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#Y(){let Q=parseInt(this.getAttribute("min"));return isNaN(Q)?2:Q}get#X(){let Q=parseInt(this.getAttribute("max"));return isNaN(Q)?8:Q}connectedCallback(){if(this.setAttribute("tabindex","-1"),this.removeEventListener("focus",this.#q),this.addEventListener("focus",this.#q),this.removeEventListener("keydown",this.#j),this.addEventListener("keydown",this.#j),this.#J)cancelAnimationFrame(this.#J);this.#J=requestAnimationFrame(()=>{if(this.#J=null,!this.isConnected)return;this.#N(),this.#K()})}disconnectedCallback(){if(this.#J)cancelAnimationFrame(this.#J),this.#J=null;this.removeEventListener("keydown",this.#j),this.removeEventListener("focus",this.#q),this.#Z=[],this.#$=[]}#W(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target!==this.querySelector(".palette-colors-inline"))return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.preventDefault(),Q.stopPropagation(),this.open=!0,this.querySelector(".palette-colors-inline")?.setAttribute("aria-expanded","true")}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":this.#N(),this.#M();break;case"disabled":this.#D();break;case"min":case"max":case"fixed":this.#K();break;case"open":this.#T();break}}#N(){let Q=this.getAttribute("value");if(!Q){this.#Q=[];return}let Z=Q.trim();try{let $=JSON.parse(Z);if(Array.isArray($)){this.#Q=$.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.#Q=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.#Q=[{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}];return}this.#Q=[]}get value(){return this.#Q.map((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#K(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Z=[],this.#$=[];let Z=document.createElement("div");Z.className="palette-colors-inline",Z.setAttribute("role","button"),Z.setAttribute("tabindex",Q?"-1":"+0"),Z.setAttribute("aria-expanded",String(this.open)),Z.setAttribute("aria-label","Edit palette colors"),Z.addEventListener("blur",()=>{Z.style.removeProperty("outline"),Z.style.removeProperty("outline-offset")});let $=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0,Z.setAttribute("aria-expanded","true")};Z.addEventListener("click",$);let J=document.createElement("div");if(J.className="palette-colors",this.#Q.forEach((q,_)=>{J.appendChild(this.#G(q,_,Q,{inline:!0}))}),Z.appendChild(J),this.appendChild(Z),this.#T(),!this.#_)this.#F(Q,this);let j=document.createElement("div");j.className="palette-colors-expanded",this.#Q.forEach((q,_)=>{if(j.appendChild(this.#G(q,_,Q)),!this.#_)j.appendChild(this.#U(_,Q))}),this.appendChild(j)}#G(Q,Z,$,{inline:J=!1}={}){let j=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,q=document.createElement("fig-input-color");if(q.setAttribute("value",j),J)q.setAttribute("text","false"),q.setAttribute("alpha","true"),q.setAttribute("swatch-disabled","");else q.setAttribute("text","true"),q.setAttribute("alpha","true"),q.setAttribute("full","");if($)q.setAttribute("disabled","");let _=J?this.#$:this.#Z,X=(Y)=>{Y.stopPropagation();let K=Y.currentTarget;this.#Q[Z]={color:K.hexOpaque||this.#Q[Z].color,alpha:K.rgba?K.rgba.a:this.#Q[Z].alpha};let G=_[Z];if(G){let N=this.#Q[Z],W=N.alpha<1?N.color+Math.round(N.alpha*255).toString(16).padStart(2,"0"):N.color;G.setAttribute("value",W)}};if(q.addEventListener("input",(Y)=>{X(Y),this.#O()}),q.addEventListener("change",(Y)=>{X(Y),this.#R()}),J)this.#Z.push(q);else this.#$.push(q);return q}#U(Q,Z){let $=document.createElement("fig-button");if($.setAttribute("variant","ghost"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Remove color"),$.className="palette-remove-btn",Z||this.#Q.length<=this.#Y)$.setAttribute("disabled","");$.appendChild(u("minus")),$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#L(Q)});let J=document.createElement("fig-tooltip");return J.setAttribute("text","Remove color"),J.appendChild($),J}#L(Q){if(this.#_)return;if(Q<0||Q>=this.#Q.length)return;if(this.#Q.length<=this.#Y)return;this.#Q.splice(Q,1),this.#Z=[],this.#$=[],this.#K(),this.#R()}#F(Q,Z=this){let $=this.#Q.length>=this.#X,J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Add color"),J.className="palette-add-btn",Q||$)J.setAttribute("disabled","");J.appendChild(u("add")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Q.length>=this.#X)return;this.open=!0,this.#z({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(J),Z.appendChild(j)}#z(Q){if(this.#_)return;this.#Q.push(Q);let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#Q.length-1,J=this.#G(Q,$,Z,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(J);let q=this.#G(Q,$,Z),_=this.querySelector(".palette-colors-expanded");if(_)_.appendChild(q),_.appendChild(this.#U($,Z));if(this.#Q.length>=this.#X){let X=this.querySelector(".palette-add-btn");if(X)X.setAttribute("disabled","")}this.#H(Z),this.#R()}#B(Q){let Z=this.#Q[Q];if(!Z)return;let $=Z.alpha<1?Z.color+Math.round(Z.alpha*255).toString(16).padStart(2,"0"):Z.color,J=this.#Z[Q];if(J)J.setAttribute("value",$);let j=this.#$[Q];if(j)j.setAttribute("value",$)}#M(){if(this.#Z.length!==this.#Q.length){this.#K();return}this.#Q.forEach((Q,Z)=>{this.#B(Z)})}#D(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Z,...this.#$].forEach(($)=>{if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")});let Z=this.querySelector(".palette-add-btn");if(Z)if(Q||this.#Q.length>=this.#X)Z.setAttribute("disabled","");else Z.removeAttribute("disabled");this.#H(Q),this.#T()}#T(){let Q=this.querySelector(".palette-colors-inline");if(!Q)return;let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";Q.setAttribute("tabindex",Z?"-1":"+0"),Q.setAttribute("aria-disabled",String(Z)),Q.setAttribute("aria-expanded",String(this.open))}focus(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.querySelector(".palette-colors-inline");if(!Q)return;Q.style.outline="var(--figma-focus-outline)",Q.style.outlineOffset="var(--figma-focus-outline-offset)",Q.focus()}#H(Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let Z=Q||this.#Q.length<=this.#Y;this.querySelectorAll(".palette-remove-btn").forEach(($)=>{if(Z)$.setAttribute("disabled","");else $.removeAttribute("disabled")})}#O(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}z("fig-input-palette",Z1);class Q0 extends HTMLElement{static SHIFT_SNAP=5;#Q;#Z;#$=!1;#J=null;#j=null;#q=null;#_={type:"linear",angle:90,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode","size"]}get#Y(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#X(){return this.#Y==="true"}get#W(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#N(){if(!this.#Z)return null;return this.#Z.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#K(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#X?"-1":"0")}#G(Q){let Z=Z0(Q);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.#F(),this.#R(),this.removeEventListener("keydown",this.#L),this.addEventListener("keydown",this.#L),this.#X)document.addEventListener("keydown",this.#U)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#U),this.removeEventListener("keydown",this.#L),this.#j)this.#j.disconnect(),this.#j=null;if(this.#q!==null)cancelAnimationFrame(this.#q),this.#q=null;clearTimeout(this.#J),this.removeEventListener("pointerenter",this.#E),this.removeEventListener("pointermove",this.#k),this.removeEventListener("pointerleave",this.#C),this.removeEventListener("click",this.#b),this.removeEventListener("dblclick",this.#v)}#U=(Q)=>{let Z=document.activeElement;if(!(Z instanceof Node)||!this.contains(Z))return;let $=Z&&(Z.tagName==="INPUT"||Z.tagName==="TEXTAREA"||Z.isContentEditable);if(!this.#Z)return;if(Q.key==="Tab"&&!$){let q=this.#Z.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;Q.preventDefault();let _=[...this.#Z.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],X=_.indexOf(q),Y=Q.shiftKey?(X-1+_.length)%_.length:(X+1)%_.length;q.deselect(),_[Y].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!$){let q=this.#Z.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;let _=parseInt(q.dataset.stopIndex,10);if(isNaN(_)||!this.#_.stops[_])return;Q.preventDefault();let X=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?Q0.SHIFT_SNAP:1),Y=this.#_.stops[_];Y.position=Math.max(0,Math.min(100,Y.position+X)),q.setAttribute("value",`${Y.position}% 50%`);let K=q.closest("fig-tooltip");if(K)K.text=`${Math.round(Y.position)}%`,K.setAttribute("show","true"),K.showPopup(),q.hideColorTip(),clearTimeout(this.#J),this.#J=setTimeout(()=>{K.removeAttribute("show"),q.showColorTip()},600);this.#h(),this.#p(),this.#s();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if($)return;if(this.#_.stops.length<=2)return;let J=this.#Z.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!J)return;let j=parseInt(J.dataset.stopIndex,10);if(isNaN(j)||!this.#_.stops[j])return;Q.preventDefault(),J.removeAttribute("selected"),this.#_.stops.splice(j,1),this.#g(),this.#h(),this.#p(),this.#s()};#L=(Q)=>{if(this.#Y!=="picker")return;if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.altKey||Q.ctrlKey||Q.metaKey)return;if(F(this,"disabled"))return;let Z=this.querySelector("fig-fill-picker");if(!Z||typeof Z.open!=="function")return;Q.preventDefault(),Z.open()};#F(){let Q=this.getAttribute("value");if(!Q)return;try{let Z=JSON.parse(Q);if(Z?.type==="gradient"&&Z.gradient){this.#_=this.#G({...this.#_,...Z.gradient});return}if(Z?.gradient)this.#_=this.#G({...this.#_,...Z.gradient})}catch(Z){}}#z(){let Q=this.#G(this.#_),$=[...Q.stops].sort((q,_)=>q.position-_.position).map((q)=>{let _=(q.opacity??100)/100;if(_>=1)return`${q.color} ${q.position}%`;let{r:X,g:Y,b:K}=r(q.color);return`rgba(${X}, ${Y}, ${K}, ${_}) ${q.position}%`}).join(", "),J=e0(Q),j=J?` ${J}`:"";if(this.#Y==="true")return`linear-gradient(to right${j}, ${$})`;if(Q.type==="radial")return`radial-gradient(circle at ${Q.centerX}% ${Q.centerY}%${j}, ${$})`;if(Q.type==="angular")return`conic-gradient(from ${Q.angle}deg${j}, ${$})`;return`linear-gradient(${Q.angle}deg${j}, ${$})`}#B(Q){let Z=(Q.opacity??100)/100;if(Z>=1)return Q.color;let{r:$,g:J,b:j}=r(Q.color);return`rgba(${$}, ${J}, ${j}, ${Z})`}#M(){let Q=this.getAttribute("size");return Q?` size="${Q}"`:""}#D(){if(!this.#Q)return;let Q=this.getAttribute("size");if(Q)this.#Q.setAttribute("size",Q);else this.#Q.removeAttribute("size")}#T(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.#W==="tip"?' tip="color"':"";return this.#_.stops.map(($,J)=>`<fig-tooltip action="manual" text="${Math.round($.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${Z} color="${this.#B($)}" value="${$.position}% 50%" hit-area="4" data-stop-index="${J}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#H=null;#O=!1;#R(){this.#j?.disconnect(),this.#j=null;let Q=F(this,"disabled"),Z=this.#Y;if(Z==="picker"&&o()){let $=JSON.stringify(this.value);this.innerHTML=`
268
268
  <fig-fill-picker mode="gradient" value='${$}'${Q?" disabled":""}>
269
269
  <fig-swatch background="${this.#z()}"${this.#M()}${Q?" disabled":""}></fig-swatch>
270
- </fig-fill-picker>`,this.#Z=this.querySelector("fig-swatch"),this.#Q=null,this.#P(),this.#K();return}if(this.innerHTML=`
270
+ </fig-fill-picker>`,this.#Q=this.querySelector("fig-swatch"),this.#Z=null,this.#P(),this.#K();return}if(this.innerHTML=`
271
271
  <fig-swatch background="${this.#z()}"${this.#M()}${Q?" disabled":""}></fig-swatch>
272
- ${Z==="true"||Z==="picker"?`<div class="fig-input-gradient-track">${this.#E()}</div>`:""}`,this.#Z=this.querySelector("fig-swatch"),this.#Q=this.querySelector(".fig-input-gradient-track"),Z==="true"||Z==="picker")this.#S(),this.#d();this.#K()}#P(){let Q=this.querySelector("fig-fill-picker");if(!Q)return;Q.anchorElement=this;let Z=($)=>{$.stopPropagation();let J=$.detail;if(!J?.gradient)return;this.#_=this.#G({...this.#_,...J.gradient}),this.#v()};Q.addEventListener("input",($)=>{Z($),this.#p()}),Q.addEventListener("change",($)=>{Z($),this.#s()})}#C(Q){return r1(this.#_.stops,Q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#S(){if(!this.#Q||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#W==="tip")Q.setAttribute("tip","add");Q.style.position="absolute",Q.style.top="50%",Q.style.transform="translate(-50%, -50%)",Q.style.pointerEvents="none",Q.style.opacity="0",Q.style.transition="opacity 0.15s",this.#Q.appendChild(Q),this.#H=Q,this.addEventListener("pointerenter",this.#k),this.addEventListener("pointermove",this.#f),this.addEventListener("pointerleave",this.#T),this.addEventListener("click",this.#h),this.addEventListener("dblclick",this.#g)}#I(){if(!this.#H)return;this.#H.style.opacity="1"}#A(){if(!this.#H)return;this.#H.style.opacity="0"}#k=()=>{if(this.#$)return;this.#I()};#T=()=>{this.#A()};#f=(Q)=>{if(this.#$){this.#A();return}if(!this.#H||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#A();return}let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width));this.#H.style.left=`${$*100}%`;let J=this.#C($);this.#H.setAttribute("color",J),this.#I()};#y(){let Q=this.#_.stops.length;if(Q<2)return;for(let Z=0;Z<Q;Z++)this.#_.stops[Z].position=Math.round(Z/(Q-1)*100);this.#b(),this.#v(),this.#p(),this.#s()}#g=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#y(),this.#Q.querySelectorAll("fig-handle[selected]").forEach((Z)=>{Z.removeAttribute("selected")})};#h=(Q)=>{if(!this.#Q)return;if(this.#$)return;if(this.#O){this.#O=!1;return}if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(Q.shiftKey){let _=Q.target.closest("fig-handle"),X=parseInt(_?.dataset.stopIndex,10);if(this.#y(),!isNaN(X))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(parseInt(Y.dataset.stopIndex,10)===X)Y.select();else Y.deselect()});Q.stopPropagation()}return}let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#C($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((_,X)=>_.position-X.position);let q=this.#_.stops.findIndex((_)=>_.position===J&&_.color===j);this.#b(),this.#v(),this.#p(),this.#s(),requestAnimationFrame(()=>{let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)X.click()})};#w(){if(this.#q=null,!this.isConnected)return;if(!this.#Q)return;let Q=this.#_.stops;this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z,$)=>{if($>=Q.length)return;Z.removeAttribute("value"),Z.setAttribute("value",`${Q[$].position}% 50%`)})}refreshLayout(){this.#w()}#V(){if(this.#q!==null)return;this.#q=requestAnimationFrame(()=>this.#w())}#b(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops;if(Q.length!==Z.length){let $=this.#H;if(this.#Q.innerHTML=this.#E(),$)this.#Q.appendChild($);this.#x(),this.#u(),this.#V();return}for(let $=0;$<Z.length;$++){let J=Q[$],j=Z[$];if(J.dataset.stopIndex=$,J.setAttribute("value",`${j.position}% 50%`),J.setAttribute("color",this.#B(j)),this.#W==="tip")J.setAttribute("tip","color");else J.removeAttribute("tip");let q=J.closest("fig-tooltip");if(q)q.setAttribute("text",`${Math.round(j.position)}%`)}this.#x()}#x(){if(!this.#Q)return;let Q=this.#W==="tip";if(this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(Q)Z.setAttribute("tip","color");else Z.removeAttribute("tip")}),this.#H)if(Q)this.#H.setAttribute("tip","add");else this.#H.removeAttribute("tip")}#u(){if(!this.#j||!this.#Q)return;this.#j.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#m(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops,$=new Set;Q.forEach((J)=>{let j=Math.round(parseFloat(J.getAttribute("value"))||0),q=(J.getAttribute("color")||"").toUpperCase(),_=-1;for(let X=0;X<Z.length;X++){if($.has(X))continue;if(Z[X].position===j&&Z[X].color.toUpperCase()===q){_=X;break}}if(_===-1){let X=1/0;for(let Y=0;Y<Z.length;Y++){if($.has(Y))continue;let K=Math.abs(Z[Y].position-j);if(K<X)X=K,_=Y}}if(_!==-1)$.add(_),J.dataset.stopIndex=_})}#v(){if(!this.#Z)return;this.#Z.setAttribute("background",this.#z()),this.#D()}#d(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(F(this,"disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#C($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((Y,K)=>Y.position-K.position);let q=this.#_.stops.findIndex((Y)=>Y.position===J&&Y.color===j);this.#O=!0,this.#b(),this.#v(),this.#p(),this.#A();let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(Y!==X)Y.deselect()}),X.select(),X.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:Q.clientX,clientY:Q.clientY,pointerId:Q.pointerId,pointerType:Q.pointerType,button:Q.button,buttons:Q.buttons}))}),this.#Q.addEventListener("input",(Q)=>{let Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt(Z.dataset.stopIndex,10);if(!isNaN(Y)&&this.#_.stops[Y]){if(this.#_.stops[Y].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[Y].opacity=Q.detail.opacity;Z.setAttribute("color",this.#B(this.#_.stops[Y])),this.#v(),this.#p()}return}if(!this.#$)Z.style.zIndex="5";this.#$=!0;let $=parseInt(Z.dataset.stopIndex,10);if(isNaN($)||!this.#_.stops[$])return;let J=Q.detail?.px??0,j=Math.round(J*100),q=j,_=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)q=Math.round(q/Q0.SHIFT_SNAP)*Q0.SHIFT_SNAP;else{let Y=_>0?5/_*100:0;for(let K=0;K<this.#_.stops.length;K++){if(K===$)continue;if(Math.abs(this.#_.stops[K].position-q)<=Y){q=this.#_.stops[K].position;break}}}if(this.#_.stops[$].position=q,q!==j)Z.style.left=`${q/100*_}px`;let X=Z.closest("fig-tooltip");if(X){if(X.text=`${Math.round(q)}%`,!X.hasAttribute("show"))X.setAttribute("show","true"),Z.hideColorTip()}this.#v(),this.#p()}),this.#Q.addEventListener("change",(Q)=>{let Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt(Z.dataset.stopIndex,10);if(!isNaN(Y)&&this.#_.stops[Y]){if(this.#_.stops[Y].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[Y].opacity=Q.detail.opacity;Z.setAttribute("color",this.#B(this.#_.stops[Y])),this.#v(),this.#s()}return}Z.style.zIndex="";let $=Z.closest("fig-tooltip");if($)$.removeAttribute("show");Z.showColorTip();let J=parseInt(Z.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])return;let j=Q.detail?.px??0,q=Math.round(j*100),_=this.#Q.getBoundingClientRect().width,X=_>0?5/_*100:0;for(let Y=0;Y<this.#_.stops.length;Y++){if(Y===J)continue;if(Math.abs(this.#_.stops[Y].position-q)<=X){q=this.#_.stops[Y].position;break}}this.#_.stops[J].position=q,Z.style.left=`${q/100*_}px`,this.#_.stops.sort((Y,K)=>Y.position-K.position),this.#m(),this.#v(),this.#s(),requestAnimationFrame(()=>{this.#$=!1})}),this.#j=new MutationObserver((Q)=>{for(let Z of Q){if(Z.attributeName!=="color")continue;let $=Z.target;if($.classList.contains("fig-input-gradient-ghost"))continue;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])continue;let j=$.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#_.stops[J].color)this.#_.stops[J].color=j,this.#v(),this.#p()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#p(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#s(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:n0(this.#G(this.#_))}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}focus(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#X){let Z=this.#N();if(Z){Z.focus(Q);return}}HTMLElement.prototype.focus.call(this,Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":this.#F(),this.#v(),this.#b();break;case"disabled":this.#t();break;case"edit":if(this.#R(),this.#X)document.addEventListener("keydown",this.#U);else document.removeEventListener("keydown",this.#U);break;case"mode":this.#x();break;case"size":this.#D();break}}#t(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#K(),this.#Z)if(Q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#Q)for(let Z of this.#Q.querySelectorAll("fig-handle"))if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}z("fig-input-gradient",Q0);class Y0 extends HTMLElement{#Z=null;#Q;#$;#J;#j=!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.#Q=this.handleInput.bind(this),this.#$=this.handleChange.bind(this),this.#J=(Q)=>{if(Q.target!==this||this.input.disabled)return;this.input.click()}}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("input",this.#Q),this.input.addEventListener("input",this.#Q),this.input.removeEventListener("change",this.#$),this.input.addEventListener("change",this.#$),this.removeEventListener("click",this.#J),this.addEventListener("click",this.#J),this.#X();let Z=this.querySelector(":scope > label");if(Z)this.#Z=Z,this.#j=!1,this.#Z.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#q(),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"]}#q(){if(!this.#Z)this.#Z=document.createElement("label"),this.#j=!0,this.#Z.setAttribute("for",this.input.id);if(this.#Z&&!this.#Z.parentNode&&this.input.parentNode)this.input.after(this.#Z)}render(){}#_(Q){return this.hasAttribute(Q)&&this.getAttribute(Q)!=="false"}#Y(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#X(){let Q=this.#_("checked"),Z=this.#_("indeterminate")&&!Q,$=this.#_("disabled");this.input.checked=Q,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.#Y()}focus(){this.input.focus()}get value(){return this.input.value}set value(Q){this.input.value=Q,this.setAttribute("value",Q)}get checked(){return this.input.checked}set checked(Q){if(this.input.checked=Q,Q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("input",this.#Q),this.input.removeEventListener("change",this.#$),this.removeEventListener("click",this.#J)}attributeChangedCallback(Q,Z,$){switch(Q){case"label":if($)this.#q(),this.#Z.innerText=$;else if(this.#Z&&this.#j)this.#Z.remove(),this.#Z=null,this.#j=!1;break;case"checked":if(this.#_("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#X();break;case"indeterminate":this.#X();break;case"disabled":this.#X();break;case"name":if($)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"value":this.input.value=$||"";break;default:this.input[Q]=$,this.input.setAttribute(Q,$);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#Y(),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(Q){Q.stopPropagation(),this.#Y(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}z("fig-checkbox",Y0);class $1 extends Y0{constructor(){super();this.input.setAttribute("type","radio");let Q=this.getAttribute("name");if(Q)this.input.setAttribute("name",Q);else this.input.removeAttribute("name")}}z("fig-radio",$1);class J1 extends Y0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}z("fig-switch",J1);class j1 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Z=!1;#Q=null;#$=null;#J=null;#j=null;#q=!1;#_=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Y=this.#F.bind(this);#X=this.#z.bind(this);#W=this.#B.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}#N(){return!!this.querySelector(":scope > .input-combo")}#K(){if(this.#Q=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#$=this.querySelector("fig-dropdown"),this.#Q)this.#Q.setAttribute("value",this.value),this.#Q.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#R()}connectedCallback(){if(this.#j=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#Z=this.#j!==null,this.#j)this.#j.remove();if(this.#N())this.#K(),this.#U();else this.#G(),this.#U();this.#P(F(this,"disabled"))}disconnectedCallback(){this.#L()}#G(){let Q=this.#E(),Z=this.getAttribute("placeholder")||"",$=this.value,J=this.#O(),j=this.#Z?"":`<fig-dropdown type="dropdown" label="${v(J)}">${Q.map((q)=>`<option>${v(q.trim())}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
272
+ ${Z==="true"||Z==="picker"?`<div class="fig-input-gradient-track">${this.#T()}</div>`:""}`,this.#Q=this.querySelector("fig-swatch"),this.#Z=this.querySelector(".fig-input-gradient-track"),Z==="true"||Z==="picker")this.#f(),this.#d();this.#K()}#P(){let Q=this.querySelector("fig-fill-picker");if(!Q)return;Q.anchorElement=this;let Z=($)=>{$.stopPropagation();let J=$.detail;if(!J?.gradient)return;this.#_=this.#G({...this.#_,...J.gradient}),this.#h()};Q.addEventListener("input",($)=>{Z($),this.#p()}),Q.addEventListener("change",($)=>{Z($),this.#s()})}#S(Q){return r1(this.#_.stops,Q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#f(){if(!this.#Z||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#W==="tip")Q.setAttribute("tip","add");Q.style.position="absolute",Q.style.top="50%",Q.style.transform="translate(-50%, -50%)",Q.style.pointerEvents="none",Q.style.opacity="0",Q.style.transition="opacity 0.15s",this.#Z.appendChild(Q),this.#H=Q,this.addEventListener("pointerenter",this.#E),this.addEventListener("pointermove",this.#k),this.addEventListener("pointerleave",this.#C),this.addEventListener("click",this.#b),this.addEventListener("dblclick",this.#v)}#I(){if(!this.#H)return;this.#H.style.opacity="1"}#A(){if(!this.#H)return;this.#H.style.opacity="0"}#E=()=>{if(this.#$)return;this.#I()};#C=()=>{this.#A()};#k=(Q)=>{if(this.#$){this.#A();return}if(!this.#H||!this.#Z)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#A();return}let Z=this.#Z.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width));this.#H.style.left=`${$*100}%`;let J=this.#S($);this.#H.setAttribute("color",J),this.#I()};#y(){let Q=this.#_.stops.length;if(Q<2)return;for(let Z=0;Z<Q;Z++)this.#_.stops[Z].position=Math.round(Z/(Q-1)*100);this.#g(),this.#h(),this.#p(),this.#s()}#v=(Q)=>{if(!this.#Z)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#y(),this.#Z.querySelectorAll("fig-handle[selected]").forEach((Z)=>{Z.removeAttribute("selected")})};#b=(Q)=>{if(!this.#Z)return;if(this.#$)return;if(this.#O){this.#O=!1;return}if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(Q.shiftKey){let _=Q.target.closest("fig-handle"),X=parseInt(_?.dataset.stopIndex,10);if(this.#y(),!isNaN(X))this.#Z.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(parseInt(Y.dataset.stopIndex,10)===X)Y.select();else Y.deselect()});Q.stopPropagation()}return}let Z=this.#Z.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#S($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((_,X)=>_.position-X.position);let q=this.#_.stops.findIndex((_)=>_.position===J&&_.color===j);this.#g(),this.#h(),this.#p(),this.#s(),requestAnimationFrame(()=>{let X=this.#Z.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)X.click()})};#w(){if(this.#q=null,!this.isConnected)return;if(!this.#Z)return;let Q=this.#_.stops;this.#Z.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z,$)=>{if($>=Q.length)return;Z.removeAttribute("value"),Z.setAttribute("value",`${Q[$].position}% 50%`)})}refreshLayout(){this.#w()}#V(){if(this.#q!==null)return;this.#q=requestAnimationFrame(()=>this.#w())}#g(){if(!this.#Z)return;let Q=this.#Z.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops;if(Q.length!==Z.length){let $=this.#H;if(this.#Z.innerHTML=this.#T(),$)this.#Z.appendChild($);this.#x(),this.#c(),this.#V();return}for(let $=0;$<Z.length;$++){let J=Q[$],j=Z[$];if(J.dataset.stopIndex=$,J.setAttribute("value",`${j.position}% 50%`),J.setAttribute("color",this.#B(j)),this.#W==="tip")J.setAttribute("tip","color");else J.removeAttribute("tip");let q=J.closest("fig-tooltip");if(q)q.setAttribute("text",`${Math.round(j.position)}%`)}this.#x()}#x(){if(!this.#Z)return;let Q=this.#W==="tip";if(this.#Z.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(Q)Z.setAttribute("tip","color");else Z.removeAttribute("tip")}),this.#H)if(Q)this.#H.setAttribute("tip","add");else this.#H.removeAttribute("tip")}#c(){if(!this.#j||!this.#Z)return;this.#j.disconnect(),this.#Z.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#m(){if(!this.#Z)return;let Q=this.#Z.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops,$=new Set;Q.forEach((J)=>{let j=Math.round(parseFloat(J.getAttribute("value"))||0),q=(J.getAttribute("color")||"").toUpperCase(),_=-1;for(let X=0;X<Z.length;X++){if($.has(X))continue;if(Z[X].position===j&&Z[X].color.toUpperCase()===q){_=X;break}}if(_===-1){let X=1/0;for(let Y=0;Y<Z.length;Y++){if($.has(Y))continue;let K=Math.abs(Z[Y].position-j);if(K<X)X=K,_=Y}}if(_!==-1)$.add(_),J.dataset.stopIndex=_})}#h(){if(!this.#Q)return;this.#Q.setAttribute("background",this.#z()),this.#D()}#d(){if(!this.#Z)return;this.#Z.addEventListener("pointerdown",(Q)=>{if(F(this,"disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let Z=this.#Z.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#S($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((Y,K)=>Y.position-K.position);let q=this.#_.stops.findIndex((Y)=>Y.position===J&&Y.color===j);this.#O=!0,this.#g(),this.#h(),this.#p(),this.#A();let X=this.#Z.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)this.#Z.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(Y!==X)Y.deselect()}),X.select(),X.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:Q.clientX,clientY:Q.clientY,pointerId:Q.pointerId,pointerType:Q.pointerType,button:Q.button,buttons:Q.buttons}))}),this.#Z.addEventListener("input",(Q)=>{let Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt(Z.dataset.stopIndex,10);if(!isNaN(Y)&&this.#_.stops[Y]){if(this.#_.stops[Y].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[Y].opacity=Q.detail.opacity;Z.setAttribute("color",this.#B(this.#_.stops[Y])),this.#h(),this.#p()}return}if(!this.#$)Z.style.zIndex="5";this.#$=!0;let $=parseInt(Z.dataset.stopIndex,10);if(isNaN($)||!this.#_.stops[$])return;let J=Q.detail?.px??0,j=Math.round(J*100),q=j,_=this.#Z.getBoundingClientRect().width;if(Q.detail?.shiftKey)q=Math.round(q/Q0.SHIFT_SNAP)*Q0.SHIFT_SNAP;else{let Y=_>0?5/_*100:0;for(let K=0;K<this.#_.stops.length;K++){if(K===$)continue;if(Math.abs(this.#_.stops[K].position-q)<=Y){q=this.#_.stops[K].position;break}}}if(this.#_.stops[$].position=q,q!==j)Z.style.left=`${q/100*_}px`;let X=Z.closest("fig-tooltip");if(X){if(X.text=`${Math.round(q)}%`,!X.hasAttribute("show"))X.setAttribute("show","true"),Z.hideColorTip()}this.#h(),this.#p()}),this.#Z.addEventListener("change",(Q)=>{let Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt(Z.dataset.stopIndex,10);if(!isNaN(Y)&&this.#_.stops[Y]){if(this.#_.stops[Y].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[Y].opacity=Q.detail.opacity;Z.setAttribute("color",this.#B(this.#_.stops[Y])),this.#h(),this.#s()}return}Z.style.zIndex="";let $=Z.closest("fig-tooltip");if($)$.removeAttribute("show");Z.showColorTip();let J=parseInt(Z.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])return;let j=Q.detail?.px??0,q=Math.round(j*100),_=this.#Z.getBoundingClientRect().width,X=_>0?5/_*100:0;for(let Y=0;Y<this.#_.stops.length;Y++){if(Y===J)continue;if(Math.abs(this.#_.stops[Y].position-q)<=X){q=this.#_.stops[Y].position;break}}this.#_.stops[J].position=q,Z.style.left=`${q/100*_}px`,this.#_.stops.sort((Y,K)=>Y.position-K.position),this.#m(),this.#h(),this.#s(),requestAnimationFrame(()=>{this.#$=!1})}),this.#j=new MutationObserver((Q)=>{for(let Z of Q){if(Z.attributeName!=="color")continue;let $=Z.target;if($.classList.contains("fig-input-gradient-ghost"))continue;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])continue;let j=$.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#_.stops[J].color)this.#_.stops[J].color=j,this.#h(),this.#p()}}),this.#Z.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#p(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#s(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:n0(this.#G(this.#_))}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}focus(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#X){let Z=this.#N();if(Z){Z.focus(Q);return}}HTMLElement.prototype.focus.call(this,Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":this.#F(),this.#h(),this.#g();break;case"disabled":this.#t();break;case"edit":if(this.#R(),this.#X)document.addEventListener("keydown",this.#U);else document.removeEventListener("keydown",this.#U);break;case"mode":this.#x();break;case"size":this.#D();break}}#t(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#K(),this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#Z)for(let Z of this.#Z.querySelectorAll("fig-handle"))if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}z("fig-input-gradient",Q0);class Y0 extends HTMLElement{#Q=null;#Z;#$;#J;#j=!1;constructor(){super();if(this.input=document.createElement("input"),this.name=this.getAttribute("name")||"",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",h()),this.name)this.input.setAttribute("name",this.name);this.input.setAttribute("type","checkbox"),this.#Z=this.handleInput.bind(this),this.#$=this.handleChange.bind(this),this.#J=(Q)=>{if(Q.target!==this||this.input.disabled)return;this.input.click()}}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("input",this.#Z),this.input.addEventListener("input",this.#Z),this.input.removeEventListener("change",this.#$),this.input.addEventListener("change",this.#$),this.removeEventListener("click",this.#J),this.addEventListener("click",this.#J),this.#X();let Z=this.querySelector(":scope > label");if(Z)this.#Q=Z,this.#j=!1,this.#Q.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#q(),this.#Q.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"]}#q(){if(!this.#Q)this.#Q=document.createElement("label"),this.#j=!0,this.#Q.setAttribute("for",this.input.id);if(this.#Q&&!this.#Q.parentNode&&this.input.parentNode)this.input.after(this.#Q)}render(){}#_(Q){return this.hasAttribute(Q)&&this.getAttribute(Q)!=="false"}#Y(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#X(){let Q=this.#_("checked"),Z=this.#_("indeterminate")&&!Q,$=this.#_("disabled");this.input.checked=Q,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.#Y()}focus(){this.input.focus()}get value(){return this.input.value}set value(Q){this.input.value=Q,this.setAttribute("value",Q)}get checked(){return this.input.checked}set checked(Q){if(this.input.checked=Q,Q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("input",this.#Z),this.input.removeEventListener("change",this.#$),this.removeEventListener("click",this.#J)}attributeChangedCallback(Q,Z,$){switch(Q){case"label":if($)this.#q(),this.#Q.innerText=$;else if(this.#Q&&this.#j)this.#Q.remove(),this.#Q=null,this.#j=!1;break;case"checked":if(this.#_("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#X();break;case"indeterminate":this.#X();break;case"disabled":this.#X();break;case"name":if($)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"value":this.input.value=$||"";break;default:this.input[Q]=$,this.input.setAttribute(Q,$);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#Y(),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(Q){Q.stopPropagation(),this.#Y(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}z("fig-checkbox",Y0);class $1 extends Y0{constructor(){super();this.input.setAttribute("type","radio");let Q=this.getAttribute("name");if(Q)this.input.setAttribute("name",Q);else this.input.removeAttribute("name")}}z("fig-radio",$1);class J1 extends Y0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}z("fig-switch",J1);class j1 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Q=!1;#Z=null;#$=null;#J=null;#j=null;#q=!1;#_=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Y=this.#F.bind(this);#X=this.#z.bind(this);#W=this.#B.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}#N(){return!!this.querySelector(":scope > .input-combo")}#K(){if(this.#Z=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#$=this.querySelector("fig-dropdown"),this.#Z)this.#Z.setAttribute("value",this.value),this.#Z.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#R()}connectedCallback(){if(this.#j=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#Q=this.#j!==null,this.#j)this.#j.remove();if(this.#N())this.#K(),this.#U();else this.#G(),this.#U();this.#P(F(this,"disabled"))}disconnectedCallback(){this.#L()}#G(){let Q=this.#T(),Z=this.getAttribute("placeholder")||"",$=this.value,J=this.#O(),j=this.#Q?"":`<fig-dropdown type="dropdown" label="${v(J)}">${Q.map((q)=>`<option>${v(q.trim())}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
273
273
  <fig-input-text placeholder="${v(Z)}" value="${v($)}"></fig-input-text>
274
274
  <fig-button type="select" variant="input" icon>
275
275
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -277,7 +277,7 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
277
277
  </svg>
278
278
  ${j}
279
279
  </fig-button>
280
- </div>`,this.#Q=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#Z&&this.#j&&this.#J){if(!this.#j.hasAttribute("type"))this.#j.setAttribute("type","dropdown");if(!this.#j.hasAttribute("label"))this.#j.setAttribute("label",J);this.#J.append(this.#j)}this.#$=this.querySelector("fig-dropdown"),this.#R()}#U(){this.#L(),this.#$?.addEventListener("input",this.#Y),this.#Q?.addEventListener("input",this.#X),this.#Q?.addEventListener("change",this.#W)}#L(){this.#$?.removeEventListener("input",this.#Y),this.#Q?.removeEventListener("input",this.#X),this.#Q?.removeEventListener("change",this.#W)}#F(Q){Q.stopPropagation();let Z=Q.target.closest("fig-dropdown")?.value??"";if(this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#Q)this.#Q.setAttribute("value",Z);this.#M(),this.#D()}#z(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#M()}#B(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#D()}#M(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#D(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#E(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#H(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#O(){return`${this.#H()} options`}#R(){if(this.#Q)this.#_.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,Z)});if(this.#$&&!this.#$.hasAttribute("aria-label"))this.#$.setAttribute("label",this.#O())}#P(Q){if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}focus(){this.#Q?.focus()}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"options":if(this.#$&&!this.#Z){let J=this.#E();this.#$.replaceChildren(...J.map((j)=>{let q=document.createElement("option");return q.textContent=j,q}))}break;case"placeholder":if(this.#Q)this.#Q.setAttribute("placeholder",$||"");this.#R();break;case"value":if(!this.#q&&this.#Q)this.#Q.setAttribute("value",$||"");break;case"disabled":this.#P($!==null&&$!=="false");break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#R();break}}}z("fig-combo-input",j1);class q1 extends HTMLElement{#Z="color";#Q=null;#$=!1;constructor(){super();this.#Q=this.#W.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#Y(),this.#J(),this.#X()}#J(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#j(Q){if(!Q)return"color";let Z=Q.toLowerCase();if(Z.includes("gradient"))return"gradient";if(Z.includes("url("))return"image";return"color"}#q(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:Z}=O0(1,1);return Z.fillStyle=Q,Z.fillStyle}catch{return"#D9D9D9"}}#_(Q){if(!Q||!Q.includes("var("))return Q;let Z=this.style.background;this.style.background=Q;let $=getComputedStyle(this),J=$.backgroundImage,j=$.backgroundColor;if(this.style.background=Z,J&&J!=="none")return J;return j||Q}#Y(){let Q=this.getAttribute("background")||"#D9D9D9",Z=Q.includes("var("),$=Z?this.#_(Q):Q,J=this.#j($);if(J!==this.#Z||!this.input){if(this.#Z=J,this.setAttribute("data-type",this.#Z),this.input)this.input.removeEventListener("input",this.#Q);if(this.#Z==="color"){let q=this.#q($);if(this.innerHTML=`<div></div><input type="color" value="${q}" />`,this.input=this.querySelector("input"),!Z)this.input.addEventListener("input",this.#Q);this.#X()}else this.innerHTML="<div></div>",this.input=null,this.#X()}else if(this.#Z==="color"&&this.input){let q=this.#q($);if(this.input.value!==q)this.input.value=q}let j=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Q);this.style.setProperty("--swatch-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#X(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",Q?"true":"false"),this.input){this.input.disabled=Q;let Z=this.getAttribute("aria-labelledby"),$=this.getAttribute("aria-label")||"Color swatch",J=this.getAttribute("aria-describedby");if(Z)this.input.setAttribute("aria-labelledby",Z),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",$),this.input.removeAttribute("aria-labelledby");if(J)this.input.setAttribute("aria-describedby",J);else this.input.removeAttribute("aria-describedby");this.removeAttribute("role"),this.removeAttribute("aria-hidden");return}if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-hidden","true");else this.setAttribute("role","img"),this.removeAttribute("aria-hidden")}#W(Q){this.#$=!0,this.setAttribute("background",Q.target.value),this.#$=!1}get background(){return this.getAttribute("background")}set background(Q){this.setAttribute("background",Q)}focus(){this.input?.focus()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="background"){if(this.#$){let J=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--swatch-background",J?$:`linear-gradient(${$}, ${$})`);return}this.#Y()}else if(Q==="alpha")this.#J();else if(Q==="disabled"||Q==="aria-label"||Q==="aria-labelledby"||Q==="aria-describedby")this.#X()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",Q)}}z("fig-swatch",q1);class K0 extends HTMLElement{#Z=null;#Q=null;#$=null;#J=null;#j=null;#q=null;#_=null;#Y=this.#u.bind(this);#X=this.#v.bind(this);#W=this.#d.bind(this);#N=this.#p.bind(this);#K=null;#G=null;#U=null;#L=null;#F=null;#z=null;#B=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","caption","controls","autoplay","loop","muted","poster","aria-label","aria-labelledby","title"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#Z}set src(Q){if(this.#Z=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#_}#M(){return this.#q||this.#Z||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#M())return null;if(!this.#Q)return null;try{if(typeof this.#Q.decode==="function")await this.#Q.decode();else if(!this.#Q.complete)await new Promise((J,j)=>{this.#Q.addEventListener("load",J,{once:!0}),this.#Q.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Q.naturalWidth,Z=this.#Q.naturalHeight;if(!(Q>0)||!(Z>0))return null;let $=document.createElement("canvas");return $.width=Q,$.height=Z,$.getContext("2d").drawImage(this.#Q,0,0),$.toDataURL()}connectedCallback(){this.#Z=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--fig-media-aspect-ratio",Q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let Z=this.getAttribute("fit");if(Z)this.style.setProperty("--fig-media-fit",Z);if(this.querySelectorAll("fig-swatch[data-generated]").forEach((J)=>J.remove()),this.#H(),this.#R(),this.#E(),this.#k(),this.#P(),this.#I(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#b();this.#J=this.querySelector("fig-input-file[data-generated]"),this.#J?.removeEventListener("change",this.#Y),this.#J?.addEventListener("change",this.#Y)}disconnectedCallback(){if(this.#J?.removeEventListener("change",this.#Y),this.#D(),this.#V(),this.#j)URL.revokeObjectURL(this.#j),this.#j=null;this.#q=null}#D(){if(!this.#Q)return;if(this.#Q.tagName==="VIDEO")this.#Q.removeEventListener("play",this.#X),this.#Q.removeEventListener("pause",this.#W),this.#Q.removeEventListener("ended",this.#N)}#E(){if(this.#D(),this.#Q?.tagName!=="VIDEO")return;this.#Q.addEventListener("play",this.#X),this.#Q.addEventListener("pause",this.#W),this.#Q.addEventListener("ended",this.#N)}#H(){if(this.#$?.isConnected)return;let Q=this.querySelector(":scope > fig-preview");if(Q){this.#$=Q;return}let Z=document.createElement("fig-preview");Z.setAttribute("data-generated",""),this.prepend(Z),this.#$=Z}#O(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#R(){let Q=this.#O();if(Q){if(this.#H(),this.#Q&&this.#Q!==Q){if(this.#D(),this.#Q.hasAttribute("data-generated"))this.#Q.remove()}if(this.#Q=Q,this.#$&&Q.parentElement!==this.#$)this.#$.append(Q);this.#P();return}this.#H();let Z=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Q&&this.#Q.tagName!==Z){if(this.#D(),this.#Q.hasAttribute("data-generated"))this.#Q.remove();this.#Q=null}if(this.#Q)return;if(this.mediaKind==="video"){let $=document.createElement("video");$.setAttribute("data-generated",""),$.className="fig-media-element",$.setAttribute("playsinline",""),$.preload="auto",this.#$.append($),this.#Q=$,this.#E();let J=()=>{if(this.#Q?.autoplay)return;try{this.#Q.currentTime=0.001}catch{}};this.#Q.addEventListener("loadedmetadata",J,{once:!0})}else{let $=document.createElement("img");$.setAttribute("data-generated",""),$.className="fig-media-element",$.loading="lazy",$.decoding="async",$.alt=this.getAttribute("alt")||"",this.#$.append($),this.#Q=$}}#P(){if(!this.#Q)return;if(this.#Q.tagName==="IMG"){if(this.hasAttribute("alt")||this.#Q.hasAttribute("data-generated"))this.#Q.alt=this.getAttribute("alt")||"";return}if(this.#Q.tagName!=="VIDEO")return;["aria-label","aria-labelledby","title"].forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,Z)})}#C(){return this.querySelector(":scope > figcaption:not([data-generated])")}#S(){return Array.from(this.querySelectorAll(":scope > figcaption[data-generated]"))}#I(){let Q=this.#C(),Z=this.#S();if(Q){Z.forEach((q)=>q.remove());return}let $=this.getAttribute("caption")||"";if(!$){Z.forEach((q)=>q.remove());return}let J=Z[0]||document.createElement("figcaption");if(Z.slice(1).forEach((q)=>q.remove()),!J.hasAttribute("data-generated"))J.setAttribute("data-generated","");if(J.textContent!==$)J.textContent=$;let j=this.querySelector(":scope > fig-media-controls");if(j)j.before(J);else if(this.#$?.isConnected)this.#$.after(J);else if(!J.isConnected)this.append(J)}#A(Q,Z=!1){if(!this.hasAttribute(Q))return Z;return this.getAttribute(Q)!=="false"}#k(){if(!this.#Q)return;if(!this.#Q.hasAttribute("data-generated"))return;let Q=this.#M();if(this.#Q.getAttribute("src")!==Q){if(Q)this.#Q.setAttribute("src",Q);else if(this.#Q.removeAttribute("src"),this.#Q.tagName==="VIDEO")this.#Q.load()}if(this.#Q.tagName==="IMG"){this.#P();return}let Z=this.getAttribute("poster");if(Z)this.#Q.setAttribute("poster",Z);else this.#Q.removeAttribute("poster");this.#Q.controls=!1,this.#Q.removeAttribute("controls"),this.#Q.autoplay=this.#A("autoplay",!1),this.#Q.loop=this.#A("loop",!1),this.#Q.muted=this.#A("muted",!1),this.#Q.playsInline=!0,this.#P(),this.#y(),this.#f()}get mediaEl(){return this.#Q}#T(){if(this.mediaKind!=="video")return!1;return Boolean(this.#M())}#f(){let Q=this.#K||this.querySelector(":scope > fig-media-controls");if(!Q)return;if(this.mediaKind!=="video")return;if(this.#T()){if(Q.hasAttribute("data-fig-empty-disabled"))Q.removeAttribute("disabled"),Q.removeAttribute("data-fig-empty-disabled");return}Q.setAttribute("disabled",""),Q.setAttribute("data-fig-empty-disabled",""),Q.playing=!1,Q.time=0,Q.duration=0}#y(){if(this.mediaKind!=="video"){this.#V();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#K!==Q)this.#V(),this.#K=Q;this.#h(),this.#f();return}if(this.#A("controls",!1))this.#g();else this.#V()}#g(){let Q=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Z=Q[0];if(Q.slice(1).forEach((J)=>J.remove()),Z){this.#K=Z,this.#h(),this.#f();return}let $=document.createElement("fig-media-controls");$.setAttribute("data-generated",""),this.append($),this.#K=$,this.#h(),this.#f()}#h(){if(!this.#K||!this.#Q)return;if(this.#G===this.#Q&&this.#U===this.#K){this.#f();return}this.#w();let Q=this.#K,Z=this.#Q;this.#G=Z,this.#U=Q;let $=null,J=()=>{if(this.#f(),!this.#T())return;if(Q.playing=!Z.paused&&!Z.ended,Number.isFinite(Z.duration))Q.duration=Z.duration;if($!==null)if(Math.abs(Z.currentTime-$)<0.25)$=null;else return;Q.time=Z.currentTime||0},j=()=>{if(!this.#T())return;let X=Z.play?.();if(X&&typeof X.catch==="function")X.catch(()=>{})},q=()=>Z.pause?.(),_=(X)=>{if(!this.#T())return;let Y=Number(X?.detail?.time);if(!Number.isFinite(Y))return;$=Y;try{Z.currentTime=Y}catch{}};this.#L=J,this.#F=j,this.#z=q,this.#B=_,Z.addEventListener("play",J),Z.addEventListener("pause",J),Z.addEventListener("ended",J),Z.addEventListener("timeupdate",J),Z.addEventListener("loadedmetadata",J),Z.addEventListener("durationchange",J),Z.addEventListener("seeked",J),Q.addEventListener("play",j),Q.addEventListener("pause",q),Q.addEventListener("seek",_),J()}#w(){let Q=this.#G,Z=this.#U;if(Q&&this.#L)Q.removeEventListener("play",this.#L),Q.removeEventListener("pause",this.#L),Q.removeEventListener("ended",this.#L),Q.removeEventListener("timeupdate",this.#L),Q.removeEventListener("loadedmetadata",this.#L),Q.removeEventListener("durationchange",this.#L),Q.removeEventListener("seeked",this.#L);if(Z){if(this.#F)Z.removeEventListener("play",this.#F);if(this.#z)Z.removeEventListener("pause",this.#z);if(this.#B)Z.removeEventListener("seek",this.#B)}this.#G=null,this.#U=null,this.#L=null,this.#F=null,this.#z=null,this.#B=null}#V(){this.#w(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((Q)=>{Q.remove()}),this.#K=null}toggle(){if(!this.#Q||this.mediaKind!=="video")return;if(this.#Q.paused||this.#Q.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Q)return;let Q=this.#Q.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Q)return;this.#Q.pause()}#b(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let Z=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#Z?"Replace":Z),this.#_?.name)Q.setAttribute("filename",this.#_.name);else if(this.#Z)Q.setAttribute("url",this.#Z);Q.addEventListener("change",this.#Y),this.#H(),this.#$.append(Q),this.#J=Q}#x(){if(this.#J)this.#J.removeEventListener("change",this.#Y),this.#J.remove(),this.#J=null}#u(Q){if(Q.target!==this.#J)return;let Z=Q.detail?.files?.[0],$=Q.detail?.cleared===!0;if(!Z){if(this.#j)URL.revokeObjectURL(this.#j),this.#j=null;if(this.#_=null,this.#q=null,$)this.src="";if(this.#k(),this.#J){let J=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#Z?"Replace":J),this.#J.removeAttribute("filename"),this.#Z)this.#J.setAttribute("url",this.#Z);else this.#J.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#j)URL.revokeObjectURL(this.#j);if(this.#_=Z,this.#j=URL.createObjectURL(Z),this.#q=this.#j,this.#k(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Z,src:this.#j}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#J)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",Z.name),this.#J.setAttribute("label","Replace")}#m(Q){if(!this.#Q)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Z||"",currentTime:this.#Q.currentTime,duration:this.#Q.duration}}))}#v(){this.#m("play")}#d(){this.#m("pause")}#p(){this.#m("ended")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="src"){let J=$||"",j=J&&(J===this.#q||J===this.#j);if(this.#Z=J,this.#j&&!j)URL.revokeObjectURL(this.#j),this.#j=null,this.#q=null,this.#_=null;if(this.#k(),this.#J){let q=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#Z?"Replace":q),this.#Z)if(this.#_?.name)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",this.#_.name);else this.#J.setAttribute("url",this.#Z),this.#J.removeAttribute("filename");else this.#J.removeAttribute("url"),this.#J.removeAttribute("filename")}}if(Q==="type"){if(this.#R(),this.#k(),this.#J)this.#J.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(Q))this.#P();if(Q==="upload"){let J=$!==null&&$!=="false";if(J&&!this.#J)this.#b();else if(!J)this.#x()}if(Q==="aspect-ratio")if($)this.style.setProperty("--fig-media-aspect-ratio",$);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if($)this.style.setProperty("--fig-media-fit",$);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#J){let J=this.getAttribute("label")||"Upload";this.#J.setAttribute("label",this.#Z?"Replace":J)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#k();if(Q==="caption")this.#I()}}z("fig-media",K0);class _1 extends K0{get mediaKind(){return"image"}}z("fig-image",_1);class X1 extends K0{get mediaKind(){return"video"}}z("fig-video",X1);class Y1 extends HTMLElement{static get observedAttributes(){return["src","alt","label","text","sublabel","href","target","selected","disabled","full","aspect-ratio","fit","label-line-clamp"]}#Z=null;#Q=null;#$=null;#J=null;#j=null;#q=null;#_=!1;connectedCallback(){this.#G(),this.#U()}attributeChangedCallback(){if(!this.isConnected)return;this.#G(),this.#U()}#Y(){return this.getAttribute("label")??this.getAttribute("text")??""}#X(){return this.getAttribute("sublabel")??""}#W(){let Q=this.getAttribute("href");return Boolean(Q)&&!F(this,"disabled")}#N(){return this.getAttribute("label-line-clamp")==="2"?"2":"1"}#K(){return this.querySelector(":scope > fig-image:not([data-generated]), :scope > fig-media:not([data-generated]), :scope > fig-preview:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-image:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-media:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-preview:not([data-generated])")}#G(){let Q=this.#K();this.#_=Boolean(Q);let $=this.#W()?"a":"div";if(!this.#Z||this.#Z.tagName.toLowerCase()!==$){let J=document.createElement($);if(J.className="fig-card-link",this.#Z){while(this.#Z.firstChild)J.appendChild(this.#Z.firstChild);this.#Z.replaceWith(J)}else this.appendChild(J);this.#Z=J}if(!this.#Q||!this.#Q.isConnected){if(this.#Q=this.#Z.querySelector(":scope > .fig-card-media"),!this.#Q)this.#Q=document.createElement("div"),this.#Q.className="fig-card-media",this.#Z.prepend(this.#Q)}if(Q&&Q.parentElement!==this.#Q)this.#Q.querySelectorAll("[data-generated]").forEach((J)=>J.remove()),this.#Q.appendChild(Q),this.#J=null;if(!this.#_){if(this.#J=this.#Q.querySelector(":scope > fig-image[data-generated]")||null,!this.#J)this.#Q.querySelectorAll(":scope > fig-image, :scope > fig-media, :scope > fig-preview").forEach((J)=>{if(J.hasAttribute("data-generated"))J.remove()}),this.#J=document.createElement("fig-image"),this.#J.setAttribute("data-generated",""),this.#J.setAttribute("full",""),this.#J.setAttribute("size","auto"),this.#Q.appendChild(this.#J)}if(!this.#$||!this.#$.isConnected){if(this.#$=this.#Z.querySelector(":scope > .fig-card-text"),!this.#$)this.#$=document.createElement("div"),this.#$.className="fig-card-text",this.#$.setAttribute("data-generated",""),this.#Z.appendChild(this.#$)}if(!this.#j||!this.#j.isConnected){if(this.#j=this.#$.querySelector(":scope > .fig-card-label[data-generated]"),!this.#j){if(this.#j=this.#Z.querySelector(":scope > .fig-card-label[data-generated]")||null,!this.#j)this.#j=document.createElement("label"),this.#j.className="fig-card-label",this.#j.setAttribute("data-generated","");this.#$.appendChild(this.#j)}}if(!this.#q||!this.#q.isConnected){if(this.#q=this.#$.querySelector(":scope > .fig-card-sublabel[data-generated]"),!this.#q){if(this.#q=this.#Z.querySelector(":scope > .fig-card-sublabel[data-generated]")||null,!this.#q)this.#q=document.createElement("span"),this.#q.className="fig-card-sublabel",this.#q.setAttribute("data-generated","");this.#j.after(this.#q)}}}#U(){if(!this.#Z)return;let Q=F(this,"disabled"),Z=F(this,"selected"),$=this.#Y(),J=this.#X(),j=this.#N();if(this.style.setProperty("--fig-card-label-line-clamp",j),this.#W()){let q=this.getAttribute("href")||"",_=this.getAttribute("target");if(this.#Z.setAttribute("href",q),_)if(this.#Z.setAttribute("target",_),_==="_blank")this.#Z.setAttribute("rel","noopener noreferrer");else this.#Z.removeAttribute("rel");else this.#Z.removeAttribute("target"),this.#Z.removeAttribute("rel");if(Z)this.#Z.setAttribute("aria-current","true");else this.#Z.removeAttribute("aria-current");this.removeAttribute("role"),this.removeAttribute("aria-label")}else{this.#Z.removeAttribute("href"),this.#Z.removeAttribute("target"),this.#Z.removeAttribute("rel"),this.#Z.removeAttribute("aria-current"),this.setAttribute("role","group");let q=[$,J].filter(Boolean).join(", ");if(q)this.setAttribute("aria-label",q);else this.removeAttribute("aria-label")}if(Q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#J&&!this.#_){let q=this.getAttribute("src"),_=this.getAttribute("alt"),X=this.getAttribute("aspect-ratio")||"1/1",Y=this.getAttribute("fit")||"contain",K=_!=null?_:"";if(q)this.#J.setAttribute("src",q);else this.#J.removeAttribute("src");this.#J.setAttribute("alt",K),this.#J.setAttribute("aspect-ratio",X),this.#J.setAttribute("fit",Y),this.#J.setAttribute("full",""),this.#J.setAttribute("size","auto")}if(this.#j)this.#j.textContent=$,this.#j.hidden=!$;if(this.#q)this.#q.textContent=J,this.#q.hidden=!J;if(this.#$)this.#$.hidden=!$&&!J}}z("fig-card",Y1);class K1 extends HTMLElement{#Z=null;#Q=null;#$=null;#J=null;#j=!1;#q=!1;static get observedAttributes(){return["playing","duration","time","disabled"]}connectedCallback(){this.#_(),this.#N(),this.#K(),this.#Y()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let Q=Number(this.getAttribute("duration"));return Number.isFinite(Q)&&Q>=0?Q:0}set duration(Q){let Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("duration");return}this.setAttribute("duration",String(Z))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("time");return}this.setAttribute("time",String(Z))}get disabled(){return F(this,"disabled")}set disabled(Q){if(Q)this.setAttribute("disabled","");else this.removeAttribute("disabled")}attributeChangedCallback(Q){if(!this.#q)return;if(Q==="playing")this.#N();if(Q==="duration"||Q==="time")this.#K();if(Q==="disabled")this.#Y()}#_(){if(this.#q)return;if(this.#q=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Play");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("size","small"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Play");let $=u("play",{className:"fig-media-controls-play-icon"});Z.append($),Q.append(Z),Z.addEventListener("click",(_)=>{_.preventDefault(),_.stopPropagation(),this.toggle()});let J=document.createElement("fig-slider");J.setAttribute("text","false"),J.setAttribute("min","0"),J.setAttribute("max",String(this.duration)),J.setAttribute("step","1"),J.setAttribute("value",String(this.time)),J.setAttribute("full",""),J.setAttribute("aria-label","Seek"),J.setAttribute("aria-valuetext",this.#W(this.time,this.duration));let j=document.createElement("span");j.className="fig-media-controls-time",j.textContent=this.#X(this.time);let q=(_)=>{if(this.disabled){_.preventDefault?.(),_.stopPropagation();return}let X=_.currentTarget,Y=Number(X?.value);if(!Number.isFinite(Y))return;this.#j=!0,this.setAttribute("time",String(Y)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:Y}})),requestAnimationFrame(()=>{this.#j=!1})};J.addEventListener("input",q),J.addEventListener("change",q),this.append(Q,J,j),this.#Z=Z,this.#Q=Q,this.#$=J,this.#J=j,this.#Y()}#Y(){let Q=this.disabled;if(this.setAttribute("aria-disabled",Q?"true":"false"),this.#Z)if(Q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}#X(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let Z=Math.floor(Q),$=Math.floor(Z/60),J=Z%60;return`${String($).padStart(2,"0")}:${String(J).padStart(2,"0")}`}#W(Q,Z=0){let $=this.#X(Q);if(!Number.isFinite(Z)||Z<=0)return $;return`${$} of ${this.#X(Z)}`}#N(){if(!this.#Z)return;let Q=this.playing;this.#Z.setAttribute("aria-label",Q?"Pause":"Play"),this.#Q?.setAttribute("text",Q?"Pause":"Play");let Z=this.#Z.querySelector(".fig-media-controls-play-icon");if(Z)Z.setAttribute("name",Q?"pause":"play")}#K(){if(!this.#$)return;let Q=this.duration;if(Number(this.#$.getAttribute("max"))!==Q)this.#$.setAttribute("max",String(Q));let Z=this.time;if(!this.#j)this.#$.setAttribute("value",String(Z));if(this.#$.setAttribute("aria-valuetext",this.#W(Z,Q)),this.#J)this.#J.textContent=this.#X(Z)}toggle(){if(this.disabled)return;let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.disabled||this.playing)return;this.toggle()}pause(){if(this.disabled||!this.playing)return;this.toggle()}}z("fig-media-controls",K1);class G1 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#Z=null;#Q=null;#$=null;#J=null;#j=null;#q=null;get files(){return this.#q}get#_(){let Q=this.getAttribute("filename");if(Q)return Q;let Z=this.getAttribute("url");if(!Z)return"";try{let J=new URL(Z,location.href).pathname.split("/").pop();return J?decodeURIComponent(J):Z}catch{return Z}}get value(){if(this.#q&&this.#q.length>0){if(this.#q.length===1)return this.#q[0].name;return`${this.#q.length} files`}return this.#_}connectedCallback(){this.#U(),this.addEventListener("dragover",this.#N),this.addEventListener("dragleave",this.#K),this.addEventListener("drop",this.#G)}disconnectedCallback(){this.#Z?.removeEventListener("change",this.#X),this.#$?.removeEventListener("click",this.#W),this.removeEventListener("dragover",this.#N),this.removeEventListener("dragleave",this.#K),this.removeEventListener("drop",this.#G)}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#U()}clear(){if(this.#q=null,this.#Z)this.#Z.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#U(),this.#Y({cleared:!0})}#Y(Q={}){let Z={files:this.#q,...Q};this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0}))}#X=()=>{if(this.#Z.files.length>0)this.#q=this.#Z.files,this.removeAttribute("url"),this.#U(),this.#Y()};#W=(Q)=>{Q.stopPropagation(),this.clear()};#N=(Q)=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#j)this.#j.dataset.prevText=this.#j.textContent,this.#j.textContent="Drop file"}};#K=()=>{if(this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText};#G=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.getAttribute("accepts"),$=Array.from(Q.dataTransfer.files);if(Z){let j=Z.split(",").map((q)=>q.trim().toLowerCase());$=$.filter((q)=>{let _="."+q.name.split(".").pop().toLowerCase(),X=q.type.toLowerCase();return j.some((Y)=>Y===_||Y===X||Y.endsWith("/*")&&X.startsWith(Y.slice(0,-1)))})}if(!this.hasAttribute("multiple")||this.getAttribute("multiple")==="false")$=$.slice(0,1);if($.length===0)return;let J=new DataTransfer;if($.forEach((j)=>J.items.add(j)),this.#q=J.files,this.#Z)this.#Z.files=J.files;this.removeAttribute("url"),this.#U(),this.#Y()};#U(){let Q=this.getAttribute("accepts")||"",Z=this.getAttribute("label")||"Upload",$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.hasAttribute("multiple")&&this.getAttribute("multiple")!=="false",j=this.getAttribute("variant")||"input",q=this.#q&&this.#q.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",q){let _=Q?`Accepts ${Q.split(",").map((N)=>N.trim()).join(", ")}`:"";if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.className="fig-input-file-filename",$)this.#j.setAttribute("disabled","");let X=document.createElement("fig-truncate");X.setAttribute("position","middle"),X.setAttribute("tooltip","");let Y=this.value,K=Y.lastIndexOf(".");if(K>0)X.setAttribute("tail",Y.slice(K));if(X.textContent=Y,this.#j.appendChild(X),this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",this.#Z.disabled=$,Q)this.#Z.setAttribute("accept",Q);if(J)this.#Z.setAttribute("multiple","");if(this.#Z.addEventListener("change",this.#X),this.#j.appendChild(this.#Z),_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_),this.#J.appendChild(this.#j),this.appendChild(this.#J);else this.appendChild(this.#j);let G=document.createElement("fig-tooltip");if(G.setAttribute("text","Remove"),this.#$=document.createElement("fig-button"),this.#$.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#$.setAttribute("icon","true"),this.#$.setAttribute("aria-label","Remove"),this.#$.className="fig-input-file-clear",$)this.#$.setAttribute("disabled","");this.#$.replaceChildren(u("minus")),this.#$.addEventListener("click",this.#W),G.appendChild(this.#$),this.appendChild(G)}else{let _=Q?`Accepts ${Q.split(",").map((X)=>X.trim()).join(", ")}`:"";if(_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_);if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.textContent=Z,$)this.#j.setAttribute("disabled","");if(this.#Z=document.createElement("input"),this.#Z.type="file",this.#Z.title="",this.#Z.disabled=$,Q)this.#Z.setAttribute("accept",Q);if(J)this.#Z.setAttribute("multiple","");if(this.#Z.addEventListener("change",this.#X),this.#j.appendChild(this.#Z),this.#J)this.#J.appendChild(this.#j),this.appendChild(this.#J);else this.appendChild(this.#j)}}}z("fig-input-file",G1);class w extends HTMLElement{#Z={x:0.42,y:0};#Q={x:0.58,y:1};#$={stiffness:200,damping:15,mass:1};#J="bezier";#j=2;#q=null;#_=null;#Y=null;#X=null;#W=null;#N=null;#K=null;#G=null;#U=null;#L=null;#F=null;#z=0.8;#B=200;#M=200;#D=null;#E=null;#H=null;#O=null;#R=5;#P=10;#C=10;#S=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#j=parseInt(this.getAttribute("precision")||"2"),b(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#I(Q);this.#L=this.#A(),this.#y(),this.#m()}disconnectedCallback(){if(this.#q=null,this.#O)this.#O.disconnect(),this.#O=null}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="aspect-ratio"){if(b(this,"--aspect-ratio",$),this.#_)this.#v(),this.#c();return}if(Q==="edit"){if(this.isConnected)this.#y();return}if(Q==="value"&&$){let J=this.#J;if(this.#I($),this.#L=this.#A(),J!==this.#J&&this.#f())this.#y();else{if(this.#_)this.#c();this.#e(),this.#l()}}if(Q==="precision")this.#j=parseInt($||"2")}get value(){if(this.#J==="spring"){let{stiffness:Z,damping:$,mass:J}=this.#$;return`spring(${Z}, ${$}, ${J})`}let Q=this.#j;return`${this.#Z.x.toFixed(Q)}, ${this.#Z.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}`}get cssValue(){if(this.#J==="spring"){let Z=this.#k(),$=20,J=Math.max(1,Math.floor(Z.length/20)),j=[];for(let q=0;q<Z.length;q+=J)j.push(Z[q].value.toFixed(3));if(Z.length>0)j.push(Z[Z.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#j;return`cubic-bezier(${this.#Z.x.toFixed(Q)}, ${this.#Z.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)})`}get preset(){return this.#L}set value(Q){this.setAttribute("value",Q)}#I(Q){let Z=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if(Z)return this.#J="spring",this.#$.stiffness=parseFloat(Z[1]),this.#$.damping=parseFloat(Z[2]),this.#$.mass=parseFloat(Z[3]),!0;let $=Q.split(",").map((J)=>parseFloat(J.trim()));if($.length>=4&&$.every((J)=>!isNaN(J)))return this.#J="bezier",this.#Z.x=$[0],this.#Z.y=$[1],this.#Q.x=$[2],this.#Q.y=$[3],!0;return!1}#A(){if(this.#J==="bezier"){for(let Z of w.PRESETS){if(Z.type!=="bezier"||!Z.value)continue;if(Math.abs(this.#Z.x-Z.value[0])<0.001&&Math.abs(this.#Z.y-Z.value[1])<0.001&&Math.abs(this.#Q.x-Z.value[2])<0.001&&Math.abs(this.#Q.y-Z.value[3])<0.001)return Z.name}return"Custom bezier"}for(let Z of w.PRESETS){if(Z.type!=="spring"||!Z.spring)continue;if(Math.abs(this.#$.stiffness-Z.spring.stiffness)<0.001&&Math.abs(this.#$.damping-Z.spring.damping)<0.001&&Math.abs(this.#$.mass-Z.spring.mass)<0.001)return Z.name}return"Custom spring"}#k(){let{stiffness:Q,damping:Z,mass:$}=this.#$,J=0.004,j=5,q=[],_=0,X=0;for(let Y=0;Y<=5;Y+=0.004){let K=-Q*(_-1)-Z*X;if(X+=K/$*0.004,_+=X*0.004,q.push({t:Y,value:_}),Y>0.1&&Math.abs(_-1)<0.0005&&Math.abs(X)<0.0005)break}return q}static#T(Q,Z=24){let{stiffness:$,damping:J,mass:j}=Q,q=0.004,_=5,X=[],Y=0,K=0;for(let A=0;A<=5;A+=0.004){let M=-$*(Y-1)-J*K;if(K+=M/j*0.004,Y+=K*0.004,X.push({t:A,value:Y}),A>0.1&&Math.abs(Y-1)<0.001&&Math.abs(K)<0.001)break}let G=X[X.length-1].t||1,N=1;for(let A of X)if(A.value>N)N=A.value;let W=0;for(let A of X)if(A.value<W)W=A.value;let O=Math.max(N-W,1),B=6,L=Z-B*2,T=Math.max(1,Math.floor(X.length/30)),R="";for(let A=0;A<X.length;A+=T){let M=B+X[A].t/G*L,E=B+(1-(X[A].value-W)/O)*L;R+=(A===0?"M":"L")+M.toFixed(1)+","+E.toFixed(1)}return`<svg width="${Z}" height="${Z}" viewBox="0 0 ${Z} ${Z}" fill="none"><path d="${R}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,Z,$,J,j=24){let _=(j-12)/2,X=48,Y=[],K=(M,E,k,S,x)=>{let y=1-x;return y*y*y*M+3*y*y*x*E+3*y*x*x*k+x*x*x*S};for(let M=0;M<=48;M++){let E=M/48;Y.push({x:K(0,Q,$,1,E),y:K(0,Z,J,1,E)})}let G=1/0,N=-1/0,W=1/0,O=-1/0;for(let M of Y){if(M.x<G)G=M.x;if(M.x>N)N=M.x;if(M.y<W)W=M.y;if(M.y>O)O=M.y}let B=Math.max(N-G,0.000001),L=Math.max(O-W,0.000001),T=(M)=>_+(M-G)/B*12,R=(M)=>_+(1-(M-W)/L)*12,A="";for(let M=0;M<Y.length;M++){let E=T(Y[M].x),k=R(Y[M].y);A+=`${M===0?"M":"L"}${E.toFixed(1)},${k.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${A}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#f(){return this.getAttribute("edit")!=="false"}#y(){if(this.classList.toggle("spring-mode",this.#J==="spring"),this.classList.toggle("bezier-mode",this.#J!=="spring"),this.#b(),this.innerHTML=this.#w(),this.#x(),this.#_)this.#u(),this.#v(),this.#c();this.#l(),this.#U0()}static#g(Q){return String(Q).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#h(){let Q="",Z=void 0;for(let J of w.PRESETS){if(!this.#f()&&!J.value&&!J.spring)continue;if(J.group!==Z){if(J.group)Q+=`<fig-menu-separator label="${w.#g(J.group)}"></fig-menu-separator>`;Z=J.group}let j;if(J.type==="spring"){let _=J.spring||this.#$;j=w.#T(_)}else{let _=J.value||[this.#Z.x,this.#Z.y,this.#Q.x,this.#Q.y];j=w.curveIcon(..._)}let q=w.#g(J.name);Q+=`<fig-select-option value="${q}" label="${q}"><span slot="prepend">${j}</span><span>${q}</span></fig-select-option>`}return`<fig-select class="fig-easing-curve-select" label="Easing preset" value="${w.#g(this.#L)}" full><fig-select-options>${Q}</fig-select-options></fig-select>`}#w(){let Z=this.#h();if(!this.#f())return Z;let $=`<fig-input-text class="fig-easing-curve-value-input" value="${w.#g(this.value)}" full></fig-input-text>`;if(this.#J==="spring")return`${Z}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
280
+ </div>`,this.#Z=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#Q&&this.#j&&this.#J){if(!this.#j.hasAttribute("type"))this.#j.setAttribute("type","dropdown");if(!this.#j.hasAttribute("label"))this.#j.setAttribute("label",J);this.#J.append(this.#j)}this.#$=this.querySelector("fig-dropdown"),this.#R()}#U(){this.#L(),this.#$?.addEventListener("input",this.#Y),this.#Z?.addEventListener("input",this.#X),this.#Z?.addEventListener("change",this.#W)}#L(){this.#$?.removeEventListener("input",this.#Y),this.#Z?.removeEventListener("input",this.#X),this.#Z?.removeEventListener("change",this.#W)}#F(Q){Q.stopPropagation();let Z=Q.target.closest("fig-dropdown")?.value??"";if(this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#Z)this.#Z.setAttribute("value",Z);this.#M(),this.#D()}#z(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#M()}#B(Q){Q.stopPropagation();let Z=Q.target.value??"";this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.#D()}#M(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#D(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#T(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#H(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#O(){return`${this.#H()} options`}#R(){if(this.#Z)this.#_.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.#Z.removeAttribute(Q);else this.#Z.setAttribute(Q,Z)});if(this.#$&&!this.#$.hasAttribute("aria-label"))this.#$.setAttribute("label",this.#O())}#P(Q){if(this.#Z)if(Q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}focus(){this.#Z?.focus()}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"options":if(this.#$&&!this.#Q){let J=this.#T();this.#$.replaceChildren(...J.map((j)=>{let q=document.createElement("option");return q.textContent=j,q}))}break;case"placeholder":if(this.#Z)this.#Z.setAttribute("placeholder",$||"");this.#R();break;case"value":if(!this.#q&&this.#Z)this.#Z.setAttribute("value",$||"");break;case"disabled":this.#P($!==null&&$!=="false");break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#R();break}}}z("fig-combo-input",j1);class q1 extends HTMLElement{#Q="color";#Z=null;#$=!1;constructor(){super();this.#Z=this.#W.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#Y(),this.#J(),this.#X()}#J(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#j(Q){if(!Q)return"color";let Z=Q.toLowerCase();if(Z.includes("gradient"))return"gradient";if(Z.includes("url("))return"image";return"color"}#q(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:Z}=O0(1,1);return Z.fillStyle=Q,Z.fillStyle}catch{return"#D9D9D9"}}#_(Q){if(!Q||!Q.includes("var("))return Q;let Z=this.style.background;this.style.background=Q;let $=getComputedStyle(this),J=$.backgroundImage,j=$.backgroundColor;if(this.style.background=Z,J&&J!=="none")return J;return j||Q}#Y(){let Q=this.getAttribute("background")||"#D9D9D9",Z=Q.includes("var("),$=Z?this.#_(Q):Q,J=this.#j($);if(J!==this.#Q||!this.input){if(this.#Q=J,this.setAttribute("data-type",this.#Q),this.input)this.input.removeEventListener("input",this.#Z);if(this.#Q==="color"){let q=this.#q($);if(this.innerHTML=`<div></div><input type="color" value="${q}" />`,this.input=this.querySelector("input"),!Z)this.input.addEventListener("input",this.#Z);this.#X()}else this.innerHTML="<div></div>",this.input=null,this.#X()}else if(this.#Q==="color"&&this.input){let q=this.#q($);if(this.input.value!==q)this.input.value=q}let j=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Q);this.style.setProperty("--swatch-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#X(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",Q?"true":"false"),this.input){this.input.disabled=Q;let Z=this.getAttribute("aria-labelledby"),$=this.getAttribute("aria-label")||"Color swatch",J=this.getAttribute("aria-describedby");if(Z)this.input.setAttribute("aria-labelledby",Z),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",$),this.input.removeAttribute("aria-labelledby");if(J)this.input.setAttribute("aria-describedby",J);else this.input.removeAttribute("aria-describedby");this.removeAttribute("role"),this.removeAttribute("aria-hidden");return}if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-hidden","true");else this.setAttribute("role","img"),this.removeAttribute("aria-hidden")}#W(Q){this.#$=!0,this.setAttribute("background",Q.target.value),this.#$=!1}get background(){return this.getAttribute("background")}set background(Q){this.setAttribute("background",Q)}focus(){this.input?.focus()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="background"){if(this.#$){let J=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test($);this.style.setProperty("--swatch-background",J?$:`linear-gradient(${$}, ${$})`);return}this.#Y()}else if(Q==="alpha")this.#J();else if(Q==="disabled"||Q==="aria-label"||Q==="aria-labelledby"||Q==="aria-describedby")this.#X()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",Q)}}z("fig-swatch",q1);class K0 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#_=null;#Y=this.#c.bind(this);#X=this.#h.bind(this);#W=this.#d.bind(this);#N=this.#p.bind(this);#K=null;#G=null;#U=null;#L=null;#F=null;#z=null;#B=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","caption","controls","autoplay","loop","muted","poster","aria-label","aria-labelledby","title"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#Q}set src(Q){if(this.#Q=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#_}#M(){return this.#q||this.#Q||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#M())return null;if(!this.#Z)return null;try{if(typeof this.#Z.decode==="function")await this.#Z.decode();else if(!this.#Z.complete)await new Promise((J,j)=>{this.#Z.addEventListener("load",J,{once:!0}),this.#Z.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Z.naturalWidth,Z=this.#Z.naturalHeight;if(!(Q>0)||!(Z>0))return null;let $=document.createElement("canvas");return $.width=Q,$.height=Z,$.getContext("2d").drawImage(this.#Z,0,0),$.toDataURL()}connectedCallback(){this.#Q=this.getAttribute("src")||"";let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--fig-media-aspect-ratio",Q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let Z=this.getAttribute("fit");if(Z)this.style.setProperty("--fig-media-fit",Z);if(this.querySelectorAll("fig-swatch[data-generated]").forEach((J)=>J.remove()),this.#H(),this.#R(),this.#T(),this.#E(),this.#P(),this.#I(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#g();this.#J=this.querySelector("fig-input-file[data-generated]"),this.#J?.removeEventListener("change",this.#Y),this.#J?.addEventListener("change",this.#Y)}disconnectedCallback(){if(this.#J?.removeEventListener("change",this.#Y),this.#D(),this.#V(),this.#j)URL.revokeObjectURL(this.#j),this.#j=null;this.#q=null}#D(){if(!this.#Z)return;if(this.#Z.tagName==="VIDEO")this.#Z.removeEventListener("play",this.#X),this.#Z.removeEventListener("pause",this.#W),this.#Z.removeEventListener("ended",this.#N)}#T(){if(this.#D(),this.#Z?.tagName!=="VIDEO")return;this.#Z.addEventListener("play",this.#X),this.#Z.addEventListener("pause",this.#W),this.#Z.addEventListener("ended",this.#N)}#H(){if(this.#$?.isConnected)return;let Q=this.querySelector(":scope > fig-preview");if(Q){this.#$=Q;return}let Z=document.createElement("fig-preview");Z.setAttribute("data-generated",""),this.prepend(Z),this.#$=Z}#O(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#R(){let Q=this.#O();if(Q){if(this.#H(),this.#Z&&this.#Z!==Q){if(this.#D(),this.#Z.hasAttribute("data-generated"))this.#Z.remove()}if(this.#Z=Q,this.#$&&Q.parentElement!==this.#$)this.#$.append(Q);this.#P();return}this.#H();let Z=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Z&&this.#Z.tagName!==Z){if(this.#D(),this.#Z.hasAttribute("data-generated"))this.#Z.remove();this.#Z=null}if(this.#Z)return;if(this.mediaKind==="video"){let $=document.createElement("video");$.setAttribute("data-generated",""),$.className="fig-media-element",$.setAttribute("playsinline",""),$.preload="auto",this.#$.append($),this.#Z=$,this.#T();let J=()=>{if(this.#Z?.autoplay)return;try{this.#Z.currentTime=0.001}catch{}};this.#Z.addEventListener("loadedmetadata",J,{once:!0})}else{let $=document.createElement("img");$.setAttribute("data-generated",""),$.className="fig-media-element",$.loading="lazy",$.decoding="async",$.alt=this.getAttribute("alt")||"",this.#$.append($),this.#Z=$}}#P(){if(!this.#Z)return;if(this.#Z.tagName==="IMG"){if(this.hasAttribute("alt")||this.#Z.hasAttribute("data-generated"))this.#Z.alt=this.getAttribute("alt")||"";return}if(this.#Z.tagName!=="VIDEO")return;["aria-label","aria-labelledby","title"].forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.#Z.removeAttribute(Q);else this.#Z.setAttribute(Q,Z)})}#S(){return this.querySelector(":scope > figcaption:not([data-generated])")}#f(){return Array.from(this.querySelectorAll(":scope > figcaption[data-generated]"))}#I(){let Q=this.#S(),Z=this.#f();if(Q){Z.forEach((q)=>q.remove());return}let $=this.getAttribute("caption")||"";if(!$){Z.forEach((q)=>q.remove());return}let J=Z[0]||document.createElement("figcaption");if(Z.slice(1).forEach((q)=>q.remove()),!J.hasAttribute("data-generated"))J.setAttribute("data-generated","");if(J.textContent!==$)J.textContent=$;let j=this.querySelector(":scope > fig-media-controls");if(j)j.before(J);else if(this.#$?.isConnected)this.#$.after(J);else if(!J.isConnected)this.append(J)}#A(Q,Z=!1){if(!this.hasAttribute(Q))return Z;return this.getAttribute(Q)!=="false"}#E(){if(!this.#Z)return;if(!this.#Z.hasAttribute("data-generated"))return;let Q=this.#M();if(this.#Z.getAttribute("src")!==Q){if(Q)this.#Z.setAttribute("src",Q);else if(this.#Z.removeAttribute("src"),this.#Z.tagName==="VIDEO")this.#Z.load()}if(this.#Z.tagName==="IMG"){this.#P();return}let Z=this.getAttribute("poster");if(Z)this.#Z.setAttribute("poster",Z);else this.#Z.removeAttribute("poster");this.#Z.controls=!1,this.#Z.removeAttribute("controls"),this.#Z.autoplay=this.#A("autoplay",!1),this.#Z.loop=this.#A("loop",!1),this.#Z.muted=this.#A("muted",!1),this.#Z.playsInline=!0,this.#P(),this.#y(),this.#k()}get mediaEl(){return this.#Z}#C(){if(this.mediaKind!=="video")return!1;return Boolean(this.#M())}#k(){let Q=this.#K||this.querySelector(":scope > fig-media-controls");if(!Q)return;if(this.mediaKind!=="video")return;if(this.#C()){if(Q.hasAttribute("data-fig-empty-disabled"))Q.removeAttribute("disabled"),Q.removeAttribute("data-fig-empty-disabled");return}Q.setAttribute("disabled",""),Q.setAttribute("data-fig-empty-disabled",""),Q.playing=!1,Q.time=0,Q.duration=0}#y(){if(this.mediaKind!=="video"){this.#V();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#K!==Q)this.#V(),this.#K=Q;this.#b(),this.#k();return}if(this.#A("controls",!1))this.#v();else this.#V()}#v(){let Q=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Z=Q[0];if(Q.slice(1).forEach((J)=>J.remove()),Z){this.#K=Z,this.#b(),this.#k();return}let $=document.createElement("fig-media-controls");$.setAttribute("data-generated",""),this.append($),this.#K=$,this.#b(),this.#k()}#b(){if(!this.#K||!this.#Z)return;if(this.#G===this.#Z&&this.#U===this.#K){this.#k();return}this.#w();let Q=this.#K,Z=this.#Z;this.#G=Z,this.#U=Q;let $=null,J=()=>{if(this.#k(),!this.#C())return;if(Q.playing=!Z.paused&&!Z.ended,Number.isFinite(Z.duration))Q.duration=Z.duration;if($!==null)if(Math.abs(Z.currentTime-$)<0.25)$=null;else return;Q.time=Z.currentTime||0},j=()=>{if(!this.#C())return;let X=Z.play?.();if(X&&typeof X.catch==="function")X.catch(()=>{})},q=()=>Z.pause?.(),_=(X)=>{if(!this.#C())return;let Y=Number(X?.detail?.time);if(!Number.isFinite(Y))return;$=Y;try{Z.currentTime=Y}catch{}};this.#L=J,this.#F=j,this.#z=q,this.#B=_,Z.addEventListener("play",J),Z.addEventListener("pause",J),Z.addEventListener("ended",J),Z.addEventListener("timeupdate",J),Z.addEventListener("loadedmetadata",J),Z.addEventListener("durationchange",J),Z.addEventListener("seeked",J),Q.addEventListener("play",j),Q.addEventListener("pause",q),Q.addEventListener("seek",_),J()}#w(){let Q=this.#G,Z=this.#U;if(Q&&this.#L)Q.removeEventListener("play",this.#L),Q.removeEventListener("pause",this.#L),Q.removeEventListener("ended",this.#L),Q.removeEventListener("timeupdate",this.#L),Q.removeEventListener("loadedmetadata",this.#L),Q.removeEventListener("durationchange",this.#L),Q.removeEventListener("seeked",this.#L);if(Z){if(this.#F)Z.removeEventListener("play",this.#F);if(this.#z)Z.removeEventListener("pause",this.#z);if(this.#B)Z.removeEventListener("seek",this.#B)}this.#G=null,this.#U=null,this.#L=null,this.#F=null,this.#z=null,this.#B=null}#V(){this.#w(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((Q)=>{Q.remove()}),this.#K=null}toggle(){if(!this.#Z||this.mediaKind!=="video")return;if(this.#Z.paused||this.#Z.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Z)return;let Q=this.#Z.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Z)return;this.#Z.pause()}#g(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let Z=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#Q?"Replace":Z),this.#_?.name)Q.setAttribute("filename",this.#_.name);else if(this.#Q)Q.setAttribute("url",this.#Q);Q.addEventListener("change",this.#Y),this.#H(),this.#$.append(Q),this.#J=Q}#x(){if(this.#J)this.#J.removeEventListener("change",this.#Y),this.#J.remove(),this.#J=null}#c(Q){if(Q.target!==this.#J)return;let Z=Q.detail?.files?.[0],$=Q.detail?.cleared===!0;if(!Z){if(this.#j)URL.revokeObjectURL(this.#j),this.#j=null;if(this.#_=null,this.#q=null,$)this.src="";if(this.#E(),this.#J){let J=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#Q?"Replace":J),this.#J.removeAttribute("filename"),this.#Q)this.#J.setAttribute("url",this.#Q);else this.#J.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#j)URL.revokeObjectURL(this.#j);if(this.#_=Z,this.#j=URL.createObjectURL(Z),this.#q=this.#j,this.#E(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Z,src:this.#j}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#J)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",Z.name),this.#J.setAttribute("label","Replace")}#m(Q){if(!this.#Z)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Q||"",currentTime:this.#Z.currentTime,duration:this.#Z.duration}}))}#h(){this.#m("play")}#d(){this.#m("pause")}#p(){this.#m("ended")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="src"){let J=$||"",j=J&&(J===this.#q||J===this.#j);if(this.#Q=J,this.#j&&!j)URL.revokeObjectURL(this.#j),this.#j=null,this.#q=null,this.#_=null;if(this.#E(),this.#J){let q=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#Q?"Replace":q),this.#Q)if(this.#_?.name)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",this.#_.name);else this.#J.setAttribute("url",this.#Q),this.#J.removeAttribute("filename");else this.#J.removeAttribute("url"),this.#J.removeAttribute("filename")}}if(Q==="type"){if(this.#R(),this.#E(),this.#J)this.#J.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(Q))this.#P();if(Q==="upload"){let J=$!==null&&$!=="false";if(J&&!this.#J)this.#g();else if(!J)this.#x()}if(Q==="aspect-ratio")if($)this.style.setProperty("--fig-media-aspect-ratio",$);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if($)this.style.setProperty("--fig-media-fit",$);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#J){let J=this.getAttribute("label")||"Upload";this.#J.setAttribute("label",this.#Q?"Replace":J)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#E();if(Q==="caption")this.#I()}}z("fig-media",K0);class _1 extends K0{get mediaKind(){return"image"}}z("fig-image",_1);class X1 extends K0{get mediaKind(){return"video"}}z("fig-video",X1);class Y1 extends HTMLElement{static get observedAttributes(){return["src","alt","label","text","sublabel","href","target","selected","disabled","full","aspect-ratio","fit","label-line-clamp"]}#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#_=!1;connectedCallback(){this.#G(),this.#U()}attributeChangedCallback(){if(!this.isConnected)return;this.#G(),this.#U()}#Y(){return this.getAttribute("label")??this.getAttribute("text")??""}#X(){return this.getAttribute("sublabel")??""}#W(){let Q=this.getAttribute("href");return Boolean(Q)&&!F(this,"disabled")}#N(){return this.getAttribute("label-line-clamp")==="2"?"2":"1"}#K(){return this.querySelector(":scope > fig-image:not([data-generated]), :scope > fig-media:not([data-generated]), :scope > fig-preview:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-image:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-media:not([data-generated]), :scope > .fig-card-link > .fig-card-media > fig-preview:not([data-generated])")}#G(){let Q=this.#K();this.#_=Boolean(Q);let $=this.#W()?"a":"div";if(!this.#Q||this.#Q.tagName.toLowerCase()!==$){let J=document.createElement($);if(J.className="fig-card-link",this.#Q){while(this.#Q.firstChild)J.appendChild(this.#Q.firstChild);this.#Q.replaceWith(J)}else this.appendChild(J);this.#Q=J}if(!this.#Z||!this.#Z.isConnected){if(this.#Z=this.#Q.querySelector(":scope > .fig-card-media"),!this.#Z)this.#Z=document.createElement("div"),this.#Z.className="fig-card-media",this.#Q.prepend(this.#Z)}if(Q&&Q.parentElement!==this.#Z)this.#Z.querySelectorAll("[data-generated]").forEach((J)=>J.remove()),this.#Z.appendChild(Q),this.#J=null;if(!this.#_){if(this.#J=this.#Z.querySelector(":scope > fig-image[data-generated]")||null,!this.#J)this.#Z.querySelectorAll(":scope > fig-image, :scope > fig-media, :scope > fig-preview").forEach((J)=>{if(J.hasAttribute("data-generated"))J.remove()}),this.#J=document.createElement("fig-image"),this.#J.setAttribute("data-generated",""),this.#J.setAttribute("full",""),this.#J.setAttribute("size","auto"),this.#Z.appendChild(this.#J)}if(!this.#$||!this.#$.isConnected){if(this.#$=this.#Q.querySelector(":scope > .fig-card-text"),!this.#$)this.#$=document.createElement("div"),this.#$.className="fig-card-text",this.#$.setAttribute("data-generated",""),this.#Q.appendChild(this.#$)}if(!this.#j||!this.#j.isConnected){if(this.#j=this.#$.querySelector(":scope > .fig-card-label[data-generated]"),!this.#j){if(this.#j=this.#Q.querySelector(":scope > .fig-card-label[data-generated]")||null,!this.#j)this.#j=document.createElement("label"),this.#j.className="fig-card-label",this.#j.setAttribute("data-generated","");this.#$.appendChild(this.#j)}}if(!this.#q||!this.#q.isConnected){if(this.#q=this.#$.querySelector(":scope > .fig-card-sublabel[data-generated]"),!this.#q){if(this.#q=this.#Q.querySelector(":scope > .fig-card-sublabel[data-generated]")||null,!this.#q)this.#q=document.createElement("span"),this.#q.className="fig-card-sublabel",this.#q.setAttribute("data-generated","");this.#j.after(this.#q)}}}#U(){if(!this.#Q)return;let Q=F(this,"disabled"),Z=F(this,"selected"),$=this.#Y(),J=this.#X(),j=this.#N();if(this.style.setProperty("--fig-card-label-line-clamp",j),this.#W()){let q=this.getAttribute("href")||"",_=this.getAttribute("target");if(this.#Q.setAttribute("href",q),_)if(this.#Q.setAttribute("target",_),_==="_blank")this.#Q.setAttribute("rel","noopener noreferrer");else this.#Q.removeAttribute("rel");else this.#Q.removeAttribute("target"),this.#Q.removeAttribute("rel");if(Z)this.#Q.setAttribute("aria-current","true");else this.#Q.removeAttribute("aria-current");this.removeAttribute("role"),this.removeAttribute("aria-label")}else{this.#Q.removeAttribute("href"),this.#Q.removeAttribute("target"),this.#Q.removeAttribute("rel"),this.#Q.removeAttribute("aria-current"),this.setAttribute("role","group");let q=[$,J].filter(Boolean).join(", ");if(q)this.setAttribute("aria-label",q);else this.removeAttribute("aria-label")}if(Q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#J&&!this.#_){let q=this.getAttribute("src"),_=this.getAttribute("alt"),X=this.getAttribute("aspect-ratio")||"1/1",Y=this.getAttribute("fit")||"contain",K=_!=null?_:"";if(q)this.#J.setAttribute("src",q);else this.#J.removeAttribute("src");this.#J.setAttribute("alt",K),this.#J.setAttribute("aspect-ratio",X),this.#J.setAttribute("fit",Y),this.#J.setAttribute("full",""),this.#J.setAttribute("size","auto")}if(this.#j)this.#j.textContent=$,this.#j.hidden=!$;if(this.#q)this.#q.textContent=J,this.#q.hidden=!J;if(this.#$)this.#$.hidden=!$&&!J}}z("fig-card",Y1);class K1 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=!1;#q=!1;static get observedAttributes(){return["playing","duration","time","disabled"]}connectedCallback(){this.#_(),this.#N(),this.#K(),this.#Y()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let Q=Number(this.getAttribute("duration"));return Number.isFinite(Q)&&Q>=0?Q:0}set duration(Q){let Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("duration");return}this.setAttribute("duration",String(Z))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let Z=Number(Q);if(!Number.isFinite(Z)||Z<0){this.removeAttribute("time");return}this.setAttribute("time",String(Z))}get disabled(){return F(this,"disabled")}set disabled(Q){if(Q)this.setAttribute("disabled","");else this.removeAttribute("disabled")}attributeChangedCallback(Q){if(!this.#q)return;if(Q==="playing")this.#N();if(Q==="duration"||Q==="time")this.#K();if(Q==="disabled")this.#Y()}#_(){if(this.#q)return;if(this.#q=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");let Q=document.createElement("fig-tooltip");Q.setAttribute("text","Play");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("size","small"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Play");let $=u("play",{className:"fig-media-controls-play-icon"});Z.append($),Q.append(Z),Z.addEventListener("click",(_)=>{_.preventDefault(),_.stopPropagation(),this.toggle()});let J=document.createElement("fig-slider");J.setAttribute("text","false"),J.setAttribute("min","0"),J.setAttribute("max",String(this.duration)),J.setAttribute("step","1"),J.setAttribute("value",String(this.time)),J.setAttribute("full",""),J.setAttribute("aria-label","Seek"),J.setAttribute("aria-valuetext",this.#W(this.time,this.duration));let j=document.createElement("span");j.className="fig-media-controls-time",j.textContent=this.#X(this.time);let q=(_)=>{if(this.disabled){_.preventDefault?.(),_.stopPropagation();return}let X=_.currentTarget,Y=Number(X?.value);if(!Number.isFinite(Y))return;this.#j=!0,this.setAttribute("time",String(Y)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:Y}})),requestAnimationFrame(()=>{this.#j=!1})};J.addEventListener("input",q),J.addEventListener("change",q),this.append(Q,J,j),this.#Q=Z,this.#Z=Q,this.#$=J,this.#J=j,this.#Y()}#Y(){let Q=this.disabled;if(this.setAttribute("aria-disabled",Q?"true":"false"),this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}#X(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let Z=Math.floor(Q),$=Math.floor(Z/60),J=Z%60;return`${String($).padStart(2,"0")}:${String(J).padStart(2,"0")}`}#W(Q,Z=0){let $=this.#X(Q);if(!Number.isFinite(Z)||Z<=0)return $;return`${$} of ${this.#X(Z)}`}#N(){if(!this.#Q)return;let Q=this.playing;this.#Q.setAttribute("aria-label",Q?"Pause":"Play"),this.#Z?.setAttribute("text",Q?"Pause":"Play");let Z=this.#Q.querySelector(".fig-media-controls-play-icon");if(Z)Z.setAttribute("name",Q?"pause":"play")}#K(){if(!this.#$)return;let Q=this.duration;if(Number(this.#$.getAttribute("max"))!==Q)this.#$.setAttribute("max",String(Q));let Z=this.time;if(!this.#j)this.#$.setAttribute("value",String(Z));if(this.#$.setAttribute("aria-valuetext",this.#W(Z,Q)),this.#J)this.#J.textContent=this.#X(Z)}toggle(){if(this.disabled)return;let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.disabled||this.playing)return;this.toggle()}pause(){if(this.disabled||!this.playing)return;this.toggle()}}z("fig-media-controls",K1);class G1 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;get files(){return this.#q}get#_(){let Q=this.getAttribute("filename");if(Q)return Q;let Z=this.getAttribute("url");if(!Z)return"";try{let J=new URL(Z,location.href).pathname.split("/").pop();return J?decodeURIComponent(J):Z}catch{return Z}}get value(){if(this.#q&&this.#q.length>0){if(this.#q.length===1)return this.#q[0].name;return`${this.#q.length} files`}return this.#_}connectedCallback(){this.#U(),this.addEventListener("dragover",this.#N),this.addEventListener("dragleave",this.#K),this.addEventListener("drop",this.#G)}disconnectedCallback(){this.#Q?.removeEventListener("change",this.#X),this.#$?.removeEventListener("click",this.#W),this.removeEventListener("dragover",this.#N),this.removeEventListener("dragleave",this.#K),this.removeEventListener("drop",this.#G)}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#U()}clear(){if(this.#q=null,this.#Q)this.#Q.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#U(),this.#Y({cleared:!0})}#Y(Q={}){let Z={files:this.#q,...Q};this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0}))}#X=()=>{if(this.#Q.files.length>0)this.#q=this.#Q.files,this.removeAttribute("url"),this.#U(),this.#Y()};#W=(Q)=>{Q.stopPropagation(),this.clear()};#N=(Q)=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#j)this.#j.dataset.prevText=this.#j.textContent,this.#j.textContent="Drop file"}};#K=()=>{if(this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText};#G=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#j&&this.#j.dataset.prevText!==void 0)this.#j.textContent=this.#j.dataset.prevText,delete this.#j.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.getAttribute("accepts"),$=Array.from(Q.dataTransfer.files);if(Z){let j=Z.split(",").map((q)=>q.trim().toLowerCase());$=$.filter((q)=>{let _="."+q.name.split(".").pop().toLowerCase(),X=q.type.toLowerCase();return j.some((Y)=>Y===_||Y===X||Y.endsWith("/*")&&X.startsWith(Y.slice(0,-1)))})}if(!this.hasAttribute("multiple")||this.getAttribute("multiple")==="false")$=$.slice(0,1);if($.length===0)return;let J=new DataTransfer;if($.forEach((j)=>J.items.add(j)),this.#q=J.files,this.#Q)this.#Q.files=J.files;this.removeAttribute("url"),this.#U(),this.#Y()};#U(){let Q=this.getAttribute("accepts")||"",Z=this.getAttribute("label")||"Upload",$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.hasAttribute("multiple")&&this.getAttribute("multiple")!=="false",j=this.getAttribute("variant")||"input",q=this.#q&&this.#q.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",q){let _=Q?`Accepts ${Q.split(",").map((N)=>N.trim()).join(", ")}`:"";if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.className="fig-input-file-filename",$)this.#j.setAttribute("disabled","");let X=document.createElement("fig-truncate");X.setAttribute("position","middle"),X.setAttribute("tooltip","");let Y=this.value,K=Y.lastIndexOf(".");if(K>0)X.setAttribute("tail",Y.slice(K));if(X.textContent=Y,this.#j.appendChild(X),this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",this.#Q.disabled=$,Q)this.#Q.setAttribute("accept",Q);if(J)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#X),this.#j.appendChild(this.#Q),_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_),this.#J.appendChild(this.#j),this.appendChild(this.#J);else this.appendChild(this.#j);let G=document.createElement("fig-tooltip");if(G.setAttribute("text","Remove"),this.#$=document.createElement("fig-button"),this.#$.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#$.setAttribute("icon","true"),this.#$.setAttribute("aria-label","Remove"),this.#$.className="fig-input-file-clear",$)this.#$.setAttribute("disabled","");this.#$.replaceChildren(u("minus")),this.#$.addEventListener("click",this.#W),G.appendChild(this.#$),this.appendChild(G)}else{let _=Q?`Accepts ${Q.split(",").map((X)=>X.trim()).join(", ")}`:"";if(_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_);if(this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j),this.#j.setAttribute("type","upload"),this.#j.textContent=Z,$)this.#j.setAttribute("disabled","");if(this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",this.#Q.disabled=$,Q)this.#Q.setAttribute("accept",Q);if(J)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#X),this.#j.appendChild(this.#Q),this.#J)this.#J.appendChild(this.#j),this.appendChild(this.#J);else this.appendChild(this.#j)}}}z("fig-input-file",G1);class w extends HTMLElement{#Q={x:0.42,y:0};#Z={x:0.58,y:1};#$={stiffness:200,damping:15,mass:1};#J="bezier";#j=2;#q=null;#_=null;#Y=null;#X=null;#W=null;#N=null;#K=null;#G=null;#U=null;#L=null;#F=null;#z=0.8;#B=200;#M=200;#D=null;#T=null;#H=null;#O=null;#R=5;#P=10;#S=10;#f=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#j=parseInt(this.getAttribute("precision")||"2"),b(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#I(Q);this.#L=this.#A(),this.#y(),this.#m()}disconnectedCallback(){if(this.#q=null,this.#O)this.#O.disconnect(),this.#O=null}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="aspect-ratio"){if(b(this,"--aspect-ratio",$),this.#_)this.#h(),this.#u();return}if(Q==="edit"){if(this.isConnected)this.#y();return}if(Q==="value"&&$){let J=this.#J;if(this.#I($),this.#L=this.#A(),J!==this.#J&&this.#k())this.#y();else{if(this.#_)this.#u();this.#e(),this.#l()}}if(Q==="precision")this.#j=parseInt($||"2")}get value(){if(this.#J==="spring"){let{stiffness:Z,damping:$,mass:J}=this.#$;return`spring(${Z}, ${$}, ${J})`}let Q=this.#j;return`${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}, ${this.#Z.x.toFixed(Q)}, ${this.#Z.y.toFixed(Q)}`}get cssValue(){if(this.#J==="spring"){let Z=this.#E(),$=20,J=Math.max(1,Math.floor(Z.length/20)),j=[];for(let q=0;q<Z.length;q+=J)j.push(Z[q].value.toFixed(3));if(Z.length>0)j.push(Z[Z.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#j;return`cubic-bezier(${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}, ${this.#Z.x.toFixed(Q)}, ${this.#Z.y.toFixed(Q)})`}get preset(){return this.#L}set value(Q){this.setAttribute("value",Q)}#I(Q){let Z=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if(Z)return this.#J="spring",this.#$.stiffness=parseFloat(Z[1]),this.#$.damping=parseFloat(Z[2]),this.#$.mass=parseFloat(Z[3]),!0;let $=Q.split(",").map((J)=>parseFloat(J.trim()));if($.length>=4&&$.every((J)=>!isNaN(J)))return this.#J="bezier",this.#Q.x=$[0],this.#Q.y=$[1],this.#Z.x=$[2],this.#Z.y=$[3],!0;return!1}#A(){if(this.#J==="bezier"){for(let Z of w.PRESETS){if(Z.type!=="bezier"||!Z.value)continue;if(Math.abs(this.#Q.x-Z.value[0])<0.001&&Math.abs(this.#Q.y-Z.value[1])<0.001&&Math.abs(this.#Z.x-Z.value[2])<0.001&&Math.abs(this.#Z.y-Z.value[3])<0.001)return Z.name}return"Custom bezier"}for(let Z of w.PRESETS){if(Z.type!=="spring"||!Z.spring)continue;if(Math.abs(this.#$.stiffness-Z.spring.stiffness)<0.001&&Math.abs(this.#$.damping-Z.spring.damping)<0.001&&Math.abs(this.#$.mass-Z.spring.mass)<0.001)return Z.name}return"Custom spring"}#E(){let{stiffness:Q,damping:Z,mass:$}=this.#$,J=0.004,j=5,q=[],_=0,X=0;for(let Y=0;Y<=5;Y+=0.004){let K=-Q*(_-1)-Z*X;if(X+=K/$*0.004,_+=X*0.004,q.push({t:Y,value:_}),Y>0.1&&Math.abs(_-1)<0.0005&&Math.abs(X)<0.0005)break}return q}static#C(Q,Z=24){let{stiffness:$,damping:J,mass:j}=Q,q=0.004,_=5,X=[],Y=0,K=0;for(let A=0;A<=5;A+=0.004){let M=-$*(Y-1)-J*K;if(K+=M/j*0.004,Y+=K*0.004,X.push({t:A,value:Y}),A>0.1&&Math.abs(Y-1)<0.001&&Math.abs(K)<0.001)break}let G=X[X.length-1].t||1,N=1;for(let A of X)if(A.value>N)N=A.value;let W=0;for(let A of X)if(A.value<W)W=A.value;let O=Math.max(N-W,1),B=6,L=Z-B*2,T=Math.max(1,Math.floor(X.length/30)),R="";for(let A=0;A<X.length;A+=T){let M=B+X[A].t/G*L,E=B+(1-(X[A].value-W)/O)*L;R+=(A===0?"M":"L")+M.toFixed(1)+","+E.toFixed(1)}return`<svg width="${Z}" height="${Z}" viewBox="0 0 ${Z} ${Z}" fill="none"><path d="${R}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,Z,$,J,j=24){let _=(j-12)/2,X=48,Y=[],K=(M,E,k,S,x)=>{let y=1-x;return y*y*y*M+3*y*y*x*E+3*y*x*x*k+x*x*x*S};for(let M=0;M<=48;M++){let E=M/48;Y.push({x:K(0,Q,$,1,E),y:K(0,Z,J,1,E)})}let G=1/0,N=-1/0,W=1/0,O=-1/0;for(let M of Y){if(M.x<G)G=M.x;if(M.x>N)N=M.x;if(M.y<W)W=M.y;if(M.y>O)O=M.y}let B=Math.max(N-G,0.000001),L=Math.max(O-W,0.000001),T=(M)=>_+(M-G)/B*12,R=(M)=>_+(1-(M-W)/L)*12,A="";for(let M=0;M<Y.length;M++){let E=T(Y[M].x),k=R(Y[M].y);A+=`${M===0?"M":"L"}${E.toFixed(1)},${k.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${A}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#k(){return this.getAttribute("edit")!=="false"}#y(){if(this.classList.toggle("spring-mode",this.#J==="spring"),this.classList.toggle("bezier-mode",this.#J!=="spring"),this.#g(),this.innerHTML=this.#w(),this.#x(),this.#_)this.#c(),this.#h(),this.#u();this.#l(),this.#U0()}static#v(Q){return String(Q).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#b(){let Q="",Z=void 0;for(let J of w.PRESETS){if(!this.#k()&&!J.value&&!J.spring)continue;if(J.group!==Z){if(J.group)Q+=`<fig-menu-separator label="${w.#v(J.group)}"></fig-menu-separator>`;Z=J.group}let j;if(J.type==="spring"){let _=J.spring||this.#$;j=w.#C(_)}else{let _=J.value||[this.#Q.x,this.#Q.y,this.#Z.x,this.#Z.y];j=w.curveIcon(..._)}let q=w.#v(J.name);Q+=`<fig-select-option value="${q}" label="${q}"><span slot="prepend">${j}</span><span>${q}</span></fig-select-option>`}return`<fig-select class="fig-easing-curve-select" label="Easing preset" value="${w.#v(this.#L)}" full><fig-select-options>${Q}</fig-select-options></fig-select>`}#w(){let Z=this.#b();if(!this.#k())return Z;let $=`<fig-input-text class="fig-easing-curve-value-input" value="${w.#v(this.value)}" full></fig-input-text>`;if(this.#J==="spring")return`${Z}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
281
281
  <rect class="fig-easing-curve-bounds" x="0" y="0" width="200" height="200"/>
282
282
  <line class="fig-easing-curve-target" x1="0" y1="40" x2="200" y2="40"/>
283
283
  <path class="fig-easing-curve-path"/>
@@ -292,7 +292,7 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
292
292
  <line class="fig-easing-curve-arm" data-arm="2"/>
293
293
  <foreignObject class="fig-easing-curve-handle" data-handle="1" width="20" height="20"><fig-handle size="small" aria-label="First easing control point"></fig-handle></foreignObject>
294
294
  <foreignObject class="fig-easing-curve-handle" data-handle="2" width="20" height="20"><fig-handle size="small" aria-label="Second easing control point"></fig-handle></foreignObject>
295
- </svg></div>${$}`}#V(Q,Z){let $=getComputedStyle(this).getPropertyValue(Q).trim();if(!$)return Z;let J=Number.parseFloat($);return Number.isFinite(J)?J:Z}#b(){this.#S=this.#V("--easing-duration-bar-radius",this.#S)}#x(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#Y=this.querySelector(".fig-easing-curve-path"),this.#X=this.querySelector('[data-arm="1"]'),this.#W=this.querySelector('[data-arm="2"]'),this.#N=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#K=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#G=this.querySelector(".fig-easing-curve-select"),this.#U=this.querySelector(".fig-easing-curve-value-input"),this.#F=this.querySelector(".fig-easing-curve-target"),this.#D=this.querySelector(".fig-easing-curve-bounds"),this.#E=this.querySelector('[data-boundary="top"]'),this.#H=this.querySelector('[data-boundary="bottom"]')}#u(){let Q=this.#N?.querySelector("fig-handle"),Z=this.#K?.querySelector("fig-handle");if(Q){let $=Q.offsetWidth||this.#R*2,J=Q.offsetHeight||this.#R*2;this.#R=Math.max($,J)/2,this.#N.setAttribute("width",$),this.#N.setAttribute("height",J)}if(Z){let $=Z.offsetWidth||this.#P,J=Z.offsetHeight||this.#C;if(this.#J==="spring")this.#P=$,this.#C=J;this.#K.setAttribute("width",$),this.#K.setAttribute("height",J)}}#m(){if(this.#O||!window.ResizeObserver)return;this.#O=new ResizeObserver(()=>{if(this.#v())this.#c()}),this.#O.observe(this)}#v(){if(!this.#_)return!1;let Q=this.#_.getBoundingClientRect(),Z=Math.max(1,Math.round(Q.width||200)),$=Math.max(1,Math.round(Q.height||200)),J=Z!==this.#B||$!==this.#M;return this.#B=Z,this.#M=$,this.#_.setAttribute("viewBox",`0 0 ${Z} ${$}`),J}#d(){let Q=Math.min(0,this.#Z.y,this.#Q.y),Z=Math.max(1,this.#Z.y,this.#Q.y),$=Z-Q||1,J=Math.min(this.#R,Math.max(0,(this.#M-1)/2));return{minVal:Q,maxVal:Z,range:$,pad:J,draw:Math.max(1,this.#M-J*2)}}#p(Q,Z){let{maxVal:$,range:J,pad:j,draw:q}=this.#d();return{x:Q*this.#B,y:j+($-Z)/J*q}}#s(Q,Z){let{maxVal:$,range:J,pad:j,draw:q}=this.#d();return{x:Q/this.#B,y:$-(Z-j)/q*J}}#t={minVal:0,maxVal:1.2,totalTime:1};#r(Q,Z){let J=this.#M-40,{minVal:j,maxVal:q}=this.#t,_=q-j||1;return{x:Q*this.#B,y:20+(1-(Z-j)/_)*J}}#c(){if(this.#v(),this.#J==="spring")this.#j0();else this.#i()}#o(){this.#X?.classList.toggle("is-active",this.#J==="bezier"&&this.#q===1),this.#W?.classList.toggle("is-active",this.#J==="bezier"&&this.#q===2)}#i(){if(this.#D)this.#D.setAttribute("x","0"),this.#D.setAttribute("y","0"),this.#D.setAttribute("width",this.#B),this.#D.setAttribute("height",this.#M);let Q=this.#p(0,0),Z=this.#p(this.#Z.x,this.#Z.y),$=this.#p(this.#Q.x,this.#Q.y),J=this.#p(1,1);for(let[q,_]of[[this.#E,J.y],[this.#H,Q.y]]){if(!q)continue;q.setAttribute("x1","0"),q.setAttribute("y1",_),q.setAttribute("x2",this.#B),q.setAttribute("y2",_)}this.#Y.setAttribute("d",`M${Q.x},${Q.y} C${Z.x},${Z.y} ${$.x},${$.y} ${J.x},${J.y}`),this.#X.setAttribute("x1",Q.x),this.#X.setAttribute("y1",Q.y),this.#X.setAttribute("x2",Z.x),this.#X.setAttribute("y2",Z.y),this.#W.setAttribute("x1",J.x),this.#W.setAttribute("y1",J.y),this.#W.setAttribute("x2",$.x),this.#W.setAttribute("y2",$.y);let j=this.#R;this.#N.setAttribute("x",Z.x-j),this.#N.setAttribute("y",Z.y-j),this.#K.setAttribute("x",$.x-j),this.#K.setAttribute("y",$.y-j),this.#Z0()}#Z0(){if(!this.#_||!this.#N||!this.#K)return;let Q=this.#Z.y>=this.#Q.y?[this.#N,this.#K]:[this.#K,this.#N];for(let Z of Q)this.#_.append(Z)}#j0(){if(this.#D)this.#D.setAttribute("x","0"),this.#D.setAttribute("y","0"),this.#D.setAttribute("width",this.#B),this.#D.setAttribute("height",this.#M);let Q=this.#k();if(!Q.length)return;let Z=Q[Q.length-1].t||1,$=0,J=1;for(let L of Q){if(L.value<$)$=L.value;if(L.value>J)J=L.value}let j=Math.max(Math.abs($-1),Math.abs(J-1),0.01),q=0;this.#t={minVal:1-j-q,maxVal:1+j+q,totalTime:Z};let _=Math.max(0.05,Math.min(0.95,this.#z)),X="";for(let L=0;L<Q.length;L++){let T=Q[L].t/Z*_,R=this.#r(T,Q[L].value);X+=(L===0?"M":"L")+R.x.toFixed(1)+","+R.y.toFixed(1)}let Y=this.#r(_,1),K=this.#r(1,1);if(X+=`L${Y.x.toFixed(1)},${Y.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#Y.setAttribute("d",X),this.#F){let L=this.#r(0,1),T=this.#r(1,1);this.#F.setAttribute("x1",L.x),this.#F.setAttribute("y1",L.y),this.#F.setAttribute("x2",T.x),this.#F.setAttribute("y2",T.y)}let G=this.#q0(Q),N=G.t/Z*_,W=this.#r(N,G.value),O=this.#R;this.#N.setAttribute("x",W.x-O),this.#N.setAttribute("y",W.y-O);let B=this.#r(_,1);this.#K.setAttribute("x",B.x-this.#P/2),this.#K.setAttribute("y",B.y-this.#C/2)}#q0(Q){let Z={t:0,value:1},$=!1;for(let J of Q){if(J.value>=0.99)$=!0;if($&&J.value>Z.value)Z={t:J.t,value:J.value}}return Z}#e(){if(!this.#G)return;this.#G.value=this.#L,this.#n()}#l(){if(!this.#U)return;this.#U.setAttribute("value",this.value)}#J0(Q){let Z=Q.split(",").map(($)=>Number.parseFloat($.trim()));if(Z.length!==4||Z.some(($)=>!Number.isFinite($)))return null;if(Z[0]<0||Z[0]>1||Z[2]<0||Z[2]>1)return null;return Z}#$0(Q,Z){let $=this.#J0(Q);if(!$){if(Z==="change")this.#l();return}let J=this.#J;if(this.#J="bezier",this.#Z.x=$[0],this.#Z.y=$[1],this.#Q.x=$[2],this.#Q.y=$[3],this.#L=this.#A(),J!==this.#J)this.#y();else if(this.#c(),this.#e(),Z==="change")this.#l();this.#Q0(Z)}#a(Q,Z){if(!this.#G)return;for(let $ of this.#G.querySelectorAll("fig-select-option"))if($.value===Q){let J=$.querySelector(':scope > [slot="prepend"]');if(J)J.innerHTML=Z}}#n(){if(!this.#G)return;if(!this.#f())return;let Q=w.curveIcon(this.#Z.x,this.#Z.y,this.#Q.x,this.#Q.y),Z=w.#T(this.#$);this.#a("Custom bezier",Q),this.#a("Custom spring",Z)}#_0(Q){this.#c(),this.#L=this.#A(),this.#e(),this.#l(),this.#Q0(Q)}#G0(Q,Z){let $=Q.shiftKey?0.1:0.01,J=Z===1?this.#Z:this.#Q;switch(Q.key){case"ArrowLeft":J.x-=$;break;case"ArrowRight":J.x+=$;break;case"ArrowUp":J.y+=$;break;case"ArrowDown":J.y-=$;break;case"Home":J.x=0,J.y=0;break;case"End":J.x=1,J.y=1;break;default:return!1}return J.x=Math.max(0,Math.min(1,Math.round(J.x*100)/100)),J.y=Math.round(J.y*100)/100,this.#_0("input"),this.#Q0("change"),!0}#W0(Q,Z){let $=Q.shiftKey?10:1;if(Z==="bounce")switch(Q.key){case"ArrowUp":this.#$.damping=Math.max(1,Math.round(this.#$.damping-$));break;case"ArrowDown":this.#$.damping=Math.max(1,Math.round(this.#$.damping+$));break;case"Home":this.#$.damping=1;break;case"End":this.#$.damping=50;break;default:return!1}else{let J=$*2;switch(Q.key){case"ArrowLeft":this.#z=Math.max(0.05,this.#z-J/200),this.#$.stiffness=Math.max(10,Math.round(this.#$.stiffness+J*1.5));break;case"ArrowRight":this.#z=Math.min(0.95,this.#z+J/200),this.#$.stiffness=Math.max(10,Math.round(this.#$.stiffness-J*1.5));break;case"Home":this.#z=0.05;break;case"End":this.#z=0.95;break;default:return!1}}return this.#_0("input"),this.#Q0("change"),!0}#X0(Q,Z){let $=Q?.querySelector("fig-handle");if(!$)return;$.addEventListener("pointerdown",(J)=>{if(J.preventDefault(),J.stopImmediatePropagation(),this.#J==="bezier")this.#Y0(J,Number(Z));else this.#K0(J,Z)},{capture:!0}),$.addEventListener("keydown",(J)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(J.key))return;if(!(this.#J==="bezier"?this.#G0(J,Number(Z)):this.#W0(J,Z)))return;J.preventDefault(),J.stopImmediatePropagation()},{capture:!0})}#Q0(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#J,value:this.value,cssValue:this.cssValue,preset:this.#L}}))}#U0(){if(this.#_&&this.#J==="bezier"){this.#X0(this.#N,"1"),this.#X0(this.#K,"2"),this.#N.addEventListener("pointerdown",(Z)=>this.#Y0(Z,1)),this.#K.addEventListener("pointerdown",(Z)=>this.#Y0(Z,2));let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#Y0(Z,this.#L0(Z))})}else if(this.#_){this.#X0(this.#N,"bounce"),this.#X0(this.#K,"duration"),this.#N.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#K0(Z,"bounce")}),this.#K.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#K0(Z,"duration")});let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#K0(Z,"duration")})}if(this.#G)this.#G.addEventListener("change",(Q)=>{let Z=Q.detail,$=w.PRESETS.find((J)=>J.name===Z);if(!$)return;if($.type==="bezier"){if($.value)this.#Z.x=$.value[0],this.#Z.y=$.value[1],this.#Q.x=$.value[2],this.#Q.y=$.value[3];if(this.#L=Z,this.#J!=="bezier")this.#J="bezier",this.#y();else if(this.#_)this.#c(),this.#l()}else if($.type==="spring"){if($.spring)this.#$={...$.spring};if(this.#L=Z,this.#J!=="spring")this.#J="spring",this.#y();else if(this.#_)this.#c(),this.#l()}this.#Q0("input"),this.#Q0("change")});if(this.#U)this.#U.addEventListener("input",(Q)=>{Q.stopPropagation();let Z=Q.detail??Q.target?.value;if(typeof Z!=="string")return;this.#$0(Z,"input")}),this.#U.addEventListener("change",(Q)=>{Q.stopPropagation();let Z=Q.detail??Q.target?.value;if(typeof Z!=="string")return;this.#$0(Z,"change")})}#N0(Q){let Z=this.#_.getScreenCTM();if(!Z)return{x:0,y:0};let $=Z.inverse();return{x:$.a*Q.clientX+$.c*Q.clientY+$.e,y:$.b*Q.clientX+$.d*Q.clientY+$.f}}#L0(Q){return this.#N0(Q).x<=this.#B/2?1:2}#Y0(Q,Z){Q.preventDefault(),this.#q=Z,this.#o();let $=this.#_.getBoundingClientRect(),J=Q.clientX,j=Q.clientY,q=Q.target?.closest?.(".fig-easing-curve-handle, fig-handle"),_=Z===1?this.#Z:this.#Q,X=this.#N0(Q),Y=q?{..._}:this.#s(X.x,X.y),{range:K,draw:G}=this.#d(),N=K/Math.max(1,G/this.#M*Math.max(1,$.height)),W=(B)=>{if(!this.#q)return;let L={x:Y.x+(B.clientX-J)/Math.max(1,$.width),y:Y.y-(B.clientY-j)*N};if(L.x=Math.round(L.x*100)/100,L.y=Math.round(L.y*100)/100,L.x=Math.max(0,Math.min(1,L.x)),this.#q===1)this.#Z.x=L.x,this.#Z.y=L.y;else this.#Q.x=L.x,this.#Q.y=L.y;this.#c(),this.#L=this.#A(),this.#e(),this.#l(),this.#Q0("input")},O=()=>{this.#q=null,this.#o(),document.removeEventListener("pointermove",W),document.removeEventListener("pointerup",O),this.#Q0("change")};document.addEventListener("pointermove",W),document.addEventListener("pointerup",O)}#K0(Q,Z){Q.preventDefault(),this.#q=Z,this.classList.toggle("spring-bounce-dragging",Z==="bounce");let $=this.#$.damping,J=this.#$.stiffness,j=this.#z,q=Q.clientY,_=Q.clientX,X=(K)=>{if(!this.#q)return;if(Z==="bounce"){let G=K.clientY-q;this.#$.damping=Math.max(1,Math.round($+G*0.15))}else{let G=K.clientX-_;this.#z=Math.max(0.05,Math.min(0.95,j+G/200)),this.#$.stiffness=Math.max(10,Math.round(J-G*1.5))}this.#c(),this.#L=this.#A(),this.#e(),this.#l(),this.#Q0("input")},Y=()=>{this.#q=null,this.classList.remove("spring-bounce-dragging"),document.removeEventListener("pointermove",X),document.removeEventListener("pointerup",Y),this.#Q0("change")};document.addEventListener("pointermove",X),document.addEventListener("pointerup",Y)}}z("fig-easing-curve",w);class N1 extends HTMLElement{#Z=0;#Q=0;#$=0;#J=1;#j=!1;#q=!1;#_=null;#Y=null;#X=null;#W=null;#N=(Q)=>this.#T(Q);#K=null;#G=[];#U={};#L={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#J=parseInt(this.getAttribute("precision")||"1"),b(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),b(this,"--perspective",this.getAttribute("perspective")),b(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#B(this.getAttribute("transform-origin")),this.#E(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#H(Q);if(this.querySelector(".fig-3d-rotate-container"))this.#F();else this.#O();this.#D(this.getAttribute("selected")),this.#M()}disconnectedCallback(){this.#j=!1,this.#z()}#F(){this.#Y=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#R(),this.#C(),this.#A()}#z(){if(this.#K?.abort(),this.#K=null,this.#X)window.removeEventListener("keydown",this.#X),window.removeEventListener("keyup",this.#W),this.#X=null,this.#W=null}#B(Q){if(!Q||!Q.trim()){this.style.removeProperty("--transform-origin");return}let Z=Q.trim().split(/\s+/);if(Z.length===2)this.style.setProperty("--transform-origin",`${Z[0]} ${Z[1]} -50cqi`);else this.style.setProperty("--transform-origin",Q.trim())}#M(){if(!this.#Y)return;this.#Y.style.cursor=this.#k?"":"default"}#D(Q){if(!this.#_)return;let Z=this.#_.querySelectorAll(".fig-3d-rotate-face"),$=Q?Q.trim().toLowerCase():"";for(let J of Z)J.classList.toggle("selected",$!==""&&J.classList.contains($))}#E(Q){if(!Q||!Q.trim()){this.#G=[];return}let Z=["rotateX","rotateY","rotateZ"];this.#G=Q.split(",").map(($)=>$.trim()).filter(($)=>Z.includes($))}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){b(this,"--aspect-ratio",$);return}if(Q==="perspective"){b(this,"--perspective",$);return}if(Q==="perspective-origin"){b(this,"--perspective-origin",$);return}if(Q==="transform-origin"){this.#B($);return}if(Q==="selected"){this.#D($);return}if(Q==="drag"){this.#M();return}if(Q==="fields"){if(this.#E($),this.#_)this.#O();return}if(!this.#_)return;if(Q==="value"&&$){if(this.#j)return;this.#H($),this.#C(),this.#P()}if(Q==="precision")this.#J=parseInt($||"1")}get value(){let Q=this.#J;return`rotateX(${this.#Z.toFixed(Q)}deg) rotateY(${this.#Q.toFixed(Q)}deg) rotateZ(${this.#$.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#Z}get rotateY(){return this.#Q}get rotateZ(){return this.#$}#H(Q){let Z=Q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),$=Q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),J=Q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if(Z)this.#Z=parseFloat(Z[1]);if($)this.#Q=parseFloat($[1]);if(J)this.#$=parseFloat(J[1])}#O(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},Z={rotateX:this.#Z,rotateY:this.#Q,rotateZ:this.#$},$=this.#G.map((J)=>`<fig-input-number
295
+ </svg></div>${$}`}#V(Q,Z){let $=getComputedStyle(this).getPropertyValue(Q).trim();if(!$)return Z;let J=Number.parseFloat($);return Number.isFinite(J)?J:Z}#g(){this.#f=this.#V("--easing-duration-bar-radius",this.#f)}#x(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#Y=this.querySelector(".fig-easing-curve-path"),this.#X=this.querySelector('[data-arm="1"]'),this.#W=this.querySelector('[data-arm="2"]'),this.#N=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#K=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#G=this.querySelector(".fig-easing-curve-select"),this.#U=this.querySelector(".fig-easing-curve-value-input"),this.#F=this.querySelector(".fig-easing-curve-target"),this.#D=this.querySelector(".fig-easing-curve-bounds"),this.#T=this.querySelector('[data-boundary="top"]'),this.#H=this.querySelector('[data-boundary="bottom"]')}#c(){let Q=this.#N?.querySelector("fig-handle"),Z=this.#K?.querySelector("fig-handle");if(Q){let $=Q.offsetWidth||this.#R*2,J=Q.offsetHeight||this.#R*2;this.#R=Math.max($,J)/2,this.#N.setAttribute("width",$),this.#N.setAttribute("height",J)}if(Z){let $=Z.offsetWidth||this.#P,J=Z.offsetHeight||this.#S;if(this.#J==="spring")this.#P=$,this.#S=J;this.#K.setAttribute("width",$),this.#K.setAttribute("height",J)}}#m(){if(this.#O||!window.ResizeObserver)return;this.#O=new ResizeObserver(()=>{if(this.#h())this.#u()}),this.#O.observe(this)}#h(){if(!this.#_)return!1;let Q=this.#_.getBoundingClientRect(),Z=Math.max(1,Math.round(Q.width||200)),$=Math.max(1,Math.round(Q.height||200)),J=Z!==this.#B||$!==this.#M;return this.#B=Z,this.#M=$,this.#_.setAttribute("viewBox",`0 0 ${Z} ${$}`),J}#d(){let Q=Math.min(0,this.#Q.y,this.#Z.y),Z=Math.max(1,this.#Q.y,this.#Z.y),$=Z-Q||1,J=Math.min(this.#R,Math.max(0,(this.#M-1)/2));return{minVal:Q,maxVal:Z,range:$,pad:J,draw:Math.max(1,this.#M-J*2)}}#p(Q,Z){let{maxVal:$,range:J,pad:j,draw:q}=this.#d();return{x:Q*this.#B,y:j+($-Z)/J*q}}#s(Q,Z){let{maxVal:$,range:J,pad:j,draw:q}=this.#d();return{x:Q/this.#B,y:$-(Z-j)/q*J}}#t={minVal:0,maxVal:1.2,totalTime:1};#r(Q,Z){let J=this.#M-40,{minVal:j,maxVal:q}=this.#t,_=q-j||1;return{x:Q*this.#B,y:20+(1-(Z-j)/_)*J}}#u(){if(this.#h(),this.#J==="spring")this.#j0();else this.#i()}#o(){this.#X?.classList.toggle("is-active",this.#J==="bezier"&&this.#q===1),this.#W?.classList.toggle("is-active",this.#J==="bezier"&&this.#q===2)}#i(){if(this.#D)this.#D.setAttribute("x","0"),this.#D.setAttribute("y","0"),this.#D.setAttribute("width",this.#B),this.#D.setAttribute("height",this.#M);let Q=this.#p(0,0),Z=this.#p(this.#Q.x,this.#Q.y),$=this.#p(this.#Z.x,this.#Z.y),J=this.#p(1,1);for(let[q,_]of[[this.#T,J.y],[this.#H,Q.y]]){if(!q)continue;q.setAttribute("x1","0"),q.setAttribute("y1",_),q.setAttribute("x2",this.#B),q.setAttribute("y2",_)}this.#Y.setAttribute("d",`M${Q.x},${Q.y} C${Z.x},${Z.y} ${$.x},${$.y} ${J.x},${J.y}`),this.#X.setAttribute("x1",Q.x),this.#X.setAttribute("y1",Q.y),this.#X.setAttribute("x2",Z.x),this.#X.setAttribute("y2",Z.y),this.#W.setAttribute("x1",J.x),this.#W.setAttribute("y1",J.y),this.#W.setAttribute("x2",$.x),this.#W.setAttribute("y2",$.y);let j=this.#R;this.#N.setAttribute("x",Z.x-j),this.#N.setAttribute("y",Z.y-j),this.#K.setAttribute("x",$.x-j),this.#K.setAttribute("y",$.y-j),this.#Z0()}#Z0(){if(!this.#_||!this.#N||!this.#K)return;let Q=this.#Q.y>=this.#Z.y?[this.#N,this.#K]:[this.#K,this.#N];for(let Z of Q)this.#_.append(Z)}#j0(){if(this.#D)this.#D.setAttribute("x","0"),this.#D.setAttribute("y","0"),this.#D.setAttribute("width",this.#B),this.#D.setAttribute("height",this.#M);let Q=this.#E();if(!Q.length)return;let Z=Q[Q.length-1].t||1,$=0,J=1;for(let L of Q){if(L.value<$)$=L.value;if(L.value>J)J=L.value}let j=Math.max(Math.abs($-1),Math.abs(J-1),0.01),q=0;this.#t={minVal:1-j-q,maxVal:1+j+q,totalTime:Z};let _=Math.max(0.05,Math.min(0.95,this.#z)),X="";for(let L=0;L<Q.length;L++){let T=Q[L].t/Z*_,R=this.#r(T,Q[L].value);X+=(L===0?"M":"L")+R.x.toFixed(1)+","+R.y.toFixed(1)}let Y=this.#r(_,1),K=this.#r(1,1);if(X+=`L${Y.x.toFixed(1)},${Y.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#Y.setAttribute("d",X),this.#F){let L=this.#r(0,1),T=this.#r(1,1);this.#F.setAttribute("x1",L.x),this.#F.setAttribute("y1",L.y),this.#F.setAttribute("x2",T.x),this.#F.setAttribute("y2",T.y)}let G=this.#q0(Q),N=G.t/Z*_,W=this.#r(N,G.value),O=this.#R;this.#N.setAttribute("x",W.x-O),this.#N.setAttribute("y",W.y-O);let B=this.#r(_,1);this.#K.setAttribute("x",B.x-this.#P/2),this.#K.setAttribute("y",B.y-this.#S/2)}#q0(Q){let Z={t:0,value:1},$=!1;for(let J of Q){if(J.value>=0.99)$=!0;if($&&J.value>Z.value)Z={t:J.t,value:J.value}}return Z}#e(){if(!this.#G)return;this.#G.value=this.#L,this.#n()}#l(){if(!this.#U)return;this.#U.setAttribute("value",this.value)}#J0(Q){let Z=Q.split(",").map(($)=>Number.parseFloat($.trim()));if(Z.length!==4||Z.some(($)=>!Number.isFinite($)))return null;if(Z[0]<0||Z[0]>1||Z[2]<0||Z[2]>1)return null;return Z}#$0(Q,Z){let $=this.#J0(Q);if(!$){if(Z==="change")this.#l();return}let J=this.#J;if(this.#J="bezier",this.#Q.x=$[0],this.#Q.y=$[1],this.#Z.x=$[2],this.#Z.y=$[3],this.#L=this.#A(),J!==this.#J)this.#y();else if(this.#u(),this.#e(),Z==="change")this.#l();this.#Q0(Z)}#a(Q,Z){if(!this.#G)return;for(let $ of this.#G.querySelectorAll("fig-select-option"))if($.value===Q){let J=$.querySelector(':scope > [slot="prepend"]');if(J)J.innerHTML=Z}}#n(){if(!this.#G)return;if(!this.#k())return;let Q=w.curveIcon(this.#Q.x,this.#Q.y,this.#Z.x,this.#Z.y),Z=w.#C(this.#$);this.#a("Custom bezier",Q),this.#a("Custom spring",Z)}#_0(Q){this.#u(),this.#L=this.#A(),this.#e(),this.#l(),this.#Q0(Q)}#G0(Q,Z){let $=Q.shiftKey?0.1:0.01,J=Z===1?this.#Q:this.#Z;switch(Q.key){case"ArrowLeft":J.x-=$;break;case"ArrowRight":J.x+=$;break;case"ArrowUp":J.y+=$;break;case"ArrowDown":J.y-=$;break;case"Home":J.x=0,J.y=0;break;case"End":J.x=1,J.y=1;break;default:return!1}return J.x=Math.max(0,Math.min(1,Math.round(J.x*100)/100)),J.y=Math.round(J.y*100)/100,this.#_0("input"),this.#Q0("change"),!0}#W0(Q,Z){let $=Q.shiftKey?10:1;if(Z==="bounce")switch(Q.key){case"ArrowUp":this.#$.damping=Math.max(1,Math.round(this.#$.damping-$));break;case"ArrowDown":this.#$.damping=Math.max(1,Math.round(this.#$.damping+$));break;case"Home":this.#$.damping=1;break;case"End":this.#$.damping=50;break;default:return!1}else{let J=$*2;switch(Q.key){case"ArrowLeft":this.#z=Math.max(0.05,this.#z-J/200),this.#$.stiffness=Math.max(10,Math.round(this.#$.stiffness+J*1.5));break;case"ArrowRight":this.#z=Math.min(0.95,this.#z+J/200),this.#$.stiffness=Math.max(10,Math.round(this.#$.stiffness-J*1.5));break;case"Home":this.#z=0.05;break;case"End":this.#z=0.95;break;default:return!1}}return this.#_0("input"),this.#Q0("change"),!0}#X0(Q,Z){let $=Q?.querySelector("fig-handle");if(!$)return;$.addEventListener("pointerdown",(J)=>{if(J.preventDefault(),J.stopImmediatePropagation(),this.#J==="bezier")this.#Y0(J,Number(Z));else this.#K0(J,Z)},{capture:!0}),$.addEventListener("keydown",(J)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(J.key))return;if(!(this.#J==="bezier"?this.#G0(J,Number(Z)):this.#W0(J,Z)))return;J.preventDefault(),J.stopImmediatePropagation()},{capture:!0})}#Q0(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#J,value:this.value,cssValue:this.cssValue,preset:this.#L}}))}#U0(){if(this.#_&&this.#J==="bezier"){this.#X0(this.#N,"1"),this.#X0(this.#K,"2"),this.#N.addEventListener("pointerdown",(Z)=>this.#Y0(Z,1)),this.#K.addEventListener("pointerdown",(Z)=>this.#Y0(Z,2));let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#Y0(Z,this.#L0(Z))})}else if(this.#_){this.#X0(this.#N,"bounce"),this.#X0(this.#K,"duration"),this.#N.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#K0(Z,"bounce")}),this.#K.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#K0(Z,"duration")});let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#K0(Z,"duration")})}if(this.#G)this.#G.addEventListener("change",(Q)=>{let Z=Q.detail,$=w.PRESETS.find((J)=>J.name===Z);if(!$)return;if($.type==="bezier"){if($.value)this.#Q.x=$.value[0],this.#Q.y=$.value[1],this.#Z.x=$.value[2],this.#Z.y=$.value[3];if(this.#L=Z,this.#J!=="bezier")this.#J="bezier",this.#y();else if(this.#_)this.#u(),this.#l()}else if($.type==="spring"){if($.spring)this.#$={...$.spring};if(this.#L=Z,this.#J!=="spring")this.#J="spring",this.#y();else if(this.#_)this.#u(),this.#l()}this.#Q0("input"),this.#Q0("change")});if(this.#U)this.#U.addEventListener("input",(Q)=>{Q.stopPropagation();let Z=Q.detail??Q.target?.value;if(typeof Z!=="string")return;this.#$0(Z,"input")}),this.#U.addEventListener("change",(Q)=>{Q.stopPropagation();let Z=Q.detail??Q.target?.value;if(typeof Z!=="string")return;this.#$0(Z,"change")})}#N0(Q){let Z=this.#_.getScreenCTM();if(!Z)return{x:0,y:0};let $=Z.inverse();return{x:$.a*Q.clientX+$.c*Q.clientY+$.e,y:$.b*Q.clientX+$.d*Q.clientY+$.f}}#L0(Q){return this.#N0(Q).x<=this.#B/2?1:2}#Y0(Q,Z){Q.preventDefault(),this.#q=Z,this.#o();let $=this.#_.getBoundingClientRect(),J=Q.clientX,j=Q.clientY,q=Q.target?.closest?.(".fig-easing-curve-handle, fig-handle"),_=Z===1?this.#Q:this.#Z,X=this.#N0(Q),Y=q?{..._}:this.#s(X.x,X.y),{range:K,draw:G}=this.#d(),N=K/Math.max(1,G/this.#M*Math.max(1,$.height)),W=(B)=>{if(!this.#q)return;let L={x:Y.x+(B.clientX-J)/Math.max(1,$.width),y:Y.y-(B.clientY-j)*N};if(L.x=Math.round(L.x*100)/100,L.y=Math.round(L.y*100)/100,L.x=Math.max(0,Math.min(1,L.x)),this.#q===1)this.#Q.x=L.x,this.#Q.y=L.y;else this.#Z.x=L.x,this.#Z.y=L.y;this.#u(),this.#L=this.#A(),this.#e(),this.#l(),this.#Q0("input")},O=()=>{this.#q=null,this.#o(),document.removeEventListener("pointermove",W),document.removeEventListener("pointerup",O),this.#Q0("change")};document.addEventListener("pointermove",W),document.addEventListener("pointerup",O)}#K0(Q,Z){Q.preventDefault(),this.#q=Z,this.classList.toggle("spring-bounce-dragging",Z==="bounce");let $=this.#$.damping,J=this.#$.stiffness,j=this.#z,q=Q.clientY,_=Q.clientX,X=(K)=>{if(!this.#q)return;if(Z==="bounce"){let G=K.clientY-q;this.#$.damping=Math.max(1,Math.round($+G*0.15))}else{let G=K.clientX-_;this.#z=Math.max(0.05,Math.min(0.95,j+G/200)),this.#$.stiffness=Math.max(10,Math.round(J-G*1.5))}this.#u(),this.#L=this.#A(),this.#e(),this.#l(),this.#Q0("input")},Y=()=>{this.#q=null,this.classList.remove("spring-bounce-dragging"),document.removeEventListener("pointermove",X),document.removeEventListener("pointerup",Y),this.#Q0("change")};document.addEventListener("pointermove",X),document.addEventListener("pointerup",Y)}}z("fig-easing-curve",w);class N1 extends HTMLElement{#Q=0;#Z=0;#$=0;#J=1;#j=!1;#q=!1;#_=null;#Y=null;#X=null;#W=null;#N=(Q)=>this.#C(Q);#K=null;#G=[];#U={};#L={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#J=parseInt(this.getAttribute("precision")||"1"),b(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),b(this,"--perspective",this.getAttribute("perspective")),b(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#B(this.getAttribute("transform-origin")),this.#T(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#H(Q);if(this.querySelector(".fig-3d-rotate-container"))this.#F();else this.#O();this.#D(this.getAttribute("selected")),this.#M()}disconnectedCallback(){this.#j=!1,this.#z()}#F(){this.#Y=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#R(),this.#S(),this.#A()}#z(){if(this.#K?.abort(),this.#K=null,this.#X)window.removeEventListener("keydown",this.#X),window.removeEventListener("keyup",this.#W),this.#X=null,this.#W=null}#B(Q){if(!Q||!Q.trim()){this.style.removeProperty("--transform-origin");return}let Z=Q.trim().split(/\s+/);if(Z.length===2)this.style.setProperty("--transform-origin",`${Z[0]} ${Z[1]} -50cqi`);else this.style.setProperty("--transform-origin",Q.trim())}#M(){if(!this.#Y)return;this.#Y.style.cursor=this.#E?"":"default"}#D(Q){if(!this.#_)return;let Z=this.#_.querySelectorAll(".fig-3d-rotate-face"),$=Q?Q.trim().toLowerCase():"";for(let J of Z)J.classList.toggle("selected",$!==""&&J.classList.contains($))}#T(Q){if(!Q||!Q.trim()){this.#G=[];return}let Z=["rotateX","rotateY","rotateZ"];this.#G=Q.split(",").map(($)=>$.trim()).filter(($)=>Z.includes($))}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){b(this,"--aspect-ratio",$);return}if(Q==="perspective"){b(this,"--perspective",$);return}if(Q==="perspective-origin"){b(this,"--perspective-origin",$);return}if(Q==="transform-origin"){this.#B($);return}if(Q==="selected"){this.#D($);return}if(Q==="drag"){this.#M();return}if(Q==="fields"){if(this.#T($),this.#_)this.#O();return}if(!this.#_)return;if(Q==="value"&&$){if(this.#j)return;this.#H($),this.#S(),this.#P()}if(Q==="precision")this.#J=parseInt($||"1")}get value(){let Q=this.#J;return`rotateX(${this.#Q.toFixed(Q)}deg) rotateY(${this.#Z.toFixed(Q)}deg) rotateZ(${this.#$.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#Q}get rotateY(){return this.#Z}get rotateZ(){return this.#$}#H(Q){let Z=Q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),$=Q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),J=Q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if(Z)this.#Q=parseFloat(Z[1]);if($)this.#Z=parseFloat($[1]);if(J)this.#$=parseFloat(J[1])}#O(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},Z={rotateX:this.#Q,rotateY:this.#Z,rotateZ:this.#$},$=this.#G.map((J)=>`<fig-input-number
296
296
  name="${J}"
297
297
  step="1"
298
298
  precision="1"
@@ -310,9 +310,9 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
310
310
  <div class="fig-3d-rotate-face bottom"></div>
311
311
  </div>
312
312
  </div>
313
- </div>${$}`,this.#Y=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#R(),this.#C(),this.#A()}#R(){this.#U={};for(let Q of this.#G){let Z=this.querySelector(`fig-input-number[name="${Q}"]`);if(!Z)continue;if(this.#U[Q]=Z,!this.#L[Q])this.#L[Q]=(J)=>{J.stopPropagation();let j=parseFloat(J.target.value);if(isNaN(j))return;if(Q==="rotateX")this.#Z=j;else if(Q==="rotateY")this.#Q=j;else if(Q==="rotateZ")this.#$=j;this.#C(),this.#S(J.type)};let $=this.#L[Q];Z.removeEventListener("input",$),Z.removeEventListener("change",$),Z.addEventListener("input",$),Z.addEventListener("change",$)}}#P(){let Q={rotateX:this.#Z,rotateY:this.#Q,rotateZ:this.#$};for(let Z of this.#G){let $=this.#U[Z];if($)$.setAttribute("value",Q[Z].toFixed(this.#J))}}#C(){if(!this.#_)return;this.#_.style.transform=`rotateX(${this.#Z}deg) rotateY(${this.#Q}deg) rotateZ(${this.#$}deg)`}#S(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#Z,rotateY:this.#Q,rotateZ:this.#$}}))}#I(Q){if(!this.#q)return Q;return Math.round(Q/15)*15}#A(){if(this.#z(),!this.#Y)return;this.#K=new AbortController,this.#Y.addEventListener("pointerdown",this.#N,{signal:this.#K.signal}),this.#X=(Q)=>{if(Q.key==="Shift")this.#q=!0},this.#W=(Q)=>{if(Q.key==="Shift")this.#q=!1},window.addEventListener("keydown",this.#X),window.addEventListener("keyup",this.#W)}get#k(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#T(Q){if(!this.#k)return;Q.preventDefault(),this.#j=!0,this.#Y.classList.add("dragging"),this.#Y.setPointerCapture(Q.pointerId);let{clientX:Z,clientY:$}=Q,J=this.#Z,j=this.#Q,q=(X)=>{if(!this.#j)return;if(X.buttons===0){_();return}let Y=X.clientX-Z,K=X.clientY-$;this.#Q=this.#I(j+Y*0.5),this.#Z=this.#I(J-K*0.5),this.#C(),this.#P(),this.setAttribute("value",this.value),this.#S("input")},_=()=>{if(!this.#j)return;this.setAttribute("value",this.value),this.#j=!1,this.#Y.classList.remove("dragging"),this.#Y.removeEventListener("pointermove",q),this.#Y.removeEventListener("pointerup",_),this.#Y.removeEventListener("pointercancel",_),this.#Y.removeEventListener("lostpointercapture",_),this.#S("change")};this.#Y.addEventListener("pointermove",q),this.#Y.addEventListener("pointerup",_),this.#Y.addEventListener("pointercancel",_),this.#Y.addEventListener("lostpointercapture",_)}}z("fig-3d-rotate",N1);class F0 extends HTMLElement{#Z=50;#Q=50;#$=0;#J=null;#j=[];#q=null;#_=null;#Y=null;#X=!1;#W=!1;#N=null;#K=null;#G=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.#J=this.querySelector(".origin-grid"),this.#j=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#Y=this.querySelector('fig-input-number[name="y"]'),this.#C(),this.#S(),this.#O(),this.#m()}connectedCallback(){if(this.#$=parseInt(this.getAttribute("precision")||"0"),b(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#E(this.getAttribute("value")),this.querySelector(".fig-origin-grid-surface"))this.#U();else this.#H();this.#z(),this.#R()}disconnectedCallback(){this.#X=!1,this.#V(),this.#u()}get value(){let Q=this.#$;return`${this.#Z.toFixed(Q)}% ${this.#Q.toFixed(Q)}%`}set value(Q){this.setAttribute("value",Q)}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){b(this,"--aspect-ratio",$);return}if(Q==="drag"){this.#z();return}if(Q==="fields"){this.#H(),this.#z(),this.#R();return}if(Q==="precision"){this.#$=parseInt($||"0"),this.#O(),this.#R();return}if(Q==="value"){if(this.#W||this.#X)return;this.#E($),this.#C(),this.#S(),this.#O()}}get#L(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}get#F(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#z(){if(!this.#J)return;this.#J.classList.toggle("drag-disabled",!this.#L)}#B(Q){return Math.max(0,Math.min(100,Q))}#M(Q,Z){let $=(Q||"").trim().toLowerCase();if(!$)return Z==="x"?this.#Z:this.#Q;let J=Z==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if($ in J)return J[$];let j=Number.parseFloat($.replace("%",""));if(Number.isFinite(j))return j;return Z==="x"?this.#Z:this.#Q}#D(Q){let Z=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if(Z.length<1)return;if(Z.length===1){let $=this.#M(Z[0],"x");this.#Z=$,this.#Q=$;return}this.#Z=this.#M(Z[0],"x"),this.#Q=this.#M(Z[1],"y")}#E(Q){let Z=typeof Q==="string"?Q.trim():"";if(!Z){this.#Z=50,this.#Q=50;return}this.#D(Z)}#H(){let Q=Array.from({length:9},(j,q)=>{let _=q%3,X=Math.floor(q/3);return`<span class="origin-grid-cell" data-col="${_}" data-row="${X}">
313
+ </div>${$}`,this.#Y=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#R(),this.#S(),this.#A()}#R(){this.#U={};for(let Q of this.#G){let Z=this.querySelector(`fig-input-number[name="${Q}"]`);if(!Z)continue;if(this.#U[Q]=Z,!this.#L[Q])this.#L[Q]=(J)=>{J.stopPropagation();let j=parseFloat(J.target.value);if(isNaN(j))return;if(Q==="rotateX")this.#Q=j;else if(Q==="rotateY")this.#Z=j;else if(Q==="rotateZ")this.#$=j;this.#S(),this.#f(J.type)};let $=this.#L[Q];Z.removeEventListener("input",$),Z.removeEventListener("change",$),Z.addEventListener("input",$),Z.addEventListener("change",$)}}#P(){let Q={rotateX:this.#Q,rotateY:this.#Z,rotateZ:this.#$};for(let Z of this.#G){let $=this.#U[Z];if($)$.setAttribute("value",Q[Z].toFixed(this.#J))}}#S(){if(!this.#_)return;this.#_.style.transform=`rotateX(${this.#Q}deg) rotateY(${this.#Z}deg) rotateZ(${this.#$}deg)`}#f(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#Q,rotateY:this.#Z,rotateZ:this.#$}}))}#I(Q){if(!this.#q)return Q;return Math.round(Q/15)*15}#A(){if(this.#z(),!this.#Y)return;this.#K=new AbortController,this.#Y.addEventListener("pointerdown",this.#N,{signal:this.#K.signal}),this.#X=(Q)=>{if(Q.key==="Shift")this.#q=!0},this.#W=(Q)=>{if(Q.key==="Shift")this.#q=!1},window.addEventListener("keydown",this.#X),window.addEventListener("keyup",this.#W)}get#E(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#C(Q){if(!this.#E)return;Q.preventDefault(),this.#j=!0,this.#Y.classList.add("dragging"),this.#Y.setPointerCapture(Q.pointerId);let{clientX:Z,clientY:$}=Q,J=this.#Q,j=this.#Z,q=(X)=>{if(!this.#j)return;if(X.buttons===0){_();return}let Y=X.clientX-Z,K=X.clientY-$;this.#Z=this.#I(j+Y*0.5),this.#Q=this.#I(J-K*0.5),this.#S(),this.#P(),this.setAttribute("value",this.value),this.#f("input")},_=()=>{if(!this.#j)return;this.setAttribute("value",this.value),this.#j=!1,this.#Y.classList.remove("dragging"),this.#Y.removeEventListener("pointermove",q),this.#Y.removeEventListener("pointerup",_),this.#Y.removeEventListener("pointercancel",_),this.#Y.removeEventListener("lostpointercapture",_),this.#f("change")};this.#Y.addEventListener("pointermove",q),this.#Y.addEventListener("pointerup",_),this.#Y.addEventListener("pointercancel",_),this.#Y.addEventListener("lostpointercapture",_)}}z("fig-3d-rotate",N1);class F0 extends HTMLElement{#Q=50;#Z=50;#$=0;#J=null;#j=[];#q=null;#_=null;#Y=null;#X=!1;#W=!1;#N=null;#K=null;#G=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.#J=this.querySelector(".origin-grid"),this.#j=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#Y=this.querySelector('fig-input-number[name="y"]'),this.#S(),this.#f(),this.#O(),this.#m()}connectedCallback(){if(this.#$=parseInt(this.getAttribute("precision")||"0"),b(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#T(this.getAttribute("value")),this.querySelector(".fig-origin-grid-surface"))this.#U();else this.#H();this.#z(),this.#R()}disconnectedCallback(){this.#X=!1,this.#V(),this.#c()}get value(){let Q=this.#$;return`${this.#Q.toFixed(Q)}% ${this.#Z.toFixed(Q)}%`}set value(Q){this.setAttribute("value",Q)}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){b(this,"--aspect-ratio",$);return}if(Q==="drag"){this.#z();return}if(Q==="fields"){this.#H(),this.#z(),this.#R();return}if(Q==="precision"){this.#$=parseInt($||"0"),this.#O(),this.#R();return}if(Q==="value"){if(this.#W||this.#X)return;this.#T($),this.#S(),this.#f(),this.#O()}}get#L(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}get#F(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#z(){if(!this.#J)return;this.#J.classList.toggle("drag-disabled",!this.#L)}#B(Q){return Math.max(0,Math.min(100,Q))}#M(Q,Z){let $=(Q||"").trim().toLowerCase();if(!$)return Z==="x"?this.#Q:this.#Z;let J=Z==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if($ in J)return J[$];let j=Number.parseFloat($.replace("%",""));if(Number.isFinite(j))return j;return Z==="x"?this.#Q:this.#Z}#D(Q){let Z=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if(Z.length<1)return;if(Z.length===1){let $=this.#M(Z[0],"x");this.#Q=$,this.#Z=$;return}this.#Q=this.#M(Z[0],"x"),this.#Z=this.#M(Z[1],"y")}#T(Q){let Z=typeof Q==="string"?Q.trim():"";if(!Z){this.#Q=50,this.#Z=50;return}this.#D(Z)}#H(){let Q=Array.from({length:9},(j,q)=>{let _=q%3,X=Math.floor(q/3);return`<span class="origin-grid-cell" data-col="${_}" data-row="${X}">
314
314
  <span class="origin-grid-dot"></span>
315
- </span>`}).join(""),Z=this.#Z.toFixed(this.#$),$=this.#Q.toFixed(this.#$),J=this.#F?`<div class="origin-values">
315
+ </span>`}).join(""),Z=this.#Q.toFixed(this.#$),$=this.#Z.toFixed(this.#$),J=this.#F?`<div class="origin-values">
316
316
  <fig-input-number name="x" value="${Z}" step="1" units="%"><span slot="prepend">X</span></fig-input-number>
317
317
  <fig-input-number name="y" value="${$}" step="1" units="%"><span slot="prepend">Y</span></fig-input-number>
318
318
  </div>`:"";this.innerHTML=`<div class="fig-origin-grid-surface">
@@ -321,7 +321,7 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
321
321
  <fig-handle></fig-handle>
322
322
  </div>
323
323
  </div>
324
- ${J}`,this.#J=this.querySelector(".origin-grid"),this.#j=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#Y=this.querySelector('fig-input-number[name="y"]'),this.#C(),this.#S(),this.#O(),this.#m()}#O(){let Q=this.#Z.toFixed(this.#$),Z=this.#Q.toFixed(this.#$);if(this.#_)this.#_.setAttribute("value",Q);if(this.#Y)this.#Y.setAttribute("value",Z)}#R(){let Q=this.value;if(this.getAttribute("value")===Q)return;this.#W=!0,this.setAttribute("value",Q),this.#W=!1}#P(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#Z,y:this.#Q}}))}#C(){if(!this.#q)return;let Q=(Z)=>16.6667+this.#B(Z)/100*66.6667;this.#q.style.left=`${Q(this.#Z)}%`,this.#q.style.top=`${Q(this.#Q)}%`}#S(){if(!this.#q)return;let Q=this.#Z<0||this.#Z>100,Z=this.#Q<0||this.#Q>100,$=this.#Z<0,J=this.#Z>100,j=this.#Q<0,q=this.#Q>100;this.#q.classList.toggle("beyond-bounds-x",Q),this.#q.classList.toggle("beyond-bounds-y",Z),this.#q.classList.toggle("overflow-left",$),this.#q.classList.toggle("overflow-right",J),this.#q.classList.toggle("overflow-up",j),this.#q.classList.toggle("overflow-down",q)}#I(Q,Z){if(!this.#J)return null;let $=this.#J.getBoundingClientRect(),J=(Q-$.left)/Math.max($.width,1),j=(Z-$.top)/Math.max($.height,1);if(J<0||J>1||j<0||j>1)return null;let q=Math.max(0,Math.min(2,Math.floor(J*3))),_=Math.max(0,Math.min(2,Math.floor(j*3)));return this.#j.find((X)=>Number(X.getAttribute("data-col"))===q&&Number(X.getAttribute("data-row"))===_)}#A(){for(let Q of this.#j)Q.classList.remove("is-hovered")}#k(Q){if(this.#A(),Q)Q.classList.add("is-hovered")}#T(Q,Z,$){let J=Number(Q),j=Number(Z);if(!Number.isFinite(J)||!Number.isFinite(j))return;if(J===this.#Z&&j===this.#Q&&$==="input")return;this.#Z=J,this.#Q=j,this.#C(),this.#S(),this.#O(),this.#R(),this.#P($)}#f(Q,Z){if(!this.#J)return{x:this.#Z,y:this.#Q};let $=this.#J.getBoundingClientRect(),J=$.width/6,j=$.height/6,q=Math.max(1,$.width-J*2),_=Math.max(1,$.height-j*2),X=(Q-($.left+J))/q,Y=(Z-($.top+j))/_;return{x:X*100,y:Y*100}}#y(Q,Z){if(!this.#J)return{x:50,y:50};let $=this.#J.getBoundingClientRect(),J=(Q-$.left)/Math.max($.width,1)*3,j=(Z-$.top)/Math.max($.height,1)*3,q=Math.max(0,Math.min(2,Math.floor(J))),_=Math.max(0,Math.min(2,Math.floor(j)));return{x:q*50,y:_*50}}#g(Q){let $=Q,J=1/0;for(let j of F0.SNAP_POINTS){let q=Math.abs(Q-j);if(q<J)J=q,$=j}return J<=2.5?$:Q}#h(Q,Z){if(!Z)return Q;return{x:this.#g(Q.x),y:this.#g(Q.y)}}#w(Q){if(!this.#L)return!1;let Z=Q.shiftKey?10:1,$=this.#Z,J=this.#Q;switch(Q.key){case"ArrowLeft":$-=Z;break;case"ArrowRight":$+=Z;break;case"ArrowUp":J-=Z;break;case"ArrowDown":J+=Z;break;case"Home":$=0,J=0;break;case"End":$=100,J=100;break;default:return!1}return this.#T(this.#B($),this.#B(J),"input"),this.#P("change"),!0}#V(){if(!this.#J||!this.#K||!this.#G)return;this.#J.removeEventListener("pointermove",this.#K),this.#J.removeEventListener("pointerup",this.#G),this.#J.removeEventListener("pointercancel",this.#G),this.#J.removeEventListener("lostpointercapture",this.#G),this.#K=null,this.#G=null}#b(Q){if(!this.#J||!this.#L)return;Q.preventDefault(),this.#X=!0,this.#N=Q.pointerId;let{clientX:Z,clientY:$}=Q,J=3,j=!1;this.#J.setPointerCapture(Q.pointerId),this.#K=(q)=>{if(!this.#X||q.pointerId!==this.#N)return;let _=q.clientX-Z,X=q.clientY-$,Y=Math.hypot(_,X);if(!j&&Y<J)return;if(!j)j=!0,this.#J.classList.add("is-dragging"),this.#A();let K=this.#h(this.#f(q.clientX,q.clientY),q.shiftKey);this.#T(K.x,K.y,"input")},this.#G=(q)=>{if(!this.#X||q.pointerId!==this.#N)return;if(this.#X=!1,this.#N=null,this.#J.classList.remove("is-dragging"),this.#A(),this.#V(),!j){let _=this.#y(Z,$);this.#T(_.x,_.y,"input")}this.#P("change")},this.#J.addEventListener("pointermove",this.#K),this.#J.addEventListener("pointerup",this.#G),this.#J.addEventListener("pointercancel",this.#G),this.#J.addEventListener("lostpointercapture",this.#G)}#x=null;#u(){this.#x?.abort(),this.#x=null}#m(){if(this.#u(),!this.#J||!this.#q)return;this.#x=new AbortController;let{signal:Q}=this.#x;this.#J.addEventListener("pointerdown",($)=>{let J=this.#I($.clientX,$.clientY);if(this.#k(J),this.#L){this.#b($);return}let j=this.#y($.clientX,$.clientY);this.#T(j.x,j.y,"input"),this.#P("change")},{signal:Q}),this.#J.addEventListener("pointermove",($)=>{if(this.#X)return;let J=this.#I($.clientX,$.clientY);this.#k(J)},{signal:Q}),this.#J.addEventListener("pointerleave",()=>{this.#A()},{signal:Q}),this.#q.addEventListener("keydown",($)=>{if(!this.#w($))return;$.preventDefault(),$.stopPropagation()},{signal:Q});let Z=($,J)=>{if(!$)return;let j=(q)=>{let _=Number.parseFloat(q.target.value);if(!Number.isFinite(_))return;if(J==="x")this.#T(_,this.#Q,"input");else this.#T(this.#Z,_,"input")};$.addEventListener("input",j,{signal:Q}),$.addEventListener("change",j,{signal:Q}),$.addEventListener("focusout",()=>{this.#P("change")},{signal:Q})};Z(this.#_,"x"),Z(this.#Y,"y")}}z("fig-origin-grid",F0);class W1 extends HTMLElement{#Z=null;#Q=null;#$=null;#J=null;#j=null;#q=null;#_=null;#Y=null;#X=!1;#W={x:0.5,y:0.5};#N=!1;constructor(){super();this.position={x:0.5,y:0.5},this.isDragging=!1,this.plane=null,this.cursor=null,this.xInput=null,this.yInput=null,this.coordinates="screen",this.#Z=(Q)=>this.#R(Q),this.#Q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#$=(Q)=>this.#P(Q),this.#J=()=>this.#C(),this.#j=(Q)=>this.#D(Q),this.#q=(Q)=>this.#E(Q),this.#_=()=>this.#H(),this.#Y=()=>this.#H()}#K(){this.#B(),this.#A(),this.#T(),this.#f(),this.#N=!0}connectedCallback(){c(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",b(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");if(this.querySelector(".fig-input-joystick-plane")){this.#K();return}this.#L(),this.#B(),this.#A(),this.#T(),this.#f(),this.#N=!0})}#G(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#M()}get#U(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#L(){this.innerHTML=this.#z()}#F(){let Q=(this.getAttribute("axis-labels")||"").trim();if(!Q)return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1};let Z=Q.split(/[\s,]+/).filter(Boolean);if(Z.length===1)return{left:"",right:"",top:Z[0],bottom:"",leftNoRotate:!1};if(Z.length===2){let[$,J]=Z;return{left:$,right:"",top:"",bottom:J,leftNoRotate:!0}}if(Z.length===4){let[$,J,j,q]=Z;return{left:$,right:J,top:j,bottom:q,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#z(){let Q=this.#F();return`
324
+ ${J}`,this.#J=this.querySelector(".origin-grid"),this.#j=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#Y=this.querySelector('fig-input-number[name="y"]'),this.#S(),this.#f(),this.#O(),this.#m()}#O(){let Q=this.#Q.toFixed(this.#$),Z=this.#Z.toFixed(this.#$);if(this.#_)this.#_.setAttribute("value",Q);if(this.#Y)this.#Y.setAttribute("value",Z)}#R(){let Q=this.value;if(this.getAttribute("value")===Q)return;this.#W=!0,this.setAttribute("value",Q),this.#W=!1}#P(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#Q,y:this.#Z}}))}#S(){if(!this.#q)return;let Q=(Z)=>16.6667+this.#B(Z)/100*66.6667;this.#q.style.left=`${Q(this.#Q)}%`,this.#q.style.top=`${Q(this.#Z)}%`}#f(){if(!this.#q)return;let Q=this.#Q<0||this.#Q>100,Z=this.#Z<0||this.#Z>100,$=this.#Q<0,J=this.#Q>100,j=this.#Z<0,q=this.#Z>100;this.#q.classList.toggle("beyond-bounds-x",Q),this.#q.classList.toggle("beyond-bounds-y",Z),this.#q.classList.toggle("overflow-left",$),this.#q.classList.toggle("overflow-right",J),this.#q.classList.toggle("overflow-up",j),this.#q.classList.toggle("overflow-down",q)}#I(Q,Z){if(!this.#J)return null;let $=this.#J.getBoundingClientRect(),J=(Q-$.left)/Math.max($.width,1),j=(Z-$.top)/Math.max($.height,1);if(J<0||J>1||j<0||j>1)return null;let q=Math.max(0,Math.min(2,Math.floor(J*3))),_=Math.max(0,Math.min(2,Math.floor(j*3)));return this.#j.find((X)=>Number(X.getAttribute("data-col"))===q&&Number(X.getAttribute("data-row"))===_)}#A(){for(let Q of this.#j)Q.classList.remove("is-hovered")}#E(Q){if(this.#A(),Q)Q.classList.add("is-hovered")}#C(Q,Z,$){let J=Number(Q),j=Number(Z);if(!Number.isFinite(J)||!Number.isFinite(j))return;if(J===this.#Q&&j===this.#Z&&$==="input")return;this.#Q=J,this.#Z=j,this.#S(),this.#f(),this.#O(),this.#R(),this.#P($)}#k(Q,Z){if(!this.#J)return{x:this.#Q,y:this.#Z};let $=this.#J.getBoundingClientRect(),J=$.width/6,j=$.height/6,q=Math.max(1,$.width-J*2),_=Math.max(1,$.height-j*2),X=(Q-($.left+J))/q,Y=(Z-($.top+j))/_;return{x:X*100,y:Y*100}}#y(Q,Z){if(!this.#J)return{x:50,y:50};let $=this.#J.getBoundingClientRect(),J=(Q-$.left)/Math.max($.width,1)*3,j=(Z-$.top)/Math.max($.height,1)*3,q=Math.max(0,Math.min(2,Math.floor(J))),_=Math.max(0,Math.min(2,Math.floor(j)));return{x:q*50,y:_*50}}#v(Q){let $=Q,J=1/0;for(let j of F0.SNAP_POINTS){let q=Math.abs(Q-j);if(q<J)J=q,$=j}return J<=2.5?$:Q}#b(Q,Z){if(!Z)return Q;return{x:this.#v(Q.x),y:this.#v(Q.y)}}#w(Q){if(!this.#L)return!1;let Z=Q.shiftKey?10:1,$=this.#Q,J=this.#Z;switch(Q.key){case"ArrowLeft":$-=Z;break;case"ArrowRight":$+=Z;break;case"ArrowUp":J-=Z;break;case"ArrowDown":J+=Z;break;case"Home":$=0,J=0;break;case"End":$=100,J=100;break;default:return!1}return this.#C(this.#B($),this.#B(J),"input"),this.#P("change"),!0}#V(){if(!this.#J||!this.#K||!this.#G)return;this.#J.removeEventListener("pointermove",this.#K),this.#J.removeEventListener("pointerup",this.#G),this.#J.removeEventListener("pointercancel",this.#G),this.#J.removeEventListener("lostpointercapture",this.#G),this.#K=null,this.#G=null}#g(Q){if(!this.#J||!this.#L)return;Q.preventDefault(),this.#X=!0,this.#N=Q.pointerId;let{clientX:Z,clientY:$}=Q,J=3,j=!1;this.#J.setPointerCapture(Q.pointerId),this.#K=(q)=>{if(!this.#X||q.pointerId!==this.#N)return;let _=q.clientX-Z,X=q.clientY-$,Y=Math.hypot(_,X);if(!j&&Y<J)return;if(!j)j=!0,this.#J.classList.add("is-dragging"),this.#A();let K=this.#b(this.#k(q.clientX,q.clientY),q.shiftKey);this.#C(K.x,K.y,"input")},this.#G=(q)=>{if(!this.#X||q.pointerId!==this.#N)return;if(this.#X=!1,this.#N=null,this.#J.classList.remove("is-dragging"),this.#A(),this.#V(),!j){let _=this.#y(Z,$);this.#C(_.x,_.y,"input")}this.#P("change")},this.#J.addEventListener("pointermove",this.#K),this.#J.addEventListener("pointerup",this.#G),this.#J.addEventListener("pointercancel",this.#G),this.#J.addEventListener("lostpointercapture",this.#G)}#x=null;#c(){this.#x?.abort(),this.#x=null}#m(){if(this.#c(),!this.#J||!this.#q)return;this.#x=new AbortController;let{signal:Q}=this.#x;this.#J.addEventListener("pointerdown",($)=>{let J=this.#I($.clientX,$.clientY);if(this.#E(J),this.#L){this.#g($);return}let j=this.#y($.clientX,$.clientY);this.#C(j.x,j.y,"input"),this.#P("change")},{signal:Q}),this.#J.addEventListener("pointermove",($)=>{if(this.#X)return;let J=this.#I($.clientX,$.clientY);this.#E(J)},{signal:Q}),this.#J.addEventListener("pointerleave",()=>{this.#A()},{signal:Q}),this.#q.addEventListener("keydown",($)=>{if(!this.#w($))return;$.preventDefault(),$.stopPropagation()},{signal:Q});let Z=($,J)=>{if(!$)return;let j=(q)=>{let _=Number.parseFloat(q.target.value);if(!Number.isFinite(_))return;if(J==="x")this.#C(_,this.#Z,"input");else this.#C(this.#Q,_,"input")};$.addEventListener("input",j,{signal:Q}),$.addEventListener("change",j,{signal:Q}),$.addEventListener("focusout",()=>{this.#P("change")},{signal:Q})};Z(this.#_,"x"),Z(this.#Y,"y")}}z("fig-origin-grid",F0);class W1 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#_=null;#Y=null;#X=!1;#W={x:0.5,y:0.5};#N=!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.#Q=(Q)=>this.#R(Q),this.#Z=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#$=(Q)=>this.#P(Q),this.#J=()=>this.#S(),this.#j=(Q)=>this.#D(Q),this.#q=(Q)=>this.#T(Q),this.#_=()=>this.#H(),this.#Y=()=>this.#H()}#K(){this.#B(),this.#A(),this.#C(),this.#k(),this.#N=!0}connectedCallback(){c(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",b(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");if(this.querySelector(".fig-input-joystick-plane")){this.#K();return}this.#L(),this.#B(),this.#A(),this.#C(),this.#k(),this.#N=!0})}#G(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#M()}get#U(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#L(){this.innerHTML=this.#z()}#F(){let Q=(this.getAttribute("axis-labels")||"").trim();if(!Q)return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1};let Z=Q.split(/[\s,]+/).filter(Boolean);if(Z.length===1)return{left:"",right:"",top:Z[0],bottom:"",leftNoRotate:!1};if(Z.length===2){let[$,J]=Z;return{left:$,right:"",top:"",bottom:J,leftNoRotate:!0}}if(Z.length===4){let[$,J,j,q]=Z;return{left:$,right:J,top:j,bottom:q,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#z(){let Q=this.#F();return`
325
325
  <div class="fig-input-joystick-plane-container">
326
326
  ${[Q.left?`<label class="fig-joystick-axis-label left${Q.leftNoRotate?" no-rotate":""}" aria-hidden="true">${Q.left}</label>`:"",Q.right?`<label class="fig-joystick-axis-label right" aria-hidden="true">${Q.right}</label>`:"",Q.top?`<label class="fig-joystick-axis-label top" aria-hidden="true">${Q.top}</label>`:"",Q.bottom?`<label class="fig-joystick-axis-label bottom" aria-hidden="true">${Q.bottom}</label>`:""].join("")}
327
327
  <div class="fig-input-joystick-plane">
@@ -354,11 +354,11 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
354
354
  <span slot="prepend">Y</span>
355
355
  </fig-input-number>
356
356
  </div>`:""}
357
- `}#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.#Q),this.cursor?.addEventListener("input",this.#$),this.cursor?.addEventListener("change",this.#J);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#y());if(this.#U&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#j),this.xInput.addEventListener("change",this.#j),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#q),this.yInput.addEventListener("change",this.#q),this.yInput.addEventListener("focusout",this.#Y)}#M(){if(this.plane?.removeEventListener("pointerdown",this.#Z),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#$),this.cursor?.removeEventListener("change",this.#J),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#U&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#j),this.xInput.removeEventListener("change",this.#j),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#q),this.yInput.removeEventListener("change",this.#q),this.yInput.removeEventListener("focusout",this.#Y)}#D(Q){let Z=Number.parseFloat(Q.target.value);if(!Number.isFinite(Z))return;this.position.x=Math.max(0,Math.min(1,Z/100)),this.#A(),this.#T(),this.#S()}#E(Q){let Z=Number.parseFloat(Q.target.value);if(!Number.isFinite(Z))return;this.position.y=Math.max(0,Math.min(1,Z/100)),this.#A(),this.#T(),this.#S()}#H(){this.#T(),this.#I()}#O(Q,Z,{syncHandle:$=!0}={}){let J=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,Z)),q=this.coordinates==="math"?1-j:j;if(this.position={x:J,y:q},$)this.#A();this.#k(),this.#T()}#R(Q){if(!this.plane||!this.cursor)return;if(Q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let Z=this.plane.getBoundingClientRect(),$=Z.width>0?(Q.clientX-Z.left)/Z.width:0.5,J=Z.height>0?(Q.clientY-Z.top)/Z.height:0.5;this.cursor.value=`${Math.round($*100)}% ${Math.round(J*100)}%`,this.#O($,J,{syncHandle:!1}),this.#S(),this.#I()}#P(Q){let Z=Q.detail??{};if(typeof Z.px!=="number"||typeof Z.py!=="number")return;this.#O(Z.px,Z.py,{syncHandle:!1}),this.#S()}#C(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#T(),this.#I()}#S(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#I(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#A(){let Q=this.#G(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;this.#k()}#k(){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))}#T(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#X=!0,this.setAttribute("value",Q),this.#X=!1;this.#f()}#f(){let Q=this.#W,Z=Math.round(this.position.x*100)===Math.round(Q.x*100)&&Math.round(this.position.y*100)===Math.round(Q.y*100);this.toggleAttribute("default",Z),this.style.setProperty("--is-not-default",Z?"0":"1")}#y(){this.position={...this.#W},this.#A(),this.#T(),this.#S(),this.#I()}focus(){this.cursor?.focus()}static get observedAttributes(){return["value","precision","transform","fields","coordinates","aspect-ratio","axis-labels"]}get value(){return`${Math.round(this.position.x*100)}% ${Math.round(this.position.y*100)}%`}set value(Q){let Z=Q==null?"":String(Q).trim();if(!Z)this.position={x:0.5,y:0.5};else{let $=Z.split(/[\s,]+/).filter(Boolean),J=(_)=>{if(!_)return 0.5;let X=_.includes("%"),Y=Number.parseFloat(_.replace(/%/g,"").trim());if(!Number.isFinite(Y))return 0.5;let K=X||Math.abs(Y)>1?Y/100:Y;return Math.max(0,Math.min(1,K))},j=J($[0]),q=J($[1]??$[0]);this.position={x:j,y:q}}if(this.#N)this.#A(),this.#f()}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){b(this,"--aspect-ratio",$);return}if(Q==="value"){if(this.#X||this.isDragging)return;this.value=$}if(Q==="precision")this.precision=parseInt($);if(Q==="transform")this.transform=Number($);if(Q==="fields"&&$!==Z)this.#M(),this.#L(),this.#B(),this.#A();if(Q==="axis-labels"&&$!==Z)this.#M(),this.#L(),this.#B(),this.#A();if(Q==="coordinates")this.coordinates=$||"screen",this.#A()}}z("fig-joystick",W1);class z0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let Q=this.getAttribute("duration");if(Q)this.style.setProperty(this.durationPropertyName,Q);this.#Z()}static get observedAttributes(){return["duration","playing","aria-label","aria-labelledby"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(Q,Z,$){if(Q==="duration")this.style.setProperty(this.durationPropertyName,$||"1.5s");if(Q==="playing"||Q==="aria-label"||Q==="aria-labelledby")this.#Z()}#Z(){let Q=this.playing;if(this.setAttribute("aria-busy",Q?"true":"false"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")){if(!this.hasAttribute("role"))this.setAttribute("role","status");this.removeAttribute("aria-hidden")}else this.removeAttribute("role"),this.setAttribute("aria-hidden","true")}}z("fig-shimmer",z0);class U1 extends z0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}z("fig-skeleton",U1);class L1 extends HTMLElement{static observedAttributes=["name","collapsible","open"];#Z=null;#Q=null;connectedCallback(){this.#j()}disconnectedCallback(){if(this.#Q)this.#Q.removeEventListener("click",this.#$);if(this.#Z)this.#Z.removeEventListener("click",this.#$),this.#Z.removeEventListener("keydown",this.#J),this.#Z.querySelector("h3")?.removeEventListener("click",this.#$)}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){this.#Z?.setAttribute("aria-expanded",String(this.open));return}this.#j()}get open(){let Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){let Z=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#Z?.setAttribute("aria-expanded",String(!!Q)),Z!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}#$=(Q)=>{Q.stopPropagation(),this.open=!this.open};#J=(Q)=>{if(Q.key!=="Enter"&&Q.key!==" ")return;Q.preventDefault(),Q.stopPropagation(),this.open=!this.open};#j(){let Q=this.hasAttribute("collapsible"),$=this.getAttribute("name")||(Q?"Group":null),J=this.querySelector(":scope > fig-header");if(!$&&!Q&&!J){if(this.#Z&&this.#Z.dataset.generated)this.#Z.remove(),this.#Z=null,this.#Q=null;return}if(J)this.#Z=J;else if(!this.#Z||!this.#Z.dataset.generated)this.#Z=document.createElement("fig-header"),this.#Z.setAttribute("borderless",""),this.#Z.dataset.generated="true",this.prepend(this.#Z);let j=this.#Z.querySelector("h3");if(!j)j=document.createElement("h3"),this.#Z.prepend(j);if(!j.id)j.id=g();if(this.#Z.dataset.generated)j.textContent=$;if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",j.id);if(Q){if(!j.querySelector(".fig-group-chevron")){let q=u("chevron",{size:"small",className:"fig-group-chevron"});j.prepend(q)}if(this.#Q=j.querySelector(".fig-group-chevron"),j.removeEventListener("click",this.#$),this.#Z.removeEventListener("click",this.#$),this.#Z.addEventListener("click",this.#$),this.#Z.setAttribute("role","button"),this.#Z.setAttribute("tabindex","0"),this.#Z.setAttribute("aria-expanded",String(this.open)),this.#Z.removeEventListener("keydown",this.#J),this.#Z.addEventListener("keydown",this.#J),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Z.setAttribute("aria-expanded","false")}else{if(j.removeEventListener("click",this.#$),this.#Z.removeEventListener("click",this.#$),this.#Z.removeAttribute("role"),this.#Z.removeAttribute("tabindex"),this.#Z.removeAttribute("aria-expanded"),this.#Z.removeEventListener("keydown",this.#J),this.#Q)this.#Q.remove(),this.#Q=null;this.removeAttribute("open")}}}z("fig-group",L1);class B1 extends HTMLElement{}z("fig-header",B1);class M1 extends HTMLElement{}z("fig-footer",M1);class O1 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")}}z("fig-spinner",O1);class F1 extends HTMLElement{static get observedAttributes(){return["fit"]}connectedCallback(){this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="fit")this.#Z()}#Z(){let Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-preview-fit",Q);else this.style.removeProperty("--fig-preview-fit")}}z("fig-preview",F1);class C extends HTMLElement{static#Z=new Set(["oklch","hsl"]);static#Q=10;static#$=10;static#J=8;static#j=3;static#q=210;static#_={type:"linear",angle:135,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{color:"#FF0000",position:0,opacity:100},{color:"#4F9EFF",position:100,opacity:100}]};#Y=!1;#X=null;#W=null;#N={...C.#_};static get observedAttributes(){return["value"]}get value(){return{type:"gradient",gradient:{...this.#N}}}set value(Q){if(Q==null||Q===""){this.removeAttribute("value");return}if(typeof Q==="string"){this.setAttribute("value",Q);return}this.setAttribute("value",JSON.stringify(Q))}connectedCallback(){this.#K(),this.#G(),this.#P(),this.#C()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q!=="value")return;if(this.#G(),this.#Y)this.#C()}#K(){if(!(this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby"))&&!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}#G(){let Q=this.getAttribute("value");if(!Q){this.#N={...C.#_,stops:C.#_.stops.map((Z)=>({...Z}))};return}try{let Z=JSON.parse(Q),$=Z?.type==="gradient"&&Z.gradient?Z.gradient:Z?.gradient?Z.gradient:Z;if(!$||typeof $!=="object")return;this.#N=this.#U({...C.#_,...$})}catch{}}#U(Q){let Z={...Q??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase(),J=String(Z.hueInterpolation??"shorter").toLowerCase(),j=Array.isArray(Z.stops)?Z.stops.map((q)=>({color:String(q?.color||"#D9D9D9").replace(/^(#(?:[0-9a-f]{6})).*/i,"$1"),position:q?.position??0,opacity:q?.opacity??100})):C.#_.stops.map((q)=>({...q}));if(j.length<2)return{...C.#_,stops:C.#_.stops.map((q)=>({...q}))};return{type:["linear","radial","angular"].includes(Z.type)?Z.type:"linear",angle:Number.isFinite(Number(Z.angle))?Number(Z.angle):135,interpolationSpace:$,hueInterpolation:J,stops:j}}#L(){return C.#Z.has(this.#N.interpolationSpace||"srgb")}#F(Q){let{r:Z,g:$,b:J}=r(Q);if(this.#N.interpolationSpace==="hsl")return B0(Z,$,J).h;let j=e(Z,$,J);return(L0(j.l,j.a,j.b).h%360+360)%360}#z(){let Q=this.#H(),Z=this.#F(Q[0]?.color||"#FF0000"),$=this.#F(Q[Q.length-1]?.color||"#4F9EFF"),J=C.#q-Z,q=((C.#q-$-J)%360+360)%360,_=q===0?0:q-360,X=this.#N.hueInterpolation||"shorter",Y;if(X==="increasing")Y=_;else if(X==="decreasing")Y=q;else if(X==="longer")Y=q<180?_:q;else Y=q<=180?q:_;let K=Math.sign(Y),G=Math.asin(C.#j/2/C.#J)*180/Math.PI,N=Math.min(G,Math.max(0,(Math.abs(Y)-0.01)/2));return{startDeg:J+K*N,sweepDeg:Y-K*N*2}}#B(Q){let Z=Q*Math.PI/180;return{x:C.#Q+C.#J*Math.cos(Z),y:C.#$+C.#J*Math.sin(Z)}}#M(Q,Z){let $=Q+Z,J=this.#B(Q),j=this.#B($),q=Math.abs(Z)>180?1:0,_=Z>=0?1:0;return`M ${J.x} ${J.y} A ${C.#J} ${C.#J} 0 ${q} ${_} ${j.x} ${j.y}`}#D(){let Q=this.#B(180),Z=this.#B(0);return`M ${Q.x} ${Q.y} L ${Z.x} ${Z.y}`}#E(Q){let Z=C.#j,$=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none"><path d="${Q}" fill="none" stroke="white" stroke-width="${Z}" stroke-linecap="round" stroke-linejoin="round"/></svg>`;return`url("data:image/svg+xml,${encodeURIComponent($)}")`}#H(){return[...this.#N.stops].sort((Q,Z)=>(Q.position??0)-(Z.position??0))}#O(){let Q=this.#N.interpolationSpace||"srgb";if(Q==="srgb")return"";if(C.#Z.has(Q))return` in ${Q} ${this.#N.hueInterpolation||"shorter"} hue`;return` in ${Q}`}#R(){let Q=this.#H(),Z=this.#O();if(this.#L()){let J=(C.#q+90)%360,j=this.#N.interpolationSpace,q=(X)=>j==="oklch"?`oklch(65% 0.25 ${X})`:`hsl(${X} 100% 50%)`,_=[0,300,240,180,120,60,0].map(q).join(", ");return`conic-gradient(from ${J}deg in ${j} decreasing hue, ${_})`}let $=Q.map((J)=>`${J.color} ${J.position??0}%`).join(", ");return`linear-gradient(90deg${Z}, ${$})`}#P(){if(this.#Y)return;let Q=C.#j;this.innerHTML=`
357
+ `}#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.#Q),this.cursor?.addEventListener("pointerdown",this.#Z),this.cursor?.addEventListener("input",this.#$),this.cursor?.addEventListener("change",this.#J);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#y());if(this.#U&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#j),this.xInput.addEventListener("change",this.#j),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#q),this.yInput.addEventListener("change",this.#q),this.yInput.addEventListener("focusout",this.#Y)}#M(){if(this.plane?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("pointerdown",this.#Z),this.cursor?.removeEventListener("input",this.#$),this.cursor?.removeEventListener("change",this.#J),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#U&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#j),this.xInput.removeEventListener("change",this.#j),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#q),this.yInput.removeEventListener("change",this.#q),this.yInput.removeEventListener("focusout",this.#Y)}#D(Q){let Z=Number.parseFloat(Q.target.value);if(!Number.isFinite(Z))return;this.position.x=Math.max(0,Math.min(1,Z/100)),this.#A(),this.#C(),this.#f()}#T(Q){let Z=Number.parseFloat(Q.target.value);if(!Number.isFinite(Z))return;this.position.y=Math.max(0,Math.min(1,Z/100)),this.#A(),this.#C(),this.#f()}#H(){this.#C(),this.#I()}#O(Q,Z,{syncHandle:$=!0}={}){let J=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,Z)),q=this.coordinates==="math"?1-j:j;if(this.position={x:J,y:q},$)this.#A();this.#E(),this.#C()}#R(Q){if(!this.plane||!this.cursor)return;if(Q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let Z=this.plane.getBoundingClientRect(),$=Z.width>0?(Q.clientX-Z.left)/Z.width:0.5,J=Z.height>0?(Q.clientY-Z.top)/Z.height:0.5;this.cursor.value=`${Math.round($*100)}% ${Math.round(J*100)}%`,this.#O($,J,{syncHandle:!1}),this.#f(),this.#I()}#P(Q){let Z=Q.detail??{};if(typeof Z.px!=="number"||typeof Z.py!=="number")return;this.#O(Z.px,Z.py,{syncHandle:!1}),this.#f()}#S(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#C(),this.#I()}#f(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#I(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#A(){let Q=this.#G(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;this.#E()}#E(){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))}#C(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#X=!0,this.setAttribute("value",Q),this.#X=!1;this.#k()}#k(){let Q=this.#W,Z=Math.round(this.position.x*100)===Math.round(Q.x*100)&&Math.round(this.position.y*100)===Math.round(Q.y*100);this.toggleAttribute("default",Z),this.style.setProperty("--is-not-default",Z?"0":"1")}#y(){this.position={...this.#W},this.#A(),this.#C(),this.#f(),this.#I()}focus(){this.cursor?.focus()}static get observedAttributes(){return["value","precision","transform","fields","coordinates","aspect-ratio","axis-labels"]}get value(){return`${Math.round(this.position.x*100)}% ${Math.round(this.position.y*100)}%`}set value(Q){let Z=Q==null?"":String(Q).trim();if(!Z)this.position={x:0.5,y:0.5};else{let $=Z.split(/[\s,]+/).filter(Boolean),J=(_)=>{if(!_)return 0.5;let X=_.includes("%"),Y=Number.parseFloat(_.replace(/%/g,"").trim());if(!Number.isFinite(Y))return 0.5;let K=X||Math.abs(Y)>1?Y/100:Y;return Math.max(0,Math.min(1,K))},j=J($[0]),q=J($[1]??$[0]);this.position={x:j,y:q}}if(this.#N)this.#A(),this.#k()}attributeChangedCallback(Q,Z,$){if(Q==="aspect-ratio"){b(this,"--aspect-ratio",$);return}if(Q==="value"){if(this.#X||this.isDragging)return;this.value=$}if(Q==="precision")this.precision=parseInt($);if(Q==="transform")this.transform=Number($);if(Q==="fields"&&$!==Z)this.#M(),this.#L(),this.#B(),this.#A();if(Q==="axis-labels"&&$!==Z)this.#M(),this.#L(),this.#B(),this.#A();if(Q==="coordinates")this.coordinates=$||"screen",this.#A()}}z("fig-joystick",W1);class z0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let Q=this.getAttribute("duration");if(Q)this.style.setProperty(this.durationPropertyName,Q);this.#Q()}static get observedAttributes(){return["duration","playing","aria-label","aria-labelledby"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(Q,Z,$){if(Q==="duration")this.style.setProperty(this.durationPropertyName,$||"1.5s");if(Q==="playing"||Q==="aria-label"||Q==="aria-labelledby")this.#Q()}#Q(){let Q=this.playing;if(this.setAttribute("aria-busy",Q?"true":"false"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")){if(!this.hasAttribute("role"))this.setAttribute("role","status");this.removeAttribute("aria-hidden")}else this.removeAttribute("role"),this.setAttribute("aria-hidden","true")}}z("fig-shimmer",z0);class U1 extends z0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}z("fig-skeleton",U1);class L1 extends HTMLElement{static observedAttributes=["name","collapsible","open"];#Q=null;#Z=null;connectedCallback(){this.#j()}disconnectedCallback(){if(this.#Z)this.#Z.removeEventListener("click",this.#$);if(this.#Q)this.#Q.removeEventListener("click",this.#$),this.#Q.removeEventListener("keydown",this.#J),this.#Q.querySelector("h3")?.removeEventListener("click",this.#$)}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){this.#Q?.setAttribute("aria-expanded",String(this.open));return}this.#j()}get open(){let Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){let Z=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#Q?.setAttribute("aria-expanded",String(!!Q)),Z!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}#$=(Q)=>{Q.stopPropagation(),this.open=!this.open};#J=(Q)=>{if(Q.key!=="Enter"&&Q.key!==" ")return;Q.preventDefault(),Q.stopPropagation(),this.open=!this.open};#j(){let Q=this.hasAttribute("collapsible"),$=this.getAttribute("name")||(Q?"Group":null),J=this.querySelector(":scope > fig-header");if(!$&&!Q&&!J){if(this.#Q&&this.#Q.dataset.generated)this.#Q.remove(),this.#Q=null,this.#Z=null;return}if(J)this.#Q=J;else if(!this.#Q||!this.#Q.dataset.generated)this.#Q=document.createElement("fig-header"),this.#Q.setAttribute("borderless",""),this.#Q.dataset.generated="true",this.prepend(this.#Q);let j=this.#Q.querySelector("h3");if(!j)j=document.createElement("h3"),this.#Q.prepend(j);if(!j.id)j.id=h();if(this.#Q.dataset.generated)j.textContent=$;if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",j.id);if(Q){if(!j.querySelector(".fig-group-chevron")){let q=u("chevron",{size:"small",className:"fig-group-chevron"});j.prepend(q)}if(this.#Z=j.querySelector(".fig-group-chevron"),j.removeEventListener("click",this.#$),this.#Q.removeEventListener("click",this.#$),this.#Q.addEventListener("click",this.#$),this.#Q.setAttribute("role","button"),this.#Q.setAttribute("tabindex","0"),this.#Q.setAttribute("aria-expanded",String(this.open)),this.#Q.removeEventListener("keydown",this.#J),this.#Q.addEventListener("keydown",this.#J),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Q.setAttribute("aria-expanded","false")}else{if(j.removeEventListener("click",this.#$),this.#Q.removeEventListener("click",this.#$),this.#Q.removeAttribute("role"),this.#Q.removeAttribute("tabindex"),this.#Q.removeAttribute("aria-expanded"),this.#Q.removeEventListener("keydown",this.#J),this.#Z)this.#Z.remove(),this.#Z=null;this.removeAttribute("open")}}}z("fig-group",L1);class B1 extends HTMLElement{}z("fig-header",B1);class M1 extends HTMLElement{}z("fig-footer",M1);class O1 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")}}z("fig-spinner",O1);class F1 extends HTMLElement{static get observedAttributes(){return["fit"]}connectedCallback(){this.#Q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="fit")this.#Q()}#Q(){let Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-preview-fit",Q);else this.style.removeProperty("--fig-preview-fit")}}z("fig-preview",F1);class C extends HTMLElement{static#Q=new Set(["oklch","hsl"]);static#Z=10;static#$=10;static#J=8;static#j=3;static#q=210;static#_={type:"linear",angle:135,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{color:"#FF0000",position:0,opacity:100},{color:"#4F9EFF",position:100,opacity:100}]};#Y=!1;#X=null;#W=null;#N={...C.#_};static get observedAttributes(){return["value"]}get value(){return{type:"gradient",gradient:{...this.#N}}}set value(Q){if(Q==null||Q===""){this.removeAttribute("value");return}if(typeof Q==="string"){this.setAttribute("value",Q);return}this.setAttribute("value",JSON.stringify(Q))}connectedCallback(){this.#K(),this.#G(),this.#P(),this.#S()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q!=="value")return;if(this.#G(),this.#Y)this.#S()}#K(){if(!(this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby"))&&!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}#G(){let Q=this.getAttribute("value");if(!Q){this.#N={...C.#_,stops:C.#_.stops.map((Z)=>({...Z}))};return}try{let Z=JSON.parse(Q),$=Z?.type==="gradient"&&Z.gradient?Z.gradient:Z?.gradient?Z.gradient:Z;if(!$||typeof $!=="object")return;this.#N=this.#U({...C.#_,...$})}catch{}}#U(Q){let Z={...Q??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase(),J=String(Z.hueInterpolation??"shorter").toLowerCase(),j=Array.isArray(Z.stops)?Z.stops.map((q)=>({color:String(q?.color||"#D9D9D9").replace(/^(#(?:[0-9a-f]{6})).*/i,"$1"),position:q?.position??0,opacity:q?.opacity??100})):C.#_.stops.map((q)=>({...q}));if(j.length<2)return{...C.#_,stops:C.#_.stops.map((q)=>({...q}))};return{type:["linear","radial","angular"].includes(Z.type)?Z.type:"linear",angle:Number.isFinite(Number(Z.angle))?Number(Z.angle):135,interpolationSpace:$,hueInterpolation:J,stops:j}}#L(){return C.#Q.has(this.#N.interpolationSpace||"srgb")}#F(Q){let{r:Z,g:$,b:J}=r(Q);if(this.#N.interpolationSpace==="hsl")return B0(Z,$,J).h;let j=e(Z,$,J);return(L0(j.l,j.a,j.b).h%360+360)%360}#z(){let Q=this.#H(),Z=this.#F(Q[0]?.color||"#FF0000"),$=this.#F(Q[Q.length-1]?.color||"#4F9EFF"),J=C.#q-Z,q=((C.#q-$-J)%360+360)%360,_=q===0?0:q-360,X=this.#N.hueInterpolation||"shorter",Y;if(X==="increasing")Y=_;else if(X==="decreasing")Y=q;else if(X==="longer")Y=q<180?_:q;else Y=q<=180?q:_;let K=Math.sign(Y),G=Math.asin(C.#j/2/C.#J)*180/Math.PI,N=Math.min(G,Math.max(0,(Math.abs(Y)-0.01)/2));return{startDeg:J+K*N,sweepDeg:Y-K*N*2}}#B(Q){let Z=Q*Math.PI/180;return{x:C.#Z+C.#J*Math.cos(Z),y:C.#$+C.#J*Math.sin(Z)}}#M(Q,Z){let $=Q+Z,J=this.#B(Q),j=this.#B($),q=Math.abs(Z)>180?1:0,_=Z>=0?1:0;return`M ${J.x} ${J.y} A ${C.#J} ${C.#J} 0 ${q} ${_} ${j.x} ${j.y}`}#D(){let Q=this.#B(180),Z=this.#B(0);return`M ${Q.x} ${Q.y} L ${Z.x} ${Z.y}`}#T(Q){let Z=C.#j,$=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none"><path d="${Q}" fill="none" stroke="white" stroke-width="${Z}" stroke-linecap="round" stroke-linejoin="round"/></svg>`;return`url("data:image/svg+xml,${encodeURIComponent($)}")`}#H(){return[...this.#N.stops].sort((Q,Z)=>(Q.position??0)-(Z.position??0))}#O(){let Q=this.#N.interpolationSpace||"srgb";if(Q==="srgb")return"";if(C.#Q.has(Q))return` in ${Q} ${this.#N.hueInterpolation||"shorter"} hue`;return` in ${Q}`}#R(){let Q=this.#H(),Z=this.#O();if(this.#L()){let J=(C.#q+90)%360,j=this.#N.interpolationSpace,q=(X)=>j==="oklch"?`oklch(65% 0.25 ${X})`:`hsl(${X} 100% 50%)`,_=[0,300,240,180,120,60,0].map(q).join(", ");return`conic-gradient(from ${J}deg in ${j} decreasing hue, ${_})`}let $=Q.map((J)=>`${J.color} ${J.position??0}%`).join(", ");return`linear-gradient(90deg${Z}, ${$})`}#P(){if(this.#Y)return;let Q=C.#j;this.innerHTML=`
358
358
  <svg class="fig-interpolation-swatch-svg" width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
359
359
  <circle class="fig-interpolation-swatch-rim" cx="10" cy="10" r="8" fill="none" stroke="currentColor" stroke-width="${Q}"/>
360
360
  </svg>
361
361
  <div class="fig-interpolation-swatch-fill" aria-hidden="true"></div>
362
- `,this.#X=this.querySelector(".fig-interpolation-swatch-svg"),this.#W=this.querySelector(".fig-interpolation-swatch-fill"),this.#Y=!0}#C(){if(!this.#W)return;let Q=this.#L();if(this.#X)this.#X.style.display=Q?"":"none";let Z=Q?(()=>{let{startDeg:J,sweepDeg:j}=this.#z();return this.#M(J,j)})():this.#D(),$=this.#E(Z);this.#W.style.setProperty("-webkit-mask-image",$),this.#W.style.maskImage=$,this.#W.style.background=this.#R()}}z("fig-interpolation-swatch",C);var l1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:{medium:"--icon-24-reset",small:"--icon-16-reset"},"arrow-left":{medium:"--icon-24-arrow-left",small:"--icon-16-arrow-left"},steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",adjust:{medium:"--icon-24-adjust",small:"--icon-16-adjust"},minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",download:"--icon-24-download",upload:"--icon-24-upload",sun:"--icon-24-sun",moon:"--icon-24-moon",edit:{medium:"--icon-24-edit",small:"--icon-16-edit"},settings:{medium:"--icon-24-settings",small:"--icon-16-settings"},more:{medium:"--icon-24-more",small:"--icon-16-more"},visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function a1(Q,Z="medium"){let $=Q&&l1[Q];if(!$)return"";let J=typeof $==="string"?$:$[Z==="small"?"small":"medium"];return J?`var(${J})`:""}class z1 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#Z()}attributeChangedCallback(Q,Z,$){if(Z!==$)this.#Z()}#Z(){let Q=this.getAttribute("name"),Z=this.getAttribute("size")||"medium",$=a1(Q,Z);if($)this.style.setProperty("--icon",$);else this.style.removeProperty("--icon");if(Z==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let J=this.getAttribute("color");if(J)this.style.backgroundColor=J;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}z("fig-icon",z1);class H1 extends HTMLElement{}z("fig-content",H1);class A1 extends HTMLElement{}z("fig-tab-content",A1);class R1 extends HTMLElement{}z("fig-button-combo",R1);class D1 extends HTMLElement{}z("fig-input-combo",D1);class T1 extends HTMLElement{#Z=null;#Q=null;#$=null;#J=this.#B.bind(this);#j=this.#M.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#q(){return this.getAttribute("control")||"color"}connectedCallback(){this.#W(),this.#L()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#N)}#_(){if(this.#Z)this.#Z.removeEventListener("input",this.#J),this.#Z.removeEventListener("change",this.#j);if(this.#Q)this.#Q.removeEventListener("input",this.#J),this.#Q.removeEventListener("change",this.#j);if(this.#$)this.#$.disconnect(),this.#$=null}#Y(){if(this.#$)this.#$.disconnect(),this.#$=null;if(!this.#Q)return;this.#$=new MutationObserver(()=>{if(this.#Q?.hasAttribute("selected")&&this.#Q.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#$.observe(this.#Q,{attributes:!0,attributeFilter:["selected"]})}get#X(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#W(){let Q=this.#q;if(Q==="add"||Q==="remove"){let X=Q==="add"?"add":"minus",Y=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");this.innerHTML=`<fig-button icon variant="ghost" aria-label="${v(Y)}"><fig-icon name="${X}"></fig-icon></fig-button>`,this.#Z=null,this.#Q=null,this.addEventListener("click",this.#N),this.#F();return}this.removeEventListener("click",this.#N);let Z=(this.getAttribute("value")||"").trim(),$=this.#U(Z),J=this.#G(Z),j=this.#X?"":'alpha="false"',q=J<1?JSON.stringify({type:"solid",color:$,opacity:Math.round(J*100)}):JSON.stringify({type:"solid",color:$}),_=J<1?` alpha="${J}"`:"";if(this.innerHTML=o()?`<fig-fill-picker mode="solid" ${j} value='${q}'>
362
+ `,this.#X=this.querySelector(".fig-interpolation-swatch-svg"),this.#W=this.querySelector(".fig-interpolation-swatch-fill"),this.#Y=!0}#S(){if(!this.#W)return;let Q=this.#L();if(this.#X)this.#X.style.display=Q?"":"none";let Z=Q?(()=>{let{startDeg:J,sweepDeg:j}=this.#z();return this.#M(J,j)})():this.#D(),$=this.#T(Z);this.#W.style.setProperty("-webkit-mask-image",$),this.#W.style.maskImage=$,this.#W.style.background=this.#R()}}z("fig-interpolation-swatch",C);var l1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:{medium:"--icon-24-reset",small:"--icon-16-reset"},"arrow-left":{medium:"--icon-24-arrow-left",small:"--icon-16-arrow-left"},steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",adjust:{medium:"--icon-24-adjust",small:"--icon-16-adjust"},minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",download:"--icon-24-download",upload:"--icon-24-upload",sun:"--icon-24-sun",moon:"--icon-24-moon",edit:{medium:"--icon-24-edit",small:"--icon-16-edit"},settings:{medium:"--icon-24-settings",small:"--icon-16-settings"},more:{medium:"--icon-24-more",small:"--icon-16-more"},visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function a1(Q,Z="medium"){let $=Q&&l1[Q];if(!$)return"";let J=typeof $==="string"?$:$[Z==="small"?"small":"medium"];return J?`var(${J})`:""}class z1 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#Q()}attributeChangedCallback(Q,Z,$){if(Z!==$)this.#Q()}#Q(){let Q=this.getAttribute("name"),Z=this.getAttribute("size")||"medium",$=a1(Q,Z);if($)this.style.setProperty("--icon",$);else this.style.removeProperty("--icon");if(Z==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let J=this.getAttribute("color");if(J)this.style.backgroundColor=J;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}z("fig-icon",z1);class H1 extends HTMLElement{}z("fig-content",H1);class A1 extends HTMLElement{}z("fig-tab-content",A1);class R1 extends HTMLElement{}z("fig-button-combo",R1);class D1 extends HTMLElement{}z("fig-input-combo",D1);class T1 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=this.#B.bind(this);#j=this.#M.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#q(){return this.getAttribute("control")||"color"}connectedCallback(){this.#W(),this.#L()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#N)}#_(){if(this.#Q)this.#Q.removeEventListener("input",this.#J),this.#Q.removeEventListener("change",this.#j);if(this.#Z)this.#Z.removeEventListener("input",this.#J),this.#Z.removeEventListener("change",this.#j);if(this.#$)this.#$.disconnect(),this.#$=null}#Y(){if(this.#$)this.#$.disconnect(),this.#$=null;if(!this.#Z)return;this.#$=new MutationObserver(()=>{if(this.#Z?.hasAttribute("selected")&&this.#Z.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#$.observe(this.#Z,{attributes:!0,attributeFilter:["selected"]})}get#X(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#W(){let Q=this.#q;if(Q==="add"||Q==="remove"){let X=Q==="add"?"add":"minus",Y=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");this.innerHTML=`<fig-button icon variant="ghost" aria-label="${v(Y)}"><fig-icon name="${X}"></fig-icon></fig-button>`,this.#Q=null,this.#Z=null,this.addEventListener("click",this.#N),this.#F();return}this.removeEventListener("click",this.#N);let Z=(this.getAttribute("value")||"").trim(),$=this.#U(Z),J=this.#G(Z),j=this.#X?"":'alpha="false"',q=J<1?JSON.stringify({type:"solid",color:$,opacity:Math.round(J*100)}):JSON.stringify({type:"solid",color:$}),_=J<1?` alpha="${J}"`:"";if(this.innerHTML=o()?`<fig-fill-picker mode="solid" ${j} value='${q}'>
363
363
  <fig-swatch background="${$}"${_}></fig-swatch>
364
- </fig-fill-picker>`:`<fig-swatch background="${$}"${_}></fig-swatch>`,this.#Z=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-swatch"),this.#_(),this.#Z?.addEventListener("input",this.#J),this.#Z?.addEventListener("change",this.#j),!this.#Z)this.#Q?.addEventListener("input",this.#J),this.#Q?.addEventListener("change",this.#j);this.#Y(),this.#F()}#N=()=>{let Q=this.#q;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#K(Q){if(!Q)return"#D9D9D9";let Z=Q.replace("#","").trim();if(Z.length===3||Z.length===4){let[$,J,j]=Z;return`#${$}${$}${J}${J}${j}${j}`.toUpperCase()}if(Z.length===6||Z.length===8)return`#${Z.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#G(Q){if(!Q)return 1;let Z=String(Q).trim(),$=Z.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test($)){let j=$[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test($))return parseInt($.slice(6,8),16)/255;let J=Z.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(J)return parseFloat(J[1]);return 1}#U(Q){if(!Q)return"#D9D9D9";let Z=String(Q).trim();if(Z.startsWith("{"))try{let $=JSON.parse(Z);if($?.color)return this.#U($.color)}catch{}if(Z.startsWith("#"))return this.#K(Z);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Z))return this.#K(Z);try{let{ctx:$}=O0(1,1);$.fillStyle="#000000",$.fillStyle=Z;let J=$.fillStyle;if(J.startsWith("#"))return this.#K(J);let j=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let q=(_)=>Math.max(0,Math.min(255,Number(_))).toString(16).padStart(2,"0");return`#${q(j[1])}${q(j[2])}${q(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#L(){let Q=this.getAttribute("value"),Z=this.#U(Q),$=this.#G(Q);if(Q!==Z&&$>=1){this.setAttribute("value",Z);return}if(this.#Z){this.#F();let J=$<1?{type:"solid",color:Z,opacity:Math.round($*100)}:{type:"solid",color:Z};if(this.#Z.setAttribute("value",JSON.stringify(J)),this.#X)this.#Z.removeAttribute("alpha");else this.#Z.setAttribute("alpha","false");if(F(this,"disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}if(this.#Q){if(this.#F(),this.#Q.setAttribute("background",Z),$<1)this.#Q.setAttribute("alpha",String($));else this.#Q.removeAttribute("alpha");if(F(this,"disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}}#F(){let Q=this.#q,Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",Z?"true":"false"),this.setAttribute("aria-pressed",$?"true":"false"),Q==="add"||Q==="remove"){let X=this.querySelector("fig-button"),Y=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");if(X?.setAttribute("aria-label",Y),Z)X?.setAttribute("disabled","");else X?.removeAttribute("disabled");return}let J=this.#Z||this.#Q;if(!J)return;let j=this.getAttribute("aria-label")||"Color stop",q=this.getAttribute("aria-labelledby"),_=this.getAttribute("aria-describedby");if(q)J.setAttribute("aria-labelledby",q),J.removeAttribute("aria-label");else J.setAttribute("aria-label",j),J.removeAttribute("aria-labelledby");if(_)J.setAttribute("aria-describedby",_);else J.removeAttribute("aria-describedby")}#z(Q,Z){let $=this.#U(Q?.color),J=this.#U(this.getAttribute("value"));if($!==J)this.setAttribute("value",$);else this.#L();let j={color:this.value};if(this.#X){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent(Z,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#B(Q){Q.stopPropagation(),this.#z(Q.detail||{color:Q.target?.value},"input")}#M(Q){Q.stopPropagation(),this.#z(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(!this.isConnected)return;switch(Q){case"control":this.#W();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#L(),this.#F();break}}get value(){return this.#U(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#U(Q))}get selected(){return F(this,"selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return F(this,"disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}z("fig-color-tip",T1);class P1 extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",F(this,"selected")?"true":"false"),F(this,"disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",F(this,"selected")?"true":"false");if(Q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}z("fig-choice",P1);class E1 extends HTMLElement{#Z=null;#Q=this.#D.bind(this);#$=this.#E.bind(this);#J=this.#O.bind(this);#j=null;#q=null;#_=null;#Y=null;#X=null;#W=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#N(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#K(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#G(){return this.getAttribute("choice-element")||"fig-choice"}#U(){let Q=this.getAttribute("columns"),Z=Q===null?NaN:Number(Q);if(Number.isInteger(Z)&&Z>0)this.style.setProperty("--fig-chooser-grid-columns",String(Z));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from(this.querySelectorAll(`:scope > ${this.#G}`))}get selectedChoice(){return this.#Z}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let Z=this.choices;for(let J of Z){let j=J===Q,q=F(J,"selected");if(j&&!q)J.setAttribute("selected","");else if(!j&&q)J.removeAttribute("selected")}this.#Z=Q;let $=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==$){if($)this.setAttribute("value",$)}this.#y(Q)}get value(){return this.#Z?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){if(this.setAttribute("role","listbox"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.#S(),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#$),this.addEventListener("scroll",this.#J),this.#I(),this.#P(),this.#g(),this.#R(),this.#z(),c(this,()=>{this.#F(),this.#O(),this.#L()})}#L(){let Q=()=>{if(!this.isConnected)return;if(this.#Z)this.#y(this.#Z,"auto")},Z=()=>{let $=this.querySelectorAll("img, video");for(let J of $){if(J.tagName==="IMG"?J.complete:J.readyState>=1)continue;let j=()=>{J.removeEventListener("load",j),J.removeEventListener("loadedmetadata",j),J.removeEventListener("error",j),Q()};J.addEventListener("load",j),J.addEventListener("loadedmetadata",j),J.addEventListener("error",j)}};requestAnimationFrame(()=>{Z(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#$),this.removeEventListener("scroll",this.#J),this.#C(),this.#j?.disconnect(),this.#j=null,this.#q?.disconnect(),this.#q=null,this.#A()}attributeChangedCallback(Q,Z,$){if(Q==="value"&&$!==Z&&$)this.#B($);if(Q==="disabled")this.#z();if(Q==="choice-element")requestAnimationFrame(()=>this.#F());if(Q==="columns")this.#U(),this.#f();if(Q==="drag")if(this.#K)this.#P();else this.#C();if(Q==="overflow")this.#I(),requestAnimationFrame(()=>this.#O());if(Q==="layout"){if(this.#I(),$==="horizontal")this.scrollTop=0;else this.scrollLeft=0;this.#f()}}#F(){let Q=this.choices;if(!Q.length){this.#Z=null;return}let Z=this.getAttribute("value");if(Z&&this.#B(Z))return;let $=Q.find((J)=>F(J,"selected"));if($){this.selectedChoice=$;return}this.selectedChoice=Q[0]}#z(){let Q=F(this,"disabled");if(Q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Z of this.choices)if(Q||F(Z,"disabled"))Z.setAttribute("aria-disabled","true"),Z.setAttribute("tabindex","-1");else Z.removeAttribute("aria-disabled"),Z.setAttribute("tabindex","0")}#B(Q){let Z=this.choices;for(let $ of Z)if($.getAttribute("value")===Q)return this.selectedChoice=$,!0;return!1}#M(Q){let Z=this.#G,$=Q;while($&&$!==this){if($.matches(Z))return $;$=$.parentElement}return null}#D(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#M(Q.target);if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.selectedChoice=Z,this.#H()}#E(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!Z.length)return;let $=Z.indexOf(this.#Z),J=$,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),$<Z.length-1)J=$+1;else if(j)J=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),$>0)J=$-1;else if(j)J=Z.length-1;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#G)){let q=this.#M(document.activeElement);if(q&&q!==this.#Z)this.selectedChoice=q,this.#H()}return;default:return}if(J!==$&&Z[J])this.selectedChoice=Z[J],Z[J].focus(),this.#H()}#H(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#O(){if(this.#N==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal";a(this,this,Q?"x":"y")}#R(){this.#q?.disconnect(),this.#q=new ResizeObserver(()=>{this.#O(),this.#f()}),this.#q.observe(this)}#P(){if(this.#X?.bound)return;if(!this.#K)return;let Q=(q)=>{if(q.button!==0)return;if(q.target.closest("[data-fig-chooser-nav]"))return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#X.active=!0,this.#X.didDrag=!1,this.#X.startX=q.clientX,this.#X.startY=q.clientY,this.#X.scrollLeft=this.scrollLeft,this.#X.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Z=(q)=>{if(!this.#X.active)return;let _=this.getAttribute("layout")==="horizontal",X=q.clientX-this.#X.startX,Y=q.clientY-this.#X.startY;if(!this.#X.didDrag&&Math.abs(_?X:Y)>3)this.#X.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(q.pointerId);if(!this.#X.didDrag)return;if(_)this.scrollLeft=this.#X.scrollLeft-X;else this.scrollTop=this.#X.scrollTop-Y},$=(q)=>{if(!this.#X.active)return;let _=this.#X.didDrag;if(this.#X.active=!1,this.#X.didDrag=!1,this.style.cursor="",this.style.userSelect="",q.pointerId!==void 0)try{this.releasePointerCapture(q.pointerId)}catch{}if(_)q.preventDefault(),q.stopPropagation()},J=(q)=>{if(this.#X?.suppressClick)q.stopPropagation(),q.preventDefault(),this.#X.suppressClick=!1},j=(q)=>{if(this.#X?.didDrag)this.#X.suppressClick=!0,setTimeout(()=>{if(this.#X)this.#X.suppressClick=!1},0)};this.#X={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:Q,onPointerMove:Z,onPointerUp:$,onClick:J,onPointerUpCapture:j},this.addEventListener("pointerdown",Q),window.addEventListener("pointermove",Z),window.addEventListener("pointerup",$),this.addEventListener("pointerup",j,!0),this.addEventListener("click",J,!0)}#C(){if(!this.#X?.bound)return;this.removeEventListener("pointerdown",this.#X.onPointerDown),window.removeEventListener("pointermove",this.#X.onPointerMove),window.removeEventListener("pointerup",this.#X.onPointerUp),this.removeEventListener("pointerup",this.#X.onPointerUpCapture,!0),this.removeEventListener("click",this.#X.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#X=null}#S(){if(this.#W)return;let Q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!Q)return;this.#W=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#W=!1}}#I(){if(this.#N==="scrollbar")this.#A();else this.#k()}#A(){this.#_?.remove(),this.#Y?.remove(),this.#_=null,this.#Y=null,this.classList.remove("overflow-start","overflow-end")}#k(){if(this.#_&&this.#Y&&this.contains(this.#_)&&this.contains(this.#Y))return;this.#_?.remove(),this.#Y?.remove(),this.#_=null,this.#Y=null;let Q=X0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#T(-1),onEnd:()=>this.#T(1)});this.#_=Q.start,this.#Y=Q.end,this.prepend(this.#_),this.append(this.#Y)}#T(Q){let Z=this.getAttribute("layout")==="horizontal";i(this,Z?"x":"y",Q)}#f(){if(!this.#Z)return;this.#y(this.#Z,"auto")}#y(Q,Z="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let $=this.scrollHeight>this.clientHeight,J=this.scrollWidth>this.clientWidth;if(!J&&!$)return;let j=Q.getBoundingClientRect(),q=this.getBoundingClientRect(),_={behavior:Z},X=!1;if($){let Y=j.top-q.top+this.scrollTop,K=this.scrollHeight-this.clientHeight;_.top=Math.max(0,Math.min(Y+j.height/2-this.clientHeight/2,K)),X=!0}if(J){let Y=j.left-q.left+this.scrollLeft,K=this.scrollWidth-this.clientWidth;_.left=Math.max(0,Math.min(Y+j.width/2-this.clientWidth/2,K)),X=!0}if(X)this.scrollTo(_);this.#O()})}#g(){this.#j?.disconnect(),this.#j=new MutationObserver(()=>{if(this.#W)return;this.#S(),this.#I(),this.#z();let Q=this.choices;if(this.#Z&&!Q.includes(this.#Z))this.#Z=null,this.#F();else if(!this.#Z&&Q.length)this.#F();requestAnimationFrame(()=>this.#O())}),this.#j.observe(this,{childList:!0,subtree:!1})}}z("fig-chooser",E1);class C1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#Z=!1;#Q=!1;#$=null;#J=null;#j=!1;#q=null;#_=null;#Y=null;#X=null;get#W(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#N(){return!this.hasAttribute("data-no-color-picker")}get#K(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#G(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#U(){let Q=this.getAttribute("drag-snapping");if(Q===null)return"false";let Z=Q.trim().toLowerCase();if(Z==="modifier")return"modifier";if(Z===""||Z==="true")return"true";return"false"}#L(Q){let Z=this.#U;if(Z==="true")return!0;if(Z==="modifier")return!!Q;return!1}#F(Q){if(Q<0.1)return 0;if(Q>0.9)return 1;if(Q>0.4&&Q<0.6)return 0.5;return Q}#z(Q,Z){if(Math.abs(Q-Z)<0.1){let J=(Q+Z)/2;return{x:J,y:J}}if(Math.abs(1-Q-Z)<0.1)return{x:Q,y:1-Q};return{x:Q,y:Z}}#B(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#B();if(!Q)return"0% 0%";let{px:Z,py:$}=this.#n(Q.getBoundingClientRect());return`${Math.round(Z*100)}% ${Math.round($*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#M(Q){let Z=Q==null?"":String(Q).trim();if(!Z)return{xPct:0,yPct:0};let $=Z.split(/[\s,]+/).filter(Boolean),J=(_)=>{if(!_)return 0;let X=_.includes("px"),Y=_.includes("%"),K=parseFloat(_.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(X)return{px:K};if(Y||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},j=J($[0]),q=J($[1]??$[0]);return{xToken:j,yToken:q}}#D(Q){let Z=this.#B();if(!Z)return;let{xToken:$,yToken:J}=this.#M(Q),j=Z.getBoundingClientRect(),q=(Y,K)=>{if(Y&&typeof Y==="object"&&"px"in Y)return Math.max(0,Math.min(K,Y.px));return null},_=(Y)=>{return`${typeof Y==="number"?Y:0}%`},X=this.#G;if(this.#E(X),X.x){let Y=q($,j.width);this.style.left=Y===null?_($):`${Math.round(Y)}px`}if(X.y){let Y=q(J,j.height);this.style.top=Y===null?_(J):`${Math.round(Y)}px`}}#E(Q=this.#G){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#H(){this.#j=!0,this.setAttribute("value",this.value),this.#j=!1}get#O(){return this.getAttribute("hit-area-mode")||"handle"}#R(){let Q=this.getAttribute("hit-area");if(!Q)return null;let Z=Q.trim().split(/\s+/),$=0,J=0,j=!1,q=[];for(let _ of Z){if(_==="circle"){j=!0;continue}let X=parseFloat(_);if(Number.isFinite(X))q.push(X)}if(q.length>=2)$=q[0],J=q[1];else if(q.length===1)$=q[0],J=q[0];else return null;return{vPad:$,hPad:J,circle:j}}#P(){let Q=this.#R();if(!Q){if(this.#X)this.#X.remove(),this.#X=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#X){let Z=document.createElement("div");Z.classList.add("fig-handle-hit-area"),Z.addEventListener("pointerdown",($)=>this.#C($)),this.prepend(Z),this.#X=Z}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#X.style.borderRadius="50%";else this.#X.style.borderRadius="inherit"}#C(Q){if(F(this,"disabled"))return;if(Q.target!==this.#X)return;if(this.#O==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#g(Q)}connectedCallback(){this.#f(),this.#T(),this.#P(),this.addEventListener("click",this.#S),document.addEventListener("pointerdown",this.#I),document.addEventListener("keydown",this.#A);let Q=this.getAttribute("value");if(Q)this.#D(Q);if(this.#W)this.#s()}disconnectedCallback(){if(this.#y(),this.#t(),this.#u(),this.#d(),this.#X)this.#X.remove(),this.#X=null;this.removeEventListener("click",this.#S),document.removeEventListener("pointerdown",this.#I),document.removeEventListener("keydown",this.#A)}select(){if(F(this,"disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#S=(Q)=>{if(this.#Q){this.#Q=!1;return}if(this.getAttribute("type")==="color"&&this.#N&&!this.#W){this.#x();return}this.select()};#I=(Q)=>{if(this.contains(Q.target))return;if((this.#q||this.#_)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#A=(Q)=>{if(Q.defaultPrevented)return;if(Q.target===this&&this.#K&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Q.key)){if(this.#k(Q)){if(Q.preventDefault(),!F(this,"selected"))this.select()}return}if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target===this&&!F(this,"selected")){if(Q.preventDefault(),this.getAttribute("type")==="color"&&this.#N&&!this.#W)this.#x();else this.select();return}if(!F(this,"selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#N)return;if(Q.preventDefault(),!this.#W)this.#x()};#k(Q){if(F(this,"disabled"))return!1;let Z=this.#B();if(!Z)return!1;let $=Z.getBoundingClientRect();if($.width<=0||$.height<=0)return!1;let J=this.#G,j=this.#n($),q=Q.shiftKey?0.1:0.01,_=j.px,X=j.py;switch(Q.key){case"ArrowLeft":if(!J.x)return!1;_-=q;break;case"ArrowRight":if(!J.x)return!1;_+=q;break;case"ArrowUp":if(!J.y)return!1;X-=q;break;case"ArrowDown":if(!J.y)return!1;X+=q;break;case"Home":if(J.x)_=0;if(J.y)X=0;break;case"End":if(J.x)_=1;if(J.y)X=1;break;default:return!1}if(_=Math.max(0,Math.min(1,_)),X=Math.max(0,Math.min(1,X)),this.#E(J),J.x)this.style.left=`${Math.round(_*$.width)}px`;if(J.y)this.style.top=`${Math.round(X*$.height)}px`;this.#H();let Y={...this.#n($),shiftKey:Q.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Y})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Y})),!0}attributeChangedCallback(Q,Z,$){if(Q==="color"){if(!$||$==="false"||$==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",$);if(this.#q&&this.#W==="color"&&$)this.#q.setAttribute("value",$);this.#V()}if(Q==="drag")this.#T();if(Q==="hit-area")this.#P();if(Q==="selected")this.#r();if(Q==="selected"||Q==="disabled"||Q==="type"||Q==="tip"||Q==="aria-label"||Q==="aria-labelledby")this.#f();if(Q==="value"&&!this.#j&&!this.#Z)this.#D($);if(Q==="tip"){if(this.#t(),this.#W)this.#u(),this.#s()}}#T(){if(this.#K&&!this.#$)this.#$=(Q)=>this.#g(Q),this.addEventListener("pointerdown",this.#$);else if(!this.#K&&this.#$)this.#y()}#f(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex",Q?"-1":"0");else if(Q)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",Q?"true":"false"),this.setAttribute("aria-pressed",Z?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let $=this.#W||this.getAttribute("type")||"handle";this.setAttribute("aria-label",$==="color"?"Color handle":$==="add"?"Add handle":$==="remove"?"Remove handle":"Handle")}}#y(){if(this.#J?.(),this.#J=null,this.#$)this.removeEventListener("pointerdown",this.#$),this.#$=null;this.#Z=!1,this.#Q=!1}#g(Q){if(!this.#K||F(this,"disabled"))return;Q.preventDefault();let Z=this.#B();if(!Z)return;this.#J?.(),this.#Z=!0;let $=this.#G,J=null,j=this.getBoundingClientRect(),q=j.left+j.width/2,_=j.top+j.height/2,X=Q.clientX-q,Y=Q.clientY-_,K=Q.clientX,G=Q.clientY,N=3,W=(T,R,A=!1)=>{let M=Z.getBoundingClientRect();J=M;let E=this.#n(M),k=T-X-M.left,S=R-Y-M.top,x=Math.max(0,Math.min(M.width,k)),y=Math.max(0,Math.min(M.height,S)),m=M.width>0?$.x?x/M.width:E.px:0.5,d=M.height>0?$.y?y/M.height:E.py:0.5;if(this.#L(A)){if($.x)m=this.#F(m);if($.y)d=this.#F(d);if($.x&&$.y){let t=this.#z(m,d);m=t.x,d=t.y}}if(this.#E($),$.x)this.style.left=`${Math.round(Math.max(0,Math.min(M.width,m*M.width)))}px`;if($.y)this.style.top=`${Math.round(Math.max(0,Math.min(M.height,d*M.height)))}px`},O=(T)=>{if(!this.#Z)return;if(!this.#Q){let R=T.clientX-K,A=T.clientY-G;if(R*R+A*A<N*N)return;if(this.#p(),this.classList.add("dragging"),this.style.cursor="grabbing",!F(this,"selected"))this.select()}this.#Q=!0,W(T.clientX,T.clientY,T.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#n(J),shiftKey:T.shiftKey}}))},B=(T)=>{if(L(),this.#Q){W(T.clientX,T.clientY,T.shiftKey),this.#H(),this.#D(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#n(J)}));let R=(A)=>{A.stopPropagation(),A.preventDefault()};this.addEventListener("click",R,{capture:!0,once:!0})}else this.#H();this.#Q=!1},L=()=>{if(window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",B),this.#Z=!1,this.style.cursor="",this.classList.remove("dragging"),this.#J===L)this.#J=null};this.#J=L,window.addEventListener("pointermove",O),window.addEventListener("pointerup",B)}showColorTip(){if(!this.#W)return;if(this.#q){this.#q.style.display="";return}this.#s()}hideColorTip(){if(!this.#q)return;this.#q.style.display="none"}#h(Q=this.getAttribute("color")){let Z={color:"#D9D9D9",opacity:100},$=String(Q||"").trim();if(!$)return Z;let J=(q)=>{let _=q.replace("#","").trim();if(_.length===3||_.length===4){let[X,Y,K,G]=_;return{color:`#${X}${X}${Y}${Y}${K}${K}`.toUpperCase(),opacity:G?Math.round(parseInt(`${G}${G}`,16)/255*100):100}}if(_.length===6||_.length===8)return{color:`#${_.slice(0,6)}`.toUpperCase(),opacity:_.length===8?Math.round(parseInt(_.slice(6,8),16)/255*100):100};return Z},j=(q,_,X)=>{let Y=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${Y(q)}${Y(_)}${Y(X)}`.toUpperCase()};if($.startsWith("#"))return J($);try{let{ctx:q}=O0(1,1);q.fillStyle="#000000",q.fillStyle=$;let _=q.fillStyle;if(_.startsWith("#"))return J(_);let X=_.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(X)return{color:j(X[1],X[2],X[3]),opacity:X[4]!==void 0?Math.round(parseFloat(X[4])*100):100}}catch{}return Z}#w(){let{color:Q,opacity:Z}=this.#h();return JSON.stringify(Z<100?{type:"solid",color:Q,opacity:Z}:{type:"solid",color:Q})}#V(){if(!this.#_)return;this.#_.setAttribute("value",this.#w())}#b(){if(!o())return null;if(this.#_)return this.#_;let Q=document.createElement("fig-fill-picker");Q.setAttribute("mode","solid"),Q.setAttribute("alpha","true"),Q.setAttribute("dialog-offset","8 8"),Q.setAttribute("value",this.#w()),Q.anchorElement=this;let Z=document.createElement("span");return Z.hidden=!0,Q.appendChild(Z),Q.addEventListener("input",this.#i),Q.addEventListener("change",this.#Z0),Q.addEventListener("close",this.#l),this.appendChild(Q),this.#_=Q,Q}#x(){if(F(this,"disabled"))return;let Q=this.#b();if(!Q){this.#v();return}this.setAttribute("selected",""),this.#V(),Q.open()}#u(){if(!this.#_)return;this.#_.removeEventListener("input",this.#i),this.#_.removeEventListener("change",this.#Z0),this.#_.removeEventListener("close",this.#l),this.#_.close(),this.#_.remove(),this.#_=null,this.removeAttribute("selected")}#m(){if(this.#Y)return this.#Y;let Q=document.createElement("input");return Q.type="color",Q.tabIndex=-1,Q.setAttribute("aria-hidden","true"),Q.style.position="fixed",Q.style.inlineSize="1px",Q.style.blockSize="1px",Q.style.opacity="0",Q.style.pointerEvents="none",Q.addEventListener("input",this.#q0),Q.addEventListener("change",this.#e),this.appendChild(Q),this.#Y=Q,Q}#v(){let Q=this.#m(),{color:Z}=this.#h();Q.value=Z,this.setAttribute("selected",""),Q.click()}#d(){if(!this.#Y)return;this.#Y.removeEventListener("input",this.#q0),this.#Y.removeEventListener("change",this.#e),this.#Y.remove(),this.#Y=null}#p(){if(this.getAttribute("type")!=="color")return;this.#_?.close()}#s(){let Q=this.#W;if(!Q)return;if(this.#q)return;let Z=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")Z.setAttribute("control",Q);else Z.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Z.setAttribute("alpha","true");Z.addEventListener("input",this.#J0),Z.addEventListener("change",this.#$0),Z.addEventListener("add",this.#a),Z.addEventListener("remove",this.#a),this.appendChild(Z),this.#q=Z,this.#r()}#t(){if(!this.#q)return;this.#q.removeEventListener("input",this.#J0),this.#q.removeEventListener("change",this.#$0),this.#q.removeEventListener("add",this.#a),this.#q.removeEventListener("remove",this.#a),this.#q.remove(),this.#q=null}#r(){if(!this.#q||this.#W!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#q.toggleAttribute("selected",Q)}#c(Q,Z){if(Z===void 0||Z>=100)return Q;let{r:$,g:J,b:j}=r(Q);return`rgba(${$}, ${J}, ${j}, ${Z/100})`}#o(Q){if(!Q?.color)return null;let Z=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:Z}}#i=(Q)=>{Q.stopPropagation();let Z=this.#o(Q.detail);if(!Z)return;this.setAttribute("color",this.#c(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#Z0=(Q)=>{Q.stopPropagation();let Z=this.#o(Q.detail);if(!Z)return;this.setAttribute("color",this.#c(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#j0(Q){let{opacity:Z}=this.#h();return Z<100?{color:Q,opacity:Z}:{color:Q}}#q0=(Q)=>{Q.stopPropagation();let Z=this.#j0(Q.target.value);this.setAttribute("color",this.#c(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#e=(Q)=>{Q.stopPropagation();let Z=this.#j0(Q.target.value);this.setAttribute("color",this.#c(Z.color,Z.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#l=()=>{this.removeAttribute("selected")};#J0=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#c(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#$0=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#c(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#a=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#n(Q){let Z=Q||this.#B()?.getBoundingClientRect();if(!Z)return{x:0,y:0,px:0,py:0};let $=this.getBoundingClientRect(),J=this.offsetWidth/2,j=this.offsetHeight/2,q=$.left-Z.left,_=$.top-Z.top,X=q+J,Y=_+j,K=Z.width>0?X/Z.width:0,G=Z.height>0?Y/Z.height:0;return{x:q,y:_,px:K,py:G}}}z("fig-handle",C1);class k1 extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled")this.#Z()}#Z(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}z("fig-menu-item",k1);class S1 extends HTMLElement{static get observedAttributes(){return["label"]}get label(){return this.getAttribute("label")??""}set label(Q){if(Q==null||Q==="")this.removeAttribute("label");else this.setAttribute("label",String(Q))}connectedCallback(){this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#Z()}#Z(){if(!this.hasAttribute("role"))this.setAttribute("role","separator");let Q=this.label.trim();if(Q)this.setAttribute("aria-label",Q);else this.removeAttribute("aria-label")}}z("fig-menu-separator",S1);class f1 extends HTMLElement{#Z=null;#Q=null;#$=null;#J=null;#j=null;#q=null;#_=null;#Y=null;#X;#W;#N;#K;#G;#U=this.#P.bind(this);#L=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open","trigger"]}constructor(){super();this.#X=this.#y.bind(this),this.#W=this.#g.bind(this),this.#N=this.#w.bind(this),this.#K=this.#V.bind(this),this.#G=this.#b.bind(this)}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q){if(this.#f())return;this.setAttribute("open","")}else this.removeAttribute("open")}connectedCallback(){if(this.#F(),this.#B(),this.#M(),this.#D(),this.#O(),this.#H(),this.#T(),this.open)this.#u()}disconnectedCallback(){if(this.#E(),this.#R(),document.removeEventListener("keydown",this.#K,!0),this.#j)this.#j.disconnect(),this.#j=null;if(this.#Z){this.#Z.removeEventListener("close",this.#G);let Q=Array.from(this.#Q?.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator")??[]);for(let Z of Q)this.insertBefore(Z,this.#Z);this.#Z.remove(),this.#Z=null,this.#Q=null}}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){if($===null||$==="false")this.#m();else{if(this.#f()){this.removeAttribute("open");return}this.#u()}return}if(Q==="disabled"){this.#T();return}if(this.#Z&&(Q==="position"||Q==="offset"||Q==="closedby"))if($!==null)this.#Z.setAttribute(Q,$);else this.#Z.removeAttribute(Q)}#F(){this.#$=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#z(){return(this.getAttribute("trigger")||"").toLowerCase()==="contextmenu"||this.hasAttribute("contextmenu")}#B(){this.#Z=document.createElement("dialog",{is:"fig-popup"}),this.#Z.setAttribute("is","fig-popup"),this.#Z.classList.add("fig-menu-popup"),this.#Z.setAttribute("theme","menu"),this.#Z.setAttribute("role","menu"),this.#Z.setAttribute("id",this.#Z.getAttribute("id")||g());let Q=this.getAttribute("position")||"bottom left";this.#Z.setAttribute("position",Q);let Z=this.getAttribute("offset");if(Z)this.#Z.setAttribute("offset",Z);let $=this.getAttribute("closedby");if($)this.#Z.setAttribute("closedby",$);if(this.#$)this.#Z.anchor=this.#$;this.#Q=document.createElement("div"),this.#Q.className="fig-menu-options",this.#Q.setAttribute("role","presentation"),this.#Z.appendChild(this.#Q),this.#Z.addEventListener("close",this.#G),this.appendChild(this.#Z)}#M(){if(!this.#Q)return;let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let Z of Q)this.#Q.appendChild(Z)}#D(){if(this.addEventListener("keydown",this.#K),this.#$)this.#$.addEventListener("click",this.#X),this.#$.addEventListener("contextmenu",this.#W),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded","false"),this.#$.setAttribute("aria-controls",this.#Z.getAttribute("id"));if(this.#Z)this.#Z.addEventListener("click",this.#N),this.#Z.addEventListener("keydown",this.#K)}#E(){if(this.removeEventListener("keydown",this.#K),this.#$)this.#$.removeEventListener("click",this.#X),this.#$.removeEventListener("contextmenu",this.#W);if(this.#Z)this.#Z.removeEventListener("click",this.#N),this.#Z.removeEventListener("keydown",this.#K)}#H(){this.#j=new MutationObserver((Q)=>{for(let Z of Q)for(let $ of Z.addedNodes){if($.nodeType!==1||$===this.#Z)continue;if(($.tagName==="FIG-MENU-ITEM"||$.tagName==="FIG-MENU-SEPARATOR")&&$.parentElement===this)this.#Q?.appendChild($);else if(!this.#$&&$.parentElement===this){if(this.#F(),this.#$)this.#$.addEventListener("click",this.#X),this.#$.addEventListener("contextmenu",this.#W),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded","false"),this.#$.setAttribute("aria-controls",this.#Z.getAttribute("id")),this.#Z.anchor=this.#$,this.#T()}}this.#P()}),this.#j.observe(this,{childList:!0})}#O(){if(!this.#Q)return;this.#C(),this.#Q.addEventListener("scroll",this.#U,{passive:!0}),this.#q?.disconnect(),this.#q=new ResizeObserver(()=>this.#P()),this.#q.observe(this.#Q),requestAnimationFrame(()=>this.#P())}#R(){this.#Q?.removeEventListener("scroll",this.#U),this.#q?.disconnect(),this.#q=null,this.#S()}#P(){return a(this.#Q,this.#Q,"y")}#C(){if(this.#_&&this.#Y&&this.#Q?.contains(this.#_)&&this.#Q?.contains(this.#Y))return;this.#S();let Q=X0({owner:"menu",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>i(this.#Q,"y",-1),onEnd:()=>i(this.#Q,"y",1)});this.#_=Q.start,this.#Y=Q.end,this.#Q.prepend(this.#_),this.#Q.append(this.#Y)}#S(){this.#_?.remove(),this.#Y?.remove(),this.#_=null,this.#Y=null,this.#Q?.classList.remove("overflow-start","overflow-end")}#I(){if(!this.#Q)return[];return Array.from(this.#Q.querySelectorAll("fig-menu-item")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#A(){let Q=this.#I();if(!Q.length){this.#L=-1;return}let Z=document.activeElement,$=Q.findIndex((J)=>J===Z||J.contains(Z));this.#L=$>=0?$:-1}#k(Q){let Z=this.#I();if(!Z.length)return;let $=(Q+Z.length)%Z.length;this.#L=$;let J=Z[$];J.focus(),S0(this.#Q,J,"y")}#T(){let Q=this.#f();if(Q)if(this.open)this.removeAttribute("open");else this.#m();if(!this.#$)return;if(Q)this.#$.setAttribute("disabled",""),this.#$.setAttribute("aria-disabled","true"),this.#$.setAttribute("aria-expanded","false");else this.#$.removeAttribute("disabled"),this.#$.removeAttribute("aria-disabled")}#f(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#y(Q){if(this.#z())return;if(this.#f())return;Q.stopPropagation();let Z=this.#Z?.matches?.(":open")??!1;if(this.open&&!Z)this.removeAttribute("open");if(this.open&&Z)this.open=!1;else{if(this.#Z&&this.#$)this.#Z.anchor=this.#$;this.open=!0}}#g(Q){if(!this.#z())return;if(this.#f())return;Q.preventDefault(),Q.stopPropagation(),this.#h(Q.clientX,Q.clientY)}#h(Q,Z){let $=!1,J=0,j=()=>{window.clearTimeout(J),window.removeEventListener("pointerup",q,!0),window.removeEventListener("pointercancel",_,!0)},q=()=>{if($)return;$=!0,j(),requestAnimationFrame(()=>this.showAt(Q,Z))},_=()=>{if($)return;$=!0,j()};window.addEventListener("pointerup",q,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),J=window.setTimeout(q,180)}#w(Q){if(this.#f())return;let Z=Q.target.closest("fig-menu-item");if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#x(Z)}#V(Q){if(this.#f())return;if(Q.currentTarget===document&&Q.key!=="Escape")return;if(Q.currentTarget===this&&this.#Z?.contains(Q.target))return;if(!this.open||!this.#Z?.matches?.(":open")){if(this.#$?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" ")){if(Q.preventDefault(),this.#Z&&this.#$)this.#Z.anchor=this.#$;this.open=!0,requestAnimationFrame(()=>this.#k(0))}return}let Z=this.#I();if(!Z.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#A(),this.#k(this.#L+1);break}case"ArrowUp":{Q.preventDefault(),this.#A(),this.#k(this.#L-1);break}case"Home":{Q.preventDefault(),this.#k(0);break}case"End":{Q.preventDefault(),this.#k(Z.length-1);break}case"Escape":{Q.preventDefault(),this.open=!1,this.#$?.focus();break}case"Enter":case" ":{this.#A();let $=Z[this.#L];if(!$)return;Q.preventDefault(),this.#x($);break}}}#b(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#$)this.#$.setAttribute("aria-expanded","false"),this.#$.focus();this.#L=-1}#x(Q){let Z=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("change",{detail:{value:Z,item:Q},bubbles:!0})),this.open=!1}showAt(Q,Z){if(this.#f())return;if(this.#J={getBoundingClientRect:()=>({width:0,height:0,top:Z,right:Q,bottom:Z,left:Q,x:Q,y:Z})},this.#Z)this.#Z.anchor=this.#J;if(this.open)this.open=!1;requestAnimationFrame(()=>{if(this.#f())return;this.open=!0})}#u(){if(!this.#Z||this.#f()){if(this.hasAttribute("open"))this.removeAttribute("open");return}if(this.#Z.open=!0,document.addEventListener("keydown",this.#K,!0),this.#$)this.#$.setAttribute("aria-expanded","true");this.#L=-1,requestAnimationFrame(()=>{if(this.#P(),!this.#$?.matches?.(":focus-visible"))return;this.#k(0)})}#m(){if(!this.#Z)return;document.removeEventListener("keydown",this.#K,!0),this.#Z.open=!1,this.#$?.setAttribute("aria-expanded","false")}}z("fig-menu",f1);
364
+ </fig-fill-picker>`:`<fig-swatch background="${$}"${_}></fig-swatch>`,this.#Q=this.querySelector("fig-fill-picker"),this.#Z=this.querySelector("fig-swatch"),this.#_(),this.#Q?.addEventListener("input",this.#J),this.#Q?.addEventListener("change",this.#j),!this.#Q)this.#Z?.addEventListener("input",this.#J),this.#Z?.addEventListener("change",this.#j);this.#Y(),this.#F()}#N=()=>{let Q=this.#q;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#K(Q){if(!Q)return"#D9D9D9";let Z=Q.replace("#","").trim();if(Z.length===3||Z.length===4){let[$,J,j]=Z;return`#${$}${$}${J}${J}${j}${j}`.toUpperCase()}if(Z.length===6||Z.length===8)return`#${Z.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#G(Q){if(!Q)return 1;let Z=String(Q).trim(),$=Z.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test($)){let j=$[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test($))return parseInt($.slice(6,8),16)/255;let J=Z.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(J)return parseFloat(J[1]);return 1}#U(Q){if(!Q)return"#D9D9D9";let Z=String(Q).trim();if(Z.startsWith("{"))try{let $=JSON.parse(Z);if($?.color)return this.#U($.color)}catch{}if(Z.startsWith("#"))return this.#K(Z);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Z))return this.#K(Z);try{let{ctx:$}=O0(1,1);$.fillStyle="#000000",$.fillStyle=Z;let J=$.fillStyle;if(J.startsWith("#"))return this.#K(J);let j=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let q=(_)=>Math.max(0,Math.min(255,Number(_))).toString(16).padStart(2,"0");return`#${q(j[1])}${q(j[2])}${q(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#L(){let Q=this.getAttribute("value"),Z=this.#U(Q),$=this.#G(Q);if(Q!==Z&&$>=1){this.setAttribute("value",Z);return}if(this.#Q){this.#F();let J=$<1?{type:"solid",color:Z,opacity:Math.round($*100)}:{type:"solid",color:Z};if(this.#Q.setAttribute("value",JSON.stringify(J)),this.#X)this.#Q.removeAttribute("alpha");else this.#Q.setAttribute("alpha","false");if(F(this,"disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}if(this.#Z){if(this.#F(),this.#Z.setAttribute("background",Z),$<1)this.#Z.setAttribute("alpha",String($));else this.#Z.removeAttribute("alpha");if(F(this,"disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}}#F(){let Q=this.#q,Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",Z?"true":"false"),this.setAttribute("aria-pressed",$?"true":"false"),Q==="add"||Q==="remove"){let X=this.querySelector("fig-button"),Y=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");if(X?.setAttribute("aria-label",Y),Z)X?.setAttribute("disabled","");else X?.removeAttribute("disabled");return}let J=this.#Q||this.#Z;if(!J)return;let j=this.getAttribute("aria-label")||"Color stop",q=this.getAttribute("aria-labelledby"),_=this.getAttribute("aria-describedby");if(q)J.setAttribute("aria-labelledby",q),J.removeAttribute("aria-label");else J.setAttribute("aria-label",j),J.removeAttribute("aria-labelledby");if(_)J.setAttribute("aria-describedby",_);else J.removeAttribute("aria-describedby")}#z(Q,Z){let $=this.#U(Q?.color),J=this.#U(this.getAttribute("value"));if($!==J)this.setAttribute("value",$);else this.#L();let j={color:this.value};if(this.#X){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent(Z,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#B(Q){Q.stopPropagation(),this.#z(Q.detail||{color:Q.target?.value},"input")}#M(Q){Q.stopPropagation(),this.#z(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(!this.isConnected)return;switch(Q){case"control":this.#W();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#L(),this.#F();break}}get value(){return this.#U(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#U(Q))}get selected(){return F(this,"selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return F(this,"disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}z("fig-color-tip",T1);class P1 extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",F(this,"selected")?"true":"false"),F(this,"disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",F(this,"selected")?"true":"false");if(Q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}z("fig-choice",P1);class E1 extends HTMLElement{#Q=null;#Z=this.#D.bind(this);#$=this.#T.bind(this);#J=this.#O.bind(this);#j=null;#q=null;#_=null;#Y=null;#X=null;#W=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#N(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#K(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#G(){return this.getAttribute("choice-element")||"fig-choice"}#U(){let Q=this.getAttribute("columns"),Z=Q===null?NaN:Number(Q);if(Number.isInteger(Z)&&Z>0)this.style.setProperty("--fig-chooser-grid-columns",String(Z));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from(this.querySelectorAll(`:scope > ${this.#G}`))}get selectedChoice(){return this.#Q}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let Z=this.choices;for(let J of Z){let j=J===Q,q=F(J,"selected");if(j&&!q)J.setAttribute("selected","");else if(!j&&q)J.removeAttribute("selected")}this.#Q=Q;let $=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==$){if($)this.setAttribute("value",$)}this.#y(Q)}get value(){return this.#Q?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){if(this.setAttribute("role","listbox"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.#f(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#$),this.addEventListener("scroll",this.#J),this.#I(),this.#P(),this.#v(),this.#R(),this.#z(),c(this,()=>{this.#F(),this.#O(),this.#L()})}#L(){let Q=()=>{if(!this.isConnected)return;if(this.#Q)this.#y(this.#Q,"auto")},Z=()=>{let $=this.querySelectorAll("img, video");for(let J of $){if(J.tagName==="IMG"?J.complete:J.readyState>=1)continue;let j=()=>{J.removeEventListener("load",j),J.removeEventListener("loadedmetadata",j),J.removeEventListener("error",j),Q()};J.addEventListener("load",j),J.addEventListener("loadedmetadata",j),J.addEventListener("error",j)}};requestAnimationFrame(()=>{Z(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#$),this.removeEventListener("scroll",this.#J),this.#S(),this.#j?.disconnect(),this.#j=null,this.#q?.disconnect(),this.#q=null,this.#A()}attributeChangedCallback(Q,Z,$){if(Q==="value"&&$!==Z&&$)this.#B($);if(Q==="disabled")this.#z();if(Q==="choice-element")requestAnimationFrame(()=>this.#F());if(Q==="columns")this.#U(),this.#k();if(Q==="drag")if(this.#K)this.#P();else this.#S();if(Q==="overflow")this.#I(),requestAnimationFrame(()=>this.#O());if(Q==="layout"){if(this.#I(),$==="horizontal")this.scrollTop=0;else this.scrollLeft=0;this.#k()}}#F(){let Q=this.choices;if(!Q.length){this.#Q=null;return}let Z=this.getAttribute("value");if(Z&&this.#B(Z))return;let $=Q.find((J)=>F(J,"selected"));if($){this.selectedChoice=$;return}this.selectedChoice=Q[0]}#z(){let Q=F(this,"disabled");if(Q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Z of this.choices)if(Q||F(Z,"disabled"))Z.setAttribute("aria-disabled","true"),Z.setAttribute("tabindex","-1");else Z.removeAttribute("aria-disabled"),Z.setAttribute("tabindex","0")}#B(Q){let Z=this.choices;for(let $ of Z)if($.getAttribute("value")===Q)return this.selectedChoice=$,!0;return!1}#M(Q){let Z=this.#G,$=Q;while($&&$!==this){if($.matches(Z))return $;$=$.parentElement}return null}#D(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#M(Q.target);if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.selectedChoice=Z,this.#H()}#T(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!Z.length)return;let $=Z.indexOf(this.#Q),J=$,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),$<Z.length-1)J=$+1;else if(j)J=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),$>0)J=$-1;else if(j)J=Z.length-1;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#G)){let q=this.#M(document.activeElement);if(q&&q!==this.#Q)this.selectedChoice=q,this.#H()}return;default:return}if(J!==$&&Z[J])this.selectedChoice=Z[J],Z[J].focus(),this.#H()}#H(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#O(){if(this.#N==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal";a(this,this,Q?"x":"y")}#R(){this.#q?.disconnect(),this.#q=new ResizeObserver(()=>{this.#O(),this.#k()}),this.#q.observe(this)}#P(){if(this.#X?.bound)return;if(!this.#K)return;let Q=(q)=>{if(q.button!==0)return;if(q.target.closest("[data-fig-chooser-nav]"))return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#X.active=!0,this.#X.didDrag=!1,this.#X.startX=q.clientX,this.#X.startY=q.clientY,this.#X.scrollLeft=this.scrollLeft,this.#X.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Z=(q)=>{if(!this.#X.active)return;let _=this.getAttribute("layout")==="horizontal",X=q.clientX-this.#X.startX,Y=q.clientY-this.#X.startY;if(!this.#X.didDrag&&Math.abs(_?X:Y)>3)this.#X.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(q.pointerId);if(!this.#X.didDrag)return;if(_)this.scrollLeft=this.#X.scrollLeft-X;else this.scrollTop=this.#X.scrollTop-Y},$=(q)=>{if(!this.#X.active)return;let _=this.#X.didDrag;if(this.#X.active=!1,this.#X.didDrag=!1,this.style.cursor="",this.style.userSelect="",q.pointerId!==void 0)try{this.releasePointerCapture(q.pointerId)}catch{}if(_)q.preventDefault(),q.stopPropagation()},J=(q)=>{if(this.#X?.suppressClick)q.stopPropagation(),q.preventDefault(),this.#X.suppressClick=!1},j=(q)=>{if(this.#X?.didDrag)this.#X.suppressClick=!0,setTimeout(()=>{if(this.#X)this.#X.suppressClick=!1},0)};this.#X={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:Q,onPointerMove:Z,onPointerUp:$,onClick:J,onPointerUpCapture:j},this.addEventListener("pointerdown",Q),window.addEventListener("pointermove",Z),window.addEventListener("pointerup",$),this.addEventListener("pointerup",j,!0),this.addEventListener("click",J,!0)}#S(){if(!this.#X?.bound)return;this.removeEventListener("pointerdown",this.#X.onPointerDown),window.removeEventListener("pointermove",this.#X.onPointerMove),window.removeEventListener("pointerup",this.#X.onPointerUp),this.removeEventListener("pointerup",this.#X.onPointerUpCapture,!0),this.removeEventListener("click",this.#X.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#X=null}#f(){if(this.#W)return;let Q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!Q)return;this.#W=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#W=!1}}#I(){if(this.#N==="scrollbar")this.#A();else this.#E()}#A(){this.#_?.remove(),this.#Y?.remove(),this.#_=null,this.#Y=null,this.classList.remove("overflow-start","overflow-end")}#E(){if(this.#_&&this.#Y&&this.contains(this.#_)&&this.contains(this.#Y))return;this.#_?.remove(),this.#Y?.remove(),this.#_=null,this.#Y=null;let Q=X0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#C(-1),onEnd:()=>this.#C(1)});this.#_=Q.start,this.#Y=Q.end,this.prepend(this.#_),this.append(this.#Y)}#C(Q){let Z=this.getAttribute("layout")==="horizontal";i(this,Z?"x":"y",Q)}#k(){if(!this.#Q)return;this.#y(this.#Q,"auto")}#y(Q,Z="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let $=this.scrollHeight>this.clientHeight,J=this.scrollWidth>this.clientWidth;if(!J&&!$)return;let j=Q.getBoundingClientRect(),q=this.getBoundingClientRect(),_={behavior:Z},X=!1;if($){let Y=j.top-q.top+this.scrollTop,K=this.scrollHeight-this.clientHeight;_.top=Math.max(0,Math.min(Y+j.height/2-this.clientHeight/2,K)),X=!0}if(J){let Y=j.left-q.left+this.scrollLeft,K=this.scrollWidth-this.clientWidth;_.left=Math.max(0,Math.min(Y+j.width/2-this.clientWidth/2,K)),X=!0}if(X)this.scrollTo(_);this.#O()})}#v(){this.#j?.disconnect(),this.#j=new MutationObserver(()=>{if(this.#W)return;this.#f(),this.#I(),this.#z();let Q=this.choices;if(this.#Q&&!Q.includes(this.#Q))this.#Q=null,this.#F();else if(!this.#Q&&Q.length)this.#F();requestAnimationFrame(()=>this.#O())}),this.#j.observe(this,{childList:!0,subtree:!1})}}z("fig-chooser",E1);class C1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#Q=!1;#Z=!1;#$=null;#J=null;#j=!1;#q=null;#_=null;#Y=null;#X=null;get#W(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#N(){return!this.hasAttribute("data-no-color-picker")}get#K(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#G(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#U(){let Q=this.getAttribute("drag-snapping");if(Q===null)return"false";let Z=Q.trim().toLowerCase();if(Z==="modifier")return"modifier";if(Z===""||Z==="true")return"true";return"false"}#L(Q){let Z=this.#U;if(Z==="true")return!0;if(Z==="modifier")return!!Q;return!1}#F(Q){if(Q<0.1)return 0;if(Q>0.9)return 1;if(Q>0.4&&Q<0.6)return 0.5;return Q}#z(Q,Z){if(Math.abs(Q-Z)<0.1){let J=(Q+Z)/2;return{x:J,y:J}}if(Math.abs(1-Q-Z)<0.1)return{x:Q,y:1-Q};return{x:Q,y:Z}}#B(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#B();if(!Q)return"0% 0%";let{px:Z,py:$}=this.#n(Q.getBoundingClientRect());return`${Math.round(Z*100)}% ${Math.round($*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#M(Q){let Z=Q==null?"":String(Q).trim();if(!Z)return{xPct:0,yPct:0};let $=Z.split(/[\s,]+/).filter(Boolean),J=(_)=>{if(!_)return 0;let X=_.includes("px"),Y=_.includes("%"),K=parseFloat(_.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(X)return{px:K};if(Y||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},j=J($[0]),q=J($[1]??$[0]);return{xToken:j,yToken:q}}#D(Q){let Z=this.#B();if(!Z)return;let{xToken:$,yToken:J}=this.#M(Q),j=Z.getBoundingClientRect(),q=(Y,K)=>{if(Y&&typeof Y==="object"&&"px"in Y)return Math.max(0,Math.min(K,Y.px));return null},_=(Y)=>{return`${typeof Y==="number"?Y:0}%`},X=this.#G;if(this.#T(X),X.x){let Y=q($,j.width);this.style.left=Y===null?_($):`${Math.round(Y)}px`}if(X.y){let Y=q(J,j.height);this.style.top=Y===null?_(J):`${Math.round(Y)}px`}}#T(Q=this.#G){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#H(){this.#j=!0,this.setAttribute("value",this.value),this.#j=!1}get#O(){return this.getAttribute("hit-area-mode")||"handle"}#R(){let Q=this.getAttribute("hit-area");if(!Q)return null;let Z=Q.trim().split(/\s+/),$=0,J=0,j=!1,q=[];for(let _ of Z){if(_==="circle"){j=!0;continue}let X=parseFloat(_);if(Number.isFinite(X))q.push(X)}if(q.length>=2)$=q[0],J=q[1];else if(q.length===1)$=q[0],J=q[0];else return null;return{vPad:$,hPad:J,circle:j}}#P(){let Q=this.#R();if(!Q){if(this.#X)this.#X.remove(),this.#X=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#X){let Z=document.createElement("div");Z.classList.add("fig-handle-hit-area"),Z.addEventListener("pointerdown",($)=>this.#S($)),this.prepend(Z),this.#X=Z}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#X.style.borderRadius="50%";else this.#X.style.borderRadius="inherit"}#S(Q){if(F(this,"disabled"))return;if(Q.target!==this.#X)return;if(this.#O==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#v(Q)}connectedCallback(){this.#k(),this.#C(),this.#P(),this.addEventListener("click",this.#f),document.addEventListener("pointerdown",this.#I),document.addEventListener("keydown",this.#A);let Q=this.getAttribute("value");if(Q)this.#D(Q);if(this.#W)this.#s()}disconnectedCallback(){if(this.#y(),this.#t(),this.#c(),this.#d(),this.#X)this.#X.remove(),this.#X=null;this.removeEventListener("click",this.#f),document.removeEventListener("pointerdown",this.#I),document.removeEventListener("keydown",this.#A)}select(){if(F(this,"disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#f=(Q)=>{if(this.#Z){this.#Z=!1;return}if(this.getAttribute("type")==="color"&&this.#N&&!this.#W){this.#x();return}this.select()};#I=(Q)=>{if(this.contains(Q.target))return;if((this.#q||this.#_)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#A=(Q)=>{if(Q.defaultPrevented)return;if(Q.target===this&&this.#K&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Q.key)){if(this.#E(Q)){if(Q.preventDefault(),!F(this,"selected"))this.select()}return}if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target===this&&!F(this,"selected")){if(Q.preventDefault(),this.getAttribute("type")==="color"&&this.#N&&!this.#W)this.#x();else this.select();return}if(!F(this,"selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#N)return;if(Q.preventDefault(),!this.#W)this.#x()};#E(Q){if(F(this,"disabled"))return!1;let Z=this.#B();if(!Z)return!1;let $=Z.getBoundingClientRect();if($.width<=0||$.height<=0)return!1;let J=this.#G,j=this.#n($),q=Q.shiftKey?0.1:0.01,_=j.px,X=j.py;switch(Q.key){case"ArrowLeft":if(!J.x)return!1;_-=q;break;case"ArrowRight":if(!J.x)return!1;_+=q;break;case"ArrowUp":if(!J.y)return!1;X-=q;break;case"ArrowDown":if(!J.y)return!1;X+=q;break;case"Home":if(J.x)_=0;if(J.y)X=0;break;case"End":if(J.x)_=1;if(J.y)X=1;break;default:return!1}if(_=Math.max(0,Math.min(1,_)),X=Math.max(0,Math.min(1,X)),this.#T(J),J.x)this.style.left=`${Math.round(_*$.width)}px`;if(J.y)this.style.top=`${Math.round(X*$.height)}px`;this.#H();let Y={...this.#n($),shiftKey:Q.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Y})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Y})),!0}attributeChangedCallback(Q,Z,$){if(Q==="color"){if(!$||$==="false"||$==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",$);if(this.#q&&this.#W==="color"&&$)this.#q.setAttribute("value",$);this.#V()}if(Q==="drag")this.#C();if(Q==="hit-area")this.#P();if(Q==="selected")this.#r();if(Q==="selected"||Q==="disabled"||Q==="type"||Q==="tip"||Q==="aria-label"||Q==="aria-labelledby")this.#k();if(Q==="value"&&!this.#j&&!this.#Q)this.#D($);if(Q==="tip"){if(this.#t(),this.#W)this.#c(),this.#s()}}#C(){if(this.#K&&!this.#$)this.#$=(Q)=>this.#v(Q),this.addEventListener("pointerdown",this.#$);else if(!this.#K&&this.#$)this.#y()}#k(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex",Q?"-1":"0");else if(Q)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",Q?"true":"false"),this.setAttribute("aria-pressed",Z?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let $=this.#W||this.getAttribute("type")||"handle";this.setAttribute("aria-label",$==="color"?"Color handle":$==="add"?"Add handle":$==="remove"?"Remove handle":"Handle")}}#y(){if(this.#J?.(),this.#J=null,this.#$)this.removeEventListener("pointerdown",this.#$),this.#$=null;this.#Q=!1,this.#Z=!1}#v(Q){if(!this.#K||F(this,"disabled"))return;Q.preventDefault();let Z=this.#B();if(!Z)return;this.#J?.(),this.#Q=!0;let $=this.#G,J=null,j=this.getBoundingClientRect(),q=j.left+j.width/2,_=j.top+j.height/2,X=Q.clientX-q,Y=Q.clientY-_,K=Q.clientX,G=Q.clientY,N=3,W=(T,R,A=!1)=>{let M=Z.getBoundingClientRect();J=M;let E=this.#n(M),k=T-X-M.left,S=R-Y-M.top,x=Math.max(0,Math.min(M.width,k)),y=Math.max(0,Math.min(M.height,S)),m=M.width>0?$.x?x/M.width:E.px:0.5,d=M.height>0?$.y?y/M.height:E.py:0.5;if(this.#L(A)){if($.x)m=this.#F(m);if($.y)d=this.#F(d);if($.x&&$.y){let t=this.#z(m,d);m=t.x,d=t.y}}if(this.#T($),$.x)this.style.left=`${Math.round(Math.max(0,Math.min(M.width,m*M.width)))}px`;if($.y)this.style.top=`${Math.round(Math.max(0,Math.min(M.height,d*M.height)))}px`},O=(T)=>{if(!this.#Q)return;if(!this.#Z){let R=T.clientX-K,A=T.clientY-G;if(R*R+A*A<N*N)return;if(this.#p(),this.classList.add("dragging"),this.style.cursor="grabbing",!F(this,"selected"))this.select()}this.#Z=!0,W(T.clientX,T.clientY,T.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#n(J),shiftKey:T.shiftKey}}))},B=(T)=>{if(L(),this.#Z){W(T.clientX,T.clientY,T.shiftKey),this.#H(),this.#D(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#n(J)}));let R=(A)=>{A.stopPropagation(),A.preventDefault()};this.addEventListener("click",R,{capture:!0,once:!0})}else this.#H();this.#Z=!1},L=()=>{if(window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",B),this.#Q=!1,this.style.cursor="",this.classList.remove("dragging"),this.#J===L)this.#J=null};this.#J=L,window.addEventListener("pointermove",O),window.addEventListener("pointerup",B)}showColorTip(){if(!this.#W)return;if(this.#q){this.#q.style.display="";return}this.#s()}hideColorTip(){if(!this.#q)return;this.#q.style.display="none"}#b(Q=this.getAttribute("color")){let Z={color:"#D9D9D9",opacity:100},$=String(Q||"").trim();if(!$)return Z;let J=(q)=>{let _=q.replace("#","").trim();if(_.length===3||_.length===4){let[X,Y,K,G]=_;return{color:`#${X}${X}${Y}${Y}${K}${K}`.toUpperCase(),opacity:G?Math.round(parseInt(`${G}${G}`,16)/255*100):100}}if(_.length===6||_.length===8)return{color:`#${_.slice(0,6)}`.toUpperCase(),opacity:_.length===8?Math.round(parseInt(_.slice(6,8),16)/255*100):100};return Z},j=(q,_,X)=>{let Y=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${Y(q)}${Y(_)}${Y(X)}`.toUpperCase()};if($.startsWith("#"))return J($);try{let{ctx:q}=O0(1,1);q.fillStyle="#000000",q.fillStyle=$;let _=q.fillStyle;if(_.startsWith("#"))return J(_);let X=_.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(X)return{color:j(X[1],X[2],X[3]),opacity:X[4]!==void 0?Math.round(parseFloat(X[4])*100):100}}catch{}return Z}#w(){let{color:Q,opacity:Z}=this.#b();return JSON.stringify(Z<100?{type:"solid",color:Q,opacity:Z}:{type:"solid",color:Q})}#V(){if(!this.#_)return;this.#_.setAttribute("value",this.#w())}#g(){if(!o())return null;if(this.#_)return this.#_;let Q=document.createElement("fig-fill-picker");Q.setAttribute("mode","solid"),Q.setAttribute("alpha","true"),Q.setAttribute("dialog-offset","8 8"),Q.setAttribute("value",this.#w()),Q.anchorElement=this;let Z=document.createElement("span");return Z.hidden=!0,Q.appendChild(Z),Q.addEventListener("input",this.#i),Q.addEventListener("change",this.#Z0),Q.addEventListener("close",this.#l),this.appendChild(Q),this.#_=Q,Q}#x(){if(F(this,"disabled"))return;let Q=this.#g();if(!Q){this.#h();return}this.setAttribute("selected",""),this.#V(),Q.open()}#c(){if(!this.#_)return;this.#_.removeEventListener("input",this.#i),this.#_.removeEventListener("change",this.#Z0),this.#_.removeEventListener("close",this.#l),this.#_.close(),this.#_.remove(),this.#_=null,this.removeAttribute("selected")}#m(){if(this.#Y)return this.#Y;let Q=document.createElement("input");return Q.type="color",Q.tabIndex=-1,Q.setAttribute("aria-hidden","true"),Q.style.position="fixed",Q.style.inlineSize="1px",Q.style.blockSize="1px",Q.style.opacity="0",Q.style.pointerEvents="none",Q.addEventListener("input",this.#q0),Q.addEventListener("change",this.#e),this.appendChild(Q),this.#Y=Q,Q}#h(){let Q=this.#m(),{color:Z}=this.#b();Q.value=Z,this.setAttribute("selected",""),Q.click()}#d(){if(!this.#Y)return;this.#Y.removeEventListener("input",this.#q0),this.#Y.removeEventListener("change",this.#e),this.#Y.remove(),this.#Y=null}#p(){if(this.getAttribute("type")!=="color")return;this.#_?.close()}#s(){let Q=this.#W;if(!Q)return;if(this.#q)return;let Z=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")Z.setAttribute("control",Q);else Z.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Z.setAttribute("alpha","true");Z.addEventListener("input",this.#J0),Z.addEventListener("change",this.#$0),Z.addEventListener("add",this.#a),Z.addEventListener("remove",this.#a),this.appendChild(Z),this.#q=Z,this.#r()}#t(){if(!this.#q)return;this.#q.removeEventListener("input",this.#J0),this.#q.removeEventListener("change",this.#$0),this.#q.removeEventListener("add",this.#a),this.#q.removeEventListener("remove",this.#a),this.#q.remove(),this.#q=null}#r(){if(!this.#q||this.#W!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#q.toggleAttribute("selected",Q)}#u(Q,Z){if(Z===void 0||Z>=100)return Q;let{r:$,g:J,b:j}=r(Q);return`rgba(${$}, ${J}, ${j}, ${Z/100})`}#o(Q){if(!Q?.color)return null;let Z=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:Z}}#i=(Q)=>{Q.stopPropagation();let Z=this.#o(Q.detail);if(!Z)return;this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#Z0=(Q)=>{Q.stopPropagation();let Z=this.#o(Q.detail);if(!Z)return;this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#j0(Q){let{opacity:Z}=this.#b();return Z<100?{color:Q,opacity:Z}:{color:Q}}#q0=(Q)=>{Q.stopPropagation();let Z=this.#j0(Q.target.value);this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#e=(Q)=>{Q.stopPropagation();let Z=this.#j0(Q.target.value);this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#l=()=>{this.removeAttribute("selected")};#J0=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#u(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#$0=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#u(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#a=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#n(Q){let Z=Q||this.#B()?.getBoundingClientRect();if(!Z)return{x:0,y:0,px:0,py:0};let $=this.getBoundingClientRect(),J=this.offsetWidth/2,j=this.offsetHeight/2,q=$.left-Z.left,_=$.top-Z.top,X=q+J,Y=_+j,K=Z.width>0?X/Z.width:0,G=Z.height>0?Y/Z.height:0;return{x:q,y:_,px:K,py:G}}}z("fig-handle",C1);class k1 extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled")this.#Q()}#Q(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}z("fig-menu-item",k1);class S1 extends HTMLElement{static get observedAttributes(){return["label"]}get label(){return this.getAttribute("label")??""}set label(Q){if(Q==null||Q==="")this.removeAttribute("label");else this.setAttribute("label",String(Q))}connectedCallback(){this.#Q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#Q()}#Q(){if(!this.hasAttribute("role"))this.setAttribute("role","separator");let Q=this.label.trim();if(Q)this.setAttribute("aria-label",Q);else this.removeAttribute("aria-label")}}z("fig-menu-separator",S1);class f1 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#_=null;#Y=null;#X;#W;#N;#K;#G;#U=this.#P.bind(this);#L=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open","trigger"]}constructor(){super();this.#X=this.#y.bind(this),this.#W=this.#v.bind(this),this.#N=this.#w.bind(this),this.#K=this.#V.bind(this),this.#G=this.#g.bind(this)}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q){if(this.#k())return;this.setAttribute("open","")}else this.removeAttribute("open")}connectedCallback(){if(this.#F(),this.#B(),this.#M(),this.#D(),this.#O(),this.#H(),this.#C(),this.open)this.#c()}disconnectedCallback(){if(this.#T(),this.#R(),document.removeEventListener("keydown",this.#K,!0),this.#j)this.#j.disconnect(),this.#j=null;if(this.#Q){this.#Q.removeEventListener("close",this.#G);let Q=Array.from(this.#Z?.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator")??[]);for(let Z of Q)this.insertBefore(Z,this.#Q);this.#Q.remove(),this.#Q=null,this.#Z=null}}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){if($===null||$==="false")this.#m();else{if(this.#k()){this.removeAttribute("open");return}this.#c()}return}if(Q==="disabled"){this.#C();return}if(this.#Q&&(Q==="position"||Q==="offset"||Q==="closedby"))if($!==null)this.#Q.setAttribute(Q,$);else this.#Q.removeAttribute(Q)}#F(){this.#$=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#z(){return(this.getAttribute("trigger")||"").toLowerCase()==="contextmenu"||this.hasAttribute("contextmenu")}#B(){this.#Q=document.createElement("dialog",{is:"fig-popup"}),this.#Q.setAttribute("is","fig-popup"),this.#Q.classList.add("fig-menu-popup"),this.#Q.setAttribute("theme","menu"),this.#Q.setAttribute("role","menu"),this.#Q.setAttribute("id",this.#Q.getAttribute("id")||h());let Q=this.getAttribute("position")||"bottom left";this.#Q.setAttribute("position",Q);let Z=this.getAttribute("offset");if(Z)this.#Q.setAttribute("offset",Z);let $=this.getAttribute("closedby");if($)this.#Q.setAttribute("closedby",$);if(this.#$)this.#Q.anchor=this.#$;this.#Z=document.createElement("div"),this.#Z.className="fig-menu-options",this.#Z.setAttribute("role","presentation"),this.#Q.appendChild(this.#Z),this.#Q.addEventListener("close",this.#G),this.appendChild(this.#Q)}#M(){if(!this.#Z)return;let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let Z of Q)this.#Z.appendChild(Z)}#D(){if(this.addEventListener("keydown",this.#K),this.#$)this.#$.addEventListener("click",this.#X),this.#$.addEventListener("contextmenu",this.#W),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded","false"),this.#$.setAttribute("aria-controls",this.#Q.getAttribute("id"));if(this.#Q)this.#Q.addEventListener("click",this.#N),this.#Q.addEventListener("keydown",this.#K)}#T(){if(this.removeEventListener("keydown",this.#K),this.#$)this.#$.removeEventListener("click",this.#X),this.#$.removeEventListener("contextmenu",this.#W);if(this.#Q)this.#Q.removeEventListener("click",this.#N),this.#Q.removeEventListener("keydown",this.#K)}#H(){this.#j=new MutationObserver((Q)=>{for(let Z of Q)for(let $ of Z.addedNodes){if($.nodeType!==1||$===this.#Q)continue;if(($.tagName==="FIG-MENU-ITEM"||$.tagName==="FIG-MENU-SEPARATOR")&&$.parentElement===this)this.#Z?.appendChild($);else if(!this.#$&&$.parentElement===this){if(this.#F(),this.#$)this.#$.addEventListener("click",this.#X),this.#$.addEventListener("contextmenu",this.#W),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded","false"),this.#$.setAttribute("aria-controls",this.#Q.getAttribute("id")),this.#Q.anchor=this.#$,this.#C()}}this.#P()}),this.#j.observe(this,{childList:!0})}#O(){if(!this.#Z)return;this.#S(),this.#Z.addEventListener("scroll",this.#U,{passive:!0}),this.#q?.disconnect(),this.#q=new ResizeObserver(()=>this.#P()),this.#q.observe(this.#Z),requestAnimationFrame(()=>this.#P())}#R(){this.#Z?.removeEventListener("scroll",this.#U),this.#q?.disconnect(),this.#q=null,this.#f()}#P(){return a(this.#Z,this.#Z,"y")}#S(){if(this.#_&&this.#Y&&this.#Z?.contains(this.#_)&&this.#Z?.contains(this.#Y))return;this.#f();let Q=X0({owner:"menu",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>i(this.#Z,"y",-1),onEnd:()=>i(this.#Z,"y",1)});this.#_=Q.start,this.#Y=Q.end,this.#Z.prepend(this.#_),this.#Z.append(this.#Y)}#f(){this.#_?.remove(),this.#Y?.remove(),this.#_=null,this.#Y=null,this.#Z?.classList.remove("overflow-start","overflow-end")}#I(){if(!this.#Z)return[];return Array.from(this.#Z.querySelectorAll("fig-menu-item")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#A(){let Q=this.#I();if(!Q.length){this.#L=-1;return}let Z=document.activeElement,$=Q.findIndex((J)=>J===Z||J.contains(Z));this.#L=$>=0?$:-1}#E(Q){let Z=this.#I();if(!Z.length)return;let $=(Q+Z.length)%Z.length;this.#L=$;let J=Z[$];J.focus(),S0(this.#Z,J,"y")}#C(){let Q=this.#k();if(Q)if(this.open)this.removeAttribute("open");else this.#m();if(!this.#$)return;if(Q)this.#$.setAttribute("disabled",""),this.#$.setAttribute("aria-disabled","true"),this.#$.setAttribute("aria-expanded","false");else this.#$.removeAttribute("disabled"),this.#$.removeAttribute("aria-disabled")}#k(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#y(Q){if(this.#z())return;if(this.#k())return;Q.stopPropagation();let Z=this.#Q?.matches?.(":open")??!1;if(this.open&&!Z)this.removeAttribute("open");if(this.open&&Z)this.open=!1;else{if(this.#Q&&this.#$)this.#Q.anchor=this.#$;this.open=!0}}#v(Q){if(!this.#z())return;if(this.#k())return;Q.preventDefault(),Q.stopPropagation(),this.#b(Q.clientX,Q.clientY)}#b(Q,Z){let $=!1,J=0,j=()=>{window.clearTimeout(J),window.removeEventListener("pointerup",q,!0),window.removeEventListener("pointercancel",_,!0)},q=()=>{if($)return;$=!0,j(),requestAnimationFrame(()=>this.showAt(Q,Z))},_=()=>{if($)return;$=!0,j()};window.addEventListener("pointerup",q,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),J=window.setTimeout(q,180)}#w(Q){if(this.#k())return;let Z=Q.target.closest("fig-menu-item");if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#x(Z)}#V(Q){if(this.#k())return;if(Q.currentTarget===document&&Q.key!=="Escape")return;if(Q.currentTarget===this&&this.#Q?.contains(Q.target))return;if(!this.open||!this.#Q?.matches?.(":open")){if(this.#$?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" ")){if(Q.preventDefault(),this.#Q&&this.#$)this.#Q.anchor=this.#$;this.open=!0,requestAnimationFrame(()=>this.#E(0))}return}let Z=this.#I();if(!Z.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#A(),this.#E(this.#L+1);break}case"ArrowUp":{Q.preventDefault(),this.#A(),this.#E(this.#L-1);break}case"Home":{Q.preventDefault(),this.#E(0);break}case"End":{Q.preventDefault(),this.#E(Z.length-1);break}case"Escape":{Q.preventDefault(),this.open=!1,this.#$?.focus();break}case"Enter":case" ":{this.#A();let $=Z[this.#L];if(!$)return;Q.preventDefault(),this.#x($);break}}}#g(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#$)this.#$.setAttribute("aria-expanded","false"),this.#$.focus();this.#L=-1}#x(Q){let Z=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("change",{detail:{value:Z,item:Q},bubbles:!0})),this.open=!1}showAt(Q,Z){if(this.#k())return;if(this.#J={getBoundingClientRect:()=>({width:0,height:0,top:Z,right:Q,bottom:Z,left:Q,x:Q,y:Z})},this.#Q)this.#Q.anchor=this.#J;if(this.open)this.open=!1;requestAnimationFrame(()=>{if(this.#k())return;this.open=!0})}#c(){if(!this.#Q||this.#k()){if(this.hasAttribute("open"))this.removeAttribute("open");return}if(this.#Q.open=!0,document.addEventListener("keydown",this.#K,!0),this.#$)this.#$.setAttribute("aria-expanded","true");this.#L=-1,requestAnimationFrame(()=>{if(this.#P(),!this.#$?.matches?.(":focus-visible"))return;this.#E(0)})}#m(){if(!this.#Q)return;document.removeEventListener("keydown",this.#K,!0),this.#Q.open=!1,this.#$?.setAttribute("aria-expanded","false")}}z("fig-menu",f1);