@rogieking/figui3 6.32.2 → 6.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/fig.js CHANGED
@@ -1,4 +1,4 @@
1
- var w1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var v1={};var P0=w1(()=>{/*! 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,C=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(n).observe(Q,x),T0(Document.prototype,"importNode"),T0(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 f=P[J]+'[is="'+U+'"]',I=Q.querySelectorAll(f);for(var V=0,g=I.length;V<g;V++)e(I[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=N0(U);if(D&&!(U instanceof D.Class))D0(U,D);else M.call(Z,U)}},whenDefined:{value:function(U){return U in k?Promise.resolve():C.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(n).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))J0(this,e)}}});function n(U){for(var D=0,P=U.length;D<P;D++){var f=U[D],I=f.addedNodes,V=f.removedNodes;for(var g=0,j0=I.length;g<j0;g++)e(I[g]);for(var W0=0,y1=V.length;W0<y1;W0++)R0(V[W0])}}function A0(U){for(var D=0,P=U.length;D<P;D++){var f=U[D],I=f.attributeName,V=f.oldValue,g=f.target,j0=g.getAttribute(I);if(Y in g&&!(V==j0&&j0==null))g[Y](I,V,g.getAttribute(I),null)}}function R0(U){if(U.nodeType!==1)return;var D=N0(U);if(D&&U instanceof D.Class&&G in U&&S.get(U)!==G)S.set(U,G),Promise.resolve(U).then(x1);J0(U,R0)}function N0(U){var D=U.getAttribute("is");if(D){if(D=D.toLowerCase(),D in k)return k[D]}return null}function V1(U){U[K]()}function x1(U){U[G]()}function D0(U,D){var P=D.Class,f=P.observedAttributes||[];if(T(U,P.prototype),f.length){new MutationObserver(A0).observe(U,{attributes:!0,attributeFilter:f,attributeOldValue:!0});var I=[];for(var V=0,g=f.length;V<g;V++)I.push({attributeName:f[V],oldValue:null,target:U});A0(I)}}function e(U){if(U.nodeType!==1)return;var D=N0(U);if(D){if(!(U instanceof D.Class))D0(U,D);if(K in U&&U.isConnected&&S.get(U)!==K)S.set(U,K),Promise.resolve(U).then(V1)}J0(U,e)}function J0(U,D){for(var P=U.content,f=(P&&P.nodeType==11?P:U).querySelectorAll("[is]"),I=0,V=f.length;I<V;I++)D(f[I])}function T0(U,D){var P=U[D],f={};f[D]={value:function(){var I=P.apply(this,arguments);switch(I.nodeType){case 1:case 11:J0(I,e)}return I}},B(U,f)}})()}})(document,customElements,Object)});function h1(){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 l(Q,Z,$){let J=Number(Z),j=Number($),q=Number.isFinite(J)?Math.max(0,Math.min(1,J)):Number.isFinite(j)?Math.max(0,Math.min(100,j))/100:1,_=Number.isFinite(j)?Math.max(0,Math.min(100,j)):Math.round(q*100);return{color:Q,alpha:q,opacity:_}}function _0(Q){Q.querySelectorAll(':scope > [slot="prepend"], :scope > [slot="append"]').forEach((Z)=>{if(Z.children.length>0){U0(Z);return}let $=Z.textContent.trim();if(!$){U0(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 U0(Z)})}function g1(Q){if(Q.dataset.figInputSlotTooltipBound==="true")return;Q.dataset.figInputSlotTooltipBound="true",Q.addEventListener("pointerenter",C0),Q.addEventListener("pointerleave",L0),Q.addEventListener("focus",C0),Q.addEventListener("blur",L0)}function U0(Q){L0({currentTarget:Q}),delete Q.dataset.figInputSlotFullText,Q.removeAttribute("aria-label")}function C0(Q){let Z=Q.currentTarget,$=Z?.dataset?.figInputSlotFullText;if(!Z||!$)return;H.show(Z,$)}function L0(Q){let Z=Q.currentTarget;if(!Z)return;H.hide(Z)}function Y0({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 t(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 r(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 I0(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){t(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}),t(Q,Q,$)})}function i(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function b1(){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=h1()&&!b1(),m1=(f0?Promise.resolve().then(() => (P0(),v1)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q});function O0(Q,Z,$){let J=()=>{if(!customElements.get(Q))customElements.define(Q,Z,$)};if(!f0){J();return}m1.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 q0(){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 c1=1e4;function V0(){return c1++}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 F0(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 x0 extends HTMLElement{type;#Q;#Z=new WeakMap;#$=["aria-label","aria-labelledby","aria-describedby","title"];#J=this.#N.bind(this);#j=this.#U.bind(this);#q=()=>this.#z();#Y=()=>{if(this.button?.matches(":focus-visible"))this.setAttribute("data-focus-visible","")};#_=()=>{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 hq=(q,Q)=>()=>(q&&(Q=q(q=0)),Q);var vq={};var P0=hq(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(q,Q,Z){if(q.importNode.length!=1||Q.get("ungap-li"))return;var $="extends";try{var J={};J[$]="li";var j=HTMLLIElement,_=function(){return Reflect.construct(j,[],_)};if(_.prototype=Z.create(j.prototype),Q.define("ungap-li",_,J),!/is="ungap-li"/.test(new _().outerHTML))throw J}catch(W){(function(){var N="attributeChangedCallback",K="connectedCallback",G="disconnectedCallback",U=Element.prototype,X=Z.assign,O=Z.create,R=Z.defineProperties,L=Z.getOwnPropertyDescriptor,D=Z.setPrototypeOf,F=Q.define,H=Q.get,B=Q.upgrade,f=Q.whenDefined,I=O(null),S=new WeakMap,x={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(Y){return typeof Y=="string"&&/^HTML(?!Element)/.test(Y)}).forEach(function(Y){function T(){}var P=self[Y];D(T,P),(T.prototype=P.prototype).constructor=T,P={},P[Y]={value:T},R(self,P)}),new MutationObserver(n).observe(q,x),D0(Document.prototype,"importNode"),D0(Node.prototype,"cloneNode"),R(Q,{define:{value:function(Y,T,P){if(Y=Y.toLowerCase(),P&&$ in P){I[Y]=X({},P,{Class:T});var V=P[$]+'[is="'+Y+'"]',C=q.querySelectorAll(V);for(var E=0,v=C.length;E<v;E++)e(C[E])}else F.apply(Q,arguments)}},get:{value:function(Y){return Y in I?I[Y].Class:H.call(Q,Y)}},upgrade:{value:function(Y){var T=U0(Y);if(T&&!(Y instanceof T.Class))T0(Y,T);else B.call(Q,Y)}},whenDefined:{value:function(Y){return Y in I?Promise.resolve():f.call(Q,Y)}}});var w=q.createElement;R(q,{createElement:{value:function(Y,T){var P=w.call(q,Y);if(T&&"is"in T)P.setAttribute("is",T.is),Q.upgrade(P);return P}}});var g=L(U,"attachShadow").value,d=L(U,"innerHTML");R(U,{attachShadow:{value:function(){var Y=g.apply(this,arguments);return new MutationObserver(n).observe(Y,x),Y}},innerHTML:{get:d.get,set:function(Y){if(d.set.call(this,Y),/\bis=("|')?[a-z0-9_-]+\1/i.test(Y))$0(this,e)}}});function n(Y){for(var T=0,P=Y.length;T<P;T++){var V=Y[T],C=V.addedNodes,E=V.removedNodes;for(var v=0,J0=C.length;v<J0;v++)e(C[v]);for(var X0=0,bq=E.length;X0<bq;X0++)F0(E[X0])}}function H0(Y){for(var T=0,P=Y.length;T<P;T++){var V=Y[T],C=V.attributeName,E=V.oldValue,v=V.target,J0=v.getAttribute(C);if(N in v&&!(E==J0&&J0==null))v[N](C,E,v.getAttribute(C),null)}}function F0(Y){if(Y.nodeType!==1)return;var T=U0(Y);if(T&&Y instanceof T.Class&&G in Y&&S.get(Y)!==G)S.set(Y,G),Promise.resolve(Y).then(yq);$0(Y,F0)}function U0(Y){var T=Y.getAttribute("is");if(T){if(T=T.toLowerCase(),T in I)return I[T]}return null}function wq(Y){Y[K]()}function yq(Y){Y[G]()}function T0(Y,T){var P=T.Class,V=P.observedAttributes||[];if(D(Y,P.prototype),V.length){new MutationObserver(H0).observe(Y,{attributes:!0,attributeFilter:V,attributeOldValue:!0});var C=[];for(var E=0,v=V.length;E<v;E++)C.push({attributeName:V[E],oldValue:null,target:Y});H0(C)}}function e(Y){if(Y.nodeType!==1)return;var T=U0(Y);if(T){if(!(Y instanceof T.Class))T0(Y,T);if(K in Y&&Y.isConnected&&S.get(Y)!==K)S.set(Y,K),Promise.resolve(Y).then(wq)}$0(Y,e)}function $0(Y,T){for(var P=Y.content,V=(P&&P.nodeType==11?P:Y).querySelectorAll("[is]"),C=0,E=V.length;C<E;C++)T(V[C])}function D0(Y,T){var P=Y[T],V={};V[T]={value:function(){var C=P.apply(this,arguments);switch(C.nodeType){case 1:case 11:$0(C,e)}return C}},R(Y,V)}})()}})(document,customElements,Object)});function mq(){if(typeof navigator>"u")return!1;let q=navigator.userAgent||"",Q=/\b(iPad|iPhone|iPod)\b/.test(q)||/\bMacintosh\b/.test(q)&&/\bMobile\b/.test(q),Z=/\bAppleWebKit\b/.test(q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(q);return Q||Z}function c(q,Q={}){let Z=document.createElement("fig-icon");if(q)Z.setAttribute("name",q);if(Q.size)Z.setAttribute("size",Q.size);if(Q.className)Z.className=Q.className;return Z}function u(q,Q){requestAnimationFrame(()=>{if(q&&!q.isConnected)return;Q()})}function z(q,Q){return q.hasAttribute(Q)&&q.getAttribute(Q)!=="false"}function l(q,Q,Z){let $=Number(Q),J=Number(Z),j=Number.isFinite($)?Math.max(0,Math.min(1,$)):Number.isFinite(J)?Math.max(0,Math.min(100,J))/100:1,_=Number.isFinite(J)?Math.max(0,Math.min(100,J)):Math.round(j*100);return{color:q,alpha:j,opacity:_}}function _0(q){q.querySelectorAll(':scope > [slot="prepend"], :scope > [slot="append"]').forEach((Q)=>{if(Q.children.length>0){Y0(Q);return}let Z=Q.textContent.trim();if(!Z){Y0(Q);return}let $=Q.dataset.figInputSlotFullText||"",J=$?Array.from($)[0]?.toUpperCase():"",j=Z===J?$:Z,W=Array.from(Z)[0].toUpperCase();if(Q.textContent!==W)Q.textContent=W;if(j&&j!==W)Q.dataset.figInputSlotFullText=j,Q.setAttribute("aria-label",j),gq(Q);else Y0(Q)})}function gq(q){if(q.dataset.figInputSlotTooltipBound==="true")return;q.dataset.figInputSlotTooltipBound="true",q.addEventListener("pointerenter",f0),q.addEventListener("pointerleave",L0),q.addEventListener("focus",f0),q.addEventListener("blur",L0)}function Y0(q){L0({currentTarget:q}),delete q.dataset.figInputSlotFullText,q.removeAttribute("aria-label")}function f0(q){let Q=q.currentTarget,Z=Q?.dataset?.figInputSlotFullText;if(!Q||!Z)return;A.show(Q,Z)}function L0(q){let Q=q.currentTarget;if(!Q)return;A.hide(Q)}function N0({owner:q,onStart:Q,onEnd:Z,startClass:$="",endClass:J="",chevronClass:j="",startLabel:_="Scroll back",endLabel:W="Scroll forward"}={}){let N=(K,G)=>{let U=document.createElement("button");if(U.type="button",U.className=["fig-overflow",`fig-overflow-${K}`,K==="start"?$:J].filter(Boolean).join(" "),U.dataset.figOverflow=K,q)U.setAttribute(`data-fig-${q}-nav`,K);return U.setAttribute("tabindex","-1"),U.setAttribute("aria-label",K==="start"?_:W),U.appendChild(c("chevron",{size:"small",className:["fig-overflow-chevron",j].filter(Boolean).join(" ")})),U.addEventListener("click",(X)=>{X.preventDefault(),X.stopPropagation(),G?.(X)}),U};return{start:N("start",Q),end:N("end",Z)}}function a(q,Q,Z="x",$=2){if(!q||!Q)return!1;let J=Z==="x",j=J?Q.scrollWidth:Q.scrollHeight,_=J?Q.clientWidth:Q.clientHeight,W=J?Q.scrollLeft:Q.scrollTop,N=j-_>$,K=!N||W<=$,G=!N||W+_>=j-$;return q.classList.toggle("overflow-start",!K),q.classList.toggle("overflow-end",!G),N}function r(q,Q="x",Z=1){if(!q)return;let $=Q==="x",j=($?q.clientWidth:q.clientHeight)*0.8*Z;q.scrollBy({[$?"left":"top"]:j,behavior:"smooth"})}function C0(q,Q,Z="y",$="auto"){if(!q||!Q||!q.contains(Q))return;requestAnimationFrame(()=>{if(!q.isConnected||!Q.isConnected)return;let J=Z==="x",j=J?q.scrollWidth:q.scrollHeight,_=J?q.clientWidth:q.clientHeight;if(j<=_+1){a(q,q,Z);return}let W=Q.getBoundingClientRect(),N=q.getBoundingClientRect(),K=J?q.scrollLeft:q.scrollTop,G=(J?W.left-N.left:W.top-N.top)+K,U=J?W.width:W.height,X=j-_,O=Math.max(0,Math.min(G+U/2-_/2,X));q.scrollTo({[J?"left":"top"]:O,behavior:$}),a(q,q,Z)})}function o(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function uq(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class Q extends HTMLButtonElement{}try{return customElements.define(q,Q,{extends:"button"}),document.createElement("button",{is:q})instanceof Q}catch(Z){return!1}}var V0=mq()&&!uq(),cq=(V0?Promise.resolve().then(() => (P0(),vq)):Promise.resolve()).then(()=>{}).catch((q)=>{throw q});function O0(q,Q,Z){let $=()=>{if(!customElements.get(q))customElements.define(q,Q,Z)};if(!V0){$();return}cq.then($).catch((J)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${q}".`,J)})}function M(q,Q){if(!customElements.get(q))customElements.define(q,Q)}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",Q=document.body.querySelector(`:scope > [${q}]`);if(!Q)Q=document.createElement("div"),Q.setAttribute(q,""),document.body.append(Q);return Q}var pq=1e4;function E0(){return pq++}function m(q,Q,Z){if(Z&&Z.trim())q.style.setProperty(Q,Z.trim());else q.style.removeProperty(Q)}function b(q){return String(q??"").replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var s=null,k0=null;function z0(q=1,Q=1){if(!s)s=document.createElement("canvas"),k0=s.getContext("2d");if(s.width!==q)s.width=q;if(s.height!==Q)s.height=Q;return{canvas:s,ctx:k0}}class x0 extends HTMLElement{type;#Q;#q=new WeakMap;#Z=["aria-label","aria-labelledby","aria-describedby","title"];#$=this.#X.bind(this);#J=this.#Y.bind(this);#j=()=>this.#M();#N=()=>{if(this.button?.matches(":focus-visible"))this.setAttribute("data-focus-visible","")};#_=()=>{this.removeAttribute("data-focus-visible")};constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){if(this.type=this.getAttribute("type")||"button",!this.button){let Q=this.type==="select"||this.type==="upload",Z=Q?"span":"button",$=Q?"":' type="button"';this.shadowRoot.innerHTML=`
2
2
  <style>
3
3
  button, button:hover, button:active, .fig-button-control {
4
4
  padding: 0 var(--spacer-2);
@@ -31,14 +31,14 @@ var w1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var v1={};var P0=w1(()=>{/*! Vendored from @
31
31
  padding: 0;
32
32
  }
33
33
  </style>
34
- <${$} class="fig-button-control"${J}>
34
+ <${Z} class="fig-button-control"${$}>
35
35
  <slot></slot>
36
- </${$}>
37
- `,this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.button.addEventListener("click",this.#j),this.button.addEventListener("focus",this.#Y),this.button.addEventListener("blur",this.#_)}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"}#U(){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}}#G(){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.#G();if(Q instanceof HTMLSelectElement)return Q;if(Q?.tagName==="FIG-DROPDOWN")return Q.select||Q.querySelector?.("select")||null;return null}#N(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{}}#W(){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.#W()}#z(){let Q=this.#G();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.#W();break;default:this.#L();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#J),this.shadowRoot?.querySelector("slot")?.removeEventListener("slotchange",this.#q)}}z("fig-button",x0);class y0 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.#U.bind(this),this.#J=this.#G.bind(this),this.#j=this.#K.bind(this),this.#q=this.slotChange.bind(this)}#Y(){this.select.addEventListener("input",this.#$),this.select.addEventListener("change",this.#J),this.select.addEventListener("keydown",this.#j)}#_(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.#N(),!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.#Y()}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.#W($);if(this.type==="dropdown")this.select.selectedIndex=-1}#U(Q){Q.stopPropagation();let Z=Q.target.selectedOptions?.[0];if(this.#_(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}))}#G(Q){Q.stopPropagation();let Z=Q.target.selectedOptions?.[0];if(this.#_(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"]}#N(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=Q}#W(Q){if(this.type==="dropdown")return;if(this.select)this.select.value=Q??""}attributeChangedCallback(Q,Z,$){if(Q==="value")this.#W($);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.#N()}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",y0);class H extends HTMLElement{static#Q=0;static#Z=0;static#$=1000;static#J=null;static#j=!1;static#q=new Set;#Y;#_;#X;#U;#G;#K;#N;#W;#L;#F;#z;#B;#M=null;#A=null;#P=null;#D=!1;#H;#O=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#Y=this.#x.bind(this),this.#_=this.hidePopupOutsideClick.bind(this),this.#X=this.showDelayedPopup.bind(this),this.#U=this.#k.bind(this),this.#G=()=>{if(!this.#D)this.showDelayedPopup()},this.#K=()=>{this.#D=!1,this.hidePopup()},this.#N=this.#y.bind(this),this.#W=this.#w.bind(this),this.#L=this.#b.bind(this),this.#F=this.#v.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.#I(),this.setupEventListeners(),this.#M=this.closest("dialog"),this.#M)this.#M.addEventListener("close",this.#z)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#f(),this.#S(),document.removeEventListener("mousedown",this.#Y,!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.#_);if(clearTimeout(this.#H),H.#J===this)H.#J=null}#T(){return this.firstElementChild}#S(){this.#P?.disconnect(),this.#P=null}#I(){if(this.#f(),this.action==="manual")return;let Q=this.#T();if(!Q){if(!this.#P&&typeof MutationObserver<"u")this.#P=new MutationObserver(()=>{if(this.#T())this.#S(),this.#I()}),this.#P.observe(this,{childList:!0});return}if(this.#A=Q,this.action==="hover"){if(!this.isTouchDevice())Q.addEventListener("pointerenter",this.#X),Q.addEventListener("pointerleave",this.#U);Q.addEventListener("touchstart",this.#N,{passive:!0}),Q.addEventListener("touchmove",this.#W,{passive:!0}),Q.addEventListener("touchend",this.#L,{passive:!0}),Q.addEventListener("touchcancel",this.#F,{passive:!0}),Q.addEventListener("focus",this.#G),Q.addEventListener("blur",this.#K)}else if(this.action==="click")Q.addEventListener("click",this.#X),Q.addEventListener("touchstart",this.#X,{passive:!0})}#f(){let Q=this.#A;if(!Q)return;if(this.action==="hover")Q.removeEventListener("pointerenter",this.#X),Q.removeEventListener("pointerleave",this.#U),Q.removeEventListener("touchstart",this.#N),Q.removeEventListener("touchmove",this.#W),Q.removeEventListener("touchend",this.#L),Q.removeEventListener("touchcancel",this.#F),Q.removeEventListener("focus",this.#G),Q.removeEventListener("blur",this.#K);else if(this.action==="click")Q.removeEventListener("click",this.#X),Q.removeEventListener("touchstart",this.#X);this.#A=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)(q0()??document.body).append(this.popup);else{let q=this.closest("dialog");if(q&&q.open)q.append(this.popup);else(q0()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.#R(this.popup.id),this.popup.hidePopup?.(),this.popup.remove(),this.popup=null}#R(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.#_);document.addEventListener("mousedown",this.#Y,!0),document.addEventListener("keydown",this.#B,!0)}get#C(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#E(){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.#C)return;if(clearTimeout(this.timeout),this.#E()){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.#C)return;clearTimeout(this.timeout),clearTimeout(this.#H);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.#O)this.hidePopup()}#y(Q){if(this.action==="hover")this.#O=!0,clearTimeout(this.#H),this.showDelayedPopup()}#w(Q){if(this.action==="hover"&&this.#O)clearTimeout(this.#H),this.#H=setTimeout(()=>{this.#O=!1,this.hidePopup()},150)}#b(Q){if(this.action==="hover"&&this.#O)clearTimeout(this.#H),this.#H=setTimeout(()=>{this.#O=!1,this.hidePopup()},300)}#v(Q){if(this.action==="hover"&&this.#O)this.#O=!1,clearTimeout(this.#H),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)}#m(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.#f(),Z==="click")document.body?.removeEventListener("click",this.#_);if(this.action=$||"hover",this.isConnected){if(this.#I(),this.action==="click")document.body?.addEventListener("click",this.#_)}}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.#m($??"");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.#d()};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.#C)continue;if(Q.#D=!0,setTimeout(()=>{let Z=Q.#A;if(Z!==document.activeElement&&!Z?.matches?.(":focus, :focus-within"))Q.#D=!1},0),Q.isOpen||Q.timeout)Q.hidePopup()}for(let Q of Array.from(H.#q))H.hide(Q)}static#g=new WeakMap;static#d(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof H))continue;if(Q.#C)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.#g.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)(q0()??document.body).append(Y);else{let G=Q.closest?.("dialog");if(G&&G.open)G.append(Y);else(q0()??document.body).append(Y)}Y.anchor=Q,Y.open=!0,_.popup=Y,H.#Q=Date.now()},q)}static hide(Q){let Z=H.#g.get(Q);if(!Z)return;if(clearTimeout(Z.timeout),Z.popup)Z.popup.remove(),H.#Z=Date.now();H.#g.delete(Q),H.#q.delete(Q)}}z("fig-tooltip",H);class w0 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",w0);class v0 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(V0()+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()}}O0("fig-dialog",v0,{extends:"dialog"});class h0 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()}}O0("fig-toast",h0,{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(V0()+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"))}}O0("fig-popup",g0,{extends:"dialog"});class b0 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",b0);class m0 extends HTMLElement{#Q;#Z;#$=this.#L.bind(this);#J=null;#j=null;#q=null;#Y=null;#_=!1;#X=new WeakSet;constructor(){super();this.#Q=this.handleClick.bind(this),this.#Z=this.#A.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.#W(),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.#H(Q);if(F(this,"disabled"))this.#U(!0);this.#K(),this.#L(),this.#N(void 0,"auto")})}#U(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()}#G(){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.#G()[0];Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false";$.setAttribute("tabindex",!J&&$===Z?"0":"-1")})}#N(Q=this.selectedTab,Z="smooth"){let $=Q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#G()[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()}#W(){if(this.#_)return;let Q=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!Q)return;this.#_=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#_=!1}}#L(){t(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.#_)return;this.#W(),this.#M(),this.#K(),requestAnimationFrame(()=>{this.#L(),this.#N()})}),this.#J.observe(this,{childList:!0,subtree:!1})}#B(){this.#q?.remove(),this.#Y?.remove(),this.#q=null,this.#Y=null,this.classList.remove("overflow-start","overflow-end")}#M(){if(this.#q&&this.#Y&&this.contains(this.#q)&&this.contains(this.#Y))return;this.#q?.remove(),this.#Y?.remove();let Q=Y0({owner:"tabs",onStart:()=>r(this,"x",-1),onEnd:()=>r(this,"x",1)});this.#q=Q.start,this.#Y=Q.end,this.prepend(this.#q),this.append(this.#Y)}#A(Q){let Z=this.#G();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.#D(Z[J]);if(j)this.setAttribute("value",j);else this.removeAttribute("value");Z[J].focus(),this.#K(),this.#N(Z[J]),this.#P()}}get value(){return this.#D(this.selectedTab)}set value(Q){this.setAttribute("value",Q)}#P(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#D(Q){if(!Q)return"";let Z=Q.getAttribute("value");if(Z!==null)return Z;return Q.textContent?.trim()||""}#H(Q){let Z=this.querySelectorAll("fig-tab");for(let $ of Z)if(this.#D($)===Q)this.selectedTab=$,$.setAttribute("selected","true");else $.removeAttribute("selected");this.#K(),this.#N(this.selectedTab)}attributeChangedCallback(Q,Z,$){switch(Q){case"value":if($!==Z)this.#H($);break;case"disabled":this.#U($!==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.#D(Z);if(q)this.setAttribute("value",q);else this.removeAttribute("value");if(this.#K(),this.#N(Z),$!==Z||J!==this.value)this.#P()}}z("fig-tabs",m0);class c0 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",c0);class u0 extends HTMLElement{#Q=null;#Z=this.handleClick.bind(this);#$=this.#F.bind(this);#J=null;#j=null;#q=0;#Y=!1;#_=!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.#T(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#O(),this.#P(),c(this,()=>{this.#H({enforceFallback:!0}),this.#D(),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.#Y=!1,this.#_=!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.#W(),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))}#U(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#G(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}#N(){return Array.from(this.querySelectorAll("fig-segment")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#W(){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.#G(Q);if(J)this.setAttribute("value",J);else this.removeAttribute("value");let j=this.value;if(Z!==Q||$!==j)this.#U(j)}#F(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#N();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.#G(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.#Y=this.#Y||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let Z=this.#Y;this.#Y=!1,this.#A({forceInstant:Z})})}#A({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.#_=!1;return}if(!J){if(this.#_)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.#_)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.#_||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#_=!0}#P(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#M()}),this.#D()}#D(){if(!this.#j)return;this.#j.disconnect(),this.#j.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#j?.observe(Q)})}#H({enforceFallback:Q=!1}={}){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.#N()[0]||null}#O(){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.#T(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#D(),this.#H({enforceFallback:!0}),this.#W()}),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)}#T(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.#W()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled"){this.#T($!==null&&$!=="false"),this.#M({forceInstant:!0});return}if(Q==="value"){this.#H({enforceFallback:!1});return}if(Q==="animated"){if(!this.#B())this.#_=!1;this.#M({forceInstant:!0});return}if(Q==="sizing")this.#M({forceInstant:!0})}}z("fig-segmented-control",u0);class p0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Q="segments";#Z=0;#$=null;#J=[];#j=null;#q=!1;#Y(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($)}#_(){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.#W()}connectedCallback(){if(this.#U(),this.#_()){this.#X(),this.#F(),c(this,()=>c(this,()=>this.#M()));return}this.#G(),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.#U(),this.#N();return}if(Q==="value"){this.#W();return}if(Q==="disabled"){this.#L("disabled");return}if(Q==="full"){this.#L("full");return}if(Q==="sizing")this.#L("sizing"),this.#N()}#U(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#J=JSON.parse(Q);return}catch{}let Z=Q.includes(`
36
+ </${Z}>
37
+ `,this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.button.addEventListener("click",this.#J),this.button.addEventListener("focus",this.#N),this.button.addEventListener("blur",this.#_)}let q=this.shadowRoot.querySelector("slot");q?.removeEventListener("slotchange",this.#j),q?.addEventListener("slotchange",this.#j),this.removeEventListener("keydown",this.#$),this.addEventListener("keydown",this.#$),this.#Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#z()}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)}#W(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#Y(){if(this.#W())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"),Q=this.getAttribute("target");if(q)if(Q)window.open(q,Q);else window.location.href=q}}#G(){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.#G();if(q instanceof HTMLSelectElement)return q;if(q?.tagName==="FIG-DROPDOWN")return q.select||q.querySelector?.("select")||null;return null}#X(q){if(this.type!=="select")return;if(q.key!=="Enter")return;if(q.altKey||q.ctrlKey||q.metaKey||q.shiftKey)return;let Q=this.#K();if(!Q||Q.disabled||Q.multiple)return;if(typeof Q.showPicker!=="function")return;q.preventDefault();try{Q.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.#Z.forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.button.removeAttribute(q);else this.button.setAttribute(q,Q)})}#z(){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.#M(),this.#L(),this.#U()}#M(){let q=this.#G();if(!q)return;if(this.#W()){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 Z=this.#q.get(q);if(this.#q.delete(q),Z)q.setAttribute("disabled","");else q.removeAttribute("disabled")}}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"type":{let $=(J)=>J==="select"||J==="upload";if($(Q||"button")!==$(Z||"button")){this.button=null,this.connectedCallback();break}this.#z();break}case"disabled":this.#z();break;case"selected":this.#Q=Z!==null&&Z!=="false",this.#U();break;default:this.#L();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#$),this.shadowRoot?.querySelector("slot")?.removeEventListener("slotchange",this.#j)}}M("fig-button",x0);class w0 extends HTMLElement{#Q="Menu";#q=null;#Z;#$;#J;get label(){return this.#Q}set label(q){this.#Q=q}#j;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#Z=this.#Y.bind(this),this.#$=this.#G.bind(this),this.#J=this.#K.bind(this),this.#j=this.slotChange.bind(this)}#N(){this.select.addEventListener("input",this.#Z),this.select.addEventListener("change",this.#$),this.select.addEventListener("keydown",this.#J)}#_(q){if(!q||!(q instanceof Element))return!1;return!!q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#W(){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.#X(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#j),this.optionsSlot.addEventListener("slotchange",this.#j),this.select.removeEventListener("input",this.#Z),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#J),this.#N()}slotChange(){let q=this.hasAttribute("value"),Q=this.select.options.length>0&&this.select.selectedIndex>=0,Z=q?this.getAttribute("value"):this.type==="dropdown"?this.#q:Q?this.select.value:null;while(this.select.firstChild)this.select.firstChild.remove();if(this.type==="dropdown"){let $=document.createElement("option");$.setAttribute("hidden","true"),$.setAttribute("selected","true"),$.selected=!0,this.select.appendChild($)}if(this.optionsSlot.assignedNodes().forEach(($)=>{if($.nodeName==="OPTION"||$.nodeName==="OPTGROUP")this.select.appendChild($.cloneNode(!0))}),Z!==null)this.#U(Z);if(this.type==="dropdown")this.select.selectedIndex=-1}#Y(q){q.stopPropagation();let Q=q.target.selectedOptions?.[0];if(this.#_(Q)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#W();return}let Z=q.target.value;if(this.type==="dropdown")this.#q=Z;this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}#G(q){q.stopPropagation();let Q=q.target.selectedOptions?.[0];if(this.#_(Q)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#W();return}let Z=this.type==="dropdown"?this.#q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.dispatchEvent(new CustomEvent("change",{detail:Z,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"]}#X(){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,Q,Z){if(q==="value")this.#U(Z);if(q==="type"){if(this.type=Z||"select",this.isConnected)this.slotChange()}if(q==="label")this.#Q=Z||"Menu",this.select.setAttribute("aria-label",this.#Q);if(q==="disabled")this.#X()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#j),this.select.removeEventListener("input",this.#Z),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#J)}}M("fig-dropdown",w0);class A extends HTMLElement{static#Q=0;static#q=0;static#Z=1000;static#$=null;static#J=!1;static#j=new Set;#N;#_;#W;#Y;#G;#K;#X;#U;#L;#z;#M;#B;#R=null;#H=null;#D=null;#T=!1;#A;#O=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(q)?q:500,this.#N=this.#x.bind(this),this.#_=this.hidePopupOutsideClick.bind(this),this.#W=this.showDelayedPopup.bind(this),this.#Y=this.#S.bind(this),this.#G=()=>{if(!this.#T)this.showDelayedPopup()},this.#K=()=>{this.#T=!1,this.hidePopup()},this.#X=this.#w.bind(this),this.#U=this.#y.bind(this),this.#L=this.#u.bind(this),this.#z=this.#b.bind(this),this.#B=this.#E.bind(this),this.#M=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(A.#v(),this.setup(),this.#C(),this.setupEventListeners(),this.#R=this.closest("dialog"),this.#R)this.#R.addEventListener("close",this.#M)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#V(),this.#k(),document.removeEventListener("mousedown",this.#N,!0),document.removeEventListener("keydown",this.#B,!0),this.#R)this.#R.removeEventListener("close",this.#M),this.#R=null;if(this.action==="click")document.body.removeEventListener("click",this.#_);if(clearTimeout(this.#A),A.#$===this)A.#$=null}#P(){return this.firstElementChild}#k(){this.#D?.disconnect(),this.#D=null}#C(){if(this.#V(),this.action==="manual")return;let q=this.#P();if(!q){if(!this.#D&&typeof MutationObserver<"u")this.#D=new MutationObserver(()=>{if(this.#P())this.#k(),this.#C()}),this.#D.observe(this,{childList:!0});return}if(this.#H=q,this.action==="hover"){if(!this.isTouchDevice())q.addEventListener("pointerenter",this.#W),q.addEventListener("pointerleave",this.#Y);q.addEventListener("touchstart",this.#X,{passive:!0}),q.addEventListener("touchmove",this.#U,{passive:!0}),q.addEventListener("touchend",this.#L,{passive:!0}),q.addEventListener("touchcancel",this.#z,{passive:!0}),q.addEventListener("focus",this.#G),q.addEventListener("blur",this.#K)}else if(this.action==="click")q.addEventListener("click",this.#W),q.addEventListener("touchstart",this.#W,{passive:!0})}#V(){let q=this.#H;if(!q)return;if(this.action==="hover")q.removeEventListener("pointerenter",this.#W),q.removeEventListener("pointerleave",this.#Y),q.removeEventListener("touchstart",this.#X),q.removeEventListener("touchmove",this.#U),q.removeEventListener("touchend",this.#L),q.removeEventListener("touchcancel",this.#z),q.removeEventListener("focus",this.#G),q.removeEventListener("blur",this.#K);else if(this.action==="click")q.removeEventListener("click",this.#W),q.removeEventListener("touchstart",this.#W);this.#H=null}setup(){this.style.display="contents"}render(){this.destroy();let q=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Q=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 Z=h();this.popup.setAttribute("id",Z);let $=this.getAttribute("theme");if($)this.popup.setAttribute("theme",$);let J=this.getAttribute("pointer");if(J!==null)this.popup.setAttribute("pointer",J);if(this.popup.append(Q),Q.innerText=this.getAttribute("text")??"",this.firstElementChild){let j=new Set((this.firstElementChild.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));j.add(Z),this.firstElementChild.setAttribute("aria-describedby",[...j].join(" "))}if(q)(j0()??document.body).append(this.popup);else{let j=this.closest("dialog");if(j&&j.open)j.append(this.popup);else(j0()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.#F(this.popup.id),this.popup.hidePopup?.(),this.popup.remove(),this.popup=null}#F(q){let Q=this.firstElementChild;if(!Q||!q)return;let Z=Q.getAttribute("aria-describedby");if(!Z)return;let $=Z.split(/\s+/).filter((J)=>J&&J!==q).join(" ");if($)Q.setAttribute("aria-describedby",$);else Q.removeAttribute("aria-describedby")}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#_);document.addEventListener("mousedown",this.#N,!0),document.addEventListener("keydown",this.#B,!0)}get#f(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#I(){let q=Date.now(),Q=A.#Z;if(this.action==="hover"&&A.#$)return!0;if(A.#Q&&q-A.#Q<Q)return!0;if(A.#q&&q-A.#q<Q)return!0;return!1}showDelayedPopup(){if(this.#f)return;if(clearTimeout(this.timeout),this.#I()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#R&&!this.#R.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&A.#$&&A.#$!==this)A.#$.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")A.#$=this;A.#Q=Date.now()}hidePopup(){if(this.#f)return;clearTimeout(this.timeout),clearTimeout(this.#A);let q=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,A.#$===this)A.#$=null;if(q)A.#q=Date.now()}hidePopupOutsideClick(q){if(this.isOpen&&!this.popup.contains(q.target))this.hidePopup()}#S(q){if(!this.#O)this.hidePopup()}#w(q){if(this.action==="hover")this.#O=!0,clearTimeout(this.#A),this.showDelayedPopup()}#y(q){if(this.action==="hover"&&this.#O)clearTimeout(this.#A),this.#A=setTimeout(()=>{this.#O=!1,this.hidePopup()},150)}#u(q){if(this.action==="hover"&&this.#O)clearTimeout(this.#A),this.#A=setTimeout(()=>{this.#O=!1,this.hidePopup()},300)}#b(q){if(this.action==="hover"&&this.#O)this.#O=!1,clearTimeout(this.#A),this.hidePopup()}#E(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)}#h(q){if(!this.popup)return;let Q=this.popup.firstElementChild??this.popup.firstChild;if(!Q)return;Q.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,Q,Z){if(q==="action"){if(this.#V(),Q==="click")document.body?.removeEventListener("click",this.#_);if(this.action=Z||"hover",this.isConnected){if(this.#C(),this.action==="click")document.body?.addEventListener("click",this.#_)}}if(q==="delay"){let $=parseInt(Z);this.delay=!isNaN($)?$:500}if(q==="open")if(Z!==null&&Z!=="false")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(q==="show")if(Z!==null&&Z!=="false")this.showPopup();else this.hidePopup();if(q==="text")this.#h(Z??"");if(q==="pointer"){if(this.popup)if(Z!==null)this.popup.setAttribute("pointer",Z);else this.popup.removeAttribute("pointer")}if(q==="theme"){if(this.popup)if(Z)this.popup.setAttribute("theme",Z);else this.popup.removeAttribute("theme")}}#x(q){if(!this.isOpen)return;let Q=q.target;if(this.popup&&this.popup.contains(Q))return;if(Q.tagName==="SELECT"||Q.hasAttribute("popover")||Q.closest("dialog"))this.hidePopup()}static#v(){if(A.#J)return;A.#J=!0;let q=()=>{A.dismissHoverTooltips()},Q=()=>{A.#o()};document.documentElement.addEventListener("mouseleave",q),document.addEventListener("mouseout",(Z)=>{if(Z.relatedTarget)return;q()}),document.addEventListener("scroll",Q,{capture:!0,passive:!0}),window.addEventListener("scroll",Q,{passive:!0}),window.visualViewport?.addEventListener("scroll",Q,{passive:!0}),window.visualViewport?.addEventListener("resize",Q,{passive:!0});try{let Z=window.frameElement;if(Z)Z.addEventListener("mouseleave",q)}catch{}window.addEventListener("message",(Z)=>{if(Z?.data?.type!=="figui:dismiss-tooltips")return;if(window.parent!==window&&Z.source!==window.parent)return;q()})}static dismissHoverTooltips(){for(let q of document.querySelectorAll("fig-tooltip")){if(!(q instanceof A))continue;if(q.action!=="hover")continue;if(q.#f)continue;if(q.#T=!0,setTimeout(()=>{let Q=q.#H;if(Q!==document.activeElement&&!Q?.matches?.(":focus, :focus-within"))q.#T=!1},0),q.isOpen||q.timeout)q.hidePopup()}for(let q of Array.from(A.#j))A.hide(q)}static#g=new WeakMap;static#o(){for(let q of document.querySelectorAll("fig-tooltip")){if(!(q instanceof A))continue;if(q.#f)continue;if(q.isOpen||q.timeout)q.hidePopup()}for(let q of Array.from(A.#j))A.hide(q)}static show(q,Q,Z={}){A.#v(),A.hide(q);let $=Z.delay??500,j=Date.now()-A.#Q<A.#Z?0:$,_={timeout:null,popup:null};A.#g.set(q,_),A.#j.add(q),_.timeout=setTimeout(()=>{let W=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,N=document.createElement("dialog",{is:"fig-popup"});if(N.setAttribute("is","fig-popup"),N.setAttribute("variant","tooltip"),N.setAttribute("data-tooltip-managed",""),N.setAttribute("role","tooltip"),N.setAttribute("closedby","closerequest"),W)N.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=Q,N.append(K),W)(j0()??document.body).append(N);else{let G=q.closest?.("dialog");if(G&&G.open)G.append(N);else(j0()??document.body).append(N)}N.anchor=q,N.open=!0,_.popup=N,A.#Q=Date.now()},j)}static hide(q){let Q=A.#g.get(q);if(!Q)return;if(clearTimeout(Q.timeout),Q.popup)Q.popup.remove(),A.#q=Date.now();A.#g.delete(q),A.#j.delete(q)}}M("fig-tooltip",A);class y0 extends HTMLElement{static observedAttributes=["position","tail"];#Q=null;#q=null;#Z=null;connectedCallback(){this.#Q=this.textContent,u(this,()=>{this.#$(),this.#J()})}disconnectedCallback(){this.#j()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(this.#Q===null)return;this.#$()}#$(){let q=this.getAttribute("position")||"right",Q=this.#Q||"";if(q==="middle"){let Z=this.getAttribute("tail"),$;if(Z){let _=Q.lastIndexOf(Z);$=_>0?_:Math.ceil(Q.length/2)}else $=Math.ceil(Q.length/2);this.innerHTML="";let J=document.createElement("span");J.className="start",J.textContent=Q.slice(0,$);let j=document.createElement("span");j.className="end",j.textContent=Q.slice($),this.appendChild(J),this.appendChild(j)}else this.textContent=Q}#J(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#q=()=>{if(this.scrollWidth<=this.clientWidth)return;A.show(this,this.#Q)},this.#Z=()=>{A.hide(this)},this.addEventListener("pointerenter",this.#q),this.addEventListener("pointerleave",this.#Z)}#j(){if(this.#q)this.removeEventListener("pointerenter",this.#q);if(this.#Z)this.removeEventListener("pointerleave",this.#Z);A.hide(this)}}M("fig-truncate",y0);class b0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._isDragging=!1,this._dragPending=!1,this._dragStartPos={x:0,y:0},this._dragOffset={x:0,y:0},this._resizeObserver=null,this._mutationObserver=null,this._autoResizeRafId=0,this._offset=16,this._positionInitialized=!1,this._dragThreshold=3,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundClose=this.close.bind(this),this._boundIframeMessage=this._handleIframeMessage.bind(this),this._boundContentMutation=this._scheduleAutoResize.bind(this),this._boundContentResize=this._scheduleAutoResize.bind(this),this._boundRestoreFocus=this._restoreFocus.bind(this),this._boundIframeMouseLeave=this._handleIframeMouseLeave.bind(this),this._iframeDismissMutationObserver=null,this._previousFocus=null}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){if(this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),this.open&&!this.matches?.(":modal"))this._assignStackingOrder();u(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._setupIframeDismissListeners(),this._syncA11y()}),window.addEventListener("message",this._boundIframeMessage)}disconnectedCallback(){this._figInit(),this._removeDragListeners(),this.querySelectorAll("fig-button[close-dialog]").forEach((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 Q=document.activeElement;if(Q&&Q!==document.body&&!this.contains(Q))return;requestAnimationFrame(()=>q.focus?.())}_assignStackingOrder(){this.style.zIndex=String(E0()+1)}_clearStackingOrder(){this.style.zIndex=""}show(){return this._captureFocusBeforeOpen(),this._assignStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),A.dismissHoverTooltips(),super.show()}showModal(){return this._captureFocusBeforeOpen(),this._clearStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),A.dismissHoverTooltips(),super.showModal()}close(...q){let Q=super.close(...q);return this._clearStackingOrder(),Q}_handleIframeMouseLeave(q){let Q=q?.currentTarget;if(!(Q instanceof HTMLIFrameElement))return;try{Q.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 Q=q?.data;if(!Q||Q.type!=="figui:iframe-resize")return;let Z=q.source;if(!Z)return;let $=Array.from(this.querySelectorAll("iframe")).find((J)=>J.contentWindow===Z);if(!$)return;this._resizeForIframe($,Q)}_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 Q of q)Q.addedNodes?.forEach((Z)=>{if(Z instanceof Element&&Z.parentElement===this)try{this._resizeObserver?.observe(Z)}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 Q=window.getComputedStyle(this),Z=parseFloat(Q.paddingTop||"0")+parseFloat(Q.paddingBottom||"0")+parseFloat(Q.borderTopWidth||"0")+parseFloat(Q.borderBottomWidth||"0"),$=0,J=parseFloat(Q.rowGap||Q.gap||"0")||0,j=0;for(let _ of this.children){let W=_.getBoundingClientRect();if(W.height===0)continue;if(j+=1,_===q)continue;let N=window.getComputedStyle(_),K=parseFloat(N.marginTop||"0")+parseFloat(N.marginBottom||"0");$+=W.height+K}if(J&&j>1)$+=J*(j-1);return Z+$}_resizeForIframe(q,Q){if(typeof Q.height!=="number"||!(Q.height>0))return;let Z=this._computeChrome(q);this.style.height=`${Math.ceil(Q.height+Z)}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 Q=document.createElement("h3");Q.textContent=this.getAttribute("title")||"Dialog";let Z=document.createElement("fig-tooltip");Z.setAttribute("text","Close");let $=document.createElement("fig-button");$.setAttribute("variant","ghost"),$.setAttribute("icon",""),$.setAttribute("aria-label","Close dialog"),$.setAttribute("close-dialog",""),$.appendChild(c("close")),Z.appendChild($),q.appendChild(Q),q.appendChild(Z),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 Q=q.getAttribute("id")||h();q.setAttribute("id",Q),this.setAttribute("aria-labelledby",Q)}}}_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 Q=q.includes("top"),Z=q.includes("bottom"),$=q.includes("left"),J=q.includes("right"),j=q.includes("center")&&!Q&&!Z,_=q.includes("center")&&!$&&!J;if(Q)this.style.top=`${this._offset}px`;else if(Z)this.style.bottom=`${this._offset}px`;else if(j)this.style.top="0",this.style.bottom="0";if($)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(j&&_)this.style.margin="auto";else if(j)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"),Q=q?this.querySelector(q):this.querySelector("fig-header, header");if(Q)Q.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 Q=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],Z=["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.some((_)=>j.matches?.(_))||j.tagName?.startsWith("FIG-")&&!Z.includes(j.tagName);if($(q))return!0;let J=q.parentElement;while(J&&J!==this){if($(J))return!0;J=J.parentElement}return!1}_handlePointerDown(q){if(!this.drag)return;if(this._isInteractiveElement(q.target))return;let Q=this.getAttribute("handle");if(Q&&Q.trim()){let $=this.querySelector(Q);if(!$||!$.contains(q.target))return}this._dragPending=!0,this._dragStartPos.x=q.clientX,this._dragStartPos.y=q.clientY;let Z=this.getBoundingClientRect();this._dragOffset.x=q.clientX-Z.left,this._dragOffset.y=q.clientY-Z.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}_handlePointerMove(q){if(this._dragPending&&!this._isDragging){let Q=Math.abs(q.clientX-this._dragStartPos.x),Z=Math.abs(q.clientY-this._dragStartPos.y);if(Q>this._dragThreshold||Z>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(q.pointerId),this.style.cursor="grabbing";let $=this.getBoundingClientRect();this.style.top=`${$.top}px`,this.style.left=`${$.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,Q,Z){if(this._figInit(),q==="autoresize"&&this.isConnected)this._syncAutoResize();if(q==="drag")if(this.drag=Z!==null&&Z!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let $=this.querySelector("fig-header, header");if($)$.style.cursor=""}if(q==="position"&&this._positionInitialized)this._applyPosition();if(q==="modal"){let $=this.modal;if(this.modal=Z!==null&&Z!=="false",this.open&&$!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(q==="closedby")this.closedby=Z||"any";if(q==="title"){let $=this.querySelector("fig-header[data-auto] h3");if($)$.textContent=Z||"Dialog";this._syncA11y()}if(q==="aria-label"||q==="aria-labelledby")this._syncA11y()}}O0("fig-dialog",b0,{extends:"dialog"});class h0 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")),Q=Number.isFinite(q)?q:this._defaultOffset;this.style.bottom=`${Q}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",Q=q?"alert":"status",Z=q?"assertive":"polite";if(!this.hasAttribute("role")||this.getAttribute("role")===this._managedRole)this.setAttribute("role",Q),this._managedRole=Q;if(!this.hasAttribute("aria-live")||this.getAttribute("aria-live")===this._managedLive)this.setAttribute("aria-live",Z),this._managedLive=Z;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,Q,Z){if(this._figInit(),Q===Z)return;if(!this.isConnected)return;if(this._syncingOpen)return;if(q==="offset")this.applyPosition();if(q==="open")if(Z!==null&&Z!=="false")this.showToast();else this.hideToast();if(q==="duration"&&this._toastVisible)this.startAutoClose();if(q==="theme")if(Z==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme");if(q==="theme"||q==="live")this.syncLiveRegion()}}O0("fig-toast",h0,{extends:"dialog"});class v0 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 Q=q.target;if(this.open&&(!(Q instanceof Node)||!this.contains(Q))&&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 Q=q.target;if(this.open&&(!(Q instanceof Node)||!this.contains(Q))&&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,Q,Z){if(this.ensureInitialized(),Q===Z)return;if(q==="open"){if(Z==="false"){this.open=!1;return}if(Z===null){this.hidePopup();return}this.showPopup();return}if(q==="drag"){if(this.drag=Z!==null&&Z!=="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(E0()+1),this.captureFocusBeforeOpen();let q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),Q=this.shouldAutoReposition();if(Q)this.style.visibility="hidden";if(q)try{this.showPopover()}catch($){q=!1}if(!q&&!super.open)try{this.show()}catch($){}if(Q&&(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 Z=this.resolveAnchor();if(Z?.classList)Z.classList.add("has-popup-open");if(this.getAttribute("variant")!=="tooltip")A.dismissHoverTooltips()}hidePopup(){let q=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),Q=this.resolveAnchor();if(Q?.classList)Q.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(Z){}if(this.matches?.(":open"))try{this.close()}catch(Z){}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(),Q=this._previousFocus?.isConnected?this._previousFocus:q instanceof HTMLElement?q:null;if(this._previousFocus=null,!Q?.isConnected)return;let Z=document.activeElement;if(Z&&Z!==document.body&&!this.contains(Z))return;requestAnimationFrame(()=>Q.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 Q=q.getBoundingClientRect();return{x:Q.x,y:Q.y,width:Q.width,height:Q.height}}hasRectChanged(q,Q,Z=0.25){if(!q&&!Q)return!1;if(!q||!Q)return!0;return Math.abs(q.x-Q.x)>Z||Math.abs(q.y-Q.y)>Z||Math.abs(q.width-Q.width)>Z||Math.abs(q.height-Q.height)>Z}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let Q=this.resolveAnchor(),Z=this.readRectSnapshot(Q),$=this.shouldAutoReposition();if($&&this.hasRectChanged(this._lastAnchorRect,Z))this._lastAnchorRect=Z,this.queueReposition();else if(!$)this._lastAnchorRect=Z;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 Q=this.getAttribute("closedby");if(Q==="none"||Q==="closerequest")return;let Z=q.target;if(!(Z instanceof Node))return;let $=typeof q.composedPath==="function"?q.composedPath():[];if($.includes(this))return;if(this.contains(Z))return;let J=this.resolveAnchor();if(J&&($.includes(J)||J.contains?.(Z)))return;if(this.isInsideDescendantPopup(Z))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 $=Array.from(document.querySelectorAll('dialog[is="fig-popup"][open]')).filter((J)=>J.open).map((J)=>({popup:J,z:Number.parseInt(getComputedStyle(J).zIndex||"0",10)||0})).sort((J,j)=>J.z-j.z).at(-1)?.popup;if($&&$!==this)return;q.preventDefault(),this.open=!1}isInsideDescendantPopup(q){let Q=q.closest?.('dialog[is="fig-popup"]');if(!Q||Q===this)return!1;let Z=Q,$=new Set;while(Z&&!$.has(Z)){$.add(Z);let J=Z.anchor;if(!(J instanceof Element))break;if(this.contains(J))return!0;Z=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 Q=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],Z=["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.some((_)=>j.matches?.(_))||j.tagName?.startsWith("FIG-")&&!Z.includes(j.tagName);if($(q))return!0;let J=q.parentElement;while(J&&J!==this){if($(J))return!0;J=J.parentElement}return!1}handlePointerDown(q){if(!this.drag)return;if(this.isInteractiveElement(q.target))return;let Q=this.getAttribute("handle");if(Q&&Q.trim()){let $=this.querySelector(Q);if(!$||!$.contains(q.target))return}this._dragPending=!0,this._dragStartPos.x=q.clientX,this._dragStartPos.y=q.clientY;let Z=this.getBoundingClientRect();this._dragOffset.x=q.clientX-Z.left,this._dragOffset.y=q.clientY-Z.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}handlePointerMove(q){if(this._dragPending&&!this._isDragging){let Q=Math.abs(q.clientX-this._dragStartPos.x),Z=Math.abs(q.clientY-this._dragStartPos.y);if(Q>this._dragThreshold||Z>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(q.pointerId),this.style.cursor="grabbing";let $=this.getBoundingClientRect();this.style.top=`${$.top}px`,this.style.left=`${$.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 Q=this.parentElement;try{if(Q?.querySelector){let Z=Q.querySelector(q);if(Z&&!this.contains(Z))return Z}return document.querySelector(q)}catch{return null}}parsePosition(){let Q=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),Z=new Set(["top","center","bottom"]),$=new Set(["left","center","right"]),J="top",j="center",_=null;if(Q.length>=2){if(Z.has(Q[0]))J=Q[0];if($.has(Q[1]))j=Q[1];return{vertical:J,horizontal:j,shorthand:_}}if(Q.length===1){let W=Q[0];if(W==="top"||W==="bottom")J=W,_=W;else if(W==="left"||W==="right")j=W,_=W;else if(W==="center")J="center",j="center"}return{vertical:J,horizontal:j,shorthand:_}}normalizeOffsetToken(q,Q="0px"){if(!q)return Q;let Z=q.trim();if(!Z)return Q;if(/^-?\d+(\.\d+)?$/.test(Z))return`${Z}px`;return Z}measureLengthPx(q,Q="x"){if(!q)return 0;let Z=this.normalizeOffsetToken(q,"0px");if(Z.endsWith("px")){let j=parseFloat(Z);return Number.isFinite(j)?j:0}let $=document.createElement("div");if($.style.position="fixed",$.style.visibility="hidden",$.style.pointerEvents="none",$.style.left="0",$.style.top="0",$.style.margin="0",$.style.padding="0",$.style.border="0",Q==="x")$.style.width=Z,$.style.height="0";else $.style.height=Z,$.style.width="0";document.body.appendChild($);let J=$.getBoundingClientRect();return $.remove(),Q==="x"?J.width:J.height}parseOffset(){let Q=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),Z=this.normalizeOffsetToken(Q[0],"0px"),$=this.normalizeOffsetToken(Q[1],"0px");return{xToken:Z,yToken:$,xPx:this.measureLengthPx(Z,"x"),yPx:this.measureLengthPx($,"y")}}parseViewportMargins(){let Q=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter(($)=>!Number.isNaN($)),Z=8;if(Q.length===0)return{top:8,right:8,bottom:8,left:8};if(Q.length===1)return{top:Q[0],right:Q[0],bottom:Q[0],left:Q[0]};if(Q.length===2)return{top:Q[0],right:Q[1],bottom:Q[0],left:Q[1]};if(Q.length===3)return{top:Q[0],right:Q[1],bottom:Q[2],left:Q[1]};return{top:Q[0],right:Q[1],bottom:Q[2],left:Q[3]}}getPlacementCandidates(q,Q,Z){let $={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if(Z){let j=Z==="left"||Z==="right"?["top","bottom"]:["left","right"];return[{v:q,h:Q,s:Z},{v:q,h:Q,s:$[Z]},{v:q,h:Q,s:j[0]},{v:q,h:Q,s:j[1]}]}if(q==="center")return[{v:"center",h:Q,s:null},{v:"center",h:$[Q],s:null},{v:"top",h:Q,s:null},{v:"bottom",h:Q,s:null},{v:"top",h:$[Q],s:null},{v:"bottom",h:$[Q],s:null}];if(Q==="center")return[{v:q,h:"center",s:null},{v:$[q],h:"center",s:null},{v:q,h:"left",s:null},{v:q,h:"right",s:null},{v:$[q],h:"left",s:null},{v:$[q],h:"right",s:null}];return[{v:q,h:Q,s:null},{v:$[q],h:Q,s:null},{v:q,h:$[Q],s:null},{v:$[q],h:$[Q],s:null}]}computeCoords(q,Q,Z,$,J,j){let _,W;if(j==="left"||j==="right")return W=j==="left"?q.left-Q.width-J.xPx:q.right+J.xPx,_=q.top,{top:_,left:W};if(j==="top"||j==="bottom")return _=j==="top"?q.top-Q.height-J.yPx:q.bottom+J.yPx,W=q.left,{top:_,left:W};if(Z==="top")_=q.top-Q.height-J.yPx;else if(Z==="bottom")_=q.bottom+J.yPx;else _=q.top+(q.height-Q.height)/2;if(Z==="center")if($==="left")W=q.left-Q.width-J.xPx;else if($==="right")W=q.right+J.xPx;else W=q.left+(q.width-Q.width)/2;else if($==="left")W=q.left+J.xPx;else if($==="right")W=q.right-Q.width-J.xPx;else W=q.left+(q.width-Q.width)/2;return{top:_,left:W}}oppositeSide(q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[q]||"bottom"}getPlacementSide(q,Q,Z){if(Z==="top")return"top";if(Z==="bottom")return"bottom";if(Z==="left")return"left";if(Z==="right")return"right";if(q!=="center")return q;if(Q!=="center")return Q;return"top"}lengthToPx(q,Q=0){let Z=getComputedStyle(this),$=String(q||"").trim(),J=parseFloat($);if(!Number.isFinite(J))return Q;if($.endsWith("rem"))return J*parseFloat(getComputedStyle(document.documentElement).fontSize);if($.endsWith("em"))return J*parseFloat(Z.fontSize);return J}radiusForSide(q){let Q=getComputedStyle(this),Z=($)=>this.lengthToPx($,0);if(q==="top")return Math.max(Z(Q.borderTopLeftRadius),Z(Q.borderTopRightRadius));if(q==="bottom")return Math.max(Z(Q.borderBottomLeftRadius),Z(Q.borderBottomRightRadius));if(q==="left")return Math.max(Z(Q.borderTopLeftRadius),Z(Q.borderBottomLeftRadius));if(q==="right")return Math.max(Z(Q.borderTopRightRadius),Z(Q.borderBottomRightRadius));return 0}getBeakEdgeInset(q){let Q=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(q)+Q/2)}tracksAnchorBeak(){let q=this.getAttribute("variant");return q==="popover"||q==="tooltip"}getViewportBounds(q){let Q=window.visualViewport,Z=Q?.width??window.innerWidth,$=Q?.height??window.innerHeight,J=Q?.offsetLeft??0,j=Q?.offsetTop??0;return{minLeft:J+q.left,minTop:j+q.top,maxRight:J+Z-q.right,maxBottom:j+$-q.bottom}}clampToViewport(q,Q,Z){let $=this.getViewportBounds(Z),J=$.maxRight-Q.width,j=$.maxBottom-Q.height;return{left:Math.min(J,Math.max($.minLeft,q.left)),top:Math.min(j,Math.max($.minTop,q.top))}}resolveCoordsAtViewport(q,Q,Z,$,J){let{left:j,top:_}=this.clampToViewport(Z,Q,J);if(!q||!this.tracksAnchorBeak())return{left:j,top:_};let W=this.oppositeSide($),N=this.getViewportBounds(J),K=N.maxRight-Q.width,G=N.minLeft,U=N.maxBottom-Q.height,X=N.minTop;if(W==="top"||W==="bottom"){let O=this.getBeakEdgeInset(W),R=q.left+q.width/2,L=R-j;if(L<O)j=R-O;else if(L>Q.width-O)j=R-(Q.width-O);j=Math.min(K,Math.max(G,j))}else if(W==="left"||W==="right"){let O=this.getBeakEdgeInset(W),R=q.top+q.height/2,L=R-_;if(L<O)_=R-O;else if(L>Q.height-O)_=R-(Q.height-O);_=Math.min(U,Math.max(X,_))}return{left:j,top:_}}canPointAtAnchor(q,Q,Z,$,J){if(!q||!this.tracksAnchorBeak())return!0;let j=this.oppositeSide(J),_=this.getBeakEdgeInset(j);if(j==="top"||j==="bottom"){let N=q.left+q.width/2-Z;return N>=_-0.5&&N<=Q.width-_+0.5}let W=q.top+q.height/2-$;return W>=_-0.5&&W<=Q.height-_+0.5}updatePopoverBeak(q,Q,Z,$,J){if(!this.tracksAnchorBeak()||!q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let j=this.oppositeSide(J);this.setAttribute("data-beak-side",j);let _=q.left+q.width/2,W=q.top+q.height/2,N=this.getBoundingClientRect(),K=N.width>0&&N.height>0?N:Q,G=K.left,U=K.top,X=this.getBeakEdgeInset(j),O;if(j==="top"||j==="bottom"){O=_-G;let R=X,L=Math.max(R,K.width-X);O=Math.min(L,Math.max(R,O))}else{O=W-U;let R=X,L=Math.max(R,K.height-X);O=Math.min(L,Math.max(R,O))}this.style.setProperty("--fig-popup-beak-offset",`${O}px`)}overflowScore(q,Q,Z){let $=this.getViewportBounds(Z),J=q.left+Q.width,j=q.top+Q.height,_=Math.max(0,$.minLeft-q.left),W=Math.max(0,$.minTop-q.top),N=Math.max(0,J-$.maxRight),K=Math.max(0,j-$.maxBottom);return _+W+N+K}fits(q,Q,Z){return this.overflowScore(q,Q,Z)===0}clamp(q,Q,Z,$=null,J="top"){if($)return this.resolveCoordsAtViewport($,Q,q,J,Z);return this.clampToViewport(q,Q,Z)}primaryAxisOverflowPenalty(q,Q,Z,$){let J=this.getViewportBounds(Z),j=0;if($==="top")j=Math.max(0,J.minTop-q.top);else if($==="bottom")j=Math.max(0,q.top+Q.height-J.maxBottom);else if($==="left")j=Math.max(0,J.minLeft-q.left);else if($==="right")j=Math.max(0,q.left+Q.width-J.maxRight);return j>0?1000+j:0}placementScore(q,Q,Z,$,J){let j=this.resolveCoordsAtViewport(q,Q,Z,$,J),_=this.overflowScore(j,Q,J);if(_+=this.primaryAxisOverflowPenalty(Z,Q,J,$),q&&!this.canPointAtAnchor(q,Q,j.left,j.top,$))_+=1e4;return{score:_,resolved:j}}applyPopupPosition(q,Q,Z,$,J){let j=this.resolveCoordsAtViewport(q,Q,Z,$,J);this.style.left=`${j.left}px`,this.style.top=`${j.top}px`,this.updatePopoverBeak(q,Q,j.left,j.top,$)}positionPopup(){if(!this.open)return;let q=this.getBoundingClientRect(),Q=this.parseOffset(),{vertical:Z,horizontal:$,shorthand:J}=this.parsePosition(),j=this.resolveAnchor(),_=this.parseViewportMargins();if(!j){this.updatePopoverBeak(null,q,0,0,"top");let X=this.getViewportBounds(_),O={left:X.minLeft+(X.maxRight-X.minLeft-q.width)/2,top:X.minTop+(X.maxBottom-X.minTop-q.height)/2},R=this.clampToViewport(O,q,_);this.style.left=`${R.left}px`,this.style.top=`${R.top}px`;return}let W=j.getBoundingClientRect(),N=this.getPlacementCandidates(Z,$,J),K=null,G="top",U=Number.POSITIVE_INFINITY;for(let{v:X,h:O,s:R}of N){let L=this.computeCoords(W,q,X,O,Q,R),D=this.getPlacementSide(X,O,R),{score:F,resolved:H}=this.placementScore(W,q,L,D,_);if(R){let B=this.getViewportBounds(_);if((R==="left"||R==="right"?L.left>=B.minLeft&&L.left+q.width<=B.maxRight:L.top>=B.minTop&&L.top+q.height<=B.maxBottom)&&F<1e4){this.applyPopupPosition(W,q,L,D,_);return}}else if(F===0){this.applyPopupPosition(W,q,L,D,_);return}if(F<U)U=F,K=H,G=D}this.applyPopupPosition(W,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"))}}O0("fig-popup",v0,{extends:"dialog"});class m0 extends HTMLElement{#Q;#q;constructor(){super();this.content=null,this.#Q=!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),u(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let q=this.getAttribute("id")||h(),Q=this.content.getAttribute("id")||h();if(this.setAttribute("id",q),this.content.setAttribute("id",Q),this.setAttribute("aria-controls",Q),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.#q)}handleClick(){if(z(this,"disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(q,Q,Z){if(q==="selected"){if(this.#Q=Z!==null&&Z!=="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(Z!==null&&Z!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#Q?"0":"-1")}}M("fig-tab",m0);class g0 extends HTMLElement{#Q;#q;#Z=this.#L.bind(this);#$=null;#J=null;#j=null;#N=null;#_=!1;#W=new WeakSet;constructor(){super();this.#Q=this.handleClick.bind(this),this.#q=this.#H.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.#q),this.addEventListener("scroll",this.#Z),this.#R(),this.#M(),this.#z(),u(this,()=>{let q=this.getAttribute("value");if(q)this.#A(q);if(z(this,"disabled"))this.#Y(!0);this.#K(),this.#L(),this.#X(void 0,"auto")})}#Y(q){this.querySelectorAll("fig-tab").forEach((Z)=>{if(q){if(!(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false"))this.#W.add(Z),Z.setAttribute("disabled","");Z.setAttribute("aria-disabled","true"),Z.setAttribute("tabindex","-1")}else if(this.#W.has(Z))this.#W.delete(Z),Z.removeAttribute("disabled"),Z.removeAttribute("aria-disabled")}),this.#K()}#G(){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")),Q=q.find((Z)=>Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false")||this.#G()[0];q.forEach((Z)=>{let $=Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false";Z.setAttribute("tabindex",!$&&Z===Q?"0":"-1")})}#X(q=this.selectedTab,Q="smooth"){let Z=q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#G()[0];if(!Z)return;requestAnimationFrame(()=>{if(!this.isConnected||!Z.isConnected)return;if(!(this.scrollWidth>this.clientWidth))return;let J=this.getBoundingClientRect(),j=Z.getBoundingClientRect(),_=j.left-J.left+this.scrollLeft+j.width/2;this.scrollTo({left:_-this.clientWidth/2,behavior:Q}),this.#L()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#q),this.removeEventListener("scroll",this.#Z),this.#$?.disconnect(),this.#$=null,this.#J?.disconnect(),this.#J=null,this.#B()}#U(){if(this.#_)return;let q=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!q)return;this.#_=!0;try{let Q=Array.from(q.childNodes);q.replaceWith(...Q)}finally{this.#_=!1}}#L(){a(this,this,"x")}#z(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>this.#L()),this.#J.observe(this)}#M(){this.#$?.disconnect(),this.#$=new MutationObserver(()=>{if(this.#_)return;this.#U(),this.#R(),this.#K(),requestAnimationFrame(()=>{this.#L(),this.#X()})}),this.#$.observe(this,{childList:!0,subtree:!1})}#B(){this.#j?.remove(),this.#N?.remove(),this.#j=null,this.#N=null,this.classList.remove("overflow-start","overflow-end")}#R(){if(this.#j&&this.#N&&this.contains(this.#j)&&this.contains(this.#N))return;this.#j?.remove(),this.#N?.remove();let q=N0({owner:"tabs",onStart:()=>r(this,"x",-1),onEnd:()=>r(this,"x",1)});this.#j=q.start,this.#N=q.end,this.prepend(this.#j),this.append(this.#N)}#H(q){let Q=this.#G();if(!Q.length)return;let Z=Q.findIndex((J)=>z(J,"selected")),$=Z>=0?Z:0;switch(q.key){case"ArrowLeft":case"ArrowUp":q.preventDefault(),$=Z>0?Z-1:Q.length-1;break;case"ArrowRight":case"ArrowDown":q.preventDefault(),$=Z<Q.length-1?Z+1:0;break;case"Home":q.preventDefault(),$=0;break;case"End":q.preventDefault(),$=Q.length-1;break;default:return}if($!==Z&&Q[$]){this.querySelectorAll("fig-tab").forEach((j)=>j.removeAttribute("selected")),this.selectedTab=Q[$],Q[$].setAttribute("selected","true");let J=this.#T(Q[$]);if(J)this.setAttribute("value",J);else this.removeAttribute("value");Q[$].focus(),this.#K(),this.#X(Q[$]),this.#D()}}get value(){return this.#T(this.selectedTab)}set value(q){this.setAttribute("value",q)}#D(){let q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:q,bubbles:!0}))}#T(q){if(!q)return"";let Q=q.getAttribute("value");if(Q!==null)return Q;return q.textContent?.trim()||""}#A(q){let Q=this.querySelectorAll("fig-tab");for(let Z of Q)if(this.#T(Z)===q)this.selectedTab=Z,Z.setAttribute("selected","true");else Z.removeAttribute("selected");this.#K(),this.#X(this.selectedTab)}attributeChangedCallback(q,Q,Z){switch(q){case"value":if(Z!==Q)this.#A(Z);break;case"disabled":this.#Y(Z!==null&&Z!=="false");break}}handleClick(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=q.target.closest("fig-tab");if(!Q||!this.contains(Q))return;if(Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;let Z=this.selectedTab,$=this.value,J=this.querySelectorAll("fig-tab");for(let _ of J)if(_===Q)this.selectedTab=_,_.setAttribute("selected","true");else _.removeAttribute("selected");let j=this.#T(Q);if(j)this.setAttribute("value",j);else this.removeAttribute("value");if(this.#K(),this.#X(Q),Z!==Q||$!==this.value)this.#D()}}M("fig-tabs",g0);class u0 extends HTMLElement{#Q;#q;#Z;constructor(){super();this.#Z=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#$(),this.addEventListener("click",this.#Z)}disconnectedCallback(){this.removeEventListener("click",this.#Z)}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.#q}set selected(q){this.#q=q,this.setAttribute("selected",q)}static get observedAttributes(){return["selected","value","disabled"]}#$(){let q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",q?"true":"false"),Q)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",q?"0":"-1")}attributeChangedCallback(q,Q,Z){switch(q){case"value":this.#Q=Z;break;case"selected":this.#q=Z,this.#$();break;case"disabled":this.#$();break}}}M("fig-segment",u0);class c0 extends HTMLElement{#Q=null;#q=this.handleClick.bind(this);#Z=this.#z.bind(this);#$=null;#J=null;#j=0;#N=!1;#_=!1;#W=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.#Z),this.#P(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#O(),this.#D(),u(this,()=>{this.#A({enforceFallback:!0}),this.#T(),this.#R({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#q),this.removeEventListener("keydown",this.#Z),this.#$?.disconnect(),this.#$=null,this.#J?.disconnect(),this.#J=null,this.#j)cancelAnimationFrame(this.#j),this.#j=0;this.#N=!1,this.#_=!1}get selectedSegment(){return this.#Q}set selectedSegment(q){let Q=this.querySelectorAll("fig-segment");for(let Z of Q){let $=Z===q,J=z(Z,"selected");if($&&!J)Z.setAttribute("selected","true");else if(!$&&J)Z.removeAttribute("selected")}this.#Q=q instanceof HTMLElement&&this.contains(q)?q:null,this.#U(),this.#R()}get value(){return this.getAttribute("value")||""}set value(q){if(q===null||q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(q))}#Y(q){this.dispatchEvent(new CustomEvent("input",{detail:q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:q,bubbles:!0}))}#G(q){let Q=q.getAttribute("value");if(Q!==null){let Z=Q.trim();if(Z.length>0)return Z}return q.textContent?.trim()||""}#K(){let q=this.querySelectorAll("fig-segment");for(let Q of q)if(Q.hasAttribute("selected")&&Q.getAttribute("selected")!=="false")return Q;return null}#X(){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")),Q=q.find((Z)=>Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false");q.forEach((Z)=>{let $=Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false",J=Z===Q;Z.setAttribute("aria-checked",J?"true":"false"),Z.setAttribute("tabindex",!$&&J?"0":"-1")})}#L(q){if(!q)return;let Q=this.selectedSegment,Z=this.value;this.selectedSegment=q;let $=this.#G(q);if($)this.setAttribute("value",$);else this.removeAttribute("value");let J=this.value;if(Q!==q||Z!==J)this.#Y(J)}#z(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.#X();if(!Q.length)return;let Z=Q.findIndex((j)=>z(j,"selected")),$=Z>=0?Z:0;switch(q.key){case"ArrowLeft":case"ArrowUp":q.preventDefault(),$=$>0?$-1:Q.length-1;break;case"ArrowRight":case"ArrowDown":q.preventDefault(),$=$<Q.length-1?$+1:0;break;case"Home":q.preventDefault(),$=0;break;case"End":q.preventDefault(),$=Q.length-1;break;case" ":case"Enter":{let j=q.target.closest("fig-segment");if(j&&this.contains(j))q.preventDefault(),this.#L(j);return}default:return}let J=Q[$];this.#L(J),J.focus(),requestAnimationFrame(()=>{if(this.contains(J))J.focus()})}#M(q){let Q=String(q??"").trim();if(!Q)return!1;let Z=this.querySelectorAll("fig-segment");for(let $ of Z){let J=this.#G($);if(!J)continue;if(J===Q)return this.selectedSegment=$,!0}return!1}#B(){let q=this.getAttribute("animated");if(q===null)return!1;if(q==="")return!0;return q.trim().toLowerCase()==="true"}#R({forceInstant:q=!1}={}){if(this.#N=this.#N||q,this.#j)return;this.#j=requestAnimationFrame(()=>{this.#j=0;let Q=this.#N;this.#N=!1,this.#H({forceInstant:Q})})}#H({forceInstant:q=!1}={}){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.#B(),$=this.#Q&&this.contains(this.#Q)?this.#Q:this.#K();if(Q||!Z){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!Z||Q)this.#_=!1;return}if(!$){if(this.#_)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let J=this.getBoundingClientRect(),j=$.getBoundingClientRect();if(J.width<=0||j.width<=0){if(this.#_)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,j.left-J.left);this.style.setProperty("--seg-indicator-x",`${_}px`),this.style.setProperty("--seg-indicator-w",`${j.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#_||q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#_=!0}#D(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#R()}),this.#T()}#T(){if(!this.#J)return;this.#J.disconnect(),this.#J.observe(this),this.querySelectorAll("fig-segment").forEach((q)=>{this.#J?.observe(q)})}#A({enforceFallback:q=!1}={}){if(this.querySelectorAll("fig-segment").length===0){this.#Q=null,this.#R({forceInstant:!0});return}let Z=this.getAttribute("value"),$=Z?.trim()??"";if(Z!==null){if($!==Z){this.setAttribute("value",$);return}if($&&this.#M($))return}let J=this.#K();if(J){this.selectedSegment=J;return}if(q)this.selectedSegment=this.#X()[0]||null}#O(){this.#$?.disconnect(),this.#$=new MutationObserver((q)=>{let Q=!1;for(let Z of q){if(Z.type==="childList"){Q=!0;break}if(Z.type==="attributes"&&Z.target instanceof HTMLElement&&Z.target.tagName.toLowerCase()==="fig-segment"&&(Z.attributeName==="value"||Z.attributeName==="selected")){Q=!0;break}if(Z.type==="characterData"){Q=!0;break}}if(Q)this.#P(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#T(),this.#A({enforceFallback:!0}),this.#U()}),this.#$.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=q.target.closest("fig-segment");if(!Q||!this.contains(Q))return;if(Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.#L(Q)}#P(q){this.setAttribute("aria-disabled",q?"true":"false"),this.querySelectorAll("fig-segment").forEach((Q)=>{if(q){if(!(Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false"))this.#W.add(Q),Q.setAttribute("disabled","");Q.setAttribute("aria-disabled","true")}else if(this.#W.has(Q))this.#W.delete(Q),Q.removeAttribute("disabled"),Q.removeAttribute("aria-disabled")}),this.#U()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="disabled"){this.#P(Z!==null&&Z!=="false"),this.#R({forceInstant:!0});return}if(q==="value"){this.#A({enforceFallback:!1});return}if(q==="animated"){if(!this.#B())this.#_=!1;this.#R({forceInstant:!0});return}if(q==="sizing")this.#R({forceInstant:!0})}}M("fig-segmented-control",c0);class p0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Q="segments";#q=0;#Z=null;#$=[];#J=null;#j=!1;#N(q){let Q=q?.detail;if(typeof Q==="string")return Q;let Z=q?.currentTarget?.value??q?.target?.value??this.getAttribute("value");if(Z===null||Z===void 0)return null;return String(Z)}#_(){if(this.#$.length===0)return!1;let q=this.querySelector(":scope > fig-segmented-control");if(q){let Z=q.querySelectorAll("fig-segment");if(Z.length!==this.#$.length)return!1;return Array.from(Z).every(($,J)=>$.getAttribute("value")===this.#$[J])}let Q=this.querySelector(":scope > fig-dropdown");if(Q){let Z=Q.querySelectorAll("option");return Z.length===this.#$.length&&Array.from(Z).every(($,J)=>$.textContent?.trim()===this.#$[J])}return!1}#W(){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.#Y(),this.#_()){this.#W(),this.#z(),u(this,()=>u(this,()=>this.#R()));return}this.#G(),this.#z(),u(this,()=>u(this,()=>this.#R()))}disconnectedCallback(){this.#Z?.disconnect(),this.#Z=null}get value(){return this.getAttribute("value")||""}set value(q){if(q===null||q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(q))}get options(){return this.#$.slice()}set options(q){if(Array.isArray(q)){let Z=q.some(($)=>String($).includes(","))?JSON.stringify(q):q.join(",");this.setAttribute("options",Z)}else this.setAttribute("options",String(q||""))}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="options"){this.#Y(),this.#X();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.#X()}#Y(){let q=this.getAttribute("options")||"";if(q.startsWith("["))try{this.#$=JSON.parse(q);return}catch{}let Q=q.includes(`
38
38
  `)?`
39
- `:",";this.#J=Q.split(Z).map(($)=>$.trim()).filter(Boolean)}#G(){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.#Y($);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.#Y($);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.#Y($);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.#Y($);if(!J)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Q="dropdown"}#N(){if(this.#Q==="segments")this.#G(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#M())});else this.#K()}#W(){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.#G(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#B())this.#K()})})}}z("fig-options",p0);function u1(Q){let Z=Q||"";if(Z.startsWith("["))try{let J=JSON.parse(Z);return Array.isArray(J)?J:[]}catch{}let $=Z.includes(`
39
+ `:",";this.#$=q.split(Q).map((Z)=>Z.trim()).filter(Boolean)}#G(){if(this.innerHTML="",this.#$.length===0)return;let q=document.createElement("fig-segmented-control");if(q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),z(this,"disabled"))q.setAttribute("disabled","");if(z(this,"full"))q.setAttribute("full","");let Q=this.getAttribute("value");for(let Z of this.#$){let $=document.createElement("fig-segment");if($.setAttribute("value",Z),$.textContent=Z,Q===Z)$.setAttribute("selected","true");q.appendChild($)}if(Q)q.setAttribute("value",Q);q.addEventListener("input",(Z)=>{if(Z.stopPropagation(),this.#j)return;let $=this.#N(Z);if($===null)return;this.#j=!0,this.setAttribute("value",$),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}),q.addEventListener("change",(Z)=>{if(Z.stopPropagation(),this.#j)return;let $=this.#N(Z);if($===null)return;this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,composed:!0}))}),this.appendChild(q),this.#J=q,this.#Q="segments"}#K(){if(this.innerHTML="",this.#$.length===0)return;let q=document.createElement("fig-dropdown");if(z(this,"disabled"))q.setAttribute("disabled","");let Q=this.getAttribute("value");for(let Z of this.#$){let $=document.createElement("option");if($.value=Z,$.textContent=Z,Q===Z)$.selected=!0;q.appendChild($)}if(Q)q.setAttribute("value",Q);q.addEventListener("input",(Z)=>{if(Z.stopPropagation(),this.#j)return;let $=this.#N(Z);if(!$)return;this.#j=!0,this.setAttribute("value",$),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}),q.addEventListener("change",(Z)=>{if(Z.stopPropagation(),this.#j)return;let $=this.#N(Z);if(!$)return;this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,composed:!0}))}),this.appendChild(q),this.#J=q,this.#Q="dropdown"}#X(){if(this.#Q==="segments")this.#G(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#R())});else this.#K()}#U(){if(!this.#J||this.#j)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)}#z(){this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#R()}),this.#Z.observe(this)}#M(q){let Q=document.createRange();Q.selectNodeContents(q);let Z=Q.getBoundingClientRect().width,J=q.getBoundingClientRect().width,j=getComputedStyle(q),_=parseFloat(j.paddingLeft)||0,W=parseFloat(j.paddingRight)||0,N=J-_-W;return Z>N+0.5}#B(){let q=this.querySelectorAll("fig-segment");for(let Q of q)if(this.#M(Q))return!0;return!1}#R(){if(this.#$.length<=1)return;if(this.#Q==="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.#G(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let q=this.#J;if(q&&q.scrollWidth>q.clientWidth+1||this.#B())this.#K()})})}}M("fig-options",p0);function dq(q){let Q=q||"";if(Q.startsWith("["))try{let $=JSON.parse(Q);return Array.isArray($)?$:[]}catch{}let Z=Q.includes(`
40
40
  `)?`
41
- `:",";return Z.split($).map((J)=>J.trim()).filter(Boolean)}function p1(Q){if(Q&&typeof Q==="object")return String(Q.value??Q.label??"");return String(Q??"")}function d1(Q){if(Q&&typeof Q==="object")return String(Q.label??Q.value??"");return String(Q??"")}class d0 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",d0);class s0 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.#Y()}syncOverflow(){return t(this,this,"y")}scrollToOption(Q,Z="auto"){I0(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.#Y();let Q=Y0({owner:"select",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>r(this,"y",-1),onEnd:()=>r(this,"y",1)});this.#Q=Q.start,this.#Z=Q.end,this.prepend(this.#Q),this.append(this.#Z)}#Y(){this.#Q?.remove(),this.#Z?.remove(),this.#Q=null,this.#Z=null,this.classList.remove("overflow-start","overflow-end")}}z("fig-select-options",s0);class i0 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#Y=!1;#_=-1;#X=!1;#U=!1;#G=null;#K=!1;#N=null;#W=null;#L=!1;#F=this.#j0.bind(this);#z=this.#q0.bind(this);#B=this.#Q0.bind(this);#M=this.#l.bind(this);#A=this.#_0.bind(this);#P=this.#g.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.#Y)this.#f();if(this.#H(),this.#I(),this.#u(),this.#p(),this.#r(),this.#d(),this.open)this.#K0()}disconnectedCallback(){this.#c(),document.removeEventListener("keydown",this.#M,!0),this.#q?.disconnect(),this.#q=null}attributeChangedCallback(Q,Z,$){if(Z===$||!this.#Y)return;if(Q==="options"){this.#I(),this.#r();return}if(Q==="value"||Q==="label"){this.#r();return}if(Q==="disabled"){this.#u();return}if(Q==="open"){if($===null||$==="false")this.#X0();else this.#K0();return}if(Q==="position"||Q==="offset"||Q==="closedby")this.#p()}focus(Q){this.#Q?.focus(Q)}blur(){this.#Q?.blur()}#D(Q){return Q?.nodeType===1&&(Q.tagName==="FIG-SELECT-OPTION"||Q.tagName==="FIG-SEPARATOR"||Q.tagName==="FIG-SELECT-OPTIONS")}#H(){for(let Q of this.querySelectorAll(":scope > fig-select-options"))if(!Q.hasAttribute("slot"))Q.setAttribute("slot","panel")}#O(){let Z=(this.#j?.assignedElements({flatten:!0})??[]).find(($)=>$.tagName==="FIG-SELECT-OPTIONS");if(Z)return Z;return this.querySelector(":scope > fig-select-options")}#T(){return Boolean(this.querySelector(":scope > fig-select-option:not([data-fig-generated]), :scope > fig-select-options > fig-select-option:not([data-fig-generated])"))}#S(){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}#I(){if(this.#T())return;let Q=this.hasAttribute("options"),Z=Q?this.#S():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 $=u1(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",p1(j)),q.textContent=d1(j),J)Z.insertBefore(q,J);else Z.appendChild(q)}}finally{this.#L=!1}}#f(){this.#Y=!0;let Q=this.attachShadow({mode:"open"});Q.innerHTML=`
41
+ `:",";return Q.split(Z).map(($)=>$.trim()).filter(Boolean)}function sq(q){if(q&&typeof q==="object")return String(q.value??q.label??"");return String(q??"")}function oq(q){if(q&&typeof q==="object")return String(q.label??q.value??"");return String(q??"")}class d0 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 z(this,"disabled")}set disabled(q){if(q)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get selected(){return z(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,Q,Z){if(Q===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")}}M("fig-select-option",d0);class s0 extends HTMLElement{#Q=null;#q=null;#Z=null;#$=this.syncOverflow.bind(this);connectedCallback(){if(!this.hasAttribute("slot"))this.setAttribute("slot","panel");this.#J(),this.#j(),this.addEventListener("scroll",this.#$,{passive:!0}),this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>this.syncOverflow()),this.#Z.observe(this),requestAnimationFrame(()=>this.syncOverflow())}disconnectedCallback(){this.removeEventListener("scroll",this.#$),this.#Z?.disconnect(),this.#Z=null,this.#N()}syncOverflow(){return a(this,this,"y")}scrollToOption(q,Q="auto"){C0(this,q,"y",Q)}#J(){let q=this.querySelector(":scope > fig-chooser");if(!q)return;while(q.firstChild)this.insertBefore(q.firstChild,q);q.remove()}#j(){if(this.#Q&&this.#q&&this.contains(this.#Q)&&this.contains(this.#q))return;this.#N();let q=N0({owner:"select",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>r(this,"y",-1),onEnd:()=>r(this,"y",1)});this.#Q=q.start,this.#q=q.end,this.prepend(this.#Q),this.append(this.#q)}#N(){this.#Q?.remove(),this.#q?.remove(),this.#Q=null,this.#q=null,this.classList.remove("overflow-start","overflow-end")}}M("fig-select-options",s0);class o0 extends HTMLElement{#Q=null;#q=null;#Z=null;#$=null;#J=null;#j=null;#N=!1;#_=-1;#W=!1;#Y=!1;#G=null;#K=!1;#X=null;#U=null;#L=!1;#z=this.#$0.bind(this);#M=this.#J0.bind(this);#B=this.#q0.bind(this);#R=this.#t.bind(this);#H=this.#_0.bind(this);#D=this.#g.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 z(this,"open")}set open(q){if(q)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(!this.#N)this.#V();if(this.#A(),this.#C(),this.#c(),this.#p(),this.#i(),this.#o(),this.open)this.#K0()}disconnectedCallback(){this.#v(),document.removeEventListener("keydown",this.#R,!0),this.#j?.disconnect(),this.#j=null}attributeChangedCallback(q,Q,Z){if(Q===Z||!this.#N)return;if(q==="options"){this.#C(),this.#i();return}if(q==="value"||q==="label"){this.#i();return}if(q==="disabled"){this.#c();return}if(q==="open"){if(Z===null||Z==="false")this.#W0();else this.#K0();return}if(q==="position"||q==="offset"||q==="closedby")this.#p()}focus(q){this.#Q?.focus(q)}blur(){this.#Q?.blur()}#T(q){return q?.nodeType===1&&(q.tagName==="FIG-SELECT-OPTION"||q.tagName==="FIG-SEPARATOR"||q.tagName==="FIG-SELECT-OPTIONS")}#A(){for(let q of this.querySelectorAll(":scope > fig-select-options"))if(!q.hasAttribute("slot"))q.setAttribute("slot","panel")}#O(){let Q=(this.#J?.assignedElements({flatten:!0})??[]).find((Z)=>Z.tagName==="FIG-SELECT-OPTIONS");if(Q)return Q;return this.querySelector(":scope > fig-select-options")}#P(){return Boolean(this.querySelector(":scope > fig-select-option:not([data-fig-generated]), :scope > fig-select-options > fig-select-option:not([data-fig-generated])"))}#k(){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.#P())return;let q=this.hasAttribute("options"),Q=q?this.#k():this.#O();if(!Q)return;this.#L=!0;try{for(let J of Q.querySelectorAll(":scope > fig-select-option[data-fig-generated]"))J.remove();if(!q)return;let Z=dq(this.getAttribute("options")),$=Q.querySelector(":scope > .fig-overflow-end");for(let J of Z){let j=document.createElement("fig-select-option");if(j.setAttribute("data-fig-generated",""),j.setAttribute("value",sq(J)),j.textContent=oq(J),$)Q.insertBefore(j,$);else Q.appendChild(j)}}finally{this.#L=!1}}#V(){this.#N=!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 w1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var v1={};var P0=w1(()=>{/*! 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=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.#x(),this.#R(),!this.hasAttribute("value")){let _=this.#s().find((X)=>F(X,"selected"));if(_)this.setAttribute("value",_.value)}}#R(){if(!this.#Z||this.#U)return;if(typeof this.#Z.positionPopup!=="function")return;this.#G=this.#Z.positionPopup.bind(this.#Z),this.#Z.positionPopup=()=>{if(!this.open){this.#G?.();return}this.#m()},this.#U=!0}#C(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}}#k(){let Q=this.#J?.getBoundingClientRect();if(!Q)return null;return{x:Q.x,y:Q.y,width:Q.width,height:Q.height}}#y(){let Q=window.visualViewport;return{width:Q?.width??window.innerWidth,height:Q?.height??window.innerHeight,offsetLeft:Q?.offsetLeft??0,offsetTop:Q?.offsetTop??0}}#w(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)>$}#b(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)>$}#v(){if(!this.#K)return!1;let Q=this.#w(this.#N,this.#k()),Z=this.#b(this.#W,this.#y());return!Q&&!Z}#V(){this.#N=this.#k(),this.#W=this.#y()}#m(){if(this.#v())return;let Q=this.#Z,Z=this.#J;if(!Q||!Z){this.#G?.();return}let $=this.#s(),J=$.find((L)=>this.#h(L)===this.value)||$[0];if(!J){this.#G?.();return}this.#G?.();let j=Q.getBoundingClientRect(),q=Z.getBoundingClientRect(),_=this.#C(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.#C(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.#V()}#x(){this.#Q?.addEventListener("click",this.#F),this.#Q?.addEventListener("keydown",this.#M),this.addEventListener("click",this.#z),this.addEventListener("pointerover",this.#B),this.#Z?.addEventListener("keydown",this.#M),this.#Z?.addEventListener("close",this.#A),this.#j?.addEventListener("slotchange",this.#P)}#c(){this.#Q?.removeEventListener("click",this.#F),this.#Q?.removeEventListener("keydown",this.#M),this.removeEventListener("click",this.#z),this.removeEventListener("pointerover",this.#B),this.#Z?.removeEventListener("keydown",this.#M),this.#Z?.removeEventListener("close",this.#A),this.#j?.removeEventListener("slotchange",this.#P)}#g(){this.#H(),this.#r()}#d(){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.#D(J))||[...$.removedNodes].some((J)=>this.#D(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.#r()}),this.#q.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","disabled","selected","label"]})}#s({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"))}#h(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()}#t(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()}#i(Q){if(!this.#$)return;let Z=Q?.querySelector?.(':scope > [slot="prepend"]');this.#$.replaceChildren(...Array.from(Z?.childNodes??[],($)=>$.cloneNode(!0)))}#p(){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")}#u(){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}#o(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}#n(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0,composed:!0}))}#r(){if(this.#X)return;this.#X=!0;try{let Q=this.#s(),Z=this.hasAttribute("value"),$=Z?this.getAttribute("value"):null,J=Z?Q.find((X)=>this.#h(X)===$):null,j=!1;if(!J){if(Z){if(!Q.length){if(this.#J)this.#J.textContent=$||this.getAttribute("label")||"";return}if(J=this.#o(Q),J){let X=this.#h(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.#h(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.#t(J)||this.getAttribute("label")||"";if(this.#J)this.#J.textContent=q;this.#i(J);let _=this.getAttribute("label")||"Select";if(this.#Q?.setAttribute("aria-label",_),this.#O()?.syncOverflow?.(),j)this.#n(this.getAttribute("value")??"")}finally{this.#X=!1}}#j0(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}#q0(Q){let $=(typeof Q.composedPath==="function"?Q.composedPath():[]).find((J)=>J?.tagName==="FIG-SELECT-OPTION");if(!$||!this.contains($))return;if(F($,"disabled"))return;this.#J0($)}#Q0(Q){let $=(typeof Q.composedPath==="function"?Q.composedPath():[]).find((J)=>J?.tagName==="FIG-SELECT-OPTION");if(!$||!this.contains($))return;if(F($,"disabled"))return;if(Q.relatedTarget instanceof Node&&$.contains(Q.relatedTarget))return;this.dispatchEvent(new CustomEvent("optionhover",{detail:this.#h($),bubbles:!0,composed:!0}))}#l(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.#s({enabledOnly:!0}).findIndex((q)=>this.#h(q)===this.value);this.#Z0(j>=0?j:0)})}return}let $=this.#s({enabledOnly:!0});if(!$.length)return;switch(Q.key){case"ArrowDown":Q.preventDefault(),this.#a(),this.#Z0(this.#_+1);break;case"ArrowUp":Q.preventDefault(),this.#a(),this.#Z0(this.#_-1);break;case"Home":Q.preventDefault(),this.#Z0(0);break;case"End":Q.preventDefault(),this.#Z0($.length-1);break;case"Escape":Q.preventDefault(),this.open=!1,this.#Q?.focus();break;case"Enter":case" ":{this.#a();let J=$[this.#_];if(!J)return;Q.preventDefault(),this.#J0(J);break}}}#_0(){if(this.hasAttribute("open"))this.removeAttribute("open");this.#Q?.setAttribute("aria-expanded","false"),this.#Q?.focus(),this.#_=-1}#J0(Q){let Z=this.#h(Q);this.setAttribute("value",Z),this.#r(),this.#n(Z),this.open=!1}#e(){return this.#s({enabledOnly:!0})}#a(){let Q=this.#e();if(!Q.length){this.#_=-1;return}let Z=Q.find((J)=>J===document.activeElement),$=Z?Q.indexOf(Z):-1;this.#_=$>=0?$:this.#_}#Z0(Q){let Z=this.#e();if(!Z.length)return;let $=(Q%Z.length+Z.length)%Z.length;this.#_=$,Z[$]?.focus()}#Y0(){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")}#K0(){if(!this.#Z||F(this,"disabled"))return;if(this.#Q)this.#Z.anchor=this.#Q;this.#R(),this.#K=!1,this.#N=null,this.#W=null,this.#r(),this.#Y0(),this.#Z.open=!0,document.addEventListener("keydown",this.#M,!0),this.#Q?.setAttribute("aria-expanded","true"),this.#_=-1,requestAnimationFrame(()=>{this.#Y0(),this.#m();let Q=this.#O(),$=this.#e().findIndex((J)=>this.#h(J)===this.value);if($>=0)this.#Z0($);else if(this.#Q?.hasAttribute("data-focus-visible")||this.#Q?.matches?.(":focus-visible"))this.#Z0(0);Q?.syncOverflow?.(),this.#K=!0,this.#V()})}#X0(){if(!this.#Z)return;this.#K=!1,this.#N=null,this.#W=null,document.removeEventListener("keydown",this.#M,!0),this.#Z.open=!1,this.#Q?.setAttribute("aria-expanded","false")}}z("fig-select",i0);class r0 extends HTMLElement{#Q=!1;#Z=!1;#$=!1;#J=!1;#j="";#q=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#Y={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"}};#_;#X;#U;#G;#K;#N;#W;#L=null;#F=null;#z=null;#B=null;constructor(){super();this.initialInnerHTML=null,this.#_=(Q)=>{Q.stopPropagation(),this.#b()},this.#X=(Q)=>{Q.stopPropagation(),this.#v()},this.#K=(Q)=>{this.#V(Q)},this.#U=(Q)=>{Q.stopPropagation(),this.#O()},this.#G=(Q)=>{Q.stopPropagation(),this.#m()},this.#N=()=>{this.#Q=!0},this.#W=()=>{if(this.#Q=!1,this.#Z&&this.isConnected)this.#Z=!1,this.#H()}}#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.#Y[this.type]||this.#Y.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.#C(Q)}#A(){if(!this.querySelector("[type=range]"))return!1;return this.getAttribute("text")!=="false"===!!this.querySelector("fig-input-number")}#P(){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)}}#D(){if(this.#y(),this.input.removeEventListener("input",this.#_),this.input.addEventListener("input",this.#_),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.#N),this.input.addEventListener("pointerdown",this.#N),this.input.removeEventListener("pointerup",this.#W),this.input.addEventListener("pointerup",this.#W),this.input.removeEventListener("pointercancel",this.#W),this.input.addEventListener("pointercancel",this.#W),this.default)this.style.setProperty("--default",this.#T(this.default));if(this.figInputNumber)this.#w(),this.figInputNumber.removeEventListener("input",this.#U),this.figInputNumber.addEventListener("input",this.#U),this.figInputNumber.removeEventListener("change",this.#G),this.figInputNumber.addEventListener("change",this.#G)}#H(){if(this.#M(),this.color)this.style.setProperty("--color",this.color);let Q="",Z=`<div class="fig-slider-input-container" role="group">
130
+ `;let Q=document.createElement("fig-button");Q.className="fig-select-trigger",Q.setAttribute("part","trigger"),Q.setAttribute("variant","ghost"),Q.setAttribute("aria-haspopup","listbox"),Q.setAttribute("aria-expanded","false");let Z=document.createElement("span");Z.className="fig-select-prepend",Z.setAttribute("part","prepend"),Z.setAttribute("aria-hidden","true");let $=document.createElement("span");$.className="fig-select-label",$.setAttribute("part","label"),Q.append(Z,$);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(),Q.setAttribute("aria-controls",J.id);let j=document.createElement("slot");if(j.setAttribute("name","panel"),J.appendChild(j),q.append(Q,J),this.#Q=Q,this.#Z=Z,this.#$=$,this.#q=J,this.#J=j,J.anchor=Q,this.#A(),this.#x(),this.#F(),!this.hasAttribute("value")){let _=this.#d().find((W)=>z(W,"selected"));if(_)this.setAttribute("value",_.value)}}#F(){if(!this.#q||this.#Y)return;if(typeof this.#q.positionPopup!=="function")return;this.#G=this.#q.positionPopup.bind(this.#q),this.#q.positionPopup=()=>{if(!this.open){this.#G?.();return}this.#h()},this.#Y=!0}#f(q){if(!q)return null;let Q=document.createRange();Q.selectNodeContents(q);let Z=[...Q.getClientRects()].filter(($)=>$.width>0&&$.height>0);if(Z.length)return Z[0];return q.getBoundingClientRect()}#I(){if(typeof this.#q?.parseViewportMargins==="function")return this.#q.parseViewportMargins();return{top:8,right:8,bottom:8,left:8}}#S(){let q=this.#$?.getBoundingClientRect();if(!q)return null;return{x:q.x,y:q.y,width:q.width,height:q.height}}#w(){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,Q,Z=0.25){if(!q&&!Q)return!1;if(!q||!Q)return!0;return Math.abs(q.x-Q.x)>Z||Math.abs(q.y-Q.y)>Z||Math.abs(q.width-Q.width)>Z||Math.abs(q.height-Q.height)>Z}#u(q,Q,Z=0.25){if(!q&&!Q)return!1;if(!q||!Q)return!0;return Math.abs(q.width-Q.width)>Z||Math.abs(q.height-Q.height)>Z||Math.abs(q.offsetLeft-Q.offsetLeft)>Z||Math.abs(q.offsetTop-Q.offsetTop)>Z}#b(){if(!this.#K)return!1;let q=this.#y(this.#X,this.#S()),Q=this.#u(this.#U,this.#w());return!q&&!Q}#E(){this.#X=this.#S(),this.#U=this.#w()}#h(){if(this.#b())return;let q=this.#q,Q=this.#$;if(!q||!Q){this.#G?.();return}let Z=this.#d(),$=Z.find((L)=>this.#m(L)===this.value)||Z[0];if(!$){this.#G?.();return}this.#G?.();let J=q.getBoundingClientRect(),j=Q.getBoundingClientRect(),_=this.#f($);if(!J.width||!J.height||!j.width||!_)return;let W=_.left-J.left,N=_.top-J.top,G=z(this,"full")?this.getBoundingClientRect().left:j.left-W,U=j.top-N,X=this.#I();if(typeof q.clampToViewport==="function")({left:G,top:U}=q.clampToViewport({left:G,top:U},J,X));else{let{left:L,top:D}=X,F=window.innerWidth-J.width-X.right,H=window.innerHeight-J.height-X.bottom;G=Math.min(Math.max(G,L),Math.max(L,F)),U=Math.min(Math.max(U,D),Math.max(D,H))}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(U)}px`,"important");let O=this.#O(),R=this.#f($);if(R&&O&&O.scrollHeight>O.clientHeight+1){let L=R.top-j.top;if(Math.abs(L)>0.5)O.scrollTop+=L;O.syncOverflow?.()}if(this.#K||this.open)this.#E()}#x(){this.#Q?.addEventListener("click",this.#z),this.#Q?.addEventListener("keydown",this.#R),this.addEventListener("click",this.#M),this.addEventListener("pointerover",this.#B),this.#q?.addEventListener("keydown",this.#R),this.#q?.addEventListener("close",this.#H),this.#J?.addEventListener("slotchange",this.#D)}#v(){this.#Q?.removeEventListener("click",this.#z),this.#Q?.removeEventListener("keydown",this.#R),this.removeEventListener("click",this.#M),this.removeEventListener("pointerover",this.#B),this.#q?.removeEventListener("keydown",this.#R),this.#q?.removeEventListener("close",this.#H),this.#J?.removeEventListener("slotchange",this.#D)}#g(){this.#A(),this.#i()}#o(){if(this.#j)return;this.#j=new MutationObserver((q)=>{if(this.#W||this.#L)return;let Q=!1;for(let Z of q){if(Z.type==="childList"){if([...Z.addedNodes].some(($)=>this.#T($))||[...Z.removedNodes].some(($)=>this.#T($))||Z.target?.closest?.("fig-select-option"))Q=!0}if(Z.type==="attributes"&&Z.target?.tagName==="FIG-SELECT-OPTION"&&(Z.attributeName==="value"||Z.attributeName==="disabled"||Z.attributeName==="label"))Q=!0;if(Z.type==="characterData"&&Z.target?.parentElement?.tagName==="FIG-SELECT-OPTION")Q=!0}if(Q)this.#i()}),this.#j.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","disabled","selected","label"]})}#d({enabledOnly:q=!1}={}){let Q=this.#O(),Z=Q?Array.from(Q.querySelectorAll(":scope > fig-select-option")):[];if(!q)return Z;return Z.filter(($)=>!z($,"disabled"))}#m(q){if(!q)return"";if(typeof q.value==="string")return q.value;let Q=q.getAttribute?.("value");if(Q!=null)return Q;return(q.textContent||"").trim()}#l(q){if(!q)return"";let Q=q.getAttribute?.("label");if(Q!=null&&Q!=="")return Q.trim();let Z=[];for(let $ of q.childNodes){if($.nodeType===Node.TEXT_NODE){let _=$.textContent?.trim();if(_)Z.push(_);continue}if(!($ instanceof Element))continue;let J=$.getAttribute("slot");if(J==="prepend"||J==="append")continue;let j=$.textContent?.trim();if(j)Z.push(j)}if(Z.length)return Z.join(" ").trim();return(q.textContent||"").trim()}#s(q){if(!this.#Z)return;let Q=q?.querySelector?.(':scope > [slot="prepend"]');this.#Z.replaceChildren(...Array.from(Q?.childNodes??[],(Z)=>Z.cloneNode(!0)))}#p(){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 Q=this.getAttribute("closedby");if(Q)this.#q.setAttribute("closedby",Q);else this.#q.removeAttribute("closedby")}#c(){let q=z(this,"disabled");if(this.#Q)if(q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(q&&this.open)this.open=!1}#r(q){if(!q.length)return null;let Q=q.find((Z)=>z(Z,"selected"));if(Q&&!z(Q,"disabled"))return Q;return q.find((Z)=>!z(Z,"disabled"))||q[0]||null}#a(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.#W)return;this.#W=!0;try{let q=this.#d(),Q=this.hasAttribute("value"),Z=Q?this.getAttribute("value"):null,$=Q?q.find((W)=>this.#m(W)===Z):null,J=!1;if(!$){if(Q){if(!q.length){if(this.#$)this.#$.textContent=Z||this.getAttribute("label")||"";return}if($=this.#r(q),$){let W=this.#m($);if(Z!==W)this.setAttribute("value",W),J=!0}else this.removeAttribute("value"),J=!0}else if($=q.find((W)=>z(W,"selected")),$)this.setAttribute("value",this.#m($)),J=!0}for(let W of q){let N=W===$;if(W.setAttribute("aria-selected",N?"true":"false"),N)W.setAttribute("selected","");else W.removeAttribute("selected")}let j=$&&this.#l($)||this.getAttribute("label")||"";if(this.#$)this.#$.textContent=j;this.#s($);let _=this.getAttribute("label")||"Select";if(this.#Q?.setAttribute("aria-label",_),this.#O()?.syncOverflow?.(),J)this.#a(this.getAttribute("value")??"")}finally{this.#W=!1}}#$0(q){if(z(this,"disabled"))return;q.preventDefault(),q.stopPropagation();let Q=!this.open;if(Q&&this.#q&&this.#Q)this.#q.anchor=this.#Q;this.open=Q}#J0(q){let Z=(typeof q.composedPath==="function"?q.composedPath():[]).find(($)=>$?.tagName==="FIG-SELECT-OPTION");if(!Z||!this.contains(Z))return;if(z(Z,"disabled"))return;this.#j0(Z)}#q0(q){let Z=(typeof q.composedPath==="function"?q.composedPath():[]).find(($)=>$?.tagName==="FIG-SELECT-OPTION");if(!Z||!this.contains(Z))return;if(z(Z,"disabled"))return;if(q.relatedTarget instanceof Node&&Z.contains(q.relatedTarget))return;this.dispatchEvent(new CustomEvent("optionhover",{detail:this.#m(Z),bubbles:!0,composed:!0}))}#t(q){if(q.currentTarget===document&&q.key!=="Escape")return;if(!(this.open&&(this.#q?.matches?.(":open")??!1))){if(this.#Q?.contains(q.target)&&(q.key==="ArrowDown"||q.key==="Enter"||q.key===" ")){if(q.preventDefault(),this.#q&&this.#Q)this.#q.anchor=this.#Q;this.open=!0,requestAnimationFrame(()=>{let J=this.#d({enabledOnly:!0}).findIndex((j)=>this.#m(j)===this.value);this.#Q0(J>=0?J:0)})}return}let Z=this.#d({enabledOnly:!0});if(!Z.length)return;switch(q.key){case"ArrowDown":q.preventDefault(),this.#n(),this.#Q0(this.#_+1);break;case"ArrowUp":q.preventDefault(),this.#n(),this.#Q0(this.#_-1);break;case"Home":q.preventDefault(),this.#Q0(0);break;case"End":q.preventDefault(),this.#Q0(Z.length-1);break;case"Escape":q.preventDefault(),this.open=!1,this.#Q?.focus();break;case"Enter":case" ":{this.#n();let $=Z[this.#_];if(!$)return;q.preventDefault(),this.#j0($);break}}}#_0(){if(this.hasAttribute("open"))this.removeAttribute("open");this.#Q?.setAttribute("aria-expanded","false"),this.#Q?.focus(),this.#_=-1}#j0(q){let Q=this.#m(q);this.setAttribute("value",Q),this.#i(),this.#a(Q),this.open=!1}#e(){return this.#d({enabledOnly:!0})}#n(){let q=this.#e();if(!q.length){this.#_=-1;return}let Q=q.find(($)=>$===document.activeElement),Z=Q?q.indexOf(Q):-1;this.#_=Z>=0?Z:this.#_}#Q0(q){let Q=this.#e();if(!Q.length)return;let Z=(q%Q.length+Q.length)%Q.length;this.#_=Z,Q[Z]?.focus()}#N0(){if(!this.#q||!this.#Q)return;let q=Math.ceil(this.getBoundingClientRect().width),Q=Math.ceil(this.#Q.getBoundingClientRect().width),Z=Math.max(q,Q,96);this.#q.style.setProperty("width","max-content","important"),this.#q.style.setProperty("min-width",`${Z}px`,"important"),this.#q.style.setProperty("max-width","min(20rem, calc(100vw - 1rem))","important")}#K0(){if(!this.#q||z(this,"disabled"))return;if(this.#Q)this.#q.anchor=this.#Q;this.#F(),this.#K=!1,this.#X=null,this.#U=null,this.#i(),this.#N0(),this.#q.open=!0,document.addEventListener("keydown",this.#R,!0),this.#Q?.setAttribute("aria-expanded","true"),this.#_=-1,requestAnimationFrame(()=>{this.#N0(),this.#h();let q=this.#O(),Z=this.#e().findIndex(($)=>this.#m($)===this.value);if(Z>=0)this.#Q0(Z);else if(this.#Q?.hasAttribute("data-focus-visible")||this.#Q?.matches?.(":focus-visible"))this.#Q0(0);q?.syncOverflow?.(),this.#K=!0,this.#E()})}#W0(){if(!this.#q)return;this.#K=!1,this.#X=null,this.#U=null,document.removeEventListener("keydown",this.#R,!0),this.#q.open=!1,this.#Q?.setAttribute("aria-expanded","false")}}M("fig-select",o0);class r0 extends HTMLElement{#Q=!1;#q=!1;#Z=!1;#$=!1;#J="";#j=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#N={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"}};#_;#W;#Y;#G;#K;#X;#U;#L=null;#z=null;#M=null;#B=null;constructor(){super();this.initialInnerHTML=null,this.#_=(q)=>{q.stopPropagation(),this.#u()},this.#W=(q)=>{q.stopPropagation(),this.#b()},this.#K=(q)=>{this.#E(q)},this.#Y=(q)=>{q.stopPropagation(),this.#O()},this.#G=(q)=>{q.stopPropagation(),this.#h()},this.#X=()=>{this.#Q=!0},this.#U=()=>{if(this.#Q=!1,this.#q&&this.isConnected)this.#q=!1,this.#A()}}#R(){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 Q=this.#N[this.type]||this.#N.range,Z=($,J)=>{let j=this.getAttribute($),_=j===null||j.trim()===""?J:Number(j);return Number.isFinite(_)?_:J};if(this.min=Z("min",Q.min),this.max=Z("max",Q.max),this.step=Z("step",Q.step),!(this.step>0))this.step=Q.step>0?Q.step:1;this.color=this.getAttribute("color")||Q?.color,this.default=this.hasAttribute("default")?this.getAttribute("default"):this.type==="delta"?0:this.min,this.#Z=this.type!=="range"&&(q===null||typeof q==="string"&&q.trim()===""),this.value=this.#f(q)}#H(){if(!this.querySelector("[type=range]"))return!1;return this.getAttribute("text")!=="false"===!!this.querySelector("fig-input-number")}#D(){if(this.#R(),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.#Z?"":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)}}#T(){if(this.#w(),this.input.removeEventListener("input",this.#_),this.input.addEventListener("input",this.#_),this.input.removeEventListener("change",this.#W),this.input.addEventListener("change",this.#W),this.input.removeEventListener("keydown",this.#K),this.input.addEventListener("keydown",this.#K),this.input.removeEventListener("pointerdown",this.#X),this.input.addEventListener("pointerdown",this.#X),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.#y(),this.figInputNumber.removeEventListener("input",this.#Y),this.figInputNumber.addEventListener("input",this.#Y),this.figInputNumber.removeEventListener("change",this.#G),this.figInputNumber.addEventListener("change",this.#G)}#A(){if(this.#R(),this.color)this.style.setProperty("--color",this.color);let q="",Q=`<div class="fig-slider-input-container" role="group">
131
131
  <input
132
132
  type="range"
133
133
  ${this.text?'tabindex="-1"':""}
@@ -141,32 +141,32 @@ var w1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var v1={};var P0=w1(()=>{/*! Vendored from @
141
141
  aria-valuemax="${this.max}"
142
142
  aria-valuenow="${this.value}">
143
143
  ${this.initialInnerHTML}
144
- </div>`;if(this.text)Q=`${Z}
144
+ </div>`;if(this.text)q=`${Q}
145
145
  <fig-input-number
146
- placeholder="${v(this.placeholder)}"
146
+ placeholder="${b(this.placeholder)}"
147
147
  min="${this.min}"
148
148
  max="${this.max}"
149
149
  transform="${this.transform}"
150
150
  step="${this.step}"
151
- value="${this.#$?"":this.value}"
152
- ${this.units?`units="${v(this.units)}"`:""}
151
+ value="${this.#Z?"":this.value}"
152
+ ${this.units?`units="${b(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.#D(),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.#A()){this.#P(),this.#D(),this.#k();return}this.#H()}get value(){if(this.#j!=="")return this.#j;let Q=this.getAttribute("value");if(Q!==null)return String(this.#C(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.#C(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.#E()}disconnectedCallback(){if(this.#Z=!1,this.input)this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#X),this.input.removeEventListener("keydown",this.#K),this.input.removeEventListener("pointerdown",this.#N),this.input.removeEventListener("pointerup",this.#W),this.input.removeEventListener("pointercancel",this.#W);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#U),this.figInputNumber.removeEventListener("change",this.#G)}#O(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#$=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let Z=this.#C(Q);this.value=Z,this.input.value=String(Z),this.#k(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#T(Q){let{min:Z,max:$}=this.#I(),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}#I(){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}}#f(Q){let{min:Z,max:$}=this.#I();return Math.min($,Math.max(Z,Q))}#R(){if(this.type==="delta"){let Z=this.#S(this.default);if(Z!==null)return this.#f(Z);return this.#f(0)}if(this.type==="range"){let{min:Z,max:$}=this.#I();return this.#f(Z+($-Z)/2)}let{min:Q}=this.#I();return Q}#C(Q){let Z=this.#S(Q);if(Z===null)return this.#R();return this.#f(Z)}#E(){let Q=this.#T(this.value),Z=this.#T(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.#E(),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.#w();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)})}#w(){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}))}#v(){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.#R(),J=this.#S(this.step)??1,j=this.#C($+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}))}#m(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#$=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let Z=this.#C(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.#Y[this.type]||this.#Y.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.#C(this.value),this.#E(),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)}#g(){if(this.#Q){this.#Z=!0;return}this.#Z=!1,this.#H()}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.#C($),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.#E();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.#g();break;case"text":if(!this.#Q)this.text=$!=="false";this.#g();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",r0);class o0 extends HTMLElement{#Q=!1;#Z=!1;#$="";#J=!1;#j;#q;#Y;#_;#X;#U;#G;#K;#N=null;#W=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.#w.bind(this),this.#Y=this.#w.bind(this),this.#_=this.#y.bind(this),this.#X=(Q)=>{Q.stopPropagation(),this.#E(Q)},this.#U=(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.#G=()=>{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.#H(),this.#O(),this.#T(),this.#S(),this.#I(),this.#R(),_0(this),this.#A(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#C(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#C(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#C(this.step));this.addEventListener("pointerdown",this.#_)}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.#U),this.input.addEventListener("input",this.#U)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#X),this.input.removeEventListener("input",this.#U);if(this.removeEventListener("click",this.#K),this.removeEventListener("pointerdown",this.#_),window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#q),window.removeEventListener("blur",this.#Y),this.#N?.disconnect(),this.#N=null,this.#W)cancelAnimationFrame(this.#W),this.#W=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.#C(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()}#A(){this.#N?.disconnect(),this.#N=new MutationObserver(()=>this.#P()),this.#N.observe(this,{childList:!0,characterData:!0,subtree:!0})}#P(){if(this.#W)return;this.#W=requestAnimationFrame(()=>{if(this.#W=0,!this.isConnected)return;this.#D()})}#D(){if(!this.input||!this.contains(this.input))this.input=this.#B(),this.input.readOnly=this.readonly,this.input.addEventListener("change",this.#X),this.input.addEventListener("input",this.#U);this.#H(),this.#O(),this.#T(),this.#S(),this.#I(),this.#R(),_0(this)}#H(){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)})}#O(){let Q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){Q?.remove();return}if(this.querySelector('[slot="prepend"]:not([data-generated])')){Q?.remove();return}if(Q){let J=Q.querySelector("fig-icon");if(J&&J.getAttribute("name")!=="search")J.setAttribute("name","search");return}let $=u("search");$.setAttribute("slot","prepend"),$.setAttribute("data-generated","search-prefix"),$.setAttribute("color","var(--figma-color-icon)"),$.addEventListener("click",this.#G),this.prepend($)}#T(){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)}#I(){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.#f(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.#f($),j.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),this.disabled)return;if(this.#Z=!this.#Z,this.input)this.input.type=this.#Z?"text":"password";this.#f($),this.focus()})}#f(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")}#R(){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")})}#C(Q){if(Q==="")return"";let Z=Number(Q)*(this.transform||1);return Z=this.#v(Z),Z}#E(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.#w();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.#v($),J=this.#v(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.#Y)}#w(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.#Y),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.#C(this.min):this.min,$);if(typeof this.max==="number")$=Math.min(Z?this.#C(this.max):this.max,$);$=this.#v($)}return $}#v(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.#C(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.#R();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.#C(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.#_),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.#_);this.#O(),this.#T(),this.#S(),this.#I(),this.#R();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.#U),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.#U),this.#H()}break}case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#H();break;default:this[Q]=this.input[Q]=$;break}}}z("fig-input-text",o0);class X0 extends HTMLElement{#Q;#Z;#$;#J;#j;#q;#Y;#_;#X;#U;#G;#K;#N;#W;#L;#F;#z=!1;#B=null;#M=null;#A=0;#P="";#D="";#H=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#O="px";#T(Q){return(Q||"").split(",").map((Z)=>Z.trim().toLowerCase()).filter(Boolean)}#S(Q){let Z=(Q||"").trim();if(!Z)return"";return(this.#W??[]).includes(Z.toLowerCase())?"":Z}#I(){this.#K=this.#S(this.#N)}#f(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.#C(J),this.input.focus()}),this.append(this.#B);else if(!Q&&this.#B)this.#B.remove(),this.#B=null;this.#R()}#R(){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.#m(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||_}#C(Q){let Z=this.step||1,$=this.#m(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.#R(),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.#i.bind(this),this.#Z=this.#u.bind(this),this.#$=this.#u.bind(this),this.#J=this.#p.bind(this),this.#j=(Q)=>{Q.stopPropagation(),this.#t(Q)},this.#q=(Q)=>{Q.stopPropagation(),this.#h(Q)},this.#Y=(Q)=>{this.#g(Q)},this.#_=(Q)=>{this.#d(Q)},this.#X=(Q)=>{this.#s(Q)},this.#U=this.focus.bind(this),this.#G=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.#N=this.getAttribute("units")||"";let Z=this.getAttribute("units-disallow");if(this.#W=this.#T(Z===null?X0.#O:Z),this.#I(),this.#L=this.getAttribute("unit-position")||"suffix",this.#F=this.#r(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.#E(),this.#v(),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.#f($),this.hasAttribute("disabled")){let J=this.getAttribute("disabled");this.disabled=this.input.disabled=J!=="false"}this.#R(),this.#V(),_0(this),this.addEventListener("pointerdown",this.#J),this.removeEventListener("click",this.#G),this.addEventListener("click",this.#G),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.#Y),this.input.addEventListener("focus",this.#Y),this.input.removeEventListener("blur",this.#_),this.input.addEventListener("blur",this.#_),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.#Y),this.input.removeEventListener("blur",this.#_),this.input.removeEventListener("keydown",this.#X);if(this.removeEventListener("click",this.#G),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.#A)cancelAnimationFrame(this.#A),this.#A=0}focus(){this.input.focus()}#E(){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.#w()),this.#M.observe(this,{childList:!0,characterData:!0,subtree:!0})}#w(){if(this.#A)return;this.#A=requestAnimationFrame(()=>{if(this.#A=0,!this.isConnected)return;this.#b()})}#b(){if(!this.input||!this.contains(this.input))this.input=this.#E(),this.input.addEventListener("change",this.#j),this.input.addEventListener("input",this.#q),this.input.addEventListener("focus",this.#Y),this.input.addEventListener("blur",this.#_),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.#f(Q),this.#v(),this.#V(),_0(this)}#v(){if(!this.input)return;this.#H.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")}#m(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.#n(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.#n(Z),Z.toString()}#g(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)}#d(Q){this.#z=!1;let Z=this.#m(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.#R(),this.#V()}#s(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.#m(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.#R(),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#h(Q){let Z=this.#m(Q.target.value);if(Z!=="")this.value=Number(Z)/(this.transform||1);else this.value="";this.#R(),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#t(Q){Q.stopPropagation();let Z=this.#m(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.#R(),this.#V(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#i(Q){if(this.disabled)return;if(Q.buttons===0){this.#u();return}let Z=(this.step||1)*Q.movementX,$=this.#m(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.#R(),this.#V(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#p(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#z=!0,this.#P=this.style.userSelect,this.#D=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.#D,this.style.userSelect=this.#P,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.#n($),$}#n(Q){let Z=this.#F??2,$=Math.pow(10,Z),J=Math.round(Q*$)/$;return Number.isInteger(J)?J:parseFloat(J.toFixed(Z))}#r(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.#R();break;case"units":this.#N=$||"",this.#I(),this.input.value=this.#x(this.value),this.#V();break;case"units-disallow":this.#W=this.#T($===null?X0.#O:$),this.#I(),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.#R(),this.#V();break;case"min":case"max":case"step":if($===null||$===""){this[Q]=void 0,this.#R(),this.#V();break}this[Q]=Number($),this.#R(),this.#V();break;case"steppers":{let j=$!==null&&$!=="false";this.#f(j);break}case"precision":this.#F=this.#r($!==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.#v();break;default:this[Q]=this.input[Q]=$;break}}}z("fig-input-number",X0);class l0 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",l0);class a0 extends HTMLElement{#Q=!1;#Z=null;#$=null;#J=null;#j=null;#q=null;#Y=null;constructor(){super();this.#$=this.#U.bind(this),this.#J=this.focus.bind(this),this.#j=this.#G.bind(this),this.#q=this.#K.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(!this.isConnected)return;this.#X(),this.#_()})}#_(){if(this.#Y||typeof MutationObserver>"u")return;this.#Y=new MutationObserver(()=>{this.#X()}),this.#Y.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.#N();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.#Y?.disconnect(),this.#Y=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.#$)}#U(Q){if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open}#G(){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)}#N(){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.#N();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",a0);class t0 extends HTMLElement{rgba;hex;#Q=100;#Z;#$;#J;#j;#q=!1;#Y=!1;#_=null;#X=this.#f.bind(this);#U=this.#R.bind(this);#G=this.#C.bind(this);#K=this.#V.bind(this);#N=this.#k.bind(this);#W=this.#w.bind(this);#L=this.#y.bind(this);#F=this.#m.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.#A();return}this.#H()}disconnectedCallback(){this.#P()}#M(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-swatch")}#A(){if(this.#E(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.#v(),this.#D()}#P(){if(this.#Z)this.#Z.removeEventListener("pointerdown",this.#X,{capture:!0}),this.#Z.removeEventListener("click",this.#U,{capture:!0}),this.#Z.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#G),this.#Z.removeEventListener("input",this.#K);this.#J?.removeEventListener("input",this.#N),this.#J?.removeEventListener("change",this.#W),this.#j?.removeEventListener("input",this.#L),this.#j?.removeEventListener("change",this.#W),this.#$?.removeEventListener("input",this.#F),this.#$?.removeEventListener("change",this.#W)}#D(){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.#U,{capture:!0}),Q?.addEventListener("keydown",this.#G),this.#Z.addEventListener("input",this.#K)}if(this.#J)this.#J.addEventListener("input",this.#N),this.#J.addEventListener("change",this.#W);if(this.#j)this.#j.addEventListener("input",this.#L),this.#j.addEventListener("change",this.#W);if(this.#$)this.#$.addEventListener("input",this.#F),this.#$.addEventListener("change",this.#W)}#H(){this.#E(this.getAttribute("value"));let Q=this.getAttribute("alpha")!=="false",$=this.#d?" disabled":"",J="";if(this.getAttribute("text")!=="false"){let q=`<fig-input-text
154
+ </fig-input-number>`;else q=Q;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.#T(),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 Z=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1));for(let $=0;$<Z;$++){let J=document.createElement("option");J.setAttribute("value",this.min+$*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 Z=document.createElement("option");Z.setAttribute("value",this.default),this.datalist.append(Z),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let Z=this.datalist.querySelector(`option[value='${this.default}']`);if(Z)Z.setAttribute("default","true")}this.#S()}connectedCallback(){if(this.initialInnerHTML===null)this.initialInnerHTML=this.innerHTML;if(this.#H()){this.#D(),this.#T(),this.#S();return}this.#A()}get value(){if(this.#J!=="")return this.#J;let q=this.getAttribute("value");if(q!==null)return String(this.#f(q));return""}set value(q){let Q=q===null||q===void 0?"":String(q),$=this.min!==void 0||this.max!==void 0?String(this.#f(Q)):Q;if(this.#J=$,this.getAttribute("value")!==$)this.#$=!0,this.setAttribute("value",$),this.#$=!1;if(this.input&&this.input.value!==$)this.input.value=$,this.input.setAttribute("aria-valuenow",$);if(this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Z?"":$);if(this.input)this.#I()}disconnectedCallback(){if(this.#q=!1,this.input)this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#W),this.input.removeEventListener("keydown",this.#K),this.input.removeEventListener("pointerdown",this.#X),this.input.removeEventListener("pointerup",this.#U),this.input.removeEventListener("pointercancel",this.#U);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#Y),this.figInputNumber.removeEventListener("change",this.#G)}#O(){if(this.figInputNumber){let q=this.figInputNumber.value;this.#Z=q===null||q===void 0||typeof q==="string"&&q.trim()==="";let Q=this.#f(q);this.value=Q,this.input.value=String(Q),this.#S(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#P(q){let{min:Q,max:Z}=this.#C(),$=Z-Q;if($===0)return 0;return(Number(q)-Q)/$}#k(q){if(q===null||q===void 0)return null;if(typeof q==="string"&&q.trim()==="")return null;let Q=Number(q);return Number.isFinite(Q)?Q:null}#C(){let q=this.#k(this.min),Q=this.#k(this.max);if(q===null)q=0;if(Q===null)Q=q;if(q>Q)[q,Q]=[Q,q];return{min:q,max:Q}}#V(q){let{min:Q,max:Z}=this.#C();return Math.min(Z,Math.max(Q,q))}#F(){if(this.type==="delta"){let Q=this.#k(this.default);if(Q!==null)return this.#V(Q);return this.#V(0)}if(this.type==="range"){let{min:Q,max:Z}=this.#C();return this.#V(Q+(Z-Q)/2)}let{min:q}=this.#C();return q}#f(q){let Q=this.#k(q);if(Q===null)return this.#F();return this.#V(Q)}#I(){let q=this.#P(this.value),Q=this.#P(this.default),Z=q<Q?-1:1,$=q===Q?1:0;if(this.#L!==q)this.style.setProperty("--slider-complete",q),this.#L=q;if(this.#z!==Q)this.style.setProperty("--default",Q),this.#z=Q;if(this.#M!==Z)this.style.setProperty("--slider-delta-direction",Z),this.#M=Z;if(this.#B!==$)this.style.setProperty("--unchanged",$),this.#B=$}#S(){let q=this.input.value;if(this.value=q,this.#I(),this.input.setAttribute("aria-valuenow",q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Z?"":q)}#w(){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 Q=this.getAttribute(q);if(Q===null)this.input.removeAttribute(q);else this.input.setAttribute(q,Q)})}#y(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.figInputNumber.removeAttribute(q);else this.figInputNumber.setAttribute(q,Q)})}#u(){this.#Z=!1,this.#S(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#b(){this.#Q=!1,this.#Z=!1,this.#S(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#E(q){if(this.disabled||!q.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(q.key))return;q.preventDefault(),this.#Z=!1;let Q=q.key==="ArrowRight"||q.key==="ArrowUp"?1:-1,Z=this.#k(this.input.value)??this.#F(),$=this.#k(this.step)??1,J=this.#f(Z+$*10*Q);this.value=J,this.input.value=String(J),this.#S(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#h(){if(this.figInputNumber){let q=this.figInputNumber.value;this.#Z=q===null||q===void 0||typeof q==="string"&&q.trim()==="";let Q=this.#f(q);this.value=Q,this.input.value=String(Q),this.#S(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}#x(q,Q){if(!this.input)return;let Z=this.#N[this.type]||this.#N.range,$=Q===null||String(Q).trim()===""?Z[q]:Number(Q),J=Number.isFinite($)?$:Z[q];if(q==="step"&&!(J>0))J=Z.step>0?Z.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.#f(this.value),this.#I(),this.#v()}#v(){if(this.type!=="stepper"||!this.datalist)return;let q=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1)),Q=document.createDocumentFragment();for(let Z=0;Z<q;Z++){let $=document.createElement("option");$.setAttribute("value",this.min+Z*this.step),Q.append($)}this.datalist.replaceChildren(Q),this.input.setAttribute("list",this.datalist.id)}#g(){if(this.#Q){this.#q=!0;return}this.#q=!1,this.#A()}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,Q,Z){if(Q===Z)return;if(q==="value"&&this.#$)return;if(this.input)switch(q){case"color":this.color=Z,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=Z!==null&&Z!=="false",this.figInputNumber)this.figInputNumber.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#Q)break;if(this.#Z=Z===null||typeof Z==="string"&&Z.trim()==="",this.value=this.#f(Z),this.input.value=String(this.value),this.#S(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Z?"":this.value);break;case"transform":if(this.transform=Number(Z)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=Z!==null?Number(Z):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=Z!==null?Z:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=Z!==null?Z:this.type==="delta"?0:this.min,this.#I();break;case"min":case"max":case"step":this.#x(q,Z);break;case"units":if(this.units=Z||"",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]=Z;this.#g();break;case"text":if(!this.#Q)this.text=Z!=="false";this.#g();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#w();break;default:this[q]=this.input[q]=Z,this.#S();break}}}M("fig-slider",r0);class i0 extends HTMLElement{#Q=!1;#q=!1;#Z="";#$=!1;#J;#j;#N;#_;#W;#Y;#G;#K;#X=null;#U=0;#L="";#z="";#M=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#J=this.#S.bind(this),this.#j=this.#y.bind(this),this.#N=this.#y.bind(this),this.#_=this.#w.bind(this),this.#W=(q)=>{q.stopPropagation(),this.#I(q)},this.#Y=(q)=>{q.stopPropagation();let Q=q.target.value;if(this.type==="number")Q=Number(Q)/(this.transform||1);this.value=Q,this.#k(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))},this.#G=()=>{if(!this.disabled)this.focus()},this.#K=this.#R.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.#A(),this.#O(),this.#P(),this.#k(),this.#C(),this.#F(),_0(this),this.#H(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#f(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#f(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#f(this.step));this.addEventListener("pointerdown",this.#_)}this.removeEventListener("click",this.#K),this.addEventListener("click",this.#K),this.input.removeEventListener("change",this.#W),this.input.addEventListener("change",this.#W),this.input.removeEventListener("input",this.#Y),this.input.addEventListener("input",this.#Y)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#W),this.input.removeEventListener("input",this.#Y);if(this.removeEventListener("click",this.#K),this.removeEventListener("pointerdown",this.#_),window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#j),window.removeEventListener("blur",this.#N),this.#X?.disconnect(),this.#X=null,this.#U)cancelAnimationFrame(this.#U),this.#U=0}focus(){this.input.focus()}#B(){let q=this.multiline,Q=this.querySelector("input,textarea");if(Q){if(q?Q.tagName==="TEXTAREA":Q.tagName==="INPUT")return Q;Q.remove()}let Z;if(q)Z=document.createElement("textarea"),Z.value=this.value;else Z=document.createElement("input"),Z.type=this.type,Z.value=this.type==="number"?this.#f(this.value):this.value;if(Z.setAttribute("data-generated","input-control"),this.name)Z.name=this.name;return Z.placeholder=this.placeholder,this.insertBefore(Z,this.querySelector('[slot="append"]')),Z}#R(q){let Q=q.target?.closest?.("[slot]");if(!Q||Q.parentElement!==this)return;if(this.disabled)return;this.focus()}#H(){this.#X?.disconnect(),this.#X=new MutationObserver(()=>this.#D()),this.#X.observe(this,{childList:!0,characterData:!0,subtree:!0})}#D(){if(this.#U)return;this.#U=requestAnimationFrame(()=>{if(this.#U=0,!this.isConnected)return;this.#T()})}#T(){if(!this.input||!this.contains(this.input))this.input=this.#B(),this.input.readOnly=this.readonly,this.input.addEventListener("change",this.#W),this.input.addEventListener("input",this.#Y);this.#A(),this.#O(),this.#P(),this.#k(),this.#C(),this.#F(),_0(this)}#A(){if(!this.input)return;this.#M.forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.input.removeAttribute(q);else this.input.setAttribute(q,Q)})}#O(){let q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){q?.remove();return}if(this.querySelector('[slot="prepend"]:not([data-generated])')){q?.remove();return}if(q){let $=q.querySelector("fig-icon");if($&&$.getAttribute("name")!=="search")$.setAttribute("name","search");return}let Z=c("search");Z.setAttribute("slot","prepend"),Z.setAttribute("data-generated","search-prefix"),Z.setAttribute("color","var(--figma-color-icon)"),Z.addEventListener("click",this.#G),this.prepend(Z)}#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 Z=document.createElement("span");Z.setAttribute("slot","append"),Z.setAttribute("data-generated","search-clear");let $=document.createElement("fig-tooltip");$.setAttribute("text","Clear search");let J=document.createElement("fig-button");J.setAttribute("variant","ghost"),J.setAttribute("icon",""),J.setAttribute("aria-label","Clear search");let j=c("close",{size:"small"});j.setAttribute("color","var(--figma-color-icon-secondary)"),J.append(j),$.append(J),Z.append($),this.append(Z),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.#k(),this.focus()})}#k(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#C(){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.#V(q);return}let Z=document.createElement("span");Z.setAttribute("slot","append"),Z.setAttribute("data-generated","password-toggle");let $=document.createElement("fig-tooltip"),J=document.createElement("fig-button");J.setAttribute("variant","ghost"),J.setAttribute("icon","");let j=c("visible",{size:"small"});j.setAttribute("color","var(--figma-color-icon-secondary)"),J.append(j),$.append(J),Z.append($),this.append(Z),this.#V(Z),J.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),this.disabled)return;if(this.#q=!this.#q,this.input)this.input.type=this.#q?"text":"password";this.#V(Z),this.focus()})}#V(q){let Q=q.querySelector("fig-tooltip"),Z=q.querySelector("fig-button"),$=q.querySelector("fig-icon"),J=this.#q?"Hide password":"Show password";Q?.setAttribute("text",J),Z?.setAttribute("aria-label",J),$?.setAttribute("name",this.#q?"visible":"hidden")}#F(){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")})}#f(q){if(q==="")return"";let Q=Number(q)*(this.transform||1);return Q=this.#b(Q),Q}#I(q){q.stopPropagation();let Q=q.target.value,Z=Q;if(this.type==="number")Q=Q/(this.transform||1),Q=this.#u(Q,!1),Z=Q*(this.transform||1);this.value=Q,this.input.value=Z,this.#k(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#S(q){if(this.type!=="number")return;if(q.buttons===0){this.#y();return}let Q=(this.step||1)*q.movementX,Z=Number(this.input.value);Z=Z/(this.transform||1)+Q,Z=this.#u(Z,!1);let $=Z*(this.transform||1);Z=this.#b(Z),$=this.#b($),this.value=Z,this.input.value=$,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#w(q){if(this.type!=="number")return;if(q.altKey||q.target.closest("[slot]"))this.#Q=!0,this.#L=this.style.userSelect,this.#z=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.#j),window.addEventListener("pointercancel",this.#j),window.addEventListener("blur",this.#N)}#y(q){if(this.type!=="number")return;let Q=this.#Q;if(this.#Q=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#z,this.style.userSelect=this.#L,window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#j),window.removeEventListener("pointercancel",this.#j),window.removeEventListener("blur",this.#N),Q)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#u(q,Q=!0){let Z=q;if(this.type==="number"){if(Z=Number(Z),typeof this.min==="number")Z=Math.max(Q?this.#f(this.min):this.min,Z);if(typeof this.max==="number")Z=Math.min(Q?this.#f(this.max):this.max,Z);Z=this.#b(Z)}return Z}#b(q,Q=2){let Z=Math.round(q*100)/100;return Number.isInteger(Z)?Z:Z.toFixed(Q)}get value(){return this.#Z}set value(q){let Q=q??"";this.#Z=Q;let Z=String(Q);if(this.getAttribute("value")!==Z)this.#$=!0,this.setAttribute("value",Z),this.#$=!1;this.#E(Q)}#E(q){if(!this.input||this.#Q)return;let Q=this.type==="number"?String(this.#f(q)):String(q??"");if(this.input.value!==Q)this.input.value=Q;this.#k()}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,Q,Z){if(this.input)switch(q){case"disabled":this.disabled=this.input.disabled=Z!==null&&Z!=="false",this.#F();break;case"readonly":this.readonly=Z!==null&&Z!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number(Z)||1,this.input.value=this.#f(this.value);break;case"value":if(this.#Q)break;let $=Z;if(this.type==="number")$=this.#u($,!1);if(this.#Z=$??"",!this.#$)this.#E(this.#Z);break;case"min":case"max":case"step":if(Z===null||Z==="")this[q]=void 0,this.input.removeAttribute(q);else this[q]=this.input[q]=Number(Z),this.input.setAttribute(q,Z);break;case"name":if(this[q]=this.input[q]=Z||"",Z)this.input.setAttribute("name",Z);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=Z??"",this.input.placeholder=this.placeholder;break;case"type":if(this.type=Z||"text",this.input.type=this.type,this.removeEventListener("pointerdown",this.#_),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.#_);this.#O(),this.#P(),this.#k(),this.#C(),this.#F();break;case"multiline":{let J=Z!==null&&Z!=="false";if(J!==this.multiline){this.multiline=J;let j=this.input;j.removeEventListener("change",this.#W),j.removeEventListener("input",this.#Y),j.remove(),this.input=this.#B(),this.input.readOnly=this.readonly,this.input.disabled=Boolean(this.disabled),this.input.addEventListener("change",this.#W),this.input.addEventListener("input",this.#Y),this.#A()}break}case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#A();break;default:this[q]=this.input[q]=Z;break}}}M("fig-input-text",i0);class W0 extends HTMLElement{#Q;#q;#Z;#$;#J;#j;#N;#_;#W;#Y;#G;#K;#X;#U;#L;#z;#M=!1;#B=null;#R=null;#H=0;#D="";#T="";#A=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#O="px";#P(q){return(q||"").split(",").map((Q)=>Q.trim().toLowerCase()).filter(Boolean)}#k(q){let Q=(q||"").trim();if(!Q)return"";return(this.#U??[]).includes(Q.toLowerCase())?"":Q}#C(){this.#K=this.#k(this.#X)}#V(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",(Q)=>{Q.preventDefault(),Q.stopPropagation();let Z=Q.target.closest("button");if(!Z||this.disabled||Z.disabled)return;let $=Z.classList.contains("fig-stepper-up")?1:-1;this.#f($),this.input.focus()}),this.append(this.#B);else if(!q&&this.#B)this.#B.remove(),this.#B=null;this.#F()}#F(){if(!this.#B)return;let q=this.#B.querySelector(".fig-stepper-up"),Q=this.#B.querySelector(".fig-stepper-down");if(!q||!Q)return;let Z=this.input?this.#h(this.input.value):this.value,$=Z!==""&&Z!==null&&Z!==void 0?Number(Z)/(this.transform||1):Number(this.value),J=Number.isFinite($),j=Boolean(this.disabled),_=J&&typeof this.min==="number"&&$<=this.min,W=J&&typeof this.max==="number"&&$>=this.max;q.disabled=j||W,Q.disabled=j||_}#f(q){let Q=this.step||1,Z=this.#h(this.input.value),$=(Z!==""?Number(Z)/(this.transform||1):0)+Q*q;$=this.#r($,!1),this.value=$,this.input.value=this.#x(this.value),this.#F(),this.#E(),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.#s.bind(this),this.#q=this.#c.bind(this),this.#Z=this.#c.bind(this),this.#$=this.#p.bind(this),this.#J=(q)=>{q.stopPropagation(),this.#l(q)},this.#j=(q)=>{q.stopPropagation(),this.#m(q)},this.#N=(q)=>{this.#g(q)},this.#_=(q)=>{this.#o(q)},this.#W=(q)=>{this.#d(q)},this.#Y=this.focus.bind(this),this.#G=this.#S.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.#X=this.getAttribute("units")||"";let Q=this.getAttribute("units-disallow");if(this.#U=this.#P(Q===null?W0.#O:Q),this.#C(),this.#L=this.getAttribute("unit-position")||"suffix",this.#z=this.#i(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 Z=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.input=this.#I(),this.#b(),this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.#V(Z),this.hasAttribute("disabled")){let $=this.getAttribute("disabled");this.disabled=this.input.disabled=$!=="false"}this.#F(),this.#E(),_0(this),this.addEventListener("pointerdown",this.#$),this.removeEventListener("click",this.#G),this.addEventListener("click",this.#G),this.#w(),this.input.removeEventListener("change",this.#J),this.input.addEventListener("change",this.#J),this.input.removeEventListener("input",this.#j),this.input.addEventListener("input",this.#j),this.input.removeEventListener("focus",this.#N),this.input.addEventListener("focus",this.#N),this.input.removeEventListener("blur",this.#_),this.input.addEventListener("blur",this.#_),this.input.removeEventListener("keydown",this.#W),this.input.addEventListener("keydown",this.#W)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#J),this.input.removeEventListener("input",this.#j),this.input.removeEventListener("focus",this.#N),this.input.removeEventListener("blur",this.#_),this.input.removeEventListener("keydown",this.#W);if(this.removeEventListener("click",this.#G),this.removeEventListener("pointerdown",this.#$),window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#q),window.removeEventListener("blur",this.#Z),this.#R?.disconnect(),this.#R=null,this.#H)cancelAnimationFrame(this.#H),this.#H=0}focus(){this.input.focus()}#I(){let q=this.querySelector("input");if(q)return q;let Q=document.createElement("input");if(Q.type="text",Q.inputMode="decimal",Q.setAttribute("data-generated","input-control"),this.name)Q.name=this.name;return Q.placeholder=this.placeholder,Q.value=this.#x(this.value),this.insertBefore(Q,this.querySelector('[slot="append"]')),Q}#S(q){let Q=q.target?.closest?.("[slot]");if(!Q||Q.parentElement!==this)return;this.focus()}#w(){this.#R?.disconnect(),this.#R=new MutationObserver(()=>this.#y()),this.#R.observe(this,{childList:!0,characterData:!0,subtree:!0})}#y(){if(this.#H)return;this.#H=requestAnimationFrame(()=>{if(this.#H=0,!this.isConnected)return;this.#u()})}#u(){if(!this.input||!this.contains(this.input))this.input=this.#I(),this.input.addEventListener("change",this.#J),this.input.addEventListener("input",this.#j),this.input.addEventListener("focus",this.#N),this.input.addEventListener("blur",this.#_),this.input.addEventListener("keydown",this.#W);let q=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.#B&&!this.contains(this.#B))this.#B=null;this.#V(q),this.#b(),this.#E(),_0(this)}#b(){if(!this.input)return;this.#A.forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.input.removeAttribute(q);else this.input.setAttribute(q,Q)})}#E(){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")}#h(q){if(!q)return"";if(!this.#K){let $=q.replace(/[^\d.-]/g,""),J=$.split(".");if(J.length>2)$=J[0]+"."+J.slice(1).join("");return $}let Q=q.replace(this.#K,"").trim();Q=Q.replace(/[^\d.-]/g,"");let Z=Q.split(".");if(Z.length>2)Q=Z[0]+"."+Z.slice(1).join("");return Q}#x(q){if(q===""||q===null||q===void 0)return"";let Q=Number(q)*(this.transform||1);if(isNaN(Q))return"";if(Q=this.#a(Q),!this.#K)return Q.toString();if(this.#L==="prefix")return this.#K+Q;else return Q+this.#K}#v(q){if(q===""||q===null||q===void 0)return"";let Q=Number(q)*(this.transform||1);return Q=this.#a(Q),Q.toString()}#g(q){this.#M=!0,setTimeout(()=>{let Q=q.target.value;if(Q&&this.#K)if(this.#L==="prefix")q.target.setSelectionRange(this.#K.length,Q.length);else{let Z=Q.indexOf(this.#K);if(Z>-1)q.target.setSelectionRange(0,Z)}},0)}#o(q){this.#M=!1;let Q=this.#h(q.target.value);if(Q!==""){let Z=Number(Q)/(this.transform||1);Z=this.#r(Z,!1),this.value=Z,q.target.value=this.#x(this.value)}else this.value="",q.target.value="";this.#F(),this.#E()}#d(q){if(this.disabled)return;if(q.key!=="ArrowUp"&&q.key!=="ArrowDown")return;q.preventDefault();let Q=this.step||1,Z=q.shiftKey?10:1,$=Q*Z*(q.key==="ArrowUp"?1:-1),J=this.#h(this.input.value),j=(J!==""?Number(J)/(this.transform||1):0)+$;j=this.#r(j,!1),this.value=j,this.input.value=this.#x(this.value),this.#F(),this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#m(q){let Q=this.#h(q.target.value);if(Q!=="")this.value=Number(Q)/(this.transform||1);else this.value="";this.#F(),this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#l(q){q.stopPropagation();let Q=this.#h(q.target.value);if(Q!==""){let Z=Number(Q)/(this.transform||1);Z=this.#r(Z,!1),this.value=Z,q.target.value=this.#x(this.value)}else this.value="",q.target.value="";this.#F(),this.#E(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#s(q){if(this.disabled)return;if(q.buttons===0){this.#c();return}let Q=(this.step||1)*q.movementX,Z=this.#h(this.input.value),$=Number(Z)/(this.transform||1)+Q;$=this.#r($,!1),this.value=$,this.input.value=this.#x(this.value),this.#F(),this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#p(q){if(this.disabled)return;if(q.altKey||q.target.closest("[slot]"))this.#M=!0,this.#D=this.style.userSelect,this.#T=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.#q),window.addEventListener("pointercancel",this.#q),window.addEventListener("blur",this.#Z)}#c(q){let Q=this.#M;if(this.#M=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#T,this.style.userSelect=this.#D,window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#q),window.removeEventListener("pointercancel",this.#q),window.removeEventListener("blur",this.#Z),Q)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#r(q,Q=!0){let Z=Number(q);if(isNaN(Z))return"";if(typeof this.min==="number")Z=Math.max(this.min,Z);if(typeof this.max==="number")Z=Math.min(this.max,Z);return Z=this.#a(Z),Z}#a(q){let Q=this.#z??2,Z=Math.pow(10,Q),$=Math.round(q*Z)/Z;return Number.isInteger($)?$:parseFloat($.toFixed(Q))}#i(q){let Q=Number(q);if(!Number.isFinite(Q))return 2;return Math.max(0,Math.min(100,Math.trunc(Q)))}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,Q,Z){if(this.input)switch(q){case"disabled":this.disabled=this.input.disabled=Z!==null&&Z!=="false",this.#F();break;case"units":this.#X=Z||"",this.#C(),this.input.value=this.#x(this.value),this.#E();break;case"units-disallow":this.#U=this.#P(Z===null?W0.#O:Z),this.#C(),this.input.value=this.#x(this.value),this.#E();break;case"unit-position":this.#L=Z||"suffix",this.input.value=this.#x(this.value),this.#E();break;case"transform":this.transform=Number(Z)||1,this.input.value=this.#x(this.value),this.#E();break;case"value":if(this.#M)break;let $=Z!==null&&Z!==""?Number(Z):"";if($!=="")$=this.#r($,!1);this.value=$,this.input.value=this.#x(this.value),this.#F(),this.#E();break;case"min":case"max":case"step":if(Z===null||Z===""){this[q]=void 0,this.#F(),this.#E();break}this[q]=Number(Z),this.#F(),this.#E();break;case"steppers":{let J=Z!==null&&Z!=="false";this.#V(J);break}case"precision":this.#z=this.#i(Z!==null?Z:2),this.input.value=this.#x(this.value),this.#E();break;case"name":if(this[q]=this.input[q]=Z||"",Z)this.input.setAttribute("name",Z);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=Z??"",this.input.placeholder=this.placeholder;break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#b();break;default:this[q]=this.input[q]=Z;break}}}M("fig-input-number",W0);class l0 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 Q=this.querySelector(":scope > img")||document.createElement("img");if(Q.src=q,Q.alt=this.name||"",!Q.isConnected)this.replaceChildren(Q);this.img=Q}getInitials(q){return q?q.split(" ").map((Q)=>Q[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(q,Q,Z){if(this[q]=Z,q==="name"){if(this.img)this.img.alt=Z||"";this.name=Z,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials)}else if(q==="src")this.src=Z,this.setSrc(this.src)}}M("fig-avatar",l0);class t0 extends HTMLElement{#Q=!1;#q=null;#Z=null;#$=null;#J=null;#j=null;#N=null;constructor(){super();this.#Z=this.#Y.bind(this),this.#$=this.focus.bind(this),this.#J=this.#G.bind(this),this.#j=this.#K.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(!this.isConnected)return;this.#W(),this.#_()})}#_(){if(this.#N||typeof MutationObserver>"u")return;this.#N=new MutationObserver(()=>{this.#W()}),this.#N.observe(this,{childList:!0})}#W(){let q=this.label,Q=this.#q;q?.removeEventListener("click",this.#Z),q?.removeEventListener("click",this.#$),q?.removeEventListener("pointerenter",this.#J),q?.removeEventListener("pointerleave",this.#j),Q?.removeEventListener("click",this.#Z),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 Z=this.input?.localName??"",$=Z==="fig-select"||Z==="fig-menu"||Z==="fig-dropdown"||Z==="fig-tooltip"||this.input instanceof HTMLDialogElement;if(this.#Q=!!(this.input&&("open"in this.input)&&!$),this.#Q&&this.label){if(!this.#q||!this.#q.isConnected)this.#q=c("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#q,this.label);this.#q.addEventListener("click",this.#Z),this.label.addEventListener("click",this.#Z)}else{if(this.#q)this.#q.removeEventListener("click",this.#Z),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.#$)}}if(this.input&&this.label&&!this.#Q)this.#X();if(this.label)this.label.removeEventListener("pointerenter",this.#J),this.label.addEventListener("pointerenter",this.#J),this.label.removeEventListener("pointerleave",this.#j),this.label.addEventListener("pointerleave",this.#j)}disconnectedCallback(){if(this.#N?.disconnect(),this.#N=null,this.label)A.hide(this.label);if(this.label&&this.#Z)this.label.removeEventListener("click",this.#Z);if(this.label&&this.#$)this.label.removeEventListener("click",this.#$);if(this.label&&this.#J)this.label.removeEventListener("pointerenter",this.#J);if(this.label&&this.#j)this.label.removeEventListener("pointerleave",this.#j);if(this.#q&&this.#Z)this.#q.removeEventListener("click",this.#Z)}#Y(q){if(q.preventDefault(),q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open}#G(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;A.show(this.label,this.label.textContent.trim())}#K(){if(this.label)A.hide(this.label)}#X(){if(!this.input||!this.label)return;let q=this.label.getAttribute("id")||h();this.label.setAttribute("id",q);let Q=this.input.querySelectorAll("input, select, textarea");if(Q.length===1){let Z=Q[0],$=Z.getAttribute("id")||h();if(Z.setAttribute("id",$),this.label.setAttribute("for",$),this.input.getAttribute("aria-labelledby")===q)this.input.removeAttribute("aria-labelledby");if(!Z.hasAttribute("aria-labelledby"))Z.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,Q,Z){switch(q){case"label":if(this.label)this.label.textContent=Z,this.#X();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()}}M("fig-field",t0);class a0 extends HTMLElement{rgba;hex;#Q=100;#q;#Z;#$;#J;#j=!1;#N=!1;#_=null;#W=this.#V.bind(this);#Y=this.#F.bind(this);#G=this.#f.bind(this);#K=this.#E.bind(this);#X=this.#S.bind(this);#U=this.#y.bind(this);#L=this.#w.bind(this);#z=this.#h.bind(this);constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(q){if(q===null||q===void 0||q===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(q))}#M(){let q={};for(let{name:Q,value:Z}of this.attributes)if(Q.startsWith("picker-")&&Q!=="picker-anchor"&&Q!=="picker-experimental")q[Q.slice(7)]=Z;if(!q["dialog-position"])q["dialog-position"]="left";return q}#B(){let q=this.#M();return Object.entries(q).map(([Q,Z])=>`${Q}="${Z}"`).join(" ")}connectedCallback(){if(this.#R()){this.#H();return}this.#A()}disconnectedCallback(){this.#D()}#R(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-swatch")}#H(){if(this.#I(this.getAttribute("value")),this.#q=this.querySelector("fig-swatch"),this.#Z=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#J=this.querySelector("fig-input-number"),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",String(this.#Q));if(this.#q)this.#q.setAttribute("background",this.hexOpaque),this.#q.setAttribute("alpha",String(this.rgba.a));this.#b(),this.#T()}#D(){if(this.#q)this.#q.removeEventListener("pointerdown",this.#W,{capture:!0}),this.#q.removeEventListener("click",this.#Y,{capture:!0}),this.#q.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#G),this.#q.removeEventListener("input",this.#K);this.#$?.removeEventListener("input",this.#X),this.#$?.removeEventListener("change",this.#U),this.#J?.removeEventListener("input",this.#L),this.#J?.removeEventListener("change",this.#U),this.#Z?.removeEventListener("input",this.#z),this.#Z?.removeEventListener("change",this.#U)}#T(){if(this.#q){this.#q.disabled=z(this,"disabled");let q=this.#q.querySelector('input[type="color"]');if(this.#$||this.hasAttribute("swatch-disabled"))q?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(q?.setAttribute("disabled",""),q)q.style.pointerEvents="none"}this.#q.addEventListener("pointerdown",this.#W,{capture:!0}),this.#q.addEventListener("click",this.#Y,{capture:!0}),q?.addEventListener("keydown",this.#G),this.#q.addEventListener("input",this.#K)}if(this.#$)this.#$.addEventListener("input",this.#X),this.#$.addEventListener("change",this.#U);if(this.#J)this.#J.addEventListener("input",this.#L),this.#J.addEventListener("change",this.#U);if(this.#Z)this.#Z.addEventListener("input",this.#z),this.#Z.addEventListener("change",this.#U)}#A(){this.#I(this.getAttribute("value"));let q=this.getAttribute("alpha")!=="false",Z=this.#o?" disabled":"",$="";if(this.getAttribute("text")!=="false"){let j=`<fig-input-text
155
155
  type="text"
156
156
  placeholder="000000"
157
- value="${this.hexOpaque.slice(1).toUpperCase()}"${$}>
158
- </fig-input-text>`;if(Q)q+=`<fig-tooltip text="Opacity">
157
+ value="${this.hexOpaque.slice(1).toUpperCase()}"${Z}>
158
+ </fig-input-text>`;if(q)j+=`<fig-tooltip text="Opacity">
159
159
  <fig-input-number
160
160
  placeholder="##"
161
161
  min="0"
162
162
  max="100"
163
163
  value="${this.#Q}"
164
- units="%"${$}>
164
+ units="%"${Z}>
165
165
  </fig-input-number>
166
- </fig-tooltip>`;let _="";_=`<fig-swatch background="${this.hexOpaque}" alpha="${this.rgba.a}"${$}></fig-swatch>`,J=`<div class="input-combo">
166
+ </fig-tooltip>`;let _="";_=`<fig-swatch background="${this.hexOpaque}" alpha="${this.rgba.a}"${Z}></fig-swatch>`,$=`<div class="input-combo">
167
167
  ${_}
168
- ${q}
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.#v(),this.#J){let q=this.rgbAlphaToHex(this.rgba,1);if(this.#J.value=q.slice(1).toUpperCase(),this.#Z)this.#Z.background=q}this.#D()}#O(){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}))}#T(){if(!i())return null;if(this.#$?.isConnected)return this.#O(),this.#$;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#F),Q.addEventListener("change",this.#W),this.appendChild(Q),this.#$=Q,this.#O(),Q}#S(){if(F(this,"disabled")||F(this,"swatch-disabled"))return!1;let Q=this.#T();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#I(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#f(Q){if(!i())return;if(F(this,"disabled")||F(this,"swatch-disabled"))return;if(this.#Y=!0,this.#q=!0,this.#_)clearTimeout(this.#_);this.#_=setTimeout(()=>{this.#q=!1,this.#Y=!1,this.#_=null},500),this.#I(Q)}#R(Q){if(!this.#q)return;if(this.#q=!1,this.#_)clearTimeout(this.#_),this.#_=null;if(this.#I(Q),this.#Y)this.#Y=!1,this.#S()}#C(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!i())return;if(!this.#S())return;this.#I(Q)}#E(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.#E("#"+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.#E(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()}#w(Q){Q.stopPropagation(),this.#c()}focus(){if(this.#J){this.#J.focus();return}this.#Z?.focus()}#b(){return this.getAttribute("aria-label")||"Color"}#v(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#d)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.#E(Q.target.value),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#x()}#m(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.#E($),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:this.#g()}))}#c(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:this.#g()}))}#g(){return{value:this.value,hex:this.hex,rgba:this.rgba,...l(this.hexOpaque,this.rgba?.a,Math.round((this.rgba?.a??1)*100))}}static get observedAttributes(){return["value","style","mode","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(Q){this.setAttribute("mode",Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":if(this.#E($),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.#O();break;case"alpha":case"text":if(this.isConnected)this.#H();break;case"disabled":this.#s();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#v();break}}get#d(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#s(){let Q=this.#d;for(let Z of[this.#Z,this.#J,this.#j]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}if(this.#v(),this.#$)this.#O()}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",t0);var s1=["srgb","srgb-linear","display-p3","oklab","oklch","hsl"],i1=["shorter","longer","increasing","decreasing"],n0=new Set(["oklch","hsl"]);function $0(Q){let Z={...Q??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase();if(!s1.includes($))$="srgb";Z.interpolationSpace=$;let J=String(Z.hueInterpolation??"shorter").toLowerCase();return Z.hueInterpolation=i1.includes(J)?J:"shorter",Z}function e0(Q){let Z=$0(Q),$={...Z,interpolationSpace:Z.interpolationSpace};if(n0.has(Z.interpolationSpace))$.hueInterpolation=Z.hueInterpolation;else delete $.hueInterpolation;return $}function Q1(Q){let Z=$0(Q);if(Z.interpolationSpace==="srgb")return"";if(n0.has(Z.interpolationSpace))return`in ${Z.interpolationSpace} ${Z.hueInterpolation} hue`;return`in ${Z.interpolationSpace}`}function o(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 a(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 Q0(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 k0(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:a(4.0767416621*_-3.3077115913*X+0.2309699292*Y),g:a(-1.2684380046*_+2.6097574011*X-0.3413193965*Y),b:a(-0.0041960863*_-0.7034186147*X+1.707614701*Y)}}function B0(Q,Z,$){return{l:Q,c:Math.sqrt(Z*Z+$*$),h:Math.atan2($,Z)*180/Math.PI}}function r1(Q,Z,$){let J=$*Math.PI/180;return{l:Q,a:Z*Math.cos(J),b:Z*Math.sin(J)}}function S0(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 o1(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=o(X.color),W=o(Y.color),O,B,L,T=$||"oklab";if(T==="srgb-linear"){let R=p(N.r),A=p(N.g),M=p(N.b),C=p(W.r),k=p(W.g),S=p(W.b);O=a(R+(C-R)*G),B=a(A+(k-A)*G),L=a(M+(S-M)*G)}else if(T==="oklch"){let R=Q0(N.r,N.g,N.b),A=Q0(W.r,W.g,W.b),M=B0(R.l,R.a,R.b),C=B0(A.l,A.a,A.b),k=M.l+(C.l-M.l)*G,S=M.c+(C.c-M.c)*G,x=S0(M.h,C.h,G,J||"shorter"),y=r1(k,S,x),m=k0(y.l,y.a,y.b);O=m.r,B=m.g,L=m.b}else if(T==="hsl"){let R=M0(N.r,N.g,N.b),A=M0(W.r,W.g,W.b),M=S0(R.h,A.h,G,J||"shorter"),C=R.s+(A.s-R.s)*G,k=R.l+(A.l-R.l)*G,S=l1(M,C,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=Q0(N.r,N.g,N.b),A=Q0(W.r,W.g,W.b),M=R.l+(A.l-R.l)*G,C=R.a+(A.a-R.a)*G,k=R.b+(A.b-R.b)*G,S=k0(M,C,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 M0(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 l1(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 Z1 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}]};#Y={url:null,scaleMode:"fill",scale:50,opacity:1};#_={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.#U(),this.#z()}disconnectedCallback(){this.#Z=null,this.#$=null,this.#J=null}#U(){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=$0({...this.#q,...Z.gradient}),this.#q.opacity=this.#N(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.#N(Z.opacity??Z.alpha,this.#q.opacity??1);break;case"image":if(Z.image)this.#Y={...this.#Y,...Z.image};break;case"video":if(Z.video)this.#_={...this.#_,...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}}}}#G(){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}=o(J.color);return`rgba(${q}, ${_}, ${X}, ${j}) ${J.position}%`}).join(", "),$=Q1(this.#q);return`linear-gradient(${this.#q.angle}deg${$?` ${$}`:""}, ${Z})`}case"image":return this.#Y.url?`url(${this.#Y.url})`:"#D9D9D9";default:return"#D9D9D9"}}#N(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,$))}#W(){switch(this.#Q){case"solid":return this.#j.alpha;case"gradient":return this.#q.opacity??1;case"image":return this.#Y.opacity??1;case"video":return this.#_.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">
168
+ ${j}
169
+ </div>`}else $=`<fig-swatch background="${this.hexOpaque}" alpha="${this.rgba.a}"${Z}></fig-swatch>`;if(this.innerHTML=$,this.#q=this.querySelector("fig-swatch"),this.#Z=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#J=this.querySelector("fig-input-number"),this.#b(),this.#$){let j=this.rgbAlphaToHex(this.rgba,1);if(this.#$.value=j.slice(1).toUpperCase(),this.#q)this.#q.background=j}this.#T()}#O(){if(!this.#Z)return;for(let[q,Q]of Object.entries(this.#M()))this.#Z.setAttribute(q,Q);if(this.#Z.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#Z.removeAttribute("alpha");else this.#Z.setAttribute("alpha","false");if(z(this,"disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");this.#Z.anchorElement=this,this.#Z.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Q}))}#P(){if(!o())return null;if(this.#Z?.isConnected)return this.#O(),this.#Z;let q=document.createElement("fig-fill-picker");return q.innerHTML="<span hidden></span>",q.addEventListener("input",this.#z),q.addEventListener("change",this.#U),this.appendChild(q),this.#Z=q,this.#O(),q}#k(){if(z(this,"disabled")||z(this,"swatch-disabled"))return!1;let q=this.#P();if(!q)return!1;return requestAnimationFrame(()=>q.open?.()),!0}#C(q){q.preventDefault(),q.stopPropagation(),q.stopImmediatePropagation?.()}#V(q){if(!o())return;if(z(this,"disabled")||z(this,"swatch-disabled"))return;if(this.#N=!0,this.#j=!0,this.#_)clearTimeout(this.#_);this.#_=setTimeout(()=>{this.#j=!1,this.#N=!1,this.#_=null},500),this.#C(q)}#F(q){if(!this.#j)return;if(this.#j=!1,this.#_)clearTimeout(this.#_),this.#_=null;if(this.#C(q),this.#N)this.#N=!1,this.#k()}#f(q){if(q.key!=="Enter"&&q.key!==" ")return;if(!o())return;if(!this.#k())return;this.#C(q)}#I(q){let Q=typeof q==="string"&&q.trim()?q.trim():"#D9D9D9",Z=this.convertToRGBA(Q);if(!Z||!Number.isFinite(Z.r)||!Number.isFinite(Z.g)||!Number.isFinite(Z.b)||!Number.isFinite(Z.a))Q="#D9D9D9",Z={r:217,g:217,b:217,a:1};this.rgba=Z,this.value=this.rgbAlphaToHex({r:isNaN(this.rgba.r)?0:this.rgba.r,g:isNaN(this.rgba.g)?0:this.rgba.g,b:isNaN(this.rgba.b)?0:this.rgba.b},this.rgba.a),this.hexWithAlpha=this.value.toUpperCase(),this.hexOpaque=this.hexWithAlpha.slice(0,7),this.#Q=Q.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#S(q){q.stopPropagation();let Q=q.target.value.replace(/#/g,"");if(this.#I("#"+Q),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",this.#Q);if(this.#q)this.#q.setAttribute("background",this.hexOpaque);this.#x()}#w(q){q.stopPropagation();let Q=Number(q.target.value)||0,$=Math.round(Q/100*255).toString(16).padStart(2,"0");if(this.#I(this.hexOpaque+$),this.#q)this.#q.setAttribute("alpha",this.rgba.a);if(this.#Z)this.#Z.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Q}));this.#x()}#y(q){q.stopPropagation(),this.#v()}focus(){if(this.#$){this.#$.focus();return}this.#q?.focus()}#u(){return this.getAttribute("aria-label")||"Color"}#b(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#o)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let q=this.getAttribute("aria-describedby"),Q=this.getAttribute("aria-invalid"),Z=this.getAttribute("aria-required"),$=this.getAttribute("aria-labelledby"),J=this.#u();if(this.#$){if(this.#$.setAttribute("aria-label",`${J} hex color`),q)this.#$.setAttribute("aria-describedby",q);else this.#$.removeAttribute("aria-describedby");if(Q)this.#$.setAttribute("aria-invalid",Q);else this.#$.removeAttribute("aria-invalid");if(Z)this.#$.setAttribute("aria-required",Z);else this.#$.removeAttribute("aria-required")}if(this.#J){if(this.#J.setAttribute("aria-label",`${J} opacity`),q)this.#J.setAttribute("aria-describedby",q);else this.#J.removeAttribute("aria-describedby");if(Q)this.#J.setAttribute("aria-invalid",Q);else this.#J.removeAttribute("aria-invalid");if(Z)this.#J.setAttribute("aria-required",Z);else this.#J.removeAttribute("aria-required")}if(!this.#$){let j=this.#q?.querySelector('input[type="color"]');if(!j)return;if($)j.setAttribute("aria-labelledby",$),j.removeAttribute("aria-label");else j.setAttribute("aria-label",J),j.removeAttribute("aria-labelledby");if(q)j.setAttribute("aria-describedby",q);else j.removeAttribute("aria-describedby")}}#E(q){if(q.stopPropagation(),this.#I(q.target.value),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#x()}#h(q){q.stopPropagation();let Q=q.detail;if(Q&&Q.color){let Z=Q.color;if(Q.alpha!==void 0){let $=Math.round(Q.alpha*255).toString(16).padStart(2,"0");Z=Q.color+$}if(this.#I(Z),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#J&&Q.alpha!==void 0)this.#J.setAttribute("value",Math.round(Q.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:this.#g()}))}#v(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:this.#g()}))}#g(){return{value:this.value,hex:this.hex,rgba:this.rgba,...l(this.hexOpaque,this.rgba?.a,Math.round((this.rgba?.a??1)*100))}}static get observedAttributes(){return["value","style","mode","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(q){this.setAttribute("mode",q)}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"value":if(this.#I(Z),this.#$)this.#$.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.#Z)this.#Z.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.#O();break;case"alpha":case"text":if(this.isConnected)this.#A();break;case"disabled":this.#d();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#b();break}}get#o(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#d(){let q=this.#o;for(let Q of[this.#q,this.#$,this.#J]){if(!Q)continue;if(q)Q.setAttribute("disabled","");else Q.removeAttribute("disabled")}if(this.#b(),this.#Z)this.#O()}rgbAlphaToHex({r:q,g:Q,b:Z},$=1){q=Math.max(0,Math.min(255,Math.round(q))),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(1,$));let J=q.toString(16).padStart(2,"0"),j=Q.toString(16).padStart(2,"0"),_=Z.toString(16).padStart(2,"0");if($===1)return`#${J}${j}${_}`.toUpperCase();let N=Math.round($*255).toString(16).padStart(2,"0");return`#${J}${j}${_}${N}`.toUpperCase()}convertToRGBA(q){if(typeof q!=="string")return null;let Q,Z,$,J=1;if(q.startsWith("#")){let j=q.slice(1);if(j.length===8)J=parseInt(j.slice(6),16)/255,j=j.slice(0,6);Q=parseInt(j.slice(0,2),16),Z=parseInt(j.slice(2,4),16),$=parseInt(j.slice(4,6),16)}else if(q.startsWith("rgba")||q.startsWith("rgb")){let j=q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(j)Q=parseInt(j[1]),Z=parseInt(j[2]),$=parseInt(j[3]),J=j[4]?parseFloat(j[4]):1}else if(q.startsWith("hsla")||q.startsWith("hsl")){let j=q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(j){let _=parseInt(j[1])/360,W=parseInt(j[2])/100,N=parseInt(j[3])/100;if(J=j[4]?parseFloat(j[4]):1,W===0)Q=Z=$=N;else{let K=(X,O,R)=>{if(R<0)R+=1;if(R>1)R-=1;if(R<0.16666666666666666)return X+(O-X)*6*R;if(R<0.5)return O;if(R<0.6666666666666666)return X+(O-X)*(0.6666666666666666-R)*6;return X},G=N<0.5?N*(1+W):N+W-N*W,U=2*N-G;Q=K(U,G,_+0.3333333333333333),Z=K(U,G,_),$=K(U,G,_-0.3333333333333333)}Q=Math.round(Q*255),Z=Math.round(Z*255),$=Math.round($*255)}}else return null;return{r:Q,g:Z,b:$,a:J}}}M("fig-input-color",a0);var rq=["srgb","srgb-linear","display-p3","oklab","oklch","hsl"],iq=["shorter","longer","increasing","decreasing"],n0=new Set(["oklch","hsl"]);function Z0(q){let Q={...q??{}},Z=String(Q.interpolationSpace??"srgb").toLowerCase();if(!rq.includes(Z))Z="srgb";Q.interpolationSpace=Z;let $=String(Q.hueInterpolation??"shorter").toLowerCase();return Q.hueInterpolation=iq.includes($)?$:"shorter",Q}function e0(q){let Q=Z0(q),Z={...Q,interpolationSpace:Q.interpolationSpace};if(n0.has(Q.interpolationSpace))Z.hueInterpolation=Q.hueInterpolation;else delete Z.hueInterpolation;return Z}function qq(q){let Q=Z0(q);if(Q.interpolationSpace==="srgb")return"";if(n0.has(Q.interpolationSpace))return`in ${Q.interpolationSpace} ${Q.hueInterpolation} hue`;return`in ${Q.interpolationSpace}`}function i(q){let Q=q.replace(/^#/,"");return{r:parseInt(Q.substring(0,2),16),g:parseInt(Q.substring(2,4),16),b:parseInt(Q.substring(4,6),16)}}function p(q){let Q=q/255;return Q<=0.04045?Q/12.92:Math.pow((Q+0.055)/1.055,2.4)}function t(q){let Q=q<=0.0031308?12.92*q:1.055*Math.pow(q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Q))*255)}function q0(q,Q,Z){let $=p(q),J=p(Q),j=p(Z),_=Math.cbrt(0.4122214708*$+0.5363325363*J+0.0514459929*j),W=Math.cbrt(0.2119034982*$+0.6806995451*J+0.1073969566*j),N=Math.cbrt(0.0883024619*$+0.2817188376*J+0.6299787005*j);return{l:0.2104542553*_+0.793617785*W-0.0040720468*N,a:1.9779984951*_-2.428592205*W+0.4505937099*N,b:0.0259040371*_+0.7827717662*W-0.808675766*N}}function I0(q,Q,Z){let $=q+0.3963377774*Q+0.2158037573*Z,J=q-0.1055613458*Q-0.0638541728*Z,j=q-0.0894841775*Q-1.291485548*Z,_=$*$*$,W=J*J*J,N=j*j*j;return{r:t(4.0767416621*_-3.3077115913*W+0.2309699292*N),g:t(-1.2684380046*_+2.6097574011*W-0.3413193965*N),b:t(-0.0041960863*_-0.7034186147*W+1.707614701*N)}}function R0(q,Q,Z){return{l:q,c:Math.sqrt(Q*Q+Z*Z),h:Math.atan2(Z,Q)*180/Math.PI}}function lq(q,Q,Z){let $=Z*Math.PI/180;return{l:q,a:Q*Math.cos($),b:Q*Math.sin($)}}function S0(q,Q,Z,$){let J=(q%360+360)%360,_=(Q%360+360)%360-J;switch($){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+_*Z)%360+360)%360}function tq(q,Q,Z,$){let J=[...q].sort((F,H)=>F.position-H.position),j=Q*100;if(J.length===0)return"#888888";if(j<=J[0].position)return J[0].color;if(j>=J[J.length-1].position)return J[J.length-1].color;let _=0;while(_<J.length-1&&J[_+1].position<j)_++;let W=J[_],N=J[_+1],K=N.position-W.position,G=K>0?(j-W.position)/K:0,U=i(W.color),X=i(N.color),O,R,L,D=Z||"oklab";if(D==="srgb-linear"){let F=p(U.r),H=p(U.g),B=p(U.b),f=p(X.r),I=p(X.g),S=p(X.b);O=t(F+(f-F)*G),R=t(H+(I-H)*G),L=t(B+(S-B)*G)}else if(D==="oklch"){let F=q0(U.r,U.g,U.b),H=q0(X.r,X.g,X.b),B=R0(F.l,F.a,F.b),f=R0(H.l,H.a,H.b),I=B.l+(f.l-B.l)*G,S=B.c+(f.c-B.c)*G,x=S0(B.h,f.h,G,$||"shorter"),w=lq(I,S,x),g=I0(w.l,w.a,w.b);O=g.r,R=g.g,L=g.b}else if(D==="hsl"){let F=B0(U.r,U.g,U.b),H=B0(X.r,X.g,X.b),B=S0(F.h,H.h,G,$||"shorter"),f=F.s+(H.s-F.s)*G,I=F.l+(H.l-F.l)*G,S=aq(B,f,I);O=S[0],R=S[1],L=S[2]}else if(D==="srgb")O=Math.round(U.r+(X.r-U.r)*G),R=Math.round(U.g+(X.g-U.g)*G),L=Math.round(U.b+(X.b-U.b)*G);else{let F=q0(U.r,U.g,U.b),H=q0(X.r,X.g,X.b),B=F.l+(H.l-F.l)*G,f=F.a+(H.a-F.a)*G,I=F.b+(H.b-F.b)*G,S=I0(B,f,I);O=S.r,R=S.g,L=S.b}return`#${O.toString(16).padStart(2,"0")}${R.toString(16).padStart(2,"0")}${L.toString(16).padStart(2,"0")}`.toUpperCase()}function B0(q,Q,Z){let $=q/255,J=Q/255,j=Z/255,_=Math.max($,J,j),W=Math.min($,J,j),N=(_+W)/2;if(_===W)return{h:0,s:0,l:N*100};let K=_-W,G=N>0.5?K/(2-_-W):K/(_+W),U;switch(_){case $:U=((J-j)/K+(J<j?6:0))/6;break;case J:U=((j-$)/K+2)/6;break;default:U=(($-J)/K+4)/6;break}return{h:U*360,s:G*100,l:N*100}}function aq(q,Q,Z){Q/=100,Z/=100;let $=(1-Math.abs(2*Z-1))*Q,J=$*(1-Math.abs(q/60%2-1)),j=Z-$/2,_,W,N;if(q<60)_=$,W=J,N=0;else if(q<120)_=J,W=$,N=0;else if(q<180)_=0,W=$,N=J;else if(q<240)_=0,W=J,N=$;else if(q<300)_=J,W=0,N=$;else _=$,W=0,N=J;return[Math.round((_+j)*255),Math.round((W+j)*255),Math.round((N+j)*255)]}class Qq extends HTMLElement{#Q="solid";#q;#Z;#$;#J={color:"#D9D9D9",alpha:1};#j={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",opacity:1,stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#N={url:null,scaleMode:"fill",scale:50,opacity:1};#_={url:null,scaleMode:"fill",opacity:1};#W={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.#Y(),this.#M()}disconnectedCallback(){this.#q=null,this.#Z=null,this.#$=null}#Y(){let q=this.getAttribute("value");if(!q)return;try{let Q=JSON.parse(q);if(Q.type)this.#Q=Q.type;switch(this.#Q){case"solid":if(Q.color)this.#J.color=Q.color;if(Q.alpha!==void 0)this.#J.alpha=Q.alpha;if(Q.opacity!==void 0)this.#J.alpha=Q.opacity/100;break;case"gradient":if(Q.gradient)this.#j=Z0({...this.#j,...Q.gradient}),this.#j.opacity=this.#X(Q.gradient.opacity??Q.opacity??Q.alpha,this.#j.opacity??1);else if(Q.opacity!==void 0||Q.alpha!==void 0)this.#j.opacity=this.#X(Q.opacity??Q.alpha,this.#j.opacity??1);break;case"image":if(Q.image)this.#N={...this.#N,...Q.image};break;case"video":if(Q.video)this.#_={...this.#_,...Q.video};break;case"webcam":if(Q.webcam)this.#W={...this.#W,...Q.webcam};if(Q.opacity!==void 0)this.#W.opacity=Q.opacity;break}}catch(Q){if(q.startsWith("#")){if(this.#Q="solid",this.#J.color=q.slice(0,7),q.length>7){let Z=q.slice(7,9);this.#J.alpha=parseInt(Z,16)/255}}}}#G(){let q={},Q=this.getAttribute("mode");if(Q)q.mode=Q;let Z=this.getAttribute("alpha");if(Z)q.alpha=Z;for(let{name:$,value:J}of this.attributes)if($.startsWith("picker-")&&$!=="picker-anchor"&&$!=="picker-experimental")q[$.slice(7)]=J;if(!q["dialog-position"])q["dialog-position"]="left";return Object.entries(q).map(([$,J])=>`${$}="${b(J)}"`).join(" ")}#K(){switch(this.#Q){case"solid":return this.#J.color;case"gradient":{let Q=[...this.#j.stops].sort(($,J)=>$.position-J.position).map(($)=>{let J=($.opacity??100)/100;if(J>=1)return`${$.color} ${$.position}%`;let{r:j,g:_,b:W}=i($.color);return`rgba(${j}, ${_}, ${W}, ${J}) ${$.position}%`}).join(", "),Z=qq(this.#j);return`linear-gradient(${this.#j.angle}deg${Z?` ${Z}`:""}, ${Q})`}case"image":return this.#N.url?`url(${this.#N.url})`:"#D9D9D9";default:return"#D9D9D9"}}#X(q,Q=1){if(q===void 0||q===null||q==="")return Q;let Z=Number(q);if(!Number.isFinite(Z))return Q;if(Z>1)return Math.max(0,Math.min(1,Z/100));return Math.max(0,Math.min(1,Z))}#U(){switch(this.#Q){case"solid":return this.#J.alpha;case"gradient":return this.#j.opacity??1;case"image":return this.#N.opacity??1;case"video":return this.#_.opacity??1;case"webcam":return this.#W.opacity??1;default:return 1}}#L(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.setAttribute("aria-disabled",q?"true":"false");for(let Q of[this.#q,this.#Z,this.#$]){if(!Q)continue;if(q)Q.setAttribute("disabled","");else Q.removeAttribute("disabled")}}#z(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#L();let q=this.getAttribute("aria-label")||"Fill",Q=this.getAttribute("aria-describedby"),Z=this.getAttribute("aria-invalid"),$=this.getAttribute("aria-required"),J=(j,_)=>{if(!j)return;if(j.setAttribute("aria-label",_),Q)j.setAttribute("aria-describedby",Q);else j.removeAttribute("aria-describedby");if(Z)j.setAttribute("aria-invalid",Z);else j.removeAttribute("aria-invalid");if($)j.setAttribute("aria-required",$);else j.removeAttribute("aria-required")};J(this.#q,`${q} picker`),J(this.#$,`${q} hex color`),J(this.#Z,`${q} opacity`)}#M(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Q=JSON.stringify(this.value),Z=this.getAttribute("alpha")!=="false",$=(_)=>Z?`<fig-tooltip text="Opacity">
170
170
  <fig-input-number
171
171
  class="fig-input-fill-opacity"
172
172
  placeholder="##"
@@ -174,75 +174,75 @@ var w1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var v1={};var P0=w1(()=>{/*! Vendored from @
174
174
  max="100"
175
175
  value="${_}"
176
176
  units="%"
177
- ${Q?"disabled":""}>
177
+ ${q?"disabled":""}>
178
178
  </fig-input-number>
179
- </fig-tooltip>`:"",j="";switch(this.#Q){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"
183
183
  placeholder="000000"
184
- value="${v(this.#j.color.slice(1).toUpperCase())}"
185
- ${Q?"disabled":""}>
184
+ value="${b(this.#J.color.slice(1).toUpperCase())}"
185
+ ${q?"disabled":""}>
186
186
  </fig-input-text>
187
- ${J(Math.round(this.#j.alpha*100))}`;break;case"gradient":{let _=this.#q.type.charAt(0).toUpperCase()+this.#q.type.slice(1);j=`
188
- <label class="fig-input-fill-label">${v(_)}</label>
189
- ${J(Math.round((this.#q.opacity??1)*100))}`;break}case"image":j=`
187
+ ${$(Math.round(this.#J.alpha*100))}`;break;case"gradient":{let _=this.#j.type.charAt(0).toUpperCase()+this.#j.type.slice(1);J=`
188
+ <label class="fig-input-fill-label">${b(_)}</label>
189
+ ${$(Math.round((this.#j.opacity??1)*100))}`;break}case"image":J=`
190
190
  <label class="fig-input-fill-label">Image</label>
191
- ${J(Math.round((this.#Y.opacity??1)*100))}`;break;case"video":j=`
191
+ ${$(Math.round((this.#N.opacity??1)*100))}`;break;case"video":J=`
192
192
  <label class="fig-input-fill-label">Video</label>
193
- ${J(Math.round((this.#_.opacity??1)*100))}`;break;case"webcam":j=`
193
+ ${$(Math.round((this.#_.opacity??1)*100))}`;break;case"webcam":J=`
194
194
  <label class="fig-input-fill-label">Webcam</label>
195
- ${J(Math.round((this.#X.opacity??1)*100))}`;break}let q=this.#G();this.innerHTML=`
195
+ ${$(Math.round((this.#W.opacity??1)*100))}`;break}let j=this.#G();this.innerHTML=`
196
196
  <div class="input-combo">
197
- <fig-fill-picker ${q} value='${v(Z)}' ${Q?"disabled":""}>
198
- <fig-swatch background="${v(this.#K())}" alpha="${this.#W()}"${Q?" disabled":""}></fig-swatch>
197
+ <fig-fill-picker ${j} value='${b(Q)}' ${q?"disabled":""}>
198
+ <fig-swatch background="${b(this.#K())}" alpha="${this.#U()}"${q?" disabled":""}></fig-swatch>
199
199
  </fig-fill-picker>
200
- ${j}
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=$0({...this.#q,...J.gradient});break;case"image":if(J.image)this.#Y=J.image;break;case"video":if(J.video)this.#_=J.video;break}if(q)this.#A();else this.#M();this.#H()}),this.#Z.addEventListener("change",($)=>{$.stopPropagation(),this.#O()})}if(this.#J)this.#J.addEventListener("input",(Z)=>{Z.stopPropagation();let $="#"+Z.target.value.replace("#","");this.#j.color=$,this.#P(),this.#H()}),this.#J.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#O()});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.#Y.opacity=j;break;case"video":this.#_.opacity=j;break;case"webcam":this.#X.opacity=j;break}this.#P(),this.#D(j),this.#H()}),this.#$.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#O()})}#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.#Y.opacity??1)*100));break;case"video":if(this.#$)this.#$.setAttribute("value",Math.round((this.#_.opacity??1)*100));break;case"webcam":if(this.#$)this.#$.setAttribute("value",Math.round((this.#X.opacity??1)*100));break}}#A(){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=`
200
+ ${J}
201
+ </div>`,this.#B()}#B(){this.#q=this.querySelector("fig-fill-picker"),this.#Z=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let q=this.querySelector(".fig-input-fill-label");if(this.#z(),q&&this.#q)q.addEventListener("click",()=>{let Q=this.#q.querySelector("fig-swatch");if(Q)Q.click()});if(this.#q){let Q=this.getAttribute("picker-anchor");if(!Q||Q==="self")this.#q.anchorElement=this;else{let Z=null;try{Z=document.querySelector(Q)}catch{}if(Z)this.#q.anchorElement=Z}this.#q.addEventListener("input",(Z)=>{Z.stopPropagation();let $=Z.detail;if(!$)return;let J=$.type,j=J!==this.#Q;switch(this.#Q=J,J){case"solid":this.#J.color=$.color,this.#J.alpha=$.alpha;break;case"gradient":if($.gradient)this.#j=Z0({...this.#j,...$.gradient});break;case"image":if($.image)this.#N=$.image;break;case"video":if($.video)this.#_=$.video;break}if(j)this.#H();else this.#R();this.#A()}),this.#q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#O()})}if(this.#$)this.#$.addEventListener("input",(Q)=>{Q.stopPropagation();let Z="#"+Q.target.value.replace("#","");this.#J.color=Z,this.#D(),this.#A()}),this.#$.addEventListener("change",(Q)=>{Q.stopPropagation(),this.#O()});if(this.#Z)this.#Z.addEventListener("input",(Q)=>{Q.stopPropagation();let Z=parseFloat(Q.target.value),J=(isNaN(Z)?100:Z)/100;switch(this.#Q){case"solid":this.#J.alpha=J;break;case"gradient":this.#j.opacity=J;break;case"image":this.#N.opacity=J;break;case"video":this.#_.opacity=J;break;case"webcam":this.#W.opacity=J;break}this.#D(),this.#T(J),this.#A()}),this.#Z.addEventListener("change",(Q)=>{Q.stopPropagation(),this.#O()})}#R(){switch(this.#Q){case"solid":if(this.#$)this.#$.setAttribute("value",this.#J.color.slice(1).toUpperCase());if(this.#Z)this.#Z.setAttribute("value",Math.round(this.#J.alpha*100));break;case"gradient":{let q=this.querySelector(".fig-input-fill-label");if(q){let Q=this.#j.type.charAt(0).toUpperCase()+this.#j.type.slice(1);q.textContent=Q}if(this.#Z)this.#Z.setAttribute("value",Math.round((this.#j.opacity??1)*100));break}case"image":if(this.#Z)this.#Z.setAttribute("value",Math.round((this.#N.opacity??1)*100));break;case"video":if(this.#Z)this.#Z.setAttribute("value",Math.round((this.#_.opacity??1)*100));break;case"webcam":if(this.#Z)this.#Z.setAttribute("value",Math.round((this.#W.opacity??1)*100));break}}#H(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Q=this.getAttribute("alpha")!=="false",Z=this.querySelector(".input-combo");if(!Z)return;let $=Z.querySelector(".fig-input-fill-label"),J=Z.querySelector(".fig-input-fill-hex"),j=Z.querySelector(".fig-input-fill-opacity"),_=Z.querySelectorAll("fig-tooltip");$?.remove(),J?.remove(),_.forEach((K)=>K.remove());let W="";switch(this.#Q){case"solid":W=`
202
202
  <fig-input-text
203
203
  type="text"
204
204
  class="fig-input-fill-hex"
205
205
  placeholder="000000"
206
- value="${v(this.#j.color.slice(1).toUpperCase())}"
207
- ${Q?"disabled":""}>
206
+ value="${b(this.#J.color.slice(1).toUpperCase())}"
207
+ ${q?"disabled":""}>
208
208
  </fig-input-text>
209
- ${Z?`<fig-tooltip text="Opacity">
209
+ ${Q?`<fig-tooltip text="Opacity">
210
210
  <fig-input-number
211
211
  class="fig-input-fill-opacity"
212
212
  placeholder="##"
213
213
  min="0"
214
214
  max="100"
215
- value="${Math.round(this.#j.alpha*100)}"
215
+ value="${Math.round(this.#J.alpha*100)}"
216
216
  units="%"
217
- ${Q?"disabled":""}>
217
+ ${q?"disabled":""}>
218
218
  </fig-input-number>
219
- </fig-tooltip>`:""}`;break;case"gradient":{let K=this.#q.type.charAt(0).toUpperCase()+this.#q.type.slice(1);X=`
220
- <label class="fig-input-fill-label">${v(K)}</label>
221
- ${Z?`<fig-tooltip text="Opacity">
219
+ </fig-tooltip>`:""}`;break;case"gradient":{let K=this.#j.type.charAt(0).toUpperCase()+this.#j.type.slice(1);W=`
220
+ <label class="fig-input-fill-label">${b(K)}</label>
221
+ ${Q?`<fig-tooltip text="Opacity">
222
222
  <fig-input-number
223
223
  class="fig-input-fill-opacity"
224
224
  placeholder="##"
225
225
  min="0"
226
226
  max="100"
227
- value="${Math.round((this.#q.opacity??1)*100)}"
227
+ value="${Math.round((this.#j.opacity??1)*100)}"
228
228
  units="%"
229
- ${Q?"disabled":""}>
229
+ ${q?"disabled":""}>
230
230
  </fig-input-number>
231
- </fig-tooltip>`:""}`;break}case"image":X=`
231
+ </fig-tooltip>`:""}`;break}case"image":W=`
232
232
  <label class="fig-input-fill-label">Image</label>
233
- ${Z?`<fig-tooltip text="Opacity">
233
+ ${Q?`<fig-tooltip text="Opacity">
234
234
  <fig-input-number
235
235
  class="fig-input-fill-opacity"
236
236
  placeholder="##"
237
237
  min="0"
238
238
  max="100"
239
- value="${Math.round((this.#Y.opacity??1)*100)}"
239
+ value="${Math.round((this.#N.opacity??1)*100)}"
240
240
  units="%"
241
- ${Q?"disabled":""}>
241
+ ${q?"disabled":""}>
242
242
  </fig-input-number>
243
- </fig-tooltip>`:""}`;break;case"video":X=`
243
+ </fig-tooltip>`:""}`;break;case"video":W=`
244
244
  <label class="fig-input-fill-label">Video</label>
245
- ${Z?`<fig-tooltip text="Opacity">
245
+ ${Q?`<fig-tooltip text="Opacity">
246
246
  <fig-input-number
247
247
  class="fig-input-fill-opacity"
248
248
  placeholder="##"
@@ -250,40 +250,40 @@ var w1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var v1={};var P0=w1(()=>{/*! Vendored from @
250
250
  max="100"
251
251
  value="${Math.round((this.#_.opacity??1)*100)}"
252
252
  units="%"
253
- ${Q?"disabled":""}>
253
+ ${q?"disabled":""}>
254
254
  </fig-input-number>
255
- </fig-tooltip>`:""}`;break;case"webcam":X=`
255
+ </fig-tooltip>`:""}`;break;case"webcam":W=`
256
256
  <label class="fig-input-fill-label">Webcam</label>
257
- ${Z?`<fig-tooltip text="Opacity">
257
+ ${Q?`<fig-tooltip text="Opacity">
258
258
  <fig-input-number
259
259
  class="fig-input-fill-opacity"
260
260
  placeholder="##"
261
261
  min="0"
262
262
  max="100"
263
- value="${Math.round((this.#X.opacity??1)*100)}"
263
+ value="${Math.round((this.#W.opacity??1)*100)}"
264
264
  units="%"
265
- ${Q?"disabled":""}>
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.#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.#P(),this.#H()}),this.#J.addEventListener("change",(K)=>{K.stopPropagation(),this.#O()});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.#Y.opacity=W;break;case"video":this.#_.opacity=W;break;case"webcam":this.#X.opacity=W;break}this.#P(),this.#D(W),this.#H()}),this.#$.addEventListener("change",(K)=>{K.stopPropagation(),this.#O()})}#P(){if(this.#Z)this.#Z.setAttribute("value",JSON.stringify(this.value))}#D(Q){if(this.#Z){let Z=this.#Z.querySelector("fig-swatch");if(Z)Z.setAttribute("alpha",Q)}}#H(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#O(){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:e0(this.#q)};case"image":return{type:"image",image:{...this.#Y}};case"video":return{type:"video",video:{...this.#_}};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.#U(),this.#Z)if(this.#Q!==J)this.#z();else this.#P(),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",Z1);class $1 extends HTMLElement{#Q=[];#Z=[];#$=[];#J=null;#j=this.#U.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#Y(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#_(){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.#G(),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.#$=[]}#U(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.#G(),this.#M();break;case"disabled":this.#A();break;case"min":case"max":case"fixed":this.#K();break;case"open":this.#P();break}}#G(){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.#N(q,_,Q,{inline:!0}))}),Z.appendChild(J),this.appendChild(Z),this.#P(),!this.#Y)this.#F(Q,this);let j=document.createElement("div");j.className="palette-colors-expanded",this.#Q.forEach((q,_)=>{if(j.appendChild(this.#N(q,_,Q)),!this.#Y)j.appendChild(this.#W(_,Q))}),this.appendChild(j)}#N(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.#H()}),q.addEventListener("change",(Y)=>{X(Y),this.#O()}),J)this.#Z.push(q);else this.#$.push(q);return q}#W(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.#_)$.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.#Y)return;if(Q<0||Q>=this.#Q.length)return;if(this.#Q.length<=this.#_)return;this.#Q.splice(Q,1),this.#Z=[],this.#$=[],this.#K(),this.#O()}#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.#Y)return;this.#Q.push(Q);let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#Q.length-1,J=this.#N(Q,$,Z,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(J);let q=this.#N(Q,$,Z),_=this.querySelector(".palette-colors-expanded");if(_)_.appendChild(q),_.appendChild(this.#W($,Z));if(this.#Q.length>=this.#X){let X=this.querySelector(".palette-add-btn");if(X)X.setAttribute("disabled","")}this.#D(Z),this.#O()}#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)})}#A(){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.#D(Q),this.#P()}#P(){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()}#D(Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let Z=Q||this.#Q.length<=this.#_;this.querySelectorAll(".palette-remove-btn").forEach(($)=>{if(Z)$.setAttribute("disabled","");else $.removeAttribute("disabled")})}#H(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#O(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}z("fig-input-palette",$1);class Z0 extends HTMLElement{static SHIFT_SNAP=5;#Q;#Z;#$=!1;#J=null;#j=null;#q=null;#Y=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#X(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#U(){return this.#X==="true"}get#G(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#K(){if(!this.#Z)return null;return this.#Z.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#N(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#U?"-1":"0")}#W(Q){let Z=$0(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.#B(),this.#S(),this.#L(),this.removeEventListener("keydown",this.#z),this.addEventListener("keydown",this.#z),this.#U)document.addEventListener("keydown",this.#F)}#L(){if(this.#X!=="picker"||i())return;this.#Y??=customElements.whenDefined("fig-fill-picker").then(()=>{if(!this.isConnected||this.#X!=="picker")return;this.#S()})}disconnectedCallback(){if(document.removeEventListener("keydown",this.#F),this.removeEventListener("keydown",this.#z),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.#w),this.removeEventListener("pointerleave",this.#y),this.removeEventListener("click",this.#V),this.removeEventListener("dblclick",this.#v)}#F=(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?Z0.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.#i(),this.#p();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.#c(),this.#h(),this.#i(),this.#p()};#z=(Q)=>{if(this.#X!=="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()};#B(){let Q=this.getAttribute("value");if(!Q)return;try{let Z=JSON.parse(Q);if(Z?.type==="gradient"&&Z.gradient){this.#_=this.#W({...this.#_,...Z.gradient});return}if(Z?.gradient)this.#_=this.#W({...this.#_,...Z.gradient})}catch(Z){}}#M(){let Q=this.#W(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}=o(q.color);return`rgba(${X}, ${Y}, ${K}, ${_}) ${q.position}%`}).join(", "),J=Q1(Q),j=J?` ${J}`:"";if(this.#X==="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}, ${$})`}#A(Q){let Z=(Q.opacity??100)/100;if(Z>=1)return Q.color;let{r:$,g:J,b:j}=o(Q.color);return`rgba(${$}, ${J}, ${j}, ${Z})`}#P(){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")}#H(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.#G==="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.#A($)}" value="${$.position}% 50%" hit-area="4" data-stop-index="${J}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#O=null;#T=!1;#S(){this.#j?.disconnect(),this.#j=null;let Q=F(this,"disabled"),Z=this.#X;if(Z==="picker"&&i()){let $=JSON.stringify(this.value);this.innerHTML=`
268
- <fig-fill-picker mode="gradient" value='${$}'${Q?" disabled":""}>
269
- <fig-swatch background="${this.#M()}"${this.#P()}${Q?" disabled":""}></fig-swatch>
270
- </fig-fill-picker>`,this.#Q=this.querySelector("fig-swatch"),this.#Z=null,this.#I(),this.#N();return}if(this.innerHTML=`
271
- <fig-swatch background="${this.#M()}"${this.#P()}${Q?" disabled":""}></fig-swatch>
272
- ${Z==="true"||Z==="picker"?`<div class="fig-input-gradient-track">${this.#H()}</div>`:""}`,this.#Q=this.querySelector("fig-swatch"),this.#Z=this.querySelector(".fig-input-gradient-track"),Z==="true"||Z==="picker")this.#R(),this.#t();this.#N()}#I(){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.#W({...this.#_,...J.gradient}),this.#h()};Q.addEventListener("input",($)=>{Z($),this.#i()}),Q.addEventListener("change",($)=>{Z($),this.#p()})}#f(Q){return o1(this.#_.stops,Q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#R(){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.#G==="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.#O=Q,this.addEventListener("pointerenter",this.#k),this.addEventListener("pointermove",this.#w),this.addEventListener("pointerleave",this.#y),this.addEventListener("click",this.#V),this.addEventListener("dblclick",this.#v)}#C(){if(!this.#O)return;this.#O.style.opacity="1"}#E(){if(!this.#O)return;this.#O.style.opacity="0"}#k=()=>{if(this.#$)return;this.#C()};#y=()=>{this.#E()};#w=(Q)=>{if(this.#$){this.#E();return}if(!this.#O||!this.#Z)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#E();return}let Z=this.#Z.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width));this.#O.style.left=`${$*100}%`;let J=this.#f($);this.#O.setAttribute("color",J),this.#C()};#b(){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.#c(),this.#h(),this.#i(),this.#p()}#v=(Q)=>{if(!this.#Z)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#b(),this.#Z.querySelectorAll("fig-handle[selected]").forEach((Z)=>{Z.removeAttribute("selected")})};#V=(Q)=>{if(!this.#Z)return;if(this.#$)return;if(this.#T){this.#T=!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.#b(),!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.#f($);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.#c(),this.#h(),this.#i(),this.#p(),requestAnimationFrame(()=>{let X=this.#Z.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)X.click()})};#m(){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.#m()}#x(){if(this.#q!==null)return;this.#q=requestAnimationFrame(()=>this.#m())}#c(){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.#O;if(this.#Z.innerHTML=this.#H(),$)this.#Z.appendChild($);this.#g(),this.#d(),this.#x();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.#A(j)),this.#G==="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.#g()}#g(){if(!this.#Z)return;let Q=this.#G==="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.#O)if(Q)this.#O.setAttribute("tip","add");else this.#O.removeAttribute("tip")}#d(){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"]})})}#s(){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.#M()),this.#D()}#t(){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.#f($);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.#T=!0,this.#c(),this.#h(),this.#i(),this.#E();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;else if(Q.detail.alpha!==void 0)this.#_.stops[Y].opacity=Math.round(Q.detail.alpha*100);Z.setAttribute("color",this.#A(this.#_.stops[Y])),this.#h(),this.#i()}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/Z0.SHIFT_SNAP)*Z0.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.#i()}),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.#A(this.#_.stops[Y])),this.#h(),this.#p()}return}Z.style.zIndex="";let $=Z.closest("fig-tooltip");if($)$.removeAttribute("show");Z.showColorTip();let J=parseInt(Z.dataset.stopIndex,10);if(isNaN(J)||!this.#_.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.#s(),this.#h(),this.#p(),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.#i()}}),this.#Z.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#i(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#p(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:e0(this.#W(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.#U){let Z=this.#K();if(Z){Z.focus(Q);return}}HTMLElement.prototype.focus.call(this,Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":this.#B(),this.#h(),this.#c();break;case"disabled":this.#u();break;case"edit":if(this.#S(),this.#L(),this.#U)document.addEventListener("keydown",this.#F);else document.removeEventListener("keydown",this.#F);break;case"mode":this.#g();break;case"size":this.#D();break}}#u(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#N(),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",Z0);class K0 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(){}#Y(Q){return this.hasAttribute(Q)&&this.getAttribute(Q)!=="false"}#_(){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.#Y("checked"),Z=this.#Y("indeterminate")&&!Q,$=this.#Y("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.#_()}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.#Y("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.#_(),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.#_(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}z("fig-checkbox",K0);class J1 extends K0{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",J1);class j1 extends K0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}z("fig-switch",j1);class q1 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;#Y=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#_=this.#F.bind(this);#X=this.#z.bind(this);#U=this.#B.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}#G(){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.#O()}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.#G())this.#K(),this.#W();else this.#N(),this.#W();this.#T(F(this,"disabled"))}disconnectedCallback(){this.#L()}#N(){let Q=this.#P(),Z=this.getAttribute("placeholder")||"",$=this.value,J=this.#H(),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
- <fig-input-text placeholder="${v(Z)}" value="${v($)}"></fig-input-text>
267
+ </fig-tooltip>`:""}`;break}Z.insertAdjacentHTML("beforeend",W),this.#Z=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let N=this.querySelector(".fig-input-fill-label");if(this.#z(),N&&this.#q)N.addEventListener("click",()=>{let K=this.#q.querySelector("fig-swatch");if(K)K.click()});if(this.#$)this.#$.addEventListener("input",(K)=>{K.stopPropagation();let G="#"+K.target.value.replace("#","");this.#J.color=G,this.#D(),this.#A()}),this.#$.addEventListener("change",(K)=>{K.stopPropagation(),this.#O()});if(this.#Z)this.#Z.addEventListener("input",(K)=>{K.stopPropagation();let G=parseFloat(K.target.value),X=(isNaN(G)?100:G)/100;switch(this.#Q){case"solid":this.#J.alpha=X;break;case"gradient":this.#j.opacity=X;break;case"image":this.#N.opacity=X;break;case"video":this.#_.opacity=X;break;case"webcam":this.#W.opacity=X;break}this.#D(),this.#T(X),this.#A()}),this.#Z.addEventListener("change",(K)=>{K.stopPropagation(),this.#O()})}#D(){if(this.#q)this.#q.setAttribute("value",JSON.stringify(this.value))}#T(q){if(this.#q){let Q=this.#q.querySelector("fig-swatch");if(Q)Q.setAttribute("alpha",q)}}#A(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#O(){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:e0(this.#j)};case"image":return{type:"image",image:{...this.#N}};case"video":return{type:"video",video:{...this.#_}};case"webcam":return{type:"webcam",webcam:{...this.#W}};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,Q,Z){if(Q===Z)return;switch(q){case"value":let $=this.#Q;if(this.#Y(),this.#q)if(this.#Q!==$)this.#M();else this.#D(),this.#R();break;case"disabled":this.#L();break;case"mode":if(this.#q)if(Z)this.#q.setAttribute(q,Z);else this.#q.removeAttribute(q);break;case"alpha":if(this.isConnected)this.#M();break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#z();break}}}M("fig-input-fill",Qq);class Zq extends HTMLElement{#Q=[];#q=[];#Z=[];#$=null;#J=this.#Y.bind(this);#j=()=>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 Q=this.open;if(q)this.setAttribute("open","");else this.removeAttribute("open");if(Q!==!!q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!q},bubbles:!0}))}get#N(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#_(){let q=parseInt(this.getAttribute("min"));return isNaN(q)?2:q}get#W(){let q=parseInt(this.getAttribute("max"));return isNaN(q)?8:q}connectedCallback(){if(this.setAttribute("tabindex","-1"),this.removeEventListener("focus",this.#j),this.addEventListener("focus",this.#j),this.removeEventListener("keydown",this.#J),this.addEventListener("keydown",this.#J),this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{if(this.#$=null,!this.isConnected)return;this.#G(),this.#K()})}disconnectedCallback(){if(this.#$)cancelAnimationFrame(this.#$),this.#$=null;this.removeEventListener("keydown",this.#J),this.removeEventListener("focus",this.#j),this.#q=[],this.#Z=[]}#Y(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,Q,Z){if(Q===Z)return;switch(q){case"value":this.#G(),this.#R();break;case"disabled":this.#H();break;case"min":case"max":case"fixed":this.#K();break;case"open":this.#D();break}}#G(){let q=this.getAttribute("value");if(!q){this.#Q=[];return}let Q=q.trim();try{let Z=JSON.parse(Q);if(Array.isArray(Z)){this.#Q=Z.map(($)=>{if(typeof $==="string")return{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1};if($&&typeof $==="object")return{color:$.color||"#D9D9D9",alpha:$.alpha!==void 0?$.alpha:$.opacity!==void 0?$.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch(Z){}if(Q.includes(",")){this.#Q=Q.split(",").map((Z)=>{let $=Z.trim();return{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1}});return}if(Q.startsWith("#")){this.#Q=[{color:Q.slice(0,7),alpha:Q.length>7?parseInt(Q.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.#q=[],this.#Z=[];let Q=document.createElement("div");Q.className="palette-colors-inline",Q.setAttribute("role","button"),Q.setAttribute("tabindex",q?"-1":"+0"),Q.setAttribute("aria-expanded",String(this.open)),Q.setAttribute("aria-label","Edit palette colors"),Q.addEventListener("blur",()=>{Q.style.removeProperty("outline"),Q.style.removeProperty("outline-offset")});let Z=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0,Q.setAttribute("aria-expanded","true")};Q.addEventListener("click",Z);let $=document.createElement("div");if($.className="palette-colors",this.#Q.forEach((j,_)=>{$.appendChild(this.#X(j,_,q,{inline:!0}))}),Q.appendChild($),this.appendChild(Q),this.#D(),!this.#N)this.#z(q,this);let J=document.createElement("div");J.className="palette-colors-expanded",this.#Q.forEach((j,_)=>{if(J.appendChild(this.#X(j,_,q)),!this.#N)J.appendChild(this.#U(_,q))}),this.appendChild(J)}#X(q,Q,Z,{inline:$=!1}={}){let J=q.alpha<1?q.color+Math.round(q.alpha*255).toString(16).padStart(2,"0"):q.color,j=document.createElement("fig-input-color");if(j.setAttribute("value",J),$)j.setAttribute("text","false"),j.setAttribute("alpha","true"),j.setAttribute("swatch-disabled","");else j.setAttribute("text","true"),j.setAttribute("alpha","true"),j.setAttribute("full","");if(Z)j.setAttribute("disabled","");let _=$?this.#Z:this.#q,W=(N)=>{N.stopPropagation();let K=N.currentTarget;this.#Q[Q]={color:K.hexOpaque||this.#Q[Q].color,alpha:K.rgba?K.rgba.a:this.#Q[Q].alpha};let G=_[Q];if(G){let U=this.#Q[Q],X=U.alpha<1?U.color+Math.round(U.alpha*255).toString(16).padStart(2,"0"):U.color;G.setAttribute("value",X)}};if(j.addEventListener("input",(N)=>{W(N),this.#A()}),j.addEventListener("change",(N)=>{W(N),this.#O()}),$)this.#q.push(j);else this.#Z.push(j);return j}#U(q,Q){let Z=document.createElement("fig-button");if(Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Remove color"),Z.className="palette-remove-btn",Q||this.#Q.length<=this.#_)Z.setAttribute("disabled","");Z.appendChild(c("minus")),Z.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#L(q)});let $=document.createElement("fig-tooltip");return $.setAttribute("text","Remove color"),$.appendChild(Z),$}#L(q){if(this.#N)return;if(q<0||q>=this.#Q.length)return;if(this.#Q.length<=this.#_)return;this.#Q.splice(q,1),this.#q=[],this.#Z=[],this.#K(),this.#O()}#z(q,Q=this){let Z=this.#Q.length>=this.#W,$=document.createElement("fig-button");if($.setAttribute("variant","ghost"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Add color"),$.className="palette-add-btn",q||Z)$.setAttribute("disabled","");$.appendChild(c("add")),$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Q.length>=this.#W)return;this.open=!0,this.#M({color:"#D9D9D9",alpha:1})});let J=document.createElement("fig-tooltip");J.setAttribute("text","Add color"),J.appendChild($),Q.appendChild(J)}#M(q){if(this.#N)return;this.#Q.push(q);let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.#Q.length-1,$=this.#X(q,Z,Q,{inline:!0}),J=this.querySelector(".palette-colors");if(J)J.appendChild($);let j=this.#X(q,Z,Q),_=this.querySelector(".palette-colors-expanded");if(_)_.appendChild(j),_.appendChild(this.#U(Z,Q));if(this.#Q.length>=this.#W){let W=this.querySelector(".palette-add-btn");if(W)W.setAttribute("disabled","")}this.#T(Q),this.#O()}#B(q){let Q=this.#Q[q];if(!Q)return;let Z=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,$=this.#q[q];if($)$.setAttribute("value",Z);let J=this.#Z[q];if(J)J.setAttribute("value",Z)}#R(){if(this.#q.length!==this.#Q.length){this.#K();return}this.#Q.forEach((q,Q)=>{this.#B(Q)})}#H(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#q,...this.#Z].forEach((Z)=>{if(q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")});let Q=this.querySelector(".palette-add-btn");if(Q)if(q||this.#Q.length>=this.#W)Q.setAttribute("disabled","");else Q.removeAttribute("disabled");this.#T(q),this.#D()}#D(){let q=this.querySelector(".palette-colors-inline");if(!q)return;let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";q.setAttribute("tabindex",Q?"-1":"+0"),q.setAttribute("aria-disabled",String(Q)),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()}#T(q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let Q=q||this.#Q.length<=this.#_;this.querySelectorAll(".palette-remove-btn").forEach((Z)=>{if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")})}#A(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#O(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}M("fig-input-palette",Zq);class Q0 extends HTMLElement{static SHIFT_SNAP=5;#Q;#q;#Z=!1;#$=null;#J=null;#j=null;#N=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#W(){let q=this.getAttribute("edit");if(q==="false")return"false";if(q==="picker")return"picker";return"true"}get#Y(){return this.#W==="true"}get#G(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#K(){if(!this.#q)return null;return this.#q.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#X(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#Y?"-1":"0")}#U(q){let Q=Z0(q);return{...Q,type:["linear","radial","angular"].includes(Q.type)?Q.type:"linear",angle:Number.isFinite(Number(Q.angle))?Number(Q.angle):90,centerX:Number.isFinite(Number(Q.centerX))?Number(Q.centerX):50,centerY:Number.isFinite(Number(Q.centerY))?Number(Q.centerY):50}}connectedCallback(){if(this.#B(),this.#k(),this.#L(),this.removeEventListener("keydown",this.#M),this.addEventListener("keydown",this.#M),this.#Y)document.addEventListener("keydown",this.#z)}#L(){if(this.#W!=="picker"||o())return;this.#N??=customElements.whenDefined("fig-fill-picker").then(()=>{if(!this.isConnected||this.#W!=="picker")return;this.#k()})}disconnectedCallback(){if(document.removeEventListener("keydown",this.#z),this.removeEventListener("keydown",this.#M),this.#J)this.#J.disconnect(),this.#J=null;if(this.#j!==null)cancelAnimationFrame(this.#j),this.#j=null;clearTimeout(this.#$),this.removeEventListener("pointerenter",this.#S),this.removeEventListener("pointermove",this.#y),this.removeEventListener("pointerleave",this.#w),this.removeEventListener("click",this.#E),this.removeEventListener("dblclick",this.#b)}#z=(q)=>{let Q=document.activeElement;if(!(Q instanceof Node)||!this.contains(Q))return;let Z=Q&&(Q.tagName==="INPUT"||Q.tagName==="TEXTAREA"||Q.isContentEditable);if(!this.#q)return;if(q.key==="Tab"&&!Z){let j=this.#q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!j)return;q.preventDefault();let _=[...this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],W=_.indexOf(j),N=q.shiftKey?(W-1+_.length)%_.length:(W+1)%_.length;j.deselect(),_[N].select();return}if((q.key==="ArrowLeft"||q.key==="ArrowRight")&&!Z){let j=this.#q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!j)return;let _=parseInt(j.dataset.stopIndex,10);if(isNaN(_)||!this.#_.stops[_])return;q.preventDefault();let W=(q.key==="ArrowRight"?1:-1)*(q.shiftKey?Q0.SHIFT_SNAP:1),N=this.#_.stops[_];N.position=Math.max(0,Math.min(100,N.position+W)),j.setAttribute("value",`${N.position}% 50%`);let K=j.closest("fig-tooltip");if(K)K.text=`${Math.round(N.position)}%`,K.setAttribute("show","true"),K.showPopup(),j.hideColorTip(),clearTimeout(this.#$),this.#$=setTimeout(()=>{K.removeAttribute("show"),j.showColorTip()},600);this.#m(),this.#s(),this.#p();return}if(q.key!=="Delete"&&q.key!=="Backspace")return;if(Z)return;if(this.#_.stops.length<=2)return;let $=this.#q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!$)return;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])return;q.preventDefault(),$.removeAttribute("selected"),this.#_.stops.splice(J,1),this.#v(),this.#m(),this.#s(),this.#p()};#M=(q)=>{if(this.#W!=="picker")return;if(q.key!=="Enter"&&q.key!==" ")return;if(q.altKey||q.ctrlKey||q.metaKey)return;if(z(this,"disabled"))return;let Q=this.querySelector("fig-fill-picker");if(!Q||typeof Q.open!=="function")return;q.preventDefault(),Q.open()};#B(){let q=this.getAttribute("value");if(!q)return;try{let Q=JSON.parse(q);if(Q?.type==="gradient"&&Q.gradient){this.#_=this.#U({...this.#_,...Q.gradient});return}if(Q?.gradient)this.#_=this.#U({...this.#_,...Q.gradient})}catch(Q){}}#R(){let q=this.#U(this.#_),Z=[...q.stops].sort((j,_)=>j.position-_.position).map((j)=>{let _=(j.opacity??100)/100;if(_>=1)return`${j.color} ${j.position}%`;let{r:W,g:N,b:K}=i(j.color);return`rgba(${W}, ${N}, ${K}, ${_}) ${j.position}%`}).join(", "),$=qq(q),J=$?` ${$}`:"";if(this.#W==="true")return`linear-gradient(to right${J}, ${Z})`;if(q.type==="radial")return`radial-gradient(circle at ${q.centerX}% ${q.centerY}%${J}, ${Z})`;if(q.type==="angular")return`conic-gradient(from ${q.angle}deg${J}, ${Z})`;return`linear-gradient(${q.angle}deg${J}, ${Z})`}#H(q){let Q=(q.opacity??100)/100;if(Q>=1)return q.color;let{r:Z,g:$,b:J}=i(q.color);return`rgba(${Z}, ${$}, ${J}, ${Q})`}#D(){let q=this.getAttribute("size");return q?` size="${q}"`:""}#T(){if(!this.#Q)return;let q=this.getAttribute("size");if(q)this.#Q.setAttribute("size",q);else this.#Q.removeAttribute("size")}#A(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Q=this.#G==="tip"?' tip="color"':"";return this.#_.stops.map((Z,$)=>`<fig-tooltip action="manual" text="${Math.round(Z.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${Q} color="${this.#H(Z)}" value="${Z.position}% 50%" hit-area="4" data-stop-index="${$}"${q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#O=null;#P=!1;#k(){this.#J?.disconnect(),this.#J=null;let q=z(this,"disabled"),Q=this.#W;if(Q==="picker"&&o()){let Z=JSON.stringify(this.value);this.innerHTML=`
268
+ <fig-fill-picker mode="gradient" value='${Z}'${q?" disabled":""}>
269
+ <fig-swatch background="${this.#R()}"${this.#D()}${q?" disabled":""}></fig-swatch>
270
+ </fig-fill-picker>`,this.#Q=this.querySelector("fig-swatch"),this.#q=null,this.#C(),this.#X();return}if(this.innerHTML=`
271
+ <fig-swatch background="${this.#R()}"${this.#D()}${q?" disabled":""}></fig-swatch>
272
+ ${Q==="true"||Q==="picker"?`<div class="fig-input-gradient-track">${this.#A()}</div>`:""}`,this.#Q=this.querySelector("fig-swatch"),this.#q=this.querySelector(".fig-input-gradient-track"),Q==="true"||Q==="picker")this.#F(),this.#l();this.#X()}#C(){let q=this.querySelector("fig-fill-picker");if(!q)return;q.anchorElement=this;let Q=(Z)=>{Z.stopPropagation();let $=Z.detail;if(!$?.gradient)return;this.#_=this.#U({...this.#_,...$.gradient}),this.#m()};q.addEventListener("input",(Z)=>{Q(Z),this.#s()}),q.addEventListener("change",(Z)=>{Q(Z),this.#p()})}#V(q){return tq(this.#_.stops,q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#F(){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.#G==="tip")q.setAttribute("tip","add");q.style.position="absolute",q.style.top="50%",q.style.transform="translate(-50%, -50%)",q.style.pointerEvents="none",q.style.opacity="0",q.style.transition="opacity 0.15s",this.#q.appendChild(q),this.#O=q,this.addEventListener("pointerenter",this.#S),this.addEventListener("pointermove",this.#y),this.addEventListener("pointerleave",this.#w),this.addEventListener("click",this.#E),this.addEventListener("dblclick",this.#b)}#f(){if(!this.#O)return;this.#O.style.opacity="1"}#I(){if(!this.#O)return;this.#O.style.opacity="0"}#S=()=>{if(this.#Z)return;this.#f()};#w=()=>{this.#I()};#y=(q)=>{if(this.#Z){this.#I();return}if(!this.#O||!this.#q)return;if(q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#I();return}let Q=this.#q.getBoundingClientRect(),Z=Math.max(0,Math.min(1,(q.clientX-Q.left)/Q.width));this.#O.style.left=`${Z*100}%`;let $=this.#V(Z);this.#O.setAttribute("color",$),this.#f()};#u(){let q=this.#_.stops.length;if(q<2)return;for(let Q=0;Q<q;Q++)this.#_.stops[Q].position=Math.round(Q/(q-1)*100);this.#v(),this.#m(),this.#s(),this.#p()}#b=(q)=>{if(!this.#q)return;if(!q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#u(),this.#q.querySelectorAll("fig-handle[selected]").forEach((Q)=>{Q.removeAttribute("selected")})};#E=(q)=>{if(!this.#q)return;if(this.#Z)return;if(this.#P){this.#P=!1;return}if(q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(q.shiftKey){let _=q.target.closest("fig-handle"),W=parseInt(_?.dataset.stopIndex,10);if(this.#u(),!isNaN(W))this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((N)=>{if(parseInt(N.dataset.stopIndex,10)===W)N.select();else N.deselect()});q.stopPropagation()}return}let Q=this.#q.getBoundingClientRect(),Z=Math.max(0,Math.min(1,(q.clientX-Q.left)/Q.width)),$=Math.round(Z*100),J=this.#V(Z);this.#_.stops.push({position:$,color:J,opacity:100}),this.#_.stops.sort((_,W)=>_.position-W.position);let j=this.#_.stops.findIndex((_)=>_.position===$&&_.color===J);this.#v(),this.#m(),this.#s(),this.#p(),requestAnimationFrame(()=>{let W=this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[j];if(W)W.click()})};#h(){if(this.#j=null,!this.isConnected)return;if(!this.#q)return;let q=this.#_.stops;this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q,Z)=>{if(Z>=q.length)return;Q.removeAttribute("value"),Q.setAttribute("value",`${q[Z].position}% 50%`)})}refreshLayout(){this.#h()}#x(){if(this.#j!==null)return;this.#j=requestAnimationFrame(()=>this.#h())}#v(){if(!this.#q)return;let q=this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Q=this.#_.stops;if(q.length!==Q.length){let Z=this.#O;if(this.#q.innerHTML=this.#A(),Z)this.#q.appendChild(Z);this.#g(),this.#o(),this.#x();return}for(let Z=0;Z<Q.length;Z++){let $=q[Z],J=Q[Z];if($.dataset.stopIndex=Z,$.setAttribute("value",`${J.position}% 50%`),$.setAttribute("color",this.#H(J)),this.#G==="tip")$.setAttribute("tip","color");else $.removeAttribute("tip");let j=$.closest("fig-tooltip");if(j)j.setAttribute("text",`${Math.round(J.position)}%`)}this.#g()}#g(){if(!this.#q)return;let q=this.#G==="tip";if(this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{if(q)Q.setAttribute("tip","color");else Q.removeAttribute("tip")}),this.#O)if(q)this.#O.setAttribute("tip","add");else this.#O.removeAttribute("tip")}#o(){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"]})})}#d(){if(!this.#q)return;let q=this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Q=this.#_.stops,Z=new Set;q.forEach(($)=>{let J=Math.round(parseFloat($.getAttribute("value"))||0),j=($.getAttribute("color")||"").toUpperCase(),_=-1;for(let W=0;W<Q.length;W++){if(Z.has(W))continue;if(Q[W].position===J&&Q[W].color.toUpperCase()===j){_=W;break}}if(_===-1){let W=1/0;for(let N=0;N<Q.length;N++){if(Z.has(N))continue;let K=Math.abs(Q[N].position-J);if(K<W)W=K,_=N}}if(_!==-1)Z.add(_),$.dataset.stopIndex=_})}#m(){if(!this.#Q)return;this.#Q.setAttribute("background",this.#R()),this.#T()}#l(){if(!this.#q)return;this.#q.addEventListener("pointerdown",(q)=>{if(z(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 Q=this.#q.getBoundingClientRect(),Z=Math.max(0,Math.min(1,(q.clientX-Q.left)/Q.width)),$=Math.round(Z*100),J=this.#V(Z);this.#_.stops.push({position:$,color:J,opacity:100}),this.#_.stops.sort((N,K)=>N.position-K.position);let j=this.#_.stops.findIndex((N)=>N.position===$&&N.color===J);this.#P=!0,this.#v(),this.#m(),this.#s(),this.#I();let W=this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[j];if(W)this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((N)=>{if(N!==W)N.deselect()}),W.select(),W.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 Q=q.target.closest("fig-handle");if(!Q)return;if(q.stopPropagation(),q.detail?.color){let N=parseInt(Q.dataset.stopIndex,10);if(!isNaN(N)&&this.#_.stops[N]){if(this.#_.stops[N].color=q.detail.color,q.detail.opacity!==void 0)this.#_.stops[N].opacity=q.detail.opacity;else if(q.detail.alpha!==void 0)this.#_.stops[N].opacity=Math.round(q.detail.alpha*100);Q.setAttribute("color",this.#H(this.#_.stops[N])),this.#m(),this.#s()}return}if(!this.#Z)Q.style.zIndex="5";this.#Z=!0;let Z=parseInt(Q.dataset.stopIndex,10);if(isNaN(Z)||!this.#_.stops[Z])return;let $=q.detail?.px??0,J=Math.round($*100),j=J,_=this.#q.getBoundingClientRect().width;if(q.detail?.shiftKey)j=Math.round(j/Q0.SHIFT_SNAP)*Q0.SHIFT_SNAP;else{let N=_>0?5/_*100:0;for(let K=0;K<this.#_.stops.length;K++){if(K===Z)continue;if(Math.abs(this.#_.stops[K].position-j)<=N){j=this.#_.stops[K].position;break}}}if(this.#_.stops[Z].position=j,j!==J)Q.style.left=`${j/100*_}px`;let W=Q.closest("fig-tooltip");if(W){if(W.text=`${Math.round(j)}%`,!W.hasAttribute("show"))W.setAttribute("show","true"),Q.hideColorTip()}this.#m(),this.#s()}),this.#q.addEventListener("change",(q)=>{let Q=q.target.closest("fig-handle");if(!Q)return;if(q.stopPropagation(),q.detail?.color){let N=parseInt(Q.dataset.stopIndex,10);if(!isNaN(N)&&this.#_.stops[N]){if(this.#_.stops[N].color=q.detail.color,q.detail.opacity!==void 0)this.#_.stops[N].opacity=q.detail.opacity;Q.setAttribute("color",this.#H(this.#_.stops[N])),this.#m(),this.#p()}return}Q.style.zIndex="";let Z=Q.closest("fig-tooltip");if(Z)Z.removeAttribute("show");Q.showColorTip();let $=parseInt(Q.dataset.stopIndex,10);if(isNaN($)||!this.#_.stops[$])return;let J=q.detail?.px??0,j=Math.round(J*100),_=this.#q.getBoundingClientRect().width,W=_>0?5/_*100:0;for(let N=0;N<this.#_.stops.length;N++){if(N===$)continue;if(Math.abs(this.#_.stops[N].position-j)<=W){j=this.#_.stops[N].position;break}}this.#_.stops[$].position=j,Q.style.left=`${j/100*_}px`,this.#_.stops.sort((N,K)=>N.position-K.position),this.#d(),this.#m(),this.#p(),requestAnimationFrame(()=>{this.#Z=!1})}),this.#J=new MutationObserver((q)=>{for(let Q of q){if(Q.attributeName!=="color")continue;let Z=Q.target;if(Z.classList.contains("fig-input-gradient-ghost"))continue;let $=parseInt(Z.dataset.stopIndex,10);if(isNaN($)||!this.#_.stops[$])continue;let J=Z.getAttribute("color");if(!J||!J.startsWith("#"))continue;if(J!==this.#_.stops[$].color)this.#_.stops[$].color=J,this.#m(),this.#s()}}),this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((q)=>{this.#J.observe(q,{attributes:!0,attributeFilter:["color"]})})}#s(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#p(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:e0(this.#U(this.#_))}}set value(q){if(typeof q==="string")this.setAttribute("value",q);else this.setAttribute("value",JSON.stringify(q))}focus(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Y){let Q=this.#K();if(Q){Q.focus(q);return}}HTMLElement.prototype.focus.call(this,q)}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"value":this.#B(),this.#m(),this.#v();break;case"disabled":this.#c();break;case"edit":if(this.#k(),this.#L(),this.#Y)document.addEventListener("keydown",this.#z);else document.removeEventListener("keydown",this.#z);break;case"mode":this.#g();break;case"size":this.#T();break}}#c(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#X(),this.#Q)if(q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#q)for(let Q of this.#q.querySelectorAll("fig-handle"))if(q)Q.setAttribute("disabled","");else Q.removeAttribute("disabled")}}M("fig-input-gradient",Q0);class K0 extends HTMLElement{#Q=null;#q;#Z;#$;#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.#q=this.handleInput.bind(this),this.#Z=this.handleChange.bind(this),this.#$=(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.#Z),this.input.addEventListener("change",this.#Z),this.removeEventListener("click",this.#$),this.addEventListener("click",this.#$),this.#W();let Q=this.querySelector(":scope > label");if(Q)this.#Q=Q,this.#J=!1,this.#Q.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#j(),this.#Q.innerText=this.getAttribute("label");if(!this.hasAttribute("label")){let Z=Array.from(this.childNodes).filter(($)=>$.nodeType===Node.TEXT_NODE).map(($)=>$.textContent||"").join(" ").trim();if(Z&&!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-label",Z)}this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#j(){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(){}#N(q){return this.hasAttribute(q)&&this.getAttribute(q)!=="false"}#_(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#W(){let q=this.#N("checked"),Q=this.#N("indeterminate")&&!q,Z=this.#N("disabled");this.input.checked=q,this.input.indeterminate=Q,this.input.disabled=Z,this.input.value=this.getAttribute("value")||"";let $=this.getAttribute("name")||this.name;if($)this.input.setAttribute("name",$);else this.input.removeAttribute("name");if(Q)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#_()}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.#Z),this.removeEventListener("click",this.#$)}attributeChangedCallback(q,Q,Z){switch(q){case"label":if(Z)this.#j(),this.#Q.innerText=Z;else if(this.#Q&&this.#J)this.#Q.remove(),this.#Q=null,this.#J=!1;break;case"checked":if(this.#N("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#W();break;case"indeterminate":this.#W();break;case"disabled":this.#W();break;case"name":if(Z)this.input.setAttribute("name",Z);else this.input.removeAttribute("name");break;case"value":this.input.value=Z||"";break;default:this.input[q]=Z,this.input.setAttribute(q,Z);break}}handleInput(q){if(q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#_(),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.#_(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}M("fig-checkbox",K0);class $q extends K0{constructor(){super();this.input.setAttribute("type","radio");let q=this.getAttribute("name");if(q)this.input.setAttribute("name",q);else this.input.removeAttribute("name")}}M("fig-radio",$q);class Jq extends K0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}M("fig-switch",Jq);class jq extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Q=!1;#q=null;#Z=null;#$=null;#J=null;#j=!1;#N=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#_=this.#z.bind(this);#W=this.#M.bind(this);#Y=this.#B.bind(this);get value(){return this.getAttribute("value")||""}set value(q){this.setAttribute("value",q??"")}#G(){return!!this.querySelector(":scope > .input-combo")}#K(){if(this.#q=this.querySelector("fig-input-text"),this.#$=this.querySelector("fig-button"),this.#Z=this.querySelector("fig-dropdown"),this.#q)this.#q.setAttribute("value",this.value),this.#q.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#O()}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.#G())this.#K(),this.#U();else this.#X(),this.#U();this.#P(z(this,"disabled"))}disconnectedCallback(){this.#L()}#X(){let q=this.#D(),Q=this.getAttribute("placeholder")||"",Z=this.value,$=this.#A(),J=this.#Q?"":`<fig-dropdown type="dropdown" label="${b($)}">${q.map((j)=>`<option>${b(j.trim())}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
273
+ <fig-input-text placeholder="${b(Q)}" value="${b(Z)}"></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">
276
276
  <path d="M5.87868 7.12132L8 9.24264L10.1213 7.12132" stroke="currentColor" stroke-opacity="0.9" stroke-linecap="round"/>
277
277
  </svg>
278
- ${j}
278
+ ${J}
279
279
  </fig-button>
280
- </div>`,this.#Z=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#Q&&this.#j&&this.#J){if(!this.#j.hasAttribute("type"))this.#j.setAttribute("type","dropdown");if(!this.#j.hasAttribute("label"))this.#j.setAttribute("label",J);this.#J.append(this.#j)}this.#$=this.querySelector("fig-dropdown"),this.#O()}#W(){this.#L(),this.#$?.addEventListener("input",this.#_),this.#Z?.addEventListener("input",this.#X),this.#Z?.addEventListener("change",this.#U)}#L(){this.#$?.removeEventListener("input",this.#_),this.#Z?.removeEventListener("input",this.#X),this.#Z?.removeEventListener("change",this.#U)}#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.#A()}#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.#A()}#M(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#A(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#P(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#D(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#H(){return`${this.#D()} options`}#O(){if(this.#Z)this.#Y.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.#H())}#T(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.#P();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.#O();break;case"value":if(!this.#q&&this.#Z)this.#Z.setAttribute("value",$||"");break;case"disabled":this.#T($!==null&&$!=="false");break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#O();break}}}z("fig-combo-input",q1);class _1 extends HTMLElement{#Q="color";#Z=null;#$=!1;constructor(){super();this.#Z=this.#U.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#_(),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}=F0(1,1);return Z.fillStyle=Q,Z.fillStyle}catch{return"#D9D9D9"}}#Y(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}#_(){let Q=this.getAttribute("background")||"#D9D9D9",Z=Q.includes("var("),$=Z?this.#Y(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")}#U(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.#_()}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",_1);class G0 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#Y=null;#_=this.#c.bind(this);#X=this.#d.bind(this);#U=this.#s.bind(this);#G=this.#h.bind(this);#K=null;#N=null;#W=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.#Y}#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.#D(),this.#O(),this.#P(),this.#C(),this.#T(),this.#f(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#m();this.#J=this.querySelector("fig-input-file[data-generated]"),this.#J?.removeEventListener("change",this.#_),this.#J?.addEventListener("change",this.#_)}disconnectedCallback(){if(this.#J?.removeEventListener("change",this.#_),this.#A(),this.#V(),this.#j)URL.revokeObjectURL(this.#j),this.#j=null;this.#q=null}#A(){if(!this.#Z)return;if(this.#Z.tagName==="VIDEO")this.#Z.removeEventListener("play",this.#X),this.#Z.removeEventListener("pause",this.#U),this.#Z.removeEventListener("ended",this.#G)}#P(){if(this.#A(),this.#Z?.tagName!=="VIDEO")return;this.#Z.addEventListener("play",this.#X),this.#Z.addEventListener("pause",this.#U),this.#Z.addEventListener("ended",this.#G)}#D(){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}#H(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#O(){let Q=this.#H();if(Q){if(this.#D(),this.#Z&&this.#Z!==Q){if(this.#A(),this.#Z.hasAttribute("data-generated"))this.#Z.remove()}if(this.#Z=Q,this.#$&&Q.parentElement!==this.#$)this.#$.append(Q);this.#T();return}this.#D();let Z=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Z&&this.#Z.tagName!==Z){if(this.#A(),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.#P();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=$}}#T(){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])")}#I(){return Array.from(this.querySelectorAll(":scope > figcaption[data-generated]"))}#f(){let Q=this.#S(),Z=this.#I();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)}#R(Q,Z=!1){if(!this.hasAttribute(Q))return Z;return this.getAttribute(Q)!=="false"}#C(){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.#T();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.#R("autoplay",!1),this.#Z.loop=this.#R("loop",!1),this.#Z.muted=this.#R("muted",!1),this.#Z.playsInline=!0,this.#T(),this.#y(),this.#k()}get mediaEl(){return this.#Z}#E(){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.#E()){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.#R("controls",!1))this.#w();else this.#V()}#w(){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.#N===this.#Z&&this.#W===this.#K){this.#k();return}this.#v();let Q=this.#K,Z=this.#Z;this.#N=Z,this.#W=Q;let $=null,J=()=>{if(this.#k(),!this.#E())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.#E())return;let X=Z.play?.();if(X&&typeof X.catch==="function")X.catch(()=>{})},q=()=>Z.pause?.(),_=(X)=>{if(!this.#E())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()}#v(){let Q=this.#N,Z=this.#W;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.#N=null,this.#W=null,this.#L=null,this.#F=null,this.#z=null,this.#B=null}#V(){this.#v(),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()}#m(){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.#Y?.name)Q.setAttribute("filename",this.#Y.name);else if(this.#Q)Q.setAttribute("url",this.#Q);Q.addEventListener("change",this.#_),this.#D(),this.#$.append(Q),this.#J=Q}#x(){if(this.#J)this.#J.removeEventListener("change",this.#_),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.#Y=null,this.#q=null,$)this.src="";if(this.#C(),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.#Y=Z,this.#j=URL.createObjectURL(Z),this.#q=this.#j,this.#C(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Z,src:this.#j}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#J)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",Z.name),this.#J.setAttribute("label","Replace")}#g(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}}))}#d(){this.#g("play")}#s(){this.#g("pause")}#h(){this.#g("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.#Y=null;if(this.#C(),this.#J){let q=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#Q?"Replace":q),this.#Q)if(this.#Y?.name)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",this.#Y.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.#O(),this.#C(),this.#J)this.#J.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(Q))this.#T();if(Q==="upload"){let J=$!==null&&$!=="false";if(J&&!this.#J)this.#m();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.#C();if(Q==="caption")this.#f()}}z("fig-media",G0);class X1 extends G0{get mediaKind(){return"image"}}z("fig-image",X1);class Y1 extends G0{get mediaKind(){return"video"}}z("fig-video",Y1);class K1 extends HTMLElement{static get observedAttributes(){return["src","alt","label","text","sublabel","href","target","selected","disabled","full","size","aspect-ratio","fit","label-line-clamp"]}#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=!1;#Y=new MutationObserver((Q)=>{if(!Q.some(($)=>[...$.addedNodes,...$.removedNodes].some((J)=>J instanceof Element&&(J.matches("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])")||J.querySelector("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])"))))||!this.isConnected)return;this.#W(),this.#F()});connectedCallback(){this.#Y.observe(this,{childList:!0,subtree:!0}),this.#W(),this.#F()}disconnectedCallback(){this.#Y.disconnect()}attributeChangedCallback(){if(!this.isConnected)return;this.#W(),this.#F()}#_(){return this.getAttribute("label")??this.getAttribute("text")??""}#X(){return this.getAttribute("sublabel")??""}#U(){let Q=this.getAttribute("href");return Boolean(Q)&&!F(this,"disabled")}#G(){return this.getAttribute("label-line-clamp")==="2"?"2":"1"}#K(){return Boolean(this.getAttribute("src"))}#N(){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-image:not([data-generated]), :scope > .fig-card-link > fig-media:not([data-generated]), :scope > .fig-card-link > 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])")}#W(){if(!this.#K()){this.#L();return}if(this.querySelectorAll(":scope > fig-footer[data-generated]").forEach((q)=>q.remove()),this.#Z?.parentElement===this)this.#Z=null;let Q=this.#N();this.#q=Boolean(Q);let $=this.#U()?"a":"div";if(!this.#Q||this.#Q.tagName.toLowerCase()!==$){let q=document.createElement($);if(q.className="fig-card-link",this.#Q){while(this.#Q.firstChild)q.appendChild(this.#Q.firstChild);this.#Q.replaceWith(q)}else this.appendChild(q);this.#Q=q}let J=this.#Q.querySelector(":scope > .fig-card-media");if(J){while(J.firstChild)this.#Q.insertBefore(J.firstChild,J);J.remove()}if(Q&&Q.parentElement!==this.#Q)this.#Q.querySelectorAll(":scope > [data-generated]:not(fig-footer)").forEach((q)=>q.remove()),this.#Q.prepend(Q),this.#$=null;if(!this.#q){if(this.#$=this.#Q.querySelector(":scope > fig-image[data-generated]")||null,!this.#$)this.#Q.querySelectorAll(":scope > fig-image, :scope > fig-media, :scope > fig-preview").forEach((q)=>{if(q.hasAttribute("data-generated"))q.remove()}),this.#$=document.createElement("fig-image"),this.#$.setAttribute("data-generated",""),this.#$.setAttribute("full",""),this.#$.setAttribute("size","auto"),this.#Q.prepend(this.#$)}if(!Boolean(this.#_()||this.#X())){this.#Q.querySelector(":scope > fig-footer[data-generated]")?.remove(),this.#Z=null,this.#J=null,this.#j=null;return}if(!this.#Z||!this.#Z.isConnected){if(this.#Z=this.#Q.querySelector(":scope > fig-footer[data-generated]"),!this.#Z)this.#Z=document.createElement("fig-footer"),this.#Z.setAttribute("data-generated",""),this.#Q.appendChild(this.#Z)}if(!this.#J||!this.#J.isConnected){if(this.#J=this.#Z.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.#Z.appendChild(this.#J)}}if(!this.#j||!this.#j.isConnected){if(this.#j=this.#Z.querySelector(":scope > .fig-card-sublabel[data-generated]"),!this.#j){if(this.#j=this.#Q.querySelector(":scope > .fig-card-sublabel[data-generated]")||null,!this.#j)this.#j=document.createElement("label"),this.#j.className="fig-card-sublabel",this.#j.setAttribute("data-generated","");this.#J.after(this.#j)}}}#L(){let Q=this.#Q||this.querySelector(":scope > .fig-card-link");if(Q)Q.querySelectorAll("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])").forEach(($)=>this.insertBefore($,Q)),Q.remove();if(this.querySelectorAll(":scope > [data-generated]").forEach(($)=>$.remove()),this.#Q=null,this.#$=null,this.#q=!0,this.#Z=null,this.#J=null,this.#j=null,!this.#_()&&!this.#X())return;this.#Z=document.createElement("fig-footer"),this.#Z.setAttribute("data-generated",""),this.#J=document.createElement("label"),this.#J.className="fig-card-label",this.#J.setAttribute("data-generated",""),this.#Z.appendChild(this.#J);let Z=this.#X();if(this.#j=null,Z)this.#j=document.createElement("label"),this.#j.className="fig-card-sublabel",this.#j.setAttribute("data-generated",""),this.#Z.appendChild(this.#j);this.appendChild(this.#Z)}#F(){if(!this.#K()){this.#z();return}if(!this.#Q)return;let Q=F(this,"disabled"),Z=F(this,"selected"),$=this.#_(),J=this.#X(),j=this.#G();if(this.style.setProperty("--fig-card-label-line-clamp",j),this.#U()){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.#$&&!this.#q){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.#$.setAttribute("src",q);else this.#$.removeAttribute("src");this.#$.setAttribute("alt",K),this.#$.setAttribute("aspect-ratio",X),this.#$.setAttribute("fit",Y),this.#$.setAttribute("full",""),this.#$.setAttribute("size","auto")}if(this.#J)this.#J.textContent=$,this.#J.hidden=!$;if(this.#j)this.#j.textContent=J,this.#j.hidden=!J;if(this.#Z)this.#Z.hidden=!$&&!J}#z(){let Q=F(this,"disabled"),Z=this.#_(),$=this.#X();this.style.setProperty("--fig-card-label-line-clamp",this.#G()),this.setAttribute("role","group");let J=[Z,$].filter(Boolean).join(", ");if(J)this.setAttribute("aria-label",J);else this.removeAttribute("aria-label");if(Q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#J)this.#J.textContent=Z,this.#J.hidden=!Z;if(this.#j)this.#j.textContent=$}}z("fig-card",K1);class G1 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=!1;#q=!1;static get observedAttributes(){return["playing","duration","time","disabled"]}connectedCallback(){this.#Y(),this.#G(),this.#K(),this.#_()}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.#G();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.#U(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.#_()}#_(){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")}`}#U(Q,Z=0){let $=this.#X(Q);if(!Number.isFinite(Z)||Z<=0)return $;return`${$} of ${this.#X(Z)}`}#G(){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.#U(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",G1);class N1 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#Y(){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.#Y}connectedCallback(){this.#W(),this.addEventListener("dragover",this.#G),this.addEventListener("dragleave",this.#K),this.addEventListener("drop",this.#N)}disconnectedCallback(){this.#Q?.removeEventListener("change",this.#X),this.#$?.removeEventListener("click",this.#U),this.removeEventListener("dragover",this.#G),this.removeEventListener("dragleave",this.#K),this.removeEventListener("drop",this.#N)}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#W()}clear(){if(this.#q=null,this.#Q)this.#Q.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#W(),this.#_({cleared:!0})}#_(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.#W(),this.#_()};#U=(Q)=>{Q.stopPropagation(),this.clear()};#G=(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};#N=(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.#W(),this.#_()};#W(){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.#U),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",N1);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;#Y=null;#_=null;#X=null;#U=null;#G=null;#K=null;#N=null;#W=null;#L=null;#F=null;#z=0.8;#B=200;#M=200;#A=null;#P=null;#D=null;#H=null;#O=5;#T=10;#S=10;#I=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.#f(Q);this.#L=this.#R(),this.#y(),this.#g()}disconnectedCallback(){if(this.#q=null,this.#H)this.#H.disconnect(),this.#H=null}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="aspect-ratio"){if(b(this,"--aspect-ratio",$),this.#Y)this.#d(),this.#u();return}if(Q==="edit"){if(this.isConnected)this.#y();return}if(Q==="value"&&$){let J=this.#J;if(this.#f($),this.#L=this.#R(),J!==this.#J&&this.#k())this.#y();else{if(this.#Y)this.#u();this.#Q0(),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.#C(),$=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)}#f(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}#R(){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"}#C(){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#E(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,C=B+(1-(X[A].value-W)/O)*L;R+=(A===0?"M":"L")+M.toFixed(1)+","+C.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,C,k,S,x)=>{let y=1-x;return y*y*y*M+3*y*y*x*C+3*y*x*x*k+x*x*x*S};for(let M=0;M<=48;M++){let C=M/48;Y.push({x:K(0,Q,$,1,C),y:K(0,Z,J,1,C)})}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 C=T(Y[M].x),k=R(Y[M].y);A+=`${M===0?"M":"L"}${C.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.#m(),this.innerHTML=this.#v(),this.#x(),this.#Y)this.#c(),this.#d(),this.#u();this.#l(),this.#U0()}static#w(Q){return String(Q).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#b(){let Q="",Z=void 0;for(let J of w.PRESETS){if(!this.#k()&&!J.value&&!J.spring)continue;if(J.group!==Z){if(J.group)Q+=`<fig-separator label="${w.#w(J.group)}"></fig-separator>`;Z=J.group}let j;if(J.type==="spring"){let _=J.spring||this.#$;j=w.#E(_)}else{let _=J.value||[this.#Q.x,this.#Q.y,this.#Z.x,this.#Z.y];j=w.curveIcon(..._)}let q=w.#w(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.#w(this.#L)}" full><fig-select-options>${Q}</fig-select-options></fig-select>`}#v(){let Z=this.#b();if(!this.#k())return Z;let $=`<fig-input-text class="fig-easing-curve-value-input" value="${w.#w(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.#q=this.querySelector("fig-input-text"),this.#$=this.querySelector("fig-button"),this.#Q&&this.#J&&this.#$){if(!this.#J.hasAttribute("type"))this.#J.setAttribute("type","dropdown");if(!this.#J.hasAttribute("label"))this.#J.setAttribute("label",$);this.#$.append(this.#J)}this.#Z=this.querySelector("fig-dropdown"),this.#O()}#U(){this.#L(),this.#Z?.addEventListener("input",this.#_),this.#q?.addEventListener("input",this.#W),this.#q?.addEventListener("change",this.#Y)}#L(){this.#Z?.removeEventListener("input",this.#_),this.#q?.removeEventListener("input",this.#W),this.#q?.removeEventListener("change",this.#Y)}#z(q){q.stopPropagation();let Q=q.target.closest("fig-dropdown")?.value??"";if(this.#j=!0,this.setAttribute("value",Q),this.#j=!1,this.#q)this.#q.setAttribute("value",Q);this.#R(),this.#H()}#M(q){q.stopPropagation();let Q=q.target.value??"";this.#j=!0,this.setAttribute("value",Q),this.#j=!1,this.#R()}#B(q){q.stopPropagation();let Q=q.target.value??"";this.#j=!0,this.setAttribute("value",Q),this.#j=!1,this.#H()}#R(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#H(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#D(){return(this.getAttribute("options")||"").split(",").map((q)=>q.trim()).filter(Boolean)}#T(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#A(){return`${this.#T()} options`}#O(){if(this.#q)this.#N.forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.#q.removeAttribute(q);else this.#q.setAttribute(q,Q)});if(this.#Z&&!this.#Z.hasAttribute("aria-label"))this.#Z.setAttribute("label",this.#A())}#P(q){if(this.#q)if(q)this.#q.setAttribute("disabled","");else this.#q.removeAttribute("disabled");if(this.#$)if(q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#Z)if(q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}focus(){this.#q?.focus()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"options":if(this.#Z&&!this.#Q){let $=this.#D();this.#Z.replaceChildren(...$.map((J)=>{let j=document.createElement("option");return j.textContent=J,j}))}break;case"placeholder":if(this.#q)this.#q.setAttribute("placeholder",Z||"");this.#O();break;case"value":if(!this.#j&&this.#q)this.#q.setAttribute("value",Z||"");break;case"disabled":this.#P(Z!==null&&Z!=="false");break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#O();break}}}M("fig-combo-input",jq);class _q extends HTMLElement{#Q="color";#q=null;#Z=!1;constructor(){super();this.#q=this.#Y.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#_(),this.#$(),this.#W()}#$(){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 Q=q.toLowerCase();if(Q.includes("gradient"))return"gradient";if(Q.includes("url("))return"image";return"color"}#j(q){if(!q)return"#D9D9D9";if(q.startsWith("#"))return q.slice(0,7);try{let{ctx:Q}=z0(1,1);return Q.fillStyle=q,Q.fillStyle}catch{return"#D9D9D9"}}#N(q){if(!q||!q.includes("var("))return q;let Q=this.style.background;this.style.background=q;let Z=getComputedStyle(this),$=Z.backgroundImage,J=Z.backgroundColor;if(this.style.background=Q,$&&$!=="none")return $;return J||q}#_(){let q=this.getAttribute("background")||"#D9D9D9",Q=q.includes("var("),Z=Q?this.#N(q):q,$=this.#J(Z);if($!==this.#Q||!this.input){if(this.#Q=$,this.setAttribute("data-type",this.#Q),this.input)this.input.removeEventListener("input",this.#q);if(this.#Q==="color"){let j=this.#j(Z);if(this.innerHTML=`<div></div><input type="color" value="${j}" />`,this.input=this.querySelector("input"),!Q)this.input.addEventListener("input",this.#q);this.#W()}else this.innerHTML="<div></div>",this.input=null,this.#W()}else if(this.#Q==="color"&&this.input){let j=this.#j(Z);if(this.input.value!==j)this.input.value=j}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})`)}#W(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",q?"true":"false"),this.input){this.input.disabled=q;let Q=this.getAttribute("aria-labelledby"),Z=this.getAttribute("aria-label")||"Color swatch",$=this.getAttribute("aria-describedby");if(Q)this.input.setAttribute("aria-labelledby",Q),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",Z),this.input.removeAttribute("aria-labelledby");if($)this.input.setAttribute("aria-describedby",$);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")}#Y(q){this.#Z=!0,this.setAttribute("background",q.target.value),this.#Z=!1}get background(){return this.getAttribute("background")}set background(q){this.setAttribute("background",q)}focus(){this.input?.focus()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="background"){if(this.#Z){let $=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Z);this.style.setProperty("--swatch-background",$?Z:`linear-gradient(${Z}, ${Z})`);return}this.#_()}else if(q==="alpha")this.#$();else if(q==="disabled"||q==="aria-label"||q==="aria-labelledby"||q==="aria-describedby")this.#W()}get alpha(){return this.getAttribute("alpha")}set alpha(q){if(q===null||q===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",q)}}M("fig-swatch",_q);var Wq=["load","error"],Nq=["loadstart","progress","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","durationchange","timeupdate","ratechange","resize","volumechange"],nq=[...new Set([...Wq,...Nq])];class G0 extends HTMLElement{#Q=null;#q=null;#Z=null;#$=null;#J=null;#j=null;#N=null;#_=this.#c.bind(this);#W=this.#i.bind(this);#Y=this.#$0.bind(this);#G=this.#J0.bind(this);#K=this.#a.bind(this);#X=null;#U=null;#L=null;#z=void 0;#M=null;#B=null;#R=null;#H=null;#D=null;#T=null;#A=null;static get observedAttributes(){return["src","type","alt","upload","loading-indicator","label","aspect-ratio","fit","checkerboard","caption","controls","autoplay","loop","muted","poster","aria-label","aria-labelledby","title"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#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.#N}#O(){return this.#j||this.#Q||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#O())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)=>{this.#q.addEventListener("load",$,{once:!0}),this.#q.addEventListener("error",J,{once:!0})})}catch{}let q=this.#q.naturalWidth,Q=this.#q.naturalHeight;if(!(q>0)||!(Q>0))return null;let Z=document.createElement("canvas");return Z.width=q,Z.height=Q,Z.getContext("2d").drawImage(this.#q,0,0),Z.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 Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-media-fit",Q);if(this.querySelectorAll("fig-swatch[data-generated]").forEach(($)=>$.remove()),this.#f(),this.#S(),this.#k(),this.#h(),this.#V(),this.#w(),this.#b(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#s();this.#$=this.querySelector("fig-input-file[data-generated]"),this.#$?.removeEventListener("change",this.#_),this.#$?.addEventListener("change",this.#_)}disconnectedCallback(){if(this.#$?.removeEventListener("change",this.#_),this.#F(),this.#P(),this.#l(),this.#J)URL.revokeObjectURL(this.#J),this.#J=null;this.#j=null}#P(){if(!this.#q)return;if(nq.forEach((q)=>{this.#q.removeEventListener(q,this.#K)}),this.#q.tagName==="VIDEO")this.#q.removeEventListener("play",this.#W),this.#q.removeEventListener("pause",this.#Y),this.#q.removeEventListener("ended",this.#G)}#k(){if(this.#P(),!this.#q)return;if((this.#q.tagName==="VIDEO"?Nq:Wq).forEach((Q)=>{this.#q.addEventListener(Q,this.#K)}),this.#q.tagName!=="VIDEO")return;this.#q.addEventListener("play",this.#W),this.#q.addEventListener("pause",this.#Y),this.#q.addEventListener("ended",this.#G)}#C(){return this.mediaKind==="image"&&this.getAttribute("loading-indicator")!=="false"&&this.#Z?.hasAttribute("data-generated")&&this.#q?.hasAttribute("data-generated")}#V(){let q=this.#O();if(!q||!this.#C()){this.#F();return}if(this.#q?.tagName==="IMG"&&this.#q.complete&&this.#q.currentSrc){this.#F();return}if(this.#L===q)return;this.#F(),this.#L=q,this.#z=this.getAttribute("aria-busy"),this.setAttribute("aria-busy","true"),this.#U=setTimeout(()=>{if(this.#U=null,this.#L!==q||!this.isConnected||!this.#C())return;let Q=document.createElement("fig-spinner");Q.setAttribute("data-generated",""),Q.setAttribute("data-loading-indicator",""),Q.setAttribute("slot","overlay"),Q.setAttribute("aria-hidden","true"),this.append(Q),this.#X=Q},150)}#F(){if(this.#U!==null)clearTimeout(this.#U),this.#U=null;if(this.#X?.remove(),this.#X=null,this.#L=null,this.#z!==void 0){if(this.#z===null)this.removeAttribute("aria-busy");else this.setAttribute("aria-busy",this.#z);this.#z=void 0}}#f(){if(this.#Z?.isConnected)return;let q=this.querySelector(":scope > fig-preview");if(q){this.#Z=q;return}let Q=document.createElement("fig-preview");Q.setAttribute("data-generated",""),this.prepend(Q),this.#Z=Q}#I(){let q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${q}:not([data-generated])`)}#S(){let q=this.#I();if(q){if(this.#f(),this.#q&&this.#q!==q){if(this.#P(),this.#q.hasAttribute("data-generated"))this.#q.remove()}if(this.#q=q,this.#Z&&q.parentElement!==this.#Z)this.#Z.append(q);this.#k(),this.#w();return}this.#f();let Q=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#q&&this.#q.tagName!==Q){if(this.#P(),this.#q.hasAttribute("data-generated"))this.#q.remove();this.#q=null}if(this.#q)return;if(this.mediaKind==="video"){let Z=document.createElement("video");Z.setAttribute("data-generated",""),Z.className="fig-media-element",Z.setAttribute("playsinline",""),Z.preload="auto",this.#Z.append(Z),this.#q=Z;let $=()=>{if(this.#q?.autoplay)return;try{this.#q.currentTime=0.001}catch{}};this.#q.addEventListener("loadedmetadata",$,{once:!0})}else{let Z=document.createElement("img");Z.setAttribute("data-generated",""),Z.className="fig-media-element",Z.loading="lazy",Z.decoding="async",Z.alt=this.getAttribute("alt")||"",this.#Z.append(Z),this.#q=Z}this.#k()}#w(){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 Q=this.getAttribute(q);if(Q===null)this.#q.removeAttribute(q);else this.#q.setAttribute(q,Q)})}#y(){return this.querySelector(":scope > figcaption:not([data-generated])")}#u(){return Array.from(this.querySelectorAll(":scope > figcaption[data-generated]"))}#b(){let q=this.#y(),Q=this.#u();if(q){Q.forEach((j)=>j.remove());return}let Z=this.getAttribute("caption")||"";if(!Z){Q.forEach((j)=>j.remove());return}let $=Q[0]||document.createElement("figcaption");if(Q.slice(1).forEach((j)=>j.remove()),!$.hasAttribute("data-generated"))$.setAttribute("data-generated","");if($.textContent!==Z)$.textContent=Z;let J=this.querySelector(":scope > fig-media-controls");if(J)J.before($);else if(this.#Z?.isConnected)this.#Z.after($);else if(!$.isConnected)this.append($)}#E(q,Q=!1){if(!this.hasAttribute(q))return Q;return this.getAttribute(q)!=="false"}#h(){if(!this.#q)return;if(!this.#q.hasAttribute("data-generated"))return;let q=this.#O();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.#w(),this.#V();return}let Q=this.getAttribute("poster");if(Q)this.#q.setAttribute("poster",Q);else this.#q.removeAttribute("poster");this.#q.controls=!1,this.#q.removeAttribute("controls"),this.#q.autoplay=this.#E("autoplay",!1),this.#q.loop=this.#E("loop",!1),this.#q.muted=this.#E("muted",!1),this.#q.playsInline=!0,this.#w(),this.#g(),this.#v(),this.#V()}get mediaEl(){return this.#q}#x(){if(this.mediaKind!=="video")return!1;return Boolean(this.#O())}#v(){let q=this.#M||this.querySelector(":scope > fig-media-controls");if(!q)return;if(this.mediaKind!=="video")return;if(this.#x()){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}#g(){if(this.mediaKind!=="video"){this.#l();return}let q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(q){if(this.#M!==q)this.#l(),this.#M=q;this.#d(),this.#v();return}if(this.#E("controls",!1))this.#o();else this.#l()}#o(){let q=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Q=q[0];if(q.slice(1).forEach(($)=>$.remove()),Q){this.#M=Q,this.#d(),this.#v();return}let Z=document.createElement("fig-media-controls");Z.setAttribute("data-generated",""),this.append(Z),this.#M=Z,this.#d(),this.#v()}#d(){if(!this.#M||!this.#q)return;if(this.#B===this.#q&&this.#R===this.#M){this.#v();return}this.#m();let q=this.#M,Q=this.#q;this.#B=Q,this.#R=q;let Z=null,$=()=>{if(this.#v(),!this.#x())return;if(q.playing=!Q.paused&&!Q.ended,Number.isFinite(Q.duration))q.duration=Q.duration;if(Z!==null)if(Math.abs(Q.currentTime-Z)<0.25)Z=null;else return;q.time=Q.currentTime||0},J=()=>{if(!this.#x())return;let W=Q.play?.();if(W&&typeof W.catch==="function")W.catch(()=>{})},j=()=>Q.pause?.(),_=(W)=>{if(!this.#x())return;let N=Number(W?.detail?.time);if(!Number.isFinite(N))return;Z=N;try{Q.currentTime=N}catch{}};this.#H=$,this.#D=J,this.#T=j,this.#A=_,Q.addEventListener("play",$),Q.addEventListener("pause",$),Q.addEventListener("ended",$),Q.addEventListener("timeupdate",$),Q.addEventListener("loadedmetadata",$),Q.addEventListener("durationchange",$),Q.addEventListener("seeked",$),q.addEventListener("play",J),q.addEventListener("pause",j),q.addEventListener("seek",_),$()}#m(){let q=this.#B,Q=this.#R;if(q&&this.#H)q.removeEventListener("play",this.#H),q.removeEventListener("pause",this.#H),q.removeEventListener("ended",this.#H),q.removeEventListener("timeupdate",this.#H),q.removeEventListener("loadedmetadata",this.#H),q.removeEventListener("durationchange",this.#H),q.removeEventListener("seeked",this.#H);if(Q){if(this.#D)Q.removeEventListener("play",this.#D);if(this.#T)Q.removeEventListener("pause",this.#T);if(this.#A)Q.removeEventListener("seek",this.#A)}this.#B=null,this.#R=null,this.#H=null,this.#D=null,this.#T=null,this.#A=null}#l(){this.#m(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((q)=>{q.remove()}),this.#M=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()}#s(){let q=document.createElement("fig-input-file");q.setAttribute("data-generated",""),q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),q.setAttribute("variant","overlay");let Q=this.getAttribute("label")||"Upload";if(q.setAttribute("label",this.#Q?"Replace":Q),this.#N?.name)q.setAttribute("filename",this.#N.name);else if(this.#Q)q.setAttribute("url",this.#Q);q.addEventListener("change",this.#_),this.#f(),this.#Z.append(q),this.#$=q}#p(){if(this.#$)this.#$.removeEventListener("change",this.#_),this.#$.remove(),this.#$=null}#c(q){if(q.target!==this.#$)return;let Q=q.detail?.files?.[0],Z=q.detail?.cleared===!0;if(!Q){if(this.#J)URL.revokeObjectURL(this.#J),this.#J=null;if(this.#N=null,this.#j=null,Z)this.src="";if(this.#h(),this.#$){let $=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Q?"Replace":$),this.#$.removeAttribute("filename"),this.#Q)this.#$.setAttribute("url",this.#Q);else this.#$.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#J)URL.revokeObjectURL(this.#J);if(this.#N=Q,this.#J=URL.createObjectURL(Q),this.#j=this.#J,this.#h(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Q,src:this.#J}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#$)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",Q.name),this.#$.setAttribute("label","Replace")}#r(q){if(!this.#q)return;this.dispatchEvent(new CustomEvent(q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Q||"",currentTime:this.#q.currentTime,duration:this.#q.duration}}))}#a(q){let Q=this.#q;if(!Q||q.currentTarget!==Q)return;if(Q.tagName==="IMG"&&(q.type==="load"||q.type==="error"))this.#F();let Z={src:this.#O(),media:Q,originalEvent:q};if(Q.tagName==="VIDEO")Z.currentTime=Q.currentTime,Z.duration=Q.duration,Z.readyState=Q.readyState,Z.networkState=Q.networkState,Z.error=Q.error;this.dispatchEvent(new CustomEvent(q.type,{bubbles:!0,cancelable:!1,composed:!0,detail:Z}))}#i(){this.#r("play")}#$0(){this.#r("pause")}#J0(){this.#r("ended")}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="src"){let $=Z||"",J=$&&($===this.#j||$===this.#J);if(this.#Q=$,this.#J&&!J)URL.revokeObjectURL(this.#J),this.#J=null,this.#j=null,this.#N=null;if(this.#h(),this.#$){let j=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Q?"Replace":j),this.#Q)if(this.#N?.name)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",this.#N.name);else this.#$.setAttribute("url",this.#Q),this.#$.removeAttribute("filename");else this.#$.removeAttribute("url"),this.#$.removeAttribute("filename")}}if(q==="type"){if(this.#S(),this.#h(),this.#$)this.#$.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(q))this.#w();if(q==="upload"){let $=Z!==null&&Z!=="false";if($&&!this.#$)this.#s();else if(!$)this.#p()}if(q==="loading-indicator")this.#V();if(q==="aspect-ratio")if(Z)this.style.setProperty("--fig-media-aspect-ratio",Z);else this.style.removeProperty("--fig-media-aspect-ratio");if(q==="fit")if(Z)this.style.setProperty("--fig-media-fit",Z);else this.style.removeProperty("--fig-media-fit");if(q==="label"&&this.#$){let $=this.getAttribute("label")||"Upload";this.#$.setAttribute("label",this.#Q?"Replace":$)}if(["controls","autoplay","loop","muted","poster"].includes(q))this.#h();if(q==="caption")this.#b()}}M("fig-media",G0);class Kq extends G0{get mediaKind(){return"image"}}M("fig-image",Kq);class Gq extends G0{get mediaKind(){return"video"}}M("fig-video",Gq);class Uq extends HTMLElement{static get observedAttributes(){return["src","alt","label","text","sublabel","href","target","selected","disabled","full","size","aspect-ratio","fit","label-line-clamp"]}#Q=null;#q=null;#Z=null;#$=null;#J=null;#j=!1;#N=new MutationObserver((q)=>{if(!q.some((Z)=>[...Z.addedNodes,...Z.removedNodes].some(($)=>$ instanceof Element&&($.matches("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])")||$.querySelector("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])"))))||!this.isConnected)return;this.#U(),this.#z()});connectedCallback(){this.#N.observe(this,{childList:!0,subtree:!0}),this.#U(),this.#z()}disconnectedCallback(){this.#N.disconnect()}attributeChangedCallback(){if(!this.isConnected)return;this.#U(),this.#z()}#_(){return this.getAttribute("label")??this.getAttribute("text")??""}#W(){return this.getAttribute("sublabel")??""}#Y(){let q=this.getAttribute("href");return Boolean(q)&&!z(this,"disabled")}#G(){return this.getAttribute("label-line-clamp")==="2"?"2":"1"}#K(){return Boolean(this.getAttribute("src"))}#X(){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-image:not([data-generated]), :scope > .fig-card-link > fig-media:not([data-generated]), :scope > .fig-card-link > 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])")}#U(){if(!this.#K()){this.#L();return}if(this.querySelectorAll(":scope > fig-footer[data-generated]").forEach((j)=>j.remove()),this.#q?.parentElement===this)this.#q=null;let q=this.#X();this.#j=Boolean(q);let Z=this.#Y()?"a":"div";if(!this.#Q||this.#Q.tagName.toLowerCase()!==Z){let j=document.createElement(Z);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}let $=this.#Q.querySelector(":scope > .fig-card-media");if($){while($.firstChild)this.#Q.insertBefore($.firstChild,$);$.remove()}if(q&&q.parentElement!==this.#Q)this.#Q.querySelectorAll(":scope > [data-generated]:not(fig-footer)").forEach((j)=>j.remove()),this.#Q.prepend(q),this.#Z=null;if(!this.#j){if(this.#Z=this.#Q.querySelector(":scope > fig-image[data-generated]")||null,!this.#Z)this.#Q.querySelectorAll(":scope > fig-image, :scope > fig-media, :scope > fig-preview").forEach((j)=>{if(j.hasAttribute("data-generated"))j.remove()}),this.#Z=document.createElement("fig-image"),this.#Z.setAttribute("data-generated",""),this.#Z.setAttribute("full",""),this.#Z.setAttribute("size","auto"),this.#Q.prepend(this.#Z)}if(!Boolean(this.#_()||this.#W())){this.#Q.querySelector(":scope > fig-footer[data-generated]")?.remove(),this.#q=null,this.#$=null,this.#J=null;return}if(!this.#q||!this.#q.isConnected){if(this.#q=this.#Q.querySelector(":scope > fig-footer[data-generated]"),!this.#q)this.#q=document.createElement("fig-footer"),this.#q.setAttribute("data-generated",""),this.#Q.appendChild(this.#q)}if(!this.#$||!this.#$.isConnected){if(this.#$=this.#q.querySelector(":scope > .fig-card-label[data-generated]"),!this.#$){if(this.#$=this.#Q.querySelector(":scope > .fig-card-label[data-generated]")||null,!this.#$)this.#$=document.createElement("label"),this.#$.className="fig-card-label",this.#$.setAttribute("data-generated","");this.#q.appendChild(this.#$)}}if(!this.#J||!this.#J.isConnected){if(this.#J=this.#q.querySelector(":scope > .fig-card-sublabel[data-generated]"),!this.#J){if(this.#J=this.#Q.querySelector(":scope > .fig-card-sublabel[data-generated]")||null,!this.#J)this.#J=document.createElement("label"),this.#J.className="fig-card-sublabel",this.#J.setAttribute("data-generated","");this.#$.after(this.#J)}}}#L(){let q=this.#Q||this.querySelector(":scope > .fig-card-link");if(q)q.querySelectorAll("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])").forEach((Z)=>this.insertBefore(Z,q)),q.remove();if(this.querySelectorAll(":scope > [data-generated]").forEach((Z)=>Z.remove()),this.#Q=null,this.#Z=null,this.#j=!0,this.#q=null,this.#$=null,this.#J=null,!this.#_()&&!this.#W())return;this.#q=document.createElement("fig-footer"),this.#q.setAttribute("data-generated",""),this.#$=document.createElement("label"),this.#$.className="fig-card-label",this.#$.setAttribute("data-generated",""),this.#q.appendChild(this.#$);let Q=this.#W();if(this.#J=null,Q)this.#J=document.createElement("label"),this.#J.className="fig-card-sublabel",this.#J.setAttribute("data-generated",""),this.#q.appendChild(this.#J);this.appendChild(this.#q)}#z(){if(!this.#K()){this.#M();return}if(!this.#Q)return;let q=z(this,"disabled"),Q=z(this,"selected"),Z=this.#_(),$=this.#W(),J=this.#G();if(this.style.setProperty("--fig-card-label-line-clamp",J),this.#Y()){let j=this.getAttribute("href")||"",_=this.getAttribute("target");if(this.#Q.setAttribute("href",j),_)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(Q)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 j=[Z,$].filter(Boolean).join(", ");if(j)this.setAttribute("aria-label",j);else this.removeAttribute("aria-label")}if(q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#Z&&!this.#j){let j=this.getAttribute("src"),_=this.getAttribute("alt"),W=this.getAttribute("aspect-ratio")||"1/1",N=this.getAttribute("fit")||"contain",K=_!=null?_:"";if(j)this.#Z.setAttribute("src",j);else this.#Z.removeAttribute("src");this.#Z.setAttribute("alt",K),this.#Z.setAttribute("aspect-ratio",W),this.#Z.setAttribute("fit",N),this.#Z.setAttribute("full",""),this.#Z.setAttribute("size","auto")}if(this.#$)this.#$.textContent=Z,this.#$.hidden=!Z;if(this.#J)this.#J.textContent=$,this.#J.hidden=!$;if(this.#q)this.#q.hidden=!Z&&!$}#M(){let q=z(this,"disabled"),Q=this.#_(),Z=this.#W();this.style.setProperty("--fig-card-label-line-clamp",this.#G()),this.setAttribute("role","group");let $=[Q,Z].filter(Boolean).join(", ");if($)this.setAttribute("aria-label",$);else this.removeAttribute("aria-label");if(q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#$)this.#$.textContent=Q,this.#$.hidden=!Q;if(this.#J)this.#J.textContent=Z}}M("fig-card",Uq);class Xq extends HTMLElement{#Q=null;#q=null;#Z=null;#$=null;#J=!1;#j=!1;static get observedAttributes(){return["playing","duration","time","disabled"]}connectedCallback(){this.#N(),this.#G(),this.#K(),this.#_()}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 Q=Number(q);if(!Number.isFinite(Q)||Q<0){this.removeAttribute("duration");return}this.setAttribute("duration",String(Q))}get time(){let q=Number(this.getAttribute("time"));return Number.isFinite(q)&&q>=0?q:0}set time(q){let Q=Number(q);if(!Number.isFinite(Q)||Q<0){this.removeAttribute("time");return}this.setAttribute("time",String(Q))}get disabled(){return z(this,"disabled")}set disabled(q){if(q)this.setAttribute("disabled","");else this.removeAttribute("disabled")}attributeChangedCallback(q){if(!this.#j)return;if(q==="playing")this.#G();if(q==="duration"||q==="time")this.#K();if(q==="disabled")this.#_()}#N(){if(this.#j)return;if(this.#j=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");let q=document.createElement("fig-tooltip");q.setAttribute("text","Play");let Q=document.createElement("fig-button");Q.setAttribute("variant","ghost"),Q.setAttribute("size","small"),Q.setAttribute("icon","true"),Q.setAttribute("aria-label","Play");let Z=c("play",{className:"fig-media-controls-play-icon"});Q.append(Z),q.append(Q),Q.addEventListener("click",(_)=>{_.preventDefault(),_.stopPropagation(),this.toggle()});let $=document.createElement("fig-slider");$.setAttribute("text","false"),$.setAttribute("min","0"),$.setAttribute("max",String(this.duration)),$.setAttribute("step","1"),$.setAttribute("value",String(this.time)),$.setAttribute("full",""),$.setAttribute("aria-label","Seek"),$.setAttribute("aria-valuetext",this.#Y(this.time,this.duration));let J=document.createElement("span");J.className="fig-media-controls-time",J.textContent=this.#W(this.time);let j=(_)=>{if(this.disabled){_.preventDefault?.(),_.stopPropagation();return}let W=_.currentTarget,N=Number(W?.value);if(!Number.isFinite(N))return;this.#J=!0,this.setAttribute("time",String(N)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:N}})),requestAnimationFrame(()=>{this.#J=!1})};$.addEventListener("input",j),$.addEventListener("change",j),this.append(q,$,J),this.#Q=Q,this.#q=q,this.#Z=$,this.#$=J,this.#_()}#_(){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.#Z)if(q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}#W(q){if(!Number.isFinite(q)||q<0)q=0;let Q=Math.floor(q),Z=Math.floor(Q/60),$=Q%60;return`${String(Z).padStart(2,"0")}:${String($).padStart(2,"0")}`}#Y(q,Q=0){let Z=this.#W(q);if(!Number.isFinite(Q)||Q<=0)return Z;return`${Z} of ${this.#W(Q)}`}#G(){if(!this.#Q)return;let q=this.playing;this.#Q.setAttribute("aria-label",q?"Pause":"Play"),this.#q?.setAttribute("text",q?"Pause":"Play");let Q=this.#Q.querySelector(".fig-media-controls-play-icon");if(Q)Q.setAttribute("name",q?"pause":"play")}#K(){if(!this.#Z)return;let q=this.duration;if(Number(this.#Z.getAttribute("max"))!==q)this.#Z.setAttribute("max",String(q));let Q=this.time;if(!this.#J)this.#Z.setAttribute("value",String(Q));if(this.#Z.setAttribute("aria-valuetext",this.#Y(Q,q)),this.#$)this.#$.textContent=this.#W(Q)}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()}}M("fig-media-controls",Xq);class Yq extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#Q=null;#q=null;#Z=null;#$=null;#J=null;#j=null;get files(){return this.#j}get#N(){let q=this.getAttribute("filename");if(q)return q;let Q=this.getAttribute("url");if(!Q)return"";try{let $=new URL(Q,location.href).pathname.split("/").pop();return $?decodeURIComponent($):Q}catch{return Q}}get value(){if(this.#j&&this.#j.length>0){if(this.#j.length===1)return this.#j[0].name;return`${this.#j.length} files`}return this.#N}connectedCallback(){this.#U(),this.addEventListener("dragover",this.#G),this.addEventListener("dragleave",this.#K),this.addEventListener("drop",this.#X)}disconnectedCallback(){this.#Q?.removeEventListener("change",this.#W),this.#Z?.removeEventListener("click",this.#Y),this.removeEventListener("dragover",this.#G),this.removeEventListener("dragleave",this.#K),this.removeEventListener("drop",this.#X)}attributeChangedCallback(q,Q,Z){if(Q===Z)return;this.#U()}clear(){if(this.#j=null,this.#Q)this.#Q.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#U(),this.#_({cleared:!0})}#_(q={}){let Q={files:this.#j,...q};this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#W=()=>{if(this.#Q.files.length>0)this.#j=this.#Q.files,this.removeAttribute("url"),this.#U(),this.#_()};#Y=(q)=>{q.stopPropagation(),this.clear()};#G=(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};#X=(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 Q=this.getAttribute("accepts"),Z=Array.from(q.dataTransfer.files);if(Q){let J=Q.split(",").map((j)=>j.trim().toLowerCase());Z=Z.filter((j)=>{let _="."+j.name.split(".").pop().toLowerCase(),W=j.type.toLowerCase();return J.some((N)=>N===_||N===W||N.endsWith("/*")&&W.startsWith(N.slice(0,-1)))})}if(!this.hasAttribute("multiple")||this.getAttribute("multiple")==="false")Z=Z.slice(0,1);if(Z.length===0)return;let $=new DataTransfer;if(Z.forEach((J)=>$.items.add(J)),this.#j=$.files,this.#Q)this.#Q.files=$.files;this.removeAttribute("url"),this.#U(),this.#_()};#U(){let q=this.getAttribute("accepts")||"",Q=this.getAttribute("label")||"Upload",Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("multiple")&&this.getAttribute("multiple")!=="false",J=this.getAttribute("variant")||"input",j=this.#j&&this.#j.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",j){let _=q?`Accepts ${q.split(",").map((U)=>U.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",Z)this.#J.setAttribute("disabled","");let W=document.createElement("fig-truncate");W.setAttribute("position","middle"),W.setAttribute("tooltip","");let N=this.value,K=N.lastIndexOf(".");if(K>0)W.setAttribute("tail",N.slice(K));if(W.textContent=N,this.#J.appendChild(W),this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",this.#Q.disabled=Z,q)this.#Q.setAttribute("accept",q);if($)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#W),this.#J.appendChild(this.#Q),_)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",_),this.#$.appendChild(this.#J),this.appendChild(this.#$);else this.appendChild(this.#J);let G=document.createElement("fig-tooltip");if(G.setAttribute("text","Remove"),this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",J==="overlay"?"overlay":"ghost"),this.#Z.setAttribute("icon","true"),this.#Z.setAttribute("aria-label","Remove"),this.#Z.className="fig-input-file-clear",Z)this.#Z.setAttribute("disabled","");this.#Z.replaceChildren(c("minus")),this.#Z.addEventListener("click",this.#Y),G.appendChild(this.#Z),this.appendChild(G)}else{let _=q?`Accepts ${q.split(",").map((W)=>W.trim()).join(", ")}`:"";if(_)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",_);if(this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant",J),this.#J.setAttribute("type","upload"),this.#J.textContent=Q,Z)this.#J.setAttribute("disabled","");if(this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",this.#Q.disabled=Z,q)this.#Q.setAttribute("accept",q);if($)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#W),this.#J.appendChild(this.#Q),this.#$)this.#$.appendChild(this.#J),this.appendChild(this.#$);else this.appendChild(this.#J)}}}M("fig-input-file",Yq);class y extends HTMLElement{#Q={x:0.42,y:0};#q={x:0.58,y:1};#Z={stiffness:200,damping:15,mass:1};#$="bezier";#J=2;#j=null;#N=null;#_=null;#W=null;#Y=null;#G=null;#K=null;#X=null;#U=null;#L=null;#z=null;#M=0.8;#B=200;#R=200;#H=null;#D=null;#T=null;#A=null;#O=5;#P=10;#k=10;#C=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#J=parseInt(this.getAttribute("precision")||"2"),m(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let q=this.getAttribute("value");if(q)this.#V(q);this.#L=this.#F(),this.#w(),this.#g()}disconnectedCallback(){if(this.#j=null,this.#A)this.#A.disconnect(),this.#A=null}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="aspect-ratio"){if(m(this,"--aspect-ratio",Z),this.#N)this.#o(),this.#c();return}if(q==="edit"){if(this.isConnected)this.#w();return}if(q==="value"&&Z){let $=this.#$;if(this.#V(Z),this.#L=this.#F(),$!==this.#$&&this.#S())this.#w();else{if(this.#N)this.#c();this.#q0(),this.#t()}}if(q==="precision")this.#J=parseInt(Z||"2")}get value(){if(this.#$==="spring"){let{stiffness:Q,damping:Z,mass:$}=this.#Z;return`spring(${Q}, ${Z}, ${$})`}let q=this.#J;return`${this.#Q.x.toFixed(q)}, ${this.#Q.y.toFixed(q)}, ${this.#q.x.toFixed(q)}, ${this.#q.y.toFixed(q)}`}get cssValue(){if(this.#$==="spring"){let Q=this.#f(),Z=20,$=Math.max(1,Math.floor(Q.length/20)),J=[];for(let j=0;j<Q.length;j+=$)J.push(Q[j].value.toFixed(3));if(Q.length>0)J.push(Q[Q.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.#q.x.toFixed(q)}, ${this.#q.y.toFixed(q)})`}get preset(){return this.#L}set value(q){this.setAttribute("value",q)}#V(q){let Q=q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if(Q)return this.#$="spring",this.#Z.stiffness=parseFloat(Q[1]),this.#Z.damping=parseFloat(Q[2]),this.#Z.mass=parseFloat(Q[3]),!0;let Z=q.split(",").map(($)=>parseFloat($.trim()));if(Z.length>=4&&Z.every(($)=>!isNaN($)))return this.#$="bezier",this.#Q.x=Z[0],this.#Q.y=Z[1],this.#q.x=Z[2],this.#q.y=Z[3],!0;return!1}#F(){if(this.#$==="bezier"){for(let Q of y.PRESETS){if(Q.type!=="bezier"||!Q.value)continue;if(Math.abs(this.#Q.x-Q.value[0])<0.001&&Math.abs(this.#Q.y-Q.value[1])<0.001&&Math.abs(this.#q.x-Q.value[2])<0.001&&Math.abs(this.#q.y-Q.value[3])<0.001)return Q.name}return"Custom bezier"}for(let Q of y.PRESETS){if(Q.type!=="spring"||!Q.spring)continue;if(Math.abs(this.#Z.stiffness-Q.spring.stiffness)<0.001&&Math.abs(this.#Z.damping-Q.spring.damping)<0.001&&Math.abs(this.#Z.mass-Q.spring.mass)<0.001)return Q.name}return"Custom spring"}#f(){let{stiffness:q,damping:Q,mass:Z}=this.#Z,$=0.004,J=5,j=[],_=0,W=0;for(let N=0;N<=5;N+=0.004){let K=-q*(_-1)-Q*W;if(W+=K/Z*0.004,_+=W*0.004,j.push({t:N,value:_}),N>0.1&&Math.abs(_-1)<0.0005&&Math.abs(W)<0.0005)break}return j}static#I(q,Q=24){let{stiffness:Z,damping:$,mass:J}=q,j=0.004,_=5,W=[],N=0,K=0;for(let H=0;H<=5;H+=0.004){let B=-Z*(N-1)-$*K;if(K+=B/J*0.004,N+=K*0.004,W.push({t:H,value:N}),H>0.1&&Math.abs(N-1)<0.001&&Math.abs(K)<0.001)break}let G=W[W.length-1].t||1,U=1;for(let H of W)if(H.value>U)U=H.value;let X=0;for(let H of W)if(H.value<X)X=H.value;let O=Math.max(U-X,1),R=6,L=Q-R*2,D=Math.max(1,Math.floor(W.length/30)),F="";for(let H=0;H<W.length;H+=D){let B=R+W[H].t/G*L,f=R+(1-(W[H].value-X)/O)*L;F+=(H===0?"M":"L")+B.toFixed(1)+","+f.toFixed(1)}return`<svg width="${Q}" height="${Q}" viewBox="0 0 ${Q} ${Q}" fill="none"><path d="${F}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(q,Q,Z,$,J=24){let _=(J-12)/2,W=48,N=[],K=(B,f,I,S,x)=>{let w=1-x;return w*w*w*B+3*w*w*x*f+3*w*x*x*I+x*x*x*S};for(let B=0;B<=48;B++){let f=B/48;N.push({x:K(0,q,Z,1,f),y:K(0,Q,$,1,f)})}let G=1/0,U=-1/0,X=1/0,O=-1/0;for(let B of N){if(B.x<G)G=B.x;if(B.x>U)U=B.x;if(B.y<X)X=B.y;if(B.y>O)O=B.y}let R=Math.max(U-G,0.000001),L=Math.max(O-X,0.000001),D=(B)=>_+(B-G)/R*12,F=(B)=>_+(1-(B-X)/L)*12,H="";for(let B=0;B<N.length;B++){let f=D(N[B].x),I=F(N[B].y);H+=`${B===0?"M":"L"}${f.toFixed(1)},${I.toFixed(1)}`}return`<svg width="${J}" height="${J}" viewBox="0 0 ${J} ${J}" fill="none"><path d="${H}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#S(){return this.getAttribute("edit")!=="false"}#w(){if(this.classList.toggle("spring-mode",this.#$==="spring"),this.classList.toggle("bezier-mode",this.#$!=="spring"),this.#h(),this.innerHTML=this.#b(),this.#x(),this.#N)this.#v(),this.#o(),this.#c();this.#t(),this.#Y0()}static#y(q){return String(q).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#u(){let q="",Q=void 0;for(let $ of y.PRESETS){if(!this.#S()&&!$.value&&!$.spring)continue;if($.group!==Q){if($.group)q+=`<fig-separator label="${y.#y($.group)}"></fig-separator>`;Q=$.group}let J;if($.type==="spring"){let _=$.spring||this.#Z;J=y.#I(_)}else{let _=$.value||[this.#Q.x,this.#Q.y,this.#q.x,this.#q.y];J=y.curveIcon(..._)}let j=y.#y($.name);q+=`<fig-select-option value="${j}" label="${j}"><span slot="prepend">${J}</span><span>${j}</span></fig-select-option>`}return`<fig-select class="fig-easing-curve-select" label="Easing preset" value="${y.#y(this.#L)}" full><fig-select-options>${q}</fig-select-options></fig-select>`}#b(){let Q=this.#u();if(!this.#S())return Q;let Z=`<fig-input-text class="fig-easing-curve-value-input" value="${y.#y(this.value)}" full></fig-input-text>`;if(this.#$==="spring")return`${Q}<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"/>
284
284
  <foreignObject class="fig-easing-curve-handle" data-handle="bounce" width="20" height="20"><fig-handle size="small" aria-label="Spring bounce handle"></fig-handle></foreignObject>
285
285
  <foreignObject class="fig-easing-curve-handle fig-easing-curve-duration-bar" data-handle="duration" width="20" height="20"><fig-handle size="small" aria-label="Spring duration handle"></fig-handle></foreignObject>
286
- </svg></div>${$}`;return`${Z}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
286
+ </svg></div>${Z}`;return`${Q}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
287
287
  <rect class="fig-easing-curve-bounds" x="0" y="0" width="200" height="200"/>
288
288
  <line class="fig-easing-curve-boundary" data-boundary="top" x1="0" y1="0" x2="200" y2="0"/>
289
289
  <line class="fig-easing-curve-boundary" data-boundary="bottom" x1="0" y1="200" x2="200" y2="200"/>
@@ -292,13 +292,13 @@ var w1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var v1={};var P0=w1(()=>{/*! 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}#m(){this.#I=this.#V("--easing-duration-bar-radius",this.#I)}#x(){this.#Y=this.querySelector(".fig-easing-curve-svg"),this.#_=this.querySelector(".fig-easing-curve-path"),this.#X=this.querySelector('[data-arm="1"]'),this.#U=this.querySelector('[data-arm="2"]'),this.#G=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#K=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#N=this.querySelector(".fig-easing-curve-select"),this.#W=this.querySelector(".fig-easing-curve-value-input"),this.#F=this.querySelector(".fig-easing-curve-target"),this.#A=this.querySelector(".fig-easing-curve-bounds"),this.#P=this.querySelector('[data-boundary="top"]'),this.#D=this.querySelector('[data-boundary="bottom"]')}#c(){let Q=this.#G?.querySelector("fig-handle"),Z=this.#K?.querySelector("fig-handle");if(Q){let $=Q.offsetWidth||this.#O*2,J=Q.offsetHeight||this.#O*2;this.#O=Math.max($,J)/2,this.#G.setAttribute("width",$),this.#G.setAttribute("height",J)}if(Z){let $=Z.offsetWidth||this.#T,J=Z.offsetHeight||this.#S;if(this.#J==="spring")this.#T=$,this.#S=J;this.#K.setAttribute("width",$),this.#K.setAttribute("height",J)}}#g(){if(this.#H||!window.ResizeObserver)return;this.#H=new ResizeObserver(()=>{if(this.#d())this.#u()}),this.#H.observe(this)}#d(){if(!this.#Y)return!1;let Q=this.#Y.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.#Y.setAttribute("viewBox",`0 0 ${Z} ${$}`),J}#s(){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.#O,Math.max(0,(this.#M-1)/2));return{minVal:Q,maxVal:Z,range:$,pad:J,draw:Math.max(1,this.#M-J*2)}}#h(Q,Z){let{maxVal:$,range:J,pad:j,draw:q}=this.#s();return{x:Q*this.#B,y:j+($-Z)/J*q}}#t(Q,Z){let{maxVal:$,range:J,pad:j,draw:q}=this.#s();return{x:Q/this.#B,y:$-(Z-j)/q*J}}#i={minVal:0,maxVal:1.2,totalTime:1};#p(Q,Z){let J=this.#M-40,{minVal:j,maxVal:q}=this.#i,_=q-j||1;return{x:Q*this.#B,y:20+(1-(Z-j)/_)*J}}#u(){if(this.#d(),this.#J==="spring")this.#j0();else this.#n()}#o(){this.#X?.classList.toggle("is-active",this.#J==="bezier"&&this.#q===1),this.#U?.classList.toggle("is-active",this.#J==="bezier"&&this.#q===2)}#n(){if(this.#A)this.#A.setAttribute("x","0"),this.#A.setAttribute("y","0"),this.#A.setAttribute("width",this.#B),this.#A.setAttribute("height",this.#M);let Q=this.#h(0,0),Z=this.#h(this.#Q.x,this.#Q.y),$=this.#h(this.#Z.x,this.#Z.y),J=this.#h(1,1);for(let[q,_]of[[this.#P,J.y],[this.#D,Q.y]]){if(!q)continue;q.setAttribute("x1","0"),q.setAttribute("y1",_),q.setAttribute("x2",this.#B),q.setAttribute("y2",_)}this.#_.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.#U.setAttribute("x1",J.x),this.#U.setAttribute("y1",J.y),this.#U.setAttribute("x2",$.x),this.#U.setAttribute("y2",$.y);let j=this.#O;this.#G.setAttribute("x",Z.x-j),this.#G.setAttribute("y",Z.y-j),this.#K.setAttribute("x",$.x-j),this.#K.setAttribute("y",$.y-j),this.#r()}#r(){if(!this.#Y||!this.#G||!this.#K)return;let Q=this.#Q.y>=this.#Z.y?[this.#G,this.#K]:[this.#K,this.#G];for(let Z of Q)this.#Y.append(Z)}#j0(){if(this.#A)this.#A.setAttribute("x","0"),this.#A.setAttribute("y","0"),this.#A.setAttribute("width",this.#B),this.#A.setAttribute("height",this.#M);let Q=this.#C();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.#i={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.#p(T,Q[L].value);X+=(L===0?"M":"L")+R.x.toFixed(1)+","+R.y.toFixed(1)}let Y=this.#p(_,1),K=this.#p(1,1);if(X+=`L${Y.x.toFixed(1)},${Y.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#_.setAttribute("d",X),this.#F){let L=this.#p(0,1),T=this.#p(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.#p(N,G.value),O=this.#O;this.#G.setAttribute("x",W.x-O),this.#G.setAttribute("y",W.y-O);let B=this.#p(_,1);this.#K.setAttribute("x",B.x-this.#T/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}#Q0(){if(!this.#N)return;this.#N.value=this.#L,this.#a()}#l(){if(!this.#W)return;this.#W.setAttribute("value",this.value)}#_0(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}#J0(Q,Z){let $=this.#_0(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.#R(),J!==this.#J)this.#y();else if(this.#u(),this.#Q0(),Z==="change")this.#l();this.#$0(Z)}#e(Q,Z){if(!this.#N)return;for(let $ of this.#N.querySelectorAll("fig-select-option"))if($.value===Q){let J=$.querySelector(':scope > [slot="prepend"]');if(J)J.innerHTML=Z}}#a(){if(!this.#N)return;if(!this.#k())return;let Q=w.curveIcon(this.#Q.x,this.#Q.y,this.#Z.x,this.#Z.y),Z=w.#E(this.#$);this.#e("Custom bezier",Q),this.#e("Custom spring",Z)}#Z0(Q){this.#u(),this.#L=this.#R(),this.#Q0(),this.#l(),this.#$0(Q)}#Y0(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.#Z0("input"),this.#$0("change"),!0}#K0(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.#Z0("input"),this.#$0("change"),!0}#X0(Q,Z){let $=Q?.querySelector("fig-handle");if(!$)return;$.addEventListener("pointerdown",(J)=>{if(J.preventDefault(),J.stopImmediatePropagation(),this.#J==="bezier")this.#G0(J,Number(Z));else this.#N0(J,Z)},{capture:!0}),$.addEventListener("keydown",(J)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(J.key))return;if(!(this.#J==="bezier"?this.#Y0(J,Number(Z)):this.#K0(J,Z)))return;J.preventDefault(),J.stopImmediatePropagation()},{capture:!0})}#$0(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#J,value:this.value,cssValue:this.cssValue,preset:this.#L}}))}#U0(){if(this.#Y&&this.#J==="bezier"){this.#X0(this.#G,"1"),this.#X0(this.#K,"2"),this.#G.addEventListener("pointerdown",(Z)=>this.#G0(Z,1)),this.#K.addEventListener("pointerdown",(Z)=>this.#G0(Z,2));let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",(Z)=>{if(Z.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#G0(Z,this.#L0(Z))})}else if(this.#Y){this.#X0(this.#G,"bounce"),this.#X0(this.#K,"duration"),this.#G.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#N0(Z,"bounce")}),this.#K.addEventListener("pointerdown",(Z)=>{Z.stopPropagation(),this.#N0(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.#N0(Z,"duration")})}if(this.#N)this.#N.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.#Y)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.#Y)this.#u(),this.#l()}this.#$0("input"),this.#$0("change")});if(this.#W)this.#W.addEventListener("input",(Q)=>{Q.stopPropagation();let Z=Q.detail??Q.target?.value;if(typeof Z!=="string")return;this.#J0(Z,"input")}),this.#W.addEventListener("change",(Q)=>{Q.stopPropagation();let Z=Q.detail??Q.target?.value;if(typeof Z!=="string")return;this.#J0(Z,"change")})}#W0(Q){let Z=this.#Y.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.#W0(Q).x<=this.#B/2?1:2}#G0(Q,Z){Q.preventDefault(),this.#q=Z,this.#o();let $=this.#Y.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.#W0(Q),Y=q?{..._}:this.#t(X.x,X.y),{range:K,draw:G}=this.#s(),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.#R(),this.#Q0(),this.#l(),this.#$0("input")},O=()=>{this.#q=null,this.#o(),document.removeEventListener("pointermove",W),document.removeEventListener("pointerup",O),this.#$0("change")};document.addEventListener("pointermove",W),document.addEventListener("pointerup",O)}#N0(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.#R(),this.#Q0(),this.#l(),this.#$0("input")},Y=()=>{this.#q=null,this.classList.remove("spring-bounce-dragging"),document.removeEventListener("pointermove",X),document.removeEventListener("pointerup",Y),this.#$0("change")};document.addEventListener("pointermove",X),document.addEventListener("pointerup",Y)}}z("fig-easing-curve",w);class W1 extends HTMLElement{#Q=0;#Z=0;#$=0;#J=1;#j=!1;#q=!1;#Y=null;#_=null;#X=null;#U=null;#G=(Q)=>this.#E(Q);#K=null;#N=[];#W={};#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.#P(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#D(Q);if(this.querySelector(".fig-3d-rotate-container"))this.#F();else this.#H();this.#A(this.getAttribute("selected")),this.#M()}disconnectedCallback(){this.#j=!1,this.#z()}#F(){this.#_=this.querySelector(".fig-3d-rotate-container"),this.#Y=this.querySelector(".fig-3d-rotate-cube"),this.#O(),this.#S(),this.#R()}#z(){if(this.#K?.abort(),this.#K=null,this.#X)window.removeEventListener("keydown",this.#X),window.removeEventListener("keyup",this.#U),this.#X=null,this.#U=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.#_)return;this.#_.style.cursor=this.#C?"":"default"}#A(Q){if(!this.#Y)return;let Z=this.#Y.querySelectorAll(".fig-3d-rotate-face"),$=Q?Q.trim().toLowerCase():"";for(let J of Z)J.classList.toggle("selected",$!==""&&J.classList.contains($))}#P(Q){if(!Q||!Q.trim()){this.#N=[];return}let Z=["rotateX","rotateY","rotateZ"];this.#N=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.#A($);return}if(Q==="drag"){this.#M();return}if(Q==="fields"){if(this.#P($),this.#Y)this.#H();return}if(!this.#Y)return;if(Q==="value"&&$){if(this.#j)return;this.#D($),this.#S(),this.#T()}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.#$}#D(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])}#H(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},Z={rotateX:this.#Q,rotateY:this.#Z,rotateZ:this.#$},$=this.#N.map((J)=>`<fig-input-number
296
- name="${J}"
295
+ </svg></div>${Z}`}#E(q,Q){let Z=getComputedStyle(this).getPropertyValue(q).trim();if(!Z)return Q;let $=Number.parseFloat(Z);return Number.isFinite($)?$:Q}#h(){this.#C=this.#E("--easing-duration-bar-radius",this.#C)}#x(){this.#N=this.querySelector(".fig-easing-curve-svg"),this.#_=this.querySelector(".fig-easing-curve-path"),this.#W=this.querySelector('[data-arm="1"]'),this.#Y=this.querySelector('[data-arm="2"]'),this.#G=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#K=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#X=this.querySelector(".fig-easing-curve-select"),this.#U=this.querySelector(".fig-easing-curve-value-input"),this.#z=this.querySelector(".fig-easing-curve-target"),this.#H=this.querySelector(".fig-easing-curve-bounds"),this.#D=this.querySelector('[data-boundary="top"]'),this.#T=this.querySelector('[data-boundary="bottom"]')}#v(){let q=this.#G?.querySelector("fig-handle"),Q=this.#K?.querySelector("fig-handle");if(q){let Z=q.offsetWidth||this.#O*2,$=q.offsetHeight||this.#O*2;this.#O=Math.max(Z,$)/2,this.#G.setAttribute("width",Z),this.#G.setAttribute("height",$)}if(Q){let Z=Q.offsetWidth||this.#P,$=Q.offsetHeight||this.#k;if(this.#$==="spring")this.#P=Z,this.#k=$;this.#K.setAttribute("width",Z),this.#K.setAttribute("height",$)}}#g(){if(this.#A||!window.ResizeObserver)return;this.#A=new ResizeObserver(()=>{if(this.#o())this.#c()}),this.#A.observe(this)}#o(){if(!this.#N)return!1;let q=this.#N.getBoundingClientRect(),Q=Math.max(1,Math.round(q.width||200)),Z=Math.max(1,Math.round(q.height||200)),$=Q!==this.#B||Z!==this.#R;return this.#B=Q,this.#R=Z,this.#N.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#d(){let q=Math.min(0,this.#Q.y,this.#q.y),Q=Math.max(1,this.#Q.y,this.#q.y),Z=Q-q||1,$=Math.min(this.#O,Math.max(0,(this.#R-1)/2));return{minVal:q,maxVal:Q,range:Z,pad:$,draw:Math.max(1,this.#R-$*2)}}#m(q,Q){let{maxVal:Z,range:$,pad:J,draw:j}=this.#d();return{x:q*this.#B,y:J+(Z-Q)/$*j}}#l(q,Q){let{maxVal:Z,range:$,pad:J,draw:j}=this.#d();return{x:q/this.#B,y:Z-(Q-J)/j*$}}#s={minVal:0,maxVal:1.2,totalTime:1};#p(q,Q){let $=this.#R-40,{minVal:J,maxVal:j}=this.#s,_=j-J||1;return{x:q*this.#B,y:20+(1-(Q-J)/_)*$}}#c(){if(this.#o(),this.#$==="spring")this.#$0();else this.#a()}#r(){this.#W?.classList.toggle("is-active",this.#$==="bezier"&&this.#j===1),this.#Y?.classList.toggle("is-active",this.#$==="bezier"&&this.#j===2)}#a(){if(this.#H)this.#H.setAttribute("x","0"),this.#H.setAttribute("y","0"),this.#H.setAttribute("width",this.#B),this.#H.setAttribute("height",this.#R);let q=this.#m(0,0),Q=this.#m(this.#Q.x,this.#Q.y),Z=this.#m(this.#q.x,this.#q.y),$=this.#m(1,1);for(let[j,_]of[[this.#D,$.y],[this.#T,q.y]]){if(!j)continue;j.setAttribute("x1","0"),j.setAttribute("y1",_),j.setAttribute("x2",this.#B),j.setAttribute("y2",_)}this.#_.setAttribute("d",`M${q.x},${q.y} C${Q.x},${Q.y} ${Z.x},${Z.y} ${$.x},${$.y}`),this.#W.setAttribute("x1",q.x),this.#W.setAttribute("y1",q.y),this.#W.setAttribute("x2",Q.x),this.#W.setAttribute("y2",Q.y),this.#Y.setAttribute("x1",$.x),this.#Y.setAttribute("y1",$.y),this.#Y.setAttribute("x2",Z.x),this.#Y.setAttribute("y2",Z.y);let J=this.#O;this.#G.setAttribute("x",Q.x-J),this.#G.setAttribute("y",Q.y-J),this.#K.setAttribute("x",Z.x-J),this.#K.setAttribute("y",Z.y-J),this.#i()}#i(){if(!this.#N||!this.#G||!this.#K)return;let q=this.#Q.y>=this.#q.y?[this.#G,this.#K]:[this.#K,this.#G];for(let Q of q)this.#N.append(Q)}#$0(){if(this.#H)this.#H.setAttribute("x","0"),this.#H.setAttribute("y","0"),this.#H.setAttribute("width",this.#B),this.#H.setAttribute("height",this.#R);let q=this.#f();if(!q.length)return;let Q=q[q.length-1].t||1,Z=0,$=1;for(let L of q){if(L.value<Z)Z=L.value;if(L.value>$)$=L.value}let J=Math.max(Math.abs(Z-1),Math.abs($-1),0.01),j=0;this.#s={minVal:1-J-j,maxVal:1+J+j,totalTime:Q};let _=Math.max(0.05,Math.min(0.95,this.#M)),W="";for(let L=0;L<q.length;L++){let D=q[L].t/Q*_,F=this.#p(D,q[L].value);W+=(L===0?"M":"L")+F.x.toFixed(1)+","+F.y.toFixed(1)}let N=this.#p(_,1),K=this.#p(1,1);if(W+=`L${N.x.toFixed(1)},${N.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#_.setAttribute("d",W),this.#z){let L=this.#p(0,1),D=this.#p(1,1);this.#z.setAttribute("x1",L.x),this.#z.setAttribute("y1",L.y),this.#z.setAttribute("x2",D.x),this.#z.setAttribute("y2",D.y)}let G=this.#J0(q),U=G.t/Q*_,X=this.#p(U,G.value),O=this.#O;this.#G.setAttribute("x",X.x-O),this.#G.setAttribute("y",X.y-O);let R=this.#p(_,1);this.#K.setAttribute("x",R.x-this.#P/2),this.#K.setAttribute("y",R.y-this.#k/2)}#J0(q){let Q={t:0,value:1},Z=!1;for(let $ of q){if($.value>=0.99)Z=!0;if(Z&&$.value>Q.value)Q={t:$.t,value:$.value}}return Q}#q0(){if(!this.#X)return;this.#X.value=this.#L,this.#n()}#t(){if(!this.#U)return;this.#U.setAttribute("value",this.value)}#_0(q){let Q=q.split(",").map((Z)=>Number.parseFloat(Z.trim()));if(Q.length!==4||Q.some((Z)=>!Number.isFinite(Z)))return null;if(Q[0]<0||Q[0]>1||Q[2]<0||Q[2]>1)return null;return Q}#j0(q,Q){let Z=this.#_0(q);if(!Z){if(Q==="change")this.#t();return}let $=this.#$;if(this.#$="bezier",this.#Q.x=Z[0],this.#Q.y=Z[1],this.#q.x=Z[2],this.#q.y=Z[3],this.#L=this.#F(),$!==this.#$)this.#w();else if(this.#c(),this.#q0(),Q==="change")this.#t();this.#Z0(Q)}#e(q,Q){if(!this.#X)return;for(let Z of this.#X.querySelectorAll("fig-select-option"))if(Z.value===q){let $=Z.querySelector(':scope > [slot="prepend"]');if($)$.innerHTML=Q}}#n(){if(!this.#X)return;if(!this.#S())return;let q=y.curveIcon(this.#Q.x,this.#Q.y,this.#q.x,this.#q.y),Q=y.#I(this.#Z);this.#e("Custom bezier",q),this.#e("Custom spring",Q)}#Q0(q){this.#c(),this.#L=this.#F(),this.#q0(),this.#t(),this.#Z0(q)}#N0(q,Q){let Z=q.shiftKey?0.1:0.01,$=Q===1?this.#Q:this.#q;switch(q.key){case"ArrowLeft":$.x-=Z;break;case"ArrowRight":$.x+=Z;break;case"ArrowUp":$.y+=Z;break;case"ArrowDown":$.y-=Z;break;case"Home":$.x=0,$.y=0;break;case"End":$.x=1,$.y=1;break;default:return!1}return $.x=Math.max(0,Math.min(1,Math.round($.x*100)/100)),$.y=Math.round($.y*100)/100,this.#Q0("input"),this.#Z0("change"),!0}#K0(q,Q){let Z=q.shiftKey?10:1;if(Q==="bounce")switch(q.key){case"ArrowUp":this.#Z.damping=Math.max(1,Math.round(this.#Z.damping-Z));break;case"ArrowDown":this.#Z.damping=Math.max(1,Math.round(this.#Z.damping+Z));break;case"Home":this.#Z.damping=1;break;case"End":this.#Z.damping=50;break;default:return!1}else{let $=Z*2;switch(q.key){case"ArrowLeft":this.#M=Math.max(0.05,this.#M-$/200),this.#Z.stiffness=Math.max(10,Math.round(this.#Z.stiffness+$*1.5));break;case"ArrowRight":this.#M=Math.min(0.95,this.#M+$/200),this.#Z.stiffness=Math.max(10,Math.round(this.#Z.stiffness-$*1.5));break;case"Home":this.#M=0.05;break;case"End":this.#M=0.95;break;default:return!1}}return this.#Q0("input"),this.#Z0("change"),!0}#W0(q,Q){let Z=q?.querySelector("fig-handle");if(!Z)return;Z.addEventListener("pointerdown",($)=>{if($.preventDefault(),$.stopImmediatePropagation(),this.#$==="bezier")this.#G0($,Number(Q));else this.#U0($,Q)},{capture:!0}),Z.addEventListener("keydown",($)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!(this.#$==="bezier"?this.#N0($,Number(Q)):this.#K0($,Q)))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#Z0(q){this.dispatchEvent(new CustomEvent(q,{bubbles:!0,detail:{mode:this.#$,value:this.value,cssValue:this.cssValue,preset:this.#L}}))}#Y0(){if(this.#N&&this.#$==="bezier"){this.#W0(this.#G,"1"),this.#W0(this.#K,"2"),this.#G.addEventListener("pointerdown",(Q)=>this.#G0(Q,1)),this.#K.addEventListener("pointerdown",(Q)=>this.#G0(Q,2));let q=this.querySelector(".fig-easing-curve-svg-container");if(q)q.addEventListener("pointerdown",(Q)=>{if(Q.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#G0(Q,this.#L0(Q))})}else if(this.#N){this.#W0(this.#G,"bounce"),this.#W0(this.#K,"duration"),this.#G.addEventListener("pointerdown",(Q)=>{Q.stopPropagation(),this.#U0(Q,"bounce")}),this.#K.addEventListener("pointerdown",(Q)=>{Q.stopPropagation(),this.#U0(Q,"duration")});let q=this.querySelector(".fig-easing-curve-svg-container");if(q)q.addEventListener("pointerdown",(Q)=>{if(Q.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#U0(Q,"duration")})}if(this.#X)this.#X.addEventListener("change",(q)=>{let Q=q.detail,Z=y.PRESETS.find(($)=>$.name===Q);if(!Z)return;if(Z.type==="bezier"){if(Z.value)this.#Q.x=Z.value[0],this.#Q.y=Z.value[1],this.#q.x=Z.value[2],this.#q.y=Z.value[3];if(this.#L=Q,this.#$!=="bezier")this.#$="bezier",this.#w();else if(this.#N)this.#c(),this.#t()}else if(Z.type==="spring"){if(Z.spring)this.#Z={...Z.spring};if(this.#L=Q,this.#$!=="spring")this.#$="spring",this.#w();else if(this.#N)this.#c(),this.#t()}this.#Z0("input"),this.#Z0("change")});if(this.#U)this.#U.addEventListener("input",(q)=>{q.stopPropagation();let Q=q.detail??q.target?.value;if(typeof Q!=="string")return;this.#j0(Q,"input")}),this.#U.addEventListener("change",(q)=>{q.stopPropagation();let Q=q.detail??q.target?.value;if(typeof Q!=="string")return;this.#j0(Q,"change")})}#X0(q){let Q=this.#N.getScreenCTM();if(!Q)return{x:0,y:0};let Z=Q.inverse();return{x:Z.a*q.clientX+Z.c*q.clientY+Z.e,y:Z.b*q.clientX+Z.d*q.clientY+Z.f}}#L0(q){return this.#X0(q).x<=this.#B/2?1:2}#G0(q,Q){q.preventDefault(),this.#j=Q,this.#r();let Z=this.#N.getBoundingClientRect(),$=q.clientX,J=q.clientY,j=q.target?.closest?.(".fig-easing-curve-handle, fig-handle"),_=Q===1?this.#Q:this.#q,W=this.#X0(q),N=j?{..._}:this.#l(W.x,W.y),{range:K,draw:G}=this.#d(),U=K/Math.max(1,G/this.#R*Math.max(1,Z.height)),X=(R)=>{if(!this.#j)return;let L={x:N.x+(R.clientX-$)/Math.max(1,Z.width),y:N.y-(R.clientY-J)*U};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.#j===1)this.#Q.x=L.x,this.#Q.y=L.y;else this.#q.x=L.x,this.#q.y=L.y;this.#c(),this.#L=this.#F(),this.#q0(),this.#t(),this.#Z0("input")},O=()=>{this.#j=null,this.#r(),document.removeEventListener("pointermove",X),document.removeEventListener("pointerup",O),this.#Z0("change")};document.addEventListener("pointermove",X),document.addEventListener("pointerup",O)}#U0(q,Q){q.preventDefault(),this.#j=Q,this.classList.toggle("spring-bounce-dragging",Q==="bounce");let Z=this.#Z.damping,$=this.#Z.stiffness,J=this.#M,j=q.clientY,_=q.clientX,W=(K)=>{if(!this.#j)return;if(Q==="bounce"){let G=K.clientY-j;this.#Z.damping=Math.max(1,Math.round(Z+G*0.15))}else{let G=K.clientX-_;this.#M=Math.max(0.05,Math.min(0.95,J+G/200)),this.#Z.stiffness=Math.max(10,Math.round($-G*1.5))}this.#c(),this.#L=this.#F(),this.#q0(),this.#t(),this.#Z0("input")},N=()=>{this.#j=null,this.classList.remove("spring-bounce-dragging"),document.removeEventListener("pointermove",W),document.removeEventListener("pointerup",N),this.#Z0("change")};document.addEventListener("pointermove",W),document.addEventListener("pointerup",N)}}M("fig-easing-curve",y);class Lq extends HTMLElement{#Q=0;#q=0;#Z=0;#$=1;#J=!1;#j=!1;#N=null;#_=null;#W=null;#Y=null;#G=(q)=>this.#I(q);#K=null;#X=[];#U={};#L={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#$=parseInt(this.getAttribute("precision")||"1"),m(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),m(this,"--perspective",this.getAttribute("perspective")),m(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#B(this.getAttribute("transform-origin")),this.#D(this.getAttribute("fields"));let q=this.getAttribute("value");if(q)this.#T(q);if(this.querySelector(".fig-3d-rotate-container"))this.#z();else this.#A();this.#H(this.getAttribute("selected")),this.#R()}disconnectedCallback(){this.#J=!1,this.#M()}#z(){this.#_=this.querySelector(".fig-3d-rotate-container"),this.#N=this.querySelector(".fig-3d-rotate-cube"),this.#O(),this.#k(),this.#F()}#M(){if(this.#K?.abort(),this.#K=null,this.#W)window.removeEventListener("keydown",this.#W),window.removeEventListener("keyup",this.#Y),this.#W=null,this.#Y=null}#B(q){if(!q||!q.trim()){this.style.removeProperty("--transform-origin");return}let Q=q.trim().split(/\s+/);if(Q.length===2)this.style.setProperty("--transform-origin",`${Q[0]} ${Q[1]} -50cqi`);else this.style.setProperty("--transform-origin",q.trim())}#R(){if(!this.#_)return;this.#_.style.cursor=this.#f?"":"default"}#H(q){if(!this.#N)return;let Q=this.#N.querySelectorAll(".fig-3d-rotate-face"),Z=q?q.trim().toLowerCase():"";for(let $ of Q)$.classList.toggle("selected",Z!==""&&$.classList.contains(Z))}#D(q){if(!q||!q.trim()){this.#X=[];return}let Q=["rotateX","rotateY","rotateZ"];this.#X=q.split(",").map((Z)=>Z.trim()).filter((Z)=>Q.includes(Z))}attributeChangedCallback(q,Q,Z){if(q==="aspect-ratio"){m(this,"--aspect-ratio",Z);return}if(q==="perspective"){m(this,"--perspective",Z);return}if(q==="perspective-origin"){m(this,"--perspective-origin",Z);return}if(q==="transform-origin"){this.#B(Z);return}if(q==="selected"){this.#H(Z);return}if(q==="drag"){this.#R();return}if(q==="fields"){if(this.#D(Z),this.#N)this.#A();return}if(!this.#N)return;if(q==="value"&&Z){if(this.#J)return;this.#T(Z),this.#k(),this.#P()}if(q==="precision")this.#$=parseInt(Z||"1")}get value(){let q=this.#$;return`rotateX(${this.#Q.toFixed(q)}deg) rotateY(${this.#q.toFixed(q)}deg) rotateZ(${this.#Z.toFixed(q)}deg)`}set value(q){this.setAttribute("value",q)}get rotateX(){return this.#Q}get rotateY(){return this.#q}get rotateZ(){return this.#Z}#T(q){let Q=q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),Z=q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),$=q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if(Q)this.#Q=parseFloat(Q[1]);if(Z)this.#q=parseFloat(Z[1]);if($)this.#Z=parseFloat($[1])}#A(){let q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},Q={rotateX:this.#Q,rotateY:this.#q,rotateZ:this.#Z},Z=this.#X.map(($)=>`<fig-input-number
296
+ name="${$}"
297
297
  step="1"
298
298
  precision="1"
299
- value="${Z[J]}"
299
+ value="${Q[$]}"
300
300
  units="°">
301
- <span slot="prepend">${Q[J]}</span>
301
+ <span slot="prepend">${q[$]}</span>
302
302
  </fig-input-number>`).join("");this.innerHTML=`<div class="fig-3d-rotate-container" tabindex="0">
303
303
  <div class="fig-3d-rotate-scene">
304
304
  <div class="fig-3d-rotate-cube">
@@ -310,20 +310,20 @@ var w1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var v1={};var P0=w1(()=>{/*! Vendored from @
310
310
  <div class="fig-3d-rotate-face bottom"></div>
311
311
  </div>
312
312
  </div>
313
- </div>${$}`,this.#_=this.querySelector(".fig-3d-rotate-container"),this.#Y=this.querySelector(".fig-3d-rotate-cube"),this.#O(),this.#S(),this.#R()}#O(){this.#W={};for(let Q of this.#N){let Z=this.querySelector(`fig-input-number[name="${Q}"]`);if(!Z)continue;if(this.#W[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.#I(J.type)};let $=this.#L[Q];Z.removeEventListener("input",$),Z.removeEventListener("change",$),Z.addEventListener("input",$),Z.addEventListener("change",$)}}#T(){let Q={rotateX:this.#Q,rotateY:this.#Z,rotateZ:this.#$};for(let Z of this.#N){let $=this.#W[Z];if($)$.setAttribute("value",Q[Z].toFixed(this.#J))}}#S(){if(!this.#Y)return;this.#Y.style.transform=`rotateX(${this.#Q}deg) rotateY(${this.#Z}deg) rotateZ(${this.#$}deg)`}#I(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#Q,rotateY:this.#Z,rotateZ:this.#$}}))}#f(Q){if(!this.#q)return Q;return Math.round(Q/15)*15}#R(){if(this.#z(),!this.#_)return;this.#K=new AbortController,this.#_.addEventListener("pointerdown",this.#G,{signal:this.#K.signal}),this.#X=(Q)=>{if(Q.key==="Shift")this.#q=!0},this.#U=(Q)=>{if(Q.key==="Shift")this.#q=!1},window.addEventListener("keydown",this.#X),window.addEventListener("keyup",this.#U)}get#C(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#E(Q){if(!this.#C)return;Q.preventDefault(),this.#j=!0,this.#_.classList.add("dragging"),this.#_.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.#f(j+Y*0.5),this.#Q=this.#f(J-K*0.5),this.#S(),this.#T(),this.setAttribute("value",this.value),this.#I("input")},_=()=>{if(!this.#j)return;this.setAttribute("value",this.value),this.#j=!1,this.#_.classList.remove("dragging"),this.#_.removeEventListener("pointermove",q),this.#_.removeEventListener("pointerup",_),this.#_.removeEventListener("pointercancel",_),this.#_.removeEventListener("lostpointercapture",_),this.#I("change")};this.#_.addEventListener("pointermove",q),this.#_.addEventListener("pointerup",_),this.#_.addEventListener("pointercancel",_),this.#_.addEventListener("lostpointercapture",_)}}z("fig-3d-rotate",W1);class z0 extends HTMLElement{#Q=50;#Z=50;#$=0;#J=null;#j=[];#q=null;#Y=null;#_=null;#X=!1;#U=!1;#G=null;#K=null;#N=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"]}#W(){this.#J=this.querySelector(".origin-grid"),this.#j=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#Y=this.querySelector('fig-input-number[name="x"]'),this.#_=this.querySelector('fig-input-number[name="y"]'),this.#S(),this.#I(),this.#H(),this.#g()}connectedCallback(){if(this.#$=parseInt(this.getAttribute("precision")||"0"),b(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#P(this.getAttribute("value")),this.querySelector(".fig-origin-grid-surface"))this.#W();else this.#D();this.#z(),this.#O()}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.#D(),this.#z(),this.#O();return}if(Q==="precision"){this.#$=parseInt($||"0"),this.#H(),this.#O();return}if(Q==="value"){if(this.#U||this.#X)return;this.#P($),this.#S(),this.#I(),this.#H()}}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}#A(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")}#P(Q){let Z=typeof Q==="string"?Q.trim():"";if(!Z){this.#Q=50,this.#Z=50;return}this.#A(Z)}#D(){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>${Z}`,this.#_=this.querySelector(".fig-3d-rotate-container"),this.#N=this.querySelector(".fig-3d-rotate-cube"),this.#O(),this.#k(),this.#F()}#O(){this.#U={};for(let q of this.#X){let Q=this.querySelector(`fig-input-number[name="${q}"]`);if(!Q)continue;if(this.#U[q]=Q,!this.#L[q])this.#L[q]=($)=>{$.stopPropagation();let J=parseFloat($.target.value);if(isNaN(J))return;if(q==="rotateX")this.#Q=J;else if(q==="rotateY")this.#q=J;else if(q==="rotateZ")this.#Z=J;this.#k(),this.#C($.type)};let Z=this.#L[q];Q.removeEventListener("input",Z),Q.removeEventListener("change",Z),Q.addEventListener("input",Z),Q.addEventListener("change",Z)}}#P(){let q={rotateX:this.#Q,rotateY:this.#q,rotateZ:this.#Z};for(let Q of this.#X){let Z=this.#U[Q];if(Z)Z.setAttribute("value",q[Q].toFixed(this.#$))}}#k(){if(!this.#N)return;this.#N.style.transform=`rotateX(${this.#Q}deg) rotateY(${this.#q}deg) rotateZ(${this.#Z}deg)`}#C(q){this.dispatchEvent(new CustomEvent(q,{bubbles:!0,detail:{value:this.value,rotateX:this.#Q,rotateY:this.#q,rotateZ:this.#Z}}))}#V(q){if(!this.#j)return q;return Math.round(q/15)*15}#F(){if(this.#M(),!this.#_)return;this.#K=new AbortController,this.#_.addEventListener("pointerdown",this.#G,{signal:this.#K.signal}),this.#W=(q)=>{if(q.key==="Shift")this.#j=!0},this.#Y=(q)=>{if(q.key==="Shift")this.#j=!1},window.addEventListener("keydown",this.#W),window.addEventListener("keyup",this.#Y)}get#f(){let q=this.getAttribute("drag");return q===null||q.toLowerCase()!=="false"}#I(q){if(!this.#f)return;q.preventDefault(),this.#J=!0,this.#_.classList.add("dragging"),this.#_.setPointerCapture(q.pointerId);let{clientX:Q,clientY:Z}=q,$=this.#Q,J=this.#q,j=(W)=>{if(!this.#J)return;if(W.buttons===0){_();return}let N=W.clientX-Q,K=W.clientY-Z;this.#q=this.#V(J+N*0.5),this.#Q=this.#V($-K*0.5),this.#k(),this.#P(),this.setAttribute("value",this.value),this.#C("input")},_=()=>{if(!this.#J)return;this.setAttribute("value",this.value),this.#J=!1,this.#_.classList.remove("dragging"),this.#_.removeEventListener("pointermove",j),this.#_.removeEventListener("pointerup",_),this.#_.removeEventListener("pointercancel",_),this.#_.removeEventListener("lostpointercapture",_),this.#C("change")};this.#_.addEventListener("pointermove",j),this.#_.addEventListener("pointerup",_),this.#_.addEventListener("pointercancel",_),this.#_.addEventListener("lostpointercapture",_)}}M("fig-3d-rotate",Lq);class M0 extends HTMLElement{#Q=50;#q=50;#Z=0;#$=null;#J=[];#j=null;#N=null;#_=null;#W=!1;#Y=!1;#G=null;#K=null;#X=null;static SNAP_POINTS=[0,16.6667,33.3333,50,66.6667,83.3333,100];static get observedAttributes(){return["value","precision","aspect-ratio","drag","fields"]}#U(){this.#$=this.querySelector(".origin-grid"),this.#J=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#j=this.querySelector("fig-handle"),this.#N=this.querySelector('fig-input-number[name="x"]'),this.#_=this.querySelector('fig-input-number[name="y"]'),this.#k(),this.#C(),this.#A(),this.#g()}connectedCallback(){if(this.#Z=parseInt(this.getAttribute("precision")||"0"),m(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#D(this.getAttribute("value")),this.querySelector(".fig-origin-grid-surface"))this.#U();else this.#T();this.#M(),this.#O()}disconnectedCallback(){this.#W=!1,this.#E(),this.#v()}get value(){let q=this.#Z;return`${this.#Q.toFixed(q)}% ${this.#q.toFixed(q)}%`}set value(q){this.setAttribute("value",q)}attributeChangedCallback(q,Q,Z){if(q==="aspect-ratio"){m(this,"--aspect-ratio",Z);return}if(q==="drag"){this.#M();return}if(q==="fields"){this.#T(),this.#M(),this.#O();return}if(q==="precision"){this.#Z=parseInt(Z||"0"),this.#A(),this.#O();return}if(q==="value"){if(this.#Y||this.#W)return;this.#D(Z),this.#k(),this.#C(),this.#A()}}get#L(){let q=this.getAttribute("drag");return q===null||q.toLowerCase()!=="false"}get#z(){let q=this.getAttribute("fields");if(q===null)return!1;return q.toLowerCase()!=="false"}#M(){if(!this.#$)return;this.#$.classList.toggle("drag-disabled",!this.#L)}#B(q){return Math.max(0,Math.min(100,q))}#R(q,Q){let Z=(q||"").trim().toLowerCase();if(!Z)return Q==="x"?this.#Q:this.#q;let $=Q==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if(Z in $)return $[Z];let J=Number.parseFloat(Z.replace("%",""));if(Number.isFinite(J))return J;return Q==="x"?this.#Q:this.#q}#H(q){let Q=q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if(Q.length<1)return;if(Q.length===1){let Z=this.#R(Q[0],"x");this.#Q=Z,this.#q=Z;return}this.#Q=this.#R(Q[0],"x"),this.#q=this.#R(Q[1],"y")}#D(q){let Q=typeof q==="string"?q.trim():"";if(!Q){this.#Q=50,this.#q=50;return}this.#H(Q)}#T(){let q=Array.from({length:9},(J,j)=>{let _=j%3,W=Math.floor(j/3);return`<span class="origin-grid-cell" data-col="${_}" data-row="${W}">
314
314
  <span class="origin-grid-dot"></span>
315
- </span>`}).join(""),Z=this.#Q.toFixed(this.#$),$=this.#Z.toFixed(this.#$),J=this.#F?`<div class="origin-values">
316
- <fig-input-number name="x" value="${Z}" step="1" units="%"><span slot="prepend">X</span></fig-input-number>
317
- <fig-input-number name="y" value="${$}" step="1" units="%"><span slot="prepend">Y</span></fig-input-number>
315
+ </span>`}).join(""),Q=this.#Q.toFixed(this.#Z),Z=this.#q.toFixed(this.#Z),$=this.#z?`<div class="origin-values">
316
+ <fig-input-number name="x" value="${Q}" step="1" units="%"><span slot="prepend">X</span></fig-input-number>
317
+ <fig-input-number name="y" value="${Z}" step="1" units="%"><span slot="prepend">Y</span></fig-input-number>
318
318
  </div>`:"";this.innerHTML=`<div class="fig-origin-grid-surface">
319
319
  <div class="origin-grid" aria-label="Transform origin grid">
320
- <div class="origin-grid-cells">${Q}</div>
320
+ <div class="origin-grid-cells">${q}</div>
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.#Y=this.querySelector('fig-input-number[name="x"]'),this.#_=this.querySelector('fig-input-number[name="y"]'),this.#S(),this.#I(),this.#H(),this.#g()}#H(){let Q=this.#Q.toFixed(this.#$),Z=this.#Z.toFixed(this.#$);if(this.#Y)this.#Y.setAttribute("value",Q);if(this.#_)this.#_.setAttribute("value",Z)}#O(){let Q=this.value;if(this.getAttribute("value")===Q)return;this.#U=!0,this.setAttribute("value",Q),this.#U=!1}#T(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)}%`}#I(){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)}#f(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"))===_)}#R(){for(let Q of this.#j)Q.classList.remove("is-hovered")}#C(Q){if(this.#R(),Q)Q.classList.add("is-hovered")}#E(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.#I(),this.#H(),this.#O(),this.#T($)}#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}}#w(Q){let $=Q,J=1/0;for(let j of z0.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.#w(Q.x),y:this.#w(Q.y)}}#v(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.#E(this.#B($),this.#B(J),"input"),this.#T("change"),!0}#V(){if(!this.#J||!this.#K||!this.#N)return;this.#J.removeEventListener("pointermove",this.#K),this.#J.removeEventListener("pointerup",this.#N),this.#J.removeEventListener("pointercancel",this.#N),this.#J.removeEventListener("lostpointercapture",this.#N),this.#K=null,this.#N=null}#m(Q){if(!this.#J||!this.#L)return;Q.preventDefault(),this.#X=!0,this.#G=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.#G)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.#R();let K=this.#b(this.#k(q.clientX,q.clientY),q.shiftKey);this.#E(K.x,K.y,"input")},this.#N=(q)=>{if(!this.#X||q.pointerId!==this.#G)return;if(this.#X=!1,this.#G=null,this.#J.classList.remove("is-dragging"),this.#R(),this.#V(),!j){let _=this.#y(Z,$);this.#E(_.x,_.y,"input")}this.#T("change")},this.#J.addEventListener("pointermove",this.#K),this.#J.addEventListener("pointerup",this.#N),this.#J.addEventListener("pointercancel",this.#N),this.#J.addEventListener("lostpointercapture",this.#N)}#x=null;#c(){this.#x?.abort(),this.#x=null}#g(){if(this.#c(),!this.#J||!this.#q)return;this.#x=new AbortController;let{signal:Q}=this.#x;this.#J.addEventListener("pointerdown",($)=>{let J=this.#f($.clientX,$.clientY);if(this.#C(J),this.#L){this.#m($);return}let j=this.#y($.clientX,$.clientY);this.#E(j.x,j.y,"input"),this.#T("change")},{signal:Q}),this.#J.addEventListener("pointermove",($)=>{if(this.#X)return;let J=this.#f($.clientX,$.clientY);this.#C(J)},{signal:Q}),this.#J.addEventListener("pointerleave",()=>{this.#R()},{signal:Q}),this.#q.addEventListener("keydown",($)=>{if(!this.#v($))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.#E(_,this.#Z,"input");else this.#E(this.#Q,_,"input")};$.addEventListener("input",j,{signal:Q}),$.addEventListener("change",j,{signal:Q}),$.addEventListener("focusout",()=>{this.#T("change")},{signal:Q})};Z(this.#Y,"x"),Z(this.#_,"y")}}z("fig-origin-grid",z0);class U1 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#Y=null;#_=null;#X=!1;#U={x:0.5,y:0.5};#G=!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.#O(Q),this.#Z=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#$=(Q)=>this.#T(Q),this.#J=()=>this.#S(),this.#j=(Q)=>this.#A(Q),this.#q=(Q)=>this.#P(Q),this.#Y=()=>this.#D(),this.#_=()=>this.#D()}#K(){this.#B(),this.#R(),this.#E(),this.#k(),this.#G=!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.#R(),this.#E(),this.#k(),this.#G=!0})}#N(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#M()}get#W(){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
+ ${$}`,this.#$=this.querySelector(".origin-grid"),this.#J=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#j=this.querySelector("fig-handle"),this.#N=this.querySelector('fig-input-number[name="x"]'),this.#_=this.querySelector('fig-input-number[name="y"]'),this.#k(),this.#C(),this.#A(),this.#g()}#A(){let q=this.#Q.toFixed(this.#Z),Q=this.#q.toFixed(this.#Z);if(this.#N)this.#N.setAttribute("value",q);if(this.#_)this.#_.setAttribute("value",Q)}#O(){let q=this.value;if(this.getAttribute("value")===q)return;this.#Y=!0,this.setAttribute("value",q),this.#Y=!1}#P(q){this.dispatchEvent(new CustomEvent(q,{bubbles:!0,detail:{value:this.value,x:this.#Q,y:this.#q}}))}#k(){if(!this.#j)return;let q=(Q)=>16.6667+this.#B(Q)/100*66.6667;this.#j.style.left=`${q(this.#Q)}%`,this.#j.style.top=`${q(this.#q)}%`}#C(){if(!this.#j)return;let q=this.#Q<0||this.#Q>100,Q=this.#q<0||this.#q>100,Z=this.#Q<0,$=this.#Q>100,J=this.#q<0,j=this.#q>100;this.#j.classList.toggle("beyond-bounds-x",q),this.#j.classList.toggle("beyond-bounds-y",Q),this.#j.classList.toggle("overflow-left",Z),this.#j.classList.toggle("overflow-right",$),this.#j.classList.toggle("overflow-up",J),this.#j.classList.toggle("overflow-down",j)}#V(q,Q){if(!this.#$)return null;let Z=this.#$.getBoundingClientRect(),$=(q-Z.left)/Math.max(Z.width,1),J=(Q-Z.top)/Math.max(Z.height,1);if($<0||$>1||J<0||J>1)return null;let j=Math.max(0,Math.min(2,Math.floor($*3))),_=Math.max(0,Math.min(2,Math.floor(J*3)));return this.#J.find((W)=>Number(W.getAttribute("data-col"))===j&&Number(W.getAttribute("data-row"))===_)}#F(){for(let q of this.#J)q.classList.remove("is-hovered")}#f(q){if(this.#F(),q)q.classList.add("is-hovered")}#I(q,Q,Z){let $=Number(q),J=Number(Q);if(!Number.isFinite($)||!Number.isFinite(J))return;if($===this.#Q&&J===this.#q&&Z==="input")return;this.#Q=$,this.#q=J,this.#k(),this.#C(),this.#A(),this.#O(),this.#P(Z)}#S(q,Q){if(!this.#$)return{x:this.#Q,y:this.#q};let Z=this.#$.getBoundingClientRect(),$=Z.width/6,J=Z.height/6,j=Math.max(1,Z.width-$*2),_=Math.max(1,Z.height-J*2),W=(q-(Z.left+$))/j,N=(Q-(Z.top+J))/_;return{x:W*100,y:N*100}}#w(q,Q){if(!this.#$)return{x:50,y:50};let Z=this.#$.getBoundingClientRect(),$=(q-Z.left)/Math.max(Z.width,1)*3,J=(Q-Z.top)/Math.max(Z.height,1)*3,j=Math.max(0,Math.min(2,Math.floor($))),_=Math.max(0,Math.min(2,Math.floor(J)));return{x:j*50,y:_*50}}#y(q){let Z=q,$=1/0;for(let J of M0.SNAP_POINTS){let j=Math.abs(q-J);if(j<$)$=j,Z=J}return $<=2.5?Z:q}#u(q,Q){if(!Q)return q;return{x:this.#y(q.x),y:this.#y(q.y)}}#b(q){if(!this.#L)return!1;let Q=q.shiftKey?10:1,Z=this.#Q,$=this.#q;switch(q.key){case"ArrowLeft":Z-=Q;break;case"ArrowRight":Z+=Q;break;case"ArrowUp":$-=Q;break;case"ArrowDown":$+=Q;break;case"Home":Z=0,$=0;break;case"End":Z=100,$=100;break;default:return!1}return this.#I(this.#B(Z),this.#B($),"input"),this.#P("change"),!0}#E(){if(!this.#$||!this.#K||!this.#X)return;this.#$.removeEventListener("pointermove",this.#K),this.#$.removeEventListener("pointerup",this.#X),this.#$.removeEventListener("pointercancel",this.#X),this.#$.removeEventListener("lostpointercapture",this.#X),this.#K=null,this.#X=null}#h(q){if(!this.#$||!this.#L)return;q.preventDefault(),this.#W=!0,this.#G=q.pointerId;let{clientX:Q,clientY:Z}=q,$=3,J=!1;this.#$.setPointerCapture(q.pointerId),this.#K=(j)=>{if(!this.#W||j.pointerId!==this.#G)return;let _=j.clientX-Q,W=j.clientY-Z,N=Math.hypot(_,W);if(!J&&N<$)return;if(!J)J=!0,this.#$.classList.add("is-dragging"),this.#F();let K=this.#u(this.#S(j.clientX,j.clientY),j.shiftKey);this.#I(K.x,K.y,"input")},this.#X=(j)=>{if(!this.#W||j.pointerId!==this.#G)return;if(this.#W=!1,this.#G=null,this.#$.classList.remove("is-dragging"),this.#F(),this.#E(),!J){let _=this.#w(Q,Z);this.#I(_.x,_.y,"input")}this.#P("change")},this.#$.addEventListener("pointermove",this.#K),this.#$.addEventListener("pointerup",this.#X),this.#$.addEventListener("pointercancel",this.#X),this.#$.addEventListener("lostpointercapture",this.#X)}#x=null;#v(){this.#x?.abort(),this.#x=null}#g(){if(this.#v(),!this.#$||!this.#j)return;this.#x=new AbortController;let{signal:q}=this.#x;this.#$.addEventListener("pointerdown",(Z)=>{let $=this.#V(Z.clientX,Z.clientY);if(this.#f($),this.#L){this.#h(Z);return}let J=this.#w(Z.clientX,Z.clientY);this.#I(J.x,J.y,"input"),this.#P("change")},{signal:q}),this.#$.addEventListener("pointermove",(Z)=>{if(this.#W)return;let $=this.#V(Z.clientX,Z.clientY);this.#f($)},{signal:q}),this.#$.addEventListener("pointerleave",()=>{this.#F()},{signal:q}),this.#j.addEventListener("keydown",(Z)=>{if(!this.#b(Z))return;Z.preventDefault(),Z.stopPropagation()},{signal:q});let Q=(Z,$)=>{if(!Z)return;let J=(j)=>{let _=Number.parseFloat(j.target.value);if(!Number.isFinite(_))return;if($==="x")this.#I(_,this.#q,"input");else this.#I(this.#Q,_,"input")};Z.addEventListener("input",J,{signal:q}),Z.addEventListener("change",J,{signal:q}),Z.addEventListener("focusout",()=>{this.#P("change")},{signal:q})};Q(this.#N,"x"),Q(this.#_,"y")}}M("fig-origin-grid",M0);class Rq extends HTMLElement{#Q=null;#q=null;#Z=null;#$=null;#J=null;#j=null;#N=null;#_=null;#W=!1;#Y={x:0.5,y:0.5};#G=!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.#O(q),this.#q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#Z=(q)=>this.#P(q),this.#$=()=>this.#k(),this.#J=(q)=>this.#H(q),this.#j=(q)=>this.#D(q),this.#N=()=>this.#T(),this.#_=()=>this.#T()}#K(){this.#B(),this.#F(),this.#I(),this.#S(),this.#G=!0}connectedCallback(){u(this,()=>{if(this.precision=this.getAttribute("precision")||3,this.precision=parseInt(this.precision),this.transform=this.getAttribute("transform")||1,this.transform=Number(this.transform),this.coordinates=this.getAttribute("coordinates")||"screen",m(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.#F(),this.#I(),this.#S(),this.#G=!0})}#X(q){return this.coordinates==="math"?1-q:q}disconnectedCallback(){this.#R()}get#U(){let q=this.getAttribute("fields");if(q===null)return!1;return q.toLowerCase()!=="false"}#L(){this.innerHTML=this.#M()}#z(){let q=(this.getAttribute("axis-labels")||"").trim();if(!q)return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1};let Q=q.split(/[\s,]+/).filter(Boolean);if(Q.length===1)return{left:"",right:"",top:Q[0],bottom:"",leftNoRotate:!1};if(Q.length===2){let[Z,$]=Q;return{left:Z,right:"",top:"",bottom:$,leftNoRotate:!0}}if(Q.length===4){let[Z,$,J,j]=Q;return{left:Z,right:$,top:J,bottom:j,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#M(){let q=this.#z();return`
325
325
  <div class="fig-input-joystick-plane-container">
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("")}
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">
328
328
  <div class="fig-input-joystick-guides"></div>
329
329
  <fig-handle drag drag-surface=".fig-input-joystick-plane" drag-axes="x,y" drag-snapping="modifier"></fig-handle>
@@ -334,7 +334,7 @@ var w1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var v1={};var P0=w1(()=>{/*! Vendored from @
334
334
  </fig-button>
335
335
  </fig-tooltip>
336
336
  </div>
337
- ${this.#W?`<div class="joystick-values">
337
+ ${this.#U?`<div class="joystick-values">
338
338
  <fig-input-number
339
339
  name="x"
340
340
  step="1"
@@ -354,11 +354,11 @@ var w1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var v1={};var P0=w1(()=>{/*! 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.#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.#W&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#j),this.xInput.addEventListener("change",this.#j),this.xInput.addEventListener("focusout",this.#Y),this.yInput.addEventListener("input",this.#q),this.yInput.addEventListener("change",this.#q),this.yInput.addEventListener("focusout",this.#_)}#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.#W&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#j),this.xInput.removeEventListener("change",this.#j),this.xInput.removeEventListener("focusout",this.#Y),this.yInput.removeEventListener("input",this.#q),this.yInput.removeEventListener("change",this.#q),this.yInput.removeEventListener("focusout",this.#_)}#A(Q){let Z=Number.parseFloat(Q.target.value);if(!Number.isFinite(Z))return;this.position.x=Math.max(0,Math.min(1,Z/100)),this.#R(),this.#E(),this.#I()}#P(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.#R(),this.#E(),this.#I()}#D(){this.#E(),this.#f()}#H(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.#R();this.#C(),this.#E()}#O(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.#H($,J,{syncHandle:!1}),this.#I(),this.#f()}#T(Q){let Z=Q.detail??{};if(typeof Z.px!=="number"||typeof Z.py!=="number")return;this.#H(Z.px,Z.py,{syncHandle:!1}),this.#I()}#S(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#E(),this.#f()}#I(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#f(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#R(){let Q=this.#N(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;this.#C()}#C(){if(this.#W&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#E(){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.#U,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.#U},this.#R(),this.#E(),this.#I(),this.#f()}focus(){this.cursor?.focus()}static get observedAttributes(){return["value","precision","transform","fields","coordinates","aspect-ratio","axis-labels"]}get value(){return`${Math.round(this.position.x*100)}% ${Math.round(this.position.y*100)}%`}set value(Q){let Z=Q==null?"":String(Q).trim();if(!Z)this.position={x:0.5,y:0.5};else{let $=Z.split(/[\s,]+/).filter(Boolean),J=(_)=>{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.#G)this.#R(),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.#R();if(Q==="axis-labels"&&$!==Z)this.#M(),this.#L(),this.#B(),this.#R();if(Q==="coordinates")this.coordinates=$||"screen",this.#R()}}z("fig-joystick",U1);class H0 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",H0);class L1 extends H0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}z("fig-skeleton",L1);class B1 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",B1);class M1 extends HTMLElement{}z("fig-header",M1);class O1 extends HTMLElement{}z("fig-footer",O1);class F1 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",F1);class z1 extends HTMLElement{static get observedAttributes(){return["fit","aspect-ratio"]}connectedCallback(){this.#Q(),this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="fit")this.#Q();if(Q==="aspect-ratio")this.#Z()}#Q(){let Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-preview-fit",Q);else this.style.removeProperty("--fig-preview-fit")}#Z(){let Q=this.getAttribute("aspect-ratio");if(Q)this.style.setProperty("--fig-preview-aspect-ratio",Q);else this.style.removeProperty("--fig-preview-aspect-ratio")}}z("fig-preview",z1);class E extends HTMLElement{static#Q=new Set(["oklch","hsl"]);static#Z=10;static#$=10;static#J=8;static#j=3;static#q=210;static#Y={type:"linear",angle:135,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{color:"#FF0000",position:0,opacity:100},{color:"#4F9EFF",position:100,opacity:100}]};#_=!1;#X=null;#U=null;#G={...E.#Y};static get observedAttributes(){return["value"]}get value(){return{type:"gradient",gradient:{...this.#G}}}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.#N(),this.#T(),this.#S()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q!=="value")return;if(this.#N(),this.#_)this.#S()}#K(){if(!(this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby"))&&!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}#N(){let Q=this.getAttribute("value");if(!Q){this.#G={...E.#Y,stops:E.#Y.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.#G=this.#W({...E.#Y,...$})}catch{}}#W(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})):E.#Y.stops.map((q)=>({...q}));if(j.length<2)return{...E.#Y,stops:E.#Y.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 E.#Q.has(this.#G.interpolationSpace||"srgb")}#F(Q){let{r:Z,g:$,b:J}=o(Q);if(this.#G.interpolationSpace==="hsl")return M0(Z,$,J).h;let j=Q0(Z,$,J);return(B0(j.l,j.a,j.b).h%360+360)%360}#z(){let Q=this.#D(),Z=this.#F(Q[0]?.color||"#FF0000"),$=this.#F(Q[Q.length-1]?.color||"#4F9EFF"),J=E.#q-Z,q=((E.#q-$-J)%360+360)%360,_=q===0?0:q-360,X=this.#G.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(E.#j/2/E.#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:E.#Z+E.#J*Math.cos(Z),y:E.#$+E.#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 ${E.#J} ${E.#J} 0 ${q} ${_} ${j.x} ${j.y}`}#A(){let Q=this.#B(180),Z=this.#B(0);return`M ${Q.x} ${Q.y} L ${Z.x} ${Z.y}`}#P(Q){let Z=E.#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($)}")`}#D(){return[...this.#G.stops].sort((Q,Z)=>(Q.position??0)-(Z.position??0))}#H(){let Q=this.#G.interpolationSpace||"srgb";if(Q==="srgb")return"";if(E.#Q.has(Q))return` in ${Q} ${this.#G.hueInterpolation||"shorter"} hue`;return` in ${Q}`}#O(){let Q=this.#D(),Z=this.#H();if(this.#L()){let J=(E.#q+90)%360,j=this.#G.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}, ${$})`}#T(){if(this.#_)return;let Q=E.#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.#q),this.cursor?.addEventListener("input",this.#Z),this.cursor?.addEventListener("change",this.#$);let q=this.querySelector(".fig-joystick-reset");if(q)q.addEventListener("click",()=>this.#w());if(this.#U&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#J),this.xInput.addEventListener("change",this.#J),this.xInput.addEventListener("focusout",this.#N),this.yInput.addEventListener("input",this.#j),this.yInput.addEventListener("change",this.#j),this.yInput.addEventListener("focusout",this.#_)}#R(){if(this.plane?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("pointerdown",this.#q),this.cursor?.removeEventListener("input",this.#Z),this.cursor?.removeEventListener("change",this.#$),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.#N),this.yInput.removeEventListener("input",this.#j),this.yInput.removeEventListener("change",this.#j),this.yInput.removeEventListener("focusout",this.#_)}#H(q){let Q=Number.parseFloat(q.target.value);if(!Number.isFinite(Q))return;this.position.x=Math.max(0,Math.min(1,Q/100)),this.#F(),this.#I(),this.#C()}#D(q){let Q=Number.parseFloat(q.target.value);if(!Number.isFinite(Q))return;this.position.y=Math.max(0,Math.min(1,Q/100)),this.#F(),this.#I(),this.#C()}#T(){this.#I(),this.#V()}#A(q,Q,{syncHandle:Z=!0}={}){let $=Math.max(0,Math.min(1,q)),J=Math.max(0,Math.min(1,Q)),j=this.coordinates==="math"?1-J:J;if(this.position={x:$,y:j},Z)this.#F();this.#f(),this.#I()}#O(q){if(!this.plane||!this.cursor)return;if(q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let Q=this.plane.getBoundingClientRect(),Z=Q.width>0?(q.clientX-Q.left)/Q.width:0.5,$=Q.height>0?(q.clientY-Q.top)/Q.height:0.5;this.cursor.value=`${Math.round(Z*100)}% ${Math.round($*100)}%`,this.#A(Z,$,{syncHandle:!1}),this.#C(),this.#V()}#P(q){let Q=q.detail??{};if(typeof Q.px!=="number"||typeof Q.py!=="number")return;this.#A(Q.px,Q.py,{syncHandle:!1}),this.#C()}#k(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#I(),this.#V()}#C(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#V(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#F(){let q=this.#X(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${q*100}%`;this.#f()}#f(){if(this.#U&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#I(){let q=this.value;if(this.getAttribute("value")!==q)this.#W=!0,this.setAttribute("value",q),this.#W=!1;this.#S()}#S(){let q=this.#Y,Q=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",Q),this.style.setProperty("--is-not-default",Q?"0":"1")}#w(){this.position={...this.#Y},this.#F(),this.#I(),this.#C(),this.#V()}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 Q=q==null?"":String(q).trim();if(!Q)this.position={x:0.5,y:0.5};else{let Z=Q.split(/[\s,]+/).filter(Boolean),$=(_)=>{if(!_)return 0.5;let W=_.includes("%"),N=Number.parseFloat(_.replace(/%/g,"").trim());if(!Number.isFinite(N))return 0.5;let K=W||Math.abs(N)>1?N/100:N;return Math.max(0,Math.min(1,K))},J=$(Z[0]),j=$(Z[1]??Z[0]);this.position={x:J,y:j}}if(this.#G)this.#F(),this.#S()}attributeChangedCallback(q,Q,Z){if(q==="aspect-ratio"){m(this,"--aspect-ratio",Z);return}if(q==="value"){if(this.#W||this.isDragging)return;this.value=Z}if(q==="precision")this.precision=parseInt(Z);if(q==="transform")this.transform=Number(Z);if(q==="fields"&&Z!==Q)this.#R(),this.#L(),this.#B(),this.#F();if(q==="axis-labels"&&Z!==Q)this.#R(),this.#L(),this.#B(),this.#F();if(q==="coordinates")this.coordinates=Z||"screen",this.#F()}}M("fig-joystick",Rq);class A0 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,Q,Z){if(q==="duration")this.style.setProperty(this.durationPropertyName,Z||"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")}}M("fig-shimmer",A0);class Bq extends A0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}M("fig-skeleton",Bq);class Oq extends HTMLElement{static observedAttributes=["name","collapsible","open"];#Q=null;#q=null;connectedCallback(){this.#J()}disconnectedCallback(){if(this.#q)this.#q.removeEventListener("click",this.#Z);if(this.#Q)this.#Q.removeEventListener("click",this.#Z),this.#Q.removeEventListener("keydown",this.#$),this.#Q.querySelector("h3")?.removeEventListener("click",this.#Z)}attributeChangedCallback(q,Q,Z){if(Q===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 Q=this.open;if(q)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#Q?.setAttribute("aria-expanded",String(!!q)),Q!==!!q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!q},bubbles:!0}))}#Z=(q)=>{q.stopPropagation(),this.open=!this.open};#$=(q)=>{if(q.key!=="Enter"&&q.key!==" ")return;q.preventDefault(),q.stopPropagation(),this.open=!this.open};#J(){let q=this.hasAttribute("collapsible"),Z=this.getAttribute("name")||(q?"Group":null),$=this.querySelector(":scope > fig-header");if(!Z&&!q&&!$){if(this.#Q&&this.#Q.dataset.generated)this.#Q.remove(),this.#Q=null,this.#q=null;return}if($)this.#Q=$;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=Z;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 j=c("chevron",{size:"small",className:"fig-group-chevron"});J.prepend(j)}if(this.#q=J.querySelector(".fig-group-chevron"),J.removeEventListener("click",this.#Z),this.#Q.removeEventListener("click",this.#Z),this.#Q.addEventListener("click",this.#Z),this.#Q.setAttribute("role","button"),this.#Q.setAttribute("tabindex","0"),this.#Q.setAttribute("aria-expanded",String(this.open)),this.#Q.removeEventListener("keydown",this.#$),this.#Q.addEventListener("keydown",this.#$),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Q.setAttribute("aria-expanded","false")}else{if(J.removeEventListener("click",this.#Z),this.#Q.removeEventListener("click",this.#Z),this.#Q.removeAttribute("role"),this.#Q.removeAttribute("tabindex"),this.#Q.removeAttribute("aria-expanded"),this.#Q.removeEventListener("keydown",this.#$),this.#q)this.#q.remove(),this.#q=null;this.removeAttribute("open")}}}M("fig-group",Oq);class zq extends HTMLElement{}M("fig-header",zq);class Mq extends HTMLElement{}M("fig-footer",Mq);class Aq 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")}}M("fig-spinner",Aq);class Hq extends HTMLElement{static get observedAttributes(){return["fit","aspect-ratio"]}connectedCallback(){this.#Q(),this.#q()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="fit")this.#Q();if(q==="aspect-ratio")this.#q()}#Q(){let q=this.getAttribute("fit");if(q)this.style.setProperty("--fig-preview-fit",q);else this.style.removeProperty("--fig-preview-fit")}#q(){let q=this.getAttribute("aspect-ratio");if(q)this.style.setProperty("--fig-preview-aspect-ratio",q);else this.style.removeProperty("--fig-preview-aspect-ratio")}}M("fig-preview",Hq);class k extends HTMLElement{static#Q=new Set(["oklch","hsl"]);static#q=10;static#Z=10;static#$=8;static#J=3;static#j=210;static#N={type:"linear",angle:135,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{color:"#FF0000",position:0,opacity:100},{color:"#4F9EFF",position:100,opacity:100}]};#_=!1;#W=null;#Y=null;#G={...k.#N};static get observedAttributes(){return["value"]}get value(){return{type:"gradient",gradient:{...this.#G}}}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.#X(),this.#P(),this.#k()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q!=="value")return;if(this.#X(),this.#_)this.#k()}#K(){if(!(this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby"))&&!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}#X(){let q=this.getAttribute("value");if(!q){this.#G={...k.#N,stops:k.#N.stops.map((Q)=>({...Q}))};return}try{let Q=JSON.parse(q),Z=Q?.type==="gradient"&&Q.gradient?Q.gradient:Q?.gradient?Q.gradient:Q;if(!Z||typeof Z!=="object")return;this.#G=this.#U({...k.#N,...Z})}catch{}}#U(q){let Q={...q??{}},Z=String(Q.interpolationSpace??"srgb").toLowerCase(),$=String(Q.hueInterpolation??"shorter").toLowerCase(),J=Array.isArray(Q.stops)?Q.stops.map((j)=>({color:String(j?.color||"#D9D9D9").replace(/^(#(?:[0-9a-f]{6})).*/i,"$1"),position:j?.position??0,opacity:j?.opacity??100})):k.#N.stops.map((j)=>({...j}));if(J.length<2)return{...k.#N,stops:k.#N.stops.map((j)=>({...j}))};return{type:["linear","radial","angular"].includes(Q.type)?Q.type:"linear",angle:Number.isFinite(Number(Q.angle))?Number(Q.angle):135,interpolationSpace:Z,hueInterpolation:$,stops:J}}#L(){return k.#Q.has(this.#G.interpolationSpace||"srgb")}#z(q){let{r:Q,g:Z,b:$}=i(q);if(this.#G.interpolationSpace==="hsl")return B0(Q,Z,$).h;let J=q0(Q,Z,$);return(R0(J.l,J.a,J.b).h%360+360)%360}#M(){let q=this.#T(),Q=this.#z(q[0]?.color||"#FF0000"),Z=this.#z(q[q.length-1]?.color||"#4F9EFF"),$=k.#j-Q,j=((k.#j-Z-$)%360+360)%360,_=j===0?0:j-360,W=this.#G.hueInterpolation||"shorter",N;if(W==="increasing")N=_;else if(W==="decreasing")N=j;else if(W==="longer")N=j<180?_:j;else N=j<=180?j:_;let K=Math.sign(N),G=Math.asin(k.#J/2/k.#$)*180/Math.PI,U=Math.min(G,Math.max(0,(Math.abs(N)-0.01)/2));return{startDeg:$+K*U,sweepDeg:N-K*U*2}}#B(q){let Q=q*Math.PI/180;return{x:k.#q+k.#$*Math.cos(Q),y:k.#Z+k.#$*Math.sin(Q)}}#R(q,Q){let Z=q+Q,$=this.#B(q),J=this.#B(Z),j=Math.abs(Q)>180?1:0,_=Q>=0?1:0;return`M ${$.x} ${$.y} A ${k.#$} ${k.#$} 0 ${j} ${_} ${J.x} ${J.y}`}#H(){let q=this.#B(180),Q=this.#B(0);return`M ${q.x} ${q.y} L ${Q.x} ${Q.y}`}#D(q){let Q=k.#J,Z=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none"><path d="${q}" fill="none" stroke="white" stroke-width="${Q}" stroke-linecap="round" stroke-linejoin="round"/></svg>`;return`url("data:image/svg+xml,${encodeURIComponent(Z)}")`}#T(){return[...this.#G.stops].sort((q,Q)=>(q.position??0)-(Q.position??0))}#A(){let q=this.#G.interpolationSpace||"srgb";if(q==="srgb")return"";if(k.#Q.has(q))return` in ${q} ${this.#G.hueInterpolation||"shorter"} hue`;return` in ${q}`}#O(){let q=this.#T(),Q=this.#A();if(this.#L()){let $=(k.#j+90)%360,J=this.#G.interpolationSpace,j=(W)=>J==="oklch"?`oklch(65% 0.25 ${W})`:`hsl(${W} 100% 50%)`,_=[0,300,240,180,120,60,0].map(j).join(", ");return`conic-gradient(from ${$}deg in ${J} decreasing hue, ${_})`}let Z=q.map(($)=>`${$.color} ${$.position??0}%`).join(", ");return`linear-gradient(90deg${Q}, ${Z})`}#P(){if(this.#_)return;let q=k.#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
- <circle class="fig-interpolation-swatch-rim" cx="10" cy="10" r="8" fill="none" stroke="currentColor" stroke-width="${Q}"/>
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.#U=this.querySelector(".fig-interpolation-swatch-fill"),this.#_=!0}#S(){if(!this.#U)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.#A(),$=this.#P(Z);this.#U.style.setProperty("-webkit-mask-image",$),this.#U.style.maskImage=$,this.#U.style.background=this.#O()}}z("fig-interpolation-swatch",E);var a1={chevron:{medium:"--icon-24-chevron",small:"--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",send:{medium:"--icon-24-send",small:"--icon-16-send"},adjust:{medium:"--icon-24-adjust",small:"--icon-16-adjust"},minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",download:"--icon-24-download",upload:"--icon-24-upload",sun:"--icon-24-sun",moon:"--icon-24-moon",edit:{medium:"--icon-24-edit",small:"--icon-16-edit"},settings:{medium:"--icon-24-settings",small:"--icon-16-settings"},more:{medium:"--icon-24-more",small:"--icon-16-more"},visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"},globe:{medium:"--icon-24-globe",small:"--icon-16-globe"}};function t1(Q,Z="medium"){let $=Q&&a1[Q];if(!$)return"";let J=typeof $==="string"?$:$[Z==="small"?"small":"medium"];return J?`var(${J})`:""}class H1 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",$=t1(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",H1);class A1 extends HTMLElement{}z("fig-content",A1);class R1 extends HTMLElement{}z("fig-tab-content",R1);class D1 extends HTMLElement{}z("fig-button-combo",D1);class T1 extends HTMLElement{}z("fig-input-combo",T1);class P1 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.#U(),this.#L()}disconnectedCallback(){this.#Y(),this.removeEventListener("click",this.#G)}#Y(){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}#_(){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"}#U(){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.#G),this.#F();return}this.removeEventListener("click",this.#G);let Z=(this.getAttribute("value")||"").trim(),$=this.#W(Z),J=this.#N(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=i()?`<fig-fill-picker mode="solid" ${j} value='${q}'>
363
- <fig-swatch background="${$}"${_}></fig-swatch>
364
- </fig-fill-picker>`:`<fig-swatch background="${$}"${_}></fig-swatch>`,this.#Q=this.querySelector("fig-fill-picker"),this.#Z=this.querySelector("fig-swatch"),this.#Y(),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.#_(),this.#F()}#G=()=>{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"}#N(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}#W(Q){if(!Q)return"#D9D9D9";let Z=String(Q).trim();if(Z.startsWith("{"))try{let $=JSON.parse(Z);if($?.color)return this.#W($.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:$}=F0(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.#W(Q),$=this.#N(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.#W(Q?.color),J=this.#W(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)}Object.assign(j,l(j.color,this.#X?Q?.alpha:1,j.opacity)),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.#U();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.#W(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#W(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",P1);class C1 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",C1);class E1 extends HTMLElement{#Q=null;#Z=this.#A.bind(this);#$=this.#P.bind(this);#J=this.#H.bind(this);#j=null;#q=null;#Y=null;#_=null;#X=null;#U=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#G(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#K(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#N(){return this.getAttribute("choice-element")||"fig-choice"}#W(){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.#N}`))}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.#W(),this.#I(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#$),this.addEventListener("scroll",this.#J),this.#f(),this.#T(),this.#w(),this.#O(),this.#z(),c(this,()=>{this.#F(),this.#H(),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.#R()}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.#W(),this.#k();if(Q==="drag")if(this.#K)this.#T();else this.#S();if(Q==="overflow")this.#f(),requestAnimationFrame(()=>this.#H());if(Q==="layout"){if(this.#f(),$==="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.#N,$=Q;while($&&$!==this){if($.matches(Z))return $;$=$.parentElement}return null}#A(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#M(Q.target);if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.selectedChoice=Z,this.#D()}#P(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.#N)){let q=this.#M(document.activeElement);if(q&&q!==this.#Q)this.selectedChoice=q,this.#D()}return;default:return}if(J!==$&&Z[J])this.selectedChoice=Z[J],Z[J].focus(),this.#D()}#D(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#H(){if(this.#G==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal";t(this,this,Q?"x":"y")}#O(){this.#q?.disconnect(),this.#q=new ResizeObserver(()=>{this.#H(),this.#k()}),this.#q.observe(this)}#T(){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}#I(){if(this.#U)return;let Q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!Q)return;this.#U=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#U=!1}}#f(){if(this.#G==="scrollbar")this.#R();else this.#C()}#R(){this.#Y?.remove(),this.#_?.remove(),this.#Y=null,this.#_=null,this.classList.remove("overflow-start","overflow-end")}#C(){if(this.#Y&&this.#_&&this.contains(this.#Y)&&this.contains(this.#_))return;this.#Y?.remove(),this.#_?.remove(),this.#Y=null,this.#_=null;let Q=Y0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#E(-1),onEnd:()=>this.#E(1)});this.#Y=Q.start,this.#_=Q.end,this.prepend(this.#Y),this.append(this.#_)}#E(Q){let Z=this.getAttribute("layout")==="horizontal";r(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.#H()})}#w(){this.#j?.disconnect(),this.#j=new MutationObserver(()=>{if(this.#U)return;this.#I(),this.#f(),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.#H())}),this.#j.observe(this,{childList:!0,subtree:!1})}}z("fig-chooser",E1);class k1 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;#Y=null;#_=null;#X=null;get#U(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#G(){return!this.hasAttribute("data-no-color-picker")}get#K(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#N(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#W(){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.#W;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.#a(Q.getBoundingClientRect());return`${Math.round(Z*100)}% ${Math.round($*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#M(Q){let Z=Q==null?"":String(Q).trim();if(!Z)return{xPct:0,yPct:0};let $=Z.split(/[\s,]+/).filter(Boolean),J=(_)=>{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}}#A(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.#N;if(this.#P(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`}}#P(Q=this.#N){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#D(){this.#j=!0,this.setAttribute("value",this.value),this.#j=!1}get#H(){return this.getAttribute("hit-area-mode")||"handle"}#O(){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}}#T(){let Q=this.#O();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.#H==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#w(Q)}connectedCallback(){this.#k(),this.#E(),this.#T(),this.addEventListener("click",this.#I),document.addEventListener("pointerdown",this.#f),document.addEventListener("keydown",this.#R);let Q=this.getAttribute("value");if(Q)this.#A(Q);if(this.#U)this.#t()}disconnectedCallback(){if(this.#y(),this.#i(),this.#c(),this.#s(),this.#X)this.#X.remove(),this.#X=null;this.removeEventListener("click",this.#I),document.removeEventListener("pointerdown",this.#f),document.removeEventListener("keydown",this.#R)}select(){if(F(this,"disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#I=(Q)=>{if(this.#Z){this.#Z=!1;return}if(this.getAttribute("type")==="color"&&this.#G&&!this.#U){this.#x();return}this.select()};#f=(Q)=>{if(this.contains(Q.target))return;if((this.#q||this.#Y)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#R=(Q)=>{if(Q.defaultPrevented)return;if(Q.target===this&&this.#K&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Q.key)){if(this.#C(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.#G&&!this.#U)this.#x();else this.select();return}if(!F(this,"selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#G)return;if(Q.preventDefault(),!this.#U)this.#x()};#C(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.#N,j=this.#a($),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.#P(J),J.x)this.style.left=`${Math.round(_*$.width)}px`;if(J.y)this.style.top=`${Math.round(X*$.height)}px`;this.#D();let Y={...this.#a($),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.#U==="color"&&$)this.#q.setAttribute("value",$);this.#V()}if(Q==="drag")this.#E();if(Q==="hit-area")this.#T();if(Q==="selected")this.#p();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.#A($);if(Q==="tip"){if(this.#i(),this.#U)this.#c(),this.#t()}}#E(){if(this.#K&&!this.#$)this.#$=(Q)=>this.#w(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.#U||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}#w(Q){if(!this.#K||F(this,"disabled"))return;Q.preventDefault();let Z=this.#B();if(!Z)return;this.#J?.(),this.#Q=!0;let $=this.#N,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 C=this.#a(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:C.px:0.5,d=M.height>0?$.y?y/M.height:C.py:0.5;if(this.#L(A)){if($.x)m=this.#F(m);if($.y)d=this.#F(d);if($.x&&$.y){let n=this.#z(m,d);m=n.x,d=n.y}}if(this.#P($),$.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.#h(),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.#a(J),shiftKey:T.shiftKey}}))},B=(T)=>{if(L(),this.#Z){W(T.clientX,T.clientY,T.shiftKey),this.#D(),this.#A(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#a(J)}));let R=(A)=>{A.stopPropagation(),A.preventDefault()};this.addEventListener("click",R,{capture:!0,once:!0})}else this.#D();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.#U)return;if(this.#q){this.#q.style.display="";return}this.#t()}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}=F0(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}#v(){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.#Y)return;this.#Y.setAttribute("value",this.#v())}#m(){if(!i())return null;if(this.#Y)return this.#Y;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.#v()),Q.anchorElement=this;let Z=document.createElement("span");return Z.hidden=!0,Q.appendChild(Z),Q.addEventListener("input",this.#n),Q.addEventListener("change",this.#r),Q.addEventListener("close",this.#l),this.appendChild(Q),this.#Y=Q,Q}#x(){if(F(this,"disabled"))return;let Q=this.#m();if(!Q){this.#d();return}this.setAttribute("selected",""),this.#V(),Q.open()}#c(){if(!this.#Y)return;this.#Y.removeEventListener("input",this.#n),this.#Y.removeEventListener("change",this.#r),this.#Y.removeEventListener("close",this.#l),this.#Y.close(),this.#Y.remove(),this.#Y=null,this.removeAttribute("selected")}#g(){if(this.#_)return this.#_;let Q=document.createElement("input");return Q.type="color",Q.tabIndex=-1,Q.setAttribute("aria-hidden","true"),Q.style.position="fixed",Q.style.inlineSize="1px",Q.style.blockSize="1px",Q.style.opacity="0",Q.style.pointerEvents="none",Q.addEventListener("input",this.#q0),Q.addEventListener("change",this.#Q0),this.appendChild(Q),this.#_=Q,Q}#d(){let Q=this.#g(),{color:Z}=this.#b();Q.value=Z,this.setAttribute("selected",""),Q.click()}#s(){if(!this.#_)return;this.#_.removeEventListener("input",this.#q0),this.#_.removeEventListener("change",this.#Q0),this.#_.remove(),this.#_=null}#h(){if(this.getAttribute("type")!=="color")return;this.#Y?.close()}#t(){let Q=this.#U;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.#_0),Z.addEventListener("change",this.#J0),Z.addEventListener("add",this.#e),Z.addEventListener("remove",this.#e),this.appendChild(Z),this.#q=Z,this.#p()}#i(){if(!this.#q)return;this.#q.removeEventListener("input",this.#_0),this.#q.removeEventListener("change",this.#J0),this.#q.removeEventListener("add",this.#e),this.#q.removeEventListener("remove",this.#e),this.#q.remove(),this.#q=null}#p(){if(!this.#q||this.#U!=="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}=o(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,...l(Q.color,Q.alpha,Z)}}#n=(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}))};#r=(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},...l(Q,void 0,Z)}}#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}))};#Q0=(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")};#_0=(Q)=>{if(Q.stopPropagation(),Q.detail?.color){let Z={color:Q.detail.color,opacity:Q.detail.opacity,...l(Q.detail.color,Q.detail.alpha,Q.detail.opacity)};this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))}};#J0=(Q)=>{if(Q.stopPropagation(),Q.detail?.color){let Z={color:Q.detail.color,opacity:Q.detail.opacity,...l(Q.detail.color,Q.detail.alpha,Q.detail.opacity)};this.setAttribute("color",this.#u(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))}};#e=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#a(Q){let Z=Q||this.#B()?.getBoundingClientRect();if(!Z)return{x:0,y:0,px:0,py:0};let $=this.getBoundingClientRect(),J=this.offsetWidth/2,j=this.offsetHeight/2,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",k1);class S1 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",S1);class I1 extends HTMLElement{static get observedAttributes(){return["label"]}get label(){return this.getAttribute("label")??""}set label(Q){if(Q==null||Q==="")this.removeAttribute("label");else this.setAttribute("label",String(Q))}connectedCallback(){this.#Q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#Q()}#Q(){if(!this.hasAttribute("role"))this.setAttribute("role","separator");let Q=this.label.trim();if(Q)this.setAttribute("aria-label",Q);else this.removeAttribute("aria-label")}}z("fig-separator",I1);class f1 extends HTMLElement{#Q=null;#Z=null;#$=null;#J=null;#j=null;#q=null;#Y=null;#_=null;#X;#U;#G;#K;#N;#W=this.#T.bind(this);#L=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open","trigger"]}constructor(){super();this.#X=this.#y.bind(this),this.#U=this.#w.bind(this),this.#G=this.#v.bind(this),this.#K=this.#V.bind(this),this.#N=this.#m.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.#A(),this.#H(),this.#D(),this.#E(),this.open)this.#c()}disconnectedCallback(){if(this.#P(),this.#O(),document.removeEventListener("keydown",this.#K,!0),this.#j)this.#j.disconnect(),this.#j=null;if(this.#Q){this.#Q.removeEventListener("close",this.#N);let Q=Array.from(this.#Z?.querySelectorAll(":scope > fig-menu-item, :scope > fig-separator")??[]);for(let Z of Q)this.insertBefore(Z,this.#Q);this.#Q.remove(),this.#Q=null,this.#Z=null}}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){if($===null||$==="false")this.#g();else{if(this.#k()){this.removeAttribute("open");return}this.#c()}return}if(Q==="disabled"){this.#E();return}if(this.#Q&&(Q==="position"||Q==="offset"||Q==="closedby"))if($!==null)this.#Q.setAttribute(Q,$);else this.#Q.removeAttribute(Q)}#F(){this.#$=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-separator)")}#z(){return(this.getAttribute("trigger")||"").toLowerCase()==="contextmenu"||this.hasAttribute("contextmenu")}#B(){this.#Q=document.createElement("dialog",{is:"fig-popup"}),this.#Q.setAttribute("is","fig-popup"),this.#Q.classList.add("fig-menu-popup"),this.#Q.setAttribute("theme","menu"),this.#Q.setAttribute("role","menu"),this.#Q.setAttribute("id",this.#Q.getAttribute("id")||h());let Q=this.getAttribute("position")||"bottom left";this.#Q.setAttribute("position",Q);let Z=this.getAttribute("offset");if(Z)this.#Q.setAttribute("offset",Z);let $=this.getAttribute("closedby");if($)this.#Q.setAttribute("closedby",$);if(this.#$)this.#Q.anchor=this.#$;this.#Z=document.createElement("div"),this.#Z.className="fig-menu-options",this.#Z.setAttribute("role","presentation"),this.#Q.appendChild(this.#Z),this.#Q.addEventListener("close",this.#N),this.appendChild(this.#Q)}#M(){if(!this.#Z)return;let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-separator"));for(let Z of Q)this.#Z.appendChild(Z)}#A(){if(this.addEventListener("keydown",this.#K),this.#$)this.#$.addEventListener("click",this.#X),this.#$.addEventListener("contextmenu",this.#U),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.#G),this.#Q.addEventListener("keydown",this.#K)}#P(){if(this.removeEventListener("keydown",this.#K),this.#$)this.#$.removeEventListener("click",this.#X),this.#$.removeEventListener("contextmenu",this.#U);if(this.#Q)this.#Q.removeEventListener("click",this.#G),this.#Q.removeEventListener("keydown",this.#K)}#D(){this.#j=new MutationObserver((Q)=>{for(let Z of Q)for(let $ of Z.addedNodes){if($.nodeType!==1||$===this.#Q)continue;if(($.tagName==="FIG-MENU-ITEM"||$.tagName==="FIG-SEPARATOR")&&$.parentElement===this)this.#Z?.appendChild($);else if(!this.#$&&$.parentElement===this){if(this.#F(),this.#$)this.#$.addEventListener("click",this.#X),this.#$.addEventListener("contextmenu",this.#U),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded","false"),this.#$.setAttribute("aria-controls",this.#Q.getAttribute("id")),this.#Q.anchor=this.#$,this.#E()}}this.#T()}),this.#j.observe(this,{childList:!0})}#H(){if(!this.#Z)return;this.#S(),this.#Z.addEventListener("scroll",this.#W,{passive:!0}),this.#q?.disconnect(),this.#q=new ResizeObserver(()=>this.#T()),this.#q.observe(this.#Z),requestAnimationFrame(()=>this.#T())}#O(){this.#Z?.removeEventListener("scroll",this.#W),this.#q?.disconnect(),this.#q=null,this.#I()}#T(){return t(this.#Z,this.#Z,"y")}#S(){if(this.#Y&&this.#_&&this.#Z?.contains(this.#Y)&&this.#Z?.contains(this.#_))return;this.#I();let Q=Y0({owner:"menu",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>r(this.#Z,"y",-1),onEnd:()=>r(this.#Z,"y",1)});this.#Y=Q.start,this.#_=Q.end,this.#Z.prepend(this.#Y),this.#Z.append(this.#_)}#I(){this.#Y?.remove(),this.#_?.remove(),this.#Y=null,this.#_=null,this.#Z?.classList.remove("overflow-start","overflow-end")}#f(){if(!this.#Z)return[];return Array.from(this.#Z.querySelectorAll("fig-menu-item")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#R(){let Q=this.#f();if(!Q.length){this.#L=-1;return}let Z=document.activeElement,$=Q.findIndex((J)=>J===Z||J.contains(Z));this.#L=$>=0?$:-1}#C(Q){let Z=this.#f();if(!Z.length)return;let $=(Q+Z.length)%Z.length;this.#L=$;let J=Z[$];J.focus(),I0(this.#Z,J,"y")}#E(){let Q=this.#k();if(Q)if(this.open)this.removeAttribute("open");else this.#g();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}}#w(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)}#v(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.#C(0))}return}let Z=this.#f();if(!Z.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#R(),this.#C(this.#L+1);break}case"ArrowUp":{Q.preventDefault(),this.#R(),this.#C(this.#L-1);break}case"Home":{Q.preventDefault(),this.#C(0);break}case"End":{Q.preventDefault(),this.#C(Z.length-1);break}case"Escape":{Q.preventDefault(),this.open=!1,this.#$?.focus();break}case"Enter":case" ":{this.#R();let $=Z[this.#L];if(!$)return;Q.preventDefault(),this.#x($);break}}}#m(){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.#T(),!this.#$?.matches?.(":focus-visible"))return;this.#C(0)})}#g(){if(!this.#Q)return;document.removeEventListener("keydown",this.#K,!0),this.#Q.open=!1,this.#$?.setAttribute("aria-expanded","false")}}z("fig-menu",f1);
362
+ `,this.#W=this.querySelector(".fig-interpolation-swatch-svg"),this.#Y=this.querySelector(".fig-interpolation-swatch-fill"),this.#_=!0}#k(){if(!this.#Y)return;let q=this.#L();if(this.#W)this.#W.style.display=q?"":"none";let Q=q?(()=>{let{startDeg:$,sweepDeg:J}=this.#M();return this.#R($,J)})():this.#H(),Z=this.#D(Q);this.#Y.style.setProperty("-webkit-mask-image",Z),this.#Y.style.maskImage=Z,this.#Y.style.background=this.#O()}}M("fig-interpolation-swatch",k);var eq={chevron:{medium:"--icon-24-chevron",small:"--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",send:{medium:"--icon-24-send",small:"--icon-16-send"},adjust:{medium:"--icon-24-adjust",small:"--icon-16-adjust"},minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",download:"--icon-24-download",upload:"--icon-24-upload",sun:"--icon-24-sun",moon:"--icon-24-moon",edit:{medium:"--icon-24-edit",small:"--icon-16-edit"},settings:{medium:"--icon-24-settings",small:"--icon-16-settings"},more:{medium:"--icon-24-more",small:"--icon-16-more"},visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"},globe:{medium:"--icon-24-globe",small:"--icon-16-globe"}};function q1(q,Q="medium"){let Z=q&&eq[q];if(!Z)return"";let $=typeof Z==="string"?Z:Z[Q==="small"?"small":"medium"];return $?`var(${$})`:""}class Fq extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#Q()}attributeChangedCallback(q,Q,Z){if(Q!==Z)this.#Q()}#Q(){let q=this.getAttribute("name"),Q=this.getAttribute("size")||"medium",Z=q1(q,Q);if(Z)this.style.setProperty("--icon",Z);else this.style.removeProperty("--icon");if(Q==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let $=this.getAttribute("color");if($)this.style.backgroundColor=$;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}M("fig-icon",Fq);class Tq extends HTMLElement{}M("fig-content",Tq);class Dq extends HTMLElement{}M("fig-tab-content",Dq);class Pq extends HTMLElement{}M("fig-button-combo",Pq);class fq extends HTMLElement{}M("fig-input-combo",fq);class kq extends HTMLElement{#Q=null;#q=null;#Z=null;#$=this.#B.bind(this);#J=this.#R.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#j(){return this.getAttribute("control")||"color"}connectedCallback(){this.#Y(),this.#L()}disconnectedCallback(){this.#N(),this.removeEventListener("click",this.#G)}#N(){if(this.#Q)this.#Q.removeEventListener("input",this.#$),this.#Q.removeEventListener("change",this.#J);if(this.#q)this.#q.removeEventListener("input",this.#$),this.#q.removeEventListener("change",this.#J);if(this.#Z)this.#Z.disconnect(),this.#Z=null}#_(){if(this.#Z)this.#Z.disconnect(),this.#Z=null;if(!this.#q)return;this.#Z=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.#Z.observe(this.#q,{attributes:!0,attributeFilter:["selected"]})}get#W(){let q=this.getAttribute("alpha");return q===null||q!=="false"}#Y(){let q=this.#j;if(q==="add"||q==="remove"){let W=q==="add"?"add":"minus",N=this.getAttribute("aria-label")||(q==="add"?"Add color stop":"Remove color stop");this.innerHTML=`<fig-button icon variant="ghost" aria-label="${b(N)}"><fig-icon name="${W}"></fig-icon></fig-button>`,this.#Q=null,this.#q=null,this.addEventListener("click",this.#G),this.#z();return}this.removeEventListener("click",this.#G);let Q=(this.getAttribute("value")||"").trim(),Z=this.#U(Q),$=this.#X(Q),J=this.#W?"":'alpha="false"',j=$<1?JSON.stringify({type:"solid",color:Z,opacity:Math.round($*100)}):JSON.stringify({type:"solid",color:Z}),_=$<1?` alpha="${$}"`:"";if(this.innerHTML=o()?`<fig-fill-picker mode="solid" ${J} value='${j}'>
363
+ <fig-swatch background="${Z}"${_}></fig-swatch>
364
+ </fig-fill-picker>`:`<fig-swatch background="${Z}"${_}></fig-swatch>`,this.#Q=this.querySelector("fig-fill-picker"),this.#q=this.querySelector("fig-swatch"),this.#N(),this.#Q?.addEventListener("input",this.#$),this.#Q?.addEventListener("change",this.#J),!this.#Q)this.#q?.addEventListener("input",this.#$),this.#q?.addEventListener("change",this.#J);this.#_(),this.#z()}#G=()=>{let q=this.#j;this.dispatchEvent(new CustomEvent(q,{bubbles:!0,composed:!0}))};#K(q){if(!q)return"#D9D9D9";let Q=q.replace("#","").trim();if(Q.length===3||Q.length===4){let[Z,$,J]=Q;return`#${Z}${Z}${$}${$}${J}${J}`.toUpperCase()}if(Q.length===6||Q.length===8)return`#${Q.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#X(q){if(!q)return 1;let Q=String(q).trim(),Z=Q.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test(Z)){let J=Z[3];return parseInt(`${J}${J}`,16)/255}if(/^[0-9a-f]{8}$/i.test(Z))return parseInt(Z.slice(6,8),16)/255;let $=Q.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if($)return parseFloat($[1]);return 1}#U(q){if(!q)return"#D9D9D9";let Q=String(q).trim();if(Q.startsWith("{"))try{let Z=JSON.parse(Q);if(Z?.color)return this.#U(Z.color)}catch{}if(Q.startsWith("#"))return this.#K(Q);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Q))return this.#K(Q);try{let{ctx:Z}=z0(1,1);Z.fillStyle="#000000",Z.fillStyle=Q;let $=Z.fillStyle;if($.startsWith("#"))return this.#K($);let J=$.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(J){let j=(_)=>Math.max(0,Math.min(255,Number(_))).toString(16).padStart(2,"0");return`#${j(J[1])}${j(J[2])}${j(J[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#L(){let q=this.getAttribute("value"),Q=this.#U(q),Z=this.#X(q);if(q!==Q&&Z>=1){this.setAttribute("value",Q);return}if(this.#Q){this.#z();let $=Z<1?{type:"solid",color:Q,opacity:Math.round(Z*100)}:{type:"solid",color:Q};if(this.#Q.setAttribute("value",JSON.stringify($)),this.#W)this.#Q.removeAttribute("alpha");else this.#Q.setAttribute("alpha","false");if(z(this,"disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}if(this.#q){if(this.#z(),this.#q.setAttribute("background",Q),Z<1)this.#q.setAttribute("alpha",String(Z));else this.#q.removeAttribute("alpha");if(z(this,"disabled"))this.#q.setAttribute("disabled","");else this.#q.removeAttribute("disabled")}}#z(){let q=this.#j,Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",Q?"true":"false"),this.setAttribute("aria-pressed",Z?"true":"false"),q==="add"||q==="remove"){let W=this.querySelector("fig-button"),N=this.getAttribute("aria-label")||(q==="add"?"Add color stop":"Remove color stop");if(W?.setAttribute("aria-label",N),Q)W?.setAttribute("disabled","");else W?.removeAttribute("disabled");return}let $=this.#Q||this.#q;if(!$)return;let J=this.getAttribute("aria-label")||"Color stop",j=this.getAttribute("aria-labelledby"),_=this.getAttribute("aria-describedby");if(j)$.setAttribute("aria-labelledby",j),$.removeAttribute("aria-label");else $.setAttribute("aria-label",J),$.removeAttribute("aria-labelledby");if(_)$.setAttribute("aria-describedby",_);else $.removeAttribute("aria-describedby")}#M(q,Q){let Z=this.#U(q?.color),$=this.#U(this.getAttribute("value"));if(Z!==$)this.setAttribute("value",Z);else this.#L();let J={color:this.value};if(this.#W){if(q?.opacity!==void 0)J.opacity=q.opacity;else if(q?.alpha!==void 0)J.opacity=Math.round(q.alpha*100)}Object.assign(J,l(J.color,this.#W?q?.alpha:1,J.opacity)),this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!0,composed:!0,detail:J}))}#B(q){q.stopPropagation(),this.#M(q.detail||{color:q.target?.value},"input")}#R(q){q.stopPropagation(),this.#M(q.detail||{color:q.target?.value},"change")}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(!this.isConnected)return;switch(q){case"control":this.#Y();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#L(),this.#z();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 z(this,"selected")}set selected(q){this.toggleAttribute("selected",Boolean(q))}get disabled(){return z(this,"disabled")}set disabled(q){this.toggleAttribute("disabled",Boolean(q))}}M("fig-color-tip",kq);class Iq 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",z(this,"selected")?"true":"false"),z(this,"disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(q){if(q==="selected")this.setAttribute("aria-selected",z(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")}}M("fig-choice",Iq);class Sq extends HTMLElement{#Q=null;#q=this.#H.bind(this);#Z=this.#D.bind(this);#$=this.#A.bind(this);#J=null;#j=null;#N=null;#_=null;#W=null;#Y=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#G(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#K(){let q=this.getAttribute("drag");return q===null||q!=="false"}get#X(){return this.getAttribute("choice-element")||"fig-choice"}#U(){let q=this.getAttribute("columns"),Q=q===null?NaN:Number(q);if(Number.isInteger(Q)&&Q>0)this.style.setProperty("--fig-chooser-grid-columns",String(Q));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from(this.querySelectorAll(`:scope > ${this.#X}`))}get selectedChoice(){return this.#Q}set selectedChoice(q){if(q&&!this.contains(q))return;let Q=this.choices;for(let $ of Q){let J=$===q,j=z($,"selected");if(J&&!j)$.setAttribute("selected","");else if(!J&&j)$.removeAttribute("selected")}this.#Q=q;let Z=q?.getAttribute("value")??"";if(this.getAttribute("value")!==Z){if(Z)this.setAttribute("value",Z)}this.#w(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.#C(),this.addEventListener("click",this.#q),this.addEventListener("keydown",this.#Z),this.addEventListener("scroll",this.#$),this.#V(),this.#P(),this.#y(),this.#O(),this.#M(),u(this,()=>{this.#z(),this.#A(),this.#L()})}#L(){let q=()=>{if(!this.isConnected)return;if(this.#Q)this.#w(this.#Q,"auto")},Q=()=>{let Z=this.querySelectorAll("img, video");for(let $ of Z){if($.tagName==="IMG"?$.complete:$.readyState>=1)continue;let J=()=>{$.removeEventListener("load",J),$.removeEventListener("loadedmetadata",J),$.removeEventListener("error",J),q()};$.addEventListener("load",J),$.addEventListener("loadedmetadata",J),$.addEventListener("error",J)}};requestAnimationFrame(()=>{Q(),q()})}disconnectedCallback(){this.removeEventListener("click",this.#q),this.removeEventListener("keydown",this.#Z),this.removeEventListener("scroll",this.#$),this.#k(),this.#J?.disconnect(),this.#J=null,this.#j?.disconnect(),this.#j=null,this.#F()}attributeChangedCallback(q,Q,Z){if(q==="value"&&Z!==Q&&Z)this.#B(Z);if(q==="disabled")this.#M();if(q==="choice-element")requestAnimationFrame(()=>this.#z());if(q==="columns")this.#U(),this.#S();if(q==="drag")if(this.#K)this.#P();else this.#k();if(q==="overflow")this.#V(),requestAnimationFrame(()=>this.#A());if(q==="layout"){if(this.#V(),Z==="horizontal")this.scrollTop=0;else this.scrollLeft=0;this.#S()}}#z(){let q=this.choices;if(!q.length){this.#Q=null;return}let Q=this.getAttribute("value");if(Q&&this.#B(Q))return;let Z=q.find(($)=>z($,"selected"));if(Z){this.selectedChoice=Z;return}this.selectedChoice=q[0]}#M(){let q=z(this,"disabled");if(q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Q of this.choices)if(q||z(Q,"disabled"))Q.setAttribute("aria-disabled","true"),Q.setAttribute("tabindex","-1");else Q.removeAttribute("aria-disabled"),Q.setAttribute("tabindex","0")}#B(q){let Q=this.choices;for(let Z of Q)if(Z.getAttribute("value")===q)return this.selectedChoice=Z,!0;return!1}#R(q){let Q=this.#X,Z=q;while(Z&&Z!==this){if(Z.matches(Q))return Z;Z=Z.parentElement}return null}#H(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.#R(q.target);if(!Q)return;if(Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.selectedChoice=Q,this.#T()}#D(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.choices.filter((j)=>!j.hasAttribute("disabled")||j.getAttribute("disabled")==="false");if(!Q.length)return;let Z=Q.indexOf(this.#Q),$=Z,J=this.hasAttribute("loop");switch(q.key){case"ArrowDown":case"ArrowRight":if(q.preventDefault(),Z<Q.length-1)$=Z+1;else if(J)$=0;break;case"ArrowUp":case"ArrowLeft":if(q.preventDefault(),Z>0)$=Z-1;else if(J)$=Q.length-1;break;case"Home":q.preventDefault(),$=0;break;case"End":q.preventDefault(),$=Q.length-1;break;case"Enter":case" ":if(q.preventDefault(),document.activeElement?.matches(this.#X)){let j=this.#R(document.activeElement);if(j&&j!==this.#Q)this.selectedChoice=j,this.#T()}return;default:return}if($!==Z&&Q[$])this.selectedChoice=Q[$],Q[$].focus(),this.#T()}#T(){let q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:q,bubbles:!0}))}#A(){if(this.#G==="scrollbar")return;let q=this.getAttribute("layout")==="horizontal";a(this,this,q?"x":"y")}#O(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#A(),this.#S()}),this.#j.observe(this)}#P(){if(this.#W?.bound)return;if(!this.#K)return;let q=(j)=>{if(j.button!==0)return;if(j.target.closest("[data-fig-chooser-nav]"))return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#W.active=!0,this.#W.didDrag=!1,this.#W.startX=j.clientX,this.#W.startY=j.clientY,this.#W.scrollLeft=this.scrollLeft,this.#W.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Q=(j)=>{if(!this.#W.active)return;let _=this.getAttribute("layout")==="horizontal",W=j.clientX-this.#W.startX,N=j.clientY-this.#W.startY;if(!this.#W.didDrag&&Math.abs(_?W:N)>3)this.#W.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(j.pointerId);if(!this.#W.didDrag)return;if(_)this.scrollLeft=this.#W.scrollLeft-W;else this.scrollTop=this.#W.scrollTop-N},Z=(j)=>{if(!this.#W.active)return;let _=this.#W.didDrag;if(this.#W.active=!1,this.#W.didDrag=!1,this.style.cursor="",this.style.userSelect="",j.pointerId!==void 0)try{this.releasePointerCapture(j.pointerId)}catch{}if(_)j.preventDefault(),j.stopPropagation()},$=(j)=>{if(this.#W?.suppressClick)j.stopPropagation(),j.preventDefault(),this.#W.suppressClick=!1},J=(j)=>{if(this.#W?.didDrag)this.#W.suppressClick=!0,setTimeout(()=>{if(this.#W)this.#W.suppressClick=!1},0)};this.#W={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:q,onPointerMove:Q,onPointerUp:Z,onClick:$,onPointerUpCapture:J},this.addEventListener("pointerdown",q),window.addEventListener("pointermove",Q),window.addEventListener("pointerup",Z),this.addEventListener("pointerup",J,!0),this.addEventListener("click",$,!0)}#k(){if(!this.#W?.bound)return;this.removeEventListener("pointerdown",this.#W.onPointerDown),window.removeEventListener("pointermove",this.#W.onPointerMove),window.removeEventListener("pointerup",this.#W.onPointerUp),this.removeEventListener("pointerup",this.#W.onPointerUpCapture,!0),this.removeEventListener("click",this.#W.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#W=null}#C(){if(this.#Y)return;let q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!q)return;this.#Y=!0;try{let Q=Array.from(q.childNodes);q.replaceWith(...Q)}finally{this.#Y=!1}}#V(){if(this.#G==="scrollbar")this.#F();else this.#f()}#F(){this.#N?.remove(),this.#_?.remove(),this.#N=null,this.#_=null,this.classList.remove("overflow-start","overflow-end")}#f(){if(this.#N&&this.#_&&this.contains(this.#N)&&this.contains(this.#_))return;this.#N?.remove(),this.#_?.remove(),this.#N=null,this.#_=null;let q=N0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#I(-1),onEnd:()=>this.#I(1)});this.#N=q.start,this.#_=q.end,this.prepend(this.#N),this.append(this.#_)}#I(q){let Q=this.getAttribute("layout")==="horizontal";r(this,Q?"x":"y",q)}#S(){if(!this.#Q)return;this.#w(this.#Q,"auto")}#w(q,Q="smooth"){if(!q)return;requestAnimationFrame(()=>{if(!q.isConnected)return;let Z=this.scrollHeight>this.clientHeight,$=this.scrollWidth>this.clientWidth;if(!$&&!Z)return;let J=q.getBoundingClientRect(),j=this.getBoundingClientRect(),_={behavior:Q},W=!1;if(Z){let N=J.top-j.top+this.scrollTop,K=this.scrollHeight-this.clientHeight;_.top=Math.max(0,Math.min(N+J.height/2-this.clientHeight/2,K)),W=!0}if($){let N=J.left-j.left+this.scrollLeft,K=this.scrollWidth-this.clientWidth;_.left=Math.max(0,Math.min(N+J.width/2-this.clientWidth/2,K)),W=!0}if(W)this.scrollTo(_);this.#A()})}#y(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>{if(this.#Y)return;this.#C(),this.#V(),this.#M();let q=this.choices;if(this.#Q&&!q.includes(this.#Q))this.#Q=null,this.#z();else if(!this.#Q&&q.length)this.#z();requestAnimationFrame(()=>this.#A())}),this.#J.observe(this,{childList:!0,subtree:!1})}}M("fig-chooser",Sq);class Cq 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;#q=!1;#Z=null;#$=null;#J=!1;#j=null;#N=null;#_=null;#W=null;get#Y(){let q=(this.getAttribute("tip")||"").trim().toLowerCase();return q==="color"||q==="add"||q==="remove"?q:null}get#G(){return!this.hasAttribute("data-no-color-picker")}get#K(){let q=this.getAttribute("drag");return q!==null&&q!=="false"}get#X(){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 Q=q.trim().toLowerCase();if(Q==="modifier")return"modifier";if(Q===""||Q==="true")return"true";return"false"}#L(q){let Q=this.#U;if(Q==="true")return!0;if(Q==="modifier")return!!q;return!1}#z(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}#M(q,Q){if(Math.abs(q-Q)<0.1){let $=(q+Q)/2;return{x:$,y:$}}if(Math.abs(1-q-Q)<0.1)return{x:q,y:1-q};return{x:q,y:Q}}#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:Q,py:Z}=this.#n(q.getBoundingClientRect());return`${Math.round(Q*100)}% ${Math.round(Z*100)}%`}set value(q){this.setAttribute("value",q??"0% 0%")}#R(q){let Q=q==null?"":String(q).trim();if(!Q)return{xPct:0,yPct:0};let Z=Q.split(/[\s,]+/).filter(Boolean),$=(_)=>{if(!_)return 0;let W=_.includes("px"),N=_.includes("%"),K=parseFloat(_.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(W)return{px:K};if(N||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},J=$(Z[0]),j=$(Z[1]??Z[0]);return{xToken:J,yToken:j}}#H(q){let Q=this.#B();if(!Q)return;let{xToken:Z,yToken:$}=this.#R(q),J=Q.getBoundingClientRect(),j=(N,K)=>{if(N&&typeof N==="object"&&"px"in N)return Math.max(0,Math.min(K,N.px));return null},_=(N)=>{return`${typeof N==="number"?N:0}%`},W=this.#X;if(this.#D(W),W.x){let N=j(Z,J.width);this.style.left=N===null?_(Z):`${Math.round(N)}px`}if(W.y){let N=j($,J.height);this.style.top=N===null?_($):`${Math.round(N)}px`}}#D(q=this.#X){this.style.setProperty("--fig-handle-position-translate",`${q.x?"-50%":"0"} ${q.y?"-50%":"0"}`)}#T(){this.#J=!0,this.setAttribute("value",this.value),this.#J=!1}get#A(){return this.getAttribute("hit-area-mode")||"handle"}#O(){let q=this.getAttribute("hit-area");if(!q)return null;let Q=q.trim().split(/\s+/),Z=0,$=0,J=!1,j=[];for(let _ of Q){if(_==="circle"){J=!0;continue}let W=parseFloat(_);if(Number.isFinite(W))j.push(W)}if(j.length>=2)Z=j[0],$=j[1];else if(j.length===1)Z=j[0],$=j[0];else return null;return{vPad:Z,hPad:$,circle:J}}#P(){let q=this.#O();if(!q){if(this.#W)this.#W.remove(),this.#W=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#W){let Q=document.createElement("div");Q.classList.add("fig-handle-hit-area"),Q.addEventListener("pointerdown",(Z)=>this.#k(Z)),this.prepend(Q),this.#W=Q}if(this.style.setProperty("--fig-handle-hit-area-size",String(q.hPad*2)),q.circle)this.#W.style.borderRadius="50%";else this.#W.style.borderRadius="inherit"}#k(q){if(z(this,"disabled"))return;if(q.target!==this.#W)return;if(this.#A==="delegate")q.preventDefault(),q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:q}}));else this.#y(q)}connectedCallback(){this.#S(),this.#I(),this.#P(),this.addEventListener("click",this.#C),document.addEventListener("pointerdown",this.#V),document.addEventListener("keydown",this.#F);let q=this.getAttribute("value");if(q)this.#H(q);if(this.#Y)this.#l()}disconnectedCallback(){if(this.#w(),this.#s(),this.#v(),this.#d(),this.#W)this.#W.remove(),this.#W=null;this.removeEventListener("click",this.#C),document.removeEventListener("pointerdown",this.#V),document.removeEventListener("keydown",this.#F)}select(){if(z(this,"disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#C=(q)=>{if(this.#q){this.#q=!1;return}if(this.getAttribute("type")==="color"&&this.#G&&!this.#Y){this.#x();return}this.select()};#V=(q)=>{if(this.contains(q.target))return;if((this.#j||this.#N)&&q.target.closest?.("dialog, [popover]"))return;this.deselect()};#F=(q)=>{if(q.defaultPrevented)return;if(q.target===this&&this.#K&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(q.key)){if(this.#f(q)){if(q.preventDefault(),!z(this,"selected"))this.select()}return}if(q.key!=="Enter"&&q.key!==" ")return;if(q.target===this&&!z(this,"selected")){if(q.preventDefault(),this.getAttribute("type")==="color"&&this.#G&&!this.#Y)this.#x();else this.select();return}if(!z(this,"selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#G)return;if(q.preventDefault(),!this.#Y)this.#x()};#f(q){if(z(this,"disabled"))return!1;let Q=this.#B();if(!Q)return!1;let Z=Q.getBoundingClientRect();if(Z.width<=0||Z.height<=0)return!1;let $=this.#X,J=this.#n(Z),j=q.shiftKey?0.1:0.01,_=J.px,W=J.py;switch(q.key){case"ArrowLeft":if(!$.x)return!1;_-=j;break;case"ArrowRight":if(!$.x)return!1;_+=j;break;case"ArrowUp":if(!$.y)return!1;W-=j;break;case"ArrowDown":if(!$.y)return!1;W+=j;break;case"Home":if($.x)_=0;if($.y)W=0;break;case"End":if($.x)_=1;if($.y)W=1;break;default:return!1}if(_=Math.max(0,Math.min(1,_)),W=Math.max(0,Math.min(1,W)),this.#D($),$.x)this.style.left=`${Math.round(_*Z.width)}px`;if($.y)this.style.top=`${Math.round(W*Z.height)}px`;this.#T();let N={...this.#n(Z),shiftKey:q.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:N})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:N})),!0}attributeChangedCallback(q,Q,Z){if(q==="color"){if(!Z||Z==="false"||Z==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",Z);if(this.#j&&this.#Y==="color"&&Z)this.#j.setAttribute("value",Z);this.#E()}if(q==="drag")this.#I();if(q==="hit-area")this.#P();if(q==="selected")this.#p();if(q==="selected"||q==="disabled"||q==="type"||q==="tip"||q==="aria-label"||q==="aria-labelledby")this.#S();if(q==="value"&&!this.#J&&!this.#Q)this.#H(Z);if(q==="tip"){if(this.#s(),this.#Y)this.#v(),this.#l()}}#I(){if(this.#K&&!this.#Z)this.#Z=(q)=>this.#y(q),this.addEventListener("pointerdown",this.#Z);else if(!this.#K&&this.#Z)this.#w()}#S(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Q=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",Q?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let Z=this.#Y||this.getAttribute("type")||"handle";this.setAttribute("aria-label",Z==="color"?"Color handle":Z==="add"?"Add handle":Z==="remove"?"Remove handle":"Handle")}}#w(){if(this.#$?.(),this.#$=null,this.#Z)this.removeEventListener("pointerdown",this.#Z),this.#Z=null;this.#Q=!1,this.#q=!1}#y(q){if(!this.#K||z(this,"disabled"))return;q.preventDefault();let Q=this.#B();if(!Q)return;this.#$?.(),this.#Q=!0;let Z=this.#X,$=null,J=this.getBoundingClientRect(),j=J.left+J.width/2,_=J.top+J.height/2,W=q.clientX-j,N=q.clientY-_,K=q.clientX,G=q.clientY,U=3,X=(D,F,H=!1)=>{let B=Q.getBoundingClientRect();$=B;let f=this.#n(B),I=D-W-B.left,S=F-N-B.top,x=Math.max(0,Math.min(B.width,I)),w=Math.max(0,Math.min(B.height,S)),g=B.width>0?Z.x?x/B.width:f.px:0.5,d=B.height>0?Z.y?w/B.height:f.py:0.5;if(this.#L(H)){if(Z.x)g=this.#z(g);if(Z.y)d=this.#z(d);if(Z.x&&Z.y){let n=this.#M(g,d);g=n.x,d=n.y}}if(this.#D(Z),Z.x)this.style.left=`${Math.round(Math.max(0,Math.min(B.width,g*B.width)))}px`;if(Z.y)this.style.top=`${Math.round(Math.max(0,Math.min(B.height,d*B.height)))}px`},O=(D)=>{if(!this.#Q)return;if(!this.#q){let F=D.clientX-K,H=D.clientY-G;if(F*F+H*H<U*U)return;if(this.#m(),this.classList.add("dragging"),this.style.cursor="grabbing",!z(this,"selected"))this.select()}this.#q=!0,X(D.clientX,D.clientY,D.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#n($),shiftKey:D.shiftKey}}))},R=(D)=>{if(L(),this.#q){X(D.clientX,D.clientY,D.shiftKey),this.#T(),this.#H(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#n($)}));let F=(H)=>{H.stopPropagation(),H.preventDefault()};this.addEventListener("click",F,{capture:!0,once:!0})}else this.#T();this.#q=!1},L=()=>{if(window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",R),this.#Q=!1,this.style.cursor="",this.classList.remove("dragging"),this.#$===L)this.#$=null};this.#$=L,window.addEventListener("pointermove",O),window.addEventListener("pointerup",R)}showColorTip(){if(!this.#Y)return;if(this.#j){this.#j.style.display="";return}this.#l()}hideColorTip(){if(!this.#j)return;this.#j.style.display="none"}#u(q=this.getAttribute("color")){let Q={color:"#D9D9D9",opacity:100},Z=String(q||"").trim();if(!Z)return Q;let $=(j)=>{let _=j.replace("#","").trim();if(_.length===3||_.length===4){let[W,N,K,G]=_;return{color:`#${W}${W}${N}${N}${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 Q},J=(j,_,W)=>{let N=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${N(j)}${N(_)}${N(W)}`.toUpperCase()};if(Z.startsWith("#"))return $(Z);try{let{ctx:j}=z0(1,1);j.fillStyle="#000000",j.fillStyle=Z;let _=j.fillStyle;if(_.startsWith("#"))return $(_);let W=_.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(W)return{color:J(W[1],W[2],W[3]),opacity:W[4]!==void 0?Math.round(parseFloat(W[4])*100):100}}catch{}return Q}#b(){let{color:q,opacity:Q}=this.#u();return JSON.stringify(Q<100?{type:"solid",color:q,opacity:Q}:{type:"solid",color:q})}#E(){if(!this.#N)return;this.#N.setAttribute("value",this.#b())}#h(){if(!o())return null;if(this.#N)return this.#N;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.#b()),q.anchorElement=this;let Q=document.createElement("span");return Q.hidden=!0,q.appendChild(Q),q.addEventListener("input",this.#a),q.addEventListener("change",this.#i),q.addEventListener("close",this.#t),this.appendChild(q),this.#N=q,q}#x(){if(z(this,"disabled"))return;let q=this.#h();if(!q){this.#o();return}this.setAttribute("selected",""),this.#E(),q.open()}#v(){if(!this.#N)return;this.#N.removeEventListener("input",this.#a),this.#N.removeEventListener("change",this.#i),this.#N.removeEventListener("close",this.#t),this.#N.close(),this.#N.remove(),this.#N=null,this.removeAttribute("selected")}#g(){if(this.#_)return this.#_;let q=document.createElement("input");return q.type="color",q.tabIndex=-1,q.setAttribute("aria-hidden","true"),q.style.position="fixed",q.style.inlineSize="1px",q.style.blockSize="1px",q.style.opacity="0",q.style.pointerEvents="none",q.addEventListener("input",this.#J0),q.addEventListener("change",this.#q0),this.appendChild(q),this.#_=q,q}#o(){let q=this.#g(),{color:Q}=this.#u();q.value=Q,this.setAttribute("selected",""),q.click()}#d(){if(!this.#_)return;this.#_.removeEventListener("input",this.#J0),this.#_.removeEventListener("change",this.#q0),this.#_.remove(),this.#_=null}#m(){if(this.getAttribute("type")!=="color")return;this.#N?.close()}#l(){let q=this.#Y;if(!q)return;if(this.#j)return;let Q=document.createElement("fig-color-tip");if(q==="add"||q==="remove")Q.setAttribute("control",q);else Q.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Q.setAttribute("alpha","true");Q.addEventListener("input",this.#_0),Q.addEventListener("change",this.#j0),Q.addEventListener("add",this.#e),Q.addEventListener("remove",this.#e),this.appendChild(Q),this.#j=Q,this.#p()}#s(){if(!this.#j)return;this.#j.removeEventListener("input",this.#_0),this.#j.removeEventListener("change",this.#j0),this.#j.removeEventListener("add",this.#e),this.#j.removeEventListener("remove",this.#e),this.#j.remove(),this.#j=null}#p(){if(!this.#j||this.#Y!=="color")return;let q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#j.toggleAttribute("selected",q)}#c(q,Q){if(Q===void 0||Q>=100)return q;let{r:Z,g:$,b:J}=i(q);return`rgba(${Z}, ${$}, ${J}, ${Q/100})`}#r(q){if(!q?.color)return null;let Q=q.opacity!==void 0?q.opacity:q.alpha!==void 0?Math.round(q.alpha*100):void 0;return{color:q.color,opacity:Q,...l(q.color,q.alpha,Q)}}#a=(q)=>{q.stopPropagation();let Q=this.#r(q.detail);if(!Q)return;this.setAttribute("color",this.#c(Q.color,Q.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Q}))};#i=(q)=>{q.stopPropagation();let Q=this.#r(q.detail);if(!Q)return;this.setAttribute("color",this.#c(Q.color,Q.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Q}))};#$0(q){let{opacity:Q}=this.#u();return{...Q<100?{color:q,opacity:Q}:{color:q},...l(q,void 0,Q)}}#J0=(q)=>{q.stopPropagation();let Q=this.#$0(q.target.value);this.setAttribute("color",this.#c(Q.color,Q.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Q}))};#q0=(q)=>{q.stopPropagation();let Q=this.#$0(q.target.value);this.setAttribute("color",this.#c(Q.color,Q.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Q}))};#t=()=>{this.removeAttribute("selected")};#_0=(q)=>{if(q.stopPropagation(),q.detail?.color){let Q={color:q.detail.color,opacity:q.detail.opacity,...l(q.detail.color,q.detail.alpha,q.detail.opacity)};this.setAttribute("color",this.#c(Q.color,Q.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Q}))}};#j0=(q)=>{if(q.stopPropagation(),q.detail?.color){let Q={color:q.detail.color,opacity:q.detail.opacity,...l(q.detail.color,q.detail.alpha,q.detail.opacity)};this.setAttribute("color",this.#c(Q.color,Q.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Q}))}};#e=(q)=>{q.stopPropagation(),this.dispatchEvent(new CustomEvent(q.type,{bubbles:!0,composed:!0}))};#n(q){let Q=q||this.#B()?.getBoundingClientRect();if(!Q)return{x:0,y:0,px:0,py:0};let Z=this.getBoundingClientRect(),$=this.offsetWidth/2,J=this.offsetHeight/2,j=Z.left-Q.left,_=Z.top-Q.top,W=j+$,N=_+J,K=Q.width>0?W/Q.width:0,G=Q.height>0?N/Q.height:0;return{x:j,y:_,px:K,py:G}}}M("fig-handle",Cq);class Vq 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,Q,Z){if(Q===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")}}M("fig-menu-item",Vq);class Eq 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,Q,Z){if(Q===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")}}M("fig-separator",Eq);class xq extends HTMLElement{#Q=null;#q=null;#Z=null;#$=null;#J=null;#j=null;#N=null;#_=null;#W;#Y;#G;#K;#X;#U=this.#P.bind(this);#L=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open","trigger"]}constructor(){super();this.#W=this.#w.bind(this),this.#Y=this.#y.bind(this),this.#G=this.#b.bind(this),this.#K=this.#E.bind(this),this.#X=this.#h.bind(this)}get value(){return this.getAttribute("value")||""}set value(q){this.setAttribute("value",q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(q){if(q){if(this.#S())return;this.setAttribute("open","")}else this.removeAttribute("open")}connectedCallback(){if(this.#z(),this.#B(),this.#R(),this.#H(),this.#A(),this.#T(),this.#I(),this.open)this.#v()}disconnectedCallback(){if(this.#D(),this.#O(),document.removeEventListener("keydown",this.#K,!0),this.#J)this.#J.disconnect(),this.#J=null;if(this.#Q){this.#Q.removeEventListener("close",this.#X);let q=Array.from(this.#q?.querySelectorAll(":scope > fig-menu-item, :scope > fig-separator")??[]);for(let Q of q)this.insertBefore(Q,this.#Q);this.#Q.remove(),this.#Q=null,this.#q=null}}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="open"){if(Z===null||Z==="false")this.#g();else{if(this.#S()){this.removeAttribute("open");return}this.#v()}return}if(q==="disabled"){this.#I();return}if(this.#Q&&(q==="position"||q==="offset"||q==="closedby"))if(Z!==null)this.#Q.setAttribute(q,Z);else this.#Q.removeAttribute(q)}#z(){this.#Z=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-separator)")}#M(){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 Q=this.getAttribute("offset");if(Q)this.#Q.setAttribute("offset",Q);let Z=this.getAttribute("closedby");if(Z)this.#Q.setAttribute("closedby",Z);if(this.#Z)this.#Q.anchor=this.#Z;this.#q=document.createElement("div"),this.#q.className="fig-menu-options",this.#q.setAttribute("role","presentation"),this.#Q.appendChild(this.#q),this.#Q.addEventListener("close",this.#X),this.appendChild(this.#Q)}#R(){if(!this.#q)return;let q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-separator"));for(let Q of q)this.#q.appendChild(Q)}#H(){if(this.addEventListener("keydown",this.#K),this.#Z)this.#Z.addEventListener("click",this.#W),this.#Z.addEventListener("contextmenu",this.#Y),this.#Z.setAttribute("aria-haspopup","menu"),this.#Z.setAttribute("aria-expanded","false"),this.#Z.setAttribute("aria-controls",this.#Q.getAttribute("id"));if(this.#Q)this.#Q.addEventListener("click",this.#G),this.#Q.addEventListener("keydown",this.#K)}#D(){if(this.removeEventListener("keydown",this.#K),this.#Z)this.#Z.removeEventListener("click",this.#W),this.#Z.removeEventListener("contextmenu",this.#Y);if(this.#Q)this.#Q.removeEventListener("click",this.#G),this.#Q.removeEventListener("keydown",this.#K)}#T(){this.#J=new MutationObserver((q)=>{for(let Q of q)for(let Z of Q.addedNodes){if(Z.nodeType!==1||Z===this.#Q)continue;if((Z.tagName==="FIG-MENU-ITEM"||Z.tagName==="FIG-SEPARATOR")&&Z.parentElement===this)this.#q?.appendChild(Z);else if(!this.#Z&&Z.parentElement===this){if(this.#z(),this.#Z)this.#Z.addEventListener("click",this.#W),this.#Z.addEventListener("contextmenu",this.#Y),this.#Z.setAttribute("aria-haspopup","menu"),this.#Z.setAttribute("aria-expanded","false"),this.#Z.setAttribute("aria-controls",this.#Q.getAttribute("id")),this.#Q.anchor=this.#Z,this.#I()}}this.#P()}),this.#J.observe(this,{childList:!0})}#A(){if(!this.#q)return;this.#k(),this.#q.addEventListener("scroll",this.#U,{passive:!0}),this.#j?.disconnect(),this.#j=new ResizeObserver(()=>this.#P()),this.#j.observe(this.#q),requestAnimationFrame(()=>this.#P())}#O(){this.#q?.removeEventListener("scroll",this.#U),this.#j?.disconnect(),this.#j=null,this.#C()}#P(){return a(this.#q,this.#q,"y")}#k(){if(this.#N&&this.#_&&this.#q?.contains(this.#N)&&this.#q?.contains(this.#_))return;this.#C();let q=N0({owner:"menu",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>r(this.#q,"y",-1),onEnd:()=>r(this.#q,"y",1)});this.#N=q.start,this.#_=q.end,this.#q.prepend(this.#N),this.#q.append(this.#_)}#C(){this.#N?.remove(),this.#_?.remove(),this.#N=null,this.#_=null,this.#q?.classList.remove("overflow-start","overflow-end")}#V(){if(!this.#q)return[];return Array.from(this.#q.querySelectorAll("fig-menu-item")).filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false")}#F(){let q=this.#V();if(!q.length){this.#L=-1;return}let Q=document.activeElement,Z=q.findIndex(($)=>$===Q||$.contains(Q));this.#L=Z>=0?Z:-1}#f(q){let Q=this.#V();if(!Q.length)return;let Z=(q+Q.length)%Q.length;this.#L=Z;let $=Q[Z];$.focus(),C0(this.#q,$,"y")}#I(){let q=this.#S();if(q)if(this.open)this.removeAttribute("open");else this.#g();if(!this.#Z)return;if(q)this.#Z.setAttribute("disabled",""),this.#Z.setAttribute("aria-disabled","true"),this.#Z.setAttribute("aria-expanded","false");else this.#Z.removeAttribute("disabled"),this.#Z.removeAttribute("aria-disabled")}#S(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#w(q){if(this.#M())return;if(this.#S())return;q.stopPropagation();let Q=this.#Q?.matches?.(":open")??!1;if(this.open&&!Q)this.removeAttribute("open");if(this.open&&Q)this.open=!1;else{if(this.#Q&&this.#Z)this.#Q.anchor=this.#Z;this.open=!0}}#y(q){if(!this.#M())return;if(this.#S())return;q.preventDefault(),q.stopPropagation(),this.#u(q.clientX,q.clientY)}#u(q,Q){let Z=!1,$=0,J=()=>{window.clearTimeout($),window.removeEventListener("pointerup",j,!0),window.removeEventListener("pointercancel",_,!0)},j=()=>{if(Z)return;Z=!0,J(),requestAnimationFrame(()=>this.showAt(q,Q))},_=()=>{if(Z)return;Z=!0,J()};window.addEventListener("pointerup",j,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),$=window.setTimeout(j,180)}#b(q){if(this.#S())return;let Q=q.target.closest("fig-menu-item");if(!Q)return;if(Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.#x(Q)}#E(q){if(this.#S())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.#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(()=>this.#f(0))}return}let Q=this.#V();if(!Q.length)return;switch(q.key){case"ArrowDown":{q.preventDefault(),this.#F(),this.#f(this.#L+1);break}case"ArrowUp":{q.preventDefault(),this.#F(),this.#f(this.#L-1);break}case"Home":{q.preventDefault(),this.#f(0);break}case"End":{q.preventDefault(),this.#f(Q.length-1);break}case"Escape":{q.preventDefault(),this.open=!1,this.#Z?.focus();break}case"Enter":case" ":{this.#F();let Z=Q[this.#L];if(!Z)return;q.preventDefault(),this.#x(Z);break}}}#h(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#Z)this.#Z.setAttribute("aria-expanded","false"),this.#Z.focus();this.#L=-1}#x(q){let Q=q.getAttribute("value")||q.textContent.trim();this.setAttribute("value",Q),this.dispatchEvent(new CustomEvent("change",{detail:{value:Q,item:q},bubbles:!0})),this.open=!1}showAt(q,Q){if(this.#S())return;if(this.#$={getBoundingClientRect:()=>({width:0,height:0,top:Q,right:q,bottom:Q,left:q,x:q,y:Q})},this.#Q)this.#Q.anchor=this.#$;if(this.open)this.open=!1;requestAnimationFrame(()=>{if(this.#S())return;this.open=!0})}#v(){if(!this.#Q||this.#S()){if(this.hasAttribute("open"))this.removeAttribute("open");return}if(this.#Q.open=!0,document.addEventListener("keydown",this.#K,!0),this.#Z)this.#Z.setAttribute("aria-expanded","true");this.#L=-1,requestAnimationFrame(()=>{if(this.#P(),!this.#Z?.matches?.(":focus-visible"))return;this.#f(0)})}#g(){if(!this.#Q)return;document.removeEventListener("keydown",this.#K,!0),this.#Q.open=!1,this.#Z?.setAttribute("aria-expanded","false")}}M("fig-menu",xq);