@rogieking/figui3 6.37.0 → 6.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/fig.js +1 -1
  2. package/fig.js +8 -1
  3. package/package.json +1 -1
package/dist/fig.js CHANGED
@@ -34,7 +34,7 @@ var hq=(q,Q)=>()=>(q&&(Q=q(q=0)),Q);var vq={};var P0=hq(()=>{/*! Vendored from @
34
34
  <${Z} class="fig-button-control"${$}>
35
35
  <slot></slot>
36
36
  </${Z}>
37
- `,this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.button.addEventListener("click",this.#J),this.button.addEventListener("focus",this.#N),this.button.addEventListener("blur",this.#_)}let q=this.shadowRoot.querySelector("slot");q?.removeEventListener("slotchange",this.#j),q?.addEventListener("slotchange",this.#j),this.removeEventListener("keydown",this.#$),this.addEventListener("keydown",this.#$),this.#Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#z()}get type(){return this.getAttribute("type")||"button"}set type(q){this.setAttribute("type",q)}get selected(){return this.#Q}set selected(q){this.setAttribute("selected",q)}#W(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#Y(){if(this.#W())return;if(this.type==="toggle")if(this.selected)this.removeAttribute("selected");else this.setAttribute("selected","");if(this.type==="submit"){let q=this.closest("form");if(q)if(typeof q.requestSubmit==="function")q.requestSubmit();else q.submit()}if(this.type==="link"){let q=this.getAttribute("href"),Q=this.getAttribute("target");if(q)if(Q)window.open(q,Q);else window.location.href=q}}#G(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#K(){let q=this.#G();if(q instanceof HTMLSelectElement)return q;if(q?.tagName==="FIG-DROPDOWN")return q.select||q.querySelector?.("select")||null;return null}#X(q){if(this.type!=="select")return;if(q.key!=="Enter")return;if(q.altKey||q.ctrlKey||q.metaKey||q.shiftKey)return;let Q=this.#K();if(!Q||Q.disabled||Q.multiple)return;if(typeof Q.showPicker!=="function")return;q.preventDefault();try{Q.showPicker()}catch{}}#U(){if(!this.button)return;if(this.type!=="toggle"){this.removeAttribute("aria-pressed"),this.button.removeAttribute("aria-pressed");return}let q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.setAttribute("aria-pressed",q?"true":"false"),this.button.setAttribute("aria-pressed",q?"true":"false")}#L(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#Z.forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.button.removeAttribute(q);else this.button.setAttribute(q,Q)})}#z(){if(!this.button)return;let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=q,this.button instanceof HTMLButtonElement)this.button.disabled=q,this.button.type="button",this.button.setAttribute("type","button");this.#M(),this.#L(),this.#U()}#M(){let q=this.#G();if(!q)return;if(this.#W()){if(!this.#q.has(q))this.#q.set(q,q.hasAttribute("disabled")&&q.getAttribute("disabled")!=="false");q.setAttribute("disabled","")}else if(this.#q.has(q)){let Z=this.#q.get(q);if(this.#q.delete(q),Z)q.setAttribute("disabled","");else q.removeAttribute("disabled")}}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"type":{let $=(J)=>J==="select"||J==="upload";if($(Q||"button")!==$(Z||"button")){this.button=null,this.connectedCallback();break}this.#z();break}case"disabled":this.#z();break;case"selected":this.#Q=Z!==null&&Z!=="false",this.#U();break;default:this.#L();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#$),this.shadowRoot?.querySelector("slot")?.removeEventListener("slotchange",this.#j)}}M("fig-button",x0);class w0 extends HTMLElement{#Q="Menu";#q=null;#Z;#$;#J;get label(){return this.#Q}set label(q){this.#Q=q}#j;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#Z=this.#Y.bind(this),this.#$=this.#G.bind(this),this.#J=this.#K.bind(this),this.#j=this.slotChange.bind(this)}#N(){this.select.addEventListener("input",this.#Z),this.select.addEventListener("change",this.#$),this.select.addEventListener("keydown",this.#J)}#_(q){if(!q||!(q instanceof Element))return!1;return!!q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#W(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){if(this.type=this.getAttribute("type")||"select",this.#Q=this.getAttribute("label")||this.#Q,this.select.setAttribute("aria-label",this.#Q),this.#X(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#j),this.optionsSlot.addEventListener("slotchange",this.#j),this.select.removeEventListener("input",this.#Z),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#J),this.#N()}slotChange(){let q=this.hasAttribute("value"),Q=this.select.options.length>0&&this.select.selectedIndex>=0,Z=q?this.getAttribute("value"):this.type==="dropdown"?this.#q:Q?this.select.value:null;while(this.select.firstChild)this.select.firstChild.remove();if(this.type==="dropdown"){let $=document.createElement("option");$.setAttribute("hidden","true"),$.setAttribute("selected","true"),$.selected=!0,this.select.appendChild($)}if(this.optionsSlot.assignedNodes().forEach(($)=>{if($.nodeName==="OPTION"||$.nodeName==="OPTGROUP")this.select.appendChild($.cloneNode(!0))}),Z!==null)this.#U(Z);if(this.type==="dropdown")this.select.selectedIndex=-1}#Y(q){q.stopPropagation();let Q=q.target.selectedOptions?.[0];if(this.#_(Q)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#W();return}let Z=q.target.value;if(this.type==="dropdown")this.#q=Z;this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}#G(q){q.stopPropagation();let Q=q.target.selectedOptions?.[0];if(this.#_(Q)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#W();return}let Z=this.type==="dropdown"?this.#q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}#K(q){if(this.closest('fig-button[type="select"]'))return;if(q.key!=="Enter"||q.defaultPrevented)return;if(q.altKey||q.ctrlKey||q.metaKey||q.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(typeof this.select.showPicker!=="function")return;q.preventDefault();try{this.select.showPicker()}catch{}}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#q;return this.select?.value}set value(q){if(this.type==="dropdown")this.#q=q;this.setAttribute("value",q)}static get observedAttributes(){return["value","type","label","disabled"]}#X(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=q}#U(q){if(this.type==="dropdown")return;if(this.select)this.select.value=q??""}attributeChangedCallback(q,Q,Z){if(q==="value")this.#U(Z);if(q==="type"){if(this.type=Z||"select",this.isConnected)this.slotChange()}if(q==="label")this.#Q=Z||"Menu",this.select.setAttribute("aria-label",this.#Q);if(q==="disabled")this.#X()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#j),this.select.removeEventListener("input",this.#Z),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#J)}}M("fig-dropdown",w0);class A extends HTMLElement{static#Q=0;static#q=0;static#Z=1000;static#$=null;static#J=!1;static#j=new Set;#N;#_;#W;#Y;#G;#K;#X;#U;#L;#z;#M;#B;#R=null;#H=null;#D=null;#T=!1;#A;#O=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(q)?q:500,this.#N=this.#x.bind(this),this.#_=this.hidePopupOutsideClick.bind(this),this.#W=this.showDelayedPopup.bind(this),this.#Y=this.#S.bind(this),this.#G=()=>{if(!this.#T)this.showDelayedPopup()},this.#K=()=>{this.#T=!1,this.hidePopup()},this.#X=this.#w.bind(this),this.#U=this.#y.bind(this),this.#L=this.#u.bind(this),this.#z=this.#b.bind(this),this.#B=this.#E.bind(this),this.#M=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(A.#v(),this.setup(),this.#C(),this.setupEventListeners(),this.#R=this.closest("dialog"),this.#R)this.#R.addEventListener("close",this.#M)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#V(),this.#k(),document.removeEventListener("mousedown",this.#N,!0),document.removeEventListener("keydown",this.#B,!0),this.#R)this.#R.removeEventListener("close",this.#M),this.#R=null;if(this.action==="click")document.body.removeEventListener("click",this.#_);if(clearTimeout(this.#A),A.#$===this)A.#$=null}#P(){return this.firstElementChild}#k(){this.#D?.disconnect(),this.#D=null}#C(){if(this.#V(),this.action==="manual")return;let q=this.#P();if(!q){if(!this.#D&&typeof MutationObserver<"u")this.#D=new MutationObserver(()=>{if(this.#P())this.#k(),this.#C()}),this.#D.observe(this,{childList:!0});return}if(this.#H=q,this.action==="hover"){if(!this.isTouchDevice())q.addEventListener("pointerenter",this.#W),q.addEventListener("pointerleave",this.#Y);q.addEventListener("touchstart",this.#X,{passive:!0}),q.addEventListener("touchmove",this.#U,{passive:!0}),q.addEventListener("touchend",this.#L,{passive:!0}),q.addEventListener("touchcancel",this.#z,{passive:!0}),q.addEventListener("focus",this.#G),q.addEventListener("blur",this.#K)}else if(this.action==="click")q.addEventListener("click",this.#W),q.addEventListener("touchstart",this.#W,{passive:!0})}#V(){let q=this.#H;if(!q)return;if(this.action==="hover")q.removeEventListener("pointerenter",this.#W),q.removeEventListener("pointerleave",this.#Y),q.removeEventListener("touchstart",this.#X),q.removeEventListener("touchmove",this.#U),q.removeEventListener("touchend",this.#L),q.removeEventListener("touchcancel",this.#z),q.removeEventListener("focus",this.#G),q.removeEventListener("blur",this.#K);else if(this.action==="click")q.removeEventListener("click",this.#W),q.removeEventListener("touchstart",this.#W);this.#H=null}setup(){this.style.display="contents"}render(){this.destroy();let q=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Q=document.createElement("span");if(this.popup=document.createElement("dialog",{is:"fig-popup"}),this.popup.setAttribute("is","fig-popup"),this.popup.setAttribute("variant","tooltip"),this.popup.setAttribute("data-tooltip-managed",""),this.popup.setAttribute("role","tooltip"),this.popup.setAttribute("closedby","closerequest"),q)this.popup.setAttribute("popover","manual");let Z=h();this.popup.setAttribute("id",Z);let $=this.getAttribute("theme");if($)this.popup.setAttribute("theme",$);let J=this.getAttribute("pointer");if(J!==null)this.popup.setAttribute("pointer",J);if(this.popup.append(Q),Q.innerText=this.getAttribute("text")??"",this.firstElementChild){let j=new Set((this.firstElementChild.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));j.add(Z),this.firstElementChild.setAttribute("aria-describedby",[...j].join(" "))}if(q)(j0()??document.body).append(this.popup);else{let j=this.closest("dialog");if(j&&j.open)j.append(this.popup);else(j0()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.#F(this.popup.id),this.popup.hidePopup?.(),this.popup.remove(),this.popup=null}#F(q){let Q=this.firstElementChild;if(!Q||!q)return;let Z=Q.getAttribute("aria-describedby");if(!Z)return;let $=Z.split(/\s+/).filter((J)=>J&&J!==q).join(" ");if($)Q.setAttribute("aria-describedby",$);else Q.removeAttribute("aria-describedby")}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#_);document.addEventListener("mousedown",this.#N,!0),document.addEventListener("keydown",this.#B,!0)}get#f(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#I(){let q=Date.now(),Q=A.#Z;if(this.action==="hover"&&A.#$)return!0;if(A.#Q&&q-A.#Q<Q)return!0;if(A.#q&&q-A.#q<Q)return!0;return!1}showDelayedPopup(){if(this.#f)return;if(clearTimeout(this.timeout),this.#I()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#R&&!this.#R.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&A.#$&&A.#$!==this)A.#$.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")A.#$=this;A.#Q=Date.now()}hidePopup(){if(this.#f)return;clearTimeout(this.timeout),clearTimeout(this.#A);let q=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,A.#$===this)A.#$=null;if(q)A.#q=Date.now()}hidePopupOutsideClick(q){if(this.isOpen&&!this.popup.contains(q.target))this.hidePopup()}#S(q){if(!this.#O)this.hidePopup()}#w(q){if(this.action==="hover")this.#O=!0,clearTimeout(this.#A),this.showDelayedPopup()}#y(q){if(this.action==="hover"&&this.#O)clearTimeout(this.#A),this.#A=setTimeout(()=>{this.#O=!1,this.hidePopup()},150)}#u(q){if(this.action==="hover"&&this.#O)clearTimeout(this.#A),this.#A=setTimeout(()=>{this.#O=!1,this.hidePopup()},300)}#b(q){if(this.action==="hover"&&this.#O)this.#O=!1,clearTimeout(this.#A),this.hidePopup()}#E(q){if(!this.isOpen&&!this.popup||q.key!=="Escape")return;q.preventDefault(),this.hidePopup(),this.firstElementChild?.focus?.()}static get observedAttributes(){return["action","delay","open","pointer","show","text","theme"]}get text(){return this.getAttribute("text")??""}set text(q){this.setAttribute("text",q)}#h(q){if(!this.popup)return;let Q=this.popup.firstElementChild??this.popup.firstChild;if(!Q)return;Q.innerText=q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(q){if(q===!1||q==="false"||q===null)this.removeAttribute("open");else this.setAttribute("open","true")}attributeChangedCallback(q,Q,Z){if(q==="action"){if(this.#V(),Q==="click")document.body?.removeEventListener("click",this.#_);if(this.action=Z||"hover",this.isConnected){if(this.#C(),this.action==="click")document.body?.addEventListener("click",this.#_)}}if(q==="delay"){let $=parseInt(Z);this.delay=!isNaN($)?$:500}if(q==="open")if(Z!==null&&Z!=="false")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(q==="show")if(Z!==null&&Z!=="false")this.showPopup();else this.hidePopup();if(q==="text")this.#h(Z??"");if(q==="pointer"){if(this.popup)if(Z!==null)this.popup.setAttribute("pointer",Z);else this.popup.removeAttribute("pointer")}if(q==="theme"){if(this.popup)if(Z)this.popup.setAttribute("theme",Z);else this.popup.removeAttribute("theme")}}#x(q){if(!this.isOpen)return;let Q=q.target;if(this.popup&&this.popup.contains(Q))return;if(Q.tagName==="SELECT"||Q.hasAttribute("popover")||Q.closest("dialog"))this.hidePopup()}static#v(){if(A.#J)return;A.#J=!0;let q=()=>{A.dismissHoverTooltips()},Q=()=>{A.#o()};document.documentElement.addEventListener("mouseleave",q),document.addEventListener("mouseout",(Z)=>{if(Z.relatedTarget)return;q()}),document.addEventListener("scroll",Q,{capture:!0,passive:!0}),window.addEventListener("scroll",Q,{passive:!0}),window.visualViewport?.addEventListener("scroll",Q,{passive:!0}),window.visualViewport?.addEventListener("resize",Q,{passive:!0});try{let Z=window.frameElement;if(Z)Z.addEventListener("mouseleave",q)}catch{}window.addEventListener("message",(Z)=>{if(Z?.data?.type!=="figui:dismiss-tooltips")return;if(window.parent!==window&&Z.source!==window.parent)return;q()})}static dismissHoverTooltips(){for(let q of document.querySelectorAll("fig-tooltip")){if(!(q instanceof A))continue;if(q.action!=="hover")continue;if(q.#f)continue;if(q.#T=!0,setTimeout(()=>{let Q=q.#H;if(Q!==document.activeElement&&!Q?.matches?.(":focus, :focus-within"))q.#T=!1},0),q.isOpen||q.timeout)q.hidePopup()}for(let q of Array.from(A.#j))A.hide(q)}static#g=new WeakMap;static#o(){for(let q of document.querySelectorAll("fig-tooltip")){if(!(q instanceof A))continue;if(q.#f)continue;if(q.isOpen||q.timeout)q.hidePopup()}for(let q of Array.from(A.#j))A.hide(q)}static show(q,Q,Z={}){A.#v(),A.hide(q);let $=Z.delay??500,j=Date.now()-A.#Q<A.#Z?0:$,_={timeout:null,popup:null};A.#g.set(q,_),A.#j.add(q),_.timeout=setTimeout(()=>{let W=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,N=document.createElement("dialog",{is:"fig-popup"});if(N.setAttribute("is","fig-popup"),N.setAttribute("variant","tooltip"),N.setAttribute("data-tooltip-managed",""),N.setAttribute("role","tooltip"),N.setAttribute("closedby","closerequest"),W)N.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=Q,N.append(K),W)(j0()??document.body).append(N);else{let G=q.closest?.("dialog");if(G&&G.open)G.append(N);else(j0()??document.body).append(N)}N.anchor=q,N.open=!0,_.popup=N,A.#Q=Date.now()},j)}static hide(q){let Q=A.#g.get(q);if(!Q)return;if(clearTimeout(Q.timeout),Q.popup)Q.popup.remove(),A.#q=Date.now();A.#g.delete(q),A.#j.delete(q)}}M("fig-tooltip",A);class y0 extends HTMLElement{static observedAttributes=["position","tail"];#Q=null;#q=null;#Z=null;connectedCallback(){this.#Q=this.textContent,u(this,()=>{this.#$(),this.#J()})}disconnectedCallback(){this.#j()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(this.#Q===null)return;this.#$()}#$(){let q=this.getAttribute("position")||"right",Q=this.#Q||"";if(q==="middle"){let Z=this.getAttribute("tail"),$;if(Z){let _=Q.lastIndexOf(Z);$=_>0?_:Math.ceil(Q.length/2)}else $=Math.ceil(Q.length/2);this.innerHTML="";let J=document.createElement("span");J.className="start",J.textContent=Q.slice(0,$);let j=document.createElement("span");j.className="end",j.textContent=Q.slice($),this.appendChild(J),this.appendChild(j)}else this.textContent=Q}#J(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#q=()=>{if(this.scrollWidth<=this.clientWidth)return;A.show(this,this.#Q)},this.#Z=()=>{A.hide(this)},this.addEventListener("pointerenter",this.#q),this.addEventListener("pointerleave",this.#Z)}#j(){if(this.#q)this.removeEventListener("pointerenter",this.#q);if(this.#Z)this.removeEventListener("pointerleave",this.#Z);A.hide(this)}}M("fig-truncate",y0);class b0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._isDragging=!1,this._dragPending=!1,this._dragStartPos={x:0,y:0},this._dragOffset={x:0,y:0},this._resizeObserver=null,this._mutationObserver=null,this._autoResizeRafId=0,this._offset=16,this._positionInitialized=!1,this._dragThreshold=3,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundClose=this.close.bind(this),this._boundIframeMessage=this._handleIframeMessage.bind(this),this._boundContentMutation=this._scheduleAutoResize.bind(this),this._boundContentResize=this._scheduleAutoResize.bind(this),this._boundRestoreFocus=this._restoreFocus.bind(this),this._boundIframeMouseLeave=this._handleIframeMouseLeave.bind(this),this._iframeDismissMutationObserver=null,this._previousFocus=null}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){if(this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),this.open&&!this.matches?.(":modal"))this._assignStackingOrder();u(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._setupIframeDismissListeners(),this._syncA11y()}),window.addEventListener("message",this._boundIframeMessage)}disconnectedCallback(){this._figInit(),this._removeDragListeners(),this.querySelectorAll("fig-button[close-dialog]").forEach((q)=>{q.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize(),this._teardownIframeDismissListeners(),this.removeEventListener("close",this._boundRestoreFocus)}_captureFocusBeforeOpen(){let q=document.activeElement;this._previousFocus=q instanceof HTMLElement&&q!==document.body&&!this.contains(q)?q:null}_restoreFocus(){let q=this._previousFocus;if(this._previousFocus=null,!q?.isConnected)return;let Q=document.activeElement;if(Q&&Q!==document.body&&!this.contains(Q))return;requestAnimationFrame(()=>q.focus?.())}_assignStackingOrder(){this.style.zIndex=String(E0()+1)}_clearStackingOrder(){this.style.zIndex=""}show(){return this._captureFocusBeforeOpen(),this._assignStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),A.dismissHoverTooltips(),super.show()}showModal(){return this._captureFocusBeforeOpen(),this._clearStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),A.dismissHoverTooltips(),super.showModal()}close(...q){let Q=super.close(...q);return this._clearStackingOrder(),Q}_handleIframeMouseLeave(q){let Q=q?.currentTarget;if(!(Q instanceof HTMLIFrameElement))return;try{Q.contentWindow?.postMessage({type:"figui:dismiss-tooltips"},"*")}catch{}}_syncIframeDismissListeners(){for(let q of this.querySelectorAll(":scope > iframe")){if(!(q instanceof HTMLIFrameElement))continue;if(q.dataset.figuiDismissBound==="true")continue;q.dataset.figuiDismissBound="true",q.addEventListener("mouseleave",this._boundIframeMouseLeave)}}_setupIframeDismissListeners(){if(this._syncIframeDismissListeners(),this._iframeDismissMutationObserver)return;this._iframeDismissMutationObserver=new MutationObserver(()=>{this._syncIframeDismissListeners()}),this._iframeDismissMutationObserver.observe(this,{childList:!0,subtree:!1})}_teardownIframeDismissListeners(){this._iframeDismissMutationObserver?.disconnect(),this._iframeDismissMutationObserver=null;for(let q of this.querySelectorAll(":scope > iframe"))q.removeEventListener("mouseleave",this._boundIframeMouseLeave),delete q.dataset.figuiDismissBound}_handleIframeMessage(q){if(!this.autoresize)return;let Q=q?.data;if(!Q||Q.type!=="figui:iframe-resize")return;let Z=q.source;if(!Z)return;let $=Array.from(this.querySelectorAll("iframe")).find((J)=>J.contentWindow===Z);if(!$)return;this._resizeForIframe($,Q)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let q of this.children)try{this._resizeObserver.observe(q)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((q)=>{for(let Q of q)Q.addedNodes?.forEach((Z)=>{if(Z instanceof Element&&Z.parentElement===this)try{this._resizeObserver?.observe(Z)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(q){let Q=window.getComputedStyle(this),Z=parseFloat(Q.paddingTop||"0")+parseFloat(Q.paddingBottom||"0")+parseFloat(Q.borderTopWidth||"0")+parseFloat(Q.borderBottomWidth||"0"),$=0,J=parseFloat(Q.rowGap||Q.gap||"0")||0,j=0;for(let _ of this.children){let W=_.getBoundingClientRect();if(W.height===0)continue;if(j+=1,_===q)continue;let N=window.getComputedStyle(_),K=parseFloat(N.marginTop||"0")+parseFloat(N.marginBottom||"0");$+=W.height+K}if(J&&j>1)$+=J*(j-1);return Z+$}_resizeForIframe(q,Q){if(typeof Q.height!=="number"||!(Q.height>0))return;let Z=this._computeChrome(q);this.style.height=`${Math.ceil(Q.height+Z)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){if(this.querySelector("fig-header[dialog-header]"))return;let q=document.createElement("fig-header");q.setAttribute("dialog-header",""),q.setAttribute("data-auto","");let Q=document.createElement("h3");Q.textContent=this.getAttribute("title")||"Dialog";let Z=document.createElement("fig-tooltip");Z.setAttribute("text","Close");let $=document.createElement("fig-button");$.setAttribute("variant","ghost"),$.setAttribute("icon",""),$.setAttribute("aria-label","Close dialog"),$.setAttribute("close-dialog",""),$.appendChild(c("close")),Z.appendChild($),q.appendChild(Q),q.appendChild(Z),this.prepend(q)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((q)=>{if(!q.hasAttribute("aria-label"))q.setAttribute("aria-label","Close dialog");q.removeEventListener("click",this._boundClose),q.addEventListener("click",this._boundClose)})}_syncA11y(){if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let q=this.querySelector("fig-header[dialog-header] h1, fig-header[dialog-header] h2, fig-header[dialog-header] h3, fig-header[dialog-header] h4, fig-header[dialog-header] h5, fig-header[dialog-header] h6");if(q){let Q=q.getAttribute("id")||h();q.setAttribute("id",Q),this.setAttribute("aria-labelledby",Q)}}}_applyPosition(){let q=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let Q=q.includes("top"),Z=q.includes("bottom"),$=q.includes("left"),J=q.includes("right"),j=q.includes("center")&&!Q&&!Z,_=q.includes("center")&&!$&&!J;if(Q)this.style.top=`${this._offset}px`;else if(Z)this.style.bottom=`${this._offset}px`;else if(j)this.style.top="0",this.style.bottom="0";if($)this.style.left=`${this._offset}px`;else if(J)this.style.right=`${this._offset}px`;else if(_)this.style.left="0",this.style.right="0";if(j&&_)this.style.margin="auto";else if(j)this.style.marginTop="auto",this.style.marginBottom="auto";else if(_)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let q=this.getAttribute("handle"),Q=q?this.querySelector(q):this.querySelector("fig-header, header");if(Q)Q.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}_isInteractiveElement(q){let Q=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],Z=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],$=(j)=>Q.some((_)=>j.matches?.(_))||j.tagName?.startsWith("FIG-")&&!Z.includes(j.tagName);if($(q))return!0;let J=q.parentElement;while(J&&J!==this){if($(J))return!0;J=J.parentElement}return!1}_handlePointerDown(q){if(!this.drag)return;if(this._isInteractiveElement(q.target))return;let Q=this.getAttribute("handle");if(Q&&Q.trim()){let $=this.querySelector(Q);if(!$||!$.contains(q.target))return}this._dragPending=!0,this._dragStartPos.x=q.clientX,this._dragStartPos.y=q.clientY;let Z=this.getBoundingClientRect();this._dragOffset.x=q.clientX-Z.left,this._dragOffset.y=q.clientY-Z.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}_handlePointerMove(q){if(this._dragPending&&!this._isDragging){let Q=Math.abs(q.clientX-this._dragStartPos.x),Z=Math.abs(q.clientY-this._dragStartPos.y);if(Q>this._dragThreshold||Z>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(q.pointerId),this.style.cursor="grabbing";let $=this.getBoundingClientRect();this.style.top=`${$.top}px`,this.style.left=`${$.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${q.clientX-this._dragOffset.x}px`,this.style.top=`${q.clientY-this._dragOffset.y}px`,q.preventDefault()}_handlePointerUp(q){if(this._isDragging){if(this.hasPointerCapture?.(q.pointerId))this.releasePointerCapture(q.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(q,Q,Z){if(this._figInit(),q==="autoresize"&&this.isConnected)this._syncAutoResize();if(q==="drag")if(this.drag=Z!==null&&Z!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let $=this.querySelector("fig-header, header");if($)$.style.cursor=""}if(q==="position"&&this._positionInitialized)this._applyPosition();if(q==="modal"){let $=this.modal;if(this.modal=Z!==null&&Z!=="false",this.open&&$!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(q==="closedby")this.closedby=Z||"any";if(q==="title"){let $=this.querySelector("fig-header[data-auto] h3");if($)$.textContent=Z||"Dialog";this._syncA11y()}if(q==="aria-label"||q==="aria-labelledby")this._syncA11y()}}O0("fig-dialog",b0,{extends:"dialog"});class h0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._toastVisible=!1,this._syncingOpen=!1,this._managedRole=null,this._managedLive=null,this._boundHandleClose=this.handleClose.bind(this)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast();else{if(this.getAttribute("open")==="false")this._syncingOpen=!0,this.removeAttribute("open"),this._syncingOpen=!1;this._toastVisible=!1}}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((q)=>{if(!q.hasAttribute("aria-label"))q.setAttribute("aria-label","Close notification");q.removeEventListener("click",this._boundHandleClose),q.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto";let q=Number.parseFloat(this.getAttribute("offset")),Q=Number.isFinite(q)?q:this._defaultOffset;this.style.bottom=`${Q}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let q=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger",Q=q?"alert":"status",Z=q?"assertive":"polite";if(!this.hasAttribute("role")||this.getAttribute("role")===this._managedRole)this.setAttribute("role",Q),this._managedRole=Q;if(!this.hasAttribute("aria-live")||this.getAttribute("aria-live")===this._managedLive)this.setAttribute("aria-live",Z),this._managedLive=Z;if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}startAutoClose(){this.clearAutoClose();let q=parseInt(this.getAttribute("duration")??"5000");if(q>0)this._autoCloseTimer=setTimeout(()=>this.hideToast(),q)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}_resolveAutoTheme(){if(this.getAttribute("theme")!=="auto")return;let q=getComputedStyle(document.documentElement).colorScheme||"";this.style.colorScheme=q.includes("dark")?"light":"dark"}showToast(){let q=this._toastVisible;this.syncLiveRegion(),this._resolveAutoTheme(),this._syncingOpen=!0;try{if(!this.open)this.show()}finally{this._syncingOpen=!1}if(this._toastVisible=!0,this.applyPosition(),this.startAutoClose(),!q)this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){let q=this._toastVisible||this.open;this.clearAutoClose(),this._syncingOpen=!0;try{if(this.open)this.close();else if(this.hasAttribute("open"))this.removeAttribute("open")}finally{this._syncingOpen=!1}if(this._toastVisible=!1,q)this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live"]}attributeChangedCallback(q,Q,Z){if(this._figInit(),Q===Z)return;if(!this.isConnected)return;if(this._syncingOpen)return;if(q==="offset")this.applyPosition();if(q==="open")if(Z!==null&&Z!=="false")this.showToast();else this.hideToast();if(q==="duration"&&this._toastVisible)this.startAutoClose();if(q==="theme")if(Z==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme");if(q==="theme"||q==="live")this.syncLiveRegion()}}O0("fig-toast",h0,{extends:"dialog"});class v0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;_previousFocus=null;_boundDocumentKeydown;_boundNativeClose;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(q)=>{let Q=q.target;if(this.open&&(!(Q instanceof Node)||!this.contains(Q))&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this),this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this),this._boundNativeClose=this.handleNativeClose.bind(this)}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._previousFocus>"u")this._previousFocus=null;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(q)=>{let Q=q.target;if(this.open&&(!(Q instanceof Node)||!this.contains(Q))&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this);if(typeof this._boundDocumentKeydown!=="function")this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this);if(typeof this._boundNativeClose!=="function")this._boundNativeClose=this.handleNativeClose.bind(this)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(q){if(q===!1||q==="false"||q===null){if(!(this.matches?.(":open")||this.matches?.(":popover-open"))&&!this.hasAttribute("open"))return;if(this.hidePopup(),this.hasAttribute("open"))this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(q){if(q instanceof Element)this._anchorRef=q;else if(typeof q==="string")this._anchorRef=null,this.setAttribute("anchor",q);else if(q&&typeof q.getBoundingClientRect==="function")this._anchorRef=q;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role",this.getAttribute("variant")==="tooltip"?"tooltip":"dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this.removeEventListener("close",this._boundNativeClose),this.addEventListener("close",this._boundNativeClose),requestAnimationFrame(()=>{this.setupDragListeners()}),this.open)this.showPopup();else this.hidePopup()}disconnectedCallback(){if(this.ensureInitialized(),this.teardownObservers(),this.removeDragListeners(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this.removeEventListener("close",this._boundNativeClose),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(q,Q,Z){if(this.ensureInitialized(),Q===Z)return;if(q==="open"){if(Z==="false"){this.open=!1;return}if(Z===null){this.hidePopup();return}this.showPopup();return}if(q==="drag"){if(this.drag=Z!==null&&Z!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(E0()+1),this.captureFocusBeforeOpen();let q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),Q=this.shouldAutoReposition();if(Q)this.style.visibility="hidden";if(q)try{this.showPopover()}catch($){q=!1}if(!q&&!super.open)try{this.show()}catch($){}if(Q&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.addEventListener("keydown",this._boundDocumentKeydown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let Z=this.resolveAnchor();if(Z?.classList)Z.classList.add("has-popup-open");if(this.getAttribute("variant")!=="tooltip")A.dismissHoverTooltips()}hidePopup(){let q=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),Q=this.resolveAnchor();if(Q?.classList)Q.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch(Z){}if(this.matches?.(":open"))try{this.close()}catch(Z){}if(q)this.restoreFocusAfterClose()}shouldRestoreFocus(){return this.getAttribute("variant")!=="tooltip"}captureFocusBeforeOpen(){if(!this.shouldRestoreFocus())return;let q=document.activeElement;this._previousFocus=q instanceof HTMLElement&&q!==document.body&&!this.contains(q)?q:null}restoreFocusAfterClose(){if(!this.shouldRestoreFocus()){this._previousFocus=null;return}let q=this.resolveAnchor(),Q=this._previousFocus?.isConnected?this._previousFocus:q instanceof HTMLElement?q:null;if(this._previousFocus=null,!Q?.isConnected)return;let Z=document.activeElement;if(Z&&Z!==document.body&&!this.contains(Z))return;requestAnimationFrame(()=>Q.focus?.())}get autoresize(){let q=this.getAttribute("autoresize");return q===null||q!=="false"}set autoresize(q){if(q===!1||q==="false"||q===null)this.setAttribute("autoresize","false");else if(q||q==="")this.setAttribute("autoresize",q===!0?"":q);else this.setAttribute("autoresize","false")}handleNativeClose(){if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}setupObservers(){this.teardownObservers();let q=this.resolveAnchor();if(q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(q){if(!q)return null;let Q=q.getBoundingClientRect();return{x:Q.x,y:Q.y,width:Q.width,height:Q.height}}hasRectChanged(q,Q,Z=0.25){if(!q&&!Q)return!1;if(!q||!Q)return!0;return Math.abs(q.x-Q.x)>Z||Math.abs(q.y-Q.y)>Z||Math.abs(q.width-Q.width)>Z||Math.abs(q.height-Q.height)>Z}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let Q=this.resolveAnchor(),Z=this.readRectSnapshot(Q),$=this.shouldAutoReposition();if($&&this.hasRectChanged(this._lastAnchorRect,Z))this._lastAnchorRect=Z,this.queueReposition();else if(!$)this._lastAnchorRect=Z;this._anchorTrackRAF=requestAnimationFrame(q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(q){if(!this.open||!(this.matches?.(":open")||this.matches?.(":popover-open")))return;let Q=this.getAttribute("closedby");if(Q==="none"||Q==="closerequest")return;let Z=q.target;if(!(Z instanceof Node))return;let $=typeof q.composedPath==="function"?q.composedPath():[];if($.includes(this))return;if(this.contains(Z))return;let J=this.resolveAnchor();if(J&&($.includes(J)||J.contains?.(Z)))return;if(this.isInsideDescendantPopup(Z))return;this.open=!1}handleDocumentKeydown(q){if(q.key!=="Escape"||q.defaultPrevented)return;if(!this.open)return;if(this.getAttribute("role")==="menu")return;if(this.getAttribute("closedby")==="none")return;let $=Array.from(document.querySelectorAll('dialog[is="fig-popup"][open]')).filter((J)=>J.open).map((J)=>({popup:J,z:Number.parseInt(getComputedStyle(J).zIndex||"0",10)||0})).sort((J,j)=>J.z-j.z).at(-1)?.popup;if($&&$!==this)return;q.preventDefault(),this.open=!1}isInsideDescendantPopup(q){let Q=q.closest?.('dialog[is="fig-popup"]');if(!Q||Q===this)return!1;let Z=Q,$=new Set;while(Z&&!$.has(Z)){$.add(Z);let J=Z.anchor;if(!(J instanceof Element))break;if(this.contains(J))return!0;Z=J.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}isInteractiveElement(q){let Q=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],Z=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],$=(j)=>Q.some((_)=>j.matches?.(_))||j.tagName?.startsWith("FIG-")&&!Z.includes(j.tagName);if($(q))return!0;let J=q.parentElement;while(J&&J!==this){if($(J))return!0;J=J.parentElement}return!1}handlePointerDown(q){if(!this.drag)return;if(this.isInteractiveElement(q.target))return;let Q=this.getAttribute("handle");if(Q&&Q.trim()){let $=this.querySelector(Q);if(!$||!$.contains(q.target))return}this._dragPending=!0,this._dragStartPos.x=q.clientX,this._dragStartPos.y=q.clientY;let Z=this.getBoundingClientRect();this._dragOffset.x=q.clientX-Z.left,this._dragOffset.y=q.clientY-Z.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}handlePointerMove(q){if(this._dragPending&&!this._isDragging){let Q=Math.abs(q.clientX-this._dragStartPos.x),Z=Math.abs(q.clientY-this._dragStartPos.y);if(Q>this._dragThreshold||Z>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(q.pointerId),this.style.cursor="grabbing";let $=this.getBoundingClientRect();this.style.top=`${$.top}px`,this.style.left=`${$.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${q.clientX-this._dragOffset.x}px`,this.style.top=`${q.clientY-this._dragOffset.y}px`,q.preventDefault()}handlePointerUp(q){if(this._isDragging){if(this.hasPointerCapture?.(q.pointerId))this.releasePointerCapture(q.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let q=this.getAttribute("anchor");if(!q)return null;let Q=this.parentElement;try{if(Q?.querySelector){let Z=Q.querySelector(q);if(Z&&!this.contains(Z))return Z}return document.querySelector(q)}catch{return null}}parsePosition(){let Q=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),Z=new Set(["top","center","bottom"]),$=new Set(["left","center","right"]),J="top",j="center",_=null;if(Q.length>=2){if(Z.has(Q[0]))J=Q[0];if($.has(Q[1]))j=Q[1];return{vertical:J,horizontal:j,shorthand:_}}if(Q.length===1){let W=Q[0];if(W==="top"||W==="bottom")J=W,_=W;else if(W==="left"||W==="right")j=W,_=W;else if(W==="center")J="center",j="center"}return{vertical:J,horizontal:j,shorthand:_}}normalizeOffsetToken(q,Q="0px"){if(!q)return Q;let Z=q.trim();if(!Z)return Q;if(/^-?\d+(\.\d+)?$/.test(Z))return`${Z}px`;return Z}measureLengthPx(q,Q="x"){if(!q)return 0;let Z=this.normalizeOffsetToken(q,"0px");if(Z.endsWith("px")){let j=parseFloat(Z);return Number.isFinite(j)?j:0}let $=document.createElement("div");if($.style.position="fixed",$.style.visibility="hidden",$.style.pointerEvents="none",$.style.left="0",$.style.top="0",$.style.margin="0",$.style.padding="0",$.style.border="0",Q==="x")$.style.width=Z,$.style.height="0";else $.style.height=Z,$.style.width="0";document.body.appendChild($);let J=$.getBoundingClientRect();return $.remove(),Q==="x"?J.width:J.height}parseOffset(){let Q=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),Z=this.normalizeOffsetToken(Q[0],"0px"),$=this.normalizeOffsetToken(Q[1],"0px");return{xToken:Z,yToken:$,xPx:this.measureLengthPx(Z,"x"),yPx:this.measureLengthPx($,"y")}}parseViewportMargins(){let Q=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter(($)=>!Number.isNaN($)),Z=8;if(Q.length===0)return{top:8,right:8,bottom:8,left:8};if(Q.length===1)return{top:Q[0],right:Q[0],bottom:Q[0],left:Q[0]};if(Q.length===2)return{top:Q[0],right:Q[1],bottom:Q[0],left:Q[1]};if(Q.length===3)return{top:Q[0],right:Q[1],bottom:Q[2],left:Q[1]};return{top:Q[0],right:Q[1],bottom:Q[2],left:Q[3]}}getPlacementCandidates(q,Q,Z){let $={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if(Z){let j=Z==="left"||Z==="right"?["top","bottom"]:["left","right"];return[{v:q,h:Q,s:Z},{v:q,h:Q,s:$[Z]},{v:q,h:Q,s:j[0]},{v:q,h:Q,s:j[1]}]}if(q==="center")return[{v:"center",h:Q,s:null},{v:"center",h:$[Q],s:null},{v:"top",h:Q,s:null},{v:"bottom",h:Q,s:null},{v:"top",h:$[Q],s:null},{v:"bottom",h:$[Q],s:null}];if(Q==="center")return[{v:q,h:"center",s:null},{v:$[q],h:"center",s:null},{v:q,h:"left",s:null},{v:q,h:"right",s:null},{v:$[q],h:"left",s:null},{v:$[q],h:"right",s:null}];return[{v:q,h:Q,s:null},{v:$[q],h:Q,s:null},{v:q,h:$[Q],s:null},{v:$[q],h:$[Q],s:null}]}computeCoords(q,Q,Z,$,J,j){let _,W;if(j==="left"||j==="right")return W=j==="left"?q.left-Q.width-J.xPx:q.right+J.xPx,_=q.top,{top:_,left:W};if(j==="top"||j==="bottom")return _=j==="top"?q.top-Q.height-J.yPx:q.bottom+J.yPx,W=q.left,{top:_,left:W};if(Z==="top")_=q.top-Q.height-J.yPx;else if(Z==="bottom")_=q.bottom+J.yPx;else _=q.top+(q.height-Q.height)/2;if(Z==="center")if($==="left")W=q.left-Q.width-J.xPx;else if($==="right")W=q.right+J.xPx;else W=q.left+(q.width-Q.width)/2;else if($==="left")W=q.left+J.xPx;else if($==="right")W=q.right-Q.width-J.xPx;else W=q.left+(q.width-Q.width)/2;return{top:_,left:W}}oppositeSide(q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[q]||"bottom"}getPlacementSide(q,Q,Z){if(Z==="top")return"top";if(Z==="bottom")return"bottom";if(Z==="left")return"left";if(Z==="right")return"right";if(q!=="center")return q;if(Q!=="center")return Q;return"top"}lengthToPx(q,Q=0){let Z=getComputedStyle(this),$=String(q||"").trim(),J=parseFloat($);if(!Number.isFinite(J))return Q;if($.endsWith("rem"))return J*parseFloat(getComputedStyle(document.documentElement).fontSize);if($.endsWith("em"))return J*parseFloat(Z.fontSize);return J}radiusForSide(q){let Q=getComputedStyle(this),Z=($)=>this.lengthToPx($,0);if(q==="top")return Math.max(Z(Q.borderTopLeftRadius),Z(Q.borderTopRightRadius));if(q==="bottom")return Math.max(Z(Q.borderBottomLeftRadius),Z(Q.borderBottomRightRadius));if(q==="left")return Math.max(Z(Q.borderTopLeftRadius),Z(Q.borderBottomLeftRadius));if(q==="right")return Math.max(Z(Q.borderTopRightRadius),Z(Q.borderBottomRightRadius));return 0}getBeakEdgeInset(q){let Q=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(q)+Q/2)}tracksAnchorBeak(){let q=this.getAttribute("variant");return q==="popover"||q==="tooltip"}getViewportBounds(q){let Q=window.visualViewport,Z=Q?.width??window.innerWidth,$=Q?.height??window.innerHeight,J=Q?.offsetLeft??0,j=Q?.offsetTop??0;return{minLeft:J+q.left,minTop:j+q.top,maxRight:J+Z-q.right,maxBottom:j+$-q.bottom}}clampToViewport(q,Q,Z){let $=this.getViewportBounds(Z),J=$.maxRight-Q.width,j=$.maxBottom-Q.height;return{left:Math.min(J,Math.max($.minLeft,q.left)),top:Math.min(j,Math.max($.minTop,q.top))}}resolveCoordsAtViewport(q,Q,Z,$,J){let{left:j,top:_}=this.clampToViewport(Z,Q,J);if(!q||!this.tracksAnchorBeak())return{left:j,top:_};let W=this.oppositeSide($),N=this.getViewportBounds(J),K=N.maxRight-Q.width,G=N.minLeft,U=N.maxBottom-Q.height,X=N.minTop;if(W==="top"||W==="bottom"){let O=this.getBeakEdgeInset(W),R=q.left+q.width/2,L=R-j;if(L<O)j=R-O;else if(L>Q.width-O)j=R-(Q.width-O);j=Math.min(K,Math.max(G,j))}else if(W==="left"||W==="right"){let O=this.getBeakEdgeInset(W),R=q.top+q.height/2,L=R-_;if(L<O)_=R-O;else if(L>Q.height-O)_=R-(Q.height-O);_=Math.min(U,Math.max(X,_))}return{left:j,top:_}}canPointAtAnchor(q,Q,Z,$,J){if(!q||!this.tracksAnchorBeak())return!0;let j=this.oppositeSide(J),_=this.getBeakEdgeInset(j);if(j==="top"||j==="bottom"){let N=q.left+q.width/2-Z;return N>=_-0.5&&N<=Q.width-_+0.5}let W=q.top+q.height/2-$;return W>=_-0.5&&W<=Q.height-_+0.5}updatePopoverBeak(q,Q,Z,$,J){if(!this.tracksAnchorBeak()||!q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let j=this.oppositeSide(J);this.setAttribute("data-beak-side",j);let _=q.left+q.width/2,W=q.top+q.height/2,N=this.getBoundingClientRect(),K=N.width>0&&N.height>0?N:Q,G=K.left,U=K.top,X=this.getBeakEdgeInset(j),O;if(j==="top"||j==="bottom"){O=_-G;let R=X,L=Math.max(R,K.width-X);O=Math.min(L,Math.max(R,O))}else{O=W-U;let R=X,L=Math.max(R,K.height-X);O=Math.min(L,Math.max(R,O))}this.style.setProperty("--fig-popup-beak-offset",`${O}px`)}overflowScore(q,Q,Z){let $=this.getViewportBounds(Z),J=q.left+Q.width,j=q.top+Q.height,_=Math.max(0,$.minLeft-q.left),W=Math.max(0,$.minTop-q.top),N=Math.max(0,J-$.maxRight),K=Math.max(0,j-$.maxBottom);return _+W+N+K}fits(q,Q,Z){return this.overflowScore(q,Q,Z)===0}clamp(q,Q,Z,$=null,J="top"){if($)return this.resolveCoordsAtViewport($,Q,q,J,Z);return this.clampToViewport(q,Q,Z)}primaryAxisOverflowPenalty(q,Q,Z,$){let J=this.getViewportBounds(Z),j=0;if($==="top")j=Math.max(0,J.minTop-q.top);else if($==="bottom")j=Math.max(0,q.top+Q.height-J.maxBottom);else if($==="left")j=Math.max(0,J.minLeft-q.left);else if($==="right")j=Math.max(0,q.left+Q.width-J.maxRight);return j>0?1000+j:0}placementScore(q,Q,Z,$,J){let j=this.resolveCoordsAtViewport(q,Q,Z,$,J),_=this.overflowScore(j,Q,J);if(_+=this.primaryAxisOverflowPenalty(Z,Q,J,$),q&&!this.canPointAtAnchor(q,Q,j.left,j.top,$))_+=1e4;return{score:_,resolved:j}}applyPopupPosition(q,Q,Z,$,J){let j=this.resolveCoordsAtViewport(q,Q,Z,$,J);this.style.left=`${j.left}px`,this.style.top=`${j.top}px`,this.updatePopoverBeak(q,Q,j.left,j.top,$)}positionPopup(){if(!this.open)return;let q=this.getBoundingClientRect(),Q=this.parseOffset(),{vertical:Z,horizontal:$,shorthand:J}=this.parsePosition(),j=this.resolveAnchor(),_=this.parseViewportMargins();if(!j){this.updatePopoverBeak(null,q,0,0,"top");let X=this.getViewportBounds(_),O={left:X.minLeft+(X.maxRight-X.minLeft-q.width)/2,top:X.minTop+(X.maxBottom-X.minTop-q.height)/2},R=this.clampToViewport(O,q,_);this.style.left=`${R.left}px`,this.style.top=`${R.top}px`;return}let W=j.getBoundingClientRect(),N=this.getPlacementCandidates(Z,$,J),K=null,G="top",U=Number.POSITIVE_INFINITY;for(let{v:X,h:O,s:R}of N){let L=this.computeCoords(W,q,X,O,Q,R),D=this.getPlacementSide(X,O,R),{score:F,resolved:H}=this.placementScore(W,q,L,D,_);if(R){let B=this.getViewportBounds(_);if((R==="left"||R==="right"?L.left>=B.minLeft&&L.left+q.width<=B.maxRight:L.top>=B.minTop&&L.top+q.height<=B.maxBottom)&&F<1e4){this.applyPopupPosition(W,q,L,D,_);return}}else if(F===0){this.applyPopupPosition(W,q,L,D,_);return}if(F<U)U=F,K=H,G=D}this.applyPopupPosition(W,q,K||{left:0,top:0},G,_)}queueReposition(){if(!this.open||!this.isPopupDisplayed()||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}isPopupDisplayed(){return Boolean(this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"))}}O0("fig-popup",v0,{extends:"dialog"});class m0 extends HTMLElement{#Q;#q;constructor(){super();this.content=null,this.#Q=!1,this.#q=this.handleClick.bind(this)}connectedCallback(){if(this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.addEventListener("click",this.#q),u(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let q=this.getAttribute("id")||h(),Q=this.content.getAttribute("id")||h();if(this.setAttribute("id",q),this.content.setAttribute("id",Q),this.setAttribute("aria-controls",Q),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",q),this.#Q)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}}})}get selected(){return this.#Q}set selected(q){this.setAttribute("selected",q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#q)}handleClick(){if(z(this,"disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(q,Q,Z){if(q==="selected"){if(this.#Q=Z!==null&&Z!=="false",this.setAttribute("aria-selected",this.#Q?"true":"false"),this.setAttribute("tabindex",this.#Q?"0":"-1"),this?.content)this.content.style.display=this.#Q?"block":"none"}if(q==="disabled")if(Z!==null&&Z!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#Q?"0":"-1")}}M("fig-tab",m0);class g0 extends HTMLElement{#Q;#q;#Z=this.#L.bind(this);#$=null;#J=null;#j=null;#N=null;#_=!1;#W=new WeakSet;constructor(){super();this.#Q=this.handleClick.bind(this),this.#q=this.#H.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){if(this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#q),this.addEventListener("scroll",this.#Z),this.#R(),this.#M(),this.#z(),u(this,()=>{let q=this.getAttribute("value");if(q)this.#A(q);if(z(this,"disabled"))this.#Y(!0);this.#K(),this.#L(),this.#X(void 0,"auto")})}#Y(q){this.querySelectorAll("fig-tab").forEach((Z)=>{if(q){if(!(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false"))this.#W.add(Z),Z.setAttribute("disabled","");Z.setAttribute("aria-disabled","true"),Z.setAttribute("tabindex","-1")}else if(this.#W.has(Z))this.#W.delete(Z),Z.removeAttribute("disabled"),Z.removeAttribute("aria-disabled")}),this.#K()}#G(){return Array.from(this.querySelectorAll("fig-tab")).filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false")}#K(){let q=Array.from(this.querySelectorAll("fig-tab")),Q=q.find((Z)=>Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false")||this.#G()[0];q.forEach((Z)=>{let $=Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false";Z.setAttribute("tabindex",!$&&Z===Q?"0":"-1")})}#X(q=this.selectedTab,Q="smooth"){let Z=q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#G()[0];if(!Z)return;requestAnimationFrame(()=>{if(!this.isConnected||!Z.isConnected)return;if(!(this.scrollWidth>this.clientWidth))return;let J=this.getBoundingClientRect(),j=Z.getBoundingClientRect(),_=j.left-J.left+this.scrollLeft+j.width/2;this.scrollTo({left:_-this.clientWidth/2,behavior:Q}),this.#L()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#q),this.removeEventListener("scroll",this.#Z),this.#$?.disconnect(),this.#$=null,this.#J?.disconnect(),this.#J=null,this.#B()}#U(){if(this.#_)return;let q=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!q)return;this.#_=!0;try{let Q=Array.from(q.childNodes);q.replaceWith(...Q)}finally{this.#_=!1}}#L(){a(this,this,"x")}#z(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>this.#L()),this.#J.observe(this)}#M(){this.#$?.disconnect(),this.#$=new MutationObserver(()=>{if(this.#_)return;this.#U(),this.#R(),this.#K(),requestAnimationFrame(()=>{this.#L(),this.#X()})}),this.#$.observe(this,{childList:!0,subtree:!1})}#B(){this.#j?.remove(),this.#N?.remove(),this.#j=null,this.#N=null,this.classList.remove("overflow-start","overflow-end")}#R(){if(this.#j&&this.#N&&this.contains(this.#j)&&this.contains(this.#N))return;this.#j?.remove(),this.#N?.remove();let q=N0({owner:"tabs",onStart:()=>r(this,"x",-1),onEnd:()=>r(this,"x",1)});this.#j=q.start,this.#N=q.end,this.prepend(this.#j),this.append(this.#N)}#H(q){let Q=this.#G();if(!Q.length)return;let Z=Q.findIndex((J)=>z(J,"selected")),$=Z>=0?Z:0;switch(q.key){case"ArrowLeft":case"ArrowUp":q.preventDefault(),$=Z>0?Z-1:Q.length-1;break;case"ArrowRight":case"ArrowDown":q.preventDefault(),$=Z<Q.length-1?Z+1:0;break;case"Home":q.preventDefault(),$=0;break;case"End":q.preventDefault(),$=Q.length-1;break;default:return}if($!==Z&&Q[$]){this.querySelectorAll("fig-tab").forEach((j)=>j.removeAttribute("selected")),this.selectedTab=Q[$],Q[$].setAttribute("selected","true");let J=this.#T(Q[$]);if(J)this.setAttribute("value",J);else this.removeAttribute("value");Q[$].focus(),this.#K(),this.#X(Q[$]),this.#D()}}get value(){return this.#T(this.selectedTab)}set value(q){this.setAttribute("value",q)}#D(){let q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:q,bubbles:!0}))}#T(q){if(!q)return"";let Q=q.getAttribute("value");if(Q!==null)return Q;return q.textContent?.trim()||""}#A(q){let Q=this.querySelectorAll("fig-tab");for(let Z of Q)if(this.#T(Z)===q)this.selectedTab=Z,Z.setAttribute("selected","true");else Z.removeAttribute("selected");this.#K(),this.#X(this.selectedTab)}attributeChangedCallback(q,Q,Z){switch(q){case"value":if(Z!==Q)this.#A(Z);break;case"disabled":this.#Y(Z!==null&&Z!=="false");break}}handleClick(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=q.target.closest("fig-tab");if(!Q||!this.contains(Q))return;if(Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;let Z=this.selectedTab,$=this.value,J=this.querySelectorAll("fig-tab");for(let _ of J)if(_===Q)this.selectedTab=_,_.setAttribute("selected","true");else _.removeAttribute("selected");let j=this.#T(Q);if(j)this.setAttribute("value",j);else this.removeAttribute("value");if(this.#K(),this.#X(Q),Z!==Q||$!==this.value)this.#D()}}M("fig-tabs",g0);class u0 extends HTMLElement{#Q;#q;#Z;constructor(){super();this.#Z=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#$(),this.addEventListener("click",this.#Z)}disconnectedCallback(){this.removeEventListener("click",this.#Z)}handleClick(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let q=this.closest("fig-segmented-control");if(q&&q.hasAttribute("disabled")&&q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#Q}set value(q){this.#Q=q,this.setAttribute("value",q)}get selected(){return this.#q}set selected(q){this.#q=q,this.setAttribute("selected",q)}static get observedAttributes(){return["selected","value","disabled"]}#$(){let q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",q?"true":"false"),Q)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",q?"0":"-1")}attributeChangedCallback(q,Q,Z){switch(q){case"value":this.#Q=Z;break;case"selected":this.#q=Z,this.#$();break;case"disabled":this.#$();break}}}M("fig-segment",u0);class c0 extends HTMLElement{#Q=null;#q=this.handleClick.bind(this);#Z=this.#z.bind(this);#$=null;#J=null;#j=0;#N=!1;#_=!1;#W=new WeakSet;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){if(this.name=this.getAttribute("name")||"segmented-control",!this.hasAttribute("role"))this.setAttribute("role","radiogroup");this.addEventListener("click",this.#q),this.addEventListener("keydown",this.#Z),this.#P(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#O(),this.#D(),u(this,()=>{this.#A({enforceFallback:!0}),this.#T(),this.#R({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#q),this.removeEventListener("keydown",this.#Z),this.#$?.disconnect(),this.#$=null,this.#J?.disconnect(),this.#J=null,this.#j)cancelAnimationFrame(this.#j),this.#j=0;this.#N=!1,this.#_=!1}get selectedSegment(){return this.#Q}set selectedSegment(q){let Q=this.querySelectorAll("fig-segment");for(let Z of Q){let $=Z===q,J=z(Z,"selected");if($&&!J)Z.setAttribute("selected","true");else if(!$&&J)Z.removeAttribute("selected")}this.#Q=q instanceof HTMLElement&&this.contains(q)?q:null,this.#U(),this.#R()}get value(){return this.getAttribute("value")||""}set value(q){if(q===null||q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(q))}#Y(q){this.dispatchEvent(new CustomEvent("input",{detail:q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:q,bubbles:!0}))}#G(q){let Q=q.getAttribute("value");if(Q!==null){let Z=Q.trim();if(Z.length>0)return Z}return q.textContent?.trim()||""}#K(){let q=this.querySelectorAll("fig-segment");for(let Q of q)if(Q.hasAttribute("selected")&&Q.getAttribute("selected")!=="false")return Q;return null}#X(){return Array.from(this.querySelectorAll("fig-segment")).filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false")}#U(){let q=Array.from(this.querySelectorAll("fig-segment")),Q=q.find((Z)=>Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false");q.forEach((Z)=>{let $=Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false",J=Z===Q;Z.setAttribute("aria-checked",J?"true":"false"),Z.setAttribute("tabindex",!$&&J?"0":"-1")})}#L(q){if(!q)return;let Q=this.selectedSegment,Z=this.value;this.selectedSegment=q;let $=this.#G(q);if($)this.setAttribute("value",$);else this.removeAttribute("value");let J=this.value;if(Q!==q||Z!==J)this.#Y(J)}#z(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.#X();if(!Q.length)return;let Z=Q.findIndex((j)=>z(j,"selected")),$=Z>=0?Z:0;switch(q.key){case"ArrowLeft":case"ArrowUp":q.preventDefault(),$=$>0?$-1:Q.length-1;break;case"ArrowRight":case"ArrowDown":q.preventDefault(),$=$<Q.length-1?$+1:0;break;case"Home":q.preventDefault(),$=0;break;case"End":q.preventDefault(),$=Q.length-1;break;case" ":case"Enter":{let j=q.target.closest("fig-segment");if(j&&this.contains(j))q.preventDefault(),this.#L(j);return}default:return}let J=Q[$];this.#L(J),J.focus(),requestAnimationFrame(()=>{if(this.contains(J))J.focus()})}#M(q){let Q=String(q??"").trim();if(!Q)return!1;let Z=this.querySelectorAll("fig-segment");for(let $ of Z){let J=this.#G($);if(!J)continue;if(J===Q)return this.selectedSegment=$,!0}return!1}#B(){let q=this.getAttribute("animated");if(q===null)return!1;if(q==="")return!0;return q.trim().toLowerCase()==="true"}#R({forceInstant:q=!1}={}){if(this.#N=this.#N||q,this.#j)return;this.#j=requestAnimationFrame(()=>{this.#j=0;let Q=this.#N;this.#N=!1,this.#H({forceInstant:Q})})}#H({forceInstant:q=!1}={}){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.#B(),$=this.#Q&&this.contains(this.#Q)?this.#Q:this.#K();if(Q||!Z){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!Z||Q)this.#_=!1;return}if(!$){if(this.#_)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let J=this.getBoundingClientRect(),j=$.getBoundingClientRect();if(J.width<=0||j.width<=0){if(this.#_)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let _=Math.max(0,j.left-J.left);this.style.setProperty("--seg-indicator-x",`${_}px`),this.style.setProperty("--seg-indicator-w",`${j.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#_||q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#_=!0}#D(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#R()}),this.#T()}#T(){if(!this.#J)return;this.#J.disconnect(),this.#J.observe(this),this.querySelectorAll("fig-segment").forEach((q)=>{this.#J?.observe(q)})}#A({enforceFallback:q=!1}={}){if(this.querySelectorAll("fig-segment").length===0){this.#Q=null,this.#R({forceInstant:!0});return}let Z=this.getAttribute("value"),$=Z?.trim()??"";if(Z!==null){if($!==Z){this.setAttribute("value",$);return}if($&&this.#M($))return}let J=this.#K();if(J){this.selectedSegment=J;return}if(q)this.selectedSegment=this.#X()[0]||null}#O(){this.#$?.disconnect(),this.#$=new MutationObserver((q)=>{let Q=!1;for(let Z of q){if(Z.type==="childList"){Q=!0;break}if(Z.type==="attributes"&&Z.target instanceof HTMLElement&&Z.target.tagName.toLowerCase()==="fig-segment"&&(Z.attributeName==="value"||Z.attributeName==="selected")){Q=!0;break}if(Z.type==="characterData"){Q=!0;break}}if(Q)this.#P(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#T(),this.#A({enforceFallback:!0}),this.#U()}),this.#$.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=q.target.closest("fig-segment");if(!Q||!this.contains(Q))return;if(Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.#L(Q)}#P(q){this.setAttribute("aria-disabled",q?"true":"false"),this.querySelectorAll("fig-segment").forEach((Q)=>{if(q){if(!(Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false"))this.#W.add(Q),Q.setAttribute("disabled","");Q.setAttribute("aria-disabled","true")}else if(this.#W.has(Q))this.#W.delete(Q),Q.removeAttribute("disabled"),Q.removeAttribute("aria-disabled")}),this.#U()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="disabled"){this.#P(Z!==null&&Z!=="false"),this.#R({forceInstant:!0});return}if(q==="value"){this.#A({enforceFallback:!1});return}if(q==="animated"){if(!this.#B())this.#_=!1;this.#R({forceInstant:!0});return}if(q==="sizing")this.#R({forceInstant:!0})}}M("fig-segmented-control",c0);class p0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Q="segments";#q=0;#Z=null;#$=[];#J=null;#j=!1;#N(q){let Q=q?.detail;if(typeof Q==="string")return Q;let Z=q?.currentTarget?.value??q?.target?.value??this.getAttribute("value");if(Z===null||Z===void 0)return null;return String(Z)}#_(){if(this.#$.length===0)return!1;let q=this.querySelector(":scope > fig-segmented-control");if(q){let Z=q.querySelectorAll("fig-segment");if(Z.length!==this.#$.length)return!1;return Array.from(Z).every(($,J)=>$.getAttribute("value")===this.#$[J])}let Q=this.querySelector(":scope > fig-dropdown");if(Q){let Z=Q.querySelectorAll("option");return Z.length===this.#$.length&&Array.from(Z).every(($,J)=>$.textContent?.trim()===this.#$[J])}return!1}#W(){let q=this.querySelector(":scope > fig-segmented-control");if(q)this.#J=q,this.#Q="segments";else this.#J=this.querySelector(":scope > fig-dropdown"),this.#Q="dropdown";this.#U()}connectedCallback(){if(this.#Y(),this.#_()){this.#W(),this.#z(),u(this,()=>u(this,()=>this.#R()));return}this.#G(),this.#z(),u(this,()=>u(this,()=>this.#R()))}disconnectedCallback(){this.#Z?.disconnect(),this.#Z=null}get value(){return this.getAttribute("value")||""}set value(q){if(q===null||q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(q))}get options(){return this.#$.slice()}set options(q){if(Array.isArray(q)){let Z=q.some(($)=>String($).includes(","))?JSON.stringify(q):q.join(",");this.setAttribute("options",Z)}else this.setAttribute("options",String(q||""))}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="options"){this.#Y(),this.#X();return}if(q==="value"){this.#U();return}if(q==="disabled"){this.#L("disabled");return}if(q==="full"){this.#L("full");return}if(q==="sizing")this.#L("sizing"),this.#X()}#Y(){let q=this.getAttribute("options")||"";if(q.startsWith("["))try{this.#$=JSON.parse(q);return}catch{}let Q=q.includes(`
37
+ `,this.button=this.shadowRoot.querySelector("button, .fig-button-control"),this.button.addEventListener("click",this.#J),this.button.addEventListener("focus",this.#N),this.button.addEventListener("blur",this.#_)}let q=this.shadowRoot.querySelector("slot");q?.removeEventListener("slotchange",this.#j),q?.addEventListener("slotchange",this.#j),this.removeEventListener("keydown",this.#$),this.addEventListener("keydown",this.#$),this.#Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",this.#z()}get type(){return this.getAttribute("type")||"button"}set type(q){this.setAttribute("type",q)}get selected(){return this.#Q}set selected(q){this.setAttribute("selected",q)}#W(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#Y(){if(this.#W())return;if(this.type==="toggle")if(this.selected)this.removeAttribute("selected");else this.setAttribute("selected","");if(this.type==="submit"){let q=this.closest("form");if(q)if(typeof q.requestSubmit==="function")q.requestSubmit();else q.submit()}if(this.type==="link"){let q=this.getAttribute("href"),Q=this.getAttribute("target");if(q)if(Q)window.open(q,Q);else window.location.href=q}}#G(){if(this.type==="select")return this.querySelector("select, fig-dropdown");if(this.type==="upload")return this.querySelector('input[type="file"], input');return null}#K(){let q=this.#G();if(q instanceof HTMLSelectElement)return q;if(q?.tagName==="FIG-DROPDOWN")return q.select||q.querySelector?.("select")||null;return null}#X(q){if(this.type!=="select")return;if(q.key!=="Enter")return;if(q.altKey||q.ctrlKey||q.metaKey||q.shiftKey)return;let Q=this.#K();if(!Q||Q.disabled||Q.multiple)return;if(typeof Q.showPicker!=="function")return;q.preventDefault();try{Q.showPicker()}catch{}}#U(){if(!this.button)return;if(this.type!=="toggle"){this.removeAttribute("aria-pressed"),this.button.removeAttribute("aria-pressed");return}let q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.setAttribute("aria-pressed",q?"true":"false"),this.button.setAttribute("aria-pressed",q?"true":"false")}#L(){if(!this.button)return;if(!(this.button instanceof HTMLButtonElement))return;this.#Z.forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.button.removeAttribute(q);else this.button.setAttribute(q,Q)})}#z(){if(!this.button)return;let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.disabled=q,this.button instanceof HTMLButtonElement)this.button.disabled=q,this.button.type="button",this.button.setAttribute("type","button");this.#M(),this.#L(),this.#U()}#M(){let q=this.#G();if(!q)return;if(this.#W()){if(!this.#q.has(q))this.#q.set(q,q.hasAttribute("disabled")&&q.getAttribute("disabled")!=="false");q.setAttribute("disabled","")}else if(this.#q.has(q)){let Z=this.#q.get(q);if(this.#q.delete(q),Z)q.setAttribute("disabled","");else q.removeAttribute("disabled")}}static get observedAttributes(){return["disabled","selected","type","aria-label","aria-labelledby","aria-describedby","title"]}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"type":{let $=(J)=>J==="select"||J==="upload";if($(Q||"button")!==$(Z||"button")){this.button=null,this.connectedCallback();break}this.#z();break}case"disabled":this.#z();break;case"selected":this.#Q=Z!==null&&Z!=="false",this.#U();break;default:this.#L();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#$),this.shadowRoot?.querySelector("slot")?.removeEventListener("slotchange",this.#j)}}M("fig-button",x0);class w0 extends HTMLElement{#Q="Menu";#q=null;#Z;#$;#J;get label(){return this.#Q}set label(q){this.#Q=q}#j;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#Z=this.#Y.bind(this),this.#$=this.#G.bind(this),this.#J=this.#K.bind(this),this.#j=this.slotChange.bind(this)}#N(){this.select.addEventListener("input",this.#Z),this.select.addEventListener("change",this.#$),this.select.addEventListener("keydown",this.#J)}#_(q){if(!q||!(q instanceof Element))return!1;return!!q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#W(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){if(this.type=this.getAttribute("type")||"select",this.#Q=this.getAttribute("label")||this.#Q,this.select.setAttribute("aria-label",this.#Q),this.#X(),!this.select.isConnected)this.appendChild(this.select);if(!this.optionsSlot.isConnected)this.shadowRoot.appendChild(this.optionsSlot);this.optionsSlot.removeEventListener("slotchange",this.#j),this.optionsSlot.addEventListener("slotchange",this.#j),this.select.removeEventListener("input",this.#Z),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#J),this.#N()}slotChange(){let q=this.hasAttribute("value"),Q=this.select.options.length>0&&this.select.selectedIndex>=0,Z=q?this.getAttribute("value"):this.type==="dropdown"?this.#q:Q?this.select.value:null;while(this.select.firstChild)this.select.firstChild.remove();if(this.type==="dropdown"){let $=document.createElement("option");$.setAttribute("hidden","true"),$.setAttribute("selected","true"),$.selected=!0,this.select.appendChild($)}if(this.optionsSlot.assignedNodes().forEach(($)=>{if($.nodeName==="OPTION"||$.nodeName==="OPTGROUP")this.select.appendChild($.cloneNode(!0))}),Z!==null)this.#U(Z);if(this.type==="dropdown")this.select.selectedIndex=-1}#Y(q){q.stopPropagation();let Q=q.target.selectedOptions?.[0];if(this.#_(Q)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#W();return}let Z=q.target.value;if(this.type==="dropdown")this.#q=Z;this.setAttribute("value",Z),this.dispatchEvent(new CustomEvent("input",{detail:Z,bubbles:!0,composed:!0}))}#G(q){q.stopPropagation();let Q=q.target.selectedOptions?.[0];if(this.#_(Q)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#W();return}let Z=this.type==="dropdown"?this.#q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.dispatchEvent(new CustomEvent("change",{detail:Z,bubbles:!0,composed:!0}))}#K(q){if(this.closest('fig-button[type="select"]'))return;if(q.key!=="Enter"||q.defaultPrevented)return;if(q.altKey||q.ctrlKey||q.metaKey||q.shiftKey)return;if(this.select.disabled||this.select.multiple)return;if(typeof this.select.showPicker!=="function")return;q.preventDefault();try{this.select.showPicker()}catch{}}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#q;return this.select?.value}set value(q){if(this.type==="dropdown")this.#q=q;this.setAttribute("value",q)}static get observedAttributes(){return["value","type","label","disabled"]}#X(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=q}#U(q){if(this.type==="dropdown")return;if(this.select)this.select.value=q??""}attributeChangedCallback(q,Q,Z){if(q==="value")this.#U(Z);if(q==="type"){if(this.type=Z||"select",this.isConnected)this.slotChange()}if(q==="label")this.#Q=Z||"Menu",this.select.setAttribute("aria-label",this.#Q);if(q==="disabled")this.#X()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#j),this.select.removeEventListener("input",this.#Z),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#J)}}M("fig-dropdown",w0);class A extends HTMLElement{static#Q=0;static#q=0;static#Z=1000;static#$=null;static#J=!1;static#j=new Set;#N;#_;#W;#Y;#G;#K;#X;#U;#L;#z;#M;#B;#R=null;#H=null;#D=null;#T=!1;#A;#O=!1;constructor(){super();this.action=this.getAttribute("action")||"hover";let q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(q)?q:500,this.#N=this.#x.bind(this),this.#_=this.hidePopupOutsideClick.bind(this),this.#W=this.showDelayedPopup.bind(this),this.#Y=this.#S.bind(this),this.#G=()=>{if(!this.#T)this.showDelayedPopup()},this.#K=()=>{this.#T=!1,this.hidePopup()},this.#X=this.#w.bind(this),this.#U=this.#y.bind(this),this.#L=this.#u.bind(this),this.#z=this.#b.bind(this),this.#B=this.#E.bind(this),this.#M=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(A.#v(),this.setup(),this.#C(),this.setupEventListeners(),this.#R=this.closest("dialog"),this.#R)this.#R.addEventListener("close",this.#M)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#V(),this.#k(),document.removeEventListener("mousedown",this.#N,!0),document.removeEventListener("keydown",this.#B,!0),this.#R)this.#R.removeEventListener("close",this.#M),this.#R=null;if(this.action==="click")document.body.removeEventListener("click",this.#_);if(clearTimeout(this.#A),A.#$===this)A.#$=null}#P(){return this.firstElementChild}#k(){this.#D?.disconnect(),this.#D=null}#C(){if(this.#V(),this.action==="manual")return;let q=this.#P();if(!q){if(!this.#D&&typeof MutationObserver<"u")this.#D=new MutationObserver(()=>{if(this.#P())this.#k(),this.#C()}),this.#D.observe(this,{childList:!0});return}if(this.#H=q,this.action==="hover"){if(!this.isTouchDevice())q.addEventListener("pointerenter",this.#W),q.addEventListener("pointerleave",this.#Y);q.addEventListener("touchstart",this.#X,{passive:!0}),q.addEventListener("touchmove",this.#U,{passive:!0}),q.addEventListener("touchend",this.#L,{passive:!0}),q.addEventListener("touchcancel",this.#z,{passive:!0}),q.addEventListener("focus",this.#G),q.addEventListener("blur",this.#K)}else if(this.action==="click")q.addEventListener("click",this.#W),q.addEventListener("touchstart",this.#W,{passive:!0})}#V(){let q=this.#H;if(!q)return;if(this.action==="hover")q.removeEventListener("pointerenter",this.#W),q.removeEventListener("pointerleave",this.#Y),q.removeEventListener("touchstart",this.#X),q.removeEventListener("touchmove",this.#U),q.removeEventListener("touchend",this.#L),q.removeEventListener("touchcancel",this.#z),q.removeEventListener("focus",this.#G),q.removeEventListener("blur",this.#K);else if(this.action==="click")q.removeEventListener("click",this.#W),q.removeEventListener("touchstart",this.#W);this.#H=null}setup(){this.style.display="contents"}render(){this.destroy();let q=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,Q=document.createElement("span");if(this.popup=document.createElement("dialog",{is:"fig-popup"}),this.popup.setAttribute("is","fig-popup"),this.popup.setAttribute("variant","tooltip"),this.popup.setAttribute("data-tooltip-managed",""),this.popup.setAttribute("role","tooltip"),this.popup.setAttribute("closedby","closerequest"),q)this.popup.setAttribute("popover","manual");let Z=h();this.popup.setAttribute("id",Z);let $=this.getAttribute("theme");if($)this.popup.setAttribute("theme",$);let J=this.getAttribute("pointer");if(J!==null)this.popup.setAttribute("pointer",J);if(this.popup.append(Q),Q.innerText=this.getAttribute("text")??"",this.firstElementChild){let j=new Set((this.firstElementChild.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));j.add(Z),this.firstElementChild.setAttribute("aria-describedby",[...j].join(" "))}if(q)(j0()??document.body).append(this.popup);else{let j=this.closest("dialog");if(j&&j.open)j.append(this.popup);else(j0()??document.body).append(this.popup)}this.popup.anchor=this.firstElementChild}destroy(){if(this.popup)this.#F(this.popup.id),this.popup.hidePopup?.(),this.popup.remove(),this.popup=null}#F(q){let Q=this.firstElementChild;if(!Q||!q)return;let Z=Q.getAttribute("aria-describedby");if(!Z)return;let $=Z.split(/\s+/).filter((J)=>J&&J!==q).join(" ");if($)Q.setAttribute("aria-describedby",$);else Q.removeAttribute("aria-describedby")}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="click")document.body.addEventListener("click",this.#_);document.addEventListener("mousedown",this.#N,!0),document.addEventListener("keydown",this.#B,!0)}get#f(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#I(){let q=Date.now(),Q=A.#Z;if(this.action==="hover"&&A.#$)return!0;if(A.#Q&&q-A.#Q<Q)return!0;if(A.#q&&q-A.#q<Q)return!0;return!1}showDelayedPopup(q){if(this.#f)return;if(clearTimeout(this.timeout),q?.type==="pointerenter"){let Q=this.#H;if(Q?.matches?.("fig-select[open]")||Q?.querySelector?.("fig-select[open]"))return}if(this.#I()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#R&&!this.#R.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&A.#$&&A.#$!==this)A.#$.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")A.#$=this;A.#Q=Date.now()}hidePopup(){if(this.#f)return;clearTimeout(this.timeout),clearTimeout(this.#A);let q=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,A.#$===this)A.#$=null;if(q)A.#q=Date.now()}hidePopupOutsideClick(q){if(this.isOpen&&!this.popup.contains(q.target))this.hidePopup()}#S(q){if(!this.#O)this.hidePopup()}#w(q){if(this.action==="hover")this.#O=!0,clearTimeout(this.#A),this.showDelayedPopup()}#y(q){if(this.action==="hover"&&this.#O)clearTimeout(this.#A),this.#A=setTimeout(()=>{this.#O=!1,this.hidePopup()},150)}#u(q){if(this.action==="hover"&&this.#O)clearTimeout(this.#A),this.#A=setTimeout(()=>{this.#O=!1,this.hidePopup()},300)}#b(q){if(this.action==="hover"&&this.#O)this.#O=!1,clearTimeout(this.#A),this.hidePopup()}#E(q){if(!this.isOpen&&!this.popup||q.key!=="Escape")return;q.preventDefault(),this.hidePopup(),this.firstElementChild?.focus?.()}static get observedAttributes(){return["action","delay","open","pointer","show","text","theme"]}get text(){return this.getAttribute("text")??""}set text(q){this.setAttribute("text",q)}#h(q){if(!this.popup)return;let Q=this.popup.firstElementChild??this.popup.firstChild;if(!Q)return;Q.innerText=q}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(q){if(q===!1||q==="false"||q===null)this.removeAttribute("open");else this.setAttribute("open","true")}attributeChangedCallback(q,Q,Z){if(q==="action"){if(this.#V(),Q==="click")document.body?.removeEventListener("click",this.#_);if(this.action=Z||"hover",this.isConnected){if(this.#C(),this.action==="click")document.body?.addEventListener("click",this.#_)}}if(q==="delay"){let $=parseInt(Z);this.delay=!isNaN($)?$:500}if(q==="open")if(Z!==null&&Z!=="false")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(q==="show")if(Z!==null&&Z!=="false")this.showPopup();else this.hidePopup();if(q==="text")this.#h(Z??"");if(q==="pointer"){if(this.popup)if(Z!==null)this.popup.setAttribute("pointer",Z);else this.popup.removeAttribute("pointer")}if(q==="theme"){if(this.popup)if(Z)this.popup.setAttribute("theme",Z);else this.popup.removeAttribute("theme")}}#x(q){if(!this.isOpen)return;let Q=q.target;if(this.popup&&this.popup.contains(Q))return;if(Q.tagName==="SELECT"||Q.hasAttribute("popover")||Q.closest("dialog"))this.hidePopup()}static#v(){if(A.#J)return;A.#J=!0;let q=()=>{A.dismissHoverTooltips()},Q=()=>{A.#o()};document.documentElement.addEventListener("mouseleave",q),document.addEventListener("mouseout",(Z)=>{if(Z.relatedTarget)return;q()}),document.addEventListener("scroll",Q,{capture:!0,passive:!0}),window.addEventListener("scroll",Q,{passive:!0}),window.visualViewport?.addEventListener("scroll",Q,{passive:!0}),window.visualViewport?.addEventListener("resize",Q,{passive:!0});try{let Z=window.frameElement;if(Z)Z.addEventListener("mouseleave",q)}catch{}window.addEventListener("message",(Z)=>{if(Z?.data?.type!=="figui:dismiss-tooltips")return;if(window.parent!==window&&Z.source!==window.parent)return;q()})}static dismissHoverTooltips(){for(let q of document.querySelectorAll("fig-tooltip")){if(!(q instanceof A))continue;if(q.action!=="hover")continue;if(q.#f)continue;if(q.#T=!0,setTimeout(()=>{let Q=q.#H;if(Q!==document.activeElement&&!Q?.matches?.(":focus, :focus-within"))q.#T=!1},0),q.isOpen||q.timeout)q.hidePopup()}for(let q of Array.from(A.#j))A.hide(q)}static#g=new WeakMap;static#o(){for(let q of document.querySelectorAll("fig-tooltip")){if(!(q instanceof A))continue;if(q.#f)continue;if(q.isOpen||q.timeout)q.hidePopup()}for(let q of Array.from(A.#j))A.hide(q)}static show(q,Q,Z={}){A.#v(),A.hide(q);let $=Z.delay??500,j=Date.now()-A.#Q<A.#Z?0:$,_={timeout:null,popup:null};A.#g.set(q,_),A.#j.add(q),_.timeout=setTimeout(()=>{let W=typeof HTMLElement<"u"&&"popover"in HTMLElement.prototype,N=document.createElement("dialog",{is:"fig-popup"});if(N.setAttribute("is","fig-popup"),N.setAttribute("variant","tooltip"),N.setAttribute("data-tooltip-managed",""),N.setAttribute("role","tooltip"),N.setAttribute("closedby","closerequest"),W)N.setAttribute("popover","manual");let K=document.createElement("span");if(K.innerText=Q,N.append(K),W)(j0()??document.body).append(N);else{let G=q.closest?.("dialog");if(G&&G.open)G.append(N);else(j0()??document.body).append(N)}N.anchor=q,N.open=!0,_.popup=N,A.#Q=Date.now()},j)}static hide(q){let Q=A.#g.get(q);if(!Q)return;if(clearTimeout(Q.timeout),Q.popup)Q.popup.remove(),A.#q=Date.now();A.#g.delete(q),A.#j.delete(q)}}M("fig-tooltip",A);class y0 extends HTMLElement{static observedAttributes=["position","tail"];#Q=null;#q=null;#Z=null;connectedCallback(){this.#Q=this.textContent,u(this,()=>{this.#$(),this.#J()})}disconnectedCallback(){this.#j()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(this.#Q===null)return;this.#$()}#$(){let q=this.getAttribute("position")||"right",Q=this.#Q||"";if(q==="middle"){let Z=this.getAttribute("tail"),$;if(Z){let _=Q.lastIndexOf(Z);$=_>0?_:Math.ceil(Q.length/2)}else $=Math.ceil(Q.length/2);this.innerHTML="";let J=document.createElement("span");J.className="start",J.textContent=Q.slice(0,$);let j=document.createElement("span");j.className="end",j.textContent=Q.slice($),this.appendChild(J),this.appendChild(j)}else this.textContent=Q}#J(){if(!this.hasAttribute("tooltip")||this.getAttribute("tooltip")==="false")return;this.#q=()=>{if(this.scrollWidth<=this.clientWidth)return;A.show(this,this.#Q)},this.#Z=()=>{A.hide(this)},this.addEventListener("pointerenter",this.#q),this.addEventListener("pointerleave",this.#Z)}#j(){if(this.#q)this.removeEventListener("pointerenter",this.#q);if(this.#Z)this.removeEventListener("pointerleave",this.#Z);A.hide(this)}}M("fig-truncate",y0);class b0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._isDragging=!1,this._dragPending=!1,this._dragStartPos={x:0,y:0},this._dragOffset={x:0,y:0},this._resizeObserver=null,this._mutationObserver=null,this._autoResizeRafId=0,this._offset=16,this._positionInitialized=!1,this._dragThreshold=3,this._boundPointerDown=this._handlePointerDown.bind(this),this._boundPointerMove=this._handlePointerMove.bind(this),this._boundPointerUp=this._handlePointerUp.bind(this),this._boundClose=this.close.bind(this),this._boundIframeMessage=this._handleIframeMessage.bind(this),this._boundContentMutation=this._scheduleAutoResize.bind(this),this._boundContentResize=this._scheduleAutoResize.bind(this),this._boundRestoreFocus=this._restoreFocus.bind(this),this._boundIframeMouseLeave=this._handleIframeMouseLeave.bind(this),this._iframeDismissMutationObserver=null,this._previousFocus=null}get autoresize(){return this.hasAttribute("autoresize")&&this.getAttribute("autoresize")!=="false"}connectedCallback(){if(this._figInit(),this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this._ensureHeader(),this.open&&!this.matches?.(":modal"))this._assignStackingOrder();u(this,()=>{this._addCloseListeners(),this._setupDragListeners(),this._applyPosition(),this._syncAutoResize(),this._setupIframeDismissListeners(),this._syncA11y()}),window.addEventListener("message",this._boundIframeMessage)}disconnectedCallback(){this._figInit(),this._removeDragListeners(),this.querySelectorAll("fig-button[close-dialog]").forEach((q)=>{q.removeEventListener("click",this._boundClose)}),window.removeEventListener("message",this._boundIframeMessage),this._teardownAutoResize(),this._teardownIframeDismissListeners(),this.removeEventListener("close",this._boundRestoreFocus)}_captureFocusBeforeOpen(){let q=document.activeElement;this._previousFocus=q instanceof HTMLElement&&q!==document.body&&!this.contains(q)?q:null}_restoreFocus(){let q=this._previousFocus;if(this._previousFocus=null,!q?.isConnected)return;let Q=document.activeElement;if(Q&&Q!==document.body&&!this.contains(Q))return;requestAnimationFrame(()=>q.focus?.())}_assignStackingOrder(){this.style.zIndex=String(E0()+1)}_clearStackingOrder(){this.style.zIndex=""}show(){return this._captureFocusBeforeOpen(),this._assignStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),A.dismissHoverTooltips(),super.show()}showModal(){return this._captureFocusBeforeOpen(),this._clearStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),A.dismissHoverTooltips(),super.showModal()}close(...q){let Q=super.close(...q);return this._clearStackingOrder(),Q}_handleIframeMouseLeave(q){let Q=q?.currentTarget;if(!(Q instanceof HTMLIFrameElement))return;try{Q.contentWindow?.postMessage({type:"figui:dismiss-tooltips"},"*")}catch{}}_syncIframeDismissListeners(){for(let q of this.querySelectorAll(":scope > iframe")){if(!(q instanceof HTMLIFrameElement))continue;if(q.dataset.figuiDismissBound==="true")continue;q.dataset.figuiDismissBound="true",q.addEventListener("mouseleave",this._boundIframeMouseLeave)}}_setupIframeDismissListeners(){if(this._syncIframeDismissListeners(),this._iframeDismissMutationObserver)return;this._iframeDismissMutationObserver=new MutationObserver(()=>{this._syncIframeDismissListeners()}),this._iframeDismissMutationObserver.observe(this,{childList:!0,subtree:!1})}_teardownIframeDismissListeners(){this._iframeDismissMutationObserver?.disconnect(),this._iframeDismissMutationObserver=null;for(let q of this.querySelectorAll(":scope > iframe"))q.removeEventListener("mouseleave",this._boundIframeMouseLeave),delete q.dataset.figuiDismissBound}_handleIframeMessage(q){if(!this.autoresize)return;let Q=q?.data;if(!Q||Q.type!=="figui:iframe-resize")return;let Z=q.source;if(!Z)return;let $=Array.from(this.querySelectorAll("iframe")).find((J)=>J.contentWindow===Z);if(!$)return;this._resizeForIframe($,Q)}_syncAutoResize(){if(this.autoresize)this._setupAutoResize(),this._scheduleAutoResize();else this._teardownAutoResize()}_setupAutoResize(){if(!this._resizeObserver){this._resizeObserver=new ResizeObserver(this._boundContentResize);for(let q of this.children)try{this._resizeObserver.observe(q)}catch{}}if(!this._mutationObserver)this._mutationObserver=new MutationObserver((q)=>{for(let Q of q)Q.addedNodes?.forEach((Z)=>{if(Z instanceof Element&&Z.parentElement===this)try{this._resizeObserver?.observe(Z)}catch{}});this._scheduleAutoResize()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}_teardownAutoResize(){if(this._resizeObserver)this._resizeObserver.disconnect(),this._resizeObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;if(this._autoResizeRafId)cancelAnimationFrame(this._autoResizeRafId),this._autoResizeRafId=0}_scheduleAutoResize(){if(!this.autoresize)return;if(this._autoResizeRafId)return;this._autoResizeRafId=requestAnimationFrame(()=>{this._autoResizeRafId=0,this._applyAutoResize()})}_applyAutoResize(){if(!this.autoresize)return;if(this.querySelector(":scope > iframe"))return;this._resizeToContent(null)}_computeChrome(q){let Q=window.getComputedStyle(this),Z=parseFloat(Q.paddingTop||"0")+parseFloat(Q.paddingBottom||"0")+parseFloat(Q.borderTopWidth||"0")+parseFloat(Q.borderBottomWidth||"0"),$=0,J=parseFloat(Q.rowGap||Q.gap||"0")||0,j=0;for(let _ of this.children){let W=_.getBoundingClientRect();if(W.height===0)continue;if(j+=1,_===q)continue;let N=window.getComputedStyle(_),K=parseFloat(N.marginTop||"0")+parseFloat(N.marginBottom||"0");$+=W.height+K}if(J&&j>1)$+=J*(j-1);return Z+$}_resizeForIframe(q,Q){if(typeof Q.height!=="number"||!(Q.height>0))return;let Z=this._computeChrome(q);this.style.height=`${Math.ceil(Q.height+Z)}px`}_resizeToContent(){if(this.style.height)this.style.height=""}_ensureHeader(){if(this.querySelector("fig-header[dialog-header]"))return;let q=document.createElement("fig-header");q.setAttribute("dialog-header",""),q.setAttribute("data-auto","");let Q=document.createElement("h3");Q.textContent=this.getAttribute("title")||"Dialog";let Z=document.createElement("fig-tooltip");Z.setAttribute("text","Close");let $=document.createElement("fig-button");$.setAttribute("variant","ghost"),$.setAttribute("icon",""),$.setAttribute("aria-label","Close dialog"),$.setAttribute("close-dialog",""),$.appendChild(c("close")),Z.appendChild($),q.appendChild(Q),q.appendChild(Z),this.prepend(q)}_addCloseListeners(){this.querySelectorAll("fig-button[close-dialog]").forEach((q)=>{if(!q.hasAttribute("aria-label"))q.setAttribute("aria-label","Close dialog");q.removeEventListener("click",this._boundClose),q.addEventListener("click",this._boundClose)})}_syncA11y(){if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let q=this.querySelector("fig-header[dialog-header] h1, fig-header[dialog-header] h2, fig-header[dialog-header] h3, fig-header[dialog-header] h4, fig-header[dialog-header] h5, fig-header[dialog-header] h6");if(q){let Q=q.getAttribute("id")||h();q.setAttribute("id",Q),this.setAttribute("aria-labelledby",Q)}}}_applyPosition(){let q=this.getAttribute("position")||"";this.style.position="fixed",this.style.transform="none",this.style.top="auto",this.style.bottom="auto",this.style.left="auto",this.style.right="auto",this.style.margin="0";let Q=q.includes("top"),Z=q.includes("bottom"),$=q.includes("left"),J=q.includes("right"),j=q.includes("center")&&!Q&&!Z,_=q.includes("center")&&!$&&!J;if(Q)this.style.top=`${this._offset}px`;else if(Z)this.style.bottom=`${this._offset}px`;else if(j)this.style.top="0",this.style.bottom="0";if($)this.style.left=`${this._offset}px`;else if(J)this.style.right=`${this._offset}px`;else if(_)this.style.left="0",this.style.right="0";if(j&&_)this.style.margin="auto";else if(j)this.style.marginTop="auto",this.style.marginBottom="auto";else if(_)this.style.marginLeft="auto",this.style.marginRight="auto";this._positionInitialized=!0}_setupDragListeners(){if(this.drag){this.addEventListener("pointerdown",this._boundPointerDown);let q=this.getAttribute("handle"),Q=q?this.querySelector(q):this.querySelector("fig-header, header");if(Q)Q.style.cursor="grab"}}_removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}_isInteractiveElement(q){let Q=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],Z=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],$=(j)=>Q.some((_)=>j.matches?.(_))||j.tagName?.startsWith("FIG-")&&!Z.includes(j.tagName);if($(q))return!0;let J=q.parentElement;while(J&&J!==this){if($(J))return!0;J=J.parentElement}return!1}_handlePointerDown(q){if(!this.drag)return;if(this._isInteractiveElement(q.target))return;let Q=this.getAttribute("handle");if(Q&&Q.trim()){let $=this.querySelector(Q);if(!$||!$.contains(q.target))return}this._dragPending=!0,this._dragStartPos.x=q.clientX,this._dragStartPos.y=q.clientY;let Z=this.getBoundingClientRect();this._dragOffset.x=q.clientX-Z.left,this._dragOffset.y=q.clientY-Z.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}_handlePointerMove(q){if(this._dragPending&&!this._isDragging){let Q=Math.abs(q.clientX-this._dragStartPos.x),Z=Math.abs(q.clientY-this._dragStartPos.y);if(Q>this._dragThreshold||Z>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this.setPointerCapture(q.pointerId),this.style.cursor="grabbing";let $=this.getBoundingClientRect();this.style.top=`${$.top}px`,this.style.left=`${$.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${q.clientX-this._dragOffset.x}px`,this.style.top=`${q.clientY-this._dragOffset.y}px`,q.preventDefault()}_handlePointerUp(q){if(this._isDragging){if(this.hasPointerCapture?.(q.pointerId))this.releasePointerCapture(q.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle","title","resizable","closedby","autoresize","aria-label","aria-labelledby"]}attributeChangedCallback(q,Q,Z){if(this._figInit(),q==="autoresize"&&this.isConnected)this._syncAutoResize();if(q==="drag")if(this.drag=Z!==null&&Z!=="false",this.drag)this._setupDragListeners();else{this._removeDragListeners();let $=this.querySelector("fig-header, header");if($)$.style.cursor=""}if(q==="position"&&this._positionInitialized)this._applyPosition();if(q==="modal"){let $=this.modal;if(this.modal=Z!==null&&Z!=="false",this.open&&$!==this.modal)if(this.close(),this.modal)this.showModal();else this.show()}if(q==="closedby")this.closedby=Z||"any";if(q==="title"){let $=this.querySelector("fig-header[data-auto] h3");if($)$.textContent=Z||"Dialog";this._syncA11y()}if(q==="aria-label"||q==="aria-labelledby")this._syncA11y()}}O0("fig-dialog",b0,{extends:"dialog"});class h0 extends HTMLDialogElement{constructor(){super();this._figInit()}_figInit(){if(this._figInitialized)return;this._figInitialized=!0,this._defaultOffset=16,this._autoCloseTimer=null,this._toastVisible=!1,this._syncingOpen=!1,this._managedRole=null,this._managedLive=null,this._boundHandleClose=this.handleClose.bind(this)}connectedCallback(){if(this._figInit(),!this.hasAttribute("theme"))this.setAttribute("theme","dark");if(this.syncLiveRegion(),this.addCloseListeners(),this.applyPosition(),this.hasAttribute("open")&&this.getAttribute("open")!=="false")this.showToast();else{if(this.getAttribute("open")==="false")this._syncingOpen=!0,this.removeAttribute("open"),this._syncingOpen=!1;this._toastVisible=!1}}disconnectedCallback(){this._figInit(),this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((q)=>{if(!q.hasAttribute("aria-label"))q.setAttribute("aria-label","Close notification");q.removeEventListener("click",this._boundHandleClose),q.addEventListener("click",this._boundHandleClose)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto";let q=Number.parseFloat(this.getAttribute("offset")),Q=Number.isFinite(q)?q:this._defaultOffset;this.style.bottom=`${Q}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}syncLiveRegion(){let q=this.getAttribute("live")==="assertive"||this.getAttribute("theme")==="danger",Q=q?"alert":"status",Z=q?"assertive":"polite";if(!this.hasAttribute("role")||this.getAttribute("role")===this._managedRole)this.setAttribute("role",Q),this._managedRole=Q;if(!this.hasAttribute("aria-live")||this.getAttribute("aria-live")===this._managedLive)this.setAttribute("aria-live",Z),this._managedLive=Z;if(!this.hasAttribute("aria-atomic"))this.setAttribute("aria-atomic","true")}startAutoClose(){this.clearAutoClose();let q=parseInt(this.getAttribute("duration")??"5000");if(q>0)this._autoCloseTimer=setTimeout(()=>this.hideToast(),q)}clearAutoClose(){if(this._autoCloseTimer)clearTimeout(this._autoCloseTimer),this._autoCloseTimer=null}_resolveAutoTheme(){if(this.getAttribute("theme")!=="auto")return;let q=getComputedStyle(document.documentElement).colorScheme||"";this.style.colorScheme=q.includes("dark")?"light":"dark"}showToast(){let q=this._toastVisible;this.syncLiveRegion(),this._resolveAutoTheme(),this._syncingOpen=!0;try{if(!this.open)this.show()}finally{this._syncingOpen=!1}if(this._toastVisible=!0,this.applyPosition(),this.startAutoClose(),!q)this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){let q=this._toastVisible||this.open;this.clearAutoClose(),this._syncingOpen=!0;try{if(this.open)this.close();else if(this.hasAttribute("open"))this.removeAttribute("open")}finally{this._syncingOpen=!1}if(this._toastVisible=!1,q)this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme","live"]}attributeChangedCallback(q,Q,Z){if(this._figInit(),Q===Z)return;if(!this.isConnected)return;if(this._syncingOpen)return;if(q==="offset")this.applyPosition();if(q==="open")if(Z!==null&&Z!=="false")this.showToast();else this.hideToast();if(q==="duration"&&this._toastVisible)this.startAutoClose();if(q==="theme")if(Z==="auto")this._resolveAutoTheme();else this.style.removeProperty("color-scheme");if(q==="theme"||q==="live")this.syncLiveRegion()}}O0("fig-toast",h0,{extends:"dialog"});class v0 extends HTMLDialogElement{_anchorObserver=null;_contentObserver=null;_mutationObserver=null;_anchorTrackRAF=null;_lastAnchorRect=null;_isPopupActive=!1;_boundReposition;_boundScroll;_boundOutsidePointerDown;_rafId=null;_anchorRef=null;_isDragging=!1;_dragPending=!1;_dragStartPos={x:0,y:0};_dragOffset={x:0,y:0};_dragThreshold=3;_boundPointerDown;_boundPointerMove;_boundPointerUp;_wasDragged=!1;_previousFocus=null;_boundDocumentKeydown;_boundNativeClose;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(q)=>{let Q=q.target;if(this.open&&(!(Q instanceof Node)||!this.contains(Q))&&this.shouldAutoReposition())this.queueReposition()},this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this),this._boundPointerDown=this.handlePointerDown.bind(this),this._boundPointerMove=this.handlePointerMove.bind(this),this._boundPointerUp=this.handlePointerUp.bind(this),this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this),this._boundNativeClose=this.handleNativeClose.bind(this)}ensureInitialized(){if(typeof this._anchorObserver>"u")this._anchorObserver=null;if(typeof this._contentObserver>"u")this._contentObserver=null;if(typeof this._mutationObserver>"u")this._mutationObserver=null;if(typeof this._anchorTrackRAF>"u")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect>"u")this._lastAnchorRect=null;if(typeof this._isPopupActive>"u")this._isPopupActive=!1;if(typeof this._rafId>"u")this._rafId=null;if(typeof this._anchorRef>"u")this._anchorRef=null;if(typeof this._isDragging>"u")this._isDragging=!1;if(typeof this._dragPending>"u")this._dragPending=!1;if(typeof this._dragStartPos>"u")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset>"u")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged>"u")this._wasDragged=!1;if(typeof this._previousFocus>"u")this._previousFocus=null;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(q)=>{let Q=q.target;if(this.open&&(!(Q instanceof Node)||!this.contains(Q))&&this.shouldAutoReposition())this.queueReposition()};if(typeof this._boundOutsidePointerDown!=="function")this._boundOutsidePointerDown=this.handleOutsidePointerDown.bind(this);if(typeof this._boundPointerDown!=="function")this._boundPointerDown=this.handlePointerDown.bind(this);if(typeof this._boundPointerMove!=="function")this._boundPointerMove=this.handlePointerMove.bind(this);if(typeof this._boundPointerUp!=="function")this._boundPointerUp=this.handlePointerUp.bind(this);if(typeof this._boundDocumentKeydown!=="function")this._boundDocumentKeydown=this.handleDocumentKeydown.bind(this);if(typeof this._boundNativeClose!=="function")this._boundNativeClose=this.handleNativeClose.bind(this)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(q){if(q===!1||q==="false"||q===null){if(!(this.matches?.(":open")||this.matches?.(":popover-open"))&&!this.hasAttribute("open"))return;if(this.hidePopup(),this.hasAttribute("open"))this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(q){if(q instanceof Element)this._anchorRef=q;else if(typeof q==="string")this._anchorRef=null,this.setAttribute("anchor",q);else if(q&&typeof q.getBoundingClientRect==="function")this._anchorRef=q;else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),this.getAttribute("variant")==="tooltip"){if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("offset"))this.setAttribute("offset","8 8");if(!this.hasAttribute("viewport-margin"))this.setAttribute("viewport-margin","8");if(!this.hasAttribute("theme"))this.setAttribute("theme","menu")}if(!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role",this.getAttribute("variant")==="tooltip"?"tooltip":"dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this.removeEventListener("close",this._boundNativeClose),this.addEventListener("close",this._boundNativeClose),requestAnimationFrame(()=>{this.setupDragListeners()}),this.open)this.showPopup();else this.hidePopup()}disconnectedCallback(){if(this.ensureInitialized(),this.teardownObservers(),this.removeDragListeners(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this.removeEventListener("close",this._boundNativeClose),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(q,Q,Z){if(this.ensureInitialized(),Q===Z)return;if(q==="open"){if(Z==="false"){this.open=!1;return}if(Z===null){this.hidePopup();return}this.showPopup();return}if(q==="drag"){if(this.drag=Z!==null&&Z!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(E0()+1),this.captureFocusBeforeOpen();let q=this.hasAttribute("popover")&&typeof this.showPopover==="function"&&!this.matches?.(":popover-open"),Q=this.shouldAutoReposition();if(Q)this.style.visibility="hidden";if(q)try{this.showPopover()}catch($){q=!1}if(!q&&!super.open)try{this.show()}catch($){}if(Q&&(this.matches?.(":open")||this.matches?.(":popover-open")))this.positionPopup(),this.style.visibility="";this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.addEventListener("keydown",this._boundDocumentKeydown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;let Z=this.resolveAnchor();if(Z?.classList)Z.classList.add("has-popup-open");if(this.getAttribute("variant")!=="tooltip")A.dismissHoverTooltips()}hidePopup(){let q=this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"),Q=this.resolveAnchor();if(Q?.classList)Q.classList.remove("has-popup-open");if(this.style.visibility="",this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),document.removeEventListener("keydown",this._boundDocumentKeydown,!0),this.hasAttribute("popover")&&typeof this.hidePopover==="function"&&this.matches?.(":popover-open"))try{this.hidePopover()}catch(Z){}if(this.matches?.(":open"))try{this.close()}catch(Z){}if(q)this.restoreFocusAfterClose()}shouldRestoreFocus(){return this.getAttribute("variant")!=="tooltip"}captureFocusBeforeOpen(){if(!this.shouldRestoreFocus())return;let q=document.activeElement;this._previousFocus=q instanceof HTMLElement&&q!==document.body&&!this.contains(q)?q:null}restoreFocusAfterClose(){if(!this.shouldRestoreFocus()){this._previousFocus=null;return}let q=this.resolveAnchor(),Q=this._previousFocus?.isConnected?this._previousFocus:q instanceof HTMLElement?q:null;if(this._previousFocus=null,!Q?.isConnected)return;let Z=document.activeElement;if(Z&&Z!==document.body&&!this.contains(Z))return;requestAnimationFrame(()=>Q.focus?.())}get autoresize(){let q=this.getAttribute("autoresize");return q===null||q!=="false"}set autoresize(q){if(q===!1||q==="false"||q===null)this.setAttribute("autoresize","false");else if(q||q==="")this.setAttribute("autoresize",q===!0?"":q);else this.setAttribute("autoresize","false")}handleNativeClose(){if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}setupObservers(){this.teardownObservers();let q=this.resolveAnchor();if(q instanceof Element&&"ResizeObserver"in window)this._anchorObserver=new ResizeObserver(this._boundReposition),this._anchorObserver.observe(q);if(this.autoresize){if("ResizeObserver"in window)this._contentObserver=new ResizeObserver(this._boundReposition),this._contentObserver.observe(this);this._mutationObserver=new MutationObserver(this._boundReposition),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0})}window.addEventListener("resize",this._boundReposition),window.addEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.startAnchorTracking()}teardownObservers(){if(this._anchorObserver)this._anchorObserver.disconnect(),this._anchorObserver=null;if(this._contentObserver)this._contentObserver.disconnect(),this._contentObserver=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null;window.removeEventListener("resize",this._boundReposition),window.removeEventListener("scroll",this._boundScroll,{capture:!0,passive:!0}),this.stopAnchorTracking()}readRectSnapshot(q){if(!q)return null;let Q=q.getBoundingClientRect();return{x:Q.x,y:Q.y,width:Q.width,height:Q.height}}hasRectChanged(q,Q,Z=0.25){if(!q&&!Q)return!1;if(!q||!Q)return!0;return Math.abs(q.x-Q.x)>Z||Math.abs(q.y-Q.y)>Z||Math.abs(q.width-Q.width)>Z||Math.abs(q.height-Q.height)>Z}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;let q=()=>{if(!this.open){this._anchorTrackRAF=null;return}let Q=this.resolveAnchor(),Z=this.readRectSnapshot(Q),$=this.shouldAutoReposition();if($&&this.hasRectChanged(this._lastAnchorRect,Z))this._lastAnchorRect=Z,this.queueReposition();else if(!$)this._lastAnchorRect=Z;this._anchorTrackRAF=requestAnimationFrame(q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(q){if(!this.open||!(this.matches?.(":open")||this.matches?.(":popover-open")))return;let Q=this.getAttribute("closedby");if(Q==="none"||Q==="closerequest")return;let Z=q.target;if(!(Z instanceof Node))return;let $=typeof q.composedPath==="function"?q.composedPath():[];if($.includes(this))return;if(this.contains(Z))return;let J=this.resolveAnchor();if(J&&($.includes(J)||J.contains?.(Z)))return;if(this.isInsideDescendantPopup(Z))return;this.open=!1}handleDocumentKeydown(q){if(q.key!=="Escape"||q.defaultPrevented)return;if(!this.open)return;if(this.getAttribute("role")==="menu")return;if(this.getAttribute("closedby")==="none")return;let $=Array.from(document.querySelectorAll('dialog[is="fig-popup"][open]')).filter((J)=>J.open).map((J)=>({popup:J,z:Number.parseInt(getComputedStyle(J).zIndex||"0",10)||0})).sort((J,j)=>J.z-j.z).at(-1)?.popup;if($&&$!==this)return;q.preventDefault(),this.open=!1}isInsideDescendantPopup(q){let Q=q.closest?.('dialog[is="fig-popup"]');if(!Q||Q===this)return!1;let Z=Q,$=new Set;while(Z&&!$.has(Z)){$.add(Z);let J=Z.anchor;if(!(J instanceof Element))break;if(this.contains(J))return!0;Z=J.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp)}isInteractiveElement(q){let Q=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],Z=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],$=(j)=>Q.some((_)=>j.matches?.(_))||j.tagName?.startsWith("FIG-")&&!Z.includes(j.tagName);if($(q))return!0;let J=q.parentElement;while(J&&J!==this){if($(J))return!0;J=J.parentElement}return!1}handlePointerDown(q){if(!this.drag)return;if(this.isInteractiveElement(q.target))return;let Q=this.getAttribute("handle");if(Q&&Q.trim()){let $=this.querySelector(Q);if(!$||!$.contains(q.target))return}this._dragPending=!0,this._dragStartPos.x=q.clientX,this._dragStartPos.y=q.clientY;let Z=this.getBoundingClientRect();this._dragOffset.x=q.clientX-Z.left,this._dragOffset.y=q.clientY-Z.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp),document.addEventListener("pointercancel",this._boundPointerUp)}handlePointerMove(q){if(this._dragPending&&!this._isDragging){let Q=Math.abs(q.clientX-this._dragStartPos.x),Z=Math.abs(q.clientY-this._dragStartPos.y);if(Q>this._dragThreshold||Z>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(q.pointerId),this.style.cursor="grabbing";let $=this.getBoundingClientRect();this.style.top=`${$.top}px`,this.style.left=`${$.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${q.clientX-this._dragOffset.x}px`,this.style.top=`${q.clientY-this._dragOffset.y}px`,q.preventDefault()}handlePointerUp(q){if(this._isDragging){if(this.hasPointerCapture?.(q.pointerId))this.releasePointerCapture(q.pointerId);this.style.cursor=""}this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),document.removeEventListener("pointercancel",this._boundPointerUp),q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;let q=this.getAttribute("anchor");if(!q)return null;let Q=this.parentElement;try{if(Q?.querySelector){let Z=Q.querySelector(q);if(Z&&!this.contains(Z))return Z}return document.querySelector(q)}catch{return null}}parsePosition(){let Q=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),Z=new Set(["top","center","bottom"]),$=new Set(["left","center","right"]),J="top",j="center",_=null;if(Q.length>=2){if(Z.has(Q[0]))J=Q[0];if($.has(Q[1]))j=Q[1];return{vertical:J,horizontal:j,shorthand:_}}if(Q.length===1){let W=Q[0];if(W==="top"||W==="bottom")J=W,_=W;else if(W==="left"||W==="right")j=W,_=W;else if(W==="center")J="center",j="center"}return{vertical:J,horizontal:j,shorthand:_}}normalizeOffsetToken(q,Q="0px"){if(!q)return Q;let Z=q.trim();if(!Z)return Q;if(/^-?\d+(\.\d+)?$/.test(Z))return`${Z}px`;return Z}measureLengthPx(q,Q="x"){if(!q)return 0;let Z=this.normalizeOffsetToken(q,"0px");if(Z.endsWith("px")){let j=parseFloat(Z);return Number.isFinite(j)?j:0}let $=document.createElement("div");if($.style.position="fixed",$.style.visibility="hidden",$.style.pointerEvents="none",$.style.left="0",$.style.top="0",$.style.margin="0",$.style.padding="0",$.style.border="0",Q==="x")$.style.width=Z,$.style.height="0";else $.style.height=Z,$.style.width="0";document.body.appendChild($);let J=$.getBoundingClientRect();return $.remove(),Q==="x"?J.width:J.height}parseOffset(){let Q=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),Z=this.normalizeOffsetToken(Q[0],"0px"),$=this.normalizeOffsetToken(Q[1],"0px");return{xToken:Z,yToken:$,xPx:this.measureLengthPx(Z,"x"),yPx:this.measureLengthPx($,"y")}}parseViewportMargins(){let Q=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter(($)=>!Number.isNaN($)),Z=8;if(Q.length===0)return{top:8,right:8,bottom:8,left:8};if(Q.length===1)return{top:Q[0],right:Q[0],bottom:Q[0],left:Q[0]};if(Q.length===2)return{top:Q[0],right:Q[1],bottom:Q[0],left:Q[1]};if(Q.length===3)return{top:Q[0],right:Q[1],bottom:Q[2],left:Q[1]};return{top:Q[0],right:Q[1],bottom:Q[2],left:Q[3]}}getPlacementCandidates(q,Q,Z){let $={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if(Z){let j=Z==="left"||Z==="right"?["top","bottom"]:["left","right"];return[{v:q,h:Q,s:Z},{v:q,h:Q,s:$[Z]},{v:q,h:Q,s:j[0]},{v:q,h:Q,s:j[1]}]}if(q==="center")return[{v:"center",h:Q,s:null},{v:"center",h:$[Q],s:null},{v:"top",h:Q,s:null},{v:"bottom",h:Q,s:null},{v:"top",h:$[Q],s:null},{v:"bottom",h:$[Q],s:null}];if(Q==="center")return[{v:q,h:"center",s:null},{v:$[q],h:"center",s:null},{v:q,h:"left",s:null},{v:q,h:"right",s:null},{v:$[q],h:"left",s:null},{v:$[q],h:"right",s:null}];return[{v:q,h:Q,s:null},{v:$[q],h:Q,s:null},{v:q,h:$[Q],s:null},{v:$[q],h:$[Q],s:null}]}computeCoords(q,Q,Z,$,J,j){let _,W;if(j==="left"||j==="right")return W=j==="left"?q.left-Q.width-J.xPx:q.right+J.xPx,_=q.top,{top:_,left:W};if(j==="top"||j==="bottom")return _=j==="top"?q.top-Q.height-J.yPx:q.bottom+J.yPx,W=q.left,{top:_,left:W};if(Z==="top")_=q.top-Q.height-J.yPx;else if(Z==="bottom")_=q.bottom+J.yPx;else _=q.top+(q.height-Q.height)/2;if(Z==="center")if($==="left")W=q.left-Q.width-J.xPx;else if($==="right")W=q.right+J.xPx;else W=q.left+(q.width-Q.width)/2;else if($==="left")W=q.left+J.xPx;else if($==="right")W=q.right-Q.width-J.xPx;else W=q.left+(q.width-Q.width)/2;return{top:_,left:W}}oppositeSide(q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[q]||"bottom"}getPlacementSide(q,Q,Z){if(Z==="top")return"top";if(Z==="bottom")return"bottom";if(Z==="left")return"left";if(Z==="right")return"right";if(q!=="center")return q;if(Q!=="center")return Q;return"top"}lengthToPx(q,Q=0){let Z=getComputedStyle(this),$=String(q||"").trim(),J=parseFloat($);if(!Number.isFinite(J))return Q;if($.endsWith("rem"))return J*parseFloat(getComputedStyle(document.documentElement).fontSize);if($.endsWith("em"))return J*parseFloat(Z.fontSize);return J}radiusForSide(q){let Q=getComputedStyle(this),Z=($)=>this.lengthToPx($,0);if(q==="top")return Math.max(Z(Q.borderTopLeftRadius),Z(Q.borderTopRightRadius));if(q==="bottom")return Math.max(Z(Q.borderBottomLeftRadius),Z(Q.borderBottomRightRadius));if(q==="left")return Math.max(Z(Q.borderTopLeftRadius),Z(Q.borderBottomLeftRadius));if(q==="right")return Math.max(Z(Q.borderTopRightRadius),Z(Q.borderBottomRightRadius));return 0}getBeakEdgeInset(q){let Q=this.lengthToPx(getComputedStyle(this).getPropertyValue("--fig-popup-beak-width"),16);return Math.max(10,this.radiusForSide(q)+Q/2)}tracksAnchorBeak(){let q=this.getAttribute("variant");return q==="popover"||q==="tooltip"}getViewportBounds(q){let Q=window.visualViewport,Z=Q?.width??window.innerWidth,$=Q?.height??window.innerHeight,J=Q?.offsetLeft??0,j=Q?.offsetTop??0;return{minLeft:J+q.left,minTop:j+q.top,maxRight:J+Z-q.right,maxBottom:j+$-q.bottom}}clampToViewport(q,Q,Z){let $=this.getViewportBounds(Z),J=$.maxRight-Q.width,j=$.maxBottom-Q.height;return{left:Math.min(J,Math.max($.minLeft,q.left)),top:Math.min(j,Math.max($.minTop,q.top))}}resolveCoordsAtViewport(q,Q,Z,$,J){let{left:j,top:_}=this.clampToViewport(Z,Q,J);if(!q||!this.tracksAnchorBeak())return{left:j,top:_};let W=this.oppositeSide($),N=this.getViewportBounds(J),K=N.maxRight-Q.width,G=N.minLeft,U=N.maxBottom-Q.height,X=N.minTop;if(W==="top"||W==="bottom"){let O=this.getBeakEdgeInset(W),R=q.left+q.width/2,L=R-j;if(L<O)j=R-O;else if(L>Q.width-O)j=R-(Q.width-O);j=Math.min(K,Math.max(G,j))}else if(W==="left"||W==="right"){let O=this.getBeakEdgeInset(W),R=q.top+q.height/2,L=R-_;if(L<O)_=R-O;else if(L>Q.height-O)_=R-(Q.height-O);_=Math.min(U,Math.max(X,_))}return{left:j,top:_}}canPointAtAnchor(q,Q,Z,$,J){if(!q||!this.tracksAnchorBeak())return!0;let j=this.oppositeSide(J),_=this.getBeakEdgeInset(j);if(j==="top"||j==="bottom"){let N=q.left+q.width/2-Z;return N>=_-0.5&&N<=Q.width-_+0.5}let W=q.top+q.height/2-$;return W>=_-0.5&&W<=Q.height-_+0.5}updatePopoverBeak(q,Q,Z,$,J){if(!this.tracksAnchorBeak()||!q){this.style.removeProperty("--fig-popup-beak-offset"),this.removeAttribute("data-beak-side");return}let j=this.oppositeSide(J);this.setAttribute("data-beak-side",j);let _=q.left+q.width/2,W=q.top+q.height/2,N=this.getBoundingClientRect(),K=N.width>0&&N.height>0?N:Q,G=K.left,U=K.top,X=this.getBeakEdgeInset(j),O;if(j==="top"||j==="bottom"){O=_-G;let R=X,L=Math.max(R,K.width-X);O=Math.min(L,Math.max(R,O))}else{O=W-U;let R=X,L=Math.max(R,K.height-X);O=Math.min(L,Math.max(R,O))}this.style.setProperty("--fig-popup-beak-offset",`${O}px`)}overflowScore(q,Q,Z){let $=this.getViewportBounds(Z),J=q.left+Q.width,j=q.top+Q.height,_=Math.max(0,$.minLeft-q.left),W=Math.max(0,$.minTop-q.top),N=Math.max(0,J-$.maxRight),K=Math.max(0,j-$.maxBottom);return _+W+N+K}fits(q,Q,Z){return this.overflowScore(q,Q,Z)===0}clamp(q,Q,Z,$=null,J="top"){if($)return this.resolveCoordsAtViewport($,Q,q,J,Z);return this.clampToViewport(q,Q,Z)}primaryAxisOverflowPenalty(q,Q,Z,$){let J=this.getViewportBounds(Z),j=0;if($==="top")j=Math.max(0,J.minTop-q.top);else if($==="bottom")j=Math.max(0,q.top+Q.height-J.maxBottom);else if($==="left")j=Math.max(0,J.minLeft-q.left);else if($==="right")j=Math.max(0,q.left+Q.width-J.maxRight);return j>0?1000+j:0}placementScore(q,Q,Z,$,J){let j=this.resolveCoordsAtViewport(q,Q,Z,$,J),_=this.overflowScore(j,Q,J);if(_+=this.primaryAxisOverflowPenalty(Z,Q,J,$),q&&!this.canPointAtAnchor(q,Q,j.left,j.top,$))_+=1e4;return{score:_,resolved:j}}applyPopupPosition(q,Q,Z,$,J){let j=this.resolveCoordsAtViewport(q,Q,Z,$,J);this.style.left=`${j.left}px`,this.style.top=`${j.top}px`,this.updatePopoverBeak(q,Q,j.left,j.top,$)}positionPopup(){if(!this.open)return;let q=this.getBoundingClientRect(),Q=this.parseOffset(),{vertical:Z,horizontal:$,shorthand:J}=this.parsePosition(),j=this.resolveAnchor(),_=this.parseViewportMargins();if(!j){this.updatePopoverBeak(null,q,0,0,"top");let X=this.getViewportBounds(_),O={left:X.minLeft+(X.maxRight-X.minLeft-q.width)/2,top:X.minTop+(X.maxBottom-X.minTop-q.height)/2},R=this.clampToViewport(O,q,_);this.style.left=`${R.left}px`,this.style.top=`${R.top}px`;return}let W=j.getBoundingClientRect(),N=this.getPlacementCandidates(Z,$,J),K=null,G="top",U=Number.POSITIVE_INFINITY;for(let{v:X,h:O,s:R}of N){let L=this.computeCoords(W,q,X,O,Q,R),D=this.getPlacementSide(X,O,R),{score:F,resolved:H}=this.placementScore(W,q,L,D,_);if(R){let B=this.getViewportBounds(_);if((R==="left"||R==="right"?L.left>=B.minLeft&&L.left+q.width<=B.maxRight:L.top>=B.minTop&&L.top+q.height<=B.maxBottom)&&F<1e4){this.applyPopupPosition(W,q,L,D,_);return}}else if(F===0){this.applyPopupPosition(W,q,L,D,_);return}if(F<U)U=F,K=H,G=D}this.applyPopupPosition(W,q,K||{left:0,top:0},G,_)}queueReposition(){if(!this.open||!this.isPopupDisplayed()||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}isPopupDisplayed(){return Boolean(this._isPopupActive||this.matches?.(":open")||this.matches?.(":popover-open"))}}O0("fig-popup",v0,{extends:"dialog"});class m0 extends HTMLElement{#Q;#q;constructor(){super();this.content=null,this.#Q=!1,this.#q=this.handleClick.bind(this)}connectedCallback(){if(this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.addEventListener("click",this.#q),u(this,()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content){let q=this.getAttribute("id")||h(),Q=this.content.getAttribute("id")||h();if(this.setAttribute("id",q),this.content.setAttribute("id",Q),this.setAttribute("aria-controls",Q),this.content.setAttribute("role","tabpanel"),this.content.setAttribute("aria-labelledby",q),this.#Q)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}}})}get selected(){return this.#Q}set selected(q){this.setAttribute("selected",q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#q)}handleClick(){if(z(this,"disabled"))return;if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected","disabled"]}attributeChangedCallback(q,Q,Z){if(q==="selected"){if(this.#Q=Z!==null&&Z!=="false",this.setAttribute("aria-selected",this.#Q?"true":"false"),this.setAttribute("tabindex",this.#Q?"0":"-1"),this?.content)this.content.style.display=this.#Q?"block":"none"}if(q==="disabled")if(Z!==null&&Z!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",this.#Q?"0":"-1")}}M("fig-tab",m0);class g0 extends HTMLElement{#Q;#q;#Z=this.#L.bind(this);#$=null;#J=null;#j=null;#N=null;#_=!1;#W=new WeakSet;constructor(){super();this.#Q=this.handleClick.bind(this),this.#q=this.#H.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){if(this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#U(),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#q),this.addEventListener("scroll",this.#Z),this.#R(),this.#M(),this.#z(),u(this,()=>{let q=this.getAttribute("value");if(q)this.#A(q);if(z(this,"disabled"))this.#Y(!0);this.#K(),this.#L(),this.#X(void 0,"auto")})}#Y(q){this.querySelectorAll("fig-tab").forEach((Z)=>{if(q){if(!(Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false"))this.#W.add(Z),Z.setAttribute("disabled","");Z.setAttribute("aria-disabled","true"),Z.setAttribute("tabindex","-1")}else if(this.#W.has(Z))this.#W.delete(Z),Z.removeAttribute("disabled"),Z.removeAttribute("aria-disabled")}),this.#K()}#G(){return Array.from(this.querySelectorAll("fig-tab")).filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false")}#K(){let q=Array.from(this.querySelectorAll("fig-tab")),Q=q.find((Z)=>Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false")||this.#G()[0];q.forEach((Z)=>{let $=Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false";Z.setAttribute("tabindex",!$&&Z===Q?"0":"-1")})}#X(q=this.selectedTab,Q="smooth"){let Z=q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#G()[0];if(!Z)return;requestAnimationFrame(()=>{if(!this.isConnected||!Z.isConnected)return;if(!(this.scrollWidth>this.clientWidth))return;let J=this.getBoundingClientRect(),j=Z.getBoundingClientRect(),_=j.left-J.left+this.scrollLeft+j.width/2;this.scrollTo({left:_-this.clientWidth/2,behavior:Q}),this.#L()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#q),this.removeEventListener("scroll",this.#Z),this.#$?.disconnect(),this.#$=null,this.#J?.disconnect(),this.#J=null,this.#B()}#U(){if(this.#_)return;let q=this.querySelector(":scope > [data-fig-tabs-scroll]");if(!q)return;this.#_=!0;try{let Q=Array.from(q.childNodes);q.replaceWith(...Q)}finally{this.#_=!1}}#L(){a(this,this,"x")}#z(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>this.#L()),this.#J.observe(this)}#M(){this.#$?.disconnect(),this.#$=new MutationObserver(()=>{if(this.#_)return;this.#U(),this.#R(),this.#K(),requestAnimationFrame(()=>{this.#L(),this.#X()})}),this.#$.observe(this,{childList:!0,subtree:!1})}#B(){this.#j?.remove(),this.#N?.remove(),this.#j=null,this.#N=null,this.classList.remove("overflow-start","overflow-end")}#R(){if(this.#j&&this.#N&&this.contains(this.#j)&&this.contains(this.#N))return;this.#j?.remove(),this.#N?.remove();let q=N0({owner:"tabs",onStart:()=>r(this,"x",-1),onEnd:()=>r(this,"x",1)});this.#j=q.start,this.#N=q.end,this.prepend(this.#j),this.append(this.#N)}#H(q){let Q=this.#G();if(!Q.length)return;let Z=Q.findIndex((J)=>z(J,"selected")),$=Z>=0?Z:0;switch(q.key){case"ArrowLeft":case"ArrowUp":q.preventDefault(),$=Z>0?Z-1:Q.length-1;break;case"ArrowRight":case"ArrowDown":q.preventDefault(),$=Z<Q.length-1?Z+1:0;break;case"Home":q.preventDefault(),$=0;break;case"End":q.preventDefault(),$=Q.length-1;break;default:return}if($!==Z&&Q[$]){this.querySelectorAll("fig-tab").forEach((j)=>j.removeAttribute("selected")),this.selectedTab=Q[$],Q[$].setAttribute("selected","true");let J=this.#T(Q[$]);if(J)this.setAttribute("value",J);else this.removeAttribute("value");Q[$].focus(),this.#K(),this.#X(Q[$]),this.#D()}}get value(){return this.#T(this.selectedTab)}set value(q){this.setAttribute("value",q)}#D(){let q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:q,bubbles:!0}))}#T(q){if(!q)return"";let Q=q.getAttribute("value");if(Q!==null)return Q;return q.textContent?.trim()||""}#A(q){let Q=this.querySelectorAll("fig-tab");for(let Z of Q)if(this.#T(Z)===q)this.selectedTab=Z,Z.setAttribute("selected","true");else Z.removeAttribute("selected");this.#K(),this.#X(this.selectedTab)}attributeChangedCallback(q,Q,Z){switch(q){case"value":if(Z!==Q)this.#A(Z);break;case"disabled":this.#Y(Z!==null&&Z!=="false");break}}handleClick(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=q.target.closest("fig-tab");if(!Q||!this.contains(Q))return;if(Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;let Z=this.selectedTab,$=this.value,J=this.querySelectorAll("fig-tab");for(let _ of J)if(_===Q)this.selectedTab=_,_.setAttribute("selected","true");else _.removeAttribute("selected");let j=this.#T(Q);if(j)this.setAttribute("value",j);else this.removeAttribute("value");if(this.#K(),this.#X(Q),Z!==Q||$!==this.value)this.#D()}}M("fig-tabs",g0);class u0 extends HTMLElement{#Q;#q;#Z;constructor(){super();this.#Z=this.handleClick.bind(this)}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","radio");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#$(),this.addEventListener("click",this.#Z)}disconnectedCallback(){this.removeEventListener("click",this.#Z)}handleClick(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let q=this.closest("fig-segmented-control");if(q&&q.hasAttribute("disabled")&&q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#Q}set value(q){this.#Q=q,this.setAttribute("value",q)}get selected(){return this.#q}set selected(q){this.#q=q,this.setAttribute("selected",q)}static get observedAttributes(){return["selected","value","disabled"]}#$(){let q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-checked",q?"true":"false"),Q)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex",q?"0":"-1")}attributeChangedCallback(q,Q,Z){switch(q){case"value":this.#Q=Z;break;case"selected":this.#q=Z,this.#$();break;case"disabled":this.#$();break}}}M("fig-segment",u0);class c0 extends HTMLElement{#Q=null;#q=this.handleClick.bind(this);#Z=this.#z.bind(this);#$=null;#J=null;#j=0;#N=!1;#_=!1;#W=new WeakSet;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){if(this.name=this.getAttribute("name")||"segmented-control",!this.hasAttribute("role"))this.setAttribute("role","radiogroup");this.addEventListener("click",this.#q),this.addEventListener("keydown",this.#Z),this.#P(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#O(),this.#D(),u(this,()=>{this.#A({enforceFallback:!0}),this.#T(),this.#R({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#q),this.removeEventListener("keydown",this.#Z),this.#$?.disconnect(),this.#$=null,this.#J?.disconnect(),this.#J=null,this.#j)cancelAnimationFrame(this.#j),this.#j=0;this.#N=!1,this.#_=!1}get selectedSegment(){return this.#Q}set selectedSegment(q){let Q=this.querySelectorAll("fig-segment");for(let Z of Q){let $=Z===q,J=z(Z,"selected");if($&&!J)Z.setAttribute("selected","true");else if(!$&&J)Z.removeAttribute("selected")}this.#Q=q instanceof HTMLElement&&this.contains(q)?q:null,this.#U(),this.#R()}get value(){return this.getAttribute("value")||""}set value(q){if(q===null||q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(q))}#Y(q){this.dispatchEvent(new CustomEvent("input",{detail:q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:q,bubbles:!0}))}#G(q){let Q=q.getAttribute("value");if(Q!==null){let Z=Q.trim();if(Z.length>0)return Z}return q.textContent?.trim()||""}#K(){let q=this.querySelectorAll("fig-segment");for(let Q of q)if(Q.hasAttribute("selected")&&Q.getAttribute("selected")!=="false")return Q;return null}#X(){return Array.from(this.querySelectorAll("fig-segment")).filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false")}#U(){let q=Array.from(this.querySelectorAll("fig-segment")),Q=q.find((Z)=>Z.hasAttribute("selected")&&Z.getAttribute("selected")!=="false");q.forEach((Z)=>{let $=Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false",J=Z===Q;Z.setAttribute("aria-checked",J?"true":"false"),Z.setAttribute("tabindex",!$&&J?"0":"-1")})}#L(q){if(!q)return;let Q=this.selectedSegment,Z=this.value;this.selectedSegment=q;let $=this.#G(q);if($)this.setAttribute("value",$);else this.removeAttribute("value");let J=this.value;if(Q!==q||Z!==J)this.#Y(J)}#z(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.#X();if(!Q.length)return;let Z=Q.findIndex((j)=>z(j,"selected")),$=Z>=0?Z:0;switch(q.key){case"ArrowLeft":case"ArrowUp":q.preventDefault(),$=$>0?$-1:Q.length-1;break;case"ArrowRight":case"ArrowDown":q.preventDefault(),$=$<Q.length-1?$+1:0;break;case"Home":q.preventDefault(),$=0;break;case"End":q.preventDefault(),$=Q.length-1;break;case" ":case"Enter":{let j=q.target.closest("fig-segment");if(j&&this.contains(j))q.preventDefault(),this.#L(j);return}default:return}let J=Q[$];this.#L(J),J.focus(),requestAnimationFrame(()=>{if(this.contains(J))J.focus()})}#M(q){let Q=String(q??"").trim();if(!Q)return!1;let Z=this.querySelectorAll("fig-segment");for(let $ of Z){let J=this.#G($);if(!J)continue;if(J===Q)return this.selectedSegment=$,!0}return!1}#B(){let q=this.getAttribute("animated");if(q===null)return!1;if(q==="")return!0;return q.trim().toLowerCase()==="true"}#R({forceInstant:q=!1}={}){if(this.#N=this.#N||q,this.#j)return;this.#j=requestAnimationFrame(()=>{this.#j=0;let Q=this.#N;this.#N=!1,this.#H({forceInstant:Q})})}#H({forceInstant:q=!1}={}){let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.#B(),$=this.#Q&&this.contains(this.#Q)?this.#Q:this.#K();if(Q||!Z){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!Z||Q)this.#_=!1;return}if(!$){if(this.#_)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let J=this.getBoundingClientRect(),j=$.getBoundingClientRect();if(J.width<=0||j.width<=0){if(this.#_)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}let _=Math.max(0,j.left-J.left);this.style.setProperty("--seg-indicator-x",`${_}px`),this.style.setProperty("--seg-indicator-w",`${j.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#_||q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#_=!0}#D(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#R()}),this.#T()}#T(){if(!this.#J)return;this.#J.disconnect(),this.#J.observe(this),this.querySelectorAll("fig-segment").forEach((q)=>{this.#J?.observe(q)})}#A({enforceFallback:q=!1}={}){if(this.querySelectorAll("fig-segment").length===0){this.#Q=null,this.#R({forceInstant:!0});return}let Z=this.getAttribute("value"),$=Z?.trim()??"";if(Z!==null){if($!==Z){this.setAttribute("value",$);return}if($&&this.#M($))return}let J=this.#K();if(J){this.selectedSegment=J;return}if(q)this.selectedSegment=this.#X()[0]||null}#O(){this.#$?.disconnect(),this.#$=new MutationObserver((q)=>{let Q=!1;for(let Z of q){if(Z.type==="childList"){Q=!0;break}if(Z.type==="attributes"&&Z.target instanceof HTMLElement&&Z.target.tagName.toLowerCase()==="fig-segment"&&(Z.attributeName==="value"||Z.attributeName==="selected")){Q=!0;break}if(Z.type==="characterData"){Q=!0;break}}if(Q)this.#P(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#T(),this.#A({enforceFallback:!0}),this.#U()}),this.#$.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=q.target.closest("fig-segment");if(!Q||!this.contains(Q))return;if(Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.#L(Q)}#P(q){this.setAttribute("aria-disabled",q?"true":"false"),this.querySelectorAll("fig-segment").forEach((Q)=>{if(q){if(!(Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false"))this.#W.add(Q),Q.setAttribute("disabled","");Q.setAttribute("aria-disabled","true")}else if(this.#W.has(Q))this.#W.delete(Q),Q.removeAttribute("disabled"),Q.removeAttribute("aria-disabled")}),this.#U()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="disabled"){this.#P(Z!==null&&Z!=="false"),this.#R({forceInstant:!0});return}if(q==="value"){this.#A({enforceFallback:!1});return}if(q==="animated"){if(!this.#B())this.#_=!1;this.#R({forceInstant:!0});return}if(q==="sizing")this.#R({forceInstant:!0})}}M("fig-segmented-control",c0);class p0 extends HTMLElement{static get observedAttributes(){return["options","value","disabled","full","sizing"]}#Q="segments";#q=0;#Z=null;#$=[];#J=null;#j=!1;#N(q){let Q=q?.detail;if(typeof Q==="string")return Q;let Z=q?.currentTarget?.value??q?.target?.value??this.getAttribute("value");if(Z===null||Z===void 0)return null;return String(Z)}#_(){if(this.#$.length===0)return!1;let q=this.querySelector(":scope > fig-segmented-control");if(q){let Z=q.querySelectorAll("fig-segment");if(Z.length!==this.#$.length)return!1;return Array.from(Z).every(($,J)=>$.getAttribute("value")===this.#$[J])}let Q=this.querySelector(":scope > fig-dropdown");if(Q){let Z=Q.querySelectorAll("option");return Z.length===this.#$.length&&Array.from(Z).every(($,J)=>$.textContent?.trim()===this.#$[J])}return!1}#W(){let q=this.querySelector(":scope > fig-segmented-control");if(q)this.#J=q,this.#Q="segments";else this.#J=this.querySelector(":scope > fig-dropdown"),this.#Q="dropdown";this.#U()}connectedCallback(){if(this.#Y(),this.#_()){this.#W(),this.#z(),u(this,()=>u(this,()=>this.#R()));return}this.#G(),this.#z(),u(this,()=>u(this,()=>this.#R()))}disconnectedCallback(){this.#Z?.disconnect(),this.#Z=null}get value(){return this.getAttribute("value")||""}set value(q){if(q===null||q===void 0)this.removeAttribute("value");else this.setAttribute("value",String(q))}get options(){return this.#$.slice()}set options(q){if(Array.isArray(q)){let Z=q.some(($)=>String($).includes(","))?JSON.stringify(q):q.join(",");this.setAttribute("options",Z)}else this.setAttribute("options",String(q||""))}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="options"){this.#Y(),this.#X();return}if(q==="value"){this.#U();return}if(q==="disabled"){this.#L("disabled");return}if(q==="full"){this.#L("full");return}if(q==="sizing")this.#L("sizing"),this.#X()}#Y(){let q=this.getAttribute("options")||"";if(q.startsWith("["))try{this.#$=JSON.parse(q);return}catch{}let Q=q.includes(`
38
38
  `)?`
39
39
  `:",";this.#$=q.split(Q).map((Z)=>Z.trim()).filter(Boolean)}#G(){if(this.innerHTML="",this.#$.length===0)return;let q=document.createElement("fig-segmented-control");if(q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),z(this,"disabled"))q.setAttribute("disabled","");if(z(this,"full"))q.setAttribute("full","");let Q=this.getAttribute("value");for(let Z of this.#$){let $=document.createElement("fig-segment");if($.setAttribute("value",Z),$.textContent=Z,Q===Z)$.setAttribute("selected","true");q.appendChild($)}if(Q)q.setAttribute("value",Q);q.addEventListener("input",(Z)=>{if(Z.stopPropagation(),this.#j)return;let $=this.#N(Z);if($===null)return;this.#j=!0,this.setAttribute("value",$),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}),q.addEventListener("change",(Z)=>{if(Z.stopPropagation(),this.#j)return;let $=this.#N(Z);if($===null)return;this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,composed:!0}))}),this.appendChild(q),this.#J=q,this.#Q="segments"}#K(){if(this.innerHTML="",this.#$.length===0)return;let q=document.createElement("fig-dropdown");if(z(this,"disabled"))q.setAttribute("disabled","");let Q=this.getAttribute("value");for(let Z of this.#$){let $=document.createElement("option");if($.value=Z,$.textContent=Z,Q===Z)$.selected=!0;q.appendChild($)}if(Q)q.setAttribute("value",Q);q.addEventListener("input",(Z)=>{if(Z.stopPropagation(),this.#j)return;let $=this.#N(Z);if(!$)return;this.#j=!0,this.setAttribute("value",$),this.#j=!1,this.dispatchEvent(new CustomEvent("input",{detail:$,bubbles:!0,composed:!0}))}),q.addEventListener("change",(Z)=>{if(Z.stopPropagation(),this.#j)return;let $=this.#N(Z);if(!$)return;this.dispatchEvent(new CustomEvent("change",{detail:$,bubbles:!0,composed:!0}))}),this.appendChild(q),this.#J=q,this.#Q="dropdown"}#X(){if(this.#Q==="segments")this.#G(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#R())});else this.#K()}#U(){if(!this.#J||this.#j)return;let q=this.getAttribute("value")||"";this.#J.value=q}#L(q){if(!this.#J)return;if(this.hasAttribute(q))this.#J.setAttribute(q,this.getAttribute(q)||"");else this.#J.removeAttribute(q)}#z(){this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#R()}),this.#Z.observe(this)}#M(q){let Q=document.createRange();Q.selectNodeContents(q);let Z=Q.getBoundingClientRect().width,J=q.getBoundingClientRect().width,j=getComputedStyle(q),_=parseFloat(j.paddingLeft)||0,W=parseFloat(j.paddingRight)||0,N=J-_-W;return Z>N+0.5}#B(){let q=this.querySelectorAll("fig-segment");for(let Q of q)if(this.#M(Q))return!0;return!1}#R(){if(this.#$.length<=1)return;if(this.#Q==="segments"){let q=this.#J;if(q&&q.scrollWidth>q.clientWidth+1||this.#B())this.#q=this.clientWidth,this.#K()}else if(this.#q>0&&this.clientWidth>=this.#q)this.#G(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let q=this.#J;if(q&&q.scrollWidth>q.clientWidth+1||this.#B())this.#K()})})}}M("fig-options",p0);function dq(q){let Q=q||"";if(Q.startsWith("["))try{let $=JSON.parse(Q);return Array.isArray($)?$:[]}catch{}let Z=Q.includes(`
40
40
  `)?`
package/fig.js CHANGED
@@ -1164,9 +1164,16 @@ class FigTooltip extends HTMLElement {
1164
1164
  return false;
1165
1165
  }
1166
1166
 
1167
- showDelayedPopup() {
1167
+ showDelayedPopup(event) {
1168
1168
  if (this.#showPersisted) return;
1169
1169
  clearTimeout(this.timeout);
1170
+ if (event?.type === "pointerenter") {
1171
+ const trigger = this.#triggerEl;
1172
+ const openSelect =
1173
+ trigger?.matches?.("fig-select[open]") ||
1174
+ trigger?.querySelector?.("fig-select[open]");
1175
+ if (openSelect) return;
1176
+ }
1170
1177
  if (this.#isWarmSession()) {
1171
1178
  this.render();
1172
1179
  this.showPopup();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "6.37.0",
3
+ "version": "6.37.1",
4
4
  "description": "A lightweight web components library for building Figma plugin and widget UIs with native look and feel",
5
5
  "author": "Rogie King",
6
6
  "license": "MIT",