@rogieking/figui3 3.16.0 → 3.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +725 -643
- package/components.css +1 -21
- package/dist/base.css +1 -99
- package/dist/components.css +1 -3978
- package/dist/fig.css +1 -2
- package/dist/fig.js +80 -78
- package/fig.js +209 -151
- package/package.json +14 -9
package/dist/fig.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var u0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var s0={};var Z0=u0(()=>{/*! Vendored from @ungap/custom-elements-builtin@0.6.5 (ISC). */(function(Q,$,J){if(Q.importNode.length!=1||$.get("ungap-li"))return;var Z="extends";try{var j={};j[Z]="li";var _=HTMLLIElement,q=function(){return Reflect.construct(_,[],q)};if(q.prototype=J.create(_.prototype),$.define("ungap-li",q,j),!/is="ungap-li"/.test(new q().outerHTML))throw j}catch(K){(function(){var X="attributeChangedCallback",Y="connectedCallback",W="disconnectedCallback",U=Element.prototype,L=J.assign,z=J.create,M=J.defineProperties,G=J.getOwnPropertyDescriptor,B=J.setPrototypeOf,A=$.define,F=$.get,R=$.upgrade,T=$.whenDefined,k=z(null),w=new WeakMap,f={childList:!0,subtree:!0};Reflect.ownKeys(self).filter(function(N){return typeof N=="string"&&/^HTML(?!Element)/.test(N)}).forEach(function(N){function O(){}var E=self[N];B(O,E),(O.prototype=E.prototype).constructor=O,E={},E[N]={value:O},M(self,E)}),new MutationObserver(n).observe(Q,f),J0(Document.prototype,"importNode"),J0(Node.prototype,"cloneNode"),M($,{define:{value:function(N,O,E){if(N=N.toLowerCase(),E&&Z in E){k[N]=L({},E,{Class:O});var P=E[Z]+'[is="'+N+'"]',D=Q.querySelectorAll(P);for(var H=0,S=D.length;H<S;H++)h(D[H])}else A.apply($,arguments)}},get:{value:function(N){return N in k?k[N].Class:F.call($,N)}},upgrade:{value:function(N){var O=s(N);if(O&&!(N instanceof O.Class))$0(N,O);else R.call($,N)}},whenDefined:{value:function(N){return N in k?Promise.resolve():T.call($,N)}}});var x=Q.createElement;M(Q,{createElement:{value:function(N,O){var E=x.call(Q,N);if(O&&"is"in O)E.setAttribute("is",O.is),$.upgrade(E);return E}}});var g0=G(U,"attachShadow").value,a=G(U,"innerHTML");M(U,{attachShadow:{value:function(){var N=g0.apply(this,arguments);return new MutationObserver(n).observe(N,f),N}},innerHTML:{get:a.get,set:function(N){if(a.set.call(this,N),/\bis=("|')?[a-z0-9_-]+\1/i.test(N))m(this,h)}}});function n(N){for(var O=0,E=N.length;O<E;O++){var P=N[O],D=P.addedNodes,H=P.removedNodes;for(var S=0,p=D.length;S<p;S++)h(D[S]);for(var d=0,c0=H.length;d<c0;d++)Q0(H[d])}}function e(N){for(var O=0,E=N.length;O<E;O++){var P=N[O],D=P.attributeName,H=P.oldValue,S=P.target,p=S.getAttribute(D);if(X in S&&!(H==p&&p==null))S[X](D,H,S.getAttribute(D),null)}}function Q0(N){if(N.nodeType!==1)return;var O=s(N);if(O&&N instanceof O.Class&&W in N&&w.get(N)!==W)w.set(N,W),Promise.resolve(N).then(p0);m(N,Q0)}function s(N){var O=N.getAttribute("is");if(O){if(O=O.toLowerCase(),O in k)return k[O]}return null}function m0(N){N[Y]()}function p0(N){N[W]()}function $0(N,O){var E=O.Class,P=E.observedAttributes||[];if(B(N,E.prototype),P.length){new MutationObserver(e).observe(N,{attributes:!0,attributeFilter:P,attributeOldValue:!0});var D=[];for(var H=0,S=P.length;H<S;H++)D.push({attributeName:P[H],oldValue:null,target:N});e(D)}}function h(N){if(N.nodeType!==1)return;var O=s(N);if(O){if(!(N instanceof O.Class))$0(N,O);if(Y in N&&N.isConnected&&w.get(N)!==Y)w.set(N,Y),Promise.resolve(N).then(m0)}m(N,h)}function m(N,O){for(var E=N.content,P=(E&&E.nodeType==11?E:N).querySelectorAll("[is]"),D=0,H=P.length;D<H;D++)O(P[D])}function J0(N,O){var E=N[O],P={};P[O]={value:function(){var D=E.apply(this,arguments);switch(D.nodeType){case 1:case 11:m(D,h)}return D}},M(N,P)}})()}})(document,customElements,Object)});function d0(){if(typeof navigator==="undefined")return!1;const Q=navigator.userAgent||"",$=/\b(iPad|iPhone|iPod)\b/.test(Q)||/\bMacintosh\b/.test(Q)&&/\bMobile\b/.test(Q),J=/\bAppleWebKit\b/.test(Q)&&!/\b(Chrome|Chromium|Edg|OPR|SamsungBrowser)\b/.test(Q);return $||J}function i0(){if(typeof window==="undefined"||!window.customElements||typeof HTMLButtonElement==="undefined")return!1;const Q=`fig-builtin-probe-${Math.random().toString(36).slice(2)}`;class $ extends HTMLButtonElement{}try{return customElements.define(Q,$,{extends:"button"}),document.createElement("button",{is:Q})instanceof $}catch(J){return!1}}function i(Q,$,J){const Z=()=>{if(!customElements.get(Q))customElements.define(Q,$,J)};if(!_0){Z();return}r0.then(Z).catch((j)=>{console.error(`[figui3] Failed to load customized built-in polyfill for "${Q}".`,j)})}function v(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function q0(){return o0++}function C(Q,$,J){if(J&&J.trim())Q.style.setProperty($,J.trim());else Q.style.removeProperty($)}function r(Q=1,$=1){if(!V)V=document.createElement("canvas"),j0=V.getContext("2d");if(V.width!==Q)V.width=Q;if(V.height!==$)V.height=$;return{canvas:V,ctx:j0}}function y(Q){const $={...Q??{}};let J=String($.interpolationSpace??"oklab").toLowerCase();if(!l0.includes(J))J="oklab";if(J==="srgb"||J==="display-p3")J="oklab";$.interpolationSpace=J;const Z=String($.hueInterpolation??"shorter").toLowerCase();return $.hueInterpolation=t0.includes(Z)?Z:"shorter",$}function o(Q){const $=y(Q),J={...$,interpolationSpace:$.interpolationSpace};if($.interpolationSpace==="oklch")J.hueInterpolation=$.hueInterpolation;else delete J.hueInterpolation;return J}function a0(Q){const $=y(Q);if($.interpolationSpace==="oklch")return`in oklch ${$.hueInterpolation} hue`;return`in ${$.interpolationSpace}`}function n0(Q,$,J){return e0(Q,$,J).map((j)=>+(j/255).toFixed(4))}function e0(Q,$,J){$/=100,J/=100;const Z=(1-Math.abs(2*J-1))*$,j=Z*(1-Math.abs(Q/60%2-1)),_=J-Z/2;let q,K,X;if(Q<60)q=Z,K=j,X=0;else if(Q<120)q=j,K=Z,X=0;else if(Q<180)q=0,K=Z,X=j;else if(Q<240)q=0,K=j,X=Z;else if(Q<300)q=j,K=0,X=Z;else q=Z,K=0,X=j;return[Math.round((q+_)*255),Math.round((K+_)*255),Math.round((X+_)*255)]}var _0=d0()&&!i0(),r0=(_0?Promise.resolve().then(() => (Z0(),s0)):Promise.resolve()).then(()=>{}).catch((Q)=>{throw Q}),o0=1e4,V=null,j0=null;class K0 extends HTMLElement{type;#$;constructor(){super();this.attachShadow({mode:"open",delegatesFocus:!0})}connectedCallback(){this.type=this.getAttribute("type")||"button",this.shadowRoot.innerHTML=`
|
|
2
2
|
<style>
|
|
3
3
|
button, button:hover, button:active {
|
|
4
4
|
padding: 0 var(--spacer-2);
|
|
@@ -32,7 +32,7 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
32
32
|
<button type="${this.type}">
|
|
33
33
|
<slot></slot>
|
|
34
34
|
</button>
|
|
35
|
-
`,this.#Q=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",requestAnimationFrame(()=>{this.button=this.shadowRoot.querySelector("button"),this.button.addEventListener("click",this.#J.bind(this)),this.button.addEventListener("focus",()=>{if(this.button.matches(":focus-visible"))this.setAttribute("data-focus-visible","")}),this.button.addEventListener("blur",()=>{this.removeAttribute("data-focus-visible")})})}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)}#J(){if(this.type==="toggle")this.toggleAttribute("selected",!this.hasAttribute("selected"));if(this.type==="submit"){let Q=this.closest("form");if(Q)Q.submit()}if(this.type==="link"){const Q=this.getAttribute("href"),$=this.getAttribute("target");if(Q)if($)window.open(Q,$);else window.location.href=Q}}static get observedAttributes(){return["disabled","selected"]}attributeChangedCallback(Q,$,J){if(this.button)switch(this.button[Q]=J,Q){case"disabled":this.disabled=this.button.disabled=J!==null&&J!=="false";break;case"type":this.type=J,this.button.type=this.type,this.button.setAttribute("type",this.type);break;case"selected":this.#Q=J==="true";break}}}customElements.define("fig-button",$0);class J0 extends HTMLElement{#Q="Menu";#J=null;#$;#Z;#q=!1;#K=null;get label(){return this.#Q}set label(Q){this.#Q=Q}constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#$=this.#U.bind(this),this.#Z=this.#O.bind(this)}#_(){if(typeof CSS==="undefined"||typeof CSS.supports!=="function")return!1;try{return CSS.supports("appearance: base-select")&&CSS.supports("selector(::picker(select))")}catch{return!1}}#W(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#_()){this.#q=!1;return}const J=document.createElement("button");J.setAttribute("type","button"),J.setAttribute("aria-hidden","true");const Z=document.createElement("selectedcontent");J.appendChild(Z),this.select.appendChild(J),this.#q=!0,this.#K=Z}#j(){if(!this.#K)return;const Q=this.select.selectedOptions?.[0];if(!Q){this.#K.textContent="";return}this.#K.innerHTML=Q.innerHTML}#X(){this.select.addEventListener("input",this.#$),this.select.addEventListener("change",this.#Z)}#Y(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#G(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){this.type=this.getAttribute("type")||"select",this.#Q=this.getAttribute("label")||this.#Q,this.select.setAttribute("aria-label",this.#Q),this.appendChild(this.select),this.shadowRoot.appendChild(this.optionsSlot),this.optionsSlot.addEventListener("slotchange",this.slotChange.bind(this)),this.#X()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.#W(),this.type==="dropdown"){const Q=document.createElement("option");Q.setAttribute("hidden","true"),Q.setAttribute("selected","true"),Q.selected=!0,this.select.appendChild(Q)}if(this.optionsSlot.assignedNodes().forEach((Q)=>{if(Q.nodeName==="OPTION"||Q.nodeName==="OPTGROUP")this.select.appendChild(Q.cloneNode(!0))}),this.#L(this.value),this.#j(),this.type==="dropdown")this.select.selectedIndex=-1}#U(Q){const $=Q.target.selectedOptions?.[0];if(this.#Y($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#G();return}const J=Q.target.value;if(this.type==="dropdown")this.#J=J;this.setAttribute("value",J),this.#j(),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}#O(Q){const $=Q.target.selectedOptions?.[0];if(this.#Y($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#G();return}const J=this.type==="dropdown"?this.#J:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#j(),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#J;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#J=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","experimental"]}#L(Q){if(this.type==="dropdown")return;if(this.select)this.select.querySelectorAll("option").forEach(($,J)=>{if($.value===this.getAttribute("value"))this.select.selectedIndex=J});this.#j()}attributeChangedCallback(Q,$,J){if(Q==="value")this.#L(J);if(Q==="type")this.type=J;if(Q==="experimental")this.slotChange();if(Q==="label")this.#Q=J,this.select.setAttribute("aria-label",this.#Q)}}customElements.define("fig-dropdown",J0);class V extends HTMLElement{static#Q=0;static#J=500;#$;#Z;#q;#K=!1;#_=null;#W=null;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#$=this.#N.bind(this),this.#Z=this.hidePopupOutsideClick.bind(this)}connectedCallback(){this.setup(),this.setupEventListeners()}disconnectedCallback(){if(this.destroy(),document.removeEventListener("mousedown",this.#$,!0),this.#Y(),this.action==="click")document.body.removeEventListener("click",this.#Z);if(clearTimeout(this.#q),this.action==="hover")this.removeEventListener("touchstart",this.#U),this.removeEventListener("touchmove",this.#O),this.removeEventListener("touchend",this.#L),this.removeEventListener("touchcancel",this.#M);else if(this.action==="click")this.removeEventListener("touchstart",this.showDelayedPopup)}setup(){this.style.display="contents"}render(){this.destroy();let Q=document.createElement("span");this.popup=document.createElement("span"),this.popup.setAttribute("class","fig-tooltip"),this.popup.setAttribute("role","tooltip");const $=w();if(this.popup.setAttribute("id",$),this.popup.style.position="fixed",this.popup.style.visibility="hidden",this.popup.style.display="inline-flex",this.popup.style.pointerEvents="none",this.popup.append(Q),Q.innerText=this.getAttribute("text"),this.firstElementChild)this.firstElementChild.setAttribute("aria-describedby",$);const J=this.closest("dialog");if(J&&J.open)J.append(this.popup);else document.body.append(this.popup);const Z=Q.childNodes[0];if(Z){const j=document.createRange();j.setStartBefore(Z),j.setEndAfter(Z);const _=j.getBoundingClientRect();Q.style.width=`${_.width}px`}}destroy(){if(this.#Y(),this.popup)this.popup.remove();if(this.action==="click")document.body.removeEventListener("click",this.#Z)}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="hover"){if(!this.isTouchDevice())this.addEventListener("pointerenter",this.showDelayedPopup.bind(this)),this.addEventListener("pointerleave",this.#G.bind(this));this.addEventListener("touchstart",this.#U.bind(this),{passive:!0}),this.addEventListener("touchmove",this.#O.bind(this),{passive:!0}),this.addEventListener("touchend",this.#L.bind(this),{passive:!0}),this.addEventListener("touchcancel",this.#M.bind(this),{passive:!0})}else if(this.action==="click")this.addEventListener("click",this.showDelayedPopup.bind(this)),document.body.addEventListener("click",this.#Z),this.addEventListener("touchstart",this.showDelayedPopup.bind(this),{passive:!0});document.addEventListener("mousedown",this.#$,!0)}getOffset(){const Q={left:8,top:4,right:8,bottom:4},$=this.getAttribute("offset");if(!$)return Q;const[J,Z,j,_]=$.split(",").map(Number);return{left:isNaN(J)?Q.left:J,top:isNaN(Z)?Q.top:Z,right:isNaN(j)?Q.right:j,bottom:isNaN(_)?Q.bottom:_}}showDelayedPopup(){this.render(),clearTimeout(this.timeout);const $=Date.now()-V.#Q<V.#J?0:this.delay;this.timeout=setTimeout(this.showPopup.bind(this),$)}showPopup(){this.#j(),this.popup.style.opacity="1",this.popup.style.visibility="visible",this.popup.style.display="block",this.popup.style.pointerEvents="all",this.popup.style.zIndex=Q0()+1,this.isOpen=!0,V.#Q=Date.now(),this.#X()}#j(){if(!this.popup||!this.firstElementChild)return;const Q=this.firstElementChild.getBoundingClientRect(),$=this.popup.getBoundingClientRect(),J=this.getOffset();let Z=Q.top-$.height-J.top,j=Q.left+(Q.width-$.width)/2;if(this.popup.setAttribute("position","top"),Z<0)this.popup.setAttribute("position","bottom"),Z=Q.bottom+J.bottom;if(j<J.left)j=J.left;else if(j+$.width>window.innerWidth-J.right)j=window.innerWidth-$.width-J.right;const q=Q.left+Q.width/2-j;this.popup.style.setProperty("--beak-offset",`${q}px`),this.popup.style.top=`${Z}px`,this.popup.style.left=`${j}px`}hidePopup(){if(clearTimeout(this.timeout),clearTimeout(this.#q),this.#Y(),this.popup)this.popup.style.opacity="0",this.popup.style.display="block",this.popup.style.pointerEvents="none",this.destroy();this.isOpen=!1,V.#Q=Date.now()}#X(){this.#Y();const Q=this.firstElementChild;if(!Q)return;this.#_=new MutationObserver(()=>{if(this.#W)cancelAnimationFrame(this.#W);this.#W=requestAnimationFrame(()=>{this.#j()})}),this.#_.observe(Q,{attributes:!0,attributeFilter:["style","class","transform"]})}#Y(){if(this.#W)cancelAnimationFrame(this.#W),this.#W=null;if(this.#_)this.#_.disconnect(),this.#_=null}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#G(Q){if(!this.#K)this.hidePopup()}#U(Q){if(this.action==="hover")this.#K=!0,clearTimeout(this.#q),this.showDelayedPopup()}#O(Q){if(this.action==="hover"&&this.#K)clearTimeout(this.#q),this.#q=setTimeout(()=>{this.#K=!1,this.hidePopup()},150)}#L(Q){if(this.action==="hover"&&this.#K)clearTimeout(this.#q),this.#q=setTimeout(()=>{this.#K=!1,this.hidePopup()},300)}#M(Q){if(this.action==="hover"&&this.#K)this.#K=!1,clearTimeout(this.#q),this.hidePopup()}static get observedAttributes(){return["action","delay","open"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")==="true"}set open(Q){this.setAttribute("open",Q)}attributeChangedCallback(Q,$,J){if(Q==="action")this.action=J;if(Q==="delay"){let Z=parseInt(J);this.delay=!isNaN(Z)?Z:500}if(Q==="open")if(J==="true")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()})}#N(Q){if(!this.isOpen)return;const $=Q.target;if(this.popup&&this.popup.contains($))return;if($.tagName==="SELECT"||$.hasAttribute("popover")||$.closest("dialog"))this.hidePopup()}}customElements.define("fig-tooltip",V);class Z0 extends HTMLDialogElement{#Q=!1;#J=!1;#$={x:0,y:0};#Z={x:0,y:0};#q;#K;#_;#W=16;#j=!1;#X=3;constructor(){super();this.#q=this.#M.bind(this),this.#K=this.#N.bind(this),this.#_=this.#B.bind(this)}connectedCallback(){this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",requestAnimationFrame(()=>{this.#Y(),this.#U(),this.#G()})}disconnectedCallback(){this.#O()}#Y(){this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this.close),Q.addEventListener("click",this.close.bind(this))})}#G(){const 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";const $=Q.includes("top"),J=Q.includes("bottom"),Z=Q.includes("left"),j=Q.includes("right"),_=Q.includes("center")&&!$&&!J,K=Q.includes("center")&&!Z&&!j;if($)this.style.top=`${this.#W}px`;else if(J)this.style.bottom=`${this.#W}px`;else if(_)this.style.top="0",this.style.bottom="0";if(Z)this.style.left=`${this.#W}px`;else if(j)this.style.right=`${this.#W}px`;else if(K)this.style.left="0",this.style.right="0";if(_&&K)this.style.margin="auto";else if(_)this.style.marginTop="auto",this.style.marginBottom="auto";else if(K)this.style.marginLeft="auto",this.style.marginRight="auto";this.#j=!0}#U(){if(this.drag){this.addEventListener("pointerdown",this.#q);const Q=this.getAttribute("handle"),$=Q?this.querySelector(Q):this.querySelector("fig-header, header");if($)$.style.cursor="grab"}}#O(){this.removeEventListener("pointerdown",this.#q),document.removeEventListener("pointermove",this.#K),document.removeEventListener("pointerup",this.#_)}#L(Q){const $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(_)=>$.some((K)=>_.matches?.(K))||_.tagName?.startsWith("FIG-")&&!J.includes(_.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}#M(Q){if(!this.drag)return;if(this.#L(Q.target))return;const $=this.getAttribute("handle");if($&&$.trim()){const Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this.#J=!0,this.#$.x=Q.clientX,this.#$.y=Q.clientY;const J=this.getBoundingClientRect();this.#Z.x=Q.clientX-J.left,this.#Z.y=Q.clientY-J.top,document.addEventListener("pointermove",this.#K),document.addEventListener("pointerup",this.#_)}#N(Q){if(this.#J&&!this.#Q){const $=Math.abs(Q.clientX-this.#$.x),J=Math.abs(Q.clientY-this.#$.y);if($>this.#X||J>this.#X){this.#Q=!0,this.#J=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";const Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this.#Q)return;this.style.left=`${Q.clientX-this.#Z.x}px`,this.style.top=`${Q.clientY-this.#Z.y}px`,Q.preventDefault()}#B(Q){if(this.#Q)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this.#Q=!1,this.#J=!1,document.removeEventListener("pointermove",this.#K),document.removeEventListener("pointerup",this.#_),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle"]}attributeChangedCallback(Q,$,J){if(Q==="drag")if(this.drag=J!==null&&J!=="false",this.drag)this.#U();else{this.#O();const Z=this.querySelector("fig-header, header");if(Z)Z.style.cursor=""}if(Q==="position"&&this.#j)this.#G()}}p("fig-dialog",Z0,{extends:"dialog"});class j0 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;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{if(this.open&&!this.contains(Q.target)&&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)}ensureInitialized(){if(typeof this._anchorObserver==="undefined")this._anchorObserver=null;if(typeof this._contentObserver==="undefined")this._contentObserver=null;if(typeof this._mutationObserver==="undefined")this._mutationObserver=null;if(typeof this._anchorTrackRAF==="undefined")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect==="undefined")this._lastAnchorRect=null;if(typeof this._isPopupActive==="undefined")this._isPopupActive=!1;if(typeof this._rafId==="undefined")this._rafId=null;if(typeof this._anchorRef==="undefined")this._anchorRef=null;if(typeof this._isDragging==="undefined")this._isDragging=!1;if(typeof this._dragPending==="undefined")this._dragPending=!1;if(typeof this._dragStartPos==="undefined")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset==="undefined")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged==="undefined")this._wasDragged=!1;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{if(this.open&&!this.contains(Q.target)&&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)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!this.open)return;this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this.addEventListener("close",()=>{if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}),requestAnimationFrame(()=>{this.setupDragListeners()}),this.open)this.showPopup();else this.hidePopup()}disconnectedCallback(){if(this.ensureInitialized(),this.teardownObservers(),this.removeDragListeners(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(Q,$,J){if(this.ensureInitialized(),$===J)return;if(Q==="open"){if(J===null||J==="false"){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=J!==null&&J!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}if(this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(Q0()+1),!super.open)try{this.show()}catch($){}this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;const Q=this.resolveAnchor();if(Q)Q.classList.add("has-popup-open")}hidePopup(){const Q=this.resolveAnchor();if(Q)Q.classList.remove("has-popup-open");if(this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),super.open)try{this.close()}catch($){}}get autoresize(){const Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.removeAttribute("autoresize")}setupObservers(){this.teardownObservers();const Q=this.resolveAnchor();if(Q&&"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;const $=Q.getBoundingClientRect();return{x:$.x,y:$.y,width:$.width,height:$.height}}hasRectChanged(Q,$,J=0.25){if(!Q&&!$)return!1;if(!Q||!$)return!0;return Math.abs(Q.x-$.x)>J||Math.abs(Q.y-$.y)>J||Math.abs(Q.width-$.width)>J||Math.abs(Q.height-$.height)>J}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;const Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}const $=this.resolveAnchor(),J=this.readRectSnapshot($),Z=this.shouldAutoReposition();if(Z&&this.hasRectChanged(this._lastAnchorRect,J))this._lastAnchorRect=J,this.queueReposition();else if(!Z)this._lastAnchorRect=J;this._anchorTrackRAF=requestAnimationFrame(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!super.open)return;const $=this.getAttribute("closedby");if($==="none"||$==="closerequest")return;const J=Q.target;if(!(J instanceof Node))return;if(this.contains(J))return;const Z=this.resolveAnchor();if(Z&&Z.contains(J))return;if(this.isInsideDescendantPopup(J))return;this.open=!1}isInsideDescendantPopup(Q){const $=Q.closest?.('dialog[is="fig-popup"]');if(!$||$===this)return!1;let J=$;const Z=new Set;while(J&&!Z.has(J)){Z.add(J);const j=J.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;J=j.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}isInteractiveElement(Q){const $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(_)=>$.some((K)=>_.matches?.(K))||_.tagName?.startsWith("FIG-")&&!J.includes(_.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;const $=this.getAttribute("handle");if($&&$.trim()){const Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;const J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){const $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";const Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;const Q=this.getAttribute("anchor");if(!Q)return null;const $=this.parentElement;if($?.querySelector){const J=$.querySelector(Q);if(J&&!this.contains(J))return J}return document.querySelector(Q)}parsePosition(){const $=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),J=new Set(["top","center","bottom"]),Z=new Set(["left","center","right"]);let j="top",_="center",K=null;if($.length>=2){if(J.has($[0]))j=$[0];if(Z.has($[1]))_=$[1];return{vertical:j,horizontal:_,shorthand:K}}if($.length===1){const q=$[0];if(q==="top"||q==="bottom")j=q,K=q;else if(q==="left"||q==="right")_=q,K=q;else if(q==="center")j="center",_="center"}return{vertical:j,horizontal:_,shorthand:K}}normalizeOffsetToken(Q,$="0px"){if(!Q)return $;const J=Q.trim();if(!J)return $;if(/^-?\d+(\.\d+)?$/.test(J))return`${J}px`;return J}measureLengthPx(Q,$="x"){if(!Q)return 0;const J=this.normalizeOffsetToken(Q,"0px");if(J.endsWith("px")){const _=parseFloat(J);return Number.isFinite(_)?_:0}const Z=document.createElement("div");if(Z.style.position="fixed",Z.style.visibility="hidden",Z.style.pointerEvents="none",Z.style.left="0",Z.style.top="0",Z.style.margin="0",Z.style.padding="0",Z.style.border="0",$==="x")Z.style.width=J,Z.style.height="0";else Z.style.height=J,Z.style.width="0";document.body.appendChild(Z);const j=Z.getBoundingClientRect();return Z.remove(),$==="x"?j.width:j.height}parseOffset(){const $=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),J=this.normalizeOffsetToken($[0],"0px"),Z=this.normalizeOffsetToken($[1],"0px");return{xToken:J,yToken:Z,xPx:this.measureLengthPx(J,"x"),yPx:this.measureLengthPx(Z,"y")}}parseViewportMargins(){const $=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((Z)=>!Number.isNaN(Z));if($.length===0)return{top:8,right:8,bottom:8,left:8};if($.length===1)return{top:$[0],right:$[0],bottom:$[0],left:$[0]};if($.length===2)return{top:$[0],right:$[1],bottom:$[0],left:$[1]};if($.length===3)return{top:$[0],right:$[1],bottom:$[2],left:$[1]};return{top:$[0],right:$[1],bottom:$[2],left:$[3]}}getPlacementCandidates(Q,$,J){const Z={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if(J){const _=J==="left"||J==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:$,s:J},{v:Q,h:$,s:Z[J]},{v:Q,h:$,s:_[0]},{v:Q,h:$,s:_[1]}]}if(Q==="center")return[{v:"center",h:$,s:null},{v:"center",h:Z[$],s:null},{v:"top",h:$,s:null},{v:"bottom",h:$,s:null},{v:"top",h:Z[$],s:null},{v:"bottom",h:Z[$],s:null}];if($==="center")return[{v:Q,h:"center",s:null},{v:Z[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:Z[Q],h:"left",s:null},{v:Z[Q],h:"right",s:null}];return[{v:Q,h:$,s:null},{v:Z[Q],h:$,s:null},{v:Q,h:Z[$],s:null},{v:Z[Q],h:Z[$],s:null}]}computeCoords(Q,$,J,Z,j,_){let K,q;if(_==="left"||_==="right")return q=_==="left"?Q.left-$.width-j.xPx:Q.right+j.xPx,K=Q.top,{top:K,left:q};if(_==="top"||_==="bottom")return K=_==="top"?Q.top-$.height-j.yPx:Q.bottom+j.yPx,q=Q.left,{top:K,left:q};if(J==="top")K=Q.top-$.height-j.yPx;else if(J==="bottom")K=Q.bottom+j.yPx;else K=Q.top+(Q.height-$.height)/2;if(J==="center")if(Z==="left")q=Q.left-$.width-j.xPx;else if(Z==="right")q=Q.right+j.xPx;else q=Q.left+(Q.width-$.width)/2;else if(Z==="left")q=Q.left+j.xPx;else if(Z==="right")q=Q.right-$.width-j.xPx;else q=Q.left+(Q.width-$.width)/2;return{top:K,left:q}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,$,J){if(J==="top")return"top";if(J==="bottom")return"bottom";if(J==="left")return"left";if(J==="right")return"right";if(Q!=="center")return Q;if($!=="center")return $;return"top"}updatePopoverBeak(Q,$,J,Z,j){if(this.getAttribute("variant")!=="popover"||!Q){this.style.removeProperty("--beak-offset"),this.removeAttribute("data-beak-side");return}const _=this.oppositeSide(j);this.setAttribute("data-beak-side",_);const K=Q.left+Q.width/2,q=Q.top+Q.height/2,X=this.getBoundingClientRect(),W=X.width>0&&X.height>0?X:$,Y=W.left,U=W.top,L=10;let F;if(_==="top"||_==="bottom"){F=K-Y;const N=L,B=Math.max(N,W.width-L);F=Math.min(B,Math.max(N,F))}else{F=q-U;const N=L,B=Math.max(N,W.height-L);F=Math.min(B,Math.max(N,F))}this.style.setProperty("--beak-offset",`${F}px`)}overflowScore(Q,$,J){const{innerWidth:Z,innerHeight:j}=window,_=Q.left+$.width,K=Q.top+$.height,q=Math.max(0,J.left-Q.left),X=Math.max(0,J.top-Q.top),W=Math.max(0,_-(Z-J.right)),Y=Math.max(0,K-(j-J.bottom));return q+X+W+Y}fits(Q,$,J){return this.overflowScore(Q,$,J)===0}clamp(Q,$,J){const{left:Z,top:j}=J,_=Math.max(J.left,window.innerWidth-$.width-J.right),K=Math.max(J.top,window.innerHeight-$.height-J.bottom);return{left:Math.min(_,Math.max(Z,Q.left)),top:Math.min(K,Math.max(j,Q.top))}}positionPopup(){if(!this.open||!super.open)return;const Q=this.getBoundingClientRect(),$=this.parseOffset(),{vertical:J,horizontal:Z,shorthand:j}=this.parsePosition(),_=this.resolveAnchor(),K=this.parseViewportMargins();if(!_){this.updatePopoverBeak(null,Q,0,0,"top");const F={left:K.left+(window.innerWidth-K.right-K.left-Q.width)/2,top:K.top+(window.innerHeight-K.bottom-K.top-Q.height)/2},N=this.clamp(F,Q,K);this.style.left=`${N.left}px`,this.style.top=`${N.top}px`;return}const q=_.getBoundingClientRect(),X=this.getPlacementCandidates(J,Z,j);let W=null,Y="top",U=Number.POSITIVE_INFINITY;for(let{v:F,h:N,s:B}of X){const O=this.computeCoords(q,Q,F,N,$,B),H=this.getPlacementSide(F,N,B);if(B){const D=this.clamp(O,Q,K);if(B==="left"||B==="right"?O.left>=K.left&&O.left+Q.width<=window.innerWidth-K.right:O.top>=K.top&&O.top+Q.height<=window.innerHeight-K.bottom){this.style.left=`${D.left}px`,this.style.top=`${D.top}px`,this.updatePopoverBeak(q,Q,D.left,D.top,H);return}const E=this.overflowScore(O,Q,K);if(E<U)U=E,W=D,Y=H}else{if(this.fits(O,Q,K)){this.style.left=`${O.left}px`,this.style.top=`${O.top}px`,this.updatePopoverBeak(q,Q,O.left,O.top,H);return}const D=this.overflowScore(O,Q,K);if(D<U)U=D,W=O,Y=H}}const L=this.clamp(W||{left:0,top:0},Q,K);this.style.left=`${L.left}px`,this.style.top=`${L.top}px`,this.updatePopoverBeak(q,Q,L.left,L.top,Y)}queueReposition(){if(!this.open||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}}p("fig-popup",j0,{extends:"dialog"});class _0 extends HTMLElement{#Q;constructor(){super();this.content=null,this.#Q=!1}connectedCallback(){this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.handleClick.bind(this)),requestAnimationFrame(()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content)if(this.content.setAttribute("role","tabpanel"),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.handleClick)}handleClick(){if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected"]}attributeChangedCallback(Q,$,J){if(Q==="selected"){if(this.#Q=J!==null&&J!=="false",this.setAttribute("aria-selected",this.#Q?"true":"false"),this?.content)this.content.style.display=this.#Q?"block":"none"}}}customElements.define("fig-tab",_0);class K0 extends HTMLElement{constructor(){super()}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.addEventListener("click",this.handleClick.bind(this)),this.addEventListener("keydown",this.#J.bind(this)),requestAnimationFrame(()=>{const Q=this.getAttribute("value");if(Q)this.#$(Q);if(this.hasAttribute("disabled"))this.#Q(!0)})}#Q(Q){this.querySelectorAll("fig-tab").forEach((J)=>{if(Q)J.setAttribute("disabled",""),J.setAttribute("aria-disabled","true"),J.setAttribute("tabindex","-1");else J.removeAttribute("disabled"),J.removeAttribute("aria-disabled"),J.setAttribute("tabindex","0")})}disconnectedCallback(){this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.#J)}#J(Q){const $=Array.from(this.querySelectorAll("fig-tab")),J=$.findIndex((j)=>j.hasAttribute("selected"));let Z=J;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),Z=J>0?J-1:$.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),Z=J<$.length-1?J+1:0;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;default:return}if(Z!==J&&$[Z])$.forEach((j)=>j.removeAttribute("selected")),this.selectedTab=$[Z],this.setAttribute("value",$[Z].getAttribute("value")||""),$[Z].focus()}get value(){return this.selectedTab?.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q)}#$(Q){const $=this.querySelectorAll("fig-tab");for(let J of $)if(J.getAttribute("value")===Q)this.selectedTab=J,J.setAttribute("selected","true");else J.removeAttribute("selected")}attributeChangedCallback(Q,$,J){switch(Q){case"value":if(J!==$)this.#$(J);break;case"disabled":this.#Q(J!==null&&J!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled"))return;const $=Q.target;if($.nodeName.toLowerCase()==="fig-tab"){const J=this.querySelectorAll("fig-tab");for(let Z of J)if(Z===$)this.selectedTab=Z,Z.setAttribute("selected","true"),this.setAttribute("value",Z.getAttribute("value")||"");else Z.removeAttribute("selected")}}}customElements.define("fig-tabs",K0);class q0 extends HTMLElement{#Q;#J;constructor(){super()}connectedCallback(){this.addEventListener("click",this.handleClick.bind(this))}disconnectedCallback(){this.removeEventListener("click",this.handleClick)}handleClick(){const 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.#J}set selected(Q){this.#J=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value"]}attributeChangedCallback(Q,$,J){switch(Q){case"value":this.#Q=J;break;case"selected":this.#J=J;break}}}customElements.define("fig-segment",q0);class W0 extends HTMLElement{#Q=null;#J=this.handleClick.bind(this);#$=null;#Z=null;#q=0;#K=!1;#_=!1;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){this.name=this.getAttribute("name")||"segmented-control",this.addEventListener("click",this.#J),this.#R(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#B(),this.#L(),requestAnimationFrame(()=>{this.#N({enforceFallback:!0}),this.#M(),this.#U({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#J),this.#$?.disconnect(),this.#$=null,this.#Z?.disconnect(),this.#Z=null,this.#q)cancelAnimationFrame(this.#q),this.#q=0;this.#K=!1,this.#_=!1}get selectedSegment(){return this.#Q}set selectedSegment(Q){const $=this.querySelectorAll("fig-segment");for(let J of $){const Z=J===Q,j=J.hasAttribute("selected");if(Z&&!j)J.setAttribute("selected","true");else if(!Z&&j)J.removeAttribute("selected")}this.#Q=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#U()}get value(){return this.getAttribute("value")||""}set value(Q){if(Q===null||Q===void 0){this.removeAttribute("value");return}this.setAttribute("value",String(Q))}#W(Q){this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#j(Q){const $=Q.getAttribute("value");if($!==null){const J=$.trim();if(J.length>0)return J}return Q.textContent?.trim()||""}#X(){const Q=this.querySelectorAll("fig-segment");for(let $ of Q)if($.hasAttribute("selected"))return $;return null}#Y(Q){const $=String(Q??"").trim();if(!$)return!1;const J=this.querySelectorAll("fig-segment");for(let Z of J){const j=this.#j(Z);if(!j)continue;if(j===$)return this.selectedSegment=Z,!0}return!1}#G(){const Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#U({forceInstant:Q=!1}={}){if(this.#K=this.#K||Q,this.#q)return;this.#q=requestAnimationFrame(()=>{this.#q=0;const $=this.#K;this.#K=!1,this.#O({forceInstant:$})})}#O({forceInstant:Q=!1}={}){const $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#G(),Z=this.#Q&&this.contains(this.#Q)?this.#Q:this.#X();if($||!J){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!J||$)this.#_=!1;return}if(!Z){if(this.#_)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}const j=this.getBoundingClientRect(),_=Z.getBoundingClientRect();if(j.width<=0||_.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}const K=Math.max(0,_.left-j.left);this.style.setProperty("--seg-indicator-x",`${K}px`),this.style.setProperty("--seg-indicator-w",`${_.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}#L(){this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#U()}),this.#M()}#M(){if(!this.#Z)return;this.#Z.disconnect(),this.#Z.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#Z?.observe(Q)})}#N({enforceFallback:Q=!1}={}){const $=this.querySelectorAll("fig-segment");if($.length===0){this.#Q=null,this.#U({forceInstant:!0});return}const J=this.getAttribute("value"),Z=J?.trim()??"";if(J!==null){if(Z!==J){this.setAttribute("value",Z);return}if(Z&&this.#Y(Z))return}const j=this.#X();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=$[0]}#B(){this.#$?.disconnect(),this.#$=new MutationObserver((Q)=>{let $=!1;for(let J of Q){if(J.type==="childList"){$=!0;break}if(J.type==="attributes"&&J.target instanceof HTMLElement&&J.target.tagName.toLowerCase()==="fig-segment"&&(J.attributeName==="value"||J.attributeName==="selected")){$=!0;break}if(J.type==="characterData"){$=!0;break}}if($)this.#R(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#M(),this.#N({enforceFallback:!0})}),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;const $=Q.target.closest("fig-segment");if(!$||!this.contains($))return;const J=this.selectedSegment,Z=this.value;this.selectedSegment=$;const j=this.#j($);if(j)this.setAttribute("value",j);else this.removeAttribute("value");const _=this.value;if(J!==$||Z!==_)this.#W(_)}#R(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach(($)=>{if(Q)$.setAttribute("disabled",""),$.setAttribute("aria-disabled","true");else $.removeAttribute("disabled"),$.removeAttribute("aria-disabled")})}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="disabled"){this.#R(J!==null&&J!=="false"),this.#U({forceInstant:!0});return}if(Q==="value"){this.#N({enforceFallback:!1});return}if(Q==="animated"){if(!this.#G())this.#_=!1;this.#U({forceInstant:!0});return}if(Q==="sizing")this.#U({forceInstant:!0})}}customElements.define("fig-segmented-control",W0);class X0 extends HTMLElement{#Q=!1;#J=!1;#$={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"}};#Z;#q;#K;#_;constructor(){super();this.initialInnerHTML=this.innerHTML,this.#Z=(Q)=>{Q.stopPropagation(),this.#B()},this.#q=(Q)=>{Q.stopPropagation(),this.#R()},this.#K=(Q)=>{Q.stopPropagation(),this.#j()},this.#_=(Q)=>{Q.stopPropagation(),this.#D()}}#W(){const Q=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.hasAttribute("text")&&this.getAttribute("text")!=="false",this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.getAttribute("disabled")?!0:!1,this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";const $=this.#$[this.type];if(this.min=Number(this.getAttribute("min")||$.min),this.max=Number(this.getAttribute("max")||$.max),this.step=Number(this.getAttribute("step")||$.step),this.color=this.getAttribute("color")||$?.color,this.default=this.hasAttribute("default")?this.getAttribute("default"):this.type==="delta"?0:this.min,this.#J=Q===null||typeof Q==="string"&&Q.trim()==="",this.value=this.#L(Q),this.color)this.style.setProperty("--color",this.color);let J="",Z=`<div class="fig-slider-input-container" role="group">
|
|
35
|
+
`,this.#$=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",requestAnimationFrame(()=>{this.button=this.shadowRoot.querySelector("button"),this.button.addEventListener("click",this.#Q.bind(this)),this.button.addEventListener("focus",()=>{if(this.button.matches(":focus-visible"))this.setAttribute("data-focus-visible","")}),this.button.addEventListener("blur",()=>{this.removeAttribute("data-focus-visible")})})}get type(){return this.getAttribute("type")||"button"}set type(Q){this.setAttribute("type",Q)}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q)}#Q(){if(this.type==="toggle")this.toggleAttribute("selected",!this.hasAttribute("selected"));if(this.type==="submit"){let Q=this.closest("form");if(Q)Q.submit()}if(this.type==="link"){const Q=this.getAttribute("href"),$=this.getAttribute("target");if(Q)if($)window.open(Q,$);else window.location.href=Q}}static get observedAttributes(){return["disabled","selected"]}attributeChangedCallback(Q,$,J){if(this.button)switch(this.button[Q]=J,Q){case"disabled":this.disabled=this.button.disabled=J!==null&&J!=="false";break;case"type":this.type=J,this.button.type=this.type,this.button.setAttribute("type",this.type);break;case"selected":this.#$=J==="true";break}}}customElements.define("fig-button",K0);class X0 extends HTMLElement{#$="Menu";#Q=null;#J;#j;#_=!1;#Z=null;get label(){return this.#$}set label(Q){this.#$=Q}#K;constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"}),this.#J=this.#M.bind(this),this.#j=this.#L.bind(this),this.#K=this.slotChange.bind(this)}#X(){if(typeof CSS==="undefined"||typeof CSS.supports!=="function")return!1;try{return CSS.supports("appearance: base-select")&&CSS.supports("selector(::picker(select))")}catch{return!1}}#q(){if(!(this.getAttribute("experimental")||"").split(/\s+/).filter(Boolean).includes("modern")||!this.#X()){this.#_=!1;return}const J=document.createElement("button");J.setAttribute("type","button"),J.setAttribute("aria-hidden","true");const Z=document.createElement("selectedcontent");J.appendChild(Z),this.select.appendChild(J),this.#_=!0,this.#Z=Z}#W(){if(!this.#Z)return;const Q=this.select.selectedOptions?.[0];if(!Q){this.#Z.textContent="";return}this.#Z.innerHTML=Q.innerHTML}#Y(){this.select.addEventListener("input",this.#J),this.select.addEventListener("change",this.#j)}#N(Q){if(!Q||!(Q instanceof Element))return!1;return!!Q.querySelector('fig-checkbox, fig-switch, input[type="checkbox"]')}#U(){if(typeof this.select.showPicker==="function")requestAnimationFrame(()=>{try{this.select.showPicker()}catch{}})}connectedCallback(){this.type=this.getAttribute("type")||"select",this.#$=this.getAttribute("label")||this.#$,this.select.setAttribute("aria-label",this.#$),this.appendChild(this.select),this.shadowRoot.appendChild(this.optionsSlot),this.optionsSlot.addEventListener("slotchange",this.#K),this.#Y()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.#q(),this.type==="dropdown"){const Q=document.createElement("option");Q.setAttribute("hidden","true"),Q.setAttribute("selected","true"),Q.selected=!0,this.select.appendChild(Q)}if(this.optionsSlot.assignedNodes().forEach((Q)=>{if(Q.nodeName==="OPTION"||Q.nodeName==="OPTGROUP")this.select.appendChild(Q.cloneNode(!0))}),this.#O(this.value),this.#W(),this.type==="dropdown")this.select.selectedIndex=-1}#M(Q){const $=Q.target.selectedOptions?.[0];if(this.#N($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#U();return}const J=Q.target.value;if(this.type==="dropdown")this.#Q=J;this.setAttribute("value",J),this.#W(),this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0}))}#L(Q){const $=Q.target.selectedOptions?.[0];if(this.#N($)){if(this.type==="dropdown")this.select.selectedIndex=-1;this.#U();return}const J=this.type==="dropdown"?this.#Q:this.select.value;if(this.type==="dropdown")this.select.selectedIndex=-1;this.#W(),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}focus(){this.select.focus()}blur(){this.select.blur()}get value(){if(this.type==="dropdown")return this.#Q;return this.select?.value}set value(Q){if(this.type==="dropdown")this.#Q=Q;this.setAttribute("value",Q)}static get observedAttributes(){return["value","type","experimental"]}#O(Q){if(this.type==="dropdown")return;if(this.select)this.select.querySelectorAll("option").forEach(($,J)=>{if($.value===this.getAttribute("value"))this.select.selectedIndex=J});this.#W()}attributeChangedCallback(Q,$,J){if(Q==="value")this.#O(J);if(Q==="type")this.type=J;if(Q==="experimental")this.slotChange();if(Q==="label")this.#$=J,this.select.setAttribute("aria-label",this.#$)}disconnectedCallback(){this.optionsSlot.removeEventListener("slotchange",this.#K),this.select.removeEventListener("input",this.#J),this.select.removeEventListener("change",this.#j)}}customElements.define("fig-dropdown",X0);class b extends HTMLElement{static#$=0;static#Q=500;#J;#j;#_;#Z;#K;#X;#q;#W;#Y;#N=!1;#U=null;#M=null;constructor(){super();this.action=this.getAttribute("action")||"hover";let Q=parseInt(this.getAttribute("delay"));this.delay=!isNaN(Q)?Q:500,this.#J=this.#A.bind(this),this.#j=this.hidePopupOutsideClick.bind(this),this.#_=this.showDelayedPopup.bind(this),this.#Z=this.#z.bind(this),this.#K=this.#R.bind(this),this.#X=this.#F.bind(this),this.#q=this.#D.bind(this),this.#W=this.#k.bind(this)}connectedCallback(){this.setup(),this.setupEventListeners()}disconnectedCallback(){if(this.destroy(),document.removeEventListener("mousedown",this.#J,!0),this.#B(),this.action==="click")document.body.removeEventListener("click",this.#j);if(clearTimeout(this.#Y),this.action==="hover")this.removeEventListener("pointerenter",this.#_),this.removeEventListener("pointerleave",this.#Z),this.removeEventListener("touchstart",this.#K),this.removeEventListener("touchmove",this.#X),this.removeEventListener("touchend",this.#q),this.removeEventListener("touchcancel",this.#W);else if(this.action==="click")this.removeEventListener("click",this.#_),this.removeEventListener("touchstart",this.#_)}setup(){this.style.display="contents"}render(){this.destroy();let Q=document.createElement("span");this.popup=document.createElement("span"),this.popup.setAttribute("class","fig-tooltip"),this.popup.setAttribute("role","tooltip");const $=v();if(this.popup.setAttribute("id",$),this.popup.style.position="fixed",this.popup.style.visibility="hidden",this.popup.style.display="inline-flex",this.popup.style.pointerEvents="none",this.popup.append(Q),Q.innerText=this.getAttribute("text"),this.firstElementChild)this.firstElementChild.setAttribute("aria-describedby",$);const J=this.closest("dialog");if(J&&J.open)J.append(this.popup);else document.body.append(this.popup);const Z=Q.childNodes[0];if(Z){const j=document.createRange();j.setStartBefore(Z),j.setEndAfter(Z);const _=j.getBoundingClientRect();Q.style.width=`${_.width}px`}}destroy(){if(this.#B(),this.popup)this.popup.remove(),this.popup=null;if(this.action==="click")document.body.removeEventListener("click",this.#j)}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}setupEventListeners(){if(this.action==="manual")return;if(this.action==="hover"){if(!this.isTouchDevice())this.addEventListener("pointerenter",this.#_),this.addEventListener("pointerleave",this.#Z);this.addEventListener("touchstart",this.#K,{passive:!0}),this.addEventListener("touchmove",this.#X,{passive:!0}),this.addEventListener("touchend",this.#q,{passive:!0}),this.addEventListener("touchcancel",this.#W,{passive:!0})}else if(this.action==="click")this.addEventListener("click",this.#_),document.body.addEventListener("click",this.#j),this.addEventListener("touchstart",this.#_,{passive:!0});document.addEventListener("mousedown",this.#J,!0)}getOffset(){const Q={left:8,top:4,right:8,bottom:4},$=this.getAttribute("offset");if(!$)return Q;const[J,Z,j,_]=$.split(",").map(Number);return{left:isNaN(J)?Q.left:J,top:isNaN(Z)?Q.top:Z,right:isNaN(j)?Q.right:j,bottom:isNaN(_)?Q.bottom:_}}get#L(){return this.hasAttribute("show")&&this.getAttribute("show")!=="false"}showDelayedPopup(){if(this.#L)return;this.render(),clearTimeout(this.timeout);const $=Date.now()-b.#$<b.#Q?0:this.delay;this.timeout=setTimeout(this.showPopup.bind(this),$)}showPopup(){if(!this.popup)this.render();this.popup.style.display="block",this.popup.style.visibility="hidden",this.#O(),this.popup.style.opacity="1",this.popup.style.visibility="visible",this.popup.style.pointerEvents="all",this.popup.style.zIndex=q0()+1,this.isOpen=!0,b.#$=Date.now(),this.#G()}#O(){if(!this.popup||!this.firstElementChild)return;const Q=this.firstElementChild.getBoundingClientRect(),$=this.popup.getBoundingClientRect(),J=this.getOffset(),Z=this.popup.parentElement,j=Z&&Z!==document.body?Z.getBoundingClientRect():{left:0,top:0};let _=Q.top-$.height-J.top-j.top,q=Q.left+(Q.width-$.width)/2-j.left;if(this.popup.setAttribute("position","top"),_+j.top<0)this.popup.setAttribute("position","bottom"),_=Q.bottom+J.bottom-j.top;const K=q+j.left;if(K<J.left)q=J.left-j.left;else if(K+$.width>window.innerWidth-J.right)q=window.innerWidth-$.width-J.right-j.left;const Y=Q.left-j.left+Q.width/2-q;this.popup.style.setProperty("--beak-offset",`${Y}px`),this.popup.style.top=`${_}px`,this.popup.style.left=`${q}px`}hidePopup(){if(this.#L)return;if(clearTimeout(this.timeout),clearTimeout(this.#Y),this.#B(),this.popup)this.popup.style.opacity="0",this.popup.style.display="block",this.popup.style.pointerEvents="none",this.destroy();this.isOpen=!1,b.#$=Date.now()}#G(){this.#B();const Q=this.firstElementChild;if(!Q)return;this.#U=new MutationObserver(()=>{if(this.#M)cancelAnimationFrame(this.#M);this.#M=requestAnimationFrame(()=>{this.#O()})}),this.#U.observe(Q,{attributes:!0,attributeFilter:["style","class","transform"]})}#B(){if(this.#M)cancelAnimationFrame(this.#M),this.#M=null;if(this.#U)this.#U.disconnect(),this.#U=null}hidePopupOutsideClick(Q){if(this.isOpen&&!this.popup.contains(Q.target))this.hidePopup()}#z(Q){if(!this.#N)this.hidePopup()}#R(Q){if(this.action==="hover")this.#N=!0,clearTimeout(this.#Y),this.showDelayedPopup()}#F(Q){if(this.action==="hover"&&this.#N)clearTimeout(this.#Y),this.#Y=setTimeout(()=>{this.#N=!1,this.hidePopup()},150)}#D(Q){if(this.action==="hover"&&this.#N)clearTimeout(this.#Y),this.#Y=setTimeout(()=>{this.#N=!1,this.hidePopup()},300)}#k(Q){if(this.action==="hover"&&this.#N)this.#N=!1,clearTimeout(this.#Y),this.hidePopup()}static get observedAttributes(){return["action","delay","open","show","text"]}get text(){return this.getAttribute("text")??""}set text(Q){this.setAttribute("text",Q)}#H(Q){if(!this.popup)return;const $=this.popup.firstElementChild??this.popup.firstChild;if(!$)return;$.innerText=Q,$.style.width="";const J=$.childNodes[0];if(J){const Z=document.createRange();Z.setStartBefore(J),Z.setEndAfter(J),$.style.width=`${Z.getBoundingClientRect().width}px`}if(this.isOpen)this.#O()}get open(){return this.hasAttribute("open")&&this.getAttribute("open")==="true"}set open(Q){this.setAttribute("open",Q)}attributeChangedCallback(Q,$,J){if(Q==="action")this.action=J;if(Q==="delay"){let Z=parseInt(J);this.delay=!isNaN(Z)?Z:500}if(Q==="open")if(J==="true")requestAnimationFrame(()=>{this.showDelayedPopup()});else requestAnimationFrame(()=>{this.hidePopup()});if(Q==="show")if(J!==null&&J!=="false")this.showPopup();else this.hidePopup();if(Q==="text")this.#H(J??"")}#A(Q){if(!this.isOpen)return;const $=Q.target;if(this.popup&&this.popup.contains($))return;if($.tagName==="SELECT"||$.hasAttribute("popover")||$.closest("dialog"))this.hidePopup()}}customElements.define("fig-tooltip",b);class Y0 extends HTMLDialogElement{#$=!1;#Q=!1;#J={x:0,y:0};#j={x:0,y:0};#_;#Z;#K;#X;#q=16;#W=!1;#Y=3;constructor(){super();this.#_=this.#G.bind(this),this.#Z=this.#B.bind(this),this.#K=this.#z.bind(this),this.#X=this.close.bind(this)}connectedCallback(){this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",requestAnimationFrame(()=>{this.#N(),this.#M(),this.#U()})}disconnectedCallback(){this.#L(),this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this.#X)})}#N(){this.querySelectorAll("fig-button[close-dialog]").forEach((Q)=>{Q.removeEventListener("click",this.#X),Q.addEventListener("click",this.#X)})}#U(){const 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";const $=Q.includes("top"),J=Q.includes("bottom"),Z=Q.includes("left"),j=Q.includes("right"),_=Q.includes("center")&&!$&&!J,q=Q.includes("center")&&!Z&&!j;if($)this.style.top=`${this.#q}px`;else if(J)this.style.bottom=`${this.#q}px`;else if(_)this.style.top="0",this.style.bottom="0";if(Z)this.style.left=`${this.#q}px`;else if(j)this.style.right=`${this.#q}px`;else if(q)this.style.left="0",this.style.right="0";if(_&&q)this.style.margin="auto";else if(_)this.style.marginTop="auto",this.style.marginBottom="auto";else if(q)this.style.marginLeft="auto",this.style.marginRight="auto";this.#W=!0}#M(){if(this.drag){this.addEventListener("pointerdown",this.#_);const Q=this.getAttribute("handle"),$=Q?this.querySelector(Q):this.querySelector("fig-header, header");if($)$.style.cursor="grab"}}#L(){this.removeEventListener("pointerdown",this.#_),document.removeEventListener("pointermove",this.#Z),document.removeEventListener("pointerup",this.#K)}#O(Q){const $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(_)=>$.some((q)=>_.matches?.(q))||_.tagName?.startsWith("FIG-")&&!J.includes(_.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}#G(Q){if(!this.drag)return;if(this.#O(Q.target))return;const $=this.getAttribute("handle");if($&&$.trim()){const Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this.#Q=!0,this.#J.x=Q.clientX,this.#J.y=Q.clientY;const J=this.getBoundingClientRect();this.#j.x=Q.clientX-J.left,this.#j.y=Q.clientY-J.top,document.addEventListener("pointermove",this.#Z),document.addEventListener("pointerup",this.#K)}#B(Q){if(this.#Q&&!this.#$){const $=Math.abs(Q.clientX-this.#J.x),J=Math.abs(Q.clientY-this.#J.y);if($>this.#Y||J>this.#Y){this.#$=!0,this.#Q=!1,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";const Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this.#$)return;this.style.left=`${Q.clientX-this.#j.x}px`,this.style.top=`${Q.clientY-this.#j.y}px`,Q.preventDefault()}#z(Q){if(this.#$)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this.#$=!1,this.#Q=!1,document.removeEventListener("pointermove",this.#Z),document.removeEventListener("pointerup",this.#K),Q.preventDefault()}static get observedAttributes(){return["modal","drag","position","handle"]}attributeChangedCallback(Q,$,J){if(Q==="drag")if(this.drag=J!==null&&J!=="false",this.drag)this.#M();else{this.#L();const Z=this.querySelector("fig-header, header");if(Z)Z.style.cursor=""}if(Q==="position"&&this.#W)this.#U()}}i("fig-dialog",Y0,{extends:"dialog"});class W0 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;constructor(){super();this._boundReposition=this.queueReposition.bind(this),this._boundScroll=(Q)=>{if(this.open&&!this.contains(Q.target)&&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)}ensureInitialized(){if(typeof this._anchorObserver==="undefined")this._anchorObserver=null;if(typeof this._contentObserver==="undefined")this._contentObserver=null;if(typeof this._mutationObserver==="undefined")this._mutationObserver=null;if(typeof this._anchorTrackRAF==="undefined")this._anchorTrackRAF=null;if(typeof this._lastAnchorRect==="undefined")this._lastAnchorRect=null;if(typeof this._isPopupActive==="undefined")this._isPopupActive=!1;if(typeof this._rafId==="undefined")this._rafId=null;if(typeof this._anchorRef==="undefined")this._anchorRef=null;if(typeof this._isDragging==="undefined")this._isDragging=!1;if(typeof this._dragPending==="undefined")this._dragPending=!1;if(typeof this._dragStartPos==="undefined")this._dragStartPos={x:0,y:0};if(typeof this._dragOffset==="undefined")this._dragOffset={x:0,y:0};if(typeof this._dragThreshold!=="number")this._dragThreshold=3;if(typeof this._wasDragged==="undefined")this._wasDragged=!1;if(typeof this._boundReposition!=="function")this._boundReposition=this.queueReposition.bind(this);if(typeof this._boundScroll!=="function")this._boundScroll=(Q)=>{if(this.open&&!this.contains(Q.target)&&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)}static get observedAttributes(){return["open","anchor","position","offset","variant","theme","drag","handle","autoresize","viewport-margin"]}get open(){return this.hasAttribute("open")&&this.getAttribute("open")!=="false"}set open(Q){if(Q===!1||Q==="false"||Q===null){if(!this.open)return;this.removeAttribute("open");return}if(this.open)return;this.setAttribute("open","true")}get anchor(){return this._anchorRef??this.getAttribute("anchor")}set anchor(Q){if(Q instanceof Element)this._anchorRef=Q;else if(typeof Q==="string")this._anchorRef=null,this.setAttribute("anchor",Q);else this._anchorRef=null;if(this.open)this.queueReposition()}connectedCallback(){if(this.ensureInitialized(),!this.hasAttribute("position"))this.setAttribute("position","top center");if(!this.hasAttribute("role"))this.setAttribute("role","dialog");if(!this.hasAttribute("closedby"))this.setAttribute("closedby","any");if(this.drag=this.hasAttribute("drag")&&this.getAttribute("drag")!=="false",this.addEventListener("close",()=>{if(this.teardownObservers(),this.hasAttribute("open"))this.removeAttribute("open")}),requestAnimationFrame(()=>{this.setupDragListeners()}),this.open)this.showPopup();else this.hidePopup()}disconnectedCallback(){if(this.ensureInitialized(),this.teardownObservers(),this.removeDragListeners(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),this._rafId!==null)cancelAnimationFrame(this._rafId),this._rafId=null}attributeChangedCallback(Q,$,J){if(this.ensureInitialized(),$===J)return;if(Q==="open"){if(J===null||J==="false"){this.hidePopup();return}this.showPopup();return}if(Q==="drag"){if(this.drag=J!==null&&J!=="false",this.drag)this.setupDragListeners();else this.removeDragListeners();return}if(this.open)this.queueReposition(),this.setupObservers()}showPopup(){if(this._isPopupActive){this.queueReposition();return}if(this.style.position="fixed",this.style.inset="auto",this.style.margin="0",this.style.zIndex=String(q0()+1),!super.open)try{this.show()}catch($){}this.setupObservers(),document.addEventListener("pointerdown",this._boundOutsidePointerDown,!0),this._wasDragged=!1,this.queueReposition(),this._isPopupActive=!0;const Q=this.resolveAnchor();if(Q)Q.classList.add("has-popup-open")}hidePopup(){const Q=this.resolveAnchor();if(Q)Q.classList.remove("has-popup-open");if(this._isPopupActive=!1,this._wasDragged=!1,this.teardownObservers(),document.removeEventListener("pointerdown",this._boundOutsidePointerDown,!0),super.open)try{this.close()}catch($){}}get autoresize(){const Q=this.getAttribute("autoresize");return Q===null||Q!=="false"}set autoresize(Q){if(Q||Q==="")this.setAttribute("autoresize",Q===!0?"":Q);else this.removeAttribute("autoresize")}setupObservers(){this.teardownObservers();const Q=this.resolveAnchor();if(Q&&"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;const $=Q.getBoundingClientRect();return{x:$.x,y:$.y,width:$.width,height:$.height}}hasRectChanged(Q,$,J=0.25){if(!Q&&!$)return!1;if(!Q||!$)return!0;return Math.abs(Q.x-$.x)>J||Math.abs(Q.y-$.y)>J||Math.abs(Q.width-$.width)>J||Math.abs(Q.height-$.height)>J}startAnchorTracking(){if(this.stopAnchorTracking(),!this.open)return;const Q=()=>{if(!this.open){this._anchorTrackRAF=null;return}const $=this.resolveAnchor(),J=this.readRectSnapshot($),Z=this.shouldAutoReposition();if(Z&&this.hasRectChanged(this._lastAnchorRect,J))this._lastAnchorRect=J,this.queueReposition();else if(!Z)this._lastAnchorRect=J;this._anchorTrackRAF=requestAnimationFrame(Q)};this._lastAnchorRect=this.readRectSnapshot(this.resolveAnchor()),this._anchorTrackRAF=requestAnimationFrame(Q)}stopAnchorTracking(){if(this._anchorTrackRAF!==null)cancelAnimationFrame(this._anchorTrackRAF),this._anchorTrackRAF=null;this._lastAnchorRect=null}handleOutsidePointerDown(Q){if(!this.open||!super.open)return;const $=this.getAttribute("closedby");if($==="none"||$==="closerequest")return;const J=Q.target;if(!(J instanceof Node))return;if(this.contains(J))return;const Z=this.resolveAnchor();if(Z&&Z.contains(J))return;if(this.isInsideDescendantPopup(J))return;this.open=!1}isInsideDescendantPopup(Q){const $=Q.closest?.('dialog[is="fig-popup"]');if(!$||$===this)return!1;let J=$;const Z=new Set;while(J&&!Z.has(J)){Z.add(J);const j=J.anchor;if(!(j instanceof Element))break;if(this.contains(j))return!0;J=j.closest?.('dialog[is="fig-popup"]')}return!1}setupDragListeners(){if(this.drag)this.addEventListener("pointerdown",this._boundPointerDown)}removeDragListeners(){this.removeEventListener("pointerdown",this._boundPointerDown),document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp)}isInteractiveElement(Q){const $=["input","button","select","textarea","a","label","details","summary",'[contenteditable="true"]',"[tabindex]"],J=["FIG-HEADER","FIG-DIALOG","FIG-POPUP","FIG-FIELD","FIG-TOOLTIP","FIG-CONTENT","FIG-TABS","FIG-TAB","FIG-POPOVER","FIG-SHIMMER","FIG-LAYER","FIG-FILL-PICKER"],Z=(_)=>$.some((q)=>_.matches?.(q))||_.tagName?.startsWith("FIG-")&&!J.includes(_.tagName);if(Z(Q))return!0;let j=Q.parentElement;while(j&&j!==this){if(Z(j))return!0;j=j.parentElement}return!1}handlePointerDown(Q){if(!this.drag)return;if(this.isInteractiveElement(Q.target))return;const $=this.getAttribute("handle");if($&&$.trim()){const Z=this.querySelector($);if(!Z||!Z.contains(Q.target))return}this._dragPending=!0,this._dragStartPos.x=Q.clientX,this._dragStartPos.y=Q.clientY;const J=this.getBoundingClientRect();this._dragOffset.x=Q.clientX-J.left,this._dragOffset.y=Q.clientY-J.top,document.addEventListener("pointermove",this._boundPointerMove),document.addEventListener("pointerup",this._boundPointerUp)}handlePointerMove(Q){if(this._dragPending&&!this._isDragging){const $=Math.abs(Q.clientX-this._dragStartPos.x),J=Math.abs(Q.clientY-this._dragStartPos.y);if($>this._dragThreshold||J>this._dragThreshold){this._isDragging=!0,this._dragPending=!1,this._wasDragged=!0,this.setPointerCapture(Q.pointerId),this.style.cursor="grabbing";const Z=this.getBoundingClientRect();this.style.top=`${Z.top}px`,this.style.left=`${Z.left}px`,this.style.bottom="auto",this.style.right="auto",this.style.margin="0"}}if(!this._isDragging)return;this.style.left=`${Q.clientX-this._dragOffset.x}px`,this.style.top=`${Q.clientY-this._dragOffset.y}px`,Q.preventDefault()}handlePointerUp(Q){if(this._isDragging)this.releasePointerCapture(Q.pointerId),this.style.cursor="";this._isDragging=!1,this._dragPending=!1,document.removeEventListener("pointermove",this._boundPointerMove),document.removeEventListener("pointerup",this._boundPointerUp),Q.preventDefault()}resolveAnchor(){if(this._anchorRef)return this._anchorRef;const Q=this.getAttribute("anchor");if(!Q)return null;const $=this.parentElement;if($?.querySelector){const J=$.querySelector(Q);if(J&&!this.contains(J))return J}return document.querySelector(Q)}parsePosition(){const $=(this.getAttribute("position")||"top center").trim().toLowerCase().split(/\s+/).filter(Boolean),J=new Set(["top","center","bottom"]),Z=new Set(["left","center","right"]);let j="top",_="center",q=null;if($.length>=2){if(J.has($[0]))j=$[0];if(Z.has($[1]))_=$[1];return{vertical:j,horizontal:_,shorthand:q}}if($.length===1){const K=$[0];if(K==="top"||K==="bottom")j=K,q=K;else if(K==="left"||K==="right")_=K,q=K;else if(K==="center")j="center",_="center"}return{vertical:j,horizontal:_,shorthand:q}}normalizeOffsetToken(Q,$="0px"){if(!Q)return $;const J=Q.trim();if(!J)return $;if(/^-?\d+(\.\d+)?$/.test(J))return`${J}px`;return J}measureLengthPx(Q,$="x"){if(!Q)return 0;const J=this.normalizeOffsetToken(Q,"0px");if(J.endsWith("px")){const _=parseFloat(J);return Number.isFinite(_)?_:0}const Z=document.createElement("div");if(Z.style.position="fixed",Z.style.visibility="hidden",Z.style.pointerEvents="none",Z.style.left="0",Z.style.top="0",Z.style.margin="0",Z.style.padding="0",Z.style.border="0",$==="x")Z.style.width=J,Z.style.height="0";else Z.style.height=J,Z.style.width="0";document.body.appendChild(Z);const j=Z.getBoundingClientRect();return Z.remove(),$==="x"?j.width:j.height}parseOffset(){const $=(this.getAttribute("offset")||"0 0").trim().split(/\s+/).filter(Boolean),J=this.normalizeOffsetToken($[0],"0px"),Z=this.normalizeOffsetToken($[1],"0px");return{xToken:J,yToken:Z,xPx:this.measureLengthPx(J,"x"),yPx:this.measureLengthPx(Z,"y")}}parseViewportMargins(){const $=(this.getAttribute("viewport-margin")||"8").trim().split(/\s+/).map(Number).filter((Z)=>!Number.isNaN(Z));if($.length===0)return{top:8,right:8,bottom:8,left:8};if($.length===1)return{top:$[0],right:$[0],bottom:$[0],left:$[0]};if($.length===2)return{top:$[0],right:$[1],bottom:$[0],left:$[1]};if($.length===3)return{top:$[0],right:$[1],bottom:$[2],left:$[1]};return{top:$[0],right:$[1],bottom:$[2],left:$[3]}}getPlacementCandidates(Q,$,J){const Z={top:"bottom",bottom:"top",left:"right",right:"left",center:"center"};if(J){const _=J==="left"||J==="right"?["top","bottom"]:["left","right"];return[{v:Q,h:$,s:J},{v:Q,h:$,s:Z[J]},{v:Q,h:$,s:_[0]},{v:Q,h:$,s:_[1]}]}if(Q==="center")return[{v:"center",h:$,s:null},{v:"center",h:Z[$],s:null},{v:"top",h:$,s:null},{v:"bottom",h:$,s:null},{v:"top",h:Z[$],s:null},{v:"bottom",h:Z[$],s:null}];if($==="center")return[{v:Q,h:"center",s:null},{v:Z[Q],h:"center",s:null},{v:Q,h:"left",s:null},{v:Q,h:"right",s:null},{v:Z[Q],h:"left",s:null},{v:Z[Q],h:"right",s:null}];return[{v:Q,h:$,s:null},{v:Z[Q],h:$,s:null},{v:Q,h:Z[$],s:null},{v:Z[Q],h:Z[$],s:null}]}computeCoords(Q,$,J,Z,j,_){let q,K;if(_==="left"||_==="right")return K=_==="left"?Q.left-$.width-j.xPx:Q.right+j.xPx,q=Q.top,{top:q,left:K};if(_==="top"||_==="bottom")return q=_==="top"?Q.top-$.height-j.yPx:Q.bottom+j.yPx,K=Q.left,{top:q,left:K};if(J==="top")q=Q.top-$.height-j.yPx;else if(J==="bottom")q=Q.bottom+j.yPx;else q=Q.top+(Q.height-$.height)/2;if(J==="center")if(Z==="left")K=Q.left-$.width-j.xPx;else if(Z==="right")K=Q.right+j.xPx;else K=Q.left+(Q.width-$.width)/2;else if(Z==="left")K=Q.left+j.xPx;else if(Z==="right")K=Q.right-$.width-j.xPx;else K=Q.left+(Q.width-$.width)/2;return{top:q,left:K}}oppositeSide(Q){return{top:"bottom",bottom:"top",left:"right",right:"left"}[Q]||"bottom"}getPlacementSide(Q,$,J){if(J==="top")return"top";if(J==="bottom")return"bottom";if(J==="left")return"left";if(J==="right")return"right";if(Q!=="center")return Q;if($!=="center")return $;return"top"}updatePopoverBeak(Q,$,J,Z,j){if(this.getAttribute("variant")!=="popover"||!Q){this.style.removeProperty("--beak-offset"),this.removeAttribute("data-beak-side");return}const _=this.oppositeSide(j);this.setAttribute("data-beak-side",_);const q=Q.left+Q.width/2,K=Q.top+Q.height/2,X=this.getBoundingClientRect(),Y=X.width>0&&X.height>0?X:$,W=Y.left,U=Y.top,L=10;let z;if(_==="top"||_==="bottom"){z=q-W;const M=L,G=Math.max(M,Y.width-L);z=Math.min(G,Math.max(M,z))}else{z=K-U;const M=L,G=Math.max(M,Y.height-L);z=Math.min(G,Math.max(M,z))}this.style.setProperty("--beak-offset",`${z}px`)}overflowScore(Q,$,J){const{innerWidth:Z,innerHeight:j}=window,_=Q.left+$.width,q=Q.top+$.height,K=Math.max(0,J.left-Q.left),X=Math.max(0,J.top-Q.top),Y=Math.max(0,_-(Z-J.right)),W=Math.max(0,q-(j-J.bottom));return K+X+Y+W}fits(Q,$,J){return this.overflowScore(Q,$,J)===0}clamp(Q,$,J){const{left:Z,top:j}=J,_=Math.max(J.left,window.innerWidth-$.width-J.right),q=Math.max(J.top,window.innerHeight-$.height-J.bottom);return{left:Math.min(_,Math.max(Z,Q.left)),top:Math.min(q,Math.max(j,Q.top))}}positionPopup(){if(!this.open||!super.open)return;const Q=this.getBoundingClientRect(),$=this.parseOffset(),{vertical:J,horizontal:Z,shorthand:j}=this.parsePosition(),_=this.resolveAnchor(),q=this.parseViewportMargins();if(!_){this.updatePopoverBeak(null,Q,0,0,"top");const z={left:q.left+(window.innerWidth-q.right-q.left-Q.width)/2,top:q.top+(window.innerHeight-q.bottom-q.top-Q.height)/2},M=this.clamp(z,Q,q);this.style.left=`${M.left}px`,this.style.top=`${M.top}px`;return}const K=_.getBoundingClientRect(),X=this.getPlacementCandidates(J,Z,j);let Y=null,W="top",U=Number.POSITIVE_INFINITY;for(let{v:z,h:M,s:G}of X){const B=this.computeCoords(K,Q,z,M,$,G),A=this.getPlacementSide(z,M,G);if(G){const F=this.clamp(B,Q,q);if(G==="left"||G==="right"?B.left>=q.left&&B.left+Q.width<=window.innerWidth-q.right:B.top>=q.top&&B.top+Q.height<=window.innerHeight-q.bottom){this.style.left=`${F.left}px`,this.style.top=`${F.top}px`,this.updatePopoverBeak(K,Q,F.left,F.top,A);return}const T=this.overflowScore(B,Q,q);if(T<U)U=T,Y=F,W=A}else{if(this.fits(B,Q,q)){this.style.left=`${B.left}px`,this.style.top=`${B.top}px`,this.updatePopoverBeak(K,Q,B.left,B.top,A);return}const F=this.overflowScore(B,Q,q);if(F<U)U=F,Y=B,W=A}}const L=this.clamp(Y||{left:0,top:0},Q,q);this.style.left=`${L.left}px`,this.style.top=`${L.top}px`,this.updatePopoverBeak(K,Q,L.left,L.top,W)}queueReposition(){if(!this.open||!this.shouldAutoReposition())return;if(this._rafId!==null)return;this._rafId=requestAnimationFrame(()=>{this._rafId=null,this.positionPopup()})}shouldAutoReposition(){if(!(this.drag&&this._wasDragged))return!0;return!this.resolveAnchor()}}i("fig-popup",W0,{extends:"dialog"});class U0 extends HTMLElement{#$;#Q;constructor(){super();this.content=null,this.#$=!1,this.#Q=this.handleClick.bind(this)}connectedCallback(){this.setAttribute("label",this.innerText),this.setAttribute("role","tab"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#Q),requestAnimationFrame(()=>{if(typeof this.getAttribute("content")==="string"){if(this.content=document.querySelector(this.getAttribute("content")),this.content)if(this.content.setAttribute("role","tabpanel"),this.#$)this.content.style.display="block",this.setAttribute("aria-selected","true");else this.content.style.display="none",this.setAttribute("aria-selected","false")}})}get selected(){return this.#$}set selected(Q){this.setAttribute("selected",Q?"true":"false")}disconnectedCallback(){this.removeEventListener("click",this.#Q)}handleClick(){if(this.selected=!0,this.content)this.content.style.display="block"}static get observedAttributes(){return["selected"]}attributeChangedCallback(Q,$,J){if(Q==="selected"){if(this.#$=J!==null&&J!=="false",this.setAttribute("aria-selected",this.#$?"true":"false"),this?.content)this.content.style.display=this.#$?"block":"none"}}}customElements.define("fig-tab",U0);class N0 extends HTMLElement{#$;#Q;constructor(){super();this.#$=this.handleClick.bind(this),this.#Q=this.#j.bind(this)}static get observedAttributes(){return["value","name","disabled"]}connectedCallback(){this.name=this.getAttribute("name")||"tabs",this.setAttribute("role","tablist"),this.addEventListener("click",this.#$),this.addEventListener("keydown",this.#Q),requestAnimationFrame(()=>{const Q=this.getAttribute("value");if(Q)this.#_(Q);if(this.hasAttribute("disabled"))this.#J(!0)})}#J(Q){this.querySelectorAll("fig-tab").forEach((J)=>{if(Q)J.setAttribute("disabled",""),J.setAttribute("aria-disabled","true"),J.setAttribute("tabindex","-1");else J.removeAttribute("disabled"),J.removeAttribute("aria-disabled"),J.setAttribute("tabindex","0")})}disconnectedCallback(){this.removeEventListener("click",this.#$),this.removeEventListener("keydown",this.#Q)}#j(Q){const $=Array.from(this.querySelectorAll("fig-tab")),J=$.findIndex((j)=>j.hasAttribute("selected"));let Z=J;switch(Q.key){case"ArrowLeft":case"ArrowUp":Q.preventDefault(),Z=J>0?J-1:$.length-1;break;case"ArrowRight":case"ArrowDown":Q.preventDefault(),Z=J<$.length-1?J+1:0;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;default:return}if(Z!==J&&$[Z])$.forEach((j)=>j.removeAttribute("selected")),this.selectedTab=$[Z],this.setAttribute("value",$[Z].getAttribute("value")||""),$[Z].focus()}get value(){return this.selectedTab?.getAttribute("value")||""}set value(Q){this.setAttribute("value",Q)}#_(Q){const $=this.querySelectorAll("fig-tab");for(let J of $)if(J.getAttribute("value")===Q)this.selectedTab=J,J.setAttribute("selected","true");else J.removeAttribute("selected")}attributeChangedCallback(Q,$,J){switch(Q){case"value":if(J!==$)this.#_(J);break;case"disabled":this.#J(J!==null&&J!=="false");break}}handleClick(Q){if(this.hasAttribute("disabled"))return;const $=Q.target;if($.nodeName.toLowerCase()==="fig-tab"){const J=this.querySelectorAll("fig-tab");for(let Z of J)if(Z===$)this.selectedTab=Z,Z.setAttribute("selected","true"),this.setAttribute("value",Z.getAttribute("value")||"");else Z.removeAttribute("selected")}}}customElements.define("fig-tabs",N0);class L0 extends HTMLElement{#$;#Q;#J;constructor(){super();this.#J=this.handleClick.bind(this)}connectedCallback(){this.addEventListener("click",this.#J)}disconnectedCallback(){this.removeEventListener("click",this.#J)}handleClick(){const Q=this.closest("fig-segmented-control");if(Q&&Q.hasAttribute("disabled")&&Q.getAttribute("disabled")!=="false")return;this.setAttribute("selected","true")}get value(){return this.#$}set value(Q){this.#$=Q,this.setAttribute("value",Q)}get selected(){return this.#Q}set selected(Q){this.#Q=Q,this.setAttribute("selected",Q)}static get observedAttributes(){return["selected","value"]}attributeChangedCallback(Q,$,J){switch(Q){case"value":this.#$=J;break;case"selected":this.#Q=J;break}}}customElements.define("fig-segment",L0);class G0 extends HTMLElement{#$=null;#Q=this.handleClick.bind(this);#J=null;#j=null;#_=0;#Z=!1;#K=!1;constructor(){super()}static get observedAttributes(){return["disabled","value","animated","sizing"]}connectedCallback(){this.name=this.getAttribute("name")||"segmented-control",this.addEventListener("click",this.#Q),this.#z(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#B(),this.#L(),requestAnimationFrame(()=>{this.#G({enforceFallback:!0}),this.#O(),this.#U({forceInstant:!0})})}disconnectedCallback(){if(this.removeEventListener("click",this.#Q),this.#J?.disconnect(),this.#J=null,this.#j?.disconnect(),this.#j=null,this.#_)cancelAnimationFrame(this.#_),this.#_=0;this.#Z=!1,this.#K=!1}get selectedSegment(){return this.#$}set selectedSegment(Q){const $=this.querySelectorAll("fig-segment");for(let J of $){const Z=J===Q,j=J.hasAttribute("selected");if(Z&&!j)J.setAttribute("selected","true");else if(!Z&&j)J.removeAttribute("selected")}this.#$=Q instanceof HTMLElement&&this.contains(Q)?Q:null,this.#U()}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}))}#q(Q){const $=Q.getAttribute("value");if($!==null){const J=$.trim();if(J.length>0)return J}return Q.textContent?.trim()||""}#W(){const Q=this.querySelectorAll("fig-segment");for(let $ of Q)if($.hasAttribute("selected"))return $;return null}#Y(Q){const $=String(Q??"").trim();if(!$)return!1;const J=this.querySelectorAll("fig-segment");for(let Z of J){const j=this.#q(Z);if(!j)continue;if(j===$)return this.selectedSegment=Z,!0}return!1}#N(){const Q=this.getAttribute("animated");if(Q===null)return!1;if(Q==="")return!0;return Q.trim().toLowerCase()==="true"}#U({forceInstant:Q=!1}={}){if(this.#Z=this.#Z||Q,this.#_)return;this.#_=requestAnimationFrame(()=>{this.#_=0;const $=this.#Z;this.#Z=!1,this.#M({forceInstant:$})})}#M({forceInstant:Q=!1}={}){const $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#N(),Z=this.#$&&this.contains(this.#$)?this.#$:this.#W();if($||!J){if(this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready"),!J||$)this.#K=!1;return}if(!Z){if(this.#K)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}const j=this.getBoundingClientRect(),_=Z.getBoundingClientRect();if(j.width<=0||_.width<=0){if(this.#K)return;this.style.setProperty("--seg-indicator-opacity","0"),this.style.setProperty("--seg-indicator-transition-duration","0ms"),this.removeAttribute("data-indicator-ready");return}const q=Math.max(0,_.left-j.left);this.style.setProperty("--seg-indicator-x",`${q}px`),this.style.setProperty("--seg-indicator-w",`${_.width}px`),this.style.setProperty("--seg-indicator-opacity","1"),this.style.setProperty("--seg-indicator-transition-duration",!this.#K||Q?"0ms":"150ms"),this.setAttribute("data-indicator-ready","true"),this.#K=!0}#L(){this.#j?.disconnect(),this.#j=new ResizeObserver(()=>{this.#U()}),this.#O()}#O(){if(!this.#j)return;this.#j.disconnect(),this.#j.observe(this),this.querySelectorAll("fig-segment").forEach((Q)=>{this.#j?.observe(Q)})}#G({enforceFallback:Q=!1}={}){const $=this.querySelectorAll("fig-segment");if($.length===0){this.#$=null,this.#U({forceInstant:!0});return}const J=this.getAttribute("value"),Z=J?.trim()??"";if(J!==null){if(Z!==J){this.setAttribute("value",Z);return}if(Z&&this.#Y(Z))return}const j=this.#W();if(j){this.selectedSegment=j;return}if(Q)this.selectedSegment=$[0]}#B(){this.#J?.disconnect(),this.#J=new MutationObserver((Q)=>{let $=!1;for(let J of Q){if(J.type==="childList"){$=!0;break}if(J.type==="attributes"&&J.target instanceof HTMLElement&&J.target.tagName.toLowerCase()==="fig-segment"&&(J.attributeName==="value"||J.attributeName==="selected")){$=!0;break}if(J.type==="characterData"){$=!0;break}}if($)this.#z(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"),this.#O(),this.#G({enforceFallback:!0})}),this.#J.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","selected"]})}handleClick(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;const $=Q.target.closest("fig-segment");if(!$||!this.contains($))return;const J=this.selectedSegment,Z=this.value;this.selectedSegment=$;const j=this.#q($);if(j)this.setAttribute("value",j);else this.removeAttribute("value");const _=this.value;if(J!==$||Z!==_)this.#X(_)}#z(Q){this.setAttribute("aria-disabled",Q?"true":"false"),this.querySelectorAll("fig-segment").forEach(($)=>{if(Q)$.setAttribute("disabled",""),$.setAttribute("aria-disabled","true");else $.removeAttribute("disabled"),$.removeAttribute("aria-disabled")})}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="disabled"){this.#z(J!==null&&J!=="false"),this.#U({forceInstant:!0});return}if(Q==="value"){this.#G({enforceFallback:!1});return}if(Q==="animated"){if(!this.#N())this.#K=!1;this.#U({forceInstant:!0});return}if(Q==="sizing")this.#U({forceInstant:!0})}}customElements.define("fig-segmented-control",G0);class B0 extends HTMLElement{#$=!1;#Q=!1;#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"}};#j;#_;#Z;#K;constructor(){super();this.initialInnerHTML=this.innerHTML,this.#j=(Q)=>{Q.stopPropagation(),this.#B()},this.#_=(Q)=>{Q.stopPropagation(),this.#z()},this.#Z=(Q)=>{Q.stopPropagation(),this.#q()},this.#K=(Q)=>{Q.stopPropagation(),this.#R()}}#X(){const Q=this.getAttribute("value");this.type=this.getAttribute("type")||"range",this.variant=this.getAttribute("variant")||"default",this.text=this.hasAttribute("text")&&this.getAttribute("text")!=="false",this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.getAttribute("disabled")?!0:!1,this.precision=this.hasAttribute("precision")?Number(this.getAttribute("precision")):null,this.placeholder=this.getAttribute("placeholder")!==null?this.getAttribute("placeholder"):"##";const $=this.#J[this.type];if(this.min=Number(this.getAttribute("min")||$.min),this.max=Number(this.getAttribute("max")||$.max),this.step=Number(this.getAttribute("step")||$.step),this.color=this.getAttribute("color")||$?.color,this.default=this.hasAttribute("default")?this.getAttribute("default"):this.type==="delta"?0:this.min,this.#Q=Q===null||typeof Q==="string"&&Q.trim()==="",this.value=this.#L(Q),this.color)this.style.setProperty("--color",this.color);let J="",Z=`<div class="fig-slider-input-container" role="group">
|
|
36
36
|
<input
|
|
37
37
|
type="range"
|
|
38
38
|
${this.text?'tabindex="-1"':""}
|
|
@@ -53,70 +53,70 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
53
53
|
max="${this.max}"
|
|
54
54
|
transform="${this.transform}"
|
|
55
55
|
step="${this.step}"
|
|
56
|
-
value="${this.#
|
|
56
|
+
value="${this.#Q?"":this.value}"
|
|
57
57
|
${this.units?`units="${this.units}"`:""}
|
|
58
58
|
${this.precision!==null?`precision="${this.precision}"`:""}>
|
|
59
|
-
</fig-input-number>`;else J=Z;this.innerHTML=J,requestAnimationFrame(()=>{if(this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.input.removeEventListener("input",this.#
|
|
59
|
+
</fig-input-number>`;else J=Z;this.innerHTML=J,requestAnimationFrame(()=>{if(this.input=this.querySelector("[type=range]"),this.inputContainer=this.querySelector(".fig-slider-input-container"),this.input.removeEventListener("input",this.#j),this.input.addEventListener("input",this.#j),this.input.removeEventListener("change",this.#_),this.input.addEventListener("change",this.#_),this.input.addEventListener("pointerdown",()=>{this.#$=!0}),this.input.addEventListener("pointerup",()=>{this.#$=!1}),this.default)this.style.setProperty("--default",this.#W(this.default));if(this.datalist=this.querySelector("datalist"),this.figInputNumber=this.querySelector("fig-input-number"),this.datalist)this.inputContainer.append(this.datalist),this.datalist.setAttribute("id",this.datalist.getAttribute("id")||v()),this.input.setAttribute("list",this.datalist.getAttribute("id"));else if(this.type==="stepper"){this.datalist=document.createElement("datalist"),this.datalist.setAttribute("id",v());let j=(this.max-this.min)/this.step+1;for(let _=0;_<j;_++){let q=document.createElement("option");q.setAttribute("value",this.min+_*this.step),this.datalist.append(q)}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",v());let j=document.createElement("option");j.setAttribute("value",this.default),this.datalist.append(j),this.inputContainer.append(this.datalist),this.input.setAttribute("list",this.datalist.getAttribute("id"))}if(this.datalist){let j=this.datalist.querySelector(`option[value='${this.default}']`);if(j)j.setAttribute("default","true")}if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#Z),this.figInputNumber.addEventListener("input",this.#Z),this.figInputNumber.removeEventListener("change",this.#K),this.figInputNumber.addEventListener("change",this.#K);this.#G()})}connectedCallback(){this.#X()}disconnectedCallback(){if(this.input)this.input.removeEventListener("input",this.#j),this.input.removeEventListener("change",this.#_);if(this.figInputNumber)this.figInputNumber.removeEventListener("input",this.#Z),this.figInputNumber.removeEventListener("change",this.#K)}#q(){if(this.figInputNumber){const Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";const $=this.#L(Q);this.value=$,this.input.value=String($),this.#G(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}}#W(Q){const{min:$,max:J}=this.#N(),Z=J-$;if(Z===0)return 0;return(Number(Q)-$)/Z}#Y(Q){if(Q===null||Q===void 0)return null;if(typeof Q==="string"&&Q.trim()==="")return null;const $=Number(Q);return Number.isFinite($)?$:null}#N(){let Q=this.#Y(this.min),$=this.#Y(this.max);if(Q===null)Q=0;if($===null)$=Q;if(Q>$)[Q,$]=[$,Q];return{min:Q,max:$}}#U(Q){const{min:$,max:J}=this.#N();return Math.min(J,Math.max($,Q))}#M(){if(this.type==="delta"){const $=this.#Y(this.default);if($!==null)return this.#U($);return this.#U(0)}const{min:Q}=this.#N();return Q}#L(Q){const $=this.#Y(Q);if($===null)return this.#M();return this.#U($)}#O(){let Q=this.#W(this.value);this.style.setProperty("--slider-complete",Q);let $=this.#W(this.default);this.style.setProperty("--default",$),this.style.setProperty("--unchanged",Q===$?1:0)}#G(){let Q=this.input.value;if(this.value=Q,this.#O(),this.input.setAttribute("aria-valuenow",Q),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":Q)}#B(){this.#Q=!1,this.#G(),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#z(){this.#$=!1,this.#Q=!1,this.#G(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#R(){if(this.figInputNumber){const Q=this.figInputNumber.value;this.#Q=Q===null||Q===void 0||typeof Q==="string"&&Q.trim()==="";const $=this.#L(Q);this.value=$,this.input.value=String($),this.#G(),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}}static get observedAttributes(){return["value","step","min","max","type","variant","disabled","color","units","transform","text","placeholder","default","precision"]}focus(){this.input.focus()}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"color":this.color=J,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=J!==null&&J!=="false",this.figInputNumber)this.figInputNumber.disabled=this.disabled,this.figInputNumber.setAttribute("disabled",this.disabled);break;case"value":if(this.#$)break;if(this.#Q=J===null||typeof J==="string"&&J.trim()==="",this.value=this.#L(J),this.input.value=String(this.value),this.#G(),this.figInputNumber)this.figInputNumber.setAttribute("value",this.#Q?"":this.value);break;case"transform":if(this.transform=Number(J)||1,this.figInputNumber)this.figInputNumber.setAttribute("transform",this.transform);break;case"precision":if(this.precision=J!==null?Number(J):null,this.figInputNumber)if(this.precision!==null)this.figInputNumber.setAttribute("precision",this.precision);else this.figInputNumber.removeAttribute("precision");break;case"placeholder":if(this.placeholder=J!==null?J:"##",this.figInputNumber)this.figInputNumber.setAttribute("placeholder",this.placeholder);break;case"default":this.default=J!==null?J:this.type==="delta"?0:this.min,this.#O();break;case"min":case"max":case"step":case"type":case"variant":case"units":this[Q]=J,this.#X();break;case"text":this.text=J!==null&&J!=="false",this.#X();break;default:this[Q]=this.input[Q]=J,this.#G();break}}}customElements.define("fig-slider",B0);class O0 extends HTMLElement{#$=!1;#Q;#J;#j;#_;#Z;constructor(){super();this.#Q=this.#q.bind(this),this.#J=this.#Y.bind(this),this.#j=this.#Y.bind(this),this.#_=this.#W.bind(this),this.#Z=(Q)=>{Q.stopPropagation(),this.#X(Q)}}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")||!1,this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.readonly=this.hasAttribute("readonly")&&this.getAttribute("readonly")!=="false",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.input.setAttribute("min",String(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",String(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",String(this.step));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}let Q=`<input
|
|
60
60
|
type="${this.type}"
|
|
61
61
|
${this.name?`name="${this.name}"`:""}
|
|
62
62
|
placeholder="${this.placeholder}"
|
|
63
|
-
value="${this.type==="number"?this.#
|
|
64
|
-
placeholder="${this.placeholder}">${this.value}</textarea>`;requestAnimationFrame(()=>{let $=this.querySelector("[slot=append]"),J=this.querySelector("[slot=prepend]");if(this.innerHTML=Q,J)J.addEventListener("click",this.focus.bind(this)),this.prepend(J);if($)$.addEventListener("click",this.focus.bind(this)),this.append($);if(this.input=this.querySelector("input,textarea"),this.input.readOnly=this.readonly,this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#
|
|
63
|
+
value="${this.type==="number"?this.#K(this.value):this.value}" />`;if(this.multiline)Q=`<textarea
|
|
64
|
+
placeholder="${this.placeholder}">${this.value}</textarea>`;requestAnimationFrame(()=>{let $=this.querySelector("[slot=append]"),J=this.querySelector("[slot=prepend]");if(this.innerHTML=Q,J)J.addEventListener("click",this.focus.bind(this)),this.prepend(J);if($)$.addEventListener("click",this.focus.bind(this)),this.append($);if(this.input=this.querySelector("input,textarea"),this.input.readOnly=this.readonly,this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#K(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#K(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#K(this.step));this.addEventListener("pointerdown",this.#_)}this.input.removeEventListener("change",this.#Z),this.input.addEventListener("change",this.#Z)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#Z);this.removeEventListener("pointerdown",this.#_),window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#j)}focus(){this.input.focus()}#K(Q){if(Q==="")return"";let $=Number(Q)*(this.transform||1);return $=this.#U($),$}#X(Q){Q.stopPropagation();let $=Q.target.value,J=$;if(this.type==="number")$=$/(this.transform||1),$=this.#N($,!1),J=$*(this.transform||1);this.value=$,this.input.value=J,this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#q(Q){if(this.type!=="number")return;if(Q.buttons===0){this.#Y();return}let $=(this.step||1)*Q.movementX,J=Number(this.input.value);J=J/(this.transform||1)+$,J=this.#N(J,!1);let Z=J*(this.transform||1);J=this.#U(J),Z=this.#U(Z),this.value=J,this.input.value=Z,this.dispatchEvent(new CustomEvent("input",{bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0}))}#W(Q){if(this.type!=="number")return;if(Q.altKey||Q.target.closest("[slot]"))this.#$=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#Q),window.addEventListener("pointerup",this.#J),window.addEventListener("blur",this.#j)}#Y(Q){if(this.type!=="number")return;this.#$=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#j)}#N(Q,$=!0){let J=Q;if(this.type==="number"){if(J=Number(J),typeof this.min==="number")J=Math.max($?this.#K(this.min):this.min,J);if(typeof this.max==="number")J=Math.min($?this.#K(this.max):this.max,J);J=this.#U(J)}return J}#U(Q,$=2){const J=Math.round(Q*100)/100;return Number.isInteger(J)?J:J.toFixed($)}static get observedAttributes(){return["value","placeholder","label","disabled","readonly","type","step","min","max","transform","name"]}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false";break;case"readonly":this.readonly=J!==null&&J!=="false",this.input.readOnly=this.readonly;break;case"transform":if(this.type==="number")this.transform=Number(J)||1,this.input.value=this.#K(this.value);break;case"value":if(this.#$)break;let Z=J;if(this.type==="number")Z=this.#N(Z,!1),this.value=Z,this.input.value=this.#K(Z);else this.value=Z,this.input.value=Z;break;case"min":case"max":case"step":if(this[Q]=this.input[Q]=Number(J),this.input)this.input.setAttribute(Q,J);break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-text",O0);class M0 extends HTMLElement{#$;#Q;#J;#j;#_;#Z;#K;#X;#q;#W;#Y;#N;#U=!1;#M=null;#L(Q){if(Q&&!this.#M)this.#M=document.createElement("span"),this.#M.className="fig-steppers",this.#M.innerHTML='<button class="fig-stepper-up" tabindex="-1" aria-label="Increase"></button><button class="fig-stepper-down" tabindex="-1" aria-label="Decrease"></button>',this.#M.addEventListener("pointerdown",($)=>{$.preventDefault(),$.stopPropagation();const J=$.target.closest("button");if(!J||this.disabled)return;const Z=J.classList.contains("fig-stepper-up")?1:-1;this.#O(Z),this.input.focus()}),this.append(this.#M);else if(!Q&&this.#M)this.#M.remove(),this.#M=null}#O(Q){const $=this.step||1;let J=this.#G(this.input.value),Z=(J!==""?Number(J)/(this.transform||1):0)+$*Q;Z=this.#E(Z,!1),this.value=Z,this.input.value=this.#B(this.value),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}constructor(){super();this.#$=this.#A.bind(this),this.#Q=this.#C.bind(this),this.#J=this.#C.bind(this),this.#j=this.#T.bind(this),this.#_=(Q)=>{Q.stopPropagation(),this.#H(Q)},this.#Z=(Q)=>{Q.stopPropagation(),this.#k(Q)},this.#K=(Q)=>{this.#R(Q)},this.#X=(Q)=>{this.#F(Q)},this.#q=(Q)=>{this.#D(Q)}}connectedCallback(){const Q=this.getAttribute("value");if(this.value=Q!==null&&Q!==""?Number(Q):"",this.placeholder=this.getAttribute("placeholder")||"",this.name=this.getAttribute("name")||null,this.#W=this.getAttribute("units")||"",this.#Y=this.getAttribute("unit-position")||"suffix",this.#N=this.hasAttribute("precision")?Number(this.getAttribute("precision")):2,this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));this.transform=Number(this.getAttribute("transform")||1);const $=this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false";let J=`<input
|
|
65
65
|
type="text"
|
|
66
66
|
inputmode="decimal"
|
|
67
67
|
${this.name?`name="${this.name}"`:""}
|
|
68
68
|
placeholder="${this.placeholder}"
|
|
69
|
-
value="${this.#B(this.value)}" />`;requestAnimationFrame(()=>{let Z=this.querySelector("[slot=append]"),j=this.querySelector("[slot=prepend]");if(this.innerHTML=J,j)j.addEventListener("click",this.focus.bind(this)),this.prepend(j);if(Z)Z.addEventListener("click",this.focus.bind(this)),this.append(Z);if(this.input=this.querySelector("input"),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.#L($),this.hasAttribute("disabled")){const _=this.getAttribute("disabled");this.disabled=this.input.disabled=_!=="false"}this.addEventListener("pointerdown",this.#Z),this.input.removeEventListener("change",this.#q),this.input.addEventListener("change",this.#q),this.input.removeEventListener("input",this.#K),this.input.addEventListener("input",this.#K),this.input.removeEventListener("focus",this.#_),this.input.addEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#W),this.input.addEventListener("blur",this.#W),this.input.removeEventListener("keydown",this.#j),this.input.addEventListener("keydown",this.#j)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#q),this.input.removeEventListener("input",this.#K),this.input.removeEventListener("focus",this.#_),this.input.removeEventListener("blur",this.#W),this.input.removeEventListener("keydown",this.#j);this.removeEventListener("pointerdown",this.#Z),window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#$)}focus(){this.input.focus()}#N(Q){if(!Q)return"";if(!this.#X){let Z=Q.replace(/[^\d.-]/g,"");const j=Z.split(".");if(j.length>2)Z=j[0]+"."+j.slice(1).join("");return Z}let $=Q.replace(this.#X,"").trim();$=$.replace(/[^\d.-]/g,"");const J=$.split(".");if(J.length>2)$=J[0]+"."+J.slice(1).join("");return $}#B(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);if(isNaN($))return"";if($=this.#P($),!this.#X)return $.toString();if(this.#Y==="prefix")return this.#X+$;else return $+this.#X}#R(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);return $=this.#P($),$.toString()}#D(Q){this.#U=!0,setTimeout(()=>{const $=Q.target.value;if($&&this.#X)if(this.#Y==="prefix")Q.target.setSelectionRange(this.#X.length,$.length);else{const J=$.indexOf(this.#X);if(J>-1)Q.target.setSelectionRange(0,J)}},0)}#E(Q){this.#U=!1;let $=this.#N(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#H(J,!1),this.value=J,Q.target.value=this.#B(this.value)}else this.value="",Q.target.value="";this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#k(Q){if(this.disabled)return;if(Q.key!=="ArrowUp"&&Q.key!=="ArrowDown")return;Q.preventDefault();const $=this.step||1,J=Q.shiftKey?10:1,Z=$*J*(Q.key==="ArrowUp"?1:-1);let j=this.#N(this.input.value),_=(j!==""?Number(j)/(this.transform||1):0)+Z;_=this.#H(_,!1),this.value=_,this.input.value=this.#B(this.value),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#F(Q){let $=this.#N(Q.target.value);if($!=="")this.value=Number($)/(this.transform||1);else this.value="";this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#z(Q){Q.stopPropagation();let $=this.#N(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#H(J,!1),this.value=J,Q.target.value=this.#B(this.value)}else this.value="",Q.target.value="";this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#A(Q){if(this.disabled)return;if(Q.buttons===0){this.#T();return}let $=(this.step||1)*Q.movementX,J=this.#N(this.input.value),Z=Number(J)/(this.transform||1)+$;Z=this.#H(Z,!1),this.value=Z,this.input.value=this.#B(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0}))}#f(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#U=!0,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.#J),window.addEventListener("blur",this.#$)}#T(Q){this.#U=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#Q),window.removeEventListener("pointerup",this.#J),window.removeEventListener("blur",this.#$)}#H(Q,$=!0){let J=Number(Q);if(isNaN(J))return"";if(typeof this.min==="number")J=Math.max(this.min,J);if(typeof this.max==="number")J=Math.min(this.max,J);return J=this.#P(J),J}#P(Q){const $=this.#G??2,J=Math.pow(10,$),Z=Math.round(Q*J)/J;return Number.isInteger(Z)?Z:parseFloat(Z.toFixed($))}static get observedAttributes(){return["value","placeholder","disabled","step","min","max","transform","name","units","unit-position","steppers","precision"]}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false";break;case"units":this.#X=J||"",this.input.value=this.#B(this.value);break;case"unit-position":this.#Y=J||"suffix",this.input.value=this.#B(this.value);break;case"transform":this.transform=Number(J)||1,this.input.value=this.#B(this.value);break;case"value":if(this.#U)break;let Z=J!==null&&J!==""?Number(J):"";if(Z!=="")Z=this.#H(Z,!1);this.value=Z,this.input.value=this.#B(this.value);break;case"min":case"max":case"step":if(J===null||J===""){this[Q]=void 0;break}this[Q]=Number(J);break;case"steppers":{const j=J!==null&&J!=="false";this.#L(j);break}case"precision":this.#G=J!==null?Number(J):2,this.input.value=this.#B(this.value);break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-number",U0);class G0 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),requestAnimationFrame(()=>{this.img=this.querySelector("img")})}setSrc(Q){if(this.src=Q,Q)this.innerHTML=`<img src="${this.src}" ${this.name?`alt="${this.name}"`:""} />`}getInitials(Q){return Q?Q.split(" ").map(($)=>$[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(Q,$,J){if(this[Q]=J,Q==="name")this.img?.setAttribute("alt",J),this.name=J,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials);else if(Q==="src")this.src=J,this.setSrc(this.src)}}customElements.define("fig-avatar",G0);class L0 extends HTMLElement{constructor(){super()}static get observedAttributes(){return["label"]}connectedCallback(){requestAnimationFrame(()=>{if(this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((Q)=>Q.nodeName.toLowerCase().startsWith("fig-")),this.input&&this.label){this.label.addEventListener("click",this.focus.bind(this));let Q=this.input.getAttribute("id")||w();this.input.setAttribute("id",Q),this.label.setAttribute("for",Q)}})}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(this.label)this.label.textContent=J;break}}focus(){this.input.focus()}}customElements.define("fig-field",L0);class N0 extends HTMLElement{#Q=null;#J=null;#$=null;#Z=null;#q=new Set;#K=0;#_=null;#W=null;#j=new Set(["variant","color","text","full"]);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#Q)this.#X();if(this.#Y(),this.#G(),this.#M(),!this.#Z)this.#Z=new MutationObserver((Q)=>{let $=!1,J=!1;for(let Z of Q)if(Z.type==="attributes"){if(Z.attributeName&&this.#j.has(Z.attributeName))continue;if(Z.attributeName==="label"||Z.attributeName==="direction")$=!0;else J=!0}if($)this.#Y();if(J)this.#G()});this.#Z.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#Z?.disconnect(),this.#K)cancelAnimationFrame(this.#K),this.#K=0;this.#N()}attributeChangedCallback(Q,$,J){if($===J||!this.#Q)return;if(Q==="label"||Q==="direction")this.#Y()}#X(){const Q=Array.from(this.childNodes).filter((j)=>{return j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())}),$=document.createElement("fig-field"),J=document.createElement("label"),Z=document.createElement("fig-slider");Z.setAttribute("text","true");for(let j of this.#U()){const _=this.getAttribute(j);Z.setAttribute(j,_??"")}$.append(J,Z),this.#Q=$,this.#J=J,this.#$=Z,this.replaceChildren($);for(let j of Q)this.#$.appendChild(j)}#Y(){if(!this.#Q||!this.#J)return;const Q=this.hasAttribute("label"),$=this.getAttribute("label");if(Q&&($??"").trim()===""){if(this.#J.parentElement===this.#Q)this.#J.remove()}else if(this.#J.textContent=Q?$??"":"Label",this.#J.parentElement!==this.#Q)this.#Q.prepend(this.#J);this.#Q.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#G(){if(!this.#$)return;const Q=this.#U(),$=new Set(Q.filter((Z)=>Z!=="text"));for(let Z of this.#q)if(!$.has(Z))this.#$.removeAttribute(Z);for(let Z of Q){if(Z==="text")continue;const j=this.getAttribute(Z);this.#$.setAttribute(Z,j??"")}this.#$.removeAttribute("variant"),this.#$.removeAttribute("color"),this.#$.removeAttribute("transform"),this.#$.removeAttribute("full"),this.#$.setAttribute("text","true");const J=(this.getAttribute("type")||"range").toLowerCase();if(J==="delta"||J==="stepper")this.#$.setAttribute("default",this.getAttribute("default")??"50");else if(!this.hasAttribute("default"))this.#$.removeAttribute("default");if(J==="stepper")this.#$.setAttribute("step",this.getAttribute("step")??"10");else if(!this.hasAttribute("step"))this.#$.removeAttribute("step");if(J==="opacity")this.#$.style.setProperty("--color","var(--figma-color-bg-tertiary)");else this.#$.style.removeProperty("--color");this.#q=$,this.#O()}#U(){const Q=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter(($)=>!Q.has($)&&!this.#j.has($))}#O(){if(this.#K)cancelAnimationFrame(this.#K);this.#K=requestAnimationFrame(()=>{this.#K=0,this.#L()})}#L(){if(!this.#$)return;const Q=this.#$.querySelector("fig-input-number");if(!Q)return;if(!(this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false")){Q.removeAttribute("steppers");return}const J=this.getAttribute("steppers");Q.setAttribute("steppers",J??"")}#M(){if(!this.#$)return;if(!this.#_)this.#_=this.#B.bind(this,"input");if(!this.#W)this.#W=this.#B.bind(this,"change");this.#$.addEventListener("input",this.#_),this.#$.addEventListener("change",this.#W)}#N(){if(!this.#$)return;if(this.#_)this.#$.removeEventListener("input",this.#_);if(this.#W)this.#$.removeEventListener("change",this.#W)}#B(Q,$){$.stopPropagation();const J=$ instanceof CustomEvent&&$.detail!==void 0?$.detail:this.#$?.value;this.dispatchEvent(new CustomEvent(Q,{detail:J,bubbles:!0,cancelable:!0,composed:!0}))}}customElements.define("fig-field-slider",N0);class B0 extends HTMLElement{rgba;hex;alpha=100;#Q;#J;#$;#Z;constructor(){super()}get picker(){return this.getAttribute("picker")||"native"}set picker(Q){this.setAttribute("picker",Q)}#q(){const Q={},$=this.getAttribute("experimental");if($)Q.experimental=$;for(let{name:J,value:Z}of this.attributes)if(J.startsWith("picker-")&&J!=="picker-anchor")Q[J.slice(7)]=Z;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([J,Z])=>`${J}="${Z}"`).join(" ")}connectedCallback(){this.#K(this.getAttribute("value"));const Q=this.picker==="figma",$=this.picker==="false",J=this.getAttribute("alpha")==="true",Z=this.#q();let j="";if(this.getAttribute("text")){let _=`<fig-input-text
|
|
69
|
+
value="${this.#B(this.value)}" />`;requestAnimationFrame(()=>{let Z=this.querySelector("[slot=append]"),j=this.querySelector("[slot=prepend]");if(this.innerHTML=J,j)j.addEventListener("click",this.focus.bind(this)),this.prepend(j);if(Z)Z.addEventListener("click",this.focus.bind(this)),this.append(Z);if(this.input=this.querySelector("input"),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.#L($),this.hasAttribute("disabled")){const _=this.getAttribute("disabled");this.disabled=this.input.disabled=_!=="false"}this.addEventListener("pointerdown",this.#j),this.input.removeEventListener("change",this.#_),this.input.addEventListener("change",this.#_),this.input.removeEventListener("input",this.#Z),this.input.addEventListener("input",this.#Z),this.input.removeEventListener("focus",this.#K),this.input.addEventListener("focus",this.#K),this.input.removeEventListener("blur",this.#X),this.input.addEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#q),this.input.addEventListener("keydown",this.#q)})}disconnectedCallback(){if(this.input)this.input.removeEventListener("change",this.#_),this.input.removeEventListener("input",this.#Z),this.input.removeEventListener("focus",this.#K),this.input.removeEventListener("blur",this.#X),this.input.removeEventListener("keydown",this.#q);this.removeEventListener("pointerdown",this.#j),window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J)}focus(){this.input.focus()}#G(Q){if(!Q)return"";if(!this.#W){let Z=Q.replace(/[^\d.-]/g,"");const j=Z.split(".");if(j.length>2)Z=j[0]+"."+j.slice(1).join("");return Z}let $=Q.replace(this.#W,"").trim();$=$.replace(/[^\d.-]/g,"");const J=$.split(".");if(J.length>2)$=J[0]+"."+J.slice(1).join("");return $}#B(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);if(isNaN($))return"";if($=this.#P($),!this.#W)return $.toString();if(this.#Y==="prefix")return this.#W+$;else return $+this.#W}#z(Q){if(Q===""||Q===null||Q===void 0)return"";let $=Number(Q)*(this.transform||1);return $=this.#P($),$.toString()}#R(Q){this.#U=!0,setTimeout(()=>{const $=Q.target.value;if($&&this.#W)if(this.#Y==="prefix")Q.target.setSelectionRange(this.#W.length,$.length);else{const J=$.indexOf(this.#W);if(J>-1)Q.target.setSelectionRange(0,J)}},0)}#F(Q){this.#U=!1;let $=this.#G(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#E(J,!1),this.value=J,Q.target.value=this.#B(this.value)}else this.value="",Q.target.value="";this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#D(Q){if(this.disabled)return;if(Q.key!=="ArrowUp"&&Q.key!=="ArrowDown")return;Q.preventDefault();const $=this.step||1,J=Q.shiftKey?10:1,Z=$*J*(Q.key==="ArrowUp"?1:-1);let j=this.#G(this.input.value),_=(j!==""?Number(j)/(this.transform||1):0)+Z;_=this.#E(_,!1),this.value=_,this.input.value=this.#B(this.value),this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#k(Q){let $=this.#G(Q.target.value);if($!=="")this.value=Number($)/(this.transform||1);else this.value="";this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0}))}#H(Q){Q.stopPropagation();let $=this.#G(Q.target.value);if($!==""){let J=Number($)/(this.transform||1);J=this.#E(J,!1),this.value=J,Q.target.value=this.#B(this.value)}else this.value="",Q.target.value="";this.dispatchEvent(new CustomEvent("input",{detail:this.value,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:this.value,bubbles:!0}))}#A(Q){if(this.disabled)return;if(Q.buttons===0){this.#C();return}let $=(this.step||1)*Q.movementX,J=this.#G(this.input.value),Z=Number(J)/(this.transform||1)+$;Z=this.#E(Z,!1),this.value=Z,this.input.value=this.#B(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0}))}#T(Q){if(this.disabled)return;if(Q.altKey||Q.target.closest("[slot]"))this.#U=!0,this.input.style.cursor=this.style.cursor=document.body.style.cursor="ew-resize",this.style.userSelect="none",window.addEventListener("pointermove",this.#$),window.addEventListener("pointerup",this.#Q),window.addEventListener("blur",this.#J)}#C(Q){this.#U=!1,this.input.style.cursor=this.style.cursor=document.body.style.cursor="",this.style.userSelect="all",window.removeEventListener("pointermove",this.#$),window.removeEventListener("pointerup",this.#Q),window.removeEventListener("blur",this.#J)}#E(Q,$=!0){let J=Number(Q);if(isNaN(J))return"";if(typeof this.min==="number")J=Math.max(this.min,J);if(typeof this.max==="number")J=Math.min(this.max,J);return J=this.#P(J),J}#P(Q){const $=this.#N??2,J=Math.pow(10,$),Z=Math.round(Q*J)/J;return Number.isInteger(Z)?Z:parseFloat(Z.toFixed($))}static get observedAttributes(){return["value","placeholder","disabled","step","min","max","transform","name","units","unit-position","steppers","precision"]}attributeChangedCallback(Q,$,J){if(this.input)switch(Q){case"disabled":this.disabled=this.input.disabled=J!==null&&J!=="false";break;case"units":this.#W=J||"",this.input.value=this.#B(this.value);break;case"unit-position":this.#Y=J||"suffix",this.input.value=this.#B(this.value);break;case"transform":this.transform=Number(J)||1,this.input.value=this.#B(this.value);break;case"value":if(this.#U)break;let Z=J!==null&&J!==""?Number(J):"";if(Z!=="")Z=this.#E(Z,!1);this.value=Z,this.input.value=this.#B(this.value);break;case"min":case"max":case"step":if(J===null||J===""){this[Q]=void 0;break}this[Q]=Number(J);break;case"steppers":{const j=J!==null&&J!=="false";this.#L(j);break}case"precision":this.#N=J!==null?Number(J):2,this.input.value=this.#B(this.value);break;case"name":this[Q]=this.input[Q]=J,this.input.setAttribute("name",J);break;default:this[Q]=this.input[Q]=J;break}}}customElements.define("fig-input-number",M0);class R0 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),requestAnimationFrame(()=>{this.img=this.querySelector("img")})}setSrc(Q){if(this.src=Q,Q)this.innerHTML=`<img src="${this.src}" ${this.name?`alt="${this.name}"`:""} />`}getInitials(Q){return Q?Q.split(" ").map(($)=>$[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(Q,$,J){if(this[Q]=J,Q==="name")this.img?.setAttribute("alt",J),this.name=J,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials);else if(Q==="src")this.src=J,this.setSrc(this.src)}}customElements.define("fig-avatar",R0);class z0 extends HTMLElement{constructor(){super()}static get observedAttributes(){return["label"]}connectedCallback(){requestAnimationFrame(()=>{if(this.label=this.querySelector(":scope>label"),this.input=Array.from(this.childNodes).find((Q)=>Q.nodeName.toLowerCase().startsWith("fig-")),this.input&&this.label){this.label.addEventListener("click",this.focus.bind(this));let Q=this.input.getAttribute("id")||v();this.input.setAttribute("id",Q),this.label.setAttribute("for",Q)}})}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(this.label)this.label.textContent=J;break}}focus(){this.input.focus()}}customElements.define("fig-field",z0);class A0 extends HTMLElement{#$=null;#Q=null;#J=null;#j=null;#_=new Set;#Z=0;#K=null;#X=null;#q=new Set(["variant","color","text","full"]);static get observedAttributes(){return["label","direction"]}connectedCallback(){if(!this.#$)this.#W();if(this.#Y(),this.#N(),this.#O(),!this.#j)this.#j=new MutationObserver((Q)=>{let $=!1,J=!1;for(let Z of Q)if(Z.type==="attributes"){if(Z.attributeName&&this.#q.has(Z.attributeName))continue;if(Z.attributeName==="label"||Z.attributeName==="direction")$=!0;else J=!0}if($)this.#Y();if(J)this.#N()});this.#j.observe(this,{attributes:!0})}disconnectedCallback(){if(this.#j?.disconnect(),this.#Z)cancelAnimationFrame(this.#Z),this.#Z=0;this.#G()}attributeChangedCallback(Q,$,J){if($===J||!this.#$)return;if(Q==="label"||Q==="direction")this.#Y()}#W(){const Q=Array.from(this.childNodes).filter((j)=>{return j.nodeType!==Node.TEXT_NODE||Boolean(j.textContent?.trim())}),$=document.createElement("fig-field"),J=document.createElement("label"),Z=document.createElement("fig-slider");Z.setAttribute("text","true");for(let j of this.#U()){const _=this.getAttribute(j);Z.setAttribute(j,_??"")}$.append(J,Z),this.#$=$,this.#Q=J,this.#J=Z,this.replaceChildren($);for(let j of Q)this.#J.appendChild(j)}#Y(){if(!this.#$||!this.#Q)return;const Q=this.hasAttribute("label"),$=this.getAttribute("label");if(Q&&($??"").trim()===""){if(this.#Q.parentElement===this.#$)this.#Q.remove()}else if(this.#Q.textContent=Q?$??"":"Label",this.#Q.parentElement!==this.#$)this.#$.prepend(this.#Q);this.#$.setAttribute("direction",this.getAttribute("direction")||"horizontal")}#N(){if(!this.#J)return;const Q=this.#U(),$=new Set(Q.filter((Z)=>Z!=="text"));for(let Z of this.#_)if(!$.has(Z))this.#J.removeAttribute(Z);for(let Z of Q){if(Z==="text")continue;const j=this.getAttribute(Z);this.#J.setAttribute(Z,j??"")}this.#J.removeAttribute("variant"),this.#J.removeAttribute("color"),this.#J.removeAttribute("transform"),this.#J.removeAttribute("full"),this.#J.setAttribute("text","true");const J=(this.getAttribute("type")||"range").toLowerCase();if(J==="delta"||J==="stepper")this.#J.setAttribute("default",this.getAttribute("default")??"50");else if(!this.hasAttribute("default"))this.#J.removeAttribute("default");if(J==="stepper")this.#J.setAttribute("step",this.getAttribute("step")??"10");else if(!this.hasAttribute("step"))this.#J.removeAttribute("step");if(J==="opacity")this.#J.style.setProperty("--color","var(--figma-color-bg-tertiary)");else this.#J.style.removeProperty("--color");this.#_=$,this.#M()}#U(){const Q=new Set(["label","direction","oninput","onchange","steppers"]);return this.getAttributeNames().filter(($)=>!Q.has($)&&!this.#q.has($))}#M(){if(this.#Z)cancelAnimationFrame(this.#Z);this.#Z=requestAnimationFrame(()=>{this.#Z=0,this.#L()})}#L(){if(!this.#J)return;const Q=this.#J.querySelector("fig-input-number");if(!Q)return;if(!(this.hasAttribute("steppers")&&this.getAttribute("steppers")!=="false")){Q.removeAttribute("steppers");return}const J=this.getAttribute("steppers");Q.setAttribute("steppers",J??"")}#O(){if(!this.#J)return;if(!this.#K)this.#K=this.#B.bind(this,"input");if(!this.#X)this.#X=this.#B.bind(this,"change");this.#J.addEventListener("input",this.#K),this.#J.addEventListener("change",this.#X)}#G(){if(!this.#J)return;if(this.#K)this.#J.removeEventListener("input",this.#K);if(this.#X)this.#J.removeEventListener("change",this.#X)}#B(Q,$){$.stopPropagation();const J=$ instanceof CustomEvent&&$.detail!==void 0?$.detail:this.#J?.value;this.dispatchEvent(new CustomEvent(Q,{detail:J,bubbles:!0,cancelable:!0,composed:!0}))}}customElements.define("fig-field-slider",A0);class F0 extends HTMLElement{rgba;hex;#$=100;#Q;#J;#j;#_;constructor(){super()}get picker(){return this.getAttribute("picker")||"native"}set picker(Q){this.setAttribute("picker",Q)}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0||Q===!1)this.removeAttribute("alpha");else this.setAttribute("alpha",String(Q))}#Z(){const Q={},$=this.getAttribute("experimental");if($)Q.experimental=$;for(let{name:J,value:Z}of this.attributes)if(J.startsWith("picker-")&&J!=="picker-anchor")Q[J.slice(7)]=Z;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([J,Z])=>`${J}="${Z}"`).join(" ")}connectedCallback(){if(this.#K)cancelAnimationFrame(this.#K);this.#K=requestAnimationFrame(()=>{this.#K=null,this.#X()})}#K=null;#X(){this.#q(this.getAttribute("value"));const Q=this.picker==="figma",$=this.picker==="false",J=this.getAttribute("alpha")==="true",Z=this.#Z(),_=this.#G?" disabled":"";let q="";if(this.getAttribute("text")==="true"){let X=`<fig-input-text
|
|
70
70
|
type="text"
|
|
71
71
|
placeholder="000000"
|
|
72
|
-
value="${this.hexOpaque.slice(1).toUpperCase()}">
|
|
73
|
-
</fig-input-text>`;if(J)
|
|
72
|
+
value="${this.hexOpaque.slice(1).toUpperCase()}"${_}>
|
|
73
|
+
</fig-input-text>`;if(J)X+=`<fig-tooltip text="Opacity">
|
|
74
74
|
<fig-input-number
|
|
75
75
|
placeholder="##"
|
|
76
76
|
min="0"
|
|
77
77
|
max="100"
|
|
78
|
-
value="${this
|
|
79
|
-
units="%">
|
|
78
|
+
value="${this.#$}"
|
|
79
|
+
units="%"${_}>
|
|
80
80
|
</fig-input-number>
|
|
81
|
-
</fig-tooltip>`;let
|
|
82
|
-
${
|
|
83
|
-
${
|
|
84
|
-
</div>`}else if($)
|
|
81
|
+
</fig-tooltip>`;let Y="";if(!$)Y=Q?`<fig-fill-picker mode="solid" ${Z} ${J?"":'alpha="false"'} value='{"type":"solid","color":"${this.hexOpaque}","opacity":${this.#$}}'${_}></fig-fill-picker>`:`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${_}></fig-chit>`;q=`<div class="input-combo">
|
|
82
|
+
${Y}
|
|
83
|
+
${X}
|
|
84
|
+
</div>`}else if($)q="";else q=Q?`<fig-fill-picker mode="solid" ${Z} ${J?"":'alpha="false"'} value='{"type":"solid","color":"${this.hexOpaque}","opacity":${this.#$}}'${_}></fig-fill-picker>`:`<fig-chit background="${this.hexOpaque}" alpha="${this.rgba.a}"${_}></fig-chit>`;this.innerHTML=q,requestAnimationFrame(()=>{if(this.#Q=this.querySelector("fig-chit"),this.#J=this.querySelector("fig-fill-picker"),this.#j=this.querySelector("fig-input-text:not([type=number])"),this.#_=this.querySelector("fig-input-number"),this.#Q)this.#Q.disabled=this.hasAttribute("disabled"),this.#Q.addEventListener("input",this.#U.bind(this));if(this.#J){const X=this.getAttribute("picker-anchor");if(X==="self")this.#J.anchorElement=this;else if(X){const Y=document.querySelector(X);if(Y)this.#J.anchorElement=Y}if(this.hasAttribute("disabled"))this.#J.setAttribute("disabled","");this.#J.addEventListener("input",this.#M.bind(this)),this.#J.addEventListener("change",this.#N.bind(this))}if(this.#j){const X=this.rgbAlphaToHex(this.rgba,1);if(this.#j.value=X.slice(1).toUpperCase(),this.#Q)this.#Q.background=X;this.#j.addEventListener("input",this.#W.bind(this)),this.#j.addEventListener("change",this.#N.bind(this))}if(this.#_)this.#_.addEventListener("input",this.#Y.bind(this)),this.#_.addEventListener("change",this.#N.bind(this))})}#q(Q){if(this.rgba=this.convertToRGBA(Q),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),Q.length>7)this.#$=(this.rgba.a*100).toFixed(0);this.style.setProperty("--alpha",this.rgba.a)}#W(Q){Q.stopPropagation();let $=Q.target.value.replace("#","");if(this.#q("#"+$),this.#_)this.#_.setAttribute("value",this.#$);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque);this.#L()}#Y(Q){Q.stopPropagation();const $=Number(Q.target.value)||0,Z=Math.round($/100*255).toString(16).padStart(2,"0");if(this.#q(this.hexOpaque+Z),this.#Q)this.#Q.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));this.#L()}#N(Q){Q.stopPropagation(),this.#O()}focus(){this.#Q.focus()}#U(Q){if(Q.stopPropagation(),this.#q(Q.target.value),this.#j)this.#j.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());this.#L()}#M(Q){Q.stopPropagation();const $=Q.detail;if($&&$.color){let J=$.color;if($.alpha!==void 0){const Z=Math.round($.alpha*255).toString(16).padStart(2,"0");J=$.color+Z}if(this.#q(J),this.#j)this.#j.setAttribute("value",this.hexOpaque.slice(1).toUpperCase());if(this.#_&&$.alpha!==void 0)this.#_.setAttribute("value",Math.round($.alpha*100));if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);this.#L()}}#L(){const Q=new CustomEvent("input",{bubbles:!0,cancelable:!0});this.dispatchEvent(Q)}#O(){const Q=new CustomEvent("change",{bubbles:!0,cancelable:!0});this.dispatchEvent(Q)}static get observedAttributes(){return["value","style","mode","picker","experimental","alpha","text","disabled"]}get mode(){return this.getAttribute("mode")}set mode(Q){this.setAttribute("mode",Q)}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":if(this.#q(J),this.#j)this.#j.setAttribute("value",this.value);if(this.#Q)this.#Q.setAttribute("background",this.hexOpaque),this.#Q.setAttribute("alpha",this.rgba.a);if(this.#J)this.#J.setAttribute("value",JSON.stringify({type:"solid",color:this.hexOpaque,opacity:this.#$}));if(this.#_)this.#_.setAttribute("value",this.#$);break;case"mode":if(this.#J&&J)this.#J.setAttribute("mode",J);break;case"picker":break;case"alpha":case"text":if(this.isConnected)this.#X();break;case"disabled":this.#B();break}}get#G(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#B(){const Q=this.#G;for(let $ of[this.#Q,this.#j,this.#_]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}if(this.#J)if(Q)this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}rgbAlphaToHex({r:Q,g:$,b:J},Z=1){Q=Math.max(0,Math.min(255,Math.round(Q))),$=Math.max(0,Math.min(255,Math.round($))),J=Math.max(0,Math.min(255,Math.round(J))),Z=Math.max(0,Math.min(1,Z));const j=Q.toString(16).padStart(2,"0"),_=$.toString(16).padStart(2,"0"),q=J.toString(16).padStart(2,"0");if(Z===1)return`#${j}${_}${q}`.toUpperCase();const X=Math.round(Z*255).toString(16).padStart(2,"0");return`#${j}${_}${q}${X}`.toUpperCase()}convertToRGBA(Q){let $,J,Z,j=1;if(Q.startsWith("#")){let _=Q.slice(1);if(_.length===8)j=parseInt(_.slice(6),16)/255,_=_.slice(0,6);$=parseInt(_.slice(0,2),16),J=parseInt(_.slice(2,4),16),Z=parseInt(_.slice(4,6),16)}else if(Q.startsWith("rgba")||Q.startsWith("rgb")){let _=Q.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(_)$=parseInt(_[1]),J=parseInt(_[2]),Z=parseInt(_[3]),j=_[4]?parseFloat(_[4]):1}else if(Q.startsWith("hsla")||Q.startsWith("hsl")){let _=Q.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(_){let q=parseInt(_[1])/360,K=parseInt(_[2])/100,X=parseInt(_[3])/100;if(j=_[4]?parseFloat(_[4]):1,K===0)$=J=Z=X;else{let Y=(L,z,M)=>{if(M<0)M+=1;if(M>1)M-=1;if(M<0.16666666666666666)return L+(z-L)*6*M;if(M<0.5)return z;if(M<0.6666666666666666)return L+(z-L)*(0.6666666666666666-M)*6;return L},W=X<0.5?X*(1+K):X+K-X*K,U=2*X-W;$=Y(U,W,q+0.3333333333333333),J=Y(U,W,q),Z=Y(U,W,q-0.3333333333333333)}$=Math.round($*255),J=Math.round(J*255),Z=Math.round(Z*255)}}else return null;return{r:$,g:J,b:Z,a:j}}}customElements.define("fig-input-color",F0);var l0=["srgb","srgb-linear","display-p3","oklab","oklch"],t0=["shorter","longer","increasing","decreasing"];class E0 extends HTMLElement{#$="solid";#Q;#J;#j;#_={color:"#D9D9D9",alpha:1};#Z={type:"linear",angle:180,interpolationSpace:"oklab",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#K={url:null,scaleMode:"fill",scale:50,opacity:1};#X={url:null,scaleMode:"fill",opacity:1};#q={snapshot:null,opacity:1};constructor(){super()}static get observedAttributes(){return["value","disabled","mode","experimental","alpha"]}connectedCallback(){this.#W(),this.#U()}disconnectedCallback(){this.#Q=null,this.#J=null,this.#j=null}#W(){const Q=this.getAttribute("value");if(!Q)return;try{const $=JSON.parse(Q);if($.type)this.#$=$.type;switch(this.#$){case"solid":if($.color)this.#_.color=$.color;if($.alpha!==void 0)this.#_.alpha=$.alpha;if($.opacity!==void 0)this.#_.alpha=$.opacity/100;break;case"gradient":if($.gradient)this.#Z=y({...this.#Z,...$.gradient});break;case"image":if($.image)this.#K={...this.#K,...$.image};break;case"video":if($.video)this.#X={...this.#X,...$.video};break;case"webcam":if($.webcam)this.#q={...this.#q,...$.webcam};if($.opacity!==void 0)this.#q.opacity=$.opacity;break}}catch($){if(Q.startsWith("#")){if(this.#$="solid",this.#_.color=Q.slice(0,7),Q.length>7){const J=Q.slice(7,9);this.#_.alpha=parseInt(J,16)/255}}}}#Y(){const Q={},$=this.getAttribute("mode");if($)Q.mode=$;const J=this.getAttribute("experimental");if(J)Q.experimental=J;const Z=this.getAttribute("alpha");if(Z)Q.alpha=Z;for(let{name:j,value:_}of this.attributes)if(j.startsWith("picker-")&&j!=="picker-anchor")Q[j.slice(7)]=_;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([j,_])=>`${j}="${_}"`).join(" ")}#N(){const Q=this.hasAttribute("disabled");for(let $ of[this.#Q,this.#J,this.#j]){if(!$)continue;if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}#U(){const Q=this.hasAttribute("disabled"),$=JSON.stringify(this.value),J=this.getAttribute("alpha")!=="false",Z=(q)=>J?`<fig-tooltip text="Opacity">
|
|
85
85
|
<fig-input-number
|
|
86
86
|
class="fig-input-fill-opacity"
|
|
87
87
|
placeholder="##"
|
|
88
88
|
min="0"
|
|
89
89
|
max="100"
|
|
90
|
-
value="${
|
|
90
|
+
value="${q}"
|
|
91
91
|
units="%"
|
|
92
92
|
${Q?"disabled":""}>
|
|
93
93
|
</fig-input-number>
|
|
94
|
-
</fig-tooltip>`:"";let j="";switch(this
|
|
94
|
+
</fig-tooltip>`:"";let j="";switch(this.#$){case"solid":j=`
|
|
95
95
|
<fig-input-text
|
|
96
96
|
type="text"
|
|
97
97
|
class="fig-input-fill-hex"
|
|
98
98
|
placeholder="000000"
|
|
99
|
-
value="${this.#
|
|
99
|
+
value="${this.#_.color.slice(1).toUpperCase()}"
|
|
100
100
|
${Q?"disabled":""}>
|
|
101
101
|
</fig-input-text>
|
|
102
|
-
${Z(Math.round(this.#
|
|
103
|
-
<label class="fig-input-fill-label">${this.#
|
|
104
|
-
${Z(this.#
|
|
102
|
+
${Z(Math.round(this.#_.alpha*100))}`;break;case"gradient":j=`
|
|
103
|
+
<label class="fig-input-fill-label">${this.#Z.type.charAt(0).toUpperCase()+this.#Z.type.slice(1)}</label>
|
|
104
|
+
${Z(this.#Z.stops[0]?.opacity??100)}`;break;case"image":j=`
|
|
105
105
|
<label class="fig-input-fill-label">Image</label>
|
|
106
|
-
${Z(Math.round((this.#
|
|
106
|
+
${Z(Math.round((this.#K.opacity??1)*100))}`;break;case"video":j=`
|
|
107
107
|
<label class="fig-input-fill-label">Video</label>
|
|
108
|
-
${Z(Math.round((this.#
|
|
108
|
+
${Z(Math.round((this.#X.opacity??1)*100))}`;break;case"webcam":j=`
|
|
109
109
|
<label class="fig-input-fill-label">Webcam</label>
|
|
110
|
-
${Z(Math.round((this.#
|
|
110
|
+
${Z(Math.round((this.#q.opacity??1)*100))}`;break}const _=this.#Y();this.innerHTML=`
|
|
111
111
|
<div class="input-combo">
|
|
112
112
|
<fig-fill-picker ${_} value='${$}' ${Q?"disabled":""}></fig-fill-picker>
|
|
113
113
|
${j}
|
|
114
|
-
</div>`,this.#
|
|
114
|
+
</div>`,this.#M()}#M(){requestAnimationFrame(()=>{this.#Q=this.querySelector("fig-fill-picker"),this.#J=this.querySelector(".fig-input-fill-opacity"),this.#j=this.querySelector(".fig-input-fill-hex");const Q=this.querySelector(".fig-input-fill-label");if(Q&&this.#Q)Q.addEventListener("click",()=>{const $=this.#Q.querySelector("fig-chit");if($)$.click()});if(this.#Q){const $=this.getAttribute("picker-anchor");if(!$||$==="self")this.#Q.anchorElement=this;else{const J=document.querySelector($);if(J)this.#Q.anchorElement=J}this.#Q.addEventListener("input",(J)=>{J.stopPropagation();const Z=J.detail;if(!Z)return;const j=Z.type,_=j!==this.#$;switch(this.#$=j,j){case"solid":this.#_.color=Z.color,this.#_.alpha=Z.alpha;break;case"gradient":if(Z.gradient)this.#Z=y({...this.#Z,...Z.gradient});break;case"image":if(Z.image)this.#K=Z.image;break;case"video":if(Z.video)this.#X=Z.video;break}if(_)this.#O();else this.#L();this.#z()}),this.#Q.addEventListener("change",(J)=>{J.stopPropagation(),this.#R()})}if(this.#j)this.#j.addEventListener("input",($)=>{$.stopPropagation();const J="#"+$.target.value.replace("#","");this.#_.color=J,this.#G(),this.#z()}),this.#j.addEventListener("change",($)=>{$.stopPropagation(),this.#R()});if(this.#J)this.#J.addEventListener("input",($)=>{$.stopPropagation();const J=parseFloat($.target.value),Z=isNaN(J)?100:J,j=Z/100;switch(this.#$){case"solid":this.#_.alpha=j;break;case"gradient":this.#Z.stops.forEach((_)=>{_.opacity=Z});break;case"image":this.#K.opacity=j;break;case"video":this.#X.opacity=j;break;case"webcam":this.#q.opacity=j;break}this.#G(),this.#B(j),this.#z()}),this.#J.addEventListener("change",($)=>{$.stopPropagation(),this.#R()})})}#L(){switch(this.#$){case"solid":if(this.#j)this.#j.setAttribute("value",this.#_.color.slice(1).toUpperCase());if(this.#J)this.#J.setAttribute("value",Math.round(this.#_.alpha*100));break;case"gradient":{if(this.#J)this.#J.setAttribute("value",this.#Z.stops[0]?.opacity??100);const Q=this.querySelector(".fig-input-fill-label");if(Q){const $=this.#Z.type.charAt(0).toUpperCase()+this.#Z.type.slice(1);Q.textContent=$}break}case"image":if(this.#J)this.#J.setAttribute("value",Math.round((this.#K.opacity??1)*100));break;case"video":if(this.#J)this.#J.setAttribute("value",Math.round((this.#X.opacity??1)*100));break;case"webcam":if(this.#J)this.#J.setAttribute("value",Math.round((this.#q.opacity??1)*100));break}}#O(){const Q=this.hasAttribute("disabled"),$=this.querySelector(".input-combo");if(!$)return;const J=$.querySelector(".fig-input-fill-label"),Z=$.querySelector(".fig-input-fill-hex"),j=$.querySelector(".fig-input-fill-opacity"),_=$.querySelectorAll("fig-tooltip");J?.remove(),Z?.remove(),_.forEach((K)=>K.remove());let q="";switch(this.#$){case"solid":q=`
|
|
115
115
|
<fig-input-text
|
|
116
116
|
type="text"
|
|
117
117
|
class="fig-input-fill-hex"
|
|
118
118
|
placeholder="000000"
|
|
119
|
-
value="${this.#
|
|
119
|
+
value="${this.#_.color.slice(1).toUpperCase()}"
|
|
120
120
|
${Q?"disabled":""}>
|
|
121
121
|
</fig-input-text>
|
|
122
122
|
<fig-tooltip text="Opacity">
|
|
@@ -125,23 +125,23 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
125
125
|
placeholder="##"
|
|
126
126
|
min="0"
|
|
127
127
|
max="100"
|
|
128
|
-
value="${Math.round(this.#
|
|
128
|
+
value="${Math.round(this.#_.alpha*100)}"
|
|
129
129
|
units="%"
|
|
130
130
|
${Q?"disabled":""}>
|
|
131
131
|
</fig-input-number>
|
|
132
|
-
</fig-tooltip>`;break;case"gradient":
|
|
133
|
-
<label class="fig-input-fill-label">${this.#
|
|
132
|
+
</fig-tooltip>`;break;case"gradient":q=`
|
|
133
|
+
<label class="fig-input-fill-label">${this.#Z.type.charAt(0).toUpperCase()+this.#Z.type.slice(1)}</label>
|
|
134
134
|
<fig-tooltip text="Opacity">
|
|
135
135
|
<fig-input-number
|
|
136
136
|
class="fig-input-fill-opacity"
|
|
137
137
|
placeholder="##"
|
|
138
138
|
min="0"
|
|
139
139
|
max="100"
|
|
140
|
-
value="${this.#
|
|
140
|
+
value="${this.#Z.stops[0]?.opacity??100}"
|
|
141
141
|
units="%"
|
|
142
142
|
${Q?"disabled":""}>
|
|
143
143
|
</fig-input-number>
|
|
144
|
-
</fig-tooltip>`;break;case"image":
|
|
144
|
+
</fig-tooltip>`;break;case"image":q=`
|
|
145
145
|
<label class="fig-input-fill-label">Image</label>
|
|
146
146
|
<fig-tooltip text="Opacity">
|
|
147
147
|
<fig-input-number
|
|
@@ -149,11 +149,11 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
149
149
|
placeholder="##"
|
|
150
150
|
min="0"
|
|
151
151
|
max="100"
|
|
152
|
-
value="${Math.round((this.#
|
|
152
|
+
value="${Math.round((this.#K.opacity??1)*100)}"
|
|
153
153
|
units="%"
|
|
154
154
|
${Q?"disabled":""}>
|
|
155
155
|
</fig-input-number>
|
|
156
|
-
</fig-tooltip>`;break;case"video":
|
|
156
|
+
</fig-tooltip>`;break;case"video":q=`
|
|
157
157
|
<label class="fig-input-fill-label">Video</label>
|
|
158
158
|
<fig-tooltip text="Opacity">
|
|
159
159
|
<fig-input-number
|
|
@@ -161,11 +161,11 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
161
161
|
placeholder="##"
|
|
162
162
|
min="0"
|
|
163
163
|
max="100"
|
|
164
|
-
value="${Math.round((this.#
|
|
164
|
+
value="${Math.round((this.#X.opacity??1)*100)}"
|
|
165
165
|
units="%"
|
|
166
166
|
${Q?"disabled":""}>
|
|
167
167
|
</fig-input-number>
|
|
168
|
-
</fig-tooltip>`;break;case"webcam":
|
|
168
|
+
</fig-tooltip>`;break;case"webcam":q=`
|
|
169
169
|
<label class="fig-input-fill-label">Webcam</label>
|
|
170
170
|
<fig-tooltip text="Opacity">
|
|
171
171
|
<fig-input-number
|
|
@@ -173,12 +173,13 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
173
173
|
placeholder="##"
|
|
174
174
|
min="0"
|
|
175
175
|
max="100"
|
|
176
|
-
value="${Math.round((this.#
|
|
176
|
+
value="${Math.round((this.#q.opacity??1)*100)}"
|
|
177
177
|
units="%"
|
|
178
178
|
${Q?"disabled":""}>
|
|
179
179
|
</fig-input-number>
|
|
180
|
-
</fig-tooltip>`;break}$.insertAdjacentHTML("beforeend",K),requestAnimationFrame(()=>{this.#$=this.querySelector(".fig-input-fill-opacity"),this.#Z=this.querySelector(".fig-input-fill-hex");const q=this.querySelector(".fig-input-fill-label");if(q&&this.#J)q.addEventListener("click",()=>{const X=this.#J.querySelector("fig-chit");if(X)X.click()});if(this.#Z)this.#Z.addEventListener("input",(X)=>{X.stopPropagation();const W="#"+X.target.value.replace("#","");this.#q.color=W,this.#M(),this.#B()}),this.#Z.addEventListener("change",(X)=>{X.stopPropagation(),this.#R()});if(this.#$)this.#$.addEventListener("input",(X)=>{X.stopPropagation();const W=parseFloat(X.target.value),Y=isNaN(W)?100:W,U=Y/100;switch(this.#Q){case"solid":this.#q.alpha=U;break;case"gradient":this.#K.stops.forEach((L)=>{L.opacity=Y});break;case"image":this.#_.opacity=U;break;case"video":this.#W.opacity=U;break;case"webcam":this.#j.opacity=U;break}this.#M(),this.#N(U),this.#B()}),this.#$.addEventListener("change",(X)=>{X.stopPropagation(),this.#R()})})}#M(){if(this.#J)this.#J.setAttribute("value",JSON.stringify(this.value))}#N(Q){if(this.#J){const $=this.#J.querySelector("fig-chit");if($)$.setAttribute("alpha",Q)}}#B(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#Q){case"solid":return{type:"solid",color:this.#q.color,alpha:this.#q.alpha,opacity:Math.round(this.#q.alpha*100)};case"gradient":return{type:"gradient",gradient:u(this.#K)};case"image":return{type:"image",image:{...this.#_}};case"video":return{type:"video",video:{...this.#W}};case"webcam":return{type:"webcam",webcam:{...this.#j}};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,$,J){if($===J)return;switch(Q){case"value":const Z=this.#Q;if(this.#X(),this.#J)if(this.#Q!==Z)this.#G();else this.#M(),this.#O();break;case"disabled":if(this.#J)this.#G();break;case"mode":case"experimental":if(this.#J)if(J)this.#J.setAttribute(Q,J);else this.#J.removeAttribute(Q);break}}}customElements.define("fig-input-fill",O0);class M0 extends HTMLElement{#Q;#J={type:"linear",angle:180,interpolationSpace:"oklab",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled","experimental","picker-anchor"]}connectedCallback(){this.#$(),this.#q()}#$(){const Q=this.getAttribute("value");if(!Q)return;try{const $=JSON.parse(Q);if($?.type==="gradient"&&$.gradient){this.#J=S({...this.#J,...$.gradient});return}if($?.gradient)this.#J=S({...this.#J,...$.gradient})}catch($){}}#Z(){const Q={},$=this.getAttribute("experimental");if($)Q.experimental=$;for(let{name:J,value:Z}of this.attributes)if(J.startsWith("picker-")&&J!=="picker-anchor")Q[J.slice(7)]=Z;if(!Q["dialog-position"])Q["dialog-position"]="left";return Object.entries(Q).map(([J,Z])=>`${J}="${Z}"`).join(" ")}#q(){const Q=this.hasAttribute("disabled"),$=JSON.stringify(this.value),J=this.#Z();this.innerHTML=`
|
|
181
|
-
<fig-
|
|
180
|
+
</fig-tooltip>`;break}$.insertAdjacentHTML("beforeend",q),requestAnimationFrame(()=>{this.#J=this.querySelector(".fig-input-fill-opacity"),this.#j=this.querySelector(".fig-input-fill-hex");const K=this.querySelector(".fig-input-fill-label");if(K&&this.#Q)K.addEventListener("click",()=>{const X=this.#Q.querySelector("fig-chit");if(X)X.click()});if(this.#j)this.#j.addEventListener("input",(X)=>{X.stopPropagation();const Y="#"+X.target.value.replace("#","");this.#_.color=Y,this.#G(),this.#z()}),this.#j.addEventListener("change",(X)=>{X.stopPropagation(),this.#R()});if(this.#J)this.#J.addEventListener("input",(X)=>{X.stopPropagation();const Y=parseFloat(X.target.value),W=isNaN(Y)?100:Y,U=W/100;switch(this.#$){case"solid":this.#_.alpha=U;break;case"gradient":this.#Z.stops.forEach((L)=>{L.opacity=W});break;case"image":this.#K.opacity=U;break;case"video":this.#X.opacity=U;break;case"webcam":this.#q.opacity=U;break}this.#G(),this.#B(U),this.#z()}),this.#J.addEventListener("change",(X)=>{X.stopPropagation(),this.#R()})})}#G(){if(this.#Q)this.#Q.setAttribute("value",JSON.stringify(this.value))}#B(Q){if(this.#Q){const $=this.#Q.querySelector("fig-chit");if($)$.setAttribute("alpha",Q)}}#z(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#R(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){switch(this.#$){case"solid":return{type:"solid",color:this.#_.color,alpha:this.#_.alpha,opacity:Math.round(this.#_.alpha*100)};case"gradient":return{type:"gradient",gradient:o(this.#Z)};case"image":return{type:"image",image:{...this.#K}};case"video":return{type:"video",video:{...this.#X}};case"webcam":return{type:"webcam",webcam:{...this.#q}};default:return{type:this.#$}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":const Z=this.#$;if(this.#W(),this.#Q)if(this.#$!==Z)this.#U();else this.#G(),this.#L();break;case"disabled":this.#N();break;case"mode":case"experimental":if(this.#Q)if(J)this.#Q.setAttribute(Q,J);else this.#Q.removeAttribute(Q);break}}}customElements.define("fig-input-fill",E0);class D0 extends HTMLElement{#$=[];#Q=[];#J=[];#j=null;static get observedAttributes(){return["value","disabled","min","max","expanded","add"]}get#_(){return this.hasAttribute("expanded")&&this.getAttribute("expanded")!=="false"}get#Z(){return!this.hasAttribute("add")||this.getAttribute("add")!=="false"}get#K(){const Q=parseInt(this.getAttribute("min"));return isNaN(Q)?2:Q}get#X(){const Q=parseInt(this.getAttribute("max"));return isNaN(Q)?8:Q}connectedCallback(){if(this.#j)cancelAnimationFrame(this.#j);this.#j=requestAnimationFrame(()=>{this.#j=null,this.#q(),this.#W()})}disconnectedCallback(){if(this.#j)cancelAnimationFrame(this.#j),this.#j=null;this.#Q=[],this.#J=[]}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#q(),this.#L();break;case"disabled":this.#O();break;case"min":case"max":case"expanded":case"add":this.#W();break}}#q(){const Q=this.getAttribute("value");if(!Q){this.#$=[];return}const $=Q.trim();try{const J=JSON.parse($);if(Array.isArray(J)){this.#$=J.map((Z)=>{if(typeof Z==="string")return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1};if(Z&&typeof Z==="object")return{color:Z.color||"#D9D9D9",alpha:Z.alpha!==void 0?Z.alpha:Z.opacity!==void 0?Z.opacity/100:1};return{color:"#D9D9D9",alpha:1}});return}}catch(J){}if($.includes(",")){this.#$=$.split(",").map((J)=>{const Z=J.trim();return{color:Z.slice(0,7),alpha:Z.length>7?parseInt(Z.slice(7,9),16)/255:1}});return}if($.startsWith("#")){this.#$=[{color:$.slice(0,7),alpha:$.length>7?parseInt($.slice(7,9),16)/255:1}];return}this.#$=[]}get value(){return this.#$.map((Q)=>({...Q}))}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}#W(){const Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";this.innerHTML="",this.#Q=[],this.#J=[];const $=document.createElement("div");$.className="palette-colors-inline";const J=document.createElement("div");if(J.className="palette-colors",this.#$.forEach((j,_)=>{J.appendChild(this.#Y(j,_,Q,{inline:!0}))}),$.appendChild(J),this.#Z)this.#N(Q,$);this.appendChild($);const Z=document.createElement("div");Z.className="palette-colors-expanded",this.#$.forEach((j,_)=>{Z.appendChild(this.#Y(j,_,Q))}),this.appendChild(Z)}#Y(Q,$,J,{inline:Z=!1}={}){const j=Q.alpha<1?Q.color+Math.round(Q.alpha*255).toString(16).padStart(2,"0"):Q.color,_=document.createElement("fig-input-color");if(_.setAttribute("value",j),_.setAttribute("picker","figma"),_.setAttribute("picker-anchor","self"),Z)_.setAttribute("text","false"),_.setAttribute("alpha","true");else _.setAttribute("text","true"),_.setAttribute("alpha","true"),_.setAttribute("full","");if(J)_.setAttribute("disabled","");const q=Z?this.#J:this.#Q,K=(X)=>{X.stopPropagation();const Y=X.currentTarget;this.#$[$]={color:Y.hexOpaque||this.#$[$].color,alpha:Y.rgba?Y.rgba.a:this.#$[$].alpha};const W=q[$];if(W){const U=this.#$[$],L=U.alpha<1?U.color+Math.round(U.alpha*255).toString(16).padStart(2,"0"):U.color;W.setAttribute("value",L)}};if(_.addEventListener("input",(X)=>{K(X),this.#G()}),_.addEventListener("change",(X)=>{K(X),this.#B()}),Z)this.#Q.push(_);else this.#J.push(_);return _}#N(Q,$=this){const J=this.#$.length>=this.#X,Z=document.createElement("fig-button");if(Z.setAttribute("variant","ghost"),Z.setAttribute("icon","true"),Z.setAttribute("aria-label","Add color"),Z.className="palette-add-btn",Q||J)Z.setAttribute("disabled","");Z.innerHTML='<span class="fig-mask-icon" style="--icon: var(--icon-add)"></span>',Z.addEventListener("click",()=>{if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;if(this.#$.length>=this.#X)return;this.#U({color:"#D9D9D9",alpha:1})});const j=document.createElement("fig-tooltip");j.setAttribute("text","Add color"),j.appendChild(Z),$.appendChild(j)}#U(Q){this.#$.push(Q);const $=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false",J=this.#$.length-1,Z=this.#Y(Q,J,$,{inline:!0}),j=this.querySelector(".palette-colors");if(j)j.appendChild(Z);const _=this.#Y(Q,J,$),q=this.querySelector(".palette-colors-expanded");if(q)q.appendChild(_);if(this.#$.length>=this.#X){const K=this.querySelector(".palette-add-btn");if(K)K.setAttribute("disabled","")}this.#B()}#M(Q){const $=this.#$[Q];if(!$)return;const J=$.alpha<1?$.color+Math.round($.alpha*255).toString(16).padStart(2,"0"):$.color,Z=this.#Q[Q];if(Z)Z.setAttribute("value",J);const j=this.#J[Q];if(j)j.setAttribute("value",J)}#L(){if(this.#Q.length!==this.#$.length){this.#W();return}this.#$.forEach((Q,$)=>{this.#M($)})}#O(){const Q=this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false";[...this.#Q,...this.#J].forEach((J)=>{if(Q)J.setAttribute("disabled","");else J.removeAttribute("disabled")});const $=this.querySelector(".palette-add-btn");if($)if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}#G(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#B(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}}customElements.define("fig-input-palette",D0);class g extends HTMLElement{static SHIFT_SNAP=5;#$;#Q;#J=!1;#j=null;#_=null;#Z={type:"linear",angle:180,interpolationSpace:"oklab",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};constructor(){super()}static get observedAttributes(){return["value","disabled"]}connectedCallback(){this.#X(),this.#N(),document.addEventListener("keydown",this.#K)}disconnectedCallback(){if(document.removeEventListener("keydown",this.#K),this.#_)this.#_.disconnect(),this.#_=null;clearTimeout(this.#j),this.removeEventListener("pointerenter",this.#G),this.removeEventListener("pointermove",this.#z),this.removeEventListener("pointerleave",this.#B),this.removeEventListener("click",this.#D),this.removeEventListener("dblclick",this.#F)}#K=(Q)=>{const $=document.activeElement,J=$&&($.tagName==="INPUT"||$.tagName==="TEXTAREA"||$.isContentEditable);if(!this.#Q)return;if(Q.key==="Tab"&&!J){const _=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!_)return;Q.preventDefault();const q=[...this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")],K=q.indexOf(_),X=Q.shiftKey?(K-1+q.length)%q.length:(K+1)%q.length;_.deselect(),q[X].select();return}if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&!J){const _=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!_)return;const q=parseInt(_.dataset.stopIndex,10);if(isNaN(q)||!this.#Z.stops[q])return;Q.preventDefault();const K=(Q.key==="ArrowRight"?1:-1)*(Q.shiftKey?g.SHIFT_SNAP:1),X=this.#Z.stops[q];X.position=Math.max(0,Math.min(100,X.position+K)),_.setAttribute("value",`${X.position}% 50%`);const Y=_.closest("fig-tooltip");if(Y)Y.text=`${Math.round(X.position)}%`,Y.setAttribute("show","true"),Y.showPopup(),_.hideColorTip(),clearTimeout(this.#j),this.#j=setTimeout(()=>{Y.removeAttribute("show"),_.showColorTip()},600);this.#T(),this.#E(),this.#P();return}if(Q.key!=="Delete"&&Q.key!=="Backspace")return;if(J)return;if(this.#Z.stops.length<=2)return;const Z=this.#Q.querySelector("fig-handle[selected]:not(.fig-input-gradient-ghost)");if(!Z)return;const j=parseInt(Z.dataset.stopIndex,10);if(isNaN(j)||!this.#Z.stops[j])return;Q.preventDefault(),Z.removeAttribute("selected"),this.#Z.stops.splice(j,1),this.#k(),this.#T(),this.#E(),this.#P()};#X(){const Q=this.getAttribute("value");if(!Q)return;try{const $=JSON.parse(Q);if($?.type==="gradient"&&$.gradient){this.#Z=y({...this.#Z,...$.gradient});return}if($?.gradient)this.#Z=y({...this.#Z,...$.gradient})}catch($){}}#q(){const $=[...this.#Z.stops].sort((J,Z)=>J.position-Z.position).map((J)=>`${J.color} ${J.position}%`).join(", ");return`linear-gradient(${this.#Z.angle}deg, ${$})`}#W(){const Q=this.hasAttribute("disabled");return this.#Z.stops.map(($,J)=>`<fig-tooltip action="manual" text="${Math.round($.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color" color="${$.color}" value="${$.position}% 50%" data-stop-index="${J}"${Q?" disabled":""}></fig-handle></fig-tooltip>`).join("")}#Y=null;#N(){const Q=this.hasAttribute("disabled");this.innerHTML=`
|
|
181
|
+
<fig-chit size="medium" background="${this.#q()}"${Q?" disabled":""}></fig-chit>
|
|
182
|
+
<div class="fig-input-gradient-track">${this.#W()}</div>`,this.#$=this.querySelector("fig-chit"),this.#Q=this.querySelector(".fig-input-gradient-track"),this.#M(),this.#C()}#U(Q){const{ctx:$}=r(256,1);$.clearRect(0,0,256,1);const J=$.createLinearGradient(0,0,256,0);for(let K of this.#Z.stops)try{J.addColorStop(K.position/100,K.color)}catch{}$.fillStyle=J,$.fillRect(0,0,256,1);const Z=Math.round(Math.max(0,Math.min(255,Q*255))),[j,_,q]=$.getImageData(Z,0,1,1).data;return`#${j.toString(16).padStart(2,"0")}${_.toString(16).padStart(2,"0")}${q.toString(16).padStart(2,"0")}`.toUpperCase()}#M(){if(!this.#Q||this.hasAttribute("disabled"))return;const Q=document.createElement("fig-handle");Q.classList.add("fig-input-gradient-ghost"),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",Q.style.overflow="visible";const $=document.createElement("fig-color-tip");$.setAttribute("control","add"),$.style.position="absolute",$.style.bottom="calc(100% + 6px)",$.style.left="50%",$.style.transform="translateX(-50%)",$.style.zIndex="10",Q.appendChild($),this.#Q.appendChild(Q),this.#Y=Q,this.addEventListener("pointerenter",this.#G),this.addEventListener("pointermove",this.#z),this.addEventListener("pointerleave",this.#B),this.addEventListener("click",this.#D),this.addEventListener("dblclick",this.#F)}#L(){if(!this.#Y)return;this.#Y.style.opacity="1"}#O(){if(!this.#Y)return;this.#Y.style.opacity="0"}#G=()=>{if(this.#J)return;this.#L()};#B=()=>{this.#O()};#z=(Q)=>{if(this.#J){this.#O();return}if(!this.#Y||!this.#Q)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){this.#O();return}const $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width));this.#Y.style.left=`${J*100}%`;const Z=this.#U(J);this.#Y.setAttribute("color",Z),this.#L()};#R(){const Q=this.#Z.stops.length;if(Q<2)return;for(let $=0;$<Q;$++)this.#Z.stops[$].position=Math.round($/(Q-1)*100);this.#k(),this.#T(),this.#E(),this.#P()}#F=(Q)=>{if(!this.#Q)return;if(!Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;this.#R(),this.#Q.querySelectorAll("fig-handle[selected]").forEach(($)=>{$.removeAttribute("selected")})};#D=(Q)=>{if(!this.#Q)return;if(this.#J)return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)")){if(Q.shiftKey){const q=Q.target.closest("fig-handle"),K=parseInt(q?.dataset.stopIndex,10);if(this.#R(),!isNaN(K))this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((X)=>{if(parseInt(X.dataset.stopIndex,10)===K)X.select();else X.deselect()});Q.stopPropagation()}return}const $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#U(J);this.#Z.stops.push({position:Z,color:j,opacity:100}),this.#Z.stops.sort((q,K)=>q.position-K.position);const _=this.#Z.stops.findIndex((q)=>q.position===Z&&q.color===j);this.#k(),this.#T(),this.#E(),this.#P(),requestAnimationFrame(()=>{const K=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[_];if(K)K.click()})};#k(){if(!this.#Q)return;const Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#Z.stops;if(Q.length!==$.length){const J=this.#Y;if(this.#Q.innerHTML=this.#W(),J)this.#Q.appendChild(J);this.#H();return}for(let J=0;J<$.length;J++){const Z=Q[J],j=$[J];Z.dataset.stopIndex=J,Z.setAttribute("value",`${j.position}% 50%`),Z.setAttribute("color",j.color);const _=Z.closest("fig-tooltip");if(_)_.setAttribute("text",`${Math.round(j.position)}%`)}}#H(){if(!this.#_||!this.#Q)return;this.#_.disconnect(),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#_.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#A(){if(!this.#Q)return;const Q=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)"),$=this.#Z.stops,J=new Set;Q.forEach((Z)=>{const j=Math.round(parseFloat(Z.getAttribute("value"))||0),_=(Z.getAttribute("color")||"").toUpperCase();let q=-1;for(let K=0;K<$.length;K++){if(J.has(K))continue;if($[K].position===j&&$[K].color.toUpperCase()===_){q=K;break}}if(q===-1){let K=1/0;for(let X=0;X<$.length;X++){if(J.has(X))continue;const Y=Math.abs($[X].position-j);if(Y<K)K=Y,q=X}}if(q!==-1)J.add(q),Z.dataset.stopIndex=q})}#T(){if(!this.#$)return;this.#$.setAttribute("background",this.#q())}#C(){if(!this.#Q)return;this.#Q.addEventListener("pointerdown",(Q)=>{if(this.hasAttribute("disabled"))return;if(Q.target.closest("fig-handle:not(.fig-input-gradient-ghost)"))return;if(Q.button!==0)return;Q.preventDefault();const $=this.#Q.getBoundingClientRect(),J=Math.max(0,Math.min(1,(Q.clientX-$.left)/$.width)),Z=Math.round(J*100),j=this.#U(J);this.#Z.stops.push({position:Z,color:j,opacity:100}),this.#Z.stops.sort((X,Y)=>X.position-Y.position);const _=this.#Z.stops.findIndex((X)=>X.position===Z&&X.color===j);this.#k(),this.#T(),this.#E(),this.#O();const K=this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)")[_];if(K)K.select(),K.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)=>{const $=Q.target.closest("fig-handle");if(!$)return;if(Q.stopPropagation(),!this.#J)$.style.zIndex="5";this.#J=!0;const J=parseInt($.dataset.stopIndex,10);if(isNaN(J)||!this.#Z.stops[J])return;const Z=Q.detail?.px??0,j=Math.round(Z*100);let _=j;const q=this.#Q.getBoundingClientRect().width;if(Q.detail?.shiftKey)_=Math.round(_/g.SHIFT_SNAP)*g.SHIFT_SNAP;else{const X=q>0?5/q*100:0;for(let Y=0;Y<this.#Z.stops.length;Y++){if(Y===J)continue;if(Math.abs(this.#Z.stops[Y].position-_)<=X){_=this.#Z.stops[Y].position;break}}}if(this.#Z.stops[J].position=_,_!==j)$.style.left=`${_/100*q-$.offsetWidth/2}px`;const K=$.closest("fig-tooltip");if(K){if(K.text=`${Math.round(_)}%`,!K.hasAttribute("show"))K.setAttribute("show","true"),$.hideColorTip()}this.#T(),this.#E()}),this.#Q.addEventListener("change",(Q)=>{const $=Q.target.closest("fig-handle");if(!$)return;Q.stopPropagation(),$.style.zIndex="";const J=$.closest("fig-tooltip");if(J)J.removeAttribute("show");$.showColorTip();const Z=parseInt($.dataset.stopIndex,10);if(isNaN(Z)||!this.#Z.stops[Z])return;const j=Q.detail?.px??0;let _=Math.round(j*100);const q=this.#Q.getBoundingClientRect().width,K=q>0?5/q*100:0;for(let X=0;X<this.#Z.stops.length;X++){if(X===Z)continue;if(Math.abs(this.#Z.stops[X].position-_)<=K){_=this.#Z.stops[X].position;break}}this.#Z.stops[Z].position=_,$.style.left=`${_/100*q-$.offsetWidth/2}px`,this.#Z.stops.sort((X,Y)=>X.position-Y.position),this.#A(),this.#T(),this.#P(),requestAnimationFrame(()=>{this.#J=!1})}),this.#_=new MutationObserver((Q)=>{for(let $ of Q){if($.attributeName!=="color")continue;const J=$.target;if(J.classList.contains("fig-input-gradient-ghost"))continue;const Z=parseInt(J.dataset.stopIndex,10);if(isNaN(Z)||!this.#Z.stops[Z])continue;const j=J.getAttribute("color");if(j&&j!==this.#Z.stops[Z].color)this.#Z.stops[Z].color=j,this.#T(),this.#E()}}),this.#Q.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((Q)=>{this.#_.observe(Q,{attributes:!0,attributeFilter:["color"]})})}#E(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#P(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){return{type:"gradient",gradient:o(this.#Z)}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":this.#X(),this.#T(),this.#k();break;case"disabled":this.#S();break}}#S(){const Q=this.hasAttribute("disabled");if(this.#$)if(Q)this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled");if(this.#Q)for(let $ of this.#Q.querySelectorAll("fig-handle"))if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}}customElements.define("fig-input-gradient",g);class u extends HTMLElement{#$=null;#Q;constructor(){super();this.input=document.createElement("input"),this.name=this.getAttribute("name")||"checkbox",this.input.value=this.getAttribute("value")||"",this.input.setAttribute("id",v()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","checkbox"),this.input.setAttribute("role","checkbox"),this.#Q=this.handleInput.bind(this)}connectedCallback(){const Q=this.querySelector(":scope > input");if(Q)this.input=Q;else if(!this.input.parentNode)this.append(this.input);if(this.input.checked=this.hasAttribute("checked")&&this.getAttribute("checked")!=="false",this.input.removeEventListener("change",this.#Q),this.input.addEventListener("change",this.#Q),this.hasAttribute("disabled"))this.input.disabled=!0;if(this.hasAttribute("indeterminate"))this.input.indeterminate=!0,this.input.setAttribute("indeterminate","true");const $=this.querySelector(":scope > label");if($)this.#$=$,this.#$.setAttribute("for",this.input.id);if(this.hasAttribute("label"))this.#J(),this.#$.innerText=this.getAttribute("label");this.render()}static get observedAttributes(){return["disabled","label","checked","name","value","indeterminate"]}#J(){if(!this.#$)this.#$=document.createElement("label"),this.#$.setAttribute("for",this.input.id);if(this.#$&&!this.#$.parentNode&&this.input.parentNode)this.input.after(this.#$)}render(){}focus(){this.input.focus()}get value(){return this.input.value}set value(Q){this.input.value=Q,this.setAttribute("value",Q)}get checked(){return this.input.checked}set checked(Q){if(this.input.checked=Q,Q)this.setAttribute("checked","");else this.removeAttribute("checked")}disconnectedCallback(){this.input.removeEventListener("change",this.#Q),this.input.remove()}attributeChangedCallback(Q,$,J){switch(Q){case"label":if(J)this.#J(),this.#$.innerText=J;else if(this.#$)this.#$.remove(),this.#$=null;break;case"checked":if(this.input.checked=this.hasAttribute("checked")&&this.getAttribute("checked")!=="false",this.input.checked&&this.hasAttribute("indeterminate"))this.removeAttribute("indeterminate");if(this.input.indeterminate=this.hasAttribute("indeterminate")&&this.getAttribute("indeterminate")!=="false"&&!this.input.checked,this.input.indeterminate)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");break;case"indeterminate":if(this.input.indeterminate=this.hasAttribute("indeterminate")&&this.getAttribute("indeterminate")!=="false"&&!this.input.checked,this.input.indeterminate)this.input.setAttribute("indeterminate","true");else this.input.removeAttribute("indeterminate");break;case"value":this.input.value=J;break;default:this.input[Q]=J,this.input.setAttribute(Q,J);break}}handleInput(Q){if(Q.stopPropagation(),this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.input.setAttribute("aria-checked",this.input.checked),this.input.checked)this.setAttribute("checked","");else this.removeAttribute("checked");this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{checked:this.input.checked,value:this.input.value}}))}}customElements.define("fig-checkbox",u);class T0 extends u{constructor(){super();this.input.setAttribute("type","radio"),this.input.setAttribute("name",this.getAttribute("name")||"radio")}}customElements.define("fig-radio",T0);class P0 extends u{render(){this.input.setAttribute("class","switch"),this.input.setAttribute("role","switch")}}customElements.define("fig-switch",P0);class k0 extends HTMLDialogElement{_defaultOffset=16;_autoCloseTimer=null;#$;constructor(){super();this.#$=this.handleClose.bind(this)}getOffset(){return parseInt(this.getAttribute("offset")??this._defaultOffset)}connectedCallback(){if(typeof this._defaultOffset!=="number")this._defaultOffset=16;if(typeof this._autoCloseTimer==="undefined")this._autoCloseTimer=null;if(!this.hasAttribute("theme"))this.setAttribute("theme","dark");const Q=this.getAttribute("open")==="true"||this.getAttribute("open")==="";if(this.hasAttribute("open")&&!Q)this.removeAttribute("open");if(!Q)this.close();requestAnimationFrame(()=>{if(this.addCloseListeners(),this.applyPosition(),Q)this.showToast()})}disconnectedCallback(){this.clearAutoClose()}addCloseListeners(){this.querySelectorAll("[close-toast]").forEach((Q)=>{Q.removeEventListener("click",this.#$),Q.addEventListener("click",this.#$)})}handleClose(){this.hideToast()}applyPosition(){this.style.position="fixed",this.style.margin="0",this.style.top="auto",this.style.bottom=`${this.getOffset()}px`,this.style.left="50%",this.style.right="auto",this.style.transform="translateX(-50%)"}startAutoClose(){this.clearAutoClose();const 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}#Q(){if(this.getAttribute("theme")!=="auto")return;const $=(getComputedStyle(document.documentElement).colorScheme||"").includes("dark");this.style.colorScheme=$?"light":"dark"}showToast(){this.#Q(),this.show(),this.applyPosition(),this.startAutoClose(),this.dispatchEvent(new CustomEvent("toast-show",{bubbles:!0}))}hideToast(){this.clearAutoClose(),this.close(),this.dispatchEvent(new CustomEvent("toast-hide",{bubbles:!0}))}static get observedAttributes(){return["duration","offset","open","theme"]}attributeChangedCallback(Q,$,J){if(Q==="offset")this.applyPosition();if(Q==="open")if(J!==null&&J!=="false")this.showToast();else this.hideToast();if(Q==="theme")if(J==="auto")this.#Q();else this.style.removeProperty("color-scheme")}}i("fig-toast",k0,{extends:"dialog"});class H0 extends HTMLElement{#$=!1;#Q=null;constructor(){super();this.#Q=this.handleSelectInput.bind(this)}getOptionsFromAttribute(){return(this.getAttribute("options")||"").split(",")}connectedCallback(){const Q=Array.from(this.children).find((j)=>j.tagName==="FIG-DROPDOWN")||null;if(this.#$=Q!==null,Q)Q.remove();this.options=this.getOptionsFromAttribute(),this.placeholder=this.getAttribute("placeholder")||"",this.value=this.getAttribute("value")||"";const $=this.getAttribute("experimental"),J=$?`experimental="${$}"`:"",Z=this.#$?"":`<fig-dropdown type="dropdown" ${J}>
|
|
182
183
|
${this.options.map((j)=>`<option>${j}</option>`).join("")}
|
|
183
184
|
</fig-dropdown>`;this.innerHTML=`<div class="input-combo">
|
|
184
185
|
<fig-input-text placeholder="${this.placeholder}">
|
|
@@ -189,19 +190,19 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
189
190
|
</svg>
|
|
190
191
|
${Z}
|
|
191
192
|
</fig-button>
|
|
192
|
-
</div>`,requestAnimationFrame(()=>{this.input=this.querySelector("fig-input-text");const j=this.querySelector("fig-button");if(this
|
|
193
|
+
</div>`,requestAnimationFrame(()=>{this.input=this.querySelector("fig-input-text");const j=this.querySelector("fig-button");if(this.#$&&Q&&j){if(!Q.hasAttribute("type"))Q.setAttribute("type","dropdown");if($)Q.setAttribute("experimental",$);j.append(Q)}if(this.dropdown=this.querySelector("fig-dropdown"),this.dropdown?.removeEventListener("input",this.#Q),this.dropdown?.addEventListener("input",this.#Q),this.input)this.input.setAttribute("value",this.value);if(this.hasAttribute("disabled"))this.#J(!0)})}disconnectedCallback(){this.dropdown?.removeEventListener("input",this.#Q)}handleSelectInput(Q){this.setAttribute("value",Q.target.closest("fig-dropdown").value)}handleInput(Q){this.value=this.input.value}static get observedAttributes(){return["options","placeholder","value","disabled","experimental"]}focus(){this.input.focus()}#J(Q){if(this.input)if(Q)this.input.setAttribute("disabled","");else this.input.removeAttribute("disabled");const $=this.querySelector("fig-button");if($)if(Q)$.setAttribute("disabled","");else $.removeAttribute("disabled")}attributeChangedCallback(Q,$,J){switch(Q){case"options":if(this.options=J.split(","),this.dropdown&&!this.#$)this.dropdown.innerHTML=this.options.map((Z)=>`<option>${Z}</option>`).join("");break;case"placeholder":if(this.placeholder=J,this.input)this.input.setAttribute("placeholder",J);break;case"value":if(this.value=J,this.input)this.input.setAttribute("value",J);break;case"disabled":this.#J(J!==null&&J!=="false");break;case"experimental":if(this.dropdown){if(J)this.dropdown.setAttribute("experimental",J);else if(!this.#$)this.dropdown.removeAttribute("experimental")}break}}}customElements.define("fig-combo-input",H0);class S0 extends HTMLElement{#$="color";#Q=null;#J=!1;constructor(){super();this.#Q=this.#q.bind(this)}static get observedAttributes(){return["background","size","selected","disabled","alpha"]}connectedCallback(){this.#X(),this.#j()}#j(){const Q=this.getAttribute("alpha");if(Q!==null)this.style.setProperty("--alpha",Q);else this.style.removeProperty("--alpha")}#_(Q){if(!Q)return"color";const $=Q.toLowerCase();if($.includes("gradient"))return"gradient";if($.includes("url("))return"image";return"color"}#Z(Q){if(!Q)return"#D9D9D9";if(Q.startsWith("#"))return Q.slice(0,7);try{const{ctx:$}=r(1,1);return $.fillStyle=Q,$.fillStyle}catch{return"#D9D9D9"}}#K(Q){if(!Q||!Q.includes("var("))return Q;const $=this.style.background;this.style.background=Q;const J=getComputedStyle(this),Z=J.backgroundImage,j=J.backgroundColor;if(this.style.background=$,Z&&Z!=="none")return Z;return j||Q}#X(){const Q=this.getAttribute("background")||"#D9D9D9",$=Q.includes("var("),J=$?this.#K(Q):Q,Z=this.#_(J);if(Z!==this.#$||!this.input){if(this.#$=Z,this.setAttribute("data-type",this.#$),this.input)this.input.removeEventListener("input",this.#Q);if(this.#$==="color"){const j=this.#Z(J);if(this.innerHTML=`<input type="color" value="${j}" />`,this.input=this.querySelector("input"),!$)this.input.addEventListener("input",this.#Q)}else this.innerHTML="",this.input=null}else if(this.#$==="color"&&this.input){const j=this.#Z(J);if(this.input.value!==j)this.input.value=j}this.style.setProperty("--chit-background",Q)}#q(Q){this.#J=!0,this.setAttribute("background",Q.target.value),this.#J=!1}get background(){return this.getAttribute("background")}set background(Q){this.setAttribute("background",Q)}focus(){this.input?.focus()}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="background"){if(this.#J){this.style.setProperty("--chit-background",J);return}this.#X()}else if(Q==="alpha")this.#j()}get alpha(){return this.getAttribute("alpha")}set alpha(Q){if(Q===null||Q===void 0)this.removeAttribute("alpha");else this.setAttribute("alpha",Q)}}customElements.define("fig-chit",S0);class C0 extends HTMLElement{#$=null;#Q=this.#X.bind(this);#J=this.#Z.bind(this);constructor(){super()}#j(){const Q=this.hasAttribute("checkerboard")&&this.getAttribute("checkerboard")!=="false";return`<fig-chit size="large" data-type="image" background="${this.src?`url(${this.src})`:Q?"url()":"var(--figma-color-bg-secondary)"}" disabled${Q?" checkerboard":""}></fig-chit><div>${this.upload?`<fig-button variant="overlay" type="upload">
|
|
193
194
|
${this.label}
|
|
194
195
|
<input type="file" accept="image/*" />
|
|
195
196
|
</fig-button>`:""} ${this.download?`<fig-button variant="overlay" icon="true" type="download">
|
|
196
197
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
197
198
|
<path d="M17.5 13C17.7761 13 18 13.2239 18 13.5V16.5C18 17.3284 17.3284 18 16.5 18H7.5C6.67157 18 6 17.3284 6 16.5V13.5C6 13.2239 6.22386 13 6.5 13C6.77614 13 7 13.2239 7 13.5V16.5C7 16.7761 7.22386 17 7.5 17H16.5C16.7761 17 17 16.7761 17 16.5V13.5C17 13.2239 17.2239 13 17.5 13ZM12 6C12.2761 6 12.5 6.22386 12.5 6.5V12.293L14.6465 10.1465C14.8417 9.95122 15.1583 9.95122 15.3535 10.1465C15.5488 10.3417 15.5488 10.6583 15.3535 10.8535L12.3535 13.8535C12.2597 13.9473 12.1326 14 12 14C11.9006 14 11.8042 13.9704 11.7227 13.916L11.6465 13.8535L8.64648 10.8535C8.45122 10.6583 8.45122 10.3417 8.64648 10.1465C8.84175 9.95122 9.15825 9.95122 9.35352 10.1465L11.5 12.293V6.5C11.5 6.22386 11.7239 6 12 6Z" fill="black"/>
|
|
198
|
-
</svg></fig-button>`:""}</div>`}connectedCallback(){this
|
|
199
|
+
</svg></fig-button>`:""}</div>`}connectedCallback(){this.#$=this.getAttribute("src")||"",this.upload=this.hasAttribute("upload")&&this.getAttribute("upload")!=="false",this.download=this.hasAttribute("download")&&this.getAttribute("download")!=="false",this.label=this.getAttribute("label")||"Upload",this.size=this.getAttribute("size")||"small",this.innerHTML=this.#j(),this.#_();const Q=this.getAttribute("aspect-ratio");if(Q&&Q!=="auto")this.style.setProperty("--aspect-ratio",Q);const $=this.getAttribute("fit");if($)this.style.setProperty("--fit",$)}disconnectedCallback(){this.fileInput?.removeEventListener("change",this.#Q),this.downloadButton?.removeEventListener("click",this.#J)}#_(){requestAnimationFrame(()=>{if(this.chit=this.querySelector("fig-chit"),this.upload)this.uploadButton=this.querySelector("fig-button[type='upload']"),this.fileInput=this.uploadButton?.querySelector("input"),this.fileInput?.removeEventListener("change",this.#Q),this.fileInput?.addEventListener("change",this.#Q);if(this.download)this.downloadButton=this.querySelector("fig-button[type='download']"),this.downloadButton?.removeEventListener("click",this.#J),this.downloadButton?.addEventListener("click",this.#J)})}#Z(){const Q=document.createElement("a");Q.href=this.blob,Q.download="image.png",Q.click()}async#K(Q){await new Promise(($)=>{this.image=new Image,this.image.crossOrigin="Anonymous",this.image.onload=async()=>{this.aspectRatio=this.image.width/this.image.height;const J=this.getAttribute("aspect-ratio");if(!J||J==="auto")this.style.setProperty("--aspect-ratio",`${this.image.width}/${this.image.height}`);this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{blob:this.blob,base64:this.base64}})),$();const Z=document.createElement("canvas"),j=Z.getContext("2d");Z.width=this.image.width,Z.height=this.image.height,j.drawImage(this.image,0,0),this.base64=Z.toDataURL(),Z.toBlob((_)=>{if(this.blob)URL.revokeObjectURL(this.blob);if(_)this.blob=URL.createObjectURL(_)})},this.image.src=Q})}async#X(Q){if(this.blob)URL.revokeObjectURL(this.blob);this.blob=URL.createObjectURL(Q.target.files[0]);const $=new FileReader;$.readAsDataURL(Q.target.files[0]),await new Promise((J)=>{$.onload=(Z)=>{this.base64=Z.target.result,J()}}),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,cancelable:!0,detail:{blob:this.blob,base64:this.base64}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),this.setAttribute("src",this.blob)}static get observedAttributes(){return["src","upload","download","aspect-ratio","fit","checkerboard"]}get src(){return this.#$}set src(Q){this.#$=Q,this.setAttribute("src",Q)}attributeChangedCallback(Q,$,J){if(Q==="src"){if(this.#$=J,this.chit){const Z=this.hasAttribute("checkerboard")&&this.getAttribute("checkerboard")!=="false";if(this.#$)this.chit.setAttribute("background",`url(${this.#$})`);else this.chit.setAttribute("background",Z?"url()":"var(--figma-color-bg-secondary)")}if(this.#$)this.#K(this.#$)}if(Q==="upload")this.upload=J!==null&&J!=="false",this.innerHTML=this.#j(),this.#_();if(Q==="download")this.download=J!==null&&J!=="false",this.innerHTML=this.#j(),this.#_();if(Q==="size")this.size=J;if(Q==="aspect-ratio"){if(J&&J!=="auto")this.style.setProperty("--aspect-ratio",J);else if(!J)this.style.removeProperty("--aspect-ratio")}if(Q==="fit")if(J)this.style.setProperty("--fit",J);else this.style.removeProperty("--fit");if(Q==="checkerboard"){if(this.chit)if(J!==null&&J!=="false")this.chit.setAttribute("checkerboard","");else this.chit.removeAttribute("checkerboard")}}}customElements.define("fig-image",C0);class I extends HTMLElement{#$={x:0.42,y:0};#Q={x:0.58,y:1};#J={stiffness:200,damping:15,mass:1};#j="bezier";#_=2;#Z=null;#K=null;#X=null;#q=null;#W=null;#Y=null;#N=null;#U=null;#M=null;#L=null;#O=null;#G=null;#B=0.8;#z=200;#R=200;#F=null;#D=null;#k=null;#H=5;#A=2;#T=10;#C=10;#E=3;static PRESETS=[{group:null,name:"Linear",type:"bezier",value:[0,0,1,1]},{group:"Bezier",name:"Ease in",type:"bezier",value:[0.42,0,1,1]},{group:"Bezier",name:"Ease out",type:"bezier",value:[0,0,0.58,1]},{group:"Bezier",name:"Ease in and out",type:"bezier",value:[0.42,0,0.58,1]},{group:"Bezier",name:"Ease in back",type:"bezier",value:[0.6,-0.28,0.735,0.045]},{group:"Bezier",name:"Ease out back",type:"bezier",value:[0.175,0.885,0.32,1.275]},{group:"Bezier",name:"Ease in and out back",type:"bezier",value:[0.68,-0.55,0.265,1.55]},{group:"Bezier",name:"Custom bezier",type:"bezier",value:null},{group:"Spring",name:"Gentle",type:"spring",spring:{stiffness:120,damping:14,mass:1}},{group:"Spring",name:"Quick",type:"spring",spring:{stiffness:380,damping:20,mass:1}},{group:"Spring",name:"Bouncy",type:"spring",spring:{stiffness:250,damping:8,mass:1}},{group:"Spring",name:"Slow",type:"spring",spring:{stiffness:60,damping:11,mass:1}},{group:"Spring",name:"Custom spring",type:"spring",spring:null}];static get observedAttributes(){return["value","precision","aspect-ratio"]}connectedCallback(){this.#_=parseInt(this.getAttribute("precision")||"2"),C(this,"--aspect-ratio",this.getAttribute("aspect-ratio"));const Q=this.getAttribute("value");if(Q)this.#P(Q);this.#O=this.#S(),this.#I(),this.#j0()}disconnectedCallback(){if(this.#Z=null,this.#k)this.#k.disconnect(),this.#k=null}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){if(C(this,"--aspect-ratio",J),this.#K)this.#r(),this.#w();return}if(!this.#K)return;if(Q==="value"&&J){const Z=this.#j;if(this.#P(J),this.#O=this.#S(),Z!==this.#j)this.#I();else this.#w(),this.#a()}if(Q==="precision")this.#_=parseInt(J||"2")}get value(){if(this.#j==="spring"){const{stiffness:$,damping:J,mass:Z}=this.#J;return`spring(${$}, ${J}, ${Z})`}const Q=this.#_;return`${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)}`}get cssValue(){if(this.#j==="spring"){const $=this.#b(),Z=Math.max(1,Math.floor($.length/20)),j=[];for(let _=0;_<$.length;_+=Z)j.push($[_].value.toFixed(3));if($.length>0)j.push($[$.length-1].value.toFixed(3));return`linear(${j.join(", ")})`}const Q=this.#_;return`cubic-bezier(${this.#$.x.toFixed(Q)}, ${this.#$.y.toFixed(Q)}, ${this.#Q.x.toFixed(Q)}, ${this.#Q.y.toFixed(Q)})`}get preset(){return this.#O}set value(Q){this.setAttribute("value",Q)}#P(Q){const $=Q.match(/^spring\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);if($){this.#j="spring",this.#J.stiffness=parseFloat($[1]),this.#J.damping=parseFloat($[2]),this.#J.mass=parseFloat($[3]);return}const J=Q.split(",").map((Z)=>parseFloat(Z.trim()));if(J.length>=4&&J.every((Z)=>!isNaN(Z)))this.#j="bezier",this.#$.x=J[0],this.#$.y=J[1],this.#Q.x=J[2],this.#Q.y=J[3]}#S(){if(this.#j==="bezier"){for(let $ of I.PRESETS){if($.type!=="bezier"||!$.value)continue;if(Math.abs(this.#$.x-$.value[0])<0.001&&Math.abs(this.#$.y-$.value[1])<0.001&&Math.abs(this.#Q.x-$.value[2])<0.001&&Math.abs(this.#Q.y-$.value[3])<0.001)return $.name}return"Custom bezier"}for(let $ of I.PRESETS){if($.type!=="spring"||!$.spring)continue;if(Math.abs(this.#J.stiffness-$.spring.stiffness)<0.001&&Math.abs(this.#J.damping-$.spring.damping)<0.001&&Math.abs(this.#J.mass-$.spring.mass)<0.001)return $.name}return"Custom spring"}#b(){const{stiffness:Q,damping:$,mass:J}=this.#J,_=[];let q=0,K=0;for(let X=0;X<=5;X+=0.004){const Y=-Q*(q-1)-$*K;if(K+=Y/J*0.004,q+=K*0.004,_.push({t:X,value:q}),X>0.1&&Math.abs(q-1)<0.0005&&Math.abs(K)<0.0005)break}return _}static#y(Q,$=24){const{stiffness:J,damping:Z,mass:j}=Q,K=[];let X=0,Y=0;for(let F=0;F<=5;F+=0.004){const R=-J*(X-1)-Z*Y;if(Y+=R/j*0.004,X+=Y*0.004,K.push({t:F,value:X}),F>0.1&&Math.abs(X-1)<0.001&&Math.abs(Y)<0.001)break}const W=K[K.length-1].t||1;let U=1;for(let F of K)if(F.value>U)U=F.value;let L=0;for(let F of K)if(F.value<L)L=F.value;const z=Math.max(U-L,1),M=6,G=$-M*2,B=Math.max(1,Math.floor(K.length/30));let A="";for(let F=0;F<K.length;F+=B){const R=M+K[F].t/W*G,T=M+(1-(K[F].value-L)/z)*G;A+=(F===0?"M":"L")+R.toFixed(1)+","+T.toFixed(1)}return`<svg width="${$}" height="${$}" viewBox="0 0 ${$} ${$}" fill="none"><path d="${A}" stroke="currentColor" stroke-width="1" stroke-linecap="round" fill="none"/></svg>`}static curveIcon(Q,$,J,Z,j=24){const q=(j-12)/2,X=[],Y=(R,T,k,w,f)=>{const x=1-f;return x*x*x*R+3*x*x*f*T+3*x*f*f*k+f*f*f*w};for(let R=0;R<=48;R++){const T=R/48;X.push({x:Y(0,Q,J,1,T),y:Y(0,$,Z,1,T)})}let W=1/0,U=-1/0,L=1/0,z=-1/0;for(let R of X){if(R.x<W)W=R.x;if(R.x>U)U=R.x;if(R.y<L)L=R.y;if(R.y>z)z=R.y}const M=Math.max(U-W,0.000001),G=Math.max(z-L,0.000001),B=(R)=>q+(R-W)/M*12,A=(R)=>q+(1-(R-L)/G)*12;let F="";for(let R=0;R<X.length;R++){const T=B(X[R].x),k=A(X[R].y);F+=`${R===0?"M":"L"}${T.toFixed(1)},${k.toFixed(1)}`}return`<svg width="${j}" height="${j}" viewBox="0 0 ${j} ${j}" fill="none"><path d="${F}" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>`}#I(){this.classList.toggle("spring-mode",this.#j==="spring"),this.classList.toggle("bezier-mode",this.#j!=="spring"),this.#l(),this.innerHTML=this.#s(),this.#Z0(),this.#p(),this.#r(),this.#w(),this.#q0()}#v(){if(this.getAttribute("dropdown")!=="true")return"";let Q="",$=void 0;for(let J of I.PRESETS){if(J.group!==$){if($!==void 0)Q+="</optgroup>";if(J.group)Q+=`<optgroup label="${J.group}">`;$=J.group}let Z;if(J.type==="spring"){const _=J.spring||this.#J;Z=I.#y(_)}else{const _=J.value||[this.#$.x,this.#$.y,this.#Q.x,this.#Q.y];Z=I.curveIcon(..._)}const j=J.name===this.#O?" selected":"";Q+=`<option value="${J.name}"${j}>${Z} ${J.name}</option>`}if($)Q+="</optgroup>";return`<fig-dropdown class="fig-easing-curve-dropdown" full experimental="modern">${Q}</fig-dropdown>`}#s(){const $=this.#v();if(this.#j==="spring")return`${$}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
|
|
199
200
|
<rect class="fig-easing-curve-bounds" x="0" y="0" width="200" height="200"/>
|
|
200
201
|
<line class="fig-easing-curve-target" x1="0" y1="40" x2="200" y2="40"/>
|
|
201
202
|
<line class="fig-easing-curve-diagonal" x1="0" y1="180" x2="0" y2="180"/>
|
|
202
203
|
<path class="fig-easing-curve-path"/>
|
|
203
|
-
<foreignObject class="fig-easing-curve-handle" data-handle="bounce" width="
|
|
204
|
-
<foreignObject class="fig-easing-curve-handle fig-easing-curve-duration-bar" data-handle="duration" width="
|
|
204
|
+
<foreignObject class="fig-easing-curve-handle" data-handle="bounce" width="20" height="20"><fig-handle size="small"></fig-handle></foreignObject>
|
|
205
|
+
<foreignObject class="fig-easing-curve-handle fig-easing-curve-duration-bar" data-handle="duration" width="20" height="20"><fig-handle size="small"></fig-handle></foreignObject>
|
|
205
206
|
</svg></div>`;return`${$}<div class="fig-easing-curve-svg-container"><svg viewBox="0 0 200 200" class="fig-easing-curve-svg">
|
|
206
207
|
<rect class="fig-easing-curve-bounds" x="0" y="0" width="200" height="200"/>
|
|
207
208
|
<line class="fig-easing-curve-diagonal" x1="0" y1="200" x2="200" y2="0"/>
|
|
@@ -210,9 +211,9 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
210
211
|
<path class="fig-easing-curve-path"/>
|
|
211
212
|
<circle class="fig-easing-curve-endpoint" data-endpoint="start" r="${this.#A}"/>
|
|
212
213
|
<circle class="fig-easing-curve-endpoint" data-endpoint="end" r="${this.#A}"/>
|
|
213
|
-
<foreignObject class="fig-easing-curve-handle" data-handle="1" width="
|
|
214
|
-
<foreignObject class="fig-easing-curve-handle" data-handle="2" width="
|
|
215
|
-
</svg></div>`}#V(Q,$){const J=getComputedStyle(this).getPropertyValue(Q).trim();if(!J)return $;const Z=Number.parseFloat(J);return Number.isFinite(Z)?Z:$}#j0(){this.#z=this.#V("--easing-bezier-handle-radius",this.#z),this.#A=this.#V("--easing-bezier-endpoint-radius",this.#A),this.#f=this.#V("--easing-spring-handle-radius",this.#f),this.#T=this.#V("--easing-duration-bar-width",this.#T),this.#H=this.#V("--easing-duration-bar-height",this.#H),this.#P=this.#V("--easing-duration-bar-radius",this.#P)}#v(){this.#_=this.querySelector(".fig-easing-curve-svg"),this.#W=this.querySelector(".fig-easing-curve-path"),this.#j=this.querySelector('[data-arm="1"]'),this.#X=this.querySelector('[data-arm="2"]'),this.#Y=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#G=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#U=this.querySelector('[data-endpoint="start"]'),this.#O=this.querySelector('[data-endpoint="end"]'),this.#L=this.querySelector(".fig-easing-curve-dropdown"),this.#N=this.querySelector(".fig-easing-curve-target"),this.#E=this.querySelector(".fig-easing-curve-bounds"),this.#k=this.querySelector(".fig-easing-curve-diagonal")}#h(){if(this.#F||!window.ResizeObserver)return;this.#F=new ResizeObserver(()=>{if(this.#o())this.#w()}),this.#F.observe(this)}#o(){if(!this.#_)return!1;const Q=this.#_.getBoundingClientRect(),$=Math.max(1,Math.round(Q.width||200)),J=Math.max(1,Math.round(Q.height||200)),Z=$!==this.#R||J!==this.#D;return this.#R=$,this.#D=J,this.#_.setAttribute("viewBox",`0 0 ${$} ${J}`),Z}#s(Q,$){return{x:Q*this.#R,y:(1-$)*this.#D}}#Z0(Q,$){return{x:Q/this.#R,y:1-$/this.#D}}#l={minVal:0,maxVal:1.2,totalTime:1};#g(Q,$){const Z=this.#D-40,{minVal:j,maxVal:_}=this.#l,K=_-j||1;return{x:Q*this.#R,y:20+(1-($-j)/K)*Z}}#w(){if(this.#o(),this.#Z==="spring")this.#e();else this.#t()}#t(){if(this.#E)this.#E.setAttribute("x","0"),this.#E.setAttribute("y","0"),this.#E.setAttribute("width",this.#R),this.#E.setAttribute("height",this.#D);if(this.#k)this.#k.setAttribute("x1","0"),this.#k.setAttribute("y1",this.#D),this.#k.setAttribute("x2",this.#R),this.#k.setAttribute("y2","0");const Q=this.#s(0,0),$=this.#s(this.#Q.x,this.#Q.y),J=this.#s(this.#J.x,this.#J.y),Z=this.#s(1,1);this.#W.setAttribute("d",`M${Q.x},${Q.y} C${$.x},${$.y} ${J.x},${J.y} ${Z.x},${Z.y}`),this.#j.setAttribute("x1",Q.x),this.#j.setAttribute("y1",Q.y),this.#j.setAttribute("x2",$.x),this.#j.setAttribute("y2",$.y),this.#X.setAttribute("x1",Z.x),this.#X.setAttribute("y1",Z.y),this.#X.setAttribute("x2",J.x),this.#X.setAttribute("y2",J.y);const j=this.#z;if(this.#Y.setAttribute("x",$.x-j),this.#Y.setAttribute("y",$.y-j),this.#G.setAttribute("x",J.x-j),this.#G.setAttribute("y",J.y-j),this.#U)this.#U.setAttribute("cx",Q.x),this.#U.setAttribute("cy",Q.y);if(this.#O)this.#O.setAttribute("cx",Z.x),this.#O.setAttribute("cy",Z.y)}#e(){if(this.#E)this.#E.setAttribute("x","0"),this.#E.setAttribute("y","0"),this.#E.setAttribute("width",this.#R),this.#E.setAttribute("height",this.#D);const Q=this.#c();if(!Q.length)return;const $=Q[Q.length-1].t||1;let J=0,Z=1;for(let B of Q){if(B.value<J)J=B.value;if(B.value>Z)Z=B.value}const j=Math.max(Math.abs(J-1),Math.abs(Z-1),0.01),_=0;this.#l={minVal:1-j-_,maxVal:1+j+_,totalTime:$};const K=Math.max(0.05,Math.min(0.95,this.#B));let q="";for(let B=0;B<Q.length;B++){const O=Q[B].t/$*K,H=this.#g(O,Q[B].value);q+=(B===0?"M":"L")+H.x.toFixed(1)+","+H.y.toFixed(1)}const X=this.#g(K,1),W=this.#g(1,1);if(q+=`L${X.x.toFixed(1)},${X.y.toFixed(1)} L${W.x.toFixed(1)},${W.y.toFixed(1)}`,this.#W.setAttribute("d",q),this.#N){const B=this.#g(0,1),O=this.#g(1,1);this.#N.setAttribute("x1",B.x),this.#N.setAttribute("y1",B.y),this.#N.setAttribute("x2",O.x),this.#N.setAttribute("y2",O.y)}const Y=this.#_0(Q),U=Y.t/$*K,L=this.#g(U,Y.value),F=this.#z;this.#Y.setAttribute("x",L.x-F),this.#Y.setAttribute("y",L.y-F);const N=this.#g(K,1);this.#G.setAttribute("x",N.x-this.#T/2),this.#G.setAttribute("y",N.y-this.#H/2)}#_0(Q){let $={t:0,value:1},J=!1;for(let Z of Q){if(Z.value>=0.99)J=!0;if(J&&Z.value>$.value)$={t:Z.t,value:Z.value}}return $}#Q0(){if(!this.#L)return;this.#L.value=this.#M,this.#K0()}#n(Q,$,J){if(!Q)return;for(let Z of Q.querySelectorAll("option"))if(Z.value===$)Z.innerHTML=`${J} ${$}`}#K0(){if(!this.#L)return;const Q=I.curveIcon(this.#Q.x,this.#Q.y,this.#J.x,this.#J.y),$=I.#p(this.#$);this.#n(this.#L,"Custom bezier",Q),this.#n(this.#L,"Custom spring",$),this.#n(this.#L.select,"Custom bezier",Q),this.#n(this.#L.select,"Custom spring",$)}#m(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#Z,value:this.value,cssValue:this.cssValue,preset:this.#M}}))}#i(){if(this.#Z==="bezier"){this.#Y.addEventListener("pointerdown",($)=>this.#$0($,1)),this.#G.addEventListener("pointerdown",($)=>this.#$0($,2));const Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#$0($,this.#a($))})}else{this.#Y.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#J0($,"bounce")}),this.#G.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#J0($,"duration")});const Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#J0($,"duration")})}if(this.#L)this.#L.addEventListener("change",(Q)=>{const $=Q.detail,J=I.PRESETS.find((Z)=>Z.name===$);if(!J)return;if(J.type==="bezier"){if(J.value)this.#Q.x=J.value[0],this.#Q.y=J.value[1],this.#J.x=J.value[2],this.#J.y=J.value[3];if(this.#M=$,this.#Z!=="bezier")this.#Z="bezier",this.#u();else this.#w()}else if(J.type==="spring"){if(J.spring)this.#$={...J.spring};if(this.#M=$,this.#Z!=="spring")this.#Z="spring",this.#u();else this.#w()}this.#m("input"),this.#m("change")})}#b(Q){const $=this.#_.getScreenCTM();if(!$)return{x:0,y:0};const J=$.inverse();return{x:J.a*Q.clientX+J.c*Q.clientY+J.e,y:J.b*Q.clientX+J.d*Q.clientY+J.f}}#a(Q){return this.#b(Q).x<=this.#R/2?1:2}#$0(Q,$){Q.preventDefault(),this.#K=$;const J=(j)=>{if(!this.#K)return;const _=this.#b(j),K=this.#Z0(_.x,_.y);if(K.x=Math.round(K.x*100)/100,K.y=Math.round(K.y*100)/100,K.x=Math.max(0,Math.min(1,K.x)),this.#K===1)this.#Q.x=K.x,this.#Q.y=K.y;else this.#J.x=K.x,this.#J.y=K.y;this.#w(),this.#M=this.#y(),this.#Q0(),this.#m("input")},Z=()=>{this.#K=null,document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",Z),this.#m("change")};document.addEventListener("pointermove",J),document.addEventListener("pointerup",Z)}#J0(Q,$){Q.preventDefault(),this.#K=$;const J=this.#$.damping,Z=this.#$.stiffness,j=this.#B,_=Q.clientY,K=Q.clientX,q=(W)=>{if(!this.#K)return;if($==="bounce"){const Y=W.clientY-_;this.#$.damping=Math.max(1,Math.round(J+Y*0.15))}else{const Y=W.clientX-K;this.#B=Math.max(0.05,Math.min(0.95,j+Y/200)),this.#$.stiffness=Math.max(10,Math.round(Z-Y*1.5))}this.#w(),this.#M=this.#y(),this.#Q0(),this.#m("input")},X=()=>{this.#K=null,document.removeEventListener("pointermove",q),document.removeEventListener("pointerup",X),this.#m("change")};document.addEventListener("pointermove",q),document.addEventListener("pointerup",X)}}customElements.define("fig-easing-curve",I);class k0 extends HTMLElement{#Q=0;#J=0;#$=0;#Z=1;#q=!1;#K=!1;#_=null;#W=null;#j=null;#X=null;#Y=[];#G={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#Z=parseInt(this.getAttribute("precision")||"1"),this.#U(this.getAttribute("aspect-ratio")),this.#O(this.getAttribute("perspective")),this.#L("--perspective-origin",this.getAttribute("perspective-origin")),this.#M(this.getAttribute("transform-origin")),this.#R(this.getAttribute("fields"));const Q=this.getAttribute("value");if(Q)this.#D(Q);this.#E(),this.#B(this.getAttribute("selected")),this.#N()}disconnectedCallback(){if(this.#q=!1,this.#j)window.removeEventListener("keydown",this.#j),window.removeEventListener("keyup",this.#X)}#U(Q){if(Q&&Q.trim())this.style.setProperty("--aspect-ratio",Q.trim());else this.style.removeProperty("--aspect-ratio")}#O(Q){if(Q&&Q.trim())this.style.setProperty("--perspective",Q.trim());else this.style.removeProperty("--perspective")}#L(Q,$){if($&&$.trim())this.style.setProperty(Q,$.trim());else this.style.removeProperty(Q)}#M(Q){if(!Q||!Q.trim()){this.style.removeProperty("--transform-origin");return}const $=Q.trim().split(/\s+/);if($.length===2)this.style.setProperty("--transform-origin",`${$[0]} ${$[1]} -50cqi`);else this.style.setProperty("--transform-origin",Q.trim())}#N(){if(!this.#W)return;this.#W.style.cursor=this.#T?"":"default"}#B(Q){if(!this.#_)return;const $=this.#_.querySelectorAll(".fig-3d-rotate-face"),J=Q?Q.trim().toLowerCase():"";for(let Z of $)Z.classList.toggle("selected",J!==""&&Z.classList.contains(J))}#R(Q){if(!Q||!Q.trim()){this.#Y=[];return}const $=["rotateX","rotateY","rotateZ"];this.#Y=Q.split(",").map((J)=>J.trim()).filter((J)=>$.includes(J))}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){this.#U(J);return}if(Q==="perspective"){this.#O(J);return}if(Q==="perspective-origin"){this.#L("--perspective-origin",J);return}if(Q==="transform-origin"){this.#M(J);return}if(Q==="selected"){this.#B(J);return}if(Q==="drag"){this.#N();return}if(Q==="fields"){if(this.#R(J),this.#_)this.#E();return}if(!this.#_)return;if(Q==="value"&&J){if(this.#q)return;this.#D(J),this.#F(),this.#k()}if(Q==="precision")this.#Z=parseInt(J||"1")}get value(){const Q=this.#Z;return`rotateX(${this.#Q.toFixed(Q)}deg) rotateY(${this.#J.toFixed(Q)}deg) rotateZ(${this.#$.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#Q}get rotateY(){return this.#J}get rotateZ(){return this.#$}#D(Q){const $=Q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),J=Q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),Z=Q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if($)this.#Q=parseFloat($[1]);if(J)this.#J=parseFloat(J[1]);if(Z)this.#$=parseFloat(Z[1])}#E(){const Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},$={rotateX:this.#Q,rotateY:this.#J,rotateZ:this.#$},J=this.#Y.map((Z)=>`<fig-input-number
|
|
214
|
+
<foreignObject class="fig-easing-curve-handle" data-handle="1" width="20" height="20"><fig-handle size="small"></fig-handle></foreignObject>
|
|
215
|
+
<foreignObject class="fig-easing-curve-handle" data-handle="2" width="20" height="20"><fig-handle size="small"></fig-handle></foreignObject>
|
|
216
|
+
</svg></div>`}#d(Q,$){const J=getComputedStyle(this).getPropertyValue(Q).trim();if(!J)return $;const Z=Number.parseFloat(J);return Number.isFinite(Z)?Z:$}#l(){this.#A=this.#d("--easing-bezier-endpoint-radius",this.#A),this.#E=this.#d("--easing-duration-bar-radius",this.#E)}#Z0(){this.#K=this.querySelector(".fig-easing-curve-svg"),this.#X=this.querySelector(".fig-easing-curve-path"),this.#q=this.querySelector('[data-arm="1"]'),this.#W=this.querySelector('[data-arm="2"]'),this.#Y=this.querySelector('[data-handle="1"]')||this.querySelector('[data-handle="bounce"]'),this.#N=this.querySelector('[data-handle="2"]')||this.querySelector('[data-handle="duration"]'),this.#U=this.querySelector('[data-endpoint="start"]'),this.#M=this.querySelector('[data-endpoint="end"]'),this.#L=this.querySelector(".fig-easing-curve-dropdown"),this.#G=this.querySelector(".fig-easing-curve-target"),this.#F=this.querySelector(".fig-easing-curve-bounds"),this.#D=this.querySelector(".fig-easing-curve-diagonal")}#p(){const Q=this.#Y?.querySelector("fig-handle"),$=this.#N?.querySelector("fig-handle");if(Q){const J=Q.offsetWidth||this.#H*2,Z=Q.offsetHeight||this.#H*2;this.#H=Math.max(J,Z)/2,this.#Y.setAttribute("width",J),this.#Y.setAttribute("height",Z)}if($){const J=$.offsetWidth||this.#T,Z=$.offsetHeight||this.#C;if(this.#j==="spring")this.#T=J,this.#C=Z;this.#N.setAttribute("width",J),this.#N.setAttribute("height",Z)}}#j0(){if(this.#k||!window.ResizeObserver)return;this.#k=new ResizeObserver(()=>{if(this.#r())this.#w()}),this.#k.observe(this)}#r(){if(!this.#K)return!1;const Q=this.#K.getBoundingClientRect(),$=Math.max(1,Math.round(Q.width||200)),J=Math.max(1,Math.round(Q.height||200)),Z=$!==this.#z||J!==this.#R;return this.#z=$,this.#R=J,this.#K.setAttribute("viewBox",`0 0 ${$} ${J}`),Z}#x(Q,$){return{x:Q*this.#z,y:(1-$)*this.#R}}#h(Q,$){return{x:Q/this.#z,y:1-$/this.#R}}#e={minVal:0,maxVal:1.2,totalTime:1};#V(Q,$){const Z=this.#R-40,{minVal:j,maxVal:_}=this.#e,q=_-j||1;return{x:Q*this.#z,y:20+(1-($-j)/q)*Z}}#w(){if(this.#r(),this.#j==="spring")this.#t();else this.#Q0()}#Q0(){if(this.#F)this.#F.setAttribute("x","0"),this.#F.setAttribute("y","0"),this.#F.setAttribute("width",this.#z),this.#F.setAttribute("height",this.#R);if(this.#D)this.#D.setAttribute("x1","0"),this.#D.setAttribute("y1",this.#R),this.#D.setAttribute("x2",this.#z),this.#D.setAttribute("y2","0");const Q=this.#x(0,0),$=this.#x(this.#$.x,this.#$.y),J=this.#x(this.#Q.x,this.#Q.y),Z=this.#x(1,1);this.#X.setAttribute("d",`M${Q.x},${Q.y} C${$.x},${$.y} ${J.x},${J.y} ${Z.x},${Z.y}`),this.#q.setAttribute("x1",Q.x),this.#q.setAttribute("y1",Q.y),this.#q.setAttribute("x2",$.x),this.#q.setAttribute("y2",$.y),this.#W.setAttribute("x1",Z.x),this.#W.setAttribute("y1",Z.y),this.#W.setAttribute("x2",J.x),this.#W.setAttribute("y2",J.y);const j=this.#H;if(this.#Y.setAttribute("x",$.x-j),this.#Y.setAttribute("y",$.y-j),this.#N.setAttribute("x",J.x-j),this.#N.setAttribute("y",J.y-j),this.#U)this.#U.setAttribute("cx",Q.x),this.#U.setAttribute("cy",Q.y);if(this.#M)this.#M.setAttribute("cx",Z.x),this.#M.setAttribute("cy",Z.y)}#t(){if(this.#F)this.#F.setAttribute("x","0"),this.#F.setAttribute("y","0"),this.#F.setAttribute("width",this.#z),this.#F.setAttribute("height",this.#R);const Q=this.#b();if(!Q.length)return;const $=Q[Q.length-1].t||1;let J=0,Z=1;for(let G of Q){if(G.value<J)J=G.value;if(G.value>Z)Z=G.value}const j=Math.max(Math.abs(J-1),Math.abs(Z-1),0.01),_=0;this.#e={minVal:1-j-_,maxVal:1+j+_,totalTime:$};const q=Math.max(0.05,Math.min(0.95,this.#B));let K="";for(let G=0;G<Q.length;G++){const B=Q[G].t/$*q,A=this.#V(B,Q[G].value);K+=(G===0?"M":"L")+A.x.toFixed(1)+","+A.y.toFixed(1)}const X=this.#V(q,1),Y=this.#V(1,1);if(K+=`L${X.x.toFixed(1)},${X.y.toFixed(1)} L${Y.x.toFixed(1)},${Y.y.toFixed(1)}`,this.#X.setAttribute("d",K),this.#G){const G=this.#V(0,1),B=this.#V(1,1);this.#G.setAttribute("x1",G.x),this.#G.setAttribute("y1",G.y),this.#G.setAttribute("x2",B.x),this.#G.setAttribute("y2",B.y)}const W=this.#_0(Q),U=W.t/$*q,L=this.#V(U,W.value),z=this.#H;this.#Y.setAttribute("x",L.x-z),this.#Y.setAttribute("y",L.y-z);const M=this.#V(q,1);this.#N.setAttribute("x",M.x-this.#T/2),this.#N.setAttribute("y",M.y-this.#C/2)}#_0(Q){let $={t:0,value:1},J=!1;for(let Z of Q){if(Z.value>=0.99)J=!0;if(J&&Z.value>$.value)$={t:Z.t,value:Z.value}}return $}#a(){if(!this.#L)return;this.#L.value=this.#O,this.#n()}#g(Q,$,J){if(!Q)return;for(let Z of Q.querySelectorAll("option"))if(Z.value===$)Z.innerHTML=`${J} ${$}`}#n(){if(!this.#L)return;const Q=I.curveIcon(this.#$.x,this.#$.y,this.#Q.x,this.#Q.y),$=I.#y(this.#J);this.#g(this.#L,"Custom bezier",Q),this.#g(this.#L,"Custom spring",$),this.#g(this.#L.select,"Custom bezier",Q),this.#g(this.#L.select,"Custom spring",$)}#c(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{mode:this.#j,value:this.value,cssValue:this.cssValue,preset:this.#O}}))}#q0(){if(this.#j==="bezier"){this.#Y.addEventListener("pointerdown",($)=>this.#o($,1)),this.#N.addEventListener("pointerdown",($)=>this.#o($,2));const Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#o($,this.#K0($))})}else{this.#Y.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#m($,"bounce")}),this.#N.addEventListener("pointerdown",($)=>{$.stopPropagation(),this.#m($,"duration")});const Q=this.querySelector(".fig-easing-curve-svg-container");if(Q)Q.addEventListener("pointerdown",($)=>{if($.target?.closest?.(".fig-easing-curve-handle, fig-handle"))return;this.#m($,"duration")})}if(this.#L)this.#L.addEventListener("change",(Q)=>{const $=Q.detail,J=I.PRESETS.find((Z)=>Z.name===$);if(!J)return;if(J.type==="bezier"){if(J.value)this.#$.x=J.value[0],this.#$.y=J.value[1],this.#Q.x=J.value[2],this.#Q.y=J.value[3];if(this.#O=$,this.#j!=="bezier")this.#j="bezier",this.#I();else this.#w()}else if(J.type==="spring"){if(J.spring)this.#J={...J.spring};if(this.#O=$,this.#j!=="spring")this.#j="spring",this.#I();else this.#w()}this.#c("input"),this.#c("change")})}#$0(Q){const $=this.#K.getScreenCTM();if(!$)return{x:0,y:0};const J=$.inverse();return{x:J.a*Q.clientX+J.c*Q.clientY+J.e,y:J.b*Q.clientX+J.d*Q.clientY+J.f}}#K0(Q){return this.#$0(Q).x<=this.#z/2?1:2}#o(Q,$){Q.preventDefault(),this.#Z=$;const J=(j)=>{if(!this.#Z)return;const _=this.#$0(j),q=this.#h(_.x,_.y);if(q.x=Math.round(q.x*100)/100,q.y=Math.round(q.y*100)/100,q.x=Math.max(0,Math.min(1,q.x)),this.#Z===1)this.#$.x=q.x,this.#$.y=q.y;else this.#Q.x=q.x,this.#Q.y=q.y;this.#w(),this.#O=this.#S(),this.#a(),this.#c("input")},Z=()=>{this.#Z=null,document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",Z),this.#c("change")};document.addEventListener("pointermove",J),document.addEventListener("pointerup",Z)}#m(Q,$){Q.preventDefault(),this.#Z=$;const J=this.#J.damping,Z=this.#J.stiffness,j=this.#B,_=Q.clientY,q=Q.clientX,K=(Y)=>{if(!this.#Z)return;if($==="bounce"){const W=Y.clientY-_;this.#J.damping=Math.max(1,Math.round(J+W*0.15))}else{const W=Y.clientX-q;this.#B=Math.max(0.05,Math.min(0.95,j+W/200)),this.#J.stiffness=Math.max(10,Math.round(Z-W*1.5))}this.#w(),this.#O=this.#S(),this.#a(),this.#c("input")},X=()=>{this.#Z=null,document.removeEventListener("pointermove",K),document.removeEventListener("pointerup",X),this.#c("change")};document.addEventListener("pointermove",K),document.addEventListener("pointerup",X)}}customElements.define("fig-easing-curve",I);class f0 extends HTMLElement{#$=0;#Q=0;#J=0;#j=1;#_=!1;#Z=!1;#K=null;#X=null;#q=null;#W=null;#Y=[];#N={};static get observedAttributes(){return["value","precision","aspect-ratio","fields","perspective","perspective-origin","transform-origin","selected","drag"]}connectedCallback(){this.#j=parseInt(this.getAttribute("precision")||"1"),C(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),C(this,"--perspective",this.getAttribute("perspective")),C(this,"--perspective-origin",this.getAttribute("perspective-origin")),this.#U(this.getAttribute("transform-origin")),this.#O(this.getAttribute("fields"));const Q=this.getAttribute("value");if(Q)this.#G(Q);this.#B(),this.#L(this.getAttribute("selected")),this.#M()}disconnectedCallback(){if(this.#_=!1,this.#q)window.removeEventListener("keydown",this.#q),window.removeEventListener("keyup",this.#W)}#U(Q){if(!Q||!Q.trim()){this.style.removeProperty("--transform-origin");return}const $=Q.trim().split(/\s+/);if($.length===2)this.style.setProperty("--transform-origin",`${$[0]} ${$[1]} -50cqi`);else this.style.setProperty("--transform-origin",Q.trim())}#M(){if(!this.#X)return;this.#X.style.cursor=this.#H?"":"default"}#L(Q){if(!this.#K)return;const $=this.#K.querySelectorAll(".fig-3d-rotate-face"),J=Q?Q.trim().toLowerCase():"";for(let Z of $)Z.classList.toggle("selected",J!==""&&Z.classList.contains(J))}#O(Q){if(!Q||!Q.trim()){this.#Y=[];return}const $=["rotateX","rotateY","rotateZ"];this.#Y=Q.split(",").map((J)=>J.trim()).filter((J)=>$.includes(J))}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){C(this,"--aspect-ratio",J);return}if(Q==="perspective"){C(this,"--perspective",J);return}if(Q==="perspective-origin"){C(this,"--perspective-origin",J);return}if(Q==="transform-origin"){this.#U(J);return}if(Q==="selected"){this.#L(J);return}if(Q==="drag"){this.#M();return}if(Q==="fields"){if(this.#O(J),this.#K)this.#B();return}if(!this.#K)return;if(Q==="value"&&J){if(this.#_)return;this.#G(J),this.#R(),this.#z()}if(Q==="precision")this.#j=parseInt(J||"1")}get value(){const Q=this.#j;return`rotateX(${this.#$.toFixed(Q)}deg) rotateY(${this.#Q.toFixed(Q)}deg) rotateZ(${this.#J.toFixed(Q)}deg)`}set value(Q){this.setAttribute("value",Q)}get rotateX(){return this.#$}get rotateY(){return this.#Q}get rotateZ(){return this.#J}#G(Q){const $=Q.match(/rotateX\(\s*(-?[\d.]+)\s*deg\s*\)/),J=Q.match(/rotateY\(\s*(-?[\d.]+)\s*deg\s*\)/),Z=Q.match(/rotateZ\(\s*(-?[\d.]+)\s*deg\s*\)/);if($)this.#$=parseFloat($[1]);if(J)this.#Q=parseFloat(J[1]);if(Z)this.#J=parseFloat(Z[1])}#B(){const Q={rotateX:"X",rotateY:"Y",rotateZ:"Z"},$={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J},J=this.#Y.map((Z)=>`<fig-input-number
|
|
216
217
|
name="${Z}"
|
|
217
218
|
step="1"
|
|
218
219
|
precision="1"
|
|
@@ -230,9 +231,9 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
230
231
|
<div class="fig-3d-rotate-face bottom"></div>
|
|
231
232
|
</div>
|
|
232
233
|
</div>
|
|
233
|
-
</div>${J}`,this.#
|
|
234
|
+
</div>${J}`,this.#X=this.querySelector(".fig-3d-rotate-container"),this.#K=this.querySelector(".fig-3d-rotate-cube"),this.#N={};for(let Z of this.#Y){const j=this.querySelector(`fig-input-number[name="${Z}"]`);if(j){this.#N[Z]=j;const _=(q)=>{q.stopPropagation();const K=parseFloat(q.target.value);if(isNaN(K))return;if(Z==="rotateX")this.#$=K;else if(Z==="rotateY")this.#Q=K;else if(Z==="rotateZ")this.#J=K;this.#R(),this.#F(q.type)};j.addEventListener("input",_),j.addEventListener("change",_)}}this.#R(),this.#k()}#z(){const Q={rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J};for(let $ of this.#Y){const J=this.#N[$];if(J)J.setAttribute("value",Q[$].toFixed(this.#j))}}#R(){if(!this.#K)return;this.#K.style.transform=`rotateX(${this.#$}deg) rotateY(${this.#Q}deg) rotateZ(${this.#J}deg)`}#F(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,rotateX:this.#$,rotateY:this.#Q,rotateZ:this.#J}}))}#D(Q){if(!this.#Z)return Q;return Math.round(Q/15)*15}#k(){this.#X.addEventListener("pointerdown",(Q)=>this.#A(Q)),this.#q=(Q)=>{if(Q.key==="Shift")this.#Z=!0},this.#W=(Q)=>{if(Q.key==="Shift")this.#Z=!1},window.addEventListener("keydown",this.#q),window.addEventListener("keyup",this.#W)}get#H(){const Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}#A(Q){if(!this.#H)return;Q.preventDefault(),this.#_=!0,this.#X.classList.add("dragging"),this.#X.setPointerCapture(Q.pointerId);const{clientX:$,clientY:J}=Q,Z=this.#$,j=this.#Q,_=(K)=>{if(!this.#_)return;if(K.buttons===0){q();return}const X=K.clientX-$,Y=K.clientY-J;this.#Q=this.#D(j+X*0.5),this.#$=this.#D(Z-Y*0.5),this.#R(),this.#z(),this.setAttribute("value",this.value),this.#F("input")},q=()=>{if(!this.#_)return;this.setAttribute("value",this.value),this.#_=!1,this.#X.classList.remove("dragging"),this.#X.removeEventListener("pointermove",_),this.#X.removeEventListener("pointerup",q),this.#X.removeEventListener("pointercancel",q),this.#X.removeEventListener("lostpointercapture",q),this.#F("change")};this.#X.addEventListener("pointermove",_),this.#X.addEventListener("pointerup",q),this.#X.addEventListener("pointercancel",q),this.#X.addEventListener("lostpointercapture",q)}}customElements.define("fig-3d-rotate",f0);class l extends HTMLElement{#$=50;#Q=50;#J=0;#j=null;#_=[];#Z=null;#K=null;#X=null;#q=!1;#W=!1;#Y=null;#N=null;#U=null;static SNAP_POINTS=[0,16.6667,33.3333,50,66.6667,83.3333,100];static get observedAttributes(){return["value","precision","aspect-ratio","drag","fields"]}connectedCallback(){this.#J=parseInt(this.getAttribute("precision")||"0"),C(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),this.#R(this.getAttribute("value")),this.#F(),this.#O(),this.#k()}disconnectedCallback(){this.#q=!1,this.#s()}get value(){const Q=this.#J;return`${this.#$.toFixed(Q)}% ${this.#Q.toFixed(Q)}%`}set value(Q){this.setAttribute("value",Q)}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){C(this,"--aspect-ratio",J);return}if(Q==="drag"){this.#O();return}if(Q==="fields"){this.#F(),this.#O(),this.#k();return}if(Q==="precision"){this.#J=parseInt(J||"0"),this.#D(),this.#k();return}if(Q==="value"){if(this.#W||this.#q)return;this.#R(J),this.#A(),this.#T(),this.#D()}}get#M(){const Q=this.getAttribute("drag");return Q===null||Q.toLowerCase()!=="false"}get#L(){const Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#O(){if(!this.#j)return;this.#j.classList.toggle("drag-disabled",!this.#M)}#G(Q){return Math.max(0,Math.min(100,Q))}#B(Q,$){const J=(Q||"").trim().toLowerCase();if(!J)return $==="x"?this.#$:this.#Q;const Z=$==="x"?{left:0,center:50,right:100}:{top:0,center:50,bottom:100};if(J in Z)return Z[J];const j=Number.parseFloat(J.replace("%",""));if(Number.isFinite(j))return j;return $==="x"?this.#$:this.#Q}#z(Q){const $=Q.trim().replace(/,/g," ").split(/\s+/).filter(Boolean);if($.length<1)return;if($.length===1){const J=this.#B($[0],"x");this.#$=J,this.#Q=J;return}this.#$=this.#B($[0],"x"),this.#Q=this.#B($[1],"y")}#R(Q){const $=typeof Q==="string"?Q.trim():"";if(!$){this.#$=50,this.#Q=50;return}this.#z($)}#F(){const Q=Array.from({length:9},(j,_)=>{const q=_%3,K=Math.floor(_/3);return`<span class="origin-grid-cell" data-col="${q}" data-row="${K}">
|
|
234
235
|
<span class="origin-grid-dot"></span>
|
|
235
|
-
</span>`}).join(""),$=this
|
|
236
|
+
</span>`}).join(""),$=this.#$.toFixed(this.#J),J=this.#Q.toFixed(this.#J),Z=this.#L?`<div class="origin-values">
|
|
236
237
|
<fig-input-number name="x" value="${$}" step="1" units="%"><span slot="prepend">X</span></fig-input-number>
|
|
237
238
|
<fig-input-number name="y" value="${J}" step="1" units="%"><span slot="prepend">Y</span></fig-input-number>
|
|
238
239
|
</div>`:"";this.innerHTML=`<div class="fig-origin-grid-surface">
|
|
@@ -241,7 +242,7 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
241
242
|
<fig-handle></fig-handle>
|
|
242
243
|
</div>
|
|
243
244
|
</div>
|
|
244
|
-
${Z}`,this.#
|
|
245
|
+
${Z}`,this.#j=this.querySelector(".origin-grid"),this.#_=Array.from(this.querySelectorAll(".origin-grid-cell")),this.#Z=this.querySelector("fig-handle"),this.#K=this.querySelector('fig-input-number[name="x"]'),this.#X=this.querySelector('fig-input-number[name="y"]'),this.#A(),this.#T(),this.#D(),this.#l()}#D(){const Q=this.#$.toFixed(this.#J),$=this.#Q.toFixed(this.#J);if(this.#K)this.#K.setAttribute("value",Q);if(this.#X)this.#X.setAttribute("value",$)}#k(){const Q=this.value;if(this.getAttribute("value")===Q)return;this.#W=!0,this.setAttribute("value",Q),this.#W=!1}#H(Q){this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,detail:{value:this.value,x:this.#$,y:this.#Q}}))}#A(){if(!this.#Z)return;const Q=($)=>16.6667+this.#G($)/100*66.6667;this.#Z.style.left=`${Q(this.#$)}%`,this.#Z.style.top=`${Q(this.#Q)}%`}#T(){if(!this.#Z)return;const Q=this.#$<0||this.#$>100,$=this.#Q<0||this.#Q>100,J=this.#$<0,Z=this.#$>100,j=this.#Q<0,_=this.#Q>100;this.#Z.classList.toggle("beyond-bounds-x",Q),this.#Z.classList.toggle("beyond-bounds-y",$),this.#Z.classList.toggle("overflow-left",J),this.#Z.classList.toggle("overflow-right",Z),this.#Z.classList.toggle("overflow-up",j),this.#Z.classList.toggle("overflow-down",_)}#C(Q,$){if(!this.#j)return null;const J=this.#j.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1),j=($-J.top)/Math.max(J.height,1);if(Z<0||Z>1||j<0||j>1)return null;const _=Math.max(0,Math.min(2,Math.floor(Z*3))),q=Math.max(0,Math.min(2,Math.floor(j*3)));return this.#_.find((K)=>Number(K.getAttribute("data-col"))===_&&Number(K.getAttribute("data-row"))===q)}#E(){for(let Q of this.#_)Q.classList.remove("is-hovered")}#P(Q){if(this.#E(),Q)Q.classList.add("is-hovered")}#S(Q,$,J){const Z=Number(Q),j=Number($);if(!Number.isFinite(Z)||!Number.isFinite(j))return;if(Z===this.#$&&j===this.#Q&&J==="input")return;this.#$=Z,this.#Q=j,this.#A(),this.#T(),this.#D(),this.#k(),this.#H(J)}#b(Q,$){if(!this.#j)return{x:this.#$,y:this.#Q};const J=this.#j.getBoundingClientRect(),Z=J.width/6,j=J.height/6,_=Math.max(1,J.width-Z*2),q=Math.max(1,J.height-j*2),K=(Q-(J.left+Z))/_,X=($-(J.top+j))/q;return{x:K*100,y:X*100}}#y(Q,$){if(!this.#j)return{x:50,y:50};const J=this.#j.getBoundingClientRect(),Z=(Q-J.left)/Math.max(J.width,1)*3,j=($-J.top)/Math.max(J.height,1)*3,_=Math.max(0,Math.min(2,Math.floor(Z))),q=Math.max(0,Math.min(2,Math.floor(j)));return{x:_*50,y:q*50}}#I(Q){let J=Q,Z=1/0;for(let j of l.SNAP_POINTS){const _=Math.abs(Q-j);if(_<Z)Z=_,J=j}return Z<=2.5?J:Q}#v(Q,$){if(!$)return Q;return{x:this.#I(Q.x),y:this.#I(Q.y)}}#s(){if(!this.#j||!this.#N||!this.#U)return;this.#j.removeEventListener("pointermove",this.#N),this.#j.removeEventListener("pointerup",this.#U),this.#j.removeEventListener("pointercancel",this.#U),this.#j.removeEventListener("lostpointercapture",this.#U),this.#N=null,this.#U=null}#d(Q){if(!this.#j||!this.#M)return;Q.preventDefault(),this.#q=!0,this.#Y=Q.pointerId;const{clientX:$,clientY:J}=Q,Z=3;let j=!1;this.#j.setPointerCapture(Q.pointerId),this.#N=(_)=>{if(!this.#q||_.pointerId!==this.#Y)return;const q=_.clientX-$,K=_.clientY-J,X=Math.hypot(q,K);if(!j&&X<Z)return;if(!j)j=!0,this.#j.classList.add("is-dragging"),this.#E();const Y=this.#v(this.#b(_.clientX,_.clientY),_.shiftKey);this.#S(Y.x,Y.y,"input")},this.#U=(_)=>{if(!this.#q||_.pointerId!==this.#Y)return;if(this.#q=!1,this.#Y=null,this.#j.classList.remove("is-dragging"),this.#E(),this.#s(),!j){const q=this.#y($,J);this.#S(q.x,q.y,"input")}this.#H("change")},this.#j.addEventListener("pointermove",this.#N),this.#j.addEventListener("pointerup",this.#U),this.#j.addEventListener("pointercancel",this.#U),this.#j.addEventListener("lostpointercapture",this.#U)}#l(){if(!this.#j||!this.#Z)return;this.#j.addEventListener("pointerdown",($)=>{const J=this.#C($.clientX,$.clientY);if(this.#P(J),this.#M){this.#d($);return}const Z=this.#y($.clientX,$.clientY);this.#S(Z.x,Z.y,"input"),this.#H("change")}),this.#j.addEventListener("pointermove",($)=>{if(this.#q)return;const J=this.#C($.clientX,$.clientY);this.#P(J)}),this.#j.addEventListener("pointerleave",()=>{this.#E()});const Q=($,J)=>{if(!$)return;const Z=(j)=>{const _=Number.parseFloat(j.target.value);if(!Number.isFinite(_))return;if(J==="x")this.#S(_,this.#Q,"input");else this.#S(this.#$,_,"input")};$.addEventListener("input",Z),$.addEventListener("change",Z),$.addEventListener("focusout",()=>{this.#H("change")})};Q(this.#K,"x"),Q(this.#X,"y")}}customElements.define("fig-origin-grid",l);class I0 extends HTMLElement{#$=null;#Q=null;#J=null;#j=null;#_=null;#Z=null;#K=null;#X=null;#q=!1;#W={x:0.5,y:0.5};#Y=!1;constructor(){super();this.position={x:0.5,y:0.5},this.isDragging=!1,this.plane=null,this.cursor=null,this.xInput=null,this.yInput=null,this.coordinates="screen",this.#$=(Q)=>this.#k(Q),this.#Q=()=>{this.isDragging=!0,this.plane?.classList.add("dragging")},this.#J=(Q)=>this.#H(Q),this.#j=()=>this.#A(),this.#_=(Q)=>this.#z(Q),this.#Z=(Q)=>this.#R(Q),this.#K=()=>this.#F(),this.#X=()=>this.#F()}connectedCallback(){requestAnimationFrame(()=>{if(this.precision=this.getAttribute("precision")||3,this.precision=parseInt(this.precision),this.transform=this.getAttribute("transform")||1,this.transform=Number(this.transform),this.coordinates=this.getAttribute("coordinates")||"screen",C(this,"--aspect-ratio",this.getAttribute("aspect-ratio")),!this.hasAttribute("value"))this.setAttribute("value","50% 50%");this.#M(),this.#G(),this.#E(),this.#P(),this.#S(),this.#Y=!0})}#N(Q){return this.coordinates==="math"?1-Q:Q}disconnectedCallback(){this.#B()}get#U(){const Q=this.getAttribute("fields");if(Q===null)return!1;return Q.toLowerCase()!=="false"}#M(){this.innerHTML=this.#O()}#L(){const Q=(this.getAttribute("axis-labels")||"").trim();if(!Q)return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1};const $=Q.split(/\s+/).filter(Boolean);if($.length===1)return{left:"",right:"",top:$[0],bottom:"",leftNoRotate:!1};if($.length===2){const[J,Z]=$;return{left:J,right:"",top:"",bottom:Z,leftNoRotate:!0}}if($.length===4){const[J,Z,j,_]=$;return{left:J,right:Z,top:j,bottom:_,leftNoRotate:!1}}return{left:"",right:"",top:"",bottom:"",leftNoRotate:!1}}#O(){const Q=this.#L();return`
|
|
245
246
|
<div class="fig-input-joystick-plane-container" tabindex="0">
|
|
246
247
|
${[Q.left?`<label class="fig-joystick-axis-label left${Q.leftNoRotate?" no-rotate":""}" aria-hidden="true">${Q.left}</label>`:"",Q.right?`<label class="fig-joystick-axis-label right" aria-hidden="true">${Q.right}</label>`:"",Q.top?`<label class="fig-joystick-axis-label top" aria-hidden="true">${Q.top}</label>`:"",Q.bottom?`<label class="fig-joystick-axis-label bottom" aria-hidden="true">${Q.bottom}</label>`:""].join("")}
|
|
247
248
|
<div class="fig-input-joystick-plane">
|
|
@@ -254,7 +255,7 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
254
255
|
</fig-button>
|
|
255
256
|
</fig-tooltip>
|
|
256
257
|
</div>
|
|
257
|
-
${this.#
|
|
258
|
+
${this.#U?`<div class="joystick-values">
|
|
258
259
|
<fig-input-number
|
|
259
260
|
name="x"
|
|
260
261
|
step="1"
|
|
@@ -274,7 +275,7 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
274
275
|
<span slot="prepend">Y</span>
|
|
275
276
|
</fig-input-number>
|
|
276
277
|
</div>`:""}
|
|
277
|
-
`}#
|
|
278
|
+
`}#G(){this.plane=this.querySelector(".fig-input-joystick-plane"),this.cursor=this.querySelector("fig-handle"),this.xInput=this.querySelector("fig-input-number[name='x']"),this.yInput=this.querySelector("fig-input-number[name='y']"),this.plane?.addEventListener("pointerdown",this.#$),this.cursor?.addEventListener("pointerdown",this.#Q),this.cursor?.addEventListener("input",this.#J),this.cursor?.addEventListener("change",this.#j);const Q=this.querySelector(".fig-joystick-reset");if(Q)Q.addEventListener("click",()=>this.#b());if(this.#U&&this.xInput&&this.yInput)this.xInput.addEventListener("input",this.#_),this.xInput.addEventListener("change",this.#_),this.xInput.addEventListener("focusout",this.#K),this.yInput.addEventListener("input",this.#Z),this.yInput.addEventListener("change",this.#Z),this.yInput.addEventListener("focusout",this.#X)}#B(){if(this.plane?.removeEventListener("pointerdown",this.#$),this.cursor?.removeEventListener("pointerdown",this.#Q),this.cursor?.removeEventListener("input",this.#J),this.cursor?.removeEventListener("change",this.#j),this.plane?.classList.remove("dragging"),this.isDragging=!1,this.#U&&this.xInput&&this.yInput)this.xInput.removeEventListener("input",this.#_),this.xInput.removeEventListener("change",this.#_),this.xInput.removeEventListener("focusout",this.#K),this.yInput.removeEventListener("input",this.#Z),this.yInput.removeEventListener("change",this.#Z),this.yInput.removeEventListener("focusout",this.#X)}#z(Q){const $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.x=Math.max(0,Math.min(1,$/100)),this.#E(),this.#P(),this.#T()}#R(Q){const $=Number.parseFloat(Q.target.value);if(!Number.isFinite($))return;this.position.y=Math.max(0,Math.min(1,$/100)),this.#E(),this.#P(),this.#T()}#F(){this.#P(),this.#C()}#D(Q,$,{syncHandle:J=!0}={}){const Z=Math.max(0,Math.min(1,Q)),j=Math.max(0,Math.min(1,$)),_=this.coordinates==="math"?1-j:j;if(this.position={x:Z,y:_},J)this.#E();this.#P()}#k(Q){if(!this.plane||!this.cursor)return;if(Q.target?.closest?.(".fig-joystick-reset, fig-tooltip, fig-handle"))return;const $=this.plane.getBoundingClientRect(),J=$.width>0?(Q.clientX-$.left)/$.width:0.5,Z=$.height>0?(Q.clientY-$.top)/$.height:0.5;this.cursor.value=`${Math.round(J*100)}% ${Math.round(Z*100)}%`,this.#D(J,Z,{syncHandle:!1}),this.#T(),this.#C()}#H(Q){const $=Q.detail??{};if(typeof $.px!=="number"||typeof $.py!=="number")return;this.#D($.px,$.py,{syncHandle:!1}),this.#T()}#A(){this.isDragging=!1,this.plane?.classList.remove("dragging"),this.#P(),this.#C()}#T(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0}))}#C(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}))}#E(){const Q=this.#N(this.position.y);if(this.cursor)this.cursor.value=`${this.position.x*100}% ${Q*100}%`;if(this.#U&&this.xInput&&this.yInput)this.xInput.setAttribute("value",Math.round(this.position.x*100)),this.yInput.setAttribute("value",Math.round(this.position.y*100))}#P(){const Q=this.value;if(this.getAttribute("value")!==Q)this.#q=!0,this.setAttribute("value",Q),this.#q=!1;this.#S()}#S(){const Q=this.#W,$=Math.round(this.position.x*100)===Math.round(Q.x*100)&&Math.round(this.position.y*100)===Math.round(Q.y*100);this.toggleAttribute("default",$),this.style.setProperty("--is-not-default",$?"0":"1")}#b(){this.position={...this.#W},this.#E(),this.#P(),this.#T(),this.#C()}focus(){this.querySelector(".fig-input-joystick-plane-container")?.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){const $=Q==null?"":String(Q).trim();if(!$)this.position={x:0.5,y:0.5};else{const J=$.split(/[\s,]+/).filter(Boolean),Z=(q)=>{if(!q)return 0.5;const K=q.includes("%"),X=Number.parseFloat(q.replace(/%/g,"").trim());if(!Number.isFinite(X))return 0.5;const Y=K||Math.abs(X)>1?X/100:X;return Math.max(0,Math.min(1,Y))},j=Z(J[0]),_=Z(J[1]??J[0]);this.position={x:j,y:_}}if(this.#Y)this.#E(),this.#S()}attributeChangedCallback(Q,$,J){if(Q==="aspect-ratio"){C(this,"--aspect-ratio",J);return}if(Q==="value"){if(this.#q||this.isDragging)return;this.value=J}if(Q==="precision")this.precision=parseInt(J);if(Q==="transform")this.transform=Number(J);if(Q==="fields"&&J!==$)this.#B(),this.#M(),this.#G(),this.#E();if(Q==="axis-labels"&&J!==$)this.#B(),this.#M(),this.#G(),this.#E();if(Q==="coordinates")this.coordinates=J||"screen",this.#E()}}customElements.define("fig-joystick",I0);class y0 extends HTMLElement{#$;#Q;#J=null;#j;#_;#Z;#K;#X;#q;constructor(){super();this.angle=0,this.#$=1,this.#Q=0,this.isDragging=!1,this.isShiftHeld=!1,this.handle=null,this.angleInput=null,this.plane=null,this.units="\xB0",this.min=null,this.max=null,this.dial=!0,this.showRotations=!1,this.rotationSpan=null,this.#j=this.#D.bind(this),this.#_=this.#b.bind(this),this.#Z=this.#y.bind(this),this.#K=this.#I.bind(this),this.#X=this.#v.bind(this),this.#q=this.#k.bind(this)}connectedCallback(){requestAnimationFrame(()=>{this.precision=this.getAttribute("precision")||1,this.precision=parseInt(this.precision),this.text=this.getAttribute("text")==="true";let Q=this.getAttribute("units")||"\xB0";if(Q==="deg")Q="\xB0";if(this.units=Q,this.min=this.hasAttribute("min")?Number(this.getAttribute("min")):null,this.max=this.hasAttribute("max")?Number(this.getAttribute("max")):null,this.dial=this.#Y("dial",!0),this.showRotations=this.#N(),this.#W(),this.#R(),this.#S(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision))})}disconnectedCallback(){this.#F()}#W(){this.innerHTML=this.#U()}#Y(Q,$=!1){const J=this.getAttribute(Q);if(J===null)return $;const Z=J.trim().toLowerCase();if(Z===""||Z==="true")return!0;if(Z==="false")return!1;return!0}#N(){if(this.hasAttribute("rotations"))return this.#Y("rotations",!1);if(this.hasAttribute("show-rotations"))return this.#Y("show-rotations",!1);return!1}#U(){const Q=this.#O(),$=this.min!==null?`min="${this.min}"`:"",J=this.max!==null?`max="${this.max}"`:"";return`
|
|
278
279
|
${this.dial?`<div class="fig-input-angle-plane" tabindex="0">
|
|
279
280
|
<div class="fig-input-angle-handle"></div>
|
|
280
281
|
</div>`:""}
|
|
@@ -287,38 +288,39 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
287
288
|
units="${this.units}">
|
|
288
289
|
${this.showRotations?'<span slot="append" class="fig-input-angle-rotations"></span>':""}
|
|
289
290
|
</fig-input-number>`:""}
|
|
290
|
-
`}#j(){const Q=Math.abs(this.#G(this.angle));return Math.floor(Q/360)}#X(){if(!this.rotationSpan)return;const Q=this.#j();if(Q>1)this.rotationSpan.textContent=`\xD7${Q}`,this.rotationSpan.style.display="";else this.rotationSpan.textContent="",this.rotationSpan.style.display="none"}#Y(){switch(this.units){case"rad":return 0.01;case"turn":return 0.001;default:return 0.1}}#G(Q){switch(this.units){case"rad":return Q*180/Math.PI;case"turn":return Q*360;default:return Q}}#U(Q){switch(this.units){case"rad":return Q*Math.PI/180;case"turn":return Q/360;default:return Q}}#O(Q,$,J){let Z;switch($){case"rad":Z=Q*180/Math.PI;break;case"turn":Z=Q*360;break;default:Z=Q}switch(J){case"rad":return Z*Math.PI/180;case"turn":return Z/360;default:return Z}}#L(){if(this.handle=this.querySelector(".fig-input-angle-handle"),this.plane=this.querySelector(".fig-input-angle-plane"),this.angleInput=this.querySelector("fig-input-number[name='angle']"),this.rotationSpan=this.querySelector(".fig-input-angle-rotations"),this.#X(),this.plane?.addEventListener("mousedown",this.#f.bind(this)),this.plane?.addEventListener("touchstart",this.#T.bind(this)),window.addEventListener("keydown",this.#H.bind(this)),window.addEventListener("keyup",this.#P.bind(this)),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#B.bind(this));this.addEventListener("change",this.#Z,!0)}#M(){if(this.plane?.removeEventListener("mousedown",this.#f),this.plane?.removeEventListener("touchstart",this.#T),window.removeEventListener("keydown",this.#H),window.removeEventListener("keyup",this.#P),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#B);this.removeEventListener("change",this.#Z,!0)}#N(Q){if(!Q.target?.matches?.("input"))return;const J=Q.target.value.match(/^(-?\d*\.?\d+)\s*(turn|rad|deg|°)$/i);if(J){const Z=parseFloat(J[1]);let j=J[2].toLowerCase();if(j==="deg")j="\xB0";if(j!==this.units){const _=this.#O(Z,j,this.units);Q.target.value=String(_)}}}#B(Q){Q.stopPropagation(),this.angle=Number(Q.target.value),this.#R(),this.#A(),this.#X(),this.#F(),this.#z()}#R(){const $=this.#G(this.angle)*Math.PI/180;this.#Q=Math.cos($),this.#J=Math.sin($)}#D(Q){if(!this.isShiftHeld)return Q;const $=45;return Math.round(Q/$)*$}#E(Q){const $=this.plane.getBoundingClientRect(),J=$.left+$.width/2,Z=$.top+$.height/2,j=Q.clientX-J,_=Q.clientY-Z;return Math.atan2(_,j)*180/Math.PI}#k(Q){let J=(this.#E(Q)%360+360)%360;if(J=this.#D(J),this.min!==null||this.max!==null)this.angle=this.#U(J);else if(this.#$===null){this.#$=J;const _=(this.#G(this.angle)%360+360)%360;let K=J-_;if(K>180)K-=360;if(K<-180)K+=360;this.angle+=this.#U(K)}else{let j=J-this.#$;if(j>180)j-=360;if(j<-180)j+=360;this.angle+=this.#U(j),this.#$=J}if(this.#R(),this.#A(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#X(),this.#F()}#F(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0}))}#z(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}))}#A(){if(this.handle){const $=this.#G(this.angle)*Math.PI/180,J=this.plane.offsetWidth/2-this.handle.offsetWidth/2,Z=Math.cos($)*J,j=Math.sin($)*J;this.handle.style.transform=`translate(${Z}px, ${j}px)`}}#f(Q){this.isDragging=!0,this.#$=null,this.#k(Q);const $=(Z)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#k(Z)},J=()=>{this.isDragging=!1,this.#$=null,this.plane.classList.remove("dragging"),window.removeEventListener("mousemove",$),window.removeEventListener("mouseup",J),this.#z()};window.addEventListener("mousemove",$),window.addEventListener("mouseup",J)}#T(Q){Q.preventDefault(),this.isDragging=!0,this.#$=null,this.#k(Q.touches[0]);const $=(Z)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#k(Z.touches[0])},J=()=>{this.isDragging=!1,this.#$=null,this.plane.classList.remove("dragging"),window.removeEventListener("touchmove",$),window.removeEventListener("touchend",J),this.#z()};window.addEventListener("touchmove",$),window.addEventListener("touchend",J)}#H(Q){if(Q.key==="Shift")this.isShiftHeld=!0}#P(Q){if(Q.key==="Shift")this.isShiftHeld=!1}focus(){this.plane?.focus()}static get observedAttributes(){return["value","precision","text","min","max","units","dial","rotations","show-rotations"]}get value(){return this.angle}get adjacent(){return this.#Q}get opposite(){return this.#J}set value(Q){if(isNaN(Q)){console.error("Invalid value: must be a number.");return}if(this.angle=Q,this.#R(),this.#A(),this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#X()}attributeChangedCallback(Q,$,J){switch(Q){case"value":if(this.isDragging)break;this.value=Number(J);break;case"precision":this.precision=parseInt(J);break;case"text":if(J!==$){if(this.text=J?.toLowerCase()==="true",this.isConnected)this.#q(),this.#L(),this.#A()}break;case"dial":if(this.dial=this.#K("dial",!0),this.isConnected)this.#q(),this.#L(),this.#A();break;case"units":{let Z=J||"\xB0";if(Z==="deg")Z="\xB0";if(this.units=Z,this.isConnected)this.#q(),this.#L(),this.#A();break}case"min":if(this.min=J!==null?Number(J):null,this.isConnected)this.#q(),this.#L(),this.#A();break;case"max":if(this.max=J!==null?Number(J):null,this.isConnected)this.#q(),this.#L(),this.#A();break;case"rotations":case"show-rotations":if(this.showRotations=this.#_(),this.isConnected)this.#q(),this.#L(),this.#A();break}}}customElements.define("fig-input-angle",H0);class d extends HTMLElement{connectedCallback(){const Q=this.getAttribute("duration");if(Q)this.style.setProperty("--shimmer-duration",Q)}static get observedAttributes(){return["duration","playing"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(Q,$,J){if(Q==="duration")this.style.setProperty("--shimmer-duration",J||"1.5s")}}customElements.define("fig-shimmer",d);class P0 extends d{}customElements.define("fig-skeleton",P0);class C0 extends HTMLElement{static get observedAttributes(){return["open","visible"]}#Q=null;#J=null;connectedCallback(){requestAnimationFrame(()=>{this.#$()})}disconnectedCallback(){if(this.#Q&&this.#J)this.#Q.removeEventListener("click",this.#J)}#$(){const Q=this.querySelector(":scope > .fig-layer-row");if(!Q)return;if(Q.querySelector(".fig-layer-chevron"))return;this.#Q=document.createElement("span"),this.#Q.className="fig-layer-chevron",Q.prepend(this.#Q),this.#J=this.#Z.bind(this),this.#Q.addEventListener("click",this.#J)}#Z(Q){Q.stopPropagation(),this.open=!this.open}get open(){const Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){const $=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if($!==Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:Q},bubbles:!0}))}get visible(){return this.getAttribute("visible")!=="false"}set visible(Q){const $=this.visible;if(Q)this.setAttribute("visible","true");else this.setAttribute("visible","false");if($!==Q)this.dispatchEvent(new CustomEvent("visibilitychange",{detail:{visible:Q},bubbles:!0}))}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){const Z=J!==null&&J!=="false";this.dispatchEvent(new CustomEvent("openchange",{detail:{open:Z},bubbles:!0}))}if(Q==="visible"){const Z=J!=="false";this.dispatchEvent(new CustomEvent("visibilitychange",{detail:{visible:Z},bubbles:!0}))}}}customElements.define("fig-layer",C0);class S0 extends HTMLElement{#Q=null;#J=null;#$=null;#Z="solid";anchorElement=null;#q="solid";#K="srgb";#_={h:0,s:0,v:85,a:1};#W="hex";#j={type:"linear",angle:0,centerX:50,centerY:50,interpolationSpace:"oklab",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#X={url:null,scaleMode:"fill",scale:50};#Y={url:null,scaleMode:"fill",scale:50};#G={stream:null,snapshot:null};#U={};#O={};#L=null;#M=null;#N=null;#B=null;#R=!1;#D=null;constructor(){super()}static get observedAttributes(){return["value","disabled","alpha","mode","experimental"]}connectedCallback(){this.style.display="contents",requestAnimationFrame(()=>{this.#E(),this.#k(),this.#F()})}disconnectedCallback(){if(this.#D)this.#D(),this.#D=null;if(this.#$)this.#$.close(),this.#$.remove()}#E(){const Q=Array.from(this.children).find(($)=>!$.getAttribute("slot")?.startsWith("mode-"));if(!Q)this.#J=document.createElement("fig-chit"),this.#J.setAttribute("background","#D9D9D9"),this.appendChild(this.#J),this.#Q=this.#J;else if(Q.tagName==="FIG-CHIT")this.#J=Q,this.#Q=Q;else this.#Q=Q,this.#J=null;if(this.#Q.addEventListener("click",($)=>{if(this.hasAttribute("disabled"))return;$.stopPropagation(),$.preventDefault(),this.#A()}),this.#J)requestAnimationFrame(()=>{const $=this.#J.querySelector('input[type="color"]');if($)$.style.pointerEvents="none"})}#k(){const Q=this.getAttribute("value");if(!Q)return;const $=["solid","gradient","image","video","webcam"];try{const J=JSON.parse(Q);if(J.type)this.#q=J.type;if(J.color){if(typeof J.color==="string")this.#_=this.#a(J.color);else if(typeof J.color==="object"&&J.color.h!==void 0)this.#_=J.color}if(J.opacity!==void 0)this.#_.a=J.opacity/100;if(J.colorSpace==="display-p3"||J.colorSpace==="srgb")this.#K=J.colorSpace;if(J.gradient)this.#j=S({...this.#j,...J.gradient});if(J.image)this.#X={...this.#X,...J.image};if(J.video)this.#Y={...this.#Y,...J.video};if(J.type&&!$.includes(J.type)){const{type:Z,...j}=J;this.#O[J.type]=j}}catch(J){if(Q.startsWith("#"))this.#q="solid",this.#_=this.#a(Q)}}#F(){if(!this.#J)return;let Q,$="cover",J="center";switch(this.#q){case"solid":Q=this.#b(this.#_);break;case"gradient":Q=this.#l();break;case"image":if(this.#X.url){Q=`url(${this.#X.url})`;const j=this.#z(this.#X.scaleMode,this.#X.scale);$=j.size,J=j.position}else Q="";break;case"video":if(this.#Y.url){Q=`url(${this.#Y.url})`;const j=this.#z(this.#Y.scaleMode,this.#Y.scale);$=j.size,J=j.position}else Q="";break;default:Q=this.#U[this.#q]?.element?.getAttribute("chit-background")||"#D9D9D9"}if(this.#J.setAttribute("background",Q),this.#J.style.setProperty("--chit-bg-size",$),this.#J.style.setProperty("--chit-bg-position",J),this.#q==="solid")this.#J.setAttribute("alpha",this.#_.a);else this.#J.removeAttribute("alpha")}#z(Q,$){switch(Q){case"fill":return{size:"cover",position:"center"};case"fit":return{size:"contain",position:"center"};case"crop":return{size:"cover",position:"center"};case"tile":return{size:`${$}%`,position:"top left"};default:return{size:"cover",position:"center"}}}#A(){if(!this.#$)this.#f();this.#T(this.#q);const Q=this.#$.querySelector(".fig-fill-picker-gamut");if(Q)Q.value=this.#K;this.#$.open=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#I(),this.#S()})})}#f(){this.#U={},this.querySelectorAll('[slot^="mode-"]').forEach((N)=>{const B=N.getAttribute("slot").slice(5);this.#U[B]={element:N,label:N.getAttribute("label")||B.charAt(0).toUpperCase()+B.slice(1)}}),this.#$=document.createElement("dialog",{is:"fig-popup"}),this.#$.setAttribute("is","fig-popup"),this.#$.setAttribute("drag","true"),this.#$.setAttribute("handle","fig-header"),this.#$.setAttribute("autoresize","false"),this.#$.classList.add("fig-fill-picker-dialog"),this.#$.anchor=this.anchorElement||this.#Q;const Q=this.getAttribute("dialog-position")||"left";this.#$.setAttribute("position",Q);const $=["solid","gradient","image","video","webcam"],J={solid:"Solid",gradient:"Gradient",image:"Image",video:"Video",webcam:"Webcam"},Z=this.getAttribute("mode");let j;if(Z){if(j=Z.split(",").map((B)=>B.trim().toLowerCase()).filter((B)=>$.includes(B)||this.#U[B]),j.length===0)j=[...$]}else j=[...$];const _={...J};for(let[N,{label:B}]of Object.entries(this.#U))_[N]=B;if(!j.includes(this.#q))this.#q=j[0],this.#Z=j[0];const K=this.getAttribute("experimental"),q=K?`experimental="${K}"`:"";let X;if(j.length===1)X=`<h3 class="fig-fill-picker-type-label">${_[j[0]]}</h3>`;else{const N=j.map((B)=>`<option value="${B}">${_[B]}</option>`).join("\n ");X=`<fig-dropdown class="fig-fill-picker-type" ${q} value="${this.#q}">
|
|
291
|
-
${
|
|
292
|
-
</fig-dropdown>`}const
|
|
291
|
+
`}#M(){const Q=Math.abs(this.#G(this.angle));return Math.floor(Q/360)}#L(){if(!this.rotationSpan)return;const Q=this.#M();if(Q>1)this.rotationSpan.textContent=`\xD7${Q}`,this.rotationSpan.style.display="";else this.rotationSpan.textContent="",this.rotationSpan.style.display="none"}#O(){switch(this.units){case"rad":return 0.01;case"turn":return 0.001;default:return 0.1}}#G(Q){switch(this.units){case"rad":return Q*180/Math.PI;case"turn":return Q*360;default:return Q}}#B(Q){switch(this.units){case"rad":return Q*Math.PI/180;case"turn":return Q/360;default:return Q}}#z(Q,$,J){let Z;switch($){case"rad":Z=Q*180/Math.PI;break;case"turn":Z=Q*360;break;default:Z=Q}switch(J){case"rad":return Z*Math.PI/180;case"turn":return Z/360;default:return Z}}#R(){if(this.handle=this.querySelector(".fig-input-angle-handle"),this.plane=this.querySelector(".fig-input-angle-plane"),this.angleInput=this.querySelector("fig-input-number[name='angle']"),this.rotationSpan=this.querySelector(".fig-input-angle-rotations"),this.#L(),this.plane?.addEventListener("mousedown",this.#_),this.plane?.addEventListener("touchstart",this.#Z),window.addEventListener("keydown",this.#K),window.addEventListener("keyup",this.#X),this.text&&this.angleInput)this.angleInput.addEventListener("input",this.#q);this.addEventListener("change",this.#j,!0)}#F(){if(this.plane?.removeEventListener("mousedown",this.#_),this.plane?.removeEventListener("touchstart",this.#Z),window.removeEventListener("keydown",this.#K),window.removeEventListener("keyup",this.#X),this.text&&this.angleInput)this.angleInput.removeEventListener("input",this.#q);this.removeEventListener("change",this.#j,!0)}#D(Q){if(!Q.target?.matches?.("input"))return;const J=Q.target.value.match(/^(-?\d*\.?\d+)\s*(turn|rad|deg|°)$/i);if(J){const Z=parseFloat(J[1]);let j=J[2].toLowerCase();if(j==="deg")j="\xB0";if(j!==this.units){const _=this.#z(Z,j,this.units);Q.target.value=String(_)}}}#k(Q){Q.stopPropagation(),this.angle=Number(Q.target.value),this.#H(),this.#S(),this.#L(),this.#E(),this.#P()}#H(){const $=this.#G(this.angle)*Math.PI/180;this.#$=Math.cos($),this.#Q=Math.sin($)}#A(Q){if(!this.isShiftHeld)return Q;const $=45;return Math.round(Q/$)*$}#T(Q){const $=this.plane.getBoundingClientRect(),J=$.left+$.width/2,Z=$.top+$.height/2,j=Q.clientX-J,_=Q.clientY-Z;return Math.atan2(_,j)*180/Math.PI}#C(Q){let J=(this.#T(Q)%360+360)%360;if(J=this.#A(J),this.min!==null||this.max!==null)this.angle=this.#B(J);else if(this.#J===null){this.#J=J;const _=(this.#G(this.angle)%360+360)%360;let q=J-_;if(q>180)q-=360;if(q<-180)q+=360;this.angle+=this.#B(q)}else{let j=J-this.#J;if(j>180)j-=360;if(j<-180)j+=360;this.angle+=this.#B(j),this.#J=J}if(this.#H(),this.#S(),this.text&&this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#L(),this.#E()}#E(){this.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0}))}#P(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0}))}#S(){if(this.handle){const $=this.#G(this.angle)*Math.PI/180,J=this.plane.offsetWidth/2-this.handle.offsetWidth/2,Z=Math.cos($)*J,j=Math.sin($)*J;this.handle.style.transform=`translate(${Z}px, ${j}px)`}}#b(Q){this.isDragging=!0,this.#J=null,this.#C(Q);const $=(Z)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#C(Z)},J=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("mousemove",$),window.removeEventListener("mouseup",J),this.#P()};window.addEventListener("mousemove",$),window.addEventListener("mouseup",J)}#y(Q){Q.preventDefault(),this.isDragging=!0,this.#J=null,this.#C(Q.touches[0]);const $=(Z)=>{if(this.plane.classList.add("dragging"),this.isDragging)this.#C(Z.touches[0])},J=()=>{this.isDragging=!1,this.#J=null,this.plane.classList.remove("dragging"),window.removeEventListener("touchmove",$),window.removeEventListener("touchend",J),this.#P()};window.addEventListener("touchmove",$),window.addEventListener("touchend",J)}#I(Q){if(Q.key==="Shift")this.isShiftHeld=!0}#v(Q){if(Q.key==="Shift")this.isShiftHeld=!1}focus(){this.plane?.focus()}static get observedAttributes(){return["value","precision","text","min","max","units","dial","rotations","show-rotations"]}get value(){return this.angle}get adjacent(){return this.#$}get opposite(){return this.#Q}set value(Q){if(isNaN(Q)){console.error("Invalid value: must be a number.");return}if(this.angle=Q,this.#H(),this.#S(),this.angleInput)this.angleInput.setAttribute("value",this.angle.toFixed(this.precision));this.#L()}attributeChangedCallback(Q,$,J){switch(Q){case"value":if(this.isDragging)break;this.value=Number(J);break;case"precision":this.precision=parseInt(J);break;case"text":if(J!==$){if(this.text=J?.toLowerCase()==="true",this.isConnected)this.#W(),this.#R(),this.#S()}break;case"dial":if(this.dial=this.#Y("dial",!0),this.isConnected)this.#W(),this.#R(),this.#S();break;case"units":{let Z=J||"\xB0";if(Z==="deg")Z="\xB0";if(this.units=Z,this.isConnected)this.#W(),this.#R(),this.#S();break}case"min":if(this.min=J!==null?Number(J):null,this.isConnected)this.#W(),this.#R(),this.#S();break;case"max":if(this.max=J!==null?Number(J):null,this.isConnected)this.#W(),this.#R(),this.#S();break;case"rotations":case"show-rotations":if(this.showRotations=this.#N(),this.isConnected)this.#W(),this.#R(),this.#S();break}}}customElements.define("fig-input-angle",y0);class t extends HTMLElement{connectedCallback(){const Q=this.getAttribute("duration");if(Q)this.style.setProperty("--shimmer-duration",Q)}static get observedAttributes(){return["duration","playing"]}get playing(){return this.getAttribute("playing")!=="false"}set playing(Q){if(Q)this.removeAttribute("playing");else this.setAttribute("playing","false")}attributeChangedCallback(Q,$,J){if(Q==="duration")this.style.setProperty("--shimmer-duration",J||"1.5s")}}customElements.define("fig-shimmer",t);class x0 extends t{}customElements.define("fig-skeleton",x0);class V0 extends HTMLElement{static get observedAttributes(){return["open","visible"]}#$=null;#Q=null;connectedCallback(){requestAnimationFrame(()=>{this.#J()})}disconnectedCallback(){if(this.#$&&this.#Q)this.#$.removeEventListener("click",this.#Q)}#J(){const Q=this.querySelector(":scope > .fig-layer-row");if(!Q)return;if(Q.querySelector(".fig-layer-chevron"))return;this.#$=document.createElement("span"),this.#$.className="fig-layer-chevron",Q.prepend(this.#$),this.#Q=this.#j.bind(this),this.#$.addEventListener("click",this.#Q)}#j(Q){Q.stopPropagation(),this.open=!this.open}get open(){const Q=this.getAttribute("open");return Q!==null&&Q!=="false"}set open(Q){const $=this.open;if(Q)this.setAttribute("open","true");else this.setAttribute("open","false");if($!==Q)this.dispatchEvent(new CustomEvent("openchange",{detail:{open:Q},bubbles:!0}))}get visible(){return this.getAttribute("visible")!=="false"}set visible(Q){const $=this.visible;if(Q)this.setAttribute("visible","true");else this.setAttribute("visible","false");if($!==Q)this.dispatchEvent(new CustomEvent("visibilitychange",{detail:{visible:Q},bubbles:!0}))}attributeChangedCallback(Q,$,J){if($===J)return;if(Q==="open"){const Z=J!==null&&J!=="false";this.dispatchEvent(new CustomEvent("openchange",{detail:{open:Z},bubbles:!0}))}if(Q==="visible"){const Z=J!=="false";this.dispatchEvent(new CustomEvent("visibilitychange",{detail:{visible:Z},bubbles:!0}))}}}customElements.define("fig-layer",V0);class c extends HTMLElement{#$=null;#Q=null;#J=null;#j="solid";anchorElement=null;#_="solid";#Z="srgb";#K={h:0,s:0,v:85,a:1};#X="hex";#q={type:"linear",angle:0,centerX:50,centerY:50,interpolationSpace:"oklab",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#W={url:null,scaleMode:"fill",scale:50};#Y={url:null,scaleMode:"fill",scale:50};#N={stream:null,snapshot:null};#U={};#M={};#L=null;#O=null;#G=null;#B=null;#z=!1;#R=null;#F=null;#D=null;constructor(){super()}static get observedAttributes(){return["value","disabled","alpha","mode","experimental"]}connectedCallback(){this.style.display="contents",requestAnimationFrame(()=>{this.#k(),this.#H(),this.#A()})}disconnectedCallback(){if(this.#R)this.#R(),this.#R=null;if(this.#F)this.#F.disconnect(),this.#F=null;if(this.#D)this.#D.disconnect(),this.#D=null;if(this.#N.stream)this.#N.stream.getTracks().forEach((Q)=>Q.stop()),this.#N.stream=null;if(this.#Y.url&&this.#Y.url.startsWith("blob:"))URL.revokeObjectURL(this.#Y.url);if(this.#Q)this.#Q.removeAttribute("selected");if(this.#J)this.#J.close(),this.#J.remove(),this.#J=null}#k(){const Q=Array.from(this.children).find(($)=>!$.getAttribute("slot")?.startsWith("mode-"));if(!Q)this.#Q=document.createElement("fig-chit"),this.#Q.setAttribute("background","#D9D9D9"),this.appendChild(this.#Q),this.#$=this.#Q;else if(Q.tagName==="FIG-CHIT")this.#Q=Q,this.#$=Q;else this.#$=Q,this.#Q=null;if(this.#$.addEventListener("click",($)=>{if(this.hasAttribute("disabled"))return;$.stopPropagation(),$.preventDefault(),this.#C()}),this.#Q)requestAnimationFrame(()=>{const $=this.#Q.querySelector('input[type="color"]');if($)$.style.pointerEvents="none"})}#H(){const Q=this.getAttribute("value");if(!Q)return;const $=["solid","gradient","image","video","webcam"];try{const J=JSON.parse(Q);if(J.type)this.#_=J.type;if(J.color){if(typeof J.color==="string")this.#K=this.#J0(J.color);else if(typeof J.color==="object"&&J.color.h!==void 0)this.#K=J.color}if(J.opacity!==void 0)this.#K.a=J.opacity/100;if(J.colorSpace==="display-p3"||J.colorSpace==="srgb")this.#Z=J.colorSpace;if(J.gradient)this.#q=y({...this.#q,...J.gradient});if(J.image)this.#W={...this.#W,...J.image};if(J.video)this.#Y={...this.#Y,...J.video};if(J.type&&!$.includes(J.type)){const{type:Z,...j}=J;this.#M[J.type]=j}}catch(J){if(Q.startsWith("#"))this.#_="solid",this.#K=this.#J0(Q)}}#A(){if(!this.#Q)return;let Q,$="cover",J="center";switch(this.#_){case"solid":Q=this.#i(this.#K);break;case"gradient":Q=this.#t();break;case"image":if(this.#W.url){Q=`url(${this.#W.url})`;const j=this.#T(this.#W.scaleMode,this.#W.scale);$=j.size,J=j.position}else Q="";break;case"video":if(this.#Y.url){Q=`url(${this.#Y.url})`;const j=this.#T(this.#Y.scaleMode,this.#Y.scale);$=j.size,J=j.position}else Q="";break;default:Q=this.#U[this.#_]?.element?.getAttribute("chit-background")||"#D9D9D9"}if(this.#Q.setAttribute("background",Q),this.#Q.style.setProperty("--chit-bg-size",$),this.#Q.style.setProperty("--chit-bg-position",J),this.#_==="solid")this.#Q.setAttribute("alpha",this.#K.a);else this.#Q.removeAttribute("alpha")}#T(Q,$){switch(Q){case"fill":return{size:"cover",position:"center"};case"fit":return{size:"contain",position:"center"};case"crop":return{size:"cover",position:"center"};case"tile":return{size:`${$}%`,position:"top left"};default:return{size:"cover",position:"center"}}}#C(){if(!this.#J)this.#E();this.#P(this.#_);const Q=this.#J.querySelector(".fig-fill-picker-gamut");if(Q)Q.value=this.#Z;if(this.#Q)this.#Q.setAttribute("selected","true");this.#J.open=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#y(),this.#I()})})}#E(){this.#U={},this.querySelectorAll('[slot^="mode-"]').forEach((G)=>{const B=G.getAttribute("slot").slice(5);this.#U[B]={element:G,label:G.getAttribute("label")||B.charAt(0).toUpperCase()+B.slice(1)}}),this.#J=document.createElement("dialog",{is:"fig-popup"}),this.#J.setAttribute("is","fig-popup"),this.#J.setAttribute("drag","true"),this.#J.setAttribute("handle","fig-header"),this.#J.setAttribute("autoresize","false"),this.#J.classList.add("fig-fill-picker-dialog"),this.#J.anchor=this.anchorElement||this.#$;const Q=this.getAttribute("dialog-position")||"left";this.#J.setAttribute("position",Q);const $=["solid","gradient","image","video","webcam"],J={solid:"Solid",gradient:"Gradient",image:"Image",video:"Video",webcam:"Webcam"},Z=this.getAttribute("mode");let j;if(Z){if(j=Z.split(",").map((B)=>B.trim().toLowerCase()).filter((B)=>$.includes(B)||this.#U[B]),j.length===0)j=[...$]}else j=[...$];const _={...J};for(let[G,{label:B}]of Object.entries(this.#U))_[G]=B;if(!j.includes(this.#_))this.#_=j[0],this.#j=j[0];const q=this.getAttribute("experimental"),K=q?`experimental="${q}"`:"";let X;if(j.length===1)X=`<h3 class="fig-fill-picker-type-label">${_[j[0]]}</h3>`;else{const G=j.map((B)=>`<option value="${B}">${_[B]}</option>`).join("\n ");X=`<fig-dropdown class="fig-fill-picker-type" ${K} value="${this.#_}">
|
|
292
|
+
${G}
|
|
293
|
+
</fig-dropdown>`}const Y=j.map((G)=>`<div class="fig-fill-picker-tab" data-tab="${G}"></div>`).join("\n "),W=`<fig-dropdown class="fig-fill-picker-gamut" ${K} value="${this.#Z}">
|
|
293
294
|
<option value="srgb">sRGB</option>
|
|
294
295
|
<option value="display-p3">Display P3</option>
|
|
295
|
-
</fig-dropdown>`;this
|
|
296
|
+
</fig-dropdown>`;this.#J.innerHTML=`
|
|
296
297
|
<fig-header>
|
|
297
298
|
${X}
|
|
298
|
-
${
|
|
299
|
+
${W}
|
|
299
300
|
<fig-button icon variant="ghost" class="fig-fill-picker-close">
|
|
300
301
|
<span class="fig-mask-icon" style="--icon: var(--icon-close)"></span>
|
|
301
302
|
</fig-button>
|
|
302
303
|
</fig-header>
|
|
303
304
|
<fig-content>
|
|
304
|
-
${
|
|
305
|
+
${Y}
|
|
305
306
|
</fig-content>
|
|
306
|
-
`,document.body.appendChild(this
|
|
307
|
+
`,document.body.appendChild(this.#J);for(let[G,{element:B}]of Object.entries(this.#U)){const A=this.#J.querySelector(`[data-tab="${G}"]`);if(!A)continue;while(B.firstChild)A.appendChild(B.firstChild);this.dispatchEvent(new CustomEvent("modeready",{bubbles:!0,detail:{mode:G,container:A}}))}const U=this.#J.querySelector(".fig-fill-picker-type");if(U)U.addEventListener("change",(G)=>{this.#P(G.target.value)});const L=this.#J.querySelector(".fig-fill-picker-gamut");if(L){const G=(B)=>{const A=B.currentTarget?.value??B.target?.value??B.detail;if(A&&A!==this.#Z)this.#Z=A,this.#b()};L.addEventListener("input",G),L.addEventListener("change",G)}this.#J.querySelector(".fig-fill-picker-close").addEventListener("click",()=>{this.#J.open=!1});const z=()=>{if(this.#Q)this.#Q.removeAttribute("selected");this.#u()};this.#J.addEventListener("close",z),this.#F=new MutationObserver(()=>{if(!(this.#J.hasAttribute("open")&&this.#J.getAttribute("open")!=="false"))z()}),this.#F.observe(this.#J,{attributes:!0,attributeFilter:["open"]});const M={solid:()=>this.#S(),gradient:()=>this.#j0(),image:()=>this.#_0(),video:()=>this.#c(),webcam:()=>this.#$0()};for(let[G,B]of Object.entries(M))if(!this.#U[G]&&j.includes(G))B();for(let G of Object.keys(this.#U)){if($.includes(G))continue;const B=this.#J.querySelector(`[data-tab="${G}"]`);if(!B)continue;B.addEventListener("input",(A)=>{if(A.target===this)return;if(A.stopPropagation(),A.detail)this.#M[G]=A.detail;this.#f()}),B.addEventListener("change",(A)=>{if(A.target===this)return;if(A.stopPropagation(),A.detail)this.#M[G]=A.detail;this.#u()})}}#P(Q){if(!this.#J?.querySelector(`.fig-fill-picker-tab[data-tab="${Q}"]`))return;this.#j=Q,this.#_=Q;const J=this.#J.querySelector(".fig-fill-picker-type");if(J&&J.value!==Q)J.value=Q;this.#J.querySelectorAll(".fig-fill-picker-tab").forEach((_)=>{if(_.dataset.tab===Q)_.style.display="block";else _.style.display="none"});const j=this.#J.querySelector("fig-content");if(j)j.style.padding=this.#U[Q]?"0":"";if(Q==="gradient")requestAnimationFrame(()=>{this.#x()});this.#A(),this.#f()}#S(){const Q=this.#J.querySelector('[data-tab="solid"]'),$=this.getAttribute("alpha")!=="false",J=this.getAttribute("experimental"),Z=J?`experimental="${J}"`:"",j=localStorage.getItem("figui-color-input-mode");if(j&&["hex","rgb","hsl","hsb","lab","lch"].includes(j))this.#X=j;if(Q.innerHTML=`
|
|
307
308
|
<fig-preview class="fig-fill-picker-color-area">
|
|
308
309
|
<canvas width="200" height="200"></canvas>
|
|
309
310
|
<fig-handle
|
|
310
311
|
drag
|
|
311
312
|
drag-surface=".fig-fill-picker-color-area"
|
|
312
313
|
drag-axes="x,y"
|
|
314
|
+
drag-snapping="modifier"
|
|
313
315
|
></fig-handle>
|
|
314
316
|
</fig-preview>
|
|
315
317
|
<div class="fig-fill-picker-sliders">
|
|
316
318
|
<fig-tooltip text="Sample color"><fig-button icon variant="ghost" class="fig-fill-picker-eyedropper"><span class="fig-mask-icon" style="--icon: var(--icon-eyedropper)"></span></fig-button></fig-tooltip>
|
|
317
|
-
<fig-slider type="hue" variant="neue" min="0" max="360" value="${this.#
|
|
318
|
-
${$?`<fig-slider type="opacity" variant="neue" text="true" units="%" min="0" max="100" value="${this.#
|
|
319
|
+
<fig-slider type="hue" variant="neue" min="0" max="360" value="${this.#K.h}"></fig-slider>
|
|
320
|
+
${$?`<fig-slider type="opacity" variant="neue" text="true" units="%" min="0" max="100" value="${this.#K.a*100}" color="${this.#i(this.#K)}"></fig-slider>`:""}
|
|
319
321
|
</div>
|
|
320
322
|
<fig-field class="fig-fill-picker-inputs" direction="horizontal">
|
|
321
|
-
<fig-dropdown class="fig-fill-picker-input-mode" ${Z} value="${this.#
|
|
323
|
+
<fig-dropdown class="fig-fill-picker-input-mode" ${Z} value="${this.#X}">
|
|
322
324
|
<option value="hex">Hex</option>
|
|
323
325
|
<option value="rgb">RGB</option>
|
|
324
326
|
<option value="hsl">HSL</option>
|
|
@@ -328,7 +330,7 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
328
330
|
</fig-dropdown>
|
|
329
331
|
<span class="fig-fill-picker-input-fields"></span>
|
|
330
332
|
</fig-field>
|
|
331
|
-
`,this.#L=Q.querySelector("canvas"),this.#
|
|
333
|
+
`,this.#L=Q.querySelector("canvas"),this.#O=Q.querySelector("fig-handle"),this.#y(),this.#I(),this.#s(),this.#G=Q.querySelector('fig-slider[type="hue"]'),this.#G.addEventListener("input",(K)=>{this.#K.h=parseFloat(K.target.value),this.#y(),this.#I(),this.#p(),this.#f()}),this.#G.addEventListener("change",()=>{this.#u()}),$)this.#B=Q.querySelector('fig-slider[type="opacity"]'),this.#B.addEventListener("input",(K)=>{this.#K.a=parseFloat(K.target.value)/100,this.#p(),this.#f()}),this.#B.addEventListener("change",()=>{this.#u()});Q.querySelector(".fig-fill-picker-input-mode").addEventListener("input",(K)=>{this.#X=K.target.value,localStorage.setItem("figui-color-input-mode",this.#X),this.#d()}),this.#d();const q=Q.querySelector(".fig-fill-picker-eyedropper");if("EyeDropper"in window)q.addEventListener("click",async()=>{try{const X=await new EyeDropper().open();this.#K={...this.#J0(X.sRGBHex),a:this.#K.a},this.#y(),this.#I(),this.#p(),this.#f()}catch(K){}});else q.setAttribute("disabled",""),q.title="EyeDropper not supported in this browser"}#b(){const Q=this.#J?.querySelector('[data-tab="solid"]');if(Q){const $=Q.querySelector("canvas");if($){const J=document.createElement("canvas");J.width=$.width,J.height=$.height,$.replaceWith(J),this.#L=J,this.#s()}this.#y(),this.#I()}this.#h(),this.#f()}#y(){if(!this.#L&&this.#J)this.#L=this.#J.querySelector('[data-tab="solid"] canvas');if(!this.#L)return;const Q=this.#Z==="display-p3"?"display-p3":"srgb",$=this.#L.getContext("2d",{colorSpace:Q});if(!$)return;const J=this.#L.width,Z=this.#L.height;$.clearRect(0,0,J,Z);const j=this.#K.h,_=this.#Z==="display-p3",q=$.createLinearGradient(0,0,J,0);if(_){q.addColorStop(0,"color(display-p3 1 1 1)");const[X,Y,W]=n0(j,100,50);q.addColorStop(1,`color(display-p3 ${X} ${Y} ${W})`)}else q.addColorStop(0,"#FFFFFF"),q.addColorStop(1,`hsl(${j}, 100%, 50%)`);$.fillStyle=q,$.fillRect(0,0,J,Z);const K=$.createLinearGradient(0,0,0,Z);K.addColorStop(0,"rgba(0,0,0,0)"),K.addColorStop(1,"rgba(0,0,0,1)"),$.fillStyle=K,$.fillRect(0,0,J,Z)}#I(Q=0){if(!this.#O||!this.#L)return;const $=this.#L.getBoundingClientRect();if(($.width===0||$.height===0)&&Q<5){requestAnimationFrame(()=>this.#I(Q+1));return}const J=Math.max(0,Math.min(100,this.#K.s)),Z=Math.max(0,Math.min(100,100-this.#K.v));this.#O.setAttribute("value",`${J}% ${Z}%`),this.#O.setAttribute("color",this.#i({...this.#K,a:1}))}#v(Q,$,J={}){const{updateHandle:Z=!0,emitInput:j=!0,emitChange:_=!1}=J;if(this.#K.s=Math.max(0,Math.min(100,Q*100)),this.#K.v=Math.max(0,Math.min(100,(1-$)*100)),this.#O)this.#O.setAttribute("color",this.#i({...this.#K,a:1}));if(Z)this.#I();if(this.#p(),j)this.#f();if(_)this.#u()}#s(){if(this.#R)this.#R(),this.#R=null;if(!this.#L||!this.#O)return;const Q=this.#L.parentElement||this.#L,$=this.#O;let J=!1;const Z=(Y,W={})=>{const U=Q.getBoundingClientRect();if(U.width===0||U.height===0)return;const L=Math.max(0,Math.min(Y.clientX-U.left,U.width)),z=Math.max(0,Math.min(Y.clientY-U.top,U.height));this.#v(L/U.width,z/U.height,W)},j=(Y)=>{if(Y.button!==0)return;if(Y.target===$||$.contains(Y.target))return;J=!0,this.#z=!0,Q.setPointerCapture(Y.pointerId),Z(Y,{updateHandle:!0,emitInput:!0})},_=(Y)=>{if(!J)return;if(Y.buttons===0){q();return}Z(Y,{updateHandle:!0,emitInput:!0})},q=()=>{if(!J)return;J=!1,this.#z=!1,this.#u()},K=(Y)=>{this.#z=!0;const W=Y.detail?.px,U=Y.detail?.py;if(!Number.isFinite(W)||!Number.isFinite(U))return;$.setAttribute("value",`${W*100}% ${U*100}%`),this.#v(W,U,{updateHandle:!1,emitInput:!0})},X=(Y)=>{const W=Y.detail?.px,U=Y.detail?.py;if(Number.isFinite(W)&&Number.isFinite(U))$.setAttribute("value",`${W*100}% ${U*100}%`),this.#v(W,U,{updateHandle:!1,emitInput:!1});this.#z=!1,this.#u()};Q.addEventListener("pointerdown",j),Q.addEventListener("pointermove",_),Q.addEventListener("pointerup",q),Q.addEventListener("pointercancel",q),Q.addEventListener("lostpointercapture",q),$.addEventListener("input",K),$.addEventListener("change",X),this.#R=()=>{Q.removeEventListener("pointerdown",j),Q.removeEventListener("pointermove",_),Q.removeEventListener("pointerup",q),Q.removeEventListener("pointercancel",q),Q.removeEventListener("lostpointercapture",q),$.removeEventListener("input",K),$.removeEventListener("change",X),this.#z=!1}}#d(){const Q=this.#J?.querySelector(".fig-fill-picker-input-fields");if(!Q)return;const $=(j,_)=>`<fig-tooltip text="${j}">${_}</fig-tooltip>`,J=(j,_,q,K)=>`<fig-input-number class="${j}" min="${_}" max="${q}"${K!=null?` step="${K}"`:""}></fig-input-number>`;let Z;switch(this.#X){case"rgb":Z=`<div class="input-combo">
|
|
332
334
|
${$("Red",J("fig-fill-picker-ci-r",0,255))}
|
|
333
335
|
${$("Green",J("fig-fill-picker-ci-g",0,255))}
|
|
334
336
|
${$("Blue",J("fig-fill-picker-ci-b",0,255))}
|
|
@@ -348,19 +350,19 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
348
350
|
${$("Lightness",J("fig-fill-picker-ci-okl",0,100))}
|
|
349
351
|
${$("Chroma",J("fig-fill-picker-ci-okc",0,0.4,0.001))}
|
|
350
352
|
${$("Hue",J("fig-fill-picker-ci-okh",0,360))}
|
|
351
|
-
</div>`;break;default:Z='<fig-input-text class="fig-fill-picker-ci-hex" placeholder="FFFFFF"></fig-input-text>';break}Q.innerHTML=Z,this.#
|
|
353
|
+
</div>`;break;default:Z='<fig-input-text class="fig-fill-picker-ci-hex" placeholder="FFFFFF"></fig-input-text>';break}Q.innerHTML=Z,this.#l(),requestAnimationFrame(()=>this.#p())}#l(){const Q=this.#J?.querySelector(".fig-fill-picker-input-fields");if(!Q)return;const $=()=>{if(this.#z)return;const j=this.#Z0();if(!j)return;if(this.#K={...j,a:this.#K.a},this.#y(),this.#I(),this.#G)this.#G.setAttribute("value",this.#K.h);this.#f()},J=()=>this.#u();Q.querySelectorAll("fig-input-number, fig-input-text").forEach((j)=>{j.addEventListener("input",$),j.addEventListener("change",J)})}#Z0(){const Q=(J)=>this.#J?.querySelector(`.${J}`),$=(J)=>parseFloat(Q(J)?.value??0);switch(this.#X){case"rgb":return this.#m({r:$("fig-fill-picker-ci-r"),g:$("fig-fill-picker-ci-g"),b:$("fig-fill-picker-ci-b")});case"hsl":{const J=this.#L0({h:$("fig-fill-picker-ci-h"),s:$("fig-fill-picker-ci-s"),l:$("fig-fill-picker-ci-l")});return this.#m(J)}case"hsb":return{h:$("fig-fill-picker-ci-h"),s:$("fig-fill-picker-ci-s"),v:$("fig-fill-picker-ci-v"),a:1};case"lab":{const J=this.#Y0({l:$("fig-fill-picker-ci-okl")/100,a:$("fig-fill-picker-ci-oka"),b:$("fig-fill-picker-ci-okb")});return this.#m(J)}case"lch":{const J=this.#B0({l:$("fig-fill-picker-ci-okl")/100,c:$("fig-fill-picker-ci-okc"),h:$("fig-fill-picker-ci-okh")});return this.#m(J)}default:{const J=Q("fig-fill-picker-ci-hex");if(!J)return null;let Z=J.value.replace(/^#/,"");if(Z.length===3)Z=Z[0]+Z[0]+Z[1]+Z[1]+Z[2]+Z[2];if(Z.length!==6||!/^[0-9a-fA-F]{6}$/.test(Z))return null;return this.#J0(`#${Z}`)}}}#p(){if(!this.#J)return;const Q=this.#i(this.#K),$=this.#o(this.#K),J=(j)=>this.#J.querySelector(`.${j}`),Z=(j,_)=>{const q=J(j);if(q)q.setAttribute("value",_)};switch(this.#X){case"rgb":Z("fig-fill-picker-ci-r",$.r),Z("fig-fill-picker-ci-g",$.g),Z("fig-fill-picker-ci-b",$.b);break;case"hsl":{const j=this.#N0($);Z("fig-fill-picker-ci-h",Math.round(j.h)),Z("fig-fill-picker-ci-s",Math.round(j.s)),Z("fig-fill-picker-ci-l",Math.round(j.l));break}case"hsb":Z("fig-fill-picker-ci-h",Math.round(this.#K.h)),Z("fig-fill-picker-ci-s",Math.round(this.#K.s)),Z("fig-fill-picker-ci-v",Math.round(this.#K.v));break;case"lab":{const j=this.#X0($);Z("fig-fill-picker-ci-okl",Math.round(j.l*100)),Z("fig-fill-picker-ci-oka",+j.a.toFixed(3)),Z("fig-fill-picker-ci-okb",+j.b.toFixed(3));break}case"lch":{const j=this.#G0($);Z("fig-fill-picker-ci-okl",Math.round(j.l*100)),Z("fig-fill-picker-ci-okc",+j.c.toFixed(3)),Z("fig-fill-picker-ci-okh",Math.round(j.h));break}default:Z("fig-fill-picker-ci-hex",Q.replace(/^#/,"").toUpperCase());break}if(this.#B)this.#B.setAttribute("color",Q);this.#A()}#j0(){const Q=this.#J.querySelector('[data-tab="gradient"]'),$=this.getAttribute("experimental"),J=$?`experimental="${$}"`:"";Q.innerHTML=`
|
|
352
354
|
<fig-field class="fig-fill-picker-gradient-header" direction="horizontal">
|
|
353
|
-
<fig-dropdown class="fig-fill-picker-gradient-type" ${J} value="${this.#
|
|
355
|
+
<fig-dropdown class="fig-fill-picker-gradient-type" ${J} value="${this.#q.type}">
|
|
354
356
|
<option value="linear" selected>Linear</option>
|
|
355
357
|
<option value="radial">Radial</option>
|
|
356
358
|
<option value="angular">Angular</option>
|
|
357
359
|
</fig-dropdown>
|
|
358
360
|
<fig-tooltip text="Rotate gradient">
|
|
359
|
-
<fig-input-angle class="fig-fill-picker-gradient-angle" value="${(this.#
|
|
361
|
+
<fig-input-angle class="fig-fill-picker-gradient-angle" value="${(this.#q.angle-90+360)%360}"></fig-input-angle>
|
|
360
362
|
</fig-tooltip>
|
|
361
363
|
<div class="fig-fill-picker-gradient-center input-combo" style="display: none;">
|
|
362
|
-
<fig-input-number min="0" max="100" value="${this.#
|
|
363
|
-
<fig-input-number min="0" max="100" value="${this.#
|
|
364
|
+
<fig-input-number min="0" max="100" value="${this.#q.centerX}" units="%" class="fig-fill-picker-gradient-cx"></fig-input-number>
|
|
365
|
+
<fig-input-number min="0" max="100" value="${this.#q.centerY}" units="%" class="fig-fill-picker-gradient-cy"></fig-input-number>
|
|
364
366
|
</div>
|
|
365
367
|
<fig-tooltip text="Flip gradient">
|
|
366
368
|
<fig-button icon variant="ghost" class="fig-fill-picker-gradient-flip">
|
|
@@ -374,7 +376,7 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
374
376
|
</fig-preview>
|
|
375
377
|
<fig-field class="fig-fill-picker-gradient-interpolation" direction="horizontal">
|
|
376
378
|
<label>Mixing</label>
|
|
377
|
-
<fig-dropdown class="fig-fill-picker-gradient-space" full ${J} value="${this.#
|
|
379
|
+
<fig-dropdown class="fig-fill-picker-gradient-space" full ${J} value="${this.#q.interpolationSpace==="oklch"?`oklch-${this.#q.hueInterpolation||"shorter"}`:this.#q.interpolationSpace}">
|
|
378
380
|
<optgroup label="sRGB">
|
|
379
381
|
<option value="srgb-linear">Linear</option>
|
|
380
382
|
</optgroup>
|
|
@@ -398,23 +400,23 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
398
400
|
</fig-header>
|
|
399
401
|
<div class="fig-fill-picker-gradient-stops-list"></div>
|
|
400
402
|
</div>
|
|
401
|
-
`,this.#
|
|
403
|
+
`,this.#x(),this.#r(Q)}#r(Q){const $=Q.querySelector(".fig-fill-picker-gradient-type"),J=(Y)=>Y.currentTarget?.value??Y.target?.value??Y.detail,Z=(Y)=>{this.#q.type=J(Y),this.#x(),this.#f()};$.addEventListener("input",Z),$.addEventListener("change",Z);const j=Q.querySelector(".fig-fill-picker-gradient-space"),_=(Y)=>{const W=J(Y);let U=W,L="shorter";if(W.startsWith("oklch-"))U="oklch",L=W.slice(6);this.#q=y({...this.#q,interpolationSpace:U,hueInterpolation:L}),this.#x(),this.#f()};j?.addEventListener("input",_),j?.addEventListener("change",_),Q.querySelector(".fig-fill-picker-gradient-angle").addEventListener("input",(Y)=>{const W=parseFloat(Y.target.value)||0;this.#q.angle=(W+90)%360,this.#h(),this.#f()});const K=Q.querySelector(".fig-fill-picker-gradient-cx"),X=Q.querySelector(".fig-fill-picker-gradient-cy");K?.addEventListener("input",(Y)=>{this.#q.centerX=parseFloat(Y.target.value)||50,this.#h(),this.#f()}),X?.addEventListener("input",(Y)=>{this.#q.centerY=parseFloat(Y.target.value)||50,this.#h(),this.#f()}),Q.querySelector(".fig-fill-picker-gradient-flip").addEventListener("click",()=>{this.#q.stops.forEach((Y)=>{Y.position=100-Y.position}),this.#q.stops.sort((Y,W)=>Y.position-W.position),this.#x(),this.#f()}),Q.querySelector(".fig-fill-picker-gradient-add").addEventListener("click",()=>{this.#q.stops.push({position:50,color:"#888888",opacity:100}),this.#q.stops.sort((W,U)=>W.position-U.position),this.#x(),this.#f()})}#x(){if(!this.#J)return;const Q=this.#J.querySelector('[data-tab="gradient"]');if(!Q)return;this.#q=y(this.#q);const $=Q.querySelector(".fig-fill-picker-gradient-angle"),J=Q.querySelector(".fig-fill-picker-gradient-center");if(this.#q.type==="radial")$.style.display="none",J.style.display="flex";else{$.style.display="block",J.style.display="none";const j=(this.#q.angle-90+360)%360;$.setAttribute("value",j)}const Z=Q.querySelector(".fig-fill-picker-gradient-space");if(Z)Z.value=this.#q.interpolationSpace==="oklch"?`oklch-${this.#q.hueInterpolation||"shorter"}`:this.#q.interpolationSpace;this.#h(),this.#e()}#h(){if(!this.#J)return;const Q=this.#J.querySelector(".fig-fill-picker-gradient-preview"),$=this.#J.querySelector(".fig-fill-picker-gradient-bar");if(Q||$){const J=this.#t();if($)$.style.background=J;if(Q)Q.style.background=J}this.#A()}#e(){if(!this.#J)return;const Q=this.#J.querySelector(".fig-fill-picker-gradient-stops-list");if(!Q)return;Q.innerHTML=this.#q.stops.map(($,J)=>`
|
|
402
404
|
<fig-field class="fig-fill-picker-gradient-stop-row" direction="horizontal" data-index="${J}">
|
|
403
405
|
<fig-input-number class="fig-fill-picker-stop-position" min="0" max="100" value="${$.position}" units="%"></fig-input-number>
|
|
404
406
|
<fig-input-color class="fig-fill-picker-stop-color" text="true" alpha="true" picker="figma" picker-dialog-position="right" value="${$.color}"></fig-input-color>
|
|
405
|
-
<fig-button icon variant="ghost" class="fig-fill-picker-stop-remove" ${this.#
|
|
407
|
+
<fig-button icon variant="ghost" class="fig-fill-picker-stop-remove" ${this.#q.stops.length<=2?"disabled":""}>
|
|
406
408
|
<span class="fig-mask-icon" style="--icon: var(--icon-minus)"></span>
|
|
407
409
|
</fig-button>
|
|
408
410
|
</fig-field>
|
|
409
|
-
`).join(""),Q.querySelectorAll(".fig-fill-picker-gradient-stop-row").forEach(($)=>{const J=parseInt($.dataset.index);$.querySelector(".fig-fill-picker-stop-position").addEventListener("input",(_)=>{this.#
|
|
411
|
+
`).join(""),Q.querySelectorAll(".fig-fill-picker-gradient-stop-row").forEach(($)=>{const J=parseInt($.dataset.index);$.querySelector(".fig-fill-picker-stop-position").addEventListener("input",(_)=>{this.#q.stops[J].position=parseFloat(_.target.value)||0,this.#h(),this.#f()});const Z=$.querySelector(".fig-fill-picker-stop-color"),j=Z.querySelector("fig-fill-picker");if(j)j.anchorElement=this.#J;else requestAnimationFrame(()=>{const _=Z.querySelector("fig-fill-picker");if(_)_.anchorElement=this.#J});Z.addEventListener("input",(_)=>{this.#q.stops[J].color=_.target.hexOpaque||_.target.value;const q=parseFloat(_.target.alpha);this.#q.stops[J].opacity=isNaN(q)?100:q,this.#h(),this.#f()}),$.querySelector(".fig-fill-picker-stop-remove").addEventListener("click",()=>{if(this.#q.stops.length>2)this.#q.stops.splice(J,1),this.#x(),this.#f()})})}#V(Q,$=!0){const J=y({...this.#q,interpolationSpace:Q??this.#q.interpolationSpace}),Z=this.#Z==="display-p3",j=J.stops.map((q)=>{return`${Z?this.#U0(q.color,q.opacity/100):this.#W0(q.color,q.opacity/100)} ${q.position}%`}).join(", "),_=$?` ${a0(J)}`:"";switch(J.type){case"linear":return`linear-gradient(${J.angle}deg${_}, ${j})`;case"radial":return`radial-gradient(circle at ${J.centerX}% ${J.centerY}%${_}, ${j})`;case"angular":return`conic-gradient(from ${J.angle}deg${_}, ${j})`;default:return`linear-gradient(${J.angle}deg${_}, ${j})`}}static#w=new Map;#Q0(Q){const $=c.#w.get(Q);if($!==void 0)return $;const J=document.createElement("div");J.style.background=Q;const Z=!!J.style.background;return c.#w.set(Q,Z),Z}#t(){const Q=this.#V(void 0,!0);if(this.#Q0(Q))return Q;const $=this.#V("oklab",!0);if(this.#Q0($))return $;return this.#V("oklab",!1)}#_0(){const Q=this.#J.querySelector('[data-tab="image"]'),$=this.getAttribute("experimental"),J=$?`experimental="${$}"`:"";Q.innerHTML=`
|
|
410
412
|
<fig-field class="fig-fill-picker-media-header" direction="horizontal">
|
|
411
|
-
<fig-dropdown class="fig-fill-picker-scale-mode" ${J} value="${this.#
|
|
413
|
+
<fig-dropdown class="fig-fill-picker-scale-mode" ${J} value="${this.#W.scaleMode}">
|
|
412
414
|
<option value="fill" selected>Fill</option>
|
|
413
415
|
<option value="fit">Fit</option>
|
|
414
416
|
<option value="crop">Crop</option>
|
|
415
417
|
<option value="tile">Tile</option>
|
|
416
418
|
</fig-dropdown>
|
|
417
|
-
<fig-input-number class="fig-fill-picker-scale" min="1" max="200" value="${this.#
|
|
419
|
+
<fig-input-number class="fig-fill-picker-scale" min="1" max="200" value="${this.#W.scale}" units="%" style="display: none;"></fig-input-number>
|
|
418
420
|
</fig-field>
|
|
419
421
|
<div class="fig-fill-picker-media-preview">
|
|
420
422
|
<div class="fig-fill-picker-checkerboard"></div>
|
|
@@ -424,7 +426,7 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
424
426
|
<input type="file" accept="image/*" style="display: none;" />
|
|
425
427
|
</fig-button>
|
|
426
428
|
</div>
|
|
427
|
-
`,this.#
|
|
429
|
+
`,this.#a(Q)}#a(Q){const $=Q.querySelector(".fig-fill-picker-scale-mode"),J=Q.querySelector(".fig-fill-picker-scale"),Z=Q.querySelector(".fig-fill-picker-upload"),j=Q.querySelector('input[type="file"]'),_=Q.querySelector(".fig-fill-picker-image-preview");$.addEventListener("change",(K)=>{this.#W.scaleMode=K.target.value,J.style.display=K.target.value==="tile"?"block":"none",this.#g(_),this.#A(),this.#f()}),J.addEventListener("input",(K)=>{this.#W.scale=parseFloat(K.target.value)||100,this.#g(_),this.#A(),this.#f()}),Z.addEventListener("click",()=>{j.click()}),j.addEventListener("change",(K)=>{const X=K.target.files[0];if(X){const Y=new FileReader;Y.onload=(W)=>{this.#W.url=W.target.result,this.#g(_),this.#A(),this.#f()},Y.readAsDataURL(X)}});const q=Q.querySelector(".fig-fill-picker-media-preview");q.addEventListener("dragover",(K)=>{K.preventDefault(),q.classList.add("dragover")}),q.addEventListener("dragleave",()=>{q.classList.remove("dragover")}),q.addEventListener("drop",(K)=>{K.preventDefault(),q.classList.remove("dragover");const X=K.dataTransfer.files[0];if(X&&X.type.startsWith("image/")){const Y=new FileReader;Y.onload=(W)=>{this.#W.url=W.target.result,this.#g(_),this.#A(),this.#f()},Y.readAsDataURL(X)}})}#g(Q){const $=Q.closest(".fig-fill-picker-media-preview");if(!this.#W.url){Q.style.display="none",$?.classList.remove("has-media");return}switch(Q.style.display="block",$?.classList.add("has-media"),Q.style.backgroundImage=`url(${this.#W.url})`,Q.style.backgroundPosition="center",this.#W.scaleMode){case"fill":Q.style.backgroundSize="cover",Q.style.backgroundRepeat="no-repeat";break;case"fit":Q.style.backgroundSize="contain",Q.style.backgroundRepeat="no-repeat";break;case"crop":Q.style.backgroundSize="cover",Q.style.backgroundRepeat="no-repeat";break;case"tile":Q.style.backgroundSize=`${this.#W.scale}%`,Q.style.backgroundRepeat="repeat",Q.style.backgroundPosition="top left";break}}#n(Q){switch(Q.style.objectPosition="center",Q.style.width="100%",Q.style.height="100%",this.#Y.scaleMode){case"fill":case"crop":Q.style.objectFit="cover";break;case"fit":Q.style.objectFit="contain";break}}#c(){const Q=this.#J.querySelector('[data-tab="video"]'),$=this.getAttribute("experimental"),J=$?`experimental="${$}"`:"";Q.innerHTML=`
|
|
428
430
|
<fig-field class="fig-fill-picker-media-header" direction="horizontal">
|
|
429
431
|
<fig-dropdown class="fig-fill-picker-scale-mode" ${J} value="${this.#Y.scaleMode}">
|
|
430
432
|
<option value="fill" selected>Fill</option>
|
|
@@ -440,7 +442,7 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
440
442
|
<input type="file" accept="video/*" style="display: none;" />
|
|
441
443
|
</fig-button>
|
|
442
444
|
</div>
|
|
443
|
-
`,this.#
|
|
445
|
+
`,this.#q0(Q)}#q0(Q){const $=Q.querySelector(".fig-fill-picker-scale-mode"),J=Q.querySelector(".fig-fill-picker-upload"),Z=Q.querySelector('input[type="file"]'),j=Q.querySelector(".fig-fill-picker-video-preview");$.addEventListener("change",(q)=>{this.#Y.scaleMode=q.target.value,this.#n(j),this.#A(),this.#f()}),J.addEventListener("click",()=>{Z.click()});const _=Q.querySelector(".fig-fill-picker-media-preview");Z.addEventListener("change",(q)=>{const K=q.target.files[0];if(K)this.#Y.url=URL.createObjectURL(K),j.src=this.#Y.url,j.style.display="block",j.play(),_.classList.add("has-media"),this.#n(j),this.#A(),this.#f()}),_.addEventListener("dragover",(q)=>{q.preventDefault(),_.classList.add("dragover")}),_.addEventListener("dragleave",()=>{_.classList.remove("dragover")}),_.addEventListener("drop",(q)=>{q.preventDefault(),_.classList.remove("dragover");const K=q.dataTransfer.files[0];if(K&&K.type.startsWith("video/"))this.#Y.url=URL.createObjectURL(K),j.src=this.#Y.url,j.style.display="block",j.play(),_.classList.add("has-media"),this.#n(j),this.#A(),this.#f()})}#$0(){const Q=this.#J.querySelector('[data-tab="webcam"]'),$=this.getAttribute("experimental"),J=$?`experimental="${$}"`:"";Q.innerHTML=`
|
|
444
446
|
<div class="fig-fill-picker-webcam-preview">
|
|
445
447
|
<div class="fig-fill-picker-checkerboard"></div>
|
|
446
448
|
<video class="fig-fill-picker-webcam-video" autoplay muted playsinline></video>
|
|
@@ -455,7 +457,7 @@ var h0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var g0={};var a=h0(()=>{/*! Vendored from @u
|
|
|
455
457
|
Capture
|
|
456
458
|
</fig-button>
|
|
457
459
|
</fig-field>
|
|
458
|
-
`,this.#K0(Q)}#K0(Q){const $=Q.querySelector(".fig-fill-picker-webcam-video"),J=Q.querySelector(".fig-fill-picker-webcam-status"),Z=Q.querySelector(".fig-fill-picker-webcam-capture"),j=Q.querySelector(".fig-fill-picker-camera-select"),_=async(q=null)=>{try{const
|
|
459
|
-
<fig-fill-picker mode="solid"
|
|
460
|
-
<fig-chit background="${
|
|
461
|
-
</fig-fill-picker>`,this.#Q=this.querySelector("fig-fill-picker"),this.#J=this.querySelector("fig-chit"),this.#q(),this.#Q?.addEventListener("input",this.#$),this.#Q?.addEventListener("change",this.#Z)}#_(Q){if(!Q)return"#D9D9D9";const $=Q.replace("#","").trim();if($.length===3||$.length===4){const[J,Z,j]=$;return`#${J}${J}${Z}${Z}${j}${j}`.toUpperCase()}if($.length===6||$.length===8)return`#${$.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#W(Q){if(!Q)return"#D9D9D9";const $=String(Q).trim();if($.startsWith("{"))try{const J=JSON.parse($);if(J?.color)return this.#W(J.color)}catch{}if($.startsWith("#"))return this.#_($);try{const J=document.createElement("canvas").getContext("2d");if(!J)return"#D9D9D9";J.fillStyle=$;const Z=J.fillStyle;if(Z.startsWith("#"))return this.#_(Z);const j=Z.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){const _=(K)=>Math.max(0,Math.min(255,Number(K))).toString(16).padStart(2,"0");return`#${_(j[1])}${_(j[2])}${_(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#j(){const Q=this.#W(this.getAttribute("value"));if(this.getAttribute("value")!==Q){this.setAttribute("value",Q);return}if(this.#Q)if(this.#Q.setAttribute("value",JSON.stringify({type:"solid",color:Q})),this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled");if(this.#J){if(this.#J.setAttribute("background",Q),this.hasAttribute("selected"))this.#J.setAttribute("selected","");else this.#J.removeAttribute("selected");if(this.hasAttribute("disabled"))this.#J.setAttribute("disabled","");else this.#J.removeAttribute("disabled")}}#X(Q,$){const J=this.#W(Q?.color),Z=this.#W(this.getAttribute("value"));if(J!==Z)this.setAttribute("value",J);else this.#j();this.dispatchEvent(new CustomEvent($,{bubbles:!0,cancelable:!0,composed:!0,detail:{color:this.value}}))}#Y(Q){Q.stopPropagation(),this.#X(Q.detail,"input")}#G(Q){Q.stopPropagation(),this.#X(Q.detail,"change")}attributeChangedCallback(Q,$,J){if($===J)return;if(!this.isConnected)return;switch(Q){case"value":case"selected":case"disabled":this.#j();break}}get value(){return this.#W(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#W(Q))}get selected(){return this.hasAttribute("selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return this.hasAttribute("disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}customElements.define("fig-color-tip",f0);class I0 extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false"),this.hasAttribute("disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false");if(Q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}customElements.define("fig-choice",I0);class y0 extends HTMLElement{#Q=null;#J=this.#M.bind(this);#$=this.#N.bind(this);#Z=this.#R.bind(this);#q=null;#K=null;#_=null;#W=null;#j=null;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","drag","overflow","loop"]}get#X(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#Y(){const Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#G(){return this.getAttribute("choice-element")||"fig-choice"}get choices(){return Array.from(this.querySelectorAll(this.#G))}get selectedChoice(){return this.#Q}set selectedChoice(Q){if(Q&&!this.contains(Q))return;const $=this.choices;for(let Z of $){const j=Z===Q,_=Z.hasAttribute("selected");if(j&&!_)Z.setAttribute("selected","");else if(!j&&_)Z.removeAttribute("selected")}this.#Q=Q;const J=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==J){if(J)this.setAttribute("value",J)}this.#T(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(){this.setAttribute("role","listbox"),this.addEventListener("click",this.#J),this.addEventListener("keydown",this.#$),this.addEventListener("scroll",this.#Z),this.#F(),this.#E(),this.#H(),this.#D(),requestAnimationFrame(()=>{this.#U(),this.#R()})}disconnectedCallback(){this.removeEventListener("click",this.#J),this.removeEventListener("keydown",this.#$),this.removeEventListener("scroll",this.#Z),this.#k(),this.#q?.disconnect(),this.#q=null,this.#K?.disconnect(),this.#K=null,this.#z()}attributeChangedCallback(Q,$,J){if(Q==="value"&&J!==$&&J)this.#O(J);if(Q==="disabled"){const Z=J!==null&&J!=="false",j=this.choices;for(let _ of j)if(Z)_.setAttribute("aria-disabled","true"),_.setAttribute("tabindex","-1");else _.removeAttribute("aria-disabled"),_.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#U());if(Q==="drag")if(this.#Y)this.#E();else this.#k();if(Q==="overflow")this.#F()}#U(){const Q=this.choices;if(!Q.length){this.#Q=null;return}const $=this.getAttribute("value");if($&&this.#O($))return;const J=Q.find((Z)=>Z.hasAttribute("selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=Q[0]}#O(Q){const $=this.choices;for(let J of $)if(J.getAttribute("value")===Q)return this.selectedChoice=J,!0;return!1}#L(Q){const $=this.#G;let J=Q;while(J&&J!==this){if(J.matches($))return J;J=J.parentElement}return null}#M(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;const $=this.#L(Q.target);if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.selectedChoice=$,this.#B()}#N(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;const $=this.choices.filter((_)=>!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false");if(!$.length)return;const J=$.indexOf(this.#Q);let Z=J;const j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),J<$.length-1)Z=J+1;else if(j)Z=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),J>0)Z=J-1;else if(j)Z=$.length-1;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#G)){const _=this.#L(document.activeElement);if(_&&_!==this.#Q)this.selectedChoice=_,this.#B()}return;default:return}if(Z!==J&&$[Z])this.selectedChoice=$[Z],$[Z].focus(),this.#B()}#B(){const Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#R(){if(this.#X==="scrollbar")return;const Q=this.getAttribute("layout")==="horizontal",$=2;if(Q){const J=this.scrollLeft<=$,Z=this.scrollLeft+this.clientWidth>=this.scrollWidth-$;this.classList.toggle("overflow-start",!J),this.classList.toggle("overflow-end",!Z)}else{const J=this.scrollTop<=$,Z=this.scrollTop+this.clientHeight>=this.scrollHeight-$;this.classList.toggle("overflow-start",!J),this.classList.toggle("overflow-end",!Z)}}#D(){this.#K?.disconnect(),this.#K=new ResizeObserver(()=>{this.#R()}),this.#K.observe(this)}#E(){if(this.#j?.bound)return;if(!this.#Y)return;const Q=(_)=>{if(_.button!==0)return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#j.active=!0,this.#j.didDrag=!1,this.#j.startX=_.clientX,this.#j.startY=_.clientY,this.#j.scrollLeft=this.scrollLeft,this.#j.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},$=(_)=>{if(!this.#j.active)return;const K=this.getAttribute("layout")==="horizontal",q=_.clientX-this.#j.startX,X=_.clientY-this.#j.startY;if(!this.#j.didDrag&&Math.abs(K?q:X)>3)this.#j.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(_.pointerId);if(!this.#j.didDrag)return;if(K)this.scrollLeft=this.#j.scrollLeft-q;else this.scrollTop=this.#j.scrollTop-X},J=(_)=>{if(!this.#j.active)return;const K=this.#j.didDrag;if(this.#j.active=!1,this.#j.didDrag=!1,this.style.cursor="",this.style.userSelect="",_.pointerId!==void 0)try{this.releasePointerCapture(_.pointerId)}catch{}if(K)_.preventDefault(),_.stopPropagation()},Z=(_)=>{if(this.#j?.suppressClick)_.stopPropagation(),_.preventDefault(),this.#j.suppressClick=!1},j=(_)=>{if(this.#j?.didDrag)this.#j.suppressClick=!0,setTimeout(()=>{if(this.#j)this.#j.suppressClick=!1},0)};this.#j={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:Q,onPointerMove:$,onPointerUp:J,onClick:Z,onPointerUpCapture:j},this.addEventListener("pointerdown",Q),window.addEventListener("pointermove",$),window.addEventListener("pointerup",J),this.addEventListener("pointerup",j,!0),this.addEventListener("click",Z,!0)}#k(){if(!this.#j?.bound)return;this.removeEventListener("pointerdown",this.#j.onPointerDown),window.removeEventListener("pointermove",this.#j.onPointerMove),window.removeEventListener("pointerup",this.#j.onPointerUp),this.removeEventListener("pointerup",this.#j.onPointerUpCapture,!0),this.removeEventListener("click",this.#j.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#j=null}#F(){if(this.#X==="scrollbar")this.#z();else this.#A()}#z(){this.#_?.remove(),this.#W?.remove(),this.#_=null,this.#W=null,this.classList.remove("overflow-start","overflow-end")}#A(){if(this.#_)return;this.#_=document.createElement("button"),this.#_.className="fig-chooser-nav-start",this.#_.setAttribute("tabindex","-1"),this.#_.setAttribute("aria-label","Scroll back"),this.#W=document.createElement("button"),this.#W.className="fig-chooser-nav-end",this.#W.setAttribute("tabindex","-1"),this.#W.setAttribute("aria-label","Scroll forward"),this.#_.addEventListener("pointerdown",(Q)=>{Q.stopPropagation(),this.#f(-1)}),this.#W.addEventListener("pointerdown",(Q)=>{Q.stopPropagation(),this.#f(1)}),this.prepend(this.#_),this.append(this.#W)}#f(Q){const $=this.getAttribute("layout")==="horizontal",Z=($?this.clientWidth:this.clientHeight)*0.8*Q;this.scrollBy({[$?"left":"top"]:Z,behavior:"smooth"})}#T(Q){if(!Q)return;requestAnimationFrame(()=>{const $=this.scrollHeight>this.clientHeight,J=this.scrollWidth>this.clientWidth;if(!J&&!$)return;const Z={behavior:"smooth"};if($){const j=Q.offsetTop-this.clientHeight/2+Q.offsetHeight/2;Z.top=j}if(J){const j=Q.offsetLeft-this.clientWidth/2+Q.offsetWidth/2;Z.left=j}this.scrollTo(Z)})}#H(){this.#q?.disconnect(),this.#q=new MutationObserver(()=>{const Q=this.choices;if(this.#Q&&!Q.includes(this.#Q))this.#Q=null,this.#U();else if(!this.#Q&&Q.length)this.#U()}),this.#q.observe(this,{childList:!0,subtree:!0})}}customElements.define("fig-chooser",y0);class x0 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value"];#Q=!1;#J=null;#$=!1;get#Z(){const Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#q(){const Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#K(){const Q=this.getAttribute("drag-snapping");if(Q===null)return"false";const $=Q.trim().toLowerCase();if($==="modifier")return"modifier";if($===""||$==="true")return"true";return"false"}#_(Q){const $=this.#K;if($==="true")return!0;if($==="modifier")return!!Q;return!1}#W(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}#j(Q,$){if(Math.abs(Q-$)<0.1){const Z=(Q+$)/2;return{x:Z,y:Z}}if(Math.abs(1-Q-$)<0.1)return{x:Q,y:1-Q};return{x:Q,y:$}}#X(){const Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){const Q=this.#X();if(!Q)return"0% 0%";const $=Q.getBoundingClientRect(),J=this.offsetWidth/2,Z=this.offsetHeight/2,j=parseFloat(this.style.left)||0,_=parseFloat(this.style.top)||0,K=$.width>0?(j+J)/$.width*100:0,q=$.height>0?(_+Z)/$.height*100:0;return`${Math.round(K)}% ${Math.round(q)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#Y(Q){const $=Q==null?"":String(Q).trim();if(!$)return{xPct:0,yPct:0};const J=$.split(/[\s,]+/).filter(Boolean),Z=(K)=>{if(!K)return 0;const q=K.includes("px"),X=K.includes("%"),W=parseFloat(K.replace(/[%px]/g,""));if(!Number.isFinite(W))return 0;if(q)return{px:W};if(X||Math.abs(W)>1)return Math.max(0,Math.min(100,W));return Math.max(0,Math.min(100,W*100))},j=Z(J[0]),_=Z(J[1]??J[0]);return{xToken:j,yToken:_}}#G(Q){const $=this.#X();if(!$)return;const{xToken:J,yToken:Z}=this.#Y(Q),j=$.getBoundingClientRect(),_=this.offsetWidth/2,K=this.offsetHeight/2,q=(W,Y,U)=>{if(W&&typeof W==="object"&&"px"in W)return Math.max(-U,Math.min(Y-U,W.px-U));const F=(typeof W==="number"?W:0)/100*Y;return Math.max(-U,Math.min(Y-U,F-U))},X=this.#q;if(X.x)this.style.left=`${q(J,j.width,_)}px`;if(X.y)this.style.top=`${q(Z,j.height,K)}px`}#U(){this.#$=!0,this.setAttribute("value",this.value),this.#$=!1}connectedCallback(){this.#M(),this.addEventListener("pointerdown",this.#O),document.addEventListener("pointerdown",this.#L);const Q=this.getAttribute("value");if(Q)this.#G(Q)}disconnectedCallback(){this.#N(),this.removeEventListener("pointerdown",this.#O),document.removeEventListener("pointerdown",this.#L)}#O=(Q)=>{if(Q.stopPropagation(),this.hasAttribute("disabled"))return;this.setAttribute("selected","")};#L=()=>{this.removeAttribute("selected")};attributeChangedCallback(Q,$,J){if(Q==="color")if(!J||J==="false")this.style.removeProperty("--fill");else this.style.setProperty("--fill",J);if(Q==="drag")this.#M();if(Q==="value"&&!this.#$&&!this.#Q)this.#G(J)}#M(){if(this.#Z&&!this.#J)this.#J=(Q)=>this.#B(Q),this.addEventListener("pointerdown",this.#J);else if(!this.#Z&&this.#J)this.#N()}#N(){if(this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#Q=!1}#B(Q){if(!this.#Z||this.hasAttribute("disabled"))return;Q.preventDefault();const $=this.#X();if(!$)return;this.#Q=!0;const J=this.#q,Z=$.getBoundingClientRect(),j=this.offsetWidth,_=this.offsetHeight,K=(W,Y,U=!1)=>{const L=$.getBoundingClientRect(),F=parseFloat(this.style.left)||0,N=parseFloat(this.style.top)||0,B=W-L.left-j/2,O=Y-L.top-_/2,H=Math.max(-j/2,Math.min(L.width-j/2,B)),D=Math.max(-_/2,Math.min(L.height-_/2,O));let R=L.width>0?((J.x?H:F)+j/2)/L.width:0.5,E=L.height>0?((J.y?D:N)+_/2)/L.height:0.5;if(this.#_(U)){if(J.x)R=this.#W(R);if(J.y)E=this.#W(E);if(J.x&&J.y){const z=this.#j(R,E);R=z.x,E=z.y}}if(J.x){const z=R*L.width-j/2;this.style.left=`${Math.max(-j/2,Math.min(L.width-j/2,z))}px`}if(J.y){const z=E*L.height-_/2;this.style.top=`${Math.max(-_/2,Math.min(L.height-_/2,z))}px`}};K(Q.clientX,Q.clientY,Q.shiftKey),this.style.cursor="grabbing",this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.#R(Z)}));const q=(W)=>{if(!this.#Q)return;K(W.clientX,W.clientY,W.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.#R($.getBoundingClientRect())}))},X=(W)=>{this.#Q=!1,this.style.cursor="",window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",X),K(W.clientX,W.clientY,W.shiftKey),this.#U(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#R($.getBoundingClientRect())}))};window.addEventListener("pointermove",q),window.addEventListener("pointerup",X)}#R(Q){const $=this.offsetWidth/2,J=this.offsetHeight/2,Z=parseFloat(this.style.left)||0,j=parseFloat(this.style.top)||0,_=Q.width>0?(Z+$)/Q.width:0,K=Q.height>0?(j+J)/Q.height:0;return{x:Z,y:j,px:_,py:K}}}customElements.define("fig-handle",x0);
|
|
460
|
+
`,this.#K0(Q)}#K0(Q){const $=Q.querySelector(".fig-fill-picker-webcam-video"),J=Q.querySelector(".fig-fill-picker-webcam-status"),Z=Q.querySelector(".fig-fill-picker-webcam-capture"),j=Q.querySelector(".fig-fill-picker-camera-select"),_=async(q=null)=>{try{const K={video:q?{deviceId:{exact:q}}:!0};if(this.#N.stream)this.#N.stream.getTracks().forEach((W)=>W.stop());this.#N.stream=await navigator.mediaDevices.getUserMedia(K),$.srcObject=this.#N.stream,$.style.display="block",J.style.display="none";const Y=(await navigator.mediaDevices.enumerateDevices()).filter((W)=>W.kind==="videoinput");if(Y.length>1)j.style.display="block",j.innerHTML=Y.map((W,U)=>`<option value="${W.deviceId}">${W.label||`Camera ${U+1}`}</option>`).join("")}catch(K){console.error("Webcam error:",K.name,K.message);let X="Camera access denied";if(K.name==="NotAllowedError")X="Camera permission denied";else if(K.name==="NotFoundError")X="No camera found";else if(K.name==="NotReadableError")X="Camera in use by another app";else if(K.name==="OverconstrainedError")X="Camera constraints not supported";else if(!window.isSecureContext)X="Camera requires secure context";J.innerHTML=`<span>${X}</span>`,J.style.display="flex",$.style.display="none"}};this.#D=new MutationObserver(()=>{if(Q.style.display!=="none"&&!this.#N.stream)_()}),this.#D.observe(Q,{attributes:!0,attributeFilter:["style"]}),j.addEventListener("change",(q)=>{_(q.target.value)}),Z.addEventListener("click",()=>{if(!this.#N.stream)return;const q=document.createElement("canvas");q.width=$.videoWidth,q.height=$.videoHeight,q.getContext("2d").drawImage($,0,0),this.#N.snapshot=q.toDataURL("image/png"),this.#W.url=this.#N.snapshot,this.#_="image",this.#A(),this.#f(),this.#P("image");const K=this.#J.querySelector("fig-tabs");K.value="image"})}#o(Q){const $=Q.h/360,J=Q.s/100,Z=Q.v/100;let j,_,q;const K=Math.floor($*6),X=$*6-K,Y=Z*(1-J),W=Z*(1-X*J),U=Z*(1-(1-X)*J);switch(K%6){case 0:j=Z,_=U,q=Y;break;case 1:j=W,_=Z,q=Y;break;case 2:j=Y,_=Z,q=U;break;case 3:j=Y,_=W,q=Z;break;case 4:j=U,_=Y,q=Z;break;case 5:j=Z,_=Y,q=W;break}return{r:Math.round(j*255),g:Math.round(_*255),b:Math.round(q*255)}}#m(Q){const $=Q.r/255,J=Q.g/255,Z=Q.b/255,j=Math.max($,J,Z),_=Math.min($,J,Z),q=j-_;let K=0;const X=j===0?0:q/j,Y=j;if(j!==_){switch(j){case $:K=(J-Z)/q+(J<Z?6:0);break;case J:K=(Z-$)/q+2;break;case Z:K=($-J)/q+4;break}K/=6}return{h:K*360,s:X*100,v:Y*100,a:1}}#i(Q){if(!Q||typeof Q.h!=="number"||typeof Q.s!=="number"||typeof Q.v!=="number")return"#D9D9D9";const $=this.#o(Q),J=(Z)=>{return(isNaN(Z)?217:Math.max(0,Math.min(255,Math.round(Z)))).toString(16).padStart(2,"0")};return`#${J($.r)}${J($.g)}${J($.b)}`}#J0(Q){const $=parseInt(Q.slice(1,3),16),J=parseInt(Q.slice(3,5),16),Z=parseInt(Q.slice(5,7),16);return this.#m({r:$,g:J,b:Z})}#W0(Q,$=1){const J=parseInt(Q.slice(1,3),16),Z=parseInt(Q.slice(3,5),16),j=parseInt(Q.slice(5,7),16);return`rgba(${J}, ${Z}, ${j}, ${$})`}#U0(Q,$=1){const J=+(parseInt(Q.slice(1,3),16)/255).toFixed(4),Z=+(parseInt(Q.slice(3,5),16)/255).toFixed(4),j=+(parseInt(Q.slice(5,7),16)/255).toFixed(4);return`color(display-p3 ${J} ${Z} ${j} / ${$})`}#N0(Q){const $=Q.r/255,J=Q.g/255,Z=Q.b/255,j=Math.max($,J,Z),_=Math.min($,J,Z);let q,K;const X=(j+_)/2;if(j===_)q=K=0;else{const Y=j-_;switch(K=X>0.5?Y/(2-j-_):Y/(j+_),j){case $:q=((J-Z)/Y+(J<Z?6:0))/6;break;case J:q=((Z-$)/Y+2)/6;break;case Z:q=(($-J)/Y+4)/6;break}}return{h:q*360,s:K*100,l:X*100}}#L0(Q){const $=Q.h/360,J=Q.s/100,Z=Q.l/100;let j,_,q;if(J===0)j=_=q=Z;else{const K=(W,U,L)=>{if(L<0)L+=1;if(L>1)L-=1;if(L<0.16666666666666666)return W+(U-W)*6*L;if(L<0.5)return U;if(L<0.6666666666666666)return W+(U-W)*(0.6666666666666666-L)*6;return W},X=Z<0.5?Z*(1+J):Z+J-Z*J,Y=2*Z-X;j=K(Y,X,$+0.3333333333333333),_=K(Y,X,$),q=K(Y,X,$-0.3333333333333333)}return{r:Math.round(j*255),g:Math.round(_*255),b:Math.round(q*255)}}#X0(Q){const $=(U)=>{return U=U/255,U<=0.04045?U/12.92:Math.pow((U+0.055)/1.055,2.4)},J=$(Q.r),Z=$(Q.g),j=$(Q.b),_=0.4122214708*J+0.5363325363*Z+0.0514459929*j,q=0.2119034982*J+0.6806995451*Z+0.1073969566*j,K=0.0883024619*J+0.2817188376*Z+0.6299787005*j,X=Math.cbrt(_),Y=Math.cbrt(q),W=Math.cbrt(K);return{l:0.2104542553*X+0.793617785*Y-0.0040720468*W,a:1.9779984951*X-2.428592205*Y+0.4505937099*W,b:0.0259040371*X+0.7827717662*Y-0.808675766*W}}#G0(Q){const $=this.#X0(Q);return{l:$.l,c:Math.sqrt($.a*$.a+$.b*$.b),h:(Math.atan2($.b,$.a)*180/Math.PI+360)%360}}#Y0(Q){const $=Q.l+0.3963377774*Q.a+0.2158037573*Q.b,J=Q.l-0.1055613458*Q.a-0.0638541728*Q.b,Z=Q.l-0.0894841775*Q.a-1.291485548*Q.b,j=$*$*$,_=J*J*J,q=Z*Z*Z,K=(X)=>{const Y=X<=0.0031308?12.92*X:1.055*Math.pow(X,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,Y))*255)};return{r:K(4.0767416621*j-3.3077115913*_+0.2309699292*q),g:K(-1.2684380046*j+2.6097574011*_-0.3413193965*q),b:K(-0.0041960863*j-0.7034186147*_+1.707614701*q)}}#B0(Q){const $=Q.h*Math.PI/180;return this.#Y0({l:Q.l,a:Q.c*Math.cos($),b:Q.c*Math.sin($)})}#f(){this.#A(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#u(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){const Q={type:this.#_,colorSpace:this.#Z};switch(this.#_){case"solid":return{...Q,color:this.#i(this.#K),alpha:this.#K.a,hsv:{...this.#K}};case"gradient":return{...Q,gradient:o(this.#q),css:this.#t()};case"image":return{...Q,image:{...this.#W}};case"video":return{...Q,video:{...this.#Y}};case"webcam":return{...Q,image:{url:this.#N.snapshot,scaleMode:"fill",scale:50}};default:return{...Q,...this.#M[this.#_]}}}set value(Q){if(typeof Q==="string")this.setAttribute("value",Q);else this.setAttribute("value",JSON.stringify(Q))}attributeChangedCallback(Q,$,J){if($===J)return;switch(Q){case"value":if(this.#H(),this.#A(),this.#J){if(!this.#z){if(this.#I(),this.#p(),this.#G)this.#G.setAttribute("value",this.#K.h);if(this.#B)this.#B.setAttribute("value",this.#K.a*100),this.#B.setAttribute("color",this.#i(this.#K))}}break;case"disabled":break}}}customElements.define("fig-fill-picker",c);class w0 extends HTMLElement{#$=null;#Q=null;#J=this.#L.bind(this);#j=this.#O.bind(this);static get observedAttributes(){return["value","selected","disabled","alpha","control"]}get#_(){return this.getAttribute("control")||"color"}connectedCallback(){this.#q(),this.#U()}disconnectedCallback(){this.#Z(),this.removeEventListener("click",this.#W)}#Z(){if(!this.#$)return;this.#$.removeEventListener("input",this.#J),this.#$.removeEventListener("change",this.#j)}#K=()=>{requestAnimationFrame(()=>{const Q=document.querySelector(".fig-fill-picker-dialog[open]");if(!Q)return;Q.addEventListener("close",()=>this.removeAttribute("selected"),{once:!0})})};get#X(){const Q=this.getAttribute("alpha");return Q===null||Q!=="false"}#q(){const Q=this.#_;if(Q==="add"||Q==="remove"){const Z=Q==="add"?"var(--icon-add)":"var(--icon-minus)";this.innerHTML=`<fig-button icon variant="ghost"><span class="fig-mask-icon" style="--icon: ${Z}"></span></fig-button>`,this.#$=null,this.#Q=null,this.addEventListener("click",this.#W);return}this.removeEventListener("click",this.#W);const $=this.#N(this.getAttribute("value")),J=this.#X?"":'alpha="false"';this.innerHTML=`
|
|
461
|
+
<fig-fill-picker mode="solid" ${J} value='${JSON.stringify({type:"solid",color:$})}'>
|
|
462
|
+
<fig-chit background="${$}"></fig-chit>
|
|
463
|
+
</fig-fill-picker>`,this.#$=this.querySelector("fig-fill-picker"),this.#Q=this.querySelector("fig-chit"),this.#Z(),this.#$?.addEventListener("input",this.#J),this.#$?.addEventListener("change",this.#j),this.#Q?.addEventListener("click",()=>{this.setAttribute("selected",""),this.#K()})}#W=()=>{const Q=this.#_;this.dispatchEvent(new CustomEvent(Q,{bubbles:!0,composed:!0}))};#Y(Q){if(!Q)return"#D9D9D9";const $=Q.replace("#","").trim();if($.length===3||$.length===4){const[J,Z,j]=$;return`#${J}${J}${Z}${Z}${j}${j}`.toUpperCase()}if($.length===6||$.length===8)return`#${$.slice(0,6)}`.toUpperCase();return"#D9D9D9"}#N(Q){if(!Q)return"#D9D9D9";const $=String(Q).trim();if($.startsWith("{"))try{const J=JSON.parse($);if(J?.color)return this.#N(J.color)}catch{}if($.startsWith("#"))return this.#Y($);try{const{ctx:J}=r(1,1);J.fillStyle="#000000",J.fillStyle=$;const Z=J.fillStyle;if(Z.startsWith("#"))return this.#Y(Z);const j=Z.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(j){const _=(q)=>Math.max(0,Math.min(255,Number(q))).toString(16).padStart(2,"0");return`#${_(j[1])}${_(j[2])}${_(j[3])}`.toUpperCase()}}catch{}return"#D9D9D9"}#U(){const Q=this.#N(this.getAttribute("value"));if(this.getAttribute("value")!==Q){this.setAttribute("value",Q);return}if(this.#$){if(this.#$.setAttribute("value",JSON.stringify({type:"solid",color:Q})),this.#X)this.#$.removeAttribute("alpha");else this.#$.setAttribute("alpha","false");if(this.hasAttribute("disabled"))this.#$.setAttribute("disabled","");else this.#$.removeAttribute("disabled")}if(this.#Q)if(this.#Q.setAttribute("background",Q),this.hasAttribute("disabled"))this.#Q.setAttribute("disabled","");else this.#Q.removeAttribute("disabled")}#M(Q,$){const J=this.#N(Q?.color),Z=this.#N(this.getAttribute("value"));if(J!==Z)this.setAttribute("value",J);else this.#U();const j={color:this.value};if(this.#X&&Q?.opacity!==void 0)j.opacity=Q.opacity;this.dispatchEvent(new CustomEvent($,{bubbles:!0,cancelable:!0,composed:!0,detail:j}))}#L(Q){Q.stopPropagation(),this.#M(Q.detail,"input")}#O(Q){Q.stopPropagation(),this.#M(Q.detail,"change")}attributeChangedCallback(Q,$,J){if($===J)return;if(!this.isConnected)return;switch(Q){case"control":this.#q();break;case"value":case"selected":case"disabled":this.#U();break}}get value(){return this.#N(this.getAttribute("value"))}set value(Q){if(Q===null||Q===void 0||Q===""){this.removeAttribute("value");return}this.setAttribute("value",this.#N(Q))}get selected(){return this.hasAttribute("selected")}set selected(Q){this.toggleAttribute("selected",Boolean(Q))}get disabled(){return this.hasAttribute("disabled")}set disabled(Q){this.toggleAttribute("disabled",Boolean(Q))}}customElements.define("fig-color-tip",w0);class b0 extends HTMLElement{static get observedAttributes(){return["selected","disabled"]}connectedCallback(){if(this.setAttribute("role","option"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","0");if(this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false"),this.hasAttribute("disabled"))this.setAttribute("aria-disabled","true")}attributeChangedCallback(Q){if(Q==="selected")this.setAttribute("aria-selected",this.hasAttribute("selected")?"true":"false");if(Q==="disabled")if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")}}customElements.define("fig-choice",b0);class v0 extends HTMLElement{#$=null;#Q=this.#O.bind(this);#J=this.#G.bind(this);#j=this.#z.bind(this);#_=null;#Z=null;#K=null;#X=null;#q=null;constructor(){super()}static get observedAttributes(){return["value","disabled","choice-element","drag","overflow","loop","padding"]}get#W(){return this.getAttribute("overflow")==="scrollbar"?"scrollbar":"buttons"}get#Y(){const Q=this.getAttribute("drag");return Q===null||Q!=="false"}get#N(){return this.getAttribute("choice-element")||"fig-choice"}get choices(){return Array.from(this.querySelectorAll(this.#N))}get selectedChoice(){return this.#$}set selectedChoice(Q){if(Q&&!this.contains(Q))return;const $=this.choices;for(let Z of $){const j=Z===Q,_=Z.hasAttribute("selected");if(j&&!_)Z.setAttribute("selected","");else if(!j&&_)Z.removeAttribute("selected")}this.#$=Q;const J=Q?.getAttribute("value")??"";if(this.getAttribute("value")!==J){if(J)this.setAttribute("value",J)}this.#C(Q)}get value(){return this.#$?.getAttribute("value")??""}set value(Q){if(Q===null||Q===void 0||Q==="")return;this.setAttribute("value",String(Q))}connectedCallback(){this.setAttribute("role","listbox"),this.addEventListener("click",this.#Q),this.addEventListener("keydown",this.#J),this.addEventListener("scroll",this.#j),this.#k(),this.#F(),this.#E(),this.#R(),requestAnimationFrame(()=>{this.#U(),this.#z()})}disconnectedCallback(){this.removeEventListener("click",this.#Q),this.removeEventListener("keydown",this.#J),this.removeEventListener("scroll",this.#j),this.#D(),this.#_?.disconnect(),this.#_=null,this.#Z?.disconnect(),this.#Z=null,this.#H()}attributeChangedCallback(Q,$,J){if(Q==="value"&&J!==$&&J)this.#M(J);if(Q==="disabled"){const Z=J!==null&&J!=="false",j=this.choices;for(let _ of j)if(Z)_.setAttribute("aria-disabled","true"),_.setAttribute("tabindex","-1");else _.removeAttribute("aria-disabled"),_.setAttribute("tabindex","0")}if(Q==="choice-element")requestAnimationFrame(()=>this.#U());if(Q==="drag")if(this.#Y)this.#F();else this.#D();if(Q==="overflow")this.#k()}#U(){const Q=this.choices;if(!Q.length){this.#$=null;return}const $=this.getAttribute("value");if($&&this.#M($))return;const J=Q.find((Z)=>Z.hasAttribute("selected"));if(J){this.selectedChoice=J;return}this.selectedChoice=Q[0]}#M(Q){const $=this.choices;for(let J of $)if(J.getAttribute("value")===Q)return this.selectedChoice=J,!0;return!1}#L(Q){const $=this.#N;let J=Q;while(J&&J!==this){if(J.matches($))return J;J=J.parentElement}return null}#O(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;const $=this.#L(Q.target);if(!$)return;if($.hasAttribute("disabled")&&$.getAttribute("disabled")!=="false")return;this.selectedChoice=$,this.#B()}#G(Q){if(this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false")return;const $=this.choices.filter((_)=>!_.hasAttribute("disabled")||_.getAttribute("disabled")==="false");if(!$.length)return;const J=$.indexOf(this.#$);let Z=J;const j=this.hasAttribute("loop");switch(Q.key){case"ArrowDown":case"ArrowRight":if(Q.preventDefault(),J<$.length-1)Z=J+1;else if(j)Z=0;break;case"ArrowUp":case"ArrowLeft":if(Q.preventDefault(),J>0)Z=J-1;else if(j)Z=$.length-1;break;case"Home":Q.preventDefault(),Z=0;break;case"End":Q.preventDefault(),Z=$.length-1;break;case"Enter":case" ":if(Q.preventDefault(),document.activeElement?.matches(this.#N)){const _=this.#L(document.activeElement);if(_&&_!==this.#$)this.selectedChoice=_,this.#B()}return;default:return}if(Z!==J&&$[Z])this.selectedChoice=$[Z],$[Z].focus(),this.#B()}#B(){const Q=this.value;this.dispatchEvent(new CustomEvent("input",{detail:Q,bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:Q,bubbles:!0}))}#z(){if(this.#W==="scrollbar")return;const Q=this.getAttribute("layout")==="horizontal",$=2;if(Q){const J=this.scrollLeft<=$,Z=this.scrollLeft+this.clientWidth>=this.scrollWidth-$;this.classList.toggle("overflow-start",!J),this.classList.toggle("overflow-end",!Z)}else{const J=this.scrollTop<=$,Z=this.scrollTop+this.clientHeight>=this.scrollHeight-$;this.classList.toggle("overflow-start",!J),this.classList.toggle("overflow-end",!Z)}}#R(){this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#z()}),this.#Z.observe(this)}#F(){if(this.#q?.bound)return;if(!this.#Y)return;const Q=(_)=>{if(_.button!==0)return;if(!(this.getAttribute("layout")==="horizontal"?this.scrollWidth>this.clientWidth:this.scrollHeight>this.clientHeight))return;this.#q.active=!0,this.#q.didDrag=!1,this.#q.startX=_.clientX,this.#q.startY=_.clientY,this.#q.scrollLeft=this.scrollLeft,this.#q.scrollTop=this.scrollTop,this.style.cursor="grab",this.style.userSelect="none"},$=(_)=>{if(!this.#q.active)return;const q=this.getAttribute("layout")==="horizontal",K=_.clientX-this.#q.startX,X=_.clientY-this.#q.startY;if(!this.#q.didDrag&&Math.abs(q?K:X)>3)this.#q.didDrag=!0,this.style.cursor="grabbing",this.setPointerCapture(_.pointerId);if(!this.#q.didDrag)return;if(q)this.scrollLeft=this.#q.scrollLeft-K;else this.scrollTop=this.#q.scrollTop-X},J=(_)=>{if(!this.#q.active)return;const q=this.#q.didDrag;if(this.#q.active=!1,this.#q.didDrag=!1,this.style.cursor="",this.style.userSelect="",_.pointerId!==void 0)try{this.releasePointerCapture(_.pointerId)}catch{}if(q)_.preventDefault(),_.stopPropagation()},Z=(_)=>{if(this.#q?.suppressClick)_.stopPropagation(),_.preventDefault(),this.#q.suppressClick=!1},j=(_)=>{if(this.#q?.didDrag)this.#q.suppressClick=!0,setTimeout(()=>{if(this.#q)this.#q.suppressClick=!1},0)};this.#q={active:!1,didDrag:!1,suppressClick:!1,startX:0,startY:0,scrollLeft:0,scrollTop:0,bound:!0,onPointerDown:Q,onPointerMove:$,onPointerUp:J,onClick:Z,onPointerUpCapture:j},this.addEventListener("pointerdown",Q),window.addEventListener("pointermove",$),window.addEventListener("pointerup",J),this.addEventListener("pointerup",j,!0),this.addEventListener("click",Z,!0)}#D(){if(!this.#q?.bound)return;this.removeEventListener("pointerdown",this.#q.onPointerDown),window.removeEventListener("pointermove",this.#q.onPointerMove),window.removeEventListener("pointerup",this.#q.onPointerUp),this.removeEventListener("pointerup",this.#q.onPointerUpCapture,!0),this.removeEventListener("click",this.#q.onClick,!0),this.style.cursor="",this.style.userSelect="",this.#q=null}#k(){if(this.#W==="scrollbar")this.#H();else this.#A()}#H(){this.#K?.remove(),this.#X?.remove(),this.#K=null,this.#X=null,this.classList.remove("overflow-start","overflow-end")}#A(){if(this.#K)return;this.#K=document.createElement("button"),this.#K.className="fig-chooser-nav-start",this.#K.setAttribute("tabindex","-1"),this.#K.setAttribute("aria-label","Scroll back"),this.#X=document.createElement("button"),this.#X.className="fig-chooser-nav-end",this.#X.setAttribute("tabindex","-1"),this.#X.setAttribute("aria-label","Scroll forward"),this.#K.addEventListener("pointerdown",(Q)=>{Q.stopPropagation(),this.#T(-1)}),this.#X.addEventListener("pointerdown",(Q)=>{Q.stopPropagation(),this.#T(1)}),this.prepend(this.#K),this.append(this.#X)}#T(Q){const $=this.getAttribute("layout")==="horizontal",Z=($?this.clientWidth:this.clientHeight)*0.8*Q;this.scrollBy({[$?"left":"top"]:Z,behavior:"smooth"})}#C(Q){if(!Q)return;requestAnimationFrame(()=>{const $=this.scrollHeight>this.clientHeight,J=this.scrollWidth>this.clientWidth;if(!J&&!$)return;const Z={behavior:"smooth"};if($){const j=Q.offsetTop-this.clientHeight/2+Q.offsetHeight/2;Z.top=j}if(J){const j=Q.offsetLeft-this.clientWidth/2+Q.offsetWidth/2;Z.left=j}this.scrollTo(Z)})}#E(){this.#_?.disconnect(),this.#_=new MutationObserver(()=>{const Q=this.choices;if(this.#$&&!Q.includes(this.#$))this.#$=null,this.#U();else if(!this.#$&&Q.length)this.#U()}),this.#_.observe(this,{childList:!0,subtree:!0})}}customElements.define("fig-chooser",v0);class h0 extends HTMLElement{static observedAttributes=["color","selected","disabled","drag","drag-surface","drag-axes","drag-snapping","value","type","control"];#$=!1;#Q=!1;#J=null;#j=!1;#_=null;get#Z(){return this.getAttribute("control")||null}get#K(){return this.#Z==="add"||this.#Z==="remove"}get#X(){return this.classList.contains("fig-input-gradient-ghost")}get#q(){const Q=this.getAttribute("drag");return Q!==null&&Q!=="false"}get#W(){const Q=(this.getAttribute("drag-axes")||"x,y").toLowerCase();return{x:Q.includes("x"),y:Q.includes("y")}}get#Y(){const Q=this.getAttribute("drag-snapping");if(Q===null)return"false";const $=Q.trim().toLowerCase();if($==="modifier")return"modifier";if($===""||$==="true")return"true";return"false"}#N(Q){const $=this.#Y;if($==="true")return!0;if($==="modifier")return!!Q;return!1}#U(Q){if(Q<0.1)return 0;if(Q>0.9)return 1;if(Q>0.4&&Q<0.6)return 0.5;return Q}#M(Q,$){if(Math.abs(Q-$)<0.1){const Z=(Q+$)/2;return{x:Z,y:Z}}if(Math.abs(1-Q-$)<0.1)return{x:Q,y:1-Q};return{x:Q,y:$}}#L(){const Q=this.getAttribute("drag-surface");if(!Q||Q==="parent")return this.parentElement;return this.closest(Q)}get value(){const Q=this.#L();if(!Q)return"0% 0%";const $=Q.getBoundingClientRect(),J=this.offsetWidth/2,Z=this.offsetHeight/2,j=parseFloat(this.style.left)||0,_=parseFloat(this.style.top)||0,q=$.width>0?(j+J)/$.width*100:0,K=$.height>0?(_+Z)/$.height*100:0;return`${Math.round(q)}% ${Math.round(K)}%`}set value(Q){this.setAttribute("value",Q??"0% 0%")}#O(Q){const $=Q==null?"":String(Q).trim();if(!$)return{xPct:0,yPct:0};const J=$.split(/[\s,]+/).filter(Boolean),Z=(q)=>{if(!q)return 0;const K=q.includes("px"),X=q.includes("%"),Y=parseFloat(q.replace(/[%px]/g,""));if(!Number.isFinite(Y))return 0;if(K)return{px:Y};if(X||Math.abs(Y)>1)return Math.max(0,Math.min(100,Y));return Math.max(0,Math.min(100,Y*100))},j=Z(J[0]),_=Z(J[1]??J[0]);return{xToken:j,yToken:_}}#G(Q){const $=this.#L();if(!$)return;const{xToken:J,yToken:Z}=this.#O(Q),j=$.getBoundingClientRect(),_=this.offsetWidth/2,q=this.offsetHeight/2,K=(Y,W,U)=>{if(Y&&typeof Y==="object"&&"px"in Y)return Math.max(-U,Math.min(W-U,Y.px-U));const z=(typeof Y==="number"?Y:0)/100*W;return Math.max(-U,Math.min(W-U,z-U))},X=this.#W;if(X.x)this.style.left=`${Math.round(K(J,j.width,_))}px`;if(X.y)this.style.top=`${Math.round(K(Z,j.height,q))}px`}#B(){this.#j=!0,this.setAttribute("value",this.value),this.#j=!1}connectedCallback(){this.#D(),this.addEventListener("click",this.#z),document.addEventListener("pointerdown",this.#R),document.addEventListener("keydown",this.#F);const Q=this.getAttribute("value");if(Q)this.#G(Q);if(this.#K&&!this.#X)this.#A()}disconnectedCallback(){this.#k(),this.#T(),this.removeEventListener("click",this.#z),document.removeEventListener("pointerdown",this.#R),document.removeEventListener("keydown",this.#F)}select(){if(this.hasAttribute("disabled"))return;if(this.setAttribute("selected",""),this.getAttribute("type")==="color"&&!this.#$)this.#A()}deselect(){this.removeAttribute("selected"),this.#T()}#z=(Q)=>{if(this.#K)return;if(this.#Q){this.#Q=!1;return}this.select()};#R=(Q)=>{if(this.#K)return;if(this.contains(Q.target))return;if(this.#_&&Q.target.closest?.("dialog, [popover]"))return;this.deselect()};#F=(Q)=>{if(Q.key!=="Enter")return;if(!this.hasAttribute("selected"))return;if(this.getAttribute("type")!=="color")return;if(this.#_)return;Q.preventDefault(),this.#A()};attributeChangedCallback(Q,$,J){if(Q==="color"){if(!J||J==="false"||J==="true")this.style.removeProperty("--fill");else this.style.setProperty("--fill",J);if(this.#_&&J)this.#_.setAttribute("value",J)}if(Q==="drag")this.#D();if(Q==="value"&&!this.#j&&!this.#$)this.#G(J);if(Q==="control"&&!this.#X)if(this.#K)this.#T(),this.#A();else this.#T()}#D(){if(this.#q&&!this.#J)this.#J=(Q)=>this.#H(Q),this.addEventListener("pointerdown",this.#J);else if(!this.#q&&this.#J)this.#k()}#k(){if(this.#J)this.removeEventListener("pointerdown",this.#J),this.#J=null;this.#$=!1}#H(Q){if(!this.#q||this.hasAttribute("disabled"))return;Q.preventDefault();const $=this.#L();if(!$)return;this.#$=!0;const J=this.#W,Z=this.offsetWidth,j=this.offsetHeight;let _=null;const q=(Y,W,U=!1)=>{const L=$.getBoundingClientRect();_=L;const z=parseFloat(this.style.left)||0,M=parseFloat(this.style.top)||0,G=Y-L.left-Z/2,B=W-L.top-j/2,A=Math.max(-Z/2,Math.min(L.width-Z/2,G)),F=Math.max(-j/2,Math.min(L.height-j/2,B));let R=L.width>0?((J.x?A:z)+Z/2)/L.width:0.5,T=L.height>0?((J.y?F:M)+j/2)/L.height:0.5;if(this.#N(U)){if(J.x)R=this.#U(R);if(J.y)T=this.#U(T);if(J.x&&J.y){const k=this.#M(R,T);R=k.x,T=k.y}}if(J.x){const k=R*L.width-Z/2;this.style.left=`${Math.round(Math.max(-Z/2,Math.min(L.width-Z/2,k)))}px`}if(J.y){const k=T*L.height-j/2;this.style.top=`${Math.round(Math.max(-j/2,Math.min(L.height-j/2,k)))}px`}},K=(Y)=>{if(!this.#$)return;if(!this.#Q){if(this.classList.add("dragging"),this.style.cursor="grabbing",!this.hasAttribute("selected"))this.select()}this.#Q=!0,q(Y.clientX,Y.clientY,Y.shiftKey),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{...this.#S(_),shiftKey:Y.shiftKey}}))},X=(Y)=>{if(this.#$=!1,this.style.cursor="",this.classList.remove("dragging"),window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",X),this.#Q){q(Y.clientX,Y.clientY,Y.shiftKey),this.#B(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.#S(_)}));const W=(U)=>{U.stopPropagation(),U.preventDefault()};this.addEventListener("click",W,{capture:!0,once:!0})}else this.#B();this.#Q=!1};window.addEventListener("pointermove",K),window.addEventListener("pointerup",X)}showColorTip(){if(this.#_){this.#_.style.display="";return}this.#A()}hideColorTip(){if(!this.#_)return;this.#_.style.display="none"}#A(){if(this.#_)return;const Q=document.createElement("fig-color-tip");if(this.#K)Q.setAttribute("control",this.#Z);else Q.setAttribute("value",this.getAttribute("color")||"#D9D9D9"),Q.setAttribute("alpha","true"),Q.setAttribute("selected","");Q.addEventListener("input",this.#C),Q.addEventListener("change",this.#E),Q.addEventListener("add",this.#P),Q.addEventListener("remove",this.#P),this.appendChild(Q),this.#_=Q}#T(){if(!this.#_)return;this.#_.removeEventListener("input",this.#C),this.#_.removeEventListener("change",this.#E),this.#_.removeEventListener("add",this.#P),this.#_.removeEventListener("remove",this.#P),this.#_.remove(),this.#_=null}#C=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",Q.detail.color)};#E=(Q)=>{if(Q.stopPropagation(),Q.detail?.color)this.setAttribute("color",Q.detail.color)};#P=(Q)=>{Q.stopPropagation(),this.dispatchEvent(new CustomEvent(Q.type,{bubbles:!0,composed:!0}))};#S(Q){const $=this.offsetWidth/2,J=this.offsetHeight/2,Z=parseFloat(this.style.left)||0,j=parseFloat(this.style.top)||0,_=Q.width>0?(Z+$)/Q.width:0,q=Q.height>0?(j+J)/Q.height:0;return{x:Z,y:j,px:_,py:q}}}customElements.define("fig-handle",h0);
|