@rogieking/figui3 6.6.0 → 6.6.2

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.
Files changed (3) hide show
  1. package/dist/fig.js +26 -26
  2. package/fig.js +588 -213
  3. package/package.json +1 -1
package/dist/fig.js CHANGED
@@ -1,4 +1,4 @@
1
- var B1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var O1={};var G0=B1(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(Q,$,J){if(Q.importNode.length!=1||$.get("ungap-li"))return;var Z="extends";try{var j={};j[Z]="li";var q=HTMLLIElement,_=function(){return Reflect.construct(q,[],_)};if(_.prototype=J.create(q.prototype),$.define("ungap-li",_,j),!/is="ungap-li"/.test(new _().outerHTML))throw j}catch(X){(function(){var Y="attributeChangedCallback",K="connectedCallback",N="disconnectedCallback",L=Element.prototype,O=J.assign,H=J.create,B=J.defineProperties,U=J.getOwnPropertyDescriptor,z=J.setPrototypeOf,A=$.define,G=$.get,M=$.upgrade,D=$.whenDefined,T=H(null),P=new WeakMap,E={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(W){return typeof W=="string"&&/^HTML(?!Element)/.test(W)}).forEach(function(W){function R(){}var F=self[W];z(R,F),(R.prototype=F.prototype).constructor=R,F={},F[W]={value:R},B(self,F)}),new MutationObserver(X0).observe(Q,E),N0(Document.prototype,"importNode"),N0(Node.prototype,"cloneNode"),B($,{define:{value:function(W,R,F){if(W=W.toLowerCase(),F&&Z in F){T[W]=O({},F,{Class:R});var C=F[Z]+'[is="'+W+'"]',k=Q.querySelectorAll(C);for(var I=0,x=k.length;I<x;I++)d(k[I])}else A.apply($,arguments)}},get:{value:function(W){return W in T?T[W].Class:G.call($,W)}},upgrade:{value:function(W){var R=e(W);if(R&&!(W instanceof R.Class))W0(W,R);else M.call($,W)}},whenDefined:{value:function(W){return W in T?Promise.resolve():D.call($,W)}}});var f=Q.createElement;B(Q,{createElement:{value:function(W,R){var F=f.call(Q,W);if(R&&"is"in R)F.setAttribute("is",R.is),$.upgrade(F);return F}}});var w=U(L,"attachShadow").value,c=U(L,"innerHTML");B(L,{attachShadow:{value:function(){var W=w.apply(this,arguments);return new MutationObserver(X0).observe(W,E),W}},innerHTML:{get:c.get,set:function(W){if(c.set.call(this,W),/\bis=("|')?[a-z0-9_-]+\1/i.test(W))i(this,d)}}});function X0(W){for(var R=0,F=W.length;R<F;R++){var C=W[R],k=C.addedNodes,I=C.removedNodes;for(var x=0,o=k.length;x<o;x++)d(k[x]);for(var Q0=0,M1=I.length;Q0<M1;Q0++)K0(I[Q0])}}function Y0(W){for(var R=0,F=W.length;R<F;R++){var C=W[R],k=C.attributeName,I=C.oldValue,x=C.target,o=x.getAttribute(k);if(Y in x&&!(I==o&&o==null))x[Y](k,I,x.getAttribute(k),null)}}function K0(W){if(W.nodeType!==1)return;var R=e(W);if(R&&W instanceof R.Class&&N in W&&P.get(W)!==N)P.set(W,N),Promise.resolve(W).then(L1);i(W,K0)}function e(W){var R=W.getAttribute("is");if(R){if(R=R.toLowerCase(),R in T)return T[R]}return null}function U1(W){W[K]()}function L1(W){W[N]()}function W0(W,R){var F=R.Class,C=F.observedAttributes||[];if(z(W,F.prototype),C.length){new MutationObserver(Y0).observe(W,{attributes:!0,attributeFilter:C,attributeOldValue:!0});var k=[];for(var I=0,x=C.length;I<x;I++)k.push({attributeName:C[I],oldValue:null,target:W});Y0(k)}}function d(W){if(W.nodeType!==1)return;var R=e(W);if(R){if(!(W instanceof R.Class))W0(W,R);if(K in W&&W.isConnected&&P.get(W)!==K)P.set(W,K),Promise.resolve(W).then(U1)}i(W,d)}function i(W,R){for(var F=W.content,C=(F&&F.nodeType==11?F:W).querySelectorAll("[is]"),k=0,I=C.length;k<I;k++)R(C[k])}function N0(W,R){var F=W[R],C={};C[R]={value:function(){var k=F.apply(this,arguments);switch(k.nodeType){case 1:case 11:i(k,d)}return k}},B(W,C)}})()}})(document,customElements,Object)});function R1(){if(typeof navigator>"u")return!1;let Q=navigator.userAgent||"",$=/\b(iPad|iPhone|iPod)\b/.test(Q)||/\bMacintosh\b/.test(Q)&&/\bMobile\b/.test(Q),J=/\bAppleWebKit\b/.test(Q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(Q);return $||J}function v(Q,$={}){let J=document.createElement("fig-icon");if(Q)J.setAttribute("name",Q);if($.size)J.setAttribute("size",$.size);if($.className)J.className=$.className;return J}function B0({owner:Q,onStart:$,onEnd:J,startClass:Z="",endClass:j="",chevronClass:q=""}={}){let _=(X,Y)=>{let K=document.createElement("button");if(K.className=["fig-overflow",`fig-overflow-${X}`,X==="start"?Z:j].filter(Boolean).join(" "),K.dataset.figOverflow=X,Q)K.setAttribute(`data-fig-${Q}-nav`,X);return K.setAttribute("tabindex","-1"),K.setAttribute("aria-label",X==="start"?"Scroll back":"Scroll forward"),K.appendChild(v("chevron",{size:"small",className:["fig-overflow-chevron",q].filter(Boolean).join(" ")})),K.addEventListener("pointerdown",(N)=>{N.preventDefault(),N.stopPropagation(),Y?.(N)}),K};return{start:_("start",$),end:_("end",J)}}function O0(Q,$,J="x",Z=2){if(!Q||!$)return!1;let j=J==="x",q=j?$.scrollWidth:$.scrollHeight,_=j?$.clientWidth:$.clientHeight,X=j?$.scrollLeft:$.scrollTop,Y=q-_>Z,K=!Y||X<=Z,N=!Y||X+_>=q-Z;return Q.classList.toggle("overflow-start",!K),Q.classList.toggle("overflow-end",!N),Y}function $0(Q,$="x",J=1){if(!Q)return;let Z=$==="x",q=(Z?Q.clientWidth:Q.clientHeight)*0.8*J;Q.scrollBy({[Z?"left":"top"]:q,behavior:"smooth"})}function m(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function A1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let Q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class $ extends HTMLButtonElement{}try{return customElements.define(Q,$,{extends:"button"}),document.createElement("button",{is:Q})instanceof $}catch(J){return!1}}var R0=R1()&&!A1(),z1=(R0?Promise.resolve().then(() => (G0(),O1)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q});function J0(Q,$,J){let Z=()=>{if(!customElements.get(Q))customElements.define(Q,$,J)};if(!R0){Z();return}z1.then(Z).catch((j)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${Q}".`,j)})}function y(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}var D1=1e4;function H1(){return D1++}function V(Q,$,J){if(J&&J.trim())Q.style.setProperty($,J.trim());else Q.style.removeProperty($)}var g=null,U0=null;function Z0(Q=1,$=1){if(!g)g=document.createElement("canvas"),U0=g.getContext("2d");if(g.width!==Q)g.width=Q;if(g.height!==$)g.height=$;return{canvas:g,ctx:U0}}class A0 extends HTMLElement{type;#$;#Q=["aria-label","aria-labelledby","aria-describedby","title"];#j=this.#X.bind(this);constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){this.type=this.getAttribute("type")||"button";let Q=this.type==="select"||this.type==="upload",$=Q?"span":"button",J=Q?"":` type="${this.type}"`;this.shadowRoot.innerHTML=`
1
+ var O1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var R1={};var U0=O1(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(Q,$,J){if(Q.importNode.length!=1||$.get("ungap-li"))return;var Z="extends";try{var j={};j[Z]="li";var q=HTMLLIElement,_=function(){return Reflect.construct(q,[],_)};if(_.prototype=J.create(q.prototype),$.define("ungap-li",_,j),!/is="ungap-li"/.test(new _().outerHTML))throw j}catch(X){(function(){var Y="attributeChangedCallback",K="connectedCallback",N="disconnectedCallback",L=Element.prototype,O=J.assign,H=J.create,B=J.defineProperties,U=J.getOwnPropertyDescriptor,z=J.setPrototypeOf,A=$.define,G=$.get,M=$.upgrade,D=$.whenDefined,T=H(null),P=new WeakMap,k={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(W){return typeof W=="string"&&/^HTML(?!Element)/.test(W)}).forEach(function(W){function R(){}var F=self[W];z(R,F),(R.prototype=F.prototype).constructor=R,F={},F[W]={value:R},B(self,F)}),new MutationObserver(Y0).observe(Q,k),G0(Document.prototype,"importNode"),G0(Node.prototype,"cloneNode"),B($,{define:{value:function(W,R,F){if(W=W.toLowerCase(),F&&Z in F){T[W]=O({},F,{Class:R});var C=F[Z]+'[is="'+W+'"]',E=Q.querySelectorAll(C);for(var I=0,x=E.length;I<x;I++)s(E[I])}else A.apply($,arguments)}},get:{value:function(W){return W in T?T[W].Class:G.call($,W)}},upgrade:{value:function(W){var R=Q0(W);if(R&&!(W instanceof R.Class))N0(W,R);else M.call($,W)}},whenDefined:{value:function(W){return W in T?Promise.resolve():D.call($,W)}}});var f=Q.createElement;B(Q,{createElement:{value:function(W,R){var F=f.call(Q,W);if(R&&"is"in R)F.setAttribute("is",R.is),$.upgrade(F);return F}}});var w=U(L,"attachShadow").value,d=U(L,"innerHTML");B(L,{attachShadow:{value:function(){var W=w.apply(this,arguments);return new MutationObserver(Y0).observe(W,k),W}},innerHTML:{get:d.get,set:function(W){if(d.set.call(this,W),/\bis=("|')?[a-z0-9_-]+\1/i.test(W))o(this,s)}}});function Y0(W){for(var R=0,F=W.length;R<F;R++){var C=W[R],E=C.addedNodes,I=C.removedNodes;for(var x=0,l=E.length;x<l;x++)s(E[x]);for(var $0=0,B1=I.length;$0<B1;$0++)W0(I[$0])}}function K0(W){for(var R=0,F=W.length;R<F;R++){var C=W[R],E=C.attributeName,I=C.oldValue,x=C.target,l=x.getAttribute(E);if(Y in x&&!(I==l&&l==null))x[Y](E,I,x.getAttribute(E),null)}}function W0(W){if(W.nodeType!==1)return;var R=Q0(W);if(R&&W instanceof R.Class&&N in W&&P.get(W)!==N)P.set(W,N),Promise.resolve(W).then(M1);o(W,W0)}function Q0(W){var R=W.getAttribute("is");if(R){if(R=R.toLowerCase(),R in T)return T[R]}return null}function L1(W){W[K]()}function M1(W){W[N]()}function N0(W,R){var F=R.Class,C=F.observedAttributes||[];if(z(W,F.prototype),C.length){new MutationObserver(K0).observe(W,{attributes:!0,attributeFilter:C,attributeOldValue:!0});var E=[];for(var I=0,x=C.length;I<x;I++)E.push({attributeName:C[I],oldValue:null,target:W});K0(E)}}function s(W){if(W.nodeType!==1)return;var R=Q0(W);if(R){if(!(W instanceof R.Class))N0(W,R);if(K in W&&W.isConnected&&P.get(W)!==K)P.set(W,K),Promise.resolve(W).then(L1)}o(W,s)}function o(W,R){for(var F=W.content,C=(F&&F.nodeType==11?F:W).querySelectorAll("[is]"),E=0,I=C.length;E<I;E++)R(C[E])}function G0(W,R){var F=W[R],C={};C[R]={value:function(){var E=F.apply(this,arguments);switch(E.nodeType){case 1:case 11:o(E,s)}return E}},B(W,C)}})()}})(document,customElements,Object)});function A1(){if(typeof navigator>"u")return!1;let Q=navigator.userAgent||"",$=/\b(iPad|iPhone|iPod)\b/.test(Q)||/\bMacintosh\b/.test(Q)&&/\bMobile\b/.test(Q),J=/\bAppleWebKit\b/.test(Q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(Q);return $||J}function h(Q,$={}){let J=document.createElement("fig-icon");if(Q)J.setAttribute("name",Q);if($.size)J.setAttribute("size",$.size);if($.className)J.className=$.className;return J}function v(Q,$){requestAnimationFrame(()=>{if(Q&&!Q.isConnected)return;$()})}function O0({owner:Q,onStart:$,onEnd:J,startClass:Z="",endClass:j="",chevronClass:q=""}={}){let _=(X,Y)=>{let K=document.createElement("button");if(K.className=["fig-overflow",`fig-overflow-${X}`,X==="start"?Z:j].filter(Boolean).join(" "),K.dataset.figOverflow=X,Q)K.setAttribute(`data-fig-${Q}-nav`,X);return K.setAttribute("tabindex","-1"),K.setAttribute("aria-label",X==="start"?"Scroll back":"Scroll forward"),K.appendChild(h("chevron",{size:"small",className:["fig-overflow-chevron",q].filter(Boolean).join(" ")})),K.addEventListener("pointerdown",(N)=>{N.preventDefault(),N.stopPropagation(),Y?.(N)}),K};return{start:_("start",$),end:_("end",J)}}function R0(Q,$,J="x",Z=2){if(!Q||!$)return!1;let j=J==="x",q=j?$.scrollWidth:$.scrollHeight,_=j?$.clientWidth:$.clientHeight,X=j?$.scrollLeft:$.scrollTop,Y=q-_>Z,K=!Y||X<=Z,N=!Y||X+_>=q-Z;return Q.classList.toggle("overflow-start",!K),Q.classList.toggle("overflow-end",!N),Y}function J0(Q,$="x",J=1){if(!Q)return;let Z=$==="x",q=(Z?Q.clientWidth:Q.clientHeight)*0.8*J;Q.scrollBy({[Z?"left":"top"]:q,behavior:"smooth"})}function p(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function z1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let Q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class $ extends HTMLButtonElement{}try{return customElements.define(Q,$,{extends:"button"}),document.createElement("button",{is:Q})instanceof $}catch(J){return!1}}var A0=A1()&&!z1(),D1=(A0?Promise.resolve().then(() => (U0(),R1)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q});function Z0(Q,$,J){let Z=()=>{if(!customElements.get(Q))customElements.define(Q,$,J)};if(!A0){Z();return}D1.then(Z).catch((j)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${Q}".`,j)})}function y(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}var H1=1e4;function F1(){return H1++}function V(Q,$,J){if(J&&J.trim())Q.style.setProperty($,J.trim());else Q.style.removeProperty($)}var m=null,L0=null;function j0(Q=1,$=1){if(!m)m=document.createElement("canvas"),L0=m.getContext("2d");if(m.width!==Q)m.width=Q;if(m.height!==$)m.height=$;return{canvas:m,ctx:L0}}class z0 extends HTMLElement{type;#$;#Q=["aria-label","aria-labelledby","aria-describedby","title"];#j=this.#N.bind(this);#J=this.#X.bind(this);#Z=()=>{if(this.button?.matches(":focus-visible"))this.setAttribute("data-focus-visible","")};#q=()=>{this.removeAttribute("data-focus-visible")};constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){if(this.type=this.getAttribute("type")||"button",!this.button){let Q=this.type==="select"||this.type==="upload",$=Q?"span":"button",J=Q?"":` type="${this.type}"`;this.shadowRoot.innerHTML=`
2
2
  <style>
3
3
  button, button:hover, button:active, .fig-button-control {
4
4
  padding: 0 var(--spacer-2);
@@ -34,9 +34,9 @@ var B1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var O1={};var G0=B1(()=>{/*! Vendored from @
34
34
  <${$} class="fig-button-control"${J}>
35
35
  <slot></slot>
36
36
  </${$}>
37
- `,this.#$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.#W(),this.button.addEventListener("click",this.#Z.bind(this)),this.button.addEventListener("focus",()=>{if(this.button.matches(":focus-visible"))this.setAttribute("data-focus-visible","")}),this.button.addEventListener("blur",()=>{this.removeAttribute("data-focus-visible")}),this.addEventListener("keydown",this.#j)}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q)}#J(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#Z(){if(this.#J())return;if(this.type==="toggle")this.toggleAttribute("selected",!this.hasAttribute("selected"));if(this.type==="submit"){let Q=this.closest("form");if(Q)Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),$=this.getAttribute("target");if(Q)if($)window.open(Q,$);else window.location.href=Q}}#q(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#_(){let Q=this.#q();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 $=this.#_();if(!$||$.disabled||$.multiple)return;if(typeof $.showPicker!=="function")return;Q.preventDefault();try{$.showPicker()}catch{}}#K(){if(!this.button)return;if(this.type!=="toggle"){this.removeAttribute("aria-pressed"),this.button.removeAttribute("aria-pressed");return}let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.setAttribute("aria-pressed",Q?"true":"false"),this.button.setAttribute("aria-pressed",Q?"true":"false")}#Y(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#Q.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.button.removeAttribute(Q);else this.button.setAttribute(Q,$)})}#W(){if(!this.button)return;let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=Q,this.button instanceof HTMLButtonElement)this.button.disabled=Q,this.button.type=this.type,this.button.setAttribute("type",this.type);this.#Y(),this.#K()}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"disabled":case"type":this.#W();break;case"selected":this.#$=J!==null&&J!=="false",this.#K();break;default:this.#Y();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#j)}}customElements.define("fig-button",A0);class z0 extends HTMLElement{#$="Menu";#Q=null;#j;#J;#Z;#q=!1;#_=null;get label(){return this.#$}set label(Q){this.#$=Q}#X;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#j=this.#B.bind(this),this.#J=this.#M.bind(this),this.#Z=this.#G.bind(this),this.#X=this.slotChange.bind(this)}#K(){if(typeof CSS>"u"||typeof CSS.supports!=="function")return!1;try{return CSS.supports("appearance: base-select")&&CSS.supports("selector(::picker(select))")}catch{return!1}}#Y(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#K()){this.#q=!1;return}let J=document.createElement("button");J.setAttribute("type","button"),J.setAttribute("aria-hidden","true");let Z=document.createElement("selectedcontent");J.appendChild(Z),this.select.appendChild(J),this.#q=!0,this.#_=Z}#W(){if(!this.#_)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#_.textContent="";return}this.#_.innerHTML=Q.innerHTML}#N(){this.select.addEventListener("input",this.#j),this.select.addEventListener("change",this.#J),this.select.addEventListener("keydown",this.#Z)}#L(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#U(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){this.type=this.getAttribute("type")||"select",this.#$=this.getAttribute("label")||this.#$,this.select.setAttribute("aria-label",this.#$),this.#A(),this.appendChild(this.select),this.shadowRoot.appendChild(this.optionsSlot),this.optionsSlot.addEventListener("slotchange",this.#X),this.#N()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.#Y(),this.type==="dropdown"){let Q=document.createElement("option");Q.setAttribute("hidden","true"),Q.setAttribute("selected","true"),Q.selected=!0,this.select.appendChild(Q)}if(this.optionsSlot.assignedNodes().forEach((Q)=>{if(Q.nodeName==="OPTION"||Q.nodeName==="OPTGROUP")this.select.appendChild(Q.cloneNode(!0))}),this.#D(this.value),this.#W(),this.type==="dropdown")this.select.selectedIndex=-1}#B(Q){let $=Q.target.selectedOptions?.[0];if(this.#L($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#U();return}let J=Q.target.value;if(this.type==="dropdown")this.#Q=J;this.setAttribute("value",J),this.#W(),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}#M(Q){let $=Q.target.selectedOptions?.[0];if(this.#L($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#U();return}let J=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#W(),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}#G(Q){if(this.closest('fig-button[type="select"]'))return;if(Q.key!=="Enter"||Q.defaultPrevented)return;if(this.#q&&this.select.matches(":open"))return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(typeof this.select.showPicker!=="function")return;Q.preventDefault();try{this.select.showPicker()}catch{}}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#Q;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#Q=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","experimental","label","disabled"]}#A(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=Q}#D(Q){if(this.type==="dropdown")return;if(this.select)this.select.querySelectorAll("option").forEach(($,J)=>{if($.value===this.getAttribute("value"))this.select.selectedIndex=J});this.#W()}attributeChangedCallback(Q,$,J){if(Q==="value")this.#D(J);if(Q==="type")this.type=J;if(Q==="experimental")this.slotChange();if(Q==="label")this.#$=J,this.select.setAttribute("aria-label",this.#$);if(Q==="disabled")this.#A()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#X),this.select.removeEventListener("input",this.#j),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#Z)}}customElements.define("fig-dropdown",z0);class S extends HTMLElement{static#$=0;static#Q=500;#j;#J;#Z;#q;#_;#X;#K;#Y;#W;#N;#L=null;#U;#B=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#j=this.#z.bind(this),this.#J=this.hidePopupOutsideClick.bind(this),this.#Z=this.showDelayedPopup.bind(this),this.#q=this.#G.bind(this),this.#_=this.#A.bind(this),this.#X=this.#D.bind(this),this.#K=this.#O.bind(this),this.#Y=this.#H.bind(this),this.#N=this.#R.bind(this),this.#W=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(this.setup(),this.setupEventListeners(),this.#L=this.closest("dialog"),this.#L)this.#L.addEventListener("close",this.#W)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),document.removeEventListener("mousedown",this.#j,!0),document.removeEventListener("keydown",this.#N,!0),this.#L)this.#L.removeEventListener("close",this.#W),this.#L=null;if(this.action==="click")document.body.removeEventListener("click",this.#J);if(clearTimeout(this.#U),this.action==="hover")this.removeEventListener("pointerenter",this.#Z),this.removeEventListener("pointerleave",this.#q),this.removeEventListener("touchstart",this.#_),this.removeEventListener("touchmove",this.#X),this.removeEventListener("touchend",this.#K),this.removeEventListener("touchcancel",this.#Y);else if(this.action==="click")this.removeEventListener("click",this.#Z),this.removeEventListener("touchstart",this.#Z)}setup(){this.style.display="contents"}render(){this.destroy();let Q=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,$=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 J=y();this.popup.setAttribute("id",J);let Z=this.getAttribute("theme");if(Z)this.popup.setAttribute("theme",Z);let j=this.getAttribute("pointer");if(j!==null)this.popup.setAttribute("pointer",j);if(this.popup.append($),$.innerText=this.getAttribute("text")??"",this.firstElementChild)this.firstElementChild.setAttribute("aria-describedby",J);if(Q)document.body.append(this.popup);else{let q=this.closest("dialog");if(q&&q.open)q.append(this.popup);else document.body.append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.popup.remove(),this.popup=null;if(this.action==="click")document.body.removeEventListener("click",this.#J)}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="manual")return;if(this.action==="hover"){if(!this.isTouchDevice())this.addEventListener("pointerenter",this.#Z),this.addEventListener("pointerleave",this.#q);this.addEventListener("touchstart",this.#_,{passive:!0}),this.addEventListener("touchmove",this.#X,{passive:!0}),this.addEventListener("touchend",this.#K,{passive:!0}),this.addEventListener("touchcancel",this.#Y,{passive:!0})}else if(this.action==="click")this.addEventListener("click",this.#Z),document.body.addEventListener("click",this.#J),this.addEventListener("touchstart",this.#Z,{passive:!0});document.addEventListener("mousedown",this.#j,!0),document.addEventListener("keydown",this.#N,!0)}get#M(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}showDelayedPopup(){if(this.#M)return;this.render(),clearTimeout(this.timeout);let $=Date.now()-S.#$<S.#Q?0:this.delay;this.timeout=setTimeout(this.showPopup.bind(this),$)}showPopup(){if(this.#L&&!this.#L.open)return;if(!this.firstElementChild)return;if(!this.popup)this.render();this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,S.#$=Date.now()}hidePopup(){if(this.#M)return;if(clearTimeout(this.timeout),clearTimeout(this.#U),this.popup)this.destroy();this.isOpen=!1,S.#$=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#G(Q){if(!this.#B)this.hidePopup()}#A(Q){if(this.action==="hover")this.#B=!0,clearTimeout(this.#U),this.showDelayedPopup()}#D(Q){if(this.action==="hover"&&this.#B)clearTimeout(this.#U),this.#U=setTimeout(()=>{this.#B=!1,this.hidePopup()},150)}#O(Q){if(this.action==="hover"&&this.#B)clearTimeout(this.#U),this.#U=setTimeout(()=>{this.#B=!1,this.hidePopup()},300)}#H(Q){if(this.action==="hover"&&this.#B)this.#B=!1,clearTimeout(this.#U),this.hidePopup()}#R(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)}#F(Q){if(!this.popup)return;let $=this.popup.firstElementChild??this.popup.firstChild;if(!$)return;$.innerText=Q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")==="true"}set open(Q){this.setAttribute("open",Q)}attributeChangedCallback(Q,$,J){if(Q==="action")this.action=J;if(Q==="delay"){let Z=parseInt(J);this.delay=!isNaN(Z)?Z:500}if(Q==="open")if(J==="true")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(Q==="show")if(J!==null&&J!=="false")this.showPopup();else this.hidePopup();if(Q==="text")this.#F(J??"");if(Q==="pointer"){if(this.popup)if(J!==null)this.popup.setAttribute("pointer",J);else this.popup.removeAttribute("pointer")}if(Q==="theme"){if(this.popup)if(J)this.popup.setAttribute("theme",J);else this.popup.removeAttribute("theme")}}#z(Q){if(!this.isOpen)return;let $=Q.target;if(this.popup&&this.popup.contains($))return;if($.tagName==="SELECT"||$.hasAttribute("popover")||$.closest("dialog"))this.hidePopup()}static#C=new WeakMap;static show(Q,$,J={}){S.hide(Q);let Z=J.delay??500,q=Date.now()-S.#$<S.#Q?0:Z,_={timeout:null,popup:null};S.#C.set(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=$,Y.append(K),X)document.body.append(Y);else{let N=Q.closest?.("dialog");if(N&&N.open)N.append(Y);else document.body.append(Y)}Y.anchor=Q,Y.open=!0,_.popup=Y,S.#$=Date.now()},q)}static hide(Q){let $=S.#C.get(Q);if(!$)return;if(clearTimeout($.timeout),$.popup)$.popup.remove();S.#C.delete(Q)}}customElements.define("fig-tooltip",S);class D0 extends HTMLElement{static observedAttributes=["position","tail"];#$=null;#Q=null;#j=null;connectedCallback(){this.#$=this.textContent,requestAnimationFrame(()=>{this.#J(),this.#Z()})}disconnectedCallback(){this.#q()}attributeChangedCallback(Q,$,J){if($===J)return;if(this.#$===null)return;this.#J()}#J(){let Q=this.getAttribute("position")||"right",$=this.#$||"";if(Q==="middle"){let J=this.getAttribute("tail"),Z;if(J){let _=$.lastIndexOf(J);Z=_>0?_:Math.ceil($.length/2)}else Z=Math.ceil($.length/2);this.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=$.slice(0,Z);let q=document.createElement("span");q.className="end",q.textContent=$.slice(Z),this.appendChild(j),this.appendChild(q)}else this.textContent=$}#Z(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;S.show(this,this.#$)},this.#j=()=>{S.hide(this)},this.addEventListener("pointerenter",this.#Q),this.addEventListener("pointerleave",this.#j)}#q(){if(this.#Q)this.removeEventListener("pointerenter",this.#Q);if(this.#j)this.removeEventListener("pointerleave",this.#j);S.hide(this)}}customElements.define("fig-truncate",D0);class H0 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._previousFocus=null}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),requestAnimationFrame(()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),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.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 $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Q.focus?.())}show(){return this._captureFocusBeforeOpen(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),super.show()}showModal(){return this._captureFocusBeforeOpen(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),super.showModal()}_handleIframeMessage(Q){if(!this.autoresize)return;let $=Q?.data;if(!$||$.type!=="figui:iframe-resize")return;let J=Q.source;if(!J)return;let Z=Array.from(this.querySelectorAll("iframe")).find((j)=>j.contentWindow===J);if(!Z)return;this._resizeForIframe(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 $ of Q)$.addedNodes?.forEach((J)=>{if(J instanceof Element&&J.parentElement===this)try{this._resizeObserver?.observe(J)}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 $=window.getComputedStyle(this),J=parseFloat($.paddingTop||"0")+parseFloat($.paddingBottom||"0")+parseFloat($.borderTopWidth||"0")+parseFloat($.borderBottomWidth||"0"),Z=0,j=parseFloat($.rowGap||$.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");Z+=X.height+K}if(j&&q>1)Z+=j*(q-1);return J+Z}_resizeForIframe(Q,$){if(typeof $.height!=="number"||!($.height>0))return;let J=this._computeChrome(Q);this.style.height=`${Math.ceil($.height+J)}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 $=document.createElement("h3");$.textContent=this.getAttribute("title")||"Dialog";let J=document.createElement("fig-tooltip");J.setAttribute("text","Close");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("icon",""),Z.setAttribute("aria-label","Close dialog"),Z.setAttribute("close-dialog",""),Z.appendChild(v("close")),J.appendChild(Z),Q.appendChild($),Q.appendChild(J),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.getAttribute("id")||y();Q.setAttribute("id",$),this.setAttribute("aria-labelledby",$)}}}_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.includes("top"),J=Q.includes("bottom"),Z=Q.includes("left"),j=Q.includes("right"),q=Q.includes("center")&&!$&&!J,_=Q.includes("center")&&!Z&&!j;if($)this.style.top=`${this._offset}px`;else if(J)this.style.bottom=`${this._offset}px`;else if(q)this.style.top="0",this.style.bottom="0";if(Z)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"),$=Q?this.querySelector(Q):this.querySelector("fig-header, header");if($)$.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}_isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(q)=>$.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}_handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(Q,$,J){if(this._figInit(),Q==="autoresize"&&this.isConnected)this._syncAutoResize();if(Q==="drag")if(this.drag=J!==null&&J!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let Z=this.querySelector("fig-header, header");if(Z)Z.style.cursor=""}if(Q==="position"&&this._positionInitialized)this._applyPosition();if(Q==="modal"){let Z=this.modal;if(this.modal=J!==null&&J!=="false",this.open&&Z!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(Q==="closedby")this.closedby=J||"any";if(Q==="title"){let Z=this.querySelector("fig-header[data-auto] h3");if(Z)Z.textContent=J||"Dialog";this._syncA11y()}if(Q==="aria-label"||Q==="aria-labelledby")this._syncA11y()}}J0("fig-dialog",H0,{extends:"dialog"});class F0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._boundHandleClose=this.handleClose.bind(this)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast()}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close notification");Q.removeEventListener("click",this._boundHandleClose),Q.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto",this.style.bottom=`${parseInt(this.getAttribute("offset")??this._defaultOffset)}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let Q=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger";if(!this.hasAttribute("role"))this.setAttribute("role",Q?"alert":"status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live",Q?"assertive":"polite");if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}startAutoClose(){this.clearAutoClose();let Q=parseInt(this.getAttribute("duration")??"5000");if(Q>0)this._autoCloseTimer=setTimeout(()=>this.hideToast(),Q)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}showToast(){if(this.syncLiveRegion(),!this.open)this.show();this.applyPosition(),this.startAutoClose(),this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){if(this.clearAutoClose(),this.open)this.close();this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live"]}attributeChangedCallback(Q,$,J){if(this._figInit(),$===J)return;if(!this.isConnected)return;if(Q==="offset")this.applyPosition();if(Q==="open")if(J!==null&&J!=="false")this.showToast();else this.hideToast();if(Q==="theme"||Q==="live")this.syncLiveRegion()}}J0("fig-toast",F0,{extends:"dialog"});class T0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;_previousFocus=null;_boundDocumentKeydown;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{let $=Q.target;if(this.open&&(!($ instanceof Node)||!this.contains($))&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this),this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this)}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._previousFocus>"u")this._previousFocus=null;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{let $=Q.target;if(this.open&&(!($ instanceof Node)||!this.contains($))&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this);if(typeof this._boundDocumentKeydown!=="function")this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!this.open)return;this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else if(Q&&typeof Q.getBoundingClientRect==="function")this._anchorRef=Q;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role",this.getAttribute("variant")==="tooltip"?"tooltip":"dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this.addEventListener("close",()=>{if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}),requestAnimationFrame(()=>{this.setupDragListeners()}),this.open)this.showPopup();else this.hidePopup()}disconnectedCallback(){if(this.ensureInitialized(),this.teardownObservers(),this.removeDragListeners(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(Q,$,J){if(this.ensureInitialized(),$===J)return;if(Q==="open"){if(J===null||J==="false"){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=J!==null&&J!=="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(H1()+1),this.captureFocusBeforeOpen();let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),$=this.shouldAutoReposition();if($)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(Z){}if(!Q&&!super.open)try{this.show()}catch(Z){}if($&&(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 J=this.resolveAnchor();if(J?.classList)J.classList.add("has-popup-open")}hidePopup(){let Q=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),$=this.resolveAnchor();if($?.classList)$.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(J){}if(this.matches?.(":open"))try{this.close()}catch(J){}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(),$=this._previousFocus?.isConnected?this._previousFocus:Q instanceof HTMLElement?Q:null;if(this._previousFocus=null,!$?.isConnected)return;let J=document.activeElement;if(J&&J!==document.body&&!this.contains(J))return;requestAnimationFrame(()=>$.focus?.())}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.removeAttribute("autoresize")}setupObservers(){this.teardownObservers();let Q=this.resolveAnchor();if(Q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(Q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(Q){if(!Q)return null;let $=Q.getBoundingClientRect();return{x:$.x,y:$.y,width:$.width,height:$.height}}hasRectChanged(Q,$,J=0.25){if(!Q&&!$)return!1;if(!Q||!$)return!0;return Math.abs(Q.x-$.x)>J||Math.abs(Q.y-$.y)>J||Math.abs(Q.width-$.width)>J||Math.abs(Q.height-$.height)>J}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let $=this.resolveAnchor(),J=this.readRectSnapshot($),Z=this.shouldAutoReposition();if(Z&&this.hasRectChanged(this._lastAnchorRect,J))this._lastAnchorRect=J,this.queueReposition();else if(!Z)this._lastAnchorRect=J;this._anchorTrackRAF=requestAnimationFrame(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!super.open)return;let $=this.getAttribute("closedby");if($==="none"||$==="closerequest")return;let J=Q.target;if(!(J instanceof Node))return;if(this.contains(J))return;let Z=this.resolveAnchor();if(Z?.contains&&Z.contains(J))return;if(this.isInsideDescendantPopup(J))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 Z=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(Z&&Z!==this)return;Q.preventDefault(),this.open=!1}isInsideDescendantPopup(Q){let $=Q.closest?.('dialog[is="fig-popup"]');if(!$||$===this)return!1;let J=$,Z=new Set;while(J&&!Z.has(J)){Z.add(J);let j=J.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;J=j.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["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"],Z=(q)=>$.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let $=this.parentElement;if($?.querySelector){let J=$.querySelector(Q);if(J&&!this.contains(J))return J}return document.querySelector(Q)}parsePosition(){let $=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),J=new Set(["top","center","bottom"]),Z=new Set(["left","center","right"]),j="top",q="center",_=null;if($.length>=2){if(J.has($[0]))j=$[0];if(Z.has($[1]))q=$[1];return{vertical:j,horizontal:q,shorthand:_}}if($.length===1){let X=$[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,$="0px"){if(!Q)return $;let J=Q.trim();if(!J)return $;if(/^-?\d+(\.\d+)?$/.test(J))return`${J}px`;return J}measureLengthPx(Q,$="x"){if(!Q)return 0;let J=this.normalizeOffsetToken(Q,"0px");if(J.endsWith("px")){let q=parseFloat(J);return Number.isFinite(q)?q:0}let Z=document.createElement("div");if(Z.style.position="fixed",Z.style.visibility="hidden",Z.style.pointerEvents="none",Z.style.left="0",Z.style.top="0",Z.style.margin="0",Z.style.padding="0",Z.style.border="0",$==="x")Z.style.width=J,Z.style.height="0";else Z.style.height=J,Z.style.width="0";document.body.appendChild(Z);let j=Z.getBoundingClientRect();return Z.remove(),$==="x"?j.width:j.height}parseOffset(){let $=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),J=this.normalizeOffsetToken($[0],"0px"),Z=this.normalizeOffsetToken($[1],"0px");return{xToken:J,yToken:Z,xPx:this.measureLengthPx(J,"x"),yPx:this.measureLengthPx(Z,"y")}}parseViewportMargins(){let $=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((Z)=>!Number.isNaN(Z)),J=8;if($.length===0)return{top:8,right:8,bottom:8,left:8};if($.length===1)return{top:$[0],right:$[0],bottom:$[0],left:$[0]};if($.length===2)return{top:$[0],right:$[1],bottom:$[0],left:$[1]};if($.length===3)return{top:$[0],right:$[1],bottom:$[2],left:$[1]};return{top:$[0],right:$[1],bottom:$[2],left:$[3]}}getPlacementCandidates(Q,$,J){let Z={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if(J){let q=J==="left"||J==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:$,s:J},{v:Q,h:$,s:Z[J]},{v:Q,h:$,s:q[0]},{v:Q,h:$,s:q[1]}]}if(Q==="center")return[{v:"center",h:$,s:null},{v:"center",h:Z[$],s:null},{v:"top",h:$,s:null},{v:"bottom",h:$,s:null},{v:"top",h:Z[$],s:null},{v:"bottom",h:Z[$],s:null}];if($==="center")return[{v:Q,h:"center",s:null},{v:Z[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:Z[Q],h:"left",s:null},{v:Z[Q],h:"right",s:null}];return[{v:Q,h:$,s:null},{v:Z[Q],h:$,s:null},{v:Q,h:Z[$],s:null},{v:Z[Q],h:Z[$],s:null}]}computeCoords(Q,$,J,Z,j,q){let _,X;if(q==="left"||q==="right")return X=q==="left"?Q.left-$.width-j.xPx:Q.right+j.xPx,_=Q.top,{top:_,left:X};if(q==="top"||q==="bottom")return _=q==="top"?Q.top-$.height-j.yPx:Q.bottom+j.yPx,X=Q.left,{top:_,left:X};if(J==="top")_=Q.top-$.height-j.yPx;else if(J==="bottom")_=Q.bottom+j.yPx;else _=Q.top+(Q.height-$.height)/2;if(J==="center")if(Z==="left")X=Q.left-$.width-j.xPx;else if(Z==="right")X=Q.right+j.xPx;else X=Q.left+(Q.width-$.width)/2;else if(Z==="left")X=Q.left+j.xPx;else if(Z==="right")X=Q.right-$.width-j.xPx;else X=Q.left+(Q.width-$.width)/2;return{top:_,left:X}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,$,J){if(J==="top")return"top";if(J==="bottom")return"bottom";if(J==="left")return"left";if(J==="right")return"right";if(Q!=="center")return Q;if($!=="center")return $;return"top"}updatePopoverBeak(Q,$,J,Z,j){let q=this.getAttribute("variant");if(!(q==="popover"||q==="tooltip")||!Q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let X=this.oppositeSide(j);this.setAttribute("data-beak-side",X);let Y=Q.left+Q.width/2,K=Q.top+Q.height/2,N=this.getBoundingClientRect(),L=N.width>0&&N.height>0?N:$,O=L.left,H=L.top,B=getComputedStyle(this),U=(D,T=0)=>{let P=String(D||"").trim(),E=parseFloat(P);if(!Number.isFinite(E))return T;if(P.endsWith("rem"))return E*parseFloat(getComputedStyle(document.documentElement).fontSize);if(P.endsWith("em"))return E*parseFloat(B.fontSize);return E},z=(D)=>{if(D==="top")return Math.max(U(B.borderTopLeftRadius),U(B.borderTopRightRadius));if(D==="bottom")return Math.max(U(B.borderBottomLeftRadius),U(B.borderBottomRightRadius));if(D==="left")return Math.max(U(B.borderTopLeftRadius),U(B.borderBottomLeftRadius));if(D==="right")return Math.max(U(B.borderTopRightRadius),U(B.borderBottomRightRadius));return 0},A=U(B.getPropertyValue("--fig-popup-beak-width"),16),G=Math.max(10,z(X)+A/2),M;if(X==="top"||X==="bottom"){M=Y-O;let D=G,T=Math.max(D,L.width-G);M=Math.min(T,Math.max(D,M))}else{M=K-H;let D=G,T=Math.max(D,L.height-G);M=Math.min(T,Math.max(D,M))}this.style.setProperty("--fig-popup-beak-offset",`${M}px`)}overflowScore(Q,$,J){let{innerWidth:Z,innerHeight:j}=window,q=Q.left+$.width,_=Q.top+$.height,X=Math.max(0,J.left-Q.left),Y=Math.max(0,J.top-Q.top),K=Math.max(0,q-(Z-J.right)),N=Math.max(0,_-(j-J.bottom));return X+Y+K+N}fits(Q,$,J){return this.overflowScore(Q,$,J)===0}clamp(Q,$,J){let{left:Z,top:j}=J,q=Math.max(J.left,window.innerWidth-$.width-J.right),_=Math.max(J.top,window.innerHeight-$.height-J.bottom);return{left:Math.min(q,Math.max(Z,Q.left)),top:Math.min(_,Math.max(j,Q.top))}}positionPopup(){if(!this.open||!this.matches?.(":open"))return;let Q=this.getBoundingClientRect(),$=this.parseOffset(),{vertical:J,horizontal:Z,shorthand:j}=this.parsePosition(),q=this.resolveAnchor(),_=this.parseViewportMargins();if(!q){this.updatePopoverBeak(null,Q,0,0,"top");let H={left:_.left+(window.innerWidth-_.right-_.left-Q.width)/2,top:_.top+(window.innerHeight-_.bottom-_.top-Q.height)/2},B=this.clamp(H,Q,_);this.style.left=`${B.left}px`,this.style.top=`${B.top}px`;return}let X=q.getBoundingClientRect(),Y=this.getPlacementCandidates(J,Z,j),K=null,N="top",L=Number.POSITIVE_INFINITY;for(let{v:H,h:B,s:U}of Y){let z=this.computeCoords(X,Q,H,B,$,U),A=this.getPlacementSide(H,B,U);if(U){let G=this.clamp(z,Q,_);if(U==="left"||U==="right"?z.left>=_.left&&z.left+Q.width<=window.innerWidth-_.right:z.top>=_.top&&z.top+Q.height<=window.innerHeight-_.bottom){this.style.left=`${G.left}px`,this.style.top=`${G.top}px`,this.updatePopoverBeak(X,Q,G.left,G.top,A);return}let D=this.overflowScore(z,Q,_);if(D<L)L=D,K=G,N=A}else{if(this.fits(z,Q,_)){this.style.left=`${z.left}px`,this.style.top=`${z.top}px`,this.updatePopoverBeak(X,Q,z.left,z.top,A);return}let G=this.overflowScore(z,Q,_);if(G<L)L=G,K=z,N=A}}let O=this.clamp(K||{left:0,top:0},Q,_);this.style.left=`${O.left}px`,this.style.top=`${O.top}px`,this.updatePopoverBeak(X,Q,O.left,O.top,N)}queueReposition(){if(!this.open||!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()}}J0("fig-popup",T0,{extends:"dialog"});class P0 extends HTMLElement{#$;#Q;constructor(){super();this.content=null,this.#$=!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),requestAnimationFrame(()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let Q=this.getAttribute("id")||y(),$=this.content.getAttribute("id")||y();if(this.setAttribute("id",Q),this.content.setAttribute("id",$),this.setAttribute("aria-controls",$),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",Q),this.#$)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.#$}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(this.hasAttribute("disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(Q,$,J){if(Q==="selected"){if(this.#$=J!==null&&J!=="false",this.setAttribute("aria-selected",this.#$?"true":"false"),this.setAttribute("tabindex",this.#$?"0":"-1"),this?.content)this.content.style.display=this.#$?"block":"none"}if(Q==="disabled")if(J!==null&&J!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#$?"0":"-1")}}customElements.define("fig-tab",P0);class k0 extends HTMLElement{#$;#Q;#j=this.#M.bind(this);#J=null;#Z=null;#q=null;#_=null;#X=null;#K=!1;constructor(){super();this.#$=this.handleClick.bind(this),this.#Q=this.#H.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.#B(),this.addEventListener("click",this.#$),this.addEventListener("keydown",this.#Q),this.#Y.addEventListener("scroll",this.#j),this.#O(),this.#A(),this.#G(),requestAnimationFrame(()=>{let Q=this.getAttribute("value");if(Q)this.#R(Q);if(this.hasAttribute("disabled"))this.#W(!0);this.#L(),this.#M(),this.#U(void 0,"auto")})}get#Y(){return this.#q||this}get scrollLeft(){return this.#Y.scrollLeft}set scrollLeft(Q){this.#Y.scrollLeft=Q}get scrollWidth(){return this.#Y.scrollWidth}scrollTo(...Q){this.#Y.scrollTo(...Q)}scrollBy(...Q){this.#Y.scrollBy(...Q)}#W(Q){this.querySelectorAll("fig-tab").forEach((J)=>{if(Q)J.setAttribute("disabled",""),J.setAttribute("aria-disabled","true"),J.setAttribute("tabindex","-1");else J.removeAttribute("disabled"),J.removeAttribute("aria-disabled")}),this.#L()}#N(){return Array.from(this.querySelectorAll("fig-tab")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#L(){let Q=Array.from(this.querySelectorAll("fig-tab")),$=Q.find((J)=>J.hasAttribute("selected"))||this.#N()[0];Q.forEach((J)=>{let Z=J.hasAttribute("disabled")&&J.getAttribute("disabled")!=="false";J.setAttribute("tabindex",!Z&&J===$?"0":"-1")})}#U(Q=this.selectedTab,$="smooth"){let J=Q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#N()[0];if(!J)return;requestAnimationFrame(()=>{if(!this.isConnected||!J.isConnected)return;let Z=this.#Y;if(!(Z.scrollWidth>Z.clientWidth))return;let q=Z.getBoundingClientRect(),_=J.getBoundingClientRect(),X=_.left-q.left+Z.scrollLeft+_.width/2;Z.scrollTo({left:X-Z.clientWidth/2,behavior:$}),this.#M()})}disconnectedCallback(){this.removeEventListener("click",this.#$),this.removeEventListener("keydown",this.#Q),this.#Y.removeEventListener("scroll",this.#j),this.#J?.disconnect(),this.#J=null,this.#Z?.disconnect(),this.#Z=null,this.#D()}#B(){if(this.#K)return;let Q=this.querySelector(":scope > [data-fig-tabs-scroll]"),$=Q?Array.from(this.childNodes).filter((J)=>{if(J===Q)return!1;if(J.nodeType!==Node.ELEMENT_NODE)return!0;return!J.hasAttribute("data-fig-tabs-nav")}):null;if(Q&&Q===this.#q&&!$?.length)return;this.#K=!0;try{let J=this.#q;if(J&&J!==Q)J.removeEventListener("scroll",this.#j);let Z=Q||document.createElement("div");Z.className="fig-tabs-scroll",Z.dataset.figTabsScroll="";let j=$??Array.from(this.childNodes).filter((q)=>{if(q===Z)return!1;if(q.nodeType!==Node.ELEMENT_NODE)return!0;return!q.hasAttribute("data-fig-tabs-nav")});for(let q of j)Z.appendChild(q);if(!Q)this.prepend(Z);if(this.#q=Z,this.#q.removeEventListener("scroll",this.#j),this.#q.addEventListener("scroll",this.#j),this.#Z)this.#Z.observe(this.#q)}finally{this.#K=!1}}#M(){O0(this,this.#Y,"x")}#G(){if(this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>this.#M()),this.#Z.observe(this),this.#q)this.#Z.observe(this.#q)}#A(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>{if(this.#K)return;this.#B(),this.#O(),this.#L(),requestAnimationFrame(()=>{this.#M(),this.#U()})}),this.#J.observe(this,{childList:!0,subtree:!0})}#D(){this.#_?.remove(),this.#X?.remove(),this.#_=null,this.#X=null,this.classList.remove("overflow-start","overflow-end")}#O(){if(this.#_&&this.#X&&this.contains(this.#_)&&this.contains(this.#X))return;this.#_?.remove(),this.#X?.remove();let Q=B0({owner:"tabs",onStart:()=>$0(this.#Y,"x",-1),onEnd:()=>$0(this.#Y,"x",1)});this.#_=Q.start,this.#X=Q.end,this.prepend(this.#_),this.append(this.#X)}#H(Q){let $=this.#N();if(!$.length)return;let J=$.findIndex((j)=>j.hasAttribute("selected")),Z=J>=0?J:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),Z=J>0?J-1:$.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),Z=J<$.length-1?J+1:0;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;default:return}if(Z!==J&&$[Z]){this.querySelectorAll("fig-tab").forEach((q)=>q.removeAttribute("selected")),this.selectedTab=$[Z],$[Z].setAttribute("selected","true");let j=$[Z].getAttribute("value");if(j)this.setAttribute("value",j);$[Z].focus(),this.#L(),this.#U($[Z])}}get value(){return this.selectedTab?.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q)}#R(Q){let $=this.querySelectorAll("fig-tab");for(let J of $)if(J.getAttribute("value")===Q)this.selectedTab=J,J.setAttribute("selected","true");else J.removeAttribute("selected");this.#L(),this.#U(this.selectedTab)}attributeChangedCallback(Q,$,J){switch(Q){case"value":if(J!==$)this.#R(J);break;case"disabled":this.#W(J!==null&&J!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled"))return;let $=Q.target.closest("fig-tab");if(!$||!this.contains($))return;let J=this.querySelectorAll("fig-tab");for(let j of J)if(j===$)this.selectedTab=j,j.setAttribute("selected","true");else j.removeAttribute("selected");let Z=$.getAttribute("value");if(Z)this.setAttribute("value",Z);this.#L(),this.#U($)}}customElements.define("fig-tabs",k0);class E0 extends HTMLElement{#$;#Q;#j;constructor(){super();this.#j=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#J(),this.addEventListener("click",this.#j)}disconnectedCallback(){this.removeEventListener("click",this.#j)}handleClick(){let Q=this.closest("fig-segmented-control");if(Q&&Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#$}set value(Q){this.#$=Q,this.setAttribute("value",Q)}get selected(){return this.#Q}set selected(Q){this.#Q=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value","disabled"]}#J(){let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",Q?"true":"false"),$)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",Q?"0":"-1")}attributeChangedCallback(Q,$,J){switch(Q){case"value":this.#$=J;break;case"selected":this.#Q=J,this.#J();break;case"disabled":this.#J();break}}}customElements.define("fig-segment",E0);class C0 extends HTMLElement{#$=null;#Q=this.handleClick.bind(this);#j=this.#B.bind(this);#J=null;#Z=null;#q=0;#_=!1;#X=!1;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){if(this.name=this.getAttribute("name")||"segmented-control",!this.hasAttribute("role"))this.setAttribute("role","radiogroup");this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#j),this.#z(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#F(),this.#O(),requestAnimationFrame(()=>{this.#R({enforceFallback:!0}),this.#H(),this.#A({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#j),this.#J?.disconnect(),this.#J=null,this.#Z?.disconnect(),this.#Z=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#_=!1,this.#X=!1}get selectedSegment(){return this.#$}set selectedSegment(Q){let $=this.querySelectorAll("fig-segment");for(let J of $){let Z=J===Q,j=J.hasAttribute("selected");if(Z&&!j)J.setAttribute("selected","true");else if(!Z&&j)J.removeAttribute("selected")}this.#$=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#L(),this.#A()}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(Q))}#K(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#Y(Q){let $=Q.getAttribute("value");if($!==null){let J=$.trim();if(J.length>0)return J}return Q.textContent?.trim()||""}#W(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if($.hasAttribute("selected"))return $;return null}#N(){return Array.from(this.querySelectorAll("fig-segment")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#L(){let Q=Array.from(this.querySelectorAll("fig-segment")),$=Q.find((J)=>J.hasAttribute("selected"));Q.forEach((J)=>{let Z=J.hasAttribute("disabled")&&J.getAttribute("disabled")!=="false",j=J===$;J.setAttribute("aria-checked",j?"true":"false"),J.setAttribute("tabindex",!Z&&j?"0":"-1")})}#U(Q){if(!Q)return;let $=this.selectedSegment,J=this.value;this.selectedSegment=Q;let Z=this.#Y(Q);if(Z)this.setAttribute("value",Z);else this.removeAttribute("value");let j=this.value;if($!==Q||J!==j)this.#K(j)}#B(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.#N();if(!$.length)return;let J=$.findIndex((q)=>q.hasAttribute("selected")),Z=J>=0?J:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),Z=Z>0?Z-1:$.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),Z=Z<$.length-1?Z+1:0;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;case" ":case"Enter":{let q=Q.target.closest("fig-segment");if(q&&this.contains(q))Q.preventDefault(),this.#U(q);return}default:return}let j=$[Z];this.#U(j),j.focus(),requestAnimationFrame(()=>{if(this.contains(j))j.focus()})}#M(Q){let $=String(Q??"").trim();if(!$)return!1;let J=this.querySelectorAll("fig-segment");for(let Z of J){let j=this.#Y(Z);if(!j)continue;if(j===$)return this.selectedSegment=Z,!0}return!1}#G(){let Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#A({forceInstant:Q=!1}={}){if(this.#_=this.#_||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let $=this.#_;this.#_=!1,this.#D({forceInstant:$})})}#D({forceInstant:Q=!1}={}){let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#G(),Z=this.#$&&this.contains(this.#$)?this.#$:this.#W();if($||!J){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!J||$)this.#X=!1;return}if(!Z){if(this.#X)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=Z.getBoundingClientRect();if(j.width<=0||q.width<=0){if(this.#X)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.#X||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#X=!0}#O(){this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#A()}),this.#H()}#H(){if(!this.#Z)return;this.#Z.disconnect(),this.#Z.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#Z?.observe(Q)})}#R({enforceFallback:Q=!1}={}){let $=this.querySelectorAll("fig-segment");if($.length===0){this.#$=null,this.#A({forceInstant:!0});return}let J=this.getAttribute("value"),Z=J?.trim()??"";if(J!==null){if(Z!==J){this.setAttribute("value",Z);return}if(Z&&this.#M(Z))return}let j=this.#W();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=$[0]}#F(){this.#J?.disconnect(),this.#J=new MutationObserver((Q)=>{let $=!1;for(let J of Q){if(J.type==="childList"){$=!0;break}if(J.type==="attributes"&&J.target instanceof HTMLElement&&J.target.tagName.toLowerCase()==="fig-segment"&&(J.attributeName==="value"||J.attributeName==="selected")){$=!0;break}if(J.type==="characterData"){$=!0;break}}if($)this.#z(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#H(),this.#R({enforceFallback:!0}),this.#L()}),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 $=Q.target.closest("fig-segment");if(!$||!this.contains($))return;this.#U($)}#z(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach(($)=>{if(Q)$.setAttribute("disabled",""),$.setAttribute("aria-disabled","true");else $.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#L()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="disabled"){this.#z(J!==null&&J!=="false"),this.#A({forceInstant:!0});return}if(Q==="value"){this.#R({enforceFallback:!1});return}if(Q==="animated"){if(!this.#G())this.#X=!1;this.#A({forceInstant:!0});return}if(Q==="sizing")this.#A({forceInstant:!0})}}customElements.define("fig-segmented-control",C0);class S0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#$="segments";#Q=0;#j=null;#J=[];#Z=null;#q=!1;#_(Q){let $=Q?.detail;if(typeof $==="string")return $;let J=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if(J===null||J===void 0)return null;return String(J)}connectedCallback(){this.#X(),this.#K(),this.#U(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#G())})}disconnectedCallback(){this.#j?.disconnect(),this.#j=null}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get options(){return this.#J.slice()}set options(Q){if(Array.isArray(Q)){let J=Q.some((Z)=>String(Z).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",J)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="options"){this.#X(),this.#W();return}if(Q==="value"){this.#N();return}if(Q==="disabled"){this.#L("disabled");return}if(Q==="full"){this.#L("full");return}if(Q==="sizing")this.#L("sizing"),this.#W()}#X(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#J=JSON.parse(Q);return}catch{}let $=Q.includes(`
37
+ `,this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.button.addEventListener("click",this.#J),this.button.addEventListener("focus",this.#Z),this.button.addEventListener("blur",this.#q),this.addEventListener("keydown",this.#j)}this.#$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#G()}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q)}#_(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#X(){if(this.#_())return;if(this.type==="toggle")this.toggleAttribute("selected",!this.hasAttribute("selected"));if(this.type==="submit"){let Q=this.closest("form");if(Q)Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),$=this.getAttribute("target");if(Q)if($)window.open(Q,$);else window.location.href=Q}}#K(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#Y(){let Q=this.#K();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 $=this.#Y();if(!$||$.disabled||$.multiple)return;if(typeof $.showPicker!=="function")return;Q.preventDefault();try{$.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.#Q.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.button.removeAttribute(Q);else this.button.setAttribute(Q,$)})}#G(){if(!this.button)return;let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=Q,this.button instanceof HTMLButtonElement)this.button.disabled=Q,this.button.type=this.type,this.button.setAttribute("type",this.type);this.#L(),this.#W()}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"type":{let Z=(j)=>j==="select"||j==="upload";if(Z($||"button")!==Z(J||"button")){this.button=null,this.connectedCallback();break}this.#G();break}case"disabled":this.#G();break;case"selected":this.#$=J!==null&&J!=="false",this.#W();break;default:this.#L();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#j)}}customElements.define("fig-button",z0);class D0 extends HTMLElement{#$="Menu";#Q=null;#j;#J;#Z;#q=!1;#_=null;get label(){return this.#$}set label(Q){this.#$=Q}#X;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#j=this.#U.bind(this),this.#J=this.#B.bind(this),this.#Z=this.#M.bind(this),this.#X=this.slotChange.bind(this)}#K(){if(typeof CSS>"u"||typeof CSS.supports!=="function")return!1;try{return CSS.supports("appearance: base-select")&&CSS.supports("selector(::picker(select))")}catch{return!1}}#Y(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#K()){this.#q=!1;return}let J=document.createElement("button");J.setAttribute("type","button"),J.setAttribute("aria-hidden","true");let Z=document.createElement("selectedcontent");J.appendChild(Z),this.select.appendChild(J),this.#q=!0,this.#_=Z}#N(){if(!this.#_)return;let Q=this.select.selectedOptions?.[0];if(!Q){this.#_.textContent="";return}this.#_.innerHTML=Q.innerHTML}#W(){this.select.addEventListener("input",this.#j),this.select.addEventListener("change",this.#J),this.select.addEventListener("keydown",this.#Z)}#L(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#G(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){if(this.type=this.getAttribute("type")||"select",this.#$=this.getAttribute("label")||this.#$,this.select.setAttribute("aria-label",this.#$),this.#R(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#X),this.optionsSlot.addEventListener("slotchange",this.#X),this.select.removeEventListener("input",this.#j),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#Z),this.#W()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.#Y(),this.type==="dropdown"){let Q=document.createElement("option");Q.setAttribute("hidden","true"),Q.setAttribute("selected","true"),Q.selected=!0,this.select.appendChild(Q)}if(this.optionsSlot.assignedNodes().forEach((Q)=>{if(Q.nodeName==="OPTION"||Q.nodeName==="OPTGROUP")this.select.appendChild(Q.cloneNode(!0))}),this.#z(this.value),this.#N(),this.type==="dropdown")this.select.selectedIndex=-1}#U(Q){let $=Q.target.selectedOptions?.[0];if(this.#L($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#G();return}let J=Q.target.value;if(this.type==="dropdown")this.#Q=J;this.setAttribute("value",J),this.#N(),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}#B(Q){let $=Q.target.selectedOptions?.[0];if(this.#L($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#G();return}let J=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#N(),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}#M(Q){if(this.closest('fig-button[type="select"]'))return;if(Q.key!=="Enter"||Q.defaultPrevented)return;if(this.#q&&this.select.matches(":open"))return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(typeof this.select.showPicker!=="function")return;Q.preventDefault();try{this.select.showPicker()}catch{}}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#Q;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#Q=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","experimental","label","disabled"]}#R(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=Q}#z(Q){if(this.type==="dropdown")return;if(this.select)this.select.querySelectorAll("option").forEach(($,J)=>{if($.value===this.getAttribute("value"))this.select.selectedIndex=J});this.#N()}attributeChangedCallback(Q,$,J){if(Q==="value")this.#z(J);if(Q==="type")this.type=J;if(Q==="experimental")this.slotChange();if(Q==="label")this.#$=J,this.select.setAttribute("aria-label",this.#$);if(Q==="disabled")this.#R()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#X),this.select.removeEventListener("input",this.#j),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#Z)}}customElements.define("fig-dropdown",D0);class S extends HTMLElement{static#$=0;static#Q=500;#j;#J;#Z;#q;#_;#X;#K;#Y;#N;#W;#L=null;#G;#U=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#j=this.#O.bind(this),this.#J=this.hidePopupOutsideClick.bind(this),this.#Z=this.showDelayedPopup.bind(this),this.#q=this.#M.bind(this),this.#_=this.#R.bind(this),this.#X=this.#z.bind(this),this.#K=this.#A.bind(this),this.#Y=this.#F.bind(this),this.#W=this.#D.bind(this),this.#N=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(this.setup(),this.setupEventListeners(),this.#L=this.closest("dialog"),this.#L)this.#L.addEventListener("close",this.#N)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),document.removeEventListener("mousedown",this.#j,!0),document.removeEventListener("keydown",this.#W,!0),this.#L)this.#L.removeEventListener("close",this.#N),this.#L=null;if(this.action==="click")document.body.removeEventListener("click",this.#J);if(clearTimeout(this.#G),this.action==="hover")this.removeEventListener("pointerenter",this.#Z),this.removeEventListener("pointerleave",this.#q),this.removeEventListener("touchstart",this.#_),this.removeEventListener("touchmove",this.#X),this.removeEventListener("touchend",this.#K),this.removeEventListener("touchcancel",this.#Y);else if(this.action==="click")this.removeEventListener("click",this.#Z),this.removeEventListener("touchstart",this.#Z)}setup(){this.style.display="contents"}render(){this.destroy();let Q=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,$=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 J=y();this.popup.setAttribute("id",J);let Z=this.getAttribute("theme");if(Z)this.popup.setAttribute("theme",Z);let j=this.getAttribute("pointer");if(j!==null)this.popup.setAttribute("pointer",j);if(this.popup.append($),$.innerText=this.getAttribute("text")??"",this.firstElementChild)this.firstElementChild.setAttribute("aria-describedby",J);if(Q)document.body.append(this.popup);else{let q=this.closest("dialog");if(q&&q.open)q.append(this.popup);else document.body.append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.popup.remove(),this.popup=null;if(this.action==="click")document.body.removeEventListener("click",this.#J)}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="manual")return;if(this.action==="hover"){if(!this.isTouchDevice())this.addEventListener("pointerenter",this.#Z),this.addEventListener("pointerleave",this.#q);this.addEventListener("touchstart",this.#_,{passive:!0}),this.addEventListener("touchmove",this.#X,{passive:!0}),this.addEventListener("touchend",this.#K,{passive:!0}),this.addEventListener("touchcancel",this.#Y,{passive:!0})}else if(this.action==="click")this.addEventListener("click",this.#Z),document.body.addEventListener("click",this.#J),this.addEventListener("touchstart",this.#Z,{passive:!0});document.addEventListener("mousedown",this.#j,!0),document.addEventListener("keydown",this.#W,!0)}get#B(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}showDelayedPopup(){if(this.#B)return;this.render(),clearTimeout(this.timeout);let $=Date.now()-S.#$<S.#Q?0:this.delay;this.timeout=setTimeout(this.showPopup.bind(this),$)}showPopup(){if(this.#L&&!this.#L.open)return;if(!this.firstElementChild)return;if(!this.popup)this.render();this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,S.#$=Date.now()}hidePopup(){if(this.#B)return;if(clearTimeout(this.timeout),clearTimeout(this.#G),this.popup)this.destroy();this.isOpen=!1,S.#$=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#M(Q){if(!this.#U)this.hidePopup()}#R(Q){if(this.action==="hover")this.#U=!0,clearTimeout(this.#G),this.showDelayedPopup()}#z(Q){if(this.action==="hover"&&this.#U)clearTimeout(this.#G),this.#G=setTimeout(()=>{this.#U=!1,this.hidePopup()},150)}#A(Q){if(this.action==="hover"&&this.#U)clearTimeout(this.#G),this.#G=setTimeout(()=>{this.#U=!1,this.hidePopup()},300)}#F(Q){if(this.action==="hover"&&this.#U)this.#U=!1,clearTimeout(this.#G),this.hidePopup()}#D(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 $=this.popup.firstElementChild??this.popup.firstChild;if(!$)return;$.innerText=Q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")==="true"}set open(Q){this.setAttribute("open",Q)}attributeChangedCallback(Q,$,J){if(Q==="action")this.action=J;if(Q==="delay"){let Z=parseInt(J);this.delay=!isNaN(Z)?Z:500}if(Q==="open")if(J==="true")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(Q==="show")if(J!==null&&J!=="false")this.showPopup();else this.hidePopup();if(Q==="text")this.#H(J??"");if(Q==="pointer"){if(this.popup)if(J!==null)this.popup.setAttribute("pointer",J);else this.popup.removeAttribute("pointer")}if(Q==="theme"){if(this.popup)if(J)this.popup.setAttribute("theme",J);else this.popup.removeAttribute("theme")}}#O(Q){if(!this.isOpen)return;let $=Q.target;if(this.popup&&this.popup.contains($))return;if($.tagName==="SELECT"||$.hasAttribute("popover")||$.closest("dialog"))this.hidePopup()}static#k=new WeakMap;static show(Q,$,J={}){S.hide(Q);let Z=J.delay??500,q=Date.now()-S.#$<S.#Q?0:Z,_={timeout:null,popup:null};S.#k.set(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=$,Y.append(K),X)document.body.append(Y);else{let N=Q.closest?.("dialog");if(N&&N.open)N.append(Y);else document.body.append(Y)}Y.anchor=Q,Y.open=!0,_.popup=Y,S.#$=Date.now()},q)}static hide(Q){let $=S.#k.get(Q);if(!$)return;if(clearTimeout($.timeout),$.popup)$.popup.remove();S.#k.delete(Q)}}customElements.define("fig-tooltip",S);class H0 extends HTMLElement{static observedAttributes=["position","tail"];#$=null;#Q=null;#j=null;connectedCallback(){this.#$=this.textContent,v(this,()=>{this.#J(),this.#Z()})}disconnectedCallback(){this.#q()}attributeChangedCallback(Q,$,J){if($===J)return;if(this.#$===null)return;this.#J()}#J(){let Q=this.getAttribute("position")||"right",$=this.#$||"";if(Q==="middle"){let J=this.getAttribute("tail"),Z;if(J){let _=$.lastIndexOf(J);Z=_>0?_:Math.ceil($.length/2)}else Z=Math.ceil($.length/2);this.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=$.slice(0,Z);let q=document.createElement("span");q.className="end",q.textContent=$.slice(Z),this.appendChild(j),this.appendChild(q)}else this.textContent=$}#Z(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;S.show(this,this.#$)},this.#j=()=>{S.hide(this)},this.addEventListener("pointerenter",this.#Q),this.addEventListener("pointerleave",this.#j)}#q(){if(this.#Q)this.removeEventListener("pointerenter",this.#Q);if(this.#j)this.removeEventListener("pointerleave",this.#j);S.hide(this)}}customElements.define("fig-truncate",H0);class F0 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._previousFocus=null}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),v(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),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.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 $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Q.focus?.())}show(){return this._captureFocusBeforeOpen(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),super.show()}showModal(){return this._captureFocusBeforeOpen(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),super.showModal()}_handleIframeMessage(Q){if(!this.autoresize)return;let $=Q?.data;if(!$||$.type!=="figui:iframe-resize")return;let J=Q.source;if(!J)return;let Z=Array.from(this.querySelectorAll("iframe")).find((j)=>j.contentWindow===J);if(!Z)return;this._resizeForIframe(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 $ of Q)$.addedNodes?.forEach((J)=>{if(J instanceof Element&&J.parentElement===this)try{this._resizeObserver?.observe(J)}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 $=window.getComputedStyle(this),J=parseFloat($.paddingTop||"0")+parseFloat($.paddingBottom||"0")+parseFloat($.borderTopWidth||"0")+parseFloat($.borderBottomWidth||"0"),Z=0,j=parseFloat($.rowGap||$.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");Z+=X.height+K}if(j&&q>1)Z+=j*(q-1);return J+Z}_resizeForIframe(Q,$){if(typeof $.height!=="number"||!($.height>0))return;let J=this._computeChrome(Q);this.style.height=`${Math.ceil($.height+J)}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 $=document.createElement("h3");$.textContent=this.getAttribute("title")||"Dialog";let J=document.createElement("fig-tooltip");J.setAttribute("text","Close");let Z=document.createElement("fig-button");Z.setAttribute("variant","ghost"),Z.setAttribute("icon",""),Z.setAttribute("aria-label","Close dialog"),Z.setAttribute("close-dialog",""),Z.appendChild(h("close")),J.appendChild(Z),Q.appendChild($),Q.appendChild(J),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.getAttribute("id")||y();Q.setAttribute("id",$),this.setAttribute("aria-labelledby",$)}}}_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.includes("top"),J=Q.includes("bottom"),Z=Q.includes("left"),j=Q.includes("right"),q=Q.includes("center")&&!$&&!J,_=Q.includes("center")&&!Z&&!j;if($)this.style.top=`${this._offset}px`;else if(J)this.style.bottom=`${this._offset}px`;else if(q)this.style.top="0",this.style.bottom="0";if(Z)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"),$=Q?this.querySelector(Q):this.querySelector("fig-header, header");if($)$.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}_isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(q)=>$.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}_handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(Q,$,J){if(this._figInit(),Q==="autoresize"&&this.isConnected)this._syncAutoResize();if(Q==="drag")if(this.drag=J!==null&&J!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let Z=this.querySelector("fig-header, header");if(Z)Z.style.cursor=""}if(Q==="position"&&this._positionInitialized)this._applyPosition();if(Q==="modal"){let Z=this.modal;if(this.modal=J!==null&&J!=="false",this.open&&Z!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(Q==="closedby")this.closedby=J||"any";if(Q==="title"){let Z=this.querySelector("fig-header[data-auto] h3");if(Z)Z.textContent=J||"Dialog";this._syncA11y()}if(Q==="aria-label"||Q==="aria-labelledby")this._syncA11y()}}Z0("fig-dialog",F0,{extends:"dialog"});class T0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._boundHandleClose=this.handleClose.bind(this)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast()}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close notification");Q.removeEventListener("click",this._boundHandleClose),Q.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto",this.style.bottom=`${parseInt(this.getAttribute("offset")??this._defaultOffset)}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let Q=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger";if(!this.hasAttribute("role"))this.setAttribute("role",Q?"alert":"status");if(!this.hasAttribute("aria-live"))this.setAttribute("aria-live",Q?"assertive":"polite");if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}startAutoClose(){this.clearAutoClose();let Q=parseInt(this.getAttribute("duration")??"5000");if(Q>0)this._autoCloseTimer=setTimeout(()=>this.hideToast(),Q)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}showToast(){if(this.syncLiveRegion(),!this.open)this.show();this.applyPosition(),this.startAutoClose(),this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){if(this.clearAutoClose(),this.open)this.close();this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live"]}attributeChangedCallback(Q,$,J){if(this._figInit(),$===J)return;if(!this.isConnected)return;if(Q==="offset")this.applyPosition();if(Q==="open")if(J!==null&&J!=="false")this.showToast();else this.hideToast();if(Q==="theme"||Q==="live")this.syncLiveRegion()}}Z0("fig-toast",T0,{extends:"dialog"});class P0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;_previousFocus=null;_boundDocumentKeydown;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{let $=Q.target;if(this.open&&(!($ instanceof Node)||!this.contains($))&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this),this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this)}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._previousFocus>"u")this._previousFocus=null;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{let $=Q.target;if(this.open&&(!($ instanceof Node)||!this.contains($))&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this);if(typeof this._boundDocumentKeydown!=="function")this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!this.open)return;this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else if(Q&&typeof Q.getBoundingClientRect==="function")this._anchorRef=Q;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role",this.getAttribute("variant")==="tooltip"?"tooltip":"dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this.addEventListener("close",()=>{if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}),requestAnimationFrame(()=>{this.setupDragListeners()}),this.open)this.showPopup();else this.hidePopup()}disconnectedCallback(){if(this.ensureInitialized(),this.teardownObservers(),this.removeDragListeners(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(Q,$,J){if(this.ensureInitialized(),$===J)return;if(Q==="open"){if(J===null||J==="false"){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=J!==null&&J!=="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(F1()+1),this.captureFocusBeforeOpen();let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),$=this.shouldAutoReposition();if($)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(Z){}if(!Q&&!super.open)try{this.show()}catch(Z){}if($&&(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 J=this.resolveAnchor();if(J?.classList)J.classList.add("has-popup-open")}hidePopup(){let Q=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),$=this.resolveAnchor();if($?.classList)$.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(J){}if(this.matches?.(":open"))try{this.close()}catch(J){}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(),$=this._previousFocus?.isConnected?this._previousFocus:Q instanceof HTMLElement?Q:null;if(this._previousFocus=null,!$?.isConnected)return;let J=document.activeElement;if(J&&J!==document.body&&!this.contains(J))return;requestAnimationFrame(()=>$.focus?.())}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.removeAttribute("autoresize")}setupObservers(){this.teardownObservers();let Q=this.resolveAnchor();if(Q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(Q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(Q){if(!Q)return null;let $=Q.getBoundingClientRect();return{x:$.x,y:$.y,width:$.width,height:$.height}}hasRectChanged(Q,$,J=0.25){if(!Q&&!$)return!1;if(!Q||!$)return!0;return Math.abs(Q.x-$.x)>J||Math.abs(Q.y-$.y)>J||Math.abs(Q.width-$.width)>J||Math.abs(Q.height-$.height)>J}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let $=this.resolveAnchor(),J=this.readRectSnapshot($),Z=this.shouldAutoReposition();if(Z&&this.hasRectChanged(this._lastAnchorRect,J))this._lastAnchorRect=J,this.queueReposition();else if(!Z)this._lastAnchorRect=J;this._anchorTrackRAF=requestAnimationFrame(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!super.open)return;let $=this.getAttribute("closedby");if($==="none"||$==="closerequest")return;let J=Q.target;if(!(J instanceof Node))return;if(this.contains(J))return;let Z=this.resolveAnchor();if(Z?.contains&&Z.contains(J))return;if(this.isInsideDescendantPopup(J))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 Z=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(Z&&Z!==this)return;Q.preventDefault(),this.open=!1}isInsideDescendantPopup(Q){let $=Q.closest?.('dialog[is="fig-popup"]');if(!$||$===this)return!1;let J=$,Z=new Set;while(J&&!Z.has(J)){Z.add(J);let j=J.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;J=j.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}isInteractiveElement(Q){let $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["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"],Z=(q)=>$.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!J.includes(q.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let $=this.getAttribute("handle");if($&&$.trim()){let Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let $=this.parentElement;if($?.querySelector){let J=$.querySelector(Q);if(J&&!this.contains(J))return J}return document.querySelector(Q)}parsePosition(){let $=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),J=new Set(["top","center","bottom"]),Z=new Set(["left","center","right"]),j="top",q="center",_=null;if($.length>=2){if(J.has($[0]))j=$[0];if(Z.has($[1]))q=$[1];return{vertical:j,horizontal:q,shorthand:_}}if($.length===1){let X=$[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,$="0px"){if(!Q)return $;let J=Q.trim();if(!J)return $;if(/^-?\d+(\.\d+)?$/.test(J))return`${J}px`;return J}measureLengthPx(Q,$="x"){if(!Q)return 0;let J=this.normalizeOffsetToken(Q,"0px");if(J.endsWith("px")){let q=parseFloat(J);return Number.isFinite(q)?q:0}let Z=document.createElement("div");if(Z.style.position="fixed",Z.style.visibility="hidden",Z.style.pointerEvents="none",Z.style.left="0",Z.style.top="0",Z.style.margin="0",Z.style.padding="0",Z.style.border="0",$==="x")Z.style.width=J,Z.style.height="0";else Z.style.height=J,Z.style.width="0";document.body.appendChild(Z);let j=Z.getBoundingClientRect();return Z.remove(),$==="x"?j.width:j.height}parseOffset(){let $=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),J=this.normalizeOffsetToken($[0],"0px"),Z=this.normalizeOffsetToken($[1],"0px");return{xToken:J,yToken:Z,xPx:this.measureLengthPx(J,"x"),yPx:this.measureLengthPx(Z,"y")}}parseViewportMargins(){let $=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((Z)=>!Number.isNaN(Z)),J=8;if($.length===0)return{top:8,right:8,bottom:8,left:8};if($.length===1)return{top:$[0],right:$[0],bottom:$[0],left:$[0]};if($.length===2)return{top:$[0],right:$[1],bottom:$[0],left:$[1]};if($.length===3)return{top:$[0],right:$[1],bottom:$[2],left:$[1]};return{top:$[0],right:$[1],bottom:$[2],left:$[3]}}getPlacementCandidates(Q,$,J){let Z={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if(J){let q=J==="left"||J==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:$,s:J},{v:Q,h:$,s:Z[J]},{v:Q,h:$,s:q[0]},{v:Q,h:$,s:q[1]}]}if(Q==="center")return[{v:"center",h:$,s:null},{v:"center",h:Z[$],s:null},{v:"top",h:$,s:null},{v:"bottom",h:$,s:null},{v:"top",h:Z[$],s:null},{v:"bottom",h:Z[$],s:null}];if($==="center")return[{v:Q,h:"center",s:null},{v:Z[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:Z[Q],h:"left",s:null},{v:Z[Q],h:"right",s:null}];return[{v:Q,h:$,s:null},{v:Z[Q],h:$,s:null},{v:Q,h:Z[$],s:null},{v:Z[Q],h:Z[$],s:null}]}computeCoords(Q,$,J,Z,j,q){let _,X;if(q==="left"||q==="right")return X=q==="left"?Q.left-$.width-j.xPx:Q.right+j.xPx,_=Q.top,{top:_,left:X};if(q==="top"||q==="bottom")return _=q==="top"?Q.top-$.height-j.yPx:Q.bottom+j.yPx,X=Q.left,{top:_,left:X};if(J==="top")_=Q.top-$.height-j.yPx;else if(J==="bottom")_=Q.bottom+j.yPx;else _=Q.top+(Q.height-$.height)/2;if(J==="center")if(Z==="left")X=Q.left-$.width-j.xPx;else if(Z==="right")X=Q.right+j.xPx;else X=Q.left+(Q.width-$.width)/2;else if(Z==="left")X=Q.left+j.xPx;else if(Z==="right")X=Q.right-$.width-j.xPx;else X=Q.left+(Q.width-$.width)/2;return{top:_,left:X}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,$,J){if(J==="top")return"top";if(J==="bottom")return"bottom";if(J==="left")return"left";if(J==="right")return"right";if(Q!=="center")return Q;if($!=="center")return $;return"top"}updatePopoverBeak(Q,$,J,Z,j){let q=this.getAttribute("variant");if(!(q==="popover"||q==="tooltip")||!Q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let X=this.oppositeSide(j);this.setAttribute("data-beak-side",X);let Y=Q.left+Q.width/2,K=Q.top+Q.height/2,N=this.getBoundingClientRect(),L=N.width>0&&N.height>0?N:$,O=L.left,H=L.top,B=getComputedStyle(this),U=(D,T=0)=>{let P=String(D||"").trim(),k=parseFloat(P);if(!Number.isFinite(k))return T;if(P.endsWith("rem"))return k*parseFloat(getComputedStyle(document.documentElement).fontSize);if(P.endsWith("em"))return k*parseFloat(B.fontSize);return k},z=(D)=>{if(D==="top")return Math.max(U(B.borderTopLeftRadius),U(B.borderTopRightRadius));if(D==="bottom")return Math.max(U(B.borderBottomLeftRadius),U(B.borderBottomRightRadius));if(D==="left")return Math.max(U(B.borderTopLeftRadius),U(B.borderBottomLeftRadius));if(D==="right")return Math.max(U(B.borderTopRightRadius),U(B.borderBottomRightRadius));return 0},A=U(B.getPropertyValue("--fig-popup-beak-width"),16),G=Math.max(10,z(X)+A/2),M;if(X==="top"||X==="bottom"){M=Y-O;let D=G,T=Math.max(D,L.width-G);M=Math.min(T,Math.max(D,M))}else{M=K-H;let D=G,T=Math.max(D,L.height-G);M=Math.min(T,Math.max(D,M))}this.style.setProperty("--fig-popup-beak-offset",`${M}px`)}overflowScore(Q,$,J){let{innerWidth:Z,innerHeight:j}=window,q=Q.left+$.width,_=Q.top+$.height,X=Math.max(0,J.left-Q.left),Y=Math.max(0,J.top-Q.top),K=Math.max(0,q-(Z-J.right)),N=Math.max(0,_-(j-J.bottom));return X+Y+K+N}fits(Q,$,J){return this.overflowScore(Q,$,J)===0}clamp(Q,$,J){let{left:Z,top:j}=J,q=Math.max(J.left,window.innerWidth-$.width-J.right),_=Math.max(J.top,window.innerHeight-$.height-J.bottom);return{left:Math.min(q,Math.max(Z,Q.left)),top:Math.min(_,Math.max(j,Q.top))}}positionPopup(){if(!this.open||!this.matches?.(":open"))return;let Q=this.getBoundingClientRect(),$=this.parseOffset(),{vertical:J,horizontal:Z,shorthand:j}=this.parsePosition(),q=this.resolveAnchor(),_=this.parseViewportMargins();if(!q){this.updatePopoverBeak(null,Q,0,0,"top");let H={left:_.left+(window.innerWidth-_.right-_.left-Q.width)/2,top:_.top+(window.innerHeight-_.bottom-_.top-Q.height)/2},B=this.clamp(H,Q,_);this.style.left=`${B.left}px`,this.style.top=`${B.top}px`;return}let X=q.getBoundingClientRect(),Y=this.getPlacementCandidates(J,Z,j),K=null,N="top",L=Number.POSITIVE_INFINITY;for(let{v:H,h:B,s:U}of Y){let z=this.computeCoords(X,Q,H,B,$,U),A=this.getPlacementSide(H,B,U);if(U){let G=this.clamp(z,Q,_);if(U==="left"||U==="right"?z.left>=_.left&&z.left+Q.width<=window.innerWidth-_.right:z.top>=_.top&&z.top+Q.height<=window.innerHeight-_.bottom){this.style.left=`${G.left}px`,this.style.top=`${G.top}px`,this.updatePopoverBeak(X,Q,G.left,G.top,A);return}let D=this.overflowScore(z,Q,_);if(D<L)L=D,K=G,N=A}else{if(this.fits(z,Q,_)){this.style.left=`${z.left}px`,this.style.top=`${z.top}px`,this.updatePopoverBeak(X,Q,z.left,z.top,A);return}let G=this.overflowScore(z,Q,_);if(G<L)L=G,K=z,N=A}}let O=this.clamp(K||{left:0,top:0},Q,_);this.style.left=`${O.left}px`,this.style.top=`${O.top}px`,this.updatePopoverBeak(X,Q,O.left,O.top,N)}queueReposition(){if(!this.open||!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()}}Z0("fig-popup",P0,{extends:"dialog"});class E0 extends HTMLElement{#$;#Q;constructor(){super();this.content=null,this.#$=!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),v(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let Q=this.getAttribute("id")||y(),$=this.content.getAttribute("id")||y();if(this.setAttribute("id",Q),this.content.setAttribute("id",$),this.setAttribute("aria-controls",$),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",Q),this.#$)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.#$}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(this.hasAttribute("disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(Q,$,J){if(Q==="selected"){if(this.#$=J!==null&&J!=="false",this.setAttribute("aria-selected",this.#$?"true":"false"),this.setAttribute("tabindex",this.#$?"0":"-1"),this?.content)this.content.style.display=this.#$?"block":"none"}if(Q==="disabled")if(J!==null&&J!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#$?"0":"-1")}}customElements.define("fig-tab",E0);class k0 extends HTMLElement{#$;#Q;#j=this.#B.bind(this);#J=null;#Z=null;#q=null;#_=null;#X=null;#K=!1;constructor(){super();this.#$=this.handleClick.bind(this),this.#Q=this.#F.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.#U(),this.addEventListener("click",this.#$),this.addEventListener("keydown",this.#Q),this.#Y.addEventListener("scroll",this.#j),this.#A(),this.#R(),this.#M(),v(this,()=>{let Q=this.getAttribute("value");if(Q)this.#O(Q);if(this.hasAttribute("disabled"))this.#N(!0);this.#L(),this.#B(),this.#G(void 0,"auto")})}get#Y(){return this.#q||this}get scrollLeft(){return this.#Y.scrollLeft}set scrollLeft(Q){this.#Y.scrollLeft=Q}get scrollWidth(){return this.#Y.scrollWidth}scrollTo(...Q){this.#Y.scrollTo(...Q)}scrollBy(...Q){this.#Y.scrollBy(...Q)}#N(Q){this.querySelectorAll("fig-tab").forEach((J)=>{if(Q)J.setAttribute("disabled",""),J.setAttribute("aria-disabled","true"),J.setAttribute("tabindex","-1");else J.removeAttribute("disabled"),J.removeAttribute("aria-disabled")}),this.#L()}#W(){return Array.from(this.querySelectorAll("fig-tab")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#L(){let Q=Array.from(this.querySelectorAll("fig-tab")),$=Q.find((J)=>J.hasAttribute("selected"))||this.#W()[0];Q.forEach((J)=>{let Z=J.hasAttribute("disabled")&&J.getAttribute("disabled")!=="false";J.setAttribute("tabindex",!Z&&J===$?"0":"-1")})}#G(Q=this.selectedTab,$="smooth"){let J=Q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#W()[0];if(!J)return;requestAnimationFrame(()=>{if(!this.isConnected||!J.isConnected)return;let Z=this.#Y;if(!(Z.scrollWidth>Z.clientWidth))return;let q=Z.getBoundingClientRect(),_=J.getBoundingClientRect(),X=_.left-q.left+Z.scrollLeft+_.width/2;Z.scrollTo({left:X-Z.clientWidth/2,behavior:$}),this.#B()})}disconnectedCallback(){this.removeEventListener("click",this.#$),this.removeEventListener("keydown",this.#Q),this.#Y.removeEventListener("scroll",this.#j),this.#J?.disconnect(),this.#J=null,this.#Z?.disconnect(),this.#Z=null,this.#z()}#U(){if(this.#K)return;let Q=this.querySelector(":scope > [data-fig-tabs-scroll]"),$=Q?Array.from(this.childNodes).filter((J)=>{if(J===Q)return!1;if(J.nodeType!==Node.ELEMENT_NODE)return!0;return!J.hasAttribute("data-fig-tabs-nav")}):null;if(Q&&Q===this.#q&&!$?.length)return;this.#K=!0;try{let J=this.#q;if(J&&J!==Q)J.removeEventListener("scroll",this.#j);let Z=Q||document.createElement("div");Z.className="fig-tabs-scroll",Z.dataset.figTabsScroll="";let j=$??Array.from(this.childNodes).filter((q)=>{if(q===Z)return!1;if(q.nodeType!==Node.ELEMENT_NODE)return!0;return!q.hasAttribute("data-fig-tabs-nav")});for(let q of j)Z.appendChild(q);if(!Q)this.prepend(Z);if(this.#q=Z,this.#q.removeEventListener("scroll",this.#j),this.#q.addEventListener("scroll",this.#j),this.#Z)this.#Z.observe(this.#q)}finally{this.#K=!1}}#B(){R0(this,this.#Y,"x")}#M(){if(this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>this.#B()),this.#Z.observe(this),this.#q)this.#Z.observe(this.#q)}#R(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>{if(this.#K)return;this.#U(),this.#A(),this.#L(),requestAnimationFrame(()=>{this.#B(),this.#G()})}),this.#J.observe(this,{childList:!0,subtree:!0})}#z(){this.#_?.remove(),this.#X?.remove(),this.#_=null,this.#X=null,this.classList.remove("overflow-start","overflow-end")}#A(){if(this.#_&&this.#X&&this.contains(this.#_)&&this.contains(this.#X))return;this.#_?.remove(),this.#X?.remove();let Q=O0({owner:"tabs",onStart:()=>J0(this.#Y,"x",-1),onEnd:()=>J0(this.#Y,"x",1)});this.#_=Q.start,this.#X=Q.end,this.prepend(this.#_),this.append(this.#X)}#F(Q){let $=this.#W();if(!$.length)return;let J=$.findIndex((j)=>j.hasAttribute("selected")),Z=J>=0?J:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),Z=J>0?J-1:$.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),Z=J<$.length-1?J+1:0;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;default:return}if(Z!==J&&$[Z]){this.querySelectorAll("fig-tab").forEach((q)=>q.removeAttribute("selected")),this.selectedTab=$[Z],$[Z].setAttribute("selected","true");let j=this.#H($[Z]);if(j)this.setAttribute("value",j);else this.removeAttribute("value");$[Z].focus(),this.#L(),this.#G($[Z]),this.#D()}}get value(){return this.#H(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}))}#H(Q){if(!Q)return"";let $=Q.getAttribute("value");if($!==null)return $;return Q.textContent?.trim()||""}#O(Q){let $=this.querySelectorAll("fig-tab");for(let J of $)if(this.#H(J)===Q)this.selectedTab=J,J.setAttribute("selected","true");else J.removeAttribute("selected");this.#L(),this.#G(this.selectedTab)}attributeChangedCallback(Q,$,J){switch(Q){case"value":if(J!==$)this.#O(J);break;case"disabled":this.#N(J!==null&&J!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled"))return;let $=Q.target.closest("fig-tab");if(!$||!this.contains($))return;let J=this.selectedTab,Z=this.value,j=this.querySelectorAll("fig-tab");for(let _ of j)if(_===$)this.selectedTab=_,_.setAttribute("selected","true");else _.removeAttribute("selected");let q=this.#H($);if(q)this.setAttribute("value",q);else this.removeAttribute("value");if(this.#L(),this.#G($),J!==$||Z!==this.value)this.#D()}}customElements.define("fig-tabs",k0);class C0 extends HTMLElement{#$;#Q;#j;constructor(){super();this.#j=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#J(),this.addEventListener("click",this.#j)}disconnectedCallback(){this.removeEventListener("click",this.#j)}handleClick(){let Q=this.closest("fig-segmented-control");if(Q&&Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#$}set value(Q){this.#$=Q,this.setAttribute("value",Q)}get selected(){return this.#Q}set selected(Q){this.#Q=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value","disabled"]}#J(){let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",Q?"true":"false"),$)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",Q?"0":"-1")}attributeChangedCallback(Q,$,J){switch(Q){case"value":this.#$=J;break;case"selected":this.#Q=J,this.#J();break;case"disabled":this.#J();break}}}customElements.define("fig-segment",C0);class S0 extends HTMLElement{#$=null;#Q=this.handleClick.bind(this);#j=this.#U.bind(this);#J=null;#Z=null;#q=0;#_=!1;#X=!1;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){if(this.name=this.getAttribute("name")||"segmented-control",!this.hasAttribute("role"))this.setAttribute("role","radiogroup");this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#j),this.#O(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#H(),this.#A(),v(this,()=>{this.#D({enforceFallback:!0}),this.#F(),this.#R({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#j),this.#J?.disconnect(),this.#J=null,this.#Z?.disconnect(),this.#Z=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#_=!1,this.#X=!1}get selectedSegment(){return this.#$}set selectedSegment(Q){let $=this.querySelectorAll("fig-segment");for(let J of $){let Z=J===Q,j=J.hasAttribute("selected");if(Z&&!j)J.setAttribute("selected","true");else if(!Z&&j)J.removeAttribute("selected")}this.#$=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#L(),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))}#K(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#Y(Q){let $=Q.getAttribute("value");if($!==null){let J=$.trim();if(J.length>0)return J}return Q.textContent?.trim()||""}#N(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if($.hasAttribute("selected"))return $;return null}#W(){return Array.from(this.querySelectorAll("fig-segment")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#L(){let Q=Array.from(this.querySelectorAll("fig-segment")),$=Q.find((J)=>J.hasAttribute("selected"));Q.forEach((J)=>{let Z=J.hasAttribute("disabled")&&J.getAttribute("disabled")!=="false",j=J===$;J.setAttribute("aria-checked",j?"true":"false"),J.setAttribute("tabindex",!Z&&j?"0":"-1")})}#G(Q){if(!Q)return;let $=this.selectedSegment,J=this.value;this.selectedSegment=Q;let Z=this.#Y(Q);if(Z)this.setAttribute("value",Z);else this.removeAttribute("value");let j=this.value;if($!==Q||J!==j)this.#K(j)}#U(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.#W();if(!$.length)return;let J=$.findIndex((q)=>q.hasAttribute("selected")),Z=J>=0?J:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),Z=Z>0?Z-1:$.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),Z=Z<$.length-1?Z+1:0;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;case" ":case"Enter":{let q=Q.target.closest("fig-segment");if(q&&this.contains(q))Q.preventDefault(),this.#G(q);return}default:return}let j=$[Z];this.#G(j),j.focus(),requestAnimationFrame(()=>{if(this.contains(j))j.focus()})}#B(Q){let $=String(Q??"").trim();if(!$)return!1;let J=this.querySelectorAll("fig-segment");for(let Z of J){let j=this.#Y(Z);if(!j)continue;if(j===$)return this.selectedSegment=Z,!0}return!1}#M(){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.#_=this.#_||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let $=this.#_;this.#_=!1,this.#z({forceInstant:$})})}#z({forceInstant:Q=!1}={}){let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#M(),Z=this.#$&&this.contains(this.#$)?this.#$:this.#N();if($||!J){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!J||$)this.#X=!1;return}if(!Z){if(this.#X)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=Z.getBoundingClientRect();if(j.width<=0||q.width<=0){if(this.#X)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.#X||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#X=!0}#A(){this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#R()}),this.#F()}#F(){if(!this.#Z)return;this.#Z.disconnect(),this.#Z.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#Z?.observe(Q)})}#D({enforceFallback:Q=!1}={}){let $=this.querySelectorAll("fig-segment");if($.length===0){this.#$=null,this.#R({forceInstant:!0});return}let J=this.getAttribute("value"),Z=J?.trim()??"";if(J!==null){if(Z!==J){this.setAttribute("value",Z);return}if(Z&&this.#B(Z))return}let j=this.#N();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=$[0]}#H(){this.#J?.disconnect(),this.#J=new MutationObserver((Q)=>{let $=!1;for(let J of Q){if(J.type==="childList"){$=!0;break}if(J.type==="attributes"&&J.target instanceof HTMLElement&&J.target.tagName.toLowerCase()==="fig-segment"&&(J.attributeName==="value"||J.attributeName==="selected")){$=!0;break}if(J.type==="characterData"){$=!0;break}}if($)this.#O(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#F(),this.#D({enforceFallback:!0}),this.#L()}),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 $=Q.target.closest("fig-segment");if(!$||!this.contains($))return;this.#G($)}#O(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach(($)=>{if(Q)$.setAttribute("disabled",""),$.setAttribute("aria-disabled","true");else $.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#L()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="disabled"){this.#O(J!==null&&J!=="false"),this.#R({forceInstant:!0});return}if(Q==="value"){this.#D({enforceFallback:!1});return}if(Q==="animated"){if(!this.#M())this.#X=!1;this.#R({forceInstant:!0});return}if(Q==="sizing")this.#R({forceInstant:!0})}}customElements.define("fig-segmented-control",S0);class f0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#$="segments";#Q=0;#j=null;#J=[];#Z=null;#q=!1;#_(Q){let $=Q?.detail;if(typeof $==="string")return $;let J=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if(J===null||J===void 0)return null;return String(J)}#X(){if(this.#J.length===0)return!1;let Q=this.querySelector(":scope > fig-segmented-control");if(Q){let J=Q.querySelectorAll("fig-segment");if(J.length!==this.#J.length)return!1;return Array.from(J).every((Z,j)=>Z.getAttribute("value")===this.#J[j])}let $=this.querySelector(":scope > fig-dropdown");if($){let J=$.querySelectorAll("option");return J.length===this.#J.length&&Array.from(J).every((Z,j)=>Z.textContent?.trim()===this.#J[j])}return!1}#K(){let Q=this.querySelector(":scope > fig-segmented-control");if(Q)this.#Z=Q,this.#$="segments";else this.#Z=this.querySelector(":scope > fig-dropdown"),this.#$="dropdown";this.#G()}connectedCallback(){if(this.#Y(),this.#X()){this.#K(),this.#B(),v(this,()=>v(this,()=>this.#z()));return}this.#N(),this.#B(),v(this,()=>v(this,()=>this.#z()))}disconnectedCallback(){this.#j?.disconnect(),this.#j=null}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get options(){return this.#J.slice()}set options(Q){if(Array.isArray(Q)){let J=Q.some((Z)=>String(Z).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",J)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="options"){this.#Y(),this.#L();return}if(Q==="value"){this.#G();return}if(Q==="disabled"){this.#U("disabled");return}if(Q==="full"){this.#U("full");return}if(Q==="sizing")this.#U("sizing"),this.#L()}#Y(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#J=JSON.parse(Q);return}catch{}let $=Q.includes(`
38
38
  `)?`
39
- `:",";this.#J=Q.split($).map((J)=>J.trim()).filter(Boolean)}#K(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-segmented-control");if(Q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),this.hasAttribute("disabled"))Q.setAttribute("disabled","");if(this.hasAttribute("full"))Q.setAttribute("full","");let $=this.getAttribute("value");for(let J of this.#J){let Z=document.createElement("fig-segment");if(Z.setAttribute("value",J),Z.textContent=J,$===J)Z.setAttribute("selected","true");Q.appendChild(Z)}if($)Q.setAttribute("value",$);Q.addEventListener("input",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(Z===null)return;this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(Z===null)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#Z=Q,this.#$="segments"}#Y(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-dropdown");if(this.hasAttribute("disabled"))Q.setAttribute("disabled","");let $=this.getAttribute("value");for(let J of this.#J){let Z=document.createElement("option");if(Z.value=J,Z.textContent=J,$===J)Z.selected=!0;Q.appendChild(Z)}if($)Q.setAttribute("value",$);Q.addEventListener("input",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(!Z)return;this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(!Z)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#Z=Q,this.#$="dropdown"}#W(){if(this.#$==="segments")this.#K(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#G())});else this.#Y()}#N(){if(!this.#Z||this.#q)return;let Q=this.getAttribute("value")||"";this.#Z.value=Q}#L(Q){if(!this.#Z)return;if(this.hasAttribute(Q))this.#Z.setAttribute(Q,this.getAttribute(Q)||"");else this.#Z.removeAttribute(Q)}#U(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#G()}),this.#j.observe(this)}#B(Q){let $=document.createRange();$.selectNodeContents(Q);let J=$.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,q=getComputedStyle(Q),_=parseFloat(q.paddingLeft)||0,X=parseFloat(q.paddingRight)||0,Y=j-_-X;return J>Y+0.5}#M(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if(this.#B($))return!0;return!1}#G(){if(this.#J.length<=1)return;if(this.#$==="segments"){let Q=this.#Z;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#M())this.#Q=this.clientWidth,this.#Y()}else if(this.#Q>0&&this.clientWidth>=this.#Q)this.#K(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#Z;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#M())this.#Y()})})}}customElements.define("fig-options",S0);class f0 extends HTMLElement{#$=!1;#Q=!1;#j=!1;#J="";#Z=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#q={range:{min:0,max:100,step:1},hue:{min:0,max:255,step:1},delta:{min:-100,max:100,step:1},stepper:{min:0,max:100,step:25},opacity:{min:0,max:100,step:0.1,color:"#FF0000"}};#_;#X;#K;#Y;#W;#N;#L;#U=null;#B=null;#M=null;constructor(){super();this.initialInnerHTML=this.innerHTML,this.#_=(Q)=>{Q.stopPropagation(),this.#P()},this.#X=(Q)=>{Q.stopPropagation(),this.#S()},this.#W=(Q)=>{this.#f(Q)},this.#K=(Q)=>{Q.stopPropagation(),this.#A()},this.#Y=(Q)=>{Q.stopPropagation(),this.#I()},this.#N=()=>{this.#$=!0},this.#L=()=>{this.#$=!1}}#G(){let Q=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.getAttribute("text")!=="false",this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.getAttribute("disabled")?!0:!1,this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";let $=this.#q[this.type];if(this.min=Number(this.getAttribute("min")||$.min),this.max=Number(this.getAttribute("max")||$.max),this.step=Number(this.getAttribute("step")||$.step),this.color=this.getAttribute("color")||$?.color,this.default=this.hasAttribute("default")?this.getAttribute("default"):this.type==="delta"?0:this.min,this.#Q=this.type!=="range"&&(Q===null||typeof Q==="string"&&Q.trim()===""),this.value=this.#z(Q),this.color)this.style.setProperty("--color",this.color);let J="",Z=`<div class="fig-slider-input-container" role="group">
39
+ `:",";this.#J=Q.split($).map((J)=>J.trim()).filter(Boolean)}#N(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-segmented-control");if(Q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),this.hasAttribute("disabled"))Q.setAttribute("disabled","");if(this.hasAttribute("full"))Q.setAttribute("full","");let $=this.getAttribute("value");for(let J of this.#J){let Z=document.createElement("fig-segment");if(Z.setAttribute("value",J),Z.textContent=J,$===J)Z.setAttribute("selected","true");Q.appendChild(Z)}if($)Q.setAttribute("value",$);Q.addEventListener("input",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(Z===null)return;this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(Z===null)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#Z=Q,this.#$="segments"}#W(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-dropdown");if(this.hasAttribute("disabled"))Q.setAttribute("disabled","");let $=this.getAttribute("value");for(let J of this.#J){let Z=document.createElement("option");if(Z.value=J,Z.textContent=J,$===J)Z.selected=!0;Q.appendChild(Z)}if($)Q.setAttribute("value",$);Q.addEventListener("input",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(!Z)return;this.#q=!0,this.setAttribute("value",Z),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}),Q.addEventListener("change",(J)=>{if(J.stopPropagation(),this.#q)return;let Z=this.#_(J);if(!Z)return;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#Z=Q,this.#$="dropdown"}#L(){if(this.#$==="segments")this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#z())});else this.#W()}#G(){if(!this.#Z||this.#q)return;let Q=this.getAttribute("value")||"";this.#Z.value=Q}#U(Q){if(!this.#Z)return;if(this.hasAttribute(Q))this.#Z.setAttribute(Q,this.getAttribute(Q)||"");else this.#Z.removeAttribute(Q)}#B(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#z()}),this.#j.observe(this)}#M(Q){let $=document.createRange();$.selectNodeContents(Q);let J=$.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,q=getComputedStyle(Q),_=parseFloat(q.paddingLeft)||0,X=parseFloat(q.paddingRight)||0,Y=j-_-X;return J>Y+0.5}#R(){let Q=this.querySelectorAll("fig-segment");for(let $ of Q)if(this.#M($))return!0;return!1}#z(){if(this.#J.length<=1)return;if(this.#$==="segments"){let Q=this.#Z;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#R())this.#Q=this.clientWidth,this.#W()}else if(this.#Q>0&&this.clientWidth>=this.#Q)this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#Z;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#R())this.#W()})})}}customElements.define("fig-options",f0);class I0 extends HTMLElement{#$=!1;#Q=!1;#j=!1;#J="";#Z=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#q={range:{min:0,max:100,step:1},hue:{min:0,max:255,step:1},delta:{min:-100,max:100,step:1},stepper:{min:0,max:100,step:25},opacity:{min:0,max:100,step:0.1,color:"#FF0000"}};#_;#X;#K;#Y;#N;#W;#L;#G=null;#U=null;#B=null;constructor(){super();this.initialInnerHTML=this.innerHTML,this.#_=(Q)=>{Q.stopPropagation(),this.#b()},this.#X=(Q)=>{Q.stopPropagation(),this.#V()},this.#N=(Q)=>{this.#y(Q)},this.#K=(Q)=>{Q.stopPropagation(),this.#D()},this.#Y=(Q)=>{Q.stopPropagation(),this.#w()},this.#W=()=>{this.#$=!0},this.#L=()=>{this.#$=!1}}#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.getAttribute("disabled")?!0:!1,this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";let $=this.#q[this.type];this.min=Number(this.getAttribute("min")||$.min),this.max=Number(this.getAttribute("max")||$.max),this.step=Number(this.getAttribute("step")||$.step),this.color=this.getAttribute("color")||$?.color,this.default=this.hasAttribute("default")?this.getAttribute("default"):this.type==="delta"?0:this.min,this.#Q=this.type!=="range"&&(Q===null||typeof Q==="string"&&Q.trim()===""),this.value=this.#P(Q)}#R(){if(!this.querySelector("[type=range]"))return!1;return this.getAttribute("text")!=="false"===!!this.querySelector("fig-input-number")}#z(){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.#Q?"":String(this.value)),this.units)this.figInputNumber.setAttribute("units",this.units);else this.figInputNumber.removeAttribute("units");if(this.precision!==null)this.figInputNumber.setAttribute("precision",String(this.precision));else this.figInputNumber.removeAttribute("precision");this.figInputNumber.disabled=this.disabled,this.figInputNumber.toggleAttribute("disabled",this.disabled)}}#A(){if(this.#C(),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.#N),this.input.addEventListener("keydown",this.#N),this.input.removeEventListener("pointerdown",this.#W),this.input.addEventListener("pointerdown",this.#W),this.input.removeEventListener("pointerup",this.#L),this.input.addEventListener("pointerup",this.#L),this.default)this.style.setProperty("--default",this.#H(this.default));if(this.figInputNumber)this.#x(),this.figInputNumber.removeEventListener("input",this.#K),this.figInputNumber.addEventListener("input",this.#K),this.figInputNumber.removeEventListener("change",this.#Y),this.figInputNumber.addEventListener("change",this.#Y)}#F(){if(this.#M(),this.color)this.style.setProperty("--color",this.color);let Q="",$=`<div class="fig-slider-input-container" role="group">
40
40
  <input
41
41
  type="range"
42
42
  ${this.text?'tabindex="-1"':""}
@@ -50,7 +50,7 @@ var B1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var O1={};var G0=B1(()=>{/*! Vendored from @
50
50
  aria-valuemax="${this.max}"
51
51
  aria-valuenow="${this.value}">
52
52
  ${this.initialInnerHTML}
53
- </div>`;if(this.text)J=`${Z}
53
+ </div>`;if(this.text)Q=`${$}
54
54
  <fig-input-number
55
55
  placeholder="${this.placeholder}"
56
56
  min="${this.min}"
@@ -60,17 +60,17 @@ var B1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var O1={};var G0=B1(()=>{/*! Vendored from @
60
60
  value="${this.#Q?"":this.value}"
61
61
  ${this.units?`units="${this.units}"`:""}
62
62
  ${this.precision!==null?`precision="${this.precision}"`:""}>
63
- </fig-input-number>`;else J=Z;if(this.innerHTML=J,this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.#T(),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.#W),this.input.addEventListener("keydown",this.#W),this.input.removeEventListener("pointerdown",this.#N),this.input.addEventListener("pointerdown",this.#N),this.input.removeEventListener("pointerup",this.#L),this.input.addEventListener("pointerup",this.#L),this.default)this.style.setProperty("--default",this.#D(this.default));if(this.datalist=this.querySelector("datalist"),this.figInputNumber=this.querySelector("fig-input-number"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||y()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",y());let j=(this.max-this.min)/this.step+1;for(let q=0;q<j;q++){let _=document.createElement("option");_.setAttribute("value",this.min+q*this.step),this.datalist.append(_)}this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.type==="delta"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",y());let j=document.createElement("option");j.setAttribute("value",this.default),this.datalist.append(j),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let j=this.datalist.querySelector(`option[value='${this.default}']`);if(j)j.setAttribute("default","true")}if(this.figInputNumber)this.#E(),this.figInputNumber.removeEventListener("input",this.#K),this.figInputNumber.addEventListener("input",this.#K),this.figInputNumber.removeEventListener("change",this.#Y),this.figInputNumber.addEventListener("change",this.#Y);this.#k()}connectedCallback(){this.#G()}get value(){if(this.#J!=="")return this.#J;let Q=this.getAttribute("value");if(Q!==null)return String(this.#z(Q));return""}set value(Q){let $=Q===null||Q===void 0?"":String(Q),Z=this.min!==void 0||this.max!==void 0?String(this.#z($)):$;if(this.#J=Z,this.getAttribute("value")!==Z)this.#j=!0,this.setAttribute("value",Z),this.#j=!1;if(this.input&&this.input.value!==Z)this.input.value=Z,this.input.setAttribute("aria-valuenow",Z);if(this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Z);if(this.input)this.#C()}disconnectedCallback(){if(this.input)this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#X),this.input.removeEventListener("keydown",this.#W),this.input.removeEventListener("pointerdown",this.#N),this.input.removeEventListener("pointerup",this.#L);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#K),this.figInputNumber.removeEventListener("change",this.#Y)}#A(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#z(Q);this.value=$,this.input.value=String($),this.#k(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#D(Q){let{min:$,max:J}=this.#H(),Z=J-$;if(Z===0)return 0;return(Number(Q)-$)/Z}#O(Q){if(Q===null||Q===void 0)return null;if(typeof Q==="string"&&Q.trim()==="")return null;let $=Number(Q);return Number.isFinite($)?$:null}#H(){let Q=this.#O(this.min),$=this.#O(this.max);if(Q===null)Q=0;if($===null)$=Q;if(Q>$)[Q,$]=[$,Q];return{min:Q,max:$}}#R(Q){let{min:$,max:J}=this.#H();return Math.min(J,Math.max($,Q))}#F(){if(this.type==="delta"){let $=this.#O(this.default);if($!==null)return this.#R($);return this.#R(0)}if(this.type==="range"){let{min:$,max:J}=this.#H();return this.#R($+(J-$)/2)}let{min:Q}=this.#H();return Q}#z(Q){let $=this.#O(Q);if($===null)return this.#F();return this.#R($)}#C(){let Q=this.#D(this.value),$=this.#D(this.default),J=Q===$?1:0;if(this.#U!==Q)this.style.setProperty("--slider-complete",Q),this.#U=Q;if(this.#B!==$)this.style.setProperty("--default",$),this.#B=$;if(this.#M!==J)this.style.setProperty("--unchanged",J),this.#M=J}#k(){let Q=this.input.value;if(this.value=Q,this.#C(),this.input.setAttribute("aria-valuenow",Q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Q)}#T(){if(!this.input)return;if(this.text){this.input.setAttribute("aria-hidden","true"),["aria-label","aria-labelledby","aria-describedby","aria-valuetext"].forEach((Q)=>this.input.removeAttribute(Q)),this.#E();return}this.input.removeAttribute("aria-hidden"),this.#Z.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,$)})}#E(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.figInputNumber.removeAttribute(Q);else this.figInputNumber.setAttribute(Q,$)})}#P(){this.#Q=!1,this.#k(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#S(){this.#$=!1,this.#Q=!1,this.#k(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#f(Q){if(this.disabled||!Q.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Q.key))return;Q.preventDefault(),this.#Q=!1;let $=Q.key==="ArrowRight"||Q.key==="ArrowUp"?1:-1,J=this.#O(this.input.value)??this.#F(),Z=this.#O(this.step)??1,j=this.#z(J+Z*10*$);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}))}#I(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#z(Q);this.value=$,this.input.value=String($),this.#k(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"]}focus(){if(this.text&&this.figInputNumber){this.figInputNumber.focus();return}this.input.focus()}attributeChangedCallback(Q,$,J){if(Q==="value"&&this.#j)return;if(this.input)switch(Q){case"color":this.color=J,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=J!==null&&J!=="false",this.figInputNumber)this.figInputNumber.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#$)break;if(this.#Q=J===null||typeof J==="string"&&J.trim()==="",this.value=this.#z(J),this.input.value=String(this.value),this.#k(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":this.value);break;case"transform":if(this.transform=Number(J)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=J!==null?Number(J):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=J!==null?J:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=J!==null?J:this.type==="delta"?0:this.min,this.#C();break;case"min":case"max":case"step":case"type":case"variant":case"units":this[Q]=J,this.#G();break;case"text":this.text=J!=="false",this.#G();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#T();break;default:this[Q]=this.input[Q]=J,this.#k();break}}}customElements.define("fig-slider",f0);class I0 extends HTMLElement{#$=!1;#Q=!1;#j;#J;#Z;#q;#_;#X;#K;#Y=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#j=this.#D.bind(this),this.#J=this.#H.bind(this),this.#Z=this.#H.bind(this),this.#q=this.#O.bind(this),this.#_=(Q)=>{Q.stopPropagation(),this.#A(Q)},this.#X=()=>{this.#U()},this.#K=this.focus.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")||!1,this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}let Q=`<input
63
+ </fig-input-number>`;else Q=$;if(this.innerHTML=Q,this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.#A(),this.datalist=this.querySelector("datalist"),this.figInputNumber=this.querySelector("fig-input-number"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||y()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",y());let J=(this.max-this.min)/this.step+1;for(let Z=0;Z<J;Z++){let j=document.createElement("option");j.setAttribute("value",this.min+Z*this.step),this.datalist.append(j)}this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.type==="delta"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",y());let J=document.createElement("option");J.setAttribute("value",this.default),this.datalist.append(J),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let J=this.datalist.querySelector(`option[value='${this.default}']`);if(J)J.setAttribute("default","true")}this.#T()}connectedCallback(){if(this.#R()){this.#z(),this.#A(),this.#T();return}this.#F()}get value(){if(this.#J!=="")return this.#J;let Q=this.getAttribute("value");if(Q!==null)return String(this.#P(Q));return""}set value(Q){let $=Q===null||Q===void 0?"":String(Q),Z=this.min!==void 0||this.max!==void 0?String(this.#P($)):$;if(this.#J=Z,this.getAttribute("value")!==Z)this.#j=!0,this.setAttribute("value",Z),this.#j=!1;if(this.input&&this.input.value!==Z)this.input.value=Z,this.input.setAttribute("aria-valuenow",Z);if(this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Z);if(this.input)this.#E()}disconnectedCallback(){if(this.input)this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#X),this.input.removeEventListener("keydown",this.#N),this.input.removeEventListener("pointerdown",this.#W),this.input.removeEventListener("pointerup",this.#L);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#K),this.figInputNumber.removeEventListener("change",this.#Y)}#D(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#P(Q);this.value=$,this.input.value=String($),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#H(Q){let{min:$,max:J}=this.#k(),Z=J-$;if(Z===0)return 0;return(Number(Q)-$)/Z}#O(Q){if(Q===null||Q===void 0)return null;if(typeof Q==="string"&&Q.trim()==="")return null;let $=Number(Q);return Number.isFinite($)?$:null}#k(){let Q=this.#O(this.min),$=this.#O(this.max);if(Q===null)Q=0;if($===null)$=Q;if(Q>$)[Q,$]=[$,Q];return{min:Q,max:$}}#S(Q){let{min:$,max:J}=this.#k();return Math.min(J,Math.max($,Q))}#f(){if(this.type==="delta"){let $=this.#O(this.default);if($!==null)return this.#S($);return this.#S(0)}if(this.type==="range"){let{min:$,max:J}=this.#k();return this.#S($+(J-$)/2)}let{min:Q}=this.#k();return Q}#P(Q){let $=this.#O(Q);if($===null)return this.#f();return this.#S($)}#E(){let Q=this.#H(this.value),$=this.#H(this.default),J=Q===$?1:0;if(this.#G!==Q)this.style.setProperty("--slider-complete",Q),this.#G=Q;if(this.#U!==$)this.style.setProperty("--default",$),this.#U=$;if(this.#B!==J)this.style.setProperty("--unchanged",J),this.#B=J}#T(){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?"":Q)}#C(){if(!this.input)return;if(this.text){this.input.setAttribute("aria-hidden","true"),["aria-label","aria-labelledby","aria-describedby","aria-valuetext"].forEach((Q)=>this.input.removeAttribute(Q)),this.#x();return}this.input.removeAttribute("aria-hidden"),this.#Z.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,$)})}#x(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.figInputNumber.removeAttribute(Q);else this.figInputNumber.setAttribute(Q,$)})}#b(){this.#Q=!1,this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#V(){this.#$=!1,this.#Q=!1,this.#T(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#y(Q){if(this.disabled||!Q.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Q.key))return;Q.preventDefault(),this.#Q=!1;let $=Q.key==="ArrowRight"||Q.key==="ArrowUp"?1:-1,J=this.#O(this.input.value)??this.#f(),Z=this.#O(this.step)??1,j=this.#P(J+Z*10*$);this.value=j,this.input.value=String(j),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#w(){if(this.figInputNumber){let Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";let $=this.#P(Q);this.value=$,this.input.value=String($),this.#T(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"]}focus(){if(this.text&&this.figInputNumber){this.figInputNumber.focus();return}this.input.focus()}attributeChangedCallback(Q,$,J){if(Q==="value"&&this.#j)return;if(this.input)switch(Q){case"color":this.color=J,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=J!==null&&J!=="false",this.figInputNumber)this.figInputNumber.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#$)break;if(this.#Q=J===null||typeof J==="string"&&J.trim()==="",this.value=this.#P(J),this.input.value=String(this.value),this.#T(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":this.value);break;case"transform":if(this.transform=Number(J)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=J!==null?Number(J):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=J!==null?J:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=J!==null?J:this.type==="delta"?0:this.min,this.#E();break;case"min":case"max":case"step":case"type":case"variant":case"units":this[Q]=J,this.#F();break;case"text":this.text=J!=="false",this.#F();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#C();break;default:this[Q]=this.input[Q]=J,this.#T();break}}}customElements.define("fig-slider",I0);class x0 extends HTMLElement{#$=!1;#Q=!1;#j;#J;#Z;#q;#_;#X;#K;#Y=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#j=this.#A.bind(this),this.#J=this.#D.bind(this),this.#Z=this.#D.bind(this),this.#q=this.#F.bind(this),this.#_=(Q)=>{Q.stopPropagation(),this.#z(Q)},this.#X=()=>{this.#U()},this.#K=this.focus.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")||!1,this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}if(this.input=this.#N(),this.input.readOnly=this.readonly,this.#W(),this.#L(),this.#G(),this.#U(),this.#B(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#R(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#R(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#R(this.step));this.addEventListener("pointerdown",this.#q)}this.input.removeEventListener("change",this.#_),this.input.addEventListener("change",this.#_),this.input.removeEventListener("input",this.#X),this.input.addEventListener("input",this.#X)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#_),this.input.removeEventListener("input",this.#X);this.removeEventListener("pointerdown",this.#q),window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#Z)}focus(){this.input.focus()}#N(){let Q=this.multiline,$=this.querySelector("input,textarea");if($){if(Q?$.tagName==="TEXTAREA":$.tagName==="INPUT")return $}let J=`<input
64
64
  type="${this.type}"
65
65
  ${this.name?`name="${this.name}"`:""}
66
66
  placeholder="${this.placeholder}"
67
- value="${this.type==="number"?this.#G(this.value):this.value}" />`;if(this.multiline)Q=`<textarea
68
- placeholder="${this.placeholder}">${this.value}</textarea>`;let $=this.querySelector("[slot=append]"),J=this.querySelector("[slot=prepend]");if(this.innerHTML=Q,J)J.removeEventListener("click",this.#K),J.addEventListener("click",this.#K),this.prepend(J);if($)$.removeEventListener("click",this.#K),$.addEventListener("click",this.#K),this.append($);if(this.input=this.querySelector("input,textarea"),this.input.readOnly=this.readonly,this.#W(),this.#N(),this.#L(),this.#U(),this.#B(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#G(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#G(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#G(this.step));this.addEventListener("pointerdown",this.#q)}this.input.removeEventListener("change",this.#_),this.input.addEventListener("change",this.#_),this.input.removeEventListener("input",this.#X),this.input.addEventListener("input",this.#X)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#_),this.input.removeEventListener("input",this.#X);this.removeEventListener("pointerdown",this.#q),window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#Z)}focus(){this.input.focus()}#W(){if(!this.input)return;this.#Y.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,$)})}#N(){let Q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="prepend"]');if($&&$!==Q)return;if(Q)return;let J=v("search");J.setAttribute("slot","prepend"),J.setAttribute("data-generated","search-prefix"),J.setAttribute("color","var(--figma-color-icon)"),J.addEventListener("click",this.focus.bind(this)),this.prepend(J)}#L(){let Q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q)return;let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","search-clear");let Z=document.createElement("fig-tooltip");Z.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=v("",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),q.style.setProperty("--icon","var(--icon-16-close)"),j.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),!this.input||this.input.value===""){this.focus();return}this.value="",this.input.value="",this.dispatchEvent(new CustomEvent("input",{detail:"",bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:"",bubbles:!0})),this.#U(),this.focus()})}#U(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#B(){let Q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){Q?.remove(),this.#Q=!1;return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q){this.#M(Q);return}let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","password-toggle");let Z=document.createElement("fig-tooltip"),j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon","");let q=v("visible",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),this.#M(J),j.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),this.#Q=!this.#Q,this.input)this.input.type=this.#Q?"text":"password";this.#M(J),this.focus()})}#M(Q){let $=Q.querySelector("fig-tooltip"),J=Q.querySelector("fig-button"),Z=Q.querySelector("fig-icon"),j=this.#Q?"Hide password":"Show password";$?.setAttribute("text",j),J?.setAttribute("aria-label",j),Z?.setAttribute("name",this.#Q?"visible":"hidden")}#G(Q){if(Q==="")return"";let $=Number(Q)*(this.transform||1);return $=this.#F($),$}#A(Q){Q.stopPropagation();let $=Q.target.value,J=$;if(this.type==="number")$=$/(this.transform||1),$=this.#R($,!1),J=$*(this.transform||1);this.value=$,this.input.value=J,this.#U(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#D(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#H();return}let $=(this.step||1)*Q.movementX,J=Number(this.input.value);J=J/(this.transform||1)+$,J=this.#R(J,!1);let Z=J*(this.transform||1);J=this.#F(J),Z=this.#F(Z),this.value=J,this.input.value=Z,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#O(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#$=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#j),window.addEventListener("pointerup",this.#J),window.addEventListener("blur",this.#Z)}#H(Q){if(this.type!=="number")return;this.#$=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#Z)}#R(Q,$=!0){let J=Q;if(this.type==="number"){if(J=Number(J),typeof this.min==="number")J=Math.max($?this.#G(this.min):this.min,J);if(typeof this.max==="number")J=Math.min($?this.#G(this.max):this.max,J);J=this.#F(J)}return J}#F(Q,$=2){let J=Math.round(Q*100)/100;return Number.isInteger(J)?J:J.toFixed($)}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","step","min","max","transform","name","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false";break;case"readonly":this.readonly=J!==null&&J!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number(J)||1,this.input.value=this.#G(this.value);break;case"value":if(this.#$)break;let Z=J;if(this.type==="number")Z=this.#R(Z,!1),this.value=Z,this.input.value=this.#G(Z);else this.value=Z,this.input.value=Z;this.#U();break;case"min":case"max":case"step":if(this[Q]=this.input[Q]=Number(J),this.input)this.input.setAttribute(Q,J);break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;case"type":this.type=J||"text",this.input.type=this.type,this.#N(),this.#L(),this.#U(),this.#B();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#W();break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-text",I0);class a extends HTMLElement{#$;#Q;#j;#J;#Z;#q;#_;#X;#K;#Y;#W;#N;#L;#U;#B;#M=!1;#G=null;#A=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#D="px";#O(Q){return(Q||"").split(",").map(($)=>$.trim().toLowerCase()).filter(Boolean)}#H(Q){let $=(Q||"").trim();if(!$)return"";return(this.#L??[]).includes($.toLowerCase())?"":$}#R(){this.#W=this.#H(this.#N)}#F(Q){if(Q&&!this.#G)this.#G=document.createElement("span"),this.#G.className="fig-steppers",this.#G.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#G.addEventListener("pointerdown",($)=>{$.preventDefault(),$.stopPropagation();let J=$.target.closest("button");if(!J||this.disabled||J.disabled)return;let Z=J.classList.contains("fig-stepper-up")?1:-1;this.#C(Z),this.input.focus()}),this.append(this.#G);else if(!Q&&this.#G)this.#G.remove(),this.#G=null;this.#z()}#z(){if(!this.#G)return;let Q=this.#G.querySelector(".fig-stepper-up"),$=this.#G.querySelector(".fig-stepper-down");if(!Q||!$)return;let J=this.input?this.#E(this.input.value):this.value,Z=J!==""&&J!==null&&J!==void 0?Number(J)/(this.transform||1):Number(this.value),j=Number.isFinite(Z),q=Boolean(this.disabled),_=j&&typeof this.min==="number"&&Z<=this.min,X=j&&typeof this.max==="number"&&Z>=this.max;Q.disabled=q||X,$.disabled=q||_}#C(Q){let $=this.step||1,J=this.#E(this.input.value),Z=(J!==""?Number(J)/(this.transform||1):0)+$*Q;Z=this.#h(Z,!1),this.value=Z,this.input.value=this.#P(this.value),this.#z(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#$=this.#b.bind(this),this.#Q=this.#v.bind(this),this.#j=this.#v.bind(this),this.#J=this.#g.bind(this),this.#Z=(Q)=>{Q.stopPropagation(),this.#y(Q)},this.#q=(Q)=>{Q.stopPropagation(),this.#V(Q)},this.#_=(Q)=>{this.#f(Q)},this.#X=(Q)=>{this.#I(Q)},this.#K=(Q)=>{this.#w(Q)},this.#Y=this.focus.bind(this)}connectedCallback(){let Q=this.getAttribute("value");this.value=Q!==null&&Q!==""?Number(Q):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#N=this.getAttribute("units")||"";let $=this.getAttribute("units-disallow");if(this.#L=this.#O($===null?a.#D:$),this.#R(),this.#U=this.getAttribute("unit-position")||"suffix",this.#B=this.hasAttribute("precision")?Number(this.getAttribute("precision")):2,this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));this.transform=Number(this.getAttribute("transform")||1);let J=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false",Z=`<input
67
+ value="${this.type==="number"?this.#R(this.value):this.value}" />`;if(Q)J=`<textarea
68
+ placeholder="${this.placeholder}">${this.value}</textarea>`;let Z=this.querySelector("[slot=append]"),j=this.querySelector("[slot=prepend]");if(this.innerHTML=J,j)j.removeEventListener("click",this.#K),j.addEventListener("click",this.#K),this.prepend(j);if(Z)Z.removeEventListener("click",this.#K),Z.addEventListener("click",this.#K),this.append(Z);return this.querySelector("input,textarea")}#W(){if(!this.input)return;this.#Y.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,$)})}#L(){let Q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="prepend"]');if($&&$!==Q)return;if(Q){let Z=Q.querySelector("fig-icon");if(Z&&Z.getAttribute("name")!=="search")Z.setAttribute("name","search");return}let J=h("search");J.setAttribute("slot","prepend"),J.setAttribute("data-generated","search-prefix"),J.setAttribute("color","var(--figma-color-icon)"),J.addEventListener("click",this.#K),this.prepend(J)}#G(){let Q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){Q?.remove();return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q){let _=Q.querySelector("fig-icon");if(_&&_.getAttribute("name")!=="close")_.setAttribute("name","close");return}let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","search-clear");let Z=document.createElement("fig-tooltip");Z.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=h("close",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),j.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),!this.input||this.input.value===""){this.focus();return}this.value="",this.input.value="",this.dispatchEvent(new CustomEvent("input",{detail:"",bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:"",bubbles:!0})),this.#U(),this.focus()})}#U(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#B(){let Q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){Q?.remove(),this.#Q=!1;return}let $=this.querySelector('[slot="append"]');if($&&$!==Q)return;if(Q){this.#M(Q);return}let J=document.createElement("span");J.setAttribute("slot","append"),J.setAttribute("data-generated","password-toggle");let Z=document.createElement("fig-tooltip"),j=document.createElement("fig-button");j.setAttribute("variant","ghost"),j.setAttribute("icon","");let q=h("visible",{size:"small"});q.setAttribute("color","var(--figma-color-icon-secondary)"),j.append(q),Z.append(j),J.append(Z),this.append(J),this.#M(J),j.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),this.#Q=!this.#Q,this.input)this.input.type=this.#Q?"text":"password";this.#M(J),this.focus()})}#M(Q){let $=Q.querySelector("fig-tooltip"),J=Q.querySelector("fig-button"),Z=Q.querySelector("fig-icon"),j=this.#Q?"Hide password":"Show password";$?.setAttribute("text",j),J?.setAttribute("aria-label",j),Z?.setAttribute("name",this.#Q?"visible":"hidden")}#R(Q){if(Q==="")return"";let $=Number(Q)*(this.transform||1);return $=this.#O($),$}#z(Q){Q.stopPropagation();let $=Q.target.value,J=$;if(this.type==="number")$=$/(this.transform||1),$=this.#H($,!1),J=$*(this.transform||1);this.value=$,this.input.value=J,this.#U(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#A(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#D();return}let $=(this.step||1)*Q.movementX,J=Number(this.input.value);J=J/(this.transform||1)+$,J=this.#H(J,!1);let Z=J*(this.transform||1);J=this.#O(J),Z=this.#O(Z),this.value=J,this.input.value=Z,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#F(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#$=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#j),window.addEventListener("pointerup",this.#J),window.addEventListener("blur",this.#Z)}#D(Q){if(this.type!=="number")return;this.#$=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#j),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#Z)}#H(Q,$=!0){let J=Q;if(this.type==="number"){if(J=Number(J),typeof this.min==="number")J=Math.max($?this.#R(this.min):this.min,J);if(typeof this.max==="number")J=Math.min($?this.#R(this.max):this.max,J);J=this.#O(J)}return J}#O(Q,$=2){let J=Math.round(Q*100)/100;return Number.isInteger(J)?J:J.toFixed($)}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","step","min","max","transform","name","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false";break;case"readonly":this.readonly=J!==null&&J!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number(J)||1,this.input.value=this.#R(this.value);break;case"value":if(this.#$)break;let Z=J;if(this.type==="number")Z=this.#H(Z,!1),this.value=Z,this.input.value=this.#R(Z);else this.value=Z,this.input.value=Z;this.#U();break;case"min":case"max":case"step":if(this[Q]=this.input[Q]=Number(J),this.input)this.input.setAttribute(Q,J);break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;case"type":this.type=J||"text",this.input.type=this.type,this.#L(),this.#G(),this.#U(),this.#B();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#W();break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-text",x0);class t extends HTMLElement{#$;#Q;#j;#J;#Z;#q;#_;#X;#K;#Y;#N;#W;#L;#G;#U;#B=!1;#M=null;#R=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#z="px";#A(Q){return(Q||"").split(",").map(($)=>$.trim().toLowerCase()).filter(Boolean)}#F(Q){let $=(Q||"").trim();if(!$)return"";return(this.#L??[]).includes($.toLowerCase())?"":$}#D(){this.#N=this.#F(this.#W)}#H(Q){if(Q&&!this.#M)this.#M=document.createElement("span"),this.#M.className="fig-steppers",this.#M.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#M.addEventListener("pointerdown",($)=>{$.preventDefault(),$.stopPropagation();let J=$.target.closest("button");if(!J||this.disabled||J.disabled)return;let Z=J.classList.contains("fig-stepper-up")?1:-1;this.#k(Z),this.input.focus()}),this.append(this.#M);else if(!Q&&this.#M)this.#M.remove(),this.#M=null;this.#O()}#O(){if(!this.#M)return;let Q=this.#M.querySelector(".fig-stepper-up"),$=this.#M.querySelector(".fig-stepper-down");if(!Q||!$)return;let J=this.input?this.#E(this.input.value):this.value,Z=J!==""&&J!==null&&J!==void 0?Number(J)/(this.transform||1):Number(this.value),j=Number.isFinite(Z),q=Boolean(this.disabled),_=j&&typeof this.min==="number"&&Z<=this.min,X=j&&typeof this.max==="number"&&Z>=this.max;Q.disabled=q||X,$.disabled=q||_}#k(Q){let $=this.step||1,J=this.#E(this.input.value),Z=(J!==""?Number(J)/(this.transform||1):0)+$*Q;Z=this.#I(Z,!1),this.value=Z,this.input.value=this.#T(this.value),this.#O(),this.#P(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#$=this.#h.bind(this),this.#Q=this.#v.bind(this),this.#j=this.#v.bind(this),this.#J=this.#g.bind(this),this.#Z=(Q)=>{Q.stopPropagation(),this.#w(Q)},this.#q=(Q)=>{Q.stopPropagation(),this.#y(Q)},this.#_=(Q)=>{this.#x(Q)},this.#X=(Q)=>{this.#b(Q)},this.#K=(Q)=>{this.#V(Q)},this.#Y=this.focus.bind(this)}connectedCallback(){let Q=this.getAttribute("value");this.value=Q!==null&&Q!==""?Number(Q):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#W=this.getAttribute("units")||"";let $=this.getAttribute("units-disallow");if(this.#L=this.#A($===null?t.#z:$),this.#D(),this.#G=this.getAttribute("unit-position")||"suffix",this.#U=this.hasAttribute("precision")?Number(this.getAttribute("precision")):2,this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));this.transform=Number(this.getAttribute("transform")||1);let J=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.input=this.#S(),this.#f(),this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.#H(J),this.hasAttribute("disabled")){let Z=this.getAttribute("disabled");this.disabled=this.input.disabled=Z!=="false"}this.#O(),this.#P(),this.addEventListener("pointerdown",this.#J),this.input.removeEventListener("change",this.#Z),this.input.addEventListener("change",this.#Z),this.input.removeEventListener("input",this.#q),this.input.addEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.addEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.addEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#K),this.input.addEventListener("keydown",this.#K)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#Z),this.input.removeEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#K);this.removeEventListener("pointerdown",this.#J),window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#j)}focus(){this.input.focus()}#S(){let Q=this.querySelector("input");if(Q)return Q;let $=`<input
69
69
  type="text"
70
70
  inputmode="decimal"
71
71
  ${this.name?`name="${this.name}"`:""}
72
72
  placeholder="${this.placeholder}"
73
- value="${this.#P(this.value)}" />`,j=this.querySelector("[slot=append]"),q=this.querySelector("[slot=prepend]");if(this.innerHTML=Z,q)q.removeEventListener("click",this.#Y),q.addEventListener("click",this.#Y),this.prepend(q);if(j)j.removeEventListener("click",this.#Y),j.addEventListener("click",this.#Y),this.append(j);if(this.input=this.querySelector("input"),this.#k(),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(J),this.hasAttribute("disabled")){let _=this.getAttribute("disabled");this.disabled=this.input.disabled=_!=="false"}this.#z(),this.#T(),this.addEventListener("pointerdown",this.#J),this.input.removeEventListener("change",this.#Z),this.input.addEventListener("change",this.#Z),this.input.removeEventListener("input",this.#q),this.input.addEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.addEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.addEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#K),this.input.addEventListener("keydown",this.#K)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#Z),this.input.removeEventListener("input",this.#q),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#K);this.removeEventListener("pointerdown",this.#J),window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#j)}focus(){this.input.focus()}#k(){if(!this.input)return;this.#A.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,$)})}#T(){if(!this.input)return;if(this.input.setAttribute("role","spinbutton"),typeof this.min==="number")this.input.setAttribute("aria-valuemin",String(this.min));else this.input.removeAttribute("aria-valuemin");if(typeof this.max==="number")this.input.setAttribute("aria-valuemax",String(this.max));else this.input.removeAttribute("aria-valuemax");let Q=this.value===""?null:Number(this.value);if(Number.isFinite(Q))this.input.setAttribute("aria-valuenow",String(Q)),this.input.setAttribute("aria-valuetext",this.#P(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#E(Q){if(!Q)return"";if(!this.#W){let Z=Q.replace(/[^\d.-]/g,""),j=Z.split(".");if(j.length>2)Z=j[0]+"."+j.slice(1).join("");return Z}let $=Q.replace(this.#W,"").trim();$=$.replace(/[^\d.-]/g,"");let J=$.split(".");if(J.length>2)$=J[0]+"."+J.slice(1).join("");return $}#P(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);if(isNaN($))return"";if($=this.#x($),!this.#W)return $.toString();if(this.#U==="prefix")return this.#W+$;else return $+this.#W}#S(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);return $=this.#x($),$.toString()}#f(Q){this.#M=!0,setTimeout(()=>{let $=Q.target.value;if($&&this.#W)if(this.#U==="prefix")Q.target.setSelectionRange(this.#W.length,$.length);else{let J=$.indexOf(this.#W);if(J>-1)Q.target.setSelectionRange(0,J)}},0)}#I(Q){this.#M=!1;let $=this.#E(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#h(J,!1),this.value=J,Q.target.value=this.#P(this.value)}else this.value="",Q.target.value="";this.#z(),this.#T(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#w(Q){if(this.disabled)return;if(Q.key!=="ArrowUp"&&Q.key!=="ArrowDown")return;Q.preventDefault();let $=this.step||1,J=Q.shiftKey?10:1,Z=$*J*(Q.key==="ArrowUp"?1:-1),j=this.#E(this.input.value),q=(j!==""?Number(j)/(this.transform||1):0)+Z;q=this.#h(q,!1),this.value=q,this.input.value=this.#P(this.value),this.#z(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#V(Q){let $=this.#E(Q.target.value);if($!=="")this.value=Number($)/(this.transform||1);else this.value="";this.#z(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#y(Q){Q.stopPropagation();let $=this.#E(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#h(J,!1),this.value=J,Q.target.value=this.#P(this.value)}else this.value="",Q.target.value="";this.#z(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#b(Q){if(this.disabled)return;if(Q.buttons===0){this.#v();return}let $=(this.step||1)*Q.movementX,J=this.#E(this.input.value),Z=Number(J)/(this.transform||1)+$;Z=this.#h(Z,!1),this.value=Z,this.input.value=this.#P(this.value),this.#z(),this.#T(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#g(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#M=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#$),window.addEventListener("pointerup",this.#Q),window.addEventListener("blur",this.#j)}#v(Q){this.#M=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#j)}#h(Q,$=!0){let J=Number(Q);if(isNaN(J))return"";if(typeof this.min==="number")J=Math.max(this.min,J);if(typeof this.max==="number")J=Math.min(this.max,J);return J=this.#x(J),J}#x(Q){let $=this.#B??2,J=Math.pow(10,$),Z=Math.round(Q*J)/J;return Number.isInteger(Z)?Z:parseFloat(Z.toFixed($))}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,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false",this.#z();break;case"units":this.#N=J||"",this.#R(),this.input.value=this.#P(this.value),this.#T();break;case"units-disallow":this.#L=this.#O(J===null?a.#D:J),this.#R(),this.input.value=this.#P(this.value),this.#T();break;case"unit-position":this.#U=J||"suffix",this.input.value=this.#P(this.value),this.#T();break;case"transform":this.transform=Number(J)||1,this.input.value=this.#P(this.value),this.#T();break;case"value":if(this.#M)break;let Z=J!==null&&J!==""?Number(J):"";if(Z!=="")Z=this.#h(Z,!1);this.value=Z,this.input.value=this.#P(this.value),this.#z(),this.#T();break;case"min":case"max":case"step":if(J===null||J===""){this[Q]=void 0,this.#z(),this.#T();break}this[Q]=Number(J),this.#z(),this.#T();break;case"steppers":{let j=J!==null&&J!=="false";this.#F(j);break}case"precision":this.#B=J!==null?Number(J):2,this.input.value=this.#P(this.value),this.#T();break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#k();break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-number",a);class x0 extends HTMLElement{constructor(){super()}connectedCallback(){this.src=this.getAttribute("src"),this.name=this.getAttribute("name"),this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials),this.setSrc(this.src),this.img=this.querySelector("img")}setSrc(Q){if(this.src=Q,Q)this.innerHTML=`<img src="${this.src}" ${this.name?`alt="${this.name}"`:""} />`}getInitials(Q){return Q?Q.split(" ").map(($)=>$[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(Q,$,J){if(this[Q]=J,Q==="name")this.img?.setAttribute("alt",J),this.name=J,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials);else if(Q==="src")this.src=J,this.setSrc(this.src)}}customElements.define("fig-avatar",x0);class V0 extends HTMLElement{#$=!1;#Q=null;#j=null;#J=null;#Z=null;#q=null;constructor(){super();this.#J=this.focus.bind(this),this.#Z=this.#X.bind(this),this.#q=this.#K.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(this.isConnected)this.#_()})}#_(){if(this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((Q)=>Q.nodeName.toLowerCase().startsWith("fig-")),this.#$=!!(this.input&&("open"in this.input)),this.#$&&this.label){if(!this.#Q||!this.#Q.isConnected)this.#Q=v("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#Q,this.label);this.#j=(Q)=>{if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open},this.#Q.addEventListener("click",this.#j),this.label.addEventListener("click",this.#j)}else if(this.input&&this.label)this.label.removeEventListener("click",this.#J),this.label.addEventListener("click",this.#J);if(this.input&&this.label&&!this.#$)this.#Y();if(this.label)this.label.removeEventListener("pointerenter",this.#Z),this.label.addEventListener("pointerenter",this.#Z),this.label.removeEventListener("pointerleave",this.#q),this.label.addEventListener("pointerleave",this.#q)}disconnectedCallback(){if(this.label)S.hide(this.label);if(this.label&&this.#j)this.label.removeEventListener("click",this.#j);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.label&&this.#Z)this.label.removeEventListener("pointerenter",this.#Z);if(this.label&&this.#q)this.label.removeEventListener("pointerleave",this.#q);if(this.#Q&&this.#j)this.#Q.removeEventListener("click",this.#j)}#X(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;S.show(this.label,this.label.textContent.trim())}#K(){if(this.label)S.hide(this.label)}#Y(){if(!this.input||!this.label)return;let Q=this.label.getAttribute("id")||y();this.label.setAttribute("id",Q);let $=this.input.querySelectorAll("input, select, textarea");if($.length===1){let J=$[0],Z=J.getAttribute("id")||y();if(J.setAttribute("id",Z),this.label.setAttribute("for",Z),this.input.getAttribute("aria-labelledby")===Q)this.input.removeAttribute("aria-labelledby");if(!J.hasAttribute("aria-labelledby"))J.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,$,J){switch(Q){case"label":if(this.label)this.label.textContent=J,this.#Y();break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let Q=this.input.querySelectorAll("input, select, textarea");if(Q.length===1)Q[0].focus(),Q[0].click();else if(this.input.focus(),Q.length===0)this.input.click()}}customElements.define("fig-field",V0);class y0 extends HTMLElement{rgba;hex;#$=100;#Q;#j;#J;#Z;#q=!1;#_=!1;#X=null;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))}#K(){let Q={},$=this.getAttribute("experimental");if($)Q.experimental=$;for(let{name:J,value:Z}of this.attributes)if(J.startsWith("picker-")&&J!=="picker-anchor")Q[J.slice(7)]=Z;if(!Q["dialog-position"])Q["dialog-position"]="left";return Q}#Y(){let Q=this.#K();return Object.entries(Q).map(([$,J])=>`${$}="${J}"`).join(" ")}connectedCallback(){this.#W()}#W(){this.#D(this.getAttribute("value"));let Q=this.getAttribute("alpha")!=="false",J=this.#P?" disabled":"",Z="";if(this.getAttribute("text")!=="false"){let q=`<fig-input-text
73
+ value="${this.#T(this.value)}" />`,J=this.querySelector("[slot=append]"),Z=this.querySelector("[slot=prepend]");if(this.innerHTML=$,Z)Z.removeEventListener("click",this.#Y),Z.addEventListener("click",this.#Y),this.prepend(Z);if(J)J.removeEventListener("click",this.#Y),J.addEventListener("click",this.#Y),this.append(J);return this.querySelector("input")}#f(){if(!this.input)return;this.#R.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.input.removeAttribute(Q);else this.input.setAttribute(Q,$)})}#P(){if(!this.input)return;if(this.input.setAttribute("role","spinbutton"),typeof this.min==="number")this.input.setAttribute("aria-valuemin",String(this.min));else this.input.removeAttribute("aria-valuemin");if(typeof this.max==="number")this.input.setAttribute("aria-valuemax",String(this.max));else this.input.removeAttribute("aria-valuemax");let Q=this.value===""?null:Number(this.value);if(Number.isFinite(Q))this.input.setAttribute("aria-valuenow",String(Q)),this.input.setAttribute("aria-valuetext",this.#T(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#E(Q){if(!Q)return"";if(!this.#N){let Z=Q.replace(/[^\d.-]/g,""),j=Z.split(".");if(j.length>2)Z=j[0]+"."+j.slice(1).join("");return Z}let $=Q.replace(this.#N,"").trim();$=$.replace(/[^\d.-]/g,"");let J=$.split(".");if(J.length>2)$=J[0]+"."+J.slice(1).join("");return $}#T(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);if(isNaN($))return"";if($=this.#m($),!this.#N)return $.toString();if(this.#G==="prefix")return this.#N+$;else return $+this.#N}#C(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);return $=this.#m($),$.toString()}#x(Q){this.#B=!0,setTimeout(()=>{let $=Q.target.value;if($&&this.#N)if(this.#G==="prefix")Q.target.setSelectionRange(this.#N.length,$.length);else{let J=$.indexOf(this.#N);if(J>-1)Q.target.setSelectionRange(0,J)}},0)}#b(Q){this.#B=!1;let $=this.#E(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#I(J,!1),this.value=J,Q.target.value=this.#T(this.value)}else this.value="",Q.target.value="";this.#O(),this.#P(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#V(Q){if(this.disabled)return;if(Q.key!=="ArrowUp"&&Q.key!=="ArrowDown")return;Q.preventDefault();let $=this.step||1,J=Q.shiftKey?10:1,Z=$*J*(Q.key==="ArrowUp"?1:-1),j=this.#E(this.input.value),q=(j!==""?Number(j)/(this.transform||1):0)+Z;q=this.#I(q,!1),this.value=q,this.input.value=this.#T(this.value),this.#O(),this.#P(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#y(Q){let $=this.#E(Q.target.value);if($!=="")this.value=Number($)/(this.transform||1);else this.value="";this.#O(),this.#P(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#w(Q){Q.stopPropagation();let $=this.#E(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#I(J,!1),this.value=J,Q.target.value=this.#T(this.value)}else this.value="",Q.target.value="";this.#O(),this.#P(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#h(Q){if(this.disabled)return;if(Q.buttons===0){this.#v();return}let $=(this.step||1)*Q.movementX,J=this.#E(this.input.value),Z=Number(J)/(this.transform||1)+$;Z=this.#I(Z,!1),this.value=Z,this.input.value=this.#T(this.value),this.#O(),this.#P(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#g(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#B=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#$),window.addEventListener("pointerup",this.#Q),window.addEventListener("blur",this.#j)}#v(Q){this.#B=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#j)}#I(Q,$=!0){let J=Number(Q);if(isNaN(J))return"";if(typeof this.min==="number")J=Math.max(this.min,J);if(typeof this.max==="number")J=Math.min(this.max,J);return J=this.#m(J),J}#m(Q){let $=this.#U??2,J=Math.pow(10,$),Z=Math.round(Q*J)/J;return Number.isInteger(Z)?Z:parseFloat(Z.toFixed($))}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,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false",this.#O();break;case"units":this.#W=J||"",this.#D(),this.input.value=this.#T(this.value),this.#P();break;case"units-disallow":this.#L=this.#A(J===null?t.#z:J),this.#D(),this.input.value=this.#T(this.value),this.#P();break;case"unit-position":this.#G=J||"suffix",this.input.value=this.#T(this.value),this.#P();break;case"transform":this.transform=Number(J)||1,this.input.value=this.#T(this.value),this.#P();break;case"value":if(this.#B)break;let Z=J!==null&&J!==""?Number(J):"";if(Z!=="")Z=this.#I(Z,!1);this.value=Z,this.input.value=this.#T(this.value),this.#O(),this.#P();break;case"min":case"max":case"step":if(J===null||J===""){this[Q]=void 0,this.#O(),this.#P();break}this[Q]=Number(J),this.#O(),this.#P();break;case"steppers":{let j=J!==null&&J!=="false";this.#H(j);break}case"precision":this.#U=J!==null?Number(J):2,this.input.value=this.#T(this.value),this.#P();break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;case"placeholder":this.placeholder=J??"",this.input.placeholder=this.placeholder;break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#f();break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-number",t);class V0 extends HTMLElement{constructor(){super()}connectedCallback(){this.src=this.getAttribute("src"),this.name=this.getAttribute("name"),this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials),this.setSrc(this.src),this.img=this.querySelector("img")}setSrc(Q){if(this.src=Q,Q)this.innerHTML=`<img src="${this.src}" ${this.name?`alt="${this.name}"`:""} />`}getInitials(Q){return Q?Q.split(" ").map(($)=>$[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(Q,$,J){if(this[Q]=J,Q==="name")this.img?.setAttribute("alt",J),this.name=J,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials);else if(Q==="src")this.src=J,this.setSrc(this.src)}}customElements.define("fig-avatar",V0);class y0 extends HTMLElement{#$=!1;#Q=null;#j=null;#J=null;#Z=null;#q=null;constructor(){super();this.#J=this.focus.bind(this),this.#Z=this.#X.bind(this),this.#q=this.#K.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(this.isConnected)this.#_()})}#_(){if(this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((Q)=>Q.nodeName.toLowerCase().startsWith("fig-")),this.#$=!!(this.input&&("open"in this.input)),this.#$&&this.label){if(!this.#Q||!this.#Q.isConnected)this.#Q=h("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#Q,this.label);this.#j=(Q)=>{if(Q.preventDefault(),Q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open},this.#Q.addEventListener("click",this.#j),this.label.addEventListener("click",this.#j)}else if(this.input&&this.label)this.label.removeEventListener("click",this.#J),this.label.addEventListener("click",this.#J);if(this.input&&this.label&&!this.#$)this.#Y();if(this.label)this.label.removeEventListener("pointerenter",this.#Z),this.label.addEventListener("pointerenter",this.#Z),this.label.removeEventListener("pointerleave",this.#q),this.label.addEventListener("pointerleave",this.#q)}disconnectedCallback(){if(this.label)S.hide(this.label);if(this.label&&this.#j)this.label.removeEventListener("click",this.#j);if(this.label&&this.#J)this.label.removeEventListener("click",this.#J);if(this.label&&this.#Z)this.label.removeEventListener("pointerenter",this.#Z);if(this.label&&this.#q)this.label.removeEventListener("pointerleave",this.#q);if(this.#Q&&this.#j)this.#Q.removeEventListener("click",this.#j)}#X(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;S.show(this.label,this.label.textContent.trim())}#K(){if(this.label)S.hide(this.label)}#Y(){if(!this.input||!this.label)return;let Q=this.label.getAttribute("id")||y();this.label.setAttribute("id",Q);let $=this.input.querySelectorAll("input, select, textarea");if($.length===1){let J=$[0],Z=J.getAttribute("id")||y();if(J.setAttribute("id",Z),this.label.setAttribute("for",Z),this.input.getAttribute("aria-labelledby")===Q)this.input.removeAttribute("aria-labelledby");if(!J.hasAttribute("aria-labelledby"))J.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,$,J){switch(Q){case"label":if(this.label)this.label.textContent=J,this.#Y();break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let Q=this.input.querySelectorAll("input, select, textarea");if(Q.length===1)Q[0].focus(),Q[0].click();else if(this.input.focus(),Q.length===0)this.input.click()}}customElements.define("fig-field",y0);class w0 extends HTMLElement{rgba;hex;#$=100;#Q;#j;#J;#Z;#q=!1;#_=!1;#X=null;#K=this.#P.bind(this);#Y=this.#E.bind(this);#N=this.#T.bind(this);#W=this.#h.bind(this);#L=this.#x.bind(this);#G=this.#V.bind(this);#U=this.#b.bind(this);#B=this.#g.bind(this);constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0||Q===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(Q))}#M(){let Q={},$=this.getAttribute("experimental");if($)Q.experimental=$;for(let{name:J,value:Z}of this.attributes)if(J.startsWith("picker-")&&J!=="picker-anchor")Q[J.slice(7)]=Z;if(!Q["dialog-position"])Q["dialog-position"]="left";return Q}#R(){let Q=this.#M();return Object.entries(Q).map(([$,J])=>`${$}="${J}"`).join(" ")}connectedCallback(){if(this.#z()){this.#A();return}this.#H()}disconnectedCallback(){this.#F()}#z(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-chit")}#A(){if(this.#C(this.getAttribute("value")),this.#Q=this.querySelector("fig-chit"),this.#j=this.querySelector("fig-fill-picker"),this.#J=this.querySelector("fig-input-text:not([type=number])"),this.#Z=this.querySelector("fig-input-number"),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Z)this.#Z.setAttribute("value",String(this.#$));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",String(this.rgba.a));this.#w(),this.#D()}#F(){if(this.#Q)this.#Q.removeEventListener("pointerdown",this.#K,{capture:!0}),this.#Q.removeEventListener("click",this.#Y,{capture:!0}),this.#Q.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#N),this.#Q.removeEventListener("input",this.#W);this.#J?.removeEventListener("input",this.#L),this.#J?.removeEventListener("change",this.#G),this.#Z?.removeEventListener("input",this.#U),this.#Z?.removeEventListener("change",this.#G),this.#j?.removeEventListener("input",this.#B),this.#j?.removeEventListener("change",this.#G)}#D(){if(this.#Q){this.#Q.disabled=this.hasAttribute("disabled");let Q=this.#Q.querySelector('input[type="color"]');if(this.#J||this.hasAttribute("swatch-disabled"))Q?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(Q?.setAttribute("disabled",""),Q)Q.style.pointerEvents="none"}this.#Q.addEventListener("pointerdown",this.#K,{capture:!0}),this.#Q.addEventListener("click",this.#Y,{capture:!0}),Q?.addEventListener("keydown",this.#N),this.#Q.addEventListener("input",this.#W)}if(this.#J)this.#J.addEventListener("input",this.#L),this.#J.addEventListener("change",this.#G);if(this.#Z)this.#Z.addEventListener("input",this.#U),this.#Z.addEventListener("change",this.#G);if(this.#j)this.#j.addEventListener("input",this.#B),this.#j.addEventListener("change",this.#G)}#H(){this.#C(this.getAttribute("value"));let Q=this.getAttribute("alpha")!=="false",J=this.#m?" disabled":"",Z="";if(this.getAttribute("text")!=="false"){let q=`<fig-input-text
74
74
  type="text"
75
75
  placeholder="000000"
76
76
  value="${this.hexOpaque.slice(1).toUpperCase()}"${J}>
@@ -85,7 +85,7 @@ var B1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var O1={};var G0=B1(()=>{/*! Vendored from @
85
85
  </fig-tooltip>`;let _="";_=`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${J}></fig-chit>`,Z=`<div class="input-combo">
86
86
  ${_}
87
87
  ${q}
88
- </div>`}else Z=`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${J}></fig-chit>`;if(this.innerHTML=Z,this.#Q=this.querySelector("fig-chit"),this.#j=this.querySelector("fig-fill-picker"),this.#J=this.querySelector("fig-input-text:not([type=number])"),this.#Z=this.querySelector("fig-input-number"),this.#z(),this.#Q){this.#Q.disabled=this.hasAttribute("disabled");let q=this.#Q.querySelector('input[type="color"]');if(this.#J||this.hasAttribute("swatch-disabled"))q?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(q?.setAttribute("disabled",""),q)q.style.pointerEvents="none"}this.#Q.addEventListener("pointerdown",this.#M.bind(this),{capture:!0}),this.#Q.addEventListener("click",this.#G.bind(this),{capture:!0}),q?.addEventListener("keydown",this.#A.bind(this)),this.#Q.addEventListener("input",this.#C.bind(this))}if(this.#J){let q=this.rgbAlphaToHex(this.rgba,1);if(this.#J.value=q.slice(1).toUpperCase(),this.#Q)this.#Q.background=q;this.#J.addEventListener("input",this.#O.bind(this)),this.#J.addEventListener("change",this.#R.bind(this))}if(this.#Z)this.#Z.addEventListener("input",this.#H.bind(this)),this.#Z.addEventListener("change",this.#R.bind(this))}#N(){if(!this.#j)return;for(let[Q,$]of Object.entries(this.#K()))this.#j.setAttribute(Q,$);if(this.#j.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#j.removeAttribute("alpha");else this.#j.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#j.setAttribute("disabled","");else this.#j.removeAttribute("disabled");this.#j.anchorElement=this,this.#j.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}))}#L(){if(!m())return null;if(this.#j?.isConnected)return this.#N(),this.#j;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#k.bind(this)),Q.addEventListener("change",this.#R.bind(this)),this.appendChild(Q),this.#j=Q,this.#N(),Q}#U(){if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return!1;let Q=this.#L();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#B(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#M(Q){if(!m())return;if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return;if(this.#_=!0,this.#q=!0,this.#X)clearTimeout(this.#X);this.#X=setTimeout(()=>{this.#q=!1,this.#_=!1,this.#X=null},500),this.#B(Q)}#G(Q){if(!this.#q)return;if(this.#q=!1,this.#X)clearTimeout(this.#X),this.#X=null;if(this.#B(Q),this.#_)this.#_=!1,this.#U()}#A(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!m())return;if(!this.#U())return;this.#B(Q)}#D(Q){let $=Q||"#D9D9D9";this.rgba=this.convertToRGBA($),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.#$=$.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#O(Q){Q.stopPropagation();let $=Q.target.value.replace("#","");if(this.#D("#"+$),this.#Z)this.#Z.setAttribute("value",this.#$);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#T()}#H(Q){Q.stopPropagation();let $=Number(Q.target.value)||0,Z=Math.round($/100*255).toString(16).padStart(2,"0");if(this.#D(this.hexOpaque+Z),this.#Q)this.#Q.setAttribute("alpha",this.rgba.a);if(this.#j)this.#j.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));this.#T()}#R(Q){Q.stopPropagation(),this.#E()}focus(){if(this.#J){this.#J.focus();return}this.#Q?.focus()}#F(){return this.getAttribute("aria-label")||"Color"}#z(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#P)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let Q=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),Z=this.getAttribute("aria-labelledby"),j=this.#F();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($)this.#J.setAttribute("aria-invalid",$);else this.#J.removeAttribute("aria-invalid");if(J)this.#J.setAttribute("aria-required",J);else this.#J.removeAttribute("aria-required")}if(this.#Z){if(this.#Z.setAttribute("aria-label",`${j} opacity`),Q)this.#Z.setAttribute("aria-describedby",Q);else this.#Z.removeAttribute("aria-describedby");if($)this.#Z.setAttribute("aria-invalid",$);else this.#Z.removeAttribute("aria-invalid");if(J)this.#Z.setAttribute("aria-required",J);else this.#Z.removeAttribute("aria-required")}if(!this.#J){let q=this.#Q?.querySelector('input[type="color"]');if(!q)return;if(Z)q.setAttribute("aria-labelledby",Z),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")}}#C(Q){if(Q.stopPropagation(),this.#D(Q.target.value),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#T()}#k(Q){Q.stopPropagation();let $=Q.detail;if($&&$.color){let J=$.color;if($.alpha!==void 0){let Z=Math.round($.alpha*255).toString(16).padStart(2,"0");J=$.color+Z}if(this.#D(J),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Z&&$.alpha!==void 0)this.#Z.setAttribute("value",Math.round($.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#T()}}#T(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#E(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}static get observedAttributes(){return["value","style","mode","experimental","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(Q){this.setAttribute("mode",Q)}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":if(this.#D(J),this.#J)this.#J.setAttribute("value",this.value);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);if(this.#j)this.#j.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));if(this.#Z)this.#Z.setAttribute("value",this.#$);break;case"mode":this.#N();break;case"alpha":case"text":if(this.isConnected)this.#W();break;case"disabled":this.#S();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#z();break}}get#P(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#S(){let Q=this.#P;for(let $ of[this.#Q,this.#J,this.#Z]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}if(this.#z(),this.#j)this.#N()}rgbAlphaToHex({r:Q,g:$,b:J},Z=1){Q=Math.max(0,Math.min(255,Math.round(Q))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(255,Math.round(J))),Z=Math.max(0,Math.min(1,Z));let j=Q.toString(16).padStart(2,"0"),q=$.toString(16).padStart(2,"0"),_=J.toString(16).padStart(2,"0");if(Z===1)return`#${j}${q}${_}`.toUpperCase();let Y=Math.round(Z*255).toString(16).padStart(2,"0");return`#${j}${q}${_}${Y}`.toUpperCase()}convertToRGBA(Q){let $,J,Z,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);$=parseInt(q.slice(0,2),16),J=parseInt(q.slice(2,4),16),Z=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)$=parseInt(q[1]),J=parseInt(q[2]),Z=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)$=J=Z=Y;else{let K=(O,H,B)=>{if(B<0)B+=1;if(B>1)B-=1;if(B<0.16666666666666666)return O+(H-O)*6*B;if(B<0.5)return H;if(B<0.6666666666666666)return O+(H-O)*(0.6666666666666666-B)*6;return O},N=Y<0.5?Y*(1+X):Y+X-Y*X,L=2*Y-N;$=K(L,N,_+0.3333333333333333),J=K(L,N,_),Z=K(L,N,_-0.3333333333333333)}$=Math.round($*255),J=Math.round(J*255),Z=Math.round(Z*255)}}else return null;return{r:$,g:J,b:Z,a:j}}}customElements.define("fig-input-color",y0);var F1=["srgb","srgb-linear","display-p3","oklab","oklch"],T1=["shorter","longer","increasing","decreasing"];function r(Q){let $={...Q??{}},J=String($.interpolationSpace??"srgb").toLowerCase();if(!F1.includes(J))J="srgb";$.interpolationSpace=J;let Z=String($.hueInterpolation??"shorter").toLowerCase();return $.hueInterpolation=T1.includes(Z)?Z:"shorter",$}function w0(Q){let $=r(Q),J={...$,interpolationSpace:$.interpolationSpace};if($.interpolationSpace==="oklch")J.hueInterpolation=$.hueInterpolation;else delete J.hueInterpolation;return J}function b0(Q){let $=r(Q);if($.interpolationSpace==="srgb")return"";if($.interpolationSpace==="oklch")return`in oklch ${$.hueInterpolation} hue`;return`in ${$.interpolationSpace}`}function u(Q){let $=Q.replace(/^#/,"");return{r:parseInt($.substring(0,2),16),g:parseInt($.substring(2,4),16),b:parseInt($.substring(4,6),16)}}function h(Q){let $=Q/255;return $<=0.04045?$/12.92:Math.pow(($+0.055)/1.055,2.4)}function p(Q){let $=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,$))*255)}function l(Q,$,J){let Z=h(Q),j=h($),q=h(J),_=Math.cbrt(0.4122214708*Z+0.5363325363*j+0.0514459929*q),X=Math.cbrt(0.2119034982*Z+0.6806995451*j+0.1073969566*q),Y=Math.cbrt(0.0883024619*Z+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 L0(Q,$,J){let Z=Q+0.3963377774*$+0.2158037573*J,j=Q-0.1055613458*$-0.0638541728*J,q=Q-0.0894841775*$-1.291485548*J,_=Z*Z*Z,X=j*j*j,Y=q*q*q;return{r:p(4.0767416621*_-3.3077115913*X+0.2309699292*Y),g:p(-1.2684380046*_+2.6097574011*X-0.3413193965*Y),b:p(-0.0041960863*_-0.7034186147*X+1.707614701*Y)}}function M0(Q,$,J){return{l:Q,c:Math.sqrt($*$+J*J),h:Math.atan2(J,$)*180/Math.PI}}function P1(Q,$,J){let Z=J*Math.PI/180;return{l:Q,a:$*Math.cos(Z),b:$*Math.sin(Z)}}function k1(Q,$,J,Z){let j=(Q%360+360)%360,_=($%360+360)%360-j;switch(Z){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+_*J)%360+360)%360}function E1(Q,$,J,Z){let j=[...Q].sort((A,G)=>A.position-G.position),q=$*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,N=K>0?(q-X.position)/K:0,L=u(X.color),O=u(Y.color),H,B,U,z=J||"oklab";if(z==="srgb-linear"){let A=h(L.r),G=h(L.g),M=h(L.b),D=h(O.r),T=h(O.g),P=h(O.b);H=p(A+(D-A)*N),B=p(G+(T-G)*N),U=p(M+(P-M)*N)}else if(z==="oklch"){let A=l(L.r,L.g,L.b),G=l(O.r,O.g,O.b),M=M0(A.l,A.a,A.b),D=M0(G.l,G.a,G.b),T=M.l+(D.l-M.l)*N,P=M.c+(D.c-M.c)*N,E=k1(M.h,D.h,N,Z||"shorter"),f=P1(T,P,E),w=L0(f.l,f.a,f.b);H=w.r,B=w.g,U=w.b}else{let A=l(L.r,L.g,L.b),G=l(O.r,O.g,O.b),M=A.l+(G.l-A.l)*N,D=A.a+(G.a-A.a)*N,T=A.b+(G.b-A.b)*N,P=L0(M,D,T);H=P.r,B=P.g,U=P.b}return`#${H.toString(16).padStart(2,"0")}${B.toString(16).padStart(2,"0")}${U.toString(16).padStart(2,"0")}`.toUpperCase()}class v0 extends HTMLElement{#$="solid";#Q;#j;#J;#Z={color:"#D9D9D9",alpha:1};#q={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#_={url:null,scaleMode:"fill",scale:50,opacity:1};#X={url:null,scaleMode:"fill",opacity:1};#K={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","experimental","alpha","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#Y(),this.#M()}disconnectedCallback(){this.#Q=null,this.#j=null,this.#J=null}#Y(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($.type)this.#$=$.type;switch(this.#$){case"solid":if($.color)this.#Z.color=$.color;if($.alpha!==void 0)this.#Z.alpha=$.alpha;if($.opacity!==void 0)this.#Z.alpha=$.opacity/100;break;case"gradient":if($.gradient)this.#q=r({...this.#q,...$.gradient});break;case"image":if($.image)this.#_={...this.#_,...$.image};break;case"video":if($.video)this.#X={...this.#X,...$.video};break;case"webcam":if($.webcam)this.#K={...this.#K,...$.webcam};if($.opacity!==void 0)this.#K.opacity=$.opacity;break}}catch($){if(Q.startsWith("#")){if(this.#$="solid",this.#Z.color=Q.slice(0,7),Q.length>7){let J=Q.slice(7,9);this.#Z.alpha=parseInt(J,16)/255}}}}#W(){let Q={},$=this.getAttribute("mode");if($)Q.mode=$;let J=this.getAttribute("experimental");if(J)Q.experimental=J;let Z=this.getAttribute("alpha");if(Z)Q.alpha=Z;for(let{name:j,value:q}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor")Q[j.slice(7)]=q;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([j,q])=>`${j}="${q}"`).join(" ")}#N(){switch(this.#$){case"solid":return this.#Z.color;case"gradient":{let $=[...this.#q.stops].sort((J,Z)=>J.position-Z.position).map((J)=>{let Z=(J.opacity??100)/100;if(Z>=1)return`${J.color} ${J.position}%`;let{r:j,g:q,b:_}=u(J.color);return`rgba(${j}, ${q}, ${_}, ${Z}) ${J.position}%`}).join(", ");return`linear-gradient(${this.#q.angle}deg ${b0(this.#q)}, ${$})`}case"image":return this.#_.url?`url(${this.#_.url})`:"#D9D9D9";default:return"#D9D9D9"}}#L(){switch(this.#$){case"solid":return this.#Z.alpha;case"image":return this.#_.opacity??1;case"video":return this.#X.opacity??1;case"webcam":return this.#K.opacity??1;default:return 1}}#U(){let Q=this.hasAttribute("disabled");this.setAttribute("aria-disabled",Q?"true":"false");for(let $ of[this.#Q,this.#j,this.#J]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}#B(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#U();let Q=this.getAttribute("aria-label")||"Fill",$=this.getAttribute("aria-describedby"),J=this.getAttribute("aria-invalid"),Z=this.getAttribute("aria-required"),j=(q,_)=>{if(!q)return;if(q.setAttribute("aria-label",_),$)q.setAttribute("aria-describedby",$);else q.removeAttribute("aria-describedby");if(J)q.setAttribute("aria-invalid",J);else q.removeAttribute("aria-invalid");if(Z)q.setAttribute("aria-required",Z);else q.removeAttribute("aria-required")};j(this.#Q,`${Q} picker`),j(this.#J,`${Q} hex color`),j(this.#j,`${Q} opacity`)}#M(){let Q=this.hasAttribute("disabled"),$=JSON.stringify(this.value),J=this.getAttribute("alpha")!=="false",Z=(_)=>J?`<fig-tooltip text="Opacity">
88
+ </div>`}else Z=`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${J}></fig-chit>`;if(this.innerHTML=Z,this.#Q=this.querySelector("fig-chit"),this.#j=this.querySelector("fig-fill-picker"),this.#J=this.querySelector("fig-input-text:not([type=number])"),this.#Z=this.querySelector("fig-input-number"),this.#w(),this.#J){let q=this.rgbAlphaToHex(this.rgba,1);if(this.#J.value=q.slice(1).toUpperCase(),this.#Q)this.#Q.background=q}this.#D()}#O(){if(!this.#j)return;for(let[Q,$]of Object.entries(this.#M()))this.#j.setAttribute(Q,$);if(this.#j.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#j.removeAttribute("alpha");else this.#j.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#j.setAttribute("disabled","");else this.#j.removeAttribute("disabled");this.#j.anchorElement=this,this.#j.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}))}#k(){if(!p())return null;if(this.#j?.isConnected)return this.#O(),this.#j;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#g.bind(this)),Q.addEventListener("change",this.#V.bind(this)),this.appendChild(Q),this.#j=Q,this.#O(),Q}#S(){if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return!1;let Q=this.#k();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#f(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#P(Q){if(!p())return;if(this.hasAttribute("disabled")||this.hasAttribute("swatch-disabled"))return;if(this.#_=!0,this.#q=!0,this.#X)clearTimeout(this.#X);this.#X=setTimeout(()=>{this.#q=!1,this.#_=!1,this.#X=null},500),this.#f(Q)}#E(Q){if(!this.#q)return;if(this.#q=!1,this.#X)clearTimeout(this.#X),this.#X=null;if(this.#f(Q),this.#_)this.#_=!1,this.#S()}#T(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!p())return;if(!this.#S())return;this.#f(Q)}#C(Q){let $=Q||"#D9D9D9";this.rgba=this.convertToRGBA($),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.#$=$.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#x(Q){Q.stopPropagation();let $=Q.target.value.replace("#","");if(this.#C("#"+$),this.#Z)this.#Z.setAttribute("value",this.#$);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#v()}#b(Q){Q.stopPropagation();let $=Number(Q.target.value)||0,Z=Math.round($/100*255).toString(16).padStart(2,"0");if(this.#C(this.hexOpaque+Z),this.#Q)this.#Q.setAttribute("alpha",this.rgba.a);if(this.#j)this.#j.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));this.#v()}#V(Q){Q.stopPropagation(),this.#I()}focus(){if(this.#J){this.#J.focus();return}this.#Q?.focus()}#y(){return this.getAttribute("aria-label")||"Color"}#w(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#m)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let Q=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),Z=this.getAttribute("aria-labelledby"),j=this.#y();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($)this.#J.setAttribute("aria-invalid",$);else this.#J.removeAttribute("aria-invalid");if(J)this.#J.setAttribute("aria-required",J);else this.#J.removeAttribute("aria-required")}if(this.#Z){if(this.#Z.setAttribute("aria-label",`${j} opacity`),Q)this.#Z.setAttribute("aria-describedby",Q);else this.#Z.removeAttribute("aria-describedby");if($)this.#Z.setAttribute("aria-invalid",$);else this.#Z.removeAttribute("aria-invalid");if(J)this.#Z.setAttribute("aria-required",J);else this.#Z.removeAttribute("aria-required")}if(!this.#J){let q=this.#Q?.querySelector('input[type="color"]');if(!q)return;if(Z)q.setAttribute("aria-labelledby",Z),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")}}#h(Q){if(Q.stopPropagation(),this.#C(Q.target.value),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#v()}#g(Q){Q.stopPropagation();let $=Q.detail;if($&&$.color){let J=$.color;if($.alpha!==void 0){let Z=Math.round($.alpha*255).toString(16).padStart(2,"0");J=$.color+Z}if(this.#C(J),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Z&&$.alpha!==void 0)this.#Z.setAttribute("value",Math.round($.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#v()}}#v(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#I(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}static get observedAttributes(){return["value","style","mode","experimental","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(Q){this.setAttribute("mode",Q)}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":if(this.#C(J),this.#J)this.#J.setAttribute("value",this.value);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);if(this.#j)this.#j.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));if(this.#Z)this.#Z.setAttribute("value",this.#$);break;case"mode":this.#O();break;case"alpha":case"text":if(this.isConnected)this.#H();break;case"disabled":this.#p();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#w();break}}get#m(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#p(){let Q=this.#m;for(let $ of[this.#Q,this.#J,this.#Z]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}if(this.#w(),this.#j)this.#O()}rgbAlphaToHex({r:Q,g:$,b:J},Z=1){Q=Math.max(0,Math.min(255,Math.round(Q))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(255,Math.round(J))),Z=Math.max(0,Math.min(1,Z));let j=Q.toString(16).padStart(2,"0"),q=$.toString(16).padStart(2,"0"),_=J.toString(16).padStart(2,"0");if(Z===1)return`#${j}${q}${_}`.toUpperCase();let Y=Math.round(Z*255).toString(16).padStart(2,"0");return`#${j}${q}${_}${Y}`.toUpperCase()}convertToRGBA(Q){let $,J,Z,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);$=parseInt(q.slice(0,2),16),J=parseInt(q.slice(2,4),16),Z=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)$=parseInt(q[1]),J=parseInt(q[2]),Z=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)$=J=Z=Y;else{let K=(O,H,B)=>{if(B<0)B+=1;if(B>1)B-=1;if(B<0.16666666666666666)return O+(H-O)*6*B;if(B<0.5)return H;if(B<0.6666666666666666)return O+(H-O)*(0.6666666666666666-B)*6;return O},N=Y<0.5?Y*(1+X):Y+X-Y*X,L=2*Y-N;$=K(L,N,_+0.3333333333333333),J=K(L,N,_),Z=K(L,N,_-0.3333333333333333)}$=Math.round($*255),J=Math.round(J*255),Z=Math.round(Z*255)}}else return null;return{r:$,g:J,b:Z,a:j}}}customElements.define("fig-input-color",w0);var T1=["srgb","srgb-linear","display-p3","oklab","oklch"],P1=["shorter","longer","increasing","decreasing"];function i(Q){let $={...Q??{}},J=String($.interpolationSpace??"srgb").toLowerCase();if(!T1.includes(J))J="srgb";$.interpolationSpace=J;let Z=String($.hueInterpolation??"shorter").toLowerCase();return $.hueInterpolation=P1.includes(Z)?Z:"shorter",$}function b0(Q){let $=i(Q),J={...$,interpolationSpace:$.interpolationSpace};if($.interpolationSpace==="oklch")J.hueInterpolation=$.hueInterpolation;else delete J.hueInterpolation;return J}function v0(Q){let $=i(Q);if($.interpolationSpace==="srgb")return"";if($.interpolationSpace==="oklch")return`in oklch ${$.hueInterpolation} hue`;return`in ${$.interpolationSpace}`}function u(Q){let $=Q.replace(/^#/,"");return{r:parseInt($.substring(0,2),16),g:parseInt($.substring(2,4),16),b:parseInt($.substring(4,6),16)}}function g(Q){let $=Q/255;return $<=0.04045?$/12.92:Math.pow(($+0.055)/1.055,2.4)}function c(Q){let $=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,$))*255)}function a(Q,$,J){let Z=g(Q),j=g($),q=g(J),_=Math.cbrt(0.4122214708*Z+0.5363325363*j+0.0514459929*q),X=Math.cbrt(0.2119034982*Z+0.6806995451*j+0.1073969566*q),Y=Math.cbrt(0.0883024619*Z+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 M0(Q,$,J){let Z=Q+0.3963377774*$+0.2158037573*J,j=Q-0.1055613458*$-0.0638541728*J,q=Q-0.0894841775*$-1.291485548*J,_=Z*Z*Z,X=j*j*j,Y=q*q*q;return{r:c(4.0767416621*_-3.3077115913*X+0.2309699292*Y),g:c(-1.2684380046*_+2.6097574011*X-0.3413193965*Y),b:c(-0.0041960863*_-0.7034186147*X+1.707614701*Y)}}function B0(Q,$,J){return{l:Q,c:Math.sqrt($*$+J*J),h:Math.atan2(J,$)*180/Math.PI}}function E1(Q,$,J){let Z=J*Math.PI/180;return{l:Q,a:$*Math.cos(Z),b:$*Math.sin(Z)}}function k1(Q,$,J,Z){let j=(Q%360+360)%360,_=($%360+360)%360-j;switch(Z){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+_*J)%360+360)%360}function C1(Q,$,J,Z){let j=[...Q].sort((A,G)=>A.position-G.position),q=$*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,N=K>0?(q-X.position)/K:0,L=u(X.color),O=u(Y.color),H,B,U,z=J||"oklab";if(z==="srgb-linear"){let A=g(L.r),G=g(L.g),M=g(L.b),D=g(O.r),T=g(O.g),P=g(O.b);H=c(A+(D-A)*N),B=c(G+(T-G)*N),U=c(M+(P-M)*N)}else if(z==="oklch"){let A=a(L.r,L.g,L.b),G=a(O.r,O.g,O.b),M=B0(A.l,A.a,A.b),D=B0(G.l,G.a,G.b),T=M.l+(D.l-M.l)*N,P=M.c+(D.c-M.c)*N,k=k1(M.h,D.h,N,Z||"shorter"),f=E1(T,P,k),w=M0(f.l,f.a,f.b);H=w.r,B=w.g,U=w.b}else{let A=a(L.r,L.g,L.b),G=a(O.r,O.g,O.b),M=A.l+(G.l-A.l)*N,D=A.a+(G.a-A.a)*N,T=A.b+(G.b-A.b)*N,P=M0(M,D,T);H=P.r,B=P.g,U=P.b}return`#${H.toString(16).padStart(2,"0")}${B.toString(16).padStart(2,"0")}${U.toString(16).padStart(2,"0")}`.toUpperCase()}class h0 extends HTMLElement{#$="solid";#Q;#j;#J;#Z={color:"#D9D9D9",alpha:1};#q={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#_={url:null,scaleMode:"fill",scale:50,opacity:1};#X={url:null,scaleMode:"fill",opacity:1};#K={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","experimental","alpha","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#Y(),this.#B()}disconnectedCallback(){this.#Q=null,this.#j=null,this.#J=null}#Y(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($.type)this.#$=$.type;switch(this.#$){case"solid":if($.color)this.#Z.color=$.color;if($.alpha!==void 0)this.#Z.alpha=$.alpha;if($.opacity!==void 0)this.#Z.alpha=$.opacity/100;break;case"gradient":if($.gradient)this.#q=i({...this.#q,...$.gradient});break;case"image":if($.image)this.#_={...this.#_,...$.image};break;case"video":if($.video)this.#X={...this.#X,...$.video};break;case"webcam":if($.webcam)this.#K={...this.#K,...$.webcam};if($.opacity!==void 0)this.#K.opacity=$.opacity;break}}catch($){if(Q.startsWith("#")){if(this.#$="solid",this.#Z.color=Q.slice(0,7),Q.length>7){let J=Q.slice(7,9);this.#Z.alpha=parseInt(J,16)/255}}}}#N(){let Q={},$=this.getAttribute("mode");if($)Q.mode=$;let J=this.getAttribute("experimental");if(J)Q.experimental=J;let Z=this.getAttribute("alpha");if(Z)Q.alpha=Z;for(let{name:j,value:q}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor")Q[j.slice(7)]=q;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([j,q])=>`${j}="${q}"`).join(" ")}#W(){switch(this.#$){case"solid":return this.#Z.color;case"gradient":{let $=[...this.#q.stops].sort((J,Z)=>J.position-Z.position).map((J)=>{let Z=(J.opacity??100)/100;if(Z>=1)return`${J.color} ${J.position}%`;let{r:j,g:q,b:_}=u(J.color);return`rgba(${j}, ${q}, ${_}, ${Z}) ${J.position}%`}).join(", ");return`linear-gradient(${this.#q.angle}deg ${v0(this.#q)}, ${$})`}case"image":return this.#_.url?`url(${this.#_.url})`:"#D9D9D9";default:return"#D9D9D9"}}#L(){switch(this.#$){case"solid":return this.#Z.alpha;case"image":return this.#_.opacity??1;case"video":return this.#X.opacity??1;case"webcam":return this.#K.opacity??1;default:return 1}}#G(){let Q=this.hasAttribute("disabled");this.setAttribute("aria-disabled",Q?"true":"false");for(let $ of[this.#Q,this.#j,this.#J]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}#U(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#G();let Q=this.getAttribute("aria-label")||"Fill",$=this.getAttribute("aria-describedby"),J=this.getAttribute("aria-invalid"),Z=this.getAttribute("aria-required"),j=(q,_)=>{if(!q)return;if(q.setAttribute("aria-label",_),$)q.setAttribute("aria-describedby",$);else q.removeAttribute("aria-describedby");if(J)q.setAttribute("aria-invalid",J);else q.removeAttribute("aria-invalid");if(Z)q.setAttribute("aria-required",Z);else q.removeAttribute("aria-required")};j(this.#Q,`${Q} picker`),j(this.#J,`${Q} hex color`),j(this.#j,`${Q} opacity`)}#B(){let Q=this.hasAttribute("disabled"),$=JSON.stringify(this.value),J=this.getAttribute("alpha")!=="false",Z=(_)=>J?`<fig-tooltip text="Opacity">
89
89
  <fig-input-number
90
90
  class="fig-input-fill-opacity"
91
91
  placeholder="##"
@@ -111,13 +111,13 @@ var B1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var O1={};var G0=B1(()=>{/*! Vendored from @
111
111
  <label class="fig-input-fill-label">Video</label>
112
112
  ${Z(Math.round((this.#X.opacity??1)*100))}`;break;case"webcam":j=`
113
113
  <label class="fig-input-fill-label">Webcam</label>
114
- ${Z(Math.round((this.#K.opacity??1)*100))}`;break}let q=this.#W();this.innerHTML=`
114
+ ${Z(Math.round((this.#K.opacity??1)*100))}`;break}let q=this.#N();this.innerHTML=`
115
115
  <div class="input-combo">
116
116
  <fig-fill-picker ${q} value='${$}' ${Q?"disabled":""}>
117
- <fig-chit background="${this.#N()}" alpha="${this.#L()}"${Q?" disabled":""}></fig-chit>
117
+ <fig-chit background="${this.#W()}" alpha="${this.#L()}"${Q?" disabled":""}></fig-chit>
118
118
  </fig-fill-picker>
119
119
  ${j}
120
- </div>`,this.#G()}#G(){this.#Q=this.querySelector("fig-fill-picker"),this.#j=this.querySelector(".fig-input-fill-opacity"),this.#J=this.querySelector(".fig-input-fill-hex");let Q=this.querySelector(".fig-input-fill-label");if(this.#B(),Q&&this.#Q)Q.addEventListener("click",()=>{let $=this.#Q.querySelector("fig-chit");if($)$.click()});if(this.#Q){let $=this.getAttribute("picker-anchor");if(!$||$==="self")this.#Q.anchorElement=this;else{let J=document.querySelector($);if(J)this.#Q.anchorElement=J}this.#Q.addEventListener("input",(J)=>{J.stopPropagation();let Z=J.detail;if(!Z)return;let j=Z.type,q=j!==this.#$;switch(this.#$=j,j){case"solid":this.#Z.color=Z.color,this.#Z.alpha=Z.alpha;break;case"gradient":if(Z.gradient)this.#q=r({...this.#q,...Z.gradient});break;case"image":if(Z.image)this.#_=Z.image;break;case"video":if(Z.video)this.#X=Z.video;break}if(q)this.#D();else this.#A();this.#R()}),this.#Q.addEventListener("change",(J)=>{J.stopPropagation(),this.#F()})}if(this.#J)this.#J.addEventListener("input",($)=>{$.stopPropagation();let J="#"+$.target.value.replace("#","");this.#Z.color=J,this.#O(),this.#R()}),this.#J.addEventListener("change",($)=>{$.stopPropagation(),this.#F()});if(this.#j)this.#j.addEventListener("input",($)=>{$.stopPropagation();let J=parseFloat($.target.value),j=(isNaN(J)?100:J)/100;switch(this.#$){case"solid":this.#Z.alpha=j;break;case"gradient":break;case"image":this.#_.opacity=j;break;case"video":this.#X.opacity=j;break;case"webcam":this.#K.opacity=j;break}this.#O(),this.#H(j),this.#R()}),this.#j.addEventListener("change",($)=>{$.stopPropagation(),this.#F()})}#A(){switch(this.#$){case"solid":if(this.#J)this.#J.setAttribute("value",this.#Z.color.slice(1).toUpperCase());if(this.#j)this.#j.setAttribute("value",Math.round(this.#Z.alpha*100));break;case"gradient":{let Q=this.querySelector(".fig-input-fill-label");if(Q){let $=this.#q.type.charAt(0).toUpperCase()+this.#q.type.slice(1);Q.textContent=$}break}case"image":if(this.#j)this.#j.setAttribute("value",Math.round((this.#_.opacity??1)*100));break;case"video":if(this.#j)this.#j.setAttribute("value",Math.round((this.#X.opacity??1)*100));break;case"webcam":if(this.#j)this.#j.setAttribute("value",Math.round((this.#K.opacity??1)*100));break}}#D(){let Q=this.hasAttribute("disabled"),$=this.querySelector(".input-combo");if(!$)return;let J=$.querySelector(".fig-input-fill-label"),Z=$.querySelector(".fig-input-fill-hex"),j=$.querySelector(".fig-input-fill-opacity"),q=$.querySelectorAll("fig-tooltip");J?.remove(),Z?.remove(),q.forEach((Y)=>Y.remove());let _="";switch(this.#$){case"solid":_=`
120
+ </div>`,this.#M()}#M(){this.#Q=this.querySelector("fig-fill-picker"),this.#j=this.querySelector(".fig-input-fill-opacity"),this.#J=this.querySelector(".fig-input-fill-hex");let Q=this.querySelector(".fig-input-fill-label");if(this.#U(),Q&&this.#Q)Q.addEventListener("click",()=>{let $=this.#Q.querySelector("fig-chit");if($)$.click()});if(this.#Q){let $=this.getAttribute("picker-anchor");if(!$||$==="self")this.#Q.anchorElement=this;else{let J=document.querySelector($);if(J)this.#Q.anchorElement=J}this.#Q.addEventListener("input",(J)=>{J.stopPropagation();let Z=J.detail;if(!Z)return;let j=Z.type,q=j!==this.#$;switch(this.#$=j,j){case"solid":this.#Z.color=Z.color,this.#Z.alpha=Z.alpha;break;case"gradient":if(Z.gradient)this.#q=i({...this.#q,...Z.gradient});break;case"image":if(Z.image)this.#_=Z.image;break;case"video":if(Z.video)this.#X=Z.video;break}if(q)this.#z();else this.#R();this.#D()}),this.#Q.addEventListener("change",(J)=>{J.stopPropagation(),this.#H()})}if(this.#J)this.#J.addEventListener("input",($)=>{$.stopPropagation();let J="#"+$.target.value.replace("#","");this.#Z.color=J,this.#A(),this.#D()}),this.#J.addEventListener("change",($)=>{$.stopPropagation(),this.#H()});if(this.#j)this.#j.addEventListener("input",($)=>{$.stopPropagation();let J=parseFloat($.target.value),j=(isNaN(J)?100:J)/100;switch(this.#$){case"solid":this.#Z.alpha=j;break;case"gradient":break;case"image":this.#_.opacity=j;break;case"video":this.#X.opacity=j;break;case"webcam":this.#K.opacity=j;break}this.#A(),this.#F(j),this.#D()}),this.#j.addEventListener("change",($)=>{$.stopPropagation(),this.#H()})}#R(){switch(this.#$){case"solid":if(this.#J)this.#J.setAttribute("value",this.#Z.color.slice(1).toUpperCase());if(this.#j)this.#j.setAttribute("value",Math.round(this.#Z.alpha*100));break;case"gradient":{let Q=this.querySelector(".fig-input-fill-label");if(Q){let $=this.#q.type.charAt(0).toUpperCase()+this.#q.type.slice(1);Q.textContent=$}break}case"image":if(this.#j)this.#j.setAttribute("value",Math.round((this.#_.opacity??1)*100));break;case"video":if(this.#j)this.#j.setAttribute("value",Math.round((this.#X.opacity??1)*100));break;case"webcam":if(this.#j)this.#j.setAttribute("value",Math.round((this.#K.opacity??1)*100));break}}#z(){let Q=this.hasAttribute("disabled"),$=this.querySelector(".input-combo");if(!$)return;let J=$.querySelector(".fig-input-fill-label"),Z=$.querySelector(".fig-input-fill-hex"),j=$.querySelector(".fig-input-fill-opacity"),q=$.querySelectorAll("fig-tooltip");J?.remove(),Z?.remove(),q.forEach((Y)=>Y.remove());let _="";switch(this.#$){case"solid":_=`
121
121
  <fig-input-text
122
122
  type="text"
123
123
  class="fig-input-fill-hex"
@@ -183,12 +183,12 @@ var B1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var O1={};var G0=B1(()=>{/*! Vendored from @
183
183
  units="%"
184
184
  ${Q?"disabled":""}>
185
185
  </fig-input-number>
186
- </fig-tooltip>`;break}$.insertAdjacentHTML("beforeend",_),this.#j=this.querySelector(".fig-input-fill-opacity"),this.#J=this.querySelector(".fig-input-fill-hex");let X=this.querySelector(".fig-input-fill-label");if(this.#B(),X&&this.#Q)X.addEventListener("click",()=>{let Y=this.#Q.querySelector("fig-chit");if(Y)Y.click()});if(this.#J)this.#J.addEventListener("input",(Y)=>{Y.stopPropagation();let K="#"+Y.target.value.replace("#","");this.#Z.color=K,this.#O(),this.#R()}),this.#J.addEventListener("change",(Y)=>{Y.stopPropagation(),this.#F()});if(this.#j)this.#j.addEventListener("input",(Y)=>{Y.stopPropagation();let K=parseFloat(Y.target.value),L=(isNaN(K)?100:K)/100;switch(this.#$){case"solid":this.#Z.alpha=L;break;case"gradient":break;case"image":this.#_.opacity=L;break;case"video":this.#X.opacity=L;break;case"webcam":this.#K.opacity=L;break}this.#O(),this.#H(L),this.#R()}),this.#j.addEventListener("change",(Y)=>{Y.stopPropagation(),this.#F()})}#O(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#H(Q){if(this.#Q){let $=this.#Q.querySelector("fig-chit");if($)$.setAttribute("alpha",Q)}}#R(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#F(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#$){case"solid":return{type:"solid",color:this.#Z.color,alpha:this.#Z.alpha,opacity:Math.round(this.#Z.alpha*100)};case"gradient":return{type:"gradient",gradient:w0(this.#q)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#X}};case"webcam":return{type:"webcam",webcam:{...this.#K}};default:return{type:this.#$}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":let Z=this.#$;if(this.#Y(),this.#Q)if(this.#$!==Z)this.#M();else this.#O(),this.#A();break;case"disabled":this.#U();break;case"mode":case"experimental":if(this.#Q)if(J)this.#Q.setAttribute(Q,J);else this.#Q.removeAttribute(Q);break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#B();break}}}customElements.define("fig-input-fill",v0);class h0 extends HTMLElement{#$=[];#Q=[];#j=[];#J=null;#Z=this.#K.bind(this);static get observedAttributes(){return["value","disabled","min","max","open","fixed"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","");else this.removeAttribute("open");if($!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}get#q(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#_(){let Q=parseInt(this.getAttribute("min"));return isNaN(Q)?2:Q}get#X(){let Q=parseInt(this.getAttribute("max"));return isNaN(Q)?8:Q}connectedCallback(){if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.removeEventListener("keydown",this.#Z),this.addEventListener("keydown",this.#Z),this.#J)cancelAnimationFrame(this.#J);this.#J=requestAnimationFrame(()=>{this.#J=null,this.#Y(),this.#W()})}disconnectedCallback(){if(this.#J)cancelAnimationFrame(this.#J),this.#J=null;this.removeEventListener("keydown",this.#Z),this.#Q=[],this.#j=[]}#K(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target!==this&&!Q.target?.closest?.(".palette-colors-inline"))return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.preventDefault(),Q.stopPropagation(),this.open=!0,this.querySelector(".palette-colors-inline")?.setAttribute("aria-expanded","true")}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#Y(),this.#A();break;case"disabled":this.#D();break;case"min":case"max":case"fixed":this.#W();break;case"open":break}}#Y(){let Q=this.getAttribute("value");if(!Q){this.#$=[];return}let $=Q.trim();try{let J=JSON.parse($);if(Array.isArray(J)){this.#$=J.map((Z)=>{if(typeof Z==="string")return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1};if(Z&&typeof Z==="object")return{color:Z.color||"#D9D9D9",alpha:Z.alpha!==void 0?Z.alpha:Z.opacity!==void 0?Z.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch(J){}if($.includes(",")){this.#$=$.split(",").map((J)=>{let Z=J.trim();return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}});return}if($.startsWith("#")){this.#$=[{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1}];return}this.#$=[]}get value(){return this.#$.map((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#W(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#j=[];let $=document.createElement("div");$.className="palette-colors-inline",$.setAttribute("role","button"),$.setAttribute("aria-expanded",String(this.open)),$.setAttribute("aria-label","Edit palette colors");let J=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0,$.setAttribute("aria-expanded","true")};$.addEventListener("click",J),$.addEventListener("keydown",(q)=>{if(q.key!=="Enter"&&q.key!==" ")return;q.preventDefault(),q.stopPropagation(),J()});let Z=document.createElement("div");if(Z.className="palette-colors",this.#$.forEach((q,_)=>{Z.appendChild(this.#N(q,_,Q,{inline:!0}))}),$.appendChild(Z),this.appendChild($),!this.#q)this.#B(Q,this);let j=document.createElement("div");j.className="palette-colors-expanded",this.#$.forEach((q,_)=>{if(j.appendChild(this.#N(q,_,Q)),!this.#q)j.appendChild(this.#L(_,Q))}),this.appendChild(j)}#N(Q,$,J,{inline:Z=!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),Z)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(J)q.setAttribute("disabled","");let _=Z?this.#j:this.#Q,X=(Y)=>{Y.stopPropagation();let K=Y.currentTarget;this.#$[$]={color:K.hexOpaque||this.#$[$].color,alpha:K.rgba?K.rgba.a:this.#$[$].alpha};let N=_[$];if(N){let L=this.#$[$],O=L.alpha<1?L.color+Math.round(L.alpha*255).toString(16).padStart(2,"0"):L.color;N.setAttribute("value",O)}};if(q.addEventListener("input",(Y)=>{X(Y),this.#H()}),q.addEventListener("change",(Y)=>{X(Y),this.#R()}),Z)this.#Q.push(q);else this.#j.push(q);return q}#L(Q,$){let J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Remove color"),J.className="palette-remove-btn",$||this.#$.length<=this.#_)J.setAttribute("disabled","");J.appendChild(v("minus")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#U(Q)});let Z=document.createElement("fig-tooltip");return Z.setAttribute("text","Remove color"),Z.appendChild(J),Z}#U(Q){if(this.#q)return;if(Q<0||Q>=this.#$.length)return;if(this.#$.length<=this.#_)return;this.#$.splice(Q,1),this.#Q=[],this.#j=[],this.#W(),this.#R()}#B(Q,$=this){let J=this.#$.length>=this.#X,Z=document.createElement("fig-button");if(Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Add color"),Z.className="palette-add-btn",Q||J)Z.setAttribute("disabled","");Z.appendChild(v("add")),Z.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#$.length>=this.#X)return;this.open=!0,this.#M({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(Z),$.appendChild(j)}#M(Q){if(this.#q)return;this.#$.push(Q);let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#$.length-1,Z=this.#N(Q,J,$,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(Z);let q=this.#N(Q,J,$),_=this.querySelector(".palette-colors-expanded");if(_)_.appendChild(q),_.appendChild(this.#L(J,$));if(this.#$.length>=this.#X){let X=this.querySelector(".palette-add-btn");if(X)X.setAttribute("disabled","")}this.#O($),this.#R()}#G(Q){let $=this.#$[Q];if(!$)return;let J=$.alpha<1?$.color+Math.round($.alpha*255).toString(16).padStart(2,"0"):$.color,Z=this.#Q[Q];if(Z)Z.setAttribute("value",J);let j=this.#j[Q];if(j)j.setAttribute("value",J)}#A(){if(this.#Q.length!==this.#$.length){this.#W();return}this.#$.forEach((Q,$)=>{this.#G($)})}#D(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#j].forEach((J)=>{if(Q)J.setAttribute("disabled","");else J.removeAttribute("disabled")});let $=this.querySelector(".palette-add-btn");if($)if(Q||this.#$.length>=this.#X)$.setAttribute("disabled","");else $.removeAttribute("disabled");this.#O(Q)}#O(Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let $=Q||this.#$.length<=this.#_;this.querySelectorAll(".palette-remove-btn").forEach((J)=>{if($)J.setAttribute("disabled","");else J.removeAttribute("disabled")})}#H(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}customElements.define("fig-input-palette",h0);class s extends HTMLElement{static SHIFT_SNAP=5;#$;#Q;#j=!1;#J=null;#Z=null;#q=null;#_={type:"linear",angle:90,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode"]}get#X(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#K(){return this.#X==="true"}get#Y(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#W(){if(!this.#Q)return null;return this.#Q.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#N(){if(this.hasAttribute("disabled")){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#K?"-1":"0")}#L(Q){return{...r(Q),type:"linear",angle:90}}connectedCallback(){if(this.#M(),this.#R(),this.removeEventListener("keydown",this.#B),this.addEventListener("keydown",this.#B),this.#K)document.addEventListener("keydown",this.#U)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#U),this.removeEventListener("keydown",this.#B),this.#Z)this.#Z.disconnect(),this.#Z=null;if(this.#q!==null)cancelAnimationFrame(this.#q),this.#q=null;clearTimeout(this.#J),this.removeEventListener("pointerenter",this.#E),this.removeEventListener("pointermove",this.#S),this.removeEventListener("pointerleave",this.#P),this.removeEventListener("click",this.#w),this.removeEventListener("dblclick",this.#I)}#U=(Q)=>{let $=document.activeElement,J=$&&($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;Q.preventDefault();let _=[...this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],X=_.indexOf(q),Y=Q.shiftKey?(X-1+_.length)%_.length:(X+1)%_.length;q.deselect(),_[Y].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;let _=parseInt(q.dataset.stopIndex,10);if(isNaN(_)||!this.#_.stops[_])return;Q.preventDefault();let X=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?s.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.#x(),this.#m(),this.#c();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if(J)return;if(this.#_.stops.length<=2)return;let Z=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!Z)return;let j=parseInt(Z.dataset.stopIndex,10);if(isNaN(j)||!this.#_.stops[j])return;Q.preventDefault(),Z.removeAttribute("selected"),this.#_.stops.splice(j,1),this.#b(),this.#x(),this.#m(),this.#c()};#B=(Q)=>{if(this.#X!=="picker")return;if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.altKey||Q.ctrlKey||Q.metaKey)return;if(this.hasAttribute("disabled"))return;let $=this.querySelector("fig-fill-picker");if(!$||typeof $.open!=="function")return;Q.preventDefault(),$.open()};#M(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($?.type==="gradient"&&$.gradient){this.#_=this.#L({...this.#_,...$.gradient});return}if($?.gradient)this.#_=this.#L({...this.#_,...$.gradient})}catch($){}}#G(){let Q=this.#L(this.#_),J=[...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}=u(q.color);return`rgba(${X}, ${Y}, ${K}, ${_}) ${q.position}%`}).join(", "),Z=b0(Q),j=Z?` ${Z}`:"";return`linear-gradient(${Q.angle}deg${j}, ${J})`}#A(Q){let $=(Q.opacity??100)/100;if($>=1)return Q.color;let{r:J,g:Z,b:j}=u(Q.color);return`rgba(${J}, ${Z}, ${j}, ${$})`}#D(){let Q=this.hasAttribute("disabled"),$=this.#Y==="tip"?' tip="color"':"";return this.#_.stops.map((J,Z)=>`<fig-tooltip action="manual" text="${Math.round(J.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${$} color="${this.#A(J)}" value="${J.position}% 50%" hit-area="4" data-stop-index="${Z}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#O=null;#H=!1;#R(){let Q=this.hasAttribute("disabled"),$=this.#X;if($==="picker"&&m()){let J=this.getAttribute("experimental"),Z=J?` experimental="${J}"`:"",j=JSON.stringify(this.value);this.innerHTML=`
186
+ </fig-tooltip>`;break}$.insertAdjacentHTML("beforeend",_),this.#j=this.querySelector(".fig-input-fill-opacity"),this.#J=this.querySelector(".fig-input-fill-hex");let X=this.querySelector(".fig-input-fill-label");if(this.#U(),X&&this.#Q)X.addEventListener("click",()=>{let Y=this.#Q.querySelector("fig-chit");if(Y)Y.click()});if(this.#J)this.#J.addEventListener("input",(Y)=>{Y.stopPropagation();let K="#"+Y.target.value.replace("#","");this.#Z.color=K,this.#A(),this.#D()}),this.#J.addEventListener("change",(Y)=>{Y.stopPropagation(),this.#H()});if(this.#j)this.#j.addEventListener("input",(Y)=>{Y.stopPropagation();let K=parseFloat(Y.target.value),L=(isNaN(K)?100:K)/100;switch(this.#$){case"solid":this.#Z.alpha=L;break;case"gradient":break;case"image":this.#_.opacity=L;break;case"video":this.#X.opacity=L;break;case"webcam":this.#K.opacity=L;break}this.#A(),this.#F(L),this.#D()}),this.#j.addEventListener("change",(Y)=>{Y.stopPropagation(),this.#H()})}#A(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#F(Q){if(this.#Q){let $=this.#Q.querySelector("fig-chit");if($)$.setAttribute("alpha",Q)}}#D(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#H(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#$){case"solid":return{type:"solid",color:this.#Z.color,alpha:this.#Z.alpha,opacity:Math.round(this.#Z.alpha*100)};case"gradient":return{type:"gradient",gradient:b0(this.#q)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#X}};case"webcam":return{type:"webcam",webcam:{...this.#K}};default:return{type:this.#$}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":let Z=this.#$;if(this.#Y(),this.#Q)if(this.#$!==Z)this.#B();else this.#A(),this.#R();break;case"disabled":this.#G();break;case"mode":case"experimental":if(this.#Q)if(J)this.#Q.setAttribute(Q,J);else this.#Q.removeAttribute(Q);break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#U();break}}}customElements.define("fig-input-fill",h0);class g0 extends HTMLElement{#$=[];#Q=[];#j=[];#J=null;#Z=this.#K.bind(this);static get observedAttributes(){return["value","disabled","min","max","open","fixed"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","");else this.removeAttribute("open");if($!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}get#q(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#_(){let Q=parseInt(this.getAttribute("min"));return isNaN(Q)?2:Q}get#X(){let Q=parseInt(this.getAttribute("max"));return isNaN(Q)?8:Q}connectedCallback(){if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.removeEventListener("keydown",this.#Z),this.addEventListener("keydown",this.#Z),this.#J)cancelAnimationFrame(this.#J);this.#J=requestAnimationFrame(()=>{if(this.#J=null,!this.isConnected)return;this.#Y(),this.#N()})}disconnectedCallback(){if(this.#J)cancelAnimationFrame(this.#J),this.#J=null;this.removeEventListener("keydown",this.#Z),this.#Q=[],this.#j=[]}#K(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target!==this&&!Q.target?.closest?.(".palette-colors-inline"))return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.preventDefault(),Q.stopPropagation(),this.open=!0,this.querySelector(".palette-colors-inline")?.setAttribute("aria-expanded","true")}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#Y(),this.#R();break;case"disabled":this.#z();break;case"min":case"max":case"fixed":this.#N();break;case"open":break}}#Y(){let Q=this.getAttribute("value");if(!Q){this.#$=[];return}let $=Q.trim();try{let J=JSON.parse($);if(Array.isArray(J)){this.#$=J.map((Z)=>{if(typeof Z==="string")return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1};if(Z&&typeof Z==="object")return{color:Z.color||"#D9D9D9",alpha:Z.alpha!==void 0?Z.alpha:Z.opacity!==void 0?Z.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch(J){}if($.includes(",")){this.#$=$.split(",").map((J)=>{let Z=J.trim();return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}});return}if($.startsWith("#")){this.#$=[{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1}];return}this.#$=[]}get value(){return this.#$.map((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#N(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#j=[];let $=document.createElement("div");$.className="palette-colors-inline",$.setAttribute("role","button"),$.setAttribute("aria-expanded",String(this.open)),$.setAttribute("aria-label","Edit palette colors");let J=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0,$.setAttribute("aria-expanded","true")};$.addEventListener("click",J),$.addEventListener("keydown",(q)=>{if(q.key!=="Enter"&&q.key!==" ")return;q.preventDefault(),q.stopPropagation(),J()});let Z=document.createElement("div");if(Z.className="palette-colors",this.#$.forEach((q,_)=>{Z.appendChild(this.#W(q,_,Q,{inline:!0}))}),$.appendChild(Z),this.appendChild($),!this.#q)this.#U(Q,this);let j=document.createElement("div");j.className="palette-colors-expanded",this.#$.forEach((q,_)=>{if(j.appendChild(this.#W(q,_,Q)),!this.#q)j.appendChild(this.#L(_,Q))}),this.appendChild(j)}#W(Q,$,J,{inline:Z=!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),Z)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(J)q.setAttribute("disabled","");let _=Z?this.#j:this.#Q,X=(Y)=>{Y.stopPropagation();let K=Y.currentTarget;this.#$[$]={color:K.hexOpaque||this.#$[$].color,alpha:K.rgba?K.rgba.a:this.#$[$].alpha};let N=_[$];if(N){let L=this.#$[$],O=L.alpha<1?L.color+Math.round(L.alpha*255).toString(16).padStart(2,"0"):L.color;N.setAttribute("value",O)}};if(q.addEventListener("input",(Y)=>{X(Y),this.#F()}),q.addEventListener("change",(Y)=>{X(Y),this.#D()}),Z)this.#Q.push(q);else this.#j.push(q);return q}#L(Q,$){let J=document.createElement("fig-button");if(J.setAttribute("variant","ghost"),J.setAttribute("icon","true"),J.setAttribute("aria-label","Remove color"),J.className="palette-remove-btn",$||this.#$.length<=this.#_)J.setAttribute("disabled","");J.appendChild(h("minus")),J.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#G(Q)});let Z=document.createElement("fig-tooltip");return Z.setAttribute("text","Remove color"),Z.appendChild(J),Z}#G(Q){if(this.#q)return;if(Q<0||Q>=this.#$.length)return;if(this.#$.length<=this.#_)return;this.#$.splice(Q,1),this.#Q=[],this.#j=[],this.#N(),this.#D()}#U(Q,$=this){let J=this.#$.length>=this.#X,Z=document.createElement("fig-button");if(Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Add color"),Z.className="palette-add-btn",Q||J)Z.setAttribute("disabled","");Z.appendChild(h("add")),Z.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#$.length>=this.#X)return;this.open=!0,this.#B({color:"#D9D9D9",alpha:1})});let j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(Z),$.appendChild(j)}#B(Q){if(this.#q)return;this.#$.push(Q);let $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#$.length-1,Z=this.#W(Q,J,$,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(Z);let q=this.#W(Q,J,$),_=this.querySelector(".palette-colors-expanded");if(_)_.appendChild(q),_.appendChild(this.#L(J,$));if(this.#$.length>=this.#X){let X=this.querySelector(".palette-add-btn");if(X)X.setAttribute("disabled","")}this.#A($),this.#D()}#M(Q){let $=this.#$[Q];if(!$)return;let J=$.alpha<1?$.color+Math.round($.alpha*255).toString(16).padStart(2,"0"):$.color,Z=this.#Q[Q];if(Z)Z.setAttribute("value",J);let j=this.#j[Q];if(j)j.setAttribute("value",J)}#R(){if(this.#Q.length!==this.#$.length){this.#N();return}this.#$.forEach((Q,$)=>{this.#M($)})}#z(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#j].forEach((J)=>{if(Q)J.setAttribute("disabled","");else J.removeAttribute("disabled")});let $=this.querySelector(".palette-add-btn");if($)if(Q||this.#$.length>=this.#X)$.setAttribute("disabled","");else $.removeAttribute("disabled");this.#A(Q)}#A(Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let $=Q||this.#$.length<=this.#_;this.querySelectorAll(".palette-remove-btn").forEach((J)=>{if($)J.setAttribute("disabled","");else J.removeAttribute("disabled")})}#F(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#D(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}customElements.define("fig-input-palette",g0);class r extends HTMLElement{static SHIFT_SNAP=5;#$;#Q;#j=!1;#J=null;#Z=null;#q=null;#_={type:"linear",angle:90,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode"]}get#X(){let Q=this.getAttribute("edit");if(Q==="false")return"false";if(Q==="picker")return"picker";return"true"}get#K(){return this.#X==="true"}get#Y(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#N(){if(!this.#Q)return null;return this.#Q.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#W(){if(this.hasAttribute("disabled")){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#K?"-1":"0")}#L(Q){return{...i(Q),type:"linear",angle:90}}connectedCallback(){if(this.#B(),this.#D(),this.removeEventListener("keydown",this.#U),this.addEventListener("keydown",this.#U),this.#K)document.addEventListener("keydown",this.#G)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#G),this.removeEventListener("keydown",this.#U),this.#Z)this.#Z.disconnect(),this.#Z=null;if(this.#q!==null)cancelAnimationFrame(this.#q),this.#q=null;clearTimeout(this.#J),this.removeEventListener("pointerenter",this.#P),this.removeEventListener("pointermove",this.#T),this.removeEventListener("pointerleave",this.#E),this.removeEventListener("click",this.#b),this.removeEventListener("dblclick",this.#x)}#G=(Q)=>{let $=document.activeElement,J=$&&($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;Q.preventDefault();let _=[...this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],X=_.indexOf(q),Y=Q.shiftKey?(X-1+_.length)%_.length:(X+1)%_.length;q.deselect(),_[Y].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!J){let q=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!q)return;let _=parseInt(q.dataset.stopIndex,10);if(isNaN(_)||!this.#_.stops[_])return;Q.preventDefault();let X=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?r.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.#I(),this.#p(),this.#d();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if(J)return;if(this.#_.stops.length<=2)return;let Z=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!Z)return;let j=parseInt(Z.dataset.stopIndex,10);if(isNaN(j)||!this.#_.stops[j])return;Q.preventDefault(),Z.removeAttribute("selected"),this.#_.stops.splice(j,1),this.#w(),this.#I(),this.#p(),this.#d()};#U=(Q)=>{if(this.#X!=="picker")return;if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.altKey||Q.ctrlKey||Q.metaKey)return;if(this.hasAttribute("disabled"))return;let $=this.querySelector("fig-fill-picker");if(!$||typeof $.open!=="function")return;Q.preventDefault(),$.open()};#B(){let Q=this.getAttribute("value");if(!Q)return;try{let $=JSON.parse(Q);if($?.type==="gradient"&&$.gradient){this.#_=this.#L({...this.#_,...$.gradient});return}if($?.gradient)this.#_=this.#L({...this.#_,...$.gradient})}catch($){}}#M(){let Q=this.#L(this.#_),J=[...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}=u(q.color);return`rgba(${X}, ${Y}, ${K}, ${_}) ${q.position}%`}).join(", "),Z=v0(Q),j=Z?` ${Z}`:"";return`linear-gradient(${Q.angle}deg${j}, ${J})`}#R(Q){let $=(Q.opacity??100)/100;if($>=1)return Q.color;let{r:J,g:Z,b:j}=u(Q.color);return`rgba(${J}, ${Z}, ${j}, ${$})`}#z(){let Q=this.hasAttribute("disabled"),$=this.#Y==="tip"?' tip="color"':"";return this.#_.stops.map((J,Z)=>`<fig-tooltip action="manual" text="${Math.round(J.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${$} color="${this.#R(J)}" value="${J.position}% 50%" hit-area="4" data-stop-index="${Z}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#A=null;#F=!1;#D(){let Q=this.hasAttribute("disabled"),$=this.#X;if($==="picker"&&p()){let J=this.getAttribute("experimental"),Z=J?` experimental="${J}"`:"",j=JSON.stringify(this.value);this.innerHTML=`
187
187
  <fig-fill-picker mode="gradient"${Z} value='${j}'${Q?" disabled":""}>
188
- <fig-chit background="${this.#G()}"${Q?" disabled":""}></fig-chit>
189
- </fig-fill-picker>`,this.#$=this.querySelector("fig-chit"),this.#Q=null,this.#F(),this.#N();return}if(this.innerHTML=`
190
- <fig-chit background="${this.#G()}"${Q?" disabled":""}></fig-chit>
191
- ${$==="true"||$==="picker"?`<div class="fig-input-gradient-track">${this.#D()}</div>`:""}`,this.#$=this.querySelector("fig-chit"),this.#Q=this.querySelector(".fig-input-gradient-track"),$==="true"||$==="picker")this.#C(),this.#n();this.#N()}#F(){let Q=this.querySelector("fig-fill-picker");if(!Q)return;Q.anchorElement=this;let $=(J)=>{J.stopPropagation();let Z=J.detail;if(!Z?.gradient)return;this.#_=this.#L({...this.#_,...Z.gradient}),this.#x()};Q.addEventListener("input",(J)=>{$(J),this.#m()}),Q.addEventListener("change",(J)=>{$(J),this.#c()})}#z(Q){return E1(this.#_.stops,Q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#C(){if(!this.#Q||this.hasAttribute("disabled"))return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#Y==="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.#E),this.addEventListener("pointermove",this.#S),this.addEventListener("pointerleave",this.#P),this.addEventListener("click",this.#w),this.addEventListener("dblclick",this.#I)}#k(){if(!this.#O)return;this.#O.style.opacity="1"}#T(){if(!this.#O)return;this.#O.style.opacity="0"}#E=()=>{if(this.#j)return;this.#k()};#P=()=>{this.#T()};#S=(Q)=>{if(this.#j){this.#T();return}if(!this.#O||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#T();return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width));this.#O.style.left=`${J*100}%`;let Z=this.#z(J);this.#O.setAttribute("color",Z),this.#k()};#f(){let Q=this.#_.stops.length;if(Q<2)return;for(let $=0;$<Q;$++)this.#_.stops[$].position=Math.round($/(Q-1)*100);this.#b(),this.#x(),this.#m(),this.#c()}#I=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#f(),this.#Q.querySelectorAll("fig-handle[selected]").forEach(($)=>{$.removeAttribute("selected")})};#w=(Q)=>{if(!this.#Q)return;if(this.#j)return;if(this.#H){this.#H=!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.#f(),!isNaN(X))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(parseInt(Y.dataset.stopIndex,10)===X)Y.select();else Y.deselect()});Q.stopPropagation()}return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#z(J);this.#_.stops.push({position:Z,color:j,opacity:100}),this.#_.stops.sort((_,X)=>_.position-X.position);let q=this.#_.stops.findIndex((_)=>_.position===Z&&_.color===j);this.#b(),this.#x(),this.#m(),this.#c(),requestAnimationFrame(()=>{let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)X.click()})};#V(){if(this.#q=null,!this.isConnected)return;if(!this.#Q)return;let Q=this.#_.stops;this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($,J)=>{if(J>=Q.length)return;$.removeAttribute("value"),$.setAttribute("value",`${Q[J].position}% 50%`)})}refreshLayout(){this.#V()}#y(){if(this.#q!==null)return;this.#q=requestAnimationFrame(()=>this.#V())}#b(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#_.stops;if(Q.length!==$.length){let J=this.#O;if(this.#Q.innerHTML=this.#D(),J)this.#Q.appendChild(J);this.#g(),this.#v(),this.#y();return}for(let J=0;J<$.length;J++){let Z=Q[J],j=$[J];if(Z.dataset.stopIndex=J,Z.setAttribute("value",`${j.position}% 50%`),Z.setAttribute("color",this.#A(j)),this.#Y==="tip")Z.setAttribute("tip","color");else Z.removeAttribute("tip");let q=Z.closest("fig-tooltip");if(q)q.setAttribute("text",`${Math.round(j.position)}%`)}this.#g()}#g(){if(!this.#Q)return;let Q=this.#Y==="tip";if(this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($)=>{if(Q)$.setAttribute("tip","color");else $.removeAttribute("tip")}),this.#O)if(Q)this.#O.setAttribute("tip","add");else this.#O.removeAttribute("tip")}#v(){if(!this.#Z||!this.#Q)return;this.#Z.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#Z.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#h(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#_.stops,J=new Set;Q.forEach((Z)=>{let j=Math.round(parseFloat(Z.getAttribute("value"))||0),q=(Z.getAttribute("color")||"").toUpperCase(),_=-1;for(let X=0;X<$.length;X++){if(J.has(X))continue;if($[X].position===j&&$[X].color.toUpperCase()===q){_=X;break}}if(_===-1){let X=1/0;for(let Y=0;Y<$.length;Y++){if(J.has(Y))continue;let K=Math.abs($[Y].position-j);if(K<X)X=K,_=Y}}if(_!==-1)J.add(_),Z.dataset.stopIndex=_})}#x(){if(!this.#$)return;this.#$.setAttribute("background",this.#G())}#n(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(this.hasAttribute("disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#z(J);this.#_.stops.push({position:Z,color:j,opacity:100}),this.#_.stops.sort((Y,K)=>Y.position-K.position);let q=this.#_.stops.findIndex((Y)=>Y.position===Z&&Y.color===j);this.#H=!0,this.#b(),this.#x(),this.#m(),this.#T();let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(Y!==X)Y.deselect()}),X.select(),X.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:Q.clientX,clientY:Q.clientY,pointerId:Q.pointerId,pointerType:Q.pointerType,button:Q.button,buttons:Q.buttons}))}),this.#Q.addEventListener("input",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt($.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;$.setAttribute("color",this.#A(this.#_.stops[Y])),this.#x(),this.#m()}return}if(!this.#j)$.style.zIndex="5";this.#j=!0;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])return;let Z=Q.detail?.px??0,j=Math.round(Z*100),q=j,_=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)q=Math.round(q/s.SHIFT_SNAP)*s.SHIFT_SNAP;else{let Y=_>0?5/_*100:0;for(let K=0;K<this.#_.stops.length;K++){if(K===J)continue;if(Math.abs(this.#_.stops[K].position-q)<=Y){q=this.#_.stops[K].position;break}}}if(this.#_.stops[J].position=q,q!==j)$.style.left=`${q/100*_}px`;let X=$.closest("fig-tooltip");if(X){if(X.text=`${Math.round(q)}%`,!X.hasAttribute("show"))X.setAttribute("show","true"),$.hideColorTip()}this.#x(),this.#m()}),this.#Q.addEventListener("change",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt($.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;$.setAttribute("color",this.#A(this.#_.stops[Y])),this.#x(),this.#c()}return}$.style.zIndex="";let J=$.closest("fig-tooltip");if(J)J.removeAttribute("show");$.showColorTip();let Z=parseInt($.dataset.stopIndex,10);if(isNaN(Z)||!this.#_.stops[Z])return;let j=Q.detail?.px??0,q=Math.round(j*100),_=this.#Q.getBoundingClientRect().width,X=_>0?5/_*100:0;for(let Y=0;Y<this.#_.stops.length;Y++){if(Y===Z)continue;if(Math.abs(this.#_.stops[Y].position-q)<=X){q=this.#_.stops[Y].position;break}}this.#_.stops[Z].position=q,$.style.left=`${q/100*_}px`,this.#_.stops.sort((Y,K)=>Y.position-K.position),this.#h(),this.#x(),this.#c(),requestAnimationFrame(()=>{this.#j=!1})}),this.#Z=new MutationObserver((Q)=>{for(let $ of Q){if($.attributeName!=="color")continue;let J=$.target;if(J.classList.contains("fig-input-gradient-ghost"))continue;let Z=parseInt(J.dataset.stopIndex,10);if(isNaN(Z)||!this.#_.stops[Z])continue;let j=J.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#_.stops[Z].color)this.#_.stops[Z].color=j,this.#x(),this.#m()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#Z.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#m(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#c(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:w0(this.#L(this.#_))}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}focus(Q){if(this.hasAttribute("disabled"))return;if(this.#K){let $=this.#W();if($){$.focus(Q);return}}HTMLElement.prototype.focus.call(this,Q)}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#M(),this.#x(),this.#b();break;case"disabled":this.#d();break;case"edit":if(this.#R(),this.#K)document.addEventListener("keydown",this.#U);else document.removeEventListener("keydown",this.#U);break;case"mode":this.#g();break}}#d(){let Q=this.hasAttribute("disabled");if(this.#N(),this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#Q)for(let $ of this.#Q.querySelectorAll("fig-handle"))if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}customElements.define("fig-input-gradient",s);class t extends HTMLElement{#$=null;#Q;constructor(){super();this.input=document.createElement("input"),this.name=this.getAttribute("name")||"checkbox",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",y()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","checkbox"),this.#Q=this.handleInput.bind(this)}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.#q();let $=this.querySelector(":scope > label");if($)this.#$=$,this.#$.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#j(),this.#$.innerText=this.getAttribute("label");this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#j(){if(!this.#$)this.#$=document.createElement("label"),this.#$.setAttribute("for",this.input.id);if(this.#$&&!this.#$.parentNode&&this.input.parentNode)this.input.after(this.#$)}render(){}#J(Q){return this.hasAttribute(Q)&&this.getAttribute(Q)!=="false"}#Z(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#q(){let Q=this.#J("checked"),$=this.#J("indeterminate")&&!Q,J=this.#J("disabled");if(this.input.checked=Q,this.input.indeterminate=$,this.input.disabled=J,this.input.value=this.getAttribute("value")||"",this.input.setAttribute("name",this.getAttribute("name")||this.name),$)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#Z()}focus(){this.input.focus()}get value(){return this.input.value}set value(Q){this.input.value=Q,this.setAttribute("value",Q)}get checked(){return this.input.checked}set checked(Q){if(this.input.checked=Q,Q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("change",this.#Q),this.input.remove()}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(J)this.#j(),this.#$.innerText=J;else if(this.#$)this.#$.remove(),this.#$=null;break;case"checked":if(this.#J("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#q();break;case"indeterminate":this.#q();break;case"disabled":this.#q();break;case"name":this.input.setAttribute("name",J||this.name);break;case"value":this.input.value=J||"";break;default:this.input[Q]=J,this.input.setAttribute(Q,J);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#Z(),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}customElements.define("fig-checkbox",t);class g0 extends t{constructor(){super();this.input.setAttribute("type","radio"),this.input.setAttribute("name",this.getAttribute("name")||"radio")}}customElements.define("fig-radio",g0);class m0 extends t{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}customElements.define("fig-switch",m0);class p0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#$=!1;#Q=null;#j=null;#J=null;#Z=null;#q=!1;#_=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#X=this.#U.bind(this);#K=this.#B.bind(this);#Y=this.#M.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(this.#Z=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#$=this.#Z!==null,this.#Z)this.#Z.remove();if(this.#W(),this.#N(),this.hasAttribute("disabled"))this.#F(!0)}disconnectedCallback(){this.#L()}#W(){let Q=this.#D(),$=this.getAttribute("placeholder")||"",J=this.value,Z=this.getAttribute("experimental"),j=Z?` experimental="${Z}"`:"",q=this.#H(),_=this.#$?"":`<fig-dropdown type="dropdown" label="${q}"${j}>${Q.map((X)=>`<option>${X.trim()}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
188
+ <fig-chit background="${this.#M()}"${Q?" disabled":""}></fig-chit>
189
+ </fig-fill-picker>`,this.#$=this.querySelector("fig-chit"),this.#Q=null,this.#H(),this.#W();return}if(this.innerHTML=`
190
+ <fig-chit background="${this.#M()}"${Q?" disabled":""}></fig-chit>
191
+ ${$==="true"||$==="picker"?`<div class="fig-input-gradient-track">${this.#z()}</div>`:""}`,this.#$=this.querySelector("fig-chit"),this.#Q=this.querySelector(".fig-input-gradient-track"),$==="true"||$==="picker")this.#k(),this.#m();this.#W()}#H(){let Q=this.querySelector("fig-fill-picker");if(!Q)return;Q.anchorElement=this;let $=(J)=>{J.stopPropagation();let Z=J.detail;if(!Z?.gradient)return;this.#_=this.#L({...this.#_,...Z.gradient}),this.#I()};Q.addEventListener("input",(J)=>{$(J),this.#p()}),Q.addEventListener("change",(J)=>{$(J),this.#d()})}#O(Q){return C1(this.#_.stops,Q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#k(){if(!this.#Q||this.hasAttribute("disabled"))return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#Y==="tip")Q.setAttribute("tip","add");Q.style.position="absolute",Q.style.top="50%",Q.style.transform="translate(-50%, -50%)",Q.style.pointerEvents="none",Q.style.opacity="0",Q.style.transition="opacity 0.15s",this.#Q.appendChild(Q),this.#A=Q,this.addEventListener("pointerenter",this.#P),this.addEventListener("pointermove",this.#T),this.addEventListener("pointerleave",this.#E),this.addEventListener("click",this.#b),this.addEventListener("dblclick",this.#x)}#S(){if(!this.#A)return;this.#A.style.opacity="1"}#f(){if(!this.#A)return;this.#A.style.opacity="0"}#P=()=>{if(this.#j)return;this.#S()};#E=()=>{this.#f()};#T=(Q)=>{if(this.#j){this.#f();return}if(!this.#A||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#f();return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width));this.#A.style.left=`${J*100}%`;let Z=this.#O(J);this.#A.setAttribute("color",Z),this.#S()};#C(){let Q=this.#_.stops.length;if(Q<2)return;for(let $=0;$<Q;$++)this.#_.stops[$].position=Math.round($/(Q-1)*100);this.#w(),this.#I(),this.#p(),this.#d()}#x=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#C(),this.#Q.querySelectorAll("fig-handle[selected]").forEach(($)=>{$.removeAttribute("selected")})};#b=(Q)=>{if(!this.#Q)return;if(this.#j)return;if(this.#F){this.#F=!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.#C(),!isNaN(X))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(parseInt(Y.dataset.stopIndex,10)===X)Y.select();else Y.deselect()});Q.stopPropagation()}return}let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#O(J);this.#_.stops.push({position:Z,color:j,opacity:100}),this.#_.stops.sort((_,X)=>_.position-X.position);let q=this.#_.stops.findIndex((_)=>_.position===Z&&_.color===j);this.#w(),this.#I(),this.#p(),this.#d(),requestAnimationFrame(()=>{let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)X.click()})};#V(){if(this.#q=null,!this.isConnected)return;if(!this.#Q)return;let Q=this.#_.stops;this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($,J)=>{if(J>=Q.length)return;$.removeAttribute("value"),$.setAttribute("value",`${Q[J].position}% 50%`)})}refreshLayout(){this.#V()}#y(){if(this.#q!==null)return;this.#q=requestAnimationFrame(()=>this.#V())}#w(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#_.stops;if(Q.length!==$.length){let J=this.#A;if(this.#Q.innerHTML=this.#z(),J)this.#Q.appendChild(J);this.#h(),this.#g(),this.#y();return}for(let J=0;J<$.length;J++){let Z=Q[J],j=$[J];if(Z.dataset.stopIndex=J,Z.setAttribute("value",`${j.position}% 50%`),Z.setAttribute("color",this.#R(j)),this.#Y==="tip")Z.setAttribute("tip","color");else Z.removeAttribute("tip");let q=Z.closest("fig-tooltip");if(q)q.setAttribute("text",`${Math.round(j.position)}%`)}this.#h()}#h(){if(!this.#Q)return;let Q=this.#Y==="tip";if(this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach(($)=>{if(Q)$.setAttribute("tip","color");else $.removeAttribute("tip")}),this.#A)if(Q)this.#A.setAttribute("tip","add");else this.#A.removeAttribute("tip")}#g(){if(!this.#Z||!this.#Q)return;this.#Z.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#Z.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#v(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#_.stops,J=new Set;Q.forEach((Z)=>{let j=Math.round(parseFloat(Z.getAttribute("value"))||0),q=(Z.getAttribute("color")||"").toUpperCase(),_=-1;for(let X=0;X<$.length;X++){if(J.has(X))continue;if($[X].position===j&&$[X].color.toUpperCase()===q){_=X;break}}if(_===-1){let X=1/0;for(let Y=0;Y<$.length;Y++){if(J.has(Y))continue;let K=Math.abs($[Y].position-j);if(K<X)X=K,_=Y}}if(_!==-1)J.add(_),Z.dataset.stopIndex=_})}#I(){if(!this.#$)return;this.#$.setAttribute("background",this.#M())}#m(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(this.hasAttribute("disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#O(J);this.#_.stops.push({position:Z,color:j,opacity:100}),this.#_.stops.sort((Y,K)=>Y.position-K.position);let q=this.#_.stops.findIndex((Y)=>Y.position===Z&&Y.color===j);this.#F=!0,this.#w(),this.#I(),this.#p(),this.#f();let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(Y!==X)Y.deselect()}),X.select(),X.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:Q.clientX,clientY:Q.clientY,pointerId:Q.pointerId,pointerType:Q.pointerType,button:Q.button,buttons:Q.buttons}))}),this.#Q.addEventListener("input",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt($.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;$.setAttribute("color",this.#R(this.#_.stops[Y])),this.#I(),this.#p()}return}if(!this.#j)$.style.zIndex="5";this.#j=!0;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])return;let Z=Q.detail?.px??0,j=Math.round(Z*100),q=j,_=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)q=Math.round(q/r.SHIFT_SNAP)*r.SHIFT_SNAP;else{let Y=_>0?5/_*100:0;for(let K=0;K<this.#_.stops.length;K++){if(K===J)continue;if(Math.abs(this.#_.stops[K].position-q)<=Y){q=this.#_.stops[K].position;break}}}if(this.#_.stops[J].position=q,q!==j)$.style.left=`${q/100*_}px`;let X=$.closest("fig-tooltip");if(X){if(X.text=`${Math.round(q)}%`,!X.hasAttribute("show"))X.setAttribute("show","true"),$.hideColorTip()}this.#I(),this.#p()}),this.#Q.addEventListener("change",(Q)=>{let $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt($.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;$.setAttribute("color",this.#R(this.#_.stops[Y])),this.#I(),this.#d()}return}$.style.zIndex="";let J=$.closest("fig-tooltip");if(J)J.removeAttribute("show");$.showColorTip();let Z=parseInt($.dataset.stopIndex,10);if(isNaN(Z)||!this.#_.stops[Z])return;let j=Q.detail?.px??0,q=Math.round(j*100),_=this.#Q.getBoundingClientRect().width,X=_>0?5/_*100:0;for(let Y=0;Y<this.#_.stops.length;Y++){if(Y===Z)continue;if(Math.abs(this.#_.stops[Y].position-q)<=X){q=this.#_.stops[Y].position;break}}this.#_.stops[Z].position=q,$.style.left=`${q/100*_}px`,this.#_.stops.sort((Y,K)=>Y.position-K.position),this.#v(),this.#I(),this.#d(),requestAnimationFrame(()=>{this.#j=!1})}),this.#Z=new MutationObserver((Q)=>{for(let $ of Q){if($.attributeName!=="color")continue;let J=$.target;if(J.classList.contains("fig-input-gradient-ghost"))continue;let Z=parseInt(J.dataset.stopIndex,10);if(isNaN(Z)||!this.#_.stops[Z])continue;let j=J.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#_.stops[Z].color)this.#_.stops[Z].color=j,this.#I(),this.#p()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#Z.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#p(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#d(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:b0(this.#L(this.#_))}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}focus(Q){if(this.hasAttribute("disabled"))return;if(this.#K){let $=this.#N();if($){$.focus(Q);return}}HTMLElement.prototype.focus.call(this,Q)}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#B(),this.#I(),this.#w();break;case"disabled":this.#s();break;case"edit":if(this.#D(),this.#K)document.addEventListener("keydown",this.#G);else document.removeEventListener("keydown",this.#G);break;case"mode":this.#h();break}}#s(){let Q=this.hasAttribute("disabled");if(this.#W(),this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#Q)for(let $ of this.#Q.querySelectorAll("fig-handle"))if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}customElements.define("fig-input-gradient",r);class n extends HTMLElement{#$=null;#Q;constructor(){super();this.input=document.createElement("input"),this.name=this.getAttribute("name")||"checkbox",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",y()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","checkbox"),this.#Q=this.handleInput.bind(this)}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.#q();let $=this.querySelector(":scope > label");if($)this.#$=$,this.#$.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#j(),this.#$.innerText=this.getAttribute("label");this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#j(){if(!this.#$)this.#$=document.createElement("label"),this.#$.setAttribute("for",this.input.id);if(this.#$&&!this.#$.parentNode&&this.input.parentNode)this.input.after(this.#$)}render(){}#J(Q){return this.hasAttribute(Q)&&this.getAttribute(Q)!=="false"}#Z(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#q(){let Q=this.#J("checked"),$=this.#J("indeterminate")&&!Q,J=this.#J("disabled");if(this.input.checked=Q,this.input.indeterminate=$,this.input.disabled=J,this.input.value=this.getAttribute("value")||"",this.input.setAttribute("name",this.getAttribute("name")||this.name),$)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#Z()}focus(){this.input.focus()}get value(){return this.input.value}set value(Q){this.input.value=Q,this.setAttribute("value",Q)}get checked(){return this.input.checked}set checked(Q){if(this.input.checked=Q,Q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("change",this.#Q),this.input.remove()}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(J)this.#j(),this.#$.innerText=J;else if(this.#$)this.#$.remove(),this.#$=null;break;case"checked":if(this.#J("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#q();break;case"indeterminate":this.#q();break;case"disabled":this.#q();break;case"name":this.input.setAttribute("name",J||this.name);break;case"value":this.input.value=J||"";break;default:this.input[Q]=J,this.input.setAttribute(Q,J);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#Z(),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}customElements.define("fig-checkbox",n);class m0 extends n{constructor(){super();this.input.setAttribute("type","radio"),this.input.setAttribute("name",this.getAttribute("name")||"radio")}}customElements.define("fig-radio",m0);class p0 extends n{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}customElements.define("fig-switch",p0);class c0 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","experimental","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#$=!1;#Q=null;#j=null;#J=null;#Z=null;#q=!1;#_=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#X=this.#B.bind(this);#K=this.#M.bind(this);#Y=this.#R.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}#N(){return!!this.querySelector(":scope > .input-combo")}#W(){if(this.#Q=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#j=this.querySelector("fig-dropdown"),this.#Q)this.#Q.setAttribute("value",this.value),this.#Q.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#O()}connectedCallback(){if(this.#Z=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#$=this.#Z!==null,this.#Z)this.#Z.remove();if(this.#N())this.#W(),this.#G();else this.#L(),this.#G();if(this.hasAttribute("disabled"))this.#k(!0)}disconnectedCallback(){this.#U()}#L(){let Q=this.#F(),$=this.getAttribute("placeholder")||"",J=this.value,Z=this.getAttribute("experimental"),j=Z?` experimental="${Z}"`:"",q=this.#H(),_=this.#$?"":`<fig-dropdown type="dropdown" label="${q}"${j}>${Q.map((X)=>`<option>${X.trim()}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
192
192
  <fig-input-text placeholder="${$}" value="${J}"></fig-input-text>
193
193
  <fig-button type="select" variant="input" icon>
194
194
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -196,7 +196,7 @@ var B1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var O1={};var G0=B1(()=>{/*! Vendored from @
196
196
  </svg>
197
197
  ${_}
198
198
  </fig-button>
199
- </div>`,this.#Q=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#$&&this.#Z&&this.#J){if(!this.#Z.hasAttribute("type"))this.#Z.setAttribute("type","dropdown");if(!this.#Z.hasAttribute("label"))this.#Z.setAttribute("label",q);if(Z)this.#Z.setAttribute("experimental",Z);this.#J.append(this.#Z)}this.#j=this.querySelector("fig-dropdown"),this.#R()}#N(){this.#j?.addEventListener("input",this.#X),this.#Q?.addEventListener("input",this.#K),this.#Q?.addEventListener("change",this.#Y)}#L(){this.#j?.removeEventListener("input",this.#X),this.#Q?.removeEventListener("input",this.#K),this.#Q?.removeEventListener("change",this.#Y)}#U(Q){Q.stopPropagation();let $=Q.target.closest("fig-dropdown")?.value??"";if(this.#q=!0,this.setAttribute("value",$),this.#q=!1,this.#Q)this.#Q.setAttribute("value",$);this.#G(),this.#A()}#B(Q){Q.stopPropagation();let $=Q.target.value??"";this.#q=!0,this.setAttribute("value",$),this.#q=!1,this.#G()}#M(Q){Q.stopPropagation();let $=Q.target.value??"";this.#q=!0,this.setAttribute("value",$),this.#q=!1,this.#A()}#G(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#A(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#D(){return(this.getAttribute("options")||"").split(",").map((Q)=>Q.trim()).filter(Boolean)}#O(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#H(){return`${this.#O()} options`}#R(){if(this.#Q)this.#_.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,$)});if(this.#j&&!this.#j.hasAttribute("aria-label"))this.#j.setAttribute("label",this.#H())}#F(Q){if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");if(this.#j)if(Q)this.#j.setAttribute("disabled","");else this.#j.removeAttribute("disabled")}focus(){this.#Q?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"options":if(this.#j&&!this.#$){let Z=this.#D();this.#j.innerHTML=Z.map((j)=>`<option>${j}</option>`).join("")}break;case"placeholder":if(this.#Q)this.#Q.setAttribute("placeholder",J||"");this.#R();break;case"value":if(!this.#q&&this.#Q)this.#Q.setAttribute("value",J||"");break;case"disabled":this.#F(J!==null&&J!=="false");break;case"experimental":if(this.#j){if(J)this.#j.setAttribute("experimental",J);else if(!this.#$)this.#j.removeAttribute("experimental")}break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#R();break}}}customElements.define("fig-combo-input",p0);class j0 extends HTMLElement{#$="color";#Q=null;#j=!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.#X(),this.#J(),this.#K()}#J(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#Z(Q){if(!Q)return"color";let $=Q.toLowerCase();if($.includes("gradient"))return"gradient";if($.includes("url("))return"image";return"color"}#q(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:$}=Z0(1,1);return $.fillStyle=Q,$.fillStyle}catch{return"#D9D9D9"}}#_(Q){if(!Q||!Q.includes("var("))return Q;let $=this.style.background;this.style.background=Q;let J=getComputedStyle(this),Z=J.backgroundImage,j=J.backgroundColor;if(this.style.background=$,Z&&Z!=="none")return Z;return j||Q}#X(){let Q=this.getAttribute("background")||"#D9D9D9",$=Q.includes("var("),J=$?this.#_(Q):Q,Z=this.#Z(J);if(Z!==this.#$||!this.input){if(this.#$=Z,this.setAttribute("data-type",this.#$),this.input)this.input.removeEventListener("input",this.#Q);if(this.#$==="color"){let q=this.#q(J);if(this.innerHTML=`<div></div><input type="color" value="${q}" />`,this.input=this.querySelector("input"),!$)this.input.addEventListener("input",this.#Q);this.#K()}else this.innerHTML="<div></div>",this.input=null,this.#K()}else if(this.#$==="color"&&this.input){let q=this.#q(J);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("--chit-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#K(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",Q?"true":"false"),this.input){this.input.disabled=Q;let $=this.getAttribute("aria-labelledby"),J=this.getAttribute("aria-label")||"Color swatch",Z=this.getAttribute("aria-describedby");if($)this.input.setAttribute("aria-labelledby",$),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",J),this.input.removeAttribute("aria-labelledby");if(Z)this.input.setAttribute("aria-describedby",Z);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.#j=!0,this.setAttribute("background",Q.target.value),this.#j=!1}get background(){return this.getAttribute("background")}set background(Q){this.setAttribute("background",Q)}focus(){this.input?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="background"){if(this.#j){let Z=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(J);this.style.setProperty("--chit-background",Z?J:`linear-gradient(${J}, ${J})`);return}this.#X()}else if(Q==="alpha")this.#J();else if(Q==="disabled"||Q==="aria-label"||Q==="aria-labelledby"||Q==="aria-describedby")this.#K()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",Q)}}customElements.define("fig-chit",j0);class u0 extends j0{}customElements.define("fig-swatch",u0);class n extends HTMLElement{#$=null;#Q=null;#j=null;#J=null;#Z=null;#q=null;#_=null;#X=this.#V.bind(this);#K=this.#b.bind(this);#Y=this.#g.bind(this);#W=this.#v.bind(this);#N=null;#L=null;#U=null;#B=null;#M=null;#G=null;#A=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","controls","autoplay","loop","muted","poster","aria-label","aria-labelledby","title"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#$}set src(Q){if(this.#$=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#_}#D(){return this.#q||this.#$||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#D())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((Z,j)=>{this.#Q.addEventListener("load",Z,{once:!0}),this.#Q.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Q.naturalWidth,$=this.#Q.naturalHeight;if(!(Q>0)||!($>0))return null;let J=document.createElement("canvas");return J.width=Q,J.height=$,J.getContext("2d").drawImage(this.#Q,0,0),J.toDataURL()}connectedCallback(){this.#$=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 $=this.getAttribute("fit");if($)this.style.setProperty("--fig-media-fit",$);if(this.querySelectorAll("fig-chit[data-generated]").forEach((Z)=>Z.remove()),this.#H(),this.#F(),this.#k(),this.#z(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#I()}disconnectedCallback(){if(this.#J?.removeEventListener("change",this.#X),this.#O(),this.#f(),this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null;this.#q=null}#O(){if(!this.#Q)return;if(this.#Q.tagName==="VIDEO")this.#Q.removeEventListener("play",this.#K),this.#Q.removeEventListener("pause",this.#Y),this.#Q.removeEventListener("ended",this.#W)}#H(){if(this.#j?.isConnected)return;let Q=this.querySelector(":scope > fig-preview");if(Q){this.#j=Q;return}let $=document.createElement("fig-preview");$.setAttribute("data-generated",""),this.prepend($),this.#j=$}#R(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#F(){let Q=this.#R();if(Q){if(this.#H(),this.#Q&&this.#Q!==Q){if(this.#O(),this.#Q.hasAttribute("data-generated"))this.#Q.remove()}if(this.#Q=Q,this.#j&&Q.parentElement!==this.#j)this.#j.append(Q);this.#z();return}this.#H();let $=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Q&&this.#Q.tagName!==$){if(this.#O(),this.#Q.hasAttribute("data-generated"))this.#Q.remove();this.#Q=null}if(this.#Q)return;if(this.mediaKind==="video"){let J=document.createElement("video");J.setAttribute("data-generated",""),J.className="fig-media-element",J.setAttribute("playsinline",""),J.preload="auto",this.#j.append(J),this.#Q=J,this.#Q.addEventListener("play",this.#K),this.#Q.addEventListener("pause",this.#Y),this.#Q.addEventListener("ended",this.#W);let Z=()=>{if(this.#Q?.autoplay)return;try{this.#Q.currentTime=0.001}catch{}};this.#Q.addEventListener("loadedmetadata",Z,{once:!0})}else{let J=document.createElement("img");J.setAttribute("data-generated",""),J.className="fig-media-element",J.loading="lazy",J.decoding="async",J.alt=this.getAttribute("alt")||"",this.#j.append(J),this.#Q=J}}#z(){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 $=this.getAttribute(Q);if($===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,$)})}#C(Q,$=!1){if(!this.hasAttribute(Q))return $;return this.getAttribute(Q)!=="false"}#k(){if(!this.#Q)return;if(!this.#Q.hasAttribute("data-generated"))return;let Q=this.#D();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.#z();return}let $=this.getAttribute("poster");if($)this.#Q.setAttribute("poster",$);else this.#Q.removeAttribute("poster");this.#Q.controls=!1,this.#Q.removeAttribute("controls"),this.#Q.autoplay=this.#C("autoplay",!1),this.#Q.loop=this.#C("loop",!1),this.#Q.muted=this.#C("muted",!1),this.#Q.playsInline=!0,this.#z(),this.#T()}get mediaEl(){return this.#Q}#T(){if(this.mediaKind!=="video"){this.#f();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#N!==Q)this.#f(),this.#N=Q;this.#P();return}if(this.#C("controls",!1))this.#E();else this.#f()}#E(){if(this.#N&&this.#N.isConnected){this.#P();return}let Q=document.createElement("fig-media-controls");Q.setAttribute("data-generated",""),this.append(Q),this.#N=Q,this.#P()}#P(){if(!this.#N||!this.#Q)return;if(this.#L===this.#Q&&this.#U===this.#N)return;this.#S();let Q=this.#N,$=this.#Q;this.#L=$,this.#U=Q;let J=null,Z=()=>{if(Q.playing=!$.paused&&!$.ended,Number.isFinite($.duration))Q.duration=$.duration;if(J!==null)if(Math.abs($.currentTime-J)<0.25)J=null;else return;Q.time=$.currentTime||0},j=()=>{let X=$.play?.();if(X&&typeof X.catch==="function")X.catch(()=>{})},q=()=>$.pause?.(),_=(X)=>{let Y=Number(X?.detail?.time);if(!Number.isFinite(Y))return;J=Y;try{$.currentTime=Y}catch{}};this.#B=Z,this.#M=j,this.#G=q,this.#A=_,$.addEventListener("play",Z),$.addEventListener("pause",Z),$.addEventListener("ended",Z),$.addEventListener("timeupdate",Z),$.addEventListener("loadedmetadata",Z),$.addEventListener("durationchange",Z),$.addEventListener("seeked",Z),Q.addEventListener("play",j),Q.addEventListener("pause",q),Q.addEventListener("seek",_),Z()}#S(){let Q=this.#L,$=this.#U;if(Q&&this.#B)Q.removeEventListener("play",this.#B),Q.removeEventListener("pause",this.#B),Q.removeEventListener("ended",this.#B),Q.removeEventListener("timeupdate",this.#B),Q.removeEventListener("loadedmetadata",this.#B),Q.removeEventListener("durationchange",this.#B),Q.removeEventListener("seeked",this.#B);if($){if(this.#M)$.removeEventListener("play",this.#M);if(this.#G)$.removeEventListener("pause",this.#G);if(this.#A)$.removeEventListener("seek",this.#A)}this.#L=null,this.#U=null,this.#B=null,this.#M=null,this.#G=null,this.#A=null}#f(){if(this.#S(),!this.#N)return;if(this.#N.hasAttribute("data-generated"))this.#N.remove();this.#N=null}toggle(){if(!this.#Q||this.mediaKind!=="video")return;if(this.#Q.paused||this.#Q.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Q)return;let Q=this.#Q.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Q)return;this.#Q.pause()}#I(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let $=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#$?"Replace":$),this.#_?.name)Q.setAttribute("filename",this.#_.name);else if(this.#$)Q.setAttribute("url",this.#$);Q.addEventListener("change",this.#X),this.#H(),this.#j.append(Q),this.#J=Q}#w(){if(this.#J)this.#J.removeEventListener("change",this.#X),this.#J.remove(),this.#J=null}#V(Q){if(Q.target!==this.#J)return;let $=Q.detail?.files?.[0],J=Q.detail?.cleared===!0;if(!$){if(this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null;if(this.#_=null,this.#q=null,J)this.src="";if(this.#k(),this.#J){let Z=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":Z),this.#J.removeAttribute("filename"),this.#$)this.#J.setAttribute("url",this.#$);else this.#J.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#Z)URL.revokeObjectURL(this.#Z);if(this.#_=$,this.#Z=URL.createObjectURL($),this.#q=this.#Z,this.#k(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:$,src:this.#Z}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#J)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",$.name),this.#J.setAttribute("label","Replace")}#y(Q){if(!this.#Q)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#$||"",currentTime:this.#Q.currentTime,duration:this.#Q.duration}}))}#b(){this.#y("play")}#g(){this.#y("pause")}#v(){this.#y("ended")}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="src"){let Z=J||"",j=Z&&(Z===this.#q||Z===this.#Z);if(this.#$=Z,this.#Z&&!j)URL.revokeObjectURL(this.#Z),this.#Z=null,this.#q=null,this.#_=null;if(this.#k(),this.#J){let q=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":q),this.#$)if(this.#_?.name)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",this.#_.name);else this.#J.setAttribute("url",this.#$),this.#J.removeAttribute("filename");else this.#J.removeAttribute("url"),this.#J.removeAttribute("filename")}}if(Q==="type"){if(this.#F(),this.#k(),this.#J)this.#J.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(Q))this.#z();if(Q==="upload"){let Z=J!==null&&J!=="false";if(Z&&!this.#J)this.#I();else if(!Z)this.#w()}if(Q==="aspect-ratio")if(J)this.style.setProperty("--fig-media-aspect-ratio",J);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if(J)this.style.setProperty("--fig-media-fit",J);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#J){let Z=this.getAttribute("label")||"Upload";this.#J.setAttribute("label",this.#$?"Replace":Z)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#k()}}customElements.define("fig-media",n);class c0 extends n{get mediaKind(){return"image"}}customElements.define("fig-image",c0);class d0 extends n{get mediaKind(){return"video"}}customElements.define("fig-video",d0);class s0 extends HTMLElement{#$=null;#Q=null;#j=null;#J=null;#Z=!1;#q=!1;static get observedAttributes(){return["playing","duration","time"]}connectedCallback(){this.#_(),this.#Y(),this.#W()}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 $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("duration");return}this.setAttribute("duration",String($))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("time");return}this.setAttribute("time",String($))}attributeChangedCallback(Q){if(!this.#q)return;if(Q==="playing")this.#Y();if(Q==="duration"||Q==="time")this.#W()}#_(){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 $=document.createElement("fig-button");$.setAttribute("variant","ghost"),$.setAttribute("size","small"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Play");let J=v("play",{className:"fig-media-controls-play-icon"});$.append(J),Q.append($),$.addEventListener("click",(_)=>{_.preventDefault(),_.stopPropagation(),this.toggle()});let Z=document.createElement("fig-slider");Z.setAttribute("text","false"),Z.setAttribute("min","0"),Z.setAttribute("max",String(this.duration)),Z.setAttribute("step","1"),Z.setAttribute("value",String(this.time)),Z.setAttribute("full",""),Z.setAttribute("aria-label","Seek"),Z.setAttribute("aria-valuetext",this.#K(this.time,this.duration));let j=document.createElement("span");j.className="fig-media-controls-time",j.textContent=this.#X(this.time);let q=(_)=>{let X=_.currentTarget,Y=Number(X?.value);if(!Number.isFinite(Y))return;this.#Z=!0,this.setAttribute("time",String(Y)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:Y}})),requestAnimationFrame(()=>{this.#Z=!1})};Z.addEventListener("input",q),Z.addEventListener("change",q),this.append(Q,Z,j),this.#$=$,this.#Q=Q,this.#j=Z,this.#J=j}#X(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let $=Math.floor(Q),J=Math.floor($/60),Z=$%60;return`${String(J).padStart(2,"0")}:${String(Z).padStart(2,"0")}`}#K(Q,$=0){let J=this.#X(Q);if(!Number.isFinite($)||$<=0)return J;return`${J} of ${this.#X($)}`}#Y(){if(!this.#$)return;let Q=this.playing;this.#$.setAttribute("aria-label",Q?"Pause":"Play"),this.#Q?.setAttribute("text",Q?"Pause":"Play");let $=this.#$.querySelector(".fig-media-controls-play-icon");if($)$.setAttribute("name",Q?"pause":"play")}#W(){if(!this.#j)return;let Q=this.duration;if(Number(this.#j.getAttribute("max"))!==Q)this.#j.setAttribute("max",String(Q));let $=this.time;if(!this.#Z)this.#j.setAttribute("value",String($));if(this.#j.setAttribute("aria-valuetext",this.#K($,Q)),this.#J)this.#J.textContent=this.#X($)}toggle(){let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.playing)return;this.toggle()}pause(){if(!this.playing)return;this.toggle()}}customElements.define("fig-media-controls",s0);class r0 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#$=null;#Q=null;#j=null;#J=null;#Z=null;#q=null;get files(){return this.#q}get#_(){let Q=this.getAttribute("filename");if(Q)return Q;let $=this.getAttribute("url");if(!$)return"";try{let Z=new URL($,location.href).pathname.split("/").pop();return Z?decodeURIComponent(Z):$}catch{return $}}get value(){if(this.#q&&this.#q.length>0){if(this.#q.length===1)return this.#q[0].name;return`${this.#q.length} files`}return this.#_}connectedCallback(){this.#U(),this.addEventListener("dragover",this.#W),this.addEventListener("dragleave",this.#N),this.addEventListener("drop",this.#L)}disconnectedCallback(){this.#$?.removeEventListener("change",this.#K),this.#j?.removeEventListener("click",this.#Y),this.removeEventListener("dragover",this.#W),this.removeEventListener("dragleave",this.#N),this.removeEventListener("drop",this.#L)}attributeChangedCallback(Q,$,J){if($===J)return;this.#U()}clear(){if(this.#q=null,this.#$)this.#$.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#U(),this.#X({cleared:!0})}#X(Q={}){let $={files:this.#q,...Q};this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0}))}#K=()=>{if(this.#$.files.length>0)this.#q=this.#$.files,this.removeAttribute("url"),this.#U(),this.#X()};#Y=(Q)=>{Q.stopPropagation(),this.clear()};#W=(Q)=>{if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#Z)this.#Z.dataset.prevText=this.#Z.textContent,this.#Z.textContent="Drop file"}};#N=()=>{if(this.removeAttribute("dragover"),this.#Z&&this.#Z.dataset.prevText!==void 0)this.#Z.textContent=this.#Z.dataset.prevText,delete this.#Z.dataset.prevText};#L=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#Z&&this.#Z.dataset.prevText!==void 0)this.#Z.textContent=this.#Z.dataset.prevText,delete this.#Z.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.getAttribute("accepts"),J=Array.from(Q.dataTransfer.files);if($){let j=$.split(",").map((q)=>q.trim().toLowerCase());J=J.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"))J=J.slice(0,1);if(J.length===0)return;let Z=new DataTransfer;if(J.forEach((j)=>Z.items.add(j)),this.#q=Z.files,this.#$)this.#$.files=Z.files;this.removeAttribute("url"),this.#U(),this.#X()};#U(){let Q=this.getAttribute("accepts")||"",$=this.getAttribute("label")||"Upload",J=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("multiple"),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((L)=>L.trim()).join(", ")}`:"";if(this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",j),this.#Z.setAttribute("type","upload"),this.#Z.className="fig-input-file-filename",J)this.#Z.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.#Z.appendChild(X),this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#K),this.#Z.appendChild(this.#$),_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_),this.#J.appendChild(this.#Z),this.appendChild(this.#J);else this.appendChild(this.#Z);let N=document.createElement("fig-tooltip");if(N.setAttribute("text","Remove"),this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#j.setAttribute("icon","true"),this.#j.setAttribute("aria-label","Remove"),this.#j.className="fig-input-file-clear",J)this.#j.setAttribute("disabled","");this.#j.replaceChildren(v("minus")),this.#j.addEventListener("click",this.#Y),N.appendChild(this.#j),this.appendChild(N)}else{let _=Q?`Accepts ${Q.split(",").map((X)=>X.trim()).join(", ")}`:"";if(_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_);if(this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",j),this.#Z.setAttribute("type","upload"),this.#Z.textContent=$,J)this.#Z.setAttribute("disabled","");if(this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#K),this.#Z.appendChild(this.#$),this.#J)this.#J.appendChild(this.#Z),this.appendChild(this.#J);else this.appendChild(this.#Z)}}}customElements.define("fig-input-file",r0);class b extends HTMLElement{#$={x:0.42,y:0};#Q={x:0.58,y:1};#j={stiffness:200,damping:15,mass:1};#J="bezier";#Z=2;#q=null;#_=null;#X=null;#K=null;#Y=null;#W=null;#N=null;#L=null;#U=null;#B=null;#M=null;#G=null;#A=null;#D=0.8;#O=200;#H=200;#R=null;#F=null;#z=null;#C=5;#k=2;#T=10;#E=10;#P=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.#Z=parseInt(this.getAttribute("precision")||"2"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#S(Q);this.#G=this.#f(),this.#y(),this.#c()}disconnectedCallback(){if(this.#q=null,this.#z)this.#z.disconnect(),this.#z=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="aspect-ratio"){if(V(this,"--aspect-ratio",J),this.#_)this.#d(),this.#p();return}if(Q==="edit"){if(this.isConnected)this.#y();return}if(Q==="value"&&J){let Z=this.#J;if(this.#S(J),this.#G=this.#f(),Z!==this.#J&&this.#V())this.#y();else{if(this.#_)this.#p();this.#l(),this.#u()}}if(Q==="precision")this.#Z=parseInt(J||"2")}get value(){if(this.#J==="spring"){let{stiffness:$,damping:J,mass:Z}=this.#j;return`spring(${$}, ${J}, ${Z})`}let Q=this.#Z;return`${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}`}get cssValue(){if(this.#J==="spring"){let $=this.#I(),J=20,Z=Math.max(1,Math.floor($.length/20)),j=[];for(let q=0;q<$.length;q+=Z)j.push($[q].value.toFixed(3));if($.length>0)j.push($[$.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#Z;return`cubic-bezier(${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)})`}get preset(){return this.#G}set value(Q){this.setAttribute("value",Q)}#S(Q){let $=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if($)return this.#J="spring",this.#j.stiffness=parseFloat($[1]),this.#j.damping=parseFloat($[2]),this.#j.mass=parseFloat($[3]),!0;let J=Q.split(",").map((Z)=>parseFloat(Z.trim()));if(J.length>=4&&J.every((Z)=>!isNaN(Z)))return this.#J="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],!0;return!1}#f(){if(this.#J==="bezier"){for(let $ of b.PRESETS){if($.type!=="bezier"||!$.value)continue;if(Math.abs(this.#$.x-$.value[0])<0.001&&Math.abs(this.#$.y-$.value[1])<0.001&&Math.abs(this.#Q.x-$.value[2])<0.001&&Math.abs(this.#Q.y-$.value[3])<0.001)return $.name}return"Custom bezier"}for(let $ of b.PRESETS){if($.type!=="spring"||!$.spring)continue;if(Math.abs(this.#j.stiffness-$.spring.stiffness)<0.001&&Math.abs(this.#j.damping-$.spring.damping)<0.001&&Math.abs(this.#j.mass-$.spring.mass)<0.001)return $.name}return"Custom spring"}#I(){let{stiffness:Q,damping:$,mass:J}=this.#j,Z=0.004,j=5,q=[],_=0,X=0;for(let Y=0;Y<=5;Y+=0.004){let K=-Q*(_-1)-$*X;if(X+=K/J*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#w(Q,$=24){let{stiffness:J,damping:Z,mass:j}=Q,q=0.004,_=5,X=[],Y=0,K=0;for(let G=0;G<=5;G+=0.004){let M=-J*(Y-1)-Z*K;if(K+=M/j*0.004,Y+=K*0.004,X.push({t:G,value:Y}),G>0.1&&Math.abs(Y-1)<0.001&&Math.abs(K)<0.001)break}let N=X[X.length-1].t||1,L=1;for(let G of X)if(G.value>L)L=G.value;let O=0;for(let G of X)if(G.value<O)O=G.value;let H=Math.max(L-O,1),B=6,U=$-B*2,z=Math.max(1,Math.floor(X.length/30)),A="";for(let G=0;G<X.length;G+=z){let M=B+X[G].t/N*U,D=B+(1-(X[G].value-O)/H)*U;A+=(G===0?"M":"L")+M.toFixed(1)+","+D.toFixed(1)}return`<svg width="${$}" height="${$}" viewBox="0 0 ${$} ${$}" fill="none"><path d="${A}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,$,J,Z,j=24){let _=(j-12)/2,X=48,Y=[],K=(M,D,T,P,E)=>{let f=1-E;return f*f*f*M+3*f*f*E*D+3*f*E*E*T+E*E*E*P};for(let M=0;M<=48;M++){let D=M/48;Y.push({x:K(0,Q,J,1,D),y:K(0,$,Z,1,D)})}let N=1/0,L=-1/0,O=1/0,H=-1/0;for(let M of Y){if(M.x<N)N=M.x;if(M.x>L)L=M.x;if(M.y<O)O=M.y;if(M.y>H)H=M.y}let B=Math.max(L-N,0.000001),U=Math.max(H-O,0.000001),z=(M)=>_+(M-N)/B*12,A=(M)=>_+(1-(M-O)/U)*12,G="";for(let M=0;M<Y.length;M++){let D=z(Y[M].x),T=A(Y[M].y);G+=`${M===0?"M":"L"}${D.toFixed(1)},${T.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${G}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#V(){return this.getAttribute("edit")!=="false"}#y(){if(this.classList.toggle("spring-mode",this.#J==="spring"),this.classList.toggle("bezier-mode",this.#J!=="spring"),this.#x(),this.innerHTML=this.#v(),this.#n(),this.#_)this.#m(),this.#d(),this.#p();this.#u(),this.#L0()}static#b(Q){return String(Q).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#g(){let Q="",$=void 0;for(let J of b.PRESETS){if(!this.#V()&&!J.value&&!J.spring)continue;if(J.group!==$){if($!==void 0)Q+="</optgroup>";if(J.group)Q+=`<optgroup label="${J.group}">`;$=J.group}let Z;if(J.type==="spring"){let q=J.spring||this.#j;Z=b.#w(q)}else{let q=J.value||[this.#$.x,this.#$.y,this.#Q.x,this.#Q.y];Z=b.curveIcon(...q)}let j=J.name===this.#G?" selected":"";Q+=`<option value="${J.name}"${j}>${Z} ${J.name}</option>`}if($)Q+="</optgroup>";return`<fig-dropdown class="fig-easing-curve-dropdown" full experimental="modern">${Q}</fig-dropdown>`}#v(){let $=this.#g();if(!this.#V())return $;let J=`<fig-input-text class="fig-easing-curve-value-input" value="${b.#b(this.value)}" full></fig-input-text>`;if(this.#J==="spring")return`${$}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
199
+ </div>`,this.#Q=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#$&&this.#Z&&this.#J){if(!this.#Z.hasAttribute("type"))this.#Z.setAttribute("type","dropdown");if(!this.#Z.hasAttribute("label"))this.#Z.setAttribute("label",q);if(Z)this.#Z.setAttribute("experimental",Z);this.#J.append(this.#Z)}this.#j=this.querySelector("fig-dropdown"),this.#O()}#G(){this.#U(),this.#j?.addEventListener("input",this.#X),this.#Q?.addEventListener("input",this.#K),this.#Q?.addEventListener("change",this.#Y)}#U(){this.#j?.removeEventListener("input",this.#X),this.#Q?.removeEventListener("input",this.#K),this.#Q?.removeEventListener("change",this.#Y)}#B(Q){Q.stopPropagation();let $=Q.target.closest("fig-dropdown")?.value??"";if(this.#q=!0,this.setAttribute("value",$),this.#q=!1,this.#Q)this.#Q.setAttribute("value",$);this.#z(),this.#A()}#M(Q){Q.stopPropagation();let $=Q.target.value??"";this.#q=!0,this.setAttribute("value",$),this.#q=!1,this.#z()}#R(Q){Q.stopPropagation();let $=Q.target.value??"";this.#q=!0,this.setAttribute("value",$),this.#q=!1,this.#A()}#z(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#A(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#F(){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.#Q)this.#_.forEach((Q)=>{let $=this.getAttribute(Q);if($===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,$)});if(this.#j&&!this.#j.hasAttribute("aria-label"))this.#j.setAttribute("label",this.#H())}#k(Q){if(this.#Q)if(Q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled");if(this.#j)if(Q)this.#j.setAttribute("disabled","");else this.#j.removeAttribute("disabled")}focus(){this.#Q?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"options":if(this.#j&&!this.#$){let Z=this.#F();this.#j.innerHTML=Z.map((j)=>`<option>${j}</option>`).join("")}break;case"placeholder":if(this.#Q)this.#Q.setAttribute("placeholder",J||"");this.#O();break;case"value":if(!this.#q&&this.#Q)this.#Q.setAttribute("value",J||"");break;case"disabled":this.#k(J!==null&&J!=="false");break;case"experimental":if(this.#j){if(J)this.#j.setAttribute("experimental",J);else if(!this.#$)this.#j.removeAttribute("experimental")}break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#O();break}}}customElements.define("fig-combo-input",c0);class q0 extends HTMLElement{#$="color";#Q=null;#j=!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.#X(),this.#J(),this.#K()}#J(){let Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#Z(Q){if(!Q)return"color";let $=Q.toLowerCase();if($.includes("gradient"))return"gradient";if($.includes("url("))return"image";return"color"}#q(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{let{ctx:$}=j0(1,1);return $.fillStyle=Q,$.fillStyle}catch{return"#D9D9D9"}}#_(Q){if(!Q||!Q.includes("var("))return Q;let $=this.style.background;this.style.background=Q;let J=getComputedStyle(this),Z=J.backgroundImage,j=J.backgroundColor;if(this.style.background=$,Z&&Z!=="none")return Z;return j||Q}#X(){let Q=this.getAttribute("background")||"#D9D9D9",$=Q.includes("var("),J=$?this.#_(Q):Q,Z=this.#Z(J);if(Z!==this.#$||!this.input){if(this.#$=Z,this.setAttribute("data-type",this.#$),this.input)this.input.removeEventListener("input",this.#Q);if(this.#$==="color"){let q=this.#q(J);if(this.innerHTML=`<div></div><input type="color" value="${q}" />`,this.input=this.querySelector("input"),!$)this.input.addEventListener("input",this.#Q);this.#K()}else this.innerHTML="<div></div>",this.input=null,this.#K()}else if(this.#$==="color"&&this.input){let q=this.#q(J);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("--chit-background",j?Q:`linear-gradient(${Q}, ${Q})`)}#K(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",Q?"true":"false"),this.input){this.input.disabled=Q;let $=this.getAttribute("aria-labelledby"),J=this.getAttribute("aria-label")||"Color swatch",Z=this.getAttribute("aria-describedby");if($)this.input.setAttribute("aria-labelledby",$),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",J),this.input.removeAttribute("aria-labelledby");if(Z)this.input.setAttribute("aria-describedby",Z);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.#j=!0,this.setAttribute("background",Q.target.value),this.#j=!1}get background(){return this.getAttribute("background")}set background(Q){this.setAttribute("background",Q)}focus(){this.input?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="background"){if(this.#j){let Z=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(J);this.style.setProperty("--chit-background",Z?J:`linear-gradient(${J}, ${J})`);return}this.#X()}else if(Q==="alpha")this.#J();else if(Q==="disabled"||Q==="aria-label"||Q==="aria-labelledby"||Q==="aria-describedby")this.#K()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",Q)}}customElements.define("fig-chit",q0);class u0 extends q0{}customElements.define("fig-swatch",u0);class e extends HTMLElement{#$=null;#Q=null;#j=null;#J=null;#Z=null;#q=null;#_=null;#X=this.#V.bind(this);#K=this.#w.bind(this);#Y=this.#h.bind(this);#N=this.#g.bind(this);#W=null;#L=null;#G=null;#U=null;#B=null;#M=null;#R=null;static get observedAttributes(){return["src","type","alt","upload","label","aspect-ratio","fit","checkerboard","controls","autoplay","loop","muted","poster","aria-label","aria-labelledby","title"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#$}set src(Q){if(this.#$=Q||"",Q===null||Q===void 0||Q==="")this.removeAttribute("src");else this.setAttribute("src",Q)}get file(){return this.#_}#z(){return this.#q||this.#$||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#z())return null;if(!this.#Q)return null;try{if(typeof this.#Q.decode==="function")await this.#Q.decode();else if(!this.#Q.complete)await new Promise((Z,j)=>{this.#Q.addEventListener("load",Z,{once:!0}),this.#Q.addEventListener("error",j,{once:!0})})}catch{}let Q=this.#Q.naturalWidth,$=this.#Q.naturalHeight;if(!(Q>0)||!($>0))return null;let J=document.createElement("canvas");return J.width=Q,J.height=$,J.getContext("2d").drawImage(this.#Q,0,0),J.toDataURL()}connectedCallback(){this.#$=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 $=this.getAttribute("fit");if($)this.style.setProperty("--fig-media-fit",$);if(this.querySelectorAll("fig-chit[data-generated]").forEach((Z)=>Z.remove()),this.#F(),this.#H(),this.#S(),this.#O(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#x()}disconnectedCallback(){if(this.#J?.removeEventListener("change",this.#X),this.#A(),this.#C(),this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null;this.#q=null}#A(){if(!this.#Q)return;if(this.#Q.tagName==="VIDEO")this.#Q.removeEventListener("play",this.#K),this.#Q.removeEventListener("pause",this.#Y),this.#Q.removeEventListener("ended",this.#N)}#F(){if(this.#j?.isConnected)return;let Q=this.querySelector(":scope > fig-preview");if(Q){this.#j=Q;return}let $=document.createElement("fig-preview");$.setAttribute("data-generated",""),this.prepend($),this.#j=$}#D(){let Q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${Q}:not([data-generated])`)}#H(){let Q=this.#D();if(Q){if(this.#F(),this.#Q&&this.#Q!==Q){if(this.#A(),this.#Q.hasAttribute("data-generated"))this.#Q.remove()}if(this.#Q=Q,this.#j&&Q.parentElement!==this.#j)this.#j.append(Q);this.#O();return}this.#F();let $=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#Q&&this.#Q.tagName!==$){if(this.#A(),this.#Q.hasAttribute("data-generated"))this.#Q.remove();this.#Q=null}if(this.#Q)return;if(this.mediaKind==="video"){let J=document.createElement("video");J.setAttribute("data-generated",""),J.className="fig-media-element",J.setAttribute("playsinline",""),J.preload="auto",this.#j.append(J),this.#Q=J,this.#Q.addEventListener("play",this.#K),this.#Q.addEventListener("pause",this.#Y),this.#Q.addEventListener("ended",this.#N);let Z=()=>{if(this.#Q?.autoplay)return;try{this.#Q.currentTime=0.001}catch{}};this.#Q.addEventListener("loadedmetadata",Z,{once:!0})}else{let J=document.createElement("img");J.setAttribute("data-generated",""),J.className="fig-media-element",J.loading="lazy",J.decoding="async",J.alt=this.getAttribute("alt")||"",this.#j.append(J),this.#Q=J}}#O(){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 $=this.getAttribute(Q);if($===null)this.#Q.removeAttribute(Q);else this.#Q.setAttribute(Q,$)})}#k(Q,$=!1){if(!this.hasAttribute(Q))return $;return this.getAttribute(Q)!=="false"}#S(){if(!this.#Q)return;if(!this.#Q.hasAttribute("data-generated"))return;let Q=this.#z();if(this.#Q.getAttribute("src")!==Q){if(Q)this.#Q.setAttribute("src",Q);else if(this.#Q.removeAttribute("src"),this.#Q.tagName==="VIDEO")this.#Q.load()}if(this.#Q.tagName==="IMG"){this.#O();return}let $=this.getAttribute("poster");if($)this.#Q.setAttribute("poster",$);else this.#Q.removeAttribute("poster");this.#Q.controls=!1,this.#Q.removeAttribute("controls"),this.#Q.autoplay=this.#k("autoplay",!1),this.#Q.loop=this.#k("loop",!1),this.#Q.muted=this.#k("muted",!1),this.#Q.playsInline=!0,this.#O(),this.#f()}get mediaEl(){return this.#Q}#f(){if(this.mediaKind!=="video"){this.#C();return}let Q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(Q){if(this.#W!==Q)this.#C(),this.#W=Q;this.#E();return}if(this.#k("controls",!1))this.#P();else this.#C()}#P(){if(this.#W&&this.#W.isConnected){this.#E();return}let Q=document.createElement("fig-media-controls");Q.setAttribute("data-generated",""),this.append(Q),this.#W=Q,this.#E()}#E(){if(!this.#W||!this.#Q)return;if(this.#L===this.#Q&&this.#G===this.#W)return;this.#T();let Q=this.#W,$=this.#Q;this.#L=$,this.#G=Q;let J=null,Z=()=>{if(Q.playing=!$.paused&&!$.ended,Number.isFinite($.duration))Q.duration=$.duration;if(J!==null)if(Math.abs($.currentTime-J)<0.25)J=null;else return;Q.time=$.currentTime||0},j=()=>{let X=$.play?.();if(X&&typeof X.catch==="function")X.catch(()=>{})},q=()=>$.pause?.(),_=(X)=>{let Y=Number(X?.detail?.time);if(!Number.isFinite(Y))return;J=Y;try{$.currentTime=Y}catch{}};this.#U=Z,this.#B=j,this.#M=q,this.#R=_,$.addEventListener("play",Z),$.addEventListener("pause",Z),$.addEventListener("ended",Z),$.addEventListener("timeupdate",Z),$.addEventListener("loadedmetadata",Z),$.addEventListener("durationchange",Z),$.addEventListener("seeked",Z),Q.addEventListener("play",j),Q.addEventListener("pause",q),Q.addEventListener("seek",_),Z()}#T(){let Q=this.#L,$=this.#G;if(Q&&this.#U)Q.removeEventListener("play",this.#U),Q.removeEventListener("pause",this.#U),Q.removeEventListener("ended",this.#U),Q.removeEventListener("timeupdate",this.#U),Q.removeEventListener("loadedmetadata",this.#U),Q.removeEventListener("durationchange",this.#U),Q.removeEventListener("seeked",this.#U);if($){if(this.#B)$.removeEventListener("play",this.#B);if(this.#M)$.removeEventListener("pause",this.#M);if(this.#R)$.removeEventListener("seek",this.#R)}this.#L=null,this.#G=null,this.#U=null,this.#B=null,this.#M=null,this.#R=null}#C(){if(this.#T(),!this.#W)return;if(this.#W.hasAttribute("data-generated"))this.#W.remove();this.#W=null}toggle(){if(!this.#Q||this.mediaKind!=="video")return;if(this.#Q.paused||this.#Q.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#Q)return;let Q=this.#Q.play();if(Q&&typeof Q.catch==="function")Q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#Q)return;this.#Q.pause()}#x(){let Q=document.createElement("fig-input-file");Q.setAttribute("data-generated",""),Q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),Q.setAttribute("variant","overlay");let $=this.getAttribute("label")||"Upload";if(Q.setAttribute("label",this.#$?"Replace":$),this.#_?.name)Q.setAttribute("filename",this.#_.name);else if(this.#$)Q.setAttribute("url",this.#$);Q.addEventListener("change",this.#X),this.#F(),this.#j.append(Q),this.#J=Q}#b(){if(this.#J)this.#J.removeEventListener("change",this.#X),this.#J.remove(),this.#J=null}#V(Q){if(Q.target!==this.#J)return;let $=Q.detail?.files?.[0],J=Q.detail?.cleared===!0;if(!$){if(this.#Z)URL.revokeObjectURL(this.#Z),this.#Z=null;if(this.#_=null,this.#q=null,J)this.src="";if(this.#S(),this.#J){let Z=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":Z),this.#J.removeAttribute("filename"),this.#$)this.#J.setAttribute("url",this.#$);else this.#J.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#Z)URL.revokeObjectURL(this.#Z);if(this.#_=$,this.#Z=URL.createObjectURL($),this.#q=this.#Z,this.#S(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:$,src:this.#Z}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#J)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",$.name),this.#J.setAttribute("label","Replace")}#y(Q){if(!this.#Q)return;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#$||"",currentTime:this.#Q.currentTime,duration:this.#Q.duration}}))}#w(){this.#y("play")}#h(){this.#y("pause")}#g(){this.#y("ended")}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="src"){let Z=J||"",j=Z&&(Z===this.#q||Z===this.#Z);if(this.#$=Z,this.#Z&&!j)URL.revokeObjectURL(this.#Z),this.#Z=null,this.#q=null,this.#_=null;if(this.#S(),this.#J){let q=this.getAttribute("label")||"Upload";if(this.#J.setAttribute("label",this.#$?"Replace":q),this.#$)if(this.#_?.name)this.#J.removeAttribute("url"),this.#J.setAttribute("filename",this.#_.name);else this.#J.setAttribute("url",this.#$),this.#J.removeAttribute("filename");else this.#J.removeAttribute("url"),this.#J.removeAttribute("filename")}}if(Q==="type"){if(this.#H(),this.#S(),this.#J)this.#J.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(Q))this.#O();if(Q==="upload"){let Z=J!==null&&J!=="false";if(Z&&!this.#J)this.#x();else if(!Z)this.#b()}if(Q==="aspect-ratio")if(J)this.style.setProperty("--fig-media-aspect-ratio",J);else this.style.removeProperty("--fig-media-aspect-ratio");if(Q==="fit")if(J)this.style.setProperty("--fig-media-fit",J);else this.style.removeProperty("--fig-media-fit");if(Q==="label"&&this.#J){let Z=this.getAttribute("label")||"Upload";this.#J.setAttribute("label",this.#$?"Replace":Z)}if(["controls","autoplay","loop","muted","poster"].includes(Q))this.#S()}}customElements.define("fig-media",e);class d0 extends e{get mediaKind(){return"image"}}customElements.define("fig-image",d0);class s0 extends e{get mediaKind(){return"video"}}customElements.define("fig-video",s0);class r0 extends HTMLElement{#$=null;#Q=null;#j=null;#J=null;#Z=!1;#q=!1;static get observedAttributes(){return["playing","duration","time"]}connectedCallback(){this.#_(),this.#Y(),this.#N()}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 $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("duration");return}this.setAttribute("duration",String($))}get time(){let Q=Number(this.getAttribute("time"));return Number.isFinite(Q)&&Q>=0?Q:0}set time(Q){let $=Number(Q);if(!Number.isFinite($)||$<0){this.removeAttribute("time");return}this.setAttribute("time",String($))}attributeChangedCallback(Q){if(!this.#q)return;if(Q==="playing")this.#Y();if(Q==="duration"||Q==="time")this.#N()}#_(){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 $=document.createElement("fig-button");$.setAttribute("variant","ghost"),$.setAttribute("size","small"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Play");let J=h("play",{className:"fig-media-controls-play-icon"});$.append(J),Q.append($),$.addEventListener("click",(_)=>{_.preventDefault(),_.stopPropagation(),this.toggle()});let Z=document.createElement("fig-slider");Z.setAttribute("text","false"),Z.setAttribute("min","0"),Z.setAttribute("max",String(this.duration)),Z.setAttribute("step","1"),Z.setAttribute("value",String(this.time)),Z.setAttribute("full",""),Z.setAttribute("aria-label","Seek"),Z.setAttribute("aria-valuetext",this.#K(this.time,this.duration));let j=document.createElement("span");j.className="fig-media-controls-time",j.textContent=this.#X(this.time);let q=(_)=>{let X=_.currentTarget,Y=Number(X?.value);if(!Number.isFinite(Y))return;this.#Z=!0,this.setAttribute("time",String(Y)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:Y}})),requestAnimationFrame(()=>{this.#Z=!1})};Z.addEventListener("input",q),Z.addEventListener("change",q),this.append(Q,Z,j),this.#$=$,this.#Q=Q,this.#j=Z,this.#J=j}#X(Q){if(!Number.isFinite(Q)||Q<0)Q=0;let $=Math.floor(Q),J=Math.floor($/60),Z=$%60;return`${String(J).padStart(2,"0")}:${String(Z).padStart(2,"0")}`}#K(Q,$=0){let J=this.#X(Q);if(!Number.isFinite($)||$<=0)return J;return`${J} of ${this.#X($)}`}#Y(){if(!this.#$)return;let Q=this.playing;this.#$.setAttribute("aria-label",Q?"Pause":"Play"),this.#Q?.setAttribute("text",Q?"Pause":"Play");let $=this.#$.querySelector(".fig-media-controls-play-icon");if($)$.setAttribute("name",Q?"pause":"play")}#N(){if(!this.#j)return;let Q=this.duration;if(Number(this.#j.getAttribute("max"))!==Q)this.#j.setAttribute("max",String(Q));let $=this.time;if(!this.#Z)this.#j.setAttribute("value",String($));if(this.#j.setAttribute("aria-valuetext",this.#K($,Q)),this.#J)this.#J.textContent=this.#X($)}toggle(){let Q=!this.playing;this.playing=Q,this.dispatchEvent(new CustomEvent(Q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:Q}}))}play(){if(this.playing)return;this.toggle()}pause(){if(!this.playing)return;this.toggle()}}customElements.define("fig-media-controls",r0);class i0 extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#$=null;#Q=null;#j=null;#J=null;#Z=null;#q=null;get files(){return this.#q}get#_(){let Q=this.getAttribute("filename");if(Q)return Q;let $=this.getAttribute("url");if(!$)return"";try{let Z=new URL($,location.href).pathname.split("/").pop();return Z?decodeURIComponent(Z):$}catch{return $}}get value(){if(this.#q&&this.#q.length>0){if(this.#q.length===1)return this.#q[0].name;return`${this.#q.length} files`}return this.#_}connectedCallback(){this.#G(),this.addEventListener("dragover",this.#N),this.addEventListener("dragleave",this.#W),this.addEventListener("drop",this.#L)}disconnectedCallback(){this.#$?.removeEventListener("change",this.#K),this.#j?.removeEventListener("click",this.#Y),this.removeEventListener("dragover",this.#N),this.removeEventListener("dragleave",this.#W),this.removeEventListener("drop",this.#L)}attributeChangedCallback(Q,$,J){if($===J)return;this.#G()}clear(){if(this.#q=null,this.#$)this.#$.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#G(),this.#X({cleared:!0})}#X(Q={}){let $={files:this.#q,...Q};this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0}))}#K=()=>{if(this.#$.files.length>0)this.#q=this.#$.files,this.removeAttribute("url"),this.#G(),this.#X()};#Y=(Q)=>{Q.stopPropagation(),this.clear()};#N=(Q)=>{if(Q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#Z)this.#Z.dataset.prevText=this.#Z.textContent,this.#Z.textContent="Drop file"}};#W=()=>{if(this.removeAttribute("dragover"),this.#Z&&this.#Z.dataset.prevText!==void 0)this.#Z.textContent=this.#Z.dataset.prevText,delete this.#Z.dataset.prevText};#L=(Q)=>{if(Q.preventDefault(),this.removeAttribute("dragover"),this.#Z&&this.#Z.dataset.prevText!==void 0)this.#Z.textContent=this.#Z.dataset.prevText,delete this.#Z.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.getAttribute("accepts"),J=Array.from(Q.dataTransfer.files);if($){let j=$.split(",").map((q)=>q.trim().toLowerCase());J=J.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"))J=J.slice(0,1);if(J.length===0)return;let Z=new DataTransfer;if(J.forEach((j)=>Z.items.add(j)),this.#q=Z.files,this.#$)this.#$.files=Z.files;this.removeAttribute("url"),this.#G(),this.#X()};#G(){let Q=this.getAttribute("accepts")||"",$=this.getAttribute("label")||"Upload",J=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("multiple"),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((L)=>L.trim()).join(", ")}`:"";if(this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",j),this.#Z.setAttribute("type","upload"),this.#Z.className="fig-input-file-filename",J)this.#Z.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.#Z.appendChild(X),this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#K),this.#Z.appendChild(this.#$),_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_),this.#J.appendChild(this.#Z),this.appendChild(this.#J);else this.appendChild(this.#Z);let N=document.createElement("fig-tooltip");if(N.setAttribute("text","Remove"),this.#j=document.createElement("fig-button"),this.#j.setAttribute("variant",j==="overlay"?"overlay":"ghost"),this.#j.setAttribute("icon","true"),this.#j.setAttribute("aria-label","Remove"),this.#j.className="fig-input-file-clear",J)this.#j.setAttribute("disabled","");this.#j.replaceChildren(h("minus")),this.#j.addEventListener("click",this.#Y),N.appendChild(this.#j),this.appendChild(N)}else{let _=Q?`Accepts ${Q.split(",").map((X)=>X.trim()).join(", ")}`:"";if(_)this.#J=document.createElement("fig-tooltip"),this.#J.setAttribute("text",_);if(this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",j),this.#Z.setAttribute("type","upload"),this.#Z.textContent=$,J)this.#Z.setAttribute("disabled","");if(this.#$=document.createElement("input"),this.#$.type="file",this.#$.title="",Q)this.#$.setAttribute("accept",Q);if(Z)this.#$.setAttribute("multiple","");if(this.#$.addEventListener("change",this.#K),this.#Z.appendChild(this.#$),this.#J)this.#J.appendChild(this.#Z),this.appendChild(this.#J);else this.appendChild(this.#Z)}}}customElements.define("fig-input-file",i0);class b extends HTMLElement{#$={x:0.42,y:0};#Q={x:0.58,y:1};#j={stiffness:200,damping:15,mass:1};#J="bezier";#Z=2;#q=null;#_=null;#X=null;#K=null;#Y=null;#N=null;#W=null;#L=null;#G=null;#U=null;#B=null;#M=null;#R=null;#z=0.8;#A=200;#F=200;#D=null;#H=null;#O=null;#k=5;#S=2;#f=10;#P=10;#E=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.#Z=parseInt(this.getAttribute("precision")||"2"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let Q=this.getAttribute("value");if(Q)this.#T(Q);this.#M=this.#C(),this.#y(),this.#d()}disconnectedCallback(){if(this.#q=null,this.#O)this.#O.disconnect(),this.#O=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="aspect-ratio"){if(V(this,"--aspect-ratio",J),this.#_)this.#s(),this.#c();return}if(Q==="edit"){if(this.isConnected)this.#y();return}if(Q==="value"&&J){let Z=this.#J;if(this.#T(J),this.#M=this.#C(),Z!==this.#J&&this.#V())this.#y();else{if(this.#_)this.#c();this.#a(),this.#u()}}if(Q==="precision")this.#Z=parseInt(J||"2")}get value(){if(this.#J==="spring"){let{stiffness:$,damping:J,mass:Z}=this.#j;return`spring(${$}, ${J}, ${Z})`}let Q=this.#Z;return`${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}`}get cssValue(){if(this.#J==="spring"){let $=this.#x(),J=20,Z=Math.max(1,Math.floor($.length/20)),j=[];for(let q=0;q<$.length;q+=Z)j.push($[q].value.toFixed(3));if($.length>0)j.push($[$.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}let Q=this.#Z;return`cubic-bezier(${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)})`}get preset(){return this.#M}set value(Q){this.setAttribute("value",Q)}#T(Q){let $=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if($)return this.#J="spring",this.#j.stiffness=parseFloat($[1]),this.#j.damping=parseFloat($[2]),this.#j.mass=parseFloat($[3]),!0;let J=Q.split(",").map((Z)=>parseFloat(Z.trim()));if(J.length>=4&&J.every((Z)=>!isNaN(Z)))return this.#J="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],!0;return!1}#C(){if(this.#J==="bezier"){for(let $ of b.PRESETS){if($.type!=="bezier"||!$.value)continue;if(Math.abs(this.#$.x-$.value[0])<0.001&&Math.abs(this.#$.y-$.value[1])<0.001&&Math.abs(this.#Q.x-$.value[2])<0.001&&Math.abs(this.#Q.y-$.value[3])<0.001)return $.name}return"Custom bezier"}for(let $ of b.PRESETS){if($.type!=="spring"||!$.spring)continue;if(Math.abs(this.#j.stiffness-$.spring.stiffness)<0.001&&Math.abs(this.#j.damping-$.spring.damping)<0.001&&Math.abs(this.#j.mass-$.spring.mass)<0.001)return $.name}return"Custom spring"}#x(){let{stiffness:Q,damping:$,mass:J}=this.#j,Z=0.004,j=5,q=[],_=0,X=0;for(let Y=0;Y<=5;Y+=0.004){let K=-Q*(_-1)-$*X;if(X+=K/J*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#b(Q,$=24){let{stiffness:J,damping:Z,mass:j}=Q,q=0.004,_=5,X=[],Y=0,K=0;for(let G=0;G<=5;G+=0.004){let M=-J*(Y-1)-Z*K;if(K+=M/j*0.004,Y+=K*0.004,X.push({t:G,value:Y}),G>0.1&&Math.abs(Y-1)<0.001&&Math.abs(K)<0.001)break}let N=X[X.length-1].t||1,L=1;for(let G of X)if(G.value>L)L=G.value;let O=0;for(let G of X)if(G.value<O)O=G.value;let H=Math.max(L-O,1),B=6,U=$-B*2,z=Math.max(1,Math.floor(X.length/30)),A="";for(let G=0;G<X.length;G+=z){let M=B+X[G].t/N*U,D=B+(1-(X[G].value-O)/H)*U;A+=(G===0?"M":"L")+M.toFixed(1)+","+D.toFixed(1)}return`<svg width="${$}" height="${$}" viewBox="0 0 ${$} ${$}" fill="none"><path d="${A}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,$,J,Z,j=24){let _=(j-12)/2,X=48,Y=[],K=(M,D,T,P,k)=>{let f=1-k;return f*f*f*M+3*f*f*k*D+3*f*k*k*T+k*k*k*P};for(let M=0;M<=48;M++){let D=M/48;Y.push({x:K(0,Q,J,1,D),y:K(0,$,Z,1,D)})}let N=1/0,L=-1/0,O=1/0,H=-1/0;for(let M of Y){if(M.x<N)N=M.x;if(M.x>L)L=M.x;if(M.y<O)O=M.y;if(M.y>H)H=M.y}let B=Math.max(L-N,0.000001),U=Math.max(H-O,0.000001),z=(M)=>_+(M-N)/B*12,A=(M)=>_+(1-(M-O)/U)*12,G="";for(let M=0;M<Y.length;M++){let D=z(Y[M].x),T=A(Y[M].y);G+=`${M===0?"M":"L"}${D.toFixed(1)},${T.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${G}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#V(){return this.getAttribute("edit")!=="false"}#y(){if(this.classList.toggle("spring-mode",this.#J==="spring"),this.classList.toggle("bezier-mode",this.#J!=="spring"),this.#I(),this.innerHTML=this.#g(),this.#m(),this.#_)this.#p(),this.#s(),this.#c();this.#u(),this.#L0()}static#w(Q){return String(Q).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}#h(){let Q="",$=void 0;for(let J of b.PRESETS){if(!this.#V()&&!J.value&&!J.spring)continue;if(J.group!==$){if($!==void 0)Q+="</optgroup>";if(J.group)Q+=`<optgroup label="${J.group}">`;$=J.group}let Z;if(J.type==="spring"){let q=J.spring||this.#j;Z=b.#b(q)}else{let q=J.value||[this.#$.x,this.#$.y,this.#Q.x,this.#Q.y];Z=b.curveIcon(...q)}let j=J.name===this.#M?" selected":"";Q+=`<option value="${J.name}"${j}>${Z} ${J.name}</option>`}if($)Q+="</optgroup>";return`<fig-dropdown class="fig-easing-curve-dropdown" full experimental="modern">${Q}</fig-dropdown>`}#g(){let $=this.#h();if(!this.#V())return $;let J=`<fig-input-text class="fig-easing-curve-value-input" value="${b.#w(this.value)}" full></fig-input-text>`;if(this.#J==="spring")return`${$}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
200
200
  <rect class="fig-easing-curve-bounds" x="0" y="0" width="200" height="200"/>
201
201
  <line class="fig-easing-curve-target" x1="0" y1="40" x2="200" y2="40"/>
202
202
  <line class="fig-easing-curve-diagonal" x1="0" y1="180" x2="0" y2="180"/>
@@ -209,11 +209,11 @@ var B1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var O1={};var G0=B1(()=>{/*! Vendored from @
209
209
  <line class="fig-easing-curve-arm" data-arm="1"/>
210
210
  <line class="fig-easing-curve-arm" data-arm="2"/>
211
211
  <path class="fig-easing-curve-path"/>
212
- <circle class="fig-easing-curve-endpoint" data-endpoint="start" r="${this.#k}"/>
213
- <circle class="fig-easing-curve-endpoint" data-endpoint="end" r="${this.#k}"/>
212
+ <circle class="fig-easing-curve-endpoint" data-endpoint="start" r="${this.#S}"/>
213
+ <circle class="fig-easing-curve-endpoint" data-endpoint="end" r="${this.#S}"/>
214
214
  <foreignObject class="fig-easing-curve-handle" data-handle="1" width="20" height="20"><fig-handle size="small" drag aria-label="First easing control point"></fig-handle></foreignObject>
215
215
  <foreignObject class="fig-easing-curve-handle" data-handle="2" width="20" height="20"><fig-handle size="small" drag aria-label="Second easing control point"></fig-handle></foreignObject>
216
- </svg></div>${J}`}#h(Q,$){let J=getComputedStyle(this).getPropertyValue(Q).trim();if(!J)return $;let Z=Number.parseFloat(J);return Number.isFinite(Z)?Z:$}#x(){this.#k=this.#h("--easing-bezier-endpoint-radius",this.#k),this.#P=this.#h("--easing-duration-bar-radius",this.#P)}#n(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#X=this.querySelector(".fig-easing-curve-path"),this.#K=this.querySelector('[data-arm="1"]'),this.#Y=this.querySelector('[data-arm="2"]'),this.#W=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#N=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#L=this.querySelector('[data-endpoint="start"]'),this.#U=this.querySelector('[data-endpoint="end"]'),this.#B=this.querySelector(".fig-easing-curve-dropdown"),this.#M=this.querySelector(".fig-easing-curve-value-input"),this.#A=this.querySelector(".fig-easing-curve-target"),this.#R=this.querySelector(".fig-easing-curve-bounds"),this.#F=this.querySelector(".fig-easing-curve-diagonal")}#m(){let Q=this.#W?.querySelector("fig-handle"),$=this.#N?.querySelector("fig-handle");if(Q){let J=Q.offsetWidth||this.#C*2,Z=Q.offsetHeight||this.#C*2;this.#C=Math.max(J,Z)/2,this.#W.setAttribute("width",J),this.#W.setAttribute("height",Z)}if($){let J=$.offsetWidth||this.#T,Z=$.offsetHeight||this.#E;if(this.#J==="spring")this.#T=J,this.#E=Z;this.#N.setAttribute("width",J),this.#N.setAttribute("height",Z)}}#c(){if(this.#z||!window.ResizeObserver)return;this.#z=new ResizeObserver(()=>{if(this.#d())this.#p()}),this.#z.observe(this)}#d(){if(!this.#_)return!1;let Q=this.#_.getBoundingClientRect(),$=Math.max(1,Math.round(Q.width||200)),J=Math.max(1,Math.round(Q.height||200)),Z=$!==this.#O||J!==this.#H;return this.#O=$,this.#H=J,this.#_.setAttribute("viewBox",`0 0 ${$} ${J}`),Z}#a(Q,$){return{x:Q*this.#O,y:(1-$)*this.#H}}#Q0(Q,$){return{x:Q/this.#O,y:1-$/this.#H}}#i={minVal:0,maxVal:1.2,totalTime:1};#s(Q,$){let Z=this.#H-40,{minVal:j,maxVal:q}=this.#i,_=q-j||1;return{x:Q*this.#O,y:20+(1-($-j)/_)*Z}}#p(){if(this.#d(),this.#J==="spring")this.#Z0();else this.#$0()}#e(){this.#K?.classList.toggle("is-active",this.#J==="bezier"&&this.#q===1),this.#Y?.classList.toggle("is-active",this.#J==="bezier"&&this.#q===2)}#$0(){if(this.#R)this.#R.setAttribute("x","0"),this.#R.setAttribute("y","0"),this.#R.setAttribute("width",this.#O),this.#R.setAttribute("height",this.#H);if(this.#F)this.#F.setAttribute("x1","0"),this.#F.setAttribute("y1",this.#H),this.#F.setAttribute("x2",this.#O),this.#F.setAttribute("y2","0");let Q=this.#a(0,0),$=this.#a(this.#$.x,this.#$.y),J=this.#a(this.#Q.x,this.#Q.y),Z=this.#a(1,1);this.#X.setAttribute("d",`M${Q.x},${Q.y} C${$.x},${$.y} ${J.x},${J.y} ${Z.x},${Z.y}`),this.#K.setAttribute("x1",Q.x),this.#K.setAttribute("y1",Q.y),this.#K.setAttribute("x2",$.x),this.#K.setAttribute("y2",$.y),this.#Y.setAttribute("x1",Z.x),this.#Y.setAttribute("y1",Z.y),this.#Y.setAttribute("x2",J.x),this.#Y.setAttribute("y2",J.y);let j=this.#C;if(this.#W.setAttribute("x",$.x-j),this.#W.setAttribute("y",$.y-j),this.#N.setAttribute("x",J.x-j),this.#N.setAttribute("y",J.y-j),this.#L)this.#L.setAttribute("cx",Q.x),this.#L.setAttribute("cy",Q.y);if(this.#U)this.#U.setAttribute("cx",Z.x),this.#U.setAttribute("cy",Z.y);this.#J0()}#J0(){if(!this.#_||!this.#W||!this.#N)return;let Q=this.#$.y>=this.#Q.y?[this.#W,this.#N]:[this.#N,this.#W];for(let $ of Q)this.#_.append($)}#Z0(){if(this.#R)this.#R.setAttribute("x","0"),this.#R.setAttribute("y","0"),this.#R.setAttribute("width",this.#O),this.#R.setAttribute("height",this.#H);let Q=this.#I();if(!Q.length)return;let $=Q[Q.length-1].t||1,J=0,Z=1;for(let U of Q){if(U.value<J)J=U.value;if(U.value>Z)Z=U.value}let j=Math.max(Math.abs(J-1),Math.abs(Z-1),0.01),q=0;this.#i={minVal:1-j-q,maxVal:1+j+q,totalTime:$};let _=Math.max(0.05,Math.min(0.95,this.#D)),X="";for(let U=0;U<Q.length;U++){let z=Q[U].t/$*_,A=this.#s(z,Q[U].value);X+=(U===0?"M":"L")+A.x.toFixed(1)+","+A.y.toFixed(1)}let Y=this.#s(_,1),K=this.#s(1,1);if(X+=`L${Y.x.toFixed(1)},${Y.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#X.setAttribute("d",X),this.#A){let U=this.#s(0,1),z=this.#s(1,1);this.#A.setAttribute("x1",U.x),this.#A.setAttribute("y1",U.y),this.#A.setAttribute("x2",z.x),this.#A.setAttribute("y2",z.y)}let N=this.#j0(Q),L=N.t/$*_,O=this.#s(L,N.value),H=this.#C;this.#W.setAttribute("x",O.x-H),this.#W.setAttribute("y",O.y-H);let B=this.#s(_,1);this.#N.setAttribute("x",B.x-this.#T/2),this.#N.setAttribute("y",B.y-this.#E/2)}#j0(Q){let $={t:0,value:1},J=!1;for(let Z of Q){if(Z.value>=0.99)J=!0;if(J&&Z.value>$.value)$={t:Z.t,value:Z.value}}return $}#l(){if(!this.#B)return;this.#B.value=this.#G,this.#N0()}#u(){if(!this.#M)return;this.#M.setAttribute("value",this.value)}#t(Q){let $=Q.split(",").map((J)=>Number.parseFloat(J.trim()));if($.length!==4||$.some((J)=>!Number.isFinite(J)))return null;if($[0]<0||$[0]>1||$[2]<0||$[2]>1)return null;return $}#o(Q,$){let J=this.#t(Q);if(!J){if($==="change")this.#u();return}let Z=this.#J;if(this.#J="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],this.#G=this.#f(),Z!==this.#J)this.#y();else if(this.#p(),this.#l(),$==="change")this.#u();this.#r($)}#q0(Q,$,J){if(!Q)return;for(let Z of Q.querySelectorAll("option"))if(Z.value===$)Z.innerHTML=`${J} ${$}`}#N0(){if(!this.#B)return;if(!this.#V())return;let Q=b.curveIcon(this.#$.x,this.#$.y,this.#Q.x,this.#Q.y),$=b.#w(this.#j);this.#q0(this.#B,"Custom bezier",Q),this.#q0(this.#B,"Custom spring",$),this.#q0(this.#B.select,"Custom bezier",Q),this.#q0(this.#B.select,"Custom spring",$)}#K0(Q){this.#p(),this.#G=this.#f(),this.#l(),this.#u(),this.#r(Q)}#G0(Q,$){let J=Q.shiftKey?0.1:0.01,Z=$===1?this.#$:this.#Q;switch(Q.key){case"ArrowLeft":Z.x-=J;break;case"ArrowRight":Z.x+=J;break;case"ArrowUp":Z.y+=J;break;case"ArrowDown":Z.y-=J;break;case"Home":Z.x=0,Z.y=0;break;case"End":Z.x=1,Z.y=1;break;default:return!1}return Z.x=Math.max(0,Math.min(1,Math.round(Z.x*100)/100)),Z.y=Math.round(Z.y*100)/100,this.#K0("input"),this.#r("change"),!0}#U0(Q,$){let J=Q.shiftKey?10:1;if($==="bounce")switch(Q.key){case"ArrowUp":this.#j.damping=Math.max(1,Math.round(this.#j.damping-J));break;case"ArrowDown":this.#j.damping=Math.max(1,Math.round(this.#j.damping+J));break;case"Home":this.#j.damping=1;break;case"End":this.#j.damping=50;break;default:return!1}else{let Z=J*2;switch(Q.key){case"ArrowLeft":this.#D=Math.max(0.05,this.#D-Z/200),this.#j.stiffness=Math.max(10,Math.round(this.#j.stiffness+Z*1.5));break;case"ArrowRight":this.#D=Math.min(0.95,this.#D+Z/200),this.#j.stiffness=Math.max(10,Math.round(this.#j.stiffness-Z*1.5));break;case"Home":this.#D=0.05;break;case"End":this.#D=0.95;break;default:return!1}}return this.#K0("input"),this.#r("change"),!0}#_0(Q,$){let J=Q?.querySelector("fig-handle");if(!J)return;J.addEventListener("pointerdown",(Z)=>{if(Z.preventDefault(),Z.stopImmediatePropagation(),this.#J==="bezier")this.#X0(Z,Number($));else this.#Y0(Z,$)},{capture:!0}),J.addEventListener("keydown",(Z)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Z.key))return;if(!(this.#J==="bezier"?this.#G0(Z,Number($)):this.#U0(Z,$)))return;Z.preventDefault(),Z.stopImmediatePropagation()},{capture:!0})}#r(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#J,value:this.value,cssValue:this.cssValue,preset:this.#G}}))}#L0(){if(this.#_&&this.#J==="bezier"){this.#_0(this.#W,"1"),this.#_0(this.#N,"2"),this.#W.addEventListener("pointerdown",($)=>this.#X0($,1)),this.#N.addEventListener("pointerdown",($)=>this.#X0($,2));let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#X0($,this.#M0($))})}else if(this.#_){this.#_0(this.#W,"bounce"),this.#_0(this.#N,"duration"),this.#W.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#Y0($,"bounce")}),this.#N.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#Y0($,"duration")});let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#Y0($,"duration")})}if(this.#B)this.#B.addEventListener("change",(Q)=>{let $=Q.detail,J=b.PRESETS.find((Z)=>Z.name===$);if(!J)return;if(J.type==="bezier"){if(J.value)this.#$.x=J.value[0],this.#$.y=J.value[1],this.#Q.x=J.value[2],this.#Q.y=J.value[3];if(this.#G=$,this.#J!=="bezier")this.#J="bezier",this.#y();else if(this.#_)this.#p(),this.#u()}else if(J.type==="spring"){if(J.spring)this.#j={...J.spring};if(this.#G=$,this.#J!=="spring")this.#J="spring",this.#y();else if(this.#_)this.#p(),this.#u()}this.#r("input"),this.#r("change")});if(this.#M)this.#M.addEventListener("input",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#o($,"input")}),this.#M.addEventListener("change",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#o($,"change")})}#W0(Q){let $=this.#_.getScreenCTM();if(!$)return{x:0,y:0};let J=$.inverse();return{x:J.a*Q.clientX+J.c*Q.clientY+J.e,y:J.b*Q.clientX+J.d*Q.clientY+J.f}}#M0(Q){return this.#W0(Q).x<=this.#O/2?1:2}#X0(Q,$){Q.preventDefault(),this.#q=$,this.#e();let J=(j)=>{if(!this.#q)return;let q=this.#W0(j),_=this.#Q0(q.x,q.y);if(_.x=Math.round(_.x*100)/100,_.y=Math.round(_.y*100)/100,_.x=Math.max(0,Math.min(1,_.x)),this.#q===1)this.#$.x=_.x,this.#$.y=_.y;else this.#Q.x=_.x,this.#Q.y=_.y;this.#p(),this.#G=this.#f(),this.#l(),this.#u(),this.#r("input")},Z=()=>{this.#q=null,this.#e(),document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",Z),this.#r("change")};document.addEventListener("pointermove",J),document.addEventListener("pointerup",Z)}#Y0(Q,$){Q.preventDefault(),this.#q=$;let J=this.#j.damping,Z=this.#j.stiffness,j=this.#D,q=Q.clientY,_=Q.clientX,X=(K)=>{if(!this.#q)return;if($==="bounce"){let N=K.clientY-q;this.#j.damping=Math.max(1,Math.round(J+N*0.15))}else{let N=K.clientX-_;this.#D=Math.max(0.05,Math.min(0.95,j+N/200)),this.#j.stiffness=Math.max(10,Math.round(Z-N*1.5))}this.#p(),this.#G=this.#f(),this.#l(),this.#u(),this.#r("input")},Y=()=>{this.#q=null,document.removeEventListener("pointermove",X),document.removeEventListener("pointerup",Y),this.#r("change")};document.addEventListener("pointermove",X),document.addEventListener("pointerup",Y)}}customElements.define("fig-easing-curve",b);class i0 extends HTMLElement{#$=0;#Q=0;#j=0;#J=1;#Z=!1;#q=!1;#_=null;#X=null;#K=null;#Y=null;#W=[];#N={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#J=parseInt(this.getAttribute("precision")||"1"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),V(this,"--perspective",this.getAttribute("perspective")),V(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#L(this.getAttribute("transform-origin")),this.#M(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#G(Q);this.#A(),this.#B(this.getAttribute("selected")),this.#U()}disconnectedCallback(){if(this.#Z=!1,this.#K)window.removeEventListener("keydown",this.#K),window.removeEventListener("keyup",this.#Y)}#L(Q){if(!Q||!Q.trim()){this.style.removeProperty("--transform-origin");return}let $=Q.trim().split(/\s+/);if($.length===2)this.style.setProperty("--transform-origin",`${$[0]} ${$[1]} -50cqi`);else this.style.setProperty("--transform-origin",Q.trim())}#U(){if(!this.#X)return;this.#X.style.cursor=this.#z?"":"default"}#B(Q){if(!this.#_)return;let $=this.#_.querySelectorAll(".fig-3d-rotate-face"),J=Q?Q.trim().toLowerCase():"";for(let Z of $)Z.classList.toggle("selected",J!==""&&Z.classList.contains(J))}#M(Q){if(!Q||!Q.trim()){this.#W=[];return}let $=["rotateX","rotateY","rotateZ"];this.#W=Q.split(",").map((J)=>J.trim()).filter((J)=>$.includes(J))}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",J);return}if(Q==="perspective"){V(this,"--perspective",J);return}if(Q==="perspective-origin"){V(this,"--perspective-origin",J);return}if(Q==="transform-origin"){this.#L(J);return}if(Q==="selected"){this.#B(J);return}if(Q==="drag"){this.#U();return}if(Q==="fields"){if(this.#M(J),this.#_)this.#A();return}if(!this.#_)return;if(Q==="value"&&J){if(this.#Z)return;this.#G(J),this.#O(),this.#D()}if(Q==="precision")this.#J=parseInt(J||"1")}get value(){let Q=this.#J;return`rotateX(${this.#$.toFixed(Q)}deg) rotateY(${this.#Q.toFixed(Q)}deg) rotateZ(${this.#j.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#$}get rotateY(){return this.#Q}get rotateZ(){return this.#j}#G(Q){let $=Q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),J=Q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),Z=Q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if($)this.#$=parseFloat($[1]);if(J)this.#Q=parseFloat(J[1]);if(Z)this.#j=parseFloat(Z[1])}#A(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},$={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#j},J=this.#W.map((Z)=>`<fig-input-number
216
+ </svg></div>${J}`}#v(Q,$){let J=getComputedStyle(this).getPropertyValue(Q).trim();if(!J)return $;let Z=Number.parseFloat(J);return Number.isFinite(Z)?Z:$}#I(){this.#S=this.#v("--easing-bezier-endpoint-radius",this.#S),this.#E=this.#v("--easing-duration-bar-radius",this.#E)}#m(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#X=this.querySelector(".fig-easing-curve-path"),this.#K=this.querySelector('[data-arm="1"]'),this.#Y=this.querySelector('[data-arm="2"]'),this.#N=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#W=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#L=this.querySelector('[data-endpoint="start"]'),this.#G=this.querySelector('[data-endpoint="end"]'),this.#U=this.querySelector(".fig-easing-curve-dropdown"),this.#B=this.querySelector(".fig-easing-curve-value-input"),this.#R=this.querySelector(".fig-easing-curve-target"),this.#D=this.querySelector(".fig-easing-curve-bounds"),this.#H=this.querySelector(".fig-easing-curve-diagonal")}#p(){let Q=this.#N?.querySelector("fig-handle"),$=this.#W?.querySelector("fig-handle");if(Q){let J=Q.offsetWidth||this.#k*2,Z=Q.offsetHeight||this.#k*2;this.#k=Math.max(J,Z)/2,this.#N.setAttribute("width",J),this.#N.setAttribute("height",Z)}if($){let J=$.offsetWidth||this.#f,Z=$.offsetHeight||this.#P;if(this.#J==="spring")this.#f=J,this.#P=Z;this.#W.setAttribute("width",J),this.#W.setAttribute("height",Z)}}#d(){if(this.#O||!window.ResizeObserver)return;this.#O=new ResizeObserver(()=>{if(this.#s())this.#c()}),this.#O.observe(this)}#s(){if(!this.#_)return!1;let Q=this.#_.getBoundingClientRect(),$=Math.max(1,Math.round(Q.width||200)),J=Math.max(1,Math.round(Q.height||200)),Z=$!==this.#A||J!==this.#F;return this.#A=$,this.#F=J,this.#_.setAttribute("viewBox",`0 0 ${$} ${J}`),Z}#t(Q,$){return{x:Q*this.#A,y:(1-$)*this.#F}}#Q0(Q,$){return{x:Q/this.#A,y:1-$/this.#F}}#o={minVal:0,maxVal:1.2,totalTime:1};#r(Q,$){let Z=this.#F-40,{minVal:j,maxVal:q}=this.#o,_=q-j||1;return{x:Q*this.#A,y:20+(1-($-j)/_)*Z}}#c(){if(this.#s(),this.#J==="spring")this.#Z0();else this.#$0()}#e(){this.#K?.classList.toggle("is-active",this.#J==="bezier"&&this.#q===1),this.#Y?.classList.toggle("is-active",this.#J==="bezier"&&this.#q===2)}#$0(){if(this.#D)this.#D.setAttribute("x","0"),this.#D.setAttribute("y","0"),this.#D.setAttribute("width",this.#A),this.#D.setAttribute("height",this.#F);if(this.#H)this.#H.setAttribute("x1","0"),this.#H.setAttribute("y1",this.#F),this.#H.setAttribute("x2",this.#A),this.#H.setAttribute("y2","0");let Q=this.#t(0,0),$=this.#t(this.#$.x,this.#$.y),J=this.#t(this.#Q.x,this.#Q.y),Z=this.#t(1,1);this.#X.setAttribute("d",`M${Q.x},${Q.y} C${$.x},${$.y} ${J.x},${J.y} ${Z.x},${Z.y}`),this.#K.setAttribute("x1",Q.x),this.#K.setAttribute("y1",Q.y),this.#K.setAttribute("x2",$.x),this.#K.setAttribute("y2",$.y),this.#Y.setAttribute("x1",Z.x),this.#Y.setAttribute("y1",Z.y),this.#Y.setAttribute("x2",J.x),this.#Y.setAttribute("y2",J.y);let j=this.#k;if(this.#N.setAttribute("x",$.x-j),this.#N.setAttribute("y",$.y-j),this.#W.setAttribute("x",J.x-j),this.#W.setAttribute("y",J.y-j),this.#L)this.#L.setAttribute("cx",Q.x),this.#L.setAttribute("cy",Q.y);if(this.#G)this.#G.setAttribute("cx",Z.x),this.#G.setAttribute("cy",Z.y);this.#J0()}#J0(){if(!this.#_||!this.#N||!this.#W)return;let Q=this.#$.y>=this.#Q.y?[this.#N,this.#W]:[this.#W,this.#N];for(let $ of Q)this.#_.append($)}#Z0(){if(this.#D)this.#D.setAttribute("x","0"),this.#D.setAttribute("y","0"),this.#D.setAttribute("width",this.#A),this.#D.setAttribute("height",this.#F);let Q=this.#x();if(!Q.length)return;let $=Q[Q.length-1].t||1,J=0,Z=1;for(let U of Q){if(U.value<J)J=U.value;if(U.value>Z)Z=U.value}let j=Math.max(Math.abs(J-1),Math.abs(Z-1),0.01),q=0;this.#o={minVal:1-j-q,maxVal:1+j+q,totalTime:$};let _=Math.max(0.05,Math.min(0.95,this.#z)),X="";for(let U=0;U<Q.length;U++){let z=Q[U].t/$*_,A=this.#r(z,Q[U].value);X+=(U===0?"M":"L")+A.x.toFixed(1)+","+A.y.toFixed(1)}let Y=this.#r(_,1),K=this.#r(1,1);if(X+=`L${Y.x.toFixed(1)},${Y.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#X.setAttribute("d",X),this.#R){let U=this.#r(0,1),z=this.#r(1,1);this.#R.setAttribute("x1",U.x),this.#R.setAttribute("y1",U.y),this.#R.setAttribute("x2",z.x),this.#R.setAttribute("y2",z.y)}let N=this.#j0(Q),L=N.t/$*_,O=this.#r(L,N.value),H=this.#k;this.#N.setAttribute("x",O.x-H),this.#N.setAttribute("y",O.y-H);let B=this.#r(_,1);this.#W.setAttribute("x",B.x-this.#f/2),this.#W.setAttribute("y",B.y-this.#P/2)}#j0(Q){let $={t:0,value:1},J=!1;for(let Z of Q){if(Z.value>=0.99)J=!0;if(J&&Z.value>$.value)$={t:Z.t,value:Z.value}}return $}#a(){if(!this.#U)return;this.#U.value=this.#M,this.#N0()}#u(){if(!this.#B)return;this.#B.setAttribute("value",this.value)}#n(Q){let $=Q.split(",").map((J)=>Number.parseFloat(J.trim()));if($.length!==4||$.some((J)=>!Number.isFinite(J)))return null;if($[0]<0||$[0]>1||$[2]<0||$[2]>1)return null;return $}#l(Q,$){let J=this.#n(Q);if(!J){if($==="change")this.#u();return}let Z=this.#J;if(this.#J="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3],this.#M=this.#C(),Z!==this.#J)this.#y();else if(this.#c(),this.#a(),$==="change")this.#u();this.#i($)}#q0(Q,$,J){if(!Q)return;for(let Z of Q.querySelectorAll("option"))if(Z.value===$)Z.innerHTML=`${J} ${$}`}#N0(){if(!this.#U)return;if(!this.#V())return;let Q=b.curveIcon(this.#$.x,this.#$.y,this.#Q.x,this.#Q.y),$=b.#b(this.#j);this.#q0(this.#U,"Custom bezier",Q),this.#q0(this.#U,"Custom spring",$),this.#q0(this.#U.select,"Custom bezier",Q),this.#q0(this.#U.select,"Custom spring",$)}#K0(Q){this.#c(),this.#M=this.#C(),this.#a(),this.#u(),this.#i(Q)}#G0(Q,$){let J=Q.shiftKey?0.1:0.01,Z=$===1?this.#$:this.#Q;switch(Q.key){case"ArrowLeft":Z.x-=J;break;case"ArrowRight":Z.x+=J;break;case"ArrowUp":Z.y+=J;break;case"ArrowDown":Z.y-=J;break;case"Home":Z.x=0,Z.y=0;break;case"End":Z.x=1,Z.y=1;break;default:return!1}return Z.x=Math.max(0,Math.min(1,Math.round(Z.x*100)/100)),Z.y=Math.round(Z.y*100)/100,this.#K0("input"),this.#i("change"),!0}#U0(Q,$){let J=Q.shiftKey?10:1;if($==="bounce")switch(Q.key){case"ArrowUp":this.#j.damping=Math.max(1,Math.round(this.#j.damping-J));break;case"ArrowDown":this.#j.damping=Math.max(1,Math.round(this.#j.damping+J));break;case"Home":this.#j.damping=1;break;case"End":this.#j.damping=50;break;default:return!1}else{let Z=J*2;switch(Q.key){case"ArrowLeft":this.#z=Math.max(0.05,this.#z-Z/200),this.#j.stiffness=Math.max(10,Math.round(this.#j.stiffness+Z*1.5));break;case"ArrowRight":this.#z=Math.min(0.95,this.#z+Z/200),this.#j.stiffness=Math.max(10,Math.round(this.#j.stiffness-Z*1.5));break;case"Home":this.#z=0.05;break;case"End":this.#z=0.95;break;default:return!1}}return this.#K0("input"),this.#i("change"),!0}#_0(Q,$){let J=Q?.querySelector("fig-handle");if(!J)return;J.addEventListener("pointerdown",(Z)=>{if(Z.preventDefault(),Z.stopImmediatePropagation(),this.#J==="bezier")this.#X0(Z,Number($));else this.#Y0(Z,$)},{capture:!0}),J.addEventListener("keydown",(Z)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Z.key))return;if(!(this.#J==="bezier"?this.#G0(Z,Number($)):this.#U0(Z,$)))return;Z.preventDefault(),Z.stopImmediatePropagation()},{capture:!0})}#i(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#J,value:this.value,cssValue:this.cssValue,preset:this.#M}}))}#L0(){if(this.#_&&this.#J==="bezier"){this.#_0(this.#N,"1"),this.#_0(this.#W,"2"),this.#N.addEventListener("pointerdown",($)=>this.#X0($,1)),this.#W.addEventListener("pointerdown",($)=>this.#X0($,2));let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#X0($,this.#M0($))})}else if(this.#_){this.#_0(this.#N,"bounce"),this.#_0(this.#W,"duration"),this.#N.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#Y0($,"bounce")}),this.#W.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#Y0($,"duration")});let Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#Y0($,"duration")})}if(this.#U)this.#U.addEventListener("change",(Q)=>{let $=Q.detail,J=b.PRESETS.find((Z)=>Z.name===$);if(!J)return;if(J.type==="bezier"){if(J.value)this.#$.x=J.value[0],this.#$.y=J.value[1],this.#Q.x=J.value[2],this.#Q.y=J.value[3];if(this.#M=$,this.#J!=="bezier")this.#J="bezier",this.#y();else if(this.#_)this.#c(),this.#u()}else if(J.type==="spring"){if(J.spring)this.#j={...J.spring};if(this.#M=$,this.#J!=="spring")this.#J="spring",this.#y();else if(this.#_)this.#c(),this.#u()}this.#i("input"),this.#i("change")});if(this.#B)this.#B.addEventListener("input",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#l($,"input")}),this.#B.addEventListener("change",(Q)=>{Q.stopPropagation();let $=Q.detail??Q.target?.value;if(typeof $!=="string")return;this.#l($,"change")})}#W0(Q){let $=this.#_.getScreenCTM();if(!$)return{x:0,y:0};let J=$.inverse();return{x:J.a*Q.clientX+J.c*Q.clientY+J.e,y:J.b*Q.clientX+J.d*Q.clientY+J.f}}#M0(Q){return this.#W0(Q).x<=this.#A/2?1:2}#X0(Q,$){Q.preventDefault(),this.#q=$,this.#e();let J=(j)=>{if(!this.#q)return;let q=this.#W0(j),_=this.#Q0(q.x,q.y);if(_.x=Math.round(_.x*100)/100,_.y=Math.round(_.y*100)/100,_.x=Math.max(0,Math.min(1,_.x)),this.#q===1)this.#$.x=_.x,this.#$.y=_.y;else this.#Q.x=_.x,this.#Q.y=_.y;this.#c(),this.#M=this.#C(),this.#a(),this.#u(),this.#i("input")},Z=()=>{this.#q=null,this.#e(),document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",Z),this.#i("change")};document.addEventListener("pointermove",J),document.addEventListener("pointerup",Z)}#Y0(Q,$){Q.preventDefault(),this.#q=$;let J=this.#j.damping,Z=this.#j.stiffness,j=this.#z,q=Q.clientY,_=Q.clientX,X=(K)=>{if(!this.#q)return;if($==="bounce"){let N=K.clientY-q;this.#j.damping=Math.max(1,Math.round(J+N*0.15))}else{let N=K.clientX-_;this.#z=Math.max(0.05,Math.min(0.95,j+N/200)),this.#j.stiffness=Math.max(10,Math.round(Z-N*1.5))}this.#c(),this.#M=this.#C(),this.#a(),this.#u(),this.#i("input")},Y=()=>{this.#q=null,document.removeEventListener("pointermove",X),document.removeEventListener("pointerup",Y),this.#i("change")};document.addEventListener("pointermove",X),document.addEventListener("pointerup",Y)}}customElements.define("fig-easing-curve",b);class o0 extends HTMLElement{#$=0;#Q=0;#j=0;#J=1;#Z=!1;#q=!1;#_=null;#X=null;#K=null;#Y=null;#N=(Q)=>this.#C(Q);#W=null;#L=[];#G={};#U={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#J=parseInt(this.getAttribute("precision")||"1"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),V(this,"--perspective",this.getAttribute("perspective")),V(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#R(this.getAttribute("transform-origin")),this.#F(this.getAttribute("fields"));let Q=this.getAttribute("value");if(Q)this.#D(Q);if(this.querySelector(".fig-3d-rotate-container"))this.#B();else this.#H();this.#A(this.getAttribute("selected")),this.#z()}disconnectedCallback(){this.#Z=!1,this.#M()}#B(){this.#X=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#O(),this.#S(),this.#E()}#M(){if(this.#W?.abort(),this.#W=null,this.#K)window.removeEventListener("keydown",this.#K),window.removeEventListener("keyup",this.#Y),this.#K=null,this.#Y=null}#R(Q){if(!Q||!Q.trim()){this.style.removeProperty("--transform-origin");return}let $=Q.trim().split(/\s+/);if($.length===2)this.style.setProperty("--transform-origin",`${$[0]} ${$[1]} -50cqi`);else this.style.setProperty("--transform-origin",Q.trim())}#z(){if(!this.#X)return;this.#X.style.cursor=this.#T?"":"default"}#A(Q){if(!this.#_)return;let $=this.#_.querySelectorAll(".fig-3d-rotate-face"),J=Q?Q.trim().toLowerCase():"";for(let Z of $)Z.classList.toggle("selected",J!==""&&Z.classList.contains(J))}#F(Q){if(!Q||!Q.trim()){this.#L=[];return}let $=["rotateX","rotateY","rotateZ"];this.#L=Q.split(",").map((J)=>J.trim()).filter((J)=>$.includes(J))}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",J);return}if(Q==="perspective"){V(this,"--perspective",J);return}if(Q==="perspective-origin"){V(this,"--perspective-origin",J);return}if(Q==="transform-origin"){this.#R(J);return}if(Q==="selected"){this.#A(J);return}if(Q==="drag"){this.#z();return}if(Q==="fields"){if(this.#F(J),this.#_)this.#H();return}if(!this.#_)return;if(Q==="value"&&J){if(this.#Z)return;this.#D(J),this.#S(),this.#k()}if(Q==="precision")this.#J=parseInt(J||"1")}get value(){let Q=this.#J;return`rotateX(${this.#$.toFixed(Q)}deg) rotateY(${this.#Q.toFixed(Q)}deg) rotateZ(${this.#j.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#$}get rotateY(){return this.#Q}get rotateZ(){return this.#j}#D(Q){let $=Q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),J=Q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),Z=Q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if($)this.#$=parseFloat($[1]);if(J)this.#Q=parseFloat(J[1]);if(Z)this.#j=parseFloat(Z[1])}#H(){let Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},$={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#j},J=this.#L.map((Z)=>`<fig-input-number
217
217
  name="${Z}"
218
218
  step="1"
219
219
  precision="1"
@@ -231,7 +231,7 @@ var B1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var O1={};var G0=B1(()=>{/*! Vendored from @
231
231
  <div class="fig-3d-rotate-face bottom"></div>
232
232
  </div>
233
233
  </div>
234
- </div>${J}`,this.#X=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#N={};for(let Z of this.#W){let j=this.querySelector(`fig-input-number[name="${Z}"]`);if(j){this.#N[Z]=j;let q=(_)=>{_.stopPropagation();let X=parseFloat(_.target.value);if(isNaN(X))return;if(Z==="rotateX")this.#$=X;else if(Z==="rotateY")this.#Q=X;else if(Z==="rotateZ")this.#j=X;this.#O(),this.#H(_.type)};j.addEventListener("input",q),j.addEventListener("change",q)}}this.#O(),this.#F()}#D(){let Q={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#j};for(let $ of this.#W){let J=this.#N[$];if(J)J.setAttribute("value",Q[$].toFixed(this.#J))}}#O(){if(!this.#_)return;this.#_.style.transform=`rotateX(${this.#$}deg) rotateY(${this.#Q}deg) rotateZ(${this.#j}deg)`}#H(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#j}}))}#R(Q){if(!this.#q)return Q;return Math.round(Q/15)*15}#F(){this.#X.addEventListener("pointerdown",(Q)=>this.#C(Q)),this.#K=(Q)=>{if(Q.key==="Shift")this.#q=!0},this.#Y=(Q)=>{if(Q.key==="Shift")this.#q=!1},window.addEventListener("keydown",this.#K),window.addEventListener("keyup",this.#Y)}get#z(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#C(Q){if(!this.#z)return;Q.preventDefault(),this.#Z=!0,this.#X.classList.add("dragging"),this.#X.setPointerCapture(Q.pointerId);let{clientX:$,clientY:J}=Q,Z=this.#$,j=this.#Q,q=(X)=>{if(!this.#Z)return;if(X.buttons===0){_();return}let Y=X.clientX-$,K=X.clientY-J;this.#Q=this.#R(j+Y*0.5),this.#$=this.#R(Z-K*0.5),this.#O(),this.#D(),this.setAttribute("value",this.value),this.#H("input")},_=()=>{if(!this.#Z)return;this.setAttribute("value",this.value),this.#Z=!1,this.#X.classList.remove("dragging"),this.#X.removeEventListener("pointermove",q),this.#X.removeEventListener("pointerup",_),this.#X.removeEventListener("pointercancel",_),this.#X.removeEventListener("lostpointercapture",_),this.#H("change")};this.#X.addEventListener("pointermove",q),this.#X.addEventListener("pointerup",_),this.#X.addEventListener("pointercancel",_),this.#X.addEventListener("lostpointercapture",_)}}customElements.define("fig-3d-rotate",i0);class q0 extends HTMLElement{#$=50;#Q=50;#j=0;#J=null;#Z=[];#q=null;#_=null;#X=null;#K=!1;#Y=!1;#W=null;#N=null;#L=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"]}connectedCallback(){this.#j=parseInt(this.getAttribute("precision")||"0"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#O(this.getAttribute("value")),this.#H(),this.#M(),this.#F()}disconnectedCallback(){this.#K=!1,this.#b()}get value(){let Q=this.#j;return`${this.#$.toFixed(Q)}% ${this.#Q.toFixed(Q)}%`}set value(Q){this.setAttribute("value",Q)}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",J);return}if(Q==="drag"){this.#M();return}if(Q==="fields"){this.#H(),this.#M(),this.#F();return}if(Q==="precision"){this.#j=parseInt(J||"0"),this.#R(),this.#F();return}if(Q==="value"){if(this.#Y||this.#K)return;this.#O(J),this.#C(),this.#k(),this.#R()}}get#U(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}get#B(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#M(){if(!this.#J)return;this.#J.classList.toggle("drag-disabled",!this.#U)}#G(Q){return Math.max(0,Math.min(100,Q))}#A(Q,$){let J=(Q||"").trim().toLowerCase();if(!J)return $==="x"?this.#$:this.#Q;let Z=$==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if(J in Z)return Z[J];let j=Number.parseFloat(J.replace("%",""));if(Number.isFinite(j))return j;return $==="x"?this.#$:this.#Q}#D(Q){let $=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if($.length<1)return;if($.length===1){let J=this.#A($[0],"x");this.#$=J,this.#Q=J;return}this.#$=this.#A($[0],"x"),this.#Q=this.#A($[1],"y")}#O(Q){let $=typeof Q==="string"?Q.trim():"";if(!$){this.#$=50,this.#Q=50;return}this.#D($)}#H(){let Q=Array.from({length:9},(j,q)=>{let _=q%3,X=Math.floor(q/3);return`<span class="origin-grid-cell" data-col="${_}" data-row="${X}">
234
+ </div>${J}`,this.#X=this.querySelector(".fig-3d-rotate-container"),this.#_=this.querySelector(".fig-3d-rotate-cube"),this.#O(),this.#S(),this.#E()}#O(){this.#G={};for(let Q of this.#L){let $=this.querySelector(`fig-input-number[name="${Q}"]`);if(!$)continue;if(this.#G[Q]=$,!this.#U[Q])this.#U[Q]=(Z)=>{Z.stopPropagation();let j=parseFloat(Z.target.value);if(isNaN(j))return;if(Q==="rotateX")this.#$=j;else if(Q==="rotateY")this.#Q=j;else if(Q==="rotateZ")this.#j=j;this.#S(),this.#f(Z.type)};let J=this.#U[Q];$.removeEventListener("input",J),$.removeEventListener("change",J),$.addEventListener("input",J),$.addEventListener("change",J)}}#k(){let Q={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#j};for(let $ of this.#L){let J=this.#G[$];if(J)J.setAttribute("value",Q[$].toFixed(this.#J))}}#S(){if(!this.#_)return;this.#_.style.transform=`rotateX(${this.#$}deg) rotateY(${this.#Q}deg) rotateZ(${this.#j}deg)`}#f(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#j}}))}#P(Q){if(!this.#q)return Q;return Math.round(Q/15)*15}#E(){if(this.#M(),!this.#X)return;this.#W=new AbortController,this.#X.addEventListener("pointerdown",this.#N,{signal:this.#W.signal}),this.#K=(Q)=>{if(Q.key==="Shift")this.#q=!0},this.#Y=(Q)=>{if(Q.key==="Shift")this.#q=!1},window.addEventListener("keydown",this.#K),window.addEventListener("keyup",this.#Y)}get#T(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#C(Q){if(!this.#T)return;Q.preventDefault(),this.#Z=!0,this.#X.classList.add("dragging"),this.#X.setPointerCapture(Q.pointerId);let{clientX:$,clientY:J}=Q,Z=this.#$,j=this.#Q,q=(X)=>{if(!this.#Z)return;if(X.buttons===0){_();return}let Y=X.clientX-$,K=X.clientY-J;this.#Q=this.#P(j+Y*0.5),this.#$=this.#P(Z-K*0.5),this.#S(),this.#k(),this.setAttribute("value",this.value),this.#f("input")},_=()=>{if(!this.#Z)return;this.setAttribute("value",this.value),this.#Z=!1,this.#X.classList.remove("dragging"),this.#X.removeEventListener("pointermove",q),this.#X.removeEventListener("pointerup",_),this.#X.removeEventListener("pointercancel",_),this.#X.removeEventListener("lostpointercapture",_),this.#f("change")};this.#X.addEventListener("pointermove",q),this.#X.addEventListener("pointerup",_),this.#X.addEventListener("pointercancel",_),this.#X.addEventListener("lostpointercapture",_)}}customElements.define("fig-3d-rotate",o0);class _0 extends HTMLElement{#$=50;#Q=50;#j=0;#J=null;#Z=[];#q=null;#_=null;#X=null;#K=!1;#Y=!1;#N=null;#W=null;#L=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"]}#G(){this.#J=this.querySelector(".origin-grid"),this.#Z=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#X=this.querySelector('fig-input-number[name="y"]'),this.#S(),this.#f(),this.#H(),this.#m()}connectedCallback(){if(this.#j=parseInt(this.getAttribute("precision")||"0"),V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#F(this.getAttribute("value")),this.querySelector(".fig-origin-grid-surface"))this.#G();else this.#D();this.#M(),this.#O()}disconnectedCallback(){this.#K=!1,this.#h(),this.#I()}get value(){let Q=this.#j;return`${this.#$.toFixed(Q)}% ${this.#Q.toFixed(Q)}%`}set value(Q){this.setAttribute("value",Q)}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",J);return}if(Q==="drag"){this.#M();return}if(Q==="fields"){this.#D(),this.#M(),this.#O();return}if(Q==="precision"){this.#j=parseInt(J||"0"),this.#H(),this.#O();return}if(Q==="value"){if(this.#Y||this.#K)return;this.#F(J),this.#S(),this.#f(),this.#H()}}get#U(){let Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}get#B(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#M(){if(!this.#J)return;this.#J.classList.toggle("drag-disabled",!this.#U)}#R(Q){return Math.max(0,Math.min(100,Q))}#z(Q,$){let J=(Q||"").trim().toLowerCase();if(!J)return $==="x"?this.#$:this.#Q;let Z=$==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if(J in Z)return Z[J];let j=Number.parseFloat(J.replace("%",""));if(Number.isFinite(j))return j;return $==="x"?this.#$:this.#Q}#A(Q){let $=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if($.length<1)return;if($.length===1){let J=this.#z($[0],"x");this.#$=J,this.#Q=J;return}this.#$=this.#z($[0],"x"),this.#Q=this.#z($[1],"y")}#F(Q){let $=typeof Q==="string"?Q.trim():"";if(!$){this.#$=50,this.#Q=50;return}this.#A($)}#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}">
235
235
  <span class="origin-grid-dot"></span>
236
236
  </span>`}).join(""),$=this.#$.toFixed(this.#j),J=this.#Q.toFixed(this.#j),Z=this.#B?`<div class="origin-values">
237
237
  <fig-input-number name="x" value="${$}" step="1" units="%"><span slot="prepend">X</span></fig-input-number>
@@ -242,7 +242,7 @@ var B1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var O1={};var G0=B1(()=>{/*! Vendored from @
242
242
  <fig-handle></fig-handle>
243
243
  </div>
244
244
  </div>
245
- ${Z}`,this.#J=this.querySelector(".origin-grid"),this.#Z=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#X=this.querySelector('fig-input-number[name="y"]'),this.#C(),this.#k(),this.#R(),this.#v()}#R(){let Q=this.#$.toFixed(this.#j),$=this.#Q.toFixed(this.#j);if(this.#_)this.#_.setAttribute("value",Q);if(this.#X)this.#X.setAttribute("value",$)}#F(){let Q=this.value;if(this.getAttribute("value")===Q)return;this.#Y=!0,this.setAttribute("value",Q),this.#Y=!1}#z(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#$,y:this.#Q}}))}#C(){if(!this.#q)return;let Q=($)=>16.6667+this.#G($)/100*66.6667;this.#q.style.left=`${Q(this.#$)}%`,this.#q.style.top=`${Q(this.#Q)}%`}#k(){if(!this.#q)return;let Q=this.#$<0||this.#$>100,$=this.#Q<0||this.#Q>100,J=this.#$<0,Z=this.#$>100,j=this.#Q<0,q=this.#Q>100;this.#q.classList.toggle("beyond-bounds-x",Q),this.#q.classList.toggle("beyond-bounds-y",$),this.#q.classList.toggle("overflow-left",J),this.#q.classList.toggle("overflow-right",Z),this.#q.classList.toggle("overflow-up",j),this.#q.classList.toggle("overflow-down",q)}#T(Q,$){if(!this.#J)return null;let J=this.#J.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1),j=($-J.top)/Math.max(J.height,1);if(Z<0||Z>1||j<0||j>1)return null;let q=Math.max(0,Math.min(2,Math.floor(Z*3))),_=Math.max(0,Math.min(2,Math.floor(j*3)));return this.#Z.find((X)=>Number(X.getAttribute("data-col"))===q&&Number(X.getAttribute("data-row"))===_)}#E(){for(let Q of this.#Z)Q.classList.remove("is-hovered")}#P(Q){if(this.#E(),Q)Q.classList.add("is-hovered")}#S(Q,$,J){let Z=Number(Q),j=Number($);if(!Number.isFinite(Z)||!Number.isFinite(j))return;if(Z===this.#$&&j===this.#Q&&J==="input")return;this.#$=Z,this.#Q=j,this.#C(),this.#k(),this.#R(),this.#F(),this.#z(J)}#f(Q,$){if(!this.#J)return{x:this.#$,y:this.#Q};let J=this.#J.getBoundingClientRect(),Z=J.width/6,j=J.height/6,q=Math.max(1,J.width-Z*2),_=Math.max(1,J.height-j*2),X=(Q-(J.left+Z))/q,Y=($-(J.top+j))/_;return{x:X*100,y:Y*100}}#I(Q,$){if(!this.#J)return{x:50,y:50};let J=this.#J.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1)*3,j=($-J.top)/Math.max(J.height,1)*3,q=Math.max(0,Math.min(2,Math.floor(Z))),_=Math.max(0,Math.min(2,Math.floor(j)));return{x:q*50,y:_*50}}#w(Q){let J=Q,Z=1/0;for(let j of q0.SNAP_POINTS){let q=Math.abs(Q-j);if(q<Z)Z=q,J=j}return Z<=2.5?J:Q}#V(Q,$){if(!$)return Q;return{x:this.#w(Q.x),y:this.#w(Q.y)}}#y(Q){if(!this.#U)return!1;let $=Q.shiftKey?10:1,J=this.#$,Z=this.#Q;switch(Q.key){case"ArrowLeft":J-=$;break;case"ArrowRight":J+=$;break;case"ArrowUp":Z-=$;break;case"ArrowDown":Z+=$;break;case"Home":J=0,Z=0;break;case"End":J=100,Z=100;break;default:return!1}return this.#S(this.#G(J),this.#G(Z),"input"),this.#z("change"),!0}#b(){if(!this.#J||!this.#N||!this.#L)return;this.#J.removeEventListener("pointermove",this.#N),this.#J.removeEventListener("pointerup",this.#L),this.#J.removeEventListener("pointercancel",this.#L),this.#J.removeEventListener("lostpointercapture",this.#L),this.#N=null,this.#L=null}#g(Q){if(!this.#J||!this.#U)return;Q.preventDefault(),this.#K=!0,this.#W=Q.pointerId;let{clientX:$,clientY:J}=Q,Z=3,j=!1;this.#J.setPointerCapture(Q.pointerId),this.#N=(q)=>{if(!this.#K||q.pointerId!==this.#W)return;let _=q.clientX-$,X=q.clientY-J,Y=Math.hypot(_,X);if(!j&&Y<Z)return;if(!j)j=!0,this.#J.classList.add("is-dragging"),this.#E();let K=this.#V(this.#f(q.clientX,q.clientY),q.shiftKey);this.#S(K.x,K.y,"input")},this.#L=(q)=>{if(!this.#K||q.pointerId!==this.#W)return;if(this.#K=!1,this.#W=null,this.#J.classList.remove("is-dragging"),this.#E(),this.#b(),!j){let _=this.#I($,J);this.#S(_.x,_.y,"input")}this.#z("change")},this.#J.addEventListener("pointermove",this.#N),this.#J.addEventListener("pointerup",this.#L),this.#J.addEventListener("pointercancel",this.#L),this.#J.addEventListener("lostpointercapture",this.#L)}#v(){if(!this.#J||!this.#q)return;this.#J.addEventListener("pointerdown",($)=>{let J=this.#T($.clientX,$.clientY);if(this.#P(J),this.#U){this.#g($);return}let Z=this.#I($.clientX,$.clientY);this.#S(Z.x,Z.y,"input"),this.#z("change")}),this.#J.addEventListener("pointermove",($)=>{if(this.#K)return;let J=this.#T($.clientX,$.clientY);this.#P(J)}),this.#J.addEventListener("pointerleave",()=>{this.#E()}),this.#q.addEventListener("keydown",($)=>{if(!this.#y($))return;$.preventDefault(),$.stopPropagation()});let Q=($,J)=>{if(!$)return;let Z=(j)=>{let q=Number.parseFloat(j.target.value);if(!Number.isFinite(q))return;if(J==="x")this.#S(q,this.#Q,"input");else this.#S(this.#$,q,"input")};$.addEventListener("input",Z),$.addEventListener("change",Z),$.addEventListener("focusout",()=>{this.#z("change")})};Q(this.#_,"x"),Q(this.#X,"y")}}customElements.define("fig-origin-grid",q0);class o0 extends HTMLElement{#$=null;#Q=null;#j=null;#J=null;#Z=null;#q=null;#_=null;#X=null;#K=!1;#Y={x:0.5,y:0.5};#W=!1;constructor(){super();this.position={x:0.5,y:0.5},this.isDragging=!1,this.plane=null,this.cursor=null,this.xInput=null,this.yInput=null,this.coordinates="screen",this.#$=(Q)=>this.#F(Q),this.#Q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#j=(Q)=>this.#z(Q),this.#J=()=>this.#C(),this.#Z=(Q)=>this.#D(Q),this.#q=(Q)=>this.#O(Q),this.#_=()=>this.#H(),this.#X=()=>this.#H()}connectedCallback(){requestAnimationFrame(()=>{if(this.precision=this.getAttribute("precision")||3,this.precision=parseInt(this.precision),this.transform=this.getAttribute("transform")||1,this.transform=Number(this.transform),this.coordinates=this.getAttribute("coordinates")||"screen",V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");this.#U(),this.#G(),this.#E(),this.#P(),this.#S(),this.#W=!0})}#N(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#A()}get#L(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#U(){this.innerHTML=this.#M()}#B(){let Q=(this.getAttribute("axis-labels")||"").trim();if(!Q)return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1};let $=Q.split(/[\s,]+/).filter(Boolean);if($.length===1)return{left:"",right:"",top:$[0],bottom:"",leftNoRotate:!1};if($.length===2){let[J,Z]=$;return{left:J,right:"",top:"",bottom:Z,leftNoRotate:!0}}if($.length===4){let[J,Z,j,q]=$;return{left:J,right:Z,top:j,bottom:q,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#M(){let Q=this.#B();return`
245
+ ${Z}`,this.#J=this.querySelector(".origin-grid"),this.#Z=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#q=this.querySelector("fig-handle"),this.#_=this.querySelector('fig-input-number[name="x"]'),this.#X=this.querySelector('fig-input-number[name="y"]'),this.#S(),this.#f(),this.#H(),this.#m()}#H(){let Q=this.#$.toFixed(this.#j),$=this.#Q.toFixed(this.#j);if(this.#_)this.#_.setAttribute("value",Q);if(this.#X)this.#X.setAttribute("value",$)}#O(){let Q=this.value;if(this.getAttribute("value")===Q)return;this.#Y=!0,this.setAttribute("value",Q),this.#Y=!1}#k(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#$,y:this.#Q}}))}#S(){if(!this.#q)return;let Q=($)=>16.6667+this.#R($)/100*66.6667;this.#q.style.left=`${Q(this.#$)}%`,this.#q.style.top=`${Q(this.#Q)}%`}#f(){if(!this.#q)return;let Q=this.#$<0||this.#$>100,$=this.#Q<0||this.#Q>100,J=this.#$<0,Z=this.#$>100,j=this.#Q<0,q=this.#Q>100;this.#q.classList.toggle("beyond-bounds-x",Q),this.#q.classList.toggle("beyond-bounds-y",$),this.#q.classList.toggle("overflow-left",J),this.#q.classList.toggle("overflow-right",Z),this.#q.classList.toggle("overflow-up",j),this.#q.classList.toggle("overflow-down",q)}#P(Q,$){if(!this.#J)return null;let J=this.#J.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1),j=($-J.top)/Math.max(J.height,1);if(Z<0||Z>1||j<0||j>1)return null;let q=Math.max(0,Math.min(2,Math.floor(Z*3))),_=Math.max(0,Math.min(2,Math.floor(j*3)));return this.#Z.find((X)=>Number(X.getAttribute("data-col"))===q&&Number(X.getAttribute("data-row"))===_)}#E(){for(let Q of this.#Z)Q.classList.remove("is-hovered")}#T(Q){if(this.#E(),Q)Q.classList.add("is-hovered")}#C(Q,$,J){let Z=Number(Q),j=Number($);if(!Number.isFinite(Z)||!Number.isFinite(j))return;if(Z===this.#$&&j===this.#Q&&J==="input")return;this.#$=Z,this.#Q=j,this.#S(),this.#f(),this.#H(),this.#O(),this.#k(J)}#x(Q,$){if(!this.#J)return{x:this.#$,y:this.#Q};let J=this.#J.getBoundingClientRect(),Z=J.width/6,j=J.height/6,q=Math.max(1,J.width-Z*2),_=Math.max(1,J.height-j*2),X=(Q-(J.left+Z))/q,Y=($-(J.top+j))/_;return{x:X*100,y:Y*100}}#b(Q,$){if(!this.#J)return{x:50,y:50};let J=this.#J.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1)*3,j=($-J.top)/Math.max(J.height,1)*3,q=Math.max(0,Math.min(2,Math.floor(Z))),_=Math.max(0,Math.min(2,Math.floor(j)));return{x:q*50,y:_*50}}#V(Q){let J=Q,Z=1/0;for(let j of _0.SNAP_POINTS){let q=Math.abs(Q-j);if(q<Z)Z=q,J=j}return Z<=2.5?J:Q}#y(Q,$){if(!$)return Q;return{x:this.#V(Q.x),y:this.#V(Q.y)}}#w(Q){if(!this.#U)return!1;let $=Q.shiftKey?10:1,J=this.#$,Z=this.#Q;switch(Q.key){case"ArrowLeft":J-=$;break;case"ArrowRight":J+=$;break;case"ArrowUp":Z-=$;break;case"ArrowDown":Z+=$;break;case"Home":J=0,Z=0;break;case"End":J=100,Z=100;break;default:return!1}return this.#C(this.#R(J),this.#R(Z),"input"),this.#k("change"),!0}#h(){if(!this.#J||!this.#W||!this.#L)return;this.#J.removeEventListener("pointermove",this.#W),this.#J.removeEventListener("pointerup",this.#L),this.#J.removeEventListener("pointercancel",this.#L),this.#J.removeEventListener("lostpointercapture",this.#L),this.#W=null,this.#L=null}#g(Q){if(!this.#J||!this.#U)return;Q.preventDefault(),this.#K=!0,this.#N=Q.pointerId;let{clientX:$,clientY:J}=Q,Z=3,j=!1;this.#J.setPointerCapture(Q.pointerId),this.#W=(q)=>{if(!this.#K||q.pointerId!==this.#N)return;let _=q.clientX-$,X=q.clientY-J,Y=Math.hypot(_,X);if(!j&&Y<Z)return;if(!j)j=!0,this.#J.classList.add("is-dragging"),this.#E();let K=this.#y(this.#x(q.clientX,q.clientY),q.shiftKey);this.#C(K.x,K.y,"input")},this.#L=(q)=>{if(!this.#K||q.pointerId!==this.#N)return;if(this.#K=!1,this.#N=null,this.#J.classList.remove("is-dragging"),this.#E(),this.#h(),!j){let _=this.#b($,J);this.#C(_.x,_.y,"input")}this.#k("change")},this.#J.addEventListener("pointermove",this.#W),this.#J.addEventListener("pointerup",this.#L),this.#J.addEventListener("pointercancel",this.#L),this.#J.addEventListener("lostpointercapture",this.#L)}#v=null;#I(){this.#v?.abort(),this.#v=null}#m(){if(this.#I(),!this.#J||!this.#q)return;this.#v=new AbortController;let{signal:Q}=this.#v;this.#J.addEventListener("pointerdown",(J)=>{let Z=this.#P(J.clientX,J.clientY);if(this.#T(Z),this.#U){this.#g(J);return}let j=this.#b(J.clientX,J.clientY);this.#C(j.x,j.y,"input"),this.#k("change")},{signal:Q}),this.#J.addEventListener("pointermove",(J)=>{if(this.#K)return;let Z=this.#P(J.clientX,J.clientY);this.#T(Z)},{signal:Q}),this.#J.addEventListener("pointerleave",()=>{this.#E()},{signal:Q}),this.#q.addEventListener("keydown",(J)=>{if(!this.#w(J))return;J.preventDefault(),J.stopPropagation()},{signal:Q});let $=(J,Z)=>{if(!J)return;let j=(q)=>{let _=Number.parseFloat(q.target.value);if(!Number.isFinite(_))return;if(Z==="x")this.#C(_,this.#Q,"input");else this.#C(this.#$,_,"input")};J.addEventListener("input",j,{signal:Q}),J.addEventListener("change",j,{signal:Q}),J.addEventListener("focusout",()=>{this.#k("change")},{signal:Q})};$(this.#_,"x"),$(this.#X,"y")}}customElements.define("fig-origin-grid",_0);class l0 extends HTMLElement{#$=null;#Q=null;#j=null;#J=null;#Z=null;#q=null;#_=null;#X=null;#K=!1;#Y={x:0.5,y:0.5};#N=!1;constructor(){super();this.position={x:0.5,y:0.5},this.isDragging=!1,this.plane=null,this.cursor=null,this.xInput=null,this.yInput=null,this.coordinates="screen",this.#$=(Q)=>this.#O(Q),this.#Q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#j=(Q)=>this.#k(Q),this.#J=()=>this.#S(),this.#Z=(Q)=>this.#A(Q),this.#q=(Q)=>this.#F(Q),this.#_=()=>this.#D(),this.#X=()=>this.#D()}#W(){this.#R(),this.#E(),this.#T(),this.#C(),this.#N=!0}connectedCallback(){v(this,()=>{if(this.precision=this.getAttribute("precision")||3,this.precision=parseInt(this.precision),this.transform=this.getAttribute("transform")||1,this.transform=Number(this.transform),this.coordinates=this.getAttribute("coordinates")||"screen",V(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");if(this.querySelector(".fig-input-joystick-plane")){this.#W();return}this.#U(),this.#R(),this.#E(),this.#T(),this.#C(),this.#N=!0})}#L(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#z()}get#G(){let Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#U(){this.innerHTML=this.#M()}#B(){let Q=(this.getAttribute("axis-labels")||"").trim();if(!Q)return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1};let $=Q.split(/[\s,]+/).filter(Boolean);if($.length===1)return{left:"",right:"",top:$[0],bottom:"",leftNoRotate:!1};if($.length===2){let[J,Z]=$;return{left:J,right:"",top:"",bottom:Z,leftNoRotate:!0}}if($.length===4){let[J,Z,j,q]=$;return{left:J,right:Z,top:j,bottom:q,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#M(){let Q=this.#B();return`
246
246
  <div class="fig-input-joystick-plane-container">
247
247
  ${[Q.left?`<label class="fig-joystick-axis-label left${Q.leftNoRotate?" no-rotate":""}" aria-hidden="true">${Q.left}</label>`:"",Q.right?`<label class="fig-joystick-axis-label right" aria-hidden="true">${Q.right}</label>`:"",Q.top?`<label class="fig-joystick-axis-label top" aria-hidden="true">${Q.top}</label>`:"",Q.bottom?`<label class="fig-joystick-axis-label bottom" aria-hidden="true">${Q.bottom}</label>`:""].join("")}
248
248
  <div class="fig-input-joystick-plane">
@@ -255,7 +255,7 @@ var B1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var O1={};var G0=B1(()=>{/*! Vendored from @
255
255
  </fig-button>
256
256
  </fig-tooltip>
257
257
  </div>
258
- ${this.#L?`<div class="joystick-values">
258
+ ${this.#G?`<div class="joystick-values">
259
259
  <fig-input-number
260
260
  name="x"
261
261
  step="1"
@@ -275,6 +275,6 @@ var B1=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var O1={};var G0=B1(()=>{/*! Vendored from @
275
275
  <span slot="prepend">Y</span>
276
276
  </fig-input-number>
277
277
  </div>`:""}
278
- `}#G(){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.#$),this.cursor?.addEventListener("pointerdown",this.#Q),this.cursor?.addEventListener("input",this.#j),this.cursor?.addEventListener("change",this.#J);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#f());if(this.#L&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#Z),this.xInput.addEventListener("change",this.#Z),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#q),this.yInput.addEventListener("change",this.#q),this.yInput.addEventListener("focusout",this.#X)}#A(){if(this.plane?.removeEventListener("pointerdown",this.#$),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#j),this.cursor?.removeEventListener("change",this.#J),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#L&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#Z),this.xInput.removeEventListener("change",this.#Z),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#q),this.yInput.removeEventListener("change",this.#q),this.yInput.removeEventListener("focusout",this.#X)}#D(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.x=Math.max(0,Math.min(1,$/100)),this.#E(),this.#P(),this.#k()}#O(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.y=Math.max(0,Math.min(1,$/100)),this.#E(),this.#P(),this.#k()}#H(){this.#P(),this.#T()}#R(Q,$,{syncHandle:J=!0}={}){let Z=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,$)),q=this.coordinates==="math"?1-j:j;if(this.position={x:Z,y:q},J)this.#E();this.#P()}#F(Q){if(!this.plane||!this.cursor)return;if(Q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let $=this.plane.getBoundingClientRect(),J=$.width>0?(Q.clientX-$.left)/$.width:0.5,Z=$.height>0?(Q.clientY-$.top)/$.height:0.5;this.cursor.value=`${Math.round(J*100)}% ${Math.round(Z*100)}%`,this.#R(J,Z,{syncHandle:!1}),this.#k(),this.#T()}#z(Q){let $=Q.detail??{};if(typeof $.px!=="number"||typeof $.py!=="number")return;this.#R($.px,$.py,{syncHandle:!1}),this.#k()}#C(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#P(),this.#T()}#k(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#T(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#E(){let Q=this.#N(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;if(this.#L&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#P(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#K=!0,this.setAttribute("value",Q),this.#K=!1;this.#S()}#S(){let Q=this.#Y,$=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",$),this.style.setProperty("--is-not-default",$?"0":"1")}#f(){this.position={...this.#Y},this.#E(),this.#P(),this.#k(),this.#T()}focus(){this.cursor?.focus()}static get observedAttributes(){return["value","precision","transform","fields","coordinates","aspect-ratio","axis-labels"]}get value(){return`${Math.round(this.position.x*100)}% ${Math.round(this.position.y*100)}%`}set value(Q){let $=Q==null?"":String(Q).trim();if(!$)this.position={x:0.5,y:0.5};else{let J=$.split(/[\s,]+/).filter(Boolean),Z=(_)=>{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=Z(J[0]),q=Z(J[1]??J[0]);this.position={x:j,y:q}}if(this.#W)this.#E(),this.#S()}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",J);return}if(Q==="value"){if(this.#K||this.isDragging)return;this.value=J}if(Q==="precision")this.precision=parseInt(J);if(Q==="transform")this.transform=Number(J);if(Q==="fields"&&J!==$)this.#A(),this.#U(),this.#G(),this.#E();if(Q==="axis-labels"&&J!==$)this.#A(),this.#U(),this.#G(),this.#E();if(Q==="coordinates")this.coordinates=J||"screen",this.#E()}}customElements.define("fig-joystick",o0);class _0 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.#$()}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,$,J){if(Q==="duration")this.style.setProperty(this.durationPropertyName,J||"1.5s");if(Q==="playing"||Q==="aria-label"||Q==="aria-labelledby")this.#$()}#$(){let Q=this.playing;if(this.setAttribute("aria-busy",Q?"true":"false"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")){if(!this.hasAttribute("role"))this.setAttribute("role","status");this.removeAttribute("aria-hidden")}else this.removeAttribute("role"),this.setAttribute("aria-hidden","true")}}customElements.define("fig-shimmer",_0);class l0 extends _0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}customElements.define("fig-skeleton",l0);class a0 extends HTMLElement{static observedAttributes=["name","collapsible","open"];#$=null;#Q=null;connectedCallback(){this.#Z()}disconnectedCallback(){if(this.#Q)this.#Q.removeEventListener("click",this.#j);if(this.#$)this.#$.removeEventListener("click",this.#j),this.#$.removeEventListener("keydown",this.#J),this.#$.querySelector("h3")?.removeEventListener("click",this.#j)}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){this.#$?.setAttribute("aria-expanded",String(this.open));return}this.#Z()}get open(){let Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#$?.setAttribute("aria-expanded",String(!!Q)),$!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}#j=(Q)=>{Q.stopPropagation(),this.open=!this.open};#J=(Q)=>{if(Q.key!=="Enter"&&Q.key!==" ")return;Q.preventDefault(),Q.stopPropagation(),this.open=!this.open};#Z(){let Q=this.hasAttribute("collapsible"),J=this.getAttribute("name")||(Q?"Group":null),Z=this.querySelector(":scope > fig-header");if(!J&&!Q&&!Z){if(this.#$&&this.#$.dataset.generated)this.#$.remove(),this.#$=null,this.#Q=null;return}if(Z)this.#$=Z;else if(!this.#$||!this.#$.dataset.generated)this.#$=document.createElement("fig-header"),this.#$.setAttribute("borderless",""),this.#$.dataset.generated="true",this.prepend(this.#$);let j=this.#$.querySelector("h3");if(!j)j=document.createElement("h3"),this.#$.prepend(j);if(!j.id)j.id=y();if(this.#$.dataset.generated)j.textContent=J;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=v("chevron",{size:"small",className:"fig-group-chevron"});j.prepend(q)}if(this.#Q=j.querySelector(".fig-group-chevron"),j.removeEventListener("click",this.#j),this.#$.removeEventListener("click",this.#j),this.#$.addEventListener("click",this.#j),this.#$.setAttribute("role","button"),this.#$.setAttribute("tabindex","0"),this.#$.setAttribute("aria-expanded",String(this.open)),this.#$.removeEventListener("keydown",this.#J),this.#$.addEventListener("keydown",this.#J),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#$.setAttribute("aria-expanded","false")}else{if(j.removeEventListener("click",this.#j),this.#$.removeEventListener("click",this.#j),this.#$.removeAttribute("role"),this.#$.removeAttribute("tabindex"),this.#$.removeAttribute("aria-expanded"),this.#$.removeEventListener("keydown",this.#J),this.#Q)this.#Q.remove(),this.#Q=null;this.removeAttribute("open")}}}customElements.define("fig-group",a0);class t0 extends HTMLElement{}customElements.define("fig-header",t0);class n0 extends HTMLElement{}customElements.define("fig-footer",n0);class e0 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Loading")}}customElements.define("fig-spinner",e0);class Q1 extends HTMLElement{static get observedAttributes(){return["fit"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="fit")this.#$()}#$(){let Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-preview-fit",Q);else this.style.removeProperty("--fig-preview-fit")}}customElements.define("fig-preview",Q1);var C1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:"--icon-16-reset","arrow-left":"--icon-16-arrow-left",steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function S1(Q,$="medium"){let J=Q&&C1[Q];if(!J)return"";let Z=typeof J==="string"?J:J[$==="small"?"small":"medium"];return Z?`var(${Z})`:""}class $1 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($!==J)this.#$()}#$(){let Q=this.getAttribute("name"),$=this.getAttribute("size")||"medium",J=S1(Q,$);if(J)this.style.setProperty("--icon",J);else this.style.removeProperty("--icon");if($==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let Z=this.getAttribute("color");if(Z)this.style.backgroundColor=Z;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}customElements.define("fig-icon",$1);class J1 extends HTMLElement{}customElements.define("fig-content",J1);class Z1 extends HTMLElement{}customElements.define("fig-tab-content",Z1);class j1 extends HTMLElement{}customElements.define("fig-button-combo",j1);class q1 extends HTMLElement{}customElements.define("fig-input-combo",q1);class _1 extends HTMLElement{#$=null;#Q=null;#j=null;#J=this.#A.bind(this);#Z=this.#D.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.#Y(),this.#B()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#W)}#_(){if(this.#$)this.#$.removeEventListener("input",this.#J),this.#$.removeEventListener("change",this.#Z);if(this.#Q)this.#Q.removeEventListener("input",this.#J),this.#Q.removeEventListener("change",this.#Z);if(this.#j)this.#j.disconnect(),this.#j=null}#X(){if(this.#j)this.#j.disconnect(),this.#j=null;if(!this.#Q)return;this.#j=new MutationObserver(()=>{if(this.#Q?.hasAttribute("selected")&&this.#Q.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#j.observe(this.#Q,{attributes:!0,attributeFilter:["selected"]})}get#K(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#Y(){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="${Y}"><fig-icon name="${X}"></fig-icon></fig-button>`,this.#$=null,this.#Q=null,this.addEventListener("click",this.#W),this.#M();return}this.removeEventListener("click",this.#W);let $=(this.getAttribute("value")||"").trim(),J=this.#U($),Z=this.#L($),j=this.#K?"":'alpha="false"',q=Z<1?JSON.stringify({type:"solid",color:J,opacity:Math.round(Z*100)}):JSON.stringify({type:"solid",color:J}),_=Z<1?` alpha="${Z}"`:"";if(this.innerHTML=m()?`<fig-fill-picker mode="solid" ${j} value='${q}'>
278
+ `}#R(){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.#$),this.cursor?.addEventListener("pointerdown",this.#Q),this.cursor?.addEventListener("input",this.#j),this.cursor?.addEventListener("change",this.#J);let Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#x());if(this.#G&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#Z),this.xInput.addEventListener("change",this.#Z),this.xInput.addEventListener("focusout",this.#_),this.yInput.addEventListener("input",this.#q),this.yInput.addEventListener("change",this.#q),this.yInput.addEventListener("focusout",this.#X)}#z(){if(this.plane?.removeEventListener("pointerdown",this.#$),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#j),this.cursor?.removeEventListener("change",this.#J),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#G&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#Z),this.xInput.removeEventListener("change",this.#Z),this.xInput.removeEventListener("focusout",this.#_),this.yInput.removeEventListener("input",this.#q),this.yInput.removeEventListener("change",this.#q),this.yInput.removeEventListener("focusout",this.#X)}#A(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.x=Math.max(0,Math.min(1,$/100)),this.#E(),this.#T(),this.#f()}#F(Q){let $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.y=Math.max(0,Math.min(1,$/100)),this.#E(),this.#T(),this.#f()}#D(){this.#T(),this.#P()}#H(Q,$,{syncHandle:J=!0}={}){let Z=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,$)),q=this.coordinates==="math"?1-j:j;if(this.position={x:Z,y:q},J)this.#E();this.#T()}#O(Q){if(!this.plane||!this.cursor)return;if(Q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let $=this.plane.getBoundingClientRect(),J=$.width>0?(Q.clientX-$.left)/$.width:0.5,Z=$.height>0?(Q.clientY-$.top)/$.height:0.5;this.cursor.value=`${Math.round(J*100)}% ${Math.round(Z*100)}%`,this.#H(J,Z,{syncHandle:!1}),this.#f(),this.#P()}#k(Q){let $=Q.detail??{};if(typeof $.px!=="number"||typeof $.py!=="number")return;this.#H($.px,$.py,{syncHandle:!1}),this.#f()}#S(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#T(),this.#P()}#f(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#P(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#E(){let Q=this.#L(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;if(this.#G&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#T(){let Q=this.value;if(this.getAttribute("value")!==Q)this.#K=!0,this.setAttribute("value",Q),this.#K=!1;this.#C()}#C(){let Q=this.#Y,$=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",$),this.style.setProperty("--is-not-default",$?"0":"1")}#x(){this.position={...this.#Y},this.#E(),this.#T(),this.#f(),this.#P()}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==null?"":String(Q).trim();if(!$)this.position={x:0.5,y:0.5};else{let J=$.split(/[\s,]+/).filter(Boolean),Z=(_)=>{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=Z(J[0]),q=Z(J[1]??J[0]);this.position={x:j,y:q}}if(this.#N)this.#E(),this.#C()}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){V(this,"--aspect-ratio",J);return}if(Q==="value"){if(this.#K||this.isDragging)return;this.value=J}if(Q==="precision")this.precision=parseInt(J);if(Q==="transform")this.transform=Number(J);if(Q==="fields"&&J!==$)this.#z(),this.#U(),this.#R(),this.#E();if(Q==="axis-labels"&&J!==$)this.#z(),this.#U(),this.#R(),this.#E();if(Q==="coordinates")this.coordinates=J||"screen",this.#E()}}customElements.define("fig-joystick",l0);class X0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let Q=this.getAttribute("duration");if(Q)this.style.setProperty(this.durationPropertyName,Q);this.#$()}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,$,J){if(Q==="duration")this.style.setProperty(this.durationPropertyName,J||"1.5s");if(Q==="playing"||Q==="aria-label"||Q==="aria-labelledby")this.#$()}#$(){let Q=this.playing;if(this.setAttribute("aria-busy",Q?"true":"false"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")){if(!this.hasAttribute("role"))this.setAttribute("role","status");this.removeAttribute("aria-hidden")}else this.removeAttribute("role"),this.setAttribute("aria-hidden","true")}}customElements.define("fig-shimmer",X0);class a0 extends X0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}customElements.define("fig-skeleton",a0);class t0 extends HTMLElement{static observedAttributes=["name","collapsible","open"];#$=null;#Q=null;connectedCallback(){this.#Z()}disconnectedCallback(){if(this.#Q)this.#Q.removeEventListener("click",this.#j);if(this.#$)this.#$.removeEventListener("click",this.#j),this.#$.removeEventListener("keydown",this.#J),this.#$.querySelector("h3")?.removeEventListener("click",this.#j)}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){this.#$?.setAttribute("aria-expanded",String(this.open));return}this.#Z()}get open(){let Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){let $=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#$?.setAttribute("aria-expanded",String(!!Q)),$!==!!Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!Q},bubbles:!0}))}#j=(Q)=>{Q.stopPropagation(),this.open=!this.open};#J=(Q)=>{if(Q.key!=="Enter"&&Q.key!==" ")return;Q.preventDefault(),Q.stopPropagation(),this.open=!this.open};#Z(){let Q=this.hasAttribute("collapsible"),J=this.getAttribute("name")||(Q?"Group":null),Z=this.querySelector(":scope > fig-header");if(!J&&!Q&&!Z){if(this.#$&&this.#$.dataset.generated)this.#$.remove(),this.#$=null,this.#Q=null;return}if(Z)this.#$=Z;else if(!this.#$||!this.#$.dataset.generated)this.#$=document.createElement("fig-header"),this.#$.setAttribute("borderless",""),this.#$.dataset.generated="true",this.prepend(this.#$);let j=this.#$.querySelector("h3");if(!j)j=document.createElement("h3"),this.#$.prepend(j);if(!j.id)j.id=y();if(this.#$.dataset.generated)j.textContent=J;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=h("chevron",{size:"small",className:"fig-group-chevron"});j.prepend(q)}if(this.#Q=j.querySelector(".fig-group-chevron"),j.removeEventListener("click",this.#j),this.#$.removeEventListener("click",this.#j),this.#$.addEventListener("click",this.#j),this.#$.setAttribute("role","button"),this.#$.setAttribute("tabindex","0"),this.#$.setAttribute("aria-expanded",String(this.open)),this.#$.removeEventListener("keydown",this.#J),this.#$.addEventListener("keydown",this.#J),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#$.setAttribute("aria-expanded","false")}else{if(j.removeEventListener("click",this.#j),this.#$.removeEventListener("click",this.#j),this.#$.removeAttribute("role"),this.#$.removeAttribute("tabindex"),this.#$.removeAttribute("aria-expanded"),this.#$.removeEventListener("keydown",this.#J),this.#Q)this.#Q.remove(),this.#Q=null;this.removeAttribute("open")}}}customElements.define("fig-group",t0);class n0 extends HTMLElement{}customElements.define("fig-header",n0);class e0 extends HTMLElement{}customElements.define("fig-footer",e0);class Q1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Loading")}}customElements.define("fig-spinner",Q1);class $1 extends HTMLElement{static get observedAttributes(){return["fit"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="fit")this.#$()}#$(){let Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-preview-fit",Q);else this.style.removeProperty("--fig-preview-fit")}}customElements.define("fig-preview",$1);var S1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:"--icon-16-reset","arrow-left":"--icon-16-arrow-left",steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function f1(Q,$="medium"){let J=Q&&S1[Q];if(!J)return"";let Z=typeof J==="string"?J:J[$==="small"?"small":"medium"];return Z?`var(${Z})`:""}class J1 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#$()}attributeChangedCallback(Q,$,J){if($!==J)this.#$()}#$(){let Q=this.getAttribute("name"),$=this.getAttribute("size")||"medium",J=f1(Q,$);if(J)this.style.setProperty("--icon",J);else this.style.removeProperty("--icon");if($==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let Z=this.getAttribute("color");if(Z)this.style.backgroundColor=Z;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}customElements.define("fig-icon",J1);class Z1 extends HTMLElement{}customElements.define("fig-content",Z1);class j1 extends HTMLElement{}customElements.define("fig-tab-content",j1);class q1 extends HTMLElement{}customElements.define("fig-button-combo",q1);class _1 extends HTMLElement{}customElements.define("fig-input-combo",_1);class X1 extends HTMLElement{#$=null;#Q=null;#j=null;#J=this.#R.bind(this);#Z=this.#z.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#q(){return this.getAttribute("control")||"color"}connectedCallback(){this.#Y(),this.#U()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#N)}#_(){if(this.#$)this.#$.removeEventListener("input",this.#J),this.#$.removeEventListener("change",this.#Z);if(this.#Q)this.#Q.removeEventListener("input",this.#J),this.#Q.removeEventListener("change",this.#Z);if(this.#j)this.#j.disconnect(),this.#j=null}#X(){if(this.#j)this.#j.disconnect(),this.#j=null;if(!this.#Q)return;this.#j=new MutationObserver(()=>{if(this.#Q?.hasAttribute("selected")&&this.#Q.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#j.observe(this.#Q,{attributes:!0,attributeFilter:["selected"]})}get#K(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#Y(){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="${Y}"><fig-icon name="${X}"></fig-icon></fig-button>`,this.#$=null,this.#Q=null,this.addEventListener("click",this.#N),this.#B();return}this.removeEventListener("click",this.#N);let $=(this.getAttribute("value")||"").trim(),J=this.#G($),Z=this.#L($),j=this.#K?"":'alpha="false"',q=Z<1?JSON.stringify({type:"solid",color:J,opacity:Math.round(Z*100)}):JSON.stringify({type:"solid",color:J}),_=Z<1?` alpha="${Z}"`:"";if(this.innerHTML=p()?`<fig-fill-picker mode="solid" ${j} value='${q}'>
279
279
  <fig-chit background="${J}"${_}></fig-chit>
280
- </fig-fill-picker>`:`<fig-chit background="${J}"${_}></fig-chit>`,this.#$=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-chit"),this.#_(),this.#$?.addEventListener("input",this.#J),this.#$?.addEventListener("change",this.#Z),!this.#$)this.#Q?.addEventListener("input",this.#J),this.#Q?.addEventListener("change",this.#Z);this.#X(),this.#M()}#W=()=>{let Q=this.#q;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#N(Q){if(!Q)return"#D9D9D9";let $=Q.replace("#","").trim();if($.length===3||$.length===4){let[J,Z,j]=$;return`#${J}${J}${Z}${Z}${j}${j}`.toUpperCase()}if($.length===6||$.length===8)return`#${$.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#L(Q){if(!Q)return 1;let $=String(Q).trim(),J=$.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test(J)){let j=J[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test(J))return parseInt(J.slice(6,8),16)/255;let Z=$.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(Z)return parseFloat(Z[1]);return 1}#U(Q){if(!Q)return"#D9D9D9";let $=String(Q).trim();if($.startsWith("{"))try{let J=JSON.parse($);if(J?.color)return this.#U(J.color)}catch{}if($.startsWith("#"))return this.#N($);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test($))return this.#N($);try{let{ctx:J}=Z0(1,1);J.fillStyle="#000000",J.fillStyle=$;let Z=J.fillStyle;if(Z.startsWith("#"))return this.#N(Z);let j=Z.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"}#B(){let Q=this.getAttribute("value"),$=this.#U(Q),J=this.#L(Q);if(Q!==$&&J>=1){this.setAttribute("value",$);return}if(this.#$){this.#M();let Z=J<1?{type:"solid",color:$,opacity:Math.round(J*100)}:{type:"solid",color:$};if(this.#$.setAttribute("value",JSON.stringify(Z)),this.#K)this.#$.removeAttribute("alpha");else this.#$.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}if(this.#Q){if(this.#M(),this.#Q.setAttribute("background",$),J<1)this.#Q.setAttribute("alpha",String(J));else this.#Q.removeAttribute("alpha");if(this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}}#M(){let Q=this.#q,$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",$?"true":"false"),this.setAttribute("aria-pressed",J?"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),$)X?.setAttribute("disabled","");else X?.removeAttribute("disabled");return}let Z=this.#$||this.#Q;if(!Z)return;let j=this.getAttribute("aria-label")||"Color stop",q=this.getAttribute("aria-labelledby"),_=this.getAttribute("aria-describedby");if(q)Z.setAttribute("aria-labelledby",q),Z.removeAttribute("aria-label");else Z.setAttribute("aria-label",j),Z.removeAttribute("aria-labelledby");if(_)Z.setAttribute("aria-describedby",_);else Z.removeAttribute("aria-describedby")}#G(Q,$){let J=this.#U(Q?.color),Z=this.#U(this.getAttribute("value"));if(J!==Z)this.setAttribute("value",J);else this.#B();let j={color:this.value};if(this.#K){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent($,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#A(Q){Q.stopPropagation(),this.#G(Q.detail||{color:Q.target?.value},"input")}#D(Q){Q.stopPropagation(),this.#G(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,$,J){if($===J)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.#B(),this.#M();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 this.hasAttribute("selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return this.hasAttribute("disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}customElements.define("fig-color-tip",_1);class X1 extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false"),this.hasAttribute("disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false");if(Q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}customElements.define("fig-choice",X1);class Y1 extends HTMLElement{#$=null;#Q=this.#H.bind(this);#j=this.#R.bind(this);#J=this.#z.bind(this);#Z=null;#q=null;#_=null;#X=null;#K=null;#Y=null;#W=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#N(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#L(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#U(){return this.getAttribute("choice-element")||"fig-choice"}#B(){let Q=this.getAttribute("columns"),$=Q===null?NaN:Number(Q);if(Number.isInteger($)&&$>0)this.style.setProperty("--fig-chooser-grid-columns",String($));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from((this.#_||this).querySelectorAll(this.#U))}get#M(){return this.#_||this}get scrollTop(){return this.#M.scrollTop}set scrollTop(Q){this.#M.scrollTop=Q}get scrollLeft(){return this.#M.scrollLeft}set scrollLeft(Q){this.#M.scrollLeft=Q}get scrollWidth(){return this.#M.scrollWidth}get scrollHeight(){return this.#M.scrollHeight}scrollTo(...Q){this.#M.scrollTo(...Q)}scrollBy(...Q){this.#M.scrollBy(...Q)}get selectedChoice(){return this.#$}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let $=this.choices;for(let Z of $){let j=Z===Q,q=Z.hasAttribute("selected");if(j&&!q)Z.setAttribute("selected","");else if(!j&&q)Z.removeAttribute("selected")}this.#$=Q;let J=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==J){if(J)this.setAttribute("value",J)}this.#w(Q)}get value(){return this.#$?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){this.setAttribute("role","listbox"),this.#B(),this.#E(),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#j),this.#M.addEventListener("scroll",this.#J),this.#P(),this.#k(),this.#V(),this.#C(),requestAnimationFrame(()=>{this.#A(),this.#z(),this.#G()})}#G(){let Q=()=>{if(!this.isConnected)return;if(this.#$)this.#w(this.#$,"auto")},$=()=>{let J=this.querySelectorAll("img, video");for(let Z of J){if(Z.tagName==="IMG"?Z.complete:Z.readyState>=1)continue;let j=()=>{Z.removeEventListener("load",j),Z.removeEventListener("loadedmetadata",j),Z.removeEventListener("error",j),Q()};Z.addEventListener("load",j),Z.addEventListener("loadedmetadata",j),Z.addEventListener("error",j)}};requestAnimationFrame(()=>{$(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#j),this.#M.removeEventListener("scroll",this.#J),this.#T(),this.#Z?.disconnect(),this.#Z=null,this.#q?.disconnect(),this.#q=null,this.#S()}attributeChangedCallback(Q,$,J){if(Q==="value"&&J!==$&&J)this.#D(J);if(Q==="disabled"){let Z=J!==null&&J!=="false",j=this.choices;for(let q of j)if(Z)q.setAttribute("aria-disabled","true"),q.setAttribute("tabindex","-1");else q.removeAttribute("aria-disabled"),q.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#A());if(Q==="columns")this.#B();if(Q==="drag")if(this.#L)this.#k();else this.#T();if(Q==="overflow")this.#P();if(Q==="layout")this.#P(),requestAnimationFrame(()=>this.#z())}#A(){let Q=this.choices;if(!Q.length){this.#$=null;return}let $=this.getAttribute("value");if($&&this.#D($))return;let J=Q.find((Z)=>Z.hasAttribute("selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=Q[0]}#D(Q){let $=this.choices;for(let J of $)if(J.getAttribute("value")===Q)return this.selectedChoice=J,!0;return!1}#O(Q){let $=this.#U,J=Q;while(J&&J!==this){if(J.matches($))return J;J=J.parentElement}return null}#H(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.#O(Q.target);if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.selectedChoice=$,this.#F()}#R(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!$.length)return;let J=$.indexOf(this.#$),Z=J,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),J<$.length-1)Z=J+1;else if(j)Z=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),J>0)Z=J-1;else if(j)Z=$.length-1;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#U)){let q=this.#O(document.activeElement);if(q&&q!==this.#$)this.selectedChoice=q,this.#F()}return;default:return}if(Z!==J&&$[Z])this.selectedChoice=$[Z],$[Z].focus(),this.#F()}#F(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#z(){if(this.#N==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal";O0(this,this.#M,Q?"x":"y")}#C(){if(this.#q?.disconnect(),this.#q=new ResizeObserver(()=>{this.#z()}),this.#q.observe(this),this.#_)this.#q.observe(this.#_)}#k(){if(this.#Y?.bound)return;if(!this.#L)return;let Q=this.#M,$=(_)=>{if(_.button!==0)return;if(!(this.getAttribute("layout")==="horizontal"?Q.scrollWidth>Q.clientWidth:Q.scrollHeight>Q.clientHeight))return;this.#Y.active=!0,this.#Y.didDrag=!1,this.#Y.startX=_.clientX,this.#Y.startY=_.clientY,this.#Y.scrollLeft=Q.scrollLeft,this.#Y.scrollTop=Q.scrollTop,Q.style.cursor="grab",Q.style.userSelect="none"},J=(_)=>{if(!this.#Y.active)return;let X=this.getAttribute("layout")==="horizontal",Y=_.clientX-this.#Y.startX,K=_.clientY-this.#Y.startY;if(!this.#Y.didDrag&&Math.abs(X?Y:K)>3)this.#Y.didDrag=!0,Q.style.cursor="grabbing",Q.setPointerCapture(_.pointerId);if(!this.#Y.didDrag)return;if(X)Q.scrollLeft=this.#Y.scrollLeft-Y;else Q.scrollTop=this.#Y.scrollTop-K},Z=(_)=>{if(!this.#Y.active)return;let X=this.#Y.didDrag;if(this.#Y.active=!1,this.#Y.didDrag=!1,Q.style.cursor="",Q.style.userSelect="",_.pointerId!==void 0)try{Q.releasePointerCapture(_.pointerId)}catch{}if(X)_.preventDefault(),_.stopPropagation()},j=(_)=>{if(this.#Y?.suppressClick)_.stopPropagation(),_.preventDefault(),this.#Y.suppressClick=!1},q=(_)=>{if(this.#Y?.didDrag)this.#Y.suppressClick=!0,setTimeout(()=>{if(this.#Y)this.#Y.suppressClick=!1},0)};this.#Y={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:$,onPointerMove:J,onPointerUp:Z,onClick:j,onPointerUpCapture:q,scrollEl:Q},Q.addEventListener("pointerdown",$),window.addEventListener("pointermove",J),window.addEventListener("pointerup",Z),this.addEventListener("pointerup",q,!0),this.addEventListener("click",j,!0)}#T(){if(!this.#Y?.bound)return;this.#Y.scrollEl.removeEventListener("pointerdown",this.#Y.onPointerDown),window.removeEventListener("pointermove",this.#Y.onPointerMove),window.removeEventListener("pointerup",this.#Y.onPointerUp),this.removeEventListener("pointerup",this.#Y.onPointerUpCapture,!0),this.removeEventListener("click",this.#Y.onClick,!0),this.#Y.scrollEl.style.cursor="",this.#Y.scrollEl.style.userSelect="",this.#Y=null}#E(){if(this.#W)return;let Q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(Q&&Q===this.#_)return;this.#W=!0;try{let $=this.#_;if($&&$!==Q)$.removeEventListener("scroll",this.#J);let J=Q||document.createElement("div");J.className="fig-chooser-scroll",J.dataset.figChooserScroll="";let Z=Array.from(this.childNodes).filter((j)=>{if(j===J)return!1;if(j.nodeType!==Node.ELEMENT_NODE)return!0;return!j.hasAttribute("data-fig-chooser-nav")});for(let j of Z)J.appendChild(j);if(!Q)this.prepend(J);if(this.#_=J,this.#_.removeEventListener("scroll",this.#J),this.#_.addEventListener("scroll",this.#J),this.#q)this.#q.observe(this.#_)}finally{this.#W=!1}}#P(){if(this.#E(),this.#N==="scrollbar")this.#S();else this.#f()}#S(){this.#X?.remove(),this.#K?.remove(),this.#X=null,this.#K=null,this.classList.remove("overflow-start","overflow-end")}#f(){if(this.#X&&this.#K&&this.contains(this.#X)&&this.contains(this.#K))return;this.#X?.remove(),this.#K?.remove(),this.#X=null,this.#K=null;let Q=B0({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.#X=Q.start,this.#K=Q.end,this.prepend(this.#X),this.append(this.#K)}#I(Q){let $=this.getAttribute("layout")==="horizontal",J=this.#M;$0(J,$?"x":"y",Q)}#w(Q,$="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let J=this.#M,Z=J.scrollHeight>J.clientHeight,j=J.scrollWidth>J.clientWidth;if(!j&&!Z)return;let q=Q.getBoundingClientRect(),_=J.getBoundingClientRect(),X={behavior:$};if(Z){let Y=q.top-_.top+J.scrollTop+q.height/2;X.top=Y-J.clientHeight/2}if(j){let Y=q.left-_.left+J.scrollLeft+q.width/2;X.left=Y-J.clientWidth/2}J.scrollTo(X)})}#V(){this.#Z?.disconnect(),this.#Z=new MutationObserver(()=>{if(this.#W)return;this.#E(),this.#P();let Q=this.choices;if(this.#$&&!Q.includes(this.#$))this.#$=null,this.#A();else if(!this.#$&&Q.length)this.#A();requestAnimationFrame(()=>this.#z())}),this.#Z.observe(this,{childList:!0,subtree:!0})}}customElements.define("fig-chooser",Y1);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"];#$=!1;#Q=!1;#j=null;#J=!1;#Z=null;#q=null;#_=null;#X=null;get#K(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#Y(){return!this.hasAttribute("data-no-color-picker")}get#W(){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#L(){let Q=this.getAttribute("drag-snapping");if(Q===null)return"false";let $=Q.trim().toLowerCase();if($==="modifier")return"modifier";if($===""||$==="true")return"true";return"false"}#U(Q){let $=this.#L;if($==="true")return!0;if($==="modifier")return!!Q;return!1}#B(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,$){if(Math.abs(Q-$)<0.1){let Z=(Q+$)/2;return{x:Z,y:Z}}if(Math.abs(1-Q-$)<0.1)return{x:Q,y:1-Q};return{x:Q,y:$}}#G(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#G();if(!Q)return"0% 0%";let{px:$,py:J}=this.#o(Q.getBoundingClientRect());return`${Math.round($*100)}% ${Math.round(J*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#A(Q){let $=Q==null?"":String(Q).trim();if(!$)return{xPct:0,yPct:0};let J=$.split(/[\s,]+/).filter(Boolean),Z=(_)=>{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=Z(J[0]),q=Z(J[1]??J[0]);return{xToken:j,yToken:q}}#D(Q){let $=this.#G();if(!$)return;let{xToken:J,yToken:Z}=this.#A(Q),j=$.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.#O(X),X.x){let Y=q(J,j.width);this.style.left=Y===null?_(J):`${Math.round(Y)}px`}if(X.y){let Y=q(Z,j.height);this.style.top=Y===null?_(Z):`${Math.round(Y)}px`}}#O(Q=this.#N){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#H(){this.#J=!0,this.setAttribute("value",this.value),this.#J=!1}get#R(){return this.getAttribute("hit-area-mode")||"handle"}#F(){let Q=this.getAttribute("hit-area");if(!Q)return null;let $=Q.trim().split(/\s+/),J=0,Z=0,j=!1,q=[];for(let _ of $){if(_==="circle"){j=!0;continue}let X=parseFloat(_);if(Number.isFinite(X))q.push(X)}if(q.length>=2)J=q[0],Z=q[1];else if(q.length===1)J=q[0],Z=q[0];else return null;return{vPad:J,hPad:Z,circle:j}}#z(){let Q=this.#F();if(!Q){if(this.#X)this.#X.remove(),this.#X=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#X){let $=document.createElement("div");$.classList.add("fig-handle-hit-area"),$.addEventListener("pointerdown",(J)=>this.#C(J)),this.prepend($),this.#X=$}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#X.style.borderRadius="50%";else this.#X.style.borderRadius="inherit"}#C(Q){if(this.hasAttribute("disabled"))return;if(Q.target!==this.#X)return;if(this.#R==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#w(Q)}connectedCallback(){this.#f(),this.#S(),this.#z(),this.addEventListener("click",this.#k),document.addEventListener("pointerdown",this.#T),document.addEventListener("keydown",this.#E);let Q=this.getAttribute("value");if(Q)this.#D(Q);if(this.#K)this.#d()}disconnectedCallback(){if(this.#I(),this.#a(),this.#h(),this.#m(),this.#X)this.#X.remove(),this.#X=null;this.removeEventListener("click",this.#k),document.removeEventListener("pointerdown",this.#T),document.removeEventListener("keydown",this.#E)}select(){if(this.hasAttribute("disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#k=(Q)=>{if(this.#Q){this.#Q=!1;return}if(this.getAttribute("type")==="color"&&this.#Y&&!this.#K){this.#v();return}this.select()};#T=(Q)=>{if(this.contains(Q.target))return;if((this.#Z||this.#q)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#E=(Q)=>{if(Q.defaultPrevented)return;if(Q.target===this&&this.#W&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Q.key)){if(this.#P(Q)){if(Q.preventDefault(),!this.hasAttribute("selected"))this.select()}return}if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target===this&&!this.hasAttribute("selected")){if(Q.preventDefault(),this.getAttribute("type")==="color"&&this.#Y&&!this.#K)this.#v();else this.select();return}if(!this.hasAttribute("selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#Y)return;if(Q.preventDefault(),!this.#K)this.#v()};#P(Q){if(this.hasAttribute("disabled"))return!1;let $=this.#G();if(!$)return!1;let J=$.getBoundingClientRect();if(J.width<=0||J.height<=0)return!1;let Z=this.#N,j=this.#o(J),q=Q.shiftKey?0.1:0.01,_=j.px,X=j.py;switch(Q.key){case"ArrowLeft":if(!Z.x)return!1;_-=q;break;case"ArrowRight":if(!Z.x)return!1;_+=q;break;case"ArrowUp":if(!Z.y)return!1;X-=q;break;case"ArrowDown":if(!Z.y)return!1;X+=q;break;case"Home":if(Z.x)_=0;if(Z.y)X=0;break;case"End":if(Z.x)_=1;if(Z.y)X=1;break;default:return!1}if(_=Math.max(0,Math.min(1,_)),X=Math.max(0,Math.min(1,X)),this.#O(Z),Z.x)this.style.left=`${Math.round(_*J.width)}px`;if(Z.y)this.style.top=`${Math.round(X*J.height)}px`;this.#H();let Y={...this.#o(J),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,$,J){if(Q==="color"){if(!J||J==="false"||J==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",J);if(this.#Z&&this.#K==="color"&&J)this.#Z.setAttribute("value",J);this.#b()}if(Q==="drag")this.#S();if(Q==="hit-area")this.#z();if(Q==="selected")this.#Q0();if(Q==="selected"||Q==="disabled"||Q==="type"||Q==="tip"||Q==="aria-label"||Q==="aria-labelledby")this.#f();if(Q==="value"&&!this.#J&&!this.#$)this.#D(J);if(Q==="tip"){if(this.#a(),this.#K)this.#h(),this.#d()}}#S(){if(this.#W&&!this.#j)this.#j=(Q)=>this.#w(Q),this.addEventListener("pointerdown",this.#j);else if(!this.#W&&this.#j)this.#I()}#f(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=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",$?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let J=this.#K||this.getAttribute("type")||"handle";this.setAttribute("aria-label",J==="color"?"Color handle":J==="add"?"Add handle":J==="remove"?"Remove handle":"Handle")}}#I(){if(this.#j)this.removeEventListener("pointerdown",this.#j),this.#j=null;this.#$=!1}#w(Q){if(!this.#W||this.hasAttribute("disabled"))return;Q.preventDefault();let $=this.#G();if(!$)return;this.#$=!0;let J=this.#N,Z=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,N=Q.clientY,L=3,O=(U,z,A=!1)=>{let G=$.getBoundingClientRect();Z=G;let M=this.#o(G),D=U-X-G.left,T=z-Y-G.top,P=Math.max(0,Math.min(G.width,D)),E=Math.max(0,Math.min(G.height,T)),f=G.width>0?J.x?P/G.width:M.px:0.5,w=G.height>0?J.y?E/G.height:M.py:0.5;if(this.#U(A)){if(J.x)f=this.#B(f);if(J.y)w=this.#B(w);if(J.x&&J.y){let c=this.#M(f,w);f=c.x,w=c.y}}if(this.#O(J),J.x)this.style.left=`${Math.round(Math.max(0,Math.min(G.width,f*G.width)))}px`;if(J.y)this.style.top=`${Math.round(Math.max(0,Math.min(G.height,w*G.height)))}px`},H=(U)=>{if(!this.#$)return;if(!this.#Q){let z=U.clientX-K,A=U.clientY-N;if(z*z+A*A<L*L)return;if(this.#c(),this.classList.add("dragging"),this.style.cursor="grabbing",!this.hasAttribute("selected"))this.select()}this.#Q=!0,O(U.clientX,U.clientY,U.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#o(Z),shiftKey:U.shiftKey}}))},B=(U)=>{if(this.#$=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",B),this.#Q){O(U.clientX,U.clientY,U.shiftKey),this.#H(),this.#D(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#o(Z)}));let z=(A)=>{A.stopPropagation(),A.preventDefault()};this.addEventListener("click",z,{capture:!0,once:!0})}else this.#H();this.#Q=!1};window.addEventListener("pointermove",H),window.addEventListener("pointerup",B)}showColorTip(){if(!this.#K)return;if(this.#Z){this.#Z.style.display="";return}this.#d()}hideColorTip(){if(!this.#Z)return;this.#Z.style.display="none"}#V(Q=this.getAttribute("color")){let $={color:"#D9D9D9",opacity:100},J=String(Q||"").trim();if(!J)return $;let Z=(q)=>{let _=q.replace("#","").trim();if(_.length===3||_.length===4){let[X,Y,K,N]=_;return{color:`#${X}${X}${Y}${Y}${K}${K}`.toUpperCase(),opacity:N?Math.round(parseInt(`${N}${N}`,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 $},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(J.startsWith("#"))return Z(J);try{let{ctx:q}=Z0(1,1);q.fillStyle="#000000",q.fillStyle=J;let _=q.fillStyle;if(_.startsWith("#"))return Z(_);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 $}#y(){let{color:Q,opacity:$}=this.#V();return JSON.stringify($<100?{type:"solid",color:Q,opacity:$}:{type:"solid",color:Q})}#b(){if(!this.#q)return;this.#q.setAttribute("value",this.#y())}#g(){if(!m())return null;if(this.#q)return this.#q;let Q=document.createElement("fig-fill-picker");Q.setAttribute("mode","solid"),Q.setAttribute("alpha","true"),Q.setAttribute("dialog-offset","8 8"),Q.setAttribute("value",this.#y()),Q.anchorElement=this;let $=document.createElement("span");return $.hidden=!0,Q.appendChild($),Q.addEventListener("input",this.#p),Q.addEventListener("change",this.#e),Q.addEventListener("close",this.#j0),this.appendChild(Q),this.#q=Q,Q}#v(){if(this.hasAttribute("disabled"))return;let Q=this.#g();if(!Q){this.#n();return}this.setAttribute("selected",""),this.#b(),Q.open()}#h(){if(!this.#q)return;this.#q.removeEventListener("input",this.#p),this.#q.removeEventListener("change",this.#e),this.#q.removeEventListener("close",this.#j0),this.#q.close(),this.#q.remove(),this.#q=null,this.removeAttribute("selected")}#x(){if(this.#_)return this.#_;let Q=document.createElement("input");return Q.type="color",Q.tabIndex=-1,Q.setAttribute("aria-hidden","true"),Q.style.position="fixed",Q.style.inlineSize="1px",Q.style.blockSize="1px",Q.style.opacity="0",Q.style.pointerEvents="none",Q.addEventListener("input",this.#J0),Q.addEventListener("change",this.#Z0),this.appendChild(Q),this.#_=Q,Q}#n(){let Q=this.#x(),{color:$}=this.#V();Q.value=$,this.setAttribute("selected",""),Q.click()}#m(){if(!this.#_)return;this.#_.removeEventListener("input",this.#J0),this.#_.removeEventListener("change",this.#Z0),this.#_.remove(),this.#_=null}#c(){if(this.getAttribute("type")!=="color")return;this.#q?.close()}#d(){let Q=this.#K;if(!Q)return;if(this.#Z)return;let $=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")$.setAttribute("control",Q);else $.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),$.setAttribute("alpha","true");$.addEventListener("input",this.#l),$.addEventListener("change",this.#u),$.addEventListener("add",this.#t),$.addEventListener("remove",this.#t),this.appendChild($),this.#Z=$,this.#Q0()}#a(){if(!this.#Z)return;this.#Z.removeEventListener("input",this.#l),this.#Z.removeEventListener("change",this.#u),this.#Z.removeEventListener("add",this.#t),this.#Z.removeEventListener("remove",this.#t),this.#Z.remove(),this.#Z=null}#Q0(){if(!this.#Z||this.#K!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#Z.toggleAttribute("selected",Q)}#i(Q,$){if($===void 0||$>=100)return Q;let{r:J,g:Z,b:j}=u(Q);return`rgba(${J}, ${Z}, ${j}, ${$/100})`}#s(Q){if(!Q?.color)return null;let $=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:$}}#p=(Q)=>{Q.stopPropagation();let $=this.#s(Q.detail);if(!$)return;this.setAttribute("color",this.#i($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#e=(Q)=>{Q.stopPropagation();let $=this.#s(Q.detail);if(!$)return;this.setAttribute("color",this.#i($.color,$.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#$0(Q){let{opacity:$}=this.#V();return $<100?{color:Q,opacity:$}:{color:Q}}#J0=(Q)=>{Q.stopPropagation();let $=this.#$0(Q.target.value);this.setAttribute("color",this.#i($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#Z0=(Q)=>{Q.stopPropagation();let $=this.#$0(Q.target.value);this.setAttribute("color",this.#i($.color,$.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#j0=()=>{this.removeAttribute("selected")};#l=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#i(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#u=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#i(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#t=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#o(Q){let $=Q||this.#G()?.getBoundingClientRect();if(!$)return{x:0,y:0,px:0,py:0};let J=this.getBoundingClientRect(),Z=this.offsetWidth/2,j=this.offsetHeight/2,q=J.left-$.left,_=J.top-$.top,X=q+Z,Y=_+j,K=$.width>0?X/$.width:0,N=$.height>0?Y/$.height:0;return{x:q,y:_,px:K,py:N}}}customElements.define("fig-handle",K1);class W1 extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#$()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="disabled")this.#$()}#$(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}customElements.define("fig-menu-item",W1);class N1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","separator")}}customElements.define("fig-menu-separator",N1);class G1 extends HTMLElement{#$=null;#Q=null;#j=null;#J;#Z;#q;#_;#X=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open"]}constructor(){super();this.#J=this.#D.bind(this),this.#Z=this.#O.bind(this),this.#q=this.#H.bind(this),this.#_=this.#R.bind(this)}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(this.#K(),this.#Y(),this.#W(),this.#N(),this.#U(),this.#A(),this.open)this.#z()}disconnectedCallback(){if(this.#L(),document.removeEventListener("keydown",this.#q,!0),this.#j)this.#j.disconnect(),this.#j=null;if(this.#$)this.#$.removeEventListener("close",this.#_),this.#$.remove(),this.#$=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){if(J===null||J==="false")this.#C();else this.#z();return}if(Q==="disabled"){if(this.#Q)if(J!==null&&J!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");return}if(this.#$&&(Q==="position"||Q==="offset"||Q==="closedby"))if(J!==null)this.#$.setAttribute(Q,J);else this.#$.removeAttribute(Q)}#K(){this.#Q=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#Y(){this.#$=document.createElement("dialog",{is:"fig-popup"}),this.#$.setAttribute("is","fig-popup"),this.#$.setAttribute("theme","menu"),this.#$.setAttribute("role","menu"),this.#$.setAttribute("id",this.#$.getAttribute("id")||y());let Q=this.getAttribute("position")||"bottom left";this.#$.setAttribute("position",Q);let $=this.getAttribute("offset");if($)this.#$.setAttribute("offset",$);let J=this.getAttribute("closedby");if(J)this.#$.setAttribute("closedby",J);if(this.#Q)this.#$.anchor=this.#Q;this.#$.addEventListener("close",this.#_),this.appendChild(this.#$)}#W(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let $ of Q)this.#$.appendChild($)}#N(){if(this.addEventListener("keydown",this.#q),this.#Q)this.#Q.addEventListener("click",this.#J),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#$.getAttribute("id"));if(this.#$)this.#$.addEventListener("click",this.#Z),this.#$.addEventListener("keydown",this.#q)}#L(){if(this.removeEventListener("keydown",this.#q),this.#Q)this.#Q.removeEventListener("click",this.#J);if(this.#$)this.#$.removeEventListener("click",this.#Z),this.#$.removeEventListener("keydown",this.#q)}#U(){this.#j=new MutationObserver((Q)=>{for(let $ of Q)for(let J of $.addedNodes){if(J.nodeType!==1||J===this.#$)continue;if((J.tagName==="FIG-MENU-ITEM"||J.tagName==="FIG-MENU-SEPARATOR")&&J.parentElement===this)this.#$.appendChild(J);else if(!this.#Q&&J.parentElement===this){if(this.#K(),this.#Q)this.#Q.addEventListener("click",this.#J),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#$.getAttribute("id")),this.#$.anchor=this.#Q,this.#A()}}}),this.#j.observe(this,{childList:!0})}#B(){if(!this.#$)return[];return Array.from(this.#$.querySelectorAll("fig-menu-item")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#M(){let Q=this.#B();if(!Q.length){this.#X=-1;return}let $=document.activeElement,J=Q.findIndex((Z)=>Z===$||Z.contains($));this.#X=J>=0?J:-1}#G(Q){let $=this.#B();if(!$.length)return;let J=(Q+$.length)%$.length;this.#X=J,$[J].focus()}#A(){if(!this.#Q)return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.#Q.setAttribute("disabled",""),this.#Q.setAttribute("aria-disabled","true"),this.#Q.setAttribute("aria-expanded","false");else this.#Q.removeAttribute("disabled"),this.#Q.removeAttribute("aria-disabled")}#D(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.stopPropagation();let $=this.#$?.matches?.(":open")??!1;if(this.open&&!$)this.removeAttribute("open");if(this.open&&$)this.open=!1;else this.open=!0}#O(Q){let $=Q.target.closest("fig-menu-item");if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.#F($)}#H(Q){if(Q.currentTarget===document&&Q.key!=="Escape")return;if(Q.currentTarget===this&&this.#$?.contains(Q.target))return;if(!this.open||!this.#$?.matches?.(":open")){if(this.#Q?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" "))Q.preventDefault(),this.open=!0,requestAnimationFrame(()=>this.#G(0));return}let $=this.#B();if(!$.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#M(),this.#G(this.#X+1);break}case"ArrowUp":{Q.preventDefault(),this.#M(),this.#G(this.#X-1);break}case"Home":{Q.preventDefault(),this.#G(0);break}case"End":{Q.preventDefault(),this.#G($.length-1);break}case"Escape":{Q.preventDefault(),this.open=!1,this.#Q?.focus();break}case"Enter":case" ":{this.#M();let J=$[this.#X];if(!J)return;Q.preventDefault(),this.#F(J);break}}}#R(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#Q)this.#Q.setAttribute("aria-expanded","false"),this.#Q.focus();this.#X=-1}#F(Q){let $=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("change",{detail:{value:$,item:Q},bubbles:!0})),this.open=!1}#z(){if(!this.#$)return;if(this.#$.open=!0,document.addEventListener("keydown",this.#q,!0),this.#Q)this.#Q.setAttribute("aria-expanded","true");this.#X=-1,requestAnimationFrame(()=>{if(!this.#Q?.matches?.(":focus-visible"))return;this.#G(0)})}#C(){if(!this.#$)return;document.removeEventListener("keydown",this.#q,!0),this.#$.open=!1,this.#Q?.setAttribute("aria-expanded","false")}}customElements.define("fig-menu",G1);
280
+ </fig-fill-picker>`:`<fig-chit background="${J}"${_}></fig-chit>`,this.#$=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-chit"),this.#_(),this.#$?.addEventListener("input",this.#J),this.#$?.addEventListener("change",this.#Z),!this.#$)this.#Q?.addEventListener("input",this.#J),this.#Q?.addEventListener("change",this.#Z);this.#X(),this.#B()}#N=()=>{let Q=this.#q;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#W(Q){if(!Q)return"#D9D9D9";let $=Q.replace("#","").trim();if($.length===3||$.length===4){let[J,Z,j]=$;return`#${J}${J}${Z}${Z}${j}${j}`.toUpperCase()}if($.length===6||$.length===8)return`#${$.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#L(Q){if(!Q)return 1;let $=String(Q).trim(),J=$.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test(J)){let j=J[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test(J))return parseInt(J.slice(6,8),16)/255;let Z=$.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(Z)return parseFloat(Z[1]);return 1}#G(Q){if(!Q)return"#D9D9D9";let $=String(Q).trim();if($.startsWith("{"))try{let J=JSON.parse($);if(J?.color)return this.#G(J.color)}catch{}if($.startsWith("#"))return this.#W($);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test($))return this.#W($);try{let{ctx:J}=j0(1,1);J.fillStyle="#000000",J.fillStyle=$;let Z=J.fillStyle;if(Z.startsWith("#"))return this.#W(Z);let j=Z.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"}#U(){let Q=this.getAttribute("value"),$=this.#G(Q),J=this.#L(Q);if(Q!==$&&J>=1){this.setAttribute("value",$);return}if(this.#$){this.#B();let Z=J<1?{type:"solid",color:$,opacity:Math.round(J*100)}:{type:"solid",color:$};if(this.#$.setAttribute("value",JSON.stringify(Z)),this.#K)this.#$.removeAttribute("alpha");else this.#$.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}if(this.#Q){if(this.#B(),this.#Q.setAttribute("background",$),J<1)this.#Q.setAttribute("alpha",String(J));else this.#Q.removeAttribute("alpha");if(this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}}#B(){let Q=this.#q,$=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",$?"true":"false"),this.setAttribute("aria-pressed",J?"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),$)X?.setAttribute("disabled","");else X?.removeAttribute("disabled");return}let Z=this.#$||this.#Q;if(!Z)return;let j=this.getAttribute("aria-label")||"Color stop",q=this.getAttribute("aria-labelledby"),_=this.getAttribute("aria-describedby");if(q)Z.setAttribute("aria-labelledby",q),Z.removeAttribute("aria-label");else Z.setAttribute("aria-label",j),Z.removeAttribute("aria-labelledby");if(_)Z.setAttribute("aria-describedby",_);else Z.removeAttribute("aria-describedby")}#M(Q,$){let J=this.#G(Q?.color),Z=this.#G(this.getAttribute("value"));if(J!==Z)this.setAttribute("value",J);else this.#U();let j={color:this.value};if(this.#K){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent($,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#R(Q){Q.stopPropagation(),this.#M(Q.detail||{color:Q.target?.value},"input")}#z(Q){Q.stopPropagation(),this.#M(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,$,J){if($===J)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.#U(),this.#B();break}}get value(){return this.#G(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#G(Q))}get selected(){return this.hasAttribute("selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return this.hasAttribute("disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}customElements.define("fig-color-tip",X1);class Y1 extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false"),this.hasAttribute("disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false");if(Q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}customElements.define("fig-choice",Y1);class K1 extends HTMLElement{#$=null;#Q=this.#F.bind(this);#j=this.#D.bind(this);#J=this.#O.bind(this);#Z=null;#q=null;#_=null;#X=null;#K=null;#Y=null;#N=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#W(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#L(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#G(){return this.getAttribute("choice-element")||"fig-choice"}#U(){let Q=this.getAttribute("columns"),$=Q===null?NaN:Number(Q);if(Number.isInteger($)&&$>0)this.style.setProperty("--fig-chooser-grid-columns",String($));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from((this.#_||this).querySelectorAll(this.#G))}get#B(){return this.#_||this}get scrollTop(){return this.#B.scrollTop}set scrollTop(Q){this.#B.scrollTop=Q}get scrollLeft(){return this.#B.scrollLeft}set scrollLeft(Q){this.#B.scrollLeft=Q}get scrollWidth(){return this.#B.scrollWidth}get scrollHeight(){return this.#B.scrollHeight}scrollTo(...Q){this.#B.scrollTo(...Q)}scrollBy(...Q){this.#B.scrollBy(...Q)}get selectedChoice(){return this.#$}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let $=this.choices;for(let Z of $){let j=Z===Q,q=Z.hasAttribute("selected");if(j&&!q)Z.setAttribute("selected","");else if(!j&&q)Z.removeAttribute("selected")}this.#$=Q;let J=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==J){if(J)this.setAttribute("value",J)}this.#b(Q)}get value(){return this.#$?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){this.setAttribute("role","listbox"),this.#U(),this.#P(),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#j),this.#B.addEventListener("scroll",this.#J),this.#E(),this.#S(),this.#V(),this.#k(),v(this,()=>{this.#R(),this.#O(),this.#M()})}#M(){let Q=()=>{if(!this.isConnected)return;if(this.#$)this.#b(this.#$,"auto")},$=()=>{let J=this.querySelectorAll("img, video");for(let Z of J){if(Z.tagName==="IMG"?Z.complete:Z.readyState>=1)continue;let j=()=>{Z.removeEventListener("load",j),Z.removeEventListener("loadedmetadata",j),Z.removeEventListener("error",j),Q()};Z.addEventListener("load",j),Z.addEventListener("loadedmetadata",j),Z.addEventListener("error",j)}};requestAnimationFrame(()=>{$(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#j),this.#B.removeEventListener("scroll",this.#J),this.#f(),this.#Z?.disconnect(),this.#Z=null,this.#q?.disconnect(),this.#q=null,this.#T()}attributeChangedCallback(Q,$,J){if(Q==="value"&&J!==$&&J)this.#z(J);if(Q==="disabled"){let Z=J!==null&&J!=="false",j=this.choices;for(let q of j)if(Z)q.setAttribute("aria-disabled","true"),q.setAttribute("tabindex","-1");else q.removeAttribute("aria-disabled"),q.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#R());if(Q==="columns")this.#U();if(Q==="drag")if(this.#L)this.#S();else this.#f();if(Q==="overflow")this.#E();if(Q==="layout")this.#E(),requestAnimationFrame(()=>this.#O())}#R(){let Q=this.choices;if(!Q.length){this.#$=null;return}let $=this.getAttribute("value");if($&&this.#z($))return;let J=Q.find((Z)=>Z.hasAttribute("selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=Q[0]}#z(Q){let $=this.choices;for(let J of $)if(J.getAttribute("value")===Q)return this.selectedChoice=J,!0;return!1}#A(Q){let $=this.#G,J=Q;while(J&&J!==this){if(J.matches($))return J;J=J.parentElement}return null}#F(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.#A(Q.target);if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.selectedChoice=$,this.#H()}#D(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let $=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!$.length)return;let J=$.indexOf(this.#$),Z=J,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),J<$.length-1)Z=J+1;else if(j)Z=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),J>0)Z=J-1;else if(j)Z=$.length-1;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#G)){let q=this.#A(document.activeElement);if(q&&q!==this.#$)this.selectedChoice=q,this.#H()}return;default:return}if(Z!==J&&$[Z])this.selectedChoice=$[Z],$[Z].focus(),this.#H()}#H(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#O(){if(this.#W==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal";R0(this,this.#B,Q?"x":"y")}#k(){if(this.#q?.disconnect(),this.#q=new ResizeObserver(()=>{this.#O()}),this.#q.observe(this),this.#_)this.#q.observe(this.#_)}#S(){if(this.#Y?.bound)return;if(!this.#L)return;let Q=this.#B,$=(_)=>{if(_.button!==0)return;if(!(this.getAttribute("layout")==="horizontal"?Q.scrollWidth>Q.clientWidth:Q.scrollHeight>Q.clientHeight))return;this.#Y.active=!0,this.#Y.didDrag=!1,this.#Y.startX=_.clientX,this.#Y.startY=_.clientY,this.#Y.scrollLeft=Q.scrollLeft,this.#Y.scrollTop=Q.scrollTop,Q.style.cursor="grab",Q.style.userSelect="none"},J=(_)=>{if(!this.#Y.active)return;let X=this.getAttribute("layout")==="horizontal",Y=_.clientX-this.#Y.startX,K=_.clientY-this.#Y.startY;if(!this.#Y.didDrag&&Math.abs(X?Y:K)>3)this.#Y.didDrag=!0,Q.style.cursor="grabbing",Q.setPointerCapture(_.pointerId);if(!this.#Y.didDrag)return;if(X)Q.scrollLeft=this.#Y.scrollLeft-Y;else Q.scrollTop=this.#Y.scrollTop-K},Z=(_)=>{if(!this.#Y.active)return;let X=this.#Y.didDrag;if(this.#Y.active=!1,this.#Y.didDrag=!1,Q.style.cursor="",Q.style.userSelect="",_.pointerId!==void 0)try{Q.releasePointerCapture(_.pointerId)}catch{}if(X)_.preventDefault(),_.stopPropagation()},j=(_)=>{if(this.#Y?.suppressClick)_.stopPropagation(),_.preventDefault(),this.#Y.suppressClick=!1},q=(_)=>{if(this.#Y?.didDrag)this.#Y.suppressClick=!0,setTimeout(()=>{if(this.#Y)this.#Y.suppressClick=!1},0)};this.#Y={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:$,onPointerMove:J,onPointerUp:Z,onClick:j,onPointerUpCapture:q,scrollEl:Q},Q.addEventListener("pointerdown",$),window.addEventListener("pointermove",J),window.addEventListener("pointerup",Z),this.addEventListener("pointerup",q,!0),this.addEventListener("click",j,!0)}#f(){if(!this.#Y?.bound)return;this.#Y.scrollEl.removeEventListener("pointerdown",this.#Y.onPointerDown),window.removeEventListener("pointermove",this.#Y.onPointerMove),window.removeEventListener("pointerup",this.#Y.onPointerUp),this.removeEventListener("pointerup",this.#Y.onPointerUpCapture,!0),this.removeEventListener("click",this.#Y.onClick,!0),this.#Y.scrollEl.style.cursor="",this.#Y.scrollEl.style.userSelect="",this.#Y=null}#P(){if(this.#N)return;let Q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(Q&&Q===this.#_)return;this.#N=!0;try{let $=this.#_;if($&&$!==Q)$.removeEventListener("scroll",this.#J);let J=Q||document.createElement("div");J.className="fig-chooser-scroll",J.dataset.figChooserScroll="";let Z=Array.from(this.childNodes).filter((j)=>{if(j===J)return!1;if(j.nodeType!==Node.ELEMENT_NODE)return!0;return!j.hasAttribute("data-fig-chooser-nav")});for(let j of Z)J.appendChild(j);if(!Q)this.prepend(J);if(this.#_=J,this.#_.removeEventListener("scroll",this.#J),this.#_.addEventListener("scroll",this.#J),this.#q)this.#q.observe(this.#_)}finally{this.#N=!1}}#E(){if(this.#P(),this.#W==="scrollbar")this.#T();else this.#C()}#T(){this.#X?.remove(),this.#K?.remove(),this.#X=null,this.#K=null,this.classList.remove("overflow-start","overflow-end")}#C(){if(this.#X&&this.#K&&this.contains(this.#X)&&this.contains(this.#K))return;this.#X?.remove(),this.#K?.remove(),this.#X=null,this.#K=null;let Q=O0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#x(-1),onEnd:()=>this.#x(1)});this.#X=Q.start,this.#K=Q.end,this.prepend(this.#X),this.append(this.#K)}#x(Q){let $=this.getAttribute("layout")==="horizontal",J=this.#B;J0(J,$?"x":"y",Q)}#b(Q,$="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let J=this.#B,Z=J.scrollHeight>J.clientHeight,j=J.scrollWidth>J.clientWidth;if(!j&&!Z)return;let q=Q.getBoundingClientRect(),_=J.getBoundingClientRect(),X={behavior:$};if(Z){let Y=q.top-_.top+J.scrollTop+q.height/2;X.top=Y-J.clientHeight/2}if(j){let Y=q.left-_.left+J.scrollLeft+q.width/2;X.left=Y-J.clientWidth/2}J.scrollTo(X)})}#V(){this.#Z?.disconnect(),this.#Z=new MutationObserver(()=>{if(this.#N)return;this.#P(),this.#E();let Q=this.choices;if(this.#$&&!Q.includes(this.#$))this.#$=null,this.#R();else if(!this.#$&&Q.length)this.#R();requestAnimationFrame(()=>this.#O())}),this.#Z.observe(this,{childList:!0,subtree:!0})}}customElements.define("fig-chooser",K1);class W1 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"];#$=!1;#Q=!1;#j=null;#J=!1;#Z=null;#q=null;#_=null;#X=null;get#K(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#Y(){return!this.hasAttribute("data-no-color-picker")}get#N(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#W(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#L(){let Q=this.getAttribute("drag-snapping");if(Q===null)return"false";let $=Q.trim().toLowerCase();if($==="modifier")return"modifier";if($===""||$==="true")return"true";return"false"}#G(Q){let $=this.#L;if($==="true")return!0;if($==="modifier")return!!Q;return!1}#U(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}#B(Q,$){if(Math.abs(Q-$)<0.1){let Z=(Q+$)/2;return{x:Z,y:Z}}if(Math.abs(1-Q-$)<0.1)return{x:Q,y:1-Q};return{x:Q,y:$}}#M(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#M();if(!Q)return"0% 0%";let{px:$,py:J}=this.#l(Q.getBoundingClientRect());return`${Math.round($*100)}% ${Math.round(J*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#R(Q){let $=Q==null?"":String(Q).trim();if(!$)return{xPct:0,yPct:0};let J=$.split(/[\s,]+/).filter(Boolean),Z=(_)=>{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=Z(J[0]),q=Z(J[1]??J[0]);return{xToken:j,yToken:q}}#z(Q){let $=this.#M();if(!$)return;let{xToken:J,yToken:Z}=this.#R(Q),j=$.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.#W;if(this.#A(X),X.x){let Y=q(J,j.width);this.style.left=Y===null?_(J):`${Math.round(Y)}px`}if(X.y){let Y=q(Z,j.height);this.style.top=Y===null?_(Z):`${Math.round(Y)}px`}}#A(Q=this.#W){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#F(){this.#J=!0,this.setAttribute("value",this.value),this.#J=!1}get#D(){return this.getAttribute("hit-area-mode")||"handle"}#H(){let Q=this.getAttribute("hit-area");if(!Q)return null;let $=Q.trim().split(/\s+/),J=0,Z=0,j=!1,q=[];for(let _ of $){if(_==="circle"){j=!0;continue}let X=parseFloat(_);if(Number.isFinite(X))q.push(X)}if(q.length>=2)J=q[0],Z=q[1];else if(q.length===1)J=q[0],Z=q[0];else return null;return{vPad:J,hPad:Z,circle:j}}#O(){let Q=this.#H();if(!Q){if(this.#X)this.#X.remove(),this.#X=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#X){let $=document.createElement("div");$.classList.add("fig-handle-hit-area"),$.addEventListener("pointerdown",(J)=>this.#k(J)),this.prepend($),this.#X=$}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"}#k(Q){if(this.hasAttribute("disabled"))return;if(Q.target!==this.#X)return;if(this.#D==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#b(Q)}connectedCallback(){this.#C(),this.#T(),this.#O(),this.addEventListener("click",this.#S),document.addEventListener("pointerdown",this.#f),document.addEventListener("keydown",this.#P);let Q=this.getAttribute("value");if(Q)this.#z(Q);if(this.#K)this.#s()}disconnectedCallback(){if(this.#x(),this.#t(),this.#v(),this.#p(),this.#X)this.#X.remove(),this.#X=null;this.removeEventListener("click",this.#S),document.removeEventListener("pointerdown",this.#f),document.removeEventListener("keydown",this.#P)}select(){if(this.hasAttribute("disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#S=(Q)=>{if(this.#Q){this.#Q=!1;return}if(this.getAttribute("type")==="color"&&this.#Y&&!this.#K){this.#g();return}this.select()};#f=(Q)=>{if(this.contains(Q.target))return;if((this.#Z||this.#q)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#P=(Q)=>{if(Q.defaultPrevented)return;if(Q.target===this&&this.#N&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Q.key)){if(this.#E(Q)){if(Q.preventDefault(),!this.hasAttribute("selected"))this.select()}return}if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target===this&&!this.hasAttribute("selected")){if(Q.preventDefault(),this.getAttribute("type")==="color"&&this.#Y&&!this.#K)this.#g();else this.select();return}if(!this.hasAttribute("selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#Y)return;if(Q.preventDefault(),!this.#K)this.#g()};#E(Q){if(this.hasAttribute("disabled"))return!1;let $=this.#M();if(!$)return!1;let J=$.getBoundingClientRect();if(J.width<=0||J.height<=0)return!1;let Z=this.#W,j=this.#l(J),q=Q.shiftKey?0.1:0.01,_=j.px,X=j.py;switch(Q.key){case"ArrowLeft":if(!Z.x)return!1;_-=q;break;case"ArrowRight":if(!Z.x)return!1;_+=q;break;case"ArrowUp":if(!Z.y)return!1;X-=q;break;case"ArrowDown":if(!Z.y)return!1;X+=q;break;case"Home":if(Z.x)_=0;if(Z.y)X=0;break;case"End":if(Z.x)_=1;if(Z.y)X=1;break;default:return!1}if(_=Math.max(0,Math.min(1,_)),X=Math.max(0,Math.min(1,X)),this.#A(Z),Z.x)this.style.left=`${Math.round(_*J.width)}px`;if(Z.y)this.style.top=`${Math.round(X*J.height)}px`;this.#F();let Y={...this.#l(J),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,$,J){if(Q==="color"){if(!J||J==="false"||J==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",J);if(this.#Z&&this.#K==="color"&&J)this.#Z.setAttribute("value",J);this.#w()}if(Q==="drag")this.#T();if(Q==="hit-area")this.#O();if(Q==="selected")this.#Q0();if(Q==="selected"||Q==="disabled"||Q==="type"||Q==="tip"||Q==="aria-label"||Q==="aria-labelledby")this.#C();if(Q==="value"&&!this.#J&&!this.#$)this.#z(J);if(Q==="tip"){if(this.#t(),this.#K)this.#v(),this.#s()}}#T(){if(this.#N&&!this.#j)this.#j=(Q)=>this.#b(Q),this.addEventListener("pointerdown",this.#j);else if(!this.#N&&this.#j)this.#x()}#C(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=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",$?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let J=this.#K||this.getAttribute("type")||"handle";this.setAttribute("aria-label",J==="color"?"Color handle":J==="add"?"Add handle":J==="remove"?"Remove handle":"Handle")}}#x(){if(this.#j)this.removeEventListener("pointerdown",this.#j),this.#j=null;this.#$=!1}#b(Q){if(!this.#N||this.hasAttribute("disabled"))return;Q.preventDefault();let $=this.#M();if(!$)return;this.#$=!0;let J=this.#W,Z=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,N=Q.clientY,L=3,O=(U,z,A=!1)=>{let G=$.getBoundingClientRect();Z=G;let M=this.#l(G),D=U-X-G.left,T=z-Y-G.top,P=Math.max(0,Math.min(G.width,D)),k=Math.max(0,Math.min(G.height,T)),f=G.width>0?J.x?P/G.width:M.px:0.5,w=G.height>0?J.y?k/G.height:M.py:0.5;if(this.#G(A)){if(J.x)f=this.#U(f);if(J.y)w=this.#U(w);if(J.x&&J.y){let d=this.#B(f,w);f=d.x,w=d.y}}if(this.#A(J),J.x)this.style.left=`${Math.round(Math.max(0,Math.min(G.width,f*G.width)))}px`;if(J.y)this.style.top=`${Math.round(Math.max(0,Math.min(G.height,w*G.height)))}px`},H=(U)=>{if(!this.#$)return;if(!this.#Q){let z=U.clientX-K,A=U.clientY-N;if(z*z+A*A<L*L)return;if(this.#d(),this.classList.add("dragging"),this.style.cursor="grabbing",!this.hasAttribute("selected"))this.select()}this.#Q=!0,O(U.clientX,U.clientY,U.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#l(Z),shiftKey:U.shiftKey}}))},B=(U)=>{if(this.#$=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",B),this.#Q){O(U.clientX,U.clientY,U.shiftKey),this.#F(),this.#z(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#l(Z)}));let z=(A)=>{A.stopPropagation(),A.preventDefault()};this.addEventListener("click",z,{capture:!0,once:!0})}else this.#F();this.#Q=!1};window.addEventListener("pointermove",H),window.addEventListener("pointerup",B)}showColorTip(){if(!this.#K)return;if(this.#Z){this.#Z.style.display="";return}this.#s()}hideColorTip(){if(!this.#Z)return;this.#Z.style.display="none"}#V(Q=this.getAttribute("color")){let $={color:"#D9D9D9",opacity:100},J=String(Q||"").trim();if(!J)return $;let Z=(q)=>{let _=q.replace("#","").trim();if(_.length===3||_.length===4){let[X,Y,K,N]=_;return{color:`#${X}${X}${Y}${Y}${K}${K}`.toUpperCase(),opacity:N?Math.round(parseInt(`${N}${N}`,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 $},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(J.startsWith("#"))return Z(J);try{let{ctx:q}=j0(1,1);q.fillStyle="#000000",q.fillStyle=J;let _=q.fillStyle;if(_.startsWith("#"))return Z(_);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 $}#y(){let{color:Q,opacity:$}=this.#V();return JSON.stringify($<100?{type:"solid",color:Q,opacity:$}:{type:"solid",color:Q})}#w(){if(!this.#q)return;this.#q.setAttribute("value",this.#y())}#h(){if(!p())return null;if(this.#q)return this.#q;let Q=document.createElement("fig-fill-picker");Q.setAttribute("mode","solid"),Q.setAttribute("alpha","true"),Q.setAttribute("dialog-offset","8 8"),Q.setAttribute("value",this.#y()),Q.anchorElement=this;let $=document.createElement("span");return $.hidden=!0,Q.appendChild($),Q.addEventListener("input",this.#c),Q.addEventListener("change",this.#e),Q.addEventListener("close",this.#j0),this.appendChild(Q),this.#q=Q,Q}#g(){if(this.hasAttribute("disabled"))return;let Q=this.#h();if(!Q){this.#m();return}this.setAttribute("selected",""),this.#w(),Q.open()}#v(){if(!this.#q)return;this.#q.removeEventListener("input",this.#c),this.#q.removeEventListener("change",this.#e),this.#q.removeEventListener("close",this.#j0),this.#q.close(),this.#q.remove(),this.#q=null,this.removeAttribute("selected")}#I(){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.#Z0),this.appendChild(Q),this.#_=Q,Q}#m(){let Q=this.#I(),{color:$}=this.#V();Q.value=$,this.setAttribute("selected",""),Q.click()}#p(){if(!this.#_)return;this.#_.removeEventListener("input",this.#J0),this.#_.removeEventListener("change",this.#Z0),this.#_.remove(),this.#_=null}#d(){if(this.getAttribute("type")!=="color")return;this.#q?.close()}#s(){let Q=this.#K;if(!Q)return;if(this.#Z)return;let $=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")$.setAttribute("control",Q);else $.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),$.setAttribute("alpha","true");$.addEventListener("input",this.#a),$.addEventListener("change",this.#u),$.addEventListener("add",this.#n),$.addEventListener("remove",this.#n),this.appendChild($),this.#Z=$,this.#Q0()}#t(){if(!this.#Z)return;this.#Z.removeEventListener("input",this.#a),this.#Z.removeEventListener("change",this.#u),this.#Z.removeEventListener("add",this.#n),this.#Z.removeEventListener("remove",this.#n),this.#Z.remove(),this.#Z=null}#Q0(){if(!this.#Z||this.#K!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#Z.toggleAttribute("selected",Q)}#o(Q,$){if($===void 0||$>=100)return Q;let{r:J,g:Z,b:j}=u(Q);return`rgba(${J}, ${Z}, ${j}, ${$/100})`}#r(Q){if(!Q?.color)return null;let $=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:$}}#c=(Q)=>{Q.stopPropagation();let $=this.#r(Q.detail);if(!$)return;this.setAttribute("color",this.#o($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#e=(Q)=>{Q.stopPropagation();let $=this.#r(Q.detail);if(!$)return;this.setAttribute("color",this.#o($.color,$.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#$0(Q){let{opacity:$}=this.#V();return $<100?{color:Q,opacity:$}:{color:Q}}#J0=(Q)=>{Q.stopPropagation();let $=this.#$0(Q.target.value);this.setAttribute("color",this.#o($.color,$.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:$}))};#Z0=(Q)=>{Q.stopPropagation();let $=this.#$0(Q.target.value);this.setAttribute("color",this.#o($.color,$.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:$}))};#j0=()=>{this.removeAttribute("selected")};#a=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#o(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#u=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#o(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#n=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#l(Q){let $=Q||this.#M()?.getBoundingClientRect();if(!$)return{x:0,y:0,px:0,py:0};let J=this.getBoundingClientRect(),Z=this.offsetWidth/2,j=this.offsetHeight/2,q=J.left-$.left,_=J.top-$.top,X=q+Z,Y=_+j,K=$.width>0?X/$.width:0,N=$.height>0?Y/$.height:0;return{x:q,y:_,px:K,py:N}}}customElements.define("fig-handle",W1);class N1 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.#$()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="disabled")this.#$()}#$(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}customElements.define("fig-menu-item",N1);class G1 extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","separator")}}customElements.define("fig-menu-separator",G1);class U1 extends HTMLElement{#$=null;#Q=null;#j=null;#J;#Z;#q;#_;#X=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open"]}constructor(){super();this.#J=this.#z.bind(this),this.#Z=this.#A.bind(this),this.#q=this.#F.bind(this),this.#_=this.#D.bind(this)}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(this.#K(),this.#Y(),this.#N(),this.#W(),this.#G(),this.#R(),this.open)this.#O()}disconnectedCallback(){if(this.#L(),document.removeEventListener("keydown",this.#q,!0),this.#j)this.#j.disconnect(),this.#j=null;if(this.#$)this.#$.removeEventListener("close",this.#_),this.#$.remove(),this.#$=null}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){if(J===null||J==="false")this.#k();else this.#O();return}if(Q==="disabled"){if(this.#Q)if(J!==null&&J!=="false")this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");return}if(this.#$&&(Q==="position"||Q==="offset"||Q==="closedby"))if(J!==null)this.#$.setAttribute(Q,J);else this.#$.removeAttribute(Q)}#K(){this.#Q=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#Y(){this.#$=document.createElement("dialog",{is:"fig-popup"}),this.#$.setAttribute("is","fig-popup"),this.#$.setAttribute("theme","menu"),this.#$.setAttribute("role","menu"),this.#$.setAttribute("id",this.#$.getAttribute("id")||y());let Q=this.getAttribute("position")||"bottom left";this.#$.setAttribute("position",Q);let $=this.getAttribute("offset");if($)this.#$.setAttribute("offset",$);let J=this.getAttribute("closedby");if(J)this.#$.setAttribute("closedby",J);if(this.#Q)this.#$.anchor=this.#Q;this.#$.addEventListener("close",this.#_),this.appendChild(this.#$)}#N(){let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let $ of Q)this.#$.appendChild($)}#W(){if(this.addEventListener("keydown",this.#q),this.#Q)this.#Q.addEventListener("click",this.#J),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#$.getAttribute("id"));if(this.#$)this.#$.addEventListener("click",this.#Z),this.#$.addEventListener("keydown",this.#q)}#L(){if(this.removeEventListener("keydown",this.#q),this.#Q)this.#Q.removeEventListener("click",this.#J);if(this.#$)this.#$.removeEventListener("click",this.#Z),this.#$.removeEventListener("keydown",this.#q)}#G(){this.#j=new MutationObserver((Q)=>{for(let $ of Q)for(let J of $.addedNodes){if(J.nodeType!==1||J===this.#$)continue;if((J.tagName==="FIG-MENU-ITEM"||J.tagName==="FIG-MENU-SEPARATOR")&&J.parentElement===this)this.#$.appendChild(J);else if(!this.#Q&&J.parentElement===this){if(this.#K(),this.#Q)this.#Q.addEventListener("click",this.#J),this.#Q.setAttribute("aria-haspopup","menu"),this.#Q.setAttribute("aria-expanded","false"),this.#Q.setAttribute("aria-controls",this.#$.getAttribute("id")),this.#$.anchor=this.#Q,this.#R()}}}),this.#j.observe(this,{childList:!0})}#U(){if(!this.#$)return[];return Array.from(this.#$.querySelectorAll("fig-menu-item")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#B(){let Q=this.#U();if(!Q.length){this.#X=-1;return}let $=document.activeElement,J=Q.findIndex((Z)=>Z===$||Z.contains($));this.#X=J>=0?J:-1}#M(Q){let $=this.#U();if(!$.length)return;let J=(Q+$.length)%$.length;this.#X=J,$[J].focus()}#R(){if(!this.#Q)return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.#Q.setAttribute("disabled",""),this.#Q.setAttribute("aria-disabled","true"),this.#Q.setAttribute("aria-expanded","false");else this.#Q.removeAttribute("disabled"),this.#Q.removeAttribute("aria-disabled")}#z(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;Q.stopPropagation();let $=this.#$?.matches?.(":open")??!1;if(this.open&&!$)this.removeAttribute("open");if(this.open&&$)this.open=!1;else this.open=!0}#A(Q){let $=Q.target.closest("fig-menu-item");if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.#H($)}#F(Q){if(Q.currentTarget===document&&Q.key!=="Escape")return;if(Q.currentTarget===this&&this.#$?.contains(Q.target))return;if(!this.open||!this.#$?.matches?.(":open")){if(this.#Q?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" "))Q.preventDefault(),this.open=!0,requestAnimationFrame(()=>this.#M(0));return}let $=this.#U();if(!$.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#B(),this.#M(this.#X+1);break}case"ArrowUp":{Q.preventDefault(),this.#B(),this.#M(this.#X-1);break}case"Home":{Q.preventDefault(),this.#M(0);break}case"End":{Q.preventDefault(),this.#M($.length-1);break}case"Escape":{Q.preventDefault(),this.open=!1,this.#Q?.focus();break}case"Enter":case" ":{this.#B();let J=$[this.#X];if(!J)return;Q.preventDefault(),this.#H(J);break}}}#D(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#Q)this.#Q.setAttribute("aria-expanded","false"),this.#Q.focus();this.#X=-1}#H(Q){let $=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("change",{detail:{value:$,item:Q},bubbles:!0})),this.open=!1}#O(){if(!this.#$)return;if(this.#$.open=!0,document.addEventListener("keydown",this.#q,!0),this.#Q)this.#Q.setAttribute("aria-expanded","true");this.#X=-1,requestAnimationFrame(()=>{if(!this.#Q?.matches?.(":focus-visible"))return;this.#M(0)})}#k(){if(!this.#$)return;document.removeEventListener("keydown",this.#q,!0),this.#$.open=!1,this.#Q?.setAttribute("aria-expanded","false")}}customElements.define("fig-menu",U1);