@rogieking/figui3 6.23.0 → 6.23.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.
- package/README.md +0 -45
- package/dist/fig.js +7 -7
- package/fig.js +5 -36
- package/package.json +3 -29
- package/dist/propskit.css +0 -1
- package/dist/propskit.js +0 -1
- package/propskit-core.js +0 -556
- package/propskit.d.ts +0 -98
- package/propskit.js +0 -15
package/dist/fig.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(Q,Z,$){if(Q.importNode.length!=1||Z.get("ungap-li"))return;var J="extends";try{var j={};j[J]="li";var q=HTMLLIElement,_=function(){return Reflect.construct(q,[],_)};if(_.prototype=$.create(q.prototype),Z.define("ungap-li",_,j),!/is="ungap-li"/.test(new _().outerHTML))throw j}catch(X){(function(){var Y="attributeChangedCallback",K="connectedCallback",G="disconnectedCallback",N=Element.prototype,W=$.assign,O=$.create,B=$.defineProperties,L=$.getOwnPropertyDescriptor,T=$.setPrototypeOf,R=Z.define,A=Z.get,M=Z.upgrade,E=Z.whenDefined,k=O(null),S=new WeakMap,x={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(U){return typeof U=="string"&&/^HTML(?!Element)/.test(U)}).forEach(function(U){function D(){}var P=self[U];T(D,P),(D.prototype=P.prototype).constructor=D,P={},P[U]={value:D},B(self,P)}),new MutationObserver(t).observe(Q,x),D0(Document.prototype,"importNode"),D0(Node.prototype,"cloneNode"),B(Z,{define:{value:function(U,D,P){if(U=U.toLowerCase(),P&&J in P){k[U]=W({},P,{Class:D});var I=P[J]+'[is="'+U+'"]',f=Q.querySelectorAll(I);for(var V=0,h=f.length;V<h;V++)n(f[V])}else R.apply(Z,arguments)}},get:{value:function(U){return U in k?k[U].Class:A.call(Z,U)}},upgrade:{value:function(U){var D=G0(U);if(D&&!(U instanceof D.Class))R0(U,D);else M.call(Z,U)}},whenDefined:{value:function(U){return U in k?Promise.resolve():E.call(Z,U)}}});var y=Q.createElement;B(Q,{createElement:{value:function(U,D){var P=y.call(Q,U);if(D&&"is"in D)P.setAttribute("is",D.is),Z.upgrade(P);return P}}});var m=L(N,"attachShadow").value,d=L(N,"innerHTML");B(N,{attachShadow:{value:function(){var U=m.apply(this,arguments);return new MutationObserver(t).observe(U,x),U}},innerHTML:{get:d.get,set:function(U){if(d.set.call(this,U),/\bis=("|')?[a-z0-9_-]+\1/i.test(U))$0(this,n)}}});function t(U){for(var D=0,P=U.length;D<P;D++){var I=U[D],f=I.addedNodes,V=I.removedNodes;for(var h=0,J0=f.length;h<J0;h++)n(f[h]);for(var N0=0,x1=V.length;N0<x1;N0++)A0(V[N0])}}function H0(U){for(var D=0,P=U.length;D<P;D++){var I=U[D],f=I.attributeName,V=I.oldValue,h=I.target,J0=h.getAttribute(f);if(Y in h&&!(V==J0&&J0==null))h[Y](f,V,h.getAttribute(f),null)}}function A0(U){if(U.nodeType!==1)return;var D=G0(U);if(D&&U instanceof D.Class&&G in U&&S.get(U)!==G)S.set(U,G),Promise.resolve(U).then(V1);$0(U,A0)}function G0(U){var D=U.getAttribute("is");if(D){if(D=D.toLowerCase(),D in k)return k[D]}return null}function I1(U){U[K]()}function V1(U){U[G]()}function R0(U,D){var P=D.Class,I=P.observedAttributes||[];if(T(U,P.prototype),I.length){new MutationObserver(H0).observe(U,{attributes:!0,attributeFilter:I,attributeOldValue:!0});var f=[];for(var V=0,h=I.length;V<h;V++)f.push({attributeName:I[V],oldValue:null,target:U});H0(f)}}function n(U){if(U.nodeType!==1)return;var D=G0(U);if(D){if(!(U instanceof D.Class))R0(U,D);if(K in U&&U.isConnected&&S.get(U)!==K)S.set(U,K),Promise.resolve(U).then(I1)}$0(U,n)}function $0(U,D){for(var P=U.content,I=(P&&P.nodeType==11?P:U).querySelectorAll("[is]"),f=0,V=I.length;f<V;f++)D(I[f])}function D0(U,D){var P=U[D],I={};I[D]={value:function(){var f=P.apply(this,arguments);switch(f.nodeType){case 1:case 11:$0(f,n)}return f}},B(U,I)}})()}})(document,customElements,Object)});function v1(){if(typeof navigator>"u")return!1;let Q=navigator.userAgent||"",Z=/\b(iPad|iPhone|iPod)\b/.test(Q)||/\bMacintosh\b/.test(Q)&&/\bMobile\b/.test(Q),$=/\bAppleWebKit\b/.test(Q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(Q);return Z||$}function u(Q,Z={}){let $=document.createElement("fig-icon");if(Q)$.setAttribute("name",Q);if(Z.size)$.setAttribute("size",Z.size);if(Z.className)$.className=Z.className;return $}function c(Q,Z){requestAnimationFrame(()=>{if(Q&&!Q.isConnected)return;Z()})}function F(Q,Z){return Q.hasAttribute(Z)&&Q.getAttribute(Z)!=="false"}function q0(Q){Q.querySelectorAll(':scope > [slot="prepend"], :scope > [slot="append"]').forEach((Z)=>{if(Z.children.length>0){W0(Z);return}let $=Z.textContent.trim();if(!$){W0(Z);return}let J=Z.dataset.figInputSlotFullText||"",j=J?Array.from(J)[0]?.toUpperCase():"",q=$===j?J:$,X=Array.from($)[0].toUpperCase();if(Z.textContent!==X)Z.textContent=X;if(q&&q!==X)Z.dataset.figInputSlotFullText=q,Z.setAttribute("aria-label",q),g1(Z);else W0(Z)})}function g1(Q){if(Q.dataset.figInputSlotTooltipBound==="true")return;Q.dataset.figInputSlotTooltipBound="true",Q.addEventListener("pointerenter",P0),Q.addEventListener("pointerleave",U0),Q.addEventListener("focus",P0),Q.addEventListener("blur",U0)}function W0(Q){U0({currentTarget:Q}),delete Q.dataset.figInputSlotFullText,Q.removeAttribute("aria-label")}function P0(Q){let Z=Q.currentTarget,$=Z?.dataset?.figInputSlotFullText;if(!Z||!$)return;H.show(Z,$)}function U0(Q){let Z=Q.currentTarget;if(!Z)return;H.hide(Z)}function X0({owner:Q,onStart:Z,onEnd:$,startClass:J="",endClass:j="",chevronClass:q="",startLabel:_="Scroll back",endLabel:X="Scroll forward"}={}){let Y=(K,G)=>{let N=document.createElement("button");if(N.type="button",N.className=["fig-overflow",`fig-overflow-${K}`,K==="start"?J:j].filter(Boolean).join(" "),N.dataset.figOverflow=K,Q)N.setAttribute(`data-fig-${Q}-nav`,K);return N.setAttribute("tabindex","-1"),N.setAttribute("aria-label",K==="start"?_:X),N.appendChild(u("chevron",{size:"small",className:["fig-overflow-chevron",q].filter(Boolean).join(" ")})),N.addEventListener("click",(W)=>{W.preventDefault(),W.stopPropagation(),G?.(W)}),N};return{start:Y("start",Z),end:Y("end",$)}}function a(Q,Z,$="x",J=2){if(!Q||!Z)return!1;let j=$==="x",q=j?Z.scrollWidth:Z.scrollHeight,_=j?Z.clientWidth:Z.clientHeight,X=j?Z.scrollLeft:Z.scrollTop,Y=q-_>J,K=!Y||X<=J,G=!Y||X+_>=q-J;return Q.classList.toggle("overflow-start",!K),Q.classList.toggle("overflow-end",!G),Y}function i(Q,Z="x",$=1){if(!Q)return;let J=Z==="x",q=(J?Q.clientWidth:Q.clientHeight)*0.8*$;Q.scrollBy({[J?"left":"top"]:q,behavior:"smooth"})}function S0(Q,Z,$="y",J="auto"){if(!Q||!Z||!Q.contains(Z))return;requestAnimationFrame(()=>{if(!Q.isConnected||!Z.isConnected)return;let j=$==="x",q=j?Q.scrollWidth:Q.scrollHeight,_=j?Q.clientWidth:Q.clientHeight;if(q<=_+1){a(Q,Q,$);return}let X=Z.getBoundingClientRect(),Y=Q.getBoundingClientRect(),K=j?Q.scrollLeft:Q.scrollTop,G=(j?X.left-Y.left:X.top-Y.top)+K,N=j?X.width:X.height,W=q-_,O=Math.max(0,Math.min(G+N/2-_/2,W));Q.scrollTo({[j?"left":"top"]:O,behavior:J}),a(Q,Q,$)})}function o(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function h1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let Q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class Z extends HTMLButtonElement{}try{return customElements.define(Q,Z,{extends:"button"}),document.createElement("button",{is:Q})instanceof Z}catch($){return!1}}var f0=v1()&&!h1(),b1=(f0?Promise.resolve().then(() => (T0(),w1)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q});function M0(Q,Z,$){let J=()=>{if(!customElements.get(Q))customElements.define(Q,Z,$)};if(!f0){J();return}b1.then(J).catch((j)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${Q}".`,j)})}function z(Q,Z){if(!customElements.get(Q))customElements.define(Q,Z)}function g(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function j0(
|
|
1
|
+
var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(Q,Z,$){if(Q.importNode.length!=1||Z.get("ungap-li"))return;var J="extends";try{var j={};j[J]="li";var q=HTMLLIElement,_=function(){return Reflect.construct(q,[],_)};if(_.prototype=$.create(q.prototype),Z.define("ungap-li",_,j),!/is="ungap-li"/.test(new _().outerHTML))throw j}catch(X){(function(){var Y="attributeChangedCallback",K="connectedCallback",G="disconnectedCallback",N=Element.prototype,W=$.assign,O=$.create,B=$.defineProperties,L=$.getOwnPropertyDescriptor,T=$.setPrototypeOf,R=Z.define,A=Z.get,M=Z.upgrade,E=Z.whenDefined,k=O(null),S=new WeakMap,x={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(U){return typeof U=="string"&&/^HTML(?!Element)/.test(U)}).forEach(function(U){function D(){}var P=self[U];T(D,P),(D.prototype=P.prototype).constructor=D,P={},P[U]={value:D},B(self,P)}),new MutationObserver(t).observe(Q,x),D0(Document.prototype,"importNode"),D0(Node.prototype,"cloneNode"),B(Z,{define:{value:function(U,D,P){if(U=U.toLowerCase(),P&&J in P){k[U]=W({},P,{Class:D});var I=P[J]+'[is="'+U+'"]',f=Q.querySelectorAll(I);for(var V=0,h=f.length;V<h;V++)n(f[V])}else R.apply(Z,arguments)}},get:{value:function(U){return U in k?k[U].Class:A.call(Z,U)}},upgrade:{value:function(U){var D=G0(U);if(D&&!(U instanceof D.Class))R0(U,D);else M.call(Z,U)}},whenDefined:{value:function(U){return U in k?Promise.resolve():E.call(Z,U)}}});var y=Q.createElement;B(Q,{createElement:{value:function(U,D){var P=y.call(Q,U);if(D&&"is"in D)P.setAttribute("is",D.is),Z.upgrade(P);return P}}});var m=L(N,"attachShadow").value,d=L(N,"innerHTML");B(N,{attachShadow:{value:function(){var U=m.apply(this,arguments);return new MutationObserver(t).observe(U,x),U}},innerHTML:{get:d.get,set:function(U){if(d.set.call(this,U),/\bis=("|')?[a-z0-9_-]+\1/i.test(U))$0(this,n)}}});function t(U){for(var D=0,P=U.length;D<P;D++){var I=U[D],f=I.addedNodes,V=I.removedNodes;for(var h=0,J0=f.length;h<J0;h++)n(f[h]);for(var N0=0,x1=V.length;N0<x1;N0++)A0(V[N0])}}function H0(U){for(var D=0,P=U.length;D<P;D++){var I=U[D],f=I.attributeName,V=I.oldValue,h=I.target,J0=h.getAttribute(f);if(Y in h&&!(V==J0&&J0==null))h[Y](f,V,h.getAttribute(f),null)}}function A0(U){if(U.nodeType!==1)return;var D=G0(U);if(D&&U instanceof D.Class&&G in U&&S.get(U)!==G)S.set(U,G),Promise.resolve(U).then(V1);$0(U,A0)}function G0(U){var D=U.getAttribute("is");if(D){if(D=D.toLowerCase(),D in k)return k[D]}return null}function I1(U){U[K]()}function V1(U){U[G]()}function R0(U,D){var P=D.Class,I=P.observedAttributes||[];if(T(U,P.prototype),I.length){new MutationObserver(H0).observe(U,{attributes:!0,attributeFilter:I,attributeOldValue:!0});var f=[];for(var V=0,h=I.length;V<h;V++)f.push({attributeName:I[V],oldValue:null,target:U});H0(f)}}function n(U){if(U.nodeType!==1)return;var D=G0(U);if(D){if(!(U instanceof D.Class))R0(U,D);if(K in U&&U.isConnected&&S.get(U)!==K)S.set(U,K),Promise.resolve(U).then(I1)}$0(U,n)}function $0(U,D){for(var P=U.content,I=(P&&P.nodeType==11?P:U).querySelectorAll("[is]"),f=0,V=I.length;f<V;f++)D(I[f])}function D0(U,D){var P=U[D],I={};I[D]={value:function(){var f=P.apply(this,arguments);switch(f.nodeType){case 1:case 11:$0(f,n)}return f}},B(U,I)}})()}})(document,customElements,Object)});function v1(){if(typeof navigator>"u")return!1;let Q=navigator.userAgent||"",Z=/\b(iPad|iPhone|iPod)\b/.test(Q)||/\bMacintosh\b/.test(Q)&&/\bMobile\b/.test(Q),$=/\bAppleWebKit\b/.test(Q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(Q);return Z||$}function u(Q,Z={}){let $=document.createElement("fig-icon");if(Q)$.setAttribute("name",Q);if(Z.size)$.setAttribute("size",Z.size);if(Z.className)$.className=Z.className;return $}function c(Q,Z){requestAnimationFrame(()=>{if(Q&&!Q.isConnected)return;Z()})}function F(Q,Z){return Q.hasAttribute(Z)&&Q.getAttribute(Z)!=="false"}function q0(Q){Q.querySelectorAll(':scope > [slot="prepend"], :scope > [slot="append"]').forEach((Z)=>{if(Z.children.length>0){W0(Z);return}let $=Z.textContent.trim();if(!$){W0(Z);return}let J=Z.dataset.figInputSlotFullText||"",j=J?Array.from(J)[0]?.toUpperCase():"",q=$===j?J:$,X=Array.from($)[0].toUpperCase();if(Z.textContent!==X)Z.textContent=X;if(q&&q!==X)Z.dataset.figInputSlotFullText=q,Z.setAttribute("aria-label",q),g1(Z);else W0(Z)})}function g1(Q){if(Q.dataset.figInputSlotTooltipBound==="true")return;Q.dataset.figInputSlotTooltipBound="true",Q.addEventListener("pointerenter",P0),Q.addEventListener("pointerleave",U0),Q.addEventListener("focus",P0),Q.addEventListener("blur",U0)}function W0(Q){U0({currentTarget:Q}),delete Q.dataset.figInputSlotFullText,Q.removeAttribute("aria-label")}function P0(Q){let Z=Q.currentTarget,$=Z?.dataset?.figInputSlotFullText;if(!Z||!$)return;H.show(Z,$)}function U0(Q){let Z=Q.currentTarget;if(!Z)return;H.hide(Z)}function X0({owner:Q,onStart:Z,onEnd:$,startClass:J="",endClass:j="",chevronClass:q="",startLabel:_="Scroll back",endLabel:X="Scroll forward"}={}){let Y=(K,G)=>{let N=document.createElement("button");if(N.type="button",N.className=["fig-overflow",`fig-overflow-${K}`,K==="start"?J:j].filter(Boolean).join(" "),N.dataset.figOverflow=K,Q)N.setAttribute(`data-fig-${Q}-nav`,K);return N.setAttribute("tabindex","-1"),N.setAttribute("aria-label",K==="start"?_:X),N.appendChild(u("chevron",{size:"small",className:["fig-overflow-chevron",q].filter(Boolean).join(" ")})),N.addEventListener("click",(W)=>{W.preventDefault(),W.stopPropagation(),G?.(W)}),N};return{start:Y("start",Z),end:Y("end",$)}}function a(Q,Z,$="x",J=2){if(!Q||!Z)return!1;let j=$==="x",q=j?Z.scrollWidth:Z.scrollHeight,_=j?Z.clientWidth:Z.clientHeight,X=j?Z.scrollLeft:Z.scrollTop,Y=q-_>J,K=!Y||X<=J,G=!Y||X+_>=q-J;return Q.classList.toggle("overflow-start",!K),Q.classList.toggle("overflow-end",!G),Y}function i(Q,Z="x",$=1){if(!Q)return;let J=Z==="x",q=(J?Q.clientWidth:Q.clientHeight)*0.8*$;Q.scrollBy({[J?"left":"top"]:q,behavior:"smooth"})}function S0(Q,Z,$="y",J="auto"){if(!Q||!Z||!Q.contains(Z))return;requestAnimationFrame(()=>{if(!Q.isConnected||!Z.isConnected)return;let j=$==="x",q=j?Q.scrollWidth:Q.scrollHeight,_=j?Q.clientWidth:Q.clientHeight;if(q<=_+1){a(Q,Q,$);return}let X=Z.getBoundingClientRect(),Y=Q.getBoundingClientRect(),K=j?Q.scrollLeft:Q.scrollTop,G=(j?X.left-Y.left:X.top-Y.top)+K,N=j?X.width:X.height,W=q-_,O=Math.max(0,Math.min(G+N/2-_/2,W));Q.scrollTo({[j?"left":"top"]:O,behavior:J}),a(Q,Q,$)})}function o(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function h1(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let Q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class Z extends HTMLButtonElement{}try{return customElements.define(Q,Z,{extends:"button"}),document.createElement("button",{is:Q})instanceof Z}catch($){return!1}}var f0=v1()&&!h1(),b1=(f0?Promise.resolve().then(() => (T0(),w1)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q});function M0(Q,Z,$){let J=()=>{if(!customElements.get(Q))customElements.define(Q,Z,$)};if(!f0){J();return}b1.then(J).catch((j)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${Q}".`,j)})}function z(Q,Z){if(!customElements.get(Q))customElements.define(Q,Z)}function g(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function j0(){if(!document.body)return null;let Q="data-figui-overlay-root",Z=document.body.querySelector(`:scope > [${Q}]`);if(!Z)Z=document.createElement("div"),Z.setAttribute(Q,""),document.body.append(Z);return Z}var m1=1e4;function I0(){return m1++}function b(Q,Z,$){if($&&$.trim())Q.style.setProperty(Z,$.trim());else Q.style.removeProperty(Z)}function v(Q){return String(Q??"").replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var s=null,E0=null;function O0(Q=1,Z=1){if(!s)s=document.createElement("canvas"),E0=s.getContext("2d");if(s.width!==Q)s.width=Q;if(s.height!==Z)s.height=Z;return{canvas:s,ctx:E0}}class V0 extends HTMLElement{type;#Z;#Q=new WeakMap;#$=["aria-label","aria-labelledby","aria-describedby","title"];#J=this.#G.bind(this);#j=this.#W.bind(this);#q=()=>this.#z();#_=()=>{if(this.button?.matches(":focus-visible"))this.setAttribute("data-focus-visible","")};#Y=()=>{this.removeAttribute("data-focus-visible")};constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){if(this.type=this.getAttribute("type")||"button",!this.button){let Z=this.type==="select"||this.type==="upload",$=Z?"span":"button",J=Z?"":' type="button"';this.shadowRoot.innerHTML=`
|
|
2
2
|
<style>
|
|
3
3
|
button, button:hover, button:active, .fig-button-control {
|
|
4
4
|
padding: 0 var(--spacer-2);
|
|
@@ -34,11 +34,11 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
|
|
|
34
34
|
<${$} class="fig-button-control"${J}>
|
|
35
35
|
<slot></slot>
|
|
36
36
|
</${$}>
|
|
37
|
-
`,this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.button.addEventListener("click",this.#j),this.button.addEventListener("focus",this.#_),this.button.addEventListener("blur",this.#Y)}let Q=this.shadowRoot.querySelector("slot");Q?.removeEventListener("slotchange",this.#q),Q?.addEventListener("slotchange",this.#q),this.removeEventListener("keydown",this.#J),this.addEventListener("keydown",this.#J),this.#Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#F()}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#Z}set selected(Q){this.setAttribute("selected",Q)}#X(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#W(){if(this.#X())return;if(this.type==="toggle")if(this.selected)this.removeAttribute("selected");else this.setAttribute("selected","");if(this.type==="submit"){let Q=this.closest("form");if(Q)if(typeof Q.requestSubmit==="function")Q.requestSubmit();else Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),Z=this.getAttribute("target");if(Q)if(Z)window.open(Q,Z);else window.location.href=Q}}#N(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#K(){let Q=this.#N();if(Q instanceof HTMLSelectElement)return Q;if(Q?.tagName==="FIG-DROPDOWN")return Q.select||Q.querySelector?.("select")||null;return null}#G(Q){if(this.type!=="select")return;if(Q.key!=="Enter")return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;let Z=this.#K();if(!Z||Z.disabled||Z.multiple)return;if(typeof Z.showPicker!=="function")return;Q.preventDefault();try{Z.showPicker()}catch{}}#U(){if(!this.button)return;if(this.type!=="toggle"){this.removeAttribute("aria-pressed"),this.button.removeAttribute("aria-pressed");return}let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.setAttribute("aria-pressed",Q?"true":"false"),this.button.setAttribute("aria-pressed",Q?"true":"false")}#L(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#$.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.button.removeAttribute(Q);else this.button.setAttribute(Q,Z)})}#F(){if(!this.button)return;let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=Q,this.button instanceof HTMLButtonElement)this.button.disabled=Q,this.button.type="button",this.button.setAttribute("type","button");this.#z(),this.#L(),this.#U()}#z(){let Q=this.#N();if(!Q)return;if(this.#X()){if(!this.#Q.has(Q))this.#Q.set(Q,Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false");Q.setAttribute("disabled","")}else if(this.#Q.has(Q)){let $=this.#Q.get(Q);if(this.#Q.delete(Q),$)Q.setAttribute("disabled","");else Q.removeAttribute("disabled")}}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"type":{let J=(j)=>j==="select"||j==="upload";if(J(Z||"button")!==J($||"button")){this.button=null,this.connectedCallback();break}this.#F();break}case"disabled":this.#F();break;case"selected":this.#Z=$!==null&&$!=="false",this.#U();break;default:this.#L();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#J),this.shadowRoot?.querySelector("slot")?.removeEventListener("slotchange",this.#q)}}z("fig-button",V0);class x0 extends HTMLElement{#Z="Menu";#Q=null;#$;#J;#j;get label(){return this.#Z}set label(Q){this.#Z=Q}#q;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#$=this.#W.bind(this),this.#J=this.#N.bind(this),this.#j=this.#K.bind(this),this.#q=this.slotChange.bind(this)}#_(){this.select.addEventListener("input",this.#$),this.select.addEventListener("change",this.#J),this.select.addEventListener("keydown",this.#j)}#Y(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#X(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){if(this.type=this.getAttribute("type")||"select",this.#Z=this.getAttribute("label")||this.#Z,this.select.setAttribute("aria-label",this.#Z),this.#G(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#q),this.optionsSlot.addEventListener("slotchange",this.#q),this.select.removeEventListener("input",this.#$),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#j),this.#_()}slotChange(){let Q=this.hasAttribute("value"),Z=this.select.options.length>0&&this.select.selectedIndex>=0,$=Q?this.getAttribute("value"):this.type==="dropdown"?this.#Q:Z?this.select.value:null;while(this.select.firstChild)this.select.firstChild.remove();if(this.type==="dropdown"){let J=document.createElement("option");J.setAttribute("hidden","true"),J.setAttribute("selected","true"),J.selected=!0,this.select.appendChild(J)}if(this.optionsSlot.assignedNodes().forEach((J)=>{if(J.nodeName==="OPTION"||J.nodeName==="OPTGROUP")this.select.appendChild(J.cloneNode(!0))}),$!==null)this.#U($);if(this.type==="dropdown")this.select.selectedIndex=-1}#W(Q){Q.stopPropagation();let Z=Q.target.selectedOptions?.[0];if(this.#Y(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#X();return}let $=Q.target.value;if(this.type==="dropdown")this.#Q=$;this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}#N(Q){Q.stopPropagation();let Z=Q.target.selectedOptions?.[0];if(this.#Y(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#X();return}let $=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,composed:!0}))}#K(Q){if(this.closest('fig-button[type="select"]'))return;if(Q.key!=="Enter"||Q.defaultPrevented)return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(typeof this.select.showPicker!=="function")return;Q.preventDefault();try{this.select.showPicker()}catch{}}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#Q;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#Q=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","label","disabled"]}#G(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=Q}#U(Q){if(this.type==="dropdown")return;if(this.select)this.select.value=Q??""}attributeChangedCallback(Q,Z,$){if(Q==="value")this.#U($);if(Q==="type"){if(this.type=$||"select",this.isConnected)this.slotChange()}if(Q==="label")this.#Z=$||"Menu",this.select.setAttribute("aria-label",this.#Z);if(Q==="disabled")this.#G()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#q),this.select.removeEventListener("input",this.#$),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#j)}}z("fig-dropdown",x0);class H extends HTMLElement{static#Z=0;static#Q=0;static#$=1000;static#J=null;static#j=!1;static#q=new Set;#_;#Y;#X;#W;#N;#K;#G;#U;#L;#F;#z;#B;#M=null;#D=null;#E=null;#H=!1;#O;#R=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#_=this.#x.bind(this),this.#Y=this.hidePopupOutsideClick.bind(this),this.#X=this.showDelayedPopup.bind(this),this.#W=this.#f.bind(this),this.#N=()=>{if(!this.#H)this.showDelayedPopup()},this.#K=()=>{this.#H=!1,this.hidePopup()},this.#G=this.#y.bind(this),this.#U=this.#g.bind(this),this.#L=this.#h.bind(this),this.#F=this.#w.bind(this),this.#B=this.#V.bind(this),this.#z=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(H.#u(),this.setup(),this.#S(),this.setupEventListeners(),this.#M=this.closest("dialog"),this.#M)this.#M.addEventListener("close",this.#z)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#I(),this.#C(),document.removeEventListener("mousedown",this.#_,!0),document.removeEventListener("keydown",this.#B,!0),this.#M)this.#M.removeEventListener("close",this.#z),this.#M=null;if(this.action==="click")document.body.removeEventListener("click",this.#Y);if(clearTimeout(this.#O),H.#J===this)H.#J=null}#P(){return this.firstElementChild}#C(){this.#E?.disconnect(),this.#E=null}#S(){if(this.#I(),this.action==="manual")return;let Q=this.#P();if(!Q){if(!this.#E&&typeof MutationObserver<"u")this.#E=new MutationObserver(()=>{if(this.#P())this.#C(),this.#S()}),this.#E.observe(this,{childList:!0});return}if(this.#D=Q,this.action==="hover"){if(!this.isTouchDevice())Q.addEventListener("pointerenter",this.#X),Q.addEventListener("pointerleave",this.#W);Q.addEventListener("touchstart",this.#G,{passive:!0}),Q.addEventListener("touchmove",this.#U,{passive:!0}),Q.addEventListener("touchend",this.#L,{passive:!0}),Q.addEventListener("touchcancel",this.#F,{passive:!0}),Q.addEventListener("focus",this.#N),Q.addEventListener("blur",this.#K)}else if(this.action==="click")Q.addEventListener("click",this.#X),Q.addEventListener("touchstart",this.#X,{passive:!0})}#I(){let Q=this.#D;if(!Q)return;if(this.action==="hover")Q.removeEventListener("pointerenter",this.#X),Q.removeEventListener("pointerleave",this.#W),Q.removeEventListener("touchstart",this.#G),Q.removeEventListener("touchmove",this.#U),Q.removeEventListener("touchend",this.#L),Q.removeEventListener("touchcancel",this.#F),Q.removeEventListener("focus",this.#N),Q.removeEventListener("blur",this.#K);else if(this.action==="click")Q.removeEventListener("click",this.#X),Q.removeEventListener("touchstart",this.#X);this.#D=null}setup(){this.style.display="contents"}render(){this.destroy();let Q=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Z=document.createElement("span");if(this.popup=document.createElement("dialog",{is:"fig-popup"}),this.popup.setAttribute("is","fig-popup"),this.popup.setAttribute("variant","tooltip"),this.popup.setAttribute("data-tooltip-managed",""),this.popup.setAttribute("role","tooltip"),this.popup.setAttribute("closedby","closerequest"),Q)this.popup.setAttribute("popover","manual");let $=g();this.popup.setAttribute("id",$);let J=this.getAttribute("theme");if(J)this.popup.setAttribute("theme",J);let j=this.getAttribute("pointer");if(j!==null)this.popup.setAttribute("pointer",j);if(this.popup.append(Z),Z.innerText=this.getAttribute("text")??"",this.firstElementChild){let q=new Set((this.firstElementChild.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));q.add($),this.firstElementChild.setAttribute("aria-describedby",[...q].join(" "))}if(Q)(j0(this)??document.body).append(this.popup);else{let q=this.closest("dialog");if(q&&q.open)q.append(this.popup);else(j0(this)??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.#A(this.popup.id),this.popup.hidePopup?.(),this.popup.remove(),this.popup=null}#A(Q){let Z=this.firstElementChild;if(!Z||!Q)return;let $=Z.getAttribute("aria-describedby");if(!$)return;let J=$.split(/\s+/).filter((j)=>j&&j!==Q).join(" ");if(J)Z.setAttribute("aria-describedby",J);else Z.removeAttribute("aria-describedby")}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#Y);document.addEventListener("mousedown",this.#_,!0),document.addEventListener("keydown",this.#B,!0)}get#k(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#T(){let Q=Date.now(),Z=H.#$;if(this.action==="hover"&&H.#J)return!0;if(H.#Z&&Q-H.#Z<Z)return!0;if(H.#Q&&Q-H.#Q<Z)return!0;return!1}showDelayedPopup(){if(this.#k)return;if(clearTimeout(this.timeout),this.#T()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#M&&!this.#M.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&H.#J&&H.#J!==this)H.#J.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")H.#J=this;H.#Z=Date.now()}hidePopup(){if(this.#k)return;clearTimeout(this.timeout),clearTimeout(this.#O);let Q=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,H.#J===this)H.#J=null;if(Q)H.#Q=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#f(Q){if(!this.#R)this.hidePopup()}#y(Q){if(this.action==="hover")this.#R=!0,clearTimeout(this.#O),this.showDelayedPopup()}#g(Q){if(this.action==="hover"&&this.#R)clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#R=!1,this.hidePopup()},150)}#h(Q){if(this.action==="hover"&&this.#R)clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#R=!1,this.hidePopup()},300)}#w(Q){if(this.action==="hover"&&this.#R)this.#R=!1,clearTimeout(this.#O),this.hidePopup()}#V(Q){if(!this.isOpen&&!this.popup||Q.key!=="Escape")return;Q.preventDefault(),this.hidePopup(),this.firstElementChild?.focus?.()}static get observedAttributes(){return["action","delay","open","pointer","show","text","theme"]}get text(){return this.getAttribute("text")??""}set text(Q){this.setAttribute("text",Q)}#b(Q){if(!this.popup)return;let Z=this.popup.firstElementChild??this.popup.firstChild;if(!Z)return;Z.innerText=Q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null)this.removeAttribute("open");else this.setAttribute("open","true")}attributeChangedCallback(Q,Z,$){if(Q==="action"){if(this.#I(),Z==="click")document.body?.removeEventListener("click",this.#Y);if(this.action=$||"hover",this.isConnected){if(this.#S(),this.action==="click")document.body?.addEventListener("click",this.#Y)}}if(Q==="delay"){let J=parseInt($);this.delay=!isNaN(J)?J:500}if(Q==="open")if($!==null&&$!=="false")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(Q==="show")if($!==null&&$!=="false")this.showPopup();else this.hidePopup();if(Q==="text")this.#b($??"");if(Q==="pointer"){if(this.popup)if($!==null)this.popup.setAttribute("pointer",$);else this.popup.removeAttribute("pointer")}if(Q==="theme"){if(this.popup)if($)this.popup.setAttribute("theme",$);else this.popup.removeAttribute("theme")}}#x(Q){if(!this.isOpen)return;let Z=Q.target;if(this.popup&&this.popup.contains(Z))return;if(Z.tagName==="SELECT"||Z.hasAttribute("popover")||Z.closest("dialog"))this.hidePopup()}static#u(){if(H.#j)return;H.#j=!0;let Q=()=>{H.dismissHoverTooltips()},Z=()=>{H.#v()};document.documentElement.addEventListener("mouseleave",Q),document.addEventListener("mouseout",($)=>{if($.relatedTarget)return;Q()}),document.addEventListener("scroll",Z,{capture:!0,passive:!0}),window.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("resize",Z,{passive:!0});try{let $=window.frameElement;if($)$.addEventListener("mouseleave",Q)}catch{}window.addEventListener("message",($)=>{if($?.data?.type!=="figui:dismiss-tooltips")return;if(window.parent!==window&&$.source!==window.parent)return;Q()})}static dismissHoverTooltips(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof H))continue;if(Q.action!=="hover")continue;if(Q.#k)continue;if(Q.#H=!0,setTimeout(()=>{let Z=Q.#D;if(Z!==document.activeElement&&!Z?.matches?.(":focus, :focus-within"))Q.#H=!1},0),Q.isOpen||Q.timeout)Q.hidePopup()}for(let Q of Array.from(H.#q))H.hide(Q)}static#m=new WeakMap;static#v(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof H))continue;if(Q.#k)continue;if(Q.isOpen||Q.timeout)Q.hidePopup()}for(let Q of Array.from(H.#q))H.hide(Q)}static show(Q,Z,$={}){H.#u(),H.hide(Q);let J=$.delay??500,q=Date.now()-H.#Z<H.#$?0:J,_={timeout:null,popup:null};H.#m.set(Q,_),H.#q.add(Q),_.timeout=setTimeout(()=>{let X=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Y=document.createElement("dialog",{is:"fig-popup"});if(Y.setAttribute("is","fig-popup"),Y.setAttribute("variant","tooltip"),Y.setAttribute("data-tooltip-managed",""),Y.setAttribute("role","tooltip"),Y.setAttribute("closedby","closerequest"),X)Y.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=Z,Y.append(K),X)(j0(Q)??document.body).append(Y);else{let G=Q.closest?.("dialog");if(G&&G.open)G.append(Y);else(j0(Q)??document.body).append(Y)}Y.anchor=Q,Y.open=!0,_.popup=Y,H.#Z=Date.now()},q)}static hide(Q){let Z=H.#m.get(Q);if(!Z)return;if(clearTimeout(Z.timeout),Z.popup)Z.popup.remove(),H.#Q=Date.now();H.#m.delete(Q),H.#q.delete(Q)}}z("fig-tooltip",H);class y0 extends HTMLElement{static observedAttributes=["position","tail"];#Z=null;#Q=null;#$=null;connectedCallback(){this.#Z=this.textContent,c(this,()=>{this.#J(),this.#j()})}disconnectedCallback(){this.#q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(this.#Z===null)return;this.#J()}#J(){let Q=this.getAttribute("position")||"right",Z=this.#Z||"";if(Q==="middle"){let $=this.getAttribute("tail"),J;if($){let _=Z.lastIndexOf($);J=_>0?_:Math.ceil(Z.length/2)}else J=Math.ceil(Z.length/2);this.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=Z.slice(0,J);let q=document.createElement("span");q.className="end",q.textContent=Z.slice(J),this.appendChild(j),this.appendChild(q)}else this.textContent=Z}#j(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;H.show(this,this.#Z)},this.#$=()=>{H.hide(this)},this.addEventListener("pointerenter",this.#Q),this.addEventListener("pointerleave",this.#$)}#q(){if(this.#Q)this.removeEventListener("pointerenter",this.#Q);if(this.#$)this.removeEventListener("pointerleave",this.#$);H.hide(this)}}z("fig-truncate",y0);class w0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._isDragging=!1,this._dragPending=!1,this._dragStartPos={x:0,y:0},this._dragOffset={x:0,y:0},this._resizeObserver=null,this._mutationObserver=null,this._autoResizeRafId=0,this._offset=16,this._positionInitialized=!1,this._dragThreshold=3,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundClose=this.close.bind(this),this._boundIframeMessage=this._handleIframeMessage.bind(this),this._boundContentMutation=this._scheduleAutoResize.bind(this),this._boundContentResize=this._scheduleAutoResize.bind(this),this._boundRestoreFocus=this._restoreFocus.bind(this),this._boundIframeMouseLeave=this._handleIframeMouseLeave.bind(this),this._iframeDismissMutationObserver=null,this._previousFocus=null}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){if(this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),this.open&&!this.matches?.(":modal"))this._assignStackingOrder();c(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._setupIframeDismissListeners(),this._syncA11y()}),window.addEventListener("message",this._boundIframeMessage)}disconnectedCallback(){this._figInit(),this._removeDragListeners(),this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize(),this._teardownIframeDismissListeners(),this.removeEventListener("close",this._boundRestoreFocus)}_captureFocusBeforeOpen(){let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}_restoreFocus(){let Q=this._previousFocus;if(this._previousFocus=null,!Q?.isConnected)return;let Z=document.activeElement;if(Z&&Z!==document.body&&!this.contains(Z))return;requestAnimationFrame(()=>Q.focus?.())}_assignStackingOrder(){this.style.zIndex=String(I0()+1)}_clearStackingOrder(){this.style.zIndex=""}show(){return this._captureFocusBeforeOpen(),this._assignStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),H.dismissHoverTooltips(),super.show()}showModal(){return this._captureFocusBeforeOpen(),this._clearStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),H.dismissHoverTooltips(),super.showModal()}close(...Q){let Z=super.close(...Q);return this._clearStackingOrder(),Z}_handleIframeMouseLeave(Q){let Z=Q?.currentTarget;if(!(Z instanceof HTMLIFrameElement))return;try{Z.contentWindow?.postMessage({type:"figui:dismiss-tooltips"},"*")}catch{}}_syncIframeDismissListeners(){for(let Q of this.querySelectorAll(":scope > iframe")){if(!(Q instanceof HTMLIFrameElement))continue;if(Q.dataset.figuiDismissBound==="true")continue;Q.dataset.figuiDismissBound="true",Q.addEventListener("mouseleave",this._boundIframeMouseLeave)}}_setupIframeDismissListeners(){if(this._syncIframeDismissListeners(),this._iframeDismissMutationObserver)return;this._iframeDismissMutationObserver=new MutationObserver(()=>{this._syncIframeDismissListeners()}),this._iframeDismissMutationObserver.observe(this,{childList:!0,subtree:!1})}_teardownIframeDismissListeners(){this._iframeDismissMutationObserver?.disconnect(),this._iframeDismissMutationObserver=null;for(let Q of this.querySelectorAll(":scope > iframe"))Q.removeEventListener("mouseleave",this._boundIframeMouseLeave),delete Q.dataset.figuiDismissBound}_handleIframeMessage(Q){if(!this.autoresize)return;let Z=Q?.data;if(!Z||Z.type!=="figui:iframe-resize")return;let $=Q.source;if(!$)return;let J=Array.from(this.querySelectorAll("iframe")).find((j)=>j.contentWindow===$);if(!J)return;this._resizeForIframe(J,Z)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let Q of this.children)try{this._resizeObserver.observe(Q)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((Q)=>{for(let Z of Q)Z.addedNodes?.forEach(($)=>{if($ instanceof Element&&$.parentElement===this)try{this._resizeObserver?.observe($)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(Q){let Z=window.getComputedStyle(this),$=parseFloat(Z.paddingTop||"0")+parseFloat(Z.paddingBottom||"0")+parseFloat(Z.borderTopWidth||"0")+parseFloat(Z.borderBottomWidth||"0"),J=0,j=parseFloat(Z.rowGap||Z.gap||"0")||0,q=0;for(let _ of this.children){let X=_.getBoundingClientRect();if(X.height===0)continue;if(q+=1,_===Q)continue;let Y=window.getComputedStyle(_),K=parseFloat(Y.marginTop||"0")+parseFloat(Y.marginBottom||"0");J+=X.height+K}if(j&&q>1)J+=j*(q-1);return $+J}_resizeForIframe(Q,Z){if(typeof Z.height!=="number"||!(Z.height>0))return;let $=this._computeChrome(Q);this.style.height=`${Math.ceil(Z.height+$)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){if(this.querySelector("fig-header[dialog-header]"))return;let Q=document.createElement("fig-header");Q.setAttribute("dialog-header",""),Q.setAttribute("data-auto","");let Z=document.createElement("h3");Z.textContent=this.getAttribute("title")||"Dialog";let $=document.createElement("fig-tooltip");$.setAttribute("text","Close");let J=document.createElement("fig-button");J.setAttribute("variant","ghost"),J.setAttribute("icon",""),J.setAttribute("aria-label","Close dialog"),J.setAttribute("close-dialog",""),J.appendChild(u("close")),$.appendChild(J),Q.appendChild(Z),Q.appendChild($),this.prepend(Q)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close dialog");Q.removeEventListener("click",this._boundClose),Q.addEventListener("click",this._boundClose)})}_syncA11y(){if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let Q=this.querySelector("fig-header[dialog-header] h1, fig-header[dialog-header] h2, fig-header[dialog-header] h3, fig-header[dialog-header] h4, fig-header[dialog-header] h5, fig-header[dialog-header] h6");if(Q){let Z=Q.getAttribute("id")||g();Q.setAttribute("id",Z),this.setAttribute("aria-labelledby",Z)}}}_applyPosition(){let Q=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let Z=Q.includes("top"),$=Q.includes("bottom"),J=Q.includes("left"),j=Q.includes("right"),q=Q.includes("center")&&!Z&&!$,_=Q.includes("center")&&!J&&!j;if(Z)this.style.top=`${this._offset}px`;else if($)this.style.bottom=`${this._offset}px`;else if(q)this.style.top="0",this.style.bottom="0";if(J)this.style.left=`${this._offset}px`;else if(j)this.style.right=`${this._offset}px`;else if(_)this.style.left="0",this.style.right="0";if(q&&_)this.style.margin="auto";else if(q)this.style.marginTop="auto",this.style.marginBottom="auto";else if(_)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let Q=this.getAttribute("handle"),Z=Q?this.querySelector(Q):this.querySelector("fig-header, header");if(Z)Z.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}_isInteractiveElement(Q){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(q)=>Z.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!$.includes(q.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}_handlePointerUp(Q){if(this._isDragging){if(this.hasPointerCapture?.(Q.pointerId))this.releasePointerCapture(Q.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Q==="autoresize"&&this.isConnected)this._syncAutoResize();if(Q==="drag")if(this.drag=$!==null&&$!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let J=this.querySelector("fig-header, header");if(J)J.style.cursor=""}if(Q==="position"&&this._positionInitialized)this._applyPosition();if(Q==="modal"){let J=this.modal;if(this.modal=$!==null&&$!=="false",this.open&&J!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(Q==="closedby")this.closedby=$||"any";if(Q==="title"){let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";this._syncA11y()}if(Q==="aria-label"||Q==="aria-labelledby")this._syncA11y()}}M0("fig-dialog",w0,{extends:"dialog"});class v0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._toastVisible=!1,this._syncingOpen=!1,this._managedRole=null,this._managedLive=null,this._boundHandleClose=this.handleClose.bind(this)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast();else{if(this.getAttribute("open")==="false")this._syncingOpen=!0,this.removeAttribute("open"),this._syncingOpen=!1;this._toastVisible=!1}}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close notification");Q.removeEventListener("click",this._boundHandleClose),Q.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto";let Q=Number.parseFloat(this.getAttribute("offset")),Z=Number.isFinite(Q)?Q:this._defaultOffset;this.style.bottom=`${Z}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let Q=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger",Z=Q?"alert":"status",$=Q?"assertive":"polite";if(!this.hasAttribute("role")||this.getAttribute("role")===this._managedRole)this.setAttribute("role",Z),this._managedRole=Z;if(!this.hasAttribute("aria-live")||this.getAttribute("aria-live")===this._managedLive)this.setAttribute("aria-live",$),this._managedLive=$;if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}startAutoClose(){this.clearAutoClose();let Q=parseInt(this.getAttribute("duration")??"5000");if(Q>0)this._autoCloseTimer=setTimeout(()=>this.hideToast(),Q)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}_resolveAutoTheme(){if(this.getAttribute("theme")!=="auto")return;let Q=getComputedStyle(document.documentElement).colorScheme||"";this.style.colorScheme=Q.includes("dark")?"light":"dark"}showToast(){let Q=this._toastVisible;this.syncLiveRegion(),this._resolveAutoTheme(),this._syncingOpen=!0;try{if(!this.open)this.show()}finally{this._syncingOpen=!1}if(this._toastVisible=!0,this.applyPosition(),this.startAutoClose(),!Q)this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){let Q=this._toastVisible||this.open;this.clearAutoClose(),this._syncingOpen=!0;try{if(this.open)this.close();else if(this.hasAttribute("open"))this.removeAttribute("open")}finally{this._syncingOpen=!1}if(this._toastVisible=!1,Q)this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Z===$)return;if(!this.isConnected)return;if(this._syncingOpen)return;if(Q==="offset")this.applyPosition();if(Q==="open")if($!==null&&$!=="false")this.showToast();else this.hideToast();if(Q==="duration"&&this._toastVisible)this.startAutoClose();if(Q==="theme")if($==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme");if(Q==="theme"||Q==="live")this.syncLiveRegion()}}M0("fig-toast",v0,{extends:"dialog"});class g0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;_previousFocus=null;_boundDocumentKeydown;_boundNativeClose;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{let Z=Q.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this),this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this),this._boundNativeClose=this.handleNativeClose.bind(this)}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._previousFocus>"u")this._previousFocus=null;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{let Z=Q.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this);if(typeof this._boundDocumentKeydown!=="function")this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this);if(typeof this._boundNativeClose!=="function")this._boundNativeClose=this.handleNativeClose.bind(this)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!(this.matches?.(":open")||this.matches?.(":popover-open"))&&!this.hasAttribute("open"))return;if(this.hidePopup(),this.hasAttribute("open"))this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else if(Q&&typeof Q.getBoundingClientRect==="function")this._anchorRef=Q;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role",this.getAttribute("variant")==="tooltip"?"tooltip":"dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this.removeEventListener("close",this._boundNativeClose),this.addEventListener("close",this._boundNativeClose),requestAnimationFrame(()=>{this.setupDragListeners()}),this.open)this.showPopup();else this.hidePopup()}disconnectedCallback(){if(this.ensureInitialized(),this.teardownObservers(),this.removeDragListeners(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this.removeEventListener("close",this._boundNativeClose),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(Q,Z,$){if(this.ensureInitialized(),Z===$)return;if(Q==="open"){if($==="false"){this.open=!1;return}if($===null){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=$!==null&&$!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(I0()+1),this.captureFocusBeforeOpen();let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),Z=this.shouldAutoReposition();if(Z)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(J){Q=!1}if(!Q&&!super.open)try{this.show()}catch(J){}if(Z&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.addEventListener("keydown",this._boundDocumentKeydown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let $=this.resolveAnchor();if($?.classList)$.classList.add("has-popup-open");if(this.getAttribute("variant")!=="tooltip")H.dismissHoverTooltips()}hidePopup(){let Q=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),Z=this.resolveAnchor();if(Z?.classList)Z.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch($){}if(this.matches?.(":open"))try{this.close()}catch($){}if(Q)this.restoreFocusAfterClose()}shouldRestoreFocus(){return this.getAttribute("variant")!=="tooltip"}captureFocusBeforeOpen(){if(!this.shouldRestoreFocus())return;let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}restoreFocusAfterClose(){if(!this.shouldRestoreFocus()){this._previousFocus=null;return}let Q=this.resolveAnchor(),Z=this._previousFocus?.isConnected?this._previousFocus:Q instanceof HTMLElement?Q:null;if(this._previousFocus=null,!Z?.isConnected)return;let $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Z.focus?.())}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q===!1||Q==="false"||Q===null)this.setAttribute("autoresize","false");else if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.setAttribute("autoresize","false")}handleNativeClose(){if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}setupObservers(){this.teardownObservers();let Q=this.resolveAnchor();if(Q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(Q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(Q){if(!Q)return null;let Z=Q.getBoundingClientRect();return{x:Z.x,y:Z.y,width:Z.width,height:Z.height}}hasRectChanged(Q,Z,$=0.25){if(!Q&&!Z)return!1;if(!Q||!Z)return!0;return Math.abs(Q.x-Z.x)>$||Math.abs(Q.y-Z.y)>$||Math.abs(Q.width-Z.width)>$||Math.abs(Q.height-Z.height)>$}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let Z=this.resolveAnchor(),$=this.readRectSnapshot(Z),J=this.shouldAutoReposition();if(J&&this.hasRectChanged(this._lastAnchorRect,$))this._lastAnchorRect=$,this.queueReposition();else if(!J)this._lastAnchorRect=$;this._anchorTrackRAF=requestAnimationFrame(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!(this.matches?.(":open")||this.matches?.(":popover-open")))return;let Z=this.getAttribute("closedby");if(Z==="none"||Z==="closerequest")return;let $=Q.target;if(!($ instanceof Node))return;let J=typeof Q.composedPath==="function"?Q.composedPath():[];if(J.includes(this))return;if(this.contains($))return;let j=this.resolveAnchor();if(j&&(J.includes(j)||j.contains?.($)))return;if(this.isInsideDescendantPopup($))return;this.open=!1}handleDocumentKeydown(Q){if(Q.key!=="Escape"||Q.defaultPrevented)return;if(!this.open)return;if(this.getAttribute("role")==="menu")return;if(this.getAttribute("closedby")==="none")return;let J=Array.from(document.querySelectorAll('dialog[is="fig-popup"][open]')).filter((j)=>j.open).map((j)=>({popup:j,z:Number.parseInt(getComputedStyle(j).zIndex||"0",10)||0})).sort((j,q)=>j.z-q.z).at(-1)?.popup;if(J&&J!==this)return;Q.preventDefault(),this.open=!1}isInsideDescendantPopup(Q){let Z=Q.closest?.('dialog[is="fig-popup"]');if(!Z||Z===this)return!1;let $=Z,J=new Set;while($&&!J.has($)){J.add($);let j=$.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;$=j.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}isInteractiveElement(Q){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(q)=>Z.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!$.includes(q.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging){if(this.hasPointerCapture?.(Q.pointerId))this.releasePointerCapture(Q.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let Z=this.parentElement;try{if(Z?.querySelector){let $=Z.querySelector(Q);if($&&!this.contains($))return $}return document.querySelector(Q)}catch{return null}}parsePosition(){let Z=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),$=new Set(["top","center","bottom"]),J=new Set(["left","center","right"]),j="top",q="center",_=null;if(Z.length>=2){if($.has(Z[0]))j=Z[0];if(J.has(Z[1]))q=Z[1];return{vertical:j,horizontal:q,shorthand:_}}if(Z.length===1){let X=Z[0];if(X==="top"||X==="bottom")j=X,_=X;else if(X==="left"||X==="right")q=X,_=X;else if(X==="center")j="center",q="center"}return{vertical:j,horizontal:q,shorthand:_}}normalizeOffsetToken(Q,Z="0px"){if(!Q)return Z;let $=Q.trim();if(!$)return Z;if(/^-?\d+(\.\d+)?$/.test($))return`${$}px`;return $}measureLengthPx(Q,Z="x"){if(!Q)return 0;let $=this.normalizeOffsetToken(Q,"0px");if($.endsWith("px")){let q=parseFloat($);return Number.isFinite(q)?q:0}let J=document.createElement("div");if(J.style.position="fixed",J.style.visibility="hidden",J.style.pointerEvents="none",J.style.left="0",J.style.top="0",J.style.margin="0",J.style.padding="0",J.style.border="0",Z==="x")J.style.width=$,J.style.height="0";else J.style.height=$,J.style.width="0";document.body.appendChild(J);let j=J.getBoundingClientRect();return J.remove(),Z==="x"?j.width:j.height}parseOffset(){let Z=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),$=this.normalizeOffsetToken(Z[0],"0px"),J=this.normalizeOffsetToken(Z[1],"0px");return{xToken:$,yToken:J,xPx:this.measureLengthPx($,"x"),yPx:this.measureLengthPx(J,"y")}}parseViewportMargins(){let Z=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((J)=>!Number.isNaN(J)),$=8;if(Z.length===0)return{top:8,right:8,bottom:8,left:8};if(Z.length===1)return{top:Z[0],right:Z[0],bottom:Z[0],left:Z[0]};if(Z.length===2)return{top:Z[0],right:Z[1],bottom:Z[0],left:Z[1]};if(Z.length===3)return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[1]};return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[3]}}getPlacementCandidates(Q,Z,$){let J={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if($){let q=$==="left"||$==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:Z,s:$},{v:Q,h:Z,s:J[$]},{v:Q,h:Z,s:q[0]},{v:Q,h:Z,s:q[1]}]}if(Q==="center")return[{v:"center",h:Z,s:null},{v:"center",h:J[Z],s:null},{v:"top",h:Z,s:null},{v:"bottom",h:Z,s:null},{v:"top",h:J[Z],s:null},{v:"bottom",h:J[Z],s:null}];if(Z==="center")return[{v:Q,h:"center",s:null},{v:J[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:J[Q],h:"left",s:null},{v:J[Q],h:"right",s:null}];return[{v:Q,h:Z,s:null},{v:J[Q],h:Z,s:null},{v:Q,h:J[Z],s:null},{v:J[Q],h:J[Z],s:null}]}computeCoords(Q,Z,$,J,j,q){let _,X;if(q==="left"||q==="right")return X=q==="left"?Q.left-Z.width-j.xPx:Q.right+j.xPx,_=Q.top,{top:_,left:X};if(q==="top"||q==="bottom")return _=q==="top"?Q.top-Z.height-j.yPx:Q.bottom+j.yPx,X=Q.left,{top:_,left:X};if($==="top")_=Q.top-Z.height-j.yPx;else if($==="bottom")_=Q.bottom+j.yPx;else _=Q.top+(Q.height-Z.height)/2;if($==="center")if(J==="left")X=Q.left-Z.width-j.xPx;else if(J==="right")X=Q.right+j.xPx;else X=Q.left+(Q.width-Z.width)/2;else if(J==="left")X=Q.left+j.xPx;else if(J==="right")X=Q.right-Z.width-j.xPx;else X=Q.left+(Q.width-Z.width)/2;return{top:_,left:X}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,Z,$){if($==="top")return"top";if($==="bottom")return"bottom";if($==="left")return"left";if($==="right")return"right";if(Q!=="center")return Q;if(Z!=="center")return Z;return"top"}lengthToPx(Q,Z=0){let $=getComputedStyle(this),J=String(Q||"").trim(),j=parseFloat(J);if(!Number.isFinite(j))return Z;if(J.endsWith("rem"))return j*parseFloat(getComputedStyle(document.documentElement).fontSize);if(J.endsWith("em"))return j*parseFloat($.fontSize);return j}radiusForSide(Q){let Z=getComputedStyle(this),$=(J)=>this.lengthToPx(J,0);if(Q==="top")return Math.max($(Z.borderTopLeftRadius),$(Z.borderTopRightRadius));if(Q==="bottom")return Math.max($(Z.borderBottomLeftRadius),$(Z.borderBottomRightRadius));if(Q==="left")return Math.max($(Z.borderTopLeftRadius),$(Z.borderBottomLeftRadius));if(Q==="right")return Math.max($(Z.borderTopRightRadius),$(Z.borderBottomRightRadius));return 0}getBeakEdgeInset(Q){let Z=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(Q)+Z/2)}tracksAnchorBeak(){let Q=this.getAttribute("variant");return Q==="popover"||Q==="tooltip"}getViewportBounds(Q){let Z=window.visualViewport,$=Z?.width??window.innerWidth,J=Z?.height??window.innerHeight,j=Z?.offsetLeft??0,q=Z?.offsetTop??0;return{minLeft:j+Q.left,minTop:q+Q.top,maxRight:j+$-Q.right,maxBottom:q+J-Q.bottom}}clampToViewport(Q,Z,$){let J=this.getViewportBounds($),j=J.maxRight-Z.width,q=J.maxBottom-Z.height;return{left:Math.min(j,Math.max(J.minLeft,Q.left)),top:Math.min(q,Math.max(J.minTop,Q.top))}}resolveCoordsAtViewport(Q,Z,$,J,j){let{left:q,top:_}=this.clampToViewport($,Z,j);if(!Q||!this.tracksAnchorBeak())return{left:q,top:_};let X=this.oppositeSide(J),Y=this.getViewportBounds(j),K=Y.maxRight-Z.width,G=Y.minLeft,N=Y.maxBottom-Z.height,W=Y.minTop;if(X==="top"||X==="bottom"){let O=this.getBeakEdgeInset(X),B=Q.left+Q.width/2,L=B-q;if(L<O)q=B-O;else if(L>Z.width-O)q=B-(Z.width-O);q=Math.min(K,Math.max(G,q))}else if(X==="left"||X==="right"){let O=this.getBeakEdgeInset(X),B=Q.top+Q.height/2,L=B-_;if(L<O)_=B-O;else if(L>Z.height-O)_=B-(Z.height-O);_=Math.min(N,Math.max(W,_))}return{left:q,top:_}}canPointAtAnchor(Q,Z,$,J,j){if(!Q||!this.tracksAnchorBeak())return!0;let q=this.oppositeSide(j),_=this.getBeakEdgeInset(q);if(q==="top"||q==="bottom"){let Y=Q.left+Q.width/2-$;return Y>=_-0.5&&Y<=Z.width-_+0.5}let X=Q.top+Q.height/2-J;return X>=_-0.5&&X<=Z.height-_+0.5}updatePopoverBeak(Q,Z,$,J,j){if(!this.tracksAnchorBeak()||!Q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let q=this.oppositeSide(j);this.setAttribute("data-beak-side",q);let _=Q.left+Q.width/2,X=Q.top+Q.height/2,Y=this.getBoundingClientRect(),K=Y.width>0&&Y.height>0?Y:Z,G=K.left,N=K.top,W=this.getBeakEdgeInset(q),O;if(q==="top"||q==="bottom"){O=_-G;let B=W,L=Math.max(B,K.width-W);O=Math.min(L,Math.max(B,O))}else{O=X-N;let B=W,L=Math.max(B,K.height-W);O=Math.min(L,Math.max(B,O))}this.style.setProperty("--fig-popup-beak-offset",`${O}px`)}overflowScore(Q,Z,$){let J=this.getViewportBounds($),j=Q.left+Z.width,q=Q.top+Z.height,_=Math.max(0,J.minLeft-Q.left),X=Math.max(0,J.minTop-Q.top),Y=Math.max(0,j-J.maxRight),K=Math.max(0,q-J.maxBottom);return _+X+Y+K}fits(Q,Z,$){return this.overflowScore(Q,Z,$)===0}clamp(Q,Z,$,J=null,j="top"){if(J)return this.resolveCoordsAtViewport(J,Z,Q,j,$);return this.clampToViewport(Q,Z,$)}primaryAxisOverflowPenalty(Q,Z,$,J){let j=this.getViewportBounds($),q=0;if(J==="top")q=Math.max(0,j.minTop-Q.top);else if(J==="bottom")q=Math.max(0,Q.top+Z.height-j.maxBottom);else if(J==="left")q=Math.max(0,j.minLeft-Q.left);else if(J==="right")q=Math.max(0,Q.left+Z.width-j.maxRight);return q>0?1000+q:0}placementScore(Q,Z,$,J,j){let q=this.resolveCoordsAtViewport(Q,Z,$,J,j),_=this.overflowScore(q,Z,j);if(_+=this.primaryAxisOverflowPenalty($,Z,j,J),Q&&!this.canPointAtAnchor(Q,Z,q.left,q.top,J))_+=1e4;return{score:_,resolved:q}}applyPopupPosition(Q,Z,$,J,j){let q=this.resolveCoordsAtViewport(Q,Z,$,J,j);this.style.left=`${q.left}px`,this.style.top=`${q.top}px`,this.updatePopoverBeak(Q,Z,q.left,q.top,J)}positionPopup(){if(!this.open)return;let Q=this.getBoundingClientRect(),Z=this.parseOffset(),{vertical:$,horizontal:J,shorthand:j}=this.parsePosition(),q=this.resolveAnchor(),_=this.parseViewportMargins();if(!q){this.updatePopoverBeak(null,Q,0,0,"top");let W=this.getViewportBounds(_),O={left:W.minLeft+(W.maxRight-W.minLeft-Q.width)/2,top:W.minTop+(W.maxBottom-W.minTop-Q.height)/2},B=this.clampToViewport(O,Q,_);this.style.left=`${B.left}px`,this.style.top=`${B.top}px`;return}let X=q.getBoundingClientRect(),Y=this.getPlacementCandidates($,J,j),K=null,G="top",N=Number.POSITIVE_INFINITY;for(let{v:W,h:O,s:B}of Y){let L=this.computeCoords(X,Q,W,O,Z,B),T=this.getPlacementSide(W,O,B),{score:R,resolved:A}=this.placementScore(X,Q,L,T,_);if(B){let M=this.getViewportBounds(_);if((B==="left"||B==="right"?L.left>=M.minLeft&&L.left+Q.width<=M.maxRight:L.top>=M.minTop&&L.top+Q.height<=M.maxBottom)&&R<1e4){this.applyPopupPosition(X,Q,L,T,_);return}}else if(R===0){this.applyPopupPosition(X,Q,L,T,_);return}if(R<N)N=R,K=A,G=T}this.applyPopupPosition(X,Q,K||{left:0,top:0},G,_)}queueReposition(){if(!this.open||!this.isPopupDisplayed()||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}isPopupDisplayed(){return Boolean(this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"))}}M0("fig-popup",g0,{extends:"dialog"});class h0 extends HTMLElement{#Z;#Q;constructor(){super();this.content=null,this.#Z=!1,this.#Q=this.handleClick.bind(this)}connectedCallback(){if(this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.addEventListener("click",this.#Q),c(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let Q=this.getAttribute("id")||g(),Z=this.content.getAttribute("id")||g();if(this.setAttribute("id",Q),this.content.setAttribute("id",Z),this.setAttribute("aria-controls",Z),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",Q),this.#Z)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}}})}get selected(){return this.#Z}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(F(this,"disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(Q,Z,$){if(Q==="selected"){if(this.#Z=$!==null&&$!=="false",this.setAttribute("aria-selected",this.#Z?"true":"false"),this.setAttribute("tabindex",this.#Z?"0":"-1"),this?.content)this.content.style.display=this.#Z?"block":"none"}if(Q==="disabled")if($!==null&&$!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#Z?"0":"-1")}}z("fig-tab",h0);class b0 extends HTMLElement{#Z;#Q;#$=this.#L.bind(this);#J=null;#j=null;#q=null;#_=null;#Y=!1;#X=new WeakSet;constructor(){super();this.#Z=this.handleClick.bind(this),this.#Q=this.#D.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){if(this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#Q),this.addEventListener("scroll",this.#$),this.#M(),this.#z(),this.#F(),c(this,()=>{let Q=this.getAttribute("value");if(Q)this.#O(Q);if(F(this,"disabled"))this.#W(!0);this.#K(),this.#L(),this.#G(void 0,"auto")})}#W(Q){this.querySelectorAll("fig-tab").forEach(($)=>{if(Q){if(!($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false"))this.#X.add($),$.setAttribute("disabled","");$.setAttribute("aria-disabled","true"),$.setAttribute("tabindex","-1")}else if(this.#X.has($))this.#X.delete($),$.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#K()}#N(){return Array.from(this.querySelectorAll("fig-tab")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#K(){let Q=Array.from(this.querySelectorAll("fig-tab")),Z=Q.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false")||this.#N()[0];Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false";$.setAttribute("tabindex",!J&&$===Z?"0":"-1")})}#G(Q=this.selectedTab,Z="smooth"){let $=Q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#N()[0];if(!$)return;requestAnimationFrame(()=>{if(!this.isConnected||!$.isConnected)return;if(!(this.scrollWidth>this.clientWidth))return;let j=this.getBoundingClientRect(),q=$.getBoundingClientRect(),_=q.left-j.left+this.scrollLeft+q.width/2;this.scrollTo({left:_-this.clientWidth/2,behavior:Z}),this.#L()})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#Q),this.removeEventListener("scroll",this.#$),this.#J?.disconnect(),this.#J=null,this.#j?.disconnect(),this.#j=null,this.#B()}#U(){if(this.#Y)return;let Q=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!Q)return;this.#Y=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#Y=!1}}#L(){a(this,this,"x")}#F(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>this.#L()),this.#j.observe(this)}#z(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>{if(this.#Y)return;this.#U(),this.#M(),this.#K(),requestAnimationFrame(()=>{this.#L(),this.#G()})}),this.#J.observe(this,{childList:!0,subtree:!1})}#B(){this.#q?.remove(),this.#_?.remove(),this.#q=null,this.#_=null,this.classList.remove("overflow-start","overflow-end")}#M(){if(this.#q&&this.#_&&this.contains(this.#q)&&this.contains(this.#_))return;this.#q?.remove(),this.#_?.remove();let Q=X0({owner:"tabs",onStart:()=>i(this,"x",-1),onEnd:()=>i(this,"x",1)});this.#q=Q.start,this.#_=Q.end,this.prepend(this.#q),this.append(this.#_)}#D(Q){let Z=this.#N();if(!Z.length)return;let $=Z.findIndex((j)=>F(j,"selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=$>0?$-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=$<Z.length-1?$+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;default:return}if(J!==$&&Z[J]){this.querySelectorAll("fig-tab").forEach((q)=>q.removeAttribute("selected")),this.selectedTab=Z[J],Z[J].setAttribute("selected","true");let j=this.#H(Z[J]);if(j)this.setAttribute("value",j);else this.removeAttribute("value");Z[J].focus(),this.#K(),this.#G(Z[J]),this.#E()}}get value(){return this.#H(this.selectedTab)}set value(Q){this.setAttribute("value",Q)}#E(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#H(Q){if(!Q)return"";let Z=Q.getAttribute("value");if(Z!==null)return Z;return Q.textContent?.trim()||""}#O(Q){let Z=this.querySelectorAll("fig-tab");for(let $ of Z)if(this.#H($)===Q)this.selectedTab=$,$.setAttribute("selected","true");else $.removeAttribute("selected");this.#K(),this.#G(this.selectedTab)}attributeChangedCallback(Q,Z,$){switch(Q){case"value":if($!==Z)this.#O($);break;case"disabled":this.#W($!==null&&$!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=Q.target.closest("fig-tab");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;let $=this.selectedTab,J=this.value,j=this.querySelectorAll("fig-tab");for(let _ of j)if(_===Z)this.selectedTab=_,_.setAttribute("selected","true");else _.removeAttribute("selected");let q=this.#H(Z);if(q)this.setAttribute("value",q);else this.removeAttribute("value");if(this.#K(),this.#G(Z),$!==Z||J!==this.value)this.#E()}}z("fig-tabs",b0);class m0 extends HTMLElement{#Z;#Q;#$;constructor(){super();this.#$=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#J(),this.addEventListener("click",this.#$)}disconnectedCallback(){this.removeEventListener("click",this.#$)}handleClick(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.closest("fig-segmented-control");if(Q&&Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#Z}set value(Q){this.#Z=Q,this.setAttribute("value",Q)}get selected(){return this.#Q}set selected(Q){this.#Q=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value","disabled"]}#J(){let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",Q?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",Q?"0":"-1")}attributeChangedCallback(Q,Z,$){switch(Q){case"value":this.#Z=$;break;case"selected":this.#Q=$,this.#J();break;case"disabled":this.#J();break}}}z("fig-segment",m0);class c0 extends HTMLElement{#Z=null;#Q=this.handleClick.bind(this);#$=this.#F.bind(this);#J=null;#j=null;#q=0;#_=!1;#Y=!1;#X=new WeakSet;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){if(this.name=this.getAttribute("name")||"segmented-control",!this.hasAttribute("role"))this.setAttribute("role","radiogroup");this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#$),this.#P(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#R(),this.#E(),c(this,()=>{this.#O({enforceFallback:!0}),this.#H(),this.#M({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#$),this.#J?.disconnect(),this.#J=null,this.#j?.disconnect(),this.#j=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#_=!1,this.#Y=!1}get selectedSegment(){return this.#Z}set selectedSegment(Q){let Z=this.querySelectorAll("fig-segment");for(let $ of Z){let J=$===Q,j=F($,"selected");if(J&&!j)$.setAttribute("selected","true");else if(!J&&j)$.removeAttribute("selected")}this.#Z=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#U(),this.#M()}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(Q))}#W(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#N(Q){let Z=Q.getAttribute("value");if(Z!==null){let $=Z.trim();if($.length>0)return $}return Q.textContent?.trim()||""}#K(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false")return Z;return null}#G(){return Array.from(this.querySelectorAll("fig-segment")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#U(){let Q=Array.from(this.querySelectorAll("fig-segment")),Z=Q.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false");Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false",j=$===Z;$.setAttribute("aria-checked",j?"true":"false"),$.setAttribute("tabindex",!J&&j?"0":"-1")})}#L(Q){if(!Q)return;let Z=this.selectedSegment,$=this.value;this.selectedSegment=Q;let J=this.#N(Q);if(J)this.setAttribute("value",J);else this.removeAttribute("value");let j=this.value;if(Z!==Q||$!==j)this.#W(j)}#F(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#G();if(!Z.length)return;let $=Z.findIndex((q)=>F(q,"selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=J>0?J-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=J<Z.length-1?J+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case" ":case"Enter":{let q=Q.target.closest("fig-segment");if(q&&this.contains(q))Q.preventDefault(),this.#L(q);return}default:return}let j=Z[J];this.#L(j),j.focus(),requestAnimationFrame(()=>{if(this.contains(j))j.focus()})}#z(Q){let Z=String(Q??"").trim();if(!Z)return!1;let $=this.querySelectorAll("fig-segment");for(let J of $){let j=this.#N(J);if(!j)continue;if(j===Z)return this.selectedSegment=J,!0}return!1}#B(){let Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#M({forceInstant:Q=!1}={}){if(this.#_=this.#_||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let Z=this.#_;this.#_=!1,this.#D({forceInstant:Z})})}#D({forceInstant:Q=!1}={}){let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#B(),J=this.#Z&&this.contains(this.#Z)?this.#Z:this.#K();if(Z||!$){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!$||Z)this.#Y=!1;return}if(!J){if(this.#Y)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let j=this.getBoundingClientRect(),q=J.getBoundingClientRect();if(j.width<=0||q.width<=0){if(this.#Y)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let _=Math.max(0,q.left-j.left);this.style.setProperty("--seg-indicator-x",`${_}px`),this.style.setProperty("--seg-indicator-w",`${q.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#Y||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#Y=!0}#E(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#M()}),this.#H()}#H(){if(!this.#j)return;this.#j.disconnect(),this.#j.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#j?.observe(Q)})}#O({enforceFallback:Q=!1}={}){if(this.querySelectorAll("fig-segment").length===0){this.#Z=null,this.#M({forceInstant:!0});return}let $=this.getAttribute("value"),J=$?.trim()??"";if($!==null){if(J!==$){this.setAttribute("value",J);return}if(J&&this.#z(J))return}let j=this.#K();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=this.#G()[0]||null}#R(){this.#J?.disconnect(),this.#J=new MutationObserver((Q)=>{let Z=!1;for(let $ of Q){if($.type==="childList"){Z=!0;break}if($.type==="attributes"&&$.target instanceof HTMLElement&&$.target.tagName.toLowerCase()==="fig-segment"&&($.attributeName==="value"||$.attributeName==="selected")){Z=!0;break}if($.type==="characterData"){Z=!0;break}}if(Z)this.#P(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#H(),this.#O({enforceFallback:!0}),this.#U()}),this.#J.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=Q.target.closest("fig-segment");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#L(Z)}#P(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach((Z)=>{if(Q){if(!(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false"))this.#X.add(Z),Z.setAttribute("disabled","");Z.setAttribute("aria-disabled","true")}else if(this.#X.has(Z))this.#X.delete(Z),Z.removeAttribute("disabled"),Z.removeAttribute("aria-disabled")}),this.#U()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled"){this.#P($!==null&&$!=="false"),this.#M({forceInstant:!0});return}if(Q==="value"){this.#O({enforceFallback:!1});return}if(Q==="animated"){if(!this.#B())this.#Y=!1;this.#M({forceInstant:!0});return}if(Q==="sizing")this.#M({forceInstant:!0})}}z("fig-segmented-control",c0);class u0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Z="segments";#Q=0;#$=null;#J=[];#j=null;#q=!1;#_(Q){let Z=Q?.detail;if(typeof Z==="string")return Z;let $=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if($===null||$===void 0)return null;return String($)}#Y(){if(this.#J.length===0)return!1;let Q=this.querySelector(":scope > fig-segmented-control");if(Q){let $=Q.querySelectorAll("fig-segment");if($.length!==this.#J.length)return!1;return Array.from($).every((J,j)=>J.getAttribute("value")===this.#J[j])}let Z=this.querySelector(":scope > fig-dropdown");if(Z){let $=Z.querySelectorAll("option");return $.length===this.#J.length&&Array.from($).every((J,j)=>J.textContent?.trim()===this.#J[j])}return!1}#X(){let Q=this.querySelector(":scope > fig-segmented-control");if(Q)this.#j=Q,this.#Z="segments";else this.#j=this.querySelector(":scope > fig-dropdown"),this.#Z="dropdown";this.#U()}connectedCallback(){if(this.#W(),this.#Y()){this.#X(),this.#F(),c(this,()=>c(this,()=>this.#M()));return}this.#N(),this.#F(),c(this,()=>c(this,()=>this.#M()))}disconnectedCallback(){this.#$?.disconnect(),this.#$=null}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get options(){return this.#J.slice()}set options(Q){if(Array.isArray(Q)){let $=Q.some((J)=>String(J).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",$)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="options"){this.#W(),this.#G();return}if(Q==="value"){this.#U();return}if(Q==="disabled"){this.#L("disabled");return}if(Q==="full"){this.#L("full");return}if(Q==="sizing")this.#L("sizing"),this.#G()}#W(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#J=JSON.parse(Q);return}catch{}let Z=Q.includes(`
|
|
37
|
+
`,this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.button.addEventListener("click",this.#j),this.button.addEventListener("focus",this.#_),this.button.addEventListener("blur",this.#Y)}let Q=this.shadowRoot.querySelector("slot");Q?.removeEventListener("slotchange",this.#q),Q?.addEventListener("slotchange",this.#q),this.removeEventListener("keydown",this.#J),this.addEventListener("keydown",this.#J),this.#Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#F()}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#Z}set selected(Q){this.setAttribute("selected",Q)}#X(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#W(){if(this.#X())return;if(this.type==="toggle")if(this.selected)this.removeAttribute("selected");else this.setAttribute("selected","");if(this.type==="submit"){let Q=this.closest("form");if(Q)if(typeof Q.requestSubmit==="function")Q.requestSubmit();else Q.submit()}if(this.type==="link"){let Q=this.getAttribute("href"),Z=this.getAttribute("target");if(Q)if(Z)window.open(Q,Z);else window.location.href=Q}}#N(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#K(){let Q=this.#N();if(Q instanceof HTMLSelectElement)return Q;if(Q?.tagName==="FIG-DROPDOWN")return Q.select||Q.querySelector?.("select")||null;return null}#G(Q){if(this.type!=="select")return;if(Q.key!=="Enter")return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;let Z=this.#K();if(!Z||Z.disabled||Z.multiple)return;if(typeof Z.showPicker!=="function")return;Q.preventDefault();try{Z.showPicker()}catch{}}#U(){if(!this.button)return;if(this.type!=="toggle"){this.removeAttribute("aria-pressed"),this.button.removeAttribute("aria-pressed");return}let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.setAttribute("aria-pressed",Q?"true":"false"),this.button.setAttribute("aria-pressed",Q?"true":"false")}#L(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#$.forEach((Q)=>{let Z=this.getAttribute(Q);if(Z===null)this.button.removeAttribute(Q);else this.button.setAttribute(Q,Z)})}#F(){if(!this.button)return;let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=Q,this.button instanceof HTMLButtonElement)this.button.disabled=Q,this.button.type="button",this.button.setAttribute("type","button");this.#z(),this.#L(),this.#U()}#z(){let Q=this.#N();if(!Q)return;if(this.#X()){if(!this.#Q.has(Q))this.#Q.set(Q,Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false");Q.setAttribute("disabled","")}else if(this.#Q.has(Q)){let $=this.#Q.get(Q);if(this.#Q.delete(Q),$)Q.setAttribute("disabled","");else Q.removeAttribute("disabled")}}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"type":{let J=(j)=>j==="select"||j==="upload";if(J(Z||"button")!==J($||"button")){this.button=null,this.connectedCallback();break}this.#F();break}case"disabled":this.#F();break;case"selected":this.#Z=$!==null&&$!=="false",this.#U();break;default:this.#L();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#J),this.shadowRoot?.querySelector("slot")?.removeEventListener("slotchange",this.#q)}}z("fig-button",V0);class x0 extends HTMLElement{#Z="Menu";#Q=null;#$;#J;#j;get label(){return this.#Z}set label(Q){this.#Z=Q}#q;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#$=this.#W.bind(this),this.#J=this.#N.bind(this),this.#j=this.#K.bind(this),this.#q=this.slotChange.bind(this)}#_(){this.select.addEventListener("input",this.#$),this.select.addEventListener("change",this.#J),this.select.addEventListener("keydown",this.#j)}#Y(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#X(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){if(this.type=this.getAttribute("type")||"select",this.#Z=this.getAttribute("label")||this.#Z,this.select.setAttribute("aria-label",this.#Z),this.#G(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#q),this.optionsSlot.addEventListener("slotchange",this.#q),this.select.removeEventListener("input",this.#$),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#j),this.#_()}slotChange(){let Q=this.hasAttribute("value"),Z=this.select.options.length>0&&this.select.selectedIndex>=0,$=Q?this.getAttribute("value"):this.type==="dropdown"?this.#Q:Z?this.select.value:null;while(this.select.firstChild)this.select.firstChild.remove();if(this.type==="dropdown"){let J=document.createElement("option");J.setAttribute("hidden","true"),J.setAttribute("selected","true"),J.selected=!0,this.select.appendChild(J)}if(this.optionsSlot.assignedNodes().forEach((J)=>{if(J.nodeName==="OPTION"||J.nodeName==="OPTGROUP")this.select.appendChild(J.cloneNode(!0))}),$!==null)this.#U($);if(this.type==="dropdown")this.select.selectedIndex=-1}#W(Q){Q.stopPropagation();let Z=Q.target.selectedOptions?.[0];if(this.#Y(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#X();return}let $=Q.target.value;if(this.type==="dropdown")this.#Q=$;this.setAttribute("value",$),this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}#N(Q){Q.stopPropagation();let Z=Q.target.selectedOptions?.[0];if(this.#Y(Z)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#X();return}let $=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,composed:!0}))}#K(Q){if(this.closest('fig-button[type="select"]'))return;if(Q.key!=="Enter"||Q.defaultPrevented)return;if(Q.altKey||Q.ctrlKey||Q.metaKey||Q.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(typeof this.select.showPicker!=="function")return;Q.preventDefault();try{this.select.showPicker()}catch{}}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#Q;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#Q=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","label","disabled"]}#G(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=Q}#U(Q){if(this.type==="dropdown")return;if(this.select)this.select.value=Q??""}attributeChangedCallback(Q,Z,$){if(Q==="value")this.#U($);if(Q==="type"){if(this.type=$||"select",this.isConnected)this.slotChange()}if(Q==="label")this.#Z=$||"Menu",this.select.setAttribute("aria-label",this.#Z);if(Q==="disabled")this.#G()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#q),this.select.removeEventListener("input",this.#$),this.select.removeEventListener("change",this.#J),this.select.removeEventListener("keydown",this.#j)}}z("fig-dropdown",x0);class H extends HTMLElement{static#Z=0;static#Q=0;static#$=1000;static#J=null;static#j=!1;static#q=new Set;#_;#Y;#X;#W;#N;#K;#G;#U;#L;#F;#z;#B;#M=null;#D=null;#E=null;#H=!1;#O;#R=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#_=this.#x.bind(this),this.#Y=this.hidePopupOutsideClick.bind(this),this.#X=this.showDelayedPopup.bind(this),this.#W=this.#f.bind(this),this.#N=()=>{if(!this.#H)this.showDelayedPopup()},this.#K=()=>{this.#H=!1,this.hidePopup()},this.#G=this.#y.bind(this),this.#U=this.#g.bind(this),this.#L=this.#h.bind(this),this.#F=this.#w.bind(this),this.#B=this.#V.bind(this),this.#z=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(H.#u(),this.setup(),this.#S(),this.setupEventListeners(),this.#M=this.closest("dialog"),this.#M)this.#M.addEventListener("close",this.#z)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#I(),this.#C(),document.removeEventListener("mousedown",this.#_,!0),document.removeEventListener("keydown",this.#B,!0),this.#M)this.#M.removeEventListener("close",this.#z),this.#M=null;if(this.action==="click")document.body.removeEventListener("click",this.#Y);if(clearTimeout(this.#O),H.#J===this)H.#J=null}#P(){return this.firstElementChild}#C(){this.#E?.disconnect(),this.#E=null}#S(){if(this.#I(),this.action==="manual")return;let Q=this.#P();if(!Q){if(!this.#E&&typeof MutationObserver<"u")this.#E=new MutationObserver(()=>{if(this.#P())this.#C(),this.#S()}),this.#E.observe(this,{childList:!0});return}if(this.#D=Q,this.action==="hover"){if(!this.isTouchDevice())Q.addEventListener("pointerenter",this.#X),Q.addEventListener("pointerleave",this.#W);Q.addEventListener("touchstart",this.#G,{passive:!0}),Q.addEventListener("touchmove",this.#U,{passive:!0}),Q.addEventListener("touchend",this.#L,{passive:!0}),Q.addEventListener("touchcancel",this.#F,{passive:!0}),Q.addEventListener("focus",this.#N),Q.addEventListener("blur",this.#K)}else if(this.action==="click")Q.addEventListener("click",this.#X),Q.addEventListener("touchstart",this.#X,{passive:!0})}#I(){let Q=this.#D;if(!Q)return;if(this.action==="hover")Q.removeEventListener("pointerenter",this.#X),Q.removeEventListener("pointerleave",this.#W),Q.removeEventListener("touchstart",this.#G),Q.removeEventListener("touchmove",this.#U),Q.removeEventListener("touchend",this.#L),Q.removeEventListener("touchcancel",this.#F),Q.removeEventListener("focus",this.#N),Q.removeEventListener("blur",this.#K);else if(this.action==="click")Q.removeEventListener("click",this.#X),Q.removeEventListener("touchstart",this.#X);this.#D=null}setup(){this.style.display="contents"}render(){this.destroy();let Q=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Z=document.createElement("span");if(this.popup=document.createElement("dialog",{is:"fig-popup"}),this.popup.setAttribute("is","fig-popup"),this.popup.setAttribute("variant","tooltip"),this.popup.setAttribute("data-tooltip-managed",""),this.popup.setAttribute("role","tooltip"),this.popup.setAttribute("closedby","closerequest"),Q)this.popup.setAttribute("popover","manual");let $=g();this.popup.setAttribute("id",$);let J=this.getAttribute("theme");if(J)this.popup.setAttribute("theme",J);let j=this.getAttribute("pointer");if(j!==null)this.popup.setAttribute("pointer",j);if(this.popup.append(Z),Z.innerText=this.getAttribute("text")??"",this.firstElementChild){let q=new Set((this.firstElementChild.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));q.add($),this.firstElementChild.setAttribute("aria-describedby",[...q].join(" "))}if(Q)(j0()??document.body).append(this.popup);else{let q=this.closest("dialog");if(q&&q.open)q.append(this.popup);else(j0()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.#A(this.popup.id),this.popup.hidePopup?.(),this.popup.remove(),this.popup=null}#A(Q){let Z=this.firstElementChild;if(!Z||!Q)return;let $=Z.getAttribute("aria-describedby");if(!$)return;let J=$.split(/\s+/).filter((j)=>j&&j!==Q).join(" ");if(J)Z.setAttribute("aria-describedby",J);else Z.removeAttribute("aria-describedby")}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#Y);document.addEventListener("mousedown",this.#_,!0),document.addEventListener("keydown",this.#B,!0)}get#k(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#T(){let Q=Date.now(),Z=H.#$;if(this.action==="hover"&&H.#J)return!0;if(H.#Z&&Q-H.#Z<Z)return!0;if(H.#Q&&Q-H.#Q<Z)return!0;return!1}showDelayedPopup(){if(this.#k)return;if(clearTimeout(this.timeout),this.#T()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#M&&!this.#M.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&H.#J&&H.#J!==this)H.#J.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")H.#J=this;H.#Z=Date.now()}hidePopup(){if(this.#k)return;clearTimeout(this.timeout),clearTimeout(this.#O);let Q=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,H.#J===this)H.#J=null;if(Q)H.#Q=Date.now()}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#f(Q){if(!this.#R)this.hidePopup()}#y(Q){if(this.action==="hover")this.#R=!0,clearTimeout(this.#O),this.showDelayedPopup()}#g(Q){if(this.action==="hover"&&this.#R)clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#R=!1,this.hidePopup()},150)}#h(Q){if(this.action==="hover"&&this.#R)clearTimeout(this.#O),this.#O=setTimeout(()=>{this.#R=!1,this.hidePopup()},300)}#w(Q){if(this.action==="hover"&&this.#R)this.#R=!1,clearTimeout(this.#O),this.hidePopup()}#V(Q){if(!this.isOpen&&!this.popup||Q.key!=="Escape")return;Q.preventDefault(),this.hidePopup(),this.firstElementChild?.focus?.()}static get observedAttributes(){return["action","delay","open","pointer","show","text","theme"]}get text(){return this.getAttribute("text")??""}set text(Q){this.setAttribute("text",Q)}#b(Q){if(!this.popup)return;let Z=this.popup.firstElementChild??this.popup.firstChild;if(!Z)return;Z.innerText=Q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null)this.removeAttribute("open");else this.setAttribute("open","true")}attributeChangedCallback(Q,Z,$){if(Q==="action"){if(this.#I(),Z==="click")document.body?.removeEventListener("click",this.#Y);if(this.action=$||"hover",this.isConnected){if(this.#S(),this.action==="click")document.body?.addEventListener("click",this.#Y)}}if(Q==="delay"){let J=parseInt($);this.delay=!isNaN(J)?J:500}if(Q==="open")if($!==null&&$!=="false")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(Q==="show")if($!==null&&$!=="false")this.showPopup();else this.hidePopup();if(Q==="text")this.#b($??"");if(Q==="pointer"){if(this.popup)if($!==null)this.popup.setAttribute("pointer",$);else this.popup.removeAttribute("pointer")}if(Q==="theme"){if(this.popup)if($)this.popup.setAttribute("theme",$);else this.popup.removeAttribute("theme")}}#x(Q){if(!this.isOpen)return;let Z=Q.target;if(this.popup&&this.popup.contains(Z))return;if(Z.tagName==="SELECT"||Z.hasAttribute("popover")||Z.closest("dialog"))this.hidePopup()}static#u(){if(H.#j)return;H.#j=!0;let Q=()=>{H.dismissHoverTooltips()},Z=()=>{H.#v()};document.documentElement.addEventListener("mouseleave",Q),document.addEventListener("mouseout",($)=>{if($.relatedTarget)return;Q()}),document.addEventListener("scroll",Z,{capture:!0,passive:!0}),window.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("scroll",Z,{passive:!0}),window.visualViewport?.addEventListener("resize",Z,{passive:!0});try{let $=window.frameElement;if($)$.addEventListener("mouseleave",Q)}catch{}window.addEventListener("message",($)=>{if($?.data?.type!=="figui:dismiss-tooltips")return;if(window.parent!==window&&$.source!==window.parent)return;Q()})}static dismissHoverTooltips(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof H))continue;if(Q.action!=="hover")continue;if(Q.#k)continue;if(Q.#H=!0,setTimeout(()=>{let Z=Q.#D;if(Z!==document.activeElement&&!Z?.matches?.(":focus, :focus-within"))Q.#H=!1},0),Q.isOpen||Q.timeout)Q.hidePopup()}for(let Q of Array.from(H.#q))H.hide(Q)}static#m=new WeakMap;static#v(){for(let Q of document.querySelectorAll("fig-tooltip")){if(!(Q instanceof H))continue;if(Q.#k)continue;if(Q.isOpen||Q.timeout)Q.hidePopup()}for(let Q of Array.from(H.#q))H.hide(Q)}static show(Q,Z,$={}){H.#u(),H.hide(Q);let J=$.delay??500,q=Date.now()-H.#Z<H.#$?0:J,_={timeout:null,popup:null};H.#m.set(Q,_),H.#q.add(Q),_.timeout=setTimeout(()=>{let X=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Y=document.createElement("dialog",{is:"fig-popup"});if(Y.setAttribute("is","fig-popup"),Y.setAttribute("variant","tooltip"),Y.setAttribute("data-tooltip-managed",""),Y.setAttribute("role","tooltip"),Y.setAttribute("closedby","closerequest"),X)Y.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=Z,Y.append(K),X)(j0()??document.body).append(Y);else{let G=Q.closest?.("dialog");if(G&&G.open)G.append(Y);else(j0()??document.body).append(Y)}Y.anchor=Q,Y.open=!0,_.popup=Y,H.#Z=Date.now()},q)}static hide(Q){let Z=H.#m.get(Q);if(!Z)return;if(clearTimeout(Z.timeout),Z.popup)Z.popup.remove(),H.#Q=Date.now();H.#m.delete(Q),H.#q.delete(Q)}}z("fig-tooltip",H);class y0 extends HTMLElement{static observedAttributes=["position","tail"];#Z=null;#Q=null;#$=null;connectedCallback(){this.#Z=this.textContent,c(this,()=>{this.#J(),this.#j()})}disconnectedCallback(){this.#q()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(this.#Z===null)return;this.#J()}#J(){let Q=this.getAttribute("position")||"right",Z=this.#Z||"";if(Q==="middle"){let $=this.getAttribute("tail"),J;if($){let _=Z.lastIndexOf($);J=_>0?_:Math.ceil(Z.length/2)}else J=Math.ceil(Z.length/2);this.innerHTML="";let j=document.createElement("span");j.className="start",j.textContent=Z.slice(0,J);let q=document.createElement("span");q.className="end",q.textContent=Z.slice(J),this.appendChild(j),this.appendChild(q)}else this.textContent=Z}#j(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#Q=()=>{if(this.scrollWidth<=this.clientWidth)return;H.show(this,this.#Z)},this.#$=()=>{H.hide(this)},this.addEventListener("pointerenter",this.#Q),this.addEventListener("pointerleave",this.#$)}#q(){if(this.#Q)this.removeEventListener("pointerenter",this.#Q);if(this.#$)this.removeEventListener("pointerleave",this.#$);H.hide(this)}}z("fig-truncate",y0);class w0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._isDragging=!1,this._dragPending=!1,this._dragStartPos={x:0,y:0},this._dragOffset={x:0,y:0},this._resizeObserver=null,this._mutationObserver=null,this._autoResizeRafId=0,this._offset=16,this._positionInitialized=!1,this._dragThreshold=3,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundClose=this.close.bind(this),this._boundIframeMessage=this._handleIframeMessage.bind(this),this._boundContentMutation=this._scheduleAutoResize.bind(this),this._boundContentResize=this._scheduleAutoResize.bind(this),this._boundRestoreFocus=this._restoreFocus.bind(this),this._boundIframeMouseLeave=this._handleIframeMouseLeave.bind(this),this._iframeDismissMutationObserver=null,this._previousFocus=null}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){if(this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),this.open&&!this.matches?.(":modal"))this._assignStackingOrder();c(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._setupIframeDismissListeners(),this._syncA11y()}),window.addEventListener("message",this._boundIframeMessage)}disconnectedCallback(){this._figInit(),this._removeDragListeners(),this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize(),this._teardownIframeDismissListeners(),this.removeEventListener("close",this._boundRestoreFocus)}_captureFocusBeforeOpen(){let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}_restoreFocus(){let Q=this._previousFocus;if(this._previousFocus=null,!Q?.isConnected)return;let Z=document.activeElement;if(Z&&Z!==document.body&&!this.contains(Z))return;requestAnimationFrame(()=>Q.focus?.())}_assignStackingOrder(){this.style.zIndex=String(I0()+1)}_clearStackingOrder(){this.style.zIndex=""}show(){return this._captureFocusBeforeOpen(),this._assignStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),H.dismissHoverTooltips(),super.show()}showModal(){return this._captureFocusBeforeOpen(),this._clearStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),H.dismissHoverTooltips(),super.showModal()}close(...Q){let Z=super.close(...Q);return this._clearStackingOrder(),Z}_handleIframeMouseLeave(Q){let Z=Q?.currentTarget;if(!(Z instanceof HTMLIFrameElement))return;try{Z.contentWindow?.postMessage({type:"figui:dismiss-tooltips"},"*")}catch{}}_syncIframeDismissListeners(){for(let Q of this.querySelectorAll(":scope > iframe")){if(!(Q instanceof HTMLIFrameElement))continue;if(Q.dataset.figuiDismissBound==="true")continue;Q.dataset.figuiDismissBound="true",Q.addEventListener("mouseleave",this._boundIframeMouseLeave)}}_setupIframeDismissListeners(){if(this._syncIframeDismissListeners(),this._iframeDismissMutationObserver)return;this._iframeDismissMutationObserver=new MutationObserver(()=>{this._syncIframeDismissListeners()}),this._iframeDismissMutationObserver.observe(this,{childList:!0,subtree:!1})}_teardownIframeDismissListeners(){this._iframeDismissMutationObserver?.disconnect(),this._iframeDismissMutationObserver=null;for(let Q of this.querySelectorAll(":scope > iframe"))Q.removeEventListener("mouseleave",this._boundIframeMouseLeave),delete Q.dataset.figuiDismissBound}_handleIframeMessage(Q){if(!this.autoresize)return;let Z=Q?.data;if(!Z||Z.type!=="figui:iframe-resize")return;let $=Q.source;if(!$)return;let J=Array.from(this.querySelectorAll("iframe")).find((j)=>j.contentWindow===$);if(!J)return;this._resizeForIframe(J,Z)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let Q of this.children)try{this._resizeObserver.observe(Q)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((Q)=>{for(let Z of Q)Z.addedNodes?.forEach(($)=>{if($ instanceof Element&&$.parentElement===this)try{this._resizeObserver?.observe($)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(Q){let Z=window.getComputedStyle(this),$=parseFloat(Z.paddingTop||"0")+parseFloat(Z.paddingBottom||"0")+parseFloat(Z.borderTopWidth||"0")+parseFloat(Z.borderBottomWidth||"0"),J=0,j=parseFloat(Z.rowGap||Z.gap||"0")||0,q=0;for(let _ of this.children){let X=_.getBoundingClientRect();if(X.height===0)continue;if(q+=1,_===Q)continue;let Y=window.getComputedStyle(_),K=parseFloat(Y.marginTop||"0")+parseFloat(Y.marginBottom||"0");J+=X.height+K}if(j&&q>1)J+=j*(q-1);return $+J}_resizeForIframe(Q,Z){if(typeof Z.height!=="number"||!(Z.height>0))return;let $=this._computeChrome(Q);this.style.height=`${Math.ceil(Z.height+$)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){if(this.querySelector("fig-header[dialog-header]"))return;let Q=document.createElement("fig-header");Q.setAttribute("dialog-header",""),Q.setAttribute("data-auto","");let Z=document.createElement("h3");Z.textContent=this.getAttribute("title")||"Dialog";let $=document.createElement("fig-tooltip");$.setAttribute("text","Close");let J=document.createElement("fig-button");J.setAttribute("variant","ghost"),J.setAttribute("icon",""),J.setAttribute("aria-label","Close dialog"),J.setAttribute("close-dialog",""),J.appendChild(u("close")),$.appendChild(J),Q.appendChild(Z),Q.appendChild($),this.prepend(Q)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close dialog");Q.removeEventListener("click",this._boundClose),Q.addEventListener("click",this._boundClose)})}_syncA11y(){if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let Q=this.querySelector("fig-header[dialog-header] h1, fig-header[dialog-header] h2, fig-header[dialog-header] h3, fig-header[dialog-header] h4, fig-header[dialog-header] h5, fig-header[dialog-header] h6");if(Q){let Z=Q.getAttribute("id")||g();Q.setAttribute("id",Z),this.setAttribute("aria-labelledby",Z)}}}_applyPosition(){let Q=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let Z=Q.includes("top"),$=Q.includes("bottom"),J=Q.includes("left"),j=Q.includes("right"),q=Q.includes("center")&&!Z&&!$,_=Q.includes("center")&&!J&&!j;if(Z)this.style.top=`${this._offset}px`;else if($)this.style.bottom=`${this._offset}px`;else if(q)this.style.top="0",this.style.bottom="0";if(J)this.style.left=`${this._offset}px`;else if(j)this.style.right=`${this._offset}px`;else if(_)this.style.left="0",this.style.right="0";if(q&&_)this.style.margin="auto";else if(q)this.style.marginTop="auto",this.style.marginBottom="auto";else if(_)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let Q=this.getAttribute("handle"),Z=Q?this.querySelector(Q):this.querySelector("fig-header, header");if(Z)Z.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}_isInteractiveElement(Q){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(q)=>Z.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!$.includes(q.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}_handlePointerDown(Q){if(!this.drag)return;if(this._isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}_handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}_handlePointerUp(Q){if(this._isDragging){if(this.hasPointerCapture?.(Q.pointerId))this.releasePointerCapture(Q.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Q==="autoresize"&&this.isConnected)this._syncAutoResize();if(Q==="drag")if(this.drag=$!==null&&$!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let J=this.querySelector("fig-header, header");if(J)J.style.cursor=""}if(Q==="position"&&this._positionInitialized)this._applyPosition();if(Q==="modal"){let J=this.modal;if(this.modal=$!==null&&$!=="false",this.open&&J!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(Q==="closedby")this.closedby=$||"any";if(Q==="title"){let J=this.querySelector("fig-header[data-auto] h3");if(J)J.textContent=$||"Dialog";this._syncA11y()}if(Q==="aria-label"||Q==="aria-labelledby")this._syncA11y()}}M0("fig-dialog",w0,{extends:"dialog"});class v0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._toastVisible=!1,this._syncingOpen=!1,this._managedRole=null,this._managedLive=null,this._boundHandleClose=this.handleClose.bind(this)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast();else{if(this.getAttribute("open")==="false")this._syncingOpen=!0,this.removeAttribute("open"),this._syncingOpen=!1;this._toastVisible=!1}}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((Q)=>{if(!Q.hasAttribute("aria-label"))Q.setAttribute("aria-label","Close notification");Q.removeEventListener("click",this._boundHandleClose),Q.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto";let Q=Number.parseFloat(this.getAttribute("offset")),Z=Number.isFinite(Q)?Q:this._defaultOffset;this.style.bottom=`${Z}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let Q=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger",Z=Q?"alert":"status",$=Q?"assertive":"polite";if(!this.hasAttribute("role")||this.getAttribute("role")===this._managedRole)this.setAttribute("role",Z),this._managedRole=Z;if(!this.hasAttribute("aria-live")||this.getAttribute("aria-live")===this._managedLive)this.setAttribute("aria-live",$),this._managedLive=$;if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}startAutoClose(){this.clearAutoClose();let Q=parseInt(this.getAttribute("duration")??"5000");if(Q>0)this._autoCloseTimer=setTimeout(()=>this.hideToast(),Q)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}_resolveAutoTheme(){if(this.getAttribute("theme")!=="auto")return;let Q=getComputedStyle(document.documentElement).colorScheme||"";this.style.colorScheme=Q.includes("dark")?"light":"dark"}showToast(){let Q=this._toastVisible;this.syncLiveRegion(),this._resolveAutoTheme(),this._syncingOpen=!0;try{if(!this.open)this.show()}finally{this._syncingOpen=!1}if(this._toastVisible=!0,this.applyPosition(),this.startAutoClose(),!Q)this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){let Q=this._toastVisible||this.open;this.clearAutoClose(),this._syncingOpen=!0;try{if(this.open)this.close();else if(this.hasAttribute("open"))this.removeAttribute("open")}finally{this._syncingOpen=!1}if(this._toastVisible=!1,Q)this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live"]}attributeChangedCallback(Q,Z,$){if(this._figInit(),Z===$)return;if(!this.isConnected)return;if(this._syncingOpen)return;if(Q==="offset")this.applyPosition();if(Q==="open")if($!==null&&$!=="false")this.showToast();else this.hideToast();if(Q==="duration"&&this._toastVisible)this.startAutoClose();if(Q==="theme")if($==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme");if(Q==="theme"||Q==="live")this.syncLiveRegion()}}M0("fig-toast",v0,{extends:"dialog"});class g0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;_previousFocus=null;_boundDocumentKeydown;_boundNativeClose;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{let Z=Q.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this),this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this),this._boundNativeClose=this.handleNativeClose.bind(this)}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._previousFocus>"u")this._previousFocus=null;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{let Z=Q.target;if(this.open&&(!(Z instanceof Node)||!this.contains(Z))&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this);if(typeof this._boundDocumentKeydown!=="function")this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this);if(typeof this._boundNativeClose!=="function")this._boundNativeClose=this.handleNativeClose.bind(this)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!(this.matches?.(":open")||this.matches?.(":popover-open"))&&!this.hasAttribute("open"))return;if(this.hidePopup(),this.hasAttribute("open"))this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else if(Q&&typeof Q.getBoundingClientRect==="function")this._anchorRef=Q;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role",this.getAttribute("variant")==="tooltip"?"tooltip":"dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this.removeEventListener("close",this._boundNativeClose),this.addEventListener("close",this._boundNativeClose),requestAnimationFrame(()=>{this.setupDragListeners()}),this.open)this.showPopup();else this.hidePopup()}disconnectedCallback(){if(this.ensureInitialized(),this.teardownObservers(),this.removeDragListeners(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this.removeEventListener("close",this._boundNativeClose),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(Q,Z,$){if(this.ensureInitialized(),Z===$)return;if(Q==="open"){if($==="false"){this.open=!1;return}if($===null){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=$!==null&&$!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(I0()+1),this.captureFocusBeforeOpen();let Q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),Z=this.shouldAutoReposition();if(Z)this.style.visibility="hidden";if(Q)try{this.showPopover()}catch(J){Q=!1}if(!Q&&!super.open)try{this.show()}catch(J){}if(Z&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.addEventListener("keydown",this._boundDocumentKeydown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let $=this.resolveAnchor();if($?.classList)$.classList.add("has-popup-open");if(this.getAttribute("variant")!=="tooltip")H.dismissHoverTooltips()}hidePopup(){let Q=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),Z=this.resolveAnchor();if(Z?.classList)Z.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch($){}if(this.matches?.(":open"))try{this.close()}catch($){}if(Q)this.restoreFocusAfterClose()}shouldRestoreFocus(){return this.getAttribute("variant")!=="tooltip"}captureFocusBeforeOpen(){if(!this.shouldRestoreFocus())return;let Q=document.activeElement;this._previousFocus=Q instanceof HTMLElement&&Q!==document.body&&!this.contains(Q)?Q:null}restoreFocusAfterClose(){if(!this.shouldRestoreFocus()){this._previousFocus=null;return}let Q=this.resolveAnchor(),Z=this._previousFocus?.isConnected?this._previousFocus:Q instanceof HTMLElement?Q:null;if(this._previousFocus=null,!Z?.isConnected)return;let $=document.activeElement;if($&&$!==document.body&&!this.contains($))return;requestAnimationFrame(()=>Z.focus?.())}get autoresize(){let Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q===!1||Q==="false"||Q===null)this.setAttribute("autoresize","false");else if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.setAttribute("autoresize","false")}handleNativeClose(){if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}setupObservers(){this.teardownObservers();let Q=this.resolveAnchor();if(Q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(Q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(Q){if(!Q)return null;let Z=Q.getBoundingClientRect();return{x:Z.x,y:Z.y,width:Z.width,height:Z.height}}hasRectChanged(Q,Z,$=0.25){if(!Q&&!Z)return!1;if(!Q||!Z)return!0;return Math.abs(Q.x-Z.x)>$||Math.abs(Q.y-Z.y)>$||Math.abs(Q.width-Z.width)>$||Math.abs(Q.height-Z.height)>$}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let Z=this.resolveAnchor(),$=this.readRectSnapshot(Z),J=this.shouldAutoReposition();if(J&&this.hasRectChanged(this._lastAnchorRect,$))this._lastAnchorRect=$,this.queueReposition();else if(!J)this._lastAnchorRect=$;this._anchorTrackRAF=requestAnimationFrame(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!(this.matches?.(":open")||this.matches?.(":popover-open")))return;let Z=this.getAttribute("closedby");if(Z==="none"||Z==="closerequest")return;let $=Q.target;if(!($ instanceof Node))return;let J=typeof Q.composedPath==="function"?Q.composedPath():[];if(J.includes(this))return;if(this.contains($))return;let j=this.resolveAnchor();if(j&&(J.includes(j)||j.contains?.($)))return;if(this.isInsideDescendantPopup($))return;this.open=!1}handleDocumentKeydown(Q){if(Q.key!=="Escape"||Q.defaultPrevented)return;if(!this.open)return;if(this.getAttribute("role")==="menu")return;if(this.getAttribute("closedby")==="none")return;let J=Array.from(document.querySelectorAll('dialog[is="fig-popup"][open]')).filter((j)=>j.open).map((j)=>({popup:j,z:Number.parseInt(getComputedStyle(j).zIndex||"0",10)||0})).sort((j,q)=>j.z-q.z).at(-1)?.popup;if(J&&J!==this)return;Q.preventDefault(),this.open=!1}isInsideDescendantPopup(Q){let Z=Q.closest?.('dialog[is="fig-popup"]');if(!Z||Z===this)return!1;let $=Z,J=new Set;while($&&!J.has($)){J.add($);let j=$.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;$=j.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}isInteractiveElement(Q){let Z=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],$=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],J=(q)=>Z.some((_)=>q.matches?.(_))||q.tagName?.startsWith("FIG-")&&!$.includes(q.tagName);if(J(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(J(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;let Z=this.getAttribute("handle");if(Z&&Z.trim()){let J=this.querySelector(Z);if(!J||!J.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;let $=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-$.left,this._dragOffset.y=Q.clientY-$.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){let Z=Math.abs(Q.clientX-this._dragStartPos.x),$=Math.abs(Q.clientY-this._dragStartPos.y);if(Z>this._dragThreshold||$>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";let J=this.getBoundingClientRect();this.style.top=`${J.top}px`,this.style.left=`${J.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging){if(this.hasPointerCapture?.(Q.pointerId))this.releasePointerCapture(Q.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let Q=this.getAttribute("anchor");if(!Q)return null;let Z=this.parentElement;try{if(Z?.querySelector){let $=Z.querySelector(Q);if($&&!this.contains($))return $}return document.querySelector(Q)}catch{return null}}parsePosition(){let Z=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),$=new Set(["top","center","bottom"]),J=new Set(["left","center","right"]),j="top",q="center",_=null;if(Z.length>=2){if($.has(Z[0]))j=Z[0];if(J.has(Z[1]))q=Z[1];return{vertical:j,horizontal:q,shorthand:_}}if(Z.length===1){let X=Z[0];if(X==="top"||X==="bottom")j=X,_=X;else if(X==="left"||X==="right")q=X,_=X;else if(X==="center")j="center",q="center"}return{vertical:j,horizontal:q,shorthand:_}}normalizeOffsetToken(Q,Z="0px"){if(!Q)return Z;let $=Q.trim();if(!$)return Z;if(/^-?\d+(\.\d+)?$/.test($))return`${$}px`;return $}measureLengthPx(Q,Z="x"){if(!Q)return 0;let $=this.normalizeOffsetToken(Q,"0px");if($.endsWith("px")){let q=parseFloat($);return Number.isFinite(q)?q:0}let J=document.createElement("div");if(J.style.position="fixed",J.style.visibility="hidden",J.style.pointerEvents="none",J.style.left="0",J.style.top="0",J.style.margin="0",J.style.padding="0",J.style.border="0",Z==="x")J.style.width=$,J.style.height="0";else J.style.height=$,J.style.width="0";document.body.appendChild(J);let j=J.getBoundingClientRect();return J.remove(),Z==="x"?j.width:j.height}parseOffset(){let Z=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),$=this.normalizeOffsetToken(Z[0],"0px"),J=this.normalizeOffsetToken(Z[1],"0px");return{xToken:$,yToken:J,xPx:this.measureLengthPx($,"x"),yPx:this.measureLengthPx(J,"y")}}parseViewportMargins(){let Z=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((J)=>!Number.isNaN(J)),$=8;if(Z.length===0)return{top:8,right:8,bottom:8,left:8};if(Z.length===1)return{top:Z[0],right:Z[0],bottom:Z[0],left:Z[0]};if(Z.length===2)return{top:Z[0],right:Z[1],bottom:Z[0],left:Z[1]};if(Z.length===3)return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[1]};return{top:Z[0],right:Z[1],bottom:Z[2],left:Z[3]}}getPlacementCandidates(Q,Z,$){let J={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if($){let q=$==="left"||$==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:Z,s:$},{v:Q,h:Z,s:J[$]},{v:Q,h:Z,s:q[0]},{v:Q,h:Z,s:q[1]}]}if(Q==="center")return[{v:"center",h:Z,s:null},{v:"center",h:J[Z],s:null},{v:"top",h:Z,s:null},{v:"bottom",h:Z,s:null},{v:"top",h:J[Z],s:null},{v:"bottom",h:J[Z],s:null}];if(Z==="center")return[{v:Q,h:"center",s:null},{v:J[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:J[Q],h:"left",s:null},{v:J[Q],h:"right",s:null}];return[{v:Q,h:Z,s:null},{v:J[Q],h:Z,s:null},{v:Q,h:J[Z],s:null},{v:J[Q],h:J[Z],s:null}]}computeCoords(Q,Z,$,J,j,q){let _,X;if(q==="left"||q==="right")return X=q==="left"?Q.left-Z.width-j.xPx:Q.right+j.xPx,_=Q.top,{top:_,left:X};if(q==="top"||q==="bottom")return _=q==="top"?Q.top-Z.height-j.yPx:Q.bottom+j.yPx,X=Q.left,{top:_,left:X};if($==="top")_=Q.top-Z.height-j.yPx;else if($==="bottom")_=Q.bottom+j.yPx;else _=Q.top+(Q.height-Z.height)/2;if($==="center")if(J==="left")X=Q.left-Z.width-j.xPx;else if(J==="right")X=Q.right+j.xPx;else X=Q.left+(Q.width-Z.width)/2;else if(J==="left")X=Q.left+j.xPx;else if(J==="right")X=Q.right-Z.width-j.xPx;else X=Q.left+(Q.width-Z.width)/2;return{top:_,left:X}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,Z,$){if($==="top")return"top";if($==="bottom")return"bottom";if($==="left")return"left";if($==="right")return"right";if(Q!=="center")return Q;if(Z!=="center")return Z;return"top"}lengthToPx(Q,Z=0){let $=getComputedStyle(this),J=String(Q||"").trim(),j=parseFloat(J);if(!Number.isFinite(j))return Z;if(J.endsWith("rem"))return j*parseFloat(getComputedStyle(document.documentElement).fontSize);if(J.endsWith("em"))return j*parseFloat($.fontSize);return j}radiusForSide(Q){let Z=getComputedStyle(this),$=(J)=>this.lengthToPx(J,0);if(Q==="top")return Math.max($(Z.borderTopLeftRadius),$(Z.borderTopRightRadius));if(Q==="bottom")return Math.max($(Z.borderBottomLeftRadius),$(Z.borderBottomRightRadius));if(Q==="left")return Math.max($(Z.borderTopLeftRadius),$(Z.borderBottomLeftRadius));if(Q==="right")return Math.max($(Z.borderTopRightRadius),$(Z.borderBottomRightRadius));return 0}getBeakEdgeInset(Q){let Z=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(Q)+Z/2)}tracksAnchorBeak(){let Q=this.getAttribute("variant");return Q==="popover"||Q==="tooltip"}getViewportBounds(Q){let Z=window.visualViewport,$=Z?.width??window.innerWidth,J=Z?.height??window.innerHeight,j=Z?.offsetLeft??0,q=Z?.offsetTop??0;return{minLeft:j+Q.left,minTop:q+Q.top,maxRight:j+$-Q.right,maxBottom:q+J-Q.bottom}}clampToViewport(Q,Z,$){let J=this.getViewportBounds($),j=J.maxRight-Z.width,q=J.maxBottom-Z.height;return{left:Math.min(j,Math.max(J.minLeft,Q.left)),top:Math.min(q,Math.max(J.minTop,Q.top))}}resolveCoordsAtViewport(Q,Z,$,J,j){let{left:q,top:_}=this.clampToViewport($,Z,j);if(!Q||!this.tracksAnchorBeak())return{left:q,top:_};let X=this.oppositeSide(J),Y=this.getViewportBounds(j),K=Y.maxRight-Z.width,G=Y.minLeft,N=Y.maxBottom-Z.height,W=Y.minTop;if(X==="top"||X==="bottom"){let O=this.getBeakEdgeInset(X),B=Q.left+Q.width/2,L=B-q;if(L<O)q=B-O;else if(L>Z.width-O)q=B-(Z.width-O);q=Math.min(K,Math.max(G,q))}else if(X==="left"||X==="right"){let O=this.getBeakEdgeInset(X),B=Q.top+Q.height/2,L=B-_;if(L<O)_=B-O;else if(L>Z.height-O)_=B-(Z.height-O);_=Math.min(N,Math.max(W,_))}return{left:q,top:_}}canPointAtAnchor(Q,Z,$,J,j){if(!Q||!this.tracksAnchorBeak())return!0;let q=this.oppositeSide(j),_=this.getBeakEdgeInset(q);if(q==="top"||q==="bottom"){let Y=Q.left+Q.width/2-$;return Y>=_-0.5&&Y<=Z.width-_+0.5}let X=Q.top+Q.height/2-J;return X>=_-0.5&&X<=Z.height-_+0.5}updatePopoverBeak(Q,Z,$,J,j){if(!this.tracksAnchorBeak()||!Q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let q=this.oppositeSide(j);this.setAttribute("data-beak-side",q);let _=Q.left+Q.width/2,X=Q.top+Q.height/2,Y=this.getBoundingClientRect(),K=Y.width>0&&Y.height>0?Y:Z,G=K.left,N=K.top,W=this.getBeakEdgeInset(q),O;if(q==="top"||q==="bottom"){O=_-G;let B=W,L=Math.max(B,K.width-W);O=Math.min(L,Math.max(B,O))}else{O=X-N;let B=W,L=Math.max(B,K.height-W);O=Math.min(L,Math.max(B,O))}this.style.setProperty("--fig-popup-beak-offset",`${O}px`)}overflowScore(Q,Z,$){let J=this.getViewportBounds($),j=Q.left+Z.width,q=Q.top+Z.height,_=Math.max(0,J.minLeft-Q.left),X=Math.max(0,J.minTop-Q.top),Y=Math.max(0,j-J.maxRight),K=Math.max(0,q-J.maxBottom);return _+X+Y+K}fits(Q,Z,$){return this.overflowScore(Q,Z,$)===0}clamp(Q,Z,$,J=null,j="top"){if(J)return this.resolveCoordsAtViewport(J,Z,Q,j,$);return this.clampToViewport(Q,Z,$)}primaryAxisOverflowPenalty(Q,Z,$,J){let j=this.getViewportBounds($),q=0;if(J==="top")q=Math.max(0,j.minTop-Q.top);else if(J==="bottom")q=Math.max(0,Q.top+Z.height-j.maxBottom);else if(J==="left")q=Math.max(0,j.minLeft-Q.left);else if(J==="right")q=Math.max(0,Q.left+Z.width-j.maxRight);return q>0?1000+q:0}placementScore(Q,Z,$,J,j){let q=this.resolveCoordsAtViewport(Q,Z,$,J,j),_=this.overflowScore(q,Z,j);if(_+=this.primaryAxisOverflowPenalty($,Z,j,J),Q&&!this.canPointAtAnchor(Q,Z,q.left,q.top,J))_+=1e4;return{score:_,resolved:q}}applyPopupPosition(Q,Z,$,J,j){let q=this.resolveCoordsAtViewport(Q,Z,$,J,j);this.style.left=`${q.left}px`,this.style.top=`${q.top}px`,this.updatePopoverBeak(Q,Z,q.left,q.top,J)}positionPopup(){if(!this.open)return;let Q=this.getBoundingClientRect(),Z=this.parseOffset(),{vertical:$,horizontal:J,shorthand:j}=this.parsePosition(),q=this.resolveAnchor(),_=this.parseViewportMargins();if(!q){this.updatePopoverBeak(null,Q,0,0,"top");let W=this.getViewportBounds(_),O={left:W.minLeft+(W.maxRight-W.minLeft-Q.width)/2,top:W.minTop+(W.maxBottom-W.minTop-Q.height)/2},B=this.clampToViewport(O,Q,_);this.style.left=`${B.left}px`,this.style.top=`${B.top}px`;return}let X=q.getBoundingClientRect(),Y=this.getPlacementCandidates($,J,j),K=null,G="top",N=Number.POSITIVE_INFINITY;for(let{v:W,h:O,s:B}of Y){let L=this.computeCoords(X,Q,W,O,Z,B),T=this.getPlacementSide(W,O,B),{score:R,resolved:A}=this.placementScore(X,Q,L,T,_);if(B){let M=this.getViewportBounds(_);if((B==="left"||B==="right"?L.left>=M.minLeft&&L.left+Q.width<=M.maxRight:L.top>=M.minTop&&L.top+Q.height<=M.maxBottom)&&R<1e4){this.applyPopupPosition(X,Q,L,T,_);return}}else if(R===0){this.applyPopupPosition(X,Q,L,T,_);return}if(R<N)N=R,K=A,G=T}this.applyPopupPosition(X,Q,K||{left:0,top:0},G,_)}queueReposition(){if(!this.open||!this.isPopupDisplayed()||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}isPopupDisplayed(){return Boolean(this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"))}}M0("fig-popup",g0,{extends:"dialog"});class h0 extends HTMLElement{#Z;#Q;constructor(){super();this.content=null,this.#Z=!1,this.#Q=this.handleClick.bind(this)}connectedCallback(){if(this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.addEventListener("click",this.#Q),c(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let Q=this.getAttribute("id")||g(),Z=this.content.getAttribute("id")||g();if(this.setAttribute("id",Q),this.content.setAttribute("id",Z),this.setAttribute("aria-controls",Z),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",Q),this.#Z)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}}})}get selected(){return this.#Z}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(F(this,"disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(Q,Z,$){if(Q==="selected"){if(this.#Z=$!==null&&$!=="false",this.setAttribute("aria-selected",this.#Z?"true":"false"),this.setAttribute("tabindex",this.#Z?"0":"-1"),this?.content)this.content.style.display=this.#Z?"block":"none"}if(Q==="disabled")if($!==null&&$!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#Z?"0":"-1")}}z("fig-tab",h0);class b0 extends HTMLElement{#Z;#Q;#$=this.#L.bind(this);#J=null;#j=null;#q=null;#_=null;#Y=!1;#X=new WeakSet;constructor(){super();this.#Z=this.handleClick.bind(this),this.#Q=this.#D.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){if(this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.addEventListener("click",this.#Z),this.addEventListener("keydown",this.#Q),this.addEventListener("scroll",this.#$),this.#M(),this.#z(),this.#F(),c(this,()=>{let Q=this.getAttribute("value");if(Q)this.#O(Q);if(F(this,"disabled"))this.#W(!0);this.#K(),this.#L(),this.#G(void 0,"auto")})}#W(Q){this.querySelectorAll("fig-tab").forEach(($)=>{if(Q){if(!($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false"))this.#X.add($),$.setAttribute("disabled","");$.setAttribute("aria-disabled","true"),$.setAttribute("tabindex","-1")}else if(this.#X.has($))this.#X.delete($),$.removeAttribute("disabled"),$.removeAttribute("aria-disabled")}),this.#K()}#N(){return Array.from(this.querySelectorAll("fig-tab")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#K(){let Q=Array.from(this.querySelectorAll("fig-tab")),Z=Q.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false")||this.#N()[0];Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false";$.setAttribute("tabindex",!J&&$===Z?"0":"-1")})}#G(Q=this.selectedTab,Z="smooth"){let $=Q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#N()[0];if(!$)return;requestAnimationFrame(()=>{if(!this.isConnected||!$.isConnected)return;if(!(this.scrollWidth>this.clientWidth))return;let j=this.getBoundingClientRect(),q=$.getBoundingClientRect(),_=q.left-j.left+this.scrollLeft+q.width/2;this.scrollTo({left:_-this.clientWidth/2,behavior:Z}),this.#L()})}disconnectedCallback(){this.removeEventListener("click",this.#Z),this.removeEventListener("keydown",this.#Q),this.removeEventListener("scroll",this.#$),this.#J?.disconnect(),this.#J=null,this.#j?.disconnect(),this.#j=null,this.#B()}#U(){if(this.#Y)return;let Q=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!Q)return;this.#Y=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#Y=!1}}#L(){a(this,this,"x")}#F(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>this.#L()),this.#j.observe(this)}#z(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>{if(this.#Y)return;this.#U(),this.#M(),this.#K(),requestAnimationFrame(()=>{this.#L(),this.#G()})}),this.#J.observe(this,{childList:!0,subtree:!1})}#B(){this.#q?.remove(),this.#_?.remove(),this.#q=null,this.#_=null,this.classList.remove("overflow-start","overflow-end")}#M(){if(this.#q&&this.#_&&this.contains(this.#q)&&this.contains(this.#_))return;this.#q?.remove(),this.#_?.remove();let Q=X0({owner:"tabs",onStart:()=>i(this,"x",-1),onEnd:()=>i(this,"x",1)});this.#q=Q.start,this.#_=Q.end,this.prepend(this.#q),this.append(this.#_)}#D(Q){let Z=this.#N();if(!Z.length)return;let $=Z.findIndex((j)=>F(j,"selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=$>0?$-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=$<Z.length-1?$+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;default:return}if(J!==$&&Z[J]){this.querySelectorAll("fig-tab").forEach((q)=>q.removeAttribute("selected")),this.selectedTab=Z[J],Z[J].setAttribute("selected","true");let j=this.#H(Z[J]);if(j)this.setAttribute("value",j);else this.removeAttribute("value");Z[J].focus(),this.#K(),this.#G(Z[J]),this.#E()}}get value(){return this.#H(this.selectedTab)}set value(Q){this.setAttribute("value",Q)}#E(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#H(Q){if(!Q)return"";let Z=Q.getAttribute("value");if(Z!==null)return Z;return Q.textContent?.trim()||""}#O(Q){let Z=this.querySelectorAll("fig-tab");for(let $ of Z)if(this.#H($)===Q)this.selectedTab=$,$.setAttribute("selected","true");else $.removeAttribute("selected");this.#K(),this.#G(this.selectedTab)}attributeChangedCallback(Q,Z,$){switch(Q){case"value":if($!==Z)this.#O($);break;case"disabled":this.#W($!==null&&$!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=Q.target.closest("fig-tab");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;let $=this.selectedTab,J=this.value,j=this.querySelectorAll("fig-tab");for(let _ of j)if(_===Z)this.selectedTab=_,_.setAttribute("selected","true");else _.removeAttribute("selected");let q=this.#H(Z);if(q)this.setAttribute("value",q);else this.removeAttribute("value");if(this.#K(),this.#G(Z),$!==Z||J!==this.value)this.#E()}}z("fig-tabs",b0);class m0 extends HTMLElement{#Z;#Q;#$;constructor(){super();this.#$=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#J(),this.addEventListener("click",this.#$)}disconnectedCallback(){this.removeEventListener("click",this.#$)}handleClick(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.closest("fig-segmented-control");if(Q&&Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#Z}set value(Q){this.#Z=Q,this.setAttribute("value",Q)}get selected(){return this.#Q}set selected(Q){this.#Q=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value","disabled"]}#J(){let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",Q?"true":"false"),Z)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",Q?"0":"-1")}attributeChangedCallback(Q,Z,$){switch(Q){case"value":this.#Z=$;break;case"selected":this.#Q=$,this.#J();break;case"disabled":this.#J();break}}}z("fig-segment",m0);class c0 extends HTMLElement{#Z=null;#Q=this.handleClick.bind(this);#$=this.#F.bind(this);#J=null;#j=null;#q=0;#_=!1;#Y=!1;#X=new WeakSet;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){if(this.name=this.getAttribute("name")||"segmented-control",!this.hasAttribute("role"))this.setAttribute("role","radiogroup");this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#$),this.#P(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#R(),this.#E(),c(this,()=>{this.#O({enforceFallback:!0}),this.#H(),this.#M({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#$),this.#J?.disconnect(),this.#J=null,this.#j?.disconnect(),this.#j=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#_=!1,this.#Y=!1}get selectedSegment(){return this.#Z}set selectedSegment(Q){let Z=this.querySelectorAll("fig-segment");for(let $ of Z){let J=$===Q,j=F($,"selected");if(J&&!j)$.setAttribute("selected","true");else if(!J&&j)$.removeAttribute("selected")}this.#Z=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#U(),this.#M()}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(Q))}#W(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#N(Q){let Z=Q.getAttribute("value");if(Z!==null){let $=Z.trim();if($.length>0)return $}return Q.textContent?.trim()||""}#K(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false")return Z;return null}#G(){return Array.from(this.querySelectorAll("fig-segment")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#U(){let Q=Array.from(this.querySelectorAll("fig-segment")),Z=Q.find(($)=>$.hasAttribute("selected")&&$.getAttribute("selected")!=="false");Q.forEach(($)=>{let J=$.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false",j=$===Z;$.setAttribute("aria-checked",j?"true":"false"),$.setAttribute("tabindex",!J&&j?"0":"-1")})}#L(Q){if(!Q)return;let Z=this.selectedSegment,$=this.value;this.selectedSegment=Q;let J=this.#N(Q);if(J)this.setAttribute("value",J);else this.removeAttribute("value");let j=this.value;if(Z!==Q||$!==j)this.#W(j)}#F(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#G();if(!Z.length)return;let $=Z.findIndex((q)=>F(q,"selected")),J=$>=0?$:0;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),J=J>0?J-1:Z.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),J=J<Z.length-1?J+1:0;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case" ":case"Enter":{let q=Q.target.closest("fig-segment");if(q&&this.contains(q))Q.preventDefault(),this.#L(q);return}default:return}let j=Z[J];this.#L(j),j.focus(),requestAnimationFrame(()=>{if(this.contains(j))j.focus()})}#z(Q){let Z=String(Q??"").trim();if(!Z)return!1;let $=this.querySelectorAll("fig-segment");for(let J of $){let j=this.#N(J);if(!j)continue;if(j===Z)return this.selectedSegment=J,!0}return!1}#B(){let Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#M({forceInstant:Q=!1}={}){if(this.#_=this.#_||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;let Z=this.#_;this.#_=!1,this.#D({forceInstant:Z})})}#D({forceInstant:Q=!1}={}){let Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.#B(),J=this.#Z&&this.contains(this.#Z)?this.#Z:this.#K();if(Z||!$){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!$||Z)this.#Y=!1;return}if(!J){if(this.#Y)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let j=this.getBoundingClientRect(),q=J.getBoundingClientRect();if(j.width<=0||q.width<=0){if(this.#Y)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let _=Math.max(0,q.left-j.left);this.style.setProperty("--seg-indicator-x",`${_}px`),this.style.setProperty("--seg-indicator-w",`${q.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#Y||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#Y=!0}#E(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#M()}),this.#H()}#H(){if(!this.#j)return;this.#j.disconnect(),this.#j.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#j?.observe(Q)})}#O({enforceFallback:Q=!1}={}){if(this.querySelectorAll("fig-segment").length===0){this.#Z=null,this.#M({forceInstant:!0});return}let $=this.getAttribute("value"),J=$?.trim()??"";if($!==null){if(J!==$){this.setAttribute("value",J);return}if(J&&this.#z(J))return}let j=this.#K();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=this.#G()[0]||null}#R(){this.#J?.disconnect(),this.#J=new MutationObserver((Q)=>{let Z=!1;for(let $ of Q){if($.type==="childList"){Z=!0;break}if($.type==="attributes"&&$.target instanceof HTMLElement&&$.target.tagName.toLowerCase()==="fig-segment"&&($.attributeName==="value"||$.attributeName==="selected")){Z=!0;break}if($.type==="characterData"){Z=!0;break}}if(Z)this.#P(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#H(),this.#O({enforceFallback:!0}),this.#U()}),this.#J.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=Q.target.closest("fig-segment");if(!Z||!this.contains(Z))return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#L(Z)}#P(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach((Z)=>{if(Q){if(!(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false"))this.#X.add(Z),Z.setAttribute("disabled","");Z.setAttribute("aria-disabled","true")}else if(this.#X.has(Z))this.#X.delete(Z),Z.removeAttribute("disabled"),Z.removeAttribute("aria-disabled")}),this.#U()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled"){this.#P($!==null&&$!=="false"),this.#M({forceInstant:!0});return}if(Q==="value"){this.#O({enforceFallback:!1});return}if(Q==="animated"){if(!this.#B())this.#Y=!1;this.#M({forceInstant:!0});return}if(Q==="sizing")this.#M({forceInstant:!0})}}z("fig-segmented-control",c0);class u0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Z="segments";#Q=0;#$=null;#J=[];#j=null;#q=!1;#_(Q){let Z=Q?.detail;if(typeof Z==="string")return Z;let $=Q?.currentTarget?.value??Q?.target?.value??this.getAttribute("value");if($===null||$===void 0)return null;return String($)}#Y(){if(this.#J.length===0)return!1;let Q=this.querySelector(":scope > fig-segmented-control");if(Q){let $=Q.querySelectorAll("fig-segment");if($.length!==this.#J.length)return!1;return Array.from($).every((J,j)=>J.getAttribute("value")===this.#J[j])}let Z=this.querySelector(":scope > fig-dropdown");if(Z){let $=Z.querySelectorAll("option");return $.length===this.#J.length&&Array.from($).every((J,j)=>J.textContent?.trim()===this.#J[j])}return!1}#X(){let Q=this.querySelector(":scope > fig-segmented-control");if(Q)this.#j=Q,this.#Z="segments";else this.#j=this.querySelector(":scope > fig-dropdown"),this.#Z="dropdown";this.#U()}connectedCallback(){if(this.#W(),this.#Y()){this.#X(),this.#F(),c(this,()=>c(this,()=>this.#M()));return}this.#N(),this.#F(),c(this,()=>c(this,()=>this.#M()))}disconnectedCallback(){this.#$?.disconnect(),this.#$=null}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get options(){return this.#J.slice()}set options(Q){if(Array.isArray(Q)){let $=Q.some((J)=>String(J).includes(","))?JSON.stringify(Q):Q.join(",");this.setAttribute("options",$)}else this.setAttribute("options",String(Q||""))}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="options"){this.#W(),this.#G();return}if(Q==="value"){this.#U();return}if(Q==="disabled"){this.#L("disabled");return}if(Q==="full"){this.#L("full");return}if(Q==="sizing")this.#L("sizing"),this.#G()}#W(){let Q=this.getAttribute("options")||"";if(Q.startsWith("["))try{this.#J=JSON.parse(Q);return}catch{}let Z=Q.includes(`
|
|
38
38
|
`)?`
|
|
39
|
-
`:",";this.#J=Q.split(Z).map(($)=>$.trim()).filter(Boolean)}#N(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-segmented-control");if(Q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),F(this,"disabled"))Q.setAttribute("disabled","");if(F(this,"full"))Q.setAttribute("full","");let Z=this.getAttribute("value");for(let $ of this.#J){let J=document.createElement("fig-segment");if(J.setAttribute("value",$),J.textContent=$,Z===$)J.setAttribute("selected","true");Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Z="segments"}#K(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-dropdown");if(F(this,"disabled"))Q.setAttribute("disabled","");let Z=this.getAttribute("value");for(let $ of this.#J){let J=document.createElement("option");if(J.value=$,J.textContent=$,Z===$)J.selected=!0;Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Z="dropdown"}#G(){if(this.#Z==="segments")this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#M())});else this.#K()}#U(){if(!this.#j||this.#q)return;let Q=this.getAttribute("value")||"";this.#j.value=Q}#L(Q){if(!this.#j)return;if(this.hasAttribute(Q))this.#j.setAttribute(Q,this.getAttribute(Q)||"");else this.#j.removeAttribute(Q)}#F(){this.#$?.disconnect(),this.#$=new ResizeObserver(()=>{this.#M()}),this.#$.observe(this)}#z(Q){let Z=document.createRange();Z.selectNodeContents(Q);let $=Z.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,q=getComputedStyle(Q),_=parseFloat(q.paddingLeft)||0,X=parseFloat(q.paddingRight)||0,Y=j-_-X;return $>Y+0.5}#B(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(this.#z(Z))return!0;return!1}#M(){if(this.#J.length<=1)return;if(this.#Z==="segments"){let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#B())this.#Q=this.clientWidth,this.#K()}else if(this.#Q>0&&this.clientWidth>=this.#Q)this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#B())this.#K()})})}}z("fig-options",u0);function
|
|
39
|
+
`:",";this.#J=Q.split(Z).map(($)=>$.trim()).filter(Boolean)}#N(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-segmented-control");if(Q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),F(this,"disabled"))Q.setAttribute("disabled","");if(F(this,"full"))Q.setAttribute("full","");let Z=this.getAttribute("value");for(let $ of this.#J){let J=document.createElement("fig-segment");if(J.setAttribute("value",$),J.textContent=$,Z===$)J.setAttribute("selected","true");Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(J===null)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Z="segments"}#K(){if(this.innerHTML="",this.#J.length===0)return;let Q=document.createElement("fig-dropdown");if(F(this,"disabled"))Q.setAttribute("disabled","");let Z=this.getAttribute("value");for(let $ of this.#J){let J=document.createElement("option");if(J.value=$,J.textContent=$,Z===$)J.selected=!0;Q.appendChild(J)}if(Z)Q.setAttribute("value",Z);Q.addEventListener("input",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.#q=!0,this.setAttribute("value",J),this.#q=!1,this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}),Q.addEventListener("change",($)=>{if($.stopPropagation(),this.#q)return;let J=this.#_($);if(!J)return;this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}),this.appendChild(Q),this.#j=Q,this.#Z="dropdown"}#G(){if(this.#Z==="segments")this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#M())});else this.#K()}#U(){if(!this.#j||this.#q)return;let Q=this.getAttribute("value")||"";this.#j.value=Q}#L(Q){if(!this.#j)return;if(this.hasAttribute(Q))this.#j.setAttribute(Q,this.getAttribute(Q)||"");else this.#j.removeAttribute(Q)}#F(){this.#$?.disconnect(),this.#$=new ResizeObserver(()=>{this.#M()}),this.#$.observe(this)}#z(Q){let Z=document.createRange();Z.selectNodeContents(Q);let $=Z.getBoundingClientRect().width,j=Q.getBoundingClientRect().width,q=getComputedStyle(Q),_=parseFloat(q.paddingLeft)||0,X=parseFloat(q.paddingRight)||0,Y=j-_-X;return $>Y+0.5}#B(){let Q=this.querySelectorAll("fig-segment");for(let Z of Q)if(this.#z(Z))return!0;return!1}#M(){if(this.#J.length<=1)return;if(this.#Z==="segments"){let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#B())this.#Q=this.clientWidth,this.#K()}else if(this.#Q>0&&this.clientWidth>=this.#Q)this.#N(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let Q=this.#j;if(Q&&Q.scrollWidth>Q.clientWidth+1||this.#B())this.#K()})})}}z("fig-options",u0);function c1(Q){let Z=Q||"";if(Z.startsWith("["))try{let J=JSON.parse(Z);return Array.isArray(J)?J:[]}catch{}let $=Z.includes(`
|
|
40
40
|
`)?`
|
|
41
|
-
`:",";return Z.split($).map((J)=>J.trim()).filter(Boolean)}function
|
|
41
|
+
`:",";return Z.split($).map((J)=>J.trim()).filter(Boolean)}function u1(Q){if(Q&&typeof Q==="object")return String(Q.value??Q.label??"");return String(Q??"")}function p1(Q){if(Q&&typeof Q==="object")return String(Q.label??Q.value??"");return String(Q??"")}class p0 extends HTMLElement{static get observedAttributes(){return["value","disabled","selected","label"]}get value(){let Q=this.getAttribute("value");if(Q!==null)return Q;return(this.textContent||"").trim()}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get disabled(){return F(this,"disabled")}set disabled(Q){if(Q)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get selected(){return F(this,"selected")}set selected(Q){if(Q)this.setAttribute("selected","");else this.removeAttribute("selected")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","option");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled")this.#Z()}#Z(){if(this.disabled)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}z("fig-select-option",p0);class d0 extends HTMLElement{#Z=null;#Q=null;#$=null;#J=this.syncOverflow.bind(this);connectedCallback(){if(!this.hasAttribute("slot"))this.setAttribute("slot","panel");this.#j(),this.#q(),this.addEventListener("scroll",this.#J,{passive:!0}),this.#$?.disconnect(),this.#$=new ResizeObserver(()=>this.syncOverflow()),this.#$.observe(this),requestAnimationFrame(()=>this.syncOverflow())}disconnectedCallback(){this.removeEventListener("scroll",this.#J),this.#$?.disconnect(),this.#$=null,this.#_()}syncOverflow(){return a(this,this,"y")}scrollToOption(Q,Z="auto"){S0(this,Q,"y",Z)}#j(){let Q=this.querySelector(":scope > fig-chooser");if(!Q)return;while(Q.firstChild)this.insertBefore(Q.firstChild,Q);Q.remove()}#q(){if(this.#Z&&this.#Q&&this.contains(this.#Z)&&this.contains(this.#Q))return;this.#_();let Q=X0({owner:"select",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>i(this,"y",-1),onEnd:()=>i(this,"y",1)});this.#Z=Q.start,this.#Q=Q.end,this.prepend(this.#Z),this.append(this.#Q)}#_(){this.#Z?.remove(),this.#Q?.remove(),this.#Z=null,this.#Q=null,this.classList.remove("overflow-start","overflow-end")}}z("fig-select-options",d0);class s0 extends HTMLElement{#Z=null;#Q=null;#$=null;#J=null;#j=null;#q=null;#_=!1;#Y=-1;#X=!1;#W=!1;#N=null;#K=!1;#G=null;#U=null;#L=!1;#F=this.#Z0.bind(this);#z=this.#j0.bind(this);#B=this.#q0.bind(this);#M=this.#e.bind(this);#D=this.#u.bind(this);static get observedAttributes(){return["value","disabled","label","options","position","offset","closedby","open"]}get value(){return this.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(Q))}get open(){return F(this,"open")}set open(Q){if(Q)this.setAttribute("open","");else this.removeAttribute("open")}connectedCallback(){if(!this.#_)this.#S();if(this.#H(),this.#C(),this.#r(),this.#t(),this.#i(),this.#m(),this.open)this.#_0()}disconnectedCallback(){this.#x(),document.removeEventListener("keydown",this.#B,!0),this.#q?.disconnect(),this.#q=null}attributeChangedCallback(Q,Z,$){if(Z===$||!this.#_)return;if(Q==="options"){this.#C(),this.#i();return}if(Q==="value"||Q==="label"){this.#i();return}if(Q==="disabled"){this.#r();return}if(Q==="open"){if($===null||$==="false")this.#G0();else this.#_0();return}if(Q==="position"||Q==="offset"||Q==="closedby")this.#t()}focus(Q){this.#Z?.focus(Q)}blur(){this.#Z?.blur()}#E(Q){return Q?.nodeType===1&&(Q.tagName==="FIG-SELECT-OPTION"||Q.tagName==="FIG-MENU-SEPARATOR"||Q.tagName==="FIG-SELECT-OPTIONS")}#H(){for(let Q of this.querySelectorAll(":scope > fig-select-options"))if(!Q.hasAttribute("slot"))Q.setAttribute("slot","panel")}#O(){let Z=(this.#j?.assignedElements({flatten:!0})??[]).find(($)=>$.tagName==="FIG-SELECT-OPTIONS");if(Z)return Z;return this.querySelector(":scope > fig-select-options")}#R(){return Boolean(this.querySelector(":scope > fig-select-option:not([data-fig-generated]), :scope > fig-select-options > fig-select-option:not([data-fig-generated])"))}#P(){let Q=this.#O();if(Q){if(!Q.hasAttribute("slot"))Q.setAttribute("slot","panel");return Q}return Q=document.createElement("fig-select-options"),Q.setAttribute("slot","panel"),Q.setAttribute("data-fig-generated",""),this.appendChild(Q),Q}#C(){if(this.#R())return;let Q=this.hasAttribute("options"),Z=Q?this.#P():this.#O();if(!Z)return;this.#L=!0;try{for(let j of Z.querySelectorAll(":scope > fig-select-option[data-fig-generated]"))j.remove();if(!Q)return;let $=c1(this.getAttribute("options")),J=Z.querySelector(":scope > .fig-overflow-end");for(let j of $){let q=document.createElement("fig-select-option");if(q.setAttribute("data-fig-generated",""),q.setAttribute("value",u1(j)),q.textContent=p1(j),J)Z.insertBefore(q,J);else Z.appendChild(q)}}finally{this.#L=!1}}#S(){this.#_=!0;let Q=this.attachShadow({mode:"open"});Q.innerHTML=`
|
|
42
42
|
<style>
|
|
43
43
|
:host {
|
|
44
44
|
display: inline-flex;
|
|
@@ -166,7 +166,7 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
|
|
|
166
166
|
</fig-tooltip>`;let _="";_=`<fig-swatch background="${this.hexOpaque}" alpha="${this.rgba.a}"${$}></fig-swatch>`,J=`<div class="input-combo">
|
|
167
167
|
${_}
|
|
168
168
|
${q}
|
|
169
|
-
</div>`}else J=`<fig-swatch background="${this.hexOpaque}" alpha="${this.rgba.a}"${$}></fig-swatch>`;if(this.innerHTML=J,this.#Q=this.querySelector("fig-swatch"),this.#$=this.querySelector("fig-fill-picker"),this.#J=this.querySelector("fig-input-text:not([type=number])"),this.#j=this.querySelector("fig-input-number"),this.#w(),this.#J){let q=this.rgbAlphaToHex(this.rgba,1);if(this.#J.value=q.slice(1).toUpperCase(),this.#Q)this.#Q.background=q}this.#H()}#R(){if(!this.#$)return;for(let[Q,Z]of Object.entries(this.#z()))this.#$.setAttribute(Q,Z);if(this.#$.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#$.removeAttribute("alpha");else this.#$.setAttribute("alpha","false");if(F(this,"disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");this.#$.anchorElement=this,this.#$.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}))}#P(){if(!o())return null;if(this.#$?.isConnected)return this.#R(),this.#$;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#F),Q.addEventListener("change",this.#U),this.appendChild(Q),this.#$=Q,this.#R(),Q}#C(){if(F(this,"disabled")||F(this,"swatch-disabled"))return!1;let Q=this.#P();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#S(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#I(Q){if(!o())return;if(F(this,"disabled")||F(this,"swatch-disabled"))return;if(this.#_=!0,this.#q=!0,this.#Y)clearTimeout(this.#Y);this.#Y=setTimeout(()=>{this.#q=!1,this.#_=!1,this.#Y=null},500),this.#S(Q)}#A(Q){if(!this.#q)return;if(this.#q=!1,this.#Y)clearTimeout(this.#Y),this.#Y=null;if(this.#S(Q),this.#_)this.#_=!1,this.#C()}#k(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!o())return;if(!this.#C())return;this.#S(Q)}#T(Q){let Z=typeof Q==="string"&&Q.trim()?Q.trim():"#D9D9D9",$=this.convertToRGBA(Z);if(!$||!Number.isFinite($.r)||!Number.isFinite($.g)||!Number.isFinite($.b)||!Number.isFinite($.a))Z="#D9D9D9",$={r:217,g:217,b:217,a:1};this.rgba=$,this.value=this.rgbAlphaToHex({r:isNaN(this.rgba.r)?0:this.rgba.r,g:isNaN(this.rgba.g)?0:this.rgba.g,b:isNaN(this.rgba.b)?0:this.rgba.b},this.rgba.a),this.hexWithAlpha=this.value.toUpperCase(),this.hexOpaque=this.hexWithAlpha.slice(0,7),this.#Z=Z.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#f(Q){Q.stopPropagation();let Z=Q.target.value.replace(/#/g,"");if(this.#T("#"+Z),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j)this.#j.setAttribute("value",this.#Z);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#x()}#y(Q){Q.stopPropagation();let Z=Number(Q.target.value)||0,J=Math.round(Z/100*255).toString(16).padStart(2,"0");if(this.#T(this.hexOpaque+J),this.#Q)this.#Q.setAttribute("alpha",this.rgba.a);if(this.#$)this.#$.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));this.#x()}#g(Q){Q.stopPropagation(),this.#u()}focus(){if(this.#J){this.#J.focus();return}this.#Q?.focus()}#h(){return this.getAttribute("aria-label")||"Color"}#w(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#m)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let Q=this.getAttribute("aria-describedby"),Z=this.getAttribute("aria-invalid"),$=this.getAttribute("aria-required"),J=this.getAttribute("aria-labelledby"),j=this.#h();if(this.#J){if(this.#J.setAttribute("aria-label",`${j} hex color`),Q)this.#J.setAttribute("aria-describedby",Q);else this.#J.removeAttribute("aria-describedby");if(Z)this.#J.setAttribute("aria-invalid",Z);else this.#J.removeAttribute("aria-invalid");if($)this.#J.setAttribute("aria-required",$);else this.#J.removeAttribute("aria-required")}if(this.#j){if(this.#j.setAttribute("aria-label",`${j} opacity`),Q)this.#j.setAttribute("aria-describedby",Q);else this.#j.removeAttribute("aria-describedby");if(Z)this.#j.setAttribute("aria-invalid",Z);else this.#j.removeAttribute("aria-invalid");if($)this.#j.setAttribute("aria-required",$);else this.#j.removeAttribute("aria-required")}if(!this.#J){let q=this.#Q?.querySelector('input[type="color"]');if(!q)return;if(J)q.setAttribute("aria-labelledby",J),q.removeAttribute("aria-label");else q.setAttribute("aria-label",j),q.removeAttribute("aria-labelledby");if(Q)q.setAttribute("aria-describedby",Q);else q.removeAttribute("aria-describedby")}}#V(Q){if(Q.stopPropagation(),this.#T(Q.target.value),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#x()}#b(Q){Q.stopPropagation();let Z=Q.detail;if(Z&&Z.color){let $=Z.color;if(Z.alpha!==void 0){let J=Math.round(Z.alpha*255).toString(16).padStart(2,"0");$=Z.color+J}if(this.#T($),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j&&Z.alpha!==void 0)this.#j.setAttribute("value",Math.round(Z.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#x()}}#x(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#u(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}static get observedAttributes(){return["value","style","mode","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(Q){this.setAttribute("mode",Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":if(this.#T($),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);if(this.#$)this.#$.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));if(this.#j)this.#j.setAttribute("value",this.#Z);break;case"mode":this.#R();break;case"alpha":case"text":if(this.isConnected)this.#O();break;case"disabled":this.#v();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#w();break}}get#m(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#v(){let Q=this.#m;for(let Z of[this.#Q,this.#J,this.#j]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}if(this.#w(),this.#$)this.#R()}rgbAlphaToHex({r:Q,g:Z,b:$},J=1){Q=Math.max(0,Math.min(255,Math.round(Q))),Z=Math.max(0,Math.min(255,Math.round(Z))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(1,J));let j=Q.toString(16).padStart(2,"0"),q=Z.toString(16).padStart(2,"0"),_=$.toString(16).padStart(2,"0");if(J===1)return`#${j}${q}${_}`.toUpperCase();let Y=Math.round(J*255).toString(16).padStart(2,"0");return`#${j}${q}${_}${Y}`.toUpperCase()}convertToRGBA(Q){if(typeof Q!=="string")return null;let Z,$,J,j=1;if(Q.startsWith("#")){let q=Q.slice(1);if(q.length===8)j=parseInt(q.slice(6),16)/255,q=q.slice(0,6);Z=parseInt(q.slice(0,2),16),$=parseInt(q.slice(2,4),16),J=parseInt(q.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let q=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q)Z=parseInt(q[1]),$=parseInt(q[2]),J=parseInt(q[3]),j=q[4]?parseFloat(q[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let q=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q){let _=parseInt(q[1])/360,X=parseInt(q[2])/100,Y=parseInt(q[3])/100;if(j=q[4]?parseFloat(q[4]):1,X===0)Z=$=J=Y;else{let K=(W,O,B)=>{if(B<0)B+=1;if(B>1)B-=1;if(B<0.16666666666666666)return W+(O-W)*6*B;if(B<0.5)return O;if(B<0.6666666666666666)return W+(O-W)*(0.6666666666666666-B)*6;return W},G=Y<0.5?Y*(1+X):Y+X-Y*X,N=2*Y-G;Z=K(N,G,_+0.3333333333333333),$=K(N,G,_),J=K(N,G,_-0.3333333333333333)}Z=Math.round(Z*255),$=Math.round($*255),J=Math.round(J*255)}}else return null;return{r:Z,g:$,b:J,a:j}}}z("fig-input-color",a0);var s1=["srgb","srgb-linear","display-p3","oklab","oklch","hsl"],i1=["shorter","longer","increasing","decreasing"],t0=new Set(["oklch","hsl"]);function Z0(Q){let Z={...Q??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase();if(!s1.includes($))$="srgb";Z.interpolationSpace=$;let J=String(Z.hueInterpolation??"shorter").toLowerCase();return Z.hueInterpolation=i1.includes(J)?J:"shorter",Z}function n0(Q){let Z=Z0(Q),$={...Z,interpolationSpace:Z.interpolationSpace};if(t0.has(Z.interpolationSpace))$.hueInterpolation=Z.hueInterpolation;else delete $.hueInterpolation;return $}function e0(Q){let Z=Z0(Q);if(Z.interpolationSpace==="srgb")return"";if(t0.has(Z.interpolationSpace))return`in ${Z.interpolationSpace} ${Z.hueInterpolation} hue`;return`in ${Z.interpolationSpace}`}function r(Q){let Z=Q.replace(/^#/,"");return{r:parseInt(Z.substring(0,2),16),g:parseInt(Z.substring(2,4),16),b:parseInt(Z.substring(4,6),16)}}function p(Q){let Z=Q/255;return Z<=0.04045?Z/12.92:Math.pow((Z+0.055)/1.055,2.4)}function l(Q){let Z=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Z))*255)}function e(Q,Z,$){let J=p(Q),j=p(Z),q=p($),_=Math.cbrt(0.4122214708*J+0.5363325363*j+0.0514459929*q),X=Math.cbrt(0.2119034982*J+0.6806995451*j+0.1073969566*q),Y=Math.cbrt(0.0883024619*J+0.2817188376*j+0.6299787005*q);return{l:0.2104542553*_+0.793617785*X-0.0040720468*Y,a:1.9779984951*_-2.428592205*X+0.4505937099*Y,b:0.0259040371*_+0.7827717662*X-0.808675766*Y}}function C0(Q,Z,$){let J=Q+0.3963377774*Z+0.2158037573*$,j=Q-0.1055613458*Z-0.0638541728*$,q=Q-0.0894841775*Z-1.291485548*$,_=J*J*J,X=j*j*j,Y=q*q*q;return{r:l(4.0767416621*_-3.3077115913*X+0.2309699292*Y),g:l(-1.2684380046*_+2.6097574011*X-0.3413193965*Y),b:l(-0.0041960863*_-0.7034186147*X+1.707614701*Y)}}function L0(Q,Z,$){return{l:Q,c:Math.sqrt(Z*Z+$*$),h:Math.atan2($,Z)*180/Math.PI}}function r1(Q,Z,$){let J=$*Math.PI/180;return{l:Q,a:Z*Math.cos(J),b:Z*Math.sin(J)}}function k0(Q,Z,$,J){let j=(Q%360+360)%360,_=(Z%360+360)%360-j;switch(J){case"longer":if(_>0&&_<180)_-=360;else if(_<0&&_>-180)_+=360;else if(_===0)_=0;break;case"increasing":if(_<0)_+=360;break;case"decreasing":if(_>0)_-=360;break;default:if(_>180)_-=360;else if(_<-180)_+=360;break}return((j+_*$)%360+360)%360}function o1(Q,Z,$,J){let j=[...Q].sort((R,A)=>R.position-A.position),q=Z*100;if(j.length===0)return"#888888";if(q<=j[0].position)return j[0].color;if(q>=j[j.length-1].position)return j[j.length-1].color;let _=0;while(_<j.length-1&&j[_+1].position<q)_++;let X=j[_],Y=j[_+1],K=Y.position-X.position,G=K>0?(q-X.position)/K:0,N=r(X.color),W=r(Y.color),O,B,L,T=$||"oklab";if(T==="srgb-linear"){let R=p(N.r),A=p(N.g),M=p(N.b),E=p(W.r),k=p(W.g),S=p(W.b);O=l(R+(E-R)*G),B=l(A+(k-A)*G),L=l(M+(S-M)*G)}else if(T==="oklch"){let R=e(N.r,N.g,N.b),A=e(W.r,W.g,W.b),M=L0(R.l,R.a,R.b),E=L0(A.l,A.a,A.b),k=M.l+(E.l-M.l)*G,S=M.c+(E.c-M.c)*G,x=k0(M.h,E.h,G,J||"shorter"),y=r1(k,S,x),m=C0(y.l,y.a,y.b);O=m.r,B=m.g,L=m.b}else if(T==="hsl"){let R=B0(N.r,N.g,N.b),A=B0(W.r,W.g,W.b),M=k0(R.h,A.h,G,J||"shorter"),E=R.s+(A.s-R.s)*G,k=R.l+(A.l-R.l)*G,S=l1(M,E,k);O=S[0],B=S[1],L=S[2]}else if(T==="srgb")O=Math.round(N.r+(W.r-N.r)*G),B=Math.round(N.g+(W.g-N.g)*G),L=Math.round(N.b+(W.b-N.b)*G);else{let R=e(N.r,N.g,N.b),A=e(W.r,W.g,W.b),M=R.l+(A.l-R.l)*G,E=R.a+(A.a-R.a)*G,k=R.b+(A.b-R.b)*G,S=C0(M,E,k);O=S.r,B=S.g,L=S.b}return`#${O.toString(16).padStart(2,"0")}${B.toString(16).padStart(2,"0")}${L.toString(16).padStart(2,"0")}`.toUpperCase()}function B0(Q,Z,$){let J=Q/255,j=Z/255,q=$/255,_=Math.max(J,j,q),X=Math.min(J,j,q),Y=(_+X)/2;if(_===X)return{h:0,s:0,l:Y*100};let K=_-X,G=Y>0.5?K/(2-_-X):K/(_+X),N;switch(_){case J:N=((j-q)/K+(j<q?6:0))/6;break;case j:N=((q-J)/K+2)/6;break;default:N=((J-j)/K+4)/6;break}return{h:N*360,s:G*100,l:Y*100}}function l1(Q,Z,$){Z/=100,$/=100;let J=(1-Math.abs(2*$-1))*Z,j=J*(1-Math.abs(Q/60%2-1)),q=$-J/2,_,X,Y;if(Q<60)_=J,X=j,Y=0;else if(Q<120)_=j,X=J,Y=0;else if(Q<180)_=0,X=J,Y=j;else if(Q<240)_=0,X=j,Y=J;else if(Q<300)_=j,X=0,Y=J;else _=J,X=0,Y=j;return[Math.round((_+q)*255),Math.round((X+q)*255),Math.round((Y+q)*255)]}class Q1 extends HTMLElement{#Z="solid";#Q;#$;#J;#j={color:"#D9D9D9",alpha:1};#q={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",opacity:1,stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#_={url:null,scaleMode:"fill",scale:50,opacity:1};#Y={url:null,scaleMode:"fill",opacity:1};#X={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","alpha","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#W(),this.#z()}disconnectedCallback(){this.#Q=null,this.#$=null,this.#J=null}#W(){let Q=this.getAttribute("value");if(!Q)return;try{let Z=JSON.parse(Q);if(Z.type)this.#Z=Z.type;switch(this.#Z){case"solid":if(Z.color)this.#j.color=Z.color;if(Z.alpha!==void 0)this.#j.alpha=Z.alpha;if(Z.opacity!==void 0)this.#j.alpha=Z.opacity/100;break;case"gradient":if(Z.gradient)this.#q=Z0({...this.#q,...Z.gradient}),this.#q.opacity=this.#G(Z.gradient.opacity??Z.opacity??Z.alpha,this.#q.opacity??1);else if(Z.opacity!==void 0||Z.alpha!==void 0)this.#q.opacity=this.#G(Z.opacity??Z.alpha,this.#q.opacity??1);break;case"image":if(Z.image)this.#_={...this.#_,...Z.image};break;case"video":if(Z.video)this.#Y={...this.#Y,...Z.video};break;case"webcam":if(Z.webcam)this.#X={...this.#X,...Z.webcam};if(Z.opacity!==void 0)this.#X.opacity=Z.opacity;break}}catch(Z){if(Q.startsWith("#")){if(this.#Z="solid",this.#j.color=Q.slice(0,7),Q.length>7){let $=Q.slice(7,9);this.#j.alpha=parseInt($,16)/255}}}}#N(){let Q={},Z=this.getAttribute("mode");if(Z)Q.mode=Z;let $=this.getAttribute("alpha");if($)Q.alpha=$;for(let{name:J,value:j}of this.attributes)if(J.startsWith("picker-")&&J!=="picker-anchor"&&J!=="picker-experimental")Q[J.slice(7)]=j;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([J,j])=>`${J}="${v(j)}"`).join(" ")}#K(){switch(this.#Z){case"solid":return this.#j.color;case"gradient":{let Z=[...this.#q.stops].sort((J,j)=>J.position-j.position).map((J)=>{let j=(J.opacity??100)/100;if(j>=1)return`${J.color} ${J.position}%`;let{r:q,g:_,b:X}=r(J.color);return`rgba(${q}, ${_}, ${X}, ${j}) ${J.position}%`}).join(", "),$=e0(this.#q);return`linear-gradient(${this.#q.angle}deg${$?` ${$}`:""}, ${Z})`}case"image":return this.#_.url?`url(${this.#_.url})`:"#D9D9D9";default:return"#D9D9D9"}}#G(Q,Z=1){if(Q===void 0||Q===null||Q==="")return Z;let $=Number(Q);if(!Number.isFinite($))return Z;if($>1)return Math.max(0,Math.min(1,$/100));return Math.max(0,Math.min(1,$))}#U(){switch(this.#Z){case"solid":return this.#j.alpha;case"gradient":return this.#q.opacity??1;case"image":return this.#_.opacity??1;case"video":return this.#Y.opacity??1;case"webcam":return this.#X.opacity??1;default:return 1}}#L(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.setAttribute("aria-disabled",Q?"true":"false");for(let Z of[this.#Q,this.#$,this.#J]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}#F(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#L();let Q=this.getAttribute("aria-label")||"Fill",Z=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),j=(q,_)=>{if(!q)return;if(q.setAttribute("aria-label",_),Z)q.setAttribute("aria-describedby",Z);else q.removeAttribute("aria-describedby");if($)q.setAttribute("aria-invalid",$);else q.removeAttribute("aria-invalid");if(J)q.setAttribute("aria-required",J);else q.removeAttribute("aria-required")};j(this.#Q,`${Q} picker`),j(this.#J,`${Q} hex color`),j(this.#$,`${Q} opacity`)}#z(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=JSON.stringify(this.value),$=this.getAttribute("alpha")!=="false",J=(_)=>$?`<fig-tooltip text="Opacity">
|
|
169
|
+
</div>`}else J=`<fig-swatch background="${this.hexOpaque}" alpha="${this.rgba.a}"${$}></fig-swatch>`;if(this.innerHTML=J,this.#Q=this.querySelector("fig-swatch"),this.#$=this.querySelector("fig-fill-picker"),this.#J=this.querySelector("fig-input-text:not([type=number])"),this.#j=this.querySelector("fig-input-number"),this.#w(),this.#J){let q=this.rgbAlphaToHex(this.rgba,1);if(this.#J.value=q.slice(1).toUpperCase(),this.#Q)this.#Q.background=q}this.#H()}#R(){if(!this.#$)return;for(let[Q,Z]of Object.entries(this.#z()))this.#$.setAttribute(Q,Z);if(this.#$.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#$.removeAttribute("alpha");else this.#$.setAttribute("alpha","false");if(F(this,"disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");this.#$.anchorElement=this,this.#$.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}))}#P(){if(!o())return null;if(this.#$?.isConnected)return this.#R(),this.#$;let Q=document.createElement("fig-fill-picker");return Q.innerHTML="<span hidden></span>",Q.addEventListener("input",this.#F),Q.addEventListener("change",this.#U),this.appendChild(Q),this.#$=Q,this.#R(),Q}#C(){if(F(this,"disabled")||F(this,"swatch-disabled"))return!1;let Q=this.#P();if(!Q)return!1;return requestAnimationFrame(()=>Q.open?.()),!0}#S(Q){Q.preventDefault(),Q.stopPropagation(),Q.stopImmediatePropagation?.()}#I(Q){if(!o())return;if(F(this,"disabled")||F(this,"swatch-disabled"))return;if(this.#_=!0,this.#q=!0,this.#Y)clearTimeout(this.#Y);this.#Y=setTimeout(()=>{this.#q=!1,this.#_=!1,this.#Y=null},500),this.#S(Q)}#A(Q){if(!this.#q)return;if(this.#q=!1,this.#Y)clearTimeout(this.#Y),this.#Y=null;if(this.#S(Q),this.#_)this.#_=!1,this.#C()}#k(Q){if(Q.key!=="Enter"&&Q.key!==" ")return;if(!o())return;if(!this.#C())return;this.#S(Q)}#T(Q){let Z=typeof Q==="string"&&Q.trim()?Q.trim():"#D9D9D9",$=this.convertToRGBA(Z);if(!$||!Number.isFinite($.r)||!Number.isFinite($.g)||!Number.isFinite($.b)||!Number.isFinite($.a))Z="#D9D9D9",$={r:217,g:217,b:217,a:1};this.rgba=$,this.value=this.rgbAlphaToHex({r:isNaN(this.rgba.r)?0:this.rgba.r,g:isNaN(this.rgba.g)?0:this.rgba.g,b:isNaN(this.rgba.b)?0:this.rgba.b},this.rgba.a),this.hexWithAlpha=this.value.toUpperCase(),this.hexOpaque=this.hexWithAlpha.slice(0,7),this.#Z=Z.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#f(Q){Q.stopPropagation();let Z=Q.target.value.replace(/#/g,"");if(this.#T("#"+Z),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j)this.#j.setAttribute("value",this.#Z);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#x()}#y(Q){Q.stopPropagation();let Z=Number(Q.target.value)||0,J=Math.round(Z/100*255).toString(16).padStart(2,"0");if(this.#T(this.hexOpaque+J),this.#Q)this.#Q.setAttribute("alpha",this.rgba.a);if(this.#$)this.#$.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));this.#x()}#g(Q){Q.stopPropagation(),this.#u()}focus(){if(this.#J){this.#J.focus();return}this.#Q?.focus()}#h(){return this.getAttribute("aria-label")||"Color"}#w(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#m)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let Q=this.getAttribute("aria-describedby"),Z=this.getAttribute("aria-invalid"),$=this.getAttribute("aria-required"),J=this.getAttribute("aria-labelledby"),j=this.#h();if(this.#J){if(this.#J.setAttribute("aria-label",`${j} hex color`),Q)this.#J.setAttribute("aria-describedby",Q);else this.#J.removeAttribute("aria-describedby");if(Z)this.#J.setAttribute("aria-invalid",Z);else this.#J.removeAttribute("aria-invalid");if($)this.#J.setAttribute("aria-required",$);else this.#J.removeAttribute("aria-required")}if(this.#j){if(this.#j.setAttribute("aria-label",`${j} opacity`),Q)this.#j.setAttribute("aria-describedby",Q);else this.#j.removeAttribute("aria-describedby");if(Z)this.#j.setAttribute("aria-invalid",Z);else this.#j.removeAttribute("aria-invalid");if($)this.#j.setAttribute("aria-required",$);else this.#j.removeAttribute("aria-required")}if(!this.#J){let q=this.#Q?.querySelector('input[type="color"]');if(!q)return;if(J)q.setAttribute("aria-labelledby",J),q.removeAttribute("aria-label");else q.setAttribute("aria-label",j),q.removeAttribute("aria-labelledby");if(Q)q.setAttribute("aria-describedby",Q);else q.removeAttribute("aria-describedby")}}#V(Q){if(Q.stopPropagation(),this.#T(Q.target.value),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#x()}#b(Q){Q.stopPropagation();let Z=Q.detail;if(Z&&Z.color){let $=Z.color;if(Z.alpha!==void 0){let J=Math.round(Z.alpha*255).toString(16).padStart(2,"0");$=Z.color+J}if(this.#T($),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#j&&Z.alpha!==void 0)this.#j.setAttribute("value",Math.round(Z.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#x()}}#x(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}#u(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,hex:this.hex,rgba:this.rgba}}))}static get observedAttributes(){return["value","style","mode","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(Q){this.setAttribute("mode",Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":if(this.#T($),this.#J)this.#J.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);if(this.#$)this.#$.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Z}));if(this.#j)this.#j.setAttribute("value",this.#Z);break;case"mode":this.#R();break;case"alpha":case"text":if(this.isConnected)this.#O();break;case"disabled":this.#v();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#w();break}}get#m(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#v(){let Q=this.#m;for(let Z of[this.#Q,this.#J,this.#j]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}if(this.#w(),this.#$)this.#R()}rgbAlphaToHex({r:Q,g:Z,b:$},J=1){Q=Math.max(0,Math.min(255,Math.round(Q))),Z=Math.max(0,Math.min(255,Math.round(Z))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(1,J));let j=Q.toString(16).padStart(2,"0"),q=Z.toString(16).padStart(2,"0"),_=$.toString(16).padStart(2,"0");if(J===1)return`#${j}${q}${_}`.toUpperCase();let Y=Math.round(J*255).toString(16).padStart(2,"0");return`#${j}${q}${_}${Y}`.toUpperCase()}convertToRGBA(Q){if(typeof Q!=="string")return null;let Z,$,J,j=1;if(Q.startsWith("#")){let q=Q.slice(1);if(q.length===8)j=parseInt(q.slice(6),16)/255,q=q.slice(0,6);Z=parseInt(q.slice(0,2),16),$=parseInt(q.slice(2,4),16),J=parseInt(q.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let q=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q)Z=parseInt(q[1]),$=parseInt(q[2]),J=parseInt(q[3]),j=q[4]?parseFloat(q[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let q=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(q){let _=parseInt(q[1])/360,X=parseInt(q[2])/100,Y=parseInt(q[3])/100;if(j=q[4]?parseFloat(q[4]):1,X===0)Z=$=J=Y;else{let K=(W,O,B)=>{if(B<0)B+=1;if(B>1)B-=1;if(B<0.16666666666666666)return W+(O-W)*6*B;if(B<0.5)return O;if(B<0.6666666666666666)return W+(O-W)*(0.6666666666666666-B)*6;return W},G=Y<0.5?Y*(1+X):Y+X-Y*X,N=2*Y-G;Z=K(N,G,_+0.3333333333333333),$=K(N,G,_),J=K(N,G,_-0.3333333333333333)}Z=Math.round(Z*255),$=Math.round($*255),J=Math.round(J*255)}}else return null;return{r:Z,g:$,b:J,a:j}}}z("fig-input-color",a0);var d1=["srgb","srgb-linear","display-p3","oklab","oklch","hsl"],s1=["shorter","longer","increasing","decreasing"],t0=new Set(["oklch","hsl"]);function Z0(Q){let Z={...Q??{}},$=String(Z.interpolationSpace??"srgb").toLowerCase();if(!d1.includes($))$="srgb";Z.interpolationSpace=$;let J=String(Z.hueInterpolation??"shorter").toLowerCase();return Z.hueInterpolation=s1.includes(J)?J:"shorter",Z}function n0(Q){let Z=Z0(Q),$={...Z,interpolationSpace:Z.interpolationSpace};if(t0.has(Z.interpolationSpace))$.hueInterpolation=Z.hueInterpolation;else delete $.hueInterpolation;return $}function e0(Q){let Z=Z0(Q);if(Z.interpolationSpace==="srgb")return"";if(t0.has(Z.interpolationSpace))return`in ${Z.interpolationSpace} ${Z.hueInterpolation} hue`;return`in ${Z.interpolationSpace}`}function r(Q){let Z=Q.replace(/^#/,"");return{r:parseInt(Z.substring(0,2),16),g:parseInt(Z.substring(2,4),16),b:parseInt(Z.substring(4,6),16)}}function p(Q){let Z=Q/255;return Z<=0.04045?Z/12.92:Math.pow((Z+0.055)/1.055,2.4)}function l(Q){let Z=Q<=0.0031308?12.92*Q:1.055*Math.pow(Q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Z))*255)}function e(Q,Z,$){let J=p(Q),j=p(Z),q=p($),_=Math.cbrt(0.4122214708*J+0.5363325363*j+0.0514459929*q),X=Math.cbrt(0.2119034982*J+0.6806995451*j+0.1073969566*q),Y=Math.cbrt(0.0883024619*J+0.2817188376*j+0.6299787005*q);return{l:0.2104542553*_+0.793617785*X-0.0040720468*Y,a:1.9779984951*_-2.428592205*X+0.4505937099*Y,b:0.0259040371*_+0.7827717662*X-0.808675766*Y}}function C0(Q,Z,$){let J=Q+0.3963377774*Z+0.2158037573*$,j=Q-0.1055613458*Z-0.0638541728*$,q=Q-0.0894841775*Z-1.291485548*$,_=J*J*J,X=j*j*j,Y=q*q*q;return{r:l(4.0767416621*_-3.3077115913*X+0.2309699292*Y),g:l(-1.2684380046*_+2.6097574011*X-0.3413193965*Y),b:l(-0.0041960863*_-0.7034186147*X+1.707614701*Y)}}function L0(Q,Z,$){return{l:Q,c:Math.sqrt(Z*Z+$*$),h:Math.atan2($,Z)*180/Math.PI}}function i1(Q,Z,$){let J=$*Math.PI/180;return{l:Q,a:Z*Math.cos(J),b:Z*Math.sin(J)}}function k0(Q,Z,$,J){let j=(Q%360+360)%360,_=(Z%360+360)%360-j;switch(J){case"longer":if(_>0&&_<180)_-=360;else if(_<0&&_>-180)_+=360;else if(_===0)_=0;break;case"increasing":if(_<0)_+=360;break;case"decreasing":if(_>0)_-=360;break;default:if(_>180)_-=360;else if(_<-180)_+=360;break}return((j+_*$)%360+360)%360}function r1(Q,Z,$,J){let j=[...Q].sort((R,A)=>R.position-A.position),q=Z*100;if(j.length===0)return"#888888";if(q<=j[0].position)return j[0].color;if(q>=j[j.length-1].position)return j[j.length-1].color;let _=0;while(_<j.length-1&&j[_+1].position<q)_++;let X=j[_],Y=j[_+1],K=Y.position-X.position,G=K>0?(q-X.position)/K:0,N=r(X.color),W=r(Y.color),O,B,L,T=$||"oklab";if(T==="srgb-linear"){let R=p(N.r),A=p(N.g),M=p(N.b),E=p(W.r),k=p(W.g),S=p(W.b);O=l(R+(E-R)*G),B=l(A+(k-A)*G),L=l(M+(S-M)*G)}else if(T==="oklch"){let R=e(N.r,N.g,N.b),A=e(W.r,W.g,W.b),M=L0(R.l,R.a,R.b),E=L0(A.l,A.a,A.b),k=M.l+(E.l-M.l)*G,S=M.c+(E.c-M.c)*G,x=k0(M.h,E.h,G,J||"shorter"),y=i1(k,S,x),m=C0(y.l,y.a,y.b);O=m.r,B=m.g,L=m.b}else if(T==="hsl"){let R=B0(N.r,N.g,N.b),A=B0(W.r,W.g,W.b),M=k0(R.h,A.h,G,J||"shorter"),E=R.s+(A.s-R.s)*G,k=R.l+(A.l-R.l)*G,S=o1(M,E,k);O=S[0],B=S[1],L=S[2]}else if(T==="srgb")O=Math.round(N.r+(W.r-N.r)*G),B=Math.round(N.g+(W.g-N.g)*G),L=Math.round(N.b+(W.b-N.b)*G);else{let R=e(N.r,N.g,N.b),A=e(W.r,W.g,W.b),M=R.l+(A.l-R.l)*G,E=R.a+(A.a-R.a)*G,k=R.b+(A.b-R.b)*G,S=C0(M,E,k);O=S.r,B=S.g,L=S.b}return`#${O.toString(16).padStart(2,"0")}${B.toString(16).padStart(2,"0")}${L.toString(16).padStart(2,"0")}`.toUpperCase()}function B0(Q,Z,$){let J=Q/255,j=Z/255,q=$/255,_=Math.max(J,j,q),X=Math.min(J,j,q),Y=(_+X)/2;if(_===X)return{h:0,s:0,l:Y*100};let K=_-X,G=Y>0.5?K/(2-_-X):K/(_+X),N;switch(_){case J:N=((j-q)/K+(j<q?6:0))/6;break;case j:N=((q-J)/K+2)/6;break;default:N=((J-j)/K+4)/6;break}return{h:N*360,s:G*100,l:Y*100}}function o1(Q,Z,$){Z/=100,$/=100;let J=(1-Math.abs(2*$-1))*Z,j=J*(1-Math.abs(Q/60%2-1)),q=$-J/2,_,X,Y;if(Q<60)_=J,X=j,Y=0;else if(Q<120)_=j,X=J,Y=0;else if(Q<180)_=0,X=J,Y=j;else if(Q<240)_=0,X=j,Y=J;else if(Q<300)_=j,X=0,Y=J;else _=J,X=0,Y=j;return[Math.round((_+q)*255),Math.round((X+q)*255),Math.round((Y+q)*255)]}class Q1 extends HTMLElement{#Z="solid";#Q;#$;#J;#j={color:"#D9D9D9",alpha:1};#q={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",opacity:1,stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#_={url:null,scaleMode:"fill",scale:50,opacity:1};#Y={url:null,scaleMode:"fill",opacity:1};#X={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","alpha","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#W(),this.#z()}disconnectedCallback(){this.#Q=null,this.#$=null,this.#J=null}#W(){let Q=this.getAttribute("value");if(!Q)return;try{let Z=JSON.parse(Q);if(Z.type)this.#Z=Z.type;switch(this.#Z){case"solid":if(Z.color)this.#j.color=Z.color;if(Z.alpha!==void 0)this.#j.alpha=Z.alpha;if(Z.opacity!==void 0)this.#j.alpha=Z.opacity/100;break;case"gradient":if(Z.gradient)this.#q=Z0({...this.#q,...Z.gradient}),this.#q.opacity=this.#G(Z.gradient.opacity??Z.opacity??Z.alpha,this.#q.opacity??1);else if(Z.opacity!==void 0||Z.alpha!==void 0)this.#q.opacity=this.#G(Z.opacity??Z.alpha,this.#q.opacity??1);break;case"image":if(Z.image)this.#_={...this.#_,...Z.image};break;case"video":if(Z.video)this.#Y={...this.#Y,...Z.video};break;case"webcam":if(Z.webcam)this.#X={...this.#X,...Z.webcam};if(Z.opacity!==void 0)this.#X.opacity=Z.opacity;break}}catch(Z){if(Q.startsWith("#")){if(this.#Z="solid",this.#j.color=Q.slice(0,7),Q.length>7){let $=Q.slice(7,9);this.#j.alpha=parseInt($,16)/255}}}}#N(){let Q={},Z=this.getAttribute("mode");if(Z)Q.mode=Z;let $=this.getAttribute("alpha");if($)Q.alpha=$;for(let{name:J,value:j}of this.attributes)if(J.startsWith("picker-")&&J!=="picker-anchor"&&J!=="picker-experimental")Q[J.slice(7)]=j;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([J,j])=>`${J}="${v(j)}"`).join(" ")}#K(){switch(this.#Z){case"solid":return this.#j.color;case"gradient":{let Z=[...this.#q.stops].sort((J,j)=>J.position-j.position).map((J)=>{let j=(J.opacity??100)/100;if(j>=1)return`${J.color} ${J.position}%`;let{r:q,g:_,b:X}=r(J.color);return`rgba(${q}, ${_}, ${X}, ${j}) ${J.position}%`}).join(", "),$=e0(this.#q);return`linear-gradient(${this.#q.angle}deg${$?` ${$}`:""}, ${Z})`}case"image":return this.#_.url?`url(${this.#_.url})`:"#D9D9D9";default:return"#D9D9D9"}}#G(Q,Z=1){if(Q===void 0||Q===null||Q==="")return Z;let $=Number(Q);if(!Number.isFinite($))return Z;if($>1)return Math.max(0,Math.min(1,$/100));return Math.max(0,Math.min(1,$))}#U(){switch(this.#Z){case"solid":return this.#j.alpha;case"gradient":return this.#q.opacity??1;case"image":return this.#_.opacity??1;case"video":return this.#Y.opacity??1;case"webcam":return this.#X.opacity??1;default:return 1}}#L(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.setAttribute("aria-disabled",Q?"true":"false");for(let Z of[this.#Q,this.#$,this.#J]){if(!Z)continue;if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}#F(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#L();let Q=this.getAttribute("aria-label")||"Fill",Z=this.getAttribute("aria-describedby"),$=this.getAttribute("aria-invalid"),J=this.getAttribute("aria-required"),j=(q,_)=>{if(!q)return;if(q.setAttribute("aria-label",_),Z)q.setAttribute("aria-describedby",Z);else q.removeAttribute("aria-describedby");if($)q.setAttribute("aria-invalid",$);else q.removeAttribute("aria-invalid");if(J)q.setAttribute("aria-required",J);else q.removeAttribute("aria-required")};j(this.#Q,`${Q} picker`),j(this.#J,`${Q} hex color`),j(this.#$,`${Q} opacity`)}#z(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=JSON.stringify(this.value),$=this.getAttribute("alpha")!=="false",J=(_)=>$?`<fig-tooltip text="Opacity">
|
|
170
170
|
<fig-input-number
|
|
171
171
|
class="fig-input-fill-opacity"
|
|
172
172
|
placeholder="##"
|
|
@@ -269,7 +269,7 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
|
|
|
269
269
|
<fig-swatch background="${this.#z()}"${this.#M()}${Q?" disabled":""}></fig-swatch>
|
|
270
270
|
</fig-fill-picker>`,this.#Z=this.querySelector("fig-swatch"),this.#Q=null,this.#P(),this.#K();return}if(this.innerHTML=`
|
|
271
271
|
<fig-swatch background="${this.#z()}"${this.#M()}${Q?" disabled":""}></fig-swatch>
|
|
272
|
-
${Z==="true"||Z==="picker"?`<div class="fig-input-gradient-track">${this.#E()}</div>`:""}`,this.#Z=this.querySelector("fig-swatch"),this.#Q=this.querySelector(".fig-input-gradient-track"),Z==="true"||Z==="picker")this.#S(),this.#d();this.#K()}#P(){let Q=this.querySelector("fig-fill-picker");if(!Q)return;Q.anchorElement=this;let Z=($)=>{$.stopPropagation();let J=$.detail;if(!J?.gradient)return;this.#_=this.#G({...this.#_,...J.gradient}),this.#v()};Q.addEventListener("input",($)=>{Z($),this.#p()}),Q.addEventListener("change",($)=>{Z($),this.#s()})}#C(Q){return o1(this.#_.stops,Q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#S(){if(!this.#Q||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#W==="tip")Q.setAttribute("tip","add");Q.style.position="absolute",Q.style.top="50%",Q.style.transform="translate(-50%, -50%)",Q.style.pointerEvents="none",Q.style.opacity="0",Q.style.transition="opacity 0.15s",this.#Q.appendChild(Q),this.#H=Q,this.addEventListener("pointerenter",this.#k),this.addEventListener("pointermove",this.#f),this.addEventListener("pointerleave",this.#T),this.addEventListener("click",this.#h),this.addEventListener("dblclick",this.#g)}#I(){if(!this.#H)return;this.#H.style.opacity="1"}#A(){if(!this.#H)return;this.#H.style.opacity="0"}#k=()=>{if(this.#$)return;this.#I()};#T=()=>{this.#A()};#f=(Q)=>{if(this.#$){this.#A();return}if(!this.#H||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#A();return}let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width));this.#H.style.left=`${$*100}%`;let J=this.#C($);this.#H.setAttribute("color",J),this.#I()};#y(){let Q=this.#_.stops.length;if(Q<2)return;for(let Z=0;Z<Q;Z++)this.#_.stops[Z].position=Math.round(Z/(Q-1)*100);this.#b(),this.#v(),this.#p(),this.#s()}#g=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#y(),this.#Q.querySelectorAll("fig-handle[selected]").forEach((Z)=>{Z.removeAttribute("selected")})};#h=(Q)=>{if(!this.#Q)return;if(this.#$)return;if(this.#O){this.#O=!1;return}if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(Q.shiftKey){let _=Q.target.closest("fig-handle"),X=parseInt(_?.dataset.stopIndex,10);if(this.#y(),!isNaN(X))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(parseInt(Y.dataset.stopIndex,10)===X)Y.select();else Y.deselect()});Q.stopPropagation()}return}let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#C($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((_,X)=>_.position-X.position);let q=this.#_.stops.findIndex((_)=>_.position===J&&_.color===j);this.#b(),this.#v(),this.#p(),this.#s(),requestAnimationFrame(()=>{let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)X.click()})};#w(){if(this.#q=null,!this.isConnected)return;if(!this.#Q)return;let Q=this.#_.stops;this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z,$)=>{if($>=Q.length)return;Z.removeAttribute("value"),Z.setAttribute("value",`${Q[$].position}% 50%`)})}refreshLayout(){this.#w()}#V(){if(this.#q!==null)return;this.#q=requestAnimationFrame(()=>this.#w())}#b(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops;if(Q.length!==Z.length){let $=this.#H;if(this.#Q.innerHTML=this.#E(),$)this.#Q.appendChild($);this.#x(),this.#u(),this.#V();return}for(let $=0;$<Z.length;$++){let J=Q[$],j=Z[$];if(J.dataset.stopIndex=$,J.setAttribute("value",`${j.position}% 50%`),J.setAttribute("color",this.#B(j)),this.#W==="tip")J.setAttribute("tip","color");else J.removeAttribute("tip");let q=J.closest("fig-tooltip");if(q)q.setAttribute("text",`${Math.round(j.position)}%`)}this.#x()}#x(){if(!this.#Q)return;let Q=this.#W==="tip";if(this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(Q)Z.setAttribute("tip","color");else Z.removeAttribute("tip")}),this.#H)if(Q)this.#H.setAttribute("tip","add");else this.#H.removeAttribute("tip")}#u(){if(!this.#j||!this.#Q)return;this.#j.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#m(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops,$=new Set;Q.forEach((J)=>{let j=Math.round(parseFloat(J.getAttribute("value"))||0),q=(J.getAttribute("color")||"").toUpperCase(),_=-1;for(let X=0;X<Z.length;X++){if($.has(X))continue;if(Z[X].position===j&&Z[X].color.toUpperCase()===q){_=X;break}}if(_===-1){let X=1/0;for(let Y=0;Y<Z.length;Y++){if($.has(Y))continue;let K=Math.abs(Z[Y].position-j);if(K<X)X=K,_=Y}}if(_!==-1)$.add(_),J.dataset.stopIndex=_})}#v(){if(!this.#Z)return;this.#Z.setAttribute("background",this.#z()),this.#D()}#d(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(F(this,"disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#C($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((Y,K)=>Y.position-K.position);let q=this.#_.stops.findIndex((Y)=>Y.position===J&&Y.color===j);this.#O=!0,this.#b(),this.#v(),this.#p(),this.#A();let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(Y!==X)Y.deselect()}),X.select(),X.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:Q.clientX,clientY:Q.clientY,pointerId:Q.pointerId,pointerType:Q.pointerType,button:Q.button,buttons:Q.buttons}))}),this.#Q.addEventListener("input",(Q)=>{let Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt(Z.dataset.stopIndex,10);if(!isNaN(Y)&&this.#_.stops[Y]){if(this.#_.stops[Y].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[Y].opacity=Q.detail.opacity;Z.setAttribute("color",this.#B(this.#_.stops[Y])),this.#v(),this.#p()}return}if(!this.#$)Z.style.zIndex="5";this.#$=!0;let $=parseInt(Z.dataset.stopIndex,10);if(isNaN($)||!this.#_.stops[$])return;let J=Q.detail?.px??0,j=Math.round(J*100),q=j,_=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)q=Math.round(q/Q0.SHIFT_SNAP)*Q0.SHIFT_SNAP;else{let Y=_>0?5/_*100:0;for(let K=0;K<this.#_.stops.length;K++){if(K===$)continue;if(Math.abs(this.#_.stops[K].position-q)<=Y){q=this.#_.stops[K].position;break}}}if(this.#_.stops[$].position=q,q!==j)Z.style.left=`${q/100*_}px`;let X=Z.closest("fig-tooltip");if(X){if(X.text=`${Math.round(q)}%`,!X.hasAttribute("show"))X.setAttribute("show","true"),Z.hideColorTip()}this.#v(),this.#p()}),this.#Q.addEventListener("change",(Q)=>{let Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt(Z.dataset.stopIndex,10);if(!isNaN(Y)&&this.#_.stops[Y]){if(this.#_.stops[Y].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[Y].opacity=Q.detail.opacity;Z.setAttribute("color",this.#B(this.#_.stops[Y])),this.#v(),this.#s()}return}Z.style.zIndex="";let $=Z.closest("fig-tooltip");if($)$.removeAttribute("show");Z.showColorTip();let J=parseInt(Z.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])return;let j=Q.detail?.px??0,q=Math.round(j*100),_=this.#Q.getBoundingClientRect().width,X=_>0?5/_*100:0;for(let Y=0;Y<this.#_.stops.length;Y++){if(Y===J)continue;if(Math.abs(this.#_.stops[Y].position-q)<=X){q=this.#_.stops[Y].position;break}}this.#_.stops[J].position=q,Z.style.left=`${q/100*_}px`,this.#_.stops.sort((Y,K)=>Y.position-K.position),this.#m(),this.#v(),this.#s(),requestAnimationFrame(()=>{this.#$=!1})}),this.#j=new MutationObserver((Q)=>{for(let Z of Q){if(Z.attributeName!=="color")continue;let $=Z.target;if($.classList.contains("fig-input-gradient-ghost"))continue;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])continue;let j=$.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#_.stops[J].color)this.#_.stops[J].color=j,this.#v(),this.#p()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#p(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#s(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:n0(this.#G(this.#_))}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}focus(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#X){let Z=this.#N();if(Z){Z.focus(Q);return}}HTMLElement.prototype.focus.call(this,Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":this.#F(),this.#v(),this.#b();break;case"disabled":this.#t();break;case"edit":if(this.#R(),this.#X)document.addEventListener("keydown",this.#U);else document.removeEventListener("keydown",this.#U);break;case"mode":this.#x();break;case"size":this.#D();break}}#t(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#K(),this.#Z)if(Q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#Q)for(let Z of this.#Q.querySelectorAll("fig-handle"))if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}z("fig-input-gradient",Q0);class Y0 extends HTMLElement{#Z=null;#Q;#$;#J;#j=!1;constructor(){super();if(this.input=document.createElement("input"),this.name=this.getAttribute("name")||"",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",g()),this.name)this.input.setAttribute("name",this.name);this.input.setAttribute("type","checkbox"),this.#Q=this.handleInput.bind(this),this.#$=this.handleChange.bind(this),this.#J=(Q)=>{if(Q.target!==this||this.input.disabled)return;this.input.click()}}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("input",this.#Q),this.input.addEventListener("input",this.#Q),this.input.removeEventListener("change",this.#$),this.input.addEventListener("change",this.#$),this.removeEventListener("click",this.#J),this.addEventListener("click",this.#J),this.#X();let Z=this.querySelector(":scope > label");if(Z)this.#Z=Z,this.#j=!1,this.#Z.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#q(),this.#Z.innerText=this.getAttribute("label");if(!this.hasAttribute("label")){let $=Array.from(this.childNodes).filter((J)=>J.nodeType===Node.TEXT_NODE).map((J)=>J.textContent||"").join(" ").trim();if($&&!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-label",$)}this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#q(){if(!this.#Z)this.#Z=document.createElement("label"),this.#j=!0,this.#Z.setAttribute("for",this.input.id);if(this.#Z&&!this.#Z.parentNode&&this.input.parentNode)this.input.after(this.#Z)}render(){}#_(Q){return this.hasAttribute(Q)&&this.getAttribute(Q)!=="false"}#Y(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#X(){let Q=this.#_("checked"),Z=this.#_("indeterminate")&&!Q,$=this.#_("disabled");this.input.checked=Q,this.input.indeterminate=Z,this.input.disabled=$,this.input.value=this.getAttribute("value")||"";let J=this.getAttribute("name")||this.name;if(J)this.input.setAttribute("name",J);else this.input.removeAttribute("name");if(Z)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#Y()}focus(){this.input.focus()}get value(){return this.input.value}set value(Q){this.input.value=Q,this.setAttribute("value",Q)}get checked(){return this.input.checked}set checked(Q){if(this.input.checked=Q,Q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("input",this.#Q),this.input.removeEventListener("change",this.#$),this.removeEventListener("click",this.#J)}attributeChangedCallback(Q,Z,$){switch(Q){case"label":if($)this.#q(),this.#Z.innerText=$;else if(this.#Z&&this.#j)this.#Z.remove(),this.#Z=null,this.#j=!1;break;case"checked":if(this.#_("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#X();break;case"indeterminate":this.#X();break;case"disabled":this.#X();break;case"name":if($)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"value":this.input.value=$||"";break;default:this.input[Q]=$,this.input.setAttribute(Q,$);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#Y(),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}handleChange(Q){Q.stopPropagation(),this.#Y(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}z("fig-checkbox",Y0);class $1 extends Y0{constructor(){super();this.input.setAttribute("type","radio");let Q=this.getAttribute("name");if(Q)this.input.setAttribute("name",Q);else this.input.removeAttribute("name")}}z("fig-radio",$1);class J1 extends Y0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}z("fig-switch",J1);class j1 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Z=!1;#Q=null;#$=null;#J=null;#j=null;#q=!1;#_=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Y=this.#F.bind(this);#X=this.#z.bind(this);#W=this.#B.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}#N(){return!!this.querySelector(":scope > .input-combo")}#K(){if(this.#Q=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#$=this.querySelector("fig-dropdown"),this.#Q)this.#Q.setAttribute("value",this.value),this.#Q.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#R()}connectedCallback(){if(this.#j=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#Z=this.#j!==null,this.#j)this.#j.remove();if(this.#N())this.#K(),this.#U();else this.#G(),this.#U();this.#P(F(this,"disabled"))}disconnectedCallback(){this.#L()}#G(){let Q=this.#E(),Z=this.getAttribute("placeholder")||"",$=this.value,J=this.#O(),j=this.#Z?"":`<fig-dropdown type="dropdown" label="${v(J)}">${Q.map((q)=>`<option>${v(q.trim())}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
|
|
272
|
+
${Z==="true"||Z==="picker"?`<div class="fig-input-gradient-track">${this.#E()}</div>`:""}`,this.#Z=this.querySelector("fig-swatch"),this.#Q=this.querySelector(".fig-input-gradient-track"),Z==="true"||Z==="picker")this.#S(),this.#d();this.#K()}#P(){let Q=this.querySelector("fig-fill-picker");if(!Q)return;Q.anchorElement=this;let Z=($)=>{$.stopPropagation();let J=$.detail;if(!J?.gradient)return;this.#_=this.#G({...this.#_,...J.gradient}),this.#v()};Q.addEventListener("input",($)=>{Z($),this.#p()}),Q.addEventListener("change",($)=>{Z($),this.#s()})}#C(Q){return r1(this.#_.stops,Q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#S(){if(!this.#Q||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=document.createElement("fig-handle");if(Q.classList.add("fig-input-gradient-ghost"),Q.setAttribute("type","color"),this.#W==="tip")Q.setAttribute("tip","add");Q.style.position="absolute",Q.style.top="50%",Q.style.transform="translate(-50%, -50%)",Q.style.pointerEvents="none",Q.style.opacity="0",Q.style.transition="opacity 0.15s",this.#Q.appendChild(Q),this.#H=Q,this.addEventListener("pointerenter",this.#k),this.addEventListener("pointermove",this.#f),this.addEventListener("pointerleave",this.#T),this.addEventListener("click",this.#h),this.addEventListener("dblclick",this.#g)}#I(){if(!this.#H)return;this.#H.style.opacity="1"}#A(){if(!this.#H)return;this.#H.style.opacity="0"}#k=()=>{if(this.#$)return;this.#I()};#T=()=>{this.#A()};#f=(Q)=>{if(this.#$){this.#A();return}if(!this.#H||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#A();return}let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width));this.#H.style.left=`${$*100}%`;let J=this.#C($);this.#H.setAttribute("color",J),this.#I()};#y(){let Q=this.#_.stops.length;if(Q<2)return;for(let Z=0;Z<Q;Z++)this.#_.stops[Z].position=Math.round(Z/(Q-1)*100);this.#b(),this.#v(),this.#p(),this.#s()}#g=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#y(),this.#Q.querySelectorAll("fig-handle[selected]").forEach((Z)=>{Z.removeAttribute("selected")})};#h=(Q)=>{if(!this.#Q)return;if(this.#$)return;if(this.#O){this.#O=!1;return}if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(Q.shiftKey){let _=Q.target.closest("fig-handle"),X=parseInt(_?.dataset.stopIndex,10);if(this.#y(),!isNaN(X))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(parseInt(Y.dataset.stopIndex,10)===X)Y.select();else Y.deselect()});Q.stopPropagation()}return}let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#C($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((_,X)=>_.position-X.position);let q=this.#_.stops.findIndex((_)=>_.position===J&&_.color===j);this.#b(),this.#v(),this.#p(),this.#s(),requestAnimationFrame(()=>{let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)X.click()})};#w(){if(this.#q=null,!this.isConnected)return;if(!this.#Q)return;let Q=this.#_.stops;this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z,$)=>{if($>=Q.length)return;Z.removeAttribute("value"),Z.setAttribute("value",`${Q[$].position}% 50%`)})}refreshLayout(){this.#w()}#V(){if(this.#q!==null)return;this.#q=requestAnimationFrame(()=>this.#w())}#b(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops;if(Q.length!==Z.length){let $=this.#H;if(this.#Q.innerHTML=this.#E(),$)this.#Q.appendChild($);this.#x(),this.#u(),this.#V();return}for(let $=0;$<Z.length;$++){let J=Q[$],j=Z[$];if(J.dataset.stopIndex=$,J.setAttribute("value",`${j.position}% 50%`),J.setAttribute("color",this.#B(j)),this.#W==="tip")J.setAttribute("tip","color");else J.removeAttribute("tip");let q=J.closest("fig-tooltip");if(q)q.setAttribute("text",`${Math.round(j.position)}%`)}this.#x()}#x(){if(!this.#Q)return;let Q=this.#W==="tip";if(this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Z)=>{if(Q)Z.setAttribute("tip","color");else Z.removeAttribute("tip")}),this.#H)if(Q)this.#H.setAttribute("tip","add");else this.#H.removeAttribute("tip")}#u(){if(!this.#j||!this.#Q)return;this.#j.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#m(){if(!this.#Q)return;let Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Z=this.#_.stops,$=new Set;Q.forEach((J)=>{let j=Math.round(parseFloat(J.getAttribute("value"))||0),q=(J.getAttribute("color")||"").toUpperCase(),_=-1;for(let X=0;X<Z.length;X++){if($.has(X))continue;if(Z[X].position===j&&Z[X].color.toUpperCase()===q){_=X;break}}if(_===-1){let X=1/0;for(let Y=0;Y<Z.length;Y++){if($.has(Y))continue;let K=Math.abs(Z[Y].position-j);if(K<X)X=K,_=Y}}if(_!==-1)$.add(_),J.dataset.stopIndex=_})}#v(){if(!this.#Z)return;this.#Z.setAttribute("background",this.#z()),this.#D()}#d(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(F(this,"disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault(),Q.stopPropagation();let Z=this.#Q.getBoundingClientRect(),$=Math.max(0,Math.min(1,(Q.clientX-Z.left)/Z.width)),J=Math.round($*100),j=this.#C($);this.#_.stops.push({position:J,color:j,opacity:100}),this.#_.stops.sort((Y,K)=>Y.position-K.position);let q=this.#_.stops.findIndex((Y)=>Y.position===J&&Y.color===j);this.#O=!0,this.#b(),this.#v(),this.#p(),this.#A();let X=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[q];if(X)this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Y)=>{if(Y!==X)Y.deselect()}),X.select(),X.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:Q.clientX,clientY:Q.clientY,pointerId:Q.pointerId,pointerType:Q.pointerType,button:Q.button,buttons:Q.buttons}))}),this.#Q.addEventListener("input",(Q)=>{let Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt(Z.dataset.stopIndex,10);if(!isNaN(Y)&&this.#_.stops[Y]){if(this.#_.stops[Y].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[Y].opacity=Q.detail.opacity;Z.setAttribute("color",this.#B(this.#_.stops[Y])),this.#v(),this.#p()}return}if(!this.#$)Z.style.zIndex="5";this.#$=!0;let $=parseInt(Z.dataset.stopIndex,10);if(isNaN($)||!this.#_.stops[$])return;let J=Q.detail?.px??0,j=Math.round(J*100),q=j,_=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)q=Math.round(q/Q0.SHIFT_SNAP)*Q0.SHIFT_SNAP;else{let Y=_>0?5/_*100:0;for(let K=0;K<this.#_.stops.length;K++){if(K===$)continue;if(Math.abs(this.#_.stops[K].position-q)<=Y){q=this.#_.stops[K].position;break}}}if(this.#_.stops[$].position=q,q!==j)Z.style.left=`${q/100*_}px`;let X=Z.closest("fig-tooltip");if(X){if(X.text=`${Math.round(q)}%`,!X.hasAttribute("show"))X.setAttribute("show","true"),Z.hideColorTip()}this.#v(),this.#p()}),this.#Q.addEventListener("change",(Q)=>{let Z=Q.target.closest("fig-handle");if(!Z)return;if(Q.stopPropagation(),Q.detail?.color){let Y=parseInt(Z.dataset.stopIndex,10);if(!isNaN(Y)&&this.#_.stops[Y]){if(this.#_.stops[Y].color=Q.detail.color,Q.detail.opacity!==void 0)this.#_.stops[Y].opacity=Q.detail.opacity;Z.setAttribute("color",this.#B(this.#_.stops[Y])),this.#v(),this.#s()}return}Z.style.zIndex="";let $=Z.closest("fig-tooltip");if($)$.removeAttribute("show");Z.showColorTip();let J=parseInt(Z.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])return;let j=Q.detail?.px??0,q=Math.round(j*100),_=this.#Q.getBoundingClientRect().width,X=_>0?5/_*100:0;for(let Y=0;Y<this.#_.stops.length;Y++){if(Y===J)continue;if(Math.abs(this.#_.stops[Y].position-q)<=X){q=this.#_.stops[Y].position;break}}this.#_.stops[J].position=q,Z.style.left=`${q/100*_}px`,this.#_.stops.sort((Y,K)=>Y.position-K.position),this.#m(),this.#v(),this.#s(),requestAnimationFrame(()=>{this.#$=!1})}),this.#j=new MutationObserver((Q)=>{for(let Z of Q){if(Z.attributeName!=="color")continue;let $=Z.target;if($.classList.contains("fig-input-gradient-ghost"))continue;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])continue;let j=$.getAttribute("color");if(!j||!j.startsWith("#"))continue;if(j!==this.#_.stops[J].color)this.#_.stops[J].color=j,this.#v(),this.#p()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#j.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#p(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#s(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:n0(this.#G(this.#_))}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}focus(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#X){let Z=this.#N();if(Z){Z.focus(Q);return}}HTMLElement.prototype.focus.call(this,Q)}attributeChangedCallback(Q,Z,$){if(Z===$)return;switch(Q){case"value":this.#F(),this.#v(),this.#b();break;case"disabled":this.#t();break;case"edit":if(this.#R(),this.#X)document.addEventListener("keydown",this.#U);else document.removeEventListener("keydown",this.#U);break;case"mode":this.#x();break;case"size":this.#D();break}}#t(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#K(),this.#Z)if(Q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");if(this.#Q)for(let Z of this.#Q.querySelectorAll("fig-handle"))if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")}}z("fig-input-gradient",Q0);class Y0 extends HTMLElement{#Z=null;#Q;#$;#J;#j=!1;constructor(){super();if(this.input=document.createElement("input"),this.name=this.getAttribute("name")||"",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",g()),this.name)this.input.setAttribute("name",this.name);this.input.setAttribute("type","checkbox"),this.#Q=this.handleInput.bind(this),this.#$=this.handleChange.bind(this),this.#J=(Q)=>{if(Q.target!==this||this.input.disabled)return;this.input.click()}}connectedCallback(){let Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("input",this.#Q),this.input.addEventListener("input",this.#Q),this.input.removeEventListener("change",this.#$),this.input.addEventListener("change",this.#$),this.removeEventListener("click",this.#J),this.addEventListener("click",this.#J),this.#X();let Z=this.querySelector(":scope > label");if(Z)this.#Z=Z,this.#j=!1,this.#Z.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#q(),this.#Z.innerText=this.getAttribute("label");if(!this.hasAttribute("label")){let $=Array.from(this.childNodes).filter((J)=>J.nodeType===Node.TEXT_NODE).map((J)=>J.textContent||"").join(" ").trim();if($&&!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-label",$)}this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#q(){if(!this.#Z)this.#Z=document.createElement("label"),this.#j=!0,this.#Z.setAttribute("for",this.input.id);if(this.#Z&&!this.#Z.parentNode&&this.input.parentNode)this.input.after(this.#Z)}render(){}#_(Q){return this.hasAttribute(Q)&&this.getAttribute(Q)!=="false"}#Y(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#X(){let Q=this.#_("checked"),Z=this.#_("indeterminate")&&!Q,$=this.#_("disabled");this.input.checked=Q,this.input.indeterminate=Z,this.input.disabled=$,this.input.value=this.getAttribute("value")||"";let J=this.getAttribute("name")||this.name;if(J)this.input.setAttribute("name",J);else this.input.removeAttribute("name");if(Z)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#Y()}focus(){this.input.focus()}get value(){return this.input.value}set value(Q){this.input.value=Q,this.setAttribute("value",Q)}get checked(){return this.input.checked}set checked(Q){if(this.input.checked=Q,Q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("input",this.#Q),this.input.removeEventListener("change",this.#$),this.removeEventListener("click",this.#J)}attributeChangedCallback(Q,Z,$){switch(Q){case"label":if($)this.#q(),this.#Z.innerText=$;else if(this.#Z&&this.#j)this.#Z.remove(),this.#Z=null,this.#j=!1;break;case"checked":if(this.#_("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#X();break;case"indeterminate":this.#X();break;case"disabled":this.#X();break;case"name":if($)this.input.setAttribute("name",$);else this.input.removeAttribute("name");break;case"value":this.input.value=$||"";break;default:this.input[Q]=$,this.input.setAttribute(Q,$);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#Y(),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}handleChange(Q){Q.stopPropagation(),this.#Y(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}z("fig-checkbox",Y0);class $1 extends Y0{constructor(){super();this.input.setAttribute("type","radio");let Q=this.getAttribute("name");if(Q)this.input.setAttribute("name",Q);else this.input.removeAttribute("name")}}z("fig-radio",$1);class J1 extends Y0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}z("fig-switch",J1);class j1 extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Z=!1;#Q=null;#$=null;#J=null;#j=null;#q=!1;#_=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Y=this.#F.bind(this);#X=this.#z.bind(this);#W=this.#B.bind(this);get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}#N(){return!!this.querySelector(":scope > .input-combo")}#K(){if(this.#Q=this.querySelector("fig-input-text"),this.#J=this.querySelector("fig-button"),this.#$=this.querySelector("fig-dropdown"),this.#Q)this.#Q.setAttribute("value",this.value),this.#Q.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#R()}connectedCallback(){if(this.#j=Array.from(this.children).find((Q)=>Q.tagName==="FIG-DROPDOWN")||null,this.#Z=this.#j!==null,this.#j)this.#j.remove();if(this.#N())this.#K(),this.#U();else this.#G(),this.#U();this.#P(F(this,"disabled"))}disconnectedCallback(){this.#L()}#G(){let Q=this.#E(),Z=this.getAttribute("placeholder")||"",$=this.value,J=this.#O(),j=this.#Z?"":`<fig-dropdown type="dropdown" label="${v(J)}">${Q.map((q)=>`<option>${v(q.trim())}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
|
|
273
273
|
<fig-input-text placeholder="${v(Z)}" value="${v($)}"></fig-input-text>
|
|
274
274
|
<fig-button type="select" variant="input" icon>
|
|
275
275
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -359,6 +359,6 @@ var y1=(Q,Z)=>()=>(Q&&(Z=Q(Q=0)),Z);var w1={};var T0=y1(()=>{/*! Vendored from @
|
|
|
359
359
|
<circle class="fig-interpolation-swatch-rim" cx="10" cy="10" r="8" fill="none" stroke="currentColor" stroke-width="${Q}"/>
|
|
360
360
|
</svg>
|
|
361
361
|
<div class="fig-interpolation-swatch-fill" aria-hidden="true"></div>
|
|
362
|
-
`,this.#X=this.querySelector(".fig-interpolation-swatch-svg"),this.#W=this.querySelector(".fig-interpolation-swatch-fill"),this.#Y=!0}#C(){if(!this.#W)return;let Q=this.#L();if(this.#X)this.#X.style.display=Q?"":"none";let Z=Q?(()=>{let{startDeg:J,sweepDeg:j}=this.#z();return this.#M(J,j)})():this.#D(),$=this.#E(Z);this.#W.style.setProperty("-webkit-mask-image",$),this.#W.style.maskImage=$,this.#W.style.background=this.#R()}}z("fig-interpolation-swatch",C);var
|
|
362
|
+
`,this.#X=this.querySelector(".fig-interpolation-swatch-svg"),this.#W=this.querySelector(".fig-interpolation-swatch-fill"),this.#Y=!0}#C(){if(!this.#W)return;let Q=this.#L();if(this.#X)this.#X.style.display=Q?"":"none";let Z=Q?(()=>{let{startDeg:J,sweepDeg:j}=this.#z();return this.#M(J,j)})():this.#D(),$=this.#E(Z);this.#W.style.setProperty("-webkit-mask-image",$),this.#W.style.maskImage=$,this.#W.style.background=this.#R()}}z("fig-interpolation-swatch",C);var l1={chevron:"--icon-16-chevron",checkmark:"--icon-16-checkmark",reset:{medium:"--icon-24-reset",small:"--icon-16-reset"},"arrow-left":{medium:"--icon-24-arrow-left",small:"--icon-16-arrow-left"},steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",adjust:{medium:"--icon-24-adjust",small:"--icon-16-adjust"},minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",download:"--icon-24-download",upload:"--icon-24-upload",sun:"--icon-24-sun",moon:"--icon-24-moon",edit:{medium:"--icon-24-edit",small:"--icon-16-edit"},settings:{medium:"--icon-24-settings",small:"--icon-16-settings"},more:{medium:"--icon-24-more",small:"--icon-16-more"},visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"}};function a1(Q,Z="medium"){let $=Q&&l1[Q];if(!$)return"";let J=typeof $==="string"?$:$[Z==="small"?"small":"medium"];return J?`var(${J})`:""}class z1 extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#Z()}attributeChangedCallback(Q,Z,$){if(Z!==$)this.#Z()}#Z(){let Q=this.getAttribute("name"),Z=this.getAttribute("size")||"medium",$=a1(Q,Z);if($)this.style.setProperty("--icon",$);else this.style.removeProperty("--icon");if(Z==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let J=this.getAttribute("color");if(J)this.style.backgroundColor=J;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}z("fig-icon",z1);class H1 extends HTMLElement{}z("fig-content",H1);class A1 extends HTMLElement{}z("fig-tab-content",A1);class R1 extends HTMLElement{}z("fig-button-combo",R1);class D1 extends HTMLElement{}z("fig-input-combo",D1);class T1 extends HTMLElement{#Z=null;#Q=null;#$=null;#J=this.#B.bind(this);#j=this.#M.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#q(){return this.getAttribute("control")||"color"}connectedCallback(){this.#W(),this.#L()}disconnectedCallback(){this.#_(),this.removeEventListener("click",this.#N)}#_(){if(this.#Z)this.#Z.removeEventListener("input",this.#J),this.#Z.removeEventListener("change",this.#j);if(this.#Q)this.#Q.removeEventListener("input",this.#J),this.#Q.removeEventListener("change",this.#j);if(this.#$)this.#$.disconnect(),this.#$=null}#Y(){if(this.#$)this.#$.disconnect(),this.#$=null;if(!this.#Q)return;this.#$=new MutationObserver(()=>{if(this.#Q?.hasAttribute("selected")&&this.#Q.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#$.observe(this.#Q,{attributes:!0,attributeFilter:["selected"]})}get#X(){let Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#W(){let Q=this.#q;if(Q==="add"||Q==="remove"){let X=Q==="add"?"add":"minus",Y=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");this.innerHTML=`<fig-button icon variant="ghost" aria-label="${v(Y)}"><fig-icon name="${X}"></fig-icon></fig-button>`,this.#Z=null,this.#Q=null,this.addEventListener("click",this.#N),this.#F();return}this.removeEventListener("click",this.#N);let Z=(this.getAttribute("value")||"").trim(),$=this.#U(Z),J=this.#G(Z),j=this.#X?"":'alpha="false"',q=J<1?JSON.stringify({type:"solid",color:$,opacity:Math.round(J*100)}):JSON.stringify({type:"solid",color:$}),_=J<1?` alpha="${J}"`:"";if(this.innerHTML=o()?`<fig-fill-picker mode="solid" ${j} value='${q}'>
|
|
363
363
|
<fig-swatch background="${$}"${_}></fig-swatch>
|
|
364
364
|
</fig-fill-picker>`:`<fig-swatch background="${$}"${_}></fig-swatch>`,this.#Z=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-swatch"),this.#_(),this.#Z?.addEventListener("input",this.#J),this.#Z?.addEventListener("change",this.#j),!this.#Z)this.#Q?.addEventListener("input",this.#J),this.#Q?.addEventListener("change",this.#j);this.#Y(),this.#F()}#N=()=>{let Q=this.#q;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#K(Q){if(!Q)return"#D9D9D9";let Z=Q.replace("#","").trim();if(Z.length===3||Z.length===4){let[$,J,j]=Z;return`#${$}${$}${J}${J}${j}${j}`.toUpperCase()}if(Z.length===6||Z.length===8)return`#${Z.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#G(Q){if(!Q)return 1;let Z=String(Q).trim(),$=Z.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test($)){let j=$[3];return parseInt(`${j}${j}`,16)/255}if(/^[0-9a-f]{8}$/i.test($))return parseInt($.slice(6,8),16)/255;let J=Z.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if(J)return parseFloat(J[1]);return 1}#U(Q){if(!Q)return"#D9D9D9";let Z=String(Q).trim();if(Z.startsWith("{"))try{let $=JSON.parse(Z);if($?.color)return this.#U($.color)}catch{}if(Z.startsWith("#"))return this.#K(Z);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Z))return this.#K(Z);try{let{ctx:$}=O0(1,1);$.fillStyle="#000000",$.fillStyle=Z;let J=$.fillStyle;if(J.startsWith("#"))return this.#K(J);let j=J.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){let q=(_)=>Math.max(0,Math.min(255,Number(_))).toString(16).padStart(2,"0");return`#${q(j[1])}${q(j[2])}${q(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#L(){let Q=this.getAttribute("value"),Z=this.#U(Q),$=this.#G(Q);if(Q!==Z&&$>=1){this.setAttribute("value",Z);return}if(this.#Z){this.#F();let J=$<1?{type:"solid",color:Z,opacity:Math.round($*100)}:{type:"solid",color:Z};if(this.#Z.setAttribute("value",JSON.stringify(J)),this.#X)this.#Z.removeAttribute("alpha");else this.#Z.setAttribute("alpha","false");if(F(this,"disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}if(this.#Q){if(this.#F(),this.#Q.setAttribute("background",Z),$<1)this.#Q.setAttribute("alpha",String($));else this.#Q.removeAttribute("alpha");if(F(this,"disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}}#F(){let Q=this.#q,Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",Z?"true":"false"),this.setAttribute("aria-pressed",$?"true":"false"),Q==="add"||Q==="remove"){let X=this.querySelector("fig-button"),Y=this.getAttribute("aria-label")||(Q==="add"?"Add color stop":"Remove color stop");if(X?.setAttribute("aria-label",Y),Z)X?.setAttribute("disabled","");else X?.removeAttribute("disabled");return}let J=this.#Z||this.#Q;if(!J)return;let j=this.getAttribute("aria-label")||"Color stop",q=this.getAttribute("aria-labelledby"),_=this.getAttribute("aria-describedby");if(q)J.setAttribute("aria-labelledby",q),J.removeAttribute("aria-label");else J.setAttribute("aria-label",j),J.removeAttribute("aria-labelledby");if(_)J.setAttribute("aria-describedby",_);else J.removeAttribute("aria-describedby")}#z(Q,Z){let $=this.#U(Q?.color),J=this.#U(this.getAttribute("value"));if($!==J)this.setAttribute("value",$);else this.#L();let j={color:this.value};if(this.#X){if(Q?.opacity!==void 0)j.opacity=Q.opacity;else if(Q?.alpha!==void 0)j.opacity=Math.round(Q.alpha*100)}this.dispatchEvent(new CustomEvent(Z,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#B(Q){Q.stopPropagation(),this.#z(Q.detail||{color:Q.target?.value},"input")}#M(Q){Q.stopPropagation(),this.#z(Q.detail||{color:Q.target?.value},"change")}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(!this.isConnected)return;switch(Q){case"control":this.#W();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#L(),this.#F();break}}get value(){return this.#U(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#U(Q))}get selected(){return F(this,"selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return F(this,"disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}z("fig-color-tip",T1);class P1 extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",F(this,"selected")?"true":"false"),F(this,"disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",F(this,"selected")?"true":"false");if(Q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}z("fig-choice",P1);class E1 extends HTMLElement{#Z=null;#Q=this.#D.bind(this);#$=this.#E.bind(this);#J=this.#O.bind(this);#j=null;#q=null;#_=null;#Y=null;#X=null;#W=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#N(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#K(){let Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#G(){return this.getAttribute("choice-element")||"fig-choice"}#U(){let Q=this.getAttribute("columns"),Z=Q===null?NaN:Number(Q);if(Number.isInteger(Z)&&Z>0)this.style.setProperty("--fig-chooser-grid-columns",String(Z));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from(this.querySelectorAll(`:scope > ${this.#G}`))}get selectedChoice(){return this.#Z}set selectedChoice(Q){if(Q&&!this.contains(Q))return;let Z=this.choices;for(let J of Z){let j=J===Q,q=F(J,"selected");if(j&&!q)J.setAttribute("selected","");else if(!j&&q)J.removeAttribute("selected")}this.#Z=Q;let $=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==$){if($)this.setAttribute("value",$)}this.#y(Q)}get value(){return this.#Z?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){if(this.setAttribute("role","listbox"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.#S(),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#$),this.addEventListener("scroll",this.#J),this.#I(),this.#P(),this.#g(),this.#R(),this.#z(),c(this,()=>{this.#F(),this.#O(),this.#L()})}#L(){let Q=()=>{if(!this.isConnected)return;if(this.#Z)this.#y(this.#Z,"auto")},Z=()=>{let $=this.querySelectorAll("img, video");for(let J of $){if(J.tagName==="IMG"?J.complete:J.readyState>=1)continue;let j=()=>{J.removeEventListener("load",j),J.removeEventListener("loadedmetadata",j),J.removeEventListener("error",j),Q()};J.addEventListener("load",j),J.addEventListener("loadedmetadata",j),J.addEventListener("error",j)}};requestAnimationFrame(()=>{Z(),Q()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#$),this.removeEventListener("scroll",this.#J),this.#C(),this.#j?.disconnect(),this.#j=null,this.#q?.disconnect(),this.#q=null,this.#A()}attributeChangedCallback(Q,Z,$){if(Q==="value"&&$!==Z&&$)this.#B($);if(Q==="disabled")this.#z();if(Q==="choice-element")requestAnimationFrame(()=>this.#F());if(Q==="columns")this.#U(),this.#f();if(Q==="drag")if(this.#K)this.#P();else this.#C();if(Q==="overflow")this.#I(),requestAnimationFrame(()=>this.#O());if(Q==="layout"){if(this.#I(),$==="horizontal")this.scrollTop=0;else this.scrollLeft=0;this.#f()}}#F(){let Q=this.choices;if(!Q.length){this.#Z=null;return}let Z=this.getAttribute("value");if(Z&&this.#B(Z))return;let $=Q.find((J)=>F(J,"selected"));if($){this.selectedChoice=$;return}this.selectedChoice=Q[0]}#z(){let Q=F(this,"disabled");if(Q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Z of this.choices)if(Q||F(Z,"disabled"))Z.setAttribute("aria-disabled","true"),Z.setAttribute("tabindex","-1");else Z.removeAttribute("aria-disabled"),Z.setAttribute("tabindex","0")}#B(Q){let Z=this.choices;for(let $ of Z)if($.getAttribute("value")===Q)return this.selectedChoice=$,!0;return!1}#M(Q){let Z=this.#G,$=Q;while($&&$!==this){if($.matches(Z))return $;$=$.parentElement}return null}#D(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.#M(Q.target);if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.selectedChoice=Z,this.#H()}#E(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Z=this.choices.filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false");if(!Z.length)return;let $=Z.indexOf(this.#Z),J=$,j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),$<Z.length-1)J=$+1;else if(j)J=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),$>0)J=$-1;else if(j)J=Z.length-1;break;case"Home":Q.preventDefault(),J=0;break;case"End":Q.preventDefault(),J=Z.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#G)){let q=this.#M(document.activeElement);if(q&&q!==this.#Z)this.selectedChoice=q,this.#H()}return;default:return}if(J!==$&&Z[J])this.selectedChoice=Z[J],Z[J].focus(),this.#H()}#H(){let Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#O(){if(this.#N==="scrollbar")return;let Q=this.getAttribute("layout")==="horizontal";a(this,this,Q?"x":"y")}#R(){this.#q?.disconnect(),this.#q=new ResizeObserver(()=>{this.#O(),this.#f()}),this.#q.observe(this)}#P(){if(this.#X?.bound)return;if(!this.#K)return;let Q=(q)=>{if(q.button!==0)return;if(q.target.closest("[data-fig-chooser-nav]"))return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#X.active=!0,this.#X.didDrag=!1,this.#X.startX=q.clientX,this.#X.startY=q.clientY,this.#X.scrollLeft=this.scrollLeft,this.#X.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Z=(q)=>{if(!this.#X.active)return;let _=this.getAttribute("layout")==="horizontal",X=q.clientX-this.#X.startX,Y=q.clientY-this.#X.startY;if(!this.#X.didDrag&&Math.abs(_?X:Y)>3)this.#X.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(q.pointerId);if(!this.#X.didDrag)return;if(_)this.scrollLeft=this.#X.scrollLeft-X;else this.scrollTop=this.#X.scrollTop-Y},$=(q)=>{if(!this.#X.active)return;let _=this.#X.didDrag;if(this.#X.active=!1,this.#X.didDrag=!1,this.style.cursor="",this.style.userSelect="",q.pointerId!==void 0)try{this.releasePointerCapture(q.pointerId)}catch{}if(_)q.preventDefault(),q.stopPropagation()},J=(q)=>{if(this.#X?.suppressClick)q.stopPropagation(),q.preventDefault(),this.#X.suppressClick=!1},j=(q)=>{if(this.#X?.didDrag)this.#X.suppressClick=!0,setTimeout(()=>{if(this.#X)this.#X.suppressClick=!1},0)};this.#X={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:Q,onPointerMove:Z,onPointerUp:$,onClick:J,onPointerUpCapture:j},this.addEventListener("pointerdown",Q),window.addEventListener("pointermove",Z),window.addEventListener("pointerup",$),this.addEventListener("pointerup",j,!0),this.addEventListener("click",J,!0)}#C(){if(!this.#X?.bound)return;this.removeEventListener("pointerdown",this.#X.onPointerDown),window.removeEventListener("pointermove",this.#X.onPointerMove),window.removeEventListener("pointerup",this.#X.onPointerUp),this.removeEventListener("pointerup",this.#X.onPointerUpCapture,!0),this.removeEventListener("click",this.#X.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#X=null}#S(){if(this.#W)return;let Q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!Q)return;this.#W=!0;try{let Z=Array.from(Q.childNodes);Q.replaceWith(...Z)}finally{this.#W=!1}}#I(){if(this.#N==="scrollbar")this.#A();else this.#k()}#A(){this.#_?.remove(),this.#Y?.remove(),this.#_=null,this.#Y=null,this.classList.remove("overflow-start","overflow-end")}#k(){if(this.#_&&this.#Y&&this.contains(this.#_)&&this.contains(this.#Y))return;this.#_?.remove(),this.#Y?.remove(),this.#_=null,this.#Y=null;let Q=X0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#T(-1),onEnd:()=>this.#T(1)});this.#_=Q.start,this.#Y=Q.end,this.prepend(this.#_),this.append(this.#Y)}#T(Q){let Z=this.getAttribute("layout")==="horizontal";i(this,Z?"x":"y",Q)}#f(){if(!this.#Z)return;this.#y(this.#Z,"auto")}#y(Q,Z="smooth"){if(!Q)return;requestAnimationFrame(()=>{if(!Q.isConnected)return;let $=this.scrollHeight>this.clientHeight,J=this.scrollWidth>this.clientWidth;if(!J&&!$)return;let j=Q.getBoundingClientRect(),q=this.getBoundingClientRect(),_={behavior:Z},X=!1;if($){let Y=j.top-q.top+this.scrollTop,K=this.scrollHeight-this.clientHeight;_.top=Math.max(0,Math.min(Y+j.height/2-this.clientHeight/2,K)),X=!0}if(J){let Y=j.left-q.left+this.scrollLeft,K=this.scrollWidth-this.clientWidth;_.left=Math.max(0,Math.min(Y+j.width/2-this.clientWidth/2,K)),X=!0}if(X)this.scrollTo(_);this.#O()})}#g(){this.#j?.disconnect(),this.#j=new MutationObserver(()=>{if(this.#W)return;this.#S(),this.#I(),this.#z();let Q=this.choices;if(this.#Z&&!Q.includes(this.#Z))this.#Z=null,this.#F();else if(!this.#Z&&Q.length)this.#F();requestAnimationFrame(()=>this.#O())}),this.#j.observe(this,{childList:!0,subtree:!1})}}z("fig-chooser",E1);class C1 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#Z=!1;#Q=!1;#$=null;#J=null;#j=!1;#q=null;#_=null;#Y=null;#X=null;get#W(){let Q=(this.getAttribute("tip")||"").trim().toLowerCase();return Q==="color"||Q==="add"||Q==="remove"?Q:null}get#N(){return!this.hasAttribute("data-no-color-picker")}get#K(){let Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#G(){let Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#U(){let Q=this.getAttribute("drag-snapping");if(Q===null)return"false";let Z=Q.trim().toLowerCase();if(Z==="modifier")return"modifier";if(Z===""||Z==="true")return"true";return"false"}#L(Q){let Z=this.#U;if(Z==="true")return!0;if(Z==="modifier")return!!Q;return!1}#F(Q){if(Q<0.1)return 0;if(Q>0.9)return 1;if(Q>0.4&&Q<0.6)return 0.5;return Q}#z(Q,Z){if(Math.abs(Q-Z)<0.1){let J=(Q+Z)/2;return{x:J,y:J}}if(Math.abs(1-Q-Z)<0.1)return{x:Q,y:1-Q};return{x:Q,y:Z}}#B(){let Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){let Q=this.#B();if(!Q)return"0% 0%";let{px:Z,py:$}=this.#n(Q.getBoundingClientRect());return`${Math.round(Z*100)}% ${Math.round($*100)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#M(Q){let Z=Q==null?"":String(Q).trim();if(!Z)return{xPct:0,yPct:0};let $=Z.split(/[\s,]+/).filter(Boolean),J=(_)=>{if(!_)return 0;let X=_.includes("px"),Y=_.includes("%"),K=parseFloat(_.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(X)return{px:K};if(Y||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},j=J($[0]),q=J($[1]??$[0]);return{xToken:j,yToken:q}}#D(Q){let Z=this.#B();if(!Z)return;let{xToken:$,yToken:J}=this.#M(Q),j=Z.getBoundingClientRect(),q=(Y,K)=>{if(Y&&typeof Y==="object"&&"px"in Y)return Math.max(0,Math.min(K,Y.px));return null},_=(Y)=>{return`${typeof Y==="number"?Y:0}%`},X=this.#G;if(this.#E(X),X.x){let Y=q($,j.width);this.style.left=Y===null?_($):`${Math.round(Y)}px`}if(X.y){let Y=q(J,j.height);this.style.top=Y===null?_(J):`${Math.round(Y)}px`}}#E(Q=this.#G){this.style.setProperty("--fig-handle-position-translate",`${Q.x?"-50%":"0"} ${Q.y?"-50%":"0"}`)}#H(){this.#j=!0,this.setAttribute("value",this.value),this.#j=!1}get#O(){return this.getAttribute("hit-area-mode")||"handle"}#R(){let Q=this.getAttribute("hit-area");if(!Q)return null;let Z=Q.trim().split(/\s+/),$=0,J=0,j=!1,q=[];for(let _ of Z){if(_==="circle"){j=!0;continue}let X=parseFloat(_);if(Number.isFinite(X))q.push(X)}if(q.length>=2)$=q[0],J=q[1];else if(q.length===1)$=q[0],J=q[0];else return null;return{vPad:$,hPad:J,circle:j}}#P(){let Q=this.#R();if(!Q){if(this.#X)this.#X.remove(),this.#X=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#X){let Z=document.createElement("div");Z.classList.add("fig-handle-hit-area"),Z.addEventListener("pointerdown",($)=>this.#C($)),this.prepend(Z),this.#X=Z}if(this.style.setProperty("--fig-handle-hit-area-size",String(Q.hPad*2)),Q.circle)this.#X.style.borderRadius="50%";else this.#X.style.borderRadius="inherit"}#C(Q){if(F(this,"disabled"))return;if(Q.target!==this.#X)return;if(this.#O==="delegate")Q.preventDefault(),Q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:Q}}));else this.#g(Q)}connectedCallback(){this.#f(),this.#T(),this.#P(),this.addEventListener("click",this.#S),document.addEventListener("pointerdown",this.#I),document.addEventListener("keydown",this.#A);let Q=this.getAttribute("value");if(Q)this.#D(Q);if(this.#W)this.#s()}disconnectedCallback(){if(this.#y(),this.#t(),this.#u(),this.#d(),this.#X)this.#X.remove(),this.#X=null;this.removeEventListener("click",this.#S),document.removeEventListener("pointerdown",this.#I),document.removeEventListener("keydown",this.#A)}select(){if(F(this,"disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#S=(Q)=>{if(this.#Q){this.#Q=!1;return}if(this.getAttribute("type")==="color"&&this.#N&&!this.#W){this.#x();return}this.select()};#I=(Q)=>{if(this.contains(Q.target))return;if((this.#q||this.#_)&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#A=(Q)=>{if(Q.defaultPrevented)return;if(Q.target===this&&this.#K&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(Q.key)){if(this.#k(Q)){if(Q.preventDefault(),!F(this,"selected"))this.select()}return}if(Q.key!=="Enter"&&Q.key!==" ")return;if(Q.target===this&&!F(this,"selected")){if(Q.preventDefault(),this.getAttribute("type")==="color"&&this.#N&&!this.#W)this.#x();else this.select();return}if(!F(this,"selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#N)return;if(Q.preventDefault(),!this.#W)this.#x()};#k(Q){if(F(this,"disabled"))return!1;let Z=this.#B();if(!Z)return!1;let $=Z.getBoundingClientRect();if($.width<=0||$.height<=0)return!1;let J=this.#G,j=this.#n($),q=Q.shiftKey?0.1:0.01,_=j.px,X=j.py;switch(Q.key){case"ArrowLeft":if(!J.x)return!1;_-=q;break;case"ArrowRight":if(!J.x)return!1;_+=q;break;case"ArrowUp":if(!J.y)return!1;X-=q;break;case"ArrowDown":if(!J.y)return!1;X+=q;break;case"Home":if(J.x)_=0;if(J.y)X=0;break;case"End":if(J.x)_=1;if(J.y)X=1;break;default:return!1}if(_=Math.max(0,Math.min(1,_)),X=Math.max(0,Math.min(1,X)),this.#E(J),J.x)this.style.left=`${Math.round(_*$.width)}px`;if(J.y)this.style.top=`${Math.round(X*$.height)}px`;this.#H();let Y={...this.#n($),shiftKey:Q.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Y})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Y})),!0}attributeChangedCallback(Q,Z,$){if(Q==="color"){if(!$||$==="false"||$==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",$);if(this.#q&&this.#W==="color"&&$)this.#q.setAttribute("value",$);this.#V()}if(Q==="drag")this.#T();if(Q==="hit-area")this.#P();if(Q==="selected")this.#r();if(Q==="selected"||Q==="disabled"||Q==="type"||Q==="tip"||Q==="aria-label"||Q==="aria-labelledby")this.#f();if(Q==="value"&&!this.#j&&!this.#Z)this.#D($);if(Q==="tip"){if(this.#t(),this.#W)this.#u(),this.#s()}}#T(){if(this.#K&&!this.#$)this.#$=(Q)=>this.#g(Q),this.addEventListener("pointerdown",this.#$);else if(!this.#K&&this.#$)this.#y()}#f(){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex",Q?"-1":"0");else if(Q)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",Q?"true":"false"),this.setAttribute("aria-pressed",Z?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let $=this.#W||this.getAttribute("type")||"handle";this.setAttribute("aria-label",$==="color"?"Color handle":$==="add"?"Add handle":$==="remove"?"Remove handle":"Handle")}}#y(){if(this.#J?.(),this.#J=null,this.#$)this.removeEventListener("pointerdown",this.#$),this.#$=null;this.#Z=!1,this.#Q=!1}#g(Q){if(!this.#K||F(this,"disabled"))return;Q.preventDefault();let Z=this.#B();if(!Z)return;this.#J?.(),this.#Z=!0;let $=this.#G,J=null,j=this.getBoundingClientRect(),q=j.left+j.width/2,_=j.top+j.height/2,X=Q.clientX-q,Y=Q.clientY-_,K=Q.clientX,G=Q.clientY,N=3,W=(T,R,A=!1)=>{let M=Z.getBoundingClientRect();J=M;let E=this.#n(M),k=T-X-M.left,S=R-Y-M.top,x=Math.max(0,Math.min(M.width,k)),y=Math.max(0,Math.min(M.height,S)),m=M.width>0?$.x?x/M.width:E.px:0.5,d=M.height>0?$.y?y/M.height:E.py:0.5;if(this.#L(A)){if($.x)m=this.#F(m);if($.y)d=this.#F(d);if($.x&&$.y){let t=this.#z(m,d);m=t.x,d=t.y}}if(this.#E($),$.x)this.style.left=`${Math.round(Math.max(0,Math.min(M.width,m*M.width)))}px`;if($.y)this.style.top=`${Math.round(Math.max(0,Math.min(M.height,d*M.height)))}px`},O=(T)=>{if(!this.#Z)return;if(!this.#Q){let R=T.clientX-K,A=T.clientY-G;if(R*R+A*A<N*N)return;if(this.#p(),this.classList.add("dragging"),this.style.cursor="grabbing",!F(this,"selected"))this.select()}this.#Q=!0,W(T.clientX,T.clientY,T.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#n(J),shiftKey:T.shiftKey}}))},B=(T)=>{if(L(),this.#Q){W(T.clientX,T.clientY,T.shiftKey),this.#H(),this.#D(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#n(J)}));let R=(A)=>{A.stopPropagation(),A.preventDefault()};this.addEventListener("click",R,{capture:!0,once:!0})}else this.#H();this.#Q=!1},L=()=>{if(window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",B),this.#Z=!1,this.style.cursor="",this.classList.remove("dragging"),this.#J===L)this.#J=null};this.#J=L,window.addEventListener("pointermove",O),window.addEventListener("pointerup",B)}showColorTip(){if(!this.#W)return;if(this.#q){this.#q.style.display="";return}this.#s()}hideColorTip(){if(!this.#q)return;this.#q.style.display="none"}#h(Q=this.getAttribute("color")){let Z={color:"#D9D9D9",opacity:100},$=String(Q||"").trim();if(!$)return Z;let J=(q)=>{let _=q.replace("#","").trim();if(_.length===3||_.length===4){let[X,Y,K,G]=_;return{color:`#${X}${X}${Y}${Y}${K}${K}`.toUpperCase(),opacity:G?Math.round(parseInt(`${G}${G}`,16)/255*100):100}}if(_.length===6||_.length===8)return{color:`#${_.slice(0,6)}`.toUpperCase(),opacity:_.length===8?Math.round(parseInt(_.slice(6,8),16)/255*100):100};return Z},j=(q,_,X)=>{let Y=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${Y(q)}${Y(_)}${Y(X)}`.toUpperCase()};if($.startsWith("#"))return J($);try{let{ctx:q}=O0(1,1);q.fillStyle="#000000",q.fillStyle=$;let _=q.fillStyle;if(_.startsWith("#"))return J(_);let X=_.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(X)return{color:j(X[1],X[2],X[3]),opacity:X[4]!==void 0?Math.round(parseFloat(X[4])*100):100}}catch{}return Z}#w(){let{color:Q,opacity:Z}=this.#h();return JSON.stringify(Z<100?{type:"solid",color:Q,opacity:Z}:{type:"solid",color:Q})}#V(){if(!this.#_)return;this.#_.setAttribute("value",this.#w())}#b(){if(!o())return null;if(this.#_)return this.#_;let Q=document.createElement("fig-fill-picker");Q.setAttribute("mode","solid"),Q.setAttribute("alpha","true"),Q.setAttribute("dialog-offset","8 8"),Q.setAttribute("value",this.#w()),Q.anchorElement=this;let Z=document.createElement("span");return Z.hidden=!0,Q.appendChild(Z),Q.addEventListener("input",this.#i),Q.addEventListener("change",this.#Z0),Q.addEventListener("close",this.#l),this.appendChild(Q),this.#_=Q,Q}#x(){if(F(this,"disabled"))return;let Q=this.#b();if(!Q){this.#v();return}this.setAttribute("selected",""),this.#V(),Q.open()}#u(){if(!this.#_)return;this.#_.removeEventListener("input",this.#i),this.#_.removeEventListener("change",this.#Z0),this.#_.removeEventListener("close",this.#l),this.#_.close(),this.#_.remove(),this.#_=null,this.removeAttribute("selected")}#m(){if(this.#Y)return this.#Y;let Q=document.createElement("input");return Q.type="color",Q.tabIndex=-1,Q.setAttribute("aria-hidden","true"),Q.style.position="fixed",Q.style.inlineSize="1px",Q.style.blockSize="1px",Q.style.opacity="0",Q.style.pointerEvents="none",Q.addEventListener("input",this.#q0),Q.addEventListener("change",this.#e),this.appendChild(Q),this.#Y=Q,Q}#v(){let Q=this.#m(),{color:Z}=this.#h();Q.value=Z,this.setAttribute("selected",""),Q.click()}#d(){if(!this.#Y)return;this.#Y.removeEventListener("input",this.#q0),this.#Y.removeEventListener("change",this.#e),this.#Y.remove(),this.#Y=null}#p(){if(this.getAttribute("type")!=="color")return;this.#_?.close()}#s(){let Q=this.#W;if(!Q)return;if(this.#q)return;let Z=document.createElement("fig-color-tip");if(Q==="add"||Q==="remove")Z.setAttribute("control",Q);else Z.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Z.setAttribute("alpha","true");Z.addEventListener("input",this.#J0),Z.addEventListener("change",this.#$0),Z.addEventListener("add",this.#a),Z.addEventListener("remove",this.#a),this.appendChild(Z),this.#q=Z,this.#r()}#t(){if(!this.#q)return;this.#q.removeEventListener("input",this.#J0),this.#q.removeEventListener("change",this.#$0),this.#q.removeEventListener("add",this.#a),this.#q.removeEventListener("remove",this.#a),this.#q.remove(),this.#q=null}#r(){if(!this.#q||this.#W!=="color")return;let Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#q.toggleAttribute("selected",Q)}#c(Q,Z){if(Z===void 0||Z>=100)return Q;let{r:$,g:J,b:j}=r(Q);return`rgba(${$}, ${J}, ${j}, ${Z/100})`}#o(Q){if(!Q?.color)return null;let Z=Q.opacity!==void 0?Q.opacity:Q.alpha!==void 0?Math.round(Q.alpha*100):void 0;return{color:Q.color,opacity:Z}}#i=(Q)=>{Q.stopPropagation();let Z=this.#o(Q.detail);if(!Z)return;this.setAttribute("color",this.#c(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#Z0=(Q)=>{Q.stopPropagation();let Z=this.#o(Q.detail);if(!Z)return;this.setAttribute("color",this.#c(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#j0(Q){let{opacity:Z}=this.#h();return Z<100?{color:Q,opacity:Z}:{color:Q}}#q0=(Q)=>{Q.stopPropagation();let Z=this.#j0(Q.target.value);this.setAttribute("color",this.#c(Z.color,Z.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Z}))};#e=(Q)=>{Q.stopPropagation();let Z=this.#j0(Q.target.value);this.setAttribute("color",this.#c(Z.color,Z.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Z}))};#l=()=>{this.removeAttribute("selected")};#J0=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#c(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#$0=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",this.#c(Q.detail.color,Q.detail.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{color:Q.detail.color,opacity:Q.detail.opacity}}))};#a=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#n(Q){let Z=Q||this.#B()?.getBoundingClientRect();if(!Z)return{x:0,y:0,px:0,py:0};let $=this.getBoundingClientRect(),J=this.offsetWidth/2,j=this.offsetHeight/2,q=$.left-Z.left,_=$.top-Z.top,X=q+J,Y=_+j,K=Z.width>0?X/Z.width:0,G=Z.height>0?Y/Z.height:0;return{x:q,y:_,px:K,py:G}}}z("fig-handle",C1);class k1 extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="disabled")this.#Z()}#Z(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}z("fig-menu-item",k1);class S1 extends HTMLElement{static get observedAttributes(){return["label"]}get label(){return this.getAttribute("label")??""}set label(Q){if(Q==null||Q==="")this.removeAttribute("label");else this.setAttribute("label",String(Q))}connectedCallback(){this.#Z()}attributeChangedCallback(Q,Z,$){if(Z===$)return;this.#Z()}#Z(){if(!this.hasAttribute("role"))this.setAttribute("role","separator");let Q=this.label.trim();if(Q)this.setAttribute("aria-label",Q);else this.removeAttribute("aria-label")}}z("fig-menu-separator",S1);class f1 extends HTMLElement{#Z=null;#Q=null;#$=null;#J=null;#j=null;#q=null;#_=null;#Y=null;#X;#W;#N;#K;#G;#U=this.#P.bind(this);#L=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open","trigger"]}constructor(){super();this.#X=this.#y.bind(this),this.#W=this.#g.bind(this),this.#N=this.#w.bind(this),this.#K=this.#V.bind(this),this.#G=this.#b.bind(this)}get value(){return this.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q){if(this.#f())return;this.setAttribute("open","")}else this.removeAttribute("open")}connectedCallback(){if(this.#F(),this.#B(),this.#M(),this.#D(),this.#O(),this.#H(),this.#T(),this.open)this.#u()}disconnectedCallback(){if(this.#E(),this.#R(),document.removeEventListener("keydown",this.#K,!0),this.#j)this.#j.disconnect(),this.#j=null;if(this.#Z){this.#Z.removeEventListener("close",this.#G);let Q=Array.from(this.#Q?.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator")??[]);for(let Z of Q)this.insertBefore(Z,this.#Z);this.#Z.remove(),this.#Z=null,this.#Q=null}}attributeChangedCallback(Q,Z,$){if(Z===$)return;if(Q==="open"){if($===null||$==="false")this.#m();else{if(this.#f()){this.removeAttribute("open");return}this.#u()}return}if(Q==="disabled"){this.#T();return}if(this.#Z&&(Q==="position"||Q==="offset"||Q==="closedby"))if($!==null)this.#Z.setAttribute(Q,$);else this.#Z.removeAttribute(Q)}#F(){this.#$=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-menu-separator)")}#z(){return(this.getAttribute("trigger")||"").toLowerCase()==="contextmenu"||this.hasAttribute("contextmenu")}#B(){this.#Z=document.createElement("dialog",{is:"fig-popup"}),this.#Z.setAttribute("is","fig-popup"),this.#Z.classList.add("fig-menu-popup"),this.#Z.setAttribute("theme","menu"),this.#Z.setAttribute("role","menu"),this.#Z.setAttribute("id",this.#Z.getAttribute("id")||g());let Q=this.getAttribute("position")||"bottom left";this.#Z.setAttribute("position",Q);let Z=this.getAttribute("offset");if(Z)this.#Z.setAttribute("offset",Z);let $=this.getAttribute("closedby");if($)this.#Z.setAttribute("closedby",$);if(this.#$)this.#Z.anchor=this.#$;this.#Q=document.createElement("div"),this.#Q.className="fig-menu-options",this.#Q.setAttribute("role","presentation"),this.#Z.appendChild(this.#Q),this.#Z.addEventListener("close",this.#G),this.appendChild(this.#Z)}#M(){if(!this.#Q)return;let Q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-menu-separator"));for(let Z of Q)this.#Q.appendChild(Z)}#D(){if(this.addEventListener("keydown",this.#K),this.#$)this.#$.addEventListener("click",this.#X),this.#$.addEventListener("contextmenu",this.#W),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded","false"),this.#$.setAttribute("aria-controls",this.#Z.getAttribute("id"));if(this.#Z)this.#Z.addEventListener("click",this.#N),this.#Z.addEventListener("keydown",this.#K)}#E(){if(this.removeEventListener("keydown",this.#K),this.#$)this.#$.removeEventListener("click",this.#X),this.#$.removeEventListener("contextmenu",this.#W);if(this.#Z)this.#Z.removeEventListener("click",this.#N),this.#Z.removeEventListener("keydown",this.#K)}#H(){this.#j=new MutationObserver((Q)=>{for(let Z of Q)for(let $ of Z.addedNodes){if($.nodeType!==1||$===this.#Z)continue;if(($.tagName==="FIG-MENU-ITEM"||$.tagName==="FIG-MENU-SEPARATOR")&&$.parentElement===this)this.#Q?.appendChild($);else if(!this.#$&&$.parentElement===this){if(this.#F(),this.#$)this.#$.addEventListener("click",this.#X),this.#$.addEventListener("contextmenu",this.#W),this.#$.setAttribute("aria-haspopup","menu"),this.#$.setAttribute("aria-expanded","false"),this.#$.setAttribute("aria-controls",this.#Z.getAttribute("id")),this.#Z.anchor=this.#$,this.#T()}}this.#P()}),this.#j.observe(this,{childList:!0})}#O(){if(!this.#Q)return;this.#C(),this.#Q.addEventListener("scroll",this.#U,{passive:!0}),this.#q?.disconnect(),this.#q=new ResizeObserver(()=>this.#P()),this.#q.observe(this.#Q),requestAnimationFrame(()=>this.#P())}#R(){this.#Q?.removeEventListener("scroll",this.#U),this.#q?.disconnect(),this.#q=null,this.#S()}#P(){return a(this.#Q,this.#Q,"y")}#C(){if(this.#_&&this.#Y&&this.#Q?.contains(this.#_)&&this.#Q?.contains(this.#Y))return;this.#S();let Q=X0({owner:"menu",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>i(this.#Q,"y",-1),onEnd:()=>i(this.#Q,"y",1)});this.#_=Q.start,this.#Y=Q.end,this.#Q.prepend(this.#_),this.#Q.append(this.#Y)}#S(){this.#_?.remove(),this.#Y?.remove(),this.#_=null,this.#Y=null,this.#Q?.classList.remove("overflow-start","overflow-end")}#I(){if(!this.#Q)return[];return Array.from(this.#Q.querySelectorAll("fig-menu-item")).filter((Q)=>!Q.hasAttribute("disabled")||Q.getAttribute("disabled")==="false")}#A(){let Q=this.#I();if(!Q.length){this.#L=-1;return}let Z=document.activeElement,$=Q.findIndex((J)=>J===Z||J.contains(Z));this.#L=$>=0?$:-1}#k(Q){let Z=this.#I();if(!Z.length)return;let $=(Q+Z.length)%Z.length;this.#L=$;let J=Z[$];J.focus(),S0(this.#Q,J,"y")}#T(){let Q=this.#f();if(Q)if(this.open)this.removeAttribute("open");else this.#m();if(!this.#$)return;if(Q)this.#$.setAttribute("disabled",""),this.#$.setAttribute("aria-disabled","true"),this.#$.setAttribute("aria-expanded","false");else this.#$.removeAttribute("disabled"),this.#$.removeAttribute("aria-disabled")}#f(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#y(Q){if(this.#z())return;if(this.#f())return;Q.stopPropagation();let Z=this.#Z?.matches?.(":open")??!1;if(this.open&&!Z)this.removeAttribute("open");if(this.open&&Z)this.open=!1;else{if(this.#Z&&this.#$)this.#Z.anchor=this.#$;this.open=!0}}#g(Q){if(!this.#z())return;if(this.#f())return;Q.preventDefault(),Q.stopPropagation(),this.#h(Q.clientX,Q.clientY)}#h(Q,Z){let $=!1,J=0,j=()=>{window.clearTimeout(J),window.removeEventListener("pointerup",q,!0),window.removeEventListener("pointercancel",_,!0)},q=()=>{if($)return;$=!0,j(),requestAnimationFrame(()=>this.showAt(Q,Z))},_=()=>{if($)return;$=!0,j()};window.addEventListener("pointerup",q,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),J=window.setTimeout(q,180)}#w(Q){if(this.#f())return;let Z=Q.target.closest("fig-menu-item");if(!Z)return;if(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false")return;this.#x(Z)}#V(Q){if(this.#f())return;if(Q.currentTarget===document&&Q.key!=="Escape")return;if(Q.currentTarget===this&&this.#Z?.contains(Q.target))return;if(!this.open||!this.#Z?.matches?.(":open")){if(this.#$?.contains(Q.target)&&(Q.key==="ArrowDown"||Q.key==="Enter"||Q.key===" ")){if(Q.preventDefault(),this.#Z&&this.#$)this.#Z.anchor=this.#$;this.open=!0,requestAnimationFrame(()=>this.#k(0))}return}let Z=this.#I();if(!Z.length)return;switch(Q.key){case"ArrowDown":{Q.preventDefault(),this.#A(),this.#k(this.#L+1);break}case"ArrowUp":{Q.preventDefault(),this.#A(),this.#k(this.#L-1);break}case"Home":{Q.preventDefault(),this.#k(0);break}case"End":{Q.preventDefault(),this.#k(Z.length-1);break}case"Escape":{Q.preventDefault(),this.open=!1,this.#$?.focus();break}case"Enter":case" ":{this.#A();let $=Z[this.#L];if(!$)return;Q.preventDefault(),this.#x($);break}}}#b(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#$)this.#$.setAttribute("aria-expanded","false"),this.#$.focus();this.#L=-1}#x(Q){let Z=Q.getAttribute("value")||Q.textContent.trim();this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("change",{detail:{value:Z,item:Q},bubbles:!0})),this.open=!1}showAt(Q,Z){if(this.#f())return;if(this.#J={getBoundingClientRect:()=>({width:0,height:0,top:Z,right:Q,bottom:Z,left:Q,x:Q,y:Z})},this.#Z)this.#Z.anchor=this.#J;if(this.open)this.open=!1;requestAnimationFrame(()=>{if(this.#f())return;this.open=!0})}#u(){if(!this.#Z||this.#f()){if(this.hasAttribute("open"))this.removeAttribute("open");return}if(this.#Z.open=!0,document.addEventListener("keydown",this.#K,!0),this.#$)this.#$.setAttribute("aria-expanded","true");this.#L=-1,requestAnimationFrame(()=>{if(this.#P(),!this.#$?.matches?.(":focus-visible"))return;this.#k(0)})}#m(){if(!this.#Z)return;document.removeEventListener("keydown",this.#K,!0),this.#Z.open=!1,this.#$?.setAttribute("aria-expanded","false")}}z("fig-menu",f1);
|