@rogieking/figui3 8.2.0 → 8.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fig-lab.js +1 -1
- package/dist/fig.js +20 -20
- package/fig-lab.js +1 -1
- package/fig.js +4 -31
- package/package.json +1 -1
package/dist/fig.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var wq=(q,Q)=>()=>(q&&(Q=q(q=0)),Q);var yq={};var D0=wq(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(q,Q,Z){if(q.importNode.length!=1||Q.get("ungap-li"))return;var $="extends";try{var J={};J[$]="li";var j=HTMLLIElement,_=function(){return Reflect.construct(j,[],_)};if(_.prototype=Z.create(j.prototype),Q.define("ungap-li",_,J),!/is="ungap-li"/.test(new _().outerHTML))throw J}catch(W){(function(){var N="attributeChangedCallback",K="connectedCallback",G="disconnectedCallback",U=Element.prototype,X=Z.assign,z=Z.create,B=Z.defineProperties,L=Z.getOwnPropertyDescriptor,k=Z.setPrototypeOf,H=Q.define,A=Q.get,R=Q.upgrade,D=Q.whenDefined,I=z(null),S=new WeakMap,w={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(Y){return typeof Y=="string"&&/^HTML(?!Element)/.test(Y)}).forEach(function(Y){function F(){}var f=self[Y];k(F,f),(F.prototype=f.prototype).constructor=F,f={},f[Y]={value:F},B(self,f)}),new MutationObserver(t).observe(q,w),f0(Document.prototype,"importNode"),f0(Node.prototype,"cloneNode"),B(Q,{define:{value:function(Y,F,f){if(Y=Y.toLowerCase(),f&&$ in f){I[Y]=X({},f,{Class:F});var C=f[$]+'[is="'+Y+'"]',V=q.querySelectorAll(C);for(var x=0,h=V.length;x<h;x++)a(V[x])}else H.apply(Q,arguments)}},get:{value:function(Y){return Y in I?I[Y].Class:A.call(Q,Y)}},upgrade:{value:function(Y){var F=G0(Y);if(F&&!(Y instanceof F.Class))k0(Y,F);else R.call(Q,Y)}},whenDefined:{value:function(Y){return Y in I?Promise.resolve():D.call(Q,Y)}}});var y=q.createElement;B(q,{createElement:{value:function(Y,F){var f=y.call(q,Y);if(F&&"is"in F)f.setAttribute("is",F.is),Q.upgrade(f);return f}}});var g=L(U,"attachShadow").value,d=L(U,"innerHTML");B(U,{attachShadow:{value:function(){var Y=g.apply(this,arguments);return new MutationObserver(t).observe(Y,w),Y}},innerHTML:{get:d.get,set:function(Y){if(d.set.call(this,Y),/\bis=("|')?[a-z0-9_-]+\1/i.test(Y))$0(this,a)}}});function t(Y){for(var F=0,f=Y.length;F<f;F++){var C=Y[F],V=C.addedNodes,x=C.removedNodes;for(var h=0,J0=V.length;h<J0;h++)a(V[h]);for(var U0=0,xq=x.length;U0<xq;U0++)T0(x[U0])}}function F0(Y){for(var F=0,f=Y.length;F<f;F++){var C=Y[F],V=C.attributeName,x=C.oldValue,h=C.target,J0=h.getAttribute(V);if(N in h&&!(x==J0&&J0==null))h[N](V,x,h.getAttribute(V),null)}}function T0(Y){if(Y.nodeType!==1)return;var F=G0(Y);if(F&&Y instanceof F.Class&&G in Y&&S.get(Y)!==G)S.set(Y,G),Promise.resolve(Y).then(Eq);$0(Y,T0)}function G0(Y){var F=Y.getAttribute("is");if(F){if(F=F.toLowerCase(),F in I)return I[F]}return null}function Cq(Y){Y[K]()}function Eq(Y){Y[G]()}function k0(Y,F){var f=F.Class,C=f.observedAttributes||[];if(k(Y,f.prototype),C.length){new MutationObserver(F0).observe(Y,{attributes:!0,attributeFilter:C,attributeOldValue:!0});var V=[];for(var x=0,h=C.length;x<h;x++)V.push({attributeName:C[x],oldValue:null,target:Y});F0(V)}}function a(Y){if(Y.nodeType!==1)return;var F=G0(Y);if(F){if(!(Y instanceof F.Class))k0(Y,F);if(K in Y&&Y.isConnected&&S.get(Y)!==K)S.set(Y,K),Promise.resolve(Y).then(Cq)}$0(Y,a)}function $0(Y,F){for(var f=Y.content,C=(f&&f.nodeType==11?f:Y).querySelectorAll("[is]"),V=0,x=C.length;V<x;V++)F(C[V])}function f0(Y,F){var f=Y[F],C={};C[F]={value:function(){var V=f.apply(this,arguments);switch(V.nodeType){case 1:case 11:$0(V,a)}return V}},B(Y,C)}})()}})(document,customElements,Object)});function bq(){if(typeof navigator>"u")return!1;let q=navigator.userAgent||"",Q=/\b(iPad|iPhone|iPod)\b/.test(q)||/\bMacintosh\b/.test(q)&&/\bMobile\b/.test(q),Z=/\bAppleWebKit\b/.test(q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(q);return Q||Z}function c(q,Q={}){let Z=document.createElement("fig-icon");if(q)Z.setAttribute("name",q);if(Q.size)Z.setAttribute("size",Q.size);if(Q.className)Z.className=Q.className;return Z}function u(q,Q){requestAnimationFrame(()=>{if(q&&!q.isConnected)return;Q()})}function T(q,Q){return q.hasAttribute(Q)&&q.getAttribute(Q)!=="false"}function r(q,Q,Z){let $=Number(Q),J=Number(Z),j=Number.isFinite($)?Math.max(0,Math.min(1,$)):Number.isFinite(J)?Math.max(0,Math.min(100,J))/100:1,_=Number.isFinite(J)?Math.max(0,Math.min(100,J)):Math.round(j*100);return{color:q,alpha:j,opacity:_}}function _0(q){q.querySelectorAll(':scope > [slot="prepend"], :scope > [slot="append"]').forEach((Q)=>{if(Q.children.length>0){X0(Q);return}let Z=Q.textContent.trim();if(!Z){X0(Q);return}let $=Q.dataset.figInputSlotFullText||"",J=$?Array.from($)[0]?.toUpperCase():"",j=Z===J?$:Z,W=Array.from(Z)[0].toUpperCase();if(Q.textContent!==W)Q.textContent=W;if(j&&j!==W)Q.dataset.figInputSlotFullText=j,Q.setAttribute("aria-label",j),hq(Q);else X0(Q)})}function hq(q){if(q.dataset.figInputSlotTooltipBound==="true")return;q.dataset.figInputSlotTooltipBound="true",q.addEventListener("pointerenter",P0),q.addEventListener("pointerleave",Y0),q.addEventListener("focus",P0),q.addEventListener("blur",Y0)}function X0(q){Y0({currentTarget:q}),delete q.dataset.figInputSlotFullText,q.removeAttribute("aria-label")}function P0(q){let Q=q.currentTarget,Z=Q?.dataset?.figInputSlotFullText;if(!Q||!Z)return;M.show(Q,Z)}function Y0(q){let Q=q.currentTarget;if(!Q)return;M.hide(Q)}function B0({owner:q,onStart:Q,onEnd:Z,startClass:$="",endClass:J="",chevronClass:j="",startLabel:_="Scroll back",endLabel:W="Scroll forward"}={}){let N=(K,G)=>{let U=document.createElement("button");if(U.type="button",U.className=["fig-overflow",`fig-overflow-${K}`,K==="start"?$:J].filter(Boolean).join(" "),U.dataset.figOverflow=K,q)U.setAttribute(`data-fig-${q}-nav`,K);return U.setAttribute("tabindex","-1"),U.setAttribute("aria-label",K==="start"?_:W),U.appendChild(c("chevron",{size:"small",className:["fig-overflow-chevron",j].filter(Boolean).join(" ")})),U.addEventListener("click",(X)=>{X.preventDefault(),X.stopPropagation(),G?.(X)}),U};return{start:N("start",Q),end:N("end",Z)}}function q0(q,Q,Z="x",$=2){if(!q||!Q)return!1;let J=Z==="x",j=J?Q.scrollWidth:Q.scrollHeight,_=J?Q.clientWidth:Q.clientHeight,W=J?Q.scrollLeft:Q.scrollTop,N=j-_>$,K=!N||W<=$,G=!N||W+_>=j-$;return q.classList.toggle("overflow-start",!K),q.classList.toggle("overflow-end",!G),N}function Q0(q,Q="x",Z=1){if(!q)return;let $=Q==="x",j=($?q.clientWidth:q.clientHeight)*0.8*Z;q.scrollBy({[$?"left":"top"]:j,behavior:"smooth"})}function vq(q,Q,Z="y",$="auto"){if(!q||!Q||!q.contains(Q))return;requestAnimationFrame(()=>{if(!q.isConnected||!Q.isConnected)return;let J=Z==="x",j=J?q.scrollWidth:q.scrollHeight,_=J?q.clientWidth:q.clientHeight;if(j<=_+1){q0(q,q,Z);return}let W=Q.getBoundingClientRect(),N=q.getBoundingClientRect(),K=J?q.scrollLeft:q.scrollTop,G=(J?W.left-N.left:W.top-N.top)+K,U=J?W.width:W.height,X=j-_,z=Math.max(0,Math.min(G+U/2-_/2,X));q.scrollTo({[J?"left":"top"]:z,behavior:$}),q0(q,q,Z)})}function o(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function mq(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class Q extends HTMLButtonElement{}try{return customElements.define(q,Q,{extends:"button"}),document.createElement("button",{is:q})instanceof Q}catch(Z){return!1}}var C0=bq()&&!mq(),gq=(C0?Promise.resolve().then(() => (D0(),yq)):Promise.resolve()).then(()=>{}).catch((q)=>{throw q});function O0(q,Q,Z){let $=()=>{if(!customElements.get(q))customElements.define(q,Q,Z)};if(!C0){$();return}gq.then($).catch((J)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${q}".`,J)})}function O(q,Q){if(!customElements.get(q))customElements.define(q,Q)}function m(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function j0(){if(!document.body)return null;let q="data-figui-overlay-root",Q=document.body.querySelector(`:scope > [${q}]`);if(!Q)Q=document.createElement("div"),Q.setAttribute(q,""),document.body.append(Q);return Q}var uq=1e4;function E0(){return uq++}function v(q,Q,Z){if(Z&&Z.trim())q.style.setProperty(Q,Z.trim());else q.style.removeProperty(Q)}function b(q){return String(q??"").replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var s=null,I0=null;function z0(q=1,Q=1){if(!s)s=document.createElement("canvas"),I0=s.getContext("2d");if(s.width!==q)s.width=q;if(s.height!==Q)s.height=Q;return{canvas:s,ctx:I0}}class x0 extends HTMLElement{type;#Q;#q=new WeakMap;#Z=["aria-label","aria-labelledby","aria-describedby","title"];#$=this.#
|
|
1
|
+
var wq=(q,Q)=>()=>(q&&(Q=q(q=0)),Q);var yq={};var D0=wq(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(q,Q,Z){if(q.importNode.length!=1||Q.get("ungap-li"))return;var $="extends";try{var J={};J[$]="li";var j=HTMLLIElement,_=function(){return Reflect.construct(j,[],_)};if(_.prototype=Z.create(j.prototype),Q.define("ungap-li",_,J),!/is="ungap-li"/.test(new _().outerHTML))throw J}catch(W){(function(){var N="attributeChangedCallback",K="connectedCallback",G="disconnectedCallback",U=Element.prototype,X=Z.assign,z=Z.create,B=Z.defineProperties,L=Z.getOwnPropertyDescriptor,k=Z.setPrototypeOf,H=Q.define,A=Q.get,R=Q.upgrade,D=Q.whenDefined,I=z(null),S=new WeakMap,w={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(Y){return typeof Y=="string"&&/^HTML(?!Element)/.test(Y)}).forEach(function(Y){function F(){}var f=self[Y];k(F,f),(F.prototype=f.prototype).constructor=F,f={},f[Y]={value:F},B(self,f)}),new MutationObserver(t).observe(q,w),f0(Document.prototype,"importNode"),f0(Node.prototype,"cloneNode"),B(Q,{define:{value:function(Y,F,f){if(Y=Y.toLowerCase(),f&&$ in f){I[Y]=X({},f,{Class:F});var C=f[$]+'[is="'+Y+'"]',V=q.querySelectorAll(C);for(var x=0,h=V.length;x<h;x++)a(V[x])}else H.apply(Q,arguments)}},get:{value:function(Y){return Y in I?I[Y].Class:A.call(Q,Y)}},upgrade:{value:function(Y){var F=G0(Y);if(F&&!(Y instanceof F.Class))k0(Y,F);else R.call(Q,Y)}},whenDefined:{value:function(Y){return Y in I?Promise.resolve():D.call(Q,Y)}}});var y=q.createElement;B(q,{createElement:{value:function(Y,F){var f=y.call(q,Y);if(F&&"is"in F)f.setAttribute("is",F.is),Q.upgrade(f);return f}}});var g=L(U,"attachShadow").value,d=L(U,"innerHTML");B(U,{attachShadow:{value:function(){var Y=g.apply(this,arguments);return new MutationObserver(t).observe(Y,w),Y}},innerHTML:{get:d.get,set:function(Y){if(d.set.call(this,Y),/\bis=("|')?[a-z0-9_-]+\1/i.test(Y))$0(this,a)}}});function t(Y){for(var F=0,f=Y.length;F<f;F++){var C=Y[F],V=C.addedNodes,x=C.removedNodes;for(var h=0,J0=V.length;h<J0;h++)a(V[h]);for(var U0=0,xq=x.length;U0<xq;U0++)T0(x[U0])}}function F0(Y){for(var F=0,f=Y.length;F<f;F++){var C=Y[F],V=C.attributeName,x=C.oldValue,h=C.target,J0=h.getAttribute(V);if(N in h&&!(x==J0&&J0==null))h[N](V,x,h.getAttribute(V),null)}}function T0(Y){if(Y.nodeType!==1)return;var F=G0(Y);if(F&&Y instanceof F.Class&&G in Y&&S.get(Y)!==G)S.set(Y,G),Promise.resolve(Y).then(Eq);$0(Y,T0)}function G0(Y){var F=Y.getAttribute("is");if(F){if(F=F.toLowerCase(),F in I)return I[F]}return null}function Cq(Y){Y[K]()}function Eq(Y){Y[G]()}function k0(Y,F){var f=F.Class,C=f.observedAttributes||[];if(k(Y,f.prototype),C.length){new MutationObserver(F0).observe(Y,{attributes:!0,attributeFilter:C,attributeOldValue:!0});var V=[];for(var x=0,h=C.length;x<h;x++)V.push({attributeName:C[x],oldValue:null,target:Y});F0(V)}}function a(Y){if(Y.nodeType!==1)return;var F=G0(Y);if(F){if(!(Y instanceof F.Class))k0(Y,F);if(K in Y&&Y.isConnected&&S.get(Y)!==K)S.set(Y,K),Promise.resolve(Y).then(Cq)}$0(Y,a)}function $0(Y,F){for(var f=Y.content,C=(f&&f.nodeType==11?f:Y).querySelectorAll("[is]"),V=0,x=C.length;V<x;V++)F(C[V])}function f0(Y,F){var f=Y[F],C={};C[F]={value:function(){var V=f.apply(this,arguments);switch(V.nodeType){case 1:case 11:$0(V,a)}return V}},B(Y,C)}})()}})(document,customElements,Object)});function bq(){if(typeof navigator>"u")return!1;let q=navigator.userAgent||"",Q=/\b(iPad|iPhone|iPod)\b/.test(q)||/\bMacintosh\b/.test(q)&&/\bMobile\b/.test(q),Z=/\bAppleWebKit\b/.test(q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(q);return Q||Z}function c(q,Q={}){let Z=document.createElement("fig-icon");if(q)Z.setAttribute("name",q);if(Q.size)Z.setAttribute("size",Q.size);if(Q.className)Z.className=Q.className;return Z}function u(q,Q){requestAnimationFrame(()=>{if(q&&!q.isConnected)return;Q()})}function T(q,Q){return q.hasAttribute(Q)&&q.getAttribute(Q)!=="false"}function r(q,Q,Z){let $=Number(Q),J=Number(Z),j=Number.isFinite($)?Math.max(0,Math.min(1,$)):Number.isFinite(J)?Math.max(0,Math.min(100,J))/100:1,_=Number.isFinite(J)?Math.max(0,Math.min(100,J)):Math.round(j*100);return{color:q,alpha:j,opacity:_}}function _0(q){q.querySelectorAll(':scope > [slot="prepend"], :scope > [slot="append"]').forEach((Q)=>{if(Q.children.length>0){X0(Q);return}let Z=Q.textContent.trim();if(!Z){X0(Q);return}let $=Q.dataset.figInputSlotFullText||"",J=$?Array.from($)[0]?.toUpperCase():"",j=Z===J?$:Z,W=Array.from(Z)[0].toUpperCase();if(Q.textContent!==W)Q.textContent=W;if(j&&j!==W)Q.dataset.figInputSlotFullText=j,Q.setAttribute("aria-label",j),hq(Q);else X0(Q)})}function hq(q){if(q.dataset.figInputSlotTooltipBound==="true")return;q.dataset.figInputSlotTooltipBound="true",q.addEventListener("pointerenter",P0),q.addEventListener("pointerleave",Y0),q.addEventListener("focus",P0),q.addEventListener("blur",Y0)}function X0(q){Y0({currentTarget:q}),delete q.dataset.figInputSlotFullText,q.removeAttribute("aria-label")}function P0(q){let Q=q.currentTarget,Z=Q?.dataset?.figInputSlotFullText;if(!Q||!Z)return;M.show(Q,Z)}function Y0(q){let Q=q.currentTarget;if(!Q)return;M.hide(Q)}function B0({owner:q,onStart:Q,onEnd:Z,startClass:$="",endClass:J="",chevronClass:j="",startLabel:_="Scroll back",endLabel:W="Scroll forward"}={}){let N=(K,G)=>{let U=document.createElement("button");if(U.type="button",U.className=["fig-overflow",`fig-overflow-${K}`,K==="start"?$:J].filter(Boolean).join(" "),U.dataset.figOverflow=K,q)U.setAttribute(`data-fig-${q}-nav`,K);return U.setAttribute("tabindex","-1"),U.setAttribute("aria-label",K==="start"?_:W),U.appendChild(c("chevron",{size:"small",className:["fig-overflow-chevron",j].filter(Boolean).join(" ")})),U.addEventListener("click",(X)=>{X.preventDefault(),X.stopPropagation(),G?.(X)}),U};return{start:N("start",Q),end:N("end",Z)}}function q0(q,Q,Z="x",$=2){if(!q||!Q)return!1;let J=Z==="x",j=J?Q.scrollWidth:Q.scrollHeight,_=J?Q.clientWidth:Q.clientHeight,W=J?Q.scrollLeft:Q.scrollTop,N=j-_>$,K=!N||W<=$,G=!N||W+_>=j-$;return q.classList.toggle("overflow-start",!K),q.classList.toggle("overflow-end",!G),N}function Q0(q,Q="x",Z=1){if(!q)return;let $=Q==="x",j=($?q.clientWidth:q.clientHeight)*0.8*Z;q.scrollBy({[$?"left":"top"]:j,behavior:"smooth"})}function vq(q,Q,Z="y",$="auto"){if(!q||!Q||!q.contains(Q))return;requestAnimationFrame(()=>{if(!q.isConnected||!Q.isConnected)return;let J=Z==="x",j=J?q.scrollWidth:q.scrollHeight,_=J?q.clientWidth:q.clientHeight;if(j<=_+1){q0(q,q,Z);return}let W=Q.getBoundingClientRect(),N=q.getBoundingClientRect(),K=J?q.scrollLeft:q.scrollTop,G=(J?W.left-N.left:W.top-N.top)+K,U=J?W.width:W.height,X=j-_,z=Math.max(0,Math.min(G+U/2-_/2,X));q.scrollTo({[J?"left":"top"]:z,behavior:$}),q0(q,q,Z)})}function o(){return typeof customElements<"u"&&!!customElements.get("fig-fill-picker")}function mq(){if(typeof window>"u"||!window.customElements||typeof HTMLButtonElement>"u")return!1;let q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class Q extends HTMLButtonElement{}try{return customElements.define(q,Q,{extends:"button"}),document.createElement("button",{is:q})instanceof Q}catch(Z){return!1}}var C0=bq()&&!mq(),gq=(C0?Promise.resolve().then(() => (D0(),yq)):Promise.resolve()).then(()=>{}).catch((q)=>{throw q});function O0(q,Q,Z){let $=()=>{if(!customElements.get(q))customElements.define(q,Q,Z)};if(!C0){$();return}gq.then($).catch((J)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${q}".`,J)})}function O(q,Q){if(!customElements.get(q))customElements.define(q,Q)}function m(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function j0(){if(!document.body)return null;let q="data-figui-overlay-root",Q=document.body.querySelector(`:scope > [${q}]`);if(!Q)Q=document.createElement("div"),Q.setAttribute(q,""),document.body.append(Q);return Q}var uq=1e4;function E0(){return uq++}function v(q,Q,Z){if(Z&&Z.trim())q.style.setProperty(Q,Z.trim());else q.style.removeProperty(Q)}function b(q){return String(q??"").replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var s=null,I0=null;function z0(q=1,Q=1){if(!s)s=document.createElement("canvas"),I0=s.getContext("2d");if(s.width!==q)s.width=q;if(s.height!==Q)s.height=Q;return{canvas:s,ctx:I0}}class x0 extends HTMLElement{type;#Q;#q=new WeakMap;#Z=["aria-label","aria-labelledby","aria-describedby","title"];#$=this.#G.bind(this);#J=this.#X.bind(this);#j=()=>this.#M();#N=()=>{if(this.button?.matches(":focus-visible"))this.setAttribute("data-focus-visible","")};#_=()=>{this.removeAttribute("data-focus-visible")};constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){if(this.type=this.getAttribute("type")||"button",!this.button){let Q=this.type==="select"||this.type==="upload",Z=Q?"span":"button",$=Q?"":' type="button"';this.shadowRoot.innerHTML=`
|
|
2
2
|
<style>
|
|
3
3
|
button, button:hover, button:active, .fig-button-control {
|
|
4
4
|
padding: 0 var(--spacer-2);
|
|
@@ -34,9 +34,9 @@ var wq=(q,Q)=>()=>(q&&(Q=q(q=0)),Q);var yq={};var D0=wq(()=>{/*! 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"}#X(){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}#U(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{}}#Y(){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")}#R(){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.#R(),this.#Y()}#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.#Y();break;default:this.#R();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#$),this.shadowRoot?.querySelector("slot")?.removeEventListener("slotchange",this.#j)}}O("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.#X.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.#U(),!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.#Y(Z);if(this.type==="dropdown")this.select.selectedIndex=-1}#X(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"]}#U(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=q}#Y(q){if(this.type==="dropdown")return;if(this.select)this.select.value=q??""}attributeChangedCallback(q,Q,Z){if(q==="value")this.#Y(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.#U()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#j),this.select.removeEventListener("input",this.#Z),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#J)}}O("fig-dropdown",w0);class M extends HTMLElement{static#Q=0;static#q=0;static#Z=1000;static#$=null;static#J=!1;static#j=new Set;#N;#_;#W;#X;#G;#K;#U;#Y;#R;#z;#M;#L;#B=null;#H=null;#k=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.#X=this.#S.bind(this),this.#G=()=>{if(!this.#T)this.showDelayedPopup()},this.#K=()=>{this.#T=!1,this.hidePopup()},this.#U=this.#w.bind(this),this.#Y=this.#y.bind(this),this.#R=this.#g.bind(this),this.#z=this.#b.bind(this),this.#L=this.#E.bind(this),this.#M=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(M.#v(),this.setup(),this.#C(),this.setupEventListeners(),this.#B=this.closest("dialog"),this.#B)this.#B.addEventListener("close",this.#M)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#V(),this.#D(),document.removeEventListener("mousedown",this.#N,!0),document.removeEventListener("keydown",this.#L,!0),this.#B)this.#B.removeEventListener("close",this.#M),this.#B=null;if(this.action==="click")document.body.removeEventListener("click",this.#_);if(clearTimeout(this.#A),M.#$===this)M.#$=null}#f(){return this.firstElementChild}#D(){this.#k?.disconnect(),this.#k=null}#C(){if(this.#V(),this.action==="manual")return;let q=this.#f();if(!q){if(!this.#k&&typeof MutationObserver<"u")this.#k=new MutationObserver(()=>{if(this.#f())this.#D(),this.#C()}),this.#k.observe(this,{childList:!0});return}if(this.#H=q,this.action==="hover"){if(!this.isTouchDevice())q.addEventListener("pointerenter",this.#W),q.addEventListener("pointerleave",this.#X);q.addEventListener("touchstart",this.#U,{passive:!0}),q.addEventListener("touchmove",this.#Y,{passive:!0}),q.addEventListener("touchend",this.#R,{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.#X),q.removeEventListener("touchstart",this.#U),q.removeEventListener("touchmove",this.#Y),q.removeEventListener("touchend",this.#R),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=m();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.#L,!0)}get#I(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#P(){let q=Date.now(),Q=M.#Z;if(this.action==="hover"&&M.#$)return!0;if(M.#Q&&q-M.#Q<Q)return!0;if(M.#q&&q-M.#q<Q)return!0;return!1}showDelayedPopup(q){if(this.#I)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.#P()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#B&&!this.#B.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&M.#$&&M.#$!==this)M.#$.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")M.#$=this;M.#Q=Date.now()}hidePopup(){if(this.#I)return;clearTimeout(this.timeout),clearTimeout(this.#A);let q=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,M.#$===this)M.#$=null;if(q)M.#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)}#g(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(M.#J)return;M.#J=!0;let q=()=>{M.dismissHoverTooltips()},Q=()=>{M.#r()};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 M))continue;if(q.action!=="hover")continue;if(q.#I)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(M.#j))M.hide(q)}static#m=new WeakMap;static#r(){for(let q of document.querySelectorAll("fig-tooltip")){if(!(q instanceof M))continue;if(q.#I)continue;if(q.isOpen||q.timeout)q.hidePopup()}for(let q of Array.from(M.#j))M.hide(q)}static show(q,Q,Z={}){M.#v(),M.hide(q);let $=Z.delay??500,j=Date.now()-M.#Q<M.#Z?0:$,_={timeout:null,popup:null};M.#m.set(q,_),M.#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,M.#Q=Date.now()},j)}static hide(q){let Q=M.#m.get(q);if(!Q)return;if(clearTimeout(Q.timeout),Q.popup)Q.popup.remove(),M.#q=Date.now();M.#m.delete(q),M.#j.delete(q)}}O("fig-tooltip",M);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;M.show(this,this.#Q)},this.#Z=()=>{M.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);M.hide(this)}}O("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}),M.dismissHoverTooltips(),super.show()}showModal(){return this._captureFocusBeforeOpen(),this._clearStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),M.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")||m();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")M.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 z=this.getBeakEdgeInset(W),B=q.left+q.width/2,L=B-j;if(L<z)j=B-z;else if(L>Q.width-z)j=B-(Q.width-z);j=Math.min(K,Math.max(G,j))}else if(W==="left"||W==="right"){let z=this.getBeakEdgeInset(W),B=q.top+q.height/2,L=B-_;if(L<z)_=B-z;else if(L>Q.height-z)_=B-(Q.height-z);_=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),z;if(j==="top"||j==="bottom"){z=_-G;let B=X,L=Math.max(B,K.width-X);z=Math.min(L,Math.max(B,z))}else{z=W-U;let B=X,L=Math.max(B,K.height-X);z=Math.min(L,Math.max(B,z))}this.style.setProperty("--fig-popup-beak-offset",`${z}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(_),z={left:X.minLeft+(X.maxRight-X.minLeft-q.width)/2,top:X.minTop+(X.maxBottom-X.minTop-q.height)/2},B=this.clampToViewport(z,q,_);this.style.left=`${B.left}px`,this.style.top=`${B.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:z,s:B}of N){let L=this.computeCoords(W,q,X,z,Q,B),k=this.getPlacementSide(X,z,B),{score:H,resolved:A}=this.placementScore(W,q,L,k,_);if(B){let R=this.getViewportBounds(_);if((B==="left"||B==="right"?L.left>=R.minLeft&&L.left+q.width<=R.maxRight:L.top>=R.minTop&&L.top+q.height<=R.maxBottom)&&H<1e4){this.applyPopupPosition(W,q,L,k,_);return}}else if(H===0){this.applyPopupPosition(W,q,L,k,_);return}if(H<U)U=H,K=A,G=k}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")||m(),Q=this.content.getAttribute("id")||m();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(T(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")}}O("fig-tab",m0);class g0 extends HTMLElement{#Q;#q;#Z=this.#R.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.#Y(),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#q),this.addEventListener("scroll",this.#Z),this.#B(),this.#M(),this.#z(),u(this,()=>{let q=this.getAttribute("value");if(q)this.#A(q);if(T(this,"disabled"))this.#X(!0);this.#K(),this.#R(),this.#U(void 0,"auto")})}#X(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")})}#U(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.#R()})}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.#L()}#Y(){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}}#R(){q0(this,this,"x")}#z(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>this.#R()),this.#J.observe(this)}#M(){this.#$?.disconnect(),this.#$=new MutationObserver(()=>{if(this.#_)return;this.#Y(),this.#B(),this.#K(),requestAnimationFrame(()=>{this.#R(),this.#U()})}),this.#$.observe(this,{childList:!0,subtree:!1})}#L(){this.#j?.remove(),this.#N?.remove(),this.#j=null,this.#N=null,this.classList.remove("overflow-start","overflow-end")}#B(){if(this.#j&&this.#N&&this.contains(this.#j)&&this.contains(this.#N))return;this.#j?.remove(),this.#N?.remove();let q=B0({owner:"tabs",onStart:()=>Q0(this,"x",-1),onEnd:()=>Q0(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)=>T(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.#U(Q[$]),this.#k()}}get value(){return this.#T(this.selectedTab)}set value(q){this.setAttribute("value",q)}#k(){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.#U(this.selectedTab)}attributeChangedCallback(q,Q,Z){switch(q){case"value":if(Z!==Q)this.#A(Z);break;case"disabled":this.#X(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.#U(Q),Z!==Q||$!==this.value)this.#k()}}O("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}}}O("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.#f(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#O(),this.#k(),u(this,()=>{this.#A({enforceFallback:!0}),this.#T(),this.#B({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=T(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.#Y(),this.#B()}get value(){return this.getAttribute("value")||""}set value(q){if(q===null||q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(q))}#X(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}#U(){return Array.from(this.querySelectorAll("fig-segment")).filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false")}#Y(){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")})}#R(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.#X(J)}#z(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.#U();if(!Q.length)return;let Z=Q.findIndex((j)=>T(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.#R(j);return}default:return}let J=Q[$];this.#R(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}#L(){let q=this.getAttribute("animated");if(q===null)return!1;if(q==="")return!0;return q.trim().toLowerCase()==="true"}#B({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.#L(),$=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}#k(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#B()}),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.#B({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.#U()[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.#f(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#T(),this.#A({enforceFallback:!0}),this.#Y()}),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.#R(Q)}#f(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.#Y()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="disabled"){this.#f(Z!==null&&Z!=="false"),this.#B({forceInstant:!0});return}if(q==="value"){this.#A({enforceFallback:!1});return}if(q==="animated"){if(!this.#L())this.#_=!1;this.#B({forceInstant:!0});return}if(q==="sizing")this.#B({forceInstant:!0})}}O("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.#Y()}connectedCallback(){if(this.#X(),this.#_()){this.#W(),this.#z(),u(this,()=>u(this,()=>this.#B()));return}this.#G(),this.#z(),u(this,()=>u(this,()=>this.#B()))}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.#X(),this.#U();return}if(q==="value"){this.#Y();return}if(q==="disabled"){this.#R("disabled");return}if(q==="full"){this.#R("full");return}if(q==="sizing")this.#R("sizing"),this.#U()}#X(){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"}#X(){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}}#U(){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.#U();if(q instanceof HTMLSelectElement)return q;if(q?.tagName==="FIG-DROPDOWN")return q.select||q.querySelector?.("select")||null;return null}#G(q){if(this.type!=="select")return;if(q.key!=="Enter")return;if(q.altKey||q.ctrlKey||q.metaKey||q.shiftKey)return;let Q=this.#K();if(!Q||Q.disabled||Q.multiple)return;if(typeof Q.showPicker!=="function")return;q.preventDefault();try{Q.showPicker()}catch{}}#Y(){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")}#R(){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.#R(),this.#Y()}#M(){let q=this.#U();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.#Y();break;default:this.#R();break}}disconnectedCallback(){this.removeEventListener("keydown",this.#$),this.shadowRoot?.querySelector("slot")?.removeEventListener("slotchange",this.#j)}}O("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.#X.bind(this),this.#$=this.#U.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.#G(),!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.#Y(Z);if(this.type==="dropdown")this.select.selectedIndex=-1}#X(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}))}#U(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"]}#G(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.select.disabled=q}#Y(q){if(this.type==="dropdown")return;if(this.select)this.select.value=q??""}attributeChangedCallback(q,Q,Z){if(q==="value")this.#Y(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.#G()}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#j),this.select.removeEventListener("input",this.#Z),this.select.removeEventListener("change",this.#$),this.select.removeEventListener("keydown",this.#J)}}O("fig-dropdown",w0);class M extends HTMLElement{static#Q=0;static#q=0;static#Z=1000;static#$=null;static#J=!1;static#j=new Set;#N;#_;#W;#X;#U;#K;#G;#Y;#R;#z;#M;#L;#O=null;#H=null;#f=null;#T=!1;#A;#B=!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.#X=this.#C.bind(this),this.#U=()=>{if(!this.#T)this.showDelayedPopup()},this.#K=()=>{this.#T=!1,this.hidePopup()},this.#G=this.#w.bind(this),this.#Y=this.#y.bind(this),this.#R=this.#m.bind(this),this.#z=this.#b.bind(this),this.#L=this.#E.bind(this),this.#M=()=>{clearTimeout(this.timeout),this.destroy(),this.isOpen=!1}}connectedCallback(){if(M.#h(),this.setup(),this.#S(),this.setupEventListeners(),this.#O=this.closest("dialog"),this.#O)this.#O.addEventListener("close",this.#M)}disconnectedCallback(){if(clearTimeout(this.timeout),this.destroy(),this.#V(),this.#P(),document.removeEventListener("mousedown",this.#N,!0),document.removeEventListener("keydown",this.#L,!0),this.#O)this.#O.removeEventListener("close",this.#M),this.#O=null;if(this.action==="click")document.body.removeEventListener("click",this.#_);if(clearTimeout(this.#A),M.#$===this)M.#$=null}#k(){return this.firstElementChild}#P(){this.#f?.disconnect(),this.#f=null}#S(){if(this.#V(),this.action==="manual")return;let q=this.#k();if(!q){if(!this.#f&&typeof MutationObserver<"u")this.#f=new MutationObserver(()=>{if(this.#k())this.#P(),this.#S()}),this.#f.observe(this,{childList:!0});return}if(this.#H=q,this.action==="hover"){if(!this.isTouchDevice())q.addEventListener("pointerenter",this.#W),q.addEventListener("pointerleave",this.#X);q.addEventListener("touchstart",this.#G,{passive:!0}),q.addEventListener("touchmove",this.#Y,{passive:!0}),q.addEventListener("touchend",this.#R,{passive:!0}),q.addEventListener("touchcancel",this.#z,{passive:!0}),q.addEventListener("focus",this.#U),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.#X),q.removeEventListener("touchstart",this.#G),q.removeEventListener("touchmove",this.#Y),q.removeEventListener("touchend",this.#R),q.removeEventListener("touchcancel",this.#z),q.removeEventListener("focus",this.#U),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=m();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.#L,!0)}get#I(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}#D(){let q=Date.now(),Q=M.#Z;if(this.action==="hover"&&M.#$)return!0;if(M.#Q&&q-M.#Q<Q)return!0;if(M.#q&&q-M.#q<Q)return!0;return!1}showDelayedPopup(q){if(this.#I)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.#D()){this.render(),this.showPopup();return}this.timeout=setTimeout(()=>{this.render(),this.showPopup()},this.delay)}showPopup(){if(this.#O&&!this.#O.open)return;if(!this.firstElementChild)return;if(this.action==="hover"&&M.#$&&M.#$!==this)M.#$.hidePopup();if(!this.popup)this.render();if(this.popup.anchor=this.firstElementChild,this.popup.open=!0,this.isOpen=!0,this.action==="hover")M.#$=this;M.#Q=Date.now()}hidePopup(){if(this.#I)return;clearTimeout(this.timeout),clearTimeout(this.#A);let q=this.isOpen;if(this.popup)this.destroy();if(this.isOpen=!1,M.#$===this)M.#$=null;if(q)M.#q=Date.now()}hidePopupOutsideClick(q){if(this.isOpen&&!this.popup.contains(q.target))this.hidePopup()}#C(q){if(!this.#B)this.hidePopup()}#w(q){if(this.action==="hover")this.#B=!0,clearTimeout(this.#A),this.showDelayedPopup()}#y(q){if(this.action==="hover"&&this.#B)clearTimeout(this.#A),this.#A=setTimeout(()=>{this.#B=!1,this.hidePopup()},150)}#m(q){if(this.action==="hover"&&this.#B)clearTimeout(this.#A),this.#A=setTimeout(()=>{this.#B=!1,this.hidePopup()},300)}#b(q){if(this.action==="hover"&&this.#B)this.#B=!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)}#v(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.#S(),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.#v(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#h(){if(M.#J)return;M.#J=!0;let q=()=>{M.dismissHoverTooltips()},Q=()=>{M.#r()};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 M))continue;if(q.action!=="hover")continue;if(q.#I)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(M.#j))M.hide(q)}static#g=new WeakMap;static#r(){for(let q of document.querySelectorAll("fig-tooltip")){if(!(q instanceof M))continue;if(q.#I)continue;if(q.isOpen||q.timeout)q.hidePopup()}for(let q of Array.from(M.#j))M.hide(q)}static show(q,Q,Z={}){M.#h(),M.hide(q);let $=Z.delay??500,j=Date.now()-M.#Q<M.#Z?0:$,_={timeout:null,popup:null};M.#g.set(q,_),M.#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,M.#Q=Date.now()},j)}static hide(q){let Q=M.#g.get(q);if(!Q)return;if(clearTimeout(Q.timeout),Q.popup)Q.popup.remove(),M.#q=Date.now();M.#g.delete(q),M.#j.delete(q)}}O("fig-tooltip",M);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;M.show(this,this.#Q)},this.#Z=()=>{M.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);M.hide(this)}}O("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}),M.dismissHoverTooltips(),super.show()}showModal(){return this._captureFocusBeforeOpen(),this._clearStackingOrder(),this.addEventListener("close",this._boundRestoreFocus,{once:!0}),M.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")||m();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")M.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 z=this.getBeakEdgeInset(W),B=q.left+q.width/2,L=B-j;if(L<z)j=B-z;else if(L>Q.width-z)j=B-(Q.width-z);j=Math.min(K,Math.max(G,j))}else if(W==="left"||W==="right"){let z=this.getBeakEdgeInset(W),B=q.top+q.height/2,L=B-_;if(L<z)_=B-z;else if(L>Q.height-z)_=B-(Q.height-z);_=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),z;if(j==="top"||j==="bottom"){z=_-G;let B=X,L=Math.max(B,K.width-X);z=Math.min(L,Math.max(B,z))}else{z=W-U;let B=X,L=Math.max(B,K.height-X);z=Math.min(L,Math.max(B,z))}this.style.setProperty("--fig-popup-beak-offset",`${z}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(_),z={left:X.minLeft+(X.maxRight-X.minLeft-q.width)/2,top:X.minTop+(X.maxBottom-X.minTop-q.height)/2},B=this.clampToViewport(z,q,_);this.style.left=`${B.left}px`,this.style.top=`${B.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:z,s:B}of N){let L=this.computeCoords(W,q,X,z,Q,B),k=this.getPlacementSide(X,z,B),{score:H,resolved:A}=this.placementScore(W,q,L,k,_);if(B){let R=this.getViewportBounds(_);if((B==="left"||B==="right"?L.left>=R.minLeft&&L.left+q.width<=R.maxRight:L.top>=R.minTop&&L.top+q.height<=R.maxBottom)&&H<1e4){this.applyPopupPosition(W,q,L,k,_);return}}else if(H===0){this.applyPopupPosition(W,q,L,k,_);return}if(H<U)U=H,K=A,G=k}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")||m(),Q=this.content.getAttribute("id")||m();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(T(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")}}O("fig-tab",m0);class g0 extends HTMLElement{#Q;#q;#Z=this.#R.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.#Y(),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#q),this.addEventListener("scroll",this.#Z),this.#O(),this.#M(),this.#z(),u(this,()=>{let q=this.getAttribute("value");if(q)this.#A(q);if(T(this,"disabled"))this.#X(!0);this.#K(),this.#R(),this.#G(void 0,"auto")})}#X(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()}#U(){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.#U()[0];q.forEach((Z)=>{let $=Z.hasAttribute("disabled")&&Z.getAttribute("disabled")!=="false";Z.setAttribute("tabindex",!$&&Z===Q?"0":"-1")})}#G(q=this.selectedTab,Q="smooth"){let Z=q||this.querySelector('fig-tab[selected]:not([selected="false"])')||this.#U()[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.#R()})}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.#L()}#Y(){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}}#R(){q0(this,this,"x")}#z(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>this.#R()),this.#J.observe(this)}#M(){this.#$?.disconnect(),this.#$=new MutationObserver(()=>{if(this.#_)return;this.#Y(),this.#O(),this.#K(),requestAnimationFrame(()=>{this.#R(),this.#G()})}),this.#$.observe(this,{childList:!0,subtree:!1})}#L(){this.#j?.remove(),this.#N?.remove(),this.#j=null,this.#N=null,this.classList.remove("overflow-start","overflow-end")}#O(){if(this.#j&&this.#N&&this.contains(this.#j)&&this.contains(this.#N))return;this.#j?.remove(),this.#N?.remove();let q=B0({owner:"tabs",onStart:()=>Q0(this,"x",-1),onEnd:()=>Q0(this,"x",1)});this.#j=q.start,this.#N=q.end,this.prepend(this.#j),this.append(this.#N)}#H(q){let Q=this.#U();if(!Q.length)return;let Z=Q.findIndex((J)=>T(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.#G(Q[$]),this.#f()}}get value(){return this.#T(this.selectedTab)}set value(q){this.setAttribute("value",q)}#f(){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.#G(this.selectedTab)}attributeChangedCallback(q,Q,Z){switch(q){case"value":if(Z!==Q)this.#A(Z);break;case"disabled":this.#X(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.#G(Q),Z!==Q||$!==this.value)this.#f()}}O("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}}}O("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.#k(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#B(),this.#f(),u(this,()=>{this.#A({enforceFallback:!0}),this.#T(),this.#O({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=T(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.#Y(),this.#O()}get value(){return this.getAttribute("value")||""}set value(q){if(q===null||q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(q))}#X(q){this.dispatchEvent(new CustomEvent("input",{detail:q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:q,bubbles:!0}))}#U(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}#G(){return Array.from(this.querySelectorAll("fig-segment")).filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false")}#Y(){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")})}#R(q){if(!q)return;let Q=this.selectedSegment,Z=this.value;this.selectedSegment=q;let $=this.#U(q);if($)this.setAttribute("value",$);else this.removeAttribute("value");let J=this.value;if(Q!==q||Z!==J)this.#X(J)}#z(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.#G();if(!Q.length)return;let Z=Q.findIndex((j)=>T(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.#R(j);return}default:return}let J=Q[$];this.#R(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.#U($);if(!J)continue;if(J===Q)return this.selectedSegment=$,!0}return!1}#L(){let q=this.getAttribute("animated");if(q===null)return!1;if(q==="")return!0;return q.trim().toLowerCase()==="true"}#O({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.#L(),$=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}#f(){this.#J?.disconnect(),this.#J=new ResizeObserver(()=>{this.#O()}),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.#O({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.#G()[0]||null}#B(){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.#k(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#T(),this.#A({enforceFallback:!0}),this.#Y()}),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.#R(Q)}#k(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.#Y()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="disabled"){this.#k(Z!==null&&Z!=="false"),this.#O({forceInstant:!0});return}if(q==="value"){this.#A({enforceFallback:!1});return}if(q==="animated"){if(!this.#L())this.#_=!1;this.#O({forceInstant:!0});return}if(q==="sizing")this.#O({forceInstant:!0})}}O("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.#Y()}connectedCallback(){if(this.#X(),this.#_()){this.#W(),this.#z(),u(this,()=>u(this,()=>this.#O()));return}this.#U(),this.#z(),u(this,()=>u(this,()=>this.#O()))}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.#X(),this.#G();return}if(q==="value"){this.#Y();return}if(q==="disabled"){this.#R("disabled");return}if(q==="full"){this.#R("full");return}if(q==="sizing")this.#R("sizing"),this.#G()}#X(){let q=this.getAttribute("options")||"";if(q.startsWith("["))try{this.#$=JSON.parse(q);return}catch{}let Q=q.includes(`
|
|
38
38
|
`)?`
|
|
39
|
-
`:",";this.#$=q.split(Q).map((Z)=>Z.trim()).filter(Boolean)}#
|
|
39
|
+
`:",";this.#$=q.split(Q).map((Z)=>Z.trim()).filter(Boolean)}#U(){if(this.innerHTML="",this.#$.length===0)return;let q=document.createElement("fig-segmented-control");if(q.setAttribute("sizing",this.getAttribute("sizing")||"equal"),T(this,"disabled"))q.setAttribute("disabled","");if(T(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(T(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"}#G(){if(this.#Q==="segments")this.#U(),requestAnimationFrame(()=>{requestAnimationFrame(()=>this.#O())});else this.#K()}#Y(){if(!this.#J||this.#j)return;let q=this.getAttribute("value")||"";this.#J.value=q}#R(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.#O()}),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}#L(){let q=this.querySelectorAll("fig-segment");for(let Q of q)if(this.#M(Q))return!0;return!1}#O(){if(this.#$.length<=1)return;if(this.#Q==="segments"){let q=this.#J;if(q&&q.scrollWidth>q.clientWidth+1||this.#L())this.#q=this.clientWidth,this.#K()}else if(this.#q>0&&this.clientWidth>=this.#q)this.#U(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let q=this.#J;if(q&&q.scrollWidth>q.clientWidth+1||this.#L())this.#K()})})}}O("fig-options",p0);class d0 extends HTMLElement{#Q=!1;#q=!1;#Z=!1;#$="";#J=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"];#j={range:{min:0,max:100,step:1},hue:{min:0,max:255,step:1},delta:{min:-100,max:100,step:1},stepper:{min:0,max:100,step:25},opacity:{min:0,max:100,step:0.1,color:"#FF0000"}};#N;#_;#W;#X;#U;#K;#G;#Y=null;#R=null;#z=null;#M=null;constructor(){super();this.initialInnerHTML=null,this.#N=(q)=>{q.stopPropagation(),this.#y()},this.#_=(q)=>{q.stopPropagation(),this.#m()},this.#U=(q)=>{this.#b(q)},this.#W=(q)=>{q.stopPropagation(),this.#A()},this.#X=(q)=>{q.stopPropagation(),this.#E()},this.#K=()=>{this.#Q=!0},this.#G=()=>{if(this.#Q=!1,this.#q&&this.isConnected)this.#q=!1,this.#T()}}#L(){let q=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.getAttribute("text")!=="false",this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";let Q=this.#j[this.type]||this.#j.range,Z=($,J)=>{let j=this.getAttribute($),_=j===null||j.trim()===""?J:Number(j);return Number.isFinite(_)?_:J};if(this.min=Z("min",Q.min),this.max=Z("max",Q.max),this.step=Z("step",Q.step),!(this.step>0))this.step=Q.step>0?Q.step:1;this.color=this.getAttribute("color")||Q?.color,this.default=this.hasAttribute("default")?this.getAttribute("default"):this.type==="delta"?0:this.min,this.value=this.#F(q)}#O(){if(!this.querySelector("[type=range]"))return!1;return this.getAttribute("text")!=="false"===!!this.querySelector("fig-input-number")}#H(){if(this.#L(),this.color)this.style.setProperty("--color",this.color);else this.style.removeProperty("--color");if(this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.input.className=this.type,this.input.min=String(this.min),this.input.max=String(this.max),this.input.step=String(this.step),this.input.value=String(this.value),this.input.disabled=this.disabled,this.text)this.input.setAttribute("tabindex","-1");else this.input.removeAttribute("tabindex");if(this.input.setAttribute("aria-valuemin",String(this.min)),this.input.setAttribute("aria-valuemax",String(this.max)),this.input.setAttribute("aria-valuenow",String(this.value)),this.figInputNumber=this.querySelector("fig-input-number"),this.figInputNumber){if(this.figInputNumber.setAttribute("placeholder",this.placeholder),this.figInputNumber.setAttribute("min",String(this.min)),this.figInputNumber.setAttribute("max",String(this.max)),this.figInputNumber.setAttribute("transform",String(this.transform)),this.figInputNumber.setAttribute("step",String(this.step)),this.figInputNumber.setAttribute("value",String(this.value)),this.units)this.figInputNumber.setAttribute("units",this.units);else this.figInputNumber.removeAttribute("units");if(this.precision!==null)this.figInputNumber.setAttribute("precision",String(this.precision));else this.figInputNumber.removeAttribute("precision");this.figInputNumber.disabled=this.disabled,this.figInputNumber.toggleAttribute("disabled",this.disabled)}}#f(){if(this.#C(),this.input.removeEventListener("input",this.#N),this.input.addEventListener("input",this.#N),this.input.removeEventListener("change",this.#_),this.input.addEventListener("change",this.#_),this.input.removeEventListener("keydown",this.#U),this.input.addEventListener("keydown",this.#U),this.input.removeEventListener("pointerdown",this.#K),this.input.addEventListener("pointerdown",this.#K),this.input.removeEventListener("pointerup",this.#G),this.input.addEventListener("pointerup",this.#G),this.input.removeEventListener("pointercancel",this.#G),this.input.addEventListener("pointercancel",this.#G),this.default)this.style.setProperty("--default",this.#B(this.default));if(this.figInputNumber)this.#w(),this.figInputNumber.removeEventListener("input",this.#W),this.figInputNumber.addEventListener("input",this.#W),this.figInputNumber.removeEventListener("change",this.#X),this.figInputNumber.addEventListener("change",this.#X)}#T(){if(this.#L(),this.color)this.style.setProperty("--color",this.color);let q="",Q=`<div class="fig-slider-input-container" role="group">
|
|
40
40
|
<input
|
|
41
41
|
type="range"
|
|
42
42
|
${this.text?'tabindex="-1"':""}
|
|
@@ -57,10 +57,10 @@ var wq=(q,Q)=>()=>(q&&(Q=q(q=0)),Q);var yq={};var D0=wq(()=>{/*! Vendored from @
|
|
|
57
57
|
max="${this.max}"
|
|
58
58
|
transform="${this.transform}"
|
|
59
59
|
step="${this.step}"
|
|
60
|
-
value="${this
|
|
60
|
+
value="${this.value}"
|
|
61
61
|
${this.units?`units="${b(this.units)}"`:""}
|
|
62
62
|
${this.precision!==null?`precision="${this.precision}"`:""}>
|
|
63
|
-
</fig-input-number>`;else q=Q;if(this.innerHTML=q,this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.figInputNumber=this.querySelector("fig-input-number"),this.#T(),this.datalist=this.querySelector("datalist"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||m()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",m());let Z=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1));for(let $=0;$<Z;$++){let J=document.createElement("option");J.setAttribute("value",this.min+$*this.step),this.datalist.append(J)}this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.type==="delta"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",m());let Z=document.createElement("option");Z.setAttribute("value",this.default),this.datalist.append(Z),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let Z=this.datalist.querySelector(`option[value='${this.default}']`);if(Z)Z.setAttribute("default","true")}this.#S()}connectedCallback(){if(this.initialInnerHTML===null)this.initialInnerHTML=this.innerHTML;if(this.#H()){this.#k(),this.#T(),this.#S();return}this.#A()}get value(){if(this.#J!=="")return this.#J;let q=this.getAttribute("value");if(q!==null)return String(this.#I(q));return""}set value(q){let Q=q===null||q===void 0?"":String(q);this.#Z=this.type!=="range"&&Q.trim()==="";let $=this.min!==void 0||this.max!==void 0?String(this.#I(Q)):Q;if(this.#J=$,this.getAttribute("value")!==$)this.#$=!0,this.setAttribute("value",$),this.#$=!1;if(this.input&&this.input.value!==$)this.input.value=$,this.input.setAttribute("aria-valuenow",$);if(this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Z?"":$);if(this.input)this.#P()}disconnectedCallback(){if(this.#q=!1,this.input)this.input.removeEventListener("input",this.#_),this.input.removeEventListener("change",this.#W),this.input.removeEventListener("keydown",this.#K),this.input.removeEventListener("pointerdown",this.#U),this.input.removeEventListener("pointerup",this.#Y),this.input.removeEventListener("pointercancel",this.#Y);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#X),this.figInputNumber.removeEventListener("change",this.#G)}#O(){if(this.figInputNumber){let q=this.figInputNumber.value;this.#Z=q===null||q===void 0||typeof q==="string"&&q.trim()==="";let Q=this.#I(q);this.value=Q,this.input.value=String(Q),this.#S(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#f(q){let{min:Q,max:Z}=this.#C(),$=Z-Q;if($===0)return 0;return(Number(q)-Q)/$}#D(q){if(q===null||q===void 0)return null;if(typeof q==="string"&&q.trim()==="")return null;let Q=Number(q);return Number.isFinite(Q)?Q:null}#C(){let q=this.#D(this.min),Q=this.#D(this.max);if(q===null)q=0;if(Q===null)Q=q;if(q>Q)[q,Q]=[Q,q];return{min:q,max:Q}}#V(q){let{min:Q,max:Z}=this.#C();return Math.min(Z,Math.max(Q,q))}#F(){if(this.type==="delta"){let Q=this.#D(this.default);if(Q!==null)return this.#V(Q);return this.#V(0)}if(this.type==="range"){let{min:Q,max:Z}=this.#C();return this.#V(Q+(Z-Q)/2)}let{min:q}=this.#C();return q}#I(q){let Q=this.#D(q);if(Q===null)return this.#F();return this.#V(Q)}#P(){let q=this.#f(this.value),Q=this.#f(this.default),Z=q<Q?-1:1,$=q===Q?1:0;if(this.#R!==q)this.style.setProperty("--slider-complete",q),this.#R=q;if(this.#z!==Q)this.style.setProperty("--default",Q),this.#z=Q;if(this.#M!==Z)this.style.setProperty("--slider-delta-direction",Z),this.#M=Z;if(this.#L!==$)this.style.setProperty("--unchanged",$),this.#L=$}#S(){let q=this.input.value;if(this.value=q,this.#P(),this.input.setAttribute("aria-valuenow",q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Z?"":q)}#w(){if(!this.input)return;if(this.text){this.input.setAttribute("aria-hidden","true"),["aria-label","aria-labelledby","aria-describedby","aria-valuetext"].forEach((q)=>this.input.removeAttribute(q)),this.#y();return}this.input.removeAttribute("aria-hidden"),this.#j.forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.input.removeAttribute(q);else this.input.setAttribute(q,Q)})}#y(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.figInputNumber.removeAttribute(q);else this.figInputNumber.setAttribute(q,Q)})}#g(){this.#Z=!1,this.#S(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#b(){this.#Q=!1,this.#Z=!1,this.#S(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#E(q){if(this.disabled||!q.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(q.key))return;q.preventDefault(),this.#Z=!1;let Q=q.key==="ArrowRight"||q.key==="ArrowUp"?1:-1,Z=this.#D(this.input.value)??this.#F(),$=this.#D(this.step)??1,J=this.#I(Z+$*10*Q);this.value=J,this.input.value=String(J),this.#S(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#h(){if(this.figInputNumber){let q=this.figInputNumber.value;this.#Z=q===null||q===void 0||typeof q==="string"&&q.trim()==="";let Q=this.#I(q);this.value=Q,this.input.value=String(Q),this.#S(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}#x(q,Q){if(!this.input)return;let Z=this.#N[this.type]||this.#N.range,$=Q===null||String(Q).trim()===""?Z[q]:Number(Q),J=Number.isFinite($)?$:Z[q];if(q==="step"&&!(J>0))J=Z.step>0?Z.step:1;if(this[q]===J&&this.input[q]===String(J))return;if(this[q]=J,this.input[q]=String(J),q==="min")this.input.setAttribute("aria-valuemin",String(J));else if(q==="max")this.input.setAttribute("aria-valuemax",String(J));if(this.figInputNumber)this.figInputNumber.setAttribute(q,String(J));if(!this.hasAttribute("default")&&this.type!=="delta")this.default=this.min;this.value=this.#I(this.value),this.#P(),this.#v()}#v(){if(this.type!=="stepper"||!this.datalist)return;let q=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1)),Q=document.createDocumentFragment();for(let Z=0;Z<q;Z++){let $=document.createElement("option");$.setAttribute("value",this.min+Z*this.step),Q.append($)}this.datalist.replaceChildren(Q),this.input.setAttribute("list",this.datalist.id)}#m(){if(this.#Q){this.#q=!0;return}this.#q=!1,this.#A()}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"]}focus(){if(this.text&&this.figInputNumber){this.figInputNumber.focus();return}this.input.focus()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="value"&&this.#$)return;if(this.input)switch(q){case"color":this.color=Z,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=Z!==null&&Z!=="false",this.figInputNumber)this.figInputNumber.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#Q)break;this.value=Z,this.#S();break;case"transform":if(this.transform=Number(Z)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=Z!==null?Number(Z):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=Z!==null?Z:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=Z!==null?Z:this.type==="delta"?0:this.min,this.#P();break;case"min":case"max":case"step":this.#x(q,Z);break;case"units":if(this.units=Z||"",this.figInputNumber)if(this.units)this.figInputNumber.setAttribute("units",this.units);else this.figInputNumber.removeAttribute("units");break;case"type":case"variant":if(!this.#Q)this[q]=Z;this.#m();break;case"text":if(!this.#Q)this.text=Z!=="false";this.#m();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#w();break;default:this[q]=this.input[q]=Z,this.#S();break}}}O("fig-slider",d0);class s0 extends HTMLElement{#Q=!1;#q=!1;#Z="";#$=!1;#J;#j;#N;#_;#W;#X;#G;#K;#U=null;#Y=0;#R="";#z="";#M=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#J=this.#S.bind(this),this.#j=this.#y.bind(this),this.#N=this.#y.bind(this),this.#_=this.#w.bind(this),this.#W=(q)=>{q.stopPropagation(),this.#P(q)},this.#X=(q)=>{q.stopPropagation();let Q=q.target.value;if(this.type==="number")Q=Number(Q)/(this.transform||1);this.value=Q,this.#D(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))},this.#G=()=>{if(!this.disabled)this.focus()},this.#K=this.#B.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")&&this.getAttribute("multiline")!=="false",this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}if(this.input=this.#L(),this.input.readOnly=this.readonly,this.disabled=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.input.disabled=this.disabled,this.#A(),this.#O(),this.#f(),this.#D(),this.#C(),this.#F(),_0(this),this.#H(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#I(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#I(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#I(this.step));this.addEventListener("pointerdown",this.#_)}this.removeEventListener("click",this.#K),this.addEventListener("click",this.#K),this.input.removeEventListener("change",this.#W),this.input.addEventListener("change",this.#W),this.input.removeEventListener("input",this.#X),this.input.addEventListener("input",this.#X)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#W),this.input.removeEventListener("input",this.#X);if(this.removeEventListener("click",this.#K),this.removeEventListener("pointerdown",this.#_),window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#j),window.removeEventListener("blur",this.#N),this.#U?.disconnect(),this.#U=null,this.#Y)cancelAnimationFrame(this.#Y),this.#Y=0}focus(){this.input.focus()}#L(){let q=this.multiline,Q=this.querySelector("input,textarea");if(Q){if(q?Q.tagName==="TEXTAREA":Q.tagName==="INPUT")return Q;Q.remove()}let Z;if(q)Z=document.createElement("textarea"),Z.value=this.value;else Z=document.createElement("input"),Z.type=this.type,Z.value=this.type==="number"?this.#I(this.value):this.value;if(Z.setAttribute("data-generated","input-control"),this.name)Z.name=this.name;return Z.placeholder=this.placeholder,this.insertBefore(Z,this.querySelector('[slot="append"]')),Z}#B(q){let Q=q.target?.closest?.("[slot]");if(!Q||Q.parentElement!==this)return;if(this.disabled)return;this.focus()}#H(){this.#U?.disconnect(),this.#U=new MutationObserver(()=>this.#k()),this.#U.observe(this,{childList:!0,characterData:!0,subtree:!0})}#k(){if(this.#Y)return;this.#Y=requestAnimationFrame(()=>{if(this.#Y=0,!this.isConnected)return;this.#T()})}#T(){if(!this.input||!this.contains(this.input))this.input=this.#L(),this.input.readOnly=this.readonly,this.input.addEventListener("change",this.#W),this.input.addEventListener("input",this.#X);this.#A(),this.#O(),this.#f(),this.#D(),this.#C(),this.#F(),_0(this)}#A(){if(!this.input)return;this.#M.forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.input.removeAttribute(q);else this.input.setAttribute(q,Q)})}#O(){let q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){q?.remove();return}if(this.querySelector('[slot="prepend"]:not([data-generated])')){q?.remove();return}if(q){let $=q.querySelector("fig-icon");if($&&$.getAttribute("name")!=="search")$.setAttribute("name","search");return}let Z=c("search");Z.setAttribute("slot","prepend"),Z.setAttribute("data-generated","search-prefix"),Z.setAttribute("color","var(--figma-color-icon)"),Z.addEventListener("click",this.#G),this.prepend(Z)}#f(){let q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){q?.remove();return}if(this.querySelector('[slot="append"]:not([data-generated])')){q?.remove();return}if(q){let _=q.querySelector("fig-icon");if(_&&_.getAttribute("name")!=="close")_.setAttribute("name","close");return}let Z=document.createElement("span");Z.setAttribute("slot","append"),Z.setAttribute("data-generated","search-clear");let $=document.createElement("fig-tooltip");$.setAttribute("text","Clear search");let J=document.createElement("fig-button");J.setAttribute("variant","ghost"),J.setAttribute("icon",""),J.setAttribute("aria-label","Clear search");let j=c("close",{size:"small"});j.setAttribute("color","var(--figma-color-icon-secondary)"),J.append(j),$.append(J),Z.append($),this.append(Z),J.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),this.disabled)return;if(!this.input||this.input.value===""){this.focus();return}this.value="",this.input.value="",this.dispatchEvent(new CustomEvent("input",{detail:"",bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:"",bubbles:!0})),this.#D(),this.focus()})}#D(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#C(){let q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){q?.remove(),this.#q=!1;return}if(this.querySelector('[slot="append"]:not([data-generated])')){q?.remove();return}if(q){this.#V(q);return}let Z=document.createElement("span");Z.setAttribute("slot","append"),Z.setAttribute("data-generated","password-toggle");let $=document.createElement("fig-tooltip"),J=document.createElement("fig-button");J.setAttribute("variant","ghost"),J.setAttribute("icon","");let j=c("visible",{size:"small"});j.setAttribute("color","var(--figma-color-icon-secondary)"),J.append(j),$.append(J),Z.append($),this.append(Z),this.#V(Z),J.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),this.disabled)return;if(this.#q=!this.#q,this.input)this.input.type=this.#q?"text":"password";this.#V(Z),this.focus()})}#V(q){let Q=q.querySelector("fig-tooltip"),Z=q.querySelector("fig-button"),$=q.querySelector("fig-icon"),J=this.#q?"Hide password":"Show password";Q?.setAttribute("text",J),Z?.setAttribute("aria-label",J),$?.setAttribute("name",this.#q?"visible":"hidden")}#F(){this.querySelectorAll('[data-generated="search-clear"] fig-button, [data-generated="password-toggle"] fig-button').forEach((q)=>{if(this.disabled)q.setAttribute("disabled","");else q.removeAttribute("disabled")})}#I(q){if(q==="")return"";let Q=Number(q)*(this.transform||1);return Q=this.#b(Q),Q}#P(q){q.stopPropagation();let Q=q.target.value,Z=Q;if(this.type==="number")Q=Q/(this.transform||1),Q=this.#g(Q,!1),Z=Q*(this.transform||1);this.value=Q,this.input.value=Z,this.#D(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#S(q){if(this.type!=="number")return;if(q.buttons===0){this.#y();return}let Q=(this.step||1)*q.movementX,Z=Number(this.input.value);Z=Z/(this.transform||1)+Q,Z=this.#g(Z,!1);let $=Z*(this.transform||1);Z=this.#b(Z),$=this.#b($),this.value=Z,this.input.value=$,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#w(q){if(this.type!=="number")return;if(q.altKey||q.target.closest("[slot]"))this.#Q=!0,this.#R=this.style.userSelect,this.#z=document.body.style.cursor,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#J),window.addEventListener("pointerup",this.#j),window.addEventListener("pointercancel",this.#j),window.addEventListener("blur",this.#N)}#y(q){if(this.type!=="number")return;let Q=this.#Q;if(this.#Q=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#z,this.style.userSelect=this.#R,window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#j),window.removeEventListener("pointercancel",this.#j),window.removeEventListener("blur",this.#N),Q)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#g(q,Q=!0){let Z=q;if(this.type==="number"){if(Z=Number(Z),typeof this.min==="number")Z=Math.max(Q?this.#I(this.min):this.min,Z);if(typeof this.max==="number")Z=Math.min(Q?this.#I(this.max):this.max,Z);Z=this.#b(Z)}return Z}#b(q,Q=2){let Z=Math.round(q*100)/100;return Number.isInteger(Z)?Z:Z.toFixed(Q)}get value(){return this.#Z}set value(q){let Q=q??"";this.#Z=Q;let Z=String(Q);if(this.getAttribute("value")!==Z)this.#$=!0,this.setAttribute("value",Z),this.#$=!1;this.#E(Q)}#E(q){if(!this.input||this.#Q)return;let Q=this.type==="number"?String(this.#I(q)):String(q??"");if(this.input.value!==Q)this.input.value=Q;this.#D()}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","multiline","step","min","max","transform","name","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(q,Q,Z){if(this.input)switch(q){case"disabled":this.disabled=this.input.disabled=Z!==null&&Z!=="false",this.#F();break;case"readonly":this.readonly=Z!==null&&Z!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number(Z)||1,this.input.value=this.#I(this.value);break;case"value":if(this.#Q)break;let $=Z;if(this.type==="number")$=this.#g($,!1);if(this.#Z=$??"",!this.#$)this.#E(this.#Z);break;case"min":case"max":case"step":if(Z===null||Z==="")this[q]=void 0,this.input.removeAttribute(q);else this[q]=this.input[q]=Number(Z),this.input.setAttribute(q,Z);break;case"name":if(this[q]=this.input[q]=Z||"",Z)this.input.setAttribute("name",Z);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=Z??"",this.input.placeholder=this.placeholder;break;case"type":if(this.type=Z||"text",this.input.type=this.type,this.removeEventListener("pointerdown",this.#_),this.type==="number")this.step=this.hasAttribute("step")?Number(this.getAttribute("step")):void 0,this.min=this.hasAttribute("min")?Number(this.getAttribute("min")):void 0,this.max=this.hasAttribute("max")?Number(this.getAttribute("max")):void 0,this.transform=Number(this.getAttribute("transform")||1),this.addEventListener("pointerdown",this.#_);this.#O(),this.#f(),this.#D(),this.#C(),this.#F();break;case"multiline":{let J=Z!==null&&Z!=="false";if(J!==this.multiline){this.multiline=J;let j=this.input;j.removeEventListener("change",this.#W),j.removeEventListener("input",this.#X),j.remove(),this.input=this.#L(),this.input.readOnly=this.readonly,this.input.disabled=Boolean(this.disabled),this.input.addEventListener("change",this.#W),this.input.addEventListener("input",this.#X),this.#A()}break}case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#A();break;default:this[q]=this.input[q]=Z;break}}}O("fig-input-text",s0);class W0 extends HTMLElement{#Q;#q;#Z;#$;#J;#j;#N;#_;#W;#X;#G;#K;#U;#Y;#R;#z;#M=!1;#L=null;#B=null;#H=0;#k="";#T="";#A=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#O="px";#f(q){return(q||"").split(",").map((Q)=>Q.trim().toLowerCase()).filter(Boolean)}#D(q){let Q=(q||"").trim();if(!Q)return"";return(this.#Y??[]).includes(Q.toLowerCase())?"":Q}#C(){this.#K=this.#D(this.#U)}#V(q){if(q&&!this.#L)this.#L=document.createElement("span"),this.#L.className="fig-steppers",this.#L.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#L.addEventListener("pointerdown",(Q)=>{Q.preventDefault(),Q.stopPropagation();let Z=Q.target.closest("button");if(!Z||this.disabled||Z.disabled)return;let $=Z.classList.contains("fig-stepper-up")?1:-1;this.#I($),this.input.focus()}),this.append(this.#L);else if(!q&&this.#L)this.#L.remove(),this.#L=null;this.#F()}#F(){if(!this.#L)return;let q=this.#L.querySelector(".fig-stepper-up"),Q=this.#L.querySelector(".fig-stepper-down");if(!q||!Q)return;let Z=this.input?this.#h(this.input.value):this.value,$=Z!==""&&Z!==null&&Z!==void 0?Number(Z)/(this.transform||1):Number(this.value),J=Number.isFinite($),j=Boolean(this.disabled),_=J&&typeof this.min==="number"&&$<=this.min,W=J&&typeof this.max==="number"&&$>=this.max;q.disabled=j||W,Q.disabled=j||_}#I(q){let Q=this.step||1,Z=this.#h(this.input.value),$=(Z!==""?Number(Z)/(this.transform||1):0)+Q*q;$=this.#p($,!1),this.value=$,this.input.value=this.#x(this.value),this.#F(),this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#Q=this.#c.bind(this),this.#q=this.#s.bind(this),this.#Z=this.#s.bind(this),this.#$=this.#i.bind(this),this.#J=(q)=>{q.stopPropagation(),this.#o(q)},this.#j=(q)=>{q.stopPropagation(),this.#u(q)},this.#N=(q)=>{this.#m(q)},this.#_=(q)=>{this.#r(q)},this.#W=(q)=>{this.#l(q)},this.#X=this.focus.bind(this),this.#G=this.#S.bind(this)}connectedCallback(){let q=this.getAttribute("value");this.value=q!==null&&q!==""?Number(q):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#U=this.getAttribute("units")||"";let Q=this.getAttribute("units-disallow");if(this.#Y=this.#f(Q===null?W0.#O:Q),this.#C(),this.#R=this.getAttribute("unit-position")||"suffix",this.#z=this.#a(this.hasAttribute("precision")?this.getAttribute("precision"):2),this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));this.transform=Number(this.getAttribute("transform")||1);let Z=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.input=this.#P(),this.#b(),this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.#V(Z),this.hasAttribute("disabled")){let $=this.getAttribute("disabled");this.disabled=this.input.disabled=$!=="false"}this.#F(),this.#E(),_0(this),this.addEventListener("pointerdown",this.#$),this.removeEventListener("click",this.#G),this.addEventListener("click",this.#G),this.#w(),this.input.removeEventListener("change",this.#J),this.input.addEventListener("change",this.#J),this.input.removeEventListener("input",this.#j),this.input.addEventListener("input",this.#j),this.input.removeEventListener("focus",this.#N),this.input.addEventListener("focus",this.#N),this.input.removeEventListener("blur",this.#_),this.input.addEventListener("blur",this.#_),this.input.removeEventListener("keydown",this.#W),this.input.addEventListener("keydown",this.#W)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#J),this.input.removeEventListener("input",this.#j),this.input.removeEventListener("focus",this.#N),this.input.removeEventListener("blur",this.#_),this.input.removeEventListener("keydown",this.#W);if(this.removeEventListener("click",this.#G),this.removeEventListener("pointerdown",this.#$),window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#q),window.removeEventListener("blur",this.#Z),this.#B?.disconnect(),this.#B=null,this.#H)cancelAnimationFrame(this.#H),this.#H=0}focus(){this.input.focus()}#P(){let q=this.querySelector("input");if(q)return q;let Q=document.createElement("input");if(Q.type="text",Q.inputMode="decimal",Q.setAttribute("data-generated","input-control"),this.name)Q.name=this.name;return Q.placeholder=this.placeholder,Q.value=this.#x(this.value),this.insertBefore(Q,this.querySelector('[slot="append"]')),Q}#S(q){let Q=q.target?.closest?.("[slot]");if(!Q||Q.parentElement!==this)return;this.focus()}#w(){this.#B?.disconnect(),this.#B=new MutationObserver(()=>this.#y()),this.#B.observe(this,{childList:!0,characterData:!0,subtree:!0})}#y(){if(this.#H)return;this.#H=requestAnimationFrame(()=>{if(this.#H=0,!this.isConnected)return;this.#g()})}#g(){if(!this.input||!this.contains(this.input))this.input=this.#P(),this.input.addEventListener("change",this.#J),this.input.addEventListener("input",this.#j),this.input.addEventListener("focus",this.#N),this.input.addEventListener("blur",this.#_),this.input.addEventListener("keydown",this.#W);let q=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.#L&&!this.contains(this.#L))this.#L=null;this.#V(q),this.#b(),this.#E(),_0(this)}#b(){if(!this.input)return;this.#A.forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.input.removeAttribute(q);else this.input.setAttribute(q,Q)})}#E(){if(!this.input)return;if(this.input.setAttribute("role","spinbutton"),typeof this.min==="number")this.input.setAttribute("aria-valuemin",String(this.min));else this.input.removeAttribute("aria-valuemin");if(typeof this.max==="number")this.input.setAttribute("aria-valuemax",String(this.max));else this.input.removeAttribute("aria-valuemax");let q=this.value===""?null:Number(this.value);if(Number.isFinite(q))this.input.setAttribute("aria-valuenow",String(q)),this.input.setAttribute("aria-valuetext",this.#x(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#h(q){if(!q)return"";if(!this.#K){let $=q.replace(/[^\d.-]/g,""),J=$.split(".");if(J.length>2)$=J[0]+"."+J.slice(1).join("");return $}let Q=q.replace(this.#K,"").trim();Q=Q.replace(/[^\d.-]/g,"");let Z=Q.split(".");if(Z.length>2)Q=Z[0]+"."+Z.slice(1).join("");return Q}#x(q){if(q===""||q===null||q===void 0)return"";let Q=Number(q)*(this.transform||1);if(isNaN(Q))return"";if(Q=this.#d(Q),!this.#K)return Q.toString();if(this.#R==="prefix")return this.#K+Q;else return Q+this.#K}#v(q){if(q===""||q===null||q===void 0)return"";let Q=Number(q)*(this.transform||1);return Q=this.#d(Q),Q.toString()}#m(q){this.#M=!0,setTimeout(()=>{let Q=q.target.value;if(Q&&this.#K)if(this.#R==="prefix")q.target.setSelectionRange(this.#K.length,Q.length);else{let Z=Q.indexOf(this.#K);if(Z>-1)q.target.setSelectionRange(0,Z)}},0)}#r(q){this.#M=!1;let Q=this.#h(q.target.value);if(Q!==""){let Z=Number(Q)/(this.transform||1);Z=this.#p(Z,!1),this.value=Z,q.target.value=this.#x(this.value)}else this.value="",q.target.value="";this.#F(),this.#E()}#l(q){if(this.disabled)return;if(q.key!=="ArrowUp"&&q.key!=="ArrowDown")return;q.preventDefault();let Q=this.step||1,Z=q.shiftKey?10:1,$=Q*Z*(q.key==="ArrowUp"?1:-1),J=this.#h(this.input.value),j=(J!==""?Number(J)/(this.transform||1):0)+$;j=this.#p(j,!1),this.value=j,this.input.value=this.#x(this.value),this.#F(),this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#u(q){let Q=this.#h(q.target.value);if(Q!=="")this.value=Number(Q)/(this.transform||1);else this.value="";this.#F(),this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#o(q){q.stopPropagation();let Q=this.#h(q.target.value);if(Q!==""){let Z=Number(Q)/(this.transform||1);Z=this.#p(Z,!1),this.value=Z,q.target.value=this.#x(this.value)}else this.value="",q.target.value="";this.#F(),this.#E(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#c(q){if(this.disabled)return;if(q.buttons===0){this.#s();return}let Q=(this.step||1)*q.movementX,Z=this.#h(this.input.value),$=Number(Z)/(this.transform||1)+Q;$=this.#p($,!1),this.value=$,this.input.value=this.#x(this.value),this.#F(),this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#i(q){if(this.disabled)return;if(q.altKey||q.target.closest("[slot]"))this.#M=!0,this.#k=this.style.userSelect,this.#T=document.body.style.cursor,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Q),window.addEventListener("pointerup",this.#q),window.addEventListener("pointercancel",this.#q),window.addEventListener("blur",this.#Z)}#s(q){let Q=this.#M;if(this.#M=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#T,this.style.userSelect=this.#k,window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#q),window.removeEventListener("pointercancel",this.#q),window.removeEventListener("blur",this.#Z),Q)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#p(q,Q=!0){let Z=Number(q);if(isNaN(Z))return"";if(typeof this.min==="number")Z=Math.max(this.min,Z);if(typeof this.max==="number")Z=Math.min(this.max,Z);return Z=this.#d(Z),Z}#d(q){let Q=this.#z??2,Z=Math.pow(10,Q),$=Math.round(q*Z)/Z;return Number.isInteger($)?$:parseFloat($.toFixed(Q))}#a(q){let Q=Number(q);if(!Number.isFinite(Q))return 2;return Math.max(0,Math.min(100,Math.trunc(Q)))}static get observedAttributes(){return["value","placeholder","disabled","step","min","max","transform","name","units","units-disallow","unit-position","steppers","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(q,Q,Z){if(this.input)switch(q){case"disabled":this.disabled=this.input.disabled=Z!==null&&Z!=="false",this.#F();break;case"units":this.#U=Z||"",this.#C(),this.input.value=this.#x(this.value),this.#E();break;case"units-disallow":this.#Y=this.#f(Z===null?W0.#O:Z),this.#C(),this.input.value=this.#x(this.value),this.#E();break;case"unit-position":this.#R=Z||"suffix",this.input.value=this.#x(this.value),this.#E();break;case"transform":this.transform=Number(Z)||1,this.input.value=this.#x(this.value),this.#E();break;case"value":if(this.#M)break;let $=Z!==null&&Z!==""?Number(Z):"";if($!=="")$=this.#p($,!1);this.value=$,this.input.value=this.#x(this.value),this.#F(),this.#E();break;case"min":case"max":case"step":if(Z===null||Z===""){this[q]=void 0,this.#F(),this.#E();break}this[q]=Number(Z),this.#F(),this.#E();break;case"steppers":{let J=Z!==null&&Z!=="false";this.#V(J);break}case"precision":this.#z=this.#a(Z!==null?Z:2),this.input.value=this.#x(this.value),this.#E();break;case"name":if(this[q]=this.input[q]=Z||"",Z)this.input.setAttribute("name",Z);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=Z??"",this.input.placeholder=this.placeholder;break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#b();break;default:this[q]=this.input[q]=Z;break}}}O("fig-input-number",W0);class o0 extends HTMLElement{constructor(){super()}connectedCallback(){this.src=this.getAttribute("src"),this.name=this.getAttribute("name"),this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials),this.setSrc(this.src),this.img=this.querySelector("img")}setSrc(q){if(this.src=q,!q){this.querySelector(":scope > img")?.remove(),this.img=null;return}let Q=this.querySelector(":scope > img")||document.createElement("img");if(Q.src=q,Q.alt=this.name||"",!Q.isConnected)this.replaceChildren(Q);this.img=Q}getInitials(q){return q?q.split(" ").map((Q)=>Q[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(q,Q,Z){if(this[q]=Z,q==="name"){if(this.img)this.img.alt=Z||"";this.name=Z,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials)}else if(q==="src")this.src=Z,this.setSrc(this.src)}}O("fig-avatar",o0);class i0 extends HTMLElement{#Q=!1;#q=null;#Z=null;#$=null;#J=null;#j=null;#N=null;constructor(){super();this.#Z=this.#X.bind(this),this.#$=this.focus.bind(this),this.#J=this.#G.bind(this),this.#j=this.#K.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(!this.isConnected)return;this.#W(),this.#_()})}#_(){if(this.#N||typeof MutationObserver>"u")return;this.#N=new MutationObserver(()=>{this.#W()}),this.#N.observe(this,{childList:!0})}#W(){let q=this.label,Q=this.#q;q?.removeEventListener("click",this.#Z),q?.removeEventListener("click",this.#$),q?.removeEventListener("pointerenter",this.#J),q?.removeEventListener("pointerleave",this.#j),Q?.removeEventListener("click",this.#Z),this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((J)=>J.nodeType===Node.ELEMENT_NODE&&J.nodeName.toLowerCase().startsWith("fig-")&&!(J instanceof Element&&J.classList.contains("fig-field-chevron")));let Z=this.input?.localName??"",$=Z==="fig-select"||Z==="fig-menu"||Z==="fig-dropdown"||Z==="fig-tooltip"||this.input instanceof HTMLDialogElement;if(this.#Q=!!(this.input&&("open"in this.input)&&!$),this.#Q&&this.label){if(!this.#q||!this.#q.isConnected)this.#q=c("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#q,this.label);this.#q.addEventListener("click",this.#Z),this.label.addEventListener("click",this.#Z)}else{if(this.#q)this.#q.removeEventListener("click",this.#Z),this.#q.remove(),this.#q=null;if(this.input&&this.label){if(this.input.querySelectorAll("input, select, textarea").length!==1)this.label.addEventListener("click",this.#$)}}if(this.input&&this.label&&!this.#Q)this.#U();if(this.label)this.label.removeEventListener("pointerenter",this.#J),this.label.addEventListener("pointerenter",this.#J),this.label.removeEventListener("pointerleave",this.#j),this.label.addEventListener("pointerleave",this.#j)}disconnectedCallback(){if(this.#N?.disconnect(),this.#N=null,this.label)M.hide(this.label);if(this.label&&this.#Z)this.label.removeEventListener("click",this.#Z);if(this.label&&this.#$)this.label.removeEventListener("click",this.#$);if(this.label&&this.#J)this.label.removeEventListener("pointerenter",this.#J);if(this.label&&this.#j)this.label.removeEventListener("pointerleave",this.#j);if(this.#q&&this.#Z)this.#q.removeEventListener("click",this.#Z)}#X(q){if(q.preventDefault(),q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open}#G(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;M.show(this.label,this.label.textContent.trim())}#K(){if(this.label)M.hide(this.label)}#U(){if(!this.input||!this.label)return;let q=this.label.getAttribute("id")||m();this.label.setAttribute("id",q);let Q=this.input.querySelectorAll("input, select, textarea");if(Q.length===1){let Z=Q[0],$=Z.getAttribute("id")||m();if(Z.setAttribute("id",$),this.label.setAttribute("for",$),this.input.getAttribute("aria-labelledby")===q)this.input.removeAttribute("aria-labelledby");if(!Z.hasAttribute("aria-labelledby"))Z.setAttribute("aria-labelledby",q);return}if(this.label.removeAttribute("for"),!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-labelledby",q)}attributeChangedCallback(q,Q,Z){switch(q){case"label":if(this.label)this.label.textContent=Z,this.#U();break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let q=this.input.querySelectorAll("input, select, textarea");if(q.length===1)q[0].focus();else if(this.input.focus(),q.length===0)this.input.click()}}O("fig-field",i0);class r0 extends HTMLElement{rgba;hex;#Q=100;#q;#Z;#$;#J;#j=!1;#N=!1;#_=null;#W=this.#V.bind(this);#X=this.#F.bind(this);#G=this.#I.bind(this);#K=this.#E.bind(this);#U=this.#S.bind(this);#Y=this.#y.bind(this);#R=this.#w.bind(this);#z=this.#h.bind(this);constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(q){if(q===null||q===void 0||q===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(q))}#M(){let q={};for(let{name:Q,value:Z}of this.attributes)if(Q.startsWith("picker-")&&Q!=="picker-anchor"&&Q!=="picker-experimental")q[Q.slice(7)]=Z;if(!q["dialog-position"])q["dialog-position"]="left";return q}#L(){let q=this.#M();return Object.entries(q).map(([Q,Z])=>`${Q}="${Z}"`).join(" ")}connectedCallback(){if(this.#B()){this.#H();return}this.#A()}disconnectedCallback(){this.#k()}#B(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-swatch")}#H(){if(this.#P(this.getAttribute("value")),this.#q=this.querySelector("fig-swatch"),this.#Z=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#J=this.querySelector("fig-input-number"),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",String(this.#Q));if(this.#q)this.#q.setAttribute("background",this.hexOpaque),this.#q.setAttribute("alpha",String(this.rgba.a));this.#b(),this.#T()}#k(){if(this.#q)this.#q.removeEventListener("pointerdown",this.#W,{capture:!0}),this.#q.removeEventListener("click",this.#X,{capture:!0}),this.#q.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#G),this.#q.removeEventListener("input",this.#K);this.#$?.removeEventListener("input",this.#U),this.#$?.removeEventListener("change",this.#Y),this.#J?.removeEventListener("input",this.#R),this.#J?.removeEventListener("change",this.#Y),this.#Z?.removeEventListener("input",this.#z),this.#Z?.removeEventListener("change",this.#Y)}#T(){if(this.#q){this.#q.disabled=T(this,"disabled");let q=this.#q.querySelector('input[type="color"]');if(this.#$||this.hasAttribute("swatch-disabled"))q?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(q?.setAttribute("disabled",""),q)q.style.pointerEvents="none"}this.#q.addEventListener("pointerdown",this.#W,{capture:!0}),this.#q.addEventListener("click",this.#X,{capture:!0}),q?.addEventListener("keydown",this.#G),this.#q.addEventListener("input",this.#K)}if(this.#$)this.#$.addEventListener("input",this.#U),this.#$.addEventListener("change",this.#Y);if(this.#J)this.#J.addEventListener("input",this.#R),this.#J.addEventListener("change",this.#Y);if(this.#Z)this.#Z.addEventListener("input",this.#z),this.#Z.addEventListener("change",this.#Y)}#A(){this.#P(this.getAttribute("value"));let q=this.getAttribute("alpha")!=="false",Z=this.#r?" disabled":"",$="";if(this.getAttribute("text")!=="false"){let j=`<fig-input-text
|
|
63
|
+
</fig-input-number>`;else q=Q;if(this.innerHTML=q,this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.figInputNumber=this.querySelector("fig-input-number"),this.#f(),this.datalist=this.querySelector("datalist"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||m()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",m());let Z=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1));for(let $=0;$<Z;$++){let J=document.createElement("option");J.setAttribute("value",this.min+$*this.step),this.datalist.append(J)}this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}else if(this.type==="delta"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",m());let Z=document.createElement("option");Z.setAttribute("value",this.default),this.datalist.append(Z),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let Z=this.datalist.querySelector(`option[value='${this.default}']`);if(Z)Z.setAttribute("default","true")}this.#D()}connectedCallback(){if(this.initialInnerHTML===null)this.initialInnerHTML=this.innerHTML;if(this.#O()){this.#H(),this.#f(),this.#D();return}this.#T()}get value(){if(this.#$!=="")return this.#$;let q=this.getAttribute("value");if(q!==null)return String(this.#F(q));return""}set value(q){let Q=q===null||q===void 0?"":String(q),$=this.min!==void 0||this.max!==void 0?String(this.#F(Q)):Q;if(this.#$=$,this.getAttribute("value")!==$)this.#Z=!0,this.setAttribute("value",$),this.#Z=!1;if(this.input&&this.input.value!==$)this.input.value=$,this.input.setAttribute("aria-valuenow",$);if(this.figInputNumber)this.figInputNumber.setAttribute("value",$);if(this.input)this.#I()}disconnectedCallback(){if(this.#q=!1,this.input)this.input.removeEventListener("input",this.#N),this.input.removeEventListener("change",this.#_),this.input.removeEventListener("keydown",this.#U),this.input.removeEventListener("pointerdown",this.#K),this.input.removeEventListener("pointerup",this.#G),this.input.removeEventListener("pointercancel",this.#G);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#W),this.figInputNumber.removeEventListener("change",this.#X)}#A(){if(this.figInputNumber){let q=this.figInputNumber.value,Q=this.#F(q);this.value=Q,this.input.value=String(Q),this.#D(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#B(q){let{min:Q,max:Z}=this.#P(),$=Z-Q;if($===0)return 0;return(Number(q)-Q)/$}#k(q){if(q===null||q===void 0)return null;if(typeof q==="string"&&q.trim()==="")return null;let Q=Number(q);return Number.isFinite(Q)?Q:null}#P(){let q=this.#k(this.min),Q=this.#k(this.max);if(q===null)q=0;if(Q===null)Q=q;if(q>Q)[q,Q]=[Q,q];return{min:q,max:Q}}#S(q){let{min:Q,max:Z}=this.#P();return Math.min(Z,Math.max(Q,q))}#V(){if(this.type==="delta"){let Q=this.#k(this.default);if(Q!==null)return this.#S(Q);return this.#S(0)}if(this.type==="range"){let{min:Q,max:Z}=this.#P();return this.#S(Q+(Z-Q)/2)}let{min:q}=this.#P();return q}#F(q){let Q=this.#k(q);if(Q===null)return this.#V();return this.#S(Q)}#I(){let q=this.#B(this.value),Q=this.#B(this.default),Z=q<Q?-1:1,$=q===Q?1:0;if(this.#Y!==q)this.style.setProperty("--slider-complete",q),this.#Y=q;if(this.#R!==Q)this.style.setProperty("--default",Q),this.#R=Q;if(this.#z!==Z)this.style.setProperty("--slider-delta-direction",Z),this.#z=Z;if(this.#M!==$)this.style.setProperty("--unchanged",$),this.#M=$}#D(){let q=this.input.value;if(this.value=q,this.#I(),this.input.setAttribute("aria-valuenow",q),this.figInputNumber)this.figInputNumber.setAttribute("value",q)}#C(){if(!this.input)return;if(this.text){this.input.setAttribute("aria-hidden","true"),["aria-label","aria-labelledby","aria-describedby","aria-valuetext"].forEach((q)=>this.input.removeAttribute(q)),this.#w();return}this.input.removeAttribute("aria-hidden"),this.#J.forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.input.removeAttribute(q);else this.input.setAttribute(q,Q)})}#w(){if(!this.figInputNumber)return;["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"].forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.figInputNumber.removeAttribute(q);else this.figInputNumber.setAttribute(q,Q)})}#y(){this.#D(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#m(){this.#Q=!1,this.#D(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#b(q){if(this.disabled||!q.shiftKey)return;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(q.key))return;q.preventDefault();let Q=q.key==="ArrowRight"||q.key==="ArrowUp"?1:-1,Z=this.#k(this.input.value)??this.#V(),$=this.#k(this.step)??1,J=this.#F(Z+$*10*Q);this.value=J,this.input.value=String(J),this.#D(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#E(){if(this.figInputNumber){let q=this.figInputNumber.value,Q=this.#F(q);this.value=Q,this.input.value=String(Q),this.#D(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}#v(q,Q){if(!this.input)return;let Z=this.#j[this.type]||this.#j.range,$=Q===null||String(Q).trim()===""?Z[q]:Number(Q),J=Number.isFinite($)?$:Z[q];if(q==="step"&&!(J>0))J=Z.step>0?Z.step:1;if(this[q]===J&&this.input[q]===String(J))return;if(this[q]=J,this.input[q]=String(J),q==="min")this.input.setAttribute("aria-valuemin",String(J));else if(q==="max")this.input.setAttribute("aria-valuemax",String(J));if(this.figInputNumber)this.figInputNumber.setAttribute(q,String(J));if(!this.hasAttribute("default")&&this.type!=="delta")this.default=this.min;this.value=this.#F(this.value),this.#I(),this.#x()}#x(){if(this.type!=="stepper"||!this.datalist)return;let q=Math.min(1001,Math.max(0,Math.floor((this.max-this.min)/this.step)+1)),Q=document.createDocumentFragment();for(let Z=0;Z<q;Z++){let $=document.createElement("option");$.setAttribute("value",this.min+Z*this.step),Q.append($)}this.datalist.replaceChildren(Q),this.input.setAttribute("list",this.datalist.id)}#h(){if(this.#Q){this.#q=!0;return}this.#q=!1,this.#T()}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-valuetext"]}focus(){if(this.text&&this.figInputNumber){this.figInputNumber.focus();return}this.input.focus()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="value"&&this.#Z)return;if(this.input)switch(q){case"color":this.color=Z,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=Z!==null&&Z!=="false",this.figInputNumber)this.figInputNumber.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#Q)break;this.value=Z,this.#D();break;case"transform":if(this.transform=Number(Z)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=Z!==null?Number(Z):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=Z!==null?Z:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=Z!==null?Z:this.type==="delta"?0:this.min,this.#I();break;case"min":case"max":case"step":this.#v(q,Z);break;case"units":if(this.units=Z||"",this.figInputNumber)if(this.units)this.figInputNumber.setAttribute("units",this.units);else this.figInputNumber.removeAttribute("units");break;case"type":case"variant":if(!this.#Q)this[q]=Z;this.#h();break;case"text":if(!this.#Q)this.text=Z!=="false";this.#h();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":case"aria-valuetext":this.#C();break;default:this[q]=this.input[q]=Z,this.#D();break}}}O("fig-slider",d0);class s0 extends HTMLElement{#Q=!1;#q=!1;#Z="";#$=!1;#J;#j;#N;#_;#W;#X;#U;#K;#G=null;#Y=0;#R="";#z="";#M=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];constructor(){super();this.#J=this.#C.bind(this),this.#j=this.#y.bind(this),this.#N=this.#y.bind(this),this.#_=this.#w.bind(this),this.#W=(q)=>{q.stopPropagation(),this.#D(q)},this.#X=(q)=>{q.stopPropagation();let Q=q.target.value;if(this.type==="number")Q=Number(Q)/(this.transform||1);this.value=Q,this.#P(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))},this.#U=()=>{if(!this.disabled)this.focus()},this.#K=this.#O.bind(this)}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")&&this.getAttribute("multiline")!=="false",this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}if(this.input=this.#L(),this.input.readOnly=this.readonly,this.disabled=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",this.input.disabled=this.disabled,this.#A(),this.#B(),this.#k(),this.#P(),this.#S(),this.#F(),_0(this),this.#H(),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#I(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#I(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#I(this.step));this.addEventListener("pointerdown",this.#_)}this.removeEventListener("click",this.#K),this.addEventListener("click",this.#K),this.input.removeEventListener("change",this.#W),this.input.addEventListener("change",this.#W),this.input.removeEventListener("input",this.#X),this.input.addEventListener("input",this.#X)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#W),this.input.removeEventListener("input",this.#X);if(this.removeEventListener("click",this.#K),this.removeEventListener("pointerdown",this.#_),window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#j),window.removeEventListener("blur",this.#N),this.#G?.disconnect(),this.#G=null,this.#Y)cancelAnimationFrame(this.#Y),this.#Y=0}focus(){this.input.focus()}#L(){let q=this.multiline,Q=this.querySelector("input,textarea");if(Q){if(q?Q.tagName==="TEXTAREA":Q.tagName==="INPUT")return Q;Q.remove()}let Z;if(q)Z=document.createElement("textarea"),Z.value=this.value;else Z=document.createElement("input"),Z.type=this.type,Z.value=this.type==="number"?this.#I(this.value):this.value;if(Z.setAttribute("data-generated","input-control"),this.name)Z.name=this.name;return Z.placeholder=this.placeholder,this.insertBefore(Z,this.querySelector('[slot="append"]')),Z}#O(q){let Q=q.target?.closest?.("[slot]");if(!Q||Q.parentElement!==this)return;if(this.disabled)return;this.focus()}#H(){this.#G?.disconnect(),this.#G=new MutationObserver(()=>this.#f()),this.#G.observe(this,{childList:!0,characterData:!0,subtree:!0})}#f(){if(this.#Y)return;this.#Y=requestAnimationFrame(()=>{if(this.#Y=0,!this.isConnected)return;this.#T()})}#T(){if(!this.input||!this.contains(this.input))this.input=this.#L(),this.input.readOnly=this.readonly,this.input.addEventListener("change",this.#W),this.input.addEventListener("input",this.#X);this.#A(),this.#B(),this.#k(),this.#P(),this.#S(),this.#F(),_0(this)}#A(){if(!this.input)return;this.#M.forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.input.removeAttribute(q);else this.input.setAttribute(q,Q)})}#B(){let q=this.querySelector('[slot="prepend"][data-generated="search-prefix"]');if(this.type!=="search"){q?.remove();return}if(this.querySelector('[slot="prepend"]:not([data-generated])')){q?.remove();return}if(q){let $=q.querySelector("fig-icon");if($&&$.getAttribute("name")!=="search")$.setAttribute("name","search");return}let Z=c("search");Z.setAttribute("slot","prepend"),Z.setAttribute("data-generated","search-prefix"),Z.setAttribute("color","var(--figma-color-icon)"),Z.addEventListener("click",this.#U),this.prepend(Z)}#k(){let q=this.querySelector('[slot="append"][data-generated="search-clear"]');if(this.type!=="search"){q?.remove();return}if(this.querySelector('[slot="append"]:not([data-generated])')){q?.remove();return}if(q){let _=q.querySelector("fig-icon");if(_&&_.getAttribute("name")!=="close")_.setAttribute("name","close");return}let Z=document.createElement("span");Z.setAttribute("slot","append"),Z.setAttribute("data-generated","search-clear");let $=document.createElement("fig-tooltip");$.setAttribute("text","Clear search");let J=document.createElement("fig-button");J.setAttribute("variant","ghost"),J.setAttribute("icon",""),J.setAttribute("aria-label","Clear search");let j=c("close",{size:"small"});j.setAttribute("color","var(--figma-color-icon-secondary)"),J.append(j),$.append(J),Z.append($),this.append(Z),J.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),this.disabled)return;if(!this.input||this.input.value===""){this.focus();return}this.value="",this.input.value="",this.dispatchEvent(new CustomEvent("input",{detail:"",bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:"",bubbles:!0})),this.#P(),this.focus()})}#P(){if(this.type!=="search"){this.removeAttribute("data-search-has-value");return}this.toggleAttribute("data-search-has-value",!!this.input?.value)}#S(){let q=this.querySelector('[slot="append"][data-generated="password-toggle"]');if(this.type!=="password"){q?.remove(),this.#q=!1;return}if(this.querySelector('[slot="append"]:not([data-generated])')){q?.remove();return}if(q){this.#V(q);return}let Z=document.createElement("span");Z.setAttribute("slot","append"),Z.setAttribute("data-generated","password-toggle");let $=document.createElement("fig-tooltip"),J=document.createElement("fig-button");J.setAttribute("variant","ghost"),J.setAttribute("icon","");let j=c("visible",{size:"small"});j.setAttribute("color","var(--figma-color-icon-secondary)"),J.append(j),$.append(J),Z.append($),this.append(Z),this.#V(Z),J.addEventListener("click",(_)=>{if(_.preventDefault(),_.stopPropagation(),this.disabled)return;if(this.#q=!this.#q,this.input)this.input.type=this.#q?"text":"password";this.#V(Z),this.focus()})}#V(q){let Q=q.querySelector("fig-tooltip"),Z=q.querySelector("fig-button"),$=q.querySelector("fig-icon"),J=this.#q?"Hide password":"Show password";Q?.setAttribute("text",J),Z?.setAttribute("aria-label",J),$?.setAttribute("name",this.#q?"visible":"hidden")}#F(){this.querySelectorAll('[data-generated="search-clear"] fig-button, [data-generated="password-toggle"] fig-button').forEach((q)=>{if(this.disabled)q.setAttribute("disabled","");else q.removeAttribute("disabled")})}#I(q){if(q==="")return"";let Q=Number(q)*(this.transform||1);return Q=this.#b(Q),Q}#D(q){q.stopPropagation();let Q=q.target.value,Z=Q;if(this.type==="number")Q=Q/(this.transform||1),Q=this.#m(Q,!1),Z=Q*(this.transform||1);this.value=Q,this.input.value=Z,this.#P(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#C(q){if(this.type!=="number")return;if(q.buttons===0){this.#y();return}let Q=(this.step||1)*q.movementX,Z=Number(this.input.value);Z=Z/(this.transform||1)+Q,Z=this.#m(Z,!1);let $=Z*(this.transform||1);Z=this.#b(Z),$=this.#b($),this.value=Z,this.input.value=$,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#w(q){if(this.type!=="number")return;if(q.altKey||q.target.closest("[slot]"))this.#Q=!0,this.#R=this.style.userSelect,this.#z=document.body.style.cursor,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#J),window.addEventListener("pointerup",this.#j),window.addEventListener("pointercancel",this.#j),window.addEventListener("blur",this.#N)}#y(q){if(this.type!=="number")return;let Q=this.#Q;if(this.#Q=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#z,this.style.userSelect=this.#R,window.removeEventListener("pointermove",this.#J),window.removeEventListener("pointerup",this.#j),window.removeEventListener("pointercancel",this.#j),window.removeEventListener("blur",this.#N),Q)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#m(q,Q=!0){let Z=q;if(this.type==="number"){if(Z=Number(Z),typeof this.min==="number")Z=Math.max(Q?this.#I(this.min):this.min,Z);if(typeof this.max==="number")Z=Math.min(Q?this.#I(this.max):this.max,Z);Z=this.#b(Z)}return Z}#b(q,Q=2){let Z=Math.round(q*100)/100;return Number.isInteger(Z)?Z:Z.toFixed(Q)}get value(){return this.#Z}set value(q){let Q=q??"";this.#Z=Q;let Z=String(Q);if(this.getAttribute("value")!==Z)this.#$=!0,this.setAttribute("value",Z),this.#$=!1;this.#E(Q)}#E(q){if(!this.input||this.#Q)return;let Q=this.type==="number"?String(this.#I(q)):String(q??"");if(this.input.value!==Q)this.input.value=Q;this.#P()}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","multiline","step","min","max","transform","name","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(q,Q,Z){if(this.input)switch(q){case"disabled":this.disabled=this.input.disabled=Z!==null&&Z!=="false",this.#F();break;case"readonly":this.readonly=Z!==null&&Z!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number(Z)||1,this.input.value=this.#I(this.value);break;case"value":if(this.#Q)break;let $=Z;if(this.type==="number")$=this.#m($,!1);if(this.#Z=$??"",!this.#$)this.#E(this.#Z);break;case"min":case"max":case"step":if(Z===null||Z==="")this[q]=void 0,this.input.removeAttribute(q);else this[q]=this.input[q]=Number(Z),this.input.setAttribute(q,Z);break;case"name":if(this[q]=this.input[q]=Z||"",Z)this.input.setAttribute("name",Z);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=Z??"",this.input.placeholder=this.placeholder;break;case"type":if(this.type=Z||"text",this.input.type=this.type,this.removeEventListener("pointerdown",this.#_),this.type==="number")this.step=this.hasAttribute("step")?Number(this.getAttribute("step")):void 0,this.min=this.hasAttribute("min")?Number(this.getAttribute("min")):void 0,this.max=this.hasAttribute("max")?Number(this.getAttribute("max")):void 0,this.transform=Number(this.getAttribute("transform")||1),this.addEventListener("pointerdown",this.#_);this.#B(),this.#k(),this.#P(),this.#S(),this.#F();break;case"multiline":{let J=Z!==null&&Z!=="false";if(J!==this.multiline){this.multiline=J;let j=this.input;j.removeEventListener("change",this.#W),j.removeEventListener("input",this.#X),j.remove(),this.input=this.#L(),this.input.readOnly=this.readonly,this.input.disabled=Boolean(this.disabled),this.input.addEventListener("change",this.#W),this.input.addEventListener("input",this.#X),this.#A()}break}case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#A();break;default:this[q]=this.input[q]=Z;break}}}O("fig-input-text",s0);class W0 extends HTMLElement{#Q;#q;#Z;#$;#J;#j;#N;#_;#W;#X;#U;#K;#G;#Y;#R;#z;#M=!1;#L=null;#O=null;#H=0;#f="";#T="";#A=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];static#B="px";#k(q){return(q||"").split(",").map((Q)=>Q.trim().toLowerCase()).filter(Boolean)}#P(q){let Q=(q||"").trim();if(!Q)return"";return(this.#Y??[]).includes(Q.toLowerCase())?"":Q}#S(){this.#K=this.#P(this.#G)}#V(q){if(q&&!this.#L)this.#L=document.createElement("span"),this.#L.className="fig-steppers",this.#L.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#L.addEventListener("pointerdown",(Q)=>{Q.preventDefault(),Q.stopPropagation();let Z=Q.target.closest("button");if(!Z||this.disabled||Z.disabled)return;let $=Z.classList.contains("fig-stepper-up")?1:-1;this.#I($),this.input.focus()}),this.append(this.#L);else if(!q&&this.#L)this.#L.remove(),this.#L=null;this.#F()}#F(){if(!this.#L)return;let q=this.#L.querySelector(".fig-stepper-up"),Q=this.#L.querySelector(".fig-stepper-down");if(!q||!Q)return;let Z=this.input?this.#v(this.input.value):this.value,$=Z!==""&&Z!==null&&Z!==void 0?Number(Z)/(this.transform||1):Number(this.value),J=Number.isFinite($),j=Boolean(this.disabled),_=J&&typeof this.min==="number"&&$<=this.min,W=J&&typeof this.max==="number"&&$>=this.max;q.disabled=j||W,Q.disabled=j||_}#I(q){let Q=this.step||1,Z=this.#v(this.input.value),$=(Z!==""?Number(Z)/(this.transform||1):0)+Q*q;$=this.#p($,!1),this.value=$,this.input.value=this.#x(this.value),this.#F(),this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#Q=this.#c.bind(this),this.#q=this.#s.bind(this),this.#Z=this.#s.bind(this),this.#$=this.#i.bind(this),this.#J=(q)=>{q.stopPropagation(),this.#o(q)},this.#j=(q)=>{q.stopPropagation(),this.#u(q)},this.#N=(q)=>{this.#g(q)},this.#_=(q)=>{this.#r(q)},this.#W=(q)=>{this.#l(q)},this.#X=this.focus.bind(this),this.#U=this.#C.bind(this)}connectedCallback(){let q=this.getAttribute("value");this.value=q!==null&&q!==""?Number(q):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#G=this.getAttribute("units")||"";let Q=this.getAttribute("units-disallow");if(this.#Y=this.#k(Q===null?W0.#B:Q),this.#S(),this.#R=this.getAttribute("unit-position")||"suffix",this.#z=this.#a(this.hasAttribute("precision")?this.getAttribute("precision"):2),this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));this.transform=Number(this.getAttribute("transform")||1);let Z=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.input=this.#D(),this.#b(),this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.#V(Z),this.hasAttribute("disabled")){let $=this.getAttribute("disabled");this.disabled=this.input.disabled=$!=="false"}this.#F(),this.#E(),_0(this),this.addEventListener("pointerdown",this.#$),this.removeEventListener("click",this.#U),this.addEventListener("click",this.#U),this.#w(),this.input.removeEventListener("change",this.#J),this.input.addEventListener("change",this.#J),this.input.removeEventListener("input",this.#j),this.input.addEventListener("input",this.#j),this.input.removeEventListener("focus",this.#N),this.input.addEventListener("focus",this.#N),this.input.removeEventListener("blur",this.#_),this.input.addEventListener("blur",this.#_),this.input.removeEventListener("keydown",this.#W),this.input.addEventListener("keydown",this.#W)}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#J),this.input.removeEventListener("input",this.#j),this.input.removeEventListener("focus",this.#N),this.input.removeEventListener("blur",this.#_),this.input.removeEventListener("keydown",this.#W);if(this.removeEventListener("click",this.#U),this.removeEventListener("pointerdown",this.#$),window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#q),window.removeEventListener("blur",this.#Z),this.#O?.disconnect(),this.#O=null,this.#H)cancelAnimationFrame(this.#H),this.#H=0}focus(){this.input.focus()}#D(){let q=this.querySelector("input");if(q)return q;let Q=document.createElement("input");if(Q.type="text",Q.inputMode="decimal",Q.setAttribute("data-generated","input-control"),this.name)Q.name=this.name;return Q.placeholder=this.placeholder,Q.value=this.#x(this.value),this.insertBefore(Q,this.querySelector('[slot="append"]')),Q}#C(q){let Q=q.target?.closest?.("[slot]");if(!Q||Q.parentElement!==this)return;this.focus()}#w(){this.#O?.disconnect(),this.#O=new MutationObserver(()=>this.#y()),this.#O.observe(this,{childList:!0,characterData:!0,subtree:!0})}#y(){if(this.#H)return;this.#H=requestAnimationFrame(()=>{if(this.#H=0,!this.isConnected)return;this.#m()})}#m(){if(!this.input||!this.contains(this.input))this.input=this.#D(),this.input.addEventListener("change",this.#J),this.input.addEventListener("input",this.#j),this.input.addEventListener("focus",this.#N),this.input.addEventListener("blur",this.#_),this.input.addEventListener("keydown",this.#W);let q=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";if(this.#L&&!this.contains(this.#L))this.#L=null;this.#V(q),this.#b(),this.#E(),_0(this)}#b(){if(!this.input)return;this.#A.forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.input.removeAttribute(q);else this.input.setAttribute(q,Q)})}#E(){if(!this.input)return;if(this.input.setAttribute("role","spinbutton"),typeof this.min==="number")this.input.setAttribute("aria-valuemin",String(this.min));else this.input.removeAttribute("aria-valuemin");if(typeof this.max==="number")this.input.setAttribute("aria-valuemax",String(this.max));else this.input.removeAttribute("aria-valuemax");let q=this.value===""?null:Number(this.value);if(Number.isFinite(q))this.input.setAttribute("aria-valuenow",String(q)),this.input.setAttribute("aria-valuetext",this.#x(this.value));else this.input.removeAttribute("aria-valuenow"),this.input.removeAttribute("aria-valuetext")}#v(q){if(!q)return"";if(!this.#K){let $=q.replace(/[^\d.-]/g,""),J=$.split(".");if(J.length>2)$=J[0]+"."+J.slice(1).join("");return $}let Q=q.replace(this.#K,"").trim();Q=Q.replace(/[^\d.-]/g,"");let Z=Q.split(".");if(Z.length>2)Q=Z[0]+"."+Z.slice(1).join("");return Q}#x(q){if(q===""||q===null||q===void 0)return"";let Q=Number(q)*(this.transform||1);if(isNaN(Q))return"";if(Q=this.#d(Q),!this.#K)return Q.toString();if(this.#R==="prefix")return this.#K+Q;else return Q+this.#K}#h(q){if(q===""||q===null||q===void 0)return"";let Q=Number(q)*(this.transform||1);return Q=this.#d(Q),Q.toString()}#g(q){this.#M=!0,setTimeout(()=>{let Q=q.target.value;if(Q&&this.#K)if(this.#R==="prefix")q.target.setSelectionRange(this.#K.length,Q.length);else{let Z=Q.indexOf(this.#K);if(Z>-1)q.target.setSelectionRange(0,Z)}},0)}#r(q){this.#M=!1;let Q=this.#v(q.target.value);if(Q!==""){let Z=Number(Q)/(this.transform||1);Z=this.#p(Z,!1),this.value=Z,q.target.value=this.#x(this.value)}else this.value="",q.target.value="";this.#F(),this.#E()}#l(q){if(this.disabled)return;if(q.key!=="ArrowUp"&&q.key!=="ArrowDown")return;q.preventDefault();let Q=this.step||1,Z=q.shiftKey?10:1,$=Q*Z*(q.key==="ArrowUp"?1:-1),J=this.#v(this.input.value),j=(J!==""?Number(J)/(this.transform||1):0)+$;j=this.#p(j,!1),this.value=j,this.input.value=this.#x(this.value),this.#F(),this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#u(q){let Q=this.#v(q.target.value);if(Q!=="")this.value=Number(Q)/(this.transform||1);else this.value="";this.#F(),this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#o(q){q.stopPropagation();let Q=this.#v(q.target.value);if(Q!==""){let Z=Number(Q)/(this.transform||1);Z=this.#p(Z,!1),this.value=Z,q.target.value=this.#x(this.value)}else this.value="",q.target.value="";this.#F(),this.#E(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#c(q){if(this.disabled)return;if(q.buttons===0){this.#s();return}let Q=(this.step||1)*q.movementX,Z=this.#v(this.input.value),$=Number(Z)/(this.transform||1)+Q;$=this.#p($,!1),this.value=$,this.input.value=this.#x(this.value),this.#F(),this.#E(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#i(q){if(this.disabled)return;if(q.altKey||q.target.closest("[slot]"))this.#M=!0,this.#f=this.style.userSelect,this.#T=document.body.style.cursor,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Q),window.addEventListener("pointerup",this.#q),window.addEventListener("pointercancel",this.#q),window.addEventListener("blur",this.#Z)}#s(q){let Q=this.#M;if(this.#M=!1,this.input.style.cursor="",this.style.cursor="",document.body.style.cursor=this.#T,this.style.userSelect=this.#f,window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#q),window.removeEventListener("pointercancel",this.#q),window.removeEventListener("blur",this.#Z),Q)this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#p(q,Q=!0){let Z=Number(q);if(isNaN(Z))return"";if(typeof this.min==="number")Z=Math.max(this.min,Z);if(typeof this.max==="number")Z=Math.min(this.max,Z);return Z=this.#d(Z),Z}#d(q){let Q=this.#z??2,Z=Math.pow(10,Q),$=Math.round(q*Z)/Z;return Number.isInteger($)?$:parseFloat($.toFixed(Q))}#a(q){let Q=Number(q);if(!Number.isFinite(Q))return 2;return Math.max(0,Math.min(100,Math.trunc(Q)))}static get observedAttributes(){return["value","placeholder","disabled","step","min","max","transform","name","units","units-disallow","unit-position","steppers","precision","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}attributeChangedCallback(q,Q,Z){if(this.input)switch(q){case"disabled":this.disabled=this.input.disabled=Z!==null&&Z!=="false",this.#F();break;case"units":this.#G=Z||"",this.#S(),this.input.value=this.#x(this.value),this.#E();break;case"units-disallow":this.#Y=this.#k(Z===null?W0.#B:Z),this.#S(),this.input.value=this.#x(this.value),this.#E();break;case"unit-position":this.#R=Z||"suffix",this.input.value=this.#x(this.value),this.#E();break;case"transform":this.transform=Number(Z)||1,this.input.value=this.#x(this.value),this.#E();break;case"value":if(this.#M)break;let $=Z!==null&&Z!==""?Number(Z):"";if($!=="")$=this.#p($,!1);this.value=$,this.input.value=this.#x(this.value),this.#F(),this.#E();break;case"min":case"max":case"step":if(Z===null||Z===""){this[q]=void 0,this.#F(),this.#E();break}this[q]=Number(Z),this.#F(),this.#E();break;case"steppers":{let J=Z!==null&&Z!=="false";this.#V(J);break}case"precision":this.#z=this.#a(Z!==null?Z:2),this.input.value=this.#x(this.value),this.#E();break;case"name":if(this[q]=this.input[q]=Z||"",Z)this.input.setAttribute("name",Z);else this.input.removeAttribute("name");break;case"placeholder":this.placeholder=Z??"",this.input.placeholder=this.placeholder;break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#b();break;default:this[q]=this.input[q]=Z;break}}}O("fig-input-number",W0);class o0 extends HTMLElement{constructor(){super()}connectedCallback(){this.src=this.getAttribute("src"),this.name=this.getAttribute("name"),this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials),this.setSrc(this.src),this.img=this.querySelector("img")}setSrc(q){if(this.src=q,!q){this.querySelector(":scope > img")?.remove(),this.img=null;return}let Q=this.querySelector(":scope > img")||document.createElement("img");if(Q.src=q,Q.alt=this.name||"",!Q.isConnected)this.replaceChildren(Q);this.img=Q}getInitials(q){return q?q.split(" ").map((Q)=>Q[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(q,Q,Z){if(this[q]=Z,q==="name"){if(this.img)this.img.alt=Z||"";this.name=Z,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials)}else if(q==="src")this.src=Z,this.setSrc(this.src)}}O("fig-avatar",o0);class i0 extends HTMLElement{#Q=!1;#q=null;#Z=null;#$=null;#J=null;#j=null;#N=null;constructor(){super();this.#Z=this.#X.bind(this),this.#$=this.focus.bind(this),this.#J=this.#U.bind(this),this.#j=this.#K.bind(this)}static get observedAttributes(){return["label"]}connectedCallback(){queueMicrotask(()=>{if(!this.isConnected)return;this.#W(),this.#_()})}#_(){if(this.#N||typeof MutationObserver>"u")return;this.#N=new MutationObserver(()=>{this.#W()}),this.#N.observe(this,{childList:!0})}#W(){let q=this.label,Q=this.#q;q?.removeEventListener("click",this.#Z),q?.removeEventListener("click",this.#$),q?.removeEventListener("pointerenter",this.#J),q?.removeEventListener("pointerleave",this.#j),Q?.removeEventListener("click",this.#Z),this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((J)=>J.nodeType===Node.ELEMENT_NODE&&J.nodeName.toLowerCase().startsWith("fig-")&&!(J instanceof Element&&J.classList.contains("fig-field-chevron")));let Z=this.input?.localName??"",$=Z==="fig-select"||Z==="fig-menu"||Z==="fig-dropdown"||Z==="fig-tooltip"||this.input instanceof HTMLDialogElement;if(this.#Q=!!(this.input&&("open"in this.input)&&!$),this.#Q&&this.label){if(!this.#q||!this.#q.isConnected)this.#q=c("chevron",{size:"small",className:"fig-field-chevron"}),this.insertBefore(this.#q,this.label);this.#q.addEventListener("click",this.#Z),this.label.addEventListener("click",this.#Z)}else{if(this.#q)this.#q.removeEventListener("click",this.#Z),this.#q.remove(),this.#q=null;if(this.input&&this.label){if(this.input.querySelectorAll("input, select, textarea").length!==1)this.label.addEventListener("click",this.#$)}}if(this.input&&this.label&&!this.#Q)this.#G();if(this.label)this.label.removeEventListener("pointerenter",this.#J),this.label.addEventListener("pointerenter",this.#J),this.label.removeEventListener("pointerleave",this.#j),this.label.addEventListener("pointerleave",this.#j)}disconnectedCallback(){if(this.#N?.disconnect(),this.#N=null,this.label)M.hide(this.label);if(this.label&&this.#Z)this.label.removeEventListener("click",this.#Z);if(this.label&&this.#$)this.label.removeEventListener("click",this.#$);if(this.label&&this.#J)this.label.removeEventListener("pointerenter",this.#J);if(this.label&&this.#j)this.label.removeEventListener("pointerleave",this.#j);if(this.#q&&this.#Z)this.#q.removeEventListener("click",this.#Z)}#X(q){if(q.preventDefault(),q.stopPropagation(),this.input&&typeof this.input.open<"u")this.input.open=!this.input.open}#U(){if(!this.label||this.label.scrollWidth<=this.label.clientWidth)return;M.show(this.label,this.label.textContent.trim())}#K(){if(this.label)M.hide(this.label)}#G(){if(!this.input||!this.label)return;let q=this.label.getAttribute("id")||m();this.label.setAttribute("id",q);let Q=this.input.querySelectorAll("input, select, textarea");if(Q.length===1){let Z=Q[0],$=Z.getAttribute("id")||m();if(Z.setAttribute("id",$),this.label.setAttribute("for",$),this.input.getAttribute("aria-labelledby")===q)this.input.removeAttribute("aria-labelledby");if(!Z.hasAttribute("aria-labelledby"))Z.setAttribute("aria-labelledby",q);return}if(this.label.removeAttribute("for"),!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-labelledby",q)}attributeChangedCallback(q,Q,Z){switch(q){case"label":if(this.label)this.label.textContent=Z,this.#G();break}}focus(){if(!this.input)return;if(this.input.contains(document.activeElement))return;let q=this.input.querySelectorAll("input, select, textarea");if(q.length===1)q[0].focus();else if(this.input.focus(),q.length===0)this.input.click()}}O("fig-field",i0);class r0 extends HTMLElement{rgba;hex;#Q=100;#q;#Z;#$;#J;#j=!1;#N=!1;#_=null;#W=this.#V.bind(this);#X=this.#F.bind(this);#U=this.#I.bind(this);#K=this.#E.bind(this);#G=this.#C.bind(this);#Y=this.#y.bind(this);#R=this.#w.bind(this);#z=this.#v.bind(this);constructor(){super()}get alpha(){return this.getAttribute("alpha")}set alpha(q){if(q===null||q===void 0||q===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(q))}#M(){let q={};for(let{name:Q,value:Z}of this.attributes)if(Q.startsWith("picker-")&&Q!=="picker-anchor"&&Q!=="picker-experimental")q[Q.slice(7)]=Z;if(!q["dialog-position"])q["dialog-position"]="left";return q}#L(){let q=this.#M();return Object.entries(q).map(([Q,Z])=>`${Q}="${Z}"`).join(" ")}connectedCallback(){if(this.#O()){this.#H();return}this.#A()}disconnectedCallback(){this.#f()}#O(){return this.getAttribute("text")!=="false"?!!this.querySelector(":scope > .input-combo"):!!this.querySelector(":scope > fig-swatch")}#H(){if(this.#D(this.getAttribute("value")),this.#q=this.querySelector("fig-swatch"),this.#Z=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#J=this.querySelector("fig-input-number"),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",String(this.#Q));if(this.#q)this.#q.setAttribute("background",this.hexOpaque),this.#q.setAttribute("alpha",String(this.rgba.a));this.#b(),this.#T()}#f(){if(this.#q)this.#q.removeEventListener("pointerdown",this.#W,{capture:!0}),this.#q.removeEventListener("click",this.#X,{capture:!0}),this.#q.querySelector('input[type="color"]')?.removeEventListener("keydown",this.#U),this.#q.removeEventListener("input",this.#K);this.#$?.removeEventListener("input",this.#G),this.#$?.removeEventListener("change",this.#Y),this.#J?.removeEventListener("input",this.#R),this.#J?.removeEventListener("change",this.#Y),this.#Z?.removeEventListener("input",this.#z),this.#Z?.removeEventListener("change",this.#Y)}#T(){if(this.#q){this.#q.disabled=T(this,"disabled");let q=this.#q.querySelector('input[type="color"]');if(this.#$||this.hasAttribute("swatch-disabled"))q?.setAttribute("tabindex","-1");if(this.hasAttribute("swatch-disabled")){if(q?.setAttribute("disabled",""),q)q.style.pointerEvents="none"}this.#q.addEventListener("pointerdown",this.#W,{capture:!0}),this.#q.addEventListener("click",this.#X,{capture:!0}),q?.addEventListener("keydown",this.#U),this.#q.addEventListener("input",this.#K)}if(this.#$)this.#$.addEventListener("input",this.#G),this.#$.addEventListener("change",this.#Y);if(this.#J)this.#J.addEventListener("input",this.#R),this.#J.addEventListener("change",this.#Y);if(this.#Z)this.#Z.addEventListener("input",this.#z),this.#Z.addEventListener("change",this.#Y)}#A(){this.#D(this.getAttribute("value"));let q=this.getAttribute("alpha")!=="false",Z=this.#r?" disabled":"",$="";if(this.getAttribute("text")!=="false"){let j=`<fig-input-text
|
|
64
64
|
type="text"
|
|
65
65
|
placeholder="000000"
|
|
66
66
|
value="${this.hexOpaque.slice(1).toUpperCase()}"${Z}>
|
|
@@ -75,7 +75,7 @@ var wq=(q,Q)=>()=>(q&&(Q=q(q=0)),Q);var yq={};var D0=wq(()=>{/*! Vendored from @
|
|
|
75
75
|
</fig-tooltip>`;let _="";_=`<fig-swatch background="${this.hexOpaque}" alpha="${this.rgba.a}"${Z}></fig-swatch>`,$=`<div class="input-combo">
|
|
76
76
|
${_}
|
|
77
77
|
${j}
|
|
78
|
-
</div>`}else $=`<fig-swatch background="${this.hexOpaque}" alpha="${this.rgba.a}"${Z}></fig-swatch>`;if(this.innerHTML=$,this.#q=this.querySelector("fig-swatch"),this.#Z=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#J=this.querySelector("fig-input-number"),this.#b(),this.#$){let j=this.rgbAlphaToHex(this.rgba,1);if(this.#$.value=j.slice(1).toUpperCase(),this.#q)this.#q.background=j}this.#T()}#O(){if(!this.#Z)return;for(let[q,Q]of Object.entries(this.#M()))this.#Z.setAttribute(q,Q);if(this.#Z.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#Z.removeAttribute("alpha");else this.#Z.setAttribute("alpha","false");if(T(this,"disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");this.#Z.anchorElement=this,this.#Z.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Q}))}#f(){if(!o())return null;if(this.#Z?.isConnected)return this.#O(),this.#Z;let q=document.createElement("fig-fill-picker");return q.innerHTML="<span hidden></span>",q.addEventListener("input",this.#z),q.addEventListener("change",this.#Y),this.appendChild(q),this.#Z=q,this.#O(),q}#D(){if(T(this,"disabled")||T(this,"swatch-disabled"))return!1;let q=this.#f();if(!q)return!1;return requestAnimationFrame(()=>q.open?.()),!0}#C(q){q.preventDefault(),q.stopPropagation(),q.stopImmediatePropagation?.()}#V(q){if(!o())return;if(T(this,"disabled")||T(this,"swatch-disabled"))return;if(this.#N=!0,this.#j=!0,this.#_)clearTimeout(this.#_);this.#_=setTimeout(()=>{this.#j=!1,this.#N=!1,this.#_=null},500),this.#C(q)}#F(q){if(!this.#j)return;if(this.#j=!1,this.#_)clearTimeout(this.#_),this.#_=null;if(this.#C(q),this.#N)this.#N=!1,this.#D()}#I(q){if(q.key!=="Enter"&&q.key!==" ")return;if(!o())return;if(!this.#D())return;this.#C(q)}#P(q){let Q=typeof q==="string"&&q.trim()?q.trim():"#D9D9D9",Z=this.convertToRGBA(Q);if(!Z||!Number.isFinite(Z.r)||!Number.isFinite(Z.g)||!Number.isFinite(Z.b)||!Number.isFinite(Z.a))Q="#D9D9D9",Z={r:217,g:217,b:217,a:1};this.rgba=Z,this.value=this.rgbAlphaToHex({r:isNaN(this.rgba.r)?0:this.rgba.r,g:isNaN(this.rgba.g)?0:this.rgba.g,b:isNaN(this.rgba.b)?0:this.rgba.b},this.rgba.a),this.hexWithAlpha=this.value.toUpperCase(),this.hexOpaque=this.hexWithAlpha.slice(0,7),this.#Q=Q.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#S(q){q.stopPropagation();let Q=q.target.value.replace(/#/g,"");if(this.#P("#"+Q),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",this.#Q);if(this.#q)this.#q.setAttribute("background",this.hexOpaque);this.#x()}#w(q){q.stopPropagation();let Q=Number(q.target.value)||0,$=Math.round(Q/100*255).toString(16).padStart(2,"0");if(this.#P(this.hexOpaque+$),this.#q)this.#q.setAttribute("alpha",this.rgba.a);if(this.#Z)this.#Z.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Q}));this.#x()}#y(q){q.stopPropagation(),this.#v()}focus(){if(this.#$){this.#$.focus();return}this.#q?.focus()}#g(){return this.getAttribute("aria-label")||"Color"}#b(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#r)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let q=this.getAttribute("aria-describedby"),Q=this.getAttribute("aria-invalid"),Z=this.getAttribute("aria-required"),$=this.getAttribute("aria-labelledby"),J=this.#g();if(this.#$){if(this.#$.setAttribute("aria-label",`${J} hex color`),q)this.#$.setAttribute("aria-describedby",q);else this.#$.removeAttribute("aria-describedby");if(Q)this.#$.setAttribute("aria-invalid",Q);else this.#$.removeAttribute("aria-invalid");if(Z)this.#$.setAttribute("aria-required",Z);else this.#$.removeAttribute("aria-required")}if(this.#J){if(this.#J.setAttribute("aria-label",`${J} opacity`),q)this.#J.setAttribute("aria-describedby",q);else this.#J.removeAttribute("aria-describedby");if(Q)this.#J.setAttribute("aria-invalid",Q);else this.#J.removeAttribute("aria-invalid");if(Z)this.#J.setAttribute("aria-required",Z);else this.#J.removeAttribute("aria-required")}if(!this.#$){let j=this.#q?.querySelector('input[type="color"]');if(!j)return;if($)j.setAttribute("aria-labelledby",$),j.removeAttribute("aria-label");else j.setAttribute("aria-label",J),j.removeAttribute("aria-labelledby");if(q)j.setAttribute("aria-describedby",q);else j.removeAttribute("aria-describedby")}}#E(q){if(q.stopPropagation(),this.#P(q.target.value),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#x()}#h(q){q.stopPropagation();let Q=q.detail;if(Q&&Q.color){let Z=Q.color;if(Q.alpha!==void 0){let $=Math.round(Q.alpha*255).toString(16).padStart(2,"0");Z=Q.color+$}if(this.#P(Z),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#J&&Q.alpha!==void 0)this.#J.setAttribute("value",Math.round(Q.alpha*100));if(this.#q)this.#q.setAttribute("background",this.hexOpaque),this.#q.setAttribute("alpha",this.rgba.a);this.#x()}}#x(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:this.#m()}))}#v(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:this.#m()}))}#m(){return{value:this.value,hex:this.hex,rgba:this.rgba,...r(this.hexOpaque,this.rgba?.a,Math.round((this.rgba?.a??1)*100))}}static get observedAttributes(){return["value","style","mode","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(q){this.setAttribute("mode",q)}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"value":if(this.#P(Z),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#q)this.#q.setAttribute("background",this.hexOpaque),this.#q.setAttribute("alpha",this.rgba.a);if(this.#Z)this.#Z.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Q}));if(this.#J)this.#J.setAttribute("value",this.#Q);break;case"mode":this.#O();break;case"alpha":case"text":if(this.isConnected)this.#A();break;case"disabled":this.#l();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#b();break}}get#r(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#l(){let q=this.#r;for(let Q of[this.#q,this.#$,this.#J]){if(!Q)continue;if(q)Q.setAttribute("disabled","");else Q.removeAttribute("disabled")}if(this.#b(),this.#Z)this.#O()}rgbAlphaToHex({r:q,g:Q,b:Z},$=1){q=Math.max(0,Math.min(255,Math.round(q))),Q=Math.max(0,Math.min(255,Math.round(Q))),Z=Math.max(0,Math.min(255,Math.round(Z))),$=Math.max(0,Math.min(1,$));let J=q.toString(16).padStart(2,"0"),j=Q.toString(16).padStart(2,"0"),_=Z.toString(16).padStart(2,"0");if($===1)return`#${J}${j}${_}`.toUpperCase();let N=Math.round($*255).toString(16).padStart(2,"0");return`#${J}${j}${_}${N}`.toUpperCase()}convertToRGBA(q){if(typeof q!=="string")return null;let Q,Z,$,J=1;if(q.startsWith("#")){let j=q.slice(1);if(j.length===8)J=parseInt(j.slice(6),16)/255,j=j.slice(0,6);Q=parseInt(j.slice(0,2),16),Z=parseInt(j.slice(2,4),16),$=parseInt(j.slice(4,6),16)}else if(q.startsWith("rgba")||q.startsWith("rgb")){let j=q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(j)Q=parseInt(j[1]),Z=parseInt(j[2]),$=parseInt(j[3]),J=j[4]?parseFloat(j[4]):1}else if(q.startsWith("hsla")||q.startsWith("hsl")){let j=q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(j){let _=parseInt(j[1])/360,W=parseInt(j[2])/100,N=parseInt(j[3])/100;if(J=j[4]?parseFloat(j[4]):1,W===0)Q=Z=$=N;else{let K=(X,z,B)=>{if(B<0)B+=1;if(B>1)B-=1;if(B<0.16666666666666666)return X+(z-X)*6*B;if(B<0.5)return z;if(B<0.6666666666666666)return X+(z-X)*(0.6666666666666666-B)*6;return X},G=N<0.5?N*(1+W):N+W-N*W,U=2*N-G;Q=K(U,G,_+0.3333333333333333),Z=K(U,G,_),$=K(U,G,_-0.3333333333333333)}Q=Math.round(Q*255),Z=Math.round(Z*255),$=Math.round($*255)}}else return null;return{r:Q,g:Z,b:$,a:J}}}O("fig-input-color",r0);var cq=["srgb","srgb-linear","display-p3","oklab","oklch","hsl"],pq=["shorter","longer","increasing","decreasing"],l0=new Set(["oklch","hsl"]);function Z0(q){let Q={...q??{}},Z=String(Q.interpolationSpace??"srgb").toLowerCase();if(!cq.includes(Z))Z="srgb";Q.interpolationSpace=Z;let $=String(Q.hueInterpolation??"shorter").toLowerCase();return Q.hueInterpolation=pq.includes($)?$:"shorter",Q}function t0(q){let Q=Z0(q),Z={...Q,interpolationSpace:Q.interpolationSpace};if(l0.has(Q.interpolationSpace))Z.hueInterpolation=Q.hueInterpolation;else delete Z.hueInterpolation;return Z}function a0(q){let Q=Z0(q);if(Q.interpolationSpace==="srgb")return"";if(l0.has(Q.interpolationSpace))return`in ${Q.interpolationSpace} ${Q.hueInterpolation} hue`;return`in ${Q.interpolationSpace}`}function i(q){let Q=q.replace(/^#/,"");return{r:parseInt(Q.substring(0,2),16),g:parseInt(Q.substring(2,4),16),b:parseInt(Q.substring(4,6),16)}}function p(q){let Q=q/255;return Q<=0.04045?Q/12.92:Math.pow((Q+0.055)/1.055,2.4)}function l(q){let Q=q<=0.0031308?12.92*q:1.055*Math.pow(q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Q))*255)}function n(q,Q,Z){let $=p(q),J=p(Q),j=p(Z),_=Math.cbrt(0.4122214708*$+0.5363325363*J+0.0514459929*j),W=Math.cbrt(0.2119034982*$+0.6806995451*J+0.1073969566*j),N=Math.cbrt(0.0883024619*$+0.2817188376*J+0.6299787005*j);return{l:0.2104542553*_+0.793617785*W-0.0040720468*N,a:1.9779984951*_-2.428592205*W+0.4505937099*N,b:0.0259040371*_+0.7827717662*W-0.808675766*N}}function S0(q,Q,Z){let $=q+0.3963377774*Q+0.2158037573*Z,J=q-0.1055613458*Q-0.0638541728*Z,j=q-0.0894841775*Q-1.291485548*Z,_=$*$*$,W=J*J*J,N=j*j*j;return{r:l(4.0767416621*_-3.3077115913*W+0.2309699292*N),g:l(-1.2684380046*_+2.6097574011*W-0.3413193965*N),b:l(-0.0041960863*_-0.7034186147*W+1.707614701*N)}}function R0(q,Q,Z){return{l:q,c:Math.sqrt(Q*Q+Z*Z),h:Math.atan2(Z,Q)*180/Math.PI}}function dq(q,Q,Z){let $=Z*Math.PI/180;return{l:q,a:Q*Math.cos($),b:Q*Math.sin($)}}function V0(q,Q,Z,$){let J=(q%360+360)%360,_=(Q%360+360)%360-J;switch($){case"longer":if(_>0&&_<180)_-=360;else if(_<0&&_>-180)_+=360;else if(_===0)_=0;break;case"increasing":if(_<0)_+=360;break;case"decreasing":if(_>0)_-=360;break;default:if(_>180)_-=360;else if(_<-180)_+=360;break}return((J+_*Z)%360+360)%360}function sq(q,Q,Z,$){let J=[...q].sort((H,A)=>H.position-A.position),j=Q*100;if(J.length===0)return"#888888";if(j<=J[0].position)return J[0].color;if(j>=J[J.length-1].position)return J[J.length-1].color;let _=0;while(_<J.length-1&&J[_+1].position<j)_++;let W=J[_],N=J[_+1],K=N.position-W.position,G=K>0?(j-W.position)/K:0,U=i(W.color),X=i(N.color),z,B,L,k=Z||"oklab";if(k==="srgb-linear"){let H=p(U.r),A=p(U.g),R=p(U.b),D=p(X.r),I=p(X.g),S=p(X.b);z=l(H+(D-H)*G),B=l(A+(I-A)*G),L=l(R+(S-R)*G)}else if(k==="oklch"){let H=n(U.r,U.g,U.b),A=n(X.r,X.g,X.b),R=R0(H.l,H.a,H.b),D=R0(A.l,A.a,A.b),I=R.l+(D.l-R.l)*G,S=R.c+(D.c-R.c)*G,w=V0(R.h,D.h,G,$||"shorter"),y=dq(I,S,w),g=S0(y.l,y.a,y.b);z=g.r,B=g.g,L=g.b}else if(k==="hsl"){let H=L0(U.r,U.g,U.b),A=L0(X.r,X.g,X.b),R=V0(H.h,A.h,G,$||"shorter"),D=H.s+(A.s-H.s)*G,I=H.l+(A.l-H.l)*G,S=oq(R,D,I);z=S[0],B=S[1],L=S[2]}else if(k==="srgb")z=Math.round(U.r+(X.r-U.r)*G),B=Math.round(U.g+(X.g-U.g)*G),L=Math.round(U.b+(X.b-U.b)*G);else{let H=n(U.r,U.g,U.b),A=n(X.r,X.g,X.b),R=H.l+(A.l-H.l)*G,D=H.a+(A.a-H.a)*G,I=H.b+(A.b-H.b)*G,S=S0(R,D,I);z=S.r,B=S.g,L=S.b}return`#${z.toString(16).padStart(2,"0")}${B.toString(16).padStart(2,"0")}${L.toString(16).padStart(2,"0")}`.toUpperCase()}function L0(q,Q,Z){let $=q/255,J=Q/255,j=Z/255,_=Math.max($,J,j),W=Math.min($,J,j),N=(_+W)/2;if(_===W)return{h:0,s:0,l:N*100};let K=_-W,G=N>0.5?K/(2-_-W):K/(_+W),U;switch(_){case $:U=((J-j)/K+(J<j?6:0))/6;break;case J:U=((j-$)/K+2)/6;break;default:U=(($-J)/K+4)/6;break}return{h:U*360,s:G*100,l:N*100}}function oq(q,Q,Z){Q/=100,Z/=100;let $=(1-Math.abs(2*Z-1))*Q,J=$*(1-Math.abs(q/60%2-1)),j=Z-$/2,_,W,N;if(q<60)_=$,W=J,N=0;else if(q<120)_=J,W=$,N=0;else if(q<180)_=0,W=$,N=J;else if(q<240)_=0,W=J,N=$;else if(q<300)_=J,W=0,N=$;else _=$,W=0,N=J;return[Math.round((_+j)*255),Math.round((W+j)*255),Math.round((N+j)*255)]}class n0 extends HTMLElement{#Q="solid";#q;#Z;#$;#J={color:"#D9D9D9",alpha:1};#j={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",opacity:1,stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#N={url:null,scaleMode:"fill",scale:50,opacity:1};#_={url:null,scaleMode:"fill",opacity:1};#W={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","alpha","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#X(),this.#M()}disconnectedCallback(){this.#q=null,this.#Z=null,this.#$=null}#X(){let q=this.getAttribute("value");if(!q)return;try{let Q=JSON.parse(q);if(Q.type)this.#Q=Q.type;switch(this.#Q){case"solid":if(Q.color)this.#J.color=Q.color;if(Q.alpha!==void 0)this.#J.alpha=Q.alpha;if(Q.opacity!==void 0)this.#J.alpha=Q.opacity/100;break;case"gradient":if(Q.gradient)this.#j=Z0({...this.#j,...Q.gradient}),this.#j.opacity=this.#U(Q.gradient.opacity??Q.opacity??Q.alpha,this.#j.opacity??1);else if(Q.opacity!==void 0||Q.alpha!==void 0)this.#j.opacity=this.#U(Q.opacity??Q.alpha,this.#j.opacity??1);break;case"image":if(Q.image)this.#N={...this.#N,...Q.image};break;case"video":if(Q.video)this.#_={...this.#_,...Q.video};break;case"webcam":if(Q.webcam)this.#W={...this.#W,...Q.webcam};if(Q.opacity!==void 0)this.#W.opacity=Q.opacity;break}}catch(Q){if(q.startsWith("#")){if(this.#Q="solid",this.#J.color=q.slice(0,7),q.length>7){let Z=q.slice(7,9);this.#J.alpha=parseInt(Z,16)/255}}}}#G(){let q={},Q=this.getAttribute("mode");if(Q)q.mode=Q;let Z=this.getAttribute("alpha");if(Z)q.alpha=Z;for(let{name:$,value:J}of this.attributes)if($.startsWith("picker-")&&$!=="picker-anchor"&&$!=="picker-experimental")q[$.slice(7)]=J;if(!q["dialog-position"])q["dialog-position"]="left";return Object.entries(q).map(([$,J])=>`${$}="${b(J)}"`).join(" ")}#K(){switch(this.#Q){case"solid":return this.#J.color;case"gradient":{let Q=[...this.#j.stops].sort(($,J)=>$.position-J.position).map(($)=>{let J=($.opacity??100)/100;if(J>=1)return`${$.color} ${$.position}%`;let{r:j,g:_,b:W}=i($.color);return`rgba(${j}, ${_}, ${W}, ${J}) ${$.position}%`}).join(", "),Z=a0(this.#j);return`linear-gradient(${this.#j.angle}deg${Z?` ${Z}`:""}, ${Q})`}case"image":return this.#N.url?`url(${this.#N.url})`:"#D9D9D9";default:return"#D9D9D9"}}#U(q,Q=1){if(q===void 0||q===null||q==="")return Q;let Z=Number(q);if(!Number.isFinite(Z))return Q;if(Z>1)return Math.max(0,Math.min(1,Z/100));return Math.max(0,Math.min(1,Z))}#Y(){switch(this.#Q){case"solid":return this.#J.alpha;case"gradient":return this.#j.opacity??1;case"image":return this.#N.opacity??1;case"video":return this.#_.opacity??1;case"webcam":return this.#W.opacity??1;default:return 1}}#R(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.setAttribute("aria-disabled",q?"true":"false");for(let Q of[this.#q,this.#Z,this.#$]){if(!Q)continue;if(q)Q.setAttribute("disabled","");else Q.removeAttribute("disabled")}}#z(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#R();let q=this.getAttribute("aria-label")||"Fill",Q=this.getAttribute("aria-describedby"),Z=this.getAttribute("aria-invalid"),$=this.getAttribute("aria-required"),J=(j,_)=>{if(!j)return;if(j.setAttribute("aria-label",_),Q)j.setAttribute("aria-describedby",Q);else j.removeAttribute("aria-describedby");if(Z)j.setAttribute("aria-invalid",Z);else j.removeAttribute("aria-invalid");if($)j.setAttribute("aria-required",$);else j.removeAttribute("aria-required")};J(this.#q,`${q} picker`),J(this.#$,`${q} hex color`),J(this.#Z,`${q} opacity`)}#M(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Q=JSON.stringify(this.value),Z=this.getAttribute("alpha")!=="false",$=(_)=>Z?`<fig-tooltip text="Opacity">
|
|
78
|
+
</div>`}else $=`<fig-swatch background="${this.hexOpaque}" alpha="${this.rgba.a}"${Z}></fig-swatch>`;if(this.innerHTML=$,this.#q=this.querySelector("fig-swatch"),this.#Z=this.querySelector("fig-fill-picker"),this.#$=this.querySelector("fig-input-text:not([type=number])"),this.#J=this.querySelector("fig-input-number"),this.#b(),this.#$){let j=this.rgbAlphaToHex(this.rgba,1);if(this.#$.value=j.slice(1).toUpperCase(),this.#q)this.#q.background=j}this.#T()}#B(){if(!this.#Z)return;for(let[q,Q]of Object.entries(this.#M()))this.#Z.setAttribute(q,Q);if(this.#Z.setAttribute("mode","solid"),this.getAttribute("alpha")!=="false")this.#Z.removeAttribute("alpha");else this.#Z.setAttribute("alpha","false");if(T(this,"disabled"))this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled");this.#Z.anchorElement=this,this.#Z.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Q}))}#k(){if(!o())return null;if(this.#Z?.isConnected)return this.#B(),this.#Z;let q=document.createElement("fig-fill-picker");return q.innerHTML="<span hidden></span>",q.addEventListener("input",this.#z),q.addEventListener("change",this.#Y),this.appendChild(q),this.#Z=q,this.#B(),q}#P(){if(T(this,"disabled")||T(this,"swatch-disabled"))return!1;let q=this.#k();if(!q)return!1;return requestAnimationFrame(()=>q.open?.()),!0}#S(q){q.preventDefault(),q.stopPropagation(),q.stopImmediatePropagation?.()}#V(q){if(!o())return;if(T(this,"disabled")||T(this,"swatch-disabled"))return;if(this.#N=!0,this.#j=!0,this.#_)clearTimeout(this.#_);this.#_=setTimeout(()=>{this.#j=!1,this.#N=!1,this.#_=null},500),this.#S(q)}#F(q){if(!this.#j)return;if(this.#j=!1,this.#_)clearTimeout(this.#_),this.#_=null;if(this.#S(q),this.#N)this.#N=!1,this.#P()}#I(q){if(q.key!=="Enter"&&q.key!==" ")return;if(!o())return;if(!this.#P())return;this.#S(q)}#D(q){let Q=typeof q==="string"&&q.trim()?q.trim():"#D9D9D9",Z=this.convertToRGBA(Q);if(!Z||!Number.isFinite(Z.r)||!Number.isFinite(Z.g)||!Number.isFinite(Z.b)||!Number.isFinite(Z.a))Q="#D9D9D9",Z={r:217,g:217,b:217,a:1};this.rgba=Z,this.value=this.rgbAlphaToHex({r:isNaN(this.rgba.r)?0:this.rgba.r,g:isNaN(this.rgba.g)?0:this.rgba.g,b:isNaN(this.rgba.b)?0:this.rgba.b},this.rgba.a),this.hexWithAlpha=this.value.toUpperCase(),this.hexOpaque=this.hexWithAlpha.slice(0,7),this.#Q=Q.length>7?(this.rgba.a*100).toFixed(0):100,this.style.setProperty("--alpha",this.rgba.a)}#C(q){q.stopPropagation();let Q=q.target.value.replace(/#/g,"");if(this.#D("#"+Q),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",this.#Q);if(this.#q)this.#q.setAttribute("background",this.hexOpaque);this.#x()}#w(q){q.stopPropagation();let Q=Number(q.target.value)||0,$=Math.round(Q/100*255).toString(16).padStart(2,"0");if(this.#D(this.hexOpaque+$),this.#q)this.#q.setAttribute("alpha",this.rgba.a);if(this.#Z)this.#Z.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Q}));this.#x()}#y(q){q.stopPropagation(),this.#h()}focus(){if(this.#$){this.#$.focus();return}this.#q?.focus()}#m(){return this.getAttribute("aria-label")||"Color"}#b(){if(!this.hasAttribute("role"))this.setAttribute("role","group");if(this.#r)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");let q=this.getAttribute("aria-describedby"),Q=this.getAttribute("aria-invalid"),Z=this.getAttribute("aria-required"),$=this.getAttribute("aria-labelledby"),J=this.#m();if(this.#$){if(this.#$.setAttribute("aria-label",`${J} hex color`),q)this.#$.setAttribute("aria-describedby",q);else this.#$.removeAttribute("aria-describedby");if(Q)this.#$.setAttribute("aria-invalid",Q);else this.#$.removeAttribute("aria-invalid");if(Z)this.#$.setAttribute("aria-required",Z);else this.#$.removeAttribute("aria-required")}if(this.#J){if(this.#J.setAttribute("aria-label",`${J} opacity`),q)this.#J.setAttribute("aria-describedby",q);else this.#J.removeAttribute("aria-describedby");if(Q)this.#J.setAttribute("aria-invalid",Q);else this.#J.removeAttribute("aria-invalid");if(Z)this.#J.setAttribute("aria-required",Z);else this.#J.removeAttribute("aria-required")}if(!this.#$){let j=this.#q?.querySelector('input[type="color"]');if(!j)return;if($)j.setAttribute("aria-labelledby",$),j.removeAttribute("aria-label");else j.setAttribute("aria-label",J),j.removeAttribute("aria-labelledby");if(q)j.setAttribute("aria-describedby",q);else j.removeAttribute("aria-describedby")}}#E(q){if(q.stopPropagation(),this.#D(q.target.value),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#x()}#v(q){q.stopPropagation();let Q=q.detail;if(Q&&Q.color){let Z=Q.color;if(Q.alpha!==void 0){let $=Math.round(Q.alpha*255).toString(16).padStart(2,"0");Z=Q.color+$}if(this.#D(Z),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#J&&Q.alpha!==void 0)this.#J.setAttribute("value",Math.round(Q.alpha*100));if(this.#q)this.#q.setAttribute("background",this.hexOpaque),this.#q.setAttribute("alpha",this.rgba.a);this.#x()}}#x(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:this.#g()}))}#h(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:this.#g()}))}#g(){return{value:this.value,hex:this.hex,rgba:this.rgba,...r(this.hexOpaque,this.rgba?.a,Math.round((this.rgba?.a??1)*100))}}static get observedAttributes(){return["value","style","mode","alpha","text","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"]}get mode(){return this.getAttribute("mode")}set mode(q){this.setAttribute("mode",q)}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"value":if(this.#D(Z),this.#$)this.#$.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#q)this.#q.setAttribute("background",this.hexOpaque),this.#q.setAttribute("alpha",this.rgba.a);if(this.#Z)this.#Z.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#Q}));if(this.#J)this.#J.setAttribute("value",this.#Q);break;case"mode":this.#B();break;case"alpha":case"text":if(this.isConnected)this.#A();break;case"disabled":this.#l();break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#b();break}}get#r(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#l(){let q=this.#r;for(let Q of[this.#q,this.#$,this.#J]){if(!Q)continue;if(q)Q.setAttribute("disabled","");else Q.removeAttribute("disabled")}if(this.#b(),this.#Z)this.#B()}rgbAlphaToHex({r:q,g:Q,b:Z},$=1){q=Math.max(0,Math.min(255,Math.round(q))),Q=Math.max(0,Math.min(255,Math.round(Q))),Z=Math.max(0,Math.min(255,Math.round(Z))),$=Math.max(0,Math.min(1,$));let J=q.toString(16).padStart(2,"0"),j=Q.toString(16).padStart(2,"0"),_=Z.toString(16).padStart(2,"0");if($===1)return`#${J}${j}${_}`.toUpperCase();let N=Math.round($*255).toString(16).padStart(2,"0");return`#${J}${j}${_}${N}`.toUpperCase()}convertToRGBA(q){if(typeof q!=="string")return null;let Q,Z,$,J=1;if(q.startsWith("#")){let j=q.slice(1);if(j.length===8)J=parseInt(j.slice(6),16)/255,j=j.slice(0,6);Q=parseInt(j.slice(0,2),16),Z=parseInt(j.slice(2,4),16),$=parseInt(j.slice(4,6),16)}else if(q.startsWith("rgba")||q.startsWith("rgb")){let j=q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(j)Q=parseInt(j[1]),Z=parseInt(j[2]),$=parseInt(j[3]),J=j[4]?parseFloat(j[4]):1}else if(q.startsWith("hsla")||q.startsWith("hsl")){let j=q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(j){let _=parseInt(j[1])/360,W=parseInt(j[2])/100,N=parseInt(j[3])/100;if(J=j[4]?parseFloat(j[4]):1,W===0)Q=Z=$=N;else{let K=(X,z,B)=>{if(B<0)B+=1;if(B>1)B-=1;if(B<0.16666666666666666)return X+(z-X)*6*B;if(B<0.5)return z;if(B<0.6666666666666666)return X+(z-X)*(0.6666666666666666-B)*6;return X},G=N<0.5?N*(1+W):N+W-N*W,U=2*N-G;Q=K(U,G,_+0.3333333333333333),Z=K(U,G,_),$=K(U,G,_-0.3333333333333333)}Q=Math.round(Q*255),Z=Math.round(Z*255),$=Math.round($*255)}}else return null;return{r:Q,g:Z,b:$,a:J}}}O("fig-input-color",r0);var cq=["srgb","srgb-linear","display-p3","oklab","oklch","hsl"],pq=["shorter","longer","increasing","decreasing"],l0=new Set(["oklch","hsl"]);function Z0(q){let Q={...q??{}},Z=String(Q.interpolationSpace??"srgb").toLowerCase();if(!cq.includes(Z))Z="srgb";Q.interpolationSpace=Z;let $=String(Q.hueInterpolation??"shorter").toLowerCase();return Q.hueInterpolation=pq.includes($)?$:"shorter",Q}function t0(q){let Q=Z0(q),Z={...Q,interpolationSpace:Q.interpolationSpace};if(l0.has(Q.interpolationSpace))Z.hueInterpolation=Q.hueInterpolation;else delete Z.hueInterpolation;return Z}function a0(q){let Q=Z0(q);if(Q.interpolationSpace==="srgb")return"";if(l0.has(Q.interpolationSpace))return`in ${Q.interpolationSpace} ${Q.hueInterpolation} hue`;return`in ${Q.interpolationSpace}`}function i(q){let Q=q.replace(/^#/,"");return{r:parseInt(Q.substring(0,2),16),g:parseInt(Q.substring(2,4),16),b:parseInt(Q.substring(4,6),16)}}function p(q){let Q=q/255;return Q<=0.04045?Q/12.92:Math.pow((Q+0.055)/1.055,2.4)}function l(q){let Q=q<=0.0031308?12.92*q:1.055*Math.pow(q,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Q))*255)}function n(q,Q,Z){let $=p(q),J=p(Q),j=p(Z),_=Math.cbrt(0.4122214708*$+0.5363325363*J+0.0514459929*j),W=Math.cbrt(0.2119034982*$+0.6806995451*J+0.1073969566*j),N=Math.cbrt(0.0883024619*$+0.2817188376*J+0.6299787005*j);return{l:0.2104542553*_+0.793617785*W-0.0040720468*N,a:1.9779984951*_-2.428592205*W+0.4505937099*N,b:0.0259040371*_+0.7827717662*W-0.808675766*N}}function S0(q,Q,Z){let $=q+0.3963377774*Q+0.2158037573*Z,J=q-0.1055613458*Q-0.0638541728*Z,j=q-0.0894841775*Q-1.291485548*Z,_=$*$*$,W=J*J*J,N=j*j*j;return{r:l(4.0767416621*_-3.3077115913*W+0.2309699292*N),g:l(-1.2684380046*_+2.6097574011*W-0.3413193965*N),b:l(-0.0041960863*_-0.7034186147*W+1.707614701*N)}}function R0(q,Q,Z){return{l:q,c:Math.sqrt(Q*Q+Z*Z),h:Math.atan2(Z,Q)*180/Math.PI}}function dq(q,Q,Z){let $=Z*Math.PI/180;return{l:q,a:Q*Math.cos($),b:Q*Math.sin($)}}function V0(q,Q,Z,$){let J=(q%360+360)%360,_=(Q%360+360)%360-J;switch($){case"longer":if(_>0&&_<180)_-=360;else if(_<0&&_>-180)_+=360;else if(_===0)_=0;break;case"increasing":if(_<0)_+=360;break;case"decreasing":if(_>0)_-=360;break;default:if(_>180)_-=360;else if(_<-180)_+=360;break}return((J+_*Z)%360+360)%360}function sq(q,Q,Z,$){let J=[...q].sort((H,A)=>H.position-A.position),j=Q*100;if(J.length===0)return"#888888";if(j<=J[0].position)return J[0].color;if(j>=J[J.length-1].position)return J[J.length-1].color;let _=0;while(_<J.length-1&&J[_+1].position<j)_++;let W=J[_],N=J[_+1],K=N.position-W.position,G=K>0?(j-W.position)/K:0,U=i(W.color),X=i(N.color),z,B,L,k=Z||"oklab";if(k==="srgb-linear"){let H=p(U.r),A=p(U.g),R=p(U.b),D=p(X.r),I=p(X.g),S=p(X.b);z=l(H+(D-H)*G),B=l(A+(I-A)*G),L=l(R+(S-R)*G)}else if(k==="oklch"){let H=n(U.r,U.g,U.b),A=n(X.r,X.g,X.b),R=R0(H.l,H.a,H.b),D=R0(A.l,A.a,A.b),I=R.l+(D.l-R.l)*G,S=R.c+(D.c-R.c)*G,w=V0(R.h,D.h,G,$||"shorter"),y=dq(I,S,w),g=S0(y.l,y.a,y.b);z=g.r,B=g.g,L=g.b}else if(k==="hsl"){let H=L0(U.r,U.g,U.b),A=L0(X.r,X.g,X.b),R=V0(H.h,A.h,G,$||"shorter"),D=H.s+(A.s-H.s)*G,I=H.l+(A.l-H.l)*G,S=oq(R,D,I);z=S[0],B=S[1],L=S[2]}else if(k==="srgb")z=Math.round(U.r+(X.r-U.r)*G),B=Math.round(U.g+(X.g-U.g)*G),L=Math.round(U.b+(X.b-U.b)*G);else{let H=n(U.r,U.g,U.b),A=n(X.r,X.g,X.b),R=H.l+(A.l-H.l)*G,D=H.a+(A.a-H.a)*G,I=H.b+(A.b-H.b)*G,S=S0(R,D,I);z=S.r,B=S.g,L=S.b}return`#${z.toString(16).padStart(2,"0")}${B.toString(16).padStart(2,"0")}${L.toString(16).padStart(2,"0")}`.toUpperCase()}function L0(q,Q,Z){let $=q/255,J=Q/255,j=Z/255,_=Math.max($,J,j),W=Math.min($,J,j),N=(_+W)/2;if(_===W)return{h:0,s:0,l:N*100};let K=_-W,G=N>0.5?K/(2-_-W):K/(_+W),U;switch(_){case $:U=((J-j)/K+(J<j?6:0))/6;break;case J:U=((j-$)/K+2)/6;break;default:U=(($-J)/K+4)/6;break}return{h:U*360,s:G*100,l:N*100}}function oq(q,Q,Z){Q/=100,Z/=100;let $=(1-Math.abs(2*Z-1))*Q,J=$*(1-Math.abs(q/60%2-1)),j=Z-$/2,_,W,N;if(q<60)_=$,W=J,N=0;else if(q<120)_=J,W=$,N=0;else if(q<180)_=0,W=$,N=J;else if(q<240)_=0,W=J,N=$;else if(q<300)_=J,W=0,N=$;else _=$,W=0,N=J;return[Math.round((_+j)*255),Math.round((W+j)*255),Math.round((N+j)*255)]}class n0 extends HTMLElement{#Q="solid";#q;#Z;#$;#J={color:"#D9D9D9",alpha:1};#j={type:"linear",angle:180,interpolationSpace:"srgb",hueInterpolation:"shorter",opacity:1,stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#N={url:null,scaleMode:"fill",scale:50,opacity:1};#_={url:null,scaleMode:"fill",opacity:1};#W={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","alpha","aria-label","aria-describedby","aria-invalid","aria-required"]}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#X(),this.#M()}disconnectedCallback(){this.#q=null,this.#Z=null,this.#$=null}#X(){let q=this.getAttribute("value");if(!q)return;try{let Q=JSON.parse(q);if(Q.type)this.#Q=Q.type;switch(this.#Q){case"solid":if(Q.color)this.#J.color=Q.color;if(Q.alpha!==void 0)this.#J.alpha=Q.alpha;if(Q.opacity!==void 0)this.#J.alpha=Q.opacity/100;break;case"gradient":if(Q.gradient)this.#j=Z0({...this.#j,...Q.gradient}),this.#j.opacity=this.#G(Q.gradient.opacity??Q.opacity??Q.alpha,this.#j.opacity??1);else if(Q.opacity!==void 0||Q.alpha!==void 0)this.#j.opacity=this.#G(Q.opacity??Q.alpha,this.#j.opacity??1);break;case"image":if(Q.image)this.#N={...this.#N,...Q.image};break;case"video":if(Q.video)this.#_={...this.#_,...Q.video};break;case"webcam":if(Q.webcam)this.#W={...this.#W,...Q.webcam};if(Q.opacity!==void 0)this.#W.opacity=Q.opacity;break}}catch(Q){if(q.startsWith("#")){if(this.#Q="solid",this.#J.color=q.slice(0,7),q.length>7){let Z=q.slice(7,9);this.#J.alpha=parseInt(Z,16)/255}}}}#U(){let q={},Q=this.getAttribute("mode");if(Q)q.mode=Q;let Z=this.getAttribute("alpha");if(Z)q.alpha=Z;for(let{name:$,value:J}of this.attributes)if($.startsWith("picker-")&&$!=="picker-anchor"&&$!=="picker-experimental")q[$.slice(7)]=J;if(!q["dialog-position"])q["dialog-position"]="left";return Object.entries(q).map(([$,J])=>`${$}="${b(J)}"`).join(" ")}#K(){switch(this.#Q){case"solid":return this.#J.color;case"gradient":{let Q=[...this.#j.stops].sort(($,J)=>$.position-J.position).map(($)=>{let J=($.opacity??100)/100;if(J>=1)return`${$.color} ${$.position}%`;let{r:j,g:_,b:W}=i($.color);return`rgba(${j}, ${_}, ${W}, ${J}) ${$.position}%`}).join(", "),Z=a0(this.#j);return`linear-gradient(${this.#j.angle}deg${Z?` ${Z}`:""}, ${Q})`}case"image":return this.#N.url?`url(${this.#N.url})`:"#D9D9D9";default:return"#D9D9D9"}}#G(q,Q=1){if(q===void 0||q===null||q==="")return Q;let Z=Number(q);if(!Number.isFinite(Z))return Q;if(Z>1)return Math.max(0,Math.min(1,Z/100));return Math.max(0,Math.min(1,Z))}#Y(){switch(this.#Q){case"solid":return this.#J.alpha;case"gradient":return this.#j.opacity??1;case"image":return this.#N.opacity??1;case"video":return this.#_.opacity??1;case"webcam":return this.#W.opacity??1;default:return 1}}#R(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.setAttribute("aria-disabled",q?"true":"false");for(let Q of[this.#q,this.#Z,this.#$]){if(!Q)continue;if(q)Q.setAttribute("disabled","");else Q.removeAttribute("disabled")}}#z(){if(!this.hasAttribute("role"))this.setAttribute("role","group");this.#R();let q=this.getAttribute("aria-label")||"Fill",Q=this.getAttribute("aria-describedby"),Z=this.getAttribute("aria-invalid"),$=this.getAttribute("aria-required"),J=(j,_)=>{if(!j)return;if(j.setAttribute("aria-label",_),Q)j.setAttribute("aria-describedby",Q);else j.removeAttribute("aria-describedby");if(Z)j.setAttribute("aria-invalid",Z);else j.removeAttribute("aria-invalid");if($)j.setAttribute("aria-required",$);else j.removeAttribute("aria-required")};J(this.#q,`${q} picker`),J(this.#$,`${q} hex color`),J(this.#Z,`${q} opacity`)}#M(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Q=JSON.stringify(this.value),Z=this.getAttribute("alpha")!=="false",$=(_)=>Z?`<fig-tooltip text="Opacity">
|
|
79
79
|
<fig-input-number
|
|
80
80
|
class="fig-input-fill-opacity"
|
|
81
81
|
placeholder="##"
|
|
@@ -101,13 +101,13 @@ var wq=(q,Q)=>()=>(q&&(Q=q(q=0)),Q);var yq={};var D0=wq(()=>{/*! Vendored from @
|
|
|
101
101
|
<label class="fig-input-fill-label">Video</label>
|
|
102
102
|
${$(Math.round((this.#_.opacity??1)*100))}`;break;case"webcam":J=`
|
|
103
103
|
<label class="fig-input-fill-label">Webcam</label>
|
|
104
|
-
${$(Math.round((this.#W.opacity??1)*100))}`;break}let j=this.#
|
|
104
|
+
${$(Math.round((this.#W.opacity??1)*100))}`;break}let j=this.#U();this.innerHTML=`
|
|
105
105
|
<div class="input-combo">
|
|
106
106
|
<fig-fill-picker ${j} value='${b(Q)}' ${q?"disabled":""}>
|
|
107
107
|
<fig-swatch background="${b(this.#K())}" alpha="${this.#Y()}"${q?" disabled":""}></fig-swatch>
|
|
108
108
|
</fig-fill-picker>
|
|
109
109
|
${J}
|
|
110
|
-
</div>`,this.#L()}#L(){this.#q=this.querySelector("fig-fill-picker"),this.#Z=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let q=this.querySelector(".fig-input-fill-label");if(this.#z(),q&&this.#q)q.addEventListener("click",()=>{let Q=this.#q.querySelector("fig-swatch");if(Q)Q.click()});if(this.#q){let Q=this.getAttribute("picker-anchor");if(!Q||Q==="self")this.#q.anchorElement=this;else{let Z=null;try{Z=document.querySelector(Q)}catch{}if(Z)this.#q.anchorElement=Z}this.#q.addEventListener("input",(Z)=>{Z.stopPropagation();let $=Z.detail;if(!$)return;let J=$.type,j=J!==this.#Q;switch(this.#Q=J,J){case"solid":this.#J.color=$.color,this.#J.alpha=$.alpha;break;case"gradient":if($.gradient)this.#j=Z0({...this.#j,...$.gradient});break;case"image":if($.image)this.#N=$.image;break;case"video":if($.video)this.#_=$.video;break}if(j)this.#H();else this.#
|
|
110
|
+
</div>`,this.#L()}#L(){this.#q=this.querySelector("fig-fill-picker"),this.#Z=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let q=this.querySelector(".fig-input-fill-label");if(this.#z(),q&&this.#q)q.addEventListener("click",()=>{let Q=this.#q.querySelector("fig-swatch");if(Q)Q.click()});if(this.#q){let Q=this.getAttribute("picker-anchor");if(!Q||Q==="self")this.#q.anchorElement=this;else{let Z=null;try{Z=document.querySelector(Q)}catch{}if(Z)this.#q.anchorElement=Z}this.#q.addEventListener("input",(Z)=>{Z.stopPropagation();let $=Z.detail;if(!$)return;let J=$.type,j=J!==this.#Q;switch(this.#Q=J,J){case"solid":this.#J.color=$.color,this.#J.alpha=$.alpha;break;case"gradient":if($.gradient)this.#j=Z0({...this.#j,...$.gradient});break;case"image":if($.image)this.#N=$.image;break;case"video":if($.video)this.#_=$.video;break}if(j)this.#H();else this.#O();this.#A()}),this.#q.addEventListener("change",(Z)=>{Z.stopPropagation(),this.#B()})}if(this.#$)this.#$.addEventListener("input",(Q)=>{Q.stopPropagation();let Z="#"+Q.target.value.replace("#","");this.#J.color=Z,this.#f(),this.#A()}),this.#$.addEventListener("change",(Q)=>{Q.stopPropagation(),this.#B()});if(this.#Z)this.#Z.addEventListener("input",(Q)=>{Q.stopPropagation();let Z=parseFloat(Q.target.value),J=(isNaN(Z)?100:Z)/100;switch(this.#Q){case"solid":this.#J.alpha=J;break;case"gradient":this.#j.opacity=J;break;case"image":this.#N.opacity=J;break;case"video":this.#_.opacity=J;break;case"webcam":this.#W.opacity=J;break}this.#f(),this.#T(J),this.#A()}),this.#Z.addEventListener("change",(Q)=>{Q.stopPropagation(),this.#B()})}#O(){switch(this.#Q){case"solid":if(this.#$)this.#$.setAttribute("value",this.#J.color.slice(1).toUpperCase());if(this.#Z)this.#Z.setAttribute("value",Math.round(this.#J.alpha*100));break;case"gradient":{let q=this.querySelector(".fig-input-fill-label");if(q){let Q=this.#j.type.charAt(0).toUpperCase()+this.#j.type.slice(1);q.textContent=Q}if(this.#Z)this.#Z.setAttribute("value",Math.round((this.#j.opacity??1)*100));break}case"image":if(this.#Z)this.#Z.setAttribute("value",Math.round((this.#N.opacity??1)*100));break;case"video":if(this.#Z)this.#Z.setAttribute("value",Math.round((this.#_.opacity??1)*100));break;case"webcam":if(this.#Z)this.#Z.setAttribute("value",Math.round((this.#W.opacity??1)*100));break}}#H(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Q=this.getAttribute("alpha")!=="false",Z=this.querySelector(".input-combo");if(!Z)return;let $=Z.querySelector(".fig-input-fill-label"),J=Z.querySelector(".fig-input-fill-hex"),j=Z.querySelector(".fig-input-fill-opacity"),_=Z.querySelectorAll("fig-tooltip");$?.remove(),J?.remove(),_.forEach((K)=>K.remove());let W="";switch(this.#Q){case"solid":W=`
|
|
111
111
|
<fig-input-text
|
|
112
112
|
type="text"
|
|
113
113
|
class="fig-input-fill-hex"
|
|
@@ -173,12 +173,12 @@ var wq=(q,Q)=>()=>(q&&(Q=q(q=0)),Q);var yq={};var D0=wq(()=>{/*! Vendored from @
|
|
|
173
173
|
units="%"
|
|
174
174
|
${q?"disabled":""}>
|
|
175
175
|
</fig-input-number>
|
|
176
|
-
</fig-tooltip>`:""}`;break}Z.insertAdjacentHTML("beforeend",W),this.#Z=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let N=this.querySelector(".fig-input-fill-label");if(this.#z(),N&&this.#q)N.addEventListener("click",()=>{let K=this.#q.querySelector("fig-swatch");if(K)K.click()});if(this.#$)this.#$.addEventListener("input",(K)=>{K.stopPropagation();let G="#"+K.target.value.replace("#","");this.#J.color=G,this.#k(),this.#A()}),this.#$.addEventListener("change",(K)=>{K.stopPropagation(),this.#O()});if(this.#Z)this.#Z.addEventListener("input",(K)=>{K.stopPropagation();let G=parseFloat(K.target.value),X=(isNaN(G)?100:G)/100;switch(this.#Q){case"solid":this.#J.alpha=X;break;case"gradient":this.#j.opacity=X;break;case"image":this.#N.opacity=X;break;case"video":this.#_.opacity=X;break;case"webcam":this.#W.opacity=X;break}this.#k(),this.#T(X),this.#A()}),this.#Z.addEventListener("change",(K)=>{K.stopPropagation(),this.#O()})}#k(){if(this.#q)this.#q.setAttribute("value",JSON.stringify(this.value))}#T(q){if(this.#q){let Q=this.#q.querySelector("fig-swatch");if(Q)Q.setAttribute("alpha",q)}}#A(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#O(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#Q){case"solid":return{type:"solid",color:this.#J.color,alpha:this.#J.alpha,opacity:Math.round(this.#J.alpha*100)};case"gradient":return{type:"gradient",gradient:t0(this.#j)};case"image":return{type:"image",image:{...this.#N}};case"video":return{type:"video",video:{...this.#_}};case"webcam":return{type:"webcam",webcam:{...this.#W}};default:return{type:this.#Q}}}set value(q){if(typeof q==="string")this.setAttribute("value",q);else this.setAttribute("value",JSON.stringify(q))}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"value":let $=this.#Q;if(this.#X(),this.#q)if(this.#Q!==$)this.#M();else this.#k(),this.#B();break;case"disabled":this.#R();break;case"mode":if(this.#q)if(Z)this.#q.setAttribute(q,Z);else this.#q.removeAttribute(q);break;case"alpha":if(this.isConnected)this.#M();break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#z();break}}}O("fig-input-fill",n0);class e0 extends HTMLElement{#Q=[];#q=[];#Z=[];#$=null;#J=this.#X.bind(this);#j=()=>this.focus();static get observedAttributes(){return["value","disabled","min","max","open","fixed"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(q){let Q=this.open;if(q)this.setAttribute("open","");else this.removeAttribute("open");if(Q!==!!q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!q},bubbles:!0}))}get#N(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#_(){let q=parseInt(this.getAttribute("min"));return isNaN(q)?2:q}get#W(){let q=parseInt(this.getAttribute("max"));return isNaN(q)?8:q}connectedCallback(){if(this.setAttribute("tabindex","-1"),this.removeEventListener("focus",this.#j),this.addEventListener("focus",this.#j),this.removeEventListener("keydown",this.#J),this.addEventListener("keydown",this.#J),this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{if(this.#$=null,!this.isConnected)return;this.#G(),this.#K()})}disconnectedCallback(){if(this.#$)cancelAnimationFrame(this.#$),this.#$=null;this.removeEventListener("keydown",this.#J),this.removeEventListener("focus",this.#j),this.#q=[],this.#Z=[]}#X(q){if(q.key!=="Enter"&&q.key!==" ")return;if(q.target!==this.querySelector(".palette-colors-inline"))return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;q.preventDefault(),q.stopPropagation(),this.open=!0,this.querySelector(".palette-colors-inline")?.setAttribute("aria-expanded","true")}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"value":this.#G(),this.#B();break;case"disabled":this.#H();break;case"min":case"max":case"fixed":this.#K();break;case"open":this.#k();break}}#G(){let q=this.getAttribute("value");if(!q){this.#Q=[];return}let Q=q.trim();try{let Z=JSON.parse(Q);if(Array.isArray(Z)){this.#Q=Z.map(($)=>{if(typeof $==="string")return{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1};if($&&typeof $==="object")return{color:$.color||"#D9D9D9",alpha:$.alpha!==void 0?$.alpha:$.opacity!==void 0?$.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch(Z){}if(Q.includes(",")){this.#Q=Q.split(",").map((Z)=>{let $=Z.trim();return{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1}});return}if(Q.startsWith("#")){this.#Q=[{color:Q.slice(0,7),alpha:Q.length>7?parseInt(Q.slice(7,9),16)/255:1}];return}this.#Q=[]}get value(){return this.#Q.map((q)=>({...q}))}set value(q){if(typeof q==="string")this.setAttribute("value",q);else this.setAttribute("value",JSON.stringify(q))}#K(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#q=[],this.#Z=[];let Q=document.createElement("div");Q.className="palette-colors-inline",Q.setAttribute("role","button"),Q.setAttribute("tabindex",q?"-1":"+0"),Q.setAttribute("aria-expanded",String(this.open)),Q.setAttribute("aria-label","Edit palette colors"),Q.addEventListener("blur",()=>{Q.style.removeProperty("outline"),Q.style.removeProperty("outline-offset")});let Z=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0,Q.setAttribute("aria-expanded","true")};Q.addEventListener("click",Z);let $=document.createElement("div");if($.className="palette-colors",this.#Q.forEach((j,_)=>{$.appendChild(this.#U(j,_,q,{inline:!0}))}),Q.appendChild($),this.appendChild(Q),this.#k(),!this.#N)this.#z(q,this);let J=document.createElement("div");J.className="palette-colors-expanded",this.#Q.forEach((j,_)=>{if(J.appendChild(this.#U(j,_,q)),!this.#N)J.appendChild(this.#Y(_,q))}),this.appendChild(J)}#U(q,Q,Z,{inline:$=!1}={}){let J=q.alpha<1?q.color+Math.round(q.alpha*255).toString(16).padStart(2,"0"):q.color,j=document.createElement("fig-input-color");if(j.setAttribute("value",J),$)j.setAttribute("text","false"),j.setAttribute("alpha","true"),j.setAttribute("swatch-disabled","");else j.setAttribute("text","true"),j.setAttribute("alpha","true"),j.setAttribute("full","");if(Z)j.setAttribute("disabled","");let _=$?this.#Z:this.#q,W=(N)=>{N.stopPropagation();let K=N.currentTarget;this.#Q[Q]={color:K.hexOpaque||this.#Q[Q].color,alpha:K.rgba?K.rgba.a:this.#Q[Q].alpha};let G=_[Q];if(G){let U=this.#Q[Q],X=U.alpha<1?U.color+Math.round(U.alpha*255).toString(16).padStart(2,"0"):U.color;G.setAttribute("value",X)}};if(j.addEventListener("input",(N)=>{W(N),this.#A()}),j.addEventListener("change",(N)=>{W(N),this.#O()}),$)this.#q.push(j);else this.#Z.push(j);return j}#Y(q,Q){let Z=document.createElement("fig-button");if(Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Remove color"),Z.className="palette-remove-btn",Q||this.#Q.length<=this.#_)Z.setAttribute("disabled","");Z.appendChild(c("minus")),Z.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#R(q)});let $=document.createElement("fig-tooltip");return $.setAttribute("text","Remove color"),$.appendChild(Z),$}#R(q){if(this.#N)return;if(q<0||q>=this.#Q.length)return;if(this.#Q.length<=this.#_)return;this.#Q.splice(q,1),this.#q=[],this.#Z=[],this.#K(),this.#O()}#z(q,Q=this){let Z=this.#Q.length>=this.#W,$=document.createElement("fig-button");if($.setAttribute("variant","ghost"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Add color"),$.className="palette-add-btn",q||Z)$.setAttribute("disabled","");$.appendChild(c("add")),$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Q.length>=this.#W)return;this.open=!0,this.#M({color:"#D9D9D9",alpha:1})});let J=document.createElement("fig-tooltip");J.setAttribute("text","Add color"),J.appendChild($),Q.appendChild(J)}#M(q){if(this.#N)return;this.#Q.push(q);let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.#Q.length-1,$=this.#U(q,Z,Q,{inline:!0}),J=this.querySelector(".palette-colors");if(J)J.appendChild($);let j=this.#U(q,Z,Q),_=this.querySelector(".palette-colors-expanded");if(_)_.appendChild(j),_.appendChild(this.#Y(Z,Q));if(this.#Q.length>=this.#W){let W=this.querySelector(".palette-add-btn");if(W)W.setAttribute("disabled","")}this.#T(Q),this.#O()}#L(q){let Q=this.#Q[q];if(!Q)return;let Z=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,$=this.#q[q];if($)$.setAttribute("value",Z);let J=this.#Z[q];if(J)J.setAttribute("value",Z)}#B(){if(this.#q.length!==this.#Q.length){this.#K();return}this.#Q.forEach((q,Q)=>{this.#L(Q)})}#H(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#q,...this.#Z].forEach((Z)=>{if(q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")});let Q=this.querySelector(".palette-add-btn");if(Q)if(q||this.#Q.length>=this.#W)Q.setAttribute("disabled","");else Q.removeAttribute("disabled");this.#T(q),this.#k()}#k(){let q=this.querySelector(".palette-colors-inline");if(!q)return;let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";q.setAttribute("tabindex",Q?"-1":"+0"),q.setAttribute("aria-disabled",String(Q)),q.setAttribute("aria-expanded",String(this.open))}focus(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let q=this.querySelector(".palette-colors-inline");if(!q)return;q.style.outline="var(--figma-focus-outline)",q.style.outlineOffset="var(--figma-focus-outline-offset)",q.focus()}#T(q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let Q=q||this.#Q.length<=this.#_;this.querySelectorAll(".palette-remove-btn").forEach((Z)=>{if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")})}#A(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#O(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}O("fig-input-palette",e0);class e extends HTMLElement{static SHIFT_SNAP=5;#Q;#q;#Z=!1;#$=null;#J=null;#j=null;#N=null;#_={type:"linear",angle:90,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode","size"]}get#W(){let q=this.getAttribute("edit");if(q==="false")return"false";if(q==="picker")return"picker";return"true"}get#X(){return this.#W==="true"}get#G(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#K(){if(!this.#q)return null;return this.#q.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#U(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#X?"-1":"0")}#Y(q){let Q=Z0(q);return{...Q,type:["linear","radial","angular"].includes(Q.type)?Q.type:"linear",angle:Number.isFinite(Number(Q.angle))?Number(Q.angle):90,centerX:Number.isFinite(Number(Q.centerX))?Number(Q.centerX):50,centerY:Number.isFinite(Number(Q.centerY))?Number(Q.centerY):50}}connectedCallback(){if(this.#L(),this.#D(),this.#R(),this.removeEventListener("keydown",this.#M),this.addEventListener("keydown",this.#M),this.#X)document.addEventListener("keydown",this.#z)}#R(){if(this.#W!=="picker"||o())return;this.#N??=customElements.whenDefined("fig-fill-picker").then(()=>{if(!this.isConnected||this.#W!=="picker")return;this.#D()})}disconnectedCallback(){if(document.removeEventListener("keydown",this.#z),this.removeEventListener("keydown",this.#M),this.#J)this.#J.disconnect(),this.#J=null;if(this.#j!==null)cancelAnimationFrame(this.#j),this.#j=null;clearTimeout(this.#$),this.removeEventListener("pointerenter",this.#S),this.removeEventListener("pointermove",this.#y),this.removeEventListener("pointerleave",this.#w),this.removeEventListener("click",this.#E),this.removeEventListener("dblclick",this.#b)}#z=(q)=>{let Q=document.activeElement;if(!(Q instanceof Node)||!this.contains(Q))return;let Z=Q&&(Q.tagName==="INPUT"||Q.tagName==="TEXTAREA"||Q.isContentEditable);if(!this.#q)return;if(q.key==="Tab"&&!Z){let j=this.#q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!j)return;q.preventDefault();let _=[...this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],W=_.indexOf(j),N=q.shiftKey?(W-1+_.length)%_.length:(W+1)%_.length;j.deselect(),_[N].select();return}if((q.key==="ArrowLeft"||q.key==="ArrowRight")&&!Z){let j=this.#q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!j)return;let _=parseInt(j.dataset.stopIndex,10);if(isNaN(_)||!this.#_.stops[_])return;q.preventDefault();let W=(q.key==="ArrowRight"?1:-1)*(q.shiftKey?e.SHIFT_SNAP:1),N=this.#_.stops[_];N.position=Math.max(0,Math.min(100,N.position+W)),j.setAttribute("value",`${N.position}% 50%`);let K=j.closest("fig-tooltip");if(K)K.text=`${Math.round(N.position)}%`,K.setAttribute("show","true"),K.showPopup(),j.hideColorTip(),clearTimeout(this.#$),this.#$=setTimeout(()=>{K.removeAttribute("show"),j.showColorTip()},600);this.#u(),this.#c(),this.#i();return}if(q.key!=="Delete"&&q.key!=="Backspace")return;if(Z)return;if(this.#_.stops.length<=2)return;let $=this.#q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!$)return;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])return;q.preventDefault(),$.removeAttribute("selected"),this.#_.stops.splice(J,1),this.#v(),this.#u(),this.#c(),this.#i()};#M=(q)=>{if(this.#W!=="picker")return;if(q.key!=="Enter"&&q.key!==" ")return;if(q.altKey||q.ctrlKey||q.metaKey)return;if(T(this,"disabled"))return;let Q=this.querySelector("fig-fill-picker");if(!Q||typeof Q.open!=="function")return;q.preventDefault(),Q.open()};#L(){let q=this.getAttribute("value");if(!q)return;try{let Q=JSON.parse(q);if(Q?.type==="gradient"&&Q.gradient){this.#_=this.#Y({...this.#_,...Q.gradient});return}if(Q?.gradient)this.#_=this.#Y({...this.#_,...Q.gradient})}catch(Q){}}#B(){let q=this.#Y(this.#_),Z=[...q.stops].sort((j,_)=>j.position-_.position).map((j)=>{let _=(j.opacity??100)/100;if(_>=1)return`${j.color} ${j.position}%`;let{r:W,g:N,b:K}=i(j.color);return`rgba(${W}, ${N}, ${K}, ${_}) ${j.position}%`}).join(", "),$=a0(q);return`linear-gradient(to right${$?` ${$}`:""}, ${Z})`}#H(q){let Q=(q.opacity??100)/100;if(Q>=1)return q.color;let{r:Z,g:$,b:J}=i(q.color);return`rgba(${Z}, ${$}, ${J}, ${Q})`}#k(){let q=this.getAttribute("size");return q?` size="${q}"`:""}#T(){if(!this.#Q)return;let q=this.getAttribute("size");if(q)this.#Q.setAttribute("size",q);else this.#Q.removeAttribute("size")}#A(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Q=this.#G==="tip"?' tip="color"':"";return this.#_.stops.map((Z,$)=>`<fig-tooltip action="manual" text="${Math.round(Z.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${Q} color="${this.#H(Z)}" value="${Z.position}% 50%" hit-area="4" data-stop-index="${$}"${q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#O=null;#f=!1;#D(){this.#J?.disconnect(),this.#J=null;let q=T(this,"disabled"),Q=this.#W;if(Q==="picker"&&o()){let Z=JSON.stringify(this.value);this.innerHTML=`
|
|
176
|
+
</fig-tooltip>`:""}`;break}Z.insertAdjacentHTML("beforeend",W),this.#Z=this.querySelector(".fig-input-fill-opacity"),this.#$=this.querySelector(".fig-input-fill-hex");let N=this.querySelector(".fig-input-fill-label");if(this.#z(),N&&this.#q)N.addEventListener("click",()=>{let K=this.#q.querySelector("fig-swatch");if(K)K.click()});if(this.#$)this.#$.addEventListener("input",(K)=>{K.stopPropagation();let G="#"+K.target.value.replace("#","");this.#J.color=G,this.#f(),this.#A()}),this.#$.addEventListener("change",(K)=>{K.stopPropagation(),this.#B()});if(this.#Z)this.#Z.addEventListener("input",(K)=>{K.stopPropagation();let G=parseFloat(K.target.value),X=(isNaN(G)?100:G)/100;switch(this.#Q){case"solid":this.#J.alpha=X;break;case"gradient":this.#j.opacity=X;break;case"image":this.#N.opacity=X;break;case"video":this.#_.opacity=X;break;case"webcam":this.#W.opacity=X;break}this.#f(),this.#T(X),this.#A()}),this.#Z.addEventListener("change",(K)=>{K.stopPropagation(),this.#B()})}#f(){if(this.#q)this.#q.setAttribute("value",JSON.stringify(this.value))}#T(q){if(this.#q){let Q=this.#q.querySelector("fig-swatch");if(Q)Q.setAttribute("alpha",q)}}#A(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#B(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#Q){case"solid":return{type:"solid",color:this.#J.color,alpha:this.#J.alpha,opacity:Math.round(this.#J.alpha*100)};case"gradient":return{type:"gradient",gradient:t0(this.#j)};case"image":return{type:"image",image:{...this.#N}};case"video":return{type:"video",video:{...this.#_}};case"webcam":return{type:"webcam",webcam:{...this.#W}};default:return{type:this.#Q}}}set value(q){if(typeof q==="string")this.setAttribute("value",q);else this.setAttribute("value",JSON.stringify(q))}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"value":let $=this.#Q;if(this.#X(),this.#q)if(this.#Q!==$)this.#M();else this.#f(),this.#O();break;case"disabled":this.#R();break;case"mode":if(this.#q)if(Z)this.#q.setAttribute(q,Z);else this.#q.removeAttribute(q);break;case"alpha":if(this.isConnected)this.#M();break;case"aria-label":case"aria-describedby":case"aria-invalid":case"aria-required":this.#z();break}}}O("fig-input-fill",n0);class e0 extends HTMLElement{#Q=[];#q=[];#Z=[];#$=null;#J=this.#X.bind(this);#j=()=>this.focus();static get observedAttributes(){return["value","disabled","min","max","open","fixed"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(q){let Q=this.open;if(q)this.setAttribute("open","");else this.removeAttribute("open");if(Q!==!!q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!q},bubbles:!0}))}get#N(){return this.hasAttribute("fixed")&&this.getAttribute("fixed")!=="false"}get#_(){let q=parseInt(this.getAttribute("min"));return isNaN(q)?2:q}get#W(){let q=parseInt(this.getAttribute("max"));return isNaN(q)?8:q}connectedCallback(){if(this.setAttribute("tabindex","-1"),this.removeEventListener("focus",this.#j),this.addEventListener("focus",this.#j),this.removeEventListener("keydown",this.#J),this.addEventListener("keydown",this.#J),this.#$)cancelAnimationFrame(this.#$);this.#$=requestAnimationFrame(()=>{if(this.#$=null,!this.isConnected)return;this.#U(),this.#K()})}disconnectedCallback(){if(this.#$)cancelAnimationFrame(this.#$),this.#$=null;this.removeEventListener("keydown",this.#J),this.removeEventListener("focus",this.#j),this.#q=[],this.#Z=[]}#X(q){if(q.key!=="Enter"&&q.key!==" ")return;if(q.target!==this.querySelector(".palette-colors-inline"))return;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;q.preventDefault(),q.stopPropagation(),this.open=!0,this.querySelector(".palette-colors-inline")?.setAttribute("aria-expanded","true")}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"value":this.#U(),this.#O();break;case"disabled":this.#H();break;case"min":case"max":case"fixed":this.#K();break;case"open":this.#f();break}}#U(){let q=this.getAttribute("value");if(!q){this.#Q=[];return}let Q=q.trim();try{let Z=JSON.parse(Q);if(Array.isArray(Z)){this.#Q=Z.map(($)=>{if(typeof $==="string")return{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1};if($&&typeof $==="object")return{color:$.color||"#D9D9D9",alpha:$.alpha!==void 0?$.alpha:$.opacity!==void 0?$.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch(Z){}if(Q.includes(",")){this.#Q=Q.split(",").map((Z)=>{let $=Z.trim();return{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1}});return}if(Q.startsWith("#")){this.#Q=[{color:Q.slice(0,7),alpha:Q.length>7?parseInt(Q.slice(7,9),16)/255:1}];return}this.#Q=[]}get value(){return this.#Q.map((q)=>({...q}))}set value(q){if(typeof q==="string")this.setAttribute("value",q);else this.setAttribute("value",JSON.stringify(q))}#K(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#q=[],this.#Z=[];let Q=document.createElement("div");Q.className="palette-colors-inline",Q.setAttribute("role","button"),Q.setAttribute("tabindex",q?"-1":"+0"),Q.setAttribute("aria-expanded",String(this.open)),Q.setAttribute("aria-label","Edit palette colors"),Q.addEventListener("blur",()=>{Q.style.removeProperty("outline"),Q.style.removeProperty("outline-offset")});let Z=()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.open=!0,Q.setAttribute("aria-expanded","true")};Q.addEventListener("click",Z);let $=document.createElement("div");if($.className="palette-colors",this.#Q.forEach((j,_)=>{$.appendChild(this.#G(j,_,q,{inline:!0}))}),Q.appendChild($),this.appendChild(Q),this.#f(),!this.#N)this.#z(q,this);let J=document.createElement("div");J.className="palette-colors-expanded",this.#Q.forEach((j,_)=>{if(J.appendChild(this.#G(j,_,q)),!this.#N)J.appendChild(this.#Y(_,q))}),this.appendChild(J)}#G(q,Q,Z,{inline:$=!1}={}){let J=q.alpha<1?q.color+Math.round(q.alpha*255).toString(16).padStart(2,"0"):q.color,j=document.createElement("fig-input-color");if(j.setAttribute("value",J),$)j.setAttribute("text","false"),j.setAttribute("alpha","true"),j.setAttribute("swatch-disabled","");else j.setAttribute("text","true"),j.setAttribute("alpha","true"),j.setAttribute("full","");if(Z)j.setAttribute("disabled","");let _=$?this.#Z:this.#q,W=(N)=>{N.stopPropagation();let K=N.currentTarget;this.#Q[Q]={color:K.hexOpaque||this.#Q[Q].color,alpha:K.rgba?K.rgba.a:this.#Q[Q].alpha};let G=_[Q];if(G){let U=this.#Q[Q],X=U.alpha<1?U.color+Math.round(U.alpha*255).toString(16).padStart(2,"0"):U.color;G.setAttribute("value",X)}};if(j.addEventListener("input",(N)=>{W(N),this.#A()}),j.addEventListener("change",(N)=>{W(N),this.#B()}),$)this.#q.push(j);else this.#Z.push(j);return j}#Y(q,Q){let Z=document.createElement("fig-button");if(Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Remove color"),Z.className="palette-remove-btn",Q||this.#Q.length<=this.#_)Z.setAttribute("disabled","");Z.appendChild(c("minus")),Z.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;this.#R(q)});let $=document.createElement("fig-tooltip");return $.setAttribute("text","Remove color"),$.appendChild(Z),$}#R(q){if(this.#N)return;if(q<0||q>=this.#Q.length)return;if(this.#Q.length<=this.#_)return;this.#Q.splice(q,1),this.#q=[],this.#Z=[],this.#K(),this.#B()}#z(q,Q=this){let Z=this.#Q.length>=this.#W,$=document.createElement("fig-button");if($.setAttribute("variant","ghost"),$.setAttribute("icon","true"),$.setAttribute("aria-label","Add color"),$.className="palette-add-btn",q||Z)$.setAttribute("disabled","");$.appendChild(c("add")),$.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#Q.length>=this.#W)return;this.open=!0,this.#M({color:"#D9D9D9",alpha:1})});let J=document.createElement("fig-tooltip");J.setAttribute("text","Add color"),J.appendChild($),Q.appendChild(J)}#M(q){if(this.#N)return;this.#Q.push(q);let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.#Q.length-1,$=this.#G(q,Z,Q,{inline:!0}),J=this.querySelector(".palette-colors");if(J)J.appendChild($);let j=this.#G(q,Z,Q),_=this.querySelector(".palette-colors-expanded");if(_)_.appendChild(j),_.appendChild(this.#Y(Z,Q));if(this.#Q.length>=this.#W){let W=this.querySelector(".palette-add-btn");if(W)W.setAttribute("disabled","")}this.#T(Q),this.#B()}#L(q){let Q=this.#Q[q];if(!Q)return;let Z=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,$=this.#q[q];if($)$.setAttribute("value",Z);let J=this.#Z[q];if(J)J.setAttribute("value",Z)}#O(){if(this.#q.length!==this.#Q.length){this.#K();return}this.#Q.forEach((q,Q)=>{this.#L(Q)})}#H(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#q,...this.#Z].forEach((Z)=>{if(q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")});let Q=this.querySelector(".palette-add-btn");if(Q)if(q||this.#Q.length>=this.#W)Q.setAttribute("disabled","");else Q.removeAttribute("disabled");this.#T(q),this.#f()}#f(){let q=this.querySelector(".palette-colors-inline");if(!q)return;let Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";q.setAttribute("tabindex",Q?"-1":"+0"),q.setAttribute("aria-disabled",String(Q)),q.setAttribute("aria-expanded",String(this.open))}focus(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let q=this.querySelector(".palette-colors-inline");if(!q)return;q.style.outline="var(--figma-focus-outline)",q.style.outlineOffset="var(--figma-focus-outline-offset)",q.focus()}#T(q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){let Q=q||this.#Q.length<=this.#_;this.querySelectorAll(".palette-remove-btn").forEach((Z)=>{if(Q)Z.setAttribute("disabled","");else Z.removeAttribute("disabled")})}#A(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#B(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}O("fig-input-palette",e0);class e extends HTMLElement{static SHIFT_SNAP=5;#Q;#q;#Z=!1;#$=null;#J=null;#j=null;#N=null;#_={type:"linear",angle:90,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","edit","mode","size"]}get#W(){let q=this.getAttribute("edit");if(q==="false")return"false";if(q==="picker")return"picker";return"true"}get#X(){return this.#W==="true"}get#U(){return this.getAttribute("mode")==="tip"?"tip":"handle"}#K(){if(!this.#q)return null;return this.#q.querySelector("fig-handle:not(.fig-input-gradient-ghost):not([disabled])")}#G(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"){this.setAttribute("tabindex","-1");return}this.setAttribute("tabindex",this.#X?"-1":"0")}#Y(q){let Q=Z0(q);return{...Q,type:["linear","radial","angular"].includes(Q.type)?Q.type:"linear",angle:Number.isFinite(Number(Q.angle))?Number(Q.angle):90,centerX:Number.isFinite(Number(Q.centerX))?Number(Q.centerX):50,centerY:Number.isFinite(Number(Q.centerY))?Number(Q.centerY):50}}connectedCallback(){if(this.#L(),this.#P(),this.#R(),this.removeEventListener("keydown",this.#M),this.addEventListener("keydown",this.#M),this.#X)document.addEventListener("keydown",this.#z)}#R(){if(this.#W!=="picker"||o())return;this.#N??=customElements.whenDefined("fig-fill-picker").then(()=>{if(!this.isConnected||this.#W!=="picker")return;this.#P()})}disconnectedCallback(){if(document.removeEventListener("keydown",this.#z),this.removeEventListener("keydown",this.#M),this.#J)this.#J.disconnect(),this.#J=null;if(this.#j!==null)cancelAnimationFrame(this.#j),this.#j=null;clearTimeout(this.#$),this.removeEventListener("pointerenter",this.#C),this.removeEventListener("pointermove",this.#y),this.removeEventListener("pointerleave",this.#w),this.removeEventListener("click",this.#E),this.removeEventListener("dblclick",this.#b)}#z=(q)=>{let Q=document.activeElement;if(!(Q instanceof Node)||!this.contains(Q))return;let Z=Q&&(Q.tagName==="INPUT"||Q.tagName==="TEXTAREA"||Q.isContentEditable);if(!this.#q)return;if(q.key==="Tab"&&!Z){let j=this.#q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!j)return;q.preventDefault();let _=[...this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],W=_.indexOf(j),N=q.shiftKey?(W-1+_.length)%_.length:(W+1)%_.length;j.deselect(),_[N].select();return}if((q.key==="ArrowLeft"||q.key==="ArrowRight")&&!Z){let j=this.#q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!j)return;let _=parseInt(j.dataset.stopIndex,10);if(isNaN(_)||!this.#_.stops[_])return;q.preventDefault();let W=(q.key==="ArrowRight"?1:-1)*(q.shiftKey?e.SHIFT_SNAP:1),N=this.#_.stops[_];N.position=Math.max(0,Math.min(100,N.position+W)),j.setAttribute("value",`${N.position}% 50%`);let K=j.closest("fig-tooltip");if(K)K.text=`${Math.round(N.position)}%`,K.setAttribute("show","true"),K.showPopup(),j.hideColorTip(),clearTimeout(this.#$),this.#$=setTimeout(()=>{K.removeAttribute("show"),j.showColorTip()},600);this.#u(),this.#c(),this.#i();return}if(q.key!=="Delete"&&q.key!=="Backspace")return;if(Z)return;if(this.#_.stops.length<=2)return;let $=this.#q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!$)return;let J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#_.stops[J])return;q.preventDefault(),$.removeAttribute("selected"),this.#_.stops.splice(J,1),this.#h(),this.#u(),this.#c(),this.#i()};#M=(q)=>{if(this.#W!=="picker")return;if(q.key!=="Enter"&&q.key!==" ")return;if(q.altKey||q.ctrlKey||q.metaKey)return;if(T(this,"disabled"))return;let Q=this.querySelector("fig-fill-picker");if(!Q||typeof Q.open!=="function")return;q.preventDefault(),Q.open()};#L(){let q=this.getAttribute("value");if(!q)return;try{let Q=JSON.parse(q);if(Q?.type==="gradient"&&Q.gradient){this.#_=this.#Y({...this.#_,...Q.gradient});return}if(Q?.gradient)this.#_=this.#Y({...this.#_,...Q.gradient})}catch(Q){}}#O(){let q=this.#Y(this.#_),Z=[...q.stops].sort((j,_)=>j.position-_.position).map((j)=>{let _=(j.opacity??100)/100;if(_>=1)return`${j.color} ${j.position}%`;let{r:W,g:N,b:K}=i(j.color);return`rgba(${W}, ${N}, ${K}, ${_}) ${j.position}%`}).join(", "),$=a0(q);return`linear-gradient(to right${$?` ${$}`:""}, ${Z})`}#H(q){let Q=(q.opacity??100)/100;if(Q>=1)return q.color;let{r:Z,g:$,b:J}=i(q.color);return`rgba(${Z}, ${$}, ${J}, ${Q})`}#f(){let q=this.getAttribute("size");return q?` size="${q}"`:""}#T(){if(!this.#Q)return;let q=this.getAttribute("size");if(q)this.#Q.setAttribute("size",q);else this.#Q.removeAttribute("size")}#A(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Q=this.#U==="tip"?' tip="color"':"";return this.#_.stops.map((Z,$)=>`<fig-tooltip action="manual" text="${Math.round(Z.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color"${Q} color="${this.#H(Z)}" value="${Z.position}% 50%" hit-area="4" data-stop-index="${$}"${q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#B=null;#k=!1;#P(){this.#J?.disconnect(),this.#J=null;let q=T(this,"disabled"),Q=this.#W;if(Q==="picker"&&o()){let Z=JSON.stringify(this.value);this.innerHTML=`
|
|
177
177
|
<fig-fill-picker mode="gradient" value='${Z}'${q?" disabled":""}>
|
|
178
|
-
<fig-swatch background="${this.#
|
|
179
|
-
</fig-fill-picker>`,this.#Q=this.querySelector("fig-swatch"),this.#q=null,this.#
|
|
180
|
-
<fig-swatch background="${this.#
|
|
181
|
-
${Q==="true"||Q==="picker"?`<div class="fig-input-gradient-track">${this.#A()}</div>`:""}`,this.#Q=this.querySelector("fig-swatch"),this.#q=this.querySelector(".fig-input-gradient-track"),Q==="true"||Q==="picker")this.#F(),this.#o();this.#U()}#C(){let q=this.querySelector("fig-fill-picker");if(!q)return;q.anchorElement=this;let Q=(Z)=>{Z.stopPropagation();let $=Z.detail;if(!$?.gradient)return;this.#_=this.#Y({...this.#_,...$.gradient}),this.#u()};q.addEventListener("input",(Z)=>{Q(Z),this.#c()}),q.addEventListener("change",(Z)=>{Q(Z),this.#i()})}#V(q){return sq(this.#_.stops,q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#F(){if(!this.#q||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let q=document.createElement("fig-handle");if(q.classList.add("fig-input-gradient-ghost"),q.setAttribute("type","color"),this.#G==="tip")q.setAttribute("tip","add");q.style.position="absolute",q.style.top="50%",q.style.transform="translate(-50%, -50%)",q.style.pointerEvents="none",q.style.opacity="0",q.style.transition="opacity 0.15s",this.#q.appendChild(q),this.#O=q,this.addEventListener("pointerenter",this.#S),this.addEventListener("pointermove",this.#y),this.addEventListener("pointerleave",this.#w),this.addEventListener("click",this.#E),this.addEventListener("dblclick",this.#b)}#I(){if(!this.#O)return;this.#O.style.opacity="1"}#P(){if(!this.#O)return;this.#O.style.opacity="0"}#S=()=>{if(this.#Z)return;this.#I()};#w=()=>{this.#P()};#y=(q)=>{if(this.#Z){this.#P();return}if(!this.#O||!this.#q)return;if(q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#P();return}let Q=this.#q.getBoundingClientRect(),Z=Math.max(0,Math.min(1,(q.clientX-Q.left)/Q.width));this.#O.style.left=`${Z*100}%`;let $=this.#V(Z);this.#O.setAttribute("color",$),this.#I()};#g(){let q=this.#_.stops.length;if(q<2)return;for(let Q=0;Q<q;Q++)this.#_.stops[Q].position=Math.round(Q/(q-1)*100);this.#v(),this.#u(),this.#c(),this.#i()}#b=(q)=>{if(!this.#q)return;if(!q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#g(),this.#q.querySelectorAll("fig-handle[selected]").forEach((Q)=>{Q.removeAttribute("selected")})};#E=(q)=>{if(!this.#q)return;if(this.#Z)return;if(this.#f){this.#f=!1;return}if(q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(q.shiftKey){let _=q.target.closest("fig-handle"),W=parseInt(_?.dataset.stopIndex,10);if(this.#g(),!isNaN(W))this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((N)=>{if(parseInt(N.dataset.stopIndex,10)===W)N.select();else N.deselect()});q.stopPropagation()}return}let Q=this.#q.getBoundingClientRect(),Z=Math.max(0,Math.min(1,(q.clientX-Q.left)/Q.width)),$=Math.round(Z*100),J=this.#V(Z);this.#_.stops.push({position:$,color:J,opacity:100}),this.#_.stops.sort((_,W)=>_.position-W.position);let j=this.#_.stops.findIndex((_)=>_.position===$&&_.color===J);this.#v(),this.#u(),this.#c(),this.#i(),requestAnimationFrame(()=>{let W=this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[j];if(W)W.click()})};#h(){if(this.#j=null,!this.isConnected)return;if(!this.#q)return;let q=this.#_.stops;this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q,Z)=>{if(Z>=q.length)return;Q.removeAttribute("value"),Q.setAttribute("value",`${q[Z].position}% 50%`)})}refreshLayout(){this.#h()}#x(){if(this.#j!==null)return;this.#j=requestAnimationFrame(()=>this.#h())}#v(){if(!this.#q)return;let q=this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Q=this.#_.stops;if(q.length!==Q.length){let Z=this.#O;if(this.#q.innerHTML=this.#A(),Z)this.#q.appendChild(Z);this.#m(),this.#r(),this.#x();return}for(let Z=0;Z<Q.length;Z++){let $=q[Z],J=Q[Z];if($.dataset.stopIndex=Z,$.setAttribute("value",`${J.position}% 50%`),$.setAttribute("color",this.#H(J)),this.#G==="tip")$.setAttribute("tip","color");else $.removeAttribute("tip");let j=$.closest("fig-tooltip");if(j)j.setAttribute("text",`${Math.round(J.position)}%`)}this.#m()}#m(){if(!this.#q)return;let q=this.#G==="tip";if(this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{if(q)Q.setAttribute("tip","color");else Q.removeAttribute("tip")}),this.#O)if(q)this.#O.setAttribute("tip","add");else this.#O.removeAttribute("tip")}#r(){if(!this.#J||!this.#q)return;this.#J.disconnect(),this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((q)=>{this.#J.observe(q,{attributes:!0,attributeFilter:["color"]})})}#l(){if(!this.#q)return;let q=this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Q=this.#_.stops,Z=new Set;q.forEach(($)=>{let J=Math.round(parseFloat($.getAttribute("value"))||0),j=($.getAttribute("color")||"").toUpperCase(),_=-1;for(let W=0;W<Q.length;W++){if(Z.has(W))continue;if(Q[W].position===J&&Q[W].color.toUpperCase()===j){_=W;break}}if(_===-1){let W=1/0;for(let N=0;N<Q.length;N++){if(Z.has(N))continue;let K=Math.abs(Q[N].position-J);if(K<W)W=K,_=N}}if(_!==-1)Z.add(_),$.dataset.stopIndex=_})}#u(){if(!this.#Q)return;this.#Q.setAttribute("background",this.#B()),this.#T()}#o(){if(!this.#q)return;this.#q.addEventListener("pointerdown",(q)=>{if(T(this,"disabled"))return;if(q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(q.button!==0)return;q.preventDefault(),q.stopPropagation();let Q=this.#q.getBoundingClientRect(),Z=Math.max(0,Math.min(1,(q.clientX-Q.left)/Q.width)),$=Math.round(Z*100),J=this.#V(Z);this.#_.stops.push({position:$,color:J,opacity:100}),this.#_.stops.sort((N,K)=>N.position-K.position);let j=this.#_.stops.findIndex((N)=>N.position===$&&N.color===J);this.#f=!0,this.#v(),this.#u(),this.#c(),this.#P();let W=this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[j];if(W)this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((N)=>{if(N!==W)N.deselect()}),W.select(),W.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:q.clientX,clientY:q.clientY,pointerId:q.pointerId,pointerType:q.pointerType,button:q.button,buttons:q.buttons}))}),this.#q.addEventListener("input",(q)=>{let Q=q.target.closest("fig-handle");if(!Q)return;if(q.stopPropagation(),q.detail?.color){let N=parseInt(Q.dataset.stopIndex,10);if(!isNaN(N)&&this.#_.stops[N]){if(this.#_.stops[N].color=q.detail.color,q.detail.opacity!==void 0)this.#_.stops[N].opacity=q.detail.opacity;else if(q.detail.alpha!==void 0)this.#_.stops[N].opacity=Math.round(q.detail.alpha*100);Q.setAttribute("color",this.#H(this.#_.stops[N])),this.#u(),this.#c()}return}if(!this.#Z)Q.style.zIndex="5";this.#Z=!0;let Z=parseInt(Q.dataset.stopIndex,10);if(isNaN(Z)||!this.#_.stops[Z])return;let $=q.detail?.px??0,J=Math.round($*100),j=J,_=this.#q.getBoundingClientRect().width;if(q.detail?.shiftKey)j=Math.round(j/e.SHIFT_SNAP)*e.SHIFT_SNAP;else{let N=_>0?5/_*100:0;for(let K=0;K<this.#_.stops.length;K++){if(K===Z)continue;if(Math.abs(this.#_.stops[K].position-j)<=N){j=this.#_.stops[K].position;break}}}if(this.#_.stops[Z].position=j,j!==J)Q.style.left=`${j/100*_}px`;let W=Q.closest("fig-tooltip");if(W){if(W.text=`${Math.round(j)}%`,!W.hasAttribute("show"))W.setAttribute("show","true"),Q.hideColorTip()}this.#u(),this.#c()}),this.#q.addEventListener("change",(q)=>{let Q=q.target.closest("fig-handle");if(!Q)return;if(q.stopPropagation(),q.detail?.color){let N=parseInt(Q.dataset.stopIndex,10);if(!isNaN(N)&&this.#_.stops[N]){if(this.#_.stops[N].color=q.detail.color,q.detail.opacity!==void 0)this.#_.stops[N].opacity=q.detail.opacity;Q.setAttribute("color",this.#H(this.#_.stops[N])),this.#u(),this.#i()}return}Q.style.zIndex="";let Z=Q.closest("fig-tooltip");if(Z)Z.removeAttribute("show");Q.showColorTip();let $=parseInt(Q.dataset.stopIndex,10);if(isNaN($)||!this.#_.stops[$])return;let J=q.detail?.px??0,j=Math.round(J*100),_=this.#q.getBoundingClientRect().width,W=_>0?5/_*100:0;for(let N=0;N<this.#_.stops.length;N++){if(N===$)continue;if(Math.abs(this.#_.stops[N].position-j)<=W){j=this.#_.stops[N].position;break}}this.#_.stops[$].position=j,Q.style.left=`${j/100*_}px`,this.#_.stops.sort((N,K)=>N.position-K.position),this.#l(),this.#u(),this.#i(),requestAnimationFrame(()=>{this.#Z=!1})}),this.#J=new MutationObserver((q)=>{for(let Q of q){if(Q.attributeName!=="color")continue;let Z=Q.target;if(Z.classList.contains("fig-input-gradient-ghost"))continue;let $=parseInt(Z.dataset.stopIndex,10);if(isNaN($)||!this.#_.stops[$])continue;let J=Z.getAttribute("color");if(!J||!J.startsWith("#"))continue;if(J!==this.#_.stops[$].color)this.#_.stops[$].color=J,this.#u(),this.#c()}}),this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((q)=>{this.#J.observe(q,{attributes:!0,attributeFilter:["color"]})})}#c(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#i(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:t0(this.#Y(this.#_))}}set value(q){if(typeof q==="string")this.setAttribute("value",q);else this.setAttribute("value",JSON.stringify(q))}focus(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#X){let Q=this.#K();if(Q){Q.focus(q);return}}HTMLElement.prototype.focus.call(this,q)}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"value":this.#L(),this.#u(),this.#v();break;case"disabled":this.#s();break;case"edit":if(this.#D(),this.#R(),this.#X)document.addEventListener("keydown",this.#z);else document.removeEventListener("keydown",this.#z);break;case"mode":this.#m();break;case"size":this.#T();break}}#s(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#U(),this.#Q)if(q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#q)for(let Q of this.#q.querySelectorAll("fig-handle"))if(q)Q.setAttribute("disabled","");else Q.removeAttribute("disabled")}}O("fig-input-gradient",e);class N0 extends HTMLElement{#Q=null;#q;#Z;#$;#J=!1;constructor(){super();if(this.input=document.createElement("input"),this.name=this.getAttribute("name")||"",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",m()),this.name)this.input.setAttribute("name",this.name);this.input.setAttribute("type","checkbox"),this.#q=this.handleInput.bind(this),this.#Z=this.handleChange.bind(this),this.#$=(q)=>{if(q.target!==this||this.input.disabled)return;this.input.click()}}connectedCallback(){let q=this.querySelector(":scope > input");if(q)this.input=q;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("input",this.#q),this.input.addEventListener("input",this.#q),this.input.removeEventListener("change",this.#Z),this.input.addEventListener("change",this.#Z),this.removeEventListener("click",this.#$),this.addEventListener("click",this.#$),this.#W();let Q=this.querySelector(":scope > label");if(Q)this.#Q=Q,this.#J=!1,this.#Q.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#j(),this.#Q.innerText=this.getAttribute("label");if(!this.hasAttribute("label")){let Z=Array.from(this.childNodes).filter(($)=>$.nodeType===Node.TEXT_NODE).map(($)=>$.textContent||"").join(" ").trim();if(Z&&!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-label",Z)}this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#j(){if(!this.#Q)this.#Q=document.createElement("label"),this.#J=!0,this.#Q.setAttribute("for",this.input.id);if(this.#Q&&!this.#Q.parentNode&&this.input.parentNode)this.input.after(this.#Q)}render(){}#N(q){return this.hasAttribute(q)&&this.getAttribute(q)!=="false"}#_(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#W(){let q=this.#N("checked"),Q=this.#N("indeterminate")&&!q,Z=this.#N("disabled");this.input.checked=q,this.input.indeterminate=Q,this.input.disabled=Z,this.input.value=this.getAttribute("value")||"";let $=this.getAttribute("name")||this.name;if($)this.input.setAttribute("name",$);else this.input.removeAttribute("name");if(Q)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#_()}focus(){this.input.focus()}get value(){return this.input.value}set value(q){this.input.value=q,this.setAttribute("value",q)}get checked(){return this.input.checked}set checked(q){if(this.input.checked=q,q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("input",this.#q),this.input.removeEventListener("change",this.#Z),this.removeEventListener("click",this.#$)}attributeChangedCallback(q,Q,Z){switch(q){case"label":if(Z)this.#j(),this.#Q.innerText=Z;else if(this.#Q&&this.#J)this.#Q.remove(),this.#Q=null,this.#J=!1;break;case"checked":if(this.#N("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#W();break;case"indeterminate":this.#W();break;case"disabled":this.#W();break;case"name":if(Z)this.input.setAttribute("name",Z);else this.input.removeAttribute("name");break;case"value":this.input.value=Z||"";break;default:this.input[q]=Z,this.input.setAttribute(q,Z);break}}handleInput(q){if(q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#_(),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}handleChange(q){q.stopPropagation(),this.#_(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}O("fig-checkbox",N0);class qq extends N0{constructor(){super();this.input.setAttribute("type","radio");let q=this.getAttribute("name");if(q)this.input.setAttribute("name",q);else this.input.removeAttribute("name")}}O("fig-radio",qq);class Qq extends N0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}O("fig-switch",Qq);class Zq extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Q=!1;#q=null;#Z=null;#$=null;#J=null;#j=!1;#N=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#_=this.#z.bind(this);#W=this.#M.bind(this);#X=this.#L.bind(this);get value(){return this.getAttribute("value")||""}set value(q){this.setAttribute("value",q??"")}#G(){return!!this.querySelector(":scope > .input-combo")}#K(){if(this.#q=this.querySelector("fig-input-text"),this.#$=this.querySelector("fig-button"),this.#Z=this.querySelector("fig-dropdown"),this.#q)this.#q.setAttribute("value",this.value),this.#q.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#O()}connectedCallback(){if(this.#J=Array.from(this.children).find((q)=>q.tagName==="FIG-DROPDOWN")||null,this.#Q=this.#J!==null,this.#J)this.#J.remove();if(this.#G())this.#K(),this.#Y();else this.#U(),this.#Y();this.#f(T(this,"disabled"))}disconnectedCallback(){this.#R()}#U(){let q=this.#k(),Q=this.getAttribute("placeholder")||"",Z=this.value,$=this.#A(),J=this.#Q?"":`<fig-dropdown type="dropdown" label="${b($)}">${q.map((j)=>`<option>${b(j.trim())}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
|
|
178
|
+
<fig-swatch background="${this.#O()}"${this.#f()}${q?" disabled":""}></fig-swatch>
|
|
179
|
+
</fig-fill-picker>`,this.#Q=this.querySelector("fig-swatch"),this.#q=null,this.#S(),this.#G();return}if(this.innerHTML=`
|
|
180
|
+
<fig-swatch background="${this.#O()}"${this.#f()}${q?" disabled":""}></fig-swatch>
|
|
181
|
+
${Q==="true"||Q==="picker"?`<div class="fig-input-gradient-track">${this.#A()}</div>`:""}`,this.#Q=this.querySelector("fig-swatch"),this.#q=this.querySelector(".fig-input-gradient-track"),Q==="true"||Q==="picker")this.#F(),this.#o();this.#G()}#S(){let q=this.querySelector("fig-fill-picker");if(!q)return;q.anchorElement=this;let Q=(Z)=>{Z.stopPropagation();let $=Z.detail;if(!$?.gradient)return;this.#_=this.#Y({...this.#_,...$.gradient}),this.#u()};q.addEventListener("input",(Z)=>{Q(Z),this.#c()}),q.addEventListener("change",(Z)=>{Q(Z),this.#i()})}#V(q){return sq(this.#_.stops,q,this.#_.interpolationSpace,this.#_.hueInterpolation)}#F(){if(!this.#q||this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let q=document.createElement("fig-handle");if(q.classList.add("fig-input-gradient-ghost"),q.setAttribute("type","color"),this.#U==="tip")q.setAttribute("tip","add");q.style.position="absolute",q.style.top="50%",q.style.transform="translate(-50%, -50%)",q.style.pointerEvents="none",q.style.opacity="0",q.style.transition="opacity 0.15s",this.#q.appendChild(q),this.#B=q,this.addEventListener("pointerenter",this.#C),this.addEventListener("pointermove",this.#y),this.addEventListener("pointerleave",this.#w),this.addEventListener("click",this.#E),this.addEventListener("dblclick",this.#b)}#I(){if(!this.#B)return;this.#B.style.opacity="1"}#D(){if(!this.#B)return;this.#B.style.opacity="0"}#C=()=>{if(this.#Z)return;this.#I()};#w=()=>{this.#D()};#y=(q)=>{if(this.#Z){this.#D();return}if(!this.#B||!this.#q)return;if(q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#D();return}let Q=this.#q.getBoundingClientRect(),Z=Math.max(0,Math.min(1,(q.clientX-Q.left)/Q.width));this.#B.style.left=`${Z*100}%`;let $=this.#V(Z);this.#B.setAttribute("color",$),this.#I()};#m(){let q=this.#_.stops.length;if(q<2)return;for(let Q=0;Q<q;Q++)this.#_.stops[Q].position=Math.round(Q/(q-1)*100);this.#h(),this.#u(),this.#c(),this.#i()}#b=(q)=>{if(!this.#q)return;if(!q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#m(),this.#q.querySelectorAll("fig-handle[selected]").forEach((Q)=>{Q.removeAttribute("selected")})};#E=(q)=>{if(!this.#q)return;if(this.#Z)return;if(this.#k){this.#k=!1;return}if(q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(q.shiftKey){let _=q.target.closest("fig-handle"),W=parseInt(_?.dataset.stopIndex,10);if(this.#m(),!isNaN(W))this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((N)=>{if(parseInt(N.dataset.stopIndex,10)===W)N.select();else N.deselect()});q.stopPropagation()}return}let Q=this.#q.getBoundingClientRect(),Z=Math.max(0,Math.min(1,(q.clientX-Q.left)/Q.width)),$=Math.round(Z*100),J=this.#V(Z);this.#_.stops.push({position:$,color:J,opacity:100}),this.#_.stops.sort((_,W)=>_.position-W.position);let j=this.#_.stops.findIndex((_)=>_.position===$&&_.color===J);this.#h(),this.#u(),this.#c(),this.#i(),requestAnimationFrame(()=>{let W=this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[j];if(W)W.click()})};#v(){if(this.#j=null,!this.isConnected)return;if(!this.#q)return;let q=this.#_.stops;this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q,Z)=>{if(Z>=q.length)return;Q.removeAttribute("value"),Q.setAttribute("value",`${q[Z].position}% 50%`)})}refreshLayout(){this.#v()}#x(){if(this.#j!==null)return;this.#j=requestAnimationFrame(()=>this.#v())}#h(){if(!this.#q)return;let q=this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Q=this.#_.stops;if(q.length!==Q.length){let Z=this.#B;if(this.#q.innerHTML=this.#A(),Z)this.#q.appendChild(Z);this.#g(),this.#r(),this.#x();return}for(let Z=0;Z<Q.length;Z++){let $=q[Z],J=Q[Z];if($.dataset.stopIndex=Z,$.setAttribute("value",`${J.position}% 50%`),$.setAttribute("color",this.#H(J)),this.#U==="tip")$.setAttribute("tip","color");else $.removeAttribute("tip");let j=$.closest("fig-tooltip");if(j)j.setAttribute("text",`${Math.round(J.position)}%`)}this.#g()}#g(){if(!this.#q)return;let q=this.#U==="tip";if(this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{if(q)Q.setAttribute("tip","color");else Q.removeAttribute("tip")}),this.#B)if(q)this.#B.setAttribute("tip","add");else this.#B.removeAttribute("tip")}#r(){if(!this.#J||!this.#q)return;this.#J.disconnect(),this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((q)=>{this.#J.observe(q,{attributes:!0,attributeFilter:["color"]})})}#l(){if(!this.#q)return;let q=this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),Q=this.#_.stops,Z=new Set;q.forEach(($)=>{let J=Math.round(parseFloat($.getAttribute("value"))||0),j=($.getAttribute("color")||"").toUpperCase(),_=-1;for(let W=0;W<Q.length;W++){if(Z.has(W))continue;if(Q[W].position===J&&Q[W].color.toUpperCase()===j){_=W;break}}if(_===-1){let W=1/0;for(let N=0;N<Q.length;N++){if(Z.has(N))continue;let K=Math.abs(Q[N].position-J);if(K<W)W=K,_=N}}if(_!==-1)Z.add(_),$.dataset.stopIndex=_})}#u(){if(!this.#Q)return;this.#Q.setAttribute("background",this.#O()),this.#T()}#o(){if(!this.#q)return;this.#q.addEventListener("pointerdown",(q)=>{if(T(this,"disabled"))return;if(q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(q.button!==0)return;q.preventDefault(),q.stopPropagation();let Q=this.#q.getBoundingClientRect(),Z=Math.max(0,Math.min(1,(q.clientX-Q.left)/Q.width)),$=Math.round(Z*100),J=this.#V(Z);this.#_.stops.push({position:$,color:J,opacity:100}),this.#_.stops.sort((N,K)=>N.position-K.position);let j=this.#_.stops.findIndex((N)=>N.position===$&&N.color===J);this.#k=!0,this.#h(),this.#u(),this.#c(),this.#D();let W=this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[j];if(W)this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((N)=>{if(N!==W)N.deselect()}),W.select(),W.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,clientX:q.clientX,clientY:q.clientY,pointerId:q.pointerId,pointerType:q.pointerType,button:q.button,buttons:q.buttons}))}),this.#q.addEventListener("input",(q)=>{let Q=q.target.closest("fig-handle");if(!Q)return;if(q.stopPropagation(),q.detail?.color){let N=parseInt(Q.dataset.stopIndex,10);if(!isNaN(N)&&this.#_.stops[N]){if(this.#_.stops[N].color=q.detail.color,q.detail.opacity!==void 0)this.#_.stops[N].opacity=q.detail.opacity;else if(q.detail.alpha!==void 0)this.#_.stops[N].opacity=Math.round(q.detail.alpha*100);Q.setAttribute("color",this.#H(this.#_.stops[N])),this.#u(),this.#c()}return}if(!this.#Z)Q.style.zIndex="5";this.#Z=!0;let Z=parseInt(Q.dataset.stopIndex,10);if(isNaN(Z)||!this.#_.stops[Z])return;let $=q.detail?.px??0,J=Math.round($*100),j=J,_=this.#q.getBoundingClientRect().width;if(q.detail?.shiftKey)j=Math.round(j/e.SHIFT_SNAP)*e.SHIFT_SNAP;else{let N=_>0?5/_*100:0;for(let K=0;K<this.#_.stops.length;K++){if(K===Z)continue;if(Math.abs(this.#_.stops[K].position-j)<=N){j=this.#_.stops[K].position;break}}}if(this.#_.stops[Z].position=j,j!==J)Q.style.left=`${j/100*_}px`;let W=Q.closest("fig-tooltip");if(W){if(W.text=`${Math.round(j)}%`,!W.hasAttribute("show"))W.setAttribute("show","true"),Q.hideColorTip()}this.#u(),this.#c()}),this.#q.addEventListener("change",(q)=>{let Q=q.target.closest("fig-handle");if(!Q)return;if(q.stopPropagation(),q.detail?.color){let N=parseInt(Q.dataset.stopIndex,10);if(!isNaN(N)&&this.#_.stops[N]){if(this.#_.stops[N].color=q.detail.color,q.detail.opacity!==void 0)this.#_.stops[N].opacity=q.detail.opacity;Q.setAttribute("color",this.#H(this.#_.stops[N])),this.#u(),this.#i()}return}Q.style.zIndex="";let Z=Q.closest("fig-tooltip");if(Z)Z.removeAttribute("show");Q.showColorTip();let $=parseInt(Q.dataset.stopIndex,10);if(isNaN($)||!this.#_.stops[$])return;let J=q.detail?.px??0,j=Math.round(J*100),_=this.#q.getBoundingClientRect().width,W=_>0?5/_*100:0;for(let N=0;N<this.#_.stops.length;N++){if(N===$)continue;if(Math.abs(this.#_.stops[N].position-j)<=W){j=this.#_.stops[N].position;break}}this.#_.stops[$].position=j,Q.style.left=`${j/100*_}px`,this.#_.stops.sort((N,K)=>N.position-K.position),this.#l(),this.#u(),this.#i(),requestAnimationFrame(()=>{this.#Z=!1})}),this.#J=new MutationObserver((q)=>{for(let Q of q){if(Q.attributeName!=="color")continue;let Z=Q.target;if(Z.classList.contains("fig-input-gradient-ghost"))continue;let $=parseInt(Z.dataset.stopIndex,10);if(isNaN($)||!this.#_.stops[$])continue;let J=Z.getAttribute("color");if(!J||!J.startsWith("#"))continue;if(J!==this.#_.stops[$].color)this.#_.stops[$].color=J,this.#u(),this.#c()}}),this.#q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((q)=>{this.#J.observe(q,{attributes:!0,attributeFilter:["color"]})})}#c(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#i(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:t0(this.#Y(this.#_))}}set value(q){if(typeof q==="string")this.setAttribute("value",q);else this.setAttribute("value",JSON.stringify(q))}focus(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#X){let Q=this.#K();if(Q){Q.focus(q);return}}HTMLElement.prototype.focus.call(this,q)}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"value":this.#L(),this.#u(),this.#h();break;case"disabled":this.#s();break;case"edit":if(this.#P(),this.#R(),this.#X)document.addEventListener("keydown",this.#z);else document.removeEventListener("keydown",this.#z);break;case"mode":this.#g();break;case"size":this.#T();break}}#s(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.#G(),this.#Q)if(q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#q)for(let Q of this.#q.querySelectorAll("fig-handle"))if(q)Q.setAttribute("disabled","");else Q.removeAttribute("disabled")}}O("fig-input-gradient",e);class N0 extends HTMLElement{#Q=null;#q;#Z;#$;#J=!1;constructor(){super();if(this.input=document.createElement("input"),this.name=this.getAttribute("name")||"",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",m()),this.name)this.input.setAttribute("name",this.name);this.input.setAttribute("type","checkbox"),this.#q=this.handleInput.bind(this),this.#Z=this.handleChange.bind(this),this.#$=(q)=>{if(q.target!==this||this.input.disabled)return;this.input.click()}}connectedCallback(){let q=this.querySelector(":scope > input");if(q)this.input=q;else if(!this.input.parentNode)this.append(this.input);this.input.removeEventListener("input",this.#q),this.input.addEventListener("input",this.#q),this.input.removeEventListener("change",this.#Z),this.input.addEventListener("change",this.#Z),this.removeEventListener("click",this.#$),this.addEventListener("click",this.#$),this.#W();let Q=this.querySelector(":scope > label");if(Q)this.#Q=Q,this.#J=!1,this.#Q.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#j(),this.#Q.innerText=this.getAttribute("label");if(!this.hasAttribute("label")){let Z=Array.from(this.childNodes).filter(($)=>$.nodeType===Node.TEXT_NODE).map(($)=>$.textContent||"").join(" ").trim();if(Z&&!this.input.hasAttribute("aria-label")&&!this.input.hasAttribute("aria-labelledby"))this.input.setAttribute("aria-label",Z)}this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#j(){if(!this.#Q)this.#Q=document.createElement("label"),this.#J=!0,this.#Q.setAttribute("for",this.input.id);if(this.#Q&&!this.#Q.parentNode&&this.input.parentNode)this.input.after(this.#Q)}render(){}#N(q){return this.hasAttribute(q)&&this.getAttribute(q)!=="false"}#_(){if(this.input.indeterminate)this.input.setAttribute("aria-checked","mixed");else this.input.setAttribute("aria-checked",this.input.checked?"true":"false")}#W(){let q=this.#N("checked"),Q=this.#N("indeterminate")&&!q,Z=this.#N("disabled");this.input.checked=q,this.input.indeterminate=Q,this.input.disabled=Z,this.input.value=this.getAttribute("value")||"";let $=this.getAttribute("name")||this.name;if($)this.input.setAttribute("name",$);else this.input.removeAttribute("name");if(Q)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");this.#_()}focus(){this.input.focus()}get value(){return this.input.value}set value(q){this.input.value=q,this.setAttribute("value",q)}get checked(){return this.input.checked}set checked(q){if(this.input.checked=q,q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("input",this.#q),this.input.removeEventListener("change",this.#Z),this.removeEventListener("click",this.#$)}attributeChangedCallback(q,Q,Z){switch(q){case"label":if(Z)this.#j(),this.#Q.innerText=Z;else if(this.#Q&&this.#J)this.#Q.remove(),this.#Q=null,this.#J=!1;break;case"checked":if(this.#N("checked")&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");this.#W();break;case"indeterminate":this.#W();break;case"disabled":this.#W();break;case"name":if(Z)this.input.setAttribute("name",Z);else this.input.removeAttribute("name");break;case"value":this.input.value=Z||"";break;default:this.input[q]=Z,this.input.setAttribute(q,Z);break}}handleInput(q){if(q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.#_(),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}handleChange(q){q.stopPropagation(),this.#_(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}O("fig-checkbox",N0);class qq extends N0{constructor(){super();this.input.setAttribute("type","radio");let q=this.getAttribute("name");if(q)this.input.setAttribute("name",q);else this.input.removeAttribute("name")}}O("fig-radio",qq);class Qq extends N0{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}O("fig-switch",Qq);class Zq extends HTMLElement{static observedAttributes=["options","placeholder","value","disabled","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#Q=!1;#q=null;#Z=null;#$=null;#J=null;#j=!1;#N=["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"];#_=this.#z.bind(this);#W=this.#M.bind(this);#X=this.#L.bind(this);get value(){return this.getAttribute("value")||""}set value(q){this.setAttribute("value",q??"")}#U(){return!!this.querySelector(":scope > .input-combo")}#K(){if(this.#q=this.querySelector("fig-input-text"),this.#$=this.querySelector("fig-button"),this.#Z=this.querySelector("fig-dropdown"),this.#q)this.#q.setAttribute("value",this.value),this.#q.setAttribute("placeholder",this.getAttribute("placeholder")||"");this.#B()}connectedCallback(){if(this.#J=Array.from(this.children).find((q)=>q.tagName==="FIG-DROPDOWN")||null,this.#Q=this.#J!==null,this.#J)this.#J.remove();if(this.#U())this.#K(),this.#Y();else this.#G(),this.#Y();this.#k(T(this,"disabled"))}disconnectedCallback(){this.#R()}#G(){let q=this.#f(),Q=this.getAttribute("placeholder")||"",Z=this.value,$=this.#A(),J=this.#Q?"":`<fig-dropdown type="dropdown" label="${b($)}">${q.map((j)=>`<option>${b(j.trim())}</option>`).join("")}</fig-dropdown>`;if(this.innerHTML=`<div class="input-combo">
|
|
182
182
|
<fig-input-text placeholder="${b(Q)}" value="${b(Z)}"></fig-input-text>
|
|
183
183
|
<fig-button type="select" variant="input" icon>
|
|
184
184
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -186,7 +186,7 @@ var wq=(q,Q)=>()=>(q&&(Q=q(q=0)),Q);var yq={};var D0=wq(()=>{/*! Vendored from @
|
|
|
186
186
|
</svg>
|
|
187
187
|
${J}
|
|
188
188
|
</fig-button>
|
|
189
|
-
</div>`,this.#q=this.querySelector("fig-input-text"),this.#$=this.querySelector("fig-button"),this.#Q&&this.#J&&this.#$){if(!this.#J.hasAttribute("type"))this.#J.setAttribute("type","dropdown");if(!this.#J.hasAttribute("label"))this.#J.setAttribute("label",$);this.#$.append(this.#J)}this.#Z=this.querySelector("fig-dropdown"),this.#O()}#Y(){this.#R(),this.#Z?.addEventListener("input",this.#_),this.#q?.addEventListener("input",this.#W),this.#q?.addEventListener("change",this.#X)}#R(){this.#Z?.removeEventListener("input",this.#_),this.#q?.removeEventListener("input",this.#W),this.#q?.removeEventListener("change",this.#X)}#z(q){q.stopPropagation();let Q=q.target.closest("fig-dropdown")?.value??"";if(this.#j=!0,this.setAttribute("value",Q),this.#j=!1,this.#q)this.#q.setAttribute("value",Q);this.#B(),this.#H()}#M(q){q.stopPropagation();let Q=q.target.value??"";this.#j=!0,this.setAttribute("value",Q),this.#j=!1,this.#B()}#L(q){q.stopPropagation();let Q=q.target.value??"";this.#j=!0,this.setAttribute("value",Q),this.#j=!1,this.#H()}#B(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#H(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#k(){return(this.getAttribute("options")||"").split(",").map((q)=>q.trim()).filter(Boolean)}#T(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#A(){return`${this.#T()} options`}#O(){if(this.#q)this.#N.forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.#q.removeAttribute(q);else this.#q.setAttribute(q,Q)});if(this.#Z&&!this.#Z.hasAttribute("aria-label"))this.#Z.setAttribute("label",this.#A())}#f(q){if(this.#q)if(q)this.#q.setAttribute("disabled","");else this.#q.removeAttribute("disabled");if(this.#$)if(q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#Z)if(q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}focus(){this.#q?.focus()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"options":if(this.#Z&&!this.#Q){let $=this.#k();this.#Z.replaceChildren(...$.map((J)=>{let j=document.createElement("option");return j.textContent=J,j}))}break;case"placeholder":if(this.#q)this.#q.setAttribute("placeholder",Z||"");this.#O();break;case"value":if(!this.#j&&this.#q)this.#q.setAttribute("value",Z||"");break;case"disabled":this.#f(Z!==null&&Z!=="false");break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#O();break}}}O("fig-combo-input",Zq);class M0 extends HTMLElement{#Q="color";#q=null;#Z=!1;constructor(){super();this.#q=this.#X.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#_(),this.#$(),this.#W()}#$(){let q=this.getAttribute("alpha");if(q!==null)this.style.setProperty("--alpha",q);else this.style.removeProperty("--alpha")}#J(q){if(!q)return"color";let Q=q.toLowerCase();if(Q.includes("gradient"))return"gradient";if(Q.includes("url("))return"image";return"color"}#j(q){if(!q)return"#D9D9D9";if(q.startsWith("#"))return q.slice(0,7);try{let{ctx:Q}=z0(1,1);return Q.fillStyle=q,Q.fillStyle}catch{return"#D9D9D9"}}#N(q){if(!q||!q.includes("var("))return q;let Q=this.style.background;this.style.background=q;let Z=getComputedStyle(this),$=Z.backgroundImage,J=Z.backgroundColor;if(this.style.background=Q,$&&$!=="none")return $;return J||q}#_(){let q=this.getAttribute("background")||"#D9D9D9",Q=q.includes("var("),Z=Q?this.#N(q):q,$=this.#J(Z);if($!==this.#Q||!this.input){if(this.#Q=$,this.setAttribute("data-type",this.#Q),this.input)this.input.removeEventListener("input",this.#q);if(this.#Q==="color"){let j=this.#j(Z);if(this.innerHTML=`<div></div><input type="color" value="${j}" />`,this.input=this.querySelector("input"),!Q)this.input.addEventListener("input",this.#q);this.#W()}else this.innerHTML="<div></div>",this.input=null,this.#W()}else if(this.#Q==="color"&&this.input){let j=this.#j(Z);if(this.input.value!==j)this.input.value=j}let J=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(q);this.style.setProperty("--swatch-background",J?q:`linear-gradient(${q}, ${q})`)}#W(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",q?"true":"false"),this.input){this.input.disabled=q;let Q=this.getAttribute("aria-labelledby"),Z=this.getAttribute("aria-label")||"Color swatch",$=this.getAttribute("aria-describedby");if(Q)this.input.setAttribute("aria-labelledby",Q),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",Z),this.input.removeAttribute("aria-labelledby");if($)this.input.setAttribute("aria-describedby",$);else this.input.removeAttribute("aria-describedby");this.removeAttribute("role"),this.removeAttribute("aria-hidden");return}if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-hidden","true");else this.setAttribute("role","img"),this.removeAttribute("aria-hidden")}#X(q){this.#Z=!0,this.setAttribute("background",q.target.value),this.#Z=!1}get background(){return this.getAttribute("background")}set background(q){this.setAttribute("background",q)}focus(){this.input?.focus()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="background"){if(this.#Z){let $=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Z);this.style.setProperty("--swatch-background",$?Z:`linear-gradient(${Z}, ${Z})`);return}this.#_()}else if(q==="alpha")this.#$();else if(q==="disabled"||q==="aria-label"||q==="aria-labelledby"||q==="aria-describedby")this.#W()}get alpha(){return this.getAttribute("alpha")}set alpha(q){if(q===null||q===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",q)}}O("fig-swatch",M0);class $q extends M0{}O("fig-chit",$q);var Jq=["load","error"],jq=["loadstart","progress","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","durationchange","timeupdate","ratechange","resize","volumechange"],iq=[...new Set([...Jq,...jq])];class K0 extends HTMLElement{#Q=null;#q=null;#Z=null;#$=null;#J=null;#j=null;#N=null;#_=this.#s.bind(this);#W=this.#a.bind(this);#X=this.#Q0.bind(this);#G=this.#Z0.bind(this);#K=this.#d.bind(this);#U=null;#Y=null;#R=null;#z=void 0;#M=null;#L=null;#B=null;#H=null;#k=null;#T=null;#A=null;static get observedAttributes(){return["src","type","alt","upload","loading-indicator","label","aspect-ratio","fit","checkerboard","caption","controls","autoplay","loop","muted","poster","aria-label","aria-labelledby","title"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#Q}set src(q){if(this.#Q=q||"",q===null||q===void 0||q==="")this.removeAttribute("src");else this.setAttribute("src",q)}get file(){return this.#N}#O(){return this.#j||this.#Q||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#O())return null;if(!this.#q)return null;try{if(typeof this.#q.decode==="function")await this.#q.decode();else if(!this.#q.complete)await new Promise(($,J)=>{this.#q.addEventListener("load",$,{once:!0}),this.#q.addEventListener("error",J,{once:!0})})}catch{}let q=this.#q.naturalWidth,Q=this.#q.naturalHeight;if(!(q>0)||!(Q>0))return null;let Z=document.createElement("canvas");return Z.width=q,Z.height=Q,Z.getContext("2d").drawImage(this.#q,0,0),Z.toDataURL()}connectedCallback(){this.#Q=this.getAttribute("src")||"";let q=this.getAttribute("aspect-ratio");if(q)this.style.setProperty("--fig-media-aspect-ratio",q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-media-fit",Q);if(this.querySelectorAll("fig-swatch[data-generated]").forEach(($)=>$.remove()),this.#I(),this.#S(),this.#D(),this.#h(),this.#V(),this.#w(),this.#b(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#c();this.#$=this.querySelector("fig-input-file[data-generated]"),this.#$?.removeEventListener("change",this.#_),this.#$?.addEventListener("change",this.#_)}disconnectedCallback(){if(this.#$?.removeEventListener("change",this.#_),this.#F(),this.#f(),this.#o(),this.#J)URL.revokeObjectURL(this.#J),this.#J=null;this.#j=null}#f(){if(!this.#q)return;if(iq.forEach((q)=>{this.#q.removeEventListener(q,this.#K)}),this.#q.tagName==="VIDEO")this.#q.removeEventListener("play",this.#W),this.#q.removeEventListener("pause",this.#X),this.#q.removeEventListener("ended",this.#G)}#D(){if(this.#f(),!this.#q)return;if((this.#q.tagName==="VIDEO"?jq:Jq).forEach((Q)=>{this.#q.addEventListener(Q,this.#K)}),this.#q.tagName!=="VIDEO")return;this.#q.addEventListener("play",this.#W),this.#q.addEventListener("pause",this.#X),this.#q.addEventListener("ended",this.#G)}#C(){return this.mediaKind==="image"&&this.getAttribute("loading-indicator")!=="false"&&this.#Z?.hasAttribute("data-generated")&&this.#q?.hasAttribute("data-generated")}#V(){let q=this.#O();if(!q||!this.#C()){this.#F();return}if(this.#q?.tagName==="IMG"&&this.#q.complete&&this.#q.currentSrc){this.#F();return}if(this.#R===q)return;this.#F(),this.#R=q,this.#z=this.getAttribute("aria-busy"),this.setAttribute("aria-busy","true"),this.#Y=setTimeout(()=>{if(this.#Y=null,this.#R!==q||!this.isConnected||!this.#C())return;let Q=document.createElement("fig-spinner");Q.setAttribute("data-generated",""),Q.setAttribute("data-loading-indicator",""),Q.setAttribute("slot","overlay"),Q.setAttribute("size","small"),Q.setAttribute("aria-hidden","true"),this.append(Q),this.#U=Q},150)}#F(){if(this.#Y!==null)clearTimeout(this.#Y),this.#Y=null;if(this.#U?.remove(),this.#U=null,this.#R=null,this.#z!==void 0){if(this.#z===null)this.removeAttribute("aria-busy");else this.setAttribute("aria-busy",this.#z);this.#z=void 0}}#I(){if(this.#Z?.isConnected)return;let q=this.querySelector(":scope > fig-preview");if(q){this.#Z=q;return}let Q=document.createElement("fig-preview");Q.setAttribute("data-generated",""),this.prepend(Q),this.#Z=Q}#P(){let q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${q}:not([data-generated])`)}#S(){let q=this.#P();if(q){if(this.#I(),this.#q&&this.#q!==q){if(this.#f(),this.#q.hasAttribute("data-generated"))this.#q.remove()}if(this.#q=q,this.#Z&&q.parentElement!==this.#Z)this.#Z.append(q);this.#D(),this.#w();return}this.#I();let Q=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#q&&this.#q.tagName!==Q){if(this.#f(),this.#q.hasAttribute("data-generated"))this.#q.remove();this.#q=null}if(this.#q)return;if(this.mediaKind==="video"){let Z=document.createElement("video");Z.setAttribute("data-generated",""),Z.className="fig-media-element",Z.setAttribute("playsinline",""),Z.preload="auto",this.#Z.append(Z),this.#q=Z;let $=()=>{if(this.#q?.autoplay)return;try{this.#q.currentTime=0.001}catch{}};this.#q.addEventListener("loadedmetadata",$,{once:!0})}else{let Z=document.createElement("img");Z.setAttribute("data-generated",""),Z.className="fig-media-element",Z.loading="lazy",Z.decoding="async",Z.alt=this.getAttribute("alt")||"",this.#Z.append(Z),this.#q=Z}this.#D()}#w(){if(!this.#q)return;if(this.#q.tagName==="IMG"){if(this.hasAttribute("alt")||this.#q.hasAttribute("data-generated"))this.#q.alt=this.getAttribute("alt")||"";return}if(this.#q.tagName!=="VIDEO")return;["aria-label","aria-labelledby","title"].forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.#q.removeAttribute(q);else this.#q.setAttribute(q,Q)})}#y(){return this.querySelector(":scope > figcaption:not([data-generated])")}#g(){return Array.from(this.querySelectorAll(":scope > figcaption[data-generated]"))}#b(){let q=this.#y(),Q=this.#g();if(q){Q.forEach((j)=>j.remove());return}let Z=this.getAttribute("caption")||"";if(!Z){Q.forEach((j)=>j.remove());return}let $=Q[0]||document.createElement("figcaption");if(Q.slice(1).forEach((j)=>j.remove()),!$.hasAttribute("data-generated"))$.setAttribute("data-generated","");if($.textContent!==Z)$.textContent=Z;let J=this.querySelector(":scope > fig-media-controls");if(J)J.before($);else if(this.#Z?.isConnected)this.#Z.after($);else if(!$.isConnected)this.append($)}#E(q,Q=!1){if(!this.hasAttribute(q))return Q;return this.getAttribute(q)!=="false"}#h(){if(!this.#q)return;if(!this.#q.hasAttribute("data-generated"))return;let q=this.#O();if(this.#q.getAttribute("src")!==q){if(q)this.#q.setAttribute("src",q);else if(this.#q.removeAttribute("src"),this.#q.tagName==="VIDEO")this.#q.load()}if(this.#q.tagName==="IMG"){this.#w(),this.#V();return}let Q=this.getAttribute("poster");if(Q)this.#q.setAttribute("poster",Q);else this.#q.removeAttribute("poster");this.#q.controls=!1,this.#q.removeAttribute("controls"),this.#q.autoplay=this.#E("autoplay",!1),this.#q.loop=this.#E("loop",!1),this.#q.muted=this.#E("muted",!1),this.#q.playsInline=!0,this.#w(),this.#m(),this.#v(),this.#V()}get mediaEl(){return this.#q}#x(){if(this.mediaKind!=="video")return!1;return Boolean(this.#O())}#v(){let q=this.#M||this.querySelector(":scope > fig-media-controls");if(!q)return;if(this.mediaKind!=="video")return;if(this.#x()){if(q.hasAttribute("data-fig-empty-disabled"))q.removeAttribute("disabled"),q.removeAttribute("data-fig-empty-disabled");return}q.setAttribute("disabled",""),q.setAttribute("data-fig-empty-disabled",""),q.playing=!1,q.time=0,q.duration=0}#m(){if(this.mediaKind!=="video"){this.#o();return}let q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(q){if(this.#M!==q)this.#o(),this.#M=q;this.#l(),this.#v();return}if(this.#E("controls",!1))this.#r();else this.#o()}#r(){let q=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Q=q[0];if(q.slice(1).forEach(($)=>$.remove()),Q){this.#M=Q,this.#l(),this.#v();return}let Z=document.createElement("fig-media-controls");Z.setAttribute("data-generated",""),this.append(Z),this.#M=Z,this.#l(),this.#v()}#l(){if(!this.#M||!this.#q)return;if(this.#L===this.#q&&this.#B===this.#M){this.#v();return}this.#u();let q=this.#M,Q=this.#q;this.#L=Q,this.#B=q;let Z=null,$=()=>{if(this.#v(),!this.#x())return;if(q.playing=!Q.paused&&!Q.ended,Number.isFinite(Q.duration))q.duration=Q.duration;if(Z!==null)if(Math.abs(Q.currentTime-Z)<0.25)Z=null;else return;q.time=Q.currentTime||0},J=()=>{if(!this.#x())return;let W=Q.play?.();if(W&&typeof W.catch==="function")W.catch(()=>{})},j=()=>Q.pause?.(),_=(W)=>{if(!this.#x())return;let N=Number(W?.detail?.time);if(!Number.isFinite(N))return;Z=N;try{Q.currentTime=N}catch{}};this.#H=$,this.#k=J,this.#T=j,this.#A=_,Q.addEventListener("play",$),Q.addEventListener("pause",$),Q.addEventListener("ended",$),Q.addEventListener("timeupdate",$),Q.addEventListener("loadedmetadata",$),Q.addEventListener("durationchange",$),Q.addEventListener("seeked",$),q.addEventListener("play",J),q.addEventListener("pause",j),q.addEventListener("seek",_),$()}#u(){let q=this.#L,Q=this.#B;if(q&&this.#H)q.removeEventListener("play",this.#H),q.removeEventListener("pause",this.#H),q.removeEventListener("ended",this.#H),q.removeEventListener("timeupdate",this.#H),q.removeEventListener("loadedmetadata",this.#H),q.removeEventListener("durationchange",this.#H),q.removeEventListener("seeked",this.#H);if(Q){if(this.#k)Q.removeEventListener("play",this.#k);if(this.#T)Q.removeEventListener("pause",this.#T);if(this.#A)Q.removeEventListener("seek",this.#A)}this.#L=null,this.#B=null,this.#H=null,this.#k=null,this.#T=null,this.#A=null}#o(){this.#u(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((q)=>{q.remove()}),this.#M=null}toggle(){if(!this.#q||this.mediaKind!=="video")return;if(this.#q.paused||this.#q.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#q)return;let q=this.#q.play();if(q&&typeof q.catch==="function")q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#q)return;this.#q.pause()}#c(){let q=document.createElement("fig-input-file");q.setAttribute("data-generated",""),q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),q.setAttribute("variant","overlay");let Q=this.getAttribute("label")||"Upload";if(q.setAttribute("label",this.#Q?"Replace":Q),this.#N?.name)q.setAttribute("filename",this.#N.name);else if(this.#Q)q.setAttribute("url",this.#Q);q.addEventListener("change",this.#_),this.#I(),this.#Z.append(q),this.#$=q}#i(){if(this.#$)this.#$.removeEventListener("change",this.#_),this.#$.remove(),this.#$=null}#s(q){if(q.target!==this.#$)return;let Q=q.detail?.files?.[0],Z=q.detail?.cleared===!0;if(!Q){if(this.#J)URL.revokeObjectURL(this.#J),this.#J=null;if(this.#N=null,this.#j=null,Z)this.src="";if(this.#h(),this.#$){let $=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Q?"Replace":$),this.#$.removeAttribute("filename"),this.#Q)this.#$.setAttribute("url",this.#Q);else this.#$.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#J)URL.revokeObjectURL(this.#J);if(this.#N=Q,this.#J=URL.createObjectURL(Q),this.#j=this.#J,this.#h(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Q,src:this.#J}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#$)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",Q.name),this.#$.setAttribute("label","Replace")}#p(q){if(!this.#q)return;this.dispatchEvent(new CustomEvent(q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Q||"",currentTime:this.#q.currentTime,duration:this.#q.duration}}))}#d(q){let Q=this.#q;if(!Q||q.currentTarget!==Q)return;if(Q.tagName==="IMG"&&(q.type==="load"||q.type==="error"))this.#F();let Z={src:this.#O(),media:Q,originalEvent:q};if(Q.tagName==="VIDEO")Z.currentTime=Q.currentTime,Z.duration=Q.duration,Z.readyState=Q.readyState,Z.networkState=Q.networkState,Z.error=Q.error;this.dispatchEvent(new CustomEvent(q.type,{bubbles:!0,cancelable:!1,composed:!0,detail:Z}))}#a(){this.#p("play")}#Q0(){this.#p("pause")}#Z0(){this.#p("ended")}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="src"){let $=Z||"",J=$&&($===this.#j||$===this.#J);if(this.#Q=$,this.#J&&!J)URL.revokeObjectURL(this.#J),this.#J=null,this.#j=null,this.#N=null;if(this.#h(),this.#$){let j=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Q?"Replace":j),this.#Q)if(this.#N?.name)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",this.#N.name);else this.#$.setAttribute("url",this.#Q),this.#$.removeAttribute("filename");else this.#$.removeAttribute("url"),this.#$.removeAttribute("filename")}}if(q==="type"){if(this.#S(),this.#h(),this.#$)this.#$.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(q))this.#w();if(q==="upload"){let $=Z!==null&&Z!=="false";if($&&!this.#$)this.#c();else if(!$)this.#i()}if(q==="loading-indicator")this.#V();if(q==="aspect-ratio")if(Z)this.style.setProperty("--fig-media-aspect-ratio",Z);else this.style.removeProperty("--fig-media-aspect-ratio");if(q==="fit")if(Z)this.style.setProperty("--fig-media-fit",Z);else this.style.removeProperty("--fig-media-fit");if(q==="label"&&this.#$){let $=this.getAttribute("label")||"Upload";this.#$.setAttribute("label",this.#Q?"Replace":$)}if(["controls","autoplay","loop","muted","poster"].includes(q))this.#h();if(q==="caption")this.#b()}}O("fig-media",K0);class _q extends K0{get mediaKind(){return"image"}}O("fig-image",_q);class Wq extends K0{get mediaKind(){return"video"}}O("fig-video",Wq);class Nq extends HTMLElement{static get observedAttributes(){return["src","alt","label","text","sublabel","selected","disabled","full","size","aspect-ratio","fit","label-line-clamp"]}#Q=null;#q=null;#Z=null;#$=null;#J=!1;#j=new MutationObserver((q)=>{if(!q.some((Z)=>[...Z.addedNodes,...Z.removedNodes].some(($)=>$ instanceof Element&&($.matches("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])")||$.querySelector("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])"))))||!this.isConnected)return;this.#U(),this.#R()});connectedCallback(){this.#j.observe(this,{childList:!0,subtree:!0}),this.#U(),this.#R()}disconnectedCallback(){this.#j.disconnect()}attributeChangedCallback(){if(!this.isConnected)return;this.#U(),this.#R()}#N(){return this.getAttribute("label")??this.getAttribute("text")??""}#_(){return this.getAttribute("sublabel")??""}#W(){return this.getAttribute("label-line-clamp")==="2"?"2":"1"}#X(){return Boolean(this.getAttribute("src"))}#G(){return this.querySelector(":scope > fig-image:not([data-generated]), :scope > fig-media:not([data-generated]), :scope > fig-preview:not([data-generated])")}#K(){this.querySelectorAll(":scope > .fig-card-link").forEach((q)=>{q.querySelectorAll(":scope > .fig-card-media").forEach((Q)=>{while(Q.firstChild)q.insertBefore(Q.firstChild,Q);Q.remove()});while(q.firstChild)this.insertBefore(q.firstChild,q);q.remove()})}#U(){if(this.#K(),!this.#X()){this.#Y();return}let q=this.#G();if(this.#J=Boolean(q),q)this.querySelectorAll(":scope > [data-generated]:not(fig-footer)").forEach((Z)=>Z.remove()),this.#q=null;if(!this.#J){if(this.#q=this.querySelector(":scope > fig-image[data-generated]")||null,!this.#q)this.querySelectorAll(":scope > fig-image, :scope > fig-media, :scope > fig-preview").forEach((Z)=>{if(Z.hasAttribute("data-generated"))Z.remove()}),this.#q=document.createElement("fig-image"),this.#q.setAttribute("data-generated",""),this.#q.setAttribute("full",""),this.#q.setAttribute("size","auto"),this.prepend(this.#q)}if(!Boolean(this.#N()||this.#_())){this.querySelector(":scope > fig-footer[data-generated]")?.remove(),this.#Q=null,this.#Z=null,this.#$=null;return}if(!this.#Q||!this.#Q.isConnected){if(this.#Q=this.querySelector(":scope > fig-footer[data-generated]"),!this.#Q)this.#Q=document.createElement("fig-footer"),this.#Q.setAttribute("data-generated",""),this.appendChild(this.#Q)}if(!this.#Z||!this.#Z.isConnected){if(this.#Z=this.#Q.querySelector(":scope > .fig-card-label[data-generated]"),!this.#Z)this.#Z=document.createElement("label"),this.#Z.className="fig-card-label",this.#Z.setAttribute("data-generated",""),this.#Q.appendChild(this.#Z)}if(!this.#$||!this.#$.isConnected){if(this.#$=this.#Q.querySelector(":scope > .fig-card-sublabel[data-generated]"),!this.#$)this.#$=document.createElement("label"),this.#$.className="fig-card-sublabel",this.#$.setAttribute("data-generated",""),this.#Z.after(this.#$)}}#Y(){if(this.#K(),this.querySelectorAll(":scope > [data-generated]").forEach((Q)=>Q.remove()),this.#q=null,this.#J=!0,this.#Q=null,this.#Z=null,this.#$=null,!this.#N()&&!this.#_())return;this.#Q=document.createElement("fig-footer"),this.#Q.setAttribute("data-generated",""),this.#Z=document.createElement("label"),this.#Z.className="fig-card-label",this.#Z.setAttribute("data-generated",""),this.#Q.appendChild(this.#Z);let q=this.#_();if(this.#$=null,q)this.#$=document.createElement("label"),this.#$.className="fig-card-sublabel",this.#$.setAttribute("data-generated",""),this.#Q.appendChild(this.#$);this.appendChild(this.#Q)}#R(){if(!this.#X()){this.#z();return}let q=T(this,"disabled"),Q=this.#N(),Z=this.#_(),$=this.#W();this.style.setProperty("--fig-card-label-line-clamp",$),this.setAttribute("role","group");let J=[Q,Z].filter(Boolean).join(", ");if(J)this.setAttribute("aria-label",J);else this.removeAttribute("aria-label");if(q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#q&&!this.#J){let j=this.getAttribute("src"),_=this.getAttribute("alt"),W=this.getAttribute("aspect-ratio")||"1/1",N=this.getAttribute("fit")||"contain",K=_!=null?_:"";if(j)this.#q.setAttribute("src",j);else this.#q.removeAttribute("src");this.#q.setAttribute("alt",K),this.#q.setAttribute("aspect-ratio",W),this.#q.setAttribute("fit",N),this.#q.setAttribute("full",""),this.#q.setAttribute("size","auto")}if(this.#Z)this.#Z.textContent=Q,this.#Z.hidden=!Q;if(this.#$)this.#$.textContent=Z,this.#$.hidden=!Z;if(this.#Q)this.#Q.hidden=!Q&&!Z}#z(){let q=T(this,"disabled"),Q=this.#N(),Z=this.#_();this.style.setProperty("--fig-card-label-line-clamp",this.#W()),this.setAttribute("role","group");let $=[Q,Z].filter(Boolean).join(", ");if($)this.setAttribute("aria-label",$);else this.removeAttribute("aria-label");if(q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#Z)this.#Z.textContent=Q,this.#Z.hidden=!Q;if(this.#$)this.#$.textContent=Z}}O("fig-card",Nq);class Kq extends HTMLElement{#Q=null;#q=null;#Z=null;#$=null;#J=!1;#j=!1;static get observedAttributes(){return["playing","duration","time","disabled"]}connectedCallback(){this.#N(),this.#G(),this.#K(),this.#_()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(q){if(q)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let q=Number(this.getAttribute("duration"));return Number.isFinite(q)&&q>=0?q:0}set duration(q){let Q=Number(q);if(!Number.isFinite(Q)||Q<0){this.removeAttribute("duration");return}this.setAttribute("duration",String(Q))}get time(){let q=Number(this.getAttribute("time"));return Number.isFinite(q)&&q>=0?q:0}set time(q){let Q=Number(q);if(!Number.isFinite(Q)||Q<0){this.removeAttribute("time");return}this.setAttribute("time",String(Q))}get disabled(){return T(this,"disabled")}set disabled(q){if(q)this.setAttribute("disabled","");else this.removeAttribute("disabled")}attributeChangedCallback(q){if(!this.#j)return;if(q==="playing")this.#G();if(q==="duration"||q==="time")this.#K();if(q==="disabled")this.#_()}#N(){if(this.#j)return;if(this.#j=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");let q=document.createElement("fig-tooltip");q.setAttribute("text","Play");let Q=document.createElement("fig-button");Q.setAttribute("variant","ghost"),Q.setAttribute("size","small"),Q.setAttribute("icon","true"),Q.setAttribute("aria-label","Play");let Z=c("play",{className:"fig-media-controls-play-icon"});Q.append(Z),q.append(Q),Q.addEventListener("click",(_)=>{_.preventDefault(),_.stopPropagation(),this.toggle()});let $=document.createElement("fig-slider");$.setAttribute("text","false"),$.setAttribute("min","0"),$.setAttribute("max",String(this.duration)),$.setAttribute("step","1"),$.setAttribute("value",String(this.time)),$.setAttribute("full",""),$.setAttribute("aria-label","Seek"),$.setAttribute("aria-valuetext",this.#X(this.time,this.duration));let J=document.createElement("span");J.className="fig-media-controls-time",J.textContent=this.#W(this.time);let j=(_)=>{if(this.disabled){_.preventDefault?.(),_.stopPropagation();return}let W=_.currentTarget,N=Number(W?.value);if(!Number.isFinite(N))return;this.#J=!0,this.setAttribute("time",String(N)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:N}})),requestAnimationFrame(()=>{this.#J=!1})};$.addEventListener("input",j),$.addEventListener("change",j),this.append(q,$,J),this.#Q=Q,this.#q=q,this.#Z=$,this.#$=J,this.#_()}#_(){let q=this.disabled;if(this.setAttribute("aria-disabled",q?"true":"false"),this.#Q)if(q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#Z)if(q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}#W(q){if(!Number.isFinite(q)||q<0)q=0;let Q=Math.floor(q),Z=Math.floor(Q/60),$=Q%60;return`${String(Z).padStart(2,"0")}:${String($).padStart(2,"0")}`}#X(q,Q=0){let Z=this.#W(q);if(!Number.isFinite(Q)||Q<=0)return Z;return`${Z} of ${this.#W(Q)}`}#G(){if(!this.#Q)return;let q=this.playing;this.#Q.setAttribute("aria-label",q?"Pause":"Play"),this.#q?.setAttribute("text",q?"Pause":"Play");let Q=this.#Q.querySelector(".fig-media-controls-play-icon");if(Q)Q.setAttribute("name",q?"pause":"play")}#K(){if(!this.#Z)return;let q=this.duration;if(Number(this.#Z.getAttribute("max"))!==q)this.#Z.setAttribute("max",String(q));let Q=this.time;if(!this.#J)this.#Z.setAttribute("value",String(Q));if(this.#Z.setAttribute("aria-valuetext",this.#X(Q,q)),this.#$)this.#$.textContent=this.#W(Q)}toggle(){if(this.disabled)return;let q=!this.playing;this.playing=q,this.dispatchEvent(new CustomEvent(q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:q}}))}play(){if(this.disabled||this.playing)return;this.toggle()}pause(){if(this.disabled||!this.playing)return;this.toggle()}}O("fig-media-controls",Kq);class Gq extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#Q=null;#q=null;#Z=null;#$=null;#J=null;#j=null;get files(){return this.#j}get#N(){let q=this.getAttribute("filename");if(q)return q;let Q=this.getAttribute("url");if(!Q)return"";try{let $=new URL(Q,location.href).pathname.split("/").pop();return $?decodeURIComponent($):Q}catch{return Q}}get value(){if(this.#j&&this.#j.length>0){if(this.#j.length===1)return this.#j[0].name;return`${this.#j.length} files`}return this.#N}connectedCallback(){this.#Y(),this.addEventListener("dragover",this.#G),this.addEventListener("dragleave",this.#K),this.addEventListener("drop",this.#U)}disconnectedCallback(){this.#Q?.removeEventListener("change",this.#W),this.#Z?.removeEventListener("click",this.#X),this.removeEventListener("dragover",this.#G),this.removeEventListener("dragleave",this.#K),this.removeEventListener("drop",this.#U)}attributeChangedCallback(q,Q,Z){if(Q===Z)return;this.#Y()}clear(){if(this.#j=null,this.#Q)this.#Q.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#Y(),this.#_({cleared:!0})}#_(q={}){let Q={files:this.#j,...q};this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#W=()=>{if(this.#Q.files.length>0)this.#j=this.#Q.files,this.removeAttribute("url"),this.#Y(),this.#_()};#X=(q)=>{q.stopPropagation(),this.clear()};#G=(q)=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#J)this.#J.dataset.prevText=this.#J.textContent,this.#J.textContent="Drop file"}};#K=()=>{if(this.removeAttribute("dragover"),this.#J&&this.#J.dataset.prevText!==void 0)this.#J.textContent=this.#J.dataset.prevText,delete this.#J.dataset.prevText};#U=(q)=>{if(q.preventDefault(),this.removeAttribute("dragover"),this.#J&&this.#J.dataset.prevText!==void 0)this.#J.textContent=this.#J.dataset.prevText,delete this.#J.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.getAttribute("accepts"),Z=Array.from(q.dataTransfer.files);if(Q){let J=Q.split(",").map((j)=>j.trim().toLowerCase());Z=Z.filter((j)=>{let _="."+j.name.split(".").pop().toLowerCase(),W=j.type.toLowerCase();return J.some((N)=>N===_||N===W||N.endsWith("/*")&&W.startsWith(N.slice(0,-1)))})}if(!this.hasAttribute("multiple")||this.getAttribute("multiple")==="false")Z=Z.slice(0,1);if(Z.length===0)return;let $=new DataTransfer;if(Z.forEach((J)=>$.items.add(J)),this.#j=$.files,this.#Q)this.#Q.files=$.files;this.removeAttribute("url"),this.#Y(),this.#_()};#Y(){let q=this.getAttribute("accepts")||"",Q=this.getAttribute("label")||"Upload",Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("multiple")&&this.getAttribute("multiple")!=="false",J=this.getAttribute("variant")||"input",j=this.#j&&this.#j.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",j){let _=q?`Accepts ${q.split(",").map((U)=>U.trim()).join(", ")}`:"";if(this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant",J),this.#J.setAttribute("type","upload"),this.#J.className="fig-input-file-filename",Z)this.#J.setAttribute("disabled","");let W=document.createElement("fig-truncate");W.setAttribute("position","middle"),W.setAttribute("tooltip","");let N=this.value,K=N.lastIndexOf(".");if(K>0)W.setAttribute("tail",N.slice(K));if(W.textContent=N,this.#J.appendChild(W),this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",this.#Q.disabled=Z,q)this.#Q.setAttribute("accept",q);if($)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#W),this.#J.appendChild(this.#Q),_)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",_),this.#$.appendChild(this.#J),this.appendChild(this.#$);else this.appendChild(this.#J);let G=document.createElement("fig-tooltip");if(G.setAttribute("text","Remove"),this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",J==="overlay"?"overlay":"ghost"),this.#Z.setAttribute("icon","true"),this.#Z.setAttribute("aria-label","Remove"),this.#Z.className="fig-input-file-clear",Z)this.#Z.setAttribute("disabled","");this.#Z.replaceChildren(c("minus")),this.#Z.addEventListener("click",this.#X),G.appendChild(this.#Z),this.appendChild(G)}else{let _=q?`Accepts ${q.split(",").map((W)=>W.trim()).join(", ")}`:"";if(_)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",_);if(this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant",J),this.#J.setAttribute("type","upload"),this.#J.textContent=Q,Z)this.#J.setAttribute("disabled","");if(this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",this.#Q.disabled=Z,q)this.#Q.setAttribute("accept",q);if($)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#W),this.#J.appendChild(this.#Q),this.#$)this.#$.appendChild(this.#J),this.appendChild(this.#$);else this.appendChild(this.#J)}}}O("fig-input-file",Gq);class E extends HTMLElement{#Q={x:0.42,y:0};#q={x:0.58,y:1};#Z={stiffness:200,damping:15,mass:1};#$="bezier";#J=2;#j=null;#N=null;#_=null;#W=null;#X=null;#G=null;#K=null;#U=null;#Y=null;#R=null;#z=null;#M=0.8;#L=200;#B=200;#H=null;#k=null;#T=null;#A=null;#O=5;#f=10;#D=10;#C=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#J=parseInt(this.getAttribute("precision")||"2"),v(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let q=this.getAttribute("value");if(q)this.#V(q);this.#R=this.#F(),this.#w(),this.#l()}disconnectedCallback(){if(this.#j=null,this.#A)this.#A.disconnect(),this.#A=null}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="aspect-ratio"){if(v(this,"--aspect-ratio",Z),this.#N)this.#u(),this.#d();return}if(q==="edit"){if(this.isConnected)this.#w();return}if(q==="value"&&Z){let $=this.#$;if(this.#V(Z),this.#R=this.#F(),$!==this.#$&&this.#S())this.#w();else{if(this.#N)this.#d();this.#q0(),this.#t()}}if(q==="precision")this.#J=parseInt(Z||"2")}get value(){if(this.#$==="spring"){let{stiffness:Q,damping:Z,mass:$}=this.#Z;return`spring(${Q}, ${Z}, ${$})`}let q=this.#J;return`${this.#Q.x.toFixed(q)}, ${this.#Q.y.toFixed(q)}, ${this.#q.x.toFixed(q)}, ${this.#q.y.toFixed(q)}`}get cssValue(){if(this.#$==="spring"){let Q=this.#I(),Z=20,$=Math.max(1,Math.floor(Q.length/20)),J=[];for(let j=0;j<Q.length;j+=$)J.push(Q[j].value.toFixed(3));if(Q.length>0)J.push(Q[Q.length-1].value.toFixed(3));return`linear(${J.join(", ")})`}let q=this.#J;return`cubic-bezier(${this.#Q.x.toFixed(q)}, ${this.#Q.y.toFixed(q)}, ${this.#q.x.toFixed(q)}, ${this.#q.y.toFixed(q)})`}get preset(){return this.#R}set value(q){this.setAttribute("value",q)}#V(q){let Q=q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if(Q)return this.#$="spring",this.#Z.stiffness=parseFloat(Q[1]),this.#Z.damping=parseFloat(Q[2]),this.#Z.mass=parseFloat(Q[3]),!0;let Z=q.split(",").map(($)=>parseFloat($.trim()));if(Z.length>=4&&Z.every(($)=>!isNaN($)))return this.#$="bezier",this.#Q.x=Z[0],this.#Q.y=Z[1],this.#q.x=Z[2],this.#q.y=Z[3],!0;return!1}#F(){if(this.#$==="bezier"){for(let Q of E.PRESETS){if(Q.type!=="bezier"||!Q.value)continue;if(Math.abs(this.#Q.x-Q.value[0])<0.001&&Math.abs(this.#Q.y-Q.value[1])<0.001&&Math.abs(this.#q.x-Q.value[2])<0.001&&Math.abs(this.#q.y-Q.value[3])<0.001)return Q.name}return"Custom bezier"}for(let Q of E.PRESETS){if(Q.type!=="spring"||!Q.spring)continue;if(Math.abs(this.#Z.stiffness-Q.spring.stiffness)<0.001&&Math.abs(this.#Z.damping-Q.spring.damping)<0.001&&Math.abs(this.#Z.mass-Q.spring.mass)<0.001)return Q.name}return"Custom spring"}#I(){let{stiffness:q,damping:Q,mass:Z}=this.#Z,$=0.004,J=5,j=[],_=0,W=0;for(let N=0;N<=5;N+=0.004){let K=-q*(_-1)-Q*W;if(W+=K/Z*0.004,_+=W*0.004,j.push({t:N,value:_}),N>0.1&&Math.abs(_-1)<0.0005&&Math.abs(W)<0.0005)break}return j}static#P(q,Q=24){let{stiffness:Z,damping:$,mass:J}=q,j=0.004,_=5,W=[],N=0,K=0;for(let A=0;A<=5;A+=0.004){let R=-Z*(N-1)-$*K;if(K+=R/J*0.004,N+=K*0.004,W.push({t:A,value:N}),A>0.1&&Math.abs(N-1)<0.001&&Math.abs(K)<0.001)break}let G=W[W.length-1].t||1,U=1;for(let A of W)if(A.value>U)U=A.value;let X=0;for(let A of W)if(A.value<X)X=A.value;let z=Math.max(U-X,1),B=6,L=Q-B*2,k=Math.max(1,Math.floor(W.length/30)),H="";for(let A=0;A<W.length;A+=k){let R=B+W[A].t/G*L,D=B+(1-(W[A].value-X)/z)*L;H+=(A===0?"M":"L")+R.toFixed(1)+","+D.toFixed(1)}return`<svg width="${Q}" height="${Q}" viewBox="0 0 ${Q} ${Q}" fill="none"><path d="${H}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(q,Q,Z,$,J=24){let _=(J-12)/2,W=48,N=[],K=(R,D,I,S,w)=>{let y=1-w;return y*y*y*R+3*y*y*w*D+3*y*w*w*I+w*w*w*S};for(let R=0;R<=48;R++){let D=R/48;N.push({x:K(0,q,Z,1,D),y:K(0,Q,$,1,D)})}let G=1/0,U=-1/0,X=1/0,z=-1/0;for(let R of N){if(R.x<G)G=R.x;if(R.x>U)U=R.x;if(R.y<X)X=R.y;if(R.y>z)z=R.y}let B=Math.max(U-G,0.000001),L=Math.max(z-X,0.000001),k=(R)=>_+(R-G)/B*12,H=(R)=>_+(1-(R-X)/L)*12,A="";for(let R=0;R<N.length;R++){let D=k(N[R].x),I=H(N[R].y);A+=`${R===0?"M":"L"}${D.toFixed(1)},${I.toFixed(1)}`}return`<svg width="${J}" height="${J}" viewBox="0 0 ${J} ${J}" fill="none"><path d="${A}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#S(){return this.getAttribute("edit")!=="false"}#w(){if(this.classList.toggle("spring-mode",this.#$==="spring"),this.classList.toggle("bezier-mode",this.#$!=="spring"),this.#v(),this.innerHTML=this.#h(),this.#m(),this.#N)this.#r(),this.#u(),this.#d();this.#t(),this.#L0()}static#y(q){return String(q).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}#g(){return["fig-select","fig-select-options","fig-select-option"].every((q)=>{let Q=customElements.get(q);return typeof Q==="function"&&Q.prototype instanceof HTMLElement})}#b(){let q="",Q=void 0,Z=!1;for(let J of E.PRESETS){if(!this.#S()&&!J.value&&!J.spring)continue;if(J.group!==Q){if(Z)q+="</optgroup>";if(Z=Boolean(J.group),Z)q+=`<optgroup label="${E.#y(J.group)}">`;Q=J.group}let j=E.#y(J.name);q+=`<option value="${j}">${j}</option>`}if(Z)q+="</optgroup>";return`<fig-dropdown class="fig-easing-curve-select" label="Easing preset" value="${E.#y(this.#R)}" full>${q}</fig-dropdown>`}#E(){if(!this.#g())return this.#b();let q="",Q=void 0;for(let $ of E.PRESETS){if(!this.#S()&&!$.value&&!$.spring)continue;if($.group!==Q){if($.group)q+=`<fig-separator label="${E.#y($.group)}"></fig-separator>`;Q=$.group}let J;if($.type==="spring"){let _=$.spring||this.#Z;J=E.#P(_)}else{let _=$.value||[this.#Q.x,this.#Q.y,this.#q.x,this.#q.y];J=E.curveIcon(..._)}let j=E.#y($.name);q+=`<fig-select-option value="${j}" label="${j}"><span slot="prepend">${J}</span><span>${j}</span></fig-select-option>`}return`<fig-select class="fig-easing-curve-select" label="Easing preset" value="${E.#y(this.#R)}" full><fig-select-options>${q}</fig-select-options></fig-select>`}#h(){let Q=this.#E();if(!this.#S())return Q;let Z=`<fig-input-text class="fig-easing-curve-value-input" value="${E.#y(this.value)}" full></fig-input-text>`;if(this.#$==="spring")return`${Q}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
|
|
189
|
+
</div>`,this.#q=this.querySelector("fig-input-text"),this.#$=this.querySelector("fig-button"),this.#Q&&this.#J&&this.#$){if(!this.#J.hasAttribute("type"))this.#J.setAttribute("type","dropdown");if(!this.#J.hasAttribute("label"))this.#J.setAttribute("label",$);this.#$.append(this.#J)}this.#Z=this.querySelector("fig-dropdown"),this.#B()}#Y(){this.#R(),this.#Z?.addEventListener("input",this.#_),this.#q?.addEventListener("input",this.#W),this.#q?.addEventListener("change",this.#X)}#R(){this.#Z?.removeEventListener("input",this.#_),this.#q?.removeEventListener("input",this.#W),this.#q?.removeEventListener("change",this.#X)}#z(q){q.stopPropagation();let Q=q.target.closest("fig-dropdown")?.value??"";if(this.#j=!0,this.setAttribute("value",Q),this.#j=!1,this.#q)this.#q.setAttribute("value",Q);this.#O(),this.#H()}#M(q){q.stopPropagation();let Q=q.target.value??"";this.#j=!0,this.setAttribute("value",Q),this.#j=!1,this.#O()}#L(q){q.stopPropagation();let Q=q.target.value??"";this.#j=!0,this.setAttribute("value",Q),this.#j=!1,this.#H()}#O(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#H(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value}}))}#f(){return(this.getAttribute("options")||"").split(",").map((q)=>q.trim()).filter(Boolean)}#T(){return(this.getAttribute("aria-label")||this.getAttribute("placeholder")||"Combo input").trim()}#A(){return`${this.#T()} options`}#B(){if(this.#q)this.#N.forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.#q.removeAttribute(q);else this.#q.setAttribute(q,Q)});if(this.#Z&&!this.#Z.hasAttribute("aria-label"))this.#Z.setAttribute("label",this.#A())}#k(q){if(this.#q)if(q)this.#q.setAttribute("disabled","");else this.#q.removeAttribute("disabled");if(this.#$)if(q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#Z)if(q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}focus(){this.#q?.focus()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;switch(q){case"options":if(this.#Z&&!this.#Q){let $=this.#f();this.#Z.replaceChildren(...$.map((J)=>{let j=document.createElement("option");return j.textContent=J,j}))}break;case"placeholder":if(this.#q)this.#q.setAttribute("placeholder",Z||"");this.#B();break;case"value":if(!this.#j&&this.#q)this.#q.setAttribute("value",Z||"");break;case"disabled":this.#k(Z!==null&&Z!=="false");break;case"aria-label":case"aria-labelledby":case"aria-describedby":case"aria-invalid":case"aria-required":this.#B();break}}}O("fig-combo-input",Zq);class M0 extends HTMLElement{#Q="color";#q=null;#Z=!1;constructor(){super();this.#q=this.#X.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.#_(),this.#$(),this.#W()}#$(){let q=this.getAttribute("alpha");if(q!==null)this.style.setProperty("--alpha",q);else this.style.removeProperty("--alpha")}#J(q){if(!q)return"color";let Q=q.toLowerCase();if(Q.includes("gradient"))return"gradient";if(Q.includes("url("))return"image";return"color"}#j(q){if(!q)return"#D9D9D9";if(q.startsWith("#"))return q.slice(0,7);try{let{ctx:Q}=z0(1,1);return Q.fillStyle=q,Q.fillStyle}catch{return"#D9D9D9"}}#N(q){if(!q||!q.includes("var("))return q;let Q=this.style.background;this.style.background=q;let Z=getComputedStyle(this),$=Z.backgroundImage,J=Z.backgroundColor;if(this.style.background=Q,$&&$!=="none")return $;return J||q}#_(){let q=this.getAttribute("background")||"#D9D9D9",Q=q.includes("var("),Z=Q?this.#N(q):q,$=this.#J(Z);if($!==this.#Q||!this.input){if(this.#Q=$,this.setAttribute("data-type",this.#Q),this.input)this.input.removeEventListener("input",this.#q);if(this.#Q==="color"){let j=this.#j(Z);if(this.innerHTML=`<div></div><input type="color" value="${j}" />`,this.input=this.querySelector("input"),!Q)this.input.addEventListener("input",this.#q);this.#W()}else this.innerHTML="<div></div>",this.input=null,this.#W()}else if(this.#Q==="color"&&this.input){let j=this.#j(Z);if(this.input.value!==j)this.input.value=j}let J=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(q);this.style.setProperty("--swatch-background",J?q:`linear-gradient(${q}, ${q})`)}#W(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";if(this.setAttribute("aria-disabled",q?"true":"false"),this.input){this.input.disabled=q;let Q=this.getAttribute("aria-labelledby"),Z=this.getAttribute("aria-label")||"Color swatch",$=this.getAttribute("aria-describedby");if(Q)this.input.setAttribute("aria-labelledby",Q),this.input.removeAttribute("aria-label");else this.input.setAttribute("aria-label",Z),this.input.removeAttribute("aria-labelledby");if($)this.input.setAttribute("aria-describedby",$);else this.input.removeAttribute("aria-describedby");this.removeAttribute("role"),this.removeAttribute("aria-hidden");return}if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-hidden","true");else this.setAttribute("role","img"),this.removeAttribute("aria-hidden")}#X(q){this.#Z=!0,this.setAttribute("background",q.target.value),this.#Z=!1}get background(){return this.getAttribute("background")}set background(q){this.setAttribute("background",q)}focus(){this.input?.focus()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="background"){if(this.#Z){let $=/^(linear-gradient|radial-gradient|conic-gradient|repeating-|url)\s*\(/i.test(Z);this.style.setProperty("--swatch-background",$?Z:`linear-gradient(${Z}, ${Z})`);return}this.#_()}else if(q==="alpha")this.#$();else if(q==="disabled"||q==="aria-label"||q==="aria-labelledby"||q==="aria-describedby")this.#W()}get alpha(){return this.getAttribute("alpha")}set alpha(q){if(q===null||q===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",q)}}O("fig-swatch",M0);class $q extends M0{}O("fig-chit",$q);var Jq=["load","error"],jq=["loadstart","progress","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","durationchange","timeupdate","ratechange","resize","volumechange"],iq=[...new Set([...Jq,...jq])];class K0 extends HTMLElement{#Q=null;#q=null;#Z=null;#$=null;#J=null;#j=null;#N=null;#_=this.#s.bind(this);#W=this.#a.bind(this);#X=this.#Q0.bind(this);#U=this.#Z0.bind(this);#K=this.#d.bind(this);#G=null;#Y=null;#R=null;#z=void 0;#M=null;#L=null;#O=null;#H=null;#f=null;#T=null;#A=null;static get observedAttributes(){return["src","type","alt","upload","loading-indicator","label","aspect-ratio","fit","checkerboard","caption","controls","autoplay","loop","muted","poster","aria-label","aria-labelledby","title"]}get mediaKind(){return(this.getAttribute("type")||"image").toLowerCase()==="video"?"video":"image"}get src(){return this.#Q}set src(q){if(this.#Q=q||"",q===null||q===void 0||q==="")this.removeAttribute("src");else this.setAttribute("src",q)}get file(){return this.#N}#B(){return this.#j||this.#Q||""}async getBase64(){if(this.mediaKind!=="image")return null;if(!this.#B())return null;if(!this.#q)return null;try{if(typeof this.#q.decode==="function")await this.#q.decode();else if(!this.#q.complete)await new Promise(($,J)=>{this.#q.addEventListener("load",$,{once:!0}),this.#q.addEventListener("error",J,{once:!0})})}catch{}let q=this.#q.naturalWidth,Q=this.#q.naturalHeight;if(!(q>0)||!(Q>0))return null;let Z=document.createElement("canvas");return Z.width=q,Z.height=Q,Z.getContext("2d").drawImage(this.#q,0,0),Z.toDataURL()}connectedCallback(){this.#Q=this.getAttribute("src")||"";let q=this.getAttribute("aspect-ratio");if(q)this.style.setProperty("--fig-media-aspect-ratio",q);else this.style.setProperty("--fig-media-aspect-ratio","4/3");let Q=this.getAttribute("fit");if(Q)this.style.setProperty("--fig-media-fit",Q);if(this.querySelectorAll("fig-swatch[data-generated]").forEach(($)=>$.remove()),this.#I(),this.#C(),this.#P(),this.#v(),this.#V(),this.#w(),this.#b(),this.hasAttribute("upload")&&this.getAttribute("upload")!=="false"&&!this.querySelector("fig-input-file[data-generated]"))this.#c();this.#$=this.querySelector("fig-input-file[data-generated]"),this.#$?.removeEventListener("change",this.#_),this.#$?.addEventListener("change",this.#_)}disconnectedCallback(){if(this.#$?.removeEventListener("change",this.#_),this.#F(),this.#k(),this.#o(),this.#J)URL.revokeObjectURL(this.#J),this.#J=null;this.#j=null}#k(){if(!this.#q)return;if(iq.forEach((q)=>{this.#q.removeEventListener(q,this.#K)}),this.#q.tagName==="VIDEO")this.#q.removeEventListener("play",this.#W),this.#q.removeEventListener("pause",this.#X),this.#q.removeEventListener("ended",this.#U)}#P(){if(this.#k(),!this.#q)return;if((this.#q.tagName==="VIDEO"?jq:Jq).forEach((Q)=>{this.#q.addEventListener(Q,this.#K)}),this.#q.tagName!=="VIDEO")return;this.#q.addEventListener("play",this.#W),this.#q.addEventListener("pause",this.#X),this.#q.addEventListener("ended",this.#U)}#S(){return this.mediaKind==="image"&&this.getAttribute("loading-indicator")!=="false"&&this.#Z?.hasAttribute("data-generated")&&this.#q?.hasAttribute("data-generated")}#V(){let q=this.#B();if(!q||!this.#S()){this.#F();return}if(this.#q?.tagName==="IMG"&&this.#q.complete&&this.#q.currentSrc){this.#F();return}if(this.#R===q)return;this.#F(),this.#R=q,this.#z=this.getAttribute("aria-busy"),this.setAttribute("aria-busy","true"),this.#Y=setTimeout(()=>{if(this.#Y=null,this.#R!==q||!this.isConnected||!this.#S())return;let Q=document.createElement("fig-spinner");Q.setAttribute("data-generated",""),Q.setAttribute("data-loading-indicator",""),Q.setAttribute("slot","overlay"),Q.setAttribute("size","small"),Q.setAttribute("aria-hidden","true"),this.append(Q),this.#G=Q},150)}#F(){if(this.#Y!==null)clearTimeout(this.#Y),this.#Y=null;if(this.#G?.remove(),this.#G=null,this.#R=null,this.#z!==void 0){if(this.#z===null)this.removeAttribute("aria-busy");else this.setAttribute("aria-busy",this.#z);this.#z=void 0}}#I(){if(this.#Z?.isConnected)return;let q=this.querySelector(":scope > fig-preview");if(q){this.#Z=q;return}let Q=document.createElement("fig-preview");Q.setAttribute("data-generated",""),this.prepend(Q),this.#Z=Q}#D(){let q=this.mediaKind==="video"?"video":"img";return this.querySelector(`${q}:not([data-generated])`)}#C(){let q=this.#D();if(q){if(this.#I(),this.#q&&this.#q!==q){if(this.#k(),this.#q.hasAttribute("data-generated"))this.#q.remove()}if(this.#q=q,this.#Z&&q.parentElement!==this.#Z)this.#Z.append(q);this.#P(),this.#w();return}this.#I();let Q=this.mediaKind==="video"?"VIDEO":"IMG";if(this.#q&&this.#q.tagName!==Q){if(this.#k(),this.#q.hasAttribute("data-generated"))this.#q.remove();this.#q=null}if(this.#q)return;if(this.mediaKind==="video"){let Z=document.createElement("video");Z.setAttribute("data-generated",""),Z.className="fig-media-element",Z.setAttribute("playsinline",""),Z.preload="auto",this.#Z.append(Z),this.#q=Z;let $=()=>{if(this.#q?.autoplay)return;try{this.#q.currentTime=0.001}catch{}};this.#q.addEventListener("loadedmetadata",$,{once:!0})}else{let Z=document.createElement("img");Z.setAttribute("data-generated",""),Z.className="fig-media-element",Z.loading="lazy",Z.decoding="async",Z.alt=this.getAttribute("alt")||"",this.#Z.append(Z),this.#q=Z}this.#P()}#w(){if(!this.#q)return;if(this.#q.tagName==="IMG"){if(this.hasAttribute("alt")||this.#q.hasAttribute("data-generated"))this.#q.alt=this.getAttribute("alt")||"";return}if(this.#q.tagName!=="VIDEO")return;["aria-label","aria-labelledby","title"].forEach((q)=>{let Q=this.getAttribute(q);if(Q===null)this.#q.removeAttribute(q);else this.#q.setAttribute(q,Q)})}#y(){return this.querySelector(":scope > figcaption:not([data-generated])")}#m(){return Array.from(this.querySelectorAll(":scope > figcaption[data-generated]"))}#b(){let q=this.#y(),Q=this.#m();if(q){Q.forEach((j)=>j.remove());return}let Z=this.getAttribute("caption")||"";if(!Z){Q.forEach((j)=>j.remove());return}let $=Q[0]||document.createElement("figcaption");if(Q.slice(1).forEach((j)=>j.remove()),!$.hasAttribute("data-generated"))$.setAttribute("data-generated","");if($.textContent!==Z)$.textContent=Z;let J=this.querySelector(":scope > fig-media-controls");if(J)J.before($);else if(this.#Z?.isConnected)this.#Z.after($);else if(!$.isConnected)this.append($)}#E(q,Q=!1){if(!this.hasAttribute(q))return Q;return this.getAttribute(q)!=="false"}#v(){if(!this.#q)return;if(!this.#q.hasAttribute("data-generated"))return;let q=this.#B();if(this.#q.getAttribute("src")!==q){if(q)this.#q.setAttribute("src",q);else if(this.#q.removeAttribute("src"),this.#q.tagName==="VIDEO")this.#q.load()}if(this.#q.tagName==="IMG"){this.#w(),this.#V();return}let Q=this.getAttribute("poster");if(Q)this.#q.setAttribute("poster",Q);else this.#q.removeAttribute("poster");this.#q.controls=!1,this.#q.removeAttribute("controls"),this.#q.autoplay=this.#E("autoplay",!1),this.#q.loop=this.#E("loop",!1),this.#q.muted=this.#E("muted",!1),this.#q.playsInline=!0,this.#w(),this.#g(),this.#h(),this.#V()}get mediaEl(){return this.#q}#x(){if(this.mediaKind!=="video")return!1;return Boolean(this.#B())}#h(){let q=this.#M||this.querySelector(":scope > fig-media-controls");if(!q)return;if(this.mediaKind!=="video")return;if(this.#x()){if(q.hasAttribute("data-fig-empty-disabled"))q.removeAttribute("disabled"),q.removeAttribute("data-fig-empty-disabled");return}q.setAttribute("disabled",""),q.setAttribute("data-fig-empty-disabled",""),q.playing=!1,q.time=0,q.duration=0}#g(){if(this.mediaKind!=="video"){this.#o();return}let q=this.querySelector(":scope > fig-media-controls:not([data-generated])");if(q){if(this.#M!==q)this.#o(),this.#M=q;this.#l(),this.#h();return}if(this.#E("controls",!1))this.#r();else this.#o()}#r(){let q=Array.from(this.querySelectorAll(":scope > fig-media-controls[data-generated]")),Q=q[0];if(q.slice(1).forEach(($)=>$.remove()),Q){this.#M=Q,this.#l(),this.#h();return}let Z=document.createElement("fig-media-controls");Z.setAttribute("data-generated",""),this.append(Z),this.#M=Z,this.#l(),this.#h()}#l(){if(!this.#M||!this.#q)return;if(this.#L===this.#q&&this.#O===this.#M){this.#h();return}this.#u();let q=this.#M,Q=this.#q;this.#L=Q,this.#O=q;let Z=null,$=()=>{if(this.#h(),!this.#x())return;if(q.playing=!Q.paused&&!Q.ended,Number.isFinite(Q.duration))q.duration=Q.duration;if(Z!==null)if(Math.abs(Q.currentTime-Z)<0.25)Z=null;else return;q.time=Q.currentTime||0},J=()=>{if(!this.#x())return;let W=Q.play?.();if(W&&typeof W.catch==="function")W.catch(()=>{})},j=()=>Q.pause?.(),_=(W)=>{if(!this.#x())return;let N=Number(W?.detail?.time);if(!Number.isFinite(N))return;Z=N;try{Q.currentTime=N}catch{}};this.#H=$,this.#f=J,this.#T=j,this.#A=_,Q.addEventListener("play",$),Q.addEventListener("pause",$),Q.addEventListener("ended",$),Q.addEventListener("timeupdate",$),Q.addEventListener("loadedmetadata",$),Q.addEventListener("durationchange",$),Q.addEventListener("seeked",$),q.addEventListener("play",J),q.addEventListener("pause",j),q.addEventListener("seek",_),$()}#u(){let q=this.#L,Q=this.#O;if(q&&this.#H)q.removeEventListener("play",this.#H),q.removeEventListener("pause",this.#H),q.removeEventListener("ended",this.#H),q.removeEventListener("timeupdate",this.#H),q.removeEventListener("loadedmetadata",this.#H),q.removeEventListener("durationchange",this.#H),q.removeEventListener("seeked",this.#H);if(Q){if(this.#f)Q.removeEventListener("play",this.#f);if(this.#T)Q.removeEventListener("pause",this.#T);if(this.#A)Q.removeEventListener("seek",this.#A)}this.#L=null,this.#O=null,this.#H=null,this.#f=null,this.#T=null,this.#A=null}#o(){this.#u(),this.querySelectorAll(":scope > fig-media-controls[data-generated]").forEach((q)=>{q.remove()}),this.#M=null}toggle(){if(!this.#q||this.mediaKind!=="video")return;if(this.#q.paused||this.#q.ended)this.play();else this.pause()}play(){if(this.mediaKind!=="video"||!this.#q)return;let q=this.#q.play();if(q&&typeof q.catch==="function")q.catch(()=>{})}pause(){if(this.mediaKind!=="video"||!this.#q)return;this.#q.pause()}#c(){let q=document.createElement("fig-input-file");q.setAttribute("data-generated",""),q.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*"),q.setAttribute("variant","overlay");let Q=this.getAttribute("label")||"Upload";if(q.setAttribute("label",this.#Q?"Replace":Q),this.#N?.name)q.setAttribute("filename",this.#N.name);else if(this.#Q)q.setAttribute("url",this.#Q);q.addEventListener("change",this.#_),this.#I(),this.#Z.append(q),this.#$=q}#i(){if(this.#$)this.#$.removeEventListener("change",this.#_),this.#$.remove(),this.#$=null}#s(q){if(q.target!==this.#$)return;let Q=q.detail?.files?.[0],Z=q.detail?.cleared===!0;if(!Q){if(this.#J)URL.revokeObjectURL(this.#J),this.#J=null;if(this.#N=null,this.#j=null,Z)this.src="";if(this.#v(),this.#$){let $=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Q?"Replace":$),this.#$.removeAttribute("filename"),this.#Q)this.#$.setAttribute("url",this.#Q);else this.#$.removeAttribute("url")}this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}));return}if(this.#J)URL.revokeObjectURL(this.#J);if(this.#N=Q,this.#J=URL.createObjectURL(Q),this.#j=this.#J,this.#v(),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{file:Q,src:this.#J}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.#$)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",Q.name),this.#$.setAttribute("label","Replace")}#p(q){if(!this.#q)return;this.dispatchEvent(new CustomEvent(q,{bubbles:!0,cancelable:!1,composed:!0,detail:{src:this.#Q||"",currentTime:this.#q.currentTime,duration:this.#q.duration}}))}#d(q){let Q=this.#q;if(!Q||q.currentTarget!==Q)return;if(Q.tagName==="IMG"&&(q.type==="load"||q.type==="error"))this.#F();let Z={src:this.#B(),media:Q,originalEvent:q};if(Q.tagName==="VIDEO")Z.currentTime=Q.currentTime,Z.duration=Q.duration,Z.readyState=Q.readyState,Z.networkState=Q.networkState,Z.error=Q.error;this.dispatchEvent(new CustomEvent(q.type,{bubbles:!0,cancelable:!1,composed:!0,detail:Z}))}#a(){this.#p("play")}#Q0(){this.#p("pause")}#Z0(){this.#p("ended")}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="src"){let $=Z||"",J=$&&($===this.#j||$===this.#J);if(this.#Q=$,this.#J&&!J)URL.revokeObjectURL(this.#J),this.#J=null,this.#j=null,this.#N=null;if(this.#v(),this.#$){let j=this.getAttribute("label")||"Upload";if(this.#$.setAttribute("label",this.#Q?"Replace":j),this.#Q)if(this.#N?.name)this.#$.removeAttribute("url"),this.#$.setAttribute("filename",this.#N.name);else this.#$.setAttribute("url",this.#Q),this.#$.removeAttribute("filename");else this.#$.removeAttribute("url"),this.#$.removeAttribute("filename")}}if(q==="type"){if(this.#C(),this.#v(),this.#$)this.#$.setAttribute("accepts",this.mediaKind==="video"?"video/*":"image/*")}if(["alt","aria-label","aria-labelledby","title"].includes(q))this.#w();if(q==="upload"){let $=Z!==null&&Z!=="false";if($&&!this.#$)this.#c();else if(!$)this.#i()}if(q==="loading-indicator")this.#V();if(q==="aspect-ratio")if(Z)this.style.setProperty("--fig-media-aspect-ratio",Z);else this.style.removeProperty("--fig-media-aspect-ratio");if(q==="fit")if(Z)this.style.setProperty("--fig-media-fit",Z);else this.style.removeProperty("--fig-media-fit");if(q==="label"&&this.#$){let $=this.getAttribute("label")||"Upload";this.#$.setAttribute("label",this.#Q?"Replace":$)}if(["controls","autoplay","loop","muted","poster"].includes(q))this.#v();if(q==="caption")this.#b()}}O("fig-media",K0);class _q extends K0{get mediaKind(){return"image"}}O("fig-image",_q);class Wq extends K0{get mediaKind(){return"video"}}O("fig-video",Wq);class Nq extends HTMLElement{static get observedAttributes(){return["src","alt","label","text","sublabel","selected","disabled","full","size","aspect-ratio","fit","label-line-clamp"]}#Q=null;#q=null;#Z=null;#$=null;#J=!1;#j=new MutationObserver((q)=>{if(!q.some((Z)=>[...Z.addedNodes,...Z.removedNodes].some(($)=>$ instanceof Element&&($.matches("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])")||$.querySelector("fig-image:not([data-generated]), fig-media:not([data-generated]), fig-preview:not([data-generated]), fig-footer:not([data-generated])"))))||!this.isConnected)return;this.#G(),this.#R()});connectedCallback(){this.#j.observe(this,{childList:!0,subtree:!0}),this.#G(),this.#R()}disconnectedCallback(){this.#j.disconnect()}attributeChangedCallback(){if(!this.isConnected)return;this.#G(),this.#R()}#N(){return this.getAttribute("label")??this.getAttribute("text")??""}#_(){return this.getAttribute("sublabel")??""}#W(){return this.getAttribute("label-line-clamp")==="2"?"2":"1"}#X(){return Boolean(this.getAttribute("src"))}#U(){return this.querySelector(":scope > fig-image:not([data-generated]), :scope > fig-media:not([data-generated]), :scope > fig-preview:not([data-generated])")}#K(){this.querySelectorAll(":scope > .fig-card-link").forEach((q)=>{q.querySelectorAll(":scope > .fig-card-media").forEach((Q)=>{while(Q.firstChild)q.insertBefore(Q.firstChild,Q);Q.remove()});while(q.firstChild)this.insertBefore(q.firstChild,q);q.remove()})}#G(){if(this.#K(),!this.#X()){this.#Y();return}let q=this.#U();if(this.#J=Boolean(q),q)this.querySelectorAll(":scope > [data-generated]:not(fig-footer)").forEach((Z)=>Z.remove()),this.#q=null;if(!this.#J){if(this.#q=this.querySelector(":scope > fig-image[data-generated]")||null,!this.#q)this.querySelectorAll(":scope > fig-image, :scope > fig-media, :scope > fig-preview").forEach((Z)=>{if(Z.hasAttribute("data-generated"))Z.remove()}),this.#q=document.createElement("fig-image"),this.#q.setAttribute("data-generated",""),this.#q.setAttribute("full",""),this.#q.setAttribute("size","auto"),this.prepend(this.#q)}if(!Boolean(this.#N()||this.#_())){this.querySelector(":scope > fig-footer[data-generated]")?.remove(),this.#Q=null,this.#Z=null,this.#$=null;return}if(!this.#Q||!this.#Q.isConnected){if(this.#Q=this.querySelector(":scope > fig-footer[data-generated]"),!this.#Q)this.#Q=document.createElement("fig-footer"),this.#Q.setAttribute("data-generated",""),this.appendChild(this.#Q)}if(!this.#Z||!this.#Z.isConnected){if(this.#Z=this.#Q.querySelector(":scope > .fig-card-label[data-generated]"),!this.#Z)this.#Z=document.createElement("label"),this.#Z.className="fig-card-label",this.#Z.setAttribute("data-generated",""),this.#Q.appendChild(this.#Z)}if(!this.#$||!this.#$.isConnected){if(this.#$=this.#Q.querySelector(":scope > .fig-card-sublabel[data-generated]"),!this.#$)this.#$=document.createElement("label"),this.#$.className="fig-card-sublabel",this.#$.setAttribute("data-generated",""),this.#Z.after(this.#$)}}#Y(){if(this.#K(),this.querySelectorAll(":scope > [data-generated]").forEach((Q)=>Q.remove()),this.#q=null,this.#J=!0,this.#Q=null,this.#Z=null,this.#$=null,!this.#N()&&!this.#_())return;this.#Q=document.createElement("fig-footer"),this.#Q.setAttribute("data-generated",""),this.#Z=document.createElement("label"),this.#Z.className="fig-card-label",this.#Z.setAttribute("data-generated",""),this.#Q.appendChild(this.#Z);let q=this.#_();if(this.#$=null,q)this.#$=document.createElement("label"),this.#$.className="fig-card-sublabel",this.#$.setAttribute("data-generated",""),this.#Q.appendChild(this.#$);this.appendChild(this.#Q)}#R(){if(!this.#X()){this.#z();return}let q=T(this,"disabled"),Q=this.#N(),Z=this.#_(),$=this.#W();this.style.setProperty("--fig-card-label-line-clamp",$),this.setAttribute("role","group");let J=[Q,Z].filter(Boolean).join(", ");if(J)this.setAttribute("aria-label",J);else this.removeAttribute("aria-label");if(q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#q&&!this.#J){let j=this.getAttribute("src"),_=this.getAttribute("alt"),W=this.getAttribute("aspect-ratio")||"1/1",N=this.getAttribute("fit")||"contain",K=_!=null?_:"";if(j)this.#q.setAttribute("src",j);else this.#q.removeAttribute("src");this.#q.setAttribute("alt",K),this.#q.setAttribute("aspect-ratio",W),this.#q.setAttribute("fit",N),this.#q.setAttribute("full",""),this.#q.setAttribute("size","auto")}if(this.#Z)this.#Z.textContent=Q,this.#Z.hidden=!Q;if(this.#$)this.#$.textContent=Z,this.#$.hidden=!Z;if(this.#Q)this.#Q.hidden=!Q&&!Z}#z(){let q=T(this,"disabled"),Q=this.#N(),Z=this.#_();this.style.setProperty("--fig-card-label-line-clamp",this.#W()),this.setAttribute("role","group");let $=[Q,Z].filter(Boolean).join(", ");if($)this.setAttribute("aria-label",$);else this.removeAttribute("aria-label");if(q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");if(this.#Z)this.#Z.textContent=Q,this.#Z.hidden=!Q;if(this.#$)this.#$.textContent=Z}}O("fig-card",Nq);class Kq extends HTMLElement{#Q=null;#q=null;#Z=null;#$=null;#J=!1;#j=!1;static get observedAttributes(){return["playing","duration","time","disabled"]}connectedCallback(){this.#N(),this.#U(),this.#K(),this.#_()}get playing(){return this.hasAttribute("playing")&&this.getAttribute("playing")!=="false"}set playing(q){if(q)this.setAttribute("playing","");else this.removeAttribute("playing")}get duration(){let q=Number(this.getAttribute("duration"));return Number.isFinite(q)&&q>=0?q:0}set duration(q){let Q=Number(q);if(!Number.isFinite(Q)||Q<0){this.removeAttribute("duration");return}this.setAttribute("duration",String(Q))}get time(){let q=Number(this.getAttribute("time"));return Number.isFinite(q)&&q>=0?q:0}set time(q){let Q=Number(q);if(!Number.isFinite(Q)||Q<0){this.removeAttribute("time");return}this.setAttribute("time",String(Q))}get disabled(){return T(this,"disabled")}set disabled(q){if(q)this.setAttribute("disabled","");else this.removeAttribute("disabled")}attributeChangedCallback(q){if(!this.#j)return;if(q==="playing")this.#U();if(q==="duration"||q==="time")this.#K();if(q==="disabled")this.#_()}#N(){if(this.#j)return;if(this.#j=!0,!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Media controls");let q=document.createElement("fig-tooltip");q.setAttribute("text","Play");let Q=document.createElement("fig-button");Q.setAttribute("variant","ghost"),Q.setAttribute("size","small"),Q.setAttribute("icon","true"),Q.setAttribute("aria-label","Play");let Z=c("play",{className:"fig-media-controls-play-icon"});Q.append(Z),q.append(Q),Q.addEventListener("click",(_)=>{_.preventDefault(),_.stopPropagation(),this.toggle()});let $=document.createElement("fig-slider");$.setAttribute("text","false"),$.setAttribute("min","0"),$.setAttribute("max",String(this.duration)),$.setAttribute("step","1"),$.setAttribute("value",String(this.time)),$.setAttribute("full",""),$.setAttribute("aria-label","Seek"),$.setAttribute("aria-valuetext",this.#X(this.time,this.duration));let J=document.createElement("span");J.className="fig-media-controls-time",J.textContent=this.#W(this.time);let j=(_)=>{if(this.disabled){_.preventDefault?.(),_.stopPropagation();return}let W=_.currentTarget,N=Number(W?.value);if(!Number.isFinite(N))return;this.#J=!0,this.setAttribute("time",String(N)),this.dispatchEvent(new CustomEvent("seek",{bubbles:!0,composed:!0,detail:{time:N}})),requestAnimationFrame(()=>{this.#J=!1})};$.addEventListener("input",j),$.addEventListener("change",j),this.append(q,$,J),this.#Q=Q,this.#q=q,this.#Z=$,this.#$=J,this.#_()}#_(){let q=this.disabled;if(this.setAttribute("aria-disabled",q?"true":"false"),this.#Q)if(q)this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#Z)if(q)this.#Z.setAttribute("disabled","");else this.#Z.removeAttribute("disabled")}#W(q){if(!Number.isFinite(q)||q<0)q=0;let Q=Math.floor(q),Z=Math.floor(Q/60),$=Q%60;return`${String(Z).padStart(2,"0")}:${String($).padStart(2,"0")}`}#X(q,Q=0){let Z=this.#W(q);if(!Number.isFinite(Q)||Q<=0)return Z;return`${Z} of ${this.#W(Q)}`}#U(){if(!this.#Q)return;let q=this.playing;this.#Q.setAttribute("aria-label",q?"Pause":"Play"),this.#q?.setAttribute("text",q?"Pause":"Play");let Q=this.#Q.querySelector(".fig-media-controls-play-icon");if(Q)Q.setAttribute("name",q?"pause":"play")}#K(){if(!this.#Z)return;let q=this.duration;if(Number(this.#Z.getAttribute("max"))!==q)this.#Z.setAttribute("max",String(q));let Q=this.time;if(!this.#J)this.#Z.setAttribute("value",String(Q));if(this.#Z.setAttribute("aria-valuetext",this.#X(Q,q)),this.#$)this.#$.textContent=this.#W(Q)}toggle(){if(this.disabled)return;let q=!this.playing;this.playing=q,this.dispatchEvent(new CustomEvent(q?"play":"pause",{bubbles:!0,composed:!0,detail:{playing:q}}))}play(){if(this.disabled||this.playing)return;this.toggle()}pause(){if(this.disabled||!this.playing)return;this.toggle()}}O("fig-media-controls",Kq);class Gq extends HTMLElement{static observedAttributes=["accepts","label","disabled","multiple","variant","url","filename"];#Q=null;#q=null;#Z=null;#$=null;#J=null;#j=null;get files(){return this.#j}get#N(){let q=this.getAttribute("filename");if(q)return q;let Q=this.getAttribute("url");if(!Q)return"";try{let $=new URL(Q,location.href).pathname.split("/").pop();return $?decodeURIComponent($):Q}catch{return Q}}get value(){if(this.#j&&this.#j.length>0){if(this.#j.length===1)return this.#j[0].name;return`${this.#j.length} files`}return this.#N}connectedCallback(){this.#Y(),this.addEventListener("dragover",this.#U),this.addEventListener("dragleave",this.#K),this.addEventListener("drop",this.#G)}disconnectedCallback(){this.#Q?.removeEventListener("change",this.#W),this.#Z?.removeEventListener("click",this.#X),this.removeEventListener("dragover",this.#U),this.removeEventListener("dragleave",this.#K),this.removeEventListener("drop",this.#G)}attributeChangedCallback(q,Q,Z){if(Q===Z)return;this.#Y()}clear(){if(this.#j=null,this.#Q)this.#Q.value="";this.removeAttribute("url"),this.removeAttribute("filename"),this.#Y(),this.#_({cleared:!0})}#_(q={}){let Q={files:this.#j,...q};this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#W=()=>{if(this.#Q.files.length>0)this.#j=this.#Q.files,this.removeAttribute("url"),this.#Y(),this.#_()};#X=(q)=>{q.stopPropagation(),this.clear()};#U=(q)=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(q.preventDefault(),!this.hasAttribute("dragover")){if(this.setAttribute("dragover",""),this.#J)this.#J.dataset.prevText=this.#J.textContent,this.#J.textContent="Drop file"}};#K=()=>{if(this.removeAttribute("dragover"),this.#J&&this.#J.dataset.prevText!==void 0)this.#J.textContent=this.#J.dataset.prevText,delete this.#J.dataset.prevText};#G=(q)=>{if(q.preventDefault(),this.removeAttribute("dragover"),this.#J&&this.#J.dataset.prevText!==void 0)this.#J.textContent=this.#J.dataset.prevText,delete this.#J.dataset.prevText;if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.getAttribute("accepts"),Z=Array.from(q.dataTransfer.files);if(Q){let J=Q.split(",").map((j)=>j.trim().toLowerCase());Z=Z.filter((j)=>{let _="."+j.name.split(".").pop().toLowerCase(),W=j.type.toLowerCase();return J.some((N)=>N===_||N===W||N.endsWith("/*")&&W.startsWith(N.slice(0,-1)))})}if(!this.hasAttribute("multiple")||this.getAttribute("multiple")==="false")Z=Z.slice(0,1);if(Z.length===0)return;let $=new DataTransfer;if(Z.forEach((J)=>$.items.add(J)),this.#j=$.files,this.#Q)this.#Q.files=$.files;this.removeAttribute("url"),this.#Y(),this.#_()};#Y(){let q=this.getAttribute("accepts")||"",Q=this.getAttribute("label")||"Upload",Z=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",$=this.hasAttribute("multiple")&&this.getAttribute("multiple")!=="false",J=this.getAttribute("variant")||"input",j=this.#j&&this.#j.length>0||!!this.getAttribute("url")||!!this.getAttribute("filename");if(this.innerHTML="",j){let _=q?`Accepts ${q.split(",").map((U)=>U.trim()).join(", ")}`:"";if(this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant",J),this.#J.setAttribute("type","upload"),this.#J.className="fig-input-file-filename",Z)this.#J.setAttribute("disabled","");let W=document.createElement("fig-truncate");W.setAttribute("position","middle"),W.setAttribute("tooltip","");let N=this.value,K=N.lastIndexOf(".");if(K>0)W.setAttribute("tail",N.slice(K));if(W.textContent=N,this.#J.appendChild(W),this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",this.#Q.disabled=Z,q)this.#Q.setAttribute("accept",q);if($)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#W),this.#J.appendChild(this.#Q),_)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",_),this.#$.appendChild(this.#J),this.appendChild(this.#$);else this.appendChild(this.#J);let G=document.createElement("fig-tooltip");if(G.setAttribute("text","Remove"),this.#Z=document.createElement("fig-button"),this.#Z.setAttribute("variant",J==="overlay"?"overlay":"ghost"),this.#Z.setAttribute("icon","true"),this.#Z.setAttribute("aria-label","Remove"),this.#Z.className="fig-input-file-clear",Z)this.#Z.setAttribute("disabled","");this.#Z.replaceChildren(c("minus")),this.#Z.addEventListener("click",this.#X),G.appendChild(this.#Z),this.appendChild(G)}else{let _=q?`Accepts ${q.split(",").map((W)=>W.trim()).join(", ")}`:"";if(_)this.#$=document.createElement("fig-tooltip"),this.#$.setAttribute("text",_);if(this.#J=document.createElement("fig-button"),this.#J.setAttribute("variant",J),this.#J.setAttribute("type","upload"),this.#J.textContent=Q,Z)this.#J.setAttribute("disabled","");if(this.#Q=document.createElement("input"),this.#Q.type="file",this.#Q.title="",this.#Q.disabled=Z,q)this.#Q.setAttribute("accept",q);if($)this.#Q.setAttribute("multiple","");if(this.#Q.addEventListener("change",this.#W),this.#J.appendChild(this.#Q),this.#$)this.#$.appendChild(this.#J),this.appendChild(this.#$);else this.appendChild(this.#J)}}}O("fig-input-file",Gq);class E extends HTMLElement{#Q={x:0.42,y:0};#q={x:0.58,y:1};#Z={stiffness:200,damping:15,mass:1};#$="bezier";#J=2;#j=null;#N=null;#_=null;#W=null;#X=null;#U=null;#K=null;#G=null;#Y=null;#R=null;#z=null;#M=0.8;#L=200;#O=200;#H=null;#f=null;#T=null;#A=null;#B=5;#k=10;#P=10;#S=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio","edit"]}connectedCallback(){this.#J=parseInt(this.getAttribute("precision")||"2"),v(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));let q=this.getAttribute("value");if(q)this.#V(q);this.#R=this.#F(),this.#w(),this.#l()}disconnectedCallback(){if(this.#j=null,this.#A)this.#A.disconnect(),this.#A=null}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="aspect-ratio"){if(v(this,"--aspect-ratio",Z),this.#N)this.#u(),this.#d();return}if(q==="edit"){if(this.isConnected)this.#w();return}if(q==="value"&&Z){let $=this.#$;if(this.#V(Z),this.#R=this.#F(),$!==this.#$&&this.#C())this.#w();else{if(this.#N)this.#d();this.#q0(),this.#t()}}if(q==="precision")this.#J=parseInt(Z||"2")}get value(){if(this.#$==="spring"){let{stiffness:Q,damping:Z,mass:$}=this.#Z;return`spring(${Q}, ${Z}, ${$})`}let q=this.#J;return`${this.#Q.x.toFixed(q)}, ${this.#Q.y.toFixed(q)}, ${this.#q.x.toFixed(q)}, ${this.#q.y.toFixed(q)}`}get cssValue(){if(this.#$==="spring"){let Q=this.#I(),Z=20,$=Math.max(1,Math.floor(Q.length/20)),J=[];for(let j=0;j<Q.length;j+=$)J.push(Q[j].value.toFixed(3));if(Q.length>0)J.push(Q[Q.length-1].value.toFixed(3));return`linear(${J.join(", ")})`}let q=this.#J;return`cubic-bezier(${this.#Q.x.toFixed(q)}, ${this.#Q.y.toFixed(q)}, ${this.#q.x.toFixed(q)}, ${this.#q.y.toFixed(q)})`}get preset(){return this.#R}set value(q){this.setAttribute("value",q)}#V(q){let Q=q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if(Q)return this.#$="spring",this.#Z.stiffness=parseFloat(Q[1]),this.#Z.damping=parseFloat(Q[2]),this.#Z.mass=parseFloat(Q[3]),!0;let Z=q.split(",").map(($)=>parseFloat($.trim()));if(Z.length>=4&&Z.every(($)=>!isNaN($)))return this.#$="bezier",this.#Q.x=Z[0],this.#Q.y=Z[1],this.#q.x=Z[2],this.#q.y=Z[3],!0;return!1}#F(){if(this.#$==="bezier"){for(let Q of E.PRESETS){if(Q.type!=="bezier"||!Q.value)continue;if(Math.abs(this.#Q.x-Q.value[0])<0.001&&Math.abs(this.#Q.y-Q.value[1])<0.001&&Math.abs(this.#q.x-Q.value[2])<0.001&&Math.abs(this.#q.y-Q.value[3])<0.001)return Q.name}return"Custom bezier"}for(let Q of E.PRESETS){if(Q.type!=="spring"||!Q.spring)continue;if(Math.abs(this.#Z.stiffness-Q.spring.stiffness)<0.001&&Math.abs(this.#Z.damping-Q.spring.damping)<0.001&&Math.abs(this.#Z.mass-Q.spring.mass)<0.001)return Q.name}return"Custom spring"}#I(){let{stiffness:q,damping:Q,mass:Z}=this.#Z,$=0.004,J=5,j=[],_=0,W=0;for(let N=0;N<=5;N+=0.004){let K=-q*(_-1)-Q*W;if(W+=K/Z*0.004,_+=W*0.004,j.push({t:N,value:_}),N>0.1&&Math.abs(_-1)<0.0005&&Math.abs(W)<0.0005)break}return j}static#D(q,Q=24){let{stiffness:Z,damping:$,mass:J}=q,j=0.004,_=5,W=[],N=0,K=0;for(let A=0;A<=5;A+=0.004){let R=-Z*(N-1)-$*K;if(K+=R/J*0.004,N+=K*0.004,W.push({t:A,value:N}),A>0.1&&Math.abs(N-1)<0.001&&Math.abs(K)<0.001)break}let G=W[W.length-1].t||1,U=1;for(let A of W)if(A.value>U)U=A.value;let X=0;for(let A of W)if(A.value<X)X=A.value;let z=Math.max(U-X,1),B=6,L=Q-B*2,k=Math.max(1,Math.floor(W.length/30)),H="";for(let A=0;A<W.length;A+=k){let R=B+W[A].t/G*L,D=B+(1-(W[A].value-X)/z)*L;H+=(A===0?"M":"L")+R.toFixed(1)+","+D.toFixed(1)}return`<svg width="${Q}" height="${Q}" viewBox="0 0 ${Q} ${Q}" fill="none"><path d="${H}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(q,Q,Z,$,J=24){let _=(J-12)/2,W=48,N=[],K=(R,D,I,S,w)=>{let y=1-w;return y*y*y*R+3*y*y*w*D+3*y*w*w*I+w*w*w*S};for(let R=0;R<=48;R++){let D=R/48;N.push({x:K(0,q,Z,1,D),y:K(0,Q,$,1,D)})}let G=1/0,U=-1/0,X=1/0,z=-1/0;for(let R of N){if(R.x<G)G=R.x;if(R.x>U)U=R.x;if(R.y<X)X=R.y;if(R.y>z)z=R.y}let B=Math.max(U-G,0.000001),L=Math.max(z-X,0.000001),k=(R)=>_+(R-G)/B*12,H=(R)=>_+(1-(R-X)/L)*12,A="";for(let R=0;R<N.length;R++){let D=k(N[R].x),I=H(N[R].y);A+=`${R===0?"M":"L"}${D.toFixed(1)},${I.toFixed(1)}`}return`<svg width="${J}" height="${J}" viewBox="0 0 ${J} ${J}" fill="none"><path d="${A}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#C(){return this.getAttribute("edit")!=="false"}#w(){if(this.classList.toggle("spring-mode",this.#$==="spring"),this.classList.toggle("bezier-mode",this.#$!=="spring"),this.#h(),this.innerHTML=this.#v(),this.#g(),this.#N)this.#r(),this.#u(),this.#d();this.#t(),this.#L0()}static#y(q){return String(q).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}#m(){return["fig-select","fig-select-options","fig-select-option"].every((q)=>{let Q=customElements.get(q);return typeof Q==="function"&&Q.prototype instanceof HTMLElement})}#b(){let q="",Q=void 0,Z=!1;for(let J of E.PRESETS){if(!this.#C()&&!J.value&&!J.spring)continue;if(J.group!==Q){if(Z)q+="</optgroup>";if(Z=Boolean(J.group),Z)q+=`<optgroup label="${E.#y(J.group)}">`;Q=J.group}let j=E.#y(J.name);q+=`<option value="${j}">${j}</option>`}if(Z)q+="</optgroup>";return`<fig-dropdown class="fig-easing-curve-select" label="Easing preset" value="${E.#y(this.#R)}" full>${q}</fig-dropdown>`}#E(){if(!this.#m())return this.#b();let q="",Q=void 0;for(let $ of E.PRESETS){if(!this.#C()&&!$.value&&!$.spring)continue;if($.group!==Q){if($.group)q+=`<fig-separator label="${E.#y($.group)}"></fig-separator>`;Q=$.group}let J;if($.type==="spring"){let _=$.spring||this.#Z;J=E.#D(_)}else{let _=$.value||[this.#Q.x,this.#Q.y,this.#q.x,this.#q.y];J=E.curveIcon(..._)}let j=E.#y($.name);q+=`<fig-select-option value="${j}" label="${j}"><span slot="prepend">${J}</span><span>${j}</span></fig-select-option>`}return`<fig-select class="fig-easing-curve-select" label="Easing preset" value="${E.#y(this.#R)}" full><fig-select-options>${q}</fig-select-options></fig-select>`}#v(){let Q=this.#E();if(!this.#C())return Q;let Z=`<fig-input-text class="fig-easing-curve-value-input" value="${E.#y(this.value)}" full></fig-input-text>`;if(this.#$==="spring")return`${Q}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
|
|
190
190
|
<rect class="fig-easing-curve-bounds" x="0" y="0" width="200" height="200"/>
|
|
191
191
|
<line class="fig-easing-curve-target" x1="0" y1="40" x2="200" y2="40"/>
|
|
192
192
|
<path class="fig-easing-curve-path"/>
|
|
@@ -201,7 +201,7 @@ var wq=(q,Q)=>()=>(q&&(Q=q(q=0)),Q);var yq={};var D0=wq(()=>{/*! Vendored from @
|
|
|
201
201
|
<line class="fig-easing-curve-arm" data-arm="2"/>
|
|
202
202
|
<foreignObject class="fig-easing-curve-handle" data-handle="1" width="20" height="20"><fig-handle size="small" aria-label="First easing control point"></fig-handle></foreignObject>
|
|
203
203
|
<foreignObject class="fig-easing-curve-handle" data-handle="2" width="20" height="20"><fig-handle size="small" aria-label="Second easing control point"></fig-handle></foreignObject>
|
|
204
|
-
</svg></div>${Z}`}#x(q,Q){let Z=getComputedStyle(this).getPropertyValue(q).trim();if(!Z)return Q;let $=Number.parseFloat(Z);return Number.isFinite($)?$:Q}#v(){this.#C=this.#x("--easing-duration-bar-radius",this.#C)}#m(){this.#N=this.querySelector(".fig-easing-curve-svg"),this.#_=this.querySelector(".fig-easing-curve-path"),this.#W=this.querySelector('[data-arm="1"]'),this.#X=this.querySelector('[data-arm="2"]'),this.#G=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#K=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#U=this.querySelector(".fig-easing-curve-select"),this.#Y=this.querySelector(".fig-easing-curve-value-input"),this.#z=this.querySelector(".fig-easing-curve-target"),this.#H=this.querySelector(".fig-easing-curve-bounds"),this.#k=this.querySelector('[data-boundary="top"]'),this.#T=this.querySelector('[data-boundary="bottom"]')}#r(){let q=this.#G?.querySelector("fig-handle"),Q=this.#K?.querySelector("fig-handle");if(q){let Z=q.offsetWidth||this.#O*2,$=q.offsetHeight||this.#O*2;this.#O=Math.max(Z,$)/2,this.#G.setAttribute("width",Z),this.#G.setAttribute("height",$)}if(Q){let Z=Q.offsetWidth||this.#f,$=Q.offsetHeight||this.#D;if(this.#$==="spring")this.#f=Z,this.#D=$;this.#K.setAttribute("width",Z),this.#K.setAttribute("height",$)}}#l(){if(this.#A||!window.ResizeObserver)return;this.#A=new ResizeObserver(()=>{if(this.#u())this.#d()}),this.#A.observe(this)}#u(){if(!this.#N)return!1;let q=this.#N.getBoundingClientRect(),Q=Math.max(1,Math.round(q.width||200)),Z=Math.max(1,Math.round(q.height||200)),$=Q!==this.#L||Z!==this.#B;return this.#L=Q,this.#B=Z,this.#N.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#o(){let q=Math.min(0,this.#Q.y,this.#q.y),Q=Math.max(1,this.#Q.y,this.#q.y),Z=Q-q||1,$=Math.min(this.#O,Math.max(0,(this.#B-1)/2));return{minVal:q,maxVal:Q,range:Z,pad:$,draw:Math.max(1,this.#B-$*2)}}#c(q,Q){let{maxVal:Z,range:$,pad:J,draw:j}=this.#o();return{x:q*this.#L,y:J+(Z-Q)/$*j}}#i(q,Q){let{maxVal:Z,range:$,pad:J,draw:j}=this.#o();return{x:q/this.#L,y:Z-(Q-J)/j*$}}#s={minVal:0,maxVal:1.2,totalTime:1};#p(q,Q){let $=this.#B-40,{minVal:J,maxVal:j}=this.#s,_=j-J||1;return{x:q*this.#L,y:20+(1-(Q-J)/_)*$}}#d(){if(this.#u(),this.#$==="spring")this.#J0();else this.#Q0()}#a(){this.#W?.classList.toggle("is-active",this.#$==="bezier"&&this.#j===1),this.#X?.classList.toggle("is-active",this.#$==="bezier"&&this.#j===2)}#Q0(){if(this.#H)this.#H.setAttribute("x","0"),this.#H.setAttribute("y","0"),this.#H.setAttribute("width",this.#L),this.#H.setAttribute("height",this.#B);let q=this.#c(0,0),Q=this.#c(this.#Q.x,this.#Q.y),Z=this.#c(this.#q.x,this.#q.y),$=this.#c(1,1);for(let[j,_]of[[this.#k,$.y],[this.#T,q.y]]){if(!j)continue;j.setAttribute("x1","0"),j.setAttribute("y1",_),j.setAttribute("x2",this.#L),j.setAttribute("y2",_)}this.#_.setAttribute("d",`M${q.x},${q.y} C${Q.x},${Q.y} ${Z.x},${Z.y} ${$.x},${$.y}`),this.#W.setAttribute("x1",q.x),this.#W.setAttribute("y1",q.y),this.#W.setAttribute("x2",Q.x),this.#W.setAttribute("y2",Q.y),this.#X.setAttribute("x1",$.x),this.#X.setAttribute("y1",$.y),this.#X.setAttribute("x2",Z.x),this.#X.setAttribute("y2",Z.y);let J=this.#O;this.#G.setAttribute("x",Q.x-J),this.#G.setAttribute("y",Q.y-J),this.#K.setAttribute("x",Z.x-J),this.#K.setAttribute("y",Z.y-J),this.#Z0()}#Z0(){if(!this.#N||!this.#G||!this.#K)return;let q=this.#Q.y>=this.#q.y?[this.#G,this.#K]:[this.#K,this.#G];for(let Q of q)this.#N.append(Q)}#J0(){if(this.#H)this.#H.setAttribute("x","0"),this.#H.setAttribute("y","0"),this.#H.setAttribute("width",this.#L),this.#H.setAttribute("height",this.#B);let q=this.#I();if(!q.length)return;let Q=q[q.length-1].t||1,Z=0,$=1;for(let L of q){if(L.value<Z)Z=L.value;if(L.value>$)$=L.value}let J=Math.max(Math.abs(Z-1),Math.abs($-1),0.01),j=0;this.#s={minVal:1-J-j,maxVal:1+J+j,totalTime:Q};let _=Math.max(0.05,Math.min(0.95,this.#M)),W="";for(let L=0;L<q.length;L++){let k=q[L].t/Q*_,H=this.#p(k,q[L].value);W+=(L===0?"M":"L")+H.x.toFixed(1)+","+H.y.toFixed(1)}let N=this.#p(_,1),K=this.#p(1,1);if(W+=`L${N.x.toFixed(1)},${N.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#_.setAttribute("d",W),this.#z){let L=this.#p(0,1),k=this.#p(1,1);this.#z.setAttribute("x1",L.x),this.#z.setAttribute("y1",L.y),this.#z.setAttribute("x2",k.x),this.#z.setAttribute("y2",k.y)}let G=this.#j0(q),U=G.t/Q*_,X=this.#p(U,G.value),z=this.#O;this.#G.setAttribute("x",X.x-z),this.#G.setAttribute("y",X.y-z);let B=this.#p(_,1);this.#K.setAttribute("x",B.x-this.#f/2),this.#K.setAttribute("y",B.y-this.#D/2)}#j0(q){let Q={t:0,value:1},Z=!1;for(let $ of q){if($.value>=0.99)Z=!0;if(Z&&$.value>Q.value)Q={t:$.t,value:$.value}}return Q}#q0(){if(!this.#U)return;this.#U.value=this.#R,this.#X0()}#t(){if(!this.#Y)return;this.#Y.setAttribute("value",this.value)}#$0(q){let Q=q.split(",").map((Z)=>Number.parseFloat(Z.trim()));if(Q.length!==4||Q.some((Z)=>!Number.isFinite(Z)))return null;if(Q[0]<0||Q[0]>1||Q[2]<0||Q[2]>1)return null;return Q}#e(q,Q){let Z=this.#$0(q);if(!Z){if(Q==="change")this.#t();return}let $=this.#$;if(this.#$="bezier",this.#Q.x=Z[0],this.#Q.y=Z[1],this.#q.x=Z[2],this.#q.y=Z[3],this.#R=this.#F(),$!==this.#$)this.#w();else if(this.#d(),this.#q0(),Q==="change")this.#t();this.#n(Q)}#K0(q,Q){if(!this.#U)return;for(let Z of this.#U.querySelectorAll("fig-select-option"))if(Z.value===q){let $=Z.querySelector(':scope > [slot="prepend"]');if($)$.innerHTML=Q}}#X0(){if(!this.#U)return;if(!this.#S())return;let q=E.curveIcon(this.#Q.x,this.#Q.y,this.#q.x,this.#q.y),Q=E.#P(this.#Z);this.#K0("Custom bezier",q),this.#K0("Custom spring",Q)}#G0(q){this.#d(),this.#R=this.#F(),this.#q0(),this.#t(),this.#n(q)}#Y0(q,Q){let Z=q.shiftKey?0.1:0.01,$=Q===1?this.#Q:this.#q;switch(q.key){case"ArrowLeft":$.x-=Z;break;case"ArrowRight":$.x+=Z;break;case"ArrowUp":$.y+=Z;break;case"ArrowDown":$.y-=Z;break;case"Home":$.x=0,$.y=0;break;case"End":$.x=1,$.y=1;break;default:return!1}return $.x=Math.max(0,Math.min(1,Math.round($.x*100)/100)),$.y=Math.round($.y*100)/100,this.#G0("input"),this.#n("change"),!0}#R0(q,Q){let Z=q.shiftKey?10:1;if(Q==="bounce")switch(q.key){case"ArrowUp":this.#Z.damping=Math.max(1,Math.round(this.#Z.damping-Z));break;case"ArrowDown":this.#Z.damping=Math.max(1,Math.round(this.#Z.damping+Z));break;case"Home":this.#Z.damping=1;break;case"End":this.#Z.damping=50;break;default:return!1}else{let $=Z*2;switch(q.key){case"ArrowLeft":this.#M=Math.max(0.05,this.#M-$/200),this.#Z.stiffness=Math.max(10,Math.round(this.#Z.stiffness+$*1.5));break;case"ArrowRight":this.#M=Math.min(0.95,this.#M+$/200),this.#Z.stiffness=Math.max(10,Math.round(this.#Z.stiffness-$*1.5));break;case"Home":this.#M=0.05;break;case"End":this.#M=0.95;break;default:return!1}}return this.#G0("input"),this.#n("change"),!0}#_0(q,Q){let Z=q?.querySelector("fig-handle");if(!Z)return;Z.addEventListener("pointerdown",($)=>{if($.preventDefault(),$.stopImmediatePropagation(),this.#$==="bezier")this.#W0($,Number(Q));else this.#N0($,Q)},{capture:!0}),Z.addEventListener("keydown",($)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!(this.#$==="bezier"?this.#Y0($,Number(Q)):this.#R0($,Q)))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#n(q){this.dispatchEvent(new CustomEvent(q,{bubbles:!0,detail:{mode:this.#$,value:this.value,cssValue:this.cssValue,preset:this.#R}}))}#L0(){if(this.#N&&this.#$==="bezier"){this.#_0(this.#G,"1"),this.#_0(this.#K,"2"),this.#G.addEventListener("pointerdown",(Q)=>this.#W0(Q,1)),this.#K.addEventListener("pointerdown",(Q)=>this.#W0(Q,2));let q=this.querySelector(".fig-easing-curve-svg-container");if(q)q.addEventListener("pointerdown",(Q)=>{if(Q.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#W0(Q,this.#B0(Q))})}else if(this.#N){this.#_0(this.#G,"bounce"),this.#_0(this.#K,"duration"),this.#G.addEventListener("pointerdown",(Q)=>{Q.stopPropagation(),this.#N0(Q,"bounce")}),this.#K.addEventListener("pointerdown",(Q)=>{Q.stopPropagation(),this.#N0(Q,"duration")});let q=this.querySelector(".fig-easing-curve-svg-container");if(q)q.addEventListener("pointerdown",(Q)=>{if(Q.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#N0(Q,"duration")})}if(this.#U)this.#U.addEventListener("change",(q)=>{let Q=q.detail,Z=E.PRESETS.find(($)=>$.name===Q);if(!Z)return;if(Z.type==="bezier"){if(Z.value)this.#Q.x=Z.value[0],this.#Q.y=Z.value[1],this.#q.x=Z.value[2],this.#q.y=Z.value[3];if(this.#R=Q,this.#$!=="bezier")this.#$="bezier",this.#w();else if(this.#N)this.#d(),this.#t()}else if(Z.type==="spring"){if(Z.spring)this.#Z={...Z.spring};if(this.#R=Q,this.#$!=="spring")this.#$="spring",this.#w();else if(this.#N)this.#d(),this.#t()}this.#n("input"),this.#n("change")});if(this.#Y)this.#Y.addEventListener("input",(q)=>{q.stopPropagation();let Q=q.detail??q.target?.value;if(typeof Q!=="string")return;this.#e(Q,"input")}),this.#Y.addEventListener("change",(q)=>{q.stopPropagation();let Q=q.detail??q.target?.value;if(typeof Q!=="string")return;this.#e(Q,"change")})}#U0(q){let Q=this.#N.getScreenCTM();if(!Q)return{x:0,y:0};let Z=Q.inverse();return{x:Z.a*q.clientX+Z.c*q.clientY+Z.e,y:Z.b*q.clientX+Z.d*q.clientY+Z.f}}#B0(q){return this.#U0(q).x<=this.#L/2?1:2}#W0(q,Q){q.preventDefault(),this.#j=Q,this.#a();let Z=this.#N.getBoundingClientRect(),$=q.clientX,J=q.clientY,j=q.target?.closest?.(".fig-easing-curve-handle, fig-handle"),_=Q===1?this.#Q:this.#q,W=this.#U0(q),N=j?{..._}:this.#i(W.x,W.y),{range:K,draw:G}=this.#o(),U=K/Math.max(1,G/this.#B*Math.max(1,Z.height)),X=(B)=>{if(!this.#j)return;let L={x:N.x+(B.clientX-$)/Math.max(1,Z.width),y:N.y-(B.clientY-J)*U};if(L.x=Math.round(L.x*100)/100,L.y=Math.round(L.y*100)/100,L.x=Math.max(0,Math.min(1,L.x)),this.#j===1)this.#Q.x=L.x,this.#Q.y=L.y;else this.#q.x=L.x,this.#q.y=L.y;this.#d(),this.#R=this.#F(),this.#q0(),this.#t(),this.#n("input")},z=()=>{this.#j=null,this.#a(),document.removeEventListener("pointermove",X),document.removeEventListener("pointerup",z),this.#n("change")};document.addEventListener("pointermove",X),document.addEventListener("pointerup",z)}#N0(q,Q){q.preventDefault(),this.#j=Q,this.classList.toggle("spring-bounce-dragging",Q==="bounce");let Z=this.#Z.damping,$=this.#Z.stiffness,J=this.#M,j=q.clientY,_=q.clientX,W=(K)=>{if(!this.#j)return;if(Q==="bounce"){let G=K.clientY-j;this.#Z.damping=Math.max(1,Math.round(Z+G*0.15))}else{let G=K.clientX-_;this.#M=Math.max(0.05,Math.min(0.95,J+G/200)),this.#Z.stiffness=Math.max(10,Math.round($-G*1.5))}this.#d(),this.#R=this.#F(),this.#q0(),this.#t(),this.#n("input")},N=()=>{this.#j=null,this.classList.remove("spring-bounce-dragging"),document.removeEventListener("pointermove",W),document.removeEventListener("pointerup",N),this.#n("change")};document.addEventListener("pointermove",W),document.addEventListener("pointerup",N)}}O("fig-easing-curve",E);class Uq extends HTMLElement{#Q=0;#q=0;#Z=0;#$=1;#J=!1;#j=!1;#N=null;#_=null;#W=null;#X=null;#G=(q)=>this.#P(q);#K=null;#U=[];#Y={};#R={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#$=parseInt(this.getAttribute("precision")||"1"),v(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),v(this,"--perspective",this.getAttribute("perspective")),v(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#L(this.getAttribute("transform-origin")),this.#k(this.getAttribute("fields"));let q=this.getAttribute("value");if(q)this.#T(q);if(this.querySelector(".fig-3d-rotate-container"))this.#z();else this.#A();this.#H(this.getAttribute("selected")),this.#B()}disconnectedCallback(){this.#J=!1,this.#M()}#z(){this.#_=this.querySelector(".fig-3d-rotate-container"),this.#N=this.querySelector(".fig-3d-rotate-cube"),this.#O(),this.#D(),this.#F()}#M(){if(this.#K?.abort(),this.#K=null,this.#W)window.removeEventListener("keydown",this.#W),window.removeEventListener("keyup",this.#X),this.#W=null,this.#X=null}#L(q){if(!q||!q.trim()){this.style.removeProperty("--transform-origin");return}let Q=q.trim().split(/\s+/);if(Q.length===2)this.style.setProperty("--transform-origin",`${Q[0]} ${Q[1]} -50cqi`);else this.style.setProperty("--transform-origin",q.trim())}#B(){if(!this.#_)return;this.#_.style.cursor=this.#I?"":"default"}#H(q){if(!this.#N)return;let Q=this.#N.querySelectorAll(".fig-3d-rotate-face"),Z=q?q.trim().toLowerCase():"";for(let $ of Q)$.classList.toggle("selected",Z!==""&&$.classList.contains(Z))}#k(q){if(!q||!q.trim()){this.#U=[];return}let Q=["rotateX","rotateY","rotateZ"];this.#U=q.split(",").map((Z)=>Z.trim()).filter((Z)=>Q.includes(Z))}attributeChangedCallback(q,Q,Z){if(q==="aspect-ratio"){v(this,"--aspect-ratio",Z);return}if(q==="perspective"){v(this,"--perspective",Z);return}if(q==="perspective-origin"){v(this,"--perspective-origin",Z);return}if(q==="transform-origin"){this.#L(Z);return}if(q==="selected"){this.#H(Z);return}if(q==="drag"){this.#B();return}if(q==="fields"){if(this.#k(Z),this.#N)this.#A();return}if(!this.#N)return;if(q==="value"&&Z){if(this.#J)return;this.#T(Z),this.#D(),this.#f()}if(q==="precision")this.#$=parseInt(Z||"1")}get value(){let q=this.#$;return`rotateX(${this.#Q.toFixed(q)}deg) rotateY(${this.#q.toFixed(q)}deg) rotateZ(${this.#Z.toFixed(q)}deg)`}set value(q){this.setAttribute("value",q)}get rotateX(){return this.#Q}get rotateY(){return this.#q}get rotateZ(){return this.#Z}#T(q){let Q=q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),Z=q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),$=q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if(Q)this.#Q=parseFloat(Q[1]);if(Z)this.#q=parseFloat(Z[1]);if($)this.#Z=parseFloat($[1])}#A(){let q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},Q={rotateX:this.#Q,rotateY:this.#q,rotateZ:this.#Z},Z=this.#U.map(($)=>`<fig-input-number
|
|
204
|
+
</svg></div>${Z}`}#x(q,Q){let Z=getComputedStyle(this).getPropertyValue(q).trim();if(!Z)return Q;let $=Number.parseFloat(Z);return Number.isFinite($)?$:Q}#h(){this.#S=this.#x("--easing-duration-bar-radius",this.#S)}#g(){this.#N=this.querySelector(".fig-easing-curve-svg"),this.#_=this.querySelector(".fig-easing-curve-path"),this.#W=this.querySelector('[data-arm="1"]'),this.#X=this.querySelector('[data-arm="2"]'),this.#U=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#K=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#G=this.querySelector(".fig-easing-curve-select"),this.#Y=this.querySelector(".fig-easing-curve-value-input"),this.#z=this.querySelector(".fig-easing-curve-target"),this.#H=this.querySelector(".fig-easing-curve-bounds"),this.#f=this.querySelector('[data-boundary="top"]'),this.#T=this.querySelector('[data-boundary="bottom"]')}#r(){let q=this.#U?.querySelector("fig-handle"),Q=this.#K?.querySelector("fig-handle");if(q){let Z=q.offsetWidth||this.#B*2,$=q.offsetHeight||this.#B*2;this.#B=Math.max(Z,$)/2,this.#U.setAttribute("width",Z),this.#U.setAttribute("height",$)}if(Q){let Z=Q.offsetWidth||this.#k,$=Q.offsetHeight||this.#P;if(this.#$==="spring")this.#k=Z,this.#P=$;this.#K.setAttribute("width",Z),this.#K.setAttribute("height",$)}}#l(){if(this.#A||!window.ResizeObserver)return;this.#A=new ResizeObserver(()=>{if(this.#u())this.#d()}),this.#A.observe(this)}#u(){if(!this.#N)return!1;let q=this.#N.getBoundingClientRect(),Q=Math.max(1,Math.round(q.width||200)),Z=Math.max(1,Math.round(q.height||200)),$=Q!==this.#L||Z!==this.#O;return this.#L=Q,this.#O=Z,this.#N.setAttribute("viewBox",`0 0 ${Q} ${Z}`),$}#o(){let q=Math.min(0,this.#Q.y,this.#q.y),Q=Math.max(1,this.#Q.y,this.#q.y),Z=Q-q||1,$=Math.min(this.#B,Math.max(0,(this.#O-1)/2));return{minVal:q,maxVal:Q,range:Z,pad:$,draw:Math.max(1,this.#O-$*2)}}#c(q,Q){let{maxVal:Z,range:$,pad:J,draw:j}=this.#o();return{x:q*this.#L,y:J+(Z-Q)/$*j}}#i(q,Q){let{maxVal:Z,range:$,pad:J,draw:j}=this.#o();return{x:q/this.#L,y:Z-(Q-J)/j*$}}#s={minVal:0,maxVal:1.2,totalTime:1};#p(q,Q){let $=this.#O-40,{minVal:J,maxVal:j}=this.#s,_=j-J||1;return{x:q*this.#L,y:20+(1-(Q-J)/_)*$}}#d(){if(this.#u(),this.#$==="spring")this.#J0();else this.#Q0()}#a(){this.#W?.classList.toggle("is-active",this.#$==="bezier"&&this.#j===1),this.#X?.classList.toggle("is-active",this.#$==="bezier"&&this.#j===2)}#Q0(){if(this.#H)this.#H.setAttribute("x","0"),this.#H.setAttribute("y","0"),this.#H.setAttribute("width",this.#L),this.#H.setAttribute("height",this.#O);let q=this.#c(0,0),Q=this.#c(this.#Q.x,this.#Q.y),Z=this.#c(this.#q.x,this.#q.y),$=this.#c(1,1);for(let[j,_]of[[this.#f,$.y],[this.#T,q.y]]){if(!j)continue;j.setAttribute("x1","0"),j.setAttribute("y1",_),j.setAttribute("x2",this.#L),j.setAttribute("y2",_)}this.#_.setAttribute("d",`M${q.x},${q.y} C${Q.x},${Q.y} ${Z.x},${Z.y} ${$.x},${$.y}`),this.#W.setAttribute("x1",q.x),this.#W.setAttribute("y1",q.y),this.#W.setAttribute("x2",Q.x),this.#W.setAttribute("y2",Q.y),this.#X.setAttribute("x1",$.x),this.#X.setAttribute("y1",$.y),this.#X.setAttribute("x2",Z.x),this.#X.setAttribute("y2",Z.y);let J=this.#B;this.#U.setAttribute("x",Q.x-J),this.#U.setAttribute("y",Q.y-J),this.#K.setAttribute("x",Z.x-J),this.#K.setAttribute("y",Z.y-J),this.#Z0()}#Z0(){if(!this.#N||!this.#U||!this.#K)return;let q=this.#Q.y>=this.#q.y?[this.#U,this.#K]:[this.#K,this.#U];for(let Q of q)this.#N.append(Q)}#J0(){if(this.#H)this.#H.setAttribute("x","0"),this.#H.setAttribute("y","0"),this.#H.setAttribute("width",this.#L),this.#H.setAttribute("height",this.#O);let q=this.#I();if(!q.length)return;let Q=q[q.length-1].t||1,Z=0,$=1;for(let L of q){if(L.value<Z)Z=L.value;if(L.value>$)$=L.value}let J=Math.max(Math.abs(Z-1),Math.abs($-1),0.01),j=0;this.#s={minVal:1-J-j,maxVal:1+J+j,totalTime:Q};let _=Math.max(0.05,Math.min(0.95,this.#M)),W="";for(let L=0;L<q.length;L++){let k=q[L].t/Q*_,H=this.#p(k,q[L].value);W+=(L===0?"M":"L")+H.x.toFixed(1)+","+H.y.toFixed(1)}let N=this.#p(_,1),K=this.#p(1,1);if(W+=`L${N.x.toFixed(1)},${N.y.toFixed(1)} L${K.x.toFixed(1)},${K.y.toFixed(1)}`,this.#_.setAttribute("d",W),this.#z){let L=this.#p(0,1),k=this.#p(1,1);this.#z.setAttribute("x1",L.x),this.#z.setAttribute("y1",L.y),this.#z.setAttribute("x2",k.x),this.#z.setAttribute("y2",k.y)}let G=this.#j0(q),U=G.t/Q*_,X=this.#p(U,G.value),z=this.#B;this.#U.setAttribute("x",X.x-z),this.#U.setAttribute("y",X.y-z);let B=this.#p(_,1);this.#K.setAttribute("x",B.x-this.#k/2),this.#K.setAttribute("y",B.y-this.#P/2)}#j0(q){let Q={t:0,value:1},Z=!1;for(let $ of q){if($.value>=0.99)Z=!0;if(Z&&$.value>Q.value)Q={t:$.t,value:$.value}}return Q}#q0(){if(!this.#G)return;this.#G.value=this.#R,this.#X0()}#t(){if(!this.#Y)return;this.#Y.setAttribute("value",this.value)}#$0(q){let Q=q.split(",").map((Z)=>Number.parseFloat(Z.trim()));if(Q.length!==4||Q.some((Z)=>!Number.isFinite(Z)))return null;if(Q[0]<0||Q[0]>1||Q[2]<0||Q[2]>1)return null;return Q}#e(q,Q){let Z=this.#$0(q);if(!Z){if(Q==="change")this.#t();return}let $=this.#$;if(this.#$="bezier",this.#Q.x=Z[0],this.#Q.y=Z[1],this.#q.x=Z[2],this.#q.y=Z[3],this.#R=this.#F(),$!==this.#$)this.#w();else if(this.#d(),this.#q0(),Q==="change")this.#t();this.#n(Q)}#K0(q,Q){if(!this.#G)return;for(let Z of this.#G.querySelectorAll("fig-select-option"))if(Z.value===q){let $=Z.querySelector(':scope > [slot="prepend"]');if($)$.innerHTML=Q}}#X0(){if(!this.#G)return;if(!this.#C())return;let q=E.curveIcon(this.#Q.x,this.#Q.y,this.#q.x,this.#q.y),Q=E.#D(this.#Z);this.#K0("Custom bezier",q),this.#K0("Custom spring",Q)}#G0(q){this.#d(),this.#R=this.#F(),this.#q0(),this.#t(),this.#n(q)}#Y0(q,Q){let Z=q.shiftKey?0.1:0.01,$=Q===1?this.#Q:this.#q;switch(q.key){case"ArrowLeft":$.x-=Z;break;case"ArrowRight":$.x+=Z;break;case"ArrowUp":$.y+=Z;break;case"ArrowDown":$.y-=Z;break;case"Home":$.x=0,$.y=0;break;case"End":$.x=1,$.y=1;break;default:return!1}return $.x=Math.max(0,Math.min(1,Math.round($.x*100)/100)),$.y=Math.round($.y*100)/100,this.#G0("input"),this.#n("change"),!0}#R0(q,Q){let Z=q.shiftKey?10:1;if(Q==="bounce")switch(q.key){case"ArrowUp":this.#Z.damping=Math.max(1,Math.round(this.#Z.damping-Z));break;case"ArrowDown":this.#Z.damping=Math.max(1,Math.round(this.#Z.damping+Z));break;case"Home":this.#Z.damping=1;break;case"End":this.#Z.damping=50;break;default:return!1}else{let $=Z*2;switch(q.key){case"ArrowLeft":this.#M=Math.max(0.05,this.#M-$/200),this.#Z.stiffness=Math.max(10,Math.round(this.#Z.stiffness+$*1.5));break;case"ArrowRight":this.#M=Math.min(0.95,this.#M+$/200),this.#Z.stiffness=Math.max(10,Math.round(this.#Z.stiffness-$*1.5));break;case"Home":this.#M=0.05;break;case"End":this.#M=0.95;break;default:return!1}}return this.#G0("input"),this.#n("change"),!0}#_0(q,Q){let Z=q?.querySelector("fig-handle");if(!Z)return;Z.addEventListener("pointerdown",($)=>{if($.preventDefault(),$.stopImmediatePropagation(),this.#$==="bezier")this.#W0($,Number(Q));else this.#N0($,Q)},{capture:!0}),Z.addEventListener("keydown",($)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes($.key))return;if(!(this.#$==="bezier"?this.#Y0($,Number(Q)):this.#R0($,Q)))return;$.preventDefault(),$.stopImmediatePropagation()},{capture:!0})}#n(q){this.dispatchEvent(new CustomEvent(q,{bubbles:!0,detail:{mode:this.#$,value:this.value,cssValue:this.cssValue,preset:this.#R}}))}#L0(){if(this.#N&&this.#$==="bezier"){this.#_0(this.#U,"1"),this.#_0(this.#K,"2"),this.#U.addEventListener("pointerdown",(Q)=>this.#W0(Q,1)),this.#K.addEventListener("pointerdown",(Q)=>this.#W0(Q,2));let q=this.querySelector(".fig-easing-curve-svg-container");if(q)q.addEventListener("pointerdown",(Q)=>{if(Q.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#W0(Q,this.#B0(Q))})}else if(this.#N){this.#_0(this.#U,"bounce"),this.#_0(this.#K,"duration"),this.#U.addEventListener("pointerdown",(Q)=>{Q.stopPropagation(),this.#N0(Q,"bounce")}),this.#K.addEventListener("pointerdown",(Q)=>{Q.stopPropagation(),this.#N0(Q,"duration")});let q=this.querySelector(".fig-easing-curve-svg-container");if(q)q.addEventListener("pointerdown",(Q)=>{if(Q.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#N0(Q,"duration")})}if(this.#G)this.#G.addEventListener("change",(q)=>{let Q=q.detail,Z=E.PRESETS.find(($)=>$.name===Q);if(!Z)return;if(Z.type==="bezier"){if(Z.value)this.#Q.x=Z.value[0],this.#Q.y=Z.value[1],this.#q.x=Z.value[2],this.#q.y=Z.value[3];if(this.#R=Q,this.#$!=="bezier")this.#$="bezier",this.#w();else if(this.#N)this.#d(),this.#t()}else if(Z.type==="spring"){if(Z.spring)this.#Z={...Z.spring};if(this.#R=Q,this.#$!=="spring")this.#$="spring",this.#w();else if(this.#N)this.#d(),this.#t()}this.#n("input"),this.#n("change")});if(this.#Y)this.#Y.addEventListener("input",(q)=>{q.stopPropagation();let Q=q.detail??q.target?.value;if(typeof Q!=="string")return;this.#e(Q,"input")}),this.#Y.addEventListener("change",(q)=>{q.stopPropagation();let Q=q.detail??q.target?.value;if(typeof Q!=="string")return;this.#e(Q,"change")})}#U0(q){let Q=this.#N.getScreenCTM();if(!Q)return{x:0,y:0};let Z=Q.inverse();return{x:Z.a*q.clientX+Z.c*q.clientY+Z.e,y:Z.b*q.clientX+Z.d*q.clientY+Z.f}}#B0(q){return this.#U0(q).x<=this.#L/2?1:2}#W0(q,Q){q.preventDefault(),this.#j=Q,this.#a();let Z=this.#N.getBoundingClientRect(),$=q.clientX,J=q.clientY,j=q.target?.closest?.(".fig-easing-curve-handle, fig-handle"),_=Q===1?this.#Q:this.#q,W=this.#U0(q),N=j?{..._}:this.#i(W.x,W.y),{range:K,draw:G}=this.#o(),U=K/Math.max(1,G/this.#O*Math.max(1,Z.height)),X=(B)=>{if(!this.#j)return;let L={x:N.x+(B.clientX-$)/Math.max(1,Z.width),y:N.y-(B.clientY-J)*U};if(L.x=Math.round(L.x*100)/100,L.y=Math.round(L.y*100)/100,L.x=Math.max(0,Math.min(1,L.x)),this.#j===1)this.#Q.x=L.x,this.#Q.y=L.y;else this.#q.x=L.x,this.#q.y=L.y;this.#d(),this.#R=this.#F(),this.#q0(),this.#t(),this.#n("input")},z=()=>{this.#j=null,this.#a(),document.removeEventListener("pointermove",X),document.removeEventListener("pointerup",z),this.#n("change")};document.addEventListener("pointermove",X),document.addEventListener("pointerup",z)}#N0(q,Q){q.preventDefault(),this.#j=Q,this.classList.toggle("spring-bounce-dragging",Q==="bounce");let Z=this.#Z.damping,$=this.#Z.stiffness,J=this.#M,j=q.clientY,_=q.clientX,W=(K)=>{if(!this.#j)return;if(Q==="bounce"){let G=K.clientY-j;this.#Z.damping=Math.max(1,Math.round(Z+G*0.15))}else{let G=K.clientX-_;this.#M=Math.max(0.05,Math.min(0.95,J+G/200)),this.#Z.stiffness=Math.max(10,Math.round($-G*1.5))}this.#d(),this.#R=this.#F(),this.#q0(),this.#t(),this.#n("input")},N=()=>{this.#j=null,this.classList.remove("spring-bounce-dragging"),document.removeEventListener("pointermove",W),document.removeEventListener("pointerup",N),this.#n("change")};document.addEventListener("pointermove",W),document.addEventListener("pointerup",N)}}O("fig-easing-curve",E);class Uq extends HTMLElement{#Q=0;#q=0;#Z=0;#$=1;#J=!1;#j=!1;#N=null;#_=null;#W=null;#X=null;#U=(q)=>this.#D(q);#K=null;#G=[];#Y={};#R={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#$=parseInt(this.getAttribute("precision")||"1"),v(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),v(this,"--perspective",this.getAttribute("perspective")),v(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#L(this.getAttribute("transform-origin")),this.#f(this.getAttribute("fields"));let q=this.getAttribute("value");if(q)this.#T(q);if(this.querySelector(".fig-3d-rotate-container"))this.#z();else this.#A();this.#H(this.getAttribute("selected")),this.#O()}disconnectedCallback(){this.#J=!1,this.#M()}#z(){this.#_=this.querySelector(".fig-3d-rotate-container"),this.#N=this.querySelector(".fig-3d-rotate-cube"),this.#B(),this.#P(),this.#F()}#M(){if(this.#K?.abort(),this.#K=null,this.#W)window.removeEventListener("keydown",this.#W),window.removeEventListener("keyup",this.#X),this.#W=null,this.#X=null}#L(q){if(!q||!q.trim()){this.style.removeProperty("--transform-origin");return}let Q=q.trim().split(/\s+/);if(Q.length===2)this.style.setProperty("--transform-origin",`${Q[0]} ${Q[1]} -50cqi`);else this.style.setProperty("--transform-origin",q.trim())}#O(){if(!this.#_)return;this.#_.style.cursor=this.#I?"":"default"}#H(q){if(!this.#N)return;let Q=this.#N.querySelectorAll(".fig-3d-rotate-face"),Z=q?q.trim().toLowerCase():"";for(let $ of Q)$.classList.toggle("selected",Z!==""&&$.classList.contains(Z))}#f(q){if(!q||!q.trim()){this.#G=[];return}let Q=["rotateX","rotateY","rotateZ"];this.#G=q.split(",").map((Z)=>Z.trim()).filter((Z)=>Q.includes(Z))}attributeChangedCallback(q,Q,Z){if(q==="aspect-ratio"){v(this,"--aspect-ratio",Z);return}if(q==="perspective"){v(this,"--perspective",Z);return}if(q==="perspective-origin"){v(this,"--perspective-origin",Z);return}if(q==="transform-origin"){this.#L(Z);return}if(q==="selected"){this.#H(Z);return}if(q==="drag"){this.#O();return}if(q==="fields"){if(this.#f(Z),this.#N)this.#A();return}if(!this.#N)return;if(q==="value"&&Z){if(this.#J)return;this.#T(Z),this.#P(),this.#k()}if(q==="precision")this.#$=parseInt(Z||"1")}get value(){let q=this.#$;return`rotateX(${this.#Q.toFixed(q)}deg) rotateY(${this.#q.toFixed(q)}deg) rotateZ(${this.#Z.toFixed(q)}deg)`}set value(q){this.setAttribute("value",q)}get rotateX(){return this.#Q}get rotateY(){return this.#q}get rotateZ(){return this.#Z}#T(q){let Q=q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),Z=q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),$=q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if(Q)this.#Q=parseFloat(Q[1]);if(Z)this.#q=parseFloat(Z[1]);if($)this.#Z=parseFloat($[1])}#A(){let q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},Q={rotateX:this.#Q,rotateY:this.#q,rotateZ:this.#Z},Z=this.#G.map(($)=>`<fig-input-number
|
|
205
205
|
name="${$}"
|
|
206
206
|
step="1"
|
|
207
207
|
precision="1"
|
|
@@ -219,7 +219,7 @@ var wq=(q,Q)=>()=>(q&&(Q=q(q=0)),Q);var yq={};var D0=wq(()=>{/*! Vendored from @
|
|
|
219
219
|
<div class="fig-3d-rotate-face bottom"></div>
|
|
220
220
|
</div>
|
|
221
221
|
</div>
|
|
222
|
-
</div>${Z}`,this.#_=this.querySelector(".fig-3d-rotate-container"),this.#N=this.querySelector(".fig-3d-rotate-cube"),this.#
|
|
222
|
+
</div>${Z}`,this.#_=this.querySelector(".fig-3d-rotate-container"),this.#N=this.querySelector(".fig-3d-rotate-cube"),this.#B(),this.#P(),this.#F()}#B(){this.#Y={};for(let q of this.#G){let Q=this.querySelector(`fig-input-number[name="${q}"]`);if(!Q)continue;if(this.#Y[q]=Q,!this.#R[q])this.#R[q]=($)=>{$.stopPropagation();let J=parseFloat($.target.value);if(isNaN(J))return;if(q==="rotateX")this.#Q=J;else if(q==="rotateY")this.#q=J;else if(q==="rotateZ")this.#Z=J;this.#P(),this.#S($.type)};let Z=this.#R[q];Q.removeEventListener("input",Z),Q.removeEventListener("change",Z),Q.addEventListener("input",Z),Q.addEventListener("change",Z)}}#k(){let q={rotateX:this.#Q,rotateY:this.#q,rotateZ:this.#Z};for(let Q of this.#G){let Z=this.#Y[Q];if(Z)Z.setAttribute("value",q[Q].toFixed(this.#$))}}#P(){if(!this.#N)return;this.#N.style.transform=`rotateX(${this.#Q}deg) rotateY(${this.#q}deg) rotateZ(${this.#Z}deg)`}#S(q){this.dispatchEvent(new CustomEvent(q,{bubbles:!0,detail:{value:this.value,rotateX:this.#Q,rotateY:this.#q,rotateZ:this.#Z}}))}#V(q){if(!this.#j)return q;return Math.round(q/15)*15}#F(){if(this.#M(),!this.#_)return;this.#K=new AbortController,this.#_.addEventListener("pointerdown",this.#U,{signal:this.#K.signal}),this.#W=(q)=>{if(q.key==="Shift")this.#j=!0},this.#X=(q)=>{if(q.key==="Shift")this.#j=!1},window.addEventListener("keydown",this.#W),window.addEventListener("keyup",this.#X)}get#I(){let q=this.getAttribute("drag");return q===null||q.toLowerCase()!=="false"}#D(q){if(!this.#I)return;q.preventDefault(),this.#J=!0,this.#_.classList.add("dragging"),this.#_.setPointerCapture(q.pointerId);let{clientX:Q,clientY:Z}=q,$=this.#Q,J=this.#q,j=(W)=>{if(!this.#J)return;if(W.buttons===0){_();return}let N=W.clientX-Q,K=W.clientY-Z;this.#q=this.#V(J+N*0.5),this.#Q=this.#V($-K*0.5),this.#P(),this.#k(),this.setAttribute("value",this.value),this.#S("input")},_=()=>{if(!this.#J)return;this.setAttribute("value",this.value),this.#J=!1,this.#_.classList.remove("dragging"),this.#_.removeEventListener("pointermove",j),this.#_.removeEventListener("pointerup",_),this.#_.removeEventListener("pointercancel",_),this.#_.removeEventListener("lostpointercapture",_),this.#S("change")};this.#_.addEventListener("pointermove",j),this.#_.addEventListener("pointerup",_),this.#_.addEventListener("pointercancel",_),this.#_.addEventListener("lostpointercapture",_)}}O("fig-3d-rotate",Uq);class A0 extends HTMLElement{#Q=50;#q=50;#Z=0;#$=null;#J=[];#j=null;#N=null;#_=null;#W=!1;#X=!1;#U=null;#K=null;#G=null;static SNAP_POINTS=[0,16.6667,33.3333,50,66.6667,83.3333,100];static get observedAttributes(){return["value","precision","aspect-ratio","drag","fields"]}#Y(){this.#$=this.querySelector(".origin-grid"),this.#J=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#j=this.querySelector("fig-handle"),this.#N=this.querySelector('fig-input-number[name="x"]'),this.#_=this.querySelector('fig-input-number[name="y"]'),this.#P(),this.#S(),this.#A(),this.#g()}connectedCallback(){if(this.#Z=parseInt(this.getAttribute("precision")||"0"),v(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#f(this.getAttribute("value")),this.querySelector(".fig-origin-grid-surface"))this.#Y();else this.#T();this.#M(),this.#B()}disconnectedCallback(){this.#W=!1,this.#E(),this.#h()}get value(){let q=this.#Z;return`${this.#Q.toFixed(q)}% ${this.#q.toFixed(q)}%`}set value(q){this.setAttribute("value",q)}attributeChangedCallback(q,Q,Z){if(q==="aspect-ratio"){v(this,"--aspect-ratio",Z);return}if(q==="drag"){this.#M();return}if(q==="fields"){this.#T(),this.#M(),this.#B();return}if(q==="precision"){this.#Z=parseInt(Z||"0"),this.#A(),this.#B();return}if(q==="value"){if(this.#X||this.#W)return;this.#f(Z),this.#P(),this.#S(),this.#A()}}get#R(){let q=this.getAttribute("drag");return q===null||q.toLowerCase()!=="false"}get#z(){let q=this.getAttribute("fields");if(q===null)return!1;return q.toLowerCase()!=="false"}#M(){if(!this.#$)return;this.#$.classList.toggle("drag-disabled",!this.#R)}#L(q){return Math.max(0,Math.min(100,q))}#O(q,Q){let Z=(q||"").trim().toLowerCase();if(!Z)return Q==="x"?this.#Q:this.#q;let $=Q==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if(Z in $)return $[Z];let J=Number.parseFloat(Z.replace("%",""));if(Number.isFinite(J))return J;return Q==="x"?this.#Q:this.#q}#H(q){let Q=q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if(Q.length<1)return;if(Q.length===1){let Z=this.#O(Q[0],"x");this.#Q=Z,this.#q=Z;return}this.#Q=this.#O(Q[0],"x"),this.#q=this.#O(Q[1],"y")}#f(q){let Q=typeof q==="string"?q.trim():"";if(!Q){this.#Q=50,this.#q=50;return}this.#H(Q)}#T(){let q=Array.from({length:9},(J,j)=>{let _=j%3,W=Math.floor(j/3);return`<span class="origin-grid-cell" data-col="${_}" data-row="${W}">
|
|
223
223
|
<span class="origin-grid-dot"></span>
|
|
224
224
|
</span>`}).join(""),Q=this.#Q.toFixed(this.#Z),Z=this.#q.toFixed(this.#Z),$=this.#z?`<div class="origin-values">
|
|
225
225
|
<fig-input-number name="x" value="${Q}" step="1" units="%"><span slot="prepend">X</span></fig-input-number>
|
|
@@ -230,7 +230,7 @@ var wq=(q,Q)=>()=>(q&&(Q=q(q=0)),Q);var yq={};var D0=wq(()=>{/*! Vendored from @
|
|
|
230
230
|
<fig-handle></fig-handle>
|
|
231
231
|
</div>
|
|
232
232
|
</div>
|
|
233
|
-
${$}`,this.#$=this.querySelector(".origin-grid"),this.#J=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#j=this.querySelector("fig-handle"),this.#N=this.querySelector('fig-input-number[name="x"]'),this.#_=this.querySelector('fig-input-number[name="y"]'),this.#
|
|
233
|
+
${$}`,this.#$=this.querySelector(".origin-grid"),this.#J=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#j=this.querySelector("fig-handle"),this.#N=this.querySelector('fig-input-number[name="x"]'),this.#_=this.querySelector('fig-input-number[name="y"]'),this.#P(),this.#S(),this.#A(),this.#g()}#A(){let q=this.#Q.toFixed(this.#Z),Q=this.#q.toFixed(this.#Z);if(this.#N)this.#N.setAttribute("value",q);if(this.#_)this.#_.setAttribute("value",Q)}#B(){let q=this.value;if(this.getAttribute("value")===q)return;this.#X=!0,this.setAttribute("value",q),this.#X=!1}#k(q){this.dispatchEvent(new CustomEvent(q,{bubbles:!0,detail:{value:this.value,x:this.#Q,y:this.#q}}))}#P(){if(!this.#j)return;let q=(Q)=>16.6667+this.#L(Q)/100*66.6667;this.#j.style.left=`${q(this.#Q)}%`,this.#j.style.top=`${q(this.#q)}%`}#S(){if(!this.#j)return;let q=this.#Q<0||this.#Q>100,Q=this.#q<0||this.#q>100,Z=this.#Q<0,$=this.#Q>100,J=this.#q<0,j=this.#q>100;this.#j.classList.toggle("beyond-bounds-x",q),this.#j.classList.toggle("beyond-bounds-y",Q),this.#j.classList.toggle("overflow-left",Z),this.#j.classList.toggle("overflow-right",$),this.#j.classList.toggle("overflow-up",J),this.#j.classList.toggle("overflow-down",j)}#V(q,Q){if(!this.#$)return null;let Z=this.#$.getBoundingClientRect(),$=(q-Z.left)/Math.max(Z.width,1),J=(Q-Z.top)/Math.max(Z.height,1);if($<0||$>1||J<0||J>1)return null;let j=Math.max(0,Math.min(2,Math.floor($*3))),_=Math.max(0,Math.min(2,Math.floor(J*3)));return this.#J.find((W)=>Number(W.getAttribute("data-col"))===j&&Number(W.getAttribute("data-row"))===_)}#F(){for(let q of this.#J)q.classList.remove("is-hovered")}#I(q){if(this.#F(),q)q.classList.add("is-hovered")}#D(q,Q,Z){let $=Number(q),J=Number(Q);if(!Number.isFinite($)||!Number.isFinite(J))return;if($===this.#Q&&J===this.#q&&Z==="input")return;this.#Q=$,this.#q=J,this.#P(),this.#S(),this.#A(),this.#B(),this.#k(Z)}#C(q,Q){if(!this.#$)return{x:this.#Q,y:this.#q};let Z=this.#$.getBoundingClientRect(),$=Z.width/6,J=Z.height/6,j=Math.max(1,Z.width-$*2),_=Math.max(1,Z.height-J*2),W=(q-(Z.left+$))/j,N=(Q-(Z.top+J))/_;return{x:W*100,y:N*100}}#w(q,Q){if(!this.#$)return{x:50,y:50};let Z=this.#$.getBoundingClientRect(),$=(q-Z.left)/Math.max(Z.width,1)*3,J=(Q-Z.top)/Math.max(Z.height,1)*3,j=Math.max(0,Math.min(2,Math.floor($))),_=Math.max(0,Math.min(2,Math.floor(J)));return{x:j*50,y:_*50}}#y(q){let Z=q,$=1/0;for(let J of A0.SNAP_POINTS){let j=Math.abs(q-J);if(j<$)$=j,Z=J}return $<=2.5?Z:q}#m(q,Q){if(!Q)return q;return{x:this.#y(q.x),y:this.#y(q.y)}}#b(q){if(!this.#R)return!1;let Q=q.shiftKey?10:1,Z=this.#Q,$=this.#q;switch(q.key){case"ArrowLeft":Z-=Q;break;case"ArrowRight":Z+=Q;break;case"ArrowUp":$-=Q;break;case"ArrowDown":$+=Q;break;case"Home":Z=0,$=0;break;case"End":Z=100,$=100;break;default:return!1}return this.#D(this.#L(Z),this.#L($),"input"),this.#k("change"),!0}#E(){if(!this.#$||!this.#K||!this.#G)return;this.#$.removeEventListener("pointermove",this.#K),this.#$.removeEventListener("pointerup",this.#G),this.#$.removeEventListener("pointercancel",this.#G),this.#$.removeEventListener("lostpointercapture",this.#G),this.#K=null,this.#G=null}#v(q){if(!this.#$||!this.#R)return;q.preventDefault(),this.#W=!0,this.#U=q.pointerId;let{clientX:Q,clientY:Z}=q,$=3,J=!1;this.#$.setPointerCapture(q.pointerId),this.#K=(j)=>{if(!this.#W||j.pointerId!==this.#U)return;let _=j.clientX-Q,W=j.clientY-Z,N=Math.hypot(_,W);if(!J&&N<$)return;if(!J)J=!0,this.#$.classList.add("is-dragging"),this.#F();let K=this.#m(this.#C(j.clientX,j.clientY),j.shiftKey);this.#D(K.x,K.y,"input")},this.#G=(j)=>{if(!this.#W||j.pointerId!==this.#U)return;if(this.#W=!1,this.#U=null,this.#$.classList.remove("is-dragging"),this.#F(),this.#E(),!J){let _=this.#w(Q,Z);this.#D(_.x,_.y,"input")}this.#k("change")},this.#$.addEventListener("pointermove",this.#K),this.#$.addEventListener("pointerup",this.#G),this.#$.addEventListener("pointercancel",this.#G),this.#$.addEventListener("lostpointercapture",this.#G)}#x=null;#h(){this.#x?.abort(),this.#x=null}#g(){if(this.#h(),!this.#$||!this.#j)return;this.#x=new AbortController;let{signal:q}=this.#x;this.#$.addEventListener("pointerdown",(Z)=>{let $=this.#V(Z.clientX,Z.clientY);if(this.#I($),this.#R){this.#v(Z);return}let J=this.#w(Z.clientX,Z.clientY);this.#D(J.x,J.y,"input"),this.#k("change")},{signal:q}),this.#$.addEventListener("pointermove",(Z)=>{if(this.#W)return;let $=this.#V(Z.clientX,Z.clientY);this.#I($)},{signal:q}),this.#$.addEventListener("pointerleave",()=>{this.#F()},{signal:q}),this.#j.addEventListener("keydown",(Z)=>{if(!this.#b(Z))return;Z.preventDefault(),Z.stopPropagation()},{signal:q});let Q=(Z,$)=>{if(!Z)return;let J=(j)=>{let _=Number.parseFloat(j.target.value);if(!Number.isFinite(_))return;if($==="x")this.#D(_,this.#q,"input");else this.#D(this.#Q,_,"input")};Z.addEventListener("input",J,{signal:q}),Z.addEventListener("change",J,{signal:q}),Z.addEventListener("focusout",()=>{this.#k("change")},{signal:q})};Q(this.#N,"x"),Q(this.#_,"y")}}O("fig-origin-grid",A0);class Xq extends HTMLElement{#Q=null;#q=null;#Z=null;#$=null;#J=null;#j=null;#N=null;#_=null;#W=!1;#X={x:0.5,y:0.5};#U=!1;constructor(){super();this.position={x:0.5,y:0.5},this.isDragging=!1,this.plane=null,this.cursor=null,this.xInput=null,this.yInput=null,this.coordinates="screen",this.#Q=(q)=>this.#B(q),this.#q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#Z=(q)=>this.#k(q),this.#$=()=>this.#P(),this.#J=(q)=>this.#H(q),this.#j=(q)=>this.#f(q),this.#N=()=>this.#T(),this.#_=()=>this.#T()}#K(){this.#L(),this.#F(),this.#D(),this.#C(),this.#U=!0}connectedCallback(){u(this,()=>{if(this.precision=this.getAttribute("precision")||3,this.precision=parseInt(this.precision),this.transform=this.getAttribute("transform")||1,this.transform=Number(this.transform),this.coordinates=this.getAttribute("coordinates")||"screen",v(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");if(this.querySelector(".fig-input-joystick-plane")){this.#K();return}this.#R(),this.#L(),this.#F(),this.#D(),this.#C(),this.#U=!0})}#G(q){return this.coordinates==="math"?1-q:q}disconnectedCallback(){this.#O()}get#Y(){let q=this.getAttribute("fields");if(q===null)return!1;return q.toLowerCase()!=="false"}#R(){this.innerHTML=this.#M()}#z(){let q=(this.getAttribute("axis-labels")||"").trim();if(!q)return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1};let Q=q.split(/[\s,]+/).filter(Boolean);if(Q.length===1)return{left:"",right:"",top:Q[0],bottom:"",leftNoRotate:!1};if(Q.length===2){let[Z,$]=Q;return{left:Z,right:"",top:"",bottom:$,leftNoRotate:!0}}if(Q.length===4){let[Z,$,J,j]=Q;return{left:Z,right:$,top:J,bottom:j,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#M(){let q=this.#z();return`
|
|
234
234
|
<div class="fig-input-joystick-plane-container">
|
|
235
235
|
${[q.left?`<label class="fig-joystick-axis-label left${q.leftNoRotate?" no-rotate":""}" aria-hidden="true">${q.left}</label>`:"",q.right?`<label class="fig-joystick-axis-label right" aria-hidden="true">${q.right}</label>`:"",q.top?`<label class="fig-joystick-axis-label top" aria-hidden="true">${q.top}</label>`:"",q.bottom?`<label class="fig-joystick-axis-label bottom" aria-hidden="true">${q.bottom}</label>`:""].join("")}
|
|
236
236
|
<div class="fig-input-joystick-plane">
|
|
@@ -263,11 +263,11 @@ var wq=(q,Q)=>()=>(q&&(Q=q(q=0)),Q);var yq={};var D0=wq(()=>{/*! Vendored from @
|
|
|
263
263
|
<span slot="prepend">Y</span>
|
|
264
264
|
</fig-input-number>
|
|
265
265
|
</div>`:""}
|
|
266
|
-
`}#L(){this.plane=this.querySelector(".fig-input-joystick-plane"),this.cursor=this.querySelector("fig-handle"),this.xInput=this.querySelector("fig-input-number[name='x']"),this.yInput=this.querySelector("fig-input-number[name='y']"),this.plane?.addEventListener("pointerdown",this.#Q),this.cursor?.addEventListener("pointerdown",this.#q),this.cursor?.addEventListener("input",this.#Z),this.cursor?.addEventListener("change",this.#$);let q=this.querySelector(".fig-joystick-reset");if(q)q.addEventListener("click",()=>this.#w());if(this.#Y&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#J),this.xInput.addEventListener("change",this.#J),this.xInput.addEventListener("focusout",this.#N),this.yInput.addEventListener("input",this.#j),this.yInput.addEventListener("change",this.#j),this.yInput.addEventListener("focusout",this.#_)}#B(){if(this.plane?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("pointerdown",this.#q),this.cursor?.removeEventListener("input",this.#Z),this.cursor?.removeEventListener("change",this.#$),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#Y&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#J),this.xInput.removeEventListener("change",this.#J),this.xInput.removeEventListener("focusout",this.#N),this.yInput.removeEventListener("input",this.#j),this.yInput.removeEventListener("change",this.#j),this.yInput.removeEventListener("focusout",this.#_)}#H(q){let Q=Number.parseFloat(q.target.value);if(!Number.isFinite(Q))return;this.position.x=Math.max(0,Math.min(1,Q/100)),this.#F(),this.#P(),this.#C()}#k(q){let Q=Number.parseFloat(q.target.value);if(!Number.isFinite(Q))return;this.position.y=Math.max(0,Math.min(1,Q/100)),this.#F(),this.#P(),this.#C()}#T(){this.#P(),this.#V()}#A(q,Q,{syncHandle:Z=!0}={}){let $=Math.max(0,Math.min(1,q)),J=Math.max(0,Math.min(1,Q)),j=this.coordinates==="math"?1-J:J;if(this.position={x:$,y:j},Z)this.#F();this.#I(),this.#P()}#O(q){if(!this.plane||!this.cursor)return;if(q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let Q=this.plane.getBoundingClientRect(),Z=Q.width>0?(q.clientX-Q.left)/Q.width:0.5,$=Q.height>0?(q.clientY-Q.top)/Q.height:0.5;this.cursor.value=`${Math.round(Z*100)}% ${Math.round($*100)}%`,this.#A(Z,$,{syncHandle:!1}),this.#C(),this.#V()}#f(q){let Q=q.detail??{};if(typeof Q.px!=="number"||typeof Q.py!=="number")return;this.#A(Q.px,Q.py,{syncHandle:!1}),this.#C()}#D(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#P(),this.#V()}#C(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#V(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#F(){let q=this.#U(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${q*100}%`;this.#I()}#I(){if(this.#Y&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#P(){let q=this.value;if(this.getAttribute("value")!==q)this.#W=!0,this.setAttribute("value",q),this.#W=!1;this.#S()}#S(){let q=this.#X,Q=Math.round(this.position.x*100)===Math.round(q.x*100)&&Math.round(this.position.y*100)===Math.round(q.y*100);this.toggleAttribute("default",Q),this.style.setProperty("--is-not-default",Q?"0":"1")}#w(){this.position={...this.#X},this.#F(),this.#P(),this.#C(),this.#V()}focus(){this.cursor?.focus()}static get observedAttributes(){return["value","precision","transform","fields","coordinates","aspect-ratio","axis-labels"]}get value(){return`${Math.round(this.position.x*100)}% ${Math.round(this.position.y*100)}%`}set value(q){let Q=q==null?"":String(q).trim();if(!Q)this.position={x:0.5,y:0.5};else{let Z=Q.split(/[\s,]+/).filter(Boolean),$=(_)=>{if(!_)return 0.5;let W=_.includes("%"),N=Number.parseFloat(_.replace(/%/g,"").trim());if(!Number.isFinite(N))return 0.5;let K=W||Math.abs(N)>1?N/100:N;return Math.max(0,Math.min(1,K))},J=$(Z[0]),j=$(Z[1]??Z[0]);this.position={x:J,y:j}}if(this.#G)this.#F(),this.#S()}attributeChangedCallback(q,Q,Z){if(q==="aspect-ratio"){v(this,"--aspect-ratio",Z);return}if(q==="value"){if(this.#W||this.isDragging)return;this.value=Z}if(q==="precision")this.precision=parseInt(Z);if(q==="transform")this.transform=Number(Z);if(q==="fields"&&Z!==Q)this.#B(),this.#R(),this.#L(),this.#F();if(q==="axis-labels"&&Z!==Q)this.#B(),this.#R(),this.#L(),this.#F();if(q==="coordinates")this.coordinates=Z||"screen",this.#F()}}O("fig-joystick",Xq);class H0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let q=this.getAttribute("duration");if(q)this.style.setProperty(this.durationPropertyName,q);this.#Q()}static get observedAttributes(){return["duration","playing","aria-label","aria-labelledby"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(q){if(q)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(q,Q,Z){if(q==="duration")this.style.setProperty(this.durationPropertyName,Z||"1.5s");if(q==="playing"||q==="aria-label"||q==="aria-labelledby")this.#Q()}#Q(){let q=this.playing;if(this.setAttribute("aria-busy",q?"true":"false"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")){if(!this.hasAttribute("role"))this.setAttribute("role","status");this.removeAttribute("aria-hidden")}else this.removeAttribute("role"),this.setAttribute("aria-hidden","true")}}O("fig-shimmer",H0);class Yq extends H0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}O("fig-skeleton",Yq);class Rq extends HTMLElement{static observedAttributes=["name","collapsible","open"];#Q=null;#q=null;connectedCallback(){this.#J()}disconnectedCallback(){if(this.#q)this.#q.removeEventListener("click",this.#Z);if(this.#Q)this.#Q.removeEventListener("click",this.#Z),this.#Q.removeEventListener("keydown",this.#$),this.#Q.querySelector("h3")?.removeEventListener("click",this.#Z)}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="open"){this.#Q?.setAttribute("aria-expanded",String(this.open));return}this.#J()}get open(){let q=this.getAttribute("open");return q!==null&&q!=="false"}set open(q){let Q=this.open;if(q)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#Q?.setAttribute("aria-expanded",String(!!q)),Q!==!!q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!q},bubbles:!0}))}#Z=(q)=>{q.stopPropagation(),this.open=!this.open};#$=(q)=>{if(q.key!=="Enter"&&q.key!==" ")return;q.preventDefault(),q.stopPropagation(),this.open=!this.open};#J(){let q=this.hasAttribute("collapsible"),Z=this.getAttribute("name")||(q?"Group":null),$=this.querySelector(":scope > fig-header");if(!Z&&!q&&!$){if(this.#Q&&this.#Q.dataset.generated)this.#Q.remove(),this.#Q=null,this.#q=null;return}if($)this.#Q=$;else if(!this.#Q||!this.#Q.dataset.generated)this.#Q=document.createElement("fig-header"),this.#Q.setAttribute("borderless",""),this.#Q.dataset.generated="true",this.prepend(this.#Q);let J=this.#Q.querySelector("h3");if(!J)J=document.createElement("h3"),this.#Q.prepend(J);if(!J.id)J.id=m();if(this.#Q.dataset.generated)J.textContent=Z;if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",J.id);if(q){if(!J.querySelector(".fig-group-chevron")){let j=c("chevron",{size:"small",className:"fig-group-chevron"});J.prepend(j)}if(this.#q=J.querySelector(".fig-group-chevron"),J.removeEventListener("click",this.#Z),this.#Q.removeEventListener("click",this.#Z),this.#Q.addEventListener("click",this.#Z),this.#Q.setAttribute("role","button"),this.#Q.setAttribute("tabindex","0"),this.#Q.setAttribute("aria-expanded",String(this.open)),this.#Q.removeEventListener("keydown",this.#$),this.#Q.addEventListener("keydown",this.#$),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Q.setAttribute("aria-expanded","false")}else{if(J.removeEventListener("click",this.#Z),this.#Q.removeEventListener("click",this.#Z),this.#Q.removeAttribute("role"),this.#Q.removeAttribute("tabindex"),this.#Q.removeAttribute("aria-expanded"),this.#Q.removeEventListener("keydown",this.#$),this.#q)this.#q.remove(),this.#q=null;this.removeAttribute("open")}}}O("fig-group",Rq);class Lq extends HTMLElement{}O("fig-header",Lq);class Bq extends HTMLElement{}O("fig-footer",Bq);class Oq extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Loading")}}O("fig-spinner",Oq);class zq extends HTMLElement{static get observedAttributes(){return["fit","aspect-ratio"]}connectedCallback(){this.#Q(),this.#q()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="fit")this.#Q();if(q==="aspect-ratio")this.#q()}#Q(){let q=this.getAttribute("fit");if(q)this.style.setProperty("--fig-preview-fit",q);else this.style.removeProperty("--fig-preview-fit")}#q(){let q=this.getAttribute("aspect-ratio");if(q)this.style.setProperty("--fig-preview-aspect-ratio",q);else this.style.removeProperty("--fig-preview-aspect-ratio")}}O("fig-preview",zq);class P extends HTMLElement{static#Q=new Set(["oklch","hsl"]);static#q=10;static#Z=10;static#$=8;static#J=3;static#j=210;static#N={type:"linear",angle:135,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{color:"#FF0000",position:0,opacity:100},{color:"#4F9EFF",position:100,opacity:100}]};#_=!1;#W=null;#X=null;#G={...P.#N};static get observedAttributes(){return["value"]}get value(){return{type:"gradient",gradient:{...this.#G}}}set value(q){if(q==null||q===""){this.removeAttribute("value");return}if(typeof q==="string"){this.setAttribute("value",q);return}this.setAttribute("value",JSON.stringify(q))}connectedCallback(){this.#K(),this.#U(),this.#f(),this.#D()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q!=="value")return;if(this.#U(),this.#_)this.#D()}#K(){if(!(this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby"))&&!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}#U(){let q=this.getAttribute("value");if(!q){this.#G={...P.#N,stops:P.#N.stops.map((Q)=>({...Q}))};return}try{let Q=JSON.parse(q),Z=Q?.type==="gradient"&&Q.gradient?Q.gradient:Q?.gradient?Q.gradient:Q;if(!Z||typeof Z!=="object")return;this.#G=this.#Y({...P.#N,...Z})}catch{}}#Y(q){let Q={...q??{}},Z=String(Q.interpolationSpace??"srgb").toLowerCase(),$=String(Q.hueInterpolation??"shorter").toLowerCase(),J=Array.isArray(Q.stops)?Q.stops.map((j)=>({color:String(j?.color||"#D9D9D9").replace(/^(#(?:[0-9a-f]{6})).*/i,"$1"),position:j?.position??0,opacity:j?.opacity??100})):P.#N.stops.map((j)=>({...j}));if(J.length<2)return{...P.#N,stops:P.#N.stops.map((j)=>({...j}))};return{type:["linear","radial","angular"].includes(Q.type)?Q.type:"linear",angle:Number.isFinite(Number(Q.angle))?Number(Q.angle):135,interpolationSpace:Z,hueInterpolation:$,stops:J}}#R(){return P.#Q.has(this.#G.interpolationSpace||"srgb")}#z(q){let{r:Q,g:Z,b:$}=i(q);if(this.#G.interpolationSpace==="hsl")return L0(Q,Z,$).h;let J=n(Q,Z,$);return(R0(J.l,J.a,J.b).h%360+360)%360}#M(){let q=this.#T(),Q=this.#z(q[0]?.color||"#FF0000"),Z=this.#z(q[q.length-1]?.color||"#4F9EFF"),$=P.#j-Q,j=((P.#j-Z-$)%360+360)%360,_=j===0?0:j-360,W=this.#G.hueInterpolation||"shorter",N;if(W==="increasing")N=_;else if(W==="decreasing")N=j;else if(W==="longer")N=j<180?_:j;else N=j<=180?j:_;let K=Math.sign(N),G=Math.asin(P.#J/2/P.#$)*180/Math.PI,U=Math.min(G,Math.max(0,(Math.abs(N)-0.01)/2));return{startDeg:$+K*U,sweepDeg:N-K*U*2}}#L(q){let Q=q*Math.PI/180;return{x:P.#q+P.#$*Math.cos(Q),y:P.#Z+P.#$*Math.sin(Q)}}#B(q,Q){let Z=q+Q,$=this.#L(q),J=this.#L(Z),j=Math.abs(Q)>180?1:0,_=Q>=0?1:0;return`M ${$.x} ${$.y} A ${P.#$} ${P.#$} 0 ${j} ${_} ${J.x} ${J.y}`}#H(){let q=this.#L(180),Q=this.#L(0);return`M ${q.x} ${q.y} L ${Q.x} ${Q.y}`}#k(q){let Q=P.#J,Z=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none"><path d="${q}" fill="none" stroke="white" stroke-width="${Q}" stroke-linecap="round" stroke-linejoin="round"/></svg>`;return`url("data:image/svg+xml,${encodeURIComponent(Z)}")`}#T(){return[...this.#G.stops].sort((q,Q)=>(q.position??0)-(Q.position??0))}#A(){let q=this.#G.interpolationSpace||"srgb";if(q==="srgb")return"";if(P.#Q.has(q))return` in ${q} ${this.#G.hueInterpolation||"shorter"} hue`;return` in ${q}`}#O(){let q=this.#T(),Q=this.#A();if(this.#R()){let $=(P.#j+90)%360,J=this.#G.interpolationSpace,j=(W)=>J==="oklch"?`oklch(65% 0.25 ${W})`:`hsl(${W} 100% 50%)`,_=[0,300,240,180,120,60,0].map(j).join(", ");return`conic-gradient(from ${$}deg in ${J} decreasing hue, ${_})`}let Z=q.map(($)=>`${$.color} ${$.position??0}%`).join(", ");return`linear-gradient(90deg${Q}, ${Z})`}#f(){if(this.#_)return;let q=P.#J;this.innerHTML=`
|
|
266
|
+
`}#L(){this.plane=this.querySelector(".fig-input-joystick-plane"),this.cursor=this.querySelector("fig-handle"),this.xInput=this.querySelector("fig-input-number[name='x']"),this.yInput=this.querySelector("fig-input-number[name='y']"),this.plane?.addEventListener("pointerdown",this.#Q),this.cursor?.addEventListener("pointerdown",this.#q),this.cursor?.addEventListener("input",this.#Z),this.cursor?.addEventListener("change",this.#$);let q=this.querySelector(".fig-joystick-reset");if(q)q.addEventListener("click",()=>this.#w());if(this.#Y&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#J),this.xInput.addEventListener("change",this.#J),this.xInput.addEventListener("focusout",this.#N),this.yInput.addEventListener("input",this.#j),this.yInput.addEventListener("change",this.#j),this.yInput.addEventListener("focusout",this.#_)}#O(){if(this.plane?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("pointerdown",this.#q),this.cursor?.removeEventListener("input",this.#Z),this.cursor?.removeEventListener("change",this.#$),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#Y&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#J),this.xInput.removeEventListener("change",this.#J),this.xInput.removeEventListener("focusout",this.#N),this.yInput.removeEventListener("input",this.#j),this.yInput.removeEventListener("change",this.#j),this.yInput.removeEventListener("focusout",this.#_)}#H(q){let Q=Number.parseFloat(q.target.value);if(!Number.isFinite(Q))return;this.position.x=Math.max(0,Math.min(1,Q/100)),this.#F(),this.#D(),this.#S()}#f(q){let Q=Number.parseFloat(q.target.value);if(!Number.isFinite(Q))return;this.position.y=Math.max(0,Math.min(1,Q/100)),this.#F(),this.#D(),this.#S()}#T(){this.#D(),this.#V()}#A(q,Q,{syncHandle:Z=!0}={}){let $=Math.max(0,Math.min(1,q)),J=Math.max(0,Math.min(1,Q)),j=this.coordinates==="math"?1-J:J;if(this.position={x:$,y:j},Z)this.#F();this.#I(),this.#D()}#B(q){if(!this.plane||!this.cursor)return;if(q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;let Q=this.plane.getBoundingClientRect(),Z=Q.width>0?(q.clientX-Q.left)/Q.width:0.5,$=Q.height>0?(q.clientY-Q.top)/Q.height:0.5;this.cursor.value=`${Math.round(Z*100)}% ${Math.round($*100)}%`,this.#A(Z,$,{syncHandle:!1}),this.#S(),this.#V()}#k(q){let Q=q.detail??{};if(typeof Q.px!=="number"||typeof Q.py!=="number")return;this.#A(Q.px,Q.py,{syncHandle:!1}),this.#S()}#P(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#D(),this.#V()}#S(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#V(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0,detail:{value:this.value,x:this.position.x,y:this.position.y}}))}#F(){let q=this.#G(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${q*100}%`;this.#I()}#I(){if(this.#Y&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#D(){let q=this.value;if(this.getAttribute("value")!==q)this.#W=!0,this.setAttribute("value",q),this.#W=!1;this.#C()}#C(){let q=this.#X,Q=Math.round(this.position.x*100)===Math.round(q.x*100)&&Math.round(this.position.y*100)===Math.round(q.y*100);this.toggleAttribute("default",Q),this.style.setProperty("--is-not-default",Q?"0":"1")}#w(){this.position={...this.#X},this.#F(),this.#D(),this.#S(),this.#V()}focus(){this.cursor?.focus()}static get observedAttributes(){return["value","precision","transform","fields","coordinates","aspect-ratio","axis-labels"]}get value(){return`${Math.round(this.position.x*100)}% ${Math.round(this.position.y*100)}%`}set value(q){let Q=q==null?"":String(q).trim();if(!Q)this.position={x:0.5,y:0.5};else{let Z=Q.split(/[\s,]+/).filter(Boolean),$=(_)=>{if(!_)return 0.5;let W=_.includes("%"),N=Number.parseFloat(_.replace(/%/g,"").trim());if(!Number.isFinite(N))return 0.5;let K=W||Math.abs(N)>1?N/100:N;return Math.max(0,Math.min(1,K))},J=$(Z[0]),j=$(Z[1]??Z[0]);this.position={x:J,y:j}}if(this.#U)this.#F(),this.#C()}attributeChangedCallback(q,Q,Z){if(q==="aspect-ratio"){v(this,"--aspect-ratio",Z);return}if(q==="value"){if(this.#W||this.isDragging)return;this.value=Z}if(q==="precision")this.precision=parseInt(Z);if(q==="transform")this.transform=Number(Z);if(q==="fields"&&Z!==Q)this.#O(),this.#R(),this.#L(),this.#F();if(q==="axis-labels"&&Z!==Q)this.#O(),this.#R(),this.#L(),this.#F();if(q==="coordinates")this.coordinates=Z||"screen",this.#F()}}O("fig-joystick",Xq);class H0 extends HTMLElement{get durationPropertyName(){return this.localName==="fig-skeleton"?"--fig-skeleton-duration":"--fig-shimmer-duration"}connectedCallback(){let q=this.getAttribute("duration");if(q)this.style.setProperty(this.durationPropertyName,q);this.#Q()}static get observedAttributes(){return["duration","playing","aria-label","aria-labelledby"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(q){if(q)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(q,Q,Z){if(q==="duration")this.style.setProperty(this.durationPropertyName,Z||"1.5s");if(q==="playing"||q==="aria-label"||q==="aria-labelledby")this.#Q()}#Q(){let q=this.playing;if(this.setAttribute("aria-busy",q?"true":"false"),this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")){if(!this.hasAttribute("role"))this.setAttribute("role","status");this.removeAttribute("aria-hidden")}else this.removeAttribute("role"),this.setAttribute("aria-hidden","true")}}O("fig-shimmer",H0);class Yq extends H0{connectedCallback(){super.connectedCallback(),this.inert=!0,this.setAttribute("inert","")}}O("fig-skeleton",Yq);class Rq extends HTMLElement{static observedAttributes=["name","collapsible","open"];#Q=null;#q=null;connectedCallback(){this.#J()}disconnectedCallback(){if(this.#q)this.#q.removeEventListener("click",this.#Z);if(this.#Q)this.#Q.removeEventListener("click",this.#Z),this.#Q.removeEventListener("keydown",this.#$),this.#Q.querySelector("h3")?.removeEventListener("click",this.#Z)}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="open"){this.#Q?.setAttribute("aria-expanded",String(this.open));return}this.#J()}get open(){let q=this.getAttribute("open");return q!==null&&q!=="false"}set open(q){let Q=this.open;if(q)this.setAttribute("open","true");else this.setAttribute("open","false");if(this.#Q?.setAttribute("aria-expanded",String(!!q)),Q!==!!q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:!!q},bubbles:!0}))}#Z=(q)=>{q.stopPropagation(),this.open=!this.open};#$=(q)=>{if(q.key!=="Enter"&&q.key!==" ")return;q.preventDefault(),q.stopPropagation(),this.open=!this.open};#J(){let q=this.hasAttribute("collapsible"),Z=this.getAttribute("name")||(q?"Group":null),$=this.querySelector(":scope > fig-header");if(!Z&&!q&&!$){if(this.#Q&&this.#Q.dataset.generated)this.#Q.remove(),this.#Q=null,this.#q=null;return}if($)this.#Q=$;else if(!this.#Q||!this.#Q.dataset.generated)this.#Q=document.createElement("fig-header"),this.#Q.setAttribute("borderless",""),this.#Q.dataset.generated="true",this.prepend(this.#Q);let J=this.#Q.querySelector("h3");if(!J)J=document.createElement("h3"),this.#Q.prepend(J);if(!J.id)J.id=m();if(this.#Q.dataset.generated)J.textContent=Z;if(!this.hasAttribute("role"))this.setAttribute("role","group");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-labelledby",J.id);if(q){if(!J.querySelector(".fig-group-chevron")){let j=c("chevron",{size:"small",className:"fig-group-chevron"});J.prepend(j)}if(this.#q=J.querySelector(".fig-group-chevron"),J.removeEventListener("click",this.#Z),this.#Q.removeEventListener("click",this.#Z),this.#Q.addEventListener("click",this.#Z),this.#Q.setAttribute("role","button"),this.#Q.setAttribute("tabindex","0"),this.#Q.setAttribute("aria-expanded",String(this.open)),this.#Q.removeEventListener("keydown",this.#$),this.#Q.addEventListener("keydown",this.#$),!this.hasAttribute("open"))this.setAttribute("open","false"),this.#Q.setAttribute("aria-expanded","false")}else{if(J.removeEventListener("click",this.#Z),this.#Q.removeEventListener("click",this.#Z),this.#Q.removeAttribute("role"),this.#Q.removeAttribute("tabindex"),this.#Q.removeAttribute("aria-expanded"),this.#Q.removeEventListener("keydown",this.#$),this.#q)this.#q.remove(),this.#q=null;this.removeAttribute("open")}}}O("fig-group",Rq);class Lq extends HTMLElement{}O("fig-header",Lq);class Bq extends HTMLElement{}O("fig-footer",Bq);class Oq extends HTMLElement{connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","status");if(!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby"))this.setAttribute("aria-label","Loading")}}O("fig-spinner",Oq);class zq extends HTMLElement{static get observedAttributes(){return["fit","aspect-ratio"]}connectedCallback(){this.#Q(),this.#q()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="fit")this.#Q();if(q==="aspect-ratio")this.#q()}#Q(){let q=this.getAttribute("fit");if(q)this.style.setProperty("--fig-preview-fit",q);else this.style.removeProperty("--fig-preview-fit")}#q(){let q=this.getAttribute("aspect-ratio");if(q)this.style.setProperty("--fig-preview-aspect-ratio",q);else this.style.removeProperty("--fig-preview-aspect-ratio")}}O("fig-preview",zq);class P extends HTMLElement{static#Q=new Set(["oklch","hsl"]);static#q=10;static#Z=10;static#$=8;static#J=3;static#j=210;static#N={type:"linear",angle:135,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{color:"#FF0000",position:0,opacity:100},{color:"#4F9EFF",position:100,opacity:100}]};#_=!1;#W=null;#X=null;#U={...P.#N};static get observedAttributes(){return["value"]}get value(){return{type:"gradient",gradient:{...this.#U}}}set value(q){if(q==null||q===""){this.removeAttribute("value");return}if(typeof q==="string"){this.setAttribute("value",q);return}this.setAttribute("value",JSON.stringify(q))}connectedCallback(){this.#K(),this.#G(),this.#k(),this.#P()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q!=="value")return;if(this.#G(),this.#_)this.#P()}#K(){if(!(this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby"))&&!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}#G(){let q=this.getAttribute("value");if(!q){this.#U={...P.#N,stops:P.#N.stops.map((Q)=>({...Q}))};return}try{let Q=JSON.parse(q),Z=Q?.type==="gradient"&&Q.gradient?Q.gradient:Q?.gradient?Q.gradient:Q;if(!Z||typeof Z!=="object")return;this.#U=this.#Y({...P.#N,...Z})}catch{}}#Y(q){let Q={...q??{}},Z=String(Q.interpolationSpace??"srgb").toLowerCase(),$=String(Q.hueInterpolation??"shorter").toLowerCase(),J=Array.isArray(Q.stops)?Q.stops.map((j)=>({color:String(j?.color||"#D9D9D9").replace(/^(#(?:[0-9a-f]{6})).*/i,"$1"),position:j?.position??0,opacity:j?.opacity??100})):P.#N.stops.map((j)=>({...j}));if(J.length<2)return{...P.#N,stops:P.#N.stops.map((j)=>({...j}))};return{type:["linear","radial","angular"].includes(Q.type)?Q.type:"linear",angle:Number.isFinite(Number(Q.angle))?Number(Q.angle):135,interpolationSpace:Z,hueInterpolation:$,stops:J}}#R(){return P.#Q.has(this.#U.interpolationSpace||"srgb")}#z(q){let{r:Q,g:Z,b:$}=i(q);if(this.#U.interpolationSpace==="hsl")return L0(Q,Z,$).h;let J=n(Q,Z,$);return(R0(J.l,J.a,J.b).h%360+360)%360}#M(){let q=this.#T(),Q=this.#z(q[0]?.color||"#FF0000"),Z=this.#z(q[q.length-1]?.color||"#4F9EFF"),$=P.#j-Q,j=((P.#j-Z-$)%360+360)%360,_=j===0?0:j-360,W=this.#U.hueInterpolation||"shorter",N;if(W==="increasing")N=_;else if(W==="decreasing")N=j;else if(W==="longer")N=j<180?_:j;else N=j<=180?j:_;let K=Math.sign(N),G=Math.asin(P.#J/2/P.#$)*180/Math.PI,U=Math.min(G,Math.max(0,(Math.abs(N)-0.01)/2));return{startDeg:$+K*U,sweepDeg:N-K*U*2}}#L(q){let Q=q*Math.PI/180;return{x:P.#q+P.#$*Math.cos(Q),y:P.#Z+P.#$*Math.sin(Q)}}#O(q,Q){let Z=q+Q,$=this.#L(q),J=this.#L(Z),j=Math.abs(Q)>180?1:0,_=Q>=0?1:0;return`M ${$.x} ${$.y} A ${P.#$} ${P.#$} 0 ${j} ${_} ${J.x} ${J.y}`}#H(){let q=this.#L(180),Q=this.#L(0);return`M ${q.x} ${q.y} L ${Q.x} ${Q.y}`}#f(q){let Q=P.#J,Z=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none"><path d="${q}" fill="none" stroke="white" stroke-width="${Q}" stroke-linecap="round" stroke-linejoin="round"/></svg>`;return`url("data:image/svg+xml,${encodeURIComponent(Z)}")`}#T(){return[...this.#U.stops].sort((q,Q)=>(q.position??0)-(Q.position??0))}#A(){let q=this.#U.interpolationSpace||"srgb";if(q==="srgb")return"";if(P.#Q.has(q))return` in ${q} ${this.#U.hueInterpolation||"shorter"} hue`;return` in ${q}`}#B(){let q=this.#T(),Q=this.#A();if(this.#R()){let $=(P.#j+90)%360,J=this.#U.interpolationSpace,j=(W)=>J==="oklch"?`oklch(65% 0.25 ${W})`:`hsl(${W} 100% 50%)`,_=[0,300,240,180,120,60,0].map(j).join(", ");return`conic-gradient(from ${$}deg in ${J} decreasing hue, ${_})`}let Z=q.map(($)=>`${$.color} ${$.position??0}%`).join(", ");return`linear-gradient(90deg${Q}, ${Z})`}#k(){if(this.#_)return;let q=P.#J;this.innerHTML=`
|
|
267
267
|
<svg class="fig-interpolation-swatch-svg" width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
268
268
|
<circle class="fig-interpolation-swatch-rim" cx="10" cy="10" r="8" fill="none" stroke="currentColor" stroke-width="${q}"/>
|
|
269
269
|
</svg>
|
|
270
270
|
<div class="fig-interpolation-swatch-fill" aria-hidden="true"></div>
|
|
271
|
-
`,this.#W=this.querySelector(".fig-interpolation-swatch-svg"),this.#X=this.querySelector(".fig-interpolation-swatch-fill"),this.#_=!0}#
|
|
271
|
+
`,this.#W=this.querySelector(".fig-interpolation-swatch-svg"),this.#X=this.querySelector(".fig-interpolation-swatch-fill"),this.#_=!0}#P(){if(!this.#X)return;let q=this.#R();if(this.#W)this.#W.style.display=q?"":"none";let Q=q?(()=>{let{startDeg:$,sweepDeg:J}=this.#M();return this.#O($,J)})():this.#H(),Z=this.#f(Q);this.#X.style.setProperty("-webkit-mask-image",Z),this.#X.style.maskImage=Z,this.#X.style.background=this.#B()}}O("fig-interpolation-swatch",P);var rq={chevron:{medium:"--icon-24-chevron",small:"--icon-16-chevron"},checkmark:"--icon-16-checkmark",reset:{medium:"--icon-24-reset",small:"--icon-16-reset"},"arrow-left":{medium:"--icon-24-arrow-left",small:"--icon-16-arrow-left"},steppers:"--icon-24-steppers",eyedropper:"--icon-24-eyedropper",add:"--icon-24-add",send:{medium:"--icon-24-send",small:"--icon-16-send"},adjust:{medium:"--icon-24-adjust",small:"--icon-16-adjust"},minus:"--icon-24-minus",back:"--icon-24-back",forward:"--icon-24-forward",close:{medium:"--icon-24-close",small:"--icon-16-close"},rotate:"--icon-24-rotate",swap:"--icon-24-swap",play:"--icon-24-play",pause:"--icon-24-pause",search:"--icon-24-search",download:"--icon-24-download",upload:"--icon-24-upload",sun:"--icon-24-sun",moon:"--icon-24-moon",edit:{medium:"--icon-24-edit",small:"--icon-16-edit"},settings:{medium:"--icon-24-settings",small:"--icon-16-settings"},more:{medium:"--icon-24-more",small:"--icon-16-more"},visible:{medium:"--icon-24-visible",small:"--icon-16-visible"},hidden:{medium:"--icon-24-hidden",small:"--icon-16-hidden"},globe:{medium:"--icon-24-globe",small:"--icon-16-globe"}};function lq(q,Q="medium"){let Z=q&&rq[q];if(!Z)return"";let $=typeof Z==="string"?Z:Z[Q==="small"?"small":"medium"];return $?`var(${$})`:""}class Mq extends HTMLElement{static get observedAttributes(){return["name","size","color"]}connectedCallback(){this.#Q()}attributeChangedCallback(q,Q,Z){if(Q!==Z)this.#Q()}#Q(){let q=this.getAttribute("name"),Q=this.getAttribute("size")||"medium",Z=lq(q,Q);if(Z)this.style.setProperty("--icon",Z);else this.style.removeProperty("--icon");if(Q==="small")this.style.setProperty("--size","var(--spacer-3)");else this.style.removeProperty("--size");let $=this.getAttribute("color");if($)this.style.backgroundColor=$;else this.style.removeProperty("background-color");if(!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}}O("fig-icon",Mq);class Aq extends HTMLElement{}O("fig-content",Aq);class Hq extends HTMLElement{}O("fig-tab-content",Hq);class Fq extends HTMLElement{}O("fig-button-combo",Fq);class Tq extends HTMLElement{}O("fig-input-combo",Tq);class kq extends HTMLElement{#Q=null;#q=null;#Z=null;#$=this.#L.bind(this);#J=this.#O.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control","aria-label","aria-labelledby","aria-describedby"]}get#j(){return this.getAttribute("control")||"color"}connectedCallback(){this.#X(),this.#R()}disconnectedCallback(){this.#N(),this.removeEventListener("click",this.#U)}#N(){if(this.#Q)this.#Q.removeEventListener("input",this.#$),this.#Q.removeEventListener("change",this.#J);if(this.#q)this.#q.removeEventListener("input",this.#$),this.#q.removeEventListener("change",this.#J);if(this.#Z)this.#Z.disconnect(),this.#Z=null}#_(){if(this.#Z)this.#Z.disconnect(),this.#Z=null;if(!this.#q)return;this.#Z=new MutationObserver(()=>{if(this.#q?.hasAttribute("selected")&&this.#q.getAttribute("selected")!=="false"){if(!this.hasAttribute("selected"))this.setAttribute("selected","")}else if(this.hasAttribute("selected"))this.removeAttribute("selected")}),this.#Z.observe(this.#q,{attributes:!0,attributeFilter:["selected"]})}get#W(){let q=this.getAttribute("alpha");return q===null||q!=="false"}#X(){let q=this.#j;if(q==="add"||q==="remove"){let W=q==="add"?"add":"minus",N=this.getAttribute("aria-label")||(q==="add"?"Add color stop":"Remove color stop");this.innerHTML=`<fig-button icon variant="ghost" aria-label="${b(N)}"><fig-icon name="${W}"></fig-icon></fig-button>`,this.#Q=null,this.#q=null,this.addEventListener("click",this.#U),this.#z();return}this.removeEventListener("click",this.#U);let Q=(this.getAttribute("value")||"").trim(),Z=this.#Y(Q),$=this.#G(Q),J=this.#W?"":'alpha="false"',j=$<1?JSON.stringify({type:"solid",color:Z,opacity:Math.round($*100)}):JSON.stringify({type:"solid",color:Z}),_=$<1?` alpha="${$}"`:"";if(this.innerHTML=o()?`<fig-fill-picker mode="solid" ${J} value='${j}'>
|
|
272
272
|
<fig-swatch background="${Z}"${_}></fig-swatch>
|
|
273
|
-
</fig-fill-picker>`:`<fig-swatch background="${Z}"${_}></fig-swatch>`,this.#Q=this.querySelector("fig-fill-picker"),this.#q=this.querySelector("fig-swatch"),this.#N(),this.#Q?.addEventListener("input",this.#$),this.#Q?.addEventListener("change",this.#J),!this.#Q)this.#q?.addEventListener("input",this.#$),this.#q?.addEventListener("change",this.#J);this.#_(),this.#z()}#G=()=>{let q=this.#j;this.dispatchEvent(new CustomEvent(q,{bubbles:!0,composed:!0}))};#K(q){if(!q)return"#D9D9D9";let Q=q.replace("#","").trim();if(Q.length===3||Q.length===4){let[Z,$,J]=Q;return`#${Z}${Z}${$}${$}${J}${J}`.toUpperCase()}if(Q.length===6||Q.length===8)return`#${Q.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#U(q){if(!q)return 1;let Q=String(q).trim(),Z=Q.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test(Z)){let J=Z[3];return parseInt(`${J}${J}`,16)/255}if(/^[0-9a-f]{8}$/i.test(Z))return parseInt(Z.slice(6,8),16)/255;let $=Q.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if($)return parseFloat($[1]);return 1}#Y(q){if(!q)return"#D9D9D9";let Q=String(q).trim();if(Q.startsWith("{"))try{let Z=JSON.parse(Q);if(Z?.color)return this.#Y(Z.color)}catch{}if(Q.startsWith("#"))return this.#K(Q);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Q))return this.#K(Q);try{let{ctx:Z}=z0(1,1);Z.fillStyle="#000000",Z.fillStyle=Q;let $=Z.fillStyle;if($.startsWith("#"))return this.#K($);let J=$.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(J){let j=(_)=>Math.max(0,Math.min(255,Number(_))).toString(16).padStart(2,"0");return`#${j(J[1])}${j(J[2])}${j(J[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#R(){let q=this.getAttribute("value"),Q=this.#Y(q),Z=this.#U(q);if(q!==Q&&Z>=1){this.setAttribute("value",Q);return}if(this.#Q){this.#z();let $=Z<1?{type:"solid",color:Q,opacity:Math.round(Z*100)}:{type:"solid",color:Q};if(this.#Q.setAttribute("value",JSON.stringify($)),this.#W)this.#Q.removeAttribute("alpha");else this.#Q.setAttribute("alpha","false");if(T(this,"disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}if(this.#q){if(this.#z(),this.#q.setAttribute("background",Q),Z<1)this.#q.setAttribute("alpha",String(Z));else this.#q.removeAttribute("alpha");if(T(this,"disabled"))this.#q.setAttribute("disabled","");else this.#q.removeAttribute("disabled")}}#z(){let q=this.#j,Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",Q?"true":"false"),this.setAttribute("aria-pressed",Z?"true":"false"),q==="add"||q==="remove"){let W=this.querySelector("fig-button"),N=this.getAttribute("aria-label")||(q==="add"?"Add color stop":"Remove color stop");if(W?.setAttribute("aria-label",N),Q)W?.setAttribute("disabled","");else W?.removeAttribute("disabled");return}let $=this.#Q||this.#q;if(!$)return;let J=this.getAttribute("aria-label")||"Color stop",j=this.getAttribute("aria-labelledby"),_=this.getAttribute("aria-describedby");if(j)$.setAttribute("aria-labelledby",j),$.removeAttribute("aria-label");else $.setAttribute("aria-label",J),$.removeAttribute("aria-labelledby");if(_)$.setAttribute("aria-describedby",_);else $.removeAttribute("aria-describedby")}#M(q,Q){let Z=this.#Y(q?.color),$=this.#Y(this.getAttribute("value"));if(Z!==$)this.setAttribute("value",Z);else this.#R();let J={color:this.value};if(this.#W){if(q?.opacity!==void 0)J.opacity=q.opacity;else if(q?.alpha!==void 0)J.opacity=Math.round(q.alpha*100)}Object.assign(J,r(J.color,this.#W?q?.alpha:1,J.opacity)),this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!0,composed:!0,detail:J}))}#L(q){q.stopPropagation(),this.#M(q.detail||{color:q.target?.value},"input")}#B(q){q.stopPropagation(),this.#M(q.detail||{color:q.target?.value},"change")}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(!this.isConnected)return;switch(q){case"control":this.#X();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#R(),this.#z();break}}get value(){return this.#Y(this.getAttribute("value"))}set value(q){if(q===null||q===void 0||q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#Y(q))}get selected(){return T(this,"selected")}set selected(q){this.toggleAttribute("selected",Boolean(q))}get disabled(){return T(this,"disabled")}set disabled(q){this.toggleAttribute("disabled",Boolean(q))}}O("fig-color-tip",kq);class fq extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",T(this,"selected")?"true":"false"),T(this,"disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(q){if(q==="selected")this.setAttribute("aria-selected",T(this,"selected")?"true":"false");if(q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}O("fig-choice",fq);class Dq extends HTMLElement{#Q=null;#q=this.#H.bind(this);#Z=this.#k.bind(this);#$=this.#A.bind(this);#J=null;#j=null;#N=null;#_=null;#W=null;#X=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#G(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#K(){let q=this.getAttribute("drag");return q===null||q!=="false"}get#U(){return this.getAttribute("choice-element")||"fig-choice"}#Y(){let q=this.getAttribute("columns"),Q=q===null?NaN:Number(q);if(Number.isInteger(Q)&&Q>0)this.style.setProperty("--fig-chooser-grid-columns",String(Q));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from(this.querySelectorAll(`:scope > ${this.#U}`))}get selectedChoice(){return this.#Q}set selectedChoice(q){if(q&&!this.contains(q))return;let Q=this.choices;for(let $ of Q){let J=$===q,j=T($,"selected");if(J&&!j)$.setAttribute("selected","");else if(!J&&j)$.removeAttribute("selected")}this.#Q=q;let Z=q?.getAttribute("value")??"";if(this.getAttribute("value")!==Z){if(Z)this.setAttribute("value",Z)}this.#w(q)}get value(){return this.#Q?.getAttribute("value")??""}set value(q){if(q===null||q===void 0||q==="")return;this.setAttribute("value",String(q))}connectedCallback(){if(this.setAttribute("role","listbox"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#Y(),this.#C(),this.addEventListener("click",this.#q),this.addEventListener("keydown",this.#Z),this.addEventListener("scroll",this.#$),this.#V(),this.#f(),this.#y(),this.#O(),this.#M(),u(this,()=>{this.#z(),this.#A(),this.#R()})}#R(){let q=()=>{if(!this.isConnected)return;if(this.#Q)this.#w(this.#Q,"auto")},Q=()=>{let Z=this.querySelectorAll("img, video");for(let $ of Z){if($.tagName==="IMG"?$.complete:$.readyState>=1)continue;let J=()=>{$.removeEventListener("load",J),$.removeEventListener("loadedmetadata",J),$.removeEventListener("error",J),q()};$.addEventListener("load",J),$.addEventListener("loadedmetadata",J),$.addEventListener("error",J)}};requestAnimationFrame(()=>{Q(),q()})}disconnectedCallback(){this.removeEventListener("click",this.#q),this.removeEventListener("keydown",this.#Z),this.removeEventListener("scroll",this.#$),this.#D(),this.#J?.disconnect(),this.#J=null,this.#j?.disconnect(),this.#j=null,this.#F()}attributeChangedCallback(q,Q,Z){if(q==="value"&&Z!==Q&&Z)this.#L(Z);if(q==="disabled")this.#M();if(q==="choice-element")requestAnimationFrame(()=>this.#z());if(q==="columns")this.#Y(),this.#S();if(q==="drag")if(this.#K)this.#f();else this.#D();if(q==="overflow")this.#V(),requestAnimationFrame(()=>this.#A());if(q==="layout"){if(this.#V(),Z==="horizontal")this.scrollTop=0;else this.scrollLeft=0;this.#S()}}#z(){let q=this.choices;if(!q.length){this.#Q=null;return}let Q=this.getAttribute("value");if(Q&&this.#L(Q))return;let Z=q.find(($)=>T($,"selected"));if(Z){this.selectedChoice=Z;return}this.selectedChoice=q[0]}#M(){let q=T(this,"disabled");if(q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Q of this.choices)if(q||T(Q,"disabled"))Q.setAttribute("aria-disabled","true"),Q.setAttribute("tabindex","-1");else Q.removeAttribute("aria-disabled"),Q.setAttribute("tabindex","0")}#L(q){let Q=this.choices;for(let Z of Q)if(Z.getAttribute("value")===q)return this.selectedChoice=Z,!0;return!1}#B(q){let Q=this.#U,Z=q;while(Z&&Z!==this){if(Z.matches(Q))return Z;Z=Z.parentElement}return null}#H(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.#B(q.target);if(!Q)return;if(Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.selectedChoice=Q,this.#T()}#k(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.choices.filter((j)=>!j.hasAttribute("disabled")||j.getAttribute("disabled")==="false");if(!Q.length)return;let Z=Q.indexOf(this.#Q),$=Z,J=this.hasAttribute("loop");switch(q.key){case"ArrowDown":case"ArrowRight":if(q.preventDefault(),Z<Q.length-1)$=Z+1;else if(J)$=0;break;case"ArrowUp":case"ArrowLeft":if(q.preventDefault(),Z>0)$=Z-1;else if(J)$=Q.length-1;break;case"Home":q.preventDefault(),$=0;break;case"End":q.preventDefault(),$=Q.length-1;break;case"Enter":case" ":if(q.preventDefault(),document.activeElement?.matches(this.#U)){let j=this.#B(document.activeElement);if(j&&j!==this.#Q)this.selectedChoice=j,this.#T()}return;default:return}if($!==Z&&Q[$])this.selectedChoice=Q[$],Q[$].focus(),this.#T()}#T(){let q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:q,bubbles:!0}))}#A(){if(this.#G==="scrollbar")return;let q=this.getAttribute("layout")==="horizontal";q0(this,this,q?"x":"y")}#O(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#A(),this.#S()}),this.#j.observe(this)}#f(){if(this.#W?.bound)return;if(!this.#K)return;let q=(j)=>{if(j.button!==0)return;if(j.target.closest("[data-fig-chooser-nav]"))return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#W.active=!0,this.#W.didDrag=!1,this.#W.startX=j.clientX,this.#W.startY=j.clientY,this.#W.scrollLeft=this.scrollLeft,this.#W.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Q=(j)=>{if(!this.#W.active)return;let _=this.getAttribute("layout")==="horizontal",W=j.clientX-this.#W.startX,N=j.clientY-this.#W.startY;if(!this.#W.didDrag&&Math.abs(_?W:N)>3)this.#W.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(j.pointerId);if(!this.#W.didDrag)return;if(_)this.scrollLeft=this.#W.scrollLeft-W;else this.scrollTop=this.#W.scrollTop-N},Z=(j)=>{if(!this.#W.active)return;let _=this.#W.didDrag;if(this.#W.active=!1,this.#W.didDrag=!1,this.style.cursor="",this.style.userSelect="",j.pointerId!==void 0)try{this.releasePointerCapture(j.pointerId)}catch{}if(_)j.preventDefault(),j.stopPropagation()},$=(j)=>{if(this.#W?.suppressClick)j.stopPropagation(),j.preventDefault(),this.#W.suppressClick=!1},J=(j)=>{if(this.#W?.didDrag)this.#W.suppressClick=!0,setTimeout(()=>{if(this.#W)this.#W.suppressClick=!1},0)};this.#W={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:q,onPointerMove:Q,onPointerUp:Z,onClick:$,onPointerUpCapture:J},this.addEventListener("pointerdown",q),window.addEventListener("pointermove",Q),window.addEventListener("pointerup",Z),this.addEventListener("pointerup",J,!0),this.addEventListener("click",$,!0)}#D(){if(!this.#W?.bound)return;this.removeEventListener("pointerdown",this.#W.onPointerDown),window.removeEventListener("pointermove",this.#W.onPointerMove),window.removeEventListener("pointerup",this.#W.onPointerUp),this.removeEventListener("pointerup",this.#W.onPointerUpCapture,!0),this.removeEventListener("click",this.#W.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#W=null}#C(){if(this.#X)return;let q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!q)return;this.#X=!0;try{let Q=Array.from(q.childNodes);q.replaceWith(...Q)}finally{this.#X=!1}}#V(){if(this.#G==="scrollbar")this.#F();else this.#I()}#F(){this.#N?.remove(),this.#_?.remove(),this.#N=null,this.#_=null,this.classList.remove("overflow-start","overflow-end")}#I(){if(this.#N&&this.#_&&this.contains(this.#N)&&this.contains(this.#_))return;this.#N?.remove(),this.#_?.remove(),this.#N=null,this.#_=null;let q=B0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#P(-1),onEnd:()=>this.#P(1)});this.#N=q.start,this.#_=q.end,this.prepend(this.#N),this.append(this.#_)}#P(q){let Q=this.getAttribute("layout")==="horizontal";Q0(this,Q?"x":"y",q)}#S(){if(!this.#Q)return;this.#w(this.#Q,"auto")}#w(q,Q="smooth"){if(!q)return;requestAnimationFrame(()=>{if(!q.isConnected)return;let Z=this.scrollHeight>this.clientHeight,$=this.scrollWidth>this.clientWidth;if(!$&&!Z)return;let J=q.getBoundingClientRect(),j=this.getBoundingClientRect(),_={behavior:Q},W=!1;if(Z){let N=J.top-j.top+this.scrollTop,K=this.scrollHeight-this.clientHeight;_.top=Math.max(0,Math.min(N+J.height/2-this.clientHeight/2,K)),W=!0}if($){let N=J.left-j.left+this.scrollLeft,K=this.scrollWidth-this.clientWidth;_.left=Math.max(0,Math.min(N+J.width/2-this.clientWidth/2,K)),W=!0}if(W)this.scrollTo(_);this.#A()})}#y(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>{if(this.#X)return;this.#C(),this.#V(),this.#M();let q=this.choices;if(this.#Q&&!q.includes(this.#Q))this.#Q=null,this.#z();else if(!this.#Q&&q.length)this.#z();requestAnimationFrame(()=>this.#A())}),this.#J.observe(this,{childList:!0,subtree:!1})}}O("fig-chooser",Dq);class Pq extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#Q=!1;#q=!1;#Z=null;#$=null;#J=!1;#j=null;#N=null;#_=null;#W=null;get#X(){let q=(this.getAttribute("tip")||"").trim().toLowerCase();return q==="color"||q==="add"||q==="remove"?q:null}get#G(){return!this.hasAttribute("data-no-color-picker")}get#K(){let q=this.getAttribute("drag");return q!==null&&q!=="false"}get#U(){let q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:q.includes("x"),y:q.includes("y")}}get#Y(){let q=this.getAttribute("drag-snapping");if(q===null)return"false";let Q=q.trim().toLowerCase();if(Q==="modifier")return"modifier";if(Q===""||Q==="true")return"true";return"false"}#R(q){let Q=this.#Y;if(Q==="true")return!0;if(Q==="modifier")return!!q;return!1}#z(q){if(q<0.1)return 0;if(q>0.9)return 1;if(q>0.4&&q<0.6)return 0.5;return q}#M(q,Q){if(Math.abs(q-Q)<0.1){let $=(q+Q)/2;return{x:$,y:$}}if(Math.abs(1-q-Q)<0.1)return{x:q,y:1-q};return{x:q,y:Q}}#L(){let q=this.getAttribute("drag-surface");if(!q||q==="parent")return this.parentElement;return this.closest(q)}get value(){let q=this.#L();if(!q)return"0% 0%";let{px:Q,py:Z}=this.#e(q.getBoundingClientRect());return`${Math.round(Q*100)}% ${Math.round(Z*100)}%`}set value(q){this.setAttribute("value",q??"0% 0%")}#B(q){let Q=q==null?"":String(q).trim();if(!Q)return{xPct:0,yPct:0};let Z=Q.split(/[\s,]+/).filter(Boolean),$=(_)=>{if(!_)return 0;let W=_.includes("px"),N=_.includes("%"),K=parseFloat(_.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(W)return{px:K};if(N||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},J=$(Z[0]),j=$(Z[1]??Z[0]);return{xToken:J,yToken:j}}#H(q){let Q=this.#L();if(!Q)return;let{xToken:Z,yToken:$}=this.#B(q),J=Q.getBoundingClientRect(),j=(N,K)=>{if(N&&typeof N==="object"&&"px"in N)return Math.max(0,Math.min(K,N.px));return null},_=(N)=>{return`${typeof N==="number"?N:0}%`},W=this.#U;if(this.#k(W),W.x){let N=j(Z,J.width);this.style.left=N===null?_(Z):`${Math.round(N)}px`}if(W.y){let N=j($,J.height);this.style.top=N===null?_($):`${Math.round(N)}px`}}#k(q=this.#U){this.style.setProperty("--fig-handle-position-translate",`${q.x?"-50%":"0"} ${q.y?"-50%":"0"}`)}#T(){this.#J=!0,this.setAttribute("value",this.value),this.#J=!1}get#A(){return this.getAttribute("hit-area-mode")||"handle"}#O(){let q=this.getAttribute("hit-area");if(!q)return null;let Q=q.trim().split(/\s+/),Z=0,$=0,J=!1,j=[];for(let _ of Q){if(_==="circle"){J=!0;continue}let W=parseFloat(_);if(Number.isFinite(W))j.push(W)}if(j.length>=2)Z=j[0],$=j[1];else if(j.length===1)Z=j[0],$=j[0];else return null;return{vPad:Z,hPad:$,circle:J}}#f(){let q=this.#O();if(!q){if(this.#W)this.#W.remove(),this.#W=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#W){let Q=document.createElement("div");Q.classList.add("fig-handle-hit-area"),Q.addEventListener("pointerdown",(Z)=>this.#D(Z)),this.prepend(Q),this.#W=Q}if(this.style.setProperty("--fig-handle-hit-area-size",String(q.hPad*2)),q.circle)this.#W.style.borderRadius="50%";else this.#W.style.borderRadius="inherit"}#D(q){if(T(this,"disabled"))return;if(q.target!==this.#W)return;if(this.#A==="delegate")q.preventDefault(),q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:q}}));else this.#y(q)}connectedCallback(){this.#S(),this.#P(),this.#f(),this.addEventListener("click",this.#C),document.addEventListener("pointerdown",this.#V),document.addEventListener("keydown",this.#F);let q=this.getAttribute("value");if(q)this.#H(q);if(this.#X)this.#o()}disconnectedCallback(){if(this.#w(),this.#c(),this.#v(),this.#l(),this.#W)this.#W.remove(),this.#W=null;this.removeEventListener("click",this.#C),document.removeEventListener("pointerdown",this.#V),document.removeEventListener("keydown",this.#F)}select(){if(T(this,"disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#C=(q)=>{if(this.#q){this.#q=!1;return}if(this.getAttribute("type")==="color"&&this.#G&&!this.#X){this.#x();return}this.select()};#V=(q)=>{if(this.contains(q.target))return;if((this.#j||this.#N)&&q.target.closest?.("dialog, [popover]"))return;this.deselect()};#F=(q)=>{if(q.defaultPrevented)return;if(q.target===this&&this.#K&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(q.key)){if(this.#I(q)){if(q.preventDefault(),!T(this,"selected"))this.select()}return}if(q.key!=="Enter"&&q.key!==" ")return;if(q.target===this&&!T(this,"selected")){if(q.preventDefault(),this.getAttribute("type")==="color"&&this.#G&&!this.#X)this.#x();else this.select();return}if(!T(this,"selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#G)return;if(q.preventDefault(),!this.#X)this.#x()};#I(q){if(T(this,"disabled"))return!1;let Q=this.#L();if(!Q)return!1;let Z=Q.getBoundingClientRect();if(Z.width<=0||Z.height<=0)return!1;let $=this.#U,J=this.#e(Z),j=q.shiftKey?0.1:0.01,_=J.px,W=J.py;switch(q.key){case"ArrowLeft":if(!$.x)return!1;_-=j;break;case"ArrowRight":if(!$.x)return!1;_+=j;break;case"ArrowUp":if(!$.y)return!1;W-=j;break;case"ArrowDown":if(!$.y)return!1;W+=j;break;case"Home":if($.x)_=0;if($.y)W=0;break;case"End":if($.x)_=1;if($.y)W=1;break;default:return!1}if(_=Math.max(0,Math.min(1,_)),W=Math.max(0,Math.min(1,W)),this.#k($),$.x)this.style.left=`${Math.round(_*Z.width)}px`;if($.y)this.style.top=`${Math.round(W*Z.height)}px`;this.#T();let N={...this.#e(Z),shiftKey:q.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:N})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:N})),!0}attributeChangedCallback(q,Q,Z){if(q==="color"){if(!Z||Z==="false"||Z==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",Z);if(this.#j&&this.#X==="color"&&Z)this.#j.setAttribute("value",Z);this.#E()}if(q==="drag")this.#P();if(q==="hit-area")this.#f();if(q==="selected")this.#i();if(q==="selected"||q==="disabled"||q==="type"||q==="tip"||q==="aria-label"||q==="aria-labelledby")this.#S();if(q==="value"&&!this.#J&&!this.#Q)this.#H(Z);if(q==="tip"){if(this.#c(),this.#X)this.#v(),this.#o()}}#P(){if(this.#K&&!this.#Z)this.#Z=(q)=>this.#y(q),this.addEventListener("pointerdown",this.#Z);else if(!this.#K&&this.#Z)this.#w()}#S(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex",q?"-1":"0");else if(q)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",q?"true":"false"),this.setAttribute("aria-pressed",Q?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let Z=this.#X||this.getAttribute("type")||"handle";this.setAttribute("aria-label",Z==="color"?"Color handle":Z==="add"?"Add handle":Z==="remove"?"Remove handle":"Handle")}}#w(){if(this.#$?.(),this.#$=null,this.#Z)this.removeEventListener("pointerdown",this.#Z),this.#Z=null;this.#Q=!1,this.#q=!1}#y(q){if(!this.#K||T(this,"disabled"))return;q.preventDefault();let Q=this.#L();if(!Q)return;this.#$?.(),this.#Q=!0;let Z=this.#U,$=null,J=this.getBoundingClientRect(),j=J.left+J.width/2,_=J.top+J.height/2,W=q.clientX-j,N=q.clientY-_,K=q.clientX,G=q.clientY,U=3,X=(k,H,A=!1)=>{let R=Q.getBoundingClientRect();$=R;let D=this.#e(R),I=k-W-R.left,S=H-N-R.top,w=Math.max(0,Math.min(R.width,I)),y=Math.max(0,Math.min(R.height,S)),g=R.width>0?Z.x?w/R.width:D.px:0.5,d=R.height>0?Z.y?y/R.height:D.py:0.5;if(this.#R(A)){if(Z.x)g=this.#z(g);if(Z.y)d=this.#z(d);if(Z.x&&Z.y){let t=this.#M(g,d);g=t.x,d=t.y}}if(this.#k(Z),Z.x)this.style.left=`${Math.round(Math.max(0,Math.min(R.width,g*R.width)))}px`;if(Z.y)this.style.top=`${Math.round(Math.max(0,Math.min(R.height,d*R.height)))}px`},z=(k)=>{if(!this.#Q)return;if(!this.#q){let H=k.clientX-K,A=k.clientY-G;if(H*H+A*A<U*U)return;if(this.#u(),this.classList.add("dragging"),this.style.cursor="grabbing",!T(this,"selected"))this.select()}this.#q=!0,X(k.clientX,k.clientY,k.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#e($),shiftKey:k.shiftKey}}))},B=(k)=>{if(L(),this.#q){X(k.clientX,k.clientY,k.shiftKey),this.#T(),this.#H(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#e($)}));let H=(A)=>{A.stopPropagation(),A.preventDefault()};this.addEventListener("click",H,{capture:!0,once:!0})}else this.#T();this.#q=!1},L=()=>{if(window.removeEventListener("pointermove",z),window.removeEventListener("pointerup",B),this.#Q=!1,this.style.cursor="",this.classList.remove("dragging"),this.#$===L)this.#$=null};this.#$=L,window.addEventListener("pointermove",z),window.addEventListener("pointerup",B)}showColorTip(){if(!this.#X)return;if(this.#j){this.#j.style.display="";return}this.#o()}hideColorTip(){if(!this.#j)return;this.#j.style.display="none"}#g(q=this.getAttribute("color")){let Q={color:"#D9D9D9",opacity:100},Z=String(q||"").trim();if(!Z)return Q;let $=(j)=>{let _=j.replace("#","").trim();if(_.length===3||_.length===4){let[W,N,K,G]=_;return{color:`#${W}${W}${N}${N}${K}${K}`.toUpperCase(),opacity:G?Math.round(parseInt(`${G}${G}`,16)/255*100):100}}if(_.length===6||_.length===8)return{color:`#${_.slice(0,6)}`.toUpperCase(),opacity:_.length===8?Math.round(parseInt(_.slice(6,8),16)/255*100):100};return Q},J=(j,_,W)=>{let N=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${N(j)}${N(_)}${N(W)}`.toUpperCase()};if(Z.startsWith("#"))return $(Z);try{let{ctx:j}=z0(1,1);j.fillStyle="#000000",j.fillStyle=Z;let _=j.fillStyle;if(_.startsWith("#"))return $(_);let W=_.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(W)return{color:J(W[1],W[2],W[3]),opacity:W[4]!==void 0?Math.round(parseFloat(W[4])*100):100}}catch{}return Q}#b(){let{color:q,opacity:Q}=this.#g();return JSON.stringify(Q<100?{type:"solid",color:q,opacity:Q}:{type:"solid",color:q})}#E(){if(!this.#N)return;this.#N.setAttribute("value",this.#b())}#h(){if(!o())return null;if(this.#N)return this.#N;let q=document.createElement("fig-fill-picker");q.setAttribute("mode","solid"),q.setAttribute("alpha","true"),q.setAttribute("dialog-offset","8 8"),q.setAttribute("value",this.#b()),q.anchorElement=this;let Q=document.createElement("span");return Q.hidden=!0,q.appendChild(Q),q.addEventListener("input",this.#d),q.addEventListener("change",this.#a),q.addEventListener("close",this.#j0),this.appendChild(q),this.#N=q,q}#x(){if(T(this,"disabled"))return;let q=this.#h();if(!q){this.#r();return}this.setAttribute("selected",""),this.#E(),q.open()}#v(){if(!this.#N)return;this.#N.removeEventListener("input",this.#d),this.#N.removeEventListener("change",this.#a),this.#N.removeEventListener("close",this.#j0),this.#N.close(),this.#N.remove(),this.#N=null,this.removeAttribute("selected")}#m(){if(this.#_)return this.#_;let q=document.createElement("input");return q.type="color",q.tabIndex=-1,q.setAttribute("aria-hidden","true"),q.style.position="fixed",q.style.inlineSize="1px",q.style.blockSize="1px",q.style.opacity="0",q.style.pointerEvents="none",q.addEventListener("input",this.#Z0),q.addEventListener("change",this.#J0),this.appendChild(q),this.#_=q,q}#r(){let q=this.#m(),{color:Q}=this.#g();q.value=Q,this.setAttribute("selected",""),q.click()}#l(){if(!this.#_)return;this.#_.removeEventListener("input",this.#Z0),this.#_.removeEventListener("change",this.#J0),this.#_.remove(),this.#_=null}#u(){if(this.getAttribute("type")!=="color")return;this.#N?.close()}#o(){let q=this.#X;if(!q)return;if(this.#j)return;let Q=document.createElement("fig-color-tip");if(q==="add"||q==="remove")Q.setAttribute("control",q);else Q.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Q.setAttribute("alpha","true");Q.addEventListener("input",this.#q0),Q.addEventListener("change",this.#t),Q.addEventListener("add",this.#$0),Q.addEventListener("remove",this.#$0),this.appendChild(Q),this.#j=Q,this.#i()}#c(){if(!this.#j)return;this.#j.removeEventListener("input",this.#q0),this.#j.removeEventListener("change",this.#t),this.#j.removeEventListener("add",this.#$0),this.#j.removeEventListener("remove",this.#$0),this.#j.remove(),this.#j=null}#i(){if(!this.#j||this.#X!=="color")return;let q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#j.toggleAttribute("selected",q)}#s(q,Q){if(Q===void 0||Q>=100)return q;let{r:Z,g:$,b:J}=i(q);return`rgba(${Z}, ${$}, ${J}, ${Q/100})`}#p(q){if(!q?.color)return null;let Q=q.opacity!==void 0?q.opacity:q.alpha!==void 0?Math.round(q.alpha*100):void 0;return{color:q.color,opacity:Q,...r(q.color,q.alpha,Q)}}#d=(q)=>{q.stopPropagation();let Q=this.#p(q.detail);if(!Q)return;this.setAttribute("color",this.#s(Q.color,Q.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Q}))};#a=(q)=>{q.stopPropagation();let Q=this.#p(q.detail);if(!Q)return;this.setAttribute("color",this.#s(Q.color,Q.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Q}))};#Q0(q){let{opacity:Q}=this.#g();return{...Q<100?{color:q,opacity:Q}:{color:q},...r(q,void 0,Q)}}#Z0=(q)=>{q.stopPropagation();let Q=this.#Q0(q.target.value);this.setAttribute("color",this.#s(Q.color,Q.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Q}))};#J0=(q)=>{q.stopPropagation();let Q=this.#Q0(q.target.value);this.setAttribute("color",this.#s(Q.color,Q.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Q}))};#j0=()=>{this.removeAttribute("selected")};#q0=(q)=>{if(q.stopPropagation(),q.detail?.color){let Q={color:q.detail.color,opacity:q.detail.opacity,...r(q.detail.color,q.detail.alpha,q.detail.opacity)};this.setAttribute("color",this.#s(Q.color,Q.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Q}))}};#t=(q)=>{if(q.stopPropagation(),q.detail?.color){let Q={color:q.detail.color,opacity:q.detail.opacity,...r(q.detail.color,q.detail.alpha,q.detail.opacity)};this.setAttribute("color",this.#s(Q.color,Q.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Q}))}};#$0=(q)=>{q.stopPropagation(),this.dispatchEvent(new CustomEvent(q.type,{bubbles:!0,composed:!0}))};#e(q){let Q=q||this.#L()?.getBoundingClientRect();if(!Q)return{x:0,y:0,px:0,py:0};let Z=this.getBoundingClientRect(),$=this.offsetWidth/2,J=this.offsetHeight/2,j=Z.left-Q.left,_=Z.top-Q.top,W=j+$,N=_+J,K=Q.width>0?W/Q.width:0,G=Q.height>0?N/Q.height:0;return{x:j,y:_,px:K,py:G}}}O("fig-handle",Pq);class Iq extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(q){this.setAttribute("value",q??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Q()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="disabled")this.#Q()}#Q(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}O("fig-menu-item",Iq);class Sq extends HTMLElement{static get observedAttributes(){return["label"]}get label(){return this.getAttribute("label")??""}set label(q){if(q==null||q==="")this.removeAttribute("label");else this.setAttribute("label",String(q))}connectedCallback(){this.#Q()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;this.#Q()}#Q(){if(!this.hasAttribute("role"))this.setAttribute("role","separator");let q=this.label.trim();if(q)this.setAttribute("aria-label",q);else this.removeAttribute("aria-label")}}O("fig-separator",Sq);class Vq extends HTMLElement{#Q=null;#q=null;#Z=null;#$=null;#J=null;#j=null;#N=null;#_=null;#W;#X;#G;#K;#U;#Y=this.#f.bind(this);#R=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open","trigger"]}constructor(){super();this.#W=this.#w.bind(this),this.#X=this.#y.bind(this),this.#G=this.#b.bind(this),this.#K=this.#E.bind(this),this.#U=this.#h.bind(this)}get value(){return this.getAttribute("value")||""}set value(q){this.setAttribute("value",q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(q){if(q){if(this.#S())return;this.setAttribute("open","")}else this.removeAttribute("open")}connectedCallback(){if(this.#z(),this.#L(),this.#B(),this.#H(),this.#A(),this.#T(),this.#P(),this.open)this.#v()}disconnectedCallback(){if(this.#k(),this.#O(),document.removeEventListener("keydown",this.#K,!0),this.#J)this.#J.disconnect(),this.#J=null;if(this.#Q){this.#Q.removeEventListener("close",this.#U);let q=Array.from(this.#q?.querySelectorAll(":scope > fig-menu-item, :scope > fig-separator")??[]);for(let Q of q)this.insertBefore(Q,this.#Q);this.#Q.remove(),this.#Q=null,this.#q=null}}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="open"){if(Z===null||Z==="false")this.#m();else{if(this.#S()){this.removeAttribute("open");return}this.#v()}return}if(q==="disabled"){this.#P();return}if(this.#Q&&(q==="position"||q==="offset"||q==="closedby"))if(Z!==null)this.#Q.setAttribute(q,Z);else this.#Q.removeAttribute(q)}#z(){this.#Z=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-separator)")}#M(){return(this.getAttribute("trigger")||"").toLowerCase()==="contextmenu"||this.hasAttribute("contextmenu")}#L(){this.#Q=document.createElement("dialog",{is:"fig-popup"}),this.#Q.setAttribute("is","fig-popup"),this.#Q.classList.add("fig-menu-popup"),this.#Q.setAttribute("theme","menu"),this.#Q.setAttribute("role","menu"),this.#Q.setAttribute("id",this.#Q.getAttribute("id")||m());let q=this.getAttribute("position")||"bottom left";this.#Q.setAttribute("position",q);let Q=this.getAttribute("offset");if(Q)this.#Q.setAttribute("offset",Q);let Z=this.getAttribute("closedby");if(Z)this.#Q.setAttribute("closedby",Z);if(this.#Z)this.#Q.anchor=this.#Z;this.#q=document.createElement("div"),this.#q.className="fig-menu-options",this.#q.setAttribute("role","presentation"),this.#Q.appendChild(this.#q),this.#Q.addEventListener("close",this.#U),this.appendChild(this.#Q)}#B(){if(!this.#q)return;let q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-separator"));for(let Q of q)this.#q.appendChild(Q)}#H(){if(this.addEventListener("keydown",this.#K),this.#Z)this.#Z.addEventListener("click",this.#W),this.#Z.addEventListener("contextmenu",this.#X),this.#Z.setAttribute("aria-haspopup","menu"),this.#Z.setAttribute("aria-expanded","false"),this.#Z.setAttribute("aria-controls",this.#Q.getAttribute("id"));if(this.#Q)this.#Q.addEventListener("click",this.#G),this.#Q.addEventListener("keydown",this.#K)}#k(){if(this.removeEventListener("keydown",this.#K),this.#Z)this.#Z.removeEventListener("click",this.#W),this.#Z.removeEventListener("contextmenu",this.#X);if(this.#Q)this.#Q.removeEventListener("click",this.#G),this.#Q.removeEventListener("keydown",this.#K)}#T(){this.#J=new MutationObserver((q)=>{for(let Q of q)for(let Z of Q.addedNodes){if(Z.nodeType!==1||Z===this.#Q)continue;if((Z.tagName==="FIG-MENU-ITEM"||Z.tagName==="FIG-SEPARATOR")&&Z.parentElement===this)this.#q?.appendChild(Z);else if(!this.#Z&&Z.parentElement===this){if(this.#z(),this.#Z)this.#Z.addEventListener("click",this.#W),this.#Z.addEventListener("contextmenu",this.#X),this.#Z.setAttribute("aria-haspopup","menu"),this.#Z.setAttribute("aria-expanded","false"),this.#Z.setAttribute("aria-controls",this.#Q.getAttribute("id")),this.#Q.anchor=this.#Z,this.#P()}}this.#f()}),this.#J.observe(this,{childList:!0})}#A(){if(!this.#q)return;this.#D(),this.#q.addEventListener("scroll",this.#Y,{passive:!0}),this.#j?.disconnect(),this.#j=new ResizeObserver(()=>this.#f()),this.#j.observe(this.#q),requestAnimationFrame(()=>this.#f())}#O(){this.#q?.removeEventListener("scroll",this.#Y),this.#j?.disconnect(),this.#j=null,this.#C()}#f(){return q0(this.#q,this.#q,"y")}#D(){if(this.#N&&this.#_&&this.#q?.contains(this.#N)&&this.#q?.contains(this.#_))return;this.#C();let q=B0({owner:"menu",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>Q0(this.#q,"y",-1),onEnd:()=>Q0(this.#q,"y",1)});this.#N=q.start,this.#_=q.end,this.#q.prepend(this.#N),this.#q.append(this.#_)}#C(){this.#N?.remove(),this.#_?.remove(),this.#N=null,this.#_=null,this.#q?.classList.remove("overflow-start","overflow-end")}#V(){if(!this.#q)return[];return Array.from(this.#q.querySelectorAll("fig-menu-item")).filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false")}#F(){let q=this.#V();if(!q.length){this.#R=-1;return}let Q=document.activeElement,Z=q.findIndex(($)=>$===Q||$.contains(Q));this.#R=Z>=0?Z:-1}#I(q){let Q=this.#V();if(!Q.length)return;let Z=(q+Q.length)%Q.length;this.#R=Z;let $=Q[Z];$.focus(),vq(this.#q,$,"y")}#P(){let q=this.#S();if(q)if(this.open)this.removeAttribute("open");else this.#m();if(!this.#Z)return;if(q)this.#Z.setAttribute("disabled",""),this.#Z.setAttribute("aria-disabled","true"),this.#Z.setAttribute("aria-expanded","false");else this.#Z.removeAttribute("disabled"),this.#Z.removeAttribute("aria-disabled")}#S(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#w(q){if(this.#M())return;if(this.#S())return;q.stopPropagation();let Q=this.#Q?.matches?.(":open")??!1;if(this.open&&!Q)this.removeAttribute("open");if(this.open&&Q)this.open=!1;else{if(this.#Q&&this.#Z)this.#Q.anchor=this.#Z;this.open=!0}}#y(q){if(!this.#M())return;if(this.#S())return;q.preventDefault(),q.stopPropagation(),this.#g(q.clientX,q.clientY)}#g(q,Q){let Z=!1,$=0,J=()=>{window.clearTimeout($),window.removeEventListener("pointerup",j,!0),window.removeEventListener("pointercancel",_,!0)},j=()=>{if(Z)return;Z=!0,J(),requestAnimationFrame(()=>this.showAt(q,Q))},_=()=>{if(Z)return;Z=!0,J()};window.addEventListener("pointerup",j,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),$=window.setTimeout(j,180)}#b(q){if(this.#S())return;let Q=q.target.closest("fig-menu-item");if(!Q)return;if(Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.#x(Q)}#E(q){if(this.#S())return;if(q.currentTarget===document&&q.key!=="Escape")return;if(q.currentTarget===this&&this.#Q?.contains(q.target))return;if(!this.open||!this.#Q?.matches?.(":open")){if(this.#Z?.contains(q.target)&&(q.key==="ArrowDown"||q.key==="Enter"||q.key===" ")){if(q.preventDefault(),this.#Q&&this.#Z)this.#Q.anchor=this.#Z;this.open=!0,requestAnimationFrame(()=>this.#I(0))}return}let Q=this.#V();if(!Q.length)return;switch(q.key){case"ArrowDown":{q.preventDefault(),this.#F(),this.#I(this.#R+1);break}case"ArrowUp":{q.preventDefault(),this.#F(),this.#I(this.#R-1);break}case"Home":{q.preventDefault(),this.#I(0);break}case"End":{q.preventDefault(),this.#I(Q.length-1);break}case"Escape":{q.preventDefault(),this.open=!1,this.#Z?.focus();break}case"Enter":case" ":{this.#F();let Z=Q[this.#R];if(!Z)return;q.preventDefault(),this.#x(Z);break}}}#h(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#Z)this.#Z.setAttribute("aria-expanded","false"),this.#Z.focus();this.#R=-1}#x(q){let Q=q.getAttribute("value")||q.textContent.trim();this.setAttribute("value",Q),this.dispatchEvent(new CustomEvent("change",{detail:{value:Q,item:q},bubbles:!0})),this.open=!1}showAt(q,Q){if(this.#S())return;if(this.#$={getBoundingClientRect:()=>({width:0,height:0,top:Q,right:q,bottom:Q,left:q,x:q,y:Q})},this.#Q)this.#Q.anchor=this.#$;if(this.open)this.open=!1;requestAnimationFrame(()=>{if(this.#S())return;this.open=!0})}#v(){if(!this.#Q||this.#S()){if(this.hasAttribute("open"))this.removeAttribute("open");return}if(this.#Q.open=!0,document.addEventListener("keydown",this.#K,!0),this.#Z)this.#Z.setAttribute("aria-expanded","true");this.#R=-1,requestAnimationFrame(()=>{if(this.#f(),!this.#Z?.matches?.(":focus-visible"))return;this.#I(0)})}#m(){if(!this.#Q)return;document.removeEventListener("keydown",this.#K,!0),this.#Q.open=!1,this.#Z?.setAttribute("aria-expanded","false")}}O("fig-menu",Vq);
|
|
273
|
+
</fig-fill-picker>`:`<fig-swatch background="${Z}"${_}></fig-swatch>`,this.#Q=this.querySelector("fig-fill-picker"),this.#q=this.querySelector("fig-swatch"),this.#N(),this.#Q?.addEventListener("input",this.#$),this.#Q?.addEventListener("change",this.#J),!this.#Q)this.#q?.addEventListener("input",this.#$),this.#q?.addEventListener("change",this.#J);this.#_(),this.#z()}#U=()=>{let q=this.#j;this.dispatchEvent(new CustomEvent(q,{bubbles:!0,composed:!0}))};#K(q){if(!q)return"#D9D9D9";let Q=q.replace("#","").trim();if(Q.length===3||Q.length===4){let[Z,$,J]=Q;return`#${Z}${Z}${$}${$}${J}${J}`.toUpperCase()}if(Q.length===6||Q.length===8)return`#${Q.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#G(q){if(!q)return 1;let Q=String(q).trim(),Z=Q.replace(/^#/,"");if(/^[0-9a-f]{4}$/i.test(Z)){let J=Z[3];return parseInt(`${J}${J}`,16)/255}if(/^[0-9a-f]{8}$/i.test(Z))return parseInt(Z.slice(6,8),16)/255;let $=Q.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/i);if($)return parseFloat($[1]);return 1}#Y(q){if(!q)return"#D9D9D9";let Q=String(q).trim();if(Q.startsWith("{"))try{let Z=JSON.parse(Q);if(Z?.color)return this.#Y(Z.color)}catch{}if(Q.startsWith("#"))return this.#K(Q);if(/^[0-9a-f]{3,4}$|^[0-9a-f]{6}$|^[0-9a-f]{8}$/i.test(Q))return this.#K(Q);try{let{ctx:Z}=z0(1,1);Z.fillStyle="#000000",Z.fillStyle=Q;let $=Z.fillStyle;if($.startsWith("#"))return this.#K($);let J=$.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(J){let j=(_)=>Math.max(0,Math.min(255,Number(_))).toString(16).padStart(2,"0");return`#${j(J[1])}${j(J[2])}${j(J[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#R(){let q=this.getAttribute("value"),Q=this.#Y(q),Z=this.#G(q);if(q!==Q&&Z>=1){this.setAttribute("value",Q);return}if(this.#Q){this.#z();let $=Z<1?{type:"solid",color:Q,opacity:Math.round(Z*100)}:{type:"solid",color:Q};if(this.#Q.setAttribute("value",JSON.stringify($)),this.#W)this.#Q.removeAttribute("alpha");else this.#Q.setAttribute("alpha","false");if(T(this,"disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}if(this.#q){if(this.#z(),this.#q.setAttribute("background",Q),Z<1)this.#q.setAttribute("alpha",String(Z));else this.#q.removeAttribute("alpha");if(T(this,"disabled"))this.#q.setAttribute("disabled","");else this.#q.removeAttribute("disabled")}}#z(){let q=this.#j,Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Z=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(this.setAttribute("aria-disabled",Q?"true":"false"),this.setAttribute("aria-pressed",Z?"true":"false"),q==="add"||q==="remove"){let W=this.querySelector("fig-button"),N=this.getAttribute("aria-label")||(q==="add"?"Add color stop":"Remove color stop");if(W?.setAttribute("aria-label",N),Q)W?.setAttribute("disabled","");else W?.removeAttribute("disabled");return}let $=this.#Q||this.#q;if(!$)return;let J=this.getAttribute("aria-label")||"Color stop",j=this.getAttribute("aria-labelledby"),_=this.getAttribute("aria-describedby");if(j)$.setAttribute("aria-labelledby",j),$.removeAttribute("aria-label");else $.setAttribute("aria-label",J),$.removeAttribute("aria-labelledby");if(_)$.setAttribute("aria-describedby",_);else $.removeAttribute("aria-describedby")}#M(q,Q){let Z=this.#Y(q?.color),$=this.#Y(this.getAttribute("value"));if(Z!==$)this.setAttribute("value",Z);else this.#R();let J={color:this.value};if(this.#W){if(q?.opacity!==void 0)J.opacity=q.opacity;else if(q?.alpha!==void 0)J.opacity=Math.round(q.alpha*100)}Object.assign(J,r(J.color,this.#W?q?.alpha:1,J.opacity)),this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,cancelable:!0,composed:!0,detail:J}))}#L(q){q.stopPropagation(),this.#M(q.detail||{color:q.target?.value},"input")}#O(q){q.stopPropagation(),this.#M(q.detail||{color:q.target?.value},"change")}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(!this.isConnected)return;switch(q){case"control":this.#X();break;case"value":case"selected":case"disabled":case"aria-label":case"aria-labelledby":case"aria-describedby":this.#R(),this.#z();break}}get value(){return this.#Y(this.getAttribute("value"))}set value(q){if(q===null||q===void 0||q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#Y(q))}get selected(){return T(this,"selected")}set selected(q){this.toggleAttribute("selected",Boolean(q))}get disabled(){return T(this,"disabled")}set disabled(q){this.toggleAttribute("disabled",Boolean(q))}}O("fig-color-tip",kq);class fq extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",T(this,"selected")?"true":"false"),T(this,"disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(q){if(q==="selected")this.setAttribute("aria-selected",T(this,"selected")?"true":"false");if(q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}O("fig-choice",fq);class Dq extends HTMLElement{#Q=null;#q=this.#H.bind(this);#Z=this.#f.bind(this);#$=this.#A.bind(this);#J=null;#j=null;#N=null;#_=null;#W=null;#X=!1;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","columns","drag","layout","overflow","loop"]}get#U(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#K(){let q=this.getAttribute("drag");return q===null||q!=="false"}get#G(){return this.getAttribute("choice-element")||"fig-choice"}#Y(){let q=this.getAttribute("columns"),Q=q===null?NaN:Number(q);if(Number.isInteger(Q)&&Q>0)this.style.setProperty("--fig-chooser-grid-columns",String(Q));else this.style.removeProperty("--fig-chooser-grid-columns")}get choices(){return Array.from(this.querySelectorAll(`:scope > ${this.#G}`))}get selectedChoice(){return this.#Q}set selectedChoice(q){if(q&&!this.contains(q))return;let Q=this.choices;for(let $ of Q){let J=$===q,j=T($,"selected");if(J&&!j)$.setAttribute("selected","");else if(!J&&j)$.removeAttribute("selected")}this.#Q=q;let Z=q?.getAttribute("value")??"";if(this.getAttribute("value")!==Z){if(Z)this.setAttribute("value",Z)}this.#w(q)}get value(){return this.#Q?.getAttribute("value")??""}set value(q){if(q===null||q===void 0||q==="")return;this.setAttribute("value",String(q))}connectedCallback(){if(this.setAttribute("role","listbox"),this.shadowRoot)this.shadowRoot.replaceChildren();this.#Y(),this.#S(),this.addEventListener("click",this.#q),this.addEventListener("keydown",this.#Z),this.addEventListener("scroll",this.#$),this.#V(),this.#k(),this.#y(),this.#B(),this.#M(),u(this,()=>{this.#z(),this.#A(),this.#R()})}#R(){let q=()=>{if(!this.isConnected)return;if(this.#Q)this.#w(this.#Q,"auto")},Q=()=>{let Z=this.querySelectorAll("img, video");for(let $ of Z){if($.tagName==="IMG"?$.complete:$.readyState>=1)continue;let J=()=>{$.removeEventListener("load",J),$.removeEventListener("loadedmetadata",J),$.removeEventListener("error",J),q()};$.addEventListener("load",J),$.addEventListener("loadedmetadata",J),$.addEventListener("error",J)}};requestAnimationFrame(()=>{Q(),q()})}disconnectedCallback(){this.removeEventListener("click",this.#q),this.removeEventListener("keydown",this.#Z),this.removeEventListener("scroll",this.#$),this.#P(),this.#J?.disconnect(),this.#J=null,this.#j?.disconnect(),this.#j=null,this.#F()}attributeChangedCallback(q,Q,Z){if(q==="value"&&Z!==Q&&Z)this.#L(Z);if(q==="disabled")this.#M();if(q==="choice-element")requestAnimationFrame(()=>this.#z());if(q==="columns")this.#Y(),this.#C();if(q==="drag")if(this.#K)this.#k();else this.#P();if(q==="overflow")this.#V(),requestAnimationFrame(()=>this.#A());if(q==="layout"){if(this.#V(),Z==="horizontal")this.scrollTop=0;else this.scrollLeft=0;this.#C()}}#z(){let q=this.choices;if(!q.length){this.#Q=null;return}let Q=this.getAttribute("value");if(Q&&this.#L(Q))return;let Z=q.find(($)=>T($,"selected"));if(Z){this.selectedChoice=Z;return}this.selectedChoice=q[0]}#M(){let q=T(this,"disabled");if(q)this.setAttribute("aria-disabled","true");else this.removeAttribute("aria-disabled");for(let Q of this.choices)if(q||T(Q,"disabled"))Q.setAttribute("aria-disabled","true"),Q.setAttribute("tabindex","-1");else Q.removeAttribute("aria-disabled"),Q.setAttribute("tabindex","0")}#L(q){let Q=this.choices;for(let Z of Q)if(Z.getAttribute("value")===q)return this.selectedChoice=Z,!0;return!1}#O(q){let Q=this.#G,Z=q;while(Z&&Z!==this){if(Z.matches(Q))return Z;Z=Z.parentElement}return null}#H(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.#O(q.target);if(!Q)return;if(Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.selectedChoice=Q,this.#T()}#f(q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;let Q=this.choices.filter((j)=>!j.hasAttribute("disabled")||j.getAttribute("disabled")==="false");if(!Q.length)return;let Z=Q.indexOf(this.#Q),$=Z,J=this.hasAttribute("loop");switch(q.key){case"ArrowDown":case"ArrowRight":if(q.preventDefault(),Z<Q.length-1)$=Z+1;else if(J)$=0;break;case"ArrowUp":case"ArrowLeft":if(q.preventDefault(),Z>0)$=Z-1;else if(J)$=Q.length-1;break;case"Home":q.preventDefault(),$=0;break;case"End":q.preventDefault(),$=Q.length-1;break;case"Enter":case" ":if(q.preventDefault(),document.activeElement?.matches(this.#G)){let j=this.#O(document.activeElement);if(j&&j!==this.#Q)this.selectedChoice=j,this.#T()}return;default:return}if($!==Z&&Q[$])this.selectedChoice=Q[$],Q[$].focus(),this.#T()}#T(){let q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:q,bubbles:!0}))}#A(){if(this.#U==="scrollbar")return;let q=this.getAttribute("layout")==="horizontal";q0(this,this,q?"x":"y")}#B(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#A(),this.#C()}),this.#j.observe(this)}#k(){if(this.#W?.bound)return;if(!this.#K)return;let q=(j)=>{if(j.button!==0)return;if(j.target.closest("[data-fig-chooser-nav]"))return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#W.active=!0,this.#W.didDrag=!1,this.#W.startX=j.clientX,this.#W.startY=j.clientY,this.#W.scrollLeft=this.scrollLeft,this.#W.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},Q=(j)=>{if(!this.#W.active)return;let _=this.getAttribute("layout")==="horizontal",W=j.clientX-this.#W.startX,N=j.clientY-this.#W.startY;if(!this.#W.didDrag&&Math.abs(_?W:N)>3)this.#W.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(j.pointerId);if(!this.#W.didDrag)return;if(_)this.scrollLeft=this.#W.scrollLeft-W;else this.scrollTop=this.#W.scrollTop-N},Z=(j)=>{if(!this.#W.active)return;let _=this.#W.didDrag;if(this.#W.active=!1,this.#W.didDrag=!1,this.style.cursor="",this.style.userSelect="",j.pointerId!==void 0)try{this.releasePointerCapture(j.pointerId)}catch{}if(_)j.preventDefault(),j.stopPropagation()},$=(j)=>{if(this.#W?.suppressClick)j.stopPropagation(),j.preventDefault(),this.#W.suppressClick=!1},J=(j)=>{if(this.#W?.didDrag)this.#W.suppressClick=!0,setTimeout(()=>{if(this.#W)this.#W.suppressClick=!1},0)};this.#W={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:q,onPointerMove:Q,onPointerUp:Z,onClick:$,onPointerUpCapture:J},this.addEventListener("pointerdown",q),window.addEventListener("pointermove",Q),window.addEventListener("pointerup",Z),this.addEventListener("pointerup",J,!0),this.addEventListener("click",$,!0)}#P(){if(!this.#W?.bound)return;this.removeEventListener("pointerdown",this.#W.onPointerDown),window.removeEventListener("pointermove",this.#W.onPointerMove),window.removeEventListener("pointerup",this.#W.onPointerUp),this.removeEventListener("pointerup",this.#W.onPointerUpCapture,!0),this.removeEventListener("click",this.#W.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#W=null}#S(){if(this.#X)return;let q=this.querySelector(":scope > [data-fig-chooser-scroll]");if(!q)return;this.#X=!0;try{let Q=Array.from(q.childNodes);q.replaceWith(...Q)}finally{this.#X=!1}}#V(){if(this.#U==="scrollbar")this.#F();else this.#I()}#F(){this.#N?.remove(),this.#_?.remove(),this.#N=null,this.#_=null,this.classList.remove("overflow-start","overflow-end")}#I(){if(this.#N&&this.#_&&this.contains(this.#N)&&this.contains(this.#_))return;this.#N?.remove(),this.#_?.remove(),this.#N=null,this.#_=null;let q=B0({owner:"chooser",startClass:"fig-chooser-nav-start",endClass:"fig-chooser-nav-end",chevronClass:"fig-chooser-nav-chevron",onStart:()=>this.#D(-1),onEnd:()=>this.#D(1)});this.#N=q.start,this.#_=q.end,this.prepend(this.#N),this.append(this.#_)}#D(q){let Q=this.getAttribute("layout")==="horizontal";Q0(this,Q?"x":"y",q)}#C(){if(!this.#Q)return;this.#w(this.#Q,"auto")}#w(q,Q="smooth"){if(!q)return;requestAnimationFrame(()=>{if(!q.isConnected)return;let Z=this.scrollHeight>this.clientHeight,$=this.scrollWidth>this.clientWidth;if(!$&&!Z)return;let J=q.getBoundingClientRect(),j=this.getBoundingClientRect(),_={behavior:Q},W=!1;if(Z){let N=J.top-j.top+this.scrollTop,K=this.scrollHeight-this.clientHeight;_.top=Math.max(0,Math.min(N+J.height/2-this.clientHeight/2,K)),W=!0}if($){let N=J.left-j.left+this.scrollLeft,K=this.scrollWidth-this.clientWidth;_.left=Math.max(0,Math.min(N+J.width/2-this.clientWidth/2,K)),W=!0}if(W)this.scrollTo(_);this.#A()})}#y(){this.#J?.disconnect(),this.#J=new MutationObserver(()=>{if(this.#X)return;this.#S(),this.#V(),this.#M();let q=this.choices;if(this.#Q&&!q.includes(this.#Q))this.#Q=null,this.#z();else if(!this.#Q&&q.length)this.#z();requestAnimationFrame(()=>this.#A())}),this.#J.observe(this,{childList:!0,subtree:!1})}}O("fig-chooser",Dq);class Pq extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","tip","hit-area","hit-area-mode","aria-label","aria-labelledby"];#Q=!1;#q=!1;#Z=null;#$=null;#J=!1;#j=null;#N=null;#_=null;#W=null;get#X(){let q=(this.getAttribute("tip")||"").trim().toLowerCase();return q==="color"||q==="add"||q==="remove"?q:null}get#U(){return!this.hasAttribute("data-no-color-picker")}get#K(){let q=this.getAttribute("drag");return q!==null&&q!=="false"}get#G(){let q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:q.includes("x"),y:q.includes("y")}}get#Y(){let q=this.getAttribute("drag-snapping");if(q===null)return"false";let Q=q.trim().toLowerCase();if(Q==="modifier")return"modifier";if(Q===""||Q==="true")return"true";return"false"}#R(q){let Q=this.#Y;if(Q==="true")return!0;if(Q==="modifier")return!!q;return!1}#z(q){if(q<0.1)return 0;if(q>0.9)return 1;if(q>0.4&&q<0.6)return 0.5;return q}#M(q,Q){if(Math.abs(q-Q)<0.1){let $=(q+Q)/2;return{x:$,y:$}}if(Math.abs(1-q-Q)<0.1)return{x:q,y:1-q};return{x:q,y:Q}}#L(){let q=this.getAttribute("drag-surface");if(!q||q==="parent")return this.parentElement;return this.closest(q)}get value(){let q=this.#L();if(!q)return"0% 0%";let{px:Q,py:Z}=this.#e(q.getBoundingClientRect());return`${Math.round(Q*100)}% ${Math.round(Z*100)}%`}set value(q){this.setAttribute("value",q??"0% 0%")}#O(q){let Q=q==null?"":String(q).trim();if(!Q)return{xPct:0,yPct:0};let Z=Q.split(/[\s,]+/).filter(Boolean),$=(_)=>{if(!_)return 0;let W=_.includes("px"),N=_.includes("%"),K=parseFloat(_.replace(/[%px]/g,""));if(!Number.isFinite(K))return 0;if(W)return{px:K};if(N||Math.abs(K)>1)return Math.max(0,Math.min(100,K));return Math.max(0,Math.min(100,K*100))},J=$(Z[0]),j=$(Z[1]??Z[0]);return{xToken:J,yToken:j}}#H(q){let Q=this.#L();if(!Q)return;let{xToken:Z,yToken:$}=this.#O(q),J=Q.getBoundingClientRect(),j=(N,K)=>{if(N&&typeof N==="object"&&"px"in N)return Math.max(0,Math.min(K,N.px));return null},_=(N)=>{return`${typeof N==="number"?N:0}%`},W=this.#G;if(this.#f(W),W.x){let N=j(Z,J.width);this.style.left=N===null?_(Z):`${Math.round(N)}px`}if(W.y){let N=j($,J.height);this.style.top=N===null?_($):`${Math.round(N)}px`}}#f(q=this.#G){this.style.setProperty("--fig-handle-position-translate",`${q.x?"-50%":"0"} ${q.y?"-50%":"0"}`)}#T(){this.#J=!0,this.setAttribute("value",this.value),this.#J=!1}get#A(){return this.getAttribute("hit-area-mode")||"handle"}#B(){let q=this.getAttribute("hit-area");if(!q)return null;let Q=q.trim().split(/\s+/),Z=0,$=0,J=!1,j=[];for(let _ of Q){if(_==="circle"){J=!0;continue}let W=parseFloat(_);if(Number.isFinite(W))j.push(W)}if(j.length>=2)Z=j[0],$=j[1];else if(j.length===1)Z=j[0],$=j[0];else return null;return{vPad:Z,hPad:$,circle:J}}#k(){let q=this.#B();if(!q){if(this.#W)this.#W.remove(),this.#W=null;this.style.removeProperty("--fig-handle-hit-area-size");return}if(!this.#W){let Q=document.createElement("div");Q.classList.add("fig-handle-hit-area"),Q.addEventListener("pointerdown",(Z)=>this.#P(Z)),this.prepend(Q),this.#W=Q}if(this.style.setProperty("--fig-handle-hit-area-size",String(q.hPad*2)),q.circle)this.#W.style.borderRadius="50%";else this.#W.style.borderRadius="inherit"}#P(q){if(T(this,"disabled"))return;if(q.target!==this.#W)return;if(this.#A==="delegate")q.preventDefault(),q.stopPropagation(),this.dispatchEvent(new CustomEvent("hitareadown",{bubbles:!0,detail:{originalEvent:q}}));else this.#y(q)}connectedCallback(){this.#C(),this.#D(),this.#k(),this.addEventListener("click",this.#S),document.addEventListener("pointerdown",this.#V),document.addEventListener("keydown",this.#F);let q=this.getAttribute("value");if(q)this.#H(q);if(this.#X)this.#o()}disconnectedCallback(){if(this.#w(),this.#c(),this.#h(),this.#l(),this.#W)this.#W.remove(),this.#W=null;this.removeEventListener("click",this.#S),document.removeEventListener("pointerdown",this.#V),document.removeEventListener("keydown",this.#F)}select(){if(T(this,"disabled"))return;this.setAttribute("selected","")}deselect(){this.removeAttribute("selected")}#S=(q)=>{if(this.#q){this.#q=!1;return}if(this.getAttribute("type")==="color"&&this.#U&&!this.#X){this.#x();return}this.select()};#V=(q)=>{if(this.contains(q.target))return;if((this.#j||this.#N)&&q.target.closest?.("dialog, [popover]"))return;this.deselect()};#F=(q)=>{if(q.defaultPrevented)return;if(q.target===this&&this.#K&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(q.key)){if(this.#I(q)){if(q.preventDefault(),!T(this,"selected"))this.select()}return}if(q.key!=="Enter"&&q.key!==" ")return;if(q.target===this&&!T(this,"selected")){if(q.preventDefault(),this.getAttribute("type")==="color"&&this.#U&&!this.#X)this.#x();else this.select();return}if(!T(this,"selected"))return;if(this.getAttribute("type")!=="color")return;if(!this.#U)return;if(q.preventDefault(),!this.#X)this.#x()};#I(q){if(T(this,"disabled"))return!1;let Q=this.#L();if(!Q)return!1;let Z=Q.getBoundingClientRect();if(Z.width<=0||Z.height<=0)return!1;let $=this.#G,J=this.#e(Z),j=q.shiftKey?0.1:0.01,_=J.px,W=J.py;switch(q.key){case"ArrowLeft":if(!$.x)return!1;_-=j;break;case"ArrowRight":if(!$.x)return!1;_+=j;break;case"ArrowUp":if(!$.y)return!1;W-=j;break;case"ArrowDown":if(!$.y)return!1;W+=j;break;case"Home":if($.x)_=0;if($.y)W=0;break;case"End":if($.x)_=1;if($.y)W=1;break;default:return!1}if(_=Math.max(0,Math.min(1,_)),W=Math.max(0,Math.min(1,W)),this.#f($),$.x)this.style.left=`${Math.round(_*Z.width)}px`;if($.y)this.style.top=`${Math.round(W*Z.height)}px`;this.#T();let N={...this.#e(Z),shiftKey:q.shiftKey,keyboard:!0};return this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:N})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:N})),!0}attributeChangedCallback(q,Q,Z){if(q==="color"){if(!Z||Z==="false"||Z==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",Z);if(this.#j&&this.#X==="color"&&Z)this.#j.setAttribute("value",Z);this.#E()}if(q==="drag")this.#D();if(q==="hit-area")this.#k();if(q==="selected")this.#i();if(q==="selected"||q==="disabled"||q==="type"||q==="tip"||q==="aria-label"||q==="aria-labelledby")this.#C();if(q==="value"&&!this.#J&&!this.#Q)this.#H(Z);if(q==="tip"){if(this.#c(),this.#X)this.#h(),this.#o()}}#D(){if(this.#K&&!this.#Z)this.#Z=(q)=>this.#y(q),this.addEventListener("pointerdown",this.#Z);else if(!this.#K&&this.#Z)this.#w()}#C(){let q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";if(!this.hasAttribute("role"))this.setAttribute("role","button");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex",q?"-1":"0");else if(q)this.setAttribute("tabindex","-1");if(this.setAttribute("aria-disabled",q?"true":"false"),this.setAttribute("aria-pressed",Q?"true":"false"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")){let Z=this.#X||this.getAttribute("type")||"handle";this.setAttribute("aria-label",Z==="color"?"Color handle":Z==="add"?"Add handle":Z==="remove"?"Remove handle":"Handle")}}#w(){if(this.#$?.(),this.#$=null,this.#Z)this.removeEventListener("pointerdown",this.#Z),this.#Z=null;this.#Q=!1,this.#q=!1}#y(q){if(!this.#K||T(this,"disabled"))return;q.preventDefault();let Q=this.#L();if(!Q)return;this.#$?.(),this.#Q=!0;let Z=this.#G,$=null,J=this.getBoundingClientRect(),j=J.left+J.width/2,_=J.top+J.height/2,W=q.clientX-j,N=q.clientY-_,K=q.clientX,G=q.clientY,U=3,X=(k,H,A=!1)=>{let R=Q.getBoundingClientRect();$=R;let D=this.#e(R),I=k-W-R.left,S=H-N-R.top,w=Math.max(0,Math.min(R.width,I)),y=Math.max(0,Math.min(R.height,S)),g=R.width>0?Z.x?w/R.width:D.px:0.5,d=R.height>0?Z.y?y/R.height:D.py:0.5;if(this.#R(A)){if(Z.x)g=this.#z(g);if(Z.y)d=this.#z(d);if(Z.x&&Z.y){let t=this.#M(g,d);g=t.x,d=t.y}}if(this.#f(Z),Z.x)this.style.left=`${Math.round(Math.max(0,Math.min(R.width,g*R.width)))}px`;if(Z.y)this.style.top=`${Math.round(Math.max(0,Math.min(R.height,d*R.height)))}px`},z=(k)=>{if(!this.#Q)return;if(!this.#q){let H=k.clientX-K,A=k.clientY-G;if(H*H+A*A<U*U)return;if(this.#u(),this.classList.add("dragging"),this.style.cursor="grabbing",!T(this,"selected"))this.select()}this.#q=!0,X(k.clientX,k.clientY,k.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#e($),shiftKey:k.shiftKey}}))},B=(k)=>{if(L(),this.#q){X(k.clientX,k.clientY,k.shiftKey),this.#T(),this.#H(this.getAttribute("value")),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#e($)}));let H=(A)=>{A.stopPropagation(),A.preventDefault()};this.addEventListener("click",H,{capture:!0,once:!0})}else this.#T();this.#q=!1},L=()=>{if(window.removeEventListener("pointermove",z),window.removeEventListener("pointerup",B),this.#Q=!1,this.style.cursor="",this.classList.remove("dragging"),this.#$===L)this.#$=null};this.#$=L,window.addEventListener("pointermove",z),window.addEventListener("pointerup",B)}showColorTip(){if(!this.#X)return;if(this.#j){this.#j.style.display="";return}this.#o()}hideColorTip(){if(!this.#j)return;this.#j.style.display="none"}#m(q=this.getAttribute("color")){let Q={color:"#D9D9D9",opacity:100},Z=String(q||"").trim();if(!Z)return Q;let $=(j)=>{let _=j.replace("#","").trim();if(_.length===3||_.length===4){let[W,N,K,G]=_;return{color:`#${W}${W}${N}${N}${K}${K}`.toUpperCase(),opacity:G?Math.round(parseInt(`${G}${G}`,16)/255*100):100}}if(_.length===6||_.length===8)return{color:`#${_.slice(0,6)}`.toUpperCase(),opacity:_.length===8?Math.round(parseInt(_.slice(6,8),16)/255*100):100};return Q},J=(j,_,W)=>{let N=(K)=>Math.max(0,Math.min(255,Math.round(Number(K)))).toString(16).padStart(2,"0");return`#${N(j)}${N(_)}${N(W)}`.toUpperCase()};if(Z.startsWith("#"))return $(Z);try{let{ctx:j}=z0(1,1);j.fillStyle="#000000",j.fillStyle=Z;let _=j.fillStyle;if(_.startsWith("#"))return $(_);let W=_.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?/i);if(W)return{color:J(W[1],W[2],W[3]),opacity:W[4]!==void 0?Math.round(parseFloat(W[4])*100):100}}catch{}return Q}#b(){let{color:q,opacity:Q}=this.#m();return JSON.stringify(Q<100?{type:"solid",color:q,opacity:Q}:{type:"solid",color:q})}#E(){if(!this.#N)return;this.#N.setAttribute("value",this.#b())}#v(){if(!o())return null;if(this.#N)return this.#N;let q=document.createElement("fig-fill-picker");q.setAttribute("mode","solid"),q.setAttribute("alpha","true"),q.setAttribute("dialog-offset","8 8"),q.setAttribute("value",this.#b()),q.anchorElement=this;let Q=document.createElement("span");return Q.hidden=!0,q.appendChild(Q),q.addEventListener("input",this.#d),q.addEventListener("change",this.#a),q.addEventListener("close",this.#j0),this.appendChild(q),this.#N=q,q}#x(){if(T(this,"disabled"))return;let q=this.#v();if(!q){this.#r();return}this.setAttribute("selected",""),this.#E(),q.open()}#h(){if(!this.#N)return;this.#N.removeEventListener("input",this.#d),this.#N.removeEventListener("change",this.#a),this.#N.removeEventListener("close",this.#j0),this.#N.close(),this.#N.remove(),this.#N=null,this.removeAttribute("selected")}#g(){if(this.#_)return this.#_;let q=document.createElement("input");return q.type="color",q.tabIndex=-1,q.setAttribute("aria-hidden","true"),q.style.position="fixed",q.style.inlineSize="1px",q.style.blockSize="1px",q.style.opacity="0",q.style.pointerEvents="none",q.addEventListener("input",this.#Z0),q.addEventListener("change",this.#J0),this.appendChild(q),this.#_=q,q}#r(){let q=this.#g(),{color:Q}=this.#m();q.value=Q,this.setAttribute("selected",""),q.click()}#l(){if(!this.#_)return;this.#_.removeEventListener("input",this.#Z0),this.#_.removeEventListener("change",this.#J0),this.#_.remove(),this.#_=null}#u(){if(this.getAttribute("type")!=="color")return;this.#N?.close()}#o(){let q=this.#X;if(!q)return;if(this.#j)return;let Q=document.createElement("fig-color-tip");if(q==="add"||q==="remove")Q.setAttribute("control",q);else Q.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Q.setAttribute("alpha","true");Q.addEventListener("input",this.#q0),Q.addEventListener("change",this.#t),Q.addEventListener("add",this.#$0),Q.addEventListener("remove",this.#$0),this.appendChild(Q),this.#j=Q,this.#i()}#c(){if(!this.#j)return;this.#j.removeEventListener("input",this.#q0),this.#j.removeEventListener("change",this.#t),this.#j.removeEventListener("add",this.#$0),this.#j.removeEventListener("remove",this.#$0),this.#j.remove(),this.#j=null}#i(){if(!this.#j||this.#X!=="color")return;let q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false";this.#j.toggleAttribute("selected",q)}#s(q,Q){if(Q===void 0||Q>=100)return q;let{r:Z,g:$,b:J}=i(q);return`rgba(${Z}, ${$}, ${J}, ${Q/100})`}#p(q){if(!q?.color)return null;let Q=q.opacity!==void 0?q.opacity:q.alpha!==void 0?Math.round(q.alpha*100):void 0;return{color:q.color,opacity:Q,...r(q.color,q.alpha,Q)}}#d=(q)=>{q.stopPropagation();let Q=this.#p(q.detail);if(!Q)return;this.setAttribute("color",this.#s(Q.color,Q.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Q}))};#a=(q)=>{q.stopPropagation();let Q=this.#p(q.detail);if(!Q)return;this.setAttribute("color",this.#s(Q.color,Q.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Q}))};#Q0(q){let{opacity:Q}=this.#m();return{...Q<100?{color:q,opacity:Q}:{color:q},...r(q,void 0,Q)}}#Z0=(q)=>{q.stopPropagation();let Q=this.#Q0(q.target.value);this.setAttribute("color",this.#s(Q.color,Q.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Q}))};#J0=(q)=>{q.stopPropagation();let Q=this.#Q0(q.target.value);this.setAttribute("color",this.#s(Q.color,Q.opacity)),this.removeAttribute("selected"),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Q}))};#j0=()=>{this.removeAttribute("selected")};#q0=(q)=>{if(q.stopPropagation(),q.detail?.color){let Q={color:q.detail.color,opacity:q.detail.opacity,...r(q.detail.color,q.detail.alpha,q.detail.opacity)};this.setAttribute("color",this.#s(Q.color,Q.opacity)),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:Q}))}};#t=(q)=>{if(q.stopPropagation(),q.detail?.color){let Q={color:q.detail.color,opacity:q.detail.opacity,...r(q.detail.color,q.detail.alpha,q.detail.opacity)};this.setAttribute("color",this.#s(Q.color,Q.opacity)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:Q}))}};#$0=(q)=>{q.stopPropagation(),this.dispatchEvent(new CustomEvent(q.type,{bubbles:!0,composed:!0}))};#e(q){let Q=q||this.#L()?.getBoundingClientRect();if(!Q)return{x:0,y:0,px:0,py:0};let Z=this.getBoundingClientRect(),$=this.offsetWidth/2,J=this.offsetHeight/2,j=Z.left-Q.left,_=Z.top-Q.top,W=j+$,N=_+J,K=Q.width>0?W/Q.width:0,G=Q.height>0?N/Q.height:0;return{x:j,y:_,px:K,py:G}}}O("fig-handle",Pq);class Iq extends HTMLElement{static get observedAttributes(){return["value","disabled"]}get value(){return this.getAttribute("value")||""}set value(q){this.setAttribute("value",q??"")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","menuitem");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#Q()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="disabled")this.#Q()}#Q(){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}O("fig-menu-item",Iq);class Sq extends HTMLElement{static get observedAttributes(){return["label"]}get label(){return this.getAttribute("label")??""}set label(q){if(q==null||q==="")this.removeAttribute("label");else this.setAttribute("label",String(q))}connectedCallback(){this.#Q()}attributeChangedCallback(q,Q,Z){if(Q===Z)return;this.#Q()}#Q(){if(!this.hasAttribute("role"))this.setAttribute("role","separator");let q=this.label.trim();if(q)this.setAttribute("aria-label",q);else this.removeAttribute("aria-label")}}O("fig-separator",Sq);class Vq extends HTMLElement{#Q=null;#q=null;#Z=null;#$=null;#J=null;#j=null;#N=null;#_=null;#W;#X;#U;#K;#G;#Y=this.#k.bind(this);#R=-1;static get observedAttributes(){return["position","offset","closedby","disabled","open","trigger"]}constructor(){super();this.#W=this.#w.bind(this),this.#X=this.#y.bind(this),this.#U=this.#b.bind(this),this.#K=this.#E.bind(this),this.#G=this.#v.bind(this)}get value(){return this.getAttribute("value")||""}set value(q){this.setAttribute("value",q??"")}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(q){if(q){if(this.#C())return;this.setAttribute("open","")}else this.removeAttribute("open")}connectedCallback(){if(this.#z(),this.#L(),this.#O(),this.#H(),this.#A(),this.#T(),this.#D(),this.open)this.#h()}disconnectedCallback(){if(this.#f(),this.#B(),document.removeEventListener("keydown",this.#K,!0),this.#J)this.#J.disconnect(),this.#J=null;if(this.#Q){this.#Q.removeEventListener("close",this.#G);let q=Array.from(this.#q?.querySelectorAll(":scope > fig-menu-item, :scope > fig-separator")??[]);for(let Q of q)this.insertBefore(Q,this.#Q);this.#Q.remove(),this.#Q=null,this.#q=null}}attributeChangedCallback(q,Q,Z){if(Q===Z)return;if(q==="open"){if(Z===null||Z==="false")this.#g();else{if(this.#C()){this.removeAttribute("open");return}this.#h()}return}if(q==="disabled"){this.#D();return}if(this.#Q&&(q==="position"||q==="offset"||q==="closedby"))if(Z!==null)this.#Q.setAttribute(q,Z);else this.#Q.removeAttribute(q)}#z(){this.#Z=this.querySelector("[fig-menu-trigger]")||this.querySelector(":scope > :not(fig-menu-item):not(fig-separator)")}#M(){return(this.getAttribute("trigger")||"").toLowerCase()==="contextmenu"||this.hasAttribute("contextmenu")}#L(){this.#Q=document.createElement("dialog",{is:"fig-popup"}),this.#Q.setAttribute("is","fig-popup"),this.#Q.classList.add("fig-menu-popup"),this.#Q.setAttribute("theme","menu"),this.#Q.setAttribute("role","menu"),this.#Q.setAttribute("id",this.#Q.getAttribute("id")||m());let q=this.getAttribute("position")||"bottom left";this.#Q.setAttribute("position",q);let Q=this.getAttribute("offset");if(Q)this.#Q.setAttribute("offset",Q);let Z=this.getAttribute("closedby");if(Z)this.#Q.setAttribute("closedby",Z);if(this.#Z)this.#Q.anchor=this.#Z;this.#q=document.createElement("div"),this.#q.className="fig-menu-options",this.#q.setAttribute("role","presentation"),this.#Q.appendChild(this.#q),this.#Q.addEventListener("close",this.#G),this.appendChild(this.#Q)}#O(){if(!this.#q)return;let q=Array.from(this.querySelectorAll(":scope > fig-menu-item, :scope > fig-separator"));for(let Q of q)this.#q.appendChild(Q)}#H(){if(this.addEventListener("keydown",this.#K),this.#Z)this.#Z.addEventListener("click",this.#W),this.#Z.addEventListener("contextmenu",this.#X),this.#Z.setAttribute("aria-haspopup","menu"),this.#Z.setAttribute("aria-expanded","false"),this.#Z.setAttribute("aria-controls",this.#Q.getAttribute("id"));if(this.#Q)this.#Q.addEventListener("click",this.#U),this.#Q.addEventListener("keydown",this.#K)}#f(){if(this.removeEventListener("keydown",this.#K),this.#Z)this.#Z.removeEventListener("click",this.#W),this.#Z.removeEventListener("contextmenu",this.#X);if(this.#Q)this.#Q.removeEventListener("click",this.#U),this.#Q.removeEventListener("keydown",this.#K)}#T(){this.#J=new MutationObserver((q)=>{for(let Q of q)for(let Z of Q.addedNodes){if(Z.nodeType!==1||Z===this.#Q)continue;if((Z.tagName==="FIG-MENU-ITEM"||Z.tagName==="FIG-SEPARATOR")&&Z.parentElement===this)this.#q?.appendChild(Z);else if(!this.#Z&&Z.parentElement===this){if(this.#z(),this.#Z)this.#Z.addEventListener("click",this.#W),this.#Z.addEventListener("contextmenu",this.#X),this.#Z.setAttribute("aria-haspopup","menu"),this.#Z.setAttribute("aria-expanded","false"),this.#Z.setAttribute("aria-controls",this.#Q.getAttribute("id")),this.#Q.anchor=this.#Z,this.#D()}}this.#k()}),this.#J.observe(this,{childList:!0})}#A(){if(!this.#q)return;this.#P(),this.#q.addEventListener("scroll",this.#Y,{passive:!0}),this.#j?.disconnect(),this.#j=new ResizeObserver(()=>this.#k()),this.#j.observe(this.#q),requestAnimationFrame(()=>this.#k())}#B(){this.#q?.removeEventListener("scroll",this.#Y),this.#j?.disconnect(),this.#j=null,this.#S()}#k(){return q0(this.#q,this.#q,"y")}#P(){if(this.#N&&this.#_&&this.#q?.contains(this.#N)&&this.#q?.contains(this.#_))return;this.#S();let q=B0({owner:"menu",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>Q0(this.#q,"y",-1),onEnd:()=>Q0(this.#q,"y",1)});this.#N=q.start,this.#_=q.end,this.#q.prepend(this.#N),this.#q.append(this.#_)}#S(){this.#N?.remove(),this.#_?.remove(),this.#N=null,this.#_=null,this.#q?.classList.remove("overflow-start","overflow-end")}#V(){if(!this.#q)return[];return Array.from(this.#q.querySelectorAll("fig-menu-item")).filter((q)=>!q.hasAttribute("disabled")||q.getAttribute("disabled")==="false")}#F(){let q=this.#V();if(!q.length){this.#R=-1;return}let Q=document.activeElement,Z=q.findIndex(($)=>$===Q||$.contains(Q));this.#R=Z>=0?Z:-1}#I(q){let Q=this.#V();if(!Q.length)return;let Z=(q+Q.length)%Q.length;this.#R=Z;let $=Q[Z];$.focus(),vq(this.#q,$,"y")}#D(){let q=this.#C();if(q)if(this.open)this.removeAttribute("open");else this.#g();if(!this.#Z)return;if(q)this.#Z.setAttribute("disabled",""),this.#Z.setAttribute("aria-disabled","true"),this.#Z.setAttribute("aria-expanded","false");else this.#Z.removeAttribute("disabled"),this.#Z.removeAttribute("aria-disabled")}#C(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#w(q){if(this.#M())return;if(this.#C())return;q.stopPropagation();let Q=this.#Q?.matches?.(":open")??!1;if(this.open&&!Q)this.removeAttribute("open");if(this.open&&Q)this.open=!1;else{if(this.#Q&&this.#Z)this.#Q.anchor=this.#Z;this.open=!0}}#y(q){if(!this.#M())return;if(this.#C())return;q.preventDefault(),q.stopPropagation(),this.#m(q.clientX,q.clientY)}#m(q,Q){let Z=!1,$=0,J=()=>{window.clearTimeout($),window.removeEventListener("pointerup",j,!0),window.removeEventListener("pointercancel",_,!0)},j=()=>{if(Z)return;Z=!0,J(),requestAnimationFrame(()=>this.showAt(q,Q))},_=()=>{if(Z)return;Z=!0,J()};window.addEventListener("pointerup",j,{once:!0,capture:!0}),window.addEventListener("pointercancel",_,{once:!0,capture:!0}),$=window.setTimeout(j,180)}#b(q){if(this.#C())return;let Q=q.target.closest("fig-menu-item");if(!Q)return;if(Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.#x(Q)}#E(q){if(this.#C())return;if(q.currentTarget===document&&q.key!=="Escape")return;if(q.currentTarget===this&&this.#Q?.contains(q.target))return;if(!this.open||!this.#Q?.matches?.(":open")){if(this.#Z?.contains(q.target)&&(q.key==="ArrowDown"||q.key==="Enter"||q.key===" ")){if(q.preventDefault(),this.#Q&&this.#Z)this.#Q.anchor=this.#Z;this.open=!0,requestAnimationFrame(()=>this.#I(0))}return}let Q=this.#V();if(!Q.length)return;switch(q.key){case"ArrowDown":{q.preventDefault(),this.#F(),this.#I(this.#R+1);break}case"ArrowUp":{q.preventDefault(),this.#F(),this.#I(this.#R-1);break}case"Home":{q.preventDefault(),this.#I(0);break}case"End":{q.preventDefault(),this.#I(Q.length-1);break}case"Escape":{q.preventDefault(),this.open=!1,this.#Z?.focus();break}case"Enter":case" ":{this.#F();let Z=Q[this.#R];if(!Z)return;q.preventDefault(),this.#x(Z);break}}}#v(){if(this.hasAttribute("open"))this.removeAttribute("open");if(this.#Z)this.#Z.setAttribute("aria-expanded","false"),this.#Z.focus();this.#R=-1}#x(q){let Q=q.getAttribute("value")||q.textContent.trim();this.setAttribute("value",Q),this.dispatchEvent(new CustomEvent("change",{detail:{value:Q,item:q},bubbles:!0})),this.open=!1}showAt(q,Q){if(this.#C())return;if(this.#$={getBoundingClientRect:()=>({width:0,height:0,top:Q,right:q,bottom:Q,left:q,x:q,y:Q})},this.#Q)this.#Q.anchor=this.#$;if(this.open)this.open=!1;requestAnimationFrame(()=>{if(this.#C())return;this.open=!0})}#h(){if(!this.#Q||this.#C()){if(this.hasAttribute("open"))this.removeAttribute("open");return}if(this.#Q.open=!0,document.addEventListener("keydown",this.#K,!0),this.#Z)this.#Z.setAttribute("aria-expanded","true");this.#R=-1,requestAnimationFrame(()=>{if(this.#k(),!this.#Z?.matches?.(":focus-visible"))return;this.#I(0)})}#g(){if(!this.#Q)return;document.removeEventListener("keydown",this.#K,!0),this.#Q.open=!1,this.#Z?.setAttribute("aria-expanded","false")}}O("fig-menu",Vq);
|